guidex 0.5.0 → 0.6.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 (86) hide show
  1. package/CHANGELOG.md +215 -0
  2. package/README.md +62 -16
  3. package/dist/lib/app/App.d.ts +1 -0
  4. package/dist/lib/app/AretinoControls.d.ts +35 -0
  5. package/dist/lib/app/CaretBand.d.ts +28 -0
  6. package/dist/lib/app/Developers.d.ts +13 -0
  7. package/dist/lib/app/EditorContext.d.ts +15 -0
  8. package/dist/lib/app/EditorTextarea.d.ts +18 -1
  9. package/dist/lib/app/EditorToolbar.d.ts +13 -0
  10. package/dist/lib/app/ExportSettings.d.ts +20 -1
  11. package/dist/lib/app/Footer.d.ts +1 -0
  12. package/dist/lib/app/GlyphChooser.d.ts +31 -0
  13. package/dist/lib/app/Inspector.d.ts +26 -0
  14. package/dist/lib/app/LiveScore.d.ts +31 -0
  15. package/dist/lib/app/Opening.d.ts +3 -0
  16. package/dist/lib/app/Reference.d.ts +28 -0
  17. package/dist/lib/app/RenderSettings.d.ts +2 -1
  18. package/dist/lib/app/ScriptViews.d.ts +8 -0
  19. package/dist/lib/app/SectionSize.d.ts +33 -0
  20. package/dist/lib/app/StaffSettings.d.ts +4 -0
  21. package/dist/lib/app/StaffedGlyph.d.ts +8 -0
  22. package/dist/lib/app/Tabs.d.ts +15 -0
  23. package/dist/lib/app/TakeItOut.d.ts +1 -0
  24. package/dist/lib/app/ThemeSwitch.d.ts +1 -0
  25. package/dist/lib/app/TopBar.d.ts +6 -0
  26. package/dist/lib/app/WidthControls.d.ts +21 -0
  27. package/dist/lib/app/aretinoCaret.d.ts +47 -0
  28. package/dist/lib/app/aretinoSource.d.ts +46 -0
  29. package/dist/lib/app/caretSync.d.ts +48 -0
  30. package/dist/lib/app/chantLibrary.d.ts +8 -4
  31. package/dist/lib/app/editorSnapshot.d.ts +11 -0
  32. package/dist/lib/app/editorState.d.ts +38 -5
  33. package/dist/lib/app/expandLink.d.ts +19 -0
  34. package/dist/lib/app/glyphData.d.ts +37 -0
  35. package/dist/lib/app/inCode.d.ts +4 -0
  36. package/dist/lib/app/insertAtCaret.d.ts +12 -0
  37. package/dist/lib/app/learn/Learn.d.ts +1 -0
  38. package/dist/lib/app/learn/LessonCard.d.ts +12 -0
  39. package/dist/lib/app/learn/lessons.d.ts +64 -0
  40. package/dist/lib/app/learn/narrowing.d.ts +24 -0
  41. package/dist/lib/app/learn/progress.d.ts +14 -0
  42. package/dist/lib/app/pageEvents.d.ts +14 -0
  43. package/dist/lib/app/previewHighlight.d.ts +44 -0
  44. package/dist/lib/app/samples.d.ts +9 -1
  45. package/dist/lib/app/scriptParts.d.ts +31 -0
  46. package/dist/lib/app/shareLink.d.ts +12 -2
  47. package/dist/lib/app/showcases/Showcases.d.ts +17 -0
  48. package/dist/lib/app/wordCopy.d.ts +4 -0
  49. package/dist/lib/aretino/fromAretino.d.ts +99 -0
  50. package/dist/lib/aretino/index.d.ts +38 -0
  51. package/dist/lib/aretino/index.js +1870 -0
  52. package/dist/lib/aretino/toAretino.d.ts +27 -0
  53. package/dist/lib/chantLayout-BRQ6FYND.js +1345 -0
  54. package/dist/lib/chantLayout.d.ts +101 -6
  55. package/dist/lib/chantMarkup-DX4K86Rv.js +993 -0
  56. package/dist/lib/drawnStaff.d.ts +39 -5
  57. package/dist/lib/editorStorage.d.ts +48 -6
  58. package/dist/lib/embed/core.d.ts +15 -1
  59. package/dist/lib/embed/index.js +1 -1
  60. package/dist/lib/embed/manual.d.ts +5 -4
  61. package/dist/lib/embed/manual.js +6 -4
  62. package/dist/lib/fonts/guidohu-staffless.woff2 +0 -0
  63. package/dist/lib/fonts/guidohu.ttf +0 -0
  64. package/dist/lib/glyphFamilies.d.ts +5 -1
  65. package/dist/lib/guidoRender.d.ts +30 -1
  66. package/dist/lib/guidoScriptTransforms.d.ts +2 -2
  67. package/dist/lib/guidoStyles-CvnACCsk.js +1466 -0
  68. package/dist/lib/guidoStyles.d.ts +23 -2
  69. package/dist/lib/react/GuidexScore.d.ts +10 -2
  70. package/dist/lib/react/index.js +14 -4
  71. package/dist/lib/{scoreImage-B2SGdROL.js → scoreImage-CKsQxHg5.js} +282 -1026
  72. package/dist/lib/theme.d.ts +13 -0
  73. package/dist/lib/word/index.d.ts +1 -1
  74. package/dist/lib/word/index.js +1 -1
  75. package/dist/lib/{wordChecker-CjYl2yof.js → wordChecker-BN_9dKAx.js} +133 -20
  76. package/dist/lib/wordChecker.d.ts +18 -1
  77. package/dist/lib/wordExport.d.ts +51 -3
  78. package/dist-embed/demo.html +2 -2
  79. package/dist-embed/fonts/guidohu-staffless.woff2 +0 -0
  80. package/dist-embed/fonts/guidohu.ttf +0 -0
  81. package/dist-embed/guidex-embed.min.js +1 -1
  82. package/package.json +10 -1
  83. package/dist/lib/app/ControlsRow.d.ts +0 -1
  84. package/dist/lib/app/SettingsMenu.d.ts +0 -1
  85. package/dist/lib/app/SettingsPanel.d.ts +0 -1
  86. package/dist/lib/chantLayout-BrCQUOhp.js +0 -2616
