bookstack/public/dist/app.js

34 lines
188 KiB
JavaScript

// See the "/licenses" URI for full package license details
var Yi=Object.defineProperty;var Ji=n=>{throw TypeError(n)};var Ss=(n,t,e)=>t in n?Yi(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var ks=(n,t)=>{for(var e in t)Yi(n,e,{get:t[e],enumerable:!0})};var U=(n,t,e)=>Ss(n,typeof t!="symbol"?t+"":t,e),$s=(n,t,e)=>t.has(n)||Ji("Cannot "+e);var Zi=(n,t,e)=>t.has(n)?Ji("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,e);var Zt=(n,t,e)=>($s(n,t,"access private method"),e);var ve=class{constructor(){this.listeners={};this.stack=[]}emit(t,e={}){this.stack.push({name:t,data:e});let i=this.listeners[t]||[];for(let o of i)o(e)}listen(t,e){typeof this.listeners[t]>"u"&&(this.listeners[t]=[]),this.listeners[t].push(e)}remove(t,e){let i=this.listeners[t]||[],o=i.indexOf(e);o!==-1&&i.splice(o,1)}emitPublic(t,e,i){let o=new CustomEvent(e,{detail:i,bubbles:!0});t.dispatchEvent(o)}success(t){this.emit("success",t)}error(t){this.emit("error",t)}showValidationErrors(t){if(t.status===422&&t.data){let e=Object.values(t.data).flat().join(`
`);this.error(e)}}showResponseError(t){t.status&&t.status>=400&&typeof t.data=="object"&&t.data.message&&this.error(t.data.message)}};var xt=class extends Error{constructor(t,e){super(t.statusText),this.data=e,this.headers=t.headers,this.redirected=t.redirected,this.status=t.status,this.statusText=t.statusText,this.url=t.url,this.original=t}},we=class{async getResponseContent(t){if(t.status===204)return null;let i=(t.headers.get("Content-Type")||"").split(";")[0].split("/").pop();return i==="javascript"||i==="json"?t.json():t.text()}createXMLHttpRequest(t,e,i={}){let o=document.querySelector("meta[name=token]")?.getAttribute("content"),s=new XMLHttpRequest;for(let[r,a]of Object.entries(i))s.addEventListener(r,a.bind(s));return s.open(t,e),s.withCredentials=!0,s.setRequestHeader("X-CSRF-TOKEN",o||""),s}async request(t,e={}){let i=t;if(i.startsWith("http")||(i=window.baseUrl(i)),e.params){let c=new URL(i);for(let u of Object.keys(e.params)){let h=e.params[u];typeof h<"u"&&h!==null&&c.searchParams.set(u,h)}i=c.toString()}let o=document.querySelector("meta[name=token]")?.getAttribute("content")||"",s={...e,credentials:"same-origin"};s.headers={...s.headers||{},baseURL:window.baseUrl(""),"X-CSRF-TOKEN":o};let r=await fetch(i,s),a=await this.getResponseContent(r)||"",l={data:a,headers:r.headers,redirected:r.redirected,status:r.status,statusText:r.statusText,url:r.url,original:r};if(!r.ok)throw new xt(r,a);return l}async dataRequest(t,e,i){let o={method:t,body:i};return typeof i=="object"&&!(i instanceof FormData)&&(o.headers={"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},o.body=JSON.stringify(i)),i instanceof FormData&&t!=="post"&&(i.append("_method",t),o.method="post"),this.request(e,o)}async get(t,e={}){return this.request(t,{method:"GET",params:e})}async post(t,e=null){return this.dataRequest("POST",t,e)}async put(t,e=null){return this.dataRequest("PUT",t,e)}async patch(t,e=null){return this.dataRequest("PATCH",t,e)}async delete(t,e=null){return this.dataRequest("DELETE",t,e)}formatErrorResponseText(t){let e=t.startsWith("{")?JSON.parse(t):{message:t};if(!e)return t;if(e.message||e.error)return e.message||e.error;let i=Object.values(e);return i.every(s=>Array.isArray(s)&&s.every(r=>typeof r=="string"))?i.flat().join(" "):t}};var be=class{choice(t,e,i={}){i=Object.assign({},{count:String(e)},i);let o=t.split("|"),s=/^{([0-9]+)}/,r=/^\[([0-9]+),([0-9*]+)]/,a=null;for(let l of o){let c=l.match(s);if(c!==null&&Number(c[1])===e){a=l.replace(s,"").trim();break}let u=l.match(r);if(u!==null&&Number(u[1])<=e&&(u[2]==="*"||Number(u[2])>=e)){a=l.replace(r,"").trim();break}}return a===null&&o.length>1&&(a=e===1?o[0]:o[1]),a===null&&(a=o[0]),this.performReplacements(a,i)}performReplacements(t,e){let i=t.match(/:(\S+)/g);if(i===null)return t;let o=t;for(let s of i){let r=s.substring(1);typeof e[r]>"u"||(o=o.replace(s,e[r]))}return o}};var Ki={};ks(Ki,{AddRemoveRows:()=>xe,AjaxDeleteRow:()=>Le,AjaxForm:()=>Te,Attachments:()=>Se,AttachmentsList:()=>ke,AutoSubmit:()=>De,AutoSuggest:()=>$e,BackToTop:()=>Me,BookSort:()=>Xe,ChapterContents:()=>Ye,CodeEditor:()=>Je,CodeHighlighter:()=>Ze,CodeTextarea:()=>Qe,Collapsible:()=>tn,ConfirmDialog:()=>en,CustomCheckbox:()=>nn,DetailsHighlighter:()=>on,Dropdown:()=>sn,DropdownSearch:()=>rn,Dropzone:()=>an,EditorToolbox:()=>ln,EntityPermissions:()=>cn,EntitySearch:()=>dn,EntitySelector:()=>hn,EntitySelectorPopup:()=>un,EventEmitSelect:()=>pn,ExpandToggle:()=>mn,GlobalSearch:()=>fn,HeaderMobileToggle:()=>gn,ImageManager:()=>vn,ImagePicker:()=>wn,ListSortControl:()=>bn,LoadingButton:()=>yn,MarkdownEditor:()=>En,NewUserPassword:()=>Cn,Notification:()=>xn,OptionalInput:()=>Ln,PageComment:()=>Mn,PageCommentReference:()=>An,PageComments:()=>In,PageDisplay:()=>Hn,PageEditor:()=>Bn,PagePicker:()=>Rn,PermissionsTable:()=>On,Pointer:()=>_n,Popup:()=>Nn,SettingAppColorScheme:()=>Fn,SettingColorPicker:()=>qn,SettingHomepageControl:()=>Un,ShelfSort:()=>jn,ShortcutInput:()=>Kn,Shortcuts:()=>zn,SortRuleManager:()=>Gn,SortableList:()=>Xn,SubmitOnChange:()=>Yn,Tabs:()=>zt,TagManager:()=>Jn,TemplateManager:()=>Zn,ToggleSwitch:()=>Qn,TriLayout:()=>ti,UserSelect:()=>ei,WebhookEvents:()=>ni,WysiwygEditor:()=>ii,WysiwygEditorTinymce:()=>oi,WysiwygInput:()=>si});function mt(n,t,e){let i=null;return function(...s){let r=this,a=function(){i=null,e||n.apply(r,s)},l=e&&!i;i&&clearTimeout(i),i=window.setTimeout(a,t),l&&n.apply(r,s)}}function Ds(n){return n.nodeName==="DETAILS"}function Lt(n){if(!n)return;let t=n;for(;t.parentElement;)t=t.parentElement,Ds(t)&&!t.open&&(t.open=!0);n.scrollIntoView({behavior:"smooth"});let e=getComputedStyle(document.body).getPropertyValue("--color-link");n.style.outline=`2px dashed ${e}`,n.style.outlineOffset="5px",n.style.removeProperty("transition"),setTimeout(()=>{n.style.transition="outline linear 3s",n.style.outline="2px dashed rgba(0, 0, 0, 0)";let i=()=>{n.removeEventListener("transitionend",i),n.style.removeProperty("transition"),n.style.removeProperty("outline"),n.style.removeProperty("outlineOffset")};n.addEventListener("transitionend",i)},1e3)}function Qi(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function to(){let n=()=>((1+Math.random())*65536|0).toString(16).substring(1);return`${n()+n()}-${n()}-${n()}-${n()}-${n()}${n()}${n()}`}function eo(n){return new Promise(t=>{setTimeout(t,n)})}function no(n){let t=n,e=document.querySelector('meta[name="base-url"]');if(!e)throw new Error("Could not find expected base-url meta tag in document");let i=e.getAttribute("content")||"";return i[i.length-1]==="/"&&(i=i.slice(0,i.length-1)),t[0]==="/"&&(t=t.slice(1)),`${i}/${t}`}function Ms(){let n=document.querySelector('link[href*="/dist/styles.css?version="]');if(!n)throw new Error("Could not find expected style link in document for version use");return(n.getAttribute("href")||"").split("?version=").pop()||""}function io(n){return import(window.baseUrl(`dist/${n}.js?version=${Ms()}`))}function oo(n,t=0){let e=3735928559^t,i=1103547991^t;for(let o=0,s;o<n.length;o++)s=n.charCodeAt(o),e=Math.imul(e^s,2654435761),i=Math.imul(i^s,1597334677);return e=Math.imul(e^e>>>16,2246822507),e^=Math.imul(i^i>>>13,3266489909),i=Math.imul(i^i>>>16,2246822507),i^=Math.imul(e^e>>>13,3266489909),String(4294967296*(2097151&i)+(e>>>0))}function ft(n){return n instanceof HTMLElement}function it(n,t={},e=[]){let i=document.createElement(n);for(let[o,s]of Object.entries(t))s===null?i.removeAttribute(o):i.setAttribute(o,s);for(let o of e)typeof o=="string"?i.append(document.createTextNode(o)):i.append(o);return i}function ai(n,t){let e=document.querySelectorAll(n);for(let i of e)t(i)}function ye(n,t,e){if(n)for(let i of t)n.addEventListener(i,e)}function L(n,t){Array.isArray(n)||(n=[n]);for(let e of n)e.addEventListener("click",t),e.addEventListener("keydown",i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),t(i))})}function so(n,t,e){Array.isArray(t)||(t=[t]);let i=o=>{o.key===n&&e(o)};t.forEach(o=>o.addEventListener("keydown",i))}function Ht(n,t){so("Enter",n,t)}function ro(n,t){so("Escape",n,t)}function A(n,t,e,i){n.addEventListener(e,o=>{let s=o.target?.closest(t);s&&i.call(s,o,s)})}function ao(n,t){let e=document.querySelectorAll(n);t=t.toLowerCase();for(let i of e)if((i.textContent||"").toLowerCase().includes(t)&&ft(i))return i;return null}function Tt(n){n.innerHTML='<div class="loading-container"><div></div><div></div><div></div></div>'}function Bt(){let n=document.createElement("div");return n.classList.add("loading-container"),n.innerHTML="<div></div><div></div><div></div>",n}function Qt(n){let t=n.querySelectorAll(".loading-container");for(let e of t)e.remove()}function Z(n){let t=document.createElement("div");t.innerHTML=n,window.$components.init(t);let e=t.children[0];if(!ft(e))throw new Error("Could not find child HTMLElement when creating DOM element from HTML");return e}function li(n,t,e){if(!e.contains(n))throw new Error("ParentElement must be a prent of element");let i=t,o=n.nodeType===Node.TEXT_NODE?n:n.childNodes[t];for(;o!==e&&o;)o.previousSibling?(o=o.previousSibling,i+=o.textContent?.length||0):o=o.parentNode;return i}function Ee(n,t){if(t===0)return{node:n,offset:0};let e=0,i=null;for(let o=0;o<n.childNodes.length;o++)if(i=n.childNodes[o],i.nodeType===Node.TEXT_NODE){let s=(i.textContent||"").length;if(e+s>=t)return{node:i,offset:t-e};e+=s}else if(i.nodeType===Node.ELEMENT_NODE){let s=(i.textContent||"").length;if(e+s>=t)return Ee(i,t-e);e+=s}return null}function Ce(n){let t=(n.textContent||"").replace(/\s{2,}/g,"");return oo(t)}var d=class{constructor(){U(this,"$name","");U(this,"$el",null);U(this,"$refs",{});U(this,"$manyRefs",{});U(this,"$opts",{})}setup(){}$emit(t,e={}){e.from=this;let i=this.$name,o=new CustomEvent(`${i}-${t}`,{bubbles:!0,detail:e});this.$el.dispatchEvent(o)}};var xe=class extends d{setup(){this.modelRow=this.$refs.model,this.addButton=this.$refs.add,this.removeSelector=this.$opts.removeSelector,this.rowSelector=this.$opts.rowSelector,this.setupListeners()}setupListeners(){this.addButton.addEventListener("click",this.add.bind(this)),A(this.$el,this.removeSelector,"click",t=>{t.target.closest(this.rowSelector).remove()})}add(){let t=this.modelRow.cloneNode(!0);t.classList.remove("hidden"),this.setClonedInputNames(t),this.modelRow.parentNode.insertBefore(t,this.modelRow),window.$components.init(t)}setClonedInputNames(t){let e=to(),i=t.querySelectorAll('[name*="randrowid"]');for(let o of i)o.name=o.name.split("randrowid").join(e)}};var Le=class extends d{constructor(){super(...arguments);this.deleteButtons=[]}setup(){this.row=this.$el,this.url=this.$opts.url,this.deleteButtons=this.$manyRefs.delete||[],L(this.deleteButtons,this.runDelete.bind(this))}runDelete(){this.row.style.opacity="0.7",this.row.style.pointerEvents="none",window.$http.delete(this.url).then(e=>{typeof e.data=="object"&&e.data.message&&window.$events.emit("success",e.data.message),this.row.remove()}).catch(()=>{this.row.style.removeProperty("opacity"),this.row.style.removeProperty("pointer-events")})}};var Te=class extends d{setup(){this.container=this.$el,this.responseContainer=this.container,this.url=this.$opts.url,this.method=this.$opts.method||"post",this.successMessage=this.$opts.successMessage,this.submitButtons=this.$manyRefs.submit||[],this.$opts.responseContainer&&(this.responseContainer=this.container.closest(this.$opts.responseContainer)),this.setupListeners()}setupListeners(){if(this.container.tagName==="FORM"){this.container.addEventListener("submit",this.submitRealForm.bind(this));return}Ht(this.container,t=>{this.submitFakeForm(),t.preventDefault()}),this.submitButtons.forEach(t=>L(t,this.submitFakeForm.bind(this)))}submitFakeForm(){let t=new FormData,e=this.container.querySelectorAll("[name]");for(let i of e)t.append(i.getAttribute("name"),i.value);this.submit(t)}submitRealForm(t){t.preventDefault();let e=new FormData(this.container);this.submit(e)}async submit(t){this.responseContainer.style.opacity="0.7",this.responseContainer.style.pointerEvents="none";try{let e=await window.$http[this.method.toLowerCase()](this.url,t);this.$emit("success",{formData:t}),this.responseContainer.innerHTML=e.data,this.successMessage&&window.$events.emit("success",this.successMessage)}catch(e){this.responseContainer.innerHTML=e.data}window.$components.init(this.responseContainer),this.responseContainer.style.opacity=null,this.responseContainer.style.pointerEvents=null}};var Se=class extends d{setup(){this.container=this.$el,this.pageId=this.$opts.pageId,this.editContainer=this.$refs.editContainer,this.listContainer=this.$refs.listContainer,this.linksContainer=this.$refs.linksContainer,this.listPanel=this.$refs.listPanel,this.attachLinkButton=this.$refs.attachLinkButton,this.setupListeners()}setupListeners(){let t=this.reloadList.bind(this);this.container.addEventListener("dropzone-upload-success",t),this.container.addEventListener("ajax-form-success",t),this.container.addEventListener("sortable-list-sort",e=>{this.updateOrder(e.detail.ids)}),this.container.addEventListener("event-emit-select-edit",e=>{this.startEdit(e.detail.id)}),this.container.addEventListener("event-emit-select-edit-back",()=>{this.stopEdit()}),this.container.addEventListener("event-emit-select-insert",e=>{let i=e.target.closest("[data-drag-content]").getAttribute("data-drag-content"),o=JSON.parse(i);window.$events.emit("editor::insert",{html:o["text/html"],markdown:o["text/plain"]})}),this.attachLinkButton.addEventListener("click",()=>{this.showSection("links")})}showSection(t){let e={links:this.linksContainer,edit:this.editContainer,list:this.listContainer};for(let[i,o]of Object.entries(e))o.toggleAttribute("hidden",i!==t)}reloadList(){this.stopEdit(),window.$http.get(`/attachments/get/page/${this.pageId}`).then(t=>{this.listPanel.innerHTML=t.data,window.$components.init(this.listPanel)})}updateOrder(t){window.$http.put(`/attachments/sort/page/${this.pageId}`,{order:t}).then(e=>{window.$events.emit("success",e.data.message)})}async startEdit(t){this.showSection("edit"),Tt(this.editContainer);let e=await window.$http.get(`/attachments/edit/${t}`);this.editContainer.innerHTML=e.data,window.$components.init(this.editContainer)}stopEdit(){this.showSection("list")}};var ke=class extends d{setup(){this.container=this.$el,this.fileLinks=this.$manyRefs.linkTypeFile,this.setupListeners()}setupListeners(){let t=e=>e.key==="Control"||e.key==="Meta";window.addEventListener("keydown",e=>{t(e)&&this.addOpenQueryToLinks()},{passive:!0}),window.addEventListener("keyup",e=>{t(e)&&this.removeOpenQueryFromLinks()},{passive:!0})}addOpenQueryToLinks(){for(let t of this.fileLinks)t.href.split("?")[1]!=="open=true"&&(t.href+="?open=true",t.setAttribute("target","_blank"))}removeOpenQueryFromLinks(){for(let t of this.fileLinks)t.href=t.href.split("?")[0],t.removeAttribute("target")}};var vt,di,hi,gt=class{constructor(t,e=null,i=null){Zi(this,vt);this.containers=[t],this.onEscape=e,this.onEnter=i,t.addEventListener("keydown",Zt(this,vt,di).bind(this))}shareHandlingToEl(t){this.containers.push(t),t.addEventListener("keydown",Zt(this,vt,di).bind(this))}focusNext(){let t=Zt(this,vt,hi).call(this),e=document.activeElement,o=(ft(e)?t.indexOf(e):-1)+1;o>=t.length&&(o=0),t[o].focus()}focusPrevious(){let t=Zt(this,vt,hi).call(this),e=document.activeElement,o=(ft(e)?t.indexOf(e):-1)-1;o<0&&(o=t.length-1),t[o].focus()}};vt=new WeakSet,di=function(t){ft(t.target)&&t.target.matches("input")&&(t.key==="ArrowRight"||t.key==="ArrowLeft")||(t.key==="ArrowDown"||t.key==="ArrowRight"?(this.focusNext(),t.preventDefault()):t.key==="ArrowUp"||t.key==="ArrowLeft"?(this.focusPrevious(),t.preventDefault()):t.key==="Escape"?this.onEscape?this.onEscape(t):ft(document.activeElement)&&document.activeElement.blur():t.key==="Enter"&&this.onEnter&&this.onEnter(t))},hi=function(){let t=[],e='[tabindex]:not([tabindex="-1"]),[href],button:not([tabindex="-1"],[disabled]),input:not([type=hidden])';for(let i of this.containers){let o=[...i.querySelectorAll(e)].filter(s=>ft(s));t.push(...o)}return t};var ui={},$e=class extends d{setup(){this.parent=this.$el.parentElement,this.container=this.$el,this.type=this.$opts.type,this.url=this.$opts.url,this.input=this.$refs.input,this.list=this.$refs.list,this.lastPopulated=0,this.setupListeners()}setupListeners(){new gt(this.list,()=>{this.input.focus(),setTimeout(()=>this.hideSuggestions(),1)},e=>{e.preventDefault();let i=e.target.textContent;i&&this.selectSuggestion(i)}).shareHandlingToEl(this.input),A(this.list,".text-item","click",(e,i)=>{this.selectSuggestion(i.textContent)}),this.input.addEventListener("input",this.requestSuggestions.bind(this)),this.input.addEventListener("focus",this.requestSuggestions.bind(this)),this.input.addEventListener("blur",this.hideSuggestionsIfFocusedLost.bind(this)),this.input.addEventListener("keydown",e=>{e.key==="Tab"&&this.hideSuggestions()})}selectSuggestion(t){this.input.value=t,this.lastPopulated=Date.now(),this.input.focus(),this.input.dispatchEvent(new Event("input",{bubbles:!0})),this.input.dispatchEvent(new Event("change",{bubbles:!0})),this.hideSuggestions()}async requestSuggestions(){if(Date.now()-this.lastPopulated<50)return;let t=this.getNameFilterIfNeeded(),e=this.input.value.toLowerCase(),o=(await this.loadSuggestions(e,t)).filter(s=>e===""||s.toLowerCase().startsWith(e)).slice(0,10);this.displaySuggestions(o)}getNameFilterIfNeeded(){return this.type!=="value"?null:this.parent.querySelector("input").value}async loadSuggestions(t,e=null){t=t.slice(0,4);let i={search:t,name:e},o=`${this.url}:${JSON.stringify(i)}`;if(ui[o])return ui[o];let s=await window.$http.get(this.url,i);return ui[o]=s.data,s.data}displaySuggestions(t){if(t.length===0){this.hideSuggestions();return}this.list.innerHTML=t.map(e=>`<li><div tabindex="0" class="text-item">${Qi(e)}</div></li>`).join(""),this.list.style.display="block";for(let e of this.list.querySelectorAll(".text-item"))e.addEventListener("blur",this.hideSuggestionsIfFocusedLost.bind(this))}hideSuggestions(){this.list.style.display="none"}hideSuggestionsIfFocusedLost(t){this.container.contains(t.relatedTarget)||this.hideSuggestions()}};var De=class extends d{setup(){this.form=this.$el,this.form.submit()}};var Me=class extends d{setup(){if(this.button=this.$el,this.targetElem=document.getElementById("header"),this.showing=!1,this.breakPoint=1200,document.body.classList.contains("flexbox")){this.button.style.display="none";return}this.button.addEventListener("click",this.scrollToTop.bind(this)),window.addEventListener("scroll",this.onPageScroll.bind(this))}onPageScroll(){let t=document.documentElement.scrollTop||document.body.scrollTop||0;!this.showing&&t>this.breakPoint?(this.button.style.display="block",this.showing=!0,setTimeout(()=>{this.button.style.opacity=.4},1)):this.showing&&t<this.breakPoint&&(this.button.style.opacity=0,this.showing=!1,setTimeout(()=>{this.button.style.display="none"},500))}scrollToTop(){let t=this.targetElem.getBoundingClientRect().top,e=document.documentElement.scrollTop?document.documentElement:document.body,i=300,o=Date.now(),s=this.targetElem.getBoundingClientRect().top;function r(){let a=1-(Date.now()-o)/i,l=Math.abs(a*s);a>0?(e.scrollTop=l,requestAnimationFrame(r.bind(this))):e.scrollTop=t}requestAnimationFrame(r.bind(this))}};function lo(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);t&&(i=i.filter(function(o){return Object.getOwnPropertyDescriptor(n,o).enumerable})),e.push.apply(e,i)}return e}function st(n){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?lo(Object(e),!0).forEach(function(i){As(n,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):lo(Object(e)).forEach(function(i){Object.defineProperty(n,i,Object.getOwnPropertyDescriptor(e,i))})}return n}function Oe(n){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Oe=function(t){return typeof t}:Oe=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Oe(n)}function As(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function et(){return et=Object.assign||function(n){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i])}return n},et.apply(this,arguments)}function Is(n,t){if(n==null)return{};var e={},i=Object.keys(n),o,s;for(s=0;s<i.length;s++)o=i[s],!(t.indexOf(o)>=0)&&(e[o]=n[o]);return e}function Hs(n,t){if(n==null)return{};var e=Is(n,t),i,o;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(n);for(o=0;o<s.length;o++)i=s[o],!(t.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(n,i)&&(e[i]=n[i])}return e}function Bs(n){return Ps(n)||Rs(n)||Os(n)||_s()}function Ps(n){if(Array.isArray(n))return xi(n)}function Rs(n){if(typeof Symbol<"u"&&n[Symbol.iterator]!=null||n["@@iterator"]!=null)return Array.from(n)}function Os(n,t){if(n){if(typeof n=="string")return xi(n,t);var e=Object.prototype.toString.call(n).slice(8,-1);if(e==="Object"&&n.constructor&&(e=n.constructor.name),e==="Map"||e==="Set")return Array.from(n);if(e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return xi(n,t)}}function xi(n,t){(t==null||t>n.length)&&(t=n.length);for(var e=0,i=new Array(t);e<t;e++)i[e]=n[e];return i}function _s(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var Ns="1.15.6";function ct(n){if(typeof window<"u"&&window.navigator)return!!navigator.userAgent.match(n)}var dt=ct(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),ue=ct(/Edge/i),co=ct(/firefox/i),ae=ct(/safari/i)&&!ct(/chrome/i)&&!ct(/android/i),$i=ct(/iP(ad|od|hone)/i),yo=ct(/chrome/i)&&ct(/android/i),Eo={capture:!1,passive:!1};function E(n,t,e){n.addEventListener(t,e,!dt&&Eo)}function y(n,t,e){n.removeEventListener(t,e,!dt&&Eo)}function Ue(n,t){if(t){if(t[0]===">"&&(t=t.substring(1)),n)try{if(n.matches)return n.matches(t);if(n.msMatchesSelector)return n.msMatchesSelector(t);if(n.webkitMatchesSelector)return n.webkitMatchesSelector(t)}catch{return!1}return!1}}function Co(n){return n.host&&n!==document&&n.host.nodeType?n.host:n.parentNode}function j(n,t,e,i){if(n){e=e||document;do{if(t!=null&&(t[0]===">"?n.parentNode===e&&Ue(n,t):Ue(n,t))||i&&n===e)return n;if(n===e)break}while(n=Co(n))}return null}var ho=/\s+/g;function B(n,t,e){if(n&&t)if(n.classList)n.classList[e?"add":"remove"](t);else{var i=(" "+n.className+" ").replace(ho," ").replace(" "+t+" "," ");n.className=(i+(e?" "+t:"")).replace(ho," ")}}function f(n,t,e){var i=n&&n.style;if(i){if(e===void 0)return document.defaultView&&document.defaultView.getComputedStyle?e=document.defaultView.getComputedStyle(n,""):n.currentStyle&&(e=n.currentStyle),t===void 0?e:e[t];!(t in i)&&t.indexOf("webkit")===-1&&(t="-webkit-"+t),i[t]=e+(typeof e=="string"?"":"px")}}function Dt(n,t){var e="";if(typeof n=="string")e=n;else do{var i=f(n,"transform");i&&i!=="none"&&(e=i+" "+e)}while(!t&&(n=n.parentNode));var o=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return o&&new o(e)}function xo(n,t,e){if(n){var i=n.getElementsByTagName(t),o=0,s=i.length;if(e)for(;o<s;o++)e(i[o],o);return i}return[]}function ot(){var n=document.scrollingElement;return n||document.documentElement}function $(n,t,e,i,o){if(!(!n.getBoundingClientRect&&n!==window)){var s,r,a,l,c,u,h;if(n!==window&&n.parentNode&&n!==ot()?(s=n.getBoundingClientRect(),r=s.top,a=s.left,l=s.bottom,c=s.right,u=s.height,h=s.width):(r=0,a=0,l=window.innerHeight,c=window.innerWidth,u=window.innerHeight,h=window.innerWidth),(t||e)&&n!==window&&(o=o||n.parentNode,!dt))do if(o&&o.getBoundingClientRect&&(f(o,"transform")!=="none"||e&&f(o,"position")!=="static")){var m=o.getBoundingClientRect();r-=m.top+parseInt(f(o,"border-top-width")),a-=m.left+parseInt(f(o,"border-left-width")),l=r+s.height,c=a+s.width;break}while(o=o.parentNode);if(i&&n!==window){var g=Dt(o||n),C=g&&g.a,T=g&&g.d;g&&(r/=T,a/=C,h/=C,u/=T,l=r+u,c=a+h)}return{top:r,left:a,bottom:l,right:c,width:h,height:u}}}function uo(n,t,e){for(var i=yt(n,!0),o=$(n)[t];i;){var s=$(i)[e],r=void 0;if(e==="top"||e==="left"?r=o>=s:r=o<=s,!r)return i;if(i===ot())break;i=yt(i,!1)}return!1}function Ft(n,t,e,i){for(var o=0,s=0,r=n.children;s<r.length;){if(r[s].style.display!=="none"&&r[s]!==v.ghost&&(i||r[s]!==v.dragged)&&j(r[s],e.draggable,n,!1)){if(o===t)return r[s];o++}s++}return null}function Di(n,t){for(var e=n.lastElementChild;e&&(e===v.ghost||f(e,"display")==="none"||t&&!Ue(e,t));)e=e.previousElementSibling;return e||null}function P(n,t){var e=0;if(!n||!n.parentNode)return-1;for(;n=n.previousElementSibling;)n.nodeName.toUpperCase()!=="TEMPLATE"&&n!==v.clone&&(!t||Ue(n,t))&&e++;return e}function po(n){var t=0,e=0,i=ot();if(n)do{var o=Dt(n),s=o.a,r=o.d;t+=n.scrollLeft*s,e+=n.scrollTop*r}while(n!==i&&(n=n.parentNode));return[t,e]}function Fs(n,t){for(var e in n)if(n.hasOwnProperty(e)){for(var i in t)if(t.hasOwnProperty(i)&&t[i]===n[e][i])return Number(e)}return-1}function yt(n,t){if(!n||!n.getBoundingClientRect)return ot();var e=n,i=!1;do if(e.clientWidth<e.scrollWidth||e.clientHeight<e.scrollHeight){var o=f(e);if(e.clientWidth<e.scrollWidth&&(o.overflowX=="auto"||o.overflowX=="scroll")||e.clientHeight<e.scrollHeight&&(o.overflowY=="auto"||o.overflowY=="scroll")){if(!e.getBoundingClientRect||e===document.body)return ot();if(i||t)return e;i=!0}}while(e=e.parentNode);return ot()}function qs(n,t){if(n&&t)for(var e in t)t.hasOwnProperty(e)&&(n[e]=t[e]);return n}function pi(n,t){return Math.round(n.top)===Math.round(t.top)&&Math.round(n.left)===Math.round(t.left)&&Math.round(n.height)===Math.round(t.height)&&Math.round(n.width)===Math.round(t.width)}var le;function Lo(n,t){return function(){if(!le){var e=arguments,i=this;e.length===1?n.call(i,e[0]):n.apply(i,e),le=setTimeout(function(){le=void 0},t)}}}function Us(){clearTimeout(le),le=void 0}function To(n,t,e){n.scrollLeft+=t,n.scrollTop+=e}function Mi(n){var t=window.Polymer,e=window.jQuery||window.Zepto;return t&&t.dom?t.dom(n).cloneNode(!0):e?e(n).clone(!0)[0]:n.cloneNode(!0)}function mo(n,t){f(n,"position","absolute"),f(n,"top",t.top),f(n,"left",t.left),f(n,"width",t.width),f(n,"height",t.height)}function mi(n){f(n,"position",""),f(n,"top",""),f(n,"left",""),f(n,"width",""),f(n,"height","")}function So(n,t,e){var i={};return Array.from(n.children).forEach(function(o){var s,r,a,l;if(!(!j(o,t.draggable,n,!1)||o.animated||o===e)){var c=$(o);i.left=Math.min((s=i.left)!==null&&s!==void 0?s:1/0,c.left),i.top=Math.min((r=i.top)!==null&&r!==void 0?r:1/0,c.top),i.right=Math.max((a=i.right)!==null&&a!==void 0?a:-1/0,c.right),i.bottom=Math.max((l=i.bottom)!==null&&l!==void 0?l:-1/0,c.bottom)}}),i.width=i.right-i.left,i.height=i.bottom-i.top,i.x=i.left,i.y=i.top,i}var _="Sortable"+new Date().getTime();function Vs(){var n=[],t;return{captureAnimationState:function(){if(n=[],!!this.options.animation){var i=[].slice.call(this.el.children);i.forEach(function(o){if(!(f(o,"display")==="none"||o===v.ghost)){n.push({target:o,rect:$(o)});var s=st({},n[n.length-1].rect);if(o.thisAnimationDuration){var r=Dt(o,!0);r&&(s.top-=r.f,s.left-=r.e)}o.fromRect=s}})}},addAnimationState:function(i){n.push(i)},removeAnimationState:function(i){n.splice(Fs(n,{target:i}),1)},animateAll:function(i){var o=this;if(!this.options.animation){clearTimeout(t),typeof i=="function"&&i();return}var s=!1,r=0;n.forEach(function(a){var l=0,c=a.target,u=c.fromRect,h=$(c),m=c.prevFromRect,g=c.prevToRect,C=a.rect,T=Dt(c,!0);T&&(h.top-=T.f,h.left-=T.e),c.toRect=h,c.thisAnimationDuration&&pi(m,h)&&!pi(u,h)&&(C.top-h.top)/(C.left-h.left)===(u.top-h.top)/(u.left-h.left)&&(l=js(C,m,g,o.options)),pi(h,u)||(c.prevFromRect=u,c.prevToRect=h,l||(l=o.options.animation),o.animate(c,C,h,l)),l&&(s=!0,r=Math.max(r,l),clearTimeout(c.animationResetTimer),c.animationResetTimer=setTimeout(function(){c.animationTime=0,c.prevFromRect=null,c.fromRect=null,c.prevToRect=null,c.thisAnimationDuration=null},l),c.thisAnimationDuration=l)}),clearTimeout(t),s?t=setTimeout(function(){typeof i=="function"&&i()},r):typeof i=="function"&&i(),n=[]},animate:function(i,o,s,r){if(r){f(i,"transition",""),f(i,"transform","");var a=Dt(this.el),l=a&&a.a,c=a&&a.d,u=(o.left-s.left)/(l||1),h=(o.top-s.top)/(c||1);i.animatingX=!!u,i.animatingY=!!h,f(i,"transform","translate3d("+u+"px,"+h+"px,0)"),this.forRepaintDummy=Ws(i),f(i,"transition","transform "+r+"ms"+(this.options.easing?" "+this.options.easing:"")),f(i,"transform","translate3d(0,0,0)"),typeof i.animated=="number"&&clearTimeout(i.animated),i.animated=setTimeout(function(){f(i,"transition",""),f(i,"transform",""),i.animated=!1,i.animatingX=!1,i.animatingY=!1},r)}}}}function Ws(n){return n.offsetWidth}function js(n,t,e,i){return Math.sqrt(Math.pow(t.top-n.top,2)+Math.pow(t.left-n.left,2))/Math.sqrt(Math.pow(t.top-e.top,2)+Math.pow(t.left-e.left,2))*i.animation}var Pt=[],fi={initializeByDefault:!0},pe={mount:function(t){for(var e in fi)fi.hasOwnProperty(e)&&!(e in t)&&(t[e]=fi[e]);Pt.forEach(function(i){if(i.pluginName===t.pluginName)throw"Sortable: Cannot mount plugin ".concat(t.pluginName," more than once")}),Pt.push(t)},pluginEvent:function(t,e,i){var o=this;this.eventCanceled=!1,i.cancel=function(){o.eventCanceled=!0};var s=t+"Global";Pt.forEach(function(r){e[r.pluginName]&&(e[r.pluginName][s]&&e[r.pluginName][s](st({sortable:e},i)),e.options[r.pluginName]&&e[r.pluginName][t]&&e[r.pluginName][t](st({sortable:e},i)))})},initializePlugins:function(t,e,i,o){Pt.forEach(function(a){var l=a.pluginName;if(!(!t.options[l]&&!a.initializeByDefault)){var c=new a(t,e,t.options);c.sortable=t,c.options=t.options,t[l]=c,et(i,c.defaults)}});for(var s in t.options)if(t.options.hasOwnProperty(s)){var r=this.modifyOption(t,s,t.options[s]);typeof r<"u"&&(t.options[s]=r)}},getEventProperties:function(t,e){var i={};return Pt.forEach(function(o){typeof o.eventProperties=="function"&&et(i,o.eventProperties.call(e[o.pluginName],t))}),i},modifyOption:function(t,e,i){var o;return Pt.forEach(function(s){t[s.pluginName]&&s.optionListeners&&typeof s.optionListeners[e]=="function"&&(o=s.optionListeners[e].call(t[s.pluginName],i))}),o}};function ie(n){var t=n.sortable,e=n.rootEl,i=n.name,o=n.targetEl,s=n.cloneEl,r=n.toEl,a=n.fromEl,l=n.oldIndex,c=n.newIndex,u=n.oldDraggableIndex,h=n.newDraggableIndex,m=n.originalEvent,g=n.putSortable,C=n.extraEventProperties;if(t=t||e&&e[_],!!t){var T,F=t.options,Y="on"+i.charAt(0).toUpperCase()+i.substr(1);window.CustomEvent&&!dt&&!ue?T=new CustomEvent(i,{bubbles:!0,cancelable:!0}):(T=document.createEvent("Event"),T.initEvent(i,!0,!0)),T.to=r||e,T.from=a||e,T.item=o||e,T.clone=s,T.oldIndex=l,T.newIndex=c,T.oldDraggableIndex=u,T.newDraggableIndex=h,T.originalEvent=m,T.pullMode=g?g.lastPutMode:void 0;var x=st(st({},C),pe.getEventProperties(i,t));for(var S in x)T[S]=x[S];e&&e.dispatchEvent(T),F[Y]&&F[Y].call(t,T)}}var zs=["evt"],V=function(t,e){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=i.evt,s=Hs(i,zs);pe.pluginEvent.bind(v)(t,e,st({dragEl:p,parentEl:I,ghostEl:b,rootEl:D,nextEl:$t,lastDownEl:_e,cloneEl:M,cloneHidden:bt,dragStarted:oe,putSortable:O,activeSortable:v.active,originalEvent:o,oldIndex:Nt,oldDraggableIndex:ce,newIndex:G,newDraggableIndex:wt,hideGhostForTarget:Mo,unhideGhostForTarget:Ao,cloneNowHidden:function(){bt=!0},cloneNowShown:function(){bt=!1},dispatchSortableEvent:function(a){q({sortable:e,name:a,originalEvent:o})}},s))};function q(n){ie(st({putSortable:O,cloneEl:M,targetEl:p,rootEl:D,oldIndex:Nt,oldDraggableIndex:ce,newIndex:G,newDraggableIndex:wt},n))}var p,I,b,D,$t,_e,M,bt,Nt,G,ce,wt,Ae,O,_t=!1,Ve=!1,We=[],St,Q,gi,vi,fo,go,oe,Rt,de,he=!1,Ie=!1,Ne,N,wi=[],Li=!1,je=[],Ke=typeof document<"u",He=$i,vo=ue||dt?"cssFloat":"float",Ks=Ke&&!yo&&!$i&&"draggable"in document.createElement("div"),ko=function(){if(Ke){if(dt)return!1;var n=document.createElement("x");return n.style.cssText="pointer-events:auto",n.style.pointerEvents==="auto"}}(),$o=function(t,e){var i=f(t),o=parseInt(i.width)-parseInt(i.paddingLeft)-parseInt(i.paddingRight)-parseInt(i.borderLeftWidth)-parseInt(i.borderRightWidth),s=Ft(t,0,e),r=Ft(t,1,e),a=s&&f(s),l=r&&f(r),c=a&&parseInt(a.marginLeft)+parseInt(a.marginRight)+$(s).width,u=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+$(r).width;if(i.display==="flex")return i.flexDirection==="column"||i.flexDirection==="column-reverse"?"vertical":"horizontal";if(i.display==="grid")return i.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(s&&a.float&&a.float!=="none"){var h=a.float==="left"?"left":"right";return r&&(l.clear==="both"||l.clear===h)?"vertical":"horizontal"}return s&&(a.display==="block"||a.display==="flex"||a.display==="table"||a.display==="grid"||c>=o&&i[vo]==="none"||r&&i[vo]==="none"&&c+u>o)?"vertical":"horizontal"},Xs=function(t,e,i){var o=i?t.left:t.top,s=i?t.right:t.bottom,r=i?t.width:t.height,a=i?e.left:e.top,l=i?e.right:e.bottom,c=i?e.width:e.height;return o===a||s===l||o+r/2===a+c/2},Gs=function(t,e){var i;return We.some(function(o){var s=o[_].options.emptyInsertThreshold;if(!(!s||Di(o))){var r=$(o),a=t>=r.left-s&&t<=r.right+s,l=e>=r.top-s&&e<=r.bottom+s;if(a&&l)return i=o}}),i},Do=function(t){function e(s,r){return function(a,l,c,u){var h=a.options.group.name&&l.options.group.name&&a.options.group.name===l.options.group.name;if(s==null&&(r||h))return!0;if(s==null||s===!1)return!1;if(r&&s==="clone")return s;if(typeof s=="function")return e(s(a,l,c,u),r)(a,l,c,u);var m=(r?a:l).options.group.name;return s===!0||typeof s=="string"&&s===m||s.join&&s.indexOf(m)>-1}}var i={},o=t.group;(!o||Oe(o)!="object")&&(o={name:o}),i.name=o.name,i.checkPull=e(o.pull,!0),i.checkPut=e(o.put),i.revertClone=o.revertClone,t.group=i},Mo=function(){!ko&&b&&f(b,"display","none")},Ao=function(){!ko&&b&&f(b,"display","")};Ke&&!yo&&document.addEventListener("click",function(n){if(Ve)return n.preventDefault(),n.stopPropagation&&n.stopPropagation(),n.stopImmediatePropagation&&n.stopImmediatePropagation(),Ve=!1,!1},!0);var kt=function(t){if(p){t=t.touches?t.touches[0]:t;var e=Gs(t.clientX,t.clientY);if(e){var i={};for(var o in t)t.hasOwnProperty(o)&&(i[o]=t[o]);i.target=i.rootEl=e,i.preventDefault=void 0,i.stopPropagation=void 0,e[_]._onDragOver(i)}}},Ys=function(t){p&&p.parentNode[_]._isOutsideThisEl(t.target)};function v(n,t){if(!(n&&n.nodeType&&n.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(n));this.el=n,this.options=t=et({},t),n[_]=this;var e={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(n.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return $o(n,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(r,a){r.setData("Text",a.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:v.supportPointer!==!1&&"PointerEvent"in window&&(!ae||$i),emptyInsertThreshold:5};pe.initializePlugins(this,n,e);for(var i in e)!(i in t)&&(t[i]=e[i]);Do(t);for(var o in this)o.charAt(0)==="_"&&typeof this[o]=="function"&&(this[o]=this[o].bind(this));this.nativeDraggable=t.forceFallback?!1:Ks,this.nativeDraggable&&(this.options.touchStartThreshold=1),t.supportPointer?E(n,"pointerdown",this._onTapStart):(E(n,"mousedown",this._onTapStart),E(n,"touchstart",this._onTapStart)),this.nativeDraggable&&(E(n,"dragover",this),E(n,"dragenter",this)),We.push(this.el),t.store&&t.store.get&&this.sort(t.store.get(this)||[]),et(this,Vs())}v.prototype={constructor:v,_isOutsideThisEl:function(t){!this.el.contains(t)&&t!==this.el&&(Rt=null)},_getDirection:function(t,e){return typeof this.options.direction=="function"?this.options.direction.call(this,t,e,p):this.options.direction},_onTapStart:function(t){if(t.cancelable){var e=this,i=this.el,o=this.options,s=o.preventOnFilter,r=t.type,a=t.touches&&t.touches[0]||t.pointerType&&t.pointerType==="touch"&&t,l=(a||t).target,c=t.target.shadowRoot&&(t.path&&t.path[0]||t.composedPath&&t.composedPath()[0])||l,u=o.filter;if(or(i),!p&&!(/mousedown|pointerdown/.test(r)&&t.button!==0||o.disabled)&&!c.isContentEditable&&!(!this.nativeDraggable&&ae&&l&&l.tagName.toUpperCase()==="SELECT")&&(l=j(l,o.draggable,i,!1),!(l&&l.animated)&&_e!==l)){if(Nt=P(l),ce=P(l,o.draggable),typeof u=="function"){if(u.call(this,t,l,this)){q({sortable:e,rootEl:c,name:"filter",targetEl:l,toEl:i,fromEl:i}),V("filter",e,{evt:t}),s&&t.preventDefault();return}}else if(u&&(u=u.split(",").some(function(h){if(h=j(c,h.trim(),i,!1),h)return q({sortable:e,rootEl:h,name:"filter",targetEl:l,fromEl:i,toEl:i}),V("filter",e,{evt:t}),!0}),u)){s&&t.preventDefault();return}o.handle&&!j(c,o.handle,i,!1)||this._prepareDragStart(t,a,l)}}},_prepareDragStart:function(t,e,i){var o=this,s=o.el,r=o.options,a=s.ownerDocument,l;if(i&&!p&&i.parentNode===s){var c=$(i);if(D=s,p=i,I=p.parentNode,$t=p.nextSibling,_e=i,Ae=r.group,v.dragged=p,St={target:p,clientX:(e||t).clientX,clientY:(e||t).clientY},fo=St.clientX-c.left,go=St.clientY-c.top,this._lastX=(e||t).clientX,this._lastY=(e||t).clientY,p.style["will-change"]="all",l=function(){if(V("delayEnded",o,{evt:t}),v.eventCanceled){o._onDrop();return}o._disableDelayedDragEvents(),!co&&o.nativeDraggable&&(p.draggable=!0),o._triggerDragStart(t,e),q({sortable:o,name:"choose",originalEvent:t}),B(p,r.chosenClass,!0)},r.ignore.split(",").forEach(function(u){xo(p,u.trim(),bi)}),E(a,"dragover",kt),E(a,"mousemove",kt),E(a,"touchmove",kt),r.supportPointer?(E(a,"pointerup",o._onDrop),!this.nativeDraggable&&E(a,"pointercancel",o._onDrop)):(E(a,"mouseup",o._onDrop),E(a,"touchend",o._onDrop),E(a,"touchcancel",o._onDrop)),co&&this.nativeDraggable&&(this.options.touchStartThreshold=4,p.draggable=!0),V("delayStart",this,{evt:t}),r.delay&&(!r.delayOnTouchOnly||e)&&(!this.nativeDraggable||!(ue||dt))){if(v.eventCanceled){this._onDrop();return}r.supportPointer?(E(a,"pointerup",o._disableDelayedDrag),E(a,"pointercancel",o._disableDelayedDrag)):(E(a,"mouseup",o._disableDelayedDrag),E(a,"touchend",o._disableDelayedDrag),E(a,"touchcancel",o._disableDelayedDrag)),E(a,"mousemove",o._delayedDragTouchMoveHandler),E(a,"touchmove",o._delayedDragTouchMoveHandler),r.supportPointer&&E(a,"pointermove",o._delayedDragTouchMoveHandler),o._dragStartTimer=setTimeout(l,r.delay)}else l()}},_delayedDragTouchMoveHandler:function(t){var e=t.touches?t.touches[0]:t;Math.max(Math.abs(e.clientX-this._lastX),Math.abs(e.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){p&&bi(p),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var t=this.el.ownerDocument;y(t,"mouseup",this._disableDelayedDrag),y(t,"touchend",this._disableDelayedDrag),y(t,"touchcancel",this._disableDelayedDrag),y(t,"pointerup",this._disableDelayedDrag),y(t,"pointercancel",this._disableDelayedDrag),y(t,"mousemove",this._delayedDragTouchMoveHandler),y(t,"touchmove",this._delayedDragTouchMoveHandler),y(t,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(t,e){e=e||t.pointerType=="touch"&&t,!this.nativeDraggable||e?this.options.supportPointer?E(document,"pointermove",this._onTouchMove):e?E(document,"touchmove",this._onTouchMove):E(document,"mousemove",this._onTouchMove):(E(p,"dragend",this),E(D,"dragstart",this._onDragStart));try{document.selection?Fe(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(t,e){if(_t=!1,D&&p){V("dragStarted",this,{evt:e}),this.nativeDraggable&&E(document,"dragover",Ys);var i=this.options;!t&&B(p,i.dragClass,!1),B(p,i.ghostClass,!0),v.active=this,t&&this._appendGhost(),q({sortable:this,name:"start",originalEvent:e})}else this._nulling()},_emulateDragOver:function(){if(Q){this._lastX=Q.clientX,this._lastY=Q.clientY,Mo();for(var t=document.elementFromPoint(Q.clientX,Q.clientY),e=t;t&&t.shadowRoot&&(t=t.shadowRoot.elementFromPoint(Q.clientX,Q.clientY),t!==e);)e=t;if(p.parentNode[_]._isOutsideThisEl(t),e)do{if(e[_]){var i=void 0;if(i=e[_]._onDragOver({clientX:Q.clientX,clientY:Q.clientY,target:t,rootEl:e}),i&&!this.options.dragoverBubble)break}t=e}while(e=Co(e));Ao()}},_onTouchMove:function(t){if(St){var e=this.options,i=e.fallbackTolerance,o=e.fallbackOffset,s=t.touches?t.touches[0]:t,r=b&&Dt(b,!0),a=b&&r&&r.a,l=b&&r&&r.d,c=He&&N&&po(N),u=(s.clientX-St.clientX+o.x)/(a||1)+(c?c[0]-wi[0]:0)/(a||1),h=(s.clientY-St.clientY+o.y)/(l||1)+(c?c[1]-wi[1]:0)/(l||1);if(!v.active&&!_t){if(i&&Math.max(Math.abs(s.clientX-this._lastX),Math.abs(s.clientY-this._lastY))<i)return;this._onDragStart(t,!0)}if(b){r?(r.e+=u-(gi||0),r.f+=h-(vi||0)):r={a:1,b:0,c:0,d:1,e:u,f:h};var m="matrix(".concat(r.a,",").concat(r.b,",").concat(r.c,",").concat(r.d,",").concat(r.e,",").concat(r.f,")");f(b,"webkitTransform",m),f(b,"mozTransform",m),f(b,"msTransform",m),f(b,"transform",m),gi=u,vi=h,Q=s}t.cancelable&&t.preventDefault()}},_appendGhost:function(){if(!b){var t=this.options.fallbackOnBody?document.body:D,e=$(p,!0,He,!0,t),i=this.options;if(He){for(N=t;f(N,"position")==="static"&&f(N,"transform")==="none"&&N!==document;)N=N.parentNode;N!==document.body&&N!==document.documentElement?(N===document&&(N=ot()),e.top+=N.scrollTop,e.left+=N.scrollLeft):N=ot(),wi=po(N)}b=p.cloneNode(!0),B(b,i.ghostClass,!1),B(b,i.fallbackClass,!0),B(b,i.dragClass,!0),f(b,"transition",""),f(b,"transform",""),f(b,"box-sizing","border-box"),f(b,"margin",0),f(b,"top",e.top),f(b,"left",e.left),f(b,"width",e.width),f(b,"height",e.height),f(b,"opacity","0.8"),f(b,"position",He?"absolute":"fixed"),f(b,"zIndex","100000"),f(b,"pointerEvents","none"),v.ghost=b,t.appendChild(b),f(b,"transform-origin",fo/parseInt(b.style.width)*100+"% "+go/parseInt(b.style.height)*100+"%")}},_onDragStart:function(t,e){var i=this,o=t.dataTransfer,s=i.options;if(V("dragStart",this,{evt:t}),v.eventCanceled){this._onDrop();return}V("setupClone",this),v.eventCanceled||(M=Mi(p),M.removeAttribute("id"),M.draggable=!1,M.style["will-change"]="",this._hideClone(),B(M,this.options.chosenClass,!1),v.clone=M),i.cloneId=Fe(function(){V("clone",i),!v.eventCanceled&&(i.options.removeCloneOnHide||D.insertBefore(M,p),i._hideClone(),q({sortable:i,name:"clone"}))}),!e&&B(p,s.dragClass,!0),e?(Ve=!0,i._loopId=setInterval(i._emulateDragOver,50)):(y(document,"mouseup",i._onDrop),y(document,"touchend",i._onDrop),y(document,"touchcancel",i._onDrop),o&&(o.effectAllowed="move",s.setData&&s.setData.call(i,o,p)),E(document,"drop",i),f(p,"transform","translateZ(0)")),_t=!0,i._dragStartId=Fe(i._dragStarted.bind(i,e,t)),E(document,"selectstart",i),oe=!0,window.getSelection().removeAllRanges(),ae&&f(document.body,"user-select","none")},_onDragOver:function(t){var e=this.el,i=t.target,o,s,r,a=this.options,l=a.group,c=v.active,u=Ae===l,h=a.sort,m=O||c,g,C=this,T=!1;if(Li)return;function F(Jt,Ls){V(Jt,C,st({evt:t,isOwner:u,axis:g?"vertical":"horizontal",revert:r,dragRect:o,targetRect:s,canSort:h,fromSortable:m,target:i,completed:x,onMove:function(Gi,Ts){return Be(D,e,p,o,Gi,$(Gi),t,Ts)},changed:S},Ls))}function Y(){F("dragOverAnimationCapture"),C.captureAnimationState(),C!==m&&m.captureAnimationState()}function x(Jt){return F("dragOverCompleted",{insertion:Jt}),Jt&&(u?c._hideClone():c._showClone(C),C!==m&&(B(p,O?O.options.ghostClass:c.options.ghostClass,!1),B(p,a.ghostClass,!0)),O!==C&&C!==v.active?O=C:C===v.active&&O&&(O=null),m===C&&(C._ignoreWhileAnimating=i),C.animateAll(function(){F("dragOverAnimationComplete"),C._ignoreWhileAnimating=null}),C!==m&&(m.animateAll(),m._ignoreWhileAnimating=null)),(i===p&&!p.animated||i===e&&!i.animated)&&(Rt=null),!a.dragoverBubble&&!t.rootEl&&i!==document&&(p.parentNode[_]._isOutsideThisEl(t.target),!Jt&&kt(t)),!a.dragoverBubble&&t.stopPropagation&&t.stopPropagation(),T=!0}function S(){G=P(p),wt=P(p,a.draggable),q({sortable:C,name:"change",toEl:e,newIndex:G,newDraggableIndex:wt,originalEvent:t})}if(t.preventDefault!==void 0&&t.cancelable&&t.preventDefault(),i=j(i,a.draggable,e,!0),F("dragOver"),v.eventCanceled)return T;if(p.contains(t.target)||i.animated&&i.animatingX&&i.animatingY||C._ignoreWhileAnimating===i)return x(!1);if(Ve=!1,c&&!a.disabled&&(u?h||(r=I!==D):O===this||(this.lastPutMode=Ae.checkPull(this,c,p,t))&&l.checkPut(this,c,p,t))){if(g=this._getDirection(t,i)==="vertical",o=$(p),F("dragOverValid"),v.eventCanceled)return T;if(r)return I=D,Y(),this._hideClone(),F("revert"),v.eventCanceled||($t?D.insertBefore(p,$t):D.appendChild(p)),x(!0);var R=Di(e,a.draggable);if(!R||tr(t,g,this)&&!R.animated){if(R===p)return x(!1);if(R&&e===t.target&&(i=R),i&&(s=$(i)),Be(D,e,p,o,i,s,t,!!i)!==!1)return Y(),R&&R.nextSibling?e.insertBefore(p,R.nextSibling):e.appendChild(p),I=e,S(),x(!0)}else if(R&&Qs(t,g,this)){var at=Ft(e,0,a,!0);if(at===p)return x(!1);if(i=at,s=$(i),Be(D,e,p,o,i,s,t,!1)!==!1)return Y(),e.insertBefore(p,at),I=e,S(),x(!0)}else if(i.parentNode===e){s=$(i);var J=0,Et,Kt=p.parentNode!==e,K=!Xs(p.animated&&p.toRect||o,i.animated&&i.toRect||s,g),Xt=g?"top":"left",ut=uo(i,"top","top")||uo(p,"top","top"),Gt=ut?ut.scrollTop:void 0;Rt!==i&&(Et=s[Xt],he=!1,Ie=!K&&a.invertSwap||Kt),J=er(t,i,s,g,K?1:a.swapThreshold,a.invertedSwapThreshold==null?a.swapThreshold:a.invertedSwapThreshold,Ie,Rt===i);var lt;if(J!==0){var Ct=P(p);do Ct-=J,lt=I.children[Ct];while(lt&&(f(lt,"display")==="none"||lt===b))}if(J===0||lt===i)return x(!1);Rt=i,de=J;var Yt=i.nextElementSibling,pt=!1;pt=J===1;var ge=Be(D,e,p,o,i,s,t,pt);if(ge!==!1)return(ge===1||ge===-1)&&(pt=ge===1),Li=!0,setTimeout(Zs,30),Y(),pt&&!Yt?e.appendChild(p):i.parentNode.insertBefore(p,pt?Yt:i),ut&&To(ut,0,Gt-ut.scrollTop),I=p.parentNode,Et!==void 0&&!Ie&&(Ne=Math.abs(Et-$(i)[Xt])),S(),x(!0)}if(e.contains(p))return x(!1)}return!1},_ignoreWhileAnimating:null,_offMoveEvents:function(){y(document,"mousemove",this._onTouchMove),y(document,"touchmove",this._onTouchMove),y(document,"pointermove",this._onTouchMove),y(document,"dragover",kt),y(document,"mousemove",kt),y(document,"touchmove",kt)},_offUpEvents:function(){var t=this.el.ownerDocument;y(t,"mouseup",this._onDrop),y(t,"touchend",this._onDrop),y(t,"pointerup",this._onDrop),y(t,"pointercancel",this._onDrop),y(t,"touchcancel",this._onDrop),y(document,"selectstart",this)},_onDrop:function(t){var e=this.el,i=this.options;if(G=P(p),wt=P(p,i.draggable),V("drop",this,{evt:t}),I=p&&p.parentNode,G=P(p),wt=P(p,i.draggable),v.eventCanceled){this._nulling();return}_t=!1,Ie=!1,he=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),Ti(this.cloneId),Ti(this._dragStartId),this.nativeDraggable&&(y(document,"drop",this),y(e,"dragstart",this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),ae&&f(document.body,"user-select",""),f(p,"transform",""),t&&(oe&&(t.cancelable&&t.preventDefault(),!i.dropBubble&&t.stopPropagation()),b&&b.parentNode&&b.parentNode.removeChild(b),(D===I||O&&O.lastPutMode!=="clone")&&M&&M.parentNode&&M.parentNode.removeChild(M),p&&(this.nativeDraggable&&y(p,"dragend",this),bi(p),p.style["will-change"]="",oe&&!_t&&B(p,O?O.options.ghostClass:this.options.ghostClass,!1),B(p,this.options.chosenClass,!1),q({sortable:this,name:"unchoose",toEl:I,newIndex:null,newDraggableIndex:null,originalEvent:t}),D!==I?(G>=0&&(q({rootEl:I,name:"add",toEl:I,fromEl:D,originalEvent:t}),q({sortable:this,name:"remove",toEl:I,originalEvent:t}),q({rootEl:I,name:"sort",toEl:I,fromEl:D,originalEvent:t}),q({sortable:this,name:"sort",toEl:I,originalEvent:t})),O&&O.save()):G!==Nt&&G>=0&&(q({sortable:this,name:"update",toEl:I,originalEvent:t}),q({sortable:this,name:"sort",toEl:I,originalEvent:t})),v.active&&((G==null||G===-1)&&(G=Nt,wt=ce),q({sortable:this,name:"end",toEl:I,originalEvent:t}),this.save()))),this._nulling()},_nulling:function(){V("nulling",this),D=p=I=b=$t=M=_e=bt=St=Q=oe=G=wt=Nt=ce=Rt=de=O=Ae=v.dragged=v.ghost=v.clone=v.active=null,je.forEach(function(t){t.checked=!0}),je.length=gi=vi=0},handleEvent:function(t){switch(t.type){case"drop":case"dragend":this._onDrop(t);break;case"dragenter":case"dragover":p&&(this._onDragOver(t),Js(t));break;case"selectstart":t.preventDefault();break}},toArray:function(){for(var t=[],e,i=this.el.children,o=0,s=i.length,r=this.options;o<s;o++)e=i[o],j(e,r.draggable,this.el,!1)&&t.push(e.getAttribute(r.dataIdAttr)||ir(e));return t},sort:function(t,e){var i={},o=this.el;this.toArray().forEach(function(s,r){var a=o.children[r];j(a,this.options.draggable,o,!1)&&(i[s]=a)},this),e&&this.captureAnimationState(),t.forEach(function(s){i[s]&&(o.removeChild(i[s]),o.appendChild(i[s]))}),e&&this.animateAll()},save:function(){var t=this.options.store;t&&t.set&&t.set(this)},closest:function(t,e){return j(t,e||this.options.draggable,this.el,!1)},option:function(t,e){var i=this.options;if(e===void 0)return i[t];var o=pe.modifyOption(this,t,e);typeof o<"u"?i[t]=o:i[t]=e,t==="group"&&Do(i)},destroy:function(){V("destroy",this);var t=this.el;t[_]=null,y(t,"mousedown",this._onTapStart),y(t,"touchstart",this._onTapStart),y(t,"pointerdown",this._onTapStart),this.nativeDraggable&&(y(t,"dragover",this),y(t,"dragenter",this)),Array.prototype.forEach.call(t.querySelectorAll("[draggable]"),function(e){e.removeAttribute("draggable")}),this._onDrop(),this._disableDelayedDragEvents(),We.splice(We.indexOf(this.el),1),this.el=t=null},_hideClone:function(){if(!bt){if(V("hideClone",this),v.eventCanceled)return;f(M,"display","none"),this.options.removeCloneOnHide&&M.parentNode&&M.parentNode.removeChild(M),bt=!0}},_showClone:function(t){if(t.lastPutMode!=="clone"){this._hideClone();return}if(bt){if(V("showClone",this),v.eventCanceled)return;p.parentNode==D&&!this.options.group.revertClone?D.insertBefore(M,p):$t?D.insertBefore(M,$t):D.appendChild(M),this.options.group.revertClone&&this.animate(p,M),f(M,"display",""),bt=!1}}};function Js(n){n.dataTransfer&&(n.dataTransfer.dropEffect="move"),n.cancelable&&n.preventDefault()}function Be(n,t,e,i,o,s,r,a){var l,c=n[_],u=c.options.onMove,h;return window.CustomEvent&&!dt&&!ue?l=new CustomEvent("move",{bubbles:!0,cancelable:!0}):(l=document.createEvent("Event"),l.initEvent("move",!0,!0)),l.to=t,l.from=n,l.dragged=e,l.draggedRect=i,l.related=o||t,l.relatedRect=s||$(t),l.willInsertAfter=a,l.originalEvent=r,n.dispatchEvent(l),u&&(h=u.call(c,l,r)),h}function bi(n){n.draggable=!1}function Zs(){Li=!1}function Qs(n,t,e){var i=$(Ft(e.el,0,e.options,!0)),o=So(e.el,e.options,b),s=10;return t?n.clientX<o.left-s||n.clientY<i.top&&n.clientX<i.right:n.clientY<o.top-s||n.clientY<i.bottom&&n.clientX<i.left}function tr(n,t,e){var i=$(Di(e.el,e.options.draggable)),o=So(e.el,e.options,b),s=10;return t?n.clientX>o.right+s||n.clientY>i.bottom&&n.clientX>i.left:n.clientY>o.bottom+s||n.clientX>i.right&&n.clientY>i.top}function er(n,t,e,i,o,s,r,a){var l=i?n.clientY:n.clientX,c=i?e.height:e.width,u=i?e.top:e.left,h=i?e.bottom:e.right,m=!1;if(!r){if(a&&Ne<c*o){if(!he&&(de===1?l>u+c*s/2:l<h-c*s/2)&&(he=!0),he)m=!0;else if(de===1?l<u+Ne:l>h-Ne)return-de}else if(l>u+c*(1-o)/2&&l<h-c*(1-o)/2)return nr(t)}return m=m||r,m&&(l<u+c*s/2||l>h-c*s/2)?l>u+c/2?1:-1:0}function nr(n){return P(p)<P(n)?1:-1}function ir(n){for(var t=n.tagName+n.className+n.src+n.href+n.textContent,e=t.length,i=0;e--;)i+=t.charCodeAt(e);return i.toString(36)}function or(n){je.length=0;for(var t=n.getElementsByTagName("input"),e=t.length;e--;){var i=t[e];i.checked&&je.push(i)}}function Fe(n){return setTimeout(n,0)}function Ti(n){return clearTimeout(n)}Ke&&E(document,"touchmove",function(n){(v.active||_t)&&n.cancelable&&n.preventDefault()});v.utils={on:E,off:y,css:f,find:xo,is:function(t,e){return!!j(t,e,t,!1)},extend:qs,throttle:Lo,closest:j,toggleClass:B,clone:Mi,index:P,nextTick:Fe,cancelNextTick:Ti,detectDirection:$o,getChild:Ft,expando:_};v.get=function(n){return n[_]};v.mount=function(){for(var n=arguments.length,t=new Array(n),e=0;e<n;e++)t[e]=arguments[e];t[0].constructor===Array&&(t=t[0]),t.forEach(function(i){if(!i.prototype||!i.prototype.constructor)throw"Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(i));i.utils&&(v.utils=st(st({},v.utils),i.utils)),pe.mount(i)})};v.create=function(n,t){return new v(n,t)};v.version=Ns;var H=[],se,Si,ki=!1,yi,Ei,ze,re;function sr(){function n(){this.defaults={scroll:!0,forceAutoScrollFallback:!1,scrollSensitivity:30,scrollSpeed:10,bubbleScroll:!0};for(var t in this)t.charAt(0)==="_"&&typeof this[t]=="function"&&(this[t]=this[t].bind(this))}return n.prototype={dragStarted:function(e){var i=e.originalEvent;this.sortable.nativeDraggable?E(document,"dragover",this._handleAutoScroll):this.options.supportPointer?E(document,"pointermove",this._handleFallbackAutoScroll):i.touches?E(document,"touchmove",this._handleFallbackAutoScroll):E(document,"mousemove",this._handleFallbackAutoScroll)},dragOverCompleted:function(e){var i=e.originalEvent;!this.options.dragOverBubble&&!i.rootEl&&this._handleAutoScroll(i)},drop:function(){this.sortable.nativeDraggable?y(document,"dragover",this._handleAutoScroll):(y(document,"pointermove",this._handleFallbackAutoScroll),y(document,"touchmove",this._handleFallbackAutoScroll),y(document,"mousemove",this._handleFallbackAutoScroll)),wo(),qe(),Us()},nulling:function(){ze=Si=se=ki=re=yi=Ei=null,H.length=0},_handleFallbackAutoScroll:function(e){this._handleAutoScroll(e,!0)},_handleAutoScroll:function(e,i){var o=this,s=(e.touches?e.touches[0]:e).clientX,r=(e.touches?e.touches[0]:e).clientY,a=document.elementFromPoint(s,r);if(ze=e,i||this.options.forceAutoScrollFallback||ue||dt||ae){Ci(e,this.options,a,i);var l=yt(a,!0);ki&&(!re||s!==yi||r!==Ei)&&(re&&wo(),re=setInterval(function(){var c=yt(document.elementFromPoint(s,r),!0);c!==l&&(l=c,qe()),Ci(e,o.options,c,i)},10),yi=s,Ei=r)}else{if(!this.options.bubbleScroll||yt(a,!0)===ot()){qe();return}Ci(e,this.options,yt(a,!1),!1)}}},et(n,{pluginName:"scroll",initializeByDefault:!0})}function qe(){H.forEach(function(n){clearInterval(n.pid)}),H=[]}function wo(){clearInterval(re)}var Ci=Lo(function(n,t,e,i){if(t.scroll){var o=(n.touches?n.touches[0]:n).clientX,s=(n.touches?n.touches[0]:n).clientY,r=t.scrollSensitivity,a=t.scrollSpeed,l=ot(),c=!1,u;Si!==e&&(Si=e,qe(),se=t.scroll,u=t.scrollFn,se===!0&&(se=yt(e,!0)));var h=0,m=se;do{var g=m,C=$(g),T=C.top,F=C.bottom,Y=C.left,x=C.right,S=C.width,R=C.height,at=void 0,J=void 0,Et=g.scrollWidth,Kt=g.scrollHeight,K=f(g),Xt=g.scrollLeft,ut=g.scrollTop;g===l?(at=S<Et&&(K.overflowX==="auto"||K.overflowX==="scroll"||K.overflowX==="visible"),J=R<Kt&&(K.overflowY==="auto"||K.overflowY==="scroll"||K.overflowY==="visible")):(at=S<Et&&(K.overflowX==="auto"||K.overflowX==="scroll"),J=R<Kt&&(K.overflowY==="auto"||K.overflowY==="scroll"));var Gt=at&&(Math.abs(x-o)<=r&&Xt+S<Et)-(Math.abs(Y-o)<=r&&!!Xt),lt=J&&(Math.abs(F-s)<=r&&ut+R<Kt)-(Math.abs(T-s)<=r&&!!ut);if(!H[h])for(var Ct=0;Ct<=h;Ct++)H[Ct]||(H[Ct]={});(H[h].vx!=Gt||H[h].vy!=lt||H[h].el!==g)&&(H[h].el=g,H[h].vx=Gt,H[h].vy=lt,clearInterval(H[h].pid),(Gt!=0||lt!=0)&&(c=!0,H[h].pid=setInterval(function(){i&&this.layer===0&&v.active._onTouchMove(ze);var Yt=H[this.layer].vy?H[this.layer].vy*a:0,pt=H[this.layer].vx?H[this.layer].vx*a:0;typeof u=="function"&&u.call(v.dragged.parentNode[_],pt,Yt,n,ze,H[this.layer].el)!=="continue"||To(H[this.layer].el,pt,Yt)}.bind({layer:h}),24))),h++}while(t.bubbleScroll&&m!==l&&(m=yt(m,!1)));ki=c}},30),Io=function(t){var e=t.originalEvent,i=t.putSortable,o=t.dragEl,s=t.activeSortable,r=t.dispatchSortableEvent,a=t.hideGhostForTarget,l=t.unhideGhostForTarget;if(e){var c=i||s;a();var u=e.changedTouches&&e.changedTouches.length?e.changedTouches[0]:e,h=document.elementFromPoint(u.clientX,u.clientY);l(),c&&!c.el.contains(h)&&(r("spill"),this.onSpill({dragEl:o,putSortable:i}))}};function Ai(){}Ai.prototype={startIndex:null,dragStart:function(t){var e=t.oldDraggableIndex;this.startIndex=e},onSpill:function(t){var e=t.dragEl,i=t.putSortable;this.sortable.captureAnimationState(),i&&i.captureAnimationState();var o=Ft(this.sortable.el,this.startIndex,this.options);o?this.sortable.el.insertBefore(e,o):this.sortable.el.appendChild(e),this.sortable.animateAll(),i&&i.animateAll()},drop:Io};et(Ai,{pluginName:"revertOnSpill"});function Ii(){}Ii.prototype={onSpill:function(t){var e=t.dragEl,i=t.putSortable,o=i||this.sortable;o.captureAnimationState(),e.parentNode&&e.parentNode.removeChild(e),o.animateAll()},drop:Io};et(Ii,{pluginName:"removeOnSpill"});var w=[],X=[],te,tt,ee=!1,W=!1,Ot=!1,k,ne,Pe;function Ho(){function n(t){for(var e in this)e.charAt(0)==="_"&&typeof this[e]=="function"&&(this[e]=this[e].bind(this));t.options.avoidImplicitDeselect||(t.options.supportPointer?E(document,"pointerup",this._deselectMultiDrag):(E(document,"mouseup",this._deselectMultiDrag),E(document,"touchend",this._deselectMultiDrag))),E(document,"keydown",this._checkKeyDown),E(document,"keyup",this._checkKeyUp),this.defaults={selectedClass:"sortable-selected",multiDragKey:null,avoidImplicitDeselect:!1,setData:function(o,s){var r="";w.length&&tt===t?w.forEach(function(a,l){r+=(l?", ":"")+a.textContent}):r=s.textContent,o.setData("Text",r)}}}return n.prototype={multiDragKeyDown:!1,isMultiDrag:!1,delayStartGlobal:function(e){var i=e.dragEl;k=i},delayEnded:function(){this.isMultiDrag=~w.indexOf(k)},setupClone:function(e){var i=e.sortable,o=e.cancel;if(this.isMultiDrag){for(var s=0;s<w.length;s++)X.push(Mi(w[s])),X[s].sortableIndex=w[s].sortableIndex,X[s].draggable=!1,X[s].style["will-change"]="",B(X[s],this.options.selectedClass,!1),w[s]===k&&B(X[s],this.options.chosenClass,!1);i._hideClone(),o()}},clone:function(e){var i=e.sortable,o=e.rootEl,s=e.dispatchSortableEvent,r=e.cancel;this.isMultiDrag&&(this.options.removeCloneOnHide||w.length&&tt===i&&(bo(!0,o),s("clone"),r()))},showClone:function(e){var i=e.cloneNowShown,o=e.rootEl,s=e.cancel;this.isMultiDrag&&(bo(!1,o),X.forEach(function(r){f(r,"display","")}),i(),Pe=!1,s())},hideClone:function(e){var i=this,o=e.sortable,s=e.cloneNowHidden,r=e.cancel;this.isMultiDrag&&(X.forEach(function(a){f(a,"display","none"),i.options.removeCloneOnHide&&a.parentNode&&a.parentNode.removeChild(a)}),s(),Pe=!0,r())},dragStartGlobal:function(e){var i=e.sortable;!this.isMultiDrag&&tt&&tt.multiDrag._deselectMultiDrag(),w.forEach(function(o){o.sortableIndex=P(o)}),w=w.sort(function(o,s){return o.sortableIndex-s.sortableIndex}),Ot=!0},dragStarted:function(e){var i=this,o=e.sortable;if(this.isMultiDrag){if(this.options.sort&&(o.captureAnimationState(),this.options.animation)){w.forEach(function(r){r!==k&&f(r,"position","absolute")});var s=$(k,!1,!0,!0);w.forEach(function(r){r!==k&&mo(r,s)}),W=!0,ee=!0}o.animateAll(function(){W=!1,ee=!1,i.options.animation&&w.forEach(function(r){mi(r)}),i.options.sort&&Re()})}},dragOver:function(e){var i=e.target,o=e.completed,s=e.cancel;W&&~w.indexOf(i)&&(o(!1),s())},revert:function(e){var i=e.fromSortable,o=e.rootEl,s=e.sortable,r=e.dragRect;w.length>1&&(w.forEach(function(a){s.addAnimationState({target:a,rect:W?$(a):r}),mi(a),a.fromRect=r,i.removeAnimationState(a)}),W=!1,rr(!this.options.removeCloneOnHide,o))},dragOverCompleted:function(e){var i=e.sortable,o=e.isOwner,s=e.insertion,r=e.activeSortable,a=e.parentEl,l=e.putSortable,c=this.options;if(s){if(o&&r._hideClone(),ee=!1,c.animation&&w.length>1&&(W||!o&&!r.options.sort&&!l)){var u=$(k,!1,!0,!0);w.forEach(function(m){m!==k&&(mo(m,u),a.appendChild(m))}),W=!0}if(!o)if(W||Re(),w.length>1){var h=Pe;r._showClone(i),r.options.animation&&!Pe&&h&&X.forEach(function(m){r.addAnimationState({target:m,rect:ne}),m.fromRect=ne,m.thisAnimationDuration=null})}else r._showClone(i)}},dragOverAnimationCapture:function(e){var i=e.dragRect,o=e.isOwner,s=e.activeSortable;if(w.forEach(function(a){a.thisAnimationDuration=null}),s.options.animation&&!o&&s.multiDrag.isMultiDrag){ne=et({},i);var r=Dt(k,!0);ne.top-=r.f,ne.left-=r.e}},dragOverAnimationComplete:function(){W&&(W=!1,Re())},drop:function(e){var i=e.originalEvent,o=e.rootEl,s=e.parentEl,r=e.sortable,a=e.dispatchSortableEvent,l=e.oldIndex,c=e.putSortable,u=c||this.sortable;if(i){var h=this.options,m=s.children;if(!Ot)if(h.multiDragKey&&!this.multiDragKeyDown&&this._deselectMultiDrag(),B(k,h.selectedClass,!~w.indexOf(k)),~w.indexOf(k))w.splice(w.indexOf(k),1),te=null,ie({sortable:r,rootEl:o,name:"deselect",targetEl:k,originalEvent:i});else{if(w.push(k),ie({sortable:r,rootEl:o,name:"select",targetEl:k,originalEvent:i}),i.shiftKey&&te&&r.el.contains(te)){var g=P(te),C=P(k);~g&&~C&&g!==C&&function(){var x,S;C>g?(S=g,x=C):(S=C,x=g+1);for(var R=h.filter;S<x;S++)if(!~w.indexOf(m[S])&&j(m[S],h.draggable,s,!1)){var at=R&&(typeof R=="function"?R.call(r,i,m[S],r):R.split(",").some(function(J){return j(m[S],J.trim(),s,!1)}));at||(B(m[S],h.selectedClass,!0),w.push(m[S]),ie({sortable:r,rootEl:o,name:"select",targetEl:m[S],originalEvent:i}))}}()}else te=k;tt=u}if(Ot&&this.isMultiDrag){if(W=!1,(s[_].options.sort||s!==o)&&w.length>1){var T=$(k),F=P(k,":not(."+this.options.selectedClass+")");if(!ee&&h.animation&&(k.thisAnimationDuration=null),u.captureAnimationState(),!ee&&(h.animation&&(k.fromRect=T,w.forEach(function(x){if(x.thisAnimationDuration=null,x!==k){var S=W?$(x):T;x.fromRect=S,u.addAnimationState({target:x,rect:S})}})),Re(),w.forEach(function(x){m[F]?s.insertBefore(x,m[F]):s.appendChild(x),F++}),l===P(k))){var Y=!1;w.forEach(function(x){if(x.sortableIndex!==P(x)){Y=!0;return}}),Y&&(a("update"),a("sort"))}w.forEach(function(x){mi(x)}),u.animateAll()}tt=u}(o===s||c&&c.lastPutMode!=="clone")&&X.forEach(function(x){x.parentNode&&x.parentNode.removeChild(x)})}},nullingGlobal:function(){this.isMultiDrag=Ot=!1,X.length=0},destroyGlobal:function(){this._deselectMultiDrag(),y(document,"pointerup",this._deselectMultiDrag),y(document,"mouseup",this._deselectMultiDrag),y(document,"touchend",this._deselectMultiDrag),y(document,"keydown",this._checkKeyDown),y(document,"keyup",this._checkKeyUp)},_deselectMultiDrag:function(e){if(!(typeof Ot<"u"&&Ot)&&tt===this.sortable&&!(e&&j(e.target,this.options.draggable,this.sortable.el,!1))&&!(e&&e.button!==0))for(;w.length;){var i=w[0];B(i,this.options.selectedClass,!1),w.shift(),ie({sortable:this.sortable,rootEl:this.sortable.el,name:"deselect",targetEl:i,originalEvent:e})}},_checkKeyDown:function(e){e.key===this.options.multiDragKey&&(this.multiDragKeyDown=!0)},_checkKeyUp:function(e){e.key===this.options.multiDragKey&&(this.multiDragKeyDown=!1)}},et(n,{pluginName:"multiDrag",utils:{select:function(e){var i=e.parentNode[_];!i||!i.options.multiDrag||~w.indexOf(e)||(tt&&tt!==i&&(tt.multiDrag._deselectMultiDrag(),tt=i),B(e,i.options.selectedClass,!0),w.push(e))},deselect:function(e){var i=e.parentNode[_],o=w.indexOf(e);!i||!i.options.multiDrag||!~o||(B(e,i.options.selectedClass,!1),w.splice(o,1))}},eventProperties:function(){var e=this,i=[],o=[];return w.forEach(function(s){i.push({multiDragElement:s,index:s.sortableIndex});var r;W&&s!==k?r=-1:W?r=P(s,":not(."+e.options.selectedClass+")"):r=P(s),o.push({multiDragElement:s,index:r})}),{items:Bs(w),clones:[].concat(X),oldIndicies:i,newIndicies:o}},optionListeners:{multiDragKey:function(e){return e=e.toLowerCase(),e==="ctrl"?e="Control":e.length>1&&(e=e.charAt(0).toUpperCase()+e.substr(1)),e}}})}function rr(n,t){w.forEach(function(e,i){var o=t.children[e.sortableIndex+(n?Number(i):0)];o?t.insertBefore(e,o):t.appendChild(e)})}function bo(n,t){X.forEach(function(e,i){var o=t.children[e.sortableIndex+(n?Number(i):0)];o?t.insertBefore(e,o):t.appendChild(e)})}function Re(){w.forEach(function(n){n!==k&&n.parentNode&&n.parentNode.removeChild(n)})}v.mount(new sr);v.mount(Ii,Ai);var ht=v;var Bo={name(n,t){let e=n.getAttribute("data-name").trim().toLowerCase(),i=t.getAttribute("data-name").trim().toLowerCase();return e.localeCompare(i)},created(n,t){let e=Number(n.getAttribute("data-created"));return Number(t.getAttribute("data-created"))-e},updated(n,t){let e=Number(n.getAttribute("data-updated"));return Number(t.getAttribute("data-updated"))-e},chaptersFirst(n,t){let e=n.getAttribute("data-type"),i=t.getAttribute("data-type");return e===i?0:e==="chapter"?-1:1},chaptersLast(n,t){let e=n.getAttribute("data-type"),i=t.getAttribute("data-type");return e===i?0:e==="chapter"?1:-1}},Po={up:{active(n,t){return!(n.previousElementSibling===null&&!t)},run(n,t){(n.previousElementSibling||t).insertAdjacentElement("beforebegin",n)}},down:{active(n,t){return!(n.nextElementSibling===null&&!t)},run(n,t){(n.nextElementSibling||t).insertAdjacentElement("afterend",n)}},next_book:{active(n,t,e){return e.nextElementSibling!==null},run(n,t,e){e.nextElementSibling.querySelector("ul").prepend(n)}},prev_book:{active(n,t,e){return e.previousElementSibling!==null},run(n,t,e){e.previousElementSibling.querySelector("ul").appendChild(n)}},next_chapter:{active(n,t){return n.dataset.type==="page"&&this.getNextChapter(n,t)},run(n,t){this.getNextChapter(n,t).querySelector("ul").prepend(n)},getNextChapter(n,t){let e=t||n,i=Array.from(e.parentElement.children),o=i.indexOf(e);return i.slice(o+1).find(s=>s.dataset.type==="chapter")}},prev_chapter:{active(n,t){return n.dataset.type==="page"&&this.getPrevChapter(n,t)},run(n,t){this.getPrevChapter(n,t).querySelector("ul").append(n)},getPrevChapter(n,t){let e=t||n,i=Array.from(e.parentElement.children),o=i.indexOf(e);return i.slice(0,o).reverse().find(s=>s.dataset.type==="chapter")}},book_end:{active(n,t){return t||t===null&&n.nextElementSibling},run(n,t,e){e.querySelector("ul").append(n)}},book_start:{active(n,t){return t||t===null&&n.previousElementSibling},run(n,t,e){e.querySelector("ul").prepend(n)}},before_chapter:{active(n,t){return t},run(n,t){t.insertAdjacentElement("beforebegin",n)}},after_chapter:{active(n,t){return t},run(n,t){t.insertAdjacentElement("afterend",n)}}},Xe=class extends d{setup(){this.container=this.$el,this.sortContainer=this.$refs.sortContainer,this.input=this.$refs.input,ht.mount(new Ho);let t=this.container.querySelector(".sort-box");this.setupBookSortable(t),this.setupSortPresets(),this.setupMoveActions(),window.$events.listen("entity-select-change",this.bookSelect.bind(this))}setupMoveActions(){this.container.addEventListener("click",t=>{if(t.target.matches("[data-move]")){let e=t.target.getAttribute("data-move"),i=t.target.closest("[data-id]");this.runSortAction(i,e)}}),this.updateMoveActionStateForAll()}setupSortPresets(){let t="",e=!1,i=["name","created","updated"];this.sortContainer.addEventListener("click",o=>{let s=o.target.closest(".sort-box-options [data-sort]");if(!s)return;o.preventDefault();let r=s.closest(".sort-box").querySelectorAll("ul"),a=s.getAttribute("data-sort");e=t===a?!e:!1;let l=Bo[a];e&&i.includes(a)&&(l=function(u,h){return 0-Bo[a](u,h)});for(let c of r)Array.from(c.children).filter(h=>h.matches("li")).sort(l).forEach(h=>{c.appendChild(h)});t=a,this.updateMapInput()})}bookSelect(t){if(this.container.querySelector(`[data-type="book"][data-id="${t.id}"]`)!==null)return;let i=`${t.link}/sort-item`;window.$http.get(i).then(o=>{let s=Z(o.data);this.sortContainer.append(s),this.setupBookSortable(s),this.updateMoveActionStateForAll(),s.querySelector("summary").focus()})}setupBookSortable(t){let e=Array.from(t.querySelectorAll(".sort-list, .sortable-page-sublist")),i={name:"book",pull:["book","chapter"],put:["book","chapter"]},o={name:"chapter",pull:["book","chapter"],put(s,r,a){return a.getAttribute("data-type")==="page"}};for(let s of e)ht.create(s,{group:s.classList.contains("sort-list")?i:o,animation:150,fallbackOnBody:!0,swapThreshold:.65,onSort:()=>{this.ensureNoNestedChapters(),this.updateMapInput(),this.updateMoveActionStateForAll()},dragClass:"bg-white",ghostClass:"primary-background-light",multiDrag:!0,multiDragKey:"Control",selectedClass:"sortable-selected"})}ensureNoNestedChapters(){let t=this.container.querySelectorAll('[data-type="chapter"] [data-type="chapter"]');for(let e of t)e.parentElement.closest('[data-type="chapter"]').insertAdjacentElement("afterend",e)}updateMapInput(){let t=this.buildEntityMap();this.input.value=JSON.stringify(t)}buildEntityMap(){let t=[],e=this.container.querySelectorAll(".sort-list");for(let i of e){let o=i.closest('[data-type="book"]').getAttribute("data-id"),s=Array.from(i.children).filter(r=>r.matches('[data-type="page"], [data-type="chapter"]'));for(let r=0;r<s.length;r++)this.addBookChildToMap(s[r],r,o,t)}return t}addBookChildToMap(t,e,i,o){let s=t.getAttribute("data-type"),r=!1,a=t.getAttribute("data-id");o.push({id:a,sort:e,parentChapter:r,type:s,book:i});let l=t.querySelectorAll('[data-type="page"]');for(let c=0;c<l.length;c++)o.push({id:l[c].getAttribute("data-id"),sort:c,parentChapter:a,type:"page",book:i})}runSortAction(t,e){let i=t.parentElement.closest("li[data-id]"),o=t.parentElement.closest('[data-type="book"]');Po[e].run(t,i,o),this.updateMapInput(),this.updateMoveActionStateForAll(),t.scrollIntoView({behavior:"smooth",block:"nearest"}),t.focus()}updateMoveActionState(t){let e=t.parentElement.closest("li[data-id]"),i=t.parentElement.closest('[data-type="book"]');for(let[o,s]of Object.entries(Po)){let r=t.querySelector(`[data-move="${o}"]`);r.disabled=!s.active(t,e,i)}}updateMoveActionStateForAll(){let t=this.container.querySelectorAll('[data-type="chapter"],[data-type="page"]');for(let e of t)this.updateMoveActionState(e)}};var Ge=new WeakMap;function me(n,t,e=400,i=null){let o=Object.keys(t);for(let r of o)n.style.setProperty(r,t[r][0]);let s=()=>{for(let r of o)n.style.removeProperty(r);n.style.removeProperty("transition"),n.removeEventListener("transitionend",s),Ge.delete(n),i&&i()};setTimeout(()=>{n.style.transition=`all ease-in-out ${e}ms`;for(let r of o)n.style.setProperty(r,t[r][1]);n.addEventListener("transitionend",s),Ge.set(n,s)},15)}function fe(n){Ge.has(n)&&Ge.get(n)()}function Ro(n,t=400,e=null){fe(n),n.style.display="block",me(n,{opacity:["0","1"]},t,()=>{e&&e()})}function Oo(n,t=400,e=null){fe(n),me(n,{opacity:["1","0"]},t,()=>{n.style.display="none",e&&e()})}function qt(n,t=400){fe(n);let e=n.getBoundingClientRect().height,i=getComputedStyle(n),o=i.getPropertyValue("padding-top"),s=i.getPropertyValue("padding-bottom"),r={"max-height":[`${e}px`,"0px"],overflow:["hidden","hidden"],"padding-top":[o,"0px"],"padding-bottom":[s,"0px"]};me(n,r,t,()=>{n.style.display="none"})}function Ut(n,t=400){fe(n),n.style.display="block";let e=n.getBoundingClientRect().height,i=getComputedStyle(n),o=i.getPropertyValue("padding-top"),s=i.getPropertyValue("padding-bottom"),r={"max-height":["0px",`${e}px`],overflow:["hidden","hidden"],"padding-top":["0px",o],"padding-bottom":["0px",s]};me(n,r,t)}function _o(n,t=400){let e=n.getBoundingClientRect().height,i=getComputedStyle(n),o=i.getPropertyValue("padding-top"),s=i.getPropertyValue("padding-bottom");return()=>{fe(n);let r=n.getBoundingClientRect().height,a=getComputedStyle(n),l=a.getPropertyValue("padding-top"),c=a.getPropertyValue("padding-bottom"),u={height:[`${e}px`,`${r}px`],overflow:["hidden","hidden"],"padding-top":[o,l],"padding-bottom":[s,c]};me(n,u,t)}}var Ye=class extends d{setup(){this.list=this.$refs.list,this.toggle=this.$refs.toggle,this.isOpen=this.toggle.classList.contains("open"),this.toggle.addEventListener("click",this.click.bind(this))}open(){this.toggle.classList.add("open"),this.toggle.setAttribute("aria-expanded","true"),Ut(this.list,180),this.isOpen=!0}close(){this.toggle.classList.remove("open"),this.toggle.setAttribute("aria-expanded","false"),qt(this.list,180),this.isOpen=!1}click(t){t.preventDefault(),this.isOpen?this.close():this.open()}};var Je=class extends d{constructor(){super(...arguments);U(this,"editor",null);U(this,"saveCallback",null);U(this,"cancelCallback",null);U(this,"history",{});U(this,"historyKey","code_history")}setup(){this.container=this.$refs.container,this.popup=this.$el,this.editorInput=this.$refs.editor,this.languageButtons=this.$manyRefs.languageButton,this.languageOptionsContainer=this.$refs.languageOptionsContainer,this.saveButton=this.$refs.saveButton,this.languageInput=this.$refs.languageInput,this.historyDropDown=this.$refs.historyDropDown,this.historyList=this.$refs.historyList,this.favourites=new Set(this.$opts.favourites.split(",")),this.setupListeners(),this.setupFavourites()}setupListeners(){this.container.addEventListener("keydown",e=>{e.ctrlKey&&e.key==="Enter"&&this.save()}),L(this.languageButtons,e=>{let i=e.target.dataset.lang;this.languageInput.value=i,this.languageInputChange(i)}),Ht(this.languageInput,()=>this.save()),this.languageInput.addEventListener("input",()=>this.languageInputChange(this.languageInput.value)),L(this.saveButton,()=>this.save()),A(this.historyList,"button","click",(e,i)=>{e.preventDefault();let o=i.dataset.time;this.editor&&this.editor.setContent(this.history[o])})}setupFavourites(){for(let e of this.languageButtons)this.setupFavouritesForButton(e);this.sortLanguageList()}setupFavouritesForButton(e){let i=e.dataset.lang,o=this.favourites.has(i);e.setAttribute("data-favourite",o?"true":"false"),A(e.parentElement,".lang-option-favorite-toggle","click",()=>{o=!o,o?this.favourites.add(i):this.favourites.delete(i),e.setAttribute("data-favourite",o?"true":"false"),window.$http.patch("/preferences/update-code-language-favourite",{language:i,active:o}),this.sortLanguageList(),o&&e.scrollIntoView({block:"center",behavior:"smooth"})})}sortLanguageList(){let e=this.languageButtons.sort((i,o)=>{let s=i.dataset.favourite==="true",r=o.dataset.favourite==="true";return s&&!r?-1:r&&!s||i.dataset.lang>o.dataset.lang?1:-1}).map(i=>i.parentElement);for(let i of e)this.languageOptionsContainer.append(i)}save(){this.saveCallback&&this.saveCallback(this.editor.getContent(),this.languageInput.value),this.hide()}async open(e,i,o,s,r){this.languageInput.value=i,this.saveCallback=s,this.cancelCallback=r,await this.show(),this.languageInputChange(i),this.editor.setContent(e),this.setDirection(o)}async show(){let e=await window.importVersioned("code");this.editor||(this.editor=e.popupEditor(this.editorInput,this.languageInput.value)),this.loadHistory(),this.getPopup().show(()=>{this.editor.focus()},()=>{this.addHistory(),this.cancelCallback&&this.cancelCallback()})}setDirection(e){let i=this.editorInput.parentElement;e?i.setAttribute("dir",e):i.removeAttribute("dir")}hide(){this.getPopup().hide(),this.addHistory()}getPopup(){return window.$components.firstOnElement(this.popup,"popup")}async updateEditorMode(e){this.editor.setMode(e,this.editor.getContent())}languageInputChange(e){this.updateEditorMode(e);let i=e.toLowerCase();for(let o of this.languageButtons){let s=o.dataset.lang.toLowerCase().trim(),r=i===s;o.classList.toggle("active",r),r&&o.scrollIntoView({block:"center",behavior:"smooth"})}}loadHistory(){this.history=JSON.parse(window.sessionStorage.getItem(this.historyKey)||"{}");let e=Object.keys(this.history).reverse();this.historyDropDown.classList.toggle("hidden",e.length===0),this.historyList.innerHTML=e.map(i=>{let o=new Date(parseInt(i,10)).toLocaleTimeString();return`<li><button type="button" data-time="${i}" class="text-item">${o}</button></li>`}).join("")}addHistory(){if(!this.editor)return;let e=this.editor.getContent();if(!e)return;let i=Object.keys(this.history).pop();if(this.history[i]===e)return;this.history[String(Date.now())]=e;let o=JSON.stringify(this.history);window.sessionStorage.setItem(this.historyKey,o)}};var Ze=class extends d{setup(){let t=this.$el;t.querySelectorAll("pre").length>0&&window.importVersioned("code").then(i=>{i.highlightWithin(t)})}};var Qe=class extends d{async setup(){let{mode:t}=this.$opts;(await window.importVersioned("code")).inlineEditor(this.$el,t)}};var tn=class extends d{setup(){this.container=this.$el,this.trigger=this.$refs.trigger,this.content=this.$refs.content,this.trigger&&(this.trigger.addEventListener("click",this.toggle.bind(this)),this.openIfContainsError())}open(){this.container.classList.add("open"),this.trigger.setAttribute("aria-expanded","true"),Ut(this.content,300)}close(){this.container.classList.remove("open"),this.trigger.setAttribute("aria-expanded","false"),qt(this.content,300)}toggle(){this.container.classList.contains("open")?this.close():this.open()}openIfContainsError(){this.content.querySelector(".text-neg.text-small")&&this.open()}};var en=class extends d{setup(){this.container=this.$el,this.confirmButton=this.$refs.confirm,this.res=null,L(this.confirmButton,()=>{this.sendResult(!0),this.getPopup().hide()})}show(){return this.getPopup().show(null,()=>{this.sendResult(!1)}),new Promise(t=>{this.res=t})}getPopup(){return window.$components.firstOnElement(this.container,"popup")}sendResult(t){this.res&&(this.res(t),this.res=null)}};var nn=class extends d{setup(){this.container=this.$el,this.checkbox=this.container.querySelector("input[type=checkbox]"),this.display=this.container.querySelector('[role="checkbox"]'),this.checkbox.addEventListener("change",this.stateChange.bind(this)),this.container.addEventListener("keydown",this.onKeyDown.bind(this))}onKeyDown(t){(t.key===" "||t.key==="Enter")&&(t.preventDefault(),this.toggle())}toggle(){this.checkbox.checked=!this.checkbox.checked,this.checkbox.dispatchEvent(new Event("change")),this.stateChange()}stateChange(){let t=this.checkbox.checked?"true":"false";this.display.setAttribute("aria-checked",t)}};var on=class extends d{setup(){this.container=this.$el,this.dealtWith=!1,this.container.addEventListener("toggle",this.onToggle.bind(this))}onToggle(){this.dealtWith||(this.container.querySelector("pre")&&window.importVersioned("code").then(t=>{t.highlightWithin(this.container)}),this.dealtWith=!0)}};var sn=class extends d{setup(){this.container=this.$el,this.menu=this.$refs.menu,this.toggle=this.$refs.toggle,this.moveMenu=this.$opts.moveMenu,this.bubbleEscapes=this.$opts.bubbleEscapes==="true",this.direction=document.dir==="rtl"?"right":"left",this.body=document.body,this.showing=!1,this.hide=this.hide.bind(this),this.setupListeners()}show(t=null){this.hideAll(),this.menu.style.display="block",this.menu.classList.add("anim","menuIn"),this.toggle.setAttribute("aria-expanded","true");let e=this.menu.getBoundingClientRect(),i=0,o=this.toggle.getBoundingClientRect().height,s=e.bottom>window.innerHeight,r=this.container.getBoundingClientRect();if(this.moveMenu&&(this.body.appendChild(this.menu),this.menu.style.position="fixed",this.menu.style.width=`${e.width}px`,this.menu.style.left=`${e.left}px`,s?i=window.innerHeight-e.top-o/2:i=e.top),s){this.menu.style.top="initial",this.menu.style.bottom=`${i}px`;let c=window.innerHeight-40-(window.innerHeight-r.bottom);this.menu.style.maxHeight=`${Math.floor(c)}px`}else{this.menu.style.top=`${i}px`,this.menu.style.bottom="initial";let c=window.innerHeight-40-r.top;this.menu.style.maxHeight=`${Math.floor(c)}px`}this.menu.addEventListener("mouseleave",this.hide),window.addEventListener("click",c=>{this.menu.contains(c.target)||this.hide()});let a=this.menu.querySelector("input");a!==null&&a.focus(),this.showing=!0;let l=new Event("show");this.container.dispatchEvent(l),t&&t.stopPropagation()}hideAll(){for(let t of window.$components.get("dropdown"))t.hide()}hide(){this.menu.style.display="none",this.menu.classList.remove("anim","menuIn"),this.toggle.setAttribute("aria-expanded","false"),this.menu.style.top="",this.menu.style.bottom="",this.menu.style.maxHeight="",this.moveMenu&&(this.menu.style.position="",this.menu.style[this.direction]="",this.menu.style.width="",this.menu.style.left="",this.container.appendChild(this.menu)),this.showing=!1}setupListeners(){let t=new gt(this.container,e=>{this.hide(),this.toggle.focus(),this.bubbleEscapes||e.stopPropagation()},e=>{e.target.nodeName==="INPUT"&&(e.preventDefault(),e.stopPropagation()),this.hide()});this.moveMenu&&t.shareHandlingToEl(this.menu),this.container.addEventListener("click",e=>{Array.from(this.menu.querySelectorAll("a")).includes(e.target)&&this.hide()}),L(this.toggle,e=>{e.stopPropagation(),e.preventDefault(),this.show(e),e instanceof KeyboardEvent&&t.focusNext()})}};var rn=class extends d{setup(){this.elem=this.$el,this.searchInput=this.$refs.searchInput,this.loadingElem=this.$refs.loading,this.listContainerElem=this.$refs.listContainer,this.localSearchSelector=this.$opts.localSearchSelector,this.url=this.$opts.url,this.elem.addEventListener("show",this.onShow.bind(this)),this.searchInput.addEventListener("input",this.onSearch.bind(this)),this.runAjaxSearch=mt(this.runAjaxSearch,300,!1)}onShow(){this.loadList()}onSearch(){let t=this.searchInput.value.toLowerCase().trim();this.localSearchSelector?this.runLocalSearch(t):(this.toggleLoading(!0),this.listContainerElem.innerHTML="",this.runAjaxSearch(t))}runAjaxSearch(t){this.loadList(t)}runLocalSearch(t){let e=this.listContainerElem.querySelectorAll(this.localSearchSelector);for(let i of e){let o=!t||i.textContent.toLowerCase().includes(t);i.style.display=o?"flex":"none",i.classList.toggle("hidden",!o)}}async loadList(t=""){this.listContainerElem.innerHTML="",this.toggleLoading(!0);try{let e=await window.$http.get(this.getAjaxUrl(t)),i=_o(this.listContainerElem,80);this.listContainerElem.innerHTML=e.data,i()}catch(e){console.error(e)}this.toggleLoading(!1),this.localSearchSelector&&this.onSearch()}getAjaxUrl(t=null){if(!t)return this.url;let e=this.url.includes("?")?"&":"?";return`${this.url}${e}search=${encodeURIComponent(t)}`}toggleLoading(t=!1){this.loadingElem.style.display=t?"block":"none"}};var Vt=class{constructor(t){this.data=t}hasItems(){return!!this.data&&!!this.data.types&&this.data.types.length>0}containsTabularData(){let t=this.data.getData("text/rtf");return!!t&&t.includes("\\trowd")}getImages(){return this.getFiles().filter(t=>t.type.includes("image"))}getFiles(){let{files:t}=this.data;return[...t]}};async function Hi(n){if(window.isSecureContext&&navigator.clipboard){await navigator.clipboard.writeText(n);return}let t=document.createElement("textarea");t.setAttribute("style","position: absolute; left: -1000px; top: -1000px;"),t.value=n,document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}var an=class extends d{setup(){this.container=this.$el,this.statusArea=this.$refs.statusArea,this.dropTarget=this.$refs.dropTarget,this.selectButtons=this.$manyRefs.selectButton||[],this.isActive=!0,this.url=this.$opts.url,this.method=(this.$opts.method||"post").toUpperCase(),this.successMessage=this.$opts.successMessage,this.errorMessage=this.$opts.errorMessage,this.uploadLimitMb=Number(this.$opts.uploadLimit),this.uploadLimitMessage=this.$opts.uploadLimitMessage,this.zoneText=this.$opts.zoneText,this.fileAcceptTypes=this.$opts.fileAccept,this.allowMultiple=this.$opts.allowMultiple==="true",this.setupListeners()}toggleActive(t){this.isActive=t}setupListeners(){L(this.selectButtons,this.manualSelectHandler.bind(this)),this.setupDropTargetHandlers()}setupDropTargetHandlers(){let t=0,e=()=>{this.hideOverlay(),t=0};this.dropTarget.addEventListener("dragenter",i=>{i.preventDefault(),t+=1,t===1&&this.isActive&&this.showOverlay()}),this.dropTarget.addEventListener("dragover",i=>{i.preventDefault()}),this.dropTarget.addEventListener("dragend",e),this.dropTarget.addEventListener("dragleave",()=>{t-=1,t===0&&e()}),this.dropTarget.addEventListener("drop",i=>{if(i.preventDefault(),e(),!this.isActive)return;let s=new Vt(i.dataTransfer).getFiles();for(let r of s)this.createUploadFromFile(r)})}manualSelectHandler(){let t=it("input",{type:"file",style:"left: -400px; visibility: hidden; position: fixed;",accept:this.fileAcceptTypes,multiple:this.allowMultiple?"":null});this.container.append(t),t.click(),t.addEventListener("change",()=>{for(let e of t.files)this.createUploadFromFile(e);t.remove()})}showOverlay(){if(!this.dropTarget.querySelector(".dropzone-overlay")){let e=it("div",{class:"dropzone-overlay"},[this.zoneText]);this.dropTarget.append(e)}}hideOverlay(){let t=this.dropTarget.querySelector(".dropzone-overlay");t&&t.remove()}createUploadFromFile(t){let{dom:e,status:i,progress:o,dismiss:s}=this.createDomForFile(t);this.statusArea.append(e);let r=this,a={file:t,dom:e,updateProgress(l){o.textContent=`${l}%`,o.style.width=`${l}%`},markError(l){i.setAttribute("data-status","error"),i.textContent=l,Qt(e),this.updateProgress(100)},markSuccess(l){i.setAttribute("data-status","success"),i.textContent=l,Qt(e),setTimeout(s,2400),r.$emit("upload-success",{name:t.name})}};return t.size>this.uploadLimitMb*1e6?(a.markError(this.uploadLimitMessage),a):(this.startXhrForUpload(a),a)}startXhrForUpload(t){let e=new FormData;e.append("file",t.file,t.file.name),this.method!=="POST"&&e.append("_method",this.method);let i=this,o=window.$http.createXMLHttpRequest("POST",this.url,{error(){t.markError(i.errorMessage)},readystatechange(){this.readyState===XMLHttpRequest.DONE&&this.status===200?t.markSuccess(i.successMessage):this.readyState===XMLHttpRequest.DONE&&this.status>=400&&t.markError(window.$http.formatErrorResponseText(this.responseText))}});o.upload.addEventListener("progress",s=>{let r=Math.min(Math.ceil(s.loaded/s.total*100),100);t.updateProgress(r)}),o.setRequestHeader("Accept","application/json"),o.send(e)}createDomForFile(t){let e=it("img",{src:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9.224 7.373a.924.924 0 0 0-.92.925l-.006 7.404c0 .509.412.925.921.925h5.557a.928.928 0 0 0 .926-.925v-5.553l-2.777-2.776Zm3.239 3.239V8.067l2.545 2.545z' style='fill:%23000;fill-opacity:.75'/%3E%3C/svg%3E"}),i=it("div",{class:"dropzone-file-item-status"},[]),o=it("div",{class:"dropzone-file-item-progress"}),s=it("div",{class:"dropzone-file-item-image-wrap"},[e]),r=it("div",{class:"dropzone-file-item"},[s,it("div",{class:"dropzone-file-item-text-wrap"},[it("div",{class:"dropzone-file-item-label"},[t.name]),Bt(),i]),o]);t.type.startsWith("image/")&&(e.src=URL.createObjectURL(t));let a=()=>{r.classList.add("dismiss"),r.addEventListener("animationend",()=>{r.remove()})};return r.addEventListener("click",a),{dom:r,progress:o,status:i,dismiss:a}}};var ln=class extends d{constructor(){super(...arguments);this.open=!1;this.tab=""}setup(){this.container=this.$el,this.buttons=this.$manyRefs.tabButton,this.contentElements=this.$manyRefs.tabContent,this.toggleButton=this.$refs.toggle,this.editorWrapEl=this.container.closest(".page-editor"),this.setupListeners(),this.setActiveTab(this.contentElements[0].dataset.tabContent||"")}setupListeners(){this.toggleButton.addEventListener("click",()=>this.toggle()),this.container.addEventListener("click",e=>{let i=e.target.closest("button");if(i instanceof HTMLButtonElement&&this.buttons.includes(i)){let o=i.dataset.tab||"";this.setActiveTab(o,!0)}})}toggle(){this.container.classList.toggle("open");let e=this.container.classList.contains("open");this.toggleButton.setAttribute("aria-expanded",e?"true":"false"),this.editorWrapEl.classList.toggle("toolbox-open",e),this.open=e,this.emitState()}setActiveTab(e,i=!1){for(let o of this.buttons)o.classList.remove("active"),o.dataset.tab===e&&o.classList.add("active");for(let o of this.contentElements)o.style.display="none",o.dataset.tabContent===e&&(o.style.display="block");i&&!this.container.classList.contains("open")&&this.toggle(),this.tab=e,this.emitState()}emitState(){let e={tab:this.tab,open:this.open};this.$emit("change",e)}};var cn=class extends d{setup(){this.container=this.$el,this.entityType=this.$opts.entityType,this.everyoneInheritToggle=this.$refs.everyoneInherit,this.roleSelect=this.$refs.roleSelect,this.roleContainer=this.$refs.roleContainer,this.setupListeners()}setupListeners(){this.everyoneInheritToggle.addEventListener("change",t=>{let e=t.target.checked,i=document.querySelectorAll('input[name^="permissions[0]["]');for(let o of i)o.disabled=e,o.checked=!1}),this.container.addEventListener("click",t=>{let e=t.target.closest("button");e&&e.dataset.roleId&&this.removeRowOnButtonClick(e)}),this.roleSelect.addEventListener("change",()=>{let t=this.roleSelect.value;t&&this.addRoleRow(t)})}async addRoleRow(t){this.roleSelect.disabled=!0;let e=this.roleSelect.querySelector(`option[value="${t}"]`);e&&e.remove();let i=await window.$http.get(`/permissions/form-row/${this.entityType}/${t}`),o=Z(i.data);this.roleContainer.append(o),this.roleSelect.disabled=!1}removeRowOnButtonClick(t){let e=t.closest(".item-list-row"),{roleId:i}=t.dataset,{roleName:o}=t.dataset,s=document.createElement("option");s.value=i,s.textContent=o,this.roleSelect.append(s),e.remove()}};var dn=class extends d{setup(){this.entityId=this.$opts.entityId,this.entityType=this.$opts.entityType,this.contentView=this.$refs.contentView,this.searchView=this.$refs.searchView,this.searchResults=this.$refs.searchResults,this.searchInput=this.$refs.searchInput,this.searchForm=this.$refs.searchForm,this.clearButton=this.$refs.clearButton,this.loadingBlock=this.$refs.loadingBlock,this.setupListeners()}setupListeners(){this.searchInput.addEventListener("change",this.runSearch.bind(this)),this.searchForm.addEventListener("submit",t=>{t.preventDefault(),this.runSearch()}),L(this.clearButton,this.clearSearch.bind(this))}runSearch(){let t=this.searchInput.value.trim();if(t.length===0){this.clearSearch();return}this.searchView.classList.remove("hidden"),this.contentView.classList.add("hidden"),this.loadingBlock.classList.remove("hidden");let e=window.baseUrl(`/search/${this.entityType}/${this.entityId}`);window.$http.get(e,{term:t}).then(i=>{this.searchResults.innerHTML=i.data}).catch(console.error).then(()=>{this.loadingBlock.classList.add("hidden")})}clearSearch(){this.searchView.classList.add("hidden"),this.contentView.classList.remove("hidden"),this.loadingBlock.classList.add("hidden"),this.searchInput.value=""}};var hn=class extends d{setup(){this.elem=this.$el,this.input=this.$refs.input,this.searchInput=this.$refs.search,this.loading=this.$refs.loading,this.resultsContainer=this.$refs.results,this.searchOptions={entityTypes:this.$opts.entityTypes||"page,book,chapter",entityPermission:this.$opts.entityPermission||"view",searchEndpoint:this.$opts.searchEndpoint||"",initialValue:this.searchInput.value||""},this.search="",this.lastClick=0,this.setupListeners(),this.showLoading(),this.searchOptions.searchEndpoint&&this.initialLoad()}configureSearchOptions(t){Object.assign(this.searchOptions,t),this.reset(),this.searchInput.value=this.searchOptions.initialValue}setupListeners(){this.elem.addEventListener("click",this.onClick.bind(this));let t=0;this.searchInput.addEventListener("input",()=>{t=Date.now(),this.showLoading(),setTimeout(()=>{Date.now()-t<199||this.searchEntities(this.searchInput.value)},200)}),this.searchInput.addEventListener("keydown",e=>{e.keyCode===13&&e.preventDefault()}),A(this.$el,"[data-entity-type]","keydown",e=>{if(e.ctrlKey&&e.code==="Enter"){let i=this.$el.closest("form");if(i){i.submit(),e.preventDefault();return}}e.code==="ArrowDown"&&this.focusAdjacent(!0),e.code==="ArrowUp"&&this.focusAdjacent(!1)}),this.searchInput.addEventListener("keydown",e=>{e.code==="ArrowDown"&&this.focusAdjacent(!0)})}focusAdjacent(t=!0){let e=Array.from(this.resultsContainer.querySelectorAll("[data-entity-type]")),i=e.indexOf(document.activeElement),o=e[i+(t?1:-1)]||e[0];o&&o.focus()}reset(){this.searchInput.value="",this.showLoading(),this.initialLoad()}focusSearch(){this.searchInput.focus()}showLoading(){this.loading.style.display="block",this.resultsContainer.style.display="none"}hideLoading(){this.loading.style.display="none",this.resultsContainer.style.display="block"}initialLoad(){if(!this.searchOptions.searchEndpoint)throw new Error("Search endpoint not set for entity-selector load");if(this.searchOptions.initialValue){this.searchEntities(this.searchOptions.initialValue);return}window.$http.get(this.searchUrl()).then(t=>{this.resultsContainer.innerHTML=t.data,this.hideLoading()})}searchUrl(){let t=`types=${encodeURIComponent(this.searchOptions.entityTypes)}&permission=${encodeURIComponent(this.searchOptions.entityPermission)}`;return`${this.searchOptions.searchEndpoint}?${t}`}searchEntities(t){if(!this.searchOptions.searchEndpoint)throw new Error("Search endpoint not set for entity-selector load");this.input.value="";let e=`${this.searchUrl()}&term=${encodeURIComponent(t)}`;window.$http.get(e).then(i=>{this.resultsContainer.innerHTML=i.data,this.hideLoading()})}isDoubleClick(){let t=Date.now(),e=t-this.lastClick<300;return this.lastClick=t,e}onClick(t){let e=t.target.closest("[data-entity-type]");e&&(t.preventDefault(),t.stopPropagation(),this.selectItem(e))}selectItem(t){let e=this.isDoubleClick(),i=t.getAttribute("data-entity-type"),o=t.getAttribute("data-entity-id"),s=!t.classList.contains("selected")||e;this.unselectAll(),this.input.value=s?`${i}:${o}`:"";let r=t.getAttribute("href"),a=t.querySelector(".entity-list-item-name").textContent,l={id:Number(o),name:a,link:r};s?t.classList.add("selected"):window.$events.emit("entity-select-change",null),!(!e&&!s)&&(e&&this.confirmSelection(l),s&&window.$events.emit("entity-select-change",l))}confirmSelection(t){window.$events.emit("entity-select-confirm",t)}unselectAll(){let t=this.elem.querySelectorAll(".selected");for(let e of t)e.classList.remove("selected","primary-background")}};var un=class extends d{setup(){this.container=this.$el,this.selectButton=this.$refs.select,this.selectorEl=this.$refs.selector,this.callback=null,this.selection=null,this.selectButton.addEventListener("click",this.onSelectButtonClick.bind(this)),window.$events.listen("entity-select-change",this.onSelectionChange.bind(this)),window.$events.listen("entity-select-confirm",this.handleConfirmedSelection.bind(this))}show(t,e={}){this.callback=t,this.getSelector().configureSearchOptions(e),this.getPopup().show(),this.getSelector().focusSearch()}hide(){this.getPopup().hide()}getPopup(){return window.$components.firstOnElement(this.container,"popup")}getSelector(){return window.$components.firstOnElement(this.selectorEl,"entity-selector")}onSelectButtonClick(){this.handleConfirmedSelection(this.selection)}onSelectionChange(t){this.selection=t,t===null?this.selectButton.setAttribute("disabled","true"):this.selectButton.removeAttribute("disabled")}handleConfirmedSelection(t){this.hide(),this.getSelector().reset(),this.callback&&t&&this.callback(t)}};var pn=class extends d{setup(){this.container=this.$el,this.name=this.$opts.name,L(this.$el,()=>{this.$emit(this.name,this.$opts)})}};var mn=class extends d{setup(){this.targetSelector=this.$opts.targetSelector,this.isOpen=this.$opts.isOpen==="true",this.updateEndpoint=this.$opts.updateEndpoint,this.$el.addEventListener("click",this.click.bind(this))}open(t){Ut(t,200)}close(t){qt(t,200)}click(t){t.preventDefault();let e=document.querySelectorAll(this.targetSelector);for(let i of e)(this.isOpen?this.close:this.open)(i);this.isOpen=!this.isOpen,this.updateSystemAjax(this.isOpen)}updateSystemAjax(t){window.$http.patch(this.updateEndpoint,{expand:t?"true":"false"})}};var fn=class extends d{setup(){this.container=this.$el,this.input=this.$refs.input,this.suggestions=this.$refs.suggestions,this.suggestionResultsWrap=this.$refs.suggestionResults,this.loadingWrap=this.$refs.loading,this.button=this.$refs.button,this.setupListeners()}setupListeners(){let t=mt(this.updateSuggestions.bind(this),200,!1);this.input.addEventListener("input",()=>{let{value:e}=this.input;e.length>0?(this.loadingWrap.style.display="block",this.suggestionResultsWrap.style.opacity="0.5",t(e)):this.hideSuggestions()}),this.input.addEventListener("dblclick",()=>{this.input.setAttribute("autocomplete","on"),this.button.focus(),this.input.focus()}),new gt(this.container,()=>{this.hideSuggestions()})}async updateSuggestions(t){let{data:e}=await window.$http.get("/search/suggest",{term:t});if(!this.input.value)return;let i=Z(e);this.suggestionResultsWrap.innerHTML="",this.suggestionResultsWrap.style.opacity="1",this.loadingWrap.style.display="none",this.suggestionResultsWrap.append(i),this.container.classList.contains("search-active")||this.showSuggestions()}showSuggestions(){this.container.classList.add("search-active"),window.requestAnimationFrame(()=>{this.suggestions.classList.add("search-suggestions-animation")})}hideSuggestions(){this.container.classList.remove("search-active"),this.suggestions.classList.remove("search-suggestions-animation"),this.suggestionResultsWrap.innerHTML=""}};var gn=class extends d{setup(){this.elem=this.$el,this.toggleButton=this.$refs.toggle,this.menu=this.$refs.menu,this.open=!1,this.toggleButton.addEventListener("click",this.onToggle.bind(this)),this.onWindowClick=this.onWindowClick.bind(this),this.onKeyDown=this.onKeyDown.bind(this)}onToggle(t){this.open=!this.open,this.menu.classList.toggle("show",this.open),this.toggleButton.setAttribute("aria-expanded",this.open?"true":"false"),this.open?(this.elem.addEventListener("keydown",this.onKeyDown),window.addEventListener("click",this.onWindowClick)):(this.elem.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("click",this.onWindowClick)),t.stopPropagation()}onKeyDown(t){t.code==="Escape"&&this.onToggle(t)}onWindowClick(t){this.onToggle(t)}};var vn=class extends d{setup(){this.uploadedTo=this.$opts.uploadedTo,this.container=this.$el,this.popupEl=this.$refs.popup,this.searchForm=this.$refs.searchForm,this.searchInput=this.$refs.searchInput,this.cancelSearch=this.$refs.cancelSearch,this.listContainer=this.$refs.listContainer,this.filterTabs=this.$manyRefs.filterTabs,this.selectButton=this.$refs.selectButton,this.uploadButton=this.$refs.uploadButton,this.uploadHint=this.$refs.uploadHint,this.formContainer=this.$refs.formContainer,this.formContainerPlaceholder=this.$refs.formContainerPlaceholder,this.dropzoneContainer=this.$refs.dropzoneContainer,this.loadMore=this.$refs.loadMore,this.type="gallery",this.lastSelected={},this.lastSelectedTime=0,this.callback=null,this.resetState=()=>{this.hasData=!1,this.page=1,this.filter="all"},this.resetState(),this.setupListeners()}setupListeners(){L(this.filterTabs,i=>{this.resetAll(),this.filter=i.target.dataset.filter,this.setActiveFilterTab(this.filter),this.loadGallery()}),this.searchForm.addEventListener("submit",i=>{this.resetListView(),this.loadGallery(),this.cancelSearch.toggleAttribute("hidden",!this.searchInput.value),i.preventDefault()}),L(this.cancelSearch,()=>{this.resetListView(),this.resetSearchView(),this.loadGallery()}),A(this.container,".load-more button","click",this.runLoadMore.bind(this)),this.listContainer.addEventListener("event-emit-select-image",this.onImageSelectEvent.bind(this)),this.listContainer.addEventListener("error",i=>{i.target.src=window.baseUrl("loading_error.png")},!0),L(this.selectButton,()=>{this.callback&&this.callback(this.lastSelected),this.hide()}),A(this.formContainer,"#image-manager-delete","click",()=>{this.lastSelected&&this.loadImageEditForm(this.lastSelected.id,!0)}),A(this.formContainer,"#image-manager-rebuild-thumbs","click",async(i,o)=>{o.disabled=!0,this.lastSelected&&await this.rebuildThumbnails(this.lastSelected.id),o.disabled=!1}),this.formContainer.addEventListener("ajax-form-success",()=>{this.refreshGallery(),this.resetEditForm()}),this.container.addEventListener("dropzone-upload-success",this.refreshGallery.bind(this));let t=this.listContainer.parentElement,e=[];t.addEventListener("wheel",i=>{if(!(Math.ceil(t.scrollHeight-t.scrollTop)===t.clientHeight)||i.deltaY<1)return;let r=Date.now()-1e3;e.push(Date.now()),e=e.filter(a=>a>=r),e.length>5&&this.canLoadMore()&&this.runLoadMore()})}show(t,e="gallery"){this.resetAll(),this.callback=t,this.type=e,this.getPopup().show();let i=e!=="gallery";this.dropzoneContainer.classList.toggle("hidden",i),this.uploadButton.classList.toggle("hidden",i),this.uploadHint.classList.toggle("hidden",i),window.$components.firstOnElement(this.container,"dropzone").toggleActive(!i),this.hasData||(this.loadGallery(),this.hasData=!0)}hide(){this.getPopup().hide()}getPopup(){return window.$components.firstOnElement(this.popupEl,"popup")}async loadGallery(){let t={page:this.page,search:this.searchInput.value||null,uploaded_to:this.uploadedTo,filter_type:this.filter==="all"?null:this.filter},{data:e}=await window.$http.get(`images/${this.type}`,t);t.page===1&&(this.listContainer.innerHTML=""),this.addReturnedHtmlElementsToList(e),Qt(this.listContainer)}addReturnedHtmlElementsToList(t){let e=document.createElement("div");e.innerHTML=t;let i=e.querySelector(".load-more");i&&(i.remove(),this.loadMore.innerHTML=i.innerHTML),this.loadMore.toggleAttribute("hidden",!i),window.$components.init(e);for(let o of[...e.children])this.listContainer.appendChild(o)}setActiveFilterTab(t){for(let e of this.filterTabs){let i=e.dataset.filter===t;e.setAttribute("aria-selected",i?"true":"false")}}resetAll(){this.resetState(),this.resetListView(),this.resetSearchView(),this.resetEditForm(),this.setActiveFilterTab("all"),this.selectButton.classList.add("hidden")}resetSearchView(){this.searchInput.value="",this.cancelSearch.toggleAttribute("hidden",!0)}resetEditForm(){this.formContainer.innerHTML="",this.formContainerPlaceholder.removeAttribute("hidden")}resetListView(){Tt(this.listContainer),this.page=1}refreshGallery(){this.resetListView(),this.loadGallery()}async onImageSelectEvent(t){let e=JSON.parse(t.detail.data),i=e&&e.id===this.lastSelected.id&&Date.now()-this.lastSelectedTime<400,o=t.target.classList.contains("selected");[...this.listContainer.querySelectorAll(".selected")].forEach(s=>{s.classList.remove("selected")}),!o&&!i?(t.target.classList.add("selected"),e=await this.loadImageEditForm(e.id)):i?i&&(e=this.lastSelected):this.resetEditForm(),this.selectButton.classList.toggle("hidden",o),i&&this.callback&&(this.callback(e),this.hide()),this.lastSelected=e,this.lastSelectedTime=Date.now()}async loadImageEditForm(t,e=!1){e||(this.formContainer.innerHTML="");let i=e?{delete:!0}:{},{data:o}=await window.$http.get(`/images/edit/${t}`,i);this.formContainer.innerHTML=o,this.formContainerPlaceholder.setAttribute("hidden",""),window.$components.init(this.formContainer);let s=this.formContainer.querySelector("#image-manager-form-image-data");return JSON.parse(s.text)}runLoadMore(){Tt(this.loadMore),this.page+=1,this.loadGallery()}canLoadMore(){return this.loadMore.querySelector("button")&&!this.loadMore.hasAttribute("hidden")}async rebuildThumbnails(t){try{let e=await window.$http.put(`/images/${t}/rebuild-thumbnails`);window.$events.success(e.data),this.refreshGallery()}catch(e){window.$events.showResponseError(e)}}};var wn=class extends d{setup(){this.imageElem=this.$refs.image,this.imageInput=this.$refs.imageInput,this.resetInput=this.$refs.resetInput,this.removeInput=this.$refs.removeInput,this.resetButton=this.$refs.resetButton,this.removeButton=this.$refs.removeButton||null,this.defaultImage=this.$opts.defaultImage,this.setupListeners()}setupListeners(){this.resetButton.addEventListener("click",this.reset.bind(this)),this.removeButton&&this.removeButton.addEventListener("click",this.removeImage.bind(this)),this.imageInput.addEventListener("change",this.fileInputChange.bind(this))}fileInputChange(){this.resetInput.setAttribute("disabled","disabled"),this.removeInput&&this.removeInput.setAttribute("disabled","disabled");for(let t of this.imageInput.files)this.imageElem.src=window.URL.createObjectURL(t);this.imageElem.classList.remove("none")}reset(){this.imageInput.value="",this.imageElem.src=this.defaultImage,this.resetInput.removeAttribute("disabled"),this.removeInput&&this.removeInput.setAttribute("disabled","disabled"),this.imageElem.classList.remove("none")}removeImage(){this.imageInput.value="",this.imageElem.classList.add("none"),this.removeInput.removeAttribute("disabled"),this.resetInput.setAttribute("disabled","disabled")}};var bn=class extends d{setup(){this.elem=this.$el,this.menu=this.$refs.menu,this.sortInput=this.$refs.sort,this.orderInput=this.$refs.order,this.form=this.$refs.form,this.setupListeners()}setupListeners(){this.menu.addEventListener("click",t=>{t.target.closest("[data-sort-value]")!==null&&this.sortOptionClick(t)}),this.elem.addEventListener("click",t=>{t.target.closest("[data-sort-dir]")!==null&&this.sortDirectionClick(t)})}sortOptionClick(t){let e=t.target.closest("[data-sort-value]");this.sortInput.value=e.getAttribute("data-sort-value"),t.preventDefault(),this.form.submit()}sortDirectionClick(t){let e=this.orderInput.value;this.orderInput.value=e==="asc"?"desc":"asc",t.preventDefault(),this.form.submit()}};function rt(n,t={},e=[]){let i=document.createElement(n),o=Object.keys(t);for(let s of o)t[s]!==null&&i.setAttribute(s,t[s]);for(let s of e)typeof s=="string"?i.append(document.createTextNode(s)):i.append(s);return i}var yn=class extends d{constructor(){super(...arguments);this.loadingEl=null}setup(){this.button=this.$el;let e=this.button.form,i=()=>{setTimeout(()=>this.showLoadingState(),10)};this.button.addEventListener("click",i),e&&e.addEventListener("submit",i)}showLoadingState(){this.button.disabled=!0,this.loadingEl||(this.loadingEl=rt("div",{class:"inline block"}),Tt(this.loadingEl),this.button.after(this.loadingEl))}};var En=class extends d{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.display=this.$refs.display,this.input=this.$refs.input,this.divider=this.$refs.divider,this.displayWrap=this.$refs.displayWrap;let{settingContainer:t}=this.$refs,e=t.querySelectorAll('input[type="checkbox"]');this.editor=null,window.importVersioned("markdown").then(i=>i.init({pageId:this.pageId,container:this.elem,displayEl:this.display,inputEl:this.input,drawioUrl:this.getDrawioUrl(),settingInputs:Array.from(e),text:{serverUploadLimit:this.serverUploadLimitText,imageUploadError:this.imageUploadErrorText}})).then(i=>{this.editor=i,this.setupListeners(),this.emitEditorEvents(),this.scrollToTextIfNeeded(),this.editor.actions.updateAndRender()})}emitEditorEvents(){window.$events.emitPublic(this.elem,"editor-markdown::setup",{markdownIt:this.editor.markdown.getRenderer(),displayEl:this.display,cmEditorView:this.editor.cm})}setupListeners(){this.elem.addEventListener("click",t=>{let e=t.target.closest("button[data-action]");if(e===null)return;let i=e.getAttribute("data-action");if(i==="insertImage"&&this.editor.actions.showImageInsert(),i==="insertLink"&&this.editor.actions.showLinkSelector(),i==="insertDrawing"&&(t.ctrlKey||t.metaKey)){this.editor.actions.showImageManager();return}i==="insertDrawing"&&this.editor.actions.startDrawing(),i==="fullscreen"&&this.editor.actions.fullScreen()}),this.elem.addEventListener("click",t=>{let e=t.target.closest(".editor-toolbar-label");if(!e)return;let i=this.elem.querySelectorAll(".markdown-editor-wrap");for(let o of i)o.classList.remove("active");e.closest(".markdown-editor-wrap").classList.add("active")}),this.handleDividerDrag()}handleDividerDrag(){this.divider.addEventListener("pointerdown",()=>{let e=this.elem.getBoundingClientRect(),i=s=>{let r=s.pageX-e.left,a=Math.min(Math.max(20,Math.floor(r/e.width*100)),80);this.displayWrap.style.flexBasis=`${100-a}%`,this.editor.settings.set("editorWidth",a)},o=()=>{window.removeEventListener("pointermove",i),window.removeEventListener("pointerup",o),this.display.style.pointerEvents=null,document.body.style.userSelect=null};this.display.style.pointerEvents="none",document.body.style.userSelect="none",window.addEventListener("pointermove",i),window.addEventListener("pointerup",o)});let t=this.editor.settings.get("editorWidth");t&&(this.displayWrap.style.flexBasis=`${100-t}%`)}scrollToTextIfNeeded(){let e=new URL(window.location).searchParams.get("content-text");e&&this.editor.actions.scrollToText(e)}getDrawioUrl(){let t=document.querySelector("[drawio-url]");return t&&t.getAttribute("drawio-url")||""}async getContent(){return this.editor.actions.getContent()}};var Cn=class extends d{setup(){this.container=this.$el,this.inputContainer=this.$refs.inputContainer,this.inviteOption=this.container.querySelector("input[name=send_invite]"),this.inviteOption&&(this.inviteOption.addEventListener("change",this.inviteOptionChange.bind(this)),this.inviteOptionChange())}inviteOptionChange(){let t=this.inviteOption.value==="true",e=this.container.querySelectorAll("input[type=password]");for(let i of e)i.disabled=t;this.inputContainer.style.display=t?"none":"block"}};var xn=class extends d{setup(){this.container=this.$el,this.type=this.$opts.type,this.textElem=this.container.querySelector("span"),this.autoHide=this.$opts.autoHide==="true",this.initialShow=this.$opts.show==="true",this.container.style.display="grid",window.$events.listen(this.type,t=>{this.show(t)}),this.container.addEventListener("click",this.hide.bind(this)),this.initialShow&&setTimeout(()=>this.show(this.textElem.textContent),100),this.hideCleanup=this.hideCleanup.bind(this)}show(t=""){if(this.container.removeEventListener("transitionend",this.hideCleanup),this.textElem.textContent=t,this.container.style.display="grid",setTimeout(()=>{this.container.classList.add("showing")},1),this.autoHide){let e=t.split(" ").length,i=Math.max(2e3,1e3+250*e);setTimeout(this.hide.bind(this),i)}}hide(){this.container.classList.remove("showing"),this.container.addEventListener("transitionend",this.hideCleanup)}hideCleanup(){this.container.style.display="none",this.container.removeEventListener("transitionend",this.hideCleanup)}};var Ln=class extends d{setup(){this.removeButton=this.$refs.remove,this.showButton=this.$refs.show,this.input=this.$refs.input,this.setupListeners()}setupListeners(){L(this.removeButton,()=>{this.input.value="",this.input.classList.add("hidden"),this.removeButton.classList.add("hidden"),this.showButton.classList.remove("hidden")}),L(this.showButton,()=>{this.input.classList.remove("hidden"),this.removeButton.classList.remove("hidden"),this.showButton.classList.add("hidden")})}};function No(n){for(let t=1;t<5;t++)n.shortcuts.add(`meta+${t}`,"",["FormatBlock",!1,`h${t+1}`]);n.shortcuts.add("meta+5","",["FormatBlock",!1,"p"]),n.shortcuts.add("meta+d","",["FormatBlock",!1,"p"]),n.shortcuts.add("meta+6","",["FormatBlock",!1,"blockquote"]),n.shortcuts.add("meta+q","",["FormatBlock",!1,"blockquote"]),n.shortcuts.add("meta+7","",["codeeditor",!1,"pre"]),n.shortcuts.add("meta+e","",["codeeditor",!1,"pre"]),n.shortcuts.add("meta+8","",["FormatBlock",!1,"code"]),n.shortcuts.add("meta+shift+E","",["FormatBlock",!1,"code"]),n.shortcuts.add("meta+o","","InsertOrderedList"),n.shortcuts.add("meta+p","","InsertUnorderedList"),n.shortcuts.add("meta+S","",()=>{window.$events.emit("editor-save-draft")}),n.shortcuts.add("meta+13","",()=>{window.$events.emit("editor-save-page")}),n.shortcuts.add("meta+9","",()=>{let t=n.selection.getNode(),e=t?t.closest(".callout"):null,i=["info","success","warning","danger"],s=(i.findIndex(a=>e&&e.classList.contains(a))+1)%i.length,r=i[s];n.formatter.apply(`callout${r}`)}),n.shortcuts.add("meta+shift+K","",()=>{let t=window.$components.first("entity-selector-popup"),e=n.selection.getContent({format:"text"}).trim();t.show(i=>{n.selection.isCollapsed()?n.insertContent(n.dom.createHTML("a",{href:i.link},n.dom.encode(i.name))):n.formatter.apply("link",{href:i.link}),n.selection.collapse(!1),n.focus()},{initialValue:e,searchEndpoint:"/search/entity-selector",entityTypes:"page,book,chapter,bookshelf",entityPermission:"view"})})}function Fo(n){window.$events.listen("editor::replace",({html:t})=>{n.setContent(t)}),window.$events.listen("editor::append",({html:t})=>{let e=n.getContent()+t;n.setContent(e)}),window.$events.listen("editor::prepend",({html:t})=>{let e=t+n.getContent();n.setContent(e)}),window.$events.listen("editor::insert",({html:t})=>{n.insertContent(t)}),window.$events.listen("editor::focus",()=>{n.initialized&&n.focus()})}function ar(n,t){let e=n.dom.get(encodeURIComponent(t).replace(/!/g,"%21"));e&&(e.scrollIntoView(),n.selection.select(e,!0),n.selection.collapse(!1),n.focus())}function qo(n){let e=new URL(window.location).searchParams.get("content-id");e&&ar(n,e)}var Mt,Tn;function lr(n){return n&&!!(n.textContent||n.innerText)}async function cr(n,t){if(n===null||n.type.indexOf("image")!==0)throw new Error("Not an image file");let e=n.name||`image-${Date.now()}.png`,i=new FormData;return i.append("file",n,e),i.append("uploaded_to",t),(await window.$http.post(window.baseUrl("/images/gallery"),i)).data}function Uo(n,t,e){let i=new Vt(e.clipboardData||e.dataTransfer);if(!i.hasItems()||i.containsTabularData())return;let o=i.getImages();for(let s of o){let r=`image-${Math.random().toString(16).slice(2)}`,a=window.baseUrl("/loading.gif");e.preventDefault(),setTimeout(()=>{n.insertContent(`<p><img src="${a}" id="${r}"></p>`),cr(s,t.pageId).then(l=>{let c=l.name.replace(/"/g,""),u=`<img src="${l.thumbs.display}" alt="${c}" />`,h=n.dom.create("a",{target:"_blank",href:l.url},u);n.dom.replace(h,r)}).catch(l=>{n.dom.remove(r),window.$events.error(l?.data?.message||t.translations.imageUploadErrorText),console.error(l)})},10)}}function dr(n){let t=n.selection.getNode();t.nodeName==="IMG"&&(Mt=n.dom.getParent(t,".mceTemp"),!Mt&&t.parentNode.nodeName==="A"&&!lr(t.parentNode)&&(Mt=t.parentNode)),t.hasAttribute("contenteditable")&&t.getAttribute("contenteditable")==="false"&&(Tn=t)}function hr(n,t,e){let{dom:i}=n,o=window.tinymce.dom.RangeUtils.getCaretRangeFromPoint(e.clientX,e.clientY,n.getDoc()),s=e.dataTransfer&&e.dataTransfer.getData("bookstack/template");s&&(e.preventDefault(),window.$http.get(`/templates/${s}`).then(r=>{n.selection.setRng(o),n.undoManager.transact(()=>{n.execCommand("mceInsertContent",!1,r.data.html)})})),i.getParent(o.startContainer,".mceTemp")?e.preventDefault():Mt&&(e.preventDefault(),n.undoManager.transact(()=>{n.selection.setRng(o),n.selection.setNode(Mt),i.remove(Mt)})),!e.isDefaultPrevented()&&Tn&&(e.preventDefault(),n.undoManager.transact(()=>{let r=n.selection.getNode(),a=n.selection.getRng(),l=r.closest("body > *");a.startOffset>a.startContainer.length/2?l.after(Tn):l.before(Tn)})),e.isDefaultPrevented()||Uo(n,t,e),Mt=null}function ur(n,t){t.preventDefault(),n.focus();let i=window.tinymce.dom.RangeUtils.getCaretRangeFromPoint(t.clientX??0,t.clientY??0,n.getDoc());n.selection.setRng(i)}function Vo(n,t){n.on("dragover",e=>ur(n,e)),n.on("dragstart",()=>dr(n)),n.on("drop",e=>hr(n,t,e)),n.on("paste",e=>Uo(n,t,e))}function Wo(n){return["undo redo","styles","bold italic underline forecolor backcolor formatoverflow","alignleft aligncenter alignright alignjustify","bullist numlist listoverflow",n.textDirection==="rtl"?"ltr rtl":"","link customtable imagemanager-insert insertoverflow","code about fullscreen"].filter(i=>!!i).join(" | ")}function pr(n){n.ui.registry.addGroupToolbarButton("formatoverflow",{icon:"more-drawer",tooltip:"More",items:"strikethrough superscript subscript inlinecode removeformat"}),n.ui.registry.addGroupToolbarButton("listoverflow",{icon:"more-drawer",tooltip:"More",items:"tasklist outdent indent"}),n.ui.registry.addGroupToolbarButton("insertoverflow",{icon:"more-drawer",tooltip:"More",items:"customhr codeeditor drawio media details"})}function mr(n){n.ui.registry.addContextToolbar("linkcontexttoolbar",{predicate(t){return t.closest("a")!==null},position:"node",scope:"node",items:"link unlink openlink"})}function fr(n){n.ui.registry.addContextToolbar("imagecontexttoolbar",{predicate(t){return t.closest("img")!==null&&!t.hasAttribute("data-mce-object")},position:"node",scope:"node",items:"image"})}function gr(n){n.ui.registry.addContextToolbar("objectcontexttoolbar",{predicate(t){return t.closest("img")!==null&&t.hasAttribute("data-mce-object")},position:"node",scope:"node",items:"media"})}function jo(n){pr(n),mr(n),fr(n),gr(n)}var vr={"table-delete-column":'<svg width="24" height="24"><path d="M21 19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14c1.1 0 2 .9 2 2zm-2 0V5h-4v2.2h-2V5h-2v2.2H9V5H5v14h4v-2.1h2V19h2v-2.1h2V19Z"/><path d="M14.829 10.585 13.415 12l1.414 1.414c.943.943-.472 2.357-1.414 1.414L12 13.414l-1.414 1.414c-.944.944-2.358-.47-1.414-1.414L10.586 12l-1.414-1.415c-.943-.942.471-2.357 1.414-1.414L12 10.585l1.344-1.343c1.111-1.112 2.2.627 1.485 1.343z" style="fill-rule:nonzero"/></svg>',"table-delete-row":'<svg width="24" height="24"><path d="M5 21a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14c0 1.1-.9 2-2 2zm0-2h14v-4h-2.2v-2H19v-2h-2.2V9H19V5H5v4h2.1v2H5v2h2.1v2H5Z"/><path d="M13.415 14.829 12 13.415l-1.414 1.414c-.943.943-2.357-.472-1.414-1.414L10.586 12l-1.414-1.414c-.944-.944.47-2.358 1.414-1.414L12 10.586l1.415-1.414c.942-.943 2.357.471 1.414 1.414L13.415 12l1.343 1.344c1.112 1.111-.627 2.2-1.343 1.485z" style="fill-rule:nonzero"/></svg>',"table-insert-column-after":'<svg width="24" height="24"><path d="M16 5h-5v14h5c1.235 0 1.234 2 0 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11c1.229 0 1.236 2 0 2zm-7 6V5H5v6zm0 8v-6H5v6zm11.076-6h-2v2c0 1.333-2 1.333-2 0v-2h-2c-1.335 0-1.335-2 0-2h2V9c0-1.333 2-1.333 2 0v2h1.9c1.572 0 1.113 2 .1 2z"/></svg>',"table-insert-column-before":'<svg width="24" height="24"><path d="M8 19h5V5H8C6.764 5 6.766 3 8 3h11a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H8c-1.229 0-1.236-2 0-2zm7-6v6h4v-6zm0-8v6h4V5ZM3.924 11h2V9c0-1.333 2-1.333 2 0v2h2c1.335 0 1.335 2 0 2h-2v2c0 1.333-2 1.333-2 0v-2h-1.9c-1.572 0-1.113-2-.1-2z"/></svg>',"table-insert-row-above":'<svg width="24" height="24"><path d="M5 8v5h14V8c0-1.235 2-1.234 2 0v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8C3 6.77 5 6.764 5 8zm6 7H5v4h6zm8 0h-6v4h6zM13 3.924v2h2c1.333 0 1.333 2 0 2h-2v2c0 1.335-2 1.335-2 0v-2H9c-1.333 0-1.333-2 0-2h2v-1.9c0-1.572 2-1.113 2-.1z"/></svg>',"table-insert-row-after":'<svg width="24" height="24"><path d="M19 16v-5H5v5c0 1.235-2 1.234-2 0V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v11c0 1.229-2 1.236-2 0zm-6-7h6V5h-6zM5 9h6V5H5Zm6 11.076v-2H9c-1.333 0-1.333-2 0-2h2v-2c0-1.335 2-1.335 2 0v2h2c1.333 0 1.333 2 0 2h-2v1.9c0 1.572-2 1.113-2 .1z"/></svg>',table:'<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg"><path d="M19 3a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5c0-1.1.9-2 2-2ZM5 14v5h6v-5zm14 0h-6v5h6zm0-7h-6v5h6zM5 12h6V7H5Z"/></svg>',"table-delete-table":'<svg width="24" height="24"><path d="M5 21a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14c0 1.1-.9 2-2 2zm0-2h14V5H5v14z"/><path d="m13.711 15.423-1.71-1.712-1.712 1.712c-1.14 1.14-2.852-.57-1.71-1.712l1.71-1.71-1.71-1.712c-1.143-1.142.568-2.853 1.71-1.71L12 10.288l1.711-1.71c1.141-1.142 2.852.57 1.712 1.71L13.71 12l1.626 1.626c1.345 1.345-.76 2.663-1.626 1.797z" style="fill-rule:nonzero;stroke-width:1.20992"/></svg>'};function zo(n){for(let[t,e]of Object.entries(vr))n.ui.registry.addIcon(t,e)}function wr(n){n.serializer.addNodeFilter("br",t=>{for(let e of t)if(e.parent&&e.parent.name==="code"){let i=window.tinymce.html.Node.create("#text");i.value=`
`,e.replace(i)}})}function br(n){n.parser.addNodeFilter("div",t=>{for(let e of t){let i=e.attr("id")||"",o=e.attr("class")||"";(i==="pointer"||o.includes("pointer"))&&e.remove()}})}function Ko(n){wr(n),br(n)}function Xo(n){return n.tagName.toLowerCase()==="code-block"}function Yo(n,t,e,i,o){let s=window.$components.first("code-editor"),r=n.selection.getBookmark();s.open(t,e,i,(a,l)=>{o(a,l),n.focus(),n.selection.moveToBookmark(r)},()=>{n.focus(),n.selection.moveToBookmark(r)})}function Go(n,t){let e=t.getAttribute("dir")||"";Yo(n,t.getContent(),t.getLanguage(),e,(i,o)=>{t.setContent(i,o)})}function yr(n){let t=n.getDoc(),e=t.defaultView;class i extends e.HTMLElement{constructor(){super();U(this,"editor",null);this.attachShadow({mode:"open"});let r=document.head.querySelectorAll('link[rel="stylesheet"]:not([media="print"]),style'),a=Array.from(r).map(c=>c.cloneNode(!0)),l=document.createElement("div");l.style.pointerEvents="none",l.contentEditable="false",l.classList.add("CodeMirrorContainer"),l.classList.toggle("dark-mode",document.documentElement.classList.contains("dark-mode")),this.shadowRoot.append(...a,l)}getLanguage(){let r=c=>(c.split(" ").filter(h=>h.startsWith("language-"))[0]||"").replace("language-",""),a=this.querySelector("code"),l=this.querySelector("pre");return r(l.className)||a&&r(a.className)||""}setContent(r,a){this.editor&&(this.editor.setContent(r),this.editor.setMode(a,r));let l=this.querySelector("pre");l||(l=t.createElement("pre"),this.append(l)),l.innerHTML="";let c=t.createElement("code");l.append(c),c.innerText=r,c.className=`language-${a}`}getContent(){let r=this.querySelector("code")||this.querySelector("pre"),a=document.createElement("pre");a.innerHTML=r.innerHTML.replace(/\ufeff/g,"");let l=a.querySelectorAll("br");for(let c of l)c.replaceWith(`
`);return a.textContent}connectedCallback(){let r=Date.now();if(this.editor)return;this.cleanChildContent();let a=this.getContent(),c=a.split(`
`).length*19.2+18+24;this.style.height=`${c}px`;let u=this.shadowRoot.querySelector(".CodeMirrorContainer"),h=m=>{this.editor=m.wysiwygView(u,this.shadowRoot,a,this.getLanguage()),setTimeout(()=>{this.style.height=null},12)};window.importVersioned("code").then(m=>{let g=Date.now()-r<20?20:0;setTimeout(()=>h(m),g)})}cleanChildContent(){let r=this.querySelector("pre");if(r)for(let a of r.childNodes)a.nodeName==="#text"&&a.textContent==="\uFEFF"&&a.remove()}}e.customElements.define("code-block",i)}function Er(n){n.ui.registry.addIcon("codeblock",'<svg width="24" height="24"><path d="M4 3h16c.6 0 1 .4 1 1v16c0 .6-.4 1-1 1H4a1 1 0 0 1-1-1V4c0-.6.4-1 1-1Zm1 2v14h14V5Z"/><path d="M11.103 15.423c.277.277.277.738 0 .922a.692.692 0 0 1-1.106 0l-4.057-3.78a.738.738 0 0 1 0-1.107l4.057-3.872c.276-.277.83-.277 1.106 0a.724.724 0 0 1 0 1.014L7.6 12.012ZM12.897 8.577c-.245-.312-.2-.675.08-.955.28-.281.727-.27 1.027.033l4.057 3.78a.738.738 0 0 1 0 1.107l-4.057 3.872c-.277.277-.83.277-1.107 0a.724.724 0 0 1 0-1.014l3.504-3.412z"/></svg>'),n.ui.registry.addButton("codeeditor",{tooltip:"Insert code block",icon:"codeblock",onAction(){n.execCommand("codeeditor")}}),n.ui.registry.addButton("editcodeeditor",{tooltip:"Edit code block",icon:"edit-block",onAction(){n.execCommand("codeeditor")}}),n.addCommand("codeeditor",()=>{let t=n.selection.getNode(),e=t.ownerDocument;if(Xo(t))Go(n,t);else{let i=n.selection.getContent({format:"text"}),o=document.dir==="rtl"?"ltr":"";Yo(n,i,"",o,(s,r)=>{let a=e.createElement("pre"),l=e.createElement("code");l.classList.add(`language-${r}`),l.innerText=s,o&&a.setAttribute("dir",o),a.append(l),n.insertContent(a.outerHTML)})}}),n.on("dblclick",()=>{let t=n.selection.getNode();Xo(t)&&Go(n,t)}),n.on("PreInit",()=>{n.parser.addNodeFilter("pre",t=>{for(let e of t){let i=window.tinymce.html.Node.create("code-block",{contenteditable:"false"}),o=e.children().filter(a=>a.name==="code")[0]||null,s=e.attr("dir")||o&&o.attr("dir")||"";s&&i.attr("dir",s);let r=e.getAll("span");for(let a of r)a.unwrap();e.attr("style",null),e.wrap(i)}}),n.parser.addNodeFilter("code-block",t=>{for(let e of t)e.attr("contenteditable","false")}),n.serializer.addNodeFilter("code-block",t=>{for(let e of t){let i=e.attr("dir");i&&e.firstChild?e.firstChild.attr("dir",i):e.firstChild&&e.firstChild.attr("dir",null),e.unwrap()}})}),n.ui.registry.addContextToolbar("codeeditor",{predicate(t){return t.nodeName.toLowerCase()==="code-block"},items:"editcodeeditor",position:"node",scope:"node"}),n.on("PreInit",()=>{yr(n)})}function Jo(){return Er}function Sn(n){return new Promise((t,e)=>{n.oncomplete=n.onsuccess=()=>t(n.result),n.onabort=n.onerror=()=>e(n.error)})}function Cr(n,t){let e,i=()=>{if(e)return e;let o=indexedDB.open(n);return o.onupgradeneeded=()=>o.result.createObjectStore(t),e=Sn(o),e.then(s=>{s.onclose=()=>e=void 0},()=>{}),e};return(o,s)=>i().then(r=>s(r.transaction(t,o).objectStore(t)))}var Bi;function Pi(){return Bi||(Bi=Cr("keyval-store","keyval")),Bi}function Ri(n,t=Pi()){return t("readonly",e=>Sn(e.get(n)))}function Oi(n,t,e=Pi()){return e("readwrite",i=>(i.put(t,n),Sn(i.transaction)))}function _i(n,t=Pi()){return t("readwrite",e=>(e.delete(n),Sn(e.transaction)))}var nt=null,qi,kn,Ni,Fi="last-drawing-save";function Ui(n){nt?.contentWindow?.postMessage(JSON.stringify(n),qi)}function Lr(n){Oi(Fi,n.data),Ni&&Ni(n.data).then(()=>{_i(Fi)})}function Tr(n){Ui({action:"export",format:"xmlpng",xml:n.xml,spin:"Updating drawing"})}function Sr(){kn&&kn().then(n=>{Ui({action:"load",autosave:1,xml:n})})}function kr(){let n={};nt&&(window.$events.emitPublic(nt,"editor-drawio::configure",{config:n}),Ui({action:"configure",config:n}))}function Zo(){window.removeEventListener("message",Qo),nt&&document.body.removeChild(nt)}function Qo(n){if(!n.data||n.data.length<1||n.origin!==qi)return;let t=JSON.parse(n.data);t.event==="init"?Sr():t.event==="exit"?Zo():t.event==="save"?Tr(t):t.event==="export"?Lr(t):t.event==="configure"&&kr()}async function $r(){let n=await Ri(Fi),t=document.getElementById("unsaved-drawing-dialog");t||console.error("Missing expected unsaved-drawing dialog"),n&&t&&await window.$components.firstOnElement(t,"confirm-dialog").show()&&(kn=async()=>n)}async function ts(n,t,e){kn=t,Ni=e,await $r(),nt=document.createElement("iframe"),nt.setAttribute("frameborder","0"),window.addEventListener("message",Qo),nt.setAttribute("src",n),nt.setAttribute("class","fullscreen"),nt.style.backgroundColor="#FFFFFF",document.body.appendChild(nt),qi=new URL(n).origin}async function Vi(n,t){let e={image:n,uploaded_to:t};return(await window.$http.post(window.baseUrl("/images/drawio"),e)).data}function $n(){Zo()}async function es(n){try{return`data:image/png;base64,${(await window.$http.get(window.baseUrl(`/images/drawio/base64/${n}`))).data.content}`}catch(t){throw t instanceof xt&&window.$events.showResponseError(t),$n(),t}}var z=null,It=null,At={};function Wi(n){return n.hasAttribute("drawio-diagram")}function Mr(n,t=null){z=n,It=t,window.$components.first("image-manager").show(i=>{if(t){let o=t.querySelector("img");z.undoManager.transact(()=>{z.dom.setAttrib(o,"src",i.url),z.dom.setAttrib(t,"drawio-diagram",i.id)})}else{let o=`<div drawio-diagram="${i.id}" contenteditable="false"><img src="${i.url}"></div>`;z.insertContent(o)}},"drawio")}async function Ar(n){let t=window.baseUrl("/loading.gif"),e=s=>{s.status===413?window.$events.emit("error",At.translations.serverUploadLimitText):window.$events.emit("error",At.translations.imageUploadErrorText),console.error(s)};if(It){$n();let s=It.querySelector("img");try{let r=await Vi(n,At.pageId);z.undoManager.transact(()=>{z.dom.setAttrib(s,"src",r.url),z.dom.setAttrib(It,"drawio-diagram",r.id)})}catch(r){throw e(r),new Error(`Failed to save image with error: ${r}`)}return}await eo(5);let i=`drawing-${Math.random().toString(16).slice(2)}`,o=`drawing-wrap-${Math.random().toString(16).slice(2)}`;z.insertContent(`<div drawio-diagram contenteditable="false" id="${o}"><img src="${t}" id="${i}"></div>`),$n();try{let s=await Vi(n,At.pageId);z.undoManager.transact(()=>{z.dom.setAttrib(i,"src",s.url),z.dom.setAttrib(o,"drawio-diagram",s.id)})}catch(s){throw z.dom.remove(o),e(s),new Error(`Failed to save image with error: ${s}`)}}function Ir(){if(!It)return Promise.resolve("");let n=It.getAttribute("drawio-diagram");return es(n)}function ns(n,t=null){z=n,It=t,ts(At.drawioUrl,Ir,Ar)}function Hr(n){n.addCommand("drawio",()=>{let t=n.selection.getNode();ns(n,Wi(t)?t:null)}),n.ui.registry.addIcon("diagram",`<svg width="24" height="24" fill="${At.darkMode?"#BBB":"#000000"}" xmlns="http://www.w3.org/2000/svg"><path d="M20.716 7.639V2.845h-4.794v1.598h-7.99V2.845H3.138v4.794h1.598v7.99H3.138v4.794h4.794v-1.598h7.99v1.598h4.794v-4.794h-1.598v-7.99zM4.736 4.443h1.598V6.04H4.736zm1.598 14.382H4.736v-1.598h1.598zm9.588-1.598h-7.99v-1.598H6.334v-7.99h1.598V6.04h7.99v1.598h1.598v7.99h-1.598zm3.196 1.598H17.52v-1.598h1.598zM17.52 6.04V4.443h1.598V6.04zm-4.21 7.19h-2.79l-.582 1.599H8.643l2.717-7.191h1.119l2.724 7.19h-1.302zm-2.43-1.006h2.086l-1.039-3.06z"/></svg>`),n.ui.registry.addSplitButton("drawio",{tooltip:"Insert/edit drawing",icon:"diagram",onAction(){n.execCommand("drawio"),window.document.body.dispatchEvent(new Event("mousedown",{bubbles:!0}))},fetch(t){t([{type:"choiceitem",text:"Drawing manager",value:"drawing-manager"}])},onItemAction(t,e){if(e==="drawing-manager"){let i=n.selection.getNode();Mr(n,Wi(i)?i:null)}}}),n.on("dblclick",()=>{let t=n.selection.getNode();Wi(t)&&ns(n,t)}),n.on("SetContent",()=>{let t=n.dom.select("body > div[drawio-diagram]");t.length&&n.undoManager.transact(()=>{for(let e of t)e.setAttribute("contenteditable","false")})})}function is(n){return At=n,Hr}function Br(n){n.addCommand("InsertHorizontalRule",()=>{let t=document.createElement("hr"),e=n.selection.getNode(),{parentNode:i}=e;i.insertBefore(t,e)}),n.ui.registry.addButton("customhr",{icon:"horizontal-rule",tooltip:"Insert horizontal line",onAction(){n.execCommand("InsertHorizontalRule")}})}function os(){return Br}function Pr(n){n.ui.registry.addButton("imagemanager-insert",{title:"Insert image",icon:"image",tooltip:"Insert image",onAction(){window.$components.first("image-manager").show(e=>{let i=e.thumbs?.display||e.url,o=`<a href="${e.url}" target="_blank">`;o+=`<img src="${i}" alt="${e.name}">`,o+="</a>",n.execCommand("mceInsertContent",!1,o)},"gallery")}})}function ss(){return Pr}function Rr(n){let t={title:"About the WYSIWYG Editor",url:window.baseUrl("/help/tinymce")};n.ui.registry.addButton("about",{icon:"help",tooltip:"About the editor",onAction(){window.tinymce.activeEditor.windowManager.openUrl(t)}})}function rs(){return Rr}var as=["p","h1","h2","h3","h4","h5","h6","div","blockquote","pre","code-block","details","ul","ol","table","hr"];function Dn(n){return n.selection.getNode().closest("details")}function Or(n,t){let e=Dn(n);e&&n.undoManager.transact(()=>{let i=e.querySelector("summary");i||(i=document.createElement("summary"),e.prepend(i)),i.textContent=t})}function _r(n){return{title:"Edit collapsible block",body:{type:"panel",items:[{type:"input",name:"summary",label:"Toggle label"}]},buttons:[{type:"cancel",text:"Cancel"},{type:"submit",text:"Save",primary:!0}],onSubmit(t){let{summary:e}=t.getData();Or(n,e),t.close()}}}function Nr(n){let t=n.querySelector("summary");return t?t.textContent:""}function ls(n){let t=Dn(n);n.windowManager.open(_r(n)).setData({summary:Nr(t)})}function Fr(n){let t=n.selection.getNode().closest("details"),e=n.selection.getBookmark();if(t){let i=t.querySelectorAll("details > *:not(summary, doc-root), doc-root > *");n.undoManager.transact(()=>{for(let o of i)t.parentNode.insertBefore(o,t);t.remove()})}n.focus(),n.selection.moveToBookmark(e)}function ji(n){n.attr("contenteditable",null);let t=!1;for(let e of n.children())e.name==="doc-root"&&(e.unwrap(),t=!0);t&&ji(n)}function qr(n){ji(n),n.attr("contenteditable","false");let t=window.tinymce.html.Node.create("doc-root",{contenteditable:"true"}),e=null;for(let i of n.children()){if(i.name==="summary")continue;as.includes(i.name)?(t.append(i),e=null):(e||(e=window.tinymce.html.Node.create("p"),t.append(e)),e.append(i))}n.append(t)}function Ur(n){n.parser.addNodeFilter("details",t=>{for(let e of t)qr(e)}),n.serializer.addNodeFilter("details",t=>{for(let e of t)ji(e),e.attr("open",null)}),n.serializer.addNodeFilter("doc-root",t=>{for(let e of t)e.unwrap()})}function Vr(n){n.ui.registry.addIcon("details",'<svg width="24" height="24"><path d="M8.2 9a.5.5 0 0 0-.4.8l4 5.6a.5.5 0 0 0 .8 0l4-5.6a.5.5 0 0 0-.4-.8ZM20.122 18.151h-16c-.964 0-.934 2.7 0 2.7h16c1.139 0 1.173-2.7 0-2.7zM20.122 3.042h-16c-.964 0-.934 2.7 0 2.7h16c1.139 0 1.173-2.7 0-2.7z"/></svg>'),n.ui.registry.addIcon("togglefold",'<svg height="24" width="24"><path d="M8.12 19.3c.39.39 1.02.39 1.41 0L12 16.83l2.47 2.47c.39.39 1.02.39 1.41 0 .39-.39.39-1.02 0-1.41l-3.17-3.17c-.39-.39-1.02-.39-1.41 0l-3.17 3.17c-.4.38-.4 1.02-.01 1.41zm7.76-14.6c-.39-.39-1.02-.39-1.41 0L12 7.17 9.53 4.7c-.39-.39-1.02-.39-1.41 0-.39.39-.39 1.03 0 1.42l3.17 3.17c.39.39 1.02.39 1.41 0l3.17-3.17c.4-.39.4-1.03.01-1.42z"/></svg>'),n.ui.registry.addIcon("togglelabel",'<svg height="18" width="18" viewBox="0 0 24 24"><path d="M21.41,11.41l-8.83-8.83C12.21,2.21,11.7,2,11.17,2H4C2.9,2,2,2.9,2,4v7.17c0,0.53,0.21,1.04,0.59,1.41l8.83,8.83 c0.78,0.78,2.05,0.78,2.83,0l7.17-7.17C22.2,13.46,22.2,12.2,21.41,11.41z M6.5,8C5.67,8,5,7.33,5,6.5S5.67,5,6.5,5S8,5.67,8,6.5 S7.33,8,6.5,8z"/></svg>'),n.ui.registry.addButton("details",{icon:"details",tooltip:"Insert collapsible block",onAction(){n.execCommand("InsertDetailsBlock")}}),n.ui.registry.addButton("removedetails",{icon:"table-delete-table",tooltip:"Unwrap",onAction(){Fr(n)}}),n.ui.registry.addButton("editdetials",{icon:"togglelabel",tooltip:"Edit label",onAction(){ls(n)}}),n.on("dblclick",t=>{!Dn(n)||t.target.closest("doc-root")||ls(n)}),n.ui.registry.addButton("toggledetails",{icon:"togglefold",tooltip:"Toggle open/closed",onAction(){Dn(n).toggleAttribute("open"),n.focus()}}),n.addCommand("InsertDetailsBlock",()=>{let t=n.selection.getContent({format:"html"}),e=document.createElement("details"),i=document.createElement("summary"),o=`details-${Date.now()}`;e.setAttribute("data-id",o),e.appendChild(i),t||(t="<p><br></p>"),e.innerHTML+=t,n.insertContent(e.outerHTML),n.focus();let s=n.dom.select(`[data-id="${o}"]`)[0]||null;if(s){let r=s.querySelector("doc-root > *");r&&r.focus(),s.removeAttribute("data-id")}}),n.ui.registry.addContextToolbar("details",{predicate(t){return t.nodeName.toLowerCase()==="details"},items:"editdetials toggledetails removedetails",position:"node",scope:"node"}),n.on("PreInit",()=>{Ur(n)})}function cs(){return Vr}function Wr(n){n.ui.registry.addIcon("tableclearformatting",'<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" viewBox="0 0 24 24"><path d="M15.53088 4.64727v-.82364c0-.453-.37063-.82363-.82363-.82363H4.82363C4.37063 3 4 3.37064 4 3.82363v3.29454c0 .453.37064.82364.82363.82364h9.88362c.453 0 .82363-.37064.82363-.82364v-.82363h.82364v3.29454H8.11817v7.4127c0 .453.37064.82364.82364.82364h1.64727c.453 0 .82363-.37064.82363-.82364v-5.76544h6.58907V4.64727Z"/><path d="m18.42672 19.51563-1.54687-1.54688-1.54688 1.54688c-.26751.2675-.70124.2675-.96875 0-.26751-.26752-.26751-.70124 0-.96876L15.9111 17l-1.54688-1.54688c-.26751-.2675-.26751-.70123 0-.96875.26751-.2675.70124-.2675.96875 0l1.54688 1.54688 1.54687-1.54688c.26751-.2675.70124-.2675.96875 0 .26751.26752.26751.70124 0 .96875L17.8486 17l1.54687 1.54688c.26751.2675.26751.70123 0 .96874-.26751.26752-.70124.26752-.96875 0z"/></svg>');let t={items:" | tablerowheader",predicate(i){let o=i.nodeName.toLowerCase()==="table",s=n.selection.getNode(),r=s.closest("table");return!o||!r?!1:r.querySelector("tr").contains(s)},position:"node",scope:"node"};n.ui.registry.addContextToolbar("customtabletoolbarfirstrow",t),n.addCommand("tableclearformatting",()=>{let i=n.dom.getParent(n.selection.getStart(),"table");if(!i)return;let o=["class","style","width","height"],s=[i,...i.querySelectorAll(o.map(r=>`[${r}]`).join(","))];for(let r of s)for(let a of o)r.removeAttribute(a)}),n.addCommand("tableclearsizes",()=>{let i=n.dom.getParent(n.selection.getStart(),"table");if(!i)return;let o=[i,...i.querySelectorAll("tr,td,th,tbody,thead,tfoot,th>*,td>*")];for(let s of o)s.removeAttribute("width"),s.removeAttribute("height"),s.style.height=null,s.style.width=null});let e=()=>{let i=n.ui.registry.getAll().buttons;n.ui.registry.addMenuButton("customtable",{...i.table,fetch:o=>o("inserttable | cell row column | advtablesort | tableprops tableclearformatting tableclearsizes deletetable")}),n.ui.registry.addMenuItem("tableclearformatting",{icon:"tableclearformatting",text:"Clear table formatting",onSetup:i.tableprops.onSetup,onAction(){n.execCommand("tableclearformatting")}}),n.ui.registry.addMenuItem("tableclearsizes",{icon:"resize",text:"Resize to contents",onSetup:i.tableprops.onSetup,onAction(){n.execCommand("tableclearsizes")}}),n.off("PreInit",e)};n.on("PreInit",e)}function ds(){return Wr}function jr(n){let t=n.closest("li");return t&&t.parentNode.nodeName==="UL"&&t.classList.contains("task-list-item")}function zr(n,t,e){let i=t.getBoundingClientRect();n.clientX<=i.right&&n.clientX>=i.left&&n.clientY>=i.top&&n.clientY<=i.bottom||e.undoManager.transact(()=>{t.hasAttribute("checked")?t.removeAttribute("checked"):t.setAttribute("checked","checked")})}function Kr(n){n.attr("class","task-list-item");for(let t of n.children())t.name==="input"&&(t.attr("checked")==="checked"&&n.attr("checked","checked"),t.remove())}function Xr(n){let t=n.attr("checked")==="checked";n.attr("checked",null);let e={type:"checkbox",disabled:"disabled"};t&&(e.checked="checked");let i=window.tinymce.html.Node.create("input",e);i.shortEnded=!0,n.firstChild?n.insert(i,n.firstChild,!0):n.append(i)}function Gr(n){n.ui.registry.addIcon("tasklist",'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M22,8c0-0.55-0.45-1-1-1h-7c-0.55,0-1,0.45-1,1s0.45,1,1,1h7C21.55,9,22,8.55,22,8z M13,16c0,0.55,0.45,1,1,1h7 c0.55,0,1-0.45,1-1c0-0.55-0.45-1-1-1h-7C13.45,15,13,15.45,13,16z M10.47,4.63c0.39,0.39,0.39,1.02,0,1.41l-4.23,4.25 c-0.39,0.39-1.02,0.39-1.42,0L2.7,8.16c-0.39-0.39-0.39-1.02,0-1.41c0.39-0.39,1.02-0.39,1.41,0l1.42,1.42l3.54-3.54 C9.45,4.25,10.09,4.25,10.47,4.63z M10.48,12.64c0.39,0.39,0.39,1.02,0,1.41l-4.23,4.25c-0.39,0.39-1.02,0.39-1.42,0L2.7,16.16 c-0.39-0.39-0.39-1.02,0-1.41s1.02-0.39,1.41,0l1.42,1.42l3.54-3.54C9.45,12.25,10.09,12.25,10.48,12.64L10.48,12.64z"/></svg>'),n.ui.registry.addToggleButton("tasklist",{tooltip:"Task list",icon:"tasklist",active:!1,onAction(i){i.isActive()?n.execCommand("RemoveList"):n.execCommand("InsertUnorderedList",null,{"list-item-attributes":{class:"task-list-item"},"list-style-type":"tasklist"})},onSetup(i){n.on("NodeChange",o=>{let s=o.parents.find(a=>a.nodeName==="LI"),r=s&&s.classList.contains("task-list-item");i.setActive(!!r)})}});let t=n.ui.registry.getAll().buttons.bullist;t.onSetup=function(o){n.on("NodeChange",s=>{let r=s.parents.find(c=>c.nodeName==="LI"),a=r&&r.classList.contains("task-list-item"),l=r&&r.parentNode.nodeName==="UL";o.setActive(!!(l&&!a))})},t.onAction=function(){jr(n.selection.getNode())&&n.execCommand("InsertOrderedList",null,{"list-item-attributes":{class:null}}),n.execCommand("InsertUnorderedList",null,{"list-item-attributes":{class:null}})};let e=n.ui.registry.getAll().buttons.numlist;e.onAction=function(){n.execCommand("InsertOrderedList",null,{"list-item-attributes":{class:null}})},n.on("PreInit",()=>{n.parser.addNodeFilter("li",i=>{for(let o of i)o.attributes.map.class==="task-list-item"&&Kr(o)}),n.serializer.addNodeFilter("li",i=>{for(let o of i)o.attributes.map.class==="task-list-item"&&Xr(o)})}),n.on("click",i=>{let o=i.target;o.nodeName==="LI"&&o.classList.contains("task-list-item")&&(zr(i,o,n),i.preventDefault())})}function hs(){return Gr}function us(n){function t(e){let i=e.querySelector("iframe, video");if(!i)return;let o=[...i.classList.values()].filter(r=>r.startsWith("align-")),s=[...e.classList.values()].filter(r=>r.startsWith("align-"));e.classList.remove(...s),e.classList.add(...o)}n.on("SetContent",()=>{let e=n.dom.select("span.mce-preview-object");for(let i of e)t(i)}),n.on("FormatApply",e=>{let i=e.format.startsWith("align");if(!(e.node instanceof n.dom.doc.defaultView.HTMLElement)||!i||!e.node.matches(".mce-preview-object"))return;let s=e.node.querySelector("iframe, video");if(s){let r=(n.formatter.get(e.format)[0]?.classes||[])[0],a=!s.classList.contains(r),c=(e.node.getAttribute("data-mce-p-class")||"").split(" ").filter(h=>!h.startsWith("align-"));a&&c.push(r);let u=c.join(" ");e.node.setAttribute("data-mce-p-class",u),s.setAttribute("class",u),n.formatter.apply(e.format,{},s),t(e.node)}})}function ps(n){let t=n.querySelectorAll('[align],[style*="text-align"],.align-center,.align-left,.align-right');for(let e of t)e.removeAttribute("align"),e.style.textAlign=null,e.classList.remove("align-center","align-right","align-left")}function zi(n){let t=n.querySelectorAll('[dir],[style*="direction"]');for(let e of t)e.removeAttribute("dir"),e.style.direction=null;ps(n),n.style.direction=null,n.style.textAlign=null,n.removeAttribute("align")}function ms(n){let t=[];n.on("TableSelectionChange",i=>{t=(i.cells||[]).map(o=>o.dom)}),n.on("TableSelectionClear",()=>{t=[]});let e={RemoveFormat:i=>{let o=["class","style","width","height","align"];for(let s of o)i.removeAttribute(s)},mceDirectionLTR:i=>{i.setAttribute("dir","ltr"),zi(i)},mceDirectionRTL:i=>{i.setAttribute("dir","rtl"),zi(i)},JustifyLeft:i=>{i.removeAttribute("align"),ps(i)}};e.JustifyRight=e.JustifyLeft,e.JustifyCenter=e.JustifyLeft,e.JustifyFull=e.JustifyLeft,n.on("ExecCommand",i=>{let o=e[i.command];if(o)for(let s of t)o(s)})}function fs(n){n.on("ExecCommand",t=>{let e=t.command;if(e!=="mceDirectionLTR"&&e!=="mceDirectionRTL")return;let i=n.selection.getSelectedBlocks();for(let o of i)zi(o)})}var Yr=[{title:"Large Header",format:"h2",preview:"color: blue;"},{title:"Medium Header",format:"h3"},{title:"Small Header",format:"h4"},{title:"Tiny Header",format:"h5"},{title:"Paragraph",format:"p",exact:!0,classes:""},{title:"Blockquote",format:"blockquote"},{title:"Callouts",items:[{title:"Information",format:"calloutinfo"},{title:"Success",format:"calloutsuccess"},{title:"Warning",format:"calloutwarning"},{title:"Danger",format:"calloutdanger"}]}],Jr={alignleft:{selector:"p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img,iframe,video",classes:"align-left"},aligncenter:{selector:"p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img,iframe,video",classes:"align-center"},alignright:{selector:"p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img,iframe,video",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"}}},Zr=["#BFEDD2","","#FBEEB8","","#F8CAC6","","#ECCAFA","","#C2E0F4","","#2DC26B","","#F1C40F","","#E03E2D","","#B96AD9","","#3598DB","","#169179","","#E67E23","","#BA372A","","#843FA1","","#236FA1","","#ECF0F1","","#CED4D9","","#95A5A6","","#7E8C8D","","#34495E","","#000000","","#ffffff",""];function gs(n,t,e){if(e.filetype==="file"){let i=window.$components.first("entity-selector-popup"),o=this.selection.getContent({format:"text"}).trim();i.show(s=>{n(s.link,{text:s.name,title:s.name})},{initialValue:o,searchEndpoint:"/search/entity-selector",entityTypes:"page,book,chapter,bookshelf",entityPermission:"view"})}e.filetype==="image"&&window.$components.first("image-manager").show(o=>{n(o.url,{alt:o.name})},"gallery")}function Qr(n){let t=["image","table","link","autolink","fullscreen","code","customhr","autosave","lists","codeeditor","media","imagemanager","about","details","tasklist","tableadditions",n.textDirection==="rtl"?"directionality":""];return window.tinymce.PluginManager.add("codeeditor",Jo()),window.tinymce.PluginManager.add("customhr",os()),window.tinymce.PluginManager.add("imagemanager",ss()),window.tinymce.PluginManager.add("about",rs()),window.tinymce.PluginManager.add("details",cs()),window.tinymce.PluginManager.add("tasklist",hs()),window.tinymce.PluginManager.add("tableadditions",ds()),n.drawioUrl&&(window.tinymce.PluginManager.add("drawio",is(n)),t.push("drawio")),t.filter(e=>!!e)}function vs(n){let t=document.head.innerHTML.split(`
`),e=t.findIndex(r=>r.trim()==="<!-- Start: custom user content -->"),i=t.findIndex(r=>r.trim()==="<!-- End: custom user content -->");if(e===-1||i===-1)return;let o=t.slice(e+1,i).join(`
`),s=n.createElement("div");s.innerHTML=o,n.head.append(...s.children)}function ta(n){return function(e){function i(){n.darkMode&&e.contentDocument.documentElement.classList.add("dark-mode"),window.$events.emit("editor-html-change","")}e.on("ExecCommand change input NodeChange ObjectResized",i),Fo(e),Vo(e,n),e.on("init",()=>{i(),qo(e),window.editor=e,No(e)}),e.on("PreInit",()=>{Ko(e)}),us(e),ms(e),fs(e),window.$events.emitPublic(n.containerElement,"editor-tinymce::setup",{editor:e}),e.ui.registry.addButton("inlinecode",{tooltip:"Inline code",icon:"sourcecode",onAction(){e.execCommand("mceToggleFormat",!1,"code")}})}}function ws(n){return`
html, body, html.dark-mode {
background: ${n.darkMode?"#222":"#fff"};
}
body {
padding-left: 15px !important;
padding-right: 15px !important;
height: initial !important;
margin:0!important;
margin-left: auto! important;
margin-right: auto !important;
overflow-y: hidden !important;
}`.trim().replace(`
`,"")}function bs(n){return window.tinymce.addI18n(n.language,n.translationMap),{width:"100%",height:"100%",selector:"#html-editor",cache_suffix:`?version=${document.querySelector('script[src*="/dist/app.js"]').getAttribute("src").split("?version=")[1]}`,content_css:[window.baseUrl("/dist/styles.css")],branding:!1,skin:n.darkMode?"tinymce-5-dark":"tinymce-5",body_class:"page-content",browser_spellcheck:!0,relative_urls:!1,language:n.language,directionality:n.textDirection,remove_script_host:!1,document_base_url:window.baseUrl("/"),end_container_on_empty_block:!0,remove_trailing_brs:!1,statusbar:!1,menubar:!1,paste_data_images:!1,extended_valid_elements:"pre[*],svg[*],div[drawio-diagram],details[*],summary[*],div[*],li[class|checked|style]",automatic_uploads:!1,custom_elements:"doc-root,code-block",valid_children:["-div[p|h1|h2|h3|h4|h5|h6|blockquote|code-block]","+div[pre|img]","-doc-root[doc-root|#text]","-li[details]","+code-block[pre]","+doc-root[p|h1|h2|h3|h4|h5|h6|blockquote|code-block|div|hr]"].join(","),plugins:Qr(n),contextmenu:!1,toolbar:Wo(n),content_style:ws(n),style_formats:Yr,style_formats_merge:!1,media_alt_source:!1,media_poster:!1,formats:Jr,table_style_by_css:!0,table_use_colgroups:!0,file_picker_types:"file image",color_map:Zr,file_picker_callback:gs,paste_preprocess(e,i){let{content:o}=i;o.indexOf('<img src="file://')!==-1&&(i.content="")},init_instance_callback(e){vs(e.getDoc())},setup(e){zo(e),jo(e),ta(n)(e)}}}function Wt(n){window.tinymce.addI18n(n.language,n.translationMap);let t=document.querySelector('script[src*="/dist/app.js"]').getAttribute("src").split("?version=")[1];return{width:"100%",height:"185px",target:n.containerElement,cache_suffix:`?version=${t}`,content_css:[window.baseUrl("/dist/styles.css")],branding:!1,skin:n.darkMode?"tinymce-5-dark":"tinymce-5",body_class:"wysiwyg-input",browser_spellcheck:!0,relative_urls:!1,language:n.language,directionality:n.textDirection,remove_script_host:!1,document_base_url:window.baseUrl("/"),end_container_on_empty_block:!0,remove_trailing_brs:!1,statusbar:!1,menubar:!1,plugins:"link autolink lists",contextmenu:!1,toolbar:"bold italic link bullist numlist",content_style:ws(n),file_picker_types:"file",valid_elements:"p,a[href|title|target],ol,ul,li,strong,em,br",file_picker_callback:gs,init_instance_callback(e){vs(e.getDoc()),e.contentDocument.documentElement.classList.toggle("dark-mode",n.darkMode)}}}var Mn=class extends d{constructor(){super(...arguments);this.wysiwygEditor=null}setup(){this.commentId=this.$opts.commentId,this.commentLocalId=this.$opts.commentLocalId,this.deletedText=this.$opts.deletedText,this.deletedText=this.$opts.deletedText,this.archiveText=this.$opts.archiveText,this.wysiwygLanguage=this.$opts.wysiwygLanguage,this.wysiwygTextDirection=this.$opts.wysiwygTextDirection,this.container=this.$el,this.contentContainer=this.$refs.contentContainer,this.form=this.$refs.form,this.formCancel=this.$refs.formCancel,this.editButton=this.$refs.editButton,this.deleteButton=this.$refs.deleteButton,this.replyButton=this.$refs.replyButton,this.archiveButton=this.$refs.archiveButton,this.input=this.$refs.input,this.setupListeners()}setupListeners(){if(this.replyButton){let e={id:this.commentLocalId,element:this.container};this.replyButton.addEventListener("click",()=>this.$emit("reply",e))}this.editButton&&(this.editButton.addEventListener("click",this.startEdit.bind(this)),this.form.addEventListener("submit",this.update.bind(this)),this.formCancel.addEventListener("click",()=>this.toggleEditMode(!1))),this.deleteButton&&this.deleteButton.addEventListener("click",this.delete.bind(this)),this.archiveButton&&this.archiveButton.addEventListener("click",this.archive.bind(this))}toggleEditMode(e){this.contentContainer.toggleAttribute("hidden",e),this.form.toggleAttribute("hidden",!e)}startEdit(){if(this.toggleEditMode(!0),this.wysiwygEditor){this.wysiwygEditor.focus();return}let e=Wt({language:this.wysiwygLanguage,containerElement:this.input,darkMode:document.documentElement.classList.contains("dark-mode"),textDirection:this.wysiwygTextDirection,drawioUrl:"",pageId:0,translations:{},translationMap:window.editor_translations});window.tinymce.init(e).then(i=>{this.wysiwygEditor=i[0],setTimeout(()=>this.wysiwygEditor.focus(),50)})}async update(e){e.preventDefault();let i=this.showLoading();this.form.toggleAttribute("hidden",!0);let o={html:this.wysiwygEditor.getContent()};try{let s=await window.$http.put(`/comment/${this.commentId}`,o),r=Z(s.data);this.container.replaceWith(r),window.$events.success(this.updatedText)}catch(s){console.error(s),s instanceof xt&&window.$events.showValidationErrors(s),this.form.toggleAttribute("hidden",!1),i.remove()}}async delete(){this.showLoading(),await window.$http.delete(`/comment/${this.commentId}`),this.$emit("delete");let e=this.container.closest(".comment-branch");if(e instanceof HTMLElement){let i=window.$components.allWithinElement(e,"page-comment-reference");for(let o of i)o.hideMarker();e.remove()}window.$events.success(this.deletedText)}async archive(){this.showLoading();let i=this.archiveButton.dataset.isArchived==="true"?"unarchive":"archive",o=await window.$http.put(`/comment/${this.commentId}/${i}`);window.$events.success(this.archiveText);let s={new_thread_dom:Z(o.data)};this.$emit(i,s);let r=this.container.closest(".comment-branch"),a=window.$components.allWithinElement(r,"page-comment-reference");for(let l of a)l.hideMarker();r.remove()}showLoading(){let e=Bt();return e.classList.add("px-l"),this.container.append(e),e}};var ys='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M21.99 4c0-1.1-.89-2-1.99-2H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h14l4 4zM18 14H6v-2h12zm0-3H6V9h12zm0-3H6V6h12z"/><path fill="none" d="M0 0h24v24H0z"/></svg>';var Es='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>';var jt=null,An=class extends d{constructor(){super(...arguments);this.markerWrap=null}setup(){this.link=this.$el,this.reference=this.$opts.reference,this.viewCommentText=this.$opts.viewCommentText,this.jumpToThreadText=this.$opts.jumpToThreadText,this.closeText=this.$opts.closeText,this.showForDisplay(),window.addEventListener("editor-toolbox-change",e=>{let i=e.detail.tab,o=e.detail.open;i==="comments"&&o&&this.link.checkVisibility()?this.showForEditor():this.hideMarker()}),window.addEventListener("toggle",e=>{e.target instanceof HTMLElement&&e.target.contains(this.link)&&window.requestAnimationFrame(()=>{this.link.checkVisibility()?this.showForEditor():this.hideMarker()})},{capture:!0}),window.addEventListener("tabs-change",e=>{let i=e.detail.showing;if(!i.startsWith("comment-tab-panel"))return;document.getElementById(i)?.contains(this.link)?this.showForDisplay():this.hideMarker()})}showForDisplay(){let e=document.querySelector(".page-content");e instanceof HTMLElement&&this.link.checkVisibility()&&this.updateMarker(e)}showForEditor(){let e=document.querySelector(".editor-content-wrap");e instanceof HTMLElement&&this.updateMarker(e);let i=()=>{this.hideMarker(),setTimeout(()=>{window.$events.remove("editor-html-change",i)},1)};window.$events.listen("editor-html-change",i)}updateMarker(e){this.link.classList.remove("outdated","missing"),this.markerWrap&&this.markerWrap.remove();let[i,o,s]=this.reference.split(":"),r=document.getElementById(i);if(!r){this.link.classList.add("outdated","missing");return}Ce(r)!==o&&this.link.classList.add("outdated");let l=rt("button",{type:"button",class:"content-comment-marker",title:this.viewCommentText});l.innerHTML=ys,l.addEventListener("click",u=>{this.showCommentAtMarker(l)}),this.markerWrap=rt("div",{class:"content-comment-highlight"},[l]),e.append(this.markerWrap),this.positionMarker(r,s),this.link.href=`#${r.id}`,this.link.addEventListener("click",u=>{u.preventDefault(),Lt(r)});let c=mt(()=>{this.positionMarker(r,s)},50,!1).bind(this);window.addEventListener("resize",c)}positionMarker(e,i){if(!this.markerWrap)return;let o=this.markerWrap.parentElement,s=o.getBoundingClientRect(),r=e.getBoundingClientRect(),[a,l]=i.split("-");if(a&&l){let h=new Range,m=Ee(e,Number(a)),g=Ee(e,Number(l));m&&g&&(h.setStart(m.node,m.offset),h.setEnd(g.node,g.offset),r=h.getBoundingClientRect())}let c=r.left-s.left,u=r.top-s.top+o.scrollTop;this.markerWrap.style.left=`${c}px`,this.markerWrap.style.top=`${u}px`,this.markerWrap.style.width=`${r.width}px`,this.markerWrap.style.height=`${r.height}px`}hideMarker(){jt&&jt(),this.markerWrap?.remove(),this.markerWrap=null}showCommentAtMarker(e){jt&&jt(),e.hidden=!0;let i=this.link.closest(".comment-box"),o=i.closest(".comment-branch").cloneNode(!0),s=o.querySelectorAll(".actions, form");for(let g of s)g.remove();let r=rt("button",{type:"button",title:this.closeText});r.innerHTML=Es;let a=rt("button",{type:"button","data-action":"jump"},[this.jumpToThreadText]),l=rt("div",{class:"content-comment-window"},[rt("div",{class:"content-comment-window-actions"},[a,r]),rt("div",{class:"content-comment-window-content comment-container-compact comment-container-super-compact"},[o])]);e.parentElement?.append(l);let c=()=>{l.remove(),e.hidden=!1,window.removeEventListener("click",u),jt=null},u=g=>{e.parentElement.contains(g.target)||c()};window.addEventListener("click",u),jt=c,r.addEventListener("click",c.bind(this)),a.addEventListener("click",()=>{c(),i.scrollIntoView({behavior:"smooth"});let g=i.querySelector(".header");g.classList.add("anim-highlight"),g.addEventListener("animationend",()=>g.classList.remove("anim-highlight"))});let h=l.getBoundingClientRect(),m=document.querySelector(".page-content")?.getBoundingClientRect();if(m&&h.right>m.right){let g=h.right-m.right;l.style.left=`-${g}px`}}};var zt=class extends d{constructor(){super(...arguments);this.active=null}setup(){this.container=this.$el,this.tabList=this.container.querySelector('[role="tablist"]'),this.tabs=Array.from(this.tabList.querySelectorAll('[role="tab"]')),this.panels=Array.from(this.container.querySelectorAll(':scope > [role="tabpanel"], :scope > * > [role="tabpanel"]')),this.activeUnder=this.$opts.activeUnder?Number(this.$opts.activeUnder):1e4,this.container.addEventListener("click",e=>{let i=e.target.closest('[role="tab"]');i instanceof HTMLElement&&this.tabs.includes(i)&&this.show(i.getAttribute("aria-controls")||"")}),window.addEventListener("resize",this.updateActiveState.bind(this),{passive:!0}),this.updateActiveState()}show(e){for(let o of this.panels)o.toggleAttribute("hidden",o.id!==e);for(let o of this.tabs){let r=o.getAttribute("aria-controls")===e;o.setAttribute("aria-selected",r?"true":"false")}let i={showing:e};this.$emit("change",i)}updateActiveState(){let e=window.innerWidth<this.activeUnder;e!==this.active&&(e?this.activate():this.deactivate(),this.active=e)}activate(){let e=this.panels.find(i=>!i.hasAttribute("hidden"))||this.panels[0];this.show(e.id),this.tabList.toggleAttribute("hidden",!1)}deactivate(){for(let e of this.panels)e.removeAttribute("hidden");for(let e of this.tabs)e.setAttribute("aria-selected","false");this.tabList.toggleAttribute("hidden",!0)}};var In=class extends d{constructor(){super(...arguments);this.wysiwygEditor=null;this.parentId=null;this.contentReference="";this.formReplyText=""}setup(){this.elem=this.$el,this.pageId=Number(this.$opts.pageId),this.container=this.$refs.commentContainer,this.commentCountBar=this.$refs.commentCountBar,this.activeTab=this.$refs.activeTab,this.archivedTab=this.$refs.archivedTab,this.addButtonContainer=this.$refs.addButtonContainer,this.archiveContainer=this.$refs.archiveContainer,this.activeContainer=this.$refs.activeContainer,this.replyToRow=this.$refs.replyToRow,this.referenceRow=this.$refs.referenceRow,this.formContainer=this.$refs.formContainer,this.form=this.$refs.form,this.formInput=this.$refs.formInput,this.formReplyLink=this.$refs.formReplyLink,this.formReferenceLink=this.$refs.formReferenceLink,this.addCommentButton=this.$refs.addCommentButton,this.hideFormButton=this.$refs.hideFormButton,this.removeReplyToButton=this.$refs.removeReplyToButton,this.removeReferenceButton=this.$refs.removeReferenceButton,this.wysiwygLanguage=this.$opts.wysiwygLanguage,this.wysiwygTextDirection=this.$opts.wysiwygTextDirection,this.createdText=this.$opts.createdText,this.countText=this.$opts.countText,this.archivedCountText=this.$opts.archivedCountText,this.formReplyText=this.formReplyLink?.textContent||"",this.setupListeners()}setupListeners(){this.elem.addEventListener("page-comment-delete",()=>{setTimeout(()=>{this.updateCount(),this.hideForm()},1)}),this.elem.addEventListener("page-comment-reply",e=>{this.setReply(e.detail.id,e.detail.element)}),this.elem.addEventListener("page-comment-archive",e=>{this.archiveContainer.append(e.detail.new_thread_dom),setTimeout(()=>this.updateCount(),1)}),this.elem.addEventListener("page-comment-unarchive",e=>{this.container.append(e.detail.new_thread_dom),setTimeout(()=>this.updateCount(),1)}),this.form&&(this.removeReplyToButton.addEventListener("click",this.removeReplyTo.bind(this)),this.removeReferenceButton.addEventListener("click",()=>this.setContentReference("")),this.hideFormButton.addEventListener("click",this.hideForm.bind(this)),this.addCommentButton.addEventListener("click",this.showForm.bind(this)),this.form.addEventListener("submit",this.saveComment.bind(this)))}saveComment(e){e.preventDefault(),e.stopPropagation();let i=Bt();i.classList.add("px-l"),this.form.after(i),this.form.toggleAttribute("hidden",!0);let o={html:this.wysiwygEditor.getContent(),parent_id:this.parentId||null,content_ref:this.contentReference};window.$http.post(`/comment/${this.pageId}`,o).then(s=>{let r=Z(s.data);o.parent_id?this.formContainer.after(r):this.container.append(r);let a=window.$components.allWithinElement(r,"page-comment-reference");for(let l of a)l.showForDisplay();window.$events.success(this.createdText),this.hideForm(),this.updateCount()}).catch(s=>{this.form.toggleAttribute("hidden",!1),window.$events.showValidationErrors(s)}),this.form.toggleAttribute("hidden",!1),i.remove()}updateCount(){let e=this.getActiveThreadCount();this.activeTab.textContent=window.$trans.choice(this.countText,e);let i=this.getArchivedThreadCount();this.archivedTab.textContent=window.$trans.choice(this.archivedCountText,i)}resetForm(){this.removeEditor(),this.formInput.value="",this.parentId=null,this.replyToRow.toggleAttribute("hidden",!0),this.container.append(this.formContainer),this.setContentReference("")}showForm(){this.removeEditor(),this.formContainer.toggleAttribute("hidden",!1),this.addButtonContainer.toggleAttribute("hidden",!0),this.formContainer.scrollIntoView({behavior:"smooth",block:"nearest"}),this.loadEditor();let e=window.$components.firstOnElement(this.elem,"tabs");e instanceof zt&&this.formContainer.closest("#comment-tab-panel-active")&&e.show("comment-tab-panel-active")}hideForm(){this.resetForm(),this.formContainer.toggleAttribute("hidden",!0),this.getActiveThreadCount()>0?this.activeContainer.append(this.addButtonContainer):this.commentCountBar.append(this.addButtonContainer),this.addButtonContainer.toggleAttribute("hidden",!1)}loadEditor(){if(this.wysiwygEditor){this.wysiwygEditor.focus();return}let e=Wt({language:this.wysiwygLanguage,containerElement:this.formInput,darkMode:document.documentElement.classList.contains("dark-mode"),textDirection:this.wysiwygTextDirection,drawioUrl:"",pageId:0,translations:{},translationMap:window.editor_translations});window.tinymce.init(e).then(i=>{this.wysiwygEditor=i[0],setTimeout(()=>this.wysiwygEditor.focus(),50)})}removeEditor(){this.wysiwygEditor&&(this.wysiwygEditor.remove(),this.wysiwygEditor=null)}getActiveThreadCount(){return this.container.querySelectorAll(":scope > .comment-branch:not([hidden])").length}getArchivedThreadCount(){return this.archiveContainer.querySelectorAll(":scope > .comment-branch").length}setReply(e,i){i.closest(".comment-branch").querySelector(".comment-branch-children").append(this.formContainer),this.showForm(),this.parentId=Number(e),this.replyToRow.toggleAttribute("hidden",!1),this.formReplyLink.textContent=this.formReplyText.replace("1234",String(this.parentId)),this.formReplyLink.href=`#comment${this.parentId}`}removeReplyTo(){this.parentId=null,this.replyToRow.toggleAttribute("hidden",!0),this.container.append(this.formContainer),this.showForm()}startNewComment(e){this.resetForm(),this.showForm(),this.setContentReference(e)}setContentReference(e){this.contentReference=e,this.referenceRow.toggleAttribute("hidden",!e);let[i]=e.split(":");this.formReferenceLink.href=`#${i}`,this.formReferenceLink.onclick=function(o){o.preventDefault();let s=document.getElementById(i);s&&Lt(s)}}};function ia(n,t){ai(`#page-navigation a[href="#${n}"]`,e=>{e.closest("li").classList.toggle("current-heading",t)})}function oa(n){for(let t of n){let e=t.intersectionRatio===1;ia(t.target.id,e)}}function sa(n){let t={rootMargin:"0px 0px 0px 0px",threshold:1},e=new IntersectionObserver(oa,t);for(let i of n)e.observe(i)}var Hn=class extends d{setup(){if(this.container=this.$el,this.pageId=this.$opts.pageId,window.importVersioned("code").then(e=>e.highlight()),this.setupNavHighlighting(),window.location.hash){let e=window.location.hash.replace(/%20/g," ").substring(1);this.goToText(e)}let t=document.querySelector(".sidebar-page-nav");t&&A(t,"a","click",(e,i)=>{e.preventDefault(),window.$components.first("tri-layout").showContent();let o=i.getAttribute("href").substr(1);this.goToText(o),window.history.pushState(null,null,`#${o}`)})}goToText(t){let e=document.getElementById(t);if(ai(".page-content [data-highlighted]",i=>{i.removeAttribute("data-highlighted"),i.style.backgroundColor=null}),e!==null)Lt(e);else{let i=ao(".page-content > div > *",t);i&&Lt(i)}}setupNavHighlighting(){let t=document.querySelector(".sidebar-page-nav"),e=document.querySelector(".page-content").querySelectorAll("h1, h2, h3, h4, h5, h6");e.length>0&&t!==null&&sa(e)}};function Cs(n){let t=new Date(n*1e3),e=t.getHours(),i=t.getMinutes();return`${(e>9?"":"0")+e}:${(i>9?"":"0")+i}`}var Bn=class extends d{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.deleteDraftButton=this.$refs.deleteDraft,this.deleteDraftWrap=this.$refs.deleteDraftWrap,this.draftDisplay=this.$refs.draftDisplay,this.draftDisplayIcon=this.$refs.draftDisplayIcon,this.changelogInput=this.$refs.changelogInput,this.changelogDisplay=this.$refs.changelogDisplay,this.changeEditorButtons=this.$manyRefs.changeEditor||[],this.switchDialogContainer=this.$refs.switchDialog,this.deleteDraftDialogContainer=this.$refs.deleteDraftDialog,this.draftText=this.$opts.draftText,this.autosaveFailText=this.$opts.autosaveFailText,this.editingPageText=this.$opts.editingPageText,this.draftDiscardedText=this.$opts.draftDiscardedText,this.draftDeleteText=this.$opts.draftDeleteText,this.draftDeleteFailText=this.$opts.draftDeleteFailText,this.setChangelogText=this.$opts.setChangelogText,this.autoSave={interval:null,frequency:3e4,last:0,pendingChange:!1},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));let t=()=>{this.autoSave.pendingChange=!0};window.$events.listen("editor-html-change",t),window.$events.listen("editor-markdown-change",t),this.titleElem.addEventListener("input",t);let e=mt(this.updateChangelogDisplay.bind(this),300,!1);this.changelogInput.addEventListener("input",e),L(this.saveDraftButton,this.saveDraft.bind(this)),L(this.discardDraftButton,this.discardDraft.bind(this)),L(this.deleteDraftButton,this.deleteDraft.bind(this)),L(this.changeEditorButtons,this.changeEditor.bind(this))}setInitialFocus(){if(this.hasDefaultTitle){this.titleElem.select();return}window.setTimeout(()=>{window.$events.emit("editor::focus","")},500)}startAutoSave(){this.autoSave.interval=window.setInterval(this.runAutoSave.bind(this),this.autoSave.frequency)}runAutoSave(){Date.now()-this.autoSave.last<this.autoSave.frequency/2||!this.autoSave.pendingChange||this.saveDraft()}savePage(){this.container.closest("form").requestSubmit()}async saveDraft(){let t={name:this.titleElem.value.trim()},e=await this.getEditorComponent().getContent();Object.assign(t,e);let i=!1;try{let o=await window.$http.put(`/ajax/page/${this.pageId}/save-draft`,t);this.isNewDraft||(this.discardDraftWrap.toggleAttribute("hidden",!1),this.deleteDraftWrap.toggleAttribute("hidden",!1)),this.draftNotifyChange(`${o.data.message} ${Cs(o.data.timestamp)}`),this.autoSave.last=Date.now(),o.data.warning&&!this.shownWarningsCache.has(o.data.warning)&&(window.$events.emit("warning",o.data.warning),this.shownWarningsCache.add(o.data.warning)),i=!0,this.autoSave.pendingChange=!1}catch{try{let o=`draft-save-fail-${new Date().toISOString()}`;window.localStorage.setItem(o,JSON.stringify(t))}catch(o){console.error(o)}window.$events.emit("error",this.autosaveFailText)}return i}draftNotifyChange(t){this.draftDisplay.innerText=t,this.draftDisplayIcon.classList.add("visible"),window.setTimeout(()=>{this.draftDisplayIcon.classList.remove("visible")},2e3)}async discardDraft(t=!0){let e;try{e=await window.$http.get(`/ajax/page/${this.pageId}`)}catch(i){console.error(i);return}this.autoSave.interval&&window.clearInterval(this.autoSave.interval),this.draftDisplay.innerText=this.editingPageText,this.discardDraftWrap.toggleAttribute("hidden",!0),window.$events.emit("editor::replace",{html:e.data.html,markdown:e.data.markdown}),this.titleElem.value=e.data.name,window.setTimeout(()=>{this.startAutoSave()},1e3),t&&window.$events.success(this.draftDiscardedText)}async deleteDraft(){if(await window.$components.firstOnElement(this.deleteDraftDialogContainer,"confirm-dialog").show())try{let i=this.discardDraft(!1),o=window.$http.delete(`/page-revisions/user-drafts/${this.pageId}`);await Promise.all([i,o]),window.$events.success(this.draftDeleteText),this.deleteDraftWrap.toggleAttribute("hidden",!0)}catch(i){console.error(i),window.$events.error(this.draftDeleteFailText)}}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}async changeEditor(t){t.preventDefault();let e=t.target.closest("a").href,i=window.$components.firstOnElement(this.switchDialogContainer,"confirm-dialog"),[o,s]=await Promise.all([this.saveDraft(),i.show()]);o&&s&&(window.location=e)}getEditorComponent(){return window.$components.first("markdown-editor")||window.$components.first("wysiwyg-editor")||window.$components.first("wysiwyg-editor-tinymce")}};function Pn(n,t){n.toggleAttribute("hidden",!t)}var Rn=class extends d{setup(){this.input=this.$refs.input,this.resetButton=this.$refs.resetButton,this.selectButton=this.$refs.selectButton,this.display=this.$refs.display,this.defaultDisplay=this.$refs.defaultDisplay,this.buttonSep=this.$refs.buttonSeperator,this.selectorEndpoint=this.$opts.selectorEndpoint,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.display.addEventListener("click",t=>t.stopPropagation()),this.resetButton.addEventListener("click",()=>{this.setValue("","")})}showPopup(){window.$components.first("entity-selector-popup").show(e=>{this.setValue(e.id,e.name)},{initialValue:"",searchEndpoint:this.selectorEndpoint,entityTypes:"page",entityPermission:"view"})}setValue(t,e){this.value=t,this.input.value=t,this.controlView(e)}controlView(t){let e=this.value&&this.value!==0;if(Pn(this.resetButton,e),Pn(this.buttonSep,e),Pn(this.defaultDisplay,!e),Pn(this.display,e),e){let i=this.getAssetIdFromVal();this.display.textContent=`#${i}, ${t}`,this.display.href=window.baseUrl(`/link/${i}`)}}getAssetIdFromVal(){return Number(this.value)}};var On=class extends d{setup(){this.container=this.$el,this.cellSelector=this.$opts.cellSelector||"td,th",this.rowSelector=this.$opts.rowSelector||"tr";for(let t of this.$manyRefs.toggleAll||[])t.addEventListener("click",this.toggleAllClick.bind(this));for(let t of this.$manyRefs.toggleRow||[])t.addEventListener("click",this.toggleRowClick.bind(this));for(let t of this.$manyRefs.toggleColumn||[])t.addEventListener("click",this.toggleColumnClick.bind(this))}toggleAllClick(t){t.preventDefault(),this.toggleAllInElement(this.container)}toggleRowClick(t){t.preventDefault(),this.toggleAllInElement(t.target.closest(this.rowSelector))}toggleColumnClick(t){t.preventDefault();let e=t.target.closest(this.cellSelector),i=Array.from(e.parentElement.children).indexOf(e),o=this.container.querySelectorAll(this.rowSelector),s=[];for(let r of o){let a=r.children[i];a&&s.push(...a.querySelectorAll("input[type=checkbox]"))}this.toggleAllInputs(s)}toggleAllInElement(t){let e=t.querySelectorAll("input[type=checkbox]");this.toggleAllInputs(e)}toggleAllInputs(t){let e=t.length>0?t[0].checked:!1;for(let i of t)i.checked=!e,i.dispatchEvent(new Event("change"))}};var _n=class extends d{constructor(){super(...arguments);this.showing=!1;this.isMakingSelection=!1;this.targetElement=null;this.targetSelectionRange=null}setup(){this.pointer=this.$refs.pointer,this.linkInput=this.$refs.linkInput,this.linkButton=this.$refs.linkButton,this.includeInput=this.$refs.includeInput,this.includeButton=this.$refs.includeButton,this.sectionModeButton=this.$refs.sectionModeButton,this.commentButton=this.$refs.commentButton,this.modeToggles=this.$manyRefs.modeToggle,this.modeSections=this.$manyRefs.modeSection,this.pageId=this.$opts.pageId,this.setupListeners()}setupListeners(){this.includeButton.addEventListener("click",()=>Hi(this.includeInput.value)),this.linkButton.addEventListener("click",()=>Hi(this.linkInput.value)),L([this.includeInput,this.linkInput],i=>{i.target.select(),i.stopPropagation()}),ye(this.pointer,["click","focus"],i=>{i.stopPropagation()}),ye(document.body,["click","focus"],()=>{!this.showing||this.isMakingSelection||this.hidePointer()}),ro(this.pointer,this.hidePointer.bind(this));let e=document.querySelector(".page-content");ye(e,["mouseup","keyup"],i=>{i.stopPropagation();let o=i.target.closest('[id^="bkmrk"]');if(o instanceof HTMLElement&&(window.getSelection()||"").toString().length>0){let s=i instanceof MouseEvent?i.pageX:0;this.showPointerAtTarget(o,s,!1)}}),L(this.sectionModeButton,this.enterSectionSelectMode.bind(this)),L(this.modeToggles,i=>{let o=i.target;for(let r of this.modeSections){let a=!r.contains(o);r.toggleAttribute("hidden",!a)}let s=this.modeToggles.find(r=>r!==o);s&&s.focus()}),this.commentButton&&L(this.commentButton,this.createCommentAtPointer.bind(this))}hidePointer(){this.pointer.style.removeProperty("display"),this.showing=!1,this.targetElement=null,this.targetSelectionRange=null}showPointerAtTarget(e,i,o){this.targetElement=e,this.targetSelectionRange=window.getSelection()?.getRangeAt(0)||null,this.updateDomForTarget(e),this.pointer.style.display="block";let s=e.getBoundingClientRect(),r=this.pointer.getBoundingClientRect(),l=Math.min(Math.max(i,s.left),s.right)-r.width/2,c=s.top-r.height-16;this.pointer.style.left=`${l}px`,this.pointer.style.top=`${c}px`,this.showing=!0,this.isMakingSelection=!0,setTimeout(()=>{this.isMakingSelection=!1},100);let u=()=>{this.hidePointer(),window.removeEventListener("scroll",u)};e.parentElement?.insertBefore(this.pointer,e),o||window.addEventListener("scroll",u,{passive:!0})}updateDomForTarget(e){let i=window.baseUrl(`/link/${this.pageId}#${e.id}`),o=`{{@${this.pageId}#${e.id}}}`;this.linkInput.value=i,this.includeInput.value=o;let s=this.pointer.querySelector("#pointer-edit");if(s instanceof HTMLAnchorElement&&e){let{editHref:r}=s.dataset,a=e.id,l=(e.textContent||"").substring(0,50);s.href=`${r}?content-id=${a}&content-text=${encodeURIComponent(l)}`}}enterSectionSelectMode(){let e=Array.from(document.querySelectorAll('.page-content [id^="bkmrk"]'));for(let i of e)i.setAttribute("tabindex","0");e[0].focus(),Ht(e,i=>{this.showPointerAtTarget(i.target,0,!0),this.pointer.focus()})}createCommentAtPointer(){if(!this.targetElement)return;let e=this.targetElement.id,i=Ce(this.targetElement),o="";if(this.targetSelectionRange){let a=this.targetSelectionRange.commonAncestorContainer;if(this.targetElement.contains(a)){let l=li(this.targetSelectionRange.startContainer,this.targetSelectionRange.startOffset,this.targetElement),c=li(this.targetSelectionRange.endContainer,this.targetSelectionRange.endOffset,this.targetElement);o=`${l}-${c}`}}let s=`${e}:${i}:${o}`;window.$components.first("page-comments").startNewComment(s)}};var Nn=class extends d{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",e=>{t=e.target}),this.container.addEventListener("click",e=>{e.target===this.container&&t===this.container&&this.hide()}),L(this.hideButtons,()=>this.hide())}hide(t=null){Oo(this.container,120,t),this.onkeyup&&(window.removeEventListener("keyup",this.onkeyup),this.onkeyup=null),this.onHide&&this.onHide()}show(t=null,e=null){Ro(this.container,120,t),this.onkeyup=i=>{i.key==="Escape"&&this.hide()},window.addEventListener("keyup",this.onkeyup),this.onHide=e}};var Fn=class extends d{setup(){this.container=this.$el,this.mode=this.$opts.mode,this.lightContainer=this.$refs.lightContainer,this.darkContainer=this.$refs.darkContainer,this.container.addEventListener("tabs-change",e=>{let o=e.detail.showing==="color-scheme-panel-light"?"light":"dark";this.handleModeChange(o)});let t=e=>{this.updateAppColorsFromInputs(),e.target.name.startsWith("setting-app-color")&&this.updateLightForInput(e.target)};this.container.addEventListener("change",t),this.container.addEventListener("input",t)}handleModeChange(t){this.mode=t;let e=t==="dark";document.documentElement.classList.toggle("dark-mode",e),this.updateAppColorsFromInputs()}updateAppColorsFromInputs(){let e=(this.mode==="dark"?this.darkContainer:this.lightContainer).querySelectorAll('input[type="color"]');for(let i of e){let o=i.name.split("-"),s=o.indexOf("color"),r=o.slice(1,s).join("-");r==="app"&&(r="primary");let a=`--color-${r}`;document.body.style.setProperty(a,i.value)}}updateLightForInput(t){let e=t.name.replace("-color","-color-light"),i=t.value,o=this.hexToRgb(i),s=`rgba(${[o.r,o.g,o.b,"0.15"].join(",")})`,r=this.container.querySelector(`input[name="${e}"][type="hidden"]`);r.value=s}hexToRgb(t){let e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return{r:e?parseInt(e[1],16):0,g:e?parseInt(e[2],16):0,b:e?parseInt(e[3],16):0}}};var qn=class extends d{setup(){this.colorInput=this.$refs.input,this.resetButton=this.$refs.resetButton,this.defaultButton=this.$refs.defaultButton,this.currentColor=this.$opts.current,this.defaultColor=this.$opts.default,this.resetButton.addEventListener("click",()=>this.setValue(this.currentColor)),this.defaultButton.addEventListener("click",()=>this.setValue(this.defaultColor))}setValue(t){this.colorInput.value=t,this.colorInput.dispatchEvent(new Event("change",{bubbles:!0}))}};var Un=class extends d{setup(){this.typeControl=this.$refs.typeControl,this.pagePickerContainer=this.$refs.pagePickerContainer,this.typeControl.addEventListener("change",this.controlPagePickerVisibility.bind(this)),this.controlPagePickerVisibility()}controlPagePickerVisibility(){let t=this.typeControl.value==="page";this.pagePickerContainer.style.display=t?"block":"none"}};function Vn(n,t){return{move_up(e){let i=e.parentNode,o=Array.from(i.children).indexOf(e),s=Math.max(o-1,0);i.insertBefore(e,i.children[s]||null)},move_down(e){let i=e.parentNode,o=Array.from(i.children).indexOf(e),s=Math.min(o+2,i.children.length);i.insertBefore(e,i.children[s]||null)},remove(e){n.appendChild(e)},add(e){t.appendChild(e)}}}function Wn(n,t){return e=>{let i=e.target.closest(".scroll-box-item button[data-action]");if(i){let o=i.closest(".scroll-box-item"),s=i.dataset.action;if(!s)throw new Error("No action defined for clicked button");let r=n[s];r(o),t()}}}var jn=class extends d{setup(){this.elem=this.$el,this.input=this.$refs.input,this.shelfBookList=this.$refs.shelfBookList,this.allBookList=this.$refs.allBookList,this.bookSearchInput=this.$refs.bookSearch,this.sortButtonContainer=this.$refs.sortButtonContainer,this.lastSort=null,this.initSortable(),this.setupListeners()}initSortable(){let t=this.elem.querySelectorAll(".scroll-box");for(let e of t)new ht(e,{group:"shelf-books",ghostClass:"primary-background-light",handle:".handle",animation:150,onSort:this.onChange.bind(this)})}setupListeners(){let t=Vn(this.allBookList,this.shelfBookList),e=Wn(t,this.onChange.bind(this));this.elem.addEventListener("click",e),this.bookSearchInput.addEventListener("input",()=>{this.filterBooksByName(this.bookSearchInput.value)}),this.sortButtonContainer.addEventListener("click",i=>{let o=i.target.closest("button[data-sort]");o&&this.sortShelfBooks(o.dataset.sort)})}filterBooksByName(t){this.allBookList.style.height||(this.allBookList.style.height=`${this.allBookList.getBoundingClientRect().height}px`);let e=this.allBookList.children,i=t.trim().toLowerCase();for(let o of e){let s=!t||o.textContent.toLowerCase().includes(i);o.style.display=s?null:"none"}}onChange(){let t=Array.from(this.shelfBookList.querySelectorAll("[data-id]"));this.input.value=t.map(e=>e.getAttribute("data-id")).join(",")}sortShelfBooks(t){let e=Array.from(this.shelfBookList.children),i=t===this.lastSort;e.sort((o,s)=>{let r=o.dataset[t].toLowerCase(),a=s.dataset[t].toLowerCase();return i?a.localeCompare(r):r.localeCompare(a)});for(let o of e)this.shelfBookList.append(o);this.lastSort=this.lastSort===t?null:t,this.onChange()}};function ra(n){let t={};for(let[e,i]of Object.entries(n))t[i]=e;return t}var zn=class extends d{setup(){this.container=this.$el,this.mapById=JSON.parse(this.$opts.keyMap),this.mapByShortcut=ra(this.mapById),this.hintsShowing=!1,this.hideHints=this.hideHints.bind(this),this.hintAbortController=null,this.setupListeners()}setupListeners(){window.addEventListener("keydown",t=>{if(!t.target.closest("input, select, textarea, .cm-editor, .editor-container")){if(t.key==="?"){this.hintsShowing?this.hideHints():this.showHints();return}this.handleShortcutPress(t)}})}handleShortcutPress(t){let i=[t.ctrlKey?"Ctrl":"",t.metaKey?"Cmd":"",t.key].filter(s=>!!s).join(" + "),o=this.mapByShortcut[i];o&&this.runShortcut(o)&&t.preventDefault()}runShortcut(t){let e=this.container.querySelector(`[data-shortcut="${t}"]`);return e?e.matches("input, textarea, select")?(e.focus(),!0):e.matches("a, button")?(e.click(),!0):e.matches("div[tabindex]")?(e.click(),e.focus(),!0):(console.error("Shortcut attempted to be ran for element type that does not have handling setup",e),!1):!1}showHints(){let t=document.createElement("div");t.classList.add("shortcut-container"),this.container.append(t);let e=this.container.querySelectorAll("[data-shortcut]"),i=new Set;for(let s of e){let r=s.getAttribute("data-shortcut");if(i.has(r))continue;let a=this.mapById[r];this.showHintLabel(s,a,t),i.add(r)}this.hintAbortController=new AbortController;let o=this.hintAbortController.signal;window.addEventListener("scroll",this.hideHints,{signal:o}),window.addEventListener("focus",this.hideHints,{signal:o}),window.addEventListener("blur",this.hideHints,{signal:o}),window.addEventListener("click",this.hideHints,{signal:o}),this.hintsShowing=!0}showHintLabel(t,e,i){let o=t.getBoundingClientRect(),s=document.createElement("div");s.classList.add("shortcut-hint"),s.textContent=e;let r=document.createElement("div");r.classList.add("shortcut-linkage"),r.style.left=`${o.x}px`,r.style.top=`${o.y}px`,r.style.width=`${o.width}px`,r.style.height=`${o.height}px`,i.append(s,r);let a=s.getBoundingClientRect();s.style.insetInlineStart=`${o.x+o.width-(a.width+6)}px`,s.style.insetBlockStart=`${o.y+(o.height-a.height)/2}px`}hideHints(){this.container.querySelector(".shortcut-container").remove(),this.hintAbortController?.abort(),this.hintsShowing=!1}};var aa=["Control","Alt","Shift","Meta","Super"," ","+","Tab","Escape"],Kn=class extends d{setup(){this.input=this.$el,this.setupListeners()}setupListeners(){this.listenerRecordKey=this.listenerRecordKey.bind(this),this.input.addEventListener("focus",()=>{this.startListeningForInput()}),this.input.addEventListener("blur",()=>{this.stopListeningForInput()})}startListeningForInput(){this.input.addEventListener("keydown",this.listenerRecordKey)}listenerRecordKey(t){if(aa.includes(t.key))return;let e=[t.ctrlKey?"Ctrl":"",t.metaKey?"Cmd":"",t.key];this.input.value=e.filter(i=>!!i).join(" + ")}stopListeningForInput(){this.input.removeEventListener("keydown",this.listenerRecordKey)}};var Xn=class extends d{setup(){this.container=this.$el,this.handleSelector=this.$opts.handleSelector;let t=new ht(this.container,{handle:this.handleSelector,animation:150,onSort:()=>{this.$emit("sort",{ids:t.toArray()})},setData(e,i){let o=i.getAttribute("data-drag-content");if(o){let s=JSON.parse(o);for(let[r,a]of Object.entries(s))e.setData(r,a)}},revertOnSpill:!0,dropBubble:!0,dragoverBubble:!1})}};var Gn=class extends d{setup(){this.input=this.$refs.input,this.configuredList=this.$refs.configuredOperationsList,this.availableList=this.$refs.availableOperationsList,this.initSortable();let t=Vn(this.availableList,this.configuredList),e=Wn(t,this.onChange.bind(this));this.$el.addEventListener("click",e)}initSortable(){let t=[this.configuredList,this.availableList];for(let e of t)new ht(e,{group:"sort-rule-operations",ghostClass:"primary-background-light",handle:".handle",animation:150,onSort:this.onChange.bind(this)})}onChange(){let t=Array.from(this.configuredList.querySelectorAll("[data-id]"));this.input.value=t.map(e=>e.getAttribute("data-id")).join(",")}};var Yn=class extends d{setup(){this.filter=this.$opts.filter,this.$el.addEventListener("change",t=>{if(this.filter&&!t.target.matches(this.filter))return;let e=this.$el.closest("form");e&&e.submit()})}};var Jn=class extends d{setup(){this.addRemoveComponentEl=this.$refs.addRemove,this.container=this.$el,this.rowSelector=this.$opts.rowSelector,this.setupListeners()}setupListeners(){this.container.addEventListener("input",t=>{let e=window.$components.firstOnElement(this.addRemoveComponentEl,"add-remove-rows");!this.hasEmptyRows()&&t.target.value&&e.add()})}hasEmptyRows(){return[...this.container.querySelectorAll(this.rowSelector)].find(i=>[...i.querySelectorAll("input")].filter(o=>o.value).length===0)!==void 0}};var Zn=class extends d{setup(){this.container=this.$el,this.list=this.$refs.list,this.searchInput=this.$refs.searchInput,this.searchButton=this.$refs.searchButton,this.searchCancel=this.$refs.searchCancel,this.setupListeners()}setupListeners(){A(this.container,"[template-action]","click",this.handleTemplateActionClick.bind(this)),A(this.container,".pagination a","click",this.handlePaginationClick.bind(this)),A(this.container,".template-item-content","click",this.handleTemplateItemClick.bind(this)),A(this.container,".template-item","dragstart",this.handleTemplateItemDragStart.bind(this)),this.searchInput.addEventListener("keypress",t=>{t.key==="Enter"&&(t.preventDefault(),this.performSearch())}),this.searchButton.addEventListener("click",()=>this.performSearch()),this.searchCancel.addEventListener("click",()=>{this.searchInput.value="",this.performSearch()})}handleTemplateItemClick(t,e){let i=e.closest("[template-id]").getAttribute("template-id");this.insertTemplate(i,"replace")}handleTemplateItemDragStart(t,e){let i=e.closest("[template-id]").getAttribute("template-id");t.dataTransfer.setData("bookstack/template",i),t.dataTransfer.setData("text/plain",i)}handleTemplateActionClick(t,e){t.stopPropagation();let i=e.getAttribute("template-action"),o=e.closest("[template-id]").getAttribute("template-id");this.insertTemplate(o,i)}async insertTemplate(t,e="replace"){let i=await window.$http.get(`/templates/${t}`),o=`editor::${e}`;window.$events.emit(o,i.data)}async handlePaginationClick(t,e){t.preventDefault();let i=e.getAttribute("href"),o=await window.$http.get(i);this.list.innerHTML=o.data}async performSearch(){let t=this.searchInput.value,e=await window.$http.get("/templates",{search:t});this.searchCancel.style.display=t?"block":"none",this.list.innerHTML=e.data}};var Qn=class extends d{setup(){this.input=this.$el.querySelector("input[type=hidden]"),this.checkbox=this.$el.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)}};var ti=class extends d{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",()=>{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{tab:e}=t.target.dataset;this.showTab(e)}showContent(){this.showTab("content",!1)}showTab(t,e=!0){this.scrollCache[this.lastTabShown]=document.documentElement.scrollTop;for(let o of this.tabs){let s=o.dataset.tab===t;o.setAttribute("aria-selected",s?"true":"false")}let i=t==="info";if(this.container.classList.toggle("show-info",i),e){let s=document.querySelector("header").getBoundingClientRect().bottom;document.documentElement.scrollTop=this.scrollCache[t]||s,setTimeout(()=>{document.documentElement.scrollTop=this.scrollCache[t]||s},50)}this.lastTabShown=t}};var ei=class extends d{setup(){this.container=this.$el,this.input=this.$refs.input,this.userInfoContainer=this.$refs.userInfo,A(this.container,"a.dropdown-search-item","click",this.selectUser.bind(this))}selectUser(t,e){t.preventDefault(),this.input.value=e.getAttribute("data-id"),this.userInfoContainer.innerHTML=e.innerHTML,this.input.dispatchEvent(new Event("change",{bubbles:!0})),this.hide()}hide(){window.$components.firstOnElement(this.container,"dropdown").hide()}};var ni=class extends d{setup(){this.checkboxes=this.$el.querySelectorAll('input[type="checkbox"]'),this.allCheckbox=this.$el.querySelector('input[type="checkbox"][value="all"]'),this.$el.addEventListener("change",t=>{t.target.checked&&t.target===this.allCheckbox?this.deselectIndividualEvents():t.target.checked&&(this.allCheckbox.checked=!1)})}deselectIndividualEvents(){for(let t of this.checkboxes)t!==this.allCheckbox&&(t.checked=!1)}};var ii=class extends d{setup(){this.elem=this.$el,this.editContainer=this.$refs.editContainer,this.input=this.$refs.input,this.editor=null;let t={...window.editor_translations,imageUploadErrorText:this.$opts.imageUploadErrorText,serverUploadLimitText:this.$opts.serverUploadLimitText};window.importVersioned("wysiwyg").then(i=>{let o=this.input.value;this.editor=i.createPageEditorInstance(this.editContainer,o,{drawioUrl:this.getDrawIoUrl(),pageId:Number(this.$opts.pageId),darkMode:document.documentElement.classList.contains("dark-mode"),textDirection:this.$opts.textDirection,translations:t}),window.wysiwyg=this.editor});let e=!1;this.input.form.addEventListener("submit",i=>{this.editor&&(e?e=!1:(i.preventDefault(),e=!0,this.editor.getContentAsHtml().then(o=>{this.input.value=o,setTimeout(()=>{this.input.form.requestSubmit()},5)})))})}getDrawIoUrl(){let t=document.querySelector("[drawio-url]");return t?t.getAttribute("drawio-url"):""}async getContent(){return{html:await this.editor.getContentAsHtml()}}};var oi=class extends d{setup(){this.elem=this.$el,this.tinyMceConfig=bs({language:this.$opts.language,containerElement:this.elem,darkMode:document.documentElement.classList.contains("dark-mode"),textDirection:this.$opts.textDirection,drawioUrl:this.getDrawIoUrl(),pageId:Number(this.$opts.pageId),translations:{imageUploadErrorText:this.$opts.imageUploadErrorText,serverUploadLimitText:this.$opts.serverUploadLimitText},translationMap:window.editor_translations}),window.$events.emitPublic(this.elem,"editor-tinymce::pre-init",{config:this.tinyMceConfig}),window.tinymce.init(this.tinyMceConfig).then(t=>{this.editor=t[0]})}getDrawIoUrl(){let t=document.querySelector("[drawio-url]");return t?t.getAttribute("drawio-url"):""}async getContent(){return{html:this.editor.getContent()}}};var si=class extends d{setup(){this.elem=this.$el;let t=Wt({language:this.$opts.language,containerElement:this.elem,darkMode:document.documentElement.classList.contains("dark-mode"),textDirection:this.$opts.textDirection,translations:{},translationMap:window.editor_translations});window.tinymce.init(t).then(e=>{this.editor=e[0]})}};function Xi(n){let t=i=>i.slice(0,1).toUpperCase()+i.slice(1),e=n.split("-");return e[0]+e.slice(1).map(t).join("")}function xs(n){return n.replace(/[A-Z]/g,(t,e)=>(e>0?"-":"")+t.toLowerCase())}function la(n,t){let e={},i={},o=`${n}@`,s=`[refs*="${o}"]`,r=[...t.querySelectorAll(s)];t.matches(s)&&r.push(t);for(let a of r){let l=(a.getAttribute("refs")||"").split(" ").filter(c=>c.startsWith(o)).map(c=>c.replace(o,"")).map(Xi);for(let c of l)e[c]=a,typeof i[c]>"u"&&(i[c]=[]),i[c].push(a)}return{refs:e,manyRefs:i}}function ca(n,t){let e={},i=`option:${n}:`;for(let{name:o,value:s}of t.attributes)if(o.startsWith(i)){let r=o.replace(i,"");e[Xi(r)]=s||""}return e}var ri=class{constructor(){this.components={};this.componentModelMap={};this.elementComponentMap=new WeakMap}initComponent(t,e){let i=this.componentModelMap[t];if(i===void 0)return;let o=null;try{o=new i,o.$name=t,o.$el=e;let r=la(t,e);o.$refs=r.refs,o.$manyRefs=r.manyRefs,o.$opts=ca(t,e),o.setup()}catch(r){console.error("Failed to create component",r,t,e)}if(!o)return;typeof this.components[t]>"u"&&(this.components[t]=[]),this.components[t].push(o);let s=this.elementComponentMap.get(e)||{};s[t]=o,this.elementComponentMap.set(e,s)}init(t=document){let e=t.querySelectorAll("[component],[components]");for(let i of e){let o=`${i.getAttribute("component")||""} ${i.getAttribute("components")}`.toLowerCase().split(" ").filter(Boolean);for(let s of o)this.initComponent(s,i)}}register(t){let e=Object.keys(t);for(let i of e)this.componentModelMap[xs(i)]=t[i]}first(t){return(this.components[t]||[null])[0]}get(t){return this.components[t]||[]}firstOnElement(t,e){return(this.elementComponentMap.get(t)||{})[e]||null}allWithinElement(t,e){return this.get(e).filter(o=>t.contains(o.$el))}};window.__DEV__=!1;window.baseUrl=no;window.importVersioned=io;window.$http=new we;window.$events=new ve;window.$trans=new be;window.$components=new ri;window.$components.register(Ki);window.$components.init();
/*! Bundled license information:
sortablejs/modular/sortable.esm.js:
(**!
* Sortable 1.15.6
* @author RubaXa <trash@rubaxa.org>
* @author owenm <owen23355@gmail.com>
* @license MIT
*)
*/
//# sourceMappingURL=app.js.map