jpfun 0.5.0 → 0.7.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/dist/converter/midi/convert.d.ts +3 -1
- package/dist/converter/midi/convert.js +78 -66
- package/dist/converter/musicxml/features.d.ts +19 -5
- package/dist/converter/musicxml/features.js +46 -8
- package/dist/converter/musicxml/index.js +142 -23
- package/dist/converter/musicxml/model.d.ts +15 -0
- package/dist/diagnostic.js +1 -1
- package/dist/functions/ASTtypes.d.ts +4 -0
- package/dist/functions/ASTtypes.js +25 -14
- package/dist/functions/adjust/index.js +6 -2
- package/dist/functions/arpeggio/index.js +21 -17
- package/dist/functions/arpeggio/shape.d.ts +1 -1
- package/dist/functions/arpeggio/shape.js +27 -21
- package/dist/functions/bar/index.js +37 -36
- package/dist/functions/beam/auto.js +18 -24
- package/dist/functions/beam/layout.js +15 -23
- package/dist/functions/box/index.js +52 -1
- package/dist/functions/br/index.js +3 -4
- package/dist/functions/default.js +10 -5
- package/dist/functions/div/index.js +2 -3
- package/dist/functions/gliss/index.d.ts +2 -0
- package/dist/functions/gliss/index.js +180 -0
- package/dist/functions/grace/index.d.ts +4 -2
- package/dist/functions/grace/index.js +19 -11
- package/dist/functions/head/index.js +50 -62
- package/dist/functions/meter/index.js +45 -24
- package/dist/functions/meter/shape.d.ts +3 -0
- package/dist/functions/meter/shape.js +43 -0
- package/dist/functions/note/accidentals.js +10 -16
- package/dist/functions/note/index.js +38 -48
- package/dist/functions/ottava/index.d.ts +2 -0
- package/dist/functions/ottava/index.js +217 -0
- package/dist/functions/page/index.js +3 -3
- package/dist/functions/pagebreak/index.d.ts +2 -0
- package/dist/functions/pagebreak/index.js +36 -0
- package/dist/functions/rest/index.d.ts +2 -0
- package/dist/functions/rest/index.js +231 -0
- package/dist/functions/slide/index.d.ts +2 -0
- package/dist/functions/slide/index.js +132 -0
- package/dist/functions/stack/index.js +8 -15
- package/dist/functions/symbol/index.d.ts +9 -0
- package/dist/functions/symbol/index.js +41 -12
- package/dist/functions/symbol/ornament.js +15 -20
- package/dist/functions/symbol/shape.js +4 -1
- package/dist/functions/symbol/symbols/fine.js +1 -1
- package/dist/functions/symbol/symbols/tr.js +46 -1
- package/dist/functions/temporal.d.ts +36 -12
- package/dist/functions/temporal.js +29 -9
- package/dist/functions/tie/index.js +46 -32
- package/dist/functions/tuplet/index.js +1 -1
- package/dist/functions/up/index.js +51 -33
- package/dist/functions/voice/connections.d.ts +19 -0
- package/dist/functions/voice/connections.js +90 -0
- package/dist/functions/voice/index.js +245 -99
- package/dist/functions/volta/index.js +41 -21
- package/dist/jpfun.core.min.js +48 -55
- package/dist/jpfun.from-midi.min.js +5 -5
- package/dist/jpfun.from-musicxml.min.js +8 -8
- package/dist/jpfun.min.js +57 -64
- package/dist/layout/engine.d.ts +4 -1
- package/dist/layout/engine.js +232 -75
- package/dist/layout/model.js +22 -66
- package/dist/layout/page.d.ts +3 -2
- package/dist/layout/page.js +7 -6
- package/dist/layout/types.d.ts +34 -45
- package/dist/lowering/loweringContext.d.ts +1 -1
- package/dist/lowering/loweringContext.js +41 -171
- package/dist/parser/parserContext.d.ts +2 -0
- package/dist/parser/parserContext.js +31 -14
- package/dist/parser/preprocess.js +4 -6
- package/dist/playback/compile.js +12 -3
- package/dist/playback/types.d.ts +4 -2
- package/dist/render/paint.js +1 -1
- package/dist/render/svg.js +1 -0
- package/dist/render/text.d.ts +1 -1
- package/dist/render/text.js +3 -2
- package/dist/render/types.d.ts +1 -0
- package/grammar.md +221 -257
- package/package.json +1 -1
package/dist/jpfun.core.min.js
CHANGED
|
@@ -1,86 +1,93 @@
|
|
|
1
1
|
/*! jpfun | Apache-2.0 | github.com/madderscientist/jpFun */
|
|
2
|
-
"use strict";(()=>{var Li=Object.defineProperty;var Ti=(i,t)=>{for(var e in t)Li(i,e,{get:t[e],enumerable:!0})};var No={};Ti(No,{ANCHOR_KEY:()=>U,ASTBraceNode:()=>K,ASTFunctionNode:()=>v,ASTLabelNode:()=>lt,ASTNodeBase:()=>et,ASTTextNode:()=>Z,CanvasPainter:()=>Je,CanvasTextMeasurer:()=>Mn,DEFAULT_BPM:()=>yt,DEFAULT_FONT_SIZE:()=>Ss,DEFAULT_KEY:()=>ht,DEFAULT_OCTAVE:()=>pr,DEFAULT_PAGE_CONFIG:()=>ot,DEFAULT_PROGRAM:()=>be,DEFAULT_TEXT_FONT:()=>jt,DEFAULT_TONALITY:()=>oe,DEFAULT_VELOCITY:()=>Bt,DefaultTextMeasurer:()=>ve,Diagnostic:()=>N,ErrorDiagnostic:()=>S,Fraction:()=>I,JIANPU_NUMBER_FONT:()=>Rn,LoweringContext:()=>xe,PageLayoutError:()=>Wt,ParserContext:()=>ct,RecordingPainter:()=>vo,SvgPainter:()=>Qe,TemporalNodeBase:()=>W,Track:()=>_t,WarningDiagnostic:()=>O,analyzeScoreSyntax:()=>sc,canvasFont:()=>Ne,compilePlayback:()=>ac,compileScore:()=>oc,completeSpringConfig:()=>Se,createLayoutPrepareContext:()=>So,defaultFunctions:()=>Ze,defaultTextMeasurer:()=>On,functionAddonKey:()=>Lt,isLayoutAttachment:()=>Tt,isPlaybackRelation:()=>To,isVisualTemporalNode:()=>F,layoutDocument:()=>fn,layoutElement:()=>Ce,layoutHorizontal:()=>rn,layoutHorizontalRegion:()=>Ht,layoutLocalSequence:()=>Gt,layoutPageBounds:()=>Ft,normalizePageConfig:()=>se,paginateLayoutLines:()=>cn,paintLayout:()=>_o,paintLayoutPages:()=>Qt,performanceTimeToScoreTime:()=>bi,performanceTimeToSeconds:()=>qe,prepareHorizontalLine:()=>un,prepareLayoutHost:()=>re,preprocessSource:()=>Xt,primaryName:()=>ne,renderLayoutPagesToCanvas:()=>uc,renderLayoutPagesToSvg:()=>pc,resolveArgType:()=>$t,scoreTimeToPerformanceTime:()=>wi,scoreTimeToSeconds:()=>rc,secondsToPerformanceTime:()=>gi,secondsToScoreTime:()=>ic,skipSpaces:()=>ut,skipSpacesBack:()=>pe,transformNotes:()=>Bs,unionLayoutBoxes:()=>Ae});var N=class i{code;message;span;constructor(t,e,n){this.code=t,this.message=e,this.span=n}toLineCol(t){let e=i.offsetToLineCol(this.span.start,t),n=i.offsetToLineCol(this.span.end,t);return{startLine:e.line,startColumn:e.column,endLine:n.line,endColumn:n.column}}static offsetToLineCol(t,e){let n=e.length;if(n===0)return{line:1,column:Math.max(0,t)+1};let o=t;o<0&&(o=0);let s=0,r=n-1;for(;s<=r;){let l=s+r>>1;e[l]<=o?s=l+1:r=l-1}let c=Math.max(0,r),a=e[c]??0;return{line:c+1,column:o-a+1}}static error;static warning},S=class extends N{},O=class extends N{};N.error={Bug:(i,t)=>new S("E_BUG",`\u89E3\u6790\u5668\u9519\u8BEF: ${i}\uFF0C\u8BF7\u8054\u7CFB\u5F00\u53D1\u8005\u4FEE\u590D\u8FD9\u4E2A\u95EE\u9898`,t),MissingArg:(i,t,e)=>{let n=typeof t=="number"?`[${t}]`:`"${t}"`;return new S("E_MISSING_REQUIRED_ARG",`\u51FD\u6570@${i} \u7F3A\u5C11\u5FC5\u9700\u7684\u53C2\u6570 ${n}`,e)},InvalidArgType:(i,t,e,n,o)=>{let s=typeof t=="number"?`[${t}]`:`"${t}"`;return new S("E_WRONG_ARG_TYPE",`\u51FD\u6570 @${i} \u7684\u53C2\u6570 ${s} \u7C7B\u578B\u9519\u8BEF: \u5F97\u5230\u4E86 ${n}\uFF0C\u4F46\u671F\u671B ${e}`,o)},PosAfterNamedArg:(i,t)=>new S("E_POSARG_AFTER_KWARG",`\u51FD\u6570 @${i} \u7684\u4F4D\u7F6E\u53C2\u6570\u51FA\u73B0\u5728\u547D\u540D\u53C2\u6570\u4E4B\u540E\uFF0C\u8FD9\u662F\u4E0D\u5141\u8BB8\u7684`,t),EmptyContent:(i,t,e)=>{let n=typeof t=="number"?`[${t}]`:`"${t}"`;return new S("E_EMPTY_CONTENT",`\u51FD\u6570 @${i} \u7684\u53C2\u6570 ${n} \u5185\u5BB9\u4E3A\u7A7A(\u6216\u65E0\u53EF\u7528\u5185\u5BB9)\uFF1B\u8BF7\u63D0\u4F9B\u6709\u6548\u5185\u5BB9`,e)},UnterminatedCall:(i,t)=>new S("E_UNTERMINATED_CALL",`\u51FD\u6570\u8C03\u7528\u672A\u95ED\u5408: @${i}(...)`,t),UnterminatedString:i=>new S("E_UNTERMINATED_String","\u5F15\u53F7\u672A\u95ED\u5408",i),UnknownFunction:(i,t)=>new S("E_UNKNOWN_FUNCTION",`\u672A\u77E5\u51FD\u6570: @${i}\uFF0C\u8BF7\u68C0\u67E5\u62FC\u5199`,t),UnknownLabel:(i,t)=>new S("E_UNKNOWN_LABEL",`\u672A\u77E5\u6807\u7B7E: "${i}"`,t),InvalidTonality:(i,t)=>new S("E_INVALID_TONALITY",`\u65E0\u6548\u7684\u8C03\u6027: "${i}"\uFF0C\u8BF7\u63D0\u4F9B\u6709\u6548\u7684\u8C03\u6027\u540D\u79F0\uFF0C\u5FC5\u987B [\u4E00\u4E2A\u5927\u5199\u5B57\u6BCD][\u53D8\u97F3\u8BB0\u53F7#bn\u53EA\u80FD\u4E00\u4E2A][\u7EDD\u5BF9\u516B\u5EA6\u6570\u5B57]\uFF0C\u540E\u4E8C\u8005\u53EF\u9009`,t),BreakInsideEvent:i=>new S("E_BREAK_INSIDE_EVENT","\u6362\u884C\u5207\u65AD\u4E86\u4E00\u4E2A\u4ECD\u5728\u6301\u7EED\u7684\u4E8B\u4EF6\uFF1B\u8BF7\u628A\u957F\u97F3\u5199\u6210\u591A\u4E2A\u4E8B\u4EF6\uFF0C\u6216\u8C03\u6574 @br \u7684\u4F4D\u7F6E",i),InvalidPageConfig:(i,t)=>new S("E_INVALID_PAGE_CONFIG",i,t),PageOverflow:(i,t,e)=>new S("E_PAGE_OVERFLOW",`\u8C31\u9762\u884C\u9700\u8981 ${i}px \u9AD8\u5EA6\uFF0C\u4F46\u9875\u9762\u5185\u5BB9\u533A\u53EA\u6709 ${t}px`,e)};N.warning={UnknownFunction:(i,t)=>new O("W_UNKNOWN_FUNCTION",`\u672A\u77E5\u51FD\u6570: @${i}\uFF0C\u5C06\u88AB\u5F53\u4F5C\u666E\u901A\u6587\u672C\u5904\u7406`,t),UnknownNamedArg:(i,t,e)=>new O("W_UNKNOWN_NAMED_ARG",`\u51FD\u6570 @${i} \u6536\u5230\u672A\u77E5\u7684\u547D\u540D\u53C2\u6570 "${t}"`,e),TooManyPosArgs:(i,t,e,n)=>new O("W_TOO_MANY_POS_ARGS",`\u51FD\u6570 @${i} \u63A5\u6536\u4E86\u8FC7\u591A\u7684\u4F4D\u7F6E\u53C2\u6570\uFF0C\u671F\u671B ${t} \u4E2A\u4F46\u5F97\u5230\u4E86 ${e} \u4E2A`,n),InvalidNumber:(i,t)=>new O("W_INVALID_NUMBER",`\u65E0\u6548\u7684\u6570\u5B57: "${i}"\uFF1B\u5C06\u4F7F\u7528\u9ED8\u8BA4\u503C(\u82E5\u5B58\u5728)`,t),InvalidBoolean:(i,t)=>new O("W_INVALID_BOOL",`\u65E0\u6548\u7684\u5E03\u5C14\u503C: "${i}": \u5E94\u4E3A 'true' \u6216 'false'\uFF1B\u5C06\u4F7F\u7528\u9ED8\u8BA4\u503C(\u82E5\u5B58\u5728)`,t),InvalidLength:(i,t)=>new O("W_INVALID_LENGTH",`\u65E0\u6548\u7684\u957F\u5EA6\u503C: "${i}"\uFF1B\u8BF7\u63D0\u4F9B\u6709\u6548\u7684\u957F\u5EA6\u503C\uFF0C\u4F8B\u5982 "10px" \u6216 "2em"\uFF1B\u5C06\u4F7F\u7528\u9ED8\u8BA4\u503C(\u82E5\u5B58\u5728)`,t),InvalidLengthUnit:(i,t)=>new O("W_INVALID_LENGTH_UNIT",`\u65E0\u6548\u7684\u957F\u5EA6\u5355\u4F4D: "${i}"\uFF1B\u4EC5\u652F\u6301 "px" \u548C "em"\uFF1B\u8BF7\u68C0\u67E5\u51FD\u6570\u53C2\u6570\u6216\u53D8\u91CF\u5B9A\u4E49\uFF1B\u5C06\u4F7F\u7528\u9ED8\u8BA4\u503C(\u82E5\u5B58\u5728)`,t),InvalidContent:i=>new O("W_INVALID_CONTENT","\u5185\u5BB9\u89E3\u6790\u5931\u8D25\uFF0C\u9519\u8BEF\u539F\u56E0\u89C1\u4E0A\uFF1B\u5C06\u4F7F\u7528\u9ED8\u8BA4\u503C(\u4F46\u5F80\u5F80\u4E0D\u5B58\u5728\uFF0C\u6781\u6709\u53EF\u80FD\u5BFC\u81F4\u9519\u8BEF)",i),EmptyContent:(i,t,e)=>new O("W_EMPTY_CONTENT",`\u51FD\u6570 @${i} \u7684\u53C2\u6570 "${t}" \u5185\u5BB9\u4E3A\u7A7A(\u6216\u65E0\u53EF\u7528\u5185\u5BB9)`,e),UnmatchedBrace:i=>new O("W_UNMATCHED_BRACE","\u672A\u5339\u914D\u7684\u5927\u62EC\u53F7: \u7F3A\u5C11\u53F3\u5927\u62EC\u53F7'}'\uFF1B\u5C06\u5C1D\u8BD5\u81EA\u52A8\u4FEE\u590D",i),LabelWithoutTarget:(i,t)=>new O("W_LABEL_WITHOUT_TARGET",`\u6807\u7B7E "${i}" \u6CA1\u6709\u53EF\u7ED1\u5B9A\u7684\u76EE\u6807\uFF1B\u6807\u7B7E\u5C06\u88AB\u5FFD\u7565`,t),TargetAlreadyLabeled:(i,t,e)=>new O("W_TARGET_ALREADY_LABELED",`\u76EE\u6807\u5DF2\u6807\u6CE8\u4E3A "${t}"\uFF0C"${i}" \u5C06\u88AB\u5FFD\u7565`,e),UnresolvedEndpoint:(i,t)=>new O("W_UNRESOLVED_ENDPOINT",`@${i} \u6709\u7AEF\u70B9\u627E\u4E0D\u5230\u5BF9\u5E94\u7684\u8C31\u9762\u5BF9\u8C61\uFF1B\u8BE5\u5173\u7CFB\u5C06\u88AB\u5FFD\u7565`,t),ZeroTimeTrack:(i,t)=>new O("W_ZERO_TIME_TRACK",`\u7B2C${t}\u4E2A\u5B50\u8F68\u9053\u7684\u65F6\u957F\u4E3A0`,i)};function Lt(i){return`@${i}`}var et=class{sourceSpan;parent;get children(){return null}constructor(t,e=null){this.sourceSpan=t,this.parent=e}loweringEnter(t,e){return[]}timeFlowModel(t){return null}loweringExit(t,e,n){return[]}toString(t){return t.slice(this.sourceSpan.start,this.sourceSpan.end)}},Z=class extends et{},lt=class extends et{label;target;constructor(t,e,n,o=null){super(t,o),this.label=e,this.target=n}toString(t){return`@${this.label} `}},K=class i extends et{content;get children(){return this.content}constructor(t,e,n=null){super(t,n),this.content=e,this.content.forEach(o=>o.parent=this)}innerSpan(){return i.getContentSpan(this.content)}static getContentSpan(t){if(Array.isArray(t)){if(t.length===0)return{start:0,end:0};let e=i.getContentSpan(t[0]),n=i.getContentSpan(t[t.length-1]);return{start:e.start,end:n.end}}else return{start:t.sourceSpan.start,end:t.sourceSpan.end}}timeFlowModel(){return{children:this.content,mode:"sequence"}}toString(t){return`{${this.content.map(e=>e.toString(t)).join("")}}`}};function $t(i,t,e){return t?i.args.find(n=>n.name?.toLowerCase()===t)?.type:i.args[e]?.type??(i.allowExtraArgs?i.extraArgType:void 0)}function ne(i){return Array.isArray(i.name)?i.name[0]:i.name}var v=class i extends et{label;static def;get def(){return this.constructor.def}get callName(){return this.def?ne(this.def):""}static deSugarAtom=()=>null;get deSugarAtom(){return this.constructor.deSugarAtom}static deSugarRelation=()=>null;get deSugarRelation(){return this.constructor.deSugarRelation}getArgValue(t,e){let n=this.def;if(!n)return[];let o=n.args,s=ne(n);return o.map((r,c)=>{let a=r.name?r.name.toLowerCase():null,l=(a?t.get(a):null)??t.get(c)??(a?e.variables[`${s}.${a}`.toLowerCase()]:null)??r.default;if(l===null)throw N.error.MissingArg(s,r.name||c,this.sourceSpan);return l})}toString(t){let e=this.callName;return e?`@${e} `:super.toString(t)}static loweringAugment;static loweringFinalize;static layoutDecorationHandler;static findLabelable(t){let e=t;if(e.labelable)return e.labelable();for(let n of t.children??[]){let o=i.findLabelable(n);if(o)return o}return null}static findLastFuncContentIndex(t,e){for(;e>=0;e--)if(t[e]instanceof i||t[e]instanceof K)return e;return-1}};function Ei(i,t){for(;t!==0;){let e=i%t;i=t,t=e}return i}var I=class i{_numerator=0;_denominator=1;constructor(t=0,e=1){this.set(t,e)}get numerator(){return this._numerator}get denominator(){return this._denominator}set(t,e=1){if(!Number.isFinite(t)||!Number.isFinite(e))throw new RangeError("Fraction numerator and denominator must be finite");if(e===0)throw new RangeError("Denominator must not be zero");e<0&&(t=-t,e=-e);let n=Ei(Math.abs(t),e);return this._numerator=t/n,this._denominator=e/n,this}copyFrom(t){return this._numerator=t._numerator,this._denominator=t._denominator,this}clone(){return new i(this._numerator,this._denominator)}add(t,e=1){let n;return typeof t=="number"?n=t:(n=t._numerator,e=t._denominator),this.set(this._numerator*e+n*this._denominator,this._denominator*e)}sub(t,e=1){let n;return typeof t=="number"?n=t:(n=t._numerator,e=t._denominator),this.set(this._numerator*e-n*this._denominator,this._denominator*e)}mul(t,e=1){let n;return typeof t=="number"?n=t:(n=t._numerator,e=t._denominator),this.set(this._numerator*n,this._denominator*e)}div(t,e=1){let n;if(typeof t=="number"?n=t:(n=t._numerator,e=t._denominator),n===0)throw new RangeError("Cannot divide by zero");return this.set(this._numerator*e,this._denominator*n)}divPow2(t=1){if(this._numerator===0)return this;for(;t>0&&this._numerator%2===0;)this._numerator/=2,t--;let e=this._denominator*2**t;if(!Number.isFinite(e))throw new RangeError("Fraction denominator overflow");return this._denominator=e,this}compare(t,e=1){let n;typeof t=="number"?n=t:(n=t._numerator,e=t._denominator);let o=this._numerator*e-n*this._denominator;return o<0?-1:o>0?1:0}equals(t,e=1){return t instanceof i?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 yt=120,Bt=80,oe="C4",be=0,U=-1/0,ht=1/0,W=class{t=new I;T=new I;track;ast;order;addon;mergeKey;foldedInto;breakBefore=0;layoutLine=0;box;springConfig;ports;decorations;initLayoutBox(){return this.box={x:0,y:0,w:0,h:0,anchor:0,visualAxis:0}}playbackState;prepareLayout(t){}paint(t){}};function F(i){return i.box!==void 0}function Tt(i){return typeof i.createGeometry=="function"}var zt=class{target;dx;dy;constructor(t,e,n){this.target=t,this.dx=e,this.dy=n}drawText(t,e,n,o){this.target.drawText(t,e+this.dx,n+this.dy,o)}drawLine(t,e,n,o,s){this.target.drawLine(t+this.dx,e+this.dy,n+this.dx,o+this.dy,s)}drawRect(t,e,n,o,s){this.target.drawRect(t+this.dx,e+this.dy,n,o,s)}drawCircle(t,e,n,o){this.target.drawCircle(t+this.dx,e+this.dy,n,o)}drawPath(t,e,n){if(n){let o={...n,x:n.x+this.dx,y:n.y+this.dy};this.target.drawPath(t,e,o);return}this.target.drawPath(t.map(o=>this.translateCommand(o)),e)}translateCommand(t){switch(t.op){case"Z":return t;case"Q":return{op:"Q",cx:t.cx+this.dx,cy:t.cy+this.dy,x:t.x+this.dx,y:t.y+this.dy};case"C":return{op:"C",cx1:t.cx1+this.dx,cy1:t.cy1+this.dy,cx2:t.cx2+this.dx,cy2:t.cy2+this.dy,x:t.x+this.dx,y:t.y+this.dy};default:return{op:t.op,x:t.x+this.dx,y:t.y+this.dy}}}};var on=class extends v{static def={name:["adjust","adj"],description:"\u5FAE\u8C03\u76EE\u6807\u7684\u7ED8\u5236\u4F4D\u7F6E\u4E0E\u6392\u7248\u5360\u4F4D",details:`~~~jpfun
|
|
2
|
+
"use strict";(()=>{var ar=Object.defineProperty;var lr=(r,t)=>{for(var e in t)ar(r,e,{get:t[e],enumerable:!0})};var rs={};lr(rs,{ANCHOR_KEY:()=>nt,ASTBraceNode:()=>tt,ASTFunctionNode:()=>L,ASTLabelNode:()=>mt,ASTNodeBase:()=>st,ASTTextNode:()=>et,CanvasPainter:()=>xn,CanvasTextMeasurer:()=>Zn,DEFAULT_BPM:()=>Et,DEFAULT_FONT_SIZE:()=>ei,DEFAULT_KEY:()=>dt,DEFAULT_OCTAVE:()=>Zr,DEFAULT_PAGE_CONFIG:()=>ct,DEFAULT_PROGRAM:()=>Re,DEFAULT_TEXT_FONT:()=>ee,DEFAULT_TONALITY:()=>fe,DEFAULT_VELOCITY:()=>Kt,DefaultTextMeasurer:()=>$e,Diagnostic:()=>M,ErrorDiagnostic:()=>w,Fraction:()=>B,JIANPU_NUMBER_FONT:()=>qn,LoweringContext:()=>ke,PageLayoutError:()=>Xt,ParserContext:()=>pt,RecordingPainter:()=>is,SvgPainter:()=>dn,TemporalNodeBase:()=>$,Track:()=>Bt,WarningDiagnostic:()=>P,analyzeScoreSyntax:()=>Kc,canvasFont:()=>ze,compilePlayback:()=>Zc,compileScore:()=>Yc,completeSpringConfig:()=>Oe,createLayoutPrepareContext:()=>Qo,defaultFunctions:()=>fn,defaultTextMeasurer:()=>Qn,functionAddonKey:()=>It,getLayoutBounds:()=>ot,isLayoutAttachment:()=>yt,isPlaybackRelation:()=>ns,isVisualTemporalNode:()=>I,layoutDocument:()=>_n,layoutElement:()=>Pe,layoutHorizontal:()=>bn,layoutHorizontalRegion:()=>jt,layoutLocalSequence:()=>qt,layoutPageBounds:()=>Gt,normalizePageConfig:()=>ue,paginateLayoutLines:()=>wn,paintLayout:()=>ss,paintLayoutPages:()=>ce,performanceTimeToScoreTime:()=>or,performanceTimeToSeconds:()=>un,prepareHorizontalLine:()=>kn,prepareLayoutHost:()=>me,preprocessSource:()=>oe,primaryName:()=>pe,renderLayoutPagesToCanvas:()=>ea,renderLayoutPagesToSvg:()=>Jc,resolveArgDef:()=>as,resolveArgType:()=>Yt,scoreTimeToPerformanceTime:()=>sr,scoreTimeToSeconds:()=>jc,secondsToPerformanceTime:()=>nr,secondsToScoreTime:()=>Uc,skipSpaces:()=>wt,skipSpacesBack:()=>Ce,transferFunctionAddons:()=>Ot,transformNotes:()=>gi,unionLayoutBoxes:()=>Zt});var M=class r{code;message;span;constructor(t,e,n){this.code=t,this.message=e,this.span=n}toLineCol(t){let e=r.offsetToLineCol(this.span.start,t),n=r.offsetToLineCol(this.span.end,t);return{startLine:e.line,startColumn:e.column,endLine:n.line,endColumn:n.column}}static offsetToLineCol(t,e){let n=e.length;if(n===0)return{line:1,column:Math.max(0,t)+1};let o=t;o<0&&(o=0);let s=0,i=n-1;for(;s<=i;){let l=s+i>>1;e[l]<=o?s=l+1:i=l-1}let c=Math.max(0,i),a=e[c]??0;return{line:c+1,column:o-a+1}}static error;static warning},w=class extends M{},P=class extends M{};M.error={Bug:(r,t)=>new w("E_BUG",`\u89E3\u6790\u5668\u9519\u8BEF: ${r}\uFF0C\u8BF7\u8054\u7CFB\u5F00\u53D1\u8005\u4FEE\u590D\u8FD9\u4E2A\u95EE\u9898`,t),MissingArg:(r,t,e)=>{let n=typeof t=="number"?`[${t}]`:`"${t}"`;return new w("E_MISSING_REQUIRED_ARG",`\u51FD\u6570@${r} \u7F3A\u5C11\u5FC5\u9700\u7684\u53C2\u6570 ${n}`,e)},InvalidArgType:(r,t,e,n,o)=>{let s=typeof t=="number"?`[${t}]`:`"${t}"`;return new w("E_WRONG_ARG_TYPE",`\u51FD\u6570 @${r} \u7684\u53C2\u6570 ${s} \u7C7B\u578B\u9519\u8BEF: \u5F97\u5230\u4E86 ${n}\uFF0C\u4F46\u671F\u671B ${e}`,o)},PosAfterNamedArg:(r,t)=>new w("E_POSARG_AFTER_KWARG",`\u51FD\u6570 @${r} \u7684\u4F4D\u7F6E\u53C2\u6570\u51FA\u73B0\u5728\u547D\u540D\u53C2\u6570\u4E4B\u540E\uFF0C\u8FD9\u662F\u4E0D\u5141\u8BB8\u7684`,t),EmptyContent:(r,t,e)=>{let n=typeof t=="number"?`[${t}]`:`"${t}"`;return new w("E_EMPTY_CONTENT",`\u51FD\u6570 @${r} \u7684\u53C2\u6570 ${n} \u5185\u5BB9\u4E3A\u7A7A(\u6216\u65E0\u53EF\u7528\u5185\u5BB9)\uFF1B\u8BF7\u63D0\u4F9B\u6709\u6548\u5185\u5BB9`,e)},UnterminatedCall:(r,t)=>new w("E_UNTERMINATED_CALL",`\u51FD\u6570\u8C03\u7528\u672A\u95ED\u5408: @${r}(...)`,t),UnterminatedString:r=>new w("E_UNTERMINATED_String","\u5F15\u53F7\u672A\u95ED\u5408",r),UnknownFunction:(r,t)=>new w("E_UNKNOWN_FUNCTION",`\u672A\u77E5\u51FD\u6570: @${r}\uFF0C\u8BF7\u68C0\u67E5\u62FC\u5199`,t),UnknownLabel:(r,t)=>new w("E_UNKNOWN_LABEL",`\u672A\u77E5\u6807\u7B7E: "${r}"`,t),InvalidTonality:(r,t)=>new w("E_INVALID_TONALITY",`\u65E0\u6548\u7684\u8C03\u6027: "${r}"\uFF0C\u8BF7\u63D0\u4F9B\u6709\u6548\u7684\u8C03\u6027\u540D\u79F0\uFF0C\u5FC5\u987B [\u4E00\u4E2A\u5927\u5199\u5B57\u6BCD][\u53D8\u97F3\u8BB0\u53F7#bn\u53EA\u80FD\u4E00\u4E2A][\u7EDD\u5BF9\u516B\u5EA6\u6570\u5B57]\uFF0C\u540E\u4E8C\u8005\u53EF\u9009`,t),BreakInsideEvent:r=>new 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),InvalidPageConfig:(r,t)=>new w("E_INVALID_PAGE_CONFIG",r,t),PageOverflow:(r,t,e)=>new w("E_PAGE_OVERFLOW",`\u8C31\u9762\u884C\u9700\u8981 ${r}px \u9AD8\u5EA6\uFF0C\u4F46\u9875\u9762\u5185\u5BB9\u533A\u53EA\u6709 ${t}px`,e)};M.warning={UnknownFunction:(r,t)=>new P("W_UNKNOWN_FUNCTION",`\u672A\u77E5\u51FD\u6570: @${r}\uFF0C\u5C06\u88AB\u5F53\u4F5C\u666E\u901A\u6587\u672C\u5904\u7406`,t),UnknownNamedArg:(r,t,e)=>new P("W_UNKNOWN_NAMED_ARG",`\u51FD\u6570 @${r} \u6536\u5230\u672A\u77E5\u7684\u547D\u540D\u53C2\u6570 "${t}"`,e),TooManyPosArgs:(r,t,e,n)=>new P("W_TOO_MANY_POS_ARGS",`\u51FD\u6570 @${r} \u63A5\u6536\u4E86\u8FC7\u591A\u7684\u4F4D\u7F6E\u53C2\u6570\uFF0C\u671F\u671B ${t} \u4E2A\u4F46\u5F97\u5230\u4E86 ${e} \u4E2A`,n),InvalidNumber:(r,t)=>new P("W_INVALID_NUMBER",`\u65E0\u6548\u7684\u6570\u5B57: "${r}"\uFF1B\u5C06\u4F7F\u7528\u9ED8\u8BA4\u503C(\u82E5\u5B58\u5728)`,t),InvalidBoolean:(r,t)=>new P("W_INVALID_BOOL",`\u65E0\u6548\u7684\u5E03\u5C14\u503C: "${r}": \u5E94\u4E3A 'true' \u6216 'false'\uFF1B\u5C06\u4F7F\u7528\u9ED8\u8BA4\u503C(\u82E5\u5B58\u5728)`,t),InvalidLength:(r,t)=>new P("W_INVALID_LENGTH",`\u65E0\u6548\u7684\u957F\u5EA6\u503C: "${r}"\uFF1B\u8BF7\u63D0\u4F9B\u6709\u6548\u7684\u957F\u5EA6\u503C\uFF0C\u4F8B\u5982 "10px" \u6216 "2em"\uFF1B\u5C06\u4F7F\u7528\u9ED8\u8BA4\u503C(\u82E5\u5B58\u5728)`,t),InvalidLengthUnit:(r,t)=>new P("W_INVALID_LENGTH_UNIT",`\u65E0\u6548\u7684\u957F\u5EA6\u5355\u4F4D: "${r}"\uFF1B\u4EC5\u652F\u6301 "px" \u548C "em"\uFF1B\u8BF7\u68C0\u67E5\u51FD\u6570\u53C2\u6570\u6216\u53D8\u91CF\u5B9A\u4E49\uFF1B\u5C06\u4F7F\u7528\u9ED8\u8BA4\u503C(\u82E5\u5B58\u5728)`,t),InvalidContent:r=>new P("W_INVALID_CONTENT","\u5185\u5BB9\u89E3\u6790\u5931\u8D25\uFF0C\u9519\u8BEF\u539F\u56E0\u89C1\u4E0A\uFF1B\u5C06\u4F7F\u7528\u9ED8\u8BA4\u503C(\u4F46\u5F80\u5F80\u4E0D\u5B58\u5728\uFF0C\u6781\u6709\u53EF\u80FD\u5BFC\u81F4\u9519\u8BEF)",r),EmptyContent:(r,t,e)=>new P("W_EMPTY_CONTENT",`\u51FD\u6570 @${r} \u7684\u53C2\u6570 "${t}" \u5185\u5BB9\u4E3A\u7A7A(\u6216\u65E0\u53EF\u7528\u5185\u5BB9)`,e),UnmatchedBrace:r=>new P("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 P("W_LABEL_WITHOUT_TARGET",`\u6807\u7B7E "${r}" \u6CA1\u6709\u53EF\u7ED1\u5B9A\u7684\u76EE\u6807\uFF1B\u6807\u7B7E\u5C06\u88AB\u5FFD\u7565`,t),TargetAlreadyLabeled:(r,t,e)=>new P("W_TARGET_ALREADY_LABELED",`\u76EE\u6807\u5DF2\u6807\u6CE8\u4E3A "${t}"\uFF0C"${r}" \u5C06\u88AB\u5FFD\u7565`,e),UnresolvedEndpoint:(r,t)=>new P("W_UNRESOLVED_ENDPOINT",`@${r} \u6709\u7AEF\u70B9\u627E\u4E0D\u5230\u5BF9\u5E94\u7684\u8C31\u9762\u5BF9\u8C61\uFF1B\u8BE5\u5173\u7CFB\u5C06\u88AB\u5FFD\u7565`,t),ZeroTimeTrack:(r,t)=>new P("W_ZERO_TIME_TRACK",`\u7B2C${t}\u4E2A\u5B50\u8F68\u9053\u7684\u65F6\u957F\u4E3A0`,r)};function It(r){return`@${r}`}var st=class{sourceSpan;parent;get children(){return null}constructor(t,e=null){this.sourceSpan=t,this.parent=e}loweringEnter(t,e){return[]}timeFlowModel(t){return null}loweringExit(t,e,n){return[]}toString(t){return t.slice(this.sourceSpan.start,this.sourceSpan.end)}},et=class extends st{},mt=class extends st{label;target;constructor(t,e,n,o=null){super(t,o),this.label=e,this.target=n}toString(t){return`@${this.label} `}},tt=class r extends st{content;get children(){return this.content}constructor(t,e,n=null){super(t,n),this.content=e,this.content.forEach(o=>o.parent=this)}innerSpan(){return r.getContentSpan(this.content)}static getContentSpan(t){if(Array.isArray(t)){if(t.length===0)return{start:0,end:0};let e=r.getContentSpan(t[0]),n=r.getContentSpan(t[t.length-1]);return{start:e.start,end:n.end}}else return{start:t.sourceSpan.start,end:t.sourceSpan.end}}timeFlowModel(){return{children:this.content,mode:"sequence"}}toString(t){return`{${this.content.map(e=>e.toString(t)).join("")}}`}};function as(r,t,e){if(t){let n=t.toLowerCase();return r.args.find(o=>o.name?.toLowerCase()===n)}for(let n of r.args)if(!n.namedOnly&&e--===0)return n}function Yt(r,t,e){return as(r,t,e)?.type??(!t&&r.allowExtraArgs?r.extraArgType:void 0)}function pe(r){return Array.isArray(r.name)?r.name[0]:r.name}var L=class r extends st{label;static def;get def(){return this.constructor.def}get callName(){return this.def?pe(this.def):""}static deSugarAtom=()=>null;get deSugarAtom(){return this.constructor.deSugarAtom}static deSugarRelation=()=>null;get deSugarRelation(){return this.constructor.deSugarRelation}getArgValue(t,e){let n=this.def;if(!n)return[];let o=pe(n),s=0;return n.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[`${o}.${l}`.toLowerCase()]:void 0)??i.default;if(h===null)throw M.error.MissingArg(o,i.name||(a??c),this.sourceSpan);return h})}toString(t){let e=this.callName;return e?`@${e} `:super.toString(t)}static loweringAugment;static loweringFinalize;static layoutDecorationHandler;static findLabelable(t){let e=t;if(e.labelable)return e.labelable();for(let n of t.children??[]){let o=r.findLabelable(n);if(o)return o}return null}static findLastFuncContentIndex(t,e){for(;e>=0;e--)if(t[e]instanceof r||t[e]instanceof tt)return e;return-1}};function hr(r,t){for(;t!==0;){let e=r%t;r=t,t=e}return r}var B=class r{_numerator=0;_denominator=1;constructor(t=0,e=1){this.set(t,e)}get numerator(){return this._numerator}get denominator(){return this._denominator}set(t,e=1){if(!Number.isFinite(t)||!Number.isFinite(e))throw new RangeError("Fraction numerator and denominator must be finite");if(e===0)throw new RangeError("Denominator must not be zero");e<0&&(t=-t,e=-e);let n=hr(Math.abs(t),e);return this._numerator=t/n,this._denominator=e/n,this}copyFrom(t){return this._numerator=t._numerator,this._denominator=t._denominator,this}clone(){return new r(this._numerator,this._denominator)}add(t,e=1){let n;return typeof t=="number"?n=t:(n=t._numerator,e=t._denominator),this.set(this._numerator*e+n*this._denominator,this._denominator*e)}sub(t,e=1){let n;return typeof t=="number"?n=t:(n=t._numerator,e=t._denominator),this.set(this._numerator*e-n*this._denominator,this._denominator*e)}mul(t,e=1){let n;return typeof t=="number"?n=t:(n=t._numerator,e=t._denominator),this.set(this._numerator*n,this._denominator*e)}div(t,e=1){let n;if(typeof t=="number"?n=t:(n=t._numerator,e=t._denominator),n===0)throw new RangeError("Cannot divide by zero");return this.set(this._numerator*e,this._denominator*n)}divPow2(t=1){if(this._numerator===0)return this;for(;t>0&&this._numerator%2===0;)this._numerator/=2,t--;let e=this._denominator*2**t;if(!Number.isFinite(e))throw new RangeError("Fraction denominator overflow");return this._denominator=e,this}compare(t,e=1){let n;typeof t=="number"?n=t:(n=t._numerator,e=t._denominator);let o=this._numerator*e-n*this._denominator;return o<0?-1:o>0?1:0}equals(t,e=1){return t instanceof 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 Et=120,Kt=80,fe="C4",Re=0,nt=-1/0,dt=1/0,$=class{t=new B;T=new B;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 Ot(r,t){let e=r.addon;if(e){for(let n of Object.keys(e).filter(o=>o.startsWith("@")))(t.addon??={})[n]=e[n],delete e[n];Object.keys(e).length||(r.addon=void 0)}}function I(r){return r.box!==void 0}function yt(r){return typeof r.createGeometry=="function"}var Ut=class{target;dx;dy;constructor(t,e,n){this.target=t,this.dx=e,this.dy=n}drawText(t,e,n,o){this.target.drawText(t,e+this.dx,n+this.dy,o)}drawLine(t,e,n,o,s){this.target.drawLine(t+this.dx,e+this.dy,n+this.dx,o+this.dy,s)}drawRect(t,e,n,o,s){this.target.drawRect(t+this.dx,e+this.dy,n,o,s)}drawCircle(t,e,n,o){this.target.drawCircle(t+this.dx,e+this.dy,n,o)}drawPath(t,e,n){if(n){let o={...n,x:n.x+this.dx,y:n.y+this.dy};this.target.drawPath(t,e,o);return}this.target.drawPath(t.map(o=>this.translateCommand(o)),e)}translateCommand(t){switch(t.op){case"Z":return t;case"Q":return{op:"Q",cx:t.cx+this.dx,cy:t.cy+this.dy,x:t.x+this.dx,y:t.y+this.dy};case"C":return{op:"C",cx1:t.cx1+this.dx,cy1:t.cy1+this.dy,cx2:t.cx2+this.dx,cy2:t.cy2+this.dy,x:t.x+this.dx,y:t.y+this.dy};default:return{op:t.op,x:t.x+this.dx,y:t.y+this.dy}}}};var yn=class extends L{static def={name:["adjust","adj"],description:"\u5FAE\u8C03\u76EE\u6807\u7684\u7ED8\u5236\u4F4D\u7F6E\u4E0E\u6392\u7248\u5360\u4F4D",details:`~~~jpfun
|
|
3
3
|
@adjust(1, dx=2px, dy=-1px, dw=0.2em, dh=0px)
|
|
4
4
|
~~~
|
|
5
5
|
|
|
6
|
-
\u4F4D\u7F6E\u504F\u79FB\u5728\u6392\u7248\u540E\u5E94\u7528\uFF0C\u76F8\u90BB\u5BF9\u8C61\u4FDD\u6301\u539F\u4F4D\uFF1B\u5360\u4F4D\u8C03\u6574\u5728\u6392\u7248\u524D\u5E94\u7528\u3002\u53EA\u5305\u88F9\u5173\u7CFB\u5BF9\u8C61\u65F6\uFF0C\u5E73\u79FB\u4F5C\u7528\u4E8E\u8BE5\u5173\u7CFB\u5BF9\u8C61\u672C\u8EAB\u3002`,allowExtraArgs:!1,args:[{type:"content",description:"\u8981\u5FAE\u8C03\u7684\u5185\u5BB9\u6216\u5173\u7CFB\u5BF9\u8C61",default:null},{name:"dx",description:"\u6392\u7248\u540E\u7684\u6C34\u5E73\u504F\u79FB\uFF0C\u6B63\u503C\u5411\u53F3\uFF0C\u4E0D\u6539\u53D8\u5360\u4F4D",type:"length",default:{value:0,unit:"px"}},{name:"dy",description:"\u6392\u7248\u540E\u7684\u5782\u76F4\u504F\u79FB\uFF0C\u6B63\u503C\u5411\u4E0B\uFF0C\u4E0D\u6539\u53D8\u5360\u4F4D",type:"length",default:{value:0,unit:"px"}},{name:"dw",description:"\u589E\u51CF\u6C34\u5E73\u5360\u4F4D\uFF0C\u6309\u539F\u5DE6\u53F3\u6BD4\u4F8B\u5206\u914D\uFF0C\u6700\u7EC8\u5BBD\u5EA6\u4E0D\u5C0F\u4E8E 0",type:"length",default:{value:0,unit:"px"}},{name:"dh",description:"\u589E\u51CF\u4E0B\u65B9\u5360\u4F4D\uFF0C\u6700\u7EC8\u9AD8\u5EA6\u4E0D\u5C0F\u4E8E 0",type:"length",default:{value:0,unit:"px"}}]};target;dx;dy;dw;dh;get children(){return[this.target]}timeFlowModel(){return{children:[this.target],mode:"sequence"}}loweringEnter(t){let e={temporal:0,attachment:0},n={targets:e,onTemporal:o=>{F(o)&&(e.temporal++,_i(o,this))},onAttachment:o=>{Tt(o)&&(e.attachment++,vi(o,e,this.dx,this.dy))}};return t.beginLoweringGroup(this,n),[]}loweringExit(t){let e=t.endLoweringGroup(this);return e.targets.temporal===0&&e.targets.attachment===0&&t.diagnostics.push(new O("W_ADJUST_NO_TARGET","@adjust \u6CA1\u6709\u627E\u5230\u53EF\u8C03\u6574\u7684\u5BF9\u8C61",this.sourceSpan)),[]}constructor(t,e,n,o=null){super(t,o);let[s,r,c,a,l]=this.getArgValue(e,n);s.parent=this,this.target=s,this.dx=n.length2px(r),this.dy=n.length2px(c),this.dw=n.length2px(a),this.dh=n.length2px(l)}toString(t){return`@adjust(${this.target.toString(t)}, dx=${this.dx}px, dy=${this.dy}px, dw=${this.dw}px, dh=${this.dh}px)`}},Ro=on;function _i(i,t){let{dx:e,dy:n,dw:o,dh:s}=t;if(e===0&&n===0&&o===0&&s===0)return;let r,c,a=i.finalizeLayout,l=i.onPlaced;i.finalizeLayout=h=>{a?.call(i,h);let p=Math.max(0,i.box.w+o);i.box.anchor=i.box.w>0?i.box.anchor*p/i.box.w:0,i.box.w=p,i.box.h=Math.max(0,i.box.h+s)},i.onPlaced=()=>{i.box.x!==r&&(i.box.x+=e),i.box.y!==c&&(i.box.y+=n),l?.call(i),r=i.box.x,c=i.box.y}}function vi(i,t,e,n){if(e===0&&n===0)return;let o=i.createGeometry;i.createGeometry=s=>{let r=o.call(i,s);if(t.temporal>0)return r;let c=a=>a.line===void 0?{x:a.x+e,y:a.y+n,w:a.w,h:a.h}:{x:a.x+e,y:a.y+n,w:a.w,h:a.h,line:a.line,track:a.track};return{regions:r.regions.map(c),occupancy:r.occupancy?.map(c),paint(a){r.paint(new zt(a,e,n))}}}}var we=1,Ni=6,ki=16,sn=32,Oo=1e-6,Mi=.01;function Se(i,t=we){let e=i.alpha_L??i.alpha_R??Ni;i.alpha_L??=e,i.alpha_R??=e;let n=i.mu_L??i.mu_R??ki;i.mu_L??=n,i.mu_R??=n,i.beta_L??=t/Math.max(i.alpha_L,Oo),i.beta_R??=t/Math.max(i.alpha_R,Oo)}function Ce(i,t,e,n=we){Se(i,n);let o=Math.pow(Math.max(e.T.toNumber(),Mi),.5);return{config:i,box:t,time:e,duration_L:o,duration_R:o,WL:t.anchor,WR:t.w-t.anchor,margin_L:o*i.alpha_L,margin_R:o*i.alpha_R}}function Ri(i,t=we){let e=new Map,n=0;for(let s of i)for(let r of s)e.has(r.time.track)||e.set(r.time.track,n++);let o=[];for(let s of i){if(s.length===0)continue;let r=Array(s.length);o.push(r);let c=0,a=0,l=n;for(let p of s){p.WL>c&&(c=p.WL),p.WR>a&&(a=p.WR);let f=e.get(p.time.track);if(r[f]){let d=r[f];p.time.T.compare(d.time.T)>0?(r[f]=p,r[l++]=d):r[l++]=p}else r[f]=p}let h=s[0].time.t;for(let p of e){let f=p[1];if(!r[f]){let d=Ce({anchor:0,alpha_L:c,alpha_R:a},{x:0,w:0,anchor:0},{t:h,T:new I(1),track:p[0]},t);d.fake=!0,r[f]=d}}}return{mat:o,rows:n}}function Oi(i,t,e,n){let o=n-e-i.WR-t.WL,s=i.margin_R+t.margin_L;if(o>=s)return{force:0,stiffness:0};let r=i.config.beta_R/i.duration_R,c=t.config.beta_L/t.duration_L,a=r*c/(r+c),l,h;if(o<0){let p=i.config.mu_R*t.config.mu_L/(i.config.mu_R+t.config.mu_L);l=a*s-p*o,h=p}else{let p=s-o;l=a*p,h=a}return{force:l,stiffness:h}}function Ii(i,t,e=sn){let n=t-i.WL,o=i.margin_L;if(n>=o)return{force:0,stiffness:0};let s=i.config.beta_L/i.duration_L;if(n>=0)return{force:s*(o-n),stiffness:s};let r=i.config.mu_L*e;return{force:i.config.alpha_L*i.config.beta_L-r*n,stiffness:r}}function Pi(i,t,e,n=sn){let o=e-(t+i.WR),s=i.margin_R;if(o>=s)return{force:0,stiffness:0};let r=i.config.beta_R/i.duration_R;if(o>=0)return{force:r*(s-o),stiffness:r};let c=i.config.mu_R*n;return{force:i.config.alpha_R*i.config.beta_R-c*o,stiffness:c}}function Fi(i){return{damping:i.damping??.6,maxIter:i.maxIter??100,eps:i.eps??.01,crossPunish:i.crossPunish??sn,globalC:i.globalC??we}}function Di(i,t,e,n,o){let{damping:s,maxIter:r,eps:c,crossPunish:a}=o,l=i.length,h=new Float64Array(t);for(let T=0;T<l;T++){let E=0,C=i[T];for(let _=0;_<t;_++){let P=h[_]+C[_].WL+C[_].margin_L;P>E&&(E=P)}for(let _=0;_<t;_++)h[_]=E+C[_].WR+C[_].margin_R;e[T]=E}let p=h.reduce((T,E)=>Math.max(T,E),0);if(p<=n)return!0;p=n/p;for(let T=0;T<l;T++)e[T]*=p;let f=new Float64Array(l),d=new Float32Array(t*(l+1));function u(T){f.fill(0);for(let E=0;E<t;E++){let C=E*(l+1),_=i[0][E],P=Ii(_,T[0],a);f[0]+=P.force,d[C]=P.stiffness;for(let Y=1;Y<l;Y++){let D=i[Y-1][E],$=i[Y][E],q=Oi(D,$,T[Y-1],T[Y]);f[Y-1]-=q.force,f[Y]+=q.force,d[C+Y]=q.stiffness}let j=i[l-1][E],X=Pi(j,T[l-1],n,a);f[l-1]-=X.force,d[C+l]=X.stiffness}return f}let g=new Float64Array(l);function y(T){g.fill(0);for(let C=0,_=0;C<t;C++,_+=l+1){g[0]+=d[_]*T[0];for(let P=1;P<l;P++){let j=d[_+P]*(T[P]-T[P-1]);g[P-1]-=j,g[P]+=j}g[l-1]+=d[_+l]*T[l-1]}let E=1e-4;for(let C=0;C<T.length;C++)g[C]+=E*T[C];return g}function x(T,E){let C=0;for(let _=0;_<T.length;_++)C+=T[_]*E[_];return C}let m=new Float64Array(l),b=new Float64Array(l),w=new Float64Array(l);function A(T,E=8){m.fill(0),b.set(T),w.set(b);let C=x(b,b);if(C<1e-12)return m;for(let _=0;_<E;_++){let P=y(w),j=x(w,P);if(Math.abs(j)<1e-12)break;let X=C/j;for(let $=0;$<l;$++)m[$]+=X*w[$],b[$]-=X*P[$];let Y=x(b,b);if(Math.sqrt(Y)<1e-6)break;let D=Y/C;for(let $=0;$<l;$++)w[$]=b[$]+D*w[$];C=Y}return m}let k=0,M=0;for(;k<r;k++){let T=u(e);M=0;for(let C=0;C<T.length;C++){let _=Math.abs(T[C]);_>M&&(M=_)}if(M<c)break;let E=A(T);for(let C=0;C<l;C++)e[C]+=s*E[C]}return!1}function Ht(i,t,e,n,o,s,r){if(e.length!==i.length||n.length!==Math.max(0,e.length-1))throw new Error("Horizontal region state does not match its columns");if(e.length===0||t===0)return;let c=n.some(d=>d!==0),a,l,h=i,p=e;if(c){a=new Uint32Array(e.length),l=new Float64Array(e.length),h=[];for(let d=0;d<e.length;){let u=d;for(;u<n.length&&n[u];)u++;let g=h.length;for(let y=d;y<=u;y++)a[y]=g,l[y]=e[y]-e[d];if(d===u)h.push(i[d]);else{let y=e[u]-e[d];h.push(Array.from({length:t},(x,m)=>{let b=i[d][m],w=i[u][m];return{config:{alpha_L:b.config.alpha_L,alpha_R:w.config.alpha_R,mu_L:b.config.mu_L,mu_R:w.config.mu_R,beta_L:b.config.beta_L,beta_R:w.config.beta_R},box:b.box,time:b.time,duration_L:b.duration_L,duration_R:w.duration_R,WL:b.WL,WR:y+w.WR,margin_L:b.margin_L,margin_R:w.margin_R,fake:b.fake&&w.fake}}))}d=u+1}p=new Float64Array(h.length)}let f=Di(h,t,p,o,s);if(n.fill(1),r!==void 0){let d=0,u=0;for(let y=0;y<t;y++)d=Math.max(d,h[0][y].WL),u=Math.max(u,h[h.length-1][y].WR);let g=p[p.length-1]+u-p[0]+d;if(!f||g>=o*r){let y=d-p[0],x=o-g;for(let m=0;m<p.length;m++)p[m]+=y+(p.length>1?x*m/(p.length-1):0)}}if(c)for(let d=0;d<e.length;d++)e[d]=p[a[d]]+l[d]}function rn(i,t,e={},n=[],o){let s=Fi(e),{mat:r,rows:c}=Ri(i,s.globalC),a=new Float64Array(r.length),l=new Uint8Array(Math.max(0,r.length-1)),h=n.length>1?[...n].sort((p,f)=>p.end-p.start-(f.end-f.start)):n;for(let{start:p,end:f,hook:d}of h){if(p<0||f<p||f>=r.length)throw new Error("Horizontal layout registration references invalid columns");d({columns:r,rows:c,start:p,end:f,X:a,fixed:l,options:s})}Ht(r,c,a,l,t,s,o);for(let p=0;p<r.length;p++)for(let f of r[p])f.box.x=a[p]-f.box.anchor;return r}var Wt=class extends Error{line;requiredHeight;availableHeight;constructor(t,e,n){super(`Page cannot fit layout line ${t}: requires ${e}px, available ${n}px`),this.name="PageLayoutError",this.line=t,this.requiredHeight=e,this.availableHeight=n}},ot={width:794,height:1/0,marginTop:45,marginBottom:48,marginLeft:40,marginRight:40,lineGap:22,fillRatio:.5};function se(i={}){let t=i.height??ot.height,e={width:i.width??ot.width,height:t<=0?1/0:t,marginTop:Math.max(0,i.marginTop??ot.marginTop),marginBottom:Math.max(0,i.marginBottom??ot.marginBottom),marginLeft:Math.max(0,i.marginLeft??ot.marginLeft),marginRight:Math.max(0,i.marginRight??ot.marginRight),lineGap:Math.max(0,i.lineGap??ot.lineGap),fillRatio:i.fillRatio??ot.fillRatio};if(!Number.isFinite(e.width)||e.width<=0)throw new Error(`Page width must be a positive finite number, got ${e.width}`);if(e.height!==1/0&&(!Number.isFinite(e.height)||e.height<=0))throw new Error(`Page height must be positive or Infinity, got ${e.height}`);if([e.marginTop,e.marginBottom,e.marginLeft,e.marginRight,e.lineGap].some(r=>!Number.isFinite(r)||r<0))throw new Error("Page margins and line gap must be finite non-negative numbers");let o=e.width-e.marginLeft-e.marginRight;if(o<=0)throw new Error(`Page horizontal margins leave no content width: ${o}px`);let 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 cn(i,t){let e=t.height-t.marginTop-t.marginBottom,n=[],o=new Array(i.length).fill(0),s=0,r=0,c=0,a=0,l=(h,p)=>{let f=h-r,d=p?Math.max(0,e-a-t.lineGap*(f-1)):0,u=t.lineGap+d/f,g=s+t.marginTop;for(let x=r;x<h;x++)o[x]=g,g+=i[x]+(x+1<h?u:0);let y=Number.isFinite(t.height)?t.height:g-s+t.marginBottom;n.push({bounds:{x:0,y:s,w:t.width,h:y},lineStart:r,lineEnd:h}),s+=y,r=h,c=0,a=0};for(let h=0;h<i.length;h++){let p=i[h];if(Number.isFinite(t.height)&&p>e+1e-6)throw new Wt(h,p,e);Number.isFinite(t.height)&&h>r&&c+t.lineGap+p>e+1e-6&&l(h,!0),c+=(h>r?t.lineGap:0)+p,a+=p}return i.length>r&&l(i.length,!1),{pages:n,lineTops:o}}var Io={start:0,end:-1,wholeLine:!1};function an(i){let t=new Set,e=n=>{t.add(n);for(let o of n.groups)for(let s of o.members)e(s)};return e(i),n=>{for(let o=n;o;o=o.parent)if(t.has(o))return o;return n}}function Po(i,t){for(let e=t;e;){let n=i.columnOf(e);if(n>=0)return n;let o=e instanceof W?e.foldedInto:void 0;e=o&&F(o)?o:void 0}return-1}function ln(i,t,e,n){if(!t)return{start:0,end:i.columns.length-1,wholeLine:!0};if(typeof t[0]=="number")return{start:Math.max(0,t[0]),end:Math.min(i.columns.length-1,t[1]),wholeLine:!1};let[o,s]=t;if(o.layoutLine>s.layoutLine&&([o,s]=[s,o]),i.index<o.layoutLine||i.index>s.layoutLine)return Io;let r=e&&n(e);if(r&&(n(o.track)!==r||n(s.track)!==r))throw new Error("Range endpoints must belong to the selected track");let c=o.layoutLine<i.index?0:Po(i,o),a=s.layoutLine>i.index?i.columns.length-1:Po(i,s);return c<0||a<0?Io:{start:Math.min(c,a),end:Math.max(c,a),wholeLine:!1}}function hn(i,t,e,n){if(!i)return[];let{start:o,end:s}=ln(i,t,e,n),r=i.columns.slice(o,s+1);if(!e)return r;let c=n(e),a=l=>l.track===c;return r.every(l=>l.every(a))?r:r.map(l=>l.filter(a))}var Do=.75;function Ae(i,t){let e=1/0,n=1/0,o=-1/0,s=-1/0;for(let r of t)e=Math.min(e,r.x),n=Math.min(n,r.y),o=Math.max(o,r.x+r.w),s=Math.max(s,r.y+r.h);return Number.isFinite(e)?(i.x=e,i.y=n,i.w=o-e,i.h=s-n,!0):(i.x=i.y=i.w=i.h=0,!1)}function re(i,t){i.springConfig??={},i.decorations=[],i.ports={},i.box.x=i.box.y=0,i.prepareLayout(t);for(let[e,n]of Object.entries(i.addon??{})){let o=t.decorationHandlers.get(e);if(!o)continue;let s=o(i,n,t);s&&i.decorations.push(s)}$i(i),i.finalizeLayout?.(t)}function fn(i,t,e={}){let n=i.attachments.filter(Tt),o=se(i.page),s=o.width-o.marginLeft-o.marginRight,r=o.marginLeft,c=an(i.rootTrack),a=new Map(n.map((C,_)=>[C,_])),l=Hi(n),h=new Map,p=C=>{let _=h.get(C);return _&&Fo(_).box};t={...t,layoutSubdomain(C,_,P,j){let X=$o(_,t),Y=new Set(_.flat()),D=Q=>{for(let tt=Q;tt&&tt!==C;tt=tt.foldedInto)if(Y.has(tt))return!0;return!1},$=j.filter(Tt).filter(Q=>!Q.endPoints?.length);for(let Q of l.get(C)??[])!h.has(Q)&&Q.endPoints.every(D)&&$.push(Q);$.sort((Q,tt)=>a.get(Q)-a.get(tt));let q=zi(_,X,P,$,t,p);return $.forEach((Q,tt)=>h.set(Q,q.items[tt])),{width:X.width,height:q.height,positions:q.positions}}};let f=Bi(i),d=[];for(let C of f)for(let _ of C.columns)for(let P of _)d.push(P),re(P,t);let u=n.filter(C=>!h.has(C)),g=f.map((C,_)=>un(C.columns,_,e)),y=g.map(C=>C.view);for(let C of u)C.prepareHorizontal?.(y,t);for(let C of g){C.layout(s,o.fillRatio);for(let _ of C.view.columns)for(let P of _)P.box.x+=r}for(let C of d){let _=f[C.layoutLine],P=-C.box.visualAxis;Le(_.hostExtents,C.track,P,P+C.box.h)}let x=Gi(f.length,d,e.rowGap),m=()=>{let C=[],_=f.map((D,$)=>{let q=Bo(D,i.rootTrack,x[$]);return C.push(q.height),q.axes}),P,j;try{({pages:P,lineTops:j}=cn(C,o))}catch(D){if(!(D instanceof Wt))throw D;let $=f[D.line],q=1/0,Q=-1/0;for(let tt of $?.columns??[])for(let St of tt)q=Math.min(q,St.ast.sourceSpan.start),Q=Math.max(Q,St.ast.sourceSpan.end);throw Number.isFinite(q)?N.error.PageOverflow(D.requiredHeight,D.availableHeight,{start:q,end:Q}):D}let X=(D,$)=>(j[D]??0)+(_[D]?.get($)??0);for(let D of d)D.box.y=X(D.layoutLine,D.track)-D.box.visualAxis,D.onPlaced?.();let Y={...t,width:s,originX:r,pages:P.map(D=>D.bounds),lines:y,getVisualAxis:(D,$)=>X(D,c($)),getHostExtent:(D,$)=>f[D]?.hostExtents.get(c($)),getRangeColumns:(D,$,q)=>hn(y[D],$,q,c)};return{pages:P,attachmentContext:Y}},b=m(),w=pn(u,b.attachmentContext,f,c,p);w.needsRelayout&&(b=m(),w=pn(u,b.attachmentContext,f,c,p));let A=b.pages,k=0,M=n.map(C=>{let _=h.get(C),{geometry:P,box:j}=_?Fo(_):w.items[k++];return{box:j,regions:P.regions,layer:C.layer,sourceSpan:C.sourceSpan,paint(X){P.paint(X)}}}),T={x:0,y:0,w:0,h:0};function*E(){for(let C of A)yield C.bounds;for(let C of d)yield C.box;for(let C of M)yield C.box}return Ae(T,E()),{diagnostics:i.diagnostics,objects:d,attachments:M,bounds:T,lineCount:f.length,pages:A}}function $i(i){let t=i.decorations.map(n=>n.below).filter(n=>n!==void 0).sort((n,o)=>n.order-o.order);if(t.length===0)return;let e=i.box.h;for(let n of t)e+=n.gap??0,n.place?.(e),e+=Math.max(0,n.height??0);i.box.h=e}function Bi(i){let t=()=>({columns:[],hostExtents:new Map,attachmentExtents:new Map}),e=[],n=t();for(let o of i.columns){let s=[];for(;e.length<o[0].layoutLine;)e.push(n),n=t();for(let r of o)F(r)&&s.push(r);s.length&&n.columns.push(s)}return(n.columns.length>0||e.length===0)&&e.push(n),e}function ie(i,t,e){i.top=Math.min(i.top,t),i.bottom=Math.max(i.bottom,e)}function Le(i,t,e,n){let o=i.get(t);o?ie(o,e,n):i.set(t,{top:e,bottom:n})}function un(i,t,e={},n=!1){let o=[],s=new Map,r=new Map;for(let a=0;a<i.length;a++)for(let l of i[a]){s.set(l,a),Se(l.springConfig,e.globalC);let h=r.get(l.track);h?h.push(l):r.set(l.track,[l])}let c={index:t,columns:i,trackRuns:r,columnOf:a=>s.get(a)??-1,registerHorizontalLayoutHook(a,l,h){let p=s.get(a),f=s.get(l);p===void 0||f===void 0||o.push({start:Math.min(p,f),end:Math.max(p,f),hook:h})}};for(let a of i)for(let l of a)l.prepareHorizontal?.(c);return{view:c,layout(a,l){let h=i.map(p=>p.map(f=>{let d=Ce(f.springConfig,f.box,f,e.globalC);return n&&(d.margin_L=d.margin_R=0),d}));return rn(h,a,e,o,l),h}}}function Gt(i,t){return i.length===0?0:$o(i.map(e=>[e]),t).width}function $o(i,t){for(let s of i)for(let r of s)re(r,t);let e=un(i,i[0][0].layoutLine,{},!0),n=1/0,o=-1/0;for(let s of e.layout(1/0))for(let r of s){let c=r.box.x+r.box.anchor;n=Math.min(n,c-r.WL),o=Math.max(o,c+r.WR)}for(let s of i)for(let r of s)r.box.x-=n;return{width:o-n,view:e.view}}function zi(i,{width:t,view:e},n,o,s,r){let c=i.flat(),a={hostExtents:new Map,attachmentExtents:new Map},l=0;for(let w of c){let A=-w.box.visualAxis;Le(a.hostExtents,w.track,A,A+w.box.h),l=Math.max(l,w.ast.size*Do)}let h=c.map(w=>({x:w.box.x,y:0})),p=()=>{let w=Bo(a,n,l);return c.forEach((A,k)=>{A.box.y=h[k].y=w.axes.get(A.track)-A.box.visualAxis,A.onPlaced?.()}),w},f=p();if(o.length===0)return{height:f.height,positions:h,items:[]};let d=an(n),u=[],g=[];u[e.index]=a,g[e.index]=e;let y=()=>pn(o,{...s,width:t,originX:0,pages:[],lines:g,getVisualAxis:(w,A)=>f.axes.get(d(A))??0,getHostExtent:(w,A)=>u[w]?.hostExtents.get(d(A)),getRangeColumns:(w,A,k)=>hn(g[w],A,k,d)},u,d,r),x=y();x.needsRelayout&&(f=p(),x=y());let m=c[0],b=x.items.map(w=>({...w,reference:m,x:m.box.x,y:m.box.y}));return{height:f.height,positions:h,items:b}}function Hi(i){let t=new Map;for(let e of i){let[n,...o]=e.endPoints??[];for(let s=n?.foldedInto;s;s=s.foldedInto){let r=s;if(!o.every(a=>Wi(r,a)))continue;let c=t.get(s);c?c.push(e):t.set(s,[e])}}return t}function Wi(i,t){for(let e=t.foldedInto;e;e=e.foldedInto)if(e===i)return!0;return!1}function Fo(i){let t=i.reference.box.x-i.x,e=i.reference.box.y-i.y;if(t===0&&e===0)return i;let n=s=>({...s,x:s.x+t,y:s.y+e}),{geometry:o}=i;return{box:n(i.box),geometry:{regions:o.regions.map(n),paint:s=>o.paint(new zt(s,t,e))}}}function Gi(i,t,e){if(e!==void 0)return new Array(i).fill(e);let n=new Array(i).fill(0),o=0;for(let s of t){let r=s.ast.size*Do;r>n[s.layoutLine]&&(n[s.layoutLine]=r),r>o&&(o=r)}for(let s=0;s<i;s++)n[s]||=o;return n}function pn(i,t,e,n,o){let s=new Map,r=new Set(i),c=[],a=!1;function l(f,d,u){let g=t.lines[f],y=u===void 0?new Map:void 0,x;if(!g)return y;let m=(E,C,_)=>{y?Le(y,E,C,_):x?ie(x,C,_):x={top:C,bottom:_}},{start:b,end:w,wholeLine:A}=ln(g,d,u,n),k=u&&n(u),M=A?t.originX:1/0,T=A?t.originX+t.width:-1/0;for(let E=b;E<=w;E++)for(let C of g.columns[E]){if(k&&C.track!==k)continue;A||(C.box.x<M&&(M=C.box.x),C.box.x+C.box.w>T&&(T=C.box.x+C.box.w));let _=C.box.y-t.getVisualAxis(f,C.track);m(C.track,_,_+C.box.h)}for(let E of c[f]??[])k&&E.track!==k||E.right<=M||E.left>=T||m(E.track,E.top,E.bottom);return y??x}let h={...t,getRangeExtents:l,getAttachmentBox(f){let d=s.get(f)??o(f);if(!d)throw new Error("Layout attachment dependency has not been measured");return d},getContentBounds(f){let d=[];for(let g of f.nodes)F(g)&&(g.box.w>0||g.box.h>0)&&d.push(g.box);for(let g of f.attachments){if(!Tt(g)||!r.has(g)&&!o(g))continue;let y=h.getAttachmentBox(g);(y.w>0||y.h>0)&&d.push(y)}let u={x:0,y:0,w:0,h:0};return Ae(u,d)?u:void 0}};return{items:i.map(f=>{let d=f.createGeometry(h),u={x:0,y:0,w:0,h:0};Ae(u,d.regions);let g={geometry:d,box:u};s.set(f,u);for(let y of d.occupancy??d.regions){if(y.line===void 0)continue;let x=e[y.line],m=n(y.track),b=y.y-t.getVisualAxis(y.line,m),w=b+y.h,A=x.hostExtents.get(m),k=x.attachmentExtents.get(m);(b<Math.min(A?.top??1/0,k?.top??1/0)||w>Math.max(A?.bottom??-1/0,k?.bottom??-1/0))&&(a=!0),Le(x.attachmentExtents,m,b,w),(c[y.line]??=[]).push({track:m,left:y.x,right:y.x+y.w,top:b,bottom:w})}return g}),needsRelayout:a}}function Bo(i,t,e){let n=new Map,o=a=>{let l=i.hostExtents.get(a),h=i.attachmentExtents.get(a),p=l?{top:l.top,bottom:l.bottom}:null;h&&(p?ie(p,h.top,h.bottom):p={top:h.top,bottom:h.bottom});let f=[];for(let u of a.groups){let g=u.members.map(o);if(g.every(m=>m===null))continue;let y=u.measure(g,e),x=null;for(let m of y){if(!m)continue;let b=m.offset+m.extent.top,w=m.offset+m.extent.bottom;x?ie(x,b,w):x={top:b,bottom:w}}x&&f.push({group:u,placements:y,extent:x})}let d=(u,g)=>{p??={top:0,bottom:0};for(let y=0;y<u.group.members.length;y++){let x=u.placements[y];x&&n.set(u.group.members[y],g+x.offset)}ie(p,g+u.extent.top,g+u.extent.bottom)};for(let u of f)u.group.place||d(u,0);for(let u of f){let g=u.group.place;if(!g)continue;d(u,g(p??{top:0,bottom:0},u.extent,e))}return p},s=o(t),r=new Map;if(!s)return{axes:r,height:0};let c=(a,l)=>{r.set(a,l);for(let h of a.groups)for(let p of h.members){let f=n.get(p);f!==void 0&&c(p,l+f)}};return c(t,-s.top),{axes:r,height:s.bottom-s.top}}var Te=class{min=1/0;max=-1/0;add(t){t<this.min&&(this.min=t),t>this.max&&(this.max=t)}};function dn(i,t,e,n,o,s){if(!(i>0&&i<1))return;let r=1-i;s.add(r*r*r*t+3*r*r*i*e+3*r*i*i*n+i*i*i*o)}function zo(i,t,e,n,o){o.add(i),o.add(n);let s=-i+3*t-3*e+n,r=2*(i-2*t+e),c=t-i;if(Math.abs(s)<1e-12){Math.abs(r)>1e-12&&dn(-c/r,i,t,e,n,o);return}let a=r*r-4*s*c;if(a<0)return;let l=Math.sqrt(a);dn((-r+l)/(2*s),i,t,e,n,o),dn((-r-l)/(2*s),i,t,e,n,o)}function Ho(i,t,e,n){n.add(i),n.add(e);let o=i-2*t+e;if(Math.abs(o)<1e-12)return;let s=(i-t)/o;if(!(s>0&&s<1))return;let r=1-s;n.add(r*r*i+2*r*s*t+s*s*e)}function Vt(i){let t=new Te,e=new Te,n=0,o=0,s=0,r=0;for(let c of i){if(c.op==="Z"){n=s,o=r;continue}c.op==="C"?(zo(n,c.cx1,c.cx2,c.x,t),zo(o,c.cy1,c.cy2,c.y,e)):c.op==="Q"?(Ho(n,c.cx,c.x,t),Ho(o,c.cy,c.y,e)):(t.add(c.x),e.add(c.y),c.op==="M"&&(s=c.x,r=c.y)),n=c.x,o=c.y}return Number.isFinite(t.min)?{x:t.min,y:e.min,w:t.max-t.min,h:e.max-e.min}:{x:0,y:0,w:0,h:0}}var Vi=54.2813,Wo=87.37505,Ee=72.8125,Vo=93.6719,Yi=-27.4688,Yo=-7.9375,Ki=Yo+Vo,Ui=[{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}],ji=[{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 Go(i,t,e,n,o,s,r,c){let a=h=>o+(c?e-h:h)*r,l=h=>s+(c?n-h:h)*r;for(let h of t)h.op==="Z"?i.push(h):h.op==="C"?i.push({op:"C",cx1:a(h.cx1),cy1:l(h.cy1),cx2:a(h.cx2),cy2:l(h.cy2),x:a(h.x),y:l(h.y)}):h.op==="Q"?i.push({op:"Q",cx:a(h.cx),cy:l(h.cy),x:a(h.x),y:l(h.y)}):i.push({op:h.op,x:a(h.x),y:l(h.y)})}function Ko(i,t,e){let n=e==="up"||e==="down",o=Math.max(1,Math.round(i/(t*.3))),s=n?Math.max(0,o-1):o,r=n?Ki+Ee*s:Wo+Ee*(s-1),c=i/r,a=[];for(let p=0;p<s;p++)Go(a,Ui,Vi,Wo,0,p*Ee*c,c,e==="");n&&Go(a,ji,113.5313,Vo,Yi*c,(s*Ee+Yo)*c,c,!1);let l=Vt(a);return e!=="up"?{commands:a,bounds:l}:{commands:a.map(p=>p.op==="Z"?p:p.op==="C"?{op:"C",cx1:l.x+l.w-(p.cx1-l.x),cy1:i-p.cy1,cx2:l.x+l.w-(p.cx2-l.x),cy2:i-p.cy2,x:l.x+l.w-(p.x-l.x),y:i-p.y}:p.op==="Q"?{op:"Q",cx:l.x+l.w-(p.cx-l.x),cy:i-p.cy,x:l.x+l.w-(p.x-l.x),y:i-p.y}:{op:p.op,x:l.x+l.w-(p.x-l.x),y:i-p.y}),bounds:{x:l.x,y:i-l.y-l.h,w:l.w,h:l.h}}}function Xi(i){let t=i,e=i.ast;return(e.callName==="up"||e.callName==="down")&&Array.isArray(t.members)&&Array.isArray(e.contents)?t:null}var xn=class extends v{static def={name:["arp","arpeggio"],description:"\u7436\u97F3",details:`~~~jpfun
|
|
6
|
+
\u4F4D\u7F6E\u504F\u79FB\u5728\u6392\u7248\u540E\u5E94\u7528\uFF0C\u76F8\u90BB\u5BF9\u8C61\u4FDD\u6301\u539F\u4F4D\uFF1B\u5360\u4F4D\u8C03\u6574\u5728\u6392\u7248\u524D\u5E94\u7528\u3002\u53EA\u5305\u88F9\u5173\u7CFB\u5BF9\u8C61\u65F6\uFF0C\u5E73\u79FB\u4F5C\u7528\u4E8E\u8BE5\u5173\u7CFB\u5BF9\u8C61\u672C\u8EAB\u3002`,allowExtraArgs:!1,args:[{type:"content",description:"\u8981\u5FAE\u8C03\u7684\u5185\u5BB9\u6216\u5173\u7CFB\u5BF9\u8C61",default:null},{name:"dx",description:"\u6392\u7248\u540E\u7684\u6C34\u5E73\u504F\u79FB\uFF0C\u6B63\u503C\u5411\u53F3\uFF0C\u4E0D\u6539\u53D8\u5360\u4F4D",type:"length",default:{value:0,unit:"px"}},{name:"dy",description:"\u6392\u7248\u540E\u7684\u5782\u76F4\u504F\u79FB\uFF0C\u6B63\u503C\u5411\u4E0B\uFF0C\u4E0D\u6539\u53D8\u5360\u4F4D",type:"length",default:{value:0,unit:"px"}},{name:"dw",description:"\u589E\u51CF\u6C34\u5E73\u5360\u4F4D\uFF0C\u6309\u539F\u5DE6\u53F3\u6BD4\u4F8B\u5206\u914D\uFF0C\u6700\u7EC8\u5BBD\u5EA6\u4E0D\u5C0F\u4E8E 0",type:"length",default:{value:0,unit:"px"}},{name:"dh",description:"\u589E\u51CF\u4E0B\u65B9\u5360\u4F4D\uFF0C\u6700\u7EC8\u9AD8\u5EA6\u4E0D\u5C0F\u4E8E 0",type:"length",default:{value:0,unit:"px"}}]};target;dx;dy;dw;dh;get children(){return[this.target]}timeFlowModel(){return{children:[this.target],mode:"sequence"}}loweringEnter(t){let e={temporal:0,attachment:0},n={targets:e,onTemporal:o=>{I(o)&&(e.temporal++,pr(o,this))},onAttachment:o=>{yt(o)&&(e.attachment++,fr(o,e,this.dx,this.dy))}};return t.beginLoweringGroup(this,n),[]}loweringExit(t){let e=t.endLoweringGroup(this);return e.targets.temporal===0&&e.targets.attachment===0&&t.diagnostics.push(new P("W_ADJUST_NO_TARGET","@adjust \u6CA1\u6709\u627E\u5230\u53EF\u8C03\u6574\u7684\u5BF9\u8C61",this.sourceSpan)),[]}constructor(t,e,n,o=null){super(t,o);let[s,i,c,a,l]=this.getArgValue(e,n);s.parent=this,this.target=s,this.dx=n.length2px(i),this.dy=n.length2px(c),this.dw=n.length2px(a),this.dh=n.length2px(l)}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=yn;function pr(r,t){let{dx:e,dy:n,dw:o,dh:s}=t;if(e===0&&n===0&&o===0&&s===0)return;(e!==0||n!==0)&&(r.placementOffset={x:(r.placementOffset?.x??0)+e,y:(r.placementOffset?.y??0)+n});let i,c,a=r.finalizeLayout,l=r.onPlaced;r.finalizeLayout=h=>{a?.call(r,h);let p=Math.max(0,r.box.w+o);r.box.anchor=r.box.w>0?r.box.anchor*p/r.box.w:0,r.box.w=p,r.box.h=Math.max(0,r.box.h+s)},r.onPlaced=()=>{r.box.x!==i&&(r.box.x+=e),r.box.y!==c&&(r.box.y+=n),l?.call(r),i=r.box.x,c=r.box.y}}function fr(r,t,e,n){if(t.temporal>0||e===0&&n===0)return;r.placementOffset={x:(r.placementOffset?.x??0)+e,y:(r.placementOffset?.y??0)+n};let o=r.createGeometry;r.createGeometry=s=>{let i=o.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+n,w:a.w,h:a.h}:{x:a.x+e,y:a.y+n,w:a.w,h:a.h,line:a.line,track:a.track};return{regions:i.regions.map(c),occupancy:i.occupancy?.map(c),paint(a){i.paint(new Ut(a,e,n))}}}}var Ie=1,ur=6,dr=16,gn=32,hs=1e-6,xr=.01;function Oe(r,t=Ie){let e=r.alpha_L??r.alpha_R??ur;r.alpha_L??=e,r.alpha_R??=e;let n=r.mu_L??r.mu_R??dr;r.mu_L??=n,r.mu_R??=n,r.beta_L??=t/Math.max(r.alpha_L,hs),r.beta_R??=t/Math.max(r.alpha_R,hs)}function Pe(r,t,e,n=Ie){Oe(r,n);let o=Math.pow(Math.max(e.T.toNumber(),xr),.5);return{config:r,box:t,time:e,duration_L:o,duration_R:o,WL:t.anchor,WR:t.w-t.anchor,margin_L:o*r.alpha_L,margin_R:o*r.alpha_R}}function mr(r,t=Ie){let e=new Map,n=0;for(let s of r)for(let i of s)e.has(i.time.track)||e.set(i.time.track,n++);let o=[];for(let s of r){if(s.length===0)continue;let i=Array(s.length);o.push(i);let c=0,a=0,l=n;for(let p of s){p.WL>c&&(c=p.WL),p.WR>a&&(a=p.WR);let f=e.get(p.time.track);if(i[f]){let d=i[f];p.time.T.compare(d.time.T)>0?(i[f]=p,i[l++]=d):i[l++]=p}else i[f]=p}let h=s[0].time.t;for(let p of e){let f=p[1];if(!i[f]){let d=Pe({alpha_L:c,alpha_R:a},{x:0,w:0,anchor:0},{t:h,T:new B(1),track:p[0]},t);d.fake=!0,i[f]=d}}}return{mat:o,rows:n}}function yr(r,t,e,n){let o=n-e-r.WR-t.WL,s=r.margin_R+t.margin_L;if(o>=s)return{force:0,stiffness:0};let i=r.config.beta_R/r.duration_R,c=t.config.beta_L/t.duration_L,a=i*c/(i+c),l,h;if(o<0){let p=r.config.mu_R*t.config.mu_L/(r.config.mu_R+t.config.mu_L);l=a*s-p*o,h=p}else{let p=s-o;l=a*p,h=a}return{force:l,stiffness:h}}function gr(r,t,e=gn){let n=t-r.WL,o=r.margin_L;if(n>=o)return{force:0,stiffness:0};let s=r.config.beta_L/r.duration_L;if(n>=0)return{force:s*(o-n),stiffness:s};let i=r.config.mu_L*e;return{force:r.config.alpha_L*r.config.beta_L-i*n,stiffness:i}}function br(r,t,e,n=gn){let o=e-(t+r.WR),s=r.margin_R;if(o>=s)return{force:0,stiffness:0};let i=r.config.beta_R/r.duration_R;if(o>=0)return{force:i*(s-o),stiffness:i};let c=r.config.mu_R*n;return{force:r.config.alpha_R*r.config.beta_R-c*o,stiffness:c}}function wr(r){return{damping:r.damping??.6,maxIter:r.maxIter??100,eps:r.eps??.01,crossPunish:r.crossPunish??gn,globalC:r.globalC??Ie}}function Sr(r,t,e,n,o){let{damping:s,maxIter:i,eps:c,crossPunish:a}=o,l=r.length,h=new Float64Array(t);for(let S=0;S<l;S++){let C=0,E=r[S];for(let k=0;k<t;k++){let N=h[k]+E[k].WL+E[k].margin_L;N>C&&(C=N)}for(let k=0;k<t;k++)h[k]=C+E[k].WR+E[k].margin_R;e[S]=C}let p=h.reduce((S,C)=>Math.max(S,C),0);if(p<=n)return!0;p=n/p;for(let S=0;S<l;S++)e[S]*=p;let f=new Float64Array(l),d=new Float64Array(l+1);function u(S){f.fill(0),d.fill(0);for(let C=0;C<t;C++){let E=r[0][C],k=gr(E,S[0],a);f[0]+=k.force,d[0]+=k.stiffness;for(let _=1;_<l;_++){let D=r[_-1][C],A=r[_][C],O=yr(D,A,S[_-1],S[_]);f[_-1]-=O.force,f[_]+=O.force,d[_]+=O.stiffness}let N=r[l-1][C],v=br(N,S[l-1],n,a);f[l-1]-=v.force,d[l]+=v.stiffness}return f}let m=new Float64Array(l),x=new Float64Array(l);function y(){for(let C=0;C<l;C++){let E=C===0?0:d[C]/m[C-1],k=d[C]+d[C+1]+1e-4-E*d[C];if(!(k>0)||!Number.isFinite(k))throw new Error("Horizontal spring stiffness must produce a finite positive definite system");m[C]=k,x[C]=f[C]+(C===0?0:E*x[C-1])}x[l-1]/=m[l-1];for(let C=l-2;C>=0;C--)x[C]=(x[C]+d[C+1]*x[C+1])/m[C];return x}let g=0,b=0;for(;g<i;g++){let S=u(e);b=0;for(let E=0;E<S.length;E++){let k=Math.abs(S[E]);k>b&&(b=k)}if(b<c)break;let C=y();for(let E=0;E<l;E++)e[E]+=s*C[E]}return!1}function jt(r,t,e,n,o,s,i){if(e.length!==r.length||n.length!==Math.max(0,e.length-1))throw new Error("Horizontal region state does not match its columns");if(e.length===0||t===0)return;let c=n.some(d=>d!==0),a,l,h=r,p=e;if(c){a=new Uint32Array(e.length),l=new Float64Array(e.length),h=[];for(let d=0;d<e.length;){let u=d;for(;u<n.length&&n[u];)u++;let m=h.length;for(let x=d;x<=u;x++)a[x]=m,l[x]=e[x]-e[d];if(d===u)h.push(r[d]);else{let x=e[u]-e[d];h.push(Array.from({length:t},(y,g)=>{let b=r[d][g],S=r[u][g];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:x+S.WR,margin_L:b.margin_L,margin_R:S.margin_R,fake:b.fake&&S.fake}}))}d=u+1}p=new Float64Array(h.length)}let f=Sr(h,t,p,o,s);if(n.fill(1),i!==void 0){let d=0,u=0;for(let x=0;x<t;x++)d=Math.max(d,h[0][x].WL),u=Math.max(u,h[h.length-1][x].WR);let m=p[p.length-1]+u-p[0]+d;if(!f||m>=o*i){let x=d-p[0],y=o-m;for(let g=0;g<p.length;g++)p[g]+=x+(p.length>1?y*g/(p.length-1):0)}}if(c)for(let d=0;d<e.length;d++)e[d]=p[a[d]]+l[d]}function bn(r,t,e={},n=[],o){let s=wr(e),{mat:i,rows:c}=mr(r,s.globalC),a=new Float64Array(i.length),l=new Uint8Array(Math.max(0,i.length-1)),h=n.length>1?[...n].sort((p,f)=>p.end-p.start-(f.end-f.start)):n;for(let{start:p,end:f,hook:d}of h){if(p<0||f<p||f>=i.length)throw new Error("Horizontal layout registration references invalid columns");d({columns:i,rows:c,start:p,end:f,X:a,fixed:l,options:s})}jt(i,c,a,l,t,s,o);for(let p=0;p<i.length;p++)for(let f of i[p])f.box.x=a[p]-f.box.anchor;return i}var Xt=class extends Error{line;requiredHeight;availableHeight;constructor(t,e,n){super(`Page cannot fit layout line ${t}: requires ${e}px, available ${n}px`),this.line=t,this.requiredHeight=e,this.availableHeight=n,this.name="PageLayoutError"}},ct={width:794,height:1/0,marginTop:45,marginBottom:48,marginLeft:40,marginRight:40,lineGap:22,fillRatio:.5};function ue(r={}){let t=r.height??ct.height,e={width:r.width??ct.width,height:t<=0?1/0:t,marginTop:Math.max(0,r.marginTop??ct.marginTop),marginBottom:Math.max(0,r.marginBottom??ct.marginBottom),marginLeft:Math.max(0,r.marginLeft??ct.marginLeft),marginRight:Math.max(0,r.marginRight??ct.marginRight),lineGap:Math.max(0,r.lineGap??ct.lineGap),fillRatio:r.fillRatio??ct.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 o=e.width-e.marginLeft-e.marginRight;if(o<=0)throw new Error(`Page horizontal margins leave no content width: ${o}px`);let s=e.height-e.marginTop-e.marginBottom;if(Number.isFinite(e.height)&&s<=0)throw new Error(`Page vertical margins leave no content height: ${s}px`);return e}function wn(r,t,e=[]){let n=t.height-t.marginTop-t.marginBottom,o=[],s=new Array(r.length).fill(0),i=0,c=0,a=0,l=0,h=(p,f)=>{let d=p-c,u=f?Math.max(0,n-l-t.lineGap*(d-1)):0,m=t.lineGap+u/d,x=i+t.marginTop;for(let g=c;g<p;g++)s[g]=x,x+=r[g]+(g+1<p?m:0);let y=Number.isFinite(t.height)?t.height:x-i+t.marginBottom;o.push({bounds:{x:0,y:i,w:t.width,h:y},lineStart:c,lineEnd:p}),i+=y,c=p,a=0,l=0};for(let p=0;p<r.length;p++){let f=r[p];if(Number.isFinite(t.height)&&f>n+1e-6)throw new Xt(p,f,n);p>c&&(e[p]!==void 0||Number.isFinite(t.height)&&a+t.lineGap+f>n+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:o,lineTops:s}}var ps={start:0,end:-1,wholeLine:!1};function Sn(r){let t=new Set,e=n=>{t.add(n);for(let o of n.groups)for(let s of o.members)e(s)};return e(r),n=>{for(let o=n;o;o=o.parent)if(t.has(o))return o;return n}}function fs(r,t){for(let e=t;e;){let n=r.columnOf(e);if(n>=0)return n;let o=e instanceof $?e.foldedInto:void 0;e=o&&I(o)?o:void 0}return-1}function Cn(r,t,e,n){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[o,s]=t;if(o.layoutLine>s.layoutLine&&([o,s]=[s,o]),r.index<o.layoutLine||r.index>s.layoutLine)return ps;let i=e&&n(e);if(i&&(n(o.track)!==i||n(s.track)!==i))throw new Error("Range endpoints must belong to the selected track");let c=o.layoutLine<r.index?0:fs(r,o),a=s.layoutLine>r.index?r.columns.length-1:fs(r,s);return c<0||a<0?ps:{start:Math.min(c,a),end:Math.max(c,a),wholeLine:!1}}function An(r,t,e,n){if(!r)return[];let{start:o,end:s}=Cn(r,t,e,n),i=r.columns.slice(o,s+1);if(!e)return i;let c=n(e),a=l=>l.track===c;return i.every(l=>l.every(a))?i:i.map(l=>l.filter(a))}var ds=.75,xe=new WeakMap;function ot(r,t=!1){let{box:e}=r,n=xe.get(r);if(!n)return e;let o=t?n.contentTop:n.top,s=t?0:n.bottom;return{x:e.x,y:e.y+o,w:e.w,h:e.h-o+s}}function Zt(r,t){let e=1/0,n=1/0,o=-1/0,s=-1/0;for(let i of t)e=Math.min(e,i.x),n=Math.min(n,i.y),o=Math.max(o,i.x+i.w),s=Math.max(s,i.y+i.h);return Number.isFinite(e)?(r.x=e,r.y=n,r.w=o-e,r.h=s-n,!0):(r.x=r.y=r.w=r.h=0,!1)}function me(r,t){if(r.springConfig??={},r.decorations&&xe.delete(r),r.decorations=[],r.ports={},r.box.x=r.box.y=0,r.prepareLayout(t),r.addon)for(let[e,n]of Object.entries(r.addon)){let o=t.decorationHandlers.get(e);if(!o)continue;let s=o(r,n,t);s&&r.decorations.push(s)}Cr(r),r.finalizeLayout?.(t)}function _n(r,t,e={}){let n=r.attachments.filter(yt),o=ue(r.page),s=o.width-o.marginLeft-o.marginRight,i=o.marginLeft,c=Sn(r.rootTrack),a=new Map(n.map((A,O)=>[A,O])),l=Er(n),h=[];if(n.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(I))];break}}let p=new Map,f=(A,O=!1)=>{let G=p.get(A);return G&&us(G,O)};t={...t,layoutSubdomain(A,O,G,Z){let q=xs(O,t),J=new Set(O.flat()),F=z=>{for(let Q=z;Q&&Q!==A;Q=Q.foldedInto)if(J.has(Q))return!0;return!1},U=Z.filter(yt).filter(z=>!z.endPoints?.length);for(let z of l.get(A)??[])!p.has(z)&&z.endPoints.every(F)&&U.push(z);U.sort((z,Q)=>a.get(z)-a.get(Q));let Y=Tr(O,q,G,U,t,f,h.length?h.filter(F):h,A);return U.forEach((z,Q)=>p.set(z,Y.items[Q])),{width:q.width,height:Y.height,positions:Y.positions}}};let{lines:d,pageBreaks:u}=Ar(r),m=[];for(let A of d)for(let O of A.columns)for(let G of O)m.push(G),me(G,t);let x=n.filter(A=>!p.has(A)),y=d.map((A,O)=>kn(A.columns,O,e)),g=y.map(A=>A.view);for(let A of x)A.prepareHorizontal?.(g,t);for(let A of y){A.layout(s,o.fillRatio);for(let O of A.view.columns)for(let G of O)G.box.x+=i}if(e.horizontalOnly)return{diagnostics:r.diagnostics,objects:m,attachments:[],bounds:{x:0,y:0,w:0,h:0},lineCount:d.length,pages:[]};for(let A of m){let O=d[A.layoutLine];ys(O.hostExtents,A)}let b=_r(d.length,m,e.rowGap),S=()=>{let A=[],O=d.map((F,U)=>{let Y=gs(F,r.rootTrack,b[U]);return A.push(Y.height),Y.axes}),G,Z;try{({pages:G,lineTops:Z}=wn(A,o,u))}catch(F){if(!(F instanceof Xt))throw F;let U=d[F.line],Y=1/0,z=-1/0;for(let Q of U?.columns??[])for(let X of Q)Y=Math.min(Y,X.ast.sourceSpan.start),z=Math.max(z,X.ast.sourceSpan.end);throw Number.isFinite(Y)?M.error.PageOverflow(F.requiredHeight,F.availableHeight,{start:Y,end:z}):F}let q=(F,U)=>(Z[F]??0)+(O[F]?.get(U)??0);for(let F of m)F.box.y=q(F.layoutLine,F.track)-F.box.visualAxis,F.onPlaced?.();let J={...t,width:s,originX:i,pages:G.map(F=>F.bounds),lines:g,getVisualAxis:(F,U)=>q(F,c(U)),getHostExtent:(F,U)=>d[F]?.hostExtents.get(c(U)),getRangeColumns:(F,U,Y)=>An(g[F],U,Y,c)};return{pages:G,attachmentContext:J}},C=S(),E=Ln(x,C.attachmentContext,d,c,f,h);E.needsRelayout&&(C=S(),E=Ln(x,C.attachmentContext,d,c,f,h));let k=C.pages,N=0,v=n.map(A=>{let O=p.get(A),{geometry:G,box:Z}=O?us(O):E.items[N++];return{box:Z,regions:G.regions,layer:A.layer,sourceSpan:A.sourceSpan,paint(q){G.paint(q)}}}),_={x:0,y:0,w:0,h:0};function*D(){for(let A of k)yield A.bounds;for(let A of m)yield ot(A);for(let A of v)yield A.box}return Zt(_,D()),{diagnostics:r.diagnostics,objects:m,attachments:v,bounds:_,lineCount:d.length,pages:k}}function Cr(r){if(r.decorations.length===0)return;let t=0,e=-1/0,n=0,o=-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,d)=>f[i].order-d[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 d=f[i];if(!d)continue;let u=Math.max(0,d.height??0);!c&&!f.paint&&(l=Math.max(l,p));let m=c?l-(d.gap??0)-u:l+(d.gap??0);d.place?.(m),l=c?m:m+u,n=Math.min(n,m),h=c?Math.max(h,m+u):l,f.paint&&(t=Math.min(t,m),p=c?Math.max(p,m+u):l)}o=Math.max(o,h),e=Math.max(e,p)}r.box.h=e;let s=Math.max(0,o-e);(n!==0||s!==0)&&xe.set(r,{top:n,bottom:s,contentTop:t})}function Ar(r){let t=()=>({columns:[],hostExtents:new Map,attachmentExtents:new Map}),e=[],n=[],o=t();for(let s of r.columns){let i=[];for(;e.length<s[0].layoutLine;)e.push(o),o=t();for(let c of s){let a=c.addon?.pageBreakBefore;a!==void 0&&(n[e.length]=(n[e.length]??!0)&&a),I(c)&&i.push(c)}i.length&&o.columns.push(i)}return(o.columns.length>0||n[e.length]!==void 0||e.length===0)&&e.push(o),{lines:e,pageBreaks:n}}function de(r,t,e){r.top=Math.min(r.top,t),r.bottom=Math.max(r.bottom,e)}function En(r,t,e,n){let o=r.get(t);o?de(o,e,n):r.set(t,{top:e,bottom:n})}function kn(r,t,e={},n=!1){let o=[],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),Oe(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),d=s.get(h);f===void 0||d===void 0||o.push({start:Math.min(f,d),end:Math.max(f,d),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(d=>{let u=Pe(d.springConfig,d.box,d,e.globalC);return n&&(u.margin_L=u.margin_R=0),u}));return bn(p,l,e,o,h),p}}}function qt(r,t){return r.length===0?0:xs(r.map(e=>[e]),t).width}function xs(r,t){for(let s of r)for(let i of s)me(i,t);let e=kn(r,r[0][0].layoutLine,{},!0),n=1/0,o=-1/0;for(let s of e.layout(1/0))for(let i of s){let c=i.box.x+i.box.anchor;n=Math.min(n,c-i.WL),o=Math.max(o,c+i.WR)}for(let s of r)for(let i of s)i.box.x-=n;return{width:o-n,view:e.view}}function Tr(r,{width:t,view:e},n,o,s,i,c,a){let l=r.flat(),h={hostExtents:new Map,attachmentExtents:new Map},p=0;for(let v of l)ys(h.hostExtents,v),p=Math.max(p,v.ast.size*ds);let f=l.map(v=>({x:v.box.x,y:0})),d=()=>{let v=gs(h,n,p);return l.forEach((_,D)=>{_.box.y=f[D].y=v.axes.get(_.track)-_.box.visualAxis,_.onPlaced?.()}),v},u=d();if(o.length===0)return{height:u.height,positions:f,items:[]};let m=Sn(n),x=[],y=[];x[e.index]=h,y[e.index]=e;let g=()=>Ln(o,{...s,width:t,originX:0,pages:[],lines:y,getVisualAxis:(v,_)=>u.axes.get(m(_))??0,getHostExtent:(v,_)=>x[v]?.hostExtents.get(m(_)),getRangeColumns:(v,_,D)=>An(y[v],_,D,m)},x,m,i,c,a),b=g();b.needsRelayout&&(u=d(),b=g());let S=l[0],C={x:S.box.x,y:S.box.y},E=b.layoutItems&&ms(S,a),k=E&&(E.x!==0||E.y!==0)?{x:C.x-E.x,y:C.y-E.y}:C,N=b.items.map((v,_)=>({...v,reference:S,position:C,...b.layoutItems&&{layout:{...b.layoutItems[_],position:k}}}));return{height:u.height,positions:f,items:N}}function Er(r){let t=new Map;for(let e of r){let[n,...o]=e.endPoints??[];for(let s=n?.foldedInto;s;s=s.foldedInto){let i=s;if(!o.every(a=>Lr(i,a)))continue;let c=t.get(s);c?c.push(e):t.set(s,[e])}}return t}function Lr(r,t){for(let e=t.foldedInto;e;e=e.foldedInto)if(e===r)return!0;return!1}function us(r,t=!1){let e=t?r.layout??r:r,{position:n,geometry:o,box:s}=e,i=r.reference.box.x-n.x,c=r.reference.box.y-n.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:o.regions.map(a),occupancy:o.occupancy?.map(a),paint:l=>o.paint(new Ut(l,i,c))}}}function _r(r,t,e){if(e!==void 0)return new Array(r).fill(e);let n=new Array(r).fill(0),o=0;for(let s of t){let i=s.ast.size*ds;i>n[s.layoutLine]&&(n[s.layoutLine]=i),i>o&&(o=i)}for(let s=0;s<r;s++)n[s]||=o;return n}function ms(r,t){let e=0,n=0;for(let o=r;o&&o!==t;o=o.foldedInto)e+=o.placementOffset?.x??0,n+=o.placementOffset?.y??0;return{x:e,y:n}}function Ln(r,t,e,n,o,s,i){if(r.length===0)return{items:[],needsRelayout:!1};let c=[];for(let p of s){let{x:f,y:d}=ms(p,i);(f!==0||d!==0)&&c.push({node:p,x:f,y:d,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:d}of c)p.box.x-=f,p.box.y-=d;try{l=Tn(r,{...t,layoutOnly:!0},e,n,o,!0)}finally{for(let{node:p,boxX:f,boxY:d}of c)p.box.x=f,p.box.y=d}}else l=Tn(r,t,e,n,o,!0);if(!a)return l;let h;return{needsRelayout:l.needsRelayout,layoutItems:l.items,get items(){return h??=Tn(r,t,e,n,o,!1).items}}}function Tn(r,t,e,n,o,s){let i=new Map,c=[],a=!1;function l(d){let u=i.get(d);return u||(u=o(d,t.layoutOnly),u&&i.set(d,u)),u}function h(d,u,m){let x=t.lines[d],y=m===void 0?new Map:void 0,g,b=u&&"left"in u?u:void 0;if(!x||b&&b.left>=b.right)return y;let S=(D,A,O)=>{y?En(y,D,A,O):g?de(g,A,O):g={top:A,bottom:O}},{start:C,end:E,wholeLine:k}=Cn(x,u&&!("left"in u)?u:void 0,m,n),N=m&&n(m),v=b?.left??(k?t.originX:1/0),_=b?.right??(k?t.originX+t.width:-1/0);for(let D=C;D<=E;D++)for(let A of x.columns[D]){if(N&&A.track!==N||b&&(A.box.x+A.box.w<=v||A.box.x>=_))continue;k||(A.box.x<v&&(v=A.box.x),A.box.x+A.box.w>_&&(_=A.box.x+A.box.w));let O=xe.get(A),G=O?.top??0,Z=A.box.y+G-t.getVisualAxis(d,A.track);S(A.track,Z,Z+(A.box.h-G+(O?.bottom??0)))}for(let D of c[d]??[])N&&D.track!==N||D.right<=v||D.left>=_||S(D.track,D.top,D.bottom);return y??g}let p={...t,getRangeExtents:h,getHorizontalExtents:(d,u,m)=>h(d,{left:u,right:m}),getAttachmentOccupancy(d){let u=l(d)?.geometry;return u&&(u.occupancy??u.regions)},getAttachmentBox(d){let u=l(d);if(!u)throw new Error("Layout attachment dependency has not been measured");return u.box},getContentBounds(d){let u=[];for(let x of d.nodes)I(x)&&(x.box.w>0||x.box.h>0)&&u.push(ot(x,!0));for(let x of d.attachments){if(!yt(x))continue;let y=l(x);if(!y&&!r.includes(x))continue;let g=y?.box??p.getAttachmentBox(x);(g.w>0||g.h>0)&&u.push(g)}let m={x:0,y:0,w:0,h:0};return Zt(m,u)?m:void 0}};return{items:r.map(d=>{let u=d.createGeometry(p),m={x:0,y:0,w:0,h:0};Zt(m,u.regions);let x={geometry:u,box:m};i.set(d,x);for(let y of u.occupancy??u.regions){if(y.line===void 0)continue;let g=e[y.line],b=n(y.track),S=y.y-t.getVisualAxis(y.line,b),C=S+y.h,E=g.hostExtents.get(b),k=g.attachmentExtents.get(b);s&&(S<Math.min(E?.top??1/0,k?.top??1/0)||C>Math.max(E?.bottom??-1/0,k?.bottom??-1/0))&&(a=!0),s&&En(g.attachmentExtents,b,S,C),(c[y.line]??=[]).push({track:b,left:y.x,right:y.x+y.w,top:S,bottom:C})}return x}),needsRelayout:a}}function ys(r,t){let e=xe.get(t),n=e?.top??0,o=t.box.h-n+(e?.bottom??0),s=n-t.box.visualAxis;En(r,t.track,s,s+o)}function gs(r,t,e){let n=new Map,o=a=>{let l=r.hostExtents.get(a),h=r.attachmentExtents.get(a),p=l?{top:l.top,bottom:l.bottom}:null;h&&(p?de(p,h.top,h.bottom):p={top:h.top,bottom:h.bottom});let f=[];for(let u of a.groups){let m=u.members.map(o);if(m.every(g=>g===null))continue;let x=u.measure(m,e),y=null;for(let g of x){if(!g)continue;let b=g.offset+g.extent.top,S=g.offset+g.extent.bottom;y?de(y,b,S):y={top:b,bottom:S}}y&&f.push({group:u,placements:x,extent:y})}let d=(u,m)=>{p??={top:0,bottom:0};for(let x=0;x<u.group.members.length;x++){let y=u.placements[x];y&&n.set(u.group.members[x],m+y.offset)}de(p,m+u.extent.top,m+u.extent.bottom)};for(let u of f)u.group.place||d(u,0);for(let u of f){let m=u.group.place;if(!m)continue;d(u,m(p??{top:0,bottom:0},u.extent,e))}return p},s=o(t),i=new Map;if(!s)return{axes:i,height:0};let c=(a,l)=>{i.set(a,l);for(let h of a.groups)for(let p of h.members){let f=n.get(p);f!==void 0&&c(p,l+f)}};return c(t,-s.top),{axes:i,height:s.bottom-s.top}}var Be=class{min=1/0;max=-1/0;add(t){t<this.min&&(this.min=t),t>this.max&&(this.max=t)}};function Nn(r,t,e,n,o,s){if(!(r>0&&r<1))return;let i=1-r;s.add(i*i*i*t+3*i*i*r*e+3*i*r*r*n+r*r*r*o)}function bs(r,t,e,n,o){o.add(r),o.add(n);let s=-r+3*t-3*e+n,i=2*(r-2*t+e),c=t-r;if(Math.abs(s)<1e-12){Math.abs(i)>1e-12&&Nn(-c/i,r,t,e,n,o);return}let a=i*i-4*s*c;if(a<0)return;let l=Math.sqrt(a);Nn((-i+l)/(2*s),r,t,e,n,o),Nn((-i-l)/(2*s),r,t,e,n,o)}function ws(r,t,e,n){n.add(r),n.add(e);let o=r-2*t+e;if(Math.abs(o)<1e-12)return;let s=(r-t)/o;if(!(s>0&&s<1))return;let i=1-s;n.add(i*i*r+2*i*s*t+s*s*e)}function xt(r){let t=new Be,e=new Be,n=0,o=0,s=0,i=0;for(let c of r){if(c.op==="Z"){n=s,o=i;continue}c.op==="C"?(bs(n,c.cx1,c.cx2,c.x,t),bs(o,c.cy1,c.cy2,c.y,e)):c.op==="Q"?(ws(n,c.cx,c.x,t),ws(o,c.cy,c.y,e)):(t.add(c.x),e.add(c.y),c.op==="M"&&(s=c.x,i=c.y)),n=c.x,o=c.y}return Number.isFinite(t.min)?{x:t.min,y:e.min,w:t.max-t.min,h:e.max-e.min}:{x:0,y:0,w:0,h:0}}var kr=54.2813,Cs=87.37505,De=72.8125,Nr=93.6719,vr=-27.4688,As=-7.9375,Mr=As+Nr,Rr=[{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}],Ir=[{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 Ss(r,t,e,n,o,s){let i=a=>e+(s?kr-a:a)*o,c=a=>n+(s?Cs-a:a)*o;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 Ts(r,t,e){let n=e==="up"||e==="down",o=Math.max(1,Math.round(r/(t*.3))),s=n?Math.max(0,o-1):o,i=n?Mr+De*s:Cs+De*(s-1),c=r/i,a=[];for(let f=0;f<s;f++)Ss(a,Rr,0,f*De*c,c,e==="");n&&Ss(a,Ir,vr*c,(s*De+As)*c,c,!1);let l=xt(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 Or(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 vn=class extends L{static def={name:["arp","arpeggio"],description:"\u7436\u97F3",details:`~~~jpfun
|
|
7
7
|
@arp({1 ^ 3 ^ 5}, direction=up)
|
|
8
8
|
~~~
|
|
9
|
-
\u7ED9\u548C\u5F26\u7ED8\u5236\u7436\u97F3\u8BB0\u53F7\uFF0C\u64AD\u653E\u65F6\u6309\u65B9\u5411\u9519\u5F00\u6210\u5458\u8D77\u70B9\u5E76\u4FDD\u6301\u5171\u540C\u7EC8\u70B9\u3002\u590D\u5408\u6210\u5458\u7684\u5185\u90E8\u97F3\u7B26\u6309\u6BD4\u4F8B\u538B\u7F29\u5230\u5269\u4F59\u65F6\u503C\uFF0C\u88C5\u9970\u97F3\u5728\u786E\u5B9A\u540E\u7684\u533A\u95F4\u5185\u5C55\u5F00\u3002`,allowExtraArgs:!1,args:[{name:"content",description:"\u7531 `up` / `down` \u5806\u53E0\u5F62\u6210\u7684\u548C\u5F26",type:"content",default:null},{name:"direction",description:"\u7A7A\u503C\u4ECE\u4F4E\u5230\u9AD8\u3001\u4E0D\u753B\u7BAD\u5934\uFF1B`up` \u4ECE\u4F4E\u5230\u9AD8\u3001\u9876\u7AEF\u5E26\u7BAD\u5934\uFF1B`down` \u4ECE\u9AD8\u5230\u4F4E\u3001\u5E95\u7AEF\u5E26\u7BAD\u5934",type:"string",default:""}]};content;direction;size;get children(){return[this.content]}constructor(t,e,n,o=null){super(t,o);let[s,
|
|
9
|
+
\u7ED9\u548C\u5F26\u7ED8\u5236\u7436\u97F3\u8BB0\u53F7\uFF0C\u64AD\u653E\u65F6\u6309\u65B9\u5411\u9519\u5F00\u6210\u5458\u8D77\u70B9\u5E76\u4FDD\u6301\u5171\u540C\u7EC8\u70B9\u3002\u590D\u5408\u6210\u5458\u7684\u5185\u90E8\u97F3\u7B26\u6309\u6BD4\u4F8B\u538B\u7F29\u5230\u5269\u4F59\u65F6\u503C\uFF0C\u88C5\u9970\u97F3\u5728\u786E\u5B9A\u540E\u7684\u533A\u95F4\u5185\u5C55\u5F00\u3002`,allowExtraArgs:!1,args:[{name:"content",description:"\u7531 `up` / `down` \u5806\u53E0\u5F62\u6210\u7684\u548C\u5F26",type:"content",default:null},{name:"direction",description:"\u7A7A\u503C\u4ECE\u4F4E\u5230\u9AD8\u3001\u4E0D\u753B\u7BAD\u5934\uFF1B`up` \u4ECE\u4F4E\u5230\u9AD8\u3001\u9876\u7AEF\u5E26\u7BAD\u5934\uFF1B`down` \u4ECE\u9AD8\u5230\u4F4E\u3001\u5E95\u7AEF\u5E26\u7BAD\u5934",type:"string",default:""}]};content;direction;size;get children(){return[this.content]}constructor(t,e,n,o=null){super(t,o);let[s,i]=this.getArgValue(e,n),c="";i!==""&&i!=="up"&&i!=="down"?n.diagnostics.push(new P("W_ARPEGGIO_INVALID_DIRECTION","@arp \u7684 direction \u53EA\u80FD\u662F up \u6216 down\uFF0C\u5DF2\u56DE\u9000\u5230\u65E0\u7BAD\u5934\u4E0A\u884C\u7436\u97F3",t)):c=i,this.content=s,this.direction=c,this.size=n.variables.fontsize,s.parent=this}loweringEnter(t,e){let n=t.isolateFromLoweringGroups(()=>{let s=t.trackedEvents(this.content,new B,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]}),o=Or(n);if(!o||o.members.length<2||o.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 Mn(this,o)]}toString(t){let e=this.direction?`, direction=${this.direction}`:"";return`@arp(${this.content.toString(t)}${e})`}},Es=vn,Mn=class extends ${host;playbackMembers;hostX=0;markX=0;markCommands=[];constructor(t,e){super(),this.ast=t,this.host=e;let n=e.ast.contents.length,o=[...e.members.slice(n).reverse(),e.members[0],...e.members.slice(1,n)];this.playbackMembers=t.direction==="down"?o.reverse():o,this.T.copyFrom(e.T),this.mergeKey=e.mergeKey,this.initLayoutBox(),e.addon&&(this.addon={...e.addon}),e.addon=void 0,e.foldedInto=this}onTimeState(t){this.host.t.copyFrom(this.t),this.host.T.copyFrom(this.T),this.host.track=this.track,this.host.layoutLine=this.layoutLine;let e=this.host.onTimeState?.(t);return this.T.copyFrom(this.host.T),e}prepareHorizontal(t){this.host.prepareHorizontal?.(t)}prepareLayout(t){Ot(this,this.host),me(this.host,t),this.springConfig={...this.host.springConfig,...this.springConfig};let e=this.ast.size,n=e*.16,o=ot(this.host,!0),s=ot(this.host),{commands:i,bounds:c}=Ts(o.h,e,this.ast.direction);this.markCommands=i,this.markX=-c.x,this.hostX=c.w+n,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-(ot(this.host).y-this.host.box.y),this.host.onPlaced?.()}emitPlayback(t){t.play(this.host);let e=t.end.clone().sub(t.start),n=new B(1,8),o=e.clone().div(2).div(this.playbackMembers.length-1);n.compare(o)>0&&n.copyFrom(o);let s=new Map(this.playbackMembers.map((c,a)=>[c,a])),i=this;t.defer(c=>{let a;for(let l=c.spans.length-1;l>=0;l--){let h=c.spans[l];if(h.origins.some(p=>p.node===i)){a=h.origins[0];break}}if(a)for(let l of c.spans){if(l.origins[0]!==a)continue;let h=l.origins.find(u=>s.has(u.node))?.node,p=h?s.get(h):void 0;if(!p)continue;let f=n.clone().mul(p),d=e.clone().sub(f).div(e);l.start.sub(t.start).mul(d).add(t.start).add(f),l.end.sub(t.start).mul(d).add(t.start).add(f)}})}paint(t){let e=this.box.x,n=ot(this.host,!0).y;t.drawPath(this.markCommands,{fill:"#000"},{x:e+this.markX,y:n,scaleX:1,scaleY:1}),this.host.paint(t);for(let o of this.host.decorations)o.paint?.(t)}};var Rn=class extends L{static def={name:["bar","|"],description:"\u5C0F\u8282\u7EBF",details:`~~~jpfun
|
|
10
10
|
@bar(0, length=1.25em)
|
|
11
11
|
~~~
|
|
12
|
-
\u6709\u8BED\u6CD5\u7CD6\u7B80\u5199\uFF0C\u89C1 type \u53C2\u6570\u7684\u8BF4\u660E\u3002`,allowExtraArgs:!1,args:[{name:"type",description:"0\uFF1A\u666E\u901A\u7EBF `|`\uFF1B1\uFF1A\u7EC8\u6B62\u7EBF `||`\uFF08\u5DE6\u7EC6\u53F3\u7C97\uFF09\uFF1B2\uFF1A\u53CD\u590D\u8D77\u70B9 `|:`\uFF1B3\uFF1A\u53CD\u590D\u7EC8\u70B9 `:|`\uFF1B4\uFF1A\u5DE6\u53F3\u53CD\u590D `:|:`",type:"number",default:0},{name:"length",description:"\u5C0F\u8282\u7EBF\u9AD8\u5EA6",type:"length",default:{value:1.25,unit:"em"}}]};static deSugarAtom(t,e,n){let o=e,s=0,r=t.slice(o,o+2);if(r==="||")s=1,o+=2;else if(r==="|:")s=2,o+=2;else if(r===":|")t[o+2]===":"?(s=4,o+=3):(s=3,o+=2);else if(t[o]==="|")s=0,o+=1;else return null;let c=new Map;return c.set("type",s),{next:o,node:{kind:"call",typed:!0,name:"bar",args:c,span:{start:e,end:o},syntaxKind:"atom"}}}type;size;constructor(t,e,n,o=null){super(t,o);let[s,r]=this.getArgValue(e,n);this.type=s,this.size=n.length2px(r)}loweringEnter(){return[this.type>=2?new bn(this):new _e(this)]}toString(){return`@bar(${this.type}, ${this.size}px)`}},jo=yn,_e=class extends W{lines=[];repeatDots=[];constructor(t){super(),this.ast=t,this.mergeKey=U,this.initLayoutBox(),this.springConfig={alpha_L:128,alpha_R:128}}prepareHorizontal(t){let e=this;for(;e.foldedInto;)e=e.foldedInto;if(!F(e))return;let n=t.trackRuns.get(e.track),o=n?.indexOf(e)??-1;!n||o<0||t.registerHorizontalLayoutHook(e,e,({columns:s,start:r})=>{let c=s[r].find(f=>f.time===e);if(!c)return;let a=f=>{let d=t.columnOf(f);return d<0?void 0:s[d].find(u=>u.time===f)},l=o>0?a(n[o-1]):void 0;l&&(l.config.mu_R*=4,c.config.mu_L*=4);let h=n[o+1],p=h?a(h):void 0;p&&h.mergeKey!==U&&(c.config.mu_R*=4,p.config.mu_L*=4)})}prepareLayout(){let{type:t,size:e}=this.ast;this.lines.length=0;let n=[],o=e,s=Math.max(1,e*.065),r=s*2.6,c=s*1.8,a=s*.8,l=c+a,h=t===3||t===4,p=t===2||t===4,f=h?a*2+l:0;if(t===1||t===3||t===4?(this.lines.push({x:f,w:s}),f+=s+c,this.lines.push({x:f,w:r}),f+=r):t===2?(this.lines.push({x:f,w:r}),f+=r+c,this.lines.push({x:f,w:s}),f+=s):(this.lines.push({x:f,w:s}),f+=s),h){let u=a;n.push({x:u,y:o*.38}),n.push({x:u,y:o*.62})}if(p){let u=f+l;n.push({x:u,y:o*.38}),n.push({x:u,y:o*.62}),f=u+a}this.box.w=f,this.box.h=o;let d=t>=2?this.lines[0]:void 0;this.box.anchor=d?d.x+d.w/2:f/2,this.box.visualAxis=o/2;for(let u of this.lines)u.x-=this.box.anchor;this.repeatDots=n.map(u=>({x:u.x-this.box.anchor,y:u.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"})}},gn="repeat.start";function Xo(i,t){return i.visits(i.seek(gn,t+1,-1)??0)}var bn=class extends _e{playbackMarks(){return this.ast.type===3?[]:[gn]}playbackFlow(t){if(this.ast.type===2)return;let e=t(this);if(e!==void 0)return{range:[e,e],run:n=>n.visits(e)>1?void 0:{kind:"jump",column:n.seek(gn,e,-1)??0}}}};var Zo="div",Et=Lt(Zo);function ft(i,t){return`div.${i}.${t}`}function qo(i,t){let e=i.ports[ft(t,"left")];e&&(e.state.claimed=!0)}function Sn(i){return Math.max(1,i*.055)}function*Qo(i){for(let t=0;;t++){let e=!1,n=-1;for(let o=0;o<=i.length;o++){let s=i[o]?.ports,r=s?.[ft(t,"left")],c=s?.[ft(t,"right")];if((r||c)&&(e=!0),r&&c){n<0&&(n=o);continue}n>=0&&o-n>=2&&(yield{level:t,from:n,to:o-1}),n=-1}if(!e)return}}var wn=class i extends v{static def={name:[Zo,"/"],description:"\u51CF\u65F6\u7EBF",details:"~~~jpfun\n@div({1 2 -}, n=2, autobeam=true)\n~~~\n**\u7B80\u5199**\uFF1A\u5728\u76EE\u6807\u540E\u52A0 `/`\uFF0C\u53EF\u91CD\u590D\u6216\u4F5C\u7528\u4E8E\u5185\u5BB9\u5757\u3002`@div(1, 2)` \u7B49\u4EF7\u4E8E `1//`\uFF0C`@div({1 2/ -}, 2)` \u7B49\u4EF7\u4E8E `{1 2/ -}//`\u3002\u9ED8\u8BA4\u53C2\u6570\u4F7F\u7528 `div.n`\u3001`div.autobeam` \u8BBE\u7F6E\u3002",allowExtraArgs:!1,args:[{type:"content",description:"\u8981\u51CF\u65F6\u7684\u5185\u5BB9\uFF0C\u53EF\u5305\u542B\u591A\u4E2A\u97F3\u7B26\u6216\u589E\u65F6\u7EBF",default:null},{name:"n",description:"\u51CF\u65F6\u5C42\u6570\uFF0C\u6BCF\u7EA7\u5C06\u65F6\u503C\u51CF\u534A\uFF0C\u53D6\u975E\u8D1F\u6574\u6570",type:"number",default:1},{name:"autobeam",description:"\u662F\u5426\u53C2\u4E0E\u4E0D\u540C div \u4E4B\u95F4\u7684\u81EA\u52A8\u8FDE\u7EBF\uFF0C\u540C\u4E00 div \u5185\u90E8\u7684\u8FDE\u7EBF\u4E0D\u53D7\u5F71\u54CD",type:"boolean",default:!0}]};static deSugarAtom(t,e,n){let o=0,s=e;for(;s<n&&t[s]==="/";)o++,s++;return o===0?null:{next:s,node:{kind:"sugar",data:{class:i,n:o},span:{start:e,end:s}}}}static deSugarRelation(t,e,n){let o=e[n++];if(o.data?.class!==i)return null;let s=v.findLastFuncContentIndex(t.nodes,t.nodes.length-1);if(s<0)return n;let r=t.nodes[s];if(r instanceof i)return r.n+=o.data.n,n;let c=new Map;c.set(0,r),c.set("n",o.data.n);let a=r.sourceSpan,l=new i({start:Math.min(a.start,o.span.start),end:Math.max(a.end,o.span.end)},c,t,null);return t.nodes[s]=l,n}static layoutDecorationHandler=(t,e)=>{let n=Math.max(0,Math.floor(Number(e)||0));if(n===0)return null;let o=t.ast.size*.14,s=Sn(t.ast.size),r=(n-1)*o+s,c=0,a=0,l=0;return{below:{order:0,gap:-t.ast.size*.08,height:r,place(h){c=t.ports["body.left"]?.x??0,a=t.ports["body.right"]?.x??t.box.w,l=h+s/2;for(let p=0;p<n;p++){let f=l+p*o;t.ports[ft(p,"left")]={x:c,y:f,state:{claimed:!1}},t.ports[ft(p,"right")]={x:a,y:f}}}},paint(h){for(let p=0;p<n;p++){if(t.ports[ft(p,"left")].state.claimed)continue;let d=t.box.y+l+p*o;h.drawLine(t.box.x+c,d,t.box.x+a,d,{stroke:"#000",strokeWidth:s})}}}};loweringEnter(t){let e=this.n;return t.beginLoweringGroup(this,{onTemporal(n){if(e===0)return;let o=n.addon??={};o[Et]=(Number(o[Et])||0)+e,n.T.divPow2(e)}}),[]}loweringExit(t){return t.endLoweringGroup(this),[]}content;n;autoBeamEnabled;get children(){return[this.content]}timeFlowModel(){return{children:[this.content],mode:"sequence"}}constructor(t,e,n,o=null){super(t,o),[this.content,this.n,this.autoBeamEnabled]=this.getArgValue(e,n),this.content.parent=this;let s=Math.max(0,Math.trunc(this.n));s!==this.n&&(n.diagnostics.push(new O("W_DIV_INVALID_N",`@div \u7684\u6570\u91CF\u53C2\u6570 n \u5FC5\u987B\u4E3A\u975E\u8D1F\u6574\u6570\uFF0C\u5DF2\u88AB\u4FEE\u6B63\u4E3A ${s}`,this.sourceSpan)),this.n=s)}toString(t){return`@div(${this.content.toString(t)}, ${this.n})`}},Yt=wn;function Kt(i,t,e){return new ce(i,t,e)}function Jo(i){let t=new Map;for(let n of i.columns)for(let o of n){if(!F(o)||o.mergeKey===U&&o.T.isZero())continue;let s=t.get(o.layoutLine);s||(s=new Map,t.set(o.layoutLine,s));let r=s.get(o.track);r?r.push(o):s.set(o.track,[o])}let e=new Map;for(let[n,o]of t)for(let[s,r]of o)for(let c=0;c<r.length;c++)e.set(r[c],{line:n,track:s,index:c});for(let n of i.attachments)if(!(!(n instanceof ce)||!n.explicit))for(let o=1;o<n.endPoints.length;o++){let s=n.endPoints[o-1],r=n.endPoints[o];if(!F(s)||!F(r))continue;let c=e.get(s),a=e.get(r);if(!(s!==r&&c!==void 0&&a!==void 0&&c.line===a.line&&c.track===a.track&&a.index===c.index+1))throw new S("E_NON_ADJACENT_BEAM","@beam \u7684\u7AEF\u70B9\u5FC5\u987B\u6309\u65F6\u95F4\u987A\u5E8F\u8FDE\u63A5\u540C\u4E00\u8F68\u9053\u3001\u540C\u4E00\u8C31\u9762\u884C\u4E2D\u7684\u76F8\u90BB\u53EF\u89C1\u5143\u7D20\uFF08\u53EF\u8DE8\u5C0F\u8282\u7EBF\uFF09",n.sourceSpan)}}function ts(i){let t=new Set;for(let e of i)if(!(!(e instanceof ce)||!e.explicit))for(let n of e.endPoints)t.add(n);return t}var ce=class{layer="foreground";endPoints;explicit;sourceSpan;fontSize;strokeWidth;constructor(t,e,n){this.endPoints=t,this.explicit=e,this.sourceSpan=n,this.fontSize=t.reduce((o,s)=>F(s)?Math.max(o,s.ast.size):o,0),this.strokeWidth=Sn(this.fontSize)}prepareHorizontal(t){let e=new Set(this.endPoints);for(let n of t)for(let o of n.trackRuns.values())for(let s=1;s<o.length;s++){let r=o[s-1],c=o[s];!e.has(r)||!e.has(c)||(r.springConfig.alpha_R=r.springConfig.alpha_R*.8,c.springConfig.alpha_L=c.springConfig.alpha_L*.8)}}createGeometry(t){let e=this.collectLines(t),n=this.strokeWidth;return{regions:e.map(s=>({x:Math.min(s.start.x,s.end.x),y:s.start.y-n/2,w:Math.abs(s.end.x-s.start.x),h:n,line:s.line,track:s.track})),paint(s){for(let r of e)s.drawLine(r.start.x,r.start.y,r.end.x,r.end.y,{stroke:"#000",strokeWidth:n})}}}absolutePort(t,e){let n=t.ports[e];return{x:t.box.x+n.x,y:t.box.y+n.y}}collectLines(t){let e=[],n=this.endPoints.filter(F);if(n.length<2)return e;for(let{level:o,from:s,to:r}of Qo(n)){let c=[];for(let a=s;a<=r;a++){let l=n[a];c.push({left:this.absolutePort(l,ft(o,"left")),right:this.absolutePort(l,ft(o,"right")),line:l.layoutLine,track:l.track,node:l})}this.addSystemLines(c,t,o,e)}if(e.length===0&&this.explicit){let o=this.fontSize*.12,s=n.map(r=>{let c={x:r.box.x+r.box.anchor,y:r.box.y+r.box.h+o};return{left:c,right:c,line:r.layoutLine,track:r.track,node:r}});this.addSystemLines(s,t,null,e)}return e}addSystemLines(t,e,n,o){let s=Math.min(...t.map(h=>h.line)),r=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<=r;h++){let p=t.filter(x=>x.line===h).sort((x,m)=>x.left.x-m.left.x);if(p.length===0){let m=e.getVisualAxis(h,c)+l;o.push({start:{x:e.originX,y:m},end:{x:e.originX+e.width,y:m},line:h,track:c});continue}let f=p[0],d=p[p.length-1],u=f.left.y,g={x:f.left.x,y:u},y={x:d.right.x,y:u};if(h>s&&(g.x=e.originX),h<r&&(y.x=e.originX+e.width),!(g.x===y.x&&s===r)){if(n!==null)for(let x of p)qo(x.node,n);o.push({start:g,end:y,line:h,track:f.track})}}}};function es(i){let t=[],e=Math.max(0,Math.floor(Number(i.addon?.[Et])||0)),n=r=>{t.push(r),e-=Math.max(0,r.n)},o=i.ast.parent;for(;o&&e>0;)o instanceof Yt&&n(o),o=o.parent;let s=r=>{for(let c of r.children??[]){if(e<=0)return;c instanceof Yt&&n(c),s(c)}};return s(i.ast),t}function Zi(i){let t=new Map,e=new Map;for(let n of i.columns)for(let o of n){if(!F(o))continue;let s=es(o);if(s.length===0)continue;let r=[];for(let c of s){let a=t.get(c);a||(a={owner:c,nodes:[]},t.set(c,a)),a.nodes.push(o),r.push(a)}e.set(o,r)}return{scopes:[...t.values()],nodeScopes:e}}function qi(i){let t=new Set(i.map(e=>e.owner));return i.filter(e=>{let n=e.owner.parent;for(;n;){if(n instanceof Yt&&t.has(n))return!1;n=n.parent}return!0})}function Qi(i){let t=1/0,e=-1/0;for(let n of i){t=Math.min(t,n.ast.sourceSpan.start),e=Math.max(e,n.ast.sourceSpan.end);for(let o of es(n))t=Math.min(t,o.sourceSpan.start),e=Math.max(e,o.sourceSpan.end)}return{start:t,end:e}}function ns(i){return Kt(i,!1,Qi(i))}function Ji(i,t){let e=[];for(let n of qi(i)){let o=new Map;for(let s of n.nodes){let r=o.get(s.track);r?r.push(s):o.set(s.track,[s])}for(let s of o.values()){let r=[],c=()=>{r.length>=2&&e.push(ns(r)),r=[]};for(let a of s){if(t.has(a)){c();continue}r.push(a)}c()}}return e}function tr(i){return Math.floor(i.numerator/i.denominator)}function er(i,t,e){let n=[],o=new Map,s=new Map,r=new I,c=new I;for(let h of i.columns)for(let p of h){let f=s.get(p.layoutLine);(f===void 0||p.t.compare(f)<0)&&s.set(p.layoutLine,p.t)}let a=h=>{let p=o.get(h);p&&(o.delete(h),p.nodes.length>=2&&n.push(ns(p.nodes)))},l=()=>{for(let h of[...o.keys()])a(h)};for(let h of i.columns){let p=h.find(f=>f.mergeKey===U);p&&(l(),r.copyFrom(p.t));for(let f of h){if(f.mergeKey===U)continue;let d=F(f)?t.get(f):void 0,u=d?.every(k=>k.nodes.length===1)??!1,g=d?.every(k=>k.owner.autoBeamEnabled)??!1;if(!(F(f)&&u&&g&&f.T.compare(1)<0&&!e.has(f))){(F(f)||!f.T.isZero())&&a(f.track);continue}let x=s.get(f.layoutLine)??f.t,m=r.compare(x)>=0?r:x,b=tr(c.copyFrom(f.t).sub(m)),w=o.get(f.track);if(!w){o.set(f.track,{nodes:[f],line:f.layoutLine,beat:b,endTime:f.t.clone().add(f.T)});continue}let A=f.t.equals(w.endTime);if(f.layoutLine!==w.line||b!==w.beat||!A){a(f.track),o.set(f.track,{nodes:[f],line:f.layoutLine,beat:b,endTime:f.t.clone().add(f.T)});continue}w.nodes.push(f),w.endTime.copyFrom(f.t).add(f.T)}}return l(),n}function os(i){let{scopes:t,nodeScopes:e}=Zi(i),n=ts(i.attachments);return[...Ji(t,n),...er(i,e,n)]}var Cn=class extends v{static loweringAugment=os;static loweringFinalize=Jo;static def={name:["beam"],description:"\u51CF\u65F6\u7EBF\u8FDE\u63A5",details:"\u4E8B\u540E\u5C06\u591A\u4E2A\u51CF\u65F6\u7EBF**\u5F3A\u884C**\u76F8\u8FDE\n~~~jpfun\n1/@a 2/@b | 3/@c @beam(a, b, c)\n~~~\n**\u4F4D\u7F6E\u53C2\u6570**\uFF1A\u5DF2\u6807\u8BB0\u97F3\u7B26\u7684\u6807\u7B7E\uFF0C\u6309\u4F20\u5165\u987A\u5E8F\u8FDE\u63A5\u51CF\u65F6\u7EBF\uFF0C\u663E\u5F0F\u6307\u5B9A\u4E00\u7EC4\u3002\u5148\u7528 `/` \u6216 `@div` \u4E3A\u76EE\u6807\u6DFB\u52A0\u51CF\u65F6\u7EBF\uFF0C\u518D\u7528 `@beam` \u63A7\u5236\u8FDE\u63A5\u3002\u7AEF\u70B9\u987B\u540C\u8F68\u3001\u540C\u8C31\u9762\u884C\u4E14\u76F8\u90BB\uFF0C\u53EF\u8DE8\u5C0F\u8282\u7EBF\uFF1B\u8FDE\u7EBF\u76F4\u63A5\u7A7F\u8FC7\u5C0F\u8282\u7EBF\uFF0C\u4FDD\u7559\u539F\u6709\u95F4\u8DDD\u3002",allowExtraArgs:!0,extraArgType:"label",args:[]};endPoints=[];constructor(t,e,n,o=null){super(t,o);for(let[,r]of e){let c=r instanceof v?r:n.parseArgWithType(r.valueSpan,"label",t.start);c instanceof v&&this.endPoints.push(c)}let s=n.labelableNodes.length-1;for(;this.endPoints.length<2&&s>=0;){let r=n.labelableNodes[s--];!r||this.endPoints.includes(r)||this.endPoints.unshift(r)}if(this.endPoints.length<2)throw new S("E_NOT_ENOUGH_ARGS","@beam \u81F3\u5C11\u9700\u8981\u4E24\u4E2A\u7AEF\u70B9",t)}loweringEnter(t){let e=[];for(let n of this.endPoints){let o=t.getTemporalNodes(n).at(-1);for(;o?.foldedInto;)o=o.foldedInto;o&&e.push(o)}return e.length<2?(t.diagnostics.push(N.warning.UnresolvedEndpoint("beam",this.sourceSpan)),[]):(t.addAttachment(Kt(e,!0,this.sourceSpan)),[])}},ss=Cn;var An=class extends v{static def={name:["box"],description:"\u7ED9\u76EE\u6807\u7ED3\u6784\u6216\u5BF9\u8C61\u52A0\u5916\u6846",details:`~~~jpfun
|
|
12
|
+
\u6709\u8BED\u6CD5\u7CD6\u7B80\u5199\uFF0C\u89C1 type \u53C2\u6570\u7684\u8BF4\u660E\u3002`,allowExtraArgs:!1,args:[{name:"type",description:"0\uFF1A\u666E\u901A\u7EBF `|`\uFF1B1\uFF1A\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,n){let o=e,s=0,i=t.slice(o,o+3),c=t.slice(o,o+2);if(i==="|||")s=2,o+=3;else if(c==="||")s=1,o+=2;else if(c==="|:")s=3,o+=2;else if(c===":|")t[o+2]===":"?(s=5,o+=3):(s=4,o+=2);else if(t[o]==="|")s=0,o+=1;else return null;let a=new Map;return a.set("type",s),{next:o,node:{kind:"call",typed:!0,name:"bar",args:a,span:{start:e,end:o},syntaxKind:"atom"}}}type;size;constructor(t,e,n,o=null){super(t,o);let[s,i]=this.getArgValue(e,n);this.type=s,this.size=n.length2px(i)}loweringEnter(){return[this.type>=3&&this.type<=5?new On(this):new Fe(this)]}toString(){return`@bar(${this.type}, ${this.size}px)`}},Ls=Rn,Fe=class extends ${lines=[];repeatDots=[];constructor(t){super(),this.ast=t,this.mergeKey=nt,this.initLayoutBox(),this.springConfig={alpha_L:128,alpha_R:128}}prepareHorizontal(t){let e=this;for(;e.foldedInto;)e=e.foldedInto;if(!I(e))return;let n=t.trackRuns.get(e.track),o=t.trackIndexOf(e);if(!n||o<0)return;let s=n[o-1];s&&(s.springConfig.mu_R*=4,e.springConfig.mu_L*=4);let i=n[o+1];i&&i.mergeKey!==nt&&(e.springConfig.mu_R*=4,i.springConfig.mu_L*=4)}prepareLayout(){let{type:t,size:e}=this.ast;this.lines.length=0;let n=[],o=e,s=Math.max(1,e*.065),i=s*2.6,c=s*1.8,a=s*.8,l=c+a,h=t===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 u=a;n.push({x:u,y:o*.38}),n.push({x:u,y:o*.62})}if(p){let u=f+l;n.push({x:u,y:o*.38}),n.push({x:u,y:o*.62}),f=u+a}this.box.w=f,this.box.h=o;let d=t>=3&&t<=5?this.lines[0]:void 0;this.box.anchor=d?d.x+d.w/2:f/2,this.box.visualAxis=o/2;for(let u of this.lines)u.x-=this.box.anchor;this.repeatDots=n.map(u=>({x:u.x-this.box.anchor,y:u.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"})}},In="repeat.start";function _s(r,t){return r.visits(r.seek(In,t+1,-1)??0)}var On=class extends Fe{playbackMarks(){return this.ast.type===4?[]:[In]}playbackFlow(t){if(this.ast.type===3)return;let e=t(this);if(e!==void 0)return{range:[e,e],run:n=>n.visits(e)>1?void 0:{kind:"jump",column:n.seek(In,e,-1)??0}}}};var ks="div",Pt=It(ks);function bt(r,t){return`div.${r}.${t}`}function Ns(r,t){let e=r.ports[bt(t,"left")];e&&(e.state.claimed=!0)}function Bn(r){return Math.max(1,r*.055)}function*vs(r){for(let t=0;;t++){let e=!1,n=-1;for(let o=0;o<=r.length;o++){let s=r[o]?.ports,i=s?.[bt(t,"left")],c=s?.[bt(t,"right")];if((i||c)&&(e=!0),i&&c){n<0&&(n=o);continue}n>=0&&o-n>=2&&(yield{level:t,from:n,to:o-1}),n=-1}if(!e)return}}var Pn=class r extends L{static def={name:[ks,"/"],description:"\u51CF\u65F6\u7EBF",details:"~~~jpfun\n@div({1 2 -}, n=2, autobeam=true)\n~~~\n**\u7B80\u5199**\uFF1A\u5728\u76EE\u6807\u540E\u52A0 `/`\uFF0C\u53EF\u91CD\u590D\u6216\u4F5C\u7528\u4E8E\u5185\u5BB9\u5757\u3002`@div(1, 2)` \u7B49\u4EF7\u4E8E `1//`\uFF0C`@div({1 2/ -}, 2)` \u7B49\u4EF7\u4E8E `{1 2/ -}//`\u3002\u9ED8\u8BA4\u53C2\u6570\u4F7F\u7528 `div.n`\u3001`div.autobeam` \u8BBE\u7F6E\u3002",allowExtraArgs:!1,args:[{type:"content",description:"\u8981\u51CF\u65F6\u7684\u5185\u5BB9\uFF0C\u53EF\u5305\u542B\u591A\u4E2A\u97F3\u7B26\u6216\u589E\u65F6\u7EBF",default:null},{name:"n",description:"\u51CF\u65F6\u5C42\u6570\uFF0C\u6BCF\u7EA7\u5C06\u65F6\u503C\u51CF\u534A\uFF0C\u53D6\u975E\u8D1F\u6574\u6570",type:"number",default:1},{name:"autobeam",description:"\u662F\u5426\u53C2\u4E0E\u4E0D\u540C div \u4E4B\u95F4\u7684\u81EA\u52A8\u8FDE\u7EBF\uFF0C\u540C\u4E00 div \u5185\u90E8\u7684\u8FDE\u7EBF\u4E0D\u53D7\u5F71\u54CD",type:"boolean",default:!0}]};static deSugarAtom(t,e,n){let o=0,s=e;for(;s<n&&t[s]==="/";)o++,s++;return o===0?null:{next:s,node:{kind:"sugar",data:{class:r,n:o},span:{start:e,end:s}}}}static deSugarRelation(t,e,n){let o=e[n++];if(o.data?.class!==r)return null;let s=L.findLastFuncContentIndex(t.nodes,t.nodes.length-1);if(s<0)return n;let i=t.nodes[s];if(i instanceof r)return i.n+=o.data.n,n;let c=new Map;c.set(0,i),c.set("n",o.data.n);let a=i.sourceSpan,l=new r({start:Math.min(a.start,o.span.start),end:Math.max(a.end,o.span.end)},c,t,null);return t.nodes[s]=l,n}static layoutDecorationHandler=(t,e)=>{let n=Math.max(0,Math.floor(Number(e)||0));if(n===0)return null;let o=t.ast.size*.14,s=Bn(t.ast.size),i=(n-1)*o+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<n;p++){let f=l+p*o;t.ports[bt(p,"left")]={x:c,y:f,state:{claimed:!1}},t.ports[bt(p,"right")]={x:a,y:f}}}},paint(h){for(let p=0;p<n;p++){if(t.ports[bt(p,"left")].state.claimed)continue;let d=t.box.y+l+p*o;h.drawLine(t.box.x+c,d,t.box.x+a,d,{stroke:"#000",strokeWidth:s})}}}};loweringEnter(t){let e=this.n;return t.beginLoweringGroup(this,{onTemporal(n){if(e===0)return;let o=n.addon??={};o[Pt]=(Number(o[Pt])||0)+e,n.T.divPow2(e)}}),[]}loweringExit(t){return t.endLoweringGroup(this),[]}content;n;autoBeamEnabled;get children(){return[this.content]}timeFlowModel(){return{children:[this.content],mode:"sequence"}}constructor(t,e,n,o=null){super(t,o),[this.content,this.n,this.autoBeamEnabled]=this.getArgValue(e,n),this.content.parent=this;let s=Math.max(0,Math.trunc(this.n));s!==this.n&&(n.diagnostics.push(new P("W_DIV_INVALID_N",`@div \u7684\u6570\u91CF\u53C2\u6570 n \u5FC5\u987B\u4E3A\u975E\u8D1F\u6574\u6570\uFF0C\u5DF2\u88AB\u4FEE\u6B63\u4E3A ${s}`,this.sourceSpan)),this.n=s)}toString(t){return`@div(${this.content.toString(t)}, ${this.n})`}},Qt=Pn;function Jt(r,t,e){return new ye(r,t,e)}function Ms(r){let t=new Map,e=new Map;for(let n of r.columns)for(let o of n){if(!I(o)||o.mergeKey===nt&&o.T.isZero())continue;let s=t.get(o.layoutLine);s||(s=new Map,t.set(o.layoutLine,s));let i=s.get(o.track)??0;e.set(o,{line:o.layoutLine,track:o.track,index:i}),s.set(o.track,i+1)}for(let n of r.attachments)if(!(!(n instanceof ye)||!n.explicit))for(let o=1;o<n.endPoints.length;o++){let s=n.endPoints[o-1],i=n.endPoints[o];if(!I(s)||!I(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",n.sourceSpan)}}function Rs(r){let t=new Set;for(let e of r)if(!(!(e instanceof ye)||!e.explicit))for(let n of e.endPoints)t.add(n);return t}var ye=class{layer="foreground";endPoints;explicit;sourceSpan;fontSize;strokeWidth;constructor(t,e,n){this.endPoints=t,this.explicit=e,this.sourceSpan=n,this.fontSize=t.reduce((o,s)=>I(s)?Math.max(o,s.ast.size):o,0),this.strokeWidth=Bn(this.fontSize)}prepareHorizontal(t){let e;for(let n of this.endPoints)if(I(n)){if(e&&e.layoutLine===n.layoutLine&&e.track===n.track){let o=t[e.layoutLine],s=o?o.trackIndexOf(e):-1;s>=0&&s+1===o.trackIndexOf(n)&&(e.springConfig.alpha_R*=.8,n.springConfig.alpha_L*=.8)}e=n}}createGeometry(t){let e=this.collectLines(t),n=this.strokeWidth;return{regions:e.map(s=>({x:Math.min(s.start.x,s.end.x),y:s.start.y-n/2,w:Math.abs(s.end.x-s.start.x),h:n,line:s.line,track:s.track})),paint(s){for(let i of e)s.drawLine(i.start.x,i.start.y,i.end.x,i.end.y,{stroke:"#000",strokeWidth:n})}}}absolutePort(t,e){let n=t.ports[e];return{x:t.box.x+n.x,y:t.box.y+n.y}}collectLines(t){let e=[],n=this.endPoints.filter(I);if(n.length<2)return e;for(let{level:o,from:s,to:i}of vs(n)){let c=[];for(let a=s;a<=i;a++){let l=n[a];c.push({left:this.absolutePort(l,bt(o,"left")),right:this.absolutePort(l,bt(o,"right")),line:l.layoutLine,track:l.track,node:l})}this.addSystemLines(c,t,o,e)}if(e.length===0&&this.explicit){let o=this.fontSize*.12,s=n.map(i=>{let c={x:i.box.x+i.box.anchor,y:i.box.y+i.box.h+o};return{left:c,right:c,line:i.layoutLine,track:i.track,node:i}});this.addSystemLines(s,t,null,e)}return e}addSystemLines(t,e,n,o){let s=Math.min(...t.map(h=>h.line)),i=Math.max(...t.map(h=>h.line)),c=t[0].track,a=e.getVisualAxis(t[0].line,c),l=t[0].left.y-a;for(let h=s;h<=i;h++){let p=t.filter(y=>y.line===h).sort((y,g)=>y.left.x-g.left.x);if(p.length===0){let g=e.getVisualAxis(h,c)+l;o.push({start:{x:e.originX,y:g},end:{x:e.originX+e.width,y:g},line:h,track:c});continue}let f=p[0],d=p[p.length-1],u=f.left.y,m={x:f.left.x,y:u},x={x:d.right.x,y:u};if(h>s&&(m.x=e.originX),h<i&&(x.x=e.originX+e.width),!(m.x===x.x&&s===i)){if(n!==null)for(let y of p)Ns(y.node,n);o.push({start:m,end:x,line:h,track:f.track})}}}};function Pr(r){let t=Math.max(0,Math.floor(Number(r.addon?.[Pt])||0));if(t<=0)return[];let e=[],n=i=>{e.push(i),t-=Math.max(0,i.n)},o=r.ast.parent;for(;o&&t>0;)o instanceof Qt&&n(o),o=o.parent;if(t<=0)return e;let s=i=>{for(let c of i.children??[]){if(t<=0)return;c instanceof Qt&&n(c),s(c)}};return s(r.ast),e}function Br(r){let t=new Map,e=new Map;for(let n of r.columns)for(let o of n){if(!I(o))continue;let s=Pr(o);if(s.length===0)continue;let i=[];for(let c of s){let a=t.get(c);a||(a={owner:c,nodes:[]},t.set(c,a)),a.nodes.push(o),i.push(a)}e.set(o,i)}return{scopes:[...t.values()],nodeScopes:e}}function Dr(r){let t=new Set(r.map(e=>e.owner));return r.filter(e=>{let n=e.owner.parent;for(;n;){if(n instanceof Qt&&t.has(n))return!1;n=n.parent}return!0})}function Is(r,t){let e=1/0,n=-1/0;for(let o of r){e=Math.min(e,o.ast.sourceSpan.start),n=Math.max(n,o.ast.sourceSpan.end);for(let{owner:s}of t.get(o)??[])e=Math.min(e,s.sourceSpan.start),n=Math.max(n,s.sourceSpan.end)}return Jt(r,!1,{start:e,end:n})}function Fr(r,t,e){let n=[];for(let o of Dr(r)){let s=new Map;for(let i of o.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&&n.push(Is(c,t)),c=[]};for(let l of i){if(e.has(l)){a();continue}c.push(l)}a()}}return n}function $r(r){return Math.floor(r.numerator/r.denominator)}function zr(r,t,e){let n=[],o=new Map,s=new Map,i=new B,c=new B;for(let h of r.columns)for(let p of h){let f=s.get(p.layoutLine);(f===void 0||p.t.compare(f)<0)&&s.set(p.layoutLine,p.t)}let a=h=>{let p=o.get(h);p&&(o.delete(h),p.nodes.length>=2&&n.push(Is(p.nodes,t)))},l=()=>{for(let h of[...o.keys()])a(h)};for(let h of r.columns){let p=h.find(f=>f.mergeKey===nt);p&&(l(),i.copyFrom(p.t));for(let f of h){if(f.mergeKey===nt)continue;let d=I(f)?t.get(f):void 0,u=d?.every(E=>E.nodes.length===1)??!1,m=d?.every(E=>E.owner.autoBeamEnabled)??!1;if(!(I(f)&&u&&m&&f.T.compare(1)<0&&!e.has(f))){(I(f)||!f.T.isZero())&&a(f.track);continue}let y=s.get(f.layoutLine)??f.t,g=i.compare(y)>=0?i:y,b=$r(c.copyFrom(f.t).sub(g)),S=o.get(f.track),C=S&&f.t.equals(S.endTime);if(!S||f.layoutLine!==S.line||b!==S.beat||!C){a(f.track),o.set(f.track,{nodes:[f],line:f.layoutLine,beat:b,endTime:f.t.clone().add(f.T)});continue}S.nodes.push(f),S.endTime.copyFrom(f.t).add(f.T)}}return l(),n}function Os(r){let{scopes:t,nodeScopes:e}=Br(r);if(t.length===0)return[];let n=Rs(r.attachments);return[...Fr(t,e,n),...zr(r,e,n)]}var Dn=class extends L{static loweringAugment=Os;static loweringFinalize=Ms;static def={name:["beam"],description:"\u51CF\u65F6\u7EBF\u8FDE\u63A5",details:"\u4E8B\u540E\u5C06\u591A\u4E2A\u51CF\u65F6\u7EBF**\u5F3A\u884C**\u76F8\u8FDE\n~~~jpfun\n1/@a 2/@b | 3/@c @beam(a, b, c)\n~~~\n**\u4F4D\u7F6E\u53C2\u6570**\uFF1A\u5DF2\u6807\u8BB0\u97F3\u7B26\u7684\u6807\u7B7E\uFF0C\u6309\u4F20\u5165\u987A\u5E8F\u8FDE\u63A5\u51CF\u65F6\u7EBF\uFF0C\u663E\u5F0F\u6307\u5B9A\u4E00\u7EC4\u3002\u5148\u7528 `/` \u6216 `@div` \u4E3A\u76EE\u6807\u6DFB\u52A0\u51CF\u65F6\u7EBF\uFF0C\u518D\u7528 `@beam` \u63A7\u5236\u8FDE\u63A5\u3002\u7AEF\u70B9\u987B\u540C\u8F68\u3001\u540C\u8C31\u9762\u884C\u4E14\u76F8\u90BB\uFF0C\u53EF\u8DE8\u5C0F\u8282\u7EBF\uFF1B\u8FDE\u7EBF\u76F4\u63A5\u7A7F\u8FC7\u5C0F\u8282\u7EBF\uFF0C\u4FDD\u7559\u539F\u6709\u95F4\u8DDD\u3002",allowExtraArgs:!0,extraArgType:"label",args:[]};endPoints=[];constructor(t,e,n,o=null){super(t,o);for(let[,i]of e){let c=i instanceof L?i:n.parseArgWithType(i.valueSpan,"label",t.start);c instanceof L&&this.endPoints.push(c)}let s=n.labelableNodes.length-1;for(;this.endPoints.length<2&&s>=0;){let i=n.labelableNodes[s--];!i||this.endPoints.includes(i)||this.endPoints.unshift(i)}if(this.endPoints.length<2)throw new w("E_NOT_ENOUGH_ARGS","@beam \u81F3\u5C11\u9700\u8981\u4E24\u4E2A\u7AEF\u70B9",t)}loweringEnter(t){let e=[];for(let n of this.endPoints){let o=t.getTemporalNodes(n).at(-1);for(;o?.foldedInto;)o=o.foldedInto;o&&e.push(o)}return e.length<2?(t.diagnostics.push(M.warning.UnresolvedEndpoint("beam",this.sourceSpan)),[]):(t.addAttachment(Jt(e,!0,this.sourceSpan)),[])}},Ps=Dn;var Fn=class extends L{static def={name:["box"],description:"\u7ED9\u76EE\u6807\u7ED3\u6784\u6216\u5BF9\u8C61\u52A0\u5916\u6846",details:`~~~jpfun
|
|
13
13
|
@box({1 2 3}, padding=0.2em, stroke=0.08em)
|
|
14
|
-
~~~`,allowExtraArgs:!1,args:[{type:"content",description:"\u9700\u8981\u52A0\u6846\u7684\u5185\u5BB9\u6216\u7ED3\u6784",default:null},{name:"padding",description:"\u5185\u5BB9\u5230\u6846\u7EBF\u7684\u5185\u8FB9\u8DDD\uFF0C\u8D1F\u503C\u5411\u5185\u6536\u7F29",type:"length",default:{value:0,unit:"em"}},{name:"stroke",description:"\u6846\u7EBF\u5BBD\u5EA6",type:"length",default:{value:1,unit:"px"}},{name:"width",description:"\u7EA6\u675F\u5185\u90E8\u6392\u7248\u7684\u5BBD\u5EA6\uFF0C\u975E\u6B63\u503C\u8868\u793A\u968F\u5185\u5BB9\u81EA\u52A8\u786E\u5B9A",type:"length",default:{value:-1,unit:"px"}}]};target;padding;stroke;width;get children(){return[this.target]}timeFlowModel(){return{children:[this.target],mode:"sequence"}}loweringEnter(t){let e={nodes:[],attachments:[],onTemporal(n){
|
|
14
|
+
~~~`,allowExtraArgs:!1,args:[{type:"content",description:"\u9700\u8981\u52A0\u6846\u7684\u5185\u5BB9\u6216\u7ED3\u6784",default:null},{name:"padding",description:"\u5185\u5BB9\u5230\u6846\u7EBF\u7684\u5185\u8FB9\u8DDD\uFF0C\u8D1F\u503C\u5411\u5185\u6536\u7F29",type:"length",default:{value:0,unit:"em"}},{name:"stroke",description:"\u6846\u7EBF\u5BBD\u5EA6",type:"length",default:{value:1,unit:"px"}},{name:"width",description:"\u7EA6\u675F\u5185\u90E8\u6392\u7248\u7684\u5BBD\u5EA6\uFF0C\u975E\u6B63\u503C\u8868\u793A\u968F\u5185\u5BB9\u81EA\u52A8\u786E\u5B9A",type:"length",default:{value:-1,unit:"px"}}]};target;padding;stroke;width;get children(){return[this.target]}timeFlowModel(){return{children:[this.target],mode:"sequence"}}loweringEnter(t){let e={nodes:[],attachments:[],onTemporal(n){I(n)&&e.nodes.push(n)},onAttachment(n){e.attachments.push(n)}};return t.beginLoweringGroup(this,e),[]}loweringExit(t){let e=t.endLoweringGroup(this),n=new $n(e,this);t.addAttachment(n);let o=e.nodes[0];if(o){if(n.reservedHost){let i=o.prepareLayout;o.prepareLayout=c=>{i.call(o,c);let a={order:1/0,height:Math.max(0,this.padding+this.stroke/2)};o.decorations.push({above:a,below:a})}}let s=o.prepareHorizontal;o.prepareHorizontal=i=>{s?.call(o,i),n.registerHorizontal(i)}}return[]}constructor(t,e,n,o=null){super(t,o);let[s,i,c,a]=this.getArgValue(e,n);s.parent=this,this.target=s,this.padding=n.length2px(i),this.stroke=Math.max(0,n.length2px(c)),this.width=n.length2px(a)}toString(t){return`@box(${this.target.toString(t)}, padding=${this.padding}px, stroke=${this.stroke}px, width=${this.width}px)`}},Bs=Fn,$n=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[n]=t.nodes;t.nodes.length===1&&t.attachments.every(o=>o instanceof r&&o.reservedHost===n)&&(this.reservedHost=n)}registerHorizontal(t){let e=this.content.nodes,n=e[0];if(!n)return;if(e.some(a=>a.layoutLine!==n.layoutLine))throw new w("E_BOX_CROSS_LINE","@box \u7684\u5185\u5BB9\u4E0D\u80FD\u8DE8\u8D8A\u8C31\u9762\u884C",this.owner.sourceSpan);let o=n;for(let a of e){let l=t.columnOf(a);if(l<0)return;l<t.columnOf(n)&&(n=a),l>t.columnOf(o)&&(o=a)}let{width:s,padding:i,stroke:c}=this.owner;t.registerHorizontalLayoutHook(n,o,({columns:a,rows:l,start:h,end:p,X:f,fixed:d,options:u})=>{let m=b=>a[b].filter(S=>e.some(C=>C.box===S.box)),x=m(h),y=m(p);if(s>0){let b=Math.max(...x.map(E=>E.WL)),S=Math.max(...y.map(E=>E.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(d[h-1]||d[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 E=(s-b-S)/2;for(let k of x)k.WL+=E;for(let k of y)k.WR+=E;C[0]=b+E}else{jt(a.slice(h,p+1),l,C,d.subarray(h,p),s,u,0);let E=C[C.length-1]-C[0]+b+S;if(Math.abs(E-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=n,this.wallOffset=-C[0]}let g=i+c/2;for(let b of x)b.WL+=g;for(let b of y)b.WR+=g})}createGeometry(t){let{padding:e,stroke:n}=this.owner,o=t.getContentBounds(this.content);if(!o)return{regions:[],paint(){}};let s=e+n/2,c={x:(this.fixedStart?this.fixedStart.box.x+this.fixedStart.box.anchor+this.wallOffset:o.x)-s,y:o.y-s,w:(this.fixedStart?this.owner.width:o.w)+s*2,h:o.h+s*2};if(c.w<n||c.h<n)throw new w("E_BOX_PADDING_TOO_SMALL","@box \u7684\u8D1F\u5185\u8FB9\u8DDD\u4F7F\u8FB9\u6846\u5BBD\u5EA6\u6216\u9AD8\u5EA6\u5C0F\u4E8E\u96F6",this.owner.sourceSpan);return{regions:[c],occupancy:this.reservedHost?[]:this.occupancy(t,c),paint(a){let l=n/2;a.drawRect(c.x+l,c.y+l,Math.max(0,c.w-n),Math.max(0,c.h-n),{stroke:"#000",strokeWidth:n})}}}occupancy(t,e){let n=new Set,o,s=(a,l)=>{if(o!==void 0&&o!==a)throw new w("E_BOX_CROSS_LINE","@box \u7684\u5185\u5BB9\u4E0D\u80FD\u8DE8\u8D8A\u8C31\u9762\u884C",this.owner.sourceSpan);o=a,n.add(l)};for(let a of this.content.nodes)s(a.layoutLine,a.track);for(let a of this.content.attachments){if(!yt(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(o===void 0)return[];let i=o,c=[...n].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 zn=class extends L{static def={name:["dash","-"],description:"\u589E\u65F6\u7EBF",details:"~~~jpfun\n1 @dash()\n~~~\n\u65E0\u53C2\u6570\u3002\u6DFB\u52A0\u4E00\u6839\u589E\u65F6\u7EBF\uFF0C\u6269\u5C55\u524D\u65B9\u97F3\u7B26\u6216\u4F11\u6B62\u7B26\u7684\u5B8C\u6574\u65F6\u503C\uFF1B\u4E5F\u53EF\u7B80\u5199\u4E3A `1 -`\u3002\u6BCF\u6839\u7EBF\u7684\u57FA\u7840\u65F6\u503C\u4E3A\u4E00\u4E2A\u56DB\u5206\u97F3\u7B26\uFF0C\u53EF\u7528\u51CF\u65F6\u7EBF\u6216\u9644\u70B9\u8C03\u6574\u3002\u88C5\u9970\u97F3\u8986\u76D6\u5EF6\u957F\u540E\u7684\u5B8C\u6574\u97F3\u7B26\uFF0C\u4F8B\u5982 `1 ^ $tr -` \u5728\u4E24\u62CD\u5185\u6301\u7EED\u98A4\u97F3\u3002",allowExtraArgs:!1,args:[]};static deSugarAtom(t,e,n){if(t[e]!=="-")return null;let o={kind:"call",typed:!0,name:"-",args:new Map,span:{start:e,end:e+1},syntaxKind:"atom"};return{next:e+1,node:o}}size;constructor(t,e,n,o=null){super(t,o),this.size=n.variables.fontsize}loweringEnter(){return[new Hn(this)]}labelable(){return this}toString(){return"-"}},Ds=zn,Hn=class extends ${lineWidth=0;lineY=0;constructor(t){super(),this.ast=t,this.T.set(1),this.mergeKey=dt,this.initLayoutBox()}onTimeState(t){this.playbackState={bpm:t.bpm}}prepareLayout(){let t=this.ast.size;this.lineWidth=t*.42,this.box.w=this.lineWidth,this.box.h=t,this.box.anchor=this.lineWidth/2,this.lineY=t*.5,this.box.visualAxis=this.lineY}emitPlayback(t){let e=t.start.clone(),n=t.track,o=this.ast.sourceSpan;t.defer(s=>{let i;for(let c=s.spans.length-1;c>=0;c--){let a=s.spans[c];if(a.track===n){if(i===void 0){if(!a.end.equals(e))continue;i=a.origins[0]}else if(a.origins[0]!==i)break;a.end.equals(e)&&t.extend(a)}}i===void 0&&s.diagnostics.push(new P("W_PLAYBACK_SUSTAIN_WITHOUT_TARGET","\u589E\u65F6\u7EBF\u524D\u6CA1\u6709\u53EF\u5EF6\u7EED\u7684\u97F3\u6BB5",o))})}paint(t){t.drawLine(this.box.x,this.box.y+this.lineY,this.box.x+this.lineWidth,this.box.y+this.lineY,{stroke:"#000",strokeWidth:Math.max(1,this.ast.size*.1)})}};var zs="dot",Fs=It(zs);function $s(r){let t=2**r;return[2*t-1,t]}var Wn=class r extends L{static def={name:[zs,"."],description:"\u9644\u70B9",details:"~~~jpfun\n@dot(1, n=2)\n~~~\n**\u7B80\u5199**\uFF1A\u76EE\u6807\u540E\u52A0 `.`\uFF0C\u53EF\u91CD\u590D\u3002`@dot(1, 2)` \u7B49\u4EF7\u4E8E `1..`\uFF1B`{1^2}.` \u7B49\u4EF7\u4E8E `{1.^2}`\u3002\n\n`@dot({1 2/ -}, 2)` \u5305\u542B\u591A\u4E2A\u65F6\u95F4\u5143\u7D20\uFF0C\u4F1A\u62A5\u9519\uFF1B\u9700\u8981\u5206\u522B\u4E3A\u5404\u5143\u7D20\u6DFB\u52A0\u9644\u70B9\u3002",allowExtraArgs:!1,args:[{type:"content",description:"\u5355\u4E2A\u53EF\u89C1\u65F6\u95F4\u5143\u7D20\uFF0C\u5982\u97F3\u7B26\u3001\u589E\u65F6\u7EBF\u6216\u6298\u53E0\u548C\u5F26",default:null},{name:"n",description:"\u9644\u70B9\u6570\uFF0C\u7B2C\u4E00\u70B9\u589E\u52A0\u539F\u65F6\u503C\u7684\u4E00\u534A\uFF0C\u540E\u7EED\u5404\u70B9\u589E\u52A0\u91CF\u518D\u51CF\u534A",type:"number",default:1}]};static deSugarAtom(t,e,n){let o=0,s=e;for(;s<n&&t[s]===".";)o++,s++;return o===0?null:{next:s,node:{kind:"sugar",data:{class:r,n:o},span:{start:e,end:s}}}}static deSugarRelation(t,e,n){let o=e[n++];if(o.data?.class!==r)return null;let s=L.findLastFuncContentIndex(t.nodes,t.nodes.length-1);if(s<0)return n;let i=t.nodes[s];if(i instanceof r)return i.n+=o.data.n,n;let c=new Map;c.set(0,i),c.set("n",o.data.n);let a=i.sourceSpan,l=new r({start:Math.min(a.start,o.span.start),end:Math.max(a.end,o.span.end)},c,t,null);return t.nodes[s]=l,n}static layoutDecorationHandler=(t,e)=>{let n=Math.max(0,Math.floor(Number(e)||0));if(n===0)return null;let o=t.ast.size*.075,s=t.ast.size*.12,i=t.ports.dot??{x:t.box.w,y:t.box.visualAxis},c=i.x+s+o,a=o*2+s,l=c+(n-1)*a+o;return t.box.w=Math.max(t.box.w,l),{paint(h){let p=t.box.y+i.y;for(let f=0;f<n;f++)h.drawCircle(t.box.x+c+f*a,p,o,{fill:"#000"})}}};loweringEnter(t){let e=this.n,n={temporalCount:0,onTemporal(o){if(n.temporalCount++,e===0)return;let s=o.addon??={},i=Number(s[Fs])||0,c=i+e,[a,l]=$s(c),[h,p]=$s(i);o.T.mul(a*p,l*h),s[Fs]=c}};return t.beginLoweringGroup(this,n),[]}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 ${e.temporalCount} \u4E2A`,this.sourceSpan);return[]}timeFlowModel(){return{children:[this.content],mode:"sequence"}}content;n;get children(){return[this.content]}constructor(t,e,n,o=null){super(t,o),[this.content,this.n]=this.getArgValue(e,n),this.content.parent=this;let s=Math.max(0,Math.trunc(this.n));s!==this.n&&(n.diagnostics.push(new P("W_DOT_INVALID_N",`@dot \u7684\u6570\u91CF\u53C2\u6570 n \u5FC5\u987B\u4E3A\u975E\u8D1F\u6574\u6570\uFF0C\u5DF2\u88AB\u4FEE\u6B63\u4E3A ${s}`,this.sourceSpan)),this.n=s)}toString(t){return`@dot(${this.content.toString(t)}, ${this.n})`}},Hs=Wn;var Gn=class extends L{static def={name:["dyn"],description:"\u6E10\u5F3A\u6E10\u5F31",details:`~~~jpfun
|
|
15
15
|
1 ^ $p 2@a 3 4@b
|
|
16
16
|
@dyn(a, b, 24)
|
|
17
17
|
~~~
|
|
18
18
|
\u7AEF\u70B9\u987B\u4F4D\u4E8E\u540C\u4E00\u97F3\u8F68\u3001\u4E0D\u540C\u65F6\u95F4\uFF1B\u53D8\u5316\u91CF\u6CBF\u533A\u95F4\u7EBF\u6027\u589E\u52A0\uFF0C\u53E0\u52A0\u5728\u6BCF\u4E2A\u97F3\u7B26\u539F\u6709\u529B\u5EA6\u4E0A\u3002\u672C\u4F8B\u4ECE \`a\` \u5230 \`b\` \u6E10\u5F3A\uFF0C\u7EC8\u70B9\u589E\u52A0 24 \u7684\u529B\u5EA6\u3002
|
|
19
19
|
|
|
20
|
-
\u7AEF\u70B9\u4E5F\u53EF\u6807\u5728\u589E\u65F6\u7EBF\u4E0A\u3002\u7EC8\u70B9\u6CA1\u6709\u529B\u5EA6\u65F6\uFF0C\u53D6\u540C\u8F68\u3001\u4E0D\u665A\u4E8E\u7EC8\u70B9\u7684\u6700\u540E\u4E00\u4E2A\u539F\u59CB\u529B\u5EA6\u4F5C\u4E3A\u4FDD\u6301\u57FA\u51C6\uFF1B\u627E\u4E0D\u5230\u65F6\u7ED9\u51FA\u8B66\u544A\u5E76\u4EC5\u7ED8\u5236\u3002\u589E\u65F6\u7EBF\u5EF6\u7EED\u7684\u97F3\u7B26\u4FDD\u6301\u8D77\u97F3\u65F6\u7684\u529B\u5EA6\u3002`,allowExtraArgs:!1,args:[{name:"from",description:"\u6E10\u53D8\u8D77\u70B9\u7684\u6807\u7B7E",type:"label",default:null},{name:"to",description:"\u6E10\u53D8\u7EC8\u70B9\u7684\u6807\u7B7E",type:"label",default:null},{name:"dv",description:"\u529B\u5EA6\u53D8\u5316\u91CF\uFF0C\u6B63\u6570\u6E10\u5F3A\uFF0C\u8D1F\u6570\u6E10\u5F31",type:"number",default:null}]};static loweringFinalize=t=>{let e=t.attachments.filter(o=>o instanceof ae);if(e.length===0)return;let n=[];for(let o of t.astToTemporal.values())for(let s of o){let r=s.playbackState?.velocity;if(r===void 0)continue;let c=s;for(;c.foldedInto;)c=c.foldedInto;n.push({node:s,host:c,velocity:r,increment:0})}n.sort((o,s)=>o.host.t.compare(s.host.t)||o.node.order-s.node.order);for(let o of e){let s=o.end.playbackState?.velocity??n.find(a=>a.host===o.toHost)?.velocity;for(let a=n.length-1;s===void 0&&a>=0;a--){let l=n[a];l.host.track===o.track&&l.host.t.compare(o.toHost.t)<=0&&(s=l.velocity)}if(s===void 0){t.diagnostics.push(new O("W_DYN_NO_VELOCITY","@dyn \u7EC8\u70B9\u53CA\u6B64\u524D\u540C\u8F68\u6CA1\u6709\u53EF\u7528\u7684\u529B\u5EA6\u57FA\u51C6\uFF0C\u4EC5\u7ED8\u5236\u6E10\u53D8\u7EBF",o.sourceSpan));continue}let r=n.find(a=>a.host.track===o.track&&a.host.t.compare(o.toHost.t)>0&&a.velocity!==s)?.host.t,c=o.toHost.t.clone().sub(o.fromHost.t);for(let a of n){if(a.host.track!==o.track||a.host.t.compare(o.fromHost.t)<0||r&&a.host.t.compare(r)>=0)continue;let h=a.host.t.compare(o.toHost.t)>=0?1:a.host.t.clone().sub(o.fromHost.t).div(c).toNumber();a.increment+=o.dv*h}}for(let o of n){if(o.increment===0)continue;let s=Math.max(1,Math.min(127,o.velocity+o.increment));o.node.playbackState={...o.node.playbackState,velocity:s}}};from;to;dv;size;loweringEnter(t){let e=t.getTemporalNodes(this.from).at(0),n=t.getTemporalNodes(this.to).at(-1);if(!e||!n)return t.diagnostics.push(N.warning.UnresolvedEndpoint("dyn",this.sourceSpan)),[];let o=e,s=n;for(;o.foldedInto;)o=o.foldedInto;for(;s.foldedInto;)s=s.foldedInto;if(!F(o)||!F(s))return t.diagnostics.push(N.warning.UnresolvedEndpoint("dyn",this.sourceSpan)),[];if(o.track!==s.track)throw new S("E_DYN_CROSS_TRACK","@dyn \u7684\u4E24\u4E2A\u7AEF\u70B9\u5FC5\u987B\u4F4D\u4E8E\u540C\u4E00\u97F3\u8F68",this.sourceSpan);if(o.t.equals(s.t))throw new S("E_DYN_ZERO_SPAN","@dyn \u7684\u4E24\u4E2A\u7AEF\u70B9\u5FC5\u987B\u4F4D\u4E8E\u4E0D\u540C\u65F6\u95F4",this.sourceSpan);return o.t.compare(s.t)<0?t.addAttachment(new ae(this,n,o,s)):t.addAttachment(new ae(this,e,s,o)),[]}constructor(t,e,n,o=null){super(t,o);let[s,r,c]=this.getArgValue(e,n),a=c;if(!Number.isFinite(a)||a===0)throw new S("E_DYN_INVALID_DELTA","@dyn \u7684 dv \u5FC5\u987B\u662F\u975E\u96F6\u6709\u9650\u6570",t);a=Math.max(-127,Math.min(127,a)),a!==c&&n.diagnostics.push(new O("W_DYN_DELTA_CLAMPED",`@dyn \u7684 dv \u5FC5\u987B\u5728 -127 \u5230 127 \u4E4B\u95F4\uFF0C\u5DF2\u88AB\u9650\u5236\u4E3A ${a}`,t)),this.from=s,this.to=r,this.dv=a,this.size=n.variables.fontsize}toString(t){let e=n=>n.label??n.toString(t);return`@dyn(${e(this.from)}, ${e(this.to)}, ${this.dv})`}},ps=vn,ae=class{ast;end;fromHost;toHost;layer="foreground";constructor(t,e,n,o){this.ast=t,this.end=e,this.fromHost=n,this.toHost=o}get sourceSpan(){return this.ast.sourceSpan}get endPoints(){return[this.fromHost,this.toHost]}get dv(){return this.ast.dv}get track(){return this.fromHost.track}createGeometry(t){let e=this.fromHost.layoutLine,n=this.toHost.layoutLine,o=[this.fromHost,this.toHost],s=[],r=this.ast.size;for(let u=e;u<=n;u++){let g=t.getRangeColumns(u,o,this.track);if(g.some(y=>y.length>0)){for(let y of g)for(let x of y)r=Math.max(r,x.ast.size);s.push({line:u,startX:u===e?this.fromHost.box.x:this.lineEntryX(t,u),endX:u===n?this.toHost.box.x+this.toHost.box.w:this.lineRightX(t,u)})}}for(let u of s)u.line>e&&(u.startX-=r/4);let c=Math.max(.75,r*.035),a=s.filter(u=>u.startX!==u.endX),l=a.reduce((u,g)=>u+Math.abs(g.endX-g.startX),0);if(l===0)return{regions:[],paint(){}};let h=r*.4,p=c/2,f=0,d=a.map(u=>{let g=Math.abs(u.endX-u.startX),y=f/l,x=(f+g)/l;f+=g;let m=t.getRangeExtents(u.line,o,this.track),b=t.getVisualAxis(u.line,this.track),w=m?b+m.top:b;return{line:u.line,startX:u.startX,endX:u.endX,lineY:w-r*.62,startOpen:h*(this.dv>0?y:1-y),endOpen:h*(this.dv>0?x:1-x)}});return{regions:d.map(u=>({x:Math.min(u.startX,u.endX)-p,y:u.lineY-Math.max(u.startOpen,u.endOpen)/2-p,w:Math.abs(u.endX-u.startX)+c,h:Math.max(u.startOpen,u.endOpen)+c,line:u.line,track:this.track})),paint(u){let g={stroke:"#000",strokeWidth:c};for(let y of d)u.drawLine(y.startX,y.lineY-y.startOpen/2,y.endX,y.lineY-y.endOpen/2,g),u.drawLine(y.startX,y.lineY+y.startOpen/2,y.endX,y.lineY+y.endOpen/2,g)}}}lineEntryX(t,e){return t.lines[e].trackRuns.get(this.track)?.find(o=>!o.T.isZero())?.box.x??t.originX}lineRightX(t,e){let n=t.lines[e].trackRuns;if(n.size===0)return t.originX+t.width;let o=t.originX;for(let s of n.values())for(let r of s)o=Math.max(o,r.box.x+r.box.w);return o}};var _t=class i{parent;groups=[];constructor(t=null){this.parent=t}group(t,e){let n=this.groups.find(o=>o.laneKey===t.laneKey);for(n||(n={laneKey:t.laneKey,members:[],measure:t.measure,place:t.place},this.groups.push(n));n.members.length<e;)n.members.push(new i(this));return n}};var Ut=.7,fs="shoulder";function ds(i,t){let e=i;typeof e.size=="number"&&(e.size*=t);for(let n of i.children??[])ds(n,t)}var Nn=class i extends v{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 v.findLabelable(this.host)}static deSugarAtom(t,e,n){let o=t[e];switch(o){case">":o="pre";break;case"<":o="post";break;default:return null}return{next:e+1,node:{kind:"sugar",data:{class:i,side:o},span:{start:e,end:e+1}}}}static deSugarRelation(t,e,n){let o=e[n++];if(o.kind!=="sugar"||o.data?.class!==i)return null;let s=o.data.side,r=t.nodes.length-1;for(;r>=0&&t.nodes[r]instanceof Z;)r--;if(r<0)throw new S("E_GRACE_NO_TARGET","@grace\u8BED\u6CD5\u7CD6\u9519\u8BEF: \u5DE6\u8FB9\u6CA1\u6709\u627E\u5230\u76EE\u6807",o.span);let c=t.nodes[r],a=r;if(c instanceof lt){let h=c.target;for(;h&&!t.nodes.includes(h);)h=h.parent;for(let p=r-1;p>=0;p--)if(t.nodes[p]===h){c=new K({start:h.sourceSpan.start,end:c.sourceSpan.end},t.nodes.slice(p,r+1),null),a=p;break}}let l=t.nodes;t.nodes=[],t.makeNodes(e,n);for(let h=0;h<t.nodes.length;h++){let p=t.nodes[h];if(p instanceof Z)continue;let f=s==="pre"?i.attachPre(c,p,o.span,t):i.create(t,o.span,"post",c,p);for(l.length=a,l.push(f);++h<t.nodes.length;)l.push(t.nodes[h]);return t.nodes=l,e.length}throw new S("E_GRACE_NO_TARGET","@grace\u8BED\u6CD5\u7CD6\u9519\u8BEF: \u53F3\u8FB9\u6CA1\u6709\u627E\u5230\u76EE\u6807",o.span)}host;grace;side="pre";size;static attachPre(t,e,n,o){if(e instanceof i&&e.side==="pre"){let s=e,r=1;for(;s.grace instanceof i&&s.grace.side==="pre";)s=s.grace,r++;let c=new Map;c.set(0,s.grace),c.set(1,t);let a=Ut**r,l=new i(n,c,o,null,Ut*a);return l.size*=a,s.setGrace(l,1),e}return i.create(o,n,"pre",e,t)}static create(t,e,n,o,s){let r=new Map;return r.set(0,o),r.set(1,s),r.set("side",n),new i(e,r,t)}get children(){let t=[];return this.host&&t.push(this.host),this.grace&&t.push(this.grace),t}constructor(t,e,n,o=null,s=Ut){if(super(t,o),this.size=n.variables.fontsize,[this.host,this.grace,this.side]=this.getArgValue(e,n),this.side!=="pre"&&this.side!=="post")throw new S("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=Ut){ds(t,e),this.grace=t,this.adopt(t)}adopt(t){t.parent=this,this.sourceSpan.start=Math.min(this.sourceSpan.start,t.sourceSpan.start),this.sourceSpan.end=Math.max(this.sourceSpan.end,t.sourceSpan.end)}loweringEnter(t,e){let n=this.host,o=this.grace;if(!n||!o)throw new S("E_GRACE_MISSING_ARGS","@grace \u9700\u8981\u540C\u65F6\u7ED9\u51FA\u5BBF\u4E3B\u548C\u501A\u97F3",this.sourceSpan);let s=new _t(e),r=[],c=[],a=[],l=(d,u)=>t.trackedEvents(d,new I,u);t.isolateFromLoweringGroups(()=>{this.side==="post"&&(r=l(n,e).flat()),t.beginLoweringGroup(this,{onAttachment(d){a.push(d)}}),c=l(o,s),t.endLoweringGroup(this),this.side==="pre"&&(r=l(n,e).flat())});let[h]=r;if(r.length!==1||!F(h))throw new S("E_GRACE_INVALID_HOST","@grace \u7684\u5BBF\u4E3B\u5FC5\u987B\u6070\u597D\u4EA7\u751F\u4E00\u4E2A\u53EF\u89C1 Temporal",n.sourceSpan);let p=c.flat();if(!p.some(F)||p.some(d=>d.breakBefore>0))throw new S("E_GRACE_INVALID_CONTENT","@grace \u7684\u501A\u97F3\u81F3\u5C11\u4EA7\u751F\u4E00\u4E2A\u53EF\u89C1\u5BF9\u8C61\uFF0C\u4E14\u4E0D\u80FD\u6362\u884C",o.sourceSpan);let f=new kn(this,h,c,s,a,this.side);for(let d of f.graceRuns)d.length<2||t.addAttachment(Kt([...d],!1,o.sourceSpan));return[f]}toString(t){let e=this.host?.toString(t)??"",n=this.grace?.toString(t)??"";return`@grace(${e}, ${n}, side=${this.side})`}},xs=Nn,nr=[{op:"M",x:0,y:0},{op:"C",cx1:-.01,cy1:.26,cx2:.14,cy2:.42,x:.29,y:.36}],or=.07,sr=.18,us=new I(3,4),kn=class extends W{host;graceColumns;graces;graceRuns;side;root;attachments;events;starts;hostOffset={x:0,y:0};graceOffsets=[];hookOrigin=null;constructor(t,e,n,o,s,r){super(),this.ast=t,this.host=e,this.root=o,this.attachments=s,this.side=r,this.T.copyFrom(e.T),this.mergeKey=e.mergeKey,this.initLayoutBox(),e.addon&&(this.addon={...e.addon}),e.addon=void 0,e.foldedInto=this;let c=[],a=[],l=[];for(let f of n){let d=f[0].t.clone().divPow2(),u=[];for(let g of f)g.foldedInto=this,a.push(g),l.push(d),F(g)&&u.push(g);u.length>0&&c.push(u)}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 d=h.get(f.track);d||(h.set(f.track,d=[]),p.push(d)),d.push(f);let u=f.addon={...f.addon};u[Et]=(Number(u[Et])||0)+1,f.T.divPow2()}this.graceRuns=p}onTimeState(t){this.host.T.copyFrom(this.T);for(let e of this.side==="pre"?[...this.events,this.host]:[this.host,...this.events])e.t.copyFrom(this.t),e.layoutLine=this.layoutLine,e.onTimeState?.(t)}emitPlayback(t){let e=new I,n=new I;this.events.forEach((h,p)=>{n.copyFrom(this.starts[p]).add(h.T),n.compare(e)>0&&e.copyFrom(n)});let o=e.compare(us)>0?us:e,s=t.end.clone().sub(t.start),r=s.clone().mul(o),c=s.sub(r),a=e.isZero()?new I:r.clone().div(e),l=this.side==="pre"?t.start.clone():t.start.clone().add(c);this.side==="post"&&t.play(this.host,t.start.clone(),c),this.events.forEach((h,p)=>{t.play(h,this.starts[p].clone().mul(a).add(l),h.T.clone().mul(a))}),this.side==="pre"&&t.play(this.host,l.add(r),c)}prepareLayout(t){this.addon&&(this.host.addon=this.addon,this.addon=void 0);let e=t.layoutSubdomain(this,this.graceColumns,this.root,this.attachments),n=Gt([this.host],t),o=this.ast.size*Ut,s=o*.2,r=o*sr,a=(this.host.ports[fs]?.y??0)-r-e.height,l=Math.max(0,-a),h=this.side==="pre"?0:n+s;this.hostOffset={x:this.host.box.x+(this.side==="pre"?e.width+s:0),y:l},this.graceOffsets=e.positions.map(d=>({x:h+d.x,y:a+l+d.y})),this.box.w=n+s+e.width,this.box.h=l+this.host.box.h,this.box.anchor=this.hostOffset.x+this.host.box.anchor,this.box.visualAxis=l+this.host.box.visualAxis;for(let d in this.host.ports){let u=this.host.ports[d];this.ports[d]={...u,x:this.hostOffset.x+u.x,y:this.hostOffset.y+u.y}}this.ports[fs]??={x:this.box.anchor,y:this.hostOffset.y};let p=this.graces.filter(d=>!d.T.isZero()),f=this.side==="pre"?p.at(-1):p[0];this.hookOrigin=f?{x:this.graceOffsets[this.graces.indexOf(f)].x+f.box.anchor,y:Math.max(...this.graces.map((d,u)=>this.graceOffsets[u].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 r of s.decorations)r.paint(t)}if(!this.hookOrigin)return;let e=this.ast.size*Ut,n=this.hookOrigin,o=this.side==="pre"?1:-1;t.drawPath(nr,{stroke:"#000",strokeWidth:Math.max(.8,e*or)},{x:this.box.x+n.x,y:this.box.y+n.y,scaleX:e*o,scaleY:e})}};var jt="sans-serif",Rn="'Cascadia Mono', Consolas, 'Liberation Mono', 'Noto Sans Mono', monospace";function Ne(i){return`${i.fontWeight??"normal"} ${i.fontSize}px ${i.fontFamily??jt}`}var ve=class{measureText(t,e){let n=e.fontSize,o=e.fontFamily?.toLowerCase().includes("mono")??!1,s=0;for(let r of t)s+=r.charCodeAt(0)>127?1:o?.62:.58;return{w:Math.max(s*n,n*.25),h:n,baseline:n*.8}}},On=new ve,Mn=class{context;widths=new Map;constructor(t){this.context=t}clearCache(){this.widths.clear()}measureText(t,e){let n=Ne(e),o=`${n}\0${t}`,s=this.widths.get(o);return s===void 0&&(this.context.font=n,s=this.context.measureText(t).width,this.widths.set(o,s)),{w:Math.max(s,e.fontSize*.25),h:e.fontSize,baseline:e.fontSize*.8}}};var ir=/[A-Za-z0-9_./-]/;function he(i,t,e){let n=t+1;for(;n<e&&ir.test(i[n]);)n++;let o=i.slice(t+1,n);if(!o||n>=e||i[n]!=="(")return null;let s=n,r=1,c=0,a=null,l=!1,h=[],p=s+1,f=(u,g,y=!1)=>{let x=le(i,p,u);if(!y&&x.start>=x.end)return;let m=rr(i,x.start,x.end),b=m>x.start?le(i,x.start,m):void 0,w=m>x.start?le(i,m+1,x.end):x;h.push({span:x,valueSpan:w,nameSpan:b,equalsSpan:m>x.start?{start:m,end:m+1}:void 0,commaSpan:g===void 0?void 0:{start:g,end:g+1}})},d=(u,g)=>({name:o,span:{start:t,end:u},nameSpan:{start:t,end:s},openParenSpan:{start:s,end:s+1},closeParenSpan:g,args:h});for(n++;n<e;n++){let u=i[n];if(a){l?l=!1:u==="\\"?l=!0:u===a&&(a=null);continue}if(u==='"'){a=u;continue}if(u==="{")c++;else if(u==="}")c=Math.max(0,c-1);else if(u==="("&&c===0)r++;else if(u===")"&&c===0){if(--r)continue;return f(n),d(n+1,{start:n,end:n+1})}else u===","&&r===1&&c===0&&(f(n,n,!0),p=n+1)}return f(e),d(e)}var ms=/\s/;function le(i,t,e){let n=t,o=e;for(;n<o&&ms.test(i[n]);)n+=1;for(;o>n&&ms.test(i[o-1]);)o-=1;return{start:n,end:o}}function rr(i,t=0,e=i.length){let n=0,o=0,s=null,r=!1;for(let c=t;c<e;c++){let a=i[c];if(s){r?r=!1:a==="\\"?r=!0:a===s&&(s=null);continue}if(a==='"')s=a;else if(a==="("&&o===0)n++;else if(a===")"&&o===0)n=Math.max(0,n-1);else if(a==="{")o++;else if(a==="}")o=Math.max(0,o-1);else if(a==="="&&n===0&&o===0)return c}return-1}function ys(i,t,e){let n=1,o=null,s=!1;for(let r=t;r<e;r++){let c=i[r];if(o){s?s=!1:c==="\\"?s=!0:c===o&&(o=null);continue}if(c==='"')o=c;else if(c==="(")n++;else if(c===")"&&--n===0)return r}return-1}function gt(i,t,e){for(let n=t+1;n<e;n++)if(i[n]==="\\")n++;else if(i[n]==='"')return n;return-1}function vt(i){return i.length<2||!i.startsWith('"')||!i.endsWith('"')?i:i.slice(1,-1).replace(/\\(.)/gs,"$1")}function rt(i){return`"${i.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function gs(i,t,e){let n=1,o=null,s=!1;for(let r=t+1;r<e;r++){let c=i[r];if(o){s?s=!1:c==="\\"?s=!0:c===o&&(o=null);continue}if(c==='"')o=c;else if(c==="{")n++;else if(c==="}"&&(n--,n===0))return r}return-1}var cr=/\s|\(|\)|\{|\}|,/;function bs(i,t,e){let n=t+1;for(;n<e&&!cr.test(i[n]);)n++;return n<=t+1?null:{label:i.slice(t+1,n),next:n}}var ar=/^(-?(?:\d+(?:\.\d*)?|\.\d+))([a-z%]+)?$/i,lr=["em","px"];function In(i){let t=i.match(ar);if(!t)return N.warning.InvalidLength(i,{start:0,end:i.length});let e=parseFloat(t[1]);if(!Number.isFinite(e))return N.warning.InvalidLength(i,{start:0,end:i.length});if(t[2]){let n=t[2].toLowerCase();return lr.includes(n)?{value:e,unit:n}:N.warning.InvalidLengthUnit(n,{start:t[1].length,end:i.length})}else return{value:e,unit:"px"}}var ws=/^(true|false)$/;function hr(i,t){if(i)return i==="content"?void 0:i;if(ws.test(t))return"boolean";if(t.startsWith('"'))return"string";if(!isNaN(Number(t)))return"number";if(!(In(t)instanceof N))return"length"}var Ss=22,pr=4,ct=class i{static systemVariables={fontsize:{type:"length",default:Ss},font:{type:"string",default:jt},numberfont:{type:"string",default:Rn},strict:{type:"boolean",default:!1}};scopeDepth;source;syntax;diagnostics;variables;documentDeclarations;functions;deSugarAtomFns;deSugarRelationFns;labelableNodes;nodes;constructor(t){t instanceof i?(this.scopeDepth=t.scopeDepth+1,this.documentDeclarations=t.documentDeclarations,this.source=t.source,this.diagnostics=t.diagnostics,this.syntax=t.syntax,this.variables={...t.variables},this.functions=t.functions,this.deSugarAtomFns=t.deSugarAtomFns,this.deSugarRelationFns=t.deSugarRelationFns,this.labelableNodes=t.labelableNodes,this.nodes=[]):(this.scopeDepth=0,this.documentDeclarations={},this.source=t.source,this.diagnostics=t.diagnostics??[],this.syntax={tokens:(t.commentSpans??[]).map(e=>({kind:"comment",span:e})),calls:[]},this.variables=Object.fromEntries(Object.entries(i.systemVariables).map(([e,n])=>[e,n.default])),Object.assign(this.variables,t.variables),this.functions=t.functions??new Map,this.labelableNodes=t.labelableNodes??[],this.nodes=t.toConsume??[],t.functions?[this.deSugarAtomFns,this.deSugarRelationFns]=i.getDeSugarFns(this.functions.values()):(this.deSugarAtomFns=[],this.deSugarRelationFns=[]))}static getDeSugarFns(t){let e=new Set(t),n=[],o=[];for(let s of e){let r=s.deSugarAtom;r&&r!==v.deSugarAtom&&n.push(r);let c=s.deSugarRelation;c&&c!==v.deSugarRelation&&o.push(c)}return[n,o]}pushNode(t){this.nodes.push(t);let e=t.labelable?.();e!==void 0&&this.labelableNodes.push(e)}setVariable(t,e){Object.hasOwn(i.systemVariables,t)&&(t==="fontsize"&&e&&(e=this.length2px(e)),(e===void 0||e===""||e===0)&&(e=i.systemVariables[t].default)),this.variables[t]=e}registerFunctions(t){let e=this.functions;for(let n of t){let o=n.def;if(!o)continue;let s=Array.isArray(o.name)?o.name:[o.name];for(let r of s){if(e.has(r.toLowerCase()))throw new Error(`Duplicate function name detected: ${r}`);e.set(r.toLowerCase(),n)}}[this.deSugarAtomFns,this.deSugarRelationFns]=i.getDeSugarFns(this.functions.values())}parse(t=0,e=this.source.length){return this.makeNodes(this.parseGrammar(t,e)),this.nodes}parseSyntax(t=0,e=this.source.length){if(this.parseGrammar(t,e,!0),this.scopeDepth===0){let n=(o,s)=>o.span.start-s.span.start||o.span.end-s.span.end;this.syntax.tokens.sort(n),this.syntax.calls.sort(n)}return this.syntax}addSyntax(t,e){e&&e.start<e.end&&this.syntax.tokens.push({kind:t,span:e})}recordSyntax(t){if(t.kind==="brace"){this.addSyntax("punctuation",{start:t.span.start,end:t.span.start+1});let c=Math.min(this.source.length,t.span.end-1);this.source[c]==="}"&&this.addSyntax("punctuation",{start:c,end:c+1}),new i(this).parseSyntax(t.span.start+1,c);return}if(t.kind==="label"){this.addSyntax("label",t.span);return}if(t.kind==="sugar"||t.typed){this.addSyntax(t.syntaxKind??"operator",t.span);return}let{kind:e,typed:n,syntaxKind:o,...s}=t;this.syntax.calls.push(s),this.addSyntax("function",s.nameSpan),this.addSyntax("punctuation",s.openParenSpan),this.addSyntax("punctuation",s.closeParenSpan);let r=this.functions.get(s.name.toLowerCase())?.def;for(let c=0;c<s.args.length;c++){let a=s.args[c];this.addSyntax("property",a.nameSpan),this.addSyntax("punctuation",a.equalsSpan),this.addSyntax("punctuation",a.commaSpan);let l=a.nameSpan?this.source.slice(a.nameSpan.start,a.nameSpan.end).toLowerCase():void 0,h=r&&$t(r,l,c);if(h==="content")new i(this).parseSyntax(a.valueSpan.start,a.valueSpan.end);else{let p=this.source.slice(a.valueSpan.start,a.valueSpan.end),f=hr(h,p);f&&this.addSyntax(f,a.valueSpan)}}}makeNodes(t,e=0,n=t.length){t:for(;e<n;e++){let o=t[e];if(typeof o=="number"){let s=this.nodes.at(-1);s instanceof Z&&s.sourceSpan.end===o?s.sourceSpan.end=o+1:this.nodes.push(new Z({start:o,end:o+1},null));continue}switch(o.kind){case"call":this.pushNode(this.parseCallNode(o));break;case"brace":let s=new i(this);this.nodes.push(new K(o.span,s.parse(o.span.start+1,o.span.end-1),null));break;case"label":let r=this.labelableNodes.at(-1);r?r.label!==void 0?this.diagnostics.push(N.warning.TargetAlreadyLabeled(o.label,r.label,o.span)):(r.label=o.label,this.nodes.push(new lt(o.span,o.label,r))):this.diagnostics.push(N.warning.LabelWithoutTarget(o.label,o.span));break;case"sugar":for(let a of this.deSugarRelationFns){let l=a(this,t,e);if(l!==null){e=l-1;continue t}}let c=this.nodes.at(-1);c instanceof Z&&c.sourceSpan.end===o.span.start?c.sourceSpan.end=o.span.end:this.nodes.push(new Z(o.span,null));break}}return e}parseGrammar(t,e,n=!1){let o=[],s=r=>{o.push(r),n&&this.recordSyntax(r)};t:for(;(t=ut(this.source,t,e))<e;){let r=this.source[t];if(r==="@"){let c=he(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=N.error.PosAfterNamedArg(c.name,h.span);if(!n)throw f;this.diagnostics.push(f)}}if(!c.closeParenSpan){let h=N.error.UnterminatedCall(c.name,c.span);if(!n)throw h;this.diagnostics.push(h)}t=c.span.end;continue}let a=bs(this.source,t,e);if(a){s({kind:"label",span:{start:t,end:a.next},label:a.label}),t=a.next;continue}}if(r==="{"){let c=gs(this.source,t,e);(c<0||c>=e||c<=t)&&(this.diagnostics.push(N.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 N?this.diagnostics.push(a):this.diagnostics.push(N.error.Bug(a.toString(),{start:t,end:e})),a}o.push(t++)}return o}parseCallNode(t){let e=this.functions.get(t.name.toLowerCase()),n=e?.def;if(!e||!n){if(this.variables.strict)throw N.error.UnknownFunction(t.name,t.span);return this.diagnostics.push(N.warning.UnknownFunction(t.name,t.span)),new v(t.span,null)}let o=n.args;if(!t.typed){let s=new Map;for(let r=0;r<t.args.length;r++){let c=t.args[r],a=c.nameSpan?this.source.slice(c.nameSpan.start,c.nameSpan.end).toLowerCase():void 0,l=$t(n,a,r),h=a??r;if(l===void 0){n.allowExtraArgs?s.set(h,c):this.diagnostics.push(N.warning.TooManyPosArgs(t.name,o.length,r+1,c.valueSpan));continue}let p=this.parseArgWithType(c.valueSpan,l,t.span.start);p!==null&&s.set(h,p)}return new e(t.span,s,this,null)}return new e(t.span,t.args,this,null)}parseArgWithType(t,e,n){let o=le(this.source,t.start,t.end),s=o.start,r=o.end;if(s>=r)return null;let c=e==="content"?"":this.source.slice(s,r);switch(e){case"number":let a=Number(c);return Number.isFinite(a)?a:(this.diagnostics.push(N.warning.InvalidNumber(c,o)),null);case"boolean":let l=c;return ws.test(l)?l==="true":(this.diagnostics.push(N.warning.InvalidBoolean(c,o)),null);case"content":{let f=this.labelableNodes,d=f.length,u=f.at(-1),g=u?.label,y=u&&Object.hasOwn(u,"label");try{let m=new i(this).parse(s,r);return m.length===1?m[0]:new K(o,m,null)}catch(x){if(f.length=d,u&&(y?u.label=g:delete u.label),this.variables.strict||!(x instanceof N))throw x;return this.diagnostics.push(x,N.warning.InvalidContent(o)),null}}case"label":n??=t.start;for(let f=this.labelableNodes.length-1;f>=0;f--){let d=this.labelableNodes[f];if(d&&!(d.sourceSpan.start>=n)&&d.label==c)return d}throw N.error.UnknownLabel(c,o);case"length":let h=In(c);return h instanceof N?(h.span.start+=s,h.span.end+=s,this.diagnostics.push(h),null):h;default:return vt(c)}return null}length2px(t){return t.unit==="em"?t.value*this.variables.fontsize:t.value}};function ut(i,t,e){for(;t<e&&Cs(i[t]);)t++;return t}function pe(i,t,e=0){for(;t>=e&&Cs(i[t]);)t--;return t}function Cs(i){switch(i){case" ":case" ":case"\v":case"\f":case"\xA0":case"\uFEFF":case"\u3000":return!0;default:return!1}}var fr=/^[A-GXZ]/,ke=/^[0-9]/,Me=/^[#bn]+/,As=/^[+-]?\d+/,Ls=/^[,']+/;function Nt(i,t=0,e=i.length){if(e-t===0)return new S("E_WRONG_NOTE_NAME",'\u51FD\u6570 @note \u7684\u53C2\u6570 [0]:"name" \u4E0D\u80FD\u4E3A\u7A7A',{start:t,end:e});let n=0,o=null,s=null,r=null,c=!1,a;for(let l=t;l<e;l++){let h=i[l];switch(n){case 0:if(fr.test(h))o=h,c=!0,n=1;else if(ke.test(h))o=h,c=!1,n=3;else{let f=i.slice(l,e).match(Me);if(f)s=f[0],l+=s.length-1,c=!1,n=2;else return new S("E_WRONG_NOTE_NAME",`\u51FD\u6570 @note \u7684\u53C2\u6570 [0]:"name" \u683C\u5F0F\u9519\u8BEF: \u9996\u5B57\u7B26 "${h}" \u4E0D\u5408\u6CD5\uFF0C\u671F\u671B A-G (a-g)\u30010-9\u3001X \u6216 Z \u5F00\u5934\uFF0C\u6216\u5728\u5F00\u5934\u76F4\u63A5\u4F7F\u7528\u5347\u964D\u53F7(#/b/n)`,{start:l,end:l+1})}break;case 1:let p=i.slice(l,e);if(a=p.match(As),a){r=parseInt(a[0],10),l+=a[0].length-1,n=4;break}if(a=p.match(Me),a){s=a[0],l+=s.length-1,n=5;break}return{name:o,next:l,acc:null,octave:null,absOctave:c};case 2:if(ke.test(h)){o=h,n=6;break}else return new S("E_WRONG_NOTE_NAME",`\u51FD\u6570 @note \u7684\u53C2\u6570 [0]:"name" \u683C\u5F0F\u9519\u8BEF: \u5728\u5347\u964D\u53F7\u5F00\u5934\u65F6\uFF0C\u5E94\u8BE5\u63A5\u6570\u5B57\u97F3\u540D\uFF0C\u4F46\u53D1\u73B0\u5B57\u7B26 "${h}"`,{start:l,end:l+1});case 3:if(a=i.slice(l,e).match(Ls),a){let f=a[0];return r=Ts(f),{name:o,next:l+f.length,acc:s,octave:r,absOctave:c}}if(a=i.slice(l,e).match(Me),a&&!ke.test(i[l+a[0].length]??"")){let f=a[0];s=f,l+=f.length-1,n=6;break}return{name:o,next:l,acc:s,octave:r,absOctave:c};case 4:if(a=i.slice(l,e).match(Me),a&&!ke.test(i[l+a[0].length]??"")){let f=a[0];return s=f,{name:o,next:l+f.length,acc:s,octave:r,absOctave:c}}return{name:o,next:l,acc:null,octave:r,absOctave:c};case 5:return a=i.slice(l,e).match(As),a?(r=parseInt(a[0],10),{name:o,next:l+a[0].length,acc:s,octave:r,absOctave:c}):{name:o,next:l,acc:s,octave:null,absOctave:c};case 6:if(a=i.slice(l,e).match(Ls),a){let f=a[0];return r=Ts(f),{name:o,next:l+f.length,acc:s,octave:r,absOctave:c}}return{name:o,next:l,acc:s,octave:r,absOctave:c};default:return N.error.Bug("\u97F3\u7B26\u540D\u79F0\u89E3\u6790\u72B6\u6001\u673A\u8FDB\u5165\u4E86\u672A\u5B9A\u4E49\u7684\u72B6\u6001",{start:l,end:e})}}return o===null?new S("E_WRONG_NOTE_NAME",'\u51FD\u6570 @note \u7684\u53C2\u6570 [0]:"name" \u683C\u5F0F\u9519\u8BEF: \u5728\u5347\u964D\u53F7\u5F00\u5934\u65F6\uFF0C\u5E94\u8BE5\u63A5\u6570\u5B57\u97F3\u540D\uFF0C\u4F46\u8F93\u5165\u5DF2\u7ED3\u675F',{start:t,end:e}):{name:o,next:e,acc:s,octave:r,absOctave:c}}function Ts(i){let t=0;for(let e=0;e<i.length;e++)i[e]===","?t--:i[e]==="'"&&t++;return t}var Oe=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],Es=["C","Db","D","Eb","E","F","Gb","G","Ab","A","Bb","B"],dt={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},Re=["C","D","E","F","G","A","B"],Pn=[0,2,4,5,7,9,11];function kt(i,t){let e=i[0],n="",o=1;o<i.length&&(i[o]==="#"||i[o]==="b"||i[o]==="n")&&(n=i[o],o++);let s=dt[e+n];if(s===void 0)throw N.error.InvalidTonality(i,{start:0,end:o});if(o<i.length){let r=i.slice(o);if(t=Number(r),!/^-?\d+$/.test(r)||!Number.isSafeInteger(t))throw N.error.InvalidTonality(i,{start:o,end:i.length})}return(t+1)*12+s}function Dn(i,t=!0,e=0){for(let n of i)n==="#"?e++:n==="b"?e--:n==="n"&&!t&&(e=0);return e}function $n(i,t,e,n){let o=dt[i];if(o===void 0)return null;let s=Dn(t);return i>="1"&&i<="7"?kt(n,4)+o+s+e*12:(e+1)*12+o+s}function _s(i,t,e,n){let o,s;if(i>="1"&&i<="7")o=Number(i)-1,s=e;else{let a=fe(i,t,e,n);if(!a)return;o=Number(a.renderName)-1,s=a.renderOctave}let r=kt(n,4),c=s*7+o;return a=>{let l=c+a,h=Math.floor(l/7);return r+Pn[(l%7+7)%7]+h*12}}function Fn(i){return(i%12+12)%12}function ur(i){let t=Fn(i);return t>6?t-12:t}function dr(i){return i===0?"":i>0?"#".repeat(i):"b".repeat(-i)}function fe(i,t,e,n){let o=Re.indexOf(n[0]),s=Re.indexOf(i),r=$n(i,t,e,n);if(o<0||s<0||r===null)return null;let c=kt(n,4),a=(s-o+Re.length)%Re.length,l=Fn(c+Pn[a]),h=ur(Fn(r)-l),p=(r-c-Pn[a]-h)/12;return{renderName:String(a+1),renderAcc:dr(h),renderOctave:p}}var xr={"#":{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 mr(i,t){let e=xr[i];if(!e)return null;let n=t*.72;return{w:e.w*n,h:e.h*n,baseline:e.baseline*n,strokeWidth:t*.06,commands:e.commands}}function Ie(i,t,e,n,o){let s=[],r=t*.42,c=e,a=0;for(let l of i){let h=mr(l,t);if(!h)continue;let p=n-h.baseline-r;s.push({shape:h,x:c,y:p}),p<a&&(a=p),c+=h.w+o}return{placed:s,right:c,top:a}}function Pe(i,{shape:t,x:e,y:n},o,s){i.drawPath(t.commands,{stroke:s,strokeWidth:t.strokeWidth},{x:o.x+e,y:o.y+n,scaleX:t.w,scaleY:t.h})}function yr(i){try{return kt(i,4),i}catch{}let t=Nt(i.replace(/^[a-g]/,c=>c.toUpperCase()));if(t instanceof N||t.next!==i.length)return null;let e=dt[t.name];if(e===void 0)return null;let n=Dn(t.acc??"",!1),s=((t.absOctave?t.octave??4:4+(t.octave??0))+1)*12+e+n,r=Object.keys(dt).filter(c=>dt[c]===(s%12+12)%12&&/^[A-G]/.test(c));return(n<0?r.at(-1):r[0])+(Math.floor(s/12)-1)}var zn=class extends v{static def={name:["key","1"],description:"\u8BBE\u7F6E\u65F6\u95F4\u7EBF\u4E0A\u7684 1= \u8C03\u6027\u57FA\u51C6",details:`~~~jpfun
|
|
20
|
+
\u7AEF\u70B9\u4E5F\u53EF\u6807\u5728\u589E\u65F6\u7EBF\u4E0A\u3002\u7EC8\u70B9\u6CA1\u6709\u529B\u5EA6\u65F6\uFF0C\u53D6\u540C\u8F68\u3001\u4E0D\u665A\u4E8E\u7EC8\u70B9\u7684\u6700\u540E\u4E00\u4E2A\u539F\u59CB\u529B\u5EA6\u4F5C\u4E3A\u4FDD\u6301\u57FA\u51C6\uFF1B\u627E\u4E0D\u5230\u65F6\u7ED9\u51FA\u8B66\u544A\u5E76\u4EC5\u7ED8\u5236\u3002\u589E\u65F6\u7EBF\u5EF6\u7EED\u7684\u97F3\u7B26\u4FDD\u6301\u8D77\u97F3\u65F6\u7684\u529B\u5EA6\u3002`,allowExtraArgs:!1,args:[{name:"from",description:"\u6E10\u53D8\u8D77\u70B9\u7684\u6807\u7B7E",type:"label",default:null},{name:"to",description:"\u6E10\u53D8\u7EC8\u70B9\u7684\u6807\u7B7E",type:"label",default:null},{name:"dv",description:"\u529B\u5EA6\u53D8\u5316\u91CF\uFF0C\u6B63\u6570\u6E10\u5F3A\uFF0C\u8D1F\u6570\u6E10\u5F31",type:"number",default:null}]};static loweringFinalize=t=>{let e=t.attachments.filter(o=>o instanceof ge);if(e.length===0)return;let n=[];for(let o of t.astToTemporal.values())for(let s of o){let i=s.playbackState?.velocity;if(i===void 0)continue;let c=s;for(;c.foldedInto;)c=c.foldedInto;n.push({node:s,host:c,velocity:i,increment:0})}n.sort((o,s)=>o.host.t.compare(s.host.t)||o.node.order-s.node.order);for(let o of e){let s=o.end.playbackState?.velocity??n.find(a=>a.host===o.toHost)?.velocity;for(let a=n.length-1;s===void 0&&a>=0;a--){let l=n[a];l.host.track===o.track&&l.host.t.compare(o.toHost.t)<=0&&(s=l.velocity)}if(s===void 0){t.diagnostics.push(new P("W_DYN_NO_VELOCITY","@dyn \u7EC8\u70B9\u53CA\u6B64\u524D\u540C\u8F68\u6CA1\u6709\u53EF\u7528\u7684\u529B\u5EA6\u57FA\u51C6\uFF0C\u4EC5\u7ED8\u5236\u6E10\u53D8\u7EBF",o.sourceSpan));continue}let i=n.find(a=>a.host.track===o.track&&a.host.t.compare(o.toHost.t)>0&&a.velocity!==s)?.host.t,c=o.toHost.t.clone().sub(o.fromHost.t);for(let a of n){if(a.host.track!==o.track||a.host.t.compare(o.fromHost.t)<0||i&&a.host.t.compare(i)>=0)continue;let h=a.host.t.compare(o.toHost.t)>=0?1:a.host.t.clone().sub(o.fromHost.t).div(c).toNumber();a.increment+=o.dv*h}}for(let o of n){if(o.increment===0)continue;let s=Math.max(1,Math.min(127,o.velocity+o.increment));o.node.playbackState={...o.node.playbackState,velocity:s}}};from;to;dv;size;loweringEnter(t){let e=t.getTemporalNodes(this.from).at(0),n=t.getTemporalNodes(this.to).at(-1);if(!e||!n)return t.diagnostics.push(M.warning.UnresolvedEndpoint("dyn",this.sourceSpan)),[];let o=e,s=n;for(;o.foldedInto;)o=o.foldedInto;for(;s.foldedInto;)s=s.foldedInto;if(!I(o)||!I(s))return t.diagnostics.push(M.warning.UnresolvedEndpoint("dyn",this.sourceSpan)),[];if(o.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(o.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 o.t.compare(s.t)<0?t.addAttachment(new ge(this,n,o,s)):t.addAttachment(new ge(this,e,s,o)),[]}constructor(t,e,n,o=null){super(t,o);let[s,i,c]=this.getArgValue(e,n),a=c;if(!Number.isFinite(a)||a===0)throw new 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&&n.diagnostics.push(new P("W_DYN_DELTA_CLAMPED",`@dyn \u7684 dv \u5FC5\u987B\u5728 -127 \u5230 127 \u4E4B\u95F4\uFF0C\u5DF2\u88AB\u9650\u5236\u4E3A ${a}`,t)),this.from=s,this.to=i,this.dv=a,this.size=n.variables.fontsize}toString(t){let e=n=>n.label??n.toString(t);return`@dyn(${e(this.from)}, ${e(this.to)}, ${this.dv})`}},Ws=Gn,ge=class{ast;end;fromHost;toHost;layer="foreground";constructor(t,e,n,o){this.ast=t,this.end=e,this.fromHost=n,this.toHost=o}get sourceSpan(){return this.ast.sourceSpan}get endPoints(){return[this.fromHost,this.toHost]}get dv(){return this.ast.dv}get track(){return this.fromHost.track}createGeometry(t){let e=this.fromHost.layoutLine,n=this.toHost.layoutLine,o=[this.fromHost,this.toHost],s=[],i=this.ast.size;for(let u=e;u<=n;u++){let m=t.getRangeColumns(u,o,this.track);if(m.some(x=>x.length>0)){for(let x of m)for(let y of x)i=Math.max(i,y.ast.size);s.push({line:u,startX:u===e?this.fromHost.box.x:this.lineEntryX(t,u),endX:u===n?this.toHost.box.x+this.toHost.box.w:this.lineRightX(t,u)})}}for(let u of s)u.line>e&&(u.startX-=i/4);let c=Math.max(.75,i*.035),a=s.filter(u=>u.startX!==u.endX),l=a.reduce((u,m)=>u+Math.abs(m.endX-m.startX),0);if(l===0)return{regions:[],paint(){}};let h=i*.4,p=c/2,f=0,d=a.map(u=>{let m=Math.abs(u.endX-u.startX),x=f/l,y=(f+m)/l;f+=m;let g=t.getRangeExtents(u.line,o,this.track),b=t.getVisualAxis(u.line,this.track),S=g?b+g.top:b;return{line:u.line,startX:u.startX,endX:u.endX,lineY:S-i*.62,startOpen:h*(this.dv>0?x:1-x),endOpen:h*(this.dv>0?y:1-y)}});return{regions:d.map(u=>({x:Math.min(u.startX,u.endX)-p,y:u.lineY-Math.max(u.startOpen,u.endOpen)/2-p,w:Math.abs(u.endX-u.startX)+c,h:Math.max(u.startOpen,u.endOpen)+c,line:u.line,track:this.track})),paint(u){let m={stroke:"#000",strokeWidth:c};for(let x of d)u.drawLine(x.startX,x.lineY-x.startOpen/2,x.endX,x.lineY-x.endOpen/2,m),u.drawLine(x.startX,x.lineY+x.startOpen/2,x.endX,x.lineY+x.endOpen/2,m)}}}lineEntryX(t,e){return t.lines[e].trackRuns.get(this.track)?.find(o=>!o.T.isZero())?.box.x??t.originX}lineRightX(t,e){let n=t.lines[e].trackRuns;if(n.size===0)return t.originX+t.width;let o=t.originX;for(let s of n.values())for(let i of s)o=Math.max(o,i.box.x+i.box.w);return o}};var Bt=class r{parent;groups=[];constructor(t=null){this.parent=t}group(t,e){let n=this.groups.find(o=>o.laneKey===t.laneKey);for(n||(n={laneKey:t.laneKey,members:[],measure:t.measure,place:t.place},this.groups.push(n));n.members.length<e;)n.members.push(new r(this));return n}};var te=.7,Gs="shoulder";function Ys(r,t){let e=r;typeof e.size=="number"&&(e.size*=t);for(let n of r.children??[])Ys(n,t)}var Vn=class r extends L{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 L.findLabelable(this.host)}static deSugarAtom(t,e,n){let o=t[e];switch(o){case">":o="pre";break;case"<":o="post";break;default:return null}return{next:e+1,node:{kind:"sugar",data:{class:r,side:o},span:{start:e,end:e+1}}}}static deSugarRelation(t,e,n){let o=e[n++];if(o.kind!=="sugar"||o.data?.class!==r)return null;let s=o.data.side,i=t.nodes.length-1;for(;i>=0&&t.nodes[i]instanceof 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",o.span);let c=t.nodes[i],a=i;if(c instanceof mt){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,n);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,o.span,t):r.create(t,o.span,"post",c,p);for(l.length=a,l.push(f);++h<t.nodes.length;)l.push(t.nodes[h]);return t.nodes=l,e.length}throw new w("E_GRACE_NO_TARGET","@grace\u8BED\u6CD5\u7CD6\u9519\u8BEF: \u53F3\u8FB9\u6CA1\u6709\u627E\u5230\u76EE\u6807",o.span)}host;grace;side="pre";size;static attachPre(t,e,n,o){if(e instanceof r&&e.side==="pre"){let s=e,i=1;for(;s.grace instanceof r&&s.grace.side==="pre";)s=s.grace,i++;let c=new Map;c.set(0,s.grace),c.set(1,t);let a=te**i,l=new r(n,c,o,null,te*a);return l.size*=a,s.setGrace(l,1),e}return r.create(o,n,"pre",e,t)}static create(t,e,n,o,s){let i=new Map;return i.set(0,o),i.set(1,s),i.set("side",n),new r(e,i,t)}get children(){let t=[];return this.host&&t.push(this.host),this.grace&&t.push(this.grace),t}constructor(t,e,n,o=null,s=te){if(super(t,o),this.size=n.variables.fontsize,[this.host,this.grace,this.side]=this.getArgValue(e,n),this.side!=="pre"&&this.side!=="post")throw new 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=te){Ys(t,e),this.grace=t,this.adopt(t)}adopt(t){t.parent=this,this.sourceSpan.start=Math.min(this.sourceSpan.start,t.sourceSpan.start),this.sourceSpan.end=Math.max(this.sourceSpan.end,t.sourceSpan.end)}loweringEnter(t,e){let n=this.host,o=this.grace;if(!n||!o)throw new 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=(d,u)=>t.trackedEvents(d,new B,u);t.isolateFromLoweringGroups(()=>{this.side==="post"&&(i=l(n,e).flat()),t.beginLoweringGroup(this,{onAttachment(d){a.push(d)}}),c=l(o,s),t.endLoweringGroup(this),this.side==="pre"&&(i=l(n,e).flat())});let[h]=i;if(i.length!==1||!I(h))throw new w("E_GRACE_INVALID_HOST","@grace \u7684\u5BBF\u4E3B\u5FC5\u987B\u6070\u597D\u4EA7\u751F\u4E00\u4E2A\u53EF\u89C1 Temporal",n.sourceSpan);let p=c.flat();if(!p.some(I)||p.some(d=>(d.addon?.breakBefore??0)>0))throw new w("E_GRACE_INVALID_CONTENT","@grace \u7684\u501A\u97F3\u81F3\u5C11\u4EA7\u751F\u4E00\u4E2A\u53EF\u89C1\u5BF9\u8C61\uFF0C\u4E14\u4E0D\u80FD\u6362\u884C",o.sourceSpan);let f=new Yn(this,h,c,s,a,this.side);for(let d of f.graceRuns)d.length<2||t.addAttachment(Jt([...d],!1,o.sourceSpan));return[f]}toString(t){let e=this.host?.toString(t)??"",n=this.grace?.toString(t)??"";return`@grace(${e}, ${n}, side=${this.side})`}},Ks=Vn,Hr=[{op:"M",x:0,y:0},{op:"C",cx1:-.01,cy1:.26,cx2:.14,cy2:.42,x:.29,y:.36}],Wr=.07,Gr=.18,Vs=new B(3,4),Yn=class extends ${host;graceColumns;graces;graceRuns;side;root;attachments;events;starts;hostOffset={x:0,y:0};graceOffsets=[];hookOrigin=null;constructor(t,e,n,o,s,i){super(),this.ast=t,this.host=e,this.root=o,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 n){let d=f[0].t.clone().divPow2(),u=[];for(let m of f)m.foldedInto=this,a.push(m),l.push(d),I(m)&&u.push(m);u.length>0&&c.push(u)}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 d=h.get(f.track);d||(h.set(f.track,d=[]),p.push(d)),d.push(f);let u=f.addon={...f.addon};u[Pt]=(Number(u[Pt])||0)+1,f.T.divPow2()}this.graceRuns=p}onTimeState(t){this.host.T.copyFrom(this.T);let e;for(let n of this.side==="pre"?[...this.events,this.host]:[this.host,...this.events]){n.t.copyFrom(this.t),n.layoutLine=this.layoutLine;let o=n.onTimeState?.(t);n===this.host&&(this.T.copyFrom(n.T),e=o)}return e}prepareHorizontal(t){this.host.prepareHorizontal?.(t)}emitPlayback(t){let e=new B,n=new B;this.events.forEach((h,p)=>{n.copyFrom(this.starts[p]).add(h.T),n.compare(e)>0&&e.copyFrom(n)});let o=e.compare(Vs)>0?Vs:e,s=t.end.clone().sub(t.start),i=s.clone().mul(o),c=s.sub(i),a=e.isZero()?new B:i.clone().div(e),l=this.side==="pre"?t.start.clone():t.start.clone().add(c);this.side==="post"&&t.play(this.host,t.start.clone(),c),this.events.forEach((h,p)=>{t.play(h,this.starts[p].clone().mul(a).add(l),h.T.clone().mul(a))}),this.side==="pre"&&t.play(this.host,l.add(i),c)}prepareLayout(t){Ot(this,this.host);let e=t.layoutSubdomain(this,this.graceColumns,this.root,this.attachments),n=qt([this.host],t);this.springConfig={...this.host.springConfig,...this.springConfig};let o=this.ast.size*te,s=o*.2,i=o*Gr,a=(this.host.ports[Gs]?.y??0)-i-e.height,l=ot(this.host),h=Math.max(0,-a,-l.y),p=this.side==="pre"?0:n+s;this.hostOffset={x:this.host.box.x+(this.side==="pre"?e.width+s:0),y:h},this.graceOffsets=e.positions.map(u=>({x:p+u.x,y:a+h+u.y})),this.box.w=n+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 u in this.host.ports){let m=this.host.ports[u];this.ports[u]={...m,x:this.hostOffset.x+m.x,y:this.hostOffset.y+m.y}}this.ports[Gs]??={x:this.box.anchor,y:this.hostOffset.y};let f=this.graces.filter(u=>!u.T.isZero()),d=this.side==="pre"?f.at(-1):f[0];this.hookOrigin=d?{x:this.graceOffsets[this.graces.indexOf(d)].x+d.box.anchor,y:Math.max(...this.graces.map((u,m)=>this.graceOffsets[m].y+u.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*te,n=this.hookOrigin,o=this.side==="pre"?1:-1;t.drawPath(Hr,{stroke:"#000",strokeWidth:Math.max(.8,e*Wr)},{x:this.box.x+n.x,y:this.box.y+n.y,scaleX:e*o,scaleY:e})}};function Us(r){let{resolvedMidi:t}=r;return typeof t=="number"?t:void 0}var Kn=class extends L{static def={name:["gliss"],description:"\u6ED1\u97F3\u8FDE\u7EBF",details:`~~~jpfun
|
|
21
|
+
1 -@a 5@b @gliss(a, b)
|
|
22
|
+
~~~
|
|
23
|
+
\u82E5\u9644\u5C5E\u5BF9\u8C61\u65E0\u97F3\u9AD8\uFF0C\u5C06\u4F7F\u7528\u524D\u9762\u6700\u8FD1\u7684\u7684\u540C\u8F68\u6709\u97F3\u9AD8\u5BF9\u8C61\u7684\u97F3\u9AD8`,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,n,o=null){super(t,o),[this.from,this.to]=this.getArgValue(e,n)}loweringEnter(t){let e=t.getTemporalNodes(this.from).at(-1),n=t.getTemporalNodes(this.to).at(-1);if(!e||!n||!I(e)||!I(n))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);return t.addAttachment(new Un(e,n,this.sourceSpan,t.diagnostics)),[]}toString(t){let e=this.from instanceof L?this.from.label:void 0,n=this.to instanceof L?this.to.label:void 0;return e&&n?`@gliss(${e}, ${n})`:t.slice(this.sourceSpan.start,this.sourceSpan.end)}},js=Kn;function be(r,t){for(;r.foldedInto&&I(r.foldedInto)&&(!t||t.columnOf(r)<0);)r=r.foldedInto;return r}var Un=class{from;to;sourceSpan;diagnostics;layer="foreground";endPoints;direction;warned=!1;constructor(t,e,n,o){this.from=t,this.to=e,this.sourceSpan=n,this.diagnostics=o,this.endPoints=[t,e]}get orderedEndpoints(){let[t,e]=this.endPoints,n=be(t),o=be(e),{sourceSpan:s}=this;if(n.t.equals(o.t))throw new w("E_GLISS_ORDER","@gliss \u4E24\u4E2A\u7AEF\u70B9\u4E0D\u80FD\u4F4D\u4E8E\u540C\u4E00\u65F6\u523B",s);if(n.layoutLine!==o.layoutLine)throw new w("E_GLISS_CROSS_LINE","@gliss \u4E0D\u652F\u6301\u8DE8\u8C31\u9762\u884C",s);return n.t.compare(o.t)>0?[e,t]:[t,e]}prepareHorizontal(t){let[e,n]=this.orderedEndpoints,{sourceSpan:o}=this,s=e.layoutLine,i=t[s],c=i&&be(e,i),a=i&&be(n,i),l=c?i.columnOf(c):-1,h=a?i.columnOf(a):-1;if(!i||l<0||h<=l)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",o);let p=(m,x)=>{if("resolvedMidi"in m)return Us(m);let y=be(m,i).track;for(let g=s;g>=0;g--){let b=t[g].columns;for(let S=g===s?x-1:b.length-1;S>=0;S--){let C=b[S].find(E=>E.track===y&&"resolvedMidi"in E);if(C)return Us(C)}}},f=p(e,l),d=p(n,h);this.direction=f===void 0||d===void 0?void 0:Math.sign(d-f),this.direction===void 0&&!this.warned&&(this.diagnostics.push(new P("W_GLISS_NO_PITCH","@gliss \u7AEF\u70B9\u6CA1\u6709\u53EF\u7528\u97F3\u9AD8",o)),this.warned=!0);let u=c.box.w-c.box.anchor+this.size*1.4;i.registerHorizontalLayoutHook(c,a,({columns:m})=>{for(let x of m[l])x.WR=Math.max(x.WR,u)})}get size(){return Math.max(this.from.ast.size,this.to.ast.size)}createGeometry(){let[t,e]=this.orderedEndpoints,n=this.size,o=n*.12,s={x:t.box.x+t.box.w+o,y:t.box.y+t.box.visualAxis},i={x:e.box.x-o,y:e.box.y+e.box.visualAxis};if(t.track===e.track&&(this.direction===void 0?i.y=s.y:(s.y+=this.direction*n*.24,i.y-=this.direction*n*.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(n*.3,Math.hypot(i.x-s.x,i.y-s.y)*.35),l=u=>({x:i.x-a*Math.cos(c+u),y:i.y-a*Math.sin(c+u)}),h=[{op:"M",...s},{op:"L",...i},{op:"M",...l(-Math.PI/6)},{op:"L",...i},{op:"L",...l(Math.PI/6)}],p=n*.05,f=xt(h),d={x:f.x-p/2,y:f.y-p/2,w:f.w+p,h:f.h+p};return{regions:[{...d,line:t.layoutLine,track:t.track}],occupancy:t.track===e.track?[{...d,line:t.layoutLine,track:t.track}]:[],paint:u=>{u.drawPath(h,{fill:"none",stroke:"#000",strokeWidth:p})}}}};var jn=class extends L{static def={name:["slide"],description:"\u6ED1\u5165\u6216\u6ED1\u51FA\u8BB0\u53F7",details:`~~~jpfun
|
|
24
|
+
@slide(5, side=pre, direction=up)
|
|
25
|
+
~~~
|
|
26
|
+
\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 L.findLabelable(this.content)}constructor(t,e,n,o=null){super(t,o);let[s,i,c]=this.getArgValue(e,n);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",n={onTemporal(o){I(o)&&(!e||!n.host)&&(n.host=o)}};return t.beginLoweringGroup(this,n),[]}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 n=new Xn(e,this);t.addAttachment(n);let o=e.prepareHorizontal;return e.prepareHorizontal=s=>{o?.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)+n.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})`}},Xs=jn,Xn=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,n=t.ast.size,o=e.side==="pre",s=this.length,i=e.direction==="up",c=t.box.y+t.box.visualAxis,a=o?t.box.x-n*.12-s:t.box.x+t.box.w+n*.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=y=>({x:h.x-n*.25*Math.cos(p+y),y:h.y-n*.25*Math.sin(p+y)}),d=[{op:"M",...l},{op:"L",...h},{op:"M",...f(-Math.PI/6)},{op:"L",...h},{op:"L",...f(Math.PI/6)}],u=n*.05,m=xt(d);return{regions:[{x:m.x-u/2,y:m.y-u/2,w:m.w+u,h:m.h+u,line:t.layoutLine,track:t.track}],paint(y){y.drawPath(d,{fill:"none",stroke:"#000",strokeWidth:u})}}}};var ee="sans-serif",qn="'Cascadia Mono', Consolas, 'Liberation Mono', 'Noto Sans Mono', monospace";function ze(r){return`${r.fontStyle?`${r.fontStyle} `:""}${r.fontWeight??"normal"} ${r.fontSize}px ${r.fontFamily??ee}`}var $e=class{measureText(t,e){let n=e.fontSize,o=e.fontFamily?.toLowerCase().includes("mono")??!1,s=0;for(let i of t)s+=i.charCodeAt(0)>127?1:o?.62:.58;return{w:Math.max(s*n,n*.25),h:n,baseline:n*.8}}},Qn=new $e,Zn=class{context;widths=new Map;constructor(t){this.context=t}clearCache(){this.widths.clear()}measureText(t,e){let n=ze(e),o=`${n}\0${t}`,s=this.widths.get(o);return s===void 0&&(this.context.font=n,s=this.context.measureText(t).width,this.widths.set(o,s)),{w:Math.max(s,e.fontSize*.25),h:e.fontSize,baseline:e.fontSize*.8}}};var Vr=/[A-Za-z0-9_./-]/;function Se(r,t,e){let n=t+1;for(;n<e&&Vr.test(r[n]);)n++;let o=r.slice(t+1,n);if(!o||n>=e||r[n]!=="(")return null;let s=n,i=1,c=0,a=null,l=!1,h=[],p=s+1,f=(u,m,x=!1)=>{let y=we(r,p,u);if(!x&&y.start>=y.end)return;let g=Yr(r,y.start,y.end),b=g>y.start?we(r,y.start,g):void 0,S=g>y.start?we(r,g+1,y.end):y;h.push({span:y,valueSpan:S,nameSpan:b,equalsSpan:g>y.start?{start:g,end:g+1}:void 0,commaSpan:m===void 0?void 0:{start:m,end:m+1}})},d=(u,m)=>({name:o,span:{start:t,end:u},nameSpan:{start:t,end:s},openParenSpan:{start:s,end:s+1},closeParenSpan:m,args:h});for(n++;n<e;n++){let u=r[n];if(a){l?l=!1:u==="\\"?l=!0:u===a&&(a=null);continue}if(u==='"'){a=u;continue}if(u==="{")c++;else if(u==="}")c=Math.max(0,c-1);else if(u==="("&&c===0)i++;else if(u===")"&&c===0){if(--i)continue;return f(n),d(n+1,{start:n,end:n+1})}else u===","&&i===1&&c===0&&(f(n,n,!0),p=n+1)}return f(e),d(e)}var Zs=/\s/;function we(r,t,e){let n=t,o=e;for(;n<o&&Zs.test(r[n]);)n+=1;for(;o>n&&Zs.test(r[o-1]);)o-=1;return{start:n,end:o}}function Yr(r,t=0,e=r.length){let n=0,o=0,s=null,i=!1;for(let c=t;c<e;c++){let a=r[c];if(s){i?i=!1:a==="\\"?i=!0:a===s&&(s=null);continue}if(a==='"')s=a;else if(a==="("&&o===0)n++;else if(a===")"&&o===0)n=Math.max(0,n-1);else if(a==="{")o++;else if(a==="}")o=Math.max(0,o-1);else if(a==="="&&n===0&&o===0)return c}return-1}function qs(r,t,e){let n=1,o=null,s=!1;for(let i=t;i<e;i++){let c=r[i];if(o){s?s=!1:c==="\\"?s=!0:c===o&&(o=null);continue}if(c==='"')o=c;else if(c==="(")n++;else if(c===")"&&--n===0)return i}return-1}function Lt(r,t,e){for(let n=t+1;n<e;n++)if(r[n]==="\\")n++;else if(r[n]==='"')return n;return-1}function Dt(r){return r.length<2||!r.startsWith('"')||!r.endsWith('"')?r:r.slice(1,-1).replace(/\\(.)/gs,"$1")}function ht(r){return`"${r.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function Qs(r,t,e){let n=1,o=null,s=!1;for(let i=t+1;i<e;i++){let c=r[i];if(o){s?s=!1:c==="\\"?s=!0:c===o&&(o=null);continue}if(c==='"')o=c;else if(c==="{")n++;else if(c==="}"&&(n--,n===0))return i}return-1}var Kr=/\s|\(|\)|\{|\}|,/;function Js(r,t,e){let n=t+1;for(;n<e&&!Kr.test(r[n]);)n++;return n<=t+1?null:{label:r.slice(t+1,n),next:n}}var Ur=/^(-?(?:\d+(?:\.\d*)?|\.\d+))([a-z%]+)?$/i,jr=["em","px"];function Jn(r){let t=r.match(Ur);if(!t)return M.warning.InvalidLength(r,{start:0,end:r.length});let e=parseFloat(t[1]);if(!Number.isFinite(e))return M.warning.InvalidLength(r,{start:0,end:r.length});if(t[2]){let n=t[2].toLowerCase();return jr.includes(n)?{value:e,unit:n}:M.warning.InvalidLengthUnit(n,{start:t[1].length,end:r.length})}else return{value:e,unit:"px"}}var ti=/^(true|false)$/;function Xr(r,t){if(r)return r==="content"?void 0:r;if(ti.test(t))return"boolean";if(t.startsWith('"'))return"string";if(!isNaN(Number(t)))return"number";if(!(Jn(t)instanceof M))return"length"}var ei=22,Zr=4,pt=class r{static systemVariables={fontsize:{type:"length",default:ei},font:{type:"string",default:ee},numberfont:{type:"string",default:qn},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,n])=>[e,n.default])),Object.assign(this.variables,t.variables),this.functions=t.functions??new Map,this.labelableNodes=t.labelableNodes??[],this.nodes=t.toConsume??[],t.functions?[this.deSugarAtomFns,this.deSugarRelationFns]=r.getDeSugarFns(this.functions.values()):(this.deSugarAtomFns=[],this.deSugarRelationFns=[]))}static getDeSugarFns(t){let e=new Set(t),n=[],o=[];for(let s of e){let i=s.deSugarAtom;i&&i!==L.deSugarAtom&&n.push(i);let c=s.deSugarRelation;c&&c!==L.deSugarRelation&&o.push(c)}return[n,o]}pushNode(t){this.nodes.push(t);let e=t.labelable?.();e!==void 0&&this.labelableNodes.push(e)}setVariable(t,e){Object.hasOwn(r.systemVariables,t)&&(t==="fontsize"&&e&&(e=this.length2px(e)),(e===void 0||e===""||e===0)&&(e=r.systemVariables[t].default)),this.variables[t]=e}registerFunctions(t){let e=this.functions;for(let n of t){let o=n.def;if(!o)continue;let s=Array.isArray(o.name)?o.name:[o.name];for(let i of s){if(e.has(i.toLowerCase()))throw new Error(`Duplicate function name detected: ${i}`);e.set(i.toLowerCase(),n)}}[this.deSugarAtomFns,this.deSugarRelationFns]=r.getDeSugarFns(this.functions.values())}parse(t=0,e=this.source.length){return this.makeNodes(this.parseGrammar(t,e)),this.nodes}parseSyntax(t=0,e=this.source.length){if(this.parseGrammar(t,e,!0),this.scopeDepth===0){let n=(o,s)=>o.span.start-s.span.start||o.span.end-s.span.end;this.syntax.tokens.sort(n),this.syntax.calls.sort(n)}return this.syntax}addSyntax(t,e){if(!e||e.start>=e.end)return;let n=e.start,o=this.syntax.tokens;for(;o[this.commentIndex]?.kind==="comment"&&o[this.commentIndex].span.end<=n;)this.commentIndex++;for(let s=this.commentIndex;s<o.length;s++){let i=o[s];if(i.kind!=="comment"||i.span.start>=e.end)break;n<i.span.start&&o.push({kind:t,span:{start:n,end:i.span.start}}),n=i.span.end,this.commentIndex=s+1}n<e.end&&o.push({kind:t,span:{start:n,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:n,syntaxKind:o,...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&&Yt(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=Xr(h,p);f&&this.addSyntax(f,a.valueSpan)}this.addSyntax("punctuation",a.commaSpan)}this.addSyntax("punctuation",s.closeParenSpan)}makeNodes(t,e=0,n=t.length){t:for(;e<n;e++){let o=t[e];if(typeof o=="number"){let s=this.nodes.at(-1);s instanceof et&&s.sourceSpan.end===o?s.sourceSpan.end=o+1:this.nodes.push(new et({start:o,end:o+1},null));continue}switch(o.kind){case"call":this.pushNode(this.parseCallNode(o));break;case"brace":let s=new r(this);this.nodes.push(new tt(o.span,s.parse(o.span.start+1,o.span.end-1),null));break;case"label":let i=this.labelableNodes.at(-1);i?i.label!==void 0?this.diagnostics.push(M.warning.TargetAlreadyLabeled(o.label,i.label,o.span)):(i.label=o.label,this.nodes.push(new mt(o.span,o.label,i))):this.diagnostics.push(M.warning.LabelWithoutTarget(o.label,o.span));break;case"sugar":for(let a of this.deSugarRelationFns){let l=a(this,t,e);if(l!==null){e=l-1;continue t}}let c=this.nodes.at(-1);c instanceof et&&c.sourceSpan.end===o.span.start?c.sourceSpan.end=o.span.end:this.nodes.push(new et(o.span,null));break}}return e}parseGrammar(t,e,n=!1){let o=[],s=i=>{o.push(i),n&&this.recordSyntax(i)};t:for(;(t=wt(this.source,t,e))<e;){let i=this.source[t];if(i==="@"){let c=Se(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=M.error.PosAfterNamedArg(c.name,h.span);if(!n)throw f;this.diagnostics.push(f)}}if(!c.closeParenSpan){let h=M.error.UnterminatedCall(c.name,c.span);if(!n)throw h;this.diagnostics.push(h)}t=c.span.end;continue}let a=Js(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=Qs(this.source,t,e);(c<0||c>=e||c<=t)&&(this.diagnostics.push(M.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 M?this.diagnostics.push(a):this.diagnostics.push(M.error.Bug(a.toString(),{start:t,end:e})),a}o.push(t++)}return o}parseCallNode(t){let e=this.functions.get(t.name.toLowerCase()),n=e?.def;if(!e||!n){if(this.variables.strict)throw M.error.UnknownFunction(t.name,t.span);return this.diagnostics.push(M.warning.UnknownFunction(t.name,t.span)),new L(t.span,null)}let o=n.args;if(!t.typed){let s=new Map;for(let i=0;i<t.args.length;i++){let c=t.args[i],a=c.nameSpan?this.source.slice(c.nameSpan.start,c.nameSpan.end).toLowerCase():void 0,l=Yt(n,a,i),h=a??i;if(l===void 0){n.allowExtraArgs?s.set(h,c):this.diagnostics.push(M.warning.TooManyPosArgs(t.name,o.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,n){let o=we(this.source,t.start,t.end),s=o.start,i=o.end;if(s>=i)return null;let c=e==="content"?"":this.source.slice(s,i);switch(e){case"number":let a=Number(c);return Number.isFinite(a)?a:(this.diagnostics.push(M.warning.InvalidNumber(c,o)),null);case"boolean":return ti.test(c)?c==="true":(this.diagnostics.push(M.warning.InvalidBoolean(c,o)),null);case"content":{let h=this.labelableNodes,p=h.length,f=h.at(-1),d=f?.label,u=f&&Object.hasOwn(f,"label");try{let x=new r(this).parse(s,i);return x.length===1?x[0]:new tt(o,x,null)}catch(m){if(h.length=p,f&&(u?f.label=d:delete f.label),this.variables.strict||!(m instanceof M))throw m;return this.diagnostics.push(m,M.warning.InvalidContent(o)),null}}case"label":n??=t.start;for(let h=this.labelableNodes.length-1;h>=0;h--){let p=this.labelableNodes[h];if(p&&!(p.sourceSpan.start>=n)&&p.label==c)return p}throw M.error.UnknownLabel(c,o);case"length":let l=Jn(c);return l instanceof M?(l.span.start+=s,l.span.end+=s,this.diagnostics.push(l),null):l;default:return Dt(c)}}length2px(t){return t.unit==="em"?t.value*this.variables.fontsize:t.value}};function wt(r,t,e){for(;t<e&&ni(r[t]);)t++;return t}function Ce(r,t,e=0){for(;t>=e&&ni(r[t]);)t--;return t}function ni(r){switch(r){case" ":case" ":case"\v":case"\f":case"\xA0":case"\uFEFF":case"\u3000":return!0;default:return!1}}var qr=/^[A-GXZ]/,He=/^[0-9]/,We=/^[#bn]+/,oi=/^[+-]?\d+/,si=/^[,']+/;function Ft(r,t=0,e=r.length){if(e-t===0)return new w("E_WRONG_NOTE_NAME",'\u51FD\u6570 @note \u7684\u53C2\u6570 [0]:"name" \u4E0D\u80FD\u4E3A\u7A7A',{start:t,end:e});let n=0,o=null,s=null,i=null,c=!1,a;for(let l=t;l<e;l++){let h=r[l];switch(n){case 0:if(qr.test(h))o=h,c=!0,n=1;else if(He.test(h))o=h,c=!1,n=3;else{let f=r.slice(l,e).match(We);if(f)s=f[0],l+=s.length-1,c=!1,n=2;else return new w("E_WRONG_NOTE_NAME",`\u51FD\u6570 @note \u7684\u53C2\u6570 [0]:"name" \u683C\u5F0F\u9519\u8BEF: \u9996\u5B57\u7B26 "${h}" \u4E0D\u5408\u6CD5\uFF0C\u671F\u671B A-G (a-g)\u30010-9\u3001X \u6216 Z \u5F00\u5934\uFF0C\u6216\u5728\u5F00\u5934\u76F4\u63A5\u4F7F\u7528\u5347\u964D\u53F7(#/b/n)`,{start:l,end:l+1})}break;case 1:let p=r.slice(l,e);if(a=p.match(oi),a){i=parseInt(a[0],10),l+=a[0].length-1,n=4;break}if(a=p.match(We),a){s=a[0],l+=s.length-1,n=5;break}return{name:o,next:l,acc:null,octave:null,absOctave:c};case 2:if(He.test(h)){o=h,n=6;break}else return 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 "${h}"`,{start:l,end:l+1});case 3:if(a=r.slice(l,e).match(si),a){let f=a[0];return i=ii(f),{name:o,next:l+f.length,acc:s,octave:i,absOctave:c}}if(a=r.slice(l,e).match(We),a&&!He.test(r[l+a[0].length]??"")){let f=a[0];s=f,l+=f.length-1,n=6;break}return{name:o,next:l,acc:s,octave:i,absOctave:c};case 4:if(a=r.slice(l,e).match(We),a&&!He.test(r[l+a[0].length]??"")){let f=a[0];return s=f,{name:o,next:l+f.length,acc:s,octave:i,absOctave:c}}return{name:o,next:l,acc:null,octave:i,absOctave:c};case 5:return a=r.slice(l,e).match(oi),a?(i=parseInt(a[0],10),{name:o,next:l+a[0].length,acc:s,octave:i,absOctave:c}):{name:o,next:l,acc:s,octave:null,absOctave:c};case 6:if(a=r.slice(l,e).match(si),a){let f=a[0];return i=ii(f),{name:o,next:l+f.length,acc:s,octave:i,absOctave:c}}return{name:o,next:l,acc:s,octave:i,absOctave:c};default:return M.error.Bug("\u97F3\u7B26\u540D\u79F0\u89E3\u6790\u72B6\u6001\u673A\u8FDB\u5165\u4E86\u672A\u5B9A\u4E49\u7684\u72B6\u6001",{start:l,end:e})}}return o===null?new 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}):{name:o,next:e,acc:s,octave:i,absOctave:c}}function ii(r){let t=0;for(let e=0;e<r.length;e++)r[e]===","?t--:r[e]==="'"&&t++;return t}var Ve=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],ri=["C","Db","D","Eb","E","F","Gb","G","Ab","A","Bb","B"],St={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},Ge=["C","D","E","F","G","A","B"],to=[0,2,4,5,7,9,11];function $t(r,t){let e=r[0],n="",o=1;o<r.length&&(r[o]==="#"||r[o]==="b"||r[o]==="n")&&(n=r[o],o++);let s=St[e+n];if(s===void 0)throw M.error.InvalidTonality(r,{start:0,end:o});if(o<r.length){let i=r.slice(o);if(t=Number(i),!/^-?\d+$/.test(i)||!Number.isSafeInteger(t))throw M.error.InvalidTonality(r,{start:o,end:r.length})}return(t+1)*12+s}function no(r,t=!0,e=0){for(let n of r)n==="#"?e++:n==="b"?e--:n==="n"&&!t&&(e=0);return e}function oo(r,t,e,n){let o=St[r];if(o===void 0)return null;let s=no(t);return r>="1"&&r<="7"?$t(n,4)+o+s+e*12:(e+1)*12+o+s}function ci(r,t,e,n){let o,s;if(r>="1"&&r<="7")o=Number(r)-1,s=e;else{let a=Ae(r,t,e,n);if(!a)return;o=Number(a.renderName)-1,s=a.renderOctave}let i=$t(n,4),c=s*7+o;return a=>{let l=c+a,h=Math.floor(l/7);return i+to[(l%7+7)%7]+h*12}}function eo(r){return(r%12+12)%12}function Qr(r){let t=eo(r);return t>6?t-12:t}function Jr(r){return r===0?"":r>0?"#".repeat(r):"b".repeat(-r)}function Ae(r,t,e,n){let o=Ge.indexOf(n[0]),s=Ge.indexOf(r),i=oo(r,t,e,n);if(o<0||s<0||i===null)return null;let c=$t(n,4),a=(s-o+Ge.length)%Ge.length,l=eo(c+to[a]),h=Qr(eo(i)-l),p=(i-c-to[a]-h)/12;return{renderName:String(a+1),renderAcc:Jr(h),renderOctave:p}}var tc={"#":{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 Ye(r,t,e,n,o){let s=[],i=t*.72,c=t*.42,a=e,l=0;for(let h of r){let p=tc[h];if(!p)continue;let f={w:p.w*i,h:p.h*i,baseline:p.baseline*i,strokeWidth:t*.06,commands:p.commands},d=n-f.baseline-c;s.push({shape:f,x:a,y:d}),d<l&&(l=d),a+=f.w+o}return{placed:s,right:a,top:l}}function Ke(r,{shape:t,x:e,y:n},o,s){r.drawPath(t.commands,{stroke:s,strokeWidth:t.strokeWidth},{x:o.x+e,y:o.y+n,scaleX:t.w,scaleY:t.h})}function ec(r){try{return $t(r,4),r}catch{}let t=Ft(r.replace(/^[a-g]/,c=>c.toUpperCase()));if(t instanceof M||t.next!==r.length)return null;let e=St[t.name];if(e===void 0)return null;let n=no(t.acc??"",!1),s=((t.absOctave?t.octave??4:4+(t.octave??0))+1)*12+e+n,i=Object.keys(St).filter(c=>St[c]===(s%12+12)%12&&/^[A-G]/.test(c));return(n<0?i.at(-1):i[0])+(Math.floor(s/12)-1)}var io=class extends L{static def={name:["key","1"],description:"\u8BBE\u7F6E\u65F6\u95F4\u7EBF\u4E0A\u7684 1= \u8C03\u6027\u57FA\u51C6",details:`~~~jpfun
|
|
21
27
|
1 ^ @key(F#3)
|
|
22
28
|
~~~
|
|
23
|
-
\u8C03\u6027\u6CBF\u65F6\u95F4\u7EBF\u5F71\u54CD\u540E\u7EED\u6570\u5B57\u97F3\u540D\u3002\u8C31\u9762\u8BB0\u53F7\u663E\u793A\u97F3\u540D\u4E0E\u5347\u964D\u53F7\uFF0C\u7701\u7565\u516B\u5EA6\uFF1B\u901A\u5E38\u7528 \`^\` \u53E0\u5728\u97F3\u7B26\u4E0A\u65B9\u3002`,allowExtraArgs:!1,args:[{name:"tonality",description:"`1=` \u7684\u97F3\u9AD8\u57FA\u51C6\uFF0C\u5982 `C4`\u3001`F#3`",type:"string",default:null},{name:"size",description:"\u8C03\u6027\u8BB0\u53F7\u5B57\u53F7",type:"length",default:{value:1,unit:"em"}}]};tonality;size;font;displayName;displayAcc;constructor(t,e,n,o=null){super(t,o);let[s,
|
|
29
|
+
\u8C03\u6027\u6CBF\u65F6\u95F4\u7EBF\u5F71\u54CD\u540E\u7EED\u6570\u5B57\u97F3\u540D\u3002\u8C31\u9762\u8BB0\u53F7\u663E\u793A\u97F3\u540D\u4E0E\u5347\u964D\u53F7\uFF0C\u7701\u7565\u516B\u5EA6\uFF1B\u901A\u5E38\u7528 \`^\` \u53E0\u5728\u97F3\u7B26\u4E0A\u65B9\u3002`,allowExtraArgs:!1,args:[{name:"tonality",description:"`1=` \u7684\u97F3\u9AD8\u57FA\u51C6\uFF0C\u5982 `C4`\u3001`F#3`",type:"string",default:null},{name:"size",description:"\u8C03\u6027\u8BB0\u53F7\u5B57\u53F7",type:"length",default:{value:1,unit:"em"}}]};tonality;size;font;displayName;displayAcc;constructor(t,e,n,o=null){super(t,o);let[s,i]=this.getArgValue(e,n);this.font=n.variables.numberfont,this.tonality=s,this.size=n.length2px(i);let c=ec(s);if(c!==s){if(n.variables.strict)throw new w("E_KEY_TONALITY",`@key \u65E0\u6CD5\u89E3\u6790\u8C03\u6027 "${s}"`,t);this.tonality=c??fe,n.diagnostics.push(new P("W_KEY_TONALITY",`@key \u7684\u8C03\u6027 "${s}" \u4E0D\u662F\u89C4\u8303\u5199\u6CD5\uFF0C\u5DF2\u81EA\u52A8\u5207\u6362\u5230 ${this.tonality}`,t))}this.displayName=this.tonality[0],this.displayAcc=this.tonality[1]==="#"||this.tonality[1]==="b"?this.tonality[1]:""}loweringEnter(){return[new ro(this)]}toString(){return`@1(${this.tonality})`}},Ue=io,so="1=",ro=class extends ${accidentals=[];nameX=0;textBaselineY=0;style;constructor(t){super(),this.ast=t,this.style={fontSize:t.size,fontFamily:t.font,fill:"#000"},this.initLayoutBox()}onTimeState(t){t.keySignature=this.ast.tonality}prepareLayout(t){let e=this.ast.size,n=this.style,o=t.textMeasurer.measureText(so,n),s=t.textMeasurer.measureText(this.ast.displayName,n),i=e*.02,{placed:c,right:a,top:l}=Ye(this.ast.displayAcc,e,o.w,o.baseline,i);this.accidentals=c;let h=-l;for(let p of c)p.y+=h;this.nameX=a,this.textBaselineY=h+o.baseline,this.box.w=a+s.w,this.box.h=h+Math.max(o.h,s.h),this.box.anchor=t.textMeasurer.measureText(so[0],n).w/2,this.box.visualAxis=this.box.h/2}paint(t){let e=this.style;t.drawText(so,this.box.x,this.box.y+this.textBaselineY,e);for(let n of this.accidentals)Ke(t,n,this.box,"#000");t.drawText(this.ast.displayName,this.box.x+this.nameX,this.box.y+this.textBaselineY,e)}};var ai=new WeakMap;function ne(r){let t=1/0,e=1/0,n=-1/0,o=-1/0,s=(i,c,a,l)=>{t=Math.min(t,i),e=Math.min(e,c),n=Math.max(n,i+a),o=Math.max(o,c+l)};for(let i of r){let c=i.dx??0;if(i.circle){let{cx:a,cy:l,r:h}=i.circle;s(a+c-h,l-h,2*h,2*h)}if(i.path?.length){let a=ai.get(i.path)??xt(i.path);ai.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,n-t),h:Math.max(1e-9,o-e)}:{x:0,y:0,w:1e-9,h:1e-9}}function je(r,t,e,n,o){let s=n.x-e.x*o,i=n.y-e.y*o;for(let c of t){let a=c.style,l=a.strokeWidth===void 0?a:{...a,strokeWidth:a.strokeWidth*o},h=s+(c.dx??0)*o;c.path&&r.drawPath(c.path,l,{x:h,y:i,scaleX:o,scaleY:o}),c.circle&&r.drawCircle(h+c.circle.cx*o,i+c.circle.cy*o,c.circle.r*o,l)}}var co=[{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"}}],Te=ne(co);var ao=new WeakMap;function nc(r,t,e){let n=r.currentEvent??t,o=t.ast.sourceSpan,s=ao.get(n);s||ao.set(n,s={start:o.start,end:o.end,meter:e}),s.end=o.end,s.meter=e}var lo=class extends L{static def={name:["meter"],description:"\u8BBE\u7F6E\u62CD\u53F7",details:`~~~jpfun
|
|
24
30
|
@meter(6, 8)
|
|
25
31
|
~~~
|
|
26
|
-
\u8BBE\u7F6E \`6/8\` \u62CD\u53F7\uFF1A\u6BCF\u5C0F\u8282\u542B\u516D\u4E2A\u516B\u5206\u97F3\u7B26\u7684\u65F6\u503C
|
|
32
|
+
\u8BBE\u7F6E \`6/8\` \u62CD\u53F7\uFF1A\u6BCF\u5C0F\u8282\u542B\u516D\u4E2A\u516B\u5206\u97F3\u7B26\u7684\u65F6\u503C\u3002
|
|
33
|
+
\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,n,o=null){super(t,o);let[s,i,c]=this.getArgValue(e,n);if(this.font=n.variables.numberfont,!Number.isSafeInteger(s)||!Number.isSafeInteger(s*4)||s<0||!Number.isSafeInteger(i)||i<0){let a="@meter \u7684\u5206\u5B50\u548C\u5206\u6BCD\u5FC5\u987B\u662F\u975E\u8D1F\u6574\u6570";if(n.variables.strict)throw new w("E_METER_INVALID",a,t);n.diagnostics.push(new P("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 B(s*4,i)),this.size=n.length2px(c),this.strict=n.variables.strict}loweringEnter(){return[new ho(this)]}static loweringFinalize=t=>{let e=new B,n=new B,o=null,s=!1,i=0,c=(a,l)=>{if(!(!o?.measureDuration||a.equals(e))){if(n.copyFrom(a).sub(e),!n.equals(o.measureDuration)&&(s||n.compare(o.measureDuration)>0)){let h=`\u5C0F\u8282\u65F6\u957F\u4E3A ${n} QN\uFF0C\u4E0D\u6EE1\u8DB3 ${o.numerator}/${o.denominator} \u62CD\u53F7`,p={start:i,end:l};if(o.strict)throw new w("E_METER_MISMATCH",h,p);t.diagnostics.push(new P("W_METER_MISMATCH",h,p))}e.copyFrom(a)}};for(let a of t.columns){let l=a[0].t;for(let p of a){let f=ao.get(p);f&&(c(l,f.start),o=f.meter,e.copyFrom(l),i=f.end)}let h=a.find(p=>p.mergeKey===nt);h&&(c(l,h.ast.sourceSpan.end),i=h.ast.sourceSpan.end,s=!0)}if(o){let a=t.columns.at(-1)?.at(-1)?.ast.sourceSpan??o.sourceSpan;c(t.duration,a.end)}};toString(){return`@meter(${this.numerator}, ${this.denominator})`}},Xe=lo,ho=class extends ${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,nc(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*Te.w/Te.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),n=t.textMeasurer.measureText(String(this.ast.denominator),this.style),o=this.ast.size*.08,s=this.ast.size*.08;this.lineHeight=Math.max(1,this.ast.size*.06),this.numeratorBaseline=e.baseline,this.lineY=e.h+o,this.denominatorBaseline=this.lineY+this.lineHeight+o+n.baseline,this.box.w=Math.max(e.w,n.w)+s*2,this.box.h=this.lineY+this.lineHeight+o+n.h,this.box.anchor=this.box.w/2,this.box.visualAxis=this.lineY+this.lineHeight/2}paint(t){if(!this.ast.measureDuration){je(t,co,Te,this.box,this.ast.size/Te.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)}};var oc=[{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 li(r){let t=r/11;return{w:3.864*t,h:10.88*t,stemCenterX:(3.304+3.864)/2*t,commands:oc,scale:t}}var po=class extends L{static def={name:["tempo"],description:"\u8BBE\u7F6E\u65F6\u95F4\u7EBF\u4E0A\u7684\u901F\u5EA6",details:`~~~jpfun
|
|
27
34
|
@tempo(96)
|
|
28
35
|
~~~
|
|
29
|
-
\u901F\u5EA6\u4ECE\u5F53\u524D\u65F6\u95F4\u4F4D\u7F6E\u8D77\u751F\u6548\uFF1B\u7528 \`1 ^ @tempo(96)\` \u53EF\u5C06\u8BB0\u53F7\u53E0\u5728\u97F3\u7B26\u4E0A\u65B9`,allowExtraArgs:!1,args:[{name:"bpm",description:"\u6BCF\u5206\u949F\u56DB\u5206\u97F3\u7B26\u6570",type:"number",default:null},{name:"size",description:"\u901F\u5EA6\u8BB0\u53F7\u5B57\u53F7",type:"length",default:{value:1,unit:"em"}}]};bpm;size;font;constructor(t,e,n,o=null){super(t,o);let[s,
|
|
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,n,o=null){super(t,o);let[s,i]=this.getArgValue(e,n);this.bpm=s,this.size=n.length2px(i),this.font=n.variables.font}loweringEnter(){return[new fo(this)]}toString(){return`@tempo(${this.bpm}, size=${this.size}px)`}},Ze=po,fo=class extends ${glyph;text;style;glyphY=0;textX=0;textBaselineY=0;constructor(t){super(),this.ast=t,this.glyph=li(t.size),this.text=`= ${t.bpm}`,this.style={fontSize:t.size,fontFamily:t.font,fill:"#000"},Number.isFinite(t.bpm)&&t.bpm>0&&(this.playbackState={bpm:t.bpm}),this.initLayoutBox()}onTimeState(t){let e=this.playbackState?.bpm;e!==void 0&&(t.bpm=e)}prepareLayout(t){let e=this.glyph,n=t.textMeasurer.measureText(this.text,this.style),o=Math.max(0,e.h-n.baseline);this.textX=e.w+this.ast.size*.26,this.textBaselineY=o+n.baseline,this.glyphY=this.textBaselineY-e.h,this.box.w=this.textX+n.w,this.box.h=o+n.h,this.box.anchor=e.stemCenterX,this.box.visualAxis=o+n.h/2}paint(t){t.drawPath(this.glyph.commands,{fill:"#000"},{x:this.box.x,y:this.box.y+this.glyphY,scaleX:this.glyph.scale,scaleY:this.glyph.scale}),t.drawText(this.text,this.box.x+this.textX,this.box.y+this.textBaselineY,this.style)}};var uo=class extends L{static def={name:["text"],description:"\u6587\u672C\u6807\u8BB0",details:`~~~jpfun
|
|
30
37
|
@text(\u8FDB\u5165\u4E3B\u9898, size=0.8em, align=center)
|
|
31
38
|
~~~
|
|
32
|
-
**\u7B80\u5199**\uFF1A\u76F4\u63A5\u5199\u53CC\u5F15\u53F7\u6587\u672C\uFF0C\u5982 \`"\u8FDB\u5165\u4E3B\u9898"\`\uFF1B\u53EF\u8DE8\u884C\uFF0C\u53CC\u5F15\u53F7\u987B\u914D\u5BF9`,allowExtraArgs:!1,args:[{type:"string",description:"\u6587\u672C\u5185\u5BB9\uFF0C\u53EF\u76F4\u63A5\u6362\u884C\uFF1B\u542B\u9017\u53F7\u7B49\u6B67\u4E49\u5B57\u7B26\u65F6\u9700\u52A0\u5F15\u53F7",default:null},{name:"size",description:"\u6587\u672C\u5B57\u53F7",type:"length",default:{value:.8,unit:"em"}},{name:"lineheight",description:"\u76F8\u5BF9\u81EA\u8EAB\u5B57\u53F7\u7684\u884C\u9AD8\u500D\u6570",type:"number",default:1.25},{name:"align",description:"\u6587\u672C\u5BF9\u9F50\u65B9\u5F0F\uFF1A`left`\u3001`center` \u6216 `right`",type:"string",default:"left"},{name:"font",description:"\u6587\u672C\u5B57\u4F53\uFF0C\u7A7A\u503C\u6CBF\u7528\u5F53\u524D\u5B57\u4F53\u8BBE\u7F6E",type:"string",default:""}]};static deSugarAtom(t,e,n){if(t[e]!=='"')return null;let o=
|
|
33
|
-
`))}, size=${this.size}px, lineheight=${t}, align=${this.align}, font=${
|
|
34
|
-
`;)t++;return t}function
|
|
35
|
-
`)||typeof
|
|
36
|
-
`&&
|
|
39
|
+
**\u7B80\u5199**\uFF1A\u76F4\u63A5\u5199\u53CC\u5F15\u53F7\u6587\u672C\uFF0C\u5982 \`"\u8FDB\u5165\u4E3B\u9898"\`\uFF1B\u53EF\u8DE8\u884C\uFF0C\u53CC\u5F15\u53F7\u987B\u914D\u5BF9`,allowExtraArgs:!1,args:[{type:"string",description:"\u6587\u672C\u5185\u5BB9\uFF0C\u53EF\u76F4\u63A5\u6362\u884C\uFF1B\u542B\u9017\u53F7\u7B49\u6B67\u4E49\u5B57\u7B26\u65F6\u9700\u52A0\u5F15\u53F7",default:null},{name:"size",description:"\u6587\u672C\u5B57\u53F7",type:"length",default:{value:.8,unit:"em"}},{name:"lineheight",description:"\u76F8\u5BF9\u81EA\u8EAB\u5B57\u53F7\u7684\u884C\u9AD8\u500D\u6570",type:"number",default:1.25},{name:"align",description:"\u6587\u672C\u5BF9\u9F50\u65B9\u5F0F\uFF1A`left`\u3001`center` \u6216 `right`",type:"string",default:"left"},{name:"font",description:"\u6587\u672C\u5B57\u4F53\uFF0C\u7A7A\u503C\u6CBF\u7528\u5F53\u524D\u5B57\u4F53\u8BBE\u7F6E",type:"string",default:""}]};static deSugarAtom(t,e,n){if(t[e]!=='"')return null;let o=Lt(t,e,n);if(o<0)return null;let s={kind:"call",typed:!0,name:"text",args:new Map([[0,Dt(t.slice(e,o+1))]]),span:{start:e,end:o+1},syntaxKind:"string"};return{next:o+1,node:s}}lines;size;lineAdvance;align;font;constructor(t,e,n,o=null){super(t,o);let[s,i,c,a,l]=this.getArgValue(e,n);if(this.font=l||n.variables.font,a!=="left"&&a!=="center"&&a!=="right")throw new 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=n.length2px(i),this.lineAdvance=c*this.size,this.align=a}loweringEnter(){return[new xo(this)]}toString(){let t=this.size===0?1.25:this.lineAdvance/this.size;return`@text(${ht(this.lines.join(`
|
|
40
|
+
`))}, size=${this.size}px, lineheight=${t}, align=${this.align}, font=${ht(this.font)})`}},qe=uo,xo=class extends ${style;textBaselineY=0;constructor(t){super(),this.ast=t,this.mergeKey=dt,this.style={fontSize:t.size,fontFamily:t.font,fill:"#000",textAlign:t.align},this.initLayoutBox()}prepareLayout(t){let{lines:e,align:n,lineAdvance:o}=this.ast,s=a=>t.textMeasurer.measureText(a,this.style),i=s(e[0]),c=i.w;for(let a=1;a<e.length;a++)c=Math.max(c,s(e[a]).w);if(this.box.w=c,this.box.h=(e.length-1)*o+i.h,this.box.visualAxis=this.box.h/2,this.textBaselineY=i.baseline,n==="center")this.box.anchor=c/2;else if(n==="right"){let a=[...e[0]].at(-1);this.box.anchor=c-(a?s(a).w/2:0)}else{let a=[...e[0]][0];this.box.anchor=a?s(a).w/2:0}}paint(t){let{lines:e,align:n,lineAdvance:o}=this.ast,s=this.box.x+(n==="center"?this.box.w/2:n==="right"?this.box.w:0),i=this.box.y+this.textBaselineY;for(let c of e)t.drawText(c,s,i,this.style),i+=o}};var hi={title:"center",subtitle:"center",author:"right",signature:"left",tempo:"left",left:"left",center:"center",right:"right"},sc={title:[2,"center"],subtitle:[.85,"center"],author:[.8,"right"]},ic=.25,pi=5,fi=1e4;function Qe(r,t){return t.length===1&&t[0]instanceof tt?t[0]:new tt(r,t)}function ui(r,t,e=r.length){for(;t<e&&r[t]!=="\r"&&r[t]!==`
|
|
41
|
+
`;)t++;return t}function rc({columns:r,rows:t,start:e,end:n,X:o,fixed:s,options:i},c){jt(r.slice(e,n+1),t,o.subarray(e,n+1),s.subarray(e,n),1/0,i);let a=1/0,l=-1/0;for(let h=e+1;h<n;h++)for(let p=0;p<t;p++)a=Math.min(a,o[h]-r[h][p].WL),l=Math.max(l,o[h]+r[h][p].WR);c&&a<=l?(o[e]=a,o[n]=l):o[n]=o[e]}var Je=class extends ${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:n}=t;return{laneKey:`head/rows/${n.sourceSpan.start}/${e}`,hostIndex:null,measure:o=>{let s,i;e==="center"&&(this.titleBottom=0);let c=o.map(a=>{if(!a)return null;let l=i===void 0?0:i+n.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 o=this.sideExtents[e];if(!o)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)-o.bottom}}}prepareHead(t){if(this.members.some(s=>I(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,n,o]=this.slots;e.start.springConfig.alpha_L=0,o.end.springConfig.alpha_R=0,this.stretch(n.start,"L"),this.stretch(n.end,"R");for(let s of this.slots)t.registerHorizontalLayoutHook(s.start,s.end,i=>rc(i,s===n))}alignHead(){let t=new Map;for(let o of this.members){if(!I(o))continue;let s=this.sideCellOf(o.ast);if(!s)continue;let i=t.get(s);i?i.push(o):t.set(s,[o])}let[e,,n]=this.slots;this.packRows(e.ast,e.start.box.x,t),this.packRows(n.ast,n.end.box.x,t)}stretch(t,e){let n=e==="L"?"alpha_L":"alpha_R",o=e==="L"?"beta_L":"beta_R";t.springConfig[n]=t.springConfig[n]*fi,t.springConfig[o]=t.springConfig[o]*3/fi}packRows(t,e,n){let o=this.ast.owner.size*ic,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=n.get(a[h]);if(!p)continue;let f=1/0,d=-1/0;for(let m of p)f=Math.min(f,m.box.x),d=Math.max(d,m.box.x+m.box.w);let u=l-(s?f:d);for(let m of p)m.box.x+=u;for(let m of p)m.onPlaced?.();l+=i*(d-f+o)}}}sideCellOf(t){let e=t;for(;e.parent;){let n=e.parent,o=n instanceof zt?n:n instanceof tt&&n.parent instanceof zt?n.parent:null;if(o?.owner===this.ast.owner)return o.name==="center"?null:e;e=n}return null}},zt=class extends st{owner;name;rows;constructor(t,e,n,o){super(t,e),this.owner=e,this.name=n,this.rows=o;for(let s of this.rows)s.parent=this}get size(){return this.owner.size}get children(){return this.rows}timeFlowModel(t){if(this.rows.length===0)return null;let e=t.getTemporalNodes(this.owner.slots[0])[0];return{mode:"parallel",children:this.rows,tracks:e.createTracks(this)}}loweringEnter(t){let e=new Je(this);return this.name==="left"&&t.beginLoweringGroup(this.owner,e),[e]}loweringExit(){return[new Je(this)]}addRow(t){t.parent=this,this.rows.push(t)}},mo=class r extends L{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:pi,unit:"px"}}]};slots;size;gap;createdBySugar=!1;get children(){return this.slots}timeFlowModel(){return{mode:"sequence",children:this.slots}}static deSugarAtom(t,e,n){if(t[e]!=="H"||t[e+1]!==".")return null;let o=e+2;for(;o<n&&t[o]>="a"&&t[o]<="z";)o++;let s=t.slice(e+2,o);if(!Object.hasOwn(hi,s)||t[o]!==":")return null;o++;let i=ui(t,o,n),c=wt(t,o,i);return{next:t[c]==="@"||t[c]==="{"?o:i,node:{kind:"sugar",data:{class:r,field:s},span:{start:e,end:o}}}}static deSugarRelation(t,e,n){let o=e[n++];if(o.data?.class!==r)return null;let s=o.data.field,i=n;for(;i<e.length;i++){let y=e[i];if(typeof y=="number"&&(t.source[y]==="\r"||t.source[y]===`
|
|
42
|
+
`)||typeof y!="number"&&y.kind==="sugar"&&y.data?.class===r)break}let c=e[i],a;if(typeof c=="number")a=c;else if(c)a=c.span.start;else if(i>n){let y=e[i-1];a=typeof y=="number"?y+1:y.span.end}else a=ui(t.source,o.span.end);let l=wt(t.source,o.span.end,a),h=Ce(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.${s}: \u540E\u5FC5\u987B\u6709\u5185\u5BB9`,o.span);let f=t.source.slice(p.start,p.end).trim(),d;if(f.startsWith("@")||f.startsWith("{")){let y=new pt(t);y.makeNodes(e.slice(n,i)),d=y.nodes}let u=t.nodes.at(-1),m=u instanceof r&&u.createdBySugar?u:new r(o.span,new Map,t,null);if(m.createdBySugar=!0,m.slots.find(y=>y.name===hi[s]).addRow(r.parseSugarRow(t,s,p,f,d)),m.sourceSpan.end=p.end,m!==u&&t.pushNode(m),typeof c!="number")return i;let x=i+1;if(t.source[c]==="\r"){let y=e[x];typeof y=="number"&&t.source[y]===`
|
|
43
|
+
`&&x++}return x}static parseSugarRow(t,e,n,o,s){if(s!==void 0)return Qe(n,s);if(e==="signature"){let a=/^(1\s*=\s*(\S+))\s+((\d+)\s*\/\s*(\d+))$/.exec(o);if(!a)throw new w("E_HEAD_INVALID_SIGNATURE","H.signature \u7684\u683C\u5F0F\u5E94\u4E3A 1=C 4/4",n);let l={start:n.start,end:n.start+a[1].length},h={start:n.end-a[3].length,end:n.end};return Qe(n,[new Ue(l,new Map([["tonality",a[2]]]),t,null),new Xe(h,new Map([["num",Number(a[4])],["den",Number(a[5])]]),t,null)])}if(e==="tempo"){let a=Number(o);if(!Number.isFinite(a)||a<=0)throw new w("E_HEAD_INVALID_TEMPO","H.tempo \u540E\u5FC5\u987B\u662F\u6B63\u6570",n);return Qe(n,[new Ze(n,new Map([["bpm",a]]),t,null)])}let i=new Map([[0,o]]),c=sc[e];return c&&(i.set("size",{value:c[0],unit:"em"}),i.set("align",c[1])),Qe(n,[new qe(n,i,t,null)])}constructor(t,e,n,o=null){super(t,o),this.size=n.variables.fontsize,this.gap=n.length2px(this.getArgValue(e,n)[3]);let s=(i,c)=>{let a=e.get(i)??e.get(c);return a instanceof st?a instanceof tt?a.content:[a]:[]};this.slots=[new zt(t,this,"left",s("left",0)),new zt(t,this,"center",s("center",1)),new zt(t,this,"right",s("right",2))]}loweringExit(t){let e=t.endLoweringGroup(this);e.slots=this.slots.map(n=>{let[o,s]=t.getTemporalNodes(n);return{ast:n,start:o,end:s}}),e.slots[2].end.onTimeState=()=>e.validateDuration();for(let n of e.members)if((n.addon?.breakBefore??0)>0)throw new w("E_HEAD_INTERNAL_BREAK","@head \u7684\u5185\u90E8\u4E0D\u80FD\u6362\u884C\u6216\u6362\u9875\uFF1B\u7B2C\u4E00\u5C42\u5185\u5BB9\u5DF2\u7ECF\u8868\u793A\u89C6\u89C9\u884C",n.ast.sourceSpan);return[]}toString(t){let e=this.slots.filter(n=>n.rows.length>0).map(n=>{let o=n.rows.map(s=>` ${s.toString(t).replaceAll(`
|
|
37
44
|
`,`
|
|
38
45
|
`)}`).join(`
|
|
39
46
|
`);return` ${n.name}={
|
|
40
47
|
${o}
|
|
41
|
-
}`});return this.gap!==
|
|
48
|
+
}`});return this.gap!==pi&&e.push(` gap=${this.gap}px`),`@head(
|
|
42
49
|
${e.join(`,
|
|
43
50
|
`)}
|
|
44
|
-
)`}},
|
|
51
|
+
)`}},di=mo;var yo=class extends L{static def={name:["br"],description:"\u6362\u884C",details:`~~~jpfun
|
|
45
52
|
1 2 @br() 3 4
|
|
46
53
|
~~~
|
|
47
54
|
|
|
48
55
|
\`@br()\` \u6362\u5230\u4E0B\u4E00\u884C\uFF0C\`@br(2)\` \u7A7A\u51FA\u4E00\u884C\u518D\u7EE7\u7EED
|
|
49
56
|
|
|
50
57
|
**\u7B80\u5199**\uFF1A\u4EC5\u5728\u9876\u5C42\uFF0C\u8FDE\u7EED\u81F3\u5C11\u4E24\u4E2A\u6362\u884C\u8868\u793A\u6362\u884C`,allowExtraArgs:!1,args:[{name:"offset",description:"\u540E\u7EED\u5185\u5BB9\u504F\u79FB\u7684\u8C31\u9762\u884C\u6570\uFF0C2 \u8868\u793A\u7A7A\u51FA\u4E00\u884C\u518D\u7EE7\u7EED",type:"number",default:1}]};static deSugarAtom(t,e,n,o){if(o>0||t[e]!==`
|
|
51
|
-
`||t[
|
|
52
|
-
`)return null;let s=e+1,
|
|
53
|
-
`;)s=++r;return{next:s,node:{kind:"call",typed:!0,name:"br",args:new Map,span:{start:e,end:s}}}}offset;loweringEnter(){let t=new W;return t.ast=this,t.mergeKey=-1,t.breakBefore=this.offset,[t]}static loweringFinalize=t=>{let e=new I,n=new I,o=null;for(let s of t.columns){if(o&&e.compare(s[0].t)>0&&s.some(r=>r.breakBefore>0))throw N.error.BreakInsideEvent(o.ast.sourceSpan);for(let r of s)r.T.isZero()||(n.copyFrom(r.t).add(r.T),(!o||n.compare(e)>0)&&(e.copyFrom(n),o=r))}};constructor(t,e,n,o=null){super(t,o);let[s]=this.getArgValue(e,n);this.offset=Number.isFinite(s)?Math.max(1,Math.floor(s)):1,this.offset!==s&&n.diagnostics.push(new O("W_BR_OFFSET",`@br \u7684 offset \u5FC5\u987B\u662F\u5927\u4E8E\u7B49\u4E8E 1 \u7684\u6574\u6570\uFF0C\u5DF2\u88AB\u4FEE\u6B63\u4E3A ${this.offset}`,this.sourceSpan))}toString(){return`@br(${this.offset})`}},Ps=jn;var Xn=10,Zn=13,Cr=9,Ar=11,Lr=12,Tr=32,Er=160,_r=5760,vr=8239,Nr=8287,kr=12288,Mr=65279,Rr=34,Fs=92,Or=37,Ir=32,Pr=[];function Fr(i){return i>Ir?" ".repeat(i):Pr[i]??=" ".repeat(i)}function Ds(i){return i===Tr||i===Cr||i===Ar||i===Lr?!0:i<128?!1:i===Er||i===_r||i>=8192&&i<=8202||i===vr||i===Nr||i===kr||i===Mr}function Xt(i){let t=i.length,e=[0],n=[],o=[],s=(x,m)=>{if(x>=m)return;let b=o.length;if(b>=2&&x<=o[b-1]){m>o[b-1]&&(o[b-1]=m);return}o.push(x,m)},r=(x,m)=>{if(m<=0)return;let b=x+m;for(let w=x;w<b;w+=2)s(w,w+1)},c=0,a=!1,l=!1,h=-1,p=-1,f=-1,d=0,u=(x,m)=>{if(m===Fs){d>0&&p+1===x?d++:(f=x,d=1),p=x;return}f=-1,d=0,p=x};for(let x=0;x<t;){let m=i.charCodeAt(x);if(m===Zn||m===Xn){let b=m===Zn&&x+1<t&&i.charCodeAt(x+1)===Xn?2:1;e.push(x+b);let w=(d&1)===1;r(f,d),h>=0&&(s(h,x),n.push({start:h,end:x}),h=-1),w&&s(x,x+b),p=-1,f=-1,d=0,l=!1,x+=b;continue}if(c!==0){l?l=!1:m===Fs?l=!0:m===c&&(c=0),Ds(m)||u(x,m),x++;continue}if(m===Rr){a||(gt(i,x,t)<0?a=!0:c=m),u(x,m),x++;continue}if(m===Or){for(h=x,x++;x<t;){let b=i.charCodeAt(x);if(b===Zn||b===Xn)break;x++}continue}Ds(m)||u(x,m),x++}if(r(f,d),h>=0&&(s(h,t),n.push({start:h,end:t})),o.length===0)return{maskedSource:i,lineStarts:e,commentSpans:n};let g=[],y=0;for(let x=0;x<o.length;x+=2){let m=o[x],b=o[x+1];y<m&&g.push(i.slice(y,m)),g.push(Fr(b-m)),y=b}return y<t&&g.push(i.slice(y)),{maskedSource:g.join(""),lineStarts:e,commentSpans:n}}var bt="CDEFGAB",Ge=(i,t)=>(i%t+t)%t,Dr=i=>i<0?"b".repeat(-i):"#".repeat(i);function Ve(i){throw new S("E_NOTE_TRANSFORM","\u65E0\u6CD5\u5B89\u5168\u6539\u5199\u6B64\u97F3\u7B26\u7684\u97F3\u9AD8",i)}function $r(i,t){let e=t==="to-absolute"||t!=="to-relative"&&bt.includes(i.ast.name),n=i.resolvedMidi+(t==="semitone-up"?1:t==="semitone-down"?-1:0),o=kt(i.keySignature,4);[n,o,i.ast.octave,i.ast.jeOctaveOffset].every(Number.isSafeInteger)||Ve(i.ast.sourceSpan);let s=t==="semitone-down"?Es:Oe,r,c,a;if(t==="to-absolute"){let l=bt.indexOf(i.keySignature[0]),h=l<0?bt.indexOf(Oe[Ge(o,12)][0]):l,p=Number(i.ast.name)-1;r=bt[(h+p)%7];let f=Ge(o-dt[bt[h]]+6,12)-6;a=Math.floor((o-f)/12)-1+Math.floor((h+p)/7)+i.ast.octave+i.ast.jeOctaveOffset,c=Dr(n-((a+1)*12+dt[r]))}else if(t==="to-relative"){let l=i.ast,h=bt.includes(i.keySignature[0])?i.keySignature:Oe[Ge(o,12)]+(Math.floor(o/12)-1),p=fe(l.name,l.acc,l.octave+l.jeOctaveOffset,h);p||Ve(l.sourceSpan),{renderName:r,renderAcc:c,renderOctave:a}=p}else{let l=e?n:n-o,h=s[Ge(l,12)];r=e?h[0]:String(bt.indexOf(h[0])+1),c=h.slice(1),a=Math.floor(l/12)-(e?1:0)}return{name:r,acc:c,octave:a-i.ast.jeOctaveOffset,absolute:e}}function Br(i,t){for(let e=t.parent;e;e=e.parent){let n=he(i,e.sourceSpan.start,e.sourceSpan.end);if(!n)continue;let o=n.args.find(r=>r.valueSpan.start<=t.sourceSpan.start&&r.valueSpan.end>=t.sourceSpan.end);if(!o)continue;let s=0;for(let r=o.valueSpan.start;r<t.sourceSpan.start;r++)i[r]==='"'?r=gt(i,r,o.valueSpan.end):i[r]==="{"?s++:i[r]==="}"&&s--;return s===0}return!1}function $s(i,t,e,n){let{maskedSource:o}=Xt(i),s=[],r=[];function c(l,h){i.slice(l.start,l.end)!==h&&(i.slice(l.start,l.end)!==o.slice(l.start,l.end)&&Ve(l),s.push({span:l,text:h}))}for(let l of t){let M=function(T,E,C){let _=!C||C.includes(",")||T&&i[T.start]==='"'?rt(C):C;T?c(T,_):k.push(`${E}=${_}`)};var a=M;let{ast:h}=l,p=h.sourceSpan,f=he(o,p.start,p.end),d=f?.span.end===p.end&&f.closeParenSpan,u=e==="to-absolute"&&bt.includes(h.name)||e==="to-relative"&&/^[1-7]$/.test(h.name);if(d||r.push({span:p,text:i.slice(p.start,p.end)}),n&&!n.some(T=>T.start<=p.start&&T.end>=p.end)||l.resolvedMidi===null||u)continue;let g=$r(l,e),y=g.absolute?String(g.octave):g.octave<0?",".repeat(-g.octave):"'".repeat(g.octave),x=(T,E)=>g.absolute?g.name+T+E:T+g.name+E;if(!d){let T=x(g.acc,y);T.includes(",")&&Br(o,h)&&(T=`{${T}}`),r[r.length-1].text=T;continue}let m=new Map;f.args.forEach((T,E)=>{T.valueSpan.start!==T.valueSpan.end&&m.set(T.nameSpan?o.slice(T.nameSpan.start,T.nameSpan.end).toLowerCase():E,T.valueSpan)});let b=m.get("name")??m.get(0),w=m.get("acc")??m.get(1),A=m.get("octave")??m.get(2),k=[];if(M(b,"name",x(w?"":g.acc,A?"":y)),w?M(w,"acc",g.acc):h.hasDefaultAcc&&k.push('acc=""'),A&&c(A,String(g.octave)),k.length){let T=f.closeParenSpan.start,E=o.slice(f.openParenSpan.end,T).trimEnd();c({start:T,end:T},(E?E.endsWith(",")?" ":", ":"")+k.join(", "))}}r.sort((l,h)=>l.span.start-h.span.start);for(let l=0;l<r.length-1;l++){let h=r[l],p=r[l+1];if(h.span.end!==p.span.start||h.text.endsWith("}"))continue;let f=Nt(h.text+p.text);(f instanceof N||f.next!==h.text.length)&&(h.text!==i.slice(h.span.start,h.span.end)?h.text+=" ":p.text=" "+p.text)}for(let l of r)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&&Ve(s[l].span);return s}function Bs(i,t,e,n){let o=t.diagnostics.find(c=>c instanceof S);if(o)throw o;let s=[...t.astToTemporal.values()].flat().filter(c=>c instanceof Ye),r=t.diagnostics.find(c=>s.some(a=>c.span.start<a.ast.sourceSpan.end&&c.span.end>a.ast.sourceSpan.start));if(r)throw r;return $s(i,s,e,n)}var qn="note.jeOctaveOffset",Qn=class extends v{static def={name:["note","n"],description:"\u521B\u5EFA\u97F3\u7B26",details:"~~~jpfun\n@note(A, acc=#, octave=3, color=#c33)\n~~~\n**\u7B80\u5199**\uFF1A\u6570\u5B57\u97F3\u540D\u6309\u201C\u5347\u964D\u53F7\u3001\u97F3\u540D\u3001\u76F8\u5BF9\u516B\u5EA6\u201D\u4E66\u5199\uFF1B\u5B57\u6BCD\u97F3\u540D\u6309\u201C\u97F3\u540D\u3001\u5347\u964D\u53F7\u3001\u7EDD\u5BF9\u516B\u5EA6\u201D\u4E66\u5199\u3002`1,,` \u6BD4\u5F53\u524D\u8C03\u6027\u57FA\u51C6\u4F4E\u4E24\u4E2A\u516B\u5EA6\uFF0C`1'` \u9AD8\u4E00\u4E2A\u516B\u5EA6\u3002\n- \u7B80\u5199\u7684\u5347\u964D\u53F7\u5B8C\u5168\u7531\u81EA\u8EAB\u51B3\u5B9A\uFF0C\u7701\u7565\u65F6\u4E3A\u7A7A\uFF0C\u4E0D\u7EE7\u627F `@set(note.acc=...)`\uFF1B\u663E\u5F0F\u8C03\u7528\u7701\u7565 `acc` \u65F6\u4ECD\u7EE7\u627F\u9ED8\u8BA4\u503C\n- `A#3` \u7B49\u4EF7\u4E8E `@note(A, #, 3)`\uFF0C\u9ED8\u8BA4 `acc` \u4E3A\u7A7A\u65F6\u4E5F\u7B49\u4EF7\u4E8E `@note(A#3)`\n- `#1'` \u7B49\u4EF7\u4E8E `@note(1, #, 1)`\uFF0C\u9ED8\u8BA4 `acc` \u4E3A\u7A7A\u65F6\u4E5F\u7B49\u4EF7\u4E8E `@note(\"#1'\")`\n- \u652F\u6301\u7EC4\u5408\u5347\u964D\u53F7\uFF0C\u5982 `A##bn99`\uFF1B\u65E0\u6B67\u4E49\u65F6\u4E5F\u63A5\u53D7\u540E\u7F6E\u5199\u6CD5\uFF0C\u5982 `A3#`\u3001`6#,,`\n- \u5347\u964D\u53F7\u540E\u7D27\u8DDF\u6570\u5B57\u65F6\u5F52\u5165\u4E0B\u4E00\u97F3\u7B26\uFF1A`6#3` \u89E3\u6790\u4E3A `6` \u548C `#3`",allowExtraArgs:!1,args:[{name:"name",description:"\u6570\u5B57\u97F3\u540D\u6216\u5927\u5199\u5B57\u6BCD\u97F3\u540D\uFF0C\u53EF\u81EA\u5E26\u5347\u964D\u53F7\u4E0E\u516B\u5EA6\uFF1B`0` / `Z` \u4E3A\u4F11\u6B62\u7B26\uFF0C`8` \u4E3A\u9690\u5F62\u5360\u4F4D\uFF0C`9` / `X` \u4E3A\u8282\u62CD\u8BB0\u53F7\uFF0C\u540E\u4E09\u7C7B\u4E0D\u663E\u793A\u5347\u964D\u53F7\u548C\u516B\u5EA6\u70B9",type:"string",default:null},{name:"acc",description:"\u989D\u5916\u5347\u964D\u53F7\uFF0C`##` \u518D\u5347\u4E24\u4E2A\u534A\u97F3\uFF0C`b` \u518D\u964D\u4E00\u4E2A\u534A\u97F3",type:"string",default:""},{name:"octave",description:"\u5B57\u6BCD\u97F3\u540D\u4F7F\u7528\u7EDD\u5BF9\u516B\u5EA6\uFF1B\u6570\u5B57\u97F3\u540D\u4F7F\u7528\u76F8\u5BF9\u516B\u5EA6\uFF0C\u7701\u7565\u65F6\u4E3A 0",type:"number",default:4},{name:"color",description:"\u97F3\u7B26\u989C\u8272\uFF0C\u4F7F\u7528 CSS \u989C\u8272\u503C",type:"string",default:"#000"}]};static deSugarAtom(t,e,n){let o=0;switch(t[e]){case"(":case"]":o=-1;break;case"[":case")":o=1;break}if(o)return{next:e+1,node:{kind:"sugar",data:{jeOffset:o},span:{start:e,end:e+1},syntaxKind:"punctuation"}};let s=Nt(t,e,n);if(s instanceof N)return null;let r=new Map;r.set("name",s.name),s.octave!==null&&r.set("octave",s.octave),r.set("acc",s.acc??"");let c={kind:"call",typed:!0,name:"note",args:r,span:{start:e,end:s.next},syntaxKind:"atom"};return{next:s.next,node:c}}static deSugarRelation(t,e,n){let o=e[n],s=o.data?.jeOffset;return typeof s!="number"?null:(t.variables[qn]=(t.variables[qn]??0)+s,t.nodes.push(new Z(o.span)),n+1)}labelable(){return this}loweringEnter(){return[new Ye(this)]}name;octave;acc;color;size;font;jeOctaveOffset;hasDefaultAcc;constructor(t,e,n,o=null){super(t,o),this.hasDefaultAcc=!!n.variables["note.acc"],[this.name,this.acc,this.octave,this.color]=this.getArgValue(e,n),this.font=n.variables.numberfont,this.size=n.variables.fontsize;let s=Nt(this.name);if(s instanceof N)throw s.span=t,s;if(s.next!==this.name.length)throw new S("E_WRONG_NOTE_NAME",`\u51FD\u6570 @note \u7684\u53C2\u6570 [0]:"name" \u683C\u5F0F\u9519\u8BEF: \u65E0\u6CD5\u89E3\u6790\u5C3E\u90E8 "${this.name.slice(s.next)}"`,t);this.name=s.name==="X"?"9":s.name==="Z"?"0":s.name;let r=e.get("octave")??e.get(2);if(r!==void 0){if(s.octave!==null&&s.octave!=r)throw new S("E_NOTE_OCTAVE_CONFLICT",`\u51FD\u6570 @note \u7684\u53C2\u6570 "octave" \u4E0E\u97F3\u7B26\u540D\u79F0\u4E2D\u7684\u516B\u5EA6\u4FE1\u606F\u51B2\u7A81: ${r} != ${s.octave}`,t)}else s.octave!==null?this.octave=s.octave:s.absOctave||(this.octave=0);this.jeOctaveOffset=n.variables[qn]??0,s.acc!==null&&(this.acc=s.acc+this.acc)}toString(){return`@n(${this.name}, ${this.acc||'""'}, ${this.octave}, ${this.color})`}},zs=Qn,zr={8:"",9:"X"},Ye=class extends W{resolvedMidi=null;keySignature="C4";transposeDiatonic;name;acc;octave;accidentals=[];numberStyle;upperOctaveDotY=[];lowerOctaveDotY=[];octaveDotRadius=0;numberY=0;constructor(t){super(),this.ast=t,this.T.set(1),this.mergeKey=ht,this.name=t.name,this.acc=t.acc,this.octave=t.octave+t.jeOctaveOffset,this.numberStyle={fontSize:t.size,fontFamily:t.font,fontWeight:400,textAlign:"center",fill:t.color},this.initLayoutBox()}prepareLayout(t){this.upperOctaveDotY.length=0,this.lowerOctaveDotY.length=0;let{size:e,color:n}=this.ast,o=t.textMeasurer.measureText("0",this.numberStyle),s=Math.abs(this.octave);this.octaveDotRadius=e*.075;let r=e*.08,c=this.octaveDotRadius*2+r,a=s===0?0:s*this.octaveDotRadius*2+(s-1)*r+r,l=this.octave>0?a:0;this.numberY=l+o.baseline;let h=e*.01,{placed:p,right:f}=Ie(this.acc,e,0,this.numberY,h);if(this.accidentals=p,this.box.w=f+o.w,this.box.h=l+o.h,this.box.anchor=f+o.w/2,this.box.visualAxis=l+o.h/2,this.ports["body.left"]={x:this.box.anchor-o.w/2,y:this.box.visualAxis},this.ports["body.right"]={x:this.box.anchor+o.w/2,y:this.box.visualAxis},this.ports.shoulder={x:this.box.anchor,y:l},this.ports.dot={x:this.box.w,y:l+o.h*.64},this.octave>0){for(let g=0;g<s;g++)this.upperOctaveDotY.push(l-r-this.octaveDotRadius-g*c);return}if(this.octave>=0)return;let d=s*this.octaveDotRadius*2+(s-1)*r,u={below:{order:100,gap:r,height:d,place:g=>{for(let y=0;y<s;y++)this.lowerOctaveDotY.push(g+this.octaveDotRadius+y*c)}},paint:g=>{for(let y of this.lowerOctaveDotY)g.drawCircle(this.box.x+this.box.anchor,this.box.y+y,this.octaveDotRadius,{fill:n})}};this.decorations.push(u)}finalizeLayout(){this.ports.lyric={x:this.box.anchor,y:this.box.h}}paint(t){let e=this.ast.color;for(let o of this.accidentals)Pe(t,o,this.box,e);let n=zr[this.name]??this.name;n&&t.drawText(n,this.box.x+this.box.anchor,this.box.y+this.numberY,this.numberStyle);for(let o of this.upperOctaveDotY)t.drawCircle(this.box.x+this.box.anchor,this.box.y+o,this.octaveDotRadius,{fill:e})}onTimeState(t){let e=this.keySignature=t.keySignature;if(this.playbackState={bpm:t.bpm,velocity:t.velocity,program:t.program},this.resolvedMidi=$n(this.name,this.acc,this.octave,e),this.transposeDiatonic=_s(this.name,this.acc,this.octave,e),this.name>="0"&&this.name<="9")(this.name==="0"||this.name>="8")&&(this.octave=0,this.acc="");else{let n=fe(this.name,this.acc,this.octave,e);n&&(this.name=n.renderName,this.acc=n.renderAcc,this.octave=n.renderOctave)}}emitPlayback(t){let e=this.ast.name==="9",n=e?37:this.resolvedMidi;if(!(t.end.compare(t.start)<=0)){if(n===null){t.span({start:t.start,end:t.end});return}t.note({start:t.start,end:t.end,midi:n,velocity:this.playbackState?.velocity??Bt,...e?{percussion:!0}:{transpose:this.transposeDiatonic}})}}};var Ke=class i extends v{contents=[];belows=[];size;get side(){return this.constructor.side}get children(){return this.belows.length?[...this.contents,...this.belows]:this.contents}constructor(t,e,n,o=null){super(t,o),this.size=n.variables.fontsize;for(let[,s]of e){if(s instanceof et){this.addContent(s,this.side,n);continue}let r=n.parseArgWithType(s.valueSpan,"content",t.start);r!==null&&this.addContent(r,this.side,n)}}labelable(){return this.children.some(v.findLabelable)?this:null}addContent(t,e,n){return this.contents.length===0&&(e="above"),t instanceof i?this.flatten(t,e,n):((e==="above"?this.contents:this.belows).push(t),t.parent=this,this.growSpan(t.sourceSpan),this)}growSpan(t){this.sourceSpan.start=Math.min(this.sourceSpan.start,t.start),this.sourceSpan.end=Math.max(this.sourceSpan.end,t.end)}loweringEnter(t,e){let n=[];return t.isolateFromLoweringGroups(()=>{for(let o of this.children){let[s,...r]=t.trackedEvents(o,new I,e).flat();if(!s||r.length>0||!F(s))throw new S("E_UP_INVALID_CHILD","@up \u7684\u6BCF\u4E2A\u53C2\u6570\u5FC5\u987B\u6070\u597D\u4EA7\u751F\u4E00\u4E2A\u53EF\u89C1 Temporal\uFF0C\u4E14\u4E0D\u80FD\u5305\u542B\u591A\u58F0\u90E8\u7ED3\u6784",o.sourceSpan);n.push(s)}}),[new eo(this,n)]}toString(t){let e=this.contents.map(o=>o.toString(t));return this.belows.length===0?`@up(${e.join(", ")})`:`@down(${[e.length>1?`@up(${e.join(", ")})`:e[0],...this.belows.map(o=>o.toString(t))].join(", ")})`}flatten(t,e,n){let o=t.sourceSpan.start<this.sourceSpan.start?t:this,s=o===t?this:t,[r,...c]=s.contents,a=r?[r]:[],l=[...o.contents,...e==="above"?a:[],...c],h=[...o.belows,...e==="below"?a:[],...s.belows];this.contents=l,this.belows=h;for(let f of this.children)f.parent=this;this.growSpan(t.sourceSpan),t.contents=[],t.belows=[];let p=n.labelableNodes.indexOf(t);return p>=0&&n.labelableNodes.splice(p,1),this}static desugar(t,e,n){let o=e[n++];if(!(o.kind==="sugar"&&o.data===this))return null;let s=this.side==="above"?"@up":"@down",r=t.nodes.length-1;for(;r>=0&&t.nodes[r]instanceof Z;)r--;if(r<0)throw new S("E_FOLD_NO_TARGET",`${s}\u8BED\u6CD5\u7CD6\u9519\u8BEF: \u5DE6\u8FB9\u6CA1\u6709\u627E\u5230\u53EF\u53E0\u52A0\u7684\u76EE\u6807`,o.span);let c=t.nodes[r],a=r;if(c instanceof lt){let p=c,f=p.target;for(;f&&!t.nodes.includes(f);)f=f.parent;for(let d=r-1;d>=0;d--)if(t.nodes[d]===f){c=new K({start:f.sourceSpan.start,end:p.sourceSpan.end},t.nodes.slice(d,r+1),null),a=d;break}}let l=c instanceof i?c:new this(o.span,new Map,t).addContent(c,"above",t),h=t.nodes;t.nodes=[],t.makeNodes(e,n);for(let p=0;p<t.nodes.length;p++){let f=t.nodes[p];if(f instanceof Z)continue;let d=f instanceof i?f.flatten(l,this.side,t):l.addContent(f,this.side,t);for(h.length=a,h.push(d);++p<t.nodes.length;)h.push(t.nodes[p]);return t.nodes=h,t.labelableNodes.push(d.labelable()),e.length}throw new S("E_FOLD_NO_TARGET",`${s}\u8BED\u6CD5\u7CD6\u9519\u8BEF: \u53F3\u8FB9\u6CA1\u6709\u627E\u5230\u53EF\u53E0\u52A0\u7684\u76EE\u6807`,o.span)}},Jn=class i extends Ke{static side="above";static def={name:["up"],description:"\u628A\u540C\u4E00\u65F6\u95F4\u4F4D\u7F6E\u7684\u53EF\u89C1\u5BF9\u8C61\u5411\u4E0A\u5806\u53E0",details:"~~~jpfun\n@up(1, 3, 5)\n~~~\n\n\u7B2C\u4E00\u4E2A\u5185\u5BB9\u53C2\u6570\u4E3A\u5BBF\u4E3B\uFF0C\u5176\u4F59\u4F9D\u6B21\u53E0\u5728\u4E0A\u65B9\uFF1B\u6240\u6709\u6210\u5458\u5171\u4EAB\u5BBF\u4E3B\u65F6\u503C\u3002\u5E38\u7528\u4E8E\u548C\u5F26\u3001\u901F\u5EA6\u8BB0\u53F7\u548C\u97F3\u7B26\u6CE8\u91CA\u3002\n\n**\u7B80\u5199**\uFF1A`1 ^ 3 ^ 5`\u3002\u590D\u6742\u5185\u5BB9\u53EF\u7528 `{...}` \u5305\u88F9\uFF1B\u9700\u8981\u72EC\u7ACB\u8282\u594F\u7684\u5E76\u884C\u5206\u652F\u65F6\uFF0C\u4F7F\u7528 `&` / `@stack`\u3002",allowExtraArgs:!0,extraArgType:"content",args:[]};static deSugarAtom(t,e,n){if(t[e]!=="^")return null;let o={kind:"sugar",data:i,span:{start:e,end:e+1}};return{next:e+1,node:o}}static deSugarRelation(t,e,n){return i.desugar(t,e,n)}},to=class i extends Ke{static side="below";static def={name:["down"],description:"\u628A\u540C\u4E00\u65F6\u95F4\u4F4D\u7F6E\u7684\u53EF\u89C1\u5BF9\u8C61\u5411\u4E0B\u5806\u53E0",details:"~~~jpfun\n@down(1, $p)\n~~~\n\u7B2C\u4E00\u4E2A\u5185\u5BB9\u53C2\u6570\u4E3A\u5BBF\u4E3B\uFF0C\u5176\u4F59\u4F9D\u6B21\u53E0\u5728\u4E0B\u65B9\u5E76\u5171\u4EAB\u5176\u65F6\u503C\uFF0C\u5E38\u7528\u4E8E\u529B\u5EA6\u7B49\u4E0B\u65B9\u6807\u8BB0\u3002\n\n**\u7B80\u5199**\uFF1A`1 _ $p`\u3002\u4E0E `^` \u6DF7\u5199\u65F6\u5171\u7528\u540C\u4E00\u5BBF\u4E3B\uFF1A`1^2_3` \u5C06 `2` \u653E\u5728 `1` \u4E0A\u65B9\u3001`3` \u653E\u5728\u4E0B\u65B9\u3002",allowExtraArgs:!0,extraArgType:"content",args:[]};static deSugarAtom(t,e,n){if(t[e]!=="_")return null;let o={kind:"sugar",data:i,span:{start:e,end:e+1}};return{next:e+1,node:o}}static deSugarRelation(t,e,n){return i.desugar(t,e,n)}},Hs=Jn,Ws=to,eo=class extends W{members;aboveCount;verticalOffsets=[];constructor(t,e){super(),this.ast=t,this.members=e,this.aboveCount=t.contents.length;let n=e.find(s=>!s.T.isZero());n&&this.T.copyFrom(n.T),this.mergeKey=ht,this.initLayoutBox();let o=e[0]?.addon;o&&(this.addon={...o});for(let s of e)s.mergeKey===U&&(this.mergeKey=U),s.addon=void 0,s.foldedInto=this}onTimeState(t){for(let e=this.members.length-1;e>=0;e--){let n=this.members[e];n.T.isZero()||n.T.copyFrom(this.T),n.t.copyFrom(this.t),n.track=this.track,n.layoutLine=this.layoutLine,n.onTimeState?.(t)}}emitPlayback(t){for(let e=this.members.length-1;e>=0;e--)t.play(this.members[e])}prepareHorizontal(t){this.members[0]?.prepareHorizontal?.(t)}prepareLayout(t){this.addon&&this.members[0]&&(this.members[0].addon=this.addon,this.addon=void 0);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=Gt([e],t);for(let h=1;h<this.members.length;h++)Gt([this.members[h]],t);this.springConfig={...e.springConfig,...this.springConfig};let n=e.box.x+e.box.anchor,o=this.ast.size*.12;this.verticalOffsets.length=this.members.length,this.verticalOffsets.fill(0);let s=0;for(let h=1;h<this.aboveCount;h++)s-=o+this.members[h].box.h,this.verticalOffsets[h]=s;let r=e.box.h;for(let h=this.aboveCount;h<this.members.length;h++)r+=o,this.verticalOffsets[h]=r,r+=this.members[h].box.h;for(let h=0;h<this.verticalOffsets.length;h++)this.verticalOffsets[h]-=s;this.box.h=r-s,this.box.anchor=n,this.box.visualAxis=e.box.visualAxis-s;let c=this.verticalOffsets[0];for(let h in e.ports){let p=e.ports[h];this.ports[h]={...p,x:e.box.x+p.x,y:c+p.y}}this.ports["body.left"]??={x:e.box.x,y:this.box.visualAxis},this.ports["body.right"]??={x:e.box.x+e.box.w,y:this.box.visualAxis};let a=this.aboveCount-1,l=this.verticalOffsets[a];this.ports["tie.top"]={x:n,y:l+(this.members[a].ports["tie.top"]?.y??0)}}onPlaced(){for(let t=0;t<this.members.length;t++){let e=this.members[t];e.box.x=this.box.x+this.box.anchor-e.box.anchor,e.box.y=this.box.y+this.verticalOffsets[t],e.onPlaced?.()}}paint(t){for(let e of this.members){e.paint(t);for(let n of e.decorations)n.paint(t)}}};var Zt=i=>({value:i,unit:"px"}),no=16,Hr={fontSize:no,textAlign:"center",fill:"#606060"};function Wr(i,t,e){let n=i.lastIndexOf("1"),o=i.indexOf("1")!==n;return i.replace(/1/g,(s,r)=>String(o&&r===n?e:t))}var oo=class{sourceSpan;pattern;marginBottom;style;layer="foreground";constructor(t,e,n,o){this.sourceSpan=t,this.pattern=e,this.marginBottom=n,this.style=o}createGeometry(t){let e=this.style,n=t.pages.map((o,s)=>{let r=Wr(this.pattern,s+1,t.pages.length),{w:c,h:a,baseline:l}=t.textMeasurer.measureText(r,e),h=o.y+o.h-this.marginBottom/2;return{text:r,x:o.x+o.w/2,y:h-a/2+l,w:c,h:a,baseline:l}});return{regions:n.map(({x:o,y:s,w:r,h:c,baseline:a})=>({x:o-r/2,y:s-a,w:r,h:c})),paint(o){for(let s of n)o.drawText(s.text,s.x,s.y,e)}}}},so=class extends v{static def={name:["page"],description:"\u8BBE\u7F6E\u6587\u6863\u9875\u9762",details:`~~~jpfun
|
|
58
|
+
`||t[Ce(t,e-1)]!==`
|
|
59
|
+
`)return null;let s=e+1,i=s;for(;(i=wt(t,i,n))<n&&t[i]===`
|
|
60
|
+
`;)s=++i;return{next:s,node:{kind:"call",typed:!0,name:"br",args:new Map,span:{start:e,end:s}}}}offset;loweringEnter(){let t=new $;return t.ast=this,t.mergeKey=-1,t.addon={breakBefore:this.offset},[t]}static loweringFinalize=t=>{let e=new B,n=new B,o=null;for(let s of t.columns){if(o&&e.compare(s[0].t)>0&&s.some(i=>(i.addon?.breakBefore??0)>0))throw M.error.BreakInsideEvent(o.ast.sourceSpan);for(let i of s)i.T.isZero()||(n.copyFrom(i.t).add(i.T),(!o||n.compare(e)>0)&&(e.copyFrom(n),o=i))}};constructor(t,e,n,o=null){super(t,o);let[s]=this.getArgValue(e,n);this.offset=Number.isFinite(s)?Math.max(1,Math.floor(s)):1,this.offset!==s&&n.diagnostics.push(new P("W_BR_OFFSET",`@br \u7684 offset \u5FC5\u987B\u662F\u5927\u4E8E\u7B49\u4E8E 1 \u7684\u6574\u6570\uFF0C\u5DF2\u88AB\u4FEE\u6B63\u4E3A ${this.offset}`,this.sourceSpan))}toString(){return`@br(${this.offset})`}},tn=yo;var go=10,bo=13,cc=9,ac=11,lc=12,hc=32,pc=160,fc=5760,uc=8239,dc=8287,xc=12288,mc=65279,yc=34,xi=92,gc=37,bc=32,wc=[];function Sc(r){return r>bc?" ".repeat(r):wc[r]??=" ".repeat(r)}function mi(r){return r===hc||r===cc||r===ac||r===lc?!0:r<128?!1:r===pc||r===fc||r>=8192&&r<=8202||r===uc||r===dc||r===xc||r===mc}function oe(r){let t=r.length,e=[0],n=[],o=[],s=(x,y)=>{if(x>=y)return;let g=o.length;if(g>=2&&x<=o[g-1]){y>o[g-1]&&(o[g-1]=y);return}o.push(x,y)},i=(x,y)=>{if(y<=0)return;let g=x+y;for(let b=x;b<g;b+=2)s(b,b+1)},c=0,a=!1,l=!1,h=-1,p=-1,f=0,d=(x,y)=>{if(y===xi){f>0&&p+f===x?f++:(p=x,f=1);return}p=-1,f=0};for(let x=0;x<t;){let y=r.charCodeAt(x);if(y===bo||y===go){let g=y===bo&&x+1<t&&r.charCodeAt(x+1)===go?2:1;e.push(x+g);let b=(f&1)===1;i(p,f),h>=0&&(s(h,x),n.push({start:h,end:x}),h=-1),b?s(x,x+g):c===0&&g===2&&s(x,x+1),p=-1,f=0,l=!1,x+=g;continue}if(c!==0){l?l=!1:y===xi?l=!0:y===c&&(c=0),mi(y)||d(x,y),x++;continue}if(y===yc){a||(Lt(r,x,t)<0?a=!0:c=y),d(x,y),x++;continue}if(y===gc){for(h=x,x++;x<t;){let g=r.charCodeAt(x);if(g===bo||g===go)break;x++}continue}mi(y)||d(x,y),x++}if(i(p,f),h>=0&&(s(h,t),n.push({start:h,end:t})),o.length===0)return{maskedSource:r,lineStarts:e,commentSpans:n};let u=[],m=0;for(let x=0;x<o.length;x+=2){let y=o[x],g=o[x+1];m<y&&u.push(r.slice(m,y)),u.push(Sc(g-y)),m=g}return m<t&&u.push(r.slice(m)),{maskedSource:u.join(""),lineStarts:e,commentSpans:n}}var _t="CDEFGAB",en=(r,t)=>(r%t+t)%t,Cc=r=>r<0?"b".repeat(-r):"#".repeat(r);function nn(r){throw new w("E_NOTE_TRANSFORM","\u65E0\u6CD5\u5B89\u5168\u6539\u5199\u6B64\u97F3\u7B26\u7684\u97F3\u9AD8",r)}function Ac(r,t){let e=t==="to-absolute"||t!=="to-relative"&&_t.includes(r.ast.name),n=r.resolvedMidi+(t==="semitone-up"?1:t==="semitone-down"?-1:0),o=$t(r.keySignature,4);[n,o,r.ast.octave,r.ast.jeOctaveOffset].every(Number.isSafeInteger)||nn(r.ast.sourceSpan);let s=t==="semitone-down"?ri:Ve,i,c,a;if(t==="to-absolute"){let l=_t.indexOf(r.keySignature[0]),h=l<0?_t.indexOf(Ve[en(o,12)][0]):l,p=Number(r.ast.name)-1;i=_t[(h+p)%7];let f=en(o-St[_t[h]]+6,12)-6;a=Math.floor((o-f)/12)-1+Math.floor((h+p)/7)+r.ast.octave+r.ast.jeOctaveOffset,c=Cc(n-((a+1)*12+St[i]))}else if(t==="to-relative"){let l=r.ast,h=_t.includes(r.keySignature[0])?r.keySignature:Ve[en(o,12)]+(Math.floor(o/12)-1),p=Ae(l.name,l.acc,l.octave+l.jeOctaveOffset,h);p||nn(l.sourceSpan),{renderName:i,renderAcc:c,renderOctave:a}=p}else{let l=e?n:n-o,h=s[en(l,12)];i=e?h[0]:String(_t.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 Tc(r,t){for(let e=t.parent;e;e=e.parent){let n=Se(r,e.sourceSpan.start,e.sourceSpan.end);if(!n)continue;let o=n.args.find(i=>i.valueSpan.start<=t.sourceSpan.start&&i.valueSpan.end>=t.sourceSpan.end);if(!o)continue;let s=0;for(let i=o.valueSpan.start;i<t.sourceSpan.start;i++)r[i]==='"'?i=Lt(r,i,o.valueSpan.end):r[i]==="{"?s++:r[i]==="}"&&s--;return s===0}return!1}function yi(r,t,e,n){let{maskedSource:o}=oe(r),s=[],i=[];function c(l,h){r.slice(l.start,l.end)!==h&&(r.slice(l.start,l.end)!==o.slice(l.start,l.end)&&nn(l),s.push({span:l,text:h}))}for(let l of t){let k=function(N,v,_){let D=!_||_.includes(",")||N&&r[N.start]==='"'?ht(_):_;N?c(N,D):E.push(`${v}=${D}`)};var a=k;let{ast:h}=l,p=h.sourceSpan,f=Se(o,p.start,p.end),d=f?.span.end===p.end&&f.closeParenSpan,u=e==="to-absolute"&&_t.includes(h.name)||e==="to-relative"&&/^[1-7]$/.test(h.name);if(d||i.push({span:p,text:r.slice(p.start,p.end)}),n&&!n.some(N=>N.start<=p.start&&N.end>=p.end)||l.resolvedMidi===null||u)continue;let m=Ac(l,e),x=m.absolute?String(m.octave):m.octave<0?",".repeat(-m.octave):"'".repeat(m.octave),y=(N,v)=>m.absolute?m.name+N+v:N+m.name+v;if(!d){let N=y(m.acc,x);N.includes(",")&&Tc(o,h)&&(N=`{${N}}`),i[i.length-1].text=N;continue}let g=new Map;f.args.forEach((N,v)=>{N.valueSpan.start!==N.valueSpan.end&&g.set(N.nameSpan?o.slice(N.nameSpan.start,N.nameSpan.end).toLowerCase():v,N.valueSpan)});let b=g.get("name")??g.get(0),S=g.get("acc")??g.get(1),C=g.get("octave")??g.get(2),E=[];if(k(b,"name",y(S?"":m.acc,C?"":x)),S?k(S,"acc",m.acc):h.hasDefaultAcc&&E.push('acc=""'),C&&c(C,String(m.octave)),E.length){let N=f.closeParenSpan.start,v=o.slice(f.openParenSpan.end,N).trimEnd();c({start:N,end:N},(v?v.endsWith(",")?" ":", ":"")+E.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=Ft(h.text+p.text);(f instanceof M||f.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&&nn(s[l].span);return s}function gi(r,t,e,n){let o=t.diagnostics.find(c=>c instanceof w);if(o)throw o;let s=[...t.astToTemporal.values()].flat().filter(c=>c instanceof on),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 yi(r,s,e,n)}var wo="note.jeOctaveOffset",So=class extends L{static def={name:["note","n"],description:"\u521B\u5EFA\u97F3\u7B26",details:"~~~jpfun\n@note(A, acc=#, octave=3, color=#c33)\n~~~\n**\u7B80\u5199**\uFF1A\u6570\u5B57\u97F3\u540D\u6309\u201C\u5347\u964D\u53F7\u3001\u97F3\u540D\u3001\u76F8\u5BF9\u516B\u5EA6\u201D\u4E66\u5199\uFF1B\u5B57\u6BCD\u97F3\u540D\u6309\u201C\u97F3\u540D\u3001\u5347\u964D\u53F7\u3001\u7EDD\u5BF9\u516B\u5EA6\u201D\u4E66\u5199\u3002`1,,` \u6BD4\u5F53\u524D\u8C03\u6027\u57FA\u51C6\u4F4E\u4E24\u4E2A\u516B\u5EA6\uFF0C`1'` \u9AD8\u4E00\u4E2A\u516B\u5EA6\u3002\n- \u7B80\u5199\u7684\u5347\u964D\u53F7\u5B8C\u5168\u7531\u81EA\u8EAB\u51B3\u5B9A\uFF0C\u7701\u7565\u65F6\u4E3A\u7A7A\uFF0C\u4E0D\u7EE7\u627F `@set(note.acc=...)`\uFF1B\u663E\u5F0F\u8C03\u7528\u7701\u7565 `acc` \u65F6\u4ECD\u7EE7\u627F\u9ED8\u8BA4\u503C\n- `A#3` \u7B49\u4EF7\u4E8E `@note(A, #, 3)`\uFF0C\u9ED8\u8BA4 `acc` \u4E3A\u7A7A\u65F6\u4E5F\u7B49\u4EF7\u4E8E `@note(A#3)`\n- `#1'` \u7B49\u4EF7\u4E8E `@note(1, #, 1)`\uFF0C\u9ED8\u8BA4 `acc` \u4E3A\u7A7A\u65F6\u4E5F\u7B49\u4EF7\u4E8E `@note(\"#1'\")`\n- \u652F\u6301\u7EC4\u5408\u5347\u964D\u53F7\uFF0C\u5982 `A##bn99`\uFF1B\u65E0\u6B67\u4E49\u65F6\u4E5F\u63A5\u53D7\u540E\u7F6E\u5199\u6CD5\uFF0C\u5982 `A3#`\u3001`6#,,`\n- \u5347\u964D\u53F7\u540E\u7D27\u8DDF\u6570\u5B57\u65F6\u5F52\u5165\u4E0B\u4E00\u97F3\u7B26\uFF1A`6#3` \u89E3\u6790\u4E3A `6` \u548C `#3`",allowExtraArgs:!1,args:[{name:"name",description:"\u6570\u5B57\u97F3\u540D\u6216\u5927\u5199\u5B57\u6BCD\u97F3\u540D\uFF0C\u53EF\u81EA\u5E26\u5347\u964D\u53F7\u4E0E\u516B\u5EA6\uFF1B`0` / `Z` \u4E3A\u4F11\u6B62\u7B26\uFF0C`8` \u4E3A\u9690\u5F62\u5360\u4F4D\uFF0C`9` / `X` \u4E3A\u8282\u62CD\u8BB0\u53F7\uFF0C\u540E\u4E09\u7C7B\u4E0D\u663E\u793A\u5347\u964D\u53F7\u548C\u516B\u5EA6\u70B9",type:"string",default:null},{name:"acc",description:"\u989D\u5916\u5347\u964D\u53F7\uFF0C`##` \u518D\u5347\u4E24\u4E2A\u534A\u97F3\uFF0C`b` \u518D\u964D\u4E00\u4E2A\u534A\u97F3",type:"string",default:""},{name:"octave",description:"\u5B57\u6BCD\u97F3\u540D\u4F7F\u7528\u7EDD\u5BF9\u516B\u5EA6\uFF1B\u6570\u5B57\u97F3\u540D\u4F7F\u7528\u76F8\u5BF9\u516B\u5EA6\uFF0C\u7701\u7565\u65F6\u4E3A 0",type:"number",default:4},{name:"color",description:"\u97F3\u7B26\u989C\u8272\uFF0C\u4F7F\u7528 CSS \u989C\u8272\u503C",type:"string",default:"#000"}]};static deSugarAtom(t,e,n){let o=0;switch(t[e]){case"(":case"]":o=-1;break;case"[":case")":o=1;break}if(o)return{next:e+1,node:{kind:"sugar",data:{jeOffset:o},span:{start:e,end:e+1},syntaxKind:"punctuation"}};let s=Ft(t,e,n);if(s instanceof M)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,n){let o=e[n],s=o.data?.jeOffset;return typeof s!="number"?null:(t.variables[wo]=(t.variables[wo]??0)+s,t.nodes.push(new et(o.span)),n+1)}labelable(){return this}loweringEnter(){return[new on(this)]}name;octave;acc;color;size;font;jeOctaveOffset;hasDefaultAcc;constructor(t,e,n,o=null){super(t,o),this.hasDefaultAcc=!!n.variables["note.acc"],[this.name,this.acc,this.octave,this.color]=this.getArgValue(e,n),this.font=n.variables.numberfont,this.size=n.variables.fontsize;let s=Ft(this.name);if(s instanceof M)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 "${this.name.slice(s.next)}"`,t);this.name=s.name==="X"?"9":s.name==="Z"?"0":s.name;let i=e.get("octave")??e.get(2);if(i!==void 0){if(s.octave!==null&&s.octave!=i)throw new 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: ${i} != ${s.octave}`,t)}else s.octave!==null?this.octave=s.octave:s.absOctave||(this.octave=0);this.jeOctaveOffset=n.variables[wo]??0,s.acc!==null&&(this.acc=s.acc+this.acc)}toString(){return`@n(${this.name}, ${this.acc||'""'}, ${this.octave}, ${this.color})`}},bi=So,Ec={8:"",9:"X"},on=class extends ${resolvedMidi=null;keySignature="C4";transposeDiatonic;name;acc;octave;accidentals=[];numberStyle;numberY=0;constructor(t){super(),this.ast=t,this.T.set(1),this.mergeKey=dt,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:n}=this.ast,o=t.textMeasurer.measureText("0",this.numberStyle);this.numberY=o.baseline;let s=e*.01,{placed:i,right:c}=Ye(this.acc,e,0,this.numberY,s);this.accidentals=i,this.box.w=c+o.w,this.box.h=o.h,this.box.anchor=c+o.w/2,this.box.visualAxis=o.h/2,this.ports["body.left"]={x:this.box.anchor-o.w/2,y:this.box.visualAxis},this.ports["body.right"]={x:this.box.anchor+o.w/2,y:this.box.visualAxis},this.ports.shoulder={x:this.box.anchor,y:0},this.ports["decoration.below"]={x:this.box.anchor,y:this.numberY+e*.04},this.ports.dot={x:this.box.w,y:o.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,d={fill:n},u=0,m=a*h*2+(a-1)*p,x={[l?"above":"below"]:{order:100,gap:p,height:m,place:y=>{u=y}},paint:y=>{for(let g=0;g<a;g++){let b=l?u+m-h-g*f:u+h+g*f;y.drawCircle(this.box.x+this.box.anchor,this.box.y+b,h,d)}}};this.decorations.push(x)}finalizeLayout(){this.ports.lyric={x:this.box.anchor,y:this.box.h},this.octave>0&&(this.ports["tie.top"]={x:this.box.anchor,y:ot(this,!0).y-this.box.y-this.ast.size*.05})}paint(t){let e=this.ast.color;for(let o of this.accidentals)Ke(t,o,this.box,e);let n=Ec[this.name]??this.name;n&&t.drawText(n,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=oo(this.name,this.acc,this.octave,e),this.transposeDiatonic=ci(this.name,this.acc,this.octave,e),this.name>="0"&&this.name<="9")(this.name==="0"||this.name>="8")&&(this.octave=0,this.acc="");else{let n=Ae(this.name,this.acc,this.octave,e);n&&(this.name=n.renderName,this.acc=n.renderAcc,this.octave=n.renderOctave)}}emitPlayback(t){let e=this.ast.name==="9",n=e?37:this.resolvedMidi,o=e?0:this.playbackState?.pitchShift??0,s=this.transposeDiatonic;if(!(t.end.compare(t.start)<=0)){if(n===null){t.span({start:t.start,end:t.end});return}t.note({start:t.start,end:t.end,midi:n+o,velocity:this.playbackState?.velocity??Kt,...e?{percussion:!0}:{transpose:o&&s?i=>s(i)+o:s}})}}};function Co(r){for(;r.foldedInto;)r=r.foldedInto;return r}var Ao=class extends L{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=t.attachments.filter(n=>n instanceof sn).map(n=>{let[o,s]=n.endPoints;return{from:o,end:s.t.clone().add(s.T),shift:n.ast.shift*12}});if(e.length!==0)for(let n of t.astToTemporal.values())for(let o of n){if(!o.playbackState)continue;let s=Co(o),i=0;for(let c of e)s.track===c.from.track&&s.t.compare(c.from.t)>=0&&s.t.compare(c.end)<0&&(i+=c.shift);i!==0&&(o.playbackState={...o.playbackState,pitchShift:(o.playbackState.pitchShift??0)+i})}};from;to;shift;size;font;constructor(t,e,n,o=null){super(t,o);let[s,i,c]=this.getArgValue(e,n);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=n.variables.fontsize,this.font=n.variables.numberfont}loweringEnter(t){let e=t.getTemporalNodes(this.from).at(0),n=t.getTemporalNodes(this.to).at(-1),o=e&&Co(e),s=n&&Co(n);if(!o||!s||!I(o)||!I(s))return t.diagnostics.push(M.warning.UnresolvedEndpoint("ottava",this.sourceSpan)),[];if(o.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 sn(this,o,s)),[]}toString(t){let e=n=>(n instanceof L?n.label:void 0)??n.toString(t);return`@ottava(${e(this.from)}, ${e(this.to)}, ${this.shift})`}},wi=Ao,sn=class{ast;from;to;layer="foreground";constructor(t,e,n){this.ast=t,this.from=e,this.to=n}get sourceSpan(){return this.ast.sourceSpan}get endPoints(){return(this.from.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,[n,o]=e,s=n.layoutLine,i=o.layoutLine;if(t.lines[s].columnOf(n)<0||t.lines[i].columnOf(o)<0)return{regions:[],paint(){}};let{size:c,font:a,shift:l}=this.ast,h=l>0,p=n.track,f=Math.max(.75,c*.035),d={stroke:"#000",strokeWidth:f},u=c*.22,m=u+c*.14,x=f/2,y=c*.45,g=c*.2,b=c*.08,S=String(Math.abs(l)*7+1),C={fontSize:c*.6,fontFamily:a,fontStyle:"italic",textAlign:"left",fill:"#000"},E=t.textMeasurer.measureText(S,C),k=h?-x:x-E.h,N=k+E.baseline,v=Array.from({length:i-s+1},(_,D)=>{let A=s+D,O=A===s,G=A===i,Z=t.lines[A].trackRuns,q=O?n.box.x+(n.ports["body.left"]?.x??0):Z.get(p)?.find(X=>!X.T.isZero())?.box.x??t.originX,J=o.box.x+(o.ports["body.right"]?.x??o.box.w);if(!G){J=t.originX+(Z.size===0?t.width:0);for(let X of Z.values())for(let ft of X)J=Math.max(J,ft.box.x+ft.box.w)}q>J&&([q,J]=[J,q]);let F=O?q+E.w+b:q,U=(X,ft,T,R)=>({x:X,y:ft,w:T,h:R,line:A,track:p}),Y=F<J?[U(F-x,-x,J-F+f,f)]:[];O&&Y.push(U(q,k,E.w,E.h)),G&&Y.push(U(J-x,h?-x:-y-x,f,y+f));let z=U(0,0,0,0);Zt(z,Y);let Q=h?1/0:-1/0;for(let X of Y)for(let[ft,T]of t.getHorizontalExtents(A,X.x,X.x+X.w)){let R=t.getVisualAxis(A,ft);Q=h?Math.min(Q,R+T.top-g-X.y-X.h):Math.max(Q,R+T.bottom+g-X.y)}if(!Number.isFinite(Q)){let X=t.getRangeExtents(A,O||G?e:void 0,p),ft=t.getVisualAxis(A,p);Q=h?ft+(X?.top??0)-g-(z.y+z.h):ft+(X?.bottom??0)+g-z.y}for(let X of Y)X.y+=Q;return z.y+=Q,{left:q,right:J,lineStart:F,lineY:Q,first:O,last:G,parts:Y,region:z}});return{regions:v.map(_=>_.region),occupancy:v.flatMap(_=>_.parts),paint(_){for(let D of v){let{left:A,right:O,lineStart:G,lineY:Z,first:q,last:J}=D;for(let F=G;F<O;F+=m)_.drawLine(F,Z,Math.min(F+u,O),Z,d);q&&_.drawText(S,A,Z+N,C),J&&_.drawLine(O,Z,O,Z+(h?y:-y),d)}}}}};var To=Number.MAX_VALUE,se=new WeakMap,Eo=class extends L{static def={name:["rest"],description:"\u591A\u5C0F\u8282\u4F11\u6B62",details:`~~~jpfun
|
|
61
|
+
@meter(4,4) | @rest(19) |
|
|
62
|
+
~~~
|
|
63
|
+
\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,n,o=null){super(t,o);let[s,i,c]=this.getArgValue(e,n);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=n.length2px(i),this.size=n.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=n.variables.numberfont}labelable(){return this}loweringEnter(){return[new Lo(this)]}static loweringFinalize(t){if(!t.columns.some(i=>i.some(c=>c.mergeKey===To)))return;let e=0,n=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 L)||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=n.get(a);(!l||c.order<l.order)&&n.set(a,c)}let o=[],s=new Map;for(let i of t.columns){o.push(i);let c;for(let l of i){if(l.T.compare(0)>0){let p=n.get(l),f=s.get(l.track);if(f&&se.has(f)&&p?.ast instanceof L&&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=se.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 $;h.ast=new st(c.ast.sourceSpan,c.ast),h.t.copyFrom(a),h.track=c.track,h.layoutLine=c.layoutLine,h.order=e++,h.mergeKey=nt,t.astToTemporal.set(h.ast,[h]),o.push([h])}}t.columns=o}toString(){return`@rest(${this.count})`}},Si=Eo,Lo=class extends ${measureDuration=new B;metrics;lineWidth=0;textStyle;constructor(t){super(),this.ast=t,this.mergeKey=To,se.set(this,this),this.initLayoutBox(),this.textStyle={fontSize:t.size,fontFamily:t.font,textAlign:"center"}}onTimeState(t){let e=t.meter;if(!(e instanceof B))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 n=t.currentEvent??this;if(n.mergeKey===To&&this.track===n.track){let o=se.get(n);(!o||this.order<o.order)&&se.set(n,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,n=6/Math.sqrt(this.T.toNumber());this.springConfig={alpha_L:n,alpha_R:n},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&&I(e.foldedInto);)e=e.foldedInto;let n=t.columnOf(e);if(n<0)return;let o=c=>t.columns[c]?.find(a=>a.track===e.track&&a.mergeKey===nt)??e,s=o(n-1),i=o(n+1);s!==i&&t.registerHorizontalLayoutHook(s,i,({columns:c,rows:a,start:l,end:h,X:p,fixed:f})=>{for(let d=l;d<h;d++){if(f[d])continue;let u=0;for(let x=0;x<a;x++){let y=c[d][x],g=c[d+1][x],b=se.get(g.time),S=b?b.ast.size*.25:0;u=Math.max(u,y.WR+g.WL+S)}let m=p[d]+u-p[d+1];for(let x=d+1;x<p.length&&(p[x]+=m,!!f[x]);x++);f[d]=1}})}paint(t){let{size:e,count:n}=this.ast,o=this.box.x,s=o+this.lineWidth,i=this.box.y+this.box.visualAxis,c=e*.12,a=c*2,l=(e*.65-c)/2;t.drawLine(o+a/2,i,s-a/2,i,{strokeWidth:a}),t.drawLine(o+c/2,i-l,o+c/2,i+l,{strokeWidth:c}),t.drawLine(s-c/2,i-l,s-c/2,i+l,{strokeWidth:c}),t.drawText(String(n),o+this.lineWidth/2,this.box.y+this.metrics.baseline,this.textStyle)}};var rn=class r extends L{contents=[];belows=[];size;get side(){return this.constructor.side}get children(){return this.belows.length?[...this.contents,...this.belows]:this.contents}constructor(t,e,n,o=null){super(t,o),this.size=n.variables.fontsize;for(let[,s]of e){if(s instanceof st){this.addContent(s,this.side,n);continue}let i=n.parseArgWithType(s.valueSpan,"content",t.start);i!==null&&this.addContent(i,this.side,n)}}labelable(){return this.children.some(L.findLabelable)?this:null}addContent(t,e,n){return this.contents.length===0&&(e="above"),t instanceof r?this.flatten(t,e,n):((e==="above"?this.contents:this.belows).push(t),t.parent=this,this.growSpan(t.sourceSpan),this)}growSpan(t){this.sourceSpan.start=Math.min(this.sourceSpan.start,t.start),this.sourceSpan.end=Math.max(this.sourceSpan.end,t.end)}loweringEnter(t,e){let n=[];return t.isolateFromLoweringGroups(()=>{for(let o of this.children){let s=t.trackedEvents(o,new B,e),i=s.length===1&&s[0].length===1?s[0][0]:void 0;if(!i||!I(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",o.sourceSpan);n.push(i)}}),[new No(this,n)]}toString(t){let e=this.contents.map(o=>o.toString(t));return this.belows.length===0?`@up(${e.join(", ")})`:`@down(${[e.length>1?`@up(${e.join(", ")})`:e[0],...this.belows.map(o=>o.toString(t))].join(", ")})`}flatten(t,e,n){let o=t.sourceSpan.start<this.sourceSpan.start?t:this,s=o===t?this:t,[i,...c]=s.contents,a=i?[i]:[],l=[...o.contents,...e==="above"?a:[],...c],h=[...o.belows,...e==="below"?a:[],...s.belows];this.contents=l,this.belows=h;for(let f of this.children)f.parent=this;this.growSpan(t.sourceSpan),t.contents=[],t.belows=[];let p=n.labelableNodes.indexOf(t);return p>=0&&n.labelableNodes.splice(p,1),this}static desugar(t,e,n){let o=e[n++];if(!(o.kind==="sugar"&&o.data===this))return null;let s=this.side==="above"?"@up":"@down",i=t.nodes.length-1;for(;i>=0&&t.nodes[i]instanceof et;)i--;if(i<0)throw new w("E_FOLD_NO_TARGET",`${s}\u8BED\u6CD5\u7CD6\u9519\u8BEF: \u5DE6\u8FB9\u6CA1\u6709\u627E\u5230\u53EF\u53E0\u52A0\u7684\u76EE\u6807`,o.span);let c=t.nodes[i],a=i;if(c instanceof mt){let p=c,f=p.target;for(;f&&!t.nodes.includes(f);)f=f.parent;for(let d=i-1;d>=0;d--)if(t.nodes[d]===f){c=new tt({start:f.sourceSpan.start,end:p.sourceSpan.end},t.nodes.slice(d,i+1),null),a=d;break}}let l=c instanceof r?c:new this(o.span,new Map,t).addContent(c,"above",t),h=t.nodes;t.nodes=[],t.makeNodes(e,n);for(let p=0;p<t.nodes.length;p++){let f=t.nodes[p];if(f instanceof et)continue;let d=f instanceof r?f.flatten(l,this.side,t):l.addContent(f,this.side,t);for(h.length=a,h.push(d);++p<t.nodes.length;)h.push(t.nodes[p]);return t.nodes=h,t.labelableNodes.push(d.labelable()),e.length}throw new w("E_FOLD_NO_TARGET",`${s}\u8BED\u6CD5\u7CD6\u9519\u8BEF: \u53F3\u8FB9\u6CA1\u6709\u627E\u5230\u53EF\u53E0\u52A0\u7684\u76EE\u6807`,o.span)}},_o=class r extends rn{static side="above";static def={name:["up"],description:"\u628A\u540C\u4E00\u65F6\u95F4\u4F4D\u7F6E\u7684\u53EF\u89C1\u5BF9\u8C61\u5411\u4E0A\u5806\u53E0",details:"~~~jpfun\n@up(1, 3, 5)\n~~~\n\n\u7B2C\u4E00\u4E2A\u5185\u5BB9\u53C2\u6570\u4E3A\u5BBF\u4E3B\uFF0C\u5176\u4F59\u4F9D\u6B21\u53E0\u5728\u4E0A\u65B9\uFF1B\u6240\u6709\u6210\u5458\u5171\u4EAB\u5BBF\u4E3B\u65F6\u503C\u3002\u5E38\u7528\u4E8E\u548C\u5F26\u3001\u901F\u5EA6\u8BB0\u53F7\u548C\u97F3\u7B26\u6CE8\u91CA\u3002\n\n**\u7B80\u5199**\uFF1A`1 ^ 3 ^ 5`\u3002\u590D\u6742\u5185\u5BB9\u53EF\u7528 `{...}` \u5305\u88F9\uFF1B\u9700\u8981\u72EC\u7ACB\u8282\u594F\u7684\u5E76\u884C\u5206\u652F\u65F6\uFF0C\u4F7F\u7528 `&` / `@stack`\u3002",allowExtraArgs:!0,extraArgType:"content",args:[]};static deSugarAtom(t,e,n){if(t[e]!=="^")return null;let o={kind:"sugar",data:r,span:{start:e,end:e+1}};return{next:e+1,node:o}}static deSugarRelation(t,e,n){return r.desugar(t,e,n)}},ko=class r extends rn{static side="below";static def={name:["down"],description:"\u628A\u540C\u4E00\u65F6\u95F4\u4F4D\u7F6E\u7684\u53EF\u89C1\u5BF9\u8C61\u5411\u4E0B\u5806\u53E0",details:"~~~jpfun\n@down(1, $p)\n~~~\n\u7B2C\u4E00\u4E2A\u5185\u5BB9\u53C2\u6570\u4E3A\u5BBF\u4E3B\uFF0C\u5176\u4F59\u4F9D\u6B21\u53E0\u5728\u4E0B\u65B9\u5E76\u5171\u4EAB\u5176\u65F6\u503C\uFF0C\u5E38\u7528\u4E8E\u529B\u5EA6\u7B49\u4E0B\u65B9\u6807\u8BB0\u3002\n\n**\u7B80\u5199**\uFF1A`1 _ $p`\u3002\u4E0E `^` \u6DF7\u5199\u65F6\u5171\u7528\u540C\u4E00\u5BBF\u4E3B\uFF1A`1^2_3` \u5C06 `2` \u653E\u5728 `1` \u4E0A\u65B9\u3001`3` \u653E\u5728\u4E0B\u65B9\u3002",allowExtraArgs:!0,extraArgType:"content",args:[]};static deSugarAtom(t,e,n){if(t[e]!=="_")return null;let o={kind:"sugar",data:r,span:{start:e,end:e+1}};return{next:e+1,node:o}}static deSugarRelation(t,e,n){return r.desugar(t,e,n)}},Ci=_o,Ai=ko,No=class extends ${members;aboveCount;verticalOffsets=[];constructor(t,e){super(),this.ast=t,this.members=e,this.aboveCount=t.contents.length;let n=e[0];this.mergeKey=n&&n.mergeKey!==n.order?n.mergeKey:dt;let o=this.mergeKey===dt||this.mergeKey===nt;!o&&n&&this.T.copyFrom(n.T),this.initLayoutBox();let s=n?.addon;s&&(this.addon={...s});for(let i of e)o&&this.T.isZero()&&this.T.copyFrom(i.T),i.mergeKey===nt&&(this.mergeKey=nt),i.addon=void 0,i.foldedInto=this}onTimeState(t){let e=this.T.clone(),n,o=!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,n=c.onTimeState?.(t),o||=!c.T.isZero()&&!c.T.equals(e)}let s=this.members[0];if(s&&!s.T.isZero()&&(this.T.copyFrom(s.T),o))for(let i of this.members)i.T.isZero()||i.T.copyFrom(this.T);return n}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]&&Ot(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=qt([e],t);for(let p=1;p<this.members.length;p++)qt([this.members[p]],t);this.springConfig={...e.springConfig,...this.springConfig};let n=e.box.x+e.box.anchor,o=this.ast.size*.12;this.verticalOffsets.length=this.members.length,this.verticalOffsets[0]=0;let s=ot(e),i=s.y;for(let p=1;p<this.aboveCount;p++){let f=ot(this.members[p]);this.verticalOffsets[p]=i-o-f.y-f.h,i-=o+f.h}let c=s.y+s.h;for(let p=this.aboveCount;p<this.members.length;p++){let f=ot(this.members[p]);this.verticalOffsets[p]=c+o-f.y,c+=o+f.h}for(let p=0;p<this.verticalOffsets.length;p++)this.verticalOffsets[p]-=i;this.box.h=c-i,this.box.anchor=n,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:n,y:h+(this.members[l].ports["tie.top"]?.y??ot(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 n of e.decorations)n.paint?.(t)}}};var ie=r=>({value:r,unit:"px"}),vo=16,Lc={fontSize:vo,textAlign:"center",fill:"#606060"};function _c(r,t,e){let n=r.lastIndexOf("1"),o=r.indexOf("1")!==n;return r.replace(/1/g,(s,i)=>String(o&&i===n?e:t))}var Mo=class{sourceSpan;pattern;marginBottom;style;layer="foreground";constructor(t,e,n,o){this.sourceSpan=t,this.pattern=e,this.marginBottom=n,this.style=o}createGeometry(t){let e=this.style,n=t.pages.map((o,s)=>{let i=_c(this.pattern,s+1,t.pages.length),{w:c,h:a,baseline:l}=t.textMeasurer.measureText(i,e),h=o.y+o.h-this.marginBottom/2;return{text:i,x:o.x+o.w/2,y:h-a/2+l,w:c,h:a,baseline:l}});return{regions:n.map(({x:o,y:s,w:i,h:c,baseline:a})=>({x:o-i/2,y:s-a,w:i,h:c})),paint(o){for(let s of n)o.drawText(s.text,s.x,s.y,e)}}}},Ro=class extends L{static def={name:["page"],description:"\u8BBE\u7F6E\u6587\u6863\u9875\u9762",details:`~~~jpfun
|
|
54
64
|
@page(
|
|
55
65
|
width=794px, height=1123px, top=48px, bottom=48px,
|
|
56
66
|
left=40px, right=40px, gap=1em, numbering="1/1", fillRatio=0.5
|
|
57
67
|
)
|
|
58
68
|
~~~
|
|
59
|
-
\u5C3A\u5BF8\u63A5\u53D7 \`px\` \u6216 \`em\`\u3002\u9875\u8FB9\u8DDD\u548C\u884C\u8DDD\u987B\u975E\u8D1F\uFF1B\u5DE6\u53F3\u8FB9\u8DDD\u4E4B\u548C\u987B\u5C0F\u4E8E\u9875\u5BBD\uFF0C\u56FA\u5B9A\u9875\u9AD8\u65F6\u4E0A\u4E0B\u8FB9\u8DDD\u4E4B\u548C\u987B\u5C0F\u4E8E\u9875\u9AD8\u3002`,allowExtraArgs:!1,args:[{name:"width",description:"\u9875\u9762\u5BBD\u5EA6\uFF0C\u987B\u5927\u4E8E\u5DE6\u53F3\u9875\u8FB9\u8DDD\u4E4B\u548C",type:"length",default:
|
|
69
|
+
\u5C3A\u5BF8\u63A5\u53D7 \`px\` \u6216 \`em\`\u3002\u9875\u8FB9\u8DDD\u548C\u884C\u8DDD\u987B\u975E\u8D1F\uFF1B\u5DE6\u53F3\u8FB9\u8DDD\u4E4B\u548C\u987B\u5C0F\u4E8E\u9875\u5BBD\uFF0C\u56FA\u5B9A\u9875\u9AD8\u65F6\u4E0A\u4E0B\u8FB9\u8DDD\u4E4B\u548C\u987B\u5C0F\u4E8E\u9875\u9AD8\u3002`,allowExtraArgs:!1,args:[{name:"width",description:"\u9875\u9762\u5BBD\u5EA6\uFF0C\u987B\u5927\u4E8E\u5DE6\u53F3\u9875\u8FB9\u8DDD\u4E4B\u548C",type:"length",default:ie(ct.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:ie(0)},{name:"top",description:"\u9875\u9762\u4E0A\u8FB9\u8DDD",type:"length",default:ie(ct.marginTop)},{name:"bottom",description:"\u9875\u9762\u4E0B\u8FB9\u8DDD\uFF0C\u542F\u7528\u9875\u7801\u65F6\u81F3\u5C11\u4E3A `16px`",type:"length",default:ie(ct.marginBottom)},{name:"left",description:"\u9875\u9762\u5DE6\u8FB9\u8DDD",type:"length",default:ie(ct.marginLeft)},{name:"right",description:"\u9875\u9762\u53F3\u8FB9\u8DDD",type:"length",default:ie(ct.marginRight)},{name:"gap",description:"\u8C31\u9762\u884C\u4E4B\u95F4\u7684\u6700\u5C0F\u95F4\u8DDD",type:"length",default:{value:1,unit:"em"}},{name:"numbering",description:"\u9875\u7801\u683C\u5F0F\uFF0C\u7A7A\u503C\u9690\u85CF\uFF1B`1` \u663E\u793A\u5F53\u524D\u9875\uFF0C`1/1` \u663E\u793A\u5F53\u524D\u9875/\u603B\u9875\u6570",type:"string",default:""},{name:"font",description:"\u9875\u7801\u5B57\u4F53\uFF0C\u7A7A\u503C\u6CBF\u7528\u5F53\u524D\u5B57\u4F53\u8BBE\u7F6E",type:"string",default:""},{name:"fillRatio",description:"\u81EA\u7136\u5BBD\u5EA6\u8FBE\u5230\u8BE5\u6BD4\u4F8B\u540E\u6491\u6EE1",type:"number",default:ct.fillRatio}]};config;numbering="";font;constructor(t,e,n,o=null){if(super(t,o),this.font=n.variables.font,n.scopeDepth!==0){n.diagnostics.push(new P("W_PAGE_NOT_TOP_LEVEL","@page \u53EA\u80FD\u5728\u6587\u6863\u9876\u5C42\u58F0\u660E\uFF1B\u5F53\u524D\u58F0\u660E\u5DF2\u5FFD\u7565",t)),this.config=null;return}if(n.documentDeclarations.page){n.diagnostics.push(new P("W_DUPLICATE_PAGE","\u6587\u6863\u53EA\u80FD\u58F0\u660E\u4E00\u4E2A @page\uFF1B\u540E\u7EED\u58F0\u660E\u5DF2\u5FFD\u7565",t)),this.config=null;return}n.documentDeclarations.page=!0;let s=this.getArgValue(e,n),i=s.pop();this.font=s.pop()||n.variables.font;let c=s.pop(),[a,l,h,p,f,d,u]=s.map(m=>n.length2px(m));if(!Number.isFinite(a)||a<=0)throw M.error.InvalidPageConfig("@page \u7684 width \u5FC5\u987B\u662F\u6B63\u6709\u9650\u957F\u5EA6",t);if(!Number.isFinite(l))throw M.error.InvalidPageConfig("@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([h,p,f,d,u].some(m=>!Number.isFinite(m)||m<0))throw M.error.InvalidPageConfig("@page \u7684\u8FB9\u8DDD\u548C gap \u5FC5\u987B\u662F\u975E\u8D1F\u6709\u9650\u957F\u5EA6",t);if(f+d>=a)throw M.error.InvalidPageConfig("@page \u7684\u5DE6\u53F3\u8FB9\u8DDD\u6CA1\u6709\u7559\u4E0B\u53EF\u7528\u5185\u5BB9\u5BBD\u5EA6",t);if(l>0&&h+p>=l)throw M.error.InvalidPageConfig("@page \u7684\u4E0A\u4E0B\u8FB9\u8DDD\u6CA1\u6709\u7559\u4E0B\u53EF\u7528\u5185\u5BB9\u9AD8\u5EA6",t);if(c&&p<vo)throw M.error.InvalidPageConfig(`@page \u7684 bottom \u81F3\u5C11\u9700\u8981 ${vo}px \u624D\u80FD\u653E\u4E0B\u9875\u7801`,t);this.config=ue({width:a,height:l,marginTop:h,marginBottom:p,marginLeft:f,marginRight:d,lineGap:u,fillRatio:i}),this.numbering=c}loweringEnter(t){return!t||!this.config?[]:(t.setPageConfig(this.config),this.numbering&&t.addAttachment(new Mo(this.sourceSpan,this.numbering,this.config.marginBottom,{...Lc,fontFamily:this.font})),[])}toString(){if(!this.config)return"@page()";let{width:t,height:e,marginTop:n,marginBottom:o,marginLeft:s,marginRight:i,lineGap:c,fillRatio:a}=this.config;return`@page(width=${t}px, height=${Number.isFinite(e)?e:0}px, top=${n}px, bottom=${o}px, left=${s}px, right=${i}px, gap=${c}px, numbering=${ht(this.numbering)}, font=${ht(this.font)}, fillRatio=${a})`}},Ti=Ro;var Io=class extends L{static def={name:["pagebreak","pb"],description:"\u5F3A\u5236\u6362\u9875",details:`~~~jpfun
|
|
70
|
+
1 2 @br() 3 4 @pagebreak() 5 6
|
|
71
|
+
~~~
|
|
72
|
+
\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}]};static loweringFinalize=tn.loweringFinalize;justify;constructor(t,e,n,o=null){super(t,o),[this.justify]=this.getArgValue(e,n)}loweringEnter(){let t=new $;return t.ast=this,t.mergeKey=-1,t.addon={breakBefore:1,pageBreakBefore:this.justify},[t]}toString(){return`@pagebreak(justify=${this.justify})`}},Ei=Io;var Oo=class extends L{static def={name:["program","instrument"],description:"\u8BBE\u7F6E\u5F53\u524D\u97F3\u8F68\u7684 MIDI \u97F3\u8272",details:`~~~jpfun
|
|
60
73
|
@program(40) 1 2 3
|
|
61
74
|
~~~
|
|
62
|
-
\u5207\u6362\u4E3A\u5C0F\u63D0\u7434\u97F3\u8272\u3002\u8BBE\u7F6E\u5C06\u4F5C\u7528\u4E8E\u5F53\u524D\u97F3\u8F68\u7684\u540E\u7EED\u97F3\u7B26\u3002`,allowExtraArgs:!1,args:[{name:"program",description:"\u4ECE 0 \u5F00\u59CB\u7F16\u53F7\u7684 MIDI \u97F3\u8272\uFF0C\u987B\u4E3A `0..127` \u7684\u6574\u6570",type:"number",default:null}]};program;constructor(t,e,n,o=null){super(t,o);let[s]=this.getArgValue(e,n);if(!Number.isSafeInteger(s)||s<0||s>127)throw new
|
|
75
|
+
\u5207\u6362\u4E3A\u5C0F\u63D0\u7434\u97F3\u8272\u3002\u8BBE\u7F6E\u5C06\u4F5C\u7528\u4E8E\u5F53\u524D\u97F3\u8F68\u7684\u540E\u7EED\u97F3\u7B26\u3002`,allowExtraArgs:!1,args:[{name:"program",description:"\u4ECE 0 \u5F00\u59CB\u7F16\u53F7\u7684 MIDI \u97F3\u8272\uFF0C\u987B\u4E3A `0..127` \u7684\u6574\u6570",type:"number",default:null}]};program;constructor(t,e,n,o=null){super(t,o);let[s]=this.getArgValue(e,n);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 $;return t.ast=this,t.playbackState={program:this.program},t.onTimeState=e=>{e.program=this.program},[t]}toString(){return`@program(${this.program})`}},Li=Oo;var _i=.4,kc=(r,t,e)=>r.top-e*_i-t.bottom,Nc=(r,t)=>{let e=t*_i,n=[],o=0;for(let s of r){if(!s){n.push(null);continue}let i=o-s.bottom;n.push({offset:i,extent:s}),o=i+s.top-e}return n},vc={laneKey:"stack",measure:Nc,place:kc},Po=class r extends L{static def={name:["stack"],description:"\u4E34\u65F6\u591A\u58F0\u90E8",details:"~~~jpfun\n@stack({1 2}, {3/ 4/ 5})\n~~~\n\u63A5\u53D7\u81F3\u5C11\u4E24\u4E2A\u5185\u5BB9\u53C2\u6570\uFF0C\u5404\u5206\u652F\u540C\u65F6\u5F00\u59CB\u3001\u4FDD\u7559\u5404\u81EA\u65F6\u503C\uFF0C\u6574\u4F53\u65F6\u957F\u53D6\u6700\u957F\u5206\u652F\u3002\u9002\u5408\u8282\u594F\u4E0D\u540C\u7684\u4E34\u65F6\u591A\u58F0\u90E8\u3002\n\n**\u7B80\u5199**\uFF1A`{1 2} & {3/ 4/ 5}`\u3002\u53EF\u7EE7\u7EED\u7528 `&` \u8FDE\u63A5\u66F4\u591A\u5206\u652F\uFF1B\u82E5\u8981\u5199\u548C\u5F26\uFF0C\u8BF7\u4F7F\u7528 `up` / `down`\u3002",allowExtraArgs:!0,extraArgType:"content",args:[]};static deSugarAtom(t,e,n){if(t[e]==="&"){let o={kind:"sugar",data:r,span:{start:e,end:e+1}};return{next:e+1,node:o}}return null}static deSugarRelation(t,e,n){let o=e[n++];if(!(o.kind==="sugar"&&o.data===r))return null;let s=t.nodes.length-1;for(;s>=0&&t.nodes[s]instanceof 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",o.span);let c=s;if(i instanceof mt){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(o.span,new Map,t).addContent(i),l=t.nodes;t.nodes=[],t.makeNodes(e,n);for(let h=0;h<t.nodes.length;h++){let p=t.nodes[h];if(!(p instanceof 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",o.span)}contents=[];get children(){return this.contents}timeFlowModel(){return{children:this.contents,mode:"parallel",tracks:vc}}constructor(t,e,n,o=null){super(t,o);for(let[,s]of e){if(s instanceof st){this.addContent(s);continue}let i=n.parseArgWithType(s.valueSpan,"content",t.start);i!==null&&this.addContent(i)}}addContent(t){let e=t instanceof r?t.contents:[t],n=t.sourceSpan;this.sourceSpan.start=Math.min(this.sourceSpan.start,n.start),this.sourceSpan.end=Math.max(this.sourceSpan.end,n.end);for(let o of e)o.parent=this;return this.contents.push(...e),t instanceof r&&(t.contents.length=0),this}toString(t){return`@stack(
|
|
63
76
|
${this.contents.map(n=>n.toString(t)).join(`,
|
|
64
77
|
`).split(`
|
|
65
78
|
`).join(`
|
|
66
79
|
`)}
|
|
67
|
-
)`}combine(t){this.sourceSpan.start=Math.min(this.sourceSpan.start,t.sourceSpan.start),this.sourceSpan.end=Math.max(this.sourceSpan.end,t.sourceSpan.end);for(let e of t.contents)e.parent=this;return this.contents.push(...t.contents),t.contents.length=0,this}},Ks=ro;function Us(i){let t=1/0,e=1/0,n=-1/0,o=-1/0,s=(r,c,a,l)=>{t=Math.min(t,r),e=Math.min(e,c),n=Math.max(n,r+a),o=Math.max(o,c+l)};for(let r of i){let c=r.dx??0;if(r.circle){let{cx:a,cy:l,r:h}=r.circle;s(a+c-h,l-h,2*h,2*h)}if(r.path?.length){let a=Vt(r.path);s(a.x+c,a.y,a.w,a.h)}}return Number.isFinite(t)?{x:t,y:e,w:Math.max(1e-9,n-t),h:Math.max(1e-9,o-e)}:{x:0,y:0,w:1e-9,h:1e-9}}function js(i,t,e,n,o){let s=n.x-e.x*o,r=n.y-e.y*o;for(let c of t){let a=c.style,l=a.strokeWidth===void 0?a:{...a,strokeWidth:a.strokeWidth*o},h=s+(c.dx??0)*o;c.path&&i.drawPath(c.path,l,{x:h,y:r,scaleX:o,scaleY:o}),c.circle&&i.drawCircle(h+c.circle.cx*o,r+c.circle.cy*o,c.circle.r*o,l)}}var Xs={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:i=>i.affectFollowing((t,e)=>{for(let n of e)n.velocity=Math.min(127,n.velocity+20)})};var ue="repeat.jump",Zs={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:()=>[ue],onVisit:(i,t)=>i.visits(t)>1?void 0:{kind:"jump",column:0}};var co="repeat.segno",qs={name:"segno",description:"\u53CD\u590D\u8BB0\u53F7\uFF1AD.S. \u7684\u56DE\u8DF3\u76EE\u6807",weight:1.15,playbackMarks:()=>[co],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 Qs={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:()=>[ue],onVisit:(i,t)=>i.visits(t)>1?void 0:{kind:"jump",column:i.seek(co,t,-1)??0}};var Kr={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"}]},Ur={mf:8.0028,mp:9.523,ff:6.67866,pp:8.8083},jr={fill:"#000"},Xr=.79341;function wt(i,t,e){let n=0,o=Array.from(i,(s,r)=>{let c={path:Kr[s],style:jr,dx:n};return n+=Ur[s+i[r+1]]??0,c});return{name:i,description:e,shapes:o,weight:i.includes("f")?1:Xr,onTimeState:s=>{s.velocity=t}}}var Js=[wt("ppp",16,"\u6781\u5F31"),wt("pp",32,"\u5F88\u5F31"),wt("p",48,"\u5F31"),wt("mp",64,"\u4E2D\u5F31"),wt("mf",80,"\u4E2D\u5F3A"),wt("f",96,"\u5F3A"),wt("ff",112,"\u5F88\u5F3A"),wt("fff",127,"\u6781\u5F3A")];var Zr={},ti={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:i=>i.scaleFollowingBpm(Zr,1,2,{followConnections:!0})};var ei={name:"fine",description:"\u7EC8\u6B62\u8BB0\u53F7\uFF1A\u56DE\u8DF3\u4E4B\u540E\u7ECF\u8FC7\u8FD9\u91CC\u5C31\u7ED3\u675F\u4E50\u66F2",weight:1.4,text:{content:"Fine.",fontFamily:'"Times New Roman", serif'},onVisit:(i,t)=>{let e=i.seek(ue,t,1);return e!==void 0&&i.visits(e)>0?{kind:"stop"}:void 0}};function qt(i){return(t,e)=>{let n=[];for(let o of e){if(!o.transpose){n.push(o);continue}let s=o.end.clone().sub(o.start),r=t.stateAt(o.start).effectiveBpm,c=i.repeat?qr(i.body,s.toNumber(),r):i.body,a=s.div(c.length);for(let l=0;l<c.length;l++){let h=c[l],p=o.start.clone().add(a.clone().mul(l));n.push({...o,start:p,end:p.clone().add(a),midi:h===0?o.midi:o.transpose(h),transpose:f=>o.transpose(h+f)})}}return n}}function qr(i,t,e){let n=Math.min(480,Math.max(60,e))/e,o=Math.floor(256/i.length),s=Math.min(o,Math.max(1,Math.round(t*8*n/i.length))),r=[];for(let c=0;c<s;c++)r.push(...i);return r}var ni={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:i=>i.affectFollowing(qt({body:[0,-1,0]}))};var oi={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:i=>i.affectFollowing(qt({body:[0,1,0]}))};var si={name:"tr",description:"\u98A4\u97F3\uFF1A\u672C\u97F3\u4E0E\u8C03\u5185\u4E0A\u65B9\u4E8C\u5EA6\u4EA4\u66FF",shapes:[{path:[{op:"M",x:3.17992,y:5.46383},{op:"L",x:3.61827,y:3.91711},{op:"C",cx1:3.10024,cy1:3.49862,cx2:2.52947,cy2:3.29304,x:1.90541,y:3.29304},{op:"C",cx1:1.50051,cy1:3.29304,cx2:1.18833,cy2:3.40589,x:.95611,y:3.63812},{op:"C",cx1:.72361,cy1:3.87061,cx2:.59743,cy2:4.14281,x:.57105,y:4.46152},{op:"C",cx1:.57105,cy1:4.91944,cx2:.71707,cy2:5.25147,x:1.00913,y:5.47036},{op:"C",cx1:1.30118,cy1:5.68954,cx2:1.61988,cy2:5.79586,x:1.95843,y:5.79586},{op:"C",cx1:1.9916,cy1:5.79586,cx2:2.03157,cy2:5.8157,x:2.06475,y:5.84888},{op:"C",cx1:2.24394,cy1:5.82904,cx2:2.61568,cy2:5.69632,x:3.17992,y:5.46383},{op:"Z"},{op:"M",x:6.579,y:9.87204},{op:"L",x:8.40472,y:3.75096},{op:"C",cx1:8.40472,cy1:3.59162,cx2:8.35167,cy2:3.51193,x:8.23884,y:3.51193},{op:"C",cx1:7.98647,cy1:3.51193,cx2:7.4554,cy2:3.77761,x:6.63883,y:4.3152},{op:"C",cx1:5.82223,cy1:4.84655,cx2:5.37735,cy2:5.15845,x:5.30448,y:5.25145},{op:"C",cx1:5.33764,cy1:5.21147,cx2:5.39068,cy2:5.15845,x:5.46383,y:5.0853},{op:"C",cx1:6.13441,cy1:6.06127,cx2:6.47294,cy2:6.98417,x:6.47294,y:7.86061},{op:"C",cx1:6.41313,cy1:8.53088,cx2:6.18062,cy2:9.12181,x:5.7692,y:9.61968},{op:"C",cx1:5.3643,cy1:10.11758,cx2:4.85308,cy2:10.3634,x:4.24233,y:10.3634},{op:"C",cx1:3.71778,cy1:10.3634,cx2:3.25306,cy2:10.23719,x:2.83483,y:9.99138},{op:"C",cx1:2.42314,cy1:9.74586,cx2:2.20396,cy2:9.39396,x:2.17759,y:8.92271},{op:"C",cx1:2.21077,cy1:8.80986,cx2:2.23061,cy2:8.66384,x:2.23061,y:8.48436},{op:"L",x:2.85469,y:6.0944},{op:"C",cx1:2.58903,cy1:6.2339,cx2:2.21729,cy2:6.30702,x:1.73924,y:6.30702},{op:"C",cx1:1.22829,cy1:6.2804,cx2:.81007,cy2:6.1012,x:.48458,y:5.76917},{op:"C",cx1:.15935,cy1:5.43065,cx2:0,cy2:4.97926,x:0,y:4.4082},{op:"C",cx1:.03318,cy1:3.89045,cx2:.20586,cy2:3.46543,x:.53107,y:3.13369},{op:"C",cx1:.8563,cy1:2.80166,cx2:1.32782,cy2:2.63579,x:1.95843,y:2.63579},{op:"C",cx1:2.55585,cy1:2.63579,cx2:3.17992,cy2:2.87481,x:3.83716,y:3.34606},{op:"L",x:4.89277,y:0},{op:"L",x:6.85119,y:0},{op:"L",x:5.41053,y:4.51453},{op:"C",cx1:6.28694,cy1:3.83064,cx2:7.02389,cy2:3.34606,x:7.62128,y:3.06054},{op:"C",cx1:8.21899,cy1:2.77502,cx2:8.86943,cy2:2.63579,x:9.57321,y:2.63579},{op:"C",cx1:10.05773,cy1:2.63579,cx2:10.30358,cy2:2.83484,x:10.30358,y:3.23974},{op:"C",cx1:10.30358,cy1:3.44559,cx2:10.17738,cy2:3.89046,x:10.09093,y:4.18931},{op:"C",cx1:10.7283,cy1:3.15354,cx2:11.45195,cy2:2.63579,x:12.26199,y:2.63579},{op:"C",cx1:12.6272,cy1:2.63579,cx2:12.91925,cy2:2.76849,x:13.14497,y:3.03417},{op:"C",cx1:13.37717,cy1:3.29957,cx2:13.49001,cy2:3.61175,x:13.49001,y:3.97014},{op:"C",cx1:13.49001,cy1:4.62739,cx2:13.09844,cy2:5.03228,x:12.53419,y:5.03228},{op:"C",cx1:12.16899,cy1:5.03228,cx2:11.85709,cy2:4.79327,x:11.80382,y:4.29536},{op:"C",cx1:11.89029,cy1:3.91031,cx2:11.98982,cy2:3.55191,x:11.98982,y:3.34606},{op:"C",cx1:11.98982,cy1:3.27291,cx2:11.94329,cy2:3.23973,x:11.85709,y:3.23973},{op:"C",cx1:11.74403,cy1:3.23973,cx2:11.53162,cy2:3.34606,x:11.20637,y:3.56522},{op:"C",cx1:10.90752,cy1:3.7708,cx2:10.61547,cy2:4.11615,x:10.31666,y:4.61405},{op:"C",cx1:10.01808,cy1:5.11195,cx2:9.77253,cy2:5.69632,x:9.57321,y:6.36662},{op:"L",x:8.45798,y:9.87203},{op:"L",x:6.57899,y:9.87203},{op:"L",x:6.579,y:9.87204},{op:"Z"},{op:"M",x:5.05893,y:5.62971},{op:"L",x:3.94348,y:8.92274},{op:"C",cx1:3.94348,cy1:9.0288,cx2:3.92364,cy2:9.12179,x:3.89045,y:9.19495},{op:"C",cx1:3.89045,cy1:9.48047,cx2:4.06285,cy2:9.65287,x:4.40821,y:9.70617},{op:"C",cx1:5.404,cy1:9.22134,cx2:5.9019,cy2:8.51787,x:5.9019,y:7.58841},{op:"C",cx1:5.9019,cy1:6.99751,cx2:5.62318,cy2:6.34681,x:5.05893,y:5.62972},{op:"L",x:5.05893,y:5.62971},{op:"Z"}],style:{fill:"#000"}}],emitPlayback:i=>i.affectFollowing(qt({body:[0,1],repeat:!0}))};var ii=new Map([si,ti,oi,ni,Xs,...Js,Zs,Qs,qs,ei].map(i=>[i.name.toLowerCase(),i])),ao=class extends v{static def={name:["symbol","$"],description:"\u521B\u5EFA\u4E00\u4E2A\u4E50\u8C31\u7B26\u53F7",details:`~~~jpfun
|
|
80
|
+
)`}},ki=Po;var Ni={name:"accent",description:"\u91CD\u97F3",weight:.5,shapes:[{path:[{op:"M",x:.21413,y:.4818},{op:"L",x:8.21413,y:3.72071},{op:"L",x:.29494,y:6.92724}],style:{stroke:"#000",strokeWidth:1}}],emitPlayback:r=>r.affectFollowing((t,e)=>{for(let n of e)n.velocity=Math.min(127,n.velocity+20)})};var Ee="repeat.jump",vi={name:"dc",description:"\u4ECE\u5934\u53CD\u590D\uFF1A\u8DF3\u56DE\u66F2\u9996\u518D\u6F14\u4E00\u904D",weight:.9,shapes:[{path:[{op:"M",x:1.06974,y:7.0752},{op:"L",x:2.69184,y:1.21499},{op:"C",cx1:2.69184,cy1:1.1221,cx2:2.73825,cy2:.93022,x:2.73825,y:.86039},{op:"C",cx1:2.73825,cy1:.48248,cx2:2.4825,cy2:.33152,x:1.7614,y:.23838},{op:"L",x:1.7614,y:.04641},{op:"L",x:4.88344,y:.04641},{op:"C",cx1:7.64477,cy1:.04641,cx2:9.02278,cy2:1.18018,x:9.02278,y:3.45323},{op:"C",cx1:9.02278,cy1:4.47649,cx2:8.74941,cy2:5.36592,x:8.20888,y:6.11596},{op:"C",cx1:7.6681,cy1:6.86578,cx2:6.95303,cy2:7.4297,x:6.05765,y:7.81334},{op:"C",cx1:5.16823,cy1:8.19125,cx2:4.22074,cy2:8.38316,x:3.21493,y:8.38316},{op:"L",x:0,y:8.38316},{op:"L",x:0,y:8.19119},{op:"C",cx1:.64542,cy1:8.19126,cx2:.91275,cy2:7.81343,x:1.06974,y:7.07521},{op:"L",x:1.06974,y:7.0752},{op:"Z"},{op:"M",x:4.09864,y:.66867},{op:"L",x:2.2848,y:7.35998},{op:"C",cx1:2.2848,cy1:7.42409,cx2:2.26718,cy2:7.48786,x:2.23815,y:7.55197},{op:"C",cx1:2.29051,cy1:7.84841,cx2:2.58133,cy2:7.99961,x:3.12179,y:7.99961},{op:"C",cx1:3.97639,cy1:7.99961,cx2:4.74389,cy2:7.79034,x:5.42397,y:7.37165},{op:"C",cx1:6.10429,cy1:6.94733,cx2:6.62746,cy2:6.37751,x:7.00538,y:5.65666},{op:"C",cx1:7.3833,cy1:4.92994,cx2:7.5752,cy2:4.1334,x:7.5752,y:3.26134},{op:"C",cx1:7.5752,cy1:1.372,cx2:6.69156,cy2:.43029,x:4.92984,y:.43029},{op:"C",cx1:4.53471,cy1:.43029,cx2:4.25555,cy2:.51151,x:4.09864,y:.66869},{op:"L",x:4.09864,y:.66867},{op:"Z"},{op:"M",x:18.35961,y:.04641},{op:"L",x:17.90593,y:2.62204},{op:"L",x:17.66755,y:2.62204},{op:"C",cx1:17.563,cy1:1.19183,cx2:16.91187,cy2:.47678,x:15.71418,y:.47678},{op:"C",cx1:14.96437,cy1:.47678,cx2:14.29564,cy2:.73848,x:13.70274,y:1.26165},{op:"C",cx1:13.11556,cy1:1.77911,cx2:12.65617,cy2:2.43578,x:12.33664,y:3.22668},{op:"C",cx1:12.01679,cy1:4.01155,cx2:11.85988,cy2:4.77302,x:11.85988,y:5.49984},{op:"C",cx1:11.85988,cy1:6.26131,cx2:12.03424,cy2:6.90076,x:12.37734,y:7.41814},{op:"C",cx1:12.72598,cy1:7.9356,cx2:13.24931,cy2:8.19126,x:13.95279,y:8.19126},{op:"C",cx1:15.08622,cy1:8.19126,cx2:16.11543,cy2:7.68548,x:17.02818,y:6.66825},{op:"L",x:17.21412,y:6.86023},{op:"C",cx1:16.26663,cy1:8.16232,cx2:15.08051,cy2:8.81352,x:13.66775,y:8.81352},{op:"C",cx1:13.034,cy1:8.81352,cx2:12.47014,cy2:8.65637,x:11.97608,y:8.34254},{op:"C",cx1:11.48195,cy1:8.02864,cx2:11.10411,cy2:7.60432,x:10.83074,y:7.06925},{op:"C",cx1:10.56333,cy1:6.53442,cx2:10.42974,cy2:5.94748,x:10.42974,y:5.31357},{op:"C",cx1:10.42974,cy1:4.43581,cx2:10.67383,cy2:3.58692,x:11.15655,y:2.7616},{op:"C",cx1:11.63894,cy1:1.93602,cx2:12.28427,cy2:1.26738,x:13.09223,y:.76158},{op:"C",cx1:13.90042,cy1:.25578,cx2:14.74336,cy2:3e-5,x:15.62137,y:3e-5},{op:"C",cx1:15.88283,cy1:3e-5,cx2:16.12121,cy2:.0174,x:16.33651,y:.0581},{op:"C",cx1:16.55157,cy1:.09886,cx2:16.79557,cy2:.15122,x:17.05729,y:.21501},{op:"C",cx1:17.31875,cy1:.2791,cx2:17.51072,cy2:.31979,x:17.62123,y:.33717},{op:"C",cx1:17.85961,cy1:.2557,cx2:18.03389,cy2:.15694,x:18.14432,y:.04643},{op:"L",x:18.35962,y:.04643},{op:"L",x:18.35961,y:.04644},{op:"Z"},{op:"M",x:8.19134,y:7.69151},{op:"C",cx1:8.19134,cy1:7.5169,cx2:8.25544,cy2:7.36596,x:8.38894,y:7.2322},{op:"C",cx1:8.52277,cy1:7.09838,cx2:8.69134,cy2:7.0288,x:8.88332,y:7.0288},{op:"C",cx1:9.0519,cy1:7.0288,cx2:9.19722,cy2:7.09838,x:9.3251,y:7.2322},{op:"C",cx1:9.45893,cy1:7.36603,cx2:9.5227,cy2:7.52294,x:9.5227,y:7.69151},{op:"C",cx1:9.5227,cy1:8.0925,cx2:9.23221,cy2:8.38324,x:8.88332,y:8.38324},{op:"C",cx1:8.48803,cy1:8.38324,cx2:8.19134,cy2:8.10416,x:8.19134,y:7.69151},{op:"Z"},{op:"M",x:18.00469,y:7.79028},{op:"C",cx1:18.00469,cy1:7.40068,cx2:18.27814,cy2:7.12162,x:18.64432,y:7.12162},{op:"C",cx1:19.03969,cy1:7.12162,cx2:19.31298,cy2:7.39507,x:19.31298,y:7.79028},{op:"C",cx1:19.31298,cy1:8.15653,cx2:19.0339,cy2:8.42965,x:18.64432,y:8.42965},{op:"C",cx1:18.28972,cy1:8.42965,cx2:18.00469,cy2:8.14486,x:18.00469,y:7.79028},{op:"Z"}],style:{fill:"#000"}}],playbackMarks:()=>[Ee],onVisit:(r,t)=>r.visits(t)>1?void 0:{kind:"jump",column:0}};var Bo="repeat.segno",Mi={name:"segno",description:"\u53CD\u590D\u8BB0\u53F7\uFF1AD.S. \u7684\u56DE\u8DF3\u76EE\u6807",weight:1.15,playbackMarks:()=>[Bo],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 Ri={name:"ds",description:"\u4ECE\u8BB0\u53F7\u5904\u53CD\u590D\uFF1A\u8DF3\u56DE\u6700\u8FD1\u7684 $segno",weight:.9,shapes:[{path:[{op:"M",x:3.30971,y:8.58253},{op:"L",x:0,y:8.58253},{op:"L",x:0,y:8.38492},{op:"C",cx1:.66434,cy1:8.38492,cx2:.93964,cy2:7.9959,x:1.10119,y:7.23595},{op:"L",x:2.77112,y:1.20293},{op:"C",cx1:2.77112,cy1:1.10732,cx2:2.81892,cy2:.90973,x:2.81892,y:.83791},{op:"C",cx1:2.81892,cy1:.44886,cx2:2.55564,cy2:.29345,x:1.81333,y:.19758},{op:"L",x:1.81333,y:0},{op:"L",x:5.02743,y:0},{op:"C",cx1:7.87013,cy1:0,cx2:9.28879,cy2:1.16713,x:9.28879,y:3.50729},{op:"C",cx1:9.28879,cy1:4.56066,cx2:9.00736,cy2:5.47632,x:8.45088,y:6.24853},{op:"C",cx1:7.89416,cy1:7.02049,cx2:7.15799,cy2:7.60099,x:6.23624,y:7.9959},{op:"C",cx1:5.32063,cy1:8.38492,cx2:4.34519,cy2:8.58253,x:3.3097,y:8.58253},{op:"L",x:3.30971,y:8.58253},{op:"Z"},{op:"M",x:4.21944,y:.64057},{op:"L",x:2.35218,y:7.52917},{op:"C",cx1:2.35218,cy1:7.59509,cx2:2.33403,cy2:7.66079,x:2.30413,y:7.72673},{op:"C",cx1:2.35806,cy1:8.03196,cx2:2.65738,cy2:8.18763,x:3.21387,y:8.18763},{op:"C",cx1:4.71023,cy1:8.18763,cx2:5.84745,cy2:7.75053,x:6.6253,y:6.88271},{op:"C",cx1:7.40952,cy1:6.00899,cx2:7.79857,cy2:4.81807,x:7.79857,y:3.30973},{op:"C",cx1:7.79857,cy1:1.36475,cx2:6.88883,cy2:.39519,x:5.07525,y:.39519},{op:"C",cx1:4.66831,cy1:.39517,cx2:4.38101,cy2:.47876,x:4.21945,y:.64056},{op:"L",x:4.21944,y:.64056},{op:"Z"},{op:"M",x:17.3325,y:1e-5},{op:"L",x:16.81794,y:2.54976},{op:"L",x:16.57254,y:2.54976},{op:"C",cx1:16.57254,cy1:1.14312,cx2:16.03984,cy2:.44299,x:14.98033,y:.44299},{op:"C",cx1:14.57337,cy1:.44299,cx2:14.24416,cy2:.56262,x:13.98698,y:.80212},{op:"C",cx1:13.72958,cy1:1.04139,cx2:13.60383,cy2:1.35272,x:13.60383,y:1.74176},{op:"C",cx1:13.60383,cy1:2.10677,cx2:13.70556,cy2:2.424,x:13.91516,y:2.70518},{op:"C",cx1:14.12452,cy1:2.98048,cx2:14.45375,cy2:3.34575,x:14.91464,y:3.7946},{op:"C",cx1:15.37551,cy1:4.24346,cx2:15.72261,cy2:4.65626,x:15.9619,y:5.03332},{op:"C",cx1:16.20729,cy1:5.40444,cx2:16.32715,cy2:5.83541,x:16.32715,y:6.32621},{op:"C",cx1:16.35708,cy1:7.82844,cx2:15.01635,cy2:8.89386,x:13.70558,y:8.87572},{op:"C",cx1:13.47219,cy1:8.87572,cx2:13.12508,cy2:8.79188,x:12.65219,y:8.63033},{op:"C",cx1:12.17955,cy1:8.46874,cx2:11.86231,cy2:8.38489,x:11.69463,y:8.38489},{op:"C",cx1:11.45538,cy1:8.38489,cx2:11.25778,cy2:8.60652,x:11.20385,y:8.82787},{op:"L",x:10.95848,y:8.82787},{op:"L",x:11.40145,y:6.00895},{op:"L",x:11.69464,y:6.00895},{op:"C",cx1:11.69464,cy1:6.12272,cx2:11.67678,cy2:6.24847,x:11.64684,y:6.374},{op:"C",cx1:11.67065,cy1:6.93075,cx2:11.85619,cy2:7.40948,x:12.20332,y:7.82232},{op:"C",cx1:12.55657,cy1:8.22948,cx2:13.00544,cy2:8.43297,x:13.55603,y:8.43297},{op:"C",cx1:14.02891,cy1:8.43297,cx2:14.42384,cy2:8.26529,x:14.74108,y:7.92405},{op:"C",cx1:15.06418,cy1:7.58305,cx2:15.22573,cy2:7.18198,x:15.22573,y:6.72112},{op:"C",cx1:15.22573,cy1:6.34406,cx2:15.11223,cy2:6.00313,x:14.89062,y:5.69764},{op:"C",cx1:14.66925,cy1:5.39246,cx2:14.32802,cy2:5.00951,x:13.85538,y:4.54279},{op:"C",cx1:13.38247,cy1:4.07579,cx2:13.03535,cy2:3.67473,x:12.80197,y:3.33374},{op:"C",cx1:12.56858,cy1:2.99248,cx2:12.45484,cy2:2.59756,x:12.45484,y:2.16072},{op:"C",cx1:12.45484,cy1:1.53216,cx2:12.67621,cy2:1.01761,x:13.12509,y:.61042},{op:"C",cx1:13.57395,cy1:.20348,cx2:14.11864,cy2:2e-5,x:14.75896,y:2e-5},{op:"C",cx1:15.18993,cy1:2e-5,cx2:15.55495,cy2:.05983,x:15.86016,y:.17358},{op:"C",cx1:16.16536,cy1:.28733,cx2:16.38697,cy2:.34714,x:16.52452,y:.34714},{op:"C",cx1:16.6922,cy1:.34714,cx2:16.86576,cy2:.23339,x:17.03932,y:2e-5},{op:"L",x:17.33249,y:2e-5},{op:"L",x:17.3325,y:1e-5},{op:"Z"},{op:"M",x:8.43275,y:7.87042},{op:"C",cx1:8.43275,cy1:7.69072,cx2:8.4987,cy2:7.5353,x:8.63622,y:7.3975},{op:"C",cx1:8.774,cy1:7.25976,cx2:8.94755,cy2:7.18816,x:9.14514,y:7.18816},{op:"C",cx1:9.3187,cy1:7.18816,cx2:9.46824,cy2:7.25975,x:9.59988,y:7.3975},{op:"C",cx1:9.73766,cy1:7.53529,cx2:9.80338,cy2:7.69685,x:9.80338,y:7.87042},{op:"C",cx1:9.80338,cy1:8.28325,cx2:9.5043,cy2:8.58254,x:9.14514,y:8.58254},{op:"C",cx1:8.7382,cy1:8.58254,cx2:8.43275,cy2:8.29521,x:8.43275,y:7.87042},{op:"Z"},{op:"M",x:16.88952,y:7.9721},{op:"C",cx1:16.88952,cy1:7.57106,cx2:17.21875,cy2:7.28373,x:17.62569,y:7.28373},{op:"C",cx1:18.00297,cy1:7.28373,cx2:18.29003,cy2:7.56516,x:18.29003,y:7.9721},{op:"C",cx1:18.29003,cy1:8.34914,cx2:17.99096,cy2:8.63036,x:17.62569,y:8.63036},{op:"C",cx1:17.42219,cy1:8.63036,cx2:17.24863,cy2:8.56461,x:17.105,y:8.43887},{op:"C",cx1:16.96135,cy1:8.31309,cx2:16.88952,cy2:8.1577,x:16.88952,y:7.9721},{op:"Z"}],style:{fill:"#000"}}],playbackMarks:()=>[Ee],onVisit:(r,t)=>r.visits(t)>1?void 0:{kind:"jump",column:r.seek(Bo,t,-1)??0}};var Mc={m:[{op:"M",x:1.13,y:10.3672},{op:"L",x:2.9911,y:5.3125},{op:"C",cx1:3.0585,cy1:5.0607,cx2:3.0955,cy2:4.8889,x:3.0955,y:4.8089},{op:"C",cx1:3.0955,cy1:4.6248,cx2:2.9972,cy2:4.5327,x:2.7944,y:4.5327},{op:"C",cx1:2.5489,cy1:4.5327,cx2:2.217,cy2:4.7782,x:1.7994,y:5.2758},{op:"C",cx1:1.3881,cy1:5.7671,cx2:.9766,cy2:6.4856,x:.5774,y:7.4254},{op:"L",x:0,y:7.4254},{op:"C",cx1:.4976,cy1:6.3628,cx2:1.0133,cy2:5.4783,x:1.5476,y:4.7782},{op:"C",cx1:2.0882,cy1:4.0781,cx2:2.7576,cy2:3.7279,x:3.5498,y:3.7279},{op:"C",cx1:4.1518,cy1:3.7279,cx2:4.4773,cy2:4.0534,x:4.5264,y:4.7045},{op:"C",cx1:5.2818,cy1:4.0167,cx2:5.9512,cy2:3.6728,x:6.5409,y:3.6728},{op:"C",cx1:7.1796,cy1:3.6728,cx2:7.5235,cy2:4.0167,x:7.5728,y:4.7045},{op:"C",cx1:7.8797,cy1:4.3976,cx2:8.2483,cy2:4.1518,x:8.6843,y:3.9614},{op:"C",cx1:9.1205,cy1:3.7709,cx2:9.5197,cy2:3.6728,x:9.8882,y:3.6728},{op:"C",cx1:10.5393,cy1:3.6728,cx2:10.8645,cy2:3.943,x:10.8645,y:4.4834},{op:"C",cx1:10.8645,cy1:4.6001,cx2:10.8339,cy2:4.7905,x:10.7664,y:5.0607},{op:"L",x:9.3846,y:9.0345},{op:"C",cx1:9.3109,cy1:9.3353,cx2:9.2616,cy2:9.4951,x:9.2309,y:9.6364},{op:"C",cx1:9.2309,cy1:9.7959,cx2:9.3169,cy2:9.9066,x:9.4827,y:9.9619},{op:"C",cx1:10.011,cy1:9.8943,cx2:10.6988,cy2:9.1512,x:11.5463,y:7.7263},{op:"L",x:12.0499,y:7.7263},{op:"C",cx1:11.7981,cy1:8.1502,cx2:11.5279,cy2:8.6045,x:11.227,y:9.0958},{op:"C",cx1:10.9322,cy1:9.5811,cx2:10.6006,cy2:9.9864,x:10.2381,y:10.2996},{op:"C",cx1:9.8759,cy1:10.613,cx2:9.4583,cy2:10.7725,x:8.9791,y:10.7725},{op:"C",cx1:8.1499,cy1:10.7725,cx2:7.6279,cy2:10.3919,x:7.4191,y:9.6365},{op:"C",cx1:7.4437,cy1:9.397,cx2:7.5235,cy2:9.0775,x:7.6649,y:8.6783},{op:"C",cx1:7.806,cy1:8.279,cx2:7.8797,cy2:8.0395,x:7.8981,y:7.9535},{op:"L",x:8.9054,y:5.3619},{op:"C",cx1:8.924,cy1:5.2572,cx2:8.9791,cy2:5.0117,x:8.9791,y:4.9073},{op:"C",cx1:8.9791,cy1:4.6922,cx2:8.887,cy2:4.5818,x:8.7028,y:4.5818},{op:"C",cx1:8.1992,cy1:4.5818,cx2:7.8246,cy2:4.9257,x:7.5728,y:5.6137},{op:"L",x:5.8838,y:10.3673},{op:"L",x:4.0781,y:10.3673},{op:"L",x:5.9389,y:5.2635},{op:"C",cx1:5.9696,cy1:5.1591,cx2:5.9882,cy2:5.0424,x:5.9882,y:4.9073},{op:"C",cx1:5.9882,cy1:4.6922,cx2:5.8592,cy2:4.5818,x:5.6073,y:4.5818},{op:"C",cx1:5.159,cy1:4.6002,cx2:4.8335,cy2:4.944,x:4.6308,y:5.6137},{op:"L",x:2.8927,y:10.3673},{op:"L",x:1.13,y:10.3673},{op:"L",x:1.13,y:10.3672},{op:"Z"}],f:[{op:"M",x:6.1601,y:4.0781},{op:"C",cx1:6.4302,cy1:3.3717,cx2:6.8234,cy2:2.7086,x:7.3391,y:2.0882},{op:"C",cx1:7.8551,cy1:1.4679,cx2:8.4754,cy2:.9642,x:9.2062,y:.5773},{op:"C",cx1:9.937,cy1:.1904,cx2:10.7355,cy2:0,x:11.5953,y:0},{op:"C",cx1:12.0559,cy1:.043,cx2:12.4061,cy2:.2088,x:12.6333,y:.4913},{op:"C",cx1:12.8607,cy1:.7678,cx2:12.9772,cy2:1.1117,x:12.9772,y:1.5109},{op:"C",cx1:12.9772,cy1:1.9345,cx2:12.8421,cy2:2.3154,x:12.5659,y:2.6472},{op:"C",cx1:12.2954,cy1:2.9788,cx2:11.9578,cy2:3.1446,x:11.5463,y:3.1446},{op:"C",cx1:11.0487,cy1:3.1446,cx2:10.7662,cy2:2.9174,x:10.7111,y:2.4691},{op:"C",cx1:10.7418,cy1:2.1743,cx2:10.8522,cy2:1.8918,x:11.0427,y:1.6276},{op:"C",cx1:11.2331,cy1:1.3635,cx2:11.4666,cy2:1.1793,x:11.7428,y:1.087},{op:"C",cx1:11.8472,cy1:1.087,cx2:11.8965,cy2:1.0379,x:11.8965,y:.9335},{op:"C",cx1:11.8965,cy1:.8108,cx2:11.614,cy2:.6327,x:11.2147,y:.6327},{op:"C",cx1:10.0908,cy1:.6327,cx2:9.237,cy2:1.7811,x:8.6535,y:4.0781},{op:"L",x:10.8646,y:4.0781},{op:"L",x:10.8646,y:4.9073},{op:"L",x:8.4508,y:4.9073},{op:"C",cx1:8.2483,cy1:5.7918,cx2:7.9902,cy2:6.6944,x:7.671,y:7.6156},{op:"C",cx1:7.3577,cy1:8.5308,cx2:7.026,cy2:9.3723,x:6.676,y:10.1401},{op:"C",cx1:6.3319,cy1:10.9076,cx2:6.0064,cy2:11.5156,x:5.7055,y:11.9762},{op:"C",cx1:5.2632,cy1:12.658,cx2:4.7966,cy2:13.2353,x:4.299,y:13.7145},{op:"C",cx1:3.8016,cy1:14.1995,cx2:3.206,cy2:14.5067,x:2.5119,y:14.6418},{op:"C",cx1:2.211,cy1:14.6788,cx2:2.0266,cy2:14.6972,x:1.9592,y:14.6972},{op:"C",cx1:1.3632,cy1:14.6972,cx2:.8905,cy2:14.5128,x:.5527,y:14.1382},{op:"C",cx1:.2149,cy1:13.7636,cx2:.0307,cy2:13.3276,x:0,y:12.83},{op:"C",cx1:.0428,cy1:12.3941,cx2:.1718,cy2:12.0623,x:.3869,y:11.8351},{op:"C",cx1:.6017,cy1:11.6079,cx2:.9149,cy2:11.4298,x:1.3326,y:11.3008},{op:"C",cx1:1.6458,cy1:11.3254,cx2:1.9039,cy2:11.4359,x:2.1066,y:11.6324},{op:"C",cx1:2.3091,cy1:11.8352,cx2:2.4135,cy2:12.0809,x:2.4135,y:12.3818},{op:"C",cx1:2.4135,cy1:12.9405,cx2:1.8548,cy2:13.4134,x:1.4309,y:13.8127},{op:"C",cx1:1.4309,cy1:13.9171,cx2:1.5476,cy2:13.9664,x:1.7811,y:13.9664},{op:"C",cx1:2.7453,cy1:13.9664,cx2:3.5129,cy2:12.9405,x:4.0718,y:10.8955},{op:"C",cx1:4.2683,cy1:10.3426,cx2:4.4404,cy2:9.8083,x:4.5938,y:9.2926},{op:"C",cx1:4.7475,cy1:8.7703,cx2:4.9624,cy2:8.0028,x:5.2449,y:6.9832},{op:"C",cx1:5.5337,cy1:5.9575,cx2:5.7362,cy2:5.2695,x:5.8592,y:4.9073},{op:"L",x:4.1702,y:4.9073},{op:"L",x:4.1702,y:4.0781},{op:"L",x:6.1601,y:4.0781},{op:"Z"}],p:[{op:"M",x:3.767,y:8.5573},{op:"L",x:5.0097,y:5.0738},{op:"C",cx1:5.0804,cy1:4.7969,cx2:5.1126,cy2:4.5909,x:5.1126,y:4.443},{op:"C",cx1:5.1126,cy1:4.2497,cx2:5.0224,cy2:4.1531,x:4.8486,y:4.1531},{op:"C",cx1:4.7262,cy1:4.1531,cx2:4.5653,cy2:4.2497,x:4.3786,y:4.443},{op:"C",cx1:3.9471,cy1:4.9001,cx2:3.6059,cy2:5.383,x:3.3484,y:5.8917},{op:"L",x:2.6851,y:5.8917},{op:"C",cx1:2.8138,cy1:5.5117,cx2:3.0264,cy2:5.1126,x:3.3163,y:4.7004},{op:"C",cx1:3.6059,cy1:4.2818,cx2:3.9471,cy2:3.9406,x:4.3335,y:3.6702},{op:"C",cx1:4.7262,cy1:3.3933,cx2:5.1192,cy2:3.258,x:5.5119,y:3.258},{op:"C",cx1:6.1623,cy1:3.258,cx2:6.613,cy2:3.5671,x:6.8575,y:4.179},{op:"C",cx1:7.1987,cy1:3.8891,cx2:7.6044,cy2:3.6444,x:8.0617,y:3.4447},{op:"C",cx1:8.5188,cy1:3.2454,cx2:8.9632,cy2:3.1486,x:9.388,y:3.1486},{op:"C",cx1:10.1286,cy1:3.1486,cx2:10.7017,cy2:3.4447,x:11.1008,y:4.0437},{op:"C",cx1:11.5064,cy1:4.636,cx2:11.706,cy2:5.3249,x:11.706,y:6.104},{op:"C",cx1:11.706,cy1:6.8187,cx2:11.5322,cy2:7.5464,x:11.178,y:8.274},{op:"C",cx1:10.8304,cy1:9.0017,cx2:10.3538,cy2:9.6004,x:9.7422,y:10.0704},{op:"C",cx1:9.1306,cy1:10.5406,cx2:8.4607,cy2:10.7724,x:7.7267,y:10.7724},{op:"C",cx1:7.0442,cy1:10.7724,cx2:6.4133,cy2:10.5148,x:5.8273,y:10.006},{op:"L",x:4.7972,y:12.9614},{op:"C",cx1:4.765,cy1:13.0453,cx2:4.7133,cy2:13.1998,x:4.6426,y:13.4122},{op:"C",cx1:4.6684,cy1:13.6377,cx2:4.7842,cy2:13.7922,x:4.9902,y:13.8695},{op:"C",cx1:5.2028,cy1:13.9531,cx2:5.5504,cy2:13.9919,x:6.0399,y:13.9919},{op:"L",x:6.0399,y:14.8095},{op:"L",x:0,y:14.8095},{op:"L",x:0,y:13.9919},{op:"C",cx1:.7469,cy1:13.9919,cx2:1.2815,cy2:13.8759,x:1.5969,y:13.6506},{op:"C",cx1:1.9124,cy1:13.4251,cx2:2.1379,cy2:13.1289,x:2.2666,y:12.7491},{op:"L",x:3.767,y:8.5573},{op:"Z"},{op:"M",x:7.0637,y:6.3166},{op:"C",cx1:6.7802,cy1:6.9604,cx2:6.6064,cy2:7.8104,x:6.5357,y:8.8727},{op:"C",cx1:6.6064,cy1:9.5619,cx2:6.7609,cy2:9.9031,x:7.012,y:9.9031},{op:"C",cx1:7.8879,cy1:9.7356,cx2:8.609,cy2:8.7248,x:9.1755,y:6.8704},{op:"C",cx1:9.3495,cy1:6.2071,cx2:9.4395,cy2:5.6084,x:9.4395,y:5.0738},{op:"C",cx1:9.4395,cy1:4.4108,cx2:9.2657,cy2:4.05,x:8.9115,y:3.9923},{op:"C",cx1:8.332,cy1:3.9923,cx2:7.7139,cy2:4.7647,x:7.0637,y:6.3166},{op:"Z"}]},Rc={mf:8.0028,mp:9.523,ff:6.67866,pp:8.8083},Ic={fill:"#000"},Oc=.79341;function kt(r,t,e){let n=0,o=Array.from(r,(s,i)=>{let c={path:Mc[s],style:Ic,dx:n};return n+=Rc[s+r[i+1]]??0,c});return{name:r,description:e,shapes:o,weight:r.includes("f")?1:Oc,onTimeState:s=>{s.velocity=t}}}var Ii=[kt("ppp",16,"\u6781\u5F31"),kt("pp",32,"\u5F88\u5F31"),kt("p",48,"\u5F31"),kt("mp",64,"\u4E2D\u5F31"),kt("mf",80,"\u4E2D\u5F3A"),kt("f",96,"\u5F3A"),kt("ff",112,"\u5F88\u5F3A"),kt("fff",127,"\u6781\u5F3A")];var Pc={},Oi={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(Pc,1,2,{followConnections:!0})};var Pi={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(Ee,t,1);return e!==void 0&&r.visits(e)>0?{kind:"stop"}:void 0}};function re(r){return(t,e)=>{let n=[];for(let o of e){if(!o.transpose){n.push(o);continue}let s=o.end.clone().sub(o.start),i=r.body.length;if(r.repeat){let a=t.stateAt(o.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(o.start);n.push({...o,start:h,end:h.clone().add(c),midi:l===0?o.midi:o.transpose(l),transpose:p=>o.transpose(l+p)})}}return n}}var Bi={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(re({body:[0,-1,0]}))};var Di={name:"prall",description:"\u4E0A\u6CE2\u97F3\uFF1A\u672C\u97F3\u3001\u8C03\u5185\u4E0A\u65B9\u4E8C\u5EA6\u3001\u672C\u97F3",weight:.55,shapes:[{path:[{op:"M",x:3.12541,y:.06003},{op:"C",cx1:3.18541,cy1:.03003,cx2:3.30541,cy2:3e-5,x:3.36541,y:3e-5},{op:"C",cx1:3.66541,cy1:3e-5,cx2:3.63541,cy2:-.02997,x:5.25541,y:1.95003},{op:"L",x:6.78541,y:3.78003},{op:"C",cx1:6.81541,cy1:3.78003,cx2:7.35541,cy2:2.94003,x:8.01541,y:1.95003},{op:"C",cx1:9.15541,cy1:.27003,cx2:9.24541,cy2:.12003,x:9.36541,y:.06003},{op:"C",cx1:9.42541,cy1:.03003,cx2:9.54541,cy2:3e-5,x:9.60541,y:3e-5},{op:"C",cx1:9.90541,cy1:3e-5,cx2:9.87541,cy2:-.02997,x:11.49541,y:1.95003},{op:"L",x:13.02541,y:3.78003},{op:"L",x:13.50541,y:3.09003},{op:"C",cx1:14.01541,cy1:2.31003,cx2:14.04541,cy2:2.25003,x:14.19541,y:2.19003},{op:"C",cx1:14.61541,cy1:2.01003,cx2:15.06541,cy2:2.34003,x:15.00541,y:2.79003},{op:"C",cx1:14.97541,cy1:2.91003,cx2:14.70541,cy2:3.30003,x:13.50541,y:5.16003},{op:"C",cx1:12.12541,cy1:7.23003,cx2:12.00541,cy2:7.38003,x:11.88541,y:7.44003},{op:"C",cx1:11.82541,cy1:7.47003,cx2:11.70541,cy2:7.50003,x:11.64541,y:7.50003},{op:"C",cx1:11.34541,cy1:7.50003,cx2:11.37541,cy2:7.53003,x:9.75541,y:5.55003},{op:"L",x:8.22541,y:3.72003},{op:"C",cx1:8.19541,cy1:3.72003,cx2:7.65541,cy2:4.56003,x:6.99541,y:5.55003},{op:"C",cx1:5.85541,cy1:7.23003,cx2:5.76541,cy2:7.38003,x:5.64541,y:7.44003},{op:"C",cx1:5.58541,cy1:7.47003,cx2:5.46541,cy2:7.50003,x:5.40541,y:7.50003},{op:"C",cx1:5.10541,cy1:7.50003,cx2:5.13541,cy2:7.53003,x:3.51541,y:5.55003},{op:"L",x:1.98541,y:3.72003},{op:"L",x:1.50541,y:4.41003},{op:"C",cx1:.99541,cy1:5.19003,cx2:.96541,cy2:5.25003,x:.81541,y:5.31003},{op:"C",cx1:.39541,cy1:5.49003,cx2:-.05459,cy2:5.16003,x:.00541,y:4.71004},{op:"C",cx1:.03541,cy1:4.59004,cx2:.30541,cy2:4.20004,x:1.50541,y:2.34004},{op:"C",cx1:2.88541,cy1:.27004,cx2:3.00541,cy2:.12004,x:3.12541,y:.06004},{op:"Z"}],style:{fill:"#000"}}],emitPlayback:r=>r.affectFollowing(re({body:[0,1,0]}))};var Le={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=[...Le.shapes];for(let e=0;e<r[1].length;e++)t.push({...Dc,dx:14.11212+e*5.95219});return{...Le,name:r[0],anchor:Bc,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(re({body:[0,1],repeat:!0}))},Fi=ne(Le.shapes),Bc=Fi.x+Fi.w/2,Dc={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"}};var cn=new Map,$i=[];for(let r of[Le,Oi,Di,Bi,Ni,...Ii,vi,Ri,Mi,Pi]){let t=r.name.toLowerCase();if(cn.has(t))throw new Error(`Duplicate symbol name: ${r.name}`);cn.set(t,r);let e=r.pattern;if(!e)continue;let{regex:n}=e;if(n.global||n.sticky)throw new Error(`Symbol pattern must not use g or y flags: ${t}`);$i.push(n.ignoreCase?e:{...e,regex:new RegExp(n.source,`${n.flags}i`)})}var Do=class extends L{static def={name:["symbol","$"],description:"\u521B\u5EFA\u4E00\u4E2A\u4E50\u8C31\u7B26\u53F7",details:`~~~jpfun
|
|
68
81
|
1 ^ @symbol(p, size=0.5em)
|
|
69
82
|
~~~
|
|
70
|
-
**\u7B80\u5199**\uFF1A\`$name\`\uFF0C\u5982 \`1 ^ $p
|
|
83
|
+
**\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
|
|
71
84
|
|
|
72
85
|
**\u5185\u7F6E\u8BB0\u53F7**
|
|
73
|
-
${[...
|
|
74
|
-
`)}`,allowExtraArgs:!1,args:[{name:"name",description:"\u5185\u7F6E\u8BB0\u53F7\u540D\u79F0\uFF0C\u89C1\u51FD\u6570\u8BF4\u660E\u4E2D\u7684\u8BB0\u53F7\u5217\u8868",type:"string",default:null},{name:"size",description:"\u8BB0\u53F7\u5C3A\u5BF8",type:"length",default:{value:.5,unit:"em"}}]};static deSugarAtom(t,e,n){if(t[e]!=="$"||!/[A-Za-z]/.test(t[e+1]??""))return null;let o=e+2;for(;o<n&&/[A-Za-z0-9_-]/.test(t[o]);)o++;let s=t.slice(e+1,o);return{next:o,node:{kind:"call",typed:!0,name:"symbol",args:new Map([[0,s]]),span:{start:e,end:o},syntaxKind:"atom"}}}size;definition;constructor(t,e,n,o=null){super(t,o);let[s,r]=this.getArgValue(e,n);this.size=n.length2px(r);let c=ii.get(s.toLowerCase());if(!c){let a=`@symbol: \u672A\u77E5\u7B26\u53F7: $${s}`;if(n.variables.strict)throw new S("E_UNKNOWN_SYMBOL",a,t);n.diagnostics.push(new O("W_UNKNOWN_SYMBOL",a,t));return}this.definition=c}loweringEnter(){return[this.definition?new lo(this):new W]}toString(t){return this.definition?`@symbol(${this.definition.name})`:super.toString(t)}},ri=ao,lo=class extends W{bounds;height;label;scale=1;baseline=0;constructor(t){super(),this.ast=t,this.mergeKey=ht,this.onTimeState=t.definition.onTimeState,this.emitPlayback=t.definition.emitPlayback,this.playbackMarks=t.definition.playbackMarks,this.bounds=Us(t.definition.shapes??[]),this.height=t.size*(t.definition.weight??1);let e=t.definition.text;this.label=e&&{content:e.content,style:{fontSize:this.height,fontFamily:e.fontFamily}},this.initLayoutBox()}prepareLayout(t){if(this.label){let e=t.textMeasurer.measureText(this.label.content,this.label.style);this.box.w=e.w,this.box.h=e.h,this.baseline=e.baseline}else this.scale=this.height/this.bounds.h,this.box.w=this.bounds.w*this.scale,this.box.h=this.height+(this.ast.definition.paddingBottom??0)*this.scale;this.box.anchor=this.box.w/2,this.box.visualAxis=this.box.h/2}paint(t){this.label?t.drawText(this.label.content,this.box.x,this.box.y+this.baseline,this.label.style):js(t,this.ast.definition.shapes??[],this.bounds,this.box,this.scale)}playbackFlow(t){let e=this.ast.definition.onVisit;if(!e)return;let n=t(this);return n===void 0?void 0:{range:[n,n],run:o=>e(o,n)}}};var ho=class i extends v{static def={name:["set"],description:"\u8BBE\u7F6E\u5C40\u90E8\u9ED8\u8BA4\u503C",details:"~~~jpfun\n@set(fontsize=20, strict=true)\n{ @set(note.octave=5, note.color=#f00) C D E }\n~~~\n\u63A5\u53D7\u547D\u540D\u53C2\u6570\uFF0C\u53EF\u4E00\u6B21\u8BBE\u7F6E\u591A\u9879\uFF1A\n- **\u7CFB\u7EDF\u9009\u9879**\uFF1A\u5982 `fontsize=20` \u5C06\u5B57\u53F7\u8BBE\u4E3A 20px\uFF0C`strict=true` \u5F00\u542F\u4E25\u683C\u6A21\u5F0F\n- **\u51FD\u6570\u9ED8\u8BA4\u53C2\u6570**\uFF1A\u6309 `\u51FD\u6570\u4E3B\u540D.\u53C2\u6570\u540D=\u503C` \u4E66\u5199\uFF0C\u4F8B\u5982 `note.octave=5`\u3001`note.color=#f00`\uFF1B\u663E\u5F0F\u4F20\u53C2\u4F18\u5148\n\n\u8BBE\u7F6E\u4ECE\u5F53\u524D\u4F4D\u7F6E\u8D77\u751F\u6548\uFF0C\u9650\u4E8E\u5F53\u524D\u4F5C\u7528\u57DF\u53CA\u5176\u5B50\u4F5C\u7528\u57DF\uFF1B\u79BB\u5F00\u5185\u5BB9\u5757\u540E\u6062\u590D\u5916\u5C42\u8BBE\u7F6E\u3002\u5B83\u6309\u6E90\u7801\u4F5C\u7528\u57DF\u89E3\u6790\uFF0C\u4E0E\u6F14\u594F\u65F6\u95F4\u65E0\u5173\u3002",allowExtraArgs:!0,args:[]};static resolveTarget(t,e,n){let o=e.lastIndexOf(".");if(o<0)return[e,Object.hasOwn(ct.systemVariables,e)?ct.systemVariables[e].type:"string"];let s=e.slice(o+1),r=t.functions.get(e.slice(0,o))?.prototype.def,c=r&&$t(r,s,-1);return!r||!c?(t.diagnostics.push(new O("W_SET_UNKNOWN_TARGET",`@set \u7684\u53C2\u6570 [${e}] \u6CA1\u6709\u5BF9\u5E94\u7684\u51FD\u6570\u6216\u5176\u53C2\u6570\uFF0C\u5C06\u88AB\u5FFD\u7565`,n)),null):c==="content"||c==="label"?(t.diagnostics.push(new O("W_SET_INVALID_VALUE_TYPE",`@set \u7684\u53C2\u6570 [${e}] \u5185\u5BB9\u548C\u6807\u7B7E\u4E0D\u80FD\u4F5C\u4E3A\u9ED8\u8BA4\u503C\uFF0C\u5C06\u88AB\u5FFD\u7565`,n)),null):[`${ne(r)}.${s}`.toLowerCase(),c]}args=new Map;constructor(t,e,n,o=null){super(t,o);for(let[s,r]of e){let c=r;if(typeof s!="string"){n.diagnostics.push(new O("W_SET_POSITIONAL_ARG",`\u51FD\u6570 @set \u4E0D\u63A5\u6536\u4F4D\u7F6E\u53C2\u6570, \u4F4D\u7F6E\u53C2\u6570[${s}]\u5C06\u88AB\u5FFD\u7565`,c.span));continue}let a=i.resolveTarget(n,s.toLowerCase(),c.nameSpan??c.span);if(a===null)continue;let[l,h]=a,p=n.parseArgWithType(c.valueSpan,h,t.start);if(p===null){n.diagnostics.push(new O("W_SET_INVALID_VALUE",`\u51FD\u6570 @set \u7684\u53C2\u6570\u503C\u89E3\u6790\u5931\u8D25, \u53C2\u6570[${s}]\u5C06\u88AB\u5FFD\u7565`,c.valueSpan));continue}n.setVariable(l,p),this.args.set(l,p)}}toString(){return`@set(${Array.from(this.args,([t,e])=>{let n=typeof e=="string"?rt(e):e&&typeof e=="object"&&"unit"in e?`${e.value}${e.unit}`:e;return`${t}=${n}`}).join(", ")})`}},ci=ho;var po=class extends v{static def={name:["volta"],description:"\u53CD\u590D\u7684\u8DF3\u623F\u5B50",details:"~~~jpfun\n|: 1 2 | 3@a 4@b :| 5@c 6@d | 7\n@volta(a, b, 1) @volta(c, d, 2)\n~~~\n- **\u989D\u5916\u4F4D\u7F6E\u53C2\u6570**\uFF1A\u66F4\u591A\u904D\u6570\uFF1B\u4F8B\u5982 `@volta(a, b, 1, 2)` \u8BA9\u524D\u4E24\u904D\u5171\u7528\u4E00\u4E2A\u623F\u5B50\u3002\u904D\u6570\u987A\u5E8F\u4E0D\u9650\uFF0C\u8C31\u9762\u6309\u5347\u5E8F\u663E\u793A\u3002\n\n\u672C\u4F8B\u7B2C\u4E00\u904D\u6F14\u594F `a` \u5230 `b`\uFF0C\u7B2C\u4E8C\u904D\u6F14\u594F `c` \u5230 `d`\u3002",allowExtraArgs:!0,extraArgType:"number",args:[{name:"from",description:"\u533A\u95F4\u8D77\u70B9\u7684\u6807\u7B7E\uFF0C\u533A\u95F4\u5141\u8BB8\u8DE8\u8C31\u9762\u884C",type:"label",default:null},{name:"to",description:"\u533A\u95F4\u7EC8\u70B9\u7684\u6807\u7B7E",type:"label",default:null},{name:"pass",description:"\u8FDB\u5165\u6B64\u533A\u95F4\u7684\u6F14\u594F\u904D\u6570\uFF0C\u987B\u4E3A\u6B63\u6574\u6570",type:"number",default:null}]};from;to;passes;size;font;loweringEnter(t){let e=t.getTemporalNodes(this.from).at(0),n=t.getTemporalNodes(this.to).at(-1);for(;e?.foldedInto;)e=e.foldedInto;for(;n?.foldedInto;)n=n.foldedInto;return!e||!n?(t.diagnostics.push(N.warning.UnresolvedEndpoint("volta",this.sourceSpan)),[]):(t.addAttachment(new fo(this,e,n)),[])}constructor(t,e,n,o=null){super(t,o);let[s,r,c]=this.getArgValue(e,n);this.font=n.variables.numberfont;let a=new Set([c]);for(let l=3;e.has(l);l++)a.add(e.get(l));if(this.from=s,this.to=r,this.passes=[...a].sort((l,h)=>l-h),this.size=n.variables.fontsize,this.passes.some(l=>!Number.isSafeInteger(l)||l<=0))throw new S("E_VOLTA_INVALID_PASS","@volta \u7684\u904D\u6570\u5FC5\u987B\u662F\u6B63\u6574\u6570",t)}toString(t){let e=n=>n.label??n.toString(t);return`@volta(${e(this.from)}, ${e(this.to)}, ${this.passes.join(", ")})`}},li=po;function ai(i){if(i?.[0]?.mergeKey===U)return i[0]}var fo=class{ast;from;to;layer="foreground";constructor(t,e,n){this.ast=t,this.from=e,this.to=n}get sourceSpan(){return this.ast.sourceSpan}get endPoints(){return[this.from,this.to]}playbackFlow(t){let e=t(this.from),n=t(this.to);if(e===void 0||n===void 0)return;let o=Math.min(e,n),s=Math.max(e,n);return{range:[o,s],run:r=>this.ast.passes.includes(Xo(r,o))?void 0:{kind:"jump",column:s+1}}}createGeometry(t){if(!F(this.from)||!F(this.to))return{regions:[],paint(){}};let e=A=>{let k=t.lines[A.layoutLine];return{line:A.layoutLine,view:k,column:k.columnOf(A)}},[n,o]=[e(this.from),e(this.to)];if((n.line>o.line||n.line===o.line&&n.column>o.column)&&([n,o]=[o,n]),n.column<0||o.column<0)return{regions:[],paint(){}};let s=n.view.columns[n.column][0],r=o.view.columns[o.column][0],c=ai(n.view.columns[n.column-1]),a=ai(o.view.columns[o.column+1]),l=0;for(let A=n.line;A<=o.line;A++)for(let k of t.getRangeColumns(A,[s,r]))l=Math.max(l,k[0].ast.size);let h=s.layoutLine,p=r.layoutLine,f=l||this.ast.size,d={fontSize:f*.6,fontFamily:this.ast.font,textAlign:"left",fill:"#000"},u=this.ast.passes.map(A=>`${A}.`).join(""),g=t.textMeasurer.measureText(u,d),y=Math.max(1,f*.055),x=y/2,m=g.h*1.2,b=(m-g.h)/2+g.baseline,w=Array.from({length:p-h+1},(A,k)=>{let M=h+k,T=s.track,E=1/0,C=M!==h&&M!==p?t.getRangeExtents(M):t.getRangeExtents(M,[s,r]);for(let[Y,D]of C){let $=t.getVisualAxis(M,Y)+D.top;$<E&&(T=Y,E=$)}E===1/0&&(E=t.getVisualAxis(M,T));let _=M!==h?this.lineEntryX(t,M,T):c?.layoutLine===M?c.box.x+c.box.anchor+5:s.box.x+(s.ports["body.left"]?.x??0),P=M!==p?this.lineRightX(t,M):a?.layoutLine===M?a.box.x+a.box.anchor:r.box.x+(r.ports["body.right"]?.x??r.box.w),j=Math.min(_,P),X=Math.max(_,P);return{left:j,right:X,lineY:E-f*.2-m,line:M,track:T}});return{regions:w.map(({left:A,right:k,lineY:M,line:T,track:E})=>({x:A-x,y:M-x,w:k-A+y,h:m+y,line:T,track:E})),paint(A){let k={stroke:"#000",strokeWidth:y};for(let{left:M,right:T,lineY:E,line:C}of w)A.drawLine(M,E,T,E,k),C===h&&(A.drawLine(M,E,M,E+m,k),A.drawText(u,M+f*.15,E+b+2,d)),C===p&&A.drawLine(T,E,T,E+m,k)}}}lineEntryX(t,e,n){return t.lines[e].trackRuns.get(n)?.find(s=>!s.T.isZero())?.box.x??t.originX}lineRightX(t,e){let n=t.lines[e].trackRuns;if(n.size===0)return t.originX+t.width;let o=t.originX;for(let s of n.values())for(let r of s)o=Math.max(o,r.box.x+r.box.w);return o}};var hi=4/3,Qr=.09,uo=class extends v{static def={name:["tie"],description:"\u8FDE\u97F3\u7EBF",details:`~~~jpfun
|
|
75
|
-
1@a 2 3@b @tie(a, b, height=0.5em)
|
|
76
|
-
~~~
|
|
77
|
-
- **\u4F4D\u7F6E\u53C2\u6570**\uFF1A\u7AEF\u70B9\u6807\u7B7E\uFF0C\u53EF\u4F20\u591A\u4E2A\uFF0C\u6309\u987A\u5E8F\u8FDE\u63A5\uFF1B\u7701\u7565\u65F6\u67E5\u627E\u6700\u8FD1\u7684\u53EF\u6807\u8BB0\u5BF9\u8C61\uFF0C\u5305\u62EC\u589E\u65F6\u7EBF
|
|
78
|
-
- **height**\uFF1A\u5F27\u7EBF\u9AD8\u5EA6\uFF0C\u9ED8\u8BA4 \`0.5em\`
|
|
79
|
-
|
|
80
|
-
\u540C\u884C\u7AEF\u70B9\u7528\u4E00\u6761\u5F27\u7EBF\u8FDE\u63A5\uFF0C\u8DE8\u884C\u65F6\u81EA\u52A8\u62C6\u6210\u591A\u6BB5\u3002\u540C\u8F68\u540C\u97F3\u4E14\u65F6\u95F4\u8FDE\u7EED\u7684\u97F3\u6BB5\u5EFA\u7ACB\u64AD\u653E\u8FDE\u63A5\uFF0C\u5404\u6BB5\u4FDD\u7559\u81EA\u5DF1\u7684\u88C5\u9970\uFF0C\u4F8B\u5982 \`1 ^ $tr 1 @tie()\` \u7684\u540E\u4E00\u97F3\u6BB5\u4E0D\u7EE7\u627F\u98A4\u97F3\u3002\u6D89\u53CA\u589E\u65F6\u7EBF\u7684\u8FDE\u63A5\u4EC5\u7ED8\u5236\uFF0C\u4E0D\u5408\u5E76\u64AD\u653E\u97F3\u7B26\u3002`,allowExtraArgs:!0,extraArgType:"label",args:[]};endPoints=[];height;constructor(t,e,n,o=null){super(t,o);let s=n.variables.fontsize*.5;for(let[c,a]of e){if(c==="height"){let h=n.parseArgWithType(a.valueSpan,"length",t.start);h&&(s=Math.max(0,n.length2px(h)));continue}let l=a instanceof v?a:n.parseArgWithType(a.valueSpan,"label",t.start);l!==null&&this.endPoints.push(l)}let r=n.labelableNodes.length-1;for(;this.endPoints.length<2&&r>=0;){let c=n.labelableNodes[r--];!c||this.endPoints.includes(c)||this.endPoints.unshift(c)}if(this.endPoints.length<2)throw new S("E_NOT_ENOUGH_ARGS","@tie \u8FDE\u97F3\u7EBF\u9700\u8981\u81F3\u5C11\u4E24\u4E2A\u7AEF\u70B9",t);this.height=s}loweringEnter(t){let e=[];for(let n of this.endPoints){let o=t.getTemporalNodes(n).at(-1);!o||!F(o)||e.push(o)}return e.length<2?(t.diagnostics.push(N.warning.UnresolvedEndpoint("tie",this.sourceSpan)),[]):(t.addAttachment(new xo(e,this.height,this.sourceSpan)),[])}toString(t){let e=this.endPoints.map(n=>n.label);return e.some(n=>n===void 0)?t.slice(this.sourceSpan.start,this.sourceSpan.end):`@tie(${e.join(", ")}, height=${this.height}px)`}},pi=uo,xo=class{layer="foreground";sourceSpan;endPoints;height;thickness;constructor(t,e,n){this.endPoints=t,this.height=e,this.sourceSpan=n;let o=t.reduce((s,r)=>Math.max(s,r.ast.size),0);this.thickness=Math.max(1.2,o*Qr)}applyPlayback(t){for(let e of t.notes.filter(n=>n.origins.some(o=>o.node===this.endPoints[0]))){let n=e;for(let o=1;o<this.endPoints.length;o++){let s=t.notes.find(r=>r!==n&&r.origins.some(c=>c.node===this.endPoints[o])&&r.track===n.track&&r.midi===n.midi&&r.percussion===n.percussion&&n.end.equals(r.start)&&t.connect(n,r));if(!s)break;n=s}}}createGeometry(t){let e=this.createSegments(t),n=e.map(({commands:s,...r})=>r),o=e.map(s=>{let r=t.getHostExtent(s.line,s.track),c=r?Math.max(s.y,t.getVisualAxis(s.line,s.track)+r.top):s.y+s.h;return{x:s.x,y:s.y,w:s.w,h:c-s.y,line:s.line,track:s.track}});return{regions:n,occupancy:o,paint(s){for(let r of e)s.drawPath(r.commands,{fill:"#000"})}}}tiePort(t){let e=t.ports["tie.top"];return e?{x:t.box.x+e.x,y:t.box.y+e.y}:{x:t.box.x+t.box.anchor,y:t.box.y}}createSegments(t){let e=[];for(let n=1;n<this.endPoints.length;n++){let o=this.endPoints[n-1],s=this.endPoints[n];o.layoutLine>s.layoutLine&&([o,s]=[s,o]);let r=this.tiePort(o),c=this.tiePort(s);if(o.layoutLine===s.layoutLine){let a=t.getVisualAxis(o.layoutLine,o.track)+(t.getHostExtent(o.layoutLine,o.track)?.top??0),l=t.getVisualAxis(s.layoutLine,s.track)+(t.getHostExtent(s.layoutLine,s.track)?.top??0);e.push(this.arcSegment(r,c,o.layoutLine,a<=l?o.track:s.track));continue}e.push(this.openingSegment(r,this.lineRightX(t,o.layoutLine),this.plateauY(t,o.layoutLine,o.track,r.y),o.layoutLine,o.track));for(let a=o.layoutLine+1;a<s.layoutLine;a++)e.push(this.horizontalSegment(this.lineEntryX(t,a,o.track),this.lineRightX(t,a),this.plateauY(t,a,o.track),a,o.track));e.push(this.closingSegment(this.lineEntryX(t,s.layoutLine,s.track),c,this.plateauY(t,s.layoutLine,s.track,c.y),s.layoutLine,s.track))}return e}lineEntryX(t,e,n){return t.lines[e].trackRuns.get(n)?.find(r=>!r.T.isZero())?.box.x??t.originX}lineRightX(t,e){let n=t.lines[e].trackRuns;if(n.size===0)return t.originX+t.width;let o=t.originX;for(let s of n.values())for(let r of s)o=Math.max(o,r.box.x+r.box.w);return o}plateauY(t,e,n,o=1/0){if(Number.isFinite(o))return o-this.height;let s=t.getVisualAxis(e,n),r=t.getHostExtent(e,n)?.top??0;return s+r-this.height}arcSegment(t,e,n,o){let s=t,r=e;s.x>r.x&&([s,r]=[r,s]);let c=(r.x-s.x)*.25,a=s.x+c,l=r.x-c,h=this.height*hi,p=Math.max(0,h-this.thickness*hi),f=[{op:"M",x:s.x,y:s.y},{op:"C",cx1:a,cy1:s.y-h,cx2:l,cy2:r.y-h,x:r.x,y:r.y},{op:"C",cx1:l,cy1:r.y-p,cx2:a,cy2:s.y-p,x:s.x,y:s.y},{op:"Z"}];return Ue(f,n,o)}openingSegment(t,e,n,o,s){let r=this.height*1.2;e=Math.max(e,t.x+r);let c=t.x+r,a=t.x+r*.45,l=n+this.thickness;return Ue([{op:"M",x:t.x,y:t.y},{op:"Q",cx:a,cy:n,x:c,y:n},{op:"L",x:e,y:n},{op:"L",x:e,y:l},{op:"L",x:c,y:l},{op:"Q",cx:a,cy:l,x:t.x,y:t.y},{op:"Z"}],o,s)}closingSegment(t,e,n,o,s){let r=this.height*1.2;t=Math.min(t,e.x-r);let c=e.x-r,a=e.x-r*.45,l=n+this.thickness;return Ue([{op:"M",x:t,y:n},{op:"L",x:c,y:n},{op:"Q",cx:a,cy:n,x:e.x,y:e.y},{op:"Q",cx:a,cy:l,x:c,y:l},{op:"L",x:t,y:l},{op:"Z"}],o,s)}horizontalSegment(t,e,n,o,s){return Ue([{op:"M",x:t,y:n},{op:"L",x:e,y:n},{op:"L",x:e,y:n+this.thickness},{op:"L",x:t,y:n+this.thickness},{op:"Z"}],o,s)}};function Ue(i,t,e){return{commands:i,line:t,track:e,...Vt(i)}}var mo=class extends v{static def={name:["tuplet"],description:"\u591A\u8FDE\u97F3",details:`~~~jpfun
|
|
86
|
+
${[...cn.values()].map(t=>`- \`$${t.name}\`\uFF1A${t.description}`).join(`
|
|
87
|
+
`)}`,allowExtraArgs:!1,args:[{name:"name",description:"\u5185\u7F6E\u8BB0\u53F7\u540D\u79F0\uFF0C\u89C1\u51FD\u6570\u8BF4\u660E\u4E2D\u7684\u8BB0\u53F7\u5217\u8868",type:"string",default:null},{name:"size",description:"\u8BB0\u53F7\u5C3A\u5BF8",type:"length",default:{value:.5,unit:"em"}}]};static deSugarAtom(t,e,n){if(t[e]!=="$")return null;let o=/^\S+/.exec(t.slice(e+1,n))?.[0];if(!o)return null;let s=e+1+o.length;return{next:s,node:{kind:"call",typed:!0,name:"symbol",args:new Map([[0,o]]),span:{start:e,end:s},syntaxKind:"atom"}}}size;definition;constructor(t,e,n,o=null){super(t,o);let[s,i]=this.getArgValue(e,n);this.size=n.length2px(i);let c=s.toLowerCase(),a=cn.get(c);if(!a){let l;for(let h of $i){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: $${s}`;if(n.variables.strict)throw new w("E_UNKNOWN_SYMBOL",l,t);n.diagnostics.push(new P("W_UNKNOWN_SYMBOL",l,t));return}this.definition=a}loweringEnter(){return[this.definition?new Fo(this):new $]}toString(t){return this.definition?`@symbol(${this.definition.name})`:super.toString(t)}},zi=Do,Fo=class extends ${bounds;height;label;scale=1;baseline=0;constructor(t){super(),this.ast=t,this.mergeKey=dt,this.onTimeState=t.definition.onTimeState,this.emitPlayback=t.definition.emitPlayback,this.playbackMarks=t.definition.playbackMarks,this.bounds=ne(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):je(t,this.ast.definition.shapes??[],this.bounds,this.box,this.scale)}playbackFlow(t){let e=this.ast.definition.onVisit;if(!e)return;let n=t(this);return n===void 0?void 0:{range:[n,n],run:o=>e(o,n)}}};var $o=class r extends L{static def={name:["set"],description:"\u8BBE\u7F6E\u5C40\u90E8\u9ED8\u8BA4\u503C",details:"~~~jpfun\n@set(fontsize=20, strict=true)\n{ @set(note.octave=5, note.color=#f00) C D E }\n~~~\n\u63A5\u53D7\u547D\u540D\u53C2\u6570\uFF0C\u53EF\u4E00\u6B21\u8BBE\u7F6E\u591A\u9879\uFF1A\n- **\u7CFB\u7EDF\u9009\u9879**\uFF1A\u5982 `fontsize=20` \u5C06\u5B57\u53F7\u8BBE\u4E3A 20px\uFF0C`strict=true` \u5F00\u542F\u4E25\u683C\u6A21\u5F0F\n- **\u51FD\u6570\u9ED8\u8BA4\u53C2\u6570**\uFF1A\u6309 `\u51FD\u6570\u4E3B\u540D.\u53C2\u6570\u540D=\u503C` \u4E66\u5199\uFF0C\u4F8B\u5982 `note.octave=5`\u3001`note.color=#f00`\uFF1B\u663E\u5F0F\u4F20\u53C2\u4F18\u5148\n\n\u8BBE\u7F6E\u4ECE\u5F53\u524D\u4F4D\u7F6E\u8D77\u751F\u6548\uFF0C\u9650\u4E8E\u5F53\u524D\u4F5C\u7528\u57DF\u53CA\u5176\u5B50\u4F5C\u7528\u57DF\uFF1B\u79BB\u5F00\u5185\u5BB9\u5757\u540E\u6062\u590D\u5916\u5C42\u8BBE\u7F6E\u3002\u5B83\u6309\u6E90\u7801\u4F5C\u7528\u57DF\u89E3\u6790\uFF0C\u4E0E\u6F14\u594F\u65F6\u95F4\u65E0\u5173\u3002",allowExtraArgs:!0,args:[]};static resolveTarget(t,e,n){let o=e.lastIndexOf(".");if(o<0)return[e,Object.hasOwn(pt.systemVariables,e)?pt.systemVariables[e].type:"string"];let s=e.slice(o+1),i=t.functions.get(e.slice(0,o))?.prototype.def,c=i&&Yt(i,s,-1);return!i||!c?(t.diagnostics.push(new P("W_SET_UNKNOWN_TARGET",`@set \u7684\u53C2\u6570 [${e}] \u6CA1\u6709\u5BF9\u5E94\u7684\u51FD\u6570\u6216\u5176\u53C2\u6570\uFF0C\u5C06\u88AB\u5FFD\u7565`,n)),null):c==="content"||c==="label"?(t.diagnostics.push(new P("W_SET_INVALID_VALUE_TYPE",`@set \u7684\u53C2\u6570 [${e}] \u5185\u5BB9\u548C\u6807\u7B7E\u4E0D\u80FD\u4F5C\u4E3A\u9ED8\u8BA4\u503C\uFF0C\u5C06\u88AB\u5FFD\u7565`,n)),null):[`${pe(i)}.${s}`.toLowerCase(),c]}args=new Map;constructor(t,e,n,o=null){super(t,o);for(let[s,i]of e){let c=i;if(typeof s!="string"){n.diagnostics.push(new P("W_SET_POSITIONAL_ARG",`\u51FD\u6570 @set \u4E0D\u63A5\u6536\u4F4D\u7F6E\u53C2\u6570, \u4F4D\u7F6E\u53C2\u6570[${s}]\u5C06\u88AB\u5FFD\u7565`,c.span));continue}let a=r.resolveTarget(n,s.toLowerCase(),c.nameSpan??c.span);if(a===null)continue;let[l,h]=a,p=n.parseArgWithType(c.valueSpan,h,t.start);if(p===null){n.diagnostics.push(new P("W_SET_INVALID_VALUE",`\u51FD\u6570 @set \u7684\u53C2\u6570\u503C\u89E3\u6790\u5931\u8D25, \u53C2\u6570[${s}]\u5C06\u88AB\u5FFD\u7565`,c.valueSpan));continue}n.setVariable(l,p),this.args.set(l,p)}}toString(){return`@set(${Array.from(this.args,([t,e])=>{let n=typeof e=="string"?ht(e):e&&typeof e=="object"&&"unit"in e?`${e.value}${e.unit}`:e;return`${t}=${n}`}).join(", ")})`}},Hi=$o;var zo=class extends L{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),n=t.getTemporalNodes(this.to).at(-1);for(;e?.foldedInto;)e=e.foldedInto;for(;n?.foldedInto;)n=n.foldedInto;return!e||!n?(t.diagnostics.push(M.warning.UnresolvedEndpoint("volta",this.sourceSpan)),[]):(t.addAttachment(new Ho(this,e,n)),[])}constructor(t,e,n,o=null){super(t,o);let[s,i,c]=this.getArgValue(e,n);this.font=n.variables.numberfont;let a=new Set([c]);for(let l=3;e.has(l);l++)a.add(e.get(l));if(this.from=s,this.to=i,this.passes=[...a].sort((l,h)=>l-h),this.size=n.variables.fontsize,this.passes.some(l=>!Number.isSafeInteger(l)||l<=0))throw new w("E_VOLTA_INVALID_PASS","@volta \u7684\u904D\u6570\u5FC5\u987B\u662F\u6B63\u6574\u6570",t)}toString(t){let e=n=>n.label??n.toString(t);return`@volta(${e(this.from)}, ${e(this.to)}, ${this.passes.join(", ")})`}},Gi=zo;function Wi(r){if(r?.[0]?.mergeKey===nt)return r[0]}var Ho=class{ast;from;to;layer="foreground";constructor(t,e,n){this.ast=t,this.from=e,this.to=n}get sourceSpan(){return this.ast.sourceSpan}get endPoints(){return[this.from,this.to]}playbackFlow(t){let e=t(this.from),n=t(this.to);if(e===void 0||n===void 0)return;let o=Math.min(e,n),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:[o,i],run:c=>this.ast.passes.includes(_s(c,o))?void 0:{kind:"jump",column:i+1}}}createGeometry(t){if(!I(this.from)||!I(this.to))return{regions:[],paint(){}};let e=N=>{let v=t.lines[N.layoutLine];return{line:N.layoutLine,view:v,column:v.columnOf(N)}},[n,o]=[e(this.from),e(this.to)];if((n.line>o.line||n.line===o.line&&n.column>o.column)&&([n,o]=[o,n]),n.column<0||o.column<0)return{regions:[],paint(){}};let s=n.view.columns[n.column][0],i=o.view.columns[o.column][0],c=Wi(n.view.columns[n.column-1]),a=Wi(o.view.columns[o.column+1]),l=s.layoutLine,h=i.layoutLine,p=this.ast.size,f={fontSize:p*.6,fontFamily:this.ast.font,textAlign:"left",fill:"#000"},d=this.ast.passes.map(N=>`${N}.`).join(""),u=t.textMeasurer.measureText(d,f),m=Math.max(1,p*.055),x=m/2,y=u.h*1.2,g=p*.15,b=(y-u.h)/2+u.baseline+2,S=Math.max(m,x+g+u.w),C=Math.max(y+x,b-u.baseline+u.h),E=p*.2,k=Array.from({length:h-l+1},(N,v)=>{let _=l+v,D=s.track,A=1/0,O=_!==l&&_!==h?t.getRangeExtents(_):t.getRangeExtents(_,[s,i]);for(let[z,Q]of O){let X=t.getVisualAxis(_,z)+Q.top;X<A&&(D=z,A=X)}A===1/0&&(A=t.getVisualAxis(_,D));let G=_!==l?this.lineEntryX(t,_,D):c?.layoutLine===_?c.box.x+c.box.anchor+5:s.box.x+(s.ports["body.left"]?.x??0),Z=_!==h?this.lineRightX(t,_):a?.layoutLine===_?a.box.x+a.box.anchor:i.box.x+(i.ports["body.right"]?.x??i.box.w),q=Math.min(G,Z),J=Math.max(G,Z),F=(z,Q,X)=>({x:z,y:-x,w:Q,h:X+x,line:_,track:D}),U=[F(q-x,J-q+m,x)];_===l&&U.push(F(q-x,S,C)),_===h&&U.push(F(J-x,m,y+x));let Y=1/0;for(let z of U)for(let[Q,X]of t.getHorizontalExtents(_,z.x,z.x+z.w))Y=Math.min(Y,t.getVisualAxis(_,Q)+X.top-E-(z.y+z.h));Y===1/0&&(Y=A-E-x);for(let z of U)z.y+=Y;return{left:q,right:J,lineY:Y,line:_,parts:U}});return{regions:k.map(({parts:N})=>({...N[0],w:Math.max(...N.map(v=>v.x+v.w))-N[0].x,h:Math.max(...N.map(v=>v.h))})),occupancy:k.flatMap(N=>N.parts),paint(N){let v={stroke:"#000",strokeWidth:m};for(let{left:_,right:D,lineY:A,line:O}of k)N.drawLine(_,A,D,A,v),O===l&&(N.drawLine(_,A,_,A+y,v),N.drawText(d,_+g,A+b,f)),O===h&&N.drawLine(D,A,D,A+y,v)}}}lineEntryX(t,e,n){return t.lines[e].trackRuns.get(n)?.find(s=>!s.T.isZero())?.box.x??t.originX}lineRightX(t,e){let n=t.lines[e].trackRuns;if(n.size===0)return t.originX+t.width;let o=t.originX;for(let s of n.values())for(let i of s)o=Math.max(o,i.box.x+i.box.w);return o}};var Vi=4/3,Fc=.09,$c=2.5,zc=.5,Hc=.45,Wo=class extends L{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\uFF0C\u5404\u6BB5\u4FDD\u7559\u81EA\u5DF1\u7684\u88C5\u9970\uFF0C\u4F8B\u5982 `1 ^ $tr 1 @tie()` \u7684\u540E\u4E00\u97F3\u6BB5\u4E0D\u7EE7\u627F\u98A4\u97F3\u3002\u6D89\u53CA\u589E\u65F6\u7EBF\u7684\u8FDE\u63A5\u4EC5\u7ED8\u5236\uFF0C\u4E0D\u5408\u5E76\u64AD\u653E\u97F3\u7B26\u3002",allowExtraArgs:!0,extraArgType:"label",args:[{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,n,o=null){super(t,o);let[s]=this.getArgValue(e,n);for(let[c,a]of e){if(c==="height")continue;let l=a instanceof L?a:n.parseArgWithType(a.valueSpan,"label",t.start);l!==null&&this.endPoints.push(l)}let i=n.labelableNodes.length-1;for(;this.endPoints.length<2&&i>=0;){let c=n.labelableNodes[i--];!c||this.endPoints.includes(c)||this.endPoints.unshift(c)}if(this.endPoints.length<2)throw new w("E_NOT_ENOUGH_ARGS","@tie \u8FDE\u97F3\u7EBF\u9700\u8981\u81F3\u5C11\u4E24\u4E2A\u7AEF\u70B9",t);this.height=Math.max(0,n.length2px(s)),this.fontSize=n.variables.fontsize}loweringEnter(t){let e=[];for(let n of this.endPoints){let o=t.getTemporalNodes(n).at(-1);!o||!I(o)||e.push(o)}return e.length<2?(t.diagnostics.push(M.warning.UnresolvedEndpoint("tie",this.sourceSpan)),[]):(t.addAttachment(new Go(e,this.height,this.fontSize,this.sourceSpan)),[])}toString(t){let e=this.endPoints.map(n=>n.label);return e.some(n=>n===void 0)?t.slice(this.sourceSpan.start,this.sourceSpan.end):`@tie(${e.join(", ")}, height=${this.height}px)`}},Yi=Wo,Go=class{layer="foreground";sourceSpan;endPoints;height;fontSize;thickness;constructor(t,e,n,o){this.endPoints=t,this.height=e,this.fontSize=n,this.sourceSpan=o;let s=t.reduce((i,c)=>Math.max(i,c.ast.size),0);this.thickness=Math.max(1.2,s*Fc)}applyPlayback(t){for(let e of t.notes.filter(n=>n.origins.some(o=>o.node===this.endPoints[0]))){let n=e;for(let o=1;o<this.endPoints.length;o++){let s=t.notes.find(i=>i!==n&&i.origins.some(c=>c.node===this.endPoints[o])&&i.track===n.track&&i.midi===n.midi&&i.percussion===n.percussion&&n.end.equals(i.start)&&t.connect(n,i));if(!s)break;n=s}}}createGeometry(t){let e=this.createSegments(t),n=e.map(({commands:s,...i})=>i),o=e.map(s=>{let i=t.getHostExtent(s.line,s.track),c=i?Math.max(s.y,t.getVisualAxis(s.line,s.track)+i.top):s.y+s.h;return{x:s.x,y:s.y,w:s.w,h:c-s.y,line:s.line,track:s.track}});return{regions:n,occupancy:o,paint(s){for(let i of e)s.drawPath(i.commands,{fill:"#000"})}}}tiePort(t){let e=t.ports["tie.top"];return e?{x:t.box.x+e.x,y:t.box.y+e.y}:{x:t.box.x+t.box.anchor,y:ot(t,!0).y}}createSegments(t){let e=[];for(let n=1;n<this.endPoints.length;n++){let o=this.endPoints[n-1],s=this.endPoints[n];o.layoutLine>s.layoutLine&&([o,s]=[s,o]);let i=this.tiePort(o),c=this.tiePort(s);if(o.layoutLine===s.layoutLine){let l=this.hostTop(t,o.layoutLine,o.track),h=this.hostTop(t,s.layoutLine,s.track);e.push(this.arcSegment(i,c,o.layoutLine,l<=h?o.track:s.track));continue}let a=this.height>0?this.height:this.fontSize*Hc;e.push(this.openingSegment(i,this.lineRightX(t,o.layoutLine),a,o.layoutLine,o.track));for(let l=o.layoutLine+1;l<s.layoutLine;l++)e.push(this.horizontalSegment(this.lineEntryX(t,l,o.track),this.lineRightX(t,l),this.hostTop(t,l,o.track)-a,l,o.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*$c));return this.fontSize*zc*e*(2-e)}lineEntryX(t,e,n){return t.lines[e].trackRuns.get(n)?.find(i=>!i.T.isZero())?.box.x??t.originX}lineRightX(t,e){let n=t.lines[e].trackRuns;if(n.size===0)return t.originX+t.width;let o=t.originX;for(let s of n.values())for(let i of s)o=Math.max(o,i.box.x+i.box.w);return o}hostTop(t,e,n){return t.getVisualAxis(e,n)+(t.getHostExtent(e,n)?.top??0)}arcSegment(t,e,n,o){let s=t,i=e;s.x>i.x&&([s,i]=[i,s]);let c=(i.x-s.x)*.25,a=s.x+c,l=i.x-c,h=this.resolveHeight(i.x-s.x)*Vi,p=Math.max(0,h-this.thickness*Vi),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 an(f,n,o)}openingSegment(t,e,n,o,s){let i=t.y-n,c=n*1.2;e=Math.max(e,t.x+c);let a=t.x+c,l=t.x+c*.45,h=i+this.thickness;return an([{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"}],o,s)}closingSegment(t,e,n,o,s){let i=e.y-n,c=n*1.2;t=Math.min(t,e.x-c);let a=e.x-c,l=e.x-c*.45,h=i+this.thickness;return an([{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"}],o,s)}horizontalSegment(t,e,n,o,s){return an([{op:"M",x:t,y:n},{op:"L",x:e,y:n},{op:"L",x:e,y:n+this.thickness},{op:"L",x:t,y:n+this.thickness},{op:"Z"}],o,s)}};function an(r,t,e){return{commands:r,line:t,track:e,...xt(r)}}var Vo=class extends L{static def={name:["tuplet"],description:"\u591A\u8FDE\u97F3",details:`~~~jpfun
|
|
81
88
|
@tuplet({1/ 2 3}, normal=4)
|
|
82
89
|
~~~
|
|
83
|
-
\u672C\u4F8B\u6700\u77ED\u5355\u4F4D\u4E3A\u516B\u5206\u97F3\u7B26\uFF0C\u539F\u5185\u5BB9\u5360 5 \u4E2A\u5355\u4F4D\uFF0C\u7F29\u653E\u540E\u5360 4 \u4E2A\u5355\u4F4D\uFF1A\u5F62\u6210\u4E94\u8FDE\u97F3\uFF0C\u603B\u65F6\u957F\u4E3A\u4E00\u4E2A\u4E8C\u5206\u97F3\u7B26`,allowExtraArgs:!1,args:[{type:"content",description:"\u8FDE\u97F3\u5185\u5BB9\uFF0C\u5404\u5143\u7D20\u6309\u540C\u4E00\u6BD4\u4F8B\u7F29\u653E\u65F6\u503C",default:null},{name:"normal",description:"\u76EE\u6807\u603B\u65F6\u957F\uFF0C\u4EE5\u5185\u5BB9\u4E2D\u7684\u6700\u77ED\u65F6\u503C\u4E3A\u5355\u4F4D",type:"number",default:null}]};static loweringFinalize=t=>{for(let e of t.attachments)e instanceof
|
|
90
|
+
\u672C\u4F8B\u6700\u77ED\u5355\u4F4D\u4E3A\u516B\u5206\u97F3\u7B26\uFF0C\u539F\u5185\u5BB9\u5360 5 \u4E2A\u5355\u4F4D\uFF0C\u7F29\u653E\u540E\u5360 4 \u4E2A\u5355\u4F4D\uFF1A\u5F62\u6210\u4E94\u8FDE\u97F3\uFF0C\u603B\u65F6\u957F\u4E3A\u4E00\u4E2A\u4E8C\u5206\u97F3\u7B26`,allowExtraArgs:!1,args:[{type:"content",description:"\u8FDE\u97F3\u5185\u5BB9\uFF0C\u5404\u5143\u7D20\u6309\u540C\u4E00\u6BD4\u4F8B\u7F29\u653E\u65F6\u503C",default:null},{name:"normal",description:"\u76EE\u6807\u603B\u65F6\u957F\uFF0C\u4EE5\u5185\u5BB9\u4E2D\u7684\u6700\u77ED\u65F6\u503C\u4E3A\u5355\u4F4D",type:"number",default:null}]};static loweringFinalize=t=>{for(let e of t.attachments)e instanceof ln&&e.validate()};content;normal;font;get children(){return[this.content]}timeFlowModel(){return{mode:"sequence",children:[this.content]}}loweringEnter(t){let e={nodes:[],attachments:[],onTemporal(n){e.nodes.push(n)},onAttachment(n){e.attachments.push(n)}};return t.beginLoweringGroup(this,e),[]}loweringExit(t,e,n){let o=t.endLoweringGroup(this),s=o.nodes.filter(u=>u.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(u=>u.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 B;for(let u of s)u.T.compare(c)<0&&c.copyFrom(u.T),a.add(u.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 (${h})`,this.sourceSpan);let p=o.nodes[0].t;for(let u=1;u<o.nodes.length;u++)o.nodes[u].t.compare(p)<0&&(p=o.nodes[u].t);p=p.clone();let f=new B;for(let u of o.nodes)f.copyFrom(u.t).sub(p).mul(this.normal,h),u.t.copyFrom(p).add(f),u.T.mul(this.normal,h);n.copyFrom(p).add(c.mul(this.normal));let d=s.filter(I);return d.length>=2&&t.addAttachment(new ln(d,h,this.sourceSpan,this.font,o)),[]}constructor(t,e,n,o=null){super(t,o);let[s,i]=this.getArgValue(e,n);if(this.font=n.variables.numberfont,!Number.isSafeInteger(i)||i<=0)throw new 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})`}},Ki=Vo,ln=class{content;layer="foreground";endPoints;actual;sourceSpan;style;size;constructor(t,e,n,o,s){this.content=s,this.endPoints=t,this.actual=e,this.sourceSpan=n,this.size=t.reduce((i,c)=>Math.max(i,c.ast.size),0),this.style={fontSize:this.size*.72,fontFamily:o,textAlign:"center",fill:"#000"}}validate(){let t=this.endPoints[0];if(this.endPoints.some(e=>e.layoutLine!==t.layoutLine))throw new 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],n=this.endPoints[this.endPoints.length-1],o=e.ports["body.left"]?.x??0,s=n.ports["body.right"]?.x??n.box.w,i=e.box.x+o,c=n.box.x+s;i>c&&([i,c]=[c,i]);let a=t.textMeasurer.measureText(String(this.actual),this.style),l=(i+c)/2,h=this.size*.12,p=this.size*.18,f=this.size*.14,d=t.getVisualAxis(e.layoutLine,e.track),u=t.getRangeExtents(e.layoutLine,[e,n],e.track),m=t.getContentBounds(this.content),x=Math.min(d+(u?.top??0),m?.y??1/0),y=Math.max(1,this.size*.055),g=x-f-Math.max(p,a.h/2),b=g+p,S=g-a.h/2+a.baseline,C=l-a.w/2-h,E=l+a.w/2+h,k=[];C>i&&k.push([i,g,C,g]),E<c&&k.push([E,g,c,g]),k.push([i,g,i,b],[c,g,c,b]);let N=y/2,v=Math.min(g-a.h/2,g-N),_=Math.max(g+a.h/2,b+N),D=[{x:i-N,y:v,w:c-i+y,h:_-v,line:e.layoutLine,track:e.track}],A=String(this.actual),O=this.style;return{regions:D,paint(G){let Z={stroke:"#000",strokeWidth:y};for(let[q,J,F,U]of k)G.drawLine(q,J,F,U,Z);G.drawText(A,l,S,O)}}}};var Yo=[{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"}],_e=xt(Yo),Ct=2.33,Nt=1.17,Ht=.34,Ko=[{op:"M",x:0,y:0},{op:"L",x:0,y:-Ht},{op:"C",cx1:Ct*.421,cy1:-Ht+Nt*.077,cx2:Ct*.733,cy2:-Ht+Nt*.346,x:Ct,y:-Ht+Nt},{op:"L",x:Ct*.929,y:-Ht+Nt},{op:"C",cx1:Ct*.696,cy1:-Ht+Nt*.535,cx2:Ct*.328,cy2:-Ht+Nt*.352,x:0,y:0},{op:"Z"}];function hn(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 Ui(r,t){let e=r.trim(),n=/\s*([\[{])\s*(?:(?:(\d+)\s*)?-\s*(?:(\d+)\s*)?|(\d+)\s*)([\]}])\s*/y,o=[];for(;n.lastIndex<e.length;){let s=n.exec(e);if(!s||s[5]!==(s[1]==="["?"]":"}"))throw hn(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 hn(t);if(a!==void 0&&l!==void 0&&a>l)throw hn(t);o.push({kind:s[1]==="["?"bracket":"brace",from:a,to:l})}return o}function ji(r,t,e){return r.map(({kind:n,from:o=1,to:s=t})=>{if(o>s||s>t)throw hn(e);return{kind:n,from:o,to:s}})}function Uo(r){return r.map(({kind:t,from:e,to:n})=>{let o=`${e??""}-${n??""}`;return t==="brace"?`{${o}}`:`[${o}]`}).join("")}var Wc=/\s/,Zi=2.5,qi=.3,Qi=new Set("\uFF08([\uFF3B\uFF5B\u3008\u300A\u300C\u300E\u3010\u3014\u3016\u3018\u301A\u2018\u201C"),jo=new Set([...Qi,...`\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 Xi(r){let t=0,e=r.length;for(;t<e&&jo.has(r[t]);)t++;for(;e>t&&jo.has(r[e-1]);)e--;return{prefix:r.slice(0,t),body:r.slice(t,e)}}function Gc(r){let t=r/2;return(e,n)=>{let o=e.map(a=>a&&a.bottom-a.top>1e-6?a:{top:-t,bottom:t}),s=[],i=0;for(let a=0;a<o.length;a++)a>0&&(i+=o[a-1].bottom+n-o[a].top),s.push(i);let c=(s[0]+s[s.length-1])/2;return s.map((a,l)=>({offset:a-c,extent:o[l]}))}}var Wt=class r extends L{static def={name:["voice","v"],description:"\u58F0\u90E8",details:`~~~jpfun
|
|
84
91
|
@voice({1 2 3}, \u94A2\u7434, \u7537=ha ha ha, \u5973=la la la)
|
|
85
92
|
~~~
|
|
86
93
|
- **\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
|
|
@@ -93,30 +100,16 @@ N(\u94A2\u7434): 1 2 3
|
|
|
93
100
|
L(\u7537): ha ha ha
|
|
94
101
|
L: la la la
|
|
95
102
|
~~~
|
|
96
|
-
\u884C\u9996\u5141\u8BB8\u7A7A\u767D\uFF0C\u6362\u884C\u7ED3\u675F\u5F53\u524D\u58F0\u660E\uFF1B\u5728\u884C\u672B\u52A0 \`\\\` \u53EF\u7EED\u884C\u3002\u8FD9\u79CD\u5199\u6CD5\u4E2D\u7684\u6B4C\u8BCD\u5141\u8BB8\u76F4\u63A5\u4F7F\u7528\u9017\u53F7\u3002`,allowExtraArgs:!0,extraArgType:"string",args:[{type:"content",description:"\u58F0\u90E8\u7684\u97F3\u7B26\u5185\u5BB9",default:null},{name:"name",description:"\u663E\u793A\u5728\u5DE6\u4FA7\u7684\u58F0\u90E8\u540D\u79F0\uFF0C\u7A7A\u503C\u9690\u85CF\u540D\u79F0",type:"string",default:""}]};static deSugarAtom(t,e,n){if(t[e]!=="N"&&t[e]!=="L")return null;let o=e+1,s="";if(t[o]==="("){let
|
|
97
|
-
`;)o++;
|
|
98
|
-
`&&n++,n}let
|
|
99
|
-
`){
|
|
100
|
-
`)break t;
|
|
103
|
+
\u884C\u9996\u5141\u8BB8\u7A7A\u767D\uFF0C\u6362\u884C\u7ED3\u675F\u5F53\u524D\u58F0\u660E\uFF1B\u5728\u884C\u672B\u52A0 \`\\\` \u53EF\u7EED\u884C\u3002\u8FD9\u79CD\u5199\u6CD5\u4E2D\u7684\u6B4C\u8BCD\u5141\u8BB8\u76F4\u63A5\u4F7F\u7528\u9017\u53F7\u3002`,allowExtraArgs:!0,extraArgType:"string",args:[{type:"content",description:"\u58F0\u90E8\u7684\u97F3\u7B26\u5185\u5BB9",default:null},{name:"name",description:"\u663E\u793A\u5728\u5DE6\u4FA7\u7684\u58F0\u90E8\u540D\u79F0\uFF0C\u7A7A\u503C\u9690\u85CF\u540D\u79F0",type:"string",default:""}]};static deSugarAtom(t,e,n){if(t[e]!=="N"&&t[e]!=="L")return null;let o=e+1,s="";if(t[o]==="("){let i=qs(t,o+1,n);if(i<0)return null;s=Dt(t.slice(o+1,i).trim()),o=i+1}if(t[o++]!==":")return null;if(t[e]==="N")return{next:o,node:{kind:"sugar",data:{class:r,name:s},span:{start:e,end:o}}};{if(o=wt(t,o,n),o>=n)return null;let i;if(t[o]==='"'){let a=Lt(t,o,n);if(a<0)return null;i=Dt(t.slice(o,a+1)),o=a+1}else{let a=o;for(;o<n&&t[o]!==`
|
|
104
|
+
`;)o++;i=t.slice(a,o).trim()}return{next:o,node:{kind:"sugar",data:{class:r,lyric:i,name:s},span:{start:e,end:o}}}}}static deSugarRelation(t,e,n,o){let s=e[n++];if(s.data?.class!==r)return null;if(s.data?.lyric!==void 0){let x=null,y=t.nodes.length-1;for(;y>=0;y--){let g=t.nodes[y];if(g 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",g.sourceSpan)}g instanceof r?x=g:g instanceof vt&&(x=g.voices.at(-1)??null);break}if(x===null)throw new w("E_LYRICS_WITHOUT_VOICE_NOTES","\u8BED\u6CD5\u7CD6 'L:' \u6216 'L(name):' \u5FC5\u987B\u8DDF\u5728 @voice\uFF08\u6216 N:\uFF09\u4E4B\u540E\uFF0C\u4F46\u6CA1\u6709\u627E\u5230\u7B26\u5408\u8981\u6C42\u7684 voice\uFF1B\u8BF7\u68C0\u67E5\u8BED\u6CD5\u6216\u76F4\u63A5\u4F7F\u7528 @voice \u51FD\u6570",s.span);return x.addLyric(s.data.name,s.data.lyric,s.span,t),t.nodes.length=y+1,n<e.length&&typeof e[n]=="number"&&t.source[e[n]]===`
|
|
105
|
+
`&&n++,n}let i=n,c=0;for(;i<e.length;i++){let x=e[i];if(typeof x=="number"){if(t.source[x]===`
|
|
106
|
+
`){c=1;break}}else if(x.kind==="sugar"&&(x.data?.class===r||x.data?.class===vt))break}let a=new pt(t),l=e.slice(n,i);if(i+=c,a.makeNodes(l),a.nodes.length===0)throw M.error.EmptyContent("voice","content",s.span);let h={start:s.span.start,end:a.nodes.at(-1).sourceSpan.end},p=new Map;a.nodes.length===1&&a.nodes[0]instanceof tt?p.set(0,a.nodes[0]):p.set(0,new tt({...h},a.nodes)),p.set("name",s.data.name);let f=new r(h,p,t,null);if(o)return t.pushNode(f),o.push(f),i;let d=null,u=t.nodes.length-1,m=null;t:for(;u>=0;u--){let x=t.nodes[u];if(x instanceof et){if(t.variables.strict)break;for(let y=x.sourceSpan.start;y<x.sourceSpan.end;y++)if(t.source[y]===`
|
|
107
|
+
`)break t;m=x;continue}if(x instanceof vt){if(!x.createdBySugar)break;d=x}else if(x instanceof r){let y=new Map;y.set(0,x),d=new vt({start:x.sourceSpan.start,end:x.sourceSpan.end},y,t,null),d.createdBySugar=!0}break}return d?(t.nodes[u]=d,d.addVoice(f),m&&(t.nodes.length=u+1,t.diagnostics.push(new P("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",m.sourceSpan)))):t.pushNode(f),i}content;name;size;font;lyrics;get children(){return[this.content]}timeFlowModel(){return{children:this.children,mode:"sequence"}}loweringEnter(t){let e=this.parent,n=e instanceof vt&&e.voices.length>1?e.braceSpace:0,o=new pn(this,n),s=[],i=[];return t.beginLoweringGroup(this,{attachment:new qo(s,o,i),onAttachment(c){yt(c)&&c.layer==="background"&&i.push(c)},onTemporal(c){s.push(c)}}),[o]}loweringExit(t){return t.endLoweringGroup(this),[]}constructor(t,e,n,o=null){super(t,o),this.size=n.variables.fontsize,[this.content,this.name]=this.getArgValue(e,n),this.content.parent=this,this.font=n.variables.font,e.delete(0),e.delete("name"),e.delete(1),this.lyrics=[];for(let[s,i]of e){if(typeof i=="string"){this.addLyric(s,i);continue}let c=i,a=n.parseArgWithType(c.valueSpan,"string",t.start);a===null?n.diagnostics.push(new P("W_VOICE_INVALID_LYRIC",`@voice \u7684\u6B4C\u8BCD\u53C2\u6570\u503C\u89E3\u6790\u5931\u8D25, \u53C2\u6570[${s}]\u5C06\u88AB\u5FFD\u7565`,c.valueSpan)):this.addLyric(s,a)}}addLyric(t,e,n=null,o=null){typeof t=="number"&&(t="");let s=r.parseLyric(e);if(s.length===0&&o&&n&&o.diagnostics.push(new P("W_EMPTY_LYRIC",`@voice\u7684\u6B4C\u8BCD${t}\u662F\u7A7A\u7684`,n)),this.lyrics.push({name:t,tokens:s}),n)for(let i=this;i;i=i.parent)i.sourceSpan.start=Math.min(n.start,i.sourceSpan.start),i.sourceSpan.end=Math.max(n.end,i.sourceSpan.end)}static parseLyric(t){let e=[],n="",o="",s=c=>{e.push(o+c),o=""},i=()=>{n&&s(n),n=""};for(let c=0;c<t.length;c++){let a=String.fromCodePoint(t.codePointAt(c));if(c+=a.length-1,a==="\\"&&c+1<t.length&&/[\\{}@-]/.test(t[c+1]))n+=t[++c];else if(a==="{"){let l=c+1,h="";for(;l<t.length&&t[l]!=="}";l++)t[l]==="\\"&&l+1<t.length&&/[\\{}@-]/.test(t[l+1])?h+=t[++l]:h+=t[l];l<t.length?(i(),s(h),c=l):n+=a}else Wc.test(a)?i():a==="-"?(n+=a,n.length>1&&i()):a==="@"?(n&&(n+=a,i()),e.push("")):Qi.has(a)?(i(),o+=a):jo.has(a)?n?n+=a:o||!e.at(-1)?o+=a:e[e.length-1]+=a:a.charCodeAt(0)>127?(i(),s(a)):n+=a}return i(),o&&(e.at(-1)?e[e.length-1]+=o:e.push(o)),e}toString(t){let e=[`${this.content.toString(t)},${ht(this.name)}`];for(let n of this.lyrics){let o=ht(n.tokens.map(s=>s.length===0?"@":`{${s.replace(/[\\{}@-]/g,"\\$&")}}`).join(" "));e.push(n.name?`${n.name}=${o}`:o)}return`@voice(
|
|
101
108
|
${e.join(`,
|
|
102
109
|
`)}
|
|
103
|
-
)`}},
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
@voice({3 4 5}, , "la la la")
|
|
107
|
-
)
|
|
108
|
-
~~~
|
|
109
|
-
|
|
110
|
-
\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
|
|
111
|
-
|
|
112
|
-
**\u7B80\u5199**\uFF1A\u8FDE\u7EED\u58F0\u660E\u591A\u4E2A \`N:\` \u58F0\u90E8\u53CA\u5176 \`L:\` \u6B4C\u8BCD\uFF0C\u4F1A\u81EA\u52A8\u7EC4\u6210 \`voices\`
|
|
113
|
-
|
|
114
|
-
~~~jpfun
|
|
115
|
-
N(\u94A2\u7434): 1 2 3
|
|
116
|
-
L(\u7537): ha ha ha
|
|
117
|
-
N: 3 4 5
|
|
118
|
-
L: la la la
|
|
119
|
-
~~~`,allowExtraArgs:!0,extraArgType:"content",args:[]};voices;createdBySugar=!1;size;braceSpace;measure;get children(){return this.voices}timeFlowModel(){return{children:this.children,mode:"parallel",tracks:{laneKey:`voices/${this.voices.length}`,hostIndex:null,measure:this.measure}}}loweringEnter(t){let e=[];return t.beginLoweringGroup(this,{attachment:new bo(e,this),onTemporal:n=>{n instanceof Xe&&n.ast.parent===this&&e.push(n)}}),[]}loweringExit(t){return t.endLoweringGroup(this),[]}constructor(t,e,n,o=null){super(t,o),this.voices=[],this.size=n.variables.fontsize,this.braceSpace=n.variables.fontsize,this.measure=tc(n.variables.fontsize);for(let[,s]of e){if(s instanceof et){if(s instanceof de)this.addVoice(s);else throw new S("E_VOICES_INVALID_CHILD",`@voices \u7684\u53C2\u6570\u5FC5\u987B\u662F @voice \u51FD\u6570\uFF0C\u4F46\u53D1\u73B0\u4E86\u5176\u4ED6\u7C7B\u578B ${s.constructor.name}`,s instanceof et?s.sourceSpan:t);continue}let r=s,c=n.parseArgWithType(r.valueSpan,"content",t.start);if(c instanceof de)this.addVoice(c);else throw new S("E_VOICES_INVALID_CHILD",`@voices \u7684\u53C2\u6570\u5FC5\u987B\u662F @voice \u51FD\u6570\uFF0C\u4F46\u53D1\u73B0\u4E86\u5176\u4ED6\u7C7B\u578B ${c?.constructor.name}`,r.valueSpan)}if(this.voices.length===0)throw new S("E_VOICES_EMPTY","@voices \u5FC5\u987B\u81F3\u5C11\u5305\u542B\u4E00\u4E2A @voice \u51FD\u6570",t)}addVoice(t){this.voices.push(t),t.parent=this,this.sourceSpan.start=Math.min(t.sourceSpan.start,this.sourceSpan.start),this.sourceSpan.end=Math.max(t.sourceSpan.end,this.sourceSpan.end)}toString(t){let e=Array(this.voices.length);for(let n=0;n<this.voices.length;n++){let o=` ${this.voices[n].toString(t)}`;e[n]=o}return`@voices(
|
|
110
|
+
)`}},vt=class r extends L{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,n){if(t[e]!=="V")return null;let o=/^V(\{\}|\[\]|\|):/.exec(t.slice(e,n));if(!o)return null;let s=e+o[0].length,i={kind:"sugar",data:{class:r,kind:o[1]==="{}"?"brace":o[1]==="[]"?"bracket":"line"},span:{start:e,end:s}};return{next:s,node:i}}static deSugarRelation(t,e,n){let o=e[n];if(typeof o=="number"||o.kind!=="sugar"||o.data?.class!==r)return null;let s=t.nodes.length-1;for(;s>=0&&t.nodes[s]instanceof et;){let{sourceSpan:d}=t.nodes[s],u=t.source.slice(d.start,d.end);if(u.includes(`
|
|
111
|
+
`)||u.trim())break;s--}let i=t.nodes[s],c=i instanceof Wt?[i]:i instanceof r&&i.createdBySugar?[...i.voices]:[],a=c.length>0,l=[],h=n;for(;h<e.length;){let d=e[h];if(typeof d=="number"||d.kind!=="sugar"||d.data?.class!==r)break;h++;let u=e[h];typeof u=="number"&&t.source[u]==="\r"&&h++;let m=e[h];typeof m=="number"&&t.source[m]===`
|
|
112
|
+
`&&h++;let x=new pt(t),y=c.length+1;for(;h<e.length;){let g=e[h];if(typeof g=="number"||g.kind!=="sugar"||g.data?.class!==Wt)break;h=Wt.deSugarRelation(x,e,h,c)}if(c.length<y)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",d.span);(d.data.kind==="brace"||d.data.kind==="bracket")&&l.push({kind:d.data.kind,from:y,to:c.length})}let p=new Map;c.forEach((d,u)=>p.set(u,d)),p.set("connect",Uo(l));let f=new r({start:a?i.sourceSpan.start:o.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 Ui(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 Zo(e,this,ji(this.connectionSpecs,this.voices.length,this.sourceSpan)),onTemporal:n=>{n instanceof pn&&n.ast.parent===this&&e.push(n)}}),[]}loweringExit(t){return t.endLoweringGroup(this),[]}constructor(t,e,n,o=null){super(t,o),this.voices=[],this.size=n.variables.fontsize,this.braceSpace=Math.max(n.variables.fontsize,(Zi*(Ct+.5)+.5)/(1-qi)),this.measure=Gc(n.variables.fontsize),[this.connect]=this.getArgValue(e,n);for(let[s,i]of e){if(s==="connect")continue;let c=i instanceof st?i.sourceSpan:i.valueSpan,a=i instanceof st?i:n.parseArgWithType(c,"content",t.start);if(!(a instanceof Wt))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 ${a?.constructor.name}`,c);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(n=>` ${n.toString(t)}`);return e.push(` connect=${ht(Uo(this.connectionSpecs))}`),`@voices(
|
|
120
113
|
${e.join(`,
|
|
121
114
|
`)}
|
|
122
|
-
)`}},xi=de,mi=Pt,go=.82,ec=.6;function yi(i,t){return{fontFamily:t,fontSize:i*go,fill:"#000",fontWeight:600}}var Xe=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(n=>n.name))&&this.initLayoutBox()}prepareLayout(t){let e=this.ast.name?t.textMeasurer.measureText(this.ast.name,this.style):{w:0,h:0,baseline:0},n=e.w;for(let s of this.ast.lyrics){if(!s.name)continue;let r=t.textMeasurer.measureText(s.name,yi(this.ast.size,this.ast.font));n=Math.max(n,r.w)}let o=this.braceSpace>0?this.braceSpace:n>0?this.ast.size*ec:0;this.box.w=n+o,this.box.h=e.h,this.box.anchor=n,this.box.visualAxis=e.h/2,this.textBaselineY=e.baseline,this.springConfig.alpha_R=.45}get style(){return{fontSize:this.ast.size*.85,fontFamily:this.ast.font,fill:"#000",fontWeight:600,textAlign:"right"}}paint(t){this.ast.name&&t.drawText(this.ast.name,this.box.x+this.box.anchor,this.box.y+this.textBaselineY,this.style)}},Ot=2.33,It=1.17,Rt=.34,nc=[{op:"M",x:0,y:0},{op:"L",x:0,y:-Rt},{op:"C",cx1:Ot*.421,cy1:-Rt+It*.077,cx2:Ot*.733,cy2:-Rt+It*.346,x:Ot,y:-Rt+It},{op:"L",x:Ot*.929,y:-Rt+It},{op:"C",cx1:Ot*.696,cy1:-Rt+It*.535,cx2:Ot*.328,cy2:-Rt+It*.352,x:0,y:0},{op:"Z"}],bo=class{layer="background";names;ast;get sourceSpan(){return this.ast.sourceSpan}constructor(t,e){this.names=t,this.ast=e}createGeometry(){if(this.names.length<2)return{regions:[],paint(){}};let t=this.names[0].box,e=this.names[this.names.length-1].box,n=this.ast.size,o=t.y+t.visualAxis-n*.5,s=e.y+e.visualAxis+n*.5;if(s-o<1e-6)return{regions:[],paint(){}};let r=Math.max(2.5,n*.19),c=r*Ot,a=r*It,l=t.x+t.anchor+this.ast.braceSpace*.3+r/2,h=[{x:l-r/2,y:o,w:r,h:s-o},{x:l+r*1.33-r*.165,y:o+r*.67,w:r*.33,h:s-o-r*1.34}],p=[{x:l,y:o,scale:r,dir:-1},{x:l,y:s,scale:r,dir:1}];return{regions:[{x:l-r/2,y:o-a,w:c+r/2,h:s-o+a*2}],paint(d){for(let u of h)d.drawRect(u.x,u.y,u.w,u.h,{fill:"#000"});for(let u of p)d.drawPath(nc,{fill:"#000"},{x:u.x,y:u.y,scaleX:u.scale,scaleY:u.scale*u.dir})}}}},wo=class{layer="foreground";temporalMembers;nameHost;get sourceSpan(){return this.nameHost.ast.sourceSpan}constructor(t,e){this.temporalMembers=t,this.nameHost=e}prepareHorizontal(t,e){let n=this.temporalMembers.filter(F).filter(c=>c.ports?.lyric),{lyrics:o,size:s}=this.nameHost.ast;if(n.length===0||o.length===0)return;let r={fontSize:s*go,fontFamily:this.nameHost.ast.font,fill:"#000"};for(let c=0;c<n.length;c++){let a=n[c],l=0;for(let h of o){let p=h.tokens[c];if(p){let{body:f}=ui(p);f&&(l=Math.max(l,e.textMeasurer.measureText(f,r).w/2))}}l!==0&&t[a.layoutLine]?.registerHorizontalLayoutHook(a,a,({columns:h,start:p})=>{let f=h[p].find(u=>u.time===a);if(!f)return;let d=a.ports.lyric.x-a.box.anchor;f.WL=Math.max(f.WL,l-d),f.WR=Math.max(f.WR,l+d)})}}createGeometry(t){let e=this.prepareGeometry(t);return{regions:e,paint(n){for(let o of e)n.drawText(o.text,o.x,o.y+o.textBaselineY,o.style)}}}prepareGeometry(t){let{lyrics:e,size:n}=this.nameHost.ast,o=[],s=this.temporalMembers.filter(F).filter(m=>m.ports?.lyric);if(s.length===0||e.length===0)return o;let r=new Map;for(let m of s){let b=r.get(m.layoutLine);b||r.set(m.layoutLine,b=new Map);let w=m.box.y+m.box.h;b.set(m.track,Math.max(b.get(m.track)??w,w))}let c=n*go,a=n*.24,l=n*.32,h={fontSize:c,fontFamily:this.nameHost.ast.font,fill:"#000"},p=yi(n,this.nameHost.ast.font),f=t.textMeasurer.measureText("M",h).baseline+l,d=(m,b)=>m+f+b*(c+a),{box:u,layoutLine:g,track:y}=this.nameHost,x=r.get(g)?.get(y);for(let m=0;m<e.length;m++){let b=e[m];for(let A=0;A<b.tokens.length&&A<s.length;A++){let k=b.tokens[A],M=s[A],T=r.get(M.layoutLine)?.get(M.track);if(!k||T===void 0)continue;let E=t.textMeasurer.measureText(k,h),{prefix:C,body:_}=ui(k),P=_?t.textMeasurer.measureText(_,h).w:0,j=C?t.textMeasurer.measureText(C,h).w:0;o.push({text:k,style:h,textBaselineY:E.baseline,x:M.box.x+M.ports.lyric.x-P/2-j,y:d(T,m)-E.baseline,w:E.w,h:E.h,line:M.layoutLine,track:M.track})}if(!b.name||!u||x===void 0)continue;let w=t.textMeasurer.measureText(b.name,p);o.push({text:b.name,style:p,textBaselineY:w.baseline,x:u.x+u.anchor-w.w,y:d(x,m)-w.baseline,w:w.w,h:w.h,line:g,track:y})}return o}};var Ze=[zs,rs,jo,Yt,hs,fi,xi,mi,Ps,Gs,Is,Ks,Hs,Ws,Uo,xs,pi,ss,ps,is,li,Ro,ci,Fe,$e,Be,Vs,ze,ri];function So(i,t={}){let e=new Map,n=new Set(i);for(let o of n){let s=o.layoutDecorationHandler;if(!s)continue;let r=o.def?.name;if(!r)continue;let c=Array.isArray(r)?r[0]:r;e.set(Lt(c),s)}return{textMeasurer:t.textMeasurer??On,decorationHandlers:e}}var xe=class i{loweringAugmenters=[];loweringFinalizers=[];cnt=0;usedTracks=new Set;attachments=[];page;astToTemporal=new Map;activeLoweringGroups=[];diagnostics;constructor(t=[]){this.diagnostics=t}registerFunctions(t){let e=this.loweringAugmenters=[],n=this.loweringFinalizers=[];for(let o of t)o.loweringAugment&&e.push(o.loweringAugment),o.loweringFinalize&&n.push(o.loweringFinalize)}setPageConfig(t){this.page=t}lowerDocument(t){this.cnt=0,this.usedTracks.clear(),this.attachments=[],this.page=void 0,this.astToTemporal=new Map,this.activeLoweringGroups=[];let e=new _t,n=new I,o=this.trackedEvents(t,n,e);return this.solidifyColumns(o),this.postprocessResult({diagnostics:this.diagnostics,columns:o,attachments:this.attachments,astToTemporal:this.astToTemporal,duration:n,rootTrack:e,tracks:[...this.usedTracks],page:this.page})}solidifyColumns(t){let e=0;for(let a of t){let l=0;for(let h of a)h.breakBefore>l&&(l=h.breakBefore);e+=l,a.layoutLine=e}let n={bpm:yt,velocity:Bt,keySignature:oe,program:be},o=new Map,s=new Map,r=a=>o.get(a)??(a.parent?r(a.parent):Bt),c=a=>s.get(a)??(a.parent?c(a.parent):be);for(let a of t)for(let l of a)n.velocity=r(l.track),n.program=c(l.track),l.onTimeState?.(n),o.set(l.track,n.velocity),s.set(l.track,n.program)}beginLoweringGroup(t,e){this.activeLoweringGroups.push({owner:t,group:e})}endLoweringGroup(t){let e=this.activeLoweringGroups.pop();if(!e)throw new Error("No active lowering group to end");if(e.owner!==t)throw new Error("Lowering groups must end in reverse order");return e.group.attachment&&this.addAttachment(e.group.attachment),e.group}postprocessResult(t){if(this.activeLoweringGroups.length>0)throw new Error("Lowering groups must be closed before post-processing");let e=[];for(let n of this.loweringAugmenters)for(let o of n(t))e.push(o);for(let n of e)this.addAttachment(n);for(let n of this.loweringFinalizers)n(t);return t}addAttachment(t){this.attachments.push(t);for(let e=this.activeLoweringGroups.length-1;e>=0;e--)this.activeLoweringGroups[e].group.onAttachment?.(t)}getTemporalNodes(t){return this.astToTemporal.get(t)??[]}isolateFromLoweringGroups(t){let e=this.activeLoweringGroups;this.activeLoweringGroups=[];try{return t()}finally{this.activeLoweringGroups=e}}initEvent(t,e,n,o){t.t.add(n),this.usedTracks.add(o),t.track=o,t.ast??=e,t.order=this.cnt++,t.mergeKey??=t.order}trackedEvents(t,e,n){let o=[];this.appendEvents(t.loweringEnter(this,n),t,e,n,o);let s=t.timeFlowModel(this);if(s)switch(s.mode){case"sequence":for(let r of s.children)for(let c of this.trackedEvents(r,e,n))o.push(c);break;case"parallel":{let r=s.tracks,c=s.children,a=r.hostIndex===void 0?0:r.hostIndex,l=n.group(r,a===null?c.length:c.length-1),h=[];for(let d=0;d<c.length;d++){let u=c[d],g=d===a?n:l.members[a===null||d<a?d:d-1],y=e.clone(),x=this.trackedEvents(u,y,g);x.length===0&&this.diagnostics.push(N.warning.ZeroTimeTrack(u.sourceSpan,d+1)),h.push(x)}let p=o.length;for(let d of i.anchorAlign(h))o.push(d);let f=new I;for(let d=p;d<o.length;d++)for(let u of o[d])f.copyFrom(u.t).add(u.T),f.compare(e)>0&&e.copyFrom(f)}break}return this.appendEvents(t.loweringExit(this,n,e),t,e,n,o),o}appendEvents(t,e,n,o,s){let r;for(let c of t){this.initEvent(c,e,n,o),this.indexTemporal(c);for(let l=this.activeLoweringGroups.length-1;l>=0;l--)this.activeLoweringGroups[l].group.onTemporal?.(c);let a=(r??=new I).copyFrom(c.t).add(c.T);a.compare(n)>0&&n.copyFrom(a),s.push(new Ao(c))}}indexTemporal(t){let e=this.astToTemporal.get(t.ast);e?e.push(t):this.astToTemporal.set(t.ast,[t])}static anchorAlign(t){for(let l=t.length-1;l>=0;l--)t[l].length===0&&t.splice(l,1);let e=t.length;if(e===0)return[];if(e===1)return t[0];let n=[];if(e===2){let l=t[0],h=t[1],p=l.length,f=h.length,d=0,u=0,g=new I,y=new I,x=l[0],m=h[0],b=x.t.clone(),w=m.t.clone();for(;;){if(x.mergeKey===U){if(m.mergeKey!==U){for(n.push(m),m=h[++u];u<f&&m.mergeKey!==U;)y.isZero()||m.shiftTime(y),n.push(m),m=h[++u];m&&(m.shiftTime(y),w.copyFrom(m.t))}if(u<f){let A=b.compare(w)>=0?b:w;g.add(A).sub(b),y.add(A).sub(w),x.push(...m),x.t=A,m=h[++u]}if(n.push(x),x=l[++d],x&&(x.shiftTime(g),b.copyFrom(x.t)),m&&(m.shiftTime(y),w.copyFrom(m.t)),!x||!m)break}if(m.mergeKey===U){if(x.mergeKey!==U){for(n.push(x),x=l[++d];d<p&&x.mergeKey!==U;)g.isZero()||x.shiftTime(g),n.push(x),x=l[++d];x&&(x.shiftTime(g),b.copyFrom(x.t))}if(d<p){let A=b.compare(w)>=0?b:w;g.add(A).sub(b),y.add(A).sub(w),m.push(...x),m.t=A,x=l[++d]}if(n.push(m),m=h[++u],x&&(x.shiftTime(g),b.copyFrom(x.t)),m&&(m.shiftTime(y),w.copyFrom(m.t)),!x||!m)break}if(b.equals(w)){if(x.mergeKey===m.mergeKey){if(x.push(...m),n.push(x),x=l[++d],m=h[++u],x&&(x.shiftTime(g),b.copyFrom(x.t)),m&&(m.shiftTime(y),w.copyFrom(m.t)),!x||!m)break}else if(x.mergeKey<m.mergeKey)if(n.push(x),x=l[++d],x)x.shiftTime(g),b.copyFrom(x.t);else break;else if(n.push(m),m=h[++u],m)m.shiftTime(y),w.copyFrom(m.t);else break;continue}if(b.compare(w)<0)if(n.push(x),x=l[++d],x){x.shiftTime(g),b.copyFrom(x.t);continue}else break;if(w.compare(b)<0)if(n.push(m),m=h[++u],m){m.shiftTime(y),w.copyFrom(m.t);continue}else break}for(x&&n.push(x);++d<p;)x=l[d],g.isZero()||x.shiftTime(g),n.push(x);for(m&&n.push(m);++u<f;)m=h[u],y.isZero()||m.shiftTime(y),n.push(m);return n}let o=new Uint16Array(e),s=Array.from({length:e},()=>new I),r=[],c=new Lo(e);for(let l=0;l<e;l++)c.push({e:t[l][0],i:l});let a=l=>{let h=t[l][++o[l]];h&&(s[l].isZero()||h.shiftTime(s[l]),c.push({e:h,i:l}))};for(;;){let l=c.pop();if(l===void 0){if(r.length===0)break;let p=r[0],f=p.e,d=f.t;for(let u=1;u<r.length;u++)r[u].e.t.compare(d)>0&&(d=r[u].e.t);s[p.i].add(d).sub(f.t),a(p.i);for(let u=1;u<r.length;u++){let g=r[u];f.push(...g.e),s[g.i].add(d).sub(g.e.t),a(g.i)}r.length=0,f.t=d,f.sort((u,g)=>u.order-g.order),n.push(f);continue}if(l.e.mergeKey===U){r.push(l);continue}let h=[l.i];for(;;){let p=c.front();if(!p||!p.e.t.equals(l.e.t)||p.e.mergeKey!==l.e.mergeKey)break;c.pop(),l.e.push(...p.e),h.push(p.i)}n.push(l.e);for(let p of h)a(p)}return n}},Ao=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 Co(i,t){let e=i.e.t.compare(t.e.t);return e!==0?e:i.e.mergeKey!==t.e.mergeKey?i.e.mergeKey<t.e.mergeKey?-1:1:i.i-t.i}var Lo=class extends Array{validLen=0;constructor(t){super(t)}front(){if(this.validLen!==0)return this[0]}push(t){return this[this.validLen]=t,this.up(this.validLen++),this.validLen}pop(){if(this.validLen===0)return;let t=this[0];return this[0]=this[--this.validLen],this[this.validLen]=void 0,this.down(0),t}up(t){let e=this[t];for(;t>0;){let n=t-1>>1;if(Co(e,this[n])>=0)break;this[t]=this[n],t=n}this[t]=e}down(t){let e=this[t];for(;;){let n=(t<<1)+1,o=n+1;if(n>=this.validLen)break;let s=n;if(o<this.validLen&&Co(this[o],this[n])<0&&(s=o),Co(this[s],e)>=0)break;this[t]=this[s],t=s}this[t]=e}};function oc(i,t={}){let{functions:e=Ze,textMeasurer:n,variables:o,...s}=t,{maskedSource:r,lineStarts:c}=Xt(i),a=new ct({source:r,variables:o});a.registerFunctions(e);let l=new K({start:0,end:i.length},a.parse()),h=new xe(a.diagnostics);h.registerFunctions(e);let p=h.lowerDocument(l),f=So(e,{textMeasurer:n}),d=fn(p,f,s);return{lineStarts:c,maskedSource:r,diagnostics:a.diagnostics,ast:l,lowering:p,layout:d}}function sc(i,t=Ze){let{maskedSource:e,commentSpans:n}=Xt(i),o=new ct({source:e,commentSpans:n});return o.registerFunctions(t),{syntax:o.parseSyntax(),diagnostics:o.diagnostics}}function To(i){return typeof i.applyPlayback=="function"}function qe(i,t){let e=Math.max(0,t),n=0,o=0,s=yt;for(let r of i){if(r.kind!=="tempo")continue;let c=r.at.toNumber();if(c>e)break;c>o&&(n+=(c-o)*60/s),o=c,s=r.bpm}return n+(e-o)*60/s}function gi(i,t){let e=Math.max(0,t),n=0,o=yt;for(let s of i){if(s.kind!=="tempo")continue;let r=s.at.toNumber(),c=(r-n)*60/o;if(e<c)return n+e*o/60;e-=c,n=r,o=s.bpm}return n+e*o/60}function bi(i,t){let e=Math.max(0,t),n=e;for(let o of i){let s=o.performance.toNumber();if(s>e)break;n=o.score.toNumber()+e-s}return n}function wi(i,t){let e=Math.max(0,t),n;for(let o=0;o<i.length;o++){let s=i[o],r=s.score.toNumber();if(r>e){(!n||r<n.score.toNumber())&&(n=s);continue}let c=i[o+1],a=c?c.performance.toNumber()-s.performance.toNumber():1/0;if(!(e-r>=a))return s.performance.toNumber()+(e-r)}return n?.performance.toNumber()??e}function ic(i,t){let e=Math.min(gi(i.events,t),i.performanceDuration.toNumber());return bi(i.scoreMap,e)}function rc(i,t){let e=Math.min(wi(i.scoreMap,t),i.performanceDuration.toNumber());return qe(i.events,e)}var Si={tempo:0,"time-signature":1,"program-change":2,"note-off":3,"note-on":4};function Ci(i,t){return i.at.compare(t.at)||Si[i.kind]-Si[t.kind]||i.order-t.order}function Ai(i,t){let e=new Map,n=new Map;for(let c of i)if(c.kind==="note-on"){if(e.has(c.noteId))throw new Error(`Duplicate NoteOn ${c.noteId}`);e.set(c.noteId,c)}else if(c.kind==="note-off"){if(n.has(c.noteId))throw new Error(`Duplicate NoteOff ${c.noteId}`);n.set(c.noteId,c)}for(let[c,a]of e){let l=n.get(c);if(!l)throw new Error(`Note ${c} has no NoteOff`);if(l.at.compare(a.at)<=0)throw new Error(`Note ${c} has a non-positive duration`);if(a.origins.length===0||l.origins.length===0)throw new Error(`Note ${c} has no origin`)}for(let c of n.keys())if(!e.has(c))throw new Error(`NoteOff ${c} has no NoteOn`);let o=new Set;for(let c of e.values())o.add(c.track);let s=new Map;for(let c of t)o.has(c)&&s.set(c,s.size);for(let c of o)s.has(c)||s.set(c,s.size);let r=[];for(let c of i){if(c.kind==="tempo"){r.push({kind:"tempo",at:c.at,bpm:c.bpm});continue}if(c.kind==="time-signature"){r.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&&r.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"){r.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}r.push({kind:"note-off",at:c.at,noteId:c.noteId,track:l,midi:a.midi})}return{events:r,tracks:[...s.keys()]}}function cc(i,t,e){let n=i.columns,o=new Map;for(let y=0;y<n.length;y++)for(let x of n[y])o.set(x,y);let s=y=>{for(let x=y;x;x=x.foldedInto){let m=o.get(x);if(m!==void 0)return m}},r=new Map,c=new Map,a=(y,x)=>{let m=y.playbackFlow?.(s);if(!m)return;let[b,w]=m.range??[0,n.length-1];if(m.range&&(!Number.isSafeInteger(b)||!Number.isSafeInteger(w)||b<0||w<b||w>=n.length))throw new S("E_PLAYBACK_FLOW_RANGE",`\u64AD\u653E\u63A7\u5236\u6D41\u8303\u56F4 [${b}, ${w}] \u8D85\u51FA\u65F6\u95F4\u5217\u8FB9\u754C`,x);let A={hook:m,sourceSpan:x};for(let k=b;k<=w;k++){let M=c.get(k);M?M.push(A):c.set(k,[A])}};for(let y of i.astToTemporal.values())for(let x of y){a(x,x.ast.sourceSpan);let m=x.playbackMarks?.();if(!m)continue;let b=s(x);if(b!==void 0)for(let w of m){let A=r.get(w);A?A.push(b):r.set(w,[b])}}for(let y of i.attachments)a(y,y.sourceSpan??{start:0,end:0});if(c.size===0)return n.map((y,x)=>x);for(let y of r.values())y.sort((x,m)=>x-m);let l=new Array(n.length).fill(0),h=0,p={get column(){return h},visits:y=>l[y]??0,seek(y,x,m){let b=r.get(y);if(b){if(m>0)return b.find(w=>w>x);for(let w=b.length-1;w>=0;w--)if(b[w]<x)return b[w]}}},f=[],d=0;for(;h<n.length;){if(++d>e)throw new S("E_PLAYBACK_FLOW_LIMIT",`\u64AD\u653E\u63A7\u5236\u6D41\u8BBF\u95EE\u8D85\u8FC7 ${e} \u6B65\uFF1B\u53EF\u901A\u8FC7 maxFlowSteps \u63D0\u9AD8\u5C55\u5F00\u9884\u7B97`,n[h][0].ast.sourceSpan);l[h]++;let y;for(let x of c.get(h)??[]){let b=x.hook.run(p);if(b){if(b.kind==="stop")return f;if(!Number.isSafeInteger(b.column)||b.column<0||b.column>n.length)throw new S("E_PLAYBACK_FLOW_JUMP",`\u64AD\u653E\u63A7\u5236\u6D41\u8DF3\u8F6C\u76EE\u6807 ${b.column} \u8D85\u51FA\u65F6\u95F4\u5217\u8FB9\u754C`,x.sourceSpan);y=Math.min(y??1/0,b.column)}}y!==void 0?h=y:(f.push(h),h++)}let u=new Set(f),g=!1;for(let y=0;y<n.length;y++){let x=!u.has(y);x&&!g&&t.push(new O("W_PLAYBACK_COLUMN_NEVER_PLAYED","\u8FD9\u91CC\u5728\u4EFB\u4F55\u4E00\u904D\u91CC\u90FD\u4E0D\u4F1A\u6F14\u594F",n[y][0].ast.sourceSpan)),g=x}return f}function ac(i,t){let e=t?.maxFlowSteps??65536;if(!Number.isSafeInteger(e)||e<=0)throw new S("E_PLAYBACK_FLOW_LIMIT","maxFlowSteps \u5FC5\u987B\u662F\u6B63\u5B89\u5168\u6574\u6570",i.columns[0]?.[0]?.ast.sourceSpan??{start:0,end:0});let n=[],o=[],s=[],r=[],c=new Map,a=new Map,l=0,h=0,p=[{kind:"initial",at:new I,origins:[]}],f=new Map,d=new Map,u={spans:s,notes:r,diagnostics:n},g=(L,R,B)=>{if(!Number.isFinite(L.toNumber())||L.compare(0)<0)throw new S("E_PLAYBACK_CONTROL_TIME","\u7CFB\u7EDF\u63A7\u5236\u65F6\u523B\u5FC5\u987B\u662F\u975E\u8D1F\u6709\u9650\u503C",R.at(-1).node.ast.sourceSpan);p.push({kind:"control",at:L.clone(),origins:R,apply:B})};function y(L,R,B,G,z,st=[],it=L.track){let nt=[...st,{node:L}],Ct=[...R],xt=[...R],nn=[...B],Dt=[...B],ge=[];function Jt(H){let J={...H,start:H.start.clone(),end:H.end.clone(),track:it,origins:nt,sourceSpans:[{...L.ast.sourceSpan}]};return s.push(J),Dt.length&&d.set(J,Dt),J}let At=L.playbackState?.program;At!==void 0&&a.get(it)!==At&&(a.set(it,At),o.push({kind:"program-change",at:G.clone(),order:l++,origins:nt,track:it,program:At}));let te=L.playbackState?.bpm;te!==void 0&&g(G,nt,H=>{H.bpm=te}),L.emitPlayback?.({start:G,end:G.clone().add(z),track:it,span(H){Jt(H)},note(H){let J=Jt(H);r.push(J),xt.length&&c.set(J,xt)},extend(H){if(!s.includes(H)||!H.end.equals(G)||z.compare(0)<=0)throw new S("E_PLAYBACK_EXTEND_RANGE","\u6269\u5C55\u5FC5\u987B\u63A5\u7EED\u5F53\u524D\u8BA1\u5212\u5185\u7684\u533A\u95F4\u4E14\u65F6\u503C\u4E3A\u6B63",L.ast.sourceSpan);let J=H.end.clone().sub(H.start),mt=J.clone().add(z),ee=(d.get(H)??[]).map(pt=>pt.startRatio?{...pt,startRatio:pt.startRatio.clone().mul(J).div(mt)}:pt);for(let pt of Dt)ee.push({...pt,startRatio:J.clone().div(mt)});ee.length&&d.set(H,ee),H.end.add(z)},emit:H=>o.push({...H,at:H.at.clone(),order:l++,origins:nt}),control:(H,J)=>g(H,nt,J),scaleFollowingBpm(H,J,mt=1,ee){if(!Number.isSafeInteger(J)||!Number.isSafeInteger(mt)||J<=0||mt<=0)throw new S("E_PLAYBACK_BPM_SCALE","\u901F\u5EA6\u6BD4\u4F8B\u5FC5\u987B\u662F\u6B63\u6709\u7406\u6570",L.ast.sourceSpan);let pt=new I(J,mt),Mo=f.get(H);if(Mo&&!Mo.equals(pt))throw new S("E_PLAYBACK_BPM_SCALE","\u540C\u4E00\u901F\u5EA6\u6548\u679C key \u5FC5\u987B\u4F7F\u7528\u56FA\u5B9A\u6BD4\u4F8B",L.ast.sourceSpan);f.set(H,pt),B.push({key:H,factor:pt,followConnections:ee?.followConnections??!1,origins:nt})},affectFollowing:H=>R.push(H),defer:H=>ge.push(H),play:(H,J,mt)=>y(H,Ct,nn,J??G,mt??z,nt,it)});for(let H of ge)H(u)}let x=cc(i,n,e),m=i.columns[x[0]]?.[0]?.t.clone()??new I,b=[{performance:new I,score:m}],w=new I().sub(m),A=new I;for(let L=0;L<x.length;L++){let R=x[L];for(let nt of i.columns[R])y(nt,[],[],nt.t.clone().add(w),nt.T.clone());let B=i.columns[R+1]?.[0]?.t??i.duration;A.copyFrom(B).add(w);let G=x[L+1];if(G===void 0||G===R+1)continue;let z=i.columns[G][0]?.t.clone()??new I;w.add(B).sub(z);let st={performance:A.clone(),score:z};b[b.length-1].performance.equals(st.performance)?b[b.length-1]=st:b.push(st)}for(let L of s){if(!Number.isFinite(L.start.toNumber())||!Number.isFinite(L.end.toNumber())||L.start.compare(0)<0||L.end.compare(L.start)<=0)throw new S("E_PLAYBACK_NOTE_RANGE","\u97F3\u6BB5\u5FC5\u987B\u5177\u6709\u975E\u8D1F\u8D77\u70B9\u548C\u6B63\u65F6\u503C",L.sourceSpans[0]);L.end.compare(A)>0&&A.copyFrom(L.end),Object.freeze(L.start),Object.freeze(L.end);for(let R of L.origins)Object.freeze(R);for(let R of L.sourceSpans)Object.freeze(R);Object.freeze(L.origins),Object.freeze(L.sourceSpans),Object.freeze(L)}let k=new Set(r),M=new Map,T=new Map,E={notes:r,diagnostics:n,connect(L,R){if(!k.has(L)||!k.has(R)||!L.end.equals(R.start))throw new S("E_PLAYBACK_CONNECTION","\u97F3\u6BB5\u8FDE\u63A5\u5FC5\u987B\u5C5E\u4E8E\u5F53\u524D\u8BA1\u5212\u4E14\u65F6\u95F4\u76F8\u63A5",L.sourceSpans[0]);return M.has(L)&&M.get(L)!==R||T.has(R)&&T.get(R)!==L?!1:(M.set(L,R),T.set(R,L),!0)}};for(let L of i.attachments)To(L)&&L.applyPlayback(E);let C=[...r].sort((L,R)=>R.start.compare(L.start)),_=new Map;for(let L of C){let R=M.get(L),B=R?_.get(R):L.end;_.set(L,B)}for(let L of s){let R=_.get(L)??L.end;for(let B of d.get(L)??[]){let G=B.startRatio?L.start.clone().add(L.end.clone().sub(L.start).mul(B.startRatio)):L.start;p.push({kind:"scale",at:G,origins:B.origins,scale:B,delta:1},{kind:"scale",at:B.followConnections?R:L.end,origins:B.origins,scale:B,delta:-1})}}let P={bpm:yt,bpmScale:new I(1)},j=new Map,X=new I(1),Y=[];p.sort((L,R)=>L.at.compare(R.at));let D=0,$;for(;D<p.length;){let L=p[D].at,R=new Set;for(;D<p.length&&p[D].at.equals(L);){let st=p[D++];for(let it of st.origins)R.add(it);if(st.kind==="control")st.apply(P);else if(st.kind==="scale"){let{key:it,factor:nt}=st.scale,Ct=j.get(it)??0,xt=Ct+st.delta;j.set(it,xt),Ct===0&&xt>0?X.mul(nt):Ct>0&&xt===0&&X.div(nt)}}let B=P.bpmScale.clone().mul(X),G={bpm:P.bpm,bpmScale:B,effectiveBpm:P.bpm*B.toNumber()};if(!Number.isFinite(G.effectiveBpm)||G.effectiveBpm<=0)throw new S("E_PLAYBACK_BPM","\u7CFB\u7EDF\u63A7\u5236\u4EA7\u751F\u4E86\u65E0\u6548\u901F\u5EA6",[...R].at(-1)?.node.ast.sourceSpan??{start:0,end:0});let z=Y.at(-1)?.state;(!z||z.bpm!==G.bpm||!z.bpmScale.equals(B))&&Y.push({at:L.clone(),state:G}),$!==G.effectiveBpm&&($=G.effectiveBpm,o.push({kind:"tempo",at:L.clone(),bpm:G.effectiveBpm,order:l++,origins:[...R]}))}let q={diagnostics:n,stateAt(L){let R=0,B=Y.length;for(;R<B;){let z=R+B>>>1;Y[z].at.compare(L)<=0?R=z+1:B=z}let G=Y[Math.max(0,R-1)].state;return{...G,bpmScale:G.bpmScale.clone()}}},Q=new Map;for(let L of r){let R=[{...L,start:L.start.clone(),end:L.end.clone()}];for(let z of c.get(L)??[])R=z(q,R)??R;let B,G;for(let z of R){if(!Number.isFinite(z.start.toNumber())||!Number.isFinite(z.end.toNumber())||z.start.compare(L.start)<0||z.end.compare(L.end)>0||z.end.compare(z.start)<=0)throw new S("E_PLAYBACK_TRANSFORM_RANGE","\u58F0\u97F3\u5C55\u5F00\u5FC5\u987B\u4F4D\u4E8E\u539F\u97F3\u6BB5\u533A\u95F4\u5185\u4E14\u65F6\u503C\u4E3A\u6B63",L.sourceSpans[0]);(!B||z.start.compare(B)<0)&&(B=z.start),(!G||z.end.compare(G)>0)&&(G=z.end)}if(!B?.equals(L.start)||!G?.equals(L.end))throw new S("E_PLAYBACK_TRANSFORM_RANGE","\u58F0\u97F3\u5C55\u5F00\u5FC5\u987B\u4FDD\u6301\u539F\u97F3\u6BB5\u7684\u8D77\u6B62\u8FB9\u754C",L.sourceSpans[0]);Q.set(L,R.map(z=>{let{start:st,end:it,track:nt,midi:Ct,velocity:xt,percussion:nn,origins:Dt,sourceSpans:ge}=z,Jt=h++,At={kind:"note-on",at:st.clone(),noteId:Jt,order:l++,track:nt,midi:Ct,velocity:xt,percussion:nn,origins:[...Dt],sourceSpans:ge.map(H=>({...H}))},te={kind:"note-off",at:it.clone(),noteId:Jt,order:l++,origins:[...Dt]};return o.push(At,te),{on:At,off:te}}))}let tt=new Set,St=new Map;for(let L of C){let R=M.get(L);if(R)for(let B of Q.get(L)){if(!B.off.at.equals(L.end))continue;let G=Q.get(R).find(z=>!tt.has(z.on)&&z.on.at.equals(R.start)&&z.on.track===B.on.track&&z.on.midi===B.on.midi&&z.on.percussion===B.on.percussion);G&&(B.off.at.copyFrom(G.off.at),St.set(B.on,G.on),tt.add(G.on),tt.add(G.off))}}for(let L of St.keys())if(!tt.has(L))for(let R=St.get(L);R;R=St.get(R))L.sourceSpans.push(...R.sourceSpans);let ko=o.filter(L=>!tt.has(L)).sort(Ci),tn=Ai(ko,i.tracks),en=ko.at(-1)?.at;return en&&en.compare(A)>0&&A.copyFrom(en),{events:tn.events,scoreMap:b,tracks:tn.tracks,performanceDuration:A,durationSeconds:qe(tn.events,A.toNumber()),diagnostics:n}}function Ft(i){return i.pages.length>0?i.pages.map(t=>t.bounds):[i.bounds]}function _o(i,t){for(let e of i.attachments)e.layer==="background"&&e.paint(t);for(let e of i.objects){e.paint(t);for(let n of e.decorations)n.paint(t)}for(let e of i.attachments)e.layer==="foreground"&&e.paint(t)}var Eo=class{pages;painters;constructor(t,e){this.pages=t,this.painters=e}route(t,e,n){let o=0,s=this.pages.length;for(;o<s;){let r=o+s>>>1,c=this.pages[r];c.y+c.h<t?o=r+1:s=r}for(let r=o;r<this.pages.length&&this.pages[r].y<=e;r++)n(this.painters[r])}drawText(t,e,n,o){this.route(n,n,s=>s.drawText(t,e,n,o))}drawLine(t,e,n,o,s){let r=(s?.strokeWidth??1)/2;this.route(Math.min(e,o)-r,Math.max(e,o)+r,c=>c.drawLine(t,e,n,o,s))}drawRect(t,e,n,o,s){let r=s?.stroke?(s.strokeWidth??1)/2:0;this.route(e-r,e+Math.max(0,o)+r,c=>{c.drawRect(t,e,n,o,s)})}drawCircle(t,e,n,o){let s=o?.stroke?(o.strokeWidth??1)/2:0,r=Math.max(0,n)+s;this.route(e-r,e+r,c=>c.drawCircle(t,e,n,o))}drawPath(t,e,n){if(t.length===0)return;let o=n?l=>n.y+l*n.scaleY:l=>l,s=1/0,r=-1/0,c=l=>{let h=o(l);s=Math.min(s,h),r=Math.max(r,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,r+a,l=>{l.drawPath(t,e,n)})}};function Qt(i,t){let e=Ft(i);if(t.length!==e.length)throw new Error(`Expected ${e.length} page painters, got ${t.length}`);_o(i,new Eo(e,t))}var vo=class{commands=[];replay(t){for(let e of this.commands)switch(e.kind){case"text":t.drawText(e.text,e.x,e.y,e.style);break;case"line":t.drawLine(e.x1,e.y1,e.x2,e.y2,e.style);break;case"rect":t.drawRect(e.x,e.y,e.w,e.h,e.style);break;case"circle":t.drawCircle(e.cx,e.cy,e.r,e.style);break;case"path":t.drawPath(e.commands,e.style);break}}drawText(t,e,n,o){this.commands.push({kind:"text",text:t,x:e,y:n,style:o})}drawLine(t,e,n,o,s){this.commands.push({kind:"line",x1:t,y1:e,x2:n,y2:o,style:s})}drawRect(t,e,n,o,s){this.commands.push({kind:"rect",x:t,y:e,w:n,h:o,style:s})}drawCircle(t,e,n,o){this.commands.push({kind:"circle",cx:t,cy:e,r:n,style:o})}drawPath(t,e,n){this.commands.push({kind:"path",commands:t.map(o=>lc(o,n)),style:e})}};function lc(i,t){if(!t||i.op==="Z")return{...i};let e=o=>t.x+o*t.scaleX,n=o=>t.y+o*t.scaleY;return i.op==="M"||i.op==="L"?{op:i.op,x:e(i.x),y:n(i.y)}:i.op==="Q"?{op:"Q",cx:e(i.cx),cy:n(i.cy),x:e(i.x),y:n(i.y)}:i.op==="C"?{op:"C",cx1:e(i.cx1),cy1:n(i.cy1),cx2:e(i.cx2),cy2:n(i.cy2),x:e(i.x),y:n(i.y)}:{...i}}function V(i){return Number.isFinite(i)?String(Math.round(i*1e3)/1e3):"0"}function at(i){return i.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function hc(i,t){let e=[],n=t?s=>V(t.x+s*t.scaleX):V,o=t?s=>V(t.y+s*t.scaleY):V;for(let s of i){if(s.op==="Z"){e.push("Z");continue}if(s.op==="M"||s.op==="L"){e.push(`${s.op}${n(s.x)} ${o(s.y)}`);continue}if(s.op==="Q"){e.push(`Q${n(s.cx)} ${o(s.cy)} ${n(s.x)} ${o(s.y)}`);continue}"cx1"in s&&e.push(`C${n(s.cx1)} ${o(s.cy1)} ${n(s.cx2)} ${o(s.cy2)} ${n(s.x)} ${o(s.y)}`)}return e.join(" ")}function me(i){return i?.opacity===void 0?"":` opacity="${V(i.opacity)}"`}var Qe=class{body=[];drawText(t,e,n,o){let s=o.fontFamily??jt,r=o.fontWeight??"normal",c=o.fill??"#000",a=o.textAlign==="center"?"middle":o.textAlign==="right"?"end":"start";this.body.push(`<text x="${V(e)}" y="${V(n)}" font-family="${at(s)}" font-size="${V(o.fontSize)}" font-weight="${at(String(r))}" text-anchor="${a}" fill="${at(c)}" xml:space="preserve"${me(o)}>${at(t)}</text>`)}drawLine(t,e,n,o,s){let r=s?.stroke??s?.fill??"#000",c=s?.strokeWidth??1;this.body.push(`<line x1="${V(t)}" y1="${V(e)}" x2="${V(n)}" y2="${V(o)}" stroke="${at(r)}" stroke-width="${V(c)}" stroke-linecap="round"${me(s)} />`)}drawRect(t,e,n,o,s){let r=s?.fill??"none",c=s?.stroke??"none",a=s?.strokeWidth??1;this.body.push(`<rect x="${V(t)}" y="${V(e)}" width="${V(Math.max(0,n))}" height="${V(Math.max(0,o))}" fill="${at(r)}" stroke="${at(c)}" stroke-width="${V(a)}"${me(s)} />`)}drawCircle(t,e,n,o){let s=o?.fill??"#000",r=o?.stroke??"none",c=o?.strokeWidth??1;this.body.push(`<circle cx="${V(t)}" cy="${V(e)}" r="${V(Math.max(0,n))}" fill="${at(s)}" stroke="${at(r)}" stroke-width="${V(c)}"${me(o)} />`)}drawPath(t,e,n){if(t.length===0)return;let o=hc(t,n),s=e?.fill??"none",r=e?.stroke??"none",c=e?.strokeWidth??1;this.body.push(`<path d="${o}" fill="${at(s)}" stroke="${at(r)}" stroke-width="${V(c)}" stroke-linecap="round" stroke-linejoin="round"${me(e)} />`)}toSvg(t,e={}){let n=Math.max(0,e.padding??0),o=t.x-n,s=t.y-n,r=Math.max(1,t.w+n*2),c=Math.max(1,t.h+n*2),a=e.background?`<rect x="${V(o)}" y="${V(s)}" width="${V(r)}" height="${V(c)}" fill="${at(e.background)}" />`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${V(r)}" height="${V(c)}" viewBox="${V(o)} ${V(s)} ${V(r)} ${V(c)}">${a}${this.body.join("")}</svg>`}};function pc(i,t={}){let e=Ft(i),n=e.map(()=>new Qe);return Qt(i,n),n.map((o,s)=>o.toSvg(e[s],t))}function fc(i,t,e=0,n=0,o=1,s=1){i.beginPath();for(let r of t){if(r.op==="Z"){i.closePath();continue}if(r.op==="M"){i.moveTo(e+r.x*o,n+r.y*s);continue}if(r.op==="L"){i.lineTo(e+r.x*o,n+r.y*s);continue}if(r.op==="Q"){i.quadraticCurveTo(e+r.cx*o,n+r.cy*s,e+r.x*o,n+r.y*s);continue}"cx1"in r&&i.bezierCurveTo(e+r.cx1*o,n+r.cy1*s,e+r.cx2*o,n+r.cy2*s,e+r.x*o,n+r.y*s)}}function ye(i,t){t?.opacity!==void 0&&(i.globalAlpha*=t.opacity)}var Je=class{context;constructor(t){this.context=t}drawText(t,e,n,o){this.context.save(),ye(this.context,o),this.context.fillStyle=o.fill??"#000",this.context.font=Ne(o),this.context.textAlign=o.textAlign??"left",this.context.textBaseline="alphabetic",this.context.fillText(t,e,n),this.context.restore()}drawLine(t,e,n,o,s){this.context.save(),ye(this.context,s),this.context.beginPath(),this.context.moveTo(t,e),this.context.lineTo(n,o),this.context.strokeStyle=s?.stroke??s?.fill??"#000",this.context.lineWidth=s?.strokeWidth??1,this.context.lineCap="round",this.context.stroke(),this.context.restore()}drawRect(t,e,n,o,s){n<0||o<0||(this.context.save(),ye(this.context,s),s?.fill&&(this.context.fillStyle=s.fill,this.context.fillRect(t,e,n,o)),s?.stroke&&(this.context.strokeStyle=s.stroke,this.context.lineWidth=s.strokeWidth??1,this.context.strokeRect(t,e,n,o)),this.context.restore())}drawCircle(t,e,n,o){n<0||(this.context.save(),ye(this.context,o),this.context.beginPath(),this.context.arc(t,e,n,0,Math.PI*2),(o?.fill??!0)&&(this.context.fillStyle=o?.fill??"#000",this.context.fill()),o?.stroke&&(this.context.strokeStyle=o.stroke,this.context.lineWidth=o.strokeWidth??1,this.context.stroke()),this.context.restore())}drawPath(t,e,n){t.length!==0&&(this.context.save(),ye(this.context,e),fc(this.context,t,n?.x,n?.y,n?.scaleX,n?.scaleY),e?.fill&&(this.context.fillStyle=e.fill,this.context.fill()),e?.stroke&&(this.context.strokeStyle=e.stroke,this.context.lineWidth=e.strokeWidth??1,this.context.lineCap="round",this.context.lineJoin="round",this.context.stroke()),this.context.restore())}};function uc(i,t){let e=Ft(i);if(t.length!==e.length)throw new Error(`Expected ${e.length} page contexts, got ${t.length}`);for(let[n,o]of t.entries())o.save(),o.translate(-e[n].x,-e[n].y);try{Qt(i,t.map(n=>new Je(n)))}finally{for(let n of t)n.restore()}}var dc=globalThis;Object.assign(dc.jpfun??={},No);})();
|
|
115
|
+
)`}},Ji=Wt,tr=vt,Xo=.82,Vc=.6;function er(r,t){return{fontFamily:t,fontSize:r*Xo,fill:"#000",fontWeight:600}}var pn=class extends ${braceSpace;textBaselineY=0;constructor(t,e){super(),this.ast=t,this.braceSpace=e,this.mergeKey=-2,(t.name||e>0||t.lyrics.some(n=>n.name))&&this.initLayoutBox()}prepareLayout(t){let e=this.ast.name?t.textMeasurer.measureText(this.ast.name,this.style):{w:0,h:0,baseline:0},n=e.w;for(let s of this.ast.lyrics){if(!s.name)continue;let i=t.textMeasurer.measureText(s.name,er(this.ast.size,this.ast.font));n=Math.max(n,i.w)}let o=this.braceSpace>0?this.braceSpace:n>0?this.ast.size*Vc:0;this.box.w=n+o,this.box.h=e.h,this.box.anchor=n,this.box.visualAxis=e.h/2,this.textBaselineY=e.baseline,this.springConfig.alpha_R=.45}get style(){return{fontSize:this.ast.size*.85,fontFamily:this.ast.font,fill:"#000",fontWeight:600,textAlign:"right"}}paint(t){this.ast.name&&t.drawText(this.ast.name,this.box.x+this.box.anchor,this.box.y+this.textBaselineY,this.style)}},Zo=class{connections;layer="background";names;ast;get sourceSpan(){return this.ast.sourceSpan}constructor(t,e,n){this.connections=n,this.names=t,this.ast=e}createGeometry(){if(this.names.length<2)return{regions:[],paint(){}};let t=this.names[0].box,e=this.names[this.names.length-1].box,n=this.ast.size,o=t.y+t.visualAxis-n*.5,s=e.y+e.visualAxis+n*.5;if(s-o<1e-6)return{regions:[],paint(){}};let i=Math.max(Zi,n*.19),c=i*Ct,a=i*Nt,l=t.x+t.anchor+this.ast.braceSpace*qi+i/2,h=Math.min(i*.67,n*.25),p={x:l+i*1.33-i*.165,y:o+h,w:i*.33,h:s-o-h*2},f=[],d=[],u=[p];for(let m of this.connections){let x=this.names[m.from-1].box,y=this.names[m.to-1].box,g=x.y+x.visualAxis-n*.5,b=y.y+y.visualAxis+n*.5;if(m.kind==="bracket")f.push({x:l-i/2,y:g,w:i,h:b-g}),d.push({commands:Ko,transform:{x:l,y:g,scaleX:i,scaleY:-i}},{commands:Ko,transform:{x:l,y:b,scaleX:i,scaleY:i}}),u.push({x:l-i/2,y:g-a,w:c+i/2,h:b-g+a*2});else{let S=n*.35,C=p.x-n*.12-S,E=S/_e.w,k=(b-g)/_e.h;d.push({commands:Yo,transform:{x:C-_e.x*E,y:g-_e.y*k,scaleX:E,scaleY:k}}),u.push({x:C,y:g,w:S,h:b-g})}}return f.push(p),{regions:u,paint(m){for(let x of f)m.drawRect(x.x,x.y,x.w,x.h,{fill:"#000"});for(let x of d)m.drawPath(x.commands,{fill:"#000"},x.transform)}}}},qo=class{temporalMembers;nameHost;frames;layer="foreground";get sourceSpan(){return this.nameHost.ast.sourceSpan}constructor(t,e,n){this.temporalMembers=t,this.nameHost=e,this.frames=n}prepareHorizontal(t,e){let n=this.temporalMembers.filter(I).filter(c=>c.ports?.lyric),{lyrics:o,size:s}=this.nameHost.ast;if(n.length===0||o.length===0)return;let i={fontSize:s*Xo,fontFamily:this.nameHost.ast.font,fill:"#000"};for(let c=0;c<n.length;c++){let a=n[c],l=0;for(let h of o){let p=h.tokens[c];if(p){let{body:f}=Xi(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(u=>u.time===a);if(!f)return;let d=a.ports.lyric.x-a.box.anchor;f.WL=Math.max(f.WL,l-d),f.WR=Math.max(f.WR,l+d)})}}createGeometry(t){let e=this.prepareGeometry(t);return{regions:e,paint(n){for(let o of e)n.drawText(o.text,o.x,o.y+o.textBaselineY,o.style)}}}prepareGeometry(t){let{lyrics:e,size:n}=this.nameHost.ast,o=[],s=this.temporalMembers.filter(I).filter(g=>g.ports?.lyric);if(s.length===0||e.length===0)return o;let i=new Map;for(let g of s){let b=i.get(g.layoutLine);b||i.set(g.layoutLine,b=new Map);let S=b.get(g.track)??{bottom:-1/0,owner:g.track},C=ot(g),E=C.y+C.h,k=g.track;for(let N of this.frames){let v=t.getAttachmentBox(N);if(v.x+v.w<C.x||v.x>C.x+C.w||v.y+v.h<=E)continue;let _=t.getAttachmentOccupancy(N);if(!_)throw new Error("Layout attachment dependency has not been measured");let D=_.filter(A=>A.line===g.layoutLine);if(!(_.some(A=>A.line!==void 0)&&D.length===0)){E=v.y+v.h;for(let A of D)A.line!==void 0&&t.getVisualAxis(A.line,A.track)>t.getVisualAxis(g.layoutLine,k)&&(k=A.track)}}E>=S.bottom&&(S.owner=k),S.bottom=Math.max(S.bottom,E),b.set(g.track,S)}let c=n*Xo,a=n*.24,l=n*.32,h={fontSize:c,fontFamily:this.nameHost.ast.font,fill:"#000"},p=er(n,this.nameHost.ast.font),f=t.textMeasurer.measureText("M",h).baseline+l,d=(g,b)=>g+f+b*(c+a);if(this.frames.length)for(let[g,b]of i){if(b.size<2)continue;let S=new Map;for(let[,C]of[...b].sort(([E],[k])=>t.getVisualAxis(g,E)-t.getVisualAxis(g,k))){let E=S.get(C.owner)??0;C.bottom+=E*e.length*(c+a),S.set(C.owner,E+1)}}let{box:u,layoutLine:m,track:x}=this.nameHost,y=i.get(m)?.get(x);for(let g=0;g<e.length;g++){let b=e[g];for(let C=0;C<b.tokens.length&&C<s.length;C++){let E=b.tokens[C],k=s[C],N=i.get(k.layoutLine)?.get(k.track);if(!E||!N)continue;let v=t.textMeasurer.measureText(E,h),{prefix:_,body:D}=Xi(E),A=D?t.textMeasurer.measureText(D,h).w:0,O=_?t.textMeasurer.measureText(_,h).w:0;o.push({text:E,style:h,textBaselineY:v.baseline,x:k.box.x+k.ports.lyric.x-A/2-O,y:d(N.bottom,g)-v.baseline,w:v.w,h:v.h,line:k.layoutLine,track:N.owner})}if(!b.name||!u||!y)continue;let S=t.textMeasurer.measureText(b.name,p);o.push({text:b.name,style:p,textBaselineY:S.baseline,x:u.x+u.anchor-S.w,y:d(y.bottom,g)-S.baseline,w:S.w,h:S.h,line:m,track:y.owner})}return o}};var fn=[bi,Ds,Si,Ls,Qt,Hs,Ki,Ji,tr,tn,Ei,Ti,di,ki,Ci,Ai,Es,Ks,Xs,Yi,Ps,js,Ws,Bs,Gi,wi,ls,Hi,Ue,Xe,Ze,Li,qe,zi];function Qo(r,t={}){let e=new Map,n=new Set(r);for(let o of n){let s=o.layoutDecorationHandler;if(!s)continue;let i=o.def?.name;if(!i)continue;let c=Array.isArray(i)?i[0]:i;e.set(It(c),s)}return{textMeasurer:t.textMeasurer??Qn,decorationHandlers:e}}var ke=class r{loweringAugmenters=[];loweringFinalizers=[];cnt=0;usedTracks=new Set;attachments=[];page;astToTemporal=new Map;activeLoweringGroups=[];diagnostics;constructor(t=[]){this.diagnostics=t}registerFunctions(t){let e=this.loweringAugmenters=[],n=this.loweringFinalizers=[];for(let o of t){o.loweringAugment&&e.push(o.loweringAugment);let s=o.loweringFinalize;s&&!n.includes(s)&&n.push(s)}}setPageConfig(t){this.page=t}lowerDocument(t){this.cnt=0,this.usedTracks.clear(),this.attachments=[],this.page=void 0,this.astToTemporal=new Map,this.activeLoweringGroups=[];let e=new Bt,n=new B,o=this.trackedEvents(t,n,e);return this.solidifyColumns(o,n),this.postprocessResult({diagnostics:this.diagnostics,columns:o,attachments:this.attachments,astToTemporal:this.astToTemporal,duration:n,rootTrack:e,tracks:[...this.usedTracks],page:this.page})}solidifyColumns(t,e){let n=0;for(let f of t){let d=0;for(let u of f){let m=u.addon?.breakBefore??0;m>d&&(d=m)}n+=d,f.layoutLine=n}let o={bpm:Et,velocity:Kt,keySignature:fe,program:Re},s=new Map,i=new Map,c=f=>s.get(f)??(f.parent?c(f.parent):Kt),a=f=>i.get(f)??(f.parent?a(f.parent):Re),l=new B;for(let f of t){l.isZero()||f.shiftTime(l);let d;for(let u of f){o.currentEvent=u,o.velocity=c(u.track),o.program=a(u.track);let m=u.onTimeState?.(o);m&&!m.isZero()&&(!d||m.compare(d)>0)&&(d??=new B).copyFrom(m),s.set(u.track,o.velocity),i.set(u.track,o.program)}d&&l.add(d)}if(l.isZero())return;let h=new Set(i.keys()),p=new B;e.set(0);for(let f=t.length-1;f>=0&&h.size>0;f--){let d=t[f];for(let u=d.length-1;u>=0;u--){let m=d[u];if(!h.delete(m.track))continue;let x=m.T;p.copyFrom(m.t),x.isZero()||p.add(x),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=[];for(let n of this.loweringAugmenters)for(let o of n(t))e.push(o);for(let n of e)this.addAttachment(n);for(let n of this.loweringFinalizers)n(t);return t}addAttachment(t){this.attachments.push(t);for(let e=this.activeLoweringGroups.length-1;e>=0;e--)this.activeLoweringGroups[e].group.onAttachment?.(t)}getTemporalNodes(t){return this.astToTemporal.get(t)??[]}isolateFromLoweringGroups(t){let e=this.activeLoweringGroups;this.activeLoweringGroups=[];try{return t()}finally{this.activeLoweringGroups=e}}initEvent(t,e,n,o){t.t.add(n),this.usedTracks.add(o),t.track=o,t.ast??=e,t.order=this.cnt++,t.mergeKey??=t.order}trackedEvents(t,e,n){let o=[];this.appendEvents(t.loweringEnter(this,n),t,e,n,o);let s=t.timeFlowModel(this);if(s)switch(s.mode){case"sequence":for(let i of s.children)for(let c of this.trackedEvents(i,e,n))o.push(c);break;case"parallel":{let i=s.tracks,c=s.children,a=i.hostIndex===void 0?0:i.hostIndex,l=n.group(i,a===null?c.length:c.length-1),h=[];for(let d=0;d<c.length;d++){let u=c[d],m=d===a?n:l.members[a===null||d<a?d:d-1],x=e.clone(),y=this.trackedEvents(u,x,m);y.length===0&&this.diagnostics.push(M.warning.ZeroTimeTrack(u.sourceSpan,d+1)),h.push(y)}let p=o.length;for(let d of r.anchorAlign(h))o.push(d);let f=new B;for(let d=p;d<o.length;d++)for(let u of o[d])f.copyFrom(u.t).add(u.T),f.compare(e)>0&&e.copyFrom(f)}break}return this.appendEvents(t.loweringExit(this,n,e),t,e,n,o),o}appendEvents(t,e,n,o,s){let i;for(let c of t){this.initEvent(c,e,n,o),this.indexTemporal(c);for(let l=this.activeLoweringGroups.length-1;l>=0;l--)this.activeLoweringGroups[l].group.onTemporal?.(c);let a=(i??=new B).copyFrom(c.t).add(c.T);a.compare(n)>0&&n.copyFrom(a),s.push(new ts(c))}}indexTemporal(t){let e=this.astToTemporal.get(t.ast);e?e.push(t):this.astToTemporal.set(t.ast,[t])}static anchorAlign(t){for(let l=t.length-1;l>=0;l--)t[l].length===0&&t.splice(l,1);let e=t.length;if(e===0)return[];if(e===1)return t[0];let n=[],o=new Uint16Array(e),s=Array.from({length:e},()=>new B),i=[],c=new es(e);for(let l=0;l<e;l++)c.push({e:t[l][0],i:l});let a=l=>{let h=t[l][++o[l]];h&&(s[l].isZero()||h.shiftTime(s[l]),c.push({e:h,i:l}))};for(;;){let l=c.pop();if(l===void 0){if(i.length===0)break;let p=i[0],f=p.e,d=f.t;for(let u=1;u<i.length;u++)i[u].e.t.compare(d)>0&&(d=i[u].e.t);s[p.i].add(d).sub(f.t),a(p.i);for(let u=1;u<i.length;u++){let m=i[u];f.push(...m.e),s[m.i].add(d).sub(m.e.t),a(m.i)}i.length=0,f.t=d,f.sort((u,m)=>u.order-m.order),n.push(f);continue}if(l.e.mergeKey===nt){i.push(l);continue}let h=[l.i];for(;;){let p=c.front();if(!p||!p.e.t.equals(l.e.t)||p.e.mergeKey!==l.e.mergeKey)break;c.pop(),l.e.push(...p.e),h.push(p.i)}n.push(l.e);for(let p of h)a(p)}return n}},ts=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 Jo(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 es=class extends Array{validLen=0;constructor(t){super(t)}front(){if(this.validLen!==0)return this[0]}push(t){return this[this.validLen]=t,this.up(this.validLen++),this.validLen}pop(){if(this.validLen===0)return;let t=this[0];return this[0]=this[--this.validLen],this[this.validLen]=void 0,this.down(0),t}up(t){let e=this[t];for(;t>0;){let n=t-1>>1;if(Jo(e,this[n])>=0)break;this[t]=this[n],t=n}this[t]=e}down(t){let e=this[t];for(;;){let n=(t<<1)+1,o=n+1;if(n>=this.validLen)break;let s=n;if(o<this.validLen&&Jo(this[o],this[n])<0&&(s=o),Jo(this[s],e)>=0)break;this[t]=this[s],t=s}this[t]=e}};function Yc(r,t={}){let{functions:e=fn,textMeasurer:n,variables:o,...s}=t,{maskedSource:i,lineStarts:c}=oe(r),a=new pt({source:i,variables:o});a.registerFunctions(e);let l=new tt({start:0,end:r.length},a.parse()),h=new ke(a.diagnostics);h.registerFunctions(e);let p=h.lowerDocument(l),f=Qo(e,{textMeasurer:n}),d=_n(p,f,s);return{lineStarts:c,maskedSource:i,diagnostics:a.diagnostics,ast:l,lowering:p,layout:d}}function Kc(r,t=fn){let{maskedSource:e,commentSpans:n}=oe(r),o=new pt({source:e,commentSpans:n});return o.registerFunctions(t),{syntax:o.parseSyntax(),diagnostics:o.diagnostics}}function ns(r){return typeof r.applyPlayback=="function"}function un(r,t){let e=Math.max(0,t),n=0,o=0,s=Et;for(let i of r){if(i.kind!=="tempo")continue;let c=i.at.toNumber();if(c>e)break;c>o&&(n+=(c-o)*60/s),o=c,s=i.bpm}return n+(e-o)*60/s}function nr(r,t){let e=Math.max(0,t),n=0,o=Et;for(let s of r){if(s.kind!=="tempo")continue;let i=s.at.toNumber(),c=(i-n)*60/o;if(e<c)return n+e*o/60;e-=c,n=i,o=s.bpm}return n+e*o/60}function or(r,t){let e=Math.max(0,t),n=e;for(let o of r){let s=o.performance.toNumber();if(s>e)break;n=o.score.toNumber()+e-s}return n}function sr(r,t){let e=Math.max(0,t),n;for(let o=0;o<r.length;o++){let s=r[o],i=s.score.toNumber();if(i>e){(!n||i<n.score.toNumber())&&(n=s);continue}let c=r[o+1],a=c?c.performance.toNumber()-s.performance.toNumber():1/0;if(!(e-i>=a))return s.performance.toNumber()+(e-i)}return n?.performance.toNumber()??e}function Uc(r,t){let e=Math.min(nr(r.events,t),r.performanceDuration.toNumber());return or(r.scoreMap,e)}function jc(r,t){let e=Math.min(sr(r.scoreMap,t),r.performanceDuration.toNumber());return un(r.events,e)}var ir={tempo:0,"time-signature":1,"program-change":2,"note-off":3,"note-on":4};function rr(r,t){return r.at.compare(t.at)||ir[r.kind]-ir[t.kind]||r.order-t.order}function cr(r,t){let e=new Map,n=new Map;for(let c of r)if(c.kind==="note-on"){if(e.has(c.noteId))throw new Error(`Duplicate NoteOn ${c.noteId}`);e.set(c.noteId,c)}else if(c.kind==="note-off"){if(n.has(c.noteId))throw new Error(`Duplicate NoteOff ${c.noteId}`);n.set(c.noteId,c)}for(let[c,a]of e){let l=n.get(c);if(!l)throw new Error(`Note ${c} has no NoteOff`);if(l.at.compare(a.at)<=0)throw new Error(`Note ${c} has a non-positive duration`);if(a.origins.length===0||l.origins.length===0)throw new Error(`Note ${c} has no origin`)}for(let c of n.keys())if(!e.has(c))throw new Error(`NoteOff ${c} has no NoteOn`);let o=new Set;for(let c of e.values())o.add(c.track);let s=new Map;for(let c of t)o.has(c)&&s.set(c,s.size);for(let c of o)s.has(c)||s.set(c,s.size);let i=[];for(let c of r){if(c.kind==="tempo"){i.push({kind:"tempo",at:c.at,bpm:c.bpm});continue}if(c.kind==="time-signature"){i.push({kind:"time-signature",at:c.at,numerator:c.numerator,denominator:c.denominator});continue}if(c.kind==="program-change"){let h=s.get(c.track);h!==void 0&&i.push({kind:"program-change",at:c.at,track:h,program:c.program});continue}let a=c.kind==="note-on"?c:e.get(c.noteId),l=s.get(a.track);if(c.kind==="note-on"){i.push({kind:"note-on",at:c.at,noteId:c.noteId,track:l,midi:c.midi,velocity:c.velocity,...c.percussion?{percussion:!0}:{},sourceSpans:c.sourceSpans});continue}i.push({kind:"note-off",at:c.at,noteId:c.noteId,track:l,midi:a.midi})}return{events:i,tracks:[...s.keys()]}}function Xc(r,t,e){let n=r.columns,o=new Map;for(let x=0;x<n.length;x++)for(let y of n[x])o.set(y,x);let s=(x,y)=>{for(let g=x;g;g=g.foldedInto){let b=o.get(g);if(b===void 0)continue;if(y!=="end"||g.T.compare(0)<=0)return b;let S=g.t.clone().add(g.T),C=b;for(;C+1<n.length&&n[C+1][0].t.compare(S)<0;)C++;return C}},i=new Map,c=new Map,a=(x,y)=>{let g=x.playbackFlow?.(s);if(!g)return;let[b,S]=g.range??[0,n.length-1];if(g.range&&(!Number.isSafeInteger(b)||!Number.isSafeInteger(S)||b<0||S<b||S>=n.length))throw new w("E_PLAYBACK_FLOW_RANGE",`\u64AD\u653E\u63A7\u5236\u6D41\u8303\u56F4 [${b}, ${S}] \u8D85\u51FA\u65F6\u95F4\u5217\u8FB9\u754C`,y);let C={hook:g,sourceSpan:y};for(let E=b;E<=S;E++){let k=c.get(E);k?k.push(C):c.set(E,[C])}};for(let x of r.astToTemporal.values())for(let y of x){a(y,y.ast.sourceSpan);let g=y.playbackMarks?.();if(!g)continue;let b=s(y);if(b!==void 0)for(let S of g){let C=i.get(S);C?C.push(b):i.set(S,[b])}}for(let x of r.attachments)a(x,x.sourceSpan??{start:0,end:0});if(c.size===0)return n.map((x,y)=>y);for(let x of i.values())x.sort((y,g)=>y-g);let l=new Array(n.length).fill(0),h=0,p={get column(){return h},visits:x=>l[x]??0,seek(x,y,g){let b=i.get(x);if(b){if(g>0)return b.find(S=>S>y);for(let S=b.length-1;S>=0;S--)if(b[S]<y)return b[S]}}},f=[],d=0;for(;h<n.length;){if(++d>e)throw new w("E_PLAYBACK_FLOW_LIMIT",`\u64AD\u653E\u63A7\u5236\u6D41\u8BBF\u95EE\u8D85\u8FC7 ${e} \u6B65\uFF1B\u53EF\u901A\u8FC7 maxFlowSteps \u63D0\u9AD8\u5C55\u5F00\u9884\u7B97`,n[h][0].ast.sourceSpan);l[h]++;let x;for(let y of c.get(h)??[]){let b=y.hook.run(p);if(b){if(b.kind==="stop")return f;if(!Number.isSafeInteger(b.column)||b.column<0||b.column>n.length)throw new w("E_PLAYBACK_FLOW_JUMP",`\u64AD\u653E\u63A7\u5236\u6D41\u8DF3\u8F6C\u76EE\u6807 ${b.column} \u8D85\u51FA\u65F6\u95F4\u5217\u8FB9\u754C`,y.sourceSpan);x=Math.min(x??1/0,b.column)}}x!==void 0?h=x:(f.push(h),h++)}let u=new Set(f),m=!1;for(let x=0;x<n.length;x++){let y=!u.has(x);y&&!m&&t.push(new P("W_PLAYBACK_COLUMN_NEVER_PLAYED","\u8FD9\u91CC\u5728\u4EFB\u4F55\u4E00\u904D\u91CC\u90FD\u4E0D\u4F1A\u6F14\u594F",n[x][0].ast.sourceSpan)),m=y}return f}function Zc(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 n=[],o=[],s=[],i=[],c=new Map,a=new Map,l=0,h=0,p=[{kind:"initial",at:new B,origins:[]}],f=new Map,d=new Map,u={spans:s,notes:i,diagnostics:n},m=(T,R,H)=>{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",R.at(-1).node.ast.sourceSpan);p.push({kind:"control",at:T.clone(),origins:R,apply:H})};function x(T,R,H,K,W,at=[],lt=T.track){let rt=[...at,{node:T}],Mt=[...R],At=[...R],mn=[...H],Vt=[...H],Me=[];function ae(V){let it={...V,start:V.start.clone(),end:V.end.clone(),track:lt,origins:rt,sourceSpans:[{...T.ast.sourceSpan}]};return s.push(it),Vt.length&&d.set(it,Vt),it}let Rt=T.playbackState?.program;Rt!==void 0&&a.get(lt)!==Rt&&(a.set(lt,Rt),o.push({kind:"program-change",at:K.clone(),order:l++,origins:rt,track:lt,program:Rt}));let le=T.playbackState?.bpm;le!==void 0&&m(K,rt,V=>{V.bpm=le}),T.emitPlayback?.({start:K,end:K.clone().add(W),track:lt,span(V){ae(V)},note(V){let it=ae(V);i.push(it),At.length&&c.set(it,At)},extend(V){if(!s.includes(V)||!V.end.equals(K)||W.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 it=V.end.clone().sub(V.start),Tt=it.clone().add(W),he=(d.get(V)??[]).map(gt=>gt.startRatio?{...gt,startRatio:gt.startRatio.clone().mul(it).div(Tt)}:gt);for(let gt of Vt)he.push({...gt,startRatio:it.clone().div(Tt)});he.length&&d.set(V,he),V.end.add(W)},emit:V=>o.push({...V,at:V.at.clone(),order:l++,origins:rt}),control:(V,it)=>m(V,rt,it),scaleFollowingBpm(V,it,Tt=1,he){if(!Number.isSafeInteger(it)||!Number.isSafeInteger(Tt)||it<=0||Tt<=0)throw new w("E_PLAYBACK_BPM_SCALE","\u901F\u5EA6\u6BD4\u4F8B\u5FC5\u987B\u662F\u6B63\u6709\u7406\u6570",T.ast.sourceSpan);let gt=new B(it,Tt),cs=f.get(V);if(cs&&!cs.equals(gt))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(V,gt),H.push({key:V,factor:gt,followConnections:he?.followConnections??!1,origins:rt})},affectFollowing:V=>R.push(V),defer:V=>Me.push(V),play:(V,it,Tt)=>x(V,Mt,mn,it??K,Tt??W,rt,lt)});for(let V of Me)V(u)}let y=Xc(r,n,e),g=r.columns[y[0]]?.[0]?.t.clone()??new B,b=[{performance:new B,score:g}],S=new B().sub(g),C=new B;for(let T=0;T<y.length;T++){let R=y[T];for(let rt of r.columns[R])x(rt,[],[],rt.t.clone().add(S),rt.T.clone());let H=r.columns[R+1]?.[0]?.t??r.duration;C.copyFrom(H).add(S);let K=y[T+1];if(K===void 0||K===R+1)continue;let W=r.columns[K][0]?.t.clone()??new B;S.add(H).sub(W);let at={performance:C.clone(),score:W};b[b.length-1].performance.equals(at.performance)?b[b.length-1]=at:b.push(at)}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 R of T.origins)Object.freeze(R);for(let R of T.sourceSpans)Object.freeze(R);Object.freeze(T.origins),Object.freeze(T.sourceSpans),Object.freeze(T)}let E=new Set(i),k=new Map,N=new Map,v={notes:i,diagnostics:n,connect(T,R){if(!E.has(T)||!E.has(R)||!T.end.equals(R.start))throw new w("E_PLAYBACK_CONNECTION","\u97F3\u6BB5\u8FDE\u63A5\u5FC5\u987B\u5C5E\u4E8E\u5F53\u524D\u8BA1\u5212\u4E14\u65F6\u95F4\u76F8\u63A5",T.sourceSpans[0]);return k.has(T)&&k.get(T)!==R||N.has(R)&&N.get(R)!==T?!1:(k.set(T,R),N.set(R,T),!0)}};for(let T of r.attachments)ns(T)&&T.applyPlayback(v);let _=[...i].sort((T,R)=>R.start.compare(T.start)),D=new Map;for(let T of _){let R=k.get(T),H=R?D.get(R):T.end;D.set(T,H)}for(let T of s){let R=D.get(T)??T.end;for(let H of d.get(T)??[]){let K=H.startRatio?T.start.clone().add(T.end.clone().sub(T.start).mul(H.startRatio)):T.start;p.push({kind:"scale",at:K,origins:H.origins,scale:H,delta:1},{kind:"scale",at:H.followConnections?R:T.end,origins:H.origins,scale:H,delta:-1})}}let A={bpm:Et,bpmScale:new B(1)},O=new Map,G=new B(1),Z=[];p.sort((T,R)=>T.at.compare(R.at));let q=0,J;for(;q<p.length;){let T=p[q].at,R=new Set;for(;q<p.length&&p[q].at.equals(T);){let at=p[q++];for(let lt of at.origins)R.add(lt);if(at.kind==="control")at.apply(A);else if(at.kind==="scale"){let{key:lt,factor:rt}=at.scale,Mt=O.get(lt)??0,At=Mt+at.delta;O.set(lt,At),Mt===0&&At>0?G.mul(rt):Mt>0&&At===0&&G.div(rt)}}let H=A.bpmScale.clone().mul(G),K={bpm:A.bpm,bpmScale:H,effectiveBpm:A.bpm*H.toNumber()};if(!Number.isFinite(K.effectiveBpm)||K.effectiveBpm<=0)throw new w("E_PLAYBACK_BPM","\u7CFB\u7EDF\u63A7\u5236\u4EA7\u751F\u4E86\u65E0\u6548\u901F\u5EA6",[...R].at(-1)?.node.ast.sourceSpan??{start:0,end:0});let W=Z.at(-1)?.state;(!W||W.bpm!==K.bpm||!W.bpmScale.equals(H))&&Z.push({at:T.clone(),state:K}),J!==K.effectiveBpm&&(J=K.effectiveBpm,o.push({kind:"tempo",at:T.clone(),bpm:K.effectiveBpm,order:l++,origins:[...R]}))}let F={diagnostics:n,stateAt(T){let R=0,H=Z.length;for(;R<H;){let W=R+H>>>1;Z[W].at.compare(T)<=0?R=W+1:H=W}let K=Z[Math.max(0,R-1)].state;return{...K,bpmScale:K.bpmScale.clone()}}},U=new Map;for(let T of i){let R=[{...T,start:T.start.clone(),end:T.end.clone()}];for(let W of c.get(T)??[])R=W(F,R)??R;let H,K;for(let W of R){if(!Number.isFinite(W.start.toNumber())||!Number.isFinite(W.end.toNumber())||W.start.compare(T.start)<0||W.end.compare(T.end)>0||W.end.compare(W.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]);(!H||W.start.compare(H)<0)&&(H=W.start),(!K||W.end.compare(K)>0)&&(K=W.end)}if(!H?.equals(T.start)||!K?.equals(T.end))throw new w("E_PLAYBACK_TRANSFORM_RANGE","\u58F0\u97F3\u5C55\u5F00\u5FC5\u987B\u4FDD\u6301\u539F\u97F3\u6BB5\u7684\u8D77\u6B62\u8FB9\u754C",T.sourceSpans[0]);U.set(T,R.map(W=>{let{start:at,end:lt,track:rt,midi:Mt,velocity:At,percussion:mn,origins:Vt,sourceSpans:Me}=W,ae=h++,Rt={kind:"note-on",at:at.clone(),noteId:ae,order:l++,track:rt,midi:Mt,velocity:At,percussion:mn,origins:[...Vt],sourceSpans:Me.map(V=>({...V}))},le={kind:"note-off",at:lt.clone(),noteId:ae,order:l++,origins:[...Vt]};return o.push(Rt,le),{on:Rt,off:le}}))}let Y=new Set,z=new Map;for(let T of _){let R=k.get(T);if(R)for(let H of U.get(T)){if(!H.off.at.equals(T.end))continue;let K=U.get(R).find(W=>!Y.has(W.on)&&W.on.at.equals(R.start)&&W.on.track===H.on.track&&W.on.midi===H.on.midi&&W.on.percussion===H.on.percussion);K&&(H.off.at.copyFrom(K.off.at),z.set(H.on,K.on),Y.add(K.on),Y.add(K.off))}}for(let T of z.keys())if(!Y.has(T))for(let R=z.get(T);R;R=z.get(R))T.sourceSpans.push(...R.sourceSpans);let Q=(Y.size?o.filter(T=>!Y.has(T)):o).sort(rr),X=cr(Q,r.tracks),ft=Q.at(-1)?.at;return ft&&ft.compare(C)>0&&C.copyFrom(ft),{events:X.events,scoreMap:b,tracks:X.tracks,performanceDuration:C,durationSeconds:un(X.events,C.toNumber()),diagnostics:n}}function Gt(r){return r.pages.length>0?r.pages.map(t=>t.bounds):[r.bounds]}function ss(r,t){for(let e of r.attachments)e.layer==="background"&&e.paint(t);for(let e of r.objects){e.paint(t);for(let n of e.decorations)n.paint?.(t)}for(let e of r.attachments)e.layer==="foreground"&&e.paint(t)}var os=class{pages;painters;constructor(t,e){this.pages=t,this.painters=e}route(t,e,n){let o=0,s=this.pages.length;for(;o<s;){let i=o+s>>>1,c=this.pages[i];c.y+c.h<t?o=i+1:s=i}for(let i=o;i<this.pages.length&&this.pages[i].y<=e;i++)n(this.painters[i])}drawText(t,e,n,o){this.route(n,n,s=>s.drawText(t,e,n,o))}drawLine(t,e,n,o,s){let i=(s?.strokeWidth??1)/2;this.route(Math.min(e,o)-i,Math.max(e,o)+i,c=>c.drawLine(t,e,n,o,s))}drawRect(t,e,n,o,s){let i=s?.stroke?(s.strokeWidth??1)/2:0;this.route(e-i,e+Math.max(0,o)+i,c=>{c.drawRect(t,e,n,o,s)})}drawCircle(t,e,n,o){let s=o?.stroke?(o.strokeWidth??1)/2:0,i=Math.max(0,n)+s;this.route(e-i,e+i,c=>c.drawCircle(t,e,n,o))}drawPath(t,e,n){if(t.length===0)return;let o=n?l=>n.y+l*n.scaleY:l=>l,s=1/0,i=-1/0,c=l=>{let h=o(l);s=Math.min(s,h),i=Math.max(i,h)};for(let l of t)l.op!=="Z"&&(l.op==="Q"&&c(l.cy),l.op==="C"&&(c(l.cy1),c(l.cy2)),c(l.y));if(!Number.isFinite(s))return;let a=e?.stroke?(e.strokeWidth??1)/2:0;this.route(s-a,i+a,l=>{l.drawPath(t,e,n)})}};function ce(r,t){let e=Gt(r);if(t.length!==e.length)throw new Error(`Expected ${e.length} page painters, got ${t.length}`);ss(r,new os(e,t))}var is=class{commands=[];replay(t){for(let e of this.commands)switch(e.kind){case"text":t.drawText(e.text,e.x,e.y,e.style);break;case"line":t.drawLine(e.x1,e.y1,e.x2,e.y2,e.style);break;case"rect":t.drawRect(e.x,e.y,e.w,e.h,e.style);break;case"circle":t.drawCircle(e.cx,e.cy,e.r,e.style);break;case"path":t.drawPath(e.commands,e.style);break}}drawText(t,e,n,o){this.commands.push({kind:"text",text:t,x:e,y:n,style:o})}drawLine(t,e,n,o,s){this.commands.push({kind:"line",x1:t,y1:e,x2:n,y2:o,style:s})}drawRect(t,e,n,o,s){this.commands.push({kind:"rect",x:t,y:e,w:n,h:o,style:s})}drawCircle(t,e,n,o){this.commands.push({kind:"circle",cx:t,cy:e,r:n,style:o})}drawPath(t,e,n){this.commands.push({kind:"path",commands:t.map(o=>qc(o,n)),style:e})}};function qc(r,t){if(!t||r.op==="Z")return{...r};let e=o=>t.x+o*t.scaleX,n=o=>t.y+o*t.scaleY;return r.op==="M"||r.op==="L"?{op:r.op,x:e(r.x),y:n(r.y)}:r.op==="Q"?{op:"Q",cx:e(r.cx),cy:n(r.cy),x:e(r.x),y:n(r.y)}:r.op==="C"?{op:"C",cx1:e(r.cx1),cy1:n(r.cy1),cx2:e(r.cx2),cy2:n(r.cy2),x:e(r.x),y:n(r.y)}:{...r}}function j(r){return Number.isFinite(r)?String(Math.round(r*1e3)/1e3):"0"}function ut(r){return r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Qc(r,t){let e=[],n=t?s=>j(t.x+s*t.scaleX):j,o=t?s=>j(t.y+s*t.scaleY):j;for(let s of r){if(s.op==="Z"){e.push("Z");continue}if(s.op==="M"||s.op==="L"){e.push(`${s.op}${n(s.x)} ${o(s.y)}`);continue}if(s.op==="Q"){e.push(`Q${n(s.cx)} ${o(s.cy)} ${n(s.x)} ${o(s.y)}`);continue}"cx1"in s&&e.push(`C${n(s.cx1)} ${o(s.cy1)} ${n(s.cx2)} ${o(s.cy2)} ${n(s.x)} ${o(s.y)}`)}return e.join(" ")}function Ne(r){return r?.opacity===void 0?"":` opacity="${j(r.opacity)}"`}var dn=class{body=[];drawText(t,e,n,o){let s=o.fontFamily??ee,i=o.fontWeight??"normal",c=o.fill??"#000",a=o.textAlign==="center"?"middle":o.textAlign==="right"?"end":"start";this.body.push(`<text x="${j(e)}" y="${j(n)}" font-family="${ut(s)}" font-size="${j(o.fontSize)}" font-weight="${ut(String(i))}" text-anchor="${a}" `+(o.fontStyle?`font-style="${ut(o.fontStyle)}" `:"")+`fill="${ut(c)}" xml:space="preserve"${Ne(o)}>${ut(t)}</text>`)}drawLine(t,e,n,o,s){let i=s?.stroke??s?.fill??"#000",c=s?.strokeWidth??1;this.body.push(`<line x1="${j(t)}" y1="${j(e)}" x2="${j(n)}" y2="${j(o)}" stroke="${ut(i)}" stroke-width="${j(c)}" stroke-linecap="round"${Ne(s)} />`)}drawRect(t,e,n,o,s){let i=s?.fill??"none",c=s?.stroke??"none",a=s?.strokeWidth??1;this.body.push(`<rect x="${j(t)}" y="${j(e)}" width="${j(Math.max(0,n))}" height="${j(Math.max(0,o))}" fill="${ut(i)}" stroke="${ut(c)}" stroke-width="${j(a)}"${Ne(s)} />`)}drawCircle(t,e,n,o){let s=o?.fill??"#000",i=o?.stroke??"none",c=o?.strokeWidth??1;this.body.push(`<circle cx="${j(t)}" cy="${j(e)}" r="${j(Math.max(0,n))}" fill="${ut(s)}" stroke="${ut(i)}" stroke-width="${j(c)}"${Ne(o)} />`)}drawPath(t,e,n){if(t.length===0)return;let o=Qc(t,n),s=e?.fill??"none",i=e?.stroke??"none",c=e?.strokeWidth??1;this.body.push(`<path d="${o}" fill="${ut(s)}" stroke="${ut(i)}" stroke-width="${j(c)}" stroke-linecap="round" stroke-linejoin="round"${Ne(e)} />`)}toSvg(t,e={}){let n=Math.max(0,e.padding??0),o=t.x-n,s=t.y-n,i=Math.max(1,t.w+n*2),c=Math.max(1,t.h+n*2),a=e.background?`<rect x="${j(o)}" y="${j(s)}" width="${j(i)}" height="${j(c)}" fill="${ut(e.background)}" />`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${j(i)}" height="${j(c)}" viewBox="${j(o)} ${j(s)} ${j(i)} ${j(c)}">${a}${this.body.join("")}</svg>`}};function Jc(r,t={}){let e=Gt(r),n=e.map(()=>new dn);return ce(r,n),n.map((o,s)=>o.toSvg(e[s],t))}function ta(r,t,e=0,n=0,o=1,s=1){r.beginPath();for(let i of t){if(i.op==="Z"){r.closePath();continue}if(i.op==="M"){r.moveTo(e+i.x*o,n+i.y*s);continue}if(i.op==="L"){r.lineTo(e+i.x*o,n+i.y*s);continue}if(i.op==="Q"){r.quadraticCurveTo(e+i.cx*o,n+i.cy*s,e+i.x*o,n+i.y*s);continue}"cx1"in i&&r.bezierCurveTo(e+i.cx1*o,n+i.cy1*s,e+i.cx2*o,n+i.cy2*s,e+i.x*o,n+i.y*s)}}function ve(r,t){t?.opacity!==void 0&&(r.globalAlpha*=t.opacity)}var xn=class{context;constructor(t){this.context=t}drawText(t,e,n,o){this.context.save(),ve(this.context,o),this.context.fillStyle=o.fill??"#000",this.context.font=ze(o),this.context.textAlign=o.textAlign??"left",this.context.textBaseline="alphabetic",this.context.fillText(t,e,n),this.context.restore()}drawLine(t,e,n,o,s){this.context.save(),ve(this.context,s),this.context.beginPath(),this.context.moveTo(t,e),this.context.lineTo(n,o),this.context.strokeStyle=s?.stroke??s?.fill??"#000",this.context.lineWidth=s?.strokeWidth??1,this.context.lineCap="round",this.context.stroke(),this.context.restore()}drawRect(t,e,n,o,s){n<0||o<0||(this.context.save(),ve(this.context,s),s?.fill&&(this.context.fillStyle=s.fill,this.context.fillRect(t,e,n,o)),s?.stroke&&(this.context.strokeStyle=s.stroke,this.context.lineWidth=s.strokeWidth??1,this.context.strokeRect(t,e,n,o)),this.context.restore())}drawCircle(t,e,n,o){n<0||(this.context.save(),ve(this.context,o),this.context.beginPath(),this.context.arc(t,e,n,0,Math.PI*2),(o?.fill??!0)&&(this.context.fillStyle=o?.fill??"#000",this.context.fill()),o?.stroke&&(this.context.strokeStyle=o.stroke,this.context.lineWidth=o.strokeWidth??1,this.context.stroke()),this.context.restore())}drawPath(t,e,n){t.length!==0&&(this.context.save(),ve(this.context,e),ta(this.context,t,n?.x,n?.y,n?.scaleX,n?.scaleY),e?.fill&&(this.context.fillStyle=e.fill,this.context.fill()),e?.stroke&&(this.context.strokeStyle=e.stroke,this.context.lineWidth=e.strokeWidth??1,this.context.lineCap="round",this.context.lineJoin="round",this.context.stroke()),this.context.restore())}};function ea(r,t){let e=Gt(r);if(t.length!==e.length)throw new Error(`Expected ${e.length} page contexts, got ${t.length}`);for(let[n,o]of t.entries())o.save(),o.translate(-e[n].x,-e[n].y);try{ce(r,t.map(n=>new xn(n)))}finally{for(let n of t)n.restore()}}var na=globalThis;Object.assign(na.jpfun??={},rs);})();
|