Spaces:
Sleeping
Sleeping
| var j=Object.defineProperty;var U=(s,e,t)=>e in s?j(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var b=(s,e,t)=>U(s,typeof e!="symbol"?e+"":e,t);import{aT as S,aU as D,ar as G,x as X,p as W,aH as K,aM as q,z as Y,aV as Z,aW as E,aX as J,aY as Q}from"./bool-store-input-BqSYkTSj.js";import{B as ee,C as te,s as L,_ as P,c,o as r,a as f,b as g,l as T,t as _,r as F,F as p,e as w,n as se,z as N,f as M,D as ie,E as B}from"./index-DvfQQ4hm.js";const z=(s,e)=>{let t=Math.abs(s.pitch-e.pitch);return t>7&&(t-=11.5),t*2},ne=(s,e,t,a,o=2)=>{const n={},i=t.reduce((d,h)=>{const k=e.filter(u=>z(u,h)<=a&&Math.abs(h.baseCsi-u.softIndex)<o).sort((u,m)=>Math.abs(h.baseCsi-u.softIndex)-Math.abs(h.baseCsi-m.softIndex));if(k.length){const u=z(k[0],h),m=n[k[0].index];(!m||u<m.distance)&&(n[k[0].index]={si:h.index,distance:u}),++d}return d},0);return{fixed:Object.entries(n).map(([d,{si:h}])=>(s[h]=Number(d),[h,Number(d)])).length,matched:i}},oe=(s,e,t,{pitchToleranceMax:a=4}={})=>{const o=new Set;s.reduce((l,d)=>(d>=0&&(l.has(d)?o.add(d):l.add(d)),l),new Set),s.forEach((l,d)=>{o.has(l)&&(s[d]=-1)});let n=null;for(let l=0;l<t.notes.length;++l){const d=t.notes[l],h=s[l];h<0?d.baseOffset=n:n=d.softIndex-e.notes[h].softIndex}for(let l=t.notes.length-1;l>=0;--l){const d=t.notes[l],h=s[l];if(h<0){const k=d.baseOffset;d.baseOffset=Number.isFinite(k)?(k+n)/2:n}else n=d.softIndex-e.notes[h].softIndex}let i=0;for(;;){const l=e.notes.filter(u=>!s.some(m=>m===u.index)).map(u=>({index:u.index,pitch:u.pitch,softIndex:u.softIndex})),d=t.notes.filter(u=>s[u.index]<0&&Number.isFinite(u.baseOffset)).map(u=>({index:u.index,pitch:u.pitch,softIndex:u.softIndex,baseCsi:u.softIndex-u.baseOffset}));if(!l.length||!d.length)break;const{fixed:h,matched:k}=ne(s,l,d,i);if(k&&console.debug("fuzzyMatch.pass:",`c:${l.length}, s:${d.length},`,i,`${h}/${k}`),h>=k&&(++i,i>a))break}};class C{constructor({tickTable:e}){b(this,"tickTable");console.assert(e.length>0,"invalid tick table:",e),this.tickTable=e}static createFromNotation(e,t){const a={},o=new Set;let n=0;return e.notes.filter(i=>!i.outMeasure&&(!i.chordPosition||i.chordPosition.index===0)).forEach(i=>{if(i.ids){if(i.measure!==n)o.clear(),n=i.measure;else if(i.ids.some(d=>o.has(d)))return;i.ids.forEach(o.add.bind(o)),a[i.startTick]=a[i.startTick]||[];const l=i.ids.map(d=>t.get(d)).filter(d=>d);a[i.startTick].push(...l)}}),C.createFromTokenTable(a,e.endTick)}static createFromTokenTable(e,t){const a=Object.entries(e).map(([o,n])=>{if(!n.length)return null;n.sort((l,d)=>l.system===d.system?l.x-d.x:l.system-d.system);const i=n[0];return{tick:Number(o),system:i.system,measure:i.measure,x:i.x,endX:i.endX}}).filter(Boolean).sort((o,n)=>o.tick-n.tick);return a.forEach((o,n)=>{const i=a[n+1];o.endTick=i?i.tick:t,console.assert(o.endTick>o.tick,"invalid tick item, tick span is non-positive:",o,e[o.tick]),i&&o.system===i.system&&[0,1].includes(i.measure-o.measure)&&(o.endX=i.x)}),new C({tickTable:a})}get startTick(){return this.tickTable[0]?this.tickTable[0].tick:null}get endTick(){return this.tickTable[0]?this.tickTable[this.tickTable.length-1].endTick:null}lookupPosition(e){e=Math.max(Math.min(e,this.endTick),this.startTick);const t=this.tickTable.find(o=>o.tick<=e&&o.endTick>e)||this.tickTable[this.tickTable.length-1];if(!t)return console.warn("cannot find tick item:",e,this.tickTable),null;const a=t.x+(e-t.tick)*(t.endX-t.x)/(t.endTick-t.tick);return{system:t.system,x:a}}lookupTick(e){const t=this.tickTable.filter(n=>n.system===e.system).sort((n,i)=>n.x-i.x);let a=t.find(n=>n.x<=e.x&&n.endX>=e.x);if(!a){const n=t[0];if(n&&e.x<n.endX)a=n;else return null}return a.tick+Math.max(e.x-a.x,0)*(a.endTick-a.tick)/(a.endX-a.x)}}const ae=480,re=(s,e)=>{s.resetAlters();const t=[],a={};let o=!1;for(const i of e.tokens)if(i.symbols.size){if(i.is("ALTER"))Number.isInteger(i.ry*2)&&(i.is("KEY")?(o||(s.resetKeyAlters(),o=!0),s.setKeyAlter(i.ry,i.alterValue)):i.href||s.setAlter(i.ry,i.alterValue));else if(i.is("CLEF"))s.setClef(i.ry,i.clefValue);else if(i.is("OCTAVE"))s.setOctaveShift(i.octaveShiftValue);else if(i.is("TIME_SIG"))i.ry===0&&s.setBeatsPerMeasure(i.timeSignatureValue);else if(i.is("NOTEHEAD")){const l=s.snapshot(),d={x:K(i.logicX,1e-4)-e.noteRange.begin,rx:i.rx-e.noteRange.begin,y:i.ry,pitch:s.yToPitch(i.ry),id:i.href,tied:i.tied,contextIndex:l,type:i.noteType,stemUp:i.stemUp};t.push(d),a[d.pitch]=a[d.pitch]||[],a[d.pitch].push(d)}}Object.values(a).forEach(i=>{for(let l=1;l<i.length;++l){const d=i[l],h=i[l-1];d.rx-h.rx<=1.5&&d.stemUp!==h.stemUp&&(d.tied=!0)}});const n=s.beatsPerMeasure*ae;t.forEach(i=>{s.track.appendNote(i.x,{pitch:i.pitch,id:i.id,tied:i.tied,contextIndex:i.contextIndex,type:i.type})}),s.track.endTime+=n},le=(s,e)=>{if(s.resetKeyAlters(),e)for(const t of e.measures)re(s,t)},ce=(s,{logger:e=new X}={})=>{if(!s.trackCount)return null;const t=Array(s.trackCount).fill(null).map(()=>new G({logger:e}));for(const o of s.pages){e.append("parsePage",s.pages.indexOf(o));for(const n of o.systems)e.append("parseSystem",o.systems.indexOf(n)),console.assert(n.staves.length===t.length,"staves size mismatched:",t.length,n.staves.length),n.staves.length!==t.length&&e.append("mismatchedStaves",{contextLen:t.length,stavesLen:n.staves.length,system:n}),n.staves.forEach((i,l)=>{e.append("parseStaff",l),t[l]&&le(t[l],i)})}t.forEach((o,n)=>o.track.notes.forEach(i=>i.track=n));const a=[].concat(...t.map(o=>o.track.notes)).sort((o,n)=>o.time-n.time+(o.pitch-n.pitch)*-.001);return e.append("notesBeforeClusterize",a.map(o=>W(o,["time","pitch"]))),fe(a),{endTime:t[0].track.endTime,notes:a,pitchContexts:t.map(o=>o.track.contexts)}},de=(s,e)=>{s.notes.forEach(t=>{const a=t.id&&t.id.match(/^\d+:\d+/)[0];if(e[a]===void 0){if(t.id){const[o,n]=t.id.match(/\d+/g).map(Number);for(let i=n-1;i>=0;--i){const l=`${o}:${i}`;if(e[l]){t.time=e[l];return}}}console.warn("[assignTickByLocationTable] location not found in table:",a);return}t.time=e[a]})},he=s=>Math.tanh((s/1.2)**12),ue=[1,1,.5,.5],fe=s=>{s.forEach((e,t)=>{if(t<1)e.deltaTime=0;else{const a=e.time-s[t-1].time,o=Math.min(e.type,s[t-1].type);e.deltaTime=he(a/(q.NOTE_TYPE_WIDTHS[o]*ue[o]))}}),s.forEach((e,t)=>t>0&&(e.time=s[t-1].time+e.deltaTime*480))},me=async(s,e,{enableFuzzy:t=!0}={})=>{console.assert(s,"midiNotation is null."),console.assert(e,"svgNotation is null.");const a=4,o={},n={},l={notes:e.notes.reduce((u,m)=>{if(m.tied){if(n[m.pitch]){const y=n[m.pitch];y.ids=y.ids||[y.id],y.ids.push(m.id)}}else{const y=`${m.time}-${m.pitch}`;if(o[y])o[y].ids=o[y].ids||[o[y].id],o[y].ids.push(m.id);else{const v={start:m.time*a,pitch:m.pitch,id:m.id,track:m.track,contextIndex:m.contextIndex};o[y]=v,n[v.pitch]=v,u.push(v)}}return u},[]).map((u,m)=>({index:m,...u})),pitchMap:null};l.pitchMap=l.notes.reduce((u,m)=>(u[m.pitch]=u[m.pitch]||[],u[m.pitch].push(m),u),[]);const d={notes:s.notes.map(({startTick:u,pitch:m},y)=>({index:y,start:u*a,pitch:m}))};S.genNotationContext(l),S.genNotationContext(d);for(const u of d.notes)S.makeMatchNodes(u,l);const k=(await S.runNavigation(l,d)).path();return t&&oe(k,l,d),k.forEach((u,m)=>{if(u>=0){const y=l.notes[u],v=y.ids||[y.id];s.notes[m].ids=v,s.notes[m].staffTrack=y.track,s.notes[m].contextIndex=y.contextIndex}}),D(s),{criterion:l,sample:d,path:k}},ye=(s,e)=>{e.forEach((t,a)=>{const o=s.notes[a];o&&t&&(o.ids=t)}),D(s)},qt=Object.freeze(Object.defineProperty({__proto__:null,assignIds:ye,assignTickByLocationTable:de,matchNotations:me,parseNotationFromSheetDocument:ce},Symbol.toStringTag,{value:"Module"}));function Yt(s,e){return ee()?(te(s,e),!0):!1}const Zt=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const O=()=>{};function ge(s,e){function t(...a){return new Promise((o,n)=>{Promise.resolve(s(()=>e.apply(this,a),{fn:e,thisArg:this,args:a})).then(o).catch(n)})}return t}function ke(s,e={}){let t,a,o=O;const n=d=>{clearTimeout(d),o(),o=O};let i;return d=>{const h=L(s),k=L(e.maxWait);return t&&n(t),h<=0||k!==void 0&&k<=0?(a&&(n(a),a=void 0),Promise.resolve(d())):new Promise((u,m)=>{o=e.rejectOnCancel?m:u,i=d,k&&!a&&(a=setTimeout(()=>{t&&n(t),a=void 0,u(i())},k)),t=setTimeout(()=>{a&&n(a),a=void 0,u(d())},h)})}}function Jt(s,e=200,t={}){return ge(ke(e,t),s)}class xe{constructor(e=!1){b(this,"promise");b(this,"resolve");e&&this.lock()}get locked(){return!!this.resolve}lock(){return console.assert(!this.locked,"[SingleLock] duplicated locking, last locking has't been released yet."),this.promise=new Promise(e=>this.resolve=e),this.promise}release(e){this.resolve&&(this.resolve(e),this.resolve=null)}wait(){return this.promise}}class pe{constructor(e=Date){b(this,"timer");b(this,"tasks",{});b(this,"handlers",{});this.timer=e}clear(){Object.values(this.handlers).forEach(e=>clearTimeout(e)),this.tasks={},this.handlers={}}getTask(e){const t=Math.max(e-this.timer.now(),0);return this.tasks[e]||(this.tasks[e]=new Promise(a=>{this.handlers[e]=setTimeout(a,t)}).then(()=>{delete this.tasks[e],delete this.handlers[e]})),this.tasks[e]}appendTask(e,t){this.tasks[e]=this.getTask(e).then(t)}}const we={name:"sheet-token",props:{token:Object,classes:Object,showTitle:Boolean,scale:Object}},ve=["transform","data-index","data-href","data-track"],be=["data-href","xlink:href"],_e={key:0};function Te(s,e,t,a,o,n){return r(),c("g",{class:T(["token",t.classes]),transform:`translate(${t.token.x}, ${t.token.y})`+(t.scale?` scale(${t.scale.x}, ${t.scale.y})`:""),"data-index":t.token.index,"data-href":t.token.href,"data-track":t.token.track,onClick:e[0]||(e[0]=i=>s.$emit("click",i))},[f("use",{class:T(t.token.classes),"data-href":t.token.href,"xlink:href":`#sign-${t.token.hash}`},null,10,be),t.showTitle&&t.token.href?(r(),c("title",_e,_(t.token.href),1)):g("",!0)],10,ve)}const Me=P(we,[["render",Te],["__scopeId","data-v-6a5cd868"]]);class Pe{add(){}remove(){}}class Se{constructor(e){this.elems=e}add(e){this.elems.forEach(t=>t.classList.add(e))}remove(e){this.elems.forEach(t=>t.classList.remove(e))}get value(){return this.elems[0]&&this.elems[0].value}set value(e){this.elems.forEach(t=>t.value=e)}}const $=(s,e=document)=>{const t=e.querySelectorAll(`.token *[data-href='${s}']`);return t.length===0?new Pe:t.length===1?t[0].classList:new Se(t)},Ce=void 0,Ie={name:"sheet-live",components:{SheetToken:Me},props:{doc:Object,midiNotation:Object,pitchContextGroup:Array,showMark:Boolean,showCursor:{type:Boolean,default:!0},noteHighlight:{type:Boolean,default:!0},bakingMode:{type:Boolean,default:!1},backgroundImages:Array,enablePointer:{type:Boolean,default:!1},showPagesProgressively:{type:Boolean,default:!1},partialVisible:{type:Boolean,default:!0},scheduler:Object,watermark:{type:String,default:Ce},enabledFont:Boolean,highlightSymbol:String},data(){return{midiPlayer:null,statusMap:new Map,shownPages:[],watermarkSize:{width:256,height:256}}},computed:{progressTicks(){return this.midiPlayer&&this.midiPlayer.progressTicks},cursorPosition(){return!this.midiPlayer||!this.scheduler?null:this.scheduler.lookupPosition(this.progressTicks)},cursorPageIndex(){if(!this.cursorPosition||!this.doc)return null;const s=this.doc.systems[this.cursorPosition.system];return console.assert(s,"invalid cursor system index:",this.cursorPosition),s?s.pageIndex:null},cursorSystemIndex(){return!this.cursorPosition||!this.doc?null:this.cursorPosition.system},cursorRowIndex(){return this.cursorSystemIndex},svgScale(){const s=this.doc&&this.doc.pages[0];return s?this.doc.pageSize.width/s.viewBox.width:1},isPlaying(){return this.midiPlayer&&this.midiPlayer.isPlaying}},created(){if(this.pageLoadingLock=new xe,this.schedulePool=new pe(performance),this.preparePlayer(),this.showPages(),this.watermark){const s=new Image;s.src=this.watermark,s.onload=()=>{this.watermarkSize.width=s.naturalWidth,this.watermarkSize.height=s.naturalHeight}}},methods:{onPlayerMidi(s,e){if(this.$emit("midi",s,e),this.noteHighlight&&s.ids){let t=null;const a=s.ids;switch(s.subtype){case"noteOn":t=()=>a.forEach(o=>{const n=this.statusMap.get(o);n&&n.add("on")});break;case"noteOff":t=()=>a.forEach(o=>{const n=this.statusMap.get(o);n&&n.remove("on")});break}t&&this.schedulePool.appendTask(e,t)}},setNoteStatus(s,e,t){if(this.midiNotation){const a=this.midiNotation.notes[s];a?a.ids&&a.ids.forEach(o=>{const n=this.statusMap.get(o);n&&(t?n.add(e):n.remove(e))}):console.warn("invalid note index:",s,this.midiNotation.notes.length)}},clearNoteStatus(){for(const s of this.statusMap.values())s.value=""},updateTokenStatus(){if(this.midiNotation&&this.noteHighlight)for(const s of this.midiNotation.notes){const e=this.midiPlayer.isPlaying&&this.midiPlayer.progressTime>=s.start&&this.midiPlayer.progressTime<s.start+s.duration;s.ids&&s.ids.forEach(t=>{const a=this.statusMap.get(t);a&&(e?a.add("on"):a.remove("on"))})}},async preparePlayer(){if(this.statusMap.clear(),this.midiPlayer&&(this.midiPlayer.dispose(),this.midiPlayer=null),this.midiNotation&&(this.updateMidiPlayer(),await this.$nextTick(),await this.pageLoadingLock.wait(),this.updateStatusMap(),!this.scheduler)){const s=this.doc&&this.doc.getTokenMap();if(s){for(const t of s.values())t.on=t.on||!1;const e=C.createFromNotation(this.midiNotation,s);this.$emit("update:scheduler",e)}}},updateMidiPlayer(){this.midiPlayer&&this.midiPlayer.dispose(),this.midiPlayer=new Z(this.midiNotation,{cacheSpan:400,onMidi:(s,e)=>this.onPlayerMidi(s,e),onTurnCursor:()=>this.updateTokenStatus()})},updateStatusMap(){this.midiNotation&&this.midiNotation.notes.forEach(s=>s.ids&&s.ids.forEach(e=>{this.statusMap.get(e)||this.statusMap.set(e,$(e,this.$el))}))},updateStatusMapInPage(s){s.querySelectorAll(".token *[data-href]").forEach(t=>{const a=t.dataset.href;this.statusMap.set(a,$(a,s))})},addMarkingByTick(s,e,t,{id:a,cls:o,text:n="",xoffset:i=0}={}){if(!this.pitchContextGroup){console.warn("[addMarkingByTick] pitchContextGroup is required.");return}const l=this.pitchContextGroup[t];if(!l){console.warn("[addMarkingByTick] invalid staffIndex:",t,this.pitchContextGroup.length);return}const d=this.scheduler.lookupPosition(s);if(!d){console.warn("[addMarkingByTick] invalid tick:",s);return}const h=l.lookup(s);if(!h)return console.warn("no context at tick:",s,l),null;const{y:k,alter:u}=h.pitchToY(e);return this.doc.addMarking(d.system,t,{x:d.x+i,y:k,text:n,alter:u,id:a,cls:o})},addMarkingByNote(s,e,{id:t=null,cls:a,text:o=""}={}){console.assert(this.midiNotation,"[addMarkingByNote] midiNotation is null.");const n=this.midiNotation.notes[s];if(!n){console.warn("[addMarkingByNote] invalid noteIndex:",s,this.midiNotation.notes.length);return}if(!t){if(!n.ids)return null;t=n.ids[0]}return this.addMarkingByTick(n.startTick,e,n.staffTrack,{id:t,cls:a,text:o,xoffset:1.2})},removeMarking(s){this.doc.removeMarking(s)},clearMarkings(){this.doc.clearMarkings()},async showPages(){if(this.shownPages=[],!!this.doc)if(this.showPagesProgressively){await this.pageLoadingLock.wait(),this.pageLoadingLock.lock();for(let s=0;s<this.doc.pages.length;++s)this.shownPages.push(this.doc.pages[s]),await this.$nextTick(),await Y();this.pageLoadingLock.release()}else this.shownPages=this.doc.pages},onDocChanged(){this.clearNoteStatus(),this.clearMarkings(),this.showPages()},eventToSystemPosition(s,e){return{x:e.offsetX/this.svgScale-s.x,y:e.offsetY/this.svgScale-s.y}},eventToPointer(s,e){const t=this.eventToSystemPosition(s,e),a=s.index,o=this.doc.lookupMeasureIndex(a,t.x),n=this.scheduler&&this.scheduler.lookupTick({system:a,x:t.x});return{systemIndex:a,measureIndex:o,tick:n,...t}},onMousemovePad(s,e){this.$emit("pointerUpdate",this.eventToPointer(s,e))},onMouseleavePad(){this.$emit("pointerUpdate",null)},onClickPad(s,e){this.$emit("pointerClick",this.eventToPointer(s,e),e)},updatePageVisibility(){if(!this.$refs.pages){console.log("[updatePageVisibility] $refs.pages is null:",this.$refs.pages);return}this.$refs.pages.forEach((s,e)=>{const t=s.getBoundingClientRect(),a=this.shownPages[e],o=t.top>window.innerHeight||t.bottom<0||t.left>window.innerWidth||t.right<0;!!a.hidden!==o&&(a.hidden=o)})},onPageChanged(s){s.target&&s.target.nodeName==="g"&&this.updateStatusMapInPage(s.target)}},watch:{midiNotation:"preparePlayer",midiPlayer(s){this.$emit("update:midiPlayer",s)},async bakingMode(){await this.$nextTick(),await this.pageLoadingLock.wait(),this.updateStatusMap(),this.updateTokenStatus()},doc:"onDocChanged",cursorPageIndex(s){this.$emit("cursorPageShift",s)},cursorSystemIndex(s){this.$emit("cursorSystemShift",s)},isPlaying(s){s||this.schedulePool.clear()}}},Ne={class:"sheet live"},Ee=["width","height","viewBox"],Le={key:0},Be={key:0,class:"mark"},ze=["transform","onMousemove","onMouseleave","onClick"],Oe=["y","width","height"],$e={key:1},Ae={key:0,class:"wm"},De=["href","x","y","width","height"],Fe={class:"page-tokens"},He=["transform"],Re=["x","y","height"],Ve=["transform"],je={key:0,class:"mark"},Ue={class:"markings"},Ge=["transform"],Xe={key:0,class:"alter",x:"-0.2",y:"0"},We={key:2,class:"bake"},Ke=["transform"],qe=["x","y","height"],Ye=["transform"],Ze=["transform","data-track","data-index"],Je=["data-href"],Qe={class:"markings"},et=["transform"],tt={key:0,class:"alter",x:"-0.2",y:"0"};function st(s,e,t,a,o,n){const i=F("SheetToken");return r(),c("div",Ne,[(r(!0),c(p,null,w(o.shownPages,(l,d)=>(r(),c("svg",{key:d,ref_for:!0,ref:"pages",class:"page",xmlns:"http://www.w3.org/2000/svg",width:l.width,height:l.height,viewBox:`${l.viewBox.x} ${l.viewBox.y} ${l.viewBox.width} ${l.viewBox.height}`,style:se({"background-image":t.backgroundImages&&t.backgroundImages[d]&&`url(${t.backgroundImages[d]})`}),"on:DOMNodeInserted":e[0]||(e[0]=(...h)=>n.onPageChanged&&n.onPageChanged(...h))},[!t.partialVisible||!l.hidden?(r(),c("g",Le,[t.showMark?(r(),c("g",Be,[(r(!0),c(p,null,w(l.systems,(h,k)=>(r(),c("g",{class:"system",key:k,transform:`translate(${h.x}, ${h.y})`,onMousemove:u=>t.enablePointer&&n.onMousemovePad(h,u),onMouseleave:u=>t.enablePointer&&n.onMouseleavePad(h,u),onClick:u=>n.onClickPad(h,u)},[f("rect",{x:0,y:h.top,width:h.width,height:h.bottom-h.top},null,8,Oe),N(s.$slots,"system",{system:h,page:l},void 0,!0)],40,ze))),128)),N(s.$slots,"page",{page:l},void 0,!0)])):g("",!0),t.bakingMode?g("",!0):(r(),c("g",$e,[t.watermark?(r(),c("g",Ae,[f("image",{href:t.watermark,x:(t.doc.pageSize.width-o.watermarkSize.width)/2/n.svgScale,y:(t.doc.pageSize.height-o.watermarkSize.height)/2/n.svgScale,width:o.watermarkSize.width/2/n.svgScale,height:o.watermarkSize.height/2/n.svgScale},null,8,De)])):g("",!0),f("g",Fe,[(r(!0),c(p,null,w(l.tokens,(h,k)=>(r(),M(i,{key:k,token:h},null,8,["token"]))),128))]),(r(!0),c(p,null,w(l.systems,(h,k)=>(r(),c("g",{class:"system",key:k,transform:`translate(${h.x}, ${h.y})`},[t.showCursor&&n.cursorPosition&&n.cursorPosition.system===h.index?(r(),c("rect",{key:0,class:"cursor",x:n.cursorPosition.x,y:h.top-.5,width:"1",height:h.bottom-h.top+1},null,8,Re)):g("",!0),f("g",null,[(r(!0),c(p,null,w(h.tokens,(u,m)=>(r(),M(i,{key:m,token:u},null,8,["token"]))),128))]),(r(!0),c(p,null,w(h.staves,(u,m)=>(r(),c("g",{class:"staff",key:m,transform:`translate(${u.x}, ${u.y})`},[f("g",null,[(r(!0),c(p,null,w(u.tokens,(y,v)=>(r(),M(i,{key:v,token:y},null,8,["token"]))),128))]),(r(!0),c(p,null,w(u.measures,(y,v)=>(r(),c("g",{class:"measure",key:v},[(r(!0),c(p,null,w(y.tokens,(x,I)=>(r(),M(i,{key:I,token:x,classes:{matched:o.statusMap.has(x.href),mismatched:x.is("NOTEHEAD")&&!o.statusMap.has(x.href),tied:x.tied,attached:Number.isFinite(x.stemX),highlight:t.highlightSymbol&&x.is(t.highlightSymbol)},showTitle:t.showMark,scale:t.enabledFont?x.scale2:null,onClick:V=>s.$emit("click-token",x,V)},null,8,["token","classes","showTitle","scale","onClick"]))),128))]))),128)),t.showMark?(r(),c("g",je,[N(s.$slots,"staff",{staff:u,system:h,page:l},void 0,!0)])):g("",!0),f("g",Ue,[(r(!0),c(p,null,w(u.markings,y=>(r(),c("g",{key:y.index,transform:`translate(${y.x}, ${y.y+u.yRoundOffset})`,class:T(y.cls)},[f("text",null,_(y.text),1),y.alterText?(r(),c("text",Xe,_(y.alterText),1)):g("",!0)],10,Ge))),128))])],8,Ve))),128))],8,He))),128))])),t.bakingMode?(r(),c("g",We,[(r(!0),c(p,null,w(l.systems,(h,k)=>(r(),c("g",{class:"system",key:k,transform:`translate(${h.x}, ${h.y})`},[t.showCursor&&n.cursorPosition&&n.cursorPosition.system===h.index?(r(),c("rect",{key:0,class:"cursor",x:n.cursorPosition.x,y:h.top-.5,width:"1",height:h.bottom-h.top+1},null,8,qe)):g("",!0),(r(!0),c(p,null,w(h.staves,(u,m)=>(r(),c("g",{class:"staff",key:m,transform:`translate(${u.x}, ${u.y})`},[(r(!0),c(p,null,w(u.measures,(y,v)=>(r(),c("g",{class:"measure",key:v},[(r(!0),c(p,null,w(y.matchedTokens,(x,I)=>(r(),c("g",{key:I,transform:`translate(${x.x}, ${x.y})`+(x.scale&&x.scale!==1?` scale(${x.scale})`:""),class:T(["token matched",{tied:x.tied}]),"data-track":x.track,"data-index":x.index},[f("text",{"data-href":x.href},_(x.fontUnicode),9,Je)],10,Ze))),128))]))),128)),f("g",Qe,[(r(!0),c(p,null,w(u.markings,y=>(r(),c("g",{key:y.index,transform:`translate(${y.x}, ${y.y+u.yRoundOffset})`,class:T(y.cls)},[f("text",null,_(y.text),1),y.alterText?(r(),c("text",tt,_(y.alterText),1)):g("",!0)],10,et))),128))])],8,Ye))),128))],8,Ke))),128))])):g("",!0)])):g("",!0)],44,Ee))),128))])}const it=P(Ie,[["render",st],["__scopeId","data-v-b3d0b3ba"]]),nt={name:"sheet-signs",props:{hashTable:Object,enabledFont:Boolean},computed:{signs(){return this.hashTable?Object.entries(this.hashTable).map(([s,e])=>({id:s,def:e,glyph:this.enabledFont?E[s]&&J[E[s]]:null})):[]}}},ot={class:"sheet-signs",xmlns:"http://www.w3.org/2000/svg"},at=["id","transform"],rt=["innerHTML"],lt=["d","stroke-width"],ct=["x","y","width","height"],dt=["x2","y2","stroke-width","stroke-dasharray"],ht=["points","stroke-width"],ut=["font-size","font-weight","font-style","text-anchor","fill"];function ft(s,e,t,a,o,n){return r(),c("svg",ot,[f("defs",null,[(r(!0),c(p,null,w(n.signs,i=>(r(),c("g",{class:"sign",key:i.id,id:`sign-${i.id}`,transform:i.def.scale&&!i.glyph&&`scale(${i.def.scale.x}, ${i.def.scale.y})`},[i.glyph?(r(),c("text",{key:0,class:"font-char","text-anchor":"start",innerHTML:i.glyph},null,8,rt)):g("",!0),i.def.type==="path"&&!i.glyph?(r(),c("path",{key:1,d:i.def.d,"stroke-width":i.def["stroke-width"]},null,8,lt)):g("",!0),i.def.type==="rect"?(r(),c("rect",{key:2,x:i.def.width>=0?0:i.def.width,y:i.def.height>=0?0:i.def.height,width:Math.abs(i.def.width),height:Math.abs(i.def.height)},null,8,ct)):g("",!0),i.def.type==="line"?(r(),c("line",{key:3,x1:"0",y1:"0",x2:i.def.width,y2:i.def.height,"stroke-width":i.def["stroke-width"],"stroke-dasharray":i.def["stroke-dasharray"]},null,8,dt)):g("",!0),i.def.type==="polygon"?(r(),c("polygon",{key:4,points:i.def.points,"stroke-width":i.def["stroke-width"]},null,8,ht)):g("",!0),i.def.type==="text"?(r(),c("text",{key:5,"font-size":i.def["font-size"],"font-weight":i.def["font-weight"],"font-style":i.def["font-style"],"text-anchor":i.def["text-anchor"],fill:i.def.color},[f("tspan",null,_(i.def.text),1)],8,ut)):g("",!0)],8,at))),128))])])}const mt=P(nt,[["render",ft],["__scopeId","data-v-8dd46f07"]]),A=s=>{const e=document.createElement("div"),t=ie(s),a=t.mount(e);return{app:t,inst:a,container:e}},H=async(s,e)=>{const t="data:image/svg+xml,"+encodeURIComponent(Q+s),a=await new Promise((i,l)=>{const d=new Image;d.onload=()=>i(d),d.onerror=h=>{console.warn("Error when loading svg image:",t),l(h)},d.src=t});e.width=a.width,e.height=a.height,e.getContext("2d").drawImage(a,0,0);const n=await new Promise(i=>e.toBlob(l=>i(l),"image/png"));return URL.createObjectURL(n)},yt=(s,e,t)=>{const o=new DOMParser().parseFromString(s,"text/xml").childNodes[0];for(const i of o.childNodes)switch(i.tagName){case"text":/www\.lilypond\.org/.test(i.textContent)&&o.removeChild(i);break;case"a":const d=i.getAttribute("xlink:href").match(/:(\d+:\d+:\d+)$/);if(d){const h=d[1];e.has(h)&&o.removeChild(i)}break}const n=o.outerHTML;return H(n,t)},Qt=async(s,e,t)=>{const a=[];for(const o of s)a.push(await yt(o,e,t));return a},R=(s,e)=>{for(const t of s.children)if(t.tagName==="use"){const a=t.getAttribute("xlink:href");if(a){const o=a.substr(1),n=e[o];if(n){const i=n.cloneNode(!0);i.classList.add(...t.classList),(i.classList.contains("staff-line")||i.classList.contains("line")||i.classList.contains("slur"))&&i.children[0].setAttribute("stroke","black"),s.insertBefore(i,t),s.removeChild(t)}}}else R(t,e)},es=async function*({sheetDocument:s,signs:e,hashTable:t,matchedIds:a,canvas:o}){console.assert(!!s,"sheetDocument is null."),console.assert(!!a,"matchedIds is null."),console.assert(!!o,"canvas is null."),console.assert(e||t,"signs & hashTable is both null.");const{inst:n}=A(it);n.doc=s,n.partialVisible=!1,await Promise.resolve(),e||(e=A(mt).inst,e.hashTable=t);const l=[...e.$el.children[0].children].reduce((h,k)=>(h[k.id]=k,h),{}),d=[...n.$el.children];for(const h of d)a.forEach(k=>{h.querySelectorAll(`g[data-href='${k}']`).forEach(u=>u.parentElement.removeChild(u))}),R(h,l),yield await H(h.outerHTML,o)},gt={name:"Icon",props:{name:{type:String,required:!0},size:{type:[Number,String],default:18}},computed:{viewBox(){return"0 0 24 24"}}},kt=["width","height","viewBox"],xt={key:0},pt={key:1},wt={key:2},vt={key:3},bt={key:4},_t={key:5},Tt={key:6},Mt={key:7},Pt={key:8},St={key:9},Ct={key:10},It={key:11},Nt={key:12},Et={key:13},Lt={key:14},Bt={key:15},zt={key:16},Ot={key:17},$t={key:18},At={key:19},Dt={key:20},Ft={key:21},Ht={key:22};function Rt(s,e,t,a,o,n){return r(),c("svg",{xmlns:"http://www.w3.org/2000/svg",width:t.size,height:t.size,viewBox:n.viewBox,fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[t.name==="floppy"?(r(),c("g",xt,[...e[0]||(e[0]=[f("path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"},null,-1),f("polyline",{points:"17 21 17 13 7 13 7 21"},null,-1),f("polyline",{points:"7 3 7 8 15 8"},null,-1)])])):g("",!0),t.name==="gear"?(r(),c("g",pt,[...e[1]||(e[1]=[f("circle",{cx:"12",cy:"12",r:"3"},null,-1),f("path",{d:"M12 1v6m0 6v6M5.64 5.64l4.24 4.24m4.24 4.24l4.24 4.24M1 12h6m6 0h6M5.64 18.36l4.24-4.24m4.24-4.24l4.24-4.24"},null,-1)])])):g("",!0),t.name==="code"?(r(),c("g",wt,[...e[2]||(e[2]=[f("path",{d:"M16 18l4-4-4-4M8 6l-4 4 4 4"},null,-1)])])):g("",!0),t.name==="refresh"?(r(),c("g",vt,[...e[3]||(e[3]=[f("polyline",{points:"23 4 23 10 17 10"},null,-1),f("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"},null,-1)])])):g("",!0),t.name==="music"?(r(),c("g",bt,[...e[4]||(e[4]=[f("path",{d:"M9 18V5l12-2v13"},null,-1),f("circle",{cx:"6",cy:"18",r:"3"},null,-1),f("circle",{cx:"18",cy:"16",r:"3"},null,-1)])])):g("",!0),t.name==="download"?(r(),c("g",_t,[...e[5]||(e[5]=[f("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"},null,-1),f("polyline",{points:"7 10 12 15 17 10"},null,-1),f("line",{x1:"12",y1:"15",x2:"12",y2:"3"},null,-1)])])):g("",!0),t.name==="piano"?(r(),c("g",Tt,[...e[6]||(e[6]=[f("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"},null,-1),f("line",{x1:"9",y1:"3",x2:"9",y2:"12"},null,-1),f("line",{x1:"15",y1:"3",x2:"15",y2:"12"},null,-1)])])):g("",!0),t.name==="palette"?(r(),c("g",Mt,[...e[7]||(e[7]=[B('<circle cx="13.5" cy="6.5" r=".5" data-v-ff0c747e></circle><circle cx="17.5" cy="10.5" r=".5" data-v-ff0c747e></circle><circle cx="8.5" cy="7.5" r=".5" data-v-ff0c747e></circle><circle cx="6.5" cy="12.5" r=".5" data-v-ff0c747e></circle><path d="M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z" data-v-ff0c747e></path>',5)])])):g("",!0),t.name==="sliders"?(r(),c("g",Pt,[...e[8]||(e[8]=[B('<line x1="4" y1="21" x2="4" y2="14" data-v-ff0c747e></line><line x1="4" y1="10" x2="4" y2="3" data-v-ff0c747e></line><line x1="12" y1="21" x2="12" y2="12" data-v-ff0c747e></line><line x1="12" y1="8" x2="12" y2="3" data-v-ff0c747e></line><line x1="20" y1="21" x2="20" y2="16" data-v-ff0c747e></line><line x1="20" y1="12" x2="20" y2="3" data-v-ff0c747e></line><line x1="1" y1="14" x2="7" y2="14" data-v-ff0c747e></line><line x1="9" y1="8" x2="15" y2="8" data-v-ff0c747e></line><line x1="17" y1="16" x2="23" y2="16" data-v-ff0c747e></line>',9)])])):g("",!0),t.name==="git-branch"?(r(),c("g",St,[...e[9]||(e[9]=[f("circle",{cx:"18",cy:"18",r:"3"},null,-1),f("circle",{cx:"6",cy:"6",r:"3"},null,-1),f("path",{d:"M13 6h3a2 2 0 0 1 2 2v7"},null,-1),f("line",{x1:"6",y1:"9",x2:"6",y2:"21"},null,-1)])])):g("",!0),t.name==="speaker"?(r(),c("g",Ct,[...e[10]||(e[10]=[f("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"},null,-1),f("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14M15.54 8.46a5 5 0 0 1 0 7.07"},null,-1)])])):g("",!0),t.name==="playbar"?(r(),c("g",It,[...e[11]||(e[11]=[f("rect",{x:"10.5",y:"3",width:"3",height:"18",rx:"1.5"},null,-1),f("path",{d:"M7 3L10.5 6M17 3L13.5 6M7 21L10.5 18M17 21L13.5 18"},null,-1)])])):g("",!0),t.name==="triangle-right"?(r(),c("g",Nt,[...e[12]||(e[12]=[f("polygon",{points:"5 3 19 12 5 21 5 3"},null,-1)])])):g("",!0),t.name==="bars"?(r(),c("g",Et,[...e[13]||(e[13]=[f("rect",{x:"6",y:"4",width:"4",height:"16"},null,-1),f("rect",{x:"14",y:"4",width:"4",height:"16"},null,-1)])])):g("",!0),t.name==="type"?(r(),c("g",Lt,[...e[14]||(e[14]=[f("polyline",{points:"4 7 4 4 20 4 20 7"},null,-1),f("line",{x1:"9",y1:"20",x2:"15",y2:"20"},null,-1),f("line",{x1:"12",y1:"4",x2:"12",y2:"20"},null,-1)])])):g("",!0),t.name==="layers"?(r(),c("g",Bt,[...e[15]||(e[15]=[f("polygon",{points:"12 2 2 7 12 12 22 7 12 2"},null,-1),f("polyline",{points:"2 17 12 22 22 17"},null,-1),f("polyline",{points:"2 12 12 17 22 12"},null,-1)])])):g("",!0),t.name==="eye-off"?(r(),c("g",zt,[...e[16]||(e[16]=[f("path",{d:"M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"},null,-1),f("line",{x1:"1",y1:"1",x2:"23",y2:"23"},null,-1)])])):g("",!0),t.name==="cursor-arrow"?(r(),c("g",Ot,[...e[17]||(e[17]=[f("path",{d:"M3 3l7.07 16.97 2.51-7.39 7.39-2.51L3 3z"},null,-1)])])):g("",!0),t.name==="brackets"?(r(),c("g",$t,[...e[18]||(e[18]=[f("path",{d:"M9 4H6v16h3M15 4h3v16h-3"},null,-1)])])):g("",!0),t.name==="search"?(r(),c("g",At,[...e[19]||(e[19]=[f("circle",{cx:"11",cy:"11",r:"8"},null,-1),f("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"},null,-1)])])):g("",!0),t.name==="eye"?(r(),c("g",Dt,[...e[20]||(e[20]=[f("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"},null,-1),f("circle",{cx:"12",cy:"12",r:"3"},null,-1)])])):g("",!0),t.name==="book"?(r(),c("g",Ft,[...e[21]||(e[21]=[f("path",{d:"M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z"},null,-1),f("path",{d:"M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z"},null,-1)])])):g("",!0),t.name==="folder"?(r(),c("g",Ht,[...e[22]||(e[22]=[f("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"},null,-1)])])):g("",!0)],8,kt)}const Vt=P(gt,[["render",Rt],["__scopeId","data-v-ff0c747e"]]),jt={name:"check-button",components:{Icon:Vt},props:{value:Boolean,classes:{type:String,default:""},content:String,icon:String},methods:{onClick(){this.$emit("input",!this.value)}}},Ut=["innerHTML"];function Gt(s,e,t,a,o,n){const i=F("Icon");return r(),c("button",{class:T(`check-button ${t.classes} ${t.value?"on":"off"}`),onClick:e[0]||(e[0]=(...l)=>n.onClick&&n.onClick(...l))},[t.icon?(r(),M(i,{key:0,name:t.icon},null,8,["name"])):(r(),c("span",{key:1,innerHTML:t.content},null,8,Ut))],2)}const ts=P(jt,[["render",Gt],["__scopeId","data-v-a7cdcb7f"]]);export{ts as C,Vt as I,mt as S,it as a,Qt as b,C as c,de as d,es as e,Zt as i,me as m,ce as p,qt as s,Yt as t,Jt as u}; | |