@tspro/web-music-score 5.3.0 → 5.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +6 -4
  3. package/dist/audio/index.d.mts +1 -1
  4. package/dist/audio/index.d.ts +1 -1
  5. package/dist/audio/index.js +3 -3
  6. package/dist/audio/index.mjs +6 -6
  7. package/dist/audio-cg/index.js +1 -1
  8. package/dist/audio-cg/index.mjs +3 -3
  9. package/dist/audio-synth/index.js +1 -1
  10. package/dist/audio-synth/index.mjs +3 -3
  11. package/dist/{chunk-C6UQDKWU.mjs → chunk-AUT4C6TY.mjs} +2 -2
  12. package/dist/{chunk-ZBA5XLYR.mjs → chunk-MHDBTCVG.mjs} +21 -21
  13. package/dist/{chunk-PMDIUO22.mjs → chunk-QGMOI7AP.mjs} +2 -2
  14. package/dist/chunk-ZWUBO5EW.mjs +37 -0
  15. package/dist/core/index.js +2 -2
  16. package/dist/core/index.mjs +6 -31
  17. package/dist/{guitar-BsSayRsH.d.ts → guitar-CarHGDAt.d.ts} +1 -1
  18. package/dist/{guitar-DdexKdN6.d.mts → guitar-DXlB-9vK.d.mts} +1 -1
  19. package/dist/iife/audio-cg.global.js +1 -1
  20. package/dist/iife/index.global.js +18 -11
  21. package/dist/{music-objects-Ih9vCl4p.d.ts → music-objects-3Esbz7ij.d.ts} +48 -243
  22. package/dist/{music-objects-BGiRQIXW.d.mts → music-objects-ONIuVUgs.d.mts} +48 -243
  23. package/dist/{note-CgCIBwvR.d.ts → note-CJuq5aBy.d.ts} +13 -1
  24. package/dist/{note-eA2xPPiG.d.mts → note-RVXvpfyV.d.mts} +13 -1
  25. package/dist/pieces/index.d.mts +3 -3
  26. package/dist/pieces/index.d.ts +3 -3
  27. package/dist/pieces/index.js +1 -1
  28. package/dist/pieces/index.mjs +2 -2
  29. package/dist/react-ui/index.d.mts +9 -9
  30. package/dist/react-ui/index.d.ts +9 -9
  31. package/dist/react-ui/index.js +12 -14
  32. package/dist/react-ui/index.mjs +14 -16
  33. package/dist/{scale-CBW4eTz7.d.ts → scale-C8gHC448.d.mts} +3 -3
  34. package/dist/{scale-DQP3b9Zx.d.mts → scale-DulPFco_.d.ts} +3 -3
  35. package/dist/score/index.d.mts +232 -6
  36. package/dist/score/index.d.ts +232 -6
  37. package/dist/score/index.js +981 -883
  38. package/dist/score/index.mjs +837 -769
  39. package/dist/{tempo-dkctPkCS.d.mts → tempo-BlCGZuYg.d.mts} +14 -2
  40. package/dist/{tempo-DMt3iwz9.d.ts → tempo-BnUjm25M.d.ts} +14 -2
  41. package/dist/theory/index.d.mts +6 -6
  42. package/dist/theory/index.d.ts +6 -6
  43. package/dist/theory/index.js +88 -86
  44. package/dist/theory/index.mjs +85 -81
  45. package/package.json +5 -4
@@ -1,4 +1,4 @@
1
- /* WebMusicScore v5.3.0 | (c) 2023 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
1
+ /* WebMusicScore v5.4.0 | (c) 2023 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
2
2
  "use strict";
3
3
  var __create = Object.create;
4
4
  var __defProp = Object.defineProperty;
@@ -78,7 +78,7 @@ __export(score_exports, {
78
78
  MTabRhythm: () => MTabRhythm,
79
79
  MTabSignature: () => MTabSignature,
80
80
  MText: () => MText,
81
- MusicInterface: () => MusicInterface6,
81
+ MusicInterface: () => MusicInterface5,
82
82
  Navigation: () => Navigation,
83
83
  NoteAnchor: () => NoteAnchor,
84
84
  PlayState: () => PlayState,
@@ -92,40 +92,45 @@ __export(score_exports, {
92
92
  VerticalPosition: () => VerticalPosition,
93
93
  getStringNumbers: () => getStringNumbers,
94
94
  getVerseNumbers: () => getVerseNumbers,
95
- getVoiceIds: () => getVoiceIds
95
+ getVoiceIds: () => getVoiceIds,
96
+ isStringNumber: () => isStringNumber,
97
+ isVerseNumber: () => isVerseNumber,
98
+ isVoiceId: () => isVoiceId,
99
+ validateStringNumber: () => validateStringNumber,
100
+ validateVerseNumber: () => validateVerseNumber,
101
+ validateVoiceId: () => validateVoiceId
96
102
  });
97
103
  module.exports = __toCommonJS(score_exports);
98
104
 
99
105
  // src/score/pub/div-rect.ts
100
106
  var import_ts_utils_lib = require("@tspro/ts-utils-lib");
101
- var import_core = require("@tspro/web-music-score/core");
102
107
  var DivRect = class _DivRect {
103
108
  constructor(...args) {
104
109
  __publicField(this, "left");
105
- __publicField(this, "centerX");
110
+ __publicField(this, "anchorX");
106
111
  __publicField(this, "right");
107
112
  __publicField(this, "top");
108
- __publicField(this, "centerY");
113
+ __publicField(this, "anchorY");
109
114
  __publicField(this, "bottom");
110
115
  if (args.length === 6) {
111
116
  this.left = args[0];
112
- this.centerX = args[1];
117
+ this.anchorX = args[1];
113
118
  this.right = args[2];
114
119
  this.top = args[3];
115
- this.centerY = args[4];
120
+ this.anchorY = args[4];
116
121
  this.bottom = args[5];
117
122
  } else if (args.length === 4) {
118
123
  this.left = args[0];
119
124
  this.right = args[1];
120
- this.centerX = (this.left + this.right) / 2;
125
+ this.anchorX = (this.left + this.right) / 2;
121
126
  this.top = args[2];
122
127
  this.bottom = args[3];
123
- this.centerY = (this.top + this.bottom) / 2;
128
+ this.anchorY = (this.top + this.bottom) / 2;
124
129
  } else if (args.length === 0) {
125
- this.left = this.centerX = this.right = 0;
126
- this.top = this.centerY = this.bottom = 0;
130
+ this.left = this.anchorX = this.right = 0;
131
+ this.top = this.anchorY = this.bottom = 0;
127
132
  } else {
128
- throw new import_core.MusicError(import_core.MusicErrorType.InvalidArg, `Invalid DivRect args: ${args}`);
133
+ throw new TypeError(`Invalid DivRect args: ${args}`);
129
134
  }
130
135
  }
131
136
  /**
@@ -133,7 +138,7 @@ var DivRect = class _DivRect {
133
138
  *
134
139
  * @param left - Left coordinate.
135
140
  * @param top - Top coordinate.
136
- * @param width - With.
141
+ * @param width - Width.
137
142
  * @param height - Height.
138
143
  * @returns - DivRect.
139
144
  */
@@ -141,7 +146,7 @@ var DivRect = class _DivRect {
141
146
  return new _DivRect(left, left + width, top, top + height);
142
147
  }
143
148
  /**
144
- * Create rect from centerX, centerY, width, height arguments.
149
+ * Create rect from anchorX, anchorY, width, height arguments.
145
150
  *
146
151
  * @param centerX - Center x-coordinate.
147
152
  * @param centerY - Center y-coordinate.
@@ -150,7 +155,14 @@ var DivRect = class _DivRect {
150
155
  * @returns - DivRect.
151
156
  */
152
157
  static createCentered(centerX, centerY, width, height) {
153
- return new _DivRect(centerX - width / 2, centerX + width / 2, centerY - height / 2, centerY + height / 2);
158
+ return new _DivRect(
159
+ centerX - width / 2,
160
+ centerX,
161
+ centerX + width / 2,
162
+ centerY - height / 2,
163
+ centerY,
164
+ centerY + height / 2
165
+ );
154
166
  }
155
167
  /**
156
168
  * Create rect from sections.
@@ -164,6 +176,22 @@ var DivRect = class _DivRect {
164
176
  static createSections(leftw, rightw, toph, bottomh) {
165
177
  return new _DivRect(-leftw, 0, rightw, -toph, 0, bottomh);
166
178
  }
179
+ /** @deprecated - Renamed to anchorX. */
180
+ get centerX() {
181
+ return this.anchorX;
182
+ }
183
+ /** @deprecated - Renamed to anchorX. */
184
+ set centerX(x) {
185
+ this.anchorX = x;
186
+ }
187
+ /** @deprecated - Renamed to anchorY. */
188
+ get centerY() {
189
+ return this.anchorY;
190
+ }
191
+ /** @deprecated - Renamed to anchorY. */
192
+ set centerY(y) {
193
+ this.anchorY = y;
194
+ }
167
195
  /**
168
196
  * Width getter.
169
197
  */
@@ -180,25 +208,25 @@ var DivRect = class _DivRect {
180
208
  * Left section width getter.
181
209
  */
182
210
  get leftw() {
183
- return this.centerX - this.left;
211
+ return this.anchorX - this.left;
184
212
  }
185
213
  /**
186
214
  * Right section width getter.
187
215
  */
188
216
  get rightw() {
189
- return this.right - this.centerX;
217
+ return this.right - this.anchorX;
190
218
  }
191
219
  /**
192
220
  * Top section height getter.
193
221
  */
194
222
  get toph() {
195
- return this.centerY - this.top;
223
+ return this.anchorY - this.top;
196
224
  }
197
225
  /**
198
226
  * Bottom section height getter.
199
227
  */
200
228
  get bottomh() {
201
- return this.bottom - this.centerY;
229
+ return this.bottom - this.anchorY;
202
230
  }
203
231
  /**
204
232
  * Does this Rect contain given (x, y)-point?
@@ -231,7 +259,7 @@ var DivRect = class _DivRect {
231
259
  return a.right > b.left && a.left < b.right;
232
260
  }
233
261
  /**
234
- * Check if this Rect equals with given Rect.
262
+ * Check if given rects are equal.
235
263
  * @param a - DivRect a.
236
264
  * @param b - DivRect b.
237
265
  * @returns - True/false.
@@ -242,17 +270,25 @@ var DivRect = class _DivRect {
242
270
  } else if (a == null || b == null) {
243
271
  return false;
244
272
  } else {
245
- return a === b || a.left === b.left && a.centerX === b.centerX && a.right === b.right && a.top === b.top && a.centerY === b.centerY && a.bottom === b.bottom;
273
+ return a === b || a.left === b.left && a.anchorX === b.anchorX && a.right === b.right && a.top === b.top && a.anchorY === b.anchorY && a.bottom === b.bottom;
246
274
  }
247
275
  }
248
276
  /**
249
- * Check if frame of this Rect equals with given Rect, ignoring center x- and center y-coordinates.
277
+ * Check if this rect equals with another rect.
278
+ * @param other - The other rect.
279
+ * @returns - True/false.
280
+ */
281
+ equals(other) {
282
+ return _DivRect.equals(this, other);
283
+ }
284
+ /**
285
+ * Check if edges of given rects are equal, ignoring anchorX and anchorY.
250
286
  *
251
287
  * @param a - DivRect a.
252
288
  * @param b - DivRect b.
253
289
  * @returns - True/false.
254
290
  */
255
- static equalsFrame(a, b) {
291
+ static equalsEdges(a, b) {
256
292
  if (a == null && b == null) {
257
293
  return true;
258
294
  } else if (a == null || b == null) {
@@ -261,13 +297,26 @@ var DivRect = class _DivRect {
261
297
  return a === b || a.left === b.left && a.right === b.right && a.top === b.top && a.bottom === b.bottom;
262
298
  }
263
299
  }
300
+ /**
301
+ * Check if edges of this Rect equals with given Rect, ignoring anchorX and anchorY.
302
+ *
303
+ * @param other - The other DivRect.
304
+ * @returns - True/false.
305
+ */
306
+ equalsEdges(other) {
307
+ return _DivRect.equalsEdges(this, other);
308
+ }
309
+ /** @deprecated - Use `DivRect.equalsEdges()` instead. */
310
+ static equalsFrame(a, b) {
311
+ return _DivRect.equalsEdges(a, b);
312
+ }
264
313
  /**
265
314
  * Created duplicate of this Rect.
266
315
  *
267
316
  * @returns - Duplicate.
268
317
  */
269
318
  copy() {
270
- return new _DivRect(this.left, this.centerX, this.right, this.top, this.centerY, this.bottom);
319
+ return new _DivRect(this.left, this.anchorX, this.right, this.top, this.anchorY, this.bottom);
271
320
  }
272
321
  /**
273
322
  * Move this rect by (dx, dy). Modifies this Rect.
@@ -278,10 +327,10 @@ var DivRect = class _DivRect {
278
327
  */
279
328
  offsetInPlace(dx, dy) {
280
329
  this.left += dx;
281
- this.centerX += dx;
330
+ this.anchorX += dx;
282
331
  this.right += dx;
283
332
  this.top += dy;
284
- this.centerY += dy;
333
+ this.anchorY += dy;
285
334
  this.bottom += dy;
286
335
  return this;
287
336
  }
@@ -326,10 +375,10 @@ var DivRect = class _DivRect {
326
375
  clipInPlace(clipRect) {
327
376
  this.left = Math.max(this.left, clipRect.left);
328
377
  this.right = Math.min(this.right, clipRect.right);
329
- this.centerX = import_ts_utils_lib.Utils.Math.clamp(this.centerX, this.left, this.right);
378
+ this.anchorX = import_ts_utils_lib.Utils.Math.clamp(this.anchorX, this.left, this.right);
330
379
  this.top = Math.max(this.top, clipRect.top);
331
380
  this.bottom = Math.min(this.bottom, clipRect.bottom);
332
- this.centerY = import_ts_utils_lib.Utils.Math.clamp(this.centerY, this.top, this.bottom);
381
+ this.anchorY = import_ts_utils_lib.Utils.Math.clamp(this.anchorY, this.top, this.bottom);
333
382
  return this;
334
383
  }
335
384
  /**
@@ -342,7 +391,7 @@ var DivRect = class _DivRect {
342
391
  return this.copy().clipInPlace(clipRect);
343
392
  }
344
393
  /**
345
- * Scale Rect. Anchor pos is (centerX, centerY). Modifies this Rect.
394
+ * Scale Rect. Anchor pos is (anchorX, anchorY). Modifies this Rect.
346
395
  *
347
396
  * @param scaleX - Scale x-amount.
348
397
  * @param scaleY - Scale y-amount. If undefined then scale x-amount is used.
@@ -350,14 +399,14 @@ var DivRect = class _DivRect {
350
399
  */
351
400
  scaleInPlace(scaleX, scaleY) {
352
401
  scaleY = scaleY != null ? scaleY : scaleX;
353
- this.left = this.centerX - this.leftw * scaleX;
354
- this.right = this.centerX + this.rightw * scaleX;
355
- this.top = this.centerY - this.toph * scaleY;
356
- this.bottom = this.centerY + this.bottomh * scaleY;
402
+ this.left = this.anchorX - this.leftw * scaleX;
403
+ this.right = this.anchorX + this.rightw * scaleX;
404
+ this.top = this.anchorY - this.toph * scaleY;
405
+ this.bottom = this.anchorY + this.bottomh * scaleY;
357
406
  return this;
358
407
  }
359
408
  /**
360
- * Scale Rect. Anchor pos is (centerX, centerY). Immutable, returns modified copy.
409
+ * Scale Rect. Anchor pos is (anchorX, anchorY). Immutable, returns modified copy.
361
410
  *
362
411
  * @param scaleX - Scale x-amount.
363
412
  * @param scaleY - Scale y-amount. If undefined then scale x-amount is used.
@@ -376,17 +425,47 @@ var DivRect = class _DivRect {
376
425
  };
377
426
 
378
427
  // src/score/pub/document-builder.ts
379
- var import_ts_utils_lib18 = require("@tspro/ts-utils-lib");
428
+ var import_ts_utils_lib32 = require("@tspro/ts-utils-lib");
429
+
430
+ // src/score/pub/types.ts
431
+ var import_ts_utils_lib2 = require("@tspro/ts-utils-lib");
432
+
433
+ // src/core/error.ts
434
+ var MusicErrorType = /* @__PURE__ */ ((MusicErrorType23) => {
435
+ MusicErrorType23[MusicErrorType23["Unknown"] = 0] = "Unknown";
436
+ MusicErrorType23[MusicErrorType23["InvalidArg"] = 1] = "InvalidArg";
437
+ MusicErrorType23[MusicErrorType23["Note"] = 2] = "Note";
438
+ MusicErrorType23[MusicErrorType23["Scale"] = 3] = "Scale";
439
+ MusicErrorType23[MusicErrorType23["KeySignature"] = 4] = "KeySignature";
440
+ MusicErrorType23[MusicErrorType23["Timesignature"] = 5] = "Timesignature";
441
+ MusicErrorType23[MusicErrorType23["Score"] = 6] = "Score";
442
+ MusicErrorType23[MusicErrorType23["Audio"] = 7] = "Audio";
443
+ return MusicErrorType23;
444
+ })(MusicErrorType || {});
445
+ function formatType(type) {
446
+ return type === void 0 ? "" : `[${MusicErrorType[type]}] `;
447
+ }
448
+ var MusicError = class extends Error {
449
+ constructor(...args) {
450
+ const [type, msg] = args.length === 1 ? [0 /* Unknown */, args[0]] : args;
451
+ super(formatType(type) + msg);
452
+ /** Music error type. */
453
+ __publicField(this, "type");
454
+ Object.setPrototypeOf(this, new.target.prototype);
455
+ this.name = "MusicError";
456
+ this.type = type;
457
+ }
458
+ };
380
459
 
381
460
  // src/score/pub/types.ts
382
- var StaffPreset = /* @__PURE__ */ ((StaffPreset3) => {
383
- StaffPreset3["Treble"] = "treble";
384
- StaffPreset3["Bass"] = "bass";
385
- StaffPreset3["Grand"] = "grand";
386
- StaffPreset3["GuitarTreble"] = "guitarTreble";
387
- StaffPreset3["GuitarTab"] = "guitarTab";
388
- StaffPreset3["GuitarCombined"] = "guitarCombined";
389
- return StaffPreset3;
461
+ var StaffPreset = /* @__PURE__ */ ((StaffPreset2) => {
462
+ StaffPreset2["Treble"] = "treble";
463
+ StaffPreset2["Bass"] = "bass";
464
+ StaffPreset2["Grand"] = "grand";
465
+ StaffPreset2["GuitarTreble"] = "guitarTreble";
466
+ StaffPreset2["GuitarTab"] = "guitarTab";
467
+ StaffPreset2["GuitarCombined"] = "guitarCombined";
468
+ return StaffPreset2;
390
469
  })(StaffPreset || {});
391
470
  var Clef = /* @__PURE__ */ ((Clef2) => {
392
471
  Clef2["G"] = "G";
@@ -396,12 +475,42 @@ var Clef = /* @__PURE__ */ ((Clef2) => {
396
475
  function getVoiceIds() {
397
476
  return [0, 1, 2, 3];
398
477
  }
478
+ function isVoiceId(voiceId) {
479
+ return import_ts_utils_lib2.Guard.isIncluded(voiceId, getVoiceIds());
480
+ }
481
+ function validateVoiceId(voiceId) {
482
+ if (isVoiceId(voiceId)) {
483
+ return voiceId;
484
+ } else {
485
+ throw new MusicError(6 /* Score */, `Voice id ${voiceId} is invalid!`);
486
+ }
487
+ }
399
488
  function getStringNumbers() {
400
489
  return [1, 2, 3, 4, 5, 6];
401
490
  }
491
+ function isStringNumber(stringNum) {
492
+ return import_ts_utils_lib2.Guard.isIncluded(stringNum, getStringNumbers());
493
+ }
494
+ function validateStringNumber(stringNum) {
495
+ if (isStringNumber(stringNum)) {
496
+ return stringNum;
497
+ } else {
498
+ throw new MusicError(6 /* Score */, `String number ${stringNum} is invalid!`);
499
+ }
500
+ }
402
501
  function getVerseNumbers() {
403
502
  return [1, 2, 3];
404
503
  }
504
+ function isVerseNumber(verse) {
505
+ return import_ts_utils_lib2.Guard.isIncluded(verse, getVerseNumbers());
506
+ }
507
+ function validateVerseNumber(verseNum) {
508
+ if (isVerseNumber(verseNum)) {
509
+ return verseNum;
510
+ } else {
511
+ throw new MusicError(6 /* Score */, `Verse number ${verseNum} is invalid!`);
512
+ }
513
+ }
405
514
  var Stem = /* @__PURE__ */ ((Stem2) => {
406
515
  Stem2["Auto"] = "auto";
407
516
  Stem2["Up"] = "up";
@@ -432,12 +541,12 @@ var Connective = /* @__PURE__ */ ((Connective2) => {
432
541
  Connective2["Slide"] = "slide";
433
542
  return Connective2;
434
543
  })(Connective || {});
435
- var VerticalPosition = /* @__PURE__ */ ((VerticalPosition4) => {
436
- VerticalPosition4["Auto"] = "auto";
437
- VerticalPosition4["Above"] = "above";
438
- VerticalPosition4["Below"] = "below";
439
- VerticalPosition4["Both"] = "both";
440
- return VerticalPosition4;
544
+ var VerticalPosition = /* @__PURE__ */ ((VerticalPosition3) => {
545
+ VerticalPosition3["Auto"] = "auto";
546
+ VerticalPosition3["Above"] = "above";
547
+ VerticalPosition3["Below"] = "below";
548
+ VerticalPosition3["Both"] = "both";
549
+ return VerticalPosition3;
441
550
  })(VerticalPosition || {});
442
551
  var LyricsAlign = /* @__PURE__ */ ((LyricsAlign2) => {
443
552
  LyricsAlign2["Left"] = "left";
@@ -508,6 +617,7 @@ var PlayState = /* @__PURE__ */ ((PlayState2) => {
508
617
  })(PlayState || {});
509
618
 
510
619
  // src/score/engine/music-object.ts
620
+ var import_ts_utils_lib3 = require("@tspro/ts-utils-lib");
511
621
  var MusicObjectLink = class {
512
622
  constructor(head) {
513
623
  __publicField(this, "head");
@@ -536,7 +646,7 @@ var MusicObject = class {
536
646
  this.parent = parent;
537
647
  __publicField(this, "anchoredLayoutObjects", []);
538
648
  __publicField(this, "link");
539
- __publicField(this, "rect", new DivRect());
649
+ __publicField(this, "rect", new import_ts_utils_lib3.AnchoredRect());
540
650
  __publicField(this, "needRectUpdate", true);
541
651
  }
542
652
  getParent() {
@@ -588,7 +698,7 @@ var import_theory12 = require("@tspro/web-music-score/theory");
588
698
  var import_theory11 = require("@tspro/web-music-score/theory");
589
699
 
590
700
  // src/score/engine/render-context.ts
591
- var import_ts_utils_lib3 = require("@tspro/ts-utils-lib");
701
+ var import_ts_utils_lib5 = require("@tspro/ts-utils-lib");
592
702
 
593
703
  // src/score/engine/settings.ts
594
704
  var DebugSettings = {
@@ -621,7 +731,7 @@ var DocumentSettings = {
621
731
  };
622
732
 
623
733
  // src/score/engine/render-context.ts
624
- var import_core3 = require("@tspro/web-music-score/core");
734
+ var import_core2 = require("@tspro/web-music-score/core");
625
735
 
626
736
  // src/score/engine/assets/F-clef.png
627
737
  var F_clef_default = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAABGCAYAAACQRffVAAADInpUWHRSYXcgcHJvZmlsZSB0eXBlIGV4aWYAAHja7VdbktwgDPznFDkCkgCJ4/AwVblBjp8GY+/OZFPZPD7yMVADWIiWUEt2jTu+fR3uCxplTi5EtZRT8mghh8wFC/Nnq2skH9a4mrS9R49yF9LeYIhkap6Pmbf8gBxr2s95G6FL/wK6FlSwim8bpWx5fZTXDcj2DLQ3hE7Lvu8DG0h4exTO57Y9Stn04Wp93xmKp8jefkGUU0ykAWNgr5oy1sY+KOLZp6PcznP31S7B9XypMnziQ0g8RpFweinzJ1IwJ4wk4qA4hUXiGlmWGTiUEG4Fbj6BR/F3MN/H5i1GP2mfuZaHkXFM5XdXu+envOn147y5VzsN3JU3lvaGPNLq0z1/KKd4AV0bctvh95at3ZYf5ENWdt3Nvad7jG5jXRq3KCEhFmlf6rrKWkGvziiuUwldfXLANSxmz+jmi2/Iqe4bKq1inYnB/aBAnQoNOtbcqMHFwAcrZubmWJbQQFLmhlQgCbPTYJUsXQwp0c4cEr59oWU2L3ONzHfnO0GVCWCEI3/c3WcVx5i1ROTtjBM8g188qxNeeAL9c4IaGKGxgxpXgK/+3CavAgbjCrPhgsVXd0LUSG/JJYvoSW/EfFY9ad8ACBFMRzhDAgZ8IomU4JEyKxECaSCowHWWwBUMUIzc4SQHkQRyUB2wjTNKS5Ujn2K8VSU4FGsSBTdZCsgKISJ/NBhyqESJIcaYokaLOZYkaVZeSprm67moaNCoSVXNadZiYsGiJVMzy1YyZ8HrO2bUabaccykwWoBccLpAoZTKVWqosaaq1Wp2tTSkTwstttS0WcutdO7SUeA9de3Wcy8HHUilIxzxSIceduSjDKTakBFGHGmoGzbyKDdrtMv2uf8Ga7RZ48XUVNSbNUhVLwiar5M4OQNjHAiEK1gDY0jsyZk3CoEnc5MzfI9QFZHhZJzkdJqMgcFwEMdBN3ebOcfl3/Dm1BZv/LfMuUndJ5n7kbePWOvzK9EWY2cZzqB6QfVh/7DCVubn9aez+5XCZ+cX0AvoBfQCegG9gP57oIEPJ/4Bue+bLIaQwqExNwAAAYVpQ0NQSUNDIHByb2ZpbGUAAHicfZE9SMNAHMVfU7UiFQeLijhkqE4WREUcSxWLYKG0FVp1MLn0Q2jSkKS4OAquBQc/FqsOLs66OrgKguAHiKuLk6KLlPi/pNAixoPjfry797h7Bwj1MlPNjiigapaRisfEbG5FDLyiC0EMYgIDEjP1RHohA8/xdQ8fX+8iPMv73J+jV8mbDPCJxFGmGxbxOvHMpqVz3icOsZKkEJ8Tjxt0QeJHrssuv3EuOizwzJCRSc0Rh4jFYhvLbcxKhko8TRxWVI3yhazLCuctzmq5ypr35C8M5rXlNNdpjiCORSSQhAgZVWygDAsRWjVSTKRoP+bhH3b8SXLJ5NoAI8c8KlAhOX7wP/jdrVmYmnSTgjGg88W2P0aBwC7QqNn297FtN04A/zNwpbX8lTow+0l6raWFj4C+beDiuqXJe8DlDjD0pEuG5Eh+mkKhALyf0TflgP5boGfV7a25j9MHIENdLd0AB4fAWJGy1zze3d3e279nmv39ANCccsygwwDVAAAQE2lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4KPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNC40LjAtRXhpdjIiPgogPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iCiAgICB4bWxuczpzdEV2dD0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlRXZlbnQjIgogICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICAgeG1sbnM6R0lNUD0iaHR0cDovL3d3dy5naW1wLm9yZy94bXAvIgogICAgeG1sbnM6dGlmZj0iaHR0cDovL25zLmFkb2JlLmNvbS90aWZmLzEuMC8iCiAgICB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iCiAgIHhtcE1NOkRvY3VtZW50SUQ9ImdpbXA6ZG9jaWQ6Z2ltcDo0MDc4NWMzNi00MDFkLTRhNmUtOTE4Ny0wNDU1MjgyYzRkZjYiCiAgIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6Nzg3YjYxN2YtMjg1MS00YzhlLTg2MTYtZWM3NGMwYzYwMWVlIgogICB4bXBNTTpPcmlnaW5hbERvY3VtZW50SUQ9InhtcC5kaWQ6ZTdhYTQxY2EtM2JiMy00ZTliLTk0NDEtOWU1M2ZlMmJmMzlmIgogICBkYzpGb3JtYXQ9ImltYWdlL3BuZyIKICAgR0lNUDpBUEk9IjIuMCIKICAgR0lNUDpQbGF0Zm9ybT0iV2luZG93cyIKICAgR0lNUDpUaW1lU3RhbXA9IjE2ODY2MTM5NDcxOTU2ODAiCiAgIEdJTVA6VmVyc2lvbj0iMi4xMC4zNCIKICAgdGlmZjpPcmllbnRhdGlvbj0iMSIKICAgeG1wOkNyZWF0b3JUb29sPSJHSU1QIDIuMTAiCiAgIHhtcDpNZXRhZGF0YURhdGU9IjIwMjM6MDY6MTNUMDI6NTI6MjUrMDM6MDAiCiAgIHhtcDpNb2RpZnlEYXRlPSIyMDIzOjA2OjEzVDAyOjUyOjI1KzAzOjAwIj4KICAgPHhtcE1NOkhpc3Rvcnk+CiAgICA8cmRmOlNlcT4KICAgICA8cmRmOmxpCiAgICAgIHN0RXZ0OmFjdGlvbj0ic2F2ZWQiCiAgICAgIHN0RXZ0OmNoYW5nZWQ9Ii8iCiAgICAgIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6MjczNjZiZjQtZWRkMy00MTk4LTk2MmEtZTllMzkxMGU1OGJlIgogICAgICBzdEV2dDpzb2Z0d2FyZUFnZW50PSJHaW1wIDIuMTAgKFdpbmRvd3MpIgogICAgICBzdEV2dDp3aGVuPSIyMDIyLTA4LTIyVDAyOjU1OjM2Ii8+CiAgICAgPHJkZjpsaQogICAgICBzdEV2dDphY3Rpb249InNhdmVkIgogICAgICBzdEV2dDpjaGFuZ2VkPSIvIgogICAgICBzdEV2dDppbnN0YW5jZUlEPSJ4bXAuaWlkOjk2NWUxMzc5LTBkOWYtNDk4Mi1hZDcwLTkzOGM5YzM5YTRmMyIKICAgICAgc3RFdnQ6c29mdHdhcmVBZ2VudD0iR2ltcCAyLjEwIChXaW5kb3dzKSIKICAgICAgc3RFdnQ6d2hlbj0iMjAyMi0wOS0xMVQxNjozNTowMCIvPgogICAgIDxyZGY6bGkKICAgICAgc3RFdnQ6YWN0aW9uPSJzYXZlZCIKICAgICAgc3RFdnQ6Y2hhbmdlZD0iLyIKICAgICAgc3RFdnQ6aW5zdGFuY2VJRD0ieG1wLmlpZDoxMGZiYTBhMy05MjliLTQ1NGUtOGM0Yy04ZWQ4YzhhYmFkZGMiCiAgICAgIHN0RXZ0OnNvZnR3YXJlQWdlbnQ9IkdpbXAgMi4xMCAoV2luZG93cykiCiAgICAgIHN0RXZ0OndoZW49IjIwMjMtMDYtMTBUMTc6NTA6MDkiLz4KICAgICA8cmRmOmxpCiAgICAgIHN0RXZ0OmFjdGlvbj0ic2F2ZWQiCiAgICAgIHN0RXZ0OmNoYW5nZWQ9Ii8iCiAgICAgIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6MDBmYjM4YTMtZjZiMi00NjQ1LTliMTYtMjlhNWE0ODZlMjhhIgogICAgICBzdEV2dDpzb2Z0d2FyZUFnZW50PSJHaW1wIDIuMTAgKFdpbmRvd3MpIgogICAgICBzdEV2dDp3aGVuPSIyMDIzLTA2LTEzVDAyOjUyOjI3Ii8+CiAgICA8L3JkZjpTZXE+CiAgIDwveG1wTU06SGlzdG9yeT4KICA8L3JkZjpEZXNjcmlwdGlvbj4KIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAKPD94cGFja2V0IGVuZD0idyI/PsIRrtIAAAAGYktHRAD/AP8A/6C9p5MAAAAJcEhZcwAALiMAAC4jAXilP3YAAAAHdElNRQfnBgwXNBsqJURsAAAAGXRFWHRDb21tZW50AENyZWF0ZWQgd2l0aCBHSU1QV4EOFwAABF9JREFUeNrtmluIF1Ucxz9/E8P1VnnJ9dJWC4Frmq2JJmqolGEILoQvK2gZeXlRCSm1Fx9UEsJQERWsXhRftECs0Gq70EK9ZHlbFyHbds3VVXFX91+7664P81tYhpnfmft//st84TzMzDm/8/vOnPO7nYEMGTJkyJAhQ4YMGSJBLkJZw4FyYAIwDHgU+A9oAxqBv4C7xfyySoBlwKfAFaAb6DG0euAzoAoYXCxEnwH2A60eCGrtFrALGJNWokNEwY6QRO2tFXgPGJAmss8DlyImam/fASPTQHaeGJueBFod8FQhrfSLwM+ynDX8L1/oV+BP4LZY58eBUUAlMB94ycPSvQTMERmJ4jGgwYPh2Qg84VFmGbAP6DTI/aoQS/lzg1JfA2MDyn4ZuGaQvyZJspUGv3oKGBhyjmeBJmWOmxLMJIITiiIXIgwaZgFdylxbDeNHANXAZmAVUBpEiScNe2xRxC/3Y2WuRmUlLRHD1rd/HljvV4F3FAVqYlhNo4B7Pl/wdPEMbmOq/ShwRBH0Vkxb6LAy536fW64HuOpn8vOKoLKYCC9Q5rzs0L/JQxDjyYPkgHYXAW0xGslByrLuFuPUFw0eCI92mmiAQ4LgZoEbYyTcAZxVPsJk271ag7x6cWueCLvhfsyu8LzybKLtersUF9ywxe2BnXBnAZOUJuXZeNv1OSki3LLdzwPrgONuguw+7g7wAHjEoW+vEagAXgeelr1yUSZoCUn4hvJsqMO9byRaWyLGtFkiwOtBJnYzBKcVg/ZuSMIrlHl3RrWMnFK1OqX/q8oXOAisDqFLVxL7xonw9yHk7Q5RoxpuyLdjI3wmhLzBwMqAY0ck4SGcCNeKIQqKOTF84RtxEu4BPgohc2QM467HSRjgqBL5mBDUPU1Rnl1JwqBNUuJqrW0M+OLdYuk8Cdas38Rf4b3FR0HP/nLdZNYaioKbxSVuA6ZGQfoNvNWlO6VvEKxW5O5yGbNc4ml7ZrUtCtLjgGMSdjop9Q+wMIT8GoXwKw79ZxrKUG9r+a8flMoyr5AA4ybwo1QgggYHpZJ6Ou3Ta5IpddvufwEsVWQ2xFisCI1Nypf6RMmsIql4JI0S8bFuSs9UvmCgikeh8b6i8C/KuKOYD+VShzGSwLsprRnByYYYoSqNhE8qCv/kYfxrYjT7jmuPIC+PBWsVsl1YRzBeE45qqWGtwjo1SR0WoZ8a7KAfYa5h7/2OVaPuF1gqtS83srclpi565IAP0c+b7wOz+wPZckOc3Jt0LC52oiXABx7y6VasGnfRYgiwwRAu9raGqPLXQmAGcADvvyN+m9bgXnP4i4E9wN8+KiJ5WQG5QilumnioJP9lwHPANKw/fF7A+fxJw2ms/y9SFdiPBf4Vn9hJNL8T/iFxbyoxgej+m6zBOtnLpXlvhiXcDOyVJV8UCEL4KnBI/OnAtBP0q+ADMTq/SfshrdUFr4TzwJdY9d57WIdYzRIk1GMdeXSQIUOGDBmSwUMtd8u2ArdcUAAAAABJRU5ErkJggg==";
@@ -630,8 +740,8 @@ var F_clef_default = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAABGCAYA
630
740
  var G_clef_default = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAACWCAYAAACCe+v6AAADHXpUWHRSYXcgcHJvZmlsZSB0eXBlIGV4aWYAAHja7ZZRcu0mDIbfWUWXgCSExHIwmJnu4C6/Pxg7J2kyTdv7GJhjsJCF0CfZJ5y//hzhDzRK5iGpeS45R7RUUuGKicerHetKMa3ratL2Gr2Xh5L3AkMkU/O6LbzlJ+SY074vexO69W9D94QqZvq2UOuWH+/lxzbI/tHQ9kDo2jn2/cA2JLw9Std92x7l4vbuaH2fGYqXyN9+SYyzZrKEa+JolgvmzjEZ4tmno6NxWYb0CugjuO9vVYZPfApJxFUkXV7K/IlUjBlXrAYokhhuFMK5UFbgI1DCBXha9kY1PsF8jc1bjL5o3zlWxCbjnMov1J7xQ97k/HnePLOdBg81z3tB3mON+Rk/lZPehu4Fefbh1529PTu/k4vE9BqK8Ip7jO5jHRqnqCkjFnkf6j7KmkHvmFFcT2V0izkgax2T2Qu6xxobcqrHhko7MC/EoDsoUadKg841NmpwMfHJhpG5BZYldEAq3GQmQ5qdBpsU6eLImHblkPDjC61ty9qukcceYieoMsEY4ZH/3MN3FceYtUQU/YoT0gJ+8axOeBEJ+OcANTCgsYOqK8B3/9gm18lMV5gdB6zxCJeJQ+ktuWSBFigqxgsyWd8GECJsrXCGBARiJlHK8MiYjQiBdACqcJ0l8QECpModTnISyYCD6sDeeMZoqbLyJcZbVVJAsWYUrYNQBayUFPljyZFDVUWTqmY1dS1as+RZeTlbnq/namLJ1LIZ3tlWrLp4cvXs5u7Fa+EieH1rQZ0WL6XUik0rLFc8XaFQ68GHHOnQIx92+FHCURvSp6WmLTdr3kqrnbt0FHjP3br30utJJ1LpTKee+bTTz3LWgVQbMtLQkYeF4aOM+lCjXbYf+7+gRpsaL1JT0R5qkJrdJmi+TnQyAzFOBOAGaiCGxJ7MolNKPMlNZvgeoSqU4aROOJ0mMRBMJ7EOethtcoHr7+EWzBc3/r/kwkT3TXJ/5/YZtT6/Em0Ru8pwBjUKqg/rp1f2Oj+vX47hnxS+O/4Y+jH0Y+jrcYwROv51hb8AKbCqdGIdCl0AAAGFaUNDUElDQyBwcm9maWxlAAB4nH2RPUjDQBzFX1O1UqoOdhBxyFCd7OAH0rFUsQgWSluhVQeTS7+gSUOS4uIouBYc/FisOrg46+rgKgiCHyCuLk6KLlLi/5JCi1gPjvvx7t7j7h0gNCpMNXuigKpZRioeE7O5VdH3ij74MYgpRCRm6on0YgZdx9c9PHy9C/Os7uf+HANK3mSARySOMt2wiDeI5zYtnfM+cZCVJIX4nHjSoAsSP3JddvmNc9FhgWcGjUxqnjhILBY7WO5gVjJU4lnikKJqlC9kXVY4b3FWKzXWuid/YSCvraS5TnMMcSwhgSREyKihjAoshGnVSDGRov1YF/+o40+SSyZXGYwcC6hCheT4wf/gd7dmYWbaTQrEgN4X2/4YB3y7QLNu29/Htt08AbzPwJXW9lcbQOST9HpbCx0BQ9vAxXVbk/eAyx1g5EmXDMmRvDSFQgF4P6NvygHDt4B/ze2ttY/TByBDXS3fAAeHwESRste7vLu/s7d/z7T6+wEMNXLkxtwRywAADzRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+Cjx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDQuNC4wLUV4aXYyIj4KIDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+CiAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgIHhtbG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vIgogICAgeG1sbnM6c3RFdnQ9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZUV2ZW50IyIKICAgIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIKICAgIHhtbG5zOkdJTVA9Imh0dHA6Ly93d3cuZ2ltcC5vcmcveG1wLyIKICAgIHhtbG5zOnRpZmY9Imh0dHA6Ly9ucy5hZG9iZS5jb20vdGlmZi8xLjAvIgogICAgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIgogICB4bXBNTTpEb2N1bWVudElEPSJnaW1wOmRvY2lkOmdpbXA6NDA3ODVjMzYtNDAxZC00YTZlLTkxODctMDQ1NTI4MmM0ZGY2IgogICB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjhiZTJkYzc1LTVlYjQtNDk0Yy1iNWRlLWQ2MzZkNzZhNjI2YiIKICAgeG1wTU06T3JpZ2luYWxEb2N1bWVudElEPSJ4bXAuZGlkOmU3YWE0MWNhLTNiYjMtNGU5Yi05NDQxLTllNTNmZTJiZjM5ZiIKICAgZGM6Rm9ybWF0PSJpbWFnZS9wbmciCiAgIEdJTVA6QVBJPSIyLjAiCiAgIEdJTVA6UGxhdGZvcm09IldpbmRvd3MiCiAgIEdJTVA6VGltZVN0YW1wPSIxNjg2NDA4NjA5MzE2NDM4IgogICBHSU1QOlZlcnNpb249IjIuMTAuMzQiCiAgIHRpZmY6T3JpZW50YXRpb249IjEiCiAgIHhtcDpDcmVhdG9yVG9vbD0iR0lNUCAyLjEwIgogICB4bXA6TWV0YWRhdGFEYXRlPSIyMDIzOjA2OjEwVDE3OjUwOjA5KzAzOjAwIgogICB4bXA6TW9kaWZ5RGF0ZT0iMjAyMzowNjoxMFQxNzo1MDowOSswMzowMCI+CiAgIDx4bXBNTTpIaXN0b3J5PgogICAgPHJkZjpTZXE+CiAgICAgPHJkZjpsaQogICAgICBzdEV2dDphY3Rpb249InNhdmVkIgogICAgICBzdEV2dDpjaGFuZ2VkPSIvIgogICAgICBzdEV2dDppbnN0YW5jZUlEPSJ4bXAuaWlkOjI3MzY2YmY0LWVkZDMtNDE5OC05NjJhLWU5ZTM5MTBlNThiZSIKICAgICAgc3RFdnQ6c29mdHdhcmVBZ2VudD0iR2ltcCAyLjEwIChXaW5kb3dzKSIKICAgICAgc3RFdnQ6d2hlbj0iMjAyMi0wOC0yMlQwMjo1NTozNiIvPgogICAgIDxyZGY6bGkKICAgICAgc3RFdnQ6YWN0aW9uPSJzYXZlZCIKICAgICAgc3RFdnQ6Y2hhbmdlZD0iLyIKICAgICAgc3RFdnQ6aW5zdGFuY2VJRD0ieG1wLmlpZDo5NjVlMTM3OS0wZDlmLTQ5ODItYWQ3MC05MzhjOWMzOWE0ZjMiCiAgICAgIHN0RXZ0OnNvZnR3YXJlQWdlbnQ9IkdpbXAgMi4xMCAoV2luZG93cykiCiAgICAgIHN0RXZ0OndoZW49IjIwMjItMDktMTFUMTY6MzU6MDAiLz4KICAgICA8cmRmOmxpCiAgICAgIHN0RXZ0OmFjdGlvbj0ic2F2ZWQiCiAgICAgIHN0RXZ0OmNoYW5nZWQ9Ii8iCiAgICAgIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6MTBmYmEwYTMtOTI5Yi00NTRlLThjNGMtOGVkOGM4YWJhZGRjIgogICAgICBzdEV2dDpzb2Z0d2FyZUFnZW50PSJHaW1wIDIuMTAgKFdpbmRvd3MpIgogICAgICBzdEV2dDp3aGVuPSIyMDIzLTA2LTEwVDE3OjUwOjA5Ii8+CiAgICA8L3JkZjpTZXE+CiAgIDwveG1wTU06SGlzdG9yeT4KICA8L3JkZjpEZXNjcmlwdGlvbj4KIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAKPD94cGFja2V0IGVuZD0idyI/Ppn4NIQAAAAGYktHRAD/AP8A/6C9p5MAAAAJcEhZcwAALiMAAC4jAXilP3YAAAAHdElNRQfnBgoOMgm5WlWBAAAAGXRFWHRDb21tZW50AENyZWF0ZWQgd2l0aCBHSU1QV4EOFwAACHtJREFUeNrtnXuQVmMcxz+77cauTWUpbGSVu2w3BpnUEBq3chkmBjGayG1GBuNWLtUgw5SJkBkjl4QKg1wyQyarK0lRSlstU20bWam9+OM8O3P6vc8553nOe97tnO18Z84f57zP7XvOc/ndnueFfQx5e6neUmAI0B3oDPwD/AJ8Dvzcml5we+Al4D+gyeOaB1S0BrLHAut9iLqvf4ERSSZbBmwwJOu+RieV8JwQZJuARjXWE4WBIck2X38AByaJ8MwsCTcBTyWFbCFQFwHhv4DiKBqUn2PCPYEin9+bgI3AUuBPn3TtgMuT8IWv8vlq7wLdRPrTgPke6d9JAuFbPBo/3UfKK1TCh8yzIQmEb/cYjx0C8pUDuzV5D477GN6mefY+UBuQby0wV/O8U9wJr9E8W2iY92vNs45xJ6zTfKoN827UPNsdd8K1SlJyo8Awb7XhEIkVYYAVmjXVBPtr1uyqJBBeLu5LDPMdppkPdiaRcHvDfKeJ+++SIFoCLBP3R1toWW58lhQFogiodwkPlYZf1y1w/AcclCQVcYWQtILwqiA8M2lGgDcFgSN90nbXiJUXRdWQ/BYiLMdxH5+0k8VavRb4JGmEl4j7vh7pRgDni2fj1RyQKBwiuqjui/Un015dBbQloXCbaTdrZuUajTp4IwnGbEHmKPX8QmCHhuwC9p4rKBI8IghdB0zCsT1Lsg0+4zwxuEiQqqcVmGWDlAETk+zSJE9Ublyjuqof2TrgxKQT7anMNSZfd1iSiZYCUwy+avP1dJLJXglsxdyV8hHQJolEDwBewc5v9J3Klzj0xYnTsCG7W4mdicMdwC7CeQaPTBLRAjUxZeMKvSwpZPcDPghBUGpE45JAthjH92NLdiUwSDz7NO5k24YkuwTHGZYvtKMtcSabD7wVguy37OkilU7v8rgSfjoE2c816+wkkebKOJK9NgTZ2Wpykxgu0k2IG9lTcMIBbchOx9tTWKHpBbFBoZpwbMi+iL9FtEC8wG1xIvyQJdlJhuVWinzd4kD2cJxYZlOyky3KfkHkvSoOhF+2IPu8Zdk3x82O1QV96JDumhJSu5KB4XsVEwzJziCcy2Z/8UK3K5G1PZnhDi2iBW02IDvPY501xY8BuvJ6JcY+AQzAPCDGGucZkF2GefiCxFk4AWoN2K0AG4HHiSBATWJqQMXr1Qxui3Jlv8o2nHiHIl4UFeF1+G/ACOMGuZVoYqfd12qgX7ZkuwZUMjyEoWBaxETd1y5gVDaEr/YpfGqIyW9ODsm6r7FhCY/z6T625tTpLUS2+bo3DOHZHoVdYFnOqBYmG3rbz1JNQbZ2p2MsZfAor604G8OMsUVTyEBLwjMsv4r7vkapl28AH+PEWNqu1++ZNjRPk3mFJdnjDBu4HBipVoUGsewVaGb6fjgRPSsMSQ8wNb/KjA9bEp5osIzcLUitEml6BNQxxGPoWVtROmoynmFJ+CefRvytxFaJt0W6GwwtqE8GkA56cZSSGVxiI74FhTUM9ch3f0irCerleNU3wbZL2xrJzwhp+hks0s6PaBitMsnsXk7WWlY8xKPi7fjvOZI94x/sHOQFPobGw+U4kHBvrrDVRrw2RE4L6C3V7Ln3sBg43qLeeuAxj996BxHeJCYxm2i4Gh8RMwjL/BpqgA/VpKgTgnwJuzdXtbWUWpZpntUCiwwlPDf6WBLeBSzWPO8URFjuHOthUWm1ptJFaizZErb9wvJjNaMkiLDck2CrYD8n7k13hUrCvUIYB3Vdui6I8FI1qzbjUstKXwe+EV3aBKtE40pwjsKwwQEeuoEv4d3ALNf9ycCpFpU24ngRVrvkYNN8y7Ps1rqlb3MQYXCc3m7YytOb1FCYa2lhzHbiqjAoU4s2GoG+D+Fg85VGijq/ssh7qEboqLGZB6QDvBLHdZpLnK6R0EzlgNs0hGfZVJ6v1lV3ARNzTLhYo0sfY5h3sYWy4ole7Blh16ismrnEStFok/ou05BdR8iA1QfJDN2/PoeEZZTQkwZL0RoN4bvCNiCPzONlGpVJNBe7Tu4TdX1h2bbmmLCCbMfWAvTew6iDQy/QzLReZJ/RtKk+pFiagXZqmdCdyzGG8J5Eic6aOuSe4yK8A+RGRfn2/SqqwdmbVBZBPX/gHbh2MfAbEbtbTAQEr7itehyX6DDCn6zyCZlhUHcoTc7Ltj2WHKNcLexBRvaFaqxdr0Q/k2OixmNudN9uo+BEMcsOAB4AzrXIU6vUxlrVU3YqJaMEOELZoUzW0PeBezz04JyjN07o0mZy7zD7EjiTmKAQOAfHJlyJ/xmWtsHlo1UPCI28FnoBJym9urtaYspwdrOUKkmprerC/6pl7lel/HdxlTORBB/7aIJnLSQuK40orlisUWRaNXpoxnHX1ky4DZlhTkNbc5duwAlNjLRb58f8Ky/e1wgv2dcmrr6aiSur3agFOWxsL6XM91a6crUSCWfi+H9NoDtEsIKY7YI52sNQ4D5uZpBFeTKMamScyJqeFL4L8yOjfhB5x8Rp0ppoaPEoBF4j86A/HerEfUlcCB8GXGGRvqPSZYPQIeAF7DXC/bE3fJsY2eWsvCEuhMtC9oouAROgPPxveVwIN4TM53f08tnifgfmh/nmnPC6kPk2+fx2k7ifpWb4WKAT9mG+foFvMqqvkRj+pYntFp0HPMrZj8wg1VieEd8Tc6NdFXr3TCFOgLc77TZifE7AaAOyv+MY9iS64pxBK7vyJXHWcLy8eu4T0dybo9vhBMBMJvMwwEbgzqSodnfhvxOtDieQzOv3ncRkE7UNytV4tJ295+LsnUgsugKPAt/jvQm7DmcX2+Bcj7eWRjFwAo4rtYOa1avUMrSTFClSpEiRIkWKFClSpEiRIkWKFClSpEiRIkWKFClSpEiRIgL8D6ed2EKeJMaTAAAAAElFTkSuQmCC";
631
741
 
632
742
  // src/theory/rhythm.ts
633
- var import_ts_utils_lib2 = require("@tspro/ts-utils-lib");
634
- var import_core2 = require("@tspro/web-music-score/core");
743
+ var import_ts_utils_lib4 = require("@tspro/ts-utils-lib");
744
+ var import_core = require("@tspro/web-music-score/core");
635
745
  var MaxTupletRatioValue = 12;
636
746
  var TicksMultiplier = 12 * 11 * 9 * 7 * 5;
637
747
  var NoteLength = /* @__PURE__ */ ((NoteLength9) => {
@@ -673,11 +783,14 @@ var NoteLength = /* @__PURE__ */ ((NoteLength9) => {
673
783
  NoteLength9["SixtyFourthTriplet"] = "64t";
674
784
  return NoteLength9;
675
785
  })(NoteLength || {});
786
+ function isNoteLength(noteLength) {
787
+ return import_ts_utils_lib4.Guard.isEnumValue(noteLength, NoteLength);
788
+ }
676
789
  function validateNoteLength(noteLength) {
677
- if (import_ts_utils_lib2.Utils.Is.isEnumValue(noteLength, NoteLength)) {
790
+ if (isNoteLength(noteLength)) {
678
791
  return noteLength;
679
792
  } else {
680
- throw new import_core2.MusicError(import_core2.MusicErrorType.InvalidArg, `Invalid noteLength: ${noteLength}`);
793
+ throw new import_core.MusicError(import_core.MusicErrorType.InvalidArg, `Invalid noteLength: ${noteLength}`);
681
794
  }
682
795
  }
683
796
  var _NoteLengthProps = class _NoteLengthProps {
@@ -704,15 +817,15 @@ var _NoteLengthProps = class _NoteLengthProps {
704
817
  this.noteSize = parseInt(noteLength);
705
818
  this.isTriplet = noteLength.endsWith("t");
706
819
  this.maxDotCount = this.isTriplet ? 0 : Math.floor(Math.log2(_NoteLengthProps.ShortestNoteSize / this.noteSize));
707
- this.dotCount = import_ts_utils_lib2.Utils.Str.charCount(noteLength, ".");
820
+ this.dotCount = import_ts_utils_lib4.Utils.Str.charCount(noteLength, ".");
708
821
  this.flagCount = this.noteSize > 4 ? Math.floor(Math.log2(this.noteSize / 4)) : 0;
709
822
  this.ticks = TicksMultiplier * _NoteLengthProps.ShortestNoteSize / this.noteSize;
710
823
  this.hasStem = this.noteSize > 1;
711
824
  this.isSolid = this.noteSize > 2;
712
825
  if (this.dotCount > this.maxDotCount) {
713
- throw new import_core2.MusicError(import_core2.MusicErrorType.Note, `dotCount ${this.dotCount} > maxDotCount ${this.maxDotCount}, for noteLength "${this.noteLength}".`);
826
+ throw new import_core.MusicError(import_core.MusicErrorType.Note, `dotCount ${this.dotCount} > maxDotCount ${this.maxDotCount}, for noteLength "${this.noteLength}".`);
714
827
  } else if (this.isTriplet && this.dotCount > 0) {
715
- throw new import_core2.MusicError(import_core2.MusicErrorType.Note, `noteLength "${this.noteLength}" is both triplet and dotted!`);
828
+ throw new import_core.MusicError(import_core.MusicErrorType.Note, `noteLength "${this.noteLength}" is both triplet and dotted!`);
716
829
  }
717
830
  }
718
831
  /**
@@ -721,11 +834,7 @@ var _NoteLengthProps = class _NoteLengthProps {
721
834
  * @returns - Note length props.
722
835
  */
723
836
  static get(noteLength) {
724
- let p = this.cache.get(noteLength);
725
- if (!p) {
726
- this.cache.set(noteLength, p = new _NoteLengthProps(noteLength));
727
- }
728
- return p;
837
+ return this.cache.getOrCreate(noteLength, () => new _NoteLengthProps(noteLength));
729
838
  }
730
839
  /**
731
840
  * Create note length props.
@@ -735,7 +844,7 @@ var _NoteLengthProps = class _NoteLengthProps {
735
844
  */
736
845
  static create(noteLength, dotCount = 0) {
737
846
  let noteSize = typeof noteLength === "number" ? noteLength : this.get(noteLength).noteSize;
738
- return this.get(noteSize + (import_ts_utils_lib2.Utils.Is.isIntegerGte(dotCount, 1) ? ".".repeat(dotCount) : "n"));
847
+ return this.get(noteSize + (import_ts_utils_lib4.Guard.isIntegerGte(dotCount, 1) ? ".".repeat(dotCount) : "n"));
739
848
  }
740
849
  /**
741
850
  * Compare note lengths/sizes. Whole (1) > half (2) > quarter (4), etc.
@@ -747,7 +856,7 @@ var _NoteLengthProps = class _NoteLengthProps {
747
856
  static cmp(a, b) {
748
857
  let aNoteSize = a instanceof _NoteLengthProps ? a.noteSize : typeof a === "number" ? a : _NoteLengthProps.get(a).noteSize;
749
858
  let bNoteSize = b instanceof _NoteLengthProps ? b.noteSize : typeof b === "number" ? b : _NoteLengthProps.get(b).noteSize;
750
- return import_ts_utils_lib2.Utils.Math.cmp(bNoteSize, aNoteSize);
859
+ return import_ts_utils_lib4.Utils.Math.cmp(bNoteSize, aNoteSize);
751
860
  }
752
861
  /**
753
862
  * Compare note lengths/sizes for equality.
@@ -763,16 +872,19 @@ var _NoteLengthProps = class _NoteLengthProps {
763
872
  }
764
873
  };
765
874
  /** Longest note size (e.g. 1 = whole note). */
766
- __publicField(_NoteLengthProps, "LongestNoteSize", Math.min(...import_ts_utils_lib2.Utils.Enum.getEnumValues(NoteLength).map((noteLength) => parseInt(noteLength))));
875
+ __publicField(_NoteLengthProps, "LongestNoteSize", Math.min(...import_ts_utils_lib4.Utils.Enum.getEnumValues(NoteLength).map((noteLength) => parseInt(noteLength))));
767
876
  /** Shortest note size (e.g. 64 = sixtyfourth note). */
768
- __publicField(_NoteLengthProps, "ShortestNoteSize", Math.max(...import_ts_utils_lib2.Utils.Enum.getEnumValues(NoteLength).map((noteLength) => parseInt(noteLength))));
769
- __publicField(_NoteLengthProps, "cache", /* @__PURE__ */ new Map());
877
+ __publicField(_NoteLengthProps, "ShortestNoteSize", Math.max(...import_ts_utils_lib4.Utils.Enum.getEnumValues(NoteLength).map((noteLength) => parseInt(noteLength))));
878
+ __publicField(_NoteLengthProps, "cache", new import_ts_utils_lib4.UniMap());
770
879
  var NoteLengthProps = _NoteLengthProps;
880
+ function isTupletRatio(tupletRatio) {
881
+ return import_ts_utils_lib4.Guard.isObject(tupletRatio) && import_ts_utils_lib4.Guard.isIntegerBetween(tupletRatio.parts, 2, MaxTupletRatioValue) && import_ts_utils_lib4.Guard.isIntegerBetween(tupletRatio.inTimeOf, 2, MaxTupletRatioValue);
882
+ }
771
883
  function validateTupletRatio(tupletRatio) {
772
- if (import_ts_utils_lib2.Utils.Is.isObject(tupletRatio) && import_ts_utils_lib2.Utils.Is.isIntegerBetween(tupletRatio.parts, 2, MaxTupletRatioValue) && import_ts_utils_lib2.Utils.Is.isIntegerBetween(tupletRatio.inTimeOf, 2, MaxTupletRatioValue)) {
884
+ if (isTupletRatio(tupletRatio)) {
773
885
  return tupletRatio;
774
886
  } else {
775
- throw new import_core2.MusicError(import_core2.MusicErrorType.Note, `Invalid tupletRatio ${JSON.stringify(tupletRatio)}`);
887
+ throw new import_core.MusicError(import_core.MusicErrorType.Note, `Invalid tupletRatio ${JSON.stringify(tupletRatio)}`);
776
888
  }
777
889
  }
778
890
  var Tuplet = {
@@ -809,7 +921,7 @@ var _RhythmProps = class _RhythmProps {
809
921
  this.dotCount = dotCount != null ? dotCount : p.dotCount;
810
922
  this.hasStem = p.hasStem;
811
923
  this.isSolidNoteHead = p.isSolid;
812
- if (import_ts_utils_lib2.Utils.Is.isObject(tupletRatio)) {
924
+ if (import_ts_utils_lib4.Guard.isObject(tupletRatio)) {
813
925
  this.tupletRatio = validateTupletRatio(tupletRatio);
814
926
  } else if (p.isTriplet) {
815
927
  this.tupletRatio = Tuplet.Triplet;
@@ -817,9 +929,9 @@ var _RhythmProps = class _RhythmProps {
817
929
  this.tupletRatio = void 0;
818
930
  }
819
931
  if (this.dotCount > 0 && this.tupletRatio !== void 0) {
820
- throw new import_core2.MusicError(import_core2.MusicErrorType.Note, `Note cannot be both dotted and tuplet!`);
932
+ throw new import_core.MusicError(import_core.MusicErrorType.Note, `Note cannot be both dotted and tuplet!`);
821
933
  } else if (this.dotCount > p.maxDotCount) {
822
- throw new import_core2.MusicError(import_core2.MusicErrorType.Note, `Too big dot count ${this.dotCount} for note length ${this.noteLength}.`);
934
+ throw new import_core.MusicError(import_core.MusicErrorType.Note, `Too big dot count ${this.dotCount} for note length ${this.noteLength}.`);
823
935
  }
824
936
  for (let add = this.ticks / 2, i = 1; i <= this.dotCount; i++, add /= 2) {
825
937
  this.ticks += add;
@@ -848,11 +960,7 @@ var _RhythmProps = class _RhythmProps {
848
960
  if (dotCount !== void 0 || tupletRatio !== void 0) {
849
961
  return new _RhythmProps(noteLength, dotCount, tupletRatio);
850
962
  } else {
851
- let rhythmProps = this.cache.get(noteLength);
852
- if (!rhythmProps) {
853
- this.cache.set(noteLength, rhythmProps = new _RhythmProps(noteLength));
854
- }
855
- return rhythmProps;
963
+ return this.cache.getOrCreate(noteLength, () => new _RhythmProps(noteLength));
856
964
  }
857
965
  }
858
966
  /**
@@ -862,7 +970,7 @@ var _RhythmProps = class _RhythmProps {
862
970
  * @returns - -1: a < b, 0: a === b, +1: a > b (duration comparisons)
863
971
  */
864
972
  static cmp(a, b) {
865
- return import_ts_utils_lib2.Utils.Math.cmp(a.ticks, b.ticks);
973
+ return import_ts_utils_lib4.Utils.Math.cmp(a.ticks, b.ticks);
866
974
  }
867
975
  /**
868
976
  * Compare duration equality of rhythm props.
@@ -874,15 +982,15 @@ var _RhythmProps = class _RhythmProps {
874
982
  return a.ticks === b.ticks;
875
983
  }
876
984
  };
877
- __publicField(_RhythmProps, "NoteSymbolMap", /* @__PURE__ */ new Map([[1, "\u{1D15D}"], [2, "\u{1D15E}"], [4, "\u{1D15F}"], [8, "\u{1D160}"], [16, "\u{1D161}"], [32, "\u{1D162}"], [64, "\u{1D163}"], [128, "\u{1D164}"]]));
878
- __publicField(_RhythmProps, "cache", /* @__PURE__ */ new Map());
985
+ __publicField(_RhythmProps, "NoteSymbolMap", new import_ts_utils_lib4.IndexArray([[1, "\u{1D15D}"], [2, "\u{1D15E}"], [4, "\u{1D15F}"], [8, "\u{1D160}"], [16, "\u{1D161}"], [32, "\u{1D162}"], [64, "\u{1D163}"], [128, "\u{1D164}"]]));
986
+ __publicField(_RhythmProps, "cache", new import_ts_utils_lib4.UniMap());
879
987
  var RhythmProps = _RhythmProps;
880
988
 
881
989
  // src/score/engine/render-context.ts
882
990
  var HilightStaffPosRectColor = "#55cc55";
883
991
  var HilightObjectRectColor = "#55cc55";
884
992
  var PlayPosIndicatorColor = "#44aa44";
885
- var ImageAssets = /* @__PURE__ */ new Map([
993
+ var ImageAssets = new import_ts_utils_lib5.UniMap([
886
994
  [0 /* G_Clef */, { src: G_clef_default }],
887
995
  [1 /* F_Clef */, { src: F_clef_default }]
888
996
  ]);
@@ -920,7 +1028,7 @@ var RenderContext = class {
920
1028
  __publicField(this, "onMouseLeaveFn");
921
1029
  __publicField(this, "onTouchEndFn");
922
1030
  this.devicePixelRatio = window.devicePixelRatio;
923
- this.fontSize = import_ts_utils_lib3.Device.FontSize * DocumentSettings.DocumentScale * this.devicePixelRatio;
1031
+ this.fontSize = import_ts_utils_lib5.Device.FontSize * DocumentSettings.DocumentScale * this.devicePixelRatio;
924
1032
  this.unitSize = this.fontSize * 0.3;
925
1033
  this._lineWidth = this.unitSize * 0.2;
926
1034
  ImageAssets.forEach((asset) => {
@@ -933,7 +1041,7 @@ var RenderContext = class {
933
1041
  };
934
1042
  img.onerror = () => {
935
1043
  this.finishImageAsset(asset);
936
- throw new import_core3.MusicError(import_core3.MusicErrorType.Score, "Failed to load image: " + asset.src);
1044
+ throw new import_core2.MusicError(import_core2.MusicErrorType.Score, "Failed to load image: " + asset.src);
937
1045
  };
938
1046
  }
939
1047
  });
@@ -951,7 +1059,7 @@ var RenderContext = class {
951
1059
  }
952
1060
  finishImageAsset(asset) {
953
1061
  asset.finished = true;
954
- let allFinished = Array.from(ImageAssets).every((asset2) => asset2[1].finished === true);
1062
+ let allFinished = ImageAssets.every((asset2) => asset2.finished === true);
955
1063
  if (allFinished) {
956
1064
  this.onLoad();
957
1065
  }
@@ -999,7 +1107,7 @@ var RenderContext = class {
999
1107
  return this.scoreEventListener !== void 0;
1000
1108
  }
1001
1109
  getMousePos(e) {
1002
- return new import_ts_utils_lib3.Vec2(e.offsetX, e.offsetY);
1110
+ return new import_ts_utils_lib5.Vec(e.offsetX, e.offsetY);
1003
1111
  }
1004
1112
  updateCurStaffPos(staffPos, click) {
1005
1113
  let changed = !staffPosEquals(staffPos, this.curStaffPos);
@@ -1216,7 +1324,7 @@ var RenderContext = class {
1216
1324
  toph = unitSize * (0.5 + flagCount - adj);
1217
1325
  bottomh = unitSize * (1 + flagCount + adj);
1218
1326
  }
1219
- return new DivRect(-leftw, 0, rightw, -toph, 0, bottomh);
1327
+ return new import_ts_utils_lib5.AnchoredRect(-leftw, 0, rightw, -toph, 0, bottomh);
1220
1328
  }
1221
1329
  drawRest(restSize, x, y) {
1222
1330
  let { unitSize } = this;
@@ -1402,7 +1510,7 @@ var RenderContext = class {
1402
1510
  this.ctx.font = savedFont;
1403
1511
  return metrics.width;
1404
1512
  } else {
1405
- return import_ts_utils_lib3.Utils.Dom.getCanvasTextWidth(text, font);
1513
+ return import_ts_utils_lib5.Utils.Dom.getCanvasTextWidth(text, font);
1406
1514
  }
1407
1515
  }
1408
1516
  arc(x, y, radius, startRadians, endRadians) {
@@ -1438,7 +1546,7 @@ var RenderContext = class {
1438
1546
  }
1439
1547
  drawBrace(rect, side) {
1440
1548
  if (this.ctx) {
1441
- let { left, right, width, top, bottom, centerY } = rect;
1549
+ let { left, right, width, top, bottom, anchorY } = rect;
1442
1550
  if (side === "right") {
1443
1551
  [left, right, width] = [right, left, -width];
1444
1552
  }
@@ -1448,18 +1556,18 @@ var RenderContext = class {
1448
1556
  left + width * 0.1,
1449
1557
  top,
1450
1558
  left + width * 0.8,
1451
- centerY,
1559
+ anchorY,
1452
1560
  left,
1453
- centerY
1561
+ anchorY
1454
1562
  );
1455
1563
  this.ctx.moveTo(right, bottom);
1456
1564
  this.ctx.bezierCurveTo(
1457
1565
  left + width * 0.1,
1458
1566
  bottom,
1459
1567
  left + width * 0.8,
1460
- centerY,
1568
+ anchorY,
1461
1569
  left,
1462
- centerY
1570
+ anchorY
1463
1571
  );
1464
1572
  this.ctx.stroke();
1465
1573
  }
@@ -1467,11 +1575,11 @@ var RenderContext = class {
1467
1575
  };
1468
1576
 
1469
1577
  // src/score/engine/obj-staff-and-tab.ts
1470
- var import_core16 = require("@tspro/web-music-score/core");
1471
- var import_ts_utils_lib15 = require("@tspro/ts-utils-lib");
1578
+ var import_core15 = require("@tspro/web-music-score/core");
1579
+ var import_ts_utils_lib28 = require("@tspro/ts-utils-lib");
1472
1580
 
1473
1581
  // src/score/engine/obj-measure.ts
1474
- var import_ts_utils_lib14 = require("@tspro/ts-utils-lib");
1582
+ var import_ts_utils_lib26 = require("@tspro/ts-utils-lib");
1475
1583
  var import_theory9 = require("@tspro/web-music-score/theory");
1476
1584
  var import_theory10 = require("@tspro/web-music-score/theory");
1477
1585
 
@@ -1501,6 +1609,7 @@ var AccidentalState = class {
1501
1609
  var import_theory2 = require("@tspro/web-music-score/theory");
1502
1610
 
1503
1611
  // src/score/engine/obj-image.ts
1612
+ var import_ts_utils_lib6 = require("@tspro/ts-utils-lib");
1504
1613
  var ObjImage = class extends MusicObject {
1505
1614
  constructor(parent, image, anchorX, anchorY, imageScale) {
1506
1615
  super(parent);
@@ -1523,9 +1632,9 @@ var ObjImage = class extends MusicObject {
1523
1632
  try {
1524
1633
  let w = image.naturalWidth * imageScale * unitSize;
1525
1634
  let h = image.naturalHeight * imageScale * unitSize;
1526
- this.rect = DivRect.createSections(w * anchorX, w * (1 - anchorX), h * anchorY, h * (1 - anchorY));
1635
+ this.rect = import_ts_utils_lib6.AnchoredRect.createSections(w * anchorX, w * (1 - anchorX), h * anchorY, h * (1 - anchorY));
1527
1636
  } catch (err) {
1528
- this.rect = new DivRect();
1637
+ this.rect = new import_ts_utils_lib6.AnchoredRect();
1529
1638
  }
1530
1639
  }
1531
1640
  offset(dx, dy) {
@@ -1534,12 +1643,13 @@ var ObjImage = class extends MusicObject {
1534
1643
  draw(ctx) {
1535
1644
  let r = this.rect;
1536
1645
  ctx.drawDebugRect(r);
1537
- ctx.drawImage(this.image, r.centerX - r.leftw, r.centerY - r.toph, r.width, r.height);
1646
+ ctx.drawImage(this.image, r.anchorX - r.leftw, r.anchorY - r.toph, r.width, r.height);
1538
1647
  }
1539
1648
  };
1540
1649
 
1541
1650
  // src/score/engine/obj-accidental.ts
1542
- var import_core4 = require("@tspro/web-music-score/core");
1651
+ var import_core3 = require("@tspro/web-music-score/core");
1652
+ var import_ts_utils_lib7 = require("@tspro/ts-utils-lib");
1543
1653
  var ObjAccidental = class extends MusicObject {
1544
1654
  constructor(parent, diatonicId, accidental, color = "black") {
1545
1655
  super(parent);
@@ -1559,22 +1669,22 @@ var ObjAccidental = class extends MusicObject {
1559
1669
  let { unitSize } = ctx;
1560
1670
  switch (this.accidental) {
1561
1671
  case -2:
1562
- this.rect = DivRect.createSections(unitSize * 1.25, unitSize * 1.25, unitSize * 4, unitSize * 1.2);
1672
+ this.rect = import_ts_utils_lib7.AnchoredRect.createSections(unitSize * 1.25, unitSize * 1.25, unitSize * 4, unitSize * 1.2);
1563
1673
  break;
1564
1674
  case -1:
1565
- this.rect = DivRect.createSections(unitSize * 0.75, unitSize * 0.75, unitSize * 4, unitSize * 1.2);
1675
+ this.rect = import_ts_utils_lib7.AnchoredRect.createSections(unitSize * 0.75, unitSize * 0.75, unitSize * 4, unitSize * 1.2);
1566
1676
  break;
1567
1677
  case 0:
1568
- this.rect = DivRect.createSections(unitSize * 0.75, unitSize * 0.75, unitSize * 2.2, unitSize * 2.2);
1678
+ this.rect = import_ts_utils_lib7.AnchoredRect.createSections(unitSize * 0.75, unitSize * 0.75, unitSize * 2.2, unitSize * 2.2);
1569
1679
  break;
1570
1680
  case 1:
1571
- this.rect = DivRect.createSections(unitSize * 0.75, unitSize * 0.75, unitSize * 2, unitSize * 2);
1681
+ this.rect = import_ts_utils_lib7.AnchoredRect.createSections(unitSize * 0.75, unitSize * 0.75, unitSize * 2, unitSize * 2);
1572
1682
  break;
1573
1683
  case 2:
1574
- this.rect = DivRect.createSections(unitSize * 1, unitSize * 1, unitSize * 1, unitSize * 1);
1684
+ this.rect = import_ts_utils_lib7.AnchoredRect.createSections(unitSize * 1, unitSize * 1, unitSize * 1, unitSize * 1);
1575
1685
  break;
1576
1686
  default:
1577
- throw new import_core4.MusicError(import_core4.MusicErrorType.Score, "Invalid accidental value: " + this.accidental);
1687
+ throw new import_core3.MusicError(import_core3.MusicErrorType.Score, "Invalid accidental value: " + this.accidental);
1578
1688
  }
1579
1689
  }
1580
1690
  offset(dx, dy) {
@@ -1584,8 +1694,8 @@ var ObjAccidental = class extends MusicObject {
1584
1694
  ctx.drawDebugRect(this.rect);
1585
1695
  let { unitSize } = ctx;
1586
1696
  let { accidental } = this;
1587
- let x = this.rect.centerX;
1588
- let y = this.rect.centerY;
1697
+ let x = this.rect.anchorX;
1698
+ let y = this.rect.anchorY;
1589
1699
  ctx.color(this.color);
1590
1700
  const draw_b = (x2, y2) => {
1591
1701
  ctx.lineWidth(1).beginPath().moveTo(x2 - unitSize * 0.75, y2 - unitSize * 4).lineTo(x2 - unitSize * 0.75, y2 + unitSize * 1.1).bezierCurveTo(
@@ -1614,6 +1724,7 @@ var ObjAccidental = class extends MusicObject {
1614
1724
  };
1615
1725
 
1616
1726
  // src/score/engine/obj-text.ts
1727
+ var import_ts_utils_lib8 = require("@tspro/ts-utils-lib");
1617
1728
  var DefaultBoxedPadding = 0.5;
1618
1729
  var ObjText = class extends MusicObject {
1619
1730
  constructor(parent, text, anchorX, anchorY) {
@@ -1650,7 +1761,7 @@ var ObjText = class extends MusicObject {
1650
1761
  if (this.textLines.length === 0) {
1651
1762
  this.textLines = [""];
1652
1763
  }
1653
- this.rect = new DivRect();
1764
+ this.rect = new import_ts_utils_lib8.AnchoredRect();
1654
1765
  this.mi = new MText(this);
1655
1766
  }
1656
1767
  getMusicInterface() {
@@ -1662,14 +1773,14 @@ var ObjText = class extends MusicObject {
1662
1773
  updateAnchorX(anchorX) {
1663
1774
  this.anchorX = anchorX;
1664
1775
  let { width } = this.rect;
1665
- this.rect.left = this.rect.centerX - width * anchorX;
1666
- this.rect.right = this.rect.centerX + width * (1 - anchorX);
1776
+ this.rect.left = this.rect.anchorX - width * anchorX;
1777
+ this.rect.right = this.rect.anchorX + width * (1 - anchorX);
1667
1778
  }
1668
1779
  updateAnchorY(anchorY) {
1669
1780
  this.anchorY = anchorY;
1670
1781
  let { height } = this.rect;
1671
- this.rect.top = this.rect.centerY - height * anchorY;
1672
- this.rect.bottom = this.rect.centerY + height * (1 - anchorY);
1782
+ this.rect.top = this.rect.anchorY - height * anchorY;
1783
+ this.rect.bottom = this.rect.anchorY + height * (1 - anchorY);
1673
1784
  }
1674
1785
  pick(x, y) {
1675
1786
  return this.rect.contains(x, y) ? [this] : [];
@@ -1686,7 +1797,7 @@ var ObjText = class extends MusicObject {
1686
1797
  if (this.boxed === "square" || this.boxed === "circle") {
1687
1798
  h = w = Math.max(h, w);
1688
1799
  }
1689
- this.rect = DivRect.createSections(w * anchorX, w * (1 - anchorX), h * anchorY, h * (1 - anchorY));
1800
+ this.rect = import_ts_utils_lib8.AnchoredRect.createSections(w * anchorX, w * (1 - anchorX), h * anchorY, h * (1 - anchorY));
1690
1801
  }
1691
1802
  offset(dx, dy) {
1692
1803
  this.rect.offsetInPlace(dx, dy);
@@ -1708,12 +1819,12 @@ var ObjText = class extends MusicObject {
1708
1819
  let textHeight = lineCount * lineHeight;
1709
1820
  let fixY = -lineHeight * (italic ? 0.25 : 0.2);
1710
1821
  let p = padding * ctx.unitSize;
1711
- let centerX = (rect.left + p) * (1 - anchorX) + (rect.right - p) * anchorX;
1712
- let centerY = (rect.top + p) * (1 - anchorY) + (rect.bottom - p) * anchorY;
1822
+ let aX = (rect.left + p) * (1 - anchorX) + (rect.right - p) * anchorX;
1823
+ let aY = (rect.top + p) * (1 - anchorY) + (rect.bottom - p) * anchorY;
1713
1824
  ctx.color(this.color);
1714
1825
  this.textLines.forEach((textLine, i) => {
1715
- let x = centerX - lineWidths[i] * anchorX;
1716
- let y = centerY - textHeight * anchorY + lineHeight * (i + 1) + fixY;
1826
+ let x = aX - lineWidths[i] * anchorX;
1827
+ let y = aY - textHeight * anchorY + lineHeight * (i + 1) + fixY;
1717
1828
  ctx.fillText(textLine, x, y);
1718
1829
  });
1719
1830
  switch (this.boxed) {
@@ -1723,12 +1834,8 @@ var ObjText = class extends MusicObject {
1723
1834
  break;
1724
1835
  case "circle":
1725
1836
  case "ellipse":
1726
- let x = (rect.left + rect.right) / 2;
1727
- let y = (rect.top + rect.bottom) / 2;
1728
- let rx = (rect.right - rect.left) / 2;
1729
- let ry = (rect.bottom - rect.top) / 2;
1730
1837
  ctx.beginPath();
1731
- ctx.ellipse(x, y, rx, ry, 0, 0, 2 * Math.PI);
1838
+ ctx.ellipse(rect.centerX, rect.centerY, rect.width / 2, rect.height / 2, 0, 0, 2 * Math.PI);
1732
1839
  ctx.stroke();
1733
1840
  break;
1734
1841
  }
@@ -1736,7 +1843,8 @@ var ObjText = class extends MusicObject {
1736
1843
  };
1737
1844
 
1738
1845
  // src/score/engine/obj-signature.ts
1739
- var import_core5 = require("@tspro/web-music-score/core");
1846
+ var import_core4 = require("@tspro/web-music-score/core");
1847
+ var import_ts_utils_lib9 = require("@tspro/ts-utils-lib");
1740
1848
  var ObjStaffSignature = class extends MusicObject {
1741
1849
  constructor(measure, staff) {
1742
1850
  super(measure);
@@ -1832,7 +1940,7 @@ var ObjStaffSignature = class extends MusicObject {
1832
1940
  if (bottomAccidentalDiatonicId !== void 0) {
1833
1941
  return import_theory2.Note.findNextDiatonicIdAbove(accNote.diatonicId, bottomAccidentalDiatonicId, false);
1834
1942
  } else {
1835
- throw new import_core5.MusicError(import_core5.MusicErrorType.Score, "Cannot get accidental diatonicId because note has no accidental.");
1943
+ throw new import_core4.MusicError(import_core4.MusicErrorType.Score, "Cannot get accidental diatonicId because note has no accidental.");
1836
1944
  }
1837
1945
  }
1838
1946
  pick(x, y) {
@@ -1895,7 +2003,7 @@ var ObjStaffSignature = class extends MusicObject {
1895
2003
  let { staff } = this;
1896
2004
  let paddingX = unitSize;
1897
2005
  let x = 0;
1898
- this.rect = new DivRect();
2006
+ this.rect = new import_ts_utils_lib9.AnchoredRect();
1899
2007
  if (this.clefImage) {
1900
2008
  x += paddingX;
1901
2009
  this.clefImage.layout(ctx);
@@ -1905,7 +2013,7 @@ var ObjStaffSignature = class extends MusicObject {
1905
2013
  if (this.eightBelowClef) {
1906
2014
  let r = this.clefImage.getRect();
1907
2015
  this.eightBelowClef.layout(ctx);
1908
- this.eightBelowClef.offset(r.left + r.width / 2, Math.max(r.centerY + r.height * 0.3, staff.getBottomLineY()));
2016
+ this.eightBelowClef.offset(r.centerX, Math.max(r.anchorY + r.height * 0.3, staff.getBottomLineY()));
1909
2017
  this.rect.expandInPlace(this.eightBelowClef.getRect());
1910
2018
  }
1911
2019
  }
@@ -2064,7 +2172,7 @@ var ObjTabSignature = class extends MusicObject {
2064
2172
  let paddingX = unitSize;
2065
2173
  let x = 0;
2066
2174
  let topLineY = tab.getTopLineY();
2067
- this.rect = new DivRect();
2175
+ this.rect = new import_ts_utils_lib9.AnchoredRect();
2068
2176
  if (this.measureNumber) {
2069
2177
  this.measureNumber.layout(ctx);
2070
2178
  this.measureNumber.offset(0, topLineY);
@@ -2075,11 +2183,11 @@ var ObjTabSignature = class extends MusicObject {
2075
2183
  (_b = this.beatSizeText) == null ? void 0 : _b.layout(ctx);
2076
2184
  let tsWidth = Math.max((_d = (_c = this.beatCountText) == null ? void 0 : _c.getRect().width) != null ? _d : 0, (_f = (_e = this.beatSizeText) == null ? void 0 : _e.getRect().width) != null ? _f : 0);
2077
2185
  if (this.beatCountText) {
2078
- this.beatCountText.offset(0 + tsWidth / 2 + paddingX, tab.getRect().centerY - this.beatCountText.getRect().bottomh);
2186
+ this.beatCountText.offset(0 + tsWidth / 2 + paddingX, tab.getRect().anchorY - this.beatCountText.getRect().bottomh);
2079
2187
  this.rect.expandInPlace(this.beatCountText.getRect());
2080
2188
  }
2081
2189
  if (this.beatSizeText) {
2082
- this.beatSizeText.offset(0 + tsWidth / 2 + paddingX, tab.getRect().centerY + this.beatSizeText.getRect().toph);
2190
+ this.beatSizeText.offset(0 + tsWidth / 2 + paddingX, tab.getRect().anchorY + this.beatSizeText.getRect().toph);
2083
2191
  this.rect.expandInPlace(this.beatSizeText.getRect());
2084
2192
  }
2085
2193
  if (this.tempoText) {
@@ -2107,7 +2215,7 @@ var ObjTabSignature = class extends MusicObject {
2107
2215
  };
2108
2216
 
2109
2217
  // src/score/engine/player.ts
2110
- var import_ts_utils_lib7 = require("@tspro/ts-utils-lib");
2218
+ var import_ts_utils_lib16 = require("@tspro/ts-utils-lib");
2111
2219
  var import_theory6 = require("@tspro/web-music-score/theory");
2112
2220
  var Audio = __toESM(require("@tspro/web-music-score/audio"));
2113
2221
 
@@ -2115,6 +2223,7 @@ var Audio = __toESM(require("@tspro/web-music-score/audio"));
2115
2223
  var import_theory5 = require("@tspro/web-music-score/theory");
2116
2224
 
2117
2225
  // src/score/engine/obj-arpeggio.ts
2226
+ var import_ts_utils_lib10 = require("@tspro/ts-utils-lib");
2118
2227
  var ObjArpeggio = class extends MusicObject {
2119
2228
  constructor(col, line, arpeggioDir) {
2120
2229
  super(col);
@@ -2145,7 +2254,7 @@ var ObjArpeggio = class extends MusicObject {
2145
2254
  this.numCycles = Math.ceil((bottom - top) / this.cycleHeight) + 2;
2146
2255
  let width = unitSize * 2;
2147
2256
  let height = this.numCycles * this.cycleHeight;
2148
- this.rect = new DivRect(-width / 2, width / 2, -height / 2 - this.topArrowHeight, height / 2 + this.bottomArrowHeight);
2257
+ this.rect = new import_ts_utils_lib10.AnchoredRect(-width / 2, width / 2, -height / 2 - this.topArrowHeight, height / 2 + this.bottomArrowHeight);
2149
2258
  }
2150
2259
  offset(dx, dy) {
2151
2260
  this.rect.offsetInPlace(dx, dy);
@@ -2157,21 +2266,21 @@ var ObjArpeggio = class extends MusicObject {
2157
2266
  ctx.lineWidth(2);
2158
2267
  ctx.beginPath();
2159
2268
  for (let i = 0, y = rect.top + topArrowHeight; i < this.numCycles; i++, y += this.cycleHeight) {
2160
- ctx.moveTo(rect.centerX, y);
2161
- ctx.quadraticCurveTo(rect.left, y + this.cycleHeight / 4, rect.centerX, y + this.cycleHeight / 2);
2162
- ctx.quadraticCurveTo(rect.right, y + this.cycleHeight * 3 / 4, rect.centerX, y + this.cycleHeight);
2269
+ ctx.moveTo(rect.anchorX, y);
2270
+ ctx.quadraticCurveTo(rect.left, y + this.cycleHeight / 4, rect.anchorX, y + this.cycleHeight / 2);
2271
+ ctx.quadraticCurveTo(rect.right, y + this.cycleHeight * 3 / 4, rect.anchorX, y + this.cycleHeight);
2163
2272
  }
2164
2273
  ctx.stroke();
2165
2274
  if (topArrowHeight > 0) {
2166
2275
  ctx.beginPath();
2167
- ctx.moveTo(rect.centerX, rect.top);
2276
+ ctx.moveTo(rect.anchorX, rect.top);
2168
2277
  ctx.lineTo(rect.right, rect.top + topArrowHeight);
2169
2278
  ctx.lineTo(rect.left, rect.top + topArrowHeight);
2170
2279
  ctx.fill();
2171
2280
  }
2172
2281
  if (bottomArrowHeight > 0) {
2173
2282
  ctx.beginPath();
2174
- ctx.moveTo(rect.centerX, rect.bottom);
2283
+ ctx.moveTo(rect.anchorX, rect.bottom);
2175
2284
  ctx.lineTo(rect.left, rect.bottom - bottomArrowHeight);
2176
2285
  ctx.lineTo(rect.right, rect.bottom - bottomArrowHeight);
2177
2286
  ctx.fill();
@@ -2181,7 +2290,8 @@ var ObjArpeggio = class extends MusicObject {
2181
2290
 
2182
2291
  // src/score/engine/obj-rest.ts
2183
2292
  var import_theory3 = require("@tspro/web-music-score/theory");
2184
- var import_core6 = require("@tspro/web-music-score/core");
2293
+ var import_core5 = require("@tspro/web-music-score/core");
2294
+ var import_ts_utils_lib11 = require("@tspro/ts-utils-lib");
2185
2295
  function getDiatonicIdFromStaffPos(staffPos) {
2186
2296
  if (typeof staffPos === "number") {
2187
2297
  return import_theory3.Note.getChromaticNote(staffPos).diatonicId;
@@ -2198,7 +2308,7 @@ var ObjStaffRest = class extends MusicObject {
2198
2308
  super(staff);
2199
2309
  this.staff = staff;
2200
2310
  this.rest = rest;
2201
- __publicField(this, "restRect", new DivRect());
2311
+ __publicField(this, "restRect", new import_ts_utils_lib11.AnchoredRect());
2202
2312
  __publicField(this, "dotRects", []);
2203
2313
  __publicField(this, "mi");
2204
2314
  staff.addObject(this);
@@ -2217,7 +2327,7 @@ var ObjStaffRest = class extends MusicObject {
2217
2327
  this.rest.requestRectUpdate();
2218
2328
  }
2219
2329
  updateRect() {
2220
- this.rect = this.restRect.copy();
2330
+ this.rect = this.restRect.clone();
2221
2331
  this.dotRects.forEach((r) => this.rect.expandInPlace(r));
2222
2332
  }
2223
2333
  };
@@ -2323,9 +2433,9 @@ var _ObjRest = class _ObjRest extends MusicObject {
2323
2433
  getBeamCoords() {
2324
2434
  return this.staffObjects.map((obj) => {
2325
2435
  let staff = obj.staff;
2326
- let x = obj.getRect().centerX;
2436
+ let x = obj.getRect().anchorX;
2327
2437
  let y = this.stemDir === "up" /* Up */ ? obj.getRect().top : obj.getRect().bottom;
2328
- let stemHeight = Math.abs(obj.getRect().centerY - y);
2438
+ let stemHeight = Math.abs(obj.getRect().anchorY - y);
2329
2439
  return { staff, x, y, stemHeight };
2330
2440
  });
2331
2441
  }
@@ -2355,7 +2465,7 @@ var _ObjRest = class _ObjRest extends MusicObject {
2355
2465
  case 64:
2356
2466
  return -3;
2357
2467
  default:
2358
- throw new import_core6.MusicError(import_core6.MusicErrorType.Score, `Get rest dot vertical displacement: Invalid note size: ${noteSize}`);
2468
+ throw new import_core5.MusicError(import_core5.MusicErrorType.Score, `Get rest dot vertical displacement: Invalid note size: ${noteSize}`);
2359
2469
  }
2360
2470
  }
2361
2471
  updateAccidentalState(accState) {
@@ -2379,17 +2489,18 @@ var _ObjRest = class _ObjRest extends MusicObject {
2379
2489
  let dotWidth = DocumentSettings.DotSize * unitSize;
2380
2490
  let dotX = obj.restRect.rightw + (DocumentSettings.RestDotSpace + DocumentSettings.DotSize * unitSize) + i * DocumentSettings.DotSize * unitSize * 1.5;
2381
2491
  let dotY = this.getRestDotVerticalDisplacement(noteSize) * unitSize;
2382
- obj.dotRects.push(DivRect.createCentered(dotX, dotY, dotWidth, dotWidth));
2492
+ obj.dotRects.push(import_ts_utils_lib11.AnchoredRect.createCentered(dotX, dotY, dotWidth, dotWidth));
2383
2493
  }
2384
2494
  obj.offset(0, staff.getDiatonicIdY(diatonicId));
2385
2495
  this.staffObjects.push(obj);
2496
+ this.measure.addStaticObject(staff, obj);
2386
2497
  });
2387
2498
  }
2388
2499
  updateRect() {
2389
2500
  if (this.staffObjects.length === 0) {
2390
- this.rect = new DivRect();
2501
+ this.rect = new import_ts_utils_lib11.AnchoredRect();
2391
2502
  } else {
2392
- this.rect = this.staffObjects[0].getRect().copy();
2503
+ this.rect = this.staffObjects[0].getRect().clone();
2393
2504
  if (this.staffObjects.length > 1) {
2394
2505
  for (let i = 1; i < this.staffObjects.length; i++) {
2395
2506
  this.rect.expandInPlace(this.staffObjects[i].getRect());
@@ -2410,10 +2521,8 @@ var _ObjRest = class _ObjRest extends MusicObject {
2410
2521
  ctx.color(this.color).lineWidth(1);
2411
2522
  this.staffObjects.forEach((obj) => {
2412
2523
  let { dotRects, restRect } = obj;
2413
- let x = restRect.centerX;
2414
- let y = restRect.centerY;
2415
- ctx.drawRest(noteSize, x, y);
2416
- dotRects.forEach((r) => ctx.fillCircle(r.centerX, r.centerY, r.width / 2));
2524
+ ctx.drawRest(noteSize, restRect.anchorX, restRect.anchorY);
2525
+ dotRects.forEach((r) => ctx.fillCircle(r.anchorX, r.anchorY, r.width / 2));
2417
2526
  });
2418
2527
  }
2419
2528
  };
@@ -2421,18 +2530,18 @@ __publicField(_ObjRest, "UndefinedDiatonicId", Infinity);
2421
2530
  var ObjRest = _ObjRest;
2422
2531
 
2423
2532
  // src/score/engine/obj-note-group.ts
2424
- var import_ts_utils_lib4 = require("@tspro/ts-utils-lib");
2533
+ var import_ts_utils_lib12 = require("@tspro/ts-utils-lib");
2425
2534
  var import_theory4 = require("@tspro/web-music-score/theory");
2426
- var import_core7 = require("@tspro/web-music-score/core");
2535
+ var import_core6 = require("@tspro/web-music-score/core");
2427
2536
  function getArpeggio(a) {
2428
- return import_ts_utils_lib4.Utils.Is.isEnumValue(a, Arpeggio) ? a : a === true ? "up" /* Up */ : void 0;
2537
+ return import_ts_utils_lib12.Guard.isEnumValue(a, Arpeggio) ? a : a === true ? "up" /* Up */ : void 0;
2429
2538
  }
2430
2539
  function sortNotesAndStrings(notes, strings) {
2431
- let stringArr = import_ts_utils_lib4.Utils.Arr.isArray(strings) ? strings : strings !== void 0 ? [strings] : [];
2540
+ let stringArr = import_ts_utils_lib12.Utils.Arr.isArray(strings) ? strings : strings !== void 0 ? [strings] : [];
2432
2541
  let noteStringData = notes.map((note, i) => {
2433
2542
  return { note, string: stringArr[i] };
2434
2543
  });
2435
- noteStringData = import_ts_utils_lib4.Utils.Arr.removeDuplicatesCmp(noteStringData, (a, b) => import_theory4.Note.equals(a.note, b.note)).sort((a, b) => import_theory4.Note.compareFunc(a.note, b.note));
2544
+ noteStringData = import_ts_utils_lib12.Utils.Arr.removeDuplicates(noteStringData, (a, b) => import_theory4.Note.equals(a.note, b.note)).sort((a, b) => import_theory4.Note.compareFunc(a.note, b.note));
2436
2545
  return {
2437
2546
  sortedNotes: noteStringData.map((e) => e.note),
2438
2547
  sortedStrings: noteStringData.every((e) => e.string === void 0) ? void 0 : noteStringData.map((e) => e.string)
@@ -2470,7 +2579,7 @@ var ObjStaffNoteGroup = class extends MusicObject {
2470
2579
  return [this];
2471
2580
  }
2472
2581
  updateRect() {
2473
- this.rect = this.noteHeadRects[0].copy();
2582
+ this.rect = this.noteHeadRects[0].clone();
2474
2583
  this.noteHeadRects.forEach((r) => this.rect.expandInPlace(r));
2475
2584
  if (this.stemTip) this.rect.expandInPlace(this.stemTip);
2476
2585
  if (this.stemBase) this.rect.expandInPlace(this.stemBase);
@@ -2481,9 +2590,9 @@ var ObjStaffNoteGroup = class extends MusicObject {
2481
2590
  getRect() {
2482
2591
  let bottomNoteRect = this.noteHeadRects[0];
2483
2592
  let topNoteRect = this.noteHeadRects[this.noteHeadRects.length - 1];
2484
- if (this.prevTopNoteY !== topNoteRect.centerY || this.prevBottomNoteY !== bottomNoteRect.centerY) {
2485
- this.prevTopNoteY = topNoteRect.centerY;
2486
- this.prevBottomNoteY = bottomNoteRect.centerY;
2593
+ if (this.prevTopNoteY !== topNoteRect.anchorY || this.prevBottomNoteY !== bottomNoteRect.anchorY) {
2594
+ this.prevTopNoteY = topNoteRect.anchorY;
2595
+ this.prevBottomNoteY = bottomNoteRect.anchorY;
2487
2596
  this.requestRectUpdate();
2488
2597
  }
2489
2598
  return super.getRect();
@@ -2516,7 +2625,7 @@ var ObjTabNoteGroup = class extends MusicObject {
2516
2625
  return this.getRect().contains(x, y) ? [this] : [];
2517
2626
  }
2518
2627
  updateRect() {
2519
- this.rect = this.fretNumbers[0].getRect().copy();
2628
+ this.rect = this.fretNumbers[0].getRect().clone();
2520
2629
  this.fretNumbers.forEach((fn) => this.rect.expandInPlace(fn.getRect()));
2521
2630
  }
2522
2631
  offset(dx, dy) {
@@ -2552,13 +2661,15 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2552
2661
  __publicField(this, "beamGroup");
2553
2662
  __publicField(this, "staffObjects", []);
2554
2663
  __publicField(this, "tabObjects", []);
2664
+ __publicField(this, "isNoteDisplaced");
2555
2665
  __publicField(this, "mi");
2556
- if (!import_ts_utils_lib4.Utils.Is.isIntegerGte(notes.length, 1)) {
2557
- throw new import_core7.MusicError(import_core7.MusicErrorType.Score, "Cannot create note group object because notes array is empty.");
2666
+ if (!import_ts_utils_lib12.Guard.isIntegerGte(notes.length, 1)) {
2667
+ throw new import_core6.MusicError(import_core6.MusicErrorType.Score, "Cannot create note group object because notes array is empty.");
2558
2668
  }
2559
2669
  let { sortedNotes, sortedStrings } = sortNotesAndStrings(notes, options == null ? void 0 : options.string);
2560
2670
  this.notes = sortedNotes;
2561
2671
  this.setStringsNumbers = sortedStrings;
2672
+ this.isNoteDisplaced = this.notes.map(() => false);
2562
2673
  this.setDiatonicId = Math.round((this.minDiatonicId + this.maxDiatonicId) / 2);
2563
2674
  this.runningDiatonicId = this.setDiatonicId;
2564
2675
  this.runningStemDir = "up" /* Up */;
@@ -2596,14 +2707,18 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2596
2707
  get stemDir() {
2597
2708
  return this.runningStemDir;
2598
2709
  }
2710
+ setNoteDisplacement(note, isDisplaced) {
2711
+ let i = this.notes.indexOf(note);
2712
+ if (i >= 0) this.isNoteDisplaced[i] = isDisplaced;
2713
+ }
2599
2714
  enableConnective(line) {
2600
2715
  return line.containsVoiceId(this.voiceId) && (line instanceof ObjTab || line.containsDiatonicId(this.runningDiatonicId));
2601
2716
  }
2602
2717
  startConnective(connectiveProps) {
2603
2718
  if (!this.row.hasStaff && connectiveProps.connective === "tie" /* Tie */) {
2604
- throw new import_core7.MusicError(import_core7.MusicErrorType.Score, "Ties not implemented for guitar tabs alone, staff is required!");
2719
+ throw new import_core6.MusicError(import_core6.MusicErrorType.Score, "Ties not implemented for guitar tabs alone, staff is required!");
2605
2720
  } else if (!this.row.hasStaff && connectiveProps.connective === "slur" /* Slur */) {
2606
- throw new import_core7.MusicError(import_core7.MusicErrorType.Score, "Slurs not implemented for guitar tabs alone, staff is required!");
2721
+ throw new import_core6.MusicError(import_core6.MusicErrorType.Score, "Slurs not implemented for guitar tabs alone, staff is required!");
2607
2722
  }
2608
2723
  this.startConnnectives.push(connectiveProps);
2609
2724
  this.doc.addConnectiveProps(connectiveProps);
@@ -2613,20 +2728,6 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2613
2728
  this.runningStemDir = stemDir;
2614
2729
  this.runningStringNumbers = stringNumbers;
2615
2730
  }
2616
- getStaticObjects(line) {
2617
- let staticObjects = [];
2618
- this.staffObjects.forEach((obj) => {
2619
- if (obj.staff === line) {
2620
- staticObjects.push(obj);
2621
- }
2622
- });
2623
- this.tabObjects.forEach((obj) => {
2624
- if (obj.tab === line) {
2625
- staticObjects.push(obj);
2626
- }
2627
- });
2628
- return staticObjects;
2629
- }
2630
2731
  pick(x, y) {
2631
2732
  if (!this.getRect().contains(x, y)) {
2632
2733
  return [];
@@ -2655,12 +2756,12 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2655
2756
  var _a;
2656
2757
  if (line instanceof ObjStaff) {
2657
2758
  if (noteIndex < 0 || noteIndex >= this.notes.length) {
2658
- throw new import_core7.MusicError(import_core7.MusicErrorType.Score, "Invalid noteIndex: " + noteIndex);
2759
+ throw new import_core6.MusicError(import_core6.MusicErrorType.Score, "Invalid noteIndex: " + noteIndex);
2659
2760
  }
2660
2761
  let obj = this.staffObjects.find((obj2) => obj2.staff === line);
2661
2762
  if (!obj || noteIndex < 0 || noteIndex >= obj.noteHeadRects.length) {
2662
2763
  let r = this.getRect();
2663
- return { x: r.centerX, y: r.bottom };
2764
+ return { x: r.anchorX, y: r.bottom };
2664
2765
  }
2665
2766
  let noteHeadRect = obj.noteHeadRects[noteIndex];
2666
2767
  let stemTip = obj.stemTip;
@@ -2668,8 +2769,8 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2668
2769
  let hasStem = stemTip !== void 0;
2669
2770
  let stemSide = !hasStem ? void 0 : stemDir === "up" /* Up */ ? "right" : "left";
2670
2771
  let padding = noteHeadRect.height / 2;
2671
- let centerX = noteHeadRect.centerX;
2672
- let centerY = noteHeadRect.centerY;
2772
+ let anchorX = noteHeadRect.anchorX;
2773
+ let anchorY = noteHeadRect.anchorY;
2673
2774
  let leftX = noteHeadRect.left - padding;
2674
2775
  let rightX = noteHeadRect.right + padding;
2675
2776
  let aboveY = noteHeadRect.top - padding;
@@ -2681,29 +2782,29 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2681
2782
  }
2682
2783
  switch (noteAnchor) {
2683
2784
  case "center" /* Center */:
2684
- return side === "left" ? { x: rightX, y: centerY } : { x: leftX, y: centerY };
2785
+ return side === "left" ? { x: rightX, y: anchorY } : { x: leftX, y: anchorY };
2685
2786
  case "above" /* Above */:
2686
2787
  if (!hasStem || stemDir === "down" /* Down */) {
2687
- return { x: centerX, y: aboveY };
2788
+ return { x: anchorX, y: aboveY };
2688
2789
  } else {
2689
2790
  return {
2690
- x: side === "left" && stemSide === "right" ? rightX : side === "right" && stemSide === "left" ? leftX : centerX,
2791
+ x: side === "left" && stemSide === "right" ? rightX : side === "right" && stemSide === "left" ? leftX : anchorX,
2691
2792
  y: aboveY
2692
2793
  };
2693
2794
  }
2694
2795
  case "below" /* Below */:
2695
2796
  if (!hasStem || stemDir === "up" /* Up */) {
2696
- return { x: centerX, y: belowY };
2797
+ return { x: anchorX, y: belowY };
2697
2798
  } else {
2698
2799
  return {
2699
- x: side === "left" && stemSide === "right" ? rightX : side === "right" && stemSide === "left" ? leftX : centerX,
2800
+ x: side === "left" && stemSide === "right" ? rightX : side === "right" && stemSide === "left" ? leftX : anchorX,
2700
2801
  y: belowY
2701
2802
  };
2702
2803
  }
2703
2804
  case "stemTip" /* StemTip */:
2704
- return { x: centerX, y: stemTip.centerY + (stemDir === "up" /* Up */ ? -padding : padding) };
2805
+ return { x: anchorX, y: stemTip.anchorY + (stemDir === "up" /* Up */ ? -padding : padding) };
2705
2806
  default:
2706
- throw new import_core7.MusicError(import_core7.MusicErrorType.Score, "Invalid noteAnchor: " + noteAnchor);
2807
+ throw new import_core6.MusicError(import_core6.MusicErrorType.Score, "Invalid noteAnchor: " + noteAnchor);
2707
2808
  }
2708
2809
  } else if (line instanceof ObjTab) {
2709
2810
  let fretNumber = (_a = this.tabObjects.find((obj) => obj.tab === line)) == null ? void 0 : _a.fretNumbers[noteIndex];
@@ -2719,12 +2820,12 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2719
2820
  let rightFretNumber = connectiveProps.noteGroups[1].getFretNumber(line, 0);
2720
2821
  let slideUp = leftFretNumber === void 0 || rightFretNumber === void 0 || leftFretNumber <= rightFretNumber;
2721
2822
  if (side === "left") {
2722
- y = (slideUp ? r.centerY + r.bottomh : r.centerY - r.toph) * s;
2823
+ y = (slideUp ? r.anchorY + r.bottomh : r.anchorY - r.toph) * s;
2723
2824
  } else {
2724
- y = (slideUp ? r.centerY - r.toph : r.centerY + r.bottomh) * s;
2825
+ y = (slideUp ? r.anchorY - r.toph : r.anchorY + r.bottomh) * s;
2725
2826
  }
2726
2827
  } else {
2727
- y = r.centerY + r.bottomh * s;
2828
+ y = r.anchorY + r.bottomh * s;
2728
2829
  }
2729
2830
  return { x, y };
2730
2831
  } else {
@@ -2794,9 +2895,9 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2794
2895
  return this.staffObjects.map((obj) => {
2795
2896
  var _a, _b, _c, _d;
2796
2897
  let staff = obj.staff;
2797
- let x = (_b = (_a = obj.stemTip) == null ? void 0 : _a.centerX) != null ? _b : obj.noteHeadRects[0].centerX;
2798
- let y = (_d = (_c = obj.stemTip) == null ? void 0 : _c.centerY) != null ? _d : this.stemDir === "up" /* Up */ ? obj.getRect().top : obj.getRect().bottom;
2799
- let stemHeight = this.stemDir === "up" /* Up */ ? Math.abs(obj.noteHeadRects[0].centerY - y) : Math.abs(obj.noteHeadRects[obj.noteHeadRects.length - 1].centerY - y);
2898
+ let x = (_b = (_a = obj.stemTip) == null ? void 0 : _a.anchorX) != null ? _b : obj.noteHeadRects[0].anchorX;
2899
+ let y = (_d = (_c = obj.stemTip) == null ? void 0 : _c.anchorY) != null ? _d : this.stemDir === "up" /* Up */ ? obj.getRect().top : obj.getRect().bottom;
2900
+ let stemHeight = this.stemDir === "up" /* Up */ ? Math.abs(obj.noteHeadRects[0].anchorY - y) : Math.abs(obj.noteHeadRects[obj.noteHeadRects.length - 1].anchorY - y);
2800
2901
  return { staff, x, y, stemHeight };
2801
2902
  });
2802
2903
  }
@@ -2853,7 +2954,7 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2853
2954
  if (j >= 0) {
2854
2955
  tieNoteGroups = tieNoteGroups.slice(0, j);
2855
2956
  }
2856
- return import_ts_utils_lib4.Utils.Math.sum(tieNoteGroups.map((ng) => ng.rhythmProps.ticks));
2957
+ return import_ts_utils_lib12.Utils.Math.sum(tieNoteGroups.map((ng) => ng.rhythmProps.ticks));
2857
2958
  });
2858
2959
  return tiedTicks.length === 0 ? this.rhythmProps.ticks : Math.max(...tiedTicks);
2859
2960
  }
@@ -2885,14 +2986,14 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2885
2986
  let isBottomNote = noteIndex === 0;
2886
2987
  let isTopNote = noteIndex === this.notes.length - 1;
2887
2988
  let noteStaff = (_a = staff.getActualStaff(note.diatonicId)) != null ? _a : staff;
2888
- let noteX = this.col.getNoteHeadDisplacement(this, note) * noteHeadWidth;
2989
+ let noteX = this.isNoteDisplaced[noteIndex] ? noteHeadWidth * (stemDir === "down" /* Down */ ? -1 : 1) : 0;
2889
2990
  let noteY = noteStaff.getDiatonicIdY(note.diatonicId);
2890
2991
  let isNoteOnLine = noteStaff.isLine(note.diatonicId);
2891
2992
  if (isBottomNote && stemDir === "up" /* Up */) stemBaseStaff = noteStaff;
2892
2993
  if (isTopNote && stemDir === "up" /* Up */) stemTipStaff = noteStaff;
2893
2994
  if (isBottomNote && stemDir === "down" /* Down */) stemTipStaff = noteStaff;
2894
2995
  if (isTopNote && stemDir === "down" /* Down */) stemBaseStaff = noteStaff;
2895
- let noteHeadRect = obj.noteHeadRects[noteIndex] = DivRect.createCentered(noteX, noteY, noteHeadWidth, noteHeadHeight);
2996
+ let noteHeadRect = obj.noteHeadRects[noteIndex] = import_ts_utils_lib12.AnchoredRect.createCentered(noteX, noteY, noteHeadWidth, noteHeadHeight);
2896
2997
  noteStaff.addObject(noteHeadRect);
2897
2998
  if (accState.needAccidental(note)) {
2898
2999
  let acc = obj.accidentals[noteIndex] = new ObjAccidental(this, note.diatonicId, note.accidental, this.color);
@@ -2905,7 +3006,7 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2905
3006
  for (let i = 0; i < dotCount; i++) {
2906
3007
  let dotX = noteHeadRect.right + DocumentSettings.NoteDotSpace * unitSize + dotWidth / 2 + i * dotWidth * 1.5;
2907
3008
  let dotY = noteY + this.getDotVerticalDisplacement(staff, note.diatonicId, stemDir) * unitSize;
2908
- let r = DivRect.createCentered(dotX, dotY, dotWidth, dotWidth);
3009
+ let r = import_ts_utils_lib12.AnchoredRect.createCentered(dotX, dotY, dotWidth, dotWidth);
2909
3010
  obj.dotRects.push(r);
2910
3011
  noteStaff.addObject(r);
2911
3012
  }
@@ -2913,27 +3014,27 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2913
3014
  if (stemDir === "up" /* Up */ && isBottomNote) {
2914
3015
  let dotX = noteX;
2915
3016
  let dotY = noteY + unitSize * (isNoteOnLine ? 3 : 2);
2916
- let r = DivRect.createCentered(dotX, dotY, dotWidth, dotWidth);
3017
+ let r = import_ts_utils_lib12.AnchoredRect.createCentered(dotX, dotY, dotWidth, dotWidth);
2917
3018
  obj.dotRects.push(r);
2918
3019
  stemBaseStaff.addObject(r);
2919
3020
  } else if (stemDir === "down" /* Down */ && isTopNote) {
2920
3021
  let dotX = noteX;
2921
3022
  let dotY = noteY - unitSize * (isNoteOnLine ? 3 : 2);
2922
- let r = DivRect.createCentered(dotX, dotY, dotWidth, dotWidth);
3023
+ let r = import_ts_utils_lib12.AnchoredRect.createCentered(dotX, dotY, dotWidth, dotWidth);
2923
3024
  obj.dotRects.push(r);
2924
3025
  stemBaseStaff.addObject(r);
2925
3026
  }
2926
3027
  }
2927
3028
  });
2928
- let bottomNoteY = obj.noteHeadRects[0].centerY;
2929
- let topNoteY = obj.noteHeadRects[obj.noteHeadRects.length - 1].centerY;
3029
+ let bottomNoteY = obj.noteHeadRects[0].anchorY;
3030
+ let topNoteY = obj.noteHeadRects[obj.noteHeadRects.length - 1].anchorY;
2930
3031
  let stemX = stemDir === "up" /* Up */ ? noteHeadWidth / 2 : -noteHeadWidth / 2;
2931
3032
  let stemHeight = this.getStemHeight(ctx);
2932
3033
  let stemTipY = stemDir === "up" /* Up */ ? topNoteY - stemHeight : bottomNoteY + stemHeight;
2933
3034
  let stemBaseY = stemDir === "up" /* Up */ ? bottomNoteY : topNoteY;
2934
3035
  if (hasStem) {
2935
- obj.stemTip = new DivRect(stemX, stemX, stemTipY, stemTipY);
2936
- obj.stemBase = new DivRect(stemX, stemX, stemBaseY, stemBaseY);
3036
+ obj.stemTip = new import_ts_utils_lib12.AnchoredRect(stemX, stemX, stemTipY, stemTipY);
3037
+ obj.stemBase = new import_ts_utils_lib12.AnchoredRect(stemX, stemX, stemBaseY, stemBaseY);
2937
3038
  stemTipStaff.addObject(obj.stemTip);
2938
3039
  stemBaseStaff.addObject(obj.stemBase);
2939
3040
  }
@@ -2942,11 +3043,12 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2942
3043
  let flagHeight = flagCount === 0 ? 0 : DocumentSettings.FlagHeight * unitSize;
2943
3044
  for (let i = 0; i < flagCount; i++) {
2944
3045
  let flagAddY = i * unitSize * DocumentSettings.FlagSeparation;
2945
- let r = obj.flagRects[i] = stemDir === "up" /* Up */ ? new DivRect(stemX, stemX + flagWidth, stemTipY + flagAddY, stemTipY + flagHeight + flagAddY) : new DivRect(stemX, stemX + flagWidth, stemTipY - flagHeight - flagAddY, stemTipY - flagAddY);
3046
+ let r = obj.flagRects[i] = stemDir === "up" /* Up */ ? new import_ts_utils_lib12.AnchoredRect(stemX, stemX + flagWidth, stemTipY + flagAddY, stemTipY + flagHeight + flagAddY) : new import_ts_utils_lib12.AnchoredRect(stemX, stemX + flagWidth, stemTipY - flagHeight - flagAddY, stemTipY - flagAddY);
2946
3047
  stemTipStaff.addObject(r);
2947
3048
  }
2948
3049
  }
2949
3050
  this.staffObjects.push(obj);
3051
+ this.measure.addStaticObject(staff, obj);
2950
3052
  });
2951
3053
  this.tabObjects.length = 0;
2952
3054
  row.getTabs().forEach((tab) => {
@@ -2956,12 +3058,12 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2956
3058
  let obj = new ObjTabNoteGroup(tab, this);
2957
3059
  this.notes.forEach((note, noteIndex) => {
2958
3060
  let stringNumber = this.runningStringNumbers[noteIndex];
2959
- if (import_ts_utils_lib4.Utils.Is.isIntegerBetween(stringNumber, 1, 6)) {
3061
+ if (import_ts_utils_lib12.Guard.isIntegerBetween(stringNumber, 1, 6)) {
2960
3062
  let fretId = note.chromaticId - tab.getTuningStrings()[stringNumber - 1].chromaticId;
2961
3063
  let color = fretId < 0 ? "red" : "black";
2962
3064
  let fretNumber = new ObjText(this, { text: String(fretId), color, bgcolor: "white" }, 0.5, 0.5);
2963
3065
  fretNumber.layout(ctx);
2964
- let x = this.col.getRect().centerX;
3066
+ let x = this.col.getRect().anchorX;
2965
3067
  let y = tab.getStringY(stringNumber - 1);
2966
3068
  fretNumber.offset(x, y);
2967
3069
  obj.fretNumbers.push(fretNumber);
@@ -2970,16 +3072,17 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2970
3072
  if (obj.fretNumbers.length > 0) {
2971
3073
  this.tabObjects.push(obj);
2972
3074
  tab.addObject(obj);
3075
+ this.measure.addStaticObject(tab, obj);
2973
3076
  }
2974
3077
  });
2975
3078
  }
2976
3079
  updateRect() {
2977
3080
  if (this.staffObjects.length > 0) {
2978
- this.rect = this.staffObjects[0].noteHeadRects[0].copy();
3081
+ this.rect = this.staffObjects[0].noteHeadRects[0].clone();
2979
3082
  } else if (this.tabObjects.length > 0 && this.tabObjects[0].fretNumbers.length > 0) {
2980
- this.rect = this.tabObjects[0].fretNumbers[0].getRect().copy();
3083
+ this.rect = this.tabObjects[0].fretNumbers[0].getRect().clone();
2981
3084
  } else {
2982
- this.rect = new DivRect();
3085
+ this.rect = new import_ts_utils_lib12.AnchoredRect();
2983
3086
  return;
2984
3087
  }
2985
3088
  this.staffObjects.forEach((obj) => this.rect.expandInPlace(obj.getRect()));
@@ -2987,9 +3090,10 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2987
3090
  }
2988
3091
  setStemTipY(staff, stemTipY) {
2989
3092
  let obj = this.staffObjects.find((obj2) => obj2.staff === staff);
2990
- if (this.hasBeamCount() && (obj == null ? void 0 : obj.stemTip) && stemTipY !== obj.stemTip.centerY) {
2991
- obj.stemTip.top = obj.stemTip.centerY = obj.stemTip.bottom = stemTipY;
3093
+ if (this.hasBeamCount() && (obj == null ? void 0 : obj.stemTip) && stemTipY !== obj.stemTip.anchorY) {
3094
+ obj.stemTip.top = obj.stemTip.anchorY = obj.stemTip.bottom = stemTipY;
2992
3095
  this.requestRectUpdate();
3096
+ this.col.requestRectUpdate();
2993
3097
  }
2994
3098
  }
2995
3099
  offset(dx, dy) {
@@ -3009,31 +3113,31 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
3009
3113
  if (this.diamond) {
3010
3114
  if (isSolidNoteHead) {
3011
3115
  ctx.beginPath();
3012
- ctx.moveTo(r.centerX, r.top);
3013
- ctx.lineTo(r.right, r.centerY);
3014
- ctx.lineTo(r.centerX, r.bottom);
3015
- ctx.lineTo(r.left, r.centerY);
3016
- ctx.lineTo(r.centerX, r.top);
3116
+ ctx.moveTo(r.anchorX, r.top);
3117
+ ctx.lineTo(r.right, r.anchorY);
3118
+ ctx.lineTo(r.anchorX, r.bottom);
3119
+ ctx.lineTo(r.left, r.anchorY);
3120
+ ctx.lineTo(r.anchorX, r.top);
3017
3121
  ctx.fill();
3018
3122
  } else {
3019
3123
  ctx.beginPath();
3020
3124
  ctx.lineWidth(2.5);
3021
- ctx.moveTo(r.centerX, r.top);
3022
- ctx.lineTo(r.right, r.centerY);
3023
- ctx.moveTo(r.left, r.centerY);
3024
- ctx.lineTo(r.centerX, r.bottom);
3125
+ ctx.moveTo(r.anchorX, r.top);
3126
+ ctx.lineTo(r.right, r.anchorY);
3127
+ ctx.moveTo(r.left, r.anchorY);
3128
+ ctx.lineTo(r.anchorX, r.bottom);
3025
3129
  ctx.stroke();
3026
3130
  ctx.beginPath();
3027
3131
  ctx.lineWidth(1);
3028
- ctx.moveTo(r.right, r.centerY);
3029
- ctx.lineTo(r.centerX, r.bottom);
3030
- ctx.moveTo(r.centerX, r.top);
3031
- ctx.lineTo(r.left, r.centerY);
3132
+ ctx.moveTo(r.right, r.anchorY);
3133
+ ctx.lineTo(r.anchorX, r.bottom);
3134
+ ctx.moveTo(r.anchorX, r.top);
3135
+ ctx.lineTo(r.left, r.anchorY);
3032
3136
  ctx.stroke();
3033
3137
  }
3034
3138
  } else {
3035
3139
  ctx.beginPath();
3036
- ctx.ellipse(r.centerX, r.centerY, r.leftw, r.toph, -0.3, 0, Math.PI * 2);
3140
+ ctx.ellipse(r.anchorX, r.anchorY, r.leftw, r.toph, -0.3, 0, Math.PI * 2);
3037
3141
  if (isSolidNoteHead) {
3038
3142
  ctx.fill();
3039
3143
  } else {
@@ -3041,11 +3145,11 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
3041
3145
  }
3042
3146
  }
3043
3147
  });
3044
- obj.dotRects.forEach((r) => ctx.fillCircle(r.centerX, r.centerY, r.width / 2));
3148
+ obj.dotRects.forEach((r) => ctx.fillCircle(r.anchorX, r.anchorY, r.width / 2));
3045
3149
  if (obj.stemTip && obj.stemBase) {
3046
3150
  ctx.beginPath();
3047
- ctx.moveTo(obj.stemBase.centerX, obj.stemBase.centerY);
3048
- ctx.lineTo(obj.stemTip.centerX, obj.stemTip.centerY);
3151
+ ctx.moveTo(obj.stemBase.anchorX, obj.stemBase.anchorY);
3152
+ ctx.lineTo(obj.stemTip.anchorX, obj.stemTip.anchorY);
3049
3153
  ctx.stroke();
3050
3154
  }
3051
3155
  obj.flagRects.forEach((rect) => ctx.drawFlag(rect, stemDir === "up" /* Up */ ? "up" : "down"));
@@ -3075,29 +3179,21 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
3075
3179
  };
3076
3180
 
3077
3181
  // src/score/engine/obj-rhythm-column.ts
3078
- var import_core8 = require("@tspro/web-music-score/core");
3079
- var import_ts_utils_lib5 = require("@tspro/ts-utils-lib");
3080
- var noteHeadDataCompareFunc = (a, b) => {
3081
- let cmp = import_theory5.Note.compareFunc(a.note, b.note);
3082
- if (cmp === 0) {
3083
- cmp = a.noteGroup.stemDir === b.noteGroup.stemDir ? 0 : a.noteGroup.stemDir === "up" /* Up */ ? 1 : -1;
3084
- }
3085
- return cmp;
3086
- };
3182
+ var import_core7 = require("@tspro/web-music-score/core");
3183
+ var import_ts_utils_lib13 = require("@tspro/ts-utils-lib");
3087
3184
  var ObjRhythmColumn = class extends MusicObject {
3088
3185
  constructor(measure, positionTicks) {
3089
3186
  super(measure);
3090
3187
  this.measure = measure;
3091
3188
  this.positionTicks = positionTicks;
3092
- __publicField(this, "voiceSymbol", []);
3093
- __publicField(this, "lyricsObject", new import_ts_utils_lib5.Map3());
3189
+ __publicField(this, "voiceSymbol", new import_ts_utils_lib13.IndexArray());
3190
+ __publicField(this, "lyricsObject", new import_ts_utils_lib13.TriMap());
3094
3191
  __publicField(this, "minDiatonicId");
3095
3192
  __publicField(this, "maxDiatonicId");
3096
- __publicField(this, "staffMinDiatonicId", /* @__PURE__ */ new Map());
3097
- __publicField(this, "staffMaxDiatonicId", /* @__PURE__ */ new Map());
3193
+ __publicField(this, "staffMinDiatonicId", new import_ts_utils_lib13.UniMap());
3194
+ __publicField(this, "staffMaxDiatonicId", new import_ts_utils_lib13.UniMap());
3098
3195
  __publicField(this, "arpeggioDir");
3099
3196
  __publicField(this, "arpeggios", []);
3100
- __publicField(this, "noteHeadDisplacements", []);
3101
3197
  __publicField(this, "playerProps");
3102
3198
  __publicField(this, "needLayout", true);
3103
3199
  __publicField(this, "shapeRects", []);
@@ -3120,7 +3216,7 @@ var ObjRhythmColumn = class extends MusicObject {
3120
3216
  if (colId >= 0 && colId < this.measure.getColumnCount()) {
3121
3217
  return this.measure.getColumn(colId + 1);
3122
3218
  } else {
3123
- throw new import_core8.MusicError(import_core8.MusicErrorType.Score, "Cannot get next column in measure because current column's id in mesure is invalid.");
3219
+ throw new import_core7.MusicError(import_core7.MusicErrorType.Score, "Cannot get next column in measure because current column's id in mesure is invalid.");
3124
3220
  }
3125
3221
  }
3126
3222
  /**
@@ -3147,22 +3243,6 @@ var ObjRhythmColumn = class extends MusicObject {
3147
3243
  this.getRect();
3148
3244
  return this.shapeRects;
3149
3245
  }
3150
- getStaticObjects(line) {
3151
- let staticObjects = [];
3152
- this.voiceSymbol.forEach((symbol) => {
3153
- if (symbol) {
3154
- symbol.getRect();
3155
- symbol.getStaticObjects(line).forEach((obj) => staticObjects.push(obj));
3156
- }
3157
- });
3158
- this.arpeggios.forEach((arpeggio) => {
3159
- if (arpeggio.line === line) {
3160
- arpeggio.getRect();
3161
- staticObjects.push(arpeggio);
3162
- }
3163
- });
3164
- return staticObjects;
3165
- }
3166
3246
  get doc() {
3167
3247
  return this.measure.doc;
3168
3248
  }
@@ -3170,12 +3250,22 @@ var ObjRhythmColumn = class extends MusicObject {
3170
3250
  return this.measure.row;
3171
3251
  }
3172
3252
  pick(x, y) {
3173
- if (!this.getRect().contains(x, y)) {
3174
- return [];
3253
+ const thisContainsXY = this.getRect().contains(x, y);
3254
+ for (let i = 0; i < this.voiceSymbol.length; i++) {
3255
+ let sym = this.voiceSymbol.get(i);
3256
+ if (sym instanceof ObjRest) {
3257
+ let arr = sym.pick(x, y);
3258
+ if (arr.length > 0) {
3259
+ return thisContainsXY ? [this, ...arr] : arr;
3260
+ }
3261
+ }
3175
3262
  }
3263
+ if (!thisContainsXY)
3264
+ return [];
3176
3265
  for (let i = 0; i < this.voiceSymbol.length; i++) {
3177
- if (this.voiceSymbol[i]) {
3178
- let arr = this.voiceSymbol[i].pick(x, y);
3266
+ let sym = this.voiceSymbol.get(i);
3267
+ if (sym instanceof ObjNoteGroup) {
3268
+ let arr = sym.pick(x, y);
3179
3269
  if (arr.length > 0) {
3180
3270
  return [this, ...arr];
3181
3271
  }
@@ -3198,7 +3288,7 @@ var ObjRhythmColumn = class extends MusicObject {
3198
3288
  }
3199
3289
  setVoiceSymbol(voiceId, symbol) {
3200
3290
  validateVoiceId(voiceId);
3201
- this.voiceSymbol[voiceId] = symbol;
3291
+ this.voiceSymbol.set(voiceId, symbol);
3202
3292
  if (symbol instanceof ObjRest && !symbol.hide) {
3203
3293
  this.row.getStaves().forEach((staff) => {
3204
3294
  let diatonicId = symbol.getDiatonicId(staff);
@@ -3211,13 +3301,13 @@ var ObjRhythmColumn = class extends MusicObject {
3211
3301
  if (symbol.arpeggio !== void 0) {
3212
3302
  this.arpeggioDir = symbol.arpeggio;
3213
3303
  }
3214
- this.setupNoteHeadDisplacements();
3304
+ this.updateNoteDisplacements();
3215
3305
  }
3216
3306
  this.requestLayout();
3217
3307
  this.requestRectUpdate();
3218
3308
  }
3219
3309
  getVoiceSymbol(voiceId) {
3220
- return this.voiceSymbol[voiceId];
3310
+ return this.voiceSymbol.get(voiceId);
3221
3311
  }
3222
3312
  getLyricsObject(verse, line, vpos) {
3223
3313
  return this.lyricsObject.get(verse, line, vpos);
@@ -3226,7 +3316,7 @@ var ObjRhythmColumn = class extends MusicObject {
3226
3316
  this.lyricsObject.set(lyricsObj.verse, lyricsObj.line, lyricsObj.vpos, lyricsObj);
3227
3317
  }
3228
3318
  getMinWidth() {
3229
- let maxNoteSize = Math.max(...this.voiceSymbol.map((s) => s.rhythmProps.noteSize));
3319
+ let maxNoteSize = Math.max(...this.voiceSymbol.mapToArray((s) => s.rhythmProps.noteSize));
3230
3320
  let w = DocumentSettings.NoteHeadWidth;
3231
3321
  switch (maxNoteSize) {
3232
3322
  case 1:
@@ -3242,56 +3332,50 @@ var ObjRhythmColumn = class extends MusicObject {
3242
3332
  return w;
3243
3333
  }
3244
3334
  }
3245
- setupNoteHeadDisplacements() {
3246
- this.noteHeadDisplacements = [];
3335
+ updateNoteDisplacements() {
3336
+ let data = [];
3247
3337
  this.voiceSymbol.forEach((symbol) => {
3248
3338
  if (symbol instanceof ObjNoteGroup) {
3249
3339
  symbol.notes.forEach((note) => {
3250
- this.noteHeadDisplacements.push({ noteGroup: symbol, note });
3340
+ symbol.setNoteDisplacement(note, false);
3341
+ data.push({ noteGroup: symbol, note });
3251
3342
  });
3252
3343
  }
3253
3344
  });
3254
- this.noteHeadDisplacements.sort(noteHeadDataCompareFunc);
3255
- if (this.noteHeadDisplacements.length < 2) {
3345
+ const noteHeadDataCompareFunc = (a, b) => {
3346
+ let cmp = import_theory5.Note.compareFunc(a.note, b.note);
3347
+ return cmp === 0 ? a.noteGroup.stemDir === b.noteGroup.stemDir ? 0 : a.noteGroup.stemDir === "up" /* Up */ ? 1 : -1 : cmp;
3348
+ };
3349
+ data.sort(noteHeadDataCompareFunc);
3350
+ if (data.length < 2) {
3256
3351
  return;
3257
3352
  }
3258
- for (let i = 0; i < this.noteHeadDisplacements.length; i++) {
3259
- let cur = this.noteHeadDisplacements[i];
3260
- let next = this.noteHeadDisplacements[i + 1];
3353
+ for (let i = 0; i < data.length; i++) {
3354
+ let cur = data[i];
3355
+ let next = data[i + 1];
3261
3356
  if (next && cur.note.diatonicId === next.note.diatonicId) {
3262
- cur.displacement = next.displacement = 0;
3263
- }
3264
- }
3265
- for (let i = 0; i < this.noteHeadDisplacements.length; i++) {
3266
- let prev = this.noteHeadDisplacements[i - 1];
3267
- let cur = this.noteHeadDisplacements[i];
3268
- let next = this.noteHeadDisplacements[i + 1];
3269
- if (cur.displacement !== void 0) {
3270
- continue;
3271
- }
3272
- let d = cur.noteGroup.stemDir === "down" /* Down */ ? -1 : 1;
3273
- if (prev && cur.note.diatonicId - prev.note.diatonicId <= 1) {
3274
- cur.displacement = prev.displacement === 0 ? d : 0;
3275
- } else if (next && next.note.diatonicId - cur.note.diatonicId <= 1) {
3276
- cur.displacement = next.displacement === 0 ? d : 0;
3357
+ cur.isDisplaced = next.isDisplaced = false;
3358
+ }
3359
+ }
3360
+ for (let i = 0; i < data.length; i++) {
3361
+ let prev = data[i - 1];
3362
+ let cur = data[i];
3363
+ let next = data[i + 1];
3364
+ if (cur.isDisplaced === void 0) {
3365
+ if (prev && cur.note.diatonicId - prev.note.diatonicId <= 1) {
3366
+ cur.isDisplaced = !prev.isDisplaced;
3367
+ } else if (next && next.note.diatonicId - cur.note.diatonicId <= 1) {
3368
+ cur.isDisplaced = !next.isDisplaced;
3369
+ }
3277
3370
  }
3278
3371
  }
3279
- }
3280
- getNoteHeadDisplacement(noteGroup, note) {
3281
- let data = this.noteHeadDisplacements.find((d) => d.noteGroup === noteGroup && import_theory5.Note.equals(d.note, note));
3282
- if ((data == null ? void 0 : data.displacement) !== void 0) {
3283
- return data.displacement;
3284
- } else {
3285
- return 0;
3286
- }
3372
+ data.forEach((el) => {
3373
+ var _a;
3374
+ return el.noteGroup.setNoteDisplacement(el.note, (_a = el.isDisplaced) != null ? _a : false);
3375
+ });
3287
3376
  }
3288
3377
  isEmpty() {
3289
- for (let i = 0; i < this.voiceSymbol.length; i++) {
3290
- if (this.voiceSymbol[i] !== void 0 && !this.voiceSymbol[i].isEmpty()) {
3291
- return false;
3292
- }
3293
- }
3294
- return true;
3378
+ return this.voiceSymbol.size === 0 || this.voiceSymbol.every((symbol) => symbol.isEmpty());
3295
3379
  }
3296
3380
  getPlayerNotes() {
3297
3381
  let playerNotes = [];
@@ -3339,7 +3423,7 @@ var ObjRhythmColumn = class extends MusicObject {
3339
3423
  return;
3340
3424
  }
3341
3425
  this.requestRectUpdate();
3342
- this.rect = new DivRect();
3426
+ this.rect = new import_ts_utils_lib13.AnchoredRect();
3343
3427
  let { row } = this;
3344
3428
  let { unitSize } = ctx;
3345
3429
  let halfMinWidth = this.getMinWidth() * unitSize / 2;
@@ -3356,9 +3440,10 @@ var ObjRhythmColumn = class extends MusicObject {
3356
3440
  this.arpeggios = row.getNotationLines().map((line) => {
3357
3441
  let arpeggio = new ObjArpeggio(this, line, this.getArpeggioDir());
3358
3442
  arpeggio.layout(ctx);
3359
- arpeggio.offset(-leftw - arpeggio.getRect().right, line.getRect().centerY - arpeggio.getRect().centerY);
3443
+ arpeggio.offset(-leftw - arpeggio.getRect().right, line.getRect().anchorY - arpeggio.getRect().anchorY);
3360
3444
  arpeggioWidth = Math.max(arpeggioWidth, arpeggio.getRect().width);
3361
3445
  line.addObject(arpeggio);
3446
+ this.measure.addStaticObject(line, arpeggio);
3362
3447
  return arpeggio;
3363
3448
  });
3364
3449
  leftw += arpeggioWidth;
@@ -3374,7 +3459,7 @@ var ObjRhythmColumn = class extends MusicObject {
3374
3459
  }
3375
3460
  this.voiceSymbol.forEach((symbol) => symbol.updateAccidentalState(accState));
3376
3461
  this.rect.left = -leftw;
3377
- this.rect.centerX = 0;
3462
+ this.rect.anchorX = 0;
3378
3463
  this.rect.right = rightw;
3379
3464
  this.row.getStaves().forEach((staff) => {
3380
3465
  let minDiatonicId = void 0;
@@ -3408,15 +3493,15 @@ var ObjRhythmColumn = class extends MusicObject {
3408
3493
  }
3409
3494
  updateRect() {
3410
3495
  this.shapeRects = [
3411
- ...this.voiceSymbol.filter((s) => !!s).map((s) => s.getRect().copy()),
3412
- ...this.arpeggios.map((a) => a.getRect().copy())
3496
+ ...this.voiceSymbol.filter((s) => !!s).mapToArray((s) => s.getRect().clone()),
3497
+ ...this.arpeggios.map((a) => a.getRect().clone())
3413
3498
  ];
3414
3499
  this.rect.top = Math.min(...this.shapeRects.map((r) => r.top));
3415
3500
  this.rect.bottom = Math.max(...this.shapeRects.map((r) => r.bottom));
3416
- this.rect.centerY = (this.rect.top + this.rect.bottom) / 2;
3501
+ this.rect.anchorY = (this.rect.top + this.rect.bottom) / 2;
3417
3502
  }
3418
3503
  offset(dx, dy) {
3419
- this.voiceSymbol.forEach((symbol) => symbol == null ? void 0 : symbol.offset(dx, 0));
3504
+ this.voiceSymbol.forEach((symbol) => symbol.offset(dx, 0));
3420
3505
  this.arpeggios.forEach((arpeggio) => arpeggio.offset(dx, 0));
3421
3506
  this.shapeRects.forEach((r) => r.offsetInPlace(dx, dy));
3422
3507
  this.rect.offsetInPlace(dx, dy);
@@ -3426,28 +3511,25 @@ var ObjRhythmColumn = class extends MusicObject {
3426
3511
  let minDiatonicId = this.staffMinDiatonicId.get(staff);
3427
3512
  let maxDiatonicId = this.staffMaxDiatonicId.get(staff);
3428
3513
  if (minDiatonicId !== void 0) {
3429
- ctx.drawLedgerLines(staff, minDiatonicId, this.getRect().centerX);
3514
+ ctx.drawLedgerLines(staff, minDiatonicId, this.getRect().anchorX);
3430
3515
  }
3431
3516
  if (maxDiatonicId !== void 0) {
3432
- ctx.drawLedgerLines(staff, maxDiatonicId, this.getRect().centerX);
3433
- }
3434
- });
3435
- this.voiceSymbol.forEach((symbol) => {
3436
- if (symbol) {
3437
- symbol.draw(ctx);
3517
+ ctx.drawLedgerLines(staff, maxDiatonicId, this.getRect().anchorX);
3438
3518
  }
3439
3519
  });
3520
+ this.voiceSymbol.forEach((symbol) => symbol.draw(ctx));
3440
3521
  this.arpeggios.forEach((arpeggio) => arpeggio.draw(ctx));
3441
3522
  }
3442
3523
  };
3443
3524
 
3444
3525
  // src/score/engine/extension.ts
3445
- var import_core9 = require("@tspro/web-music-score/core");
3526
+ var import_core8 = require("@tspro/web-music-score/core");
3446
3527
 
3447
3528
  // src/score/engine/element-data.ts
3448
- var import_ts_utils_lib6 = require("@tspro/ts-utils-lib");
3529
+ var import_ts_utils_lib15 = require("@tspro/ts-utils-lib");
3449
3530
 
3450
3531
  // src/score/engine/obj-special-text.ts
3532
+ var import_ts_utils_lib14 = require("@tspro/ts-utils-lib");
3451
3533
  var _ObjSpecialText = class _ObjSpecialText extends MusicObject {
3452
3534
  constructor(parent, text) {
3453
3535
  super(parent);
@@ -3492,14 +3574,14 @@ var _ObjSpecialText = class _ObjSpecialText extends MusicObject {
3492
3574
  let codaText = this.components[1];
3493
3575
  codaSym.layout(ctx);
3494
3576
  codaText.layout(ctx);
3495
- codaSym.offset(0, (codaText.getRect().top + codaText.getRect().bottom) / 2);
3577
+ codaSym.offset(0, codaText.getRect().centerY);
3496
3578
  codaText.offset(codaSym.getRect().right, 0);
3497
- this.rect = new DivRect(
3579
+ this.rect = new import_ts_utils_lib14.AnchoredRect(
3498
3580
  codaSym.getRect().left,
3499
- codaSym.getRect().centerX,
3581
+ codaSym.getRect().anchorX,
3500
3582
  codaText.getRect().right,
3501
3583
  codaText.getRect().top,
3502
- codaText.getRect().centerY,
3584
+ codaText.getRect().anchorY,
3503
3585
  codaText.getRect().bottom
3504
3586
  );
3505
3587
  break;
@@ -3509,14 +3591,14 @@ var _ObjSpecialText = class _ObjSpecialText extends MusicObject {
3509
3591
  let codaSym = this.components[1];
3510
3592
  toCodaText.layout(ctx);
3511
3593
  codaSym.layout(ctx);
3512
- codaSym.offset(0, (toCodaText.getRect().top + toCodaText.getRect().bottom) / 2);
3594
+ codaSym.offset(0, toCodaText.getRect().centerY);
3513
3595
  toCodaText.offset(codaSym.getRect().left, 0);
3514
- this.rect = new DivRect(
3596
+ this.rect = new import_ts_utils_lib14.AnchoredRect(
3515
3597
  toCodaText.getRect().left,
3516
- codaSym.getRect().centerX,
3598
+ codaSym.getRect().anchorX,
3517
3599
  codaSym.getRect().right,
3518
3600
  toCodaText.getRect().top,
3519
- toCodaText.getRect().centerY,
3601
+ toCodaText.getRect().anchorY,
3520
3602
  toCodaText.getRect().bottom
3521
3603
  );
3522
3604
  break;
@@ -3524,7 +3606,7 @@ var _ObjSpecialText = class _ObjSpecialText extends MusicObject {
3524
3606
  default: {
3525
3607
  let text = this.components[0];
3526
3608
  text.layout(ctx);
3527
- this.rect = text.getRect().copy();
3609
+ this.rect = text.getRect().clone();
3528
3610
  break;
3529
3611
  }
3530
3612
  }
@@ -3567,23 +3649,23 @@ function getNavigationString(navigation) {
3567
3649
  }
3568
3650
  }
3569
3651
  function isDynamicsText(text) {
3570
- return import_ts_utils_lib6.Utils.Is.isEnumValue(text, DynamicsAnnotation);
3652
+ return import_ts_utils_lib15.Guard.isEnumValue(text, DynamicsAnnotation);
3571
3653
  }
3572
3654
  function getDynamicsVolume(text) {
3573
3655
  if (/^(p+|f+|m|mp|mf)$/.test(text)) {
3574
- let volume = 0.5 - import_ts_utils_lib6.Utils.Str.charCount(text, "p") * 0.1 + import_ts_utils_lib6.Utils.Str.charCount(text, "f") * 0.1;
3575
- return import_ts_utils_lib6.Utils.Math.clamp(volume, 0, 1);
3656
+ let volume = 0.5 - import_ts_utils_lib15.Utils.Str.charCount(text, "p") * 0.1 + import_ts_utils_lib15.Utils.Str.charCount(text, "f") * 0.1;
3657
+ return import_ts_utils_lib15.Utils.Math.clamp(volume, 0, 1);
3576
3658
  } else {
3577
3659
  return void 0;
3578
3660
  }
3579
3661
  }
3580
3662
  function isTempoText(text) {
3581
- return import_ts_utils_lib6.Utils.Is.isEnumValue(text, TempoAnnotation);
3663
+ return import_ts_utils_lib15.Guard.isEnumValue(text, TempoAnnotation);
3582
3664
  }
3583
3665
  function getAnnotation(text) {
3584
- if (import_ts_utils_lib6.Utils.Is.isEnumValue(text, DynamicsAnnotation)) {
3666
+ if (import_ts_utils_lib15.Guard.isEnumValue(text, DynamicsAnnotation)) {
3585
3667
  return "dynamics" /* Dynamics */;
3586
- } else if (import_ts_utils_lib6.Utils.Is.isEnumValue(text, TempoAnnotation)) {
3668
+ } else if (import_ts_utils_lib15.Guard.isEnumValue(text, TempoAnnotation)) {
3587
3669
  return "tempo" /* Tempo */;
3588
3670
  } else {
3589
3671
  return void 0;
@@ -3626,7 +3708,7 @@ var Extension = class extends MusicObjectLink {
3626
3708
  if (head instanceof ObjText) {
3627
3709
  head.updateAnchorY(getTextAnchorY(linePos));
3628
3710
  } else {
3629
- throw new import_core9.MusicError(import_core9.MusicErrorType.Score, "Update anchor's y-coordinate is only implemented for text objects.");
3711
+ throw new import_core8.MusicError(import_core8.MusicErrorType.Score, "Update anchor's y-coordinate is only implemented for text objects.");
3630
3712
  }
3631
3713
  }
3632
3714
  isVisible() {
@@ -3739,7 +3821,7 @@ var PlayerColumnProps = class {
3739
3821
  return this.speed;
3740
3822
  }
3741
3823
  getTempo() {
3742
- let speed = import_ts_utils_lib7.Utils.Math.clamp(this.getSpeed(), 0.1, 10);
3824
+ let speed = import_ts_utils_lib16.Utils.Math.clamp(this.getSpeed(), 0.1, 10);
3743
3825
  return (0, import_theory6.alterTempoSpeed)(this.measure.getTempo(), speed);
3744
3826
  }
3745
3827
  setVolume(volume) {
@@ -3764,7 +3846,7 @@ var PlayerColumnProps = class {
3764
3846
  if (symbolsTicks.length === 0) {
3765
3847
  return 0;
3766
3848
  } else {
3767
- return import_ts_utils_lib7.Utils.Math.sum(symbolsTicks) / symbolsTicks.length;
3849
+ return import_ts_utils_lib16.Utils.Math.sum(symbolsTicks) / symbolsTicks.length;
3768
3850
  }
3769
3851
  }
3770
3852
  }
@@ -3887,24 +3969,17 @@ var Player = class _Player {
3887
3969
  }
3888
3970
  let curSpeed = 1;
3889
3971
  let curVolume = getDefaultVolume();
3890
- let speedMap = /* @__PURE__ */ new Map();
3891
- let volumeMap = /* @__PURE__ */ new Map();
3892
- const pushSpeed = (col, speed) => {
3893
- var _a;
3894
- return speedMap.set(col, [...(_a = speedMap.get(col)) != null ? _a : [], speed]);
3895
- };
3896
- const pushVolume = (col, volume) => {
3897
- var _a;
3898
- return volumeMap.set(col, [...(_a = volumeMap.get(col)) != null ? _a : [], volume]);
3899
- };
3972
+ let speedMap = new import_ts_utils_lib16.UniMap();
3973
+ let volumeMap = new import_ts_utils_lib16.UniMap();
3974
+ const pushSpeed = (col, speed) => speedMap.getOrCreate(col, []).push(speed);
3975
+ const pushVolume = (col, volume) => volumeMap.getOrCreate(col, []).push(volume);
3900
3976
  this.playerColumnSequence.forEach((col) => {
3901
- var _a, _b;
3902
3977
  if (!(col instanceof ObjRhythmColumn)) {
3903
3978
  return;
3904
3979
  }
3905
3980
  col.getAnchoredLayoutObjects().forEach((layoutObj) => {
3906
- var _a2;
3907
- let text = (_a2 = layoutObj.getTextContent()) != null ? _a2 : "";
3981
+ var _a;
3982
+ let text = (_a = layoutObj.getTextContent()) != null ? _a : "";
3908
3983
  let vol;
3909
3984
  if (text === "a tempo" /* a_tempo */) {
3910
3985
  curSpeed = 1;
@@ -3913,7 +3988,7 @@ var Player = class _Player {
3913
3988
  } else if (layoutObj.musicObj.getLink() instanceof Extension) {
3914
3989
  let extension = layoutObj.musicObj.getLink();
3915
3990
  let { columnRange, extensionBreakText } = extension.getExtensionRangeInfo();
3916
- let totalTicks = import_ts_utils_lib7.Utils.Math.sum(columnRange.map((c) => c.getTicksToNextColumn()));
3991
+ let totalTicks = import_ts_utils_lib16.Utils.Math.sum(columnRange.map((c) => c.getTicksToNextColumn()));
3917
3992
  switch (text) {
3918
3993
  case "accel." /* accel */: {
3919
3994
  let startSpeed = curSpeed;
@@ -3965,13 +4040,13 @@ var Player = class _Player {
3965
4040
  }
3966
4041
  }
3967
4042
  });
3968
- let speedArr = (_a = speedMap.get(col)) != null ? _a : [];
4043
+ let speedArr = speedMap.getOrDefault(col, []);
3969
4044
  if (speedArr.length > 0) {
3970
- curSpeed = import_ts_utils_lib7.Utils.Math.sum(speedArr) / speedArr.length;
4045
+ curSpeed = import_ts_utils_lib16.Utils.Math.sum(speedArr) / speedArr.length;
3971
4046
  }
3972
- let volumeArr = (_b = volumeMap.get(col)) != null ? _b : [];
4047
+ let volumeArr = volumeMap.getOrDefault(col, []);
3973
4048
  if (volumeArr.length > 0) {
3974
- curVolume = import_ts_utils_lib7.Utils.Math.sum(volumeArr) / volumeArr.length;
4049
+ curVolume = import_ts_utils_lib16.Utils.Math.sum(volumeArr) / volumeArr.length;
3975
4050
  }
3976
4051
  col.getPlayerProps().setSpeed(curSpeed);
3977
4052
  col.getPlayerProps().setVolume(curVolume);
@@ -4089,14 +4164,14 @@ var Player = class _Player {
4089
4164
  return void 0;
4090
4165
  }
4091
4166
  let measure = col.measure;
4092
- let x = col.getRect().centerX;
4093
- let top = measure.row.getRect().top;
4094
- let bottom = measure.row.getRect().bottom;
4095
- return new DivRect(x, x, top, bottom);
4167
+ let x = col.getRect().anchorX;
4168
+ let { top, height } = measure.row.getRect();
4169
+ return new import_ts_utils_lib16.Rect(x, top, 0, height);
4096
4170
  }
4097
4171
  };
4098
4172
 
4099
4173
  // src/score/engine/obj-bar-line.ts
4174
+ var import_ts_utils_lib17 = require("@tspro/ts-utils-lib");
4100
4175
  var ObjStaffTabBarLine = class extends MusicObject {
4101
4176
  constructor(barLine, line) {
4102
4177
  super(line);
@@ -4183,36 +4258,36 @@ var ObjBarLine = class extends MusicObject {
4183
4258
  bottom = line.getBottomLineY();
4184
4259
  switch (barLineType) {
4185
4260
  case 0 /* None */:
4186
- obj.setRect(new DivRect(0, 0, 0, top, 0, bottom));
4261
+ obj.setRect(new import_ts_utils_lib17.AnchoredRect(0, 0, 0, top, 0, bottom));
4187
4262
  break;
4188
4263
  case 1 /* Single */:
4189
- obj.setRect(new DivRect(-thinW, 0, 0, top, 0, bottom));
4264
+ obj.setRect(new import_ts_utils_lib17.AnchoredRect(-thinW, 0, 0, top, 0, bottom));
4190
4265
  addVerticalLine(-thinW, thinW);
4191
4266
  break;
4192
4267
  case 2 /* Double */:
4193
- obj.setRect(new DivRect(-thinW - spaceW - thinW, 0, 0, top, 0, bottom));
4268
+ obj.setRect(new import_ts_utils_lib17.AnchoredRect(-thinW - spaceW - thinW, 0, 0, top, 0, bottom));
4194
4269
  addVerticalLine(-thinW - spaceW - thinW, thinW);
4195
4270
  addVerticalLine(-thinW, thinW);
4196
4271
  break;
4197
4272
  case 3 /* EndSong */:
4198
- obj.setRect(new DivRect(-thicW - spaceW - thinW, 0, 0, top, 0, bottom));
4273
+ obj.setRect(new import_ts_utils_lib17.AnchoredRect(-thicW - spaceW - thinW, 0, 0, top, 0, bottom));
4199
4274
  addVerticalLine(-thinW - spaceW - thicW, thinW);
4200
4275
  addVerticalLine(-thicW, thicW);
4201
4276
  break;
4202
4277
  case 4 /* StartRepeat */:
4203
- obj.setRect(new DivRect(0, 0, thicW + spaceW + thinW + spaceW + dotW, top, 0, bottom));
4278
+ obj.setRect(new import_ts_utils_lib17.AnchoredRect(0, 0, thicW + spaceW + thinW + spaceW + dotW, top, 0, bottom));
4204
4279
  addVerticalLine(0, thicW);
4205
4280
  addVerticalLine(thicW + spaceW, thinW);
4206
4281
  addDotPair(thicW + spaceW + thinW + spaceW + dotRadius);
4207
4282
  break;
4208
4283
  case 5 /* EndRepeat */:
4209
- obj.setRect(new DivRect(-thicW - spaceW - thinW - spaceW - dotW, 0, 0, top, 0, bottom));
4284
+ obj.setRect(new import_ts_utils_lib17.AnchoredRect(-thicW - spaceW - thinW - spaceW - dotW, 0, 0, top, 0, bottom));
4210
4285
  addVerticalLine(-thinW - spaceW - thicW, thinW);
4211
4286
  addVerticalLine(-thicW, thicW);
4212
4287
  addDotPair(-thinW - spaceW - thicW - spaceW - dotRadius);
4213
4288
  break;
4214
4289
  case 6 /* EndStartRepeat */:
4215
- obj.setRect(new DivRect(-dotW - spaceW - thinW - spaceW - thicW / 2, 0, thicW / 2 + spaceW + thinW + spaceW + dotW, top, 0, bottom));
4290
+ obj.setRect(new import_ts_utils_lib17.AnchoredRect(-dotW - spaceW - thinW - spaceW - thicW / 2, 0, thicW / 2 + spaceW + thinW + spaceW + dotW, top, 0, bottom));
4216
4291
  addVerticalLine(-thicW / 2, thicW);
4217
4292
  addVerticalLine(-thicW / 2 - spaceW - thinW, thinW);
4218
4293
  addVerticalLine(thicW / 2 + spaceW, thinW);
@@ -4228,12 +4303,12 @@ var ObjBarLine = class extends MusicObject {
4228
4303
  }
4229
4304
  updateRect() {
4230
4305
  if (this.staffTabObjects.length > 0) {
4231
- this.rect = this.staffTabObjects[0].getRect().copy();
4306
+ this.rect = this.staffTabObjects[0].getRect().clone();
4232
4307
  for (let i = 1; i < this.staffTabObjects.length; i++) {
4233
4308
  this.rect.expandInPlace(this.staffTabObjects[i].getRect());
4234
4309
  }
4235
4310
  } else {
4236
- this.rect = new DivRect();
4311
+ this.rect = new import_ts_utils_lib17.AnchoredRect();
4237
4312
  }
4238
4313
  }
4239
4314
  offset(dx, dy) {
@@ -4318,8 +4393,8 @@ var ObjBarLineRight = class extends ObjBarLine {
4318
4393
  };
4319
4394
 
4320
4395
  // src/score/engine/obj-ending.ts
4321
- var import_ts_utils_lib8 = require("@tspro/ts-utils-lib");
4322
- var import_core10 = require("@tspro/web-music-score/core");
4396
+ var import_ts_utils_lib18 = require("@tspro/ts-utils-lib");
4397
+ var import_core9 = require("@tspro/web-music-score/core");
4323
4398
  var ObjEnding = class extends MusicObject {
4324
4399
  constructor(measure, passages) {
4325
4400
  super(measure);
@@ -4329,10 +4404,10 @@ var ObjEnding = class extends MusicObject {
4329
4404
  __publicField(this, "shapeRects", []);
4330
4405
  __publicField(this, "mi");
4331
4406
  this.mi = new MEnding(this);
4332
- if (!import_ts_utils_lib8.Utils.Is.isIntegerGte(passages.length, 1)) {
4333
- throw new import_core10.MusicError(import_core10.MusicErrorType.Score, "Passages is empty.");
4334
- } else if (!this.passages.every((p) => import_ts_utils_lib8.Utils.Is.isIntegerGte(p, 1))) {
4335
- throw new import_core10.MusicError(import_core10.MusicErrorType.Score, "Invalid passages: " + this.passages);
4407
+ if (!import_ts_utils_lib18.Guard.isIntegerGte(passages.length, 1)) {
4408
+ throw new import_core9.MusicError(import_core9.MusicErrorType.Score, "Passages is empty.");
4409
+ } else if (!this.passages.every((p) => import_ts_utils_lib18.Guard.isIntegerGte(p, 1))) {
4410
+ throw new import_core9.MusicError(import_core9.MusicErrorType.Score, "Invalid passages: " + this.passages);
4336
4411
  }
4337
4412
  this.passages.sort((a, b) => a - b);
4338
4413
  let text = this.passages.map((p) => p + ".").join("");
@@ -4359,8 +4434,8 @@ var ObjEnding = class extends MusicObject {
4359
4434
  return this.rect.contains(x, y) ? [this] : [];
4360
4435
  }
4361
4436
  layout(ctx) {
4362
- this.rect = new DivRect();
4363
- this.shapeRects = [this.rect.copy()];
4437
+ this.rect = new import_ts_utils_lib18.AnchoredRect();
4438
+ this.shapeRects = [this.rect.clone()];
4364
4439
  }
4365
4440
  layoutFitToMeasure(ctx) {
4366
4441
  let { unitSize } = ctx;
@@ -4369,13 +4444,13 @@ var ObjEnding = class extends MusicObject {
4369
4444
  let textRect = this.endingText.getRect();
4370
4445
  let measureContent = measure.getColumnsContentRect();
4371
4446
  let endingHeight = textRect.height;
4372
- this.rect = new DivRect(measureContent.left + unitSize, measureContent.right - unitSize, -endingHeight, 0);
4447
+ this.rect = new import_ts_utils_lib18.AnchoredRect(measureContent.left + unitSize, measureContent.right - unitSize, -endingHeight, 0);
4373
4448
  this.endingText.offset(this.rect.left + unitSize / 2, this.rect.bottom);
4374
4449
  this.shapeRects = [
4375
- new DivRect(this.rect.left, this.rect.left + 1, this.rect.top, this.rect.bottom),
4376
- new DivRect(this.rect.left, this.rect.right, this.rect.top, this.rect.top + 1),
4377
- new DivRect(this.rect.right - 1, this.rect.right, this.rect.top, this.rect.bottom),
4378
- this.endingText.getRect().copy()
4450
+ new import_ts_utils_lib18.AnchoredRect(this.rect.left, this.rect.left + 1, this.rect.top, this.rect.bottom),
4451
+ new import_ts_utils_lib18.AnchoredRect(this.rect.left, this.rect.right, this.rect.top, this.rect.top + 1),
4452
+ new import_ts_utils_lib18.AnchoredRect(this.rect.right - 1, this.rect.right, this.rect.top, this.rect.bottom),
4453
+ this.endingText.getRect().clone()
4379
4454
  ];
4380
4455
  }
4381
4456
  offset(dx, dy) {
@@ -4400,9 +4475,9 @@ var ObjEnding = class extends MusicObject {
4400
4475
  };
4401
4476
 
4402
4477
  // src/score/engine/obj-beam-group.ts
4403
- var import_ts_utils_lib9 = require("@tspro/ts-utils-lib");
4478
+ var import_ts_utils_lib19 = require("@tspro/ts-utils-lib");
4404
4479
  var import_theory7 = require("@tspro/web-music-score/theory");
4405
- var import_core11 = require("@tspro/web-music-score/core");
4480
+ var import_core10 = require("@tspro/web-music-score/core");
4406
4481
  var adjustBeamAngle = (dx, dy) => {
4407
4482
  let T = DocumentSettings.BeamAngleFactor;
4408
4483
  if (!Number.isFinite(T) || T === 0) {
@@ -4430,7 +4505,7 @@ var BeamPoint = class {
4430
4505
  this.beamGroup.requestRectUpdate();
4431
4506
  }
4432
4507
  getRect() {
4433
- return new DivRect(this.x, this.x, this.x, this.y - this.topBeamsHeight, this.y, this.y + this.bottomBeamsHeight);
4508
+ return new import_ts_utils_lib19.AnchoredRect(this.x, this.x, this.x, this.y - this.topBeamsHeight, this.y, this.y + this.bottomBeamsHeight);
4434
4509
  }
4435
4510
  };
4436
4511
  var ObjStaffBeamGroup = class extends MusicObject {
@@ -4460,9 +4535,9 @@ var ObjStaffBeamGroup = class extends MusicObject {
4460
4535
  }
4461
4536
  updateRect() {
4462
4537
  if (this.points.length > 0) {
4463
- this.rect = this.points[0].getRect().copy();
4538
+ this.rect = this.points[0].getRect().clone();
4464
4539
  } else if (this.tupletNumber) {
4465
- this.rect = this.tupletNumber.getRect().copy();
4540
+ this.rect = this.tupletNumber.getRect().clone();
4466
4541
  }
4467
4542
  this.points.forEach((pt) => this.rect.expandInPlace(pt.getRect()));
4468
4543
  if (this.tupletNumber) {
@@ -4487,9 +4562,9 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
4487
4562
  this.mi = new MBeamGroup(this);
4488
4563
  let beamGroupName = tupletRatio ? "Tuplet" : "BeamGroup";
4489
4564
  if (!symbols.every((s) => s.measure === symbols[0].measure)) {
4490
- throw new import_core11.MusicError(import_core11.MusicErrorType.Score, `All ${beamGroupName} symbols are not in same measure.`);
4565
+ throw new import_core10.MusicError(import_core10.MusicErrorType.Score, `All ${beamGroupName} symbols are not in same measure.`);
4491
4566
  } else if (symbols.length < 2) {
4492
- throw new import_core11.MusicError(import_core11.MusicErrorType.Score, `${beamGroupName} needs minimum 2 symbols, but ${symbols.length} given.`);
4567
+ throw new import_core10.MusicError(import_core10.MusicErrorType.Score, `${beamGroupName} needs minimum 2 symbols, but ${symbols.length} given.`);
4493
4568
  }
4494
4569
  if (tupletRatio !== void 0) {
4495
4570
  let isGroup = symbols.length < 3 || symbols.some((s) => !(s instanceof ObjNoteGroup)) || symbols.some((s) => s.rhythmProps.flagCount !== symbols[0].rhythmProps.flagCount);
@@ -4509,7 +4584,7 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
4509
4584
  symbols.forEach((s) => s.setBeamGroup(this));
4510
4585
  symbols[0].measure.addBeamGroup(this);
4511
4586
  } else {
4512
- throw new import_core11.MusicError(import_core11.MusicErrorType.Score, `Cannot add ${beamGroupName} because some symbol already has one.`);
4587
+ throw new import_core10.MusicError(import_core10.MusicErrorType.Score, `Cannot add ${beamGroupName} because some symbol already has one.`);
4513
4588
  }
4514
4589
  if (this.type === 0 /* RegularBeam */) {
4515
4590
  this.symbols.filter((sym) => sym instanceof ObjNoteGroup).some((sym, i) => {
@@ -4524,7 +4599,7 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
4524
4599
  if (this.type === 0 /* RegularBeam */) {
4525
4600
  throw new InvalidBeamGroup(this, "Beam symbols have different voiceId.");
4526
4601
  } else {
4527
- throw new import_core11.MusicError(import_core11.MusicErrorType.Score, `Tuplet symbols have different voiceId.`);
4602
+ throw new import_core10.MusicError(import_core10.MusicErrorType.Score, `Tuplet symbols have different voiceId.`);
4528
4603
  }
4529
4604
  }
4530
4605
  symbols[0].row.getStaves().forEach((staff) => {
@@ -4708,7 +4783,7 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
4708
4783
  symbolY.forEach((symY, i) => {
4709
4784
  let symX = symbolX[i];
4710
4785
  if (symX !== void 0 && symY !== void 0) {
4711
- let beamY = import_ts_utils_lib9.Utils.Math.interpolateY(leftX, leftY, rightX, rightY, symX);
4786
+ let beamY = import_ts_utils_lib19.Utils.Math.interpolateY(leftX, leftY, rightX, rightY, symX);
4712
4787
  let raiseY = symY - beamY;
4713
4788
  if (stemDir === "up" /* Up */ && raiseY < 0) {
4714
4789
  raiseBeamY = Math.min(raiseBeamY, raiseY);
@@ -4723,8 +4798,8 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
4723
4798
  let obj = new ObjStaffBeamGroup(mainStaff, this);
4724
4799
  if (type === 2 /* TupletGroup */) {
4725
4800
  let ef = unitSize / (rightX - leftX);
4726
- let l = import_ts_utils_lib9.Utils.Math.interpolateCoord(leftX, leftY + groupLineDy, rightX, rightY + groupLineDy, -ef);
4727
- let r = import_ts_utils_lib9.Utils.Math.interpolateCoord(leftX, leftY + groupLineDy, rightX, rightY + groupLineDy, 1 + ef);
4801
+ let l = import_ts_utils_lib19.Utils.Math.interpolateCoord(leftX, leftY + groupLineDy, rightX, rightY + groupLineDy, -ef);
4802
+ let r = import_ts_utils_lib19.Utils.Math.interpolateCoord(leftX, leftY + groupLineDy, rightX, rightY + groupLineDy, 1 + ef);
4728
4803
  obj.points.push(new BeamPoint(leftStaff, this, leftSymbol, l.x, l.y));
4729
4804
  obj.points.push(new BeamPoint(rightStaff, this, rightSymbol, r.x, r.y));
4730
4805
  obj.tupletNumberOffsetY = 0;
@@ -4773,10 +4848,10 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
4773
4848
  }
4774
4849
  updateRect() {
4775
4850
  if (this.staffObjects.length === 0) {
4776
- this.rect = new DivRect();
4851
+ this.rect = new import_ts_utils_lib19.AnchoredRect();
4777
4852
  } else {
4778
4853
  this.staffObjects.forEach((obj) => obj.updateRect());
4779
- this.rect = this.staffObjects[0].getRect().copy();
4854
+ this.rect = this.staffObjects[0].getRect().clone();
4780
4855
  for (let i = 1; i < this.staffObjects.length; i++) {
4781
4856
  this.rect.expandInPlace(this.staffObjects[i].getRect());
4782
4857
  }
@@ -4790,7 +4865,7 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
4790
4865
  obj.points.forEach((pt) => {
4791
4866
  if (pt.symbol instanceof ObjNoteGroup) {
4792
4867
  if (pt !== left && pt !== right) {
4793
- pt.y = import_ts_utils_lib9.Utils.Math.interpolateY(left.x, left.y, right.x, right.y, pt.x);
4868
+ pt.y = import_ts_utils_lib19.Utils.Math.interpolateY(left.x, left.y, right.x, right.y, pt.x);
4794
4869
  }
4795
4870
  pt.symbol.setStemTipY(pt.staff, pt.y);
4796
4871
  }
@@ -4798,7 +4873,7 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
4798
4873
  }
4799
4874
  if (obj.tupletNumber) {
4800
4875
  let y = (left.y + right.y) / 2 + obj.tupletNumberOffsetY;
4801
- obj.tupletNumber.offset(0, -obj.tupletNumber.getRect().centerY + y);
4876
+ obj.tupletNumber.offset(0, -obj.tupletNumber.getRect().anchorY + y);
4802
4877
  }
4803
4878
  });
4804
4879
  }
@@ -4817,8 +4892,8 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
4817
4892
  let { x: rx, y: ry } = obj.points[obj.points.length - 1];
4818
4893
  if (obj.tupletNumber) {
4819
4894
  let tf = obj.tupletNumber.getRect().width / (rx - lx) * 1.2;
4820
- let lc = import_ts_utils_lib9.Utils.Math.interpolateCoord(lx, ly, rx, ry, 0.5 - tf / 2);
4821
- let rc = import_ts_utils_lib9.Utils.Math.interpolateCoord(lx, ly, rx, ry, 0.5 + tf / 2);
4895
+ let lc = import_ts_utils_lib19.Utils.Math.interpolateCoord(lx, ly, rx, ry, 0.5 - tf / 2);
4896
+ let rc = import_ts_utils_lib19.Utils.Math.interpolateCoord(lx, ly, rx, ry, 0.5 + tf / 2);
4822
4897
  ctx.strokeLine(lx, ly, lc.x, lc.y);
4823
4898
  ctx.strokeLine(rc.x, rc.y, rx, ry);
4824
4899
  } else {
@@ -4932,6 +5007,7 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
4932
5007
  };
4933
5008
 
4934
5009
  // src/score/engine/obj-fermata.ts
5010
+ var import_ts_utils_lib20 = require("@tspro/ts-utils-lib");
4935
5011
  var ObjFermata = class extends MusicObject {
4936
5012
  constructor(parent, pos) {
4937
5013
  super(parent);
@@ -4959,7 +5035,7 @@ var ObjFermata = class extends MusicObject {
4959
5035
  let { unitSize } = ctx;
4960
5036
  let width = unitSize * 4;
4961
5037
  let height = unitSize * 3;
4962
- this.rect = new DivRect(-width / 2, width / 2, -height, 0);
5038
+ this.rect = new import_ts_utils_lib20.AnchoredRect(-width / 2, width / 2, -height, 0);
4963
5039
  }
4964
5040
  offset(dx, dy) {
4965
5041
  this.rect.offsetInPlace(dx, dy);
@@ -4987,6 +5063,7 @@ var ObjFermata = class extends MusicObject {
4987
5063
  };
4988
5064
 
4989
5065
  // src/score/engine/obj-extension-line.ts
5066
+ var import_ts_utils_lib21 = require("@tspro/ts-utils-lib");
4990
5067
  var ObjExtensionLine = class extends MusicObject {
4991
5068
  constructor(measure, line, extension, leftObj, rightObj) {
4992
5069
  super(measure);
@@ -5007,7 +5084,7 @@ var ObjExtensionLine = class extends MusicObject {
5007
5084
  }
5008
5085
  getLineLeft() {
5009
5086
  if (this.leftObj instanceof ObjBarLineLeft) {
5010
- return this.leftObj.getRect().centerX;
5087
+ return this.leftObj.getRect().anchorX;
5011
5088
  } else {
5012
5089
  return this.leftObj.getRect().right;
5013
5090
  }
@@ -5022,7 +5099,7 @@ var ObjExtensionLine = class extends MusicObject {
5022
5099
  return (col.getRect().right + col.measure.getBarLineRight().getRect().left) / 2;
5023
5100
  }
5024
5101
  } else {
5025
- return this.rightObj.getRect().centerX;
5102
+ return this.rightObj.getRect().anchorX;
5026
5103
  }
5027
5104
  }
5028
5105
  layoutFitToMeasure(ctx) {
@@ -5030,13 +5107,13 @@ var ObjExtensionLine = class extends MusicObject {
5030
5107
  let lineLeft = this.getLineLeft();
5031
5108
  let lineRight = this.getLineRight();
5032
5109
  let lineRectH = unitSize;
5033
- this.rect = new DivRect(lineLeft, lineRight, -lineRectH / 2, lineRectH / 2);
5110
+ this.rect = new import_ts_utils_lib21.AnchoredRect(lineLeft, lineRight, -lineRectH / 2, lineRectH / 2);
5034
5111
  }
5035
5112
  pick(x, y) {
5036
5113
  return this.rect.contains(x, y) ? [this] : [];
5037
5114
  }
5038
5115
  layout(ctx) {
5039
- this.rect = new DivRect();
5116
+ this.rect = new import_ts_utils_lib21.AnchoredRect();
5040
5117
  }
5041
5118
  offset(dx, dy) {
5042
5119
  this.rect.offsetInPlace(dx, dy);
@@ -5047,25 +5124,25 @@ var ObjExtensionLine = class extends MusicObject {
5047
5124
  ctx.setLineDash([7, 3]);
5048
5125
  }
5049
5126
  ctx.color("black").lineWidth(1);
5050
- ctx.strokeLine(rect.left, rect.centerY, rect.right, rect.centerY);
5127
+ ctx.strokeLine(rect.left, rect.anchorY, rect.right, rect.anchorY);
5051
5128
  ctx.setLineDash([]);
5052
5129
  let tails = this.extension.getTails();
5053
5130
  if (tails.length > 0 && this === tails[tails.length - 1]) {
5054
- let tipH = rect.centerY > this.line.getRect().centerY ? -ctx.unitSize : ctx.unitSize;
5055
- ctx.strokeLine(rect.right, rect.centerY, rect.right, rect.centerY + tipH);
5131
+ let tipH = rect.anchorY > this.line.getRect().anchorY ? -ctx.unitSize : ctx.unitSize;
5132
+ ctx.strokeLine(rect.right, rect.anchorY, rect.right, rect.anchorY + tipH);
5056
5133
  }
5057
5134
  }
5058
5135
  };
5059
5136
 
5060
5137
  // src/score/engine/obj-measure.ts
5061
- var import_core14 = require("@tspro/web-music-score/core");
5138
+ var import_core13 = require("@tspro/web-music-score/core");
5062
5139
 
5063
5140
  // src/score/engine/connective-props.ts
5064
5141
  var import_theory8 = require("@tspro/web-music-score/theory");
5065
5142
 
5066
5143
  // src/score/engine/obj-connective.ts
5067
- var import_ts_utils_lib10 = require("@tspro/ts-utils-lib");
5068
- var import_core12 = require("@tspro/web-music-score/core");
5144
+ var import_ts_utils_lib22 = require("@tspro/ts-utils-lib");
5145
+ var import_core11 = require("@tspro/web-music-score/core");
5069
5146
  var ObjConnective = class extends MusicObject {
5070
5147
  constructor(connectiveProps, line, measure, leftNoteGroup, leftNoteId, ...args) {
5071
5148
  var _a;
@@ -5095,7 +5172,7 @@ var ObjConnective = class extends MusicObject {
5095
5172
  this.rightNoteGroup = args[0];
5096
5173
  this.rightNoteId = args[1];
5097
5174
  this.tieType = void 0;
5098
- } else if (import_ts_utils_lib10.Utils.Is.isEnumValue(args[0], TieType)) {
5175
+ } else if (import_ts_utils_lib22.Guard.isEnumValue(args[0], TieType)) {
5099
5176
  this.rightNoteGroup = void 0;
5100
5177
  this.rightNoteId = void 0;
5101
5178
  this.tieType = args[0];
@@ -5156,7 +5233,7 @@ var ObjConnective = class extends MusicObject {
5156
5233
  rx = contentRect.right;
5157
5234
  ry = leftPos.y + (rightPos.y - leftPos.y) * tLeft / (tLeft + tRight);
5158
5235
  } else {
5159
- throw new import_core12.MusicError(import_core12.MusicErrorType.Score, "Cannot layout connective object because no valid left and right note groups.");
5236
+ throw new import_core11.MusicError(import_core11.MusicErrorType.Score, "Cannot layout connective object because no valid left and right note groups.");
5160
5237
  }
5161
5238
  let spanDy = arcDir === "up" ? -1 : 1;
5162
5239
  let arcHeight = spanDy * unitSize * Math.log2(rx - lx) / 3;
@@ -5165,12 +5242,12 @@ var ObjConnective = class extends MusicObject {
5165
5242
  this.rx = rx;
5166
5243
  this.ry = ry;
5167
5244
  this.arcHeight = this.connectiveProps.connective === "slide" /* Slide */ ? 0 : arcHeight;
5168
- let { nx, ny } = import_ts_utils_lib10.Utils.Math.calcNormal(lx, ly, rx, ry);
5245
+ let { nx, ny } = import_ts_utils_lib22.Utils.Math.calcNormal(lx, ly, rx, ry);
5169
5246
  this.cp1x = lx * 0.7 + rx * 0.3 + nx * this.arcHeight;
5170
5247
  this.cp1y = ly * 0.7 + ry * 0.3 + ny * this.arcHeight;
5171
5248
  this.cp2x = lx * 0.3 + rx * 0.7 + nx * this.arcHeight;
5172
5249
  this.cp2y = ly * 0.3 + ry * 0.7 + ny * this.arcHeight;
5173
- this.rect = new DivRect(
5250
+ this.rect = new import_ts_utils_lib22.AnchoredRect(
5174
5251
  Math.min(this.lx, this.cp1x, this.cp2x, this.rx),
5175
5252
  Math.max(this.lx, this.cp1x, this.cp2x, this.rx),
5176
5253
  Math.min(this.ly, this.cp1y, this.cp2y, this.ry),
@@ -5220,8 +5297,8 @@ var ObjConnective = class extends MusicObject {
5220
5297
  };
5221
5298
 
5222
5299
  // src/score/engine/connective-props.ts
5223
- var import_core13 = require("@tspro/web-music-score/core");
5224
- var import_ts_utils_lib11 = require("@tspro/ts-utils-lib");
5300
+ var import_core12 = require("@tspro/web-music-score/core");
5301
+ var import_ts_utils_lib23 = require("@tspro/ts-utils-lib");
5225
5302
  var ConnectiveProps = class {
5226
5303
  constructor(connective, span, noteAnchor, startNoteGroup) {
5227
5304
  this.connective = connective;
@@ -5294,7 +5371,7 @@ var ConnectiveProps = class {
5294
5371
  this.noteGroups[0].row.getNotationLines().forEach((line) => {
5295
5372
  this.computeParams(line);
5296
5373
  if (connective === "tie" /* Tie */) {
5297
- if (import_ts_utils_lib11.Utils.Is.isEnumValue(span, TieType)) {
5374
+ if (import_ts_utils_lib23.Guard.isEnumValue(span, TieType)) {
5298
5375
  let leftNoteGroup = this.noteGroups[0];
5299
5376
  for (let noteId = 0; noteId < leftNoteGroup.notes.length; noteId++) {
5300
5377
  this.createObjConnectiveWithTieType(line, leftNoteGroup, noteId, span);
@@ -5360,13 +5437,13 @@ var ConnectiveProps = class {
5360
5437
  addConnective(leftNoteGroup.measure, leftNoteGroup, leftNoteId, rightNoteGroup, rightNoteId);
5361
5438
  addConnective(rightNoteGroup.measure, leftNoteGroup, leftNoteId, rightNoteGroup, rightNoteId);
5362
5439
  } else {
5363
- throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Cannot create connective because it is jumping measures.");
5440
+ throw new import_core12.MusicError(import_core12.MusicErrorType.Score, "Cannot create connective because it is jumping measures.");
5364
5441
  }
5365
5442
  }
5366
5443
  };
5367
5444
 
5368
5445
  // src/score/engine/obj-lyrics.ts
5369
- var import_ts_utils_lib12 = require("@tspro/ts-utils-lib");
5446
+ var import_ts_utils_lib24 = require("@tspro/ts-utils-lib");
5370
5447
  var ObjLyrics = class extends MusicObject {
5371
5448
  constructor(col, verse, line, vpos, lyricsLength, lyricsText, lyricsOptions) {
5372
5449
  super(col);
@@ -5382,9 +5459,9 @@ var ObjLyrics = class extends MusicObject {
5382
5459
  __publicField(this, "mi");
5383
5460
  this.rhythmProps = RhythmProps.get(lyricsLength);
5384
5461
  let halign = (lyricsOptions == null ? void 0 : lyricsOptions.align) === "left" /* Left */ ? 0 : (lyricsOptions == null ? void 0 : lyricsOptions.align) === "right" /* Right */ ? 1 : 0.5;
5385
- this.hyphen = import_ts_utils_lib12.Utils.Is.isEnumValue(lyricsOptions == null ? void 0 : lyricsOptions.hyphen, LyricsHyphen) ? lyricsOptions == null ? void 0 : lyricsOptions.hyphen : void 0;
5462
+ this.hyphen = import_ts_utils_lib24.Guard.isEnumValue(lyricsOptions == null ? void 0 : lyricsOptions.hyphen, LyricsHyphen) ? lyricsOptions == null ? void 0 : lyricsOptions.hyphen : void 0;
5386
5463
  this.text = new ObjText(this, { text: lyricsText, color: this.color, scale: 0.8 }, halign, 0);
5387
- this.rect = new DivRect();
5464
+ this.rect = new import_ts_utils_lib24.AnchoredRect();
5388
5465
  this.mi = new MLyrics(this);
5389
5466
  }
5390
5467
  getMusicInterface() {
@@ -5404,7 +5481,7 @@ var ObjLyrics = class extends MusicObject {
5404
5481
  }
5405
5482
  layout(ctx) {
5406
5483
  this.text.layout(ctx);
5407
- this.rect = this.text.getRect().copy();
5484
+ this.rect = this.text.getRect().clone();
5408
5485
  }
5409
5486
  offset(dx, dy) {
5410
5487
  this.text.offset(dx, dy);
@@ -5422,7 +5499,7 @@ var ObjLyrics = class extends MusicObject {
5422
5499
  let w = this.hyphen === "-" /* Hyphen */ ? Math.min(hyphenw, maxw) : maxw;
5423
5500
  if (w > 0) {
5424
5501
  let cx = r ? (r.left + l.right) / 2 : l.right + w / 0.85;
5425
- let cy = (l.top + l.bottom) / 2;
5502
+ let cy = l.centerY / 2;
5426
5503
  ctx.moveTo(cx - w / 2, cy);
5427
5504
  ctx.lineTo(cx + w / 2, cy);
5428
5505
  ctx.stroke();
@@ -5432,7 +5509,7 @@ var ObjLyrics = class extends MusicObject {
5432
5509
  };
5433
5510
 
5434
5511
  // src/score/engine/obj-tab-rhythm.ts
5435
- var import_ts_utils_lib13 = require("@tspro/ts-utils-lib");
5512
+ var import_ts_utils_lib25 = require("@tspro/ts-utils-lib");
5436
5513
  var ObjTabRhythm = class extends MusicObject {
5437
5514
  constructor(measure, tab) {
5438
5515
  super(measure);
@@ -5441,9 +5518,9 @@ var ObjTabRhythm = class extends MusicObject {
5441
5518
  __publicField(this, "voiceId");
5442
5519
  __publicField(this, "mi");
5443
5520
  // Keep non-static
5444
- __publicField(this, "tupletPartsTextObjMap", /* @__PURE__ */ new Map());
5521
+ __publicField(this, "tupletPartsTextObjMap", new import_ts_utils_lib25.UniMap());
5445
5522
  this.voiceId = getVoiceIds().filter((voiceId) => tab.containsVoiceId(voiceId));
5446
- this.rect = new DivRect();
5523
+ this.rect = new import_ts_utils_lib25.AnchoredRect();
5447
5524
  this.mi = new MTabRhythm(this);
5448
5525
  }
5449
5526
  getMusicInterface() {
@@ -5454,9 +5531,9 @@ var ObjTabRhythm = class extends MusicObject {
5454
5531
  }
5455
5532
  layout(ctx) {
5456
5533
  let columns = this.measure.getColumns();
5457
- let numColsInVoiceId = getVoiceIds().map((voiceId) => import_ts_utils_lib13.Utils.Math.sum(columns.map((col) => col.getVoiceSymbol(voiceId) ? 1 : 0)));
5458
- this.voiceId.sort((a, b) => import_ts_utils_lib13.Utils.Math.cmp(numColsInVoiceId[a], numColsInVoiceId[b]));
5459
- this.rect = new DivRect();
5534
+ let numColsInVoiceId = getVoiceIds().map((voiceId) => import_ts_utils_lib25.Utils.Math.sum(columns.map((col) => col.getVoiceSymbol(voiceId) ? 1 : 0)));
5535
+ this.voiceId.sort((a, b) => import_ts_utils_lib25.Utils.Math.cmp(numColsInVoiceId[a], numColsInVoiceId[b]));
5536
+ this.rect = new import_ts_utils_lib25.AnchoredRect();
5460
5537
  }
5461
5538
  hasTuplets() {
5462
5539
  return this.measure.getBeamGroups().some((beamGroup) => beamGroup.isTuplet());
@@ -5464,13 +5541,13 @@ var ObjTabRhythm = class extends MusicObject {
5464
5541
  layoutFitToMeasure(ctx) {
5465
5542
  let { unitSize, fontSize } = ctx;
5466
5543
  let { measure } = this;
5467
- let { left, right } = measure.getColumnsContentRect();
5544
+ let cr = measure.getColumnsContentRect();
5468
5545
  let stemHeight = unitSize * 5;
5469
- this.rect.left = left;
5470
- this.rect.centerX = (left + right) / 2;
5471
- this.rect.right = right;
5546
+ this.rect.left = cr.left;
5547
+ this.rect.anchorX = cr.centerX;
5548
+ this.rect.right = cr.right;
5472
5549
  this.rect.top = this.hasTuplets() ? -fontSize : 0;
5473
- this.rect.centerY = 0;
5550
+ this.rect.anchorY = 0;
5474
5551
  this.rect.bottom = stemHeight;
5475
5552
  }
5476
5553
  offset(dx, dy) {
@@ -5483,8 +5560,8 @@ var ObjTabRhythm = class extends MusicObject {
5483
5560
  let flagSize = unitSize;
5484
5561
  let dotSpace = unitSize;
5485
5562
  let dotWidth = unitSize * 0.25;
5486
- let { bottom, centerY } = this.getRect();
5487
- let stemTop = centerY;
5563
+ let { bottom, anchorY } = this.getRect();
5564
+ let stemTop = anchorY;
5488
5565
  let stemBottom = bottom;
5489
5566
  let columns = this.measure.getColumns();
5490
5567
  for (let colId = 0; colId < columns.length; colId++) {
@@ -5498,7 +5575,7 @@ var ObjTabRhythm = class extends MusicObject {
5498
5575
  for (let j = 0; j < symbols.length; j++) {
5499
5576
  let sym = symbols[j];
5500
5577
  let nextSym = symbols[j + 1];
5501
- let colX = sym.col.getRect().centerX;
5578
+ let colX = sym.col.getRect().anchorX;
5502
5579
  if (sym instanceof ObjNoteGroup) {
5503
5580
  if (sym.rhythmProps.noteSize >= 2) {
5504
5581
  ctx.lineWidth(sym.rhythmProps.noteSize === 4 ? 2 : 1);
@@ -5507,7 +5584,7 @@ var ObjTabRhythm = class extends MusicObject {
5507
5584
  ctx.lineWidth(1);
5508
5585
  if (symbols.length === 1) {
5509
5586
  for (let i = 0; i < sym.rhythmProps.flagCount; i++) {
5510
- ctx.drawFlag(new DivRect(colX, colX + flagSize, stemTop + i * flagSize, stemTop + (i + 2) * flagSize), "up");
5587
+ ctx.drawFlag(new import_ts_utils_lib25.AnchoredRect(colX, colX + flagSize, stemTop + i * flagSize, stemTop + (i + 2) * flagSize), "up");
5511
5588
  }
5512
5589
  }
5513
5590
  for (let i = 0; i < sym.rhythmProps.dotCount; i++) {
@@ -5529,8 +5606,8 @@ var ObjTabRhythm = class extends MusicObject {
5529
5606
  if (nextSym) {
5530
5607
  let left = sym;
5531
5608
  let right = nextSym;
5532
- let leftX = left.col.getRect().centerX;
5533
- let rightX = right.col.getRect().centerX;
5609
+ let leftX = left.col.getRect().anchorX;
5610
+ let rightX = right.col.getRect().anchorX;
5534
5611
  let leftBeamCount = left.hasTuplet() ? 1 : left instanceof ObjNoteGroup ? left.getRightBeamCount() : 1;
5535
5612
  let rightBeamCount = right.hasTuplet() ? 1 : right instanceof ObjNoteGroup ? right.getLeftBeamCount() : 1;
5536
5613
  let maxBeamCount = Math.max(leftBeamCount, rightBeamCount);
@@ -5549,14 +5626,14 @@ var ObjTabRhythm = class extends MusicObject {
5549
5626
  }
5550
5627
  }
5551
5628
  if (beamGroup && beamGroup.isTuplet()) {
5552
- let cx = (symbols[0].col.getRect().centerX + symbols[symbols.length - 1].col.getRect().centerX) / 2;
5629
+ let cx = (symbols[0].col.getRect().anchorX + symbols[symbols.length - 1].col.getRect().anchorX) / 2;
5553
5630
  let text = beamGroup.getTupletRatioText();
5554
5631
  let textObj = this.tupletPartsTextObjMap.get(text);
5555
5632
  if (!textObj) {
5556
5633
  this.tupletPartsTextObjMap.set(text, textObj = new ObjText(this, { text, scale: 0.75 }, 0.5, 0.5));
5557
5634
  textObj.layout(ctx);
5558
5635
  }
5559
- textObj.offset(-textObj.getRect().centerX, -textObj.getRect().centerY);
5636
+ textObj.offset(-textObj.getRect().anchorX, -textObj.getRect().anchorY);
5560
5637
  textObj.offset(cx, stemTop - fontSize / 2);
5561
5638
  textObj.draw(ctx);
5562
5639
  }
@@ -5572,18 +5649,11 @@ var ObjTabRhythm = class extends MusicObject {
5572
5649
  };
5573
5650
 
5574
5651
  // src/score/engine/obj-measure.ts
5575
- function validateVoiceId(voiceId) {
5576
- if (typeof voiceId === "number" && getVoiceIds().indexOf(voiceId) < 0) {
5577
- throw new import_core14.MusicError(import_core14.MusicErrorType.Score, "Invalid voiceId: " + voiceId);
5578
- } else {
5579
- return voiceId;
5580
- }
5581
- }
5582
5652
  function getExtensionTicks(extensionLength) {
5583
5653
  if (typeof extensionLength === "string") {
5584
5654
  extensionLength = [extensionLength];
5585
5655
  }
5586
- if (import_ts_utils_lib14.Utils.Is.isArray(extensionLength)) {
5656
+ if (import_ts_utils_lib26.Guard.isArray(extensionLength)) {
5587
5657
  let totalTicks = 0;
5588
5658
  for (let i = 0; i < extensionLength.length; ) {
5589
5659
  let str = extensionLength[i];
@@ -5614,7 +5684,7 @@ function getVerseLayoutGroupId(verse) {
5614
5684
  case 3:
5615
5685
  return 10 /* LyricsVerse3 */;
5616
5686
  default:
5617
- throw new import_core14.MusicError(import_core14.MusicErrorType.Unknown, "VerseNumber is not 1, 2 or 3.");
5687
+ throw new import_core13.MusicError(import_core13.MusicErrorType.Unknown, "VerseNumber is not 1, 2 or 3.");
5618
5688
  }
5619
5689
  }
5620
5690
  var _ObjMeasure = class _ObjMeasure extends MusicObject {
@@ -5643,7 +5713,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5643
5713
  __publicField(this, "leftSolidAreaWidth", 0);
5644
5714
  __publicField(this, "minColumnsAreaWidth", 0);
5645
5715
  __publicField(this, "rightSolidAreaWidth", 0);
5646
- __publicField(this, "voiceSymbols", []);
5716
+ __publicField(this, "voiceSymbols", (0, import_ts_utils_lib26.asMulti)(new import_ts_utils_lib26.IndexArray()));
5647
5717
  __publicField(this, "lastAddedRhythmColumn");
5648
5718
  __publicField(this, "lastAddedRhythmSymbol");
5649
5719
  __publicField(this, "addExtensionToMusicObjects", []);
@@ -5652,14 +5722,14 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5652
5722
  __publicField(this, "passCount", 0);
5653
5723
  // How many times player has passed this measure.
5654
5724
  __publicField(this, "needBeamsUpdate", true);
5655
- __publicField(this, "navigationSet", /* @__PURE__ */ new Set());
5725
+ __publicField(this, "navigationSet", new import_ts_utils_lib26.ValueSet());
5656
5726
  __publicField(this, "isEndSong", false);
5657
5727
  __publicField(this, "isEndSection", false);
5658
5728
  __publicField(this, "endRepeatPlayCount", 2);
5659
5729
  // play twice.
5660
5730
  __publicField(this, "endRepeatPlayCountText");
5661
- __publicField(this, "staticObjectsCache", /* @__PURE__ */ new Map());
5662
- __publicField(this, "lyricsObjectsCache", new import_ts_utils_lib14.Map3());
5731
+ __publicField(this, "staticObjectsCache", new import_ts_utils_lib26.UniMap());
5732
+ __publicField(this, "lyricsObjectsCache", new import_ts_utils_lib26.TriMap());
5663
5733
  __publicField(this, "mi");
5664
5734
  this.mi = new MMeasure(this);
5665
5735
  this.prevMeasure = row.doc.getLastMeasure();
@@ -5700,7 +5770,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5700
5770
  updateRunningArguments(runningArgs) {
5701
5771
  var _a;
5702
5772
  runningArgs != null ? runningArgs : runningArgs = [];
5703
- let numVoices = import_ts_utils_lib14.Utils.Math.sum(getVoiceIds().map((voiceId) => this.getVoiceSymbols(voiceId).length > 0 ? 1 : 0));
5773
+ let numVoices = import_ts_utils_lib26.Utils.Math.sum(getVoiceIds().map((voiceId) => this.getVoiceSymbols(voiceId).length > 0 ? 1 : 0));
5704
5774
  getVoiceIds().forEach((voiceId) => {
5705
5775
  var _a2;
5706
5776
  const getDefaultDiatonicId = () => {
@@ -5859,7 +5929,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5859
5929
  this.alterKeySignature = args[0];
5860
5930
  } else if (args[0] instanceof import_theory9.Scale) {
5861
5931
  this.alterKeySignature = args[0];
5862
- } else if (import_ts_utils_lib14.Utils.Is.isNonEmptyString(args[0])) {
5932
+ } else if (import_ts_utils_lib26.Guard.isNonEmptyString(args[0])) {
5863
5933
  if (args.length === 1) {
5864
5934
  this.alterKeySignature = (0, import_theory9.getScale)(args[0]);
5865
5935
  } else if (args.length === 2) {
@@ -5868,7 +5938,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5868
5938
  let scaleType = (0, import_theory9.validateScaleType)("" + args[1]);
5869
5939
  this.alterKeySignature = (0, import_theory9.getScale)(tonic, scaleType);
5870
5940
  } catch (e) {
5871
- throw new import_core14.MusicError(import_core14.MusicErrorType.Score, "Cannot set key signature because invalid args: " + args);
5941
+ throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Cannot set key signature because invalid args: " + args);
5872
5942
  }
5873
5943
  }
5874
5944
  }
@@ -5970,7 +6040,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5970
6040
  let grp = this.doc.getStaffGroup(staffTabOrGroup);
5971
6041
  if (grp && !prevGroups.includes(staffTabOrGroup)) {
5972
6042
  let curGroups = [...prevGroups, staffTabOrGroup];
5973
- (import_ts_utils_lib14.Utils.Is.isArray(grp.staffsTabsAndGroups) ? grp.staffsTabsAndGroups : [grp.staffsTabsAndGroups]).forEach((staffTabOrGroup2) => {
6043
+ (import_ts_utils_lib26.Guard.isArray(grp.staffsTabsAndGroups) ? grp.staffsTabsAndGroups : [grp.staffsTabsAndGroups]).forEach((staffTabOrGroup2) => {
5974
6044
  switch (grp.verticalPosition) {
5975
6045
  case "above" /* Above */:
5976
6046
  addToStaffTabOrGroup(staffTabOrGroup2, 0 /* Above */, curGroups);
@@ -5997,7 +6067,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5997
6067
  } else {
5998
6068
  addToStaffTabOrGroup(0, defaultVerticalPos);
5999
6069
  }
6000
- } else if (import_ts_utils_lib14.Utils.Is.isArray(staffTabOrGroups)) {
6070
+ } else if (import_ts_utils_lib26.Guard.isArray(staffTabOrGroups)) {
6001
6071
  staffTabOrGroups.forEach((staffTabOrGroup) => addToStaffTabOrGroup(staffTabOrGroup, defaultVerticalPos));
6002
6072
  } else {
6003
6073
  addToStaffTabOrGroup(staffTabOrGroups, defaultVerticalPos);
@@ -6006,7 +6076,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
6006
6076
  addFermata(staffTabOrGroups, fermata) {
6007
6077
  let anchor = fermata === "atMeasureEnd" /* AtMeasureEnd */ ? this.barLineRight : this.lastAddedRhythmColumn;
6008
6078
  if (!anchor) {
6009
- throw new import_core14.MusicError(import_core14.MusicErrorType.Score, "Cannot add Fermata because anchor is undefined.");
6079
+ throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Cannot add Fermata because anchor is undefined.");
6010
6080
  }
6011
6081
  this.forEachStaffGroup(staffTabOrGroups, 0 /* Above */, (line, vpos) => {
6012
6082
  this.addLayoutObject(new ObjFermata(anchor, vpos), line, 1 /* Fermata */, vpos);
@@ -6022,7 +6092,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
6022
6092
  switch (navigation) {
6023
6093
  case "ending" /* Ending */:
6024
6094
  if (this.navigationSet.has(navigation)) {
6025
- throw new import_core14.MusicError(import_core14.MusicErrorType.Score, "Cannot add ending beasure measure already has one.");
6095
+ throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Cannot add ending beasure measure already has one.");
6026
6096
  }
6027
6097
  let anchor = this;
6028
6098
  let passages = args;
@@ -6081,10 +6151,10 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
6081
6151
  case "endRepeat" /* EndRepeat */:
6082
6152
  if (args.length === 0) {
6083
6153
  this.endRepeatPlayCount = 2;
6084
- } else if (import_ts_utils_lib14.Utils.Is.isIntegerGte(args[0], 2)) {
6154
+ } else if (import_ts_utils_lib26.Guard.isIntegerGte(args[0], 2)) {
6085
6155
  this.endRepeatPlayCount = args[0];
6086
6156
  } else {
6087
- throw new import_core14.MusicError(import_core14.MusicErrorType.Score, "Invalid end repeat play count (should be 2 or greater integer): " + args[0]);
6157
+ throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Invalid end repeat play count (should be 2 or greater integer): " + args[0]);
6088
6158
  }
6089
6159
  if (this.endRepeatPlayCount !== 2) {
6090
6160
  let textProps = {
@@ -6109,9 +6179,9 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
6109
6179
  addAnnotation(staffTabOrGroups, annotation, text) {
6110
6180
  let anchor = this.lastAddedRhythmColumn;
6111
6181
  if (!anchor) {
6112
- throw new import_core14.MusicError(import_core14.MusicErrorType.Score, "Cannot add annotation because anchor is undefined.");
6182
+ throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Cannot add annotation because anchor is undefined.");
6113
6183
  } else if (text.length === 0) {
6114
- throw new import_core14.MusicError(import_core14.MusicErrorType.Score, "Cannot add annotation because annotation text is empty.");
6184
+ throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Cannot add annotation because annotation text is empty.");
6115
6185
  }
6116
6186
  let textProps = { text };
6117
6187
  let layoutGroupId;
@@ -6138,9 +6208,9 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
6138
6208
  addLabel(staffTabOrGroups, label, text) {
6139
6209
  let anchor = this.lastAddedRhythmColumn;
6140
6210
  if (!anchor) {
6141
- throw new import_core14.MusicError(import_core14.MusicErrorType.Score, "Cannot add label because anchor is undefined.");
6211
+ throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Cannot add label because anchor is undefined.");
6142
6212
  } else if (text.length === 0) {
6143
- throw new import_core14.MusicError(import_core14.MusicErrorType.Score, "Cannot add label because label text is empty.");
6213
+ throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Cannot add label because label text is empty.");
6144
6214
  }
6145
6215
  let textProps = { text };
6146
6216
  let layoutGroupId;
@@ -6165,18 +6235,18 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
6165
6235
  addConnective(connective, ...args) {
6166
6236
  let anchor = this.lastAddedRhythmSymbol;
6167
6237
  if (!(anchor instanceof ObjNoteGroup)) {
6168
- throw new import_core14.MusicError(import_core14.MusicErrorType.Score, "Connective can be added to note group only.");
6238
+ throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Connective can be added to note group only.");
6169
6239
  }
6170
6240
  if (connective === "tie" /* Tie */) {
6171
- let tieSpan = import_ts_utils_lib14.Utils.Is.isInteger(args[0]) || import_ts_utils_lib14.Utils.Is.isEnumValue(args[0], TieType) ? args[0] : 2;
6172
- let noteAnchor = import_ts_utils_lib14.Utils.Is.isEnumValue(args[1], NoteAnchor) ? args[1] : "auto" /* Auto */;
6241
+ let tieSpan = import_ts_utils_lib26.Guard.isInteger(args[0]) || import_ts_utils_lib26.Guard.isEnumValue(args[0], TieType) ? args[0] : 2;
6242
+ let noteAnchor = import_ts_utils_lib26.Guard.isEnumValue(args[1], NoteAnchor) ? args[1] : "auto" /* Auto */;
6173
6243
  anchor.startConnective(new ConnectiveProps("tie" /* Tie */, tieSpan, noteAnchor, anchor));
6174
6244
  } else if (connective === "slur" /* Slur */) {
6175
- let slurSpan = import_ts_utils_lib14.Utils.Is.isInteger(args[0]) ? args[0] : 2;
6176
- let noteAnchor = import_ts_utils_lib14.Utils.Is.isEnumValue(args[1], NoteAnchor) ? args[1] : "auto" /* Auto */;
6245
+ let slurSpan = import_ts_utils_lib26.Guard.isInteger(args[0]) ? args[0] : 2;
6246
+ let noteAnchor = import_ts_utils_lib26.Guard.isEnumValue(args[1], NoteAnchor) ? args[1] : "auto" /* Auto */;
6177
6247
  anchor.startConnective(new ConnectiveProps("slur" /* Slur */, slurSpan, noteAnchor, anchor));
6178
6248
  } else if (connective === "slide" /* Slide */) {
6179
- let noteAnchor = import_ts_utils_lib14.Utils.Is.isEnumValue(args[0], NoteAnchor) ? args[0] : "auto" /* Auto */;
6249
+ let noteAnchor = import_ts_utils_lib26.Guard.isEnumValue(args[0], NoteAnchor) ? args[0] : "auto" /* Auto */;
6180
6250
  anchor.startConnective(new ConnectiveProps("slide" /* Slide */, 2, noteAnchor, anchor));
6181
6251
  }
6182
6252
  }
@@ -6189,11 +6259,11 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
6189
6259
  let extension = new Extension(musicObj, anchor, getExtensionTicks(extensionLength), extensionVisible, lineStyle, linePos);
6190
6260
  musicObj.setLink(extension);
6191
6261
  } else {
6192
- throw new import_core14.MusicError(import_core14.MusicErrorType.Score, "Cannot add extension becaue no compatible music object to attach it to.");
6262
+ throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Cannot add extension becaue no compatible music object to attach it to.");
6193
6263
  }
6194
6264
  });
6195
6265
  if (this.addExtensionToMusicObjects.length === 0) {
6196
- throw new import_core14.MusicError(import_core14.MusicErrorType.Score, "Cannot add extension because music object to attach it to is undefined.");
6266
+ throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Cannot add extension because music object to attach it to is undefined.");
6197
6267
  }
6198
6268
  this.disableExtension();
6199
6269
  this.requestLayout();
@@ -6231,11 +6301,9 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
6231
6301
  this.disableExtension();
6232
6302
  }
6233
6303
  addRhythmSymbol(symbol) {
6234
- var _a, _b;
6235
6304
  let { col, voiceId } = symbol;
6236
6305
  col.setVoiceSymbol(voiceId, symbol);
6237
- (_b = (_a = this.voiceSymbols)[voiceId]) != null ? _b : _a[voiceId] = [];
6238
- this.voiceSymbols[voiceId].push(symbol);
6306
+ this.voiceSymbols.add(voiceId, symbol);
6239
6307
  if (symbol.oldStyleTriplet) {
6240
6308
  this.createOldStyleTriplets(voiceId);
6241
6309
  }
@@ -6262,9 +6330,9 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
6262
6330
  let col = this.getRhythmColumn({ verse, line, vpos });
6263
6331
  let lyricsObj = new ObjLyrics(col, verse, line, vpos, (0, import_theory9.validateNoteLength)(lyricsLength), lyricsText, lyricsOptions);
6264
6332
  col.addLyricsObject(lyricsObj);
6265
- let lyricsArr = this.getLyricsObjects(line, vpos, verse);
6333
+ let lyricsArr = this.lyricsObjectsCache.getOrCreate(line, vpos, verse, []);
6266
6334
  lyricsArr.push(lyricsObj);
6267
- lyricsArr.sort((a, b) => import_ts_utils_lib14.Utils.Math.cmp(a.col.positionTicks, b.col.positionTicks));
6335
+ lyricsArr.sort((a, b) => import_ts_utils_lib26.Utils.Math.cmp(a.col.positionTicks, b.col.positionTicks));
6268
6336
  (_a = lyricsObj.measure.getPrevLyricsObject(lyricsObj)) == null ? void 0 : _a.setNextLyricsObject(lyricsObj);
6269
6337
  this.addLayoutObject(lyricsObj, line, getVerseLayoutGroupId(verse), vpos);
6270
6338
  this.lastAddedRhythmColumn = col;
@@ -6294,7 +6362,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
6294
6362
  return col2;
6295
6363
  }
6296
6364
  }
6297
- throw new import_core14.MusicError(import_core14.MusicErrorType.Score, "Error in rhythm column. Should never get here.");
6365
+ throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Error in rhythm column. Should never get here.");
6298
6366
  }
6299
6367
  getMeasureTicks() {
6300
6368
  return this.getTimeSignature().measureTicks;
@@ -6313,9 +6381,9 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
6313
6381
  }
6314
6382
  // Get content rect excluding signature
6315
6383
  getColumnsContentRect() {
6316
- return new DivRect(
6317
- this.barLineLeft.getRect().centerX,
6318
- this.barLineRight.getRect().centerX,
6384
+ return new import_ts_utils_lib26.AnchoredRect(
6385
+ this.barLineLeft.getRect().anchorX,
6386
+ this.barLineRight.getRect().anchorX,
6319
6387
  this.getRect().top,
6320
6388
  this.getRect().bottom
6321
6389
  );
@@ -6344,24 +6412,17 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
6344
6412
  }
6345
6413
  }
6346
6414
  getStaffLineRight() {
6347
- return this.barLineRight.getRect().centerX;
6348
- }
6349
- getLyricsObjects(line, vpos, verse) {
6350
- let lyricsObjs = this.lyricsObjectsCache.get(line, vpos, verse);
6351
- if (!lyricsObjs) {
6352
- this.lyricsObjectsCache.set(line, vpos, verse, lyricsObjs = []);
6353
- }
6354
- return lyricsObjs;
6415
+ return this.barLineRight.getRect().anchorX;
6355
6416
  }
6356
6417
  getPrevLyricsObject(lyricsObj) {
6357
6418
  var _a;
6358
6419
  let { line, verse, vpos } = lyricsObj;
6359
- let lyricsArr = this.getLyricsObjects(line, vpos, verse);
6420
+ let lyricsArr = this.lyricsObjectsCache.getOrDefault(line, vpos, verse, []);
6360
6421
  let i = lyricsArr.indexOf(lyricsObj);
6361
6422
  if (i > 0) {
6362
6423
  return lyricsArr[i - 1];
6363
6424
  } else if (i === 0) {
6364
- let lyricsArr2 = (_a = lyricsObj.measure.getPrevMeasure()) == null ? void 0 : _a.getLyricsObjects(line, vpos, verse);
6425
+ let lyricsArr2 = (_a = lyricsObj.measure.getPrevMeasure()) == null ? void 0 : _a.lyricsObjectsCache.get(line, vpos, verse);
6365
6426
  if (lyricsArr2 && lyricsArr2.length > 0) {
6366
6427
  return lyricsArr2[lyricsArr2.length - 1];
6367
6428
  }
@@ -6369,14 +6430,13 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
6369
6430
  return void 0;
6370
6431
  }
6371
6432
  getStaticObjects(line) {
6372
- let staticObjects = this.staticObjectsCache.get(line);
6373
- if (!staticObjects) {
6374
- staticObjects = [];
6375
- this.getColumns().forEach((col) => col.getStaticObjects(line).forEach((obj) => staticObjects == null ? void 0 : staticObjects.push(obj)));
6376
- this.staticObjectsCache.set(line, staticObjects);
6377
- }
6378
6433
  let layoutObjects = this.layoutObjects.filter((layoutObj) => layoutObj.line === line && layoutObj.isPositionResolved()).map((layoutObj) => layoutObj.musicObj);
6379
- return layoutObjects.length > 0 ? [...staticObjects, ...layoutObjects] : staticObjects;
6434
+ let staticObjects = layoutObjects.length > 0 ? [...this.staticObjectsCache.getOrDefault(line, []), ...layoutObjects] : this.staticObjectsCache.getOrDefault(line, []);
6435
+ staticObjects.forEach((obj) => obj.getRect());
6436
+ return staticObjects;
6437
+ }
6438
+ addStaticObject(line, staticObj) {
6439
+ this.staticObjectsCache.getOrCreate(line, []).push(staticObj);
6380
6440
  }
6381
6441
  removeLayoutObjects(musicObj) {
6382
6442
  this.layoutObjects = this.layoutObjects.filter((layoutObj) => {
@@ -6475,7 +6535,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
6475
6535
  let beamGroupSize = ts.beamGroupSizes[groupId];
6476
6536
  let beamGroupSizeList = [beamGroupSize];
6477
6537
  if (beamGroupSize.length > 1) {
6478
- beamGroupSizeList.unshift([import_ts_utils_lib14.Utils.Math.sum(beamGroupSize)]);
6538
+ beamGroupSizeList.unshift([import_ts_utils_lib26.Utils.Math.sum(beamGroupSize)]);
6479
6539
  }
6480
6540
  let beamCreated = false;
6481
6541
  let groupStartTicksSave = groupStartTicks;
@@ -6490,7 +6550,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
6490
6550
  let symbolEndTicks = symbolStartTicks + symbol.rhythmProps.ticks;
6491
6551
  return symbolStartTicks >= groupStartTicks && symbolEndTicks <= groupEndTicks;
6492
6552
  });
6493
- let groupSymbolsTicks = import_ts_utils_lib14.Utils.Math.sum(groupSymbols.map((sym) => sym.rhythmProps.ticks));
6553
+ let groupSymbolsTicks = import_ts_utils_lib26.Utils.Math.sum(groupSymbols.map((sym) => sym.rhythmProps.ticks));
6494
6554
  if (groupSymbolsTicks === beamGroupTicks && groupSymbols.every((n) => n instanceof ObjNoteGroup) && (groupSymbols.every((n) => n.rhythmProps.flagCount === 1) || beamGroupSizeList.length === 0)) {
6495
6555
  if (ObjBeamGroup.createBeam(groupSymbols)) {
6496
6556
  beamCreated = true;
@@ -6511,10 +6571,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
6511
6571
  return this.barLineRight;
6512
6572
  }
6513
6573
  getVoiceSymbols(voiceId) {
6514
- var _a, _b;
6515
- validateVoiceId(voiceId);
6516
- (_b = (_a = this.voiceSymbols)[voiceId]) != null ? _b : _a[voiceId] = [];
6517
- return this.voiceSymbols[voiceId];
6574
+ return this.voiceSymbols.getAll(voiceId);
6518
6575
  }
6519
6576
  completeRests(voiceId) {
6520
6577
  if (voiceId === void 0) {
@@ -6524,7 +6581,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
6524
6581
  this.completeRests(getVoiceIds().filter((id) => this.getConsumedTicks(id) > 0));
6525
6582
  }
6526
6583
  return;
6527
- } else if (import_ts_utils_lib14.Utils.Is.isArray(voiceId)) {
6584
+ } else if (import_ts_utils_lib26.Guard.isArray(voiceId)) {
6528
6585
  voiceId.forEach((id) => this.completeRests(id));
6529
6586
  return;
6530
6587
  } else {
@@ -6628,34 +6685,43 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
6628
6685
  return;
6629
6686
  }
6630
6687
  width = Math.max(width, this.getMinWidth());
6631
- this.rect = new DivRect();
6632
- this.rect.centerX = this.rect.left + width / 2;
6688
+ this.rect = new import_ts_utils_lib26.AnchoredRect();
6689
+ this.rect.anchorX = this.rect.left + width / 2;
6633
6690
  this.rect.right = this.rect.left + width;
6634
6691
  let rect;
6635
6692
  this.signatures.forEach((signature) => {
6636
6693
  rect = signature.getRect();
6637
- signature.offset(this.rect.left + this.tabStringNotesWidth - rect.left, -rect.centerY);
6694
+ signature.offset(this.rect.left + this.tabStringNotesWidth - rect.left, -rect.anchorY);
6638
6695
  });
6639
6696
  let signaturesWidth = Math.max(0, ...this.signatures.map((signature) => signature.getRect().width));
6640
6697
  rect = this.barLineLeft.getRect();
6641
- this.barLineLeft.offset(this.rect.left + this.tabStringNotesWidth + signaturesWidth - rect.left, -rect.centerY);
6698
+ this.barLineLeft.offset(this.rect.left + this.tabStringNotesWidth + signaturesWidth - rect.left, -rect.anchorY);
6642
6699
  rect = this.barLineRight.getRect();
6643
- this.barLineRight.offset(this.rect.right - rect.right, -rect.centerY);
6700
+ this.barLineRight.offset(this.rect.right - rect.right, -rect.anchorY);
6644
6701
  if (this.endRepeatPlayCountText) {
6645
6702
  this.endRepeatPlayCountText.offset(this.barLineRight.getRect().left, this.barLineRight.getRect().top);
6646
6703
  }
6647
6704
  let columnsAreaLeft = this.rect.left + this.leftSolidAreaWidth;
6648
6705
  let columnsAreaRight = this.rect.right - this.rightSolidAreaWidth;
6649
6706
  let columnsAreaWidth = columnsAreaRight - columnsAreaLeft;
6650
- let columnsWidth = import_ts_utils_lib14.Utils.Math.sum(this.columns.map((col) => col.getRect().width));
6707
+ let columnsWidth = import_ts_utils_lib26.Utils.Math.sum(this.columns.map((col) => col.getRect().width));
6651
6708
  let columnScale = columnsAreaWidth / columnsWidth;
6652
6709
  let columnLeft = columnsAreaLeft;
6653
6710
  this.columns.forEach((col) => {
6654
6711
  rect = col.getRect();
6655
- let columnCenterX = columnLeft + rect.leftw * columnScale;
6656
- col.offset(columnCenterX - rect.centerX, -rect.centerY);
6712
+ let columnAnchorX = columnLeft + rect.leftw * columnScale;
6713
+ col.offset(columnAnchorX - rect.anchorX, -rect.anchorY);
6657
6714
  columnLeft += rect.width * columnScale;
6658
6715
  });
6716
+ getVoiceIds().forEach((voiceId) => {
6717
+ const symbols = this.getVoiceSymbols(voiceId);
6718
+ const onlyRest = symbols.length === 1 && symbols[0] instanceof ObjRest ? symbols[0] : void 0;
6719
+ if (!onlyRest) return;
6720
+ const isOnlySymbolInCol = getVoiceIds().map((voiceId2) => onlyRest.col.getVoiceSymbol(voiceId2)).filter((sym) => sym !== void 0 && sym !== onlyRest).length === 0;
6721
+ if (isOnlySymbolInCol) return;
6722
+ const r = this.getColumnsContentRect();
6723
+ onlyRest.offset(r.centerX - onlyRest.getRect().anchorX, 0);
6724
+ });
6659
6725
  }
6660
6726
  layoutConnectives(ctx) {
6661
6727
  if (!this.needLayout) {
@@ -6763,33 +6829,46 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
6763
6829
  }
6764
6830
  };
6765
6831
  __publicField(_ObjMeasure, "MinFlexContentWidth", 10);
6766
- var ObjMeasure2 = _ObjMeasure;
6832
+ var ObjMeasure = _ObjMeasure;
6767
6833
 
6768
6834
  // src/score/engine/layout-object.ts
6769
- var import_core15 = require("@tspro/web-music-score/core");
6770
- var WidenColumnList = [
6771
- 2 /* NoteLabel */,
6772
- 7 /* ChordLabel */
6773
- ];
6774
- var RowAlignList = [
6775
- 0 /* TabRhythm */,
6776
- 3 /* Navigation */,
6777
- 4 /* Ending */,
6778
- 5 /* TempoAnnotation */,
6779
- 6 /* DynamicsAnnotation */,
6780
- 7 /* ChordLabel */,
6781
- 8 /* LyricsVerse1 */,
6782
- 9 /* LyricsVerse2 */,
6783
- 10 /* LyricsVerse3 */
6784
- ];
6835
+ var import_core14 = require("@tspro/web-music-score/core");
6836
+ var import_ts_utils_lib27 = require("@tspro/ts-utils-lib");
6837
+ var LayoutGroupId = /* @__PURE__ */ ((LayoutGroupId2) => {
6838
+ LayoutGroupId2[LayoutGroupId2["TabRhythm"] = 0] = "TabRhythm";
6839
+ LayoutGroupId2[LayoutGroupId2["Fermata"] = 1] = "Fermata";
6840
+ LayoutGroupId2[LayoutGroupId2["NoteLabel"] = 2] = "NoteLabel";
6841
+ LayoutGroupId2[LayoutGroupId2["Navigation"] = 3] = "Navigation";
6842
+ LayoutGroupId2[LayoutGroupId2["Ending"] = 4] = "Ending";
6843
+ LayoutGroupId2[LayoutGroupId2["TempoAnnotation"] = 5] = "TempoAnnotation";
6844
+ LayoutGroupId2[LayoutGroupId2["DynamicsAnnotation"] = 6] = "DynamicsAnnotation";
6845
+ LayoutGroupId2[LayoutGroupId2["ChordLabel"] = 7] = "ChordLabel";
6846
+ LayoutGroupId2[LayoutGroupId2["LyricsVerse1"] = 8] = "LyricsVerse1";
6847
+ LayoutGroupId2[LayoutGroupId2["LyricsVerse2"] = 9] = "LyricsVerse2";
6848
+ LayoutGroupId2[LayoutGroupId2["LyricsVerse3"] = 10] = "LyricsVerse3";
6849
+ return LayoutGroupId2;
6850
+ })(LayoutGroupId || {});
6851
+ var LayoutGroupIdAttrs = new import_ts_utils_lib27.UniMap([
6852
+ [0 /* TabRhythm */, { rowAlign: true }],
6853
+ [1 /* Fermata */, {}],
6854
+ [2 /* NoteLabel */, { widen: true }],
6855
+ [3 /* Navigation */, { rowAlign: true }],
6856
+ [4 /* Ending */, { rowAlign: true, padding: 2 }],
6857
+ [5 /* TempoAnnotation */, { rowAlign: true, padding: 2 }],
6858
+ [6 /* DynamicsAnnotation */, { rowAlign: true, padding: 2 }],
6859
+ [7 /* ChordLabel */, { widen: true, rowAlign: true }],
6860
+ [8 /* LyricsVerse1 */, { rowAlign: true }],
6861
+ [9 /* LyricsVerse2 */, { rowAlign: true }],
6862
+ [10 /* LyricsVerse3 */, { rowAlign: true }]
6863
+ ]);
6785
6864
  function requireParentMeasure(p) {
6786
6865
  while (p) {
6787
- if (p instanceof ObjMeasure2) {
6866
+ if (p instanceof ObjMeasure) {
6788
6867
  return p;
6789
6868
  }
6790
6869
  p = p.getParent();
6791
6870
  }
6792
- throw new import_core15.MusicError(import_core15.MusicErrorType.Score, "Parent measure is required but not found!");
6871
+ throw new import_core14.MusicError(import_core14.MusicErrorType.Score, "Parent measure is required but not found!");
6793
6872
  }
6794
6873
  var StaffGroup = class {
6795
6874
  constructor(groupName, staffsTabsAndGroups, verticalPosition) {
@@ -6813,14 +6892,14 @@ var LayoutObjectWrapper = class {
6813
6892
  this.row = this.measure.row;
6814
6893
  let anchor = this.musicObj.getParent();
6815
6894
  if (!anchor) {
6816
- throw new import_core15.MusicError(import_core15.MusicErrorType.Score, "Parent music object is required as an anchor.");
6895
+ throw new import_core14.MusicError(import_core14.MusicErrorType.Score, "Parent music object is required as an anchor.");
6817
6896
  }
6818
6897
  this.anchor = anchor;
6819
6898
  this.anchor.addAnchoredLayoutObject(this);
6820
6899
  this.layoutGroup = this.line.getLayoutGroup(layoutGroupId);
6821
6900
  this.layoutGroup.add(this);
6822
6901
  }
6823
- clearPositionResolved() {
6902
+ resetPositionResolved() {
6824
6903
  this.positionResolved = false;
6825
6904
  }
6826
6905
  setPositionResolved() {
@@ -6841,8 +6920,8 @@ var LayoutObjectWrapper = class {
6841
6920
  let staticShapeRects = staticObj.getShapeRects();
6842
6921
  objShapeRects.forEach((objR) => {
6843
6922
  staticShapeRects.forEach((staticR) => {
6844
- if (DivRect.overlapX(objR, staticR)) {
6845
- y = verticalPos === 1 /* Below */ ? Math.max(y, staticR.bottom + objR.toph + objR.centerY) : Math.min(y, staticR.top - objR.bottomh - objR.centerY);
6923
+ if (import_ts_utils_lib27.AnchoredRect.overlapX(objR, staticR)) {
6924
+ y = verticalPos === 1 /* Below */ ? Math.max(y, staticR.bottom + objR.toph + objR.anchorY) : Math.min(y, staticR.top - objR.bottomh - objR.anchorY);
6846
6925
  }
6847
6926
  });
6848
6927
  });
@@ -6869,35 +6948,33 @@ var LayoutObjectWrapper = class {
6869
6948
  var LayoutGroup = class {
6870
6949
  constructor(layoutGroupId) {
6871
6950
  this.layoutGroupId = layoutGroupId;
6872
- __publicField(this, "layoutObjectTable", []);
6951
+ // key = VerticalPos
6952
+ __publicField(this, "layoutObject", (0, import_ts_utils_lib27.asMulti)(new import_ts_utils_lib27.IndexArray()));
6873
6953
  __publicField(this, "rowAlign");
6874
6954
  __publicField(this, "widensColumn");
6875
- this.layoutObjectTable[0 /* Above */] = [];
6876
- this.layoutObjectTable[1 /* Below */] = [];
6877
- this.rowAlign = RowAlignList.indexOf(layoutGroupId) >= 0;
6878
- this.widensColumn = WidenColumnList.indexOf(layoutGroupId) >= 0;
6955
+ __publicField(this, "padding");
6956
+ var _a, _b, _c, _d;
6957
+ this.rowAlign = ((_a = LayoutGroupIdAttrs.get(layoutGroupId)) == null ? void 0 : _a.rowAlign) === true;
6958
+ this.widensColumn = ((_b = LayoutGroupIdAttrs.get(layoutGroupId)) == null ? void 0 : _b.widen) === true;
6959
+ this.padding = (_d = (_c = LayoutGroupIdAttrs.get(layoutGroupId)) == null ? void 0 : _c.padding) != null ? _d : 0;
6879
6960
  }
6880
6961
  getLayoutObjects(verticalPos) {
6881
- return this.layoutObjectTable[verticalPos];
6962
+ return this.layoutObject.getAll(verticalPos);
6882
6963
  }
6883
6964
  add(layoutObj) {
6884
- this.layoutObjectTable[layoutObj.verticalPos].push(layoutObj);
6965
+ this.layoutObject.add(layoutObj.verticalPos, layoutObj);
6885
6966
  }
6886
6967
  remove(layoutObj) {
6887
- this.layoutObjectTable.forEach((layoutObjects) => {
6888
- let i = layoutObjects.indexOf(layoutObj);
6889
- if (i >= 0) {
6890
- layoutObjects.splice(i, 1);
6891
- }
6892
- });
6968
+ this.layoutObject.remove(layoutObj.verticalPos, layoutObj);
6893
6969
  }
6894
- clearPositionAndLayout(ctx) {
6895
- this.layoutObjectTable.forEach((layoutObjects) => {
6896
- layoutObjects.forEach((layoutObj) => {
6897
- layoutObj.clearPositionResolved();
6898
- layoutObj.musicObj.layout(ctx);
6899
- });
6900
- });
6970
+ layout(ctx) {
6971
+ for (const w of this.layoutObject.values()) {
6972
+ w.resetPositionResolved();
6973
+ w.musicObj.layout(ctx);
6974
+ }
6975
+ }
6976
+ getPadding(ctx) {
6977
+ return this.padding * ctx.unitSize;
6901
6978
  }
6902
6979
  };
6903
6980
 
@@ -6907,7 +6984,7 @@ var ObjNotationLine5 = class extends MusicObject {
6907
6984
  super(row);
6908
6985
  this.row = row;
6909
6986
  __publicField(this, "objects", []);
6910
- __publicField(this, "layoutGroups", []);
6987
+ __publicField(this, "layoutGroups", new import_ts_utils_lib28.UniMap());
6911
6988
  }
6912
6989
  addObject(o) {
6913
6990
  this.objects.push(o);
@@ -6916,41 +6993,36 @@ var ObjNotationLine5 = class extends MusicObject {
6916
6993
  this.objects.length = 0;
6917
6994
  }
6918
6995
  getLayoutGroup(lauoutGroupId) {
6919
- let layoutGroup = this.layoutGroups[lauoutGroupId];
6920
- if (!layoutGroup) {
6921
- layoutGroup = this.layoutGroups[lauoutGroupId] = new LayoutGroup(lauoutGroupId);
6922
- }
6923
- return layoutGroup;
6996
+ return this.layoutGroups.getOrCreate(lauoutGroupId, () => new LayoutGroup(lauoutGroupId));
6924
6997
  }
6925
6998
  resetLayoutGroups(ctx) {
6926
- this.layoutGroups.forEach((layoutGroup) => {
6927
- if (layoutGroup) {
6928
- layoutGroup.clearPositionAndLayout(ctx);
6929
- }
6930
- });
6999
+ this.layoutGroups.forEach((layoutGroup) => layoutGroup.layout(ctx));
6931
7000
  }
6932
7001
  layoutLayoutGroups(ctx) {
6933
- this.layoutGroups.forEach((layoutGroup) => {
7002
+ for (const groupId of import_ts_utils_lib28.Utils.Enum.getEnumValues(LayoutGroupId)) {
7003
+ const layoutGroup = this.getLayoutGroup(groupId);
6934
7004
  if (layoutGroup) {
6935
7005
  this.layoutLayoutGroup(ctx, layoutGroup, 0 /* Above */);
6936
7006
  this.layoutLayoutGroup(ctx, layoutGroup, 1 /* Below */);
6937
7007
  }
6938
- });
7008
+ }
6939
7009
  }
6940
7010
  setObjectY(layoutObj, y) {
6941
7011
  if (y === void 0) {
6942
7012
  return;
6943
7013
  }
6944
- layoutObj.offset(0, y - layoutObj.getRect().centerY);
7014
+ layoutObj.offset(0, y - layoutObj.getRect().anchorY);
6945
7015
  layoutObj.setPositionResolved();
6946
7016
  }
6947
- alignObjectsY(ctx, layoutObjArr) {
6948
- layoutObjArr = layoutObjArr.filter((layoutObj) => !layoutObj.isPositionResolved());
6949
- let rowY;
6950
- layoutObjArr.forEach((layoutObj) => {
6951
- let y = layoutObj.resolveClosestToStaffY(ctx);
6952
- rowY = layoutObj.verticalPos === 1 /* Below */ ? Math.max(y, rowY != null ? rowY : y) : Math.min(y, rowY != null ? rowY : y);
7017
+ alignObjectsY(ctx, layoutObjects, verticalPos) {
7018
+ const layoutObjArr = layoutObjects.filter((obj) => !obj.isPositionResolved() && obj.verticalPos === verticalPos);
7019
+ if (layoutObjArr.length === 0)
7020
+ return;
7021
+ const vdir = verticalPos === 1 /* Below */ ? 1 : -1;
7022
+ let yArr = layoutObjArr.map((layoutObj) => {
7023
+ return layoutObj.resolveClosestToStaffY(ctx) + layoutObj.layoutGroup.getPadding(ctx) * vdir;
6953
7024
  });
7025
+ const rowY = verticalPos === 1 /* Below */ ? Math.max(...yArr) : Math.min(...yArr);
6954
7026
  layoutObjArr.forEach((layoutObj) => this.setObjectY(layoutObj, rowY));
6955
7027
  }
6956
7028
  layoutLayoutGroup(ctx, layoutGroup, verticalPos) {
@@ -6960,20 +7032,20 @@ var ObjNotationLine5 = class extends MusicObject {
6960
7032
  if (musicObj instanceof ObjEnding || musicObj instanceof ObjExtensionLine || musicObj instanceof ObjTabRhythm) {
6961
7033
  musicObj.layoutFitToMeasure(ctx);
6962
7034
  } else {
6963
- musicObj.offset(anchor.getRect().centerX - musicObj.getRect().centerX, 0);
7035
+ musicObj.offset(anchor.getRect().anchorX - musicObj.getRect().anchorX, 0);
6964
7036
  }
6965
7037
  });
6966
7038
  if (layoutGroup.rowAlign) {
6967
- this.alignObjectsY(ctx, rowLayoutObjs);
7039
+ this.alignObjectsY(ctx, rowLayoutObjs, verticalPos);
6968
7040
  } else {
6969
7041
  rowLayoutObjs.forEach((layoutObj) => {
6970
7042
  let link = layoutObj.musicObj.getLink();
6971
7043
  if (link && link.getHead() === layoutObj.musicObj) {
6972
7044
  let objectParts = [link.getHead(), ...link.getTails()];
6973
7045
  let layoutObjs = rowLayoutObjs.filter((layoutObj2) => objectParts.some((o) => o === layoutObj2.musicObj));
6974
- this.alignObjectsY(ctx, layoutObjs);
7046
+ this.alignObjectsY(ctx, layoutObjs, verticalPos);
6975
7047
  } else {
6976
- this.alignObjectsY(ctx, [layoutObj]);
7048
+ this.alignObjectsY(ctx, [layoutObj], verticalPos);
6977
7049
  }
6978
7050
  });
6979
7051
  }
@@ -7006,7 +7078,7 @@ var ObjStaff = class extends ObjNotationLine5 {
7006
7078
  this.clefLineDiatonicId = getDiatonicId("F3", staffConfig.isOctaveDown === true);
7007
7079
  this.middleLineDiatonicId = this.clefLineDiatonicId - 2;
7008
7080
  } else {
7009
- throw new import_core16.MusicError(import_core16.MusicErrorType.Score, `Invalid staffConfig.clef ${staffConfig.clef}.`);
7081
+ throw new import_core15.MusicError(import_core15.MusicErrorType.Score, `Invalid staffConfig.clef ${staffConfig.clef}.`);
7010
7082
  }
7011
7083
  this.topLineDiatonicId = this.middleLineDiatonicId + 4;
7012
7084
  this.bottomLineDiatonicId = this.middleLineDiatonicId - 4;
@@ -7057,7 +7129,7 @@ var ObjStaff = class extends ObjNotationLine5 {
7057
7129
  } else if (this.joinedGrandStaff && this.joinedGrandStaff.containsDiatonicId(diatonicId)) {
7058
7130
  return this.joinedGrandStaff.getDiatonicIdY(diatonicId);
7059
7131
  } else {
7060
- throw new import_core16.MusicError(import_core16.MusicErrorType.Score, "Staff does not contain diatonicId " + diatonicId);
7132
+ throw new import_core15.MusicError(import_core15.MusicErrorType.Score, "Staff does not contain diatonicId " + diatonicId);
7061
7133
  }
7062
7134
  }
7063
7135
  getActualStaff(diatonicId) {
@@ -7066,7 +7138,7 @@ var ObjStaff = class extends ObjNotationLine5 {
7066
7138
  } else if (this.joinedGrandStaff && this.joinedGrandStaff.containsDiatonicId(diatonicId)) {
7067
7139
  return this.joinedGrandStaff;
7068
7140
  } else {
7069
- throw new import_core16.MusicError(import_core16.MusicErrorType.Score, "Staff does not contain diatonicId " + diatonicId);
7141
+ throw new import_core15.MusicError(import_core15.MusicErrorType.Score, "Staff does not contain diatonicId " + diatonicId);
7070
7142
  }
7071
7143
  }
7072
7144
  getDiatonicIdAt(y) {
@@ -7080,7 +7152,7 @@ var ObjStaff = class extends ObjNotationLine5 {
7080
7152
  return diatonicId % 2 !== this.middleLineDiatonicId % 2;
7081
7153
  }
7082
7154
  containsVoiceId(voiceId) {
7083
- return import_ts_utils_lib15.Utils.Is.isUndefined(this.staffConfig.voiceId) || import_ts_utils_lib15.Utils.Arr.toArray(this.staffConfig.voiceId).includes(voiceId);
7155
+ return import_ts_utils_lib28.Guard.isUndefined(this.staffConfig.voiceId) || import_ts_utils_lib28.Utils.Arr.toArray(this.staffConfig.voiceId).includes(voiceId);
7084
7156
  }
7085
7157
  calcTop() {
7086
7158
  let top = this.topLineY;
@@ -7110,7 +7182,7 @@ var ObjStaff = class extends ObjNotationLine5 {
7110
7182
  let h = unitSize * DocumentSettings.StaffHeight;
7111
7183
  this.topLineY = -h / 2;
7112
7184
  this.bottomLineY = h / 2;
7113
- this.rect = new DivRect(0, 0, this.topLineY, this.bottomLineY);
7185
+ this.rect = new import_ts_utils_lib28.AnchoredRect(0, 0, this.topLineY, this.bottomLineY);
7114
7186
  }
7115
7187
  layoutWidth(ctx) {
7116
7188
  this.rect.left = this.row.getRect().left;
@@ -7142,7 +7214,7 @@ var ObjTab = class extends ObjNotationLine5 {
7142
7214
  __publicField(this, "tuningName");
7143
7215
  __publicField(this, "tuningStrings");
7144
7216
  __publicField(this, "mi");
7145
- if (import_ts_utils_lib15.Utils.Is.isArray(tabConfig.tuning)) {
7217
+ if (import_ts_utils_lib28.Guard.isArray(tabConfig.tuning)) {
7146
7218
  this.tuningName = void 0;
7147
7219
  this.tuningStrings = tabConfig.tuning.map((noteName) => import_theory11.Note.getNote(noteName)).reverse();
7148
7220
  } else if (typeof tabConfig.tuning === "string") {
@@ -7193,7 +7265,7 @@ var ObjTab = class extends ObjNotationLine5 {
7193
7265
  return this.bottom;
7194
7266
  }
7195
7267
  containsVoiceId(voiceId) {
7196
- return import_ts_utils_lib15.Utils.Is.isUndefined(this.tabConfig.voiceId) || import_ts_utils_lib15.Utils.Arr.toArray(this.tabConfig.voiceId).includes(voiceId);
7268
+ return import_ts_utils_lib28.Guard.isUndefined(this.tabConfig.voiceId) || import_ts_utils_lib28.Utils.Arr.toArray(this.tabConfig.voiceId).includes(voiceId);
7197
7269
  }
7198
7270
  containsDiatonicId(diatonicId) {
7199
7271
  return true;
@@ -7216,7 +7288,7 @@ var ObjTab = class extends ObjNotationLine5 {
7216
7288
  let h = unitSize * DocumentSettings.TabHeight;
7217
7289
  this.top = -h / 2;
7218
7290
  this.bottom = h / 2;
7219
- this.rect = new DivRect(0, 0, this.top, this.bottom);
7291
+ this.rect = new import_ts_utils_lib28.AnchoredRect(0, 0, this.top, this.bottom);
7220
7292
  }
7221
7293
  layoutWidth(ctx) {
7222
7294
  this.rect.left = this.row.getRect().left;
@@ -7239,8 +7311,8 @@ var ObjTab = class extends ObjNotationLine5 {
7239
7311
  };
7240
7312
 
7241
7313
  // src/score/engine/obj-score-row.ts
7242
- var import_core17 = require("@tspro/web-music-score/core");
7243
- var import_ts_utils_lib16 = require("@tspro/ts-utils-lib");
7314
+ var import_core16 = require("@tspro/web-music-score/core");
7315
+ var import_ts_utils_lib29 = require("@tspro/ts-utils-lib");
7244
7316
  var ObjScoreRow = class extends MusicObject {
7245
7317
  constructor(doc, prevRow, scoreConfig) {
7246
7318
  super(doc);
@@ -7272,7 +7344,7 @@ var ObjScoreRow = class extends MusicObject {
7272
7344
  }
7273
7345
  this.instrumentLineGroups = lineGroups;
7274
7346
  this.instrumentNames = this.instrumentLineGroups.map((lines) => {
7275
- return lines.length > 0 && import_ts_utils_lib16.Utils.Is.isNonEmptyString(lines[0].getConfig().instrument) ? new ObjText(this, String(lines[0].getConfig().instrument), 0, 0.5) : void 0;
7347
+ return lines.length > 0 && import_ts_utils_lib29.Guard.isNonEmptyString(lines[0].getConfig().instrument) ? new ObjText(this, String(lines[0].getConfig().instrument), 0, 0.5) : void 0;
7276
7348
  });
7277
7349
  if (this.prevRow) {
7278
7350
  this.prevRow.nextRow = this;
@@ -7302,7 +7374,7 @@ var ObjScoreRow = class extends MusicObject {
7302
7374
  }
7303
7375
  findMatchingLine(line) {
7304
7376
  return line.row === this ? line : this.notationLines.find(
7305
- (curLine) => import_ts_utils_lib16.Utils.Obj.deepEqual(line.row.scoreConfig, curLine.row.scoreConfig) && line.id === curLine.id || import_ts_utils_lib16.Utils.Is.isNonEmptyString(line.getConfig().name) && line.getConfig().name === curLine.getConfig().name && line.getConfig().type === curLine.getConfig().type
7377
+ (curLine) => import_ts_utils_lib29.Utils.Obj.deepEqual(line.row.scoreConfig, curLine.row.scoreConfig) && line.id === curLine.id || import_ts_utils_lib29.Guard.isNonEmptyString(line.getConfig().name) && line.getConfig().name === curLine.getConfig().name && line.getConfig().type === curLine.getConfig().type
7306
7378
  );
7307
7379
  }
7308
7380
  getStaves() {
@@ -7322,7 +7394,7 @@ var ObjScoreRow = class extends MusicObject {
7322
7394
  if (topStaff) {
7323
7395
  return topStaff;
7324
7396
  } else {
7325
- throw new import_core17.MusicError(import_core17.MusicErrorType.Score, "Top staff is required!");
7397
+ throw new import_core16.MusicError(import_core16.MusicErrorType.Score, "Top staff is required!");
7326
7398
  }
7327
7399
  }
7328
7400
  getBottomStaff() {
@@ -7330,7 +7402,7 @@ var ObjScoreRow = class extends MusicObject {
7330
7402
  if (bottomStaff) {
7331
7403
  return bottomStaff;
7332
7404
  } else {
7333
- throw new import_core17.MusicError(import_core17.MusicErrorType.Score, "Bottom staff is required!");
7405
+ throw new import_core16.MusicError(import_core16.MusicErrorType.Score, "Bottom staff is required!");
7334
7406
  }
7335
7407
  }
7336
7408
  getStaff(diatonicId) {
@@ -7378,7 +7450,7 @@ var ObjScoreRow = class extends MusicObject {
7378
7450
  let r = this.getRect();
7379
7451
  let firstMeasure = this.getFirstMeasure();
7380
7452
  let left = firstMeasure ? firstMeasure.getColumnsContentRect().left : r.left;
7381
- return new DivRect(left, (left + r.right) / 2, r.right, r.top, r.centerY, r.bottom);
7453
+ return new import_ts_utils_lib29.AnchoredRect(left, (left + r.right) / 2, r.right, r.top, r.anchorY, r.bottom);
7382
7454
  }
7383
7455
  getDiatonicIdAt(y) {
7384
7456
  for (let i = 0; i < this.notationLines.length; i++) {
@@ -7428,7 +7500,7 @@ var ObjScoreRow = class extends MusicObject {
7428
7500
  return "up" /* Up */;
7429
7501
  }
7430
7502
  let diatonicIds = noteGroupDiatonicIds.length > 0 ? noteGroupDiatonicIds : restDiatonicIds;
7431
- let avgDiatonicId = Math.floor(import_ts_utils_lib16.Utils.Math.avg(...diatonicIds));
7503
+ let avgDiatonicId = Math.floor(import_ts_utils_lib29.Utils.Math.avg(...diatonicIds));
7432
7504
  let staves = this.getStaves().filter((staff) => staff.containsVoiceId(voiceId) && staff.containsDiatonicId(avgDiatonicId));
7433
7505
  return staves.length > 0 ? avgDiatonicId >= staves[0].middleLineDiatonicId ? "down" /* Down */ : "up" /* Up */ : "up" /* Up */;
7434
7506
  }
@@ -7463,7 +7535,7 @@ var ObjScoreRow = class extends MusicObject {
7463
7535
  if (!this.needLayout) {
7464
7536
  return;
7465
7537
  }
7466
- this.rect = new DivRect(0, right, 0, 0);
7538
+ this.rect = new import_ts_utils_lib29.AnchoredRect(0, right, 0, 0);
7467
7539
  this.notationLines.forEach((line) => line.layoutWidth(ctx));
7468
7540
  let targetColumnsAreaWidth = right - left;
7469
7541
  let minColumnsAreaWidth = 0;
@@ -7477,7 +7549,7 @@ var ObjScoreRow = class extends MusicObject {
7477
7549
  let newMeasureWidth = m.getSolidAreaWidth() + m.getMinColumnsAreaWidth() * columnsAreaScale;
7478
7550
  m.layoutWidth(ctx, newMeasureWidth);
7479
7551
  let r = m.getRect();
7480
- m.offset(x - r.left, -r.centerY);
7552
+ m.offset(x - r.left, -r.anchorY);
7481
7553
  x += r.width;
7482
7554
  x += m.getPostMeasureBreakWidth();
7483
7555
  });
@@ -7491,7 +7563,7 @@ var ObjScoreRow = class extends MusicObject {
7491
7563
  let right = this.measures.length > 0 ? this.measures[this.measures.length - 1].getRect().right : left;
7492
7564
  let top = this.measures.length > 0 ? Math.min(...this.measures.map((m) => m.getRect().top)) : 0;
7493
7565
  let bottom = this.measures.length > 0 ? Math.max(...this.measures.map((m) => m.getRect().bottom)) : 0;
7494
- this.rect = new DivRect(left, right, top, bottom);
7566
+ this.rect = new import_ts_utils_lib29.AnchoredRect(left, right, top, bottom);
7495
7567
  }
7496
7568
  alignStemsToBeams() {
7497
7569
  this.measures.forEach((m) => m.alignStemsToBeams());
@@ -7526,7 +7598,7 @@ var ObjScoreRow = class extends MusicObject {
7526
7598
  if (obj && grp.length > 0) {
7527
7599
  obj.offset(
7528
7600
  -obj.getRect().left,
7529
- -obj.getRect().centerY + (grp[0].getRect().top + grp[grp.length - 1].getRect().bottom) / 2
7601
+ -obj.getRect().anchorY + (grp[0].getRect().top + grp[grp.length - 1].getRect().bottom) / 2
7530
7602
  );
7531
7603
  }
7532
7604
  });
@@ -7569,7 +7641,7 @@ var ObjScoreRow = class extends MusicObject {
7569
7641
  this.instrumentNames.forEach((obj, i) => {
7570
7642
  let grp = this.instrumentLineGroups[i];
7571
7643
  if (grp.length > 1) {
7572
- let r = new DivRect(
7644
+ let r = new import_ts_utils_lib29.AnchoredRect(
7573
7645
  grpSize.braceLeft,
7574
7646
  grpSize.braceRight,
7575
7647
  grp[0].getTopLineY(),
@@ -7586,6 +7658,7 @@ var ObjScoreRow = class extends MusicObject {
7586
7658
  };
7587
7659
 
7588
7660
  // src/score/engine/obj-header.ts
7661
+ var import_ts_utils_lib30 = require("@tspro/ts-utils-lib");
7589
7662
  var ObjHeader = class extends MusicObject {
7590
7663
  constructor(doc, title, composer, arranger) {
7591
7664
  super(doc);
@@ -7630,7 +7703,7 @@ var ObjHeader = class extends MusicObject {
7630
7703
  }
7631
7704
  layoutWidth(ctx, left, right) {
7632
7705
  let top = 0;
7633
- this.rect = new DivRect(left, right, 0, 0);
7706
+ this.rect = new import_ts_utils_lib30.AnchoredRect(left, right, 0, 0);
7634
7707
  if (this.titleText) {
7635
7708
  this.titleText.layout(ctx);
7636
7709
  this.titleText.offset((left + right) / 2, top);
@@ -7676,8 +7749,8 @@ var ObjHeader = class extends MusicObject {
7676
7749
  };
7677
7750
 
7678
7751
  // src/score/engine/obj-document.ts
7679
- var import_ts_utils_lib17 = require("@tspro/ts-utils-lib");
7680
- var import_core18 = require("@tspro/web-music-score/core");
7752
+ var import_ts_utils_lib31 = require("@tspro/ts-utils-lib");
7753
+ var import_core17 = require("@tspro/web-music-score/core");
7681
7754
  var ObjDocument = class extends MusicObject {
7682
7755
  constructor() {
7683
7756
  super(void 0);
@@ -7690,7 +7763,7 @@ var ObjDocument = class extends MusicObject {
7690
7763
  __publicField(this, "header");
7691
7764
  __publicField(this, "newRowRequested", false);
7692
7765
  __publicField(this, "allConnectiveProps", []);
7693
- __publicField(this, "staffGroups", /* @__PURE__ */ new Map());
7766
+ __publicField(this, "staffGroups", new import_ts_utils_lib31.UniMap());
7694
7767
  __publicField(this, "mi");
7695
7768
  this.mi = new MDocument2(this);
7696
7769
  }
@@ -7698,7 +7771,7 @@ var ObjDocument = class extends MusicObject {
7698
7771
  return this.mi;
7699
7772
  }
7700
7773
  setScoreConfiguration(config) {
7701
- if (import_ts_utils_lib17.Utils.Is.isEnumValue(config, StaffPreset)) {
7774
+ if (import_ts_utils_lib31.Guard.isEnumValue(config, StaffPreset)) {
7702
7775
  switch (config) {
7703
7776
  default:
7704
7777
  case "treble" /* Treble */:
@@ -7726,7 +7799,7 @@ var ObjDocument = class extends MusicObject {
7726
7799
  ];
7727
7800
  break;
7728
7801
  }
7729
- } else if (import_ts_utils_lib17.Utils.Is.isArray(config)) {
7802
+ } else if (import_ts_utils_lib31.Guard.isArray(config)) {
7730
7803
  this.curScoreConfig = config;
7731
7804
  } else {
7732
7805
  this.curScoreConfig = [config];
@@ -7739,10 +7812,10 @@ var ObjDocument = class extends MusicObject {
7739
7812
  }
7740
7813
  if (treble && treble.type === "staff" && treble.isGrand) {
7741
7814
  if (treble.grandId !== void 0) {
7742
- throw new import_core18.MusicError(import_core18.MusicErrorType.Score, `Grand staff error: mixing isGrand and grandId!`);
7815
+ throw new import_core17.MusicError(import_core17.MusicErrorType.Score, `Grand staff error: mixing isGrand and grandId!`);
7743
7816
  } else if (bass && bass.type === "staff" && bass.isGrand) {
7744
7817
  if (bass.grandId !== void 0) {
7745
- throw new import_core18.MusicError(import_core18.MusicErrorType.Score, `Grand staff error: mixing isGrand and grandId!`);
7818
+ throw new import_core17.MusicError(import_core17.MusicErrorType.Score, `Grand staff error: mixing isGrand and grandId!`);
7746
7819
  } else {
7747
7820
  treble.grandId = grandId;
7748
7821
  bass.grandId = grandId;
@@ -7750,7 +7823,7 @@ var ObjDocument = class extends MusicObject {
7750
7823
  cfgId += 2;
7751
7824
  }
7752
7825
  } else {
7753
- throw new import_core18.MusicError(import_core18.MusicErrorType.Score, `Grand staff error: invalid use of isGrand!`);
7826
+ throw new import_core17.MusicError(import_core17.MusicErrorType.Score, `Grand staff error: invalid use of isGrand!`);
7754
7827
  }
7755
7828
  } else {
7756
7829
  cfgId++;
@@ -7761,20 +7834,20 @@ var ObjDocument = class extends MusicObject {
7761
7834
  let bass = this.curScoreConfig[cfgId + 1];
7762
7835
  if (treble && bass && treble.type === "staff" && bass.type === "staff" && treble.grandId !== void 0 && treble.grandId === bass.grandId) {
7763
7836
  if (usedGrandIdes.includes(treble.grandId)) {
7764
- throw new import_core18.MusicError(import_core18.MusicErrorType.Score, `Grand staff error: grandId "${treble.grandId}" already used!`);
7837
+ throw new import_core17.MusicError(import_core17.MusicErrorType.Score, `Grand staff error: grandId "${treble.grandId}" already used!`);
7765
7838
  } else if (treble.clef !== "G" /* G */) {
7766
- throw new import_core18.MusicError(import_core18.MusicErrorType.Score, `Grand staff error: Invalid treble clef "${treble.clef}"!`);
7839
+ throw new import_core17.MusicError(import_core17.MusicErrorType.Score, `Grand staff error: Invalid treble clef "${treble.clef}"!`);
7767
7840
  } else if (bass.clef !== "F" /* F */) {
7768
- throw new import_core18.MusicError(import_core18.MusicErrorType.Score, `Grand staff error: Invalid treble clef "${treble.clef}"!`);
7841
+ throw new import_core17.MusicError(import_core17.MusicErrorType.Score, `Grand staff error: Invalid treble clef "${treble.clef}"!`);
7769
7842
  } else if (treble.isOctaveDown || bass.isOctaveDown) {
7770
- throw new import_core18.MusicError(import_core18.MusicErrorType.Score, `Grand staff error: cannot use isOctaveDown option!`);
7843
+ throw new import_core17.MusicError(import_core17.MusicErrorType.Score, `Grand staff error: cannot use isOctaveDown option!`);
7771
7844
  }
7772
7845
  usedGrandIdes.push(treble.grandId);
7773
7846
  treble.minNote = "C4";
7774
7847
  bass.maxNote = "B3";
7775
7848
  cfgId += 2;
7776
7849
  } else if (treble && treble.type === "staff" && treble.grandId !== void 0) {
7777
- throw new import_core18.MusicError(import_core18.MusicErrorType.Score, `Grand staff error: invalid use of grandId "${treble.grandId}"!`);
7850
+ throw new import_core17.MusicError(import_core17.MusicErrorType.Score, `Grand staff error: invalid use of grandId "${treble.grandId}"!`);
7778
7851
  } else {
7779
7852
  cfgId++;
7780
7853
  }
@@ -7852,7 +7925,7 @@ var ObjDocument = class extends MusicObject {
7852
7925
  lastRow = this.addNewRow(lastRow);
7853
7926
  this.newRowRequested = false;
7854
7927
  }
7855
- let measure = new ObjMeasure2(lastRow, measureOptions);
7928
+ let measure = new ObjMeasure(lastRow, measureOptions);
7856
7929
  this.measures.push(measure);
7857
7930
  lastRow.addMeasure(measure);
7858
7931
  this.requestLayout();
@@ -7936,7 +8009,7 @@ var ObjDocument = class extends MusicObject {
7936
8009
  this.rows.forEach((row) => row.layoutLayoutGroups(ctx));
7937
8010
  this.rows.forEach((row) => row.layoutSetNotationLines(ctx));
7938
8011
  this.rows.forEach((row) => row.layoutPadding(ctx));
7939
- this.rect = new DivRect();
8012
+ this.rect = new import_ts_utils_lib31.AnchoredRect();
7940
8013
  if (this.header) {
7941
8014
  this.header.layoutWidth(ctx, left, right);
7942
8015
  this.rect.expandInPlace(this.header.getRect());
@@ -7999,125 +8072,105 @@ var ObjDocument = class extends MusicObject {
7999
8072
 
8000
8073
  // src/score/pub/document-builder.ts
8001
8074
  var import_theory13 = require("@tspro/web-music-score/theory");
8002
- var import_core19 = require("@tspro/web-music-score/core");
8003
- function assertArg(condition, argName, argValue) {
8004
- if (!condition) {
8005
- throw new import_core19.MusicError(import_core19.MusicErrorType.Score, `Invalid arg: ${argName} = ${argValue}`);
8006
- }
8007
- }
8008
- function isNote(note) {
8009
- if (typeof note !== "string") {
8010
- return false;
8011
- } else {
8012
- let p = import_theory13.Note.parseNote(note);
8013
- return p !== void 0 && p.octave !== void 0;
8014
- }
8015
- }
8016
- function isVoiceId(value) {
8017
- return import_ts_utils_lib18.Utils.Is.isNumber(value) && getVoiceIds().indexOf(value) >= 0;
8075
+ var import_core18 = require("@tspro/web-music-score/core");
8076
+ var assertingFunction = "";
8077
+ function setAssertFunction(fnName, ...fnArgs) {
8078
+ let argsStr = fnArgs.map((arg) => JSON.stringify(arg)).join(", ");
8079
+ assertingFunction = `DocumentBuilder.${fnName}(${argsStr})`;
8018
8080
  }
8019
- function isStringNumber(value) {
8020
- return import_ts_utils_lib18.Utils.Is.isNumber(value) && getStringNumbers().indexOf(value) >= 0;
8081
+ function assertArg(...conditions) {
8082
+ conditions.forEach((condition) => {
8083
+ if (!condition) throw new import_core18.MusicError(import_core18.MusicErrorType.Score, assertingFunction);
8084
+ });
8021
8085
  }
8022
- function isVerseNumber(value) {
8023
- return import_ts_utils_lib18.Utils.Is.isNumber(value) && getVerseNumbers().indexOf(value) >= 0;
8086
+ function assertArgMsg(condition, msg) {
8087
+ if (!condition) throw new import_core18.MusicError(import_core18.MusicErrorType.Score, msg);
8024
8088
  }
8025
8089
  function assertBaseConfig(baseConfig) {
8026
8090
  var _a;
8027
- assertArg(import_ts_utils_lib18.Utils.Is.isObject(baseConfig), "baseConfig", baseConfig);
8028
- assertArg(import_ts_utils_lib18.Utils.Is.isStringOrUndefined(baseConfig.name), "baseConfig.name", baseConfig.name);
8029
- assertArg(import_ts_utils_lib18.Utils.Is.isUndefined(baseConfig.voiceId) || isVoiceId(baseConfig.voiceId) || import_ts_utils_lib18.Utils.Is.isArray(baseConfig.voiceId) && baseConfig.voiceId.every((voiceId) => isVoiceId(voiceId)), "baseConfig.voiceId", baseConfig.voiceId);
8030
- if (!import_ts_utils_lib18.Utils.Is.isUndefined(baseConfig.voiceIds)) {
8031
- assertArg(isVoiceId(baseConfig.voiceIds) || import_ts_utils_lib18.Utils.Is.isArray(baseConfig.voiceIds) && baseConfig.voiceIds.every((voiceId) => isVoiceId(voiceId)), "baseConfig.voiceIds", baseConfig.voiceIds);
8091
+ assertArg(
8092
+ import_ts_utils_lib32.Guard.isObject(baseConfig),
8093
+ import_ts_utils_lib32.Guard.isStringOrUndefined(baseConfig.name),
8094
+ import_ts_utils_lib32.Guard.isUndefined(baseConfig.voiceId) || isVoiceId(baseConfig.voiceId) || import_ts_utils_lib32.Guard.isArray(baseConfig.voiceId) && baseConfig.voiceId.every((voiceId) => isVoiceId(voiceId))
8095
+ );
8096
+ if (!import_ts_utils_lib32.Guard.isUndefined(baseConfig.voiceIds)) {
8097
+ assertArg(isVoiceId(baseConfig.voiceIds) || import_ts_utils_lib32.Guard.isArray(baseConfig.voiceIds) && baseConfig.voiceIds.every((voiceId) => isVoiceId(voiceId)));
8032
8098
  console.warn(`Staff/tab config property 'voiceIds' is deprecated, use 'voiceId' instead.`);
8033
- let arr = import_ts_utils_lib18.Utils.Arr.toArray((_a = baseConfig.voiceId) != null ? _a : []);
8034
- import_ts_utils_lib18.Utils.Arr.toArray(baseConfig.voiceIds).forEach((voiceId) => arr.push(voiceId));
8099
+ let arr = import_ts_utils_lib32.Utils.Arr.toArray((_a = baseConfig.voiceId) != null ? _a : []);
8100
+ import_ts_utils_lib32.Utils.Arr.toArray(baseConfig.voiceIds).forEach((voiceId) => arr.push(voiceId));
8035
8101
  baseConfig.voiceId = arr;
8036
8102
  }
8037
- if (import_ts_utils_lib18.Utils.Is.isArray(baseConfig.voiceId)) {
8038
- baseConfig.voiceId = import_ts_utils_lib18.Utils.Arr.removeDuplicates(baseConfig.voiceId);
8103
+ if (import_ts_utils_lib32.Guard.isArray(baseConfig.voiceId)) {
8104
+ baseConfig.voiceId = import_ts_utils_lib32.Utils.Arr.removeDuplicates(baseConfig.voiceId);
8039
8105
  }
8040
- assertArg(import_ts_utils_lib18.Utils.Is.isStringOrUndefined(baseConfig.instrument), "baseConfig.instrument", baseConfig.instrument);
8106
+ assertArg(import_ts_utils_lib32.Guard.isStringOrUndefined(baseConfig.instrument));
8041
8107
  }
8042
8108
  function assertStaffConfig(staffConfig) {
8043
8109
  assertBaseConfig(staffConfig);
8044
- assertArg(import_ts_utils_lib18.Utils.Is.isObject(staffConfig), "staffConfig", staffConfig);
8045
- assertArg(staffConfig.type === "staff", "staffConfig.type", staffConfig.type);
8046
- assertArg(import_ts_utils_lib18.Utils.Is.isEnumValue(staffConfig.clef, Clef), "staffConfig.clef", staffConfig.clef);
8047
- assertArg(import_ts_utils_lib18.Utils.Is.isBooleanOrUndefined(staffConfig.isOctaveDown), "staffConfig.isOctaveDown", staffConfig.isOctaveDown);
8048
- assertArg(import_ts_utils_lib18.Utils.Is.isUndefined(staffConfig.minNote) || isNote(staffConfig.minNote), "staffConfig.minNote", staffConfig.minNote);
8049
- assertArg(import_ts_utils_lib18.Utils.Is.isUndefined(staffConfig.maxNote) || isNote(staffConfig.maxNote), "staffConfig.maxNote", staffConfig.maxNote);
8050
- assertArg(import_ts_utils_lib18.Utils.Is.isStringOrUndefined(staffConfig.grandId), "staffConfig.grandId", staffConfig.grandId);
8051
- assertArg(import_ts_utils_lib18.Utils.Is.isBooleanOrUndefined(staffConfig.isGrand), "staffConfig.isGrand", staffConfig.isGrand);
8052
- if (!import_ts_utils_lib18.Utils.Is.isUndefined(staffConfig.isGrand)) {
8110
+ assertArg(
8111
+ import_ts_utils_lib32.Guard.isObject(staffConfig),
8112
+ import_ts_utils_lib32.Guard.isStrictEqual(staffConfig.type, "staff"),
8113
+ import_ts_utils_lib32.Guard.isEnumValue(staffConfig.clef, Clef),
8114
+ import_ts_utils_lib32.Guard.isBooleanOrUndefined(staffConfig.isOctaveDown),
8115
+ import_ts_utils_lib32.Guard.isUndefined(staffConfig.minNote) || import_theory13.Note.isNote(staffConfig.minNote),
8116
+ import_ts_utils_lib32.Guard.isUndefined(staffConfig.maxNote) || import_theory13.Note.isNote(staffConfig.maxNote),
8117
+ import_ts_utils_lib32.Guard.isStringOrUndefined(staffConfig.grandId),
8118
+ import_ts_utils_lib32.Guard.isBooleanOrUndefined(staffConfig.isGrand)
8119
+ );
8120
+ if (!import_ts_utils_lib32.Guard.isUndefined(staffConfig.isGrand))
8053
8121
  console.warn(`Staff config property 'isGrand' is deprecated, use 'grandId' instead.`);
8054
- }
8055
8122
  }
8056
8123
  function assertTabConfig(tabConfig) {
8057
8124
  assertBaseConfig(tabConfig);
8058
- assertArg(import_ts_utils_lib18.Utils.Is.isObject(tabConfig), "tabConfig", tabConfig);
8059
- assertArg(tabConfig.type === "tab", "tabConfig.type", tabConfig.type);
8060
- if (import_ts_utils_lib18.Utils.Is.isString(tabConfig.tuning)) {
8061
- assertArg(import_theory13.TuningNameList.includes(tabConfig.tuning), "tabConfig.tuning", tabConfig.tuning);
8062
- } else if (import_ts_utils_lib18.Utils.Is.isArray(tabConfig.tuning)) {
8063
- assertArg(tabConfig.tuning.length === getStringNumbers().length && tabConfig.tuning.every((s) => isNote(s)), "tabConfig.tuning", tabConfig.tuning);
8064
- }
8125
+ assertArg(
8126
+ import_ts_utils_lib32.Guard.isObject(tabConfig),
8127
+ import_ts_utils_lib32.Guard.isStrictEqual(tabConfig.type, "tab"),
8128
+ import_ts_utils_lib32.Guard.isUndefined(tabConfig.tuning) || import_ts_utils_lib32.Guard.isString(tabConfig.tuning) && import_ts_utils_lib32.Guard.isIncluded(tabConfig.tuning, import_theory13.TuningNameList) || import_ts_utils_lib32.Guard.isArray(tabConfig.tuning) && import_ts_utils_lib32.Guard.isStrictEqual(tabConfig.tuning.length, getStringNumbers().length && tabConfig.tuning.every((s) => import_theory13.Note.isNote(s)))
8129
+ );
8065
8130
  }
8066
8131
  function assertNoteOptions(noteOptions) {
8067
- assertArg(import_ts_utils_lib18.Utils.Is.isObject(noteOptions), "noteOptions", noteOptions);
8068
- assertArg(import_ts_utils_lib18.Utils.Is.isBooleanOrUndefined(noteOptions.dotted) || import_ts_utils_lib18.Utils.Is.isIntegerGte(noteOptions.dotted, 0), "noteOptions.dotted", noteOptions.dotted);
8069
- assertArg(import_ts_utils_lib18.Utils.Is.isEnumValueOrUndefined(noteOptions.stem, Stem), "noteOptions.stem", noteOptions.stem);
8070
- assertArg(import_ts_utils_lib18.Utils.Is.isStringOrUndefined(noteOptions.color), "noteOptions.color", noteOptions.color);
8071
- assertArg(import_ts_utils_lib18.Utils.Is.isBooleanOrUndefined(noteOptions.arpeggio) || import_ts_utils_lib18.Utils.Is.isEnumValue(noteOptions.arpeggio, Arpeggio), "noteOptions.arpeggio", noteOptions.arpeggio);
8072
- assertArg(import_ts_utils_lib18.Utils.Is.isBooleanOrUndefined(noteOptions.staccato), "noteOptions.staccato", noteOptions.staccato);
8073
- assertArg(import_ts_utils_lib18.Utils.Is.isBooleanOrUndefined(noteOptions.diamond), "noteOptions.diamond", noteOptions.diamond);
8074
- assertArg(import_ts_utils_lib18.Utils.Is.isBooleanOrUndefined(noteOptions.triplet), "noteOptions.triplet", noteOptions.triplet);
8075
- assertArg(import_ts_utils_lib18.Utils.Is.isUndefined(noteOptions.string) || isStringNumber(noteOptions.string) || import_ts_utils_lib18.Utils.Is.isNonEmptyArray(noteOptions.string) && noteOptions.string.every((string) => isStringNumber(string)), "noteOptions.string", noteOptions.string);
8076
- assertArg(import_ts_utils_lib18.Utils.Is.isUndefined(noteOptions.tieSpan), 'NoteOptions.tieSpan was removed. Use addConnective("tie", tieSpan)', "");
8077
- assertArg(import_ts_utils_lib18.Utils.Is.isUndefined(noteOptions.slurSpan), 'NoteOptions.slurSpan was removed. Use addConnective("slur", slurSpan)', "");
8132
+ assertArg(
8133
+ import_ts_utils_lib32.Guard.isObject(noteOptions),
8134
+ import_ts_utils_lib32.Guard.isBooleanOrUndefined(noteOptions.dotted) || import_ts_utils_lib32.Guard.isIntegerGte(noteOptions.dotted, 0),
8135
+ import_ts_utils_lib32.Guard.isEnumValueOrUndefined(noteOptions.stem, Stem),
8136
+ import_ts_utils_lib32.Guard.isStringOrUndefined(noteOptions.color),
8137
+ import_ts_utils_lib32.Guard.isBooleanOrUndefined(noteOptions.arpeggio) || import_ts_utils_lib32.Guard.isEnumValue(noteOptions.arpeggio, Arpeggio),
8138
+ import_ts_utils_lib32.Guard.isBooleanOrUndefined(noteOptions.staccato),
8139
+ import_ts_utils_lib32.Guard.isBooleanOrUndefined(noteOptions.diamond),
8140
+ import_ts_utils_lib32.Guard.isBooleanOrUndefined(noteOptions.triplet),
8141
+ import_ts_utils_lib32.Guard.isUndefined(noteOptions.string) || isStringNumber(noteOptions.string) || import_ts_utils_lib32.Guard.isEmptyArray(noteOptions.string) || import_ts_utils_lib32.Guard.isNonEmptyArray(noteOptions.string) && noteOptions.string.every((string) => isStringNumber(string))
8142
+ );
8143
+ assertArgMsg(import_ts_utils_lib32.Guard.isUndefined(noteOptions.tieSpan), `NoteOptions.tieSpan was removed. Use addConnective("tie", tieSpan)`);
8144
+ assertArgMsg(import_ts_utils_lib32.Guard.isUndefined(noteOptions.slurSpan), `NoteOptions.slurSpan was removed. Use addConnective("slur", slurSpan)`);
8078
8145
  }
8079
8146
  function assertRestOptions(restOptions) {
8080
- assertArg(import_ts_utils_lib18.Utils.Is.isObject(restOptions), "restOptions", restOptions);
8081
- assertArg(import_ts_utils_lib18.Utils.Is.isBooleanOrUndefined(restOptions.dotted) || import_ts_utils_lib18.Utils.Is.isIntegerGte(restOptions.dotted, 0), "restOptions.dotted", restOptions.dotted);
8082
- assertArg(import_ts_utils_lib18.Utils.Is.isStringOrUndefined(restOptions.staffPos) || import_ts_utils_lib18.Utils.Is.isInteger(restOptions.staffPos) || restOptions.staffPos instanceof import_theory13.Note, "restOptions.staffPos", restOptions.staffPos);
8083
- assertArg(import_ts_utils_lib18.Utils.Is.isStringOrUndefined(restOptions.color), "restOptions.color", restOptions.color);
8084
- assertArg(import_ts_utils_lib18.Utils.Is.isBooleanOrUndefined(restOptions.hide), "restOptions.hide", restOptions.hide);
8085
- assertArg(import_ts_utils_lib18.Utils.Is.isBooleanOrUndefined(restOptions.triplet), "restOptions.triplet", restOptions.triplet);
8147
+ assertArg(
8148
+ import_ts_utils_lib32.Guard.isObject(restOptions),
8149
+ import_ts_utils_lib32.Guard.isBooleanOrUndefined(restOptions.dotted) || import_ts_utils_lib32.Guard.isIntegerGte(restOptions.dotted, 0),
8150
+ import_ts_utils_lib32.Guard.isStringOrUndefined(restOptions.staffPos) || import_ts_utils_lib32.Guard.isInteger(restOptions.staffPos) || restOptions.staffPos instanceof import_theory13.Note,
8151
+ import_ts_utils_lib32.Guard.isStringOrUndefined(restOptions.color),
8152
+ import_ts_utils_lib32.Guard.isBooleanOrUndefined(restOptions.hide),
8153
+ import_ts_utils_lib32.Guard.isBooleanOrUndefined(restOptions.triplet)
8154
+ );
8086
8155
  }
8087
8156
  function assertLyricsOptions(lyricsOptions) {
8088
- assertArg(import_ts_utils_lib18.Utils.Is.isObject(lyricsOptions), "lyricsOptions", lyricsOptions);
8089
- assertArg(import_ts_utils_lib18.Utils.Is.isEnumValueOrUndefined(lyricsOptions.align, LyricsAlign), "lyricsOptions.align", lyricsOptions.align);
8090
- assertArg(import_ts_utils_lib18.Utils.Is.isEnumValueOrUndefined(lyricsOptions.hyphen, LyricsHyphen), "lyricsOptions.hyphen", lyricsOptions.hyphen);
8157
+ assertArg(
8158
+ import_ts_utils_lib32.Guard.isObject(lyricsOptions),
8159
+ import_ts_utils_lib32.Guard.isEnumValueOrUndefined(lyricsOptions.align, LyricsAlign),
8160
+ import_ts_utils_lib32.Guard.isEnumValueOrUndefined(lyricsOptions.hyphen, LyricsHyphen)
8161
+ );
8091
8162
  }
8092
8163
  function assertMeasureOptions(measureOptions) {
8093
- assertArg(import_ts_utils_lib18.Utils.Is.isObject(measureOptions), "measureOptions", measureOptions);
8094
- assertArg(import_ts_utils_lib18.Utils.Is.isBooleanOrUndefined(measureOptions.showNumber), "measureOptions.showNumber", measureOptions.showNumber);
8164
+ assertArg(
8165
+ import_ts_utils_lib32.Guard.isObject(measureOptions),
8166
+ import_ts_utils_lib32.Guard.isBooleanOrUndefined(measureOptions.showNumber)
8167
+ );
8095
8168
  }
8096
8169
  function assertStaffTabOrGRoups(staffTabOrGroups) {
8097
8170
  assertArg(
8098
- import_ts_utils_lib18.Utils.Is.isStringOrUndefined(staffTabOrGroups) || import_ts_utils_lib18.Utils.Is.isIntegerGte(staffTabOrGroups, 0) || import_ts_utils_lib18.Utils.Is.isNonEmptyArray(staffTabOrGroups) && staffTabOrGroups.every(
8099
- (staffTabOrGroup) => import_ts_utils_lib18.Utils.Is.isString(staffTabOrGroup) || import_ts_utils_lib18.Utils.Is.isIntegerGte(staffTabOrGroup, 0)
8100
- ),
8101
- "staffTabOrGroup",
8102
- staffTabOrGroups
8171
+ import_ts_utils_lib32.Guard.isStringOrUndefined(staffTabOrGroups) || import_ts_utils_lib32.Guard.isIntegerGte(staffTabOrGroups, 0) || import_ts_utils_lib32.Guard.isNonEmptyArray(staffTabOrGroups) && staffTabOrGroups.every((staffTabOrGroup) => import_ts_utils_lib32.Guard.isString(staffTabOrGroup) || import_ts_utils_lib32.Guard.isIntegerGte(staffTabOrGroup, 0))
8103
8172
  );
8104
8173
  }
8105
- function isNoteLength(noteLen) {
8106
- try {
8107
- (0, import_theory13.validateNoteLength)(noteLen);
8108
- return true;
8109
- } catch (e) {
8110
- return false;
8111
- }
8112
- }
8113
- function isTupletRatio(tupletRatio) {
8114
- try {
8115
- (0, import_theory13.validateTupletRatio)(tupletRatio);
8116
- return true;
8117
- } catch (e) {
8118
- return false;
8119
- }
8120
- }
8121
8174
  var _DocumentBuilder = class _DocumentBuilder {
8122
8175
  /**
8123
8176
  * Create new document builder instance.
@@ -8128,27 +8181,28 @@ var _DocumentBuilder = class _DocumentBuilder {
8128
8181
  this.doc = new ObjDocument();
8129
8182
  }
8130
8183
  setScoreConfiguration(config) {
8131
- if (import_ts_utils_lib18.Utils.Is.isEnumValue(config, StaffPreset)) {
8184
+ setAssertFunction("setScoreConfiguration", config);
8185
+ if (import_ts_utils_lib32.Guard.isEnumValue(config, StaffPreset)) {
8132
8186
  this.doc.setScoreConfiguration(config);
8133
- } else if (import_ts_utils_lib18.Utils.Is.isObject(config) && config.type === "staff") {
8187
+ } else if (import_ts_utils_lib32.Guard.isObject(config) && config.type === "staff") {
8134
8188
  assertStaffConfig(config);
8135
8189
  this.doc.setScoreConfiguration(config);
8136
- } else if (import_ts_utils_lib18.Utils.Is.isObject(config) && config.type === "tab") {
8190
+ } else if (import_ts_utils_lib32.Guard.isObject(config) && config.type === "tab") {
8137
8191
  assertTabConfig(config);
8138
8192
  this.doc.setScoreConfiguration(config);
8139
- } else if (import_ts_utils_lib18.Utils.Is.isNonEmptyArray(config)) {
8193
+ } else if (import_ts_utils_lib32.Guard.isNonEmptyArray(config)) {
8140
8194
  config.forEach((c) => {
8141
- if (import_ts_utils_lib18.Utils.Is.isObject(c) && c.type === "staff") {
8195
+ if (import_ts_utils_lib32.Guard.isObject(c) && c.type === "staff") {
8142
8196
  assertStaffConfig(c);
8143
- } else if (import_ts_utils_lib18.Utils.Is.isObject(c) && c.type === "tab") {
8197
+ } else if (import_ts_utils_lib32.Guard.isObject(c) && c.type === "tab") {
8144
8198
  assertTabConfig(c);
8145
8199
  } else {
8146
- assertArg(false, "config", config);
8200
+ assertArg(false);
8147
8201
  }
8148
8202
  });
8149
8203
  this.doc.setScoreConfiguration(config);
8150
8204
  } else {
8151
- assertArg(false, "config", config);
8205
+ assertArg(false);
8152
8206
  }
8153
8207
  return this;
8154
8208
  }
@@ -8171,9 +8225,12 @@ var _DocumentBuilder = class _DocumentBuilder {
8171
8225
  * @returns - This document builder instance.
8172
8226
  */
8173
8227
  setHeader(title, composer, arranger) {
8174
- assertArg(import_ts_utils_lib18.Utils.Is.isStringOrUndefined(title), "title", title);
8175
- assertArg(import_ts_utils_lib18.Utils.Is.isStringOrUndefined(composer), "composer", composer);
8176
- assertArg(import_ts_utils_lib18.Utils.Is.isStringOrUndefined(arranger), "arranger", arranger);
8228
+ setAssertFunction("setHeader", title, composer, arranger);
8229
+ assertArg(
8230
+ import_ts_utils_lib32.Guard.isStringOrUndefined(title),
8231
+ import_ts_utils_lib32.Guard.isStringOrUndefined(composer),
8232
+ import_ts_utils_lib32.Guard.isStringOrUndefined(arranger)
8233
+ );
8177
8234
  this.doc.setHeader(title, composer, arranger);
8178
8235
  return this;
8179
8236
  }
@@ -8183,7 +8240,8 @@ var _DocumentBuilder = class _DocumentBuilder {
8183
8240
  * @returns - This document builder instance.
8184
8241
  */
8185
8242
  setMeasuresPerRow(measuresPerRow) {
8186
- assertArg(import_ts_utils_lib18.Utils.Is.isIntegerGte(measuresPerRow, 1) || import_ts_utils_lib18.Utils.Is.isPosInfinity(measuresPerRow), "measuresPerRow", measuresPerRow);
8243
+ setAssertFunction("setMeasuresPerRow", measuresPerRow);
8244
+ assertArg(import_ts_utils_lib32.Guard.isIntegerGte(measuresPerRow, 1) || import_ts_utils_lib32.Guard.isPosInfinity(measuresPerRow));
8187
8245
  this.doc.setMeasuresPerRow(measuresPerRow);
8188
8246
  return this;
8189
8247
  }
@@ -8193,36 +8251,37 @@ var _DocumentBuilder = class _DocumentBuilder {
8193
8251
  * @returns - This document builder instance.
8194
8252
  */
8195
8253
  addMeasure(measureOptions) {
8254
+ setAssertFunction("addMeasure", measureOptions);
8196
8255
  measureOptions != null ? measureOptions : measureOptions = {};
8197
8256
  assertMeasureOptions(measureOptions);
8198
8257
  this.doc.addMeasure(measureOptions);
8199
8258
  return this;
8200
8259
  }
8201
8260
  setKeySignature(...args) {
8202
- assertArg(args[0] instanceof import_theory13.Scale || args[0] instanceof import_theory13.KeySignature || import_ts_utils_lib18.Utils.Is.isNonEmptyString(args[0]) && (args.length === 1 || import_ts_utils_lib18.Utils.Is.isEnumValue(args[1], import_theory13.ScaleType)), "keySignature", args);
8261
+ setAssertFunction("setKeySignature", ...args);
8262
+ assertArg(args[0] instanceof import_theory13.Scale || args[0] instanceof import_theory13.KeySignature || import_ts_utils_lib32.Guard.isNonEmptyString(args[0]) && import_ts_utils_lib32.Guard.isEnumValueOrUndefined(args[1], import_theory13.ScaleType));
8203
8263
  this.getMeasure().setKeySignature(...args);
8204
8264
  return this;
8205
8265
  }
8206
8266
  setTimeSignature(...args) {
8267
+ setAssertFunction("setTimeSignature", ...args);
8207
8268
  if (args[0] instanceof import_theory13.TimeSignature) {
8208
8269
  this.getMeasure().setTimeSignature(args[0]);
8209
- } else if (import_ts_utils_lib18.Utils.Is.isEnumValue(args[0], import_theory13.TimeSignatures) && import_ts_utils_lib18.Utils.Is.isEnumValueOrUndefined(args[1], import_theory13.BeamGrouping)) {
8270
+ } else if (import_ts_utils_lib32.Guard.isEnumValue(args[0], import_theory13.TimeSignatures) && import_ts_utils_lib32.Guard.isEnumValueOrUndefined(args[1], import_theory13.BeamGrouping)) {
8210
8271
  this.getMeasure().setTimeSignature(new import_theory13.TimeSignature(args[0], args[1]));
8211
- } else if (import_ts_utils_lib18.Utils.Is.isIntegerGte(args[0], 1) && import_ts_utils_lib18.Utils.Is.isIntegerGte(args[1], 1) && import_ts_utils_lib18.Utils.Is.isEnumValueOrUndefined(args[2], import_theory13.BeamGrouping)) {
8272
+ } else if (import_ts_utils_lib32.Guard.isIntegerGte(args[0], 1) && import_ts_utils_lib32.Guard.isIntegerGte(args[1], 1) && import_ts_utils_lib32.Guard.isEnumValueOrUndefined(args[2], import_theory13.BeamGrouping)) {
8212
8273
  this.getMeasure().setTimeSignature(new import_theory13.TimeSignature(args[0], args[1], args[2]));
8213
8274
  } else {
8214
- assertArg(false, "timeSignature args", args);
8275
+ assertArg(false);
8215
8276
  }
8216
8277
  return this;
8217
8278
  }
8218
8279
  setTempo(beatsPerMinute, beatLength, dotted) {
8219
- assertArg(import_ts_utils_lib18.Utils.Is.isIntegerGte(beatsPerMinute, 1), "beatsPerMinute", beatsPerMinute);
8220
- if (beatLength === void 0) {
8221
- assertArg(import_ts_utils_lib18.Utils.Is.isUndefined(dotted), "dotted", dotted);
8222
- } else {
8223
- assertArg(import_ts_utils_lib18.Utils.Is.isEnumValue(beatLength, import_theory13.NoteLength) || isNoteLength(beatLength), "beatLength", beatLength);
8224
- assertArg(import_ts_utils_lib18.Utils.Is.isBooleanOrUndefined(dotted) || import_ts_utils_lib18.Utils.Is.isIntegerGte(dotted, 0), "dotted", dotted);
8225
- }
8280
+ setAssertFunction("setTempo", beatsPerMinute, beatLength, dotted);
8281
+ assertArg(
8282
+ import_ts_utils_lib32.Guard.isIntegerGte(beatsPerMinute, 1),
8283
+ import_ts_utils_lib32.Guard.isUndefined(beatLength) && import_ts_utils_lib32.Guard.isUndefined(dotted) || (0, import_theory13.isNoteLength)(beatLength) && (import_ts_utils_lib32.Guard.isBooleanOrUndefined(dotted) || import_ts_utils_lib32.Guard.isIntegerGte(dotted, 0))
8284
+ );
8226
8285
  this.getMeasure().setTempo(beatsPerMinute, beatLength, dotted);
8227
8286
  return this;
8228
8287
  }
@@ -8235,19 +8294,18 @@ var _DocumentBuilder = class _DocumentBuilder {
8235
8294
  * @returns - This document builder instance.
8236
8295
  */
8237
8296
  addNote(voiceId, note, noteLength, noteOptions) {
8238
- assertArg(isVoiceId(voiceId), "voiceId", voiceId);
8297
+ setAssertFunction("addNote", voiceId, note, noteLength, noteOptions);
8239
8298
  assertArg(
8240
- note instanceof import_theory13.Note || import_ts_utils_lib18.Utils.Is.isNonEmptyString(note) || import_ts_utils_lib18.Utils.Is.isArray(note) && note.every((note2) => note2 instanceof import_theory13.Note || import_ts_utils_lib18.Utils.Is.isNonEmptyString(note2)),
8241
- "note",
8242
- note
8299
+ isVoiceId(voiceId),
8300
+ note instanceof import_theory13.Note || import_ts_utils_lib32.Guard.isNonEmptyString(note) || import_ts_utils_lib32.Guard.isArray(note) && note.every((note2) => note2 instanceof import_theory13.Note || import_ts_utils_lib32.Guard.isNonEmptyString(note2)),
8301
+ (0, import_theory13.isNoteLength)(noteLength)
8243
8302
  );
8244
- assertArg(import_ts_utils_lib18.Utils.Is.isEnumValue(noteLength, import_theory13.NoteLength) || isNoteLength(noteLength), "noteLength", noteLength);
8245
8303
  noteOptions != null ? noteOptions : noteOptions = {};
8246
8304
  assertNoteOptions(noteOptions);
8247
- if (import_ts_utils_lib18.Utils.Is.isArray(note)) {
8305
+ if (import_ts_utils_lib32.Guard.isArray(note)) {
8248
8306
  let string = noteOptions.string;
8249
8307
  note.forEach((note2, noteId) => {
8250
- noteOptions.string = import_ts_utils_lib18.Utils.Is.isArray(string) ? string[noteId] : string;
8308
+ noteOptions.string = import_ts_utils_lib32.Guard.isArray(string) ? string[noteId] : string;
8251
8309
  this.getMeasure().addNoteGroup(voiceId, [note2], noteLength, noteOptions);
8252
8310
  });
8253
8311
  } else {
@@ -8264,9 +8322,12 @@ var _DocumentBuilder = class _DocumentBuilder {
8264
8322
  * @returns - This document builder instance.
8265
8323
  */
8266
8324
  addChord(voiceId, notes, noteLength, noteOptions) {
8267
- assertArg(isVoiceId(voiceId), "voiceId", voiceId);
8268
- assertArg(import_ts_utils_lib18.Utils.Is.isNonEmptyArray(notes) && notes.every((note) => note instanceof import_theory13.Note || import_ts_utils_lib18.Utils.Is.isNonEmptyString(note)), "notes", notes);
8269
- assertArg(import_ts_utils_lib18.Utils.Is.isEnumValue(noteLength, import_theory13.NoteLength) || isNoteLength(noteLength), "noteLength", noteLength);
8325
+ setAssertFunction("addChord", voiceId, notes, noteLength, noteOptions);
8326
+ assertArg(
8327
+ isVoiceId(voiceId),
8328
+ import_ts_utils_lib32.Guard.isNonEmptyArray(notes) && notes.every((note) => note instanceof import_theory13.Note || import_ts_utils_lib32.Guard.isNonEmptyString(note)),
8329
+ (0, import_theory13.isNoteLength)(noteLength)
8330
+ );
8270
8331
  noteOptions != null ? noteOptions : noteOptions = {};
8271
8332
  assertNoteOptions(noteOptions);
8272
8333
  this.getMeasure().addNoteGroup(voiceId, notes, noteLength, noteOptions);
@@ -8280,8 +8341,11 @@ var _DocumentBuilder = class _DocumentBuilder {
8280
8341
  * @returns - This document builder instance.
8281
8342
  */
8282
8343
  addRest(voiceId, restLength, restOptions) {
8283
- assertArg(isVoiceId(voiceId), "voiceId", voiceId);
8284
- assertArg(import_ts_utils_lib18.Utils.Is.isEnumValue(restLength, import_theory13.NoteLength) || isNoteLength(restLength), "restLength", restLength);
8344
+ setAssertFunction("addRest", voiceId, restLength, restOptions);
8345
+ assertArg(
8346
+ isVoiceId(voiceId),
8347
+ (0, import_theory13.isNoteLength)(restLength)
8348
+ );
8285
8349
  restOptions != null ? restOptions : restOptions = {};
8286
8350
  assertRestOptions(restOptions);
8287
8351
  this.getMeasure().addRest(voiceId, restLength, restOptions);
@@ -8303,25 +8367,27 @@ var _DocumentBuilder = class _DocumentBuilder {
8303
8367
  * @returns - This document builder instance.
8304
8368
  */
8305
8369
  addTuplet(voiceId, tupletRatio, tupletBuilder) {
8306
- assertArg(isVoiceId(voiceId), "voiceId", voiceId);
8307
- assertArg(import_ts_utils_lib18.Utils.Is.isFunction(tupletBuilder), "tupletBuilder", tupletBuilder);
8308
- assertArg(isTupletRatio(tupletRatio) && import_ts_utils_lib18.Utils.Is.isBooleanOrUndefined(tupletRatio.showRatio), "tupletRatio", tupletRatio);
8370
+ setAssertFunction("addTuplet", voiceId, tupletRatio);
8371
+ assertArg(
8372
+ isVoiceId(voiceId),
8373
+ import_ts_utils_lib32.Guard.isFunction(tupletBuilder),
8374
+ (0, import_theory13.isTupletRatio)(tupletRatio) && import_ts_utils_lib32.Guard.isBooleanOrUndefined(tupletRatio.showRatio)
8375
+ );
8309
8376
  let tupletSymbols = [];
8310
8377
  const helper = {
8311
8378
  addNote: (note, noteLength, noteOptions) => {
8379
+ setAssertFunction("addTuplet => addNote", note, noteLength, noteOptions);
8312
8380
  assertArg(
8313
- note instanceof import_theory13.Note || import_ts_utils_lib18.Utils.Is.isNonEmptyString(note) || import_ts_utils_lib18.Utils.Is.isArray(note) && note.every((note2) => note2 instanceof import_theory13.Note || import_ts_utils_lib18.Utils.Is.isNonEmptyString(note2)),
8314
- "note",
8315
- note
8381
+ note instanceof import_theory13.Note || import_ts_utils_lib32.Guard.isNonEmptyString(note) || import_ts_utils_lib32.Guard.isArray(note) && note.every((note2) => note2 instanceof import_theory13.Note || import_ts_utils_lib32.Guard.isNonEmptyString(note2)),
8382
+ (0, import_theory13.isNoteLength)(noteLength)
8316
8383
  );
8317
- assertArg(import_ts_utils_lib18.Utils.Is.isEnumValue(noteLength, import_theory13.NoteLength) || isNoteLength(noteLength), "noteLength", noteLength);
8318
8384
  noteOptions != null ? noteOptions : noteOptions = {};
8319
8385
  delete noteOptions.triplet;
8320
8386
  assertNoteOptions(noteOptions);
8321
- if (import_ts_utils_lib18.Utils.Is.isArray(note)) {
8387
+ if (import_ts_utils_lib32.Guard.isArray(note)) {
8322
8388
  let string = noteOptions.string;
8323
8389
  note.forEach((note2, noteId) => {
8324
- noteOptions.string = import_ts_utils_lib18.Utils.Is.isArray(string) ? string[noteId] : string;
8390
+ noteOptions.string = import_ts_utils_lib32.Guard.isArray(string) ? string[noteId] : string;
8325
8391
  let s = this.getMeasure().addNoteGroup(voiceId, [note2], noteLength, noteOptions, tupletRatio);
8326
8392
  tupletSymbols.push(s);
8327
8393
  });
@@ -8332,8 +8398,11 @@ var _DocumentBuilder = class _DocumentBuilder {
8332
8398
  return helper;
8333
8399
  },
8334
8400
  addChord: (notes, noteLength, noteOptions) => {
8335
- assertArg(import_ts_utils_lib18.Utils.Is.isNonEmptyArray(notes) && notes.every((note) => note instanceof import_theory13.Note || import_ts_utils_lib18.Utils.Is.isNonEmptyString(note)), "notes", notes);
8336
- assertArg(import_ts_utils_lib18.Utils.Is.isEnumValue(noteLength, import_theory13.NoteLength) || isNoteLength(noteLength), "noteLength", noteLength);
8401
+ setAssertFunction("addTuplet => addChord", notes, noteLength, noteOptions);
8402
+ assertArg(
8403
+ import_ts_utils_lib32.Guard.isNonEmptyArray(notes) && notes.every((note) => note instanceof import_theory13.Note || import_ts_utils_lib32.Guard.isNonEmptyString(note)),
8404
+ (0, import_theory13.isNoteLength)(noteLength)
8405
+ );
8337
8406
  noteOptions != null ? noteOptions : noteOptions = {};
8338
8407
  delete noteOptions.triplet;
8339
8408
  assertNoteOptions(noteOptions);
@@ -8342,7 +8411,8 @@ var _DocumentBuilder = class _DocumentBuilder {
8342
8411
  return helper;
8343
8412
  },
8344
8413
  addRest: (restLength, restOptions) => {
8345
- assertArg(import_ts_utils_lib18.Utils.Is.isEnumValue(restLength, import_theory13.NoteLength) || isNoteLength(restLength), "restLength", restLength);
8414
+ setAssertFunction("addTuplet => addRest", restLength, restOptions);
8415
+ assertArg((0, import_theory13.isNoteLength)(restLength));
8346
8416
  restOptions != null ? restOptions : restOptions = {};
8347
8417
  delete restOptions.triplet;
8348
8418
  assertRestOptions(restOptions);
@@ -8358,9 +8428,11 @@ var _DocumentBuilder = class _DocumentBuilder {
8358
8428
  addLyricsInternal(staffTabOrGroups, verse, lyricsLength, lyricsText, lyricsOptions) {
8359
8429
  var _a;
8360
8430
  assertStaffTabOrGRoups(staffTabOrGroups);
8361
- assertArg(isVerseNumber(verse), "verse", verse);
8362
- assertArg(import_ts_utils_lib18.Utils.Is.isEnumValue(lyricsLength, import_theory13.NoteLength), "lyricsLength", lyricsLength);
8363
- assertArg(import_ts_utils_lib18.Utils.Is.isString(lyricsText) || import_ts_utils_lib18.Utils.Is.isArray(lyricsText) && lyricsText.every((text) => import_ts_utils_lib18.Utils.Is.isString(text)), "lyricsText", lyricsText);
8431
+ assertArg(
8432
+ isVerseNumber(verse),
8433
+ import_ts_utils_lib32.Guard.isEnumValue(lyricsLength, import_theory13.NoteLength),
8434
+ import_ts_utils_lib32.Guard.isString(lyricsText) || import_ts_utils_lib32.Guard.isArray(lyricsText) && lyricsText.every((text) => import_ts_utils_lib32.Guard.isString(text))
8435
+ );
8364
8436
  lyricsOptions != null ? lyricsOptions : lyricsOptions = {};
8365
8437
  assertLyricsOptions(lyricsOptions);
8366
8438
  if (lyricsOptions.align !== void 0) {
@@ -8368,7 +8440,7 @@ var _DocumentBuilder = class _DocumentBuilder {
8368
8440
  } else {
8369
8441
  (_a = lyricsOptions.align) != null ? _a : lyricsOptions.align = this.currentLyricsAlign;
8370
8442
  }
8371
- if (import_ts_utils_lib18.Utils.Is.isArray(lyricsText)) {
8443
+ if (import_ts_utils_lib32.Guard.isArray(lyricsText)) {
8372
8444
  lyricsText.forEach((text) => this.getMeasure().addLyrics(staffTabOrGroups, verse, lyricsLength, text, lyricsOptions));
8373
8445
  } else {
8374
8446
  this.getMeasure().addLyrics(staffTabOrGroups, verse, lyricsLength, lyricsText, lyricsOptions);
@@ -8384,6 +8456,7 @@ var _DocumentBuilder = class _DocumentBuilder {
8384
8456
  * @returns - This document builder instance.
8385
8457
  */
8386
8458
  addLyrics(verse, lyricsLength, lyricsText, lyricsOptions) {
8459
+ setAssertFunction("addLyrics", verse, lyricsLength, lyricsText, lyricsOptions);
8387
8460
  return this.addLyricsInternal(void 0, verse, lyricsLength, lyricsText != null ? lyricsText : "", lyricsOptions);
8388
8461
  }
8389
8462
  /**
@@ -8396,11 +8469,12 @@ var _DocumentBuilder = class _DocumentBuilder {
8396
8469
  * @returns - This document builder instance.
8397
8470
  */
8398
8471
  addLyricsTo(staffTabOrGroups, verse, lyricsLength, lyricsText, lyricsOptions) {
8472
+ setAssertFunction("addLyricsTo", verse, lyricsLength, lyricsText, lyricsOptions);
8399
8473
  return this.addLyricsInternal(staffTabOrGroups, verse, lyricsLength, lyricsText != null ? lyricsText : "", lyricsOptions);
8400
8474
  }
8401
8475
  addFermataInternal(staffTabOrGroups, fermata) {
8402
8476
  assertStaffTabOrGRoups(staffTabOrGroups);
8403
- assertArg(import_ts_utils_lib18.Utils.Is.isEnumValue(fermata, Fermata), "fermata", fermata);
8477
+ assertArg(import_ts_utils_lib32.Guard.isEnumValue(fermata, Fermata));
8404
8478
  this.getMeasure().addFermata(staffTabOrGroups, fermata);
8405
8479
  return this;
8406
8480
  }
@@ -8410,6 +8484,7 @@ var _DocumentBuilder = class _DocumentBuilder {
8410
8484
  * @returns - This document builder instance.
8411
8485
  */
8412
8486
  addFermata(fermata = "atNote" /* AtNote */) {
8487
+ setAssertFunction("addFermata", fermata);
8413
8488
  return this.addFermataInternal(void 0, fermata);
8414
8489
  }
8415
8490
  /**
@@ -8419,37 +8494,40 @@ var _DocumentBuilder = class _DocumentBuilder {
8419
8494
  * @returns - This document builder instance.
8420
8495
  */
8421
8496
  addFermataTo(staffTabOrGroups, fermata = "atNote" /* AtNote */) {
8497
+ setAssertFunction("addFermataTo", staffTabOrGroups, fermata);
8422
8498
  return this.addFermataInternal(staffTabOrGroups, fermata);
8423
8499
  }
8424
8500
  addNavigationInternal(staffTabOrGroups, navigation, ...args) {
8425
8501
  assertStaffTabOrGRoups(staffTabOrGroups);
8426
- assertArg(import_ts_utils_lib18.Utils.Is.isEnumValue(navigation, Navigation), "navigation", navigation);
8427
- if (navigation === "endRepeat" /* EndRepeat */ && args.length > 0) {
8428
- assertArg(import_ts_utils_lib18.Utils.Is.isIntegerGte(args[0], 1), "playCount", args[0]);
8429
- } else if (navigation === "ending" /* Ending */ && args.length > 0) {
8430
- assertArg(args.every((passage) => import_ts_utils_lib18.Utils.Is.isIntegerGte(passage, 1)), "passages", args);
8431
- }
8502
+ assertArg(
8503
+ import_ts_utils_lib32.Guard.isStrictEqual(navigation, "endRepeat" /* EndRepeat */) && import_ts_utils_lib32.Guard.isStrictEqual(args.length, 1) || import_ts_utils_lib32.Guard.isStrictEqual(navigation, "ending" /* Ending */) && import_ts_utils_lib32.Guard.isIntegerGte(args.length, 1) && args.every((passage) => import_ts_utils_lib32.Guard.isIntegerGte(passage, 1)) || import_ts_utils_lib32.Guard.isEnumValue(navigation, Navigation) && import_ts_utils_lib32.Guard.isEmptyArray(args)
8504
+ );
8432
8505
  this.getMeasure().addNavigation(staffTabOrGroups, navigation, ...args);
8433
8506
  return this;
8434
8507
  }
8435
8508
  addNavigation(navigation, ...args) {
8509
+ setAssertFunction("addNavigation", navigation, ...args);
8436
8510
  return this.addNavigationInternal(void 0, navigation, ...args);
8437
8511
  }
8438
8512
  addNavigationTo(staffTabOrGroups, navigation, ...args) {
8513
+ setAssertFunction("addNavigationTo", staffTabOrGroups, navigation, ...args);
8439
8514
  return this.addNavigationInternal(staffTabOrGroups, navigation, ...args);
8440
8515
  }
8441
8516
  addAnnotationInternal(staffTabOrGroups, annotation, text) {
8442
8517
  annotation != null ? annotation : annotation = getAnnotation(text);
8443
8518
  if (annotation === void 0) {
8444
- throw new import_core19.MusicError(import_core19.MusicErrorType.Score, `Annotation text "${text}" is not known annotation.`);
8519
+ throw new import_core18.MusicError(import_core18.MusicErrorType.Score, `Annotation text "${text}" is not known annotation.`);
8445
8520
  }
8446
8521
  assertStaffTabOrGRoups(staffTabOrGroups);
8447
- assertArg(import_ts_utils_lib18.Utils.Is.isEnumValue(annotation, Annotation), "annotation", annotation);
8448
- assertArg(import_ts_utils_lib18.Utils.Is.isNonEmptyString(text), "text", text);
8522
+ assertArg(
8523
+ import_ts_utils_lib32.Guard.isEnumValue(annotation, Annotation),
8524
+ import_ts_utils_lib32.Guard.isNonEmptyString(text)
8525
+ );
8449
8526
  this.getMeasure().addAnnotation(staffTabOrGroups, annotation, text);
8450
8527
  return this;
8451
8528
  }
8452
8529
  addAnnotation(...args) {
8530
+ setAssertFunction("addAnnotation", ...args);
8453
8531
  if (args.length === 1) {
8454
8532
  return this.addAnnotationInternal(void 0, void 0, args[0]);
8455
8533
  } else {
@@ -8457,6 +8535,7 @@ var _DocumentBuilder = class _DocumentBuilder {
8457
8535
  }
8458
8536
  }
8459
8537
  addAnnotationTo(staffTabOrGroups, ...args) {
8538
+ setAssertFunction("addAnnotationTo", staffTabOrGroups, ...args);
8460
8539
  if (args.length === 1) {
8461
8540
  return this.addAnnotationInternal(staffTabOrGroups, void 0, args[0]);
8462
8541
  } else {
@@ -8465,8 +8544,10 @@ var _DocumentBuilder = class _DocumentBuilder {
8465
8544
  }
8466
8545
  addLabelInternal(staffTabOrGroups, label, text) {
8467
8546
  assertStaffTabOrGRoups(staffTabOrGroups);
8468
- assertArg(import_ts_utils_lib18.Utils.Is.isEnumValue(label, Label), "label", label);
8469
- assertArg(import_ts_utils_lib18.Utils.Is.isNonEmptyString(text), "text", text);
8547
+ assertArg(
8548
+ import_ts_utils_lib32.Guard.isEnumValue(label, Label),
8549
+ import_ts_utils_lib32.Guard.isNonEmptyString(text)
8550
+ );
8470
8551
  this.getMeasure().addLabel(staffTabOrGroups, label, text);
8471
8552
  return this;
8472
8553
  }
@@ -8477,6 +8558,7 @@ var _DocumentBuilder = class _DocumentBuilder {
8477
8558
  * @returns - This document builder instance.
8478
8559
  */
8479
8560
  addLabel(label, text) {
8561
+ setAssertFunction("addLabel", label, text);
8480
8562
  return this.addLabelInternal(void 0, label, text);
8481
8563
  }
8482
8564
  /**
@@ -8487,24 +8569,26 @@ var _DocumentBuilder = class _DocumentBuilder {
8487
8569
  * @returns - This document builder instance.
8488
8570
  */
8489
8571
  addLabelTo(staffTabOrGroups, label, text) {
8572
+ setAssertFunction("addLabelTo", staffTabOrGroups, label, text);
8490
8573
  return this.addLabelInternal(staffTabOrGroups, label, text);
8491
8574
  }
8492
8575
  addConnective(connective, ...args) {
8493
- assertArg(import_ts_utils_lib18.Utils.Is.isEnumValue(connective, Connective), "connective", connective);
8576
+ setAssertFunction("addConnective", connective, ...args);
8577
+ assertArg(import_ts_utils_lib32.Guard.isEnumValue(connective, Connective));
8494
8578
  if (connective === "tie" /* Tie */) {
8495
- assertArg(import_ts_utils_lib18.Utils.Is.isIntegerOrUndefined(args[0]) || import_ts_utils_lib18.Utils.Is.isEnumValue(args[0], TieType), "tieSpan", args[0]);
8496
- assertArg(import_ts_utils_lib18.Utils.Is.isEnumValueOrUndefined(args[1], NoteAnchor), "noteAnchor", args[1]);
8579
+ assertArg(import_ts_utils_lib32.Guard.isIntegerOrUndefined(args[0]) || import_ts_utils_lib32.Guard.isEnumValue(args[0], TieType));
8580
+ assertArg(import_ts_utils_lib32.Guard.isEnumValueOrUndefined(args[1], NoteAnchor));
8497
8581
  let tieSpan = args[0];
8498
8582
  let noteAnchor = args[1];
8499
8583
  this.getMeasure().addConnective(connective, tieSpan, noteAnchor);
8500
8584
  } else if (connective === "slur" /* Slur */) {
8501
- assertArg(import_ts_utils_lib18.Utils.Is.isIntegerOrUndefined(args[0]), "slurSpan", args[0]);
8502
- assertArg(import_ts_utils_lib18.Utils.Is.isEnumValueOrUndefined(args[1], NoteAnchor), "noteAnchor", args[1]);
8585
+ assertArg(import_ts_utils_lib32.Guard.isIntegerOrUndefined(args[0]));
8586
+ assertArg(import_ts_utils_lib32.Guard.isEnumValueOrUndefined(args[1], NoteAnchor));
8503
8587
  let slurSpan = args[0];
8504
8588
  let noteAnchor = args[1];
8505
8589
  this.getMeasure().addConnective(connective, slurSpan, noteAnchor);
8506
8590
  } else if (connective === "slide" /* Slide */) {
8507
- assertArg(import_ts_utils_lib18.Utils.Is.isEnumValueOrUndefined(args[0], NoteAnchor), "noteAnchor", args[0]);
8591
+ assertArg(import_ts_utils_lib32.Guard.isEnumValueOrUndefined(args[0], NoteAnchor));
8508
8592
  let noteAnchor = args[0];
8509
8593
  this.getMeasure().addConnective(connective, noteAnchor);
8510
8594
  }
@@ -8523,26 +8607,31 @@ var _DocumentBuilder = class _DocumentBuilder {
8523
8607
  * @returns - This document builder instance.
8524
8608
  */
8525
8609
  addExtension(extensionBuilder) {
8526
- assertArg(import_ts_utils_lib18.Utils.Is.isFunctionOrUndefined(extensionBuilder), "addExtension() has new usage, for e.g. addExtension(ext => ext.measures(2)). Please refer to README or API Reference.", extensionBuilder);
8610
+ setAssertFunction("addExtension");
8611
+ assertArgMsg(import_ts_utils_lib32.Guard.isFunctionOrUndefined(extensionBuilder), "addExtension() has new usage, e.g. addExtension(ext => ext.measures(2)).");
8527
8612
  let ticks = 0;
8528
8613
  let visible = true;
8529
8614
  const helper = {
8530
8615
  notes: (noteLength, noteCount) => {
8531
- assertArg(import_ts_utils_lib18.Utils.Is.isEnumValue(noteLength, import_theory13.NoteLength) || isNoteLength(noteLength), "noteLength", noteLength);
8532
- assertArg(import_ts_utils_lib18.Utils.Is.isUndefined(noteCount) || import_ts_utils_lib18.Utils.Is.isNumber(noteCount) && noteCount >= 0, "noteCount", noteCount);
8616
+ setAssertFunction("addExtension.notes", noteLength, noteCount);
8617
+ assertArg((0, import_theory13.isNoteLength)(noteLength));
8618
+ assertArg(import_ts_utils_lib32.Guard.isUndefined(noteCount) || import_ts_utils_lib32.Guard.isNumber(noteCount) && noteCount >= 0);
8533
8619
  ticks += import_theory13.RhythmProps.get(noteLength).ticks * (noteCount != null ? noteCount : 1);
8534
8620
  return helper;
8535
8621
  },
8536
8622
  measures: (measureCount) => {
8537
- assertArg(import_ts_utils_lib18.Utils.Is.isNumber(measureCount) && measureCount >= 1, "measureCount", measureCount);
8623
+ setAssertFunction("addExtension.measures", measureCount);
8624
+ assertArg(import_ts_utils_lib32.Guard.isNumber(measureCount) && measureCount >= 1);
8538
8625
  ticks += this.getMeasure().getMeasureTicks() * measureCount;
8539
8626
  return helper;
8540
8627
  },
8541
8628
  infinity: () => {
8629
+ setAssertFunction("addExtension.infinity");
8542
8630
  ticks = Infinity;
8543
8631
  return helper;
8544
8632
  },
8545
8633
  hide: () => {
8634
+ setAssertFunction("addExtension.hide");
8546
8635
  visible = false;
8547
8636
  return helper;
8548
8637
  }
@@ -8563,13 +8652,12 @@ var _DocumentBuilder = class _DocumentBuilder {
8563
8652
  * @returns - This document builder instance.
8564
8653
  */
8565
8654
  addStaffGroup(groupName, staffsTabsAndGroups, verticalPosition = "auto" /* Auto */) {
8566
- assertArg(import_ts_utils_lib18.Utils.Is.isNonEmptyString(groupName), "groupName", groupName);
8655
+ setAssertFunction("addStaffGroup", groupName, staffsTabsAndGroups, verticalPosition);
8567
8656
  assertArg(
8568
- import_ts_utils_lib18.Utils.Is.isNonEmptyString(staffsTabsAndGroups) || import_ts_utils_lib18.Utils.Is.isIntegerGte(staffsTabsAndGroups, 0) || import_ts_utils_lib18.Utils.Is.isNonEmptyArray(staffsTabsAndGroups) && staffsTabsAndGroups.every((line) => import_ts_utils_lib18.Utils.Is.isNonEmptyString(line) || import_ts_utils_lib18.Utils.Is.isIntegerGte(line, 0)),
8569
- "staffsTabsAndGroups",
8570
- staffsTabsAndGroups
8657
+ import_ts_utils_lib32.Guard.isNonEmptyString(groupName),
8658
+ import_ts_utils_lib32.Guard.isNonEmptyString(staffsTabsAndGroups) || import_ts_utils_lib32.Guard.isIntegerGte(staffsTabsAndGroups, 0) || import_ts_utils_lib32.Guard.isNonEmptyArray(staffsTabsAndGroups) && staffsTabsAndGroups.every((line) => import_ts_utils_lib32.Guard.isNonEmptyString(line) || import_ts_utils_lib32.Guard.isIntegerGte(line, 0)),
8659
+ import_ts_utils_lib32.Guard.isEnumValue(verticalPosition, VerticalPosition)
8571
8660
  );
8572
- assertArg(import_ts_utils_lib18.Utils.Is.isEnumValue(verticalPosition, VerticalPosition), "verticalPosition", verticalPosition);
8573
8661
  this.doc.addStaffGroup(groupName, staffsTabsAndGroups, verticalPosition);
8574
8662
  return this;
8575
8663
  }
@@ -8578,6 +8666,7 @@ var _DocumentBuilder = class _DocumentBuilder {
8578
8666
  * @returns - This document builder instance.
8579
8667
  */
8580
8668
  endSong() {
8669
+ setAssertFunction("endSong");
8581
8670
  this.getMeasure().endSong();
8582
8671
  return this;
8583
8672
  }
@@ -8586,6 +8675,7 @@ var _DocumentBuilder = class _DocumentBuilder {
8586
8675
  * @returns - This document builder instance.
8587
8676
  */
8588
8677
  endSection() {
8678
+ setAssertFunction("endSection");
8589
8679
  this.getMeasure().endSection();
8590
8680
  return this;
8591
8681
  }
@@ -8595,6 +8685,7 @@ var _DocumentBuilder = class _DocumentBuilder {
8595
8685
  */
8596
8686
  endRow() {
8597
8687
  var _a;
8688
+ setAssertFunction("endRow");
8598
8689
  (_a = this.doc.getLastMeasure()) == null ? void 0 : _a.endRow();
8599
8690
  return this;
8600
8691
  }
@@ -8604,7 +8695,8 @@ var _DocumentBuilder = class _DocumentBuilder {
8604
8695
  * @returns - This document builder instance.
8605
8696
  */
8606
8697
  completeRests(voiceId) {
8607
- assertArg(import_ts_utils_lib18.Utils.Is.isUndefined(voiceId) || isVoiceId(voiceId) || import_ts_utils_lib18.Utils.Is.isArray(voiceId) && voiceId.every((id) => isVoiceId(id)), "voiceId", voiceId);
8698
+ setAssertFunction("completeRests", voiceId);
8699
+ assertArg(import_ts_utils_lib32.Guard.isUndefined(voiceId) || isVoiceId(voiceId) || import_ts_utils_lib32.Guard.isArray(voiceId) && voiceId.every((id) => isVoiceId(id)));
8608
8700
  this.getMeasure().completeRests(voiceId);
8609
8701
  return this;
8610
8702
  }
@@ -8616,8 +8708,11 @@ var _DocumentBuilder = class _DocumentBuilder {
8616
8708
  * @returns - This document builder instance.
8617
8709
  */
8618
8710
  addScaleArpeggio(scale, bottomNote, numOctaves) {
8619
- assertArg(import_ts_utils_lib18.Utils.Is.isNonEmptyString(bottomNote), "bottomNote", bottomNote);
8620
- assertArg(import_ts_utils_lib18.Utils.Is.isIntegerGte(numOctaves, 1), "numOctaves", numOctaves);
8711
+ setAssertFunction("addScaleArpeggio", scale, bottomNote, numOctaves);
8712
+ assertArg(
8713
+ import_ts_utils_lib32.Guard.isNonEmptyString(bottomNote),
8714
+ import_ts_utils_lib32.Guard.isIntegerGte(numOctaves, 1)
8715
+ );
8621
8716
  let ts = this.getMeasure().getTimeSignature();
8622
8717
  let notes = scale.getScaleNotes(bottomNote, numOctaves);
8623
8718
  for (let i = 0; i < notes.length; i++) {
@@ -8635,7 +8730,7 @@ __publicField(_DocumentBuilder, "DefaultMeasureOptions", {});
8635
8730
  var DocumentBuilder = _DocumentBuilder;
8636
8731
 
8637
8732
  // src/score/pub/event.ts
8638
- var import_core20 = require("@tspro/web-music-score/core");
8733
+ var import_core19 = require("@tspro/web-music-score/core");
8639
8734
  var ScoreEvent = class {
8640
8735
  /**
8641
8736
  * Create new score event instance.
@@ -8678,7 +8773,7 @@ var ScoreObjectEvent = class extends ScoreEvent {
8678
8773
  this.renderContext = renderContext;
8679
8774
  this.objects = objects;
8680
8775
  if (arguments.length === 0) {
8681
- throw new import_core20.MusicError(import_core20.MusicErrorType.Score, "Empty array in score object event!");
8776
+ throw new import_core19.MusicError(import_core19.MusicErrorType.Score, "Empty array in score object event!");
8682
8777
  }
8683
8778
  }
8684
8779
  /**
@@ -8703,27 +8798,24 @@ var ScoreObjectEvent = class extends ScoreEvent {
8703
8798
 
8704
8799
  // src/score/pub/music-interface.ts
8705
8800
  var Audio2 = __toESM(require("@tspro/web-music-score/audio"));
8706
- var import_ts_utils_lib20 = require("@tspro/ts-utils-lib");
8801
+ var import_ts_utils_lib34 = require("@tspro/ts-utils-lib");
8707
8802
 
8708
8803
  // src/score/pub/music-objects.ts
8709
- var import_ts_utils_lib19 = require("@tspro/ts-utils-lib");
8710
- var import_core21 = require("@tspro/web-music-score/core");
8804
+ var import_ts_utils_lib33 = require("@tspro/ts-utils-lib");
8805
+ var import_core20 = require("@tspro/web-music-score/core");
8711
8806
  function assertArg2(condition, argName, argValue) {
8712
8807
  if (!condition) {
8713
- throw new import_core21.MusicError(import_core21.MusicErrorType.Score, `Invalid arg: ${argName} = ${argValue}`);
8808
+ throw new import_core20.MusicError(import_core20.MusicErrorType.Score, `Invalid arg: ${argName} = ${argValue}`);
8714
8809
  }
8715
8810
  }
8716
- function isVoiceId2(value) {
8717
- return import_ts_utils_lib19.Utils.Is.isNumber(value) && getVoiceIds().indexOf(value) >= 0;
8718
- }
8719
8811
  function getNotationLine(line) {
8720
8812
  if (line instanceof ObjStaff || line instanceof ObjTab) {
8721
8813
  return line.getMusicInterface();
8722
8814
  } else {
8723
- throw new import_core21.MusicError(import_core21.MusicErrorType.Score, `Notation line not staff nor tab.`);
8815
+ throw new import_core20.MusicError(import_core20.MusicErrorType.Score, `Notation line not staff nor tab.`);
8724
8816
  }
8725
8817
  }
8726
- var MusicInterface6 = class {
8818
+ var MusicInterface5 = class {
8727
8819
  /**
8728
8820
  * Create new music interface object.
8729
8821
  * @param name - OBject name.
@@ -8740,7 +8832,7 @@ var MusicInterface6 = class {
8740
8832
  return (_a = this.getMusicObject().getParent()) == null ? void 0 : _a.getMusicInterface();
8741
8833
  }
8742
8834
  };
8743
- var _MAccidental = class _MAccidental extends MusicInterface6 {
8835
+ var _MAccidental = class _MAccidental extends MusicInterface5 {
8744
8836
  /** @internal */
8745
8837
  constructor(obj) {
8746
8838
  super(_MAccidental.Name);
@@ -8761,7 +8853,7 @@ var _MAccidental = class _MAccidental extends MusicInterface6 {
8761
8853
  /** Object name. */
8762
8854
  __publicField(_MAccidental, "Name", "Accidental");
8763
8855
  var MAccidental = _MAccidental;
8764
- var _MConnective = class _MConnective extends MusicInterface6 {
8856
+ var _MConnective = class _MConnective extends MusicInterface5 {
8765
8857
  /** @internal */
8766
8858
  constructor(obj) {
8767
8859
  super(_MConnective.Name);
@@ -8775,7 +8867,7 @@ var _MConnective = class _MConnective extends MusicInterface6 {
8775
8867
  /** Object name. */
8776
8868
  __publicField(_MConnective, "Name", "Connective");
8777
8869
  var MConnective = _MConnective;
8778
- var _MArpeggio = class _MArpeggio extends MusicInterface6 {
8870
+ var _MArpeggio = class _MArpeggio extends MusicInterface5 {
8779
8871
  /** @internal */
8780
8872
  constructor(obj) {
8781
8873
  super(_MArpeggio.Name);
@@ -8803,7 +8895,7 @@ var _MArpeggio = class _MArpeggio extends MusicInterface6 {
8803
8895
  /** Object name. */
8804
8896
  __publicField(_MArpeggio, "Name", "Arpeggio");
8805
8897
  var MArpeggio = _MArpeggio;
8806
- var _MBeamGroup = class _MBeamGroup extends MusicInterface6 {
8898
+ var _MBeamGroup = class _MBeamGroup extends MusicInterface5 {
8807
8899
  /** @internal */
8808
8900
  constructor(obj) {
8809
8901
  super(_MBeamGroup.Name);
@@ -8817,7 +8909,7 @@ var _MBeamGroup = class _MBeamGroup extends MusicInterface6 {
8817
8909
  /** OBject name. */
8818
8910
  __publicField(_MBeamGroup, "Name", "BeamGroup");
8819
8911
  var MBeamGroup = _MBeamGroup;
8820
- var _MStaffBeamGroup = class _MStaffBeamGroup extends MusicInterface6 {
8912
+ var _MStaffBeamGroup = class _MStaffBeamGroup extends MusicInterface5 {
8821
8913
  /** @internal */
8822
8914
  constructor(obj) {
8823
8915
  super(_MStaffBeamGroup.Name);
@@ -8838,7 +8930,7 @@ var _MStaffBeamGroup = class _MStaffBeamGroup extends MusicInterface6 {
8838
8930
  /** Object name. */
8839
8931
  __publicField(_MStaffBeamGroup, "Name", "StaffBeamGroup");
8840
8932
  var MStaffBeamGroup = _MStaffBeamGroup;
8841
- var _MDocument = class _MDocument extends MusicInterface6 {
8933
+ var _MDocument = class _MDocument extends MusicInterface5 {
8842
8934
  /** @internal */
8843
8935
  constructor(obj) {
8844
8936
  super(_MDocument.Name);
@@ -8890,14 +8982,14 @@ var _MDocument = class _MDocument extends MusicInterface6 {
8890
8982
  * @returns - Player instance.
8891
8983
  */
8892
8984
  play(playStateChangeListener) {
8893
- assertArg2(import_ts_utils_lib19.Utils.Is.isFunctionOrUndefined(playStateChangeListener), "playStateChangeListener", playStateChangeListener);
8985
+ assertArg2(import_ts_utils_lib33.Guard.isFunctionOrUndefined(playStateChangeListener), "playStateChangeListener", playStateChangeListener);
8894
8986
  return new MPlayer(this, playStateChangeListener).play();
8895
8987
  }
8896
8988
  };
8897
8989
  /** Object name. */
8898
8990
  __publicField(_MDocument, "Name", "Document");
8899
8991
  var MDocument2 = _MDocument;
8900
- var _MEnding = class _MEnding extends MusicInterface6 {
8992
+ var _MEnding = class _MEnding extends MusicInterface5 {
8901
8993
  /** @internal */
8902
8994
  constructor(obj) {
8903
8995
  super(_MEnding.Name);
@@ -8920,14 +9012,14 @@ var _MEnding = class _MEnding extends MusicInterface6 {
8920
9012
  * @returns - Boolean whether this ending has asked passage number.
8921
9013
  */
8922
9014
  hasPassage(passage) {
8923
- assertArg2(import_ts_utils_lib19.Utils.Is.isIntegerGte(passage, 1), "passage", passage);
9015
+ assertArg2(import_ts_utils_lib33.Guard.isIntegerGte(passage, 1), "passage", passage);
8924
9016
  return this.obj.hasPassage(passage);
8925
9017
  }
8926
9018
  };
8927
9019
  /** Object name. */
8928
9020
  __publicField(_MEnding, "Name", "Ending");
8929
9021
  var MEnding = _MEnding;
8930
- var _MFermata = class _MFermata extends MusicInterface6 {
9022
+ var _MFermata = class _MFermata extends MusicInterface5 {
8931
9023
  /** @internal */
8932
9024
  constructor(obj) {
8933
9025
  super(_MFermata.Name);
@@ -8941,7 +9033,7 @@ var _MFermata = class _MFermata extends MusicInterface6 {
8941
9033
  /** OBject name. */
8942
9034
  __publicField(_MFermata, "Name", "Fermata");
8943
9035
  var MFermata = _MFermata;
8944
- var _MHeader = class _MHeader extends MusicInterface6 {
9036
+ var _MHeader = class _MHeader extends MusicInterface5 {
8945
9037
  /** @internal */
8946
9038
  constructor(obj) {
8947
9039
  super(_MHeader.Name);
@@ -8976,7 +9068,7 @@ var _MHeader = class _MHeader extends MusicInterface6 {
8976
9068
  /** OBject name. */
8977
9069
  __publicField(_MHeader, "Name", "Header");
8978
9070
  var MHeader = _MHeader;
8979
- var _MImage = class _MImage extends MusicInterface6 {
9071
+ var _MImage = class _MImage extends MusicInterface5 {
8980
9072
  /** @internal */
8981
9073
  constructor(obj) {
8982
9074
  super(_MImage.Name);
@@ -8990,7 +9082,7 @@ var _MImage = class _MImage extends MusicInterface6 {
8990
9082
  /** Object name. */
8991
9083
  __publicField(_MImage, "Name", "Image");
8992
9084
  var MImage = _MImage;
8993
- var _MMeasure = class _MMeasure extends MusicInterface6 {
9085
+ var _MMeasure = class _MMeasure extends MusicInterface5 {
8994
9086
  /** @internal */
8995
9087
  constructor(obj) {
8996
9088
  super(_MMeasure.Name);
@@ -9025,7 +9117,7 @@ var _MMeasure = class _MMeasure extends MusicInterface6 {
9025
9117
  /** OBject name. */
9026
9118
  __publicField(_MMeasure, "Name", "Measure");
9027
9119
  var MMeasure = _MMeasure;
9028
- var _MBarLineRight = class _MBarLineRight extends MusicInterface6 {
9120
+ var _MBarLineRight = class _MBarLineRight extends MusicInterface5 {
9029
9121
  /** @internal */
9030
9122
  constructor(obj) {
9031
9123
  super(_MBarLineRight.Name);
@@ -9039,7 +9131,7 @@ var _MBarLineRight = class _MBarLineRight extends MusicInterface6 {
9039
9131
  /** OBject name. */
9040
9132
  __publicField(_MBarLineRight, "Name", "BarLineRight");
9041
9133
  var MBarLineRight = _MBarLineRight;
9042
- var _MBarLineLeft = class _MBarLineLeft extends MusicInterface6 {
9134
+ var _MBarLineLeft = class _MBarLineLeft extends MusicInterface5 {
9043
9135
  /** @internal */
9044
9136
  constructor(obj) {
9045
9137
  super(_MBarLineLeft.Name);
@@ -9053,7 +9145,7 @@ var _MBarLineLeft = class _MBarLineLeft extends MusicInterface6 {
9053
9145
  /** Object name. */
9054
9146
  __publicField(_MBarLineLeft, "Name", "BarLineLeft");
9055
9147
  var MBarLineLeft = _MBarLineLeft;
9056
- var _MStaffTabBarLine = class _MStaffTabBarLine extends MusicInterface6 {
9148
+ var _MStaffTabBarLine = class _MStaffTabBarLine extends MusicInterface5 {
9057
9149
  /** @internal */
9058
9150
  constructor(obj) {
9059
9151
  super(_MStaffTabBarLine.Name);
@@ -9072,7 +9164,7 @@ var _MStaffTabBarLine = class _MStaffTabBarLine extends MusicInterface6 {
9072
9164
  if (barLine instanceof ObjBarLineLeft || barLine instanceof ObjBarLineRight) {
9073
9165
  return barLine.getMusicInterface();
9074
9166
  } else {
9075
- throw new import_core21.MusicError(import_core21.MusicErrorType.Score, `Bar line not let nor right.`);
9167
+ throw new import_core20.MusicError(import_core20.MusicErrorType.Score, `Bar line not let nor right.`);
9076
9168
  }
9077
9169
  }
9078
9170
  /**
@@ -9086,7 +9178,7 @@ var _MStaffTabBarLine = class _MStaffTabBarLine extends MusicInterface6 {
9086
9178
  /** Object name. */
9087
9179
  __publicField(_MStaffTabBarLine, "Name", "StaffTabBarLine");
9088
9180
  var MStaffTabBarLine = _MStaffTabBarLine;
9089
- var _MNoteGroup = class _MNoteGroup extends MusicInterface6 {
9181
+ var _MNoteGroup = class _MNoteGroup extends MusicInterface5 {
9090
9182
  /** @internal */
9091
9183
  constructor(obj) {
9092
9184
  super(_MNoteGroup.Name);
@@ -9128,7 +9220,7 @@ var _MNoteGroup = class _MNoteGroup extends MusicInterface6 {
9128
9220
  /** Object name. */
9129
9221
  __publicField(_MNoteGroup, "Name", "NoteGroup");
9130
9222
  var MNoteGroup = _MNoteGroup;
9131
- var _MStaffNoteGroup = class _MStaffNoteGroup extends MusicInterface6 {
9223
+ var _MStaffNoteGroup = class _MStaffNoteGroup extends MusicInterface5 {
9132
9224
  /** @internal */
9133
9225
  constructor(obj) {
9134
9226
  super(_MStaffNoteGroup.Name);
@@ -9170,7 +9262,7 @@ var _MStaffNoteGroup = class _MStaffNoteGroup extends MusicInterface6 {
9170
9262
  /** Object name. */
9171
9263
  __publicField(_MStaffNoteGroup, "Name", "StaffNoteGroup");
9172
9264
  var MStaffNoteGroup = _MStaffNoteGroup;
9173
- var _MTabNoteGroup = class _MTabNoteGroup extends MusicInterface6 {
9265
+ var _MTabNoteGroup = class _MTabNoteGroup extends MusicInterface5 {
9174
9266
  /** @internal */
9175
9267
  constructor(obj) {
9176
9268
  super(_MTabNoteGroup.Name);
@@ -9212,7 +9304,7 @@ var _MTabNoteGroup = class _MTabNoteGroup extends MusicInterface6 {
9212
9304
  /** OBject name. */
9213
9305
  __publicField(_MTabNoteGroup, "Name", "TabNoteGroup");
9214
9306
  var MTabNoteGroup = _MTabNoteGroup;
9215
- var _MRest = class _MRest extends MusicInterface6 {
9307
+ var _MRest = class _MRest extends MusicInterface5 {
9216
9308
  /** @internal */
9217
9309
  constructor(obj) {
9218
9310
  super(_MRest.Name);
@@ -9247,7 +9339,7 @@ var _MRest = class _MRest extends MusicInterface6 {
9247
9339
  /** OBject name. */
9248
9340
  __publicField(_MRest, "Name", "Rest");
9249
9341
  var MRest = _MRest;
9250
- var _MStaffRest = class _MStaffRest extends MusicInterface6 {
9342
+ var _MStaffRest = class _MStaffRest extends MusicInterface5 {
9251
9343
  /** @internal */
9252
9344
  constructor(obj) {
9253
9345
  super(_MStaffRest.Name);
@@ -9289,7 +9381,7 @@ var _MStaffRest = class _MStaffRest extends MusicInterface6 {
9289
9381
  /** Object name. */
9290
9382
  __publicField(_MStaffRest, "Name", "StaffRest");
9291
9383
  var MStaffRest = _MStaffRest;
9292
- var _MRhythmColumn = class _MRhythmColumn extends MusicInterface6 {
9384
+ var _MRhythmColumn = class _MRhythmColumn extends MusicInterface5 {
9293
9385
  /** @internal */
9294
9386
  constructor(obj) {
9295
9387
  super(_MRhythmColumn.Name);
@@ -9306,7 +9398,7 @@ var _MRhythmColumn = class _MRhythmColumn extends MusicInterface6 {
9306
9398
  */
9307
9399
  getRhythmSymbol(voiceId) {
9308
9400
  var _a;
9309
- assertArg2(isVoiceId2(voiceId), "voiceId", voiceId);
9401
+ assertArg2(isVoiceId(voiceId), "voiceId", voiceId);
9310
9402
  return (_a = this.obj.getVoiceSymbol(voiceId)) == null ? void 0 : _a.getMusicInterface();
9311
9403
  }
9312
9404
  /**
@@ -9317,7 +9409,7 @@ var _MRhythmColumn = class _MRhythmColumn extends MusicInterface6 {
9317
9409
  */
9318
9410
  getVoiceSymbol(voiceId) {
9319
9411
  var _a;
9320
- assertArg2(isVoiceId2(voiceId), "voiceId", voiceId);
9412
+ assertArg2(isVoiceId(voiceId), "voiceId", voiceId);
9321
9413
  return (_a = this.obj.getVoiceSymbol(voiceId)) == null ? void 0 : _a.getMusicInterface();
9322
9414
  }
9323
9415
  /**
@@ -9331,7 +9423,7 @@ var _MRhythmColumn = class _MRhythmColumn extends MusicInterface6 {
9331
9423
  /** OBject name. */
9332
9424
  __publicField(_MRhythmColumn, "Name", "RhythmColumn");
9333
9425
  var MRhythmColumn = _MRhythmColumn;
9334
- var _MScoreRow = class _MScoreRow extends MusicInterface6 {
9426
+ var _MScoreRow = class _MScoreRow extends MusicInterface5 {
9335
9427
  /** @internal */
9336
9428
  constructor(obj) {
9337
9429
  super(_MScoreRow.Name);
@@ -9366,7 +9458,7 @@ var _MScoreRow = class _MScoreRow extends MusicInterface6 {
9366
9458
  /** Object name. */
9367
9459
  __publicField(_MScoreRow, "Name", "ScoreRow");
9368
9460
  var MScoreRow = _MScoreRow;
9369
- var _MStaff = class _MStaff extends MusicInterface6 {
9461
+ var _MStaff = class _MStaff extends MusicInterface5 {
9370
9462
  /** @internal */
9371
9463
  constructor(obj) {
9372
9464
  super(_MStaff.Name);
@@ -9401,7 +9493,7 @@ var _MStaff = class _MStaff extends MusicInterface6 {
9401
9493
  /** Object name. */
9402
9494
  __publicField(_MStaff, "Name", "Staff");
9403
9495
  var MStaff = _MStaff;
9404
- var _MTab = class _MTab extends MusicInterface6 {
9496
+ var _MTab = class _MTab extends MusicInterface5 {
9405
9497
  /** @internal */
9406
9498
  constructor(obj) {
9407
9499
  super(_MTab.Name);
@@ -9436,7 +9528,7 @@ var _MTab = class _MTab extends MusicInterface6 {
9436
9528
  /** Object name. */
9437
9529
  __publicField(_MTab, "Name", "Tab");
9438
9530
  var MTab = _MTab;
9439
- var _MStaffSignature = class _MStaffSignature extends MusicInterface6 {
9531
+ var _MStaffSignature = class _MStaffSignature extends MusicInterface5 {
9440
9532
  /** @internal */
9441
9533
  constructor(obj) {
9442
9534
  super(_MStaffSignature.Name);
@@ -9457,7 +9549,7 @@ var _MStaffSignature = class _MStaffSignature extends MusicInterface6 {
9457
9549
  /** Object name. */
9458
9550
  __publicField(_MStaffSignature, "Name", "StaffSignature");
9459
9551
  var MStaffSignature = _MStaffSignature;
9460
- var _MTabSignature = class _MTabSignature extends MusicInterface6 {
9552
+ var _MTabSignature = class _MTabSignature extends MusicInterface5 {
9461
9553
  /** @internal */
9462
9554
  constructor(obj) {
9463
9555
  super(_MTabSignature.Name);
@@ -9478,7 +9570,7 @@ var _MTabSignature = class _MTabSignature extends MusicInterface6 {
9478
9570
  /** Object name. */
9479
9571
  __publicField(_MTabSignature, "Name", "TabSignature");
9480
9572
  var MTabSignature = _MTabSignature;
9481
- var _MTabRhythm = class _MTabRhythm extends MusicInterface6 {
9573
+ var _MTabRhythm = class _MTabRhythm extends MusicInterface5 {
9482
9574
  /** @internal */
9483
9575
  constructor(obj) {
9484
9576
  super(_MTabRhythm.Name);
@@ -9506,7 +9598,7 @@ var _MTabRhythm = class _MTabRhythm extends MusicInterface6 {
9506
9598
  /** Object name. */
9507
9599
  __publicField(_MTabRhythm, "Name", "TabRhythm");
9508
9600
  var MTabRhythm = _MTabRhythm;
9509
- var _MSpecialText = class _MSpecialText extends MusicInterface6 {
9601
+ var _MSpecialText = class _MSpecialText extends MusicInterface5 {
9510
9602
  /** @internal */
9511
9603
  constructor(obj) {
9512
9604
  super(_MSpecialText.Name);
@@ -9527,7 +9619,7 @@ var _MSpecialText = class _MSpecialText extends MusicInterface6 {
9527
9619
  /** Object name. */
9528
9620
  __publicField(_MSpecialText, "Name", "SpecialText");
9529
9621
  var MSpecialText = _MSpecialText;
9530
- var _MText = class _MText extends MusicInterface6 {
9622
+ var _MText = class _MText extends MusicInterface5 {
9531
9623
  /** @internal */
9532
9624
  constructor(obj) {
9533
9625
  super(_MText.Name);
@@ -9548,7 +9640,7 @@ var _MText = class _MText extends MusicInterface6 {
9548
9640
  /** Object name. */
9549
9641
  __publicField(_MText, "Name", "Text");
9550
9642
  var MText = _MText;
9551
- var _MLyrics = class _MLyrics extends MusicInterface6 {
9643
+ var _MLyrics = class _MLyrics extends MusicInterface5 {
9552
9644
  /** @internal */
9553
9645
  constructor(obj) {
9554
9646
  super(_MLyrics.Name);
@@ -9569,7 +9661,7 @@ var _MLyrics = class _MLyrics extends MusicInterface6 {
9569
9661
  /** Object name. */
9570
9662
  __publicField(_MLyrics, "Name", "Lyrics");
9571
9663
  var MLyrics = _MLyrics;
9572
- var _MExtensionLine = class _MExtensionLine extends MusicInterface6 {
9664
+ var _MExtensionLine = class _MExtensionLine extends MusicInterface5 {
9573
9665
  /** @internal */
9574
9666
  constructor(obj) {
9575
9667
  super(_MExtensionLine.Name);
@@ -9585,10 +9677,10 @@ __publicField(_MExtensionLine, "Name", "ExtensionLine");
9585
9677
  var MExtensionLine = _MExtensionLine;
9586
9678
 
9587
9679
  // src/score/pub/music-interface.ts
9588
- var import_core22 = require("@tspro/web-music-score/core");
9680
+ var import_core21 = require("@tspro/web-music-score/core");
9589
9681
  function assertArg3(condition, argName, argValue) {
9590
9682
  if (!condition) {
9591
- throw new import_core22.MusicError(import_core22.MusicErrorType.Score, `Invalid arg: ${argName} = ${argValue}`);
9683
+ throw new import_core21.MusicError(import_core21.MusicErrorType.Score, `Invalid arg: ${argName} = ${argValue}`);
9592
9684
  }
9593
9685
  }
9594
9686
  function require_t(t, message) {
@@ -9607,10 +9699,12 @@ var _MPlayer = class _MPlayer {
9607
9699
  constructor(doc, playStateChangeListener) {
9608
9700
  __publicField(this, "player");
9609
9701
  assertArg3(doc instanceof MDocument2, "doc", doc);
9610
- assertArg3(import_ts_utils_lib20.Utils.Is.isFunctionOrUndefined(playStateChangeListener), "playStateChangeListener", playStateChangeListener);
9702
+ assertArg3(import_ts_utils_lib34.Guard.isFunctionOrUndefined(playStateChangeListener), "playStateChangeListener", playStateChangeListener);
9611
9703
  this.player = new Player();
9612
9704
  this.player.setDocument(doc.getMusicObject());
9613
- this.player.setCursorPositionChangeListener((cursorRect) => doc.getMusicObject().updateCursorRect(cursorRect));
9705
+ this.player.setCursorPositionChangeListener((cursorRect) => {
9706
+ doc.getMusicObject().updateCursorRect(cursorRect);
9707
+ });
9614
9708
  if (playStateChangeListener) {
9615
9709
  this.player.setPlayStateChnageListener(playStateChangeListener);
9616
9710
  }
@@ -9649,7 +9743,7 @@ var _MPlayer = class _MPlayer {
9649
9743
  return this;
9650
9744
  }
9651
9745
  };
9652
- __publicField(_MPlayer, "currentlyPlaying", /* @__PURE__ */ new Set());
9746
+ __publicField(_MPlayer, "currentlyPlaying", new import_ts_utils_lib34.ValueSet());
9653
9747
  var MPlayer = _MPlayer;
9654
9748
  var MRenderContext2 = class {
9655
9749
  /**
@@ -9665,7 +9759,7 @@ var MRenderContext2 = class {
9665
9759
  * @returns - This render context instance.
9666
9760
  */
9667
9761
  setDocument(doc) {
9668
- assertArg3(import_ts_utils_lib20.Utils.Is.isUndefined(doc) || doc instanceof MDocument2, "doc", doc);
9762
+ assertArg3(import_ts_utils_lib34.Guard.isUndefined(doc) || doc instanceof MDocument2, "doc", doc);
9669
9763
  this.ctx.setDocument(doc);
9670
9764
  return this;
9671
9765
  }
@@ -9675,7 +9769,7 @@ var MRenderContext2 = class {
9675
9769
  * @returns - This render context instance.
9676
9770
  */
9677
9771
  setCanvas(canvas) {
9678
- canvas = require_t(import_ts_utils_lib20.Utils.Dom.getCanvas(canvas), typeof canvas === "string" ? "Cannot set render canvas because invalid canvas id: " + canvas : "Cannot set render canvas because given canvas is undefined.");
9772
+ canvas = require_t(import_ts_utils_lib34.Utils.Dom.getCanvas(canvas), typeof canvas === "string" ? "Cannot set render canvas because invalid canvas id: " + canvas : "Cannot set render canvas because given canvas is undefined.");
9679
9773
  this.ctx.setCanvas(canvas);
9680
9774
  return this;
9681
9775
  }
@@ -9684,7 +9778,7 @@ var MRenderContext2 = class {
9684
9778
  * @param scoreEventListener - Score event listener.
9685
9779
  */
9686
9780
  setScoreEventListener(scoreEventListener) {
9687
- assertArg3(import_ts_utils_lib20.Utils.Is.isFunctionOrUndefined(scoreEventListener), "scoreEventListener", scoreEventListener);
9781
+ assertArg3(import_ts_utils_lib34.Guard.isFunctionOrUndefined(scoreEventListener), "scoreEventListener", scoreEventListener);
9688
9782
  this.ctx.setScoreEventListener(scoreEventListener);
9689
9783
  }
9690
9784
  /**
@@ -9759,7 +9853,7 @@ var _MPlaybackButtons = class _MPlaybackButtons {
9759
9853
  * @returns
9760
9854
  */
9761
9855
  setDocument(doc) {
9762
- assertArg3(import_ts_utils_lib20.Utils.Is.isUndefined(doc) || doc instanceof MDocument2, "doc", doc);
9856
+ assertArg3(import_ts_utils_lib34.Guard.isUndefined(doc) || doc instanceof MDocument2, "doc", doc);
9763
9857
  this.onStop();
9764
9858
  if (doc) {
9765
9859
  this.player = new MPlayer(doc, (playState) => {
@@ -9803,9 +9897,9 @@ var _MPlaybackButtons = class _MPlaybackButtons {
9803
9897
  * @returns - This playback buttons class instance.
9804
9898
  */
9805
9899
  setPlayButton(btn, btnLabel) {
9806
- assertArg3(import_ts_utils_lib20.Utils.Is.isStringOrUndefined(btnLabel), "btnLabel", btnLabel);
9900
+ assertArg3(import_ts_utils_lib34.Guard.isStringOrUndefined(btnLabel), "btnLabel", btnLabel);
9807
9901
  _MPlaybackButtons.removeOnClickListeners(this.playButton, this.onPlay);
9808
- this.playButton = require_t(import_ts_utils_lib20.Utils.Dom.getButton(btn), "Play button required!");
9902
+ this.playButton = require_t(import_ts_utils_lib34.Utils.Dom.getButton(btn), "Play button required!");
9809
9903
  this.playLabel = btnLabel != null ? btnLabel : "Play";
9810
9904
  _MPlaybackButtons.removeOnClickListeners(this.playButton, "all");
9811
9905
  _MPlaybackButtons.addOnClickListener(this.playButton, this.onPlay);
@@ -9819,9 +9913,9 @@ var _MPlaybackButtons = class _MPlaybackButtons {
9819
9913
  * @returns - This playback buttons class instance.
9820
9914
  */
9821
9915
  setStopButton(btn, btnLabel) {
9822
- assertArg3(import_ts_utils_lib20.Utils.Is.isStringOrUndefined(btnLabel), "btnLabel", btnLabel);
9916
+ assertArg3(import_ts_utils_lib34.Guard.isStringOrUndefined(btnLabel), "btnLabel", btnLabel);
9823
9917
  _MPlaybackButtons.removeOnClickListeners(this.stopButton, this.onStop);
9824
- this.stopButton = require_t(import_ts_utils_lib20.Utils.Dom.getButton(btn), "Stop button required!");
9918
+ this.stopButton = require_t(import_ts_utils_lib34.Utils.Dom.getButton(btn), "Stop button required!");
9825
9919
  this.stopLabel = btnLabel != null ? btnLabel : "Stop";
9826
9920
  _MPlaybackButtons.removeOnClickListeners(this.stopButton, "all");
9827
9921
  _MPlaybackButtons.addOnClickListener(this.stopButton, this.onStop);
@@ -9836,10 +9930,10 @@ var _MPlaybackButtons = class _MPlaybackButtons {
9836
9930
  * @returns - This playback buttons class instance.
9837
9931
  */
9838
9932
  setPlayStopButton(btn, playLabel, stopLabel) {
9839
- assertArg3(import_ts_utils_lib20.Utils.Is.isStringOrUndefined(playLabel), "playLabel", playLabel);
9840
- assertArg3(import_ts_utils_lib20.Utils.Is.isStringOrUndefined(stopLabel), "stopLabel", stopLabel);
9933
+ assertArg3(import_ts_utils_lib34.Guard.isStringOrUndefined(playLabel), "playLabel", playLabel);
9934
+ assertArg3(import_ts_utils_lib34.Guard.isStringOrUndefined(stopLabel), "stopLabel", stopLabel);
9841
9935
  _MPlaybackButtons.removeOnClickListeners(this.playStopButton, this.onPlayStop);
9842
- this.playStopButton = require_t(import_ts_utils_lib20.Utils.Dom.getButton(btn), "Play/stop button required!");
9936
+ this.playStopButton = require_t(import_ts_utils_lib34.Utils.Dom.getButton(btn), "Play/stop button required!");
9843
9937
  this.playLabel = playLabel != null ? playLabel : "Play";
9844
9938
  this.stopLabel = stopLabel != null ? stopLabel : "Stop";
9845
9939
  _MPlaybackButtons.removeOnClickListeners(this.playStopButton, "all");
@@ -9854,42 +9948,40 @@ var _MPlaybackButtons = class _MPlaybackButtons {
9854
9948
  * @returns - This playback buttons class instance.
9855
9949
  */
9856
9950
  setPauseButton(btn, btnLabel) {
9857
- assertArg3(import_ts_utils_lib20.Utils.Is.isStringOrUndefined(btnLabel), "btnLabel", btnLabel);
9951
+ assertArg3(import_ts_utils_lib34.Guard.isStringOrUndefined(btnLabel), "btnLabel", btnLabel);
9858
9952
  _MPlaybackButtons.removeOnClickListeners(this.pauseButton, this.onPause);
9859
- this.pauseButton = require_t(import_ts_utils_lib20.Utils.Dom.getButton(btn), "Pause button required!");
9953
+ this.pauseButton = require_t(import_ts_utils_lib34.Utils.Dom.getButton(btn), "Pause button required!");
9860
9954
  this.pauseLabel = btnLabel != null ? btnLabel : "Pause";
9861
9955
  _MPlaybackButtons.removeOnClickListeners(this.pauseButton, "all");
9862
9956
  _MPlaybackButtons.addOnClickListener(this.pauseButton, this.onPause);
9863
9957
  this.updateButtons();
9864
9958
  return this;
9865
9959
  }
9866
- static removeOnClickListeners(btn, onClick) {
9867
- if (btn) {
9868
- let savedListeners = this.savedOnClickListeners.get(btn) || [];
9869
- let remainingListeners = [];
9870
- savedListeners.forEach((l) => {
9871
- if (onClick === l || onClick === "all") {
9872
- btn.removeEventListener("click", l);
9873
- } else {
9874
- remainingListeners.push(l);
9875
- }
9876
- });
9877
- this.savedOnClickListeners.set(btn, remainingListeners);
9878
- }
9960
+ static removeOnClickListeners(btn, onClickListener) {
9961
+ if (!btn) return;
9962
+ let curListeners = this.savedOnClickListeners.getOrDefault(btn, []);
9963
+ curListeners = curListeners.filter((listener) => {
9964
+ if (onClickListener === listener || onClickListener === "all") {
9965
+ btn.removeEventListener("click", listener);
9966
+ return false;
9967
+ } else {
9968
+ return true;
9969
+ }
9970
+ });
9971
+ this.savedOnClickListeners.set(btn, curListeners);
9879
9972
  }
9880
- static addOnClickListener(btn, onClick) {
9881
- assertArg3(import_ts_utils_lib20.Utils.Is.isFunction(onClick), "onClick", onClick);
9882
- btn.addEventListener("click", onClick);
9883
- let clickListeners = this.savedOnClickListeners.get(btn) || [];
9884
- this.savedOnClickListeners.set(btn, [...clickListeners, onClick]);
9973
+ static addOnClickListener(btn, onClickListener) {
9974
+ assertArg3(import_ts_utils_lib34.Guard.isFunction(onClickListener), "onClick", onClickListener);
9975
+ btn.addEventListener("click", onClickListener);
9976
+ this.savedOnClickListeners.getOrCreate(btn, []).push(onClickListener);
9885
9977
  }
9886
9978
  };
9887
- __publicField(_MPlaybackButtons, "savedOnClickListeners", /* @__PURE__ */ new Map());
9979
+ __publicField(_MPlaybackButtons, "savedOnClickListeners", new import_ts_utils_lib34.UniMap());
9888
9980
  var MPlaybackButtons = _MPlaybackButtons;
9889
9981
 
9890
9982
  // src/score/index.ts
9891
- var import_core23 = require("@tspro/web-music-score/core");
9892
- (0, import_core23.init)();
9983
+ var import_core22 = require("@tspro/web-music-score/core");
9984
+ (0, import_core22.init)();
9893
9985
  // Annotate the CommonJS export names for ESM import in node:
9894
9986
  0 && (module.exports = {
9895
9987
  Annotation,
@@ -9951,6 +10043,12 @@ var import_core23 = require("@tspro/web-music-score/core");
9951
10043
  VerticalPosition,
9952
10044
  getStringNumbers,
9953
10045
  getVerseNumbers,
9954
- getVoiceIds
10046
+ getVoiceIds,
10047
+ isStringNumber,
10048
+ isVerseNumber,
10049
+ isVoiceId,
10050
+ validateStringNumber,
10051
+ validateVerseNumber,
10052
+ validateVoiceId
9955
10053
  });
9956
10054
  //# sourceMappingURL=index.js.map