@@ -1 +1 @@
1
- var GuidexEmbed=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t={ð:{smallHead:`~`,modifyUp:`È`,cephalicus:`®`},ñ:{virga:`^`,smallHead:`¯`,modifyUp:`Ê`,modifyDown:`÷`,cephalicus:`−`,connectOneDown:`Ý`},0:{virga:`]`,smallHead:`‚`,modifyUp:`Ë`,modifyDown:`ø`,modifyNatural:`“`,cephalicus:`§`,connectOneDown:`Þ`},1:{virga:`q`,longa:`Ÿ`,smallHead:`ƒ`,modifyUp:`Ì`,modifyDown:`a`,modifyNatural:`”`,cephalicus:`ÿ`,connectOneDown:`Q`,connectTwoDown:`×`,connectThreeDown:`Ø`,smallPoint:`í`},2:{virga:`w`,longa:`¡`,smallHead:`„`,modifyUp:`Î`,modifyDown:`A`,modifyNatural:`•`,cephalicus:`"`,connectOneDown:`W`,connectTwoDown:`s`,connectThreeDown:`Ù`,connectFourDown:`½`},3:{virga:`e`,longa:`¢`,smallHead:`…`,modifyUp:`Ï`,modifyDown:`S`,modifyNatural:`–`,cephalicus:`+`,connectOneDown:`E`,connectTwoDown:`d`,connectThreeDown:`D`,connectFourDown:`°`,smallPoint:`y`},4:{virga:`r`,longa:`£`,smallHead:`†`,modifyUp:`Ð`,modifyDown:`Í`,modifyNatural:`—`,cephalicus:`!`,connectOneDown:`R`,connectTwoDown:`f`,connectThreeDown:`F`,connectFourDown:`±`},5:{virga:`t`,longa:`[`,smallHead:`‡`,modifyUp:`Ñ`,modifyDown:`Y`,modifyNatural:`˜`,cephalicus:`%`,connectOneDown:`T`,connectTwoDown:`g`,connectThreeDown:`G`,connectFourDown:`²`,smallPoint:`x`},6:{virga:`z`,longa:`¥`,smallHead:`ˆ`,modifyUp:`Ò`,modifyDown:`X`,modifyNatural:`™`,cephalicus:`/`,connectOneDown:`Z`,connectTwoDown:`h`,connectThreeDown:`H`,connectFourDown:`³`},7:{virga:`u`,longa:`¦`,smallHead:`‰`,modifyUp:`þ`,modifyDown:`C`,modifyNatural:`š`,cephalicus:`=`,connectOneDown:`U`,connectTwoDown:`j`,connectThreeDown:`J`,connectFourDown:`´`,smallPoint:`c`},8:{virga:`i`,longa:`©`,smallHead:`Š`,modifyUp:`ß`,modifyDown:`V`,modifyNatural:`›`,cephalicus:`(`,connectOneDown:`I`,connectTwoDown:`k`,connectThreeDown:`K`,connectFourDown:`μ`},9:{virga:`o`,longa:`ª`,smallHead:`‹`,modifyUp:`ò`,modifyDown:`B`,modifyNatural:`œ`,cephalicus:`)`,connectOneDown:`O`,connectTwoDown:`l`,connectThreeDown:`L`,connectFourDown:`·`,smallPoint:`v`},ö:{virga:`p`,longa:`«`,smallHead:`Œ`,modifyUp:`ô`,modifyDown:`N`,modifyNatural:`º`,cephalicus:`Ö`,connectOneDown:`P`,connectTwoDown:`é`,connectThreeDown:`É`,connectFourDown:`¾`},ü:{virga:`õ`,longa:`¬`,smallHead:`‘`,modifyUp:`ù`,modifyDown:`$`,modifyNatural:`»`,cephalicus:`Ü`,connectOneDown:`Õ`,connectTwoDown:`á`,connectThreeDown:`Á`,connectFourDown:`¸`,smallPoint:`b`},ó:{virga:`ú`,smallHead:`’`,modifyUp:`ý`,modifyDown:`m`,cephalicus:`Ó`,connectOneDown:`Ú`,connectTwoDown:`û`,connectThreeDown:`Û`,connectFourDown:`¹`}},n={ð:`a`,ñ:`b`,0:`c'`,1:`d'`,2:`e'`,3:`f'`,4:`g'`,5:`a'`,6:`b'`,7:`c''`,8:`d''`,9:`e''`,ö:`f''`,ü:`g''`,ó:`a''`};function r(e){return n[e]??n[l(e)?.base??``]}var i=new Map;for(let[e,n]of Object.entries(t))for(let t of Object.keys(n))i.set(n[t],{base:e,role:t});function a(e,n){return t[e]?.[n]}function o(e){return a(e,`longa`)}function s(e){return a(e,`smallHead`)}function c(e){return a(e,`modifyNatural`)}function l(e){let t=i.get(e);return t?{...t}:void 0}var u=[`modifyUp`,`modifyDown`,`modifyNatural`];function d(e){let t=i.get(e)?.role;return t!==void 0&&u.includes(t)}var f=new Map([[`Â`,`Ã`],[`Ä`,`Å`],[`Æ`,`Ç`]]);function p(e,t=0){let n=f.get(e[t]??``);if(n===void 0)return 0;let r=t+1;for(;r<e.length&&d(e[r]);)r++;if(r===t+1||e[r]!==n)return 0;for(r++;e[r]===`¨`||e[r]===`-`;)r++;return r-t}var m={">":{clef:`c`,line:1},"#":{clef:`c`,line:2},"&":{clef:`c`,line:3},"@":{clef:`c`,line:4},"{":{clef:`f`,line:3},"}":{clef:`f`,line:4},M:{clef:`g`,line:2},"<":{clef:`g`,line:2}};function h(e){return Object.hasOwn(m,e)}var g=[...`ðñ0123456789öüó`],_=`abcdefg`;function v(e,t=`M`){let n=g.indexOf(g.includes(e)?e:l(e)?.base??``),i=m[t];if(n<0||!i)return;let a=g.indexOf(`2`)+2*(i.line-1),o=_.indexOf(i.clef)-_.indexOf(r(g[a])[0]);return _[((_.indexOf(r(g[n])[0])+o)%7+7)%7]}var y=new Set(`,.:?'"+!%/=()ÖÜÓ;`.split(``));function b(e){let t=0;for(;t<e.length&&y.has(e[t]);)t++;t>0&&t<e.length&&(t=e[t]===`-`?t+1:0);let n=e.length;for(;n>t&&y.has(e[n-1]);)n--;return n<e.length&&n>t&&(n=e[n-1]===`-`?n-1:e.length),{leading:e.slice(0,t),core:e.slice(t,n),trailing:e.slice(n)}}var x=new Set([`*`,`†`]),S=new Set([`color`,`size`,`raise`,`font`]),ee={_:``,"*":``,"†":``,"∗":``},te=new Map(Object.entries(ee).map(([e,t])=>[t,e]));function ne(e){return e.replace(/\\(.)/gsu,(e,t)=>ee[t]??t)}function re(e){return e.replace(/[-]/g,e=>te.get(e))}function C(e){return[`__`,`_`].find(t=>e.length>=t.length*2+1&&e.startsWith(t)&&e.endsWith(t))}function w(e){let t=[],n=e,r=``;for(let e=/\*([^*]+)\*/.exec(n);e;e=/\*([^*]+)\*/.exec(n))r+=n.slice(0,e.index),r&&=(t.push({text:r,initial:!1}),``),t.push({text:e[1],initial:!0}),n=n.slice(e.index+e[0].length);return r+=n,r&&t.push({text:r,initial:!1}),t}function ie(e,t,n){let r=e=>x.has(e)?`marker`:n&&e===`+`?`plus`:void 0,i=[];for(let t of e){let e=r(t),n=i[i.length-1];n&&n.glyph===e?n.text+=t:i.push({text:t,glyph:e})}return i.map(e=>({text:e.text,marks:e.glyph?[...t,e.glyph]:[...t]}))}function T(e){if(e.length===0)return[];let t=ne(e);if(t===`**`)return[{text:`∗`,marks:[`star`]}];let n=C(t),r=n?t.slice(n.length,-n.length):t,i=n?[n===`__`?`liturgy`:`rubric`]:[];return w(r).flatMap(({text:e,initial:t})=>ie(re(e),t?[...i,`initial`]:i,n===`__`))}function ae(e){return re(ne(e).replace(/[_*†∗]/g,``))}function oe(e){let t=[],n=0;for(;;){let r=/^[A-Za-z][\w-]*/.exec(e.slice(n))?.[0];if(!r)return;if(n+=r.length,e[n]===`:`&&S.has(r)){let i=/^[^\s,:{}]+/.exec(e.slice(n+1))?.[0];if(!i)return;t.push(`${r}:${i}`),n+=1+i.length}else t.push(r);if(e[n]===`:`)return{marks:t,length:n+1};if(e[n]!==`,`)return;n+=1}}function se(e){let t=[],n=``,r=()=>{n&&t.push({type:`text`,written:n}),n=``};for(let i=0;i<e.length;i++){let a=e[i];if(a===`\\`&&i+1<e.length)n+=a+e[++i];else if(a===`{`){r();let n=oe(e.slice(i+1));t.push({type:`open`,marks:n?.marks}),n&&(i+=n.length)}else a===`}`?(r(),t.push({type:`close`})):n+=a}return r(),t}function E(e){let t=[],n=e.map(se),r=new Map,i=[],a=new Set;for(let[o,s]of n.entries())for(let n of s)if(n.type===`open`){n.marks||t.push({kind:`span`,text:e[o].trim(),message:`A "{" needs its marks and a colon, as in "{red:text}" (in "${e[o].trim()}")`});let a={marks:n.marks??[]};r.set(n,a),i.push(a)}else n.type===`close`&&!i.pop()&&(a.add(n),t.push({kind:`span`,text:e[o].trim(),message:`A "}" closes nothing (in "${e[o].trim()}")`}));for(let e of i)e.marks.length>0&&t.push({kind:`span`,text:e.marks.join(`,`),message:`The span "{${e.marks.join(`,`)}:" is never closed`}),e.marks=[];let o=[],s=[],c;for(let[t,i]of n.entries()){let n=o.length>0,l=[],u={bare:``,source:``,runs:[],text:``};for(let e of i)e.type===`open`?o.push(r.get(e)):e.type===`close`?a.has(e)||o.pop():l.push({marks:o.flatMap(e=>e.marks),written:e.written});u.bare=l.map(e=>e.written).join(``);let d=D(l);u.runs=d.flatMap(({marks:e,written:t})=>T(t).map(t=>({text:t.text,marks:[...e,...t.marks]}))),u.text=d.map(({written:e})=>ae(e)).join(``);let f=i.some(e=>a.has(e)||e.type===`open`&&r.get(e).marks.length===0),p=i.some(e=>e.type===`open`||e.type===`close`);u.source=n||o.length>0||f||p&&u.bare.trim()===``?d.map(({marks:e,written:t})=>e.length>0?`{${e.join(`,`)}:${t}}`:t).join(``):e[t].trim();let m=d.filter(e=>e.written.trim()!==``);if(m.length>0){if(c){let e=new Set(m[0].marks),t=c.marks.filter(t=>e.has(t));t.length>0&&(c.piece.hyphen=t)}c={piece:u,marks:m[m.length-1].marks}}s.push(u)}return{pieces:s,problems:t}}function D(e){let t=e.map(e=>({...e})),n=t[0],r=t[t.length-1];return n&&(n.written=n.written.trimStart()),r&&(r.written=r.written.trimEnd()),t.filter(e=>e.written!==``)}function O(e){return e.trim().startsWith(`@`)}function k(e){let[t,...n]=e;return t===`@`&&n.every(d)}function A(e){return!O(e)||k(e)}function j(e,t){for(let n of e)if(!d(n))throw Error(`"${n}" is not a key modifier glyph in "${t}"`);return e}function M(e){let t=e.trim();if(k(t))throw Error(`a clef group is only allowed at the start; write "(@clef ${t})" to change the clef`);let[,n,r=``]=t.match(/^@(\S*)(?: (.*))?$/)??[];switch(n){case`break`:if(r!==``)throw Error(`"@break" takes no argument: "${t}"`);return{kind:`break`};case`clef`:{let[e,...n]=r;if(e===void 0)throw Error(`"@clef" needs a clef group argument, e.g. "(@clef MX)"`);if(!h(e))throw Error(`"${e}" is not a clef glyph in "${t}"`);return{kind:`clef`,clef:e,key:j(n.join(``),t)}}case`key`:return{kind:`key`,key:j(r,t)};case`tight`:case`keep`:case`unit`:case`aid`:if(r!==``&&r!==`off`)throw Error(`"@${n}" takes only "off": "${t}"`);return{kind:n,on:r===``};default:throw Error(`Unknown statement "${t}"`)}}function N(e){switch(e.kind){case`break`:return`(@break)`;case`clef`:return`(@clef ${e.clef}${e.key})`;case`key`:return e.key===``?`(@key)`:`(@key ${e.key})`;case`tight`:case`keep`:case`unit`:case`aid`:return e.on?`(@${e.kind})`:`(@${e.kind} off)`}}function P(e){let t=e.match(/^@stanza(?:\s+([\s\S]*))?$/);return t?t[1]??``:void 0}var F=class{source;constructor(e,t={}){this.source=(t.transforms??[]).reduce((e,t)=>t.apply(e),e)}get clef(){let e=this.normalized.match(/^\s*\(([^)]*)\)/);if(!(!e||!A(e[1])))return e[1]}get tokens(){return this.parse().tokens}get stanzas(){return this.parse().stanzas}get tokenSpans(){return this.parse().spans}get spanProblems(){return this.parse().problems}parse(){let e=this.normalized,t=e.match(/^\s*\(([^)]*)\)/),n=t&&A(t[1])?t[0].length:0,r=[...e.slice(n).matchAll(/((?:[^()\\]|\\.)*)\(((?:[^)\\]|\\.)*)\)/g)],i=E(r.map(e=>e[1])),a,o=[],s=[],c=[];for(let[e,t]of r.entries()){let[,r,l]=t,u=i.pieces[e],d=u.bare,f=n+t.index,p=f+r.length+1,m={start:f+(r.length-r.trimStart().length),notesStart:p,notesEnd:p+l.length,end:p+l.length+1},h=O(l)?P(l.trim()):void 0;if(h!==void 0){if(d.trim()!==``)throw Error(`statement must not carry syllable text: "${z(d.trim())}"`);o.push(h);continue}if(o.length>0){if(d.trim()===``&&l===``)continue;throw Error(`"(@stanza …)" statements must stand at the end of the script`)}if(O(l)){let e=M(l);if(d.trim()!==``)throw Error(`statement must not carry syllable text: "${z(d.trim())}"`);s.push({...e,spaceBefore:/^\s/.test(d)}),c.push(m);continue}let g=d.trim();if(g===``&&l===``&&r.trim()!==``)continue;let _={kind:`syllable`,...L(g===`~`?I:u),role:`sung`,notes:z(l),spaceBefore:/^\s/.test(d)};if(g===`~`||g===``&&a===void 0&&_.notes!==``)_.empty=!0;else if(g===``&&_.notes!==``){if(a.notes===``)throw Error(`the group "(${_.notes})" has no syllable to hold it: "${a.text}" has no notes; write "~(${_.notes})" for an empty slot`);_.held=!0}a=_,s.push(_),c.push(m)}let l;for(let[e,t]of s.entries()){if(t.kind!==`syllable`)continue;if(t.held){t.wordEnd=l.wordEnd;continue}t.wordEnd=!0;let n=!1;for(let r=e+1;r<s.length;r++){let e=s[r];if(e.spaceBefore&&(n=!0),e.kind===`syllable`&&!e.held&&!e.empty){t.wordEnd=n;break}}l=t}return R(s),{tokens:s,stanzas:o,spans:c,problems:i.problems}}get syllables(){return this.tokens.filter(e=>e.kind===`syllable`).map(({text:e,notes:t,wordEnd:n,held:r,empty:i})=>({text:e,notes:t,wordEnd:n,...r?{held:r}:{},...i?{empty:i}:{}}))}get normalized(){let e=this.source;return(e.match(/(^|[^\\])\(/g)??[]).length>(e.match(/(^|[^\\])\)/g)??[]).length&&(e+=`)`),/(^|[^\\])\)$/.test(e)||(e+=`()`),e}get words(){let e=[],t;for(let n of this.tokens){if(n.kind!==`syllable`||n.held||n.empty)continue;t??={text:``,syllables:[]};let{text:r,source:i,runs:a,role:o,notes:s}=n;t.syllables.push({text:r,source:i,runs:a,role:o,notes:s}),t.text=t.syllables.map(e=>e.text).join(``),n.wordEnd&&(e.push(t),t=void 0)}return e}toString(){let e=this.tokens.map((e,t)=>{let n=t>0&&e.spaceBefore?` `:``;return e.kind===`syllable`?`${n}${e.empty?`~`:e.source}(${B(e.notes)})`:`${n}${N(e)}`}),t=this.stanzas.map(e=>`(@stanza ${e})`);return`${this.clef===void 0?``:`(${this.clef})`}${e.join(``)}${t.join(``)}`}},I={bare:``,source:``,runs:[],text:``};function L(e){let{text:t,source:n,runs:r,hyphen:i}=e;return{text:t,source:n,runs:r,...i?{hyphen:i}:{}}}var ce=[`liturgy`,`rubric`];function le(e){return/[^-¨]/.test(b(e).core)}function R(e){let t=0,n=`sung`,r=(e,t)=>e.runs.every(e=>e.marks.some(e=>t.includes(e)));for(let i of e)if(i.kind===`aid`&&(t=Math.max(0,t+(i.on?1:-1))),i.kind===`syllable`){if(i.held){i.role=n;continue}i.role=i.runs.length===0?!i.empty&&i.notes===``?`sign`:t>0?`aid`:`sung`:i.text===``||r(i,[`plus`])?`sign`:r(i,ce)&&!le(i.notes)?`label`:t>0?`aid`:`sung`,n=i.role}}function z(e){return e.replace(/\\(.)/g,`$1`)}function B(e){return e.replace(/\\/g,`\\\\`).replace(/[()]/g,e=>`\\${e}`)}var ue=`_…_`,de=`-=­`,V=`_*†∗{}`;function fe(e){let t=[],n=null,r=Array.from(e);for(let e=0;e<r.length;e++){let i=r[e],a=i===`\\`&&e+1<r.length;if(a&&(i=r[++e]),!a&&/\s/.test(i)){n=null;continue}n===null&&(n=[],t.push(n)),n.push({ch:i,escaped:a})}let i=[];for(let e of t){if(e.length===1&&!e[0].escaped&&e[0].ch===`~`){i.push({kind:`empty`});continue}let t=[``],n=[``];for(let{ch:r,escaped:i}of e){if(!i&&de.includes(r)){t.push(``),n.push(``);continue}let e=!i&&r===`~`?`\xA0`:r;t[t.length-1]+=e,n[n.length-1]+=i&&V.includes(r)?`\\${r}`:B(e)}let r=t.length-1;for(let[e,a]of t.entries()){if(a===``){e<r&&i.push({kind:`hold`});continue}let t=n[e];i.push({kind:`syllable`,text:a,wordEnd:e===r,...t===B(a)?{}:{source:t}})}}return pe(i)}function pe(e){let t=e.filter(e=>e.kind===`syllable`),n=t.map(e=>e.source??B(e.text));if(!n.some(e=>/[{}]/.test(e)))return e;let{pieces:r}=E(n);for(let[e,n]of t.entries())n.source=r[e].source;return e}function H(e){return e.kind===`syllable`&&e.role!==`label`&&e.role!==`sign`&&e.notes!==``&&b(e.notes).core!==``}function me(e){return typeof e==`string`?new F(e):e}function U(e){return me(e).tokens.filter(H).length}function he(e,t={}){return t.stanzas??me(e).stanzas}function W(e,t={}){return he(e,t).length+1}function G(e){return e.kind===`syllable`||e.kind===`hold`}function ge(e){return e.map(e=>e.empty?{kind:`empty`}:e.held?{kind:`hold`}:{kind:`syllable`,text:e.text,source:e.source,wordEnd:e.wordEnd})}function _e(e,t,n){let r=fe(e),i=[],a=[];for(let e=0;e<t;e++){let o=r[e];i.push(o??{kind:`missing`}),o===void 0&&a.push({stanza:n,slot:e+1,kind:`missing`,message:`Stanza ${n} has no syllable for slot ${e+1} of ${t}`})}for(let[e,i]of r.slice(t).entries()){let r=i.kind===`syllable`?i.text:i.kind===`hold`?`-`:`~`;a.push({stanza:n,slot:t+e+1,kind:`extra`,text:r,message:`Stanza ${n} has an extra syllable "${r}" past the last slot (${t})`})}return{fills:i,warnings:a}}function K(e,t){if(!Number.isInteger(e)||e<1||e>t)throw RangeError(`Stanza ${e} does not exist: the script has ${t} stanza${t===1?``:`s`}`)}function ve(e,t={}){let n=he(e,t),r=U(e);return t.stanza===void 0?n.flatMap((e,t)=>_e(e,r,t+2).warnings):(K(t.stanza,n.length+1),t.stanza===1?[]:_e(n[t.stanza-2],r,t.stanza).warnings)}function q(e){return Array.from(e,e=>{let t=s(e);if(t!==void 0)return t;let n=l(e);return n&&(n.role===`virga`||n.role===`longa`)?s(n.base)??e:e}).join(``)}function ye({text:e,source:t}){return t??(e===`~`?`\\~`:B(e))}function be(e,t,n){let r=new F(e),i=he(r,n);K(t,i.length+1);let a=n.rendered??[t];for(let e of a)K(e,i.length+1);let o=n.emptySlots??`normal`;if(t===1&&o===`normal`)return e;let s=r.tokens,c=s.filter(e=>H(e)),l=[ge(c),...i.map((e,t)=>_e(e,c.length,t+2).fills)],u=l[t-1],d=e=>o===`partial`?l.some(t=>G(t[e]))&&!l.every(t=>G(t[e])):o===`small`&&a.every(t=>!G(l[t-1][e]))&&l.some((t,n)=>!a.includes(n+1)&&G(t[e])),f=r.clef===void 0?``:`(${r.clef})`,p=!0,m=!1,h=!1,g=(e,t)=>{f+=(t&&!p?` `:``)+e,p=!1},_=0;for(let e of s){if(e.kind!==`syllable`){g(N(e),m),m=!1;continue}if(!H(e)){e.held?(g(`(${B(e.notes)})`,m),m=!1):(g(`${e.source}(${B(e.notes)})`,m||e.spaceBefore),m=e.wordEnd,h=e.notes!==``);continue}let t=u[_],n=B(d(_)?q(e.notes):e.notes);switch(_++,t.kind){case`syllable`:g(`${ye(t)}(${n})`,m),m=t.wordEnd;break;case`hold`:g(`${h?``:`~`}(${n})`,!1);break;case`empty`:g(`~(${n})`,!1);break;case`missing`:g(`${ue}(${n})`,!0),m=!0}h=!0}return f}function xe(e,t={}){return{name:`selectStanza`,apply:n=>be(n,e,t)}}function Se(e,t,n={}){return new F(typeof e==`string`?e:e.source,{transforms:[xe(t,n),...n.transforms??[]]})}function Ce(e,t,n={}){let r=W(e,n);if(t===`all`)return Array.from({length:r},(e,t)=>t+1);if(t.length===0)throw RangeError(`No stanza to stack: the list is empty`);for(let e of t)K(e,r);return[...t]}function we(e,t,n={}){let r=Ce(e,t,n);return r.map(t=>Se(e,t,{...n,rendered:r}))}var Te=[`ðñ0123456789öüó`,`^]qwertzuiopõú`,`ÝÞQWERTZUIOPÕÚ`,`×sdfghjkléáû`,`ØÙDFGHJKLÉÁÛ`,`÷øaASÍYXCVBN$m`,`ÈÊËÌÎÏÐÑÒþßòôùý`,`“”•–—˜™š›œº»`,`®−§ÿ"+!%/=()ÖÜÓ`,`Ÿ¡¢£[¥¦©ª«¬`,`~¯‚ƒ„…†‡ˆ‰Š‹Œ‘’`,`àâãäåæçèêëìîï`,`½°±²³´μ·¾¸¹`];function Ee(e,t,n){for(let r of Te){let i=r.indexOf(e);if(i===-1)continue;let a=i+t;if(a<0||a>=r.length){if(n===`null`)return`\0`;if(n===`error`)throw Error(`Transposing "${e}" by ${t} runs past the glyph range`);return r[Math.max(0,Math.min(r.length-1,a))]}return r[a]}}function De(e,t,n={}){if(t===0||O(e))return e;let r=n.overflow??`clamp`,i=``;for(let n=0;n<e.length;n++){let a=e[n],o=a===`\\`&&e[n+1]!==void 0,s=Ee(o?e[n+1]:a,t,r);if(s===void 0){i+=o?a+e[n+1]:a,o&&n++;continue}i+=`\\()`.includes(s)?`\\${s}`:s,o&&n++}return i}function Oe(e,t={}){let n=t.overflow??`clamp`;return{name:`transpose`,apply:t=>{if(e===0)return t;let r=t.match(/^\s*\(([^)]*)\)/),i=r?r[0].length:0;return t.slice(0,i)+t.slice(i).replace(/((?:[^()\\]|\\.)*)\(((?:[^)\\]|\\.)*)\)/g,(t,r,i)=>`${r}(${De(i,e,{overflow:n})})`)}}}var ke={chars:x,fontFamily:`'Times New Roman', Times, serif`},Ae={weight:`400`,scale:.7,raise:.2},je={BNS:{textFontStack:`'Book Antiqua', Georgia, serif`,notesFontStack:`'Guidohu'`,markerGlyphs:ke,verifiedFonts:[{family:`'Book Antiqua'`,weight:`400`},{family:`'Book Antiqua'`,weight:`700`},{family:`'Guidohu'`,weight:`400`},{family:`'Liturgy'`,weight:`700`}],marks:{liturgy:{fontFamily:`'Liturgy', serif`,weight:`700`,color:`var(--red)`},rubric:{uppercase:!0,scale:.7,color:`var(--red)`},initial:{weight:`700`,color:`var(--red)`,initial:!0},star:{fontFamily:ke.fontFamily,weight:`700`,scale:1,measureScale:.95,raise:.1,color:`var(--red)`},plus:Ae},padding:12},Vesperale:{textFontStack:`'Times New Roman', Times, serif`,notesFontStack:`'Guidohu'`,verifiedFonts:[{family:`'Times New Roman', Times, serif`,weight:`400`},{family:`'Times New Roman', Times, serif`,weight:`700`},{family:`'Guidohu'`,weight:`400`},{family:`'Liturgy'`,weight:`700`}],marks:{liturgy:{fontFamily:`'Liturgy', serif`,weight:`700`},rubric:{scale:.8,italic:!0},initial:{weight:`700`,initial:!0},star:{fontFamily:ke.fontFamily,weight:`700`,scale:1,measureScale:.95,raise:.2},plus:Ae},padding:12}},Me=new Map;function Ne(e){return Me.get(e)??je[e]}var Pe={red:`var(--red)`},Fe={liturgy:`'Liturgy', serif`,times:`'Times New Roman', Times, serif`},Ie=.75,Le=new Set([`liturgy`,`rubric`,`star`,`marker`,`plus`]);function Re(e){return e.filter(e=>Le.has(e)).pop()}function ze(e,t,n,r,i){let a=e=>r.colors?.[e]??Pe[e],o=t.indexOf(`:`),s=o<0?t:t.slice(0,o),c=o<0?``:t.slice(o+1),l=Number(c);switch(s){case`plain`:return{};case`red`:return{...e,color:Pe.red};case`b`:return{...e,weight:`700`};case`i`:return{...e,italic:!0};case`sc`:return{...e,smallCaps:!0};case`up`:return{...e,uppercase:!0};case`color`:{let t=a(c);return t?{...e,color:t}:void 0}case`size`:return l>0?{...e,scale:l,measureScale:void 0}:void 0;case`raise`:return Number.isFinite(l)&&c!==``?{...e,raise:l}:void 0;case`font`:{let t=r.fonts?.[c]??Fe[c];return t?{...e,fontFamily:t}:void 0}case`marker`:return r.markerGlyphs?.chars.has(n[0])?{...e,fontFamily:r.markerGlyphs.fontFamily}:e}let u=i?.[t]??r.marks[t];if(!u)return;let d=u.color&&a(u.color);return{...e,...u,...d?{color:d}:{}}}function Be(e,t,n,r){return t.reduce((t,i)=>ze(t,i,e,n,r)??t,{})}function Ve(e,t,n){return e.filter(e=>ze({},e,``,t,n)===void 0)}function He(e){let t=[];for(let n of e){let e=n.toUpperCase()!==n,r=t[t.length-1];r&&r.small===e?r.text+=n:t.push({text:n,small:e})}return t}function Ue(e,t,n,r){return e.flatMap(({text:e,marks:i})=>{let a=Be(e,i,t,r),o=n?{...a,weight:`700`}:a,s=Re(i);if(!o.smallCaps)return[{text:e,style:o,kind:s}];let c={...o,smallCaps:void 0};return He(e).map(e=>({text:e.text,kind:s,style:e.small?{...c,smallCaps:!0,uppercase:!0,scale:(c.scale??1)*Ie,measureScale:void 0}:c}))})}function We(e){return e.style.uppercase?e.text.toUpperCase():e.text}function Ge(e,t,n){return[e.italic?`italic`:`normal`,`normal`,e.weight??`400`,`${t*(e.measureScale??e.scale??1)}px`,e.fontFamily??n].join(` `)}function Ke(e,t){let n={};return e.fontFamily&&(n[`font-family`]=e.fontFamily),e.weight&&(n[`font-weight`]=e.weight),e.italic&&(n[`font-style`]=`italic`),e.scale!==void 0&&(n[`font-size`]=`${t*e.scale}px`),e.color&&(n.color=e.color),e.uppercase&&(n[`text-transform`]=`uppercase`),e.raise&&(n.position=`relative`,n.top=`${-t*e.raise}px`),n}function qe(e,t){return e.verifiedFonts.map(e=>`${e.weight} ${t}px ${e.family}`)}var Je=new Set([`+`,`.`,`/`,`R`,`V`]);function Ye(e,t={}){let n=typeof e==`string`?new F(e):e,r=Ne(t.style??`BNS`);if(!r)return n.spanProblems;let i=[...n.spanProblems],a=new Set;for(let e of n.tokens){if(e.kind!==`syllable`)continue;for(let n of Ve([...new Set(e.runs.flatMap(e=>e.marks))],r,t.marks))a.has(n)||(a.add(n),i.push({kind:`mark`,mark:n,text:e.source,message:`Unknown mark "${n}" (in "${e.source}")`}));let n=Ue(e.runs,r,!1,t.marks).filter(e=>e.style.fontFamily?.includes(`Liturgy`)&&e.kind!==`marker`).flatMap(e=>[...e.text]);for(let t of new Set(n))Je.has(t)||/\s/.test(t)||i.push({kind:`glyph`,char:t,text:e.source,message:`The Liturgy font has no "${t}" (in "${e.source}"); it has only + . / R V`})}return i}function Xe(e){let t=e.length===2&&d(e[0])?e[0]:``,n=e.slice(t.length);if(n.length!==1)return null;let r=l(n);if(r?.role===`longa`)return{sign:t,plain:r.base,glyph:n,written:`glyph`};let i=o(n);return i?{sign:t,plain:n,glyph:i,written:`plain`}:null}function Ze(e,t){let n=Xe(e);return!n||t===`written`?e:n.sign+(t===`recite`?n.glyph:n.plain)}function Qe(e,t){return t===`written`?Xe(e)?.written===`glyph`?`recite`:`plain`:t}function $e(e){let t=[],n=new Set;return(e[0]??[]).forEach((r,i)=>{if((r.kind===`clef`||r.kind===`key`)&&n.add(t.length),r.kind!==`syllable`)return;let a=e.some(e=>{let t=e[i];return t?.kind===`syllable`&&!t.held&&!t.empty});t.push({notes:r.notes,counted:a})}),{syllables:t,pitchBreaks:n}}function et(e,t){let n=Xe(e.notes);return n?n.written===`glyph`||t.plainRunsToRecitation:!1}function tt(e){let t=Xe(e);return t.sign+t.plain}function nt(e,t,n){let r=new Map,i=0;for(;i<e.length;){if(!et(e[i],n)){i++;continue}let a=tt(e[i].notes),o=i,s=0;for(;o<e.length&&et(e[o],n)&&tt(e[o].notes)===a&&(o===i||!t.has(o));)e[o].counted&&s++,o++;for(let e=i;e<o;e++)r.set(e,s>=3?`recite`:`written`);i=o}return r}function rt(e,t){return!t.twoSyllableRecitationsToPlain&&!t.plainRunsToRecitation?!1:e.some(e=>et(e,t))}function it(e,t,n,r){let i=[],a,o=``,s=-1;return e.forEach((e,c)=>{let l=t[c],u=n[c];if(!(et(e,r)&&l!==void 0&&u!==void 0&&Xe(l)!==null)){a=void 0;return}let d=tt(l);(!a||d!==o||u!==s)&&(a={members:[],count:0},i.push(a),o=d,s=u),a.members.push(c),e.counted&&a.count++}),i}function at(){return{decided:new Map,breakBefore:new Set,pending:null}}function ot(e,t){let n=new Map(e);for(let[e,r]of t.decided)n.set(e,r);return n}function st(e,t,n,r,i,a){if(i.pending){let{members:e,line:t}=i.pending;i.pending=null;let r=e.findIndex(e=>n[e]!==t);if(r>=0)return e.forEach((e,t)=>{t<r?i.decided.set(e,`written`):i.decided.delete(e)}),i.breakBefore.add(e[r]),!0}for(let o of it(e,t,n,a)){if(o.members.every(e=>i.decided.has(e)))continue;let t=o.count>=3?`recite`:o.count===2&&a.twoSyllableRecitationsToPlain?`plain`:`written`,s=o.members.some(n=>{let i=e[n].notes;return Qe(i,r.get(n)??`written`)!==Qe(i,t)});for(let e of o.members)i.decided.set(e,t);if(s){let e=o.members[0],t=n[e];return e>0&&(n[e-1]??-1)<t&&i.breakBefore.add(e),i.pending={members:o.members,line:t},!0}}return!1}var ct=new Set(`Ÿ¡¢£[¥¦©ª«¬`.split(``));function lt(e){return e.length===1&&ct.has(e)||e.length===2&&ut.has(e[0])&&ct.has(e[1])}var ut=new Set(`÷øaASÍYXCVBN$mÈÊËÌÎÏÐÑÒþßòôùý“”•–—˜™š›œº»`.split(``));function dt(e){let t=0;for(;;){let n=ut.has(e[t]??``)?1:p(e,t);if(n===0)return t;t+=n}}function ft(e){let{leading:t,core:n}=b(e),r=dt(n);return r===0?0:t.length+r}var pt=[`-`,`¨`];function mt(e){return`-`.repeat(Math.floor(e/3))+`¨`.repeat(e%3)}function ht(e,t,n=!0){let r=new Map;for(let i of e){if(!d(i))continue;let a=v(i,gt(t));if(n&&r.has(a))throw Error(`Key "${e}" alters the pitch ${a} twice`);r.set(a,l(i).role)}return r}function gt(e){return e!==void 0&&h(e)?e:`M`}function _t(e){if(y.has(e))return;if(a(e,`smallHead`)!==void 0)return e;let t=l(e);if(!(!t||t.role===`smallPoint`||d(e)))return t.base}function vt(e,t,n,r,i=[]){let o=``;for(let s of[e,...i]){let e=ft(s);for(let i=0;i<s.length;i++){let l=s[i],u=_t(l),f=u===void 0?void 0:v(u,gt(r)),p=f===void 0?void 0:n.get(f),m=i>0&&(d(s[i-1])||i===e);if(f!==void 0&&p!==t.get(f)&&!m){let e=p??`modifyNatural`,t=p?a(u,p):c(u);if(t===void 0)throw Error(`The note "${l}" has no ${e} glyph for the key change`);o.includes(t)||(o+=t)}}}let s=b(e).leading.length;return{notes:e.slice(0,s)+o+e.slice(s),inserted:[...o].map((e,t)=>s+t)}}function yt(e,t,n=0){return[...e].filter((e,r)=>!t.includes(r+n)).join(``)}var bt=null;function J(e,t){return bt||=document.createElement(`canvas`).getContext(`2d`),bt.font=t,bt.measureText(e).width}function xt(e,t){bt||=document.createElement(`canvas`).getContext(`2d`),bt.font=t;let n=bt.measureText(e);return{left:n.actualBoundingBoxLeft,right:n.actualBoundingBoxRight}}var St=[`all-but-last`,`none`,`all`,`longest`];function Ct(e){let t=typeof e==`string`||e instanceof F?[e]:e;if(t.length===0)throw Error(`Nothing to lay out: no script given`);let n=t.map(e=>(typeof e==`string`?new F(e):e).tokens),[r]=n;for(let[e,t]of n.entries())if(!(t.length===r.length&&t.every((e,t)=>{let n=r[t];return e.kind===n.kind&&(e.kind!==`syllable`||e.notes===n.notes)})))throw Error(`Stacked underlay ${e+1} does not share the first one's notes`);return n}function wt(e){return!!(e.held||e.empty)}async function Tt(e,t={}){let n={twoSyllableRecitationsToPlain:t.twoSyllableRecitationsToPlain??!0,plainRunsToRecitation:t.plainRunsToRecitation??!1},{syllables:r,pitchBreaks:i}=$e(Ct(e));if(!rt(r,n))return(await Ot(e,t,Dt)).result;let a=nt(r,i,n),o=at();for(let i=0;;i++){let s=ot(a,o),c=await Ot(e,t,{notes:Et(r.map(e=>e.notes),s),breakBefore:o.breakBefore});if(i>4*r.length+8||!st(r,c.placedNotes,c.sylLines,s,o,n))return c.result}}function Et(e,t){let n=new Map;for(let[r,i]of t){let t=Ze(e[r],i);t!==e[r]&&n.set(r,t)}return n}var Dt={notes:new Map,breakBefore:new Set};async function Ot(e,t,n){let r=new Set,i=new Set;for(;;){let a=await kt(e,t,r,n),o=a.splitRuns.filter(e=>!i.has(e.run));if(o.length===0)return a;let s=o.reduce((e,t)=>t.run<e.run?t:e);r.has(s.run)||s.atLineStart?(i.add(s.run),s.nested?r.add(s.run):r.delete(s.run)):r.add(s.run)}}async function kt(e,t,n,r=Dt){let{style:i=`BNS`,marks:a,bold:o=!1,textPx:s=18,notesPx:c=s*2,maxWidthPx:l=1/0,junctionDashes:u=3,staffFill:f=`all-but-last`,staffFillSnapPx:p=0}=t;if(!St.includes(f))throw Error(`Unknown staffFill: "${f}"`);if(!(p>=0&&Number.isFinite(p)))throw Error(`staffFillSnapPx must be zero or more: ${p}`);let m=Math.round(u*3);if(!(u>=1&&Math.abs(u-m/3)<=.01))throw Error(`junctionDashes must be at least 1, in steps of a third: ${u}`);let h=mt(m),g=mt(Math.max(3,m-3)),_=Ct(e),v=typeof e==`string`||e instanceof F?typeof e==`string`?new F(e):e:typeof e[0]==`string`?new F(e[0]):e[0],x=Ne(i);if(!x)throw Error(`Unknown style set: "${i}"`);for(let e of qe(x,s)){try{await document.fonts.load(e)}catch{}if(!document.fonts.check(e))throw Error(`Font could not be loaded: ${e} (style "${i}")`)}let S=`400 ${c}px ${x.notesFontStack}`,ee=x.textFontStack,te=Ge({weight:o?`700`:`400`},s,ee),ne=e=>Ue(e,x,o,a),re=e=>e.reduce((e,t)=>e+J(We(t),Ge(t.style,s,ee)),0),C=J(`-`,S),w=J(`-`,te),ie=e=>{if(!e)return{width:w};let t=ne([{text:`-`,marks:e}]);return{parts:t,width:re(t)}},T=v.clef?.[0],ae=[...(v.clef??``).slice(1)].filter(d).join(``),oe=v.clef,se=e=>e?`${e}-`:``,E=ht(ae,T,!1),D=E,O=_.map(e=>{let t=e.filter(e=>e.kind===`syllable`);return{syls:t,lastTextSyl:t.reduce((e,t,n)=>wt(t)?e:n,-1),cursor:0,pending:[],prevWordEnd:void 0,hyphen:{width:w}}}),k=[],A,j,M,N=!1,P,I=!1,L=()=>{A&&(O.forEach((e,t)=>{A.texts[t].textCursor=e.cursor}),A.notesEnd=A.notesParts.length?J(A.clefPrefix+A.notesParts.join(``),S):0);let e=O.map(()=>({segments:[],textCursor:0,lastWordEnd:null}));A={clefPrefix:se(oe),notesParts:[],segments:e[0].segments,textCursor:0,notesEnd:0,staffEnd:0,lastWordEnd:null,texts:e},k.push(A),j=A.clefPrefix;for(let e of O)e.cursor=0;M=!1,I=!1,N=!1,D=E,P&&P.inserted.length>0&&(P.notes=yt(P.notes,P.inserted),P.inserted=[],P.first&&(V[P.i]=P.notes))};L();let ce=_[0],le=e=>O.every(t=>t.syls[e].held),R=[],z=0,B,ue=0,de=!1;for(let e of ce)if(e.kind!==`syllable`)R.push(e),B=void 0,(e.kind===`tight`||e.kind===`unit`)&&(ue=Math.max(0,ue+(e.on?1:-1)),ue===0&&(de=!1));else{let t=z++,n={kind:`syl`,syl:e,i:t,notes:r.notes.get(t)??e.notes,inserted:[],first:!0,lastSeg:!0,heldRun:[],signedByRun:!1,tightJoin:de};e.notes!==``&&(de=ue>0),le(n.i)&&B?(B.heldRun.push(e.notes),n.signedByRun=!0):B=n,R.push(n)}let V=[],fe=(e,t,n)=>{let r=ft(e);for(let i=e.length-1;i>=r&&i>0;i--){if(!pt.includes(e[i]))continue;let r=i+1;for(;r<e.length&&y.has(e[r]);)r++;if(!(r>=e.length)&&n(e.slice(0,r))<=t)return i}return-1},pe=(e,t)=>{let n=e.notes,r=t+1;for(;r<n.length&&y.has(n[r]);)r++;e.notes=n.slice(0,t)+n.slice(t+1,r);let i=yt(n.slice(r),e.inserted,r);return e.inserted=e.inserted.filter(e=>e<t),i},H=(e,t,n)=>{e.lastSeg=!1,R.splice(t+1,0,{kind:`syl`,syl:e.syl,i:e.i,notes:n,inserted:[],first:!1,lastSeg:!0,heldRun:[],signedByRun:!1,tightJoin:!1}),U=!0},me=e=>{O.forEach((t,n)=>{for(;t.pending.length>0;){let r=t.pending[0];if(t.cursor>0&&t.cursor+r.textWidth+(r.wordEnd?0:r.hyphen.width)>l){L();continue}t.pending.shift();let i=A.texts[n];i.segments.push({kind:`syl`,parts:r.sylParts,textStart:t.cursor,textWidth:r.textWidth,contentWidth:0,contentStart:0,extraDashes:0,tight:!1,noNotes:!0,...e&&t.pending.length===0?{trailing:!0}:{}}),t.cursor+=r.textWidth,r.spaceWidth>0&&(i.segments.push({kind:`word-space`,width:r.spaceWidth}),t.cursor+=r.spaceWidth),i.lastWordEnd=r.wordEnd,i.hyphen=r.hyphen,t.hyphen=r.hyphen,i.textCursor=t.cursor}})},U=!1,he=0,W=[],G=[],ge=()=>{let e=W.pop();e&&k.length-1>e.line&&G.push(e)},_e=[],K=-1,ve=()=>{K>=0&&(_e[K]=k.length-1),K=-1},q=0;for(;q<R.length;){ve();let e=R[q];if(e.kind===`break`){(A.texts.some(e=>e.segments.length>0)||O.some(e=>e.pending.length>0))&&(me(!1),U=!0),q++;continue}if(e.kind===`tight`||e.kind===`aid`){q++;continue}if(e.kind===`keep`||e.kind===`unit`){if(!e.on)ge();else{let e=A.texts.some(e=>e.segments.length>0)||O.some(e=>e.pending.length>0);n.has(he)&&e&&(me(!1),U=!0),W.length>0&&(W[W.length-1].nested=!0),W.push({run:he++,line:U?k.length:k.length-1,atLineStart:!e||U,nested:!1})}q++;continue}if(e.kind===`clef`||e.kind===`key`){if(e.kind===`clef`&&(T=e.clef),ae=e.key,oe=(T??``)+ae,E=ht(ae,T),!U){if(A.notesParts.length===0)A.clefPrefix=se(oe),j=A.clefPrefix,D=E;else if(e.kind===`clef`){let e=(M?g:h)+oe+`-`;J(j+e,S)>l?U=!0:(A.notesParts.push(e),j+=e,D=E,N=!0,M=!1,I=!1)}}q++;continue}let t=e.syl,i=e.i;if(e.first&&(K=i),e.first&&r.breakBefore.has(i)&&(A.texts.some(e=>e.segments.length>0)||O.some(e=>e.pending.length>0))&&(me(!1),U=!0),U&&=(L(),!1),P=e,D!==E&&!e.signedByRun){let t=vt(e.notes,D,E,T,e.first?e.heldRun:[]);e.notes=t.notes,e.inserted=t.inserted}e.first&&(V[i]=e.signedByRun&&D!==E?vt(e.notes,D,E,T).notes:e.notes);let a=O.map(t=>{let n=t.syls[i],r=e.lastSeg&&i>=t.lastTextSyl,a=ne(e.first?n.runs:[]);return{t,own:n,sylParts:a,textWidth:re(a),spaceWidth:!r&&n.wordEnd?J(` `,te):0,pendingTotal:t.pending.reduce((e,t)=>e+t.textWidth+t.spaceWidth,0)}}),o=lt(e.notes);if(t.empty&&e.notes.length===0){q++;continue}if(e.notes.length===0){for(let e of a)e.own.empty||e.t.pending.push({sylParts:e.sylParts,textWidth:e.textWidth,spaceWidth:e.spaceWidth,wordEnd:e.own.wordEnd,hyphen:ie(e.own.hyphen)});q++;continue}if(e.first&&e.lastSeg&&!t.empty&&t.runs.length===0&&b(e.notes).core===``){let e=j[j.length-1],n=e&&e!==`-`&&!M&&!t.notes.startsWith(`-`)?`-`:``;A.notesParts.push(n+t.notes),j+=n+t.notes,M=!0,I=!1;for(let e of a)e.t.prevWordEnd=e.own.wordEnd;q++;continue}let s=(e,t)=>{e.own.held?(t&&(A.texts[O.indexOf(e.t)].lastWordEnd=!0),e.t.prevWordEnd=e.own.wordEnd):e.t.prevWordEnd===void 0&&(e.t.prevWordEnd=!0)};if(e.first&&a.every(e=>wt(e.own))){let t=le(i),n=lt(e.notes);if(t&&n&&V[i-1]===V[i]&&A.notesParts.length>0&&!N){I=!0,q++;continue}let r=b(e.notes),o=()=>A.notesParts.length===0||N?``:t?M?`--`:`-`:M||e.tightJoin||dt(r.core)>0?g:h,c=o();A.notesParts.length>0&&J(j+c+e.notes,S)>l&&(L(),c=o());let u=A.notesParts.length===0;if(u&&J(j+e.notes,S)>l){let t=fe(e.notes,l,e=>J(j+e,S));if(t>=0&&t+1<e.notes.length){let n=pe(e,t);H(e,q,n),r=b(e.notes)}}A.notesParts.push(c+e.notes),j+=c+e.notes;for(let e of a)s(e,u);N=!1,e.lastSeg&&(M=r.trailing.length>0,I=n),q++;continue}let c=e.first?a.filter(e=>!wt(e.own)):a,u=V[i-1]!==e.notes,d=c.every(e=>e.t.cursor===0||e.t.cursor+e.pendingTotal+e.textWidth+(e.own.wordEnd?0:ie(e.own.hyphen).width)<=l);if(o&&!u&&A.notesParts.length>0&&!d&&L(),!e.first){for(;!(J(j+e.notes,S)<=l);){let t=fe(e.notes,l,e=>J(j+e,S));if(t<0||t+1>=e.notes.length)break;let n=pe(e,t);H(e,q,n)}let t=b(e.notes);A.notesParts.push(e.notes),j+=e.notes,e.lastSeg&&(M=t.trailing.length>0);for(let[e,t]of a.entries())A.texts[e].lastWordEnd=!0,t.t.prevWordEnd=t.own.wordEnd;e.lastSeg||(U=!0),q++;continue}let f=b(e.notes),p=A.notesParts.length===0||N?``:M||e.tightJoin||dt(f.core)>0?g:h;if(I){let e=/-*$/.exec(j)[0].length;p=o&&!u||e>/^-*/.exec(p)[0].length?``:p.slice(e)}let m=(e=0)=>{let t=dt(f.core);t===f.core.length&&(t=0);let n=f.core.slice(t),r=J(n,S),i=J(j+p+`-`.repeat(e)+f.leading+f.core.slice(0,t),S),a=xt(n,S),s=-a.left,c=(a.right-a.left)/2;return{contentWidth:r,contentStart:i,textStartOf:e=>r>=e||o?i+s:i+c-e/2}},_=m(),v={notes:e.notes,inserted:e.inserted,lastSeg:e.lastSeg,forceBreak:U,items:R.length},y=()=>{for(;;){let t=J(j+p+e.notes,S)>l,n=c.some(e=>_.textStartOf(e.textWidth)+e.textWidth+(e.own.wordEnd?0:ie(e.own.hyphen).width)>l);if(!t&&!n)break;if(t){let t=fe(e.notes,l,e=>J(j+p+e,S));if(t>=0&&t+1<e.notes.length){let n=pe(e,t);H(e,q,n),f=b(e.notes),_=m();break}}if(A.notesParts.length===0&&O.every(e=>e.cursor===0)){if(t){let t=fe(e.notes,l,e=>J(j+e,S));if(t>=0&&t+1<e.notes.length){let n=pe(e,t);e.notes=e.notes.slice(0,t),H(e,q,n),f=b(e.notes),_=m()}}break}L(),p=``,f=b(e.notes),_=m()}};y();let x=e=>{let{t,textWidth:n}=e,{contentWidth:r}=_,i=A.notesParts.length>0&&!t.prevWordEnd&&e.pendingTotal===0,a=t.cursor+t.hyphen.width,o=t.cursor+e.pendingTotal+(I&&i?t.hyphen.width:0),s=_.textStartOf(n),c=_.contentStart,l=0,u=!1;if(!I&&i&&s<a&&(n>r||s<t.cursor)){u=!0,s=t.cursor;let e=r>=n?s:s+(n-r)/2;return e>c&&(l=Math.round((e-c)/C)),{textStart:s,contentStart:c,pads:l,tight:u,floor:t.cursor,minStart:a}}if(s<o){let e=r>=n?o:o+(n-r)/2;if(e>c){l=Math.max(0,Math.floor((e-c)/C));let t=m(l);for(;t.textStartOf(n)<o;)l++,t=m(l);s=t.textStartOf(n),c=t.contentStart}}return{textStart:s,contentStart:c,pads:l,tight:u,floor:o,minStart:a}},ee=o&&!u&&A.notesParts.length>0&&!N,w,F=0;if(ee){p=``,w=c.map(e=>{let t=e.t.cursor+e.pendingTotal;return{textStart:t,contentStart:_.contentStart,pads:0,tight:A.notesParts.length>0&&!e.t.prevWordEnd&&e.pendingTotal===0,floor:t,minStart:t}});let t=Math.max(...c.map((e,t)=>w[t].textStart+e.textWidth+e.spaceWidth))-J(j,S),n=l-J(j+p,S),r=t>0?Math.min(Math.ceil(t/C),Math.max(0,Math.floor(n/C))):0;e.notes=`-`.repeat(r),e.inserted=[],f=b(e.notes)}else{let t=()=>{if(w=c.map(x),F=Math.max(0,...w.map(e=>e.pads)),w.some(e=>e.pads<F)){let e=m(F);w=w.map((t,n)=>{if(t.pads===F)return t;let r=Math.max(e.textStartOf(c[n].textWidth),t.floor);return{...t,textStart:r,contentStart:e.contentStart,pads:F,tight:t.tight&&r<t.minStart}})}};if(t(),A.notesParts.length>0&&(J(j+p+`-`.repeat(F)+e.notes,S)>l||c.some((e,t)=>Math.max(w[t].textStart,e.t.cursor+e.pendingTotal)+e.textWidth+(e.own.wordEnd?0:ie(e.own.hyphen).width)>l))){let n=R.length>v.items;n&&(R.splice(q+1,R.length-v.items),e.notes=v.notes,e.inserted=v.inserted,e.lastSeg=v.lastSeg,U=v.forceBreak),L(),p=``,f=b(e.notes),_=m(),n&&y(),t()}}let ce=p+`-`.repeat(F)+e.notes,z=A.notesParts.length===0;c.forEach((e,t)=>{let{t:n,sylParts:r,textWidth:i,spaceWidth:a,pendingTotal:o}=e,s=A.texts[O.indexOf(n)],c=w[t],l=c.textStart;o>0&&l<n.cursor+o&&(l=n.cursor+o);let u=Math.max(0,l-o-n.cursor);if(z)s.segments.push({kind:`gap`,role:`lead-in`,width:u,endPx:l-o,textStartPx:l});else if(n.prevWordEnd)s.segments.push({kind:`gap`,role:`word-gap`,width:u,endPx:l-o,textStartPx:l});else if(!(o===0&&c.tight)&&o===0){let e=Math.max(0,(u-n.hyphen.width)/2);s.segments.push({kind:`connector`,pad:e,gapWidth:u,dashWidth:n.hyphen.width,...n.hyphen.parts?{parts:n.hyphen.parts}:{},dashStartPx:n.cursor+e,nextAnchorPx:l})}let d=l-o;for(let e of n.pending)s.segments.push({kind:`syl`,parts:e.sylParts,textStart:d,textWidth:e.textWidth,contentWidth:0,contentStart:0,extraDashes:0,tight:!1,noNotes:!0}),d+=e.textWidth,e.spaceWidth>0&&(s.segments.push({kind:`word-space`,width:e.spaceWidth}),d+=e.spaceWidth);n.pending=[],s.segments.push({kind:`syl`,parts:r,textStart:l,textWidth:i,contentWidth:_.contentWidth,contentStart:c.contentStart,extraDashes:F,tight:c.tight,noNotes:!1}),a>0&&s.segments.push({kind:`word-space`,width:a}),n.cursor=l+i+a,s.lastWordEnd=e.own.wordEnd,n.prevWordEnd=e.own.wordEnd,n.hyphen=ie(e.own.hyphen),s.hyphen=n.hyphen});for(let e of a)c.includes(e)||s(e,z);j+=ce,A.notesParts.push(ce),N=!1,e.lastSeg&&(M=f.trailing.length>0,I=o),e.lastSeg||(U=!0),q++}for(ve(),me(!0);W.length>0;)ge();O.forEach((e,t)=>{A.texts[t].textCursor=e.cursor}),A.notesEnd=A.notesParts.length?J(A.clefPrefix+A.notesParts.join(``),S):0,k.forEach((e,t)=>{if(t!==k.length-1)for(let t of e.texts){if(t.lastWordEnd!==!1)continue;let n=t.hyphen??{width:w},r=e.notesEnd>t.textCursor?Math.max(0,(e.notesEnd-t.textCursor-n.width)/2):0;t.segments.push({kind:`line-end-dash`,pad:r,dashWidth:n.width,...n.parts?{parts:n.parts}:{},dashStartPx:t.textCursor+r,trailEndPx:e.notesEnd,textEndPx:t.textCursor})}});for(let e of k)e.textCursor=e.texts[0].textCursor,e.lastWordEnd=e.texts[0].lastWordEnd;let ye=x.padding??0,be=l+ye,xe=J(`*`,S),Se=f===`all`&&l===1/0?`longest`:f,Ce=Se===`all`||Se===`longest`,we=Math.max(...k.map(e=>Math.max(e.notesEnd,...e.texts.map(e=>e.textCursor)))),Te=Se===`none`||l===1/0&&!Ce?null:Se===`longest`&&l-we>p?we:l;return k.forEach((e,t)=>{let n=t===k.length-1;if(e.staffEnd=e.notesEnd,n&&(!Ce||e.notesParts.length===0))return;if(Te===null){e.breakMarkerLeftPx=ye;return}let r=Te+ye,i=J(e.clefPrefix+e.notesParts.join(``),S);for(;n?i+C<=r:i+C<=r-xe&&i+C<Te;)e.notesParts.push(`-`),i+=C;if(n){let t=J(`¨`,S);for(;i+t<=r;)e.notesParts.push(`¨`),i+=t}e.staffEnd=i,n||(e.breakMarkerLeftPx=r-i-xe)}),{result:{lines:k,clefPrefix:k[0].clefPrefix,styleSet:x,styleName:i,textPx:s,notesPx:c,bold:o,maxWidthPx:l,starTarget:be,starWidth:xe},splitRuns:G,placedNotes:V,sylLines:_e}}var At=1e3,jt=[[-8,7],[193,208],[392,407],[593,608],[793,808]],Mt={" ":500,"!":74,'"':74,"#":372,$:252,"%":74,"&":372,"'":74,"(":74,")":74,"*":222,"+":74,",":144,"-":222,".":310,"/":74,0:222,1:222,2:222,3:222,4:222,5:222,6:222,7:222,8:222,9:222,":":114,";":222,"<":772,"=":74,">":372,"?":222,"@":372,A:252,B:252,C:252,D:15,E:15,F:15,G:15,H:15,I:15,J:15,K:15,L:15,M:772,N:252,O:15,P:15,Q:15,R:15,S:252,T:15,U:15,V:252,W:15,X:252,Y:252,Z:15,"[":491,"\\":0,"]":222,"^":222,_:773,"`":158,a:252,b:158,c:158,d:15,e:222,f:15,g:15,h:15,i:222,j:15,k:15,l:15,m:252,n:158,o:222,p:222,q:222,r:222,s:15,t:222,u:222,v:158,w:222,x:158,y:158,z:222,"{":723,"}":723,"~":143,"¡":491,"¢":491,"£":491,"¥":491,"¦":491,"§":74,"¨":69,"©":491,ª:491,"«":491,"¬":491,"­":74,"®":74,"¯":143,"°":15,"±":15,"²":15,"³":15,"´":15,µ:15,"·":15,"¸":15,"¹":15,º:252,"»":252,"¼":74,"½":15,"¾":15,"¿":222,À:222,Á:15,Â:222,Ã:222,Ä:222,Å:222,Æ:222,Ç:222,È:252,É:15,Ê:252,Ë:252,Ì:252,Í:252,Î:252,Ï:252,Ð:252,Ñ:252,Ò:252,Ó:74,Ô:15,Õ:15,Ö:74,"×":15,Ø:15,Ù:15,Ú:15,Û:15,Ü:74,Ý:15,Þ:15,ß:252,à:222,á:15,â:222,ã:222,ä:222,å:222,æ:222,ç:222,è:222,é:15,ê:222,ë:222,ì:222,í:158,î:222,ï:222,ð:222,ñ:222,ò:252,ó:222,ô:252,õ:222,ö:222,"÷":252,ø:252,ù:252,ú:222,û:15,ü:222,ý:252,þ:252,ÿ:74,Œ:143,œ:252,Š:143,š:252,Ÿ:491,ƒ:143,ˆ:143,ˉ:143,"˜":252,μ:15,"‐":222,"–":252,"—":252,"‘":143,"’":143,"‚":143,"“":252,"”":252,"„":143,"†":143,"‡":143,"•":252,"…":143,"‰":143,"‹":143,"›":252,"™":252,"−":74,"∙":15},Nt={"!":[[0,0,131],[1,-35.4,131],[2,0,131],[3,0,131],[4,0,131]],'"':[[0,-35.3,131],[1,0,131],[2,0,131],[3,0,131],[4,0,131]],"#":[[0,3,404],[1,3,404],[2,3,404],[3,3,404],[4,3,404]],$:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],"%":[[0,0,131],[1,0,131],[2,0,131],[3,0,131],[4,0,131]],"&":[[0,3,404],[1,3,404],[2,3,404],[3,3,404],[4,3,404]],"'":[[0,0,131],[1,0,131],[2,0,131],[3,0,131],[4,0,131]],"(":[[0,0,131],[1,0,131],[2,0,131],[3,-35.4,131],[4,0,131]],")":[[0,0,131],[1,0,131],[2,0,131],[3,0,131],[4,0,131]],"*":[[0,-1110,223],[1,-1110,223],[2,-1110,223],[3,-1110,223],[4,-1110,223]],"+":[[0,0,131],[1,0,131],[2,0,131],[3,0,131],[4,0,131]],",":[[0,-30,169],[1,-30,169],[2,-30,169],[3,-30,169],[4,-30,169]],"-":[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],".":[[0,-61,310],[1,-61,310],[2,-61,310],[3,-61,310],[4,-61,310]],"/":[[0,0,131],[1,0,131],[2,-35.3,131],[3,0,131],[4,0,131]],0:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],1:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],2:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],3:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],4:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],5:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],6:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],7:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],8:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],9:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],":":[[0,-60,171],[1,-60,171],[2,-60,171],[3,-60,171],[4,-60,171]],";":[[0,-72,270],[1,-72,270],[2,-72,270],[3,-72,270],[4,-72,270]],"<":[[0,0,841],[1,0,841],[2,0,841],[3,0,841],[4,0,841]],"=":[[0,0,131],[1,0,131],[2,0,131],[3,0,131],[4,0,131]],">":[[0,3,404],[1,3,404],[2,3,404],[3,3,404],[4,3,404]],"?":[[0,-70,222],[1,-70,222],[2,-70,222],[3,-70,222],[4,-70,222]],"@":[[0,3,404],[1,3,404],[2,3,404],[3,3,404],[4,3,404]],A:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],B:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],C:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],D:[[0,-7.1,81],[1,0,81],[2,0,81],[3,0,81],[4,0,81]],E:[[0,0,81],[1,0,81],[2,0,81],[3,0,81],[4,0,81]],F:[[0,0,81],[1,-8.6,81],[2,0,81],[3,0,81],[4,0,81]],G:[[0,0,81],[1,-7.1,81],[2,0,81],[3,0,81],[4,0,81]],H:[[0,0,81],[1,0,81],[2,-8.6,81],[3,0,81],[4,0,81]],I:[[0,0,81],[1,0,81],[2,0,81],[3,-9.1,81],[4,0,81]],J:[[0,0,81],[1,0,81],[2,-7.1,81],[3,0,81],[4,0,81]],K:[[0,0,81],[1,0,81],[2,0,81],[3,-8.6,81],[4,0,81]],L:[[0,0,81],[1,0,81],[2,0,81],[3,-7.1,81],[4,0,81]],M:[[0,0,841],[1,0,841],[2,0,841],[3,0,841],[4,0,841]],N:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],O:[[0,0,81],[1,0,81],[2,0,81],[3,0,81],[4,0,81]],P:[[0,0,81],[1,0,81],[2,0,81],[3,0,81],[4,-9.1,81]],Q:[[0,0,81],[1,0,81],[2,0,81],[3,0,81],[4,0,81]],R:[[0,0,81],[1,-9.1,81],[2,0,81],[3,0,81],[4,0,81]],S:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],T:[[0,0,81],[1,0,81],[2,0,81],[3,0,81],[4,0,81]],U:[[0,0,81],[1,0,81],[2,0,81],[3,0,81],[4,0,81]],V:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],W:[[0,-9.1,81],[1,0,81],[2,0,81],[3,0,81],[4,0,81]],X:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],Y:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],Z:[[0,0,81],[1,0,81],[2,-9.1,81],[3,0,81],[4,0,81]],"[":[[0,0,571],[1,0,571],[2,0,571],[3,0,571],[4,0,571]],"]":[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],"^":[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],_:[[0,0,801],[1,0,801],[2,0,801],[3,0,801],[4,0,801]],"`":[[0,0,221],[1,0,221],[2,0,221],[3,0,221],[4,0,221]],a:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],b:[[0,0,221],[1,0,221],[2,0,221],[3,0,221],[4,0,221]],c:[[0,0,221],[1,0,221],[2,0,221],[3,0,221],[4,0,221]],d:[[0,-3.7,81],[1,0,81],[2,0,81],[3,0,81],[4,0,81]],e:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],f:[[0,0,81],[1,-9,81],[2,0,81],[3,0,81],[4,0,81]],g:[[0,0,81],[1,-3.8,81],[2,0,81],[3,0,81],[4,0,81]],h:[[0,0,81],[1,0,81],[2,-9,81],[3,0,81],[4,0,81]],i:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],j:[[0,0,81],[1,0,81],[2,-3.7,81],[3,0,81],[4,0,81]],k:[[0,0,81],[1,0,81],[2,0,81],[3,-9,81],[4,0,81]],l:[[0,0,81],[1,0,81],[2,0,81],[3,-3.8,81],[4,0,81]],m:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],n:[[0,0,221],[1,0,221],[2,0,221],[3,0,221],[4,0,221]],o:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],p:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],q:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],r:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],s:[[0,-9,81],[1,0,81],[2,0,81],[3,0,81],[4,0,81]],t:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],u:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],v:[[0,0,221],[1,0,221],[2,0,221],[3,0,221],[4,0,221]],w:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],x:[[0,0,221],[1,0,221],[2,0,221],[3,0,221],[4,0,221]],y:[[0,0,221],[1,0,221],[2,0,221],[3,0,221],[4,0,221]],z:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],"{":[[0,0,801],[1,0,801],[2,0,801],[3,0,801],[4,0,801]],"}":[[0,0,801],[1,0,801],[2,0,801],[3,0,801],[4,0,801]],"~":[[0,0,201],[1,0,201],[2,0,201],[3,0,201],[4,0,201]],"¡":[[0,0,571],[1,0,571],[2,0,571],[3,0,571],[4,0,571]],"¢":[[0,0,571],[1,0,571],[2,0,571],[3,0,571],[4,0,571]],"£":[[0,0,571],[1,0,571],[2,0,571],[3,0,571],[4,0,571]],"¥":[[0,0,571],[1,0,571],[2,0,571],[3,0,571],[4,0,571]],"¦":[[0,0,571],[1,0,571],[2,0,571],[3,0,571],[4,0,571]],"§":[[0,0,131],[1,0,131],[2,0,131],[3,0,131],[4,0,131]],"¨":[[0,0,111],[1,0,111],[2,0,111],[3,0,111],[4,0,111]],"©":[[0,0,571],[1,0,571],[2,0,571],[3,0,571],[4,0,571]],ª:[[0,0,571],[1,0,571],[2,0,571],[3,0,571],[4,0,571]],"«":[[0,0,571],[1,0,571],[2,0,571],[3,0,571],[4,0,571]],"¬":[[0,0,571],[1,0,571],[2,0,571],[3,0,571],[4,0,571]],"­":[[0,0,131],[1,0,131],[2,0,131],[3,0,131],[4,0,131]],"®":[[0,0,131],[1,0,131],[2,0,131],[3,0,131],[4,0,131]],"¯":[[0,0,201],[1,0,201],[2,0,201],[3,0,201],[4,0,201]],"°":[[0,-8.8,81],[1,0,81],[2,0,81],[3,0,81],[4,0,81]],"±":[[0,-2.4,81],[1,-9.1,81],[2,0,81],[3,0,81],[4,0,81]],"²":[[0,0,81],[1,-8.9,81],[2,0,81],[3,0,81],[4,0,81]],"³":[[0,0,81],[1,-2.5,81],[2,-9.2,81],[3,0,81],[4,0,81]],"´":[[0,0,81],[1,0,81],[2,-8.8,81],[3,0,81],[4,0,81]],µ:[[0,0,81],[1,0,81],[2,-2.5,81],[3,-9.1,81],[4,0,81]],"·":[[0,0,81],[1,0,81],[2,0,81],[3,-8.8,81],[4,0,81]],"¸":[[0,0,81],[1,0,81],[2,0,81],[3,0,81],[4,-8.8,81]],"¹":[[0,0,81],[1,0,81],[2,0,81],[3,0,81],[4,-2.5,81]],º:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],"»":[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],"¼":[[0,-35.3,131],[1,0,131],[2,0,131],[3,0,131],[4,0,131]],"½":[[0,-9.2,81],[1,0,81],[2,0,81],[3,0,81],[4,0,81]],"¾":[[0,0,81],[1,0,81],[2,0,81],[3,-2.5,81],[4,-9.1,81]],"¿":[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],À:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],Á:[[0,0,81],[1,0,81],[2,0,81],[3,0,81],[4,-7.1,81]],Â:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],Ã:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],Ä:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],Å:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],Æ:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],Ç:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],È:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],É:[[0,0,81],[1,0,81],[2,0,81],[3,0,81],[4,-8.6,81]],Ê:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],Ë:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],Ì:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],Í:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],Î:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],Ï:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],Ð:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],Ñ:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],Ò:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],Ó:[[0,0,131],[1,0,131],[2,0,131],[3,0,131],[4,0,131]],Ô:[[0,0,81],[1,0,81],[2,0,81],[3,0,81],[4,0,81]],Õ:[[0,0,81],[1,0,81],[2,0,81],[3,0,81],[4,0,81]],Ö:[[0,0,131],[1,0,131],[2,0,131],[3,0,131],[4,-35.4,131]],"×":[[0,0,81],[1,0,81],[2,0,81],[3,0,81],[4,0,81]],Ø:[[0,0,81],[1,0,81],[2,0,81],[3,0,81],[4,0,81]],Ù:[[0,-8.6,81],[1,0,81],[2,0,81],[3,0,81],[4,0,81]],Ú:[[0,0,81],[1,0,81],[2,0,81],[3,0,81],[4,0,81]],Û:[[0,0,81],[1,0,81],[2,0,81],[3,0,81],[4,0,81]],Ü:[[0,0,131],[1,0,131],[2,0,131],[3,0,131],[4,0,131]],Ý:[[0,0,81],[1,0,81],[2,0,81],[3,0,81],[4,0,81]],Þ:[[0,0,81],[1,0,81],[2,0,81],[3,0,81],[4,0,81]],ß:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],à:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],á:[[0,0,81],[1,0,81],[2,0,81],[3,0,81],[4,-3.8,81]],â:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],ã:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],ä:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],å:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],æ:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],ç:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],è:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],é:[[0,0,81],[1,0,81],[2,0,81],[3,0,81],[4,-9,81]],ê:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],ë:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],ì:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],í:[[0,0,221],[1,0,221],[2,0,221],[3,0,221],[4,0,221]],î:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],ï:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],ð:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],ñ:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],ò:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],ó:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],ô:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],õ:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],ö:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],"÷":[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],ø:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],ù:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],ú:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],û:[[0,0,81],[1,0,81],[2,0,81],[3,0,81],[4,0,81]],ü:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],ý:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],þ:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],ÿ:[[0,0,131],[1,0,131],[2,0,131],[3,0,131],[4,0,131]],Œ:[[0,0,201],[1,0,201],[2,0,201],[3,0,201],[4,0,201]],œ:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],Š:[[0,0,201],[1,0,201],[2,0,201],[3,0,201],[4,0,201]],š:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],Ÿ:[[0,0,571],[1,0,571],[2,0,571],[3,0,571],[4,0,571]],ƒ:[[0,0,201],[1,0,201],[2,0,201],[3,0,201],[4,0,201]],ˆ:[[0,0,201],[1,0,201],[2,0,201],[3,0,201],[4,0,201]],ˉ:[[0,0,201],[1,0,201],[2,0,201],[3,0,201],[4,0,201]],"˜":[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],μ:[[0,0,81],[1,0,81],[2,-2.5,81],[3,-9.1,81],[4,0,81]],"‐":[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],"–":[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],"—":[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],"‘":[[0,0,201],[1,0,201],[2,0,201],[3,0,201],[4,0,201]],"’":[[0,0,201],[1,0,201],[2,0,201],[3,0,201],[4,0,201]],"‚":[[0,0,201],[1,0,201],[2,0,201],[3,0,201],[4,0,201]],"“":[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],"”":[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],"„":[[0,0,201],[1,0,201],[2,0,201],[3,0,201],[4,0,201]],"†":[[0,0,201],[1,0,201],[2,0,201],[3,0,201],[4,0,201]],"‡":[[0,0,201],[1,0,201],[2,0,201],[3,0,201],[4,0,201]],"•":[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],"…":[[0,0,201],[1,0,201],[2,0,201],[3,0,201],[4,0,201]],"‰":[[0,0,201],[1,0,201],[2,0,201],[3,0,201],[4,0,201]],"‹":[[0,0,201],[1,0,201],[2,0,201],[3,0,201],[4,0,201]],"›":[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],"™":[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],"−":[[0,0,131],[1,0,131],[2,0,131],[3,0,131],[4,0,131]],"∙":[[0,0,81],[1,0,81],[2,0,81],[3,-8.8,81],[4,0,81]]},Pt=`'Guidohu Staffless'`,Y=jt.length,Ft={connectOneDown:1,connectTwoDown:2,connectThreeDown:3,connectFourDown:4};function It(e){let t=g.indexOf(e);if(t>=0)return[t-4];let n=l(e);if(!n)return[];let r=g.indexOf(n.base)-4,i=Ft[n.role];return i?[r,r-i]:[r]}function Lt(e,t=Y){let n=(Y-1)*2,r=Math.min(Y,Math.max(1,Math.round(t)));if(r===Y)return{lo:0,hi:Y-1};let i=1/0,a=-1/0,o=(e,t)=>{i=Math.min(i,Math.max(0,Math.min(n,e))),a=Math.max(a,Math.max(0,Math.min(n,t)))};for(let t of e)for(let e of t.clefPrefix+t.notesParts.join(``)){let t=m[e];if(t){o((t.line-1)*2,(t.line-1)*2);continue}for(let t of It(e))t%2==0?o(t,t):o(t+1,t-1)}let s=(r-1)*2;if(a===-1/0)return{lo:0,hi:r-1};let c=Math.max(0,a-s);return c<=Math.min(i,n-s)?{lo:c/2,hi:(c+s)/2}:{lo:Math.min(i,a)/2,hi:Math.max(i,a)/2}}function Rt(e,t,n){let r=v(g[e*2+4],t);return r&&n.staffPitchColors?.[r]||n.staffLineColors?.[e]||n.staffColor||void 0}function zt(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:1}function Bt(e,t,n){let r=m[t]?m[t].line-1:-1;return zt(n.staffWeight)*zt(n.staffLineWeights?.[e])*(e===r?zt(n.staffClefLineWeight):1)}function Vt(e){return e===void 0?``:typeof e==`string`?e:`${e.light}|${e.dark??``}`}function Ht(e,t,n,r={},i){let a=t/At,o=[],s=0,c=`M`,l=(e,t)=>{for(let[i,s,l]of Nt[e]??[])i<n.lo||i>n.hi||o.push({line:i,left:t+s*a,right:t+l*a,color:Rt(i,c,r),weight:Bt(i,c,r)})};for(let t of e)m[t]&&(c=t),l(t,s),s+=(Mt[t]??0)*a;i!==void 0&&l(`*`,s+i);let u=[];for(let e=n.lo;e<=n.hi;e++){let t=o.filter(t=>t.line===e).sort((e,t)=>e.left-t.left);for(let n of t){let t=u[u.length-1];if(t&&t.line===e&&n.left<=t.right+.5){if(Vt(n.color)===Vt(t.color)&&n.weight===t.weight){t.right=Math.max(t.right,n.right);continue}if(n.right<=t.right)continue;t.right=Math.min(t.right,n.left),t.right<=t.left&&u.pop()}u.push({...n})}}let{start:d,end:f}=r.staffOverflow??{};if(Number.isFinite(d)||Number.isFinite(f))for(let e=n.lo;e<=n.hi;e++){let t=u.filter(t=>t.line===e),n=t[0],r=t[t.length-1];n&&Number.isFinite(d)&&(n.left=Math.min(n.left,d)),r&&Number.isFinite(f)&&(r.right=Math.max(r.right,f))}return u}function Ut(e){let t=document.createElement(`span`);t.className=`guidex-staff`,t.setAttribute(`aria-hidden`,`true`),t.style.cssText=`position:relative;display:inline-block;width:0;height:0;vertical-align:baseline;user-select:none;pointer-events:none`;for(let n of e){let[e,r]=jt[n.line],i=document.createElement(`span`);i.className=`guidex-staff-line`,i.dataset.line=String(n.line+1),n.weight!==1&&(i.dataset.weight=String(n.weight));let a=(r-e)*n.weight;i.style.position=`absolute`,i.style.zIndex=`-1`,i.style.left=`${n.left}px`,i.style.width=`${n.right-n.left}px`,i.style.bottom=`${((e+r)/2-a/2)/At}em`,i.style.height=`${a/At}em`;let o=n.color;if(o!==void 0){let e=typeof o==`string`?o:o.light,t=typeof o==`string`?o:o.dark??o.light;i.style.setProperty(`--guidex-staff-light`,e),i.style.setProperty(`--guidex-staff-dark`,t)}t.appendChild(i)}return t}function Wt(e){let t=typeof devicePixelRatio==`number`&&devicePixelRatio>0?devicePixelRatio:1;for(let n of e.querySelectorAll(`.guidex-staff`)){if(!n.isConnected)continue;let e=n.getBoundingClientRect().bottom,r=parseFloat(getComputedStyle(n).fontSize);if(r)for(let i of n.querySelectorAll(`.guidex-staff-line`)){let[n,a]=jt[Number(i.dataset.line)-1],o=Number(i.dataset.weight??1)||1,s=Math.max(1,Math.round((a-n)*o/At*r*t))/t,c=e-(n+a)/2/At*r,l=Math.round((c-s/2)*t)/t;i.style.bottom=`auto`,i.style.top=`${l-e}px`,i.style.height=`${s}px`}}}function Gt(e){return typeof CSS>`u`||typeof CSS.supports!=`function`||CSS.supports(`color`,e)}function Kt(e,t=`staff color`){let n=e?.trim();if(!n)return;let r=n.split(`|`).map(e=>e.trim()),i=r.find(e=>e!==``&&!Gt(e));if(r.length>2||i!==void 0||!r[0]){console.warn(`[guidex] ignoring invalid ${t} "${n}"`);return}return r.length===2&&r[1]?{light:r[0],dark:r[1]}:r[0]}function qt(e){if(e?.trim())return e.split(`;`).slice(0,Y).map((e,t)=>Kt(e,`staff line ${t+1} color`))}function Jt(e){if(!e?.trim())return;let t={};for(let n of e.split(`;`)){if(!n.trim())continue;let e=/^\s*([a-g])\s*:(.*)$/i.exec(n),r=e?Kt(e[2],`staff ${e[1].toLowerCase()} line color`):void 0;e||console.warn(`[guidex] ignoring invalid staff pitch color "${n.trim()}"`),e&&r!==void 0&&(t[e[1].toLowerCase()]=r)}return t}function Yt(e,t=`staff weight`){let n=e?.trim();if(!n)return;let r=Number(n);if(Number.isFinite(r)&&r>0)return r;console.warn(`[guidex] ignoring invalid ${t} "${n}"`)}function Xt(e){if(e?.trim())return e.split(`;`).slice(0,Y).map((e,t)=>Yt(e,`staff line ${t+1} weight`))}var Zt=class e{script;constructor(e){let t=e=>typeof e==`string`?new F(e):e;this.script=typeof e==`string`||e instanceof F?t(e):e.map(t)}async render(t,n={}){let{debug:r=!1}=n,i=await Tt(this.script,n),a=n.staff===`drawn`,{lines:o,styleSet:s,styleName:c,textPx:l,notesPx:u,bold:d,starWidth:f}=i,p;a&&(await e.verifyStaffless(u),p={range:Lt(o,n.staffLines),options:n,family:`${Pt}, ${s.notesFontStack}`}),t.style.fontSize=`${l}px`,t.style.fontFamily=s.textFontStack,t.dataset.style=c,p?(t.dataset.staff=`drawn`,t.dataset.staffLines=`${p.range.hi-p.range.lo+1}`):(delete t.dataset.staff,delete t.dataset.staffLines),t.replaceChildren(...o.flatMap(t=>[e.notesLine(t,u,f,r,p),...t.texts.map(t=>e.textLine(t,l,d,r))])),p&&n.staffSnap!==!1&&t.isConnected&&Wt(t)}static async verifyStaffless(e){let t=`400 ${e}px ${Pt}`;try{await document.fonts.load(t)}catch{}if(!document.fonts.check(t))throw Error(`Font could not be loaded: ${t} (drawn staff)`)}static notesLine(e,t,n,r,i){let a=document.createElement(`div`);a.className=`guido`,a.style.fontSize=`${t}px`;let o=e.clefPrefix+e.notesParts.join(``);if(a.textContent=o,i&&(a.style.fontFamily=i.family,a.style.isolation=`isolate`,a.prepend(Ut(Ht(o,t,i.range,i.options,e.breakMarkerLeftPx)))),e.breakMarkerLeftPx!==void 0){let t=document.createElement(`span`);t.className=`guido-break`,t.textContent=`*`,t.style.position=`relative`,t.style.left=`${e.breakMarkerLeftPx}px`,r&&(t.title=`line break at ${(e.staffEnd+e.breakMarkerLeftPx+n).toFixed(1)}px (staff filled to ${e.staffEnd.toFixed(1)}px)`),a.appendChild(t)}return a}static textLine(t,n,r,i){let a=document.createElement(`p`);r&&(a.style.fontWeight=`700`);for(let r of t.segments)switch(r.kind){case`gap`:{let t=e.spacer(r.width);i&&(t.title=`${r.role===`lead-in`?`lead-in`:`word gap`} ${r.width.toFixed(1)}px → text ${r.textStartPx.toFixed(1)}`),a.appendChild(t);break}case`connector`:{let t=e.spacer(r.pad),o=e.dashSpan(r.parts,n),s=e.spacer(r.pad);i&&(t.title=`lead pad ${r.pad.toFixed(1)}px (gap ${r.gapWidth.toFixed(1)} − dash ${r.dashWidth.toFixed(1)}, halved)`,o.title=`dash ${r.dashWidth.toFixed(1)}px`,s.title=`trail pad ${r.pad.toFixed(1)}px`),a.append(t,o,s);break}case`syl`:{let t=e.sylSpan(r.parts,n);if(i){if(r.noNotes)t.title=`no notes, text w ${r.textWidth.toFixed(1)}, ${r.trailing?`end of score`:`before the next syllable with notes`}`;else{let e=(r.textWidth-r.contentWidth)/2,n=r.textStart-r.contentStart;t.title=[`text w ${r.textWidth.toFixed(1)}`,`notes w ${r.contentWidth.toFixed(1)}`,r.extraDashes?`+${r.extraDashes} pad dash(es)`:null,`text start ${r.textStart.toFixed(1)}`,`notes start ${r.contentStart.toFixed(1)}`,`theoDiff: ${e.toFixed(1)}`,`cursDiff: ${n.toFixed(1)}`].filter(Boolean).join(`, `)}}a.appendChild(t);break}case`word-space`:{let e=document.createElement(`span`);e.className=`word-space`,e.textContent=` `,i&&(e.title=`word space ${r.width.toFixed(1)}px`),a.appendChild(e);break}case`line-end-dash`:{let t=e.spacer(r.pad),o=e.dashSpan(r.parts,n),s=e.spacer(r.pad);i&&(t.title=`lead pad ${r.pad.toFixed(1)}px → line-end dash (text end ${r.textEndPx.toFixed(1)}, notes end ${r.trailEndPx.toFixed(1)})`,o.title=`dash ${r.dashWidth.toFixed(1)}px (line end)`,s.title=`trail pad ${r.pad.toFixed(1)}px`),a.append(t,o,s);break}}return a}static dashSpan(e,t){let n=document.createElement(`span`);n.className=`dash`,n.textContent=`-`;let r=e?.[0]?.style;if(r)for(let[e,i]of Object.entries(Ke(r,t)))n.style.setProperty(e,i);return n}static sylSpan(e,t){let n=document.createElement(`span`);return n.className=`syl`,e.forEach(e=>{let r=document.createElement(`span`);r.textContent=e.text;for(let[n,i]of Object.entries(Ke(e.style,t)))r.style.setProperty(n,i);let i=[...e.kind?[e.kind]:[],...e.style.initial?[`initial`]:[]].join(` `);i&&(r.className=i),n.appendChild(r)}),n}static spacer(e){let t=document.createElement(`span`);return t.className=`spacer`,t.style.display=`inline-block`,t.style.width=`${e}px`,t}},Qt={name:`guidex`,version:`0.5.0`,description:`Guidex — render plainchant scores from a compact GuidoScript notation, as a web app and an embeddable runtime`,type:`module`,workspaces:[`examples/*`],main:`./dist/lib/embed/manual.js`,types:`./dist/lib/embed/manual.d.ts`,exports:{".":{types:`./dist/lib/embed/manual.d.ts`,default:`./dist/lib/embed/manual.js`},"./embed":{types:`./dist/lib/embed/index.d.ts`,default:`./dist/lib/embed/index.js`},"./guidex.css":{types:`./dist/lib/guidex.css.d.ts`,default:`./dist/lib/guidex.css`},"./fonts/*":`./dist/lib/fonts/*`,"./react":{types:`./dist/lib/react/index.d.ts`,default:`./dist/lib/react/index.js`},"./word":{types:`./dist/lib/word/index.d.ts`,default:`./dist/lib/word/index.js`}},files:[`dist-embed`,`dist/lib`,`CHANGELOG.md`],peerDependencies:{react:`>=18`},peerDependenciesMeta:{react:{optional:!0}},publishConfig:{access:`public`},scripts:{dev:`vite --host`,build:`tsc && vite build`,"build:embed":`vite build --config vite.embed.config.ts`,"build:lib":`vite build --config vite.lib.config.ts`,preview:`vite preview`,test:`vitest run`,lint:`eslint .`},keywords:[`plainchant`,`gregorian`,`guido`,`score`,`notation`,`liturgy`],repository:{type:`git`,url:`git+https://github.com/BrownieMaar/guidex.git`},bugs:{url:`https://github.com/BrownieMaar/guidex/issues`},homepage:`https://github.com/BrownieMaar/guidex#readme`,devDependencies:{"@eslint/js":`^10.0.1`,"@testing-library/dom":`^10.4.2`,"@testing-library/react":`^16.3.3`,"@testing-library/user-event":`^14.6.7`,"@types/react":`^19.3.0`,"@types/react-dom":`^19.3.0`,"@vitejs/plugin-react":`^6.1.1`,eslint:`^10.10.0`,jsdom:`^29.1.1`,react:`^19.3.0`,"react-dom":`^19.3.0`,typescript:`~6.0.2`,"typescript-eslint":`^8.70.0`,vite:`^8.2.2`,"vite-plugin-dts":`^5.1.1`,vitest:`^4.1.11`}}.version,$t=`.guidex-script, .guido-script`,X={maxWidth:`auto`,style:`BNS`,marks:void 0,bold:!1,textPx:18,junctionDashes:3,staffFill:`all-but-last`,staffFillSnapPx:0,twoSyllableRecitationsToPlain:!0,plainRunsToRecitation:!1,transpose:0,stanza:1,stack:void 0,emptySlots:`normal`,stanzas:void 0,debug:!1,staff:`font`,staffLines:5,staffColor:void 0,staffLineColors:void 0,staffPitchColors:void 0,staffWeight:void 0,staffLineWeights:void 0,staffClefLineWeight:void 0,staffOverflow:void 0,staffSnap:!0},Z={},en=new WeakMap,Q=new WeakMap,tn=new WeakMap;function nn(e){if(e!==void 0){if(e===``||e===`true`)return!0;if(e===`false`)return!1}}function $(e){if(e===void 0)return;let t=Number(e);return Number.isFinite(t)?t:void 0}function rn(e,t){if(/^auto$/i.test(e.trim()))return`auto`;let n=Number(e);return n>0?n:(console.warn(`[guidex] ignoring invalid data-max-width "${e}"`),t)}var an=new WeakMap;function on(e){if(e!==void 0){if(e===`normal`||e===`small`||e===`partial`)return e;console.warn(`[guidex] ignoring invalid data-empty-slots "${e}"`)}}function sn(e){if(e!==void 0){if(e===`all-but-last`||e===`none`||e===`all`||e===`longest`)return e;console.warn(`[guidex] ignoring invalid data-staff-fill "${e}"`)}}function cn(e){if(e!==void 0){if(e===`font`||e===`drawn`)return e;console.warn(`[guidex] ignoring invalid data-staff "${e}"`)}}function ln(e){if(e===void 0)return;if(/^\s*all\s*$/i.test(e))return`all`;let t=e.split(`,`).map(e=>Number(e.trim()));if(e.trim()!==``&&t.every(e=>Number.isInteger(e)&&e>0))return t;console.warn(`[guidex] ignoring invalid data-stack "${e}"`)}function un(e){let t=e.dataset,n=an.get(e)??{},r=t.maxWidth===void 0?n.maxWidth??Z.maxWidth??X.maxWidth:rn(t.maxWidth,n.maxWidth??Z.maxWidth??X.maxWidth);return{marks:n.marks??Z.marks,maxWidth:r,style:t.style??n.style??Z.style??X.style,bold:nn(t.bold)??n.bold??Z.bold??X.bold,textPx:$(t.textPx)??n.textPx??Z.textPx??X.textPx,junctionDashes:$(t.junctionDashes)??n.junctionDashes??Z.junctionDashes??X.junctionDashes,staffFill:sn(t.staffFill)??n.staffFill??Z.staffFill??X.staffFill,staffFillSnapPx:$(t.staffFillSnap)??n.staffFillSnapPx??Z.staffFillSnapPx??X.staffFillSnapPx,twoSyllableRecitationsToPlain:nn(t.twoSyllableRecitationsToPlain)??n.twoSyllableRecitationsToPlain??Z.twoSyllableRecitationsToPlain??X.twoSyllableRecitationsToPlain,plainRunsToRecitation:nn(t.plainRunsToRecitation)??n.plainRunsToRecitation??Z.plainRunsToRecitation??X.plainRunsToRecitation,transpose:$(t.transpose)??n.transpose??Z.transpose??X.transpose,stanza:$(t.stanza)??n.stanza??Z.stanza??X.stanza,stack:ln(t.stack)??n.stack??Z.stack??X.stack,emptySlots:on(t.emptySlots)??n.emptySlots??Z.emptySlots??X.emptySlots,stanzas:n.stanzas??X.stanzas,debug:nn(t.debug)??n.debug??Z.debug??X.debug,staff:cn(t.staff)??n.staff??Z.staff??X.staff,staffLines:$(t.staffLines)??n.staffLines??Z.staffLines??X.staffLines,staffColor:Kt(t.staffColor,`data-staff-color`)??n.staffColor??Z.staffColor,staffLineColors:qt(t.staffLineColors)??n.staffLineColors??Z.staffLineColors,staffPitchColors:Jt(t.staffPitchColors)??n.staffPitchColors??Z.staffPitchColors,staffWeight:Yt(t.staffWeight,`data-staff-weight`)??n.staffWeight??Z.staffWeight,staffLineWeights:Xt(t.staffLineWeights)??n.staffLineWeights??Z.staffLineWeights,staffClefLineWeight:Yt(t.staffClefLineWeight,`data-staff-clef-line-weight`)??n.staffClefLineWeight??Z.staffClefLineWeight,staffOverflow:t.staffOverflowStart!==void 0||t.staffOverflowEnd!==void 0?{start:$(t.staffOverflowStart),end:$(t.staffOverflowEnd)}:n.staffOverflow??Z.staffOverflow,staffSnap:nn(t.staffSnap)??n.staffSnap??Z.staffSnap??X.staffSnap}}function dn(e){let t=e.querySelector(`:scope > .guidex-render`);return t?.removeAttribute(`data-fixed-width`),t?.clientWidth||e.clientWidth||e.parentElement?.clientWidth||0}function fn(e,t,n){if(typeof t==`number`)return t;let r=dn(e);if(r<=0)return 1/0;let i=r-(Ne(n)?.padding??0);return i>0?i:r}function pn(e){for(let t of e.childNodes)if(t.nodeType===Node.TEXT_NODE&&t.nodeValue?.trim())return t.nodeValue.trim();return en.get(e)??``}function mn(e){let t=e.querySelector(`:scope > .guidex-render`);if(t)return t;let n=document.createElement(`div`);return n.className=`guidex-render`,e.replaceChildren(n),n}function hn(e,t){let n=document.createElement(`p`);n.className=`guidex-error`,n.textContent=t,e.removeAttribute(`data-fixed-width`),e.replaceChildren(n)}function gn(e){return e.transpose===0?[]:[Oe(e.transpose)]}function _n(e,t){let n=(e,n)=>({scripts:e,warnings:[...n,...e.flatMap(e=>Ye(e,t))]}),r=gn(t),{stanzas:i,emptySlots:a}=t;if(t.stack!==void 0){let o=Ce(e,t.stack,{stanzas:i});return n(we(e,o,{stanzas:i,emptySlots:a,transforms:r}),o.flatMap(t=>ve(e,{stanzas:i,stanza:t})))}return(t.stanza!==1||a!==`normal`)&&r.unshift(xe(t.stanza,{stanzas:i,emptySlots:a})),n([new F(e,{transforms:r})],ve(e,{stanzas:i,stanza:t.stanza}))}async function vn(e,t,n,r,i){let a=mn(e),o=document.createElement(`div`);try{let{scripts:s,warnings:c}=_n(n,r);if(await new Zt(s).render(o,{style:r.style,marks:r.marks,bold:r.bold,textPx:r.textPx,junctionDashes:r.junctionDashes,staffFill:r.staffFill,staffFillSnapPx:r.staffFillSnapPx,twoSyllableRecitationsToPlain:r.twoSyllableRecitationsToPlain,plainRunsToRecitation:r.plainRunsToRecitation,debug:r.debug,maxWidthPx:i,staff:r.staff,staffLines:r.staffLines,staffColor:r.staffColor,staffLineColors:r.staffLineColors,staffPitchColors:r.staffPitchColors,staffWeight:r.staffWeight,staffLineWeights:r.staffLineWeights,staffClefLineWeight:r.staffClefLineWeight,staffOverflow:r.staffOverflow,staffSnap:!1}),Q.get(e)!==t)return{warnings:c};for(let e of c)console.warn(`[guidex] ${e.message}`);a.replaceChildren(...o.childNodes),a.style.cssText=o.style.cssText,o.dataset.style&&(a.dataset.style=o.dataset.style);for(let e of[`staff`,`staffLines`])o.dataset[e]===void 0?delete a.dataset[e]:a.dataset[e]=o.dataset[e];return a.toggleAttribute(`data-fixed-width`,typeof r.maxWidth==`number`),r.staff===`drawn`&&r.staffSnap&&Wt(a),{warnings:c}}catch(n){return Q.get(e)===t?(console.error(`[guidex]`,n),hn(a,n instanceof Error?n.message:String(n)),{warnings:[]}):{warnings:[]}}}async function yn(e){let t=(Q.get(e)??0)+1;Q.set(e,t);let n=un(e),r=pn(e);en.set(e,r),mn(e);let i=fn(e,n.maxWidth,n.style);tn.set(e,i),await vn(e,t,r,n,i)}var bn=new WeakMap;function xn(e){let t=un(e),n=fn(e,t.maxWidth,t.style);return Math.abs(n-(tn.get(e)??NaN))>1}function Sn(e){if(bn.has(e))return;let t;if(typeof ResizeObserver<`u`){let n=new ResizeObserver(()=>{xn(e)&&yn(e)});n.observe(e),t=()=>n.disconnect()}else{let n=()=>{xn(e)&&yn(e)};window.addEventListener(`resize`,n),t=()=>window.removeEventListener(`resize`,n)}let n=0,r=()=>{cancelAnimationFrame(n),n=requestAnimationFrame(()=>{let t=e.querySelector(`:scope > .guidex-render`);t?.dataset.staff===`drawn`&&un(e).staffSnap&&Wt(t)})};window.addEventListener(`resize`,r);let i=t;t=()=>{i(),cancelAnimationFrame(n),window.removeEventListener(`resize`,r)},bn.set(e,t)}function Cn(e){bn.get(e)?.(),bn.delete(e),en.delete(e),an.delete(e),Q.delete(e),tn.delete(e)}async function wn(e,t,n={}){an.set(e,n);let r=(Q.get(e)??0)+1;Q.set(e,r),en.set(e,t);let i=un(e);mn(e);let a=fn(e,i.maxWidth,i.style);return tn.set(e,a),Sn(e),vn(e,r,t,i,a)}async function Tn(e=document){let t=Z.selector??$t,n=[];return e instanceof Element&&e.matches(t)&&n.push(e),n.push(...e.querySelectorAll(t)),Promise.all(n.map(e=>(Sn(e),yn(e)))).then(()=>void 0)}var En=!1;function Dn(){if(En||typeof MutationObserver>`u`)return;En=!0;let e=Z.selector??$t;new MutationObserver(t=>{let n=new Set;for(let r of t)for(let t of r.addedNodes)if(t instanceof Element&&!t.closest(`.guidex-render`)){t.matches(e)&&n.add(t);for(let r of t.querySelectorAll(e))n.add(r)}for(let e of n)Sn(e),yn(e)}).observe(document.documentElement,{childList:!0,subtree:!0})}function On(e={}){Z={...Z,...e},Dn(),Tn()}var kn=[`font-family`,`font-size`,`font-style`,`font-weight`,`line-height`,`letter-spacing`,`text-transform`,`color`,`position`,`top`,`left`,`margin-top`,`margin-bottom`,`padding-top`,`padding-bottom`],An=[`font-family`,`font-size`,`font-style`,`font-weight`,`line-height`,`letter-spacing`,`color`];function jn(e){return e.classList.contains(`max-width-guide`)||e.hasAttribute(`data-score-image-ignore`)}function Mn(e){let t=e.querySelector(`.guido`)?.parentElement;if(!t)throw Error(`No rendered score found to export — render a score into the element first.`);return t}function Nn(e){let t=e.getBoundingClientRect(),n=[],r=document.createRange();return r.selectNodeContents(e),typeof r.getBoundingClientRect==`function`&&n.push(r.getBoundingClientRect()),e.querySelectorAll(`*`).forEach(e=>n.push(e.getBoundingClientRect())),n.length===0&&n.push(t),{left:Math.min(...n.map(e=>e.left))-t.left,top:Math.min(...n.map(e=>e.top))-t.top,right:Math.max(...n.map(e=>e.right))-t.left,bottom:Math.max(...n.map(e=>e.bottom))-t.top}}function Pn(e){let t=document.createRange();if(t.selectNodeContents(e),typeof t.getClientRects!=`function`)return 1;let n=Array.from(t.getClientRects()).filter(e=>e.width>0||e.height>0);if(n.length===0)return 1;n.sort((e,t)=>e.top-t.top);let r=0,i=-1/0;for(let e of n)e.top>=i?(r++,i=e.bottom):e.bottom>i&&(i=e.bottom);return r}function Fn(e){let t=[],n=``,r=null;for(let i of e)r?i===r?r=null:n+=i:i===`"`||i===`'`?r=i:i===`,`?(t.push(n.trim()),n=``):n+=i;return t.push(n.trim()),t.filter(Boolean)}function In(e){return e===`normal`?`400`:e===`bold`?`700`:e}function Ln(e){return e.replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}function Rn(e,t,n,r,i){let a=/url\(\s*(['"]?)([^'")]+)\1\s*\)/.exec(r);if(!a)return;let o;try{o=new URL(a[2],i??location.href).toString()}catch{return}return{family:e,style:t||`normal`,weight:In(n||`400`),url:o,format:/format\(\s*['"]?([^'")]+?)['"]?\s*\)/.exec(r)?.[1]}}function zn(e,t){let n=[];for(let r of e.matchAll(/@font-face\s*{([^}]*)}/g)){let e=r[1],i=t=>{let n=RegExp(`(?:^|[;\\s])${t}\\s*:\\s*([^;]+)`,`i`).exec(e);return n?n[1].trim():``},a=i(`font-family`),o=i(`src`);if(!a||!o)continue;let s=Fn(a)[0];if(!s)continue;let c=Rn(s,i(`font-style`),i(`font-weight`),o,t);c&&n.push(c)}return n}async function Bn(e){let t=[],n=new Set,r=e=>{let r=`${e.family}|${e.style}|${e.weight}`;n.has(r)||(n.add(r),t.push(e))},i=[];for(let t of document.styleSheets){let n;try{n=t.cssRules}catch{t.href&&i.push(t.href);continue}for(let i of Array.from(n)){let n=i.style;if(!n)continue;let a=n.getPropertyValue(`src`),o=n.getPropertyValue(`font-family`);if(!a||!o)continue;let s=Fn(o)[0];if(!s||!e.has(s))continue;let c=Rn(s,n.getPropertyValue(`font-style`),n.getPropertyValue(`font-weight`),a,t.href??void 0);c&&r(c)}}for(let t of i)try{let n=await fetch(t);if(!n.ok)throw Error(String(n.status));let i=await n.text();for(let n of zn(i,t))e.has(n.family)&&r(n)}catch{console.warn(`[guidex] scoreImage: a cross-origin stylesheet (${t}) could not be read — fonts declared only there are missing from the export`)}return t}async function Vn(e){let t=await fetch(e);if(!t.ok)return;let n=await t.blob();return new Promise(e=>{let t=new FileReader;t.onload=()=>e(typeof t.result==`string`?t.result:void 0),t.onerror=()=>e(void 0),t.readAsDataURL(n)})}async function Hn(e,t){let n=[],r=new Set,i=new Map,a=e=>{let t=i.get(e);return t||(t=Vn(e).catch(()=>void 0),i.set(e,t)),t},o=new Map;for(let t of e){let e=o.get(t.family)??[];e.push(t),o.set(t.family,e)}for(let[e,i]of o){let o=i.filter(e=>e.style===`normal`),s=o.length>0?[...o,...t?i.filter(e=>e.style!==`normal`):[]]:i;for(let t of s){let i=await a(t.url);if(!i){r.add(e);continue}let o=t.format?` format('${t.format}')`:``;n.push(`@font-face{font-family:'${t.family}';font-style:${t.style};font-weight:${t.weight};src:url(${i})${o}}`)}}for(let e of r)console.warn(`[guidex] scoreImage: could not embed the ${e} webfont — the export falls back to the next family in its stack`);return n.join(``)}function Un(e){let t=document.createElement(`span`);return t.style.color=e,getComputedStyle(t).color}function Wn(e){let t=getComputedStyle(e).getPropertyValue(`--red`).trim();return t?Un(t):``}function Gn(e,t,n){return n&&t&&Un(t)===n?!0:e.style?.getPropertyValue(`color`).replace(/\s+/g,``)===`var(--red)`}function Kn(e,t,n){let r=new Set,i=!1;for(let a=0;a<e.length;a++){let o=e[a],s=t[a],c=getComputedStyle(o);for(let e of a===0?An:kn){if(e===`color`){let e=c.getPropertyValue(`color`);if(!e)continue;let t=Gn(o,e,n.accentProbe)?n.accent:n.foreground;s.style.setProperty(`color`,t||e);continue}let t=c.getPropertyValue(e);t&&s.style.setProperty(e,t)}if(o.classList.contains(`guidex-staff-line`)){let e=c.getPropertyValue(`background-color`),t=c.getPropertyValue(`color`);s.style.setProperty(`background-color`,e===t&&n.foreground?n.foreground:e)}let l=c.getPropertyValue(`font-family`);if(l)for(let e of Fn(l))r.add(e);c.getPropertyValue(`font-style`)===`italic`&&(i=!0)}return{families:r,italics:i}}async function qn(){let e=document.fonts;e?.ready&&await e.ready}async function Jn(e,t){let n=Math.max(0,t.padding??0),r=Mn(e);if(!r.isConnected)throw Error(`scoreImage: the score left the document before the export — re-render it and try again`);await qn();let i=Array.from(r.children).filter(e=>e.classList.contains(`guido`)||e.tagName===`P`);if(i.length===0)throw Error(`No rendered score found to export — render a score into the element first.`);let a=i.map(e=>e.getBoundingClientRect()),o=a[0],s=i.map((e,t)=>{let n=Nn(e),r=a[t],i=r.left-o.left,s=Pn(e)>1;return{left:n.left+i,top:n.top+(r.top-o.top),right:(s?Math.max(r.width,n.right):n.right)+i,bottom:n.bottom+(r.top-o.top),pinWidth:s?r.width:void 0}}),c=Math.min(0,...s.map(e=>e.left)),l=Math.min(0,...s.map(e=>e.top)),u=Math.max(...s.map(e=>e.right)),d=Math.max(...s.map(e=>e.bottom)),f=Math.max(1,Math.ceil(u-c))+n*2,p=Math.max(1,Math.ceil(d-l))+n*2,m=r.cloneNode(!0);m.querySelectorAll(`.max-width-guide, [data-score-image-ignore]`).forEach(e=>e.remove());let h=[r],g=[m],_=(e,t)=>{for(let n of e.children)jn(n)||(t.push(n),_(n,t))};if(_(r,h),_(m,g),g.length!==h.length)throw Error(`scoreImage: the cloned tree diverged from the live one`);for(let e of[m,...m.querySelectorAll(`*`)])e.removeAttribute(`title`);let{families:v,italics:y}=Kn(h,g,{foreground:t.foreground,accent:t.accent,accentProbe:Wn(r)});m.style.setProperty(`white-space`,`nowrap`);let b=Array.from(m.children).filter(e=>e.classList.contains(`guido`)||e.tagName===`P`);s.forEach((e,t)=>{let n=b[t];e.pinWidth!==void 0&&n&&n.style.setProperty(`width`,`${e.pinWidth}px`)}),m.style.setProperty(`padding-top`,`${n-l}px`),m.style.setProperty(`padding-left`,`${n-c}px`),m.style.setProperty(`padding-right`,`${n}px`),m.style.setProperty(`padding-bottom`,`${n}px`);let x=await Hn(await Bn(v),y),S=new XMLSerializer().serializeToString(m),ee=t.background?`<rect width="100%" height="100%" fill="${Ln(t.background)}"/>`:``;return{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="${f}" height="${p}" viewBox="0 0 ${f} ${p}">`+ee+(x?`<style>${x}</style>`:``)+`<foreignObject x="0" y="0" width="${f}" height="${p}">`+S+`</foreignObject></svg>`,width:f,height:p}}async function Yn(e,t={}){return(await Jn(e,t)).svg}async function Xn(e,t={}){let{svg:n,width:r,height:i}=await Jn(e,t),a=Math.max(1,t.scale??2),o=new Image;o.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`,await new Promise((e,t)=>{o.onload=()=>e(),o.onerror=()=>t(Error(`scoreImage: the exported SVG failed to rasterize`))});try{await o.decode()}catch{}let s=document.createElement(`canvas`);s.width=Math.ceil(r*a),s.height=Math.ceil(i*a);let c=s.getContext(`2d`);if(!c)throw Error(`scoreImage: this environment provides no 2D canvas`);c.scale(a,a),t.background&&(c.fillStyle=t.background,c.fillRect(0,0,r,i));let l=()=>c.drawImage(o,0,0,r,i);l(),/^((?!chrome|android|crios|fxios).)*safari/i.test(navigator.userAgent)&&(await new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(e))),l());let u=await new Promise(e=>s.toBlob(e,`image/png`));if(!u)throw Error(`scoreImage: PNG encoding failed`);return u}function Zn(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,r.click(),setTimeout(()=>URL.revokeObjectURL(n),1e4)}async function Qn(e,t={}){let n=t.filename??`score.png`;return Zn(await Xn(e,t),n),n}async function $n(e,t={}){let n=t.filename??`score.svg`;return Zn(new Blob([await Yn(e,t)],{type:`image/svg+xml;charset=utf-8`}),n),n}return document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,()=>On(),{once:!0}):On(),e.dispose=Cn,e.downloadScorePng=Qn,e.downloadScoreSvg=$n,e.init=On,e.renderAll=Tn,e.renderScore=wn,e.scorePngBlob=Xn,e.scoreSvg=Yn,e.version=Qt,e})({});
1
+ var GuidexEmbed=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t={ð:{longa:`€`,smallHead:`~`,modifyUp:`È`,cephalicus:`®`},ñ:{virga:`^`,longa:`Ž`,smallHead:`¯`,modifyUp:`Ê`,modifyDown:`÷`,cephalicus:`−`,connectOneDown:`Ý`,smallPoint:"`"},0:{virga:`]`,longa:`ž`,smallHead:`‚`,modifyUp:`Ë`,modifyDown:`ø`,modifyNatural:`“`,cephalicus:`§`,connectOneDown:`Þ`,connectTwoDown:`Ô`},1:{virga:`q`,longa:`Ÿ`,smallHead:`ƒ`,modifyUp:`Ì`,modifyDown:`a`,modifyNatural:`”`,cephalicus:`'`,connectOneDown:`Q`,connectTwoDown:`×`,connectThreeDown:`Ø`,smallPoint:`í`},2:{virga:`w`,longa:`¡`,smallHead:`„`,modifyUp:`Î`,modifyDown:`A`,modifyNatural:`•`,cephalicus:`"`,connectOneDown:`W`,connectTwoDown:`s`,connectThreeDown:`Ù`,connectFourDown:`½`},3:{virga:`e`,longa:`¢`,smallHead:`…`,modifyUp:`Ï`,modifyDown:`S`,modifyNatural:`–`,cephalicus:`+`,connectOneDown:`E`,connectTwoDown:`d`,connectThreeDown:`D`,connectFourDown:`°`,smallPoint:`y`},4:{virga:`r`,longa:`£`,smallHead:`†`,modifyUp:`Ð`,modifyDown:`Í`,modifyNatural:`—`,cephalicus:`!`,connectOneDown:`R`,connectTwoDown:`f`,connectThreeDown:`F`,connectFourDown:`±`},5:{virga:`t`,longa:`[`,smallHead:`‡`,modifyUp:`Ñ`,modifyDown:`Y`,modifyNatural:`˜`,cephalicus:`%`,connectOneDown:`T`,connectTwoDown:`g`,connectThreeDown:`G`,connectFourDown:`²`,smallPoint:`x`},6:{virga:`z`,longa:`¥`,smallHead:`ˆ`,modifyUp:`Ò`,modifyDown:`X`,modifyNatural:`™`,cephalicus:`/`,connectOneDown:`Z`,connectTwoDown:`h`,connectThreeDown:`H`,connectFourDown:`³`},7:{virga:`u`,longa:`¦`,smallHead:`‰`,modifyUp:`þ`,modifyDown:`C`,modifyNatural:`š`,cephalicus:`=`,connectOneDown:`U`,connectTwoDown:`j`,connectThreeDown:`J`,connectFourDown:`´`,smallPoint:`c`},8:{virga:`i`,longa:`©`,smallHead:`Š`,modifyUp:`ß`,modifyDown:`V`,modifyNatural:`›`,cephalicus:`(`,connectOneDown:`I`,connectTwoDown:`k`,connectThreeDown:`K`,connectFourDown:`μ`},9:{virga:`o`,longa:`ª`,smallHead:`‹`,modifyUp:`ò`,modifyDown:`B`,modifyNatural:`œ`,cephalicus:`)`,connectOneDown:`O`,connectTwoDown:`l`,connectThreeDown:`L`,connectFourDown:`·`,smallPoint:`v`},ö:{virga:`p`,longa:`«`,smallHead:`Œ`,modifyUp:`ô`,modifyDown:`N`,modifyNatural:`º`,cephalicus:`Ö`,connectOneDown:`P`,connectTwoDown:`é`,connectThreeDown:`É`,connectFourDown:`¾`},ü:{virga:`õ`,longa:`¬`,smallHead:`‘`,modifyUp:`ù`,modifyDown:`$`,modifyNatural:`»`,cephalicus:`Ü`,connectOneDown:`Õ`,connectTwoDown:`á`,connectThreeDown:`Á`,connectFourDown:`¸`,smallPoint:`b`},ó:{virga:`ú`,longa:`¤`,smallHead:`’`,modifyUp:`ý`,modifyDown:`m`,cephalicus:`Ó`,connectOneDown:`Ú`,connectTwoDown:`û`,connectThreeDown:`Û`,connectFourDown:`¹`,smallPoint:`n`}},n={ð:`a`,ñ:`b`,0:`c'`,1:`d'`,2:`e'`,3:`f'`,4:`g'`,5:`a'`,6:`b'`,7:`c''`,8:`d''`,9:`e''`,ö:`f''`,ü:`g''`,ó:`a''`};function r(e){return n[e]??n[l(e)?.base??``]}var i=new Map;for(let[e,n]of Object.entries(t))for(let t of Object.keys(n))i.set(n[t],{base:e,role:t});for(let[e,t]of Object.entries({ÿ:`'`}))i.set(e,i.get(t));function a(e,n){return t[e]?.[n]}function o(e){return a(e,`longa`)}function s(e){return a(e,`smallHead`)}function c(e){return a(e,`modifyNatural`)}function l(e){let t=i.get(e);return t?{...t}:void 0}var u=[`modifyUp`,`modifyDown`,`modifyNatural`];function d(e){let t=i.get(e)?.role;return t!==void 0&&u.includes(t)}var f=new Map([[`Â`,`Ã`],[`Ä`,`Å`],[`Æ`,`Ç`]]);function p(e,t=0){let n=f.get(e[t]??``);if(n===void 0)return 0;let r=t+1;for(;r<e.length&&d(e[r]);)r++;if(r===t+1||e[r]!==n)return 0;for(r++;e[r]===`¨`||e[r]===`-`;)r++;return r-t}var m={">":{clef:`c`,line:1},"#":{clef:`c`,line:2},"&":{clef:`c`,line:3},"@":{clef:`c`,line:4},"{":{clef:`f`,line:3},"}":{clef:`f`,line:4},M:{clef:`g`,line:2},"<":{clef:`g`,line:2}};function h(e){return Object.hasOwn(m,e)}var g=[...`ðñ0123456789öüó`],_=`abcdefg`;function ee(e,t=`M`){let n=g.indexOf(g.includes(e)?e:l(e)?.base??``),i=m[t];if(n<0||!i)return;let a=g.indexOf(`2`)+2*(i.line-1),o=_.indexOf(i.clef)-_.indexOf(r(g[a])[0]);return _[((_.indexOf(r(g[n])[0])+o)%7+7)%7]}var v=new Set(`,.:?'"+!%/=()ÖÜÓ;`.split(``));function y(e){let t=0;for(;t<e.length&&v.has(e[t]);)t++;t>0&&t<e.length&&(t=e[t]===`-`?t+1:0);let n=e.length;for(;n>t&&v.has(e[n-1]);)n--;return n<e.length&&n>t&&(n=e[n-1]===`-`?n-1:e.length),{leading:e.slice(0,t),core:e.slice(t,n),trailing:e.slice(n)}}var te=new Set([`*`,`†`]),ne=new Set([`color`,`size`,`raise`,`font`]),b={_:``,"*":``,"†":``,"∗":``},re=new Map(Object.entries(b).map(([e,t])=>[t,e]));function ie(e){return e.replace(/\\(.)/gsu,(e,t)=>b[t]??t)}function x(e){return e.replace(/[-]/g,e=>re.get(e))}function S(e){return[`__`,`_`].find(t=>e.length>=t.length*2+1&&e.startsWith(t)&&e.endsWith(t))}function C(e){let t=[],n=e,r=``;for(let e=/\*([^*]+)\*/.exec(n);e;e=/\*([^*]+)\*/.exec(n))r+=n.slice(0,e.index),r&&=(t.push({text:r,initial:!1}),``),t.push({text:e[1],initial:!0}),n=n.slice(e.index+e[0].length);return r+=n,r&&t.push({text:r,initial:!1}),t}function w(e,t,n){let r=e=>te.has(e)?`marker`:n&&e===`+`?`plus`:void 0,i=[];for(let t of e){let e=r(t),n=i[i.length-1];n&&n.glyph===e?n.text+=t:i.push({text:t,glyph:e})}return i.map(e=>({text:e.text,marks:e.glyph?[...t,e.glyph]:[...t]}))}function ae(e){if(e.length===0)return[];let t=ie(e);if(t===`**`)return[{text:`∗`,marks:[`star`]}];let n=S(t),r=n?t.slice(n.length,-n.length):t,i=n?[n===`__`?`liturgy`:`rubric`]:[];return C(r).flatMap(({text:e,initial:t})=>w(x(e),t?[...i,`initial`]:i,n===`__`))}function T(e){return x(ie(e).replace(/[_*†∗]/g,``))}function E(e){let t=[],n=0;for(;;){let r=/^[A-Za-z][\w-]*/.exec(e.slice(n))?.[0];if(!r)return;if(n+=r.length,e[n]===`:`&&ne.has(r)){let i=/^[^\s,:{}]+/.exec(e.slice(n+1))?.[0];if(!i)return;t.push(`${r}:${i}`),n+=1+i.length}else t.push(r);if(e[n]===`:`)return{marks:t,length:n+1};if(e[n]!==`,`)return;n+=1}}function oe(e){let t=[],n=``,r=()=>{n&&t.push({type:`text`,written:n}),n=``};for(let i=0;i<e.length;i++){let a=e[i];if(a===`\\`&&i+1<e.length)n+=a+e[++i];else if(a===`{`){r();let n=E(e.slice(i+1));t.push({type:`open`,marks:n?.marks}),n&&(i+=n.length)}else a===`}`?(r(),t.push({type:`close`})):n+=a}return r(),t}function D(e){let t=[],n=e.map(oe),r=new Map,i=[],a=new Set;for(let[o,s]of n.entries())for(let n of s)if(n.type===`open`){n.marks||t.push({kind:`span`,text:e[o].trim(),message:`A "{" needs its marks and a colon, as in "{red:text}" (in "${e[o].trim()}")`});let a={marks:n.marks??[]};r.set(n,a),i.push(a)}else n.type===`close`&&!i.pop()&&(a.add(n),t.push({kind:`span`,text:e[o].trim(),message:`A "}" closes nothing (in "${e[o].trim()}")`}));for(let e of i)e.marks.length>0&&t.push({kind:`span`,text:e.marks.join(`,`),message:`The span "{${e.marks.join(`,`)}:" is never closed`}),e.marks=[];let o=[],s=[],c;for(let[t,i]of n.entries()){let n=o.length>0,l=[],u={bare:``,source:``,runs:[],text:``};for(let e of i)e.type===`open`?o.push(r.get(e)):e.type===`close`?a.has(e)||o.pop():l.push({marks:o.flatMap(e=>e.marks),written:e.written});u.bare=l.map(e=>e.written).join(``);let d=se(l);u.runs=d.flatMap(({marks:e,written:t})=>ae(t).map(t=>({text:t.text,marks:[...e,...t.marks]}))),u.text=d.map(({written:e})=>T(e)).join(``);let f=i.some(e=>a.has(e)||e.type===`open`&&r.get(e).marks.length===0),p=i.some(e=>e.type===`open`||e.type===`close`);u.source=n||o.length>0||f||p&&u.bare.trim()===``?d.map(({marks:e,written:t})=>e.length>0?`{${e.join(`,`)}:${t}}`:t).join(``):e[t].trim();let m=d.filter(e=>e.written.trim()!==``);if(m.length>0){if(c){let e=new Set(m[0].marks),t=c.marks.filter(t=>e.has(t));t.length>0&&(c.piece.hyphen=t)}c={piece:u,marks:m[m.length-1].marks}}s.push(u)}return{pieces:s,problems:t}}function se(e){let t=e.map(e=>({...e})),n=t[0],r=t[t.length-1];return n&&(n.written=n.written.trimStart()),r&&(r.written=r.written.trimEnd()),t.filter(e=>e.written!==``)}function O(e){return e.trim().startsWith(`@`)}function ce(e){let[t,...n]=e;return t===`@`&&n.every(d)}function le(e){return!O(e)||ce(e)}function k(e,t){for(let n of e)if(!d(n))throw Error(`"${n}" is not a key modifier glyph in "${t}"`);return e}function ue(e){let t=e.trim();if(ce(t))throw Error(`a clef group is only allowed at the start; write "(@clef ${t})" to change the clef`);let[,n,r=``]=t.match(/^@(\S*)(?: (.*))?$/)??[];switch(n){case`break`:if(r!==``)throw Error(`"@break" takes no argument: "${t}"`);return{kind:`break`};case`clef`:{let[e,...n]=r;if(e===void 0)throw Error(`"@clef" needs a clef group argument, e.g. "(@clef MX)"`);if(!h(e))throw Error(`"${e}" is not a clef glyph in "${t}"`);return{kind:`clef`,clef:e,key:k(n.join(``),t)}}case`key`:return{kind:`key`,key:k(r,t)};case`tight`:case`keep`:case`unit`:case`aid`:if(r!==``&&r!==`off`)throw Error(`"@${n}" takes only "off": "${t}"`);return{kind:n,on:r===``};default:throw Error(`Unknown statement "${t}"`)}}function de(e){switch(e.kind){case`break`:return`(@break)`;case`clef`:return`(@clef ${e.clef}${e.key})`;case`key`:return e.key===``?`(@key)`:`(@key ${e.key})`;case`tight`:case`keep`:case`unit`:case`aid`:return e.on?`(@${e.kind})`:`(@${e.kind} off)`}}function A(e){let t=e.match(/^@stanza(?:\s+([\s\S]*))?$/);return t?t[1]??``:void 0}var j=class{source;constructor(e,t={}){this.source=(t.transforms??[]).reduce((e,t)=>t.apply(e),e)}get clef(){let e=this.normalized.match(/^\s*\(([^)]*)\)/);if(!(!e||!le(e[1])))return e[1]}get tokens(){return this.parse().tokens}get stanzas(){return this.parse().stanzas}get tokenSpans(){return this.parse().spans}get spanProblems(){return this.parse().problems}parse(){let e=this.normalized,t=e.match(/^\s*\(([^)]*)\)/),n=t&&le(t[1])?t[0].length:0,r=[...e.slice(n).matchAll(/((?:[^()\\]|\\.)*)\(((?:[^)\\]|\\.)*)\)/g)],i=D(r.map(e=>e[1])),a,o=[],s=[],c=[];for(let[e,t]of r.entries()){let[,r,l]=t,u=i.pieces[e],d=u.bare,f=n+t.index,p=f+r.length+1,m={start:f+(r.length-r.trimStart().length),notesStart:p,notesEnd:p+l.length,end:p+l.length+1},h=O(l)?A(l.trim()):void 0;if(h!==void 0){if(d.trim()!==``)throw Error(`statement must not carry syllable text: "${_e(d.trim())}"`);o.push(h);continue}if(o.length>0){if(d.trim()===``&&l===``)continue;throw Error(`"(@stanza …)" statements must stand at the end of the script`)}if(O(l)){let e=ue(l);if(d.trim()!==``)throw Error(`statement must not carry syllable text: "${_e(d.trim())}"`);s.push({...e,spaceBefore:/^\s/.test(d)}),c.push(m);continue}let g=d.trim();if(g===``&&l===``&&r.trim()!==``)continue;let _={kind:`syllable`,...pe(g===`~`?fe:u),role:`sung`,notes:_e(l),spaceBefore:/^\s/.test(d)};if(g===`~`||g===``&&a===void 0&&_.notes!==``)_.empty=!0;else if(g===``&&_.notes!==``){if(a.notes===``)throw Error(`the group "(${_.notes})" has no syllable to hold it: "${a.text}" has no notes; write "~(${_.notes})" for an empty slot`);_.held=!0}a=_,s.push(_),c.push(m)}let l;for(let[e,t]of s.entries()){if(t.kind!==`syllable`)continue;if(t.held){t.wordEnd=l.wordEnd;continue}t.wordEnd=!0;let n=!1;for(let r=e+1;r<s.length;r++){let e=s[r];if(e.spaceBefore&&(n=!0),e.kind===`syllable`&&!e.held&&!e.empty){t.wordEnd=n;break}}l=t}return ge(s),{tokens:s,stanzas:o,spans:c,problems:i.problems}}get syllables(){return this.tokens.filter(e=>e.kind===`syllable`).map(({text:e,notes:t,wordEnd:n,held:r,empty:i})=>({text:e,notes:t,wordEnd:n,...r?{held:r}:{},...i?{empty:i}:{}}))}get normalized(){let e=this.source;return(e.match(/(^|[^\\])\(/g)??[]).length>(e.match(/(^|[^\\])\)/g)??[]).length&&(e+=`)`),/(^|[^\\])\)$/.test(e)||(e+=`()`),e}get words(){let e=[],t;for(let n of this.tokens){if(n.kind!==`syllable`||n.held||n.empty)continue;t??={text:``,syllables:[]};let{text:r,source:i,runs:a,role:o,notes:s}=n;t.syllables.push({text:r,source:i,runs:a,role:o,notes:s}),t.text=t.syllables.map(e=>e.text).join(``),n.wordEnd&&(e.push(t),t=void 0)}return e}toString(){let e=this.tokens.map((e,t)=>{let n=t>0&&e.spaceBefore?` `:``;return e.kind===`syllable`?`${n}${e.empty?`~`:e.source}(${M(e.notes)})`:`${n}${de(e)}`}),t=this.stanzas.map(e=>`(@stanza ${e})`);return`${this.clef===void 0?``:`(${this.clef})`}${e.join(``)}${t.join(``)}`}},fe={bare:``,source:``,runs:[],text:``};function pe(e){let{text:t,source:n,runs:r,hyphen:i}=e;return{text:t,source:n,runs:r,...i?{hyphen:i}:{}}}var me=[`liturgy`,`rubric`];function he(e){return/[^-¨]/.test(y(e).core)}function ge(e){let t=0,n=`sung`,r=(e,t)=>e.runs.every(e=>e.marks.some(e=>t.includes(e)));for(let i of e)if(i.kind===`aid`&&(t=Math.max(0,t+(i.on?1:-1))),i.kind===`syllable`){if(i.held){i.role=n;continue}i.role=i.runs.length===0?!i.empty&&i.notes===``?`sign`:t>0?`aid`:`sung`:i.text===``||r(i,[`plus`])?`sign`:r(i,me)&&!he(i.notes)?`label`:t>0?`aid`:`sung`,n=i.role}}function _e(e){return e.replace(/\\(.)/g,`$1`)}function M(e){return e.replace(/\\/g,`\\\\`).replace(/[()]/g,e=>`\\${e}`)}var N=`_…_`,P=`-=­`,F=`_*†∗{}`;function I(e){let t=[],n=null,r=Array.from(e);for(let e=0;e<r.length;e++){let i=r[e],a=i===`\\`&&e+1<r.length;if(a&&(i=r[++e]),!a&&/\s/.test(i)){n=null;continue}n===null&&(n=[],t.push(n)),n.push({ch:i,escaped:a})}let i=[];for(let e of t){if(e.length===1&&!e[0].escaped&&e[0].ch===`~`){i.push({kind:`empty`});continue}let t=[``],n=[``];for(let{ch:r,escaped:i}of e){if(!i&&P.includes(r)){t.push(``),n.push(``);continue}let e=!i&&r===`~`?`\xA0`:r;t[t.length-1]+=e,n[n.length-1]+=i&&F.includes(r)?`\\${r}`:M(e)}let r=t.length-1;for(let[e,a]of t.entries()){if(a===``){e<r&&i.push({kind:`hold`});continue}let t=n[e];i.push({kind:`syllable`,text:a,wordEnd:e===r,...t===M(a)?{}:{source:t}})}}return L(i)}function L(e){let t=e.filter(e=>e.kind===`syllable`),n=t.map(e=>e.source??M(e.text));if(!n.some(e=>/[{}]/.test(e)))return e;let{pieces:r}=D(n);for(let[e,n]of t.entries())n.source=r[e].source;return e}function R(e){return e.kind===`syllable`&&e.role!==`label`&&e.role!==`sign`&&e.notes!==``&&y(e.notes).core!==``}function z(e){return typeof e==`string`?new j(e):e}function B(e){return z(e).tokens.filter(R).length}function V(e,t={}){return t.stanzas??z(e).stanzas}function ve(e,t={}){return V(e,t).length+1}function H(e){return e.kind===`syllable`||e.kind===`hold`}function U(e){return e.map(e=>e.empty?{kind:`empty`}:e.held?{kind:`hold`}:{kind:`syllable`,text:e.text,source:e.source,wordEnd:e.wordEnd})}function ye(e,t,n){let r=I(e),i=[],a=[];for(let e=0;e<t;e++){let o=r[e];i.push(o??{kind:`missing`}),o===void 0&&a.push({stanza:n,slot:e+1,kind:`missing`,message:`Stanza ${n} has no syllable for slot ${e+1} of ${t}`})}for(let[e,i]of r.slice(t).entries()){let r=i.kind===`syllable`?i.text:i.kind===`hold`?`-`:`~`;a.push({stanza:n,slot:t+e+1,kind:`extra`,text:r,message:`Stanza ${n} has an extra syllable "${r}" past the last slot (${t})`})}return{fills:i,warnings:a}}function be(e,t){if(!Number.isInteger(e)||e<1||e>t)throw RangeError(`Stanza ${e} does not exist: the script has ${t} stanza${t===1?``:`s`}`)}function W(e,t={}){let n=V(e,t),r=B(e);return t.stanza===void 0?n.flatMap((e,t)=>ye(e,r,t+2).warnings):(be(t.stanza,n.length+1),t.stanza===1?[]:ye(n[t.stanza-2],r,t.stanza).warnings)}function xe(e){return Array.from(e,e=>{let t=s(e);if(t!==void 0)return t;let n=l(e);return n&&(n.role===`virga`||n.role===`longa`)?s(n.base)??e:e}).join(``)}function Se({text:e,source:t}){return t??(e===`~`?`\\~`:M(e))}function Ce(e,t,n){let r=new j(e),i=V(r,n);be(t,i.length+1);let a=n.rendered??[t];for(let e of a)be(e,i.length+1);let o=n.emptySlots??`normal`;if(t===1&&o===`normal`)return e;let s=r.tokens,c=s.filter(e=>R(e)),l=[U(c),...i.map((e,t)=>ye(e,c.length,t+2).fills)],u=l[t-1],d=e=>o===`partial`?l.some(t=>H(t[e]))&&!l.every(t=>H(t[e])):o===`small`&&a.every(t=>!H(l[t-1][e]))&&l.some((t,n)=>!a.includes(n+1)&&H(t[e])),f=r.clef===void 0?``:`(${r.clef})`,p=!0,m=!1,h=!1,g=(e,t)=>{f+=(t&&!p?` `:``)+e,p=!1},_=0;for(let e of s){if(e.kind!==`syllable`){g(de(e),m),m=!1;continue}if(!R(e)){e.held?(g(`(${M(e.notes)})`,m),m=!1):(g(`${e.source}(${M(e.notes)})`,m||e.spaceBefore),m=e.wordEnd,h=e.notes!==``);continue}let t=u[_],n=M(d(_)?xe(e.notes):e.notes);switch(_++,t.kind){case`syllable`:g(`${Se(t)}(${n})`,m),m=t.wordEnd;break;case`hold`:g(`${h?``:`~`}(${n})`,!1);break;case`empty`:g(`~(${n})`,!1);break;case`missing`:g(`${N}(${n})`,!0),m=!0}h=!0}return f}function we(e,t={}){return{name:`selectStanza`,apply:n=>Ce(n,e,t)}}function G(e,t,n={}){return new j(typeof e==`string`?e:e.source,{transforms:[we(t,n),...n.transforms??[]]})}function K(e,t,n={}){let r=ve(e,n);if(t===`all`)return Array.from({length:r},(e,t)=>t+1);if(t.length===0)throw RangeError(`No stanza to stack: the list is empty`);for(let e of t)be(e,r);return[...t]}function Te(e,t,n={}){let r=K(e,t,n);return r.map(t=>G(e,t,{...n,rendered:r}))}var Ee=[`ðñ0123456789öüó`,`^]qwertzuiopõú`,`ÝÞQWERTZUIOPÕÚ`,`Ô×sdfghjkléáû`,`ØÙDFGHJKLÉÁÛ`,`÷øaASÍYXCVBN$m`,`ÈÊËÌÎÏÐÑÒþßòôùý`,`“”•–—˜™š›œº»`,`®−§'"+!%/=()ÖÜÓ`,`€ŽžŸ¡¢£[¥¦©ª«¬¤`,`~¯‚ƒ„…†‡ˆ‰Š‹Œ‘’`,`àâãäåæçèêëìîï`,`½°±²³´μ·¾¸¹`];function De(e,t,n){e===`ÿ`&&(e=`'`);for(let r of Ee){let i=r.indexOf(e);if(i===-1)continue;let a=i+t;if(a<0||a>=r.length){if(n===`null`)return`\0`;if(n===`error`)throw Error(`Transposing "${e}" by ${t} runs past the glyph range`);return r[Math.max(0,Math.min(r.length-1,a))]}return r[a]}}function q(e,t,n={}){if(t===0||O(e))return e;let r=n.overflow??`clamp`,i=``;for(let n=0;n<e.length;n++){let a=e[n],o=a===`\\`&&e[n+1]!==void 0,s=De(o?e[n+1]:a,t,r);if(s===void 0){i+=o?a+e[n+1]:a,o&&n++;continue}i+=`\\()`.includes(s)?`\\${s}`:s,o&&n++}return i}function Oe(e,t={}){let n=t.overflow??`clamp`;return{name:`transpose`,apply:t=>{if(e===0)return t;let r=t.match(/^\s*\(([^)]*)\)/),i=r?r[0].length:0;return t.slice(0,i)+t.slice(i).replace(/((?:[^()\\]|\\.)*)\(((?:[^)\\]|\\.)*)\)/g,(t,r,i)=>`${r}(${q(i,e,{overflow:n})})`)}}}var J={chars:te,fontFamily:`'Times New Roman', Times, serif`},ke={weight:`400`,scale:.7,raise:.2},Ae={BNS:{textFontStack:`'Book Antiqua', Georgia, serif`,notesFontStack:`'Guidohu'`,markerGlyphs:J,verifiedFonts:[{family:`'Book Antiqua'`,weight:`400`},{family:`'Book Antiqua'`,weight:`700`},{family:`'Guidohu'`,weight:`400`},{family:`'Liturgy'`,weight:`700`}],marks:{liturgy:{fontFamily:`'Liturgy', serif`,weight:`700`,color:`var(--red)`},rubric:{uppercase:!0,scale:.7,color:`var(--red)`},initial:{weight:`700`,color:`var(--red)`,initial:!0},star:{fontFamily:J.fontFamily,weight:`700`,scale:1,measureScale:.95,raise:.1,color:`var(--red)`},plus:ke},padding:12,clefLine:{color:`var(--red, #d40000)`}},Vesperale:{textFontStack:`'Times New Roman', Times, serif`,notesFontStack:`'Guidohu'`,verifiedFonts:[{family:`'Times New Roman', Times, serif`,weight:`400`},{family:`'Times New Roman', Times, serif`,weight:`700`},{family:`'Guidohu'`,weight:`400`},{family:`'Liturgy'`,weight:`700`}],marks:{liturgy:{fontFamily:`'Liturgy', serif`,weight:`700`},rubric:{scale:.8,italic:!0},initial:{weight:`700`,initial:!0},star:{fontFamily:J.fontFamily,weight:`700`,scale:1,measureScale:.95,raise:.2},plus:ke},padding:12,clefLine:{weight:2.5}}},je=new Map;function Me(e){return je.get(e)??Ae[e]}var Ne={red:`var(--red)`},Pe=new Set(`aliceblue antiquewhite aqua aquamarine azure beige bisque black blanchedalmond blue blueviolet brown burlywood cadetblue chartreuse chocolate coral cornflowerblue cornsilk crimson cyan darkblue darkcyan darkgoldenrod darkgray darkgreen darkgrey darkkhaki darkmagenta darkolivegreen darkorange darkorchid darkred darksalmon darkseagreen darkslateblue darkslategray darkslategrey darkturquoise darkviolet deeppink deepskyblue dimgray dimgrey dodgerblue firebrick floralwhite forestgreen fuchsia gainsboro ghostwhite gold goldenrod gray green greenyellow grey honeydew hotpink indianred indigo ivory khaki lavender lavenderblush lawngreen lemonchiffon lightblue lightcoral lightcyan lightgoldenrodyellow lightgray lightgreen lightgrey lightpink lightsalmon lightseagreen lightskyblue lightslategray lightslategrey lightsteelblue lightyellow lime limegreen linen magenta maroon mediumaquamarine mediumblue mediumorchid mediumpurple mediumseagreen mediumslateblue mediumspringgreen mediumturquoise mediumvioletred midnightblue mintcream mistyrose moccasin navajowhite navy oldlace olive olivedrab orange orangered orchid palegoldenrod palegreen paleturquoise palevioletred papayawhip peachpuff peru pink plum powderblue purple rebeccapurple red rosybrown royalblue saddlebrown salmon sandybrown seagreen seashell sienna silver skyblue slateblue slategray slategrey snow springgreen steelblue tan teal thistle tomato turquoise violet wheat white whitesmoke yellow yellowgreen`.split(` `));function Y(e){let t=e.toLowerCase();return Pe.has(t)?t:/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(e)?e:void 0}var Fe={liturgy:`'Liturgy', serif`,times:`'Times New Roman', Times, serif`},Ie=.75,Le=new Set([`liturgy`,`rubric`,`star`,`marker`,`plus`]);function Re(e){return e.filter(e=>Le.has(e)).pop()}function ze(e,t,n,r,i){let a=e=>r.colors?.[e]??Ne[e]??Y(e),o=t.indexOf(`:`),s=o<0?t:t.slice(0,o),c=o<0?``:t.slice(o+1),l=Number(c);switch(s){case`plain`:return{};case`red`:return{...e,color:Ne.red};case`b`:return{...e,weight:`700`};case`i`:return{...e,italic:!0};case`sc`:return{...e,smallCaps:!0};case`up`:return{...e,uppercase:!0};case`u`:return{...e,underline:!0};case`color`:{let t=a(c);return t?{...e,color:t}:void 0}case`size`:return l>0?{...e,scale:l,measureScale:void 0}:void 0;case`raise`:return Number.isFinite(l)&&c!==``?{...e,raise:l}:void 0;case`font`:{let t=r.fonts?.[c]??Fe[c];return t?{...e,fontFamily:t}:void 0}case`marker`:return r.markerGlyphs?.chars.has(n[0])?{...e,fontFamily:r.markerGlyphs.fontFamily}:e}let u=i?.[t]??r.marks[t];if(!u)return;let d=u.color&&a(u.color);return{...e,...u,...d?{color:d}:{}}}function Be(e,t,n,r){return t.reduce((t,i)=>ze(t,i,e,n,r)??t,{})}function Ve(e,t,n){return e.filter(e=>ze({},e,``,t,n)===void 0)}function He(e){let t=[];for(let n of e){let e=n.toUpperCase()!==n,r=t[t.length-1];r&&r.small===e?r.text+=n:t.push({text:n,small:e})}return t}function Ue(e,t,n,r){return e.flatMap(({text:e,marks:i})=>{let a=Be(e,i,t,r),o=n?{...a,weight:`700`}:a,s=Re(i);if(!o.smallCaps)return[{text:e,style:o,kind:s}];let c={...o,smallCaps:void 0};return He(e).map(e=>({text:e.text,kind:s,style:e.small?{...c,smallCaps:!0,uppercase:!0,scale:(c.scale??1)*Ie,measureScale:void 0}:c}))})}function We(e){return e.style.uppercase?e.text.toUpperCase():e.text}function Ge(e){let t=(e??``).trim().replace(/\s+/g,` `);return t&&t.length<=80&&!/["'`;{}<>\\]/.test(t)?t:void 0}function Ke(e,t){let n=Ge(t);return n?`"${n}", ${e.textFontStack}`:e.textFontStack}function qe(e,t,n){return[e.italic?`italic`:`normal`,`normal`,e.weight??`400`,`${t*(e.measureScale??e.scale??1)}px`,e.fontFamily??n].join(` `)}function Je(e,t){let n={};return e.fontFamily&&(n[`font-family`]=e.fontFamily),e.weight&&(n[`font-weight`]=e.weight),e.italic&&(n[`font-style`]=`italic`),e.scale!==void 0&&(n[`font-size`]=`${t*e.scale}px`),e.color&&(n.color=e.color),e.uppercase&&(n[`text-transform`]=`uppercase`),e.underline&&(n[`text-decoration`]=`underline`),e.raise&&(n.position=`relative`,n.top=`${-t*e.raise}px`),n}function Ye(e,t){return e.verifiedFonts.map(e=>`${e.weight} ${t}px ${e.family}`)}var Xe=new Set([`+`,`.`,`/`,`R`,`V`]);function Ze(e,t={}){let n=typeof e==`string`?new j(e):e,r=Me(t.style??`BNS`);if(!r)return n.spanProblems;let i=[...n.spanProblems],a=new Set;for(let e of n.tokens){if(e.kind!==`syllable`)continue;for(let n of Ve([...new Set(e.runs.flatMap(e=>e.marks))],r,t.marks))a.has(n)||(a.add(n),i.push({kind:`mark`,mark:n,text:e.source,message:`Unknown mark "${n}" (in "${e.source}")`}));let n=Ue(e.runs,r,!1,t.marks).filter(e=>e.style.fontFamily?.includes(`Liturgy`)&&e.kind!==`marker`).flatMap(e=>[...e.text]);for(let t of new Set(n))Xe.has(t)||/\s/.test(t)||i.push({kind:`glyph`,char:t,text:e.source,message:`The Liturgy font has no "${t}" (in "${e.source}"); it has only + . / R V`})}return i}function Qe(e){let t=e.length===2&&d(e[0])?e[0]:``,n=e.slice(t.length);if(n.length!==1)return null;let r=l(n);if(r?.role===`longa`)return{sign:t,plain:r.base,glyph:n,written:`glyph`};let i=o(n);return i?{sign:t,plain:n,glyph:i,written:`plain`}:null}function $e(e,t){let n=Qe(e);return!n||t===`written`?e:n.sign+(t===`recite`?n.glyph:n.plain)}function et(e,t){return t===`written`?Qe(e)?.written===`glyph`?`recite`:`plain`:t}function tt(e){let t=[],n=new Set;return(e[0]??[]).forEach((r,i)=>{if((r.kind===`clef`||r.kind===`key`)&&n.add(t.length),r.kind!==`syllable`)return;let a=e.some(e=>{let t=e[i];return t?.kind===`syllable`&&!t.held&&!t.empty});t.push({notes:r.notes,counted:a})}),{syllables:t,pitchBreaks:n}}function nt(e,t){let n=Qe(e.notes);return n?n.written===`glyph`||t.plainRunsToRecitation:!1}function rt(e){let t=Qe(e);return t.sign+t.plain}function it(e,t,n){let r=new Map,i=0;for(;i<e.length;){if(!nt(e[i],n)){i++;continue}let a=rt(e[i].notes),o=i,s=0;for(;o<e.length&&nt(e[o],n)&&rt(e[o].notes)===a&&(o===i||!t.has(o));)e[o].counted&&s++,o++;for(let e=i;e<o;e++)r.set(e,s>=3?`recite`:`written`);i=o}return r}function at(e,t){return!t.twoSyllableRecitationsToPlain&&!t.plainRunsToRecitation?!1:e.some(e=>nt(e,t))}function ot(e,t,n,r){let i=[],a,o=``,s=-1;return e.forEach((e,c)=>{let l=t[c],u=n[c];if(!(nt(e,r)&&l!==void 0&&u!==void 0&&Qe(l)!==null)){a=void 0;return}let d=rt(l);(!a||d!==o||u!==s)&&(a={members:[],count:0},i.push(a),o=d,s=u),a.members.push(c),e.counted&&a.count++}),i}function st(){return{decided:new Map,breakBefore:new Set,pending:null}}function ct(e,t){let n=new Map(e);for(let[e,r]of t.decided)n.set(e,r);return n}function lt(e,t,n,r,i,a){if(i.pending){let{members:e,line:t}=i.pending;i.pending=null;let r=e.findIndex(e=>n[e]!==t);if(r>=0)return e.forEach((e,t)=>{t<r?i.decided.set(e,`written`):i.decided.delete(e)}),i.breakBefore.add(e[r]),!0}for(let o of ot(e,t,n,a)){if(o.members.every(e=>i.decided.has(e)))continue;let t=o.count>=3?`recite`:o.count===2&&a.twoSyllableRecitationsToPlain?`plain`:`written`,s=o.members.some(n=>{let i=e[n].notes;return et(i,r.get(n)??`written`)!==et(i,t)});for(let e of o.members)i.decided.set(e,t);if(s){let e=o.members[0],t=n[e];return e>0&&(n[e-1]??-1)<t&&i.breakBefore.add(e),i.pending={members:o.members,line:t},!0}}return!1}var ut=new Set(`€ŽžŸ¡¢£[¥¦©ª«¬¤`.split(``));function dt(e){return e.length===1&&ut.has(e)||e.length===2&&ft.has(e[0])&&ut.has(e[1])}var ft=new Set(`÷øaASÍYXCVBN$mÈÊËÌÎÏÐÑÒþßòôùý“”•–—˜™š›œº»`.split(``));function pt(e){let t=0;for(;;){let n=ft.has(e[t]??``)?1:p(e,t);if(n===0)return t;t+=n}}function mt(e){let{leading:t,core:n}=y(e),r=pt(n);return r===0?0:t.length+r}var ht=[`-`,`¨`];function gt(e){return`-`.repeat(Math.floor(e/3))+`¨`.repeat(e%3)}function _t(e,t,n=!0){let r=new Map;for(let i of e){if(!d(i))continue;let a=ee(i,vt(t));if(n&&r.has(a))throw Error(`Key "${e}" alters the pitch ${a} twice`);r.set(a,l(i).role)}return r}function vt(e){return e!==void 0&&h(e)?e:`M`}function yt(e){if(v.has(e))return;if(a(e,`smallHead`)!==void 0)return e;let t=l(e);if(!(!t||t.role===`smallPoint`||d(e)))return t.base}function bt(e,t,n,r,i=[]){let o=``;for(let s of[e,...i]){let e=mt(s);for(let i=0;i<s.length;i++){let l=s[i],u=yt(l),f=u===void 0?void 0:ee(u,vt(r)),p=f===void 0?void 0:n.get(f),m=i>0&&(d(s[i-1])||i===e);if(f!==void 0&&p!==t.get(f)&&!m){let e=p??`modifyNatural`,t=p?a(u,p):c(u);if(t===void 0)throw Error(`The note "${l}" has no ${e} glyph for the key change`);o.includes(t)||(o+=t)}}}let s=y(e).leading.length;return{notes:e.slice(0,s)+o+e.slice(s),inserted:[...o].map((e,t)=>s+t)}}function xt(e,t,n=0){return[...e].filter((e,r)=>!t.includes(r+n)).join(``)}var St=null;function Ct(e,t){return St||=document.createElement(`canvas`).getContext(`2d`),St.font=t,St.measureText(e).width}function wt(e,t){St||=document.createElement(`canvas`).getContext(`2d`),St.font=t;let n=St.measureText(e);return{left:n.actualBoundingBoxLeft,right:n.actualBoundingBoxRight}}var Tt=[`all-but-last`,`none`,`all`,`longest`],Et=[`glyph`,`line`],Dt=/([,:;]+)[-¨]*$/;function Ot(e,t){let n=e.seg.textWidth,r=e.lo+e.space,i=t-e.space-n,a=Math.max(e.center-n/2,r);a>i&&(a=r<=i?i:Math.max(e.lo,(e.lo+t-n)/2)),e.seg.textStart=a}var kt=e=>e.runs.length===1&&e.runs[0].marks.includes(`star`);function At(e){let t=typeof e==`string`||e instanceof j?[e]:e;if(t.length===0)throw Error(`Nothing to lay out: no script given`);let n=t.map(e=>(typeof e==`string`?new j(e):e).tokens),[r]=n;for(let[e,t]of n.entries())if(!(t.length===r.length&&t.every((e,t)=>{let n=r[t];return e.kind===n.kind&&(e.kind!==`syllable`||e.notes===n.notes)})))throw Error(`Stacked underlay ${e+1} does not share the first one's notes`);return n}function jt(e){return!!(e.held||e.empty)}async function Mt(e,t={}){let n={twoSyllableRecitationsToPlain:t.twoSyllableRecitationsToPlain??!0,plainRunsToRecitation:t.plainRunsToRecitation??!1},{syllables:r,pitchBreaks:i}=tt(At(e));if(!at(r,n))return(await Ft(e,t,Pt)).result;let a=it(r,i,n),o=st();for(let i=0;;i++){let s=ct(a,o),c=await Ft(e,t,{notes:Nt(r.map(e=>e.notes),s),breakBefore:o.breakBefore});if(i>4*r.length+8||!lt(r,c.placedNotes,c.sylLines,s,o,n))return c.result}}function Nt(e,t){let n=new Map;for(let[r,i]of t){let t=$e(e[r],i);t!==e[r]&&n.set(r,t)}return n}var Pt={notes:new Map,breakBefore:new Set};async function Ft(e,t,n){let r=new Set,i=new Set;for(;;){let a=await It(e,t,r,n),o=a.splitRuns.filter(e=>!i.has(e.run));if(o.length===0)return a;let s=o.reduce((e,t)=>t.run<e.run?t:e);r.has(s.run)||s.atLineStart?(i.add(s.run),s.nested?r.add(s.run):r.delete(s.run)):r.add(s.run)}}async function It(e,t,n,r=Pt){let{style:i=`BNS`,marks:a,bold:o=!1,textPx:s=18,notesPx:c=s*2,maxWidthPx:l=1/0,junctionDashes:u=3,staffFill:f=`all-but-last`,staffFillSnapPx:p=0,paddingPx:m,clefMark:g=`glyph`,textFont:_,notesLetterSpacingPx:ee=0,starUnderBar:te=!0,cutEmptySlots:ne=!0}=t;if(!Tt.includes(f))throw Error(`Unknown staffFill: "${f}"`);if(!(p>=0&&Number.isFinite(p)))throw Error(`staffFillSnapPx must be zero or more: ${p}`);if(m!==void 0&&!(m>=0&&Number.isFinite(m)))throw Error(`paddingPx must be zero or more: ${m}`);if(!Et.includes(g))throw Error(`Unknown clefMark: "${g}"`);let b=Math.round(u*3);if(!(u>=1&&Math.abs(u-b/3)<=.01))throw Error(`junctionDashes must be at least 1, in steps of a third: ${u}`);let re=gt(b),ie=gt(Math.max(3,b-3)),x=At(e),S=typeof e==`string`||e instanceof j?typeof e==`string`?new j(e):e:typeof e[0]==`string`?new j(e[0]):e[0],C=Me(i);if(!C)throw Error(`Unknown style set: "${i}"`);let w=m??C.padding??0,ae=g===`line`?w:0,T=ae>0?-ae:0,E=l===1/0?1/0:Math.max(0,l-w-ae);for(let e of Ye(C,s)){try{await document.fonts.load(e)}catch{}if(!document.fonts.check(e))throw Error(`Font could not be loaded: ${e} (style "${i}")`)}let oe=`400 ${c}px ${C.notesFontStack}`,D=e=>Ct(e,oe)+ee*e.length,se=Ke(C,_),O=qe({weight:o?`700`:`400`},s,se),ce=e=>Ue(e,C,o,a),le=e=>e.reduce((e,t)=>e+Ct(We(t),qe(t.style,s,se)),0),k=D(`-`),ue=Ct(`-`,O),de=e=>{if(!e)return{width:ue};let t=ce([{text:`-`,marks:e}]);return{parts:t,width:le(t)}},A=S.clef?.[0],fe=[...(S.clef??``).slice(1)].filter(d).join(``),pe=S.clef,me=e=>g===`line`&&e?[...e].filter(e=>!h(e)).join(``):e??``,he=e=>me(e)?`${me(e)}-`:``,ge=()=>A?[{at:0,clef:A}]:[],_e=e=>[...e].length,M=_t(fe,A,!1),N=M,P=x.map(e=>{let t=e.filter(e=>e.kind===`syllable`);return{syls:t,lastTextSyl:t.reduce((e,t,n)=>jt(t)?e:n,-1),cursor:0,pending:[],prevWordEnd:void 0,hyphen:{width:ue}}}),F=[],I,L,R,z=!1,B,V=!1,ve=(e,t,n)=>{let r=I.clefPrefix.length+I.notesParts.reduce((e,t)=>e+t.length,0)+t.length;I.groups.push({syllable:e,from:r-n.length,to:r}),I.notesParts.push(t);for(let e of P)e.mark&&I.texts.includes(e.mark.text)&&(e.mark.inline=!0);let i=n.match(Dt);if(i){let e=I.clefPrefix+I.notesParts.join(``),t=e.length-i[0].length,n=i[1],r=D(e.slice(0,t)),{left:a,right:o}=wt(n,oe);H={line:I,center:r+(o-a)/2}}else H=null},H=null,U=()=>{I&&(P.forEach((e,t)=>{I.texts[t].textCursor=e.cursor}),I.notesEnd=I.notesParts.length?D(I.clefPrefix+I.notesParts.join(``)):0);let e=P.map(()=>({segments:[],textCursor:0,lastWordEnd:null}));I={clefPrefix:he(pe),notesParts:[],segments:e[0].segments,textCursor:0,notesEnd:0,staffEnd:0,lastWordEnd:null,texts:e,clefs:ge(),groups:[]},F.push(I),L=I.clefPrefix;for(let e of P){if(e.cursor=T,e.mark&&!e.mark.inline){let t=e.mark.text.segments;t.splice(t.indexOf(e.mark.seg),1),e.carry=e.mark.seg}e.mark=void 0}R=!1,V=!1,z=!1,N=M,B&&B.inserted.length>0&&(B.notes=xt(B.notes,B.inserted),B.inserted=[],B.first&&(G[B.i]=B.notes))};U();let ye=x[0],be=e=>P.every(t=>t.syls[e].held),W=[],xe=0,Se,Ce=0,we=!1;for(let e of ye)if(e.kind!==`syllable`)W.push(e),Se=void 0,(e.kind===`tight`||e.kind===`unit`)&&(Ce=Math.max(0,Ce+(e.on?1:-1)),Ce===0&&(we=!1));else{let t=xe++,n={kind:`syl`,syl:e,i:t,notes:r.notes.get(t)??e.notes,inserted:[],first:!0,lastSeg:!0,heldRun:[],signedByRun:!1,tightJoin:we};e.notes!==``&&(we=Ce>0),be(n.i)&&Se?(Se.heldRun.push(e.notes),n.signedByRun=!0):Se=n,W.push(n)}let G=[],K=(e,t,n)=>{let r=mt(e);for(let i=e.length-1;i>=r&&i>0;i--){if(!ht.includes(e[i]))continue;let r=i+1;for(;r<e.length&&v.has(e[r]);)r++;if(!(r>=e.length)&&n(e.slice(0,r))<=t)return i}return-1},Te=(e,t)=>{let n=e.notes,r=t+1;for(;r<n.length&&v.has(n[r]);)r++;e.notes=n.slice(0,t)+n.slice(t+1,r);let i=xt(n.slice(r),e.inserted,r);return e.inserted=e.inserted.filter(e=>e<t),i},Ee=(e,t,n)=>{e.lastSeg=!1,W.splice(t+1,0,{kind:`syl`,syl:e.syl,i:e.i,notes:n,inserted:[],first:!1,lastSeg:!0,heldRun:[],signedByRun:!1,tightJoin:!1}),q=!0},De=e=>{P.forEach((t,n)=>{for(;t.pending.length>0;){let r=t.pending[0];if(t.cursor>T&&t.cursor+r.textWidth+(r.wordEnd?0:r.hyphen.width)>E){U();continue}t.pending.shift();let i=I.texts[n];i.segments.push({kind:`syl`,syllable:r.syllable,parts:r.sylParts,textStart:t.cursor,textWidth:r.textWidth,contentWidth:0,contentStart:0,extraDashes:0,tight:!1,noNotes:!0,...e&&t.pending.length===0?{trailing:!0}:{}}),t.cursor+=r.textWidth,r.spaceWidth>0&&(i.segments.push({kind:`word-space`,width:r.spaceWidth}),t.cursor+=r.spaceWidth),i.lastWordEnd=r.wordEnd,i.hyphen=r.hyphen,t.hyphen=r.hyphen,i.textCursor=t.cursor}})},q=!1,Oe=0,J=[],ke=[],Ae=()=>{let e=J.pop();e&&F.length-1>e.line&&ke.push(e)},je=[],Ne=-1,Pe=()=>{Ne>=0&&(je[Ne]=F.length-1),Ne=-1},Y=0;for(;Y<W.length;){Pe();let e=W[Y],t=H;if(H=null,e.kind===`break`){(I.texts.some(e=>e.segments.length>0)||P.some(e=>e.pending.length>0))&&(De(!1),q=!0),Y++;continue}if(e.kind===`tight`||e.kind===`aid`){Y++;continue}if(e.kind===`keep`||e.kind===`unit`){if(!e.on)Ae();else{let e=I.texts.some(e=>e.segments.length>0)||P.some(e=>e.pending.length>0);n.has(Oe)&&e&&(De(!1),q=!0),J.length>0&&(J[J.length-1].nested=!0),J.push({run:Oe++,line:q?F.length:F.length-1,atLineStart:!e||q,nested:!1})}Y++;continue}if(e.kind===`clef`||e.kind===`key`){if(e.kind===`clef`&&(A=e.clef),fe=e.key,pe=(A??``)+fe,M=_t(fe,A),!q){if(I.notesParts.length===0)I.clefPrefix=he(pe),I.clefs=ge(),L=I.clefPrefix,N=M;else if(e.kind===`clef`){let e=me(pe),t=e?(R?ie:re)+e+`-`:``;t&&D(L+t)>E?q=!0:(A&&I.clefs.push({at:_e(L),clef:A}),t&&(I.notesParts.push(t),L+=t,z=!0,R=!1,V=!1),N=M)}}Y++;continue}let i=e.syl,a=e.i;if(e.first&&(Ne=a),e.first&&r.breakBefore.has(a)&&(I.texts.some(e=>e.segments.length>0)||P.some(e=>e.pending.length>0))&&(De(!1),q=!0),q&&=(U(),!1),B=e,N!==M&&!e.signedByRun){let t=bt(e.notes,N,M,A,e.first?e.heldRun:[]);e.notes=t.notes,e.inserted=t.inserted}e.first&&(G[a]=e.signedByRun&&N!==M?bt(e.notes,N,M,A).notes:e.notes);let o=P.map(t=>{let n=t.syls[a],r=e.lastSeg&&a>=t.lastTextSyl,i=ce(e.first?n.runs:[]);return{t,own:n,sylParts:i,textWidth:le(i),spaceWidth:!r&&n.wordEnd?Ct(` `,O):0,pendingTotal:t.pending.reduce((e,t)=>e+t.textWidth+t.spaceWidth,0)}}),s=dt(e.notes);if(i.empty&&e.notes.length===0){Y++;continue}if(e.notes.length===0){let n=te&&t?.line===I?t:null;for(let t of o)if(!t.own.empty){if(n&&kt(t.own)){let r=I.texts[P.indexOf(t.t)],i=r.segments.findLast(e=>e.kind===`syl`),a=i?i.textStart+i.textWidth:T,o={kind:`mark`,syllable:e.i,parts:t.sylParts,textStart:Math.max(n.center-t.textWidth/2,t.t.cursor),textWidth:t.textWidth,flowPx:t.t.cursor};r.segments.push(o),t.t.mark={seg:o,text:r,lo:a,space:Math.max(0,t.t.cursor-a),center:n.center};continue}t.t.pending.push({syllable:e.i,sylParts:t.sylParts,textWidth:t.textWidth,spaceWidth:t.spaceWidth,wordEnd:t.own.wordEnd,hyphen:de(t.own.hyphen)})}Y++;continue}if(e.first&&e.lastSeg&&!i.empty&&i.runs.length===0&&y(e.notes).core===``){let t=L[L.length-1],n=t&&t!==`-`&&!R&&!i.notes.startsWith(`-`)?`-`:``;ve(e.i,n+i.notes,i.notes),L+=n+i.notes,R=!0,V=!1;for(let e of o)e.t.prevWordEnd=e.own.wordEnd;Y++;continue}let c=(e,t)=>{e.own.held?(t&&(I.texts[P.indexOf(e.t)].lastWordEnd=!0),e.t.prevWordEnd=e.own.wordEnd):e.t.prevWordEnd===void 0&&(e.t.prevWordEnd=!0)};if(e.first&&o.every(e=>jt(e.own))){let t=be(a),n=dt(e.notes);if(t&&n&&G[a-1]===G[a]&&I.notesParts.length>0&&!z){V=!0,Y++;continue}let r=y(e.notes),i=()=>I.notesParts.length===0||z?``:t?R?`--`:`-`:R||e.tightJoin||pt(r.core)>0?ie:re,s=i();if(I.notesParts.length>0&&D(L+s+e.notes)>E){let n=!t&&ne?K(e.notes,E,e=>D(L+s+e)):-1;if(n>=0&&n+1<e.notes.length){let t=Te(e,n);Ee(e,Y,t),r=y(e.notes)}else U(),s=i()}let l=I.notesParts.length===0;if(l&&D(L+e.notes)>E){let t=K(e.notes,E,e=>D(L+e));if(t>=0&&t+1<e.notes.length){let n=Te(e,t);Ee(e,Y,n),r=y(e.notes)}}if(P.some(e=>e.carry)){let e=pt(r.core);e===r.core.length&&(e=0);let t=D(L+s+r.leading+r.core.slice(0,e))-wt(r.core.slice(e),oe).left;P.forEach((e,n)=>{e.carry&&=(I.texts[n].segments.push({...e.carry,textStart:Math.max(T,t),flowPx:e.cursor}),void 0)})}ve(e.i,s+e.notes,e.notes),L+=s+e.notes;for(let e of o)c(e,l);z=!1,e.lastSeg&&(R=r.trailing.length>0,V=n),Y++;continue}let l=e.first?o.filter(e=>!jt(e.own)):o,u=G[a-1]!==e.notes,d=l.every(e=>e.t.cursor===T||e.t.cursor+e.pendingTotal+e.textWidth+(e.own.wordEnd?0:de(e.own.hyphen).width)<=E);if(s&&!u&&I.notesParts.length>0&&!d&&U(),!e.first){for(;!(D(L+e.notes)<=E);){let t=K(e.notes,E,e=>D(L+e));if(t<0||t+1>=e.notes.length)break;let n=Te(e,t);Ee(e,Y,n)}let t=y(e.notes);ve(e.i,e.notes,e.notes),L+=e.notes,e.lastSeg&&(R=t.trailing.length>0);for(let[e,t]of o.entries())I.texts[e].lastWordEnd=!0,t.t.prevWordEnd=t.own.wordEnd;e.lastSeg||(q=!0),Y++;continue}let f=y(e.notes),p=I.notesParts.length===0||z?``:R||e.tightJoin||pt(f.core)>0?ie:re;if(V){let e=/-*$/.exec(L)[0].length;p=s&&!u||e>/^-*/.exec(p)[0].length?``:p.slice(e)}let m=(e=0)=>{let t=pt(f.core);t===f.core.length&&(t=0);let n=f.core.slice(t),r=D(n),i=D(L+p+`-`.repeat(e)+f.leading+f.core.slice(0,t)),a=wt(n,oe);n.length>1&&(a.right+=ee*(n.length-1));let o=-a.left,c=(a.right-a.left)/2;return{contentWidth:r,contentStart:i,textStartOf:e=>r>=e||s?i+o:i+c-e/2}},h=m(),g={notes:e.notes,inserted:e.inserted,lastSeg:e.lastSeg,forceBreak:q,items:W.length},_=()=>{for(;;){let t=D(L+p+e.notes)>E,n=l.some(e=>h.textStartOf(e.textWidth)+e.textWidth+(e.own.wordEnd?0:de(e.own.hyphen).width)>E);if(!t&&!n)break;if(t){let t=K(e.notes,E,e=>D(L+p+e));if(t>=0&&t+1<e.notes.length){let n=Te(e,t);Ee(e,Y,n),f=y(e.notes),h=m();break}}if(I.notesParts.length===0&&P.every(e=>e.cursor===T)){if(t){let t=K(e.notes,E,e=>D(L+e));if(t>=0&&t+1<e.notes.length){let n=Te(e,t);e.notes=e.notes.slice(0,t),Ee(e,Y,n),f=y(e.notes),h=m()}}break}U(),p=``,f=y(e.notes),h=m()}};_();let v=e=>{let{t,textWidth:n}=e,{contentWidth:r}=h,i=I.notesParts.length>0&&!t.prevWordEnd&&e.pendingTotal===0,a=t.cursor+t.hyphen.width,o=t.cursor+e.pendingTotal+(V&&i?t.hyphen.width:0),s=h.textStartOf(n),c=h.contentStart,l=0,u=!1;if(!V&&i&&s<a&&(n>r||s<t.cursor)){u=!0,s=t.cursor;let e=r>=n?s:s+(n-r)/2;return e>c&&(l=Math.round((e-c)/k)),{textStart:s,contentStart:c,pads:l,tight:u,floor:t.cursor,minStart:a}}if(s<o){let e=r>=n?o:o+(n-r)/2;if(e>c){l=Math.max(0,Math.floor((e-c)/k));let t=m(l);for(;t.textStartOf(n)<o;)l++,t=m(l);s=t.textStartOf(n),c=t.contentStart}}return{textStart:s,contentStart:c,pads:l,tight:u,floor:o,minStart:a}},b=s&&!u&&I.notesParts.length>0&&!z,x,S=0;if(b){p=``,x=l.map(e=>{let t=e.t.cursor+e.pendingTotal;return{textStart:t,contentStart:h.contentStart,pads:0,tight:I.notesParts.length>0&&!e.t.prevWordEnd&&e.pendingTotal===0,floor:t,minStart:t}});let t=Math.max(...l.map((e,t)=>x[t].textStart+e.textWidth+e.spaceWidth))-D(L),n=E-D(L+p),r=t>0?Math.min(Math.ceil(t/k),Math.max(0,Math.floor(n/k))):0;e.notes=`-`.repeat(r),e.inserted=[],f=y(e.notes)}else{let t=()=>{if(x=l.map(v),S=Math.max(0,...x.map(e=>e.pads)),x.some(e=>e.pads<S)){let e=m(S);x=x.map((t,n)=>{if(t.pads===S)return t;let r=Math.max(e.textStartOf(l[n].textWidth),t.floor);return{...t,textStart:r,contentStart:e.contentStart,pads:S,tight:t.tight&&r<t.minStart}})}};if(t(),I.notesParts.length>0&&(D(L+p+`-`.repeat(S)+e.notes)>E||l.some((e,t)=>Math.max(x[t].textStart,e.t.cursor+e.pendingTotal)+e.textWidth+(e.own.wordEnd?0:de(e.own.hyphen).width)>E))){let n=W.length>g.items;n&&(W.splice(Y+1,W.length-g.items),e.notes=g.notes,e.inserted=g.inserted,e.lastSeg=g.lastSeg,q=g.forceBreak),U(),p=``,f=y(e.notes),h=m(),n&&_(),t()}}let C=p+`-`.repeat(S)+e.notes,w=I.notesParts.length===0;P.forEach((t,n)=>{let r=t.carry;if(!r)return;t.carry=void 0;let i=l.findIndex(e=>e.t===t),a=i>=0&&e.first?Math.max(T,x[i].textStart-l[i].pendingTotal-Ct(` `,O)-r.textWidth):m(S).textStartOf(0);I.texts[n].segments.push({...r,textStart:a,flowPx:t.cursor})}),l.forEach((t,n)=>{let{t:r,sylParts:i,textWidth:a,spaceWidth:o,pendingTotal:s}=t,c=I.texts[P.indexOf(r)],l=x[n],u=l.textStart;s>0&&u<r.cursor+s&&(u=r.cursor+s);let d=Math.max(0,u-s-r.cursor);if(w)c.segments.push({kind:`gap`,role:`lead-in`,width:d,endPx:u-s,textStartPx:u});else if(r.prevWordEnd)c.segments.push({kind:`gap`,role:`word-gap`,width:d,endPx:u-s,textStartPx:u});else if(!(s===0&&l.tight)&&s===0){let e=Math.max(0,(d-r.hyphen.width)/2);c.segments.push({kind:`connector`,pad:e,gapWidth:d,dashWidth:r.hyphen.width,...r.hyphen.parts?{parts:r.hyphen.parts}:{},dashStartPx:r.cursor+e,nextAnchorPx:u})}r.mark?.text===c&&Ot(r.mark,u-s),r.mark=void 0;let f=u-s;for(let e of r.pending)c.segments.push({kind:`syl`,syllable:e.syllable,parts:e.sylParts,textStart:f,textWidth:e.textWidth,contentWidth:0,contentStart:0,extraDashes:0,tight:!1,noNotes:!0}),f+=e.textWidth,e.spaceWidth>0&&(c.segments.push({kind:`word-space`,width:e.spaceWidth}),f+=e.spaceWidth);r.pending=[],c.segments.push({kind:`syl`,syllable:e.i,parts:i,textStart:u,textWidth:a,contentWidth:h.contentWidth,contentStart:l.contentStart,extraDashes:S,tight:l.tight,noNotes:!1}),o>0&&c.segments.push({kind:`word-space`,width:o}),r.cursor=u+a+o,c.lastWordEnd=t.own.wordEnd,r.prevWordEnd=t.own.wordEnd,r.hyphen=de(t.own.hyphen),c.hyphen=r.hyphen});for(let e of o)l.includes(e)||c(e,w);L+=C,ve(e.i,C,e.notes),z=!1,e.lastSeg&&(R=f.trailing.length>0,V=s),e.lastSeg||(q=!0),Y++}for(Pe(),De(!0);J.length>0;)Ae();P.forEach((e,t)=>{I.texts[t].textCursor=e.cursor}),I.notesEnd=I.notesParts.length?D(I.clefPrefix+I.notesParts.join(``)):0,F.forEach((e,t)=>{if(t!==F.length-1)for(let t of e.texts){if(t.lastWordEnd!==!1)continue;let n=t.hyphen??{width:ue},r=e.notesEnd>t.textCursor?Math.max(0,(e.notesEnd-t.textCursor-n.width)/2):0;t.segments.push({kind:`line-end-dash`,pad:r,dashWidth:n.width,...n.parts?{parts:n.parts}:{},dashStartPx:t.textCursor+r,trailEndPx:e.notesEnd,textEndPx:t.textCursor})}});for(let e of F)e.textCursor=e.texts[0].textCursor,e.lastWordEnd=e.texts[0].lastWordEnd;let Fe=E+w,Ie=D(`*`),Le=f===`all`&&E===1/0?`longest`:f,Re=Le===`all`||Le===`longest`,ze=Math.max(...F.map(e=>Math.max(e.notesEnd,...e.texts.map(e=>e.textCursor)))),Be=Le===`none`||E===1/0&&!Re?null:Le===`longest`&&E-ze>p?ze:E;return F.forEach((e,t)=>{let n=t===F.length-1;if(e.staffEnd=e.notesEnd,n&&(!Re||e.notesParts.length===0))return;if(Be===null){e.breakMarkerLeftPx=w;return}let r=Be+w,i=D(e.clefPrefix+e.notesParts.join(``));for(;n?i+k<=r:i+k<=r-Ie&&i+k<Be;)e.notesParts.push(`-`),i+=k;if(n){let t=D(`¨`);for(;i+t<=r;)e.notesParts.push(`¨`),i+=t}e.staffEnd=i,n||(e.breakMarkerLeftPx=r-i-Ie)}),{result:{lines:F,clefPrefix:F[0].clefPrefix,styleSet:C,styleName:i,textPx:s,notesPx:c,bold:o,maxWidthPx:E,starTarget:Fe,starWidth:Ie,clefMark:g,leftPaddingPx:ae,textFontStack:se},splitRuns:ke,placedNotes:G,sylLines:je}}var Lt=1e3,Rt=[[-8,7],[193,208],[392,407],[593,608],[793,808]],zt={" ":500,"!":74,'"':74,"#":372,$:252,"%":74,"&":372,"'":74,"(":74,")":74,"*":222,"+":74,",":144,"-":222,".":310,"/":74,0:222,1:222,2:222,3:222,4:222,5:222,6:222,7:222,8:222,9:222,":":114,";":222,"<":772,"=":74,">":372,"?":222,"@":372,A:252,B:252,C:252,D:15,E:15,F:15,G:15,H:15,I:15,J:15,K:15,L:15,M:772,N:252,O:15,P:15,Q:15,R:15,S:252,T:15,U:15,V:252,W:15,X:252,Y:252,Z:15,"[":491,"\\":0,"]":222,"^":222,_:773,"`":158,a:252,b:158,c:158,d:15,e:222,f:15,g:15,h:15,i:222,j:15,k:15,l:15,m:252,n:158,o:222,p:222,q:222,r:222,s:15,t:222,u:222,v:158,w:222,x:158,y:158,z:222,"{":723,"}":723,"~":143,"¡":491,"¢":491,"£":491,"¤":491,"¥":491,"¦":491,"§":74,"¨":69,"©":491,ª:491,"«":491,"¬":491,"­":74,"®":74,"¯":143,"°":15,"±":15,"²":15,"³":15,"´":15,µ:15,"·":15,"¸":15,"¹":15,º:252,"»":252,"¼":74,"½":15,"¾":15,"¿":222,À:222,Á:15,Â:222,Ã:222,Ä:222,Å:222,Æ:222,Ç:222,È:252,É:15,Ê:252,Ë:252,Ì:252,Í:252,Î:252,Ï:252,Ð:252,Ñ:252,Ò:252,Ó:74,Ô:15,Õ:15,Ö:74,"×":15,Ø:15,Ù:15,Ú:15,Û:15,Ü:74,Ý:15,Þ:15,ß:252,à:222,á:15,â:222,ã:222,ä:222,å:222,æ:222,ç:222,è:222,é:15,ê:222,ë:222,ì:222,í:158,î:222,ï:222,ð:222,ñ:222,ò:252,ó:222,ô:252,õ:222,ö:222,"÷":252,ø:252,ù:252,ú:222,û:15,ü:222,ý:252,þ:252,ÿ:74,Œ:143,œ:252,Š:143,š:252,Ÿ:491,Ž:491,ž:491,ƒ:143,ˆ:143,ˉ:143,"˜":252,μ:15,"‐":222,"–":252,"—":252,"‘":143,"’":143,"‚":143,"“":252,"”":252,"„":143,"†":143,"‡":143,"•":252,"…":143,"‰":143,"‹":143,"›":252,"€":491,"™":252,"−":74,"∙":15},Bt={"!":[[0,0,131],[1,-35.4,131],[2,0,131],[3,0,131],[4,0,131]],'"':[[0,-35.3,131],[1,0,131],[2,0,131],[3,0,131],[4,0,131]],"#":[[0,3,404],[1,3,404],[2,3,404],[3,3,404],[4,3,404]],$:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],"%":[[0,0,131],[1,0,131],[2,0,131],[3,0,131],[4,0,131]],"&":[[0,3,404],[1,3,404],[2,3,404],[3,3,404],[4,3,404]],"'":[[0,0,131],[1,0,131],[2,0,131],[3,0,131],[4,0,131]],"(":[[0,0,131],[1,0,131],[2,0,131],[3,-35.4,131],[4,0,131]],")":[[0,0,131],[1,0,131],[2,0,131],[3,0,131],[4,0,131]],"*":[[0,-1110,223],[1,-1110,223],[2,-1110,223],[3,-1110,223],[4,-1110,223]],"+":[[0,0,131],[1,0,131],[2,0,131],[3,0,131],[4,0,131]],",":[[0,-30,169],[1,-30,169],[2,-30,169],[3,-30,169],[4,-30,169]],"-":[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],".":[[0,-61,310],[1,-61,310],[2,-61,310],[3,-61,310],[4,-61,310]],"/":[[0,0,131],[1,0,131],[2,-35.3,131],[3,0,131],[4,0,131]],0:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],1:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],2:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],3:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],4:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],5:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],6:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],7:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],8:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],9:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],":":[[0,-60,171],[1,-60,171],[2,-60,171],[3,-60,171],[4,-60,171]],";":[[0,-72,270],[1,-72,270],[2,-72,270],[3,-72,270],[4,-72,270]],"<":[[0,0,841],[1,0,841],[2,0,841],[3,0,841],[4,0,841]],"=":[[0,0,131],[1,0,131],[2,0,131],[3,0,131],[4,0,131]],">":[[0,3,404],[1,3,404],[2,3,404],[3,3,404],[4,3,404]],"?":[[0,-70,222],[1,-70,222],[2,-70,222],[3,-70,222],[4,-70,222]],"@":[[0,3,404],[1,3,404],[2,3,404],[3,3,404],[4,3,404]],A:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],B:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],C:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],D:[[0,-7.1,81],[1,0,81],[2,0,81],[3,0,81],[4,0,81]],E:[[0,0,81],[1,0,81],[2,0,81],[3,0,81],[4,0,81]],F:[[0,0,81],[1,-8.6,81],[2,0,81],[3,0,81],[4,0,81]],G:[[0,0,81],[1,-7.1,81],[2,0,81],[3,0,81],[4,0,81]],H:[[0,0,81],[1,0,81],[2,-8.6,81],[3,0,81],[4,0,81]],I:[[0,0,81],[1,0,81],[2,0,81],[3,-9.1,81],[4,0,81]],J:[[0,0,81],[1,0,81],[2,-7.1,81],[3,0,81],[4,0,81]],K:[[0,0,81],[1,0,81],[2,0,81],[3,-8.6,81],[4,0,81]],L:[[0,0,81],[1,0,81],[2,0,81],[3,-7.1,81],[4,0,81]],M:[[0,0,841],[1,0,841],[2,0,841],[3,0,841],[4,0,841]],N:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],O:[[0,0,81],[1,0,81],[2,0,81],[3,0,81],[4,0,81]],P:[[0,0,81],[1,0,81],[2,0,81],[3,0,81],[4,-9.1,81]],Q:[[0,0,81],[1,0,81],[2,0,81],[3,0,81],[4,0,81]],R:[[0,0,81],[1,-9.1,81],[2,0,81],[3,0,81],[4,0,81]],S:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],T:[[0,0,81],[1,0,81],[2,0,81],[3,0,81],[4,0,81]],U:[[0,0,81],[1,0,81],[2,0,81],[3,0,81],[4,0,81]],V:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],W:[[0,-9.1,81],[1,0,81],[2,0,81],[3,0,81],[4,0,81]],X:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],Y:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],Z:[[0,0,81],[1,0,81],[2,-9.1,81],[3,0,81],[4,0,81]],"[":[[0,0,571],[1,0,571],[2,0,571],[3,0,571],[4,0,571]],"]":[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],"^":[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],_:[[0,0,801],[1,0,801],[2,0,801],[3,0,801],[4,0,801]],"`":[[0,0,221],[1,0,221],[2,0,221],[3,0,221],[4,0,221]],a:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],b:[[0,0,221],[1,0,221],[2,0,221],[3,0,221],[4,0,221]],c:[[0,0,221],[1,0,221],[2,0,221],[3,0,221],[4,0,221]],d:[[0,-3.7,81],[1,0,81],[2,0,81],[3,0,81],[4,0,81]],e:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],f:[[0,0,81],[1,-9,81],[2,0,81],[3,0,81],[4,0,81]],g:[[0,0,81],[1,-3.8,81],[2,0,81],[3,0,81],[4,0,81]],h:[[0,0,81],[1,0,81],[2,-9,81],[3,0,81],[4,0,81]],i:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],j:[[0,0,81],[1,0,81],[2,-3.7,81],[3,0,81],[4,0,81]],k:[[0,0,81],[1,0,81],[2,0,81],[3,-9,81],[4,0,81]],l:[[0,0,81],[1,0,81],[2,0,81],[3,-3.8,81],[4,0,81]],m:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],n:[[0,0,221],[1,0,221],[2,0,221],[3,0,221],[4,0,221]],o:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],p:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],q:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],r:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],s:[[0,-9,81],[1,0,81],[2,0,81],[3,0,81],[4,0,81]],t:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],u:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],v:[[0,0,221],[1,0,221],[2,0,221],[3,0,221],[4,0,221]],w:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],x:[[0,0,221],[1,0,221],[2,0,221],[3,0,221],[4,0,221]],y:[[0,0,221],[1,0,221],[2,0,221],[3,0,221],[4,0,221]],z:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],"{":[[0,0,801],[1,0,801],[2,0,801],[3,0,801],[4,0,801]],"}":[[0,0,801],[1,0,801],[2,0,801],[3,0,801],[4,0,801]],"~":[[0,0,201],[1,0,201],[2,0,201],[3,0,201],[4,0,201]],"¡":[[0,0,571],[1,0,571],[2,0,571],[3,0,571],[4,0,571]],"¢":[[0,0,571],[1,0,571],[2,0,571],[3,0,571],[4,0,571]],"£":[[0,0,571],[1,0,571],[2,0,571],[3,0,571],[4,0,571]],"¤":[[0,0,571],[1,0,571],[2,0,571],[3,0,571],[4,0,571]],"¥":[[0,0,571],[1,0,571],[2,0,571],[3,0,571],[4,0,571]],"¦":[[0,0,571],[1,0,571],[2,0,571],[3,0,571],[4,0,571]],"§":[[0,0,131],[1,0,131],[2,0,131],[3,0,131],[4,0,131]],"¨":[[0,0,111],[1,0,111],[2,0,111],[3,0,111],[4,0,111]],"©":[[0,0,571],[1,0,571],[2,0,571],[3,0,571],[4,0,571]],ª:[[0,0,571],[1,0,571],[2,0,571],[3,0,571],[4,0,571]],"«":[[0,0,571],[1,0,571],[2,0,571],[3,0,571],[4,0,571]],"¬":[[0,0,571],[1,0,571],[2,0,571],[3,0,571],[4,0,571]],"­":[[0,0,131],[1,0,131],[2,0,131],[3,0,131],[4,0,131]],"®":[[0,0,131],[1,0,131],[2,0,131],[3,0,131],[4,0,131]],"¯":[[0,0,201],[1,0,201],[2,0,201],[3,0,201],[4,0,201]],"°":[[0,-8.8,81],[1,0,81],[2,0,81],[3,0,81],[4,0,81]],"±":[[0,-2.4,81],[1,-9.1,81],[2,0,81],[3,0,81],[4,0,81]],"²":[[0,0,81],[1,-8.9,81],[2,0,81],[3,0,81],[4,0,81]],"³":[[0,0,81],[1,-2.5,81],[2,-9.2,81],[3,0,81],[4,0,81]],"´":[[0,0,81],[1,0,81],[2,-8.8,81],[3,0,81],[4,0,81]],µ:[[0,0,81],[1,0,81],[2,-2.5,81],[3,-9.1,81],[4,0,81]],"·":[[0,0,81],[1,0,81],[2,0,81],[3,-8.8,81],[4,0,81]],"¸":[[0,0,81],[1,0,81],[2,0,81],[3,0,81],[4,-8.8,81]],"¹":[[0,0,81],[1,0,81],[2,0,81],[3,0,81],[4,-2.5,81]],º:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],"»":[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],"¼":[[0,-35.3,131],[1,0,131],[2,0,131],[3,0,131],[4,0,131]],"½":[[0,-9.2,81],[1,0,81],[2,0,81],[3,0,81],[4,0,81]],"¾":[[0,0,81],[1,0,81],[2,0,81],[3,-2.5,81],[4,-9.1,81]],"¿":[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],À:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],Á:[[0,0,81],[1,0,81],[2,0,81],[3,0,81],[4,-7.1,81]],Â:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],Ã:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],Ä:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],Å:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],Æ:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],Ç:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],È:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],É:[[0,0,81],[1,0,81],[2,0,81],[3,0,81],[4,-8.6,81]],Ê:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],Ë:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],Ì:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],Í:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],Î:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],Ï:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],Ð:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],Ñ:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],Ò:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],Ó:[[0,0,131],[1,0,131],[2,0,131],[3,0,131],[4,0,131]],Ô:[[0,0,81],[1,0,81],[2,0,81],[3,0,81],[4,0,81]],Õ:[[0,0,81],[1,0,81],[2,0,81],[3,0,81],[4,0,81]],Ö:[[0,0,131],[1,0,131],[2,0,131],[3,0,131],[4,-35.4,131]],"×":[[0,0,81],[1,0,81],[2,0,81],[3,0,81],[4,0,81]],Ø:[[0,0,81],[1,0,81],[2,0,81],[3,0,81],[4,0,81]],Ù:[[0,-8.6,81],[1,0,81],[2,0,81],[3,0,81],[4,0,81]],Ú:[[0,0,81],[1,0,81],[2,0,81],[3,0,81],[4,0,81]],Û:[[0,0,81],[1,0,81],[2,0,81],[3,0,81],[4,0,81]],Ü:[[0,0,131],[1,0,131],[2,0,131],[3,0,131],[4,0,131]],Ý:[[0,0,81],[1,0,81],[2,0,81],[3,0,81],[4,0,81]],Þ:[[0,0,81],[1,0,81],[2,0,81],[3,0,81],[4,0,81]],ß:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],à:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],á:[[0,0,81],[1,0,81],[2,0,81],[3,0,81],[4,-3.8,81]],â:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],ã:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],ä:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],å:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],æ:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],ç:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],è:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],é:[[0,0,81],[1,0,81],[2,0,81],[3,0,81],[4,-9,81]],ê:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],ë:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],ì:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],í:[[0,0,221],[1,0,221],[2,0,221],[3,0,221],[4,0,221]],î:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],ï:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],ð:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],ñ:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],ò:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],ó:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],ô:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],õ:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],ö:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],"÷":[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],ø:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],ù:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],ú:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],û:[[0,0,81],[1,0,81],[2,0,81],[3,0,81],[4,0,81]],ü:[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],ý:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],þ:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],ÿ:[[0,0,131],[1,0,131],[2,0,131],[3,0,131],[4,0,131]],Œ:[[0,0,201],[1,0,201],[2,0,201],[3,0,201],[4,0,201]],œ:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],Š:[[0,0,201],[1,0,201],[2,0,201],[3,0,201],[4,0,201]],š:[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],Ÿ:[[0,0,571],[1,0,571],[2,0,571],[3,0,571],[4,0,571]],Ž:[[0,0,571],[1,0,571],[2,0,571],[3,0,571],[4,0,571]],ž:[[0,0,571],[1,0,571],[2,0,571],[3,0,571],[4,0,571]],ƒ:[[0,0,201],[1,0,201],[2,0,201],[3,0,201],[4,0,201]],ˆ:[[0,0,201],[1,0,201],[2,0,201],[3,0,201],[4,0,201]],ˉ:[[0,0,201],[1,0,201],[2,0,201],[3,0,201],[4,0,201]],"˜":[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],μ:[[0,0,81],[1,0,81],[2,-2.5,81],[3,-9.1,81],[4,0,81]],"‐":[[0,0,291],[1,0,291],[2,0,291],[3,0,291],[4,0,291]],"–":[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],"—":[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],"‘":[[0,0,201],[1,0,201],[2,0,201],[3,0,201],[4,0,201]],"’":[[0,0,201],[1,0,201],[2,0,201],[3,0,201],[4,0,201]],"‚":[[0,0,201],[1,0,201],[2,0,201],[3,0,201],[4,0,201]],"“":[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],"”":[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],"„":[[0,0,201],[1,0,201],[2,0,201],[3,0,201],[4,0,201]],"†":[[0,0,201],[1,0,201],[2,0,201],[3,0,201],[4,0,201]],"‡":[[0,0,201],[1,0,201],[2,0,201],[3,0,201],[4,0,201]],"•":[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],"…":[[0,0,201],[1,0,201],[2,0,201],[3,0,201],[4,0,201]],"‰":[[0,0,201],[1,0,201],[2,0,201],[3,0,201],[4,0,201]],"‹":[[0,0,201],[1,0,201],[2,0,201],[3,0,201],[4,0,201]],"›":[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],"€":[[0,0,571],[1,0,571],[2,0,571],[3,0,571],[4,0,571]],"™":[[0,0,301],[1,0,301],[2,0,301],[3,0,301],[4,0,301]],"−":[[0,0,131],[1,0,131],[2,0,131],[3,0,131],[4,0,131]],"∙":[[0,0,81],[1,0,81],[2,0,81],[3,-8.8,81],[4,0,81]]},Vt=`'Guidohu Staffless'`,X=Rt.length,Ht={connectOneDown:1,connectTwoDown:2,connectThreeDown:3,connectFourDown:4};function Ut(e){let t=g.indexOf(e);if(t>=0)return[t-4];let n=l(e);if(!n)return[];let r=g.indexOf(n.base)-4,i=Ht[n.role];return i?[r,r-i]:[r]}function Wt(e,t=X){let n=(X-1)*2,r=Math.min(X,Math.max(1,Math.round(t)));if(r===X)return{lo:0,hi:X-1};let i=1/0,a=-1/0,o=(e,t)=>{i=Math.min(i,Math.max(0,Math.min(n,e))),a=Math.max(a,Math.max(0,Math.min(n,t)))};for(let t of e){for(let{clef:e}of t.clefs??[]){let t=m[e];t&&o((t.line-1)*2,(t.line-1)*2)}for(let e of t.clefPrefix+t.notesParts.join(``)){let t=m[e];if(t){o((t.line-1)*2,(t.line-1)*2);continue}for(let t of Ut(e))t%2==0?o(t,t):o(t+1,t-1)}}let s=(r-1)*2;if(a===-1/0)return{lo:0,hi:r-1};let c=Math.max(0,a-s);return c<=Math.min(i,n-s)?{lo:c/2,hi:(c+s)/2}:{lo:Math.min(i,a)/2,hi:Math.max(i,a)/2}}function Gt(e,t,n){let r=ee(g[e*2+4],t),i=m[t]?m[t].line-1:-1,a=n.staffClefLineColor===`none`?void 0:n.staffClefLineColor;return e===i&&a||r&&n.staffPitchColors?.[r]||n.staffLineColors?.[e]||n.staffColor||void 0}function Kt(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:1}function qt(e,t,n){let r=m[t]?m[t].line-1:-1;return Kt(n.staffWeight)*Kt(n.staffLineWeights?.[e])*(e===r?Kt(n.staffClefLineWeight):1)}function Jt(e){return e===void 0?``:typeof e==`string`?e:`${e.light}|${e.dark??``}`}function Yt(e,t,n,r={},i,a=[]){let o=t/Lt,s=[],c=0,l=`M`,u=(e,t)=>{for(let[i,a,c]of Bt[e]??[])i<n.lo||i>n.hi||s.push({line:i,left:t+a*o,right:t+c*o,color:Gt(i,l,r),weight:qt(i,l,r),...m[l]&&m[l].line-1===i?{clefLine:!0}:{}})},d=0;for(let t of e){for(let e of a)e.at===d&&(l=e.clef);m[t]&&(l=t),u(t,c),c+=(zt[t]??0)*o,d++}for(let e of a)e.at>=d&&(l=e.clef);i!==void 0&&u(`*`,c+i);let f=[];for(let e=n.lo;e<=n.hi;e++){let t=s.filter(t=>t.line===e).sort((e,t)=>e.left-t.left);for(let n of t){let t=f[f.length-1];if(t&&t.line===e&&n.left<=t.right+.5){if(Jt(n.color)===Jt(t.color)&&n.weight===t.weight&&!n.clefLine==!t.clefLine){t.right=Math.max(t.right,n.right);continue}if(n.right<=t.right)continue;t.right=Math.min(t.right,n.left),t.right<=t.left&&f.pop()}f.push({...n})}}let{start:p,end:h}=r.staffOverflow??{};if(Number.isFinite(p)||Number.isFinite(h))for(let e=n.lo;e<=n.hi;e++){let t=f.filter(t=>t.line===e),n=t[0],r=t[t.length-1];n&&Number.isFinite(p)&&(n.left=Math.min(n.left,p)),r&&Number.isFinite(h)&&(r.right=Math.max(r.right,h))}return f}var Xt=`position:relative;display:inline-block;width:0;height:0;vertical-align:baseline;user-select:none;pointer-events:none`;function Zt(e,t=`px`){let[n,r]=Rt[e.line],i=(r-n)*e.weight;return{left:`${e.left}${t}`,width:`${e.right-e.left}${t}`,bottom:`${((n+r)/2-i/2)/Lt}em`,height:`${i/Lt}em`}}function Qt(e){let t=document.createElement(`span`);t.className=`guidex-staff`,t.setAttribute(`aria-hidden`,`true`),t.style.cssText=Xt;for(let n of e){let e=document.createElement(`span`);e.className=`guidex-staff-line`,e.dataset.line=String(n.line+1),n.weight!==1&&(e.dataset.weight=String(n.weight)),n.clefLine&&(e.dataset.clefLine=``);let r=Zt(n);e.style.position=`absolute`,e.style.zIndex=`-1`,e.style.left=r.left,e.style.width=r.width,e.style.bottom=r.bottom,e.style.height=r.height;let i=n.color;if(i!==void 0){let t=typeof i==`string`?i:i.light,n=typeof i==`string`?i:i.dark??i.light;e.style.setProperty(`--guidex-staff-light`,t),e.style.setProperty(`--guidex-staff-dark`,n)}t.appendChild(e)}return t}function $t(e){let t=typeof devicePixelRatio==`number`&&devicePixelRatio>0?devicePixelRatio:1,n=[];for(let t of e.querySelectorAll(`.guidex-staff`)){if(!t.isConnected)continue;let e=parseFloat(getComputedStyle(t).fontSize);e&&n.push({anchor:t,baseline:t.getBoundingClientRect().bottom,fontPx:e})}for(let{anchor:e,baseline:r,fontPx:i}of n)for(let n of e.querySelectorAll(`.guidex-staff-line`)){let[e,a]=Rt[Number(n.dataset.line)-1],o=Number(n.dataset.weight??1)||1,s=Math.max(1,Math.round((a-e)*o/Lt*i*t))/t,c=r-(e+a)/2/Lt*i,l=Math.round((c-s/2)*t)/t;n.style.bottom=`auto`,n.style.top=`${l-r}px`,n.style.height=`${s}px`}}function en(e){return typeof CSS>`u`||typeof CSS.supports!=`function`||CSS.supports(`color`,e)}function tn(e,t=`staff color`){let n=e?.trim();if(!n)return;let r=n.split(`|`).map(e=>e.trim()),i=r.find(e=>e!==``&&!en(e));if(r.length>2||i!==void 0||!r[0]){console.warn(`[guidex] ignoring invalid ${t} "${n}"`);return}return r.length===2&&r[1]?{light:r[0],dark:r[1]}:r[0]}function nn(e,t=`clef line color`){return e?.trim().toLowerCase()===`none`?`none`:tn(e,t)}function rn(e){if(e?.trim())return e.split(`;`).slice(0,X).map((e,t)=>tn(e,`staff line ${t+1} color`))}function an(e){if(!e?.trim())return;let t={};for(let n of e.split(`;`)){if(!n.trim())continue;let e=/^\s*([a-g])\s*:(.*)$/i.exec(n),r=e?tn(e[2],`staff ${e[1].toLowerCase()} line color`):void 0;e||console.warn(`[guidex] ignoring invalid staff pitch color "${n.trim()}"`),e&&r!==void 0&&(t[e[1].toLowerCase()]=r)}return t}function on(e,t=`staff weight`){let n=e?.trim();if(!n)return;let r=Number(n);if(Number.isFinite(r)&&r>0)return r;console.warn(`[guidex] ignoring invalid ${t} "${n}"`)}function sn(e){if(e?.trim())return e.split(`;`).slice(0,X).map((e,t)=>on(e,`staff line ${t+1} weight`))}var cn=class e{script;constructor(e){let t=e=>typeof e==`string`?new j(e):e;this.script=typeof e==`string`||e instanceof j?t(e):e.map(t)}async render(t,n={}){let{debug:r=!1,sourceMap:i=!1}=n,a=n.staff!==`font`,o=await Mt(this.script,{...n,clefMark:a?n.clefMark:`glyph`}),{lines:s,styleSet:c,styleName:l,textPx:u,notesPx:d,bold:f,starWidth:p,leftPaddingPx:m}=o,h;if(a){await e.verifyStaffless(d);let t=o.clefMark===`line`?c.clefLine:void 0,r=n.staffOverflow;h={range:Wt(s,n.staffLines),options:{...n,staffClefLineColor:n.staffClefLineColor??t?.color,staffClefLineWeight:(n.staffClefLineWeight??1)*(t?.weight??1),staffOverflow:m>0?{...r,start:Math.min(r?.start??0,-m)}:r},family:`${Vt}, ${c.notesFontStack}`}}t.style.fontSize=`${u}px`,t.style.fontFamily=o.textFontStack,t.dataset.style=l,h?(t.dataset.staff=`drawn`,t.dataset.staffLines=`${h.range.hi-h.range.lo+1}`):(delete t.dataset.staff,delete t.dataset.staffLines);let g=e=>(m>0&&(e.style.paddingLeft=`${m}px`),e);t.replaceChildren(...s.flatMap(t=>[g(e.notesLine(t,d,p,r,h,i)),...t.texts.map(t=>e.textLine(t,u,f,r,i))])),h&&n.staffSnap!==!1&&t.isConnected&&$t(t)}static async verifyStaffless(e){let t=`400 ${e}px ${Vt}`;try{await document.fonts.load(t)}catch{}if(!document.fonts.check(t))throw Error(`Font could not be loaded: ${t} (drawn staff)`)}static notesLine(e,t,n,r,i,a=!1){let o=document.createElement(`div`);o.className=`guido`,o.style.fontSize=`${t}px`;let s=e.clefPrefix+e.notesParts.join(``);if(o.textContent=s,a&&(o.dataset.groups=e.groups.map(e=>`${e.syllable}:${e.from}:${e.to}`).join(` `)),i&&(o.style.fontFamily=i.family,o.style.isolation=`isolate`,o.prepend(Qt(Yt(s,t,i.range,i.options,e.breakMarkerLeftPx,e.clefs)))),e.breakMarkerLeftPx!==void 0){let t=document.createElement(`span`);t.className=`guido-break`,t.textContent=`*`,t.style.position=`relative`,t.style.left=`${e.breakMarkerLeftPx}px`,r&&(t.title=`line break at ${(e.staffEnd+e.breakMarkerLeftPx+n).toFixed(1)}px (staff filled to ${e.staffEnd.toFixed(1)}px)`),o.appendChild(t)}return o}static textLine(t,n,r,i,a=!1){let o=document.createElement(`p`);r&&(o.style.fontWeight=`700`);for(let r of t.segments)switch(r.kind){case`gap`:{let t=e.spacer(r.width);i&&(t.title=`${r.role===`lead-in`?`lead-in`:`word gap`} ${r.width.toFixed(1)}px → text ${r.textStartPx.toFixed(1)}`),o.appendChild(t);break}case`connector`:{let t=e.spacer(r.pad),a=e.dashSpan(r.parts,n),s=e.spacer(r.pad);i&&(t.title=`lead pad ${r.pad.toFixed(1)}px (gap ${r.gapWidth.toFixed(1)} − dash ${r.dashWidth.toFixed(1)}, halved)`,a.title=`dash ${r.dashWidth.toFixed(1)}px`,s.title=`trail pad ${r.pad.toFixed(1)}px`),o.append(t,a,s);break}case`syl`:{let t=e.sylSpan(r.parts,n);if(a&&(t.dataset.syl=String(r.syllable),r.noNotes||(t.dataset.notesStart=r.contentStart.toFixed(1),t.dataset.notesWidth=r.contentWidth.toFixed(1))),i){if(r.noNotes)t.title=`no notes, text w ${r.textWidth.toFixed(1)}, ${r.trailing?`end of score`:`before the next syllable with notes`}`;else{let e=(r.textWidth-r.contentWidth)/2,n=r.textStart-r.contentStart;t.title=[`text w ${r.textWidth.toFixed(1)}`,`notes w ${r.contentWidth.toFixed(1)}`,r.extraDashes?`+${r.extraDashes} pad dash(es)`:null,`text start ${r.textStart.toFixed(1)}`,`notes start ${r.contentStart.toFixed(1)}`,`theoDiff: ${e.toFixed(1)}`,`cursDiff: ${n.toFixed(1)}`].filter(Boolean).join(`, `)}}o.appendChild(t);break}case`mark`:{let t=document.createElement(`span`);t.className=`mark`,t.style.display=`inline-block`,t.style.width=`0`;let s=e.sylSpan(r.parts,n);s.style.position=`relative`,s.style.left=`${r.textStart-r.flowPx}px`,a&&(s.dataset.syl=String(r.syllable)),i&&(s.title=`star under the bar, text w ${r.textWidth.toFixed(1)}, start ${r.textStart.toFixed(1)}`),t.appendChild(s),o.appendChild(t);break}case`word-space`:{let e=document.createElement(`span`);e.className=`word-space`,e.textContent=` `,i&&(e.title=`word space ${r.width.toFixed(1)}px`),o.appendChild(e);break}case`line-end-dash`:{let t=e.spacer(r.pad),a=e.dashSpan(r.parts,n),s=e.spacer(r.pad);i&&(t.title=`lead pad ${r.pad.toFixed(1)}px → line-end dash (text end ${r.textEndPx.toFixed(1)}, notes end ${r.trailEndPx.toFixed(1)})`,a.title=`dash ${r.dashWidth.toFixed(1)}px (line end)`,s.title=`trail pad ${r.pad.toFixed(1)}px`),o.append(t,a,s);break}}return o}static dashSpan(e,t){let n=document.createElement(`span`);n.className=`dash`,n.textContent=`-`;let r=e?.[0]?.style;if(r)for(let[e,i]of Object.entries(Je(r,t)))n.style.setProperty(e,i);return n}static sylSpan(e,t){let n=document.createElement(`span`);return n.className=`syl`,e.forEach(e=>{let r=document.createElement(`span`);r.textContent=e.text;for(let[n,i]of Object.entries(Je(e.style,t)))r.style.setProperty(n,i);let i=[...e.kind?[e.kind]:[],...e.style.initial?[`initial`]:[]].join(` `);i&&(r.className=i),n.appendChild(r)}),n}static spacer(e){let t=document.createElement(`span`);return t.className=`spacer`,t.style.display=`inline-block`,t.style.width=`${e}px`,t}},ln={name:`guidex`,version:`0.6.0`,description:`Guidex — render plainchant scores from a compact GuidoScript notation, as a web app and an embeddable runtime`,type:`module`,workspaces:[`examples/*`],main:`./dist/lib/embed/manual.js`,types:`./dist/lib/embed/manual.d.ts`,exports:{".":{types:`./dist/lib/embed/manual.d.ts`,default:`./dist/lib/embed/manual.js`},"./embed":{types:`./dist/lib/embed/index.d.ts`,default:`./dist/lib/embed/index.js`},"./guidex.css":{types:`./dist/lib/guidex.css.d.ts`,default:`./dist/lib/guidex.css`},"./fonts/*":`./dist/lib/fonts/*`,"./react":{types:`./dist/lib/react/index.d.ts`,default:`./dist/lib/react/index.js`},"./word":{types:`./dist/lib/word/index.d.ts`,default:`./dist/lib/word/index.js`},"./aretino":{types:`./dist/lib/aretino/index.d.ts`,default:`./dist/lib/aretino/index.js`}},files:[`dist-embed`,`dist/lib`,`CHANGELOG.md`],peerDependencies:{"@aretino-chant/core":`>=0.29.0`,react:`>=18`},peerDependenciesMeta:{"@aretino-chant/core":{optional:!0},react:{optional:!0}},publishConfig:{access:`public`},scripts:{dev:`vite --host`,build:`tsc && vite build`,"build:embed":`vite build --config vite.embed.config.ts`,"build:lib":`vite build --config vite.lib.config.ts`,preview:`vite preview`,test:`vitest run`,lint:`eslint .`},keywords:[`plainchant`,`gregorian`,`guido`,`score`,`notation`,`liturgy`],repository:{type:`git`,url:`git+https://github.com/BrownieMaar/guidex.git`},bugs:{url:`https://github.com/BrownieMaar/guidex/issues`},homepage:`https://github.com/BrownieMaar/guidex#readme`,devDependencies:{"@aretino-chant/core":`0.29.0`,"@eslint/js":`^10.0.1`,"@testing-library/dom":`^10.4.2`,"@testing-library/react":`^16.3.3`,"@testing-library/user-event":`^14.6.7`,"@types/react":`^19.3.0`,"@types/react-dom":`^19.3.0`,"@vitejs/plugin-react":`^6.1.1`,eslint:`^10.10.0`,jsdom:`^29.1.1`,react:`^19.3.0`,"react-dom":`^19.3.0`,typescript:`~6.0.2`,"typescript-eslint":`^8.70.0`,vite:`^8.2.2`,"vite-plugin-dts":`^5.1.1`,vitest:`^4.1.11`}}.version,un=`.guidex-script, .guido-script`,Z={maxWidth:`auto`,style:`BNS`,marks:void 0,bold:!1,textPx:18,junctionDashes:3,staffFill:`all-but-last`,staffFillSnapPx:0,paddingPx:void 0,clefMark:`glyph`,textFont:void 0,twoSyllableRecitationsToPlain:!0,plainRunsToRecitation:!1,cutEmptySlots:!0,transpose:0,stanza:1,stack:void 0,emptySlots:`normal`,stanzas:void 0,debug:!1,staff:`drawn`,staffLines:5,staffColor:void 0,staffLineColors:void 0,staffPitchColors:void 0,staffWeight:void 0,staffLineWeights:void 0,staffClefLineWeight:void 0,staffClefLineColor:void 0,staffOverflow:void 0,staffSnap:!0},Q={},dn=new WeakMap,fn=new WeakMap,pn=new WeakMap;function mn(e){if(e!==void 0){if(e===``||e===`true`)return!0;if(e===`false`)return!1}}function $(e){if(e===void 0)return;let t=Number(e);return Number.isFinite(t)?t:void 0}function hn(e,t){if(/^auto$/i.test(e.trim()))return`auto`;let n=Number(e);return n>0?n:(console.warn(`[guidex] ignoring invalid data-max-width "${e}"`),t)}var gn=new WeakMap;function _n(e){if(e!==void 0){if(e===`normal`||e===`small`||e===`partial`)return e;console.warn(`[guidex] ignoring invalid data-empty-slots "${e}"`)}}function vn(e){if(e!==void 0){if(e===`glyph`||e===`line`)return e;console.warn(`[guidex] ignoring invalid data-clef-mark "${e}"`)}}function yn(e){if(e!==void 0){if(e===`all-but-last`||e===`none`||e===`all`||e===`longest`)return e;console.warn(`[guidex] ignoring invalid data-staff-fill "${e}"`)}}function bn(e){if(e!==void 0){if(e===`font`||e===`drawn`)return e;console.warn(`[guidex] ignoring invalid data-staff "${e}"`)}}function xn(e){if(e===void 0)return;if(/^\s*all\s*$/i.test(e))return`all`;let t=e.split(`,`).map(e=>Number(e.trim()));if(e.trim()!==``&&t.every(e=>Number.isInteger(e)&&e>0))return t;console.warn(`[guidex] ignoring invalid data-stack "${e}"`)}function Sn(e){let t=e.dataset,n=gn.get(e)??{},r=t.maxWidth===void 0?n.maxWidth??Q.maxWidth??Z.maxWidth:hn(t.maxWidth,n.maxWidth??Q.maxWidth??Z.maxWidth);return{marks:n.marks??Q.marks,maxWidth:r,style:t.style??n.style??Q.style??Z.style,bold:mn(t.bold)??n.bold??Q.bold??Z.bold,textPx:$(t.textPx)??n.textPx??Q.textPx??Z.textPx,junctionDashes:$(t.junctionDashes)??n.junctionDashes??Q.junctionDashes??Z.junctionDashes,staffFill:yn(t.staffFill)??n.staffFill??Q.staffFill??Z.staffFill,staffFillSnapPx:$(t.staffFillSnap)??n.staffFillSnapPx??Q.staffFillSnapPx??Z.staffFillSnapPx,paddingPx:$(t.padding)??n.paddingPx??Q.paddingPx??Z.paddingPx,clefMark:vn(t.clefMark)??n.clefMark??Q.clefMark??Z.clefMark,textFont:t.textFont?.trim()||n.textFont||Q.textFont||Z.textFont,twoSyllableRecitationsToPlain:mn(t.twoSyllableRecitationsToPlain)??n.twoSyllableRecitationsToPlain??Q.twoSyllableRecitationsToPlain??Z.twoSyllableRecitationsToPlain,plainRunsToRecitation:mn(t.plainRunsToRecitation)??n.plainRunsToRecitation??Q.plainRunsToRecitation??Z.plainRunsToRecitation,cutEmptySlots:mn(t.cutEmptySlots)??n.cutEmptySlots??Q.cutEmptySlots??Z.cutEmptySlots,transpose:$(t.transpose)??n.transpose??Q.transpose??Z.transpose,stanza:$(t.stanza)??n.stanza??Q.stanza??Z.stanza,stack:xn(t.stack)??n.stack??Q.stack??Z.stack,emptySlots:_n(t.emptySlots)??n.emptySlots??Q.emptySlots??Z.emptySlots,stanzas:n.stanzas??Z.stanzas,debug:mn(t.debug)??n.debug??Q.debug??Z.debug,staff:bn(t.staff)??n.staff??Q.staff??Z.staff,staffLines:$(t.staffLines)??n.staffLines??Q.staffLines??Z.staffLines,staffColor:tn(t.staffColor,`data-staff-color`)??n.staffColor??Q.staffColor,staffLineColors:rn(t.staffLineColors)??n.staffLineColors??Q.staffLineColors,staffPitchColors:an(t.staffPitchColors)??n.staffPitchColors??Q.staffPitchColors,staffWeight:on(t.staffWeight,`data-staff-weight`)??n.staffWeight??Q.staffWeight,staffLineWeights:sn(t.staffLineWeights)??n.staffLineWeights??Q.staffLineWeights,staffClefLineWeight:on(t.staffClefLineWeight,`data-staff-clef-line-weight`)??n.staffClefLineWeight??Q.staffClefLineWeight,staffClefLineColor:nn(t.staffClefLineColor,`data-staff-clef-line-color`)??n.staffClefLineColor??Q.staffClefLineColor,staffOverflow:t.staffOverflowStart!==void 0||t.staffOverflowEnd!==void 0?{start:$(t.staffOverflowStart),end:$(t.staffOverflowEnd)}:n.staffOverflow??Q.staffOverflow,staffSnap:mn(t.staffSnap)??n.staffSnap??Q.staffSnap??Z.staffSnap}}function Cn(e){let t=e.querySelector(`:scope > .guidex-render`);return t?.removeAttribute(`data-fixed-width`),t?.clientWidth||e.clientWidth||e.parentElement?.clientWidth||0}function wn(e,t){if(typeof t==`number`)return t;let n=Cn(e);return n>0?n:1/0}function Tn(e){for(let t of e.childNodes)if(t.nodeType===Node.TEXT_NODE&&t.nodeValue?.trim())return t.nodeValue.trim();return dn.get(e)??``}function En(e){let t=e.querySelector(`:scope > .guidex-render`);if(t)return t;let n=document.createElement(`div`);return n.className=`guidex-render`,e.replaceChildren(n),n}function Dn(e,t){let n=document.createElement(`p`);n.className=`guidex-error`,n.textContent=t,e.removeAttribute(`data-fixed-width`),e.replaceChildren(n)}function On(e){return e.transpose===0?[]:[Oe(e.transpose)]}function kn(e,t){let n=(e,n)=>({scripts:e,warnings:[...n,...e.flatMap(e=>Ze(e,t))]}),r=On(t),{stanzas:i,emptySlots:a}=t;if(t.stack!==void 0){let o=K(e,t.stack,{stanzas:i});return n(Te(e,o,{stanzas:i,emptySlots:a,transforms:r}),o.flatMap(t=>W(e,{stanzas:i,stanza:t})))}return(t.stanza!==1||a!==`normal`)&&r.unshift(we(t.stanza,{stanzas:i,emptySlots:a})),n([new j(e,{transforms:r})],W(e,{stanzas:i,stanza:t.stanza}))}async function An(e,t,n,r,i){let a=En(e),o=document.createElement(`div`);try{let{scripts:s,warnings:c}=kn(n,r);if(await new cn(s).render(o,{style:r.style,marks:r.marks,bold:r.bold,textPx:r.textPx,junctionDashes:r.junctionDashes,staffFill:r.staffFill,staffFillSnapPx:r.staffFillSnapPx,paddingPx:r.paddingPx,clefMark:r.clefMark,textFont:r.textFont,twoSyllableRecitationsToPlain:r.twoSyllableRecitationsToPlain,plainRunsToRecitation:r.plainRunsToRecitation,cutEmptySlots:r.cutEmptySlots,debug:r.debug,maxWidthPx:i,staff:r.staff,staffLines:r.staffLines,staffColor:r.staffColor,staffLineColors:r.staffLineColors,staffPitchColors:r.staffPitchColors,staffWeight:r.staffWeight,staffLineWeights:r.staffLineWeights,staffClefLineWeight:r.staffClefLineWeight,staffClefLineColor:r.staffClefLineColor,staffOverflow:r.staffOverflow,staffSnap:!1}),fn.get(e)!==t)return{warnings:c};for(let e of c)console.warn(`[guidex] ${e.message}`);a.replaceChildren(...o.childNodes),a.style.cssText=o.style.cssText,o.dataset.style&&(a.dataset.style=o.dataset.style);for(let e of[`staff`,`staffLines`])o.dataset[e]===void 0?delete a.dataset[e]:a.dataset[e]=o.dataset[e];return a.toggleAttribute(`data-fixed-width`,typeof r.maxWidth==`number`),o.dataset.staff===`drawn`&&r.staffSnap&&$t(a),{warnings:c}}catch(n){return fn.get(e)===t?(console.error(`[guidex]`,n),Dn(a,n instanceof Error?n.message:String(n)),{warnings:[]}):{warnings:[]}}}async function jn(e){let t=(fn.get(e)??0)+1;fn.set(e,t);let n=Sn(e),r=Tn(e);dn.set(e,r),En(e);let i=wn(e,n.maxWidth);pn.set(e,i),await An(e,t,r,n,i)}var Mn=new WeakMap;function Nn(e){let t=wn(e,Sn(e).maxWidth);return Math.abs(t-(pn.get(e)??NaN))>1}function Pn(e){if(Mn.has(e))return;let t;if(typeof ResizeObserver<`u`){let n=new ResizeObserver(()=>{Nn(e)&&jn(e)});n.observe(e),t=()=>n.disconnect()}else{let n=()=>{Nn(e)&&jn(e)};window.addEventListener(`resize`,n),t=()=>window.removeEventListener(`resize`,n)}let n=0,r=()=>{cancelAnimationFrame(n),n=requestAnimationFrame(()=>{let t=e.querySelector(`:scope > .guidex-render`);t?.dataset.staff===`drawn`&&Sn(e).staffSnap&&$t(t)})};window.addEventListener(`resize`,r);let i=t;t=()=>{i(),cancelAnimationFrame(n),window.removeEventListener(`resize`,r)},Mn.set(e,t)}function Fn(e){Mn.get(e)?.(),Mn.delete(e),dn.delete(e),gn.delete(e),fn.delete(e),pn.delete(e)}async function In(e,t,n={}){gn.set(e,n);let r=(fn.get(e)??0)+1;fn.set(e,r),dn.set(e,t);let i=Sn(e);En(e);let a=wn(e,i.maxWidth);return pn.set(e,a),Pn(e),An(e,r,t,i,a)}async function Ln(e=document){let t=Q.selector??un,n=[];return e instanceof Element&&e.matches(t)&&n.push(e),n.push(...e.querySelectorAll(t)),Promise.all(n.map(e=>(Pn(e),jn(e)))).then(()=>void 0)}var Rn=!1;function zn(){if(Rn||typeof MutationObserver>`u`)return;Rn=!0;let e=Q.selector??un;new MutationObserver(t=>{let n=new Set;for(let r of t)for(let t of r.addedNodes)if(t instanceof Element&&!t.closest(`.guidex-render`)){t.matches(e)&&n.add(t);for(let r of t.querySelectorAll(e))n.add(r)}for(let e of n)Pn(e),jn(e)}).observe(document.documentElement,{childList:!0,subtree:!0})}function Bn(e={}){Q={...Q,...e},zn(),Ln()}var Vn=[`font-family`,`font-size`,`font-style`,`font-weight`,`line-height`,`letter-spacing`,`text-transform`,`color`,`position`,`top`,`left`,`margin-top`,`margin-bottom`,`padding-top`,`padding-bottom`],Hn=[`font-family`,`font-size`,`font-style`,`font-weight`,`line-height`,`letter-spacing`,`color`];function Un(e){return e.classList.contains(`max-width-guide`)||e.hasAttribute(`data-score-image-ignore`)}function Wn(e){let t=e.querySelector(`.guido`)?.parentElement;if(!t)throw Error(`No rendered score found to export — render a score into the element first.`);return t}function Gn(e){let t=e.getBoundingClientRect(),n=[],r=document.createRange();return r.selectNodeContents(e),typeof r.getBoundingClientRect==`function`&&n.push(r.getBoundingClientRect()),e.querySelectorAll(`*`).forEach(e=>n.push(e.getBoundingClientRect())),n.length===0&&n.push(t),{left:Math.min(...n.map(e=>e.left))-t.left,top:Math.min(...n.map(e=>e.top))-t.top,right:Math.max(...n.map(e=>e.right))-t.left,bottom:Math.max(...n.map(e=>e.bottom))-t.top}}function Kn(e){let t=document.createRange();if(t.selectNodeContents(e),typeof t.getClientRects!=`function`)return 1;let n=Array.from(t.getClientRects()).filter(e=>e.width>0||e.height>0);if(n.length===0)return 1;n.sort((e,t)=>e.top-t.top);let r=0,i=-1/0;for(let e of n)e.top>=i?(r++,i=e.bottom):e.bottom>i&&(i=e.bottom);return r}function qn(e){let t=[],n=``,r=null;for(let i of e)r?i===r?r=null:n+=i:i===`"`||i===`'`?r=i:i===`,`?(t.push(n.trim()),n=``):n+=i;return t.push(n.trim()),t.filter(Boolean)}function Jn(e){return e===`normal`?`400`:e===`bold`?`700`:e}function Yn(e){return e.replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}function Xn(e,t,n,r,i){let a=/url\(\s*(['"]?)([^'")]+)\1\s*\)/.exec(r);if(!a)return;let o;try{o=new URL(a[2],i??location.href).toString()}catch{return}return{family:e,style:t||`normal`,weight:Jn(n||`400`),url:o,format:/format\(\s*['"]?([^'")]+?)['"]?\s*\)/.exec(r)?.[1]}}function Zn(e,t){let n=[];for(let r of e.matchAll(/@font-face\s*{([^}]*)}/g)){let e=r[1],i=t=>{let n=RegExp(`(?:^|[;\\s])${t}\\s*:\\s*([^;]+)`,`i`).exec(e);return n?n[1].trim():``},a=i(`font-family`),o=i(`src`);if(!a||!o)continue;let s=qn(a)[0];if(!s)continue;let c=Xn(s,i(`font-style`),i(`font-weight`),o,t);c&&n.push(c)}return n}async function Qn(e){let t=[],n=new Set,r=e=>{let r=`${e.family}|${e.style}|${e.weight}`;n.has(r)||(n.add(r),t.push(e))},i=[];for(let t of document.styleSheets){let n;try{n=t.cssRules}catch{t.href&&i.push(t.href);continue}for(let i of Array.from(n)){let n=i.style;if(!n)continue;let a=n.getPropertyValue(`src`),o=n.getPropertyValue(`font-family`);if(!a||!o)continue;let s=qn(o)[0];if(!s||!e.has(s))continue;let c=Xn(s,n.getPropertyValue(`font-style`),n.getPropertyValue(`font-weight`),a,t.href??void 0);c&&r(c)}}for(let t of i)try{let n=await fetch(t);if(!n.ok)throw Error(String(n.status));let i=await n.text();for(let n of Zn(i,t))e.has(n.family)&&r(n)}catch{console.warn(`[guidex] scoreImage: a cross-origin stylesheet (${t}) could not be read — fonts declared only there are missing from the export`)}return t}async function $n(e){let t=await fetch(e);if(!t.ok)return;let n=await t.blob();return new Promise(e=>{let t=new FileReader;t.onload=()=>e(typeof t.result==`string`?t.result:void 0),t.onerror=()=>e(void 0),t.readAsDataURL(n)})}async function er(e,t){let n=[],r=new Set,i=new Map,a=e=>{let t=i.get(e);return t||(t=$n(e).catch(()=>void 0),i.set(e,t)),t},o=new Map;for(let t of e){let e=o.get(t.family)??[];e.push(t),o.set(t.family,e)}for(let[e,i]of o){let o=i.filter(e=>e.style===`normal`),s=o.length>0?[...o,...t?i.filter(e=>e.style!==`normal`):[]]:i;for(let t of s){let i=await a(t.url);if(!i){r.add(e);continue}let o=t.format?` format('${t.format}')`:``;n.push(`@font-face{font-family:'${t.family}';font-style:${t.style};font-weight:${t.weight};src:url(${i})${o}}`)}}for(let e of r)console.warn(`[guidex] scoreImage: could not embed the ${e} webfont — the export falls back to the next family in its stack`);return n.join(``)}function tr(e){let t=document.createElement(`span`);return t.style.color=e,getComputedStyle(t).color}function nr(e){let t=getComputedStyle(e).getPropertyValue(`--red`).trim();return t?tr(t):``}function rr(e,t,n){return n&&t&&tr(t)===n?!0:e.style?.getPropertyValue(`color`).replace(/\s+/g,``)===`var(--red)`}function ir(e,t,n){let r=new Set,i=!1;for(let a=0;a<e.length;a++){let o=e[a],s=t[a],c=getComputedStyle(o);for(let e of a===0?Hn:Vn){if(e===`color`){let e=c.getPropertyValue(`color`);if(!e)continue;let t=rr(o,e,n.accentProbe)?n.accent:n.foreground;s.style.setProperty(`color`,t||e);continue}let t=c.getPropertyValue(e);t&&s.style.setProperty(e,t)}if(o.classList.contains(`guidex-staff-line`)){let e=c.getPropertyValue(`background-color`),t=c.getPropertyValue(`color`);s.style.setProperty(`background-color`,e===t&&n.foreground?n.foreground:e)}let l=c.getPropertyValue(`font-family`);if(l)for(let e of qn(l))r.add(e);c.getPropertyValue(`font-style`)===`italic`&&(i=!0)}return{families:r,italics:i}}async function ar(){let e=document.fonts;e?.ready&&await e.ready}async function or(e,t){let n=Math.max(0,t.padding??0),r=Wn(e);if(!r.isConnected)throw Error(`scoreImage: the score left the document before the export — re-render it and try again`);await ar();let i=Array.from(r.children).filter(e=>e.classList.contains(`guido`)||e.tagName===`P`);if(i.length===0)throw Error(`No rendered score found to export — render a score into the element first.`);let a=i.map(e=>e.getBoundingClientRect()),o=a[0],s=i.map((e,t)=>{let n=Gn(e),r=a[t],i=r.left-o.left,s=Kn(e)>1;return{left:n.left+i,top:n.top+(r.top-o.top),right:(s?Math.max(r.width,n.right):n.right)+i,bottom:n.bottom+(r.top-o.top),pinWidth:s?r.width:void 0}}),c=Math.min(0,...s.map(e=>e.left)),l=Math.min(0,...s.map(e=>e.top)),u=Math.max(...s.map(e=>e.right)),d=Math.max(...s.map(e=>e.bottom)),f=Math.max(1,Math.ceil(u-c))+n*2,p=Math.max(1,Math.ceil(d-l))+n*2,m=r.cloneNode(!0);m.querySelectorAll(`.max-width-guide, [data-score-image-ignore]`).forEach(e=>e.remove());let h=[r],g=[m],_=(e,t)=>{for(let n of e.children)Un(n)||(t.push(n),_(n,t))};if(_(r,h),_(m,g),g.length!==h.length)throw Error(`scoreImage: the cloned tree diverged from the live one`);for(let e of[m,...m.querySelectorAll(`*`)])e.removeAttribute(`title`);let{families:ee,italics:v}=ir(h,g,{foreground:t.foreground,accent:t.accent,accentProbe:nr(r)});m.style.setProperty(`white-space`,`nowrap`);let y=Array.from(m.children).filter(e=>e.classList.contains(`guido`)||e.tagName===`P`);s.forEach((e,t)=>{let n=y[t];e.pinWidth!==void 0&&n&&n.style.setProperty(`width`,`${e.pinWidth}px`)}),m.style.setProperty(`padding-top`,`${n-l}px`),m.style.setProperty(`padding-left`,`${n-c}px`),m.style.setProperty(`padding-right`,`${n}px`),m.style.setProperty(`padding-bottom`,`${n}px`);let te=await er(await Qn(ee),v),ne=new XMLSerializer().serializeToString(m),b=t.background?`<rect width="100%" height="100%" fill="${Yn(t.background)}"/>`:``;return{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="${f}" height="${p}" viewBox="0 0 ${f} ${p}">`+b+(te?`<style>${te}</style>`:``)+`<foreignObject x="0" y="0" width="${f}" height="${p}">`+ne+`</foreignObject></svg>`,width:f,height:p}}async function sr(e,t={}){return(await or(e,t)).svg}async function cr(e,t={}){let{svg:n,width:r,height:i}=await or(e,t),a=Math.max(1,t.scale??2),o=new Image;o.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`,await new Promise((e,t)=>{o.onload=()=>e(),o.onerror=()=>t(Error(`scoreImage: the exported SVG failed to rasterize`))});try{await o.decode()}catch{}let s=document.createElement(`canvas`);s.width=Math.ceil(r*a),s.height=Math.ceil(i*a);let c=s.getContext(`2d`);if(!c)throw Error(`scoreImage: this environment provides no 2D canvas`);c.scale(a,a),t.background&&(c.fillStyle=t.background,c.fillRect(0,0,r,i));let l=()=>c.drawImage(o,0,0,r,i);l(),/^((?!chrome|android|crios|fxios).)*safari/i.test(navigator.userAgent)&&(await new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(e))),l());let u=await new Promise(e=>s.toBlob(e,`image/png`));if(!u)throw Error(`scoreImage: PNG encoding failed`);return u}function lr(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,r.click(),setTimeout(()=>URL.revokeObjectURL(n),1e4)}async function ur(e,t={}){let n=t.filename??`score.png`;return lr(await cr(e,t),n),n}async function dr(e,t={}){let n=t.filename??`score.svg`;return lr(new Blob([await sr(e,t)],{type:`image/svg+xml;charset=utf-8`}),n),n}return document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,()=>Bn(),{once:!0}):Bn(),e.dispose=Fn,e.downloadScorePng=ur,e.downloadScoreSvg=dr,e.init=Bn,e.renderAll=Ln,e.renderScore=In,e.scorePngBlob=cr,e.scoreSvg=sr,e.version=ln,e})({});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "guidex",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Guidex — render plainchant scores from a compact GuidoScript notation, as a web app and an embeddable runtime",
5
5
  "type": "module",
6
6
  "workspaces": [
@@ -29,6 +29,10 @@
29
29
  "./word": {
30
30
  "types": "./dist/lib/word/index.d.ts",
31
31
  "default": "./dist/lib/word/index.js"
32
+ },
33
+ "./aretino": {
34
+ "types": "./dist/lib/aretino/index.d.ts",
35
+ "default": "./dist/lib/aretino/index.js"
32
36
  }
33
37
  },
34
38
  "files": [
@@ -37,9 +41,13 @@
37
41
  "CHANGELOG.md"
38
42
  ],
39
43
  "peerDependencies": {
44
+ "@aretino-chant/core": ">=0.29.0",
40
45
  "react": ">=18"
41
46
  },
42
47
  "peerDependenciesMeta": {
48
+ "@aretino-chant/core": {
49
+ "optional": true
50
+ },
43
51
  "react": {
44
52
  "optional": true
45
53
  }
@@ -73,6 +81,7 @@
73
81
  },
74
82
  "homepage": "https://github.com/BrownieMaar/guidex#readme",
75
83
  "devDependencies": {
84
+ "@aretino-chant/core": "0.29.0",
76
85
  "@eslint/js": "^10.0.1",
77
86
  "@testing-library/dom": "^10.4.2",
78
87
  "@testing-library/react": "^16.3.3",
@@ -1 +0,0 @@
1
- export declare function ControlsRow(): import('react').JSX.Element;
@@ -1 +0,0 @@
1
- export declare function SettingsMenu(): import('react').JSX.Element;
@@ -1 +0,0 @@
1
- export declare function SettingsPanel(): import('react').JSX.Element;