From dab170a6feb66986abf02b9de34c75aaf48a5373 Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Fri, 8 Oct 2021 22:25:36 +0100 Subject: [PATCH] Updated version and assets for release v21.08.5 --- public/dist/app.js | 2 +- version | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/dist/app.js b/public/dist/app.js index 5d07b6d78..05b405117 100644 --- a/public/dist/app.js +++ b/public/dist/app.js @@ -53,7 +53,7 @@ Expect errors in decoding.`),Z=Z.replace(/[^A-Za-z0-9\+\/\=]/g,"");ce=this.KEY_S `+c;this.cm.setValue(f),this.cm.setCursor(l.line,l.ch)}),window.$events.listen("editor::prepend",n=>{let l=this.cm.getCursor("from"),c=t(n),f=c+` `+this.cm.getValue();this.cm.setValue(f);let a=c.split(` `).length;this.cm.setCursor(l.line+a,l.ch)}),window.$events.listen("editor::insert",n=>{let l=t(n);this.cm.replaceSelection(l)}),window.$events.listen("editor::focus",()=>{this.cm.focus()})}},_v=kv;var Sv=class{constructor(t){this.elem=t,this.inviteOption=t.querySelector("input[name=send_invite]"),this.inviteOption&&(this.inviteOption.addEventListener("change",this.inviteOptionChange.bind(this)),this.inviteOptionChange())}inviteOptionChange(){let t=this.inviteOption.value==="true",n=this.elem.querySelectorAll("input[type=password]");for(let c of n)c.disabled=t;let l=this.elem.querySelector("#password-input-container");l&&(l.style.display=t?"none":"block")}},Ev=Sv;var Cv=class{constructor(t){this.elem=t,this.type=t.getAttribute("notification"),this.textElem=t.querySelector("span"),this.autohide=this.elem.hasAttribute("data-autohide"),this.elem.style.display="grid",window.$events.listen(this.type,n=>{this.show(n)}),t.addEventListener("click",this.hide.bind(this)),t.hasAttribute("data-show")&&setTimeout(()=>this.show(this.textElem.textContent),100),this.hideCleanup=this.hideCleanup.bind(this)}show(t=""){if(this.elem.removeEventListener("transitionend",this.hideCleanup),this.textElem.textContent=t,this.elem.style.display="grid",setTimeout(()=>{this.elem.classList.add("showing")},1),this.autohide){let n=t.split(" ").length,l=Math.max(2e3,1e3+250*n);setTimeout(this.hide.bind(this),l)}}hide(){this.elem.classList.remove("showing"),this.elem.addEventListener("transitionend",this.hideCleanup)}hideCleanup(){this.elem.style.display="none",this.elem.removeEventListener("transitionend",this.hideCleanup)}},Tv=Cv;var Av=class{setup(){this.removeButton=this.$refs.remove,this.showButton=this.$refs.show,this.input=this.$refs.input,this.setupListeners()}setupListeners(){Rt(this.removeButton,()=>{this.input.value="",this.input.classList.add("hidden"),this.removeButton.classList.add("hidden"),this.showButton.classList.remove("hidden")}),Rt(this.showButton,()=>{this.input.classList.remove("hidden"),this.removeButton.classList.remove("hidden"),this.showButton.classList.add("hidden")})}},Lv=Av;var Dv=class{setup(){this.elem=this.$el,this.pageId=Number(this.$opts.pageId),this.container=this.$refs.commentContainer,this.formContainer=this.$refs.formContainer,this.commentCountBar=this.$refs.commentCountBar,this.addButtonContainer=this.$refs.addButtonContainer,this.replyToRow=this.$refs.replyToRow,this.updatedText=this.$opts.updatedText,this.deletedText=this.$opts.deletedText,this.createdText=this.$opts.createdText,this.countText=this.$opts.countText,this.editingComment=null,this.parentId=null,this.formContainer&&(this.form=this.formContainer.querySelector("form"),this.formInput=this.form.querySelector("textarea"),this.form.addEventListener("submit",this.saveComment.bind(this))),this.elem.addEventListener("click",this.handleAction.bind(this)),this.elem.addEventListener("submit",this.updateComment.bind(this))}handleAction(t){let n=t.target.closest("[action]");if(t.target.matches('a[href^="#"]')){let f=t.target.href.split("#")[1];to(document.querySelector("#"+f))}if(n===null)return;t.preventDefault();let l=n.getAttribute("action"),c=n.closest("[comment]");l==="edit"&&this.editComment(c),l==="closeUpdateForm"&&this.closeUpdateForm(),l==="delete"&&this.deleteComment(c),l==="addComment"&&this.showForm(),l==="hideForm"&&this.hideForm(),l==="reply"&&this.setReply(c),l==="remove-reply-to"&&this.removeReplyTo()}closeUpdateForm(){!this.editingComment||(this.editingComment.querySelector("[comment-content]").style.display="block",this.editingComment.querySelector("[comment-edit-container]").style.display="none")}editComment(t){this.hideForm(),this.editingComment&&this.closeUpdateForm(),t.querySelector("[comment-content]").style.display="none",t.querySelector("[comment-edit-container]").style.display="block";let n=t.querySelector("[comment-edit-container] textarea"),l=n.value.split(` -`).length;n.style.height=l*20+40+"px",this.editingComment=t}updateComment(t){let n=t.target;t.preventDefault();let c={text:n.querySelector("textarea").value,parent_id:this.parentId||null};this.showLoading(n);let f=this.editingComment.getAttribute("comment");window.$http.put(`/comment/${f}`,c).then(a=>{let h=document.createElement("div");h.innerHTML=a.data,this.editingComment.innerHTML=h.children[0].innerHTML,window.$events.success(this.updatedText),window.components.init(this.editingComment),this.closeUpdateForm(),this.editingComment=null}).catch(window.$events.showValidationErrors).then(()=>{this.hideLoading(n)})}deleteComment(t){let n=t.getAttribute("comment");this.showLoading(t.querySelector("[comment-content]")),window.$http.delete(`/comment/${n}`).then(l=>{t.parentNode.removeChild(t),window.$events.success(this.deletedText),this.updateCount(),this.hideForm()})}saveComment(t){t.preventDefault(),t.stopPropagation();let l={text:this.formInput.value,parent_id:this.parentId||null};this.showLoading(this.form),window.$http.post(`/comment/${this.pageId}`,l).then(c=>{let f=document.createElement("div");f.innerHTML=c.data;let a=f.children[0];this.container.appendChild(a),window.components.init(a),window.$events.success(this.createdText),this.resetForm(),this.updateCount()}).catch(c=>{window.$events.showValidationErrors(c),this.hideLoading(this.form)})}updateCount(){let t=this.container.children.length;this.elem.querySelector("[comments-title]").textContent=window.trans_plural(this.countText,t,{count:t})}resetForm(){this.formInput.value="",this.formContainer.appendChild(this.form),this.hideForm(),this.removeReplyTo(),this.hideLoading(this.form)}showForm(){this.formContainer.style.display="block",this.formContainer.parentNode.style.display="block",this.addButtonContainer.style.display="none",this.formInput.focus(),this.formInput.scrollIntoView({behavior:"smooth"})}hideForm(){this.formContainer.style.display="none",this.formContainer.parentNode.style.display="none",this.getCommentCount()>0?this.elem.appendChild(this.addButtonContainer):this.commentCountBar.appendChild(this.addButtonContainer),this.addButtonContainer.style.display="block"}getCommentCount(){return this.elem.querySelectorAll(".comment-box[comment]").length}setReply(t){this.showForm(),this.parentId=Number(t.getAttribute("local-id")),this.replyToRow.style.display="block";let n=this.replyToRow.querySelector("a");n.textContent=`#${this.parentId}`,n.href=`#comment${this.parentId}`}removeReplyTo(){this.parentId=null,this.replyToRow.style.display="none"}showLoading(t){let n=t.querySelectorAll(".form-group");for(let l of n)l.style.display="none";t.querySelector(".form-group.loading").style.display="block"}hideLoading(t){let n=t.querySelectorAll(".form-group");for(let l of n)l.style.display="block";t.querySelector(".form-group.loading").style.display="none"}},Iv=Dv;var Fv=_t(Qs());var Mv=class{constructor(t){if(this.elem=t,this.pageId=t.getAttribute("page-display"),cr.highlight(),this.setupPointer(),this.setupNavHighlighting(),this.setupDetailsCodeBlockRefresh(),window.location.hash){let l=window.location.hash.replace(/\%20/g," ").substr(1);this.goToText(l)}let n=document.querySelector(".sidebar-page-nav");n&&Ut(n,"a","click",(l,c)=>{l.preventDefault(),window.components["tri-layout"][0].showContent();let f=c.getAttribute("href").substr(1);this.goToText(f),window.history.pushState(null,null,"#"+f)})}goToText(t){let n=document.getElementById(t);if(Qo(".page-content [data-highlighted]",l=>{l.removeAttribute("data-highlighted"),l.style.backgroundColor=null}),n!==null)to(n);else{let l=Uc(".page-content > div > *",t);l&&to(l)}}setupPointer(){let t=document.getElementById("pointer");if(!t)return;t=t.parentNode.removeChild(t);let n=t.querySelector("div.pointer"),l=!1,c=!1,f=!0,a="";Ut(t,"input","click",(d,p)=>{p.select(),d.stopPropagation()}),Jo(t,["click","focus"],d=>{d.stopPropagation()}),Ut(t,"span.icon","click",(d,p)=>{d.stopPropagation(),f=!f,p.querySelector('[data-icon="include"]').style.display=f?"none":"inline",p.querySelector('[data-icon="link"]').style.display=f?"inline":"none",h()}),new Fv.default(t.querySelector("button")),Jo(document.body,["click","focus"],d=>{!l||c||(t=t.parentElement.removeChild(t),l=!1)});let h=d=>{let p=f?window.baseUrl(`/link/${this.pageId}#${a}`):`{{@${this.pageId}#${a}}}`;f&&!p.startsWith("http")&&(p=window.location.protocol+"//"+window.location.host+p),t.querySelector("input").value=p;let y=t.querySelector("#pointer-edit");if(y&&d){let g=y.dataset.editHref,v=d.id,b=d.textContent&&d.textContent.substring(0,50);y.href=`${g}?content-id=${v}&content-text=${encodeURIComponent(b)}`}};Qo('.page-content [id^="bkmrk"]',d=>{Jo(d,["mouseup","keyup"],p=>{p.stopPropagation(),window.getSelection().toString().length!==0&&(a=d.id,h(d),d.parentNode.insertBefore(t,d),t.style.display="block",l=!0,c=!0,requestAnimationFrame(()=>{let g=d.getBoundingClientRect(),v=p.pageX-g.left-164;v<0&&(v=0);let b=v/g.width*100;n.style.left=b+"%",setTimeout(()=>{c=!1},100)}))})})}setupNavHighlighting(){if(!("IntersectionObserver"in window)||!("IntersectionObserverEntry"in window)||!("intersectionRatio"in window.IntersectionObserverEntry.prototype))return;let t=document.querySelector(".sidebar-page-nav"),n=document.querySelector(".page-content").querySelectorAll("h1, h2, h3, h4, h5, h6");n.length>0&&t!==null&&l(n);function l(a){let h={rootMargin:"0px 0px 0px 0px",threshold:1},d=new IntersectionObserver(c,h);for(let p of a)d.observe(p)}function c(a,h){for(let d of a){let p=d.intersectionRatio===1;f(d.target.id,p)}}function f(a,h){Qo('a[href="#'+a+'"]',d=>{d.closest("li").classList.toggle("current-heading",h)})}}setupDetailsCodeBlockRefresh(){let t=l=>{[...l.target.querySelectorAll(".CodeMirror")].forEach(f=>f.CodeMirror&&f.CodeMirror.refresh())};[...this.elem.querySelectorAll("details")].forEach(l=>l.addEventListener("toggle",t))}},Ov=Mv;function Pv(i){let t=new Date(i*1e3),n=t.getHours(),l=t.getMinutes();return`${(n>9?"":"0")+n}:${(l>9?"":"0")+l}`}var Rv=class{setup(){this.draftsEnabled=this.$opts.draftsEnabled==="true",this.editorType=this.$opts.editorType,this.pageId=Number(this.$opts.pageId),this.isNewDraft=this.$opts.pageNewDraft==="true",this.hasDefaultTitle=this.$opts.hasDefaultTitle||!1,this.container=this.$el,this.titleElem=this.$refs.titleContainer.querySelector("input"),this.saveDraftButton=this.$refs.saveDraft,this.discardDraftButton=this.$refs.discardDraft,this.discardDraftWrap=this.$refs.discardDraftWrap,this.draftDisplay=this.$refs.draftDisplay,this.draftDisplayIcon=this.$refs.draftDisplayIcon,this.changelogInput=this.$refs.changelogInput,this.changelogDisplay=this.$refs.changelogDisplay,this.draftText=this.$opts.draftText,this.autosaveFailText=this.$opts.autosaveFailText,this.editingPageText=this.$opts.editingPageText,this.draftDiscardedText=this.$opts.draftDiscardedText,this.setChangelogText=this.$opts.setChangelogText,this.editorHTML="",this.editorMarkdown="",this.autoSave={interval:null,frequency:3e4,last:0},this.pageId!==0&&this.draftsEnabled&&window.setTimeout(()=>{this.startAutoSave()},1e3),this.draftDisplay.innerHTML=this.draftText,this.setupListeners(),this.setInitialFocus()}setupListeners(){window.$events.listen("editor-save-draft",this.saveDraft.bind(this)),window.$events.listen("editor-save-page",this.savePage.bind(this)),window.$events.listen("editor-html-change",t=>{this.editorHTML=t}),window.$events.listen("editor-markdown-change",t=>{this.editorMarkdown=t}),this.changelogInput.addEventListener("change",this.updateChangelogDisplay.bind(this)),Rt(this.saveDraftButton,this.saveDraft.bind(this)),Rt(this.discardDraftButton,this.discardDraft.bind(this))}setInitialFocus(){if(this.hasDefaultTitle)return this.titleElem.select();window.setTimeout(()=>{window.$events.emit("editor::focus","")},500)}startAutoSave(){let t=this.titleElem.value.trim()+"::"+this.editorHTML;this.autoSaveInterval=window.setInterval(()=>{if(Date.now()-this.autoSave.last{this.draftDisplayIcon.classList.remove("visible")},2e3)}async discardDraft(){let t;try{t=await window.$http.get(`/ajax/page/${this.pageId}`)}catch(n){return console.error(n)}this.autoSave.interval&&window.clearInterval(this.autoSave.interval),this.draftDisplay.innerText=this.editingPageText,this.toggleDiscardDraftVisibility(!1),window.$events.emit("editor-html-update",t.data.html||""),window.$events.emit("editor-markdown-update",t.data.markdown||t.data.html),this.titleElem.value=t.data.name,window.setTimeout(()=>{this.startAutoSave()},1e3),window.$events.emit("success",this.draftDiscardedText)}updateChangelogDisplay(){let t=this.changelogInput.value.trim();t.length===0?t=this.setChangelogText:t.length>16&&(t=t.slice(0,16)+"..."),this.changelogDisplay.innerText=t}toggleDiscardDraftVisibility(t){this.discardDraftWrap.classList.toggle("hidden",!t)}},zv=Rv;var Nv=class{constructor(t){this.elem=t,this.input=t.querySelector("input"),this.resetButton=t.querySelector("[page-picker-reset]"),this.selectButton=t.querySelector("[page-picker-select]"),this.display=t.querySelector("[page-picker-display]"),this.defaultDisplay=t.querySelector("[page-picker-default]"),this.buttonSep=t.querySelector("span.sep"),this.value=this.input.value,this.setupListeners()}setupListeners(){this.selectButton.addEventListener("click",this.showPopup.bind(this)),this.display.parentElement.addEventListener("click",this.showPopup.bind(this)),this.resetButton.addEventListener("click",t=>{this.setValue("","")})}showPopup(){window.EntitySelectorPopup.show(t=>{this.setValue(t.id,t.name)})}setValue(t,n){this.value=t,this.input.value=t,this.controlView(n)}controlView(t){let n=this.value&&this.value!==0;if(Ba(this.resetButton,n),Ba(this.buttonSep,n),Ba(this.defaultDisplay,!n),Ba(this.display,n),n){let l=this.getAssetIdFromVal();this.display.textContent=`#${l}, ${t}`,this.display.href=window.baseUrl(`/link/${l}`)}}getAssetIdFromVal(){return Number(this.value)}};function Ba(i,t){let n=i.tagName==="BUTTON"||i.tagName==="SPAN"?"inline-block":"block";i.style.display=t?n:"none"}var Bv=Nv;var qv=class{constructor(t){this.container=t,t.querySelector("[permissions-table-toggle-all]").addEventListener("click",this.toggleAllClick.bind(this));let l=t.querySelectorAll("[permissions-table-toggle-all-in-row]");for(let f of l)f.addEventListener("click",this.toggleRowClick.bind(this));let c=t.querySelectorAll("[permissions-table-toggle-all-in-column]");for(let f of c)f.addEventListener("click",this.toggleColumnClick.bind(this))}toggleAllClick(t){t.preventDefault(),this.toggleAllInElement(this.container)}toggleRowClick(t){t.preventDefault(),this.toggleAllInElement(t.target.closest("tr"))}toggleColumnClick(t){t.preventDefault();let n=t.target.closest("th,td"),l=Array.from(n.parentElement.children).indexOf(n),c=n.closest("table").querySelectorAll("tr"),f=[];for(let a of c){let h=a.children[l];h&&f.push(...h.querySelectorAll("input[type=checkbox]"))}this.toggleAllInputs(f)}toggleAllInElement(t){let n=t.querySelectorAll("input[type=checkbox]");this.toggleAllInputs(n)}toggleAllInputs(t){let n=t.length>0?t[0].checked:!1;for(let l of t)l.checked=!n,l.dispatchEvent(new Event("change"))}},jv=qv;var $v=class{setup(){this.container=this.$el,this.hideButtons=this.$manyRefs.hide||[],this.onkeyup=null,this.onHide=null,this.setupListeners()}setupListeners(){let t=null;this.container.addEventListener("mousedown",n=>{t=n.target}),this.container.addEventListener("click",n=>{if(n.target===this.container&&t===this.container)return this.hide()}),Rt(this.hideButtons,n=>this.hide())}hide(t=null){ya(this.container,240,t),this.onkeyup&&(window.removeEventListener("keyup",this.onkeyup),this.onkeyup=null),this.onHide&&this.onHide()}show(t=null,n=null){Ff(this.container,240,t),this.onkeyup=l=>{l.key==="Escape"&&this.hide()},window.addEventListener("keyup",this.onkeyup),this.onHide=n}},Uv=$v;var Hv=class{constructor(t){this.elem=t,this.colorInput=t.querySelector("input[type=color]"),this.lightColorInput=t.querySelector('input[name="setting-app-color-light"]'),this.resetButton=t.querySelector("[setting-app-color-picker-reset]"),this.defaultButton=t.querySelector("[setting-app-color-picker-default]"),this.colorInput.addEventListener("change",this.updateColor.bind(this)),this.colorInput.addEventListener("input",this.updateColor.bind(this)),this.resetButton.addEventListener("click",n=>{this.colorInput.value=this.colorInput.dataset.current,this.updateColor()}),this.defaultButton.addEventListener("click",n=>{this.colorInput.value=this.colorInput.dataset.default,this.updateColor()})}updateColor(){let t=this.colorInput.value,n=this.hexToRgb(t),l="rgba("+[n.r,n.g,n.b,"0.15"].join(",")+")";this.lightColorInput.value=l;let c=document.getElementById("custom-styles"),f=c.getAttribute("data-color"),a=c.getAttribute("data-color-light");c.innerHTML=c.innerHTML.split(f).join(t),c.innerHTML=c.innerHTML.split(a).join(l),c.setAttribute("data-color",t),c.setAttribute("data-color-light",l)}hexToRgb(t){let n=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return{r:n?parseInt(n[1],16):0,g:n?parseInt(n[2],16):0,b:n?parseInt(n[3],16):0}}},Wv=Hv;var Gv=class{constructor(t){this.elem=t,this.colorInput=t.querySelector("input[type=color]"),this.resetButton=t.querySelector("[setting-color-picker-reset]"),this.defaultButton=t.querySelector("[setting-color-picker-default]"),this.resetButton.addEventListener("click",n=>{this.colorInput.value=this.colorInput.dataset.current}),this.defaultButton.addEventListener("click",n=>{this.colorInput.value=this.colorInput.dataset.default})}},Kv=Gv;var Vv=class{constructor(t){this.elem=t,this.input=document.getElementById("books-input"),this.shelfBooksList=t.querySelector("[shelf-sort-assigned-books]"),this.initSortable(),this.setupListeners()}initSortable(){let t=this.elem.querySelectorAll(".scroll-box");for(let n of t)new vi(n,{group:"shelf-books",ghostClass:"primary-background-light",animation:150,onSort:this.onChange.bind(this)})}setupListeners(){this.elem.addEventListener("click",t=>{let n=t.target.closest(".scroll-box-item:not(.instruction)");n&&(t.preventDefault(),this.sortItemClick(n))})}sortItemClick(t){let n=this.elem.querySelectorAll(".scroll-box"),l=Array.from(n).filter(c=>t.parentElement!==c);l.length>0&&l[0].appendChild(t),this.onChange()}onChange(){let t=Array.from(this.shelfBooksList.querySelectorAll("[data-id]"));this.input.value=t.map(n=>n.getAttribute("data-id")).join(",")}},Yv=Vv;var Xv=class{constructor(t){this.elem=t,this.toggleElem=t.querySelector(".sidebar-toggle"),this.toggleElem.addEventListener("click",this.toggle.bind(this))}toggle(t=!0){this.elem.classList.toggle("open")}},Zv=Xv;var Qv=class{setup(){this.container=this.$el,this.handleSelector=this.$opts.handleSelector;let t=new vi(this.container,{handle:this.handleSelector,animation:150,onSort:()=>{this.$emit("sort",{ids:t.toArray()})},setData(n,l){let c=l.getAttribute("data-drag-content");if(c){let f=JSON.parse(c);for(let[a,h]of Object.entries(f))n.setData(a,h)}},revertOnSpill:!0,dropBubble:!0,dragoverBubble:!1})}},Jv=Qv;var ey=class{setup(){this.filter=this.$opts.filter,this.$el.addEventListener("change",t=>{if(this.filter&&!t.target.matches(this.filter))return;let n=this.$el.closest("form");n&&n.submit()})}},ty=ey;var ry=class{setup(){this.tabContentsByName={},this.tabButtonsByName={},this.allContents=[],this.allButtons=[];for(let[t,n]of Object.entries(this.$manyRefs||{})){if(t.startsWith("toggle")){let l=t.replace("toggle","").toLowerCase();Rt(n,c=>this.show(l)),this.allButtons.push(...n),this.tabButtonsByName[l]=n}if(t.startsWith("content")){let l=t.replace("content","").toLowerCase();this.tabContentsByName[l]=n,this.allContents.push(...n)}}}show(t){this.allContents.forEach(c=>{c.classList.add("hidden"),c.classList.remove("selected")}),this.allButtons.forEach(c=>c.classList.remove("selected"));let n=this.tabContentsByName[t]||[],l=this.tabButtonsByName[t]||[];n.length>0&&(n.forEach(c=>{c.classList.remove("hidden"),c.classList.add("selected")}),l.forEach(c=>c.classList.add("selected")))}},ny=ry;var iy=class{setup(){this.addRemoveComponentEl=this.$refs.addRemove,this.container=this.$el,this.rowSelector=this.$opts.rowSelector,this.setupListeners()}setupListeners(){this.container.addEventListener("change",t=>{let n=this.addRemoveComponentEl.components["add-remove-rows"];this.hasEmptyRows()||n.add()})}hasEmptyRows(){return[...this.container.querySelectorAll(this.rowSelector)].find(l=>[...l.querySelectorAll("input")].filter(c=>c.value).length===0)!==void 0}},oy=iy;var ay=class{constructor(t){this.elem=t,this.list=t.querySelector("[template-manager-list]"),this.searching=!1,Ut(this.elem,"[template-action]","click",this.handleTemplateActionClick.bind(this)),Ut(this.elem,".pagination a","click",this.handlePaginationClick.bind(this)),Ut(this.elem,".template-item-content","click",this.handleTemplateItemClick.bind(this)),Ut(this.elem,".template-item","dragstart",this.handleTemplateItemDragStart.bind(this)),this.setupSearchBox()}handleTemplateItemClick(t,n){let l=n.closest("[template-id]").getAttribute("template-id");this.insertTemplate(l,"replace")}handleTemplateItemDragStart(t,n){let l=n.closest("[template-id]").getAttribute("template-id");t.dataTransfer.setData("bookstack/template",l),t.dataTransfer.setData("text/plain",l)}handleTemplateActionClick(t,n){t.stopPropagation();let l=n.getAttribute("template-action"),c=n.closest("[template-id]").getAttribute("template-id");this.insertTemplate(c,l)}async insertTemplate(t,n="replace"){let l=await window.$http.get(`/templates/${t}`),c="editor::"+n;window.$events.emit(c,l.data)}async handlePaginationClick(t,n){t.preventDefault();let l=n.getAttribute("href"),c=await window.$http.get(l);this.list.innerHTML=c.data}setupSearchBox(){let t=this.elem.querySelector(".search-box");if(!t)return;let n=t.querySelector("input"),l=t.querySelector("button"),c=t.querySelector("button.search-box-cancel");async function f(){let a=n.value,h=await window.$http.get("/templates",{search:a});c.style.display=a?"block":"none",this.list.innerHTML=h.data}f=f.bind(this),t.addEventListener("keypress",a=>{a.key==="Enter"&&(a.preventDefault(),f())}),l.addEventListener("click",a=>{f()}),c.addEventListener("click",a=>{n.value="",f()})}},sy=ay;var ly=class{constructor(t){this.elem=t,this.input=t.querySelector("input[type=hidden]"),this.checkbox=t.querySelector("input[type=checkbox]"),this.checkbox.addEventListener("change",this.stateChange.bind(this))}stateChange(){this.input.value=this.checkbox.checked?"true":"false";let t=new Event("change");this.input.dispatchEvent(t)}},uy=ly;var cy=class{setup(){this.container=this.$refs.container,this.tabs=this.$manyRefs.tab,this.lastLayoutType="none",this.onDestroy=null,this.scrollCache={content:0,info:0},this.lastTabShown="content",this.mobileTabClick=this.mobileTabClick.bind(this),this.updateLayout(),window.addEventListener("resize",t=>{this.updateLayout()},{passive:!0})}updateLayout(){let t="tablet";window.innerWidth<=1e3&&(t="mobile"),window.innerWidth>=1400&&(t="desktop"),t!==this.lastLayoutType&&(this.onDestroy&&(this.onDestroy(),this.onDestroy=null),t==="desktop"?this.setupDesktop():t==="mobile"&&this.setupMobile(),this.lastLayoutType=t)}setupMobile(){for(let t of this.tabs)t.addEventListener("click",this.mobileTabClick);this.onDestroy=()=>{for(let t of this.tabs)t.removeEventListener("click",this.mobileTabClick)}}setupDesktop(){}mobileTabClick(t){let n=t.target.dataset.tab;this.showTab(n)}showContent(){this.showTab("content",!1)}showTab(t,n=!0){this.scrollCache[this.lastTabShown]=document.documentElement.scrollTop;for(let c of this.tabs){let f=c.dataset.tab===t;c.setAttribute("aria-selected",f?"true":"false")}let l=t==="info";if(this.container.classList.toggle("show-info",l),n){let f=document.querySelector("header").getBoundingClientRect().bottom;document.documentElement.scrollTop=this.scrollCache[t]||f,setTimeout(()=>{document.documentElement.scrollTop=this.scrollCache[t]||f},50)}this.lastTabShown=t}},fy=cy;var dy=class{setup(){this.input=this.$refs.input,this.userInfoContainer=this.$refs.userInfo,this.hide=this.$el.components.dropdown.hide,Ut(this.$el,"a.dropdown-search-item","click",this.selectUser.bind(this))}selectUser(t,n){t.preventDefault();let l=n.getAttribute("data-id");this.input.value=l,this.userInfoContainer.innerHTML=n.innerHTML,this.input.dispatchEvent(new Event("change",{bubbles:!0})),this.hide()}},hy=dy;function py(i,t,n){let l=new bo(i.clipboardData||i.dataTransfer);if(!l.hasItems()||l.containsTabularData())return;let c=l.getImages();for(let f of c){let a="image-"+Math.random().toString(16).slice(2),h=window.baseUrl("/loading.gif");i.preventDefault(),setTimeout(()=>{t.insertContent(`

`),Kk(f,n).then(d=>{let p=d.name.replace(/"/g,""),y=`${p}`,g=t.dom.create("a",{target:"_blank",href:d.url},y);t.dom.replace(g,a)}).catch(d=>{t.dom.remove(a),window.$events.emit("error",n.imageUploadErrorText),console.log(d)})},10)}}async function Kk(i,t){if(i===null||i.type.indexOf("image")!==0)throw new Error("Not an image file");let n="png";if(i.name){let a=i.name.match(/\.(.+)$/);a.length>1&&(n=a[1])}let l="image-"+Date.now()+"."+n,c=new FormData;return c.append("file",i,l),c.append("uploaded_to",t.pageId),(await window.$http.post(window.baseUrl("/images/gallery"),c)).data}function Vk(i){for(let t=1;t<5;t++)i.shortcuts.add("meta+"+t,"",["FormatBlock",!1,"h"+(t+1)]);i.shortcuts.add("meta+5","",["FormatBlock",!1,"p"]),i.shortcuts.add("meta+d","",["FormatBlock",!1,"p"]),i.shortcuts.add("meta+6","",["FormatBlock",!1,"blockquote"]),i.shortcuts.add("meta+q","",["FormatBlock",!1,"blockquote"]),i.shortcuts.add("meta+7","",["codeeditor",!1,"pre"]),i.shortcuts.add("meta+e","",["codeeditor",!1,"pre"]),i.shortcuts.add("meta+8","",["FormatBlock",!1,"code"]),i.shortcuts.add("meta+shift+E","",["FormatBlock",!1,"code"]),i.shortcuts.add("meta+S","",()=>{window.$events.emit("editor-save-draft")}),i.shortcuts.add("meta+13","",()=>{window.$events.emit("editor-save-page")}),i.shortcuts.add("meta+9","",function(){let t=i.selection.getNode(),n=t?t.closest(".callout"):null,l=["info","success","warning","danger"],f=(l.findIndex(h=>n&&n.classList.contains(h))+1)%l.length,a=l[f];i.formatter.apply("callout"+a)})}function Yk(i){window.$http.get(window.baseUrl("/custom-head-content")).then(t=>{if(!t.data)return;let n=i.getDoc().querySelector("head");n.innerHTML+=t.data})}function Xk(){function i(l){return l.className==="CodeMirrorContainer"}function t(l){let c=l.selection.getNode();if(!i(c)){let h=l.selection.getNode().textContent;window.components.first("code-editor").open(h,"",(d,p)=>{let y=document.createElement("div");y.innerHTML=`
`,y.querySelector("code").innerText=d,l.formatter.toggle("pre");let g=l.selection.getNode();l.dom.setHTML(g,y.querySelector("pre").innerHTML),l.fire("SetContent"),l.focus()});return}let f=c.hasAttribute("data-lang")?c.getAttribute("data-lang"):"",a=c.querySelector("textarea").textContent;window.components.first("code-editor").open(a,f,(h,d)=>{let y=c.querySelector(".CodeMirror").CodeMirror;y&&(cr.setContent(y,h),cr.setMode(y,d,h));let g=c.querySelector("textarea");g&&(g.textContent=h),c.setAttribute("data-lang",d),l.focus()})}function n(l){let f=l.querySelector("textarea").textContent,a=l.getAttribute("data-lang");l.removeAttribute("contentEditable");let h=document.createElement("pre"),d=document.createElement("code");d.classList.add(`language-${a}`),d.textContent=f,h.appendChild(d),l.parentElement.replaceChild(h,l)}window.tinymce.PluginManager.add("codeeditor",function(l,c){let f=l.$;l.addButton("codeeditor",{text:"Code block",icon:!1,cmd:"codeeditor"}),l.addCommand("codeeditor",()=>{t(l)}),l.on("PreProcess",function(h){f("div.CodeMirrorContainer",h.node).each((d,p)=>{n(p)})}),l.on("dblclick",h=>{let d=l.selection.getNode();!i(d)||t(l)});function a(){f(".CodeMirrorContainer").filter((d,p)=>typeof p.querySelector(".CodeMirror").CodeMirror=="undefined").each((d,p)=>{n(p)}),f("body > pre").filter((d,p)=>p.contentEditable!=="false").each((d,p)=>{cr.wysiwygView(p)})}l.on("init",function(){l.undoManager.transact(function(){a()}),setTimeout(()=>{l.on("SetContent",()=>{setTimeout(a,100)})},200)})})}function Zk(i,t,n,l){let c=null,f=null;function a(g){return g.hasAttribute("drawio-diagram")}function h(g,v=null){c=g,f=v,window.ImageManager.show(function(b){if(v){let k=v.querySelector("img");c.dom.setAttrib(k,"src",b.url),c.dom.setAttrib(v,"drawio-diagram",b.id)}else{let k=`
`;c.insertContent(k)}},"drawio")}function d(g,v=null){c=g,f=v,Nr.show(i,y,p)}async function p(g){let v="image-"+Math.random().toString(16).slice(2),b=window.baseUrl("/loading.gif"),k=S=>{S.status===413?window.$events.emit("error",l.serverUploadLimitText):window.$events.emit("error",l.imageUploadErrorText),console.log(S)};if(f){Nr.close();let S=f.querySelector("img");try{let w=await Nr.upload(g,n);c.dom.setAttrib(S,"src",w.url),c.dom.setAttrib(f,"drawio-diagram",w.id)}catch(w){k(w)}return}setTimeout(async()=>{c.insertContent(`
`),Nr.close();try{let S=await Nr.upload(g,n);c.dom.setAttrib(v,"src",S.url),c.dom.get(v).parentNode.setAttribute("drawio-diagram",S.id)}catch(S){c.dom.remove(v),k(S)}},5)}function y(){if(!f)return Promise.resolve("");let g=f.getAttribute("drawio-diagram");return Nr.load(g)}window.tinymce.PluginManager.add("drawio",function(g,v){g.addCommand("drawio",()=>{let b=g.selection.getNode();d(g,a(b)?b:null)}),g.addButton("drawio",{type:"splitbutton",tooltip:"Drawing",image:`data:image/svg+xml;base64,${btoa(` +`).length;n.style.height=l*20+40+"px",this.editingComment=t}updateComment(t){let n=t.target;t.preventDefault();let c={text:n.querySelector("textarea").value,parent_id:this.parentId||null};this.showLoading(n);let f=this.editingComment.getAttribute("comment");window.$http.put(`/comment/${f}`,c).then(a=>{let h=document.createElement("div");h.innerHTML=a.data,this.editingComment.innerHTML=h.children[0].innerHTML,window.$events.success(this.updatedText),window.components.init(this.editingComment),this.closeUpdateForm(),this.editingComment=null}).catch(window.$events.showValidationErrors).then(()=>{this.hideLoading(n)})}deleteComment(t){let n=t.getAttribute("comment");this.showLoading(t.querySelector("[comment-content]")),window.$http.delete(`/comment/${n}`).then(l=>{t.parentNode.removeChild(t),window.$events.success(this.deletedText),this.updateCount(),this.hideForm()})}saveComment(t){t.preventDefault(),t.stopPropagation();let l={text:this.formInput.value,parent_id:this.parentId||null};this.showLoading(this.form),window.$http.post(`/comment/${this.pageId}`,l).then(c=>{let f=document.createElement("div");f.innerHTML=c.data;let a=f.children[0];this.container.appendChild(a),window.components.init(a),window.$events.success(this.createdText),this.resetForm(),this.updateCount()}).catch(c=>{window.$events.showValidationErrors(c),this.hideLoading(this.form)})}updateCount(){let t=this.container.children.length;this.elem.querySelector("[comments-title]").textContent=window.trans_plural(this.countText,t,{count:t})}resetForm(){this.formInput.value="",this.formContainer.appendChild(this.form),this.hideForm(),this.removeReplyTo(),this.hideLoading(this.form)}showForm(){this.formContainer.style.display="block",this.formContainer.parentNode.style.display="block",this.addButtonContainer.style.display="none",this.formInput.focus(),this.formInput.scrollIntoView({behavior:"smooth"})}hideForm(){this.formContainer.style.display="none",this.formContainer.parentNode.style.display="none",this.getCommentCount()>0?this.elem.appendChild(this.addButtonContainer):this.commentCountBar.appendChild(this.addButtonContainer),this.addButtonContainer.style.display="block"}getCommentCount(){return this.elem.querySelectorAll(".comment-box[comment]").length}setReply(t){this.showForm(),this.parentId=Number(t.getAttribute("local-id")),this.replyToRow.style.display="block";let n=this.replyToRow.querySelector("a");n.textContent=`#${this.parentId}`,n.href=`#comment${this.parentId}`}removeReplyTo(){this.parentId=null,this.replyToRow.style.display="none"}showLoading(t){let n=t.querySelectorAll(".form-group");for(let l of n)l.style.display="none";t.querySelector(".form-group.loading").style.display="block"}hideLoading(t){let n=t.querySelectorAll(".form-group");for(let l of n)l.style.display="block";t.querySelector(".form-group.loading").style.display="none"}},Iv=Dv;var Fv=_t(Qs());var Mv=class{constructor(t){if(this.elem=t,this.pageId=t.getAttribute("page-display"),cr.highlight(),this.setupPointer(),this.setupNavHighlighting(),this.setupDetailsCodeBlockRefresh(),window.location.hash){let l=window.location.hash.replace(/\%20/g," ").substr(1);this.goToText(l)}let n=document.querySelector(".sidebar-page-nav");n&&Ut(n,"a","click",(l,c)=>{l.preventDefault(),window.components["tri-layout"][0].showContent();let f=c.getAttribute("href").substr(1);this.goToText(f),window.history.pushState(null,null,"#"+f)})}goToText(t){let n=document.getElementById(t);if(Qo(".page-content [data-highlighted]",l=>{l.removeAttribute("data-highlighted"),l.style.backgroundColor=null}),n!==null)to(n);else{let l=Uc(".page-content > div > *",t);l&&to(l)}}setupPointer(){let t=document.getElementById("pointer");if(!t)return;t=t.parentNode.removeChild(t);let n=t.querySelector("div.pointer"),l=!1,c=!1,f=!0,a="";Ut(t,"input","click",(d,p)=>{p.select(),d.stopPropagation()}),Jo(t,["click","focus"],d=>{d.stopPropagation()}),Ut(t,"span.icon","click",(d,p)=>{d.stopPropagation(),f=!f,p.querySelector('[data-icon="include"]').style.display=f?"none":"inline",p.querySelector('[data-icon="link"]').style.display=f?"inline":"none",h()}),new Fv.default(t.querySelector("button")),Jo(document.body,["click","focus"],d=>{!l||c||(t=t.parentElement.removeChild(t),l=!1)});let h=d=>{let p=f?window.baseUrl(`/link/${this.pageId}#${a}`):`{{@${this.pageId}#${a}}}`;f&&!p.startsWith("http")&&(p=window.location.protocol+"//"+window.location.host+p),t.querySelector("input").value=p;let y=t.querySelector("#pointer-edit");if(y&&d){let g=y.dataset.editHref,v=d.id,b=d.textContent&&d.textContent.substring(0,50);y.href=`${g}?content-id=${v}&content-text=${encodeURIComponent(b)}`}};Qo('.page-content [id^="bkmrk"]',d=>{Jo(d,["mouseup","keyup"],p=>{p.stopPropagation(),window.getSelection().toString().length!==0&&(a=d.id,h(d),d.parentNode.insertBefore(t,d),t.style.display="block",l=!0,c=!0,requestAnimationFrame(()=>{let g=d.getBoundingClientRect(),v=p.pageX-g.left-164;v<0&&(v=0);let b=v/g.width*100;n.style.left=b+"%",setTimeout(()=>{c=!1},100)}))})})}setupNavHighlighting(){if(!("IntersectionObserver"in window)||!("IntersectionObserverEntry"in window)||!("intersectionRatio"in window.IntersectionObserverEntry.prototype))return;let t=document.querySelector(".sidebar-page-nav"),n=document.querySelector(".page-content").querySelectorAll("h1, h2, h3, h4, h5, h6");n.length>0&&t!==null&&l(n);function l(a){let h={rootMargin:"0px 0px 0px 0px",threshold:1},d=new IntersectionObserver(c,h);for(let p of a)d.observe(p)}function c(a,h){for(let d of a){let p=d.intersectionRatio===1;f(d.target.id,p)}}function f(a,h){Qo('a[href="#'+a+'"]',d=>{d.closest("li").classList.toggle("current-heading",h)})}}setupDetailsCodeBlockRefresh(){let t=l=>{[...l.target.querySelectorAll(".CodeMirror")].forEach(f=>f.CodeMirror&&f.CodeMirror.refresh())};[...this.elem.querySelectorAll("details")].forEach(l=>l.addEventListener("toggle",t))}},Ov=Mv;function Pv(i){let t=new Date(i*1e3),n=t.getHours(),l=t.getMinutes();return`${(n>9?"":"0")+n}:${(l>9?"":"0")+l}`}var Rv=class{setup(){this.draftsEnabled=this.$opts.draftsEnabled==="true",this.editorType=this.$opts.editorType,this.pageId=Number(this.$opts.pageId),this.isNewDraft=this.$opts.pageNewDraft==="true",this.hasDefaultTitle=this.$opts.hasDefaultTitle||!1,this.container=this.$el,this.titleElem=this.$refs.titleContainer.querySelector("input"),this.saveDraftButton=this.$refs.saveDraft,this.discardDraftButton=this.$refs.discardDraft,this.discardDraftWrap=this.$refs.discardDraftWrap,this.draftDisplay=this.$refs.draftDisplay,this.draftDisplayIcon=this.$refs.draftDisplayIcon,this.changelogInput=this.$refs.changelogInput,this.changelogDisplay=this.$refs.changelogDisplay,this.draftText=this.$opts.draftText,this.autosaveFailText=this.$opts.autosaveFailText,this.editingPageText=this.$opts.editingPageText,this.draftDiscardedText=this.$opts.draftDiscardedText,this.setChangelogText=this.$opts.setChangelogText,this.editorHTML="",this.editorMarkdown="",this.autoSave={interval:null,frequency:3e4,last:0},this.shownWarningsCache=new Set,this.pageId!==0&&this.draftsEnabled&&window.setTimeout(()=>{this.startAutoSave()},1e3),this.draftDisplay.innerHTML=this.draftText,this.setupListeners(),this.setInitialFocus()}setupListeners(){window.$events.listen("editor-save-draft",this.saveDraft.bind(this)),window.$events.listen("editor-save-page",this.savePage.bind(this)),window.$events.listen("editor-html-change",t=>{this.editorHTML=t}),window.$events.listen("editor-markdown-change",t=>{this.editorMarkdown=t}),this.changelogInput.addEventListener("change",this.updateChangelogDisplay.bind(this)),Rt(this.saveDraftButton,this.saveDraft.bind(this)),Rt(this.discardDraftButton,this.discardDraft.bind(this))}setInitialFocus(){if(this.hasDefaultTitle)return this.titleElem.select();window.setTimeout(()=>{window.$events.emit("editor::focus","")},500)}startAutoSave(){let t=this.titleElem.value.trim()+"::"+this.editorHTML;this.autoSaveInterval=window.setInterval(()=>{if(Date.now()-this.autoSave.last{this.draftDisplayIcon.classList.remove("visible")},2e3)}async discardDraft(){let t;try{t=await window.$http.get(`/ajax/page/${this.pageId}`)}catch(n){return console.error(n)}this.autoSave.interval&&window.clearInterval(this.autoSave.interval),this.draftDisplay.innerText=this.editingPageText,this.toggleDiscardDraftVisibility(!1),window.$events.emit("editor-html-update",t.data.html||""),window.$events.emit("editor-markdown-update",t.data.markdown||t.data.html),this.titleElem.value=t.data.name,window.setTimeout(()=>{this.startAutoSave()},1e3),window.$events.emit("success",this.draftDiscardedText)}updateChangelogDisplay(){let t=this.changelogInput.value.trim();t.length===0?t=this.setChangelogText:t.length>16&&(t=t.slice(0,16)+"..."),this.changelogDisplay.innerText=t}toggleDiscardDraftVisibility(t){this.discardDraftWrap.classList.toggle("hidden",!t)}},zv=Rv;var Nv=class{constructor(t){this.elem=t,this.input=t.querySelector("input"),this.resetButton=t.querySelector("[page-picker-reset]"),this.selectButton=t.querySelector("[page-picker-select]"),this.display=t.querySelector("[page-picker-display]"),this.defaultDisplay=t.querySelector("[page-picker-default]"),this.buttonSep=t.querySelector("span.sep"),this.value=this.input.value,this.setupListeners()}setupListeners(){this.selectButton.addEventListener("click",this.showPopup.bind(this)),this.display.parentElement.addEventListener("click",this.showPopup.bind(this)),this.resetButton.addEventListener("click",t=>{this.setValue("","")})}showPopup(){window.EntitySelectorPopup.show(t=>{this.setValue(t.id,t.name)})}setValue(t,n){this.value=t,this.input.value=t,this.controlView(n)}controlView(t){let n=this.value&&this.value!==0;if(Ba(this.resetButton,n),Ba(this.buttonSep,n),Ba(this.defaultDisplay,!n),Ba(this.display,n),n){let l=this.getAssetIdFromVal();this.display.textContent=`#${l}, ${t}`,this.display.href=window.baseUrl(`/link/${l}`)}}getAssetIdFromVal(){return Number(this.value)}};function Ba(i,t){let n=i.tagName==="BUTTON"||i.tagName==="SPAN"?"inline-block":"block";i.style.display=t?n:"none"}var Bv=Nv;var qv=class{constructor(t){this.container=t,t.querySelector("[permissions-table-toggle-all]").addEventListener("click",this.toggleAllClick.bind(this));let l=t.querySelectorAll("[permissions-table-toggle-all-in-row]");for(let f of l)f.addEventListener("click",this.toggleRowClick.bind(this));let c=t.querySelectorAll("[permissions-table-toggle-all-in-column]");for(let f of c)f.addEventListener("click",this.toggleColumnClick.bind(this))}toggleAllClick(t){t.preventDefault(),this.toggleAllInElement(this.container)}toggleRowClick(t){t.preventDefault(),this.toggleAllInElement(t.target.closest("tr"))}toggleColumnClick(t){t.preventDefault();let n=t.target.closest("th,td"),l=Array.from(n.parentElement.children).indexOf(n),c=n.closest("table").querySelectorAll("tr"),f=[];for(let a of c){let h=a.children[l];h&&f.push(...h.querySelectorAll("input[type=checkbox]"))}this.toggleAllInputs(f)}toggleAllInElement(t){let n=t.querySelectorAll("input[type=checkbox]");this.toggleAllInputs(n)}toggleAllInputs(t){let n=t.length>0?t[0].checked:!1;for(let l of t)l.checked=!n,l.dispatchEvent(new Event("change"))}},jv=qv;var $v=class{setup(){this.container=this.$el,this.hideButtons=this.$manyRefs.hide||[],this.onkeyup=null,this.onHide=null,this.setupListeners()}setupListeners(){let t=null;this.container.addEventListener("mousedown",n=>{t=n.target}),this.container.addEventListener("click",n=>{if(n.target===this.container&&t===this.container)return this.hide()}),Rt(this.hideButtons,n=>this.hide())}hide(t=null){ya(this.container,240,t),this.onkeyup&&(window.removeEventListener("keyup",this.onkeyup),this.onkeyup=null),this.onHide&&this.onHide()}show(t=null,n=null){Ff(this.container,240,t),this.onkeyup=l=>{l.key==="Escape"&&this.hide()},window.addEventListener("keyup",this.onkeyup),this.onHide=n}},Uv=$v;var Hv=class{constructor(t){this.elem=t,this.colorInput=t.querySelector("input[type=color]"),this.lightColorInput=t.querySelector('input[name="setting-app-color-light"]'),this.resetButton=t.querySelector("[setting-app-color-picker-reset]"),this.defaultButton=t.querySelector("[setting-app-color-picker-default]"),this.colorInput.addEventListener("change",this.updateColor.bind(this)),this.colorInput.addEventListener("input",this.updateColor.bind(this)),this.resetButton.addEventListener("click",n=>{this.colorInput.value=this.colorInput.dataset.current,this.updateColor()}),this.defaultButton.addEventListener("click",n=>{this.colorInput.value=this.colorInput.dataset.default,this.updateColor()})}updateColor(){let t=this.colorInput.value,n=this.hexToRgb(t),l="rgba("+[n.r,n.g,n.b,"0.15"].join(",")+")";this.lightColorInput.value=l;let c=document.getElementById("custom-styles"),f=c.getAttribute("data-color"),a=c.getAttribute("data-color-light");c.innerHTML=c.innerHTML.split(f).join(t),c.innerHTML=c.innerHTML.split(a).join(l),c.setAttribute("data-color",t),c.setAttribute("data-color-light",l)}hexToRgb(t){let n=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return{r:n?parseInt(n[1],16):0,g:n?parseInt(n[2],16):0,b:n?parseInt(n[3],16):0}}},Wv=Hv;var Gv=class{constructor(t){this.elem=t,this.colorInput=t.querySelector("input[type=color]"),this.resetButton=t.querySelector("[setting-color-picker-reset]"),this.defaultButton=t.querySelector("[setting-color-picker-default]"),this.resetButton.addEventListener("click",n=>{this.colorInput.value=this.colorInput.dataset.current}),this.defaultButton.addEventListener("click",n=>{this.colorInput.value=this.colorInput.dataset.default})}},Kv=Gv;var Vv=class{constructor(t){this.elem=t,this.input=document.getElementById("books-input"),this.shelfBooksList=t.querySelector("[shelf-sort-assigned-books]"),this.initSortable(),this.setupListeners()}initSortable(){let t=this.elem.querySelectorAll(".scroll-box");for(let n of t)new vi(n,{group:"shelf-books",ghostClass:"primary-background-light",animation:150,onSort:this.onChange.bind(this)})}setupListeners(){this.elem.addEventListener("click",t=>{let n=t.target.closest(".scroll-box-item:not(.instruction)");n&&(t.preventDefault(),this.sortItemClick(n))})}sortItemClick(t){let n=this.elem.querySelectorAll(".scroll-box"),l=Array.from(n).filter(c=>t.parentElement!==c);l.length>0&&l[0].appendChild(t),this.onChange()}onChange(){let t=Array.from(this.shelfBooksList.querySelectorAll("[data-id]"));this.input.value=t.map(n=>n.getAttribute("data-id")).join(",")}},Yv=Vv;var Xv=class{constructor(t){this.elem=t,this.toggleElem=t.querySelector(".sidebar-toggle"),this.toggleElem.addEventListener("click",this.toggle.bind(this))}toggle(t=!0){this.elem.classList.toggle("open")}},Zv=Xv;var Qv=class{setup(){this.container=this.$el,this.handleSelector=this.$opts.handleSelector;let t=new vi(this.container,{handle:this.handleSelector,animation:150,onSort:()=>{this.$emit("sort",{ids:t.toArray()})},setData(n,l){let c=l.getAttribute("data-drag-content");if(c){let f=JSON.parse(c);for(let[a,h]of Object.entries(f))n.setData(a,h)}},revertOnSpill:!0,dropBubble:!0,dragoverBubble:!1})}},Jv=Qv;var ey=class{setup(){this.filter=this.$opts.filter,this.$el.addEventListener("change",t=>{if(this.filter&&!t.target.matches(this.filter))return;let n=this.$el.closest("form");n&&n.submit()})}},ty=ey;var ry=class{setup(){this.tabContentsByName={},this.tabButtonsByName={},this.allContents=[],this.allButtons=[];for(let[t,n]of Object.entries(this.$manyRefs||{})){if(t.startsWith("toggle")){let l=t.replace("toggle","").toLowerCase();Rt(n,c=>this.show(l)),this.allButtons.push(...n),this.tabButtonsByName[l]=n}if(t.startsWith("content")){let l=t.replace("content","").toLowerCase();this.tabContentsByName[l]=n,this.allContents.push(...n)}}}show(t){this.allContents.forEach(c=>{c.classList.add("hidden"),c.classList.remove("selected")}),this.allButtons.forEach(c=>c.classList.remove("selected"));let n=this.tabContentsByName[t]||[],l=this.tabButtonsByName[t]||[];n.length>0&&(n.forEach(c=>{c.classList.remove("hidden"),c.classList.add("selected")}),l.forEach(c=>c.classList.add("selected")))}},ny=ry;var iy=class{setup(){this.addRemoveComponentEl=this.$refs.addRemove,this.container=this.$el,this.rowSelector=this.$opts.rowSelector,this.setupListeners()}setupListeners(){this.container.addEventListener("change",t=>{let n=this.addRemoveComponentEl.components["add-remove-rows"];this.hasEmptyRows()||n.add()})}hasEmptyRows(){return[...this.container.querySelectorAll(this.rowSelector)].find(l=>[...l.querySelectorAll("input")].filter(c=>c.value).length===0)!==void 0}},oy=iy;var ay=class{constructor(t){this.elem=t,this.list=t.querySelector("[template-manager-list]"),this.searching=!1,Ut(this.elem,"[template-action]","click",this.handleTemplateActionClick.bind(this)),Ut(this.elem,".pagination a","click",this.handlePaginationClick.bind(this)),Ut(this.elem,".template-item-content","click",this.handleTemplateItemClick.bind(this)),Ut(this.elem,".template-item","dragstart",this.handleTemplateItemDragStart.bind(this)),this.setupSearchBox()}handleTemplateItemClick(t,n){let l=n.closest("[template-id]").getAttribute("template-id");this.insertTemplate(l,"replace")}handleTemplateItemDragStart(t,n){let l=n.closest("[template-id]").getAttribute("template-id");t.dataTransfer.setData("bookstack/template",l),t.dataTransfer.setData("text/plain",l)}handleTemplateActionClick(t,n){t.stopPropagation();let l=n.getAttribute("template-action"),c=n.closest("[template-id]").getAttribute("template-id");this.insertTemplate(c,l)}async insertTemplate(t,n="replace"){let l=await window.$http.get(`/templates/${t}`),c="editor::"+n;window.$events.emit(c,l.data)}async handlePaginationClick(t,n){t.preventDefault();let l=n.getAttribute("href"),c=await window.$http.get(l);this.list.innerHTML=c.data}setupSearchBox(){let t=this.elem.querySelector(".search-box");if(!t)return;let n=t.querySelector("input"),l=t.querySelector("button"),c=t.querySelector("button.search-box-cancel");async function f(){let a=n.value,h=await window.$http.get("/templates",{search:a});c.style.display=a?"block":"none",this.list.innerHTML=h.data}f=f.bind(this),t.addEventListener("keypress",a=>{a.key==="Enter"&&(a.preventDefault(),f())}),l.addEventListener("click",a=>{f()}),c.addEventListener("click",a=>{n.value="",f()})}},sy=ay;var ly=class{constructor(t){this.elem=t,this.input=t.querySelector("input[type=hidden]"),this.checkbox=t.querySelector("input[type=checkbox]"),this.checkbox.addEventListener("change",this.stateChange.bind(this))}stateChange(){this.input.value=this.checkbox.checked?"true":"false";let t=new Event("change");this.input.dispatchEvent(t)}},uy=ly;var cy=class{setup(){this.container=this.$refs.container,this.tabs=this.$manyRefs.tab,this.lastLayoutType="none",this.onDestroy=null,this.scrollCache={content:0,info:0},this.lastTabShown="content",this.mobileTabClick=this.mobileTabClick.bind(this),this.updateLayout(),window.addEventListener("resize",t=>{this.updateLayout()},{passive:!0})}updateLayout(){let t="tablet";window.innerWidth<=1e3&&(t="mobile"),window.innerWidth>=1400&&(t="desktop"),t!==this.lastLayoutType&&(this.onDestroy&&(this.onDestroy(),this.onDestroy=null),t==="desktop"?this.setupDesktop():t==="mobile"&&this.setupMobile(),this.lastLayoutType=t)}setupMobile(){for(let t of this.tabs)t.addEventListener("click",this.mobileTabClick);this.onDestroy=()=>{for(let t of this.tabs)t.removeEventListener("click",this.mobileTabClick)}}setupDesktop(){}mobileTabClick(t){let n=t.target.dataset.tab;this.showTab(n)}showContent(){this.showTab("content",!1)}showTab(t,n=!0){this.scrollCache[this.lastTabShown]=document.documentElement.scrollTop;for(let c of this.tabs){let f=c.dataset.tab===t;c.setAttribute("aria-selected",f?"true":"false")}let l=t==="info";if(this.container.classList.toggle("show-info",l),n){let f=document.querySelector("header").getBoundingClientRect().bottom;document.documentElement.scrollTop=this.scrollCache[t]||f,setTimeout(()=>{document.documentElement.scrollTop=this.scrollCache[t]||f},50)}this.lastTabShown=t}},fy=cy;var dy=class{setup(){this.input=this.$refs.input,this.userInfoContainer=this.$refs.userInfo,this.hide=this.$el.components.dropdown.hide,Ut(this.$el,"a.dropdown-search-item","click",this.selectUser.bind(this))}selectUser(t,n){t.preventDefault();let l=n.getAttribute("data-id");this.input.value=l,this.userInfoContainer.innerHTML=n.innerHTML,this.input.dispatchEvent(new Event("change",{bubbles:!0})),this.hide()}},hy=dy;function py(i,t,n){let l=new bo(i.clipboardData||i.dataTransfer);if(!l.hasItems()||l.containsTabularData())return;let c=l.getImages();for(let f of c){let a="image-"+Math.random().toString(16).slice(2),h=window.baseUrl("/loading.gif");i.preventDefault(),setTimeout(()=>{t.insertContent(`

`),Kk(f,n).then(d=>{let p=d.name.replace(/"/g,""),y=`${p}`,g=t.dom.create("a",{target:"_blank",href:d.url},y);t.dom.replace(g,a)}).catch(d=>{t.dom.remove(a),window.$events.emit("error",n.imageUploadErrorText),console.log(d)})},10)}}async function Kk(i,t){if(i===null||i.type.indexOf("image")!==0)throw new Error("Not an image file");let n="png";if(i.name){let a=i.name.match(/\.(.+)$/);a.length>1&&(n=a[1])}let l="image-"+Date.now()+"."+n,c=new FormData;return c.append("file",i,l),c.append("uploaded_to",t.pageId),(await window.$http.post(window.baseUrl("/images/gallery"),c)).data}function Vk(i){for(let t=1;t<5;t++)i.shortcuts.add("meta+"+t,"",["FormatBlock",!1,"h"+(t+1)]);i.shortcuts.add("meta+5","",["FormatBlock",!1,"p"]),i.shortcuts.add("meta+d","",["FormatBlock",!1,"p"]),i.shortcuts.add("meta+6","",["FormatBlock",!1,"blockquote"]),i.shortcuts.add("meta+q","",["FormatBlock",!1,"blockquote"]),i.shortcuts.add("meta+7","",["codeeditor",!1,"pre"]),i.shortcuts.add("meta+e","",["codeeditor",!1,"pre"]),i.shortcuts.add("meta+8","",["FormatBlock",!1,"code"]),i.shortcuts.add("meta+shift+E","",["FormatBlock",!1,"code"]),i.shortcuts.add("meta+S","",()=>{window.$events.emit("editor-save-draft")}),i.shortcuts.add("meta+13","",()=>{window.$events.emit("editor-save-page")}),i.shortcuts.add("meta+9","",function(){let t=i.selection.getNode(),n=t?t.closest(".callout"):null,l=["info","success","warning","danger"],f=(l.findIndex(h=>n&&n.classList.contains(h))+1)%l.length,a=l[f];i.formatter.apply("callout"+a)})}function Yk(i){window.$http.get(window.baseUrl("/custom-head-content")).then(t=>{if(!t.data)return;let n=i.getDoc().querySelector("head");n.innerHTML+=t.data})}function Xk(){function i(l){return l.className==="CodeMirrorContainer"}function t(l){let c=l.selection.getNode();if(!i(c)){let h=l.selection.getNode().textContent;window.components.first("code-editor").open(h,"",(d,p)=>{let y=document.createElement("div");y.innerHTML=`
`,y.querySelector("code").innerText=d,l.formatter.toggle("pre");let g=l.selection.getNode();l.dom.setHTML(g,y.querySelector("pre").innerHTML),l.fire("SetContent"),l.focus()});return}let f=c.hasAttribute("data-lang")?c.getAttribute("data-lang"):"",a=c.querySelector("textarea").textContent;window.components.first("code-editor").open(a,f,(h,d)=>{let y=c.querySelector(".CodeMirror").CodeMirror;y&&(cr.setContent(y,h),cr.setMode(y,d,h));let g=c.querySelector("textarea");g&&(g.textContent=h),c.setAttribute("data-lang",d),l.focus()})}function n(l){let f=l.querySelector("textarea").textContent,a=l.getAttribute("data-lang");l.removeAttribute("contentEditable");let h=document.createElement("pre"),d=document.createElement("code");d.classList.add(`language-${a}`),d.textContent=f,h.appendChild(d),l.parentElement.replaceChild(h,l)}window.tinymce.PluginManager.add("codeeditor",function(l,c){let f=l.$;l.addButton("codeeditor",{text:"Code block",icon:!1,cmd:"codeeditor"}),l.addCommand("codeeditor",()=>{t(l)}),l.on("PreProcess",function(h){f("div.CodeMirrorContainer",h.node).each((d,p)=>{n(p)})}),l.on("dblclick",h=>{let d=l.selection.getNode();!i(d)||t(l)});function a(){f(".CodeMirrorContainer").filter((d,p)=>typeof p.querySelector(".CodeMirror").CodeMirror=="undefined").each((d,p)=>{n(p)}),f("body > pre").filter((d,p)=>p.contentEditable!=="false").each((d,p)=>{cr.wysiwygView(p)})}l.on("init",function(){l.undoManager.transact(function(){a()}),setTimeout(()=>{l.on("SetContent",()=>{setTimeout(a,100)})},200)})})}function Zk(i,t,n,l){let c=null,f=null;function a(g){return g.hasAttribute("drawio-diagram")}function h(g,v=null){c=g,f=v,window.ImageManager.show(function(b){if(v){let k=v.querySelector("img");c.dom.setAttrib(k,"src",b.url),c.dom.setAttrib(v,"drawio-diagram",b.id)}else{let k=`
`;c.insertContent(k)}},"drawio")}function d(g,v=null){c=g,f=v,Nr.show(i,y,p)}async function p(g){let v="image-"+Math.random().toString(16).slice(2),b=window.baseUrl("/loading.gif"),k=S=>{S.status===413?window.$events.emit("error",l.serverUploadLimitText):window.$events.emit("error",l.imageUploadErrorText),console.log(S)};if(f){Nr.close();let S=f.querySelector("img");try{let w=await Nr.upload(g,n);c.dom.setAttrib(S,"src",w.url),c.dom.setAttrib(f,"drawio-diagram",w.id)}catch(w){k(w)}return}setTimeout(async()=>{c.insertContent(`
`),Nr.close();try{let S=await Nr.upload(g,n);c.dom.setAttrib(v,"src",S.url),c.dom.get(v).parentNode.setAttribute("drawio-diagram",S.id)}catch(S){c.dom.remove(v),k(S)}},5)}function y(){if(!f)return Promise.resolve("");let g=f.getAttribute("drawio-diagram");return Nr.load(g)}window.tinymce.PluginManager.add("drawio",function(g,v){g.addCommand("drawio",()=>{let b=g.selection.getNode();d(g,a(b)?b:null)}),g.addButton("drawio",{type:"splitbutton",tooltip:"Drawing",image:`data:image/svg+xml;base64,${btoa(` `)}`,cmd:"drawio",menu:[{text:"Drawing Manager",onclick(){let b=g.selection.getNode();h(g,a(b)?b:null)}}]}),g.on("dblclick",b=>{let k=g.selection.getNode();!a(k)||d(g,k)}),g.on("SetContent",function(){let b=g.$("body > div[drawio-diagram]");!b.length||g.undoManager.transact(function(){b.each((k,S)=>{S.setAttribute("contenteditable","false")})})})})}function Qk(){window.tinymce.PluginManager.add("customhr",function(i){i.addCommand("InsertHorizontalRule",function(){let t=document.createElement("hr"),n=i.selection.getNode();n.parentNode.insertBefore(t,n)}),i.addButton("hr",{icon:"hr",tooltip:"Horizontal line",cmd:"InsertHorizontalRule"}),i.addMenuItem("hr",{icon:"hr",text:"Horizontal line",cmd:"InsertHorizontalRule",context:"insert"})})}function Jk(i){window.$events.listen("editor::replace",({html:t})=>{i.setContent(t)}),window.$events.listen("editor::append",({html:t})=>{let n=i.getContent()+t;i.setContent(n)}),window.$events.listen("editor::prepend",({html:t})=>{let n=t+i.getContent();i.setContent(n)}),window.$events.listen("editor::insert",({html:t})=>{i.insertContent(t)}),window.$events.listen("editor::focus",()=>{i.focus()})}var my=class{setup(){this.elem=this.$el,this.pageId=this.$opts.pageId,this.textDirection=this.$opts.textDirection,this.imageUploadErrorText=this.$opts.imageUploadErrorText,this.serverUploadLimitText=this.$opts.serverUploadLimitText,this.isDarkMode=document.documentElement.classList.contains("dark-mode"),this.plugins="image imagetools table textcolor paste link autolink fullscreen code customhr autosave lists codeeditor media",this.loadPlugins(),this.tinyMceConfig=this.getTinyMceConfig(),window.$events.emitPublic(this.elem,"editor-tinymce::pre-init",{config:this.tinyMceConfig}),window.tinymce.init(this.tinyMceConfig)}loadPlugins(){Xk(),Qk();let t=document.querySelector("[drawio-url]");if(t){let n=t.getAttribute("drawio-url");Zk(n,this.isDarkMode,this.pageId,this),this.plugins+=" drawio"}this.textDirection==="rtl"&&(this.plugins+=" directionality")}getToolBar(){return`undo redo | styleselect | bold italic underline strikethrough superscript subscript | forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | table image-insert link hr drawio media | removeformat code ${this.textDirection==="rtl"?"ltr rtl":""} fullscreen`}getTinyMceConfig(){let t=this;return{selector:"#html-editor",content_css:[window.baseUrl("/dist/styles.css")],branding:!1,skin:this.isDarkMode?"dark":"lightgray",body_class:"page-content",browser_spellcheck:!0,relative_urls:!1,directionality:this.textDirection,remove_script_host:!1,document_base_url:window.baseUrl("/"),end_container_on_empty_block:!0,statusbar:!1,menubar:!1,paste_data_images:!1,extended_valid_elements:"pre[*],svg[*],div[drawio-diagram]",automatic_uploads:!1,valid_children:"-div[p|h1|h2|h3|h4|h5|h6|blockquote],+div[pre],+div[img]",plugins:this.plugins,imagetools_toolbar:"imageoptions",toolbar:this.getToolBar(),content_style:`html, body, html.dark-mode {background: ${this.isDarkMode?"#222":"#fff"};} body {padding-left: 15px !important; padding-right: 15px !important; margin:0!important; margin-left:auto!important;margin-right:auto!important;}`,style_formats:[{title:"Header Large",format:"h2"},{title:"Header Medium",format:"h3"},{title:"Header Small",format:"h4"},{title:"Header Tiny",format:"h5"},{title:"Paragraph",format:"p",exact:!0,classes:""},{title:"Blockquote",format:"blockquote"},{title:"Code Block",icon:"code",cmd:"codeeditor",format:"codeeditor"},{title:"Inline Code",icon:"code",inline:"code"},{title:"Callouts",items:[{title:"Info",format:"calloutinfo"},{title:"Success",format:"calloutsuccess"},{title:"Warning",format:"calloutwarning"},{title:"Danger",format:"calloutdanger"}]}],style_formats_merge:!1,media_alt_source:!1,media_poster:!1,formats:{codeeditor:{selector:"p,h1,h2,h3,h4,h5,h6,td,th,div"},alignleft:{selector:"p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img",classes:"align-left"},aligncenter:{selector:"p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img",classes:"align-center"},alignright:{selector:"p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img",classes:"align-right"},calloutsuccess:{block:"p",exact:!0,attributes:{class:"callout success"}},calloutinfo:{block:"p",exact:!0,attributes:{class:"callout info"}},calloutwarning:{block:"p",exact:!0,attributes:{class:"callout warning"}},calloutdanger:{block:"p",exact:!0,attributes:{class:"callout danger"}}},file_browser_callback:function(n,l,c,f){c==="file"&&window.EntitySelectorPopup.show(function(a){let h=f.document.getElementById(n);h.value=a.link;let p=h.closest(".mce-form").querySelectorAll("input");p[1].value||(p[1].value=a.name),p[2].value=a.name}),c==="image"&&window.ImageManager.show(function(a){if(f.document.getElementById(n).value=a.url,"createEvent"in document){let d=document.createEvent("HTMLEvents");d.initEvent("change",!1,!0),f.document.getElementById(n).dispatchEvent(d)}else f.document.getElementById(n).fireEvent("onchange");let h=``;h+=`${a.name}`,h+="",f.tinyMCE.activeEditor.execCommand("mceInsertContent",!1,h)},"gallery")},paste_preprocess:function(n,l){l.content.indexOf('{l();let p=new URL(window.location).searchParams.get("content-id");p&&c(p);let g=n.getContainer().querySelectorAll(".mce-btn");for(let v of g)v.addEventListener("touchstart",b=>{b.stopPropagation()});window.editor=n});function l(){let d=n.getContent();t.isDarkMode&&n.contentDocument.documentElement.classList.add("dark-mode"),window.$events.emit("editor-html-change",d)}function c(d){let p=n.dom.get(encodeURIComponent(d).replace(/!/g,"%21"));!p||(p.scrollIntoView(),n.selection.select(p,!0),n.selection.collapse(!1),n.focus())}Jk(n),window.$events.listen("editor-html-update",d=>{n.setContent(d),n.selection.select(n.getBody(),!0),n.selection.collapse(!1),l(d)}),Vk(n);let f,a;function h(d){return d&&!!(d.textContent||d.innerText)}n.on("dragstart",function(){let d=n.selection.getNode();d.nodeName==="IMG"&&(f=n.dom.getParent(d,".mceTemp"),!f&&d.parentNode.nodeName==="A"&&!h(d.parentNode)&&(f=d.parentNode)),d.hasAttribute("contenteditable")&&d.getAttribute("contenteditable")==="false"&&(a=d)}),n.on("drop",function(d){let p=n.dom,y=tinymce.dom.RangeUtils.getCaretRangeFromPoint(d.clientX,d.clientY,n.getDoc()),g=d.dataTransfer&&d.dataTransfer.getData("bookstack/template");g&&(d.preventDefault(),window.$http.get(`/templates/${g}`).then(v=>{n.selection.setRng(y),n.undoManager.transact(function(){n.execCommand("mceInsertContent",!1,v.data.html)})})),p.getParent(y.startContainer,".mceTemp")?d.preventDefault():f&&(d.preventDefault(),n.undoManager.transact(function(){n.selection.setRng(y),n.selection.setNode(f),p.remove(f)})),!d.isDefaultPrevented()&&a&&(d.preventDefault(),n.undoManager.transact(function(){let v=n.selection.getNode(),b=n.selection.getRng(),k=v.closest("body > *");b.startOffset>b.startContainer.length/2?n.$(k).after(a):n.$(k).before(a)})),d.isDefaultPrevented()||py(d,n,t),f=null}),n.addButton("image-insert",{title:"My title",icon:"image",tooltip:"Insert an image",onclick:function(){window.ImageManager.show(function(d){let p=``;p+=`${d.name}`,p+="",n.execCommand("mceInsertContent",!1,p)},"gallery")}}),n.on("paste",d=>py(d,n,t)),window.$events.emitPublic(t.elem,"editor-tinymce::setup",{editor:n})}}}},gy=my;var vy={"add-remove-rows":Vc,"ajax-delete-row":Xc,"ajax-form":Qc,attachments:ef,"attachments-list":rf,"auto-suggest":of,"back-to-top":sf,"book-sort":If,"chapter-toggle":Of,"code-editor":bh,"code-highlighter":wh,collapsible:_h,"custom-checkbox":Eh,"details-highlighter":Th,dropdown:Lh,"dropdown-search":Ih,dropzone:Ph,"editor-toolbox":zh,"entity-permissions-editor":Bh,"entity-search":jh,"entity-selector":Uh,"entity-selector-popup":Wh,"event-emit-select":Kh,"expand-toggle":Yh,"header-mobile-toggle":Zh,"homepage-control":Jh,"image-manager":tp,"image-picker":np,index:qa,"list-sort-control":op,"markdown-editor":_v,"new-user-password":Ev,notification:Tv,"optional-input":Lv,"page-comments":Iv,"page-display":Ov,"page-editor":zv,"page-picker":Bv,"permissions-table":jv,popup:Uv,"setting-app-color-picker":Wv,"setting-color-picker":Kv,"shelf-sort":Yv,sidebar:Zv,"sortable-list":Jv,"submit-on-change":ty,tabs:ny,"tag-manager":oy,"template-manager":sy,"toggle-switch":uy,"tri-layout":fy,"user-select":hy,"wysiwyg-editor":gy};window.components={};function e_(i,t){let n=t.querySelectorAll(`[${i}]`);for(let l=0,c=n.length;l{a.from=l;let h=new CustomEvent(`${i}-${f}`,{bubbles:!0,detail:a});l.$el.dispatchEvent(h)},typeof l.setup=="function"&&l.setup()}catch(c){console.error("Failed to create component",c,i,t)}typeof window.components[i]=="undefined"&&(window.components[i]=[]),window.components[i].push(l),typeof t.components=="undefined"&&(t.components={}),t.components[i]=l}function t_(i,t){let n={},l={},c=`${i}@`,f=`[refs*="${c}"]`,a=[...t.querySelectorAll(f)];t.matches(f)&&a.push(t);for(let h of a){let d=h.getAttribute("refs").split(" ").filter(p=>p.startsWith(c)).map(p=>p.replace(c,"")).map(by);for(let p of d)n[p]=h,typeof l[p]=="undefined"&&(l[p]=[]),l[p].push(h)}return{refs:n,manyRefs:l}}function r_(i,t){let n={},l=`option:${i}:`;for(let{name:c,value:f}of t.attributes)if(c.startsWith(l)){let a=c.replace(l,"");n[by(a)]=f||""}return n}function by(i){let t=l=>l.slice(0,1).toUpperCase()+l.slice(1),n=i.split("-");return n[0]+n.slice(1).map(t).join("")}function xy(i){typeof i=="undefined"&&(i=document);for(let n of Object.keys(vy))e_(n,i);let t=i.querySelectorAll("[component],[components]");for(let n of t){let l=`${n.getAttribute("component")||""} ${n.getAttribute("components")}`.toLowerCase().split(" ").filter(Boolean);for(let c of l)yy(c,n)}}window.components.init=xy;window.components.first=i=>(window.components[i]||[null])[0];var qa=xy;window.baseUrl=function(i){let t=document.querySelector('meta[name="base-url"]').getAttribute("content");return t[t.length-1]==="/"&&(t=t.slice(0,t.length-1)),i[0]==="/"&&(i=i.slice(1)),t+"/"+i};window.$http=qc;window.$events=Nc;var Ei=new $c;window.trans=Ei.get.bind(Ei);window.trans_choice=Ei.getPlural.bind(Ei);window.trans_plural=Ei.parsePlural.bind(Ei);qa();})(); diff --git a/version b/version index c9d8533e9..49f6689fb 100644 --- a/version +++ b/version @@ -1 +1 @@ -v21.08.4 +v21.08.5