From: Dan Brown
1?g-1:0),P=1;P
1?g-1:0),P=1;P ',"1114111?f+="\uFFFD\uFFFD\uFFFD\uFFFD":(c-=65536,f+=String.fromCharCode(55296+(c>>10),56320+(c&1023))),o+=9;continue}f+="\uFFFD"}return f})}vn.defaultChars=";/?:@&=+$,#";vn.componentChars="";Fs.exports=vn});var Ps=ie((ig,Os)=>{"use strict";Os.exports=function(e){var t="";return t+=e.protocol||"",t+=e.slashes?"//":"",t+=e.auth?e.auth+"@":"",e.hostname&&e.hostname.indexOf(":")!==-1?t+="["+e.hostname+"]":t+=e.hostname||"",t+=e.port?":"+e.port:"",t+=e.pathname||"",t+=e.search||"",t+=e.hash||"",t}});var zs=ie((og,Us)=>{"use strict";function yn(){this.protocol=null,this.slashes=null,this.auth=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.pathname=null}var Xd=/^([a-z0-9.+-]+:)/i,Zd=/:[0-9]*$/,Qd=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,Jd=["<",">",'"',"`"," ","\r",`
-`," "],ef=["{","}","|","\\","^","`"].concat(Jd),tf=["'"].concat(ef),Ms=["%","/","?",";","#"].concat(tf),Ns=["/","?","#"],rf=255,_s=/^[+a-z0-9A-Z_-]{0,63}$/,nf=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,Bs={javascript:!0,"javascript:":!0},$s={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};function of(r,e){if(r&&r instanceof yn)return r;var t=new yn;return t.parse(r,e),t}yn.prototype.parse=function(r,e){var t,n,o,s,i,a=r;if(a=a.trim(),!e&&r.split("#").length===1){var l=Qd.exec(a);if(l)return this.pathname=l[1],l[2]&&(this.search=l[2]),this}var u=Xd.exec(a);if(u&&(u=u[0],o=u.toLowerCase(),this.protocol=u,a=a.substr(u.length)),(e||u||a.match(/^\/\/[^@\/]+@[^@\/]+/))&&(i=a.substr(0,2)==="//",i&&!(u&&Bs[u])&&(a=a.substr(2),this.slashes=!0)),!Bs[u]&&(i||u&&!$s[u])){var c=-1;for(t=0;t"+Jt(r[e].content)+"
"};Rt.code_block=function(r,e,t,n,o){var s=r[e];return"
-`};Rt.fence=function(r,e,t,n,o){var s=r[e],i=s.info?Rf(s.info).trim():"",a="",l="",u,c,f,d,h;return i&&(f=i.split(/(\s+)/g),a=f[0],l=f.slice(2).join("")),t.highlight?u=t.highlight(s.content,a,l)||Jt(s.content):u=Jt(s.content),u.indexOf(""+Jt(r[e].content)+`
>4,g=($&15)<<4|U>>2,C=(U&3)<<6|Y,G.push(p),U!==64&&G.push(g),Y!==64&&G.push(C),p=g=C="",P=$=U=Y="",Z
1114111?f+="\uFFFD\uFFFD\uFFFD\uFFFD":(c-=65536,f+=String.fromCharCode(55296+(c>>10),56320+(c&1023))),o+=9;continue}f+="\uFFFD"}return f})}vn.defaultChars=";/?:@&=+$,#";vn.componentChars="";Fs.exports=vn});var Ps=ie((hg,Os)=>{"use strict";Os.exports=function(e){var t="";return t+=e.protocol||"",t+=e.slashes?"//":"",t+=e.auth?e.auth+"@":"",e.hostname&&e.hostname.indexOf(":")!==-1?t+="["+e.hostname+"]":t+=e.hostname||"",t+=e.port?":"+e.port:"",t+=e.pathname||"",t+=e.search||"",t+=e.hash||"",t}});var zs=ie((pg,Us)=>{"use strict";function yn(){this.protocol=null,this.slashes=null,this.auth=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.pathname=null}var Qd=/^([a-z0-9.+-]+:)/i,Jd=/:[0-9]*$/,ef=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,tf=["<",">",'"',"`"," ","\r",`
+`," "],rf=["{","}","|","\\","^","`"].concat(tf),nf=["'"].concat(rf),Ms=["%","/","?",";","#"].concat(nf),Ns=["/","?","#"],of=255,_s=/^[+a-z0-9A-Z_-]{0,63}$/,sf=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,Bs={javascript:!0,"javascript:":!0},$s={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};function af(r,e){if(r&&r instanceof yn)return r;var t=new yn;return t.parse(r,e),t}yn.prototype.parse=function(r,e){var t,n,o,s,i,a=r;if(a=a.trim(),!e&&r.split("#").length===1){var l=ef.exec(a);if(l)return this.pathname=l[1],l[2]&&(this.search=l[2]),this}var u=Qd.exec(a);if(u&&(u=u[0],o=u.toLowerCase(),this.protocol=u,a=a.substr(u.length)),(e||u||a.match(/^\/\/[^@\/]+@[^@\/]+/))&&(i=a.substr(0,2)==="//",i&&!(u&&Bs[u])&&(a=a.substr(2),this.slashes=!0)),!Bs[u]&&(i||u&&!$s[u])){var c=-1;for(t=0;t"+Jt(r[e].content)+"
"};Rt.code_block=function(r,e,t,n,o){var s=r[e];return"
+`};Rt.fence=function(r,e,t,n,o){var s=r[e],i=s.info?Pf(s.info).trim():"",a="",l="",u,c,f,d,h;return i&&(f=i.split(/(\s+)/g),a=f[0],l=f.slice(2).join("")),t.highlight?u=t.highlight(s.content,a,l)||Jt(s.content):u=Jt(s.content),u.indexOf(""+Jt(r[e].content)+`
`):""+u+`
`};Rt.image=function(r,e,t,n,o){var s=r[e];return s.attrs[s.attrIndex("alt")][1]=o.renderInlineAsText(s.children,t,n),o.renderToken(r,e,t)};Rt.hardbreak=function(r,e,t){return t.xhtmlOut?`"+u+`
@@ -16,22 +16,24 @@ Expect errors in decoding.`),E=E.replace(/[^A-Za-z0-9\+\/\=]/g,"");P=this.KEY_ST
`};Rt.softbreak=function(r,e,t){return t.breaks?t.xhtmlOut?`
`:`
`:`
-`};Rt.text=function(r,e){return Jt(r[e].content)};Rt.html_block=function(r,e){return r[e].content};Rt.html_inline=function(r,e){return r[e].content};function mr(){this.rules=Ff({},Rt)}mr.prototype.renderAttrs=function(e){var t,n,o;if(!e.attrs)return"";for(o="",t=0,n=e.attrs.length;t{"use strict";var Mf=Ne().arrayReplaceAt;function Nf(r){return/^\s]/i.test(r)}function _f(r){return/^<\/a\s*>/i.test(r)}ga.exports=function(e){var t,n,o,s,i,a,l,u,c,f,d,h,m,v,y,w,x=e.tokens,D;if(!!e.md.options.linkify){for(n=0,o=x.length;n=4||e.listIndent>=0&&e.sCount[t]-e.listIndent>=4&&e.sCount[t]{"use strict";Sl.exports=function(e,t){var n,o,s,i,a,l,u,c,f=e.pos,d=e.src.charCodeAt(f);if(d!==96)return!1;for(n=f,f++,o=e.posMax;f=s:i=o<=s,!i)return n;if(n===Lt())break;n=Wt(n,!1)}return!1}function cr(r,e,t,n){for(var o=0,s=0,i=r.children;sn.right+o||r.clientX<=n.right&&r.clientY>n.bottom&&r.clientX>=n.left:r.clientX>n.right&&r.clientY>n.top||r.clientX<=n.right&&r.clientY>n.bottom+o}function jd(r,e,t,n,o,s,i,a){var l=n?r.clientY:r.clientX,u=n?t.height:t.width,c=n?t.top:t.left,f=n?t.bottom:t.right,d=!1;if(!i){if(a&&enc+u*s/2:l{"use strict";var _f=Ne().arrayReplaceAt;function Bf(r){return/^\s]/i.test(r)}function $f(r){return/^<\/a\s*>/i.test(r)}ga.exports=function(e){var t,n,o,s,i,a,l,u,c,f,d,h,m,v,y,w,x=e.tokens,D;if(!!e.md.options.linkify){for(n=0,o=x.length;n=4||e.listIndent>=0&&e.sCount[t]-e.listIndent>=4&&e.sCount[t]{"use strict";Sl.exports=function(e,t){var n,o,s,i,a,l,u,c,f=e.pos,d=e.src.charCodeAt(f);if(d!==96)return!1;for(n=f,f++,o=e.posMax;f
',"
")},e.setOption("extraKeys",o),e.on("change",(d,h)=>{this.updateAndRender()});let s=Sr(d=>{let h=d.getScrollInfo();if(h.top+h.clientHeight===h.height){this.onMarkdownScroll(-1);return}let v=d.lineAtHeight(h.top,"local"),y=d.getRange({line:0,ch:null},{line:v,ch:null}),D=new DOMParser().parseFromString(this.markdown.render(y),"text/html").documentElement.querySelectorAll("body > *");this.onMarkdownScroll(D.length)},100);e.on("scroll",d=>{s(d)}),e.on("paste",(d,h)=>{let m=new $r(h.clipboardData||h.dataTransfer);if(!m.hasItems()||m.containsTabularData())return;let v=m.getImages();for(let y of v)c(y)}),e.on("drop",(d,h)=>{let m=h.dataTransfer.getData("bookstack/template");if(m){let y=d.coordsChar({left:h.pageX,top:h.pageY});d.setCursor(y),h.preventDefault(),window.$http.get(`/templates/${m}`).then(w=>{let x=w.data.markdown||w.data.html;d.replaceSelection(x)})}let v=new $r(h.dataTransfer);if(v.hasItems()&&v.getImages().length>0){let y=d.coordsChar({left:h.pageX,top:h.pageY});d.setCursor(y),h.stopPropagation(),h.preventDefault();let w=v.getImages();for(let x of w)c(x)}});function i(d,h){let m=e.getValue(),v=e.listSelections();e.setValue(m.replace(d,h)),e.setSelections(v)}function a(d){let h=e.getCursor(),m=e.getLine(h.line),v=m.length,y=m.split(" ")[0];if(y===d){m=m.replace(`${d} `,""),e.replaceRange(m,{line:h.line,ch:0},{line:h.line,ch:v}),e.setCursor({line:h.line,ch:h.ch-(d.length+1)});return}let w=/^[#>`]/.test(y),x=0;w?(x=d.length-y.length,m=m.replace(y,d).trim()):d!==""&&(x=d.length+1,m=d+" "+m),e.replaceRange(m,{line:h.line,ch:0},{line:h.line,ch:v}),e.setCursor({line:h.line,ch:h.ch+x})}function l(d,h){let m=e.getCursor(),v=e.getLine(m.line),y=v.length,w=v;v.indexOf(d)===0&&v.slice(-h.length)===h?w=v.slice(d.length,v.length-h.length):w=`${d}${v}${h}`,e.replaceRange(w,{line:m.line,ch:0},{line:m.line,ch:y}),e.setCursor({line:m.line,ch:m.ch+d.length})}function u(d,h){let m=e.getSelection();if(m==="")return l(d,h);let v=m,y=0,w=0;m.indexOf(d)===0&&m.slice(-h.length)===h?(v=m.slice(d.length,m.length-h.length),w=-(h.length+d.length)):(v=`${d}${m}${h}`,w=d.length+h.length);let x=e.listSelections()[0];e.replaceSelection(v);let D=x.head.ch<=x.anchor.ch;x.head.ch+=D?y:w,x.anchor.ch+=D?w:y,e.setSelections([x])}function c(d){if(d===null||d.type.indexOf("image")!==0)return;let h="png";if(d.name){let N=d.name.match(/\.(.+)$/);N.length>1&&(h=N[1])}let m="image-"+Math.random().toString(16).slice(2),v=window.baseUrl(`/loading.gif#upload${m}`),y=e.getSelection(),w=``,x=e.getCursor();e.replaceSelection(w),e.setCursor({line:x.line,ch:x.ch+y.length+3});let D="image-"+Date.now()+"."+h,I=new FormData;I.append("file",d,D),I.append("uploaded_to",t.pageId),window.$http.post("/images/gallery",I).then(N=>{let S=`[](${N.data.url})`;i(w,S)}).catch(N=>{window.$events.emit("error",t.imageUploadErrorText),i(w,y),console.log(N)})}function f(){let d=e.getCursor("from"),h=e.getSelection()||"",m=`[${h}]()`;e.focus(),e.replaceSelection(m);let v=h===""?-3:-1;e.setCursor(d.line,d.ch+m.length+v)}this.updateAndRender()}actionInsertImage(){let e=this.cm.getCursor("from");window.ImageManager.show(t=>{let n=t.thumbs.display||t.url,o=this.cm.getSelection(),s="[]("+t.url+")";this.cm.focus(),this.cm.replaceSelection(s),this.cm.setCursor(e.line,e.ch+s.length)},"gallery")}actionShowImageManager(){let e=this.cm.getCursor("from");window.ImageManager.show(t=>{this.insertDrawing(t,e)},"drawio")}actionShowLinkSelector(){let e=this.cm.getCursor("from");window.EntitySelectorPopup.show(t=>{let o=`[${this.cm.getSelection()||t.name}](${t.link})`;this.cm.focus(),this.cm.replaceSelection(o),this.cm.setCursor(e.line,e.ch+o.length)})}getDrawioUrl(){let e=document.querySelector("[drawio-url]");return e?e.getAttribute("drawio-url"):!1}actionStartDrawing(){let e=this.getDrawioUrl();if(!e)return;let t=this.cm.getCursor("from");vt.show(e,()=>Promise.resolve(""),n=>{let o={image:n,uploaded_to:Number(this.pageId)};window.$http.post("/images/drawio",o).then(s=>{this.insertDrawing(s.data,t),vt.close()}).catch(s=>{this.handleDrawingUploadError(s)})})}insertDrawing(e,t){let n=`