Spaces:
Sleeping
Sleeping
| var it=Object.defineProperty;var nt=(f,e,t)=>e in f?it(f,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):f[e]=t;var x=(f,e,t)=>nt(f,typeof e!="symbol"?e+"":e,t);import{G as ae,V as oe,R as Re,H as xe,I as Ce,J as he,K as L,N as U,O as at,M as F,Q as q,g as z,U as ot,Y as rt,Z as we,h as H,_ as ce,x as Ze,$ as Te,a0 as ct,j as _e,a1 as Ie,a2 as se,a3 as ve,W as Me,D as Oe,a4 as lt,a5 as Pe,a6 as re,a7 as Ne,a8 as ut,a9 as He,n as ft,aa as ht,ab as dt,ac as le,ad as pt,ae as gt,af as mt,T as bt,ag as yt,ah as Ke,ai as Xe,aj as Ye,ak as Je,al as Qe,am as et,an as de,ao as tt,ap as kt,aq as vt,ar as xt,as as je,P as Tt,at as wt,au as Mt,av as Ve,k as Ae,aw as ze,ax as St,ay as Et,az as At,v as Ft,i as Ct,aA as _t,aB as Ge,aC as Ue,aD as We}from"./bool-store-input-BqSYkTSj.js";import{_ as Le,c as ge,o as me,a as te,F as It,e as Nt}from"./index-DvfQQ4hm.js";const Fe=new Map;async function Pt(f){const e=f==="lilypond"?"/lib/lilyParser.js":"/lib/measureLayoutParser.js",t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch prebuilt parser at ${e}. Did you run yarn build:lib?`);const s=await t.text();if(s.trim()[0]==="<")throw new Error(`Unexpected HTML at ${e}. Ensure Vite serves /public/lib/* and open the Vite URL (not backend).`);const n={exports:{}},l=new Function("module","exports","require",s+` | |
| return module.exports;`)(n,n.exports,{});if(!l||typeof l.parse!="function")throw new Error("Invalid prebuilt parser module content");return l}function Lt(f){return f.split("/").pop().replace(/\.jison$/,"").replace(/-[a-zA-Z0-9]{8}$/,"")}async function ts(f){if(!Fe.get(f)){const{default:e}=await f,t=Lt(e),s=t,i=performance.now(),n=await Pt(s);Fe.set(f,n);const l=performance.now();console.debug(`Prebuilt parser "${t}" load cost:`,l-i)}return Fe.get(f)}function $t(f){if(!Number.isFinite(f))return"E_NaN";if(f>1e6)return"E_LARGE";if(f<=0)return"E_NON_POSITIVE";const e={M:1e3,CM:900,D:500,CD:400,C:100,XC:90,L:50,XL:40,X:10,IX:9,V:5,IV:4,I:1};let t="";for(const s in e)for(;f>=e[s];)t+=s,f-=e[s];return t}class Bt extends xt{constructor(){super(...arguments);x(this,"staffTrack");x(this,"notes",[]);x(this,"channelMap",[])}executeTerm(t){if(t.newMeasure&&this.resetAlters(),t.clef&&this.setClef(t.clef.y,t.clef.value),Number.isFinite(t.octaveShift)&&this.setOctaveShift(-t.octaveShift),Number.isFinite(t.key)&&(this.resetKeyAlters(),t.key)){const s=t.key>0?1:-1;for(let i=s;i/t.key<=1;i+=s){const n=((s>0?i-1:i)+70)%7,l=wt.indexOf(Mt[n]);this.keyAlters[l]=(this.keyAlters[l]||0)+s}this.dirty=!0}if(t.pitches){t.pitches.forEach(l=>{const a=l.absoluteNotePosition,u=this.alterOnNote(a);l.alterValue!==u&&(this.alters[a]=l.alterValue,this.dirty=!0)});const s=t.event,i=this.snapshot({tick:s._tick}),n=s.implicitType||(t.tremoloType?je.Tremolo:je.None);this.notes.push(...t.pitches.map((l,a)=>({track:t.track,channel:this.channelMap[t.track]||0,measure:s._measure,start:s._tick,duration:s.durationMagnitude,division:s.division,startTick:s._tick,endTick:s._tick+s.durationMagnitude,pitch:l.absolutePitchValue+(l._transposition||0),velocity:127,id:l.href,ids:[l.href],tied:!!l._tied,rest:s.isRest,afterGrace:!!t.tickBias,implicitType:n,staffTrack:this.staffTrack,contextIndex:i,chordPosition:{index:a,count:t.pitches.length}}))),t.pitches.forEach(l=>{const a=l.tiedParent;if(a){const u=this.notes.find(b=>b.id===a.href);u&&u.ids.push(l.href)}})}else if(t.rest){const s=t.event,i=this.snapshot({tick:s._tick});this.notes.push({track:t.track,channel:this.channelMap[t.track]||0,measure:s._measure,start:s._tick,duration:s.durationMagnitude,startTick:s._tick,endTick:s._tick+s.durationMagnitude,pitch:null,velocity:0,id:s.href,ids:[s.href],tied:!1,rest:!0,afterGrace:!!t.tickBias,implicitType:s.implicitType,staffTrack:this.staffTrack,contextIndex:i})}}get pitchContextTable(){const t=this.track.contexts.map(s=>({tick:s.tick,endTick:null,context:s}));return t.forEach((s,i)=>{s.endTick=i+1<t.length?t[i+1].tick:1/0}),new Tt({items:t})}}class Se{constructor(){x(this,"block");x(this,"anchorPitch");x(this,"contextDict",null);x(this,"name");x(this,"measureHeads")}static fromBlockAnchor(e,t){const s=new Se;return s.block=e,s.anchorPitch=t,new pe(s).execute(s.music),s}get music(){return this.block._parent||(this.block._parent=new Te({cmd:"relative",args:this.anchorPitch?[this.anchorPitch.clone(),this.block]:[this.block]}),this.block.updateChordAnchors()),this.block._parent}get noteDurationSubdivider(){return ct(this.block)}get durationMagnitude(){return this.block&&this.block.durationMagnitude}get isLyricMode(){return this.music instanceof _e||!!this.block.findFirst(e=>e instanceof _e)}get isChordMode(){return this.music instanceof Ie||!!this.block.findFirst(e=>e instanceof Ie)}get measureLayoutCode(){let e=this.block.measureLayout.code;return/^\[.*\]$/.test(e)&&(e=e.match(/\[(.*)\]/)[1]),e}transform(e){new pe(this,{transformer:e}).execute(this.music)}clarifyDurations(){this.transform(e=>(e instanceof se&&(e.duration||(e.duration=e.durationValue)),[e]))}splitLongRests(){this.clarifyDurations(),this.transform((e,t)=>{if(!(e instanceof se)||!e.withMultiplier&&!(e instanceof ve))return[e];const s=t.time?t.time.value.denominator:4,i=e.durationValue,n=Math.max(i.denominator,s),l=!e.isSpacer;if(e.withMultiplier){const a=i.multipliers.reduce((M,y)=>M*Number(y),1);if(!Number.isInteger(a)||a<=0)return console.warn("invalid multiplier:",a,i.multipliers),[e];const u=e.clone();u.duration.multipliers=[];const b=u.duration.magnitude/Me*(a-1)*n;Number.isInteger(b)||console.warn("Rest count is not integear:",b,n,u.duration.magnitude,a);const m=Array(Math.floor(b)).fill(null).map(()=>new ve({name:"s",duration:new Oe({number:n,dots:0})}));return[u,...m]}else{const a=lt(i.subdivider,n),u=e.durationMagnitude*a/Me;console.assert(Number.isInteger(u),"rest count is not an integer:",u),l&&u>1&&console.warn("splitLongRests: 'r' was splitted into",u,"parts.",e._location);const b=Array(u).fill(null).map(()=>new ve({name:l?"r":"s",duration:new Oe({number:a,dots:0})}));return e.post_events&&(b[b.length-1].post_events=e.post_events.map(m=>m instanceof Pe?m.clone():m)),b}})}spreadMusicBlocks(){let e=!1;return this.transform(t=>t instanceof F?(e=!0,t.body):[t]),e}spreadRelativeBlocks(){return this.block.findFirst(Te)?(this.transform((e,t)=>{if(e instanceof Te){e.music instanceof F&&e.music.updateChordAnchors();const s=e.shiftBody(t.pitch);if(!t.event||!t.event.getPreviousT(re)){const i=new F({body:[]});i.body=s;const n=i.findFirst(re);n&&(n._anchorPitch=t.pitch)}return s}else return[e]}),!0):!1}spreadRepeatBlocks({ignoreRepeat:e=!0,keepTailPass:t=!1}={}){return this.block.findFirst(Ne)?(this.transform(s=>s instanceof Ne?e?t?s.getTailPassTerms():s.getPlainTerms():s.getUnfoldTerms():s instanceof oe&&s.name==="lotusRepeatABA"?[]:[s]),!0):!1}flatten({spreadRepeats:e=!1}={}){if(this.splitLongRests(),this.spreadRelativeBlocks(),e){for(;this.spreadRepeatBlocks(););for(;this.spreadMusicBlocks(););}}sliceMeasures(e,t){this.flatten({spreadRepeats:!0});const s=new pe(this);s.pitch=this.anchorPitch,this.block.updateChordAnchors();for(const l of this.block.body)if(Number.isInteger(l._measure))if(l._measure<e)s.execute(l);else break;const i=s.declarations.concat(this.block.body.filter(l=>l._measure>=e&&l._measure<e+t)),n=F.fromTerms(i);return Se.fromBlockAnchor(n,s.pitch)}redivide(){this.block.redivide({measureHeads:this.measureHeads})}applyMeasureLayout(e,{flatten:t=!0}={}){t&&this.flatten({spreadRepeats:!0});const s=this.block.measureChunkMap,i=e.serialize(ut.Ordinary);i.forEach(a=>{if(!s.get(a))throw new Error(`applyMeasureLayout: measure[${a}] missed in chunk map.`)});const n=Math.max(...i)+1,l=s.get(n);l&&!l.durationMagnitude&&e instanceof He&&(e=He.fromSeq([...e.seq,ft.from(n)])),this.block.body=ht(e,s).terms,this.redivide()}generateStaffTracks(){const e=[];let t=null;const s=()=>{t&&(e.push(t),t=null)},i=a=>(t&&t.staffName!==a&&s(),t||(t={staffName:a}),t);let n=0;const l=(a,u)=>{if(i(u.staffName).tick=a._tick,a._measure!==n&&(i(u.staffName).newMeasure=!0,s(),n=a._measure),a instanceof re){const b=i(u.staffName);b.event=a,b.pitches=a.pitchesValue.filter(m=>m instanceof le),b.pitches=[...b.pitches].sort((m,M)=>m.absolutePitchValue-M.absolutePitchValue),u.tickBias&&(b.tickBias=u.tickBias),b.tremoloType=u.tremoloType,s()}else if(a instanceof ve&&a.name!=="s"){const b=i(u.staffName);b.event=a,b.rest=!0,s()}else if(a instanceof Ye)switch(a.clefName){case"treble":i(u.staffName).clef={y:1,value:4};break;case"bass":i(u.staffName).clef={y:-1,value:-4};break;case"tenor":i(u.staffName).clef={y:0,value:0};break}else a instanceof Je?i(u.staffName).key=a.key:a instanceof Qe&&(i(u.staffName).octaveShift=a.value)};return new pe(this,{listener:l}).execute(this.music),e}}class pe{constructor(e=new Se,{transformer:t=null,listener:s=null,contextDict:i=null}={}){x(this,"track");x(this,"transformer");x(this,"listener");x(this,"stack",[]);x(this,"staff",null);x(this,"clef",null);x(this,"key",null);x(this,"time",null);x(this,"octave",null);x(this,"pitch",null);x(this,"staffName",null);x(this,"voiceName",null);x(this,"transposition",0);x(this,"tick",0);x(this,"tickInMeasure",0);x(this,"measureSpan",Me);x(this,"measureIndex",1);x(this,"partialDuration",null);x(this,"measureHeads",[0]);x(this,"event",null);x(this,"tying",null);x(this,"staccato",!1);x(this,"inGrace",!1);x(this,"stemDirection",null);x(this,"beamOn",!1);x(this,"tremoloType",0);this.track=e,this.track.contextDict=i||this.track.contextDict,this.track.measureHeads=this.measureHeads,this.transformer=t,this.listener=s,this.track.contextDict&&(this.staffName=this.track.contextDict.Staff,this.voiceName=this.track.contextDict.Voice)}clone(){const e={...this};return Object.setPrototypeOf(e,Object.getPrototypeOf(this)),e}mergeParallelClones(e){const t=e.reduce((i,n)=>{const l=!i||n.tick>i.tick?n:i;return l.tying=l.tying||n.tying,l.staccato=l.staccato||n.staccato,l},null),s=e[e.length-1];this.tick=t.tick,this.tickInMeasure=t.tickInMeasure,this.measureIndex=t.measureIndex,this.partialDuration=t.partialDuration,this.tying=t.tying,this.staccato=t.staccato,this.pitch=s.pitch,this.event=s.event}get factor(){for(let e=this.stack.length-1;e>=0;e--){const t=this.stack[e];if(t.factor)return t.factor}return null}get tremoloDuration(){for(let e=this.stack.length-1;e>=0;e--){const t=this.stack[e];if(t.tremoloDuration)return t.tremoloDuration}return null}get tickBias(){for(let e=this.stack.length-1;e>=0;e--){const t=this.stack[e];if(t.tickBias)return t.tickBias}return 0}get measureIndexBias(){return this.tickInMeasure+this.tickBias<-1?-1:0}get factorValue(){return this.factor&&Number.isFinite(this.factor.value)?this.factor.value:1}get currentMeasureSpan(){return Math.round(this.partialDuration?this.partialDuration.magnitude:this.measureSpan)}setPitch(e){this.track.anchorPitch||(this.track.anchorPitch=e),this.pitch=e}newMeasure(e){console.assert(Number.isFinite(this.measureHeads[this.measureIndex-1]),"invalid measureHeads at",this.measureIndex-1,this.measureHeads),this.measureHeads[this.measureIndex]=this.measureHeads[this.measureIndex-1]+e,++this.measureIndex,this.tickInMeasure-=e,this.partialDuration=null}checkIncompleteMeasure(){this.tickInMeasure&&(console.warn("incomplete measure trunated:",this.measureIndex,`${this.tickInMeasure}/${this.currentMeasureSpan}`),this.newMeasure(this.tickInMeasure))}elapse(e){const t=e*this.factorValue;for(this.tick+=t,this.tickInMeasure+=t;Math.round(this.tickInMeasure)>=this.currentMeasureSpan;)this.newMeasure(this.currentMeasureSpan)}push(e){this.stack.push(e)}pop(){this.stack.pop()}processGrace(e,t=dt){let s=[e];e instanceof se||(s=e.findAll(se));let i=this.tick;s.reverse().forEach(n=>{i-=Math.round(n.durationMagnitude*t*this.factorValue),n._tick=i,n.findAll(le).forEach(l=>l._tick=i)})}execute(e){if(!e){console.warn("null term:",e);return}if(e instanceof Pe){if(e._measure=this.measureIndex+this.measureIndexBias,e._tick=this.tick,e instanceof se){if(e._previous=this.event,e instanceof re&&(this.track.anchorPitch||(this.track.anchorPitch=le.default.clone()),this.setPitch(e.absolutePitch),e.pitches.forEach(t=>{this.execute(t),t instanceof le&&(t._transposition=this.transposition)}),this.tying&&this.event&&this.event instanceof re)){const t=new Set(this.event.pitchElements.map(s=>s.absolutePitch.pitch));e.pitchElements.forEach(s=>{t.has(s.absolutePitch.pitch)&&(s._tied=this.tying)}),this.staccato&&console.warn("tie on staccato note:",e.href)}e.beamOn?this.beamOn=!0:e.beamOff&&(this.beamOn=!1),this.event=e,this.elapse(e.durationMagnitude),e._lastMeasure=this.tickInMeasure>0?this.measureIndex:this.measureIndex-1,this.tying=null,this.staccato=!1,e.isTying&&(this.tying=e),e.isStaccato&&(this.staccato=!0)}else if(!(e instanceof le)){if(e instanceof F)if(this.track.block||(this.track.block=e),e.updateChordAnchors(),this.transformer){const t=[];for(const s of e.body){const i=this.transformer(s,this);i.forEach(n=>this.execute(n)),t.push(...i)}e.body=t}else for(const t of e.body)this.execute(t);else if(e instanceof H&&e.cmd==="numericTimeSignature")this.execute(e.args[0]);else if(e instanceof pt)this.time=e,this.measureSpan=e.value.value*Me;else if(e instanceof gt)this.partialDuration=e.duration;else if(e instanceof Ne)switch(e.type){case"volta":if(this.checkIncompleteMeasure(),this.execute(e.bodyBlock),this.checkIncompleteMeasure(),e.alternativeBlocks)for(const t of e.alternativeBlocks)this.execute(t),this.checkIncompleteMeasure();break;case"tremolo":this.push({factor:{value:e.times},tremoloDuration:e.sumDuration}),this.tremoloType=e.singleTremolo?1:2,this.execute(e.bodyBlock),this.tremoloType=0,this.pop();break;default:console.warn("unsupported repeat type:",e.type)}else if(e instanceof Te)e.anchor&&this.setPitch(e.anchor),this.execute(e.music);else if(!(e instanceof _e)){if(!(e instanceof H&&e.cmd==="lyricsto")){if(!(e instanceof Ie))if(e instanceof mt)this.transposition=e.transposition;else if(e instanceof bt)this.push({factor:e.factor}),this.execute(e.music),this.pop();else if(e instanceof yt)this.push({factor:e.divider.reciprocal}),this.execute(e.music),this.pop();else if(e instanceof Ke)this.inGrace=!0,this.push({factor:{value:0}}),this.execute(e.music),this.pop(),this.inGrace=!1,this.processGrace(e.music);else if(e instanceof Xe)this.execute(e.body),this.inGrace=!0,this.push({factor:{value:0},tickBias:-e.body.durationMagnitude}),this.execute(e.grace),this.pop(),this.inGrace=!1,this.processGrace(e.grace);else if(e instanceof Ye)this.clef=e;else if(e instanceof Je)this.key=e;else if(e instanceof Qe)this.octave=e;else if(e instanceof H&&e.cmd==="change"){const t=e.getAssignmentPair();if(t)switch(t.key){case"Staff":this.staffName=t.value.toString(),this.staff=e;break;case"Voice":this.voiceName=t.value.toString();break}}else if(e instanceof et)e.exp==="~"&&(this.tying=this.event);else if(e instanceof de)e.isStaccato&&(this.staccato=!0);else if(e instanceof q){const t=[];let s=this;for(const i of e.list){const n=this.clone();n.pitch=s.pitch,n.event=s.event,n.execute(i),t.push(n),s=n}this.mergeParallelClones(t)}else e instanceof z?this.execute(e.body):e instanceof tt?this.stemDirection=e.direction:e.isMusic&&console.warn("[TrackContext] unexpected music term:",e)}}}this.listener&&this.listener(e,this),e instanceof se&&this.tremoloType===2&&(this.tremoloType=3)}}get declarations(){return[this.staff,this.clef,this.key,this.time,this.octave].filter(e=>e)}}class Dt{constructor(){x(this,"staffNames",[]);x(this,"musicTracks",[])}get mainTrack(){const e=(s,i)=>-s.block.durationMagnitude+i*.001,t=this.musicTracks.filter(s=>s.block._parent&&!s.isChordMode&&!s.isLyricMode).map((s,i)=>({track:s,index:i})).sort((s,i)=>e(s.track,s.index)-e(i.track,i.index));return t[0]?t[0].track:null}get trackNames(){return this.musicTracks.map(e=>`${e.contextDict.Staff}:${e.contextDict.Voice}`)}get trackContextDicts(){const e=this.musicTracks.map(t=>t.contextDict);return e.unshift(void 0),e}get trackInstruments(){return this.musicTracks.map(e=>{const t=Object.keys(e.contextDict).find(s=>/\.instrumentName/.test(s));return t?e.contextDict[t]:null})}get instrumentList(){return Array.from(new Set(this.trackInstruments))}get channelMap(){const e=this.instrumentList,t=this.trackInstruments.map(s=>e.indexOf(s)+1);return t.unshift(0),t}get measureLayoutCode(){return this.mainTrack&&this.mainTrack.measureLayoutCode}applyMeasureLayout(e){this.musicTracks.forEach(t=>t.applyMeasureLayout(e))}getNotation({logger:e=new Ze}={}){const t=[].concat(...this.musicTracks.map((M,y)=>M.generateStaffTracks().map(I=>({track:y+1,...I})))),s=(M,y)=>{M.forEach(R=>{R.event&&(R.tick=R.event._tick)}),M.sort((R,_)=>R.tick-_.tick);const I=new Bt({logger:e});return I.staffTrack=y,I.channelMap=this.channelMap,e.append("staffTerms",M),M.forEach(R=>I.executeTerm(R)),I},i=[];this.staffNames.length?this.staffNames.forEach((M,y)=>{const I=t.filter(R=>R.staffName===M);i.push(s(I,y))}):i.push(s(t,0));const n=[].concat(...i.map(M=>M.notes)).sort((M,y)=>M.startTick-y.startTick),l={};n.forEach(M=>{if(M.tied){const y=l[M.pitch];y&&(y.endTick=Math.max(y.endTick,M.endTick),y.duration=y.endTick-y.startTick)}else l[M.pitch]=M});const a=i.map(M=>M.pitchContextTable),u=this.mainTrack,b=u&&u.measureHeads,m=u&&u.block.measureLayout;return kt.fromAbsoluteNotes(n,b,{pitchContextGroup:a,measureLayout:m,trackNames:this.trackNames})}getNoteDurationSubdivider(){return vt(...this.musicTracks.map(t=>t.noteDurationSubdivider))}sliceMeasures(e,t){this.musicTracks=this.musicTracks.map(s=>{const i=s.sliceMeasures(e,t);return i.name=s.name,i})}}class $e{constructor(){x(this,"variableTable",new Map);x(this,"musicTracks",[]);x(this,"staffNames",[]);x(this,"musicTrackIndex",0);x(this,"musicPerformance");x(this,"mainPerformance");x(this,"version",null);x(this,"language",null);x(this,"header",null);x(this,"includeFiles",new Set);x(this,"statements",[]);x(this,"paper",null);x(this,"layout",null);x(this,"scores",[]);x(this,"layoutMusic");x(this,"midiMusic");x(this,"functionalCommand");x(this,"reservedVariables",new Set)}static trackName(e){return`Voice_${$t(e)}`}get mainScore(){return this.variableTable.get(ae)}interpretMusic(e,t){const s=new pe(void 0,{contextDict:t});s.execute(e),s.track.spreadRelativeBlocks(),this.musicTracks.push(s.track);const i=$e.trackName(++this.musicTrackIndex);return s.track.name=i,new oe({name:i})}interpretDocument(e){return e.reservedVariables&&this.appendReservedVariables(e.reservedVariables),this.execute(e.root),this}createMusicPerformance(){this.musicTracks.length&&(this.musicPerformance||(this.musicPerformance=new Dt),this.staffNames.forEach(e=>{this.musicPerformance.staffNames.some(t=>t===e)?e||console.warn("[LilyInterpreter] Multiple empty context staff name may cause error pitchContextTable:",this.musicPerformance.staffNames):this.musicPerformance.staffNames.push(e)}),this.musicTracks.forEach(e=>this.musicPerformance.musicTracks.push(e)),this.staffNames=[],this.musicTracks=[])}execute(e,{execMusic:t=!1,contextDict:s={}}={}){if(!e)return e;if(this.functionalCommand&&e.isMusic&&(e._functional=this.functionalCommand.name,this.functionalCommand=null),e instanceof Re){for(const i of e.sections){const n=this.execute(i,{execMusic:!0});if(n instanceof xe)this.version=n;else if(n instanceof Ce)this.language=n;else if(n instanceof he)this.statements.push(n);else if(n instanceof L)switch(n.head){case"\\header":this.header=n;break;case"\\paper":this.paper=n;break;case"\\layout":this.layout=n;break;case"\\score":this.scores.push(n);break}}this.createMusicPerformance(),this.musicPerformance&&(this.layoutMusic=this.musicPerformance,this.midiMusic=this.musicPerformance,this.musicPerformance=null)}else if(e instanceof U){if(e.key){const i=e.key,n=i===ae;n&&(this.musicPerformance=null);const l=this.execute(e.value,{execMusic:n});this.variableTable.set(i,l),n&&(this.mainPerformance=this.musicPerformance)}}else if(e instanceof L)switch(e.head){case"\\score":const i=e.body.map(n=>this.execute(n,{execMusic:!0}));return this.musicPerformance=null,new L({block:e.block,head:e.head,body:i});case"\\layout":this.layoutMusic=this.musicPerformance;break;case"\\midi":this.midiMusic=this.musicPerformance;break}else if(e instanceof oe){const i=this.variableTable.get(e.name);if(!i){if(at.test(e.name))return this.functionalCommand=e,e;this.reservedVariables.has(e.name)||console.warn("uninitialized variable is referred:",e)}return e.name===ae?(this.musicPerformance=this.mainPerformance,e):this.execute(i,{execMusic:t,contextDict:s})}else if(e instanceof F){const i=new F({_parent:e._parent,_functional:e._functional,body:e.body.map(n=>this.execute(n)).filter(Boolean)});if(this.functionalCommand=null,t){const n=this.interpretMusic(i,s);return new F({body:[n]})}return i}else if(e instanceof q){const i=e.list.map(n=>this.execute(n,{execMusic:t,contextDict:s})).filter(n=>n);return this.createMusicPerformance(),new q({list:i})}else{if(e instanceof z)return e.contextDict&&typeof e.contextDict.Staff=="string"&&this.staffNames.push(e.contextDict.Staff),new z({head:this.execute(e.head),lyrics:this.execute(e.lyrics),body:this.execute(e.body,{execMusic:t,contextDict:{...s,...e.contextDict}})});if(e instanceof ot)e.voices.forEach(i=>{const n=new F({body:rt.join(i.body)}),l=this.execute(n);this.variableTable.set(i.name,l)});else if(e instanceof we)this.includeFiles.add(e.filename);else if(e instanceof H){switch(e.cmd){case"set":if(e.args[0]instanceof U){const i=e.args[0];s[i.key.toString()]=i.value.toString()}break}return ce({proto:e.proto,cmd:e.cmd,args:e.args.map(i=>this.execute(i,{execMusic:t,contextDict:s}))})}}return e}updateTrackAssignments(){this.layoutMusic&&this.layoutMusic.musicTracks.forEach(t=>this.variableTable.set(t.name,t.music)),this.midiMusic&&this.midiMusic!==this.layoutMusic&&this.midiMusic.musicTracks.forEach(t=>this.variableTable.set(t.name,t.music));const e=this.mainScore;e&&(this.variableTable.delete(ae),this.variableTable.set(ae,e))}toDocument(){this.updateTrackAssignments();const e=[].concat(...[this.paper,this.layout,...this.scores,this.mainScore].filter(u=>u).map(u=>u.findAll(oe).map(b=>b.name))),t=Array.from(new Set(e)),s=[...this.variableTable.keys()];t.sort((u,b)=>s.indexOf(u)-s.indexOf(b));const i=t.filter(u=>this.variableTable.get(u)).map(u=>new U({key:u,value:this.variableTable.get(u)})),n=Array.from(this.includeFiles).map(u=>we.create(u)),l=new Re({sections:[this.version,this.language,this.header,...n,...this.statements,this.paper,this.layout,...i,...this.scores].filter(u=>u)}),a=new Rt(l);return a.reservedVariables=this.reservedVariables,a}sliceMeasures(e,t){this.layoutMusic&&this.layoutMusic.sliceMeasures(e,t),this.midiMusic&&this.midiMusic!==this.layoutMusic&&this.midiMusic.sliceMeasures(e,t)}addIncludeFile(e){this.includeFiles.add(e)}appendReservedVariables(e){for(const t of e)this.reservedVariables.add(t)}getNotation({logger:e=new Ze}={}){return this.midiMusic?this.midiMusic.getNotation({logger:e}):null}}class Rt{constructor(e){x(this,"root");x(this,"cacheInterpreter");x(this,"reservedVariables");this.root=ce(e)}toString(){return this.root.join()}interpret({useCached:e=!0}={}){return(!e||!this.cacheInterpreter)&&(this.cacheInterpreter=new $e,this.cacheInterpreter.interpretDocument(this)),this.cacheInterpreter}globalAttributes({readonly:e=!1}={}){const t=this.root.getField("set-global-staff-size"),s=this.root.getBlock("header");let i=this.root.getBlock("paper");const n=i&&i.getField("layout-set-staff-size");let l=t||n;if(e)l=l||{value:Ve};else{let k=!1;l||(this.root.sections.push(new he({exp:{proto:"SchemeFunction",func:"set-global-staff-size",args:[Ve]}})),l=this.root.getField("set-global-staff-size"),k=!0);const r={proto:"Assignment",key:"paper-width",value:{proto:"NumberUnit",number:21,unit:"\\cm"}},c={proto:"Assignment",key:"paper-height",value:{proto:"NumberUnit",number:29.71,unit:"\\cm"}};i||(i=new L({block:"score",head:"\\paper",body:[r,c]}),this.root.sections.push(i),k=!0),i.getField("paper-width")||i.body.push(ce(r)),i.getField("paper-height")||i.body.push(ce(c)),k&&this.root.reorderSections()}const a=(k,r)=>({get value(){if(!k)return;const c=k.getField(r);if(c)return c.value},set value(c){if(console.assert(!!k,"block is null."),c===void 0)k.body=k.body.filter(h=>!(h instanceof U)||h.key!==r);else{const h=k.getField(r);h?h.value=ce(c):k.body.push(new U({key:r,value:c}))}}}),u=k=>a(i,k),b=k=>({get value(){if(!i)return;const r=i.getField(k);if(r)return r.value.exp},set value(r){console.assert(!!i,"paper is null.");const c=i.getField(k);c?c.value.exp=r:i.body.push(new U({key:k,value:{proto:"Scheme",exp:r}}))}});let m=null;const M=this.root.sections.filter(k=>k instanceof L&&k.head==="\\score");for(const k of M)if(m=k.body.find(r=>r instanceof L&&r.head==="\\midi"),m)break;const y={get value(){return m&&m.body.find(k=>k instanceof Ge)},set value(k){if(!m){const r=this.root.getBlock("score");r?(m=new L({block:"score",head:"\\midi",body:[]}),r.body.push(m)):console.warn("no score block, midiTempo assign failed.")}m&&(m.body=m.body.filter(r=>!(r instanceof Ge)),m.body.push(k))}},R=this.root.entries.filter(k=>k instanceof U).reduce((k,r)=>(k[r.key.toString()]=r.query(r.key),k),{}),_=["title","subtitle","subsubtitle","composer","poet","arranger","opus","copyright","instrument","dedication","tagline"].reduce((k,r)=>(k[r]=a(s,r),k),{}),A={staffSize:l,midiTempo:y,..._,paperWidth:u("paper-width"),paperHeight:u("paper-height"),topMargin:u("top-margin"),bottomMargin:u("bottom-margin"),leftMargin:u("left-margin"),rightMargin:u("right-margin"),systemSpacing:b("system-system-spacing.basic-distance"),topMarkupSpacing:b("top-markup-spacing.basic-distance"),raggedLast:b("ragged-last"),raggedBottom:b("ragged-bottom"),raggedLastBottom:b("ragged-last-bottom"),printPageNumber:b("print-page-number"),...R};return e&&Object.keys(A).forEach(k=>A[k]=A[k]&&A[k].value),A}globalAttributesReadOnly(){const e=this.globalAttributes();return Object.keys(e).forEach(t=>e[t]=e[t]&&e[t].value),e}markup(e){const t=this.globalAttributes(),s=e.globalAttributesReadOnly();["staffSize","midiTempo","paperWidth","paperHeight","topMargin","bottomMargin","leftMargin","rightMargin","systemSpacing","topMarkupSpacing","raggedLast","raggedBottom","raggedLastBottom","printPageNumber"].forEach(m=>{s[m]!==void 0&&(typeof t[m].value=="object"&&t[m].value&&t[m].value.set?t[m].value.set(s[m]):t[m].value=s[m])});const i=e.root.getField("LotusCommands"),n=i&&i.value&&i.value.args&&i.value.args[0].body;if(n&&Array.isArray(n))for(const m of n)m.exp&&this[m.exp]?this[m.exp]():console.warn("unexpected markup command:",m);e.root.entries.filter(m=>m instanceof U&&/^LotusOption\..+/.test(m.key.toString())).forEach(m=>this.root.sections.push(m.clone()));const a=[],u=[],b=e.root.getBlock("score");if(b){const m=b.body.find(y=>y instanceof L&&y.head==="\\layout");m&&m.body.forEach(y=>a.push(y.clone()));const M=b.body.find(y=>y instanceof L&&y.head==="\\midi");M&&M.body.forEach(y=>u.push(y.clone()))}if(a.length||u.length){const m=this.root.getBlock("score");if(m){const M=m.body.find(I=>I instanceof L&&I.head==="\\layout");M&&M.body.push(...a);const y=m.body.find(I=>I instanceof L&&I.head==="\\midi");y&&y.body.push(...u)}}}getVariables(){return new Set(this.root.findAll(oe).map(e=>e.name))}getMusicTracks({expand:e=!1}={}){const t=this.root.getBlock("score");if(!t)return null;let s=[];return t.forEachTopTerm(F,i=>{s.push(i)}),e&&(s=s.map(i=>i.clone().expandVariables(this.root))),s}getLocationTickTable(){return this.root.findAll(t=>t instanceof le||t instanceof se).reduce((t,s)=>(s._location&&Number.isFinite(s._tick)&&(t[`${s._location.lines[0]}:${s._location.columns[0]}`]=s._tick),t),{})}relocate(e=this.toString()){this.root.relocate(e)}appendIncludeFile(e){if(!this.root.includeFiles.includes(e)){const t=this.root.sections.findIndex(s=>s instanceof xe);this.root.sections.splice(t+1,0,new we({cmd:"include",args:[Ae.fromString(e)]}))}}removeStaffGroup(){const e=this.root.getBlock("score");e&&e.body.forEach(t=>{t instanceof q&&t.removeStaffGroup()})}fixTinyTrillSpans(){}removeMusicCommands(e){e=Array.isArray(e)?e:[e];const t=s=>s instanceof H&&e.includes(s.cmd);this.root.forEachTerm(F,s=>{s.body=s.body.filter(i=>!t(i))})}removeTrillSpans(){this.removeMusicCommands(["startTrillSpan","stopTrillSpan"])}removeBreaks(){this.removeMusicCommands("break")}removePageBreaks(){this.removeMusicCommands("pageBreak")}scoreBreakBefore(e=!0){const t=this.root.getBlock("score");if(t){let s=t.entries.find(n=>n.head==="\\header");s||(s=new L({head:"\\header",body:[]}),t.body.push(s));let i=s.getField("breakbefore");i?i=i.value:(i=new he({exp:!0}),s.body.push(new U({key:"breakbefore",value:i}))),i.exp=e}else console.warn("no score block")}unfoldRepeats(){const e=this.root.getBlock("score"),t=e?e.body:this.root.sections;let s=0;return t.forEach((i,n)=>{if(i.isMusic&&i.cmd!=="unfoldRepeats"){const l=new H({cmd:"unfoldRepeats",args:[i]});t.splice(n,1,l),++s}}),s||console.warn("no music term to unfold"),s}containsRepeat(){const e=t=>{if(!t.entries)return!1;const s=t.entries.filter(i=>i instanceof Pe);for(const i of s)if(i.cmd==="repeat")return!0;for(const i of s)if(e(i))return!0;return!1};return e(this.root)}removeEmptySubMusicBlocks(){this.root.forEachTerm(F,e=>{e.body=e.body.filter(t=>!(t instanceof F&&t.body.length===0))})}mergeContinuousGraces(){this.removeEmptySubMusicBlocks();const e=s=>s instanceof Ke,t=s=>e(s)||s instanceof Ue||s instanceof de;this.root.forEachTerm(F,s=>{const i=[];let n=null;s.body.forEach((a,u)=>{n?t(a)?(n.count++,n.count===2&&i.push(n)):n=null:e(a)&&(n={start:u,count:1})});let l=0;i.forEach(a=>{const u=a.start+l,b=new F({body:[]});for(let m=u;m<u+a.count;++m){const M=s.body[m],y=e(M)?M.args[0]:M;y instanceof F?b.body.push(...y.body):b.body.push(y)}s.body[u].args[0]=b,s.body.splice(u+1,a.count-1),l-=a.count-1})})}mergeContinuousEmptyAfterGraces(){const e=s=>s instanceof Xe&&s.args[0]instanceof F&&s.args[0].body.length===0,t=s=>e(s)||s instanceof Ue||s instanceof de;this.root.forEachTerm(F,s=>{const i=[];let n=null;s.body.forEach((a,u)=>{n?t(a)?(n.count++,n.count===2&&i.push(n)):n=null:e(a)&&(n={start:u,count:1})});let l=0;i.forEach(a=>{const u=a.start+l,b=new F({body:[]});for(let m=u;m<u+a.count;++m){const M=s.body[m],y=e(M)?M.args[1]:M;y instanceof F?b.body.push(...y.body):b.body.push(y)}s.body[u].args[1]=b,s.body.splice(u+1,a.count-1),l-=a.count-1})})}fixInvalidKeys(e="major"){this.root.forEachTerm(H,t=>{t.cmd==="key"&&t.args[1]==="\\none"&&(t.args[1]="\\"+e)})}fixInvalidBriefChords(){this.root.forEachTerm(ze,e=>{const t=e.body.items;if(t)for(;t.filter(s=>s==="^").length>1;){const s=t.lastIndexOf("^");t.splice(s,1,".")}})}fixInvalidMarkupWords(){this.root.forEachTerm(St,e=>{e.forEachTerm(Et,t=>{t.body=t.body.map(s=>s instanceof he?Ae.fromString(s.join().replace(/\s+$/,"")):typeof s=="string"&&s.includes("$")?Ae.fromString(s):s)})})}fixNestedRepeat(){this.root.forEachTerm(H,e=>{if(e.isRepeatWithAlternative){const t=e.args[2],s=e.args[3].args[0],i=t.body[t.body.length-1];i&&i.isRepeatWithAlternative&&(t.body.splice(t.body.length-1,1,...i.args[2].body),s.body=[...i.args[3].args[0].body,...s.body])}})}fixEmptyContextedStaff(){const e=s=>s.list.filter(i=>i instanceof z);this.root.getBlock("score").forEachTerm(q,s=>{const i=s.list.filter(n=>n instanceof z&&n.body instanceof q);if(i.length>1){const n=i[0].body,l=i[1].body;if(e(n).length===0&&e(l).length>1){const a=l.list.findIndex(b=>b instanceof z),[u]=l.list.splice(a,1);n.list.push(u)}}})}removeEmptyContextedStaff(){const e=s=>s.list.filter(i=>i instanceof z);this.root.getBlock("score").forEachTerm(q,s=>{s.list=s.list.filter(i=>!(i instanceof z)||!(i.body instanceof q)||e(i.body).length>0)})}redivide(){this.root.forEachTopTerm(F,e=>e.redivide())}makeMIDIDedicatedScore(){const e=this.root.findFirst(i=>i instanceof L&&i.head==="\\score"&&i.isMIDIDedicated);if(e)return e;const t=this.root.getBlock("score"),s=t.clone();return s.body=s.body.filter(i=>!(i instanceof L&&i.head==="\\layout")),t.body=t.body.filter(i=>!(i instanceof L&&i.head==="\\midi")),this.root.sections.push(s),s}excludeChordTracksFromMIDI(){let e=!1;const t=l=>l instanceof z&&l.head instanceof H&&l.head.args[0]==="ChordNames",s=(l,a)=>a instanceof L&&a.head===l,i=this.root.getBlock("score"),n=i.clone();if(n.forEachTerm(q,l=>{const a=l.list.filter(u=>!t(u));a.length<l.list.length&&(l.list=a,e=!0)}),n._headComment=At.createSingle(" midi output"),e){const l=i.body.filter(a=>!s("\\midi",a));l.length<i.body.length&&(i.body=l,n.body=n.body.filter(a=>!s("\\layout",a)),this.root.sections.push(n))}}getTiedNoteLocations(e){const t=[],s=n=>n instanceof F?!0:n instanceof H?n.args.filter(l=>l instanceof F).length>0:!1;this.root.forEachTerm(F,n=>{for(const l of n.voices){let a=null,u=!1,b=!1,m=!0;for(const M of l.body)for(const y of M.terms)if(y instanceof et&&y.exp==="~")u=!0,b=!1;else if(s(y))b=!0,u=!1;else if(y instanceof re&&(u&&a?t.push([a,y]):b?t.push([null,y]):m&&t.push([null,y]),m=!1,b=!1,u=!1,a=y,y.post_events))for(const I of y.post_events)I instanceof de&&I.arg==="~"&&(u=!0)}});const i=[];return t.forEach(n=>{const l=n[0]&&new Set(n[0].pitchNames),a=e.slice(n[1]._location.lines,n[1]._location.columns),u=Ft.matchPositions(/\w+/g,a);n[1].pitchNames.map((b,m)=>({pitch:b,index:m})).filter(({pitch:b})=>!l||l.has(b)||b==="q").forEach(({index:b})=>i.push([n[1]._location.lines[0],n[1]._location.columns[0]+u[b]]))}),i}getTiedNoteLocations2(){const e=[];return this.root.forEachTerm(re,t=>t.pitches.forEach(s=>{s._tied&&e.push([s._location.lines[0],s._location.columns[0]])})),e}getBriefChordLocations(){const e=[];return this.root.forEachTerm(ze,t=>e.push([t._location.lines[0],t._location.columns[0]])),e}getLyricLocations(){const e=[];return this.root.forEachTerm(Ct,t=>e.push([t._location.lines[0],t._location.columns[0]])),e}unfoldDurationMultipliers(){this.root.forEachTerm(F,e=>{e.unfoldDurationMultipliers()})}appendMIDIInstrumentsFromName(){const e=(s,i)=>s instanceof H&&s.cmd==="set"&&i.test(s.args[0].key.toString()),t=s=>{const i=s.findIndex(n=>e(n,/\.instrumentName/));if(i>=0&&!s.some(n=>e(n,/\.midiInstrument/))){const n=s[i].args[0],l=n.key.toString().replace(/\.instrumentName/,".midiInstrument");s.splice(i+1,0,H.createSet(l,n.value))}};this.root.forEachTopTerm(L,s=>{s.head==="\\score"&&(s.forEachTerm(q,i=>t(i.list)),s.forEachTerm(F,i=>t(i.body)))})}useMidiInstrumentChannelMapping(){this.appendMIDIInstrumentsFromName();const e=this.root.findFirst(s=>s instanceof L&&s.head==="\\midi");if(!e){console.warn("no MIDI block found.");return}const t=e.findFirst(s=>s instanceof U&&s.key==="midiChannelMapping");t?t.value=new he({exp:new _t({value:"instrument"})}):e.body.push(ce({proto:"Block",block:"context",head:"\\context",body:[{proto:"Command",cmd:"Score",args:[]},{proto:"Assignment",key:"midiChannelMapping",value:{proto:"Scheme",exp:{proto:"SchemePointer",value:"instrument"}}}]}))}formalize(){if(this.root.findFirst(xe)||this.root.sections.unshift(xe.default),this.root.findFirst(Ce)||this.root.sections.splice(1,0,Ce.make("english")),this.root.getBlock("header")||this.root.sections.splice(2,0,new L({block:"header",head:"\\header",body:[]})),!this.root.getBlock("score")){const e=this.root.sections.filter(s=>s.isMusic);this.root.sections=this.root.sections.filter(s=>!s.isMusic);const t=new L({block:"score",head:"\\score",body:[...e,new L({block:"score",head:"\\layout",body:[]}),new L({block:"score",head:"\\midi",body:[]})]});this.root.sections.push(t)}}convertStaffToPianoStaff(){const e=this.root.getBlock("score");if(e){const t=e.findFirst(s=>s instanceof z&&s.head.cmd==="new"&&s.head.args[0]==="Staff");t&&(t.head.args[0]="PianoStaff",t.body instanceof q&&(t.body.list=[].concat(...t.body.list.map(s=>s instanceof z?s.list.filter(n=>n instanceof z).map(n=>{const l=s.clone();return l.list=[...s.list.filter(a=>!(a instanceof z)),n],l.head.cmd="new",l}):[s]))))}}pruneStemDirections(){this.root.forEachTerm(F,e=>{let t=null;const s=[];e.body.forEach(i=>{i instanceof tt?i.direction===t?s.push(i):t=i.direction:i instanceof H&&i.findFirst(F)&&(t=null)}),e.body=e.body.filter(i=>!s.includes(i))})}removeRepeats(){this.root.forEachTerm(F,e=>e.spreadRepeatBlocks())}articulateMIDIOutput(){const e="articulate-lotus.ly";this.abstractMainScore();const t=this.makeMIDIDedicatedScore();if(!this.root.includeFiles.includes(e)){let s=this.root.sections.indexOf(t);s<0&&(s=Math.min(this.root.sections.length,3)),this.root.sections.splice(s,0,we.create(e))}t.body=t.body.map(s=>s.isMusic&&!(s instanceof H&&s.cmd==="articulate")?new H({cmd:"articulate",args:[s]}):s)}removeInvalidExpressionsOnRests(){const e=s=>[".","!","_"].includes(s instanceof de?s.arg:s);let t=0;return this.root.forEachTerm(se,s=>{s.isRest&&s.post_events.some(e)&&(s.post_events=s.post_events.filter(i=>!e(i)),++t)}),t}abstractMainScore(){const e=this.root.getBlock("score"),t=e.body.find(s=>s.isMusic);if(t&&!(t instanceof oe)){const s=this.root.sections.indexOf(e),i=new U({key:ae,value:t});this.root.sections.splice(s,0,i),e.body=e.body.map(n=>n===t?new oe({name:ae}):n)}}absoluteBlocksToRelative(){this.root.forEachTopTerm(U,e=>{if(e.value instanceof F){const t=e.value.absoluteToRelative();t&&(e.value=t)}})}}var st={exports:{}};(function(f){var e=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};/** | |
| * Prism: Lightweight, robust, elegant syntax highlighting | |
| * | |
| * @license MIT <https://opensource.org/licenses/MIT> | |
| * @author Lea Verou <https://lea.verou.me> | |
| * @namespace | |
| * @public | |
| */var t=function(s){var i=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,n=0,l={},a={manual:s.Prism&&s.Prism.manual,disableWorkerMessageHandler:s.Prism&&s.Prism.disableWorkerMessageHandler,util:{encode:function r(c){return c instanceof u?new u(c.type,r(c.content),c.alias):Array.isArray(c)?c.map(r):c.replace(/&/g,"&").replace(/</g,"<").replace(/\u00a0/g," ")},type:function(r){return Object.prototype.toString.call(r).slice(8,-1)},objId:function(r){return r.__id||Object.defineProperty(r,"__id",{value:++n}),r.__id},clone:function r(c,h){h=h||{};var g,p;switch(a.util.type(c)){case"Object":if(p=a.util.objId(c),h[p])return h[p];g={},h[p]=g;for(var w in c)c.hasOwnProperty(w)&&(g[w]=r(c[w],h));return g;case"Array":return p=a.util.objId(c),h[p]?h[p]:(g=[],h[p]=g,c.forEach(function(E,T){g[T]=r(E,h)}),g);default:return c}},getLanguage:function(r){for(;r;){var c=i.exec(r.className);if(c)return c[1].toLowerCase();r=r.parentElement}return"none"},setLanguage:function(r,c){r.className=r.className.replace(RegExp(i,"gi"),""),r.classList.add("language-"+c)},currentScript:function(){if(typeof document>"u")return null;if(document.currentScript&&document.currentScript.tagName==="SCRIPT")return document.currentScript;try{throw new Error}catch(g){var r=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(g.stack)||[])[1];if(r){var c=document.getElementsByTagName("script");for(var h in c)if(c[h].src==r)return c[h]}return null}},isActive:function(r,c,h){for(var g="no-"+c;r;){var p=r.classList;if(p.contains(c))return!0;if(p.contains(g))return!1;r=r.parentElement}return!!h}},languages:{plain:l,plaintext:l,text:l,txt:l,extend:function(r,c){var h=a.util.clone(a.languages[r]);for(var g in c)h[g]=c[g];return h},insertBefore:function(r,c,h,g){g=g||a.languages;var p=g[r],w={};for(var E in p)if(p.hasOwnProperty(E)){if(E==c)for(var T in h)h.hasOwnProperty(T)&&(w[T]=h[T]);h.hasOwnProperty(E)||(w[E]=p[E])}var N=g[r];return g[r]=w,a.languages.DFS(a.languages,function($,Z){Z===N&&$!=r&&(this[$]=w)}),w},DFS:function r(c,h,g,p){p=p||{};var w=a.util.objId;for(var E in c)if(c.hasOwnProperty(E)){h.call(c,E,c[E],g||E);var T=c[E],N=a.util.type(T);N==="Object"&&!p[w(T)]?(p[w(T)]=!0,r(T,h,null,p)):N==="Array"&&!p[w(T)]&&(p[w(T)]=!0,r(T,h,E,p))}}},plugins:{},highlightAll:function(r,c){a.highlightAllUnder(document,r,c)},highlightAllUnder:function(r,c,h){var g={callback:h,container:r,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};a.hooks.run("before-highlightall",g),g.elements=Array.prototype.slice.apply(g.container.querySelectorAll(g.selector)),a.hooks.run("before-all-elements-highlight",g);for(var p=0,w;w=g.elements[p++];)a.highlightElement(w,c===!0,g.callback)},highlightElement:function(r,c,h){var g=a.util.getLanguage(r),p=a.languages[g];a.util.setLanguage(r,g);var w=r.parentElement;w&&w.nodeName.toLowerCase()==="pre"&&a.util.setLanguage(w,g);var E=r.textContent,T={element:r,language:g,grammar:p,code:E};function N(Z){T.highlightedCode=Z,a.hooks.run("before-insert",T),T.element.innerHTML=T.highlightedCode,a.hooks.run("after-highlight",T),a.hooks.run("complete",T),h&&h.call(T.element)}if(a.hooks.run("before-sanity-check",T),w=T.element.parentElement,w&&w.nodeName.toLowerCase()==="pre"&&!w.hasAttribute("tabindex")&&w.setAttribute("tabindex","0"),!T.code){a.hooks.run("complete",T),h&&h.call(T.element);return}if(a.hooks.run("before-highlight",T),!T.grammar){N(a.util.encode(T.code));return}if(c&&s.Worker){var $=new Worker(a.filename);$.onmessage=function(Z){N(Z.data)},$.postMessage(JSON.stringify({language:T.language,code:T.code,immediateClose:!0}))}else N(a.highlight(T.code,T.grammar,T.language))},highlight:function(r,c,h){var g={code:r,grammar:c,language:h};if(a.hooks.run("before-tokenize",g),!g.grammar)throw new Error('The language "'+g.language+'" has no grammar.');return g.tokens=a.tokenize(g.code,g.grammar),a.hooks.run("after-tokenize",g),u.stringify(a.util.encode(g.tokens),g.language)},tokenize:function(r,c){var h=c.rest;if(h){for(var g in h)c[g]=h[g];delete c.rest}var p=new M;return y(p,p.head,r),m(r,p,c,p.head,0),R(p)},hooks:{all:{},add:function(r,c){var h=a.hooks.all;h[r]=h[r]||[],h[r].push(c)},run:function(r,c){var h=a.hooks.all[r];if(!(!h||!h.length))for(var g=0,p;p=h[g++];)p(c)}},Token:u};s.Prism=a;function u(r,c,h,g){this.type=r,this.content=c,this.alias=h,this.length=(g||"").length|0}u.stringify=function r(c,h){if(typeof c=="string")return c;if(Array.isArray(c)){var g="";return c.forEach(function(N){g+=r(N,h)}),g}var p={type:c.type,content:r(c.content,h),tag:"span",classes:["token",c.type],attributes:{},language:h},w=c.alias;w&&(Array.isArray(w)?Array.prototype.push.apply(p.classes,w):p.classes.push(w)),a.hooks.run("wrap",p);var E="";for(var T in p.attributes)E+=" "+T+'="'+(p.attributes[T]||"").replace(/"/g,""")+'"';return"<"+p.tag+' class="'+p.classes.join(" ")+'"'+E+">"+p.content+"</"+p.tag+">"};function b(r,c,h,g){r.lastIndex=c;var p=r.exec(h);if(p&&g&&p[1]){var w=p[1].length;p.index+=w,p[0]=p[0].slice(w)}return p}function m(r,c,h,g,p,w){for(var E in h)if(!(!h.hasOwnProperty(E)||!h[E])){var T=h[E];T=Array.isArray(T)?T:[T];for(var N=0;N<T.length;++N){if(w&&w.cause==E+","+N)return;var $=T[N],Z=$.inside,be=!!$.lookbehind,ye=!!$.greedy,X=$.alias;if(ye&&!$.pattern.global){var Ee=$.pattern.toString().match(/[imsuy]*$/)[0];$.pattern=RegExp($.pattern.source,Ee+"g")}for(var ke=$.pattern||$,B=g.next,j=p;B!==c.tail&&!(w&&j>=w.reach);j+=B.value.length,B=B.next){var Y=B.value;if(c.length>r.length)return;if(!(Y instanceof u)){var ie=1,V;if(ye){if(V=b(ke,j,r,be),!V||V.index>=r.length)break;var ne=V.index,ue=V.index+V[0].length,O=j;for(O+=B.value.length;ne>=O;)B=B.next,O+=B.value.length;if(O-=B.value.length,j=O,B.value instanceof u)continue;for(var ee=B;ee!==c.tail&&(O<ue||typeof ee.value=="string");ee=ee.next)ie++,O+=ee.value.length;ie--,Y=r.slice(j,O),V.index-=j}else if(V=b(ke,0,Y,be),!V)continue;var ne=V.index,W=V[0],G=Y.slice(0,ne),J=Y.slice(ne+W.length),o=j+Y.length;w&&o>w.reach&&(w.reach=o);var d=B.prev;G&&(d=y(c,d,G),j+=G.length),I(c,d,ie);var v=new u(E,Z?a.tokenize(W,Z):W,X,W);if(B=y(c,d,v),J&&y(c,B,J),ie>1){var S={cause:E+","+N,reach:o};m(r,c,h,B.prev,j,S),w&&S.reach>w.reach&&(w.reach=S.reach)}}}}}}function M(){var r={value:null,prev:null,next:null},c={value:null,prev:r,next:null};r.next=c,this.head=r,this.tail=c,this.length=0}function y(r,c,h){var g=c.next,p={value:h,prev:c,next:g};return c.next=p,g.prev=p,r.length++,p}function I(r,c,h){for(var g=c.next,p=0;p<h&&g!==r.tail;p++)g=g.next;c.next=g,g.prev=c,r.length-=p}function R(r){for(var c=[],h=r.head.next;h!==r.tail;)c.push(h.value),h=h.next;return c}if(!s.document)return s.addEventListener&&(a.disableWorkerMessageHandler||s.addEventListener("message",function(r){var c=JSON.parse(r.data),h=c.language,g=c.code,p=c.immediateClose;s.postMessage(a.highlight(g,a.languages[h],h)),p&&s.close()},!1)),a;var _=a.util.currentScript();_&&(a.filename=_.src,_.hasAttribute("data-manual")&&(a.manual=!0));function A(){a.manual||a.highlightAll()}if(!a.manual){var k=document.readyState;k==="loading"||k==="interactive"&&_&&_.defer?document.addEventListener("DOMContentLoaded",A):window.requestAnimationFrame?window.requestAnimationFrame(A):window.setTimeout(A,16)}return a}(e);f.exports&&(f.exports=t),typeof We<"u"&&(We.Prism=t),t.languages.markup={comment:{pattern:/<!--(?:(?!<!--)[\s\S])*?-->/,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{pattern:/<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,greedy:!0,inside:{"internal-subset":{pattern:/(^[^\[]*\[)[\s\S]+(?=\]>$)/,lookbehind:!0,greedy:!0,inside:null},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},punctuation:/^<!|>$|[[\]]/,"doctype-tag":/^DOCTYPE/i,name:/[^\s<>'"]+/}},cdata:{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,greedy:!0},tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"special-attr":[],"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:"attr-equals"},{pattern:/^(\s*)["']|["']$/,lookbehind:!0}]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:[{pattern:/&[\da-z]{1,8};/i,alias:"named-entity"},/&#x?[\da-f]{1,8};/i]},t.languages.markup.tag.inside["attr-value"].inside.entity=t.languages.markup.entity,t.languages.markup.doctype.inside["internal-subset"].inside=t.languages.markup,t.hooks.add("wrap",function(s){s.type==="entity"&&(s.attributes.title=s.content.replace(/&/,"&"))}),Object.defineProperty(t.languages.markup.tag,"addInlined",{value:function(i,n){var l={};l["language-"+n]={pattern:/(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,lookbehind:!0,inside:t.languages[n]},l.cdata=/^<!\[CDATA\[|\]\]>$/i;var a={"included-cdata":{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,inside:l}};a["language-"+n]={pattern:/[\s\S]+/,inside:t.languages[n]};var u={};u[i]={pattern:RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g,function(){return i}),"i"),lookbehind:!0,greedy:!0,inside:a},t.languages.insertBefore("markup","cdata",u)}}),Object.defineProperty(t.languages.markup.tag,"addAttribute",{value:function(s,i){t.languages.markup.tag.inside["special-attr"].push({pattern:RegExp(/(^|["'\s])/.source+"(?:"+s+")"+/\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,"i"),lookbehind:!0,inside:{"attr-name":/^[^\s=]+/,"attr-value":{pattern:/=[\s\S]+/,inside:{value:{pattern:/(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,lookbehind:!0,alias:[i,"language-"+i],inside:t.languages[i]},punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}}}})}}),t.languages.html=t.languages.markup,t.languages.mathml=t.languages.markup,t.languages.svg=t.languages.markup,t.languages.xml=t.languages.extend("markup",{}),t.languages.ssml=t.languages.xml,t.languages.atom=t.languages.xml,t.languages.rss=t.languages.xml,function(s){var i=/(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;s.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:RegExp("@[\\w-](?:"+/[^;{\s"']|\s+(?!\s)/.source+"|"+i.source+")*?"+/(?:;|(?=\s*\{))/.source),inside:{rule:/^@[\w-]+/,"selector-function-argument":{pattern:/(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,lookbehind:!0,alias:"selector"},keyword:{pattern:/(^|[^\w-])(?:and|not|only|or)(?![\w-])/,lookbehind:!0}}},url:{pattern:RegExp("\\burl\\((?:"+i.source+"|"+/(?:[^\\\r\n()"']|\\[\s\S])*/.source+")\\)","i"),greedy:!0,inside:{function:/^url/i,punctuation:/^\(|\)$/,string:{pattern:RegExp("^"+i.source+"$"),alias:"url"}}},selector:{pattern:RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|`+i.source+")*(?=\\s*\\{)"),lookbehind:!0},string:{pattern:i,greedy:!0},property:{pattern:/(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,lookbehind:!0},important:/!important\b/i,function:{pattern:/(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,lookbehind:!0},punctuation:/[(){};:,]/},s.languages.css.atrule.inside.rest=s.languages.css;var n=s.languages.markup;n&&(n.tag.addInlined("style","css"),n.tag.addAttribute("style","css"))}(t),t.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,boolean:/\b(?:false|true)\b/,function:/\b\w+(?=\()/,number:/\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,operator:/[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},t.languages.javascript=t.languages.extend("clike",{"class-name":[t.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),t.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,t.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:t.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:t.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:t.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:t.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:t.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),t.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:t.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),t.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),t.languages.markup&&(t.languages.markup.tag.addInlined("script","javascript"),t.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript")),t.languages.js=t.languages.javascript,function(){if(typeof t>"u"||typeof document>"u")return;Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector);var s="Loading…",i=function(_,A){return"✖ Error "+_+" while fetching file: "+A},n="✖ Error: File does not exist or is empty",l={js:"javascript",py:"python",rb:"ruby",ps1:"powershell",psm1:"powershell",sh:"bash",bat:"batch",h:"c",tex:"latex"},a="data-src-status",u="loading",b="loaded",m="failed",M="pre[data-src]:not(["+a+'="'+b+'"]):not(['+a+'="'+u+'"])';function y(_,A,k){var r=new XMLHttpRequest;r.open("GET",_,!0),r.onreadystatechange=function(){r.readyState==4&&(r.status<400&&r.responseText?A(r.responseText):r.status>=400?k(i(r.status,r.statusText)):k(n))},r.send(null)}function I(_){var A=/^\s*(\d+)\s*(?:(,)\s*(?:(\d+)\s*)?)?$/.exec(_||"");if(A){var k=Number(A[1]),r=A[2],c=A[3];return r?c?[k,Number(c)]:[k,void 0]:[k,k]}}t.hooks.add("before-highlightall",function(_){_.selector+=", "+M}),t.hooks.add("before-sanity-check",function(_){var A=_.element;if(A.matches(M)){_.code="",A.setAttribute(a,u);var k=A.appendChild(document.createElement("CODE"));k.textContent=s;var r=A.getAttribute("data-src"),c=_.language;if(c==="none"){var h=(/\.(\w+)$/.exec(r)||[,"none"])[1];c=l[h]||h}t.util.setLanguage(k,c),t.util.setLanguage(A,c);var g=t.plugins.autoloader;g&&g.loadLanguages(c),y(r,function(p){A.setAttribute(a,b);var w=I(A.getAttribute("data-range"));if(w){var E=p.split(/\r\n?|\n/g),T=w[0],N=w[1]==null?E.length:w[1];T<0&&(T+=E.length),T=Math.max(0,Math.min(T-1,E.length)),N<0&&(N+=E.length),N=Math.max(0,Math.min(N,E.length)),p=E.slice(T,N).join(` | |
| `),A.hasAttribute("data-start")||A.setAttribute("data-start",String(T+1))}k.textContent=p,t.highlightElement(k)},function(p){A.setAttribute(a,m),k.textContent=p})}}),t.plugins.fileHighlight={highlight:function(A){for(var k=(A||document).querySelectorAll(M),r=0,c;c=k[r++];)t.highlightElement(c)}};var R=!1;t.fileHighlight=function(){R||(console.warn("Prism.fileHighlight is deprecated. Use `Prism.plugins.fileHighlight.highlight` instead."),R=!0),t.plugins.fileHighlight.highlight.apply(this,arguments)}}()})(st);var qe=st.exports;(function(f){for(var e=/\((?:[^();"#\\]|\\[\s\S]|;.*(?!.)|"(?:[^"\\]|\\.)*"|#(?:\{(?:(?!#\})[\s\S])*#\}|[^{])|<expr>)*\)/.source,t=5,s=0;s<t;s++)e=e.replace(/<expr>/g,function(){return e});e=e.replace(/<expr>/g,/[^\s\S]/.source);var i=f.languages.lilypond={comment:/%(?:(?!\{).*|\{[\s\S]*?%\})/,"embedded-scheme":{pattern:RegExp(/(^|[=\s])#(?:"(?:[^"\\]|\\.)*"|[^\s()"]*(?:[^\s()]|<expr>))/.source.replace(/<expr>/g,function(){return e}),"m"),lookbehind:!0,greedy:!0,inside:{scheme:{pattern:/^(#)[\s\S]+$/,lookbehind:!0,alias:"language-scheme",inside:{"embedded-lilypond":{pattern:/#\{[\s\S]*?#\}/,greedy:!0,inside:{punctuation:/^#\{|#\}$/,lilypond:{pattern:/[\s\S]+/,alias:"language-lilypond",inside:null}}},rest:f.languages.scheme}},punctuation:/#/}},string:{pattern:/"(?:[^"\\]|\\.)*"/,greedy:!0},"class-name":{pattern:/(\\new\s+)[\w-]+/,lookbehind:!0},keyword:{pattern:/\\[a-z][-\w]*/i,inside:{punctuation:/^\\/}},operator:/[=|]|<<|>>/,punctuation:{pattern:/(^|[a-z\d])(?:'+|,+|[_^]?-[_^]?(?:[-+^!>._]|(?=\d))|[_^]\.?|[.!])|[{}()[\]<>^~]|\\[()[\]<>\\!]|--|__/,lookbehind:!0},number:/\b\d+(?:\/\d+)?\b/};i["embedded-scheme"].inside.scheme.inside["embedded-lilypond"].inside.lilypond.inside=i,f.languages.ly=i})(Prism);const Ot=window;function Ht(f,e,t={}){const s={tab:" ",indentOn:/[({\[]$/,moveToNewLine:/^[)}\]]/,spellcheck:!1,catchTab:!0,preserveIdent:!0,addClosing:!0,history:!0,window:Ot,autoclose:{open:`([{'"`,close:`)]}'"`},...t},i=s.window,n=i.document,l=[],a=[];let u=-1,b=!1,m=()=>{},M;f.setAttribute("contenteditable","plaintext-only"),f.setAttribute("spellcheck",s.spellcheck?"true":"false"),f.style.outline="none",f.style.overflowWrap="break-word",f.style.overflowY="auto",f.style.whiteSpace="pre-wrap";const y=(o,d)=>{e(o,d)},I=i.navigator.userAgent.match(/Firefox\/([0-9]+)\./),R=I?parseInt(I[1]):0;let _=!1;(f.contentEditable!=="plaintext-only"||R>=136)&&(_=!0),_&&f.setAttribute("contenteditable","true");const A=ee(()=>{const o=g();y(f,o),p(o)},30);let k=!1;const r=o=>!Y(o)&&!ie(o)&&o.key!=="Meta"&&o.key!=="Control"&&o.key!=="Alt"&&!o.key.startsWith("Arrow"),c=ee(o=>{r(o)&&(X(),k=!1)},300),h=(o,d)=>{l.push([o,d]),f.addEventListener(o,d)};h("keydown",o=>{o.defaultPrevented||(M=W(),s.preserveIdent?N(o):$(o),s.catchTab&&be(o),s.addClosing&&Z(o),s.history&&(ye(o),r(o)&&!k&&(X(),k=!0)),_&&!V(o)&&p(g()))}),h("keyup",o=>{o.defaultPrevented||o.isComposing||(M!==W()&&A(),c(o),m(W()))}),h("focus",o=>{b=!0}),h("blur",o=>{b=!1}),h("paste",o=>{X(),Ee(o),X(),m(W())}),h("cut",o=>{X(),ke(o),X(),m(W())});function g(){const o=J(),d={start:0,end:0,dir:void 0};let{anchorNode:v,anchorOffset:S,focusNode:C,focusOffset:P}=o;if(!v||!C)throw"error1";if(v===f&&C===f)return d.start=S>0&&f.textContent?f.textContent.length:0,d.end=P>0&&f.textContent?f.textContent.length:0,d.dir=P>=S?"->":"<-",d;if(v.nodeType===Node.ELEMENT_NODE){const D=n.createTextNode("");v.insertBefore(D,v.childNodes[S]),v=D,S=0}if(C.nodeType===Node.ELEMENT_NODE){const D=n.createTextNode("");C.insertBefore(D,C.childNodes[P]),C=D,P=0}return B(f,D=>{if(D===v&&D===C)return d.start+=S,d.end+=P,d.dir=S<=P?"->":"<-","stop";if(D===v)if(d.start+=S,!d.dir)d.dir="->";else return"stop";else if(D===C)if(d.end+=P,!d.dir)d.dir="<-";else return"stop";D.nodeType===Node.TEXT_NODE&&(d.dir!="->"&&(d.start+=D.nodeValue.length),d.dir!="<-"&&(d.end+=D.nodeValue.length))}),f.normalize(),d}function p(o){var Be,De;const d=J();let v,S=0,C,P=0;if(o.dir||(o.dir="->"),o.start<0&&(o.start=0),o.end<0&&(o.end=0),o.dir=="<-"){const{start:K,end:Q}=o;o.start=Q,o.end=K}let D=0;B(f,K=>{if(K.nodeType!==Node.TEXT_NODE)return;const Q=(K.nodeValue||"").length;if(D+Q>o.start&&(v||(v=K,S=o.start-D),D+Q>o.end))return C=K,P=o.end-D,"stop";D+=Q}),v||(v=f,S=f.childNodes.length),C||(C=f,P=f.childNodes.length),o.dir=="<-"&&([v,S,C,P]=[C,P,v,S]);{const K=w(v);if(K){const fe=n.createTextNode("");(Be=K.parentNode)==null||Be.insertBefore(fe,K),v=fe,S=0}const Q=w(C);if(Q){const fe=n.createTextNode("");(De=Q.parentNode)==null||De.insertBefore(fe,Q),C=fe,P=0}}d.setBaseAndExtent(v,S,C,P),f.normalize()}function w(o){for(;o&&o!==f;){if(o.nodeType===Node.ELEMENT_NODE){const d=o;if(d.getAttribute("contenteditable")=="false")return d}o=o.parentNode}}function E(){const d=J().getRangeAt(0),v=n.createRange();return v.selectNodeContents(f),v.setEnd(d.startContainer,d.startOffset),v.toString()}function T(){const d=J().getRangeAt(0),v=n.createRange();return v.selectNodeContents(f),v.setStart(d.endContainer,d.endOffset),v.toString()}function N(o){if(o.key==="Enter"){const d=E(),v=T();let[S]=ne(d),C=S;if(s.indentOn.test(d)&&(C+=s.tab),C.length>0?(G(o),o.stopPropagation(),O(` | |
| `+C)):$(o),C!==S&&s.moveToNewLine.test(v)){const P=g();O(` | |
| `+S),p(P)}}}function $(o){if(_&&o.key==="Enter")if(G(o),o.stopPropagation(),T()==""){O(` | |
| `);const d=g();d.start=--d.end,p(d)}else O(` | |
| `)}function Z(o){const d=s.autoclose.open,v=s.autoclose.close;if(d.includes(o.key)){G(o);const S=g(),C=S.start==S.end?"":J().toString(),P=o.key+C+(v[d.indexOf(o.key)]??"");O(P),S.start++,S.end++,p(S)}}function be(o){if(o.key==="Tab")if(G(o),o.shiftKey){const d=E();let[v,S]=ne(d);if(v.length>0){const C=g(),P=Math.min(s.tab.length,v.length);p({start:S,end:S+P}),n.execCommand("delete"),C.start-=P,C.end-=P,p(C)}}else O(s.tab)}function ye(o){if(Y(o)){G(o),u--;const d=a[u];d&&(f.innerHTML=d.html,p(d.pos)),u<0&&(u=0)}if(ie(o)){G(o),u++;const d=a[u];d&&(f.innerHTML=d.html,p(d.pos)),u>=a.length&&u--}}function X(){if(!b)return;const o=f.innerHTML,d=g(),v=a[u];if(v&&v.html===o&&v.pos.start===d.start&&v.pos.end===d.end)return;u++,a[u]={html:o,pos:d},a.splice(u+1);const S=300;u>S&&(u=S,a.splice(0,1))}function Ee(o){if(o.defaultPrevented)return;G(o);const v=(o.originalEvent??o).clipboardData.getData("text/plain").replace(/\r\n?/g,` | |
| `),S=g();O(v),y(f),p({start:Math.min(S.start,S.end)+v.length,end:Math.min(S.start,S.end)+v.length,dir:"<-"})}function ke(o){const d=g(),v=J();(o.originalEvent??o).clipboardData.setData("text/plain",v.toString()),n.execCommand("delete"),y(f),p({start:Math.min(d.start,d.end),end:Math.min(d.start,d.end),dir:"<-"}),G(o)}function B(o,d){const v=[];o.firstChild&&v.push(o.firstChild);let S=v.pop();for(;S&&d(S)!=="stop";)S.nextSibling&&v.push(S.nextSibling),S.firstChild&&v.push(S.firstChild),S=v.pop()}function j(o){return o.metaKey||o.ctrlKey}function Y(o){return j(o)&&!o.shiftKey&&ue(o)==="Z"}function ie(o){return j(o)&&o.shiftKey&&ue(o)==="Z"}function V(o){return j(o)&&ue(o)==="C"}function ue(o){let d=o.key||o.keyCode||o.which;if(d)return(typeof d=="string"?d:String.fromCharCode(d)).toUpperCase()}function O(o){o=o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),n.execCommand("insertHTML",!1,o)}function ee(o,d){let v=0;return(...S)=>{clearTimeout(v),v=i.setTimeout(()=>o(...S),d)}}function ne(o){let d=o.length-1;for(;d>=0&&o[d]!==` | |
| `;)d--;d++;let v=d;for(;v<o.length&&/[ \t]/.test(o[v]);)v++;return[o.substring(d,v)||"",d,v]}function W(){return f.textContent||""}function G(o){o.preventDefault()}function J(){return f.getRootNode().getSelection()}return{updateOptions(o){Object.assign(s,o)},updateCode(o,d=!0){f.textContent=o,y(f),d&&m(o)},onUpdate(o){m=o},toString:W,save:g,restore:p,recordHistory:X,destroy(){for(let[o,d]of l)f.removeEventListener(o,d)}}}const jt={name:"source-editor",props:{source:String,disabled:Boolean},data(){return{jar:null,isUpdatingFromProp:!1}},mounted(){this.initializeEditor()},beforeUnmount(){this.jar&&(this.jar.destroy(),this.jar=null)},methods:{highlighter(f){const e=f.textContent;f.innerHTML=qe.highlight(e,qe.languages.lilypond,"lilypond")},updateLineNumbers(){const f=this.$refs.editorContainer,e=this.$refs.lineNumbers;if(!f||!e)return;const i=(f.textContent||"").split(` | |
| `).length,n=Array.from({length:i},(l,a)=>`<span class="line-number">${a+1}</span>`).join("");e.innerHTML=n},syncScroll(){const f=this.$refs.editorContainer,e=this.$refs.lineNumbers;e&&f&&(e.scrollTop=f.scrollTop)},initializeEditor(){const f=this.$refs.editorContainer;this.jar=Ht(f,this.highlighter,{tab:" ",indentOn:/[{([]$/}),this.source&&this.jar.updateCode(this.source),this.updateLineNumbers(),this.jar.onUpdate(e=>{this.updateLineNumbers(),this.isUpdatingFromProp||this.$emit("update:source",e)}),this.disabled&&f.setAttribute("contenteditable","false")},onClick(){this.$refs.editorContainer&&!this.disabled&&this.$refs.editorContainer.focus()}},watch:{source(f){this.jar&&this.jar.toString()!==f&&(this.isUpdatingFromProp=!0,this.jar.updateCode(f||""),this.$nextTick(()=>{this.isUpdatingFromProp=!1}))},disabled(f){this.$refs.editorContainer&&this.$refs.editorContainer.setAttribute("contenteditable",f?"false":"true")}}},Vt={class:"editor-with-lines"},zt={ref:"lineNumbers",class:"line-numbers"};function Gt(f,e,t,s,i,n){return me(),ge("div",{class:"source-editor",onClick:e[1]||(e[1]=(...l)=>n.onClick&&n.onClick(...l))},[te("div",Vt,[te("div",zt,null,512),te("div",{ref:"editorContainer",class:"code-editor-wrapper",onScroll:e[0]||(e[0]=(...l)=>n.syncScroll&&n.syncScroll(...l))},null,544)])])}const ss=Le(jt,[["render",Gt],["__scopeId","data-v-126456d3"]]),Ut={name:"sheet-simple",props:{documents:Array},mounted(){this.bindLinks()},updated(){this.$nextTick(()=>this.bindLinks())},methods:{bindLinks(){const f=this.$el.querySelectorAll("a");for(const e of f)e.onclick=t=>this.$emit("linkClick",t,e.href.baseVal)}}},Wt={class:"sheet"},qt=["innerHTML"];function Zt(f,e,t,s,i,n){return me(),ge("div",Wt,[(me(!0),ge(It,null,Nt(t.documents,(l,a)=>(me(),ge("span",{class:"page",key:a,innerHTML:l},null,8,qt))),128))])}const is=Le(Ut,[["render",Zt],["__scopeId","data-v-b8425171"]]),Kt={name:"loading-dots"},Xt={class:"loading-dots"};function Yt(f,e,t,s,i,n){return me(),ge("div",Xt,[...e[0]||(e[0]=[te("div",{class:"ellipsis"},[te("div"),te("div"),te("div"),te("div")],-1)])])}const ns=Le(Kt,[["render",Yt],["__scopeId","data-v-f7137edd"]]);export{ns as L,Se as M,is as S,ss as a,Rt as b,ts as l}; | |