diff --git a/Cress-gh/editor.js b/Cress-gh/editor.js index db6d21d..2bb70fd 100644 --- a/Cress-gh/editor.js +++ b/Cress-gh/editor.js @@ -1,5 +1,5 @@ /*! For license information please see editor.js.LICENSE.txt */ -(()=>{var e={4156:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.errorLogsPanelContents=t.hotkeysModal=void 0,t.hotkeysModal='\n
\n \x3c!-- "Display" hotkeys --\x3e\n
\n
Display
\n
\n
\n
Shift
\n
+
\n
+
\n
\n
Zoom In
\n
\n
\n
\n
Shift
\n
+
\n
-
\n
\n
Zoom Out
\n
\n
\n
\n
0
\n
\n
Zoom Reset
\n
\n
\n
\n
h
\n
\n
Hide Glyph
\n
\n
\n
\n
Shift
\n
+
\n
T
\n
\n
Scroll To Syllable Text
\n
\n
\n\n \x3c!-- "Edit" hotkeys --\x3e\n
\n
Edit
\n
\n
\n
Ctrl
\n
+
\n
z
\n
or
\n
\n
+
\n
z
\n
\n
Undo
\n
\n
\n
\n
Ctrl
\n
+
\n
Shift
\n
+
\n
z
\n
or
\n
\n
+
\n
Shift
\n
+
\n
z
\n
\n
Redo
\n
\n
\n
\n
q/w/e/r/t/y
\n
\n
\n Highlight by Staff/Syllable/Neume/LayerElement/Selection/Off\n
\n
\n
\n
\n
1/2/3/4/5/6
\n
\n
\n Select by Syllable/Neume/Neume Component/Staff/Layer Element/BBox\n
\n
\n
\n
\n
Shift
\n
+
\n
Number
\n
\n
\n Begin Insert for the nth option in the selected tab\n
\n
\n
\n\n \x3c!-- "Other" hotkeys --\x3e\n
\n
Other
\n
\n
\n
s
\n
\n
Save File
\n
\n
\n
\n
Esc
\n
\n
Return to Edit Mode
\n
\n
\n
',t.errorLogsPanelContents='
\n
Error Log
\n \n \n \n
\n
'},1179:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;const r=n(25254),i=n(11775),o=n(1448),s=n(24596);t.default=class{constructor(e){this.id=e.id,this.name=e.name,this.header=e.header,this.body=e.body}start(){(0,r.default)(this).then((()=>{this.modal=new i.ModalWindow,(0,s.listenUnsavedChanges)(),document.getElementById("loading").style.display="none",this.table=new o.CressTable(this.id,this.header,this.body)})).then((()=>{}))}}},49390:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.renameHTML=t.newFileHTML=t.newFolderHTML=t.uploadAreaHTML=void 0,t.uploadAreaHTML='
\n\n
\n
\n
Upload Files
\n
\n
\n\n
\n\n
Uploading Documents
\n
\n\n
\n
\n Upload\n
\n
\n
\n\n
\n\n
',t.newFolderHTML='\n
\n
\n
\n
\n \n \n
\n
\n ',t.newFileHTML='\n
\n
\n
\n
\n \n \n
\n
\n ',t.renameHTML='\n
\n
\n
\n
\n \n \n
\n
\n '},40026:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.db=void 0,t.fetchUploads=async function(){try{return(await new Promise(((e,n)=>{t.db.allDocs({include_docs:!0}).then((t=>e(t))).catch((e=>n(e)))}))).rows.map((e=>({id:e.id,name:e.doc?e.doc.name:"undefined"})))}catch(e){return console.log("Couldn't fetch uploaded documents",e.message),[]}},t.parseWORD=s,t.createJson=function(e,t){return new Promise((async r=>{let o,a;if("csv"===t)[o,a]=await async function(e){return new Promise(((t,n)=>{i.parse(e,{header:!0,dynamicTyping:!0,complete:e=>{e.errors.length>0?n(new Error("Error parsing CSV file")):t([e.meta.fields,e.data])},error:e=>{n(e)}})}))}(e);else if("xlsx"===t)[o,a]=await async function(e){return new Promise((async(t,r)=>{const i=new(n(24974).Workbook);let o=(await i.xlsx.load(e.arrayBuffer())).worksheets[0],s=[];o.eachRow({includeEmpty:!0},(function(e,t){1===t&&e.values.forEach((e=>{s.push(e.toString())}))}));let a=[];o.eachRow({includeEmpty:!0},(function(e,t){if(1!==t){let t={};e.values.forEach(((e,n)=>{let r=s[n-1];t[r]=e?e.toString():""})),a.push(t)}}));let l=s.find((e=>e.includes("image")));for(const e of o.getImages()){const t=i.model.media.find((t=>t.index===e.imageId)),n=t.buffer.toString("base64"),r=`data:${t.type};base64,${n}`;a[e.range.tl.nativeRow-1][l]=r}t([s,a])}))}(e);else{if("doc"!==t&&"docx"!==t)return void console.error("Unsupported file format");{let t=await e.arrayBuffer();[o,a]=await s(t)}}r(new Blob([JSON.stringify([o,...a],null,2)],{type:"application/json"}))}))},t.addDocument=function(e,n,r){return new Promise(((i,o)=>{t.db.put({_id:e,name:n,_attachments:{table:{content_type:"application/json",data:r}}}).then((()=>{i(!0)})).catch((t=>{window.alert(`Error Uploading Document: ${t.message}, title: ${n}, id: ${e}.`),o(!1)}))}))},t.deleteDocument=function(e){return new Promise(((n,r)=>{t.db.get(e).then((e=>{t.db.remove(e).then((e=>{n(!0)})).catch((e=>{console.log(e),r(e)}))})).catch((e=>{console.log(e),r(e)}))}))},t.updateDocName=function(e,n){return new Promise(((r,i)=>{t.db.get(e).then((e=>(e.name=n,t.db.put(e)))).catch((e=>i(e)))}))},t.updateAttachment=async function(e,n){try{const r=await t.db.get(e),i=new Blob([JSON.stringify(n)],{type:"application/json"});return r._attachments=r._attachments||{},r._attachments.table={content_type:"application/json",data:i},await t.db.put(r),!0}catch(e){return console.error("Error updating attachment:",e),!1}};const r=n(70984),i=n(44809),o=n(30869);async function s(e){return new Promise(((t,n)=>{o.convertToHtml({arrayBuffer:e}).then((function(e){let n=e.value,r=e.messages;console.log(r);let i=(new DOMParser).parseFromString(n,"text/html").getElementsByTagName("table")[0],o=i.getElementsByTagName("tr")[0].getElementsByTagName("td"),s=Array.from(i.getElementsByTagName("tr")[0].getElementsByTagName("td"),(e=>e.innerText));i.deleteRow(0);let a=i.getElementsByTagName("tr"),l=[];for(let e=0;e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ColumnTools=void 0,t.ColumnTools=class{constructor(e){this.inputHeader=e}getColumns(e){const t=[];for(let n=0;ne.includes("image")));t.push({data:e,renderer:"imgRenderer",readOnly:!1})}else e[n].includes("mei")?t.push({data:e[n],renderer:"meiRenderer"}):t.push({data:e[n]});return t}getColWidths(e){return e.map((e=>e.includes("mei")?200:100))}getIndices(e){return e.map(((e,t)=>t+1))}getMeiData(e){return e.map((e=>e.mei))}convertMeiQuoteSign(e){for(let t=0;t{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CressTable=void 0;const r=n(39344),i=n(27746),o=n(4686),s=n(49025),a=n(38641),l=n(40026),c=n(24596),u=n(31483),d=["afterChange","afterColumnMove","afterColumnSequenceChange","afterCreateCol","afterCreateRow","afterCut","afterRemoveCol","afterRemoveRow","afterRowMove","afterRowSequenceChange"];t.CressTable=class{constructor(e,t,n){this.images=[],this.defaultHeader=["image","name","classification","mei"];const l=document.getElementById("hot-container");this.imageTools=new i.ImageTools(this.images),this.meiTools=new o.MeiTools,this.exportTools=new s.ExportTools,this.columnTools=new a.ColumnTools(t),this.columnTools.convertMeiQuoteSign(n),r.default.renderers.registerRenderer("imgRenderer",this.imageTools.imgRender.bind(this.imageTools)),r.default.renderers.registerRenderer("meiRenderer",this.meiTools.meiRender.bind(this.meiTools));const c=this.columnTools.getColumns(this.defaultHeader),u=this.columnTools.getColWidths(this.defaultHeader),d=this.columnTools.getIndices(n).map(String);let h=t.find((e=>e.includes("image")));this.imageTools.storeImages(h,n);let f=t.find((e=>e.includes("mei")));this.meiTools.initMeiData(f,n),this.table=new r.default(l,{data:n,startCols:11,startRows:n.length,height:"91vh",width:"100%",manualRowResize:!0,manualColumnResize:!0,manualRowMove:!0,selectionMode:"multiple",rowHeights:100,colWidths:u,columns:c,rowHeaders:d,colHeaders:this.defaultHeader,stretchH:"all",minSpareRows:0,autoWrapRow:!0,autoWrapCol:!0,contextMenu:!0,dropdownMenu:!0,className:"table-menu-btn",licenseKey:"non-commercial-and-evaluation",afterLoadData:(e,t)=>{t&&setTimeout(this.initValidationListener.bind(this),0)}}),this.initFileListener(e,t,n,this.defaultHeader),this.initChangeListener()}initFileListener(e,t,n,r){const i=this.table.getPlugin("exportFile");document.getElementById("export-to-csv").addEventListener("click",(()=>{this.exportTools.exportToCsv(i)})),document.getElementById("export-to-excel").addEventListener("click",(async()=>{await this.exportTools.exportToExcel(t,n,r,this.images)})),document.getElementById("save").addEventListener("click",(async()=>{await(0,l.updateAttachment)(e,[t,...n])?((0,c.setSavedStatus)(!0),u.queueNotification("Saved","success")):u.queueNotification("Save failed","error")})),document.body.addEventListener("keydown",(async r=>{"s"===r.key&&(await(0,l.updateAttachment)(e,[t,...n])?((0,c.setSavedStatus)(!0),u.queueNotification("Saved","success")):u.queueNotification("Save failed","error"))}))}initChangeListener(){d.forEach((e=>{this.table.addHook(e,(t=>{"loadData"!=t&&("afterChange"===e?t[0][2]!==t[0][3]&&(0,c.setSavedStatus)(!1):(0,c.setSavedStatus)(!1))}))}))}initValidationListener(){this.meiTools.validateMei(this.table,"afterLoadData"),this.table.addHook("afterChange",((e,t)=>{this.meiTools.validateMei(this.table,"afterChange",e)}))}}},49025:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ExportTools=void 0;const r=n(4213);t.ExportTools=class{exportToCsv(e){e.downloadFile("csv",{bom:!0,columnDelimiter:",",rowHeaders:!1,columnHeaders:!0,exportHiddenColumns:!0,exportHiddenRows:!0,fileExtension:"csv",filename:"table-CSV-file_[YYYY]-[MM]-[DD]",mimeType:"text/csv;charset=UTF-8",rowDelimiter:"\r\n"})}async exportToExcel(e,t,i,o){const s=new(n(24974).Workbook),a=s.addWorksheet("Sheet1");a.properties.defaultRowHeight=150,a.columns=i.map((e=>({width:e.includes("mei")?70:30}))),a.addRow(i);for(let n=0;ne.includes(i[l]))),u=t[n][c];if(i[l].includes("image")&&(u.includes("http")||u.includes("base64"))){u="";const e=s.addImage({base64:t[n][c],extension:"png"}),r=o.find((e=>e.row===n)),i=r.width,d=r.height;a.addImage(e,{tl:{col:l,row:n+1},ext:{width:i,height:d}})}r.push(u)}a.insertRow(n+2,r)}a.columns.forEach((e=>{e.eachCell((e=>{e.alignment={vertical:"top",horizontal:"left",wrapText:!0}}))}));const l=new Date,c=`table-XLSX-file_${l.getFullYear()}-${String(l.getMonth()+1).padStart(2,"0")}-${String(l.getDate()).padStart(2,"0")}.xlsx`,u=await s.xlsx.writeBuffer(),d=new Blob([u],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"});(0,r.saveAs)(d,c)}}},27746:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ImageTools=void 0;const r=n(39344);t.ImageTools=class{constructor(e){this.images=e}storeImages(e,t){t.forEach(((t,n)=>{const r=t[e];r&&(r.includes("http")||r.includes("base64"))&&this.getImageDimensions(r).then((([e,t])=>{this.images.push({image:r,width:e,height:t,row:n})}))}))}getImageDimensions(e){return new Promise(((t,n)=>{const r=new Image;r.onload=()=>{const e=60/r.width,n=60/r.height;let i;i=r.width>60||r.height>60?Math.min(e,n):Math.max(e,n),r.width*=i,r.height*=i,t([r.width,r.height])},r.onerror=n,r.src=e}))}imgRender(e,t,n,i,o,s,a){if(r.default.dom.empty(t),s&&(s.includes("http")||s.includes("base64"))){const r=document.createElement("div");r.classList.add("img-cell-container");const o=document.createElement("div");o.classList.add("img-container");const l=this.createImageElement(s),c=this.images.find((e=>e.row===n));l.style.width=c?`${c.width}px`:"60px",l.style.height=c?`${c.height}px`:"40px",o.appendChild(l);const u=this.createResizeHandle();this.makeImageResizable(l,u,n),o.appendChild(u),r.appendChild(o);const d=this.createButtons(e,n,i);r.appendChild(d),t.appendChild(r),a.readOnly=!0}else if(s)t.innerText=s;else{const r=this.handleImgUpload(e,n,i);t.appendChild(r),a.readOnly=!0}return t}handleImgUpload(e,t,n){const r=document.createElement("div");r.classList.add("upload-img-container");const i=document.createElement("button");i.classList.add("upload-img-btn");const o=document.createElement("img");o.src="./Cress-gh/assets/img/upload-img.svg",o.alt="Upload",i.appendChild(o);const s=document.createElement("input");return s.type="file",s.accept="image/*",s.style.display="none",i.addEventListener("click",(()=>{s.click()})),s.addEventListener("change",(r=>{const i=r.target.files[0];if(i){const r=new FileReader;r.onload=r=>{const i=r.target.result;e.setDataAtCell(t,n,i),e.render(),this.getImageDimensions(i).then((([e,n])=>{this.images.push({image:i,width:e,height:n,row:t})}))},r.readAsDataURL(i)}})),r.appendChild(i),r.appendChild(s),r}createImageElement(e){const t=document.createElement("img");return t.style.overflow="hidden",t.style.maxWidth="100%",t.style.maxHeight="100%",t.src=e,t.addEventListener("mousedown",(e=>{e.preventDefault()})),t}createResizeHandle(){const e=document.createElement("div");return e.style.width="10px",e.style.height="10px",e.style.backgroundColor="gray",e.style.position="absolute",e.style.right="0",e.style.bottom="0",e.style.cursor="se-resize",e}makeImageResizable(e,t,n){t.addEventListener("mousedown",(t=>{t.preventDefault();const r=t.clientX,i=t.clientY,o=e.offsetWidth,s=e.offsetHeight,a=t=>{const a=o+(t.clientX-r),l=s+(t.clientY-i);e.style.width=`${a}px`,e.style.height=`${l}px`;const c=this.images.find((e=>e.row===n));c&&(c.width=a,c.height=l)},l=()=>{document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",l)};document.addEventListener("mousemove",a),document.addEventListener("mouseup",l)}))}createButtons(e,t,n){const r=document.createElement("div");r.classList.add("img-btn-container");const i=document.createElement("button");i.classList.add("icon-btn");const o=document.createElement("img");o.src="./Cress-gh/assets/img/remove-doc.svg",o.alt="Delete",o.title="Delete Image",i.appendChild(o),i.addEventListener("click",(()=>{e.setDataAtCell(t,n,""),e.render()}));const s=document.createElement("button");s.classList.add("icon-btn");const a=document.createElement("img");return a.src="./Cress-gh/assets/img/rename-doc.svg",a.alt="Change",a.title="Change Image",s.appendChild(a),s.addEventListener("click",(()=>{this.handleImgUpload(e,t,n).querySelector("input").click()})),r.appendChild(i),r.appendChild(s),r}}},4686:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MeiTools=void 0;const r=n(39344),i=n(81798),o=n(31483);t.MeiTools=class{constructor(){this.validationInProgress=!1,this.pendingValidations=0,this.validationTools=new i.ValidationTools,this.meiData=[]}initMeiData(e,t){t.forEach(((t,n)=>{const r=t[e];r&&this.meiData.push({mei:r,row:n,isValid:null,errorMsg:null})}))}getMeiData(){return this.meiData}updateMeiData(e,t,n,r){const i=this.meiData.find((t=>t.row===e));i?(void 0!==t&&(i.mei=t),void 0!==n&&(i.isValid=n),void 0!==r&&(i.errorMsg=r)):this.meiData.push({row:e,mei:null!=t?t:i.mei,isValid:null!=n?n:i.isValid,errorMsg:null!=r?r:i.errorMsg})}validateMei(e,t,n){(0,i.updateStatus)("processing");let r=[];switch(t){case"afterLoadData":this.getMeiData().forEach((e=>{if(e){const t=this.validationTools.meiValidator(e.mei).then((([t,n])=>{this.updateMeiData(e.row,e.mei,t,n)}));r.push(t)}}));break;case"afterChange":null==n||n.forEach((([e,t,n,i])=>{if("mei"===t&&n!==i)if(i){const t=this.validationTools.meiValidator(i).then((([t,n])=>{this.updateMeiData(e,i,t,n)}));r.push(t)}else this.updateMeiData(e,i,void 0,void 0)}))}Promise.all(r).then((()=>{e.render();const t=this.meiData.some((e=>!1===e.isValid));(0,i.updateStatus)("done",t)}))}meiRender(e,t,n,i,s,a,l){r.default.dom.empty(t);const c=this.meiData.find((e=>e.row===n));if(c)if(!1===c.isValid){const e=document.createElement("div");e.className="invalid-container";const n=document.createElement("span");n.textContent=c.mei,e.appendChild(n);const r=document.createElement("div");r.className="tooltip-container";const i=document.createElement("div");i.className="tooltip-text",i.textContent=c.errorMsg;const s=document.createElement("img");s.src="./Cress-gh/assets/img/copy-icon.svg",s.className="tooltip-copy";const a=document.createElement("img");a.src="./Cress-gh/assets/img/info-icon.svg",a.className="tooltip-icon",i.appendChild(s),r.appendChild(i),r.appendChild(a),e.appendChild(r),t.appendChild(e),t.style.backgroundColor="#ffbeba",s.addEventListener("click",(()=>{navigator.clipboard.writeText(c.errorMsg).then((()=>{o.queueNotification("Copied to clipboard","success")})).catch((e=>{o.queueNotification("Failed to copy text","error"),console.error("Failed to copy text: ",e)}))}))}else t.textContent=c.mei;return t}}},81798:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ValidationTools=void 0,t.updateStatus=function(e,t){const n=document.getElementById("validation_status");switch(e){case"processing":n.textContent="checking...",n.style.color="gray";break;case"done":t?(n.textContent="INVALID",n.style.color="red"):(n.textContent="VALID",n.style.color="#4bc14b");break;default:n.textContent="unknown",n.style.color="gray"}},t.ValidationTools=class{constructor(){this.schemaPromise=null,this.templatePromise=null,this.fetchSchemaAndTemplate()}async fetchSchemaAndTemplate(){this.schemaPromise=fetch("/Cress/Cress-gh/assets/validation/mei-all.rng").then((e=>e.text())),this.templatePromise=fetch("/Cress/Cress-gh/assets/validation/mei_template.mei").then((e=>e.text()))}meiValidator(e){return new Promise((async t=>{null!==this.schemaPromise&&null!==this.templatePromise||await this.fetchSchemaAndTemplate();try{const n=await this.schemaPromise,r=await this.templatePromise,i=await this.validateMEI(e,n,r);if(null==i)t([!0,null]);else{let e="";i.forEach((t=>{e+=t+"\n"})),t([!1,e])}}catch(e){t([!1,"Failed to validate MEI"])}}))}validateMEI(e,t,n){return new Promise((r=>{try{const i=(new DOMParser).parseFromString(n,"text/xml");i.documentElement.querySelector("layer").innerHTML=e;const o=(new XMLSerializer).serializeToString(i),s=new Worker("/Cress/Cress-gh/workers/ValidationWorker.js");s.postMessage({mei:o,schema:t}),s.onmessage=e=>{const t=e.data;r(t),s.terminate()}}catch(e){r(["Failed to validate MEI"])}}))}}},11775:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ModalWindow=t.ModalWindowView=void 0;const r=n(4156),i=n(49390);var o,s;!function(e){e[e.HOTKEYS=0]="HOTKEYS",e[e.ERROR_LOG=1]="ERROR_LOG",e[e.DOCUMENT_UPLOAD=2]="DOCUMENT_UPLOAD",e[e.MOVE_TO=3]="MOVE_TO",e[e.NEW_FOLDER=4]="NEW_FOLDER",e[e.RENAME=5]="RENAME",e[e.NEW_FILE=6]="NEW_FILE"}(o||(t.ModalWindowView=o={})),function(e){e[e.OPEN=0]="OPEN",e[e.CLOSED=1]="CLOSED"}(s||(s={})),t.ModalWindow=class{constructor(){this.openEditSylTextModalWindow=function(){Array.from(document.getElementsByClassName("cress-modal-window-content")).forEach((e=>{e.classList.remove("visible")})),document.getElementById("cress-modal-window-content-edit-text").classList.add("visible"),document.getElementById("cress-modal-window-edit-text-cancel").removeEventListener("click",this.hideModalWindow),document.getElementById("cress-modal-window-edit-text-cancel").addEventListener("click",this.hideModalWindow.bind(this)),document.getElementById("cress-modal-window-edit-text-save").removeEventListener("click",this.updateSylText.bind(this)),document.getElementById("cress-modal-window-edit-text-save").addEventListener("click",this.updateSylText.bind(this)),document.getElementById("cress-modal-window-container").style.display="flex",this.focusModalWindow()},this.updateSylText=function(){this.hideModalWindow()},this.keydownListener=function(e){e.stopImmediatePropagation(),"Escape"===e.key&&this.hideModalWindow()},this.focusModalWindow=function(){switch(this.modalWindowView){case o.DOCUMENT_UPLOAD:case o.NEW_FOLDER:case o.RENAME:break;default:document.getElementById("cress-modal-window").focus()}},this.modalWindowState=s.CLOSED,this.setupEventListeners()}setupEventListeners(){document.getElementById("cress-modal-window-header-close").addEventListener("click",this.hideModalWindow.bind(this)),document.getElementById("cress-modal-window").addEventListener("keydown",this.keydownListener.bind(this)),document.getElementById("cress-modal-window-container").addEventListener("click",this.focusModalWindow.bind(this))}removeEventListeners(){document.getElementById("cress-modal-window-header-close").removeEventListener("click",this.hideModalWindow.bind(this)),document.getElementById("cress-modal-window").removeEventListener("keydown",this.keydownListener.bind(this)),document.getElementById("cress-modal-window-container").removeEventListener("click",this.focusModalWindow.bind(this))}setModalWindowView(e,t){this.modalWindowView=e,this.setModalWindowContent(t)}getModalWindowView(){return this.modalWindowView.toString()}openModalWindow(){switch(Array.from(document.getElementsByClassName("cress-modal-window-content")).forEach((e=>{e.classList.remove("visible")})),this.modalWindowView){case o.HOTKEYS:document.getElementById("cress-modal-window-content-hotkeys").classList.add("visible");case o.DOCUMENT_UPLOAD:case o.MOVE_TO:case o.NEW_FOLDER:case o.NEW_FILE:case o.RENAME:default:document.getElementById("cress-modal-window-container").style.display="flex",this.focusModalWindow()}document.body.style.overflowX="hidden",document.body.style.overflowY="hidden",this.modalWindowState=s.OPEN}hideModalWindow(){switch(this.modalWindowView){case o.DOCUMENT_UPLOAD:case o.MOVE_TO:case o.NEW_FOLDER:case o.NEW_FILE:case o.RENAME:document.getElementById("cress-modal-window-content-container").innerHTML=""}document.getElementById("cress-modal-window-container").style.display="none",document.body.style.overflowX="hidden",document.body.style.overflowY="scroll",this.modalWindowState=s.CLOSED,this.removeEventListeners()}setModalWindowContent(e){const t=document.getElementById("cress-modal-window-content-container"),n=document.getElementById("cress-modal-window-header-title");switch(this.modalWindowView){case o.HOTKEYS:t.innerHTML=r.hotkeysModal,n.innerText="HOTKEYS";break;case o.ERROR_LOG:t.innerHTML=`
${e}
\n `,n.innerText="ERROR LOG";break;case o.DOCUMENT_UPLOAD:n.innerText="DOCUMENT UPLOAD",t.innerHTML=i.uploadAreaHTML;break;case o.MOVE_TO:n.innerText="MOVE TO";break;case o.NEW_FOLDER:n.innerText="NEW FOLDER",t.innerHTML=i.newFolderHTML;break;case o.NEW_FILE:n.innerText="NEW FILE",t.innerHTML=i.newFileHTML;break;case o.RENAME:n.innerText="RENAME",t.innerHTML=i.renameHTML;break;default:console.error("Unknown selection type. This should not have occurred.")}}updateSelectedBBox(e){}}},31483:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Notification=void 0,t.queueNotification=d;const r=n(22831),i=new Array(0);let o=null;const s=3,a=5e3,l={default:"",warning:"⚠️ ",error:"🔴 ",success:"✅ "};class c{constructor(e,t,n=null){this.message=l[t]+e,this.displayed=!1,this.id=(0,r.v4)(),this.isModeMessage=-1!==e.search("Mode"),this.logInfo=n,this.timeoutID=-1,this.type=t}setTimeoutId(e){this.timeoutID=Math.max(e,-1)}display(){this.displayed=!0}getId(){return this.id}}function u(e){document.getElementById(e)&&document.getElementById(e).remove()}function d(e,t="default",n=null){var r;(function(e){if(e.isModeMessage){if(null!==o)return void window.clearTimeout(o.timeoutID);o=e}i.push(e),i.length>s&&u(i.shift().getId());const t=document.getElementById("notification-content"),n=document.createElement("div");n.classList.add("cress-notification"),n.classList.add(`cress-notification-${e.type}`),n.id=e.getId(),n.innerHTML=e.message,t.append(n),t.style.display="",e.display()})(r=new c(e,t,n)),r.setTimeoutId(window.setTimeout(u,a,r.getId())),document.getElementById(r.getId()).addEventListener("click",(()=>{window.clearTimeout(r.timeoutID),u(r.getId())}))}t.Notification=c,t.default={queueNotification:d}},25254:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=async function(e){const t=await fetch("/Cress/Cress-gh/assets/template.html");document.body.innerHTML=await t.text(),document.getElementById("cress-main-icon").src="https://ddmal.music.mcgill.ca/Cress/favicon.png",Array.from(document.getElementsByClassName("external-link-icon")).forEach((e=>{e.src="/Cress/Cress-gh/assets/img/external-link.svg"})),document.getElementById("filename").innerText=e.name,document.title=e.name;const n=document.querySelector("#file-saved");n.setAttribute("src","/Cress/Cress-gh/assets/img/saved-icon.svg"),n.setAttribute("alt","Your work is saved")}},24596:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setSavedStatus=function(e=!1){n=e,function(){const e=document.querySelector("#file-saved"),t=n?"/Cress/Cress-gh/assets/img/saved-icon.svg":"/Cress/Cress-gh/assets/img/unsaved-icon.svg";e.setAttribute("src",t);const r=n?"Your work is saved":"You have unsaved work";e.setAttribute("alt",r)}()},t.listenUnsavedChanges=function(){window.onbeforeunload=e=>{if(!n)return e.preventDefault(),"You have unsaved changes!"}};let n=!0},42838:function(e){e.exports=function(){"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(e,n){return t=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},t(e,n)}function n(e,r,i){return n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}()?Reflect.construct:function(e,n,r){var i=[null];i.push.apply(i,n);var o=new(Function.bind.apply(e,i));return r&&t(o,r.prototype),o},n.apply(null,arguments)}function r(e){return function(e){if(Array.isArray(e))return i(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n1?n-1:0),i=1;i/gm),$=d(/\${[\w\W]*}/gm),G=d(/^data-[\-\w.\u00B7-\uFFFF]/),q=d(/^aria-[\-\w]+$/),X=d(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),K=d(/^(?:\w+script|data):/i),J=d(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Z=d(/^html$/i),Q=d(/^[a-z][.\w]*(-[.\w]+)+$/i),ee=function(){return"undefined"==typeof window?null:window};return function t(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ee(),i=function(e){return t(e)};if(i.version="2.5.4",i.removed=[],!n||!n.document||9!==n.document.nodeType)return i.isSupported=!1,i;var o=n.document,s=n.document,a=n.DocumentFragment,l=n.HTMLTemplateElement,c=n.Node,d=n.Element,h=n.NodeFilter,f=n.NamedNodeMap,p=void 0===f?n.NamedNodeMap||n.MozNamedAttrMap:f,m=n.HTMLFormElement,g=n.DOMParser,k=n.trustedTypes,te=d.prototype,ne=L(te,"cloneNode"),re=L(te,"nextSibling"),ie=L(te,"childNodes"),oe=L(te,"parentNode");if("function"==typeof l){var se=s.createElement("template");se.content&&se.content.ownerDocument&&(s=se.content.ownerDocument)}var ae=function(t,n){if("object"!==e(t)||"function"!=typeof t.createPolicy)return null;var r=null,i="data-tt-policy-suffix";n.currentScript&&n.currentScript.hasAttribute(i)&&(r=n.currentScript.getAttribute(i));var o="dompurify"+(r?"#"+r:"");try{return t.createPolicy(o,{createHTML:function(e){return e},createScriptURL:function(e){return e}})}catch(e){return console.warn("TrustedTypes policy "+o+" could not be created."),null}}(k,o),le=ae?ae.createHTML(""):"",ce=s,ue=ce.implementation,de=ce.createNodeIterator,he=ce.createDocumentFragment,fe=ce.getElementsByTagName,pe=o.importNode,me={};try{me=O(s).documentMode?s.documentMode:{}}catch(e){}var ge={};i.isSupported="function"==typeof oe&&ue&&void 0!==ue.createHTMLDocument&&9!==me;var ye,be,_e=V,ve=z,we=$,xe=G,Se=q,Ce=K,Me=J,Te=Q,Ee=X,De=null,ke=R({},[].concat(r(A),r(I),r(P),r(H),r(U))),Re=null,Oe=R({},[].concat(r(F),r(Y),r(W),r(B))),Le=Object.seal(Object.create(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Ae=null,Ie=null,Pe=!0,Ne=!0,He=!1,je=!0,Ue=!1,Fe=!0,Ye=!1,We=!1,Be=!1,Ve=!1,ze=!1,$e=!1,Ge=!0,qe=!1,Xe=!0,Ke=!1,Je={},Ze=null,Qe=R({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),et=null,tt=R({},["audio","video","img","source","image","track"]),nt=null,rt=R({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),it="http://www.w3.org/1998/Math/MathML",ot="http://www.w3.org/2000/svg",st="http://www.w3.org/1999/xhtml",at=st,lt=!1,ct=null,ut=R({},[it,ot,st],w),dt=["application/xhtml+xml","text/html"],ht=null,ft=s.createElement("form"),pt=function(e){return e instanceof RegExp||e instanceof Function},mt=function(t){ht&&ht===t||(t&&"object"===e(t)||(t={}),t=O(t),ye=ye=-1===dt.indexOf(t.PARSER_MEDIA_TYPE)?"text/html":t.PARSER_MEDIA_TYPE,be="application/xhtml+xml"===ye?w:v,De="ALLOWED_TAGS"in t?R({},t.ALLOWED_TAGS,be):ke,Re="ALLOWED_ATTR"in t?R({},t.ALLOWED_ATTR,be):Oe,ct="ALLOWED_NAMESPACES"in t?R({},t.ALLOWED_NAMESPACES,w):ut,nt="ADD_URI_SAFE_ATTR"in t?R(O(rt),t.ADD_URI_SAFE_ATTR,be):rt,et="ADD_DATA_URI_TAGS"in t?R(O(tt),t.ADD_DATA_URI_TAGS,be):tt,Ze="FORBID_CONTENTS"in t?R({},t.FORBID_CONTENTS,be):Qe,Ae="FORBID_TAGS"in t?R({},t.FORBID_TAGS,be):{},Ie="FORBID_ATTR"in t?R({},t.FORBID_ATTR,be):{},Je="USE_PROFILES"in t&&t.USE_PROFILES,Pe=!1!==t.ALLOW_ARIA_ATTR,Ne=!1!==t.ALLOW_DATA_ATTR,He=t.ALLOW_UNKNOWN_PROTOCOLS||!1,je=!1!==t.ALLOW_SELF_CLOSE_IN_ATTR,Ue=t.SAFE_FOR_TEMPLATES||!1,Fe=!1!==t.SAFE_FOR_XML,Ye=t.WHOLE_DOCUMENT||!1,Ve=t.RETURN_DOM||!1,ze=t.RETURN_DOM_FRAGMENT||!1,$e=t.RETURN_TRUSTED_TYPE||!1,Be=t.FORCE_BODY||!1,Ge=!1!==t.SANITIZE_DOM,qe=t.SANITIZE_NAMED_PROPS||!1,Xe=!1!==t.KEEP_CONTENT,Ke=t.IN_PLACE||!1,Ee=t.ALLOWED_URI_REGEXP||Ee,at=t.NAMESPACE||st,Le=t.CUSTOM_ELEMENT_HANDLING||{},t.CUSTOM_ELEMENT_HANDLING&&pt(t.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Le.tagNameCheck=t.CUSTOM_ELEMENT_HANDLING.tagNameCheck),t.CUSTOM_ELEMENT_HANDLING&&pt(t.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Le.attributeNameCheck=t.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),t.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof t.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(Le.allowCustomizedBuiltInElements=t.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Ue&&(Ne=!1),ze&&(Ve=!0),Je&&(De=R({},r(U)),Re=[],!0===Je.html&&(R(De,A),R(Re,F)),!0===Je.svg&&(R(De,I),R(Re,Y),R(Re,B)),!0===Je.svgFilters&&(R(De,P),R(Re,Y),R(Re,B)),!0===Je.mathMl&&(R(De,H),R(Re,W),R(Re,B))),t.ADD_TAGS&&(De===ke&&(De=O(De)),R(De,t.ADD_TAGS,be)),t.ADD_ATTR&&(Re===Oe&&(Re=O(Re)),R(Re,t.ADD_ATTR,be)),t.ADD_URI_SAFE_ATTR&&R(nt,t.ADD_URI_SAFE_ATTR,be),t.FORBID_CONTENTS&&(Ze===Qe&&(Ze=O(Ze)),R(Ze,t.FORBID_CONTENTS,be)),Xe&&(De["#text"]=!0),Ye&&R(De,["html","head","body"]),De.table&&(R(De,["tbody"]),delete Ae.tbody),u&&u(t),ht=t)},gt=R({},["mi","mo","mn","ms","mtext"]),yt=R({},["foreignobject","annotation-xml"]),bt=R({},["title","style","font","a","script"]),_t=R({},I);R(_t,P),R(_t,N);var vt=R({},H);R(vt,j);var wt=function(e){_(i.removed,{element:e});try{e.parentNode.removeChild(e)}catch(t){try{e.outerHTML=le}catch(t){e.remove()}}},xt=function(e,t){try{_(i.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){_(i.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e&&!Re[e])if(Ve||ze)try{wt(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},St=function(e){var t,n;if(Be)e=""+e;else{var r=x(e,/^[\r\n\t ]+/);n=r&&r[0]}"application/xhtml+xml"===ye&&at===st&&(e=''+e+"");var i=ae?ae.createHTML(e):e;if(at===st)try{t=(new g).parseFromString(i,ye)}catch(e){}if(!t||!t.documentElement){t=ue.createDocument(at,"template",null);try{t.documentElement.innerHTML=lt?le:i}catch(e){}}var o=t.body||t.documentElement;return e&&n&&o.insertBefore(s.createTextNode(n),o.childNodes[0]||null),at===st?fe.call(t,Ye?"html":"body")[0]:Ye?t.documentElement:o},Ct=function(e){return de.call(e.ownerDocument||e,e,h.SHOW_ELEMENT|h.SHOW_COMMENT|h.SHOW_TEXT|h.SHOW_PROCESSING_INSTRUCTION|h.SHOW_CDATA_SECTION,null,!1)},Mt=function(e){return e instanceof m&&(void 0!==e.__depth&&"number"!=typeof e.__depth||void 0!==e.__removalCount&&"number"!=typeof e.__removalCount||"string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof p)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes)},Tt=function(t){return"object"===e(c)?t instanceof c:t&&"object"===e(t)&&"number"==typeof t.nodeType&&"string"==typeof t.nodeName},Et=function(e,t,n){ge[e]&&y(ge[e],(function(e){e.call(i,t,n,ht)}))},Dt=function(e){var t;if(Et("beforeSanitizeElements",e,null),Mt(e))return wt(e),!0;if(T(/[\u0080-\uFFFF]/,e.nodeName))return wt(e),!0;var n=be(e.nodeName);if(Et("uponSanitizeElement",e,{tagName:n,allowedTags:De}),e.hasChildNodes()&&!Tt(e.firstElementChild)&&(!Tt(e.content)||!Tt(e.content.firstElementChild))&&T(/<[/\w]/g,e.innerHTML)&&T(/<[/\w]/g,e.textContent))return wt(e),!0;if("select"===n&&T(/