jpfun 0.8.0 → 1.0.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.
- package/README.md +10 -15
- package/dist/diagnostic.d.ts +29 -2
- package/dist/diagnostic.js +5 -4
- package/dist/functions/ASTtypes.d.ts +1 -14
- package/dist/functions/ASTtypes.js +5 -36
- package/dist/functions/adjust/index.js +45 -33
- package/dist/functions/arpeggio/index.js +44 -48
- package/dist/functions/arpeggio/shape.d.ts +2 -3
- package/dist/functions/arpeggio/shape.js +20 -50
- package/dist/functions/bar/index.d.ts +3 -0
- package/dist/functions/bar/index.js +21 -11
- package/dist/functions/beam/auto.js +54 -123
- package/dist/functions/beam/index.js +4 -9
- package/dist/functions/beam/layout.js +3 -2
- package/dist/functions/box/index.js +1 -6
- package/dist/functions/dash/index.js +6 -4
- package/dist/functions/div/index.d.ts +3 -5
- package/dist/functions/div/index.js +14 -12
- package/dist/functions/dot/index.js +3 -9
- package/dist/functions/dyn/index.js +7 -26
- package/dist/functions/gliss/index.js +99 -91
- package/dist/functions/grace/index.d.ts +2 -5
- package/dist/functions/grace/index.js +47 -94
- package/dist/functions/head/index.js +32 -36
- package/dist/functions/key/index.js +9 -12
- package/dist/functions/meter/index.d.ts +1 -0
- package/dist/functions/meter/index.js +6 -3
- package/dist/functions/meter/shape.d.ts +1 -1
- package/dist/functions/note/accidentals.d.ts +3 -3
- package/dist/functions/note/accidentals.js +29 -16
- package/dist/functions/note/index.js +12 -14
- package/dist/functions/note/source-transform.d.ts +15 -0
- package/dist/functions/note/source-transform.js +75 -71
- package/dist/functions/ottava/index.js +12 -32
- package/dist/functions/page/index.js +15 -17
- package/dist/functions/rest/index.js +10 -10
- package/dist/functions/slide/index.js +1 -1
- package/dist/functions/stack/index.js +8 -57
- package/dist/functions/temporal.d.ts +11 -5
- package/dist/functions/temporal.js +22 -2
- package/dist/functions/text/index.js +24 -30
- package/dist/functions/tie/index.js +42 -41
- package/dist/functions/tremolo/index.js +1 -1
- package/dist/functions/tuplet/index.js +1 -6
- package/dist/functions/up/index.js +82 -88
- package/dist/functions/voice/connections.d.ts +3 -2
- package/dist/functions/voice/connections.js +48 -10
- package/dist/functions/voice/index.d.ts +2 -3
- package/dist/functions/voice/index.js +2 -970
- package/dist/functions/voice/lyrics.d.ts +34 -0
- package/dist/functions/voice/lyrics.js +393 -0
- package/dist/functions/voice/voice.d.ts +67 -0
- package/dist/functions/voice/voice.js +405 -0
- package/dist/functions/voice/voices.d.ts +106 -0
- package/dist/functions/voice/voices.js +424 -0
- package/dist/functions/volta/index.js +6 -23
- package/dist/index.d.ts +97 -3
- package/dist/index.js +97 -3
- package/dist/jpfun.min.js +63 -67
- package/dist/layout/engine.d.ts +4 -3
- package/dist/layout/engine.js +190 -24
- package/dist/layout/model.d.ts +12 -4
- package/dist/layout/model.js +16 -11
- package/dist/layout/page.d.ts +2 -1
- package/dist/layout/page.js +15 -15
- package/dist/layout/path.js +1 -1
- package/dist/layout/range.d.ts +7 -6
- package/dist/layout/range.js +23 -14
- package/dist/layout/types.d.ts +19 -30
- package/dist/lowering/loweringContext.d.ts +8 -11
- package/dist/lowering/loweringContext.js +7 -13
- package/dist/lowering/track.d.ts +8 -1
- package/dist/lowering/types.d.ts +12 -8
- package/dist/parser/grammarType.d.ts +3 -3
- package/dist/parser/parse-utils/brace-utils.js +7 -17
- package/dist/parser/parse-utils/call-utils.d.ts +4 -3
- package/dist/parser/parse-utils/call-utils.js +23 -66
- package/dist/parser/parse-utils/note-utils.d.ts +7 -3
- package/dist/parser/parse-utils/note-utils.js +25 -40
- package/dist/parser/parse-utils/string-utils.d.ts +1 -1
- package/dist/parser/parse-utils/string-utils.js +8 -6
- package/dist/parser/parserContext.d.ts +17 -11
- package/dist/parser/parserContext.js +111 -65
- package/dist/parser/preprocess.d.ts +7 -0
- package/dist/parser/preprocess.js +21 -19
- package/dist/pipeline.d.ts +1 -1
- package/dist/pipeline.js +2 -2
- package/dist/playback/compile.js +14 -15
- package/dist/playback/event.d.ts +6 -6
- package/dist/playback/event.js +13 -49
- package/dist/render/canvas.d.ts +0 -2
- package/dist/render/canvas.js +50 -56
- package/dist/render/index.d.ts +1 -1
- package/dist/render/index.js +1 -1
- package/dist/render/paint.d.ts +7 -0
- package/dist/render/paint.js +70 -20
- package/dist/render/recording.d.ts +8 -1
- package/dist/render/recording.js +12 -0
- package/dist/render/svg.d.ts +5 -2
- package/dist/render/svg.js +70 -48
- package/dist/render/text.d.ts +37 -2
- package/dist/render/text.js +136 -1
- package/dist/render/translate.d.ts +3 -1
- package/dist/render/translate.js +6 -0
- package/dist/render/types.d.ts +9 -2
- package/grammar.md +18 -14
- package/package.json +8 -18
- package/dist/converter/midi/convert.d.ts +0 -42
- package/dist/converter/midi/convert.js +0 -729
- package/dist/converter/midi/index.d.ts +0 -5
- package/dist/converter/midi/index.js +0 -11
- package/dist/converter/midi/json.d.ts +0 -38
- package/dist/converter/midi/json.js +0 -1
- package/dist/converter/midi/triplet.d.ts +0 -30
- package/dist/converter/midi/triplet.js +0 -75
- package/dist/converter/musicxml/dom.d.ts +0 -25
- package/dist/converter/musicxml/dom.js +0 -65
- package/dist/converter/musicxml/features.d.ts +0 -114
- package/dist/converter/musicxml/features.js +0 -501
- package/dist/converter/musicxml/index.d.ts +0 -14
- package/dist/converter/musicxml/index.js +0 -1295
- package/dist/converter/musicxml/model.d.ts +0 -176
- package/dist/converter/musicxml/model.js +0 -1
- package/dist/converter/musicxml/resolve.d.ts +0 -10
- package/dist/converter/musicxml/resolve.js +0 -152
- package/dist/converter/source.d.ts +0 -22
- package/dist/converter/source.js +0 -51
- package/dist/core.d.ts +0 -24
- package/dist/core.js +0 -24
- package/dist/iife/core.d.ts +0 -1
- package/dist/iife/core.js +0 -3
- package/dist/iife/from-midi.d.ts +0 -1
- package/dist/iife/from-midi.js +0 -15
- package/dist/iife/from-musicxml.d.ts +0 -1
- package/dist/iife/from-musicxml.js +0 -3
- package/dist/iife/full.d.ts +0 -1
- package/dist/iife/full.js +0 -3
- package/dist/jpfun.core.min.js +0 -123
- package/dist/jpfun.from-midi.min.js +0 -9
- package/dist/jpfun.from-musicxml.min.js +0 -12
package/dist/jpfun.core.min.js
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
/*! jpfun | Apache-2.0 | github.com/madderscientist/jpFun */
|
|
2
|
-
"use strict";(()=>{var Wr=Object.defineProperty;var Gr=(r,t)=>{for(var e in t)Wr(r,e,{get:t[e],enumerable:!0})};var Ss={};Gr(Ss,{ANCHOR_KEY:()=>ot,ASTBraceNode:()=>tt,ASTFunctionNode:()=>N,ASTLabelNode:()=>wt,ASTNodeBase:()=>rt,ASTTextNode:()=>et,CanvasPainter:()=>So,CanvasTextMeasurer:()=>rn,DEFAULT_BPM:()=>vt,DEFAULT_FONT_SIZE:()=>bi,DEFAULT_KEY:()=>bt,DEFAULT_OCTAVE:()=>Mc,DEFAULT_PAGE_CONFIG:()=>at,DEFAULT_PROGRAM:()=>Fe,DEFAULT_TEXT_FONT:()=>se,DEFAULT_TONALITY:()=>de,DEFAULT_VELOCITY:()=>Xt,DefaultTextMeasurer:()=>je,Diagnostic:()=>I,ErrorDiagnostic:()=>w,Fraction:()=>P,JIANPU_NUMBER_FONT:()=>cn,LoweringContext:()=>Re,PageLayoutError:()=>Qt,ParserContext:()=>dt,RecordingPainter:()=>ws,SvgPainter:()=>wo,TemporalNodeBase:()=>W,Track:()=>Bt,WarningDiagnostic:()=>z,analyzeScoreSyntax:()=>va,canvasFont:()=>Xe,compilePlayback:()=>Ia,compileScore:()=>_a,completeSpringConfig:()=>Be,createLayoutPrepareContext:()=>fs,defaultFunctions:()=>go,defaultTextMeasurer:()=>an,functionAddonKey:()=>Pt,getLayoutBounds:()=>st,isLayoutAttachment:()=>St,isPlaybackRelation:()=>xs,isVisualTemporalNode:()=>R,layoutDocument:()=>Oo,layoutElement:()=>He,layoutHorizontal:()=>Lo,layoutHorizontalRegion:()=>qt,layoutLocalSequence:()=>te,layoutPageBounds:()=>Kt,normalizePageConfig:()=>me,paginateLayoutLines:()=>To,paintLayout:()=>bs,paintLayoutPages:()=>he,performanceTimeToScoreTime:()=>Fr,performanceTimeToSeconds:()=>bo,prepareHorizontalLine:()=>Ro,prepareLayoutHost:()=>ge,preprocessSource:()=>ie,primaryName:()=>ue,renderLayoutPagesToCanvas:()=>Ba,renderLayoutPagesToSvg:()=>Fa,resolveArgDef:()=>As,resolveArgType:()=>jt,scoreTimeToPerformanceTime:()=>Dr,scoreTimeToSeconds:()=>Oa,secondsToPerformanceTime:()=>zr,secondsToScoreTime:()=>Ma,skipSpaces:()=>Tt,skipSpacesBack:()=>Ee,symbols:()=>le,transferFunctionAddons:()=>zt,transformNotes:()=>zi,unionLayoutBoxes:()=>Jt});var Vr=/\{(\w+)\}/g,I=class r{code;message;span;params;static format(t,e,o){return o?e.replace(Vr,(n,s)=>Object.hasOwn(o,s)?o[s]:n):e}constructor(t,e,o,n){if(this.code=t,this.span=o,n){let s={};for(let i of Object.keys(n))s[i]=String(n[i]);this.params=s}this.message=r.format(t,e,this.params)}toLineCol(t){let e=r.offsetToLineCol(this.span.start,t),o=r.offsetToLineCol(this.span.end,t);return{startLine:e.line,startColumn:e.column,endLine:o.line,endColumn:o.column}}static offsetToLineCol(t,e){let o=e.length;if(o===0)return{line:1,column:Math.max(0,t)+1};let n=t;n<0&&(n=0);let s=0,i=o-1;for(;s<=i;){let l=s+i>>1;e[l]<=n?s=l+1:i=l-1}let c=Math.max(0,i),a=e[c]??0;return{line:c+1,column:n-a+1}}static error;static warning},Cs=r=>typeof r=="number"?`[${r}]`:`"${r}"`,w=class extends I{},z=class extends I{};I.error={Bug:(r,t)=>new w("E_BUG","\u89E3\u6790\u5668\u9519\u8BEF: {message}\uFF0C\u8BF7\u8054\u7CFB\u5F00\u53D1\u8005\u4FEE\u590D\u8FD9\u4E2A\u95EE\u9898",t,{message:r}),MissingArg:(r,t,e)=>new w("E_MISSING_REQUIRED_ARG","\u51FD\u6570@{fn} \u7F3A\u5C11\u5FC5\u9700\u7684\u53C2\u6570 {arg}",e,{fn:r,arg:Cs(t)}),PosAfterNamedArg:(r,t)=>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",t,{fn:r}),EmptyContent:(r,t,e)=>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",e,{fn:r,arg:Cs(t)}),UnterminatedCall:(r,t)=>new w("E_UNTERMINATED_CALL","\u51FD\u6570\u8C03\u7528\u672A\u95ED\u5408: @{fn}(...)",t,{fn:r}),UnknownFunction:(r,t)=>new w("E_UNKNOWN_FUNCTION","\u672A\u77E5\u51FD\u6570: @{fn}\uFF0C\u8BF7\u68C0\u67E5\u62FC\u5199",t,{fn:r}),UnknownLabel:(r,t)=>new w("E_UNKNOWN_LABEL",'\u672A\u77E5\u6807\u7B7E: "{label}"',t,{label:r}),BreakInsideEvent:r=>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",r),PageOverflow:(r,t,e)=>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",e,{required:r,available:t})};I.warning={InvalidUnicodeEscape:r=>new z("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",r),UnknownFunction:(r,t)=>new z("W_UNKNOWN_FUNCTION","\u672A\u77E5\u51FD\u6570: @{fn}\uFF0C\u5C06\u88AB\u5F53\u4F5C\u666E\u901A\u6587\u672C\u5904\u7406",t,{fn:r}),TooManyPosArgs:(r,t,e,o)=>new z("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",o,{fn:r,expected:t,actual:e}),InvalidNumber:(r,t)=>new z("W_INVALID_NUMBER",'\u65E0\u6548\u7684\u6570\u5B57: "{value}"\uFF1B\u5C06\u4F7F\u7528\u9ED8\u8BA4\u503C(\u82E5\u5B58\u5728)',t,{value:r}),InvalidBoolean:(r,t)=>new z("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)`,t,{value:r}),InvalidLength:(r,t)=>new z("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)',t,{value:r}),InvalidLengthUnit:(r,t)=>new z("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)',t,{unit:r}),InvalidContent:r=>new z("W_INVALID_CONTENT","\u5185\u5BB9\u89E3\u6790\u5931\u8D25\uFF0C\u9519\u8BEF\u539F\u56E0\u89C1\u4E0A\uFF1B\u5C06\u4F7F\u7528\u9ED8\u8BA4\u503C(\u4F46\u5F80\u5F80\u4E0D\u5B58\u5728\uFF0C\u6781\u6709\u53EF\u80FD\u5BFC\u81F4\u9519\u8BEF)",r),UnmatchedBrace:r=>new z("W_UNMATCHED_BRACE","\u672A\u5339\u914D\u7684\u5927\u62EC\u53F7: \u7F3A\u5C11\u53F3\u5927\u62EC\u53F7'}'\uFF1B\u5C06\u5C1D\u8BD5\u81EA\u52A8\u4FEE\u590D",r),LabelWithoutTarget:(r,t)=>new z("W_LABEL_WITHOUT_TARGET",'\u6807\u7B7E "{label}" \u6CA1\u6709\u53EF\u7ED1\u5B9A\u7684\u76EE\u6807\uFF1B\u6807\u7B7E\u5C06\u88AB\u5FFD\u7565',t,{label:r}),TargetAlreadyLabeled:(r,t,e)=>new z("W_TARGET_ALREADY_LABELED",'\u76EE\u6807\u5DF2\u6807\u6CE8\u4E3A "{oldLabel}"\uFF0C"{newLabel}" \u5C06\u88AB\u5FFD\u7565',e,{oldLabel:t,newLabel:r}),UnresolvedEndpoint:(r,t)=>new z("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",t,{fn:r}),ZeroTimeTrack:(r,t)=>new z("W_ZERO_TIME_TRACK","\u7B2C{track}\u4E2A\u5B50\u8F68\u9053\u7684\u65F6\u957F\u4E3A0",r,{track:t})};function Pt(r){return`@${r}`}var rt=class{sourceSpan;parent;get children(){return null}constructor(t,e=null){this.sourceSpan=t,this.parent=e}loweringEnter(t,e){return[]}timeFlowModel(t){return null}loweringExit(t,e,o){return[]}toString(t){return t.slice(this.sourceSpan.start,this.sourceSpan.end)}},et=class extends rt{},wt=class extends rt{label;target;constructor(t,e,o,n=null){super(t,n),this.label=e,this.target=o}toString(t){return`@${this.label} `}},tt=class r extends rt{content;get children(){return this.content}constructor(t,e,o=null){super(t,o),this.content=e,this.content.forEach(n=>n.parent=this)}innerSpan(){return r.getContentSpan(this.content)}static getContentSpan(t){if(Array.isArray(t)){if(t.length===0)return{start:0,end:0};let e=r.getContentSpan(t[0]),o=r.getContentSpan(t[t.length-1]);return{start:e.start,end:o.end}}else return{start:t.sourceSpan.start,end:t.sourceSpan.end}}timeFlowModel(){return{children:this.content,mode:"sequence"}}toString(t){return`{${this.content.map(e=>e.toString(t)).join("")}}`}};function As(r,t,e){if(t){let o=t.toLowerCase();return r.args.find(n=>n.name?.toLowerCase()===o)}for(let o of r.args)if(!o.namedOnly&&e--===0)return o}function jt(r,t,e){return As(r,t,e)?.type??(!t&&r.allowExtraArgs?r.extraArgType:void 0)}function ue(r){return Array.isArray(r.name)?r.name[0]:r.name}var N=class r extends rt{label;static def;get def(){return this.constructor.def}get callName(){return this.def?ue(this.def):""}static deSugarAtom=()=>null;get deSugarAtom(){return this.constructor.deSugarAtom}static deSugarRelation=()=>null;get deSugarRelation(){return this.constructor.deSugarRelation}getArgValue(t,e){let o=this.def;if(!o)return[];let n=ue(o),s=0;return o.args.map((i,c)=>{let a=i.namedOnly?void 0:s++,l=i.name?.toLowerCase(),h=(l?t.get(l):void 0)??(a===void 0?void 0:t.get(a))??(l?e.variables[`${n}.${l}`.toLowerCase()]:void 0)??i.default;if(h===null)throw I.error.MissingArg(n,i.name||(a??c),this.sourceSpan);return h})}toString(t){let e=this.callName;return e?`@${e} `:super.toString(t)}static layoutDecorationHandler;static findLabelable(t){let e=t;if(e.labelable)return e.labelable();for(let o of t.children??[]){let n=r.findLabelable(o);if(n)return n}return null}static findLastFuncContentIndex(t,e){for(;e>=0;e--)if(t[e]instanceof r||t[e]instanceof tt)return e;return-1}};function Yr(r,t){for(;t!==0;){let e=r%t;r=t,t=e}return r}var P=class r{_numerator=0;_denominator=1;constructor(t=0,e=1){(t!==0||e!==1)&&this.set(t,e)}get numerator(){return this._numerator}get denominator(){return this._denominator}set(t,e=1){if(!Number.isFinite(t)||!Number.isFinite(e))throw new RangeError("Fraction numerator and denominator must be finite");if(e===0)throw new RangeError("Denominator must not be zero");e<0&&(t=-t,e=-e);let o=Yr(Math.abs(t),e);return this._numerator=t/o,this._denominator=e/o,this}copyFrom(t){return this._numerator=t._numerator,this._denominator=t._denominator,this}clone(){return new r().copyFrom(this)}add(t,e=1){let o;return typeof t=="number"?o=t:(o=t._numerator,e=t._denominator),this.set(this._numerator*e+o*this._denominator,this._denominator*e)}sub(t,e=1){let o;return typeof t=="number"?o=t:(o=t._numerator,e=t._denominator),this.set(this._numerator*e-o*this._denominator,this._denominator*e)}mul(t,e=1){let o;return typeof t=="number"?o=t:(o=t._numerator,e=t._denominator),this.set(this._numerator*o,this._denominator*e)}div(t,e=1){let o;if(typeof t=="number"?o=t:(o=t._numerator,e=t._denominator),o===0)throw new RangeError("Cannot divide by zero");return this.set(this._numerator*e,this._denominator*o)}divPow2(t=1){if(this._numerator===0)return this;for(;t>0&&this._numerator%2===0;)this._numerator/=2,t--;let e=this._denominator*2**t;if(!Number.isFinite(e))throw new RangeError("Fraction denominator overflow");return this._denominator=e,this}compare(t,e=1){let o;typeof t=="number"?o=t:(o=t._numerator,e=t._denominator);let n=this._numerator*e-o*this._denominator;return n<0?-1:n>0?1:0}equals(t,e=1){return t instanceof r?this._numerator===t._numerator&&this._denominator===t._denominator:this._numerator*e===t*this._denominator}isZero(){return this._numerator===0}toNumber(){return this._numerator/this._denominator}toString(){return this._denominator===1?String(this._numerator):`${this._numerator}/${this._denominator}`}};var vt=120,Xt=80,de="C4",Fe=0,ot=-1/0,bt=1/0,W=class{t=new P;T=new P;track;ast;order;addon;mergeKey;foldedInto;layoutLine=0;box;springConfig;ports;decorations;initLayoutBox(){return this.box={x:0,y:0,w:0,h:0,anchor:0,visualAxis:0}}playbackState;prepareLayout(t){}paint(t){}};function zt(r,t){let e=r.addon;if(e){for(let o of Object.keys(e).filter(n=>n.startsWith("@")))(t.addon??={})[o]=e[o],delete e[o];Object.keys(e).length||(r.addon=void 0)}}function R(r){return r.box!==void 0}function St(r){return typeof r.createGeometry=="function"}var Zt=class{target;dx;dy;constructor(t,e,o){this.target=t,this.dx=e,this.dy=o}drawText(t,e,o,n){this.target.drawText(t,e+this.dx,o+this.dy,n)}drawLine(t,e,o,n,s){this.target.drawLine(t+this.dx,e+this.dy,o+this.dx,n+this.dy,s)}drawRect(t,e,o,n,s){this.target.drawRect(t+this.dx,e+this.dy,o,n,s)}drawCircle(t,e,o,n){this.target.drawCircle(t+this.dx,e+this.dy,o,n)}drawPath(t,e,o){this.target.drawPath(t,e,{x:(o?.x??0)+this.dx,y:(o?.y??0)+this.dy,scaleX:o?.scaleX??1,scaleY:o?.scaleY??1})}};var Co=class extends N{static def={name:["adjust","adj"],description:"\u5FAE\u8C03\u76EE\u6807\u7684\u7ED8\u5236\u4F4D\u7F6E\u4E0E\u6392\u7248\u5360\u4F4D",details:`~~~jpfun
|
|
3
|
-
@adjust(1, dx=2px, dy=-1px, dw=0.2em, dh=0px)
|
|
4
|
-
~~~
|
|
5
|
-
|
|
6
|
-
\u4F4D\u7F6E\u504F\u79FB\u5728\u6392\u7248\u540E\u5E94\u7528\uFF0C\u76F8\u90BB\u5BF9\u8C61\u4FDD\u6301\u539F\u4F4D\uFF1B\u5360\u4F4D\u8C03\u6574\u5728\u6392\u7248\u524D\u5E94\u7528\u3002\u53EA\u5305\u88F9\u5173\u7CFB\u5BF9\u8C61\u65F6\uFF0C\u5E73\u79FB\u4F5C\u7528\u4E8E\u8BE5\u5173\u7CFB\u5BF9\u8C61\u672C\u8EAB\u3002`,allowExtraArgs:!1,args:[{type:"content",description:"\u8981\u5FAE\u8C03\u7684\u5185\u5BB9\u6216\u5173\u7CFB\u5BF9\u8C61",default:null},{name:"dx",description:"\u6392\u7248\u540E\u7684\u6C34\u5E73\u504F\u79FB\uFF0C\u6B63\u503C\u5411\u53F3\uFF0C\u4E0D\u6539\u53D8\u5360\u4F4D",type:"length",default:{value:0,unit:"px"}},{name:"dy",description:"\u6392\u7248\u540E\u7684\u5782\u76F4\u504F\u79FB\uFF0C\u6B63\u503C\u5411\u4E0B\uFF0C\u4E0D\u6539\u53D8\u5360\u4F4D",type:"length",default:{value:0,unit:"px"}},{name:"dw",description:"\u589E\u51CF\u6C34\u5E73\u5360\u4F4D\uFF0C\u6309\u539F\u5DE6\u53F3\u6BD4\u4F8B\u5206\u914D\uFF0C\u6700\u7EC8\u5BBD\u5EA6\u4E0D\u5C0F\u4E8E 0",type:"length",default:{value:0,unit:"px"}},{name:"dh",description:"\u589E\u51CF\u4E0B\u65B9\u5360\u4F4D\uFF0C\u6700\u7EC8\u9AD8\u5EA6\u4E0D\u5C0F\u4E8E 0",type:"length",default:{value:0,unit:"px"}}]};target;dx;dy;dw;dh;get children(){return[this.target]}timeFlowModel(){return{children:[this.target],mode:"sequence"}}loweringEnter(t){let e={temporal:0,attachment:0},o={targets:e,onTemporal:n=>{R(n)&&(e.temporal++,Kr(n,this))},onAttachment:n=>{St(n)&&(e.attachment++,Ur(n,e,this.dx,this.dy))}};return t.beginLoweringGroup(this,o),[]}loweringExit(t){let e=t.endLoweringGroup(this);return e.targets.temporal===0&&e.targets.attachment===0&&t.diagnostics.push(new z("W_ADJUST_NO_TARGET","@adjust \u6CA1\u6709\u627E\u5230\u53EF\u8C03\u6574\u7684\u5BF9\u8C61",this.sourceSpan)),[]}constructor(t,e,o,n=null){super(t,n);let[s,i,c,a,l]=this.getArgValue(e,o);s.parent=this,this.target=s,this.dx=o.length2px(i),this.dy=o.length2px(c),this.dw=o.length2px(a),this.dh=o.length2px(l)}toString(t){return`@adjust(${this.target.toString(t)}, dx=${this.dx}px, dy=${this.dy}px, dw=${this.dw}px, dh=${this.dh}px)`}},Ls=Co;function Kr(r,t){let{dx:e,dy:o,dw:n,dh:s}=t;if(e===0&&o===0&&n===0&&s===0)return;(e!==0||o!==0)&&(r.placementOffset={x:(r.placementOffset?.x??0)+e,y:(r.placementOffset?.y??0)+o});let i,c,a=r.finalizeLayout,l=r.onPlaced;r.finalizeLayout=h=>{a?.call(r,h);let p=Math.max(0,r.box.w+n);r.box.anchor=r.box.w>0?r.box.anchor*p/r.box.w:0,r.box.w=p,r.box.h=Math.max(0,r.box.h+s)},r.onPlaced=()=>{r.box.x!==i&&(r.box.x+=e),r.box.y!==c&&(r.box.y+=o),l?.call(r),i=r.box.x,c=r.box.y}}function Ur(r,t,e,o){if(t.temporal>0||e===0&&o===0)return;r.placementOffset={x:(r.placementOffset?.x??0)+e,y:(r.placementOffset?.y??0)+o};let n=r.createGeometry;r.createGeometry=s=>{let i=n.call(r,s);if(t.temporal>0||s.layoutOnly)return i;let c=a=>a.line===void 0?{x:a.x+e,y:a.y+o,w:a.w,h:a.h}:{x:a.x+e,y:a.y+o,w:a.w,h:a.h,line:a.line,track:a.track};return{regions:i.regions.map(c),occupancy:i.occupancy?.map(c),paint(a){i.paint(new Zt(a,e,o))}}}}var De=1,jr=6,Xr=16,Ao=32,Ts=1e-6,Zr=.01;function Be(r,t=De){let e=r.alpha_L??r.alpha_R??jr;r.alpha_L??=e,r.alpha_R??=e;let o=r.mu_L??r.mu_R??Xr;r.mu_L??=o,r.mu_R??=o,r.beta_L??=t/Math.max(r.alpha_L,Ts),r.beta_R??=t/Math.max(r.alpha_R,Ts)}function He(r,t,e,o=De){Be(r,o);let n=Math.pow(Math.max(e.T.toNumber(),Zr),.5);return{config:r,box:t,time:e,duration_L:n,duration_R:n,WL:t.anchor,WR:t.w-t.anchor,margin_L:n*r.alpha_L,margin_R:n*r.alpha_R}}function qr(r,t=De){let e=new Map,o=0;for(let s of r)for(let i of s)e.has(i.time.track)||e.set(i.time.track,o++);let n=[];for(let s of r){if(s.length===0)continue;let i=Array(s.length);n.push(i);let c=0,a=0,l=o;for(let p of s){p.WL>c&&(c=p.WL),p.WR>a&&(a=p.WR);let f=e.get(p.time.track);if(i[f]){let u=i[f];p.time.T.compare(u.time.T)>0?(i[f]=p,i[l++]=u):i[l++]=p}else i[f]=p}let h=s[0].time.t;for(let p of e){let f=p[1];if(!i[f]){let u=He({alpha_L:c,alpha_R:a},{x:0,w:0,anchor:0},{t:h,T:new P(1),track:p[0]},t);u.fake=!0,i[f]=u}}}return{mat:n,rows:o}}function Qr(r,t,e,o){let n=o-e-r.WR-t.WL,s=r.margin_R+t.margin_L;if(n>=s)return{force:0,stiffness:0};let i=r.config.beta_R/r.duration_R,c=t.config.beta_L/t.duration_L,a=i*c/(i+c),l,h;if(n<0){let p=r.config.mu_R*t.config.mu_L/(r.config.mu_R+t.config.mu_L);l=a*s-p*n,h=p}else{let p=s-n;l=a*p,h=a}return{force:l,stiffness:h}}function Jr(r,t,e=Ao){let o=t-r.WL,n=r.margin_L;if(o>=n)return{force:0,stiffness:0};let s=r.config.beta_L/r.duration_L;if(o>=0)return{force:s*(n-o),stiffness:s};let i=r.config.mu_L*e;return{force:r.config.alpha_L*r.config.beta_L-i*o,stiffness:i}}function tc(r,t,e,o=Ao){let n=e-(t+r.WR),s=r.margin_R;if(n>=s)return{force:0,stiffness:0};let i=r.config.beta_R/r.duration_R;if(n>=0)return{force:i*(s-n),stiffness:i};let c=r.config.mu_R*o;return{force:r.config.alpha_R*r.config.beta_R-c*n,stiffness:c}}function ec(r){return{damping:r.damping??.6,maxIter:r.maxIter??100,eps:r.eps??.01,crossPunish:r.crossPunish??Ao,globalC:r.globalC??De}}function oc(r,t,e,o,n){let{damping:s,maxIter:i,eps:c,crossPunish:a}=n,l=r.length,h=new Float64Array(t);for(let S=0;S<l;S++){let C=0,L=r[S];for(let E=0;E<t;E++){let _=h[E]+L[E].WL+L[E].margin_L;_>C&&(C=_)}for(let E=0;E<t;E++)h[E]=C+L[E].WR+L[E].margin_R;e[S]=C}let p=h.reduce((S,C)=>Math.max(S,C),0);if(p<=o)return!0;p=o/p;for(let S=0;S<l;S++)e[S]*=p;let f=new Float64Array(l),u=new Float64Array(l+1);function d(S){f.fill(0),u.fill(0);for(let C=0;C<t;C++){let L=r[0][C],E=Jr(L,S[0],a);f[0]+=E.force,u[0]+=E.stiffness;for(let k=1;k<l;k++){let F=r[k-1][C],A=r[k][C],O=Qr(F,A,S[k-1],S[k]);f[k-1]-=O.force,f[k]+=O.force,u[k]+=O.stiffness}let _=r[l-1][C],v=tc(_,S[l-1],o,a);f[l-1]-=v.force,u[l]+=v.stiffness}return f}let x=new Float64Array(l),m=new Float64Array(l);function g(){for(let C=0;C<l;C++){let L=C===0?0:u[C]/x[C-1],E=u[C]+u[C+1]+1e-4-L*u[C];if(!(E>0)||!Number.isFinite(E))throw new Error("Horizontal spring stiffness must produce a finite positive definite system");x[C]=E,m[C]=f[C]+(C===0?0:L*m[C-1])}m[l-1]/=x[l-1];for(let C=l-2;C>=0;C--)m[C]=(m[C]+u[C+1]*m[C+1])/x[C];return m}let y=0,b=0;for(;y<i;y++){let S=d(e);b=0;for(let L=0;L<S.length;L++){let E=Math.abs(S[L]);E>b&&(b=E)}if(b<c)break;let C=g();for(let L=0;L<l;L++)e[L]+=s*C[L]}return!1}function qt(r,t,e,o,n,s,i){if(e.length!==r.length||o.length!==Math.max(0,e.length-1))throw new Error("Horizontal region state does not match its columns");if(e.length===0||t===0)return;let c=o.some(u=>u!==0),a,l,h=r,p=e;if(c){a=new Uint32Array(e.length),l=new Float64Array(e.length),h=[];for(let u=0;u<e.length;){let d=u;for(;d<o.length&&o[d];)d++;let x=h.length;for(let m=u;m<=d;m++)a[m]=x,l[m]=e[m]-e[u];if(u===d)h.push(r[u]);else{let m=e[d]-e[u];h.push(Array.from({length:t},(g,y)=>{let b=r[u][y],S=r[d][y];return{config:{alpha_L:b.config.alpha_L,alpha_R:S.config.alpha_R,mu_L:b.config.mu_L,mu_R:S.config.mu_R,beta_L:b.config.beta_L,beta_R:S.config.beta_R},box:b.box,time:b.time,duration_L:b.duration_L,duration_R:S.duration_R,WL:b.WL,WR:m+S.WR,margin_L:b.margin_L,margin_R:S.margin_R,fake:b.fake&&S.fake}}))}u=d+1}p=new Float64Array(h.length)}let f=oc(h,t,p,n,s);if(o.fill(1),i!==void 0){let u=0,d=0;for(let m=0;m<t;m++)u=Math.max(u,h[0][m].WL),d=Math.max(d,h[h.length-1][m].WR);let x=p[p.length-1]+d-p[0]+u;if(!f||x>=n*i){let m=u-p[0],g=n-x;for(let y=0;y<p.length;y++)p[y]+=m+(p.length>1?g*y/(p.length-1):0)}}if(c)for(let u=0;u<e.length;u++)e[u]=p[a[u]]+l[u]}function Lo(r,t,e={},o=[],n){let s=ec(e),{mat:i,rows:c}=qr(r,s.globalC),a=new Float64Array(i.length),l=new Uint8Array(Math.max(0,i.length-1)),h=o.length>1?[...o].sort((p,f)=>p.end-p.start-(f.end-f.start)):o;for(let{start:p,end:f,hook:u}of h){if(p<0||f<p||f>=i.length)throw new Error("Horizontal layout registration references invalid columns");u({columns:i,rows:c,start:p,end:f,X:a,fixed:l,options:s})}qt(i,c,a,l,t,s,n);for(let p=0;p<i.length;p++)for(let f of i[p])f.box.x=a[p]-f.box.anchor;return i}var Qt=class extends Error{line;requiredHeight;availableHeight;constructor(t,e,o){super(`Page cannot fit layout line ${t}: requires ${e}px, available ${o}px`),this.line=t,this.requiredHeight=e,this.availableHeight=o,this.name="PageLayoutError"}},at={width:794,height:1/0,marginTop:45,marginBottom:48,marginLeft:40,marginRight:40,lineGap:22,fillRatio:.5};function me(r={}){let t=r.height??at.height,e={width:r.width??at.width,height:t<=0?1/0:t,marginTop:Math.max(0,r.marginTop??at.marginTop),marginBottom:Math.max(0,r.marginBottom??at.marginBottom),marginLeft:Math.max(0,r.marginLeft??at.marginLeft),marginRight:Math.max(0,r.marginRight??at.marginRight),lineGap:Math.max(0,r.lineGap??at.lineGap),fillRatio:r.fillRatio??at.fillRatio};if(!Number.isFinite(e.width)||e.width<=0)throw new Error(`Page width must be a positive finite number, got ${e.width}`);if(e.height!==1/0&&(!Number.isFinite(e.height)||e.height<=0))throw new Error(`Page height must be positive or Infinity, got ${e.height}`);if([e.marginTop,e.marginBottom,e.marginLeft,e.marginRight,e.lineGap].some(i=>!Number.isFinite(i)||i<0))throw new Error("Page margins and line gap must be finite non-negative numbers");let n=e.width-e.marginLeft-e.marginRight;if(n<=0)throw new Error(`Page horizontal margins leave no content width: ${n}px`);let s=e.height-e.marginTop-e.marginBottom;if(Number.isFinite(e.height)&&s<=0)throw new Error(`Page vertical margins leave no content height: ${s}px`);return e}function To(r,t,e=[]){let o=t.height-t.marginTop-t.marginBottom,n=[],s=new Array(r.length).fill(0),i=0,c=0,a=0,l=0,h=(p,f)=>{let u=p-c,d=f?Math.max(0,o-l-t.lineGap*(u-1)):0,x=t.lineGap+d/u,m=i+t.marginTop;for(let y=c;y<p;y++)s[y]=m,m+=r[y]+(y+1<p?x:0);let g=Number.isFinite(t.height)?t.height:m-i+t.marginBottom;n.push({bounds:{x:0,y:i,w:t.width,h:g},lineStart:c,lineEnd:p}),i+=g,c=p,a=0,l=0};for(let p=0;p<r.length;p++){let f=r[p];if(Number.isFinite(t.height)&&f>o+1e-6)throw new Qt(p,f,o);p>c&&(e[p]!==void 0||Number.isFinite(t.height)&&a+t.lineGap+f>o+1e-6)&&h(p,Number.isFinite(t.height)&&(e[p]??!0)),a+=(p>c?t.lineGap:0)+f,l+=f}return r.length>c&&h(r.length,!1),{pages:n,lineTops:s}}var Es={start:0,end:-1,wholeLine:!1};function Eo(r){let t=new Set,e=o=>{t.add(o);for(let n of o.groups)for(let s of n.members)e(s)};return e(r),o=>{for(let n=o;n;n=n.parent)if(t.has(n))return n;return o}}function ks(r,t){for(let e=t;e;){let o=r.columnOf(e);if(o>=0)return o;let n=e instanceof W?e.foldedInto:void 0;e=n&&R(n)?n:void 0}return-1}function ko(r,t,e,o){if(!t)return{start:0,end:r.columns.length-1,wholeLine:!0};if(typeof t[0]=="number")return{start:Math.max(0,t[0]),end:Math.min(r.columns.length-1,t[1]),wholeLine:!1};let[n,s]=t;if(n.layoutLine>s.layoutLine&&([n,s]=[s,n]),r.index<n.layoutLine||r.index>s.layoutLine)return Es;let i=e&&o(e);if(i&&(o(n.track)!==i||o(s.track)!==i))throw new Error("Range endpoints must belong to the selected track");let c=n.layoutLine<r.index?0:ks(r,n),a=s.layoutLine>r.index?r.columns.length-1:ks(r,s);return c<0||a<0?Es:{start:Math.min(c,a),end:Math.max(c,a),wholeLine:!1}}function No(r,t,e,o){if(!r)return[];let{start:n,end:s}=ko(r,t,e,o),i=r.columns.slice(n,s+1);if(!e)return i;let c=o(e),a=l=>l.track===c;return i.every(l=>l.every(a))?i:i.map(l=>l.filter(a))}var _s=.75,ye=new WeakMap;function st(r,t=!1){let{box:e}=r,o=ye.get(r);if(!o)return e;let n=t?o.contentTop:o.top,s=t?0:o.bottom;return{x:e.x,y:e.y+n,w:e.w,h:e.h-n+s}}function Jt(r,t){let e=1/0,o=1/0,n=-1/0,s=-1/0;for(let i of t)e=Math.min(e,i.x),o=Math.min(o,i.y),n=Math.max(n,i.x+i.w),s=Math.max(s,i.y+i.h);return Number.isFinite(e)?(r.x=e,r.y=o,r.w=n-e,r.h=s-o,!0):(r.x=r.y=r.w=r.h=0,!1)}function ge(r,t){if(r.springConfig??={},r.decorations&&ye.delete(r),r.decorations=[],r.ports={},r.box.x=r.box.y=0,r.prepareLayout(t),r.addon)for(let[e,o]of Object.entries(r.addon)){let n=t.decorationHandlers.get(e);if(!n)continue;let s=n(r,o,t);s&&r.decorations.push(s)}nc(r),r.finalizeLayout?.(t)}function Oo(r,t,e={}){let o=r.attachments.filter(St),n=me(r.page),s=n.width-n.marginLeft-n.marginRight,i=n.marginLeft,c=Eo(r.rootTrack),a=new Map(o.map((A,O)=>[A,O])),l=rc(o),h=[];if(o.length){for(let A of r.astToTemporal.values())if(A.some(O=>O.placementOffset?.x||O.placementOffset?.y)){h=[...new Set([...r.astToTemporal.values()].flat().filter(R))];break}}let p=new Map,f=(A,O=!1)=>{let H=p.get(A);return H&&Ns(H,O)};t={...t,layoutSubdomain(A,O,H,X){let Q=vs(O,t),J=new Set(O.flat()),D=G=>{for(let Z=G;Z&&Z!==A;Z=Z.foldedInto)if(J.has(Z))return!0;return!1},V=X.filter(St).filter(G=>!G.endPoints?.length);for(let G of l.get(A)??[])!p.has(G)&&G.endPoints.every(D)&&V.push(G);V.sort((G,Z)=>a.get(G)-a.get(Z));let U=ic(O,Q,H,V,t,f,h.length?h.filter(D):h,A);return V.forEach((G,Z)=>p.set(G,U.items[Z])),{width:Q.width,height:U.height,positions:U.positions}}};let{lines:u,pageBreaks:d}=sc(r),x=[];for(let A of u)for(let O of A.columns)for(let H of O)x.push(H),ge(H,t);let m=o.filter(A=>!p.has(A)),g=u.map((A,O)=>Ro(A.columns,O,e)),y=g.map(A=>A.view);for(let A of m)A.prepareHorizontal?.(y,t);for(let A of g){A.layout(s,n.fillRatio);for(let O of A.view.columns)for(let H of O)H.box.x+=i}if(e.horizontalOnly)return{diagnostics:r.diagnostics,objects:x,attachments:[],bounds:{x:0,y:0,w:0,h:0},lineCount:u.length,pages:[]};for(let A of x){let O=u[A.layoutLine];Os(O.hostExtents,A)}let b=ac(u.length,x,e.rowGap),S=()=>{let A=[],O=u.map((D,V)=>{let U=Rs(D,r.rootTrack,b[V]);return A.push(U.height),U.axes}),H,X;try{({pages:H,lineTops:X}=To(A,n,d))}catch(D){if(!(D instanceof Qt))throw D;let V=u[D.line],U=1/0,G=-1/0;for(let Z of V?.columns??[])for(let j of Z)U=Math.min(U,j.ast.sourceSpan.start),G=Math.max(G,j.ast.sourceSpan.end);throw Number.isFinite(U)?I.error.PageOverflow(D.requiredHeight,D.availableHeight,{start:U,end:G}):D}let Q=(D,V)=>(X[D]??0)+(O[D]?.get(V)??0);for(let D of x)D.box.y=Q(D.layoutLine,D.track)-D.box.visualAxis,D.onPlaced?.();let J={...t,width:s,originX:i,pages:H.map(D=>D.bounds),lines:y,getVisualAxis:(D,V)=>Q(D,c(V)),getHostExtent:(D,V)=>u[D]?.hostExtents.get(c(V)),getRangeColumns:(D,V,U)=>No(y[D],V,U,c)};return{pages:H,attachmentContext:J}},C=S(),L=Mo(m,C.attachmentContext,u,c,f,h);L.needsRelayout&&(C=S(),L=Mo(m,C.attachmentContext,u,c,f,h));let E=C.pages,_=0,v=o.map(A=>{let O=p.get(A),{geometry:H,box:X}=O?Ns(O):L.items[_++];return{box:X,regions:H.regions,layer:A.layer,sourceSpan:A.sourceSpan,paint(Q){H.paint(Q)}}}),k={x:0,y:0,w:0,h:0};function*F(){for(let A of E)yield A.bounds;for(let A of x)yield st(A);for(let A of v)yield A.box}return Jt(k,F()),{diagnostics:r.diagnostics,objects:x,attachments:v,bounds:k,lineCount:u.length,pages:E}}function nc(r){if(r.decorations.length===0)return;let t=0,e=-1/0,o=0,n=-1/0;for(let i of["above","below"]){let c=i==="above",a=r.decorations.length===1?r.decorations:r.decorations.filter(f=>f[i]);a.length>1&&a.sort((f,u)=>f[i].order-u[i].order);let l=c?0:r.ports["decoration.below"]?.y??r.box.h,h=c?-1/0:r.box.h,p=h;for(let f of a){let u=f[i];if(!u)continue;let d=Math.max(0,u.height??0);!c&&!f.paint&&(l=Math.max(l,p));let x=c?l-(u.gap??0)-d:l+(u.gap??0);u.place?.(x),l=c?x:x+d,o=Math.min(o,x),h=c?Math.max(h,x+d):l,f.paint&&(t=Math.min(t,x),p=c?Math.max(p,x+d):l)}n=Math.max(n,h),e=Math.max(e,p)}r.box.h=e;let s=Math.max(0,n-e);(o!==0||s!==0)&&ye.set(r,{top:o,bottom:s,contentTop:t})}function sc(r){let t=()=>({columns:[],hostExtents:new Map,attachmentExtents:new Map}),e=[],o=[],n=t();for(let s of r.columns){let i=[];for(;e.length<s[0].layoutLine;)e.push(n),n=t();for(let c of s){let a=c.addon?.pageBreakBefore;a!==void 0&&(o[e.length]=(o[e.length]??!0)&&a),R(c)&&i.push(c)}i.length&&n.columns.push(i)}return(n.columns.length>0||o[e.length]!==void 0||e.length===0)&&e.push(n),{lines:e,pageBreaks:o}}function xe(r,t,e){r.top=Math.min(r.top,t),r.bottom=Math.max(r.bottom,e)}function vo(r,t,e,o){let n=r.get(t);n?xe(n,e,o):r.set(t,{top:e,bottom:o})}function Ro(r,t,e={},o=!1){let n=[],s=new Map,i=new Map,c;for(let l=0;l<r.length;l++)for(let h of r[l]){s.set(h,l),Be(h.springConfig,e.globalC);let p=i.get(h.track);p?p.push(h):i.set(h.track,[h])}let a={index:t,columns:r,trackRuns:i,columnOf:l=>s.get(l)??-1,trackIndexOf(l){if(!c){c=new Map;for(let h of i.values())for(let p=0;p<h.length;p++)c.set(h[p],p)}return c.get(l)??-1},registerHorizontalLayoutHook(l,h,p){let f=s.get(l),u=s.get(h);f===void 0||u===void 0||n.push({start:Math.min(f,u),end:Math.max(f,u),hook:p})}};for(let l of r)for(let h of l)h.prepareHorizontal?.(a);return{view:a,layout(l,h){let p=r.map(f=>f.map(u=>{let d=He(u.springConfig,u.box,u,e.globalC);return o&&(d.margin_L=d.margin_R=0),d}));return Lo(p,l,e,n,h),p}}}function te(r,t){return r.length===0?0:vs(r.map(e=>[e]),t).width}function vs(r,t){for(let s of r)for(let i of s)ge(i,t);let e=Ro(r,r[0][0].layoutLine,{},!0),o=1/0,n=-1/0;for(let s of e.layout(1/0))for(let i of s){let c=i.box.x+i.box.anchor;o=Math.min(o,c-i.WL),n=Math.max(n,c+i.WR)}for(let s of r)for(let i of s)i.box.x-=o;return{width:n-o,view:e.view}}function ic(r,{width:t,view:e},o,n,s,i,c,a){let l=r.flat(),h={hostExtents:new Map,attachmentExtents:new Map},p=0;for(let v of l)Os(h.hostExtents,v),p=Math.max(p,v.ast.size*_s);let f=l.map(v=>({x:v.box.x,y:0})),u=()=>{let v=Rs(h,o,p);return l.forEach((k,F)=>{k.box.y=f[F].y=v.axes.get(k.track)-k.box.visualAxis,k.onPlaced?.()}),v},d=u();if(n.length===0)return{height:d.height,positions:f,items:[]};let x=Eo(o),m=[],g=[];m[e.index]=h,g[e.index]=e;let y=()=>Mo(n,{...s,width:t,originX:0,pages:[],lines:g,getVisualAxis:(v,k)=>d.axes.get(x(k))??0,getHostExtent:(v,k)=>m[v]?.hostExtents.get(x(k)),getRangeColumns:(v,k,F)=>No(g[v],k,F,x)},m,x,i,c,a),b=y();b.needsRelayout&&(d=u(),b=y());let S=l[0],C={x:S.box.x,y:S.box.y},L=b.layoutItems&&Ms(S,a),E=L&&(L.x!==0||L.y!==0)?{x:C.x-L.x,y:C.y-L.y}:C,_=b.items.map((v,k)=>({...v,reference:S,position:C,...b.layoutItems&&{layout:{...b.layoutItems[k],position:E}}}));return{height:d.height,positions:f,items:_}}function rc(r){let t=new Map;for(let e of r){let[o,...n]=e.endPoints??[];for(let s=o?.foldedInto;s;s=s.foldedInto){let i=s;if(!n.every(a=>cc(i,a)))continue;let c=t.get(s);c?c.push(e):t.set(s,[e])}}return t}function cc(r,t){for(let e=t.foldedInto;e;e=e.foldedInto)if(e===r)return!0;return!1}function Ns(r,t=!1){let e=t?r.layout??r:r,{position:o,geometry:n,box:s}=e,i=r.reference.box.x-o.x,c=r.reference.box.y-o.y;if(i===0&&c===0)return e;let a=l=>({...l,x:l.x+i,y:l.y+c});return{box:a(s),geometry:{regions:n.regions.map(a),occupancy:n.occupancy?.map(a),paint:l=>n.paint(new Zt(l,i,c))}}}function ac(r,t,e){if(e!==void 0)return new Array(r).fill(e);let o=new Array(r).fill(0),n=0;for(let s of t){let i=s.ast.size*_s;i>o[s.layoutLine]&&(o[s.layoutLine]=i),i>n&&(n=i)}for(let s=0;s<r;s++)o[s]||=n;return o}function Ms(r,t){let e=0,o=0;for(let n=r;n&&n!==t;n=n.foldedInto)e+=n.placementOffset?.x??0,o+=n.placementOffset?.y??0;return{x:e,y:o}}function Mo(r,t,e,o,n,s,i){if(r.length===0)return{items:[],needsRelayout:!1};let c=[];for(let p of s){let{x:f,y:u}=Ms(p,i);(f!==0||u!==0)&&c.push({node:p,x:f,y:u,boxX:p.box.x,boxY:p.box.y})}let a=c.length>0||r.some(p=>p.placementOffset?.x||p.placementOffset?.y),l;if(a){for(let{node:p,x:f,y:u}of c)p.box.x-=f,p.box.y-=u;try{l=_o(r,{...t,layoutOnly:!0},e,o,n,!0)}finally{for(let{node:p,boxX:f,boxY:u}of c)p.box.x=f,p.box.y=u}}else l=_o(r,t,e,o,n,!0);if(!a)return l;let h;return{needsRelayout:l.needsRelayout,layoutItems:l.items,get items(){return h??=_o(r,t,e,o,n,!1).items}}}function _o(r,t,e,o,n,s){let i=new Map,c=[],a=!1;function l(u){let d=i.get(u);return d||(d=n(u,t.layoutOnly),d&&i.set(u,d)),d}function h(u,d,x){let m=t.lines[u],g=x===void 0?new Map:void 0,y,b=d&&"left"in d?d:void 0;if(!m||b&&b.left>=b.right)return g;let S=(F,A,O)=>{g?vo(g,F,A,O):y?xe(y,A,O):y={top:A,bottom:O}},{start:C,end:L,wholeLine:E}=ko(m,d&&!("left"in d)?d:void 0,x,o),_=x&&o(x),v=b?.left??(E?t.originX:1/0),k=b?.right??(E?t.originX+t.width:-1/0);for(let F=C;F<=L;F++)for(let A of m.columns[F]){if(_&&A.track!==_||b&&(A.box.x+A.box.w<=v||A.box.x>=k))continue;E||(A.box.x<v&&(v=A.box.x),A.box.x+A.box.w>k&&(k=A.box.x+A.box.w));let O=ye.get(A),H=O?.top??0,X=A.box.y+H-t.getVisualAxis(u,A.track);S(A.track,X,X+(A.box.h-H+(O?.bottom??0)))}for(let F of c[u]??[])_&&F.track!==_||F.right<=v||F.left>=k||S(F.track,F.top,F.bottom);return g??y}let p={...t,getRangeExtents:h,getHorizontalExtents:(u,d,x)=>h(u,{left:d,right:x}),getAttachmentOccupancy(u){let d=l(u)?.geometry;return d&&(d.occupancy??d.regions)},getAttachmentBox(u){let d=l(u);if(!d)throw new Error("Layout attachment dependency has not been measured");return d.box},getContentBounds(u){let d=[];for(let m of u.nodes)R(m)&&(m.box.w>0||m.box.h>0)&&d.push(st(m,!0));for(let m of u.attachments){if(!St(m))continue;let g=l(m);if(!g&&!r.includes(m))continue;let y=g?.box??p.getAttachmentBox(m);(y.w>0||y.h>0)&&d.push(y)}let x={x:0,y:0,w:0,h:0};return Jt(x,d)?x:void 0}};return{items:r.map(u=>{let d=u.createGeometry(p),x={x:0,y:0,w:0,h:0};Jt(x,d.regions);let m={geometry:d,box:x};i.set(u,m);for(let g of d.occupancy??d.regions){if(g.line===void 0)continue;let y=e[g.line],b=o(g.track),S=g.y-t.getVisualAxis(g.line,b),C=S+g.h,L=y.hostExtents.get(b),E=y.attachmentExtents.get(b);s&&(S<Math.min(L?.top??1/0,E?.top??1/0)||C>Math.max(L?.bottom??-1/0,E?.bottom??-1/0))&&(a=!0),s&&vo(y.attachmentExtents,b,S,C),(c[g.line]??=[]).push({track:b,left:g.x,right:g.x+g.w,top:S,bottom:C})}return m}),needsRelayout:a}}function Os(r,t){let e=ye.get(t),o=e?.top??0,n=t.box.h-o+(e?.bottom??0),s=o-t.box.visualAxis;vo(r,t.track,s,s+n)}function Rs(r,t,e){let o=new Map,n=a=>{let l=r.hostExtents.get(a),h=r.attachmentExtents.get(a),p=l?{top:l.top,bottom:l.bottom}:null;h&&(p?xe(p,h.top,h.bottom):p={top:h.top,bottom:h.bottom});let f=[];for(let d of a.groups){let x=d.members.map(n);if(x.every(y=>y===null))continue;let m=d.measure(x,e),g=null;for(let y of m){if(!y)continue;let b=y.offset+y.extent.top,S=y.offset+y.extent.bottom;g?xe(g,b,S):g={top:b,bottom:S}}g&&f.push({group:d,placements:m,extent:g})}let u=(d,x)=>{p??={top:0,bottom:0};for(let m=0;m<d.group.members.length;m++){let g=d.placements[m];g&&o.set(d.group.members[m],x+g.offset)}xe(p,x+d.extent.top,x+d.extent.bottom)};for(let d of f)d.group.place||u(d,0);for(let d of f){let x=d.group.place;if(!x)continue;u(d,x(p??{top:0,bottom:0},d.extent,e))}return p},s=n(t),i=new Map;if(!s)return{axes:i,height:0};let c=(a,l)=>{i.set(a,l);for(let h of a.groups)for(let p of h.members){let f=o.get(p);f!==void 0&&c(p,l+f)}};return c(t,-s.top),{axes:i,height:s.bottom-s.top}}var $e=class{min=1/0;max=-1/0;add(t){t<this.min&&(this.min=t),t>this.max&&(this.max=t)}};function Io(r,t,e,o,n,s){if(!(r>0&&r<1))return;let i=1-r;s.add(i*i*i*t+3*i*i*r*e+3*i*r*r*o+r*r*r*n)}function Is(r,t,e,o,n){n.add(r),n.add(o);let s=-r+3*t-3*e+o,i=2*(r-2*t+e),c=t-r;if(Math.abs(s)<1e-12){Math.abs(i)>1e-12&&Io(-c/i,r,t,e,o,n);return}let a=i*i-4*s*c;if(a<0)return;let l=Math.sqrt(a);Io((-i+l)/(2*s),r,t,e,o,n),Io((-i-l)/(2*s),r,t,e,o,n)}function Ps(r,t,e,o){o.add(r),o.add(e);let n=r-2*t+e;if(Math.abs(n)<1e-12)return;let s=(r-t)/n;if(!(s>0&&s<1))return;let i=1-s;o.add(i*i*r+2*i*s*t+s*s*e)}function ut(r){let t=new $e,e=new $e,o=0,n=0,s=0,i=0;for(let c of r){if(c.op==="Z"){o=s,n=i;continue}c.op==="C"?(Is(o,c.cx1,c.cx2,c.x,t),Is(n,c.cy1,c.cy2,c.y,e)):c.op==="Q"?(Ps(o,c.cx,c.x,t),Ps(n,c.cy,c.y,e)):(t.add(c.x),e.add(c.y),c.op==="M"&&(s=c.x,i=c.y)),o=c.x,n=c.y}return Number.isFinite(t.min)?{x:t.min,y:e.min,w:t.max-t.min,h:e.max-e.min}:{x:0,y:0,w:0,h:0}}var lc=54.2813,Fs=87.37505,We=72.8125,hc=93.6719,pc=-27.4688,Ds=-7.9375,fc=Ds+hc,uc=[{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}],dc=[{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 zs(r,t,e,o,n,s){let i=a=>e+(s?lc-a:a)*n,c=a=>o+(s?Fs-a:a)*n;for(let a of t)a.op==="Z"?r.push(a):a.op==="C"?r.push({op:"C",cx1:i(a.cx1),cy1:c(a.cy1),cx2:i(a.cx2),cy2:c(a.cy2),x:i(a.x),y:c(a.y)}):a.op==="Q"?r.push({op:"Q",cx:i(a.cx),cy:c(a.cy),x:i(a.x),y:c(a.y)}):r.push({op:a.op,x:i(a.x),y:c(a.y)})}function Bs(r,t,e){let o=e==="up"||e==="down",n=Math.max(1,Math.round(r/(t*.3))),s=o?Math.max(0,n-1):n,i=o?fc+We*s:Fs+We*(s-1),c=r/i,a=[];for(let f=0;f<s;f++)zs(a,uc,0,f*We*c,c,e==="");o&&zs(a,dc,pc*c,(s*We+Ds)*c,c,!1);let l=ut(a);if(e!=="up")return{commands:a,bounds:l};let h=l.x+l.w,p=f=>h-(f-l.x);for(let f of a)f.op!=="Z"&&(f.op==="C"?(f.cx1=p(f.cx1),f.cy1=r-f.cy1,f.cx2=p(f.cx2),f.cy2=r-f.cy2):f.op==="Q"&&(f.cx=p(f.cx),f.cy=r-f.cy),f.x=p(f.x),f.y=r-f.y);return{commands:a,bounds:{x:l.x,y:r-l.y-l.h,w:l.w,h:l.h}}}function mc(r){let t=r,e=r.ast;return(e.callName==="up"||e.callName==="down")&&Array.isArray(t.members)&&Array.isArray(e.contents)?t:null}var Po=class extends N{static def={name:["arp","arpeggio"],description:"\u7436\u97F3",details:`~~~jpfun
|
|
7
|
-
@arp({1 ^ 3 ^ 5}, direction=up)
|
|
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]}constructor(t,e,o,n=null){super(t,n);let[s,i]=this.getArgValue(e,o),c="";i!==""&&i!=="up"&&i!=="down"?o.diagnostics.push(new z("W_ARPEGGIO_INVALID_DIRECTION","@arp \u7684 direction \u53EA\u80FD\u662F up \u6216 down\uFF0C\u5DF2\u56DE\u9000\u5230\u65E0\u7BAD\u5934\u4E0A\u884C\u7436\u97F3",t)):c=i,this.content=s,this.direction=c,this.size=o.variables.fontsize,s.parent=this}loweringEnter(t,e){let o=t.isolateFromLoweringGroups(()=>{let s=t.trackedEvents(this.content,new P,e).flat();if(s.length!==1||!s[0].box)throw new w("E_ARPEGGIO_INVALID_CONTENT","@arp \u7684\u5185\u5BB9\u5FC5\u987B\u6070\u597D\u4EA7\u751F\u4E00\u4E2A\u540C\u8F68\u548C\u5F26",this.content.sourceSpan);return s[0]}),n=mc(o);if(!n||n.members.length<2||n.members.some(s=>s.track!==e))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 zo(this,n)]}toString(t){let e=this.direction?`, direction=${this.direction}`:"";return`@arp(${this.content.toString(t)}${e})`}},Hs=Po,zo=class extends W{host;slots;hostX=0;markX=0;markCommands=[];constructor(t,e){super(),this.ast=t,this.host=e;let o=e.ast.contents.length,n=[...e.members.slice(o).reverse(),e.members[0],...e.members.slice(1,o)],s=t.direction==="down"?n.reverse():n;this.slots=new Map(s.map((i,c)=>[i,c])),this.T.copyFrom(e.T),this.mergeKey=e.mergeKey,this.initLayoutBox(),e.addon&&(this.addon={...e.addon}),e.addon=void 0,e.foldedInto=this}onTimeState(t){this.host.t.copyFrom(this.t),this.host.T.copyFrom(this.T),this.host.track=this.track,this.host.layoutLine=this.layoutLine;let e=this.host.onTimeState?.(t);return this.T.copyFrom(this.host.T),e}prepareHorizontal(t){this.host.prepareHorizontal?.(t)}prepareLayout(t){zt(this,this.host),ge(this.host,t),this.springConfig={...this.host.springConfig,...this.springConfig};let e=this.ast.size,o=e*.16,n=st(this.host,!0),s=st(this.host),{commands:i,bounds:c}=Bs(n.h,e,this.ast.direction);this.markCommands=i,this.markX=-c.x,this.hostX=c.w+o,this.box.w=this.hostX+this.host.box.w,this.box.h=s.h,this.box.anchor=this.hostX+this.host.box.anchor,this.box.visualAxis=this.host.box.visualAxis-s.y;for(let a in this.host.ports){let l=this.host.ports[a];this.ports[a]={x:this.hostX+l.x,y:l.y-s.y}}}onPlaced(){this.host.box.x=this.box.x+this.hostX,this.host.box.y=this.box.y-(st(this.host).y-this.host.box.y),this.host.onPlaced?.()}emitPlayback(t){t.play(this.host);let e=t.end.clone().sub(t.start),o=new P(1,8),n=e.clone().div(2).div(this.slots.size-1);o.compare(n)>0&&o.copyFrom(n);let{slots:s}=this,i=this;t.defer(c=>{let a;for(let l=c.spans.length-1;l>=0;l--){let h=c.spans[l];if(a){if(h.origins[0]!==a)break}else{if(!h.origins.some(x=>x.node===i))continue;a=h.origins[0]}let p=h.origins.find(x=>s.has(x.node))?.node,f=p?s.get(p):void 0;if(!f)continue;let u=o.clone().mul(f),d=e.clone().sub(u).div(e);h.start.sub(t.start).mul(d).add(t.start).add(u),h.end.sub(t.start).mul(d).add(t.start).add(u)}})}paint(t){let e=this.box.x,o=st(this.host,!0).y;t.drawPath(this.markCommands,{fill:"#000"},{x:e+this.markX,y:o,scaleX:1,scaleY:1}),this.host.paint(t);for(let n of this.host.decorations)n.paint?.(t)}};function $s(r,t,e){r.deferFinalize(o=>{let n=[],s=new P,i=1,c=!1,a=-1;for(let l of o.columns){let h=l[0].t;if(l.some(p=>p.mergeKey===ot))h.compare(s)>0&&(i++,s.copyFrom(h),c=!1);else if(l.some(p=>!p.T.isZero()&&R(p))){let p=l[0].layoutLine;p!==a&&(a>=0&&!c&&n.push({line:p,number:i}),a=p),c=!0}}n.length>0&&o.attachments.push(new Do(n,t,e))})}var Fo=class extends N{static def={name:["bar","|"],description:"\u5C0F\u8282\u7EBF",details:`~~~jpfun
|
|
10
|
-
@bar(0, length=1.25em)
|
|
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(t,e,o){let n=e,s=0,i=t.slice(n,n+3),c=t.slice(n,n+2);if(i==="|||")s=2,n+=3;else if(c==="||")s=1,n+=2;else if(c==="|:")s=3,n+=2;else if(c===":|")t[n+2]===":"?(s=5,n+=3):(s=4,n+=2);else if(t[n]==="|")s=0,n+=1;else return null;let a=new Map;return a.set("type",s),{next:n,node:{kind:"call",typed:!0,name:"bar",args:a,span:{start:e,end:n},syntaxKind:"atom"}}}type;size;constructor(t,e,o,n=null){super(t,n);let[s,i]=this.getArgValue(e,o);this.type=s,this.size=o.length2px(i)}loweringEnter(){return[this.type>=3&&this.type<=5?new Ho(this):new Ge(this)]}toString(){return`@bar(${this.type}, ${this.size}px)`}},Do=class{items;pattern;font;layer="foreground";sourceSpan=void 0;constructor(t,e,o){this.items=t,this.pattern=e,this.font=o}createGeometry(t){let e=this.items.map(({line:o,number:n})=>{let i=t.lines[o].columns[0].reduce((x,m)=>t.getVisualAxis(o,m.track)<t.getVisualAxis(o,x.track)?m:x),c=i.ast.size,a=i.ports["bar.number"],l={fontSize:c*.5,fontFamily:this.font,textAlign:a?"center":"right",fill:"#000"},h=this.pattern.replace("1",String(n)),p=t.textMeasurer.measureText(h,l),f=a?i.box.x+a.x:t.originX-c*.15,d=(a?i.box.y+a.y:Math.min(i.box.y,t.getVisualAxis(o,i.track)-c*.5))-c*.04;return{text:h,x:f,y:d,style:l,region:{x:a?f-p.w/2:f-p.w,y:d-p.baseline,w:p.w,h:p.baseline,line:o,track:i.track}}});return{regions:e.map(o=>o.region),paint(o){for(let n of e)o.drawText(n.text,n.x,n.y,n.style)}}}},Ws=Fo,Ge=class extends W{lines=[];repeatDots=[];constructor(t){super(),this.ast=t,this.mergeKey=ot,this.initLayoutBox(),this.springConfig={alpha_L:128,alpha_R:128}}prepareHorizontal(t){let e=this;for(;e.foldedInto;)e=e.foldedInto;if(!R(e))return;let o=t.trackRuns.get(e.track),n=t.trackIndexOf(e);if(!o||n<0)return;let s=o[n-1];s&&(s.springConfig.mu_R*=4,e.springConfig.mu_L*=4);let i=o[n+1];i&&i.mergeKey!==ot&&(e.springConfig.mu_R*=4,i.springConfig.mu_L*=4)}prepareLayout(){let{type:t,size:e}=this.ast;this.lines.length=0;let o=[],n=e,s=Math.max(1,e*.065),i=s*2.6,c=s*1.8,a=s*.8,l=c+a,h=t===4||t===5,p=t===3||t===5,f=h?a*2+l:0;if(t===1?(this.lines.push({x:f,w:s}),f+=s+c,this.lines.push({x:f,w:s}),f+=s):t===2||t===4||t===5?(this.lines.push({x:f,w:s}),f+=s+c,this.lines.push({x:f,w:i}),f+=i):t===3?(this.lines.push({x:f,w:i}),f+=i+c,this.lines.push({x:f,w:s}),f+=s):(this.lines.push({x:f,w:s}),f+=s),h){let d=a;o.push({x:d,y:n*.38}),o.push({x:d,y:n*.62})}if(p){let d=f+l;o.push({x:d,y:n*.38}),o.push({x:d,y:n*.62}),f=d+a}this.box.w=f,this.box.h=n;let u=t>=3&&t<=5?this.lines[0]:void 0;this.box.anchor=u?u.x+u.w/2:f/2,this.box.visualAxis=n/2;for(let d of this.lines)d.x-=this.box.anchor;this.repeatDots=o.map(d=>({x:d.x-this.box.anchor,y:d.y,r:a}))}paint(t){for(let e of this.lines)t.drawRect(this.box.x+this.box.anchor+e.x,this.box.y,e.w,this.box.h,{fill:"#000"});for(let e of this.repeatDots)t.drawCircle(this.box.x+this.box.anchor+e.x,this.box.y+e.y,e.r,{fill:"#000"})}},Bo="repeat.start";function Gs(r,t){return r.visits(r.seek(Bo,t+1,-1)??0)}var Ho=class extends Ge{playbackMarks(){return this.ast.type===4?[]:[Bo]}playbackFlow(t){if(this.ast.type===3)return;let e=t(this);if(e!==void 0)return{range:[e,e],run:o=>o.visits(e)>1?void 0:{kind:"jump",column:o.seek(Bo,e,-1)??0}}}};var Vs=new WeakMap;function Ft(r){let t=1/0,e=1/0,o=-1/0,n=-1/0,s=(i,c,a,l)=>{t=Math.min(t,i),e=Math.min(e,c),o=Math.max(o,i+a),n=Math.max(n,c+l)};for(let i of r){let c=i.dx??0;if(i.line){let{x1:a,y1:l,x2:h,y2:p}=i.line,f=(i.style.strokeWidth??1)/2;s(Math.min(a,h)+c-f,Math.min(l,p)-f,Math.abs(h-a)+f*2,Math.abs(p-l)+f*2)}if(i.circle){let{cx:a,cy:l,r:h}=i.circle,p=i.style.stroke&&i.style.stroke!=="none"?(i.style.strokeWidth??1)/2:0,f=h+p;s(a+c-f,l-f,2*f,2*f)}if(i.path?.length){let a=Vs.get(i.path)??ut(i.path);Vs.set(i.path,a),s(a.x+c,a.y,a.w,a.h)}}return Number.isFinite(t)?{x:t,y:e,w:Math.max(1e-9,o-t),h:Math.max(1e-9,n-e)}:{x:0,y:0,w:1e-9,h:1e-9}}function Ve(r,t,e,o,n){let s=o.x-e.x*n,i=o.y-e.y*n;for(let c of t){let a=c.style,l=a.strokeWidth??(c.line||c.circle?1:void 0),h=l===void 0?a:{...a,strokeWidth:l*n},p=s+(c.dx??0)*n;if(c.line){let{x1:f,y1:u,x2:d,y2:x}=c.line;r.drawLine(p+f*n,i+u*n,p+d*n,i+x*n,h)}c.path&&r.drawPath(c.path,h,{x:p,y:i,scaleX:n,scaleY:n}),c.circle&&r.drawCircle(p+c.circle.cx*n,i+c.circle.cy*n,c.circle.r*n,h)}}var $o=[{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"}}],be=Ft($o);var Ye=new WeakMap;function Ys(r){return Ye.get(r)?.meter}function xc(r,t,e){let o=r.currentEvent??t,n=t.ast.sourceSpan,s=Ye.get(o);s||Ye.set(o,s={start:n.start,end:n.end,meter:e}),s.end=n.end,s.meter=e}var Wo=class r extends N{static def={name:["meter"],description:"\u8BBE\u7F6E\u62CD\u53F7",details:`~~~jpfun
|
|
13
|
-
@meter(6, 8)
|
|
14
|
-
~~~
|
|
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;constructor(t,e,o,n=null){super(t,n);let[s,i,c]=this.getArgValue(e,o);if(this.font=o.variables.numberfont,!Number.isSafeInteger(s)||!Number.isSafeInteger(s*4)||s<0||!Number.isSafeInteger(i)||i<0){let a="@meter \u7684\u5206\u5B50\u548C\u5206\u6BCD\u5FC5\u987B\u662F\u975E\u8D1F\u6574\u6570";if(o.variables.strict)throw new w("E_METER_INVALID",a,t);o.diagnostics.push(new z("W_METER_INVALID",`${a}\uFF0C\u5DF2\u56DE\u843D\u4E3A 4/4`,t)),s=i=4}this.numerator=s,this.denominator=i,s!==0&&i!==0&&(this.measureDuration=new P(s*4,i)),this.size=o.length2px(c),this.strict=o.variables.strict}loweringEnter(t){return t.deferFinalize(r.loweringFinalize),[new Go(this)]}static loweringFinalize(t){let e=new P,o=new P,n=null,s=!1,i=0,c=(a,l)=>{if(!(!n?.measureDuration||a.equals(e))){if(o.copyFrom(a).sub(e),!o.equals(n.measureDuration)&&(s||o.compare(n.measureDuration)>0)){let h="\u5C0F\u8282\u65F6\u957F\u4E3A {duration} QN\uFF0C\u4E0D\u6EE1\u8DB3 {num}/{den} \u62CD\u53F7",p={start:i,end:l},f={duration:o,num:n.numerator,den:n.denominator};if(n.strict)throw new w("E_METER_MISMATCH",h,p,f);t.diagnostics.push(new z("W_METER_MISMATCH",h,p,f))}e.copyFrom(a)}};for(let a of t.columns){let l=a[0].t;for(let p of a){let f=Ye.get(p);f&&(c(l,f.start),n=f.meter,e.copyFrom(l),i=f.end)}let h=a.find(p=>p.mergeKey===ot);h&&(c(l,h.ast.sourceSpan.end),i=h.ast.sourceSpan.end,s=!0)}if(n){let a=t.columns.at(-1)?.at(-1)?.ast.sourceSpan??n.sourceSpan;c(t.duration,a.end)}}toString(){return`@meter(${this.numerator}, ${this.denominator})`}},Ke=Wo,Go=class extends W{style;numeratorBaseline=0;denominatorBaseline=0;lineY=0;lineHeight=0;constructor(t){super(),this.ast=t,this.style={fontSize:t.size,fontFamily:t.font,textAlign:"center",fill:"#000"},this.initLayoutBox()}onTimeState(t){t.meter=this.ast.measureDuration,xc(t,this,this.ast)}emitPlayback(t){this.ast.measureDuration&&t.emit({kind:"time-signature",at:t.start,numerator:this.ast.numerator,denominator:this.ast.denominator})}prepareLayout(t){if(!this.ast.measureDuration){this.box.w=this.ast.size*be.w/be.h,this.box.h=this.ast.size,this.box.anchor=this.box.w/2,this.box.visualAxis=this.box.h/2;return}let e=t.textMeasurer.measureText(String(this.ast.numerator),this.style),o=t.textMeasurer.measureText(String(this.ast.denominator),this.style),n=this.ast.size*.08,s=this.ast.size*.08;this.lineHeight=Math.max(1,this.ast.size*.06),this.numeratorBaseline=e.baseline,this.lineY=e.h+n,this.denominatorBaseline=this.lineY+this.lineHeight+n+o.baseline,this.box.w=Math.max(e.w,o.w)+s*2,this.box.h=this.lineY+this.lineHeight+n+o.h,this.box.anchor=this.box.w/2,this.box.visualAxis=this.lineY+this.lineHeight/2}paint(t){if(!this.ast.measureDuration){Ve(t,$o,be,this.box,this.ast.size/be.h);return}let e=this.box.x+this.box.anchor;t.drawText(String(this.ast.numerator),e,this.box.y+this.numeratorBaseline,this.style),t.drawRect(this.box.x,this.box.y+this.lineY,this.box.w,this.lineHeight,{fill:"#000"}),t.drawText(String(this.ast.denominator),e,this.box.y+this.denominatorBaseline,this.style)}};function yc(r){let t=Math.max(0,Math.floor(Number(r.addon?.[Dt])||0));if(t<=0)return[];let e=[],o=i=>{e.push(i),t-=Math.max(0,i.n)},n=r.ast.parent;for(;n&&t>0;)n instanceof ee&&o(n),n=n.parent;if(t<=0)return e;let s=i=>{for(let c of i.children??[]){if(t<=0)return;c instanceof ee&&o(c),s(c)}};return s(r.ast),e}function gc(r){let t=new Map,e=new Map;for(let o of r.columns)for(let n of o){if(!R(n))continue;let s=yc(n);if(s.length===0)continue;let i=[];for(let c of s){let a=t.get(c);a||(a={owner:c,nodes:[]},t.set(c,a)),a.nodes.push(n),i.push(a)}e.set(n,i)}return{scopes:[...t.values()],nodeScopes:e}}function bc(r){let t=new Set(r.map(e=>e.owner));return r.filter(e=>{let o=e.owner.parent;for(;o;){if(o instanceof ee&&t.has(o))return!1;o=o.parent}return!0})}function Ks(r,t){let e=1/0,o=-1/0;for(let n of r){e=Math.min(e,n.ast.sourceSpan.start),o=Math.max(o,n.ast.sourceSpan.end);for(let{owner:s}of t.get(n)??[])e=Math.min(e,s.sourceSpan.start),o=Math.max(o,s.sourceSpan.end)}return oe(r,!1,{start:e,end:o})}function wc(r,t,e){let o=[];for(let n of bc(r)){let s=new Map;for(let i of n.nodes){let c=s.get(i.track);c?c.push(i):s.set(i.track,[i])}for(let i of s.values()){let c=[],a=()=>{c.length>=2&&o.push(Ks(c,t)),c=[]};for(let l of i){if(e.has(l)){a();continue}c.push(l)}a()}}return o}function Sc(r,t,e){let o=[],n=new Map,s=new Map,i=new P,c=new P,a=new P(1),l=1;for(let f of r.columns)for(let u of f){let d=s.get(u.layoutLine);(d===void 0||u.t.compare(d)<0)&&s.set(u.layoutLine,u.t)}let h=f=>{let u=n.get(f);u&&(n.delete(f),u.nodes.length>=2&&o.push(Ks(u.nodes,t)))},p=()=>{for(let f of n.keys())h(f)};for(let f of r.columns){let u,d=!1;for(let x of f)u=Ys(x)??u,x.mergeKey===ot&&(d=!0);if((u||d)&&(p(),i.copyFrom(f[0].t)),u){let{numerator:x,denominator:m}=u;x>0&&m>4?a.set(m>=8&&x%3===0?12:4,m):a.set(1),l=a.compare(1)<0?a:1}for(let x of f){if(x.mergeKey===ot)continue;let m=R(x)?t.get(x):void 0,g=m?.every(v=>v.nodes.length===1)??!1,y=m?.every(v=>v.owner.autoBeamEnabled)??!1;if(!(R(x)&&g&&y&&x.T.compare(l)<0&&!e.has(x))){(R(x)||!x.T.isZero())&&h(x.track);continue}let S=s.get(x.layoutLine)??x.t,C=i.compare(S)>=0?i:S;c.copyFrom(x.t).sub(C);let L=Math.floor(c.numerator*a.denominator/(c.denominator*a.numerator)),E=n.get(x.track),_=E&&x.t.equals(E.endTime);if(!E||x.layoutLine!==E.line||L!==E.beat||!_){h(x.track),n.set(x.track,{nodes:[x],line:x.layoutLine,beat:L,endTime:x.t.clone().add(x.T)});continue}E.nodes.push(x),E.endTime.copyFrom(x.t).add(x.T)}}return p(),o}function Us(r){let{scopes:t,nodeScopes:e}=gc(r);if(t.length===0)return;let o=js(r.attachments);r.attachments.push(...wc(t,e,o),...Sc(r,e,o))}var Xs="div",Dt=Pt(Xs);function Lt(r,t){return`div.${r}.${t}`}function Zs(r,t){let e=r.ports[Lt(t,"left")];e&&(e.state.claimed=!0)}function Yo(r){return Math.max(1,r*.055)}function*qs(r){for(let t=0;;t++){let e=!1,o=-1;for(let n=0;n<=r.length;n++){let s=r[n]?.ports,i=s?.[Lt(t,"left")],c=s?.[Lt(t,"right")];if((i||c)&&(e=!0),i&&c){o<0&&(o=n);continue}o>=0&&n-o>=2&&(yield{level:t,from:o,to:n-1}),o=-1}if(!e)return}}var Vo=class r extends N{static def={name:[Xs,"/"],description:"\u51CF\u65F6\u7EBF",details:"~~~jpfun\n@div({1 2 -}, n=2, autobeam=true)\n~~~\n**\u7B80\u5199**\uFF1A\u5728\u76EE\u6807\u540E\u52A0 `/`\uFF0C\u53EF\u91CD\u590D\u6216\u4F5C\u7528\u4E8E\u5185\u5BB9\u5757\u3002`@div(1, 2)` \u7B49\u4EF7\u4E8E `1//`\uFF0C`@div({1 2/ -}, 2)` \u7B49\u4EF7\u4E8E `{1 2/ -}//`\u3002\u9ED8\u8BA4\u53C2\u6570\u4F7F\u7528 `div.n`\u3001`div.autobeam` \u8BBE\u7F6E\u3002",allowExtraArgs:!1,args:[{type:"content",description:"\u8981\u51CF\u65F6\u7684\u5185\u5BB9\uFF0C\u53EF\u5305\u542B\u591A\u4E2A\u97F3\u7B26\u6216\u589E\u65F6\u7EBF",default:null},{name:"n",description:"\u51CF\u65F6\u5C42\u6570\uFF0C\u6BCF\u7EA7\u5C06\u65F6\u503C\u51CF\u534A\uFF0C\u53D6\u975E\u8D1F\u6574\u6570",type:"number",default:1},{name:"autobeam",description:"\u662F\u5426\u53C2\u4E0E\u4E0D\u540C div \u4E4B\u95F4\u7684\u81EA\u52A8\u8FDE\u7EBF\uFF0C\u540C\u4E00 div \u5185\u90E8\u7684\u8FDE\u7EBF\u4E0D\u53D7\u5F71\u54CD",type:"boolean",default:!0}]};static deSugarAtom(t,e,o){let n=0,s=e;for(;s<o&&t[s]==="/";)n++,s++;return n===0?null:{next:s,node:{kind:"sugar",data:{class:r,n},span:{start:e,end:s}}}}static deSugarRelation(t,e,o){let n=e[o++];if(n.data?.class!==r)return null;let s=N.findLastFuncContentIndex(t.nodes,t.nodes.length-1);if(s<0)return o;let i=t.nodes[s];if(i instanceof r)return i.n+=n.data.n,o;let c=new Map;c.set(0,i),c.set("n",n.data.n);let a=i.sourceSpan,l=new r({start:Math.min(a.start,n.span.start),end:Math.max(a.end,n.span.end)},c,t,null);return t.nodes[s]=l,o}static layoutDecorationHandler=(t,e)=>{let o=Math.max(0,Math.floor(Number(e)||0));if(o===0)return null;let n=t.ast.size*.14,s=Yo(t.ast.size),i=(o-1)*n+s,c=0,a=0,l=0;return{below:{order:0,gap:t.box.h-(t.ports["decoration.below"]?.y??t.box.h)-t.ast.size*.08,height:i,place(h){c=t.ports["body.left"]?.x??0,a=t.ports["body.right"]?.x??t.box.w,l=h+s/2;for(let p=0;p<o;p++){let f=l+p*n;t.ports[Lt(p,"left")]={x:c,y:f,state:{claimed:!1}},t.ports[Lt(p,"right")]={x:a,y:f}}}},paint(h){for(let p=0;p<o;p++){if(t.ports[Lt(p,"left")].state.claimed)continue;let u=t.box.y+l+p*n;h.drawLine(t.box.x+c,u,t.box.x+a,u,{stroke:"#000",strokeWidth:s})}}}};loweringEnter(t){let e=this.n;return e===0?[]:(t.deferFinalize(r.loweringFinalize,-5),t.beginLoweringGroup(this,{onTemporal(o){let n=o.addon??={};n[Dt]=(Number(n[Dt])||0)+e,o.T.divPow2(e)}}),[])}loweringExit(t){return this.n>0&&t.endLoweringGroup(this),[]}static loweringFinalize=Us;content;n;autoBeamEnabled;get children(){return[this.content]}timeFlowModel(){return{children:[this.content],mode:"sequence"}}constructor(t,e,o,n=null){super(t,n),[this.content,this.n,this.autoBeamEnabled]=this.getArgValue(e,o),this.content.parent=this;let s=Math.max(0,Math.trunc(this.n));s!==this.n&&(o.diagnostics.push(new z("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:s})),this.n=s)}toString(t){return`@div(${this.content.toString(t)}, ${this.n})`}},ee=Vo;function oe(r,t,e){return new we(r,t,e)}function Qs(r){let t=new Map,e=new Map;for(let o of r.columns)for(let n of o){if(!R(n)||n.mergeKey===ot&&n.T.isZero())continue;let s=t.get(n.layoutLine);s||(s=new Map,t.set(n.layoutLine,s));let i=s.get(n.track)??0;e.set(n,{line:n.layoutLine,track:n.track,index:i}),s.set(n.track,i+1)}for(let o of r.attachments)if(!(!(o instanceof we)||!o.explicit))for(let n=1;n<o.endPoints.length;n++){let s=o.endPoints[n-1],i=o.endPoints[n];if(!R(s)||!R(i))continue;let c=e.get(s),a=e.get(i);if(!(s!==i&&c!==void 0&&a!==void 0&&c.line===a.line&&c.track===a.track&&a.index===c.index+1))throw new 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",o.sourceSpan)}}function js(r){let t=new Set;for(let e of r)if(!(!(e instanceof we)||!e.explicit))for(let o of e.endPoints)t.add(o);return t}var we=class{layer="foreground";endPoints;explicit;sourceSpan;fontSize;strokeWidth;constructor(t,e,o){this.endPoints=t,this.explicit=e,this.sourceSpan=o,this.fontSize=t.reduce((n,s)=>R(s)?Math.max(n,s.ast.size):n,0),this.strokeWidth=Yo(this.fontSize)}prepareHorizontal(t){let e;for(let o of this.endPoints)if(R(o)){if(e&&e.layoutLine===o.layoutLine&&e.track===o.track){let n=t[e.layoutLine],s=n?n.trackIndexOf(e):-1;s>=0&&s+1===n.trackIndexOf(o)&&(e.springConfig.alpha_R*=.8,o.springConfig.alpha_L*=.8)}e=o}}createGeometry(t){let e=this.collectLines(t),o=this.strokeWidth;return{regions:e.map(s=>({x:Math.min(s.start.x,s.end.x),y:s.start.y-o/2,w:Math.abs(s.end.x-s.start.x),h:o,line:s.line,track:s.track})),paint(s){for(let i of e)s.drawLine(i.start.x,i.start.y,i.end.x,i.end.y,{stroke:"#000",strokeWidth:o})}}}absolutePort(t,e){let o=t.ports[e];return{x:t.box.x+o.x,y:t.box.y+o.y}}collectLines(t){let e=[],o=this.endPoints.filter(R);if(o.length<2)return e;for(let{level:n,from:s,to:i}of qs(o)){let c=[];for(let a=s;a<=i;a++){let l=o[a];c.push({left:this.absolutePort(l,Lt(n,"left")),right:this.absolutePort(l,Lt(n,"right")),line:l.layoutLine,track:l.track,node:l})}this.addSystemLines(c,t,n,e)}if(e.length===0&&this.explicit){let n=this.fontSize*.12,s=o.map(i=>{let c={x:i.box.x+i.box.anchor,y:i.box.y+i.box.h+n};return{left:c,right:c,line:i.layoutLine,track:i.track,node:i}});this.addSystemLines(s,t,null,e)}return e}addSystemLines(t,e,o,n){let s=Math.min(...t.map(h=>h.line)),i=Math.max(...t.map(h=>h.line)),c=t[0].track,a=e.getVisualAxis(t[0].line,c),l=t[0].left.y-a;for(let h=s;h<=i;h++){let p=t.filter(g=>g.line===h).sort((g,y)=>g.left.x-y.left.x);if(p.length===0){let y=e.getVisualAxis(h,c)+l;n.push({start:{x:e.originX,y},end:{x:e.originX+e.width,y},line:h,track:c});continue}let f=p[0],u=p[p.length-1],d=f.left.y,x={x:f.left.x,y:d},m={x:u.right.x,y:d};if(h>s&&(x.x=e.originX),h<i&&(m.x=e.originX+e.width),!(x.x===m.x&&s===i)){if(o!==null)for(let g of p)Zs(g.node,o);n.push({start:x,end:m,line:h,track:f.track})}}}};var Ko=class r extends N{static loweringFinalize=Qs;static def={name:["beam"],description:"\u51CF\u65F6\u7EBF\u8FDE\u63A5",details:"\u4E8B\u540E\u5C06\u591A\u4E2A\u51CF\u65F6\u7EBF**\u5F3A\u884C**\u76F8\u8FDE\n~~~jpfun\n1/@a 2/@b | 3/@c @beam(a, b, c)\n~~~\n**\u4F4D\u7F6E\u53C2\u6570**\uFF1A\u5DF2\u6807\u8BB0\u97F3\u7B26\u7684\u6807\u7B7E\uFF0C\u6309\u4F20\u5165\u987A\u5E8F\u8FDE\u63A5\u51CF\u65F6\u7EBF\uFF0C\u663E\u5F0F\u6307\u5B9A\u4E00\u7EC4\u3002\u5148\u7528 `/` \u6216 `@div` \u4E3A\u76EE\u6807\u6DFB\u52A0\u51CF\u65F6\u7EBF\uFF0C\u518D\u7528 `@beam` \u63A7\u5236\u8FDE\u63A5\u3002\u7AEF\u70B9\u987B\u540C\u8F68\u3001\u540C\u8C31\u9762\u884C\u4E14\u76F8\u90BB\uFF0C\u53EF\u8DE8\u5C0F\u8282\u7EBF\uFF1B\u8FDE\u7EBF\u76F4\u63A5\u7A7F\u8FC7\u5C0F\u8282\u7EBF\uFF0C\u4FDD\u7559\u539F\u6709\u95F4\u8DDD\u3002",allowExtraArgs:!0,extraArgType:"label",args:[]};endPoints=[];constructor(t,e,o,n=null){super(t,n);for(let[,i]of e){let c=i instanceof N?i:o.parseArgWithType(i.valueSpan,"label",t.start);c instanceof N&&this.endPoints.push(c)}let s=o.labelableNodes.length-1;for(;this.endPoints.length<2&&s>=0;){let i=o.labelableNodes[s--];!i||this.endPoints.includes(i)||this.endPoints.unshift(i)}if(this.endPoints.length<2)throw new w("E_NOT_ENOUGH_ARGS","@{fn} \u81F3\u5C11\u9700\u8981\u4E24\u4E2A\u7AEF\u70B9",t,{fn:"beam"})}loweringEnter(t){let e=[];for(let o of this.endPoints){let n=t.getTemporalNodes(o).at(-1);for(;n?.foldedInto;)n=n.foldedInto;n&&e.push(n)}return e.length<2?(t.diagnostics.push(I.warning.UnresolvedEndpoint("beam",this.sourceSpan)),[]):(t.addAttachment(oe(e,!0,this.sourceSpan)),t.deferFinalize(r.loweringFinalize),[])}},Js=Ko;var Uo=class extends N{static def={name:["box"],description:"\u7ED9\u76EE\u6807\u7ED3\u6784\u6216\u5BF9\u8C61\u52A0\u5916\u6846",details:`~~~jpfun
|
|
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]}timeFlowModel(){return{children:[this.target],mode:"sequence"}}loweringEnter(t){let e={nodes:[],attachments:[],onTemporal(o){R(o)&&e.nodes.push(o)},onAttachment(o){e.attachments.push(o)}};return t.beginLoweringGroup(this,e),[]}loweringExit(t){let e=t.endLoweringGroup(this),o=new jo(e,this);t.addAttachment(o);let n=e.nodes[0];if(n){if(o.reservedHost){let i=n.prepareLayout;n.prepareLayout=c=>{i.call(n,c);let a={order:1/0,height:Math.max(0,this.padding+this.stroke/2)};n.decorations.push({above:a,below:a})}}let s=n.prepareHorizontal;n.prepareHorizontal=i=>{s?.call(n,i),o.registerHorizontal(i)}}return[]}constructor(t,e,o,n=null){super(t,n);let[s,i,c,a]=this.getArgValue(e,o);s.parent=this,this.target=s,this.padding=o.length2px(i),this.stroke=Math.max(0,o.length2px(c)),this.width=o.length2px(a)}toString(t){return`@box(${this.target.toString(t)}, padding=${this.padding}px, stroke=${this.stroke}px, width=${this.width}px)`}},ti=Uo,jo=class r{content;owner;layer="background";reservedHost;fixedStart=null;wallOffset=0;get sourceSpan(){return this.owner.sourceSpan}constructor(t,e){this.content=t,this.owner=e;let[o]=t.nodes;t.nodes.length===1&&t.attachments.every(n=>n instanceof r&&n.reservedHost===o)&&(this.reservedHost=o)}registerHorizontal(t){let e=this.content.nodes,o=e[0];if(!o)return;if(e.some(a=>a.layoutLine!==o.layoutLine))throw new w("E_BOX_CROSS_LINE","@box \u7684\u5185\u5BB9\u4E0D\u80FD\u8DE8\u8D8A\u8C31\u9762\u884C",this.owner.sourceSpan);let n=o;for(let a of e){let l=t.columnOf(a);if(l<0)return;l<t.columnOf(o)&&(o=a),l>t.columnOf(n)&&(n=a)}let{width:s,padding:i,stroke:c}=this.owner;t.registerHorizontalLayoutHook(o,n,({columns:a,rows:l,start:h,end:p,X:f,fixed:u,options:d})=>{let x=b=>a[b].filter(S=>e.some(C=>C.box===S.box)),m=x(h),g=x(p);if(s>0){let b=Math.max(...m.map(L=>L.WL)),S=Math.max(...g.map(L=>L.WR));if(s<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(u[h-1]||u[p])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 C=f.subarray(h,p+1);if(h===p){let L=(s-b-S)/2;for(let E of m)E.WL+=L;for(let E of g)E.WR+=L;C[0]=b+L}else{qt(a.slice(h,p+1),l,C,u.subarray(h,p),s,d,0);let L=C[C.length-1]-C[0]+b+S;if(Math.abs(L-s)>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=o,this.wallOffset=-C[0]}let y=i+c/2;for(let b of m)b.WL+=y;for(let b of g)b.WR+=y})}createGeometry(t){let{padding:e,stroke:o}=this.owner,n=t.getContentBounds(this.content);if(!n)return{regions:[],paint(){}};let s=e+o/2,c={x:(this.fixedStart?this.fixedStart.box.x+this.fixedStart.box.anchor+this.wallOffset:n.x)-s,y:n.y-s,w:(this.fixedStart?this.owner.width:n.w)+s*2,h:n.h+s*2};if(c.w<o||c.h<o)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:[c],occupancy:this.reservedHost?[]:this.occupancy(t,c),paint(a){let l=o/2;a.drawRect(c.x+l,c.y+l,Math.max(0,c.w-o),Math.max(0,c.h-o),{stroke:"#000",strokeWidth:o})}}}occupancy(t,e){let o=new Set,n,s=(a,l)=>{if(n!==void 0&&n!==a)throw new w("E_BOX_CROSS_LINE","@box \u7684\u5185\u5BB9\u4E0D\u80FD\u8DE8\u8D8A\u8C31\u9762\u884C",this.owner.sourceSpan);n=a,o.add(l)};for(let a of this.content.nodes)s(a.layoutLine,a.track);for(let a of this.content.attachments){if(!St(a))continue;let l=t.getAttachmentOccupancy(a);if(l){for(let h of a.endPoints??[])s(h.layoutLine,h.track);for(let h of l)h.line!==void 0&&s(h.line,h.track)}}if(n===void 0)return[];let i=n,c=[...o].sort((a,l)=>t.getVisualAxis(i,a)-t.getVisualAxis(i,l));return[{...e,h:0,line:i,track:c[0]},{...e,y:e.y+e.h,h:0,line:i,track:c.at(-1)}]}};var Xo=class extends N{static def={name:["dash","-"],description:"\u589E\u65F6\u7EBF",details:"~~~jpfun\n1 @dash()\n~~~\n\u65E0\u53C2\u6570\u3002\u6DFB\u52A0\u4E00\u6839\u589E\u65F6\u7EBF\uFF0C\u6269\u5C55\u524D\u65B9\u97F3\u7B26\u6216\u4F11\u6B62\u7B26\u7684\u5B8C\u6574\u65F6\u503C\uFF1B\u4E5F\u53EF\u7B80\u5199\u4E3A `1 -`\u3002\u6BCF\u6839\u7EBF\u7684\u57FA\u7840\u65F6\u503C\u4E3A\u4E00\u4E2A\u56DB\u5206\u97F3\u7B26\uFF0C\u53EF\u7528\u51CF\u65F6\u7EBF\u6216\u9644\u70B9\u8C03\u6574\u3002\u88C5\u9970\u97F3\u8986\u76D6\u5EF6\u957F\u540E\u7684\u5B8C\u6574\u97F3\u7B26\uFF0C\u4F8B\u5982 `1 ^ $tr -` \u5728\u4E24\u62CD\u5185\u6301\u7EED\u98A4\u97F3\u3002",allowExtraArgs:!1,args:[]};static deSugarAtom(t,e,o){if(t[e]!=="-")return null;let n={kind:"call",typed:!0,name:"-",args:new Map,span:{start:e,end:e+1},syntaxKind:"atom"};return{next:e+1,node:n}}size;constructor(t,e,o,n=null){super(t,n),this.size=o.variables.fontsize}loweringEnter(){return[new Zo(this)]}labelable(){return this}toString(){return"-"}},ei=Xo,Zo=class extends W{lineWidth=0;lineY=0;constructor(t){super(),this.ast=t,this.T.set(1),this.mergeKey=bt,this.initLayoutBox()}onTimeState(t){this.playbackState={bpm:t.bpm}}prepareLayout(){let t=this.ast.size;this.lineWidth=t*.42,this.box.w=this.lineWidth,this.box.h=t,this.box.anchor=this.lineWidth/2,this.lineY=t*.5,this.box.visualAxis=this.lineY}emitPlayback(t){let e=t.start.clone(),o=t.track,n=this.ast.sourceSpan;t.defer(s=>{let i,c=!1;for(let a=s.spans.length-1;a>=0;a--){let l=s.spans[a];if(i){if(l.origins[0]!==i)break}else{if(l.track!==o)continue;i=l.origins[0]}l.end.equals(e)&&(t.extend(l),c=!0)}c||s.diagnostics.push(new z("W_PLAYBACK_SUSTAIN_WITHOUT_TARGET","\u589E\u65F6\u7EBF\u524D\u6CA1\u6709\u53EF\u5EF6\u7EED\u7684\u97F3\u6BB5",n))})}paint(t){t.drawLine(this.box.x,this.box.y+this.lineY,this.box.x+this.lineWidth,this.box.y+this.lineY,{stroke:"#000",strokeWidth:Math.max(1,this.ast.size*.1)})}};var si="dot",oi=Pt(si);function ni(r){let t=2**r;return[2*t-1,t]}var qo=class r extends N{static def={name:[si,"."],description:"\u9644\u70B9",details:"~~~jpfun\n@dot(1, n=2)\n~~~\n**\u7B80\u5199**\uFF1A\u76EE\u6807\u540E\u52A0 `.`\uFF0C\u53EF\u91CD\u590D\u3002`@dot(1, 2)` \u7B49\u4EF7\u4E8E `1..`\uFF1B`{1^2}.` \u7B49\u4EF7\u4E8E `{1.^2}`\u3002\n\n`@dot({1 2/ -}, 2)` \u5305\u542B\u591A\u4E2A\u65F6\u95F4\u5143\u7D20\uFF0C\u4F1A\u62A5\u9519\uFF1B\u9700\u8981\u5206\u522B\u4E3A\u5404\u5143\u7D20\u6DFB\u52A0\u9644\u70B9\u3002",allowExtraArgs:!1,args:[{type:"content",description:"\u5355\u4E2A\u53EF\u89C1\u65F6\u95F4\u5143\u7D20\uFF0C\u5982\u97F3\u7B26\u3001\u589E\u65F6\u7EBF\u6216\u6298\u53E0\u548C\u5F26",default:null},{name:"n",description:"\u9644\u70B9\u6570\uFF0C\u7B2C\u4E00\u70B9\u589E\u52A0\u539F\u65F6\u503C\u7684\u4E00\u534A\uFF0C\u540E\u7EED\u5404\u70B9\u589E\u52A0\u91CF\u518D\u51CF\u534A",type:"number",default:1}]};static deSugarAtom(t,e,o){let n=0,s=e;for(;s<o&&t[s]===".";)n++,s++;return n===0?null:{next:s,node:{kind:"sugar",data:{class:r,n},span:{start:e,end:s}}}}static deSugarRelation(t,e,o){let n=e[o++];if(n.data?.class!==r)return null;let s=N.findLastFuncContentIndex(t.nodes,t.nodes.length-1);if(s<0)return o;let i=t.nodes[s];if(i instanceof r)return i.n+=n.data.n,o;let c=new Map;c.set(0,i),c.set("n",n.data.n);let a=i.sourceSpan,l=new r({start:Math.min(a.start,n.span.start),end:Math.max(a.end,n.span.end)},c,t,null);return t.nodes[s]=l,o}static layoutDecorationHandler=(t,e)=>{let o=Math.max(0,Math.floor(Number(e)||0));if(o===0)return null;let n=t.ast.size*.075,s=t.ast.size*.12,i=t.ports.dot??{x:t.box.w,y:t.box.visualAxis},c=i.x+s+n,a=n*2+s,l=c+(o-1)*a+n;return t.box.w=Math.max(t.box.w,l),{paint(h){let p=t.box.y+i.y;for(let f=0;f<o;f++)h.drawCircle(t.box.x+c+f*a,p,n,{fill:"#000"})}}};loweringEnter(t){let e=this.n,o={temporalCount:0,onTemporal(n){if(o.temporalCount++,e===0)return;let s=n.addon??={},i=Number(s[oi])||0,c=i+e,[a,l]=ni(c),[h,p]=ni(i);n.T.mul(a*p,l*h),s[oi]=c}};return t.beginLoweringGroup(this,o),[]}loweringExit(t){let e=t.endLoweringGroup(this);if(e.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:e.temporalCount});return[]}timeFlowModel(){return{children:[this.content],mode:"sequence"}}content;n;get children(){return[this.content]}constructor(t,e,o,n=null){super(t,n),[this.content,this.n]=this.getArgValue(e,o),this.content.parent=this;let s=Math.max(0,Math.trunc(this.n));s!==this.n&&(o.diagnostics.push(new z("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:s})),this.n=s)}toString(t){return`@dot(${this.content.toString(t)}, ${this.n})`}},ii=qo;function Ue(r,t,e=!1){let o=0,n=r.length;for(;o<n;){let s=o+n>>>1,i=r[s].host.t.compare(t);(e?i<=0:i<0)?o=s+1:n=s}return o}var Qo=class r extends N{static def={name:["dyn"],description:"\u6E10\u5F3A\u6E10\u5F31",details:`~~~jpfun
|
|
19
|
-
1 ^ $p 2@a 3 4@b
|
|
20
|
-
@dyn(a, b, 24)
|
|
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
|
|
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(t){let e=t.attachments.filter(n=>n instanceof Se);if(e.length===0)return;let o=new Map(e.map(n=>[n.track,[]]));for(let n of t.astToTemporal.values())for(let s of n){let i=s.playbackState?.velocity;if(i===void 0)continue;let c=s;for(;c.foldedInto;)c=c.foldedInto;o.get(c.track)?.push({node:s,host:c,velocity:i,increment:0})}for(let n of o.values())n.sort((s,i)=>s.host.t.compare(i.host.t)||s.node.order-i.node.order);for(let n of e){let s=o.get(n.track),i=Ue(s,n.toHost.t),c=Ue(s,n.toHost.t,!0),a=n.end.playbackState?.velocity;for(let f=i;a===void 0&&f<c;f++)s[f].host===n.toHost&&(a=s[f].velocity);if(a??=s[c-1]?.velocity,a===void 0){t.diagnostics.push(new z("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",n.sourceSpan));continue}let l=s.length;for(let f=c;f<s.length;f++)if(s[f].velocity!==a){l=Ue(s,s[f].host.t);break}let h=Ue(s,n.fromHost.t),p=n.toHost.t.clone().sub(n.fromHost.t);for(let f=h;f<l;f++){let u=f>=i?1:s[f].host.t.clone().sub(n.fromHost.t).div(p).toNumber();s[f].increment+=n.dv*u}}for(let n of o.values())for(let s of n){if(s.increment===0)continue;let i=Math.max(1,Math.min(127,s.velocity+s.increment));s.node.playbackState={...s.node.playbackState,velocity:i}}}from;to;dv;size;loweringEnter(t){let e=t.getTemporalNodes(this.from).at(0),o=t.getTemporalNodes(this.to).at(-1);if(!e||!o)return t.diagnostics.push(I.warning.UnresolvedEndpoint("dyn",this.sourceSpan)),[];let n=e,s=o;for(;n.foldedInto;)n=n.foldedInto;for(;s.foldedInto;)s=s.foldedInto;if(!R(n)||!R(s))return t.diagnostics.push(I.warning.UnresolvedEndpoint("dyn",this.sourceSpan)),[];if(n.track!==s.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(n.t.equals(s.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 n.t.compare(s.t)<0?t.addAttachment(new Se(this,o,n,s)):t.addAttachment(new Se(this,e,s,n)),t.deferFinalize(r.loweringFinalize),[]}constructor(t,e,o,n=null){super(t,n);let[s,i,c]=this.getArgValue(e,o),a=c;if(!Number.isFinite(a)||a===0)throw new w("E_DYN_INVALID_DELTA","@dyn \u7684 dv \u5FC5\u987B\u662F\u975E\u96F6\u6709\u9650\u6570",t);a=Math.max(-127,Math.min(127,a)),a!==c&&o.diagnostics.push(new z("W_DYN_DELTA_CLAMPED","@dyn \u7684 dv \u5FC5\u987B\u5728 -127 \u5230 127 \u4E4B\u95F4\uFF0C\u5DF2\u88AB\u9650\u5236\u4E3A {dv}",t,{dv:a})),this.from=s,this.to=i,this.dv=a,this.size=o.variables.fontsize}toString(t){let e=o=>o.label??o.toString(t);return`@dyn(${e(this.from)}, ${e(this.to)}, ${this.dv})`}},ri=Qo,Se=class{ast;end;fromHost;toHost;layer="foreground";constructor(t,e,o,n){this.ast=t,this.end=e,this.fromHost=o,this.toHost=n}get sourceSpan(){return this.ast.sourceSpan}get endPoints(){return[this.fromHost,this.toHost]}get dv(){return this.ast.dv}get track(){return this.fromHost.track}createGeometry(t){let e=this.fromHost.layoutLine,o=this.toHost.layoutLine,n=[this.fromHost,this.toHost],s=[],i=this.ast.size;for(let d=e;d<=o;d++){let x=t.getRangeColumns(d,n,this.track);if(x.some(m=>m.length>0)){for(let m of x)for(let g of m)i=Math.max(i,g.ast.size);s.push({line:d,startX:d===e?this.fromHost.box.x:this.lineEntryX(t,d),endX:d===o?this.toHost.box.x+this.toHost.box.w:this.lineRightX(t,d)})}}for(let d of s)d.line>e&&(d.startX-=i/4);let c=Math.max(.75,i*.035),a=s.filter(d=>d.startX!==d.endX),l=a.reduce((d,x)=>d+Math.abs(x.endX-x.startX),0);if(l===0)return{regions:[],paint(){}};let h=i*.4,p=c/2,f=0,u=a.map(d=>{let x=Math.abs(d.endX-d.startX),m=f/l,g=(f+x)/l;f+=x;let y=t.getRangeExtents(d.line,n,this.track),b=t.getVisualAxis(d.line,this.track),S=y?b+y.top:b;return{line:d.line,startX:d.startX,endX:d.endX,lineY:S-i*.62,startOpen:h*(this.dv>0?m:1-m),endOpen:h*(this.dv>0?g:1-g)}});return{regions:u.map(d=>({x:Math.min(d.startX,d.endX)-p,y:d.lineY-Math.max(d.startOpen,d.endOpen)/2-p,w:Math.abs(d.endX-d.startX)+c,h:Math.max(d.startOpen,d.endOpen)+c,line:d.line,track:this.track})),paint(d){let x={stroke:"#000",strokeWidth:c};for(let m of u)d.drawLine(m.startX,m.lineY-m.startOpen/2,m.endX,m.lineY-m.endOpen/2,x),d.drawLine(m.startX,m.lineY+m.startOpen/2,m.endX,m.lineY+m.endOpen/2,x)}}}lineEntryX(t,e){return t.lines[e].trackRuns.get(this.track)?.find(n=>!n.T.isZero())?.box.x??t.originX}lineRightX(t,e){let o=t.lines[e].trackRuns;if(o.size===0)return t.originX+t.width;let n=t.originX;for(let s of o.values())for(let i of s)n=Math.max(n,i.box.x+i.box.w);return n}};var Bt=class r{parent;groups=[];constructor(t=null){this.parent=t}group(t,e){let o=this.groups.find(n=>n.laneKey===t.laneKey);for(o||(o={laneKey:t.laneKey,members:[],measure:t.measure,place:t.place},this.groups.push(o));o.members.length<e;)o.members.push(new r(this));return o}};var ne=.7,ci="shoulder";function ai(r,t){let e=r;typeof e.size=="number"&&(e.size*=t);for(let o of r.children??[])ai(o,t)}var Jo=class r extends N{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 N.findLabelable(this.host)}static deSugarAtom(t,e,o){let n=t[e];switch(n){case">":n="pre";break;case"<":n="post";break;default:return null}return{next:e+1,node:{kind:"sugar",data:{class:r,side:n},span:{start:e,end:e+1}}}}static deSugarRelation(t,e,o){let n=e[o++];if(n.kind!=="sugar"||n.data?.class!==r)return null;let s=n.data.side,i=t.nodes.length-1;for(;i>=0&&t.nodes[i]instanceof et;)i--;if(i<0)throw new w("E_GRACE_NO_TARGET","@grace\u8BED\u6CD5\u7CD6\u9519\u8BEF: \u5DE6\u8FB9\u6CA1\u6709\u627E\u5230\u76EE\u6807",n.span);let c=t.nodes[i],a=i;if(c instanceof wt){let h=c.target;for(;h&&!t.nodes.includes(h);)h=h.parent;for(let p=i-1;p>=0;p--)if(t.nodes[p]===h){c=new tt({start:h.sourceSpan.start,end:c.sourceSpan.end},t.nodes.slice(p,i+1),null),a=p;break}}let l=t.nodes;t.nodes=[],t.makeNodes(e,o);for(let h=0;h<t.nodes.length;h++){let p=t.nodes[h];if(p instanceof et)continue;let f=s==="pre"?r.attachPre(c,p,n.span,t):r.create(t,n.span,"post",c,p);for(l.length=a,l.push(f);++h<t.nodes.length;)l.push(t.nodes[h]);return t.nodes=l,e.length}throw new w("E_GRACE_NO_TARGET","@grace\u8BED\u6CD5\u7CD6\u9519\u8BEF: \u53F3\u8FB9\u6CA1\u6709\u627E\u5230\u76EE\u6807",n.span)}host;grace;side="pre";size;static attachPre(t,e,o,n){if(e instanceof r&&e.side==="pre"){let s=e,i=1;for(;s.grace instanceof r&&s.grace.side==="pre";)s=s.grace,i++;let c=new Map;c.set(0,s.grace),c.set(1,t);let a=ne**i,l=new r(o,c,n,null,ne*a);return l.size*=a,s.setGrace(l,1),e}return r.create(n,o,"pre",e,t)}static create(t,e,o,n,s){let i=new Map;return i.set(0,n),i.set(1,s),i.set("side",o),new r(e,i,t)}get children(){let t=[];return this.host&&t.push(this.host),this.grace&&t.push(this.grace),t}constructor(t,e,o,n=null,s=ne){if(super(t,n),this.size=o.variables.fontsize,[this.host,this.grace,this.side]=this.getArgValue(e,o),this.side!=="pre"&&this.side!=="post")throw new w("E_GRACE_INVALID_SIDE","@grace \u7684 side \u53C2\u6570\u5FC5\u987B\u662F 'pre' \u6216 'post'",t);this.adopt(this.host),this.setGrace(this.grace,s)}setGrace(t,e=ne){ai(t,e),this.grace=t,this.adopt(t)}adopt(t){t.parent=this,this.sourceSpan.start=Math.min(this.sourceSpan.start,t.sourceSpan.start),this.sourceSpan.end=Math.max(this.sourceSpan.end,t.sourceSpan.end)}loweringEnter(t,e){let o=this.host,n=this.grace;if(!o||!n)throw new w("E_GRACE_MISSING_ARGS","@grace \u9700\u8981\u540C\u65F6\u7ED9\u51FA\u5BBF\u4E3B\u548C\u501A\u97F3",this.sourceSpan);let s=new Bt(e),i=[],c=[],a=[],l=(u,d)=>t.trackedEvents(u,new P,d);t.isolateFromLoweringGroups(()=>{this.side==="post"&&(i=l(o,e).flat()),t.beginLoweringGroup(this,{onAttachment(u){a.push(u)}}),c=l(n,s),t.endLoweringGroup(this),this.side==="pre"&&(i=l(o,e).flat())});let[h]=i;if(i.length!==1||!R(h))throw new w("E_GRACE_INVALID_HOST","@grace \u7684\u5BBF\u4E3B\u5FC5\u987B\u6070\u597D\u4EA7\u751F\u4E00\u4E2A\u53EF\u89C1 Temporal",o.sourceSpan);let p=c.flat();if(!p.some(R)||p.some(u=>(u.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",n.sourceSpan);let f=new tn(this,h,c,s,a,this.side);for(let u of f.graceRuns)u.length<2||t.addAttachment(oe([...u],!1,n.sourceSpan));return[f]}toString(t){let e=this.host?.toString(t)??"",o=this.grace?.toString(t)??"";return`@grace(${e}, ${o}, side=${this.side})`}},li=Jo,Cc=[{op:"M",x:0,y:0},{op:"C",cx1:-.01,cy1:.26,cx2:.14,cy2:.42,x:.29,y:.36}],Ac=.07,Lc=.18,tn=class extends W{host;graceColumns;graces;graceRuns;side;root;attachments;events;starts;hostOffset={x:0,y:0};graceOffsets=[];hookOrigin=null;constructor(t,e,o,n,s,i){super(),this.ast=t,this.host=e,this.root=n,this.attachments=s,this.side=i,this.T.copyFrom(e.T),this.mergeKey=e.mergeKey,this.initLayoutBox(),e.addon&&(this.addon={...e.addon}),e.addon=void 0,e.foldedInto=this;let c=[],a=[],l=[];for(let f of o){let u=f[0].t.clone().divPow2(),d=[];for(let x of f)x.foldedInto=this,a.push(x),l.push(u),R(x)&&d.push(x);d.length>0&&c.push(d)}this.graceColumns=c,this.graces=c.flat(),this.events=a,this.starts=l;let h=new Map,p=[];for(let f of this.graces){if(f.T.isZero()){h.delete(f.track);continue}let u=h.get(f.track);u||(h.set(f.track,u=[]),p.push(u)),u.push(f);let d=f.addon={...f.addon};d[Dt]=(Number(d[Dt])||0)+1,f.T.divPow2()}this.graceRuns=p}onTimeState(t){this.host.T.copyFrom(this.T);let e;for(let o of this.side==="pre"?[...this.events,this.host]:[this.host,...this.events]){o.t.copyFrom(this.t),o.layoutLine=this.layoutLine;let n=o.onTimeState?.(t);o===this.host&&(this.T.copyFrom(o.T),e=n)}return e}prepareHorizontal(t){this.host.prepareHorizontal?.(t)}emitPlayback(t){let e=new P,o=new P;this.events.forEach((h,p)=>{o.copyFrom(this.starts[p]).add(h.T),o.compare(e)>0&&e.copyFrom(o)});let n=t.end.clone().sub(t.start),s=new P(1,4),i=e.clone().mul(s),c=n.clone().divPow2();i.compare(c)>0&&(s.copyFrom(c).div(e),i.copyFrom(c));let a=n.sub(i),l=this.side==="pre"?t.start.clone():t.start.clone().add(a);this.side==="post"&&t.play(this.host,t.start.clone(),a),this.events.forEach((h,p)=>{t.play(h,this.starts[p].clone().mul(s).add(l),h.T.clone().mul(s))}),this.side==="pre"&&t.play(this.host,l.add(i),a)}prepareLayout(t){zt(this,this.host);let e=t.layoutSubdomain(this,this.graceColumns,this.root,this.attachments),o=te([this.host],t);this.springConfig={...this.host.springConfig,...this.springConfig};let n=this.ast.size*ne,s=n*.2,i=n*Lc,a=(this.host.ports[ci]?.y??0)-i-e.height,l=st(this.host),h=Math.max(0,-a,-l.y),p=this.side==="pre"?0:o+s;this.hostOffset={x:this.host.box.x+(this.side==="pre"?e.width+s:0),y:h},this.graceOffsets=e.positions.map(d=>({x:p+d.x,y:a+h+d.y})),this.box.w=o+s+e.width,this.box.h=h+l.y+l.h,this.box.anchor=this.hostOffset.x+this.host.box.anchor,this.box.visualAxis=h+this.host.box.visualAxis;for(let d in this.host.ports){let x=this.host.ports[d];this.ports[d]={...x,x:this.hostOffset.x+x.x,y:this.hostOffset.y+x.y}}this.ports[ci]??={x:this.box.anchor,y:this.hostOffset.y};let f=this.graces.filter(d=>!d.T.isZero()),u=this.side==="pre"?f.at(-1):f[0];this.hookOrigin=u?{x:this.graceOffsets[this.graces.indexOf(u)].x+u.box.anchor,y:Math.max(...this.graces.map((d,x)=>this.graceOffsets[x].y+d.box.h))}:null}onPlaced(){this.host.box.x=this.box.x+this.hostOffset.x,this.host.box.y=this.box.y+this.hostOffset.y,this.host.onPlaced?.(),this.graces.forEach((t,e)=>{t.box.x=this.box.x+this.graceOffsets[e].x,t.box.y=this.box.y+this.graceOffsets[e].y,t.onPlaced?.()})}paint(t){for(let s of[this.host,...this.graces]){s.paint(t);for(let i of s.decorations)i.paint?.(t)}if(!this.hookOrigin)return;let e=this.ast.size*ne,o=this.hookOrigin,n=this.side==="pre"?1:-1;t.drawPath(Cc,{stroke:"#000",strokeWidth:Math.max(.8,e*Ac)},{x:this.box.x+o.x,y:this.box.y+o.y,scaleX:e*n,scaleY:e})}};function Ae(r){let{resolvedMidi:t}=r;return typeof t=="number"?t:void 0}function hi(r,t){if("resolvedMidi"in t)return Ae(t)!==void 0?t:void 0;let e=Ce(t);for(let o=r.findIndex(n=>n.includes(e))-1;o>=0;o--){let n=r[o].find(s=>s.track===e.track&&"resolvedMidi"in s);if(n)return Ae(n)!==void 0?n:void 0}}var en=class extends N{static def={name:["gliss"],description:"\u6ED1\u97F3\u8FDE\u7EBF",details:`~~~jpfun
|
|
25
|
-
1 -@a 5@b @gliss(a, b)
|
|
26
|
-
~~~
|
|
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(t,e,o,n=null){super(t,n),[this.from,this.to]=this.getArgValue(e,o)}loweringEnter(t){let e=t.getTemporalNodes(this.from).at(-1),o=t.getTemporalNodes(this.to).at(-1);if(!e||!o||!R(e)||!R(o))throw new w("E_GLISS_ENDPOINT","@gliss \u7684\u6807\u7B7E\u5FC5\u987B\u6307\u5411\u5DF2\u751F\u6210\u4E14\u5177\u6709\u6392\u7248\u76D2\u5B50\u7684\u5BF9\u8C61",this.sourceSpan);let n=new on(e,o,this.sourceSpan);return t.addAttachment(n),t.deferFinalize(s=>n.finalize(s),1),[]}toString(t){let e=this.from instanceof N?this.from.label:void 0,o=this.to instanceof N?this.to.label:void 0;return e&&o?`@gliss(${e}, ${o})`:t.slice(this.sourceSpan.start,this.sourceSpan.end)}},pi=en;function Ce(r,t){for(;r.foldedInto&&R(r.foldedInto)&&(!t||t.columnOf(r)<0);)r=r.foldedInto;return r}var on=class{sourceSpan;layer="foreground";endPoints;direction;constructor(t,e,o){this.sourceSpan=o,this.endPoints=[t,e]}finalize({columns:t,diagnostics:e}){let[o,n]=this.endPoints,s=Ce(o),i=Ce(n);if(s.t.equals(i.t))throw new w("E_GLISS_ORDER","@gliss \u4E24\u4E2A\u7AEF\u70B9\u4E0D\u80FD\u4F4D\u4E8E\u540C\u4E00\u65F6\u523B",this.sourceSpan);if(s.layoutLine!==i.layoutLine)throw new w("E_GLISS_CROSS_LINE","@gliss \u4E0D\u652F\u6301\u8DE8\u8C31\u9762\u884C",this.sourceSpan);s.t.compare(i.t)>0&&(this.endPoints=[n,o]);let[c,a]=this.endPoints,l=hi(t,c),h=hi(t,a);if(!l||!h){e.push(new z("W_GLISS_NO_PITCH","@gliss \u7AEF\u70B9\u6CA1\u6709\u53EF\u7528\u97F3\u9AD8",this.sourceSpan));return}this.direction=Math.sign(Ae(h)-Ae(l));let p=c.emitPlayback,f=Ae(h)+(h.playbackState?.pitchShift??0);c.emitPlayback=u=>{p?.call(c,u);let{start:d,end:x}=u;u.defer(m=>{for(let g=m.notes.length-1;g>=0;g--){let y=m.notes[g];if(y.track===u.track){y.end.equals(x)&&m.transform(y,(b,S)=>{let C=S.at(-1),L=d.compare(C.start)>0?d:C.start,E=C.midi,_=Math.abs(f-E);if(C.end.compare(L)<=0||_<=1)return;let v=f>E?1:-1,k=C.end.clone().sub(L).div(_),F=S.slice(0,-1);for(let A=0;A<_;A++)F.push({...C,start:A===0?C.start.clone():k.clone().mul(A).add(L),end:k.clone().mul(A+1).add(L),midi:E+A*v});return F});break}}})}}prepareHorizontal(t){let[e,o]=this.endPoints,n=t[e.layoutLine],s=n&&Ce(e,n),i=n&&Ce(o,n),c=s?n.columnOf(s):-1,a=i?n.columnOf(i):-1;if(!n||c<0||a<=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 l=s.box.w-s.box.anchor+Math.max(e.ast.size,o.ast.size)*1.4;n.registerHorizontalLayoutHook(s,i,({columns:h})=>{for(let p of h[c])p.WR=Math.max(p.WR,l)})}createGeometry(){let[t,e]=this.endPoints,o=Math.max(t.ast.size,e.ast.size),n=o*.12,s={x:t.box.x+t.box.w+n,y:t.box.y+t.box.visualAxis},i={x:e.box.x-n,y:e.box.y+e.box.visualAxis};if(t.track===e.track&&(this.direction===void 0?i.y=s.y:(s.y+=this.direction*o*.24,i.y-=this.direction*o*.24)),i.x<=s.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 c=Math.atan2(i.y-s.y,i.x-s.x),a=Math.min(o*.3,Math.hypot(i.x-s.x,i.y-s.y)*.35),l=d=>({x:i.x-a*Math.cos(c+d),y:i.y-a*Math.sin(c+d)}),h=[{op:"M",...s},{op:"L",...i},{op:"M",...l(-Math.PI/6)},{op:"L",...i},{op:"L",...l(Math.PI/6)}],p=o*.05,f=ut(h),u={x:f.x-p/2,y:f.y-p/2,w:f.w+p,h:f.h+p};return{regions:[{...u,line:t.layoutLine,track:t.track}],occupancy:t.track===e.track?[{...u,line:t.layoutLine,track:t.track}]:[],paint:d=>{d.drawPath(h,{fill:"none",stroke:"#000",strokeWidth:p})}}}};var nn=class extends N{static def={name:["slide"],description:"\u6ED1\u5165\u6216\u6ED1\u51FA\u8BB0\u53F7",details:`~~~jpfun
|
|
28
|
-
@slide(5, side=pre, direction=up)
|
|
29
|
-
~~~
|
|
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]}timeFlowModel(){return{children:this.children,mode:"sequence"}}labelable(){return N.findLabelable(this.content)}constructor(t,e,o,n=null){super(t,n);let[s,i,c]=this.getArgValue(e,o);if(i!=="pre"&&i!=="post")throw new w("E_SLIDE_SIDE","@slide \u7684 side \u5FC5\u987B\u662F pre \u6216 post",t);if(c!=="up"&&c!=="down")throw new w("E_SLIDE_DIRECTION","@slide \u7684 direction \u5FC5\u987B\u662F up \u6216 down",t);this.content=s,this.side=i,this.direction=c,s.parent=this}loweringEnter(t){let e=this.side==="pre",o={onTemporal(n){R(n)&&(!e||!o.host)&&(o.host=n)}};return t.beginLoweringGroup(this,o),[]}loweringExit(t){let{host:e}=t.endLoweringGroup(this);if(!e)throw new w("E_SLIDE_CONTENT","@slide \u7684\u5185\u5BB9\u5FC5\u987B\u5305\u542B\u53EF\u7ED8\u5236\u5BF9\u8C61",this.sourceSpan);let o=new sn(e,this);t.addAttachment(o);let n=e.prepareHorizontal;return e.prepareHorizontal=s=>{n?.call(e,s),!(s.columnOf(e)<0)&&s.registerHorizontalLayoutHook(e,e,({columns:i,start:c})=>{let a=this.side==="pre",l=a?"WL":"WR",p=(a?e.box.anchor:e.box.w-e.box.anchor)+o.length+e.ast.size*.22;for(let f of i[c])f.box===e.box&&(f[l]=Math.max(f[l],p))})},[]}toString(t){return`@slide(${this.content.toString(t)}, side=${this.side}, direction=${this.direction})`}},fi=nn,sn=class{host;owner;layer="foreground";endPoints;get sourceSpan(){return this.owner.sourceSpan}constructor(t,e){this.host=t,this.owner=e,this.endPoints=[t]}get length(){let{host:t}=this;return t.box.visualAxis-(t.ports.shoulder?.y??0)+t.ast.size*.1}createGeometry(){let{host:t,owner:e}=this,o=t.ast.size,n=e.side==="pre",s=this.length,i=e.direction==="up",c=t.box.y+t.box.visualAxis,a=n?t.box.x-o*.12-s:t.box.x+t.box.w+o*.12,l={x:a,y:i?c:c-s},h={x:a+s,y:i?c-s:c},p=i?-Math.PI/4:Math.PI/4,f=g=>({x:h.x-o*.25*Math.cos(p+g),y:h.y-o*.25*Math.sin(p+g)}),u=[{op:"M",...l},{op:"L",...h},{op:"M",...f(-Math.PI/6)},{op:"L",...h},{op:"L",...f(Math.PI/6)}],d=o*.05,x=ut(u);return{regions:[{x:x.x-d/2,y:x.y-d/2,w:x.w+d,h:x.h+d,line:t.layoutLine,track:t.track}],paint(g){g.drawPath(u,{fill:"none",stroke:"#000",strokeWidth:d})}}}};var se="sans-serif",cn="'Cascadia Mono', Consolas, 'Liberation Mono', 'Noto Sans Mono', monospace";function Xe(r){return`${r.fontStyle?`${r.fontStyle} `:""}${r.fontWeight??"normal"} ${r.fontSize}px ${r.fontFamily??se}`}var je=class{measureText(t,e){let o=e.fontSize,n=e.fontFamily?.toLowerCase().includes("mono")??!1,s=0;for(let i of t)s+=i.charCodeAt(0)>127?1:n?.62:.58;return{w:Math.max(s*o,o*.25),h:o,baseline:o*.8}}},an=new je,rn=class{context;widths=new Map;constructor(t){this.context=t}clearCache(){this.widths.clear()}measureText(t,e){let o=Xe(e),n=`${o}\0${t}`,s=this.widths.get(n);return s===void 0&&(this.context.font=o,s=this.context.measureText(t).width,this.widths.set(n,s)),{w:Math.max(s,e.fontSize*.25),h:e.fontSize,baseline:e.fontSize*.8}}};var Tc=/[A-Za-z0-9_./-]/;function Te(r,t,e){let o=t+1;for(;o<e&&Tc.test(r[o]);)o++;let n=r.slice(t+1,o);if(!n||o>=e||r[o]!=="(")return null;let s=o,i=1,c=0,a=null,l=!1,h=[],p=s+1,f=(d,x,m=!1)=>{let g=Le(r,p,d);if(!m&&g.start>=g.end)return;let y=Ec(r,g.start,g.end),b=y>g.start?Le(r,g.start,y):void 0,S=y>g.start?Le(r,y+1,g.end):g;h.push({span:g,valueSpan:S,nameSpan:b,equalsSpan:y>g.start?{start:y,end:y+1}:void 0,commaSpan:x===void 0?void 0:{start:x,end:x+1}})},u=(d,x)=>({name:n,span:{start:t,end:d},nameSpan:{start:t,end:s},openParenSpan:{start:s,end:s+1},closeParenSpan:x,args:h});for(o++;o<e;o++){let d=r[o];if(a){l?l=!1:d==="\\"?l=!0:d===a&&(a=null);continue}if(d==='"'){a=d;continue}if(d==="{")c++;else if(d==="}")c=Math.max(0,c-1);else if(d==="("&&c===0)i++;else if(d===")"&&c===0){if(--i)continue;return f(o),u(o+1,{start:o,end:o+1})}else d===","&&i===1&&c===0&&(f(o,o,!0),p=o+1)}return f(e),u(e)}var ui=/\s/;function Le(r,t,e){let o=t,n=e;for(;o<n&&ui.test(r[o]);)o+=1;for(;n>o&&ui.test(r[n-1]);)n-=1;return{start:o,end:n}}function Ec(r,t=0,e=r.length){let o=0,n=0,s=null,i=!1;for(let c=t;c<e;c++){let a=r[c];if(s){i?i=!1:a==="\\"?i=!0:a===s&&(s=null);continue}if(a==='"')s=a;else if(a==="("&&n===0)o++;else if(a===")"&&n===0)o=Math.max(0,o-1);else if(a==="{")n++;else if(a==="}")n=Math.max(0,n-1);else if(a==="="&&o===0&&n===0)return c}return-1}function di(r,t,e){let o=1,n=null,s=!1;for(let i=t;i<e;i++){let c=r[i];if(n){s?s=!1:c==="\\"?s=!0:c===n&&(n=null);continue}if(c==='"')n=c;else if(c==="(")o++;else if(c===")"&&--o===0)return i}return-1}function Mt(r,t,e){for(let o=t+1;o<e;o++)if(r[o]==="\\")o++;else if(r[o]==='"')return o;return-1}function mi(r){if(r.length<2||!r.startsWith('"')||!r.endsWith('"'))return r;let t,e=r.slice(1,-1).replace(/\\(u.{0,4}|.)/gs,(o,n,s)=>{if(n[0]!=="u")return n;if(!/^u[0-9a-f]{4}$/i.test(n)){let i=s+1;return t??=I.warning.InvalidUnicodeEscape({start:i,end:i+o.length}),o}return String.fromCharCode(Number.parseInt(n.slice(1),16))});return t??e}function ht(r){return`"${r.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function xi(r,t,e){let o=1,n=null,s=!1;for(let i=t+1;i<e;i++){let c=r[i];if(n){s?s=!1:c==="\\"?s=!0:c===n&&(n=null);continue}if(c==='"')n=c;else if(c==="{")o++;else if(c==="}"&&(o--,o===0))return i}return-1}var kc=/\s|\(|\)|\{|\}|,/;function yi(r,t,e){let o=t+1;for(;o<e&&!kc.test(r[o]);)o++;return o<=t+1?null:{label:r.slice(t+1,o),next:o}}var Nc=/^(-?(?:\d+(?:\.\d*)?|\.\d+))([a-z%]+)?$/i,_c=["em","px"];function ln(r){let t=r.match(Nc);if(!t)return I.warning.InvalidLength(r,{start:0,end:r.length});let e=parseFloat(t[1]);if(!Number.isFinite(e))return I.warning.InvalidLength(r,{start:0,end:r.length});if(t[2]){let o=t[2].toLowerCase();return _c.includes(o)?{value:e,unit:o}:I.warning.InvalidLengthUnit(o,{start:t[1].length,end:r.length})}else return{value:e,unit:"px"}}var gi=/^(true|false)$/;function vc(r,t){if(r)return r==="content"?void 0:r;if(gi.test(t))return"boolean";if(t.startsWith('"'))return"string";if(!isNaN(Number(t)))return"number";if(!(ln(t)instanceof I))return"length"}var bi=22,Mc=4,dt=class r{static systemVariables={fontsize:{type:"length",default:bi},font:{type:"string",default:se},numberfont:{type:"string",default:cn},strict:{type:"boolean",default:!1}};scopeDepth;source;syntax;commentIndex;diagnostics;variables;documentDeclarations;functions;deSugarAtomFns;deSugarRelationFns;labelableNodes;nodes;constructor(t){t instanceof r?(this.scopeDepth=t.scopeDepth+1,this.documentDeclarations=t.documentDeclarations,this.source=t.source,this.diagnostics=t.diagnostics,this.syntax=t.syntax,this.commentIndex=t.commentIndex,this.variables={...t.variables},this.functions=t.functions,this.deSugarAtomFns=t.deSugarAtomFns,this.deSugarRelationFns=t.deSugarRelationFns,this.labelableNodes=t.labelableNodes,this.nodes=[]):(this.scopeDepth=0,this.documentDeclarations={},this.source=t.source,this.diagnostics=t.diagnostics??[],this.syntax={tokens:(t.commentSpans??[]).map(e=>({kind:"comment",span:e})),calls:[]},this.commentIndex=0,this.variables=Object.fromEntries(Object.entries(r.systemVariables).map(([e,o])=>[e,o.default])),Object.assign(this.variables,t.variables),this.functions=t.functions??new Map,this.labelableNodes=t.labelableNodes??[],this.nodes=t.toConsume??[],t.functions?[this.deSugarAtomFns,this.deSugarRelationFns]=r.getDeSugarFns(this.functions.values()):(this.deSugarAtomFns=[],this.deSugarRelationFns=[]))}static getDeSugarFns(t){let e=new Set(t),o=[],n=[];for(let s of e){let i=s.deSugarAtom;i&&i!==N.deSugarAtom&&o.push(i);let c=s.deSugarRelation;c&&c!==N.deSugarRelation&&n.push(c)}return[o,n]}pushNode(t){this.nodes.push(t);let e=t.labelable?.();e!==void 0&&this.labelableNodes.push(e)}setVariable(t,e){Object.hasOwn(r.systemVariables,t)&&(t==="fontsize"&&e&&(e=this.length2px(e)),(e===void 0||e===""||e===0)&&(e=r.systemVariables[t].default)),this.variables[t]=e}registerFunctions(t){let e=this.functions;for(let o of t){let n=o.def;if(!n)continue;let s=Array.isArray(n.name)?n.name:[n.name];for(let i of s){if(e.has(i.toLowerCase()))throw new Error(`Duplicate function name detected: ${i}`);e.set(i.toLowerCase(),o)}}[this.deSugarAtomFns,this.deSugarRelationFns]=r.getDeSugarFns(this.functions.values())}parse(t=0,e=this.source.length){return this.makeNodes(this.parseGrammar(t,e)),this.nodes}parseSyntax(t=0,e=this.source.length){if(this.parseGrammar(t,e,!0),this.scopeDepth===0){let o=(n,s)=>n.span.start-s.span.start||n.span.end-s.span.end;this.syntax.tokens.sort(o),this.syntax.calls.sort(o)}return this.syntax}addSyntax(t,e){if(!e||e.start>=e.end)return;let o=e.start,n=this.syntax.tokens;for(;n[this.commentIndex]?.kind==="comment"&&n[this.commentIndex].span.end<=o;)this.commentIndex++;for(let s=this.commentIndex;s<n.length;s++){let i=n[s];if(i.kind!=="comment"||i.span.start>=e.end)break;o<i.span.start&&n.push({kind:t,span:{start:o,end:i.span.start}}),o=i.span.end,this.commentIndex=s+1}o<e.end&&n.push({kind:t,span:{start:o,end:e.end}})}recordSyntax(t){if(t.kind==="brace"){this.addSyntax("punctuation",{start:t.span.start,end:t.span.start+1});let c=Math.min(this.source.length,t.span.end-1);new r(this).parseSyntax(t.span.start+1,c),this.source[c]==="}"&&this.addSyntax("punctuation",{start:c,end:c+1});return}if(t.kind==="label"){this.addSyntax("label",t.span);return}if(t.kind==="sugar"||t.typed){this.addSyntax(t.syntaxKind??"operator",t.span);return}let{kind:e,typed:o,syntaxKind:n,...s}=t;this.syntax.calls.push(s),this.addSyntax("function",s.nameSpan),this.addSyntax("punctuation",s.openParenSpan);let i=this.functions.get(s.name.toLowerCase())?.def;for(let c=0;c<s.args.length;c++){let a=s.args[c];this.addSyntax("property",a.nameSpan),this.addSyntax("punctuation",a.equalsSpan);let l=a.nameSpan?this.source.slice(a.nameSpan.start,a.nameSpan.end).toLowerCase():void 0,h=i&&jt(i,l,c);if(h==="content")new r(this).parseSyntax(a.valueSpan.start,a.valueSpan.end);else{let p=this.source.slice(a.valueSpan.start,a.valueSpan.end),f=vc(h,p);f&&this.addSyntax(f,a.valueSpan)}this.addSyntax("punctuation",a.commaSpan)}this.addSyntax("punctuation",s.closeParenSpan)}makeNodes(t,e=0,o=t.length){t:for(;e<o;e++){let n=t[e];if(typeof n=="number"){let s=this.nodes.at(-1);s instanceof et&&s.sourceSpan.end===n?s.sourceSpan.end=n+1:this.nodes.push(new et({start:n,end:n+1},null));continue}switch(n.kind){case"call":this.pushNode(this.parseCallNode(n));break;case"brace":let s=new r(this);this.nodes.push(new tt(n.span,s.parse(n.span.start+1,n.span.end-1),null));break;case"label":let i=this.labelableNodes.at(-1);i?i.label!==void 0?this.diagnostics.push(I.warning.TargetAlreadyLabeled(n.label,i.label,n.span)):(i.label=n.label,this.nodes.push(new wt(n.span,n.label,i))):this.diagnostics.push(I.warning.LabelWithoutTarget(n.label,n.span));break;case"sugar":for(let a of this.deSugarRelationFns){let l=a(this,t,e);if(l!==null){e=l-1;continue t}}let c=this.nodes.at(-1);c instanceof et&&c.sourceSpan.end===n.span.start?c.sourceSpan.end=n.span.end:this.nodes.push(new et(n.span,null));break}}return e}parseGrammar(t,e,o=!1){let n=[],s=i=>{n.push(i),o&&this.recordSyntax(i)};t:for(;(t=Tt(this.source,t,e))<e;){let i=this.source[t];if(i==="@"){let c=Te(this.source,t,e);if(c){s(Object.assign(c,{kind:"call",typed:!1}));let l=!1;for(let h of c.args){let p=h.nameSpan!==void 0;if(p&&!l)l=!0;else if(!p&&l){let f=I.error.PosAfterNamedArg(c.name,h.span);if(!o)throw f;this.diagnostics.push(f)}}if(!c.closeParenSpan){let h=I.error.UnterminatedCall(c.name,c.span);if(!o)throw h;this.diagnostics.push(h)}t=c.span.end;continue}let a=yi(this.source,t,e);if(a){s({kind:"label",span:{start:t,end:a.next},label:a.label}),t=a.next;continue}}if(i==="{"){let c=xi(this.source,t,e);(c<0||c>=e||c<=t)&&(this.diagnostics.push(I.warning.UnmatchedBrace({start:t,end:e})),c=e),s({kind:"brace",span:{start:t,end:c+1}}),t=c+1;continue}for(let c of this.deSugarAtomFns)try{let a=c(this.source,t,e,this.scopeDepth);if(a){s(a.node),t=a.next;continue t}}catch(a){throw a instanceof I?this.diagnostics.push(a):this.diagnostics.push(I.error.Bug(a.toString(),{start:t,end:e})),a}n.push(t++)}return n}parseCallNode(t){let e=this.functions.get(t.name.toLowerCase()),o=e?.def;if(!e||!o){if(this.variables.strict)throw I.error.UnknownFunction(t.name,t.span);return this.diagnostics.push(I.warning.UnknownFunction(t.name,t.span)),new N(t.span,null)}let n=o.args;if(!t.typed){let s=new Map;for(let i=0;i<t.args.length;i++){let c=t.args[i],a=c.nameSpan?this.source.slice(c.nameSpan.start,c.nameSpan.end).toLowerCase():void 0,l=jt(o,a,i),h=a??i;if(l===void 0){o.allowExtraArgs?s.set(h,c):this.diagnostics.push(I.warning.TooManyPosArgs(t.name,n.filter(f=>!f.namedOnly).length,i+1,c.valueSpan));continue}let p=this.parseArgWithType(c.valueSpan,l,t.span.start);p!==null&&s.set(h,p)}return new e(t.span,s,this,null)}return new e(t.span,t.args,this,null)}parseArgWithType(t,e,o){let n=Le(this.source,t.start,t.end),s=n.start,i=n.end;if(s>=i)return null;let c=e==="content"?"":this.source.slice(s,i);switch(e){case"number":let a=Number(c);return Number.isFinite(a)?a:(this.diagnostics.push(I.warning.InvalidNumber(c,n)),null);case"boolean":return gi.test(c)?c==="true":(this.diagnostics.push(I.warning.InvalidBoolean(c,n)),null);case"content":{let p=this.labelableNodes,f=p.length,u=p.at(-1),d=u?.label,x=u&&Object.hasOwn(u,"label");try{let g=new r(this).parse(s,i);return g.length===1?g[0]:new tt(n,g,null)}catch(m){if(p.length=f,u&&(x?u.label=d:delete u.label),this.variables.strict||!(m instanceof I))throw m;return this.diagnostics.push(m,I.warning.InvalidContent(n)),null}}case"label":o??=t.start;for(let p=this.labelableNodes.length-1;p>=0;p--){let f=this.labelableNodes[p];if(f&&!(f.sourceSpan.start>=o)&&f.label==c)return f}throw I.error.UnknownLabel(c,n);case"length":let l=ln(c);return l instanceof I?(l.span.start+=s,l.span.end+=s,this.diagnostics.push(l),null):l;default:let h=mi(c);return h instanceof I?(h.span.start+=s,h.span.end+=s,this.diagnostics.push(h),c.slice(1,-1)):h}}length2px(t){return t.unit==="em"?t.value*this.variables.fontsize:t.value}};function Tt(r,t,e){for(;t<e&&wi(r[t]);)t++;return t}function Ee(r,t,e=0){for(;t>=e&&wi(r[t]);)t--;return t}function wi(r){switch(r){case" ":case" ":case"\v":case"\f":case"\xA0":case"\uFEFF":case"\u3000":return!0;default:return!1}}function Oc(r){return r>="A"&&r<="G"||r==="X"||r==="Z"}function Ze(r){return r>="0"&&r<="9"}function Li(r){return r==="#"||r==="b"||r==="n"}function hn(r,t,e){for(;t<e&&Li(r[t]);)t++;return t}function Si(r,t,e){let o=hn(r,t,e);return o>t&&!Ze(r[o]??"")?r.slice(t,o):null}function Ci(r,t,e){t<e&&(r[t]==="+"||r[t]==="-")&&t++;let o=t;for(;t<e&&Ze(r[t]);)t++;return t>o?t:-1}function Ai(r,t,e,o,n){let s=0,i=t;for(;i<e&&(r[i]===","||r[i]==="'");)s+=r[i++]==="'"?1:-1;return{name:o,next:i,acc:n,octave:i>t?s:null,absOctave:!1}}function Ht(r,t=0,e=r.length,o=!0){if(e-t===0)return o?new w("E_WRONG_NOTE_NAME",'\u51FD\u6570 @note \u7684\u53C2\u6570 [0]:"name" \u4E0D\u80FD\u4E3A\u7A7A',{start:t,end:e}):null;let n=r[t];if(Oc(n)){let s=t+1,i=null,c=null,a=Ci(r,s,e);if(a>0)c=parseInt(r.slice(s,a),10),s=a,i=Si(r,s,e),i&&(s+=i.length);else{let l=hn(r,s,e);if(l>s){i=r.slice(s,l);let h=Ci(r,l,e);h>0?(c=parseInt(r.slice(l,h),10),s=h):s=l}}return{name:n,next:s,acc:i,octave:c,absOctave:!0}}if(Ze(n)){let s=Si(r,t+1,e);return Ai(r,t+1+(s?s.length:0),e,n,s)}if(Li(n)){let s=hn(r,t,e);if(s>=e)return o?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:t,end:e}):null;let i=r[s];return Ze(i)?Ai(r,s+1,e,i,r.slice(t,s)):o?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:s,end:s+1},{ch:i}):null}return o?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:t,end:t+1},{ch:n}):null}var Qe=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],Ti=["C","Db","D","Eb","E","F","Gb","G","Ab","A","Bb","B"],Et={C:0,"C#":1,Db:1,D:2,"D#":3,Eb:3,E:4,F:5,"F#":6,Gb:6,G:7,"G#":8,Ab:8,A:9,"A#":10,Bb:10,B:11,1:0,2:2,3:4,4:5,5:7,6:9,7:11},qe=["C","D","E","F","G","A","B"],pn=[0,2,4,5,7,9,11];function $t(r,t=4){let e=r[0],o="",n=1;n<r.length&&(r[n]==="#"||r[n]==="b"||r[n]==="n")&&(o=r[n],n++);let s=Et[e+o];if(s===void 0)return null;if(n<r.length){let i=r.slice(n);if(t=Number(i),!/^-?\d+$/.test(i)||!Number.isSafeInteger(t))return null}return(t+1)*12+s}function un(r,t=!0,e=0){for(let o of r)o==="#"?e++:o==="b"?e--:o==="n"&&!t&&(e=0);return e}function dn(r,t,e,o){let n=Et[r];if(n===void 0)return null;let s=un(t);return r>="1"&&r<="7"?$t(o)+n+s+e*12:(e+1)*12+n+s}function Ei(r,t,e,o){let n,s;if(r>="1"&&r<="7")n=Number(r)-1,s=e;else{let a=ke(r,t,e,o);if(!a)return;n=Number(a.renderName)-1,s=a.renderOctave}let i=$t(o),c=s*7+n;return a=>{let l=c+a,h=Math.floor(l/7);return i+pn[(l%7+7)%7]+h*12}}function fn(r){return(r%12+12)%12}function Rc(r){let t=fn(r);return t>6?t-12:t}function Ic(r){return r===0?"":r>0?"#".repeat(r):"b".repeat(-r)}function ke(r,t,e,o){let n=qe.indexOf(o[0]),s=qe.indexOf(r),i=dn(r,t,e,o);if(n<0||s<0||i===null)return null;let c=$t(o),a=(s-n+qe.length)%qe.length,l=fn(c+pn[a]),h=Rc(fn(i)-l),p=(i-c-pn[a]-h)/12;return{renderName:String(a+1),renderAcc:Ic(h),renderOctave:p}}var Pc={"#":{w:.46,h:.78,baseline:.63,commands:[{op:"M",x:.34,y:.05},{op:"L",x:.27,y:.95},{op:"M",x:.72,y:.05},{op:"L",x:.65,y:.95},{op:"M",x:.08,y:.38},{op:"L",x:.9,y:.28},{op:"M",x:.05,y:.72},{op:"L",x:.87,y:.62}]},b:{w:.38,h:.82,baseline:.67,commands:[{op:"M",x:.3,y:.04},{op:"L",x:.3,y:.94},{op:"M",x:.3,y:.5},{op:"Q",cx:.92,cy:.36,x:.76,y:.68},{op:"Q",cx:.63,cy:.87,x:.3,y:.86}]},n:{w:.42,h:.82,baseline:.67,commands:[{op:"M",x:.28,y:.05},{op:"L",x:.28,y:.82},{op:"L",x:.72,y:.68},{op:"L",x:.72,y:.95},{op:"M",x:.72,y:.95},{op:"L",x:.72,y:.18},{op:"L",x:.28,y:.32}]}};function Je(r,t,e,o,n){let s=[],i=t*.72,c=t*.42,a=e,l=0;for(let h of r){let p=Pc[h];if(!p)continue;let f={w:p.w*i,h:p.h*i,baseline:p.baseline*i,strokeWidth:t*.06,commands:p.commands},u=o-f.baseline-c;s.push({shape:f,x:a,y:u}),u<l&&(l=u),a+=f.w+n}return{placed:s,right:a,top:l}}function to(r,{shape:t,x:e,y:o},n,s){r.drawPath(t.commands,{stroke:s,strokeWidth:t.strokeWidth},{x:n.x+e,y:n.y+o,scaleX:t.w,scaleY:t.h})}function zc(r){if($t(r)!==null)return r;let t=r.replace(/^[a-g]/,a=>a.toUpperCase()),e=Ht(t,0,t.length,!1);if(!e||e.next!==t.length)return null;let o=Et[e.name];if(o===void 0)return null;let n=un(e.acc??"",!1),i=((e.absOctave?e.octave??4:4+(e.octave??0))+1)*12+o+n,c=Object.keys(Et).filter(a=>Et[a]===(i%12+12)%12&&/^[A-G]/.test(a));return(n<0?c.at(-1):c[0])+(Math.floor(i/12)-1)}var xn=class extends N{static def={name:["key","1"],description:"\u8BBE\u7F6E\u65F6\u95F4\u7EBF\u4E0A\u7684 1= \u8C03\u6027\u57FA\u51C6",details:`~~~jpfun
|
|
31
|
-
1 ^ @key(F#3)
|
|
32
|
-
~~~
|
|
33
|
-
\u8C03\u6027\u6CBF\u65F6\u95F4\u7EBF\u5F71\u54CD\u540E\u7EED\u6570\u5B57\u97F3\u540D\u3002\u8C31\u9762\u8BB0\u53F7\u663E\u793A\u97F3\u540D\u4E0E\u5347\u964D\u53F7\uFF0C\u7701\u7565\u516B\u5EA6\uFF1B\u901A\u5E38\u7528 \`^\` \u53E0\u5728\u97F3\u7B26\u4E0A\u65B9\u3002`,allowExtraArgs:!1,args:[{name:"tonality",description:"`1=` \u7684\u97F3\u9AD8\u57FA\u51C6\uFF0C\u5982 `C4`\u3001`F#3`",type:"string",default:null},{name:"size",description:"\u8C03\u6027\u8BB0\u53F7\u5B57\u53F7",type:"length",default:{value:1,unit:"em"}}]};tonality;size;font;displayName;displayAcc;constructor(t,e,o,n=null){super(t,n);let[s,i]=this.getArgValue(e,o);this.font=o.variables.numberfont,this.tonality=s,this.size=o.length2px(i);let c=zc(s);if(c!==s){if(o.variables.strict)throw new w("E_KEY_TONALITY",'@key \u65E0\u6CD5\u89E3\u6790\u8C03\u6027 "{tonality}"',t,{tonality:s});this.tonality=c??de,o.diagnostics.push(new z("W_KEY_TONALITY",'@key \u7684\u8C03\u6027 "{input}" \u4E0D\u662F\u89C4\u8303\u5199\u6CD5\uFF0C\u5DF2\u81EA\u52A8\u5207\u6362\u5230 {tonality}',t,{input:s,tonality:this.tonality}))}this.displayName=this.tonality[0],this.displayAcc=this.tonality[1]==="#"||this.tonality[1]==="b"?this.tonality[1]:""}loweringEnter(){return[new yn(this)]}toString(){return`@1(${this.tonality})`}},eo=xn,mn="1=",yn=class extends W{accidentals=[];nameX=0;textBaselineY=0;style;constructor(t){super(),this.ast=t,this.style={fontSize:t.size,fontFamily:t.font,fill:"#000"},this.initLayoutBox()}onTimeState(t){t.keySignature=this.ast.tonality}prepareLayout(t){let e=this.ast.size,o=this.style,n=t.textMeasurer.measureText(mn,o),s=t.textMeasurer.measureText(this.ast.displayName,o),i=e*.02,{placed:c,right:a,top:l}=Je(this.ast.displayAcc,e,n.w,n.baseline,i);this.accidentals=c;let h=-l;for(let p of c)p.y+=h;this.nameX=a,this.textBaselineY=h+n.baseline,this.box.w=a+s.w,this.box.h=h+Math.max(n.h,s.h),this.box.anchor=t.textMeasurer.measureText(mn[0],o).w/2,this.box.visualAxis=this.box.h/2}paint(t){let e=this.style;t.drawText(mn,this.box.x,this.box.y+this.textBaselineY,e);for(let o of this.accidentals)to(t,o,this.box,"#000");t.drawText(this.ast.displayName,this.box.x+this.nameX,this.box.y+this.textBaselineY,e)}};var Fc=[{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 ki(r){let t=r/11;return{w:3.864*t,h:10.88*t,stemCenterX:(3.304+3.864)/2*t,commands:Fc,scale:t}}var gn=class extends N{static def={name:["tempo"],description:"\u8BBE\u7F6E\u65F6\u95F4\u7EBF\u4E0A\u7684\u901F\u5EA6",details:`~~~jpfun
|
|
34
|
-
@tempo(96)
|
|
35
|
-
~~~
|
|
36
|
-
\u901F\u5EA6\u4ECE\u5F53\u524D\u65F6\u95F4\u4F4D\u7F6E\u8D77\u751F\u6548\uFF1B\u7528 \`1 ^ @tempo(96)\` \u53EF\u5C06\u8BB0\u53F7\u53E0\u5728\u97F3\u7B26\u4E0A\u65B9`,allowExtraArgs:!1,args:[{name:"bpm",description:"\u6BCF\u5206\u949F\u56DB\u5206\u97F3\u7B26\u6570",type:"number",default:null},{name:"size",description:"\u901F\u5EA6\u8BB0\u53F7\u5B57\u53F7",type:"length",default:{value:1,unit:"em"}}]};bpm;size;font;constructor(t,e,o,n=null){super(t,n);let[s,i]=this.getArgValue(e,o);this.bpm=s,this.size=o.length2px(i),this.font=o.variables.font}loweringEnter(){return[new bn(this)]}toString(){return`@tempo(${this.bpm}, size=${this.size}px)`}},oo=gn,bn=class extends W{glyph;text;style;glyphY=0;textX=0;textBaselineY=0;constructor(t){super(),this.ast=t,this.glyph=ki(t.size),this.text=`= ${t.bpm}`,this.style={fontSize:t.size,fontFamily:t.font,fill:"#000"},Number.isFinite(t.bpm)&&t.bpm>0&&(this.playbackState={bpm:t.bpm}),this.initLayoutBox()}onTimeState(t){let e=this.playbackState?.bpm;e!==void 0&&(t.bpm=e)}prepareLayout(t){let e=this.glyph,o=t.textMeasurer.measureText(this.text,this.style),n=Math.max(0,e.h-o.baseline);this.textX=e.w+this.ast.size*.26,this.textBaselineY=n+o.baseline,this.glyphY=this.textBaselineY-e.h,this.box.w=this.textX+o.w,this.box.h=n+o.h,this.box.anchor=e.stemCenterX,this.box.visualAxis=n+o.h/2}paint(t){t.drawPath(this.glyph.commands,{fill:"#000"},{x:this.box.x,y:this.box.y+this.glyphY,scaleX:this.glyph.scale,scaleY:this.glyph.scale}),t.drawText(this.text,this.box.x+this.textX,this.box.y+this.textBaselineY,this.style)}};var wn=class r extends N{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 JSON \u98CE\u683C\u7684 Unicode \u8F6C\u4E49\uFF0C\u5982 `\\uE050`\uFF1B\u663E\u793A\u5B57\u9762\u53CD\u659C\u6760\u987B\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(t,e,o){if(t[e]!=='"')return null;let n=Mt(t,e,o);if(n<0)return null;let s={kind:"sugar",data:r,span:{start:e,end:n+1},syntaxKind:"string"};return{next:n+1,node:s}}static deSugarRelation(t,e,o){let n=e[o];return n.data!==r?null:(t.pushNode(new r(n.span,new Map([[0,t.parseArgWithType(n.span,"string")]]),t,null)),o+1)}lines;size;lineAdvance;align;font;constructor(t,e,o,n=null){super(t,n);let[s,i,c,a,l]=this.getArgValue(e,o);if(this.font=l||o.variables.font,a!=="left"&&a!=="center"&&a!=="right")throw new w("E_TEXT_INVALID_ALIGN","@text \u7684 align \u53C2\u6570\u5FC5\u987B\u662F 'left'\u3001'center' \u6216 'right'",t);this.lines=s.split(/\r?\n/),this.size=o.length2px(i),this.lineAdvance=c*this.size,this.align=a}loweringEnter(){return[new Sn(this)]}toString(){let t=this.size===0?1.25:this.lineAdvance/this.size;return`@text(${ht(this.lines.join(`
|
|
37
|
-
`))}, size=${this.size}px, lineheight=${t}, align=${this.align}, font=${ht(this.font)})`}},no=wn,Sn=class extends W{style;textBaselineY=0;constructor(t){super(),this.ast=t,this.mergeKey=bt,this.style={fontSize:t.size,fontFamily:t.font,fill:"#000",textAlign:t.align},this.initLayoutBox()}prepareLayout(t){let{lines:e,align:o,lineAdvance:n}=this.ast,s=a=>t.textMeasurer.measureText(a,this.style),i=s(e[0]),c=i.w;for(let a=1;a<e.length;a++)c=Math.max(c,s(e[a]).w);if(this.box.w=c,this.box.h=(e.length-1)*n+i.h,this.box.visualAxis=this.box.h/2,this.textBaselineY=i.baseline,o==="center")this.box.anchor=c/2;else if(o==="right"){let a=[...e[0]].at(-1);this.box.anchor=c-(a?s(a).w/2:0)}else{let a=[...e[0]][0];this.box.anchor=a?s(a).w/2:0}}paint(t){let{lines:e,align:o,lineAdvance:n}=this.ast,s=this.box.x+(o==="center"?this.box.w/2:o==="right"?this.box.w:0),i=this.box.y+this.textBaselineY;for(let c of e)t.drawText(c,s,i,this.style),i+=n}};var Ni={title:"center",subtitle:"center",author:"right",signature:"left",tempo:"left",left:"left",center:"center",right:"right"},Dc={title:[2,"center"],subtitle:[.85,"center"],author:[.8,"right"]},Bc=.25,_i=5,vi=1e4;function so(r,t){return t.length===1&&t[0]instanceof tt?t[0]:new tt(r,t)}function Mi(r,t,e=r.length){for(;t<e&&r[t]!=="\r"&&r[t]!==`
|
|
38
|
-
`;)t++;return t}function Hc({columns:r,rows:t,start:e,end:o,X:n,fixed:s,options:i},c){qt(r.slice(e,o+1),t,n.subarray(e,o+1),s.subarray(e,o),1/0,i);let a=1/0,l=-1/0;for(let h=e+1;h<o;h++)for(let p=0;p<t;p++)a=Math.min(a,n[h]-r[h][p].WL),l=Math.max(l,n[h]+r[h][p].WR);c&&a<=l?(n[e]=a,n[o]=l):n[o]=n[e]}var io=class extends W{members=[];slots=[];titleBottom=0;sideExtents={left:null,right:null};constructor(t){super(),this.ast=t,this.initLayoutBox()}validateDuration(){for(let t of this.members)if(!t.T.isZero())throw new w("E_HEAD_NONZERO_DURATION","@head \u7684\u5185\u5BB9\u5FC5\u987B\u5168\u90E8\u4E3A\u96F6\u65F6\u957F",t.ast.sourceSpan)}prepareLayout(){this.box.w=this.box.h=this.box.anchor=this.box.visualAxis=0}prepareHorizontal(t){this.slots.length>0&&this.prepareHead(t)}onPlaced(){this.slots.length>0&&this.alignHead()}onTemporal(t){this.members.push(t)}createTracks(t){let{name:e,owner:o}=t;return{laneKey:`head/rows/${o.sourceSpan.start}/${e}`,hostIndex:null,measure:n=>{let s,i;e==="center"&&(this.titleBottom=0);let c=n.map(a=>{if(!a)return null;let l=i===void 0?0:i+o.gap-a.top;return i===void 0&&e==="center"&&(this.titleBottom=a.bottom),s??=l+a.top,i=l+a.bottom,{offset:l,extent:a}});return e!=="center"&&(this.sideExtents[e]=s===void 0||i===void 0?null:{top:s,bottom:i}),c},place:e==="center"?void 0:()=>{let n=this.sideExtents[e];if(!n)return this.titleBottom;let{left:s,right:i}=this.sideExtents,c=s?s.bottom-s.top:0,a=i?i.bottom-i.top:0;return this.titleBottom+Math.max(c,a)-n.bottom}}}prepareHead(t){if(this.members.some(s=>R(s)&&s.layoutLine!==t.index))throw new w("E_HEAD_INTERNAL_BREAK","@head \u7684\u5185\u5BB9\u4E0D\u80FD\u8DE8\u8C31\u9762\u884C",this.ast.owner.sourceSpan);let[e,o,n]=this.slots;e.start.springConfig.alpha_L=0,n.end.springConfig.alpha_R=0,this.stretch(o.start,"L"),this.stretch(o.end,"R");for(let s of this.slots)t.registerHorizontalLayoutHook(s.start,s.end,i=>Hc(i,s===o))}alignHead(){let t=new Map;for(let n of this.members){if(!R(n))continue;let s=this.sideCellOf(n.ast);if(!s)continue;let i=t.get(s);i?i.push(n):t.set(s,[n])}let[e,,o]=this.slots;this.packRows(e.ast,e.start.box.x,t),this.packRows(o.ast,o.end.box.x,t)}stretch(t,e){let o=e==="L"?"alpha_L":"alpha_R",n=e==="L"?"beta_L":"beta_R";t.springConfig[o]=t.springConfig[o]*vi,t.springConfig[n]=t.springConfig[n]*3/vi}packRows(t,e,o){let n=this.ast.owner.size*Bc,s=t.name==="left",i=s?1:-1;for(let c of t.rows){let a=c instanceof tt?c.content:[c],l=e;for(let h=s?0:a.length-1;h>=0&&h<a.length;h+=i){let p=o.get(a[h]);if(!p)continue;let f=1/0,u=-1/0;for(let x of p)f=Math.min(f,x.box.x),u=Math.max(u,x.box.x+x.box.w);let d=l-(s?f:u);for(let x of p)x.box.x+=d;for(let x of p)x.onPlaced?.();l+=i*(u-f+n)}}}sideCellOf(t){let e=t;for(;e.parent;){let o=e.parent,n=o instanceof Wt?o:o instanceof tt&&o.parent instanceof Wt?o.parent:null;if(n?.owner===this.ast.owner)return n.name==="center"?null:e;e=o}return null}},Wt=class extends rt{owner;name;rows;constructor(t,e,o,n){super(t,e),this.owner=e,this.name=o,this.rows=n;for(let s of this.rows)s.parent=this}get size(){return this.owner.size}get children(){return this.rows}timeFlowModel(t){if(this.rows.length===0)return null;let e=t.getTemporalNodes(this.owner.slots[0])[0];return{mode:"parallel",children:this.rows,tracks:e.createTracks(this)}}loweringEnter(t){let e=new io(this);return this.name==="left"&&t.beginLoweringGroup(this.owner,e),[e]}loweringExit(){return[new io(this)]}addRow(t){t.parent=this,this.rows.push(t)}},Cn=class r extends N{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:_i,unit:"px"}}]};slots;size;gap;createdBySugar=!1;get children(){return this.slots}timeFlowModel(){return{mode:"sequence",children:this.slots}}static deSugarAtom(t,e,o){if(t[e]!=="H"||t[e+1]!==".")return null;let n=e+2;for(;n<o&&t[n]>="a"&&t[n]<="z";)n++;let s=t.slice(e+2,n);if(!Object.hasOwn(Ni,s)||t[n]!==":")return null;n++;let i=Mi(t,n,o),c=Tt(t,n,i);return{next:t[c]==="@"||t[c]==="{"?n:i,node:{kind:"sugar",data:{class:r,field:s},span:{start:e,end:n}}}}static deSugarRelation(t,e,o){let n=e[o++];if(n.data?.class!==r)return null;let s=n.data.field,i=o;for(;i<e.length;i++){let g=e[i];if(typeof g=="number"&&(t.source[g]==="\r"||t.source[g]===`
|
|
39
|
-
`)||typeof g!="number"&&g.kind==="sugar"&&g.data?.class===r)break}let c=e[i],a;if(typeof c=="number")a=c;else if(c)a=c.span.start;else if(i>o){let g=e[i-1];a=typeof g=="number"?g+1:g.span.end}else a=Mi(t.source,n.span.end);let l=Tt(t.source,n.span.end,a),h=Ee(t.source,a-1,l),p={start:l,end:Math.max(l,h+1)};if(p.start>=p.end)throw new w("E_HEAD_EMPTY_DECLARATION","H.{field}: \u540E\u5FC5\u987B\u6709\u5185\u5BB9",n.span,{field:s});let f=t.source.slice(p.start,p.end).trim(),u;if(f.startsWith("@")||f.startsWith("{")){let g=new dt(t);g.makeNodes(e.slice(o,i)),u=g.nodes}let d=t.nodes.at(-1),x=d instanceof r&&d.createdBySugar?d:new r(n.span,new Map,t,null);if(x.createdBySugar=!0,x.slots.find(g=>g.name===Ni[s]).addRow(r.parseSugarRow(t,s,p,f,u)),x.sourceSpan.end=p.end,x!==d&&t.pushNode(x),typeof c!="number")return i;let m=i+1;if(t.source[c]==="\r"){let g=e[m];typeof g=="number"&&t.source[g]===`
|
|
40
|
-
`&&m++}return m}static parseSugarRow(t,e,o,n,s){if(s!==void 0)return so(o,s);if(e==="signature"){let a=/^(1\s*=\s*(\S+))\s+((\d+)\s*\/\s*(\d+))$/.exec(n);if(!a)throw new w("E_HEAD_INVALID_SIGNATURE","H.signature \u7684\u683C\u5F0F\u5E94\u4E3A 1=C 4/4",o);let l={start:o.start,end:o.start+a[1].length},h={start:o.end-a[3].length,end:o.end};return so(o,[new eo(l,new Map([["tonality",a[2]]]),t,null),new Ke(h,new Map([["num",Number(a[4])],["den",Number(a[5])]]),t,null)])}if(e==="tempo"){let a=Number(n);if(!Number.isFinite(a)||a<=0)throw new w("E_HEAD_INVALID_TEMPO","H.tempo \u540E\u5FC5\u987B\u662F\u6B63\u6570",o);return so(o,[new oo(o,new Map([["bpm",a]]),t,null)])}let i=new Map([[0,n]]),c=Dc[e];return c&&(i.set("size",{value:c[0],unit:"em"}),i.set("align",c[1])),so(o,[new no(o,i,t,null)])}constructor(t,e,o,n=null){super(t,n),this.size=o.variables.fontsize,this.gap=o.length2px(this.getArgValue(e,o)[3]);let s=(i,c)=>{let a=e.get(i)??e.get(c);return a instanceof rt?a instanceof tt?a.content:[a]:[]};this.slots=[new Wt(t,this,"left",s("left",0)),new Wt(t,this,"center",s("center",1)),new Wt(t,this,"right",s("right",2))]}loweringExit(t){let e=t.endLoweringGroup(this);e.slots=this.slots.map(o=>{let[n,s]=t.getTemporalNodes(o);return{ast:o,start:n,end:s}}),e.slots[2].end.onTimeState=()=>e.validateDuration();for(let o of e.members)if((o.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",o.ast.sourceSpan);return[]}toString(t){let e=this.slots.filter(o=>o.rows.length>0).map(o=>{let n=o.rows.map(s=>` ${s.toString(t).replaceAll(`
|
|
41
|
-
`,`
|
|
42
|
-
`)}`).join(`
|
|
43
|
-
`);return` ${o.name}={
|
|
44
|
-
${n}
|
|
45
|
-
}`});return this.gap!==_i&&e.push(` gap=${this.gap}px`),`@head(
|
|
46
|
-
${e.join(`,
|
|
47
|
-
`)}
|
|
48
|
-
)`}},Oi=Cn;var An=class r extends N{static def={name:["br"],description:"\u6362\u884C",details:`~~~jpfun
|
|
49
|
-
1 2 @br() 3 4
|
|
50
|
-
~~~
|
|
51
|
-
|
|
52
|
-
\`@br()\` \u6362\u5230\u4E0B\u4E00\u884C\uFF0C\`@br(2)\` \u7A7A\u51FA\u4E00\u884C\u518D\u7EE7\u7EED
|
|
53
|
-
|
|
54
|
-
**\u7B80\u5199**\uFF1A\u4EC5\u5728\u9876\u5C42\uFF0C\u8FDE\u7EED\u81F3\u5C11\u4E24\u4E2A\u6362\u884C\u8868\u793A\u6362\u884C`,allowExtraArgs:!1,args:[{name:"offset",description:"\u540E\u7EED\u5185\u5BB9\u504F\u79FB\u7684\u8C31\u9762\u884C\u6570\uFF0C2 \u8868\u793A\u7A7A\u51FA\u4E00\u884C\u518D\u7EE7\u7EED",type:"number",default:1}]};static deSugarAtom(t,e,o,n){if(n>0||t[e]!==`
|
|
55
|
-
`||t[Ee(t,e-1)]!==`
|
|
56
|
-
`)return null;let s=e+1,i=s;for(;(i=Tt(t,i,o))<o&&t[i]===`
|
|
57
|
-
`;)s=++i;return{next:s,node:{kind:"call",typed:!0,name:"br",args:new Map,span:{start:e,end:s}}}}offset;loweringEnter(t){t.deferFinalize(r.loweringFinalize);let e=new W;return e.ast=this,e.mergeKey=-1,e.addon={breakBefore:this.offset},[e]}static loweringFinalize(t){let e=new P,o=new P,n=null;for(let s of t.columns){if(n&&e.compare(s[0].t)>0&&s.some(i=>(i.addon?.breakBefore??0)>0))throw I.error.BreakInsideEvent(n.ast.sourceSpan);for(let i of s)i.T.isZero()||(o.copyFrom(i.t).add(i.T),(!n||o.compare(e)>0)&&(e.copyFrom(o),n=i))}}constructor(t,e,o,n=null){super(t,n);let[s]=this.getArgValue(e,o);this.offset=Number.isFinite(s)?Math.max(1,Math.floor(s)):1,this.offset!==s&&o.diagnostics.push(new z("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})`}},ro=An;var Ln=10,Tn=13,$c=9,Wc=11,Gc=12,Vc=32,Yc=160,Kc=5760,Uc=8239,jc=8287,Xc=12288,Zc=65279,qc=34,Ri=92,Qc=37,Jc=32,ta=[];function ea(r){return r>Jc?" ".repeat(r):ta[r]??=" ".repeat(r)}function Ii(r){return r===Vc||r===$c||r===Wc||r===Gc?!0:r<128?!1:r===Yc||r===Kc||r>=8192&&r<=8202||r===Uc||r===jc||r===Xc||r===Zc}function ie(r){let t=r.length,e=[0],o=[],n=[],s=(m,g)=>{if(m>=g)return;let y=n.length;if(y>=2&&m<=n[y-1]){g>n[y-1]&&(n[y-1]=g);return}n.push(m,g)},i=(m,g)=>{if(g<=0)return;let y=m+g;for(let b=m;b<y;b+=2)s(b,b+1)},c=0,a=!1,l=!1,h=-1,p=-1,f=0,u=(m,g)=>{if(g===Ri){f>0&&p+f===m?f++:(p=m,f=1);return}p=-1,f=0};for(let m=0;m<t;){let g=r.charCodeAt(m);if(g===Tn||g===Ln){let y=g===Tn&&m+1<t&&r.charCodeAt(m+1)===Ln?2:1;e.push(m+y);let b=(f&1)===1;i(p,f),h>=0&&(s(h,m),o.push({start:h,end:m}),h=-1),b?s(m,m+y):c===0&&y===2&&s(m,m+1),p=-1,f=0,l=!1,m+=y;continue}if(c!==0){l?l=!1:g===Ri?l=!0:g===c&&(c=0),Ii(g)||u(m,g),m++;continue}if(g===qc){a||(Mt(r,m,t)<0?a=!0:c=g),u(m,g),m++;continue}if(g===Qc){for(h=m,m++;m<t;){let y=r.charCodeAt(m);if(y===Tn||y===Ln)break;m++}continue}Ii(g)||u(m,g),m++}if(i(p,f),h>=0&&(s(h,t),o.push({start:h,end:t})),n.length===0)return{maskedSource:r,lineStarts:e,commentSpans:o};let d=[],x=0;for(let m=0;m<n.length;m+=2){let g=n[m],y=n[m+1];x<g&&d.push(r.slice(x,g)),d.push(ea(y-g)),x=y}return x<t&&d.push(r.slice(x)),{maskedSource:d.join(""),lineStarts:e,commentSpans:o}}var Ot="CDEFGAB",co=(r,t)=>(r%t+t)%t,oa=r=>r<0?"b".repeat(-r):"#".repeat(r);function ao(r){throw new w("E_NOTE_TRANSFORM","\u65E0\u6CD5\u5B89\u5168\u6539\u5199\u6B64\u97F3\u7B26\u7684\u97F3\u9AD8",r)}function na(r,t){let e=t==="to-absolute"||t!=="to-relative"&&Ot.includes(r.ast.name),o=r.resolvedMidi+(t==="semitone-up"?1:t==="semitone-down"?-1:0),n=$t(r.keySignature);[o,n,r.ast.octave,r.ast.jeOctaveOffset].every(Number.isSafeInteger)||ao(r.ast.sourceSpan);let s=t==="semitone-down"?Ti:Qe,i,c,a;if(t==="to-absolute"){let l=Ot.indexOf(r.keySignature[0]),h=l<0?Ot.indexOf(Qe[co(n,12)][0]):l,p=Number(r.ast.name)-1;i=Ot[(h+p)%7];let f=co(n-Et[Ot[h]]+6,12)-6;a=Math.floor((n-f)/12)-1+Math.floor((h+p)/7)+r.ast.octave+r.ast.jeOctaveOffset,c=oa(o-((a+1)*12+Et[i]))}else if(t==="to-relative"){let l=r.ast,h=Ot.includes(r.keySignature[0])?r.keySignature:Qe[co(n,12)]+(Math.floor(n/12)-1),p=ke(l.name,l.acc,l.octave+l.jeOctaveOffset,h);p||ao(l.sourceSpan),{renderName:i,renderAcc:c,renderOctave:a}=p}else{let l=e?o:o-n,h=s[co(l,12)];i=e?h[0]:String(Ot.indexOf(h[0])+1),c=h.slice(1),a=Math.floor(l/12)-(e?1:0)}return{name:i,acc:c,octave:a-r.ast.jeOctaveOffset,absolute:e}}function sa(r,t){for(let e=t.parent;e;e=e.parent){let o=Te(r,e.sourceSpan.start,e.sourceSpan.end);if(!o)continue;let n=o.args.find(i=>i.valueSpan.start<=t.sourceSpan.start&&i.valueSpan.end>=t.sourceSpan.end);if(!n)continue;let s=0;for(let i=n.valueSpan.start;i<t.sourceSpan.start;i++)r[i]==='"'?i=Mt(r,i,n.valueSpan.end):r[i]==="{"?s++:r[i]==="}"&&s--;return s===0}return!1}function Pi(r,t,e,o){let{maskedSource:n}=ie(r),s=[],i=[];function c(l,h){r.slice(l.start,l.end)!==h&&(r.slice(l.start,l.end)!==n.slice(l.start,l.end)&&ao(l),s.push({span:l,text:h}))}for(let l of t){let E=function(_,v,k){let F=!k||k.includes(",")||_&&r[_.start]==='"'?ht(k):k;_?c(_,F):L.push(`${v}=${F}`)};var a=E;let{ast:h}=l,p=h.sourceSpan,f=Te(n,p.start,p.end),u=f?.span.end===p.end&&f.closeParenSpan,d=e==="to-absolute"&&Ot.includes(h.name)||e==="to-relative"&&/^[1-7]$/.test(h.name);if(u||i.push({span:p,text:r.slice(p.start,p.end)}),o&&!o.some(_=>_.start<=p.start&&_.end>=p.end)||l.resolvedMidi===null||d)continue;let x=na(l,e),m=x.absolute?String(x.octave):x.octave<0?",".repeat(-x.octave):"'".repeat(x.octave),g=(_,v)=>x.absolute?x.name+_+v:_+x.name+v;if(!u){let _=g(x.acc,m);_.includes(",")&&sa(n,h)&&(_=`{${_}}`),i[i.length-1].text=_;continue}let y=new Map;f.args.forEach((_,v)=>{_.valueSpan.start!==_.valueSpan.end&&y.set(_.nameSpan?n.slice(_.nameSpan.start,_.nameSpan.end).toLowerCase():v,_.valueSpan)});let b=y.get("name")??y.get(0),S=y.get("acc")??y.get(1),C=y.get("octave")??y.get(2),L=[];if(E(b,"name",g(S?"":x.acc,C?"":m)),S?E(S,"acc",x.acc):h.hasDefaultAcc&&L.push('acc=""'),C&&c(C,String(x.octave)),L.length){let _=f.closeParenSpan.start,v=n.slice(f.openParenSpan.end,_).trimEnd();c({start:_,end:_},(v?v.endsWith(",")?" ":", ":"")+L.join(", "))}}i.sort((l,h)=>l.span.start-h.span.start);for(let l=0;l<i.length-1;l++){let h=i[l],p=i[l+1];if(h.span.end!==p.span.start||h.text.endsWith("}"))continue;let f=h.text+p.text,u=Ht(f,0,f.length,!1);(!u||u.next!==h.text.length)&&(h.text!==r.slice(h.span.start,h.span.end)?h.text+=" ":p.text=" "+p.text)}for(let l of i)c(l.span,l.text);s.sort((l,h)=>l.span.start-h.span.start);for(let l=1;l<s.length;l++)s[l-1].span.end>s[l].span.start&&ao(s[l].span);return s}function zi(r,t,e,o){let n=t.diagnostics.find(c=>c instanceof w);if(n)throw n;let s=[...t.astToTemporal.values()].flat().filter(c=>c instanceof lo),i=t.diagnostics.find(c=>s.some(a=>c.span.start<a.ast.sourceSpan.end&&c.span.end>a.ast.sourceSpan.start));if(i)throw i;return Pi(r,s,e,o)}var En="note.jeOctaveOffset",kn=class extends N{static def={name:["note","n"],description:"\u521B\u5EFA\u97F3\u7B26",details:"~~~jpfun\n@note(A, acc=#, octave=3, color=#c33)\n~~~\n**\u7B80\u5199**\uFF1A\u6570\u5B57\u97F3\u540D\u6309\u201C\u5347\u964D\u53F7\u3001\u97F3\u540D\u3001\u76F8\u5BF9\u516B\u5EA6\u201D\u4E66\u5199\uFF1B\u5B57\u6BCD\u97F3\u540D\u6309\u201C\u97F3\u540D\u3001\u5347\u964D\u53F7\u3001\u7EDD\u5BF9\u516B\u5EA6\u201D\u4E66\u5199\u3002`1,,` \u6BD4\u5F53\u524D\u8C03\u6027\u57FA\u51C6\u4F4E\u4E24\u4E2A\u516B\u5EA6\uFF0C`1'` \u9AD8\u4E00\u4E2A\u516B\u5EA6\u3002\n- \u7B80\u5199\u7684\u5347\u964D\u53F7\u5B8C\u5168\u7531\u81EA\u8EAB\u51B3\u5B9A\uFF0C\u7701\u7565\u65F6\u4E3A\u7A7A\uFF0C\u4E0D\u7EE7\u627F `@set(note.acc=...)`\uFF1B\u663E\u5F0F\u8C03\u7528\u7701\u7565 `acc` \u65F6\u4ECD\u7EE7\u627F\u9ED8\u8BA4\u503C\n- `A#3` \u7B49\u4EF7\u4E8E `@note(A, #, 3)`\uFF0C\u9ED8\u8BA4 `acc` \u4E3A\u7A7A\u65F6\u4E5F\u7B49\u4EF7\u4E8E `@note(A#3)`\n- `#1'` \u7B49\u4EF7\u4E8E `@note(1, #, 1)`\uFF0C\u9ED8\u8BA4 `acc` \u4E3A\u7A7A\u65F6\u4E5F\u7B49\u4EF7\u4E8E `@note(\"#1'\")`\n- \u652F\u6301\u7EC4\u5408\u5347\u964D\u53F7\uFF0C\u5982 `A##bn99`\uFF1B\u65E0\u6B67\u4E49\u65F6\u4E5F\u63A5\u53D7\u540E\u7F6E\u5199\u6CD5\uFF0C\u5982 `A3#`\u3001`6#,,`\n- \u5347\u964D\u53F7\u540E\u7D27\u8DDF\u6570\u5B57\u65F6\u5F52\u5165\u4E0B\u4E00\u97F3\u7B26\uFF1A`6#3` \u89E3\u6790\u4E3A `6` \u548C `#3`",allowExtraArgs:!1,args:[{name:"name",description:"\u6570\u5B57\u97F3\u540D\u6216\u5927\u5199\u5B57\u6BCD\u97F3\u540D\uFF0C\u53EF\u81EA\u5E26\u5347\u964D\u53F7\u4E0E\u516B\u5EA6\uFF1B`0` / `Z` \u4E3A\u4F11\u6B62\u7B26\uFF0C`8` \u4E3A\u9690\u5F62\u5360\u4F4D\uFF0C`9` / `X` \u4E3A\u8282\u62CD\u8BB0\u53F7\uFF0C\u540E\u4E09\u7C7B\u4E0D\u663E\u793A\u5347\u964D\u53F7\u548C\u516B\u5EA6\u70B9",type:"string",default:null},{name:"acc",description:"\u989D\u5916\u5347\u964D\u53F7\uFF0C`##` \u518D\u5347\u4E24\u4E2A\u534A\u97F3\uFF0C`b` \u518D\u964D\u4E00\u4E2A\u534A\u97F3",type:"string",default:""},{name:"octave",description:"\u5B57\u6BCD\u97F3\u540D\u4F7F\u7528\u7EDD\u5BF9\u516B\u5EA6\uFF1B\u6570\u5B57\u97F3\u540D\u4F7F\u7528\u76F8\u5BF9\u516B\u5EA6\uFF0C\u7701\u7565\u65F6\u4E3A 0",type:"number",default:4},{name:"color",description:"\u97F3\u7B26\u989C\u8272\uFF0C\u4F7F\u7528 CSS \u989C\u8272\u503C",type:"string",default:"#000"}]};static deSugarAtom(t,e,o){let n=0;switch(t[e]){case"(":case"]":n=-1;break;case"[":case")":n=1;break}if(n)return{next:e+1,node:{kind:"sugar",data:{jeOffset:n},span:{start:e,end:e+1},syntaxKind:"punctuation"}};let s=Ht(t,e,o,!1);if(!s)return null;let i=new Map;i.set("name",s.name),s.octave!==null&&i.set("octave",s.octave),i.set("acc",s.acc??"");let c={kind:"call",typed:!0,name:"note",args:i,span:{start:e,end:s.next},syntaxKind:"atom"};return{next:s.next,node:c}}static deSugarRelation(t,e,o){let n=e[o],s=n.data?.jeOffset;return typeof s!="number"?null:(t.variables[En]=(t.variables[En]??0)+s,t.nodes.push(new et(n.span)),o+1)}labelable(){return this}loweringEnter(){return[new lo(this)]}name;octave;acc;color;size;font;jeOctaveOffset;hasDefaultAcc;constructor(t,e,o,n=null){super(t,n),this.hasDefaultAcc=!!o.variables["note.acc"],[this.name,this.acc,this.octave,this.color]=this.getArgValue(e,o),this.font=o.variables.numberfont,this.size=o.variables.fontsize;let s=Ht(this.name);if(s instanceof I)throw s.span=t,s;if(s.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}"',t,{tail:this.name.slice(s.next)});this.name=s.name==="X"?"9":s.name==="Z"?"0":s.name;let i=e.get("octave")??e.get(2);if(i!==void 0){if(s.octave!==null&&s.octave!=i)throw new 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}',t,{inputOctave:String(i),noteOctave:s.octave})}else s.octave!==null?this.octave=s.octave:s.absOctave||(this.octave=0);this.jeOctaveOffset=o.variables[En]??0,s.acc!==null&&(this.acc=s.acc+this.acc)}toString(){return`@n(${this.name}, ${this.acc||'""'}, ${this.octave}, ${this.color})`}},Fi=kn,ia={8:"",9:"X"},lo=class extends W{resolvedMidi=null;keySignature="C4";transposeDiatonic;name;acc;octave;accidentals=[];numberStyle;numberY=0;constructor(t){super(),this.ast=t,this.T.set(1),this.mergeKey=bt,this.name=t.name,this.acc=t.acc,this.octave=t.octave+t.jeOctaveOffset,this.numberStyle={fontSize:t.size,fontFamily:t.font,fontWeight:400,textAlign:"center",fill:t.color},this.initLayoutBox()}prepareLayout(t){let{size:e,color:o}=this.ast,n=t.textMeasurer.measureText("0",this.numberStyle);this.numberY=n.baseline;let s=e*.01,{placed:i,right:c}=Je(this.acc,e,0,this.numberY,s);this.accidentals=i,this.box.w=c+n.w,this.box.h=n.h,this.box.anchor=c+n.w/2,this.box.visualAxis=n.h/2,this.ports["body.left"]={x:this.box.anchor-n.w/2,y:this.box.visualAxis},this.ports["body.right"]={x:this.box.anchor+n.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+e*.04},this.ports.dot={x:this.box.w,y:n.h*.64};let a=Math.abs(this.octave);if(a===0)return;let l=this.octave>0,h=e*.075,p=e*.08,f=h*2+p,u={fill:o},d=0,x=a*h*2+(a-1)*p,m={[l?"above":"below"]:{order:100,gap:p,height:x,place:g=>{d=g}},paint:g=>{for(let y=0;y<a;y++){let b=l?d+x-h-y*f:d+h+y*f;g.drawCircle(this.box.x+this.box.anchor,this.box.y+b,h,u)}}};this.decorations.push(m)}finalizeLayout(){this.ports.lyric={x:this.box.anchor,y:this.box.h},this.octave>0&&(this.ports["tie.top"]={x:this.box.anchor,y:st(this,!0).y-this.box.y-this.ast.size*.05})}paint(t){let e=this.ast.color;for(let n of this.accidentals)to(t,n,this.box,e);let o=ia[this.name]??this.name;o&&t.drawText(o,this.box.x+this.box.anchor,this.box.y+this.numberY,this.numberStyle)}onTimeState(t){let e=this.keySignature=t.keySignature;if(this.playbackState={bpm:t.bpm,velocity:t.velocity,program:t.program},this.resolvedMidi=dn(this.name,this.acc,this.octave,e),this.transposeDiatonic=Ei(this.name,this.acc,this.octave,e),this.name>="0"&&this.name<="9")(this.name==="0"||this.name>="8")&&(this.octave=0,this.acc="");else{let o=ke(this.name,this.acc,this.octave,e);o&&(this.name=o.renderName,this.acc=o.renderAcc,this.octave=o.renderOctave)}}emitPlayback(t){let e=this.ast.name==="9",o=e?37:this.resolvedMidi,n=e?0:this.playbackState?.pitchShift??0,s=this.transposeDiatonic;if(!(t.end.compare(t.start)<=0)){if(o===null){t.span({start:t.start,end:t.end});return}t.note({start:t.start,end:t.end,midi:o+n,velocity:this.playbackState?.velocity??Xt,...e?{percussion:!0}:{transpose:n&&s?i=>s(i)+n:s}})}}};function Nn(r){for(;r.foldedInto;)r=r.foldedInto;return r}var _n=class r extends N{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(t){let e=new Map;for(let o of t.attachments){if(!(o instanceof ho))continue;let[n,s]=o.endPoints,i={start:n.t,end:s.t.clone().add(s.T),shift:o.ast.shift*12},c=e.get(n.track);c?c.push(i):e.set(n.track,[i])}if(e.size!==0){for(let o of e.values())o.sort((n,s)=>n.start.compare(s.start));for(let o of t.astToTemporal.values())for(let n of o){if(!n.playbackState)continue;let s=Nn(n),i=e.get(s.track);if(!i)continue;let c=0;for(let a of i){if(s.t.compare(a.start)<0)break;s.t.compare(a.end)<0&&(c+=a.shift)}c!==0&&(n.playbackState={...n.playbackState,pitchShift:(n.playbackState.pitchShift??0)+c})}}}from;to;shift;size;font;constructor(t,e,o,n=null){super(t,n);let[s,i,c]=this.getArgValue(e,o);if(!Number.isSafeInteger(c)||c===0||!Number.isSafeInteger(c*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",t);this.from=s,this.to=i,this.shift=c,this.size=o.variables.fontsize,this.font=o.variables.numberfont}loweringEnter(t){let e=t.getTemporalNodes(this.from).at(0),o=t.getTemporalNodes(this.to).at(-1),n=e&&Nn(e),s=o&&Nn(o);if(!n||!s||!R(n)||!R(s))return t.diagnostics.push(I.warning.UnresolvedEndpoint("ottava",this.sourceSpan)),[];if(n.track!==s.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 t.addAttachment(new ho(this,n,s)),t.deferFinalize(r.loweringFinalize),[]}toString(t){let e=o=>(o instanceof N?o.label:void 0)??o.toString(t);return`@ottava(${e(this.from)}, ${e(this.to)}, ${this.shift})`}},Di=_n,ho=class{ast;from;to;layer="foreground";constructor(t,e,o){this.ast=t,this.from=e,this.to=o}get sourceSpan(){return this.ast.sourceSpan}get endPoints(){return(this.from.t.compare(this.to.t)||this.from.order-this.to.order)>0?[this.to,this.from]:[this.from,this.to]}createGeometry(t){let e=this.endPoints,[o,n]=e,s=o.layoutLine,i=n.layoutLine;if(t.lines[s].columnOf(o)<0||t.lines[i].columnOf(n)<0)return{regions:[],paint(){}};let{size:c,font:a,shift:l}=this.ast,h=l>0,p=o.track,f=Math.max(.75,c*.035),u={stroke:"#000",strokeWidth:f},d=c*.22,x=d+c*.14,m=f/2,g=c*.45,y=c*.2,b=c*.08,S=String(Math.abs(l)*7+1),C={fontSize:c*.6,fontFamily:a,fontStyle:"italic",textAlign:"left",fill:"#000"},L=t.textMeasurer.measureText(S,C),E=h?-m:m-L.h,_=E+L.baseline,v=Array.from({length:i-s+1},(k,F)=>{let A=s+F,O=A===s,H=A===i,X=t.lines[A].trackRuns,Q=O?o.box.x+(o.ports["body.left"]?.x??0):X.get(p)?.find(j=>!j.T.isZero())?.box.x??t.originX,J=n.box.x+(n.ports["body.right"]?.x??n.box.w);if(!H){J=t.originX+(X.size===0?t.width:0);for(let j of X.values())for(let mt of j)J=Math.max(J,mt.box.x+mt.box.w)}Q>J&&([Q,J]=[J,Q]);let D=O?Q+L.w+b:Q,V=(j,mt,T,M)=>({x:j,y:mt,w:T,h:M,line:A,track:p}),U=D<J?[V(D-m,-m,J-D+f,f)]:[];O&&U.push(V(Q,E,L.w,L.h)),H&&U.push(V(J-m,h?-m:-g-m,f,g+f));let G=V(0,0,0,0);Jt(G,U);let Z=h?1/0:-1/0;for(let j of U)for(let[mt,T]of t.getHorizontalExtents(A,j.x,j.x+j.w)){let M=t.getVisualAxis(A,mt);Z=h?Math.min(Z,M+T.top-y-j.y-j.h):Math.max(Z,M+T.bottom+y-j.y)}if(!Number.isFinite(Z)){let j=t.getRangeExtents(A,O||H?e:void 0,p),mt=t.getVisualAxis(A,p);Z=h?mt+(j?.top??0)-y-(G.y+G.h):mt+(j?.bottom??0)+y-G.y}for(let j of U)j.y+=Z;return G.y+=Z,{left:Q,right:J,lineStart:D,lineY:Z,first:O,last:H,parts:U,region:G}});return{regions:v.map(k=>k.region),occupancy:v.flatMap(k=>k.parts),paint(k){for(let F of v){let{left:A,right:O,lineStart:H,lineY:X,first:Q,last:J}=F;for(let D=H;D<O;D+=x)k.drawLine(D,X,Math.min(D+d,O),X,u);Q&&k.drawText(S,A,X+_,C),J&&k.drawLine(O,X,O,X+(h?g:-g),u)}}}}};var vn=Number.MAX_VALUE,re=new WeakMap,Mn=class r extends N{static def={name:["rest"],description:"\u591A\u5C0F\u8282\u4F11\u6B62",details:`~~~jpfun
|
|
58
|
-
@meter(4,4) | @rest(19) |
|
|
59
|
-
~~~
|
|
60
|
-
\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;constructor(t,e,o,n=null){super(t,n);let[s,i,c]=this.getArgValue(e,o);if(!Number.isSafeInteger(s)||s<=0||s>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",t);if(this.count=s,this.width=o.length2px(i),this.size=o.length2px(c),!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",t);this.font=o.variables.numberfont}labelable(){return this}loweringEnter(t){return t.deferFinalize(r.loweringFinalize,-10),[new On(this)]}static loweringFinalize(t){if(!t.columns.some(i=>i.some(c=>c.mergeKey===vn)))return;let e=0,o=new Map;for(let i of t.astToTemporal.values())for(let c of i){if(e=Math.max(e,c.order+1),!(c.ast instanceof N)||c.ast.callName!=="note"&&c.ast.callName!=="dash")continue;let a=c;for(;a.foldedInto;)a=a.foldedInto;if(c.track!==a.track)continue;let l=o.get(a);(!l||c.order<l.order)&&o.set(a,c)}let n=[],s=new Map;for(let i of t.columns){n.push(i);let c;for(let l of i){if(l.T.compare(0)>0){let p=o.get(l),f=s.get(l.track);if(f&&re.has(f)&&p?.ast instanceof N&&p.ast.callName==="dash")throw new w("E_REST_SUSTAIN","\u589E\u65F6\u7EBF\u4E0D\u80FD\u5EF6\u7EED\u6574\u5C0F\u8282\u4F11\u6B62",p.ast.sourceSpan);s.set(l.track,l)}let h=re.get(l);h&&(!c||h.T.compare(c.T)>0)&&(c=h)}if(!c)continue;let a=c.t.clone();for(let l=1;l<c.ast.count;l++){a.add(c.measureDuration);let h=new W;h.ast=new rt(c.ast.sourceSpan,c.ast),h.t.copyFrom(a),h.track=c.track,h.layoutLine=c.layoutLine,h.order=e++,h.mergeKey=ot,t.astToTemporal.set(h.ast,[h]),n.push([h])}}t.columns=n}toString(){return`@rest(${this.count})`}},Bi=Mn,On=class extends W{measureDuration=new P;metrics;lineWidth=0;textStyle;constructor(t){super(),this.ast=t,this.mergeKey=vn,re.set(this,this),this.initLayoutBox(),this.textStyle={fontSize:t.size,fontFamily:t.font,textAlign:"center"}}onTimeState(t){let e=t.meter;if(!(e instanceof P))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(e.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(e),this.T.copyFrom(e).mul(this.ast.count);let o=t.currentEvent??this;if(o.mergeKey===vn&&this.track===o.track){let n=re.get(o);(!n||this.order<n.order)&&re.set(o,this)}return this.playbackState={bpm:t.bpm},this.T}emitPlayback(t){t.span({start:t.start,end:t.end})}prepareLayout(t){let e=this.ast.size,o=6/Math.sqrt(this.T.toNumber());this.springConfig={alpha_L:o,alpha_R:o},this.metrics=t.textMeasurer.measureText(String(this.ast.count),this.textStyle),this.lineWidth=Math.max(this.ast.width,this.metrics.w+e*.5),this.box.w=this.lineWidth+e*.25,this.box.h=this.metrics.h+e*.5,this.box.anchor=e*.4,this.box.visualAxis=this.box.h-e*.65/2}prepareHorizontal(t){let e=this;for(;t.columnOf(e)<0&&e.foldedInto&&R(e.foldedInto);)e=e.foldedInto;let o=t.columnOf(e);if(o<0)return;let n=c=>t.columns[c]?.find(a=>a.track===e.track&&a.mergeKey===ot)??e,s=n(o-1),i=n(o+1);s!==i&&t.registerHorizontalLayoutHook(s,i,({columns:c,rows:a,start:l,end:h,X:p,fixed:f})=>{for(let u=l;u<h;u++){if(f[u])continue;let d=0;for(let m=0;m<a;m++){let g=c[u][m],y=c[u+1][m],b=re.get(y.time),S=b?b.ast.size*.25:0;d=Math.max(d,g.WR+y.WL+S)}let x=p[u]+d-p[u+1];for(let m=u+1;m<p.length&&(p[m]+=x,!!f[m]);m++);f[u]=1}})}paint(t){let{size:e,count:o}=this.ast,n=this.box.x,s=n+this.lineWidth,i=this.box.y+this.box.visualAxis,c=e*.12,a=c*2,l=(e*.65-c)/2;t.drawLine(n+a/2,i,s-a/2,i,{strokeWidth:a}),t.drawLine(n+c/2,i-l,n+c/2,i+l,{strokeWidth:c}),t.drawLine(s-c/2,i-l,s-c/2,i+l,{strokeWidth:c}),t.drawText(String(o),n+this.lineWidth/2,this.box.y+this.metrics.baseline,this.textStyle)}};var po=class r extends N{contents=[];belows=[];size;get side(){return this.constructor.side}get children(){return this.belows.length?[...this.contents,...this.belows]:this.contents}constructor(t,e,o,n=null){super(t,n),this.size=o.variables.fontsize;for(let[,s]of e){if(s instanceof rt){this.addContent(s,this.side,o);continue}let i=o.parseArgWithType(s.valueSpan,"content",t.start);i!==null&&this.addContent(i,this.side,o)}}labelable(){return this.children.some(N.findLabelable)?this:null}addContent(t,e,o){return this.contents.length===0&&(e="above"),t instanceof r?this.flatten(t,e,o):((e==="above"?this.contents:this.belows).push(t),t.parent=this,this.growSpan(t.sourceSpan),this)}growSpan(t){this.sourceSpan.start=Math.min(this.sourceSpan.start,t.start),this.sourceSpan.end=Math.max(this.sourceSpan.end,t.end)}loweringEnter(t,e){let o=[];return t.isolateFromLoweringGroups(()=>{for(let n of this.children){let s=t.trackedEvents(n,new P,e),i=s.length===1&&s[0].length===1?s[0][0]:void 0;if(!i||!R(i)||(i.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",n.sourceSpan);o.push(i)}}),[new Pn(this,o)]}toString(t){let e=this.contents.map(n=>n.toString(t));return this.belows.length===0?`@up(${e.join(", ")})`:`@down(${[e.length>1?`@up(${e.join(", ")})`:e[0],...this.belows.map(n=>n.toString(t))].join(", ")})`}flatten(t,e,o){let n=t.sourceSpan.start<this.sourceSpan.start?t:this,s=n===t?this:t,[i,...c]=s.contents,a=i?[i]:[],l=[...n.contents,...e==="above"?a:[],...c],h=[...n.belows,...e==="below"?a:[],...s.belows];this.contents=l,this.belows=h;for(let f of this.children)f.parent=this;this.growSpan(t.sourceSpan),t.contents=[],t.belows=[];let p=o.labelableNodes.indexOf(t);return p>=0&&o.labelableNodes.splice(p,1),this}static desugar(t,e,o){let n=e[o++];if(!(n.kind==="sugar"&&n.data===this))return null;let s=this.side==="above"?"@up":"@down",i=t.nodes.length-1;for(;i>=0&&t.nodes[i]instanceof et;)i--;if(i<0)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",n.span,{fn:s});let c=t.nodes[i],a=i;if(c instanceof wt){let p=c,f=p.target;for(;f&&!t.nodes.includes(f);)f=f.parent;for(let u=i-1;u>=0;u--)if(t.nodes[u]===f){c=new tt({start:f.sourceSpan.start,end:p.sourceSpan.end},t.nodes.slice(u,i+1),null),a=u;break}}let l=c instanceof r?c:new this(n.span,new Map,t).addContent(c,"above",t),h=t.nodes;t.nodes=[],t.makeNodes(e,o);for(let p=0;p<t.nodes.length;p++){let f=t.nodes[p];if(f instanceof et)continue;let u=f instanceof r?f.flatten(l,this.side,t):l.addContent(f,this.side,t);for(h.length=a,h.push(u);++p<t.nodes.length;)h.push(t.nodes[p]);return t.nodes=h,t.labelableNodes.push(u.labelable()),e.length}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",n.span,{fn:s})}},Rn=class r extends po{static side="above";static def={name:["up"],description:"\u628A\u540C\u4E00\u65F6\u95F4\u4F4D\u7F6E\u7684\u53EF\u89C1\u5BF9\u8C61\u5411\u4E0A\u5806\u53E0",details:"~~~jpfun\n@up(1, 3, 5)\n~~~\n\n\u7B2C\u4E00\u4E2A\u5185\u5BB9\u53C2\u6570\u4E3A\u5BBF\u4E3B\uFF0C\u5176\u4F59\u4F9D\u6B21\u53E0\u5728\u4E0A\u65B9\uFF1B\u6240\u6709\u6210\u5458\u5171\u4EAB\u5BBF\u4E3B\u65F6\u503C\u3002\u5E38\u7528\u4E8E\u548C\u5F26\u3001\u901F\u5EA6\u8BB0\u53F7\u548C\u97F3\u7B26\u6CE8\u91CA\u3002\n\n**\u7B80\u5199**\uFF1A`1 ^ 3 ^ 5`\u3002\u590D\u6742\u5185\u5BB9\u53EF\u7528 `{...}` \u5305\u88F9\uFF1B\u9700\u8981\u72EC\u7ACB\u8282\u594F\u7684\u5E76\u884C\u5206\u652F\u65F6\uFF0C\u4F7F\u7528 `&` / `@stack`\u3002",allowExtraArgs:!0,extraArgType:"content",args:[]};static deSugarAtom(t,e,o){if(t[e]!=="^")return null;let n={kind:"sugar",data:r,span:{start:e,end:e+1}};return{next:e+1,node:n}}static deSugarRelation(t,e,o){return r.desugar(t,e,o)}},In=class r extends po{static side="below";static def={name:["down"],description:"\u628A\u540C\u4E00\u65F6\u95F4\u4F4D\u7F6E\u7684\u53EF\u89C1\u5BF9\u8C61\u5411\u4E0B\u5806\u53E0",details:"~~~jpfun\n@down(1, $p)\n~~~\n\u7B2C\u4E00\u4E2A\u5185\u5BB9\u53C2\u6570\u4E3A\u5BBF\u4E3B\uFF0C\u5176\u4F59\u4F9D\u6B21\u53E0\u5728\u4E0B\u65B9\u5E76\u5171\u4EAB\u5176\u65F6\u503C\uFF0C\u5E38\u7528\u4E8E\u529B\u5EA6\u7B49\u4E0B\u65B9\u6807\u8BB0\u3002\n\n**\u7B80\u5199**\uFF1A`1 _ $p`\u3002\u4E0E `^` \u6DF7\u5199\u65F6\u5171\u7528\u540C\u4E00\u5BBF\u4E3B\uFF1A`1^2_3` \u5C06 `2` \u653E\u5728 `1` \u4E0A\u65B9\u3001`3` \u653E\u5728\u4E0B\u65B9\u3002",allowExtraArgs:!0,extraArgType:"content",args:[]};static deSugarAtom(t,e,o){if(t[e]!=="_")return null;let n={kind:"sugar",data:r,span:{start:e,end:e+1}};return{next:e+1,node:n}}static deSugarRelation(t,e,o){return r.desugar(t,e,o)}},Hi=Rn,$i=In,Pn=class extends W{members;aboveCount;verticalOffsets=[];constructor(t,e){super(),this.ast=t,this.members=e,this.aboveCount=t.contents.length;let o=e[0];this.mergeKey=o&&o.mergeKey!==o.order?o.mergeKey:bt;let n=this.mergeKey===bt||this.mergeKey===ot;!n&&o&&this.T.copyFrom(o.T),this.initLayoutBox();let s=o?.addon;s&&(this.addon={...s});for(let i of e)n&&this.T.isZero()&&this.T.copyFrom(i.T),i.mergeKey===ot&&(this.mergeKey=ot),i.addon=void 0,i.foldedInto=this}onTimeState(t){let e=this.T.clone(),o,n=!1;for(let i=this.members.length-1;i>=0;i--){let c=this.members[i];!c.T.isZero()&&!this.T.isZero()&&c.T.copyFrom(this.T),c.t.copyFrom(this.t),c.track=this.track,c.layoutLine=this.layoutLine,o=c.onTimeState?.(t),n||=!c.T.isZero()&&!c.T.equals(e)}let s=this.members[0];if(s&&!s.T.isZero()&&(this.T.copyFrom(s.T),n))for(let i of this.members)i.T.isZero()||i.T.copyFrom(this.T);return o}emitPlayback(t){for(let e=this.members.length-1;e>=0;e--)t.play(this.members[e])}prepareHorizontal(t){this.members[0]?.prepareHorizontal?.(t)}prepareLayout(t){this.members[0]&&zt(this,this.members[0]);let e=this.members[0];if(!e){this.box.w=this.box.h=0,this.box.anchor=this.box.visualAxis=0;return}this.box.w=te([e],t);for(let p=1;p<this.members.length;p++)te([this.members[p]],t);this.springConfig={...e.springConfig,...this.springConfig};let o=e.box.x+e.box.anchor,n=this.ast.size*.12;this.verticalOffsets.length=this.members.length,this.verticalOffsets[0]=0;let s=st(e),i=s.y;for(let p=1;p<this.aboveCount;p++){let f=st(this.members[p]);this.verticalOffsets[p]=i-n-f.y-f.h,i-=n+f.h}let c=s.y+s.h;for(let p=this.aboveCount;p<this.members.length;p++){let f=st(this.members[p]);this.verticalOffsets[p]=c+n-f.y,c+=n+f.h}for(let p=0;p<this.verticalOffsets.length;p++)this.verticalOffsets[p]-=i;this.box.h=c-i,this.box.anchor=o,this.box.visualAxis=e.box.visualAxis-i;let a=this.verticalOffsets[0];for(let p in e.ports){let f=e.ports[p];this.ports[p]={...f,x:e.box.x+f.x,y:a+f.y}}this.ports["body.left"]??={x:e.box.x,y:this.box.visualAxis},this.ports["body.right"]??={x:e.box.x+e.box.w,y:this.box.visualAxis};let l=this.aboveCount-1,h=this.verticalOffsets[l];this.ports["tie.top"]={x:o,y:h+(this.members[l].ports["tie.top"]?.y??st(this.members[l],!0).y)}}onPlaced(){for(let t=0;t<this.members.length;t++){let e=this.members[t];e.box.x=this.box.x+this.box.anchor-e.box.anchor,e.box.y=this.box.y+this.verticalOffsets[t],e.onPlaced?.()}}paint(t){for(let e of this.members){e.paint(t);for(let o of e.decorations)o.paint?.(t)}}};var ce=r=>({value:r,unit:"px"}),zn=16,ra={fontSize:zn,textAlign:"center",fill:"#606060"};function ca(r,t,e){let o=r.lastIndexOf("1"),n=r.indexOf("1")!==o;return r.replace(/1/g,(s,i)=>String(n&&i===o?e:t))}var Fn=class{sourceSpan;pattern;marginBottom;style;layer="foreground";constructor(t,e,o,n){this.sourceSpan=t,this.pattern=e,this.marginBottom=o,this.style=n}createGeometry(t){let e=this.style,o=t.pages.map((n,s)=>{let i=ca(this.pattern,s+1,t.pages.length),{w:c,h:a,baseline:l}=t.textMeasurer.measureText(i,e),h=n.y+n.h-this.marginBottom/2;return{text:i,x:n.x+n.w/2,y:h-a/2+l,w:c,h:a,baseline:l}});return{regions:o.map(({x:n,y:s,w:i,h:c,baseline:a})=>({x:n-i/2,y:s-a,w:i,h:c})),paint(n){for(let s of o)n.drawText(s.text,s.x,s.y,e)}}}},Dn=class extends N{static def={name:["page"],description:"\u8BBE\u7F6E\u6587\u6863\u9875\u9762",details:`~~~jpfun
|
|
61
|
-
@page(
|
|
62
|
-
width=794px, height=1123px, top=48px, bottom=48px,
|
|
63
|
-
left=40px, right=40px, gap=1em, fillRatio=0.5,
|
|
64
|
-
numbering="1/1", barNumbering="(1)"
|
|
65
|
-
)
|
|
66
|
-
~~~
|
|
67
|
-
\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:ce(at.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:ce(0)},{name:"top",description:"\u9875\u9762\u4E0A\u8FB9\u8DDD",type:"length",default:ce(at.marginTop)},{name:"bottom",description:"\u9875\u9762\u4E0B\u8FB9\u8DDD\uFF0C\u542F\u7528\u9875\u7801\u65F6\u81F3\u5C11\u4E3A `16px`",type:"length",default:ce(at.marginBottom)},{name:"left",description:"\u9875\u9762\u5DE6\u8FB9\u8DDD",type:"length",default:ce(at.marginLeft)},{name:"right",description:"\u9875\u9762\u53F3\u8FB9\u8DDD",type:"length",default:ce(at.marginRight)},{name:"gap",description:"\u8C31\u9762\u884C\u4E4B\u95F4\u7684\u6700\u5C0F\u95F4\u8DDD",type:"length",default:{value:1,unit:"em"}},{name:"numbering",description:"\u9875\u7801\u683C\u5F0F\uFF0C\u7A7A\u503C\u9690\u85CF\uFF1B`1` \u663E\u793A\u5F53\u524D\u9875\uFF0C`1/1` \u663E\u793A\u5F53\u524D\u9875/\u603B\u9875\u6570",type:"string",default:""},{name:"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:at.fillRatio}]};config;numbering="";barNumbering="";font;constructor(t,e,o,n=null){if(super(t,n),this.font=o.variables.font,o.scopeDepth!==0){o.diagnostics.push(new z("W_PAGE_NOT_TOP_LEVEL","@page \u53EA\u80FD\u5728\u6587\u6863\u9876\u5C42\u58F0\u660E\uFF1B\u5F53\u524D\u58F0\u660E\u5DF2\u5FFD\u7565",t)),this.config=null;return}if(o.documentDeclarations.page){o.diagnostics.push(new z("W_DUPLICATE_PAGE","\u6587\u6863\u53EA\u80FD\u58F0\u660E\u4E00\u4E2A @page\uFF1B\u540E\u7EED\u58F0\u660E\u5DF2\u5FFD\u7565",t)),this.config=null;return}o.documentDeclarations.page=!0;let s=this.getArgValue(e,o),i=s.pop();this.font=s.pop()||o.variables.font;let c=s.pop(),a=s.pop(),[l,h,p,f,u,d,x]=s.map(m=>o.length2px(m));if(!Number.isFinite(l)||l<=0)throw new w("E_INVALID_PAGE_CONFIG","@page \u7684 width \u5FC5\u987B\u662F\u6B63\u6709\u9650\u957F\u5EA6",t);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",t);if([p,f,u,d,x].some(m=>!Number.isFinite(m)||m<0))throw new w("E_INVALID_PAGE_CONFIG","@page \u7684\u8FB9\u8DDD\u548C gap \u5FC5\u987B\u662F\u975E\u8D1F\u6709\u9650\u957F\u5EA6",t);if(u+d>=l)throw new w("E_INVALID_PAGE_CONFIG","@page \u7684\u5DE6\u53F3\u8FB9\u8DDD\u6CA1\u6709\u7559\u4E0B\u53EF\u7528\u5185\u5BB9\u5BBD\u5EA6",t);if(h>0&&p+f>=h)throw new w("E_INVALID_PAGE_CONFIG","@page \u7684\u4E0A\u4E0B\u8FB9\u8DDD\u6CA1\u6709\u7559\u4E0B\u53EF\u7528\u5185\u5BB9\u9AD8\u5EA6",t);if(a&&f<zn)throw new w("E_INVALID_PAGE_CONFIG","@page \u7684 bottom \u81F3\u5C11\u9700\u8981 {minBottom}px \u624D\u80FD\u653E\u4E0B\u9875\u7801",t,{minBottom:zn});this.config=me({width:l,height:h,marginTop:p,marginBottom:f,marginLeft:u,marginRight:d,lineGap:x,fillRatio:i}),this.numbering=a,this.barNumbering=c}loweringEnter(t){return!t||!this.config?[]:(t.setPageConfig(this.config),this.numbering&&t.addAttachment(new Fn(this.sourceSpan,this.numbering,this.config.marginBottom,{...ra,fontFamily:this.font})),this.barNumbering&&$s(t,this.barNumbering,this.font),[])}toString(){if(!this.config)return"@page()";let{width:t,height:e,marginTop:o,marginBottom:n,marginLeft:s,marginRight:i,lineGap:c,fillRatio:a}=this.config;return`@page(width=${t}px, height=${Number.isFinite(e)?e:0}px, top=${o}px, bottom=${n}px, left=${s}px, right=${i}px, gap=${c}px, numbering=${ht(this.numbering)}, barNumbering=${ht(this.barNumbering)}, font=${ht(this.font)}, fillRatio=${a})`}},Wi=Dn;var Bn=class extends N{static def={name:["pagebreak","pb"],description:"\u5F3A\u5236\u6362\u9875",details:`~~~jpfun
|
|
68
|
-
1 2 @br() 3 4 @pagebreak() 5 6
|
|
69
|
-
~~~
|
|
70
|
-
\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(t,e,o,n=null){super(t,n),[this.justify]=this.getArgValue(e,o)}loweringEnter(t){t.deferFinalize(ro.loweringFinalize);let e=new W;return e.ast=this,e.mergeKey=-1,e.addon={breakBefore:1,pageBreakBefore:this.justify},[e]}toString(){return`@pagebreak(justify=${this.justify})`}},Gi=Bn;var Hn=class extends N{static def={name:["program","instrument"],description:"\u8BBE\u7F6E\u5F53\u524D\u97F3\u8F68\u7684 MIDI \u97F3\u8272",details:`~~~jpfun
|
|
71
|
-
@program(40) 1 2 3
|
|
72
|
-
~~~
|
|
73
|
-
\u5207\u6362\u4E3A\u5C0F\u63D0\u7434\u97F3\u8272\u3002\u8BBE\u7F6E\u5C06\u4F5C\u7528\u4E8E\u5F53\u524D\u97F3\u8F68\u7684\u540E\u7EED\u97F3\u7B26\u3002`,allowExtraArgs:!1,args:[{name:"program",description:"\u4ECE 0 \u5F00\u59CB\u7F16\u53F7\u7684 MIDI \u97F3\u8272\uFF0C\u987B\u4E3A `0..127` \u7684\u6574\u6570",type:"number",default:null}]};program;constructor(t,e,o,n=null){super(t,n);let[s]=this.getArgValue(e,o);if(!Number.isSafeInteger(s)||s<0||s>127)throw new w("E_PROGRAM_INVALID","@program \u5FC5\u987B\u662F 0..127 \u7684\u6574\u6570",t);this.program=s}loweringEnter(){let t=new W;return t.ast=this,t.playbackState={program:this.program},t.onTimeState=e=>{e.program=this.program},[t]}toString(){return`@program(${this.program})`}},Vi=Hn;var Yi=.4,aa=(r,t,e)=>r.top-e*Yi-t.bottom,la=(r,t)=>{let e=t*Yi,o=[],n=0;for(let s of r){if(!s){o.push(null);continue}let i=n-s.bottom;o.push({offset:i,extent:s}),n=i+s.top-e}return o},ha={laneKey:"stack",measure:la,place:aa},$n=class r extends N{static def={name:["stack"],description:"\u4E34\u65F6\u591A\u58F0\u90E8",details:"~~~jpfun\n@stack({1 2}, {3/ 4/ 5})\n~~~\n\u63A5\u53D7\u81F3\u5C11\u4E24\u4E2A\u5185\u5BB9\u53C2\u6570\uFF0C\u5404\u5206\u652F\u540C\u65F6\u5F00\u59CB\u3001\u4FDD\u7559\u5404\u81EA\u65F6\u503C\uFF0C\u6574\u4F53\u65F6\u957F\u53D6\u6700\u957F\u5206\u652F\u3002\u9002\u5408\u8282\u594F\u4E0D\u540C\u7684\u4E34\u65F6\u591A\u58F0\u90E8\u3002\n\n**\u7B80\u5199**\uFF1A`{1 2} & {3/ 4/ 5}`\u3002\u53EF\u7EE7\u7EED\u7528 `&` \u8FDE\u63A5\u66F4\u591A\u5206\u652F\uFF1B\u82E5\u8981\u5199\u548C\u5F26\uFF0C\u8BF7\u4F7F\u7528 `up` / `down`\u3002",allowExtraArgs:!0,extraArgType:"content",args:[]};static deSugarAtom(t,e,o){if(t[e]==="&"){let n={kind:"sugar",data:r,span:{start:e,end:e+1}};return{next:e+1,node:n}}return null}static deSugarRelation(t,e,o){let n=e[o++];if(!(n.kind==="sugar"&&n.data===r))return null;let s=t.nodes.length-1;for(;s>=0&&t.nodes[s]instanceof et;s--);let i=s>=0?t.nodes[s]:null;if(i===null)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",n.span);let c=s;if(i instanceof wt){let h=i,p=h.target;for(;p&&!t.nodes.includes(p);)p=p.parent;for(let f=s-1;f>=0;f--)if(t.nodes[f]===p){i=new tt({start:p.sourceSpan.start,end:h.sourceSpan.end},t.nodes.slice(f,s+1),null),c=f;break}}let a=i instanceof r?i:new r(n.span,new Map,t).addContent(i),l=t.nodes;t.nodes=[],t.makeNodes(e,o);for(let h=0;h<t.nodes.length;h++){let p=t.nodes[h];if(!(p instanceof et)){for(a.addContent(p),l.length=c,l.push(a);++h<t.nodes.length;)l.push(t.nodes[h]);return t.nodes=l,e.length}}throw new w("E_STACK_NO_TARGET","@stack\u8BED\u6CD5\u7CD6\u9519\u8BEF: \u53F3\u8FB9\u6CA1\u6709\u627E\u5230\u53EF\u53E0\u52A0\u7684\u76EE\u6807",n.span)}contents=[];get children(){return this.contents}timeFlowModel(){return{children:this.contents,mode:"parallel",tracks:ha}}constructor(t,e,o,n=null){super(t,n);for(let[,s]of e){if(s instanceof rt){this.addContent(s);continue}let i=o.parseArgWithType(s.valueSpan,"content",t.start);i!==null&&this.addContent(i)}}addContent(t){let e=t instanceof r?t.contents:[t],o=t.sourceSpan;this.sourceSpan.start=Math.min(this.sourceSpan.start,o.start),this.sourceSpan.end=Math.max(this.sourceSpan.end,o.end);for(let n of e)n.parent=this;return this.contents.push(...e),t instanceof r&&(t.contents.length=0),this}toString(t){return`@stack(
|
|
74
|
-
${this.contents.map(o=>o.toString(t)).join(`,
|
|
75
|
-
`).split(`
|
|
76
|
-
`).join(`
|
|
77
|
-
`)}
|
|
78
|
-
)`}},Ki=$n;function Ct(r){return(t,e)=>{let o=[];for(let n of e){if(!n.transpose){o.push(n);continue}let s=n.end.clone().sub(n.start),i=r.body.length;if(r.repeat){let a=t.stateAt(n.start).effectiveBpm,l=Math.min(480,Math.max(60,a))/a,h=Math.floor(256/r.body.length),p=Math.min(h,Math.max(1,Math.round(s.toNumber()*8*l/r.body.length)));i*=p}let c=s.div(i);for(let a=0;a<i;a++){let l=r.body[a%r.body.length],h=c.clone().mul(a).add(n.start);o.push({...n,start:h,end:h.clone().add(c),midi:l===0?n.midi:n.transpose(l),transpose:p=>n.transpose(l+p)})}}return o}}var fo={name:"accent",description:"\u91CD\u97F3",weight:.5,shapes:[{path:[{op:"M",x:.21413,y:.4818},{op:"L",x:8.21413,y:3.72071},{op:"L",x:.29494,y:6.92724}],style:{stroke:"#000",strokeWidth:1}}],emitPlayback:r=>r.affectFollowing((t,e)=>{for(let o of e)o.velocity=Math.min(127,o.velocity+20)})};var Wn="repeat.coda";/*!
|
|
79
|
-
* Bravura coda (U+E048), Y axis flipped; https://github.com/steinbergmedia/bravura
|
|
80
|
-
* Copyright (c) 2026, Steinberg Media Technologies GmbH. Reserved Font Name "Bravura".
|
|
81
|
-
* SPDX-License-Identifier: OFL-1.1
|
|
82
|
-
* Full license: Bravura-LICENSE.txt in the package root and dist.
|
|
83
|
-
*/var pa=[{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"}],Ui={name:"coda",description:"\u5C3E\u58F0\u8BB0\u53F7\uFF1A$tocoda \u7684\u8DF3\u8F6C\u76EE\u6807",weight:1.15,playbackMarks:()=>[Wn],shapes:[{path:pa,style:{fill:"#000"}}]};var Gt="repeat.jump",ji={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:()=>[Gt],onVisit:(r,t)=>r.visits(t)>1?void 0:{kind:"jump",column:0}};var Gn="repeat.segno",Xi={name:"segno",description:"\u53CD\u590D\u8BB0\u53F7\uFF1AD.S. \u7684\u56DE\u8DF3\u76EE\u6807",weight:1.15,playbackMarks:()=>[Gn],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 Zi={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:()=>[Gt],onVisit:(r,t)=>r.visits(t)>1?void 0:{kind:"jump",column:r.seek(Gn,t,-1)??0}};var fa={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"}]},ua={mf:8.0028,mp:9.523,ff:6.67866,pp:8.8083},da={fill:"#000"},ma=.79341,Vn=[49,33,16,10,5,1],Yn=[96,112,126,127];function ae(r,t,e){let o=0,n=Array.from(r,(s,i)=>{let c={path:fa[s],style:da,dx:o};return o+=ua[s+r[i+1]]??0,c});return{name:r,description:e,shapes:n,weight:r.includes("f")?1:ma,onTimeState:s=>{s.velocity=t}}}var qi=[{...ae("p",Vn[0],"\u5F31\uFF1B\u652F\u6301 `$p`\u3001`$pp`\u3001`$ppp` \u7B49\u8FDE\u7EED p\uFF0C\u6574\u4F53\u5C45\u4E2D"),pattern:{regex:/^p+$/,resolve:([r])=>ae(r,Vn[Math.min(r.length,Vn.length)-1],"\u5F31\u529B\u5EA6\u8BB0\u53F7")}},ae("mp",64,"\u4E2D\u5F31"),ae("mf",80,"\u4E2D\u5F3A"),{...ae("f",Yn[0],"\u5F3A\uFF1B\u652F\u6301 `$f`\u3001`$ff`\u3001`$fff` \u7B49\u8FDE\u7EED f\uFF0C\u6574\u4F53\u5C45\u4E2D"),pattern:{regex:/^f+$/,resolve:([r])=>ae(r,Yn[Math.min(r.length,Yn.length)-1],"\u5F3A\u529B\u5EA6\u8BB0\u53F7")}}];var xa={},Qi={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:r=>r.scaleFollowingBpm(xa,1,2,{followConnections:!0})};var Ji={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:(r,t)=>{let e=r.seek(Gt,t,1);return e!==void 0&&r.visits(e)>0?{kind:"stop"}:void 0}};var tr={name:"harmonic",description:"\u6CDB\u97F3",weight:.5,shapes:[{circle:{cx:5,cy:5,r:4.5},style:{fill:"none",stroke:"#000",strokeWidth:1}}]};var er={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:fo.emitPlayback};var or={name:"mordent",description:"\u4E0B\u6CE2\u97F3\uFF1A\u672C\u97F3\u3001\u8C03\u5185\u4E0B\u65B9\u4E8C\u5EA6\u3001\u672C\u97F3",weight:.73423,shapes:[{path:[{op:"M",x:7.29541,y:.05944},{op:"C",cx1:7.56541,cy1:-.09056,cx2:7.92541,cy2:.05944,x:8.04541,y:.32944},{op:"C",cx1:8.10541,cy1:.44944,cx2:8.10541,cy2:.56944,x:8.10541,y:1.76943},{op:"L",x:8.10541,y:3.05943},{op:"L",x:8.67541,y:2.21943},{op:"C",cx1:9.18541,cy1:1.46943,cx2:9.24541,cy2:1.37943,x:9.36541,y:1.31943},{op:"C",cx1:9.42541,cy1:1.28943,cx2:9.54541,cy2:1.25943,x:9.60541,y:1.25943},{op:"C",cx1:9.90541,cy1:1.25943,cx2:9.87541,cy2:1.22943,x:11.49541,y:3.20943},{op:"L",x:13.02541,y:5.03943},{op:"L",x:13.50541,y:4.34943},{op:"C",cx1:14.01541,cy1:3.56943,cx2:14.04541,cy2:3.50943,x:14.19541,y:3.44943},{op:"C",cx1:14.61541,cy1:3.26943,cx2:15.06541,cy2:3.59943,x:15.00541,y:4.04943},{op:"C",cx1:14.97541,cy1:4.16943,cx2:14.70541,cy2:4.55943,x:13.50541,y:6.41943},{op:"C",cx1:12.12541,cy1:8.48943,cx2:12.00541,cy2:8.63943,x:11.88541,y:8.69943},{op:"C",cx1:11.82541,cy1:8.72943,cx2:11.70541,cy2:8.75943,x:11.64541,y:8.75943},{op:"C",cx1:11.34541,cy1:8.75943,cx2:11.37541,cy2:8.78943,x:9.81541,y:6.86943},{op:"C",cx1:9.00541,cy1:5.87943,cx2:8.31541,cy2:5.06943,x:8.28541,y:5.00943},{op:"C",cx1:8.22541,cy1:4.97943,cx2:8.22541,cy2:4.97943,x:8.16541,y:5.03943},{op:"C",cx1:8.10541,cy1:5.09943,cx2:8.10541,cy2:5.18943,x:8.10541,y:7.31943},{op:"C",cx1:8.10541,cy1:9.26943,cx2:8.10541,cy2:9.56943,x:8.04541,y:9.65943},{op:"C",cx1:7.86541,cy1:10.10943,cx2:7.23541,cy2:10.13943,x:6.99541,y:9.68943},{op:"C",cx1:6.96541,cy1:9.62943,cx2:6.93541,cy2:9.44943,x:6.93541,y:8.27943},{op:"L",x:6.93541,y:6.92943},{op:"L",x:6.36541,y:7.76943},{op:"C",cx1:5.82541,cy1:8.54943,cx2:5.76541,cy2:8.63943,x:5.64541,y:8.69943},{op:"C",cx1:5.58541,cy1:8.72943,cx2:5.46541,cy2:8.75943,x:5.40541,y:8.75943},{op:"C",cx1:5.10541,cy1:8.75943,cx2:5.13541,cy2:8.78943,x:3.51541,y:6.80943},{op:"L",x:1.98541,y:4.97943},{op:"L",x:1.50541,y:5.66943},{op:"C",cx1:.99541,cy1:6.44943,cx2:.96541,cy2:6.50943,x:.81541,y:6.56943},{op:"C",cx1:.39541,cy1:6.74943,cx2:-.05459,cy2:6.41943,x:.00541,y:5.96943},{op:"C",cx1:.03541,cy1:5.84943,cx2:.30541,cy2:5.45943,x:1.50541,y:3.59943},{op:"C",cx1:2.88541,cy1:1.52943,cx2:3.00541,cy2:1.37943,x:3.12541,y:1.31943},{op:"C",cx1:3.18541,cy1:1.28943,cx2:3.30541,cy2:1.25943,x:3.36541,y:1.25943},{op:"C",cx1:3.66541,cy1:1.25943,cx2:3.63541,cy2:1.22943,x:5.25541,y:3.20943},{op:"L",x:6.78541,y:5.03943},{op:"C",cx1:6.81541,cy1:5.03943,cx2:6.84541,cy2:4.97943,x:6.87541,y:4.94943},{op:"C",cx1:6.93541,cy1:4.82943,cx2:6.93541,cy2:4.79943,x:6.93541,y:2.66943},{op:"C",cx1:6.93541,cy1:.74943,cx2:6.93541,cy2:.44943,x:6.99541,y:.35943},{op:"C",cx1:7.05541,cy1:.20943,cx2:7.14541,cy2:.11943,x:7.29541,y:.05943},{op:"Z"}],style:{fill:"#000"}}],emitPlayback:r=>r.affectFollowing(Ct({body:[0,-1,0]}))};var nr={name:"prall",description:"\u4E0A\u6CE2\u97F3\uFF1A\u672C\u97F3\u3001\u8C03\u5185\u4E0A\u65B9\u4E8C\u5EA6\u3001\u672C\u97F3",weight:.55,shapes:[{path:[{op:"M",x:3.12541,y:.06003},{op:"C",cx1:3.18541,cy1:.03003,cx2:3.30541,cy2:3e-5,x:3.36541,y:3e-5},{op:"C",cx1:3.66541,cy1:3e-5,cx2:3.63541,cy2:-.02997,x:5.25541,y:1.95003},{op:"L",x:6.78541,y:3.78003},{op:"C",cx1:6.81541,cy1:3.78003,cx2:7.35541,cy2:2.94003,x:8.01541,y:1.95003},{op:"C",cx1:9.15541,cy1:.27003,cx2:9.24541,cy2:.12003,x:9.36541,y:.06003},{op:"C",cx1:9.42541,cy1:.03003,cx2:9.54541,cy2:3e-5,x:9.60541,y:3e-5},{op:"C",cx1:9.90541,cy1:3e-5,cx2:9.87541,cy2:-.02997,x:11.49541,y:1.95003},{op:"L",x:13.02541,y:3.78003},{op:"L",x:13.50541,y:3.09003},{op:"C",cx1:14.01541,cy1:2.31003,cx2:14.04541,cy2:2.25003,x:14.19541,y:2.19003},{op:"C",cx1:14.61541,cy1:2.01003,cx2:15.06541,cy2:2.34003,x:15.00541,y:2.79003},{op:"C",cx1:14.97541,cy1:2.91003,cx2:14.70541,cy2:3.30003,x:13.50541,y:5.16003},{op:"C",cx1:12.12541,cy1:7.23003,cx2:12.00541,cy2:7.38003,x:11.88541,y:7.44003},{op:"C",cx1:11.82541,cy1:7.47003,cx2:11.70541,cy2:7.50003,x:11.64541,y:7.50003},{op:"C",cx1:11.34541,cy1:7.50003,cx2:11.37541,cy2:7.53003,x:9.75541,y:5.55003},{op:"L",x:8.22541,y:3.72003},{op:"C",cx1:8.19541,cy1:3.72003,cx2:7.65541,cy2:4.56003,x:6.99541,y:5.55003},{op:"C",cx1:5.85541,cy1:7.23003,cx2:5.76541,cy2:7.38003,x:5.64541,y:7.44003},{op:"C",cx1:5.58541,cy1:7.47003,cx2:5.46541,cy2:7.50003,x:5.40541,y:7.50003},{op:"C",cx1:5.10541,cy1:7.50003,cx2:5.13541,cy2:7.53003,x:3.51541,y:5.55003},{op:"L",x:1.98541,y:3.72003},{op:"L",x:1.50541,y:4.41003},{op:"C",cx1:.99541,cy1:5.19003,cx2:.96541,cy2:5.25003,x:.81541,y:5.31003},{op:"C",cx1:.39541,cy1:5.49003,cx2:-.05459,cy2:5.16003,x:.00541,y:4.71004},{op:"C",cx1:.03541,cy1:4.59004,cx2:.30541,cy2:4.20004,x:1.50541,y:2.34004},{op:"C",cx1:2.88541,cy1:.27004,cx2:3.00541,cy2:.12004,x:3.12541,y:.06004},{op:"Z"}],style:{fill:"#000"}}],emitPlayback:r=>r.affectFollowing(Ct({body:[0,1,0]}))};var sr={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:r=>r.affectFollowing((t,e)=>{let o=e[0].start.clone();for(let n of e)n.start.sub(o).div(2).add(o),n.end.sub(o).div(2).add(o)})};var ir={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 rr={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:(r,t)=>{let e=r.seek(Gt,t,1),o=r.seek(Wn,t,1);return e!==void 0&&r.visits(e)>0&&o!==void 0?{kind:"jump",column:o}:void 0}};var Ne={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:r=>{let t=[...Ne.shapes];for(let e=0;e<r[1].length;e++)t.push({...ga,dx:14.11212+e*5.95219});return{...Ne,name:r[0],anchor:ya,shapes:t}}},shapes:[{path:[{op:"M",x:3.17992,y:5.46383},{op:"L",x:3.61827,y:3.91711},{op:"C",cx1:3.10024,cy1:3.49862,cx2:2.52947,cy2:3.29304,x:1.90541,y:3.29304},{op:"C",cx1:1.50051,cy1:3.29304,cx2:1.18833,cy2:3.40589,x:.95611,y:3.63812},{op:"C",cx1:.72361,cy1:3.87061,cx2:.59743,cy2:4.14281,x:.57105,y:4.46152},{op:"C",cx1:.57105,cy1:4.91944,cx2:.71707,cy2:5.25147,x:1.00913,y:5.47036},{op:"C",cx1:1.30118,cy1:5.68954,cx2:1.61988,cy2:5.79586,x:1.95843,y:5.79586},{op:"C",cx1:1.9916,cy1:5.79586,cx2:2.03157,cy2:5.8157,x:2.06475,y:5.84888},{op:"C",cx1:2.24394,cy1:5.82904,cx2:2.61568,cy2:5.69632,x:3.17992,y:5.46383},{op:"Z"},{op:"M",x:6.579,y:9.87204},{op:"L",x:8.40472,y:3.75096},{op:"C",cx1:8.40472,cy1:3.59162,cx2:8.35167,cy2:3.51193,x:8.23884,y:3.51193},{op:"C",cx1:7.98647,cy1:3.51193,cx2:7.4554,cy2:3.77761,x:6.63883,y:4.3152},{op:"C",cx1:5.82223,cy1:4.84655,cx2:5.37735,cy2:5.15845,x:5.30448,y:5.25145},{op:"C",cx1:5.33764,cy1:5.21147,cx2:5.39068,cy2:5.15845,x:5.46383,y:5.0853},{op:"C",cx1:6.13441,cy1:6.06127,cx2:6.47294,cy2:6.98417,x:6.47294,y:7.86061},{op:"C",cx1:6.41313,cy1:8.53088,cx2:6.18062,cy2:9.12181,x:5.7692,y:9.61968},{op:"C",cx1:5.3643,cy1:10.11758,cx2:4.85308,cy2:10.3634,x:4.24233,y:10.3634},{op:"C",cx1:3.71778,cy1:10.3634,cx2:3.25306,cy2:10.23719,x:2.83483,y:9.99138},{op:"C",cx1:2.42314,cy1:9.74586,cx2:2.20396,cy2:9.39396,x:2.17759,y:8.92271},{op:"C",cx1:2.21077,cy1:8.80986,cx2:2.23061,cy2:8.66384,x:2.23061,y:8.48436},{op:"L",x:2.85469,y:6.0944},{op:"C",cx1:2.58903,cy1:6.2339,cx2:2.21729,cy2:6.30702,x:1.73924,y:6.30702},{op:"C",cx1:1.22829,cy1:6.2804,cx2:.81007,cy2:6.1012,x:.48458,y:5.76917},{op:"C",cx1:.15935,cy1:5.43065,cx2:0,cy2:4.97926,x:0,y:4.4082},{op:"C",cx1:.03318,cy1:3.89045,cx2:.20586,cy2:3.46543,x:.53107,y:3.13369},{op:"C",cx1:.8563,cy1:2.80166,cx2:1.32782,cy2:2.63579,x:1.95843,y:2.63579},{op:"C",cx1:2.55585,cy1:2.63579,cx2:3.17992,cy2:2.87481,x:3.83716,y:3.34606},{op:"L",x:4.89277,y:0},{op:"L",x:6.85119,y:0},{op:"L",x:5.41053,y:4.51453},{op:"C",cx1:6.28694,cy1:3.83064,cx2:7.02389,cy2:3.34606,x:7.62128,y:3.06054},{op:"C",cx1:8.21899,cy1:2.77502,cx2:8.86943,cy2:2.63579,x:9.57321,y:2.63579},{op:"C",cx1:10.05773,cy1:2.63579,cx2:10.30358,cy2:2.83484,x:10.30358,y:3.23974},{op:"C",cx1:10.30358,cy1:3.44559,cx2:10.17738,cy2:3.89046,x:10.09093,y:4.18931},{op:"C",cx1:10.7283,cy1:3.15354,cx2:11.45195,cy2:2.63579,x:12.26199,y:2.63579},{op:"C",cx1:12.6272,cy1:2.63579,cx2:12.91925,cy2:2.76849,x:13.14497,y:3.03417},{op:"C",cx1:13.37717,cy1:3.29957,cx2:13.49001,cy2:3.61175,x:13.49001,y:3.97014},{op:"C",cx1:13.49001,cy1:4.62739,cx2:13.09844,cy2:5.03228,x:12.53419,y:5.03228},{op:"C",cx1:12.16899,cy1:5.03228,cx2:11.85709,cy2:4.79327,x:11.80382,y:4.29536},{op:"C",cx1:11.89029,cy1:3.91031,cx2:11.98982,cy2:3.55191,x:11.98982,y:3.34606},{op:"C",cx1:11.98982,cy1:3.27291,cx2:11.94329,cy2:3.23973,x:11.85709,y:3.23973},{op:"C",cx1:11.74403,cy1:3.23973,cx2:11.53162,cy2:3.34606,x:11.20637,y:3.56522},{op:"C",cx1:10.90752,cy1:3.7708,cx2:10.61547,cy2:4.11615,x:10.31666,y:4.61405},{op:"C",cx1:10.01808,cy1:5.11195,cx2:9.77253,cy2:5.69632,x:9.57321,y:6.36662},{op:"L",x:8.45798,y:9.87203},{op:"L",x:6.57899,y:9.87203},{op:"L",x:6.579,y:9.87204},{op:"Z"},{op:"M",x:5.05893,y:5.62971},{op:"L",x:3.94348,y:8.92274},{op:"C",cx1:3.94348,cy1:9.0288,cx2:3.92364,cy2:9.12179,x:3.89045,y:9.19495},{op:"C",cx1:3.89045,cy1:9.48047,cx2:4.06285,cy2:9.65287,x:4.40821,y:9.70617},{op:"C",cx1:5.404,cy1:9.22134,cx2:5.9019,cy2:8.51787,x:5.9019,y:7.58841},{op:"C",cx1:5.9019,cy1:6.99751,cx2:5.62318,cy2:6.34681,x:5.05893,y:5.62972},{op:"L",x:5.05893,y:5.62971},{op:"Z"}],style:{fill:"#000"}}],emitPlayback:r=>r.affectFollowing(Ct({body:[0,1],repeat:!0}))},cr=Ft(Ne.shapes),ya=cr.x+cr.w/2,ga={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"}};/*!
|
|
84
|
-
* Bravura 1.482 ornamentTurn (U+E567), Y axis flipped; https://github.com/steinbergmedia/bravura
|
|
85
|
-
* Copyright (c) 2026, Steinberg Media Technologies GmbH. Reserved Font Name "Bravura".
|
|
86
|
-
* SPDX-License-Identifier: OFL-1.1
|
|
87
|
-
* Full license: Bravura-LICENSE.txt in the package root and dist.
|
|
88
|
-
*/var ba=[{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"}],ar={path:ba,style:{fill:"#000"}},lr={name:"turn",description:"\u56DE\u97F3",weight:.55,shapes:[ar],emitPlayback:r=>r.affectFollowing(Ct({body:[1,0,-1,0]}))},hr={name:"iturn",description:"\u9006\u56DE\u97F3",weight:.55*396/218,shapes:[ar,{line:{x1:230,y1:-290,x2:230,y2:74},style:{stroke:"#000",strokeWidth:32}}],emitPlayback:r=>r.affectFollowing(Ct({body:[-1,0,1,0]}))};var pr={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 _e=new Map,uo=new Map,le=Object.freeze({core:Object.freeze([Ne,Qi,nr,or,fo,pr,tr,ir,er,sr,lr,hr,...qi,ji,Zi,Xi,Ji,Ui,rr]),table:_e,register:(...r)=>{let t=r.map(e=>{let o=e.name.toLowerCase(),n=e.pattern;if(n){let{regex:s}=n;if(s.global||s.sticky)throw new Error(`Symbol pattern must not use g or y flags: ${o}`);s.ignoreCase||(n={...n,regex:new RegExp(s.source,`${s.flags}i`)})}return{name:o,definition:e,pattern:n}});for(let{name:e,definition:o,pattern:n}of t)_e.set(e,o),n?uo.set(e,n):uo.delete(e)},clear:()=>{_e.clear(),uo.clear()},reset:()=>{le.clear(),le.register(...le.core)},ornament:Ct,bounds:Ft});le.reset();var Kn=class extends N{static def={name:["symbol","$"],description:"\u521B\u5EFA\u4E00\u4E2A\u4E50\u8C31\u7B26\u53F7",get details(){return`~~~jpfun
|
|
89
|
-
1 ^ @symbol(p, size=0.5em)
|
|
90
|
-
~~~
|
|
91
|
-
**\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
|
|
92
|
-
|
|
93
|
-
**\u5DF2\u6CE8\u518C\u8BB0\u53F7**
|
|
94
|
-
${[..._e.values()].map(t=>`- \`$${t.name}\`\uFF1A${t.description}`).join(`
|
|
95
|
-
`)}`},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(t,e,o){if(t[e]!=="$")return null;let n=/^\S+/.exec(t.slice(e+1,o))?.[0];if(!n)return null;let s=e+1+n.length;return{next:s,node:{kind:"call",typed:!0,name:"symbol",args:new Map([[0,n]]),span:{start:e,end:s},syntaxKind:"atom"}}}size;definition;constructor(t,e,o,n=null){super(t,n);let[s,i]=this.getArgValue(e,o);this.size=o.length2px(i);let c=s.toLowerCase(),a=_e.get(c);if(!a){let l;for(let h of uo.values()){let p=h.regex.exec(c);if(!(!p||p.index!==0||p[0]!==c)){if(l)throw new Error(`Ambiguous symbol patterns: ${c}`);l={pattern:h,match:p}}}a=l?.pattern.resolve(l.match)}if(!a){let l="@symbol: \u672A\u77E5\u7B26\u53F7: ${name}",h={name:s};if(o.variables.strict)throw new w("E_UNKNOWN_SYMBOL",l,t,h);o.diagnostics.push(new z("W_UNKNOWN_SYMBOL",l,t,h));return}this.definition=a}loweringEnter(){return[this.definition?new Un(this):new W]}toString(t){return this.definition?`@symbol(${this.definition.name})`:super.toString(t)}},fr=Kn,Un=class extends W{bounds;height;label;scale=1;baseline=0;constructor(t){super(),this.ast=t,this.mergeKey=bt,this.onTimeState=t.definition.onTimeState,this.emitPlayback=t.definition.emitPlayback,this.playbackMarks=t.definition.playbackMarks,this.bounds=Ft(t.definition.shapes??[]),this.height=t.size*(t.definition.weight??1);let e=t.definition.text;this.label=e&&{content:e.content,style:{fontSize:this.height,fontFamily:e.fontFamily,fontStyle:e.fontStyle}},this.initLayoutBox()}prepareLayout(t){if(this.label){let e=t.textMeasurer.measureText(this.label.content,this.label.style);this.box.w=e.w,this.box.h=e.h,this.baseline=e.baseline}else this.scale=this.height/this.bounds.h,this.box.w=this.bounds.w*this.scale,this.box.h=this.height+(this.ast.definition.paddingBottom??0)*this.scale;this.box.anchor=!this.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(t){this.label?t.drawText(this.label.content,this.box.x,this.box.y+this.baseline,this.label.style):Ve(t,this.ast.definition.shapes??[],this.bounds,this.box,this.scale)}playbackFlow(t){let e=this.ast.definition.onVisit;if(!e)return;let o=t(this);return o===void 0?void 0:{range:[o,o],run:n=>e(n,o)}}};var jn=class r extends N{static def={name:["set"],description:"\u8BBE\u7F6E\u5C40\u90E8\u9ED8\u8BA4\u503C",details:"~~~jpfun\n@set(fontsize=20, strict=true)\n{ @set(note.octave=5, note.color=#f00) C D E }\n~~~\n\u63A5\u53D7\u547D\u540D\u53C2\u6570\uFF0C\u53EF\u4E00\u6B21\u8BBE\u7F6E\u591A\u9879\uFF1A\n- **\u7CFB\u7EDF\u9009\u9879**\uFF1A\u5982 `fontsize=20` \u5C06\u5B57\u53F7\u8BBE\u4E3A 20px\uFF0C`strict=true` \u5F00\u542F\u4E25\u683C\u6A21\u5F0F\n- **\u51FD\u6570\u9ED8\u8BA4\u53C2\u6570**\uFF1A\u6309 `\u51FD\u6570\u4E3B\u540D.\u53C2\u6570\u540D=\u503C` \u4E66\u5199\uFF0C\u4F8B\u5982 `note.octave=5`\u3001`note.color=#f00`\uFF1B\u663E\u5F0F\u4F20\u53C2\u4F18\u5148\n\n\u8BBE\u7F6E\u4ECE\u5F53\u524D\u4F4D\u7F6E\u8D77\u751F\u6548\uFF0C\u9650\u4E8E\u5F53\u524D\u4F5C\u7528\u57DF\u53CA\u5176\u5B50\u4F5C\u7528\u57DF\uFF1B\u79BB\u5F00\u5185\u5BB9\u5757\u540E\u6062\u590D\u5916\u5C42\u8BBE\u7F6E\u3002\u5B83\u6309\u6E90\u7801\u4F5C\u7528\u57DF\u89E3\u6790\uFF0C\u4E0E\u6F14\u594F\u65F6\u95F4\u65E0\u5173\u3002",allowExtraArgs:!0,args:[]};static resolveTarget(t,e,o){let n=e.lastIndexOf(".");if(n<0)return[e,Object.hasOwn(dt.systemVariables,e)?dt.systemVariables[e].type:"string"];let s=e.slice(n+1),i=t.functions.get(e.slice(0,n))?.prototype.def,c=i&&jt(i,s,-1);return!i||!c?(t.diagnostics.push(new z("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",o,{key:e})),null):c==="content"||c==="label"?(t.diagnostics.push(new z("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",o,{key:e})),null):[`${ue(i)}.${s}`.toLowerCase(),c]}args=new Map;constructor(t,e,o,n=null){super(t,n);for(let[s,i]of e){let c=i;if(typeof s!="string"){o.diagnostics.push(new z("W_SET_POSITIONAL_ARG","\u51FD\u6570 @set \u4E0D\u63A5\u6536\u4F4D\u7F6E\u53C2\u6570, \u4F4D\u7F6E\u53C2\u6570[{key}]\u5C06\u88AB\u5FFD\u7565",c.span,{key:s}));continue}let a=r.resolveTarget(o,s.toLowerCase(),c.nameSpan??c.span);if(a===null)continue;let[l,h]=a,p=o.parseArgWithType(c.valueSpan,h,t.start);if(p===null){o.diagnostics.push(new z("W_SET_INVALID_VALUE","\u51FD\u6570 @set \u7684\u53C2\u6570\u503C\u89E3\u6790\u5931\u8D25, \u53C2\u6570[{key}]\u5C06\u88AB\u5FFD\u7565",c.valueSpan,{key:s}));continue}o.setVariable(l,p),this.args.set(l,p)}}toString(){return`@set(${Array.from(this.args,([t,e])=>{let o=typeof e=="string"?ht(e):e&&typeof e=="object"&&"unit"in e?`${e.value}${e.unit}`:e;return`${t}=${o}`}).join(", ")})`}},ur=jn;var mr=256;function ve(r){return r.ast instanceof N&&r.ast.callName==="dash"}function Xn(r){return"midi"in r}function Me(r,t=[]){if("host"in r&&R(r.host))return Me(r.host,t);if("members"in r&&Array.isArray(r.members)){for(let e of r.members)Me(e,t);return t}return(typeof r.resolvedMidi=="number"||r.ast.name==="9")&&t.push(r.box.y+r.box.visualAxis),t}function dr(r){let t=Me(r);return(Math.min(...t)+Math.max(...t))/2}function Zn(r,t,e){let o,n=[];for(let s=r.length-1;s>=0;s--){let i=r[s];if(i.origins.at(-1).node.track!==t.track)continue;let c=i.origins.find(a=>a.node===t);if(o){if(c!==o)break}else{if(!c)continue;if(e&&!i.end.equals(e))return[];o=c}if(e&&!i.end.equals(e))return[];n.push(i)}return n}function wa(r){let t=1<<r;return(e,o)=>{let n=[];for(let s of o){let i=s.end.clone().sub(s.start),c=Math.min(mr,Math.max(2,Math.round(i.toNumber()*t))),a=i.div(c);for(let l=0;l<c;l++){let h=a.clone().mul(l).add(s.start);n.push({...s,start:h,end:h.clone().add(a)})}}return n}}var qn=class r extends N{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]}timeFlowModel(){return{children:[this.content],mode:"sequence"}}constructor(t,e,o,n=null){super(t,n);let[s,i]=this.getArgValue(e,o);if(!Number.isSafeInteger(i)||i<1||i>3)throw new w("E_TREMOLO_INVALID_N","@tremolo \u7684\u659C\u6760\u6570 n \u5FC5\u987B\u662F 1 \u5230 3 \u7684\u6574\u6570",t);this.content=s,this.n=i,s.parent=this}loweringEnter(t){for(let o=this.parent;o;o=o.parent)if(o instanceof r)throw new w("E_TREMOLO_CONTENT","@tremolo \u4E0D\u80FD\u5D4C\u5957 @tremolo",this.sourceSpan);let e={nodes:[],onTemporal(o){R(o)&&e.nodes.push(o)}};return t.beginLoweringGroup(this,e),[]}loweringExit(t){let{nodes:e}=t.endLoweringGroup(this),o=e.length>=1&&!ve(e[0])&&e.slice(1).every(ve),n=e.length===2&&!ve(e[0])&&!ve(e[1]);if(!o&&!n||e.some(a=>a.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(e.some(a=>a.track!==e[0].track))throw new w("E_TREMOLO_CROSS_TRACK","@tremolo \u7684\u5185\u5BB9\u5FC5\u987B\u4F4D\u4E8E\u540C\u4E00\u97F3\u8F68",this.sourceSpan);let s=new Qn(e,this);t.addAttachment(s),t.deferFinalize(()=>s.finalize());let i=o?e.at(-1):e[0],c=i.prepareHorizontal;return i.prepareHorizontal=a=>{c?.call(i,a),s.registerHorizontal(a)},[]}toString(t){return`@tremolo(${this.content.toString(t)}, n=${this.n})`}},xr=qn,Qn=class{nodes;owner;layer="foreground";endPoints;get sourceSpan(){return this.owner.sourceSpan}constructor(t,e){this.nodes=t,this.owner=e;let o=t.length===1||ve(t[1]);this.endPoints=o?[t.at(-1)]:[t[0],t[1]]}finalize(){let{nodes:t,owner:e,endPoints:o}=this,n=o.length===1,s=t[0].layoutLine;if(t.some(l=>l.layoutLine!==s))throw new w("E_TREMOLO_CROSS_LINE","@tremolo \u4E0D\u652F\u6301\u8DE8\u8C31\u9762\u884C",e.sourceSpan);if(Me(t[0]).length===0||!n&&Me(t[1]).length===0)throw new w("E_TREMOLO_CONTENT","@tremolo \u7684\u76EE\u6807\u5FC5\u987B\u5305\u542B\u53D1\u58F0\u97F3\u7B26",e.sourceSpan);if(n){let l=t[0],h=wa(e.n),p=l.emitPlayback;l.emitPlayback=f=>{p?.call(l,f),f.defer(u=>{for(let d of Zn(u.spans,l))Xn(d)&&u.transform(d,h)})};return}let[i,c]=t;if(!i.T.equals(c.T))throw new w("E_TREMOLO_DURATION_MISMATCH","@tremolo \u53CC\u97F3\u9707\u97F3\u7684\u4E24\u4E2A\u76EE\u6807\u65F6\u503C\u5FC5\u987B\u76F8\u7B49",e.sourceSpan);let a=c.emitPlayback;c.emitPlayback=l=>{a?.call(c,l);let{start:h,end:p}=l;l.defer(f=>{let u=Zn(f.spans,i,h),d=Zn(f.spans,c);if(u.length===0||d.length===0)return;let x=u.reduce((L,E)=>E.start.compare(L)<0?E.start:L,u[0].start).clone(),m=p.clone().sub(x),g=Math.min(mr/2,Math.max(2,Math.round(m.toNumber()*(1<<e.n-1)))),y=m.clone().div(g*2),b=(L,E)=>(_,v)=>v.flatMap(k=>{let A=(k.end.compare(p)>0?p:k.end).clone().sub(k.start).div(L),O=[];for(let H=0;H<g;H++){let X=A.clone().mul(2*H).add(k.start),Q=E&&H===g-1&&k.end.compare(p)>0?k.end.clone():X.clone().add(A);O.push({...k,start:X,end:Q})}return O}),S=b(g*2,!1),C=b(g*2-1,!0);for(let L of u)L.start.copyFrom(x),L.end.copyFrom(p),Xn(L)&&f.transform(L,S);for(let L of d)L.start.copyFrom(x).add(y),L.end.copyFrom(p),Xn(L)&&f.transform(L,C)})}}registerHorizontal(t){if(this.endPoints.length===1){let a=this.endPoints[0];if(t.columnOf(a)<0)return;let l=a.ast.size,h=a.box.w-a.box.anchor+l*.6;t.registerHorizontalLayoutHook(a,a,({columns:p,start:f})=>{for(let u of p[f])u.box===a.box&&(u.WR=Math.max(u.WR,h))});return}let[e,o]=this.endPoints,n=t.columnOf(e),s=t.columnOf(o);if(n<0||s<0)return;if(s<=n||t.trackIndexOf(o)!==t.trackIndexOf(e)+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 i=Math.max(e.ast.size,o.ast.size),c=e.box.w-e.box.anchor+i*.84;t.registerHorizontalLayoutHook(e,o,({columns:a})=>{for(let l of a[n])l.WR=Math.max(l.WR,c)})}createGeometry(){let{n:t}=this.owner,e=this.endPoints[0],o=e.ast.size,n,s,i,c,a;if(this.endPoints.length===1)n=e.box.x+e.box.w+o*.1,s=n+o*.34,i=e.box.y+e.box.visualAxis+o*.14,c=o*.18,a=o*.12;else{let[u,d]=this.endPoints;o=Math.max(u.ast.size,d.ast.size);let x=o*.12,m=u.box.x+u.box.w+x,g=d.box.x-x;if(g<=m)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 y=Math.min(g-m,o*1.2),b=(m+g)/2;n=b-y/2,s=b+y/2,i=(dr(u)+dr(d))/2,c=Math.min(o*.26,Math.max(o*.16,y*.32)),a=o*.13}let l=Math.max(1,o*.06),h=Sa(t,n,s,i,c,a),p=ut(h);return{regions:[{x:p.x-l/2,y:p.y-l/2,w:p.w+l,h:p.h+l,line:e.layoutLine,track:e.track}],paint(u){u.drawPath(h,{fill:"none",stroke:"#000",strokeWidth:l})}}}};function Sa(r,t,e,o,n,s){let i=[];for(let c=0;c<r;c++){let a=o+(c-(r-1)/2)*s;i.push({op:"M",x:t,y:a+n/2},{op:"L",x:e,y:a-n/2})}return i}var Jn=class extends N{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(t){let e=t.getTemporalNodes(this.from).at(0),o=t.getTemporalNodes(this.to).at(-1);for(;e?.foldedInto;)e=e.foldedInto;for(;o?.foldedInto;)o=o.foldedInto;return!e||!o?(t.diagnostics.push(I.warning.UnresolvedEndpoint("volta",this.sourceSpan)),[]):(t.addAttachment(new ts(this,e,o)),[])}constructor(t,e,o,n=null){super(t,n);let[s,i,c]=this.getArgValue(e,o);this.font=o.variables.numberfont;let a=new Set([c]);for(let l=3;e.has(l);l++)a.add(e.get(l));if(this.from=s,this.to=i,this.passes=[...a].sort((l,h)=>l-h),this.size=o.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",t)}toString(t){let e=o=>o.label??o.toString(t);return`@volta(${e(this.from)}, ${e(this.to)}, ${this.passes.join(", ")})`}},gr=Jn;function yr(r){if(r?.[0]?.mergeKey===ot)return r[0]}var ts=class{ast;from;to;layer="foreground";constructor(t,e,o){this.ast=t,this.from=e,this.to=o}get sourceSpan(){return this.ast.sourceSpan}get endPoints(){return[this.from,this.to]}playbackFlow(t){let e=t(this.from),o=t(this.to);if(e===void 0||o===void 0)return;let n=Math.min(e,o),s=(this.from.t.compare(this.to.t)||this.from.T.compare(this.to.T))>0?this.from:this.to,i=t(s,"end");if(i!==void 0)return{range:[n,i],run:c=>this.ast.passes.includes(Gs(c,n))?void 0:{kind:"jump",column:i+1}}}createGeometry(t){if(!R(this.from)||!R(this.to))return{regions:[],paint(){}};let e=_=>{let v=t.lines[_.layoutLine];return{line:_.layoutLine,view:v,column:v.columnOf(_)}},[o,n]=[e(this.from),e(this.to)];if((o.line>n.line||o.line===n.line&&o.column>n.column)&&([o,n]=[n,o]),o.column<0||n.column<0)return{regions:[],paint(){}};let s=o.view.columns[o.column][0],i=n.view.columns[n.column][0],c=yr(o.view.columns[o.column-1]),a=yr(n.view.columns[n.column+1]),l=s.layoutLine,h=i.layoutLine,p=this.ast.size,f={fontSize:p*.6,fontFamily:this.ast.font,textAlign:"left",fill:"#000"},u=this.ast.passes.map(_=>`${_}.`).join(""),d=t.textMeasurer.measureText(u,f),x=Math.max(1,p*.055),m=x/2,g=d.h*1.2,y=p*.15,b=(g-d.h)/2+d.baseline+2,S=Math.max(x,m+y+d.w),C=Math.max(g+m,b-d.baseline+d.h),L=p*.2,E=Array.from({length:h-l+1},(_,v)=>{let k=l+v,F=s.track,A=1/0,O=k!==l&&k!==h?t.getRangeExtents(k):t.getRangeExtents(k,[s,i]);for(let[G,Z]of O){let j=t.getVisualAxis(k,G)+Z.top;j<A&&(F=G,A=j)}A===1/0&&(A=t.getVisualAxis(k,F));let H=k!==l?this.lineEntryX(t,k,F):c?.layoutLine===k?c.box.x+c.box.anchor+5:s.box.x+(s.ports["body.left"]?.x??0),X=k!==h?this.lineRightX(t,k):a?.layoutLine===k?a.box.x+a.box.anchor:i.box.x+(i.ports["body.right"]?.x??i.box.w),Q=Math.min(H,X),J=Math.max(H,X),D=(G,Z,j)=>({x:G,y:-m,w:Z,h:j+m,line:k,track:F}),V=[D(Q-m,J-Q+x,m)];k===l&&V.push(D(Q-m,S,C)),k===h&&V.push(D(J-m,x,g+m));let U=1/0;for(let G of V)for(let[Z,j]of t.getHorizontalExtents(k,G.x,G.x+G.w))U=Math.min(U,t.getVisualAxis(k,Z)+j.top-L-(G.y+G.h));U===1/0&&(U=A-L-m);for(let G of V)G.y+=U;return{left:Q,right:J,lineY:U,line:k,parts:V}});return{regions:E.map(({parts:_})=>({..._[0],w:Math.max(..._.map(v=>v.x+v.w))-_[0].x,h:Math.max(..._.map(v=>v.h))})),occupancy:E.flatMap(_=>_.parts),paint(_){let v={stroke:"#000",strokeWidth:x};for(let{left:k,right:F,lineY:A,line:O}of E)_.drawLine(k,A,F,A,v),O===l&&(_.drawLine(k,A,k,A+g,v),_.drawText(u,k+y,A+b,f)),O===h&&_.drawLine(F,A,F,A+g,v)}}}lineEntryX(t,e,o){return t.lines[e].trackRuns.get(o)?.find(s=>!s.T.isZero())?.box.x??t.originX}lineRightX(t,e){let o=t.lines[e].trackRuns;if(o.size===0)return t.originX+t.width;let n=t.originX;for(let s of o.values())for(let i of s)n=Math.max(n,i.box.x+i.box.w);return n}};var Cr=new WeakSet,br=new WeakMap;function wr(r,t){let e=br.get(r);if(!e){e=new Map;for(let o of r)for(let{node:n}of o.origins){if(!Cr.has(n))continue;let s=e.get(n);s?s.push(o):e.set(n,[o])}br.set(r,e)}return e.get(t)??[]}var Sr=4/3,Ca=.09,Aa=2.5,La=.5,Ta=.45,es=class extends N{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;fontSize;constructor(t,e,o,n=null){super(t,n);let[s]=this.getArgValue(e,o);for(let[c,a]of e){if(c==="height")continue;let l=a instanceof N?a:o.parseArgWithType(a.valueSpan,"label",t.start);l!==null&&this.endPoints.push(l)}let i=o.labelableNodes.length-1;for(;this.endPoints.length<2&&i>=0;){let c=o.labelableNodes[i--];!c||this.endPoints.includes(c)||this.endPoints.unshift(c)}if(this.endPoints.length<2)throw new w("E_NOT_ENOUGH_ARGS","@{fn} \u8FDE\u97F3\u7EBF\u9700\u8981\u81F3\u5C11\u4E24\u4E2A\u7AEF\u70B9",t,{fn:"tie"});this.height=Math.max(0,o.length2px(s)),this.fontSize=o.variables.fontsize}loweringEnter(t){let e=[];for(let o of this.endPoints){let n=t.getTemporalNodes(o).at(-1);!n||!R(n)||e.push(n)}return e.length<2?(t.diagnostics.push(I.warning.UnresolvedEndpoint("tie",this.sourceSpan)),[]):(t.addAttachment(new os(e,this.height,this.fontSize,this.sourceSpan)),[])}toString(t){let e=this.endPoints.map(o=>o.label);return e.some(o=>o===void 0)?t.slice(this.sourceSpan.start,this.sourceSpan.end):`@tie(${e.join(", ")}, height=${this.height}px)`}},Ar=es,os=class{layer="foreground";sourceSpan;endPoints;height;fontSize;thickness;constructor(t,e,o,n){this.endPoints=t;for(let i of t)Cr.add(i);this.height=e,this.fontSize=o,this.sourceSpan=n;let s=t.reduce((i,c)=>Math.max(i,c.ast.size),0);this.thickness=Math.max(1.2,s*Ca)}applyPlayback(t){for(let e of wr(t.notes,this.endPoints[0])){let o=e;for(let n=1;n<this.endPoints.length;n++){let s=wr(t.notes,this.endPoints[n]).find(i=>i!==o&&i.track===o.track&&i.midi===o.midi&&i.percussion===o.percussion&&o.end.equals(i.start)&&t.connect(o,i));if(!s)break;o=s}}}createGeometry(t){let e=this.createSegments(t),o=e.map(({commands:s,...i})=>i),n=e.map(s=>{let i=t.getHostExtent(s.line,s.track),c=i?Math.max(s.y,t.getVisualAxis(s.line,s.track)+i.top):s.y+s.h;return{x:s.x,y:s.y,w:s.w,h:c-s.y,line:s.line,track:s.track}});return{regions:o,occupancy:n,paint(s){for(let i of e)s.drawPath(i.commands,{fill:"#000"})}}}tiePort(t){let e=t.ports["tie.top"];return e?{x:t.box.x+e.x,y:t.box.y+e.y}:{x:t.box.x+t.box.anchor,y:st(t,!0).y}}createSegments(t){let e=[];for(let o=1;o<this.endPoints.length;o++){let n=this.endPoints[o-1],s=this.endPoints[o];n.layoutLine>s.layoutLine&&([n,s]=[s,n]);let i=this.tiePort(n),c=this.tiePort(s);if(n.layoutLine===s.layoutLine){let l=this.hostTop(t,n.layoutLine,n.track),h=this.hostTop(t,s.layoutLine,s.track);e.push(this.arcSegment(i,c,n.layoutLine,l<=h?n.track:s.track));continue}let a=this.height>0?this.height:this.fontSize*Ta;e.push(this.openingSegment(i,this.lineRightX(t,n.layoutLine),a,n.layoutLine,n.track));for(let l=n.layoutLine+1;l<s.layoutLine;l++)e.push(this.horizontalSegment(this.lineEntryX(t,l,n.track),this.lineRightX(t,l),this.hostTop(t,l,n.track)-a,l,n.track));e.push(this.closingSegment(this.lineEntryX(t,s.layoutLine,s.track),c,a,s.layoutLine,s.track))}return e}resolveHeight(t){if(this.height>0)return this.height;let e=Math.min(1,t/(this.fontSize*Aa));return this.fontSize*La*e*(2-e)}lineEntryX(t,e,o){return t.lines[e].trackRuns.get(o)?.find(i=>!i.T.isZero())?.box.x??t.originX}lineRightX(t,e){let o=t.lines[e].trackRuns;if(o.size===0)return t.originX+t.width;let n=t.originX;for(let s of o.values())for(let i of s)n=Math.max(n,i.box.x+i.box.w);return n}hostTop(t,e,o){return t.getVisualAxis(e,o)+(t.getHostExtent(e,o)?.top??0)}arcSegment(t,e,o,n){let s=t,i=e;s.x>i.x&&([s,i]=[i,s]);let c=(i.x-s.x)*.25,a=s.x+c,l=i.x-c,h=this.resolveHeight(i.x-s.x)*Sr,p=Math.max(0,h-this.thickness*Sr),f=[{op:"M",x:s.x,y:s.y},{op:"C",cx1:a,cy1:s.y-h,cx2:l,cy2:i.y-h,x:i.x,y:i.y},{op:"C",cx1:l,cy1:i.y-p,cx2:a,cy2:s.y-p,x:s.x,y:s.y},{op:"Z"}];return mo(f,o,n)}openingSegment(t,e,o,n,s){let i=t.y-o,c=o*1.2;e=Math.max(e,t.x+c);let a=t.x+c,l=t.x+c*.45,h=i+this.thickness;return mo([{op:"M",x:t.x,y:t.y},{op:"Q",cx:l,cy:i,x:a,y:i},{op:"L",x:e,y:i},{op:"L",x:e,y:h},{op:"L",x:a,y:h},{op:"Q",cx:l,cy:h,x:t.x,y:t.y},{op:"Z"}],n,s)}closingSegment(t,e,o,n,s){let i=e.y-o,c=o*1.2;t=Math.min(t,e.x-c);let a=e.x-c,l=e.x-c*.45,h=i+this.thickness;return mo([{op:"M",x:t,y:i},{op:"L",x:a,y:i},{op:"Q",cx:l,cy:i,x:e.x,y:e.y},{op:"Q",cx:l,cy:h,x:a,y:h},{op:"L",x:t,y:h},{op:"Z"}],n,s)}horizontalSegment(t,e,o,n,s){return mo([{op:"M",x:t,y:o},{op:"L",x:e,y:o},{op:"L",x:e,y:o+this.thickness},{op:"L",x:t,y:o+this.thickness},{op:"Z"}],n,s)}};function mo(r,t,e){return{commands:r,line:t,track:e,...ut(r)}}var ns=class extends N{static def={name:["tuplet"],description:"\u591A\u8FDE\u97F3",details:`~~~jpfun
|
|
96
|
-
@tuplet({1/ 2 3}, normal=4)
|
|
97
|
-
~~~
|
|
98
|
-
\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]}timeFlowModel(){return{mode:"sequence",children:[this.content]}}loweringEnter(t){let e={nodes:[],attachments:[],onTemporal(o){e.nodes.push(o)},onAttachment(o){e.attachments.push(o)}};return t.beginLoweringGroup(this,e),[]}loweringExit(t,e,o){let n=t.endLoweringGroup(this),s=n.nodes.filter(d=>d.T.compare(0)>0);if(s.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 i=s[0].track;if(s.some(d=>d.track!==i))throw new w("E_TUPLET_PARALLEL_CONTENT","@tuplet \u7684\u5185\u5BB9\u4E0D\u80FD\u5305\u542B\u5E76\u884C\u97F3\u8F68",this.sourceSpan);let c=s[0].T.clone(),a=new P;for(let d of s)d.T.compare(c)<0&&c.copyFrom(d.T),a.add(d.T);let l=a.div(c),h=l.numerator;if(l.denominator!==1||h<2||!Number.isSafeInteger(h))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===h)throw new w("E_TUPLET_INVALID_RATIO","@tuplet \u7684 normal \u4E0D\u80FD\u7B49\u4E8E\u63A8\u5BFC\u51FA\u7684 actual ({actual})",this.sourceSpan,{actual:h});let p=n.nodes[0].t;for(let d=1;d<n.nodes.length;d++)n.nodes[d].t.compare(p)<0&&(p=n.nodes[d].t);p=p.clone();let f=new P;for(let d of n.nodes)f.copyFrom(d.t).sub(p).mul(this.normal,h),d.t.copyFrom(p).add(f),d.T.mul(this.normal,h);o.copyFrom(p).add(c.mul(this.normal));let u=s.filter(R);if(u.length>=2){let d=new ss(u,h,this.sourceSpan,this.font,n);t.addAttachment(d),t.deferFinalize(()=>d.validate())}return[]}constructor(t,e,o,n=null){super(t,n);let[s,i]=this.getArgValue(e,o);if(this.font=o.variables.numberfont,!Number.isSafeInteger(i)||i<=0)throw new w("E_TUPLET_INVALID_NORMAL","@tuplet \u7684 normal \u5FC5\u987B\u662F\u6B63\u7684\u5B89\u5168\u6574\u6570",t);this.content=s,this.normal=i,s.parent=this}toString(t){return`@tuplet(${this.content.toString(t)}, ${this.normal})`}},Lr=ns,ss=class{content;layer="foreground";endPoints;actual;sourceSpan;style;size;constructor(t,e,o,n,s){this.content=s,this.endPoints=t,this.actual=e,this.sourceSpan=o,this.size=t.reduce((i,c)=>Math.max(i,c.ast.size),0),this.style={fontSize:this.size*.72,fontFamily:n,textAlign:"center",fill:"#000"}}validate(){let t=this.endPoints[0];if(this.endPoints.some(e=>e.layoutLine!==t.layoutLine))throw new w("E_TUPLET_CROSS_LINE","@tuplet \u7684\u5185\u5BB9\u4E0D\u80FD\u8DE8\u8D8A\u8C31\u9762\u884C",this.sourceSpan)}createGeometry(t){let e=this.endPoints[0],o=this.endPoints[this.endPoints.length-1],n=e.ports["body.left"]?.x??0,s=o.ports["body.right"]?.x??o.box.w,i=e.box.x+n,c=o.box.x+s;i>c&&([i,c]=[c,i]);let a=t.textMeasurer.measureText(String(this.actual),this.style),l=(i+c)/2,h=this.size*.12,p=this.size*.18,f=this.size*.14,u=t.getVisualAxis(e.layoutLine,e.track),d=t.getRangeExtents(e.layoutLine,[e,o],e.track),x=t.getContentBounds(this.content),m=Math.min(u+(d?.top??0),x?.y??1/0),g=Math.max(1,this.size*.055),y=m-f-Math.max(p,a.h/2),b=y+p,S=y-a.h/2+a.baseline,C=l-a.w/2-h,L=l+a.w/2+h,E=[];C>i&&E.push([i,y,C,y]),L<c&&E.push([L,y,c,y]),E.push([i,y,i,b],[c,y,c,b]);let _=g/2,v=Math.min(y-a.h/2,y-_),k=Math.max(y+a.h/2,b+_),F=[{x:i-_,y:v,w:c-i+g,h:k-v,line:e.layoutLine,track:e.track}],A=String(this.actual),O=this.style;return{regions:F,paint(H){let X={stroke:"#000",strokeWidth:g};for(let[Q,J,D,V]of E)H.drawLine(Q,J,D,V,X);H.drawText(A,l,S,O)}}}};var is=[{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"}],Oe=ut(is),kt=2.33,Rt=1.17,Vt=.34,rs=[{op:"M",x:0,y:0},{op:"L",x:0,y:-Vt},{op:"C",cx1:kt*.421,cy1:-Vt+Rt*.077,cx2:kt*.733,cy2:-Vt+Rt*.346,x:kt,y:-Vt+Rt},{op:"L",x:kt*.929,y:-Vt+Rt},{op:"C",cx1:kt*.696,cy1:-Vt+Rt*.535,cx2:kt*.328,cy2:-Vt+Rt*.352,x:0,y:0},{op:"Z"}];function xo(r){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} \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",r)}function Tr(r,t){let e=r.trim(),o=/\s*([\[{])\s*(?:(?:(\d+)\s*)?-\s*(?:(\d+)\s*)?|(\d+)\s*)([\]}])\s*/y,n=[];for(;o.lastIndex<e.length;){let s=o.exec(e);if(!s||s[5]!==(s[1]==="["?"]":"}"))throw xo(t);let i=s[4]??s[2],c=s[4]??s[3],a=i?Number(i):void 0,l=c?Number(c):void 0;for(let h of[a,l])if(h!==void 0&&(!Number.isSafeInteger(h)||h<1))throw xo(t);if(a!==void 0&&l!==void 0&&a>l)throw xo(t);n.push({kind:s[1]==="["?"bracket":"brace",from:a,to:l})}return n}function Er(r,t,e){return r.map(({kind:o,from:n=1,to:s=t})=>{if(n>s||s>t)throw xo(e);return{kind:o,from:n,to:s}})}function cs(r){return r.map(({kind:t,from:e,to:o})=>{let n=`${e??""}-${o??""}`;return t==="brace"?`{${n}}`:`[${n}]`}).join("")}var Ea=/\s/,Nr=2.5,_r=.3,vr=new Set("\uFF08([\uFF3B\uFF5B\u3008\u300A\u300C\u300E\u3010\u3014\u3016\u3018\u301A\u2018\u201C"),as=new Set([...vr,...`\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 kr(r){let t=0,e=r.length;for(;t<e&&as.has(r[t]);)t++;for(;e>t&&as.has(r[e-1]);)e--;return{prefix:r.slice(0,t),body:r.slice(t,e)}}function ka(r){let t=r/2;return(e,o)=>{let n=e.map(a=>a&&a.bottom-a.top>1e-6?a:{top:-t,bottom:t}),s=[],i=0;for(let a=0;a<n.length;a++)a>0&&(i+=n[a-1].bottom+o-n[a].top),s.push(i);let c=(s[0]+s[s.length-1])/2;return s.map((a,l)=>({offset:a-c,extent:n[l]}))}}var Yt=class r extends N{static def={name:["voice","v"],description:"\u58F0\u90E8",details:`~~~jpfun
|
|
99
|
-
@voice({1 2 3}, \u94A2\u7434, \u7537=ha ha ha, \u5973=la la la)
|
|
100
|
-
~~~
|
|
101
|
-
- **\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
|
|
102
|
-
|
|
103
|
-
\u6B4C\u8BCD\u53EF\u7528\u5F15\u53F7\u5305\u88F9\uFF1B\u663E\u5F0F\u8C03\u7528\u4E2D\u542B\u9017\u53F7\u7B49\u6B67\u4E49\u5B57\u7B26\u65F6\u5FC5\u987B\u52A0\u5F15\u53F7\u3002\u82F1\u6587\u7528\u7A7A\u683C\u6216\u8FDE\u5B57\u7B26 \`-\` \u5206\u8BCD\uFF0C\u7528 \`@\` \u5360\u4F4D\u3002
|
|
104
|
-
|
|
105
|
-
**\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
|
|
106
|
-
~~~jpfun
|
|
107
|
-
N(\u94A2\u7434): 1 2 3
|
|
108
|
-
L(\u7537): ha ha ha
|
|
109
|
-
L: la la la
|
|
110
|
-
~~~
|
|
111
|
-
\u884C\u9996\u5141\u8BB8\u7A7A\u767D\uFF0C\u6362\u884C\u7ED3\u675F\u5F53\u524D\u58F0\u660E\uFF1B\u5728\u884C\u672B\u52A0 \`\\\` \u53EF\u7EED\u884C\u3002\u8FD9\u79CD\u5199\u6CD5\u4E2D\u7684\u6B4C\u8BCD\u5141\u8BB8\u76F4\u63A5\u4F7F\u7528\u9017\u53F7\u3002`,allowExtraArgs:!0,extraArgType:"string",args:[{type:"content",description:"\u58F0\u90E8\u7684\u97F3\u7B26\u5185\u5BB9",default:null},{name:"name",description:"\u663E\u793A\u5728\u5DE6\u4FA7\u7684\u58F0\u90E8\u540D\u79F0\uFF0C\u7A7A\u503C\u9690\u85CF\u540D\u79F0",type:"string",default:""}]};static deSugarAtom(t,e,o){if(t[e]!=="N"&&t[e]!=="L")return null;let n=e+1,s={start:n,end:n};if(t[n]==="("){let i=di(t,n+1,o);if(i<0)return null;s={start:n+1,end:i},n=i+1}if(t[n++]!==":")return null;if(t[e]==="N")return{next:n,node:{kind:"sugar",data:{class:r,name:s},span:{start:e,end:n}}};{if(n=Tt(t,n,o),n>=o)return null;let i;if(t[n]==='"'){let a=Mt(t,n,o);if(a<0)return null;i={start:n,end:a+1},n=a+1}else{let a=n;for(;n<o&&t[n]!==`
|
|
112
|
-
`;)n++;i={start:a,end:n}}return{next:n,node:{kind:"sugar",data:{class:r,lyric:i,name:s},span:{start:e,end:n}}}}}static deSugarRelation(t,e,o,n){let s=e[o++];if(s.data?.class!==r)return null;let i=y=>t.parseArgWithType(y,"string")??"";if(s.data?.lyric!==void 0){let y=null,b=t.nodes.length-1;for(;b>=0;b--){let S=t.nodes[b];if(S instanceof et){if(!t.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 r?y=S:S instanceof It&&(y=S.voices.at(-1)??null);break}if(y===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",s.span);return y.addLyric(i(s.data.name),i(s.data.lyric),s.span,t),t.nodes.length=b+1,o<e.length&&typeof e[o]=="number"&&t.source[e[o]]===`
|
|
113
|
-
`&&o++,o}let c=i(s.data.name),a=o,l=0;for(;a<e.length;a++){let y=e[a];if(typeof y=="number"){if(t.source[y]===`
|
|
114
|
-
`){l=1;break}}else if(y.kind==="sugar"&&(y.data?.class===r||y.data?.class===It))break}let h=new dt(t),p=e.slice(o,a);if(a+=l,h.makeNodes(p),h.nodes.length===0)throw I.error.EmptyContent("voice","content",s.span);let f={start:s.span.start,end:h.nodes.at(-1).sourceSpan.end},u=new Map;h.nodes.length===1&&h.nodes[0]instanceof tt?u.set(0,h.nodes[0]):u.set(0,new tt({...f},h.nodes)),u.set("name",c);let d=new r(f,u,t,null);if(n)return t.pushNode(d),n.push(d),a;let x=null,m=t.nodes.length-1,g=null;t:for(;m>=0;m--){let y=t.nodes[m];if(y instanceof et){if(t.variables.strict)break;for(let b=y.sourceSpan.start;b<y.sourceSpan.end;b++)if(t.source[b]===`
|
|
115
|
-
`)break t;g=y;continue}if(y instanceof It){if(!y.createdBySugar)break;x=y}else if(y instanceof r){let b=new Map;b.set(0,y),x=new It({start:y.sourceSpan.start,end:y.sourceSpan.end},b,t,null),x.createdBySugar=!0}break}return x?(t.nodes[m]=x,x.addVoice(d),g&&(t.nodes.length=m+1,t.diagnostics.push(new z("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)))):t.pushNode(d),a}content;name;size;font;lyrics;get children(){return[this.content]}timeFlowModel(){return{children:this.children,mode:"sequence"}}loweringEnter(t){let e=this.parent,o=e instanceof It&&e.voices.length>1?e.braceSpace:0,n=new yo(this,o),s=[],i=[];return t.beginLoweringGroup(this,{attachment:new ps(s,n,i),onAttachment(c){St(c)&&c.layer==="background"&&i.push(c)},onTemporal(c){s.push(c)}}),[n]}loweringExit(t){return t.endLoweringGroup(this),[]}constructor(t,e,o,n=null){super(t,n),this.size=o.variables.fontsize,[this.content,this.name]=this.getArgValue(e,o),this.content.parent=this,this.font=o.variables.font,e.delete(0),e.delete("name"),e.delete(1),this.lyrics=[];for(let[s,i]of e){if(typeof i=="string"){this.addLyric(s,i);continue}let c=i,a=o.parseArgWithType(c.valueSpan,"string",t.start);a===null?o.diagnostics.push(new z("W_VOICE_INVALID_LYRIC","@voice \u7684\u6B4C\u8BCD\u53C2\u6570\u503C\u89E3\u6790\u5931\u8D25, \u53C2\u6570[{key}]\u5C06\u88AB\u5FFD\u7565",c.valueSpan,{key:s})):this.addLyric(s,a)}}addLyric(t,e,o=null,n=null){typeof t=="number"&&(t="");let s=r.parseLyric(e);if(s.length===0&&n&&o&&n.diagnostics.push(new z("W_EMPTY_LYRIC","@voice\u7684\u6B4C\u8BCD{name}\u662F\u7A7A\u7684",o,{name:t})),this.lyrics.push({name:t,tokens:s}),o)for(let i=this;i;i=i.parent)i.sourceSpan.start=Math.min(o.start,i.sourceSpan.start),i.sourceSpan.end=Math.max(o.end,i.sourceSpan.end)}static parseLyric(t){let e=[],o="",n="",s=c=>{e.push(n+c),n=""},i=()=>{o&&s(o),o=""};for(let c=0;c<t.length;c++){let a=String.fromCodePoint(t.codePointAt(c));if(c+=a.length-1,a==="\\"&&c+1<t.length&&/[\\{}@-]/.test(t[c+1]))o+=t[++c];else if(a==="{"){let l=c+1,h="";for(;l<t.length&&t[l]!=="}";l++)t[l]==="\\"&&l+1<t.length&&/[\\{}@-]/.test(t[l+1])?h+=t[++l]:h+=t[l];l<t.length?(i(),s(h),c=l):o+=a}else Ea.test(a)?i():a==="-"?(o+=a,o.length>1&&i()):a==="@"?(o&&(o+=a,i()),e.push("")):vr.has(a)?(i(),n+=a):as.has(a)?o?o+=a:n||!e.at(-1)?n+=a:e[e.length-1]+=a:a.charCodeAt(0)>127?(i(),s(a)):o+=a}return i(),n&&(e.at(-1)?e[e.length-1]+=n:e.push(n)),e}toString(t){let e=[`${this.content.toString(t)},${ht(this.name)}`];for(let o of this.lyrics){let n=ht(o.tokens.map(s=>s.length===0?"@":`{${s.replace(/[\\{}@-]/g,"\\$&")}}`).join(" "));e.push(o.name?`${o.name}=${n}`:n)}return`@voice(
|
|
116
|
-
${e.join(`,
|
|
117
|
-
`)}
|
|
118
|
-
)`}},It=class r extends N{static def={name:["voices","vs"],description:"\u591A\u4E2A\u58F0\u90E8",details:'~~~jpfun\n@voices(\n @voice({1 2 3}, \u94A2\u7434, \u7537=ha ha ha),\n @voice({3 4 5}, , "la la la")\n)\n~~~\n\n\u63A5\u53D7\u591A\u4E2A\u58F0\u90E8\u4F5C\u4E3A\u4F4D\u7F6E\u53C2\u6570\uFF0C\u5C06\u5B83\u4EEC\u6309\u65F6\u95F4\u5BF9\u9F50\u3001\u5206\u884C\u6392\u5E03\uFF1B\u58F0\u90E8\u540D\u79F0\u548C\u6B4C\u8BCD\u7531\u5404\u81EA\u7684 `@voice` \u63D0\u4F9B\n\n**\u89C6\u89C9\u8FDE\u63A5**\uFF1A\u4EC5\u547D\u540D\u53C2\u6570 `connect` \u4F7F\u7528\u5B57\u7B26\u4E32\uFF0C\u5982 `connect="[1-4]{5-7}"`\u3002\n`[]` \u662F\u73B0\u6709\u62EC\u7EBF\uFF0C`{}` \u662F\u5F2F\u66F2\u5927\u62EC\u53F7\uFF1B\u7F16\u53F7\u4ECE 1 \u5F00\u59CB\uFF0C\u7701\u7565\u8D77\u70B9/\u7EC8\u70B9\u8868\u793A\u9996/\u672B\u58F0\u90E8\u3002\n`[3]` \u7B49\u4EF7\u4E8E `[3-3]`\uFF0C`{3}` \u7B49\u4EF7\u4E8E `{3-3}`\uFF0C\u7528\u4E8E\u5355\u4E2A\u58F0\u90E8\u3002\n\u9ED8\u8BA4 `"[-]"` \u8FDE\u63A5\u5168\u90E8\u58F0\u90E8\uFF1B`""` \u53EA\u4FDD\u7559\u516C\u5171\u7EC6\u8FDE\u8C31\u7EBF\u3002\u672A\u6307\u5B9A\u7684\u58F0\u90E8\u4ECD\u6709\u7EC6\u7EBF\uFF0C\u8303\u56F4\u53EF\u4EE5\u91CD\u53E0\uFF0C\u4E0D\u6539\u53D8\u58F0\u90E8\u6216\u64AD\u653E\u5173\u7CFB\u3002\n\u7528 `@set(voices.connect="{1-2}[3-]")` \u8BBE\u7F6E\u540E\u7EED\u591A\u58F0\u90E8\u5757\u7684\u9ED8\u8BA4\u65B9\u6848\uFF0C\u663E\u5F0F\u53C2\u6570\u5199\u5728\u6240\u6709\u58F0\u90E8\u4E4B\u540E\u3002\n\n**\u7B80\u5199**\uFF1A\u8FDE\u7EED\u58F0\u660E\u591A\u4E2A `N:` \u58F0\u90E8\u53CA\u5176 `L:` \u6B4C\u8BCD\uFF0C\u4F1A\u81EA\u52A8\u7EC4\u6210 `voices`\n\n~~~jpfun\nN(\u94A2\u7434): 1 2 3\nL(\u7537): ha ha ha\nN: 3 4 5\nL: la la la\n~~~\n\n\u8FDE\u63A5\u58F0\u660E `V{}:`\u3001`V[]:`\u3001`V|:` \u5206\u522B\u6307\u5B9A\u540E\u7EED\u58F0\u90E8\u7684\u5F2F\u66F2\u5927\u62EC\u53F7\u3001\u73B0\u6709\u62EC\u7EBF\u548C\u4EC5\u7EC6\u7EBF\uFF0C\u540E\u9762\u7684 `N:` \u53EF\u4EE5\u540C\u884C\uFF0C\u4E5F\u53EF\u4EE5\u6362\u884C\u3002\n\u5230\u4E0B\u4E00\u6761 V \u58F0\u660E\u6216\u5F53\u524D\u5757\u672B\u5C3E\u7ED3\u675F\uFF0C\u7EC4\u95F4\u4E0D\u7A7A\u884C\uFF1B\u7A7A\u884C\u7ED3\u675F\u6574\u4E2A\u591A\u58F0\u90E8\u5757\u3002\n\u51FA\u73B0 V \u58F0\u660E\u65F6\uFF0C\u5F53\u524D\u5757\u5B8C\u6574\u66FF\u6362\u9ED8\u8BA4\u8FDE\u63A5\u65B9\u6848\uFF0C\u4E0D\u5F71\u54CD\u540E\u9762\u7684\u5757\u3002V \u4E0D\u521B\u5EFA\u97F3\u8F68\uFF0CL \u4ECD\u5C5E\u4E8E\u524D\u9762\u7684 N\u3002\n\n~~~jpfun\nV{}: N(\u53F3\u624B): 1 2 3\nN(\u5DE6\u624B): 5 6 7\nV[]: N(\u5973\u9AD8): 6 6 5\nL: \u554A \u554A \u554A\nN(\u5973\u4F4E): 1 2 3\n~~~',allowExtraArgs:!0,extraArgType:"content",args:[{name:"connect",namedOnly:!0,type:"string",default:"[-]",description:"\u89C6\u89C9\u8FDE\u63A5\uFF1A[1-4] \u4E3A\u73B0\u6709\u62EC\u7EBF\uFF0C{5-7} \u4E3A\u5F2F\u66F2\u5927\u62EC\u53F7\uFF1B[3]\u3001{3} \u8868\u793A\u5355\u4E2A\u58F0\u90E8\uFF0C\u7701\u7565\u8303\u56F4\u7AEF\u70B9\u8868\u793A\u9996/\u672B\u58F0\u90E8\uFF0C\u7A7A\u5B57\u7B26\u4E32\u53EA\u4FDD\u7559\u516C\u5171\u8FDE\u8C31\u7EBF\u3002"}]};static deSugarAtom(t,e,o){if(t[e]!=="V")return null;let n=/^V(\{\}|\[\]|\|):/.exec(t.slice(e,o));if(!n)return null;let s=e+n[0].length,i={kind:"sugar",data:{class:r,kind:n[1]==="{}"?"brace":n[1]==="[]"?"bracket":"line"},span:{start:e,end:s}};return{next:s,node:i}}static deSugarRelation(t,e,o){let n=e[o];if(typeof n=="number"||n.kind!=="sugar"||n.data?.class!==r)return null;let s=t.nodes.length-1;for(;s>=0&&t.nodes[s]instanceof et;){let{sourceSpan:u}=t.nodes[s],d=t.source.slice(u.start,u.end);if(d.includes(`
|
|
119
|
-
`)||d.trim())break;s--}let i=t.nodes[s],c=i instanceof Yt?[i]:i instanceof r&&i.createdBySugar?[...i.voices]:[],a=c.length>0,l=[],h=o;for(;h<e.length;){let u=e[h];if(typeof u=="number"||u.kind!=="sugar"||u.data?.class!==r)break;h++;let d=e[h];typeof d=="number"&&t.source[d]==="\r"&&h++;let x=e[h];typeof x=="number"&&t.source[x]===`
|
|
120
|
-
`&&h++;let m=new dt(t),g=c.length+1;for(;h<e.length;){let y=e[h];if(typeof y=="number"||y.kind!=="sugar"||y.data?.class!==Yt)break;h=Yt.deSugarRelation(m,e,h,c)}if(c.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",u.span);(u.data.kind==="brace"||u.data.kind==="bracket")&&l.push({kind:u.data.kind,from:g,to:c.length})}let p=new Map;c.forEach((u,d)=>p.set(d,u)),p.set("connect",cs(l));let f=new r({start:a?i.sourceSpan.start:n.span.start,end:c.at(-1).sourceSpan.end},p,t);return f.createdBySugar=!0,a&&(t.nodes.length=s),t.pushNode(f),h}voices;createdBySugar=!1;size;braceSpace;connect;get connectionSpecs(){return Tr(this.connect,this.sourceSpan)}measure;get children(){return this.voices}timeFlowModel(){return{children:this.children,mode:"parallel",tracks:{laneKey:`voices/${this.voices.length}`,hostIndex:null,measure:this.measure}}}loweringEnter(t){let e=[];return t.beginLoweringGroup(this,{attachment:new hs(e,this,Er(this.connectionSpecs,this.voices.length,this.sourceSpan)),onTemporal:o=>{o instanceof yo&&o.ast.parent===this&&e.push(o)}}),[]}loweringExit(t){return t.endLoweringGroup(this),[]}constructor(t,e,o,n=null){super(t,n),this.voices=[],this.size=o.variables.fontsize,this.braceSpace=Math.max(o.variables.fontsize,(Nr*(kt+.5)+.5)/(1-_r)),this.measure=ka(o.variables.fontsize),[this.connect]=this.getArgValue(e,o);for(let[s,i]of e){if(s==="connect")continue;let c=i instanceof rt?i.sourceSpan:i.valueSpan,a=i instanceof rt?i:o.parseArgWithType(c,"content",t.start);if(!(a instanceof Yt))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}",c,{actual:String(a?.constructor.name)});this.addVoice(a)}if(this.voices.length===0)throw new w("E_VOICES_EMPTY","@voices \u5FC5\u987B\u81F3\u5C11\u5305\u542B\u4E00\u4E2A @voice \u51FD\u6570",t)}addVoice(t){this.voices.push(t),t.parent=this,this.sourceSpan.start=Math.min(t.sourceSpan.start,this.sourceSpan.start),this.sourceSpan.end=Math.max(t.sourceSpan.end,this.sourceSpan.end)}toString(t){let e=this.voices.map(o=>` ${o.toString(t)}`);return e.push(` connect=${ht(cs(this.connectionSpecs))}`),`@voices(
|
|
121
|
-
${e.join(`,
|
|
122
|
-
`)}
|
|
123
|
-
)`}},Mr=Yt,Or=It,ls=.82,Na=.6;function Rr(r,t){return{fontFamily:t,fontSize:r*ls,fill:"#000",fontWeight:600}}var yo=class extends W{braceSpace;textBaselineY=0;constructor(t,e){super(),this.ast=t,this.braceSpace=e,this.mergeKey=-2,(t.name||e>0||t.lyrics.some(o=>o.name))&&this.initLayoutBox()}prepareLayout(t){let e=this.ast.name?t.textMeasurer.measureText(this.ast.name,this.style):{w:0,h:0,baseline:0},o=e.w;for(let s of this.ast.lyrics){if(!s.name)continue;let i=t.textMeasurer.measureText(s.name,Rr(this.ast.size,this.ast.font));o=Math.max(o,i.w)}let n=this.braceSpace>0?this.braceSpace:o>0?this.ast.size*Na:0;this.box.w=o+n,this.box.h=e.h,this.box.anchor=o,this.box.visualAxis=e.h/2,this.textBaselineY=e.baseline,this.springConfig.alpha_R=.45}get style(){return{fontSize:this.ast.size*.85,fontFamily:this.ast.font,fill:"#000",fontWeight:600,textAlign:"right"}}paint(t){this.ast.name&&t.drawText(this.ast.name,this.box.x+this.box.anchor,this.box.y+this.textBaselineY,this.style)}},hs=class{connections;layer="background";names;ast;get sourceSpan(){return this.ast.sourceSpan}constructor(t,e,o){this.connections=o,this.names=t,this.ast=e}createGeometry(){if(this.names.length<2)return{regions:[],paint(){}};let t=this.names[0].box,e=this.names[this.names.length-1].box,o=this.ast.size,n=t.y+t.visualAxis-o*.5,s=e.y+e.visualAxis+o*.5;if(s-n<1e-6)return{regions:[],paint(){}};let i=Math.max(Nr,o*.19),c=i*kt,a=i*Rt,l=t.x+t.anchor+this.ast.braceSpace*_r+i/2,h=Math.min(i*.67,o*.25),p={x:l+i*1.33-i*.165,y:n+h,w:i*.33,h:s-n-h*2},f=[],u=[],d=[p];for(let x of this.connections){let m=this.names[x.from-1].box,g=this.names[x.to-1].box,y=m.y+m.visualAxis-o*.5,b=g.y+g.visualAxis+o*.5;if(x.kind==="bracket")f.push({x:l-i/2,y,w:i,h:b-y}),u.push({commands:rs,transform:{x:l,y,scaleX:i,scaleY:-i}},{commands:rs,transform:{x:l,y:b,scaleX:i,scaleY:i}}),d.push({x:l-i/2,y:y-a,w:c+i/2,h:b-y+a*2});else{let S=o*.35,C=p.x-o*.12-S,L=S/Oe.w,E=(b-y)/Oe.h;u.push({commands:is,transform:{x:C-Oe.x*L,y:y-Oe.y*E,scaleX:L,scaleY:E}}),d.push({x:C,y,w:S,h:b-y})}}return f.push(p),this.names[0].ports["bar.number"]={x:l+i*1.33-t.x,y:Math.min(n,...d.map(x=>x.y))-t.y},{regions:d,paint(x){for(let m of f)x.drawRect(m.x,m.y,m.w,m.h,{fill:"#000"});for(let m of u)x.drawPath(m.commands,{fill:"#000"},m.transform)}}}},ps=class{temporalMembers;nameHost;frames;layer="foreground";get sourceSpan(){return this.nameHost.ast.sourceSpan}constructor(t,e,o){this.temporalMembers=t,this.nameHost=e,this.frames=o}prepareHorizontal(t,e){let o=this.temporalMembers.filter(R).filter(c=>c.ports?.lyric),{lyrics:n,size:s}=this.nameHost.ast;if(o.length===0||n.length===0)return;let i={fontSize:s*ls,fontFamily:this.nameHost.ast.font,fill:"#000"};for(let c=0;c<o.length;c++){let a=o[c],l=0;for(let h of n){let p=h.tokens[c];if(p){let{body:f}=kr(p);f&&(l=Math.max(l,e.textMeasurer.measureText(f,i).w/2))}}l!==0&&t[a.layoutLine]?.registerHorizontalLayoutHook(a,a,({columns:h,start:p})=>{let f=h[p].find(d=>d.time===a);if(!f)return;let u=a.ports.lyric.x-a.box.anchor;f.WL=Math.max(f.WL,l-u),f.WR=Math.max(f.WR,l+u)})}}createGeometry(t){let e=this.prepareGeometry(t);return{regions:e,paint(o){for(let n of e)o.drawText(n.text,n.x,n.y+n.textBaselineY,n.style)}}}prepareGeometry(t){let{lyrics:e,size:o}=this.nameHost.ast,n=[],s=this.temporalMembers.filter(R).filter(y=>y.ports?.lyric);if(s.length===0||e.length===0)return n;let i=new Map;for(let y of s){let b=i.get(y.layoutLine);b||i.set(y.layoutLine,b=new Map);let S=b.get(y.track)??{bottom:-1/0,owner:y.track},C=st(y),L=C.y+C.h,E=y.track;for(let _ of this.frames){let v=t.getAttachmentBox(_);if(v.x+v.w<C.x||v.x>C.x+C.w||v.y+v.h<=L)continue;let k=t.getAttachmentOccupancy(_);if(!k)throw new Error("Layout attachment dependency has not been measured");let F=k.filter(A=>A.line===y.layoutLine);if(!(k.some(A=>A.line!==void 0)&&F.length===0)){L=v.y+v.h;for(let A of F)A.line!==void 0&&t.getVisualAxis(A.line,A.track)>t.getVisualAxis(y.layoutLine,E)&&(E=A.track)}}L>=S.bottom&&(S.owner=E),S.bottom=Math.max(S.bottom,L),b.set(y.track,S)}let c=o*ls,a=o*.24,l=o*.32,h={fontSize:c,fontFamily:this.nameHost.ast.font,fill:"#000"},p=Rr(o,this.nameHost.ast.font),f=t.textMeasurer.measureText("M",h).baseline+l,u=(y,b)=>y+f+b*(c+a);if(this.frames.length)for(let[y,b]of i){if(b.size<2)continue;let S=new Map;for(let[,C]of[...b].sort(([L],[E])=>t.getVisualAxis(y,L)-t.getVisualAxis(y,E))){let L=S.get(C.owner)??0;C.bottom+=L*e.length*(c+a),S.set(C.owner,L+1)}}let{box:d,layoutLine:x,track:m}=this.nameHost,g=i.get(x)?.get(m);for(let y=0;y<e.length;y++){let b=e[y];for(let C=0;C<b.tokens.length&&C<s.length;C++){let L=b.tokens[C],E=s[C],_=i.get(E.layoutLine)?.get(E.track);if(!L||!_)continue;let v=t.textMeasurer.measureText(L,h),{prefix:k,body:F}=kr(L),A=F?t.textMeasurer.measureText(F,h).w:0,O=k?t.textMeasurer.measureText(k,h).w:0;n.push({text:L,style:h,textBaselineY:v.baseline,x:E.box.x+E.ports.lyric.x-A/2-O,y:u(_.bottom,y)-v.baseline,w:v.w,h:v.h,line:E.layoutLine,track:_.owner})}if(!b.name||!d||!g)continue;let S=t.textMeasurer.measureText(b.name,p);n.push({text:b.name,style:p,textBaselineY:S.baseline,x:d.x+d.anchor-S.w,y:u(g.bottom,y)-S.baseline,w:S.w,h:S.h,line:x,track:g.owner})}return n}};var go=[Fi,ei,Bi,Ws,ee,ii,Lr,xr,Mr,Or,ro,Gi,Wi,Oi,Ki,Hi,$i,Hs,li,fi,Ar,Js,pi,ri,ti,gr,Di,Ls,ur,eo,Ke,oo,Vi,no,fr];function fs(r,t={}){let e=new Map,o=new Set(r);for(let n of o){let s=n.layoutDecorationHandler;if(!s)continue;let i=n.def?.name;if(!i)continue;let c=Array.isArray(i)?i[0]:i;e.set(Pt(c),s)}return{textMeasurer:t.textMeasurer??an,decorationHandlers:e}}var Re=class r{activeFinalizers=new Map;cnt=0;usedTracks=new Set;attachments=[];page;astToTemporal=new Map;activeLoweringGroups=[];diagnostics;constructor(t=[]){this.diagnostics=t}setPageConfig(t){this.page=t}lowerDocument(t){this.cnt=0,this.usedTracks.clear(),this.activeFinalizers.clear(),this.attachments=[],this.page=void 0,this.astToTemporal=new Map,this.activeLoweringGroups=[];let e=new Bt,o=new P,n=this.trackedEvents(t,o,e);return this.solidifyColumns(n,o),this.postprocessResult({diagnostics:this.diagnostics,columns:n,attachments:this.attachments,astToTemporal:this.astToTemporal,duration:o,rootTrack:e,tracks:[...this.usedTracks],page:this.page})}solidifyColumns(t,e){let o=0;for(let f of t){let u=0;for(let d of f){let x=d.addon?.breakBefore??0;x>u&&(u=x)}o+=u,f.layoutLine=o}let n={bpm:vt,velocity:Xt,keySignature:de,program:Fe},s=new Map,i=new Map,c=f=>s.get(f)??(f.parent?c(f.parent):Xt),a=f=>i.get(f)??(f.parent?a(f.parent):Fe),l=new P;for(let f of t){l.isZero()||f.shiftTime(l);let u;for(let d of f){n.currentEvent=d,n.velocity=c(d.track),n.program=a(d.track);let x=d.onTimeState?.(n);x&&!x.isZero()&&(!u||x.compare(u)>0)&&(u??=new P).copyFrom(x),s.set(d.track,n.velocity),i.set(d.track,n.program)}u&&l.add(u)}if(l.isZero())return;let h=new Set(i.keys()),p=new P;e.set(0);for(let f=t.length-1;f>=0&&h.size>0;f--){let u=t[f];for(let d=u.length-1;d>=0;d--){let x=u[d];if(!h.delete(x.track))continue;let m=x.T;p.copyFrom(x.t),m.isZero()||p.add(m),p.compare(e)>0&&e.copyFrom(p)}}}beginLoweringGroup(t,e){this.activeLoweringGroups.push({owner:t,group:e})}endLoweringGroup(t){let e=this.activeLoweringGroups.pop();if(!e)throw new Error("No active lowering group to end");if(e.owner!==t)throw new Error("Lowering groups must end in reverse order");return e.group.attachment&&this.addAttachment(e.group.attachment),e.group}postprocessResult(t){if(this.activeLoweringGroups.length>0)throw new Error("Lowering groups must be closed before post-processing");let e=this.activeFinalizers.size;if(e===0)return t;if(e===1)return this.activeFinalizers.keys().next().value(t),t;let o=[...this.activeFinalizers.entries()].sort((n,s)=>n[1]-s[1]);for(let[n]of o)n(t);return t}deferFinalize(t,e=0){let o=this.activeFinalizers.get(t);(o===void 0||e<o)&&this.activeFinalizers.set(t,e)}addAttachment(t){this.attachments.push(t);for(let e=this.activeLoweringGroups.length-1;e>=0;e--)this.activeLoweringGroups[e].group.onAttachment?.(t)}getTemporalNodes(t){return this.astToTemporal.get(t)??[]}isolateFromLoweringGroups(t){let e=this.activeLoweringGroups;this.activeLoweringGroups=[];try{return t()}finally{this.activeLoweringGroups=e}}initEvent(t,e,o,n){t.t.add(o),this.usedTracks.add(n),t.track=n,t.ast??=e,t.order=this.cnt++,t.mergeKey??=t.order}trackedEvents(t,e,o,n=[]){this.appendEvents(t.loweringEnter(this,o),t,e,o,n);let s=t.timeFlowModel(this);if(s)switch(s.mode){case"sequence":for(let i of s.children)this.trackedEvents(i,e,o,n);break;case"parallel":{let i=s.tracks,c=s.children,a=i.hostIndex===void 0?0:i.hostIndex,l=o.group(i,a===null?c.length:c.length-1),h=[];for(let u=0;u<c.length;u++){let d=c[u],x=u===a?o:l.members[a===null||u<a?u:u-1],m=e.clone(),g=this.trackedEvents(d,m,x);g.length===0&&this.diagnostics.push(I.warning.ZeroTimeTrack(d.sourceSpan,u+1)),h.push(g)}let p=n.length;for(let u of r.anchorAlign(h))n.push(u);let f=new P;for(let u=p;u<n.length;u++)for(let d of n[u])f.copyFrom(d.t).add(d.T),f.compare(e)>0&&e.copyFrom(f)}break}return this.appendEvents(t.loweringExit(this,o,e),t,e,o,n),n}appendEvents(t,e,o,n,s){let i;for(let c of t){this.initEvent(c,e,o,n),this.indexTemporal(c);for(let l=this.activeLoweringGroups.length-1;l>=0;l--)this.activeLoweringGroups[l].group.onTemporal?.(c);let a=(i??=new P).copyFrom(c.t).add(c.T);a.compare(o)>0&&o.copyFrom(a),s.push(new ds(c))}}indexTemporal(t){let e=this.astToTemporal.get(t.ast);e?e.push(t):this.astToTemporal.set(t.ast,[t])}static anchorAlign(t){for(let l=t.length-1;l>=0;l--)t[l].length===0&&t.splice(l,1);let e=t.length;if(e===0)return[];if(e===1)return t[0];let o=[],n=new Uint32Array(e),s=Array.from({length:e},()=>new P),i=[],c=new ms(e);for(let l=0;l<e;l++)c.push({e:t[l][0],i:l});let a=l=>{let h=t[l][++n[l]];h&&(s[l].isZero()||h.shiftTime(s[l]),c.push({e:h,i:l}))};for(;;){let l=c.pop();if(l===void 0){if(i.length===0)break;let p=i[0],f=p.e,u=f.t;for(let d=1;d<i.length;d++)i[d].e.t.compare(u)>0&&(u=i[d].e.t);s[p.i].add(u).sub(f.t),a(p.i);for(let d=1;d<i.length;d++){let x=i[d];f.push(...x.e),s[x.i].add(u).sub(x.e.t),a(x.i)}i.length=0,f.t=u,f.sort((d,x)=>d.order-x.order),o.push(f);continue}if(l.e.mergeKey===ot){i.push(l);continue}let h=[l.i];for(;;){let p=c.front();if(!p||!p.e.t.equals(l.e.t)||p.e.mergeKey!==l.e.mergeKey)break;c.pop(),l.e.push(...p.e),h.push(p.i)}o.push(l.e);for(let p of h)a(p)}return o}},ds=class extends Array{static get[Symbol.species](){return Array}mergeKey;constructor(t){super(1),this.mergeKey=t.mergeKey,this[0]=t}get t(){return this[0].t}set t(t){for(let e of this)e.t.copyFrom(t)}shiftTime(t){for(let e of this)e.t.add(t)}set layoutLine(t){for(let e of this)e.layoutLine=t}};function us(r,t){let e=r.e.t.compare(t.e.t);return e!==0?e:r.e.mergeKey!==t.e.mergeKey?r.e.mergeKey<t.e.mergeKey?-1:1:r.i-t.i}var ms=class extends Array{validLen=0;constructor(t){super(t)}front(){if(this.validLen!==0)return this[0]}push(t){return this[this.validLen]=t,this.up(this.validLen++),this.validLen}pop(){if(this.validLen===0)return;let t=this[0];return this[0]=this[--this.validLen],this[this.validLen]=void 0,this.down(0),t}up(t){let e=this[t];for(;t>0;){let o=t-1>>1;if(us(e,this[o])>=0)break;this[t]=this[o],t=o}this[t]=e}down(t){let e=this[t];for(;;){let o=(t<<1)+1,n=o+1;if(o>=this.validLen)break;let s=o;if(n<this.validLen&&us(this[n],this[o])<0&&(s=n),us(this[s],e)>=0)break;this[t]=this[s],t=s}this[t]=e}};function _a(r,t={}){let{functions:e=go,textMeasurer:o,variables:n,...s}=t,{maskedSource:i,lineStarts:c}=ie(r),a=new dt({source:i,variables:n});a.registerFunctions(e);let l=new tt({start:0,end:r.length},a.parse()),p=new Re(a.diagnostics).lowerDocument(l),f=fs(e,{textMeasurer:o}),u=Oo(p,f,s);return{lineStarts:c,maskedSource:i,diagnostics:a.diagnostics,ast:l,lowering:p,layout:u}}function va(r,t=go){let{maskedSource:e,commentSpans:o}=ie(r),n=new dt({source:e,commentSpans:o});return n.registerFunctions(t),{syntax:n.parseSyntax(),diagnostics:n.diagnostics}}function xs(r){return typeof r.applyPlayback=="function"}var Ir=new WeakMap;function Pr(r){let t=Ir.get(r);if(t)return t;let e=[{performance:0,seconds:0,bpm:vt}],o=0,n=0,s=vt;for(let i of r){if(i.kind!=="tempo")continue;let c=i.at.toNumber();c>n&&(o+=(c-n)*60/s,n=c),s=i.bpm;let a=e[e.length-1];a.performance===n?a.bpm=s:e.push({performance:n,seconds:o,bpm:s})}return Ir.set(r,e),e}function ys(r,t,e){let o=0,n=r.length;for(;o<n;){let s=o+n>>>1;e(r[s])<=t?o=s+1:n=s}return r[Math.max(0,o-1)]}function bo(r,t){let e=Math.max(0,t),o=ys(Pr(r),e,n=>n.performance);return o.seconds+(e-o.performance)*60/o.bpm}function zr(r,t){let e=Math.max(0,t),o=ys(Pr(r),e,n=>n.seconds);return o.performance+(e-o.seconds)*o.bpm/60}function Fr(r,t){let e=Math.max(0,t),o=ys(r,e,n=>n.performance.toNumber());return o&&o.performance.toNumber()<=e?o.score.toNumber()+e-o.performance.toNumber():e}function Dr(r,t){let e=Math.max(0,t),o;for(let n=0;n<r.length;n++){let s=r[n],i=s.score.toNumber();if(i>e){(!o||i<o.score.toNumber())&&(o=s);continue}let c=r[n+1],a=c?c.performance.toNumber()-s.performance.toNumber():1/0;if(!(e-i>=a))return s.performance.toNumber()+(e-i)}return o?.performance.toNumber()??e}function Ma(r,t){let e=Math.min(zr(r.events,t),r.performanceDuration.toNumber());return Fr(r.scoreMap,e)}function Oa(r,t){let e=Math.min(Dr(r.scoreMap,t),r.performanceDuration.toNumber());return bo(r.events,e)}var Br={tempo:0,"time-signature":1,"program-change":2,"note-off":3,"note-on":4};function Hr(r,t){return r.at.compare(t.at)||Br[r.kind]-Br[t.kind]||r.order-t.order}function $r(r,t){let e=new Map,o=new Map;for(let c of r)if(c.kind==="note-on"){if(e.has(c.noteId))throw new Error(`Duplicate NoteOn ${c.noteId}`);e.set(c.noteId,c)}else if(c.kind==="note-off"){if(o.has(c.noteId))throw new Error(`Duplicate NoteOff ${c.noteId}`);o.set(c.noteId,c)}let n=new Set;for(let[c,a]of e){let l=o.get(c);if(!l)throw new Error(`Note ${c} has no NoteOff`);if(l.at.compare(a.at)<=0)throw new Error(`Note ${c} has a non-positive duration`);if(a.origins.length===0||l.origins.length===0)throw new Error(`Note ${c} has no origin`);n.add(a.track)}if(o.size!==e.size){for(let c of o.keys())if(!e.has(c))throw new Error(`NoteOff ${c} has no NoteOn`)}let s=new Map;for(let c of t)n.has(c)&&s.set(c,s.size);for(let c of n)s.has(c)||s.set(c,s.size);let i=[];for(let c of r){if(c.kind==="tempo"){i.push({kind:"tempo",at:c.at,bpm:c.bpm});continue}if(c.kind==="time-signature"){i.push({kind:"time-signature",at:c.at,numerator:c.numerator,denominator:c.denominator});continue}if(c.kind==="program-change"){let h=s.get(c.track);h!==void 0&&i.push({kind:"program-change",at:c.at,track:h,program:c.program});continue}let a=c.kind==="note-on"?c:e.get(c.noteId),l=s.get(a.track);if(c.kind==="note-on"){i.push({kind:"note-on",at:c.at,noteId:c.noteId,track:l,midi:c.midi,velocity:c.velocity,...c.percussion?{percussion:!0}:{},sourceSpans:c.sourceSpans});continue}i.push({kind:"note-off",at:c.at,noteId:c.noteId,track:l,midi:a.midi})}return{events:i,tracks:[...s.keys()]}}function Ra(r,t,e){let o=r.columns,n,s=(m,g)=>{if(!n){n=new Map;for(let y=0;y<o.length;y++)for(let b of o[y])n.set(b,y)}for(let y=m;y;y=y.foldedInto){let b=n.get(y);if(b===void 0)continue;if(g!=="end"||y.T.compare(0)<=0)return b;let S=y.t.clone().add(y.T),C=b;for(;C+1<o.length&&o[C+1][0].t.compare(S)<0;)C++;return C}},i=new Map,c=new Map,a=(m,g)=>{let y=m.playbackFlow?.(s);if(!y)return;let[b,S]=y.range??[0,o.length-1];if(y.range&&(!Number.isSafeInteger(b)||!Number.isSafeInteger(S)||b<0||S<b||S>=o.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 C={hook:y,sourceSpan:g};for(let L=b;L<=S;L++){let E=c.get(L);E?E.push(C):c.set(L,[C])}};for(let m of r.astToTemporal.values())for(let g of m){a(g,g.ast.sourceSpan);let y=g.playbackMarks?.();if(!y?.length)continue;let b=s(g);if(b!==void 0)for(let S of y){let C=i.get(S);C?C.push(b):i.set(S,[b])}}for(let m of r.attachments)a(m,m.sourceSpan??{start:0,end:0});if(c.size===0)return o.map((m,g)=>g);for(let m of i.values())m.sort((g,y)=>g-y);let l=new Array(o.length).fill(0),h=0,p={get column(){return h},visits:m=>l[m]??0,seek(m,g,y){let b=i.get(m);if(b){if(y>0)return b.find(S=>S>g);for(let S=b.length-1;S>=0;S--)if(b[S]<g)return b[S]}}},f=[],u=0;for(;h<o.length;){if(++u>e)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",o[h][0].ast.sourceSpan,{maxFlowSteps:e});l[h]++;let m;for(let g of c.get(h)??[]){let b=g.hook.run(p);if(b){if(b.kind==="stop")return f;if(!Number.isSafeInteger(b.column)||b.column<0||b.column>o.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});m=Math.min(m??1/0,b.column)}}m!==void 0?h=m:(f.push(h),h++)}let d=new Set(f),x=!1;for(let m=0;m<o.length;m++){let g=!d.has(m)&&o[m].some(y=>!y.T.isZero());g&&!x&&t.push(new z("W_PLAYBACK_COLUMN_NEVER_PLAYED","\u8FD9\u91CC\u5728\u4EFB\u4F55\u4E00\u904D\u91CC\u90FD\u4E0D\u4F1A\u6F14\u594F",o[m][0].ast.sourceSpan)),x=g}return f}function Ia(r,t){let e=t?.maxFlowSteps??65536;if(!Number.isSafeInteger(e)||e<=0)throw new w("E_PLAYBACK_FLOW_LIMIT","maxFlowSteps \u5FC5\u987B\u662F\u6B63\u5B89\u5168\u6574\u6570",r.columns[0]?.[0]?.ast.sourceSpan??{start:0,end:0});let o=[],n=[],s=[],i=[],c=new Map,a=new Map,l=0,h=0,p=[{kind:"initial",at:new P,origins:[]}],f=new Map,u=new Map,d={spans:s,notes:i,diagnostics:o,transform(T,M){if(i.lastIndexOf(T)<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",T.sourceSpans?.[0]??{start:0,end:0});let $=c.get(T);c.set(T,$?[...$,M]:[M])}},x=(T,M,$)=>{if(!Number.isFinite(T.toNumber())||T.compare(0)<0)throw new w("E_PLAYBACK_CONTROL_TIME","\u7CFB\u7EDF\u63A7\u5236\u65F6\u523B\u5FC5\u987B\u662F\u975E\u8D1F\u6709\u9650\u503C",M.at(-1).node.ast.sourceSpan);p.push({kind:"control",at:T.clone(),origins:M,apply:$})};function m(T,M,$,B,q,ct=[],lt=T.track){if(!T.playbackState&&!T.emitPlayback)return;let it=[...ct,{node:T}],pt=M.length?[...M]:void 0,gt=$.length?[...$]:void 0,Nt,ft,pe;function Pe(Y){let nt={...Y,start:Y.start.clone(),end:Y.end.clone(),track:lt,origins:it,sourceSpans:[{...T.ast.sourceSpan}]};return s.push(nt),gt&&u.set(nt,gt),nt}let Ut=T.playbackState?.program;Ut!==void 0&&a.get(lt)!==Ut&&(a.set(lt,Ut),n.push({kind:"program-change",at:B.clone(),order:l++,origins:it,track:lt,program:Ut}));let ze=T.playbackState?.bpm;if(ze!==void 0&&x(B,it,Y=>{Y.bpm=ze}),T.emitPlayback?.({start:B,end:B.clone().add(q),track:lt,span(Y){Pe(Y)},note(Y){let nt=Pe(Y);i.push(nt),pt&&c.set(nt,pt)},extend(Y){if(s.lastIndexOf(Y)<0||!Y.end.equals(B)||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",T.ast.sourceSpan);let nt=Y.end.clone().sub(Y.start),At=nt.clone().add(q),_t=(u.get(Y)??[]).map(xt=>xt.startRatio?{...xt,startRatio:xt.startRatio.clone().mul(nt).div(At)}:xt);if(gt)for(let xt of gt)_t.push({...xt,startRatio:nt.clone().div(At)});_t.length&&u.set(Y,_t),Y.end.add(q)},emit:Y=>n.push({...Y,at:Y.at.clone(),order:l++,origins:it}),control:(Y,nt)=>x(Y,it,nt),scaleFollowingBpm(Y,nt,At=1,_t){if(!Number.isSafeInteger(nt)||!Number.isSafeInteger(At)||nt<=0||At<=0)throw new w("E_PLAYBACK_BPM_SCALE","\u901F\u5EA6\u6BD4\u4F8B\u5FC5\u987B\u662F\u6B63\u6709\u7406\u6570",T.ast.sourceSpan);let xt=new P(nt,At),fe=f.get(Y);if(fe&&!fe.equals(xt))throw new w("E_PLAYBACK_BPM_SCALE","\u540C\u4E00\u901F\u5EA6\u6548\u679C key \u5FC5\u987B\u4F7F\u7528\u56FA\u5B9A\u6BD4\u4F8B",T.ast.sourceSpan);f.set(Y,xt),$.push({key:Y,factor:xt,followConnections:_t?.followConnections??!1,origins:it})},affectFollowing:Y=>M.push(Y),defer:Y=>(pe??=[]).push(Y),play:(Y,nt,At)=>m(Y,Nt??=[...M],ft??=[...$],nt??B,At??q,it,lt)}),pe)for(let Y of pe)Y(d)}let g=Ra(r,o,e),y=r.columns[g[0]]?.[0]?.t.clone()??new P,b=[{performance:new P,score:y}],S=new P().sub(y),C=new P;for(let T=0;T<g.length;T++){let M=g[T];for(let it of r.columns[M])!it.playbackState&&!it.emitPlayback||m(it,[],[],it.t.clone().add(S),it.T.clone());let $=r.columns[M+1]?.[0]?.t??r.duration;C.copyFrom($).add(S);let B=g[T+1];if(B===void 0||B===M+1)continue;let q=r.columns[B][0]?.t.clone()??new P;S.add($).sub(q);let ct={performance:C.clone(),score:q};b[b.length-1].performance.equals(ct.performance)?b[b.length-1]=ct:b.push(ct)}for(let T of s){if(!Number.isFinite(T.start.toNumber())||!Number.isFinite(T.end.toNumber())||T.start.compare(0)<0||T.end.compare(T.start)<=0)throw new w("E_PLAYBACK_NOTE_RANGE","\u97F3\u6BB5\u5FC5\u987B\u5177\u6709\u975E\u8D1F\u8D77\u70B9\u548C\u6B63\u65F6\u503C",T.sourceSpans[0]);T.end.compare(C)>0&&C.copyFrom(T.end),Object.freeze(T.start),Object.freeze(T.end);for(let M of T.origins)Object.freeze(M);for(let M of T.sourceSpans)Object.freeze(M);Object.freeze(T.origins),Object.freeze(T.sourceSpans),Object.freeze(T)}let L,E=new Map,_=new Map,v={notes:i,diagnostics:o,connect(T,M){if(L??=new Set(i),!L.has(T)||!L.has(M)||!T.end.equals(M.start))throw new w("E_PLAYBACK_CONNECTION","\u97F3\u6BB5\u8FDE\u63A5\u5FC5\u987B\u5C5E\u4E8E\u5F53\u524D\u8BA1\u5212\u4E14\u65F6\u95F4\u76F8\u63A5",T.sourceSpans[0]);return E.has(T)&&E.get(T)!==M||_.has(M)&&_.get(M)!==T?!1:(E.set(T,M),_.set(M,T),!0)}};for(let T of r.attachments)xs(T)&&T.applyPlayback(v);for(let[T,M]of u){let $=T;if(M.some(B=>B.followConnections))for(;E.has($);)$=E.get($);for(let B of M){let q=B.startRatio?T.start.clone().add(T.end.clone().sub(T.start).mul(B.startRatio)):T.start;p.push({kind:"scale",at:q,origins:B.origins,scale:B,delta:1},{kind:"scale",at:B.followConnections?$.end:T.end,origins:B.origins,scale:B,delta:-1})}}let k={bpm:vt,bpmScale:new P(1)},F=new Map,A=new P(1),O=[];p.sort((T,M)=>T.at.compare(M.at));let H=0,X;for(;H<p.length;){let T=p[H].at,M=new Set;for(;H<p.length&&p[H].at.equals(T);){let ct=p[H++];for(let lt of ct.origins)M.add(lt);if(ct.kind==="control")ct.apply(k);else if(ct.kind==="scale"){let{key:lt,factor:it}=ct.scale,pt=F.get(lt)??0,gt=pt+ct.delta;F.set(lt,gt),pt===0&>>0?A.mul(it):pt>0&>===0&&A.div(it)}}let $=k.bpmScale.clone().mul(A),B={bpm:k.bpm,bpmScale:$,effectiveBpm:k.bpm*$.toNumber()};if(!Number.isFinite(B.effectiveBpm)||B.effectiveBpm<=0)throw new w("E_PLAYBACK_BPM","\u7CFB\u7EDF\u63A7\u5236\u4EA7\u751F\u4E86\u65E0\u6548\u901F\u5EA6",[...M].at(-1)?.node.ast.sourceSpan??{start:0,end:0});let q=O.at(-1)?.state;(!q||q.bpm!==B.bpm||!q.bpmScale.equals($))&&O.push({at:T.clone(),state:B}),X!==B.effectiveBpm&&(X=B.effectiveBpm,n.push({kind:"tempo",at:T.clone(),bpm:B.effectiveBpm,order:l++,origins:[...M]}))}let Q={diagnostics:o,stateAt(T){let M=0,$=O.length;for(;M<$;){let q=M+$>>>1;O[q].at.compare(T)<=0?M=q+1:$=q}let B=O[Math.max(0,M-1)].state;return{...B,bpmScale:B.bpmScale.clone()}}},J=(T,M)=>!c.has(M)&&T.track===M.track&&T.midi===M.midi&&T.percussion===M.percussion,D=new Map;for(let T of i){let M=_.get(T);if(M&&J(M,T))continue;let $=T,B=E.get($),q;for(;B&&J($,B);)E.delete($),q??=[...T.sourceSpans],q.push(...B.sourceSpans),$=B,B=E.get($);$!==T&&(E.delete($),B&&E.set(T,B));let ct=$.end,lt=q?Object.freeze(q):T.sourceSpans,it=c.get(T),pt;if(it){pt=[{...T,start:T.start.clone(),end:ct.clone(),sourceSpans:lt}];for(let ft of it)pt=ft(Q,pt)??pt;let Nt;for(let ft of pt){if(!Number.isFinite(ft.start.toNumber())||!Number.isFinite(ft.end.toNumber())||ft.start.compare(T.start)<0||ft.end.compare(ct)>0||ft.end.compare(ft.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",T.sourceSpans[0]);(!Nt||ft.start.compare(Nt)<0)&&(Nt=ft.start)}if(!Nt?.equals(T.start))throw new w("E_PLAYBACK_TRANSFORM_RANGE","\u58F0\u97F3\u5C55\u5F00\u5FC5\u987B\u4FDD\u6301\u539F\u97F3\u6BB5\u7684\u8D77\u70B9",T.sourceSpans[0])}else pt=[$===T?T:{...T,end:ct,sourceSpans:lt}];let gt=B!==void 0||M!==void 0?[]:void 0;for(let Nt of pt){let{start:ft,end:pe,track:Pe,midi:Ut,velocity:ze,percussion:Y,origins:nt,sourceSpans:At}=Nt,_t=h++,xt={kind:"note-on",at:ft.clone(),noteId:_t,order:l++,track:Pe,midi:Ut,velocity:ze,percussion:Y,origins:nt,sourceSpans:[...At]},fe={kind:"note-off",at:pe.clone(),noteId:_t,order:l++,origins:nt};n.push(xt,fe),gt?.push({on:xt,off:fe})}gt&&D.set(T,gt)}let V=new Set,U=new Map,G=E.size>1?[...E.keys()].sort((T,M)=>M.start.compare(T.start)):E.keys();for(let T of G){let M=E.get(T);for(let $ of D.get(T)){if(!$.off.at.equals(M.start))continue;let B=D.get(M).find(q=>!V.has(q.on)&&q.on.at.equals(M.start)&&q.on.track===$.on.track&&q.on.midi===$.on.midi&&q.on.percussion===$.on.percussion);B&&($.off.at.copyFrom(B.off.at),U.set($.on,B.on),V.add(B.on),V.add(B.off))}}for(let T of U.keys())if(!V.has(T))for(let M=U.get(T);M;M=U.get(M))T.sourceSpans.push(...M.sourceSpans);let Z=(V.size?n.filter(T=>!V.has(T)):n).sort(Hr),j=$r(Z,r.tracks),mt=Z.at(-1)?.at;return mt&&mt.compare(C)>0&&C.copyFrom(mt),{events:j.events,scoreMap:b,tracks:j.tracks,performanceDuration:C,durationSeconds:bo(j.events,C.toNumber()),diagnostics:o}}function Kt(r){return r.pages.length>0?r.pages.map(t=>t.bounds):[r.bounds]}function bs(r,t){for(let e of r.attachments)e.layer==="background"&&e.paint(t);for(let e of r.objects){e.paint(t);for(let o of e.decorations)o.paint?.(t)}for(let e of r.attachments)e.layer==="foreground"&&e.paint(t)}var gs=class{pages;painters;constructor(t,e){this.pages=t,this.painters=e}route(t,e,o){let n=0,s=this.pages.length;for(;n<s;){let i=n+s>>>1,c=this.pages[i];c.y+c.h<t?n=i+1:s=i}for(let i=n;i<this.pages.length&&this.pages[i].y<=e;i++)o(this.painters[i])}drawText(t,e,o,n){this.route(o,o,s=>s.drawText(t,e,o,n))}drawLine(t,e,o,n,s){let i=(s?.strokeWidth??1)/2;this.route(Math.min(e,n)-i,Math.max(e,n)+i,c=>c.drawLine(t,e,o,n,s))}drawRect(t,e,o,n,s){let i=s?.stroke?(s.strokeWidth??1)/2:0;this.route(e-i,e+Math.max(0,n)+i,c=>{c.drawRect(t,e,o,n,s)})}drawCircle(t,e,o,n){let s=n?.stroke?(n.strokeWidth??1)/2:0,i=Math.max(0,o)+s;this.route(e-i,e+i,c=>c.drawCircle(t,e,o,n))}drawPath(t,e,o){if(t.length===0)return;let n=o?l=>o.y+l*o.scaleY:l=>l,s=1/0,i=-1/0,c=l=>{let h=n(l);s=Math.min(s,h),i=Math.max(i,h)};for(let l of t)l.op!=="Z"&&(l.op==="Q"&&c(l.cy),l.op==="C"&&(c(l.cy1),c(l.cy2)),c(l.y));if(!Number.isFinite(s))return;let a=e?.stroke?(e.strokeWidth??1)/2:0;this.route(s-a,i+a,l=>{l.drawPath(t,e,o)})}};function he(r,t){let e=Kt(r);if(t.length!==e.length)throw new Error(`Expected ${e.length} page painters, got ${t.length}`);bs(r,new gs(e,t))}var ws=class{commands=[];replay(t){for(let e of this.commands)switch(e.kind){case"text":t.drawText(e.text,e.x,e.y,e.style);break;case"line":t.drawLine(e.x1,e.y1,e.x2,e.y2,e.style);break;case"rect":t.drawRect(e.x,e.y,e.w,e.h,e.style);break;case"circle":t.drawCircle(e.cx,e.cy,e.r,e.style);break;case"path":t.drawPath(e.commands,e.style);break}}drawText(t,e,o,n){this.commands.push({kind:"text",text:t,x:e,y:o,style:n})}drawLine(t,e,o,n,s){this.commands.push({kind:"line",x1:t,y1:e,x2:o,y2:n,style:s})}drawRect(t,e,o,n,s){this.commands.push({kind:"rect",x:t,y:e,w:o,h:n,style:s})}drawCircle(t,e,o,n){this.commands.push({kind:"circle",cx:t,cy:e,r:o,style:n})}drawPath(t,e,o){this.commands.push({kind:"path",commands:t.map(n=>Pa(n,o)),style:e})}};function Pa(r,t){if(!t||r.op==="Z")return{...r};let e=n=>t.x+n*t.scaleX,o=n=>t.y+n*t.scaleY;return r.op==="Q"?{op:"Q",cx:e(r.cx),cy:o(r.cy),x:e(r.x),y:o(r.y)}:r.op==="C"?{op:"C",cx1:e(r.cx1),cy1:o(r.cy1),cx2:e(r.cx2),cy2:o(r.cy2),x:e(r.x),y:o(r.y)}:{op:r.op,x:e(r.x),y:o(r.y)}}function K(r){return Number.isFinite(r)?String(Math.round(r*1e3)/1e3):"0"}function yt(r){return r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function za(r,t){let e=[],o=t?s=>K(t.x+s*t.scaleX):K,n=t?s=>K(t.y+s*t.scaleY):K;for(let s of r){if(s.op==="Z"){e.push("Z");continue}if(s.op==="M"||s.op==="L"){e.push(`${s.op}${o(s.x)} ${n(s.y)}`);continue}if(s.op==="Q"){e.push(`Q${o(s.cx)} ${n(s.cy)} ${o(s.x)} ${n(s.y)}`);continue}"cx1"in s&&e.push(`C${o(s.cx1)} ${n(s.cy1)} ${o(s.cx2)} ${n(s.cy2)} ${o(s.x)} ${n(s.y)}`)}return e.join(" ")}function Ie(r){return r?.opacity===void 0?"":` opacity="${K(r.opacity)}"`}var wo=class{body=[];drawText(t,e,o,n){let s=n.fontFamily??se,i=n.fontWeight??"normal",c=n.fill??"#000",a=n.textAlign==="center"?"middle":n.textAlign==="right"?"end":"start";this.body.push(`<text x="${K(e)}" y="${K(o)}" font-family="${yt(s)}" font-size="${K(n.fontSize)}" font-weight="${yt(String(i))}" text-anchor="${a}" `+(n.fontStyle?`font-style="${yt(n.fontStyle)}" `:"")+`fill="${yt(c)}" xml:space="preserve"${Ie(n)}>${yt(t)}</text>`)}drawLine(t,e,o,n,s){let i=s?.stroke??s?.fill??"#000",c=s?.strokeWidth??1;this.body.push(`<line x1="${K(t)}" y1="${K(e)}" x2="${K(o)}" y2="${K(n)}" stroke="${yt(i)}" stroke-width="${K(c)}" stroke-linecap="round"${Ie(s)} />`)}drawRect(t,e,o,n,s){let i=s?.fill??"none",c=s?.stroke??"none",a=s?.strokeWidth??1;this.body.push(`<rect x="${K(t)}" y="${K(e)}" width="${K(Math.max(0,o))}" height="${K(Math.max(0,n))}" fill="${yt(i)}" stroke="${yt(c)}" stroke-width="${K(a)}"${Ie(s)} />`)}drawCircle(t,e,o,n){let s=n?.fill??"#000",i=n?.stroke??"none",c=n?.strokeWidth??1;this.body.push(`<circle cx="${K(t)}" cy="${K(e)}" r="${K(Math.max(0,o))}" fill="${yt(s)}" stroke="${yt(i)}" stroke-width="${K(c)}"${Ie(n)} />`)}drawPath(t,e,o){if(t.length===0)return;let n=za(t,o),s=e?.fill??"none",i=e?.stroke??"none",c=e?.strokeWidth??1;this.body.push(`<path d="${n}" fill="${yt(s)}" stroke="${yt(i)}" stroke-width="${K(c)}" stroke-linecap="round" stroke-linejoin="round"${Ie(e)} />`)}toSvg(t,e={}){let o=Math.max(0,e.padding??0),n=t.x-o,s=t.y-o,i=Math.max(1,t.w+o*2),c=Math.max(1,t.h+o*2),a=e.background?`<rect x="${K(n)}" y="${K(s)}" width="${K(i)}" height="${K(c)}" fill="${yt(e.background)}" />`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${K(i)}" height="${K(c)}" viewBox="${K(n)} ${K(s)} ${K(i)} ${K(c)}">${a}${this.body.join("")}</svg>`}};function Fa(r,t={}){let e=Kt(r),o=e.map(()=>new wo);return he(r,o),o.map((n,s)=>n.toSvg(e[s],t))}function Da(r,t,e=0,o=0,n=1,s=1){r.beginPath();for(let i of t){if(i.op==="Z"){r.closePath();continue}if(i.op==="M"){r.moveTo(e+i.x*n,o+i.y*s);continue}if(i.op==="L"){r.lineTo(e+i.x*n,o+i.y*s);continue}if(i.op==="Q"){r.quadraticCurveTo(e+i.cx*n,o+i.cy*s,e+i.x*n,o+i.y*s);continue}"cx1"in i&&r.bezierCurveTo(e+i.cx1*n,o+i.cy1*s,e+i.cx2*n,o+i.cy2*s,e+i.x*n,o+i.y*s)}}var So=class{context;constructor(t){this.context=t}beginOpacity(t){if(t?.opacity===void 0)return;let e=this.context.globalAlpha;return this.context.globalAlpha=e*t.opacity,e}endOpacity(t){t!==void 0&&(this.context.globalAlpha=t)}drawText(t,e,o,n){let s=this.beginOpacity(n);this.context.fillStyle=n.fill??"#000",this.context.font=Xe(n),this.context.textAlign=n.textAlign??"left",this.context.textBaseline="alphabetic",this.context.fillText(t,e,o),this.endOpacity(s)}drawLine(t,e,o,n,s){let i=this.beginOpacity(s);this.context.beginPath(),this.context.moveTo(t,e),this.context.lineTo(o,n),this.context.strokeStyle=s?.stroke??s?.fill??"#000",this.context.lineWidth=s?.strokeWidth??1,this.context.lineCap="round",this.context.stroke(),this.endOpacity(i)}drawRect(t,e,o,n,s){if(o<0||n<0)return;let i=this.beginOpacity(s);s?.fill&&(this.context.fillStyle=s.fill,this.context.fillRect(t,e,o,n)),s?.stroke&&(this.context.strokeStyle=s.stroke,this.context.lineWidth=s.strokeWidth??1,this.context.lineJoin="miter",this.context.strokeRect(t,e,o,n)),this.endOpacity(i)}drawCircle(t,e,o,n){if(o<0)return;let s=this.beginOpacity(n);this.context.beginPath(),this.context.arc(t,e,o,0,Math.PI*2);let i=n?.fill??"#000";i&&i!=="none"&&(this.context.fillStyle=i,this.context.fill()),n?.stroke&&(this.context.strokeStyle=n.stroke,this.context.lineWidth=n.strokeWidth??1,this.context.stroke()),this.endOpacity(s)}drawPath(t,e,o){if(t.length===0)return;let n=this.beginOpacity(e);Da(this.context,t,o?.x,o?.y,o?.scaleX,o?.scaleY),e?.fill&&(this.context.fillStyle=e.fill,this.context.fill()),e?.stroke&&(this.context.strokeStyle=e.stroke,this.context.lineWidth=e.strokeWidth??1,this.context.lineCap="round",this.context.lineJoin="round",this.context.stroke()),this.endOpacity(n)}};function Ba(r,t){let e=Kt(r);if(t.length!==e.length)throw new Error(`Expected ${e.length} page contexts, got ${t.length}`);for(let[o,n]of t.entries())n.save(),n.translate(-e[o].x,-e[o].y);try{he(r,t.map(o=>new So(o)))}finally{for(let o of t)o.restore()}}var Ha=globalThis;Object.assign(Ha.jpfun??={},Ss);})();
|