jpfun 1.0.0 → 1.2.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 (83) hide show
  1. package/README.md +1 -1
  2. package/dist/diagnostic.d.ts +1 -0
  3. package/dist/diagnostic.js +1 -0
  4. package/dist/functions/ASTtypes.d.ts +2 -3
  5. package/dist/functions/ASTtypes.js +2 -3
  6. package/dist/functions/adjust/index.js +15 -67
  7. package/dist/functions/bar/index.js +11 -7
  8. package/dist/functions/beam/auto.js +15 -11
  9. package/dist/functions/beam/layout.js +22 -48
  10. package/dist/functions/br/index.d.ts +9 -3
  11. package/dist/functions/br/index.js +20 -16
  12. package/dist/functions/dash/index.js +13 -11
  13. package/dist/functions/default.js +2 -1
  14. package/dist/functions/div/index.d.ts +2 -2
  15. package/dist/functions/div/index.js +5 -9
  16. package/dist/functions/dot/index.js +5 -9
  17. package/dist/functions/dyn/index.js +125 -53
  18. package/dist/functions/gliss/index.js +81 -7
  19. package/dist/functions/grace/index.d.ts +3 -10
  20. package/dist/functions/grace/index.js +25 -57
  21. package/dist/functions/head/index.js +6 -7
  22. package/dist/functions/key/index.js +1 -0
  23. package/dist/functions/meter/index.js +7 -5
  24. package/dist/functions/note/index.d.ts +5 -2
  25. package/dist/functions/note/index.js +162 -19
  26. package/dist/functions/note/source-transform.d.ts +8 -2
  27. package/dist/functions/note/source-transform.js +25 -11
  28. package/dist/functions/ottava/index.js +8 -7
  29. package/dist/functions/page/index.d.ts +1 -36
  30. package/dist/functions/page/index.js +11 -15
  31. package/dist/functions/pagebreak/index.js +2 -1
  32. package/dist/functions/rest/index.js +5 -5
  33. package/dist/functions/set/index.js +2 -2
  34. package/dist/functions/stack/index.js +7 -7
  35. package/dist/functions/symbol/symbols/dynamics.d.ts +3 -0
  36. package/dist/functions/symbol/symbols/dynamics.js +10 -1
  37. package/dist/functions/tempo/index.js +8 -3
  38. package/dist/functions/temporal.d.ts +21 -6
  39. package/dist/functions/temporal.js +1 -1
  40. package/dist/functions/text/index.js +3 -5
  41. package/dist/functions/up/index.js +37 -34
  42. package/dist/functions/voice/connections.js +2 -2
  43. package/dist/functions/voice/lyrics.d.ts +2 -0
  44. package/dist/functions/voice/lyrics.js +4 -4
  45. package/dist/functions/voice/voice.d.ts +2 -1
  46. package/dist/functions/voice/voice.js +9 -15
  47. package/dist/functions/voice/voices.d.ts +6 -4
  48. package/dist/functions/voice/voices.js +10 -10
  49. package/dist/index.d.ts +6 -34
  50. package/dist/index.js +6 -34
  51. package/dist/jpfun.min.js +49 -46
  52. package/dist/layout/engine.js +237 -232
  53. package/dist/layout/model.d.ts +1 -1
  54. package/dist/layout/page.d.ts +2 -2
  55. package/dist/layout/page.js +8 -22
  56. package/dist/layout/types.d.ts +4 -5
  57. package/dist/lowering/accidentalMemory.d.ts +33 -0
  58. package/dist/lowering/accidentalMemory.js +84 -0
  59. package/dist/lowering/loweringContext.d.ts +12 -7
  60. package/dist/lowering/loweringContext.js +54 -51
  61. package/dist/lowering/types.d.ts +2 -3
  62. package/dist/parser/grammarType.d.ts +10 -4
  63. package/dist/parser/parse-utils/brace-utils.js +4 -3
  64. package/dist/parser/parse-utils/call-utils.js +7 -7
  65. package/dist/parser/parse-utils/string-utils.d.ts +1 -1
  66. package/dist/parser/parse-utils/string-utils.js +1 -1
  67. package/dist/parser/parserContext.d.ts +30 -34
  68. package/dist/parser/parserContext.js +77 -181
  69. package/dist/parser/preprocess.js +10 -23
  70. package/dist/parser/syntax.d.ts +9 -0
  71. package/dist/parser/syntax.js +109 -0
  72. package/dist/parser/types.d.ts +2 -1
  73. package/dist/pipeline.js +3 -2
  74. package/dist/playback/compile.js +26 -18
  75. package/dist/playback/event.d.ts +1 -2
  76. package/dist/playback/event.js +2 -3
  77. package/dist/playback/types.d.ts +0 -1
  78. package/dist/render/index.d.ts +1 -0
  79. package/dist/render/index.js +1 -0
  80. package/grammar.md +8 -6
  81. package/package.json +2 -2
  82. package/dist/functions/voice/index.d.ts +0 -2
  83. package/dist/functions/voice/index.js +0 -2
package/dist/jpfun.min.js CHANGED
@@ -1,103 +1,106 @@
1
1
  /*! jpfun | Apache-2.0 | github.com/madderscientist/jpFun */
2
- "use strict";(()=>{var yi=Object.defineProperty;var fi=(a,e)=>{for(var t in e)yi(a,t,{get:e[t],enumerable:!0})};var qa={};fi(qa,{ANCHOR_KEY:()=>Q,ASTBraceNode:()=>re,ASTFunctionNode:()=>E,ASTLabelNode:()=>it,ASTNodeBase:()=>be,ASTTextNode:()=>pe,AdjustNode:()=>lo,ArpeggioNode:()=>wo,BRACKET_HOOK_COMMANDS:()=>Qn,BRACKET_HOOK_DROP:()=>Oe,BRACKET_HOOK_REACH:()=>Ee,BarNode:()=>ko,BeamNode:()=>Go,BoxNode:()=>Wo,BrNode:()=>Qt,CODA_MARK:()=>Wn,CURVED_BRACE_BOUNDS:()=>Pt,CURVED_BRACE_COMMANDS:()=>qn,CanvasPainter:()=>io,CanvasTextMeasurer:()=>sr,DEFAULT_BPM:()=>He,DEFAULT_FONT_SIZE:()=>yr,DEFAULT_KEY:()=>Se,DEFAULT_PAGE_CONFIG:()=>ie,DEFAULT_PROGRAM:()=>pn,DEFAULT_TEXT_FONT:()=>xt,DEFAULT_TONALITY:()=>Ze,DEFAULT_VELOCITY:()=>lt,DIV_ADDON_KEY:()=>ht,DashNode:()=>Ko,DefaultTextMeasurer:()=>kn,Diagnostic:()=>O,DivNode:()=>Do,DotNode:()=>Xo,DownNode:()=>jr,DynNode:()=>qo,ErrorDiagnostic:()=>w,FLAT_NOTE_NAMES:()=>$t,Fraction:()=>V,GlissNode:()=>nr,GraceNode:()=>Jo,GraceTemporal:()=>An,HeadNode:()=>kr,JIANPU_NUMBER_FONT:()=>gt,JUMP_MARK:()=>Ye,KeyNode:()=>Xt,LYRIC_SIZE_RATIO:()=>ni,LoweringContext:()=>cn,MeterNode:()=>Dt,NOTE_LETTERS:()=>Le,NoteNameMap:()=>$e,NoteNode:()=>Rr,OttavaNode:()=>Fr,PAGE_NUMBER_FONT_SIZE:()=>zn,PageBreakNode:()=>Kr,PageFunction:()=>jn,PageLayoutError:()=>ut,PageNode:()=>$r,ParserContext:()=>le,ProgramNode:()=>Xr,RecordingPainter:()=>Za,RestNode:()=>Dr,SEGNO_MARK:()=>$n,SHARP_NOTE_NAMES:()=>Wt,SetNode:()=>Ta,SlideNode:()=>ar,StackNode:()=>qr,SvgPainter:()=>so,SymbolNode:()=>ba,TempoNode:()=>Zt,TemporalNodeBase:()=>W,TextNode:()=>qt,TieNode:()=>Ra,Track:()=>tt,TranslatingPainter:()=>Qe,TremoloNode:()=>Na,TupletNode:()=>Ba,UpNode:()=>zr,VoiceFunction:()=>Ie,VoiceLyricsAttachment:()=>sn,VoiceNameTemporal:()=>no,VoiceNode:()=>oo,VoicesFunction:()=>_e,VoicesNode:()=>eo,VoltaNode:()=>Pa,WarningDiagnostic:()=>I,acc2Offset:()=>Rn,accentSymbol:()=>en,analyzeScoreSyntax:()=>Zc,appendRun:()=>Fe,callArgName:()=>wt,canvasFont:()=>Pn,claimDivLine:()=>Oo,codaSymbol:()=>Qr,collectExplicitBeamEndpoints:()=>Fo,comparePlaybackDraftEvents:()=>Ka,compilePlayback:()=>el,compileScore:()=>Xc,completeSpringConfig:()=>mn,createAutomaticBeamAttachments:()=>Mo,createBeamLayoutAttachment:()=>et,createDiatonicTranspose:()=>xr,createLayoutPrepareContext:()=>za,dcSymbol:()=>Jr,defaultFunctions:()=>ro,defaultTextMeasurer:()=>cr,divLinePortName:()=>ve,divLineRuns:()=>Io,divLineWidth:()=>Ln,dsSymbol:()=>ta,dynamicSymbols:()=>ra,fermataSymbol:()=>aa,finalizePlaybackEvents:()=>Ua,findClosingQuote:()=>ae,findRightParen:()=>ur,fineSymbol:()=>sa,functionAddonKey:()=>Xe,getDivOwner:()=>Vt,getLayoutBounds:()=>te,harmonicSymbol:()=>ia,isLayoutAttachment:()=>Ne,isNonLineWhitespace:()=>bt,isPlaybackRelation:()=>Ya,isVisualTemporalNode:()=>M,iturnSymbol:()=>fa,layoutDocument:()=>fo,layoutElement:()=>dn,layoutHorizontal:()=>uo,layoutHorizontalRegion:()=>pt,layoutLocalSequence:()=>dt,layoutPageBounds:()=>Je,liftInto:()=>yn,lineEntryX:()=>Te,lineRightX:()=>we,lyricNameStyle:()=>an,marcatoSymbol:()=>ca,markdownToggles:()=>vn,meterChangeAt:()=>Ro,mordentSymbol:()=>la,needsBraces:()=>Is,normalizeAccidentalOffset:()=>Fn,normalizePageConfig:()=>Rt,offsetToAccidental:()=>Bn,ornament:()=>Ce,paginateLayoutLines:()=>mo,paintAccidental:()=>Ut,paintLayout:()=>go,paintLayoutPages:()=>yt,paintRichLine:()=>Be,paintSymbol:()=>It,paintVisual:()=>Me,parseConnections:()=>Va,parseLength:()=>En,parseLyric:()=>Zn,parseNoteName:()=>je,parseRichText:()=>ir,parseString:()=>jt,pathBounds:()=>he,performanceTimeToScoreTime:()=>mi,performanceTimeToSeconds:()=>ao,placeAccidentals:()=>Kt,prallSymbol:()=>pa,prepareArpeggioShape:()=>bo,prepareHorizontalLine:()=>ho,prepareLayoutHost:()=>Bt,prepareQuarterNote:()=>Tr,prepareRichLine:()=>ke,preprocessSource:()=>St,primaryName:()=>_t,quote:()=>ee,quoteSourceString:()=>ee,rangeColumns:()=>hn,readBrace:()=>mr,readCall:()=>Tt,readLabel:()=>dr,registerBarNumbering:()=>No,renderLayoutPagesToCanvas:()=>il,renderLayoutPagesToSvg:()=>al,repeatPass:()=>vo,resolveArgDef:()=>es,resolveArgType:()=>ct,resolveConnections:()=>Ha,resolveLetterNameToJianpu:()=>Yt,resolveNoteMidi:()=>Mn,resolveRange:()=>fn,rewriteNoteCall:()=>Vs,rewriteNotes:()=>Pr,sanbanBounds:()=>ft,sanbanShapes:()=>Tn,scanMarkdown:()=>zt,scoreTimeToPerformanceTime:()=>di,scoreTimeToSeconds:()=>Qc,secondsToPerformanceTime:()=>ui,secondsToScoreTime:()=>qc,segnoSymbol:()=>ea,serializeConnections:()=>Jn,serializeLyric:()=>Ia,skipSpaces:()=>Pe,skipSpacesBack:()=>Lt,staccatoSymbol:()=>ua,symbolBounds:()=>Ge,symbols:()=>nn,tenutoSymbol:()=>ma,tocodaSymbol:()=>da,tonality2Midi:()=>Ct,trSymbol:()=>vt,transferFunctionAddons:()=>qe,transformNotes:()=>Ac,trimRange:()=>ze,turnSymbol:()=>ya,unionLayoutBoxes:()=>mt,validateExplicitBeamAttachments:()=>Vo,voiceNameStyle:()=>to,wheelSymbol:()=>ha,wrapPitchClass:()=>We});var hi=/\{(\w+)\}/g,O=class a{code;message;span;params;static format(e,t,n){return n?t.replace(hi,(o,r)=>Object.hasOwn(n,r)?n[r]:o):t}constructor(e,t,n,o){if(this.code=e,this.span=n,o){let r={};for(let s of Object.keys(o))r[s]=String(o[s]);this.params=r}this.message=a.format(e,t,this.params)}toLineCol(e){let t=a.offsetToLineCol(this.span.start,e),n=a.offsetToLineCol(this.span.end,e);return{startLine:t.line,startColumn:t.column,endLine:n.line,endColumn:n.column}}static offsetToLineCol(e,t){let n=t.length;if(n===0)return{line:1,column:Math.max(0,e)+1};let o=e;o<0&&(o=0);let r=0,s=n-1;for(;r<=s;){let l=r+s>>1;t[l]<=o?r=l+1:s=l-1}let i=Math.max(0,s),c=t[i]??0;return{line:i+1,column:o-c+1}}static error;static warning},Ja=a=>typeof a=="number"?`[${a}]`:`"${a}"`,w=class extends O{},I=class extends O{},xi={Bug:(a,e)=>new w("E_BUG","\u89E3\u6790\u5668\u9519\u8BEF: {message}\uFF0C\u8BF7\u8054\u7CFB\u5F00\u53D1\u8005\u4FEE\u590D\u8FD9\u4E2A\u95EE\u9898",e,{message:a}),MissingArg:(a,e,t)=>new w("E_MISSING_REQUIRED_ARG","\u51FD\u6570@{fn} \u7F3A\u5C11\u5FC5\u9700\u7684\u53C2\u6570 {arg}",t,{fn:a,arg:Ja(e)}),PosAfterNamedArg:(a,e)=>new w("E_POSARG_AFTER_KWARG","\u51FD\u6570 @{fn} \u7684\u4F4D\u7F6E\u53C2\u6570\u51FA\u73B0\u5728\u547D\u540D\u53C2\u6570\u4E4B\u540E\uFF0C\u8FD9\u662F\u4E0D\u5141\u8BB8\u7684",e,{fn:a}),EmptyContent:(a,e,t)=>new w("E_EMPTY_CONTENT","\u51FD\u6570 @{fn} \u7684\u53C2\u6570 {arg} \u5185\u5BB9\u4E3A\u7A7A(\u6216\u65E0\u53EF\u7528\u5185\u5BB9)\uFF1B\u8BF7\u63D0\u4F9B\u6709\u6548\u5185\u5BB9",t,{fn:a,arg:Ja(e)}),UnterminatedCall:(a,e)=>new w("E_UNTERMINATED_CALL","\u51FD\u6570\u8C03\u7528\u672A\u95ED\u5408: @{fn}(...)",e,{fn:a}),UnknownFunction:(a,e)=>new w("E_UNKNOWN_FUNCTION","\u672A\u77E5\u51FD\u6570: @{fn}\uFF0C\u8BF7\u68C0\u67E5\u62FC\u5199",e,{fn:a}),UnknownLabel:(a,e)=>new w("E_UNKNOWN_LABEL",'\u672A\u77E5\u6807\u7B7E: "{label}"',e,{label:a}),BreakInsideEvent:a=>new w("E_BREAK_INSIDE_EVENT","\u6362\u884C\u6216\u6362\u9875\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\u6362\u884C\u3001\u6362\u9875\u7684\u4F4D\u7F6E",a),PageOverflow:(a,e,t)=>new w("E_PAGE_OVERFLOW","\u8C31\u9762\u884C\u9700\u8981 {required}px \u9AD8\u5EA6\uFF0C\u4F46\u9875\u9762\u5185\u5BB9\u533A\u53EA\u6709 {available}px",t,{required:a,available:e})},gi={InvalidUnicodeEscape:a=>new I("W_STRING_INVALID_UNICODE_ESCAPE","\u65E0\u6548\u7684 Unicode \u8F6C\u4E49\uFF1A\u8BF7\u4F7F\u7528 \\uXXXX\uFF08\u56DB\u4F4D\u5341\u516D\u8FDB\u5236\u6570\u5B57\uFF09\uFF1B\u5C06\u4FDD\u7559\u8BE5\u5B57\u7B26\u4E32\u539F\u6587",a),UnknownFunction:(a,e)=>new I("W_UNKNOWN_FUNCTION","\u672A\u77E5\u51FD\u6570: @{fn}\uFF0C\u5C06\u88AB\u5F53\u4F5C\u666E\u901A\u6587\u672C\u5904\u7406",e,{fn:a}),TooManyPosArgs:(a,e,t,n)=>new I("W_TOO_MANY_POS_ARGS","\u51FD\u6570 @{fn} \u63A5\u6536\u4E86\u8FC7\u591A\u7684\u4F4D\u7F6E\u53C2\u6570\uFF0C\u671F\u671B {expected} \u4E2A\u4F46\u5F97\u5230\u4E86 {actual} \u4E2A",n,{fn:a,expected:e,actual:t}),InvalidNumber:(a,e)=>new I("W_INVALID_NUMBER",'\u65E0\u6548\u7684\u6570\u5B57: "{value}"\uFF1B\u5C06\u4F7F\u7528\u9ED8\u8BA4\u503C(\u82E5\u5B58\u5728)',e,{value:a}),InvalidBoolean:(a,e)=>new I("W_INVALID_BOOL",`\u65E0\u6548\u7684\u5E03\u5C14\u503C: "{value}": \u5E94\u4E3A 'true' \u6216 'false'\uFF1B\u5C06\u4F7F\u7528\u9ED8\u8BA4\u503C(\u82E5\u5B58\u5728)`,e,{value:a}),InvalidLength:(a,e)=>new I("W_INVALID_LENGTH",'\u65E0\u6548\u7684\u957F\u5EA6\u503C: "{value}"\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)',e,{value:a}),InvalidLengthUnit:(a,e)=>new I("W_INVALID_LENGTH_UNIT",'\u65E0\u6548\u7684\u957F\u5EA6\u5355\u4F4D: "{unit}"\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)',e,{unit:a}),InvalidContent:a=>new I("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)",a),UnmatchedBrace:a=>new I("W_UNMATCHED_BRACE","\u672A\u5339\u914D\u7684\u5927\u62EC\u53F7: \u7F3A\u5C11\u53F3\u5927\u62EC\u53F7'}'\uFF1B\u5C06\u5C1D\u8BD5\u81EA\u52A8\u4FEE\u590D",a),LabelWithoutTarget:(a,e)=>new I("W_LABEL_WITHOUT_TARGET",'\u6807\u7B7E "{label}" \u6CA1\u6709\u53EF\u7ED1\u5B9A\u7684\u76EE\u6807\uFF1B\u6807\u7B7E\u5C06\u88AB\u5FFD\u7565',e,{label:a}),TargetAlreadyLabeled:(a,e,t)=>new I("W_TARGET_ALREADY_LABELED",'\u76EE\u6807\u5DF2\u6807\u6CE8\u4E3A "{oldLabel}"\uFF0C"{newLabel}" \u5C06\u88AB\u5FFD\u7565',t,{oldLabel:e,newLabel:a}),UnresolvedEndpoint:(a,e)=>new I("W_UNRESOLVED_ENDPOINT","@{fn} \u6709\u7AEF\u70B9\u627E\u4E0D\u5230\u5BF9\u5E94\u7684\u8C31\u9762\u5BF9\u8C61\uFF1B\u8BE5\u5173\u7CFB\u5C06\u88AB\u5FFD\u7565",e,{fn:a}),ZeroTimeTrack:(a,e)=>new I("W_ZERO_TIME_TRACK","\u7B2C{track}\u4E2A\u5B50\u8F68\u9053\u7684\u65F6\u957F\u4E3A0",a,{track:e})};O.error=xi;O.warning=gi;function Xe(a){return`@${a}`}var be=class{constructor(e,t=null){this.sourceSpan=e;this.parent=t}sourceSpan;parent;get children(){return null}loweringEnter(e,t){return[]}timeFlowModel(e){let t=this.children;return t?{mode:"sequence",children:t}:null}loweringExit(e,t,n){return[]}toString(e){return e.slice(this.sourceSpan.start,this.sourceSpan.end)}},pe=class extends be{},it=class extends be{label;target;constructor(e,t,n,o=null){super(e,o),this.label=t,this.target=n}toString(e){return`@${this.label} `}},re=class extends be{content;get children(){return this.content}constructor(e,t,n=null){super(e,n),this.content=t,this.content.forEach(o=>o.parent=this)}toString(e){return`{${this.content.map(t=>t.toString(e)).join("")}}`}};function es(a,e,t){if(e){let n=e.toLowerCase();return a.args.find(o=>o.name?.toLowerCase()===n)}for(let n of a.args)if(!n.namedOnly&&t--===0)return n}function ct(a,e,t){return es(a,e,t)?.type??(!e&&a.allowExtraArgs?a.extraArgType:void 0)}function _t(a){return Array.isArray(a.name)?a.name[0]:a.name}var E=class a extends be{label;static def;get def(){return this.constructor.def}get callName(){return this.def?_t(this.def):""}static deSugarAtom=()=>null;static deSugarRelation=()=>null;getArgValue(e,t){let n=this.def;if(!n)return[];let o=_t(n),r=0;return n.args.map((s,i)=>{let c=s.namedOnly?void 0:r++,l=s.name?.toLowerCase(),p=(l?e.get(l):void 0)??(c===void 0?void 0:e.get(c))??(l?t.variables[`${o}.${l}`.toLowerCase()]:void 0)??s.default;if(p===null)throw O.error.MissingArg(o,s.name||(c??i),this.sourceSpan);return p})}toString(e){let t=this.callName;return t?`@${t} `:super.toString(e)}static layoutDecorationHandler;static findLabelable(e){let t=e;if(t.labelable)return t.labelable();for(let n of e.children??[]){let o=a.findLabelable(n);if(o)return o}return null}};function bi(a,e){for(;e!==0;){let t=a%e;a=e,e=t}return a}var V=class a{_numerator=0;_denominator=1;constructor(e=0,t=1){(e!==0||t!==1)&&this.set(e,t)}get numerator(){return this._numerator}get denominator(){return this._denominator}set(e,t=1){if(!Number.isFinite(e)||!Number.isFinite(t))throw new RangeError("Fraction numerator and denominator must be finite");if(t===0)throw new RangeError("Denominator must not be zero");t<0&&(e=-e,t=-t);let n=bi(Math.abs(e),t);return this._numerator=e/n,this._denominator=t/n,this}copyFrom(e){return this._numerator=e._numerator,this._denominator=e._denominator,this}clone(){return new a().copyFrom(this)}add(e,t=1){let n;return typeof e=="number"?n=e:(n=e._numerator,t=e._denominator),this.set(this._numerator*t+n*this._denominator,this._denominator*t)}sub(e,t=1){let n;return typeof e=="number"?n=e:(n=e._numerator,t=e._denominator),this.set(this._numerator*t-n*this._denominator,this._denominator*t)}mul(e,t=1){let n;return typeof e=="number"?n=e:(n=e._numerator,t=e._denominator),this.set(this._numerator*n,this._denominator*t)}div(e,t=1){let n;if(typeof e=="number"?n=e:(n=e._numerator,t=e._denominator),n===0)throw new RangeError("Cannot divide by zero");return this.set(this._numerator*t,this._denominator*n)}divPow2(e=1){if(this._numerator===0)return this;for(;e>0&&this._numerator%2===0;)this._numerator/=2,e--;let t=this._denominator*2**e;if(!Number.isFinite(t))throw new RangeError("Fraction denominator overflow");return this._denominator=t,this}compare(e,t=1){let n;typeof e=="number"?n=e:(n=e._numerator,t=e._denominator);let o=this._numerator*t-n*this._denominator;return o<0?-1:o>0?1:0}equals(e,t=1){return e instanceof a?this._numerator===e._numerator&&this._denominator===e._denominator:this._numerator*t===e*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 He=120,lt=80,Ze="C4",pn=0,Q=-1/0,Se=1/0,W=class{t=new V;T=new V;track;ast;order;addon;mergeKey;foldedInto;get rootHost(){let e=this;for(;e.foldedInto;)e=e.foldedInto;return e}get kind(){return this.ast instanceof E?this.ast.callName:""}layoutLine=0;box;springConfig;ports;decorations;initLayoutBox(){return this.box={x:0,y:0,w:0,h:0,anchor:0,visualAxis:0}}playbackState;prepareLayout(e){}paint(e){}};function qe(a,e){let t=a.addon;if(t){for(let n of Object.keys(t).filter(o=>o.startsWith("@")))(e.addon??={})[n]=t[n],delete t[n];Object.keys(t).length||(a.addon=void 0)}}function M(a){return a.box!==void 0}function Ne(a){return typeof a.createGeometry=="function"}var Qe=class{constructor(e,t,n){this.target=e;this.dx=t;this.dy=n}target;dx;dy;beginGroup(e){this.target.beginGroup?.(e)}endGroup(){this.target.endGroup?.()}drawText(e,t,n,o){this.target.drawText(e,t+this.dx,n+this.dy,o)}drawLine(e,t,n,o,r){this.target.drawLine(e+this.dx,t+this.dy,n+this.dx,o+this.dy,r)}drawRect(e,t,n,o,r){this.target.drawRect(e+this.dx,t+this.dy,n,o,r)}drawCircle(e,t,n,o){this.target.drawCircle(e+this.dx,t+this.dy,n,o)}drawPath(e,t,n){this.target.drawPath(e,t,{x:(n?.x??0)+this.dx,y:(n?.y??0)+this.dy,scaleX:n?.scaleX??1,scaleY:n?.scaleY??1})}};var co=class extends E{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 vi=Object.defineProperty;var Pi=(a,e)=>{for(var t in e)vi(a,t,{get:e[t],enumerable:!0})};var _a={};Pi(_a,{ANCHOR_KEY:()=>Q,ASTBraceNode:()=>se,ASTFunctionNode:()=>P,ASTLabelNode:()=>lt,ASTNodeBase:()=>we,ASTTextNode:()=>pe,AccidentalMemory:()=>nn,AdjustNode:()=>po,ArpeggioNode:()=>wo,BarNode:()=>kn,BeamNode:()=>Mo,BoxNode:()=>Oo,BrNode:()=>en,CanvasPainter:()=>io,CanvasTextMeasurer:()=>or,DEFAULT_BPM:()=>Me,DEFAULT_FONT_SIZE:()=>mr,DEFAULT_KEY:()=>Le,DEFAULT_PAGE_CONFIG:()=>ue,DEFAULT_PROGRAM:()=>fn,DEFAULT_TEXT_FONT:()=>bt,DEFAULT_TONALITY:()=>qe,DEFAULT_VELOCITY:()=>pt,DashNode:()=>Vo,DefaultTextMeasurer:()=>Mn,Diagnostic:()=>M,DivNode:()=>En,DotNode:()=>Go,DownNode:()=>Gr,DynNode:()=>$o,ErrorDiagnostic:()=>w,FLAT_NOTE_NAMES:()=>Kt,Fraction:()=>I,GlissNode:()=>Jo,GraceNode:()=>Ko,GraceTemporal:()=>_n,HeadNode:()=>Cr,JIANPU_NUMBER_FONT:()=>St,KeyNode:()=>qt,LYRIC_OPENING_PUNCTUATION:()=>ba,LYRIC_SILENT_PUNCTUATION:()=>Qn,LYRIC_SIZE_RATIO:()=>yi,LoweringContext:()=>on,MeterNode:()=>ht,NOTE_LETTERS:()=>ke,NoteNameMap:()=>$e,NoteNode:()=>vr,OttavaNode:()=>Er,PageBreakNode:()=>Yr,PageNode:()=>$r,ParserContext:()=>re,ProgramNode:()=>Xr,RecordingPainter:()=>Ea,RestNode:()=>Or,SHARP_NOTE_NAMES:()=>Yt,SetNode:()=>ra,SlideNode:()=>nr,StackNode:()=>qr,SvgPainter:()=>so,SymbolNode:()=>na,TempoNode:()=>Qt,TemporalNodeBase:()=>H,TextNode:()=>Jt,TieNode:()=>fa,TimeColumn:()=>Nt,Track:()=>tt,TranslatingPainter:()=>Bt,TremoloNode:()=>la,TupletNode:()=>ga,UpNode:()=>Hr,VoiceFunction:()=>Ve,VoiceLyricsAttachment:()=>un,VoiceNameTemporal:()=>oo,VoiceNode:()=>ka,VoicesFunction:()=>Re,VoicesNode:()=>Aa,VoltaNode:()=>ma,WarningDiagnostic:()=>O,acc2Offset:()=>kt,analyzeScoreSyntax:()=>Sl,appendRun:()=>Oe,callArgName:()=>nt,canvasFont:()=>Bn,compilePlayback:()=>Cl,compileScore:()=>bl,completeSpringConfig:()=>xn,createDiatonicTranspose:()=>fr,createLayoutPrepareContext:()=>Na,defaultFunctions:()=>ro,defaultTextMeasurer:()=>ar,findClosingQuote:()=>ie,findRightParen:()=>cr,functionAddonKey:()=>Xe,getLayoutBounds:()=>ee,isLayoutAttachment:()=>Ne,isNonLineWhitespace:()=>Tt,isPlaybackRelation:()=>va,isVisualTemporalNode:()=>_,layoutDocument:()=>fo,layoutElement:()=>gn,layoutHorizontal:()=>mo,layoutHorizontalRegion:()=>ut,layoutLocalSequence:()=>yt,layoutPageBounds:()=>Je,liftInto:()=>Sn,lineEntryX:()=>Ce,lineRightX:()=>Ae,lyricNameStyle:()=>pn,markdownToggles:()=>Fn,needsBraces:()=>Es,normalizeAccidentalOffset:()=>In,normalizePageConfig:()=>mt,offsetToAccidental:()=>ot,paginateLayoutLines:()=>bn,paintLayout:()=>bo,paintLayoutPages:()=>ft,paintRichLine:()=>Ie,paintVisual:()=>Fe,parseConnections:()=>eo,parseLength:()=>Ut,parseLyric:()=>Jn,parseNoteName:()=>je,parseRichText:()=>rr,parseString:()=>$t,pathBounds:()=>Se,performanceTimeToScoreTime:()=>Li,performanceTimeToSeconds:()=>ao,prepareHorizontalLine:()=>xo,prepareLayoutHost:()=>It,prepareRichLine:()=>ve,preprocessSource:()=>wt,primaryName:()=>Mt,quoteSourceString:()=>te,rangeColumns:()=>yo,readBrace:()=>lr,readCall:()=>Lt,readLabel:()=>pr,renderLayoutPagesToCanvas:()=>_l,renderLayoutPagesToSvg:()=>Pl,resolveArgDef:()=>yn,resolveArgType:()=>Ze,resolveConnections:()=>to,resolveLetterNameToJianpu:()=>Zt,resolveNoteMidi:()=>Xt,resolveRange:()=>Tn,rewriteNoteCall:()=>Rs,rewriteNotes:()=>Wn,scanMarkdown:()=>Wt,scoreTimeToPerformanceTime:()=>Ci,scoreTimeToSeconds:()=>wl,secondsToPerformanceTime:()=>wi,secondsToScoreTime:()=>Tl,selects:()=>jn,serializeConnections:()=>dn,serializeLyric:()=>Sa,skipSpaces:()=>_e,skipSpacesBack:()=>Ct,symbols:()=>sn,tonality2Midi:()=>At,transferFunctionAddons:()=>Qe,transformNotes:()=>Yc,trimRange:()=>ze,unionLayoutBoxes:()=>dt,voiceNameStyle:()=>no,wrapPitchClass:()=>We});var Ei=/\{(\w+)\}/g,M=class a{code;message;span;params;static format(e,t,n){return n?t.replace(Ei,(o,r)=>Object.hasOwn(n,r)?n[r]:o):t}constructor(e,t,n,o){if(this.code=e,this.span=n,o){let r={};for(let s of Object.keys(o))r[s]=String(o[s]);this.params=r}this.message=a.format(e,t,this.params)}toLineCol(e){let t=a.offsetToLineCol(this.span.start,e),n=a.offsetToLineCol(this.span.end,e);return{startLine:t.line,startColumn:t.column,endLine:n.line,endColumn:n.column}}static offsetToLineCol(e,t){let n=t.length;if(n===0)return{line:1,column:Math.max(0,e)+1};let o=e;o<0&&(o=0);let r=0,s=n-1;for(;r<=s;){let l=r+s>>1;t[l]<=o?r=l+1:s=l-1}let i=Math.max(0,s),c=t[i]??0;return{line:i+1,column:o-c+1}}static error;static warning},co=a=>typeof a=="number"?`[${a}]`:`"${a}"`,w=class extends M{},O=class extends M{},_i={Bug:(a,e)=>new w("E_BUG","\u89E3\u6790\u5668\u9519\u8BEF: {message}\uFF0C\u8BF7\u8054\u7CFB\u5F00\u53D1\u8005\u4FEE\u590D\u8FD9\u4E2A\u95EE\u9898",e,{message:a}),MissingArg:(a,e,t)=>new w("E_MISSING_REQUIRED_ARG","\u51FD\u6570@{fn} \u7F3A\u5C11\u5FC5\u9700\u7684\u53C2\u6570 {arg}",t,{fn:a,arg:co(e)}),PosAfterNamedArg:(a,e)=>new w("E_POSARG_AFTER_KWARG","\u51FD\u6570 @{fn} \u7684\u4F4D\u7F6E\u53C2\u6570\u51FA\u73B0\u5728\u547D\u540D\u53C2\u6570\u4E4B\u540E\uFF0C\u8FD9\u662F\u4E0D\u5141\u8BB8\u7684",e,{fn:a}),EmptyContent:(a,e,t)=>new w("E_EMPTY_CONTENT","\u51FD\u6570 @{fn} \u7684\u53C2\u6570 {arg} \u5185\u5BB9\u4E3A\u7A7A(\u6216\u65E0\u53EF\u7528\u5185\u5BB9)\uFF1B\u8BF7\u63D0\u4F9B\u6709\u6548\u5185\u5BB9",t,{fn:a,arg:co(e)}),UnterminatedCall:(a,e)=>new w("E_UNTERMINATED_CALL","\u51FD\u6570\u8C03\u7528\u672A\u95ED\u5408: @{fn}(...)",e,{fn:a}),UnknownFunction:(a,e)=>new w("E_UNKNOWN_FUNCTION","\u672A\u77E5\u51FD\u6570: @{fn}\uFF0C\u8BF7\u68C0\u67E5\u62FC\u5199",e,{fn:a}),UnknownLabel:(a,e)=>new w("E_UNKNOWN_LABEL",'\u672A\u77E5\u6807\u7B7E: "{label}"',e,{label:a}),BreakInsideEvent:a=>new w("E_BREAK_INSIDE_EVENT","\u6362\u884C\u6216\u6362\u9875\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\u6362\u884C\u3001\u6362\u9875\u7684\u4F4D\u7F6E",a),PageOverflow:(a,e,t)=>new w("E_PAGE_OVERFLOW","\u8C31\u9762\u884C\u9700\u8981 {required}px \u9AD8\u5EA6\uFF0C\u4F46\u9875\u9762\u5185\u5BB9\u533A\u53EA\u6709 {available}px",t,{required:a,available:e})},Ri={InvalidUnicodeEscape:a=>new O("W_STRING_INVALID_UNICODE_ESCAPE","\u65E0\u6548\u7684 Unicode \u8F6C\u4E49\uFF1A\u8BF7\u4F7F\u7528 \\uXXXX\uFF08\u56DB\u4F4D\u5341\u516D\u8FDB\u5236\u6570\u5B57\uFF09\uFF1B\u5C06\u4FDD\u7559\u8BE5\u5B57\u7B26\u4E32\u539F\u6587",a),UnknownFunction:(a,e)=>new O("W_UNKNOWN_FUNCTION","\u672A\u77E5\u51FD\u6570: @{fn}\uFF0C\u5C06\u88AB\u5F53\u4F5C\u666E\u901A\u6587\u672C\u5904\u7406",e,{fn:a}),TooManyPosArgs:(a,e,t,n)=>new O("W_TOO_MANY_POS_ARGS","\u51FD\u6570 @{fn} \u63A5\u6536\u4E86\u8FC7\u591A\u7684\u4F4D\u7F6E\u53C2\u6570\uFF0C\u671F\u671B {expected} \u4E2A\u4F46\u5F97\u5230\u4E86 {actual} \u4E2A",n,{fn:a,expected:e,actual:t}),UnknownArg:(a,e,t)=>new O("W_UNKNOWN_ARG","\u51FD\u6570 @{fn} \u6CA1\u6709\u540D\u4E3A {arg} \u7684\u53C2\u6570\uFF1B\u8BE5\u53C2\u6570\u5C06\u88AB\u5FFD\u7565",t,{fn:a,arg:co(e)}),InvalidNumber:(a,e)=>new O("W_INVALID_NUMBER",'\u65E0\u6548\u7684\u6570\u5B57: "{value}"\uFF1B\u5C06\u4F7F\u7528\u9ED8\u8BA4\u503C(\u82E5\u5B58\u5728)',e,{value:a}),InvalidBoolean:(a,e)=>new O("W_INVALID_BOOL",`\u65E0\u6548\u7684\u5E03\u5C14\u503C: "{value}": \u5E94\u4E3A 'true' \u6216 'false'\uFF1B\u5C06\u4F7F\u7528\u9ED8\u8BA4\u503C(\u82E5\u5B58\u5728)`,e,{value:a}),InvalidLength:(a,e)=>new O("W_INVALID_LENGTH",'\u65E0\u6548\u7684\u957F\u5EA6\u503C: "{value}"\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)',e,{value:a}),InvalidLengthUnit:(a,e)=>new O("W_INVALID_LENGTH_UNIT",'\u65E0\u6548\u7684\u957F\u5EA6\u5355\u4F4D: "{unit}"\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)',e,{unit:a}),InvalidContent:a=>new O("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)",a),UnmatchedBrace:a=>new O("W_UNMATCHED_BRACE","\u672A\u5339\u914D\u7684\u5927\u62EC\u53F7: \u7F3A\u5C11\u53F3\u5927\u62EC\u53F7'}'\uFF1B\u5C06\u5C1D\u8BD5\u81EA\u52A8\u4FEE\u590D",a),LabelWithoutTarget:(a,e)=>new O("W_LABEL_WITHOUT_TARGET",'\u6807\u7B7E "{label}" \u6CA1\u6709\u53EF\u7ED1\u5B9A\u7684\u76EE\u6807\uFF1B\u6807\u7B7E\u5C06\u88AB\u5FFD\u7565',e,{label:a}),TargetAlreadyLabeled:(a,e,t)=>new O("W_TARGET_ALREADY_LABELED",'\u76EE\u6807\u5DF2\u6807\u6CE8\u4E3A "{oldLabel}"\uFF0C"{newLabel}" \u5C06\u88AB\u5FFD\u7565',t,{oldLabel:e,newLabel:a}),UnresolvedEndpoint:(a,e)=>new O("W_UNRESOLVED_ENDPOINT","@{fn} \u6709\u7AEF\u70B9\u627E\u4E0D\u5230\u5BF9\u5E94\u7684\u8C31\u9762\u5BF9\u8C61\uFF1B\u8BE5\u5173\u7CFB\u5C06\u88AB\u5FFD\u7565",e,{fn:a}),ZeroTimeTrack:(a,e)=>new O("W_ZERO_TIME_TRACK","\u7B2C{track}\u4E2A\u5B50\u8F68\u9053\u7684\u65F6\u957F\u4E3A0",a,{track:e})};M.error=_i;M.warning=Ri;function Xe(a){return`@${a}`}var we=class{constructor(e,t=null){this.sourceSpan=e;this.parent=t}sourceSpan;parent;get children(){return null}loweringEnter(e,t){return[]}timeFlowModel(e){let t=this.children;return t?{mode:"sequence",children:t}:null}loweringExit(e,t,n){return[]}toString(e){return e.slice(this.sourceSpan.start,this.sourceSpan.end)}},pe=class extends we{},lt=class extends we{label;target;constructor(e,t,n,o=null){super(e,o),this.label=t,this.target=n}toString(e){return`@${this.label} `}},se=class extends we{content;get children(){return this.content}constructor(e,t,n=null){super(e,n),this.content=t,this.content.forEach(o=>o.parent=this)}toString(e){return`{${this.content.map(t=>t.toString(e)).join("")}}`}};function yn(a,e,t){if(e){let n=e.toLowerCase();return a.args.find(o=>o.name?.toLowerCase()===n)}for(let n of a.args)if(!n.namedOnly&&t--===0)return n}function Ze(a,e,t){return yn(a,e,t)?.type??(!e&&a.allowExtraArgs?a.extraArgType:void 0)}function Mt(a){return Array.isArray(a.name)?a.name[0]:a.name}var P=class a extends we{label;static def;get def(){return this.constructor.def}get callName(){return this.def?Mt(this.def):""}static deSugarAtom=()=>null;getArgValue(e,t){let n=this.def;if(!n)return[];let o=Mt(n),r=0;return n.args.map((s,i)=>{let c=s.namedOnly?void 0:r++,l=s.name?.toLowerCase(),p=(l?e.get(l):void 0)??(c===void 0?void 0:e.get(c))??(l?t.variables[`${o}.${l}`.toLowerCase()]:void 0)??s.default;if(p===null)throw M.error.MissingArg(o,s.name||(c??i),this.sourceSpan);return p})}toString(e){let t=this.callName;return t?`@${t} `:super.toString(e)}static layoutDecorationHandler;static findLabelable(e){let t=e;if(t.labelable)return t.labelable();for(let n of e.children??[]){let o=a.findLabelable(n);if(o)return o}return null}};function Mi(a,e){for(;e!==0;){let t=a%e;a=e,e=t}return a}var I=class a{_numerator=0;_denominator=1;constructor(e=0,t=1){(e!==0||t!==1)&&this.set(e,t)}get numerator(){return this._numerator}get denominator(){return this._denominator}set(e,t=1){if(!Number.isFinite(e)||!Number.isFinite(t))throw new RangeError("Fraction numerator and denominator must be finite");if(t===0)throw new RangeError("Denominator must not be zero");t<0&&(e=-e,t=-t);let n=Mi(Math.abs(e),t);return this._numerator=e/n,this._denominator=t/n,this}copyFrom(e){return this._numerator=e._numerator,this._denominator=e._denominator,this}clone(){return new a().copyFrom(this)}add(e,t=1){let n;return typeof e=="number"?n=e:(n=e._numerator,t=e._denominator),this.set(this._numerator*t+n*this._denominator,this._denominator*t)}sub(e,t=1){let n;return typeof e=="number"?n=e:(n=e._numerator,t=e._denominator),this.set(this._numerator*t-n*this._denominator,this._denominator*t)}mul(e,t=1){let n;return typeof e=="number"?n=e:(n=e._numerator,t=e._denominator),this.set(this._numerator*n,this._denominator*t)}div(e,t=1){let n;if(typeof e=="number"?n=e:(n=e._numerator,t=e._denominator),n===0)throw new RangeError("Cannot divide by zero");return this.set(this._numerator*t,this._denominator*n)}divPow2(e=1){if(this._numerator===0)return this;for(;e>0&&this._numerator%2===0;)this._numerator/=2,e--;let t=this._denominator*2**e;if(!Number.isFinite(t))throw new RangeError("Fraction denominator overflow");return this._denominator=t,this}compare(e,t=1){let n;typeof e=="number"?n=e:(n=e._numerator,t=e._denominator);let o=this._numerator*t-n*this._denominator;return o<0?-1:o>0?1:0}equals(e,t=1){return e instanceof a?this._numerator===e._numerator&&this._denominator===e._denominator:this._numerator*t===e*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 Me=120,pt=80,qe="C4",fn=0,Q=-1/0,Le=1/0,H=class{t=new I;T=new I;track;ast;order;addon;mergeKey;foldedInto;get rootHost(){let e=this;for(;e.foldedInto;)e=e.foldedInto;return e}get kind(){return this.ast instanceof P?this.ast.callName:""}layoutLine=0;box;springConfig;ports;decorations;initLayoutBox(){return this.box={x:0,y:0,w:0,h:0,anchor:0,visualAxis:0}}playbackState;prepareLayout(e){}paint(e){}};function Qe(a,e){let t=a.addon;if(t){for(let n of Object.keys(t).filter(o=>o.startsWith("@")))(e.addon??={})[n]=t[n],delete t[n];Object.keys(t).length||(a.addon=void 0)}}function _(a){return a.box!==void 0}function Ne(a){return typeof a.createGeometry=="function"}var lo=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
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]}loweringEnter(e){let t={temporals:0,attachments:[],onTemporal:n=>{M(n)&&(t.temporals++,Si(n,this))},onAttachment:n=>{Ne(n)&&t.attachments.push(n)}};return e.beginLoweringGroup(this,t),[]}loweringExit(e){let{temporals:t,attachments:n}=e.endLoweringGroup(this);if(t===0&&n.length===0)e.diagnostics.push(new I("W_ADJUST_NO_TARGET","@adjust \u6CA1\u6709\u627E\u5230\u53EF\u8C03\u6574\u7684\u5BF9\u8C61",this.sourceSpan));else if(t===0&&(this.dx!==0||this.dy!==0))for(let o of n)Ti(o,this.dx,this.dy);return[]}constructor(e,t,n,o=null){super(e,o);let[r,s,i,c,l]=this.getArgValue(t,n);r.parent=this,this.target=r,this.dx=n.length2px(s),this.dy=n.length2px(i),this.dw=n.length2px(c),this.dh=n.length2px(l)}toString(e){return`@adjust(${this.target.toString(e)}, dx=${this.dx}px, dy=${this.dy}px, dw=${this.dw}px, dh=${this.dh}px)`}},lo=co;function Si(a,{dx:e,dy:t,dw:n,dh:o}){if(e===0&&t===0&&n===0&&o===0)return;let r=!a.placementOffset&&(e!==0||t!==0);(e!==0||t!==0)&&(a.placementOffset={x:(a.placementOffset?.x??0)+e,y:(a.placementOffset?.y??0)+t});let s,i,c=a.finalizeLayout;if(a.finalizeLayout=m=>{c?.call(a,m),s=i=void 0;let y=Math.max(0,a.box.w+n);a.box.anchor=a.box.w>0?a.box.anchor*y/a.box.w:0,a.box.w=y,a.box.h=Math.max(0,a.box.h+o)},!r)return;let{x:l,y:p}=a.box;Object.defineProperties(a.box,{x:{get:()=>l,set(m){m===s&&l===s&&(s=void 0),l=m}},y:{get:()=>p,set(m){m===i&&p===i&&(i=void 0),p=m}}});let u=a.onPlaced;a.onPlaced=()=>{l!==s&&(l+=a.placementOffset.x),p!==i&&(p+=a.placementOffset.y),u?.call(a),s=l,i=p}}function Ti(a,e,t){let n=!a.placementOffset;if(a.placementOffset={x:(a.placementOffset?.x??0)+e,y:(a.placementOffset?.y??0)+t},!n)return;let o=a.createGeometry;a.createGeometry=r=>{let s=o.call(a,r);if(r.layoutOnly)return s;let{x:i,y:c}=a.placementOffset,l=p=>({...p,x:p.x+i,y:p.y+c});return{regions:s.regions.map(l),occupancy:s.occupancy?.map(l),paint(p){s.paint(new Qe(p,i,c))}}}}var un=1,wi=8,Li=16,po=32,ts=1e-6,Ci=.01;function mn(a,e=un){let t=a.alpha_L??a.alpha_R??wi;a.alpha_L??=t,a.alpha_R??=t;let n=a.mu_L??a.mu_R??Li;a.mu_L??=n,a.mu_R??=n,a.beta_L??=e/Math.max(a.alpha_L,ts),a.beta_R??=e/Math.max(a.alpha_R,ts)}function dn(a,e,t,n=un){mn(a,n);let o=Math.pow(Math.max(t.T.toNumber(),Ci),.5);return{config:a,box:e,time:t,duration_L:o,duration_R:o,WL:e.anchor,WR:e.w-e.anchor,margin_L:o*a.alpha_L,margin_R:o*a.alpha_R}}function Ai(a,e=un){let t=new Map,n=0;for(let r of a)for(let s of r)t.has(s.time.track)||t.set(s.time.track,n++);let o=[];for(let r of a){if(r.length===0)continue;let s=Array(r.length);o.push(s);let i=0,c=0,l=n;for(let u of r){u.WL>i&&(i=u.WL),u.WR>c&&(c=u.WR);let m=t.get(u.time.track);if(s[m]){let y=s[m];u.time.T.compare(y.time.T)>0?(s[m]=u,s[l++]=y):s[l++]=u}else s[m]=u}let p=r[0].time.t;for(let u of t){let m=u[1];s[m]||(s[m]=dn({alpha_L:i,alpha_R:c},{x:0,w:0,anchor:0},{t:p,T:new V(1),track:u[0]},e))}}return{mat:o,rows:n}}function Ni(a,e,t,n){let o=n-t-a.WR-e.WL,r=a.margin_R+e.margin_L;if(o>=r)return{force:0,stiffness:0};let s=a.config.beta_R/a.duration_R,i=e.config.beta_L/e.duration_L,c=s*i/(s+i),l,p;if(o<0){let u=a.config.mu_R*e.config.mu_L/(a.config.mu_R+e.config.mu_L);l=c*r-u*o,p=u}else{let u=r-o;l=c*u,p=c}return{force:l,stiffness:p}}function ki(a,e,t=po){let n=e-a.WL,o=a.margin_L;if(n>=o)return{force:0,stiffness:0};let r=a.config.beta_L/a.duration_L;if(n>=0)return{force:r*(o-n),stiffness:r};let s=a.config.mu_L*t;return{force:a.config.alpha_L*a.config.beta_L-s*n,stiffness:s}}function vi(a,e,t,n=po){let o=t-(e+a.WR),r=a.margin_R;if(o>=r)return{force:0,stiffness:0};let s=a.config.beta_R/a.duration_R;if(o>=0)return{force:s*(r-o),stiffness:s};let i=a.config.mu_R*n;return{force:a.config.alpha_R*a.config.beta_R-i*o,stiffness:i}}function Pi(a){return{damping:a.damping??.6,maxIter:a.maxIter??100,eps:a.eps??.01,crossPunish:a.crossPunish??po,globalC:a.globalC??un}}function Ei(a,e,t,n,o){let{damping:r,maxIter:s,eps:i,crossPunish:c}=o,l=a.length,p=new Float64Array(e);for(let S=0;S<l;S++){let T=0,L=a[S];for(let C=0;C<e;C++){let N=p[C]+L[C].WL+L[C].margin_L;N>T&&(T=N)}for(let C=0;C<e;C++)p[C]=T+L[C].WR+L[C].margin_R;t[S]=T}let u=p.reduce((S,T)=>Math.max(S,T),0);if(u<=n)return!0;u=n/u;for(let S=0;S<l;S++)t[S]*=u;let m=new Float64Array(l),y=new Float64Array(l+1);function d(S){m.fill(0),y.fill(0);for(let T=0;T<e;T++){let L=a[0][T],C=ki(L,S[0],c);m[0]+=C.force,y[0]+=C.stiffness;for(let k=1;k<l;k++){let B=a[k-1][T],_=a[k][T],v=Ni(B,_,S[k-1],S[k]);m[k-1]-=v.force,m[k]+=v.force,y[k]+=v.stiffness}let N=a[l-1][T],P=vi(N,S[l-1],n,c);m[l-1]-=P.force,y[l]+=P.stiffness}return m}let g=new Float64Array(l),f=new Float64Array(l);function x(){for(let T=0;T<l;T++){let L=T===0?0:y[T]/g[T-1],C=y[T]+y[T+1]+1e-4-L*y[T];if(!(C>0)||!Number.isFinite(C))throw new Error("Horizontal spring stiffness must produce a finite positive definite system");g[T]=C,f[T]=m[T]+(T===0?0:L*f[T-1])}f[l-1]/=g[l-1];for(let T=l-2;T>=0;T--)f[T]=(f[T]+y[T+1]*f[T+1])/g[T];return f}let h=0,b=0;for(;h<s;h++){let S=d(t);b=0;for(let L=0;L<S.length;L++){let C=Math.abs(S[L]);C>b&&(b=C)}if(b<i)break;let T=x();for(let L=0;L<l;L++)t[L]+=r*T[L]}return!1}function pt(a,e,t,n,o,r,s){if(t.length!==a.length||n.length!==Math.max(0,t.length-1))throw new Error("Horizontal region state does not match its columns");if(t.length===0||e===0)return{extra:-1};let i=n.some(d=>d!==0),c,l,p=a,u=t;if(i){c=new Uint32Array(t.length),l=new Float64Array(t.length),p=[];for(let d=0;d<t.length;){let g=d;for(;g<n.length&&n[g];)g++;let f=p.length;for(let x=d;x<=g;x++)c[x]=f,l[x]=t[x]-t[d];if(d===g)p.push(a[d]);else{let x=t[g]-t[d];p.push(Array.from({length:e},(h,b)=>{let S=a[d][b],T=a[g][b];return{config:{alpha_L:S.config.alpha_L,alpha_R:T.config.alpha_R,mu_L:S.config.mu_L,mu_R:T.config.mu_R,beta_L:S.config.beta_L,beta_R:T.config.beta_R},box:S.box,time:S.time,duration_L:S.duration_L,duration_R:T.duration_R,WL:S.WL,WR:x+T.WR,margin_L:S.margin_L,margin_R:T.margin_R}}))}d=g+1}u=new Float64Array(p.length)}let m=Ei(p,e,u,o,r);n.fill(1);let y=-1;if(s!==void 0){let d=0,g=0;for(let x=0;x<e;x++)d=Math.max(d,p[0][x].WL),g=Math.max(g,p[p.length-1][x].WR);let f=u[u.length-1]+g-u[0]+d;if(!m||f>=o*s){let x=d-u[0],h=o-f;for(let b=0;b<u.length;b++)u[b]+=x+(u.length>1?h*b/(u.length-1):0);(u.length>1||Math.abs(h)<=1e-6)&&(y=m&&u.length>1&&h>0?h:0)}}if(i)for(let d=0;d<t.length;d++)t[d]=u[c[d]]+l[d];return{extra:y,groupOf:c}}function uo(a,e,t={},n=[],o){let r=Pi(t),{mat:s,rows:i}=Ai(a,r.globalC),c=new Float64Array(s.length),l=new Uint8Array(Math.max(0,s.length-1)),p=n.length>1?[...n].sort((m,y)=>m.end-m.start-(y.end-y.start)):n;for(let{start:m,end:y,hook:d}of p){if(m<0||y<m||y>=s.length)throw new Error("Horizontal layout registration references invalid columns");d({columns:s,rows:i,start:m,end:y,X:c,fixed:l,options:r})}let u=pt(s,i,c,l,e,r,o);for(let m=0;m<s.length;m++)for(let y of s[m])y.box.x=c[m]-y.box.anchor;return Object.assign(s,u)}var ut=class extends Error{constructor(t,n,o){super(`Page cannot fit layout line ${t}: requires ${n}px, available ${o}px`);this.line=t;this.requiredHeight=n;this.availableHeight=o;this.name="PageLayoutError"}line;requiredHeight;availableHeight},ie={width:794,height:1/0,marginTop:45,marginBottom:48,marginLeft:40,marginRight:40,lineGap:18,minLineGap:7.2,fillRatio:.5};function Rt(a={}){let e=a.height??ie.height,t={width:a.width??ie.width,height:e<=0?1/0:e,marginTop:Math.max(0,a.marginTop??ie.marginTop),marginBottom:Math.max(0,a.marginBottom??ie.marginBottom),marginLeft:Math.max(0,a.marginLeft??ie.marginLeft),marginRight:Math.max(0,a.marginRight??ie.marginRight),lineGap:Math.max(0,a.lineGap??ie.lineGap),minLineGap:Math.max(0,a.minLineGap??ie.minLineGap),fillRatio:a.fillRatio??ie.fillRatio};if(!Number.isFinite(t.width)||t.width<=0)throw new Error(`Page width must be a positive finite number, got ${t.width}`);if(t.height!==1/0&&(!Number.isFinite(t.height)||t.height<=0))throw new Error(`Page height must be positive or Infinity, got ${t.height}`);if([t.marginTop,t.marginBottom,t.marginLeft,t.marginRight,t.lineGap,t.minLineGap].some(s=>!Number.isFinite(s)))throw new Error("Page margins and line gap must be finite non-negative numbers");let o=t.width-t.marginLeft-t.marginRight;if(o<=0)throw new Error(`Page horizontal margins leave no content width: ${o}px`);let r=t.height-t.marginTop-t.marginBottom;if(Number.isFinite(t.height)&&r<=0)throw new Error(`Page vertical margins leave no content height: ${r}px`);return t}function mo(a,e,t=[],n=[]){let o=e.height-e.marginTop-e.marginBottom,r=Math.min(e.lineGap,e.minLineGap),s=y=>Math.max(e.lineGap-Math.max(0,n[y]??0),r),i=[],c=new Array(a.length).fill(0),l=0,p=0,u=0,m=(y,d)=>{let g=y-p,f=d?Math.max(0,o-u)/g:0,x=l+e.marginTop;for(let b=p;b<y;b++)c[b]=x,x+=a[b]+(b+1<y?s(b+1)+f:0);let h=Number.isFinite(e.height)?e.height:x-l+e.marginBottom;i.push({bounds:{x:0,y:l,w:e.width,h},lineStart:p,lineEnd:y}),l+=h,p=y,u=0};for(let y=0;y<a.length;y++){let d=a[y];if(Number.isFinite(e.height)&&d>o+1e-6)throw new ut(y,d,o);y>p&&(t[y]!==void 0||Number.isFinite(e.height)&&u+s(y)+d>o+1e-6)&&m(y,Number.isFinite(e.height)&&(t[y]??!0)),u+=(y>p?s(y):0)+d}return a.length>p&&m(a.length,!1),{pages:i,lineTops:c}}var ns={start:0,end:-1};function yn(a){let e=new Set,t=n=>{e.add(n);for(let o of n.groups)for(let r of o.members)t(r)};return t(a),n=>{for(let o=n;o;o=o.parent)if(e.has(o))return o;return n}}function os(a,e){for(let t=e;t;){let n=a.columnOf(t);if(n>=0)return n;let o=t instanceof W?t.foldedInto:void 0;t=o&&M(o)?o:void 0}return-1}function fn(a,e){if(!e)return{start:0,end:a.columns.length-1};let[t,n]=e;if(t.layoutLine>n.layoutLine&&([t,n]=[n,t]),a.index<t.layoutLine||a.index>n.layoutLine)return ns;let o=t.layoutLine<a.index?0:os(a,t),r=n.layoutLine>a.index?a.columns.length-1:os(a,n);return o<0||r<0?ns:{start:Math.min(o,r),end:Math.max(o,r)}}function hn(a,e,t,n){if(!a)return[];let{start:o,end:r}=fn(a,e),s=a.columns.slice(o,r+1);if(!t)return s;let i=n(t),c=l=>l.track===i;return s.every(l=>l.every(c))?s:s.map(l=>l.filter(c))}function Te(a,e,t,n=a.originX){return a.lines[e]?.trackRuns.get(t)?.find(r=>!r.T.isZero())?.box.x??n}function we(a,e){let t=a.lines[e]?.trackRuns;if(!t||t.size===0)return a.originX+a.width;let n=a.originX;for(let o of t.values())for(let r of o)n=Math.max(n,r.box.x+r.box.w);return n}var as=.75,Ft=new WeakMap;function te(a,e=!1){let{box:t}=a,n=Ft.get(a);if(!n)return t;let o=e?n.contentTop:n.top,r=e?0:n.bottom;return{x:t.x,y:t.y+o,w:t.w,h:t.h-o+r}}function mt(a,e){let t=1/0,n=1/0,o=-1/0,r=-1/0;for(let s of e)t=Math.min(t,s.x),n=Math.min(n,s.y),o=Math.max(o,s.x+s.w),r=Math.max(r,s.y+s.h);return Number.isFinite(t)?(a.x=t,a.y=n,a.w=o-t,a.h=r-n,!0):(a.x=a.y=a.w=a.h=0,!1)}function Bt(a,e){if(a.springConfig={},a.decorations&&Ft.delete(a),a.decorations=[],a.ports={},a.box.x=a.box.y=0,a.prepareLayout(e),a.addon)for(let[t,n]of Object.entries(a.addon)){let o=e.decorationHandlers.get(t);if(!o)continue;let r=o(a,n,e);r&&a.decorations.push(r)}_i(a),a.finalizeLayout?.(e)}function fo(a,e,t={}){let n=a.attachments.filter(Ne),o=Rt(a.page),r=o.width-o.marginLeft-o.marginRight,s=o.marginLeft,i=yn(a.rootTrack),c=new Map(n.map((v,R)=>[v,R])),l=Bi(n),p=[];if(n.length){for(let v of a.astToTemporal.values())if(v.some(R=>R.placementOffset?.x||R.placementOffset?.y)){p=[...new Set([...a.astToTemporal.values()].flat().filter(M))];break}}let u=new Map,m=(v,R=!1)=>{let D=u.get(v);return D&&rs(D,R)};e={...e,layoutSubdomain(v,R,D,K){let X=ss(R,e),ne=new Set(R.flat()),J=$=>{for(let U=$;U&&U!==v;U=U.foldedInto)if(ne.has(U))return!0;return!1},H=K.filter(Ne).filter($=>!$.endPoints?.length);for(let $ of l.get(v)??[])!u.has($)&&$.endPoints.every(J)&&H.push($);H.sort(($,U)=>c.get($)-c.get(U));let G=Fi(R,X,D,H,e,m,p.length?p.filter(J):p,v);return H.forEach(($,U)=>u.set($,G.items[U])),{width:X.width,height:G.height,positions:G.positions}}};let{lines:y,pageBreaks:d}=Ri(a),g=[];for(let v of y)for(let R of v.columns)for(let D of R)g.push(D),Bt(D,e);let f=n.filter(v=>!u.has(v)),x=y.map((v,R)=>ho(v.columns,R,t)),h=x.map(v=>v.view);for(let v of f)v.prepareHorizontal?.(h,e);let b=x.map(v=>v.layout(r,o.fillRatio));Mi(h,b,r,d);for(let v of x)for(let R of v.view.columns)for(let D of R)D.box.x+=s;if(t.horizontalOnly)return{diagnostics:a.diagnostics,objects:g,attachments:[],bounds:{x:0,y:0,w:0,h:0},lineCount:y.length,pages:[]};for(let v of g){let R=y[v.layoutLine];ls(R.hostExtents,v)}let S=Ii(y.length,g,t.rowGap),T=()=>{let v=[],R=[],D=y.map((H,G)=>{let $=ps(H,a.rootTrack,S[G]);v.push($.height);let U=1/0;for(let xe of H.columns)for(let Re of xe)U=Math.min(U,($.axes.get(Re.track)??0)-Re.ast.size/2);return R.push(U<1/0?U:0),$.axes}),K,X;try{({pages:K,lineTops:X}=mo(v,o,d,R))}catch(H){if(!(H instanceof ut))throw H;let G=y[H.line],$=1/0,U=-1/0;for(let xe of G?.columns??[])for(let Re of xe)$=Math.min($,Re.ast.sourceSpan.start),U=Math.max(U,Re.ast.sourceSpan.end);throw Number.isFinite($)?O.error.PageOverflow(H.requiredHeight,H.availableHeight,{start:$,end:U}):H}let ne=(H,G)=>(X[H]??0)+(D[H]?.get(G)??0);for(let H of g)H.box.y=ne(H.layoutLine,H.track)-H.box.visualAxis,H.onPlaced?.();let J={...e,width:r,originX:s,pages:K.map(H=>H.bounds),lines:h,getVisualAxis:(H,G)=>ne(H,i(G)),getHostExtent:(H,G)=>y[H]?.hostExtents.get(i(G)),getRangeColumns:(H,G,$)=>hn(h[H],G,$,i)};return{pages:K,attachmentContext:J}},L=T(),C=cs(f,L.attachmentContext,y,i,m,p);C.needsRelayout&&(L=T(),C=xn(f,L.attachmentContext,y,i,m,!1));let N=L.pages,P=0,k=n.map(v=>{let R=u.get(v),{geometry:D}=R?rs(R):C.items[P++];return{kind:v.kind,regions:D.regions,layer:v.layer,sourceSpan:v.sourceSpan,paint(K){D.paint(K)}}}),B={x:0,y:0,w:0,h:0};function*_(){for(let v of N)yield v.bounds;for(let v of g)yield te(v);for(let v of k)yield*v.regions}return mt(B,_()),{diagnostics:a.diagnostics,objects:g,attachments:k,bounds:B,lineCount:y.length,pages:N}}function _i(a){if(a.decorations.length===0)return;let e=0,t=-1/0,n=0,o=-1/0;for(let s of["above","below"]){let i=s==="above",c=a.decorations.length===1?a.decorations:a.decorations.filter(m=>m[s]);c.length>1&&c.sort((m,y)=>m[s].order-y[s].order);let l=i?0:a.ports["decoration.below"]?.y??a.box.h,p=i?-1/0:a.box.h,u=p;for(let m of c){let y=m[s];if(!y)continue;let d=Math.max(0,y.height??0);!i&&!m.paint&&(l=Math.max(l,u));let g=i?l-(y.gap??0)-d:l+(y.gap??0);y.place?.(g),l=i?g:g+d,n=Math.min(n,g),p=i?Math.max(p,g+d):l,m.paint&&(e=Math.min(e,g),u=i?Math.max(u,g+d):l)}o=Math.max(o,p),t=Math.max(t,u)}a.box.h=t;let r=Math.max(0,o-t);(n!==0||r!==0)&&Ft.set(a,{top:n,bottom:r,contentTop:e})}function Ri(a){let e=()=>({columns:[],hostExtents:new Map,attachmentExtents:new Map}),t=[],n=[],o=e();for(let r of a.columns){let s=[];for(;t.length<r[0].layoutLine;)t.push(o),o=e();for(let i of r){let c=i.addon?.pageBreakBefore;c!==void 0&&(n[t.length]=(n[t.length]??!0)&&c),M(i)&&s.push(i)}s.length&&o.columns.push(s)}return(o.columns.length>0||n[t.length]!==void 0||t.length===0)&&t.push(o),{lines:t,pageBreaks:n}}function Mt(a,e,t){a.top=Math.min(a.top,e),a.bottom=Math.max(a.bottom,t)}function yo(a,e,t,n){let o=a.get(e);o?Mt(o,t,n):a.set(e,{top:t,bottom:n})}function ho(a,e,t={},n=!1){let o=[],r=new Map,s=new Map,i;for(let l=0;l<a.length;l++)for(let p of a[l]){r.set(p,l),mn(p.springConfig,t.globalC);let u=s.get(p.track);u?u.push(p):s.set(p.track,[p])}let c={index:e,columns:a,trackRuns:s,columnOf:l=>r.get(l)??-1,trackIndexOf(l){if(!i){i=new Map;for(let p of s.values())for(let u=0;u<p.length;u++)i.set(p[u],u)}return i.get(l)??-1},registerHorizontalLayoutHook(l,p,u){let m=r.get(l),y=r.get(p);m===void 0||y===void 0||o.push({start:Math.min(m,y),end:Math.max(m,y),hook:u})}};for(let l of a)for(let p of l)p.prepareHorizontal?.(c);return{view:c,layout(l,p){let u=a.map(y=>y.map(d=>{let g=dn(d.springConfig,d.box,d,t.globalC);return n&&(g.margin_L=g.margin_R=0),g})),m=uo(u,l,t,o,p);return Object.assign(u,{extra:m.extra,groupOf:m.groupOf})}}}function Mi(a,e,t,n){let o=a.map(({columns:i},c)=>{let{extra:l,groupOf:p}=e[c];if(l<0||!i.length)return;let u=[],m=!1;for(let S=0;S<i.length;S++)i[S].some(T=>T.mergeKey===Q)?m&&(u.push(S),m=!1):i[S].some(T=>!T.T.isZero())&&(m=!0);if(m||u.pop(),!u.length)return;let y=S=>p?p[S]:S,d=y(i.length-1),g=[...u.map(y),d],f=0,x=0,h=g.map(S=>(S-=x,x+=S,S)),b=g.map((S,T)=>{let L=T<u.length?i[u[T]][0].box.x+i[u[T]][0].box.anchor:t,C=L-f;return f=L,d>0?C-l*(h[T]/d):C});return{columns:i,extra:l,groupAt:y,totalGaps:d,ends:g,gaps:h,minW:b}}),r=(i,c)=>i%c===0||c%i===0,s=(i,c)=>c?s(c,i%c):i;for(let i=0;i<o.length;i++){let c=o[i];if(!c||c.extra<=0||!c.totalGaps)continue;let l=c.minW.length,p=i,u=i,m=l,y=b=>!!b&&r(b.minW.length,l)&&r(b.minW.length,m);for(;o[p].extra>0&&n[p]===void 0&&y(o[p-1]);)m=Math.max(m,o[--p].minW.length);for(;o[u].extra>0&&n[u+1]===void 0&&y(o[u+1]);)m=Math.max(m,o[++u].minW.length);if(p===u)continue;let d=(b,S)=>{let T=o.slice(b,S+1),L=T.reduce((_,v)=>_/s(_,v.minW.length)*v.minW.length,1),C=L/l,N=new Array(L).fill(0);for(let _ of[...T].sort((v,R)=>R.minW.length-v.minW.length)){let v=L/_.minW.length;for(let R=0;R<_.minW.length;R++){let D=_.minW[R],K=0;for(let X=0;X<v;X++)K+=N[R*v+X];if(D>K)for(let X=0;X<v;X++)N[R*v+X]+=(D-K)/v}}let P=N.map((_,v)=>Number(T.every(R=>R.gaps[Math.floor(v*R.minW.length/L)]>0))),k=t;for(let _=0;_<L;_++)P[_]||(k-=N[_]);for(let _=0;_<L;_++){let v=P.reduce((D,K)=>D+K,0);if(!v||k<=0)break;let R=k/v;if(!N.some((D,K)=>P[K]&&D>R&&(k-=D,P[K]=0,!0))){for(let D=0;D<L;D++)P[D]&&(N[D]=R);break}}let B=c.minW.map((_,v)=>{if(!c.gaps[v])return _;let R=0;for(let D=0;D<C;D++)R+=N[v*C+D];return R});return{group:T,target:B}},{group:g,target:f}=d(p,u);if(f.reduce((b,S)=>b+S,0)>t+1e-6){let b=L=>L?.minW.length===l&&L.minW.every((C,N)=>Math.abs(C-c.minW[N])<=1e-6&&!L.gaps[N]==!c.gaps[N]),S=i,T=i;for(;S>p&&b(o[S-1]);)S--;for(;T<u&&b(o[T+1]);)T++;({group:g,target:f}=d(Math.max(p,S-1),Math.min(u,T+1)))}let x=c.gaps.map((b,S)=>b>0?Number(g.every(T=>T.gaps[Math.floor(S*T.minW.length/l)]>0)):0);if(!x.some(Boolean))for(let b=0;b<l;b++)x[b]=+(c.gaps[b]>0);for(let b=0;b<l;b++){let S=t,T=0,L=0;for(let N=0;N<l;N++)x[N]?(T+=f[N],L++):S-=f[N];if(!L||Math.abs(S-T)<=1e-6)break;let C=(S-T)/L;if(!f.some((N,P)=>x[P]&&N+C<c.minW[P]&&(f[P]=c.minW[P],x[P]=0,!0))){for(let N=0;N<l;N++)x[N]&&(f[N]+=C);break}}let h=new Float64Array(c.totalGaps+1);for(let b=0,S=0;b<l;b++){let T=c.gaps[b]>0?(f[b]-c.minW[b])/c.gaps[b]-c.extra/c.totalGaps:0;for(;S<c.ends[b];S++)h[S+1]=h[S]+T}for(let b=0;b<c.columns.length;b++){let S=h[c.groupAt(b)];if(S)for(let T of c.columns[b])T.box.x+=S}}}function dt(a,e){return a.length===0?0:ss(a.map(t=>[t]),e).width}function ss(a,e){for(let r of a)for(let s of r)Bt(s,e);let t=ho(a,a[0][0].layoutLine,{},!0),n=1/0,o=-1/0;for(let r of t.layout(1/0))for(let s of r){let i=s.box.x+s.box.anchor;n=Math.min(n,i-s.WL),o=Math.max(o,i+s.WR)}for(let r of a)for(let s of r)s.box.x-=n;return{width:o-n,view:t.view}}function Fi(a,{width:e,view:t},n,o,r,s,i,c){let l=a.flat(),p={hostExtents:new Map,attachmentExtents:new Map},u=0;for(let P of l)ls(p.hostExtents,P),u=Math.max(u,P.ast.size*as);let m=l.map(P=>({x:P.box.x,y:0})),y=()=>{let P=ps(p,n,u);return l.forEach((k,B)=>{k.box.y=m[B].y=P.axes.get(k.track)-k.box.visualAxis,k.onPlaced?.()}),P},d=y();if(o.length===0)return{height:d.height,positions:m,items:[]};let g=yn(n),f=[],x=[];f[t.index]=p,x[t.index]=t;let h=()=>cs(o,{...r,width:e,originX:0,pages:[],lines:x,getVisualAxis:(P,k)=>d.axes.get(g(k))??0,getHostExtent:(P,k)=>f[P]?.hostExtents.get(g(k)),getRangeColumns:(P,k,B)=>hn(x[P],k,B,g)},f,g,s,i,c),b=h();b.needsRelayout&&(d=y(),b=h());let S=l[0],T={x:S.box.x,y:S.box.y},L=b.layoutItems&&is(S,c),C=L&&(L.x!==0||L.y!==0)?{x:T.x-L.x,y:T.y-L.y}:T,N=b.items.map((P,k)=>({...P,reference:S,position:T,...b.layoutItems&&{layout:{...b.layoutItems[k],position:C}}}));return{height:d.height,positions:m,items:N}}function Bi(a){let e=new Map;for(let t of a){let[n,...o]=t.endPoints??[];for(let r=n?.foldedInto;r;r=r.foldedInto){let s=r;if(!o.every(c=>Oi(s,c)))continue;let i=e.get(r);i?i.push(t):e.set(r,[t])}}return e}function Oi(a,e){for(let t=e.foldedInto;t;t=t.foldedInto)if(t===a)return!0;return!1}function rs(a,e=!1){let t=e?a.layout??a:a,{position:n,geometry:o}=t,r=a.reference.box.x-n.x,s=a.reference.box.y-n.y;if(r===0&&s===0)return t;let i=c=>({...c,x:c.x+r,y:c.y+s});return{geometry:{regions:o.regions.map(i),occupancy:o.occupancy?.map(i),paint:c=>o.paint(new Qe(c,r,s))}}}function Ii(a,e,t){if(t!==void 0)return new Array(a).fill(t);let n=new Array(a).fill(0),o=0;for(let r of e){let s=r.ast.size*as;s>n[r.layoutLine]&&(n[r.layoutLine]=s),s>o&&(o=s)}for(let r=0;r<a;r++)n[r]||=o;return n}function is(a,e){let t=0,n=0;for(let o=a;o&&o!==e;o=o.foldedInto)t+=o.placementOffset?.x??0,n+=o.placementOffset?.y??0;return{x:t,y:n}}function cs(a,e,t,n,o,r,s){if(a.length===0)return{items:[],needsRelayout:!1};let i=[];for(let u of r){let{x:m,y}=is(u,s);(m!==0||y!==0)&&i.push({node:u,x:m,y,boxX:u.box.x,boxY:u.box.y})}let c=i.length>0||a.some(u=>u.placementOffset?.x||u.placementOffset?.y),l;if(c){for(let{node:u,x:m,y}of i)u.box.x-=m,u.box.y-=y;try{l=xn(a,{...e,layoutOnly:!0},t,n,o,!0)}finally{for(let{node:u,boxX:m,boxY:y}of i)u.box.x=m,u.box.y=y}}else l=xn(a,e,t,n,o,!0);if(!c)return l;let p;return{needsRelayout:l.needsRelayout,layoutItems:l.items,get items(){return p??=xn(a,e,t,n,o,!1).items}}}function xn(a,e,t,n,o,r){let s=new Map,i=[],c=!1;function l(y){let d=s.get(y);return d||(d=o(y,e.layoutOnly),d&&s.set(y,d)),d}function p(y,d,g){let f=e.lines[y],x=g===void 0?new Map:void 0,h,b=d&&"left"in d?d:void 0;if(!f||b&&b.left>=b.right)return x;let S=(B,_,v)=>{x?yo(x,B,_,v):h?Mt(h,_,v):h={top:_,bottom:v}},T=d&&!("left"in d)?d:void 0,{start:L,end:C}=fn(f,T),N=g&&n(g),P=b?.left??(T?1/0:e.originX),k=b?.right??(T?-1/0:e.originX+e.width);for(let B=L;B<=C;B++)for(let _ of f.columns[B]){if(N&&_.track!==N||b&&(_.box.x+_.box.w<=P||_.box.x>=k))continue;T&&(_.box.x<P&&(P=_.box.x),_.box.x+_.box.w>k&&(k=_.box.x+_.box.w));let v=Ft.get(_),R=v?.top??0,D=_.box.y+R-e.getVisualAxis(y,_.track);S(_.track,D,D+(_.box.h-R+(v?.bottom??0)))}for(let B of i[y]??[])N&&B.track!==N||B.right<=P||B.left>=k||S(B.track,B.top,B.bottom);return x??h}let u={...e,getRangeExtents:p,getHorizontalExtents:(y,d,g)=>p(y,{left:d,right:g}),getAttachmentOccupancy(y){let d=l(y)?.geometry;return d&&(d.occupancy??d.regions)},getAttachmentBox(y){let d=l(y);if(!d)throw new Error("Layout attachment dependency has not been measured");return d.box||(d.box={x:0,y:0,w:0,h:0},mt(d.box,d.geometry.regions)),d.box},getContentBounds(y){let d=[];for(let f of y.nodes)M(f)&&(f.box.w>0||f.box.h>0)&&d.push(te(f,!0));for(let f of y.attachments){if(!Ne(f))continue;let x=l(f);if(!(!x&&!a.includes(f))){if(!x)throw new Error("Layout attachment dependency has not been measured");for(let h of x.geometry.regions)(h.w>0||h.h>0)&&d.push(h)}}let g={x:0,y:0,w:0,h:0};return mt(g,d)?g:void 0}};return{items:a.map(y=>{let d=y.createGeometry(u),g={geometry:d};s.set(y,g);for(let f of d.occupancy??d.regions){if(f.line===void 0)continue;let x=t[f.line],h=n(f.track),b=f.y-e.getVisualAxis(f.line,h),S=b+f.h,T=x.hostExtents.get(h),L=x.attachmentExtents.get(h);r&&(b<Math.min(T?.top??1/0,L?.top??1/0)||S>Math.max(T?.bottom??-1/0,L?.bottom??-1/0))&&(c=!0),r&&yo(x.attachmentExtents,h,b,S),(i[f.line]??=[]).push({track:h,left:f.x,right:f.x+f.w,top:b,bottom:S})}return g}),needsRelayout:c}}function ls(a,e){let t=Ft.get(e),n=t?.top??0,o=e.box.h-n+(t?.bottom??0),r=n-e.box.visualAxis;yo(a,e.track,r,r+o)}function ps(a,e,t){let n=new Map,o=c=>{let l=a.hostExtents.get(c),p=a.attachmentExtents.get(c),u=l?{top:l.top,bottom:l.bottom}:null;p&&(u?Mt(u,p.top,p.bottom):u={top:p.top,bottom:p.bottom});let m=[];for(let d of c.groups){let g=d.members.map(o);if(g.every(h=>h===null))continue;let f=d.measure(g,t),x=null;for(let h of f){if(!h)continue;let b=h.offset+h.extent.top,S=h.offset+h.extent.bottom;x?Mt(x,b,S):x={top:b,bottom:S}}x&&m.push({group:d,placements:f,extent:x})}let y=(d,g)=>{u??={top:0,bottom:0};for(let f=0;f<d.group.members.length;f++){let x=d.placements[f];x&&n.set(d.group.members[f],g+x.offset)}Mt(u,g+d.extent.top,g+d.extent.bottom)};for(let d of m)d.group.place||y(d,0);for(let d of m){let g=d.group.place;if(!g)continue;y(d,g(u??{top:0,bottom:0},d.extent,t))}return u},r=o(e),s=new Map;if(!r)return{axes:s,height:0};let i=(c,l)=>{s.set(c,l);for(let p of c.groups)for(let u of p.members){let m=n.get(u);m!==void 0&&i(u,l+m)}};return i(e,-r.top),{axes:s,height:r.bottom-r.top}}function Je(a){return a.pages.length>0?a.pages.map(e=>e.bounds):[a.bounds]}function Me(a,e){let t=e.kind;t&&a.beginGroup?.({kind:t}),e.paint(a);for(let n of e.decorations)n.paint?.(a);t&&a.endGroup?.()}function us(a,e,t){for(let n of e){if(n.layer!==t)continue;let o=n.kind;o&&a.beginGroup?.({kind:o}),n.paint(a),o&&a.endGroup?.()}}function go(a,e){us(e,a.attachments,"background");for(let t of a.objects)Me(e,t);us(e,a.attachments,"foreground")}var xo=class{constructor(e,t){this.pages=e;this.painters=t}pages;painters;groups=[];opened=new Map;beginGroup(e){this.groups.push(e)}endGroup(){let e=this.groups.length;this.groups.pop();for(let[t,n]of this.opened)n<e||(this.painters[t].endGroup?.(),e>1?this.opened.set(t,e-1):this.opened.delete(t))}route(e,t,n){let o=0,r=this.pages.length;for(;o<r;){let i=o+r>>>1,c=this.pages[i];c.y+c.h<e?o=i+1:r=i}let s=this.groups.length;for(let i=o;i<this.pages.length&&this.pages[i].y<=t;i++){let c=this.painters[i],l=this.opened.get(i)??0;if(l<s){for(let p=l;p<s;p++)c.beginGroup?.(this.groups[p]);this.opened.set(i,s)}n(c)}}drawText(e,t,n,o){this.route(n,n,r=>r.drawText(e,t,n,o))}drawLine(e,t,n,o,r){let s=(r?.strokeWidth??1)/2;this.route(Math.min(t,o)-s,Math.max(t,o)+s,i=>i.drawLine(e,t,n,o,r))}drawRect(e,t,n,o,r){let s=r?.stroke?(r.strokeWidth??1)/2:0;this.route(t-s,t+Math.max(0,o)+s,i=>{i.drawRect(e,t,n,o,r)})}drawCircle(e,t,n,o){let r=o?.stroke?(o.strokeWidth??1)/2:0,s=Math.max(0,n)+r;this.route(t-s,t+s,i=>i.drawCircle(e,t,n,o))}drawPath(e,t,n){if(e.length===0)return;let o=1/0,r=-1/0,s=c=>{o=Math.min(o,c),r=Math.max(r,c)};for(let c of e)c.op!=="Z"&&(c.op==="Q"&&s(c.cy),c.op==="C"&&(s(c.cy1),s(c.cy2)),s(c.y));if(n){let c=n.y+o*n.scaleY,l=n.y+r*n.scaleY;o=Math.min(c,l),r=Math.max(c,l)}if(!Number.isFinite(o))return;let i=t?.stroke?(t.strokeWidth??1)/2:0;this.route(o-i,r+i,c=>{c.drawPath(e,t,n)})}};function yt(a,e){let t=Je(a);if(e.length!==t.length)throw new Error(`Expected ${t.length} page painters, got ${e.length}`);go(a,new xo(t,e))}var Di=[{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}],Vi=[{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 ms(a,e,t,n){for(let o of e)o.op==="C"?a.push({op:"C",cx1:t(o.cx1),cy1:n(o.cy1),cx2:t(o.cx2),cy2:n(o.cy2),x:t(o.x),y:n(o.y)}):a.push({op:o.op,x:t(o.x),y:n(o.y)})}function bo(a,e,t){let n=t!=="",o=Math.max(1,Math.round(a/(e*.3))-(n?1:0)),r=n?113.5313:54.2813,s=n?85.7344+72.8125*o:87.37505+72.8125*(o-1),i=a/s,c=t!=="down",l=(m,y)=>c?d=>(m-y-d)*i:d=>(y+d)*i,p=[],u=l(r,n?27.4688:0);for(let m=0;m<o;m++)ms(p,Di,u,l(s,m*72.8125));return n&&ms(p,Vi,l(r,0),l(s,o*72.8125+-7.9375)),{commands:p,width:r*i}}function ds(a){let e=a,t=e?.ast;return(t?.callName==="up"||t?.callName==="down")&&Array.isArray(e?.members)&&Array.isArray(t.contents)?e:null}function ys(a){let e=a.box.anchor;for(let t of a.members){let n=ds(t);e=Math.max(e,n?ys(n):t.box.anchor)}return e}var So=class extends E{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]}loweringEnter(e){let t={temporals:0,attachments:[],onTemporal:n=>{_(n)&&(t.temporals++,Ra(n,this.dx,this.dy),Fi(n,this.dw,this.dh))},onAttachment:n=>{Ne(n)&&t.attachments.push(n)}};return e.beginLoweringGroup(this,t),[]}loweringExit(e){let{temporals:t,attachments:n}=e.endLoweringGroup(this);if(t===0&&n.length===0)e.diagnostics.push(new O("W_ADJUST_NO_TARGET","@adjust \u6CA1\u6709\u627E\u5230\u53EF\u8C03\u6574\u7684\u5BF9\u8C61",this.sourceSpan));else if(t===0)for(let o of n)Ra(o,this.dx,this.dy);return[]}constructor(e,t,n,o=null){super(e,o);let[r,s,i,c,l]=this.getArgValue(t,n);r.parent=this,this.target=r,this.dx=n.length2px(s),this.dy=n.length2px(i),this.dw=n.length2px(c),this.dh=n.length2px(l)}toString(e){return`@adjust(${this.target.toString(e)}, dx=${this.dx}px, dy=${this.dy}px, dw=${this.dw}px, dh=${this.dh}px)`}},po=lo;function Ra(a,e,t){if(e===0&&t===0)return;let n=a.placementOffset;a.placementOffset={x:(n?.x??0)+e,y:(n?.y??0)+t}}function Fi(a,e,t){if(e===0&&t===0)return;let n=a.finalizeLayout;a.finalizeLayout=o=>{n?.call(a,o);let r=Math.max(0,a.box.w+e);a.box.anchor=a.box.w>0?a.box.anchor*r/a.box.w:0,a.box.w=r,a.box.h=Math.max(0,a.box.h+t)}}var hn=1,Bi=8,Oi=16,uo=32,Ma=1e-6,Ii=.01;function xn(a,e=hn){let t=a.alpha_L??a.alpha_R??Bi;a.alpha_L??=t,a.alpha_R??=t;let n=a.mu_L??a.mu_R??Oi;a.mu_L??=n,a.mu_R??=n,a.beta_L??=e/Math.max(a.alpha_L,Ma),a.beta_R??=e/Math.max(a.alpha_R,Ma)}function gn(a,e,t,n=hn){xn(a,n);let o=Math.pow(Math.max(t.T.toNumber(),Ii),.5);return{config:a,box:e,time:t,duration_L:o,duration_R:o,WL:e.anchor,WR:e.w-e.anchor,margin_L:o*a.alpha_L,margin_R:o*a.alpha_R}}function Di(a,e=hn){let t=new Map,n=0;for(let r of a)for(let s of r)t.has(s.time.track)||t.set(s.time.track,n++);let o=[];for(let r of a){if(r.length===0)continue;let s=Array(r.length);o.push(s);let i=0,c=0,l=n;for(let u of r){u.WL>i&&(i=u.WL),u.WR>c&&(c=u.WR);let m=t.get(u.time.track);if(s[m]){let f=s[m];u.time.T.compare(f.time.T)>0?(s[m]=u,s[l++]=f):s[l++]=u}else s[m]=u}let p=r[0].time.t;for(let u of t){let m=u[1];s[m]||(s[m]=gn({alpha_L:i,alpha_R:c},{x:0,w:0,anchor:0},{t:p,T:new I(1),track:u[0]},e))}}return{mat:o,rows:n}}function Vi(a,e,t,n){let o=n-t-a.WR-e.WL,r=a.margin_R+e.margin_L;if(o>=r)return{force:0,stiffness:0};let s=a.config.beta_R/a.duration_R,i=e.config.beta_L/e.duration_L,c=s*i/(s+i),l,p;if(o<0){let u=a.config.mu_R*e.config.mu_L/(a.config.mu_R+e.config.mu_L);l=c*r-u*o,p=u}else{let u=r-o;l=c*u,p=c}return{force:l,stiffness:p}}function Hi(a,e,t=uo){let n=e-a.WL,o=a.margin_L;if(n>=o)return{force:0,stiffness:0};let r=a.config.beta_L/a.duration_L;if(n>=0)return{force:r*(o-n),stiffness:r};let s=a.config.mu_L*t;return{force:a.config.alpha_L*a.config.beta_L-s*n,stiffness:s}}function Gi(a,e,t,n=uo){let o=t-(e+a.WR),r=a.margin_R;if(o>=r)return{force:0,stiffness:0};let s=a.config.beta_R/a.duration_R;if(o>=0)return{force:s*(r-o),stiffness:s};let i=a.config.mu_R*n;return{force:a.config.alpha_R*a.config.beta_R-i*o,stiffness:i}}function zi(a){return{damping:a.damping??.6,maxIter:a.maxIter??100,eps:a.eps??.01,crossPunish:a.crossPunish??uo,globalC:a.globalC??hn}}function ji(a,e,t,n,o){let{damping:r,maxIter:s,eps:i,crossPunish:c}=o,l=a.length,p=new Float64Array(e);for(let S=0;S<l;S++){let T=0,L=a[S];for(let C=0;C<e;C++){let A=p[C]+L[C].WL+L[C].margin_L;A>T&&(T=A)}for(let C=0;C<e;C++)p[C]=T+L[C].WR+L[C].margin_R;t[S]=T}let u=p.reduce((S,T)=>Math.max(S,T),0);if(u<=n)return!0;u=n/u;for(let S=0;S<l;S++)t[S]*=u;let m=new Float64Array(l),f=new Float64Array(l+1);function d(S){m.fill(0),f.fill(0);for(let T=0;T<e;T++){let L=a[0][T],C=Hi(L,S[0],c);m[0]+=C.force,f[0]+=C.stiffness;for(let N=1;N<l;N++){let F=a[N-1][T],B=a[N][T],$=Vi(F,B,S[N-1],S[N]);m[N-1]-=$.force,m[N]+=$.force,f[N]+=$.stiffness}let A=a[l-1][T],v=Gi(A,S[l-1],n,c);m[l-1]-=v.force,f[l]+=v.stiffness}return m}let h=new Float64Array(l),y=new Float64Array(l);function g(){for(let T=0;T<l;T++){let L=T===0?0:f[T]/h[T-1],C=f[T]+f[T+1]+1e-4-L*f[T];if(!(C>0)||!Number.isFinite(C))throw new Error("Horizontal spring stiffness must produce a finite positive definite system");h[T]=C,y[T]=m[T]+(T===0?0:L*y[T-1])}y[l-1]/=h[l-1];for(let T=l-2;T>=0;T--)y[T]=(y[T]+f[T+1]*y[T+1])/h[T];return y}let x=0,b=0;for(;x<s;x++){let S=d(t);b=0;for(let L=0;L<S.length;L++){let C=Math.abs(S[L]);C>b&&(b=C)}if(b<i)break;let T=g();for(let L=0;L<l;L++)t[L]+=r*T[L]}return!1}function ut(a,e,t,n,o,r,s){if(t.length!==a.length||n.length!==Math.max(0,t.length-1))throw new Error("Horizontal region state does not match its columns");if(t.length===0||e===0)return{extra:-1};let i=n.some(d=>d!==0),c,l,p=a,u=t;if(i){c=new Uint32Array(t.length),l=new Float64Array(t.length),p=[];for(let d=0;d<t.length;){let h=d;for(;h<n.length&&n[h];)h++;let y=p.length;for(let g=d;g<=h;g++)c[g]=y,l[g]=t[g]-t[d];if(d===h)p.push(a[d]);else{let g=t[h]-t[d];p.push(Array.from({length:e},(x,b)=>{let S=a[d][b],T=a[h][b];return{config:{alpha_L:S.config.alpha_L,alpha_R:T.config.alpha_R,mu_L:S.config.mu_L,mu_R:T.config.mu_R,beta_L:S.config.beta_L,beta_R:T.config.beta_R},box:S.box,time:S.time,duration_L:S.duration_L,duration_R:T.duration_R,WL:S.WL,WR:g+T.WR,margin_L:S.margin_L,margin_R:T.margin_R}}))}d=h+1}u=new Float64Array(p.length)}let m=ji(p,e,u,o,r);n.fill(1);let f=-1;if(s!==void 0){let d=0,h=0;for(let g=0;g<e;g++)d=Math.max(d,p[0][g].WL),h=Math.max(h,p[p.length-1][g].WR);let y=u[u.length-1]+h-u[0]+d;if(!m||y>=o*s){let g=d-u[0],x=o-y;for(let b=0;b<u.length;b++)u[b]+=g+(u.length>1?x*b/(u.length-1):0);(u.length>1||Math.abs(x)<=1e-6)&&(f=m&&u.length>1&&x>0?x:0)}}if(i)for(let d=0;d<t.length;d++)t[d]=u[c[d]]+l[d];return{extra:f,groupOf:c}}function mo(a,e,t={},n=[],o){let r=zi(t),{mat:s,rows:i}=Di(a,r.globalC),c=new Float64Array(s.length),l=new Uint8Array(Math.max(0,s.length-1)),p=n.length>1?[...n].sort((m,f)=>m.end-m.start-(f.end-f.start)):n;for(let{start:m,end:f,hook:d}of p){if(m<0||f<m||f>=s.length)throw new Error("Horizontal layout registration references invalid columns");d({columns:s,rows:i,start:m,end:f,X:c,fixed:l,options:r})}let u=ut(s,i,c,l,e,r,o);for(let m=0;m<s.length;m++)for(let f of s[m])f.box.x=c[m]-f.box.anchor;return Object.assign(s,u)}var Ft=class extends Error{constructor(t,n,o){super(`Page cannot fit layout line ${t}: requires ${n}px, available ${o}px`);this.line=t;this.requiredHeight=n;this.availableHeight=o;this.name="PageLayoutError"}line;requiredHeight;availableHeight},ue={width:794,height:1/0,marginTop:45,marginBottom:48,marginLeft:40,marginRight:40,fillRatio:.5};function mt(a={}){let e=a.height??ue.height,t={width:a.width??ue.width,height:e<=0?1/0:e,marginTop:Math.max(0,a.marginTop??ue.marginTop),marginBottom:Math.max(0,a.marginBottom??ue.marginBottom),marginLeft:Math.max(0,a.marginLeft??ue.marginLeft),marginRight:Math.max(0,a.marginRight??ue.marginRight),fillRatio:a.fillRatio??ue.fillRatio};if(!Number.isFinite(t.width)||t.width<=0)throw new Error(`Page width must be a positive finite number, got ${t.width}`);if(t.height!==1/0&&(!Number.isFinite(t.height)||t.height<=0))throw new Error(`Page height must be positive or Infinity, got ${t.height}`);if(![t.marginTop,t.marginBottom,t.marginLeft,t.marginRight].every(Number.isFinite))throw new Error("Page margins must be finite non-negative numbers");let n=t.width-t.marginLeft-t.marginRight;if(n<=0)throw new Error(`Page horizontal margins leave no content width: ${n}px`);let o=t.height-t.marginTop-t.marginBottom;if(Number.isFinite(t.height)&&o<=0)throw new Error(`Page vertical margins leave no content height: ${o}px`);return t}function bn(a,e,t=[],n=[]){let o=e.height-e.marginTop-e.marginBottom,r=[],s=new Array(a.length).fill(0),i=0,c=0,l=0,p=(u,m)=>{let f=u-c,d=m?Math.max(0,o-l)/f:0,h=i+e.marginTop;for(let g=c;g<u;g++)s[g]=h,h+=a[g]+(g+1<u?(n[g+1]??0)+d:0);let y=Number.isFinite(e.height)?e.height:h-i+e.marginBottom;r.push({bounds:{x:0,y:i,w:e.width,h:y},lineStart:c,lineEnd:u}),i+=y,c=u,l=0};for(let u=0;u<a.length;u++){let m=a[u],f=n[u]??0;if(Number.isFinite(e.height)&&m>o+1e-6)throw new Ft(u,m,o);u>c&&(t[u]!==void 0||Number.isFinite(e.height)&&l+f+m>o+1e-6)&&p(u,Number.isFinite(e.height)&&(t[u]??!0)),l+=(u>c?f:0)+m}return a.length>c&&p(a.length,!1),{pages:r,lineTops:s}}var Fa={start:0,end:-1};function Sn(a){let e=new Set,t=n=>{e.add(n);for(let o of n.groups)for(let r of o.members)t(r)};return t(a),n=>{for(let o=n;o;o=o.parent)if(e.has(o))return o;return n}}function Ba(a,e){for(let t=e;t;){let n=a.columnOf(t);if(n>=0)return n;let o=t instanceof H?t.foldedInto:void 0;t=o&&_(o)?o:void 0}return-1}function Tn(a,e){if(!e)return{start:0,end:a.columns.length-1};let[t,n]=e;if(t.layoutLine>n.layoutLine&&([t,n]=[n,t]),a.index<t.layoutLine||a.index>n.layoutLine)return Fa;let o=t.layoutLine<a.index?0:Ba(a,t),r=n.layoutLine>a.index?a.columns.length-1:Ba(a,n);return o<0||r<0?Fa:{start:Math.min(o,r),end:Math.max(o,r)}}function yo(a,e,t,n){if(!a)return[];let{start:o,end:r}=Tn(a,e),s=a.columns.slice(o,r+1);if(!t)return s;let i=n(t),c=l=>l.track===i;return s.every(l=>l.every(c))?s:s.map(l=>l.filter(c))}function Ce(a,e,t,n=a.originX){return a.lines[e]?.trackRuns.get(t)?.find(r=>!r.T.isZero())?.box.x??n}function Ae(a,e){let t=a.lines[e]?.trackRuns;if(!t||t.size===0)return a.originX+a.width;let n=a.originX;for(let o of t.values())for(let r of o)n=Math.max(n,r.box.x+r.box.w);return n}var Bt=class{constructor(e,t,n){this.target=e;this.dx=t;this.dy=n}target;dx;dy;beginGroup(e){this.target.beginGroup?.(e)}endGroup(){this.target.endGroup?.()}drawText(e,t,n,o){this.target.drawText(e,t+this.dx,n+this.dy,o)}drawLine(e,t,n,o,r){this.target.drawLine(e+this.dx,t+this.dy,n+this.dx,o+this.dy,r)}drawRect(e,t,n,o,r){this.target.drawRect(e+this.dx,t+this.dy,n,o,r)}drawCircle(e,t,n,o){this.target.drawCircle(e+this.dx,t+this.dy,n,o)}drawPath(e,t,n){this.target.drawPath(e,t,{x:(n?.x??0)+this.dx,y:(n?.y??0)+this.dy,scaleX:n?.scaleX??1,scaleY:n?.scaleY??1})}};var Oa=.75,Ln=new WeakMap;function ee(a,e=!1){let{box:t}=a,n=Ln.get(a);if(!n)return t;let o=e?n.contentTop:n.top,r=e?0:n.bottom;return{x:t.x,y:t.y+o,w:t.w,h:t.h-o+r}}function dt(a,e){let t=1/0,n=1/0,o=-1/0,r=-1/0;for(let s of e)t=Math.min(t,s.x),n=Math.min(n,s.y),o=Math.max(o,s.x+s.w),r=Math.max(r,s.y+s.h);return Number.isFinite(t)?(a.x=t,a.y=n,a.w=o-t,a.h=r-n,!0):(a.x=a.y=a.w=a.h=0,!1)}function It(a,e){if(a.springConfig={},a.decorations&&Ln.delete(a),a.decorations=[],a.ports={},a.box.x=a.box.y=0,a.prepareLayout(e),a.addon)for(let[t,n]of Object.entries(a.addon)){let o=e.decorationHandlers.get(t);if(!o)continue;let r=o(a,n,e);r&&a.decorations.push(r)}Wi(a),a.finalizeLayout?.(e)}function fo(a,e,t={}){let n=a.attachments.filter(Ne),o=mt(a.page),r=o.width-o.marginLeft-o.marginRight,s=o.marginLeft,i=Sn(a.rootTrack),c=new Map(n.map((E,G)=>[E,G])),l=Xi(n),p=qi(a),u=[],m=new Map,f=(E,G=!1)=>{let K=m.get(E);return K&&Zi(K,G)};e={...e,solverOptions:t,layoutSubdomain(E,G,K,ne){let J=Ia(G,e),z=new Set(G.flat()),W=ce=>{for(let k=ce;k&&k!==E;k=k.foldedInto)if(z.has(k))return!0;return!1},j=ne.filter(Ne).filter(ce=>!ce.endPoints?.length);for(let ce of l.get(E)??[])!m.has(ce)&&ce.endPoints.every(W)&&j.push(ce);j.sort((ce,k)=>c.get(ce)-c.get(k));let q=p.filter(W),Te=q.length>0||j.some(wn)||u.some(W);Te&&u.push(E);let fe=Yi(G,J,K,j,e,f,{nodes:q,layoutOnly:Te});return j.forEach((ce,k)=>m.set(ce,fe.items[k])),{width:J.width,height:fe.height,positions:fe.positions}}};let{lines:d,pageBreaks:h}=$i(a),y=[];for(let E of d)for(let G of E.columns)for(let K of G)y.push(K),It(K,e);let g=n.filter(E=>!m.has(E)),x=d.map((E,G)=>xo(E.columns,G,t)),b=x.map(E=>E.view);for(let E of g)E.prepareHorizontal?.(b,e);let S=x.map(E=>E.layout(r,o.fillRatio));Ui(b,S,r,h);for(let E of x)for(let G of E.view.columns)for(let K of G)K.box.x+=s;if(t.horizontalOnly)return{diagnostics:a.diagnostics,objects:y,attachments:[],bounds:{x:0,y:0,w:0,h:0},lineCount:d.length,pages:[]};for(let E of y){let G=d[E.layoutLine];za(G.hostExtents,E)}let T=Ji(d.length,y,t.rowGap),L={lines:d,views:b,lift:i},C=[],A=()=>{let E=[],G=[],K=d.map((z,W)=>{let j=ja(z,a.rootTrack,T[W]);E.push(j.height);let q=1/0;for(let ce of z.columns)for(let k of ce)q=Math.min(q,(j.axes.get(k.track)??0)-k.ast.size/2);let{gap:Te=0,minGap:fe=0}=z.breakBefore??{};return G.push(Math.max(Te-(q<1/0?Math.max(0,q):0),Math.min(Te,fe))),j.axes}),ne;try{({pages:C,lineTops:ne}=bn(E,o,h,G))}catch(z){if(!(z instanceof Ft))throw z;let W=d[z.line],j=1/0,q=-1/0;for(let Te of W?.columns??[])for(let fe of Te)j=Math.min(j,fe.ast.sourceSpan.start),q=Math.max(q,fe.ast.sourceSpan.end);throw Number.isFinite(j)?M.error.PageOverflow(z.requiredHeight,z.availableHeight,{start:j,end:q}):z}let J=(z,W)=>(ne[z]??0)+(K[z]?.get(W)??0);for(let z of y)z.box.y=J(z.layoutLine,z.track)-z.box.visualAxis,z.onPlaced?.();return Da(e,L,{width:r,originX:s,pages:C.map(z=>z.bounds)},J)},v={nodes:p,layoutOnly:p.length>0||n.some(wn)},{items:N}=Va(L,A,g,f,v),F=0,B=n.map(E=>{let{geometry:G}=f(E)??N[F++];return{kind:E.kind,regions:G.regions,layer:E.layer,sourceSpan:E.sourceSpan,paint(K){G.paint(K)}}}),$={x:0,y:0,w:0,h:0};function*U(){for(let E of C)yield E.bounds;for(let E of y)yield ee(E);for(let E of B)yield*E.regions}return dt($,U()),{diagnostics:a.diagnostics,objects:y,attachments:B,bounds:$,lineCount:d.length,pages:C}}function Wi(a){if(a.decorations.length===0)return;let e=0,t=-1/0,n=0,o=-1/0;for(let s of["above","below"]){let i=s==="above",c=a.decorations.length===1?a.decorations:a.decorations.filter(m=>m[s]);c.length>1&&c.sort((m,f)=>m[s].order-f[s].order);let l=i?0:a.ports["decoration.below"]?.y??a.box.h,p=i?-1/0:a.box.h,u=p;for(let m of c){let f=m[s];if(!f)continue;let d=Math.max(0,f.height??0);!i&&!m.paint&&(l=Math.max(l,u));let h=i?l-(f.gap??0)-d:l+(f.gap??0);f.place?.(h),l=i?h:h+d,n=Math.min(n,h),p=i?Math.max(p,h+d):l,m.paint&&(e=Math.min(e,h),u=i?Math.max(u,h+d):l)}o=Math.max(o,p),t=Math.max(t,u)}a.box.h=t;let r=Math.max(0,o-t);(n!==0||r!==0)&&Ln.set(a,{top:n,bottom:r,contentTop:e})}function $i(a){let e=()=>({columns:[],hostExtents:new Map,attachmentExtents:new Map}),t=[],n=[],o=e();for(let r of a.columns){let s=[];for(;t.length<r.layoutLine;)t.push(o),o=e();for(let i of r){let c=i.addon?.pageBreakBefore;c!==void 0&&(n[t.length]=(n[t.length]??!0)&&c);let l=i.addon?.breakBefore,p=o.breakBefore;l&&(o.breakBefore=p?{gap:Math.max(p.gap,l.gap),minGap:Math.max(p.minGap,l.minGap)}:l),_(i)&&s.push(i)}s.length&&o.columns.push(s)}return(o.columns.length>0||n[t.length]!==void 0||t.length===0)&&t.push(o),{lines:t,pageBreaks:n}}function Ot(a,e,t){a.top=Math.min(a.top,e),a.bottom=Math.max(a.bottom,t)}function ho(a,e,t,n){let o=a.get(e);o?Ot(o,t,n):a.set(e,{top:t,bottom:n})}function xo(a,e,t={},n=!1){let o=[],r=new Map,s=new Map,i;for(let l=0;l<a.length;l++)for(let p of a[l]){r.set(p,l),xn(p.springConfig,t.globalC);let u=s.get(p.track);u?u.push(p):s.set(p.track,[p])}let c={index:e,columns:a,trackRuns:s,columnOf:l=>r.get(l)??-1,trackIndexOf(l){if(!i){i=new Map;for(let p of s.values())for(let u=0;u<p.length;u++)i.set(p[u],u)}return i.get(l)??-1},registerHorizontalLayoutHook(l,p,u){let m=r.get(l),f=r.get(p);m===void 0||f===void 0||o.push({start:Math.min(m,f),end:Math.max(m,f),hook:u})}};for(let l of a)for(let p of l)p.prepareHorizontal?.(c);return{view:c,layout(l,p){let u=a.map(f=>f.map(d=>{let h=gn(d.springConfig,d.box,d,t.globalC);return n&&(h.margin_L=h.margin_R=0),h})),m=mo(u,l,t,o,p);return Object.assign(u,{extra:m.extra,groupOf:m.groupOf})}}}function Ui(a,e,t,n){let o=a.map(({columns:u},m)=>{let{extra:f,groupOf:d}=e[m];if(f<0||!u.length)return;let h=[],y=!1;for(let A=0;A<u.length;A++)u[A].some(v=>v.mergeKey===Q)?y&&(h.push(A),y=!1):u[A].some(v=>!v.T.isZero())&&(y=!0);if(y||h.pop(),!h.length)return;let g=A=>d?d[A]:A,x=g(u.length-1),b=[...h.map(g),x],S=0,T=0,L=b.map(A=>(A-=T,T+=A,A)),C=b.map((A,v)=>{let N=v<h.length?u[h[v]][0].box.x+u[h[v]][0].box.anchor:t,F=N-S;return S=N,x>0?F-f*(L[v]/x):F});return{columns:u,extra:f,groupAt:g,totalGaps:x,ends:b,gaps:L,minW:C}}),r=(u,m)=>u%m===0||m%u===0,s=(u,m)=>m?s(m,u%m):u,i=(u,m)=>{let f=o.slice(u,m+1),d=f.reduce((b,S)=>b/s(b,S.minW.length)*S.minW.length,1),h=new Array(d).fill(0);for(let b of[...f].sort((S,T)=>T.minW.length-S.minW.length)){let S=d/b.minW.length;for(let T=0;T<b.minW.length;T++){let L=b.minW[T],C=0;for(let A=0;A<S;A++)C+=h[T*S+A];if(L>C)for(let A=0;A<S;A++)h[T*S+A]+=(L-C)/S}}let y=h.map((b,S)=>Number(f.every(T=>T.gaps[Math.floor(S*T.minW.length/d)]>0))),g=y.slice(),x=t;for(let b=0;b<d;b++)g[b]||(x-=h[b]);for(let b=0;b<d;b++){let S=g.reduce((L,C)=>L+C,0);if(!S||x<=0)break;let T=x/S;if(!h.some((L,C)=>g[C]&&L>T&&(x-=L,g[C]=0,!0))){for(let L=0;L<d;L++)g[L]&&(h[L]=T);break}}return{L:d,grid:h,open:y}},c=new Map,l=(u,m,f)=>{let d=m*o.length+f,h=c.get(d);h||c.set(d,h=i(m,f));let{L:y,grid:g,open:x}=h,b=y/u.minW.length,S=u.minW.map((T,L)=>{if(!u.gaps[L])return T;let C=0;for(let A=0;A<b;A++)C+=g[L*b+A];return C});return{r:b,open:x,target:S}},p;for(let u=0;u<o.length;u++){let m=o[u];if(!m||m.extra<=0||!m.totalGaps)continue;let f=m.minW.length,d=p?.l===u-1&&p.s.minW.length===f&&p.end>=u?p:void 0,h=d?.start??u,y=d?.end??u,g=f;if(!d){let C=A=>!!A&&r(A.minW.length,f)&&r(A.minW.length,g);for(;o[h].extra>0&&n[h]===void 0&&C(o[h-1]);)g=Math.max(g,o[--h].minW.length);for(;o[y].extra>0&&n[y+1]===void 0&&C(o[y+1]);)g=Math.max(g,o[++y].minW.length)}if(p={l:u,s:m,start:h,end:y},h===y)continue;let{r:x,open:b,target:S}=l(m,h,y);if(S.reduce((C,A)=>C+A,0)>t+1e-6){let C=N=>N?.minW.length===f&&N.minW.every((F,B)=>Math.abs(F-m.minW[B])<=1e-6&&!N.gaps[B]==!m.gaps[B]),[A,v]=d?.win&&d.win[1]>=u&&d.s.minW.every((N,F)=>N===m.minW[F]&&d.s.gaps[F]===m.gaps[F])?d.win:[u,u];for(;A>h&&C(o[A-1]);)A--;for(;v<y&&C(o[v+1]);)v++;p.win=[A,v],{r:x,open:b,target:S}=l(m,Math.max(h,A-1),Math.min(y,v+1))}let T=m.gaps.map((C,A)=>C>0?b[A*x]:0);if(!T.some(Boolean))for(let C=0;C<f;C++)T[C]=+(m.gaps[C]>0);for(let C=0;C<f;C++){let A=t,v=0,N=0;for(let B=0;B<f;B++)T[B]?(v+=S[B],N++):A-=S[B];if(!N||Math.abs(A-v)<=1e-6)break;let F=(A-v)/N;if(!S.some((B,$)=>T[$]&&B+F<m.minW[$]&&(S[$]=m.minW[$],T[$]=0,!0))){for(let B=0;B<f;B++)T[B]&&(S[B]+=F);break}}let L=new Float64Array(m.totalGaps+1);for(let C=0,A=0;C<f;C++){let v=m.gaps[C]>0?(S[C]-m.minW[C])/m.gaps[C]-m.extra/m.totalGaps:0;for(;A<m.ends[C];A++)L[A+1]=L[A]+v}for(let C=0;C<m.columns.length;C++){let A=L[m.groupAt(C)];if(A)for(let v of m.columns[C])v.box.x+=A}}}function yt(a,e){return a.length===0?0:Ia(a.map(t=>[t]),e).width}function Ia(a,e){for(let r of a)for(let s of r)It(s,e);let t=xo(a,a[0][0].layoutLine,e.solverOptions,!0),n=1/0,o=-1/0;for(let r of t.layout(1/0))for(let s of r){let i=s.box.x+s.box.anchor;n=Math.min(n,i-s.WL),o=Math.max(o,i+s.WR)}for(let r of a)for(let s of r)s.box.x-=n;return{width:o-n,view:t.view}}function Yi(a,{width:e,view:t},n,o,r,s,i){let c=a.flat(),l={hostExtents:new Map,attachmentExtents:new Map},p=0;for(let T of c)za(l.hostExtents,T),p=Math.max(p,T.ast.size*Oa);let u=[],m=[];u[t.index]=l,m[t.index]=t;let f={lines:u,views:m,lift:Sn(n)},d=c.map(T=>({x:T.box.x,y:0})),h,y=Da(r,f,{width:e,originX:0,pages:[]},(T,L)=>h.axes.get(L)??0),{items:g,layoutItems:x}=Va(f,()=>(h=ja(l,n,p),c.forEach((T,L)=>{T.box.y=d[L].y=h.axes.get(T.track)-T.box.visualAxis,T.onPlaced?.()}),y),o,s,i,!0),b=c[0],S={x:b.box.x,y:b.box.y};return{height:h.height,positions:d,items:g.map(({geometry:T},L)=>{let C={geometry:T,position:S},A=x?{geometry:x[L].geometry,position:d[0]}:C;return{reference:b,paint:C,layout:A}})}}function Da(a,{lines:e,views:t,lift:n},o,r){return{...a,...o,lines:t,getVisualAxis:(s,i)=>r(s,n(i)),getHostExtent:(s,i)=>e[s]?.hostExtents.get(n(i)),getRangeColumns:(s,i,c)=>yo(t[s],i,c,n)}}function Va(a,e,t,n,{nodes:o,layoutOnly:r},s=!1){let i=(m,f)=>ec(t,m,a.lift,n,f),c=e(),l=i(c,r),p=Ki(a.lines,l.occupancy);p&&(c=e());let u=s&&r?(p?i(c,!0):l).items:void 0;return Qi(o),(p||r)&&(l=i(c,!1)),{items:l.items,layoutItems:u}}function Ki(a,e){let t=!1;return e.forEach((n,o)=>{let{hostExtents:r,attachmentExtents:s}=a[o];for(let{track:i,top:c,bottom:l}of n){let p=r.get(i);(!p||c<p.top||l>p.bottom)&&(t=!0),ho(s,i,c,l)}}),t}function Xi(a){let e=new Map;for(let t of a)for(let n=t.endPoints?.[0]?.foldedInto;n;n=n.foldedInto){let o=e.get(n);o?o.push(t):e.set(n,[t])}return e}function Zi({reference:a,paint:e,layout:t},n=!1){let{geometry:o,position:r}=n?t:e,s=a.box.x-r.x,i=a.box.y-r.y;return{geometry:s===0&&i===0?o:Ha(o,s,i)}}function Ha(a,e,t){let n=o=>({...o,x:o.x+e,y:o.y+t});return{regions:a.regions.map(n),occupancy:a.occupancy?.map(n),paint:o=>a.paint(new Bt(o,e,t))}}function wn(a){return!!(a.placementOffset?.x||a.placementOffset?.y)}function qi(a){let e=new Map;for(let t of a.astToTemporal.values())for(let n of t){if(!_(n)||!wn(n))continue;let o=0;for(let r=n.foldedInto;r;r=r.foldedInto)o++;e.set(n,o)}return[...e.keys()].sort((t,n)=>e.get(t)-e.get(n))}function Qi(a){for(let e of a)e.box.x+=e.placementOffset.x,e.box.y+=e.placementOffset.y,e.onPlaced?.()}function Ji(a,e,t){if(t!==void 0)return new Array(a).fill(t);let n=new Array(a).fill(0),o=0;for(let r of e){let s=r.ast.size*Oa;s>n[r.layoutLine]&&(n[r.layoutLine]=s),s>o&&(o=s)}for(let r=0;r<a;r++)n[r]||=o;return n}function ec(a,e,t,n,o){let r=new Map,s=[];function i(u){let m=r.get(u);return m||(m=n(u,o),m&&r.set(u,m)),m}function c(u,m,f){let d=e.lines[u],h=f===void 0?new Map:void 0,y,g=m&&"left"in m?m:void 0;if(!d||g&&g.left>=g.right)return h;let x=(v,N,F)=>{h?ho(h,v,N,F):y?Ot(y,N,F):y={top:N,bottom:F}},b=m&&!("left"in m)?m:void 0,{start:S,end:T}=Tn(d,b),L=f&&t(f),C=g?.left??(b?1/0:e.originX),A=g?.right??(b?-1/0:e.originX+e.width);for(let v=S;v<=T;v++)for(let N of d.columns[v]){if(L&&N.track!==L||g&&(N.box.x+N.box.w<=C||N.box.x>=A))continue;b&&(N.box.x<C&&(C=N.box.x),N.box.x+N.box.w>A&&(A=N.box.x+N.box.w));let{top:F,height:B}=Ga(N),$=N.box.y+F-e.getVisualAxis(u,N.track);x(N.track,$,$+B)}for(let v of s[u]??[])L&&v.track!==L||v.right<=C||v.left>=A||x(v.track,v.top,v.bottom);return h??y}let l={...e,getRangeExtents:c,getHorizontalExtents:(u,m,f)=>c(u,{left:m,right:f}),getAttachmentOccupancy(u){let m=i(u)?.geometry;return m&&(m.occupancy??m.regions)},getAttachmentBox(u){let m=i(u);if(!m)throw new Error("Layout attachment dependency has not been measured");return m.box||(m.box={x:0,y:0,w:0,h:0},dt(m.box,m.geometry.regions)),m.box},getContentBounds(u){let m=[];for(let d of u.nodes)_(d)&&(d.box.w>0||d.box.h>0)&&m.push(ee(d,!0));for(let d of u.attachments){if(!Ne(d))continue;let h=i(d);if(!(!h&&!a.includes(d))){if(!h)throw new Error("Layout attachment dependency has not been measured");for(let y of h.geometry.regions)(y.w>0||y.h>0)&&m.push(y)}}let f={x:0,y:0,w:0,h:0};return dt(f,m)?f:void 0}};return{items:a.map(u=>{let m=u.createGeometry(l);!o&&wn(u)&&(m=Ha(m,u.placementOffset.x,u.placementOffset.y));let f={geometry:m};r.set(u,f);for(let d of m.occupancy??m.regions){if(d.line===void 0)continue;let h=t(d.track),y=d.y-e.getVisualAxis(d.line,h);(s[d.line]??=[]).push({track:h,left:d.x,right:d.x+d.w,top:y,bottom:y+d.h})}return f}),occupancy:s}}function Ga(a){let e=Ln.get(a),t=e?.top??0;return{top:t,height:a.box.h-t+(e?.bottom??0)}}function za(a,e){let{top:t,height:n}=Ga(e),o=t-e.box.visualAxis;ho(a,e.track,o,o+n)}function ja(a,e,t){let n=new Map,o=c=>{let l=a.hostExtents.get(c),p=a.attachmentExtents.get(c),u=l?{top:l.top,bottom:l.bottom}:null;p&&(u?Ot(u,p.top,p.bottom):u={top:p.top,bottom:p.bottom});let m=[];for(let d of c.groups){let h=d.members.map(o);if(h.every(x=>x===null))continue;let y=d.measure(h,t),g=null;for(let x of y){if(!x)continue;let b=x.offset+x.extent.top,S=x.offset+x.extent.bottom;g?Ot(g,b,S):g={top:b,bottom:S}}g&&m.push({group:d,placements:y,extent:g})}let f=(d,h)=>{u??={top:0,bottom:0};for(let y=0;y<d.group.members.length;y++){let g=d.placements[y];g&&n.set(d.group.members[y],h+g.offset)}Ot(u,h+d.extent.top,h+d.extent.bottom)};for(let d of m)d.group.place||f(d,0);for(let d of m){let h=d.group.place;if(!h)continue;f(d,h(u??{top:0,bottom:0},d.extent,t))}return u},r=o(e),s=new Map;if(!r)return{axes:s,height:0};let i=(c,l)=>{s.set(c,l);for(let p of c.groups)for(let u of p.members){let m=n.get(u);m!==void 0&&i(u,l+m)}};return i(e,-r.top),{axes:s,height:r.bottom-r.top}}function Je(a){return a.pages.length>0?a.pages.map(e=>e.bounds):[a.bounds]}function Fe(a,e){let t=e.kind;t&&a.beginGroup?.({kind:t}),e.paint(a);for(let n of e.decorations)n.paint?.(a);t&&a.endGroup?.()}function Wa(a,e,t){for(let n of e){if(n.layer!==t)continue;let o=n.kind;o&&a.beginGroup?.({kind:o}),n.paint(a),o&&a.endGroup?.()}}function bo(a,e){Wa(e,a.attachments,"background");for(let t of a.objects)Fe(e,t);Wa(e,a.attachments,"foreground")}var go=class{constructor(e,t){this.pages=e;this.painters=t}pages;painters;groups=[];opened=new Map;beginGroup(e){this.groups.push(e)}endGroup(){let e=this.groups.length;this.groups.pop();for(let[t,n]of this.opened)n<e||(this.painters[t].endGroup?.(),e>1?this.opened.set(t,e-1):this.opened.delete(t))}route(e,t,n){let o=0,r=this.pages.length;for(;o<r;){let i=o+r>>>1,c=this.pages[i];c.y+c.h<e?o=i+1:r=i}let s=this.groups.length;for(let i=o;i<this.pages.length&&this.pages[i].y<=t;i++){let c=this.painters[i],l=this.opened.get(i)??0;if(l<s){for(let p=l;p<s;p++)c.beginGroup?.(this.groups[p]);this.opened.set(i,s)}n(c)}}drawText(e,t,n,o){this.route(n,n,r=>r.drawText(e,t,n,o))}drawLine(e,t,n,o,r){let s=(r?.strokeWidth??1)/2;this.route(Math.min(t,o)-s,Math.max(t,o)+s,i=>i.drawLine(e,t,n,o,r))}drawRect(e,t,n,o,r){let s=r?.stroke?(r.strokeWidth??1)/2:0;this.route(t-s,t+Math.max(0,o)+s,i=>{i.drawRect(e,t,n,o,r)})}drawCircle(e,t,n,o){let r=o?.stroke?(o.strokeWidth??1)/2:0,s=Math.max(0,n)+r;this.route(t-s,t+s,i=>i.drawCircle(e,t,n,o))}drawPath(e,t,n){if(e.length===0)return;let o=1/0,r=-1/0,s=c=>{o=Math.min(o,c),r=Math.max(r,c)};for(let c of e)c.op!=="Z"&&(c.op==="Q"&&s(c.cy),c.op==="C"&&(s(c.cy1),s(c.cy2)),s(c.y));if(n){let c=n.y+o*n.scaleY,l=n.y+r*n.scaleY;o=Math.min(c,l),r=Math.max(c,l)}if(!Number.isFinite(o))return;let i=t?.stroke?(t.strokeWidth??1)/2:0;this.route(o-i,r+i,c=>{c.drawPath(e,t,n)})}};function ft(a,e){let t=Je(a);if(e.length!==t.length)throw new Error(`Expected ${t.length} page painters, got ${e.length}`);bo(a,new go(t,e))}var tc=[{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}],nc=[{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 $a(a,e,t,n){for(let o of e)o.op==="C"?a.push({op:"C",cx1:t(o.cx1),cy1:n(o.cy1),cx2:t(o.cx2),cy2:n(o.cy2),x:t(o.x),y:n(o.y)}):a.push({op:o.op,x:t(o.x),y:n(o.y)})}function Ua(a,e,t){let n=t!=="",o=Math.max(1,Math.round(a/(e*.3))-(n?1:0)),r=n?113.5313:54.2813,s=n?85.7344+72.8125*o:87.37505+72.8125*(o-1),i=a/s,c=t!=="down",l=(m,f)=>c?d=>(m-f-d)*i:d=>(f+d)*i,p=[],u=l(r,n?27.4688:0);for(let m=0;m<o;m++)$a(p,tc,u,l(s,m*72.8125));return n&&$a(p,nc,l(r,0),l(s,o*72.8125+-7.9375)),{commands:p,width:r*i}}function Ya(a){let e=a,t=e?.ast;return(t?.callName==="up"||t?.callName==="down")&&Array.isArray(e?.members)&&Array.isArray(t.contents)?e:null}function Ka(a){let e=a.box.anchor;for(let t of a.members){let n=Ya(t);e=Math.max(e,n?Ka(n):t.box.anchor)}return e}var So=class extends P{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\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]}timeFlowModel(){return null}constructor(e,t,n,o=null){super(e,o);let[r,s]=this.getArgValue(t,n),i="";s!==""&&s!=="up"&&s!=="down"?n.diagnostics.push(new I("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",e)):i=s,this.content=r,this.direction=i,this.size=n.variables.fontsize,r.parent=this}loweringEnter(e,t){let n=e.isolateFromLoweringGroups(()=>e.trackedEvents(this.content,new V,t).flat()),o=n.length===1?ds(n[0]):null;if(!o||o.members.length<2)throw new w("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 To(this,o)]}toString(e){let t=this.direction?`, direction=${this.direction}`:"";return`@arp(${this.content.toString(e)}${t})`}},wo=So,To=class extends W{host;slots;hostX=0;markCommands=[];constructor(e,t){super(),this.ast=e,this.host=t;let n=t.ast.contents.length,o=[...t.members.slice(n).reverse(),...t.members.slice(0,n)],r=e.direction==="down"?o.reverse():o;this.slots=new Map(r.map((s,i)=>[s,i])),this.T.copyFrom(t.T),this.mergeKey=t.mergeKey,this.initLayoutBox(),t.addon&&(this.addon={...t.addon}),t.addon=void 0,t.foldedInto=this}onTimeState(e){this.host.t.copyFrom(this.t),this.host.T.copyFrom(this.T),this.host.track=this.track,this.host.layoutLine=this.layoutLine;let t=this.host.onTimeState?.(e);return this.T.copyFrom(this.host.T),t}prepareHorizontal(e){this.host.prepareHorizontal?.(e)}prepareLayout(e){let{host:t}=this;qe(this,t),Bt(t,e),this.springConfig={...t.springConfig};let n=this.ast.size,o=te(t,!0),r=te(t),{commands:s,width:i}=bo(o.h,n,this.ast.direction);this.markCommands=s,this.hostX=i+n*.16+ys(t)-t.box.anchor,this.box.w=this.hostX+t.box.w,this.box.h=r.h,this.box.anchor=this.hostX+t.box.anchor,this.box.visualAxis=t.box.visualAxis-r.y;for(let c in t.ports){let l=t.ports[c];this.ports[c]={...l,x:this.hostX+l.x,y:l.y-r.y}}}onPlaced(){this.host.box.x=this.box.x+this.hostX,this.host.box.y=this.box.y-(te(this.host).y-this.host.box.y),this.host.onPlaced?.()}emitPlayback(e){e.play(this.host);let t=e.end.clone().sub(e.start);if(t.compare(0)<=0)return;let n=new V(1,8),o=t.clone().div(2).div(this.slots.size-1);n.compare(o)>0&&n.copyFrom(o);let{slots:r}=this,s=this;e.defer(i=>{let c;for(let l=i.spans.length-1;l>=0;l--){let p=i.spans[l],u=p.origins.find(f=>f.node===s);if(!u||c&&u!==c)break;c=u;let m=p.origins.find(f=>r.has(f.node))?.node,y=m?r.get(m):void 0;if(!y)continue;let d=n.clone().mul(y).add(e.start),g=e.end.clone().sub(d).div(t);p.start.sub(e.start).mul(g).add(d),p.end.sub(e.start).mul(g).add(d)}})}paint(e){e.drawPath(this.markCommands,{fill:"#000"},{x:this.box.x,y:te(this.host,!0).y,scaleX:1,scaleY:1}),Me(e,this.host)}};function No(a,e,t){a.deferFinalize(n=>{let o=[],r=new V,s=1,i=!1,c=-1;for(let l of n.columns){let p=l[0].t;if(l.some(u=>u.mergeKey===Q))p.compare(r)>0&&(s++,r.copyFrom(p),i=!1);else if(l.some(u=>!u.T.isZero()&&M(u))){let u=l[0].layoutLine;u!==c&&(c>=0&&!i&&o.push({line:u,number:s}),c=u),i=!0}}o.length>0&&n.attachments.push(new Co(o,e,t))})}var Lo=class extends E{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]}timeFlowModel(){return null}constructor(e,t,n,o=null){super(e,o);let[r,s]=this.getArgValue(t,n),i="";s!==""&&s!=="up"&&s!=="down"?n.diagnostics.push(new O("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",e)):i=s,this.content=r,this.direction=i,this.size=n.variables.fontsize,r.parent=this}loweringEnter(e,t){let n=e.isolateFromLoweringGroups(()=>e.trackedEvents(this.content,new I,t).flat()),o=n.length===1?Ya(n[0]):null;if(!o||o.members.length<2)throw new w("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 To(this,o)]}toString(e){let t=this.direction?`, direction=${this.direction}`:"";return`@arp(${this.content.toString(e)}${t})`}},wo=So,To=class extends H{host;slots;hostX=0;markCommands=[];constructor(e,t){super(),this.ast=e,this.host=t;let n=t.ast.contents.length,o=[...t.members.slice(n).reverse(),...t.members.slice(0,n)],r=e.direction==="down"?o.reverse():o;this.slots=new Map(r.map((s,i)=>[s,i])),this.T.copyFrom(t.T),this.mergeKey=t.mergeKey,this.initLayoutBox(),t.addon&&(this.addon={...t.addon}),t.addon=void 0,t.foldedInto=this}onTimeState(e){this.host.t.copyFrom(this.t),this.host.T.copyFrom(this.T),this.host.track=this.track,this.host.layoutLine=this.layoutLine;let t=this.host.onTimeState?.(e);return this.T.copyFrom(this.host.T),t}prepareHorizontal(e){this.host.prepareHorizontal?.(e)}prepareLayout(e){let{host:t}=this;Qe(this,t),It(t,e),this.springConfig={...t.springConfig};let n=this.ast.size,o=ee(t,!0),r=ee(t),{commands:s,width:i}=Ua(o.h,n,this.ast.direction);this.markCommands=s,this.hostX=i+n*.16+Ka(t)-t.box.anchor,this.box.w=this.hostX+t.box.w,this.box.h=r.h,this.box.anchor=this.hostX+t.box.anchor,this.box.visualAxis=t.box.visualAxis-r.y;for(let c in t.ports){let l=t.ports[c];this.ports[c]={...l,x:this.hostX+l.x,y:l.y-r.y}}}onPlaced(){this.host.box.x=this.box.x+this.hostX,this.host.box.y=this.box.y-(ee(this.host).y-this.host.box.y),this.host.onPlaced?.()}emitPlayback(e){e.play(this.host);let t=e.end.clone().sub(e.start);if(t.compare(0)<=0)return;let n=new I(1,8),o=t.clone().div(2).div(this.slots.size-1);n.compare(o)>0&&n.copyFrom(o);let{slots:r}=this,s=this;e.defer(i=>{let c;for(let l=i.spans.length-1;l>=0;l--){let p=i.spans[l],u=p.origins.find(y=>y.node===s);if(!u||c&&u!==c)break;c=u;let m=p.origins.find(y=>r.has(y.node))?.node,f=m?r.get(m):void 0;if(!f)continue;let d=n.clone().mul(f).add(e.start),h=e.end.clone().sub(d).div(t);p.start.sub(e.start).mul(h).add(d),p.end.sub(e.start).mul(h).add(d)}})}paint(e){e.drawPath(this.markCommands,{fill:"#000"},{x:this.box.x,y:ee(this.host,!0).y,scaleX:1,scaleY:1}),Fe(e,this.host)}};function Xa(a,e,t){a.deferFinalize(n=>{let o=[],r=new I,s=1,i=!1,c=-1;for(let l of n.columns)if(l.mergeKey===Q)l.t.compare(r)>0&&(s++,r.copyFrom(l.t),i=!1);else if(l.some(p=>!p.T.isZero()&&_(p))){let p=l.layoutLine;p!==c&&(c>=0&&!i&&o.push({line:p,number:s}),c=p),i=!0}o.length>0&&n.attachments.push(new Co(o,e,t))})}var Lo=class extends P{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\u53CC\u7AD6\u7EBF `||`\uFF1B2\uFF1A\u7EC8\u6B62\u7EBF `|||`\uFF08\u5DE6\u7EC6\u53F3\u7C97\uFF09\uFF1B3\uFF1A\u53CD\u590D\u8D77\u70B9 `|:`\uFF1B4\uFF1A\u53CD\u590D\u7EC8\u70B9 `:|`\uFF1B5\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(e,t,n){let o=t,r=0,s=e.slice(o,o+3),i=e.slice(o,o+2);if(s==="|||")r=2,o+=3;else if(i==="||")r=1,o+=2;else if(i==="|:")r=3,o+=2;else if(i===":|")e[o+2]===":"?(r=5,o+=3):(r=4,o+=2);else if(e[o]==="|")r=0,o+=1;else return null;let c=new Map;return c.set("type",r),{next:o,node:{kind:"call",typed:!0,name:"bar",args:c,span:{start:t,end:o},syntaxKind:"atom"}}}type;size;constructor(e,t,n,o=null){super(e,o);let[r,s]=this.getArgValue(t,n);this.type=r,this.size=n.length2px(s)}loweringEnter(){return[this.type>=3&&this.type<=5?new Ao(this):new gn(this)]}toString(){return`@bar(${this.type}, ${this.size}px)`}},Co=class{constructor(e,t,n){this.items=e;this.pattern=t;this.font=n}items;pattern;font;kind="bar-number";layer="foreground";sourceSpan=void 0;createGeometry(e){let t=this.items.map(({line:n,number:o})=>{let s=e.lines[n].columns[0].reduce((g,f)=>e.getVisualAxis(n,f.track)<e.getVisualAxis(n,g.track)?f:g),i=s.ast.size,c=s.ports["bar.number"],l={fontSize:i*.5,fontFamily:this.font,textAlign:c?"center":"right",fill:"#000"},p=this.pattern.replace("1",String(o)),u=e.textMeasurer.measureText(p,l),m=c?s.box.x+c.x:e.originX-i*.15,d=(c?s.box.y+c.y:Math.min(s.box.y,e.getVisualAxis(n,s.track)-i*.5))-i*.04;return{text:p,x:m,y:d,style:l,region:{x:c?m-u.w/2:m-u.w,y:d-u.baseline,w:u.w,h:u.baseline,line:n,track:s.track}}});return{regions:t.map(n=>n.region),paint(n){for(let o of t)n.drawText(o.text,o.x,o.y,o.style)}}}},ko=Lo,gn=class extends W{lines=[];repeatDots=[];constructor(e){super(),this.ast=e,this.mergeKey=Q,this.initLayoutBox()}prepareHorizontal(e){let t=this.rootHost;if(!M(t))return;let n=e.trackRuns.get(t.track),o=e.trackIndexOf(t);if(!n||o<0)return;let r=n[o-1];r&&(r.springConfig.mu_R*=4,t.springConfig.mu_L*=4);let s=n[o+1];s&&s.mergeKey!==Q&&(t.springConfig.mu_R*=4,s.springConfig.mu_L*=4)}prepareLayout(){this.springConfig={alpha_L:128,alpha_R:128};let{type:e,size:t}=this.ast;this.lines.length=0;let n=[],o=t,r=Math.max(1,t*.065),s=r*2.6,i=r*1.8,c=r*.8,l=i+c,p=e===4||e===5,u=e===3||e===5,m=p?c*2+l:0;if(e===1?(this.lines.push({x:m,w:r}),m+=r+i,this.lines.push({x:m,w:r}),m+=r):e===2||e===4||e===5?(this.lines.push({x:m,w:r}),m+=r+i,this.lines.push({x:m,w:s}),m+=s):e===3?(this.lines.push({x:m,w:s}),m+=s+i,this.lines.push({x:m,w:r}),m+=r):(this.lines.push({x:m,w:r}),m+=r),p){let d=c;n.push({x:d,y:o*.38}),n.push({x:d,y:o*.62})}if(u){let d=m+l;n.push({x:d,y:o*.38}),n.push({x:d,y:o*.62}),m=d+c}this.box.w=m,this.box.h=o;let y=e>=3&&e<=5?this.lines[0]:void 0;this.box.anchor=y?y.x+y.w/2:m/2,this.box.visualAxis=o/2;for(let d of this.lines)d.x-=this.box.anchor;this.repeatDots=n.map(d=>({x:d.x-this.box.anchor,y:d.y,r:c}))}paint(e){for(let t of this.lines)e.drawRect(this.box.x+this.box.anchor+t.x,this.box.y,t.w,this.box.h,{fill:"#000"});for(let t of this.repeatDots)e.drawCircle(this.box.x+this.box.anchor+t.x,this.box.y+t.y,t.r,{fill:"#000"})}},Ot="repeat.start",bn="repeat.end";function vo(a,e){let t=a.seek(Ot,e+1,-1)??0,n=a.seek(Ot,t,1)??1/0,o=1,r=0;for(let s=a.seek(bn,t,1);s!==void 0&&s<=n;s=a.seek(bn,s,1))r++,a.visits(s)>0&&o++;return r?o:a.visits(t)}var Ao=class extends gn{playbackMarks(){let{type:e}=this.ast;return e===3?[Ot]:e===4?[bn]:[Ot,bn]}playbackFlow(e){if(this.ast.type===3)return;let t=e(this);if(t!==void 0)return{range:[t,t],run:n=>n.visits(t)>1?void 0:{kind:"jump",column:n.seek(Ot,t,-1)??0}}}};var Sn=class{min=1/0;max=-1/0;add(e){e<this.min&&(this.min=e),e>this.max&&(this.max=e)}};function Po(a,e,t,n,o,r){if(!(a>1e-9&&a<1-1e-9))return;let s=1-a;r.add(s*s*s*e+3*s*s*a*t+3*s*a*a*n+a*a*a*o)}function fs(a,e,t,n,o){o.add(a),o.add(n);let r=-a+3*e-3*t+n,s=2*(a-2*e+t),i=e-a;if(Math.abs(r)<1e-12){Math.abs(s)>1e-12&&Po(-i/s,a,e,t,n,o);return}let c=s*s-4*r*i;if(c<0)return;let l=Math.sqrt(c);Po((-s+l)/(2*r),a,e,t,n,o),Po((-s-l)/(2*r),a,e,t,n,o)}function hs(a,e,t,n){n.add(a),n.add(t);let o=a-2*e+t;if(Math.abs(o)<1e-12)return;let r=(a-e)/o;if(!(r>0&&r<1))return;let s=1-r;n.add(s*s*a+2*s*r*e+r*r*t)}function he(a){let e=new Sn,t=new Sn,n=0,o=0,r=0,s=0;for(let i of a){if(i.op==="Z"){n=r,o=s;continue}i.op==="C"?(fs(n,i.cx1,i.cx2,i.x,e),fs(o,i.cy1,i.cy2,i.y,t)):i.op==="Q"?(hs(n,i.cx,i.x,e),hs(o,i.cy,i.y,t)):(e.add(i.x),t.add(i.y),i.op==="M"&&(r=i.x,s=i.y)),n=i.x,o=i.y}return Number.isFinite(e.min)?{x:e.min,y:t.min,w:e.max-e.min,h:t.max-t.min}:{x:0,y:0,w:0,h:0}}var xs=new WeakMap;function Ge(a){let e=1/0,t=1/0,n=-1/0,o=-1/0,r=(s,i,c,l)=>{e=Math.min(e,s),t=Math.min(t,i),n=Math.max(n,s+c),o=Math.max(o,i+l)};for(let s of a){let i=s.dx??0;if(s.line){let{x1:c,y1:l,x2:p,y2:u}=s.line,m=(s.style.strokeWidth??1)/2;r(Math.min(c,p)+i-m,Math.min(l,u)-m,Math.abs(p-c)+m*2,Math.abs(u-l)+m*2)}if(s.circle){let{cx:c,cy:l,r:p}=s.circle,u=s.style.stroke&&s.style.stroke!=="none"?(s.style.strokeWidth??1)/2:0,m=p+u;r(c+i-m,l-m,2*m,2*m)}if(s.path?.length){let c=xs.get(s.path)??he(s.path);xs.set(s.path,c),r(c.x+i,c.y,c.w,c.h)}}return Number.isFinite(e)?{x:e,y:t,w:Math.max(1e-9,n-e),h:Math.max(1e-9,o-t)}:{x:0,y:0,w:1e-9,h:1e-9}}function It(a,e,t,n,o){let r=n.x-t.x*o,s=n.y-t.y*o;for(let i of e){let c=i.style,l=c.strokeWidth??(i.line||i.circle?1:void 0),p=l===void 0?c:{...c,strokeWidth:l*o},u=r+(i.dx??0)*o;if(i.line){let{x1:m,y1:y,x2:d,y2:g}=i.line;a.drawLine(u+m*o,s+y*o,u+d*o,s+g*o,p)}i.path&&a.drawPath(i.path,p,{x:u,y:s,scaleX:o,scaleY:o}),i.circle&&a.drawCircle(u+i.circle.cx*o,s+i.circle.cy*o,i.circle.r*o,p)}}var Tn=[{path:[{op:"M",x:1,y:34},{op:"C",cx1:23,cy1:36,cx2:57,cy2:28,x:82,y:23},{op:"C",cx1:91,cy1:21,cx2:98,cy2:24,x:102,y:29},{op:"Q",cx:106,cy:34,x:98,y:34},{op:"C",cx1:68,cy1:30,cx2:37,cy2:39,x:13,y:43},{op:"Q",cx:7,cy:44,x:1,y:39},{op:"Q",cx:-3,cy:35,x:1,y:34},{op:"Z"}],style:{fill:"#000"}},{path:[{op:"M",x:29,y:5},{op:"Q",cx:27,cy:3,x:31,y:4},{op:"Q",cx:44,cy:7,x:42,y:12},{op:"C",cx1:39,cy1:26,cx2:43,cy2:43,x:42,y:60},{op:"Q",cx:41,cy:69,x:38,y:62},{op:"C",cx1:34,cy1:47,cx2:35,cy2:20,x:29,y:5},{op:"Z"}],style:{fill:"#000"}},{path:[{op:"M",x:59,y:1},{op:"Q",cx:56,cy:-2,x:61,y:0},{op:"Q",cx:76,cy:4,x:74,y:9},{op:"C",cx1:71,cy1:17,cx2:74,cy2:32,x:69,y:48},{op:"C",cx1:64,cy1:66,cx2:55,cy2:77,x:40,y:84},{op:"Q",cx:37,cy:85,x:40,y:82},{op:"C",cx1:57,cy1:66,cx2:63,cy2:47,x:64,y:29},{op:"C",cx1:65,cy1:17,cx2:63,cy2:7,x:59,y:1},{op:"Z"}],style:{fill:"#000"}}],ft=Ge(Tn);var wn=new WeakMap;function Ro(a){return wn.get(a)?.meter}function Hi(a,e){let t=a.rootHost,n=a.ast.sourceSpan,o=wn.get(t);o||wn.set(t,o={start:n.start,end:n.end,meter:e}),o.end=n.end,o.meter=e}var Eo=class a extends E{static def={name:["meter"],description:"\u8BBE\u7F6E\u62CD\u53F7",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\u53CC\u7AD6\u7EBF `||`\uFF1B2\uFF1A\u7EC8\u6B62\u7EBF `|||`\uFF08\u5DE6\u7EC6\u53F3\u7C97\uFF09\uFF1B3\uFF1A\u53CD\u590D\u8D77\u70B9 `|:`\uFF1B4\uFF1A\u53CD\u590D\u7EC8\u70B9 `:|`\uFF1B5\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(e,t,n){let o=t,r=0,s=e.slice(o,o+3),i=e.slice(o,o+2);if(s==="|||")r=2,o+=3;else if(i==="||")r=1,o+=2;else if(i==="|:")r=3,o+=2;else if(i===":|")e[o+2]===":"?(r=5,o+=3):(r=4,o+=2);else if(e[o]==="|")r=0,o+=1;else return null;let c=new Map;return c.set("type",r),{next:o,node:{kind:"call",typed:!0,name:"bar",args:c,span:{start:t,end:o},syntaxKind:"atom"}}}type;size;constructor(e,t,n,o=null){super(e,o);let[r,s]=this.getArgValue(t,n);this.type=r,this.size=n.length2px(s)}loweringEnter(){return[this.type>=3&&this.type<=5?new Ao(this):new Cn(this)]}toString(){return`@bar(${this.type}, ${this.size}px)`}},Co=class{constructor(e,t,n){this.items=e;this.pattern=t;this.font=n}items;pattern;font;kind="bar-number";layer="foreground";sourceSpan=void 0;createGeometry(e){let t=this.items.map(({line:n,number:o})=>{let s=e.lines[n].columns[0].reduce((y,g)=>e.getVisualAxis(n,g.track)<e.getVisualAxis(n,y.track)?g:y),i=e.lines[n].trackRuns.get(s.track)?.find(y=>!y.T.isZero())??s,c=i.ast.size,l=s.ports["bar.number"],p={fontSize:c*.5,fontFamily:this.font,textAlign:l?"center":"right",fill:"#000"},u=this.pattern.replace("1",String(o)),m=e.textMeasurer.measureText(u,p),f=l?s.box.x+l.x:e.originX-c*.15,h=(l?s.box.y+l.y:Math.min(i.box.y,e.getVisualAxis(n,i.track)-c*.5))-c*.04;return{text:u,x:f,y:h,style:p,region:{x:l?f-m.w/2:f-m.w,y:h-m.baseline,w:m.w,h:m.baseline,line:n,track:s.track}}});return{regions:t.map(n=>n.region),paint(n){for(let o of t)n.drawText(o.text,o.x,o.y,o.style)}}}},kn=Lo,Cn=class extends H{lines=[];repeatDots=[];constructor(e){super(),this.ast=e,this.mergeKey=Q,this.initLayoutBox()}onTimeState(e){e.accidentals.clear(this.track)}prepareHorizontal(e){let t=this.rootHost;if(!_(t))return;let n=e.trackRuns.get(t.track),o=e.trackIndexOf(t);if(!n||o<0)return;let r=n[o-1];r&&(r.springConfig.mu_R*=4,t.springConfig.mu_L*=4);let s=n[o+1];s&&s.mergeKey!==Q&&(t.springConfig.mu_R*=4,s.springConfig.mu_L*=4)}prepareLayout(){this.springConfig={alpha_L:128,alpha_R:128};let{type:e,size:t}=this.ast;this.lines.length=0;let n=[],o=t,r=Math.max(1,t*.065),s=r*2.6,i=r*1.8,c=r*.8,l=i+c,p=e===4||e===5,u=e===3||e===5,m=p?c*2+l:0;if(e===1?(this.lines.push({x:m,w:r}),m+=r+i,this.lines.push({x:m,w:r}),m+=r):e===2||e===4||e===5?(this.lines.push({x:m,w:r}),m+=r+i,this.lines.push({x:m,w:s}),m+=s):e===3?(this.lines.push({x:m,w:s}),m+=s+i,this.lines.push({x:m,w:r}),m+=r):(this.lines.push({x:m,w:r}),m+=r),p){let d=c;n.push({x:d,y:o*.38}),n.push({x:d,y:o*.62})}if(u){let d=m+l;n.push({x:d,y:o*.38}),n.push({x:d,y:o*.62}),m=d+c}this.box.w=m,this.box.h=o;let f=e>=3&&e<=5?this.lines[0]:void 0;this.box.anchor=f?f.x+f.w/2:m/2,this.box.visualAxis=o/2;for(let d of this.lines)d.x-=this.box.anchor;this.repeatDots=n.map(d=>({x:d.x-this.box.anchor,y:d.y,r:c}))}paint(e){for(let t of this.lines)e.drawRect(this.box.x+this.box.anchor+t.x,this.box.y,t.w,this.box.h,{fill:"#000"});for(let t of this.repeatDots)e.drawCircle(this.box.x+this.box.anchor+t.x,this.box.y+t.y,t.r,{fill:"#000"})}},Dt="repeat.start",An="repeat.end";function Za(a,e){let t=a.seek(Dt,e+1,-1)??0,n=a.seek(Dt,t,1)??1/0,o=1,r=0;for(let s=a.seek(An,t,1);s!==void 0&&s<=n;s=a.seek(An,s,1))r++,a.visits(s)>0&&o++;return r?o:a.visits(t)}var Ao=class extends Cn{playbackMarks(){let{type:e}=this.ast;return e===3?[Dt]:e===4?[An]:[Dt,An]}playbackFlow(e){if(this.ast.type===3)return;let t=e(this);if(t!==void 0)return{range:[t,t],run:n=>n.visits(t)>1?void 0:{kind:"jump",column:n.seek(Dt,t,-1)??0}}}};var Nn=class{min=1/0;max=-1/0;add(e){e<this.min&&(this.min=e),e>this.max&&(this.max=e)}};function ko(a,e,t,n,o,r){if(!(a>1e-9&&a<1-1e-9))return;let s=1-a;r.add(s*s*s*e+3*s*s*a*t+3*s*a*a*n+a*a*a*o)}function qa(a,e,t,n,o){o.add(a),o.add(n);let r=-a+3*e-3*t+n,s=2*(a-2*e+t),i=e-a;if(Math.abs(r)<1e-12){Math.abs(s)>1e-12&&ko(-i/s,a,e,t,n,o);return}let c=s*s-4*r*i;if(c<0)return;let l=Math.sqrt(c);ko((-s+l)/(2*r),a,e,t,n,o),ko((-s-l)/(2*r),a,e,t,n,o)}function Qa(a,e,t,n){n.add(a),n.add(t);let o=a-2*e+t;if(Math.abs(o)<1e-12)return;let r=(a-e)/o;if(!(r>0&&r<1))return;let s=1-r;n.add(s*s*a+2*s*r*e+r*r*t)}function Se(a){let e=new Nn,t=new Nn,n=0,o=0,r=0,s=0;for(let i of a){if(i.op==="Z"){n=r,o=s;continue}i.op==="C"?(qa(n,i.cx1,i.cx2,i.x,e),qa(o,i.cy1,i.cy2,i.y,t)):i.op==="Q"?(Qa(n,i.cx,i.x,e),Qa(o,i.cy,i.y,t)):(e.add(i.x),t.add(i.y),i.op==="M"&&(r=i.x,s=i.y)),n=i.x,o=i.y}return Number.isFinite(e.min)?{x:e.min,y:t.min,w:e.max-e.min,h:t.max-t.min}:{x:0,y:0,w:0,h:0}}var Ja=new WeakMap;function et(a){let e=1/0,t=1/0,n=-1/0,o=-1/0,r=(s,i,c,l)=>{e=Math.min(e,s),t=Math.min(t,i),n=Math.max(n,s+c),o=Math.max(o,i+l)};for(let s of a){let i=s.dx??0;if(s.line){let{x1:c,y1:l,x2:p,y2:u}=s.line,m=(s.style.strokeWidth??1)/2;r(Math.min(c,p)+i-m,Math.min(l,u)-m,Math.abs(p-c)+m*2,Math.abs(u-l)+m*2)}if(s.circle){let{cx:c,cy:l,r:p}=s.circle,u=s.style.stroke&&s.style.stroke!=="none"?(s.style.strokeWidth??1)/2:0,m=p+u;r(c+i-m,l-m,2*m,2*m)}if(s.path?.length){let c=Ja.get(s.path)??Se(s.path);Ja.set(s.path,c),r(c.x+i,c.y,c.w,c.h)}}return Number.isFinite(e)?{x:e,y:t,w:Math.max(1e-9,n-e),h:Math.max(1e-9,o-t)}:{x:0,y:0,w:1e-9,h:1e-9}}function vn(a,e,t,n,o){let r=n.x-t.x*o,s=n.y-t.y*o;for(let i of e){let c=i.style,l=c.strokeWidth??(i.line||i.circle?1:void 0),p=l===void 0?c:{...c,strokeWidth:l*o},u=r+(i.dx??0)*o;if(i.line){let{x1:m,y1:f,x2:d,y2:h}=i.line;a.drawLine(u+m*o,s+f*o,u+d*o,s+h*o,p)}i.path&&a.drawPath(i.path,p,{x:u,y:s,scaleX:o,scaleY:o}),i.circle&&a.drawCircle(u+i.circle.cx*o,s+i.circle.cy*o,i.circle.r*o,p)}}var No=[{path:[{op:"M",x:1,y:34},{op:"C",cx1:23,cy1:36,cx2:57,cy2:28,x:82,y:23},{op:"C",cx1:91,cy1:21,cx2:98,cy2:24,x:102,y:29},{op:"Q",cx:106,cy:34,x:98,y:34},{op:"C",cx1:68,cy1:30,cx2:37,cy2:39,x:13,y:43},{op:"Q",cx:7,cy:44,x:1,y:39},{op:"Q",cx:-3,cy:35,x:1,y:34},{op:"Z"}],style:{fill:"#000"}},{path:[{op:"M",x:29,y:5},{op:"Q",cx:27,cy:3,x:31,y:4},{op:"Q",cx:44,cy:7,x:42,y:12},{op:"C",cx1:39,cy1:26,cx2:43,cy2:43,x:42,y:60},{op:"Q",cx:41,cy:69,x:38,y:62},{op:"C",cx1:34,cy1:47,cx2:35,cy2:20,x:29,y:5},{op:"Z"}],style:{fill:"#000"}},{path:[{op:"M",x:59,y:1},{op:"Q",cx:56,cy:-2,x:61,y:0},{op:"Q",cx:76,cy:4,x:74,y:9},{op:"C",cx1:71,cy1:17,cx2:74,cy2:32,x:69,y:48},{op:"C",cx1:64,cy1:66,cx2:55,cy2:77,x:40,y:84},{op:"Q",cx:37,cy:85,x:40,y:82},{op:"C",cx1:57,cy1:66,cx2:63,cy2:47,x:64,y:29},{op:"C",cx1:65,cy1:17,cx2:63,cy2:7,x:59,y:1},{op:"Z"}],style:{fill:"#000"}}],Vt=et(No);var Pn=new WeakMap;function es(a){return Pn.get(a)?.meter}function oc(a,e){let t=a.rootHost,n=a.ast.sourceSpan,o=Pn.get(t);o||Pn.set(t,o={start:n.start,end:n.end,meter:e}),o.end=n.end,o.meter=e}var vo=class a extends P{static def={name:["meter"],description:"\u8BBE\u7F6E\u62CD\u53F7",details:`~~~jpfun
13
13
  @meter(6, 8)
14
14
  ~~~
15
15
  \u8BBE\u7F6E \`6/8\` \u62CD\u53F7\uFF1A\u6BCF\u5C0F\u8282\u542B\u516D\u4E2A\u516B\u5206\u97F3\u7B26\u7684\u65F6\u503C\u3002
16
- \u5206\u5B50\u6216\u5206\u6BCD\u4E3A 0 \u65F6\u8868\u793A\u6563\u677F\u3002`,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;weight;constructor(e,t,n,o=null){super(e,o);let[r,s,i]=this.getArgValue(t,n);if(this.font=n.variables.numberfont,this.weight=n.variables.numberweight,!Number.isSafeInteger(r)||!Number.isSafeInteger(r*4)||r<0||!Number.isSafeInteger(s)||s<0){let c="@meter \u7684\u5206\u5B50\u548C\u5206\u6BCD\u5FC5\u987B\u662F\u975E\u8D1F\u6574\u6570";if(n.variables.strict)throw new w("E_METER_INVALID",c,e);n.diagnostics.push(new I("W_METER_INVALID",`${c}\uFF0C\u5DF2\u56DE\u843D\u4E3A 4/4`,e)),r=s=4}this.numerator=r,this.denominator=s,r!==0&&s!==0&&(this.measureDuration=new V(r*4,s)),this.size=n.length2px(i),this.strict=n.variables.strict}loweringEnter(e){return e.deferFinalize(a.loweringFinalize),[new _o(this)]}static loweringFinalize(e){let t=new V,n=new V,o=null,r=!1,s=0,i=(c,l)=>{if(!(!o?.measureDuration||c.equals(t))){if(n.copyFrom(c).sub(t),!n.equals(o.measureDuration)&&(r||n.compare(o.measureDuration)>0)){let p="\u5C0F\u8282\u65F6\u957F\u4E3A {duration} QN\uFF0C\u4E0D\u6EE1\u8DB3 {num}/{den} \u62CD\u53F7",u={start:s,end:l},m={duration:n,num:o.numerator,den:o.denominator};if(o.strict)throw new w("E_METER_MISMATCH",p,u,m);e.diagnostics.push(new I("W_METER_MISMATCH",p,u,m))}t.copyFrom(c)}};for(let c of e.columns){let l=c[0].t;for(let u of c){let m=wn.get(u);m&&(i(l,m.start),o=m.meter,t.copyFrom(l),s=m.end)}let p=c.find(u=>u.mergeKey===Q);p&&(i(l,p.ast.sourceSpan.end),s=p.ast.sourceSpan.end,r=!0)}if(o){let c=e.columns.at(-1)?.at(-1)?.ast.sourceSpan??o.sourceSpan;i(e.duration,c.end)}}toString(){return`@meter(${this.numerator}, ${this.denominator})`}},Dt=Eo,_o=class extends W{style;numeratorBaseline=0;denominatorBaseline=0;lineY=0;lineHeight=0;constructor(e){super(),this.ast=e,this.style={fontSize:e.size,fontFamily:e.font,fontWeight:e.weight,textAlign:"center",fill:"#000"},this.initLayoutBox()}onTimeState(e){e.meter=this.ast.measureDuration,Hi(this,this.ast)}emitPlayback(e){this.ast.measureDuration&&e.emit({kind:"time-signature",at:e.start,numerator:this.ast.numerator,denominator:this.ast.denominator})}prepareLayout(e){if(!this.ast.measureDuration){this.box.w=this.ast.size*ft.w/ft.h,this.box.h=this.ast.size,this.box.anchor=this.box.w/2,this.box.visualAxis=this.box.h/2;return}let t=e.textMeasurer.measureText(String(this.ast.numerator),this.style),n=e.textMeasurer.measureText(String(this.ast.denominator),this.style),o=this.ast.size*.08,r=this.ast.size*.08;this.lineHeight=Math.max(1,this.ast.size*.06),this.numeratorBaseline=t.baseline,this.lineY=t.h+o,this.denominatorBaseline=this.lineY+this.lineHeight+o+n.baseline,this.box.w=Math.max(t.w,n.w)+r*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(e){if(!this.ast.measureDuration){It(e,Tn,ft,this.box,this.ast.size/ft.h);return}let t=this.box.x+this.box.anchor;e.drawText(String(this.ast.numerator),t,this.box.y+this.numeratorBaseline,this.style),e.drawRect(this.box.x,this.box.y+this.lineY,this.box.w,this.lineHeight,{fill:"#000"}),e.drawText(String(this.ast.denominator),t,this.box.y+this.denominatorBaseline,this.style)}};function Gi(a){let e=new Map;for(let t of a.columns)for(let n of t){if(!M(n))continue;let o=Vt(n);if(!o)continue;let r=e.get(o);r?r.push(n):e.set(o,[n])}return e}function gs(a){let e=1/0,t=-1/0;for(let n of a){let o=Vt(n);e=Math.min(e,n.ast.sourceSpan.start,o.sourceSpan.start),t=Math.max(t,n.ast.sourceSpan.end,o.sourceSpan.end)}return et(a,!1,{start:e,end:t})}function zi(a,e){let t=[],n=new Map,o=r=>{r&&r.length>=2&&t.push(gs(r))};for(let r of a)if(!(r.length<2)){for(let s of r){if(e.has(s)){o(n.get(s.track)),n.delete(s.track);continue}let i=n.get(s.track);i?i.push(s):n.set(s.track,[s])}for(let s of n.values())o(s);n.clear()}return t}function ji(a,e,t){let n=[],o=new Map,r=new V,s=new V,i=new V(1),c=1,l=0,p=m=>{let y=o.get(m);y&&(o.delete(m),y.nodes.length>=2&&n.push(gs(y.nodes)))},u=()=>{for(let m of o.keys())p(m)};for(let m of a.columns){let y=m[0].layoutLine,d,g=!1;for(let f of m)d=Ro(f)??d,f.mergeKey===Q&&(g=!0);if((y!==l||d||g)&&(l=y,u(),r.copyFrom(m[0].t)),d){let{numerator:f,denominator:x}=d;f>0&&x>4?i.set(x>=8&&f%3===0?12:4,x):i.set(1),c=i.compare(1)<0?i:1}for(let f of m){if(f.mergeKey===Q)continue;let x=M(f)?Vt(f):void 0;if(!(M(f)&&x!==void 0&&x.autoBeamEnabled&&e.get(x)?.length===1&&f.T.compare(c)<0&&!t.has(f))){(M(f)||!f.T.isZero())&&p(f.track);continue}s.copyFrom(f.t).sub(r);let b=Math.floor(s.numerator*i.denominator/(s.denominator*i.numerator)),S=o.get(f.track);if(!S||b!==S.beat||!f.t.equals(S.endTime)){p(f.track),o.set(f.track,{nodes:[f],beat:b,endTime:f.t.clone().add(f.T)});continue}S.nodes.push(f),S.endTime.copyFrom(f.t).add(f.T)}}return u(),n}function Mo(a){let e=Gi(a);if(e.size===0)return;let t=Fo(a.attachments);a.attachments.push(...zi(e.values(),t),...ji(a,e,t))}var bs="div",ht=Xe(bs),Ss=Symbol("div.owner");function Vt(a){return a.addon?.[Ss]}function ve(a,e){return`div.${a}.${e}`}function Oo(a,e){let t=a.ports[ve(e,"left")];t&&(t.state.claimed=!0)}function Ln(a){return Math.max(1,a*.055)}function*Io(a){for(let e=0;;e++){let t=!1,n=-1;for(let o=0;o<=a.length;o++){let r=a[o]?.ports,s=r?.[ve(e,"left")],i=r?.[ve(e,"right")];if((s||i)&&(t=!0),s&&i){n<0&&(n=o);continue}n>=0&&o-n>=2&&(yield{level:e,from:n,to:o-1}),n=-1}if(!t)return}}var Bo=class a extends E{static def={name:[bs,"/"],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(e,t,n){let o=0,r=t;for(;r<n&&e[r]==="/";)o++,r++;return o===0?null:{next:r,node:{kind:"sugar",data:{class:a,n:o},span:{start:t,end:r}}}}static deSugarRelation(e,t,n){let o=t[n++];if(o.data?.class!==a)return null;let r=e.findLastOperandIndex();if(r<0)return n;let s=e.nodes[r];if(s instanceof a)return s.n+=o.data.n,s.sourceSpan.end=Math.max(s.sourceSpan.end,o.span.end),n;let i=new Map;i.set(0,s),i.set("n",o.data.n);let c=s.sourceSpan;return e.nodes[r]=new a({start:Math.min(c.start,o.span.start),end:Math.max(c.end,o.span.end)},i,e,null),n}static layoutDecorationHandler=(e,t)=>{let n=Math.max(0,Math.floor(Number(t)||0));if(n===0)return null;let o=e.ast.size*.14,r=Ln(e.ast.size),s=(n-1)*o+r,i=0,c=0,l=0;return{below:{order:0,gap:e.box.h-(e.ports["decoration.below"]?.y??e.box.h)-e.ast.size*.08,height:s,place(p){i=e.ports["body.left"]?.x??0,c=e.ports["body.right"]?.x??e.box.w,l=p+r/2;for(let u=0;u<n;u++){let m=l+u*o;e.ports[ve(u,"left")]={x:i,y:m,state:{claimed:!1}},e.ports[ve(u,"right")]={x:c,y:m}}}},paint(p){let u=e.box.x+i,m=c-i,y=e.box.y+l-r/2;for(let d=0;d<n;d++)e.ports[ve(d,"left")].state.claimed||p.drawRect(u,y+d*o,m,r,{fill:"#000"})}}};loweringEnter(e){let t=this.n;if(t===0)return[];let n=this;return e.deferFinalize(a.loweringFinalize,-5),e.beginLoweringGroup(this,{onTemporal(o){let r=o.addon??={};r[ht]=(Number(r[ht])||0)+t,r[Ss]=n,o.T.divPow2(t)}}),[]}loweringExit(e){return this.n>0&&e.endLoweringGroup(this),[]}static loweringFinalize=Mo;content;n;autoBeamEnabled;get children(){return[this.content]}constructor(e,t,n,o=null){super(e,o),[this.content,this.n,this.autoBeamEnabled]=this.getArgValue(t,n),this.content.parent=this;let r=Math.max(0,Math.trunc(this.n));r!==this.n&&(n.diagnostics.push(new I("W_DIV_INVALID_N","@div \u7684\u6570\u91CF\u53C2\u6570 n \u5FC5\u987B\u4E3A\u975E\u8D1F\u6574\u6570\uFF0C\u5DF2\u88AB\u4FEE\u6B63\u4E3A {n}",this.sourceSpan,{n:r})),this.n=r)}toString(e){return`@div(${this.content.toString(e)}, ${this.n})`}},Do=Bo;function et(a,e,t){return new Ht(a,e,t)}function Vo(a){let e=new Map,t=new Map;for(let n of a.columns)for(let o of n){if(!M(o)||o.mergeKey===Q&&o.T.isZero())continue;let r=e.get(o.layoutLine);r||(r=new Map,e.set(o.layoutLine,r));let s=r.get(o.track)??0;t.set(o,{line:o.layoutLine,track:o.track,index:s}),r.set(o.track,s+1)}for(let n of a.attachments)if(!(!(n instanceof Ht)||!n.explicit))for(let o=1;o<n.endPoints.length;o++){let r=n.endPoints[o-1],s=n.endPoints[o];if(!M(r)||!M(s))continue;let i=t.get(r),c=t.get(s);if(!(r!==s&&i!==void 0&&c!==void 0&&i.line===c.line&&i.track===c.track&&c.index===i.index+1))throw new w("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 Fo(a){let e=new Set;for(let t of a)if(!(!(t instanceof Ht)||!t.explicit))for(let n of t.endPoints)e.add(n);return e}var Ht=class{kind="beam";layer="foreground";endPoints;explicit;sourceSpan;fontSize;strokeWidth;constructor(e,t,n){this.endPoints=e,this.explicit=t,this.sourceSpan=n,this.fontSize=e.reduce((o,r)=>M(r)?Math.max(o,r.ast.size):o,0),this.strokeWidth=Ln(this.fontSize)}prepareHorizontal(e){let t;for(let n of this.endPoints)if(M(n)){if(t&&t.layoutLine===n.layoutLine&&t.track===n.track){let o=e[t.layoutLine],r=o?o.trackIndexOf(t):-1;r>=0&&r+1===o.trackIndexOf(n)&&(t.springConfig.alpha_R*=.8,n.springConfig.alpha_L*=.8)}t=n}}createGeometry(e){let t=this.collectLines(e),n=this.strokeWidth,o=t.map(r=>({x:Math.min(r.start.x,r.end.x),y:r.start.y-n/2,w:Math.abs(r.end.x-r.start.x),h:n,line:r.line,track:r.track}));return{regions:o,paint(r){for(let s of o)r.drawRect(s.x,s.y,s.w,s.h,{fill:"#000"})}}}absolutePort(e,t){let n=e.ports[t];return{x:e.box.x+n.x,y:e.box.y+n.y}}collectLines(e){let t=[],n=this.endPoints.filter(M);if(n.length<2)return t;for(let{level:o,from:r,to:s}of Io(n)){let i=[];for(let c=r;c<=s;c++){let l=n[c];i.push({left:this.absolutePort(l,ve(o,"left")),right:this.absolutePort(l,ve(o,"right")),line:l.layoutLine,track:l.track,node:l})}this.addSystemLines(i,e,o,t)}if(t.length===0&&this.explicit){let o=this.fontSize*.12,r=n.map(s=>{let i={x:s.box.x+s.box.anchor,y:s.box.y+s.box.h+o};return{left:i,right:i,line:s.layoutLine,track:s.track,node:s}});this.addSystemLines(r,e,null,t)}return t}addSystemLines(e,t,n,o){let r=Math.min(...e.map(p=>p.line)),s=Math.max(...e.map(p=>p.line)),i=e[0].track,c=t.getVisualAxis(e[0].line,i),l=e[0].left.y-c;for(let p=r;p<=s;p++){let u=e.filter(x=>x.line===p).sort((x,h)=>x.left.x-h.left.x);if(u.length===0){let h=t.getVisualAxis(p,i)+l;o.push({start:{x:t.originX,y:h},end:{x:t.originX+t.width,y:h},line:p,track:i});continue}let m=u[0],y=u[u.length-1],d=m.left.y,g={x:m.left.x,y:d},f={x:y.right.x,y:d};if(p>r&&(g.x=t.originX),p<s&&(f.x=t.originX+t.width),!(g.x===f.x&&r===s)){if(n!==null)for(let x of u)Oo(x.node,n);o.push({start:g,end:f,line:p,track:m.track})}}}};var Ho=class a extends E{static loweringFinalize=Vo;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(e,t,n,o=null){super(e,o);for(let[s,i]of t)typeof s=="number"&&this.endPoints.push(i);let r=n.labelableNodes.length-1;for(;this.endPoints.length<2&&r>=0;){let s=n.labelableNodes[r--];!s||this.endPoints.includes(s)||this.endPoints.unshift(s)}if(this.endPoints.length<2)throw new w("E_NOT_ENOUGH_ARGS","@{fn} \u81F3\u5C11\u9700\u8981\u4E24\u4E2A\u7AEF\u70B9",e,{fn:"beam"})}loweringEnter(e){let t=[];for(let n of this.endPoints){let o=e.getTemporalNodes(n).at(-1)?.rootHost;o&&t.push(o)}return t.length<2?(e.diagnostics.push(O.warning.UnresolvedEndpoint("beam",this.sourceSpan)),[]):(e.addAttachment(et(t,!0,this.sourceSpan)),e.deferFinalize(a.loweringFinalize),[])}},Go=Ho;var zo=class extends E{static def={name:["box"],description:"\u7ED9\u76EE\u6807\u7ED3\u6784\u6216\u5BF9\u8C61\u52A0\u5916\u6846",details:`~~~jpfun
16
+ \u5206\u5B50\u6216\u5206\u6BCD\u4E3A 0 \u65F6\u8868\u793A\u6563\u677F\u3002`,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;weight;constructor(e,t,n,o=null){super(e,o);let[r,s,i]=this.getArgValue(t,n);if(this.font=n.variables.numberfont,this.weight=n.variables.numberweight,!Number.isSafeInteger(r)||!Number.isSafeInteger(r*4)||r<0||!Number.isSafeInteger(s)||s<0){let c="@meter \u7684\u5206\u5B50\u548C\u5206\u6BCD\u5FC5\u987B\u662F\u975E\u8D1F\u6574\u6570";if(n.variables.strict)throw new w("E_METER_INVALID",c,e);n.diagnostics.push(new O("W_METER_INVALID",`${c}\uFF0C\u5DF2\u56DE\u843D\u4E3A 4/4`,e)),r=s=4}this.numerator=r,this.denominator=s,r!==0&&s!==0&&(this.measureDuration=new I(r*4,s)),this.size=n.length2px(i),this.strict=n.variables.strict}loweringEnter(e){return e.deferFinalize(a.loweringFinalize),[new Po(this)]}static loweringFinalize(e){let t=new I,n=new I,o=null,r=!1,s=0,i=(c,l)=>{if(!(!o?.measureDuration||c.equals(t))){if(n.copyFrom(c).sub(t),!n.equals(o.measureDuration)&&(r||n.compare(o.measureDuration)>0)){let p="\u5C0F\u8282\u65F6\u957F\u4E3A {duration} QN\uFF0C\u4E0D\u6EE1\u8DB3 {num}/{den} \u62CD\u53F7",u={start:s,end:l},m={duration:n,num:o.numerator,den:o.denominator};if(o.strict)throw new w("E_METER_MISMATCH",p,u,m);e.diagnostics.push(new O("W_METER_MISMATCH",p,u,m))}t.copyFrom(c)}};for(let c of e.columns){let l=c.t;for(let p of c){let u=Pn.get(p);u&&(i(l,u.start),o=u.meter,t.copyFrom(l),s=u.end)}if(c.mergeKey===Q){let p=c[0].ast.sourceSpan.end;i(l,p),s=p,r=!0}}if(o){let c=e.columns.at(-1)?.at(-1)?.ast.sourceSpan??o.sourceSpan;i(e.duration,c.end)}}toString(){return`@meter(${this.numerator}, ${this.denominator})`}},ht=vo,Po=class extends H{style;numeratorBaseline=0;denominatorBaseline=0;lineY=0;lineHeight=0;constructor(e){super(),this.ast=e,this.style={fontSize:e.size,fontFamily:e.font,fontWeight:e.weight,textAlign:"center",fill:"#000"},this.initLayoutBox()}onTimeState(e){e.meter=this.ast.measureDuration;let{measureDuration:t,numerator:n,denominator:o}=this.ast;e.timeSignature=t&&{numerator:n,denominator:o},oc(this,this.ast)}emitPlayback(e){this.ast.measureDuration&&e.emit({kind:"time-signature",at:e.start,numerator:this.ast.numerator,denominator:this.ast.denominator})}prepareLayout(e){if(!this.ast.measureDuration){this.box.w=this.ast.size*Vt.w/Vt.h,this.box.h=this.ast.size,this.box.anchor=this.box.w/2,this.box.visualAxis=this.box.h/2;return}let t=e.textMeasurer.measureText(String(this.ast.numerator),this.style),n=e.textMeasurer.measureText(String(this.ast.denominator),this.style),o=this.ast.size*.08,r=this.ast.size*.08;this.lineHeight=Math.max(1,this.ast.size*.06),this.numeratorBaseline=t.baseline,this.lineY=t.h+o,this.denominatorBaseline=this.lineY+this.lineHeight+o+n.baseline,this.box.w=Math.max(t.w,n.w)+r*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(e){if(!this.ast.measureDuration){vn(e,No,Vt,this.box,this.ast.size/Vt.h);return}let t=this.box.x+this.box.anchor;e.drawText(String(this.ast.numerator),t,this.box.y+this.numeratorBaseline,this.style),e.drawRect(this.box.x,this.box.y+this.lineY,this.box.w,this.lineHeight,{fill:"#000"}),e.drawText(String(this.ast.denominator),t,this.box.y+this.denominatorBaseline,this.style)}};function rc(a){let e=new Map;for(let t of a.columns)for(let n of t){if(!_(n))continue;let o=Ht(n);if(!o)continue;let r=e.get(o);r?r.push(n):e.set(o,[n])}return e}function ts(a){let e=1/0,t=-1/0;for(let n of a){let o=Ht(n);e=Math.min(e,n.ast.sourceSpan.start,o.sourceSpan.start),t=Math.max(t,n.ast.sourceSpan.end,o.sourceSpan.end)}return xt(a,!1,{start:e,end:t})}function ac(a,e){let t=[],n=new Map,o=r=>{if(!r||r.length<2)return;let s=r[0].layoutLine;if(r.some(i=>i.layoutLine!==s))throw new w("E_DIV_CROSS_LINE","@div \u5185\u8FDE\u6210\u4E00\u7EC4\u7684\u51CF\u65F6\u7EBF\u4E0D\u80FD\u8DE8\u8D8A\u8C31\u9762\u884C",Ht(r[0]).sourceSpan);t.push(ts(r))};for(let r of a)if(!(r.length<2)){for(let s of r){if(e.has(s)){o(n.get(s.track)),n.delete(s.track);continue}let i=n.get(s.track);i?i.push(s):n.set(s.track,[s])}for(let s of n.values())o(s);n.clear()}return t}function sc(a,e,t){let n=[],o=new Map,r=new I,s=new I,i=new I(1),c=1,l=0,p=m=>{let f=o.get(m);f&&(o.delete(m),f.nodes.length>=2&&n.push(ts(f.nodes)))},u=()=>{for(let m of o.keys())p(m)};for(let m of a.columns){let f=m.layoutLine,d=m.mergeKey===Q,h;for(let y of m)h=es(y)??h;if((f!==l||h||d)&&(l=f,u(),r.copyFrom(m.t)),h){let{numerator:y,denominator:g}=h;y>0&&g>4?i.set(g>=8&&y%3===0?12:4,g):i.set(1),c=i.compare(1)<0?i:1}if(!d)for(let y of m){let g=_(y)?Ht(y):void 0;if(!(_(y)&&g!==void 0&&g.autoBeamEnabled&&e.get(g)?.length===1&&y.T.compare(c)<0&&!t.has(y))){(_(y)||!y.T.isZero())&&p(y.track);continue}s.copyFrom(y.t).sub(r);let b=Math.floor(s.numerator*i.denominator/(s.denominator*i.numerator)),S=o.get(y.track);if(!S||b!==S.beat||!y.t.equals(S.endTime)){p(y.track),o.set(y.track,{nodes:[y],beat:b,endTime:y.t.clone().add(y.T)});continue}S.nodes.push(y),S.endTime.copyFrom(y.t).add(y.T)}}return u(),n}function ns(a){let e=rc(a);if(e.size===0)return;let t=os(a.attachments);a.attachments.push(...ac(e.values(),t),...sc(a,e,t))}var rs="div",Gt=Xe(rs),as=Symbol("div.owner");function Ht(a){return a.addon?.[as]}function Be(a,e){return`div.${a}.${e}`}function ss(a,e){let t=a.ports[Be(e,"left")];t&&(t.state.claimed=!0)}function _o(a){return Math.max(1,a*.055)}function*is(a){for(let e=0;;e++){let t=!1,n=-1;for(let o=0;o<=a.length;o++){let r=a[o]?.ports,s=r?.[Be(e,"left")],i=r?.[Be(e,"right")];if((s||i)&&(t=!0),s&&i){n<0&&(n=o);continue}n>=0&&o-n>=2&&(yield{level:e,from:n,to:o-1}),n=-1}if(!t)return}}var Eo=class a extends P{static def={name:[rs,"/"],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(e,t,n){let o=0,r=t;for(;r<n&&e[r]==="/";)o++,r++;if(o===0)return null;let s={kind:"sugar",data:o,span:{start:t,end:r},relation:a.deSugarRelation};return{next:r,node:s}}static deSugarRelation(e,t,n){let o=t[n++],r=e.findLastOperandIndex();if(r<0)return n;let s=e.nodes[r];if(s instanceof a)return s.n+=o.data,s.sourceSpan.end=Math.max(s.sourceSpan.end,o.span.end),n;let i=new Map;i.set(0,s),i.set("n",o.data);let c=s.sourceSpan;return e.nodes[r]=new a({start:Math.min(c.start,o.span.start),end:Math.max(c.end,o.span.end)},i,e,null),n}static layoutDecorationHandler=(e,t)=>{let n=Math.max(0,Math.floor(Number(t)||0));if(n===0)return null;let o=e.ast.size*.14,r=_o(e.ast.size),s=(n-1)*o+r,i=0,c=0,l=0;return{below:{order:0,gap:e.box.h-(e.ports["decoration.below"]?.y??e.box.h)-e.ast.size*.08,height:s,place(p){i=e.ports["body.left"]?.x??0,c=e.ports["body.right"]?.x??e.box.w,l=p+r/2;for(let u=0;u<n;u++){let m=l+u*o;e.ports[Be(u,"left")]={x:i,y:m,state:{claimed:!1}},e.ports[Be(u,"right")]={x:c,y:m}}}},paint(p){let u=e.box.x+i,m=c-i,f=e.box.y+l-r/2;for(let d=0;d<n;d++)e.ports[Be(d,"left")].state.claimed||p.drawRect(u,f+d*o,m,r,{fill:"#000"})}}};loweringEnter(e){let t=this.n;if(t===0)return[];let n=this;return e.deferFinalize(a.loweringFinalize,-5),e.beginLoweringGroup(this,{onTemporal(o){let r=o.addon??={};r[Gt]=(Number(r[Gt])||0)+t,r[as]=n,o.T.divPow2(t)}}),[]}loweringExit(e){return this.n>0&&e.endLoweringGroup(this),[]}static loweringFinalize=ns;content;n;autoBeamEnabled;get children(){return[this.content]}constructor(e,t,n,o=null){super(e,o),[this.content,this.n,this.autoBeamEnabled]=this.getArgValue(t,n),this.content.parent=this;let r=Math.max(0,Math.trunc(this.n));r!==this.n&&(n.diagnostics.push(new O("W_DIV_INVALID_N","@div \u7684\u6570\u91CF\u53C2\u6570 n \u5FC5\u987B\u4E3A\u975E\u8D1F\u6574\u6570\uFF0C\u5DF2\u88AB\u4FEE\u6B63\u4E3A {n}",this.sourceSpan,{n:r})),this.n=r)}toString(e){return`@div(${this.content.toString(e)}, ${this.n})`}},En=Eo;function xt(a,e,t){return new zt(a,e,t)}function cs(a){let e=new Map,t=new Map;for(let n of a.columns)for(let o of n){if(!_(o)||o.mergeKey===Q&&o.T.isZero())continue;let r=e.get(o.layoutLine);r||(r=new Map,e.set(o.layoutLine,r));let s=r.get(o.track)??0;t.set(o,{line:o.layoutLine,track:o.track,index:s}),r.set(o.track,s+1)}for(let n of a.attachments)if(!(!(n instanceof zt)||!n.explicit))for(let o=1;o<n.endPoints.length;o++){let r=n.endPoints[o-1],s=n.endPoints[o];if(!_(r)||!_(s))continue;let i=t.get(r),c=t.get(s);if(!(r!==s&&i!==void 0&&c!==void 0&&i.line===c.line&&i.track===c.track&&c.index===i.index+1))throw new w("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 os(a){let e=new Set;for(let t of a)if(!(!(t instanceof zt)||!t.explicit))for(let n of t.endPoints)e.add(n);return e}var zt=class{kind="beam";layer="foreground";endPoints;explicit;sourceSpan;fontSize;strokeWidth;constructor(e,t,n){this.endPoints=e,this.explicit=t,this.sourceSpan=n,this.fontSize=e.reduce((o,r)=>_(r)?Math.max(o,r.ast.size):o,0),this.strokeWidth=_o(this.fontSize)}prepareHorizontal(e){let t;for(let n of this.endPoints)if(_(n)){if(t&&t.layoutLine===n.layoutLine&&t.track===n.track){let o=e[t.layoutLine],r=o?o.trackIndexOf(t):-1;r>=0&&r+1===o.trackIndexOf(n)&&(t.springConfig.alpha_R*=.8,n.springConfig.alpha_L*=.8)}t=n}}createGeometry(){let e=this.collectLines(),t=this.strokeWidth,n=e.map(o=>({x:Math.min(o.start.x,o.end.x),y:o.start.y-t/2,w:Math.abs(o.end.x-o.start.x),h:t,line:o.line,track:o.track}));return{regions:n,paint(o){for(let r of n)o.drawRect(r.x,r.y,r.w,r.h,{fill:"#000"})}}}absolutePort(e,t){let n=e.ports[t];return{x:e.box.x+n.x,y:e.box.y+n.y}}collectLines(){let e=[],t=this.endPoints.filter(_);if(t.length<2)return e;for(let{level:n,from:o,to:r}of is(t)){let s=[];for(let i=o;i<=r;i++){let c=t[i];s.push({left:this.absolutePort(c,Be(n,"left")),right:this.absolutePort(c,Be(n,"right")),line:c.layoutLine,track:c.track,node:c})}this.addLine(s,n,e)}if(e.length===0&&this.explicit){let n=this.fontSize*.12,o=t.map(r=>{let s={x:r.box.x+r.box.anchor,y:r.box.y+r.box.h+n};return{left:s,right:s,line:r.layoutLine,track:r.track,node:r}});this.addLine(o,null,e)}return e}addLine(e,t,n){e.sort((i,c)=>i.left.x-c.left.x);let o=e[0],r=e[e.length-1],s=o.left.y;if(o.left.x!==r.right.x){if(t!==null)for(let i of e)ss(i.node,t);n.push({start:{x:o.left.x,y:s},end:{x:r.right.x,y:s},line:o.line,track:o.track})}}};var Ro=class a extends P{static loweringFinalize=cs;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(e,t,n,o=null){super(e,o);for(let[s,i]of t)typeof s=="number"&&this.endPoints.push(i);let r=n.labelableNodes.length-1;for(;this.endPoints.length<2&&r>=0;){let s=n.labelableNodes[r--];!s||this.endPoints.includes(s)||this.endPoints.unshift(s)}if(this.endPoints.length<2)throw new w("E_NOT_ENOUGH_ARGS","@{fn} \u81F3\u5C11\u9700\u8981\u4E24\u4E2A\u7AEF\u70B9",e,{fn:"beam"})}loweringEnter(e){let t=[];for(let n of this.endPoints){let o=e.getTemporalNodes(n).at(-1)?.rootHost;o&&t.push(o)}return t.length<2?(e.diagnostics.push(M.warning.UnresolvedEndpoint("beam",this.sourceSpan)),[]):(e.addAttachment(xt(t,!0,this.sourceSpan)),e.deferFinalize(a.loweringFinalize),[])}},Mo=Ro;var Fo=class extends P{static def={name:["box"],description:"\u7ED9\u76EE\u6807\u7ED3\u6784\u6216\u5BF9\u8C61\u52A0\u5916\u6846",details:`~~~jpfun
17
17
  @box({1 2 3}, padding=0.2em, stroke=0.08em)
18
- ~~~`,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]}loweringEnter(e){let t={nodes:[],attachments:[],onTemporal(n){M(n)&&t.nodes.push(n)},onAttachment(n){t.attachments.push(n)}};return e.beginLoweringGroup(this,t),[]}loweringExit(e){let t=e.endLoweringGroup(this),n=new jo(t,this);e.addAttachment(n);let o=t.nodes[0];if(o){if(n.reservedHost){let s=o.prepareLayout;o.prepareLayout=i=>{s.call(o,i);let c={order:1/0,height:Math.max(0,this.padding+this.stroke/2)};o.decorations.push({above:c,below:c})}}let r=o.prepareHorizontal;o.prepareHorizontal=s=>{r?.call(o,s),n.registerHorizontal(s)}}return[]}constructor(e,t,n,o=null){super(e,o);let[r,s,i,c]=this.getArgValue(t,n);r.parent=this,this.target=r,this.padding=n.length2px(s),this.stroke=Math.max(0,n.length2px(i)),this.width=n.length2px(c)}toString(e){return`@box(${this.target.toString(e)}, padding=${this.padding}px, stroke=${this.stroke}px, width=${this.width}px)`}},Wo=zo,jo=class a{constructor(e,t){this.content=e;this.owner=t;let[n]=e.nodes;e.nodes.length===1&&e.attachments.every(o=>o instanceof a&&o.reservedHost===n)&&(this.reservedHost=n)}content;owner;kind="box";layer="background";reservedHost;fixedStart=null;wallOffset=0;get sourceSpan(){return this.owner.sourceSpan}registerHorizontal(e){let t=this.content.nodes,n=t[0];if(!n)return;if(t.some(c=>c.layoutLine!==n.layoutLine))throw new w("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 t){let l=e.columnOf(c);if(l<0)return;l<e.columnOf(n)&&(n=c),l>e.columnOf(o)&&(o=c)}let{width:r,padding:s,stroke:i}=this.owner;e.registerHorizontalLayoutHook(n,o,({columns:c,rows:l,start:p,end:u,X:m,fixed:y,options:d})=>{let g=b=>c[b].filter(S=>t.some(T=>T.box===S.box)),f=g(p),x=g(u);if(r>0){let b=Math.max(...f.map(L=>L.WL)),S=Math.max(...x.map(L=>L.WR));if(r<b+S-1e-6)throw new w("E_BOX_WIDTH_TOO_SMALL","@box \u7684\u5BBD\u5EA6\u5C0F\u4E8E\u9996\u672B\u5143\u7D20\u7684\u56FA\u6709\u5BBD\u5EA6",this.owner.sourceSpan);if(y[p-1]||y[u])throw new w("E_BOX_CONSTRAINT_CROSSING","\u5B9A\u5BBD @box \u53EF\u4EE5\u5D4C\u5957\uFF0C\u4F46\u4E0D\u80FD\u90E8\u5206\u4EA4\u53C9",this.owner.sourceSpan);let T=m.subarray(p,u+1);if(p===u){let L=(r-b-S)/2;for(let C of f)C.WL+=L;for(let C of x)C.WR+=L;T[0]=b+L}else{pt(c.slice(p,u+1),l,T,y.subarray(p,u),r,d,0);let L=T[T.length-1]-T[0]+b+S;if(Math.abs(L-r)>1e-6)throw new w("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=-T[0]}let h=s+i/2;for(let b of f)b.WL+=h;for(let b of x)b.WR+=h})}createGeometry(e){let{padding:t,stroke:n}=this.owner,o=e.getContentBounds(this.content);if(!o)return{regions:[],paint(){}};let r=t+n/2,i={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};if(i.w<n||i.h<n)throw new w("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:[i],occupancy:this.reservedHost?[]:this.occupancy(e,i),paint(c){let l=n/2;c.drawRect(i.x+l,i.y+l,Math.max(0,i.w-n),Math.max(0,i.h-n),{stroke:"#000",strokeWidth:n})}}}occupancy(e,t){let n=new Set,o,r=(c,l)=>{if(o!==void 0&&o!==c)throw new w("E_BOX_CROSS_LINE","@box \u7684\u5185\u5BB9\u4E0D\u80FD\u8DE8\u8D8A\u8C31\u9762\u884C",this.owner.sourceSpan);o=c,n.add(l)};for(let c of this.content.nodes)r(c.layoutLine,c.track);for(let c of this.content.attachments){if(!Ne(c))continue;let l=e.getAttachmentOccupancy(c);if(l){for(let p of c.endPoints??[])r(p.layoutLine,p.track);for(let p of l)p.line!==void 0&&r(p.line,p.track)}}if(o===void 0)return[];let s=o,i=[...n].sort((c,l)=>e.getVisualAxis(s,c)-e.getVisualAxis(s,l));return[{...t,h:0,line:s,track:i[0]},{...t,y:t.y+t.h,h:0,line:s,track:i.at(-1)}]}};var $o=class extends E{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(e,t,n){if(e[t]!=="-")return null;let o={kind:"call",typed:!0,name:"-",args:new Map,span:{start:t,end:t+1},syntaxKind:"atom"};return{next:t+1,node:o}}size;constructor(e,t,n,o=null){super(e,o),this.size=n.variables.fontsize}loweringEnter(){return[new Yo(this)]}labelable(){return this}toString(){return"-"}},Ko=$o,Yo=class extends W{lineWidth=0;constructor(e){super(),this.ast=e,this.T.set(1),this.mergeKey=Se,this.initLayoutBox()}onTimeState(e){this.playbackState={bpm:e.bpm}}prepareLayout(){let e=this.ast.size;this.lineWidth=e*.42,this.box.w=this.lineWidth,this.box.h=e,this.box.anchor=this.lineWidth/2,this.box.visualAxis=e*.5}finalizeLayout(){this.ports.lyric={x:this.box.anchor,y:this.box.h}}emitPlayback(e){let t=e.start.clone(),n=e.track,o=this.ast.sourceSpan;e.defer(r=>{let s,i=!1;for(let c=r.spans.length-1;c>=0;c--){let l=r.spans[c];if(s){if(l.origins[0]!==s)break}else{if(l.track!==n)continue;s=l.origins[0]}l.end.equals(t)&&(e.extend(l),i=!0)}i||r.diagnostics.push(new I("W_PLAYBACK_SUSTAIN_WITHOUT_TARGET","\u589E\u65F6\u7EBF\u524D\u6CA1\u6709\u53EF\u5EF6\u7EED\u7684\u97F3\u6BB5",o))})}paint(e){let t=Math.max(1,this.ast.size*.1);e.drawRect(this.box.x,this.box.y+this.box.visualAxis-t/2,this.lineWidth,t,{fill:"#000"})}};var Ls="dot",Ts=Xe(Ls);function ws(a){let e=2**a;return[2*e-1,e]}var Uo=class a extends E{static def={name:[Ls,"."],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(e,t,n){let o=0,r=t;for(;r<n&&e[r]===".";)o++,r++;return o===0?null:{next:r,node:{kind:"sugar",data:{class:a,n:o},span:{start:t,end:r}}}}static deSugarRelation(e,t,n){let o=t[n++];if(o.data?.class!==a)return null;let r=e.findLastOperandIndex();if(r<0)return n;let s=e.nodes[r];if(s instanceof a)return s.n+=o.data.n,s.sourceSpan.end=Math.max(s.sourceSpan.end,o.span.end),n;let i=new Map;i.set(0,s),i.set("n",o.data.n);let c=s.sourceSpan;return e.nodes[r]=new a({start:Math.min(c.start,o.span.start),end:Math.max(c.end,o.span.end)},i,e,null),n}static layoutDecorationHandler=(e,t)=>{let n=Math.max(0,Math.floor(Number(t)||0));if(n===0)return null;let o=e.ast.size*.075,r=e.ast.size*.12,s=e.ports.dot??{x:e.box.w,y:e.box.visualAxis},i=s.x+r+o,c=o*2+r,l=i+(n-1)*c+o;return e.box.w=Math.max(e.box.w,l),{paint(p){let u=e.box.y+s.y;for(let m=0;m<n;m++)p.drawCircle(e.box.x+i+m*c,u,o,{fill:"#000"})}}};loweringEnter(e){let t=this.n,n={temporalCount:0,onTemporal(o){if(n.temporalCount++,t===0)return;let r=o.addon??={},s=Number(r[Ts])||0,i=s+t,[c,l]=ws(i),[p,u]=ws(s);o.T.mul(c*u,l*p),r[Ts]=i}};return e.beginLoweringGroup(this,n),[]}loweringExit(e){let t=e.endLoweringGroup(this);if(t.temporalCount!==1)throw new w("E_DOT_INVALID_CONTENT","\u51FD\u6570 @dot \u53EA\u80FD\u63A5\u6536 1\u4E2A\u5143\u7D20\uFF0C\u4F46\u627E\u5230\u4E86 {count} \u4E2A",this.sourceSpan,{count:t.temporalCount});return[]}content;n;get children(){return[this.content]}constructor(e,t,n,o=null){super(e,o),[this.content,this.n]=this.getArgValue(t,n),this.content.parent=this;let r=Math.max(0,Math.trunc(this.n));r!==this.n&&(n.diagnostics.push(new I("W_DOT_INVALID_N","@dot \u7684\u6570\u91CF\u53C2\u6570 n \u5FC5\u987B\u4E3A\u975E\u8D1F\u6574\u6570\uFF0C\u5DF2\u88AB\u4FEE\u6B63\u4E3A {n}",this.sourceSpan,{n:r})),this.n=r)}toString(e){return`@dot(${this.content.toString(e)}, ${this.n})`}},Xo=Uo;function Cn(a,e,t=!1){let n=0,o=a.length;for(;n<o;){let r=n+o>>>1,s=a[r].host.t.compare(e);(t?s<=0:s<0)?n=r+1:o=r}return n}var Zo=class a extends E{static def={name:["dyn"],description:"\u6E10\u5F3A\u6E10\u5F31",details:`~~~jpfun
18
+ ~~~`,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]}loweringEnter(e){let t={nodes:[],attachments:[],onTemporal(n){_(n)&&t.nodes.push(n)},onAttachment(n){t.attachments.push(n)}};return e.beginLoweringGroup(this,t),[]}loweringExit(e){let t=e.endLoweringGroup(this),n=new Bo(t,this);e.addAttachment(n);let o=t.nodes[0];if(o){if(n.reservedHost){let s=o.prepareLayout;o.prepareLayout=i=>{s.call(o,i);let c={order:1/0,height:Math.max(0,this.padding+this.stroke/2)};o.decorations.push({above:c,below:c})}}let r=o.prepareHorizontal;o.prepareHorizontal=s=>{r?.call(o,s),n.registerHorizontal(s)}}return[]}constructor(e,t,n,o=null){super(e,o);let[r,s,i,c]=this.getArgValue(t,n);r.parent=this,this.target=r,this.padding=n.length2px(s),this.stroke=Math.max(0,n.length2px(i)),this.width=n.length2px(c)}toString(e){return`@box(${this.target.toString(e)}, padding=${this.padding}px, stroke=${this.stroke}px, width=${this.width}px)`}},Oo=Fo,Bo=class a{constructor(e,t){this.content=e;this.owner=t;let[n]=e.nodes;e.nodes.length===1&&e.attachments.every(o=>o instanceof a&&o.reservedHost===n)&&(this.reservedHost=n)}content;owner;kind="box";layer="background";reservedHost;fixedStart=null;wallOffset=0;get sourceSpan(){return this.owner.sourceSpan}registerHorizontal(e){let t=this.content.nodes,n=t[0];if(!n)return;if(t.some(c=>c.layoutLine!==n.layoutLine))throw new w("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 t){let l=e.columnOf(c);if(l<0)return;l<e.columnOf(n)&&(n=c),l>e.columnOf(o)&&(o=c)}let{width:r,padding:s,stroke:i}=this.owner;e.registerHorizontalLayoutHook(n,o,({columns:c,rows:l,start:p,end:u,X:m,fixed:f,options:d})=>{let h=b=>c[b].filter(S=>t.some(T=>T.box===S.box)),y=h(p),g=h(u);if(r>0){let b=Math.max(...y.map(L=>L.WL)),S=Math.max(...g.map(L=>L.WR));if(r<b+S-1e-6)throw new w("E_BOX_WIDTH_TOO_SMALL","@box \u7684\u5BBD\u5EA6\u5C0F\u4E8E\u9996\u672B\u5143\u7D20\u7684\u56FA\u6709\u5BBD\u5EA6",this.owner.sourceSpan);if(f[p-1]||f[u])throw new w("E_BOX_CONSTRAINT_CROSSING","\u5B9A\u5BBD @box \u53EF\u4EE5\u5D4C\u5957\uFF0C\u4F46\u4E0D\u80FD\u90E8\u5206\u4EA4\u53C9",this.owner.sourceSpan);let T=m.subarray(p,u+1);if(p===u){let L=(r-b-S)/2;for(let C of y)C.WL+=L;for(let C of g)C.WR+=L;T[0]=b+L}else{ut(c.slice(p,u+1),l,T,f.subarray(p,u),r,d,0);let L=T[T.length-1]-T[0]+b+S;if(Math.abs(L-r)>1e-6)throw new w("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=-T[0]}let x=s+i/2;for(let b of y)b.WL+=x;for(let b of g)b.WR+=x})}createGeometry(e){let{padding:t,stroke:n}=this.owner,o=e.getContentBounds(this.content);if(!o)return{regions:[],paint(){}};let r=t+n/2,i={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};if(i.w<n||i.h<n)throw new w("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:[i],occupancy:this.reservedHost?[]:this.occupancy(e,i),paint(c){let l=n/2;c.drawRect(i.x+l,i.y+l,Math.max(0,i.w-n),Math.max(0,i.h-n),{stroke:"#000",strokeWidth:n})}}}occupancy(e,t){let n=new Set,o,r=(c,l)=>{if(o!==void 0&&o!==c)throw new w("E_BOX_CROSS_LINE","@box \u7684\u5185\u5BB9\u4E0D\u80FD\u8DE8\u8D8A\u8C31\u9762\u884C",this.owner.sourceSpan);o=c,n.add(l)};for(let c of this.content.nodes)r(c.layoutLine,c.track);for(let c of this.content.attachments){if(!Ne(c))continue;let l=e.getAttachmentOccupancy(c);if(l){for(let p of c.endPoints??[])r(p.layoutLine,p.track);for(let p of l)p.line!==void 0&&r(p.line,p.track)}}if(o===void 0)return[];let s=o,i=[...n].sort((c,l)=>e.getVisualAxis(s,c)-e.getVisualAxis(s,l));return[{...t,h:0,line:s,track:i[0]},{...t,y:t.y+t.h,h:0,line:s,track:i.at(-1)}]}};var Io=class extends P{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(e,t,n){if(e[t]!=="-")return null;let o={kind:"call",typed:!0,name:"-",args:new Map,span:{start:t,end:t+1},syntaxKind:"atom"};return{next:t+1,node:o}}size;numberStyle;constructor(e,t,n,o=null){super(e,o),this.size=n.variables.fontsize,this.numberStyle={fontSize:this.size,fontFamily:n.variables.numberfont,fontWeight:n.variables.numberweight}}loweringEnter(){return[new Do(this)]}labelable(){return this}toString(){return"-"}},Vo=Io,Do=class extends H{constructor(e){super(),this.ast=e,this.T.set(1),this.mergeKey=Le,this.initLayoutBox()}prepareLayout(e){let t=this.ast.size;this.box.w=e.textMeasurer.measureText("0",this.ast.numberStyle).w,this.box.h=t,this.box.anchor=this.box.w/2,this.box.visualAxis=t*.5}finalizeLayout(){this.ports.lyric={x:this.box.anchor,y:this.box.h}}emitPlayback(e){let t=e.start.clone(),n=e.track,o=this.ast.sourceSpan;e.defer(r=>{let s,i=!1;for(let c=r.spans.length-1;c>=0;c--){let l=r.spans[c];if(s){if(l.origins[0]!==s)break}else{if(l.track!==n)continue;s=l.origins[0]}l.end.equals(t)&&(e.extend(l),i=!0)}i||r.diagnostics.push(new O("W_PLAYBACK_SUSTAIN_WITHOUT_TARGET","\u589E\u65F6\u7EBF\u524D\u6CA1\u6709\u53EF\u5EF6\u7EED\u7684\u97F3\u6BB5",o))})}paint(e){let t=this.ast.size*.42,n=Math.max(1,this.ast.size*.1);e.drawRect(this.box.x+this.box.anchor-t/2,this.box.y+this.box.visualAxis-n/2,t,n,{fill:"#000"})}};var us="dot",ls=Xe(us);function ps(a){let e=2**a;return[2*e-1,e]}var Ho=class a extends P{static def={name:[us,"."],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(e,t,n){let o=0,r=t;for(;r<n&&e[r]===".";)o++,r++;if(o===0)return null;let s={kind:"sugar",data:o,span:{start:t,end:r},relation:a.deSugarRelation};return{next:r,node:s}}static deSugarRelation(e,t,n){let o=t[n++],r=e.findLastOperandIndex();if(r<0)return n;let s=e.nodes[r];if(s instanceof a)return s.n+=o.data,s.sourceSpan.end=Math.max(s.sourceSpan.end,o.span.end),n;let i=new Map;i.set(0,s),i.set("n",o.data);let c=s.sourceSpan;return e.nodes[r]=new a({start:Math.min(c.start,o.span.start),end:Math.max(c.end,o.span.end)},i,e,null),n}static layoutDecorationHandler=(e,t)=>{let n=Math.max(0,Math.floor(Number(t)||0));if(n===0)return null;let o=e.ast.size*.075,r=e.ast.size*.12,s=e.ports.dot??{x:e.box.w,y:e.box.visualAxis},i=s.x+r+o,c=o*2+r,l=i+(n-1)*c+o;return e.box.w=Math.max(e.box.w,l),{paint(p){let u=e.box.y+s.y;for(let m=0;m<n;m++)p.drawCircle(e.box.x+i+m*c,u,o,{fill:"#000"})}}};loweringEnter(e){let t=this.n,n={temporalCount:0,onTemporal(o){if(n.temporalCount++,t===0)return;let r=o.addon??={},s=Number(r[ls])||0,i=s+t,[c,l]=ps(i),[p,u]=ps(s);o.T.mul(c*u,l*p),r[ls]=i}};return e.beginLoweringGroup(this,n),[]}loweringExit(e){let t=e.endLoweringGroup(this);if(t.temporalCount!==1)throw new w("E_DOT_INVALID_CONTENT","\u51FD\u6570 @dot \u53EA\u80FD\u63A5\u6536 1\u4E2A\u5143\u7D20\uFF0C\u4F46\u627E\u5230\u4E86 {count} \u4E2A",this.sourceSpan,{count:t.temporalCount});return[]}content;n;get children(){return[this.content]}constructor(e,t,n,o=null){super(e,o),[this.content,this.n]=this.getArgValue(t,n),this.content.parent=this;let r=Math.max(0,Math.trunc(this.n));r!==this.n&&(n.diagnostics.push(new O("W_DOT_INVALID_N","@dot \u7684\u6570\u91CF\u53C2\u6570 n \u5FC5\u987B\u4E3A\u975E\u8D1F\u6574\u6570\uFF0C\u5DF2\u88AB\u4FEE\u6B63\u4E3A {n}",this.sourceSpan,{n:r})),this.n=r)}toString(e){return`@dot(${this.content.toString(e)}, ${this.n})`}},Go=Ho;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"}]},cc={mf:8.0028,mp:9.523,ff:6.67866,pp:8.8083},lc={fill:"#000"},pc=.79341,zo=[49,33,16,10,5,1],jo=[96,112,126,127],ms=new WeakMap;function ds(a){let e=a.onTimeState;return e&&ms.get(e)}function gt(a,e,t){let n=s=>{s.velocity=e};ms.set(n,e);let o=0,r=Array.from(a,(s,i)=>{let c={path:ic[s],style:lc,dx:o};return o+=cc[s+a[i+1]]??0,c});return{name:a,description:t,shapes:r,weight:a.includes("f")?1:pc,onTimeState:n}}var ys=[{...gt("p",zo[0],"\u5F31\uFF1B\u652F\u6301 `$p`\u3001`$pp`\u3001`$ppp` \u7B49\u8FDE\u7EED p\uFF0C\u6574\u4F53\u5C45\u4E2D"),pattern:{regex:/^p+$/,resolve:([a])=>gt(a,zo[Math.min(a.length,zo.length)-1],"\u5F31\u529B\u5EA6\u8BB0\u53F7")}},gt("mp",64,"\u4E2D\u5F31"),gt("mf",80,"\u4E2D\u5F3A"),{...gt("f",jo[0],"\u5F3A\uFF1B\u652F\u6301 `$f`\u3001`$ff`\u3001`$fff` \u7B49\u8FDE\u7EED f\uFF0C\u6574\u4F53\u5C45\u4E2D"),pattern:{regex:/^f+$/,resolve:([a])=>gt(a,jo[Math.min(a.length,jo.length)-1],"\u5F3A\u529B\u5EA6\u8BB0\u53F7")}}];var uc=a=>Math.max(1,Math.min(127,a));function Ge(a,e,t=!1){let n=0,o=a.length;for(;n<o;){let r=n+o>>>1,s=a[r].host.t.compare(e);(t?s<=0:s<0)?n=r+1:o=r}return n}function xs(a,e,t,n,o=0){e>=t||(a.offset[e]+=n,a.offset[t]-=n,a.slope[e]+=o,a.slope[t]-=o)}function fs(a,e,t,n){let o=e.fromHost.t,r=n/e.toHost.t.clone().sub(o).toNumber();xs(a,Ge(a.records,o),t,-r*o.toNumber(),r)}function hs({records:a,times:e,increments:t,offset:n,slope:o}){let r=0,s=0;for(let i=0;i<a.length;i++){r+=n[i],s+=o[i];let c=a[i].velocity;t[i]=uc(c+t[i]+r+s*e[i])-c}n.fill(0),o.fill(0)}var Wo=class a extends P{static def={name:["dyn"],description:"\u6E10\u5F3A\u6E10\u5F31",details:`~~~jpfun
19
19
  1 ^ $p 2@a 3 4@b
20
20
  @dyn(a, b, 24)
21
21
  ~~~
22
- \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
22
+ \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\uFF0C\u5E76\u4FDD\u6301\u5230\u4E0B\u4E00\u4E2A\u529B\u5EA6\u8BB0\u53F7\u3002\u672C\u4F8B\u4ECE \`a\` \u5230 \`b\` \u6E10\u5F3A\uFF0C\u7EC8\u70B9\u589E\u52A0 24 \u7684\u529B\u5EA6\u3002
23
23
 
24
- \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(e){let t=e.attachments.filter(o=>o instanceof Gt);if(t.length===0)return;let n=new Map(t.map(o=>[o.track,[]]));for(let o of e.astToTemporal.values())for(let r of o){let s=r.playbackState?.velocity;if(s===void 0)continue;let i=r.rootHost;n.get(i.track)?.push({node:r,host:i,velocity:s,increment:0})}for(let o of n.values())o.sort((r,s)=>r.host.t.compare(s.host.t)||r.node.order-s.node.order);for(let o of t){let r=n.get(o.track),s=Cn(r,o.toHost.t),i=Cn(r,o.toHost.t,!0),c=o.end.playbackState?.velocity;for(let m=s;c===void 0&&m<i;m++)r[m].host===o.toHost&&(c=r[m].velocity);if(c??=r[i-1]?.velocity,c===void 0){e.diagnostics.push(new I("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 l=r.length;for(let m=i;m<r.length;m++)if(r[m].velocity!==c){l=Cn(r,r[m].host.t);break}let p=Cn(r,o.fromHost.t),u=o.toHost.t.clone().sub(o.fromHost.t);for(let m=p;m<l;m++){let y=m>=s?1:r[m].host.t.clone().sub(o.fromHost.t).div(u).toNumber();r[m].increment+=o.dv*y}}for(let o of n.values())for(let r of o){if(r.increment===0)continue;let s=Math.max(1,Math.min(127,r.velocity+r.increment));r.node.playbackState={...r.node.playbackState,velocity:s}}}from;to;dv;size;loweringEnter(e){let t=e.getTemporalNodes(this.from).at(0),n=e.getTemporalNodes(this.to).at(-1);if(!t||!n)return e.diagnostics.push(O.warning.UnresolvedEndpoint("dyn",this.sourceSpan)),[];let o=t.rootHost,r=n.rootHost;if(!M(o)||!M(r))return e.diagnostics.push(O.warning.UnresolvedEndpoint("dyn",this.sourceSpan)),[];if(o.track!==r.track)throw new w("E_DYN_CROSS_TRACK","@dyn \u7684\u4E24\u4E2A\u7AEF\u70B9\u5FC5\u987B\u4F4D\u4E8E\u540C\u4E00\u97F3\u8F68",this.sourceSpan);if(o.t.equals(r.t))throw new w("E_DYN_ZERO_SPAN","@dyn \u7684\u4E24\u4E2A\u7AEF\u70B9\u5FC5\u987B\u4F4D\u4E8E\u4E0D\u540C\u65F6\u95F4",this.sourceSpan);return o.t.compare(r.t)<0?e.addAttachment(new Gt(this,n,o,r)):e.addAttachment(new Gt(this,t,r,o)),e.deferFinalize(a.loweringFinalize),[]}constructor(e,t,n,o=null){super(e,o);let[r,s,i]=this.getArgValue(t,n),c=i;if(!Number.isFinite(c)||c===0)throw new w("E_DYN_INVALID_DELTA","@dyn \u7684 dv \u5FC5\u987B\u662F\u975E\u96F6\u6709\u9650\u6570",e);c=Math.max(-127,Math.min(127,c)),c!==i&&n.diagnostics.push(new I("W_DYN_DELTA_CLAMPED","@dyn \u7684 dv \u5FC5\u987B\u5728 -127 \u5230 127 \u4E4B\u95F4\uFF0C\u5DF2\u88AB\u9650\u5236\u4E3A {dv}",e,{dv:c})),this.from=r,this.to=s,this.dv=c,this.size=n.variables.fontsize}toString(e){let t=n=>n.label??n.toString(e);return`@dyn(${t(this.from)}, ${t(this.to)}, ${this.dv})`}},qo=Zo,Gt=class{constructor(e,t,n,o){this.ast=e;this.end=t;this.fromHost=n;this.toHost=o}ast;end;fromHost;toHost;kind="dyn";layer="foreground";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(e){let t=this.fromHost.layoutLine,n=this.toHost.layoutLine,o=[this.fromHost,this.toHost],r=[],s=this.ast.size;for(let d=t;d<=n;d++){let g=e.getRangeColumns(d,o,this.track);if(g.some(f=>f.length>0)){for(let f of g)for(let x of f)s=Math.max(s,x.ast.size);r.push({line:d,startX:d===t?this.fromHost.box.x:Te(e,d,this.track),endX:d===n?this.toHost.box.x+this.toHost.box.w:we(e,d)})}}for(let d of r)d.line>t&&(d.startX-=s/4);let i=Math.max(.75,s*.035),c=r.filter(d=>d.startX!==d.endX),l=c.reduce((d,g)=>d+Math.abs(g.endX-g.startX),0);if(l===0)return{regions:[],paint(){}};let p=s*.4,u=i/2,m=0,y=c.map(d=>{let g=Math.abs(d.endX-d.startX),f=m/l,x=(m+g)/l;m+=g;let h=e.getRangeExtents(d.line,o,this.track),b=e.getVisualAxis(d.line,this.track),S=h?b+h.top:b;return{line:d.line,startX:d.startX,endX:d.endX,lineY:S-s*.62,startOpen:p*(this.dv>0?f:1-f),endOpen:p*(this.dv>0?x:1-x)}});return{regions:y.map(d=>({x:Math.min(d.startX,d.endX)-u,y:d.lineY-Math.max(d.startOpen,d.endOpen)/2-u,w:Math.abs(d.endX-d.startX)+i,h:Math.max(d.startOpen,d.endOpen)+i,line:d.line,track:this.track})),paint(d){let g={stroke:"#000",strokeWidth:i};for(let f of y)d.drawLine(f.startX,f.lineY-f.startOpen/2,f.endX,f.lineY-f.endOpen/2,g),d.drawLine(f.startX,f.lineY+f.startOpen/2,f.endX,f.lineY+f.endOpen/2,g)}}}};var tt=class a{constructor(e=null){this.parent=e}parent;groups=[];group(e,t){let n=this.groups.find(o=>o.laneKey===e.laneKey);for(n||(n={laneKey:e.laneKey,members:[],measure:e.measure,place:e.place},this.groups.push(n));n.members.length<t;)n.members.push(new a(this));return n}};var nt=.7,Cs="shoulder";function As(a,e){if(e===1)return;let t=a;typeof t.size=="number"&&(t.size*=e),typeof t.gap=="number"&&(t.gap*=e),typeof t.minGap=="number"&&(t.minGap*=e),t.aboveGaps?.forEach((n,o,r)=>r[o]*=e),t.belowGaps?.forEach((n,o,r)=>r[o]*=e);for(let n of a.children??[])As(n,e)}var Qo=class a extends E{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 E.findLabelable(this.host)}static deSugarAtom(e,t,n){let o=e[t];switch(o){case">":o="pre";break;case"<":o="post";break;default:return null}return{next:t+1,node:{kind:"sugar",data:{class:a,side:o},span:{start:t,end:t+1}}}}static deSugarRelation(e,t,n){let o=t[n++];if(o.kind!=="sugar"||o.data?.class!==a)return null;let r=o.data.side,s=e.takeLeftOperand();if(!s)throw new w("E_GRACE_NO_TARGET","@grace\u8BED\u6CD5\u7CD6\u9519\u8BEF: \u5DE6\u8FB9\u6CA1\u6709\u627E\u5230\u76EE\u6807",o.span);let i=e.consumeRightOperand(t,n,c=>r==="pre"?a.attachPre(s,c,o.span,e):a.create(e,o.span,"post",s,c));if(i!==null)return i;throw new w("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(e,t,n,o){if(t instanceof a&&t.side==="pre"){let r=t,s=1;for(;r.grace instanceof a&&r.grace.side==="pre";)r=r.grace,s++;let i=nt**s,c=a.create(o,n,"pre",r.grace,e,nt*i);return c.size*=i,r.setGrace(c,1),t}return a.create(o,n,"pre",t,e)}static create(e,t,n,o,r,s=nt){let i=new Map;return i.set(0,o),i.set(1,r),i.set("side",n),new a(t,i,e,null,s)}get children(){return[this.host,this.grace]}timeFlowModel(){return null}constructor(e,t,n,o=null,r=nt){if(super(e,o),this.size=n.variables.fontsize,[this.host,this.grace,this.side]=this.getArgValue(t,n),this.side!=="pre"&&this.side!=="post")throw new w("E_GRACE_INVALID_SIDE","@grace \u7684 side \u53C2\u6570\u5FC5\u987B\u662F 'pre' \u6216 'post'",e);this.adopt(this.host),this.setGrace(this.grace,r)}setGrace(e,t=nt){As(e,t),this.grace=e,this.adopt(e)}adopt(e){e.parent=this,this.sourceSpan.start=Math.min(this.sourceSpan.start,e.sourceSpan.start),this.sourceSpan.end=Math.max(this.sourceSpan.end,e.sourceSpan.end)}loweringEnter(e,t){let{host:n,grace:o}=this,r=new tt(t),s=[],i=[],c=[],l=(m,y)=>e.trackedEvents(m,new V,y);e.isolateFromLoweringGroups(()=>{this.side==="post"&&(s=l(n,t).flat()),e.beginLoweringGroup(this,{onAttachment(m){c.push(m)}}),i=l(o,r),e.endLoweringGroup(this),this.side==="pre"&&(s=l(n,t).flat())});let[p]=s;if(s.length!==1||!M(p))throw new w("E_GRACE_INVALID_HOST","@grace \u7684\u5BBF\u4E3B\u5FC5\u987B\u6070\u597D\u4EA7\u751F\u4E00\u4E2A\u53EF\u89C1 Temporal",n.sourceSpan);let u=i.flat();if(!u.some(M)||u.some(m=>(m.addon?.breakBefore??0)>0))throw new w("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);return[new An(this,p,i,r,c,e)]}toString(e){return`@grace(${this.host.toString(e)}, ${this.grace.toString(e)}, side=${this.side})`}},Jo=Qo,Wi=[{op:"M",x:0,y:0},{op:"C",cx1:-.01,cy1:.26,cx2:.14,cy2:.42,x:.29,y:.36}],$i=.07,Yi=.18,An=class extends W{host;graceColumns;graces;root;attachments;events;starts;hostOffset={x:0,y:0};graceOffsets=[];hookOrigin=null;constructor(e,t,n,o,r,s){super(),this.ast=e,this.host=t,this.root=o,this.attachments=r,this.T.copyFrom(t.T),this.mergeKey=t.mergeKey,this.initLayoutBox(),t.addon&&(this.addon={...t.addon}),t.addon=void 0,t.foldedInto=this;let i=[],c=[],l=[];for(let m of n){let y=m[0].t.clone().divPow2(),d=[];for(let g of m)g.foldedInto=this,c.push(g),l.push(y),M(g)&&d.push(g);d.length>0&&i.push(d)}this.graceColumns=i,this.graces=i.flat(),this.events=c,this.starts=l;let p=new Map,u=[];for(let m of this.graces){if(m.T.isZero()){p.delete(m.track);continue}let y=p.get(m.track);y||(p.set(m.track,y=[]),u.push(y)),y.push(m);let d=m.addon={...m.addon};d[ht]=(Number(d[ht])||0)+1,m.T.divPow2()}for(let m of u)m.length>=2&&s.addAttachment(et(m,!1,e.grace.sourceSpan))}onTimeState(e){this.host.T.copyFrom(this.T);let t;for(let n of this.ast.side==="pre"?[...this.events,this.host]:[this.host,...this.events]){n.t.copyFrom(this.t),n.layoutLine=this.layoutLine;let o=n.onTimeState?.(e);n===this.host&&(this.T.copyFrom(n.T),t=o)}return t}prepareHorizontal(e){this.host.prepareHorizontal?.(e)}emitPlayback(e){let t=new V,n=new V;this.events.forEach((u,m)=>{n.copyFrom(this.starts[m]).add(u.T),n.compare(t)>0&&t.copyFrom(n)});let o=e.end.clone().sub(e.start),r=new V(1,4),s=t.clone().mul(r),i=o.clone().divPow2();s.compare(i)>0&&(r.copyFrom(i).div(t),s.copyFrom(i));let c=o.sub(s),l=this.ast.side==="pre",p=l?e.start.clone():e.start.clone().add(c);l||e.play(this.host,e.start.clone(),c),this.events.forEach((u,m)=>{e.play(u,this.starts[m].clone().mul(r).add(p),u.T.clone().mul(r))}),l&&e.play(this.host,p.add(s),c)}prepareLayout(e){qe(this,this.host);let t=e.layoutSubdomain(this,this.graceColumns,this.root,this.attachments),n=dt([this.host],e);this.springConfig={...this.host.springConfig};let o=this.ast.size*nt,r=o*.2,s=o*Yi,i=this.ast.side==="pre",l=(this.host.ports[Cs]?.y??0)-s-t.height,p=te(this.host),u=Math.max(0,-l,-p.y),m=i?0:n+r;this.hostOffset={x:this.host.box.x+(i?t.width+r:0),y:u},this.graceOffsets=t.positions.map(g=>({x:m+g.x,y:l+u+g.y})),this.box.w=n+r+t.width,this.box.h=u+p.y+p.h,this.box.anchor=this.hostOffset.x+this.host.box.anchor,this.box.visualAxis=u+this.host.box.visualAxis;for(let g in this.host.ports){let f=this.host.ports[g];this.ports[g]={...f,x:this.hostOffset.x+f.x,y:this.hostOffset.y+f.y}}this.ports[Cs]??={x:this.box.anchor,y:this.hostOffset.y};let y=this.graces.filter(g=>!g.T.isZero()),d=i?y.at(-1):y[0];this.hookOrigin=d?{x:this.graceOffsets[this.graces.indexOf(d)].x+d.box.anchor,y:Math.max(...this.graces.map((g,f)=>this.graceOffsets[f].y+g.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((e,t)=>{e.box.x=this.box.x+this.graceOffsets[t].x,e.box.y=this.box.y+this.graceOffsets[t].y,e.onPlaced?.()})}paint(e){for(let r of[this.host,...this.graces])Me(e,r);if(!this.hookOrigin)return;let t=this.ast.size*nt,n=this.hookOrigin,o=this.ast.side==="pre"?1:-1;e.drawPath(Wi,{stroke:"#000",strokeWidth:Math.max(.8,t*$i)},{x:this.box.x+n.x,y:this.box.y+n.y,scaleX:t*o,scaleY:t})}};function Ns(a,e,t){let n=o=>typeof o?.resolvedMidi=="number"?o:void 0;if("resolvedMidi"in e)return n(e);for(let o=a.findIndex(r=>r.includes(t))-1;o>=0;o--){let r=a[o].find(s=>s.track===t.track&&"resolvedMidi"in s);if(r)return n(r)}}var er=class extends E{static def={name:["gliss"],description:"\u6ED1\u97F3\u8FDE\u7EBF",details:`~~~jpfun
24
+ \u7EC8\u70B9\u540C\u4E00\u65F6\u523B\u6709\u529B\u5EA6\u8BB0\u53F7\u65F6\uFF0C\u4EE5\u8BE5\u8BB0\u53F7\u4E3A\u76EE\u6807\u7EBF\u6027\u8FC7\u6E21\uFF0C\u4E0D\u518D\u53E0\u52A0 \`dv\`\u3002
25
+
26
+ \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(e){let t=e.attachments.filter(i=>i instanceof jt&&i.orient());if(t.length===0)return;let n=new Map(t.map(i=>[i.track,{records:[],marks:[]}]));for(let i of e.astToTemporal.values())for(let c of i){let l=c.rootHost,p=n.get(l.track);if(!p)continue;let u=c.playbackState?.velocity;u!==void 0&&p.records.push({node:c,host:l,velocity:u});let m=ds(c);m!==void 0&&p.marks.push({node:c,host:l,velocity:m})}let o=(i,c)=>i.host.t.compare(c.host.t)||i.node.order-c.node.order,r=new Map;for(let[i,{records:c,marks:l}]of n){c.sort(o),l.sort(o);let p=c.length,u=new Int32Array(p);for(let m=p-1;m>=0;m--)u[m]=m+1<p&&c[m+1].velocity===c[m].velocity?u[m+1]:m+1;r.set(i,{records:c,marks:l,runEnd:u,times:Float64Array.from(c,m=>m.host.t.toNumber()),increments:new Float64Array(p),offset:new Float64Array(p+1),slope:new Float64Array(p+1)})}let s=[];for(let i of t){let c=r.get(i.track),{records:l,marks:p,runEnd:u}=c,m=i.toHost.t,f=Ge(l,m),d=Ge(l,m,!0);if(d===0){e.diagnostics.push(new O("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",i.sourceSpan));continue}let h=p[Ge(p,m,!0)-1];if(h?.host.t.equals(m)){let x=l[d-1];s.push([i,x.host.t.equals(m)?x.velocity:h.velocity]);continue}let y=u[d-1];y<l.length&&(y=Ge(l,l[y].host.t));let g=p[Ge(p,m,!0)];g&&(y=Math.min(y,Ge(l,g.host.t))),fs(c,i,f,i.dv),xs(c,f,y,i.dv)}for(let i of r.values())hs(i);for(let[i,c]of s){let l=r.get(i.track),p=Ge(l.records,i.toHost.t)-1;p<0||fs(l,i,p+1,c-l.records[p].velocity-l.increments[p])}for(let i of r.values())hs(i),i.records.forEach((c,l)=>{let p=Math.round(c.velocity+i.increments[l]+1e-9);p!==c.velocity&&(c.node.playbackState={...c.node.playbackState,velocity:p})})}from;to;dv;size;loweringEnter(e){let t=e.getTemporalNodes(this.from).at(0),n=e.getTemporalNodes(this.to).at(-1);if(!t||!n)return e.diagnostics.push(M.warning.UnresolvedEndpoint("dyn",this.sourceSpan)),[];let o=t.rootHost,r=n.rootHost;if(!_(o)||!_(r))return e.diagnostics.push(M.warning.UnresolvedEndpoint("dyn",this.sourceSpan)),[];if(o.track!==r.track)throw new w("E_DYN_CROSS_TRACK","@dyn \u7684\u4E24\u4E2A\u7AEF\u70B9\u5FC5\u987B\u4F4D\u4E8E\u540C\u4E00\u97F3\u8F68",this.sourceSpan);let s=o.t.compare(r.t);return e.addAttachment(s>0?new jt(this,r,o,!1):new jt(this,o,r,s===0)),e.deferFinalize(a.loweringFinalize),[]}constructor(e,t,n,o=null){super(e,o);let[r,s,i]=this.getArgValue(t,n),c=i;if(!Number.isFinite(c)||c===0)throw new w("E_DYN_INVALID_DELTA","@dyn \u7684 dv \u5FC5\u987B\u662F\u975E\u96F6\u6709\u9650\u6570",e);c=Math.max(-127,Math.min(127,c)),c!==i&&n.diagnostics.push(new O("W_DYN_DELTA_CLAMPED","@dyn \u7684 dv \u5FC5\u987B\u5728 -127 \u5230 127 \u4E4B\u95F4\uFF0C\u5DF2\u88AB\u9650\u5236\u4E3A {dv}",e,{dv:c})),this.from=r,this.to=s,this.dv=c,this.size=n.variables.fontsize}toString(e){let t=n=>n.label??n.toString(e);return`@dyn(${t(this.from)}, ${t(this.to)}, ${this.dv})`}},$o=Wo,jt=class{constructor(e,t,n,o){this.ast=e;this.fromHost=t;this.toHost=n;this.unordered=o}ast;fromHost;toHost;unordered;kind="dyn";layer="foreground";orient(){let e=this.fromHost.t.compare(this.toHost.t);if(e===0&&this.unordered)throw new w("E_DYN_ZERO_SPAN","@dyn \u7684\u4E24\u4E2A\u7AEF\u70B9\u5FC5\u987B\u4F4D\u4E8E\u4E0D\u540C\u65F6\u95F4",this.sourceSpan);return e>0&&([this.fromHost,this.toHost]=[this.toHost,this.fromHost]),e!==0}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(e){let t=this.fromHost.layoutLine,n=this.toHost.layoutLine,o=[this.fromHost,this.toHost],r=[],s=this.ast.size;for(let d=t;d<=n;d++){let h=e.getRangeColumns(d,o,this.track);if(h.some(y=>y.length>0)){for(let y of h)for(let g of y)s=Math.max(s,g.ast.size);r.push({line:d,startX:d===t?this.fromHost.box.x:Ce(e,d,this.track),endX:d===n?this.toHost.box.x+this.toHost.box.w:Ae(e,d)})}}for(let d of r)d.line>t&&(d.startX-=s/4);let i=Math.max(.75,s*.035),c=r.filter(d=>d.startX!==d.endX),l=c.reduce((d,h)=>d+Math.abs(h.endX-h.startX),0);if(l===0)return{regions:[],paint(){}};let p=s*.4,u=i/2,m=0,f=c.map(d=>{let h=Math.abs(d.endX-d.startX),y=m/l,g=(m+h)/l;m+=h;let x=e.getRangeExtents(d.line,o,this.track),b=e.getVisualAxis(d.line,this.track),S=x?b+x.top:b;return{line:d.line,startX:d.startX,endX:d.endX,lineY:S-s*.62,startOpen:p*(this.dv>0?y:1-y),endOpen:p*(this.dv>0?g:1-g)}});return{regions:f.map(d=>({x:Math.min(d.startX,d.endX)-u,y:d.lineY-Math.max(d.startOpen,d.endOpen)/2-u,w:Math.abs(d.endX-d.startX)+i,h:Math.max(d.startOpen,d.endOpen)+i,line:d.line,track:this.track})),paint(d){let h={stroke:"#000",strokeWidth:i};for(let y of f)d.drawLine(y.startX,y.lineY-y.startOpen/2,y.endX,y.lineY-y.endOpen/2,h),d.drawLine(y.startX,y.lineY+y.startOpen/2,y.endX,y.lineY+y.endOpen/2,h)}}}};var tt=class a{constructor(e=null){this.parent=e}parent;groups=[];group(e,t){let n=this.groups.find(o=>o.laneKey===e.laneKey);for(n||(n={laneKey:e.laneKey,members:[],measure:e.measure,place:e.place},this.groups.push(n));n.members.length<t;)n.members.push(new a(this));return n}};var Uo=.7,gs="shoulder";function bs(a,e){let t=a;typeof t.size=="number"&&(t.size*=e),typeof t.gap=="number"&&(t.gap*=e),typeof t.minGap=="number"&&(t.minGap*=e),t.aboveGaps?.forEach((n,o,r)=>r[o]*=e),t.belowGaps?.forEach((n,o,r)=>r[o]*=e);for(let n of a.children??[])bs(n,e)}var Yo=class a 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\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 P.findLabelable(this.host)}static deSugarAtom(e,t,n){let o=e[t];switch(o){case">":o="pre";break;case"<":o="post";break;default:return null}return{next:t+1,node:{kind:"sugar",data:o,span:{start:t,end:t+1},relation:a.deSugarRelation}}}static deSugarRelation(e,t,n){let o=t[n++],r=o.data,s=r==="pre"?a:void 0,i=e.takeLeftOperand(s);if(!i)throw new w("E_GRACE_NO_TARGET","@grace\u8BED\u6CD5\u7CD6\u9519\u8BEF: \u5DE6\u8FB9\u6CA1\u6709\u627E\u5230\u76EE\u6807",o.span);let c=e.variables.fontsize;return e.deferRightOperand(l=>{if(!l)throw new w("E_GRACE_NO_TARGET","@grace\u8BED\u6CD5\u7CD6\u9519\u8BEF: \u53F3\u8FB9\u6CA1\u6709\u627E\u5230\u76EE\u6807",o.span);let[p,u]=r==="pre"?[l,i]:[i,l],m=new Map([[0,p],[1,u],["side",r]]);return Object.assign(new a(o.span,m,e),{size:c})},s),n}host;grace;side="pre";size;get children(){return[this.host,this.grace]}timeFlowModel(){return null}constructor(e,t,n,o=null){if(super(e,o),this.size=n.variables.fontsize,[this.host,this.grace,this.side]=this.getArgValue(t,n),this.side!=="pre"&&this.side!=="post")throw new w("E_GRACE_INVALID_SIDE","@grace \u7684 side \u53C2\u6570\u5FC5\u987B\u662F 'pre' \u6216 'post'",e);this.adopt(this.host),this.adopt(this.grace),bs(this.grace,Uo)}adopt(e){e.parent=this,this.sourceSpan.start=Math.min(this.sourceSpan.start,e.sourceSpan.start),this.sourceSpan.end=Math.max(this.sourceSpan.end,e.sourceSpan.end)}loweringEnter(e,t){let{host:n,grace:o}=this,r=new tt(t),s=[],i=[],c=[],l=(m,f)=>e.trackedEvents(m,new I,f);e.isolateFromLoweringGroups(()=>{this.side==="post"&&(s=l(n,t).flat()),e.beginLoweringGroup(this,{onAttachment(m){c.push(m)}}),i=l(o,r),e.endLoweringGroup(this),this.side==="pre"&&(s=l(n,t).flat())});let[p]=s;if(s.length!==1||!_(p))throw new w("E_GRACE_INVALID_HOST","@grace \u7684\u5BBF\u4E3B\u5FC5\u987B\u6070\u597D\u4EA7\u751F\u4E00\u4E2A\u53EF\u89C1 Temporal",n.sourceSpan);let u=i.flat();if(!u.some(_)||u.some(m=>m.addon?.breakBefore))throw new w("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);return[new _n(this,p,i,r,c,e)]}toString(e){return`@grace(${this.host.toString(e)}, ${this.grace.toString(e)}, side=${this.side})`}},Ko=Yo,mc=[{op:"M",x:0,y:0},{op:"C",cx1:-.01,cy1:.26,cx2:.14,cy2:.42,x:.29,y:.36}],dc=.07,yc=.18,_n=class extends H{host;graceColumns;graces;root;attachments;events;starts;hostOffset={x:0,y:0};graceOffsets=[];hookOrigin=null;constructor(e,t,n,o,r,s){super(),this.ast=e,this.host=t,this.root=o,this.attachments=r,this.T.copyFrom(t.T),this.mergeKey=t.mergeKey,this.initLayoutBox(),t.addon&&(this.addon={...t.addon}),t.addon=void 0,t.foldedInto=this;let i=[],c=[],l=[];for(let m of n){let f=m[0].t.clone().divPow2(),d=[];for(let h of m)h.foldedInto=this,c.push(h),l.push(f),_(h)&&d.push(h);d.length>0&&i.push(d)}this.graceColumns=i,this.graces=i.flat(),this.events=c,this.starts=l;let p=new Map,u=[];for(let m of this.graces){if(m.T.isZero()){p.delete(m.track);continue}let f=p.get(m.track);f||(p.set(m.track,f=[]),u.push(f)),f.push(m);let d=m.addon={...m.addon};d[Gt]=(Number(d[Gt])||0)+1,m.T.divPow2()}for(let m of u)m.length>=2&&s.addAttachment(xt(m,!1,e.grace.sourceSpan))}onTimeState(e){this.host.T.copyFrom(this.T);let t,n=this.ast.side==="pre"?[...this.events,this.host]:[this.host,...this.events],o=n.indexOf(this.host);for(let[r,s]of n.entries()){s.t.copyFrom(this.t),s.layoutLine=this.layoutLine;let i=e.accidentals.at(r-o,()=>s.onTimeState?.(e));s===this.host&&(this.T.copyFrom(s.T),t=i)}return t}prepareHorizontal(e){this.host.prepareHorizontal?.(e)}emitPlayback(e){let t=new I,n=new I;this.events.forEach((u,m)=>{n.copyFrom(this.starts[m]).add(u.T),n.compare(t)>0&&t.copyFrom(n)});let o=e.end.clone().sub(e.start),r=new I(1,4),s=t.clone().mul(r),i=o.clone().divPow2();s.compare(i)>0&&(r.copyFrom(i).div(t),s.copyFrom(i));let c=o.sub(s),l=this.ast.side==="pre",p=l?e.start.clone():e.start.clone().add(c);l||e.play(this.host,e.start.clone(),c),this.events.forEach((u,m)=>{e.play(u,this.starts[m].clone().mul(r).add(p),u.T.clone().mul(r))}),l&&e.play(this.host,p.add(s),c)}prepareLayout(e){Qe(this,this.host);let t=e.layoutSubdomain(this,this.graceColumns,this.root,this.attachments),n=yt([this.host],e);this.springConfig={...this.host.springConfig};let o=this.ast.size*Uo,r=o*.2,s=o*yc,i=this.ast.side==="pre",l=(this.host.ports[gs]?.y??0)-s-t.height,p=ee(this.host),u=Math.max(0,-l,-p.y),m=i?0:n+r;this.hostOffset={x:this.host.box.x+(i?t.width+r:0),y:u},this.graceOffsets=t.positions.map(h=>({x:m+h.x,y:l+u+h.y})),this.box.w=n+r+t.width,this.box.h=u+p.y+p.h,this.box.anchor=this.hostOffset.x+this.host.box.anchor,this.box.visualAxis=u+this.host.box.visualAxis;for(let h in this.host.ports){let y=this.host.ports[h];this.ports[h]={...y,x:this.hostOffset.x+y.x,y:this.hostOffset.y+y.y}}this.ports[gs]??={x:this.box.anchor,y:this.hostOffset.y};let f=this.graces.filter(h=>!h.T.isZero()),d=i?f.at(-1):f[0];this.hookOrigin=d?{x:this.graceOffsets[this.graces.indexOf(d)].x+d.box.anchor,y:Math.max(...this.graces.map((h,y)=>this.graceOffsets[y].y+h.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((e,t)=>{e.box.x=this.box.x+this.graceOffsets[t].x,e.box.y=this.box.y+this.graceOffsets[t].y,e.onPlaced?.()})}paint(e){for(let r of[this.host,...this.graces])Fe(e,r);if(!this.hookOrigin)return;let t=this.ast.size*Uo,n=this.hookOrigin,o=this.ast.side==="pre"?1:-1;e.drawPath(mc,{stroke:"#000",strokeWidth:Math.max(.8,t*dc)},{x:this.box.x+n.x,y:this.box.y+n.y,scaleX:t*o,scaleY:t})}};function Ss(a,e,t){let n=o=>typeof o?.resolvedMidi=="number"?o:void 0;if("resolvedMidi"in e)return n(e);for(let o=a.findIndex(r=>r.includes(t))-1;o>=0;o--){let r=a[o].find(s=>s.track===t.track&&"resolvedMidi"in s);if(r)return n(r)}}var qo=class extends P{static def={name:["gliss"],description:"\u6ED1\u97F3\u8FDE\u7EBF",details:`~~~jpfun
25
27
  1 -@a 5@b @gliss(a, b)
26
28
  ~~~
27
- \u82E5\u9644\u5C5E\u5BF9\u8C61\u65E0\u97F3\u9AD8\uFF0C\u5C06\u4F7F\u7528\u524D\u9762\u6700\u8FD1\u7684\u540C\u8F68\u6709\u97F3\u9AD8\u5BF9\u8C61\u7684\u97F3\u9AD8\uFF1B\u64AD\u653E\u65F6\u4ECE\u8D77\u70B9\u97F3\u6BB5\u6309\u534A\u97F3\u9636\u79BB\u6563\u8FC7\u6E21\u81F3\u7EC8\u70B9\u97F3\u9AD8\u3002`,allowExtraArgs:!1,args:[{type:"label",default:null,description:"\u4E00\u4E2A\u7AEF\u70B9\u7684\u6807\u7B7E\uFF0C\u5148\u540E\u6309\u8C31\u9762\u65F6\u95F4\u786E\u5B9A"},{type:"label",default:null,description:"\u53E6\u4E00\u4E2A\u7AEF\u70B9\u7684\u6807\u7B7E"}]};from;to;constructor(e,t,n,o=null){super(e,o),[this.from,this.to]=this.getArgValue(t,n)}loweringEnter(e){let t=e.getTemporalNodes(this.from).at(-1),n=e.getTemporalNodes(this.to).at(-1);if(!t||!n||!M(t)||!M(n))return e.diagnostics.push(O.warning.UnresolvedEndpoint("gliss",this.sourceSpan)),[];let o=new tr(t,n,this.sourceSpan);return e.addAttachment(o),e.deferFinalize(r=>o.finalize(r),1),[]}toString(e){let t=this.from instanceof E?this.from.label:void 0,n=this.to instanceof E?this.to.label:void 0;return t&&n?`@gliss(${t}, ${n})`:e.slice(this.sourceSpan.start,this.sourceSpan.end)}},nr=er;function Nn(a,e){for(;a.foldedInto&&M(a.foldedInto)&&(!e||e.columnOf(a)<0);)a=a.foldedInto;return a}var tr=class{constructor(e,t,n){this.sourceSpan=n;this.endPoints=[e,t]}sourceSpan;kind="gliss";layer="foreground";endPoints;direction;finalize({columns:e,diagnostics:t}){let[n,o]=this.endPoints,r=Nn(n),s=Nn(o);if(r.t.equals(s.t))throw new w("E_GLISS_ORDER","@gliss \u4E24\u4E2A\u7AEF\u70B9\u4E0D\u80FD\u4F4D\u4E8E\u540C\u4E00\u65F6\u523B",this.sourceSpan);r.t.compare(s.t)>0&&(this.endPoints=[o,n],[r,s]=[s,r]);let[i,c]=this.endPoints,l=Ns(e,i,r),p=Ns(e,c,s);if(!l||!p){t.push(new I("W_GLISS_NO_PITCH","@gliss \u7AEF\u70B9\u6CA1\u6709\u53EF\u7528\u97F3\u9AD8",this.sourceSpan));return}this.direction=Math.sign(p.resolvedMidi-l.resolvedMidi);let u=i.emitPlayback,m=p.resolvedMidi+(p.playbackState?.pitchShift??0);i.emitPlayback=y=>{u?.call(i,y);let{start:d,end:g}=y;y.defer(f=>{for(let x=f.notes.length-1;x>=0;x--){let h=f.notes[x];if(h.track===y.track){if(!h.end.equals(g))return;f.transform(h,(b,S)=>{let T=S.at(-1),L=d.compare(T.start)>0?d:T.start,C=Math.abs(m-T.midi);if(T.end.compare(L)<=0||C<=1)return;let N=Math.sign(m-T.midi),P=T.end.clone().sub(L).div(C);return[...S.slice(0,-1),...Array.from({length:C},(k,B)=>({...T,start:B===0?T.start.clone():P.clone().mul(B).add(L),end:P.clone().mul(B+1).add(L),midi:T.midi+B*N}))]});return}}})}}prepareHorizontal(e){let[t,n]=this.endPoints,o=e[t.layoutLine],r=e[n.layoutLine],s=o&&Nn(t,o),i=r&&Nn(n,r),c=s?o.columnOf(s):-1,l=i?r.columnOf(i):-1;if(!o||!r||c<0||l<0||o===r&&l<=c)throw new w("E_GLISS_DOMAIN","@gliss \u7684\u7AEF\u70B9\u5FC5\u987B\u4F4D\u4E8E\u540C\u4E00\u6392\u7248\u57DF\u7684\u4E0D\u540C\u65F6\u95F4\u5217",this.sourceSpan);let p=Math.max(t.ast.size,n.ast.size)*1.4,u=s.box.w-s.box.anchor+p;if(o.registerHorizontalLayoutHook(s,s,({columns:m})=>{for(let y of m[c])y.WR=Math.max(y.WR,u)}),o!==r){let m=i.box.anchor+p;r.registerHorizontalLayoutHook(i,i,({columns:y})=>{for(let d of y[l])d.WL=Math.max(d.WL,m)})}}createGeometry(e){let[t,n]=this.endPoints,o=Math.max(t.ast.size,n.ast.size),r=o*.12,s=t.track===n.track?(this.direction??0)*o*.24:0,i={x:t.box.x+t.box.w+r,y:t.box.y+t.box.visualAxis+s},c={x:n.box.x-r,y:t.track===n.track&&this.direction===void 0&&t.layoutLine===n.layoutLine?i.y:n.box.y+n.box.visualAxis-s},l=[[i,c,t.layoutLine,t.track]];if(t.layoutLine!==n.layoutLine){let y=Math.max(i.x+o,we(e,t.layoutLine)),d=Math.min(c.x-o,Te(e,n.layoutLine,n.track,c.x)),g=y-i.x,f=s*(1-2*g/(g+c.x-d));l[0]=[i,{x:y,y:i.y-s+f},t.layoutLine,t.track],l.push([{x:d,y:c.y+s+f},c,n.layoutLine,n.track])}else if(c.x<=i.x)throw new w("E_GLISS_SPACE","@gliss \u7684\u7AEF\u70B9\u4E4B\u95F4\u6CA1\u6709\u53EF\u7528\u7684\u6C34\u5E73\u7ED8\u5236\u7A7A\u95F4",this.sourceSpan);let p=o*.05,u=[],m=l.map(([y,d,g,f],x)=>{let h=[{op:"M",...y},{op:"L",...d}];if(x===l.length-1){let S=Math.atan2(d.y-y.y,d.x-y.x),T=Math.min(o*.3,Math.hypot(d.x-y.x,d.y-y.y)*.35),L=C=>({x:d.x-T*Math.cos(S+C),y:d.y-T*Math.sin(S+C)});h.push({op:"M",...L(-Math.PI/6)},{op:"L",...d},{op:"L",...L(Math.PI/6)})}u.push(...h);let b=he(h);return{x:b.x-p/2,y:b.y-p/2,w:b.w+p,h:b.h+p,line:g,track:f}});return{regions:m,occupancy:t.track===n.track?m:[],paint:y=>{y.drawPath(u,{fill:"none",stroke:"#000",strokeWidth:p})}}}};var or=class extends E{static def={name:["slide"],description:"\u6ED1\u5165\u6216\u6ED1\u51FA\u8BB0\u53F7",details:`~~~jpfun
29
+ \u82E5\u9644\u5C5E\u5BF9\u8C61\u65E0\u97F3\u9AD8\uFF0C\u5C06\u4F7F\u7528\u524D\u9762\u6700\u8FD1\u7684\u540C\u8F68\u6709\u97F3\u9AD8\u5BF9\u8C61\u7684\u97F3\u9AD8\uFF1B\u64AD\u653E\u65F6\u4ECE\u8D77\u70B9\u97F3\u6BB5\u6309\u534A\u97F3\u9636\u79BB\u6563\u8FC7\u6E21\u81F3\u7EC8\u70B9\u97F3\u9AD8\u3002`,allowExtraArgs:!1,args:[{type:"label",default:null,description:"\u4E00\u4E2A\u7AEF\u70B9\u7684\u6807\u7B7E\uFF0C\u5148\u540E\u6309\u8C31\u9762\u65F6\u95F4\u786E\u5B9A"},{type:"label",default:null,description:"\u53E6\u4E00\u4E2A\u7AEF\u70B9\u7684\u6807\u7B7E"}]};from;to;constructor(e,t,n,o=null){super(e,o),[this.from,this.to]=this.getArgValue(t,n)}loweringEnter(e){let t=e.getTemporalNodes(this.from).at(-1),n=e.getTemporalNodes(this.to).at(-1);if(!t||!n||!_(t)||!_(n))return e.diagnostics.push(M.warning.UnresolvedEndpoint("gliss",this.sourceSpan)),[];let o=new Qo(t,n,this.sourceSpan);return e.addAttachment(o),e.deferFinalize(r=>o.finalize(r),1),[]}toString(e){let t=this.from instanceof P?this.from.label:void 0,n=this.to instanceof P?this.to.label:void 0;return t&&n?`@gliss(${t}, ${n})`:e.slice(this.sourceSpan.start,this.sourceSpan.end)}},Jo=qo;function Rn(a,e){for(;a.foldedInto&&_(a.foldedInto)&&(!e||e.columnOf(a)<0);)a=a.foldedInto;return a}function Xo(a,e,t){let n=e==="L"?"WL":"WR",o=e==="L"?"margin_L":"margin_R";t>a[n]&&(a[o]=Math.max(0,a[n]+a[o]-t),a[n]=t)}function Zo(a,e,t,n,o){o<=0||a.registerHorizontalLayoutHook(t,n,({columns:r,rows:s,start:i,end:c,X:l,fixed:p})=>{let u=0;for(;u<s&&r[i][u].time.track!==e;)u++;if(u>=s)return;let m=o,f=0,d=new Float64Array(c-i);for(let y=i;y<c;y++){if(p[y]){m-=l[y+1]-l[y];continue}let g=0;for(let x=0;x<s;x++){let b=r[y][x],S=r[y+1][x];g=Math.max(g,b.WR+b.margin_R+S.WL+S.margin_L)}d[y-i]=g,f+=g}if(m<=0)return;if(f<=0){for(let y=i;y<c;y++)if(!p[y]){Xo(r[y][u],"R",m);break}return}let h=m/f;for(let y=i;y<c;y++){if(p[y])continue;let g=r[y][u],x=r[y+1][u],b=d[y-i]*h,S=g.WR+g.margin_R,T=S+x.WL+x.margin_L,L=T>0?b*(S/T):b/2;Xo(g,"R",L),Xo(x,"L",b-L)}})}var Qo=class{constructor(e,t,n){this.sourceSpan=n;this.endPoints=[e,t]}sourceSpan;kind="gliss";layer="foreground";endPoints;direction;finalize({columns:e,diagnostics:t}){let[n,o]=this.endPoints,r=Rn(n),s=Rn(o);if(r.t.equals(s.t))throw new w("E_GLISS_ORDER","@gliss \u4E24\u4E2A\u7AEF\u70B9\u4E0D\u80FD\u4F4D\u4E8E\u540C\u4E00\u65F6\u523B",this.sourceSpan);r.t.compare(s.t)>0&&(this.endPoints=[o,n],[r,s]=[s,r]);let[i,c]=this.endPoints,l=Ss(e,i,r),p=Ss(e,c,s);if(!l||!p){t.push(new O("W_GLISS_NO_PITCH","@gliss \u7AEF\u70B9\u6CA1\u6709\u53EF\u7528\u97F3\u9AD8",this.sourceSpan));return}this.direction=Math.sign(p.resolvedMidi-l.resolvedMidi);let u=i.emitPlayback,m=p.resolvedMidi+(p.playbackState?.pitchShift??0);i.emitPlayback=f=>{u?.call(i,f);let{start:d,end:h}=f;f.defer(y=>{for(let g=y.notes.length-1;g>=0;g--){let x=y.notes[g];if(x.track===f.track){if(!x.end.equals(h))return;y.transform(x,(b,S)=>{let T=S.at(-1),L=d.compare(T.start)>0?d:T.start,C=Math.abs(m-T.midi);if(T.end.compare(L)<=0||C<=1)return;let A=Math.sign(m-T.midi),v=T.end.clone().sub(L).div(C);return[...S.slice(0,-1),...Array.from({length:C},(N,F)=>({...T,start:F===0?T.start.clone():v.clone().mul(F).add(L),end:v.clone().mul(F+1).add(L),midi:T.midi+F*A}))]});return}}})}}prepareHorizontal(e){let[t,n]=this.endPoints,o=e[t.layoutLine],r=e[n.layoutLine],s=o&&Rn(t,o),i=r&&Rn(n,r),c=s?o.columnOf(s):-1,l=i?r.columnOf(i):-1;if(!o||!r||c<0||l<0||o===r&&l<=c)throw new w("E_GLISS_DOMAIN","@gliss \u7684\u7AEF\u70B9\u5FC5\u987B\u4F4D\u4E8E\u540C\u4E00\u6392\u7248\u57DF\u7684\u4E0D\u540C\u65F6\u95F4\u5217",this.sourceSpan);let p=Math.max(t.ast.size,n.ast.size)*1.4,u=s.box.w-s.box.anchor+p;if(o===r){Zo(o,s.track,s,i,u+i.box.anchor);return}let m=o.columns.length-1;if(c<m){let h=Math.max(...o.columns[m].map(y=>y.box.w-y.box.anchor));Zo(o,s.track,s,o.columns[m][0],u-h)}else o.registerHorizontalLayoutHook(s,s,({columns:h})=>{for(let y of h[c])y.WR=Math.max(y.WR,u)});let f=i.box.anchor+p,d=r.trackRuns.get(n.track)?.find(h=>!h.T.isZero());d&&r.columnOf(d)<l?Zo(r,i.track,d,i,f-d.box.anchor):r.registerHorizontalLayoutHook(i,i,({columns:h})=>{for(let y of h[l])y.WL=Math.max(y.WL,f)})}createGeometry(e){let[t,n]=this.endPoints,o=Math.max(t.ast.size,n.ast.size),r=o*.12,s=t.track===n.track?(this.direction??0)*o*.24:0,i={x:t.box.x+t.box.w+r,y:t.box.y+t.box.visualAxis+s},c={x:n.box.x-r,y:t.track===n.track&&this.direction===void 0&&t.layoutLine===n.layoutLine?i.y:n.box.y+n.box.visualAxis-s},l=[[i,c,t.layoutLine,t.track]];if(t.layoutLine!==n.layoutLine){let f=Math.max(i.x+o,Ae(e,t.layoutLine)),d=Math.min(c.x-o,Ce(e,n.layoutLine,n.track,c.x)),h=f-i.x,y=s*(1-2*h/(h+c.x-d));l[0]=[i,{x:f,y:i.y-s+y},t.layoutLine,t.track],l.push([{x:d,y:c.y+s+y},c,n.layoutLine,n.track])}else if(c.x<=i.x)throw new w("E_GLISS_SPACE","@gliss \u7684\u7AEF\u70B9\u4E4B\u95F4\u6CA1\u6709\u53EF\u7528\u7684\u6C34\u5E73\u7ED8\u5236\u7A7A\u95F4",this.sourceSpan);let p=o*.05,u=[],m=l.map(([f,d,h,y],g)=>{let x=[{op:"M",...f},{op:"L",...d}];if(g===l.length-1){let S=Math.atan2(d.y-f.y,d.x-f.x),T=Math.min(o*.3,Math.hypot(d.x-f.x,d.y-f.y)*.35),L=C=>({x:d.x-T*Math.cos(S+C),y:d.y-T*Math.sin(S+C)});x.push({op:"M",...L(-Math.PI/6)},{op:"L",...d},{op:"L",...L(Math.PI/6)})}u.push(...x);let b=Se(x);return{x:b.x-p/2,y:b.y-p/2,w:b.w+p,h:b.h+p,line:h,track:y}});return{regions:m,occupancy:t.track===n.track?m:[],paint:f=>{f.drawPath(u,{fill:"none",stroke:"#000",strokeWidth:p})}}}};var er=class extends P{static def={name:["slide"],description:"\u6ED1\u5165\u6216\u6ED1\u51FA\u8BB0\u53F7",details:`~~~jpfun
28
30
  @slide(5, side=pre, direction=up)
29
31
  ~~~
30
- \u4EC5\u7ED8\u5236\uFF0C\u4E0D\u6539\u53D8\u65F6\u503C\u548C\u64AD\u653E\u3002pre \u4FEE\u9970\u5185\u5BB9\u9996\u7AEF\uFF0Cpost \u4FEE\u9970\u672B\u7AEF\uFF1Bup/down \u8868\u793A\u968F\u65F6\u95F4\u4E0A\u884C/\u4E0B\u884C\u3002`,allowExtraArgs:!1,args:[{type:"content",default:null,description:"\u88AB\u4FEE\u9970\u7684\u5185\u5BB9"},{name:"side",type:"string",default:"pre",description:"pre \u6ED1\u5165\uFF0Cpost \u6ED1\u51FA"},{name:"direction",type:"string",default:"up",description:"up \u4E0A\u884C\uFF0Cdown \u4E0B\u884C"}]};content;side;direction;get children(){return[this.content]}labelable(){return E.findLabelable(this.content)}constructor(e,t,n,o=null){super(e,o);let[r,s,i]=this.getArgValue(t,n);if(s!=="pre"&&s!=="post")throw new w("E_SLIDE_SIDE","@slide \u7684 side \u5FC5\u987B\u662F pre \u6216 post",e);if(i!=="up"&&i!=="down")throw new w("E_SLIDE_DIRECTION","@slide \u7684 direction \u5FC5\u987B\u662F up \u6216 down",e);this.content=r,this.side=s,this.direction=i,r.parent=this}loweringEnter(e){let t=this.side==="pre",n={onTemporal(o){M(o)&&(!t||!n.host)&&(n.host=o)}};return e.beginLoweringGroup(this,n),[]}loweringExit(e){let{host:t}=e.endLoweringGroup(this);if(!t)throw new w("E_SLIDE_CONTENT","@slide \u7684\u5185\u5BB9\u5FC5\u987B\u5305\u542B\u53EF\u7ED8\u5236\u5BF9\u8C61",this.sourceSpan);let n=new rr(t,this);e.addAttachment(n);let o=t.prepareHorizontal;return t.prepareHorizontal=r=>{o?.call(t,r),!(r.columnOf(t)<0)&&r.registerHorizontalLayoutHook(t,t,({columns:s,start:i})=>{let c=this.side==="pre",l=c?"WL":"WR",u=(c?t.box.anchor:t.box.w-t.box.anchor)+n.length+t.ast.size*.22;for(let m of s[i])m.box===t.box&&(m[l]=Math.max(m[l],u))})},[]}toString(e){return`@slide(${this.content.toString(e)}, side=${this.side}, direction=${this.direction})`}},ar=or,rr=class{constructor(e,t){this.host=e;this.owner=t;this.endPoints=[e]}host;owner;kind="slide";layer="foreground";endPoints;get sourceSpan(){return this.owner.sourceSpan}get length(){let{host:e}=this;return e.box.visualAxis-(e.ports.shoulder?.y??0)+e.ast.size*.1}createGeometry(){let{host:e,owner:t}=this,n=e.ast.size,o=t.side==="pre",r=this.length,s=t.direction==="up",i=e.box.y+e.box.visualAxis,c=o?e.box.x-n*.12-r:e.box.x+e.box.w+n*.12,l={x:c,y:s?i:i-r},p={x:c+r,y:s?i-r:i},u=s?-Math.PI/4:Math.PI/4,m=x=>({x:p.x-n*.25*Math.cos(u+x),y:p.y-n*.25*Math.sin(u+x)}),y=[{op:"M",...l},{op:"L",...p},{op:"M",...m(-Math.PI/6)},{op:"L",...p},{op:"L",...m(Math.PI/6)}],d=n*.05,g=he(y);return{regions:[{x:g.x-d/2,y:g.y-d/2,w:g.w+d,h:g.h+d,line:e.layoutLine,track:e.track}],paint(x){x.drawPath(y,{fill:"none",stroke:"#000",strokeWidth:d})}}}};var xt="sans-serif",gt="Arial, 'Century Schoolbook', 'Palatino Linotype', Cambria, 'Cascadia Mono', monospace";function Fe(a,e,t){let n=a.at(-1);n&&n.mask===t?n.text+=e:a.push({text:e,mask:t})}function zt(a,e,t="\\*_^"){let n=0;for(let o=0;o<a.length;o++){let r=o,s=String.fromCodePoint(a.codePointAt(o));if(o+=s.length-1,s==="\\"&&o+1<a.length&&t.includes(a[o+1])){e(a[++o],n,!0,r,o+1);continue}if(s==="*"){n^=a[o+1]==="*"?(o++,1):2;continue}if(s==="_"){n^=4;continue}if(s==="^"){n^=8;continue}e(s,n,!1,r,o+1)}}function ir(a){let e=[[]];return zt(a,(t,n)=>{t===`
31
- `?e.push([]):Fe(e.at(-1),t,n)}),e}function vn(a){return(a&1?"**":"")+(a&2?"*":"")+(a&4?"_":"")+(a&8?"^":"")}var Ki=.7,Ui=.35;function ke(a,e,t){let n=[];typeof a=="string"?zt(a,(c,l)=>Fe(n,c,l)):n.push(...a);let o=0,r,s=n.length>1&&e.textAlign&&e.textAlign!=="left",i=n.map(c=>{let l=!s&&(c.mask&11)===0?e:{...e,...s?{textAlign:"left"}:{},...c.mask&8?{fontSize:e.fontSize*Ki}:{},...c.mask&1?{fontWeight:"bold"}:{},...c.mask&2?{fontStyle:"italic"}:{}},p=t.measureText(c.text,l);return(c.mask&8)===0&&(r??=p),o+=p.w,{...c,style:l,w:p.w}});return r??=t.measureText("",e),{runs:i,style:e,w:n.length?o:r.w,h:r.h,baseline:r.baseline}}function Be(a,e,t,n){let{runs:o,style:r,w:s}=e,{textAlign:i}=r,c=i==="center"?t-s/2:i==="right"?t-s:t,l=u=>u&8?n-r.fontSize*Ui:n,p=c;for(let u of o)a.drawText(u.text,o.length===1?t:p,l(u.mask),u.style),p+=u.w;for(let u=0,m=c;u<o.length;){let{mask:y,style:d,w:g}=o[u++];if(!(y&4)){m+=g;continue}let f=m+g;for(;u<o.length&&(o[u].mask&12)===(y&12);)f+=o[u++].w;let x=Math.max(1,d.fontSize*.06),h=l(y)+d.fontSize*.12;a.drawRect(m,h-x/2,f-m,x,{fill:r.fill??"#000"}),m=f}}function Pn(a){return`${a.fontStyle?`${a.fontStyle} `:""}${a.fontWeight??"normal"} ${a.fontSize}px ${a.fontFamily??xt}`}var kn=class{measureText(e,t){let n=t.fontSize,o=t.fontFamily?.toLowerCase().includes("mono")??!1,r=0;for(let s of e)r+=s.charCodeAt(0)>127?1:o?.62:.58;return{w:Math.max(r*n,n*.25),h:n,baseline:n*.8}}},cr=new kn,sr=class{constructor(e){this.context=e}context;widths=new Map;clearCache(){this.widths.clear()}measureText(e,t){let n=Pn(t),o=`${n}\0${e}`,r=this.widths.get(o);return r===void 0&&(this.context.font=n,r=this.context.measureText(e).width,this.widths.set(o,r)),{w:Math.max(r,t.fontSize*.25),h:t.fontSize,baseline:t.fontSize*.8}}};function ae(a,e,t){for(let n=e+1;n<t;n++)if(a[n]==="\\")n++;else if(a[n]==='"')return n;return-1}function jt(a){let e=a.length>=2&&a.startsWith('"')&&a.endsWith('"'),t=e?a.slice(1,-1):a,n,o=t.replace(/\\(u.{0,4}|.)/gs,(r,s,i)=>{if(s==='"'||s==="\\")return s;if(s[0]!=="u")return r;if(!/^u[0-9a-f]{4}$/i.test(s)){let c=i+(e?1:0);return n??=O.warning.InvalidUnicodeEscape({start:c,end:c+r.length}),r}return String.fromCharCode(Number.parseInt(s.slice(1),16))});return n??o}function ee(a){return`"${a.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}var lr=10,pr=13,Xi=9,Zi=11,qi=12,Qi=32,Ji=160,ec=5760,tc=8239,nc=8287,oc=12288,rc=65279,ac=34,ks=92,sc=37,ic=32,cc=[];function lc(a){return a>ic?" ".repeat(a):cc[a]??=" ".repeat(a)}function bt(a){return a===Qi||a===Xi||a===Zi||a===qi?!0:a<128?!1:a===Ji||a===ec||a>=8192&&a<=8202||a===tc||a===nc||a===oc||a===rc}function St(a){let e=a.length,t=[0],n=[],o=[],r=(f,x)=>{if(f>=x)return;let h=o.length;if(h>=2&&f<=o[h-1]){x>o[h-1]&&(o[h-1]=x);return}o.push(f,x)},s=(f,x)=>{if(x<=0)return;let h=f+x;for(let b=f;b<h;b+=2)r(b,b+1)},i=0,c=!1,l=!1,p=-1,u=-1,m=0,y=(f,x)=>{if(x===ks){m>0&&u+m===f?m++:(u=f,m=1);return}u=-1,m=0};for(let f=0;f<e;){let x=a.charCodeAt(f);if(x===pr||x===lr){let h=x===pr&&f+1<e&&a.charCodeAt(f+1)===lr?2:1;t.push(f+h);let b=(m&1)===1;s(u,m),p>=0&&(r(p,f),n.push({start:p,end:f}),p=-1),b?r(f,f+h):i===0&&h===2&&r(f,f+1),u=-1,m=0,l=!1,f+=h;continue}if(i!==0){l?l=!1:x===ks?l=!0:x===i&&(i=0),bt(x)||y(f,x),f++;continue}if(x===ac){c||(ae(a,f,e)<0?c=!0:i=x),y(f,x),f++;continue}if(x===sc){for(p=f,f++;f<e;){let h=a.charCodeAt(f);if(h===pr||h===lr)break;f++}continue}bt(x)||y(f,x),f++}if(s(u,m),p>=0&&(r(p,e),n.push({start:p,end:e})),o.length===0)return{maskedSource:a,lineStarts:t,commentSpans:n};let d=[],g=0;for(let f=0;f<o.length;f+=2){let x=o[f],h=o[f+1];g<x&&d.push(a.slice(g,x)),d.push(lc(h-x)),g=h}return g<e&&d.push(a.slice(g)),{maskedSource:d.join(""),lineStarts:t,commentSpans:n}}var pc=/[A-Za-z0-9_./-]/;function Tt(a,e,t){let n=e+1;for(;n<t&&pc.test(a[n]);)n++;let o=a.slice(e+1,n);if(!o||n>=t||a[n]!=="(")return null;let r=n,s=1,i=0,c=[],l=r+1,p=-1,u=(y,d,g=!1)=>{let f=ze(a,l,y);if(!g&&f.start>=f.end)return;let x=p>f.start?ze(a,f.start,p):void 0,h=p>f.start?ze(a,p+1,f.end):f;c.push({span:f,valueSpan:h,nameSpan:x,equalsSpan:p>f.start?{start:p,end:p+1}:void 0,commaSpan:d===void 0?void 0:{start:d,end:d+1}})},m=(y,d)=>({name:o,span:{start:e,end:y},nameSpan:{start:e,end:r},openParenSpan:{start:r,end:r+1},closeParenSpan:d,args:c});for(n++;n<t;n++){let y=a[n];if(y==='"'){if(n=ae(a,n,t),n<0)break}else if(y==="{")i++;else if(y==="}")i=Math.max(0,i-1);else if(y==="("&&i===0)s++;else if(y===")"&&i===0){if(--s)continue;return u(n),m(n+1,{start:n,end:n+1})}else y===","&&s===1&&i===0?(u(n,n,!0),l=n+1,p=-1):y==="="&&p===-1&&s===1&&i===0&&(p=n)}return u(t),m(t)}function wt(a,e){let t=e?.nameSpan;return t&&a.slice(t.start,t.end).toLowerCase()}var vs=/\s/;function ze(a,e,t){let n=e,o=t;for(;n<o&&vs.test(a[n]);)n+=1;for(;o>n&&vs.test(a[o-1]);)o-=1;return{start:n,end:o}}function ur(a,e,t){let n=1;for(let o=e;o<t;o++){let r=a[o];if(r==='"'){if(o=ae(a,o,t),o<0)break}else if(r==="(")n++;else if(r===")"&&--n===0)return o}return-1}function mr(a,e,t){let n=1;for(let o=e+1;o<t;o++){let r=a[o];if(r==='"'){if(o=ae(a,o,t),o<0)break}else if(r==="{")n++;else if(r==="}"&&--n===0)return o}return-1}var uc=/\s|\(|\)|\{|\}|,/;function dr(a,e,t){let n=e+1;for(;n<t&&!uc.test(a[n]);)n++;return n<=e+1?null:{label:a.slice(e+1,n),next:n}}var mc=/^(-?(?:\d+(?:\.\d*)?|\.\d+))([a-z%]+)?$/i,dc=["em","px"];function En(a){let e=a.match(mc);if(!e)return O.warning.InvalidLength(a,{start:0,end:a.length});let t=parseFloat(e[1]);if(!Number.isFinite(t))return O.warning.InvalidLength(a,{start:0,end:a.length});if(e[2]){let n=e[2].toLowerCase();return dc.includes(n)?{value:t,unit:n}:O.warning.InvalidLengthUnit(n,{start:e[1].length,end:a.length})}else return{value:t,unit:"px"}}var Ps=/^(true|false)$/;function yc(a,e){if(a)return a==="content"?void 0:a;if(Ps.test(e))return"boolean";if(e.startsWith('"'))return"string";if(!isNaN(Number(e)))return"number";if(!(En(e)instanceof O))return"length"}var yr=18,fc=700,le=class a{static systemVariables={fontsize:{type:"length",default:yr,description:"\u57FA\u51C6\u5B57\u53F7\uFF0C\u4E5F\u662F `em` \u957F\u5EA6\u7684\u6362\u7B97\u57FA\u51C6"},font:{type:"string",default:xt,description:"\u666E\u901A\u6587\u5B57\u5B57\u4F53"},numberfont:{type:"string",default:gt,description:"\u97F3\u7B26\u53CA\u540C\u7C7B\u8C31\u9762\u6570\u5B57\u5B57\u4F53"},numberweight:{type:"number",default:fc,description:"\u4E3B\u8C31\u9762\u6570\u5B57\u5B57\u91CD\uFF0C\u4EC5\u63A7\u5236 `note`\u3001`meter`\u3001`rest`"},strict:{type:"boolean",default:!1,description:"\u5F00\u542F\u4E25\u683C\u7684\u8BED\u6CD5\u68C0\u67E5"}};scopeDepth;source;syntax;commentIndex;diagnostics;variables;documentDeclarations;functions;deSugarAtomFns;deSugarRelationFns;labelableNodes;callNode;nodes;constructor(e){e instanceof a?(this.scopeDepth=e.scopeDepth+1,this.documentDeclarations=e.documentDeclarations,this.source=e.source,this.diagnostics=e.diagnostics,this.syntax=e.syntax,this.commentIndex=e.commentIndex,this.variables={...e.variables},this.functions=e.functions,this.deSugarAtomFns=e.deSugarAtomFns,this.deSugarRelationFns=e.deSugarRelationFns,this.labelableNodes=e.labelableNodes,this.nodes=[]):(this.scopeDepth=0,this.documentDeclarations={},this.source=e.source,this.diagnostics=e.diagnostics??[],this.syntax={tokens:(e.commentSpans??[]).map(t=>({kind:"comment",span:t})),calls:[]},this.commentIndex=0,this.variables=Object.fromEntries(Object.entries(a.systemVariables).map(([t,n])=>[t,n.default])),Object.assign(this.variables,e.variables),this.functions=e.functions??new Map,this.labelableNodes=e.labelableNodes??[],this.nodes=e.toConsume??[],e.functions?[this.deSugarAtomFns,this.deSugarRelationFns]=a.getDeSugarFns(this.functions.values()):(this.deSugarAtomFns=[],this.deSugarRelationFns=[]))}static getDeSugarFns(e){let t=new Set(e),n=[],o=[];for(let r of t){let s=r.deSugarAtom;s&&s!==E.deSugarAtom&&n.push(s);let i=r.deSugarRelation;i&&i!==E.deSugarRelation&&o.push(i)}return[n,o]}pushNode(e){this.nodes.push(e);let t=e.labelable?.();t!==void 0&&this.labelableNodes.push(t)}setVariable(e,t){Object.hasOwn(a.systemVariables,e)&&(e==="fontsize"&&t&&(t=this.length2px(t)),(t===void 0||t===""||t===0)&&(t=a.systemVariables[e].default)),this.variables[e]=t}registerFunctions(e){let t=this.functions;for(let n of e){let o=n.def;if(!o)continue;let r=Array.isArray(o.name)?o.name:[o.name];for(let s of r){if(t.has(s.toLowerCase()))throw new Error(`Duplicate function name detected: ${s}`);t.set(s.toLowerCase(),n)}}[this.deSugarAtomFns,this.deSugarRelationFns]=a.getDeSugarFns(this.functions.values())}parse(e=0,t=this.source.length){return this.makeNodes(this.parseGrammar(e,t)),this.nodes}parseSyntax(e=0,t=this.source.length){if(this.parseGrammar(e,t,!0),this.scopeDepth===0){let n=(o,r)=>o.span.start-r.span.start||o.span.end-r.span.end;this.syntax.tokens.sort(n),this.syntax.calls.sort(n)}return this.syntax}addSyntax(e,t){if(!t||t.start>=t.end)return;let n=t.start,o=this.syntax.tokens;for(;o[this.commentIndex]?.kind==="comment"&&o[this.commentIndex].span.end<=n;)this.commentIndex++;for(let r=this.commentIndex;r<o.length;r++){let s=o[r];if(s.kind!=="comment"||s.span.start>=t.end)break;n<s.span.start&&o.push({kind:e,span:{start:n,end:s.span.start}}),n=s.span.end,this.commentIndex=r+1}n<t.end&&o.push({kind:e,span:{start:n,end:t.end}})}recordSyntax(e){if(e.kind==="brace"){this.addSyntax("punctuation",{start:e.span.start,end:e.span.start+1});let i=Math.min(this.source.length,e.span.end-1);new a(this).parseSyntax(e.span.start+1,i),this.source[i]==="}"&&this.addSyntax("punctuation",{start:i,end:i+1});return}if(e.kind==="label"){this.addSyntax("label",e.span);return}if(e.kind==="sugar"||e.typed){if(Array.isArray(e.syntaxKind))for(let i of e.syntaxKind)this.addSyntax(i.kind,i.span);else this.addSyntax(e.syntaxKind??"operator",e.span);return}let{kind:t,typed:n,syntaxKind:o,...r}=e;this.syntax.calls.push(r),this.addSyntax("function",r.nameSpan),this.addSyntax("punctuation",r.openParenSpan);let s=this.functions.get(r.name.toLowerCase())?.def;for(let i=0;i<r.args.length;i++){let c=r.args[i];this.addSyntax("property",c.nameSpan),this.addSyntax("punctuation",c.equalsSpan);let l=s&&ct(s,wt(this.source,c),i);if(l==="content")new a(this).parseSyntax(c.valueSpan.start,c.valueSpan.end);else{let p=this.source.slice(c.valueSpan.start,c.valueSpan.end),u=yc(l,p);u&&this.addSyntax(u,c.valueSpan)}this.addSyntax("punctuation",c.commaSpan)}this.addSyntax("punctuation",r.closeParenSpan)}findLastOperandIndex(){let e=this.nodes.length-1;for(;e>=0&&this.nodes[e]instanceof pe;)e--;if(e<0)return-1;let t=this.nodes[e];if(t instanceof it){let n=t.target;for(;n.parent;)n=n.parent;let o=this.nodes.lastIndexOf(n,e-1);return o<0?-1:(this.nodes.splice(o,e-o+1,new re({start:n.sourceSpan.start,end:t.sourceSpan.end},this.nodes.slice(o,e+1),null)),o)}return e}takeLeftOperand(){let e=this.findLastOperandIndex();if(e<0)return null;let t=this.nodes[e];return this.nodes.length=e,t}consumeRightOperand(e,t,n){let o=this.nodes;this.nodes=[];try{this.makeNodes(e,t);for(let r=0;r<this.nodes.length;r++){let s=this.nodes[r];if(!(s instanceof pe)){for(o.push(n(s));++r<this.nodes.length;)o.push(this.nodes[r]);return e.length}}return null}finally{this.nodes=o}}makeNodes(e,t=0,n=e.length){e:for(;t<n;t++){let o=e[t];if(typeof o=="number"){this.pushText(o,o+1);continue}switch(o.kind){case"call":this.pushNode(this.parseCallNode(o));break;case"brace":let r=new a(this);this.nodes.push(new re(o.span,r.parse(o.span.start+1,o.span.end-1),null));break;case"label":let s=this.labelableNodes.at(-1);s?s.label!==void 0?this.diagnostics.push(O.warning.TargetAlreadyLabeled(o.label,s.label,o.span)):(s.label=o.label,this.nodes.push(new it(o.span,o.label,s))):this.diagnostics.push(O.warning.LabelWithoutTarget(o.label,o.span));break;case"sugar":for(let i of this.deSugarRelationFns){let c=i(this,e,t);if(c!==null){t=c-1;continue e}}this.pushText(o.span.start,o.span.end);break}}return t}pushText(e,t){let n=this.nodes.at(-1);n instanceof pe&&n.sourceSpan.end===e?n.sourceSpan.end=t:this.nodes.push(new pe({start:e,end:t},null))}parseGrammar(e,t,n=!1){let o=[],r=s=>{o.push(s),n&&this.recordSyntax(s)};e:for(;(e=Pe(this.source,e,t))<t;){let s=this.source[e];if(s==="@"){let i=Tt(this.source,e,t);if(i){r(Object.assign(i,{kind:"call",typed:!1}));let l=!1;for(let p of i.args){let u=p.nameSpan!==void 0;if(u&&!l)l=!0;else if(!u&&l){let m=O.error.PosAfterNamedArg(i.name,p.span);if(!n)throw m;this.diagnostics.push(m)}}if(!i.closeParenSpan){let p=O.error.UnterminatedCall(i.name,i.span);if(!n)throw p;this.diagnostics.push(p)}e=i.span.end;continue}let c=dr(this.source,e,t);if(c){r({kind:"label",span:{start:e,end:c.next},label:c.label}),e=c.next;continue}}if(s==="{"){let i=mr(this.source,e,t);i<0&&(this.diagnostics.push(O.warning.UnmatchedBrace({start:e,end:t})),i=t),r({kind:"brace",span:{start:e,end:i+1}}),e=i+1;continue}for(let i of this.deSugarAtomFns)try{let c=i(this.source,e,t,this.scopeDepth);if(c){r(c.node),e=c.next;continue e}}catch(c){throw c instanceof O||this.diagnostics.push(O.error.Bug(c.toString(),{start:e,end:t})),c}o.push(e++)}return o}parseCallNode(e){let t=this.functions.get(e.name.toLowerCase()),n=t?.def;if(!t||!n){if(this.variables.strict)throw O.error.UnknownFunction(e.name,e.span);return this.diagnostics.push(O.warning.UnknownFunction(e.name,e.span)),new E(e.span,null)}let o=n.args;if(!e.typed){let r=new Map;for(let s=0;s<e.args.length;s++){let i=e.args[s],c=wt(this.source,i),l=ct(n,c,s),p=c??s;if(l===void 0){n.allowExtraArgs?r.set(p,i):this.diagnostics.push(O.warning.TooManyPosArgs(e.name,o.filter(m=>!m.namedOnly).length,s+1,i.valueSpan));continue}let u=this.parseArgWithType(i.valueSpan,l,e.span.start);u!==null&&r.set(p,u)}return this.callNode=e,new t(e.span,r,this,null)}return this.callNode=void 0,new t(e.span,e.args,this,null)}parseArgWithType(e,t,n){let o=ze(this.source,e.start,e.end),r=o.start,s=o.end;if(r>=s)return null;let i=t==="content"?"":this.source.slice(r,s);switch(t){case"number":let c=Number(i);return Number.isFinite(c)?c:(this.diagnostics.push(O.warning.InvalidNumber(i,o)),null);case"boolean":return Ps.test(i)?i==="true":(this.diagnostics.push(O.warning.InvalidBoolean(i,o)),null);case"content":{let u=this.labelableNodes,m=u.length,y=u.at(-1),d=y?.label,g=y&&Object.hasOwn(y,"label");try{let x=new a(this).parse(r,s);return x.length===1?x[0]:new re(o,x,null)}catch(f){if(u.length=m,y&&(g?y.label=d:delete y.label),this.variables.strict||!(f instanceof O))throw f;return this.diagnostics.push(f,O.warning.InvalidContent(o)),null}}case"label":n??=e.start;for(let u=this.labelableNodes.length-1;u>=0;u--){let m=this.labelableNodes[u];if(m&&!(m.sourceSpan.start>=n)&&m.label==i)return m}throw O.error.UnknownLabel(i,o);case"length":let l=En(i);return l instanceof O?(l.span.start+=r,l.span.end+=r,this.diagnostics.push(l),null):l;default:let p=jt(i);return p instanceof O?(p.span.start+=r,p.span.end+=r,this.diagnostics.push(p),i.length>=2&&i.startsWith('"')&&i.endsWith('"')?i.slice(1,-1):i):p}}length2px(e){return e.unit==="em"?e.value*this.variables.fontsize:e.value}};function Pe(a,e,t){for(;e<t&&bt(a.charCodeAt(e));)e++;return e}function Lt(a,e,t=0){for(;e>=t&&bt(a.charCodeAt(e));)e--;return e}function hc(a){return a>="A"&&a<="G"||a==="X"||a==="Z"}function _n(a){return a>="0"&&a<="9"}function Ms(a){return a==="#"||a==="b"||a==="n"}function fr(a,e,t){for(;e<t&&Ms(a[e]);)e++;return e}function Es(a,e,t){let n=fr(a,e,t);return n>e&&!_n(a[n]??"")?a.slice(e,n):null}function _s(a,e,t){e<t&&(a[e]==="+"||a[e]==="-")&&e++;let n=e;for(;e<t&&_n(a[e]);)e++;return e>n?e:-1}function Rs(a,e,t,n,o){let r=0,s=e;for(;s<t&&(a[s]===","||a[s]==="'");)r+=a[s++]==="'"?1:-1;return{name:n,next:s,acc:o,octave:s>e?r:null,absOctave:!1}}function je(a,e=0,t=a.length,n=!0){if(t-e===0)return n?new w("E_WRONG_NOTE_NAME",'\u51FD\u6570 @note \u7684\u53C2\u6570 [0]:"name" \u4E0D\u80FD\u4E3A\u7A7A',{start:e,end:t}):null;let o=a[e];if(hc(o)){let r=e+1,s=null,i=null,c=_s(a,r,t);if(c>0)i=parseInt(a.slice(r,c),10),r=c,s=Es(a,r,t),s&&(r+=s.length);else{let l=fr(a,r,t);if(l>r){s=a.slice(r,l);let p=_s(a,l,t);p>0?(i=parseInt(a.slice(l,p),10),r=p):r=l}}return{name:o,next:r,acc:s,octave:i,absOctave:!0}}if(_n(o)){let r=Es(a,e+1,t);return Rs(a,e+1+(r?r.length:0),t,o,r)}if(Ms(o)){let r=fr(a,e,t);if(r>=t)return n?new w("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:e,end:t}):null;let s=a[r];return _n(s)?Rs(a,r+1,t,s,a.slice(e,r)):n?new w("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 "{ch}"',{start:r,end:r+1},{ch:s}):null}return n?new w("E_WRONG_NOTE_NAME",'\u51FD\u6570 @note \u7684\u53C2\u6570 [0]:"name" \u683C\u5F0F\u9519\u8BEF: \u9996\u5B57\u7B26 "{ch}" \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:e,end:e+1},{ch:o}):null}var Wt=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],$t=["C","Db","D","Eb","E","F","Gb","G","Ab","A","Bb","B"],Le="CDEFGAB",$e={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},hr=[0,2,4,5,7,9,11];function Ct(a){let e=a[0];if(!e||e<"A"||e>"G")return null;let t="",n=1;n<a.length&&(a[n]==="#"||a[n]==="b")&&(t=a[n],n++);let o=$e[e+t];if(o===void 0)return null;let r=a.slice(n),s=Number(r);return!/^-?\d+$/.test(r)||!Number.isSafeInteger(s)?null:(s+1)*12+o}function Rn(a,e=!0,t=0){for(let n of a)n==="#"?t++:n==="b"?t--:n==="n"&&!e&&(t=0);return t}function Mn(a,e,t,n){let o=$e[a];if(o===void 0)return null;let r=Rn(e);return a>="1"&&a<="7"?Ct(n)+o+r+t*12:(t+1)*12+o+r}function xr(a,e,t){if(a<"1"||a>"7")return;let n=Ct(t),o=e*7+Number(a)-1;return r=>{let s=o+r,i=Math.floor(s/7);return n+hr[(s%7+7)%7]+i*12}}function We(a){return(a%12+12)%12}function Fn(a){let e=We(a);return e>6?e-12:e}function Bn(a){return a<0?"b".repeat(-a):"#".repeat(a)}function Yt(a,e,t,n){let o=Le.indexOf(n[0]),r=Le.indexOf(a),s=Mn(a,e,t,n);if(o<0||r<0||s===null)return null;let i=Ct(n),c=(r-o+Le.length)%Le.length,l=We(i+hr[c]),p=Fn(We(s)-l),u=(s-i-hr[c]-p)/12;return{renderName:String(c+1),renderAcc:Bn(p),renderOctave:u}}var xc={"#":{w:.42,h:.82,baseline:.67,fill:!0,commands:[{op:"M",x:.22,y:.07},{op:"L",x:.35,y:.07},{op:"L",x:.35,y:1},{op:"L",x:.22,y:1},{op:"Z"},{op:"M",x:.65,y:0},{op:"L",x:.78,y:0},{op:"L",x:.78,y:.93},{op:"L",x:.65,y:.93},{op:"Z"},{op:"M",x:0,y:.33},{op:"L",x:1,y:.18},{op:"L",x:1,y:.32},{op:"L",x:0,y:.47},{op:"Z"},{op:"M",x:0,y:.68},{op:"L",x:1,y:.53},{op:"L",x:1,y:.67},{op:"L",x:0,y:.82},{op:"Z"}]},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 Kt(a,e,t,n){let o=[],r=e*.72,s=e*.42,i=t,c=0;for(let l of a){let p=xc[l];if(!p)continue;let u={w:p.w*r,h:p.h*r,baseline:p.baseline*r,fill:p.fill,strokeWidth:e*.06,commands:p.commands},m=n-u.baseline-s;o.push({shape:u,x:i,y:m}),m<c&&(c=m),i+=u.w}return{placed:o,right:i,top:c}}function Ut(a,{shape:e,x:t,y:n},o,r){a.drawPath(e.commands,e.fill?{fill:r}:{stroke:r,strokeWidth:e.strokeWidth},{x:o.x+t,y:o.y+n,scaleX:e.w,scaleY:e.h})}function gc(a){let e=a.replace(/^[a-g]/,c=>c.toUpperCase()),t=je(e,0,e.length,!1);if(!t||t.next!==e.length)return null;let n=$e[t.name];if(n===void 0)return null;let o=Rn(t.acc??"",!1),s=((t.absOctave?t.octave??4:4+(t.octave??0))+1)*12+n+o;return Number.isSafeInteger(s)?(o<0?$t:Wt)[We(s)]+(Math.floor(s/12)-1):null}var br=class extends E{static def={name:["key","1"],description:"\u8BBE\u7F6E\u65F6\u95F4\u7EBF\u4E0A\u7684 1= \u8C03\u6027\u57FA\u51C6",details:`~~~jpfun
32
+ \u4EC5\u7ED8\u5236\uFF0C\u4E0D\u6539\u53D8\u65F6\u503C\u548C\u64AD\u653E\u3002pre \u4FEE\u9970\u5185\u5BB9\u9996\u7AEF\uFF0Cpost \u4FEE\u9970\u672B\u7AEF\uFF1Bup/down \u8868\u793A\u968F\u65F6\u95F4\u4E0A\u884C/\u4E0B\u884C\u3002`,allowExtraArgs:!1,args:[{type:"content",default:null,description:"\u88AB\u4FEE\u9970\u7684\u5185\u5BB9"},{name:"side",type:"string",default:"pre",description:"pre \u6ED1\u5165\uFF0Cpost \u6ED1\u51FA"},{name:"direction",type:"string",default:"up",description:"up \u4E0A\u884C\uFF0Cdown \u4E0B\u884C"}]};content;side;direction;get children(){return[this.content]}labelable(){return P.findLabelable(this.content)}constructor(e,t,n,o=null){super(e,o);let[r,s,i]=this.getArgValue(t,n);if(s!=="pre"&&s!=="post")throw new w("E_SLIDE_SIDE","@slide \u7684 side \u5FC5\u987B\u662F pre \u6216 post",e);if(i!=="up"&&i!=="down")throw new w("E_SLIDE_DIRECTION","@slide \u7684 direction \u5FC5\u987B\u662F up \u6216 down",e);this.content=r,this.side=s,this.direction=i,r.parent=this}loweringEnter(e){let t=this.side==="pre",n={onTemporal(o){_(o)&&(!t||!n.host)&&(n.host=o)}};return e.beginLoweringGroup(this,n),[]}loweringExit(e){let{host:t}=e.endLoweringGroup(this);if(!t)throw new w("E_SLIDE_CONTENT","@slide \u7684\u5185\u5BB9\u5FC5\u987B\u5305\u542B\u53EF\u7ED8\u5236\u5BF9\u8C61",this.sourceSpan);let n=new tr(t,this);e.addAttachment(n);let o=t.prepareHorizontal;return t.prepareHorizontal=r=>{o?.call(t,r),!(r.columnOf(t)<0)&&r.registerHorizontalLayoutHook(t,t,({columns:s,start:i})=>{let c=this.side==="pre",l=c?"WL":"WR",u=(c?t.box.anchor:t.box.w-t.box.anchor)+n.length+t.ast.size*.22;for(let m of s[i])m.box===t.box&&(m[l]=Math.max(m[l],u))})},[]}toString(e){return`@slide(${this.content.toString(e)}, side=${this.side}, direction=${this.direction})`}},nr=er,tr=class{constructor(e,t){this.host=e;this.owner=t;this.endPoints=[e]}host;owner;kind="slide";layer="foreground";endPoints;get sourceSpan(){return this.owner.sourceSpan}get length(){let{host:e}=this;return e.box.visualAxis-(e.ports.shoulder?.y??0)+e.ast.size*.1}createGeometry(){let{host:e,owner:t}=this,n=e.ast.size,o=t.side==="pre",r=this.length,s=t.direction==="up",i=e.box.y+e.box.visualAxis,c=o?e.box.x-n*.12-r:e.box.x+e.box.w+n*.12,l={x:c,y:s?i:i-r},p={x:c+r,y:s?i-r:i},u=s?-Math.PI/4:Math.PI/4,m=g=>({x:p.x-n*.25*Math.cos(u+g),y:p.y-n*.25*Math.sin(u+g)}),f=[{op:"M",...l},{op:"L",...p},{op:"M",...m(-Math.PI/6)},{op:"L",...p},{op:"L",...m(Math.PI/6)}],d=n*.05,h=Se(f);return{regions:[{x:h.x-d/2,y:h.y-d/2,w:h.w+d,h:h.h+d,line:e.layoutLine,track:e.track}],paint(g){g.drawPath(f,{fill:"none",stroke:"#000",strokeWidth:d})}}}};var bt="sans-serif",St="Arial, 'Century Schoolbook', 'Palatino Linotype', Cambria, 'Cascadia Mono', monospace";function Oe(a,e,t){let n=a.at(-1);n&&n.mask===t?n.text+=e:a.push({text:e,mask:t})}function Wt(a,e,t="\\*_^"){let n=0;for(let o=0;o<a.length;o++){let r=o,s=String.fromCodePoint(a.codePointAt(o));if(o+=s.length-1,s==="\\"&&o+1<a.length&&t.includes(a[o+1])){e(a[++o],n,!0,r,o+1);continue}if(s==="*"){n^=a[o+1]==="*"?(o++,1):2;continue}if(s==="_"){n^=4;continue}if(s==="^"){n^=8;continue}e(s,n,!1,r,o+1)}}function rr(a){let e=[[]];return Wt(a,(t,n)=>{t===`
33
+ `?e.push([]):Oe(e.at(-1),t,n)}),e}function Fn(a){return(a&1?"**":"")+(a&2?"*":"")+(a&4?"_":"")+(a&8?"^":"")}var fc=.7,hc=.35;function ve(a,e,t){let n=[];typeof a=="string"?Wt(a,(c,l)=>Oe(n,c,l)):n.push(...a);let o=0,r,s=n.length>1&&e.textAlign&&e.textAlign!=="left",i=n.map(c=>{let l=!s&&(c.mask&11)===0?e:{...e,...s?{textAlign:"left"}:{},...c.mask&8?{fontSize:e.fontSize*fc}:{},...c.mask&1?{fontWeight:"bold"}:{},...c.mask&2?{fontStyle:"italic"}:{}},p=t.measureText(c.text,l);return(c.mask&8)===0&&(r??=p),o+=p.w,{...c,style:l,w:p.w}});return r??=t.measureText("",e),{runs:i,style:e,w:n.length?o:r.w,h:r.h,baseline:r.baseline}}function Ie(a,e,t,n){let{runs:o,style:r,w:s}=e,{textAlign:i}=r,c=i==="center"?t-s/2:i==="right"?t-s:t,l=u=>u&8?n-r.fontSize*hc:n,p=c;for(let u of o)a.drawText(u.text,o.length===1?t:p,l(u.mask),u.style),p+=u.w;for(let u=0,m=c;u<o.length;){let{mask:f,style:d,w:h}=o[u++];if(!(f&4)){m+=h;continue}let y=m+h;for(;u<o.length&&(o[u].mask&12)===(f&12);)y+=o[u++].w;let g=Math.max(1,d.fontSize*.06),x=l(f)+d.fontSize*.12;a.drawRect(m,x-g/2,y-m,g,{fill:r.fill??"#000"}),m=y}}function Bn(a){return`${a.fontStyle?`${a.fontStyle} `:""}${a.fontWeight??"normal"} ${a.fontSize}px ${a.fontFamily??bt}`}var Mn=class{measureText(e,t){let n=t.fontSize,o=t.fontFamily?.toLowerCase().includes("mono")??!1,r=0;for(let s of e)r+=s.charCodeAt(0)>127?1:o?.62:.58;return{w:Math.max(r*n,n*.25),h:n,baseline:n*.8}}},ar=new Mn,or=class{constructor(e){this.context=e}context;widths=new Map;clearCache(){this.widths.clear()}measureText(e,t){let n=Bn(t),o=`${n}\0${e}`,r=this.widths.get(o);return r===void 0&&(this.context.font=n,r=this.context.measureText(e).width,this.widths.set(o,r)),{w:Math.max(r,t.fontSize*.25),h:t.fontSize,baseline:t.fontSize*.8}}};function ie(a,e,t){for(let n=e+1;n<t;n++)if(a[n]==="\\")n++;else if(a[n]==='"')return n;return-1}function $t(a){let e=a.length>=2&&a.startsWith('"')&&a.endsWith('"'),t=e?a.slice(1,-1):a,n,o=t.replace(/\\(u.{0,4}|.)/gs,(r,s,i)=>{if(s==='"'||s==="\\")return s;if(s[0]!=="u")return r;if(!/^u[0-9a-f]{4}$/i.test(s)){let c=i+(e?1:0);return n??=M.warning.InvalidUnicodeEscape({start:c,end:c+r.length}),r}return String.fromCharCode(Number.parseInt(s.slice(1),16))});return n??o}function te(a){return`"${a.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}var sr=10,ir=13,xc=9,gc=11,bc=12,Sc=32,Tc=160,wc=5760,Lc=8239,Cc=8287,Ac=12288,kc=65279,Nc=34,vc=92,Pc=37,Ec=32,_c=[];function Rc(a){return a>Ec?" ".repeat(a):_c[a]??=" ".repeat(a)}function Tt(a){return a===Sc||a===xc||a===gc||a===bc?!0:a<128?!1:a===Tc||a===wc||a>=8192&&a<=8202||a===Lc||a===Cc||a===Ac||a===kc}function wt(a){let e=a.length,t=[0],n=[],o=[],r=(h,y)=>{if(h>=y)return;let g=o.length;if(g>=2&&h<=o[g-1]){y>o[g-1]&&(o[g-1]=y);return}o.push(h,y)},s=(h,y)=>{if(y<=0)return;let g=h+y;for(let x=h;x<g;x+=2)r(x,x+1)},i=-1,c=!1,l=-1,p=-1,u=0,m=(h,y)=>{if(y===vc){u>0&&p+u===h?u++:(p=h,u=1);return}p=-1,u=0};for(let h=0;h<e;){let y=a.charCodeAt(h);if(y===ir||y===sr){let g=y===ir&&h+1<e&&a.charCodeAt(h+1)===sr?2:1;t.push(h+g);let x=(u&1)===1;s(p,u),l>=0&&(r(l,h),n.push({start:l,end:h}),l=-1),x?r(h,h+g):h>i&&g===2&&r(h,h+1),p=-1,u=0,h+=g;continue}if(h<=i){Tt(y)||m(h,y),h++;continue}if(y===Nc)c||(i=ie(a,h,e),c=i<0);else if(y===Pc){for(l=h,h++;h<e;){let g=a.charCodeAt(h);if(g===ir||g===sr)break;h++}continue}Tt(y)||m(h,y),h++}if(s(p,u),l>=0&&(r(l,e),n.push({start:l,end:e})),o.length===0)return{maskedSource:a,lineStarts:t,commentSpans:n};let f=[],d=0;for(let h=0;h<o.length;h+=2){let y=o[h],g=o[h+1];d<y&&f.push(a.slice(d,y)),f.push(Rc(g-y)),d=g}return d<e&&f.push(a.slice(d)),{maskedSource:f.join(""),lineStarts:t,commentSpans:n}}var Mc=/[A-Za-z0-9_./-]/;function Lt(a,e,t){let n=e+1;for(;n<t&&Mc.test(a[n]);)n++;let o=a.slice(e+1,n);if(!o||n>=t||a[n]!=="(")return null;let r=n,s=1,i=0,c=[],l=r+1,p=-1,u=(f,d,h=!1)=>{let y=ze(a,l,f);if(!h&&y.start>=y.end)return;let g=p>y.start?ze(a,y.start,p):void 0,x=p>y.start?ze(a,p+1,y.end):y;c.push({span:y,valueSpan:x,nameSpan:g,equalsSpan:p>y.start?{start:p,end:p+1}:void 0,commaSpan:d===void 0?void 0:{start:d,end:d+1}})},m=(f,d)=>({name:o,span:{start:e,end:f},nameSpan:{start:e,end:r},openParenSpan:{start:r,end:r+1},closeParenSpan:d,args:c});for(n++;n<t;n++){let f=a[n];if(f==='"'){let d=ie(a,n,t);d>=0&&(n=d)}else if(f==="{")i++;else if(f==="}")i=Math.max(0,i-1);else if(f==="("&&i===0)s++;else if(f===")"&&i===0){if(--s)continue;return u(n),m(n+1,{start:n,end:n+1})}else f===","&&s===1&&i===0?(u(n,n,!0),l=n+1,p=-1):f==="="&&p===-1&&s===1&&i===0&&(p=n)}return u(t),m(t)}function nt(a,e){let t=e?.nameSpan;return t&&a.slice(t.start,t.end).toLowerCase()}var Ts=/\s/;function ze(a,e,t){let n=e,o=t;for(;n<o&&Ts.test(a[n]);)n+=1;for(;o>n&&Ts.test(a[o-1]);)o-=1;return{start:n,end:o}}function cr(a,e,t){let n=1;for(let o=e;o<t;o++){let r=a[o];if(r==='"'){let s=ie(a,o,t);s>=0&&(o=s)}else if(r==="(")n++;else if(r===")"&&--n===0)return o}return-1}function lr(a,e,t){let n=1;for(let o=e+1;o<t;o++){let r=a[o];if(r==='"'){let s=ie(a,o,t);s>=0&&(o=s)}else if(r==="{")n++;else if(r==="}"&&--n===0)return o}return-1}var Fc=/\s|\(|\)|\{|\}|,/;function pr(a,e,t){let n=e+1;for(;n<t&&!Fc.test(a[n]);)n++;return n<=e+1?null:{label:a.slice(e+1,n),next:n}}var Bc=/^(-?(?:\d+(?:\.\d*)?|\.\d+))([a-z%]+)?$/i,Oc=["em","px"];function Ut(a){let e=a.match(Bc);if(!e)return M.warning.InvalidLength(a,{start:0,end:a.length});let t=parseFloat(e[1]);if(!Number.isFinite(t))return M.warning.InvalidLength(a,{start:0,end:a.length});if(e[2]){let n=e[2].toLowerCase();return Oc.includes(n)?{value:t,unit:n}:M.warning.InvalidLengthUnit(n,{start:e[1].length,end:a.length})}else return{value:t,unit:"px"}}var ur=/^(true|false)$/,mr=18,Ic=700,re=class a{static systemVariables={fontsize:{type:"length",default:mr,description:"\u57FA\u51C6\u5B57\u53F7\uFF0C\u4E5F\u662F `em` \u957F\u5EA6\u7684\u6362\u7B97\u57FA\u51C6"},font:{type:"string",default:bt,description:"\u666E\u901A\u6587\u5B57\u5B57\u4F53"},numberfont:{type:"string",default:St,description:"\u97F3\u7B26\u53CA\u540C\u7C7B\u8C31\u9762\u6570\u5B57\u5B57\u4F53"},numberweight:{type:"number",default:Ic,description:"\u4E3B\u8C31\u9762\u6570\u5B57\u5B57\u91CD\uFF0C\u4EC5\u63A7\u5236 `note`\u3001`meter`\u3001`rest`"},strict:{type:"boolean",default:!1,description:"\u5F00\u542F\u4E25\u683C\u7684\u8BED\u6CD5\u68C0\u67E5"}};scopeDepth;source;diagnostics;variables;documentDeclarations;functions;deSugarAtomFns;labelableNodes;callNode;nodes;pendingRight=[];constructor(e){e instanceof a?(this.scopeDepth=e.scopeDepth+1,this.documentDeclarations=e.documentDeclarations,this.source=e.source,this.diagnostics=e.diagnostics,this.variables={...e.variables},this.functions=e.functions,this.deSugarAtomFns=e.deSugarAtomFns,this.labelableNodes=e.labelableNodes,this.nodes=[]):(this.scopeDepth=0,this.documentDeclarations={},this.source=e.source,this.diagnostics=e.diagnostics??[],this.variables=Object.fromEntries(Object.entries(a.systemVariables).map(([t,n])=>[t,n.default])),Object.assign(this.variables,e.variables),this.functions=e.functions??new Map,this.labelableNodes=e.labelableNodes??[],this.nodes=e.toConsume??[],this.deSugarAtomFns=a.getDeSugarFns(this.functions.values()))}static getDeSugarFns(e){let t=new Set;for(let n of e)t.add(n.deSugarAtom);return t.delete(P.deSugarAtom),[...t]}pushNode(e){this.nodes.push(e);let t=e.labelable?.();t!==void 0&&this.labelableNodes.push(t)}setVariable(e,t){Object.hasOwn(a.systemVariables,e)&&(e==="fontsize"&&t&&(t=this.length2px(t)),(t===void 0||t===""||t===0)&&(t=a.systemVariables[e].default)),this.variables[e]=t}registerFunctions(e){let t=this.functions;for(let n of e){let o=n.def;if(!o)continue;let r=Array.isArray(o.name)?o.name:[o.name];for(let s of r){if(t.has(s.toLowerCase()))throw new Error(`Duplicate function name detected: ${s}`);t.set(s.toLowerCase(),n)}}this.deSugarAtomFns=a.getDeSugarFns(this.functions.values())}parse(e=0,t=this.source.length){return this.makeNodes(this.parseGrammar(e,t)),this.nodes}findLastOperandIndex(){let e=this.nodes.length-1;for(;e>=0&&this.nodes[e]instanceof pe;)e--;if(e<0)return-1;let t=this.nodes[e];if(t instanceof lt){let n=t.target;for(;n.parent;)n=n.parent;let o=this.nodes.lastIndexOf(n,e-1);return o<0?-1:(this.nodes.splice(o,e-o+1,new se({start:n.sourceSpan.start,end:t.sourceSpan.end},this.nodes.slice(o,e+1),null)),o)}return e}takeLeftOperand(e){let t=this.findLastOperandIndex();if(t<0)return null;let n=this.nodes[t];this.nodes.length=t;let o=this.pendingRight.at(-1);return e===void 0||o?.chain!==e||this.nodes.some(r=>!(r instanceof pe))?n:(this.pendingRight.pop(),this.nodes=o.left,o.combine(n))}deferRightOperand(e,t){this.pendingRight.push({left:this.nodes,combine:e,chain:t}),this.nodes=[]}makeNodes(e){let t=this.pendingRight.length;for(let o=0;o<e.length;o++){let r=e[o];if(typeof r=="number"){this.pushText(r,r+1);continue}switch(r.kind){case"call":this.pushNode(this.parseCallNode(r));break;case"brace":let s=new a(this);this.nodes.push(new se(r.span,s.parse(r.span.start+1,r.span.end-1),null));break;case"label":let i=this.labelableNodes.at(-1);i?i.label!==void 0?this.diagnostics.push(M.warning.TargetAlreadyLabeled(r.label,i.label,r.span)):(i.label=r.label,this.nodes.push(new lt(r.span,r.label,i))):this.diagnostics.push(M.warning.LabelWithoutTarget(r.label,r.span));break;case"sugar":let c=r.relation(this,e,o);c===null?this.pushText(r.span.start,r.span.end):o=c-1;break}}let n=[];for(;this.pendingRight.length>t;){let{left:o,combine:r}=this.pendingRight.pop(),s=this.nodes,i=0;for(;s[i]instanceof pe;)i++;o.push(r(s[i]));for(let c=s.length-1;c>i;c--)n.push(s[c]);this.nodes=o}for(;n.length;)this.nodes.push(n.pop())}pushText(e,t){let n=this.nodes.at(-1);n instanceof pe&&n.sourceSpan.end===e?n.sourceSpan.end=t:this.nodes.push(new pe({start:e,end:t},null))}parseGrammar(e,t,n){let o=[],r=s=>(o.push(s),n?.(s,this)??!1);e:for(;(e=_e(this.source,e,t))<t;){let s=this.source[e];if(s==="@"){let i=Lt(this.source,e,t);if(i){let l=r(Object.assign(i,{kind:"call",typed:!1})),p=!1;for(let u of i.args){let m=u.nameSpan!==void 0;if(m&&!p)p=!0;else if(!m&&p){let f=M.error.PosAfterNamedArg(i.name,u.span);if(!l)throw f;this.diagnostics.push(f)}}if(!i.closeParenSpan){let u=M.error.UnterminatedCall(i.name,i.span);if(!l)throw u;this.diagnostics.push(u)}e=i.span.end;continue}let c=pr(this.source,e,t);if(c){r({kind:"label",span:{start:e,end:c.next},label:c.label}),e=c.next;continue}}if(s==="{"){let i=lr(this.source,e,t);i<0&&(this.diagnostics.push(M.warning.UnmatchedBrace({start:e,end:t})),i=t),r({kind:"brace",span:{start:e,end:i+1}}),e=i+1;continue}for(let i of this.deSugarAtomFns)try{let c=i(this.source,e,t,this.scopeDepth);if(c){r(c.node),e=c.next;continue e}}catch(c){throw c instanceof M||this.diagnostics.push(M.error.Bug(c.toString(),{start:e,end:t})),c}o.push(e++)}return o}parseCallNode(e){let t=this.functions.get(e.name.toLowerCase()),n=t?.def;if(!t||!n){if(this.variables.strict)throw M.error.UnknownFunction(e.name,e.span);return this.diagnostics.push(M.warning.UnknownFunction(e.name,e.span)),new P(e.span,null)}let o=n.args;if(!e.typed){let r=new Map;for(let s=0;s<e.args.length;s++){let i=e.args[s],c=nt(this.source,i),l=Ze(n,c,s),p=c??s;if(l===void 0){n.allowExtraArgs?r.set(p,i):this.diagnostics.push(c?M.warning.UnknownArg(e.name,this.source.slice(i.nameSpan.start,i.nameSpan.end),i.span):M.warning.TooManyPosArgs(e.name,o.filter(f=>!f.namedOnly).length,s+1,i.valueSpan));continue}let u=yn(n,c,s)?.default===null,m=this.parseArgWithType(i.valueSpan,l,e.span.start,u);m!==null&&r.set(p,m)}return this.callNode=e,new t(e.span,r,this,null)}return this.callNode=void 0,new t(e.span,e.args,this,null)}parseArgWithType(e,t,n,o=!1){let r=ze(this.source,e.start,e.end),s=r.start,i=r.end;if(s>=i)return null;let c=t==="content"?"":this.source.slice(s,i);switch(t){case"number":let l=Number(c);return Number.isFinite(l)?l:(this.diagnostics.push(M.warning.InvalidNumber(c,r)),null);case"boolean":return ur.test(c)?c==="true":(this.diagnostics.push(M.warning.InvalidBoolean(c,r)),null);case"content":{let m=this.labelableNodes,f=m.length,d=m.at(-1),h=d?.label,y=d&&Object.hasOwn(d,"label");try{let x=new a(this).parse(s,i);return x.length===1?x[0]:new se(r,x,null)}catch(g){if(m.length=f,d&&(y?d.label=h:delete d.label),o||this.variables.strict||!(g instanceof M))throw g;return this.diagnostics.push(g,M.warning.InvalidContent(r)),null}}case"label":n??=e.start;for(let m=this.labelableNodes.length-1;m>=0;m--){let f=this.labelableNodes[m];if(f&&!(f.sourceSpan.start>=n)&&f.label==c)return f}throw M.error.UnknownLabel(c,r);case"length":let p=Ut(c);return p instanceof M?(p.span.start+=s,p.span.end+=s,this.diagnostics.push(p),null):p;default:let u=$t(c);return u instanceof M?(u.span.start+=s,u.span.end+=s,this.diagnostics.push(u),c.length>=2&&c.startsWith('"')&&c.endsWith('"')?c.slice(1,-1):c):u}}length2px(e){return e.unit==="em"?e.value*this.variables.fontsize:e.value}};function _e(a,e,t){for(;e<t&&Tt(a.charCodeAt(e));)e++;return e}function Ct(a,e,t=0){for(;e>=t&&Tt(a.charCodeAt(e));)e--;return e}function Dc(a){return a>="A"&&a<="G"||a==="X"||a==="Z"}function On(a){return a>="0"&&a<="9"}function As(a){return a==="#"||a==="b"||a==="n"}function dr(a,e,t){for(;e<t&&As(a[e]);)e++;return e}function ws(a,e,t){let n=dr(a,e,t);return n>e&&!On(a[n]??"")?a.slice(e,n):null}function Ls(a,e,t){e<t&&(a[e]==="+"||a[e]==="-")&&e++;let n=e;for(;e<t&&On(a[e]);)e++;return e>n?e:-1}function Cs(a,e,t,n,o){let r=0,s=e;for(;s<t&&(a[s]===","||a[s]==="'");)r+=a[s++]==="'"?1:-1;return{name:n,next:s,acc:o,octave:s>e?r:null,absOctave:!1}}function je(a,e=0,t=a.length,n=!0){if(t-e===0)return n?new w("E_WRONG_NOTE_NAME",'\u51FD\u6570 @note \u7684\u53C2\u6570 [0]:"name" \u4E0D\u80FD\u4E3A\u7A7A',{start:e,end:t}):null;let o=a[e];if(Dc(o)){let r=e+1,s=null,i=null,c=Ls(a,r,t);if(c>0)i=parseInt(a.slice(r,c),10),r=c,s=ws(a,r,t),s&&(r+=s.length);else{let l=dr(a,r,t);if(l>r){s=a.slice(r,l);let p=Ls(a,l,t);p>0?(i=parseInt(a.slice(l,p),10),r=p):r=l}}return{name:o,next:r,acc:s,octave:i,absOctave:!0}}if(On(o)){let r=ws(a,e+1,t);return Cs(a,e+1+(r?r.length:0),t,o,r)}if(As(o)){let r=dr(a,e,t);if(r>=t)return n?new w("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:e,end:t}):null;let s=a[r];return On(s)?Cs(a,r+1,t,s,a.slice(e,r)):n?new w("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 "{ch}"',{start:r,end:r+1},{ch:s}):null}return n?new w("E_WRONG_NOTE_NAME",'\u51FD\u6570 @note \u7684\u53C2\u6570 [0]:"name" \u683C\u5F0F\u9519\u8BEF: \u9996\u5B57\u7B26 "{ch}" \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:e,end:e+1},{ch:o}):null}var Yt=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],Kt=["C","Db","D","Eb","E","F","Gb","G","Ab","A","Bb","B"],ke="CDEFGAB",$e={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},yr=[0,2,4,5,7,9,11];function At(a){let e=a[0];if(!e||e<"A"||e>"G")return null;let t="",n=1;n<a.length&&(a[n]==="#"||a[n]==="b")&&(t=a[n],n++);let o=$e[e+t];if(o===void 0)return null;let r=a.slice(n),s=Number(r);return!/^-?\d+$/.test(r)||!Number.isSafeInteger(s)?null:(s+1)*12+o}function kt(a,e=!0,t=0){for(let n of a)n==="#"?t++:n==="b"?t--:n==="n"&&!e&&(t=0);return t}function Xt(a,e,t,n){let o=$e[a];if(o===void 0)return null;let r=kt(e);return a>="1"&&a<="7"?At(n)+o+r+t*12:(t+1)*12+o+r}function fr(a,e,t){if(a<"1"||a>"7")return;let n=At(t),o=e*7+Number(a)-1;return r=>{let s=o+r,i=Math.floor(s/7);return n+yr[(s%7+7)%7]+i*12}}function We(a){return(a%12+12)%12}function In(a){let e=We(a);return e>6?e-12:e}function ot(a){return a<0?"b".repeat(-a):"#".repeat(a)}function Zt(a,e,t,n){let o=ke.indexOf(n[0]),r=ke.indexOf(a),s=Xt(a,e,t,n);if(o<0||r<0||s===null)return null;let i=At(n),c=(r-o+ke.length)%ke.length,l=We(i+yr[c]),p=In(We(s)-l),u=(s-i-yr[c]-p)/12;return{renderName:String(c+1),renderAcc:ot(p),renderOctave:u}}var Vc={"#":{w:.42,h:.82,baseline:.67,fill:!0,commands:[{op:"M",x:.22,y:.07},{op:"L",x:.35,y:.07},{op:"L",x:.35,y:1},{op:"L",x:.22,y:1},{op:"Z"},{op:"M",x:.65,y:0},{op:"L",x:.78,y:0},{op:"L",x:.78,y:.93},{op:"L",x:.65,y:.93},{op:"Z"},{op:"M",x:0,y:.33},{op:"L",x:1,y:.18},{op:"L",x:1,y:.32},{op:"L",x:0,y:.47},{op:"Z"},{op:"M",x:0,y:.68},{op:"L",x:1,y:.53},{op:"L",x:1,y:.67},{op:"L",x:0,y:.82},{op:"Z"}]},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 Dn(a,e,t,n){let o=[],r=e*.72,s=e*.42,i=t,c=0;for(let l of a){let p=Vc[l];if(!p)continue;let u={w:p.w*r,h:p.h*r,baseline:p.baseline*r,fill:p.fill,strokeWidth:e*.06,commands:p.commands},m=n-u.baseline-s;o.push({shape:u,x:i,y:m}),m<c&&(c=m),i+=u.w}return{placed:o,right:i,top:c}}function Vn(a,{shape:e,x:t,y:n},o,r){a.drawPath(e.commands,e.fill?{fill:r}:{stroke:r,strokeWidth:e.strokeWidth},{x:o.x+t,y:o.y+n,scaleX:e.w,scaleY:e.h})}function Hc(a){let e=a.replace(/^[a-g]/,c=>c.toUpperCase()),t=je(e,0,e.length,!1);if(!t||t.next!==e.length)return null;let n=$e[t.name];if(n===void 0)return null;let o=kt(t.acc??"",!1),s=((t.absOctave?t.octave??4:4+(t.octave??0))+1)*12+n+o;return Number.isSafeInteger(s)?(o<0?Kt:Yt)[We(s)]+(Math.floor(s/12)-1):null}var xr=class extends P{static def={name:["key","1"],description:"\u8BBE\u7F6E\u65F6\u95F4\u7EBF\u4E0A\u7684 1= \u8C03\u6027\u57FA\u51C6",details:`~~~jpfun
32
34
  1 ^ @key(F#3)
33
35
  ~~~
34
- \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(e,t,n,o=null){super(e,o);let[r,s]=this.getArgValue(t,n);this.font=n.variables.numberfont,this.size=n.length2px(s);let i=gc(r);if(this.tonality=i??Ze,i!==r&&i!==`${r}4`){if(n.variables.strict)throw new w("E_KEY_TONALITY",'@key \u65E0\u6CD5\u89E3\u6790\u8C03\u6027 "{tonality}"',e,{tonality:r});n.diagnostics.push(new I("W_KEY_TONALITY",'@key \u7684\u8C03\u6027 "{input}" \u4E0D\u662F\u89C4\u8303\u5199\u6CD5\uFF0C\u5DF2\u81EA\u52A8\u5207\u6362\u5230 {tonality}',e,{input:r,tonality:this.tonality}))}this.displayName=this.tonality[0],this.displayAcc=this.tonality[1]==="#"||this.tonality[1]==="b"?this.tonality[1]:""}loweringEnter(){return[new Sr(this)]}toString(){return`@1(${this.tonality})`}},Xt=br,gr="1=",Sr=class extends W{accidentals=[];nameX=0;textBaselineY=0;style;constructor(e){super(),this.ast=e,this.style={fontSize:e.size,fontFamily:e.font,fill:"#000"},this.initLayoutBox()}onTimeState(e){e.keySignature=this.ast.tonality}prepareLayout(e){let t=this.ast.size,n=this.style,o=e.textMeasurer.measureText(gr,n),r=e.textMeasurer.measureText(this.ast.displayName,n),{placed:s,right:i,top:c}=Kt(this.ast.displayAcc,t,o.w,o.baseline);this.accidentals=s;let l=-c;for(let p of s)p.y+=l;this.nameX=i,this.textBaselineY=l+o.baseline,this.box.w=i+r.w,this.box.h=l+Math.max(o.h,r.h),this.box.anchor=e.textMeasurer.measureText(gr[0],n).w/2,this.box.visualAxis=this.box.h/2}paint(e){let t=this.style;e.drawText(gr,this.box.x,this.box.y+this.textBaselineY,t);for(let n of this.accidentals)Ut(e,n,this.box,"#000");e.drawText(this.ast.displayName,this.box.x+this.nameX,this.box.y+this.textBaselineY,t)}};var bc=[{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 Tr(a){let e=a/11;return{w:3.864*e,h:10.88*e,stemCenterX:(3.304+3.864)/2*e,commands:bc,scale:e}}var wr=class extends E{static def={name:["tempo"],description:"\u8BBE\u7F6E\u65F6\u95F4\u7EBF\u4E0A\u7684\u901F\u5EA6",details:`~~~jpfun
36
+ \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(e,t,n,o=null){super(e,o);let[r,s]=this.getArgValue(t,n);this.font=n.variables.numberfont,this.size=n.length2px(s);let i=Hc(r);if(this.tonality=i??qe,i!==r&&i!==`${r}4`){if(n.variables.strict)throw new w("E_KEY_TONALITY",'@key \u65E0\u6CD5\u89E3\u6790\u8C03\u6027 "{tonality}"',e,{tonality:r});n.diagnostics.push(new O("W_KEY_TONALITY",'@key \u7684\u8C03\u6027 "{input}" \u4E0D\u662F\u89C4\u8303\u5199\u6CD5\uFF0C\u5DF2\u81EA\u52A8\u5207\u6362\u5230 {tonality}',e,{input:r,tonality:this.tonality}))}this.displayName=this.tonality[0],this.displayAcc=this.tonality[1]==="#"||this.tonality[1]==="b"?this.tonality[1]:""}loweringEnter(){return[new gr(this)]}toString(){return`@1(${this.tonality})`}},qt=xr,hr="1=",gr=class extends H{accidentals=[];nameX=0;textBaselineY=0;style;constructor(e){super(),this.ast=e,this.style={fontSize:e.size,fontFamily:e.font,fill:"#000"},this.initLayoutBox()}onTimeState(e){e.keySignature=this.ast.tonality,e.accidentals.clear()}prepareLayout(e){let t=this.ast.size,n=this.style,o=e.textMeasurer.measureText(hr,n),r=e.textMeasurer.measureText(this.ast.displayName,n),{placed:s,right:i,top:c}=Dn(this.ast.displayAcc,t,o.w,o.baseline);this.accidentals=s;let l=-c;for(let p of s)p.y+=l;this.nameX=i,this.textBaselineY=l+o.baseline,this.box.w=i+r.w,this.box.h=l+Math.max(o.h,r.h),this.box.anchor=e.textMeasurer.measureText(hr[0],n).w/2,this.box.visualAxis=this.box.h/2}paint(e){let t=this.style;e.drawText(hr,this.box.x,this.box.y+this.textBaselineY,t);for(let n of this.accidentals)Vn(e,n,this.box,"#000");e.drawText(this.ast.displayName,this.box.x+this.nameX,this.box.y+this.textBaselineY,t)}};var Gc=[{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 ks(a){let e=a/11;return{w:3.864*e,h:10.88*e,stemCenterX:(3.304+3.864)/2*e,commands:Gc,scale:e}}var br=class extends P{static def={name:["tempo"],description:"\u8BBE\u7F6E\u65F6\u95F4\u7EBF\u4E0A\u7684\u901F\u5EA6",details:`~~~jpfun
35
37
  @tempo(96)
36
38
  ~~~
37
- \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(e,t,n,o=null){super(e,o);let[r,s]=this.getArgValue(t,n);this.bpm=r,this.size=n.length2px(s),this.font=n.variables.font}loweringEnter(){return[new Lr(this)]}toString(){return`@tempo(${this.bpm}, size=${this.size}px)`}},Zt=wr,Lr=class extends W{glyph;text;style;glyphY=0;textX=0;textBaselineY=0;constructor(e){super(),this.ast=e,this.glyph=Tr(e.size),this.text=`= ${e.bpm}`,this.style={fontSize:e.size,fontFamily:e.font,fill:"#000"},Number.isFinite(e.bpm)&&e.bpm>0&&(this.playbackState={bpm:e.bpm}),this.initLayoutBox()}onTimeState(e){let t=this.playbackState?.bpm;t!==void 0&&(e.bpm=t)}prepareLayout(e){let t=this.glyph,n=e.textMeasurer.measureText(this.text,this.style),o=Math.max(0,t.h-n.baseline);this.textX=t.w+this.ast.size*.26,this.textBaselineY=o+n.baseline,this.glyphY=this.textBaselineY-t.h,this.box.w=this.textX+n.w,this.box.h=o+n.h,this.box.anchor=t.stemCenterX,this.box.visualAxis=o+n.h/2}paint(e){e.drawPath(this.glyph.commands,{fill:"#000"},{x:this.box.x,y:this.box.y+this.glyphY,scaleX:this.glyph.scale,scaleY:this.glyph.scale}),e.drawText(this.text,this.box.x+this.textX,this.box.y+this.textBaselineY,this.style)}};var Cr=class a extends E{static def={name:["text"],description:"\u6587\u672C\u6807\u8BB0",details:'~~~jpfun\n@text(\u8FDB\u5165\u4E3B\u9898, size=0.8em, align=center)\n~~~\n**\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\u3002\n\n\u652F\u6301 `*\u659C\u4F53*`\u3001`**\u7C97\u4F53**`\u3001`_\u4E0B\u5212\u7EBF_`\u3001`^\u4E0A\u6807^`\uFF08\u518D\u6B21\u51FA\u73B0\u5373\u5173\u95ED\uFF0C\u4E0D\u5173\u95ED\u5219\u4E00\u76F4\u751F\u6548\uFF1B\u5199 `\\*`\u3001`\\_`\u3001`\\^` \u663E\u793A\u539F\u5B57\u7B26\uFF09\u3002\u652F\u6301 `\\uE050` \u5F62\u5F0F\u7684 Unicode \u8F6C\u4E49\uFF1B\u53CD\u659C\u6760\u5199 `\\\\`\u3002',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(e,t,n){if(e[t]!=='"')return null;let o=ae(e,t,n);if(o<0)return null;let r={kind:"sugar",data:a,span:{start:t,end:o+1},syntaxKind:"string"};return{next:o+1,node:r}}static deSugarRelation(e,t,n){let o=t[n];return o.data!==a?null:(e.pushNode(new a(o.span,new Map([[0,e.parseArgWithType(o.span,"string")]]),e,null)),n+1)}text;size;lineHeight;align;font;constructor(e,t,n,o=null){super(e,o);let[r,s,i,c,l]=this.getArgValue(t,n);if(this.font=l||n.variables.font,c!=="left"&&c!=="center"&&c!=="right")throw new w("E_TEXT_INVALID_ALIGN","@text \u7684 align \u53C2\u6570\u5FC5\u987B\u662F 'left'\u3001'center' \u6216 'right'",e);this.text=r.replace(/\r?\n/g,`
38
- `),this.size=n.length2px(s),this.lineHeight=i,this.align=c}loweringEnter(){return[new Ar(this)]}toString(){return`@text(${ee(this.text)}, size=${this.size}px, lineheight=${this.lineHeight}, align=${this.align}, font=${ee(this.font)})`}},qt=Cr,Ar=class extends W{preparedLines=[];constructor(e){super(),this.ast=e,this.mergeKey=Se,this.initLayoutBox()}prepareLayout(e){let{text:t,align:n,size:o,font:r,lineHeight:s}=this.ast,i={fontSize:o,fontFamily:r,fill:"#000",textAlign:n};this.preparedLines=ir(t).map(p=>ke(p,i,e.textMeasurer));let c=this.preparedLines[0],l=Math.max(...this.preparedLines.map(p=>p.w));if(this.box.w=l,this.box.h=(this.preparedLines.length-1)*s*o+c.h,this.box.visualAxis=this.box.h/2,n==="center")this.box.anchor=l/2;else{let p=n==="right"?-1:0,u=c.runs.at(p),m=u?e.textMeasurer.measureText([...u.text].at(p),u.style).w/2:0;this.box.anchor=n==="right"?l-m:m}}paint(e){let{align:t,lineHeight:n,size:o}=this.ast,r=this.box.x+(t==="center"?this.box.w/2:t==="right"?this.box.w:0),s=this.box.y+this.preparedLines[0].baseline;for(let i of this.preparedLines)Be(e,i,r,s),s+=n*o}};var Fs={title:"center",subtitle:"center",author:"right",signature:"left",tempo:"left",left:"left",center:"center",right:"right"},Sc={title:[2,"center"],subtitle:[1,"center"],author:[.88,"right"]},Tc=.25,Bs=5,Os=1e4;function On(a,e){return e.length===1&&e[0]instanceof re?e[0]:new re(a,e)}function wc(a,e,t=a.length){for(;e<t&&a[e]!=="\r"&&a[e]!==`
39
- `;)e++;return e}function Lc({columns:a,rows:e,start:t,end:n,X:o,fixed:r,options:s},i){pt(a.slice(t,n+1),e,o.subarray(t,n+1),r.subarray(t,n),1/0,s);let c=1/0,l=-1/0;for(let p=t+1;p<n;p++)for(let u=0;u<e;u++)c=Math.min(c,o[p]-a[p][u].WL),l=Math.max(l,o[p]+a[p][u].WR);i&&c<=l?(o[t]=c,o[n]=l):o[n]=o[t]}var In=class extends W{members=[];slots=[];titleBottom=0;aligned=!1;sideExtents={left:null,right:null};constructor(e){super(),this.ast=e,this.initLayoutBox()}validateDuration(){for(let e of this.members)if(!e.T.isZero())throw new w("E_HEAD_NONZERO_DURATION","@head \u7684\u5185\u5BB9\u5FC5\u987B\u5168\u90E8\u4E3A\u96F6\u65F6\u957F",e.ast.sourceSpan)}prepareLayout(){this.box.w=this.box.h=this.box.anchor=this.box.visualAxis=0,this.aligned=!1}prepareHorizontal(e){this.slots.length>0&&this.prepareHead(e)}onPlaced(){this.slots.length>0&&!this.aligned&&(this.aligned=!0,this.alignHead())}onTemporal(e){this.members.push(e)}createTracks(e){let{name:t,owner:n}=e;return{laneKey:`head/rows/${n.sourceSpan.start}/${t}`,hostIndex:null,measure:o=>{let r,s;t==="center"&&(this.titleBottom=0);let i=o.map(c=>{if(!c)return null;let l=s===void 0?0:s+n.gap-c.top;return s===void 0&&t==="center"&&(this.titleBottom=c.bottom),r??=l+c.top,s=l+c.bottom,{offset:l,extent:c}});return t!=="center"&&(this.sideExtents[t]=r===void 0||s===void 0?null:{top:r,bottom:s}),i},place:t==="center"?void 0:()=>{let o=this.sideExtents[t];if(!o)return this.titleBottom;let{left:r,right:s}=this.sideExtents,i=r?r.bottom-r.top:0,c=s?s.bottom-s.top:0;return this.titleBottom+Math.max(i,c)-o.bottom}}}prepareHead(e){if(this.members.some(r=>M(r)&&r.layoutLine!==e.index))throw new w("E_HEAD_INTERNAL_BREAK","@head \u7684\u5185\u5BB9\u4E0D\u80FD\u8DE8\u8C31\u9762\u884C",this.ast.owner.sourceSpan);let[t,n,o]=this.slots;t.start.springConfig.alpha_L=0,o.end.springConfig.alpha_R=0,this.stretch(n.start,"L"),this.stretch(n.end,"R");for(let r of this.slots)e.registerHorizontalLayoutHook(r.start,r.end,s=>Lc(s,r===n))}alignHead(){let e=new Map;for(let o of this.members){if(!M(o))continue;let r=this.sideCellOf(o.ast);if(!r)continue;let s=e.get(r);s?s.push(o):e.set(r,[o])}let[t,,n]=this.slots;this.packRows(t.ast,t.start.box.x-(t.start.placementOffset?.x??0),e),this.packRows(n.ast,n.end.box.x,e)}stretch(e,t){let n=t==="L"?"alpha_L":"alpha_R",o=t==="L"?"beta_L":"beta_R";e.springConfig[n]=e.springConfig[n]*Os,e.springConfig[o]=e.springConfig[o]*3/Os}packRows(e,t,n){let o=this.ast.owner.size*Tc,r=e.name==="left",s=r?1:-1;for(let i of e.rows){let c=i instanceof re?i.content:[i],l=t;for(let p=r?0:c.length-1;p>=0&&p<c.length;p+=s){let u=n.get(c[p]);if(!u)continue;let m=1/0,y=-1/0;for(let g of u)m=Math.min(m,g.box.x),y=Math.max(y,g.box.x+g.box.w);let d=l-(r?m:y);for(let g of u)g.box.x+=d;for(let g of u)g.onPlaced?.();l+=s*(y-m+o)}}}sideCellOf(e){let t=e;for(;t.parent;){let n=t.parent,o=n instanceof ot?n:n instanceof re&&n.parent instanceof ot?n.parent:null;if(o?.owner===this.ast.owner)return o.name==="center"?null:t;t=n}return null}},ot=class extends be{constructor(t,n,o,r){super(t,n);this.owner=n;this.name=o;this.rows=r;for(let s of this.rows)s.parent=this}owner;name;rows;get size(){return this.owner.size}get children(){return this.rows}timeFlowModel(t){if(this.rows.length===0)return null;let n=t.getTemporalNodes(this.owner.slots[0])[0];return{mode:"parallel",children:this.rows,tracks:n.createTracks(this)}}loweringEnter(t){let n=new In(this);return this.name==="left"&&t.beginLoweringGroup(this.owner,n),[n]}loweringExit(){return[new In(this)]}addRow(t){t.parent=this,this.rows.push(t)}},Nr=class a extends E{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:Bs,unit:"px"}}]};slots;size;gap;createdBySugar=!1;get children(){return this.slots}static deSugarAtom(e,t,n){if(e[t]!=="H"||e[t+1]!==".")return null;let o=t+2;for(;o<n&&e[o]>="a"&&e[o]<="z";)o++;let r=e.slice(t+2,o);if(!Object.hasOwn(Fs,r)||e[o]!==":")return null;o++;let s=wc(e,o,n),i=Pe(e,o,s),c=e[i]==="@"||e[i]==="{",l=Lt(e,s-1,i),p=c?void 0:{start:i,end:Math.max(i,l+1)};return{next:c?o:s,node:{kind:"sugar",data:{class:a,field:r,contentSpan:p},span:{start:t,end:o},syntaxKind:p&&r!=="signature"&&r!=="tempo"&&p.start<p.end?[{kind:"operator",span:{start:t,end:o}},{kind:"string",span:p}]:void 0}}}static deSugarRelation(e,t,n){let o=t[n++];if(o.data?.class!==a)return null;let r=o.data.field,s=n,i=o.data.contentSpan,c;if(!i){for(;s<t.length;s++){let f=t[s];if(typeof f=="number"&&(e.source[f]==="\r"||e.source[f]===`
40
- `)||typeof f!="number"&&f.kind==="sugar"&&f.data?.class===a)break}let d=new le(e);d.makeNodes(t.slice(n,s)),c=d.nodes;let g=c.at(-1)?.sourceSpan.end??o.span.end;i={start:Pe(e.source,o.span.end,g),end:g}}if(i.start>=i.end)throw new w("E_HEAD_EMPTY_DECLARATION","H.{field}: \u540E\u5FC5\u987B\u6709\u5185\u5BB9",o.span,{field:r});let l=e.source.slice(i.start,i.end),p=e.nodes.at(-1),u=p instanceof a&&p.createdBySugar?p:new a(o.span,new Map,e,null);u.createdBySugar=!0,u.slots.find(d=>d.name===Fs[r]).addRow(a.parseSugarRow(e,r,i,l,c)),u.sourceSpan.end=i.end,u!==p&&e.pushNode(u);let m=t[s];if(typeof m!="number")return s;let y=s+1;if(e.source[m]==="\r"){let d=t[y];typeof d=="number"&&e.source[d]===`
41
- `&&y++}return y}static parseSugarRow(e,t,n,o,r){if(r!==void 0)return On(n,r);if(t==="signature"){let c=/^(1\s*=\s*(\S+))\s+((\d+)\s*\/\s*(\d+))$/.exec(o);if(!c)throw new w("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},p={start:n.end-c[3].length,end:n.end};return On(n,[new Xt(l,new Map([["tonality",c[2]]]),e,null),new Dt(p,new Map([["num",Number(c[4])],["den",Number(c[5])]]),e,null)])}if(t==="tempo"){let c=Number(o);if(!Number.isFinite(c)||c<=0)throw new w("E_HEAD_INVALID_TEMPO","H.tempo \u540E\u5FC5\u987B\u662F\u6B63\u6570",n);return On(n,[new Zt(n,new Map([["bpm",c]]),e,null)])}let s=new Map([[0,o]]),i=Sc[t];return i&&(s.set("size",{value:i[0],unit:"em"}),s.set("align",i[1])),On(n,[new qt(n,s,e,null)])}constructor(e,t,n,o=null){super(e,o),this.size=n.variables.fontsize,this.gap=n.length2px(this.getArgValue(t,n)[3]);let r=(s,i)=>{let c=t.get(s)??t.get(i);return c instanceof be?c instanceof re?c.content:[c]:[]};this.slots=[new ot(e,this,"left",r("left",0)),new ot(e,this,"center",r("center",1)),new ot(e,this,"right",r("right",2))]}loweringExit(e){let t=e.endLoweringGroup(this);t.slots=this.slots.map(n=>{let[o,r]=e.getTemporalNodes(n);return{ast:n,start:o,end:r}}),t.slots[2].end.onTimeState=()=>t.validateDuration();for(let n of t.members)if((n.addon?.breakBefore??0)>0)throw new w("E_HEAD_INTERNAL_BREAK","@head \u7684\u5185\u90E8\u4E0D\u80FD\u6362\u884C\u6216\u6362\u9875\uFF1B\u7B2C\u4E00\u5C42\u5185\u5BB9\u5DF2\u7ECF\u8868\u793A\u89C6\u89C9\u884C",n.ast.sourceSpan);return[]}toString(e){let t=this.slots.filter(n=>n.rows.length>0).map(n=>{let o=n.rows.map(r=>` ${r.toString(e).replaceAll(`
39
+ \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(e,t,n,o=null){super(e,o);let[r,s]=this.getArgValue(t,n);this.bpm=r,this.size=n.length2px(s),this.font=n.variables.font}loweringEnter(){return[new Sr(this)]}toString(){return`@tempo(${this.bpm}, size=${this.size}px)`}},Qt=br,Sr=class extends H{bpm;glyph;text;style;glyphY=0;textX=0;textBaselineY=0;constructor(e){super(),this.ast=e,this.glyph=ks(e.size),this.text=`= ${e.bpm}`,this.style={fontSize:e.size,fontFamily:e.font,fill:"#000"},Number.isFinite(e.bpm)&&e.bpm>0&&(this.bpm=e.bpm),this.initLayoutBox()}onTimeState(e){this.bpm!==void 0&&(e.bpm=this.bpm)}emitPlayback(e){let t=this.bpm;t!==void 0&&e.control(e.start,n=>{n.bpm=t})}prepareLayout(e){let t=this.glyph,n=e.textMeasurer.measureText(this.text,this.style),o=Math.max(0,t.h-n.baseline);this.textX=t.w+this.ast.size*.26,this.textBaselineY=o+n.baseline,this.glyphY=this.textBaselineY-t.h,this.box.w=this.textX+n.w,this.box.h=o+n.h,this.box.anchor=t.stemCenterX,this.box.visualAxis=o+n.h/2}paint(e){e.drawPath(this.glyph.commands,{fill:"#000"},{x:this.box.x,y:this.box.y+this.glyphY,scaleX:this.glyph.scale,scaleY:this.glyph.scale}),e.drawText(this.text,this.box.x+this.textX,this.box.y+this.textBaselineY,this.style)}};var Tr=class a extends P{static def={name:["text"],description:"\u6587\u672C\u6807\u8BB0",details:'~~~jpfun\n@text(\u8FDB\u5165\u4E3B\u9898, size=0.8em, align=center)\n~~~\n**\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\u3002\n\n\u652F\u6301 `*\u659C\u4F53*`\u3001`**\u7C97\u4F53**`\u3001`_\u4E0B\u5212\u7EBF_`\u3001`^\u4E0A\u6807^`\uFF08\u518D\u6B21\u51FA\u73B0\u5373\u5173\u95ED\uFF0C\u4E0D\u5173\u95ED\u5219\u4E00\u76F4\u751F\u6548\uFF1B\u5199 `\\*`\u3001`\\_`\u3001`\\^` \u663E\u793A\u539F\u5B57\u7B26\uFF09\u3002\u652F\u6301 `\\uE050` \u5F62\u5F0F\u7684 Unicode \u8F6C\u4E49\uFF1B\u53CD\u659C\u6760\u5199 `\\\\`\u3002',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(e,t,n){if(e[t]!=='"')return null;let o=ie(e,t,n);if(o<0)return null;let r={kind:"sugar",span:{start:t,end:o+1},syntaxKind:"string",relation:a.deSugarRelation};return{next:o+1,node:r}}static deSugarRelation(e,t,n){let o=t[n];return e.pushNode(new a(o.span,new Map([[0,e.parseArgWithType(o.span,"string")]]),e,null)),n+1}text;size;lineHeight;align;font;constructor(e,t,n,o=null){super(e,o);let[r,s,i,c,l]=this.getArgValue(t,n);if(this.font=l||n.variables.font,c!=="left"&&c!=="center"&&c!=="right")throw new w("E_TEXT_INVALID_ALIGN","@text \u7684 align \u53C2\u6570\u5FC5\u987B\u662F 'left'\u3001'center' \u6216 'right'",e);this.text=r.replace(/\r?\n/g,`
40
+ `),this.size=n.length2px(s),this.lineHeight=i,this.align=c}loweringEnter(){return[new wr(this)]}toString(){return`@text(${te(this.text)}, size=${this.size}px, lineheight=${this.lineHeight}, align=${this.align}, font=${te(this.font)})`}},Jt=Tr,wr=class extends H{preparedLines=[];constructor(e){super(),this.ast=e,this.mergeKey=Le,this.initLayoutBox()}prepareLayout(e){let{text:t,align:n,size:o,font:r,lineHeight:s}=this.ast,i={fontSize:o,fontFamily:r,fill:"#000",textAlign:n};this.preparedLines=rr(t).map(p=>ve(p,i,e.textMeasurer));let c=this.preparedLines[0],l=Math.max(...this.preparedLines.map(p=>p.w));if(this.box.w=l,this.box.h=(this.preparedLines.length-1)*s*o+c.h,this.box.visualAxis=this.box.h/2,n==="center")this.box.anchor=l/2;else{let p=n==="right"?-1:0,u=c.runs.at(p),m=u?e.textMeasurer.measureText([...u.text].at(p),u.style).w/2:0;this.box.anchor=n==="right"?l-m:m}}paint(e){let{align:t,lineHeight:n,size:o}=this.ast,r=this.box.x+(t==="center"?this.box.w/2:t==="right"?this.box.w:0),s=this.box.y+this.preparedLines[0].baseline;for(let i of this.preparedLines)Ie(e,i,r,s),s+=n*o}};var Ns={title:"center",subtitle:"center",author:"right",signature:"left",tempo:"left",left:"left",center:"center",right:"right"},zc={title:[2,"center"],subtitle:[1,"center"],author:[.88,"right"]},jc=.25,vs=5,Ps=1e4;function Hn(a,e){return e.length===1&&e[0]instanceof se?e[0]:new se(a,e)}function Wc(a,e,t=a.length){for(;e<t&&a[e]!=="\r"&&a[e]!==`
41
+ `;)e++;return e}function $c({columns:a,rows:e,start:t,end:n,X:o,fixed:r,options:s},i){ut(a.slice(t,n+1),e,o.subarray(t,n+1),r.subarray(t,n),1/0,s);let c=1/0,l=-1/0;for(let p=t+1;p<n;p++)for(let u=0;u<e;u++)c=Math.min(c,o[p]-a[p][u].WL),l=Math.max(l,o[p]+a[p][u].WR);i&&c<=l?(o[t]=c,o[n]=l):o[n]=o[t]}var Gn=class extends H{members=[];slots=[];titleBottom=0;aligned=!1;sideExtents={left:null,right:null};constructor(e){super(),this.ast=e,this.initLayoutBox()}validateDuration(){for(let e of this.members)if(!e.T.isZero())throw new w("E_HEAD_NONZERO_DURATION","@head \u7684\u5185\u5BB9\u5FC5\u987B\u5168\u90E8\u4E3A\u96F6\u65F6\u957F",e.ast.sourceSpan)}prepareLayout(){this.box.w=this.box.h=this.box.anchor=this.box.visualAxis=0,this.aligned=!1}prepareHorizontal(e){this.slots.length>0&&this.prepareHead(e)}onPlaced(){this.slots.length>0&&!this.aligned&&(this.aligned=!0,this.alignHead())}onTemporal(e){this.members.push(e)}createTracks(e){let{name:t,owner:n}=e;return{laneKey:`head/rows/${n.sourceSpan.start}/${t}`,hostIndex:null,measure:o=>{let r,s;t==="center"&&(this.titleBottom=0);let i=o.map(c=>{if(!c)return null;let l=s===void 0?0:s+n.gap-c.top;return s===void 0&&t==="center"&&(this.titleBottom=c.bottom),r??=l+c.top,s=l+c.bottom,{offset:l,extent:c}});return t!=="center"&&(this.sideExtents[t]=r===void 0||s===void 0?null:{top:r,bottom:s}),i},place:t==="center"?void 0:()=>{let o=this.sideExtents[t];if(!o)return this.titleBottom;let{left:r,right:s}=this.sideExtents,i=r?r.bottom-r.top:0,c=s?s.bottom-s.top:0;return this.titleBottom+Math.max(i,c)-o.bottom}}}prepareHead(e){if(this.members.some(r=>_(r)&&r.layoutLine!==e.index))throw new w("E_HEAD_INTERNAL_BREAK","@head \u7684\u5185\u5BB9\u4E0D\u80FD\u8DE8\u8C31\u9762\u884C",this.ast.owner.sourceSpan);let[t,n,o]=this.slots;t.start.springConfig.alpha_L=0,o.end.springConfig.alpha_R=0,this.stretch(n.start,"L"),this.stretch(n.end,"R");for(let r of this.slots)e.registerHorizontalLayoutHook(r.start,r.end,s=>$c(s,r===n))}alignHead(){let e=new Map;for(let o of this.members){if(!_(o))continue;let r=this.sideCellOf(o.ast);if(!r)continue;let s=e.get(r);s?s.push(o):e.set(r,[o])}let[t,,n]=this.slots;this.packRows(t.ast,t.start.box.x,e),this.packRows(n.ast,n.end.box.x,e)}stretch(e,t){let n=t==="L"?"alpha_L":"alpha_R",o=t==="L"?"beta_L":"beta_R";e.springConfig[n]=e.springConfig[n]*Ps,e.springConfig[o]=e.springConfig[o]*3/Ps}packRows(e,t,n){let o=this.ast.owner.size*jc,r=e.name==="left",s=r?1:-1;for(let i of e.rows){let c=i instanceof se?i.content:[i],l=t;for(let p=r?0:c.length-1;p>=0&&p<c.length;p+=s){let u=n.get(c[p]);if(!u)continue;let m=1/0,f=-1/0;for(let h of u)m=Math.min(m,h.box.x),f=Math.max(f,h.box.x+h.box.w);let d=l-(r?m:f);for(let h of u)h.box.x+=d;for(let h of u)h.onPlaced?.();l+=s*(f-m+o)}}}sideCellOf(e){let t=e;for(;t.parent;){let n=t.parent,o=n instanceof rt?n:n instanceof se&&n.parent instanceof rt?n.parent:null;if(o?.owner===this.ast.owner)return o.name==="center"?null:t;t=n}return null}},rt=class extends we{constructor(t,n,o,r){super(t,n);this.owner=n;this.name=o;this.rows=r;for(let s of this.rows)s.parent=this}owner;name;rows;get size(){return this.owner.size}get children(){return this.rows}timeFlowModel(t){if(this.rows.length===0)return null;let n=t.getTemporalNodes(this.owner.slots[0])[0];return{mode:"parallel",children:this.rows,tracks:n.createTracks(this)}}loweringEnter(t){let n=new Gn(this);return this.name==="left"&&t.beginLoweringGroup(this.owner,n),[n]}loweringExit(){return[new Gn(this)]}addRow(t){t.parent=this,this.rows.push(t)}},Lr=class a 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:vs,unit:"px"}}]};slots;size;gap;createdBySugar=!1;get children(){return this.slots}static deSugarAtom(e,t,n){if(e[t]!=="H"||e[t+1]!==".")return null;let o=t+2;for(;o<n&&e[o]>="a"&&e[o]<="z";)o++;let r=e.slice(t+2,o);if(!Object.hasOwn(Ns,r)||e[o]!==":")return null;o++;let s=Wc(e,o,n),i=_e(e,o,s),c=e[i]==="@"||e[i]==="{",l=Ct(e,s-1,i),p=c?void 0:{start:i,end:Math.max(i,l+1)};return{next:c?o:s,node:{kind:"sugar",data:{field:r,contentSpan:p},span:{start:t,end:o},relation:a.deSugarRelation,syntaxKind:p&&r!=="signature"&&r!=="tempo"&&p.start<p.end?[{kind:"operator",span:{start:t,end:o}},{kind:"string",span:p}]:void 0}}}static deSugarRelation(e,t,n){let o=t[n++],r=o.data.field,s=n,i=o.data.contentSpan,c;if(!i){for(;s<t.length;s++){let y=t[s];if(typeof y=="number"&&(e.source[y]==="\r"||e.source[y]===`
42
+ `)||typeof y!="number"&&y.kind==="sugar"&&y.relation===a.deSugarRelation)break}let d=new re(e);d.makeNodes(t.slice(n,s)),c=d.nodes;let h=c.at(-1)?.sourceSpan.end??o.span.end;i={start:_e(e.source,o.span.end,h),end:h}}if(i.start>=i.end)throw new w("E_HEAD_EMPTY_DECLARATION","H.{field}: \u540E\u5FC5\u987B\u6709\u5185\u5BB9",o.span,{field:r});let l=e.source.slice(i.start,i.end),p=e.nodes.at(-1),u=p instanceof a&&p.createdBySugar?p:new a(o.span,new Map,e,null);u.createdBySugar=!0,u.slots.find(d=>d.name===Ns[r]).addRow(a.parseSugarRow(e,r,i,l,c)),u.sourceSpan.end=i.end,u!==p&&e.pushNode(u);let m=t[s];if(typeof m!="number")return s;let f=s+1;if(e.source[m]==="\r"){let d=t[f];typeof d=="number"&&e.source[d]===`
43
+ `&&f++}return f}static parseSugarRow(e,t,n,o,r){if(r!==void 0)return Hn(n,r);if(t==="signature"){let c=/^(1\s*=\s*(\S+))\s+((\d+)\s*\/\s*(\d+))$/.exec(o);if(!c)throw new w("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},p={start:n.end-c[3].length,end:n.end};return Hn(n,[new qt(l,new Map([["tonality",c[2]]]),e,null),new ht(p,new Map([["num",Number(c[4])],["den",Number(c[5])]]),e,null)])}if(t==="tempo"){let c=Number(o);if(!Number.isFinite(c)||c<=0)throw new w("E_HEAD_INVALID_TEMPO","H.tempo \u540E\u5FC5\u987B\u662F\u6B63\u6570",n);return Hn(n,[new Qt(n,new Map([["bpm",c]]),e,null)])}let s=new Map([[0,o]]),i=zc[t];return i&&(s.set("size",{value:i[0],unit:"em"}),s.set("align",i[1])),Hn(n,[new Jt(n,s,e,null)])}constructor(e,t,n,o=null){super(e,o),this.size=n.variables.fontsize,this.gap=n.length2px(this.getArgValue(t,n)[3]);let r=(s,i)=>{let c=t.get(s)??t.get(i);return c instanceof we?c instanceof se?c.content:[c]:[]};this.slots=[new rt(e,this,"left",r("left",0)),new rt(e,this,"center",r("center",1)),new rt(e,this,"right",r("right",2))]}loweringExit(e){let t=e.endLoweringGroup(this);t.slots=this.slots.map(n=>{let[o,r]=e.getTemporalNodes(n);return{ast:n,start:o,end:r}}),t.slots[2].end.onTimeState=()=>t.validateDuration();for(let n of t.members)if(n.addon?.breakBefore)throw new w("E_HEAD_INTERNAL_BREAK","@head \u7684\u5185\u90E8\u4E0D\u80FD\u6362\u884C\u6216\u6362\u9875\uFF1B\u7B2C\u4E00\u5C42\u5185\u5BB9\u5DF2\u7ECF\u8868\u793A\u89C6\u89C9\u884C",n.ast.sourceSpan);return[]}toString(e){let t=this.slots.filter(n=>n.rows.length>0).map(n=>{let o=n.rows.map(r=>` ${r.toString(e).replaceAll(`
42
44
  `,`
43
45
  `)}`).join(`
44
46
  `);return` ${n.name}={
45
47
  ${o}
46
- }`});return this.gap!==Bs&&t.push(` gap=${this.gap}px`),`@head(
48
+ }`});return this.gap!==vs&&t.push(` gap=${this.gap}px`),`@head(
47
49
  ${t.join(`,
48
50
  `)}
49
- )`}},kr=Nr;var vr=class a extends E{static def={name:["br"],description:"\u6362\u884C",details:`~~~jpfun
50
- 1 2 @br() 3 4
51
+ )`}},Cr=Lr;var Ar=class a extends P{static def={name:["br"],description:"\u6362\u884C",details:`~~~jpfun
52
+ @set(br.gap=1.5em)
53
+ 1 2 @br() 3 4 @br(3em) 5 6
51
54
  ~~~
52
55
 
53
- \`@br()\` \u6362\u5230\u4E0B\u4E00\u884C\uFF0C\`@br(2)\` \u7A7A\u51FA\u4E00\u884C\u518D\u7EE7\u7EED
56
+ \`@br()\` \u6362\u5230\u4E0B\u4E00\u884C\uFF0C\u8FDE\u5199 \`@br() @br()\` \u53E0\u52A0\u4E24\u6BB5\u884C\u8DDD\uFF1B\u7528 \`@set(br.gap=...)\` \u8BBE\u7F6E\u540E\u7EED\u9ED8\u8BA4\u884C\u8DDD
54
57
 
55
- **\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(e,t,n,o){if(o>0||e[t]!==`
56
- `||e[Lt(e,t-1)]!==`
57
- `)return null;let r=t+1,s=r;for(;(s=Pe(e,s,n))<n&&e[s]===`
58
- `;)r=++s;return{next:r,node:{kind:"call",typed:!0,name:"br",args:new Map,span:{start:t,end:r}}}}offset;loweringEnter(e){e.deferFinalize(a.loweringFinalize);let t=new W;return t.ast=this,t.mergeKey=-1,t.addon={breakBefore:this.offset},[t]}static loweringFinalize(e){let t=new V,n=new V,o=null;for(let r of e.columns){if(o&&t.compare(r[0].t)>0&&r.some(s=>(s.addon?.breakBefore??0)>0))throw O.error.BreakInsideEvent(o.ast.sourceSpan);for(let s of r)s.T.isZero()||(n.copyFrom(s.t).add(s.T),(!o||n.compare(t)>0)&&(t.copyFrom(n),o=s))}}constructor(e,t,n,o=null){super(e,o);let[r]=this.getArgValue(t,n);this.offset=Number.isFinite(r)?Math.max(1,Math.floor(r)):1,this.offset!==r&&n.diagnostics.push(new I("W_BR_OFFSET","@br \u7684 offset \u5FC5\u987B\u662F\u5927\u4E8E\u7B49\u4E8E 1 \u7684\u6574\u6570\uFF0C\u5DF2\u88AB\u4FEE\u6B63\u4E3A {offset}",this.sourceSpan,{offset:this.offset}))}toString(){return`@br(${this.offset})`}},Qt=vr;function Dn(a){throw new w("E_NOTE_TRANSFORM","\u65E0\u6CD5\u5B89\u5168\u6539\u5199\u6B64\u97F3\u7B26\u7684\u97F3\u9AD8",a)}function Cc(a,e){let t=e==="to-absolute"||e!=="to-relative"&&Le.includes(a.ast.name),n=a.resolvedMidi+(e==="semitone-up"?1:e==="semitone-down"?-1:0),o=Ct(a.keySignature);[n,o,a.ast.octave,a.ast.jeOctaveOffset].every(Number.isSafeInteger)||Dn(a.ast.sourceSpan);let r=e==="semitone-down"?$t:Wt,s,i,c;if(e==="to-absolute"){let l=Le.indexOf(a.keySignature[0]),p=Number(a.ast.name)-1;s=Le[(l+p)%7];let u=Fn(o-$e[Le[l]]);c=Math.floor((o-u)/12)-1+Math.floor((l+p)/7)+a.ast.octave+a.ast.jeOctaveOffset,i=Bn(n-((c+1)*12+$e[s]))}else if(e==="to-relative"){let l=a.ast,p=Yt(l.name,l.acc,l.octave+l.jeOctaveOffset,a.keySignature);p||Dn(l.sourceSpan),{renderName:s,renderAcc:i,renderOctave:c}=p}else{let l=t?n:n-o,p=r[We(l)];s=t?p[0]:String(Le.indexOf(p[0])+1),i=p.slice(1),c=Math.floor(l/12)-(t?1:0)}return{name:s,acc:i,octave:c-a.ast.jeOctaveOffset,absolute:t}}function Is(a,e){for(let t=e.parent;t;t=t.parent){let o=Tt(a,t.sourceSpan.start,t.sourceSpan.end)?.args.find(s=>s.valueSpan.start<=e.sourceSpan.start&&s.valueSpan.end>=e.sourceSpan.end);if(!o)continue;let r=0;for(let s=o.valueSpan.start;s<e.sourceSpan.start;s++)if(a[s]==='"'){let i=ae(a,s,o.valueSpan.end);i>=0&&(s=i)}else a[s]==="{"?r++:a[s]==="}"&&r--;return r===0}return!1}function Ds({name:a,acc:e,octave:t,absolute:n},o=!0,r=!0){let s=o?e:"",i=r?n?String(t):t<0?",".repeat(-t):"'".repeat(t):"";return n?a+s+i:s+a+i}function Jt(a,e,t,n,o){let r=e.slice(n.start,n.end);r!==o&&(r!==t.slice(n.start,n.end)&&Dn(n),a.push({span:n,text:o}))}function Vs(a,e,t,n,o,r=[]){let s=new Map;t.args.forEach((y,d)=>{y.valueSpan.start<y.valueSpan.end&&s.set(wt(e,y)??d,y.valueSpan)});let i=s.get("name")??s.get(0),c=s.get("acc")??s.get(1),l=s.get("octave")??s.get(2),p=[],u=(y,d)=>!y||y.includes(",")||d&&a[d.start]==='"'?ee(y):y,m=Ds(n,!c&&!o,!l);if(i?Jt(r,a,e,i,u(m,i)):p.push(`name=${u(m)}`),c?Jt(r,a,e,c,u(n.acc,c)):o&&p.push(`acc=${ee(n.acc)}`),l&&Jt(r,a,e,l,String(n.octave)),p.length){let y=t.closeParenSpan.start,d=e.slice(t.openParenSpan.end,y).trimEnd();Jt(r,a,e,{start:y,end:y},(d?d.endsWith(",")?" ":", ":"")+p.join(", "))}return r}function Pr(a,e,t,n){let{maskedSource:o}=St(a),r=[],s=[];for(let i of e){let{ast:c}=i,l=c.sourceSpan,p=Tt(o,l.start,l.end),u=p?.span.end===l.end&&p.closeParenSpan,m=t==="to-absolute"&&Le.includes(c.name)||t==="to-relative"&&/^[1-7]$/.test(c.name);if(u||s.push({span:l,text:a.slice(l.start,l.end)}),n&&!n.some(g=>g.start<=l.start&&g.end>=l.end)||i.resolvedMidi===null||m)continue;let y=Cc(i,t);if(u){Vs(a,o,p,y,c.hasDefaultAcc,r);continue}let d=Ds(y);d.includes(",")&&Is(o,c)&&(d=`{${d}}`),s[s.length-1].text=d}s.sort((i,c)=>i.span.start-c.span.start);for(let i=0;i<s.length-1;i++){let c=s[i],l=s[i+1];if(c.span.end!==l.span.start||c.text.endsWith("}"))continue;let p=c.text+l.text,u=je(p,0,p.length,!1);(!u||u.next!==c.text.length)&&(c.text!==a.slice(c.span.start,c.span.end)?c.text+=" ":l.text=" "+l.text)}for(let i of s)Jt(r,a,o,i.span,i.text);r.sort((i,c)=>i.span.start-c.span.start);for(let i=1;i<r.length;i++)r[i-1].span.end>r[i].span.start&&Dn(r[i].span);return r}function Ac(a,e,t,n){let o=e.diagnostics.find(i=>i instanceof w);if(o)throw o;let r=[...e.astToTemporal.values()].flat().filter(i=>i instanceof Vn),s=e.diagnostics.find(i=>r.some(c=>i.span.start<c.ast.sourceSpan.end&&i.span.end>c.ast.sourceSpan.start));if(s)throw s;return Pr(a,r,t,n)}var Er="note.jeOctaveOffset",_r=class extends E{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(e,t,n){let o=0;switch(e[t]){case"(":case"]":o=-1;break;case"[":case")":o=1;break}if(o)return{next:t+1,node:{kind:"sugar",data:{jeOffset:o},span:{start:t,end:t+1},syntaxKind:"punctuation"}};let r=je(e,t,n,!1);if(!r)return null;let s=new Map;s.set("name",r.name),r.octave!==null&&s.set("octave",r.octave),s.set("acc",r.acc??"");let i={kind:"call",typed:!0,name:"note",args:s,span:{start:t,end:r.next},syntaxKind:"atom"};return{next:r.next,node:i}}static deSugarRelation(e,t,n){let o=t[n],r=o.data?.jeOffset;return typeof r!="number"?null:(e.variables[Er]=(e.variables[Er]??0)+r,e.nodes.push(new pe(o.span)),n+1)}labelable(){return this}loweringEnter(){return[new Vn(this)]}name;octave;acc;color;size;font;weight;jeOctaveOffset;hasDefaultAcc;constructor(e,t,n,o=null){super(e,o),this.hasDefaultAcc=!!n.variables["note.acc"],[this.name,this.acc,this.octave,this.color]=this.getArgValue(t,n),this.font=n.variables.numberfont,this.weight=n.variables.numberweight,this.size=n.variables.fontsize;let r=je(this.name);if(r instanceof O)throw r.span=e,r;if(r.next!==this.name.length)throw new w("E_WRONG_NOTE_NAME",'\u51FD\u6570 @note \u7684\u53C2\u6570 [0]:"name" \u683C\u5F0F\u9519\u8BEF: \u65E0\u6CD5\u89E3\u6790\u5C3E\u90E8 "{tail}"',e,{tail:this.name.slice(r.next)});this.name=r.name==="X"?"9":r.name==="Z"?"0":r.name;let s=t.get("octave")??t.get(2);if(s!==void 0){if(r.octave!==null&&r.octave!=s)throw new w("E_NOTE_OCTAVE_CONFLICT",'\u51FD\u6570 @note \u7684\u53C2\u6570 "octave" \u4E0E\u97F3\u7B26\u540D\u79F0\u4E2D\u7684\u516B\u5EA6\u4FE1\u606F\u51B2\u7A81: {inputOctave} != {noteOctave}',e,{inputOctave:String(s),noteOctave:r.octave})}else r.octave!==null?this.octave=r.octave:r.absOctave||(this.octave=0);this.jeOctaveOffset=n.variables[Er]??0,r.acc!==null&&(this.acc=r.acc+this.acc)}toString(){return`@n(${this.name}, ${this.acc||'""'}, ${this.octave}, ${this.color})`}},Rr=_r,Nc={8:"",9:"X"},Vn=class extends W{resolvedMidi=null;keySignature=Ze;transposeDiatonic;name;acc;octave;accidentals=[];numberStyle;numberY=0;constructor(e){super(),this.ast=e,this.T.set(1),this.mergeKey=Se,this.name=e.name,this.acc=e.acc,this.octave=e.octave+e.jeOctaveOffset,this.numberStyle={fontSize:e.size,fontFamily:e.font,fontWeight:e.weight,textAlign:"center",fill:e.color},this.initLayoutBox()}prepareLayout(e){let{size:t,color:n}=this.ast,o=e.textMeasurer.measureText("0",this.numberStyle);this.numberY=o.baseline;let{placed:r,right:s}=Kt(this.acc,t,0,this.numberY);this.accidentals=r,this.box.w=s+o.w,this.box.h=o.h,this.box.anchor=s+o.w/2,this.box.visualAxis=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:0},this.ports["decoration.below"]={x:this.box.anchor,y:this.numberY+t*.04},this.ports.dot={x:this.box.w,y:o.h*.64};let i=Math.abs(this.octave);if(i===0)return;let c=this.octave>0,l=t*.075,p=t*.08,u=l*2+p,m={fill:n},y=0,d=i*l*2+(i-1)*p,g={[c?"above":"below"]:{order:100,gap:p,height:d,place:f=>{y=f}},paint:f=>{for(let x=0;x<i;x++){let h=c?y+d-l-x*u:y+l+x*u;f.drawCircle(this.box.x+this.box.anchor,this.box.y+h,l,m)}}};this.decorations.push(g)}finalizeLayout(){this.ports.lyric={x:this.box.anchor,y:this.box.h},this.ports["tie.top"]={x:this.box.anchor,y:te(this,!0).y-this.box.y-this.ast.size*.1}}paint(e){let t=this.ast.color;for(let o of this.accidentals)Ut(e,o,this.box,t);let n=Nc[this.name]??this.name;n&&e.drawText(n,this.box.x+this.box.anchor,this.box.y+this.numberY,this.numberStyle)}onTimeState(e){let t=this.keySignature=e.keySignature;if(this.playbackState={bpm:e.bpm,velocity:e.velocity,program:e.program},this.resolvedMidi=Mn(this.name,this.acc,this.octave,t),this.name>="0"&&this.name<="9")(this.name==="0"||this.name>="8")&&(this.octave=0,this.acc="");else{let n=Yt(this.name,this.acc,this.octave,t);n&&(this.name=n.renderName,this.acc=n.renderAcc,this.octave=n.renderOctave)}this.transposeDiatonic=xr(this.name,this.octave,t)}emitPlayback(e){let t=this.ast.name==="9",n=t?37:this.resolvedMidi,o=t?0:this.playbackState?.pitchShift??0,r=this.transposeDiatonic;if(!(e.end.compare(e.start)<=0)){if(n===null){e.span({start:e.start,end:e.end});return}e.note({start:e.start,end:e.end,midi:n+o,velocity:this.playbackState?.velocity??lt,...t?{percussion:!0}:{transpose:o&&r?s=>r(s)+o:r}})}}};var Mr=class a extends E{static def={name:["ottava"],description:"\u516B\u5EA6\u53F7",details:"~~~jpfun\n1@a 2 3 -@b | 4\n@ottava(a, b, 1)\n~~~\n`shift` \u4E3A\u975E\u96F6\u6574\u6570\u516B\u5EA6\u6570\uFF0C\u6B63\u6570\u5728\u4E0A\u65B9\u6807\u9AD8\u516B\u5EA6\u53F7\uFF0C\u8D1F\u6570\u5728\u4E0B\u65B9\u6807\u4F4E\u516B\u5EA6\u53F7\uFF0C\u9ED8\u8BA4 `1`\u3002\u6807\u7B7E\u4F7F\u7528\u8C31\u9762\u6570\u5B57\u5B57\u4F53\u7684\u659C\u4F53\u3002",allowExtraArgs:!1,args:[{description:"\u8D77\u70B9\u6807\u7B7E",type:"label",default:null},{description:"\u7EC8\u70B9\u6807\u7B7E",type:"label",default:null},{name:"shift",description:"\u975E\u96F6\u6574\u6570\u516B\u5EA6\u6570\uFF0C\u6B63\u6570\u4E3A\u9AD8\uFF0C\u8D1F\u6570\u4E3A\u4F4E",type:"number",default:1}]};static loweringFinalize(e){let t=new Map;for(let n of e.attachments){if(!(n instanceof Hn))continue;let[o,r]=n.endPoints,s={start:o.t,end:r.t.clone().add(r.T),shift:n.ast.shift*12},i=t.get(o.track);i?i.push(s):t.set(o.track,[s])}if(t.size!==0){for(let n of t.values())n.sort((o,r)=>o.start.compare(r.start));for(let n of e.astToTemporal.values())for(let o of n){if(!o.playbackState)continue;let r=o.rootHost,s=t.get(r.track);if(!s)continue;let i=0;for(let c of s){if(r.t.compare(c.start)<0)break;r.t.compare(c.end)<0&&(i+=c.shift)}i!==0&&(o.playbackState={...o.playbackState,pitchShift:(o.playbackState.pitchShift??0)+i})}}}from;to;shift;size;font;constructor(e,t,n,o=null){super(e,o);let[r,s,i]=this.getArgValue(t,n);if(!Number.isSafeInteger(i)||i===0||!Number.isSafeInteger(i*12))throw new w("E_OTTAVA_INVALID_SHIFT","@ottava \u7684 shift \u5FC5\u987B\u4E3A\u53EF\u5B89\u5168\u6362\u7B97\u4E3A\u534A\u97F3\u7684\u975E\u96F6\u6574\u6570",e);this.from=r,this.to=s,this.shift=i,this.size=n.variables.fontsize,this.font=n.variables.numberfont}loweringEnter(e){let t=e.getTemporalNodes(this.from).at(0)?.rootHost,n=e.getTemporalNodes(this.to).at(-1)?.rootHost;if(!t||!n||!M(t)||!M(n))return e.diagnostics.push(O.warning.UnresolvedEndpoint("ottava",this.sourceSpan)),[];if(t.track!==n.track)throw new w("E_OTTAVA_CROSS_TRACK","@ottava \u7684\u4E24\u4E2A\u7AEF\u70B9\u5FC5\u987B\u4F4D\u4E8E\u540C\u4E00\u97F3\u8F68",this.sourceSpan);return e.addAttachment(new Hn(this,t,n)),e.deferFinalize(a.loweringFinalize),[]}toString(e){let t=n=>(n instanceof E?n.label:void 0)??n.toString(e);return`@ottava(${t(this.from)}, ${t(this.to)}, ${this.shift})`}},Fr=Mr,Hn=class{constructor(e,t,n){this.ast=e;this.endPoints=(t.t.compare(n.t)||t.order-n.order)>0?[n,t]:[t,n]}ast;kind="ottava";layer="foreground";endPoints;get sourceSpan(){return this.ast.sourceSpan}createGeometry(e){let[t,n]=this.endPoints,o=t.layoutLine,r=n.layoutLine;if(e.lines[o].columnOf(t)<0||e.lines[r].columnOf(n)<0)return{regions:[],paint(){}};let{size:s,font:i,shift:c}=this.ast,l=c>0,p=t.track,u=Math.max(.75,s*.035),m={stroke:"#000",strokeWidth:u},y=s*.22,d=y+s*.14,g=u/2,f=s*.45,x=s*.2,h=s*.08,b=String(Math.abs(c)*7+1),S={fontSize:s*.6,fontFamily:i,fontStyle:"italic",textAlign:"left",fill:"#000"},T=e.textMeasurer.measureText(b,S),L=l?-g:g-T.h,C=L+T.baseline,N=Array.from({length:r-o+1},(P,k)=>{let B=o+k,_=B===o,v=B===r,R=_?t.box.x+(t.ports["body.left"]?.x??0):Te(e,B,p),D=v?n.box.x+(n.ports["body.right"]?.x??n.box.w):we(e,B);R>D&&([R,D]=[D,R]);let K=_?R+T.w+h:R,X=(G,$,U,xe)=>({x:G,y:$,w:U,h:xe,line:B,track:p}),ne=K<D?[X(K-g,-g,D-K+u,u)]:[];_&&ne.push(X(R,L,T.w,T.h)),v&&ne.push(X(D-g,l?-g:-f-g,u,f+u));let J=X(0,0,0,0);mt(J,ne);let H=l?1/0:-1/0;for(let G of ne)for(let[$,U]of e.getHorizontalExtents(B,G.x,G.x+G.w)){let xe=e.getVisualAxis(B,$);H=l?Math.min(H,xe+U.top-x-G.y-G.h):Math.max(H,xe+U.bottom+x-G.y)}if(!Number.isFinite(H)){let G=e.getRangeExtents(B,_||v?this.endPoints:void 0,p),$=e.getVisualAxis(B,p);H=l?$+(G?.top??0)-x-(J.y+J.h):$+(G?.bottom??0)+x-J.y}for(let G of ne)G.y+=H;return J.y+=H,{left:R,right:D,lineStart:K,lineY:H,first:_,last:v,parts:ne,region:J}});return{regions:N.map(P=>P.region),occupancy:N.flatMap(P=>P.parts),paint(P){for(let k of N){let{left:B,right:_,lineStart:v,lineY:R,first:D,last:K}=k;for(let X=v;X<_;X+=d)P.drawLine(X,R,Math.min(X+y,_),R,m);D&&P.drawText(b,B,R+C,S),K&&P.drawLine(_,R,_,R+(l?f:-f),m)}}}}};var Br=Number.MAX_VALUE,At=new WeakMap,Or=class a extends E{static def={name:["rest"],description:"\u591A\u5C0F\u8282\u4F11\u6B62",details:`~~~jpfun
58
+ **\u7B80\u5199**\uFF1A\u4EC5\u5728\u9876\u5C42\uFF0C\u8FDE\u7EED\u81F3\u5C11\u4E24\u4E2A\u6362\u884C\u8868\u793A\u6362\u884C`,allowExtraArgs:!1,args:[{name:"gap",description:"\u4E0A\u4E00\u884C\u4E0B\u6CBF\u5230\u4E0B\u4E00\u884C\u4E3B\u65CB\u5F8B\u4E0A\u6CBF\u7684\u6807\u51C6\u95F4\u8DDD\uFF1B\u4E0B\u4E00\u884C\u9876\u90E8\u5916\u6269\u8BB0\u53F7\u4F18\u5148\u501F\u7528\u8FD9\u6BB5\u95F4\u8DDD",type:"length",default:{value:1,unit:"em"}},{name:"minGap",description:"\u9876\u90E8\u5916\u6269\u8BB0\u53F7\u501F\u7528\u95F4\u8DDD\u540E\uFF0C\u4E0E\u4E0A\u4E00\u884C\u4FDD\u7559\u7684\u6700\u5C0F\u95F4\u8DDD",type:"length",default:{value:.4,unit:"em"}}]};static deSugarAtom(e,t,n,o){if(o>0||e[t]!==`
59
+ `||e[Ct(e,t-1)]!==`
60
+ `)return null;let r=t+1,s=r;for(;(s=_e(e,s,n))<n&&e[s]===`
61
+ `;)r=++s;return{next:r,node:{kind:"call",typed:!0,name:"br",args:new Map,span:{start:t,end:r}}}}lineGap;loweringEnter(e){e.deferFinalize(a.loweringFinalize);let t=new H;return t.ast=this,t.mergeKey=-1,t.addon={breakBefore:this.lineGap},[t]}static loweringFinalize(e){let t=new I,n=new I,o=null;for(let r of e.columns){if(o&&t.compare(r.t)>0&&r.some(s=>s.addon?.breakBefore))throw M.error.BreakInsideEvent(o.ast.sourceSpan);for(let s of r)s.T.isZero()||(n.copyFrom(s.t).add(s.T),(!o||n.compare(t)>0)&&(t.copyFrom(n),o=s))}}constructor(e,t,n,o=null){super(e,o);let[r,s]=this.getArgValue(t,n).map(i=>n.length2px(i));this.lineGap={gap:r,minGap:s}}toString(){return`@br(gap=${this.lineGap.gap}px, minGap=${this.lineGap.minGap}px)`}},en=Ar;function zn(a){throw new w("E_NOTE_TRANSFORM","\u65E0\u6CD5\u5B89\u5168\u6539\u5199\u6B64\u97F3\u7B26\u7684\u97F3\u9AD8",a)}function jn(a,e){return!a||a.some(t=>t.start<=e.start&&t.end>=e.end)}function Uc(a,e){let t=e==="to-absolute"||e!=="to-relative"&&ke.includes(a.ast.name),n=a.resolvedMidi+(e==="semitone-up"?1:e==="semitone-down"?-1:0),o=At(a.keySignature);[n,o,a.ast.octave,a.ast.jeOctaveOffset].every(Number.isSafeInteger)||zn(a.ast.sourceSpan);let r=e==="semitone-down"?Kt:Yt,s,i,c;if(e==="to-absolute"){let l=ke.indexOf(a.keySignature[0]),p=Number(a.ast.name)-1;s=ke[(l+p)%7];let u=In(o-$e[ke[l]]);c=Math.floor((o-u)/12)-1+Math.floor((l+p)/7)+a.ast.octave+a.ast.jeOctaveOffset,i=ot(n-((c+1)*12+$e[s]))}else if(e==="to-relative"){let l=a.ast,p=Zt(l.name,l.acc,l.octave+l.jeOctaveOffset,a.keySignature);p||zn(l.sourceSpan),{renderName:s,renderAcc:i,renderOctave:c}=p,i=a.displayAcc??i}else{let l=t?n:n-o,p=r[We(l)];s=t?p[0]:String(ke.indexOf(p[0])+1),i=p.slice(1),c=Math.floor(l/12)-(t?1:0)}return{name:s,acc:i,octave:c-a.ast.jeOctaveOffset,absolute:t}}function Es(a,e){for(let t=e.parent;t;t=t.parent){let o=Lt(a,t.sourceSpan.start,t.sourceSpan.end)?.args.find(s=>s.valueSpan.start<=e.sourceSpan.start&&s.valueSpan.end>=e.sourceSpan.end);if(!o)continue;let r=0;for(let s=o.valueSpan.start;s<e.sourceSpan.start;s++)if(a[s]==='"'){let i=ie(a,s,o.valueSpan.end);i>=0&&(s=i)}else a[s]==="{"?r++:a[s]==="}"&&r--;return r===0}return!1}function _s({name:a,acc:e,octave:t,absolute:n},o=!0,r=!0){let s=o?e:"",i=r?n?String(t):t<0?",".repeat(-t):"'".repeat(t):"";return n?a+s+i:s+a+i}function tn(a,e,t,n,o){let r=e.slice(n.start,n.end);r!==o&&(r!==t.slice(n.start,n.end)&&zn(n),a.push({span:n,text:o}))}function Rs(a,e,t,n,o,r=[]){let s=new Map;t.args.forEach((d,h)=>{d.valueSpan.start<d.valueSpan.end&&s.set(nt(e,d)??h,d.valueSpan)});let i=s.get("name")??s.get(0),c=s.get("acc")??s.get(1),l=s.get("octave")??s.get(2),p=[],u=(d,h)=>!d||d.includes(",")||h&&a[h.start]==='"'?te(d):d,m=i&&/!"?$/.test(a.slice(i.start,i.end))?"!":"",f=_s(n,!c&&!o,!l)+m;if(i?tn(r,a,e,i,u(f,i)):p.push(`name=${u(f)}`),c?tn(r,a,e,c,u(n.acc,c)):o&&p.push(`acc=${te(n.acc)}`),l&&tn(r,a,e,l,String(n.octave)),p.length){let d=t.closeParenSpan.start,h=e.slice(t.openParenSpan.end,d).trimEnd();tn(r,a,e,{start:d,end:d},(h?h.endsWith(",")?" ":", ":"")+p.join(", "))}return r}function Wn(a,e,t,n,o){let{maskedSource:r}=wt(a),s=[],i=[];for(let c of e){let{ast:l}=c,p=l.sourceSpan,u=Lt(r,p.start,p.end),m=u?.span.end===p.end&&u.closeParenSpan,f=t==="to-absolute"&&ke.includes(l.name)||t==="to-relative"&&/^[1-7]$/.test(l.name);m||i.push({span:p,text:a.slice(p.start,p.end)});let d=o?.get(l),h=jn(n,p)&&c.resolvedMidi!==null&&!f;if(!h&&d===void 0)continue;let y=h?Uc(c,t):{name:l.name,acc:l.acc,octave:l.octave,absolute:!1};if(d!==void 0&&(y.acc=d),m){Rs(a,r,u,y,l.hasDefaultAcc,s);continue}let g=_s(y)+(a[p.end-1]==="!"?"!":"");g.includes(",")&&Es(r,l)&&(g=`{${g}}`),i[i.length-1].text=g}i.sort((c,l)=>c.span.start-l.span.start);for(let c=0;c<i.length-1;c++){let l=i[c],p=i[c+1];if(l.span.end!==p.span.start||l.text.endsWith("}"))continue;let u=l.text+p.text,m=je(u,0,u.length,!1);(!m||m.next!==l.text.length)&&(l.text!==a.slice(l.span.start,l.span.end)?l.text+=" ":p.text=" "+p.text)}for(let c of i)tn(s,a,r,c.span,c.text);s.sort((c,l)=>c.span.start-l.span.start);for(let c=1;c<s.length;c++)s[c-1].span.end>s[c].span.start&&zn(s[c].span);return s}function Yc(a,e,t,n,o){let r=Fs(e),s=r.find(i=>i.ast.carry&&/^[1-7]$/.test(i.ast.name));if(!t.startsWith("semitone")||!s)return Wn(a,r,t,n);if(!o)throw new w("E_NOTE_TRANSFORM","\u4E50\u8C31\u5F00\u542F\u4E86 carry\uFF0C\u5347\u964D\u534A\u97F3\u9700\u8981\u91CD\u65B0\u964D\u7EA7",s.ast.sourceSpan);return Kc(a,r,t,n,o)}function Fs(a){let e=a.diagnostics.find(o=>o instanceof w);if(e)throw e;let t=[...a.astToTemporal.values()].flat().filter(o=>o instanceof $n),n=a.diagnostics.find(o=>t.some(r=>o.span.start<r.ast.sourceSpan.end&&o.span.end>r.ast.sourceSpan.start));if(n)throw n;return t}function Ms(a){let e=new Map;for(let t of a)e.set(t.ast,[...e.get(t.ast)??[],t]);return[...e.values()].sort((t,n)=>t[0].ast.sourceSpan.start-n[0].ast.sourceSpan.start)}function Kc(a,e,t,n,o){let r=t==="semitone-up"?1:-1,s=Ms(e),i=s.map(p=>p.map(u=>u.resolvedMidi===null?null:u.resolvedMidi+(jn(n,u.ast.sourceSpan)?r:0)));function c(p=s[0][0].ast.sourceSpan){throw new w("E_NOTE_TRANSFORM","\u65E0\u6CD5\u5728\u4FDD\u6301\u5176\u4ED6\u97F3\u9AD8\u4E0D\u53D8\u7684\u524D\u63D0\u4E0B\u5347\u964D\u534A\u97F3",p)}let l=new Map;for(let p=0;p<=s.length;p++){let u=Wn(a,e,t,n,l),m;try{m=Ms(Fs(o(Xc(a,u))))}catch{return c()}m.length!==s.length&&c();let f=[];for(let[h,y]of m.entries()){let g=s[h][0].ast;y.length!==i[h].length&&c(g.sourceSpan);for(let[x,b]of y.entries()){let S=i[h][x];b.resolvedMidi!==S&&((S===null||!b.carrySlot||!/^[1-7]$/.test(b.ast.name)||l.has(g))&&c(g.sourceSpan),f.push([g,b,S,b.carrySlot]))}}if(!f.length)return u;let d=new Map;for(let[h,y,g,{bar:x,key:b}]of f.sort((S,T)=>S[3].seq-T[3].seq)){let S=d.get(x)??new Set;if(S.has(b))continue;d.set(x,S.add(b));let T=g-Xt(y.name,"",y.octave,y.keySignature),L=ot(T)||"n";(l.get(h)??L)!==L&&c(h.sourceSpan),l.set(h,L)}}return c()}function Xc(a,e){for(let t of[...e].reverse())a=a.slice(0,t.span.start)+t.text+a.slice(t.span.end);return a}var kr="note.jeOctaveOffset",Nr=class a 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- \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`\n- \u672B\u5C3E\u52A0 `!` \u7B49\u4EF7\u4E8E `force=true`\uFF1A`C4!` \u7B49\u4EF7\u4E8E `@note(C, "", 4, force=true)`',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\uFF0C\u672B\u5C3E\u7684 `!` \u7B49\u4EF7\u4E8E `force=true`\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"},{name:"carry",namedOnly:!0,description:"\u5C0F\u8282\u5185\u53D8\u97F3\u5EF6\u7EED\uFF1A\u6570\u5B57\u97F3\u540D\u6309\u672C\u5C0F\u8282\u524D\u6587\u8BFB\u8C31\uFF0C\u5B57\u6BCD\u97F3\u540D\u81EA\u52A8\u7701\u7565\u6216\u8865\u8BB0\u53D8\u97F3\u53F7",type:"boolean",default:!1},{name:"force",description:"\u5F3A\u5236\u663E\u793A\u5B9E\u9645\u751F\u6548\u7684\u53D8\u97F3\u53F7\uFF0C\u4E0D\u6539\u53D8\u97F3\u9AD8\uFF0C\u6CA1\u6709\u53D8\u97F3\u65F6\u663E\u793A\u8FD8\u539F\u53F7\uFF1B\u7B80\u5199\u4E3A\u97F3\u540D\u672B\u5C3E\u7684 `!`",type:"boolean",default:!1}]};static deSugarAtom(e,t,n){let o=0;switch(e[t]){case"(":case"]":o=-1;break;case"[":case")":o=1;break}if(o)return{next:t+1,node:{kind:"sugar",data:o,span:{start:t,end:t+1},syntaxKind:"punctuation",relation:a.deSugarRelation}};let r=je(e,t,n,!1);if(!r)return null;let s=r.next<n&&e[r.next]==="!",i=r.next+(s?1:0),c=new Map;return c.set("name",r.name),r.octave!==null&&c.set("octave",r.octave),c.set("acc",r.acc??""),s&&c.set("force",!0),{next:i,node:{kind:"call",typed:!0,name:"note",args:c,span:{start:t,end:i},syntaxKind:"atom"}}}static deSugarRelation(e,t,n){let o=t[n];return e.variables[kr]=(e.variables[kr]??0)+o.data,e.nodes.push(new pe(o.span)),n+1}labelable(){return this}loweringEnter(){return[new $n(this)]}name;octave;acc;color;carry;force;size;font;weight;jeOctaveOffset;hasDefaultAcc;hasDefaultCarry;hasDefaultForce;constructor(e,t,n,o=null){if(super(e,o),this.hasDefaultAcc=!!n.variables["note.acc"],this.hasDefaultCarry=!!n.variables["note.carry"],this.hasDefaultForce=!!n.variables["note.force"],[this.name,this.acc,this.octave,this.color,this.carry,this.force]=this.getArgValue(t,n),this.font=n.variables.numberfont,this.weight=n.variables.numberweight,this.size=n.variables.fontsize,this.name.endsWith("!")){if((t.get("force")??t.get(4))===!1)throw new w("E_NOTE_FORCE_CONFLICT",'\u51FD\u6570 @note \u7684\u53C2\u6570 "force=false" \u4E0E\u97F3\u7B26\u540D\u79F0\u672B\u5C3E\u7684 "!" \u51B2\u7A81',e);this.name=this.name.slice(0,-1),this.force=!0}let r=je(this.name);if(r instanceof M)throw r.span=e,r;if(r.next!==this.name.length)throw new w("E_WRONG_NOTE_NAME",'\u51FD\u6570 @note \u7684\u53C2\u6570 [0]:"name" \u683C\u5F0F\u9519\u8BEF: \u65E0\u6CD5\u89E3\u6790\u5C3E\u90E8 "{tail}"',e,{tail:this.name.slice(r.next)});this.name=r.name==="X"?"9":r.name==="Z"?"0":r.name;let s=t.get("octave")??t.get(2);if(s!==void 0){if(r.octave!==null&&r.octave!=s)throw new w("E_NOTE_OCTAVE_CONFLICT",'\u51FD\u6570 @note \u7684\u53C2\u6570 "octave" \u4E0E\u97F3\u7B26\u540D\u79F0\u4E2D\u7684\u516B\u5EA6\u4FE1\u606F\u51B2\u7A81: {inputOctave} != {noteOctave}',e,{inputOctave:String(s),noteOctave:r.octave})}else r.octave!==null?this.octave=r.octave:r.absOctave||(this.octave=0);this.jeOctaveOffset=n.variables[kr]??0,r.acc!==null&&(this.acc=r.acc+this.acc)}toString(){let e=this.carry||this.hasDefaultCarry?`, carry=${this.carry}`:"",t=this.force||this.hasDefaultForce?`, force=${this.force}`:"";return`@n(${this.name}, ${this.acc||'""'}, ${this.octave}, ${this.color}${e}${t})`}},vr=Nr,Zc={8:"",9:"X"},$n=class extends H{resolvedMidi=null;keySignature=qe;transposeDiatonic;name;acc;octave;displayAcc;carrySlot;accidentals=[];numberStyle;numberY=0;constructor(e){super(),this.ast=e,this.T.set(1),this.mergeKey=Le,this.name=e.name,this.acc=e.acc,this.octave=e.octave+e.jeOctaveOffset,this.numberStyle={fontSize:e.size,fontFamily:e.font,fontWeight:e.weight,textAlign:"center",fill:e.color},this.initLayoutBox()}prepareLayout(e){let{size:t,color:n}=this.ast,o=e.textMeasurer.measureText("0",this.numberStyle);this.numberY=o.baseline;let{placed:r,right:s}=Dn(this.displayAcc??this.acc,t,0,this.numberY);this.accidentals=r,this.box.w=s+o.w,this.box.h=o.h,this.box.anchor=s+o.w/2,this.box.visualAxis=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:0},this.ports["decoration.below"]={x:this.box.anchor,y:this.numberY+t*.04},this.ports.dot={x:this.box.w,y:o.h*.64};let i=Math.abs(this.octave);if(i===0)return;let c=this.octave>0,l=t*.075,p=t*.08,u=l*2+p,m={fill:n},f=0,d=i*l*2+(i-1)*p,h={[c?"above":"below"]:{order:100,gap:p,height:d,place:y=>{f=y}},paint:y=>{for(let g=0;g<i;g++){let x=c?f+d-l-g*u:f+l+g*u;y.drawCircle(this.box.x+this.box.anchor,this.box.y+x,l,m)}}};this.decorations.push(h)}finalizeLayout(){this.ports.lyric={x:this.box.anchor,y:this.box.h},this.ports["tie.top"]={x:this.box.anchor,y:ee(this,!0).y-this.box.y-this.ast.size*.1}}paint(e){let t=this.ast.color;for(let o of this.accidentals)Vn(e,o,this.box,t);let n=Zc[this.name]??this.name;n&&e.drawText(n,this.box.x+this.box.anchor,this.box.y+this.numberY,this.numberStyle)}onTimeState(e){let t=this.keySignature=e.keySignature;if(this.playbackState={velocity:e.velocity,program:e.program},this.resolvedMidi=Xt(this.name,this.acc,this.octave,t),this.name>="0"&&this.name<="9")(this.name==="0"||this.name>="8")&&(this.octave=0,this.acc="");else{let n=Zt(this.name,this.acc,this.octave,t);n&&(this.name=n.renderName,this.acc=n.renderAcc,this.octave=n.renderOctave)}this.transposeDiatonic=fr(this.name,this.octave,t),this.applyAccidentals(e.accidentals)}applyAccidentals(e){let t=this.resolvedMidi;t===null||!/^[1-7]$/.test(this.name)||e.read(this.track,`${this.name}:${this.octave}`,n=>{let{prior:o}=this.carrySlot=n,r=/^[1-7]$/.test(this.ast.name),s=this.ast.carry&&r&&!this.acc,i=s?o:kt(this.acc);s&&(this.resolvedMidi=t+o);let c=ot(i)||"n";return this.ast.force?this.displayAcc=c:this.ast.carry&&!r&&(this.displayAcc=i===o?"":c),this.displayAcc??this.acc?i:void 0})}emitPlayback(e){let t=this.ast.name==="9",n=t?37:this.resolvedMidi,o=t?0:this.playbackState?.pitchShift??0,r=this.transposeDiatonic;if(!(e.end.compare(e.start)<=0)){if(n===null){e.span({start:e.start,end:e.end});return}e.note({start:e.start,end:e.end,midi:n+o,velocity:this.playbackState?.velocity??pt,...t?{percussion:!0}:{transpose:o&&r?s=>r(s)+o:r}})}}};var Pr=class a extends P{static def={name:["ottava"],description:"\u516B\u5EA6\u53F7",details:"~~~jpfun\n1@a 2 3 -@b | 4\n@ottava(a, b, 1)\n~~~\n`shift` \u4E3A\u975E\u96F6\u6574\u6570\u516B\u5EA6\u6570\uFF0C\u6B63\u6570\u5728\u4E0A\u65B9\u6807\u9AD8\u516B\u5EA6\u53F7\uFF0C\u8D1F\u6570\u5728\u4E0B\u65B9\u6807\u4F4E\u516B\u5EA6\u53F7\uFF0C\u9ED8\u8BA4 `1`\u3002\u6807\u7B7E\u4F7F\u7528\u8C31\u9762\u6570\u5B57\u5B57\u4F53\u7684\u659C\u4F53\u3002",allowExtraArgs:!1,args:[{description:"\u8D77\u70B9\u6807\u7B7E",type:"label",default:null},{description:"\u7EC8\u70B9\u6807\u7B7E",type:"label",default:null},{name:"shift",description:"\u975E\u96F6\u6574\u6570\u516B\u5EA6\u6570\uFF0C\u6B63\u6570\u4E3A\u9AD8\uFF0C\u8D1F\u6570\u4E3A\u4F4E",type:"number",default:1}]};static loweringFinalize(e){let t=new Map;for(let n of e.attachments){if(!(n instanceof Un))continue;let[o,r]=n.endPoints,s={start:o.t,end:r.t.clone().add(r.T),shift:n.ast.shift*12},i=t.get(o.track);i?i.push(s):t.set(o.track,[s])}if(t.size!==0){for(let n of t.values())n.sort((o,r)=>o.start.compare(r.start));for(let n of e.astToTemporal.values())for(let o of n){if(!o.playbackState)continue;let r=o.rootHost,s=t.get(r.track);if(!s)continue;let i=0;for(let c of s){if(r.t.compare(c.start)<0)break;r.t.compare(c.end)<0&&(i+=c.shift)}i!==0&&(o.playbackState={...o.playbackState,pitchShift:(o.playbackState.pitchShift??0)+i})}}}from;to;shift;size;font;constructor(e,t,n,o=null){super(e,o);let[r,s,i]=this.getArgValue(t,n);if(!Number.isSafeInteger(i)||i===0||!Number.isSafeInteger(i*12))throw new w("E_OTTAVA_INVALID_SHIFT","@ottava \u7684 shift \u5FC5\u987B\u4E3A\u53EF\u5B89\u5168\u6362\u7B97\u4E3A\u534A\u97F3\u7684\u975E\u96F6\u6574\u6570",e);this.from=r,this.to=s,this.shift=i,this.size=n.variables.fontsize,this.font=n.variables.numberfont}loweringEnter(e){let t=e.getTemporalNodes(this.from).at(0)?.rootHost,n=e.getTemporalNodes(this.to).at(-1)?.rootHost;if(!t||!n||!_(t)||!_(n))return e.diagnostics.push(M.warning.UnresolvedEndpoint("ottava",this.sourceSpan)),[];if(t.track!==n.track)throw new w("E_OTTAVA_CROSS_TRACK","@ottava \u7684\u4E24\u4E2A\u7AEF\u70B9\u5FC5\u987B\u4F4D\u4E8E\u540C\u4E00\u97F3\u8F68",this.sourceSpan);return e.addAttachment(new Un(this,t,n)),e.deferFinalize(a.loweringFinalize),[]}toString(e){let t=n=>(n instanceof P?n.label:void 0)??n.toString(e);return`@ottava(${t(this.from)}, ${t(this.to)}, ${this.shift})`}},Er=Pr,Un=class{constructor(e,t,n){this.ast=e;this.endPoints=(t.t.compare(n.t)||t.order-n.order)>0?[n,t]:[t,n]}ast;kind="ottava";layer="foreground";endPoints;get sourceSpan(){return this.ast.sourceSpan}createGeometry(e){let[t,n]=this.endPoints,o=t.layoutLine,r=n.layoutLine;if(e.lines[o].columnOf(t)<0||e.lines[r].columnOf(n)<0)return{regions:[],paint(){}};let{size:s,font:i,shift:c}=this.ast,l=c>0,p=t.track,u=Math.max(.75,s*.035),m={stroke:"#000",strokeWidth:u},f=s*.22,d=f+s*.14,h=u/2,y=s*.45,g=s*.2,x=s*.08,b=String(Math.abs(c)*7+1),S={fontSize:s*.6,fontFamily:i,fontStyle:"italic",textAlign:"left",fill:"#000"},T=e.textMeasurer.measureText(b,S),L=l?-h:h-T.h,C=L+T.baseline,A=Array.from({length:r-o+1},(v,N)=>{let F=o+N,B=F===o,$=F===r,U=B?t.box.x+(t.ports["body.left"]?.x??0):Ce(e,F,p),E=$?n.box.x+(n.ports["body.right"]?.x??n.box.w):Ae(e,F);U>E&&([U,E]=[E,U]);let G=B?U+T.w+x:U,K=(j,q,Te,fe)=>({x:j,y:q,w:Te,h:fe,line:F,track:p}),ne=G<E?[K(G-h,-h,E-G+u,u)]:[];B&&ne.push(K(U,L,T.w,T.h)),$&&ne.push(K(E-h,l?-h:-y-h,u,y+u));let J=K(0,0,0,0);dt(J,ne);let z=e.getVisualAxis(F,p),W=l?1/0:-1/0;for(let j of ne){let q=e.getHorizontalExtents(F,j.x,j.x+j.w).get(p);q&&(W=l?Math.min(W,z+q.top-g-j.y-j.h):Math.max(W,z+q.bottom+g-j.y))}if(!Number.isFinite(W)){let j=e.getRangeExtents(F,B||$?this.endPoints:void 0,p);W=l?z+(j?.top??0)-g-(J.y+J.h):z+(j?.bottom??0)+g-J.y}for(let j of ne)j.y+=W;return J.y+=W,{left:U,right:E,lineStart:G,lineY:W,first:B,last:$,parts:ne,region:J}});return{regions:A.map(v=>v.region),occupancy:A.flatMap(v=>v.parts),paint(v){for(let N of A){let{left:F,right:B,lineStart:$,lineY:U,first:E,last:G}=N;for(let K=$;K<B;K+=d)v.drawLine(K,U,Math.min(K+f,B),U,m);E&&v.drawText(b,F,U+C,S),G&&v.drawLine(B,U,B,U+(l?y:-y),m)}}}}};var nn=class{memory=new Map;events=[];staged=[];now=[];reads=0;at(e,t){this.now.push(e);try{return t()}finally{this.now.pop()}}read(e,t,n){let o=qc(e);this.events.push({time:[...this.now],run:()=>{let r=this.scope(o),s=n({key:t,bar:r,seq:this.reads++,prior:r.get(t)??0});s!==void 0&&this.staged.push([o,t,s])}})}clear(e){this.events.push({time:[...this.now],run:()=>{if(!e)return this.memory.clear();for(let t of this.memory.keys())Qc(t,e)&&this.memory.delete(t)}})}commit(){let e=this.events.splice(0).sort((t,n)=>Bs(t.time,n.time));e.forEach(({time:t,run:n},o)=>{o>0&&Bs(e[o-1].time,t)&&this.flush(),n()}),this.flush()}flush(){for(let[e,t,n]of this.staged.splice(0))this.scope(e).set(t,n)}scope(e){let t=this.memory.get(e);return t||this.memory.set(e,t=new Map),t}};function Bs(a,e){for(let t=0;t<a.length||t<e.length;t++){let n=(a[t]??0)-(e[t]??0);if(n)return n}return 0}function qc(a){for(;a.parent&&!a.parent.groups.some(e=>e.members.includes(a));)a=a.parent;return a}function Qc(a,e){for(let t=a;t;t=t.parent)if(t===e)return!0;return!1}var on=class a{activeFinalizers=new Map;cnt=0;usedTracks=new Set;attachments=[];page;astToTemporal=new Map;activeLoweringGroups=[];diagnostics=[];setPageConfig(e){this.page=e}lowerDocument(e,t=[]){this.cnt=0,this.usedTracks.clear(),this.activeFinalizers.clear(),this.attachments=[],this.page=void 0,this.astToTemporal=new Map,this.activeLoweringGroups=[],this.diagnostics=t;let n=new tt,o=new I,r=this.trackedEvents(e,o,n);return this.solidifyColumns(r,o),this.postprocessResult({diagnostics:this.diagnostics,columns:r,attachments:this.attachments,astToTemporal:this.astToTemporal,duration:o,rootTrack:n,tracks:[...this.usedTracks],page:this.page})}solidifyColumns(e,t){let n=0;for(let m of e)m.some(f=>f.addon?.breakBefore)&&n++,m.layoutLine=n;let o={bpm:Me,velocity:pt,keySignature:qe,program:fn,accidentals:new nn},r=new Map,s=new Map,i=m=>r.get(m)??(m.parent?i(m.parent):pt),c=m=>s.get(m)??(m.parent?c(m.parent):fn),l=new I;for(let m of e){l.isZero()||m.shiftTime(l),m.bpm=o.bpm;let f;for(let d of m){o.velocity=i(d.track),o.program=c(d.track);let h=d.onTimeState?.(o);h&&!h.isZero()&&(!f||h.compare(f)>0)&&(f??=new I).copyFrom(h),r.set(d.track,o.velocity),s.set(d.track,o.program)}m.timeSignature=o.timeSignature,o.accidentals.commit(),f&&l.add(f)}if(l.isZero())return;let p=new Set(s.keys()),u=new I;t.set(0);for(let m=e.length-1;m>=0&&p.size>0;m--){let f=e[m];for(let d=f.length-1;d>=0;d--){let h=f[d];if(!p.delete(h.track))continue;let y=h.T;u.copyFrom(h.t),y.isZero()||u.add(y),u.compare(t)>0&&t.copyFrom(u)}}}beginLoweringGroup(e,t){this.activeLoweringGroups.push({owner:e,group:t})}endLoweringGroup(e){let t=this.activeLoweringGroups.pop();if(!t)throw new Error("No active lowering group to end");if(t.owner!==e)throw new Error("Lowering groups must end in reverse order");return t.group}postprocessResult(e){if(this.activeLoweringGroups.length>0)throw new Error("Lowering groups must be closed before post-processing");let t=this.activeFinalizers.size;if(t===0)return e;if(t===1)return this.activeFinalizers.keys().next().value(e),e;let n=[...this.activeFinalizers.entries()].sort((o,r)=>o[1]-r[1]);for(let[o]of n)o(e);return e}deferFinalize(e,t=0){let n=this.activeFinalizers.get(e);(n===void 0||t<n)&&this.activeFinalizers.set(e,t)}addAttachment(e){this.attachments.push(e);for(let t=this.activeLoweringGroups.length-1;t>=0;t--)this.activeLoweringGroups[t].group.onAttachment?.(e)}getTemporalNodes(e){return this.astToTemporal.get(e)??[]}isolateFromLoweringGroups(e){let t=this.activeLoweringGroups;this.activeLoweringGroups=[];try{return e()}finally{this.activeLoweringGroups=t}}initEvent(e,t,n,o){e.t.add(n),this.usedTracks.add(o),e.track=o,e.ast??=t,e.order=this.cnt++,e.mergeKey??=e.order}trackedEvents(e,t,n,o=[]){this.appendEvents(e.loweringEnter(this,n),e,t,n,o);let r=e.timeFlowModel(this);if(r)switch(r.mode){case"sequence":for(let s of r.children)this.trackedEvents(s,t,n,o);break;case"parallel":{let s=r.tracks,i=r.children,c=s.hostIndex===void 0?0:s.hostIndex,l=n.group(s,c===null?i.length:i.length-1),p=[],u=[];for(let f=0;f<i.length;f++){let d=i[f],h=f===c?n:l.members[c===null||f<c?f:f-1],y=t.clone(),g=this.trackedEvents(d,y,h);if(g.length===0){this.diagnostics.push(M.warning.ZeroTimeTrack(d.sourceSpan,f+1));continue}p.push(g),u.push(y)}let m=a.anchorAlign(p,u,o);m&&m.compare(t)>0&&t.copyFrom(m)}break}return this.appendEvents(e.loweringExit(this,n,t),e,t,n,o),o}appendEvents(e,t,n,o,r){let s;for(let i of e){this.initEvent(i,t,n,o),this.indexTemporal(i);for(let l=this.activeLoweringGroups.length-1;l>=0;l--)this.activeLoweringGroups[l].group.onTemporal?.(i);let c=(s??=new I).copyFrom(i.t).add(i.T);c.compare(n)>0&&n.copyFrom(c),r.push(new Nt(i))}}indexTemporal(e){let t=this.astToTemporal.get(e.ast);t?t.push(e):this.astToTemporal.set(e.ast,[e])}static anchorAlign(e,t,n){let o=e.length;if(o<=1){if(o===1)for(let u of e[0])n.push(u);return t[0]}let r=new Uint32Array(o),s=Array.from({length:o},()=>new I),i=[],c=new I,l=new Rr(o);for(let u=0;u<o;u++)l.push({e:e[u][0],i:u});let p=u=>{let m=e[u][++r[u]];m?(s[u].isZero()||m.shiftTime(s[u]),l.push({e:m,i:u})):t[u].add(s[u]).compare(c)>0&&c.copyFrom(t[u])};for(;;){let u=l.pop();if(u===void 0){if(i.length===0)break;let f=c.clone();for(let{e:h}of i)h.t.compare(f)>0&&f.copyFrom(h.t);let d=i[0].e;for(let{e:h,i:y}of i)h!==d&&d.push(...h),s[y].add(f).sub(h.t),p(y);i.length=0,d.t=f,d.sort((h,y)=>h.order-y.order),n.push(d);continue}if(u.e.mergeKey===Q){i.push(u);continue}let m=[u.i];for(;;){let f=l.front();if(!f||!f.e.t.equals(u.e.t)||f.e.mergeKey!==u.e.mergeKey)break;l.pop(),u.e.push(...f.e),m.push(f.i)}n.push(u.e);for(let f of m)p(f)}return c}},Nt=class extends Array{static get[Symbol.species](){return Array}mergeKey;bpm;timeSignature;constructor(e,t=Me){super(1),this.mergeKey=e.mergeKey,this.bpm=t,this[0]=e}get t(){return this[0].t}set t(e){for(let t of this)t.t.copyFrom(e)}shiftTime(e){for(let t of this)t.t.add(e)}get layoutLine(){return this[0].layoutLine}set layoutLine(e){for(let t of this)t.layoutLine=e}};function _r(a,e){let t=a.e.t.compare(e.e.t);return t!==0?t:a.e.mergeKey!==e.e.mergeKey?a.e.mergeKey<e.e.mergeKey?-1:1:a.i-e.i}var Rr=class extends Array{validLen=0;constructor(e){super(e)}front(){if(this.validLen!==0)return this[0]}push(e){return this[this.validLen]=e,this.up(this.validLen++),this.validLen}pop(){if(this.validLen===0)return;let e=this[0];return this[0]=this[--this.validLen],this[this.validLen]=void 0,this.down(0),e}up(e){let t=this[e];for(;e>0;){let n=e-1>>1;if(_r(t,this[n])>=0)break;this[e]=this[n],e=n}this[e]=t}down(e){let t=this[e];for(;;){let n=(e<<1)+1,o=n+1;if(n>=this.validLen)break;let r=n;if(o<this.validLen&&_r(this[o],this[n])<0&&(r=o),_r(this[r],t)>=0)break;this[e]=this[r],e=r}this[e]=t}};var Mr=Number.MAX_VALUE,vt=new WeakMap,Fr=class a extends P{static def={name:["rest"],description:"\u591A\u5C0F\u8282\u4F11\u6B62",details:`~~~jpfun
59
62
  @meter(4,4) | @rest(19) |
60
63
  ~~~
61
- \u4F7F\u7528\u5F53\u524D\u62CD\u53F7\u4EA7\u751F 19 \u4E2A\u6574\u5C0F\u8282\u7684\u9759\u97F3\uFF08\u5FC5\u987B\u5148\u58F0\u660E\u62CD\u53F7\uFF09`,allowExtraArgs:!1,args:[{name:"n",description:"\u4F11\u6B62\u7684\u5C0F\u8282\u6570",type:"number",default:1},{name:"width",description:"\u6A2A\u7EBF\u7684\u6700\u5C0F\u5BBD\u5EA6",type:"length",default:{value:3,unit:"em"}},{name:"size",description:"\u6570\u5B57\u5B57\u53F7\u4E0E\u7B14\u753B\u5C3A\u5BF8",type:"length",default:{value:1,unit:"em"}}]};count;width;size;font;weight;constructor(e,t,n,o=null){super(e,o);let[r,s,i]=this.getArgValue(t,n);if(!Number.isSafeInteger(r)||r<=0||r>4294967295)throw new w("E_REST_COUNT","@rest \u7684 n \u5FC5\u987B\u662F\u6B63\u5B89\u5168\u6574\u6570\uFF0C\u4E14\u5C0F\u8282\u7EBF\u6570\u91CF\u53EF\u7531\u6570\u7EC4\u8868\u793A",e);if(this.count=r,this.width=n.length2px(s),this.size=n.length2px(i),!Number.isFinite(this.width)||this.width<0||!Number.isFinite(this.size)||this.size<=0)throw new w("E_REST_SIZE","@rest \u7684 width \u5FC5\u987B\u6709\u9650\u4E14\u975E\u8D1F\uFF0Csize \u5FC5\u987B\u6709\u9650\u4E14\u4E3A\u6B63",e);this.font=n.variables.numberfont,this.weight=n.variables.numberweight}labelable(){return this}loweringEnter(e){return e.deferFinalize(a.loweringFinalize,-10),[new Ir(this)]}static loweringFinalize(e){if(!e.columns.some(s=>s.some(i=>i.mergeKey===Br)))return;let t=0,n=new Map;for(let s of e.astToTemporal.values())for(let i of s){if(t=Math.max(t,i.order+1),!(i.ast instanceof E)||i.ast.callName!=="note"&&i.ast.callName!=="dash")continue;let c=i.rootHost;if(i.track!==c.track)continue;let l=n.get(c);(!l||i.order<l.order)&&n.set(c,i)}let o=[],r=new Map;for(let s of e.columns){o.push(s);let i;for(let l of s){if(l.T.compare(0)>0){let u=n.get(l),m=r.get(l.track);if(m&&At.has(m)&&u?.ast instanceof E&&u.ast.callName==="dash")throw new w("E_REST_SUSTAIN","\u589E\u65F6\u7EBF\u4E0D\u80FD\u5EF6\u7EED\u6574\u5C0F\u8282\u4F11\u6B62",u.ast.sourceSpan);r.set(l.track,l)}let p=At.get(l);p&&(!i||p.T.compare(i.T)>0)&&(i=p)}if(!i)continue;let c=i.t.clone();for(let l=1;l<i.ast.count;l++){c.add(i.measureDuration);let p=new W;p.ast=new be(i.ast.sourceSpan,i.ast),p.t.copyFrom(c),p.track=i.track,p.layoutLine=i.layoutLine,p.order=t++,p.mergeKey=Q,e.astToTemporal.set(p.ast,[p]),o.push([p])}}e.columns=o}toString(){return`@rest(${this.count})`}},Dr=Or,Ir=class extends W{measureDuration=new V;metrics;lineWidth=0;textStyle;constructor(e){super(),this.ast=e,this.mergeKey=Br,At.set(this,this),this.initLayoutBox(),this.textStyle={fontSize:e.size,fontFamily:e.font,fontWeight:e.weight,textAlign:"center"}}onTimeState(e){let t=e.meter;if(!(t instanceof V))throw new w("E_REST_METER","\u6574\u5C0F\u8282\u4F11\u6B62\u524D\u5FC5\u987B\u6709\u5B9E\u9645\u751F\u6548\u7684\u663E\u5F0F\u62CD\u53F7",this.ast.sourceSpan);if(!Number.isSafeInteger(t.numerator*this.ast.count))throw new w("E_REST_COUNT","@rest \u7684\u603B\u65F6\u503C\u8D85\u51FA\u7CBE\u786E\u6574\u6570\u8303\u56F4",this.ast.sourceSpan);this.measureDuration.copyFrom(t),this.T.copyFrom(t).mul(this.ast.count);let n=this.rootHost;if(n.mergeKey===Br&&this.track===n.track){let o=At.get(n);(!o||this.order<o.order)&&At.set(n,this)}return this.playbackState={bpm:e.bpm},this.T}emitPlayback(e){e.span({start:e.start,end:e.end})}prepareLayout(e){let t=this.ast.size,n=6/Math.sqrt(this.T.toNumber());this.springConfig={alpha_L:n,alpha_R:n},this.metrics=e.textMeasurer.measureText(String(this.ast.count),this.textStyle),this.lineWidth=Math.max(this.ast.width,this.metrics.w+t*.5),this.box.w=this.lineWidth+t*.25,this.box.h=this.metrics.h+t*.5,this.box.anchor=t*.4,this.box.visualAxis=this.box.h-t*.65/2}prepareHorizontal(e){let t=this;for(;e.columnOf(t)<0&&t.foldedInto&&M(t.foldedInto);)t=t.foldedInto;let n=e.columnOf(t);if(n<0)return;let o=i=>e.columns[i]?.find(c=>c.track===t.track&&c.mergeKey===Q)??t,r=o(n-1),s=o(n+1);r!==s&&e.registerHorizontalLayoutHook(r,s,({columns:i,rows:c,start:l,end:p,X:u,fixed:m})=>{for(let y=l;y<p;y++){if(m[y])continue;let d=0;for(let f=0;f<c;f++){let x=i[y][f],h=i[y+1][f],b=At.get(h.time),S=b?b.ast.size*.25:0;d=Math.max(d,x.WR+h.WL+S)}let g=u[y]+d-u[y+1];for(let f=y+1;f<u.length&&(u[f]+=g,!!m[f]);f++);m[y]=1}})}paint(e){let{size:t,count:n}=this.ast,o=this.box.x,r=this.box.y+this.box.visualAxis,s=t*.12,i=s*2,c=t*.65,l={fill:"#000"};e.drawRect(o,r-i/2,this.lineWidth,i,l),e.drawRect(o,r-c/2,s,c,l),e.drawRect(o+this.lineWidth-s,r-c/2,s,c,l),e.drawText(String(n),o+this.lineWidth/2,this.box.y+this.metrics.baseline,this.textStyle)}};var Gs=[{name:"gap",namedOnly:!0,type:"length",default:{value:.12,unit:"em"},description:"\u76F8\u90BB\u5806\u53E0\u6210\u5458\u4E4B\u95F4\u7684\u95F4\u8DDD"}];function Hs(a,e,t,n,o){let r=e;for(let s=0;s<t.length;){let i=n[s],c=s+1;for(;c<t.length&&n[c]===i;)c++;let l=t.slice(s,c).map(p=>p.toString(o));r=`@${a}(${[r,...l,`gap=${i}px`].join(", ")})`,s=c}return r}var Gn=class a extends E{contents=[];belows=[];aboveGaps=[];belowGaps=[];size;gap;get side(){return this.constructor.side}get children(){return this.belows.length?[...this.contents,...this.belows]:this.contents}timeFlowModel(){return null}constructor(e,t,n,o=null){super(e,o),this.size=n.variables.fontsize;let[r]=this.getArgValue(t,n);if(this.gap=n.length2px(r),!Number.isFinite(this.gap)||this.gap<0)throw new w("E_INVALID_FOLD_GAP","@{fn} \u7684 gap \u5FC5\u987B\u662F\u975E\u8D1F\u6709\u9650\u957F\u5EA6",e,{fn:this.callName});for(let[s,i]of t)typeof s=="number"&&this.addContent(i,this.side,n)}labelable(){return this.children.some(E.findLabelable)?this:null}addContent(e,t,n,o=this.gap){return this.contents.length===0&&(t="above"),e instanceof a?this.flatten(e,t,n,o):(t==="above"?(this.contents.length>0&&this.aboveGaps.push(o),this.contents.push(e)):(this.belowGaps.push(o),this.belows.push(e)),e.parent=this,this.growSpan(e.sourceSpan),this)}growSpan(e){this.sourceSpan.start=Math.min(this.sourceSpan.start,e.start),this.sourceSpan.end=Math.max(this.sourceSpan.end,e.end)}loweringEnter(e,t){let n=[];return e.isolateFromLoweringGroups(()=>{for(let o of this.children){let r=e.trackedEvents(o,new V,t),s=r.length===1&&r[0].length===1?r[0][0]:void 0;if(!s||!M(s)||(s.addon?.breakBefore??0)>0)throw new w("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\u6362\u884C\u6216\u5305\u542B\u591A\u58F0\u90E8\u7ED3\u6784",o.sourceSpan);n.push(s)}}),[new Gr(this,n)]}toString(e){if(this.contents.length<=1&&this.belows.length===0)return`@${this.callName}(${[...this.contents.map(n=>n.toString(e)),`gap=${this.gap}px`].join(", ")})`;let t=Hs("up",this.contents[0].toString(e),this.contents.slice(1),this.aboveGaps,e);return Hs("down",t,this.belows,this.belowGaps,e)}flatten(e,t,n,o=this.gap){let r=e.sourceSpan.start<this.sourceSpan.start?e:this,s=r===e?this:e,[i,...c]=s.contents,l=r.contents.length>0,p=i?[i]:[],u=l&&i?[o]:[],m=!l||t==="above";this.contents=[...r.contents,...m?p:[],...c],this.belows=[...r.belows,...m?[]:p,...s.belows],this.aboveGaps=[...r.aboveGaps,...m?u:[],...s.aboveGaps],this.belowGaps=[...r.belowGaps,...m?[]:u,...s.belowGaps];for(let d of this.children)d.parent=this;this.growSpan(e.sourceSpan),e.contents.length=e.belows.length=e.aboveGaps.length=e.belowGaps.length=0;let y=n.labelableNodes.lastIndexOf(e);return y>=0&&n.labelableNodes.splice(y,1),this}static desugar(e,t,n){let o=t[n++];if(!(o.kind==="sugar"&&o.data===this))return null;let r=this.side==="above"?"@up":"@down",s=e.takeLeftOperand();if(!s)throw new w("E_FOLD_NO_TARGET","{fn}\u8BED\u6CD5\u7CD6\u9519\u8BEF: \u5DE6\u8FB9\u6CA1\u6709\u627E\u5230\u53EF\u53E0\u52A0\u7684\u76EE\u6807",o.span,{fn:r});let i=new this({...o.span},new Map,e),c=s instanceof a?s:i.addContent(s,"above",e),l=e.consumeRightOperand(t,n,p=>{let u=p instanceof a?p.flatten(c,this.side,e,i.gap):c.addContent(p,this.side,e,i.gap);return e.labelableNodes.push(u.labelable()),u});if(l!==null)return l;throw new w("E_FOLD_NO_TARGET","{fn}\u8BED\u6CD5\u7CD6\u9519\u8BEF: \u53F3\u8FB9\u6CA1\u6709\u627E\u5230\u53EF\u53E0\u52A0\u7684\u76EE\u6807",o.span,{fn:r})}},Vr=class a extends Gn{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, gap=0.12em)\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\u4EC5\u547D\u540D\u53C2\u6570 `gap` \u6307\u5B9A\u76F8\u90BB\u6210\u5458\u7684\u95F4\u8DDD\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:Gs};static deSugarAtom(e,t,n){if(e[t]!=="^")return null;let o={kind:"sugar",data:a,span:{start:t,end:t+1}};return{next:t+1,node:o}}static deSugarRelation(e,t,n){return a.desugar(e,t,n)}},Hr=class a extends Gn{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, gap=0.12em)\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\u4EC5\u547D\u540D\u53C2\u6570 `gap` \u6307\u5B9A\u76F8\u90BB\u6210\u5458\u7684\u95F4\u8DDD\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:Gs};static deSugarAtom(e,t,n){if(e[t]!=="_")return null;let o={kind:"sugar",data:a,span:{start:t,end:t+1}};return{next:t+1,node:o}}static deSugarRelation(e,t,n){return a.desugar(e,t,n)}},zr=Vr,jr=Hr,Gr=class extends W{members;aboveCount;verticalOffsets=[];constructor(e,t){super(),this.ast=e,this.members=t,this.aboveCount=e.contents.length;let n=t[0];this.mergeKey=n&&n.mergeKey!==n.order?n.mergeKey:Se;let o=this.mergeKey===Se||this.mergeKey===Q;!o&&n&&this.T.copyFrom(n.T),this.initLayoutBox();let r=n?.addon;r&&(this.addon={...r});for(let s of t)o&&this.T.isZero()&&this.T.copyFrom(s.T),s.mergeKey===Q&&(this.mergeKey=Q),s.addon=void 0,s.foldedInto=this}onTimeState(e){let t=this.T.clone(),n,o=!1;for(let s=this.members.length-1;s>=0;s--){let i=this.members[s];!i.T.isZero()&&!this.T.isZero()&&i.T.copyFrom(this.T),i.t.copyFrom(this.t),i.track=this.track,i.layoutLine=this.layoutLine,n=i.onTimeState?.(e),o||=!i.T.isZero()&&!i.T.equals(t)}let r=this.members[0];if(r&&!r.T.isZero()&&(this.T.copyFrom(r.T),o))for(let s of this.members)s.T.isZero()||s.T.copyFrom(this.T);return n}emitPlayback(e){for(let t=this.members.length-1;t>=0;t--)e.play(this.members[t])}prepareHorizontal(e){this.members[0]?.prepareHorizontal?.(e)}prepareLayout(e){this.members[0]&&qe(this,this.members[0]);let t=this.members[0];if(!t){this.box.w=this.box.h=0,this.box.anchor=this.box.visualAxis=0;return}this.box.w=dt([t],e);for(let p=1;p<this.members.length;p++)dt([this.members[p]],e);this.springConfig={...t.springConfig};let n=t.box.x+t.box.anchor;this.verticalOffsets.length=this.members.length,this.verticalOffsets[0]=0;let o=te(t),r=o.y;for(let p=1;p<this.aboveCount;p++){let u=this.ast.aboveGaps[p-1],m=te(this.members[p]);this.verticalOffsets[p]=r-u-m.y-m.h,r-=u+m.h}let s=o.y+o.h;for(let p=this.aboveCount;p<this.members.length;p++){let u=this.ast.belowGaps[p-this.aboveCount],m=te(this.members[p]);this.verticalOffsets[p]=s+u-m.y,s+=u+m.h}for(let p=0;p<this.verticalOffsets.length;p++)this.verticalOffsets[p]-=r;this.box.h=s-r,this.box.anchor=n,this.box.visualAxis=t.box.visualAxis-r;let i=this.verticalOffsets[0];for(let p in t.ports){let u=t.ports[p];this.ports[p]={...u,x:t.box.x+u.x,y:i+u.y}}this.ports["body.left"]??={x:t.box.x,y:this.box.visualAxis},this.ports["body.right"]??={x:t.box.x+t.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??te(this.members[c],!0).y)}}onPlaced(){for(let e=0;e<this.members.length;e++){let t=this.members[e];t.box.x=this.box.x+this.box.anchor-t.box.anchor,t.box.y=this.box.y+this.verticalOffsets[e],t.onPlaced?.()}}paint(e){for(let t of this.members)Me(e,t)}};var Nt=a=>({value:a,unit:"px"}),zn=16,kc={fontSize:zn,textAlign:"center",fill:"#606060"};function vc(a,e,t){let n=a.lastIndexOf("1"),o=a.indexOf("1")!==n;return a.replace(/1/g,(r,s)=>String(o&&s===n?t:e))}var Wr=class{constructor(e,t,n,o){this.sourceSpan=e;this.pattern=t;this.marginBottom=n;this.style=o}sourceSpan;pattern;marginBottom;style;kind="page-number";layer="foreground";createGeometry(e){let t=this.style,n=e.pages.map((o,r)=>{let s=vc(this.pattern,r+1,e.pages.length),{w:i,h:c,baseline:l}=e.textMeasurer.measureText(s,t),p=o.y+o.h-this.marginBottom/2;return{text:s,x:o.x+o.w/2,y:p-c/2+l,w:i,h:c,baseline:l}});return{regions:n.map(({x:o,y:r,w:s,h:i,baseline:c})=>({x:o-s/2,y:r-c,w:s,h:i})),paint(o){for(let r of n)o.drawText(r.text,r.x,r.y,t)}}}},jn=class extends E{static def={name:["page"],description:"\u8BBE\u7F6E\u6587\u6863\u9875\u9762",details:`~~~jpfun
64
+ \u4F7F\u7528\u5F53\u524D\u62CD\u53F7\u4EA7\u751F 19 \u4E2A\u6574\u5C0F\u8282\u7684\u9759\u97F3\uFF08\u5FC5\u987B\u5148\u58F0\u660E\u62CD\u53F7\uFF09`,allowExtraArgs:!1,args:[{name:"n",description:"\u4F11\u6B62\u7684\u5C0F\u8282\u6570",type:"number",default:1},{name:"width",description:"\u6A2A\u7EBF\u7684\u6700\u5C0F\u5BBD\u5EA6",type:"length",default:{value:3,unit:"em"}},{name:"size",description:"\u6570\u5B57\u5B57\u53F7\u4E0E\u7B14\u753B\u5C3A\u5BF8",type:"length",default:{value:1,unit:"em"}}]};count;width;size;font;weight;constructor(e,t,n,o=null){super(e,o);let[r,s,i]=this.getArgValue(t,n);if(!Number.isSafeInteger(r)||r<=0||r>4294967295)throw new w("E_REST_COUNT","@rest \u7684 n \u5FC5\u987B\u662F\u6B63\u5B89\u5168\u6574\u6570\uFF0C\u4E14\u5C0F\u8282\u7EBF\u6570\u91CF\u53EF\u7531\u6570\u7EC4\u8868\u793A",e);if(this.count=r,this.width=n.length2px(s),this.size=n.length2px(i),!Number.isFinite(this.width)||this.width<0||!Number.isFinite(this.size)||this.size<=0)throw new w("E_REST_SIZE","@rest \u7684 width \u5FC5\u987B\u6709\u9650\u4E14\u975E\u8D1F\uFF0Csize \u5FC5\u987B\u6709\u9650\u4E14\u4E3A\u6B63",e);this.font=n.variables.numberfont,this.weight=n.variables.numberweight}labelable(){return this}loweringEnter(e){return e.deferFinalize(a.loweringFinalize,-10),[new Br(this)]}static loweringFinalize(e){if(!e.columns.some(s=>s.mergeKey===Mr))return;let t=0,n=new Map;for(let s of e.astToTemporal.values())for(let i of s){if(t=Math.max(t,i.order+1),!(i.ast instanceof P)||i.ast.callName!=="note"&&i.ast.callName!=="dash")continue;let c=i.rootHost;if(i.track!==c.track)continue;let l=n.get(c);(!l||i.order<l.order)&&n.set(c,i)}let o=[],r=new Map;for(let s of e.columns){o.push(s);let i;for(let l of s){if(l.T.compare(0)>0){let u=n.get(l),m=r.get(l.track);if(m&&vt.has(m)&&u?.ast instanceof P&&u.ast.callName==="dash")throw new w("E_REST_SUSTAIN","\u589E\u65F6\u7EBF\u4E0D\u80FD\u5EF6\u7EED\u6574\u5C0F\u8282\u4F11\u6B62",u.ast.sourceSpan);r.set(l.track,l)}let p=vt.get(l);p&&(!i||p.T.compare(i.T)>0)&&(i=p)}if(!i)continue;let c=s.t.clone();for(let l=1;l<i.ast.count;l++){c.add(i.measureDuration);let p=new H;p.ast=new we(i.ast.sourceSpan,i.ast),p.t.copyFrom(c),p.track=i.track,p.layoutLine=s.layoutLine,p.order=t++,p.mergeKey=Q,e.astToTemporal.set(p.ast,[p]),o.push(new Nt(p,s.bpm))}}e.columns=o}toString(){return`@rest(${this.count})`}},Or=Fr,Br=class extends H{measureDuration=new I;metrics;lineWidth=0;textStyle;constructor(e){super(),this.ast=e,this.mergeKey=Mr,vt.set(this,this),this.initLayoutBox(),this.textStyle={fontSize:e.size,fontFamily:e.font,fontWeight:e.weight,textAlign:"center"}}onTimeState(e){let t=e.meter;if(!(t instanceof I))throw new w("E_REST_METER","\u6574\u5C0F\u8282\u4F11\u6B62\u524D\u5FC5\u987B\u6709\u5B9E\u9645\u751F\u6548\u7684\u663E\u5F0F\u62CD\u53F7",this.ast.sourceSpan);if(!Number.isSafeInteger(t.numerator*this.ast.count))throw new w("E_REST_COUNT","@rest \u7684\u603B\u65F6\u503C\u8D85\u51FA\u7CBE\u786E\u6574\u6570\u8303\u56F4",this.ast.sourceSpan);this.measureDuration.copyFrom(t),this.T.copyFrom(t).mul(this.ast.count);let n=this.rootHost;if(n.mergeKey===Mr&&this.track===n.track){let o=vt.get(n);(!o||this.order<o.order)&&vt.set(n,this)}return this.T}emitPlayback(e){e.span({start:e.start,end:e.end})}prepareLayout(e){let t=this.ast.size,n=6/Math.sqrt(this.T.toNumber());this.springConfig={alpha_L:n,alpha_R:n},this.metrics=e.textMeasurer.measureText(String(this.ast.count),this.textStyle),this.lineWidth=Math.max(this.ast.width,this.metrics.w+t*.5),this.box.w=this.lineWidth+t*.25,this.box.h=this.metrics.h+t*.5,this.box.anchor=t*.4,this.box.visualAxis=this.box.h-t*.65/2}prepareHorizontal(e){let t=this;for(;e.columnOf(t)<0&&t.foldedInto&&_(t.foldedInto);)t=t.foldedInto;let n=e.columnOf(t);if(n<0)return;let o=i=>e.columns[i]?.find(c=>c.track===t.track&&c.mergeKey===Q)??t,r=o(n-1),s=o(n+1);r!==s&&e.registerHorizontalLayoutHook(r,s,({columns:i,rows:c,start:l,end:p,X:u,fixed:m})=>{for(let f=l;f<p;f++){if(m[f])continue;let d=0;for(let y=0;y<c;y++){let g=i[f][y],x=i[f+1][y],b=vt.get(x.time),S=b?b.ast.size*.25:0;d=Math.max(d,g.WR+x.WL+S)}let h=u[f]+d-u[f+1];for(let y=f+1;y<u.length&&(u[y]+=h,!!m[y]);y++);m[f]=1}})}paint(e){let{size:t,count:n}=this.ast,o=this.box.x,r=this.box.y+this.box.visualAxis,s=t*.12,i=s*2,c=t*.65,l={fill:"#000"};e.drawRect(o,r-i/2,this.lineWidth,i,l),e.drawRect(o,r-c/2,s,c,l),e.drawRect(o+this.lineWidth-s,r-c/2,s,c,l),e.drawText(String(n),o+this.lineWidth/2,this.box.y+this.metrics.baseline,this.textStyle)}};var Is=[{name:"gap",namedOnly:!0,type:"length",default:{value:.12,unit:"em"},description:"\u76F8\u90BB\u5806\u53E0\u6210\u5458\u4E4B\u95F4\u7684\u95F4\u8DDD"}];function Os(a,e,t,n,o){let r=e;for(let s=0;s<t.length;){let i=n[s],c=s+1;for(;c<t.length&&n[c]===i;)c++;let l=t.slice(s,c).map(p=>p.toString(o));r=`@${a}(${[r,...l,`gap=${i}px`].join(", ")})`,s=c}return r}var Pt=class a extends P{contents=[];belows=[];aboveGaps=[];belowGaps=[];size;gap;get side(){return this.constructor.side}get children(){return this.belows.length?[...this.contents,...this.belows]:this.contents}timeFlowModel(){return null}constructor(e,t,n,o=null){super(e,o),this.size=n.variables.fontsize;let[r]=this.getArgValue(t,n);if(this.gap=n.length2px(r),!Number.isFinite(this.gap)||this.gap<0)throw new w("E_INVALID_FOLD_GAP","@{fn} \u7684 gap \u5FC5\u987B\u662F\u975E\u8D1F\u6709\u9650\u957F\u5EA6",e,{fn:this.callName});for(let[s,i]of t)typeof s=="number"&&this.addContent(i,this.side,n)}labelable(){return this.children.some(P.findLabelable)?this:null}addContent(e,t,n,o=this.gap){return this.contents.length===0&&(t="above"),e instanceof a?this.flatten(e,t,n,o):(t==="above"?(this.contents.length>0&&this.aboveGaps.push(o),this.contents.push(e)):(this.belowGaps.push(o),this.belows.push(e)),e.parent=this,this.growSpan(e.sourceSpan),this)}growSpan(e){this.sourceSpan.start=Math.min(this.sourceSpan.start,e.start),this.sourceSpan.end=Math.max(this.sourceSpan.end,e.end)}loweringEnter(e,t){let n=[];return e.isolateFromLoweringGroups(()=>{for(let o of this.children){let r=e.trackedEvents(o,new I,t),s=r.length===1&&r[0].length===1?r[0][0]:void 0;if(!s||!_(s)||s.addon?.breakBefore)throw new w("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\u6362\u884C\u6216\u5305\u542B\u591A\u58F0\u90E8\u7ED3\u6784",o.sourceSpan);n.push(s)}}),[new Vr(this,n)]}toString(e){if(this.contents.length<=1&&this.belows.length===0)return`@${this.callName}(${[...this.contents.map(n=>n.toString(e)),`gap=${this.gap}px`].join(", ")})`;let t=Os("up",this.contents[0].toString(e),this.contents.slice(1),this.aboveGaps,e);return Os("down",t,this.belows,this.belowGaps,e)}flatten(e,t,n,o=this.gap,r=!0){let s=e.sourceSpan.start<this.sourceSpan.start?e:this,i=s===e?this:e,[c,...l]=i.contents,p=s.contents.length>0,u=c?[c]:[],m=p&&c?[o]:[],f=!p||t==="above";this.contents=[...s.contents,...f?u:[],...l],this.belows=[...s.belows,...f?[]:u,...i.belows],this.aboveGaps=[...s.aboveGaps,...f?m:[],...i.aboveGaps],this.belowGaps=[...s.belowGaps,...f?[]:m,...i.belowGaps];for(let h of this.children)h.parent=this;if(this.growSpan(e.sourceSpan),e.contents.length=e.belows.length=e.aboveGaps.length=e.belowGaps.length=0,!r)return this;let d=n.labelableNodes.lastIndexOf(e);return d>=0&&n.labelableNodes.splice(d,1),this}static deSugarRelation(e,t,n){let o=t[n++],r=o.data,s=r.side==="above"?"@up":"@down",i=e.takeLeftOperand();if(!i)throw new w("E_FOLD_NO_TARGET","{fn}\u8BED\u6CD5\u7CD6\u9519\u8BEF: \u5DE6\u8FB9\u6CA1\u6709\u627E\u5230\u53EF\u53E0\u52A0\u7684\u76EE\u6807",o.span,{fn:s});let c=new r({...o.span},new Map,e),l=i instanceof a?i:c.addContent(i,"above",e);return e.deferRightOperand(p=>{if(!p)throw new w("E_FOLD_NO_TARGET","{fn}\u8BED\u6CD5\u7CD6\u9519\u8BEF: \u53F3\u8FB9\u6CA1\u6709\u627E\u5230\u53EF\u53E0\u52A0\u7684\u76EE\u6807",o.span,{fn:s});let u=p instanceof a?p.flatten(l,r.side,e,c.gap,l!==c):l.addContent(p,r.side,e,c.gap);return e.labelableNodes.push(u.labelable()),u}),n}},Ir=class a extends Pt{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, gap=0.12em)\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\u4EC5\u547D\u540D\u53C2\u6570 `gap` \u6307\u5B9A\u76F8\u90BB\u6210\u5458\u7684\u95F4\u8DDD\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:Is};static deSugarAtom(e,t,n){if(e[t]!=="^")return null;let o={kind:"sugar",data:a,span:{start:t,end:t+1},relation:Pt.deSugarRelation};return{next:t+1,node:o}}},Dr=class a extends Pt{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, gap=0.12em)\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\u4EC5\u547D\u540D\u53C2\u6570 `gap` \u6307\u5B9A\u76F8\u90BB\u6210\u5458\u7684\u95F4\u8DDD\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:Is};static deSugarAtom(e,t,n){if(e[t]!=="_")return null;let o={kind:"sugar",data:a,span:{start:t,end:t+1},relation:Pt.deSugarRelation};return{next:t+1,node:o}}},Hr=Ir,Gr=Dr,Vr=class extends H{members;aboveCount;verticalOffsets=[];constructor(e,t){super(),this.ast=e,this.members=t,this.aboveCount=e.contents.length;let n=t[0];this.mergeKey=n&&n.mergeKey!==n.order?n.mergeKey:Le;let o=this.mergeKey===Le||this.mergeKey===Q;!o&&n&&this.T.copyFrom(n.T),this.initLayoutBox();let r=n?.addon;r&&(this.addon={...r});for(let s of t)o&&this.T.isZero()&&this.T.copyFrom(s.T),s.mergeKey===Q&&(this.mergeKey=Q),s.addon=void 0,s.foldedInto=this}memberOrder(){let e=[],t=[];for(let o=this.members.length-1;o>0;o--){let r=this.members[o];(r.T.isZero()?e:t).push(r)}let n=this.members[0];return n?[...e,...t,n]:[...e,...t]}onTimeState(e){let t=this.T.clone(),n,o=!1;for(let s of this.memberOrder())!s.T.isZero()&&!this.T.isZero()&&s.T.copyFrom(this.T),s.t.copyFrom(this.t),s.track=this.track,s.layoutLine=this.layoutLine,n=s.onTimeState?.(e),o||=!s.T.isZero()&&!s.T.equals(t);let r=this.members[0];if(r&&!r.T.isZero()&&(this.T.copyFrom(r.T),o))for(let s of this.members)s.T.isZero()||s.T.copyFrom(this.T);return n}emitPlayback(e){for(let t of this.memberOrder())e.play(t)}prepareHorizontal(e){this.members[0]?.prepareHorizontal?.(e)}prepareLayout(e){this.members[0]&&Qe(this,this.members[0]);let t=this.members[0];if(!t){this.box.w=this.box.h=0,this.box.anchor=this.box.visualAxis=0;return}this.box.w=yt([t],e);for(let p=1;p<this.members.length;p++)yt([this.members[p]],e);this.springConfig={...t.springConfig};let n=t.box.x+t.box.anchor;this.verticalOffsets.length=this.members.length,this.verticalOffsets[0]=0;let o=ee(t),r=o.y;for(let p=1;p<this.aboveCount;p++){let u=this.ast.aboveGaps[p-1],m=ee(this.members[p]);this.verticalOffsets[p]=r-u-m.y-m.h,r-=u+m.h}let s=o.y+o.h;for(let p=this.aboveCount;p<this.members.length;p++){let u=this.ast.belowGaps[p-this.aboveCount],m=ee(this.members[p]);this.verticalOffsets[p]=s+u-m.y,s+=u+m.h}for(let p=0;p<this.verticalOffsets.length;p++)this.verticalOffsets[p]-=r;this.box.h=s-r,this.box.anchor=n,this.box.visualAxis=t.box.visualAxis-r;let i=this.verticalOffsets[0];for(let p in t.ports){let u=t.ports[p];this.ports[p]={...u,x:t.box.x+u.x,y:i+u.y}}this.ports["body.left"]??={x:t.box.x,y:this.box.visualAxis},this.ports["body.right"]??={x:t.box.x+t.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??ee(this.members[c],!0).y)}}onPlaced(){for(let e=0;e<this.members.length;e++){let t=this.members[e];t.box.x=this.box.x+this.box.anchor-t.box.anchor,t.box.y=this.box.y+this.verticalOffsets[e],t.onPlaced?.()}}paint(e){for(let t of this.members)Fe(e,t)}};var Et=a=>({value:a,unit:"px"}),zr=16,Jc={fontSize:zr,textAlign:"center",fill:"#606060"};function el(a,e,t){let n=a.lastIndexOf("1"),o=a.indexOf("1")!==n;return a.replace(/1/g,(r,s)=>String(o&&s===n?t:e))}var jr=class{constructor(e,t,n,o){this.sourceSpan=e;this.pattern=t;this.marginBottom=n;this.style=o}sourceSpan;pattern;marginBottom;style;kind="page-number";layer="foreground";createGeometry(e){let t=this.style,n=e.pages.map((o,r)=>{let s=el(this.pattern,r+1,e.pages.length),{w:i,h:c,baseline:l}=e.textMeasurer.measureText(s,t),p=o.y+o.h-this.marginBottom/2;return{text:s,x:o.x+o.w/2,y:p-c/2+l,w:i,h:c,baseline:l}});return{regions:n.map(({x:o,y:r,w:s,h:i,baseline:c})=>({x:o-s/2,y:r-c,w:s,h:i})),paint(o){for(let r of n)o.drawText(r.text,r.x,r.y,t)}}}},Wr=class extends P{static def={name:["page"],description:"\u8BBE\u7F6E\u6587\u6863\u9875\u9762",details:`~~~jpfun
62
65
  @page(
63
66
  width=794px, height=1123px, top=48px, bottom=48px,
64
- left=40px, right=40px, gap=1em, minGap=0.4em, fillRatio=0.5,
67
+ left=40px, right=40px, fillRatio=0.5,
65
68
  numbering="1/1", barNumbering="(1)"
66
69
  )
67
70
  ~~~
68
- \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:Nt(ie.width)},{name:"height",description:"\u9875\u9762\u9AD8\u5EA6\uFF0C\u5C0F\u4E8E\u7B49\u4E8E 0 \u8868\u793A\u4E0D\u81EA\u52A8\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:Nt(0)},{name:"top",description:"\u9875\u9762\u4E0A\u8FB9\u8DDD",type:"length",default:Nt(ie.marginTop)},{name:"bottom",description:"\u9875\u9762\u4E0B\u8FB9\u8DDD\uFF0C\u542F\u7528\u9875\u7801\u65F6\u81F3\u5C11\u4E3A `16px`",type:"length",default:Nt(ie.marginBottom)},{name:"left",description:"\u9875\u9762\u5DE6\u8FB9\u8DDD",type:"length",default:Nt(ie.marginLeft)},{name:"right",description:"\u9875\u9762\u53F3\u8FB9\u8DDD",type:"length",default:Nt(ie.marginRight)},{name:"gap",description:"\u8C31\u9762\u884C\u4E3B\u65CB\u5F8B\u4E4B\u95F4\u7684\u6807\u51C6\u95F4\u8DDD",type:"length",default:{value:1,unit:"em"}},{name:"minGap",description:"\u884C\u95F4\u4FDD\u7559\u7684\u6700\u5C0F\u95F4\u8DDD",type:"length",default:{value:.4,unit:"em"}},{name:"numbering",description:"\u9875\u7801\u683C\u5F0F\uFF0C\u7A7A\u503C\u9690\u85CF\uFF1B`1`\uFF1A\u5F53\u524D\u9875\uFF0C`1/1`\uFF1A\u663E\u793A\u5F53\u524D\u9875/\u603B\u9875\u6570",type:"string",default:""},{name:"barNumbering",description:"\u884C\u9996\u5C0F\u8282\u53F7\u683C\u5F0F\uFF0C\u9ED8\u8BA4\u7A7A\u503C\u9690\u85CF\uFF1B`1` \u663E\u793A\u5F53\u524D\u5C0F\u8282\u53F7\uFF0C`(1)` \u663E\u793A\u5E26\u62EC\u53F7\u7684\u5C0F\u8282\u53F7",type:"string",default:""},{name:"font",description:"\u9875\u7801/\u5C0F\u8282\u53F7\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:ie.fillRatio}]};config;numbering="";barNumbering="";font;constructor(e,t,n,o=null){if(super(e,o),this.font=n.variables.font,n.scopeDepth!==0){n.diagnostics.push(new I("W_PAGE_NOT_TOP_LEVEL","@page \u53EA\u80FD\u5728\u6587\u6863\u9876\u5C42\u58F0\u660E\uFF1B\u5F53\u524D\u58F0\u660E\u5DF2\u5FFD\u7565",e)),this.config=null;return}if(n.documentDeclarations.page){n.diagnostics.push(new I("W_DUPLICATE_PAGE","\u6587\u6863\u53EA\u80FD\u58F0\u660E\u4E00\u4E2A @page\uFF1B\u540E\u7EED\u58F0\u660E\u5DF2\u5FFD\u7565",e)),this.config=null;return}n.documentDeclarations.page=!0;let[r,s,i,c,l,p,u,m,y,d,g,f]=this.getArgValue(t,n);this.font=g||n.variables.font;let[x,h,b,S,T,L,C,N]=[r,s,i,c,l,p,u,m].map(P=>n.length2px(P));if(!Number.isFinite(x)||x<=0)throw new w("E_INVALID_PAGE_CONFIG","@page \u7684 width \u5FC5\u987B\u662F\u6B63\u6709\u9650\u957F\u5EA6",e);if(!Number.isFinite(h))throw new w("E_INVALID_PAGE_CONFIG","@page \u7684 height \u5FC5\u987B\u662F\u6709\u9650\u957F\u5EA6\uFF1B\u5C0F\u4E8E\u7B49\u4E8E 0 \u8868\u793A\u4E0D\u81EA\u52A8\u5206\u9875",e);if([b,S,T,L,C,N].some(P=>!Number.isFinite(P)||P<0))throw new w("E_INVALID_PAGE_CONFIG","@page \u7684\u8FB9\u8DDD\u3001gap \u548C minGap \u5FC5\u987B\u662F\u975E\u8D1F\u6709\u9650\u957F\u5EA6",e);if(T+L>=x)throw new w("E_INVALID_PAGE_CONFIG","@page \u7684\u5DE6\u53F3\u8FB9\u8DDD\u6CA1\u6709\u7559\u4E0B\u53EF\u7528\u5185\u5BB9\u5BBD\u5EA6",e);if(h>0&&b+S>=h)throw new w("E_INVALID_PAGE_CONFIG","@page \u7684\u4E0A\u4E0B\u8FB9\u8DDD\u6CA1\u6709\u7559\u4E0B\u53EF\u7528\u5185\u5BB9\u9AD8\u5EA6",e);if(y&&S<zn)throw new w("E_INVALID_PAGE_CONFIG","@page \u7684 bottom \u81F3\u5C11\u9700\u8981 {minBottom}px \u624D\u80FD\u653E\u4E0B\u9875\u7801",e,{minBottom:zn});this.config=Rt({width:x,height:h,marginTop:b,marginBottom:S,marginLeft:T,marginRight:L,lineGap:C,minLineGap:N,fillRatio:f}),this.numbering=y,this.barNumbering=d}loweringEnter(e){return this.config?(e.setPageConfig(this.config),this.numbering&&e.addAttachment(new Wr(this.sourceSpan,this.numbering,this.config.marginBottom,{...kc,fontFamily:this.font})),this.barNumbering&&No(e,this.barNumbering,this.font),[]):[]}toString(){if(!this.config)return"@page()";let{width:e,height:t,marginTop:n,marginBottom:o,marginLeft:r,marginRight:s,lineGap:i,minLineGap:c,fillRatio:l}=this.config;return`@page(width=${e}px, height=${Number.isFinite(t)?t:0}px, top=${n}px, bottom=${o}px, left=${r}px, right=${s}px, gap=${i}px, minGap=${c}px, numbering=${ee(this.numbering)}, barNumbering=${ee(this.barNumbering)}, font=${ee(this.font)}, fillRatio=${l})`}},$r=jn;var Yr=class extends E{static def={name:["pagebreak","pb"],description:"\u5F3A\u5236\u6362\u9875",details:`~~~jpfun
71
+ \u9875\u8FB9\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\u884C\u8DDD\u7531 \`@br\` \u7684 \`gap\`\u3001\`minGap\` \u8BBE\u7F6E\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:Et(ue.width)},{name:"height",description:"\u9875\u9762\u9AD8\u5EA6\uFF0C\u5C0F\u4E8E\u7B49\u4E8E 0 \u8868\u793A\u4E0D\u81EA\u52A8\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:Et(0)},{name:"top",description:"\u9875\u9762\u4E0A\u8FB9\u8DDD",type:"length",default:Et(ue.marginTop)},{name:"bottom",description:"\u9875\u9762\u4E0B\u8FB9\u8DDD\uFF0C\u542F\u7528\u9875\u7801\u65F6\u81F3\u5C11\u4E3A `16px`",type:"length",default:Et(ue.marginBottom)},{name:"left",description:"\u9875\u9762\u5DE6\u8FB9\u8DDD",type:"length",default:Et(ue.marginLeft)},{name:"right",description:"\u9875\u9762\u53F3\u8FB9\u8DDD",type:"length",default:Et(ue.marginRight)},{name:"numbering",description:"\u9875\u7801\u683C\u5F0F\uFF0C\u7A7A\u503C\u9690\u85CF\uFF1B`1`\uFF1A\u5F53\u524D\u9875\uFF0C`1/1`\uFF1A\u663E\u793A\u5F53\u524D\u9875/\u603B\u9875\u6570",type:"string",default:""},{name:"barNumbering",description:"\u884C\u9996\u5C0F\u8282\u53F7\u683C\u5F0F\uFF0C\u9ED8\u8BA4\u7A7A\u503C\u9690\u85CF\uFF1B`1` \u663E\u793A\u5F53\u524D\u5C0F\u8282\u53F7\uFF0C`(1)` \u663E\u793A\u5E26\u62EC\u53F7\u7684\u5C0F\u8282\u53F7",type:"string",default:""},{name:"font",description:"\u9875\u7801/\u5C0F\u8282\u53F7\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:ue.fillRatio}]};config;numbering="";barNumbering="";font;constructor(e,t,n,o=null){if(super(e,o),this.font=n.variables.font,n.scopeDepth!==0){n.diagnostics.push(new O("W_PAGE_NOT_TOP_LEVEL","@page \u53EA\u80FD\u5728\u6587\u6863\u9876\u5C42\u58F0\u660E\uFF1B\u5F53\u524D\u58F0\u660E\u5DF2\u5FFD\u7565",e)),this.config=null;return}if(n.documentDeclarations.page){n.diagnostics.push(new O("W_DUPLICATE_PAGE","\u6587\u6863\u53EA\u80FD\u58F0\u660E\u4E00\u4E2A @page\uFF1B\u540E\u7EED\u58F0\u660E\u5DF2\u5FFD\u7565",e)),this.config=null;return}n.documentDeclarations.page=!0;let[r,s,i,c,l,p,u,m,f,d]=this.getArgValue(t,n);this.font=f||n.variables.font;let[h,y,g,x,b,S]=[r,s,i,c,l,p].map(T=>n.length2px(T));if(!Number.isFinite(h)||h<=0)throw new w("E_INVALID_PAGE_CONFIG","@page \u7684 width \u5FC5\u987B\u662F\u6B63\u6709\u9650\u957F\u5EA6",e);if(!Number.isFinite(y))throw new w("E_INVALID_PAGE_CONFIG","@page \u7684 height \u5FC5\u987B\u662F\u6709\u9650\u957F\u5EA6\uFF1B\u5C0F\u4E8E\u7B49\u4E8E 0 \u8868\u793A\u4E0D\u81EA\u52A8\u5206\u9875",e);if([g,x,b,S].some(T=>!Number.isFinite(T)||T<0))throw new w("E_INVALID_PAGE_CONFIG","@page \u7684\u8FB9\u8DDD\u5FC5\u987B\u662F\u975E\u8D1F\u6709\u9650\u957F\u5EA6",e);if(b+S>=h)throw new w("E_INVALID_PAGE_CONFIG","@page \u7684\u5DE6\u53F3\u8FB9\u8DDD\u6CA1\u6709\u7559\u4E0B\u53EF\u7528\u5185\u5BB9\u5BBD\u5EA6",e);if(y>0&&g+x>=y)throw new w("E_INVALID_PAGE_CONFIG","@page \u7684\u4E0A\u4E0B\u8FB9\u8DDD\u6CA1\u6709\u7559\u4E0B\u53EF\u7528\u5185\u5BB9\u9AD8\u5EA6",e);if(u&&x<zr)throw new w("E_INVALID_PAGE_CONFIG","@page \u7684 bottom \u81F3\u5C11\u9700\u8981 {minBottom}px \u624D\u80FD\u653E\u4E0B\u9875\u7801",e,{minBottom:zr});this.config=mt({width:h,height:y,marginTop:g,marginBottom:x,marginLeft:b,marginRight:S,fillRatio:d}),this.numbering=u,this.barNumbering=m}loweringEnter(e){return this.config?(e.setPageConfig(this.config),this.numbering&&e.addAttachment(new jr(this.sourceSpan,this.numbering,this.config.marginBottom,{...Jc,fontFamily:this.font})),this.barNumbering&&Xa(e,this.barNumbering,this.font),[]):[]}toString(){if(!this.config)return"@page()";let{width:e,height:t,marginTop:n,marginBottom:o,marginLeft:r,marginRight:s,fillRatio:i}=this.config;return`@page(width=${e}px, height=${Number.isFinite(t)?t:0}px, top=${n}px, bottom=${o}px, left=${r}px, right=${s}px, numbering=${te(this.numbering)}, barNumbering=${te(this.barNumbering)}, font=${te(this.font)}, fillRatio=${i})`}},$r=Wr;var Ur=class extends P{static def={name:["pagebreak","pb"],description:"\u5F3A\u5236\u6362\u9875",details:`~~~jpfun
69
72
  1 2 @br() 3 4 @pagebreak() 5 6
70
73
  ~~~
71
- \u540C\u65F6\u6362\u884C\u5E76\u5F00\u542F\u65B0\u9875\uFF0C\u4E0D\u5360\u97F3\u4E50\u65F6\u503C\u3002\u540C\u4E00\u65F6\u523B\u7684\u5E76\u884C\u8C03\u7528\u53EA\u6362\u4E00\u6B21\u9875\uFF0C\`justify=false\` \u4F18\u5148\u3002`,allowExtraArgs:!1,args:[{name:"justify",description:"\u662F\u5426\u5206\u914D\u5F53\u524D\u9875\u7684\u5269\u4F59\u7A7A\u95F4\uFF1B\u65E0\u9650\u9875\u9AD8\u65F6\u4E0D\u62C9\u4F38",type:"boolean",default:!0}]};justify;constructor(e,t,n,o=null){super(e,o),[this.justify]=this.getArgValue(t,n)}loweringEnter(e){e.deferFinalize(Qt.loweringFinalize);let t=new W;return t.ast=this,t.mergeKey=-1,t.addon={breakBefore:1,pageBreakBefore:this.justify},[t]}toString(){return`@pagebreak(justify=${this.justify})`}},Kr=Yr;var Ur=class extends E{static def={name:["program","instrument"],description:"\u8BBE\u7F6E\u5F53\u524D\u97F3\u8F68\u7684 MIDI \u97F3\u8272",details:`~~~jpfun
74
+ \u540C\u65F6\u6362\u884C\u5E76\u5F00\u542F\u65B0\u9875\uFF0C\u4E0D\u5360\u97F3\u4E50\u65F6\u503C\u3002\u540C\u4E00\u65F6\u523B\u7684\u5E76\u884C\u8C03\u7528\u53EA\u6362\u4E00\u6B21\u9875\uFF0C\`justify=false\` \u4F18\u5148\u3002`,allowExtraArgs:!1,args:[{name:"justify",description:"\u662F\u5426\u5206\u914D\u5F53\u524D\u9875\u7684\u5269\u4F59\u7A7A\u95F4\uFF1B\u65E0\u9650\u9875\u9AD8\u65F6\u4E0D\u62C9\u4F38",type:"boolean",default:!0}]};justify;constructor(e,t,n,o=null){super(e,o),[this.justify]=this.getArgValue(t,n)}loweringEnter(e){e.deferFinalize(en.loweringFinalize);let t=new H;return t.ast=this,t.mergeKey=-1,t.addon={breakBefore:{gap:0,minGap:0},pageBreakBefore:this.justify},[t]}toString(){return`@pagebreak(justify=${this.justify})`}},Yr=Ur;var Kr=class extends P{static def={name:["program","instrument"],description:"\u8BBE\u7F6E\u5F53\u524D\u97F3\u8F68\u7684 MIDI \u97F3\u8272",details:`~~~jpfun
72
75
  @program(40) 1 2 3
73
76
  ~~~
74
- \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(e,t,n,o=null){super(e,o);let[r]=this.getArgValue(t,n);if(!Number.isSafeInteger(r)||r<0||r>127)throw new w("E_PROGRAM_INVALID","@program \u5FC5\u987B\u662F 0..127 \u7684\u6574\u6570",e);this.program=r}loweringEnter(){let e=new W;return e.ast=this,e.playbackState={program:this.program},e.onTimeState=t=>{t.program=this.program},[e]}toString(){return`@program(${this.program})`}},Xr=Ur;var zs=.4,Pc=(a,e,t)=>a.top-t*zs-e.bottom,Ec=(a,e)=>{let t=e*zs,n=[],o=0;for(let r of a){if(!r){n.push(null);continue}let s=o-r.bottom;n.push({offset:s,extent:r}),o=s+r.top-t}return n},_c={laneKey:"stack",measure:Ec,place:Pc},Zr=class a extends E{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(e,t,n){if(e[t]==="&"){let o={kind:"sugar",data:a,span:{start:t,end:t+1}};return{next:t+1,node:o}}return null}static deSugarRelation(e,t,n){let o=t[n++];if(!(o.kind==="sugar"&&o.data===a))return null;let r=e.takeLeftOperand();if(!r)throw new w("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 s=r instanceof a?r:new a(o.span,new Map,e).addContent(r),i=e.consumeRightOperand(t,n,c=>s.addContent(c));if(i!==null)return i;throw new w("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:_c}}constructor(e,t,n,o=null){super(e,o);for(let[r,s]of t)typeof r=="number"&&this.addContent(s)}addContent(e){let t=e instanceof a?e.contents:[e],n=e.sourceSpan;this.sourceSpan.start=Math.min(this.sourceSpan.start,n.start),this.sourceSpan.end=Math.max(this.sourceSpan.end,n.end);for(let o of t)o.parent=this;return this.contents.push(...t),e instanceof a&&(e.contents.length=0),this}toString(e){return`@stack(
77
+ \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(e,t,n,o=null){super(e,o);let[r]=this.getArgValue(t,n);if(!Number.isSafeInteger(r)||r<0||r>127)throw new w("E_PROGRAM_INVALID","@program \u5FC5\u987B\u662F 0..127 \u7684\u6574\u6570",e);this.program=r}loweringEnter(){let e=new H;return e.ast=this,e.playbackState={program:this.program},e.onTimeState=t=>{t.program=this.program},[e]}toString(){return`@program(${this.program})`}},Xr=Kr;var Ds=.4,tl=(a,e,t)=>a.top-t*Ds-e.bottom,nl=(a,e)=>{let t=e*Ds,n=[],o=0;for(let r of a){if(!r){n.push(null);continue}let s=o-r.bottom;n.push({offset:s,extent:r}),o=s+r.top-t}return n},ol={laneKey:"stack",measure:nl,place:tl},Zr=class a 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(e,t,n){if(e[t]==="&"){let o={kind:"sugar",span:{start:t,end:t+1},relation:a.deSugarRelation};return{next:t+1,node:o}}return null}static deSugarRelation(e,t,n){let o=t[n++],r=e.takeLeftOperand();if(!r)throw new w("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 s=r instanceof a?r:new a(o.span,new Map,e).addContent(r);return e.deferRightOperand(i=>{if(!i)throw new w("E_STACK_NO_TARGET","@stack\u8BED\u6CD5\u7CD6\u9519\u8BEF: \u53F3\u8FB9\u6CA1\u6709\u627E\u5230\u53EF\u53E0\u52A0\u7684\u76EE\u6807",o.span);return s.addContent(i)}),n}contents=[];get children(){return this.contents}timeFlowModel(){return{children:this.contents,mode:"parallel",tracks:ol}}constructor(e,t,n,o=null){super(e,o);for(let[r,s]of t)typeof r=="number"&&this.addContent(s)}addContent(e){let t=e instanceof a?e.contents:[e],n=e.sourceSpan;this.sourceSpan.start=Math.min(this.sourceSpan.start,n.start),this.sourceSpan.end=Math.max(this.sourceSpan.end,n.end);for(let o of t)o.parent=this;return this.contents.push(...t),e instanceof a&&(e.contents.length=0),this}toString(e){return`@stack(
75
78
  ${this.contents.map(n=>n.toString(e)).join(`,
76
79
  `).split(`
77
80
  `).join(`
78
81
  `)}
79
- )`}},qr=Zr;function Ce(a){return(e,t)=>{let n=[];for(let o of t){if(!o.transpose){n.push(o);continue}let r=o.end.clone().sub(o.start),s=a.body.length;if(a.repeat){let c=e.stateAt(o.start).effectiveBpm,l=Math.min(480,Math.max(60,c))/c,p=Math.floor(256/a.body.length),u=Math.min(p,Math.max(1,Math.round(r.toNumber()*8*l/a.body.length)));s*=u}let i=r.div(s);for(let c=0;c<s;c++){let l=a.body[c%a.body.length],p=i.clone().mul(c).add(o.start);n.push({...o,start:p,end:p.clone().add(i),midi:l===0?o.midi:o.transpose(l),transpose:u=>o.transpose(l+u)})}}return n}}var en={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:a=>a.affectFollowing((e,t)=>{for(let n of t)n.velocity=Math.min(127,n.velocity+20)})};var Wn="repeat.coda";/*!
82
+ )`}},qr=Zr;function Pe(a){return(e,t)=>{let n=[];for(let o of t){if(!o.transpose){n.push(o);continue}let r=o.end.clone().sub(o.start),s=a.body.length;if(a.repeat){let c=e.stateAt(o.start).effectiveBpm,l=Math.min(480,Math.max(60,c))/c,p=Math.floor(256/a.body.length),u=Math.min(p,Math.max(1,Math.round(r.toNumber()*8*l/a.body.length)));s*=u}let i=r.div(s);for(let c=0;c<s;c++){let l=a.body[c%a.body.length],p=i.clone().mul(c).add(o.start);n.push({...o,start:p,end:p.clone().add(i),midi:l===0?o.midi:o.transpose(l),transpose:u=>o.transpose(l+u)})}}return n}}var Yn={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:a=>a.affectFollowing((e,t)=>{for(let n of t)n.velocity=Math.min(127,n.velocity+20)})};var Qr="repeat.coda";/*!
80
83
  * Bravura coda (U+E048), Y axis flipped; https://github.com/steinbergmedia/bravura
81
84
  * Copyright (c) 2026, Steinberg Media Technologies GmbH. Reserved Font Name "Bravura".
82
85
  * SPDX-License-Identifier: OFL-1.1
83
86
  * Full license: Bravura-LICENSE.txt in the package root and dist.
84
- */var Rc=[{op:"M",x:-4,y:-376},{op:"C",cx1:-4,cy1:-363,cx2:0,cy2:-352,x:14,y:-352},{op:"L",x:146,y:-352},{op:"C",cx1:157,cy1:-165,cx2:296,cy2:-13,x:458,y:0},{op:"L",x:458,y:140},{op:"C",cx1:458,cy1:154,cx2:469,cy2:158,x:482,y:158},{op:"C",cx1:495,cy1:158,cx2:506,cy2:154,x:506,y:140},{op:"L",x:506,y:0},{op:"C",cx1:668,cy1:-13,cx2:808,cy2:-165,x:818,y:-352},{op:"L",x:937,y:-352},{op:"C",cx1:951,cy1:-352,cx2:955,cy2:-363,x:955,y:-376},{op:"C",cx1:955,cy1:-389,cx2:951,cy2:-400,x:937,y:-400},{op:"L",x:818,y:-400},{op:"C",cx1:808,cy1:-588,cx2:668,cy2:-739,x:506,y:-752},{op:"L",x:506,y:-881},{op:"C",cx1:506,cy1:-894,cx2:495,cy2:-898,x:482,y:-898},{op:"C",cx1:469,cy1:-898,cx2:458,cy2:-894,x:458,y:-881},{op:"L",x:458,y:-752},{op:"C",cx1:296,cy1:-739,cx2:157,cy2:-589,x:146,y:-400},{op:"L",x:14,y:-400},{op:"C",cx1:0,cy1:-400,cx2:-4,cy2:-389,x:-4,y:-376},{op:"Z"},{op:"M",x:653,y:-400},{op:"L",x:506,y:-400},{op:"L",x:506,y:-696},{op:"C",cx1:646,cy1:-684,cx2:653,cy2:-562,x:653,y:-400},{op:"Z"},{op:"M",x:506,y:-352},{op:"L",x:653,y:-352},{op:"C",cx1:650,cy1:-199,cx2:631,cy2:-63,x:506,y:-48},{op:"Z"},{op:"M",x:316,y:-400},{op:"C",cx1:316,cy1:-562,cx2:316,cy2:-684,x:458,y:-696},{op:"L",x:458,y:-400},{op:"Z"},{op:"M",x:458,y:-352},{op:"L",x:458,y:-48},{op:"C",cx1:329,cy1:-63,cx2:317,cy2:-198,x:316,y:-352},{op:"Z"}],Qr={name:"coda",description:"\u5C3E\u58F0\u8BB0\u53F7\uFF1A$tocoda \u7684\u8DF3\u8F6C\u76EE\u6807",weight:1.15,playbackMarks:()=>[Wn],shapes:[{path:Rc,style:{fill:"#000"}}]};var Ye="repeat.jump",Jr={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:()=>[Ye],onVisit:(a,e)=>a.visits(e)>1?void 0:{kind:"jump",column:0}};var $n="repeat.segno",ea={name:"segno",description:"\u53CD\u590D\u8BB0\u53F7\uFF1AD.S. \u7684\u56DE\u8DF3\u76EE\u6807",weight:1.15,playbackMarks:()=>[$n],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 ta={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:()=>[Ye],onVisit:(a,e)=>a.visits(e)>1?void 0:{kind:"jump",column:a.seek($n,e,-1)??0}};var Mc={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"}]},Fc={mf:8.0028,mp:9.523,ff:6.67866,pp:8.8083},Bc={fill:"#000"},Oc=.79341,na=[49,33,16,10,5,1],oa=[96,112,126,127];function kt(a,e,t){let n=0,o=Array.from(a,(r,s)=>{let i={path:Mc[r],style:Bc,dx:n};return n+=Fc[r+a[s+1]]??0,i});return{name:a,description:t,shapes:o,weight:a.includes("f")?1:Oc,onTimeState:r=>{r.velocity=e}}}var ra=[{...kt("p",na[0],"\u5F31\uFF1B\u652F\u6301 `$p`\u3001`$pp`\u3001`$ppp` \u7B49\u8FDE\u7EED p\uFF0C\u6574\u4F53\u5C45\u4E2D"),pattern:{regex:/^p+$/,resolve:([a])=>kt(a,na[Math.min(a.length,na.length)-1],"\u5F31\u529B\u5EA6\u8BB0\u53F7")}},kt("mp",64,"\u4E2D\u5F31"),kt("mf",80,"\u4E2D\u5F3A"),{...kt("f",oa[0],"\u5F3A\uFF1B\u652F\u6301 `$f`\u3001`$ff`\u3001`$fff` \u7B49\u8FDE\u7EED f\uFF0C\u6574\u4F53\u5C45\u4E2D"),pattern:{regex:/^f+$/,resolve:([a])=>kt(a,oa[Math.min(a.length,oa.length)-1],"\u5F3A\u529B\u5EA6\u8BB0\u53F7")}}];var Ic={},aa={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:a=>a.scaleFollowingBpm(Ic,1,2,{followConnections:!0})};var sa={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',fontStyle:"italic"},onVisit:(a,e)=>{let t=a.seek(Ye,e,1);return t!==void 0&&a.visits(t)>0?{kind:"stop"}:void 0}};var ia={name:"harmonic",description:"\u6CDB\u97F3",weight:.5,shapes:[{circle:{cx:5,cy:5,r:4.5},style:{fill:"none",stroke:"#000",strokeWidth:1}}]};var ca={name:"marcato",description:"\u5F3A\u8C03\u97F3\uFF1A\u5C16\u9876\u8BB0\u53F7\uFF1B\u64AD\u653E\u540C\u91CD\u97F3\uFF0C\u6240\u9644\u7740\u97F3\u7B26\u529B\u5EA6\u589E\u52A0 20\uFF0C\u6700\u9AD8 127",weight:.65,shapes:[{path:[{op:"M",x:0,y:10},{op:"L",x:4.5,y:0},{op:"L",x:5.5,y:0},{op:"L",x:10,y:10},{op:"L",x:8,y:10},{op:"L",x:5,y:3},{op:"L",x:2,y:10},{op:"Z"}],style:{fill:"#000"}}],emitPlayback:en.emitPlayback};var la={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:a=>a.affectFollowing(Ce({body:[0,-1,0]}))};var pa={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:a=>a.affectFollowing(Ce({body:[0,1,0]}))};var ua={name:"staccato",description:"\u65AD\u594F\uFF1A\u6240\u9644\u7740\u97F3\u7B26\u7684\u5B9E\u9645\u53D1\u58F0\u65F6\u957F\u7F29\u77ED\u4E3A\u4E00\u534A",weight:.8,shapes:[{path:[{op:"M",x:0,y:0},{op:"L",x:12,y:0},{op:"L",x:6,y:13},{op:"Z"}],style:{fill:"#000"}}],emitPlayback:a=>a.affectFollowing((e,t)=>{let n=t[0].start.clone();for(let o of t)o.start.sub(n).div(2).add(n),o.end.sub(n).div(2).add(n)})};var ma={name:"tenuto",description:"\u4FDD\u6301\u97F3",weight:.18,shapes:[{line:{x1:0,y1:0,x2:7.2,y2:0},style:{stroke:"#000",strokeWidth:1.8}}]};var da={name:"tocoda",description:"\u8DF3\u81F3\u5C3E\u58F0\uFF1A\u56DE\u8DF3\u4E4B\u540E\u7ECF\u8FC7\u8FD9\u91CC\u5C31\u8DF3\u5411\u6700\u8FD1\u7684 $coda",weight:1.4,text:{content:"To Coda",fontFamily:'"Times New Roman", serif',fontStyle:"italic"},onVisit:(a,e)=>{let t=a.seek(Ye,e,1),n=a.seek(Wn,e,1);return t!==void 0&&a.visits(t)>0&&n!==void 0?{kind:"jump",column:n}:void 0}};var vt={name:"tr",description:"\u98A4\u97F3\uFF1A\u672C\u97F3\u4E0E\u8C03\u5185\u4E0A\u65B9\u4E8C\u5EA6\u4EA4\u66FF\u3002\u53EF\u5199\u4E3A `$tr++`\uFF0C\u6BCF\u4E2A\u7D27\u63A5\u7684 `+` \u6DFB\u52A0\u4E00\u622A\u6CE2\u6D6A\u5C3E\u5DF4",pattern:{regex:/^tr(\++)/,resolve:a=>{let e=[...vt.shapes];for(let t=0;t<a[1].length;t++)e.push({...Vc,dx:14.11212+t*5.95219});return{...vt,name:a[0],anchor:Dc,shapes:e}}},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:a=>a.affectFollowing(Ce({body:[0,1],repeat:!0}))},js=Ge(vt.shapes),Dc=js.x+js.w/2,Vc={path:[{op:"M",x:7.03619,y:4.89762},{op:"C",cx1:7.03619,cy1:4.89762,cx2:6.87351,cy2:4.70878,x:6.65687,y:4.5183},{op:"C",cx1:6.57594,cy1:4.43737,cx2:6.46721,cy2:4.41039,x:6.38546,y:4.41039},{op:"C",cx1:6.30535,cy1:4.41039,cx2:6.25058,cy2:4.43737,x:6.19662,y:4.49132},{op:"L",x:5.89905,y:4.78889},{op:"C",cx1:5.8451,cy1:4.84367,cx2:5.79033,cy2:4.87064,x:5.73719,y:4.87064},{op:"C",cx1:5.62846,cy1:4.87064,cx2:5.57451,cy2:4.78889,x:5.57451,y:4.78889},{op:"C",cx1:5.57451,cy1:4.78889,cx2:3.84223,cy2:3.30105,x:3.57164,y:3.05662},{op:"C",cx1:3.27407,cy1:2.8408,cx2:2.9765,cy2:2.75905,x:2.70591,y:2.75905},{op:"C",cx1:2.13857,cy1:2.75905,cx2:1.62355,cy2:3.08523,x:1.40773,y:3.32721},{op:"L",x:.10873,y:4.62703},{op:"C",cx1:.02698,cy1:4.70878,cx2:0,cy2:4.76192,x:0,y:4.84367},{op:"C",cx1:0,cy1:4.97773,cx2:.10873,cy2:5.08646,x:.10873,y:5.08646},{op:"C",cx1:.10873,cy1:5.08646,cx2:.27141,cy2:5.2753,x:.48723,y:5.46578},{op:"C",cx1:.56898,cy1:5.54671,cx2:.64909,cy2:5.57451,x:.73084,y:5.57451},{op:"C",cx1:.81259,cy1:5.57451,cx2:.86655,cy2:5.54671,x:.91968,y:5.49276},{op:"L",x:1.21725,y:5.19519},{op:"C",cx1:1.27284,cy1:5.14123,cx2:1.32598,cy2:5.11344,x:1.37993,y:5.11344},{op:"C",cx1:1.48866,cy1:5.11344,cx2:1.57041,cy2:5.19519,x:1.57041,y:5.19519},{op:"C",cx1:1.57041,cy1:5.19519,cx2:3.30105,cy2:6.65605,x:3.57164,y:6.89885},{op:"C",cx1:3.86921,cy1:7.1163,cx2:4.16678,cy2:7.19805,x:4.43819,y:7.19805},{op:"C",cx1:5.00635,cy1:7.19805,cx2:5.51973,cy2:6.87187,x:5.73719,y:6.62989},{op:"L",x:7.03619,y:5.33008},{op:"C",cx1:7.1163,cy1:5.24833,cx2:7.1441,cy2:5.16821,x:7.1441,y:5.11344},{op:"C",cx1:7.1441,cy1:4.97773,cx2:7.03619,cy2:4.89762,x:7.03619,y:4.89762},{op:"Z"}],style:{fill:"#000"}};/*!
87
+ */var rl=[{op:"M",x:-4,y:-376},{op:"C",cx1:-4,cy1:-363,cx2:0,cy2:-352,x:14,y:-352},{op:"L",x:146,y:-352},{op:"C",cx1:157,cy1:-165,cx2:296,cy2:-13,x:458,y:0},{op:"L",x:458,y:140},{op:"C",cx1:458,cy1:154,cx2:469,cy2:158,x:482,y:158},{op:"C",cx1:495,cy1:158,cx2:506,cy2:154,x:506,y:140},{op:"L",x:506,y:0},{op:"C",cx1:668,cy1:-13,cx2:808,cy2:-165,x:818,y:-352},{op:"L",x:937,y:-352},{op:"C",cx1:951,cy1:-352,cx2:955,cy2:-363,x:955,y:-376},{op:"C",cx1:955,cy1:-389,cx2:951,cy2:-400,x:937,y:-400},{op:"L",x:818,y:-400},{op:"C",cx1:808,cy1:-588,cx2:668,cy2:-739,x:506,y:-752},{op:"L",x:506,y:-881},{op:"C",cx1:506,cy1:-894,cx2:495,cy2:-898,x:482,y:-898},{op:"C",cx1:469,cy1:-898,cx2:458,cy2:-894,x:458,y:-881},{op:"L",x:458,y:-752},{op:"C",cx1:296,cy1:-739,cx2:157,cy2:-589,x:146,y:-400},{op:"L",x:14,y:-400},{op:"C",cx1:0,cy1:-400,cx2:-4,cy2:-389,x:-4,y:-376},{op:"Z"},{op:"M",x:653,y:-400},{op:"L",x:506,y:-400},{op:"L",x:506,y:-696},{op:"C",cx1:646,cy1:-684,cx2:653,cy2:-562,x:653,y:-400},{op:"Z"},{op:"M",x:506,y:-352},{op:"L",x:653,y:-352},{op:"C",cx1:650,cy1:-199,cx2:631,cy2:-63,x:506,y:-48},{op:"Z"},{op:"M",x:316,y:-400},{op:"C",cx1:316,cy1:-562,cx2:316,cy2:-684,x:458,y:-696},{op:"L",x:458,y:-400},{op:"Z"},{op:"M",x:458,y:-352},{op:"L",x:458,y:-48},{op:"C",cx1:329,cy1:-63,cx2:317,cy2:-198,x:316,y:-352},{op:"Z"}],Vs={name:"coda",description:"\u5C3E\u58F0\u8BB0\u53F7\uFF1A$tocoda \u7684\u8DF3\u8F6C\u76EE\u6807",weight:1.15,playbackMarks:()=>[Qr],shapes:[{path:rl,style:{fill:"#000"}}]};var at="repeat.jump",Hs={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:()=>[at],onVisit:(a,e)=>a.visits(e)>1?void 0:{kind:"jump",column:0}};var Jr="repeat.segno",Gs={name:"segno",description:"\u53CD\u590D\u8BB0\u53F7\uFF1AD.S. \u7684\u56DE\u8DF3\u76EE\u6807",weight:1.15,playbackMarks:()=>[Jr],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 zs={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:()=>[at],onVisit:(a,e)=>a.visits(e)>1?void 0:{kind:"jump",column:a.seek(Jr,e,-1)??0}};var al={},js={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:a=>a.scaleFollowingBpm(al,1,2,{followConnections:!0})};var Ws={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',fontStyle:"italic"},onVisit:(a,e)=>{let t=a.seek(at,e,1);return t!==void 0&&a.visits(t)>0?{kind:"stop"}:void 0}};var $s={name:"harmonic",description:"\u6CDB\u97F3",weight:.5,shapes:[{circle:{cx:5,cy:5,r:4.5},style:{fill:"none",stroke:"#000",strokeWidth:1}}]};var Us={name:"marcato",description:"\u5F3A\u8C03\u97F3\uFF1A\u5C16\u9876\u8BB0\u53F7\uFF1B\u64AD\u653E\u540C\u91CD\u97F3\uFF0C\u6240\u9644\u7740\u97F3\u7B26\u529B\u5EA6\u589E\u52A0 20\uFF0C\u6700\u9AD8 127",weight:.65,shapes:[{path:[{op:"M",x:0,y:10},{op:"L",x:4.5,y:0},{op:"L",x:5.5,y:0},{op:"L",x:10,y:10},{op:"L",x:8,y:10},{op:"L",x:5,y:3},{op:"L",x:2,y:10},{op:"Z"}],style:{fill:"#000"}}],emitPlayback:Yn.emitPlayback};var Ys={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:a=>a.affectFollowing(Pe({body:[0,-1,0]}))};var Ks={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:a=>a.affectFollowing(Pe({body:[0,1,0]}))};var Xs={name:"staccato",description:"\u65AD\u594F\uFF1A\u6240\u9644\u7740\u97F3\u7B26\u7684\u5B9E\u9645\u53D1\u58F0\u65F6\u957F\u7F29\u77ED\u4E3A\u4E00\u534A",weight:.8,shapes:[{path:[{op:"M",x:0,y:0},{op:"L",x:12,y:0},{op:"L",x:6,y:13},{op:"Z"}],style:{fill:"#000"}}],emitPlayback:a=>a.affectFollowing((e,t)=>{let n=t[0].start.clone();for(let o of t)o.start.sub(n).div(2).add(n),o.end.sub(n).div(2).add(n)})};var Zs={name:"tenuto",description:"\u4FDD\u6301\u97F3",weight:.18,shapes:[{line:{x1:0,y1:0,x2:7.2,y2:0},style:{stroke:"#000",strokeWidth:1.8}}]};var qs={name:"tocoda",description:"\u8DF3\u81F3\u5C3E\u58F0\uFF1A\u56DE\u8DF3\u4E4B\u540E\u7ECF\u8FC7\u8FD9\u91CC\u5C31\u8DF3\u5411\u6700\u8FD1\u7684 $coda",weight:1.4,text:{content:"To Coda",fontFamily:'"Times New Roman", serif',fontStyle:"italic"},onVisit:(a,e)=>{let t=a.seek(at,e,1),n=a.seek(Qr,e,1);return t!==void 0&&a.visits(t)>0&&n!==void 0?{kind:"jump",column:n}:void 0}};var rn={name:"tr",description:"\u98A4\u97F3\uFF1A\u672C\u97F3\u4E0E\u8C03\u5185\u4E0A\u65B9\u4E8C\u5EA6\u4EA4\u66FF\u3002\u53EF\u5199\u4E3A `$tr++`\uFF0C\u6BCF\u4E2A\u7D27\u63A5\u7684 `+` \u6DFB\u52A0\u4E00\u622A\u6CE2\u6D6A\u5C3E\u5DF4",pattern:{regex:/^tr(\++)/,resolve:a=>{let e=[...rn.shapes];for(let t=0;t<a[1].length;t++)e.push({...il,dx:14.11212+t*5.95219});return{...rn,name:a[0],anchor:sl,shapes:e}}},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:a=>a.affectFollowing(Pe({body:[0,1],repeat:!0}))},Qs=et(rn.shapes),sl=Qs.x+Qs.w/2,il={path:[{op:"M",x:7.03619,y:4.89762},{op:"C",cx1:7.03619,cy1:4.89762,cx2:6.87351,cy2:4.70878,x:6.65687,y:4.5183},{op:"C",cx1:6.57594,cy1:4.43737,cx2:6.46721,cy2:4.41039,x:6.38546,y:4.41039},{op:"C",cx1:6.30535,cy1:4.41039,cx2:6.25058,cy2:4.43737,x:6.19662,y:4.49132},{op:"L",x:5.89905,y:4.78889},{op:"C",cx1:5.8451,cy1:4.84367,cx2:5.79033,cy2:4.87064,x:5.73719,y:4.87064},{op:"C",cx1:5.62846,cy1:4.87064,cx2:5.57451,cy2:4.78889,x:5.57451,y:4.78889},{op:"C",cx1:5.57451,cy1:4.78889,cx2:3.84223,cy2:3.30105,x:3.57164,y:3.05662},{op:"C",cx1:3.27407,cy1:2.8408,cx2:2.9765,cy2:2.75905,x:2.70591,y:2.75905},{op:"C",cx1:2.13857,cy1:2.75905,cx2:1.62355,cy2:3.08523,x:1.40773,y:3.32721},{op:"L",x:.10873,y:4.62703},{op:"C",cx1:.02698,cy1:4.70878,cx2:0,cy2:4.76192,x:0,y:4.84367},{op:"C",cx1:0,cy1:4.97773,cx2:.10873,cy2:5.08646,x:.10873,y:5.08646},{op:"C",cx1:.10873,cy1:5.08646,cx2:.27141,cy2:5.2753,x:.48723,y:5.46578},{op:"C",cx1:.56898,cy1:5.54671,cx2:.64909,cy2:5.57451,x:.73084,y:5.57451},{op:"C",cx1:.81259,cy1:5.57451,cx2:.86655,cy2:5.54671,x:.91968,y:5.49276},{op:"L",x:1.21725,y:5.19519},{op:"C",cx1:1.27284,cy1:5.14123,cx2:1.32598,cy2:5.11344,x:1.37993,y:5.11344},{op:"C",cx1:1.48866,cy1:5.11344,cx2:1.57041,cy2:5.19519,x:1.57041,y:5.19519},{op:"C",cx1:1.57041,cy1:5.19519,cx2:3.30105,cy2:6.65605,x:3.57164,y:6.89885},{op:"C",cx1:3.86921,cy1:7.1163,cx2:4.16678,cy2:7.19805,x:4.43819,y:7.19805},{op:"C",cx1:5.00635,cy1:7.19805,cx2:5.51973,cy2:6.87187,x:5.73719,y:6.62989},{op:"L",x:7.03619,y:5.33008},{op:"C",cx1:7.1163,cy1:5.24833,cx2:7.1441,cy2:5.16821,x:7.1441,y:5.11344},{op:"C",cx1:7.1441,cy1:4.97773,cx2:7.03619,cy2:4.89762,x:7.03619,y:4.89762},{op:"Z"}],style:{fill:"#000"}};/*!
85
88
  * Bravura 1.482 ornamentTurn (U+E567), Y axis flipped; https://github.com/steinbergmedia/bravura
86
89
  * Copyright (c) 2026, Steinberg Media Technologies GmbH. Reserved Font Name "Bravura".
87
90
  * SPDX-License-Identifier: OFL-1.1
88
91
  * Full license: Bravura-LICENSE.txt in the package root and dist.
89
- */var Hc=[{op:"M",x:371,y:-218},{op:"C",cx1:340,cy1:-218,cx2:315,cy2:-204,x:315,y:-174},{op:"C",cx1:315,cy1:-152,cx2:330,cy2:-138,x:351,y:-138},{op:"C",cx1:380,cy1:-138,cx2:381,cy2:-161,x:402,y:-161},{op:"C",cx1:419,cy1:-161,cx2:435,cy2:-140,x:435,y:-114},{op:"C",cx1:435,cy1:-71,cx2:405,cy2:-50,x:370,y:-50},{op:"C",cx1:338,cy1:-50,cx2:305,cy2:-77,x:262,y:-125},{op:"C",cx1:213,cy1:-179,cx2:169,cy2:-217,x:104,y:-217},{op:"C",cx1:38,cy1:-217,cx2:0,cy2:-167,x:0,y:-103},{op:"C",cx1:0,cy1:-31,cx2:46,cy2:0,x:89,y:0},{op:"C",cx1:120,cy1:0,cx2:145,cy2:-14,x:145,y:-44},{op:"C",cx1:145,cy1:-66,cx2:130,cy2:-80,x:109,y:-80},{op:"C",cx1:80,cy1:-80,cx2:79,cy2:-57,x:58,y:-57},{op:"C",cx1:41,cy1:-57,cx2:25,cy2:-78,x:25,y:-104},{op:"C",cx1:25,cy1:-147,cx2:55,cy2:-168,x:90,y:-168},{op:"C",cx1:122,cy1:-168,cx2:155,cy2:-141,x:198,y:-93},{op:"C",cx1:247,cy1:-39,cx2:291,cy2:-1,x:356,y:-1},{op:"C",cx1:422,cy1:-1,cx2:460,cy2:-51,x:460,y:-115},{op:"C",cx1:460,cy1:-187,cx2:414,cy2:-218,x:371,y:-218},{op:"Z"}],Ws={path:Hc,style:{fill:"#000"}},ya={name:"turn",description:"\u56DE\u97F3",weight:.55,shapes:[Ws],emitPlayback:a=>a.affectFollowing(Ce({body:[1,0,-1,0]}))},fa={name:"iturn",description:"\u9006\u56DE\u97F3",weight:.55*396/218,shapes:[Ws,{line:{x1:230,y1:-290,x2:230,y2:74},style:{stroke:"#000",strokeWidth:32}}],emitPlayback:a=>a.affectFollowing(Ce({body:[-1,0,1,0]}))};var ha={name:"wheel",description:"\u8F6E\u6307",shapes:[{path:[{op:"M",x:8.8,y:0},{op:"L",x:11.2,y:0},{op:"L",x:11.2,y:6},{op:"L",x:8.8,y:6},{op:"Z"},{op:"M",x:13.43341,y:7.62266},{op:"L",x:19.13974,y:5.76856},{op:"L",x:19.88139,y:8.0511},{op:"L",x:14.17505,y:9.9052},{op:"Z"},{op:"M",x:11.38032,y:13.94141},{op:"L",x:14.90703,y:18.79551},{op:"L",x:16.84867,y:17.38483},{op:"L",x:13.32196,y:12.53073},{op:"Z"},{op:"M",x:8.61968,y:13.94141},{op:"L",x:5.09297,y:18.79551},{op:"L",x:3.15133,y:17.38483},{op:"L",x:6.67804,y:12.53073},{op:"Z"},{op:"M",x:6.56659,y:7.62266},{op:"L",x:.86026,y:5.76856},{op:"L",x:.11861,y:8.0511},{op:"L",x:5.82495,y:9.9052},{op:"Z"}],style:{fill:"#000"}}]};var tn=new Map,Yn=new Map,nn=Object.freeze({core:Object.freeze([vt,aa,pa,la,en,ha,ia,ma,ca,ua,ya,fa,...ra,Jr,ta,ea,sa,Qr,da]),table:tn,register:(...a)=>{let e=a.map(t=>{let n=t.name.toLowerCase(),o=t.pattern;if(o){let{regex:r}=o;if(r.global||r.sticky)throw new Error(`Symbol pattern must not use g or y flags: ${n}`);r.ignoreCase||(o={...o,regex:new RegExp(r.source,`${r.flags}i`)})}return{name:n,definition:t,pattern:o}});for(let{name:t,definition:n,pattern:o}of e)tn.set(t,n),o?Yn.set(t,o):Yn.delete(t)},clear:()=>{tn.clear(),Yn.clear()},reset:()=>{nn.clear(),nn.register(...nn.core)},ornament:Ce,bounds:Ge});nn.reset();var xa=class extends E{static def={name:["symbol","$"],description:"\u521B\u5EFA\u4E00\u4E2A\u4E50\u8C31\u7B26\u53F7",get details(){return`~~~jpfun
92
+ */var cl=[{op:"M",x:371,y:-218},{op:"C",cx1:340,cy1:-218,cx2:315,cy2:-204,x:315,y:-174},{op:"C",cx1:315,cy1:-152,cx2:330,cy2:-138,x:351,y:-138},{op:"C",cx1:380,cy1:-138,cx2:381,cy2:-161,x:402,y:-161},{op:"C",cx1:419,cy1:-161,cx2:435,cy2:-140,x:435,y:-114},{op:"C",cx1:435,cy1:-71,cx2:405,cy2:-50,x:370,y:-50},{op:"C",cx1:338,cy1:-50,cx2:305,cy2:-77,x:262,y:-125},{op:"C",cx1:213,cy1:-179,cx2:169,cy2:-217,x:104,y:-217},{op:"C",cx1:38,cy1:-217,cx2:0,cy2:-167,x:0,y:-103},{op:"C",cx1:0,cy1:-31,cx2:46,cy2:0,x:89,y:0},{op:"C",cx1:120,cy1:0,cx2:145,cy2:-14,x:145,y:-44},{op:"C",cx1:145,cy1:-66,cx2:130,cy2:-80,x:109,y:-80},{op:"C",cx1:80,cy1:-80,cx2:79,cy2:-57,x:58,y:-57},{op:"C",cx1:41,cy1:-57,cx2:25,cy2:-78,x:25,y:-104},{op:"C",cx1:25,cy1:-147,cx2:55,cy2:-168,x:90,y:-168},{op:"C",cx1:122,cy1:-168,cx2:155,cy2:-141,x:198,y:-93},{op:"C",cx1:247,cy1:-39,cx2:291,cy2:-1,x:356,y:-1},{op:"C",cx1:422,cy1:-1,cx2:460,cy2:-51,x:460,y:-115},{op:"C",cx1:460,cy1:-187,cx2:414,cy2:-218,x:371,y:-218},{op:"Z"}],Js={path:cl,style:{fill:"#000"}},ei={name:"turn",description:"\u56DE\u97F3",weight:.55,shapes:[Js],emitPlayback:a=>a.affectFollowing(Pe({body:[1,0,-1,0]}))},ti={name:"iturn",description:"\u9006\u56DE\u97F3",weight:.55*396/218,shapes:[Js,{line:{x1:230,y1:-290,x2:230,y2:74},style:{stroke:"#000",strokeWidth:32}}],emitPlayback:a=>a.affectFollowing(Pe({body:[-1,0,1,0]}))};var ni={name:"wheel",description:"\u8F6E\u6307",shapes:[{path:[{op:"M",x:8.8,y:0},{op:"L",x:11.2,y:0},{op:"L",x:11.2,y:6},{op:"L",x:8.8,y:6},{op:"Z"},{op:"M",x:13.43341,y:7.62266},{op:"L",x:19.13974,y:5.76856},{op:"L",x:19.88139,y:8.0511},{op:"L",x:14.17505,y:9.9052},{op:"Z"},{op:"M",x:11.38032,y:13.94141},{op:"L",x:14.90703,y:18.79551},{op:"L",x:16.84867,y:17.38483},{op:"L",x:13.32196,y:12.53073},{op:"Z"},{op:"M",x:8.61968,y:13.94141},{op:"L",x:5.09297,y:18.79551},{op:"L",x:3.15133,y:17.38483},{op:"L",x:6.67804,y:12.53073},{op:"Z"},{op:"M",x:6.56659,y:7.62266},{op:"L",x:.86026,y:5.76856},{op:"L",x:.11861,y:8.0511},{op:"L",x:5.82495,y:9.9052},{op:"Z"}],style:{fill:"#000"}}]};var an=new Map,Kn=new Map,sn=Object.freeze({core:Object.freeze([rn,js,Ks,Ys,Yn,ni,$s,Zs,Us,Xs,ei,ti,...ys,Hs,zs,Gs,Ws,Vs,qs]),table:an,register:(...a)=>{let e=a.map(t=>{let n=t.name.toLowerCase(),o=t.pattern;if(o){let{regex:r}=o;if(r.global||r.sticky)throw new Error(`Symbol pattern must not use g or y flags: ${n}`);r.ignoreCase||(o={...o,regex:new RegExp(r.source,`${r.flags}i`)})}return{name:n,definition:t,pattern:o}});for(let{name:t,definition:n,pattern:o}of e)an.set(t,n),o?Kn.set(t,o):Kn.delete(t)},clear:()=>{an.clear(),Kn.clear()},reset:()=>{sn.clear(),sn.register(...sn.core)},ornament:Pe,bounds:et});sn.reset();var ea=class extends P{static def={name:["symbol","$"],description:"\u521B\u5EFA\u4E00\u4E2A\u4E50\u8C31\u7B26\u53F7",get details(){return`~~~jpfun
90
93
  1 ^ @symbol(p, size=0.5em)
91
94
  ~~~
92
95
  **\u7B80\u5199**\uFF1A\`$name\`\uFF0C\u5982 \`1 ^ $p\`\u3002\u540D\u79F0\u8BFB\u53D6\u5230\u4E0B\u4E00\u4E2A\u7A7A\u767D\u6216\u5F53\u524D\u5185\u5BB9\u533A\u95F4\u672B\u5C3E\uFF0C\u8FDE\u7EED\u7684\u6807\u70B9\u4E5F\u5C5E\u4E8E\u540D\u79F0\u3002
93
96
 
94
97
  **\u5DF2\u6CE8\u518C\u8BB0\u53F7**
95
- ${[...tn.values()].map(e=>`- \`$${e.name}\`\uFF1A${e.description}`).join(`
96
- `)}`},allowExtraArgs:!1,args:[{name:"name",description:"\u5DF2\u6CE8\u518C\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(e,t,n){if(e[t]!=="$")return null;let o=/^\S+/.exec(e.slice(t+1,n))?.[0];if(!o)return null;let r=t+1+o.length;return{next:r,node:{kind:"call",typed:!0,name:"symbol",args:new Map([[0,o]]),span:{start:t,end:r},syntaxKind:"atom"}}}size;definition;constructor(e,t,n,o=null){super(e,o);let[r,s]=this.getArgValue(t,n);this.size=n.length2px(s);let i=r.toLowerCase(),c=tn.get(i);if(!c){let l;for(let p of Yn.values()){let u=p.regex.exec(i);if(!(!u||u.index!==0||u[0]!==i)){if(l)throw new Error(`Ambiguous symbol patterns: ${i}`);l={pattern:p,match:u}}}c=l?.pattern.resolve(l.match)}if(!c){let l="@symbol: \u672A\u77E5\u7B26\u53F7: ${name}",p={name:r};if(n.variables.strict)throw new w("E_UNKNOWN_SYMBOL",l,e,p);n.diagnostics.push(new I("W_UNKNOWN_SYMBOL",l,e,p));return}this.definition=c}loweringEnter(){return[this.definition?new ga(this):new W]}toString(e){return this.definition?`@symbol(${this.definition.name})`:super.toString(e)}},ba=xa,ga=class extends W{bounds;height;label;scale=1;baseline=0;constructor(e){super(),this.ast=e,this.mergeKey=Se,this.onTimeState=e.definition.onTimeState,this.emitPlayback=e.definition.emitPlayback,this.playbackMarks=e.definition.playbackMarks,this.bounds=Ge(e.definition.shapes??[]),this.height=e.size*(e.definition.weight??1);let t=e.definition.text;this.label=t&&{content:t.content,style:{fontSize:this.height,fontFamily:t.fontFamily,fontStyle:t.fontStyle}},this.initLayoutBox()}prepareLayout(e){if(this.label){let t=e.textMeasurer.measureText(this.label.content,this.label.style);this.box.w=t.w,this.box.h=t.h,this.baseline=t.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.label&&this.ast.definition.anchor!==void 0?(this.ast.definition.anchor-this.bounds.x)*this.scale:this.box.w/2,this.box.visualAxis=this.box.h/2}paint(e){this.label?e.drawText(this.label.content,this.box.x,this.box.y+this.baseline,this.label.style):It(e,this.ast.definition.shapes??[],this.bounds,this.box,this.scale)}playbackFlow(e){let t=this.ast.definition.onVisit;if(!t)return;let n=e(this);return n===void 0?void 0:{range:[n,n],run:o=>t(o,n)}}};var Sa=class a extends E{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(e,t,n){let o=t.lastIndexOf(".");if(o<0)return[t,Object.hasOwn(le.systemVariables,t)?le.systemVariables[t].type:"string"];let r=t.slice(o+1),s=e.functions.get(t.slice(0,o))?.prototype.def,i=s&&ct(s,r,-1);return!s||!i?(e.diagnostics.push(new I("W_SET_UNKNOWN_TARGET","@set \u7684\u53C2\u6570 [{key}] \u6CA1\u6709\u5BF9\u5E94\u7684\u51FD\u6570\u6216\u5176\u53C2\u6570\uFF0C\u5C06\u88AB\u5FFD\u7565",n,{key:t})),null):i==="content"||i==="label"?(e.diagnostics.push(new I("W_SET_INVALID_VALUE_TYPE","@set \u7684\u53C2\u6570 [{key}] \u5185\u5BB9\u548C\u6807\u7B7E\u4E0D\u80FD\u4F5C\u4E3A\u9ED8\u8BA4\u503C\uFF0C\u5C06\u88AB\u5FFD\u7565",n,{key:t})),null):[`${_t(s)}.${r}`.toLowerCase(),i]}args=new Map;constructor(e,t,n,o=null){super(e,o);for(let[r,s]of t){let i=s;if(typeof r!="string"){n.diagnostics.push(new I("W_SET_POSITIONAL_ARG","\u51FD\u6570 @set \u4E0D\u63A5\u6536\u4F4D\u7F6E\u53C2\u6570, \u4F4D\u7F6E\u53C2\u6570[{key}]\u5C06\u88AB\u5FFD\u7565",i.span,{key:r}));continue}let c=a.resolveTarget(n,r.toLowerCase(),i.nameSpan??i.span);if(c===null)continue;let[l,p]=c,u=n.parseArgWithType(i.valueSpan,p,e.start);if(u===null){n.diagnostics.push(new I("W_SET_INVALID_VALUE","\u51FD\u6570 @set \u7684\u53C2\u6570\u503C\u89E3\u6790\u5931\u8D25, \u53C2\u6570[{key}]\u5C06\u88AB\u5FFD\u7565",i.valueSpan,{key:r}));continue}n.setVariable(l,u),this.args.set(l,u)}}toString(){return`@set(${Array.from(this.args,([e,t])=>{let n=typeof t=="string"?ee(t):t&&typeof t=="object"&&"unit"in t?`${t.value}${t.unit}`:t;return`${e}=${n}`}).join(", ")})`}},Ta=Sa;var Ys=256;function on(a){return a.ast instanceof E&&a.ast.callName==="dash"}function wa(a){return"midi"in a}function rn(a,e=[]){if("host"in a&&M(a.host))return rn(a.host,e);if("members"in a&&Array.isArray(a.members)){for(let t of a.members)rn(t,e);return e}return(typeof a.resolvedMidi=="number"||a.ast.name==="9")&&e.push(a.box.y+a.box.visualAxis),e}function $s(a){let e=rn(a);return(Math.min(...e)+Math.max(...e))/2}function La(a,e,t){let n,o=[];for(let r=a.length-1;r>=0;r--){let s=a[r];if(s.origins.at(-1).node.track!==e.track)continue;let i=s.origins.find(c=>c.node===e);if(n){if(i!==n)break}else{if(!i)continue;if(t&&!s.end.equals(t))return[];n=i}if(t&&!s.end.equals(t))return[];o.push(s)}return o}function Gc(a){let e=1<<a;return(t,n)=>{let o=[];for(let r of n){let s=r.end.clone().sub(r.start),i=Math.min(Ys,Math.max(2,Math.round(s.toNumber()*e))),c=s.div(i);for(let l=0;l<i;l++){let p=c.clone().mul(l).add(r.start);o.push({...r,start:p,end:p.clone().add(c)})}}return o}}var Ca=class a extends E{static def={name:["tremolo"],description:"\u9707\u97F3\uFF08\u540C\u97F3\u9707\u97F3\u4E0E\u53CC\u97F3\u4EA4\u66FF\u9707\u97F3\uFF09",details:"~~~jpfun\n@tremolo(5, n=3)\n@tremolo({#5,^7, 2^4}, n=3)\n~~~\n- **\u5355\u97F3\u9707\u97F3**\uFF1A\u5185\u5BB9\u4E3A\u5355\u4E2A\u97F3\u7B26\u6216\u548C\u5F26\uFF08\u540E\u53EF\u63A5\u589E\u65F6\u7EBF `-`\uFF09\uFF0C\u659C\u6760\u8BB0\u5728\u6700\u672B\u5143\u7D20\u53F3\u4E0B\u89D2\uFF0C\u64AD\u653E\u65F6\u6309 `1 / 2^n` \u56DB\u5206\u97F3\u7B26\u65F6\u503C\u540C\u97F3\u91CD\u590D\u3002\n- **\u53CC\u97F3\u9707\u97F3**\uFF1A\u5185\u5BB9\u4E3A\u4E24\u4E2A\u540C\u8F68\u3001\u7B49\u65F6\u503C\u7684\u76F8\u90BB\u97F3\u7B26\u6216\u548C\u5F26\uFF0C\u659C\u6760\u8BB0\u5728\u4E24\u97F3\u4E4B\u95F4\uFF0C\u64AD\u653E\u65F6\u5728\u4E24\u97F3\u603B\u65F6\u503C\u5185\u6309 `1 / 2^n` \u56DB\u5206\u97F3\u7B26\u65F6\u503C\u4EA4\u66FF\u53D1\u58F0\u3002",allowExtraArgs:!1,args:[{type:"content",default:null,description:"\u5355\u4E2A\u97F3\u7B26\uFF08\u53EF\u5E26\u589E\u65F6\u7EBF\uFF09\u6216\u4E24\u4E2A\u7B49\u65F6\u503C\u7684\u97F3\u7B26/\u548C\u5F26"},{name:"n",type:"number",default:3,description:"\u659C\u6760\u6570\u91CF\uFF0C\u53D6 1..3 \u7684\u6574\u6570"}]};content;n;get children(){return[this.content]}constructor(e,t,n,o=null){super(e,o);let[r,s]=this.getArgValue(t,n);if(!Number.isSafeInteger(s)||s<1||s>3)throw new w("E_TREMOLO_INVALID_N","@tremolo \u7684\u659C\u6760\u6570 n \u5FC5\u987B\u662F 1 \u5230 3 \u7684\u6574\u6570",e);this.content=r,this.n=s,r.parent=this}loweringEnter(e){for(let n=this.parent;n;n=n.parent)if(n instanceof a)throw new w("E_TREMOLO_CONTENT","@tremolo \u4E0D\u80FD\u5D4C\u5957 @tremolo",this.sourceSpan);let t={nodes:[],onTemporal(n){M(n)&&t.nodes.push(n)}};return e.beginLoweringGroup(this,t),[]}loweringExit(e){let{nodes:t}=e.endLoweringGroup(this),n=t.length>=1&&!on(t[0])&&t.slice(1).every(on),o=t.length===2&&!on(t[0])&&!on(t[1]);if(!n&&!o||t.some(c=>c.T.compare(0)<=0))throw new w("E_TREMOLO_CONTENT","@tremolo \u7684\u5185\u5BB9\u5FC5\u987B\u662F\u5355\u4E2A\u97F3\u7B26\uFF08\u53EF\u5E26\u589E\u65F6\u7EBF\uFF09\u6216\u4E24\u4E2A\u7B49\u65F6\u503C\u7684\u97F3\u7B26/\u548C\u5F26",this.sourceSpan);if(t.some(c=>c.track!==t[0].track))throw new w("E_TREMOLO_CROSS_TRACK","@tremolo \u7684\u5185\u5BB9\u5FC5\u987B\u4F4D\u4E8E\u540C\u4E00\u97F3\u8F68",this.sourceSpan);let r=new Aa(t,this);e.addAttachment(r),e.deferFinalize(()=>r.finalize());let s=n?t.at(-1):t[0],i=s.prepareHorizontal;return s.prepareHorizontal=c=>{i?.call(s,c),r.registerHorizontal(c)},[]}toString(e){return`@tremolo(${this.content.toString(e)}, n=${this.n})`}},Na=Ca,Aa=class{constructor(e,t){this.nodes=e;this.owner=t;let n=e.length===1||on(e[1]);this.endPoints=n?[e.at(-1)]:[e[0],e[1]]}nodes;owner;kind="tremolo";layer="foreground";endPoints;get sourceSpan(){return this.owner.sourceSpan}finalize(){let{nodes:e,owner:t,endPoints:n}=this,o=n.length===1,r=e[0].layoutLine;if(e.some(l=>l.layoutLine!==r))throw new w("E_TREMOLO_CROSS_LINE","@tremolo \u4E0D\u652F\u6301\u8DE8\u8C31\u9762\u884C",t.sourceSpan);if(rn(e[0]).length===0||!o&&rn(e[1]).length===0)throw new w("E_TREMOLO_CONTENT","@tremolo \u7684\u76EE\u6807\u5FC5\u987B\u5305\u542B\u53D1\u58F0\u97F3\u7B26",t.sourceSpan);if(o){let l=e[0],p=Gc(t.n),u=l.emitPlayback;l.emitPlayback=m=>{u?.call(l,m),m.defer(y=>{for(let d of La(y.spans,l))wa(d)&&y.transform(d,p)})};return}let[s,i]=e;if(!s.T.equals(i.T))throw new w("E_TREMOLO_DURATION_MISMATCH","@tremolo \u53CC\u97F3\u9707\u97F3\u7684\u4E24\u4E2A\u76EE\u6807\u65F6\u503C\u5FC5\u987B\u76F8\u7B49",t.sourceSpan);let c=i.emitPlayback;i.emitPlayback=l=>{c?.call(i,l);let{start:p,end:u}=l;l.defer(m=>{let y=La(m.spans,s,p),d=La(m.spans,i);if(y.length===0||d.length===0)return;let g=y.reduce((L,C)=>C.start.compare(L)<0?C.start:L,y[0].start).clone(),f=u.clone().sub(g),x=Math.min(Ys/2,Math.max(2,Math.round(f.toNumber()*(1<<t.n-1)))),h=f.clone().div(x*2),b=(L,C)=>(N,P)=>P.flatMap(k=>{let _=(k.end.compare(u)>0?u:k.end).clone().sub(k.start).div(L),v=[];for(let R=0;R<x;R++){let D=_.clone().mul(2*R).add(k.start),K=C&&R===x-1&&k.end.compare(u)>0?k.end.clone():D.clone().add(_);v.push({...k,start:D,end:K})}return v}),S=b(x*2,!1),T=b(x*2-1,!0);for(let L of y)L.start.copyFrom(g),L.end.copyFrom(u),wa(L)&&m.transform(L,S);for(let L of d)L.start.copyFrom(g).add(h),L.end.copyFrom(u),wa(L)&&m.transform(L,T)})}}registerHorizontal(e){if(this.endPoints.length===1){let c=this.endPoints[0];if(e.columnOf(c)<0)return;let l=c.ast.size,p=c.box.w-c.box.anchor+l*.6;e.registerHorizontalLayoutHook(c,c,({columns:u,start:m})=>{for(let y of u[m])y.box===c.box&&(y.WR=Math.max(y.WR,p))});return}let[t,n]=this.endPoints,o=e.columnOf(t),r=e.columnOf(n);if(o<0||r<0)return;if(r<=o||e.trackIndexOf(n)!==e.trackIndexOf(t)+1)throw new w("E_TREMOLO_ADJACENT","@tremolo \u53CC\u97F3\u9707\u97F3\u7684\u4E24\u4E2A\u7AEF\u70B9\u5FC5\u987B\u5728\u540C\u4E00\u8C31\u9762\u884C\u76F8\u90BB",this.owner.sourceSpan);let s=Math.max(t.ast.size,n.ast.size),i=t.box.w-t.box.anchor+s*.84;e.registerHorizontalLayoutHook(t,n,({columns:c})=>{for(let l of c[o])l.WR=Math.max(l.WR,i)})}createGeometry(){let{n:e}=this.owner,t=this.endPoints[0],n=t.ast.size,o,r,s,i,c;if(this.endPoints.length===1)o=t.box.x+t.box.w+n*.1,r=o+n*.34,s=t.box.y+t.box.visualAxis+n*.14,i=n*.18,c=n*.12;else{let[y,d]=this.endPoints;n=Math.max(y.ast.size,d.ast.size);let g=n*.12,f=y.box.x+y.box.w+g,x=d.box.x-g;if(x<=f)throw new w("E_TREMOLO_SPACE","@tremolo \u7684\u7AEF\u70B9\u4E4B\u95F4\u6CA1\u6709\u53EF\u7528\u7684\u6C34\u5E73\u7ED8\u5236\u7A7A\u95F4",this.owner.sourceSpan);let h=Math.min(x-f,n*1.2),b=(f+x)/2;o=b-h/2,r=b+h/2,s=($s(y)+$s(d))/2,i=Math.min(n*.26,Math.max(n*.16,h*.32)),c=n*.13}let l=Math.max(1,n*.06),p=zc(e,o,r,s,i,c),u=he(p);return{regions:[{x:u.x-l/2,y:u.y-l/2,w:u.w+l,h:u.h+l,line:t.layoutLine,track:t.track}],paint(y){y.drawPath(p,{fill:"none",stroke:"#000",strokeWidth:l})}}}};function zc(a,e,t,n,o,r){let s=[];for(let i=0;i<a;i++){let c=n+(i-(a-1)/2)*r;s.push({op:"M",x:e,y:c+o/2},{op:"L",x:t,y:c-o/2})}return s}var ka=class extends E{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\n\u64AD\u653E\u533A\u95F4\u5305\u542B\u7EC8\u70B9\u4E8B\u4EF6\u7684\u5B8C\u6574\u65F6\u503C\uFF0C\u4F46\u4E0D\u5305\u542B\u5176\u7ED3\u675F\u65F6\u523B\u7684\u5C0F\u8282\u7EBF\u6216\u540E\u7EED\u4E8B\u4EF6\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(e){let t=e.getTemporalNodes(this.from).at(0)?.rootHost,n=e.getTemporalNodes(this.to).at(-1)?.rootHost;return!t||!n?(e.diagnostics.push(O.warning.UnresolvedEndpoint("volta",this.sourceSpan)),[]):(e.addAttachment(new va(this,t,n)),[])}constructor(e,t,n,o=null){super(e,o);let[r,s,i]=this.getArgValue(t,n);this.font=n.variables.numberfont;let c=new Set([i]);for(let l=3;t.has(l);l++)c.add(t.get(l));if(this.from=r,this.to=s,this.passes=[...c].sort((l,p)=>l-p),this.size=n.variables.fontsize,this.passes.some(l=>!Number.isSafeInteger(l)||l<=0))throw new w("E_VOLTA_INVALID_PASS","@volta \u7684\u904D\u6570\u5FC5\u987B\u662F\u6B63\u6574\u6570",e)}toString(e){let t=n=>n.label??n.toString(e);return`@volta(${t(this.from)}, ${t(this.to)}, ${this.passes.join(", ")})`}},Pa=ka;function Ks(a){if(a?.[0]?.mergeKey===Q)return a[0]}var va=class{constructor(e,t,n){this.ast=e;this.from=t;this.to=n}ast;from;to;kind="volta";layer="foreground";get sourceSpan(){return this.ast.sourceSpan}get endPoints(){return[this.from,this.to]}playbackFlow(e){let t=e(this.from),n=e(this.to);if(t===void 0||n===void 0)return;let o=Math.min(t,n),r=(this.from.t.compare(this.to.t)||this.from.T.compare(this.to.T))>0?this.from:this.to,s=e(r,"end");if(s!==void 0)return{range:[o,s],run:i=>this.ast.passes.includes(vo(i,o))?void 0:{kind:"jump",column:s+1}}}createGeometry(e){if(!M(this.from)||!M(this.to))return{regions:[],paint(){}};let t=N=>{let P=e.lines[N.layoutLine];return{line:N.layoutLine,view:P,column:P.columnOf(N)}},[n,o]=[t(this.from),t(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 r=n.view.columns[n.column][0],s=o.view.columns[o.column][0],i=Ks(n.view.columns[n.column-1]),c=Ks(o.view.columns[o.column+1]),l=r.layoutLine,p=s.layoutLine,u=this.ast.size,m={fontSize:u*.6,fontFamily:this.ast.font,textAlign:"left",fill:"#000"},y=this.ast.passes.map(N=>`${N}.`).join(""),d=e.textMeasurer.measureText(y,m),g=Math.max(1,u*.055),f=g/2,x=d.h*1.2,h=u*.15,b=(x-d.h)/2+d.baseline+2,S=Math.max(g,f+h+d.w),T=Math.max(x+f,b-d.baseline+d.h),L=u*.2,C=Array.from({length:p-l+1},(N,P)=>{let k=l+P,B=r.track,_=1/0,v=k!==l&&k!==p?e.getRangeExtents(k):e.getRangeExtents(k,[r,s]);for(let[G,$]of v){let U=e.getVisualAxis(k,G)+$.top;U<_&&(B=G,_=U)}_===1/0&&(_=e.getVisualAxis(k,B));let R=k!==l?Te(e,k,B):i?.layoutLine===k?i.box.x+i.box.anchor+5:r.box.x+(r.ports["body.left"]?.x??0),D=k!==p?we(e,k):c?.layoutLine===k?c.box.x+c.box.anchor:s.box.x+(s.ports["body.right"]?.x??s.box.w),K=Math.min(R,D),X=Math.max(R,D),ne=(G,$,U)=>({x:G,y:-f,w:$,h:U+f,line:k,track:B}),J=[ne(K-f,X-K+g,f)];k===l&&J.push(ne(K-f,S,T)),k===p&&J.push(ne(X-f,g,x+f));let H=1/0;for(let G of J)for(let[$,U]of e.getHorizontalExtents(k,G.x,G.x+G.w))H=Math.min(H,e.getVisualAxis(k,$)+U.top-L-(G.y+G.h));H===1/0&&(H=_-L-f);for(let G of J)G.y+=H;return{left:K,right:X,lineY:H,line:k,parts:J}});return{regions:C.map(({parts:N})=>({...N[0],w:Math.max(...N.map(P=>P.x+P.w))-N[0].x,h:Math.max(...N.map(P=>P.h))})),occupancy:C.flatMap(N=>N.parts),paint(N){let P={stroke:"#000",strokeWidth:g};for(let{left:k,right:B,lineY:_,line:v}of C)N.drawLine(k,_,B,_,P),v===l&&(N.drawLine(k,_,k,_+x,P),N.drawText(y,k+h,_+b,m)),v===p&&N.drawLine(B,_,B,_+x,P)}}}};var Un=new WeakMap,Us=new WeakMap;function Xs(a,e){let t=Us.get(a);if(!t){t=new Map;for(let n of a)for(let{node:o}of n.origins){if(!Un.has(o))continue;let r=t.get(o);r?r.push(n):t.set(o,[n])}Us.set(a,t)}return t.get(e)??[]}var Zs=4/3,jc=.09,qs=2.5,Qs=.5,Wc=.45,Ea=class extends E{static def={name:["tie"],description:"\u8FDE\u97F3\u7EBF",details:"~~~jpfun\n1@a 2 3@b @tie(a, b, height=0.5em)\n~~~\n- **\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\n- **height**\uFF1A\u4EC5\u547D\u540D\u7684\u5F27\u7EBF\u9AD8\u5EA6\u53C2\u6570\uFF0C\u9ED8\u8BA4 `0`\uFF08\u81EA\u52A8\uFF09\uFF1B\u975E\u6B63\u6570\u6309\u6C34\u5E73\u8DE8\u5EA6\u81EA\u52A8\u8C03\u6574\uFF0C\u5728 `2.5em` \u8DE8\u5EA6\u5904\u5E73\u6ED1\u8FBE\u5230 `0.5em` \u4E0A\u9650\uFF0C\u6B63\u6570\u6307\u5B9A\u56FA\u5B9A\u5F27\u9AD8\u3002em \u76F8\u5BF9\u8C03\u7528\u5904\u5B57\u53F7\uFF1B\u53EF\u7528 `@set(tie.height=0.8em)` \u8BBE\u7F6E\u5C40\u90E8\u9ED8\u8BA4\u503C\uFF0C\u663E\u5F0F\u4F20\u53C2\u4F18\u5148\n\n\u540C\u884C\u7AEF\u70B9\u7528\u4E00\u6761\u5F27\u7EBF\u8FDE\u63A5\uFF0C\u81EA\u52A8\u9AD8\u5EA6\u6309\u6C34\u5E73\u8DE8\u5EA6\u8BA1\u7B97\uFF1B\u8DE8\u884C\u65F6\u81EA\u52A8\u62C6\u6210\u591A\u6BB5\uFF0C\u81EA\u52A8\u6A21\u5F0F\u4E0B\u5404\u6BB5\u7EDF\u4E00\u4F7F\u7528 `0.45em` \u9AD8\u5EA6\u3002\u540C\u8F68\u540C\u97F3\u4E14\u65F6\u95F4\u8FDE\u7EED\u7684\u97F3\u6BB5\u5EFA\u7ACB\u64AD\u653E\u8FDE\u63A5\uFF1A\u672A\u53E6\u52A0\u4FEE\u9970\u7684\u540E\u7EE7\u97F3\u6BB5\u5E76\u5165\u524D\u6BB5\u5171\u540C\u5C55\u5F00\uFF08\u5982 `1 ^ $tr 1 @tie()` \u5168\u7A0B\u98A4\u97F3\uFF09\uFF0C\u5E26\u72EC\u7ACB\u4FEE\u9970\u7684\u540E\u7EE7\u97F3\u6BB5\u4ECE\u81EA\u8EAB\u8D77\u70B9\u751F\u6548\uFF08\u5982 `1 1 ^ $tr @tie()` \u4ECE\u7B2C\u4E8C\u62CD\u5F00\u59CB\u98A4\u97F3\uFF09\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:[{name:"height",namedOnly:!0,description:"\u5F27\u7EBF\u9AD8\u5EA6\uFF0C\u652F\u6301 px/em\uFF1Bem \u76F8\u5BF9\u8C03\u7528\u5904\u5B57\u53F7\uFF0C\u975E\u6B63\u6570\u81EA\u52A8\u8C03\u6574\uFF0C\u6700\u9AD8 0.5em",type:"length",default:{value:0,unit:"em"}}]};endPoints=[];height;constructor(e,t,n,o=null){super(e,o);let[r]=this.getArgValue(t,n);for(let[i,c]of t)typeof i=="number"&&this.endPoints.push(c);let s=n.labelableNodes.length-1;for(;this.endPoints.length<2&&s>=0;){let i=n.labelableNodes[s--];!i||this.endPoints.includes(i)||this.endPoints.unshift(i)}if(this.endPoints.length<2)throw new w("E_NOT_ENOUGH_ARGS","@{fn} \u8FDE\u97F3\u7EBF\u9700\u8981\u81F3\u5C11\u4E24\u4E2A\u7AEF\u70B9",e,{fn:"tie"});this.height=Math.max(0,n.length2px(r))}loweringEnter(e){let t=[];for(let n of this.endPoints){let o=e.getTemporalNodes(n).at(-1);!o||!M(o)||t.push(o)}return t.length<2?(e.diagnostics.push(O.warning.UnresolvedEndpoint("tie",this.sourceSpan)),[]):(e.addAttachment(new _a(t,this.height,this.sourceSpan)),[])}toString(e){let t=this.endPoints.map(n=>n.label);return t.some(n=>n===void 0)?e.slice(this.sourceSpan.start,this.sourceSpan.end):`@tie(${t.join(", ")}, height=${this.height}px)`}},Ra=Ea,_a=class{kind="tie";layer="foreground";sourceSpan;endPoints;height;size;thickness;constructor(e,t,n){this.endPoints=e;let o=e.every(r=>r.track===e[0].track)?t:0;for(let r of e){let s=Un.get(r);if(Un.set(r,Math.max(s??0,o||r.ast.size*Qs)),s!==void 0)continue;let i=r.prepareLayout;r.prepareLayout=c=>{i.call(r,c);let l=r.ast.size,p=r.ports["body.left"]?.x??0,u=r.ports["body.right"]?.x??r.box.w,m=Math.max(0,r.box.anchor-p,u-r.box.anchor),y=Math.min(.5,m/(l*qs)),d=Math.min(.5,y/.75);d=y/(.75*(1+2*d*(1-d))),d=Math.min(.5,y/(.75*(1+2*d*(1-d)))),r.decorations.push({above:{order:200,height:l*.1+4*d*(1-d)*Un.get(r)}})}}this.height=t,this.sourceSpan=n,this.size=e.reduce((r,s)=>Math.max(r,s.ast.size),0),this.thickness=Math.max(1.2,this.size*jc)}applyPlayback(e){for(let t of Xs(e.notes,this.endPoints[0])){let n=t;for(let o=1;o<this.endPoints.length;o++){let r=Xs(e.notes,this.endPoints[o]).find(s=>s!==n&&s.track===n.track&&s.midi===n.midi&&s.percussion===n.percussion&&n.end.equals(s.start)&&e.connect(n,s));if(!r)break;n=r}}}createGeometry(e){let t=this.createSegments(e),n=t.map(({commands:r,...s})=>s),o=t.map(r=>{let s=e.getHostExtent(r.line,r.track),i=s?Math.max(r.y,e.getVisualAxis(r.line,r.track)+s.top):r.y+r.h;return{x:r.x,y:r.y,w:r.w,h:i-r.y,line:r.line,track:r.track}});return{regions:n,occupancy:o,paint(r){for(let s of t)r.drawPath(s.commands,{fill:"#000"})}}}tiePort(e){let t=e.ports["tie.top"];return t?{x:e.box.x+t.x,y:e.box.y+t.y}:{x:e.box.x+e.box.anchor,y:te(e,!0).y}}createSegments(e){let t=[];for(let n=1;n<this.endPoints.length;n++){let o=this.endPoints[n-1],r=this.endPoints[n];o.layoutLine>r.layoutLine&&([o,r]=[r,o]);let s=this.tiePort(o),i=this.tiePort(r);if(o.layoutLine===r.layoutLine){let l=this.hostTop(e,o.layoutLine,o.track),p=this.hostTop(e,r.layoutLine,r.track);t.push(this.arcSegment(s,i,o.layoutLine,l<=p?o.track:r.track));continue}let c=this.height>0?this.height:this.size*Wc;t.push(this.openingSegment(s,we(e,o.layoutLine),c,o.layoutLine,o.track));for(let l=o.layoutLine+1;l<r.layoutLine;l++)t.push(this.horizontalSegment(Te(e,l,o.track),we(e,l),this.hostTop(e,l,o.track)-c,l,o.track));t.push(this.closingSegment(Te(e,r.layoutLine,r.track),i,c,r.layoutLine,r.track))}return t}resolveHeight(e){if(this.height>0)return this.height;let t=Math.min(1,e/(this.size*qs));return this.size*Qs*t*(2-t)}hostTop(e,t,n){return e.getVisualAxis(t,n)+(e.getHostExtent(t,n)?.top??0)}arcSegment(e,t,n,o){let r=e,s=t;r.x>s.x&&([r,s]=[s,r]);let i=(s.x-r.x)*.25,c=r.x+i,l=s.x-i,p=this.resolveHeight(s.x-r.x)*Zs,u=Math.max(0,p-this.thickness*Zs),m=[{op:"M",x:r.x,y:r.y},{op:"C",cx1:c,cy1:r.y-p,cx2:l,cy2:s.y-p,x:s.x,y:s.y},{op:"C",cx1:l,cy1:s.y-u,cx2:c,cy2:r.y-u,x:r.x,y:r.y},{op:"Z"}];return Kn(m,n,o)}openingSegment(e,t,n,o,r){let s=e.y-n,i=n*1.2;t=Math.max(t,e.x+i);let c=e.x+i,l=e.x+i*.45,p=s+this.thickness;return Kn([{op:"M",x:e.x,y:e.y},{op:"Q",cx:l,cy:s,x:c,y:s},{op:"L",x:t,y:s},{op:"L",x:t,y:p},{op:"L",x:c,y:p},{op:"Q",cx:l,cy:p,x:e.x,y:e.y},{op:"Z"}],o,r)}closingSegment(e,t,n,o,r){let s=t.y-n,i=n*1.2;e=Math.min(e,t.x-i);let c=t.x-i,l=t.x-i*.45,p=s+this.thickness;return Kn([{op:"M",x:e,y:s},{op:"L",x:c,y:s},{op:"Q",cx:l,cy:s,x:t.x,y:t.y},{op:"Q",cx:l,cy:p,x:c,y:p},{op:"L",x:e,y:p},{op:"Z"}],o,r)}horizontalSegment(e,t,n,o,r){return Kn([{op:"M",x:e,y:n},{op:"L",x:t,y:n},{op:"L",x:t,y:n+this.thickness},{op:"L",x:e,y:n+this.thickness},{op:"Z"}],o,r)}};function Kn(a,e,t){return{commands:a,line:e,track:t,...he(a)}}var Ma=class extends E{static def={name:["tuplet"],description:"\u591A\u8FDE\u97F3",details:`~~~jpfun
98
+ ${[...an.values()].map(e=>`- \`$${e.name}\`\uFF1A${e.description}`).join(`
99
+ `)}`},allowExtraArgs:!1,args:[{name:"name",description:"\u5DF2\u6CE8\u518C\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(e,t,n){if(e[t]!=="$")return null;let o=/^\S+/.exec(e.slice(t+1,n))?.[0];if(!o)return null;let r=t+1+o.length;return{next:r,node:{kind:"call",typed:!0,name:"symbol",args:new Map([[0,o]]),span:{start:t,end:r},syntaxKind:"atom"}}}size;definition;constructor(e,t,n,o=null){super(e,o);let[r,s]=this.getArgValue(t,n);this.size=n.length2px(s);let i=r.toLowerCase(),c=an.get(i);if(!c){let l;for(let p of Kn.values()){let u=p.regex.exec(i);if(!(!u||u.index!==0||u[0]!==i)){if(l)throw new Error(`Ambiguous symbol patterns: ${i}`);l={pattern:p,match:u}}}c=l?.pattern.resolve(l.match)}if(!c){let l="@symbol: \u672A\u77E5\u7B26\u53F7: ${name}",p={name:r};if(n.variables.strict)throw new w("E_UNKNOWN_SYMBOL",l,e,p);n.diagnostics.push(new O("W_UNKNOWN_SYMBOL",l,e,p));return}this.definition=c}loweringEnter(){return[this.definition?new ta(this):new H]}toString(e){return this.definition?`@symbol(${this.definition.name})`:super.toString(e)}},na=ea,ta=class extends H{bounds;height;label;scale=1;baseline=0;constructor(e){super(),this.ast=e,this.mergeKey=Le,this.onTimeState=e.definition.onTimeState,this.emitPlayback=e.definition.emitPlayback,this.playbackMarks=e.definition.playbackMarks,this.bounds=et(e.definition.shapes??[]),this.height=e.size*(e.definition.weight??1);let t=e.definition.text;this.label=t&&{content:t.content,style:{fontSize:this.height,fontFamily:t.fontFamily,fontStyle:t.fontStyle}},this.initLayoutBox()}prepareLayout(e){if(this.label){let t=e.textMeasurer.measureText(this.label.content,this.label.style);this.box.w=t.w,this.box.h=t.h,this.baseline=t.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.label&&this.ast.definition.anchor!==void 0?(this.ast.definition.anchor-this.bounds.x)*this.scale:this.box.w/2,this.box.visualAxis=this.box.h/2}paint(e){this.label?e.drawText(this.label.content,this.box.x,this.box.y+this.baseline,this.label.style):vn(e,this.ast.definition.shapes??[],this.bounds,this.box,this.scale)}playbackFlow(e){let t=this.ast.definition.onVisit;if(!t)return;let n=e(this);return n===void 0?void 0:{range:[n,n],run:o=>t(o,n)}}};var oa=class a 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(e,t,n){let o=t.lastIndexOf(".");if(o<0)return[t,Object.hasOwn(re.systemVariables,t)?re.systemVariables[t].type:"string"];let r=t.slice(o+1),s=e.functions.get(t.slice(0,o))?.prototype.def,i=s&&Ze(s,r,-1);return!s||!i?(e.diagnostics.push(new O("W_SET_UNKNOWN_TARGET","@set \u7684\u53C2\u6570 [{key}] \u6CA1\u6709\u5BF9\u5E94\u7684\u51FD\u6570\u6216\u5176\u53C2\u6570\uFF0C\u5C06\u88AB\u5FFD\u7565",n,{key:t})),null):i==="content"||i==="label"?(e.diagnostics.push(new O("W_SET_INVALID_VALUE_TYPE","@set \u7684\u53C2\u6570 [{key}] \u5185\u5BB9\u548C\u6807\u7B7E\u4E0D\u80FD\u4F5C\u4E3A\u9ED8\u8BA4\u503C\uFF0C\u5C06\u88AB\u5FFD\u7565",n,{key:t})),null):[`${Mt(s)}.${r}`.toLowerCase(),i]}args=new Map;constructor(e,t,n,o=null){super(e,o);for(let[r,s]of t){let i=s;if(typeof r!="string"){n.diagnostics.push(new O("W_SET_POSITIONAL_ARG","\u51FD\u6570 @set \u4E0D\u63A5\u6536\u4F4D\u7F6E\u53C2\u6570, \u4F4D\u7F6E\u53C2\u6570[{key}]\u5C06\u88AB\u5FFD\u7565",i.span,{key:r}));continue}let c=a.resolveTarget(n,r.toLowerCase(),i.nameSpan??i.span);if(c===null)continue;let[l,p]=c,u=n.parseArgWithType(i.valueSpan,p,e.start);if(u===null){n.diagnostics.push(new O("W_SET_INVALID_VALUE","\u51FD\u6570 @set \u7684\u53C2\u6570\u503C\u89E3\u6790\u5931\u8D25, \u53C2\u6570[{key}]\u5C06\u88AB\u5FFD\u7565",i.valueSpan,{key:r}));continue}n.setVariable(l,u),this.args.set(l,u)}}toString(){return`@set(${Array.from(this.args,([e,t])=>{let n=typeof t=="string"?te(t):t&&typeof t=="object"&&"unit"in t?`${t.value}${t.unit}`:t;return`${e}=${n}`}).join(", ")})`}},ra=oa;var ri=256;function cn(a){return a.ast instanceof P&&a.ast.callName==="dash"}function aa(a){return"midi"in a}function ln(a,e=[]){if("host"in a&&_(a.host))return ln(a.host,e);if("members"in a&&Array.isArray(a.members)){for(let t of a.members)ln(t,e);return e}return(typeof a.resolvedMidi=="number"||a.ast.name==="9")&&e.push(a.box.y+a.box.visualAxis),e}function oi(a){let e=ln(a);return(Math.min(...e)+Math.max(...e))/2}function sa(a,e,t){let n,o=[];for(let r=a.length-1;r>=0;r--){let s=a[r];if(s.origins.at(-1).node.track!==e.track)continue;let i=s.origins.find(c=>c.node===e);if(n){if(i!==n)break}else{if(!i)continue;if(t&&!s.end.equals(t))return[];n=i}if(t&&!s.end.equals(t))return[];o.push(s)}return o}function ll(a){let e=1<<a;return(t,n)=>{let o=[];for(let r of n){let s=r.end.clone().sub(r.start),i=Math.min(ri,Math.max(2,Math.round(s.toNumber()*e))),c=s.div(i);for(let l=0;l<i;l++){let p=c.clone().mul(l).add(r.start);o.push({...r,start:p,end:p.clone().add(c)})}}return o}}var ia=class a extends P{static def={name:["tremolo"],description:"\u9707\u97F3\uFF08\u540C\u97F3\u9707\u97F3\u4E0E\u53CC\u97F3\u4EA4\u66FF\u9707\u97F3\uFF09",details:"~~~jpfun\n@tremolo(5, n=3)\n@tremolo({#5,^7, 2^4}, n=3)\n~~~\n- **\u5355\u97F3\u9707\u97F3**\uFF1A\u5185\u5BB9\u4E3A\u5355\u4E2A\u97F3\u7B26\u6216\u548C\u5F26\uFF08\u540E\u53EF\u63A5\u589E\u65F6\u7EBF `-`\uFF09\uFF0C\u659C\u6760\u8BB0\u5728\u6700\u672B\u5143\u7D20\u53F3\u4E0B\u89D2\uFF0C\u64AD\u653E\u65F6\u6309 `1 / 2^n` \u56DB\u5206\u97F3\u7B26\u65F6\u503C\u540C\u97F3\u91CD\u590D\u3002\n- **\u53CC\u97F3\u9707\u97F3**\uFF1A\u5185\u5BB9\u4E3A\u4E24\u4E2A\u540C\u8F68\u3001\u7B49\u65F6\u503C\u7684\u76F8\u90BB\u97F3\u7B26\u6216\u548C\u5F26\uFF0C\u659C\u6760\u8BB0\u5728\u4E24\u97F3\u4E4B\u95F4\uFF0C\u64AD\u653E\u65F6\u5728\u4E24\u97F3\u603B\u65F6\u503C\u5185\u6309 `1 / 2^n` \u56DB\u5206\u97F3\u7B26\u65F6\u503C\u4EA4\u66FF\u53D1\u58F0\u3002",allowExtraArgs:!1,args:[{type:"content",default:null,description:"\u5355\u4E2A\u97F3\u7B26\uFF08\u53EF\u5E26\u589E\u65F6\u7EBF\uFF09\u6216\u4E24\u4E2A\u7B49\u65F6\u503C\u7684\u97F3\u7B26/\u548C\u5F26"},{name:"n",type:"number",default:3,description:"\u659C\u6760\u6570\u91CF\uFF0C\u53D6 1..3 \u7684\u6574\u6570"}]};content;n;get children(){return[this.content]}constructor(e,t,n,o=null){super(e,o);let[r,s]=this.getArgValue(t,n);if(!Number.isSafeInteger(s)||s<1||s>3)throw new w("E_TREMOLO_INVALID_N","@tremolo \u7684\u659C\u6760\u6570 n \u5FC5\u987B\u662F 1 \u5230 3 \u7684\u6574\u6570",e);this.content=r,this.n=s,r.parent=this}loweringEnter(e){for(let n=this.parent;n;n=n.parent)if(n instanceof a)throw new w("E_TREMOLO_CONTENT","@tremolo \u4E0D\u80FD\u5D4C\u5957 @tremolo",this.sourceSpan);let t={nodes:[],onTemporal(n){_(n)&&t.nodes.push(n)}};return e.beginLoweringGroup(this,t),[]}loweringExit(e){let{nodes:t}=e.endLoweringGroup(this),n=t.length>=1&&!cn(t[0])&&t.slice(1).every(cn),o=t.length===2&&!cn(t[0])&&!cn(t[1]);if(!n&&!o||t.some(c=>c.T.compare(0)<=0))throw new w("E_TREMOLO_CONTENT","@tremolo \u7684\u5185\u5BB9\u5FC5\u987B\u662F\u5355\u4E2A\u97F3\u7B26\uFF08\u53EF\u5E26\u589E\u65F6\u7EBF\uFF09\u6216\u4E24\u4E2A\u7B49\u65F6\u503C\u7684\u97F3\u7B26/\u548C\u5F26",this.sourceSpan);if(t.some(c=>c.track!==t[0].track))throw new w("E_TREMOLO_CROSS_TRACK","@tremolo \u7684\u5185\u5BB9\u5FC5\u987B\u4F4D\u4E8E\u540C\u4E00\u97F3\u8F68",this.sourceSpan);let r=new ca(t,this);e.addAttachment(r),e.deferFinalize(()=>r.finalize());let s=n?t.at(-1):t[0],i=s.prepareHorizontal;return s.prepareHorizontal=c=>{i?.call(s,c),r.registerHorizontal(c)},[]}toString(e){return`@tremolo(${this.content.toString(e)}, n=${this.n})`}},la=ia,ca=class{constructor(e,t){this.nodes=e;this.owner=t;let n=e.length===1||cn(e[1]);this.endPoints=n?[e.at(-1)]:[e[0],e[1]]}nodes;owner;kind="tremolo";layer="foreground";endPoints;get sourceSpan(){return this.owner.sourceSpan}finalize(){let{nodes:e,owner:t,endPoints:n}=this,o=n.length===1,r=e[0].layoutLine;if(e.some(l=>l.layoutLine!==r))throw new w("E_TREMOLO_CROSS_LINE","@tremolo \u4E0D\u652F\u6301\u8DE8\u8C31\u9762\u884C",t.sourceSpan);if(ln(e[0]).length===0||!o&&ln(e[1]).length===0)throw new w("E_TREMOLO_CONTENT","@tremolo \u7684\u76EE\u6807\u5FC5\u987B\u5305\u542B\u53D1\u58F0\u97F3\u7B26",t.sourceSpan);if(o){let l=e[0],p=ll(t.n),u=l.emitPlayback;l.emitPlayback=m=>{u?.call(l,m),m.defer(f=>{for(let d of sa(f.spans,l))aa(d)&&f.transform(d,p)})};return}let[s,i]=e;if(!s.T.equals(i.T))throw new w("E_TREMOLO_DURATION_MISMATCH","@tremolo \u53CC\u97F3\u9707\u97F3\u7684\u4E24\u4E2A\u76EE\u6807\u65F6\u503C\u5FC5\u987B\u76F8\u7B49",t.sourceSpan);let c=i.emitPlayback;i.emitPlayback=l=>{c?.call(i,l);let{start:p,end:u}=l;l.defer(m=>{let f=sa(m.spans,s,p),d=sa(m.spans,i);if(f.length===0||d.length===0)return;let h=f.reduce((L,C)=>C.start.compare(L)<0?C.start:L,f[0].start).clone(),y=u.clone().sub(h),g=Math.min(ri/2,Math.max(2,Math.round(y.toNumber()*(1<<t.n-1)))),x=y.clone().div(g*2),b=(L,C)=>(A,v)=>v.flatMap(N=>{let B=(N.end.compare(u)>0?u:N.end).clone().sub(N.start).div(L),$=[];for(let U=0;U<g;U++){let E=B.clone().mul(2*U).add(N.start),G=C&&U===g-1&&N.end.compare(u)>0?N.end.clone():E.clone().add(B);$.push({...N,start:E,end:G})}return $}),S=b(g*2,!1),T=b(g*2-1,!0);for(let L of f)L.start.copyFrom(h),L.end.copyFrom(u),aa(L)&&m.transform(L,S);for(let L of d)L.start.copyFrom(h).add(x),L.end.copyFrom(u),aa(L)&&m.transform(L,T)})}}registerHorizontal(e){if(this.endPoints.length===1){let c=this.endPoints[0];if(e.columnOf(c)<0)return;let l=c.ast.size,p=c.box.w-c.box.anchor+l*.6;e.registerHorizontalLayoutHook(c,c,({columns:u,start:m})=>{for(let f of u[m])f.box===c.box&&(f.WR=Math.max(f.WR,p))});return}let[t,n]=this.endPoints,o=e.columnOf(t),r=e.columnOf(n);if(o<0||r<0)return;if(r<=o||e.trackIndexOf(n)!==e.trackIndexOf(t)+1)throw new w("E_TREMOLO_ADJACENT","@tremolo \u53CC\u97F3\u9707\u97F3\u7684\u4E24\u4E2A\u7AEF\u70B9\u5FC5\u987B\u5728\u540C\u4E00\u8C31\u9762\u884C\u76F8\u90BB",this.owner.sourceSpan);let s=Math.max(t.ast.size,n.ast.size),i=t.box.w-t.box.anchor+s*.84;e.registerHorizontalLayoutHook(t,n,({columns:c})=>{for(let l of c[o])l.WR=Math.max(l.WR,i)})}createGeometry(){let{n:e}=this.owner,t=this.endPoints[0],n=t.ast.size,o,r,s,i,c;if(this.endPoints.length===1)o=t.box.x+t.box.w+n*.1,r=o+n*.34,s=t.box.y+t.box.visualAxis+n*.14,i=n*.18,c=n*.12;else{let[f,d]=this.endPoints;n=Math.max(f.ast.size,d.ast.size);let h=n*.12,y=f.box.x+f.box.w+h,g=d.box.x-h;if(g<=y)throw new w("E_TREMOLO_SPACE","@tremolo \u7684\u7AEF\u70B9\u4E4B\u95F4\u6CA1\u6709\u53EF\u7528\u7684\u6C34\u5E73\u7ED8\u5236\u7A7A\u95F4",this.owner.sourceSpan);let x=Math.min(g-y,n*1.2),b=(y+g)/2;o=b-x/2,r=b+x/2,s=(oi(f)+oi(d))/2,i=Math.min(n*.26,Math.max(n*.16,x*.32)),c=n*.13}let l=Math.max(1,n*.06),p=pl(e,o,r,s,i,c),u=Se(p);return{regions:[{x:u.x-l/2,y:u.y-l/2,w:u.w+l,h:u.h+l,line:t.layoutLine,track:t.track}],paint(f){f.drawPath(p,{fill:"none",stroke:"#000",strokeWidth:l})}}}};function pl(a,e,t,n,o,r){let s=[];for(let i=0;i<a;i++){let c=n+(i-(a-1)/2)*r;s.push({op:"M",x:e,y:c+o/2},{op:"L",x:t,y:c-o/2})}return s}var pa=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\n\u64AD\u653E\u533A\u95F4\u5305\u542B\u7EC8\u70B9\u4E8B\u4EF6\u7684\u5B8C\u6574\u65F6\u503C\uFF0C\u4F46\u4E0D\u5305\u542B\u5176\u7ED3\u675F\u65F6\u523B\u7684\u5C0F\u8282\u7EBF\u6216\u540E\u7EED\u4E8B\u4EF6\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(e){let t=e.getTemporalNodes(this.from).at(0)?.rootHost,n=e.getTemporalNodes(this.to).at(-1)?.rootHost;return!t||!n?(e.diagnostics.push(M.warning.UnresolvedEndpoint("volta",this.sourceSpan)),[]):(e.addAttachment(new ua(this,t,n)),[])}constructor(e,t,n,o=null){super(e,o);let[r,s,i]=this.getArgValue(t,n);this.font=n.variables.numberfont;let c=new Set([i]);for(let l=3;t.has(l);l++)c.add(t.get(l));if(this.from=r,this.to=s,this.passes=[...c].sort((l,p)=>l-p),this.size=n.variables.fontsize,this.passes.some(l=>!Number.isSafeInteger(l)||l<=0))throw new w("E_VOLTA_INVALID_PASS","@volta \u7684\u904D\u6570\u5FC5\u987B\u662F\u6B63\u6574\u6570",e)}toString(e){let t=n=>n.label??n.toString(e);return`@volta(${t(this.from)}, ${t(this.to)}, ${this.passes.join(", ")})`}},ma=pa;function ai(a){if(a?.[0]?.mergeKey===Q)return a[0]}var ua=class{constructor(e,t,n){this.ast=e;this.from=t;this.to=n}ast;from;to;kind="volta";layer="foreground";get sourceSpan(){return this.ast.sourceSpan}get endPoints(){return[this.from,this.to]}playbackFlow(e){let t=e(this.from),n=e(this.to);if(t===void 0||n===void 0)return;let o=Math.min(t,n),r=(this.from.t.compare(this.to.t)||this.from.T.compare(this.to.T))>0?this.from:this.to,s=e(r,"end");if(s!==void 0)return{range:[o,s],run:i=>this.ast.passes.includes(Za(i,o))?void 0:{kind:"jump",column:s+1}}}createGeometry(e){if(!_(this.from)||!_(this.to))return{regions:[],paint(){}};let t=A=>{let v=e.lines[A.layoutLine];return{line:A.layoutLine,view:v,column:v.columnOf(A)}},[n,o]=[t(this.from),t(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 r=n.view.columns[n.column][0],s=o.view.columns[o.column][0],i=ai(n.view.columns[n.column-1]),c=ai(o.view.columns[o.column+1]),l=r.layoutLine,p=s.layoutLine,u=this.ast.size,m={fontSize:u*.6,fontFamily:this.ast.font,textAlign:"left",fill:"#000"},f=this.ast.passes.map(A=>`${A}.`).join(""),d=e.textMeasurer.measureText(f,m),h=Math.max(1,u*.055),y=h/2,g=d.h*1.2,x=u*.15,b=(g-d.h)/2+d.baseline+2,S=Math.max(h,y+x+d.w),T=Math.max(g+y,b-d.baseline+d.h),L=u*.2,C=Array.from({length:p-l+1},(A,v)=>{let N=l+v,F=r.track,B=1/0,$=N!==l&&N!==p?e.getRangeExtents(N):e.getRangeExtents(N,[r,s]);for(let[W,j]of $){let q=e.getVisualAxis(N,W)+j.top;q<B&&(F=W,B=q)}B===1/0&&(B=e.getVisualAxis(N,F));let U=N!==l?Ce(e,N,F):i?.layoutLine===N?i.box.x+i.box.anchor+5:r.box.x+(r.ports["body.left"]?.x??0),E=N!==p?Ae(e,N):c?.layoutLine===N?c.box.x+c.box.anchor:s.box.x+(s.ports["body.right"]?.x??s.box.w),G=Math.min(U,E),K=Math.max(U,E),ne=(W,j,q)=>({x:W,y:-y,w:j,h:q+y,line:N,track:F}),J=[ne(G-y,K-G+h,y)];N===l&&J.push(ne(G-y,S,T)),N===p&&J.push(ne(K-y,h,g+y));let z=1/0;for(let W of J)for(let[j,q]of e.getHorizontalExtents(N,W.x,W.x+W.w))z=Math.min(z,e.getVisualAxis(N,j)+q.top-L-(W.y+W.h));z===1/0&&(z=B-L-y);for(let W of J)W.y+=z;return{left:G,right:K,lineY:z,line:N,parts:J}});return{regions:C.map(({parts:A})=>({...A[0],w:Math.max(...A.map(v=>v.x+v.w))-A[0].x,h:Math.max(...A.map(v=>v.h))})),occupancy:C.flatMap(A=>A.parts),paint(A){let v={stroke:"#000",strokeWidth:h};for(let{left:N,right:F,lineY:B,line:$}of C)A.drawLine(N,B,F,B,v),$===l&&(A.drawLine(N,B,N,B+g,v),A.drawText(f,N+x,B+b,m)),$===p&&A.drawLine(F,B,F,B+g,v)}}}};var Zn=new WeakMap,si=new WeakMap;function ii(a,e){let t=si.get(a);if(!t){t=new Map;for(let n of a)for(let{node:o}of n.origins){if(!Zn.has(o))continue;let r=t.get(o);r?r.push(n):t.set(o,[n])}si.set(a,t)}return t.get(e)??[]}var ci=4/3,ul=.09,li=2.5,pi=.5,ml=.45,da=class extends P{static def={name:["tie"],description:"\u8FDE\u97F3\u7EBF",details:"~~~jpfun\n1@a 2 3@b @tie(a, b, height=0.5em)\n~~~\n- **\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\n- **height**\uFF1A\u4EC5\u547D\u540D\u7684\u5F27\u7EBF\u9AD8\u5EA6\u53C2\u6570\uFF0C\u9ED8\u8BA4 `0`\uFF08\u81EA\u52A8\uFF09\uFF1B\u975E\u6B63\u6570\u6309\u6C34\u5E73\u8DE8\u5EA6\u81EA\u52A8\u8C03\u6574\uFF0C\u5728 `2.5em` \u8DE8\u5EA6\u5904\u5E73\u6ED1\u8FBE\u5230 `0.5em` \u4E0A\u9650\uFF0C\u6B63\u6570\u6307\u5B9A\u56FA\u5B9A\u5F27\u9AD8\u3002em \u76F8\u5BF9\u8C03\u7528\u5904\u5B57\u53F7\uFF1B\u53EF\u7528 `@set(tie.height=0.8em)` \u8BBE\u7F6E\u5C40\u90E8\u9ED8\u8BA4\u503C\uFF0C\u663E\u5F0F\u4F20\u53C2\u4F18\u5148\n\n\u540C\u884C\u7AEF\u70B9\u7528\u4E00\u6761\u5F27\u7EBF\u8FDE\u63A5\uFF0C\u81EA\u52A8\u9AD8\u5EA6\u6309\u6C34\u5E73\u8DE8\u5EA6\u8BA1\u7B97\uFF1B\u8DE8\u884C\u65F6\u81EA\u52A8\u62C6\u6210\u591A\u6BB5\uFF0C\u81EA\u52A8\u6A21\u5F0F\u4E0B\u5404\u6BB5\u7EDF\u4E00\u4F7F\u7528 `0.45em` \u9AD8\u5EA6\u3002\u540C\u8F68\u540C\u97F3\u4E14\u65F6\u95F4\u8FDE\u7EED\u7684\u97F3\u6BB5\u5EFA\u7ACB\u64AD\u653E\u8FDE\u63A5\uFF1A\u672A\u53E6\u52A0\u4FEE\u9970\u7684\u540E\u7EE7\u97F3\u6BB5\u5E76\u5165\u524D\u6BB5\u5171\u540C\u5C55\u5F00\uFF08\u5982 `1 ^ $tr 1 @tie()` \u5168\u7A0B\u98A4\u97F3\uFF09\uFF0C\u5E26\u72EC\u7ACB\u4FEE\u9970\u7684\u540E\u7EE7\u97F3\u6BB5\u4ECE\u81EA\u8EAB\u8D77\u70B9\u751F\u6548\uFF08\u5982 `1 1 ^ $tr @tie()` \u4ECE\u7B2C\u4E8C\u62CD\u5F00\u59CB\u98A4\u97F3\uFF09\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:[{name:"height",namedOnly:!0,description:"\u5F27\u7EBF\u9AD8\u5EA6\uFF0C\u652F\u6301 px/em\uFF1Bem \u76F8\u5BF9\u8C03\u7528\u5904\u5B57\u53F7\uFF0C\u975E\u6B63\u6570\u81EA\u52A8\u8C03\u6574\uFF0C\u6700\u9AD8 0.5em",type:"length",default:{value:0,unit:"em"}}]};endPoints=[];height;constructor(e,t,n,o=null){super(e,o);let[r]=this.getArgValue(t,n);for(let[i,c]of t)typeof i=="number"&&this.endPoints.push(c);let s=n.labelableNodes.length-1;for(;this.endPoints.length<2&&s>=0;){let i=n.labelableNodes[s--];!i||this.endPoints.includes(i)||this.endPoints.unshift(i)}if(this.endPoints.length<2)throw new w("E_NOT_ENOUGH_ARGS","@{fn} \u8FDE\u97F3\u7EBF\u9700\u8981\u81F3\u5C11\u4E24\u4E2A\u7AEF\u70B9",e,{fn:"tie"});this.height=Math.max(0,n.length2px(r))}loweringEnter(e){let t=[];for(let n of this.endPoints){let o=e.getTemporalNodes(n).at(-1);!o||!_(o)||t.push(o)}return t.length<2?(e.diagnostics.push(M.warning.UnresolvedEndpoint("tie",this.sourceSpan)),[]):(e.addAttachment(new ya(t,this.height,this.sourceSpan)),[])}toString(e){let t=this.endPoints.map(n=>n.label);return t.some(n=>n===void 0)?e.slice(this.sourceSpan.start,this.sourceSpan.end):`@tie(${t.join(", ")}, height=${this.height}px)`}},fa=da,ya=class{kind="tie";layer="foreground";sourceSpan;endPoints;height;size;thickness;constructor(e,t,n){this.endPoints=e;let o=e.every(r=>r.track===e[0].track)?t:0;for(let r of e){let s=Zn.get(r);if(Zn.set(r,Math.max(s??0,o||r.ast.size*pi)),s!==void 0)continue;let i=r.prepareLayout;r.prepareLayout=c=>{i.call(r,c);let l=r.ast.size,p=r.ports["body.left"]?.x??0,u=r.ports["body.right"]?.x??r.box.w,m=Math.max(0,r.box.anchor-p,u-r.box.anchor),f=Math.min(.5,m/(l*li)),d=Math.min(.5,f/.75);d=f/(.75*(1+2*d*(1-d))),d=Math.min(.5,f/(.75*(1+2*d*(1-d)))),r.decorations.push({above:{order:200,height:l*.1+4*d*(1-d)*Zn.get(r)}})}}this.height=t,this.sourceSpan=n,this.size=e.reduce((r,s)=>Math.max(r,s.ast.size),0),this.thickness=Math.max(1.2,this.size*ul)}applyPlayback(e){for(let t of ii(e.notes,this.endPoints[0])){let n=t;for(let o=1;o<this.endPoints.length;o++){let r=ii(e.notes,this.endPoints[o]).find(s=>s!==n&&s.track===n.track&&s.midi===n.midi&&s.percussion===n.percussion&&n.end.equals(s.start)&&e.connect(n,s));if(!r)break;n=r}}}createGeometry(e){let t=this.createSegments(e),n=t.map(({commands:r,...s})=>s),o=t.map(r=>{let s=e.getHostExtent(r.line,r.track),i=s?Math.max(r.y,e.getVisualAxis(r.line,r.track)+s.top):r.y+r.h;return{x:r.x,y:r.y,w:r.w,h:i-r.y,line:r.line,track:r.track}});return{regions:n,occupancy:o,paint(r){for(let s of t)r.drawPath(s.commands,{fill:"#000"})}}}tiePort(e){let t=e.ports["tie.top"];return t?{x:e.box.x+t.x,y:e.box.y+t.y}:{x:e.box.x+e.box.anchor,y:ee(e,!0).y}}createSegments(e){let t=[];for(let n=1;n<this.endPoints.length;n++){let o=this.endPoints[n-1],r=this.endPoints[n];o.layoutLine>r.layoutLine&&([o,r]=[r,o]);let s=this.tiePort(o),i=this.tiePort(r);if(o.layoutLine===r.layoutLine){let l=this.hostTop(e,o.layoutLine,o.track),p=this.hostTop(e,r.layoutLine,r.track);t.push(this.arcSegment(s,i,o.layoutLine,l<=p?o.track:r.track));continue}let c=this.height>0?this.height:this.size*ml;t.push(this.openingSegment(s,Ae(e,o.layoutLine),c,o.layoutLine,o.track));for(let l=o.layoutLine+1;l<r.layoutLine;l++)t.push(this.horizontalSegment(Ce(e,l,o.track),Ae(e,l),this.hostTop(e,l,o.track)-c,l,o.track));t.push(this.closingSegment(Ce(e,r.layoutLine,r.track),i,c,r.layoutLine,r.track))}return t}resolveHeight(e){if(this.height>0)return this.height;let t=Math.min(1,e/(this.size*li));return this.size*pi*t*(2-t)}hostTop(e,t,n){return e.getVisualAxis(t,n)+(e.getHostExtent(t,n)?.top??0)}arcSegment(e,t,n,o){let r=e,s=t;r.x>s.x&&([r,s]=[s,r]);let i=(s.x-r.x)*.25,c=r.x+i,l=s.x-i,p=this.resolveHeight(s.x-r.x)*ci,u=Math.max(0,p-this.thickness*ci),m=[{op:"M",x:r.x,y:r.y},{op:"C",cx1:c,cy1:r.y-p,cx2:l,cy2:s.y-p,x:s.x,y:s.y},{op:"C",cx1:l,cy1:s.y-u,cx2:c,cy2:r.y-u,x:r.x,y:r.y},{op:"Z"}];return Xn(m,n,o)}openingSegment(e,t,n,o,r){let s=e.y-n,i=n*1.2;t=Math.max(t,e.x+i);let c=e.x+i,l=e.x+i*.45,p=s+this.thickness;return Xn([{op:"M",x:e.x,y:e.y},{op:"Q",cx:l,cy:s,x:c,y:s},{op:"L",x:t,y:s},{op:"L",x:t,y:p},{op:"L",x:c,y:p},{op:"Q",cx:l,cy:p,x:e.x,y:e.y},{op:"Z"}],o,r)}closingSegment(e,t,n,o,r){let s=t.y-n,i=n*1.2;e=Math.min(e,t.x-i);let c=t.x-i,l=t.x-i*.45,p=s+this.thickness;return Xn([{op:"M",x:e,y:s},{op:"L",x:c,y:s},{op:"Q",cx:l,cy:s,x:t.x,y:t.y},{op:"Q",cx:l,cy:p,x:c,y:p},{op:"L",x:e,y:p},{op:"Z"}],o,r)}horizontalSegment(e,t,n,o,r){return Xn([{op:"M",x:e,y:n},{op:"L",x:t,y:n},{op:"L",x:t,y:n+this.thickness},{op:"L",x:e,y:n+this.thickness},{op:"Z"}],o,r)}};function Xn(a,e,t){return{commands:a,line:e,track:t,...Se(a)}}var ha=class extends P{static def={name:["tuplet"],description:"\u591A\u8FDE\u97F3",details:`~~~jpfun
97
100
  @tuplet({1/ 2 3}, normal=4)
98
101
  ~~~
99
- \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}]};content;normal;font;get children(){return[this.content]}loweringEnter(e){let t={nodes:[],attachments:[],onTemporal(n){t.nodes.push(n)},onAttachment(n){t.attachments.push(n)}};return e.beginLoweringGroup(this,t),[]}loweringExit(e,t,n){let o=e.endLoweringGroup(this),r=o.nodes.filter(d=>d.T.compare(0)>0);if(r.length===0)throw new w("E_TUPLET_EMPTY","@tuplet \u7684\u5185\u5BB9\u5FC5\u987B\u4EA7\u751F\u81F3\u5C11\u4E00\u4E2A\u6B63\u65F6\u503C\u4E8B\u4EF6",this.sourceSpan);let s=r[0].track;if(r.some(d=>d.track!==s))throw new w("E_TUPLET_PARALLEL_CONTENT","@tuplet \u7684\u5185\u5BB9\u4E0D\u80FD\u5305\u542B\u5E76\u884C\u97F3\u8F68",this.sourceSpan);let i=r[0].T.clone(),c=new V;for(let d of r)d.T.compare(i)<0&&i.copyFrom(d.T),c.add(d.T);let l=c.div(i),p=l.numerator;if(l.denominator!==1||p<2||!Number.isSafeInteger(p))throw new w("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===p)throw new w("E_TUPLET_INVALID_RATIO","@tuplet \u7684 normal \u4E0D\u80FD\u7B49\u4E8E\u63A8\u5BFC\u51FA\u7684 actual ({actual})",this.sourceSpan,{actual:p});let u=o.nodes[0].t;for(let d=1;d<o.nodes.length;d++)o.nodes[d].t.compare(u)<0&&(u=o.nodes[d].t);u=u.clone();let m=new V;for(let d of o.nodes)m.copyFrom(d.t).sub(u).mul(this.normal,p),d.t.copyFrom(u).add(m),d.T.mul(this.normal,p);n.copyFrom(u).add(i.mul(this.normal));let y=r.filter(M);if(y.length>=2){let d=new Fa(y,p,this.sourceSpan,this.font,o);e.addAttachment(d),e.deferFinalize(()=>d.validate())}return[]}constructor(e,t,n,o=null){super(e,o);let[r,s]=this.getArgValue(t,n);if(this.font=n.variables.numberfont,!Number.isSafeInteger(s)||s<=0)throw new w("E_TUPLET_INVALID_NORMAL","@tuplet \u7684 normal \u5FC5\u987B\u662F\u6B63\u7684\u5B89\u5168\u6574\u6570",e);this.content=r,this.normal=s,r.parent=this}toString(e){return`@tuplet(${this.content.toString(e)}, ${this.normal})`}},Ba=Ma,Fa=class{constructor(e,t,n,o,r){this.content=r;this.endPoints=e,this.actual=t,this.sourceSpan=n,this.size=e.reduce((s,i)=>Math.max(s,i.ast.size),0),this.style={fontSize:this.size*.72,fontFamily:o,textAlign:"center",fill:"#000"}}content;kind="tuplet";layer="foreground";endPoints;actual;sourceSpan;style;size;validate(){let e=this.endPoints[0];if(this.endPoints.some(t=>t.layoutLine!==e.layoutLine))throw new w("E_TUPLET_CROSS_LINE","@tuplet \u7684\u5185\u5BB9\u4E0D\u80FD\u8DE8\u8D8A\u8C31\u9762\u884C",this.sourceSpan)}createGeometry(e){let t=this.endPoints[0],n=this.endPoints[this.endPoints.length-1],o=t.ports["body.left"]?.x??0,r=n.ports["body.right"]?.x??n.box.w,s=t.box.x+o,i=n.box.x+r;s>i&&([s,i]=[i,s]);let c=e.textMeasurer.measureText(String(this.actual),this.style),l=(s+i)/2,p=this.size*.12,u=this.size*.18,m=this.size*.14,y=e.getVisualAxis(t.layoutLine,t.track),d=e.getRangeExtents(t.layoutLine,[t,n],t.track),g=e.getContentBounds(this.content),f=Math.min(y+(d?.top??0),g?.y??1/0),x=Math.max(1,this.size*.055),h=f-m-Math.max(u,c.h/2),b=h+u,S=h-c.h/2+c.baseline,T=l-c.w/2-p,L=l+c.w/2+p,C=[];T>s&&C.push([s,h,T,h]),L<i&&C.push([L,h,i,h]),C.push([s,h,s,b],[i,h,i,b]);let N=x/2,P=Math.min(h-c.h/2,h-N),k=Math.max(h+c.h/2,b+N),B=[{x:s-N,y:P,w:i-s+x,h:k-P,line:t.layoutLine,track:t.track}],_=String(this.actual),v=this.style;return{regions:B,paint(R){let D={stroke:"#000",strokeWidth:x};for(let[K,X,ne,J]of C)R.drawLine(K,X,ne,J,D);R.drawText(_,l,S,v)}}}};var Js=/\s/,ni=.88,oi=new Set("\uFF08([\uFF3B\uFF5B\u3008\u300A\u300C\u300E\u3010\u3014\u3016\u3018\u301A\u2018\u201C"),Oa=new Set([...oi,...`\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 an(a,e){return{fontFamily:e,fontSize:a*ni,fill:"#000"}}function ei(a,e,t){let n=ke(a,e,t),o=n.runs.map(c=>c.text).join(""),r=0,s=o.length;for(;r<s&&Oa.has(o[r]);)r++;for(;s>r&&Oa.has(o[s-1]);)s--;let i=(c,l)=>{let p=0,u=0;for(let m of n.runs){let y=u+m.text.length,d=Math.max(c,u),g=Math.min(l,y);d<g&&(p+=d===u&&g===y?m.w:t.measureText(m.text.slice(d-u,g-u),m.style).w),u=y}return p};return{richLine:n,prefixWidth:i(0,r),bodyWidth:i(r,s)}}function ti(a){return a.ports["body.left"]?.x??0}function Xn(a,e,t){let n=e==="L"?"WL":"WR",o=e==="L"?"margin_L":"margin_R";t>a[n]&&(a[o]=Math.max(0,a[n]+a[o]-t),a[n]=t)}function Zn(a,e,t){let n=0;for(let h=0;h<a.length;h++)a[h]==="\\"?h++:a[h]==="}"&&n++;let o=[],r=[],s,i,c=-1,l=0,p=0,u=0,m=0,y=!1,d=!1,g=(h,b)=>{c<0&&(c=h),l=b},f=(h,b,S,T)=>{Fe(r,h,b),g(S,T),y=!0},x=(h=!1)=>{!h&&!y||(t&&e&&c>=0&&(t[o.length]=i={start:e[c],end:e[l]}),o.push(s=r),r=[],c=-1,y=!1)};if(zt(a,(h,b,S,T,L)=>{if(!S&&h==="}"&&n--,d)if(!S&&h==="}"){if(g(T,L),m&&(r.length=p,p&&(r[p-1].text=r[p-1].text.slice(0,u))),!p&&m){for(;m--;)o.push([]);c=-1}else for(x(!0);m--;)o.push(null);p=u=m=0,d=!1}else!S&&(h==="@"||Js.test(h))?(h==="@"&&m++,f(h,b,T,L)):(f(h,b,T,L),p=r.length,u=r[p-1].text.length,m=0);else if(!S&&h==="{"&&n>0)x(),g(T,L),d=!0;else if(S)f(h,b,T,L);else if(Js.test(h))x();else if(h==="-"){let C=y;f(h,b,T,L),C&&x()}else h==="@"?(y&&(f(h,b,T,L),x()),o.push([]),s=i=void 0):oi.has(h)?(x(),g(T,L),Fe(r,h,b)):Oa.has(h)?r.length>0||!s?.length?(g(T,L),Fe(r,h,b)):(Fe(s,h,b),i&&e&&(i.end=e[L])):h.charCodeAt(0)>127?(x(),f(h,b,T,L),x()):f(h,b,T,L)},"\\*_{}@-^"),x(),r.length>0)if(s?.length){for(let h of r)Fe(s,h.text,h.mask);i&&e&&(i.end=e[l])}else t&&e&&c>=0&&(t[o.length]={start:e[c],end:e[l]}),o.push(r);return o}function Ia(a){return ee(a.flatMap((e,t)=>{if(e===null)return[];if(e.length===0)return"@";let n=0,o=0,r="";for(;a[t+1+n]===null;)n++;for(let s of e)r+=vn(o^s.mask)+s.text.replace(/[\\{}@\-*_^]/g,"\\$&"),o=s.mask;return`{${r}${vn(o)}${"@".repeat(n)}}`}).join(" "))}var sn=class{constructor(e,t,n){this.nodes=e;this.nameHost=t;this.frames=n}nodes;nameHost;frames;kind="lyrics";layer="foreground";get sourceSpan(){return this.nameHost.ast.sourceSpan}prepareHorizontal(e,t){let n=this.nodes.filter(c=>c.ports?.lyric);if(n.length===0)return;let{lyrics:o,size:r,font:s}=this.nameHost.ast,i=an(r,s);for(let{tokens:c}of o)for(let l=0;l<c.length&&l<n.length;l++){let p=c[l];if(!p?.length)continue;let{bodyWidth:u}=ei(p,i,t.textMeasurer);if(u===0)continue;let m=n[l];if(c[l+1]!==null){e[m.layoutLine]?.registerHorizontalLayoutHook(m,m,({columns:f,start:x})=>{let h=f[x].find(S=>S.time===m);if(!h)return;let b=m.ports.lyric.x-m.box.anchor;h.WL=Math.max(h.WL,u/2-b),h.WR=Math.max(h.WR,u/2+b)});continue}let y=l;for(;c[l+1]===null;)l++,n[l]?.layoutLine===m.layoutLine&&n[l].track===m.track&&(y=l);let d=m.box.anchor-ti(m),g=Math.max(0,u-d);e[m.layoutLine]?.registerHorizontalLayoutHook(m,n[y],({columns:f,start:x,end:h})=>{let b=f[x].findIndex(N=>N.time===m);if(b<0)return;let S=f[h][b];Xn(f[x][b],"L",d);let T=S.WR+S.margin_R;for(let N=x;N<h;N++){let P=f[N][b],k=f[N+1][b];T+=P.WR+P.margin_R+k.WL+k.margin_L}let L=Math.max(0,Math.min(S.margin_R,g-(T-S.margin_R))),C=(g+L)/T;for(let N=x;N<h;N++){let P=f[N][b],k=f[N+1][b];Xn(P,"R",(P.WR+P.margin_R)*C),Xn(k,"L",(k.WL+k.margin_L)*C)}Xn(S,"R",(S.WR+S.margin_R)*C-L)})}}createGeometry(e){let t=this.prepareGeometry(e);return{regions:t,paint(n){for(let o of t)Be(n,o,o.x,o.y+o.baseline)}}}prepareGeometry(e){let{lyrics:t,size:n,font:o}=this.nameHost.ast,r=[],s=this.nodes.filter(f=>f.ports?.lyric);if(s.length===0)return r;let i=new Map;for(let f of s){let x=i.get(f.layoutLine);x||i.set(f.layoutLine,x=new Map);let h=x.get(f.track)??{bottom:-1/0,owner:f.track},b=te(f),S=b.y+b.h,T=f.track;for(let L of this.frames){let C=e.getAttachmentBox(L);if(C.x+C.w<b.x||C.x>b.x+b.w||C.y+C.h<=S)continue;let N=e.getAttachmentOccupancy(L);if(!N)throw new Error("Layout attachment dependency has not been measured");let P=N.filter(k=>k.line===f.layoutLine);if(!(N.some(k=>k.line!==void 0)&&P.length===0)){S=C.y+C.h;for(let k of P)k.line!==void 0&&e.getVisualAxis(k.line,k.track)>e.getVisualAxis(f.layoutLine,T)&&(T=k.track)}}S>=h.bottom&&(h.owner=T),h.bottom=Math.max(h.bottom,S),x.set(f.track,h)}let c=an(n,o),l=c.fontSize+n*.25,p=e.textMeasurer.measureText("M",c).baseline+n*.4,u=(f,x)=>f+p+x*l;if(this.frames.length)for(let[f,x]of i){if(x.size<2)continue;let h=new Map;for(let[,b]of[...x].sort(([S],[T])=>e.getVisualAxis(f,S)-e.getVisualAxis(f,T))){let S=h.get(b.owner)??0;b.bottom+=S*t.length*l,h.set(b.owner,S+1)}}let{box:m,layoutLine:y,track:d}=this.nameHost,g=i.get(y)?.get(d);for(let f=0;f<t.length;f++){let x=t[f];for(let b=0;b<x.tokens.length&&b<s.length;b++){let S=x.tokens[b],T=s[b],L=i.get(T.layoutLine)?.get(T.track);if(!S?.length||!L)continue;let{richLine:C,prefixWidth:N,bodyWidth:P}=ei(S,c,e.textMeasurer),k=x.tokens[b+1]===null,B=this.nameHost.ast;r.push({...C,x:T.box.x+(k?ti(T)-N:T.ports.lyric.x-P/2-N),y:u(L.bottom,f)-C.baseline,line:T.layoutLine,track:L.owner,get sourceSpan(){return B.lyricTokenSpan(f,b)}})}if(!x.name||!m||!g)continue;let h=ke(x.name,c,e.textMeasurer);r.push({...h,x:m.x+m.anchor-h.w,y:u(g.bottom,f)-h.baseline,line:y,track:g.owner})}return r}};var qn=[{op:"M",x:2.98438,y:-165.5},{op:"C",cx1:8.9375,cy1:-171.781,cx2:20.5156,cy2:-184.688,x:20.5156,y:-208.531},{op:"C",cx1:20.5156,cy1:-238.641,cx2:7.60938,cy2:-269.094,x:7.60938,y:-287.969},{op:"C",cx1:7.60938,cy1:-308.156,cx2:19.2031,cy2:-327.016,x:19.8594,y:-327.688},{op:"C",cx1:19.8594,cy1:-328.016,cx2:19.8594,cy2:-328.016,x:19.8594,y:-328.344},{op:"C",cx1:19.8594,cy1:-328.672,cx2:19.8594,cy2:-329,x:19.5313,y:-329.344},{op:"C",cx1:19.2031,cy1:-329.344,cx2:18.5313,cy2:-329.344,x:18.2031,y:-328.672},{op:"C",cx1:17.875,cy1:-328.344,cx2:0,cy2:-310.469,x:0,y:-283.328},{op:"C",cx1:0,cy1:-254.203,cx2:11.5781,cy2:-233.688,x:11.5781,y:-195.625},{op:"C",cx1:11.5781,cy1:-188.328,cx2:8.60938,cy2:-176.75,x:.328125,y:-166.484},{op:"C",cx1:0,cy1:-166.484,cx2:0,cy2:-165.828,x:0,y:-165.5},{op:"C",cx1:-.328125,cy1:-165.172,cx2:0,cy2:-164.828,x:.328125,y:-164.5},{op:"C",cx1:8.60938,cy1:-154.25,cx2:11.5781,cy2:-142.656,x:11.5781,y:-135.375},{op:"C",cx1:11.5781,cy1:-97.3125,cx2:0,cy2:-76.7969,x:0,y:-47.6563},{op:"C",cx1:0,cy1:-20.8594,cx2:17.875,cy2:-2.64063,x:18.2031,y:-2.3125},{op:"C",cx1:18.5313,cy1:-1.65625,cx2:19.2031,cy2:-1.32813,x:19.5313,y:-1.65625},{op:"C",cx1:19.8594,cy1:-1.98438,cx2:20.1875,cy2:-2.3125,x:19.8594,y:-2.64063},{op:"C",cx1:19.8594,cy1:-2.64063,cx2:19.8594,cy2:-2.98438,x:19.8594,y:-3.3125},{op:"C",cx1:19.2031,cy1:-3.96875,cx2:7.60938,cy2:-22.8438,x:7.60938,y:-43.0313},{op:"C",cx1:7.60938,cy1:-61.8906,cx2:20.5156,cy2:-92.3438,x:20.5156,y:-122.469},{op:"C",cx1:20.5156,cy1:-146.625,cx2:8.9375,cy2:-159.203,x:2.98438,y:-165.5},{op:"Z"}],Pt=he(qn),Ee=2.33,Oe=1.17,rt=.34,Qn=[{op:"M",x:0,y:0},{op:"L",x:0,y:-rt},{op:"C",cx1:Ee*.421,cy1:-rt+Oe*.077,cx2:Ee*.733,cy2:-rt+Oe*.346,x:Ee,y:-rt+Oe},{op:"L",x:Ee*.929,y:-rt+Oe},{op:"C",cx1:Ee*.696,cy1:-rt+Oe*.535,cx2:Ee*.328,cy2:-rt+Oe*.352,x:0,y:0},{op:"Z"}],Da=/\s*([\[{])\s*(?:(?:(\d+)\s*)?-\s*(?:(\d+)\s*)?|(\d+)\s*)/y,ri=/\s/,ai=/[\[\]{}:"\r\n]/;function at(a){return new w("E_VOICES_CONNECT","@voices \u7684 connect \u5FC5\u987B\u662F [\u8D77\u70B9-\u7EC8\u70B9]\u3001{\u8D77\u70B9-\u7EC8\u70B9}\u3001[\u7F16\u53F7] \u6216 {\u7F16\u53F7}\uFF08\u53EF\u7528 :\u540D\u79F0 \u6307\u5B9A\u5206\u7EC4\u540D\uFF09\u7684\u7EC4\u5408\uFF1B\u8303\u56F4\u7AEF\u70B9\u53EF\u7701\u7565\uFF0C\u5426\u5219\u987B\u4E3A\u6709\u6548\u58F0\u90E8\u7F16\u53F7\u3002\u7A7A\u5B57\u7B26\u4E32\u8868\u793A\u53EA\u6709\u8FDE\u8C31\u7EBF\u3002",a)}function Va(a,e){let t=a.trim(),n=[];for(let o=0;o<t.length;o++){Da.lastIndex=o;let r=Da.exec(t);if(!r)throw at(e);o=Da.lastIndex;let s=r[1]==="["?"]":"}",i=r[4]??r[2],c=r[4]??r[3],l=i?Number(i):void 0,p=c?Number(c):void 0;for(let m of[l,p])if(m!==void 0&&(!Number.isSafeInteger(m)||m<1))throw at(e);if(l!==void 0&&p!==void 0&&l>p)throw at(e);let u;if(t[o]===":"){for(o++;o<t.length&&ri.test(t[o]);)o++;if(t[o]==='"'){let m=ae(t,o,t.length),y=m<0?null:jt(t.slice(o,m+1));if(typeof y!="string"||!y)throw at(e);for(u=y,o=m+1;o<t.length&&ri.test(t[o]);)o++}else{let m=t.indexOf(s,o),y=m<0?"":t.slice(o,m);if(u=ai.test(y)?"":y.trim(),!u)throw at(e);o=m}}if(t[o]!==s)throw at(e);n.push({kind:r[1]==="["?"bracket":"brace",from:l,to:p,...u?{name:u}:{}})}return n}function Ha(a,e,t){return a.map(({kind:n,from:o=1,to:r=e,name:s})=>{if(o>r||r>e)throw at(t);return{kind:n,from:o,to:r,...s?{name:s}:{}}})}function Jn(a){return a.map(({kind:e,from:t,to:n,name:o})=>{let r=o?`:${ai.test(o)||o.trim()!==o?ee(o):o}`:"",s=`${t??""}-${n??""}${r}`;return e==="brace"?`{${s}}`:`[${s}]`}).join("")}var si=2.5,ii=.3,$c=.5;function Yc(a,e,t){let n=Object.assign(o=>{let r=n.size/2,s=Math.min(n.gap,n.minGap),i=o.map(u=>u?{top:Math.min(u.top,-r),bottom:Math.max(u.bottom,r)}:{top:-r,bottom:r}),c=[],l=0;for(let u=0;u<i.length;u++)u>0&&(l+=i[u-1].bottom+Math.max(n.gap+r,s-i[u].top)),c.push(l);let p=(c[0]+c[c.length-1])/2;return c.map((u,m)=>({offset:u-p,extent:i[m]}))},{size:a,gap:e,minGap:t});return n}function Kc(a,e,t,n,o){let r=1;for(let s=e;s<t;s++){let i=a[s];if(i==='"'){if(s=ae(a,s,t),s<0)return-1}else{if(i==="\r"||i===`
100
- `)return-1;if(i===n)r++;else if(i===o&&--r===0)return s}}return-1}var _e=class a extends E{static def={name:["voices","vs"],description:"\u591A\u4E2A\u58F0\u90E8",details:`~~~jpfun
102
+ \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}]};content;normal;font;get children(){return[this.content]}loweringEnter(e){let t={nodes:[],attachments:[],onTemporal(n){t.nodes.push(n)},onAttachment(n){t.attachments.push(n)}};return e.beginLoweringGroup(this,t),[]}loweringExit(e,t,n){let o=e.endLoweringGroup(this),r=o.nodes.filter(d=>d.T.compare(0)>0);if(r.length===0)throw new w("E_TUPLET_EMPTY","@tuplet \u7684\u5185\u5BB9\u5FC5\u987B\u4EA7\u751F\u81F3\u5C11\u4E00\u4E2A\u6B63\u65F6\u503C\u4E8B\u4EF6",this.sourceSpan);let s=r[0].track;if(r.some(d=>d.track!==s))throw new w("E_TUPLET_PARALLEL_CONTENT","@tuplet \u7684\u5185\u5BB9\u4E0D\u80FD\u5305\u542B\u5E76\u884C\u97F3\u8F68",this.sourceSpan);let i=r[0].T.clone(),c=new I;for(let d of r)d.T.compare(i)<0&&i.copyFrom(d.T),c.add(d.T);let l=c.div(i),p=l.numerator;if(l.denominator!==1||p<2||!Number.isSafeInteger(p))throw new w("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===p)throw new w("E_TUPLET_INVALID_RATIO","@tuplet \u7684 normal \u4E0D\u80FD\u7B49\u4E8E\u63A8\u5BFC\u51FA\u7684 actual ({actual})",this.sourceSpan,{actual:p});let u=o.nodes[0].t;for(let d=1;d<o.nodes.length;d++)o.nodes[d].t.compare(u)<0&&(u=o.nodes[d].t);u=u.clone();let m=new I;for(let d of o.nodes)m.copyFrom(d.t).sub(u).mul(this.normal,p),d.t.copyFrom(u).add(m),d.T.mul(this.normal,p);n.copyFrom(u).add(i.mul(this.normal));let f=r.filter(_);if(f.length>=2){let d=new xa(f,p,this.sourceSpan,this.font,o);e.addAttachment(d),e.deferFinalize(()=>d.validate())}return[]}constructor(e,t,n,o=null){super(e,o);let[r,s]=this.getArgValue(t,n);if(this.font=n.variables.numberfont,!Number.isSafeInteger(s)||s<=0)throw new w("E_TUPLET_INVALID_NORMAL","@tuplet \u7684 normal \u5FC5\u987B\u662F\u6B63\u7684\u5B89\u5168\u6574\u6570",e);this.content=r,this.normal=s,r.parent=this}toString(e){return`@tuplet(${this.content.toString(e)}, ${this.normal})`}},ga=ha,xa=class{constructor(e,t,n,o,r){this.content=r;this.endPoints=e,this.actual=t,this.sourceSpan=n,this.size=e.reduce((s,i)=>Math.max(s,i.ast.size),0),this.style={fontSize:this.size*.72,fontFamily:o,textAlign:"center",fill:"#000"}}content;kind="tuplet";layer="foreground";endPoints;actual;sourceSpan;style;size;validate(){let e=this.endPoints[0];if(this.endPoints.some(t=>t.layoutLine!==e.layoutLine))throw new w("E_TUPLET_CROSS_LINE","@tuplet \u7684\u5185\u5BB9\u4E0D\u80FD\u8DE8\u8D8A\u8C31\u9762\u884C",this.sourceSpan)}createGeometry(e){let t=this.endPoints[0],n=this.endPoints[this.endPoints.length-1],o=t.ports["body.left"]?.x??0,r=n.ports["body.right"]?.x??n.box.w,s=t.box.x+o,i=n.box.x+r;s>i&&([s,i]=[i,s]);let c=e.textMeasurer.measureText(String(this.actual),this.style),l=(s+i)/2,p=this.size*.12,u=this.size*.18,m=this.size*.14,f=e.getVisualAxis(t.layoutLine,t.track),d=e.getRangeExtents(t.layoutLine,[t,n],t.track),h=e.getContentBounds(this.content),y=Math.min(f+(d?.top??0),h?.y??1/0),g=Math.max(1,this.size*.055),x=y-m-Math.max(u,c.h/2),b=x+u,S=x-c.h/2+c.baseline,T=l-c.w/2-p,L=l+c.w/2+p,C=[];T>s&&C.push([s,x,T,x]),L<i&&C.push([L,x,i,x]),C.push([s,x,s,b],[i,x,i,b]);let A=g/2,v=Math.min(x-c.h/2,x-A),N=Math.max(x+c.h/2,b+A),F=[{x:s-A,y:v,w:i-s+g,h:N-v,line:t.layoutLine,track:t.track}],B=String(this.actual),$=this.style;return{regions:F,paint(U){let E={stroke:"#000",strokeWidth:g};for(let[G,K,ne,J]of C)U.drawLine(G,K,ne,J,E);U.drawText(B,l,S,$)}}}};var ui=/\s/,yi=.88,ba=new Set("\uFF08([\uFF3B\uFF5B\u3008\u300A\u300C\u300E\u3010\u3014\u3016\u3018\u301A\u2018\u201C\u2488\u2489\u248A\u248B\u248C"),Qn=new Set([...ba,...`\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 pn(a,e){return{fontFamily:e,fontSize:a*yi,fill:"#000"}}function mi(a,e,t){let n=ve(a,e,t),o=n.runs.map(c=>c.text).join(""),r=0,s=o.length;for(;r<s&&Qn.has(o[r]);)r++;for(;s>r&&Qn.has(o[s-1]);)s--;let i=(c,l)=>{let p=0,u=0;for(let m of n.runs){let f=u+m.text.length,d=Math.max(c,u),h=Math.min(l,f);d<h&&(p+=d===u&&h===f?m.w:t.measureText(m.text.slice(d-u,h-u),m.style).w),u=f}return p};return{richLine:n,prefixWidth:i(0,r),bodyWidth:i(r,s)}}function di(a){return a.ports["body.left"]?.x??0}function qn(a,e,t){let n=e==="L"?"WL":"WR",o=e==="L"?"margin_L":"margin_R";t>a[n]&&(a[o]=Math.max(0,a[n]+a[o]-t),a[n]=t)}function Jn(a,e,t){let n=0;for(let x=0;x<a.length;x++)a[x]==="\\"?x++:a[x]==="}"&&n++;let o=[],r=[],s,i,c=-1,l=0,p=0,u=0,m=0,f=!1,d=!1,h=(x,b)=>{c<0&&(c=x),l=b},y=(x,b,S,T)=>{Oe(r,x,b),h(S,T),f=!0},g=(x=!1)=>{!x&&!f||(t&&e&&c>=0&&(t[o.length]=i={start:e[c],end:e[l]}),o.push(s=r),r=[],c=-1,f=!1)};if(Wt(a,(x,b,S,T,L)=>{if(!S&&x==="}"&&n--,d)if(!S&&x==="}"){if(h(T,L),m&&(r.length=p,p&&(r[p-1].text=r[p-1].text.slice(0,u))),!p&&m){for(;m--;)o.push([]);c=-1}else for(g(!0);m--;)o.push(null);p=u=m=0,d=!1}else!S&&(x==="@"||ui.test(x))?(x==="@"&&m++,y(x,b,T,L)):(y(x,b,T,L),p=r.length,u=r[p-1].text.length,m=0);else if(!S&&x==="{"&&n>0)g(),h(T,L),d=!0;else if(S)y(x,b,T,L);else if(ui.test(x))g();else if(x==="-"){let C=f;y(x,b,T,L),C&&g()}else x==="@"?(f&&(y(x,b,T,L),g()),o.push([]),s=i=void 0):ba.has(x)?(g(),h(T,L),Oe(r,x,b)):Qn.has(x)?r.length>0||!s?.length?(h(T,L),Oe(r,x,b)):(Oe(s,x,b),i&&e&&(i.end=e[L])):x.charCodeAt(0)>127?(g(),y(x,b,T,L),g()):y(x,b,T,L)},"\\*_{}@-^"),g(),r.length>0)if(s?.length){for(let x of r)Oe(s,x.text,x.mask);i&&e&&(i.end=e[l])}else t&&e&&c>=0&&(t[o.length]={start:e[c],end:e[l]}),o.push(r);return o}function Sa(a){return te(a.flatMap((e,t)=>{if(e===null)return[];if(e.length===0)return"@";let n=0,o=0,r="";for(;a[t+1+n]===null;)n++;for(let s of e)r+=Fn(o^s.mask)+s.text.replace(/[\\{}@\-*_^]/g,"\\$&"),o=s.mask;return`{${r}${Fn(o)}${"@".repeat(n)}}`}).join(" "))}var un=class{constructor(e,t,n){this.nodes=e;this.nameHost=t;this.frames=n}nodes;nameHost;frames;kind="lyrics";layer="foreground";get sourceSpan(){return this.nameHost.ast.sourceSpan}prepareHorizontal(e,t){let n=this.nodes.filter(c=>c.ports?.lyric);if(n.length===0)return;let{lyrics:o,size:r,font:s}=this.nameHost.ast,i=pn(r,s);for(let{tokens:c}of o)for(let l=0;l<c.length&&l<n.length;l++){let p=c[l];if(!p?.length)continue;let{bodyWidth:u}=mi(p,i,t.textMeasurer);if(u===0)continue;let m=n[l];if(c[l+1]!==null){e[m.layoutLine]?.registerHorizontalLayoutHook(m,m,({columns:y,start:g})=>{let x=y[g].find(S=>S.time===m);if(!x)return;let b=m.ports.lyric.x-m.box.anchor;x.WL=Math.max(x.WL,u/2-b),x.WR=Math.max(x.WR,u/2+b)});continue}let f=l;for(;c[l+1]===null;)l++,n[l]?.layoutLine===m.layoutLine&&n[l].track===m.track&&(f=l);let d=m.box.anchor-di(m),h=Math.max(0,u-d);e[m.layoutLine]?.registerHorizontalLayoutHook(m,n[f],({columns:y,start:g,end:x})=>{let b=y[g].findIndex(A=>A.time===m);if(b<0)return;let S=y[x][b];qn(y[g][b],"L",d);let T=S.WR+S.margin_R;for(let A=g;A<x;A++){let v=y[A][b],N=y[A+1][b];T+=v.WR+v.margin_R+N.WL+N.margin_L}let L=Math.max(0,Math.min(S.margin_R,h-(T-S.margin_R))),C=(h+L)/T;for(let A=g;A<x;A++){let v=y[A][b],N=y[A+1][b];qn(v,"R",(v.WR+v.margin_R)*C),qn(N,"L",(N.WL+N.margin_L)*C)}qn(S,"R",(S.WR+S.margin_R)*C-L)})}}createGeometry(e){let t=this.prepareGeometry(e);return{regions:t,paint(n){for(let o of t)Ie(n,o,o.x,o.y+o.baseline)}}}prepareGeometry(e){let{lyrics:t,size:n,font:o}=this.nameHost.ast,r=[],s=this.nodes.filter(y=>y.ports?.lyric);if(s.length===0)return r;let i=new Map;for(let y of s){let g=i.get(y.layoutLine);g||i.set(y.layoutLine,g=new Map);let x=g.get(y.track)??{bottom:-1/0,owner:y.track},b=ee(y),S=b.y+b.h,T=y.track;for(let L of this.frames){let C=e.getAttachmentBox(L);if(C.x+C.w<b.x||C.x>b.x+b.w||C.y+C.h<=S)continue;let A=e.getAttachmentOccupancy(L);if(!A)throw new Error("Layout attachment dependency has not been measured");let v=A.filter(N=>N.line===y.layoutLine);if(!(A.some(N=>N.line!==void 0)&&v.length===0)){S=C.y+C.h;for(let N of v)N.line!==void 0&&e.getVisualAxis(N.line,N.track)>e.getVisualAxis(y.layoutLine,T)&&(T=N.track)}}S>=x.bottom&&(x.owner=T),x.bottom=Math.max(x.bottom,S),g.set(y.track,x)}let c=pn(n,o),l=c.fontSize+n*.25,p=e.textMeasurer.measureText("M",c).baseline+n*.4,u=(y,g)=>y+p+g*l;if(this.frames.length)for(let[y,g]of i){if(g.size<2)continue;let x=new Map;for(let[,b]of[...g].sort(([S],[T])=>e.getVisualAxis(y,S)-e.getVisualAxis(y,T))){let S=x.get(b.owner)??0;b.bottom+=S*t.length*l,x.set(b.owner,S+1)}}let{box:m,layoutLine:f,track:d}=this.nameHost,h=i.get(f)?.get(d);for(let y=0;y<t.length;y++){let g=t[y];for(let b=0;b<g.tokens.length&&b<s.length;b++){let S=g.tokens[b],T=s[b],L=i.get(T.layoutLine)?.get(T.track);if(!S?.length||!L)continue;let{richLine:C,prefixWidth:A,bodyWidth:v}=mi(S,c,e.textMeasurer),N=g.tokens[b+1]===null,F=this.nameHost.ast;r.push({...C,x:T.box.x+(N?di(T)-A:T.ports.lyric.x-v/2-A),y:u(L.bottom,y)-C.baseline,line:T.layoutLine,track:L.owner,get sourceSpan(){return F.lyricTokenSpan(y,b)}})}if(!g.name||!m||!h)continue;let x=ve(g.name,c,e.textMeasurer);r.push({...x,x:m.x+m.anchor-x.w,y:u(h.bottom,y)-x.baseline,line:f,track:h.owner})}return r}};var wa=[{op:"M",x:2.98438,y:-165.5},{op:"C",cx1:8.9375,cy1:-171.781,cx2:20.5156,cy2:-184.688,x:20.5156,y:-208.531},{op:"C",cx1:20.5156,cy1:-238.641,cx2:7.60938,cy2:-269.094,x:7.60938,y:-287.969},{op:"C",cx1:7.60938,cy1:-308.156,cx2:19.2031,cy2:-327.016,x:19.8594,y:-327.688},{op:"C",cx1:19.8594,cy1:-328.016,cx2:19.8594,cy2:-328.016,x:19.8594,y:-328.344},{op:"C",cx1:19.8594,cy1:-328.672,cx2:19.8594,cy2:-329,x:19.5313,y:-329.344},{op:"C",cx1:19.2031,cy1:-329.344,cx2:18.5313,cy2:-329.344,x:18.2031,y:-328.672},{op:"C",cx1:17.875,cy1:-328.344,cx2:0,cy2:-310.469,x:0,y:-283.328},{op:"C",cx1:0,cy1:-254.203,cx2:11.5781,cy2:-233.688,x:11.5781,y:-195.625},{op:"C",cx1:11.5781,cy1:-188.328,cx2:8.60938,cy2:-176.75,x:.328125,y:-166.484},{op:"C",cx1:0,cy1:-166.484,cx2:0,cy2:-165.828,x:0,y:-165.5},{op:"C",cx1:-.328125,cy1:-165.172,cx2:0,cy2:-164.828,x:.328125,y:-164.5},{op:"C",cx1:8.60938,cy1:-154.25,cx2:11.5781,cy2:-142.656,x:11.5781,y:-135.375},{op:"C",cx1:11.5781,cy1:-97.3125,cx2:0,cy2:-76.7969,x:0,y:-47.6563},{op:"C",cx1:0,cy1:-20.8594,cx2:17.875,cy2:-2.64063,x:18.2031,y:-2.3125},{op:"C",cx1:18.5313,cy1:-1.65625,cx2:19.2031,cy2:-1.32813,x:19.5313,y:-1.65625},{op:"C",cx1:19.8594,cy1:-1.98438,cx2:20.1875,cy2:-2.3125,x:19.8594,y:-2.64063},{op:"C",cx1:19.8594,cy1:-2.64063,cx2:19.8594,cy2:-2.98438,x:19.8594,y:-3.3125},{op:"C",cx1:19.2031,cy1:-3.96875,cx2:7.60938,cy2:-22.8438,x:7.60938,y:-43.0313},{op:"C",cx1:7.60938,cy1:-61.8906,cx2:20.5156,cy2:-92.3438,x:20.5156,y:-122.469},{op:"C",cx1:20.5156,cy1:-146.625,cx2:8.9375,cy2:-159.203,x:2.98438,y:-165.5},{op:"Z"}],mn=Se(wa),De=2.33,Ue=1.17,st=.34,La=[{op:"M",x:0,y:0},{op:"L",x:0,y:-st},{op:"C",cx1:De*.421,cy1:-st+Ue*.077,cx2:De*.733,cy2:-st+Ue*.346,x:De,y:-st+Ue},{op:"L",x:De*.929,y:-st+Ue},{op:"C",cx1:De*.696,cy1:-st+Ue*.535,cx2:De*.328,cy2:-st+Ue*.352,x:0,y:0},{op:"Z"}],Ta=/\s*([\[{])\s*(?:(?:(\d+)\s*)?-\s*(?:(\d+)\s*)?|(\d+)\s*)/y,fi=/\s/,hi=/[\[\]{}:"\r\n]/;function it(a){return new w("E_VOICES_CONNECT","@voices \u7684 connect \u5FC5\u987B\u662F [\u8D77\u70B9-\u7EC8\u70B9]\u3001{\u8D77\u70B9-\u7EC8\u70B9}\u3001[\u7F16\u53F7] \u6216 {\u7F16\u53F7}\uFF08\u53EF\u7528 :\u540D\u79F0 \u6307\u5B9A\u5206\u7EC4\u540D\uFF09\u7684\u7EC4\u5408\uFF1B\u8303\u56F4\u7AEF\u70B9\u53EF\u7701\u7565\uFF0C\u5426\u5219\u987B\u4E3A\u6709\u6548\u58F0\u90E8\u7F16\u53F7\u3002\u7A7A\u5B57\u7B26\u4E32\u8868\u793A\u53EA\u6709\u8FDE\u8C31\u7EBF\u3002",a)}function eo(a,e){let t=a.trim(),n=[];for(let o=0;o<t.length;o++){Ta.lastIndex=o;let r=Ta.exec(t);if(!r)throw it(e);o=Ta.lastIndex;let s=r[1]==="["?"]":"}",i=r[4]??r[2],c=r[4]??r[3],l=i?Number(i):void 0,p=c?Number(c):void 0;for(let m of[l,p])if(m!==void 0&&(!Number.isSafeInteger(m)||m<1))throw it(e);if(l!==void 0&&p!==void 0&&l>p)throw it(e);let u;if(t[o]===":"){for(o++;o<t.length&&fi.test(t[o]);)o++;if(t[o]==='"'){let m=ie(t,o,t.length),f=m<0?null:$t(t.slice(o,m+1));if(typeof f!="string"||!f)throw it(e);for(u=f,o=m+1;o<t.length&&fi.test(t[o]);)o++}else{let m=t.indexOf(s,o),f=m<0?"":t.slice(o,m);if(u=hi.test(f)?"":f.trim(),!u)throw it(e);o=m}}if(t[o]!==s)throw it(e);n.push({kind:r[1]==="["?"bracket":"brace",from:l,to:p,...u?{name:u}:{}})}return n}function to(a,e,t){return a.map(({kind:n,from:o=1,to:r=e,name:s})=>{if(o>r||r>e)throw it(t);return{kind:n,from:o,to:r,...s?{name:s}:{}}})}function dn(a){return a.map(({kind:e,from:t,to:n,name:o})=>{let r=o?`:${hi.test(o)||o.trim()!==o?te(o):o}`:"",s=`${t??""}-${n??""}${r}`;return e==="brace"?`{${s}}`:`[${s}]`}).join("")}var xi=2.5,gi=.3,dl=.5;function yl(a,e,t){let n=Object.assign(o=>{let r=n.size/2,s=Math.min(n.gap,n.minGap),i=o.map(u=>u?{top:Math.min(u.top,-r),bottom:Math.max(u.bottom,r)}:{top:-r,bottom:r}),c=[],l=0;for(let u=0;u<i.length;u++)u>0&&(l+=i[u-1].bottom+Math.max(n.gap+r,s-i[u].top)),c.push(l);let p=(c[0]+c[c.length-1])/2;return c.map((u,m)=>({offset:u-p,extent:i[m]}))},{size:a,gap:e,minGap:t});return n}function fl(a,e,t,n,o){let r=1;for(let s=e;s<t;s++){let i=a[s];if(i==='"'){if(s=ie(a,s,t),s<0)return-1}else{if(i==="\r"||i===`
103
+ `)return-1;if(i===n)r++;else if(i===o&&--r===0)return s}}return-1}var Re=class a extends P{static def={name:["voices","vs"],description:"\u591A\u4E2A\u58F0\u90E8",details:`~~~jpfun
101
104
  @voices(
102
105
  @voice({1 2 3}, \u53F3\u624B, \u7537=ha ha ha),
103
106
  @voice({3 4 5}, \u5DE6\u624B, "la la la"),
@@ -117,16 +120,16 @@ V[\u5408\u5531]:
117
120
  N(\u5973\u9AD8): 6 6 5
118
121
  L: \u554A \u554A \u554A
119
122
  N(\u5973\u4F4E): 1 2 3
120
- ~~~`,allowExtraArgs:!0,extraArgType:"content",args:[{name:"connect",namedOnly:!0,type:"string",default:"[-]",description:"\u8FDE\u8C31\u53F7\uFF1A`[\u8D77\u70B9-\u7EC8\u70B9]` \u4E3A\u62EC\u7EBF\uFF0C`{\u8D77\u70B9-\u7EC8\u70B9}` \u4E3A\u5927\u62EC\u53F7\uFF0C`[3]`/`{3}` \u8868\u793A\u5355\u58F0\u90E8\uFF1B\u7AEF\u70B9\u53EF\u7701\uFF0C\u540E\u53EF\u63A5 `:\u540D\u79F0` \u6307\u5B9A\u5206\u7EC4\u603B\u540D\u79F0\uFF0C\u7A7A\u4E32\u4EC5\u4FDD\u7559\u516C\u5171\u7EC6\u7EBF\u3002"},{name:"gap",namedOnly:!0,type:"length",default:{value:.75,unit:"em"},description:"\u76F8\u90BB\u58F0\u90E8\u4E3B\u65CB\u5F8B\u4E4B\u95F4\u7684\u6807\u51C6\u95F4\u8DDD"},{name:"minGap",namedOnly:!0,type:"length",default:{value:.2,unit:"em"},description:"\u4E0A\u65B9\u8BB0\u53F7\u501F\u7528\u95F4\u8DDD\u540E\u4FDD\u7559\u7684\u6700\u5C0F\u95F4\u8DDD"}]};static deSugarAtom(e,t,n){if(e[t]!=="V")return null;if(e.startsWith("V|:",t)&&t+3<=n)return{next:t+3,node:{kind:"sugar",data:{class:a,kind:"line"},span:{start:t,end:t+3}}};let o=e[t+1];if(o!=="{"&&o!=="[")return null;let r=Kc(e,t+2,n,o,o==="{"?"}":"]");return r<0||r+1>=n||e[r+1]!==":"?null:{next:r+2,node:{kind:"sugar",data:{class:a,kind:o==="{"?"brace":"bracket",name:{start:t+2,end:r}},span:{start:t,end:r+2}}}}static deSugarRelation(e,t,n){let o=t[n];if(typeof o=="number"||o.kind!=="sugar"||o.data?.class!==a)return null;let r=e.nodes.length-1;for(;r>=0&&e.nodes[r]instanceof pe;){let{sourceSpan:y}=e.nodes[r],d=e.source.slice(y.start,y.end);if(d.includes(`
121
- `)||d.trim())break;r--}let s=e.nodes[r],i=s instanceof Ie?[s]:s instanceof a&&s.createdBySugar?[...s.voices]:[],c=i.length>0,l=[],p=n;for(;p<t.length;){let y=t[p];if(typeof y=="number"||y.kind!=="sugar"||y.data?.class!==a)break;p++;let d=t[p];typeof d=="number"&&e.source[d]==="\r"&&p++;let g=t[p];typeof g=="number"&&e.source[g]===`
122
- `&&p++;let f=new le(e),x=i.length+1;for(;p<t.length;){let h=t[p];if(typeof h=="number"||h.kind!=="sugar"||h.data?.class!==Ie)break;p=Ie.deSugarRelation(f,t,p,i)}if(i.length<x)throw new w("E_VOICES_GROUP_EMPTY","V \u58F0\u90E8\u5206\u7EC4\u5FC5\u987B\u81F3\u5C11\u5305\u542B\u4E00\u6761 N: \u58F0\u90E8\u58F0\u660E",y.span);if(y.data.kind==="brace"||y.data.kind==="bracket"){let h=y.data.name?e.parseArgWithType(y.data.name,"string")??"":"";l.push({kind:y.data.kind,from:x,to:i.length,...h?{name:h}:{}})}}let u=new Map;i.forEach((y,d)=>u.set(d,y)),u.set("connect",Jn(l));let m=new a({start:c?s.sourceSpan.start:o.span.start,end:i.at(-1).sourceSpan.end},u,e);return m.createdBySugar=!0,c&&(e.nodes.length=r),e.pushNode(m),p}voices;createdBySugar=!1;size;font;gap;minGap;connect;get braceSpace(){return Math.max(this.size,(si*(Ee+.5)+.5)/(1-ii))}get connectionSpecs(){return Va(this.connect,this.sourceSpan)}get children(){return this.voices}timeFlowModel(){return{children:this.children,mode:"parallel",tracks:{laneKey:`voices/${this.voices.length}`,hostIndex:null,measure:Yc(this.size,this.gap,this.minGap)}}}loweringExit(e,t){let n=Ha(this.connectionSpecs,this.voices.length,this.sourceSpan);if(this.voices.length>=2){let s=this.voices.map(i=>e.getTemporalNodes(i)[0]);e.addAttachment(new Ga(s,this,n))}let o=`voices/${this.voices.length}`,r=t.groups.find(s=>s.laneKey===o)?.measure;return r&&(this.voices.length>=2&&(Math.abs(r.gap-this.gap)>1e-6||Math.abs(r.minGap-this.minGap)>1e-6)&&e.diagnostics.push(new I("W_VOICES_GAP_CONFLICT","\u76F8\u540C\u58F0\u90E8\u6570\u7684 @voices \u5171\u7528\u97F3\u8F68\u4F46\u8BBE\u7F6E\u4E86\u4E0D\u540C\u7684\u95F4\u8DDD\uFF0C\u5C06\u53D6\u8F83\u5927\u503C",this.sourceSpan)),r.size=Math.max(r.size,this.size),r.gap=Math.max(r.gap,this.gap),r.minGap=Math.max(r.minGap,this.minGap)),[]}constructor(e,t,n,o=null){super(e,o),this.voices=[],this.size=n.variables.fontsize,this.font=n.variables.font;let[r,s,i]=this.getArgValue(t,n);if(this.connect=r,this.gap=n.length2px(s),this.minGap=n.length2px(i),!Number.isFinite(this.gap)||this.gap<0||!Number.isFinite(this.minGap)||this.minGap<0)throw new w("E_INVALID_VOICES_GAP","@voices \u7684 gap \u548C minGap \u5FC5\u987B\u662F\u975E\u8D1F\u6709\u9650\u957F\u5EA6",e);for(let[c,l]of t)if(typeof c!="string"){if(!(l instanceof Ie))throw new w("E_VOICES_INVALID_CHILD","@voices \u7684\u53C2\u6570\u5FC5\u987B\u662F @voice \u51FD\u6570\uFF0C\u4F46\u53D1\u73B0\u4E86\u5176\u4ED6\u7C7B\u578B {actual}",l.sourceSpan,{actual:String(l?.constructor.name)});this.addVoice(l)}if(this.voices.length===0)throw new w("E_VOICES_EMPTY","@voices \u5FC5\u987B\u81F3\u5C11\u5305\u542B\u4E00\u4E2A @voice \u51FD\u6570",e)}addVoice(e){this.voices.push(e),e.parent=this,this.sourceSpan.start=Math.min(e.sourceSpan.start,this.sourceSpan.start),this.sourceSpan.end=Math.max(e.sourceSpan.end,this.sourceSpan.end)}toString(e){let t=this.voices.map(n=>` ${n.toString(e)}`);return t.push(` connect=${ee(Jn(this.connectionSpecs))}`,` gap=${this.gap}px`,` minGap=${this.minGap}px`),`@voices(
123
+ ~~~`,allowExtraArgs:!0,extraArgType:"content",args:[{name:"connect",namedOnly:!0,type:"string",default:"[-]",description:"\u8FDE\u8C31\u53F7\uFF1A`[\u8D77\u70B9-\u7EC8\u70B9]` \u4E3A\u62EC\u7EBF\uFF0C`{\u8D77\u70B9-\u7EC8\u70B9}` \u4E3A\u5927\u62EC\u53F7\uFF0C`[3]`/`{3}` \u8868\u793A\u5355\u58F0\u90E8\uFF1B\u7AEF\u70B9\u53EF\u7701\uFF0C\u540E\u53EF\u63A5 `:\u540D\u79F0` \u6307\u5B9A\u5206\u7EC4\u603B\u540D\u79F0\uFF0C\u7A7A\u4E32\u4EC5\u4FDD\u7559\u516C\u5171\u7EC6\u7EBF\u3002"},{name:"gap",namedOnly:!0,type:"length",default:{value:.75,unit:"em"},description:"\u76F8\u90BB\u58F0\u90E8\u4E3B\u65CB\u5F8B\u4E4B\u95F4\u7684\u6807\u51C6\u95F4\u8DDD"},{name:"minGap",namedOnly:!0,type:"length",default:{value:.2,unit:"em"},description:"\u4E0A\u65B9\u8BB0\u53F7\u501F\u7528\u95F4\u8DDD\u540E\u4FDD\u7559\u7684\u6700\u5C0F\u95F4\u8DDD"}]};static deSugarAtom(e,t,n){if(e[t]!=="V")return null;if(e.startsWith("V|:",t)&&t+3<=n)return{next:t+3,node:{kind:"sugar",data:{kind:"line"},span:{start:t,end:t+3},relation:a.deSugarGroup}};let o=e[t+1];if(o!=="{"&&o!=="[")return null;let r=fl(e,t+2,n,o,o==="{"?"}":"]");return r<0||r+1>=n||e[r+1]!==":"?null:{next:r+2,node:{kind:"sugar",data:{kind:o==="{"?"brace":"bracket",name:{start:t+2,end:r}},span:{start:t,end:r+2},relation:a.deSugarGroup}}}static deSugarGroup(e,t,n){let o=t[n],r=e.nodes.length-1;for(;r>=0&&e.nodes[r]instanceof pe;){let{sourceSpan:f}=e.nodes[r],d=e.source.slice(f.start,f.end);if(d.includes(`
124
+ `)||d.trim())break;r--}let s=e.nodes[r],i=s instanceof Ve?[s]:s instanceof a&&s.createdBySugar?[...s.voices]:[],c=i.length>0,l=[],p=n;for(;p<t.length;){let f=t[p];if(typeof f=="number"||f.kind!=="sugar"||f.relation!==a.deSugarGroup)break;p++;let d=t[p];typeof d=="number"&&e.source[d]==="\r"&&p++;let h=t[p];typeof h=="number"&&e.source[h]===`
125
+ `&&p++;let y=new re(e),g=i.length+1;for(;p<t.length;){let x=t[p];if(typeof x=="number"||x.kind!=="sugar"||x.relation!==Ve.deSugarLine)break;p=Ve.deSugarLine(y,t,p,i)}if(i.length<g)throw new w("E_VOICES_GROUP_EMPTY","V \u58F0\u90E8\u5206\u7EC4\u5FC5\u987B\u81F3\u5C11\u5305\u542B\u4E00\u6761 N: \u58F0\u90E8\u58F0\u660E",f.span);if(f.data.kind==="brace"||f.data.kind==="bracket"){let x=f.data.name?e.parseArgWithType(f.data.name,"string")??"":"";l.push({kind:f.data.kind,from:g,to:i.length,...x?{name:x}:{}})}}let u=new Map;i.forEach((f,d)=>u.set(d,f)),u.set("connect",dn(l));let m=new a({start:c?s.sourceSpan.start:o.span.start,end:i.at(-1).sourceSpan.end},u,e);return m.createdBySugar=!0,c&&(e.nodes.length=r),e.pushNode(m),p}voices;createdBySugar=!1;size;font;gap;minGap;connect;get braceSpace(){return Math.max(this.size,(xi*(De+.5)+.5)/(1-gi))}get connectionSpecs(){return eo(this.connect,this.sourceSpan)}get children(){return this.voices}timeFlowModel(){return{children:this.children,mode:"parallel",tracks:{laneKey:`voices/${this.voices.length}`,hostIndex:null,measure:yl(this.size,this.gap,this.minGap)}}}loweringExit(e,t){let n=to(this.connectionSpecs,this.voices.length,this.sourceSpan);if(this.voices.length>=2){let s=this.voices.map(i=>e.getTemporalNodes(i)[0]);e.addAttachment(new Ca(s,this,n))}let o=`voices/${this.voices.length}`,r=t.groups.find(s=>s.laneKey===o)?.measure;return r&&(this.voices.length>=2&&(Math.abs(r.gap-this.gap)>1e-6||Math.abs(r.minGap-this.minGap)>1e-6)&&e.diagnostics.push(new O("W_VOICES_GAP_CONFLICT","\u76F8\u540C\u58F0\u90E8\u6570\u7684 @voices \u5171\u7528\u97F3\u8F68\u4F46\u8BBE\u7F6E\u4E86\u4E0D\u540C\u7684\u95F4\u8DDD\uFF0C\u5C06\u53D6\u8F83\u5927\u503C",this.sourceSpan)),r.size=Math.max(r.size,this.size),r.gap=Math.max(r.gap,this.gap),r.minGap=Math.max(r.minGap,this.minGap)),[]}constructor(e,t,n,o=null){super(e,o),this.voices=[],this.size=n.variables.fontsize,this.font=n.variables.font;let[r,s,i]=this.getArgValue(t,n);if(this.connect=r,this.gap=n.length2px(s),this.minGap=n.length2px(i),!Number.isFinite(this.gap)||this.gap<0||!Number.isFinite(this.minGap)||this.minGap<0)throw new w("E_INVALID_VOICES_GAP","@voices \u7684 gap \u548C minGap \u5FC5\u987B\u662F\u975E\u8D1F\u6709\u9650\u957F\u5EA6",e);for(let[c,l]of t)if(typeof c!="string"){if(!(l instanceof Ve))throw new w("E_VOICES_INVALID_CHILD","@voices \u7684\u53C2\u6570\u5FC5\u987B\u662F @voice \u51FD\u6570\uFF0C\u4F46\u53D1\u73B0\u4E86\u5176\u4ED6\u7C7B\u578B {actual}",l.sourceSpan,{actual:String(l?.constructor.name)});this.addVoice(l)}if(this.voices.length===0)throw new w("E_VOICES_EMPTY","@voices \u5FC5\u987B\u81F3\u5C11\u5305\u542B\u4E00\u4E2A @voice \u51FD\u6570",e)}addVoice(e){this.voices.push(e),e.parent=this,this.sourceSpan.start=Math.min(e.sourceSpan.start,this.sourceSpan.start),this.sourceSpan.end=Math.max(e.sourceSpan.end,this.sourceSpan.end)}toString(e){let t=this.voices.map(n=>` ${n.toString(e)}`);return t.push(` connect=${te(dn(this.connectionSpecs))}`,` gap=${this.gap}px`,` minGap=${this.minGap}px`),`@voices(
123
126
  ${t.join(`,
124
127
  `)}
125
- )`}},Ga=class{constructor(e,t,n){this.names=e;this.ast=t;this.connections=n;let o=e[0],r=e.at(-1),s=r.prepareLayout;r.prepareLayout=c=>{s.call(r,c),this.prepareLabels(c)};let i=o.prepareHorizontal;o.prepareHorizontal=c=>{i?.call(o,c),!(this.leftWidth<=0)&&c.registerHorizontalLayoutHook(o,o,({columns:l,start:p})=>{for(let u of l[p])u.WL=Math.max(u.WL,this.leftWidth)})}}names;ast;connections;kind="voices";layer="background";leftWidth=0;measuredLabels=[];get sourceSpan(){return this.ast.sourceSpan}prepareLabels(e){let t=to(this.ast.size,this.ast.font),n=this.ast.size*$c,o=0;this.measuredLabels=this.connections.map(r=>{if(!r.name)return;let s=ke(r.name,t,e.textMeasurer),i=0;for(let l=r.from-1;l<r.to;l++)i=Math.max(i,this.names[l].box.anchor);let c=(i>0?i+n:0)+s.w;return o=Math.max(o,c),{richLine:s,leftWidth:c}}),this.leftWidth=o}createGeometry(){let e=this.names[0].box,t=this.ast.size,n=x=>{let{y:h,visualAxis:b}=this.names[x].box;return h+b},o=n(0)-t*.5,r=n(this.names.length-1)+t*.5;if(r-o<1e-6)return{regions:[],paint(){}};let s=Math.max(si,t*.19),i=s*Ee,c=s*Oe,l=e.x+e.anchor,p=l+this.ast.braceSpace*ii+s/2,u=Math.min(s*.67,t*.25),m={x:p+s*1.33-s*.165,y:o+u,w:s*.33,h:r-o-u*2},y=[],d=[],g=[],f=[m];for(let x=0;x<this.connections.length;x++){let h=this.connections[x],b=n(h.from-1)-t*.5,S=n(h.to-1)+t*.5;if(h.kind==="bracket")y.push({x:p-s/2,y:b,w:s,h:S-b}),d.push({commands:Qn,transform:{x:p,y:b,scaleX:s,scaleY:-s}},{commands:Qn,transform:{x:p,y:S,scaleX:s,scaleY:s}}),f.push({x:p-s/2,y:b-c,w:i+s/2,h:S-b+c*2});else{let L=t*.35,C=m.x-t*.12-L,N=L/Pt.w,P=(S-b)/Pt.h;d.push({commands:qn,transform:{x:C-Pt.x*N,y:b-Pt.y*P,scaleX:N,scaleY:P}}),f.push({x:C,y:b,w:L,h:S-b})}let T=this.measuredLabels[x];T&&g.push({...T.richLine,x:l-T.leftWidth,y:(b+S-T.richLine.h)/2})}return y.push(m),this.names[0].ports["bar.number"]={x:p+s*1.33-e.x,y:Math.min(o,...f.map(x=>x.y))-e.y},f.push(...g),{regions:f,paint(x){for(let h of y)x.drawRect(h.x,h.y,h.w,h.h,{fill:"#000"});for(let h of d)x.drawPath(h.commands,{fill:"#000"},h.transform);for(let h of g)Be(x,h,h.x+h.w,h.y+h.baseline)}}}},eo=_e;var Uc=.6;function to(a,e){return{fontFamily:e,fontSize:a*.85,fill:"#000",textAlign:"right"}}var Ie=class a extends E{static def={name:["voice","v"],description:"\u58F0\u90E8",details:"~~~jpfun\n@voice({1 2 3}, \u94A2\u7434, \u7537=ha ha ha, \u5973=la la la)\n~~~\n- **\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\n\n\u6B4C\u8BCD\u53EF\u7528\u5F15\u53F7\u5305\u88F9\uFF1B\u8C03\u7528 `@voice` \u65F6\u6B4C\u8BCD\u82E5\u542B\u9017\u53F7\u987B\u52A0\u5F15\u53F7\u3002\u82F1\u6587\u7528\u7A7A\u683C\u6216\u8FDE\u5B57\u7B26 `-` \u5206\u8BCD\uFF0C\u7528 `@` \u7559\u7A7A\uFF1B`{\u4F60\u597D}` \u5408\u4E3A\u4E00\u4E2A\u97F3\u7B26\u69FD\uFF0C\u672B\u5C3E\u52A0 `@`\uFF08\u5982 `{a@@}`\uFF09\u53EF\u5DE6\u5BF9\u9F50\u5E76\u8986\u76D6\u591A\u4E2A\u97F3\u7B26\u69FD\u3002\u540D\u79F0\u4E0E\u6B4C\u8BCD\u5747\u652F\u6301 `*\u659C\u4F53*`\u3001`**\u7C97\u4F53**`\u3001`_\u4E0B\u5212\u7EBF_`\u3001`^\u4E0A\u6807^`\uFF08\u53EF\u8DE8\u591A\u4E2A\u97F3\u7B26\uFF0C\u5982 `*\u6625\u7720\u4E0D\u89C9\u6653*`\uFF09\u3002\n\n**\u7B80\u5199**\uFF1A`N` \u58F0\u660E\u97F3\u7B26\u884C\uFF0C`L` \u58F0\u660E\u6B4C\u8BCD\u884C\uFF0C\u62EC\u53F7\u5185\u7684\u540D\u79F0\u53EF\u7701\u7565\uFF1A\n~~~jpfun\nN(\u94A2\u7434): 1 2 3\nL(\u7537): ha ha ha\nL: la la la\n~~~\n\u6362\u884C\u7ED3\u675F\u5F53\u524D\u884C\uFF0C\u884C\u672B\u52A0 `\\` \u53EF\u7EED\u884C\uFF1B`L:` \u4E2D\u53EF\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(e,t,n){if(e[t]!=="N"&&e[t]!=="L")return null;let o=t+1,r={start:o,end:o};if(e[o]==="("){let l=ur(e,o+1,n);if(l<0)return null;r={start:o+1,end:l},o=l+1}if(e[o++]!==":")return null;if(e[t]==="N")return{next:o,node:{kind:"sugar",data:{class:a,name:r},span:{start:t,end:o}}};let s=Pe(e,o,n);if(s>=n)return null;let i;if(e[s]==='"'){let l=ae(e,s,n);if(l<0)return null;i={start:s,end:l+1}}else{let l=s;for(;l<n&&e[l]!==`
126
- `;)l++;i={start:s,end:l}}let c={kind:"sugar",data:{class:a,lyric:i,name:r},span:{start:t,end:i.end},syntaxKind:[{kind:"operator",span:{start:t,end:o}},{kind:"string",span:i}]};return{next:i.end,node:c}}static deSugarRelation(e,t,n,o){let r=t[n++];if(r.data?.class!==a)return null;let s=h=>e.parseArgWithType(h,"string")??"";if(r.data?.lyric!==void 0){let h=null,b=e.nodes.length-1;for(;b>=0;b--){let S=e.nodes[b];if(S instanceof pe){if(!e.variables.strict)continue;throw new w("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",S.sourceSpan)}S instanceof a?h=S:S instanceof _e&&(h=S.voices.at(-1)??null);break}if(h===null)throw new w("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",r.span);return h.addLyric(s(r.data.name),s(r.data.lyric),r.data.lyric,e),e.nodes.length=b+1,n<t.length&&typeof t[n]=="number"&&e.source[t[n]]===`
127
- `&&n++,n}let i=s(r.data.name),c=n,l=0;for(;c<t.length;c++){let h=t[c];if(typeof h=="number"){if(e.source[h]===`
128
- `){l=1;break}}else if(h.kind==="sugar"&&(h.data?.class===a||h.data?.class===_e))break}let p=new le(e),u=t.slice(n,c);if(c+=l,p.makeNodes(u),p.nodes.length===0)throw O.error.EmptyContent("voice","content",r.span);let m={start:r.span.start,end:p.nodes.at(-1).sourceSpan.end},y=new Map;p.nodes.length===1&&p.nodes[0]instanceof re?y.set(0,p.nodes[0]):y.set(0,new re({...m},p.nodes)),y.set("name",i);let d=new a(m,y,e,null);if(o)return e.pushNode(d),o.push(d),c;let g=null,f=e.nodes.length-1,x=null;e:for(;f>=0;f--){let h=e.nodes[f];if(h instanceof pe){if(e.variables.strict)break;for(let b=h.sourceSpan.start;b<h.sourceSpan.end;b++)if(e.source[b]===`
129
- `)break e;x=h;continue}if(h instanceof _e){if(!h.createdBySugar)break;g=h}else if(h instanceof a){let b=new Map;b.set(0,h),g=new _e({start:h.sourceSpan.start,end:h.sourceSpan.end},b,e,null),g.createdBySugar=!0}break}return g?(e.nodes[f]=g,g.addVoice(d),x&&(e.nodes.length=f+1,e.diagnostics.push(new I("W_VOICES_TEXT_BETWEEN","\u4E24\u4E2A @voice \u4E4B\u95F4\u6709\u672A\u77E5\u6587\u672C\u3002\u5F53\u524D\u5904\u4E8E\u975E strict \u6A21\u5F0F\uFF0C\u4F1A\u5FFD\u7565\u8BE5\u5185\u5BB9\u3001\u5408\u5E76\u4E3A\u4E00\u4E2A @voices",x.sourceSpan)))):e.pushNode(d),c}content;name;size;font;lyrics;lyricSources=[];cachedLyricSpans;get children(){return[this.content]}lyricTokenSpan(e,t){return this.cachedLyricSpans??=this.lyricSources.map(({source:n,lyric:o,span:r})=>{let{start:s,end:i}=ze(n,r.start,r.end),c=i-s>=2&&n[s]==='"'&&n[i-1]==='"',l=s+(c?1:0),p=n.slice(l,i-(c?1:0)),u=[],m=0;for((o!==p||!p.includes("\\u"))&&p.replace(/\\(u[0-9a-fA-F]{4}|["\\])/g,(d,g,f)=>{for(;m<=f;)u.push(l+m++);return m=f+d.length,""});m<=p.length;)u.push(l+m++);let y=[];return Zn(o,u,y),y}),this.cachedLyricSpans[e]?.[t]}loweringEnter(e){let t=this.parent,n=t instanceof _e&&t.voices.length>1?t.braceSpace:0,o=new no(this,n);if(this.lyrics.length>0){let r={nameHost:o,nodes:[],frames:[],onTemporal(s){M(s)&&r.nodes.push(s)},onAttachment(s){Ne(s)&&s.layer==="background"&&r.frames.push(s)}};e.beginLoweringGroup(this,r)}return[o]}loweringExit(e){if(this.lyrics.length>0){let{nodes:t,nameHost:n,frames:o}=e.endLoweringGroup(this);e.addAttachment(new sn(t,n,o))}return[]}constructor(e,t,n,o=null){super(e,o),this.size=n.variables.fontsize,[this.content,this.name]=this.getArgValue(t,n),this.content.parent=this,this.font=n.variables.font,t.delete(0),t.delete("name"),t.delete(1),this.lyrics=[];for(let[r,s]of t){if(typeof s=="string"){this.addLyric(r,s,n.callNode?.args[r]?.valueSpan??null,n);continue}let i=s,c=n.parseArgWithType(i.valueSpan,"string",e.start);c===null?n.diagnostics.push(new I("W_VOICE_INVALID_LYRIC","@voice \u7684\u6B4C\u8BCD\u53C2\u6570\u503C\u89E3\u6790\u5931\u8D25, \u53C2\u6570[{key}]\u5C06\u88AB\u5FFD\u7565",i.valueSpan,{key:r})):this.addLyric(r,c,i.valueSpan,n)}}addLyric(e,t,n=null,o=null){typeof e=="number"&&(e="");let r=Zn(t);if(r.length===0&&o&&n&&o.diagnostics.push(new I("W_EMPTY_LYRIC","@voice\u7684\u6B4C\u8BCD{name}\u662F\u7A7A\u7684",n,{name:e})),this.cachedLyricSpans=void 0,o&&n&&(this.lyricSources[this.lyrics.length]={source:o.source,lyric:t,span:n}),this.lyrics.push({name:e,tokens:r}),n)for(let s=this;s;s=s.parent)s.sourceSpan.start=Math.min(n.start,s.sourceSpan.start),s.sourceSpan.end=Math.max(n.end,s.sourceSpan.end)}toString(e){let t=[`${this.content.toString(e)},${ee(this.name)}`];for(let n of this.lyrics){let o=Ia(n.tokens);t.push(n.name?`${n.name}=${o}`:o)}return`@voice(
128
+ )`}},Ca=class{constructor(e,t,n){this.names=e;this.ast=t;this.connections=n;let o=e[0],r=e.at(-1),s=r.prepareLayout;r.prepareLayout=c=>{s.call(r,c),this.prepareLabels(c)};let i=o.prepareHorizontal;o.prepareHorizontal=c=>{i?.call(o,c),!(this.leftWidth<=0)&&c.registerHorizontalLayoutHook(o,o,({columns:l,start:p})=>{for(let u of l[p])u.WL=Math.max(u.WL,this.leftWidth)})}}names;ast;connections;kind="voices";layer="background";leftWidth=0;measuredLabels=[];get sourceSpan(){return this.ast.sourceSpan}prepareLabels(e){let t=no(this.ast.size,this.ast.font),n=this.ast.size*dl,o=0;this.measuredLabels=this.connections.map(r=>{if(!r.name)return;let s=ve(r.name,t,e.textMeasurer),i=0;for(let l=r.from-1;l<r.to;l++)i=Math.max(i,this.names[l].box.anchor);let c=(i>0?i+n:0)+s.w;return o=Math.max(o,c),{richLine:s,leftWidth:c}}),this.leftWidth=o}createGeometry(){let e=this.names[0].box,t=this.ast.size,n=g=>{let{y:x,visualAxis:b}=this.names[g].box;return x+b},o=n(0)-t*.5,r=n(this.names.length-1)+t*.5;if(r-o<1e-6)return{regions:[],paint(){}};let s=Math.max(xi,t*.19),i=s*De,c=s*Ue,l=e.x+e.anchor,p=l+this.ast.braceSpace*gi+s/2,u=Math.min(s*.67,t*.25),m={x:p+s*1.33-s*.165,y:o+u,w:s*.33,h:r-o-u*2},f=[],d=[],h=[],y=[m];for(let g=0;g<this.connections.length;g++){let x=this.connections[g],b=n(x.from-1)-t*.5,S=n(x.to-1)+t*.5;if(x.kind==="bracket")f.push({x:p-s/2,y:b,w:s,h:S-b}),d.push({commands:La,transform:{x:p,y:b,scaleX:s,scaleY:-s}},{commands:La,transform:{x:p,y:S,scaleX:s,scaleY:s}}),y.push({x:p-s/2,y:b-c,w:i+s/2,h:S-b+c*2});else{let L=t*.35,C=m.x-t*.12-L,A=L/mn.w,v=(S-b)/mn.h;d.push({commands:wa,transform:{x:C-mn.x*A,y:b-mn.y*v,scaleX:A,scaleY:v}}),y.push({x:C,y:b,w:L,h:S-b})}let T=this.measuredLabels[g];T&&h.push({...T.richLine,x:l-T.leftWidth,y:(b+S-T.richLine.h)/2})}return f.push(m),this.names[0].ports["bar.number"]={x:p+s*1.33-e.x,y:Math.min(o,...y.map(g=>g.y))-e.y},y.push(...h),{regions:y,paint(g){for(let x of f)g.drawRect(x.x,x.y,x.w,x.h,{fill:"#000"});for(let x of d)g.drawPath(x.commands,{fill:"#000"},x.transform);for(let x of h)Ie(g,x,x.x+x.w,x.y+x.baseline)}}}},Aa=Re;var hl=.6;function no(a,e){return{fontFamily:e,fontSize:a*.85,fill:"#000",textAlign:"right"}}var Ve=class a extends P{static def={name:["voice","v"],description:"\u58F0\u90E8",details:"~~~jpfun\n@voice({1 2 3}, \u94A2\u7434, \u7537=ha ha ha, \u5973=la la la)\n~~~\n- **\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\n\n\u6B4C\u8BCD\u53EF\u7528\u5F15\u53F7\u5305\u88F9\uFF1B\u8C03\u7528 `@voice` \u65F6\u6B4C\u8BCD\u82E5\u542B\u9017\u53F7\u987B\u52A0\u5F15\u53F7\u3002\u82F1\u6587\u7528\u7A7A\u683C\u6216\u8FDE\u5B57\u7B26 `-` \u5206\u8BCD\uFF0C\u7528 `@` \u7559\u7A7A\uFF1B`{\u4F60\u597D}` \u5408\u4E3A\u4E00\u4E2A\u97F3\u7B26\u69FD\uFF0C\u672B\u5C3E\u52A0 `@`\uFF08\u5982 `{a@@}`\uFF09\u53EF\u5DE6\u5BF9\u9F50\u5E76\u8986\u76D6\u591A\u4E2A\u97F3\u7B26\u69FD\u3002\u540D\u79F0\u4E0E\u6B4C\u8BCD\u5747\u652F\u6301 `*\u659C\u4F53*`\u3001`**\u7C97\u4F53**`\u3001`_\u4E0B\u5212\u7EBF_`\u3001`^\u4E0A\u6807^`\uFF08\u53EF\u8DE8\u591A\u4E2A\u97F3\u7B26\uFF0C\u5982 `*\u6625\u7720\u4E0D\u89C9\u6653*`\uFF09\u3002\n\n**\u7B80\u5199**\uFF1A`N` \u58F0\u660E\u97F3\u7B26\u884C\uFF0C`L` \u58F0\u660E\u6B4C\u8BCD\u884C\uFF0C\u62EC\u53F7\u5185\u7684\u540D\u79F0\u53EF\u7701\u7565\uFF1A\n~~~jpfun\nN(\u94A2\u7434): 1 2 3\nL(\u7537): ha ha ha\nL: la la la\n~~~\n\u6362\u884C\u7ED3\u675F\u5F53\u524D\u884C\uFF0C\u884C\u672B\u52A0 `\\` \u53EF\u7EED\u884C\uFF1B`L:` \u4E2D\u53EF\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(e,t,n){if(e[t]!=="N"&&e[t]!=="L")return null;let o=t+1,r={start:o,end:o};if(e[o]==="("){let l=cr(e,o+1,n);if(l<0)return null;r={start:o+1,end:l},o=l+1}if(e[o++]!==":")return null;if(e[t]==="N"){let l={kind:"sugar",data:{name:r},span:{start:t,end:o},relation:a.deSugarLine};return{next:o,node:l}}let s=_e(e,o,n);if(s>=n)return null;let i;if(e[s]==='"'){let l=ie(e,s,n);if(l<0)return null;i={start:s,end:l+1}}else{let l=s;for(;l<n&&e[l]!==`
129
+ `;)l++;i={start:s,end:l}}let c={kind:"sugar",data:{lyric:i,name:r},span:{start:t,end:i.end},syntaxKind:[{kind:"operator",span:{start:t,end:o}},{kind:"string",span:i}],relation:a.deSugarLine};return{next:i.end,node:c}}static deSugarLine(e,t,n,o){let r=t[n++],s=x=>e.parseArgWithType(x,"string")??"";if(r.data?.lyric!==void 0){let x=null,b=e.nodes.length-1;for(;b>=0;b--){let S=e.nodes[b];if(S instanceof pe){if(!e.variables.strict)continue;throw new w("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",S.sourceSpan)}S instanceof a?x=S:S instanceof Re&&(x=S.voices.at(-1)??null);break}if(x===null)throw new w("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",r.span);return x.addLyric(s(r.data.name),s(r.data.lyric),r.data.lyric,e),e.nodes.length=b+1,n<t.length&&typeof t[n]=="number"&&e.source[t[n]]===`
130
+ `&&n++,n}let i=s(r.data.name),c=n,l=0;for(;c<t.length;c++){let x=t[c];if(typeof x=="number"){if(e.source[x]===`
131
+ `){l=1;break}}else if(x.kind==="sugar"&&(x.relation===a.deSugarLine||x.relation===Re.deSugarGroup))break}let p=new re(e),u=t.slice(n,c);if(c+=l,p.makeNodes(u),p.nodes.length===0)throw M.error.EmptyContent("voice","content",r.span);let m={start:r.span.start,end:p.nodes.at(-1).sourceSpan.end},f=new Map;p.nodes.length===1&&p.nodes[0]instanceof se?f.set(0,p.nodes[0]):f.set(0,new se({...m},p.nodes)),f.set("name",i);let d=new a(m,f,e,null);if(o)return e.pushNode(d),o.push(d),c;let h=null,y=e.nodes.length-1,g=null;e:for(;y>=0;y--){let x=e.nodes[y];if(x instanceof pe){if(e.variables.strict)break;for(let b=x.sourceSpan.start;b<x.sourceSpan.end;b++)if(e.source[b]===`
132
+ `)break e;g=x;continue}if(x instanceof Re){if(!x.createdBySugar)break;h=x}else if(x instanceof a){let b=new Map;b.set(0,x),h=new Re({start:x.sourceSpan.start,end:x.sourceSpan.end},b,e,null),h.createdBySugar=!0}break}return h?(e.nodes[y]=h,h.addVoice(d),g&&(e.nodes.length=y+1,e.diagnostics.push(new O("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",g.sourceSpan)))):e.pushNode(d),c}content;name;size;font;lyrics;lyricSources=[];cachedLyricSpans;get children(){return[this.content]}lyricTokenSpan(e,t){return this.cachedLyricSpans??=this.lyricSources.map(({source:n,lyric:o,span:r})=>{let{start:s,end:i}=ze(n,r.start,r.end),c=i-s>=2&&n[s]==='"'&&n[i-1]==='"',l=s+(c?1:0),p=n.slice(l,i-(c?1:0)),u=[],m=0;for((o!==p||!p.includes("\\u"))&&p.replace(/\\(u[0-9a-fA-F]{4}|["\\])/g,(d,h,y)=>{for(;m<=y;)u.push(l+m++);return m=y+d.length,""});m<=p.length;)u.push(l+m++);let f=[];return Jn(o,u,f),f}),this.cachedLyricSpans[e]?.[t]}loweringEnter(e){let t=this.parent,n=t instanceof Re&&t.voices.length>1?t.braceSpace:0,o=new oo(this,n);if(this.lyrics.length>0){let r={nameHost:o,nodes:[],frames:[],onTemporal(s){_(s)&&r.nodes.push(s)},onAttachment(s){Ne(s)&&s.layer==="background"&&r.frames.push(s)}};e.beginLoweringGroup(this,r)}return[o]}loweringExit(e){if(this.lyrics.length>0){let{nodes:t,nameHost:n,frames:o}=e.endLoweringGroup(this);e.addAttachment(new un(t,n,o))}return[]}constructor(e,t,n,o=null){super(e,o),this.size=n.variables.fontsize,[this.content,this.name]=this.getArgValue(t,n),this.content.parent=this,this.font=n.variables.font,t.delete(0),t.delete("name"),t.delete(1),this.lyrics=[];for(let[r,s]of t){if(typeof s=="string"){this.addLyric(r,s,n.callNode?.args[r]?.valueSpan??null,n);continue}let i=s,c=n.parseArgWithType(i.valueSpan,"string",e.start);c===null?n.diagnostics.push(new O("W_VOICE_INVALID_LYRIC","@voice \u7684\u6B4C\u8BCD\u53C2\u6570\u503C\u89E3\u6790\u5931\u8D25, \u53C2\u6570[{key}]\u5C06\u88AB\u5FFD\u7565",i.valueSpan,{key:r})):this.addLyric(r,c,i.valueSpan,n)}}addLyric(e,t,n=null,o=null){typeof e=="number"&&(e="");let r=Jn(t);if(r.length===0&&o&&n&&o.diagnostics.push(new O("W_EMPTY_LYRIC","@voice\u7684\u6B4C\u8BCD{name}\u662F\u7A7A\u7684",n,{name:e})),this.cachedLyricSpans=void 0,o&&n&&(this.lyricSources[this.lyrics.length]={source:o.source,lyric:t,span:n}),this.lyrics.push({name:e,tokens:r}),n)for(let s=this;s;s=s.parent)s.sourceSpan.start=Math.min(n.start,s.sourceSpan.start),s.sourceSpan.end=Math.max(n.end,s.sourceSpan.end)}toString(e){let t=[`${this.content.toString(e)},${te(this.name)}`];for(let n of this.lyrics){let o=Sa(n.tokens);t.push(n.name?`${n.name}=${o}`:o)}return`@voice(
130
133
  ${t.join(`,
131
134
  `)}
132
- )`}},no=class extends W{braceSpace;preparedName=null;constructor(e,t){super(),this.ast=e,this.braceSpace=t,this.mergeKey=-2,(e.name||t>0||e.lyrics.some(n=>n.name))&&this.initLayoutBox()}prepareLayout(e){this.preparedName=this.ast.name?ke(this.ast.name,to(this.ast.size,this.ast.font),e.textMeasurer):null;let t=this.preparedName?.w??0,n=an(this.ast.size,this.ast.font);for(let r of this.ast.lyrics)r.name&&(t=Math.max(t,ke(r.name,n,e.textMeasurer).w));let o=this.braceSpace>0?this.braceSpace:t>0?this.ast.size*Uc:0;this.box.w=t+o,this.box.h=this.preparedName?.h??0,this.box.anchor=t,this.box.visualAxis=this.box.h/2,this.springConfig.alpha_R=.45}paint(e){this.preparedName&&Be(e,this.preparedName,this.box.x+this.box.anchor,this.box.y+this.preparedName.baseline)}},oo=Ie;var ro=[Rr,Ko,Dr,ko,Do,Xo,Ba,Na,oo,eo,Qt,Kr,$r,kr,qr,zr,jr,wo,Jo,ar,Ra,Go,nr,qo,Wo,Pa,Fr,lo,Ta,Xt,Dt,Zt,Xr,qt,ba];function za(a,e={}){let t=new Map,n=new Set(a);for(let o of n){let r=o.layoutDecorationHandler;if(!r)continue;let s=o.def?.name;if(!s)continue;let i=Array.isArray(s)?s[0]:s;t.set(Xe(i),r)}return{textMeasurer:e.textMeasurer??cr,decorationHandlers:t}}var cn=class a{activeFinalizers=new Map;cnt=0;usedTracks=new Set;attachments=[];page;astToTemporal=new Map;activeLoweringGroups=[];diagnostics=[];setPageConfig(e){this.page=e}lowerDocument(e,t=[]){this.cnt=0,this.usedTracks.clear(),this.activeFinalizers.clear(),this.attachments=[],this.page=void 0,this.astToTemporal=new Map,this.activeLoweringGroups=[],this.diagnostics=t;let n=new tt,o=new V,r=this.trackedEvents(e,o,n);return this.solidifyColumns(r,o),this.postprocessResult({diagnostics:this.diagnostics,columns:r,attachments:this.attachments,astToTemporal:this.astToTemporal,duration:o,rootTrack:n,tracks:[...this.usedTracks],page:this.page})}solidifyColumns(e,t){let n=0;for(let m of e){let y=0;for(let d of m){let g=d.addon?.breakBefore??0;g>y&&(y=g)}n+=y,m.layoutLine=n}let o={bpm:He,velocity:lt,keySignature:Ze,program:pn},r=new Map,s=new Map,i=m=>r.get(m)??(m.parent?i(m.parent):lt),c=m=>s.get(m)??(m.parent?c(m.parent):pn),l=new V;for(let m of e){l.isZero()||m.shiftTime(l);let y;for(let d of m){o.velocity=i(d.track),o.program=c(d.track);let g=d.onTimeState?.(o);g&&!g.isZero()&&(!y||g.compare(y)>0)&&(y??=new V).copyFrom(g),r.set(d.track,o.velocity),s.set(d.track,o.program)}y&&l.add(y)}if(l.isZero())return;let p=new Set(s.keys()),u=new V;t.set(0);for(let m=e.length-1;m>=0&&p.size>0;m--){let y=e[m];for(let d=y.length-1;d>=0;d--){let g=y[d];if(!p.delete(g.track))continue;let f=g.T;u.copyFrom(g.t),f.isZero()||u.add(f),u.compare(t)>0&&t.copyFrom(u)}}}beginLoweringGroup(e,t){this.activeLoweringGroups.push({owner:e,group:t})}endLoweringGroup(e){let t=this.activeLoweringGroups.pop();if(!t)throw new Error("No active lowering group to end");if(t.owner!==e)throw new Error("Lowering groups must end in reverse order");return t.group}postprocessResult(e){if(this.activeLoweringGroups.length>0)throw new Error("Lowering groups must be closed before post-processing");let t=this.activeFinalizers.size;if(t===0)return e;if(t===1)return this.activeFinalizers.keys().next().value(e),e;let n=[...this.activeFinalizers.entries()].sort((o,r)=>o[1]-r[1]);for(let[o]of n)o(e);return e}deferFinalize(e,t=0){let n=this.activeFinalizers.get(e);(n===void 0||t<n)&&this.activeFinalizers.set(e,t)}addAttachment(e){this.attachments.push(e);for(let t=this.activeLoweringGroups.length-1;t>=0;t--)this.activeLoweringGroups[t].group.onAttachment?.(e)}getTemporalNodes(e){return this.astToTemporal.get(e)??[]}isolateFromLoweringGroups(e){let t=this.activeLoweringGroups;this.activeLoweringGroups=[];try{return e()}finally{this.activeLoweringGroups=t}}initEvent(e,t,n,o){e.t.add(n),this.usedTracks.add(o),e.track=o,e.ast??=t,e.order=this.cnt++,e.mergeKey??=e.order}trackedEvents(e,t,n,o=[]){this.appendEvents(e.loweringEnter(this,n),e,t,n,o);let r=e.timeFlowModel(this);if(r)switch(r.mode){case"sequence":for(let s of r.children)this.trackedEvents(s,t,n,o);break;case"parallel":{let s=r.tracks,i=r.children,c=s.hostIndex===void 0?0:s.hostIndex,l=n.group(s,c===null?i.length:i.length-1),p=[];for(let y=0;y<i.length;y++){let d=i[y],g=y===c?n:l.members[c===null||y<c?y:y-1],f=t.clone(),x=this.trackedEvents(d,f,g);x.length===0&&this.diagnostics.push(O.warning.ZeroTimeTrack(d.sourceSpan,y+1)),p.push(x)}let u=o.length;for(let y of a.anchorAlign(p))o.push(y);let m=new V;for(let y=u;y<o.length;y++)for(let d of o[y])m.copyFrom(d.t).add(d.T),m.compare(t)>0&&t.copyFrom(m)}break}return this.appendEvents(e.loweringExit(this,n,t),e,t,n,o),o}appendEvents(e,t,n,o,r){let s;for(let i of e){this.initEvent(i,t,n,o),this.indexTemporal(i);for(let l=this.activeLoweringGroups.length-1;l>=0;l--)this.activeLoweringGroups[l].group.onTemporal?.(i);let c=(s??=new V).copyFrom(i.t).add(i.T);c.compare(n)>0&&n.copyFrom(c),r.push(new Wa(i))}}indexTemporal(e){let t=this.astToTemporal.get(e.ast);t?t.push(e):this.astToTemporal.set(e.ast,[e])}static anchorAlign(e){for(let l=e.length-1;l>=0;l--)e[l].length===0&&e.splice(l,1);let t=e.length;if(t===0)return[];if(t===1)return e[0];let n=[],o=new Uint32Array(t),r=Array.from({length:t},()=>new V),s=[],i=new $a(t);for(let l=0;l<t;l++)i.push({e:e[l][0],i:l});let c=l=>{let p=e[l][++o[l]];p&&(r[l].isZero()||p.shiftTime(r[l]),i.push({e:p,i:l}))};for(;;){let l=i.pop();if(l===void 0){if(s.length===0)break;let u=s[0],m=u.e,y=m.t;for(let d=1;d<s.length;d++)s[d].e.t.compare(y)>0&&(y=s[d].e.t);r[u.i].add(y).sub(m.t),c(u.i);for(let d=1;d<s.length;d++){let g=s[d];m.push(...g.e),r[g.i].add(y).sub(g.e.t),c(g.i)}s.length=0,m.t=y,m.sort((d,g)=>d.order-g.order),n.push(m);continue}if(l.e.mergeKey===Q){s.push(l);continue}let p=[l.i];for(;;){let u=i.front();if(!u||!u.e.t.equals(l.e.t)||u.e.mergeKey!==l.e.mergeKey)break;i.pop(),l.e.push(...u.e),p.push(u.i)}n.push(l.e);for(let u of p)c(u)}return n}},Wa=class extends Array{static get[Symbol.species](){return Array}mergeKey;constructor(e){super(1),this.mergeKey=e.mergeKey,this[0]=e}get t(){return this[0].t}set t(e){for(let t of this)t.t.copyFrom(e)}shiftTime(e){for(let t of this)t.t.add(e)}set layoutLine(e){for(let t of this)t.layoutLine=e}};function ja(a,e){let t=a.e.t.compare(e.e.t);return t!==0?t:a.e.mergeKey!==e.e.mergeKey?a.e.mergeKey<e.e.mergeKey?-1:1:a.i-e.i}var $a=class extends Array{validLen=0;constructor(e){super(e)}front(){if(this.validLen!==0)return this[0]}push(e){return this[this.validLen]=e,this.up(this.validLen++),this.validLen}pop(){if(this.validLen===0)return;let e=this[0];return this[0]=this[--this.validLen],this[this.validLen]=void 0,this.down(0),e}up(e){let t=this[e];for(;e>0;){let n=e-1>>1;if(ja(t,this[n])>=0)break;this[e]=this[n],e=n}this[e]=t}down(e){let t=this[e];for(;;){let n=(e<<1)+1,o=n+1;if(n>=this.validLen)break;let r=n;if(o<this.validLen&&ja(this[o],this[n])<0&&(r=o),ja(this[r],t)>=0)break;this[e]=this[r],e=r}this[e]=t}};function Xc(a,e={}){let{functions:t=ro,textMeasurer:n,variables:o,...r}=e,{maskedSource:s,lineStarts:i}=St(a),c=new le({source:s,variables:o});c.registerFunctions(t);let l=new re({start:0,end:a.length},c.parse()),u=new cn().lowerDocument(l,c.diagnostics),m=za(t,{textMeasurer:n}),y=fo(u,m,r);return{lineStarts:i,maskedSource:s,diagnostics:c.diagnostics,ast:l,lowering:u,layout:y}}function Zc(a,e=ro){let{maskedSource:t,commentSpans:n}=St(a),o=new le({source:t,commentSpans:n});return o.registerFunctions(e),{syntax:o.parseSyntax(),diagnostics:o.diagnostics}}function Ya(a){return typeof a.applyPlayback=="function"}var ci={tempo:0,"time-signature":1,"program-change":2,"note-off":3,"note-on":4};function Ka(a,e){return a.at.compare(e.at)||ci[a.kind]-ci[e.kind]||a.order-e.order}function Ua(a,e,t){let n=new Map;for(let r of e)t.has(r)&&n.set(r,n.size);for(let r of t)n.has(r)||n.set(r,n.size);let o=[];for(let r of a){if(r.kind==="tempo"){o.push({kind:"tempo",at:r.at,bpm:r.bpm});continue}if(r.kind==="time-signature"){o.push({kind:"time-signature",at:r.at,numerator:r.numerator,denominator:r.denominator});continue}let s=n.get(r.track);if(s!==void 0){if(r.kind==="program-change"){o.push({kind:"program-change",at:r.at,track:s,program:r.program});continue}if(r.kind==="note-on"){o.push({kind:"note-on",at:r.at,noteId:r.noteId,track:s,midi:r.midi,velocity:r.velocity,...r.percussion?{percussion:!0}:{},sourceSpans:r.sourceSpans});continue}o.push({kind:"note-off",at:r.at,noteId:r.noteId,track:s,midi:r.midi})}}return{events:o,tracks:[...n.keys()]}}var li=new WeakMap;function pi(a){let e=li.get(a);if(e)return e;let t=[{performance:0,seconds:0,bpm:He}],n=0,o=0,r=He;for(let s of a){if(s.kind!=="tempo")continue;let i=s.at.toNumber();i>o&&(n+=(i-o)*60/r,o=i),r=s.bpm;let c=t[t.length-1];c.performance===o?c.bpm=r:t.push({performance:o,seconds:n,bpm:r})}return li.set(a,t),t}function Xa(a,e,t){let n=0,o=a.length;for(;n<o;){let r=n+o>>>1;t(a[r])<=e?n=r+1:o=r}return a[Math.max(0,n-1)]}function ao(a,e){let t=Math.max(0,e),n=Xa(pi(a),t,o=>o.performance);return n.seconds+(t-n.performance)*60/n.bpm}function ui(a,e){let t=Math.max(0,e),n=Xa(pi(a),t,o=>o.seconds);return n.performance+(t-n.seconds)*n.bpm/60}function mi(a,e){let t=Math.max(0,e),n=Xa(a,t,o=>o.performance.toNumber());return n&&n.performance.toNumber()<=t?n.score.toNumber()+t-n.performance.toNumber():t}function di(a,e){let t=Math.max(0,e),n;for(let o=0;o<a.length;o++){let r=a[o],s=r.score.toNumber();if(s>t){(!n||s<n.score.toNumber())&&(n=r);continue}let i=a[o+1],c=i?i.performance.toNumber()-r.performance.toNumber():1/0;if(!(t-s>=c))return r.performance.toNumber()+(t-s)}return n?.performance.toNumber()??t}function qc(a,e){let t=Math.min(ui(a.events,e),a.performanceDuration.toNumber());return mi(a.scoreMap,t)}function Qc(a,e){let t=Math.min(di(a.scoreMap,e),a.performanceDuration.toNumber());return ao(a.events,t)}function Jc(a,e,t){let n=a.columns,o,r=(f,x)=>{if(!o){o=new Map;for(let h=0;h<n.length;h++)for(let b of n[h])o.set(b,h)}for(let h=f;h;h=h.foldedInto){let b=o.get(h);if(b===void 0)continue;if(x!=="end"||h.T.compare(0)<=0)return b;let S=h.t.clone().add(h.T),T=b;for(;T+1<n.length&&n[T+1][0].t.compare(S)<0;)T++;return T}},s=new Map,i=new Map,c=(f,x)=>{let h=f.playbackFlow?.(r);if(!h)return;let[b,S]=h.range??[0,n.length-1];if(h.range&&(!Number.isSafeInteger(b)||!Number.isSafeInteger(S)||b<0||S<b||S>=n.length))throw new w("E_PLAYBACK_FLOW_RANGE","\u64AD\u653E\u63A7\u5236\u6D41\u8303\u56F4 [{from}, {to}] \u8D85\u51FA\u65F6\u95F4\u5217\u8FB9\u754C",x,{from:b,to:S});let T={hook:h,sourceSpan:x};for(let L=b;L<=S;L++){let C=i.get(L);C?C.push(T):i.set(L,[T])}};for(let f of a.astToTemporal.values())for(let x of f){c(x,x.ast.sourceSpan);let h=x.playbackMarks?.();if(!h?.length)continue;let b=r(x);if(b!==void 0)for(let S of h){let T=s.get(S);T?T.push(b):s.set(S,[b])}}for(let f of a.attachments)c(f,f.sourceSpan??{start:0,end:0});if(i.size===0)return n.map((f,x)=>x);for(let f of s.values())f.sort((x,h)=>x-h);let l=new Array(n.length).fill(0),p=0,u={get column(){return p},visits:f=>l[f]??0,seek(f,x,h){let b=s.get(f);if(b){if(h>0)return b.find(S=>S>x);for(let S=b.length-1;S>=0;S--)if(b[S]<x)return b[S]}}},m=[],y=0;for(;p<n.length;){if(++y>t)throw new w("E_PLAYBACK_FLOW_LIMIT","\u64AD\u653E\u63A7\u5236\u6D41\u8BBF\u95EE\u8D85\u8FC7 {maxFlowSteps} \u6B65\uFF1B\u53EF\u901A\u8FC7 maxFlowSteps \u63D0\u9AD8\u5C55\u5F00\u9884\u7B97",n[p][0].ast.sourceSpan,{maxFlowSteps:t});l[p]++;let f;for(let x of i.get(p)??[]){let b=x.hook.run(u);if(b){if(b.kind==="stop")return m;if(!Number.isSafeInteger(b.column)||b.column<0||b.column>n.length)throw new w("E_PLAYBACK_FLOW_JUMP","\u64AD\u653E\u63A7\u5236\u6D41\u8DF3\u8F6C\u76EE\u6807 {column} \u8D85\u51FA\u65F6\u95F4\u5217\u8FB9\u754C",x.sourceSpan,{column:b.column});f=Math.min(f??1/0,b.column)}}f!==void 0?p=f:(m.push(p),p++)}let d=new Set(m),g=!1;for(let f=0;f<n.length;f++){let x=!d.has(f)&&n[f].some(h=>!h.T.isZero());x&&!g&&e.push(new I("W_PLAYBACK_COLUMN_NEVER_PLAYED","\u8FD9\u91CC\u5728\u4EFB\u4F55\u4E00\u904D\u91CC\u90FD\u4E0D\u4F1A\u6F14\u594F",n[f][0].ast.sourceSpan)),g=x}return m}function el(a,e){let t=e?.maxFlowSteps??65536;if(!Number.isSafeInteger(t)||t<=0)throw new w("E_PLAYBACK_FLOW_LIMIT","maxFlowSteps \u5FC5\u987B\u662F\u6B63\u5B89\u5168\u6574\u6570",a.columns[0]?.[0]?.ast.sourceSpan??{start:0,end:0});let n=[],o=[],r=[],s=[],i=new Map,c=new Map,l=0,p=0,u=[{kind:"initial",at:new V,origins:[]}],m=new Map,y=new Map,d={spans:r,notes:s,diagnostics:n,transform(A,F){if(s.lastIndexOf(A)<0)throw new w("E_PLAYBACK_TRANSFORM_TARGET","\u58F0\u97F3\u53D8\u6362\u76EE\u6807\u5FC5\u987B\u5C5E\u4E8E\u5F53\u524D\u8BA1\u5212\u7684\u5DF2\u53D1\u5E03\u97F3\u6BB5",A.sourceSpans?.[0]??{start:0,end:0});let j=i.get(A);i.set(A,j?[...j,F]:[F])}},g=(A,F,j)=>{if(!Number.isFinite(A.toNumber())||A.compare(0)<0)throw new w("E_PLAYBACK_CONTROL_TIME","\u7CFB\u7EDF\u63A7\u5236\u65F6\u523B\u5FC5\u987B\u662F\u975E\u8D1F\u6709\u9650\u503C",F.at(-1).node.ast.sourceSpan);u.push({kind:"control",at:A.clone(),origins:F,apply:j})};function f(A,F,j,z,q,ce=[],ye=A.track){if(!A.playbackState&&!A.emitPlayback)return;let se=[...ce,{node:A}],me=F.length?[...F]:void 0,ge=j.length?[...j]:void 0,De,de,Et;function st(Y){let oe={...Y,start:Y.start.clone(),end:Y.end.clone(),track:ye,origins:se,sourceSpans:[{...A.ast.sourceSpan}]};return r.push(oe),ge&&y.set(oe,ge),oe}let Ue=A.playbackState?.program;Ue!==void 0&&c.get(ye)!==Ue&&(c.set(ye,Ue),o.push({kind:"program-change",at:z.clone(),order:l++,track:ye,program:Ue}));let ln=A.playbackState?.bpm;if(ln!==void 0&&g(z,se,Y=>{Y.bpm=ln}),A.emitPlayback?.({start:z,end:z.clone().add(q),track:ye,span(Y){st(Y)},note(Y){let oe=st(Y);s.push(oe),me&&i.set(oe,me)},extend(Y){if(r.lastIndexOf(Y)<0||!Y.end.equals(z)||q.compare(0)<=0)throw new w("E_PLAYBACK_EXTEND_RANGE","\u6269\u5C55\u5FC5\u987B\u63A5\u7EED\u5F53\u524D\u8BA1\u5212\u5185\u7684\u533A\u95F4\u4E14\u65F6\u503C\u4E3A\u6B63",A.ast.sourceSpan);let oe=Y.end.clone().sub(Y.start),Ae=oe.clone().add(q),Ve=(y.get(Y)??[]).map(fe=>fe.startRatio?{...fe,startRatio:fe.startRatio.clone().mul(oe).div(Ae)}:fe);if(ge)for(let fe of ge)Ve.push({...fe,startRatio:oe.clone().div(Ae)});Ve.length&&y.set(Y,Ve),Y.end.add(q)},emit:Y=>o.push({...Y,at:Y.at.clone(),order:l++}),control:(Y,oe)=>g(Y,se,oe),scaleFollowingBpm(Y,oe,Ae=1,Ve){if(!Number.isSafeInteger(oe)||!Number.isSafeInteger(Ae)||oe<=0||Ae<=0)throw new w("E_PLAYBACK_BPM_SCALE","\u901F\u5EA6\u6BD4\u4F8B\u5FC5\u987B\u662F\u6B63\u6709\u7406\u6570",A.ast.sourceSpan);let fe=new V(oe,Ae),Qa=m.get(Y);if(Qa&&!Qa.equals(fe))throw new w("E_PLAYBACK_BPM_SCALE","\u540C\u4E00\u901F\u5EA6\u6548\u679C key \u5FC5\u987B\u4F7F\u7528\u56FA\u5B9A\u6BD4\u4F8B",A.ast.sourceSpan);m.set(Y,fe),j.push({key:Y,factor:fe,followConnections:Ve?.followConnections??!1,origins:se})},affectFollowing:Y=>F.push(Y),defer:Y=>(Et??=[]).push(Y),play:(Y,oe,Ae)=>f(Y,De??=[...F],de??=[...j],oe??z,Ae??q,se,ye)}),Et)for(let Y of Et)Y(d)}let x=Jc(a,n,t),h=a.columns[x[0]]?.[0]?.t.clone()??new V,b=[{performance:new V,score:h}],S=new V().sub(h),T=new V;for(let A=0;A<x.length;A++){let F=x[A];for(let se of a.columns[F])!se.playbackState&&!se.emitPlayback||f(se,[],[],se.t.clone().add(S),se.T.clone());let j=a.columns[F+1]?.[0]?.t??a.duration;T.copyFrom(j).add(S);let z=x[A+1];if(z===void 0||z===F+1)continue;let q=a.columns[z][0]?.t.clone()??new V;S.add(j).sub(q);let ce={performance:T.clone(),score:q};b[b.length-1].performance.equals(ce.performance)?b[b.length-1]=ce:b.push(ce)}for(let A of r){if(!Number.isFinite(A.start.toNumber())||!Number.isFinite(A.end.toNumber())||A.start.compare(0)<0||A.end.compare(A.start)<=0)throw new w("E_PLAYBACK_NOTE_RANGE","\u97F3\u6BB5\u5FC5\u987B\u5177\u6709\u975E\u8D1F\u8D77\u70B9\u548C\u6B63\u65F6\u503C",A.sourceSpans[0]);A.end.compare(T)>0&&T.copyFrom(A.end),Object.freeze(A.start),Object.freeze(A.end);for(let F of A.origins)Object.freeze(F);for(let F of A.sourceSpans)Object.freeze(F);Object.freeze(A.origins),Object.freeze(A.sourceSpans),Object.freeze(A)}let L,C=new Map,N=new Map,P={notes:s,diagnostics:n,connect(A,F){if(L??=new Set(s),!L.has(A)||!L.has(F)||!A.end.equals(F.start))throw new w("E_PLAYBACK_CONNECTION","\u97F3\u6BB5\u8FDE\u63A5\u5FC5\u987B\u5C5E\u4E8E\u5F53\u524D\u8BA1\u5212\u4E14\u65F6\u95F4\u76F8\u63A5",A.sourceSpans[0]);return C.has(A)&&C.get(A)!==F||N.has(F)&&N.get(F)!==A?!1:(C.set(A,F),N.set(F,A),!0)}};for(let A of a.attachments)Ya(A)&&A.applyPlayback(P);for(let[A,F]of y){let j=A;if(F.some(z=>z.followConnections))for(;C.has(j);)j=C.get(j);for(let z of F){let q=z.startRatio?A.start.clone().add(A.end.clone().sub(A.start).mul(z.startRatio)):A.start;u.push({kind:"scale",at:q,origins:z.origins,scale:z,delta:1},{kind:"scale",at:z.followConnections?j.end:A.end,origins:z.origins,scale:z,delta:-1})}}let k={bpm:He,bpmScale:new V(1)},B=new Map,_=new V(1),v=[];u.sort((A,F)=>A.at.compare(F.at));let R=0,D;for(;R<u.length;){let A=u[R].at,F;for(;R<u.length&&u[R].at.equals(A);){let ce=u[R++];if(F=ce.origins.at(-1)??F,ce.kind==="control")ce.apply(k);else if(ce.kind==="scale"){let{key:ye,factor:se}=ce.scale,me=B.get(ye)??0,ge=me+ce.delta;B.set(ye,ge),me===0&&ge>0?_.mul(se):me>0&&ge===0&&_.div(se)}}let j=k.bpmScale.clone().mul(_),z={bpm:k.bpm,bpmScale:j,effectiveBpm:k.bpm*j.toNumber()};if(!Number.isFinite(z.effectiveBpm)||z.effectiveBpm<=0)throw new w("E_PLAYBACK_BPM","\u7CFB\u7EDF\u63A7\u5236\u4EA7\u751F\u4E86\u65E0\u6548\u901F\u5EA6",F?.node.ast.sourceSpan??{start:0,end:0});let q=v.at(-1)?.state;(!q||q.bpm!==z.bpm||!q.bpmScale.equals(j))&&v.push({at:A.clone(),state:z}),D!==z.effectiveBpm&&(D=z.effectiveBpm,o.push({kind:"tempo",at:A.clone(),bpm:z.effectiveBpm,order:l++}))}let K={diagnostics:n,stateAt(A){let F=0,j=v.length;for(;F<j;){let q=F+j>>>1;v[q].at.compare(A)<=0?F=q+1:j=q}let z=v[Math.max(0,F-1)].state;return{...z,bpmScale:z.bpmScale.clone()}}},X=(A,F)=>!i.has(F)&&A.track===F.track&&A.midi===F.midi&&A.percussion===F.percussion,ne=new Set,J=new Map;for(let A of s){let F=N.get(A);if(F&&X(F,A))continue;let j=A,z=C.get(j),q;for(;z&&X(j,z);)C.delete(j),q??=[...A.sourceSpans],q.push(...z.sourceSpans),j=z,z=C.get(j);j!==A&&(C.delete(j),z&&C.set(A,z));let ce=j.end,ye=q?Object.freeze(q):A.sourceSpans,se=i.get(A),me;if(se){me=[{...A,start:A.start.clone(),end:ce.clone(),sourceSpans:ye}];for(let de of se)me=de(K,me)??me;let De;for(let de of me){if(!Number.isFinite(de.start.toNumber())||!Number.isFinite(de.end.toNumber())||de.start.compare(A.start)<0||de.end.compare(ce)>0||de.end.compare(de.start)<=0)throw new w("E_PLAYBACK_TRANSFORM_RANGE","\u58F0\u97F3\u5C55\u5F00\u5FC5\u987B\u4F4D\u4E8E\u539F\u97F3\u6BB5\u533A\u95F4\u5185\u4E14\u65F6\u503C\u4E3A\u6B63",A.sourceSpans[0]);(!De||de.start.compare(De)<0)&&(De=de.start)}if(!De?.equals(A.start))throw new w("E_PLAYBACK_TRANSFORM_RANGE","\u58F0\u97F3\u5C55\u5F00\u5FC5\u987B\u4FDD\u6301\u539F\u97F3\u6BB5\u7684\u8D77\u70B9",A.sourceSpans[0])}else me=[j===A?A:{...A,end:ce,sourceSpans:ye}];let ge=z!==void 0||F!==void 0?[]:void 0;for(let De of me){let{start:de,end:Et,track:st,midi:Ue,velocity:ln,percussion:Y,sourceSpans:oe}=De,Ae=p++,Ve={kind:"note-on",at:de.clone(),noteId:Ae,order:l++,track:st,midi:Ue,velocity:ln,percussion:Y,sourceSpans:[...oe]},fe={kind:"note-off",at:Et.clone(),noteId:Ae,order:l++,track:st,midi:Ue};ne.add(st),o.push(Ve,fe),ge?.push({on:Ve,off:fe})}ge&&J.set(A,ge)}let H=new Set,G=new Map,$=C.size>1?[...C.keys()].sort((A,F)=>F.start.compare(A.start)):C.keys();for(let A of $){let F=C.get(A);for(let j of J.get(A)){if(!j.off.at.equals(F.start))continue;let z=J.get(F).find(q=>!H.has(q.on)&&q.on.at.equals(F.start)&&q.on.track===j.on.track&&q.on.midi===j.on.midi&&q.on.percussion===j.on.percussion);z&&(j.off.at.copyFrom(z.off.at),G.set(j.on,z.on),H.add(z.on),H.add(z.off))}}for(let A of G.keys())if(!H.has(A))for(let F=G.get(A);F;F=G.get(F))A.sourceSpans.push(...F.sourceSpans);let U=(H.size?o.filter(A=>!H.has(A)):o).sort(Ka),xe=Ua(U,a.tracks,ne),Re=U.at(-1)?.at;return Re&&Re.compare(T)>0&&T.copyFrom(Re),{events:xe.events,scoreMap:b,tracks:xe.tracks,performanceDuration:T,durationSeconds:ao(xe.events,T.toNumber()),diagnostics:n}}var Za=class{commands=[];replay(e){for(let t of this.commands)switch(t.kind){case"text":e.drawText(t.text,t.x,t.y,t.style);break;case"line":e.drawLine(t.x1,t.y1,t.x2,t.y2,t.style);break;case"rect":e.drawRect(t.x,t.y,t.w,t.h,t.style);break;case"circle":e.drawCircle(t.cx,t.cy,t.r,t.style);break;case"path":e.drawPath(t.commands,t.style);break;case"begin-group":e.beginGroup?.(t.group);break;case"end-group":e.endGroup?.();break}}beginGroup(e){this.commands.push({kind:"begin-group",group:e})}endGroup(){this.commands.push({kind:"end-group"})}drawText(e,t,n,o){this.commands.push({kind:"text",text:e,x:t,y:n,style:o})}drawLine(e,t,n,o,r){this.commands.push({kind:"line",x1:e,y1:t,x2:n,y2:o,style:r})}drawRect(e,t,n,o,r){this.commands.push({kind:"rect",x:e,y:t,w:n,h:o,style:r})}drawCircle(e,t,n,o){this.commands.push({kind:"circle",cx:e,cy:t,r:n,style:o})}drawPath(e,t,n){this.commands.push({kind:"path",commands:e.map(o=>tl(o,n)),style:t})}};function tl(a,e){if(!e||a.op==="Z")return{...a};let t=o=>e.x+o*e.scaleX,n=o=>e.y+o*e.scaleY;return a.op==="Q"?{op:"Q",cx:t(a.cx),cy:n(a.cy),x:t(a.x),y:n(a.y)}:a.op==="C"?{op:"C",cx1:t(a.cx1),cy1:n(a.cy1),cx2:t(a.cx2),cy2:n(a.cy2),x:t(a.x),y:n(a.y)}:{op:a.op,x:t(a.x),y:n(a.y)}}function Z(a){return Number.isFinite(a)?String(Math.round(a*1e3)/1e3):"0"}var nl=/[&<>"]/;function ue(a){return nl.test(a)?a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"):a}var ol=ue(gt);function rl(a,e){let t=[],n=e?r=>Z(e.x+r*e.scaleX):Z,o=e?r=>Z(e.y+r*e.scaleY):Z;for(let r of a)switch(r.op){case"M":case"L":t.push(`${r.op}${n(r.x)} ${o(r.y)}`);break;case"Q":t.push(`Q${n(r.cx)} ${o(r.cy)} ${n(r.x)} ${o(r.y)}`);break;case"C":t.push(`C${n(r.cx1)} ${o(r.cy1)} ${n(r.cx2)} ${o(r.cy2)} ${n(r.x)} ${o(r.y)}`);break;case"Z":t.push("Z");break;default:}return t.join(" ")}var so=class{body=[];groupStarts=[];beginGroup(e){this.groupStarts.push(this.body.length),this.body.push(`<g data-kind="${ue(e.kind)}">`)}endGroup(){let e=this.groupStarts.pop();e!==void 0&&(this.body.length===e+1?this.body.pop():this.body.push("</g>"))}drawText(e,t,n,o){let r=o.fontFamily??xt,s=o.fontWeight??"normal",i=o.fill??"#000",c=o.textAlign==="center"?"middle":o.textAlign==="right"?"end":"start";this.body.push(`<text x="${Z(t)}" y="${Z(n)}"`+(r!==gt?` font-family="${ue(r)}"`:"")+` font-size="${Z(o.fontSize)}"`+(s!=="normal"?` font-weight="${ue(String(s))}"`:"")+(c!=="start"?` text-anchor="${c}"`:"")+(o.fontStyle&&o.fontStyle!=="normal"?` font-style="${ue(o.fontStyle)}"`:"")+(i!=="#000"?` fill="${ue(i)}"`:"")+(/\s/.test(e)?' xml:space="preserve"':"")+`>${ue(e)}</text>`)}drawLine(e,t,n,o,r){let s=r?.stroke??r?.fill??"#000",i=r?.strokeWidth??1;this.body.push(`<line x1="${Z(e)}" y1="${Z(t)}" x2="${Z(n)}" y2="${Z(o)}" stroke="${ue(s)}" stroke-width="${Z(i)}" stroke-linecap="round" />`)}drawRect(e,t,n,o,r){let s=r?.fill??"none",i=r?.stroke??"none",c=r?.strokeWidth??1;this.body.push(`<rect x="${Z(e)}" y="${Z(t)}" width="${Z(Math.max(0,n))}" height="${Z(Math.max(0,o))}"`+(s!=="#000"?` fill="${ue(s)}"`:"")+(i!=="none"?` stroke="${ue(i)}" stroke-width="${Z(c)}"`:"")+" />")}drawCircle(e,t,n,o){let r=o?.fill??"#000",s=o?.stroke??"none",i=o?.strokeWidth??1;this.body.push(`<circle cx="${Z(e)}" cy="${Z(t)}" r="${Z(Math.max(0,n))}"`+(r!=="#000"?` fill="${ue(r)}"`:"")+(s!=="none"?` stroke="${ue(s)}" stroke-width="${Z(i)}"`:"")+" />")}drawPath(e,t,n){if(e.length===0)return;let o=rl(e,n),r=t?.fill??"none",s=t?.stroke??"none",i=t?.strokeWidth??1;this.body.push(`<path d="${o}"`+(r!=="#000"?` fill="${ue(r)}"`:"")+(s!=="none"?` stroke="${ue(s)}" stroke-width="${Z(i)}" stroke-linecap="round" stroke-linejoin="round"`:"")+" />")}toSvg(e,t={}){let n=e.x,o=e.y,r=Math.max(1,e.w),s=Math.max(1,e.h),i=t.background?`<rect x="${Z(n)}" y="${Z(o)}" width="${Z(r)}" height="${Z(s)}" fill="${ue(t.background)}" />`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${Z(r)}" height="${Z(s)}" viewBox="${Z(n)} ${Z(o)} ${Z(r)} ${Z(s)}" font-family="${ol}" font-weight="normal" fill="#000">${i}${this.body.join("")}</svg>`}};function al(a,e={}){let t=Je(a),n=t.map(()=>new so);return yt(a,n),n.map((o,r)=>o.toSvg(t[r],e))}function sl(a,e,t=0,n=0,o=1,r=1){a.beginPath();for(let s of e)switch(s.op){case"M":a.moveTo(t+s.x*o,n+s.y*r);break;case"L":a.lineTo(t+s.x*o,n+s.y*r);break;case"Q":a.quadraticCurveTo(t+s.cx*o,n+s.cy*r,t+s.x*o,n+s.y*r);break;case"C":a.bezierCurveTo(t+s.cx1*o,n+s.cy1*r,t+s.cx2*o,n+s.cy2*r,t+s.x*o,n+s.y*r);break;case"Z":a.closePath();break;default:}}function Ke(a){return a==="none"?void 0:a}var io=class{constructor(e){this.context=e}context;drawText(e,t,n,o){let r=Ke(o.fill??"#000");r&&(this.context.fillStyle=r,this.context.font=Pn(o),this.context.textAlign=o.textAlign??"left",this.context.textBaseline="alphabetic",this.context.fillText(e,t,n))}drawLine(e,t,n,o,r){let s=Ke(r?.stroke??r?.fill??"#000");s&&(this.context.beginPath(),this.context.moveTo(e,t),this.context.lineTo(n,o),this.context.strokeStyle=s,this.context.lineWidth=r?.strokeWidth??1,this.context.lineCap="round",this.context.stroke())}drawRect(e,t,n,o,r){if(n<0||o<0)return;let s=Ke(r?.fill);s&&(this.context.fillStyle=s,this.context.fillRect(e,t,n,o));let i=Ke(r?.stroke);i&&(this.context.strokeStyle=i,this.context.lineWidth=r?.strokeWidth??1,this.context.lineJoin="miter",this.context.strokeRect(e,t,n,o))}drawCircle(e,t,n,o){if(n<0)return;this.context.beginPath(),this.context.arc(e,t,n,0,Math.PI*2);let r=Ke(o?.fill??"#000");r&&(this.context.fillStyle=r,this.context.fill());let s=Ke(o?.stroke);s&&(this.context.strokeStyle=s,this.context.lineWidth=o?.strokeWidth??1,this.context.stroke())}drawPath(e,t,n){if(e.length===0)return;sl(this.context,e,n?.x,n?.y,n?.scaleX,n?.scaleY);let o=Ke(t?.fill);o&&(this.context.fillStyle=o,this.context.fill());let r=Ke(t?.stroke);r&&(this.context.strokeStyle=r,this.context.lineWidth=t?.strokeWidth??1,this.context.lineCap="round",this.context.lineJoin="round",this.context.stroke())}};function il(a,e){let t=Je(a);if(e.length!==t.length)throw new Error(`Expected ${t.length} page contexts, got ${e.length}`);for(let[n,o]of e.entries())o.save(),o.translate(-t[n].x,-t[n].y);try{yt(a,e.map(n=>new io(n)))}finally{for(let n of e)n.restore()}}var cl=globalThis;Object.assign(cl.jpfun??={},qa);})();
135
+ )`}},oo=class extends H{braceSpace;preparedName=null;constructor(e,t){super(),this.ast=e,this.braceSpace=t,this.mergeKey=-2,(e.name||t>0||e.lyrics.some(n=>n.name))&&this.initLayoutBox()}prepareLayout(e){this.preparedName=this.ast.name?ve(this.ast.name,no(this.ast.size,this.ast.font),e.textMeasurer):null;let t=this.preparedName?.w??0,n=pn(this.ast.size,this.ast.font);for(let r of this.ast.lyrics)r.name&&(t=Math.max(t,ve(r.name,n,e.textMeasurer).w));let o=this.braceSpace>0?this.braceSpace:t>0?this.ast.size*hl:0;this.box.w=t+o,this.box.h=this.preparedName?.h??0,this.box.anchor=t,this.box.visualAxis=this.box.h/2,this.springConfig.alpha_R=.45}paint(e){this.preparedName&&Ie(e,this.preparedName,this.box.x+this.box.anchor,this.box.y+this.preparedName.baseline)}},ka=Ve;var ro=[vr,Vo,Or,kn,En,Go,ga,la,ka,Aa,en,Yr,$r,Cr,qr,Hr,Gr,wo,Ko,nr,fa,Mo,Jo,$o,Oo,ma,Er,po,ra,qt,ht,Qt,Xr,Jt,na];function Na(a,e={}){let t=new Map,n=new Set(a);for(let o of n){let r=o.layoutDecorationHandler;if(!r)continue;let s=o.def?.name;if(!s)continue;let i=Array.isArray(s)?s[0]:s;t.set(Xe(i),r)}return{textMeasurer:e.textMeasurer??ar,decorationHandlers:t}}function xl(a,e){if(a)return a==="content"?void 0:a;if(ur.test(e))return"boolean";if(e.startsWith('"'))return"string";if(!isNaN(Number(e)))return"number";if(!(Ut(e)instanceof M))return"length"}function bi(a,e){let{source:t,functions:n}=a,o=[],r=[],s=(c,l)=>{l&&l.start<l.end&&o.push({kind:c,span:l})},i=(c,l)=>{if(c.kind==="brace"){s("punctuation",{start:c.span.start,end:c.span.start+1});let h=Math.min(t.length,c.span.end-1);return new re(l).parseGrammar(c.span.start+1,h,i),t[h]==="}"&&s("punctuation",{start:h,end:h+1}),!0}if(c.kind==="label")return s("label",c.span),!0;if(c.kind==="sugar"||c.typed){if(Array.isArray(c.syntaxKind))for(let h of c.syntaxKind)s(h.kind,h.span);else s(c.syntaxKind??"operator",c.span);return!0}let{kind:p,typed:u,syntaxKind:m,...f}=c;r.push(f),s("function",f.nameSpan),s("punctuation",f.openParenSpan);let d=n.get(f.name.toLowerCase())?.def;for(let h=0;h<f.args.length;h++){let y=f.args[h];s("property",y.nameSpan),s("punctuation",y.equalsSpan);let g=d&&Ze(d,nt(t,y),h);if(g==="content")new re(l).parseGrammar(y.valueSpan.start,y.valueSpan.end,i);else{let x=xl(g,t.slice(y.valueSpan.start,y.valueSpan.end));x&&s(x,y.valueSpan)}s("punctuation",y.commaSpan)}return s("punctuation",f.closeParenSpan),!0};return a.parseGrammar(0,t.length,i),{tokens:gl(o,e),calls:r}}function gl(a,e){if(e.length===0)return a;let t=[],n=0;for(let o of a){let{kind:r,span:s}=o,i=s.start;for(;n<e.length&&e[n].start<s.end;n++){let c=e[n];i<c.start&&t.push({kind:r,span:{start:i,end:c.start}}),t.push({kind:"comment",span:c}),i=Math.max(i,c.end)}i<s.end&&t.push(i===s.start?o:{kind:r,span:{start:i,end:s.end}})}for(;n<e.length;n++)t.push({kind:"comment",span:e[n]});return t}function bl(a,e={}){let{functions:t=ro,textMeasurer:n,variables:o,...r}=e,{maskedSource:s,lineStarts:i}=wt(a),c=new re({source:s,variables:o});c.registerFunctions(t);let l=new se({start:0,end:a.length},c.parse()),u=new on().lowerDocument(l,c.diagnostics),m=Na(t,{textMeasurer:n}),f=fo(u,m,r);return{lineStarts:i,maskedSource:s,diagnostics:c.diagnostics,ast:l,lowering:u,layout:f}}function Sl(a,e=ro){let{maskedSource:t,commentSpans:n}=wt(a),o=new re({source:t});return o.registerFunctions(e),{syntax:bi(o,n),diagnostics:o.diagnostics}}function va(a){return typeof a.applyPlayback=="function"}var Si=new WeakMap;function Ti(a){let e=Si.get(a);if(e)return e;let t=[{performance:0,seconds:0,bpm:Me}],n=0,o=0,r=Me;for(let s of a){if(s.kind!=="tempo")continue;let i=s.at.toNumber();i>o&&(n+=(i-o)*60/r,o=i),r=s.bpm;let c=t[t.length-1];c.performance===o?c.bpm=r:t.push({performance:o,seconds:n,bpm:r})}return Si.set(a,t),t}function Pa(a,e,t){let n=0,o=a.length;for(;n<o;){let r=n+o>>>1;t(a[r])<=e?n=r+1:o=r}return a[Math.max(0,n-1)]}function ao(a,e){let t=Math.max(0,e),n=Pa(Ti(a),t,o=>o.performance);return n.seconds+(t-n.performance)*60/n.bpm}function wi(a,e){let t=Math.max(0,e),n=Pa(Ti(a),t,o=>o.seconds);return n.performance+(t-n.seconds)*n.bpm/60}function Li(a,e){let t=Math.max(0,e),n=Pa(a,t,o=>o.performance.toNumber());return n&&n.performance.toNumber()<=t?n.score.toNumber()+t-n.performance.toNumber():t}function Ci(a,e){let t=Math.max(0,e),n;for(let o=0;o<a.length;o++){let r=a[o],s=r.score.toNumber();if(s>t){(!n||s<n.score.toNumber())&&(n=r);continue}let i=a[o+1],c=i?i.performance.toNumber()-r.performance.toNumber():1/0;if(!(t-s>=c))return r.performance.toNumber()+(t-s)}return n?.performance.toNumber()??t}function Tl(a,e){let t=Math.min(wi(a.events,e),a.performanceDuration.toNumber());return Li(a.scoreMap,t)}function wl(a,e){let t=Math.min(Ci(a.scoreMap,e),a.performanceDuration.toNumber());return ao(a.events,t)}var Ai={tempo:0,"time-signature":1,"program-change":2,"note-off":3,"note-on":4};function ki(a,e){return a.at.compare(e.at)||Ai[a.kind]-Ai[e.kind]}function Ni(a,e,t){let n=new Map;for(let r of e)t.has(r)&&n.set(r,n.size);for(let r of t)n.has(r)||n.set(r,n.size);let o=[];for(let r of a){if(r.kind==="tempo"){o.push({kind:"tempo",at:r.at,bpm:r.bpm});continue}if(r.kind==="time-signature"){o.push({kind:"time-signature",at:r.at,numerator:r.numerator,denominator:r.denominator});continue}let s=n.get(r.track);if(s!==void 0){if(r.kind==="program-change"){o.push({kind:"program-change",at:r.at,track:s,program:r.program});continue}if(r.kind==="note-on"){o.push({kind:"note-on",at:r.at,noteId:r.noteId,track:s,midi:r.midi,velocity:r.velocity,...r.percussion?{percussion:!0}:{},sourceSpans:r.sourceSpans});continue}o.push({kind:"note-off",at:r.at,noteId:r.noteId,track:s,midi:r.midi})}}return{events:o,tracks:[...n.keys()]}}function Ll(a,e,t){let n=a.columns,o,r=(y,g)=>{if(!o){o=new Map;for(let x=0;x<n.length;x++)for(let b of n[x])o.set(b,x)}for(let x=y;x;x=x.foldedInto){let b=o.get(x);if(b===void 0)continue;if(g!=="end"||x.T.compare(0)<=0)return b;let S=x.t.clone().add(x.T),T=b;for(;T+1<n.length&&n[T+1].t.compare(S)<0;)T++;return T}},s=new Map,i=new Map,c=(y,g)=>{let x=y.playbackFlow?.(r);if(!x)return;let[b,S]=x.range??[0,n.length-1];if(x.range&&(!Number.isSafeInteger(b)||!Number.isSafeInteger(S)||b<0||S<b||S>=n.length))throw new w("E_PLAYBACK_FLOW_RANGE","\u64AD\u653E\u63A7\u5236\u6D41\u8303\u56F4 [{from}, {to}] \u8D85\u51FA\u65F6\u95F4\u5217\u8FB9\u754C",g,{from:b,to:S});let T={hook:x,sourceSpan:g};for(let L=b;L<=S;L++){let C=i.get(L);C?C.push(T):i.set(L,[T])}};for(let y of a.astToTemporal.values())for(let g of y){c(g,g.ast.sourceSpan);let x=g.playbackMarks?.();if(!x?.length)continue;let b=r(g);if(b!==void 0)for(let S of x){let T=s.get(S);T?T.push(b):s.set(S,[b])}}for(let y of a.attachments)c(y,y.sourceSpan??{start:0,end:0});if(i.size===0)return n.map((y,g)=>g);for(let y of s.values())y.sort((g,x)=>g-x);let l=new Array(n.length).fill(0),p=0,u={get column(){return p},visits:y=>l[y]??0,seek(y,g,x){let b=s.get(y);if(b){if(x>0)return b.find(S=>S>g);for(let S=b.length-1;S>=0;S--)if(b[S]<g)return b[S]}}},m=[],f=0;for(;p<n.length;){if(++f>t)throw new w("E_PLAYBACK_FLOW_LIMIT","\u64AD\u653E\u63A7\u5236\u6D41\u8BBF\u95EE\u8D85\u8FC7 {maxFlowSteps} \u6B65\uFF1B\u53EF\u901A\u8FC7 maxFlowSteps \u63D0\u9AD8\u5C55\u5F00\u9884\u7B97",n[p][0].ast.sourceSpan,{maxFlowSteps:t});l[p]++;let y;for(let g of i.get(p)??[]){let b=g.hook.run(u);if(b){if(b.kind==="stop")return m;if(!Number.isSafeInteger(b.column)||b.column<0||b.column>n.length)throw new w("E_PLAYBACK_FLOW_JUMP","\u64AD\u653E\u63A7\u5236\u6D41\u8DF3\u8F6C\u76EE\u6807 {column} \u8D85\u51FA\u65F6\u95F4\u5217\u8FB9\u754C",g.sourceSpan,{column:b.column});y=Math.min(y??1/0,b.column)}}y!==void 0?p=y:(m.push(p),p++)}let d=new Set(m),h=!1;for(let y=0;y<n.length;y++){let g=!d.has(y)&&n[y].some(x=>!x.T.isZero());g&&!h&&e.push(new O("W_PLAYBACK_COLUMN_NEVER_PLAYED","\u8FD9\u91CC\u5728\u4EFB\u4F55\u4E00\u904D\u91CC\u90FD\u4E0D\u4F1A\u6F14\u594F",n[y][0].ast.sourceSpan)),h=g}return m}function Cl(a,e){let t=e?.maxFlowSteps??65536;if(!Number.isSafeInteger(t)||t<=0)throw new w("E_PLAYBACK_FLOW_LIMIT","maxFlowSteps \u5FC5\u987B\u662F\u6B63\u5B89\u5168\u6574\u6570",a.columns[0]?.[0]?.ast.sourceSpan??{start:0,end:0});let n=[],o=[],r=[],s=[],i=new Map,c=new Map,l,p=k=>{l?.numerator===k.numerator&&l.denominator===k.denominator||o.push(l={...k,at:k.at.clone()})},u=0,m=[{kind:"initial",at:new I,origins:[]}],f=new Map,d=new Map,h={spans:r,notes:s,diagnostics:n,transform(k,R){if(s.lastIndexOf(k)<0)throw new w("E_PLAYBACK_TRANSFORM_TARGET","\u58F0\u97F3\u53D8\u6362\u76EE\u6807\u5FC5\u987B\u5C5E\u4E8E\u5F53\u524D\u8BA1\u5212\u7684\u5DF2\u53D1\u5E03\u97F3\u6BB5",k.sourceSpans?.[0]??{start:0,end:0});let V=i.get(k);i.set(k,V?[...V,R]:[R])}},y=(k,R,V)=>{if(!Number.isFinite(k.toNumber())||k.compare(0)<0)throw new w("E_PLAYBACK_CONTROL_TIME","\u7CFB\u7EDF\u63A7\u5236\u65F6\u523B\u5FC5\u987B\u662F\u975E\u8D1F\u6709\u9650\u503C",R.at(-1).node.ast.sourceSpan);m.push({kind:"control",at:k.clone(),origins:R,apply:V})};function g(k,R,V,D,Z,le=[],me=k.track){if(!k.playbackState&&!k.emitPlayback)return;let xe=[...le,{node:k}],ae=R.length?[...R]:void 0,ge=V.length?[...V]:void 0,de,he,_t;function ct(X){let oe={...X,start:X.start.clone(),end:X.end.clone(),track:me,origins:xe,sourceSpans:[{...k.ast.sourceSpan}]};return r.push(oe),ge&&d.set(oe,ge),oe}let Ke=k.playbackState?.program;if(Ke!==void 0&&c.get(me)!==Ke&&(c.set(me,Ke),o.push({kind:"program-change",at:D.clone(),track:me,program:Ke})),k.emitPlayback?.({start:D,end:D.clone().add(Z),track:me,span(X){ct(X)},note(X){let oe=ct(X);s.push(oe),ae&&i.set(oe,ae)},extend(X){if(r.lastIndexOf(X)<0||!X.end.equals(D)||Z.compare(0)<=0)throw new w("E_PLAYBACK_EXTEND_RANGE","\u6269\u5C55\u5FC5\u987B\u63A5\u7EED\u5F53\u524D\u8BA1\u5212\u5185\u7684\u533A\u95F4\u4E14\u65F6\u503C\u4E3A\u6B63",k.ast.sourceSpan);let oe=X.end.clone().sub(X.start),Ee=oe.clone().add(Z),He=(d.get(X)??[]).map(be=>be.startRatio?{...be,startRatio:be.startRatio.clone().mul(oe).div(Ee)}:be);if(ge)for(let be of ge)He.push({...be,startRatio:oe.clone().div(Ee)});He.length&&d.set(X,He),X.end.add(Z)},emit:p,control:(X,oe)=>y(X,xe,oe),scaleFollowingBpm(X,oe,Ee=1,He){if(!Number.isSafeInteger(oe)||!Number.isSafeInteger(Ee)||oe<=0||Ee<=0)throw new w("E_PLAYBACK_BPM_SCALE","\u901F\u5EA6\u6BD4\u4F8B\u5FC5\u987B\u662F\u6B63\u6709\u7406\u6570",k.ast.sourceSpan);let be=new I(oe,Ee),Rt=f.get(X);if(Rt&&!Rt.equals(be))throw new w("E_PLAYBACK_BPM_SCALE","\u540C\u4E00\u901F\u5EA6\u6548\u679C key \u5FC5\u987B\u4F7F\u7528\u56FA\u5B9A\u6BD4\u4F8B",k.ast.sourceSpan);f.set(X,be),V.push({key:X,factor:be,followConnections:He?.followConnections??!1,origins:xe})},affectFollowing:X=>R.push(X),defer:X=>(_t??=[]).push(X),play:(X,oe,Ee)=>g(X,de??=[...R],he??=[...V],oe??D,Ee??Z,xe,me)}),_t)for(let X of _t)X(h)}let x=Ll(a,n,t),b=a.columns[x[0]]?.t.clone()??new I,S=[{performance:new I,score:b}],T=new I().sub(b),L=new I;for(let k=0;k<x.length;k++){let R=x[k],V=a.columns[R];for(let de of V)!de.playbackState&&!de.emitPlayback||g(de,[],[],V.t.clone().add(T),de.T.clone());let D=a.columns[R+1]?.t??a.duration;L.copyFrom(D).add(T);let Z=x[k+1];if(Z===void 0||Z===R+1)continue;let le=a.columns[Z],me=le.t.clone();T.add(D).sub(me),y(L,[{node:le[0]}],de=>{de.bpm=le.bpm});let{timeSignature:xe}=le;xe&&p({kind:"time-signature",at:L,...xe});let ae={performance:L.clone(),score:me};S[S.length-1].performance.equals(ae.performance)?S[S.length-1]=ae:S.push(ae)}for(let k of r){if(!Number.isFinite(k.start.toNumber())||!Number.isFinite(k.end.toNumber())||k.start.compare(0)<0||k.end.compare(k.start)<=0)throw new w("E_PLAYBACK_NOTE_RANGE","\u97F3\u6BB5\u5FC5\u987B\u5177\u6709\u975E\u8D1F\u8D77\u70B9\u548C\u6B63\u65F6\u503C",k.sourceSpans[0]);k.end.compare(L)>0&&L.copyFrom(k.end),Object.freeze(k.start),Object.freeze(k.end);for(let R of k.origins)Object.freeze(R);for(let R of k.sourceSpans)Object.freeze(R);Object.freeze(k.origins),Object.freeze(k.sourceSpans),Object.freeze(k)}let C,A=new Map,v=new Map,N={notes:s,diagnostics:n,connect(k,R){if(C??=new Set(s),!C.has(k)||!C.has(R)||!k.end.equals(R.start))throw new w("E_PLAYBACK_CONNECTION","\u97F3\u6BB5\u8FDE\u63A5\u5FC5\u987B\u5C5E\u4E8E\u5F53\u524D\u8BA1\u5212\u4E14\u65F6\u95F4\u76F8\u63A5",k.sourceSpans[0]);return A.has(k)&&A.get(k)!==R||v.has(R)&&v.get(R)!==k?!1:(A.set(k,R),v.set(R,k),!0)}};for(let k of a.attachments)va(k)&&k.applyPlayback(N);for(let[k,R]of d){let V=k;if(R.some(D=>D.followConnections))for(;A.has(V);)V=A.get(V);for(let D of R){let Z=D.startRatio?k.start.clone().add(k.end.clone().sub(k.start).mul(D.startRatio)):k.start;m.push({kind:"scale",at:Z,origins:D.origins,scale:D,delta:1},{kind:"scale",at:D.followConnections?V.end:k.end,origins:D.origins,scale:D,delta:-1})}}let F={bpm:a.columns[x[0]]?.bpm??Me,bpmScale:new I(1)},B=new Map,$=new I(1),U=[];m.sort((k,R)=>k.at.compare(R.at));let E=0,G;for(;E<m.length;){let k=m[E].at,R;for(;E<m.length&&m[E].at.equals(k);){let le=m[E++];if(R=le.origins.at(-1)??R,le.kind==="control")le.apply(F);else if(le.kind==="scale"){let{key:me,factor:xe}=le.scale,ae=B.get(me)??0,ge=ae+le.delta;B.set(me,ge),ae===0&&ge>0?$.mul(xe):ae>0&&ge===0&&$.div(xe)}}let V=F.bpmScale.clone().mul($),D={bpm:F.bpm,bpmScale:V,effectiveBpm:F.bpm*V.toNumber()};if(!Number.isFinite(D.effectiveBpm)||D.effectiveBpm<=0)throw new w("E_PLAYBACK_BPM","\u7CFB\u7EDF\u63A7\u5236\u4EA7\u751F\u4E86\u65E0\u6548\u901F\u5EA6",R?.node.ast.sourceSpan??{start:0,end:0});let Z=U.at(-1)?.state;(!Z||Z.bpm!==D.bpm||!Z.bpmScale.equals(V))&&U.push({at:k.clone(),state:D}),G!==D.effectiveBpm&&(G=D.effectiveBpm,o.push({kind:"tempo",at:k.clone(),bpm:D.effectiveBpm}))}let K={diagnostics:n,stateAt(k){let R=0,V=U.length;for(;R<V;){let Z=R+V>>>1;U[Z].at.compare(k)<=0?R=Z+1:V=Z}let D=U[Math.max(0,R-1)].state;return{...D,bpmScale:D.bpmScale.clone()}}},ne=(k,R)=>!i.has(R)&&k.track===R.track&&k.midi===R.midi&&k.percussion===R.percussion,J=new Set,z=new Map;for(let k of s){let R=v.get(k);if(R&&ne(R,k))continue;let V=k,D=A.get(V),Z;for(;D&&ne(V,D);)A.delete(V),Z??=[...k.sourceSpans],Z.push(...D.sourceSpans),V=D,D=A.get(V);V!==k&&(A.delete(V),D&&A.set(k,D));let le=V.end,me=Z?Object.freeze(Z):k.sourceSpans,xe=i.get(k),ae;if(xe){ae=[{...k,start:k.start.clone(),end:le.clone(),sourceSpans:me}];for(let he of xe)ae=he(K,ae)??ae;let de;for(let he of ae){if(!Number.isFinite(he.start.toNumber())||!Number.isFinite(he.end.toNumber())||he.start.compare(k.start)<0||he.end.compare(le)>0||he.end.compare(he.start)<=0)throw new w("E_PLAYBACK_TRANSFORM_RANGE","\u58F0\u97F3\u5C55\u5F00\u5FC5\u987B\u4F4D\u4E8E\u539F\u97F3\u6BB5\u533A\u95F4\u5185\u4E14\u65F6\u503C\u4E3A\u6B63",k.sourceSpans[0]);(!de||he.start.compare(de)<0)&&(de=he.start)}if(!de?.equals(k.start))throw new w("E_PLAYBACK_TRANSFORM_RANGE","\u58F0\u97F3\u5C55\u5F00\u5FC5\u987B\u4FDD\u6301\u539F\u97F3\u6BB5\u7684\u8D77\u70B9",k.sourceSpans[0])}else ae=[V===k?k:{...k,end:le,sourceSpans:me}];let ge=D!==void 0||R!==void 0?[]:void 0;for(let de of ae){let{start:he,end:_t,track:ct,midi:Ke,velocity:X,percussion:oe,sourceSpans:Ee}=de,He=u++,be={kind:"note-on",at:he.clone(),noteId:He,track:ct,midi:Ke,velocity:X,percussion:oe,sourceSpans:[...Ee]},Rt={kind:"note-off",at:_t.clone(),noteId:He,track:ct,midi:Ke};J.add(ct),o.push(be,Rt),ge?.push({on:be,off:Rt})}ge&&z.set(k,ge)}let W=new Set,j=new Map,q=A.size>1?[...A.keys()].sort((k,R)=>R.start.compare(k.start)):A.keys();for(let k of q){let R=A.get(k);for(let V of z.get(k)){if(!V.off.at.equals(R.start))continue;let D=z.get(R).find(Z=>!W.has(Z.on)&&Z.on.at.equals(R.start)&&Z.on.track===V.on.track&&Z.on.midi===V.on.midi&&Z.on.percussion===V.on.percussion);D&&(V.off.at.copyFrom(D.off.at),j.set(V.on,D.on),W.add(D.on),W.add(D.off))}}for(let k of j.keys())if(!W.has(k))for(let R=j.get(k);R;R=j.get(R))k.sourceSpans.push(...R.sourceSpans);let Te=(W.size?o.filter(k=>!W.has(k)):o).sort(ki),fe=Ni(Te,a.tracks,J),ce=Te.at(-1)?.at;return ce&&ce.compare(L)>0&&L.copyFrom(ce),{events:fe.events,scoreMap:S,tracks:fe.tracks,performanceDuration:L,durationSeconds:ao(fe.events,L.toNumber()),diagnostics:n}}var Ea=class{commands=[];replay(e){for(let t of this.commands)switch(t.kind){case"text":e.drawText(t.text,t.x,t.y,t.style);break;case"line":e.drawLine(t.x1,t.y1,t.x2,t.y2,t.style);break;case"rect":e.drawRect(t.x,t.y,t.w,t.h,t.style);break;case"circle":e.drawCircle(t.cx,t.cy,t.r,t.style);break;case"path":e.drawPath(t.commands,t.style);break;case"begin-group":e.beginGroup?.(t.group);break;case"end-group":e.endGroup?.();break}}beginGroup(e){this.commands.push({kind:"begin-group",group:e})}endGroup(){this.commands.push({kind:"end-group"})}drawText(e,t,n,o){this.commands.push({kind:"text",text:e,x:t,y:n,style:o})}drawLine(e,t,n,o,r){this.commands.push({kind:"line",x1:e,y1:t,x2:n,y2:o,style:r})}drawRect(e,t,n,o,r){this.commands.push({kind:"rect",x:e,y:t,w:n,h:o,style:r})}drawCircle(e,t,n,o){this.commands.push({kind:"circle",cx:e,cy:t,r:n,style:o})}drawPath(e,t,n){this.commands.push({kind:"path",commands:e.map(o=>Al(o,n)),style:t})}};function Al(a,e){if(!e||a.op==="Z")return{...a};let t=o=>e.x+o*e.scaleX,n=o=>e.y+o*e.scaleY;return a.op==="Q"?{op:"Q",cx:t(a.cx),cy:n(a.cy),x:t(a.x),y:n(a.y)}:a.op==="C"?{op:"C",cx1:t(a.cx1),cy1:n(a.cy1),cx2:t(a.cx2),cy2:n(a.cy2),x:t(a.x),y:n(a.y)}:{op:a.op,x:t(a.x),y:n(a.y)}}function Y(a){return Number.isFinite(a)?String(Math.round(a*1e3)/1e3):"0"}var kl=/[&<>"]/;function ye(a){return kl.test(a)?a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"):a}var Nl=ye(St);function vl(a,e){let t=[],n=e?r=>Y(e.x+r*e.scaleX):Y,o=e?r=>Y(e.y+r*e.scaleY):Y;for(let r of a)switch(r.op){case"M":case"L":t.push(`${r.op}${n(r.x)} ${o(r.y)}`);break;case"Q":t.push(`Q${n(r.cx)} ${o(r.cy)} ${n(r.x)} ${o(r.y)}`);break;case"C":t.push(`C${n(r.cx1)} ${o(r.cy1)} ${n(r.cx2)} ${o(r.cy2)} ${n(r.x)} ${o(r.y)}`);break;case"Z":t.push("Z");break;default:}return t.join(" ")}var so=class{body=[];groupStarts=[];beginGroup(e){this.groupStarts.push(this.body.length),this.body.push(`<g data-kind="${ye(e.kind)}">`)}endGroup(){let e=this.groupStarts.pop();e!==void 0&&(this.body.length===e+1?this.body.pop():this.body.push("</g>"))}drawText(e,t,n,o){let r=o.fontFamily??bt,s=o.fontWeight??"normal",i=o.fill??"#000",c=o.textAlign==="center"?"middle":o.textAlign==="right"?"end":"start";this.body.push(`<text x="${Y(t)}" y="${Y(n)}"`+(r!==St?` font-family="${ye(r)}"`:"")+` font-size="${Y(o.fontSize)}"`+(s!=="normal"?` font-weight="${ye(String(s))}"`:"")+(c!=="start"?` text-anchor="${c}"`:"")+(o.fontStyle&&o.fontStyle!=="normal"?` font-style="${ye(o.fontStyle)}"`:"")+(i!=="#000"?` fill="${ye(i)}"`:"")+(/\s/.test(e)?' xml:space="preserve"':"")+`>${ye(e)}</text>`)}drawLine(e,t,n,o,r){let s=r?.stroke??r?.fill??"#000",i=r?.strokeWidth??1;this.body.push(`<line x1="${Y(e)}" y1="${Y(t)}" x2="${Y(n)}" y2="${Y(o)}" stroke="${ye(s)}" stroke-width="${Y(i)}" stroke-linecap="round" />`)}drawRect(e,t,n,o,r){let s=r?.fill??"none",i=r?.stroke??"none",c=r?.strokeWidth??1;this.body.push(`<rect x="${Y(e)}" y="${Y(t)}" width="${Y(Math.max(0,n))}" height="${Y(Math.max(0,o))}"`+(s!=="#000"?` fill="${ye(s)}"`:"")+(i!=="none"?` stroke="${ye(i)}" stroke-width="${Y(c)}"`:"")+" />")}drawCircle(e,t,n,o){let r=o?.fill??"#000",s=o?.stroke??"none",i=o?.strokeWidth??1;this.body.push(`<circle cx="${Y(e)}" cy="${Y(t)}" r="${Y(Math.max(0,n))}"`+(r!=="#000"?` fill="${ye(r)}"`:"")+(s!=="none"?` stroke="${ye(s)}" stroke-width="${Y(i)}"`:"")+" />")}drawPath(e,t,n){if(e.length===0)return;let o=vl(e,n),r=t?.fill??"none",s=t?.stroke??"none",i=t?.strokeWidth??1;this.body.push(`<path d="${o}"`+(r!=="#000"?` fill="${ye(r)}"`:"")+(s!=="none"?` stroke="${ye(s)}" stroke-width="${Y(i)}" stroke-linecap="round" stroke-linejoin="round"`:"")+" />")}toSvg(e,t={}){let n=e.x,o=e.y,r=Math.max(1,e.w),s=Math.max(1,e.h),i=t.background?`<rect x="${Y(n)}" y="${Y(o)}" width="${Y(r)}" height="${Y(s)}" fill="${ye(t.background)}" />`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${Y(r)}" height="${Y(s)}" viewBox="${Y(n)} ${Y(o)} ${Y(r)} ${Y(s)}" font-family="${Nl}" font-weight="normal" fill="#000">${i}${this.body.join("")}</svg>`}};function Pl(a,e={}){let t=Je(a),n=t.map(()=>new so);return ft(a,n),n.map((o,r)=>o.toSvg(t[r],e))}function El(a,e,t=0,n=0,o=1,r=1){a.beginPath();for(let s of e)switch(s.op){case"M":a.moveTo(t+s.x*o,n+s.y*r);break;case"L":a.lineTo(t+s.x*o,n+s.y*r);break;case"Q":a.quadraticCurveTo(t+s.cx*o,n+s.cy*r,t+s.x*o,n+s.y*r);break;case"C":a.bezierCurveTo(t+s.cx1*o,n+s.cy1*r,t+s.cx2*o,n+s.cy2*r,t+s.x*o,n+s.y*r);break;case"Z":a.closePath();break;default:}}function Ye(a){return a==="none"?void 0:a}var io=class{constructor(e){this.context=e}context;drawText(e,t,n,o){let r=Ye(o.fill??"#000");r&&(this.context.fillStyle=r,this.context.font=Bn(o),this.context.textAlign=o.textAlign??"left",this.context.textBaseline="alphabetic",this.context.fillText(e,t,n))}drawLine(e,t,n,o,r){let s=Ye(r?.stroke??r?.fill??"#000");s&&(this.context.beginPath(),this.context.moveTo(e,t),this.context.lineTo(n,o),this.context.strokeStyle=s,this.context.lineWidth=r?.strokeWidth??1,this.context.lineCap="round",this.context.stroke())}drawRect(e,t,n,o,r){if(n<0||o<0)return;let s=Ye(r?.fill);s&&(this.context.fillStyle=s,this.context.fillRect(e,t,n,o));let i=Ye(r?.stroke);i&&(this.context.strokeStyle=i,this.context.lineWidth=r?.strokeWidth??1,this.context.lineJoin="miter",this.context.strokeRect(e,t,n,o))}drawCircle(e,t,n,o){if(n<0)return;this.context.beginPath(),this.context.arc(e,t,n,0,Math.PI*2);let r=Ye(o?.fill??"#000");r&&(this.context.fillStyle=r,this.context.fill());let s=Ye(o?.stroke);s&&(this.context.strokeStyle=s,this.context.lineWidth=o?.strokeWidth??1,this.context.stroke())}drawPath(e,t,n){if(e.length===0)return;El(this.context,e,n?.x,n?.y,n?.scaleX,n?.scaleY);let o=Ye(t?.fill);o&&(this.context.fillStyle=o,this.context.fill());let r=Ye(t?.stroke);r&&(this.context.strokeStyle=r,this.context.lineWidth=t?.strokeWidth??1,this.context.lineCap="round",this.context.lineJoin="round",this.context.stroke())}};function _l(a,e){let t=Je(a);if(e.length!==t.length)throw new Error(`Expected ${t.length} page contexts, got ${e.length}`);for(let[n,o]of e.entries())o.save(),o.translate(-t[n].x,-t[n].y);try{ft(a,e.map(n=>new io(n)))}finally{for(let n of e)n.restore()}}var Rl=globalThis;Object.assign(Rl.jpfun??={},_a);})();