-`);return i};bt.prototype.render=function(n,e,t){var i,r,o,s="",a=this.rules;for(i=0,r=n.length;i<r;i++)o=n[i].type,o==="inline"?s+=this.renderInline(n[i].children,e,t):typeof a[o]<"u"?s+=a[n[i].type](n,i,e,t,this):s+=this.renderToken(n,i,e,t);return s};ma.exports=bt});var ui=_((Vb,ba)=>{"use strict";function Ce(){this.__rules__=[],this.__cache__=null}Ce.prototype.__find__=function(n){for(var e=0;e<this.__rules__.length;e++)if(this.__rules__[e].name===n)return e;return-1};Ce.prototype.__compile__=function(){var n=this,e=[""];n.__rules__.forEach(function(t){t.enabled&&t.alt.forEach(function(i){e.indexOf(i)<0&&e.push(i)})}),n.__cache__={},e.forEach(function(t){n.__cache__[t]=[],n.__rules__.forEach(function(i){i.enabled&&(t&&i.alt.indexOf(t)<0||n.__cache__[t].push(i.fn))})})};Ce.prototype.at=function(n,e,t){var i=this.__find__(n),r=t||{};if(i===-1)throw new Error("Parser rule not found: "+n);this.__rules__[i].fn=e,this.__rules__[i].alt=r.alt||[],this.__cache__=null};Ce.prototype.before=function(n,e,t,i){var r=this.__find__(n),o=i||{};if(r===-1)throw new Error("Parser rule not found: "+n);this.__rules__.splice(r,0,{name:e,enabled:!0,fn:t,alt:o.alt||[]}),this.__cache__=null};Ce.prototype.after=function(n,e,t,i){var r=this.__find__(n),o=i||{};if(r===-1)throw new Error("Parser rule not found: "+n);this.__rules__.splice(r+1,0,{name:e,enabled:!0,fn:t,alt:o.alt||[]}),this.__cache__=null};Ce.prototype.push=function(n,e,t){var i=t||{};this.__rules__.push({name:n,enabled:!0,fn:e,alt:i.alt||[]}),this.__cache__=null};Ce.prototype.enable=function(n,e){Array.isArray(n)||(n=[n]);var t=[];return n.forEach(function(i){var r=this.__find__(i);if(r<0){if(e)return;throw new Error("Rules manager: invalid rule name "+i)}this.__rules__[r].enabled=!0,t.push(i)},this),this.__cache__=null,t};Ce.prototype.enableOnly=function(n,e){Array.isArray(n)||(n=[n]),this.__rules__.forEach(function(t){t.enabled=!1}),this.enable(n,e)};Ce.prototype.disable=function(n,e){Array.isArray(n)||(n=[n]);var t=[];return n.forEach(function(i){var r=this.__find__(i);if(r<0){if(e)return;throw new Error("Rules manager: invalid rule name "+i)}this.__rules__[r].enabled=!1,t.push(i)},this),this.__cache__=null,t};Ce.prototype.getRules=function(n){return this.__cache__===null&&this.__compile__(),this.__cache__[n]||[]};ba.exports=Ce});var wa=_((Wb,va)=>{"use strict";var wd=/\r\n?|\n/g,yd=/\0/g;va.exports=function(e){var t;t=e.src.replace(wd,`
-`),t=t.replace(yd,"\uFFFD"),e.src=t}});var xa=_((Gb,ya)=>{"use strict";ya.exports=function(e){var t;e.inlineMode?(t=new e.Token("inline","",0),t.content=e.src,t.map=[0,1],t.children=[],e.tokens.push(t)):e.md.block.parse(e.src,e.md,e.env,e.tokens)}});var Ca=_((Kb,ka)=>{"use strict";ka.exports=function(e){var t=e.tokens,i,r,o;for(r=0,o=t.length;r<o;r++)i=t[r],i.type==="inline"&&e.md.inline.parse(i.content,e.md,e.env,i.children)}});var _a=_((Zb,Ea)=>{"use strict";var xd=R().arrayReplaceAt;function kd(n){return/^<a[>\s]/i.test(n)}function Cd(n){return/^<\/a\s*>/i.test(n)}Ea.exports=function(e){var t,i,r,o,s,a,l,c,u,h,d,p,f,m,y,v,b=e.tokens,k;if(e.md.options.linkify){for(i=0,r=b.length;i<r;i++)if(!(b[i].type!=="inline"||!e.md.linkify.pretest(b[i].content)))for(o=b[i].children,f=0,t=o.length-1;t>=0;t--){if(a=o[t],a.type==="link_close"){for(t--;o[t].level!==a.level&&o[t].type!=="link_open";)t--;continue}if(a.type==="html_inline"&&(kd(a.content)&&f>0&&f--,Cd(a.content)&&f++),!(f>0)&&a.type==="text"&&e.md.linkify.test(a.content)){for(u=a.content,k=e.md.linkify.match(u),l=[],p=a.level,d=0,k.length>0&&k[0].index===0&&t>0&&o[t-1].type==="text_special"&&(k=k.slice(1)),c=0;c<k.length;c++)m=k[c].url,y=e.md.normalizeLink(m),e.md.validateLink(y)&&(v=k[c].text,k[c].schema?k[c].schema==="mailto:"&&!/^mailto:/i.test(v)?v=e.md.normalizeLinkText("mailto:"+v).replace(/^mailto:/,""):v=e.md.normalizeLinkText(v):v=e.md.normalizeLinkText("http://"+v).replace(/^http:\/\//,""),h=k[c].index,h>d&&(s=new e.Token("text","",0),s.content=u.slice(d,h),s.level=p,l.push(s)),s=new e.Token("link_open","a",1),s.attrs=[["href",y]],s.level=p++,s.markup="linkify",s.info="auto",l.push(s),s=new e.Token("text","",0),s.content=v,s.level=p,l.push(s),s=new e.Token("link_close","a",-1),s.level=--p,s.markup="linkify",s.info="auto",l.push(s),d=k[c].lastIndex);d<u.length&&(s=new e.Token("text","",0),s.content=u.slice(d),s.level=p,l.push(s)),b[i].children=o=xd(o,t,l)}}}}});var Da=_((Xb,Aa)=>{"use strict";var Sa=/\+-|\.\.|\?\?\?\?|!!!!|,,|--/,Ed=/\((c|tm|r)\)/i,_d=/\((c|tm|r)\)/ig,Sd={c:"\xA9",r:"\xAE",tm:"\u2122"};function Ad(n,e){return Sd[e.toLowerCase()]}function Dd(n){var e,t,i=0;for(e=n.length-1;e>=0;e--)t=n[e],t.type==="text"&&!i&&(t.content=t.content.replace(_d,Ad)),t.type==="link_open"&&t.info==="auto"&&i--,t.type==="link_close"&&t.info==="auto"&&i++}function Td(n){var e,t,i=0;for(e=n.length-1;e>=0;e--)t=n[e],t.type==="text"&&!i&&Sa.test(t.content)&&(t.content=t.content.replace(/\+-/g,"\xB1").replace(/\.{2,}/g,"\u2026").replace(/([?!])…/g,"$1..").replace(/([?!]){4,}/g,"$1$1$1").replace(/,{2,}/g,",").replace(/(^|[^-])---(?=[^-]|$)/mg,"$1\u2014").replace(/(^|\s)--(?=\s|$)/mg,"$1\u2013").replace(/(^|[^-\s])--(?=[^-\s]|$)/mg,"$1\u2013")),t.type==="link_open"&&t.info==="auto"&&i--,t.type==="link_close"&&t.info==="auto"&&i++}Aa.exports=function(e){var t;if(e.md.options.typographer)for(t=e.tokens.length-1;t>=0;t--)e.tokens[t].type==="inline"&&(Ed.test(e.tokens[t].content)&&Dd(e.tokens[t].children),Sa.test(e.tokens[t].content)&&Td(e.tokens[t].children))}});var qa=_((Yb,Fa)=>{"use strict";var Ta=R().isWhiteSpace,La=R().isPunctChar,Ia=R().isMdAsciiPunct,Ld=/['"]/,$a=/['"]/g,Ma="\u2019";function hi(n,e,t){return n.slice(0,e)+t+n.slice(e+1)}function Id(n,e){var t,i,r,o,s,a,l,c,u,h,d,p,f,m,y,v,b,k,w,E,x;for(w=[],t=0;t<n.length;t++){for(i=n[t],l=n[t].level,b=w.length-1;b>=0&&!(w[b].level<=l);b--);if(w.length=b+1,i.type==="text"){r=i.content,s=0,a=r.length;e:for(;s<a&&($a.lastIndex=s,o=$a.exec(r),!!o);){if(y=v=!0,s=o.index+1,k=o[0]==="'",u=32,o.index-1>=0)u=r.charCodeAt(o.index-1);else for(b=t-1;b>=0&&!(n[b].type==="softbreak"||n[b].type==="hardbreak");b--)if(n[b].content){u=n[b].content.charCodeAt(n[b].content.length-1);break}if(h=32,s<a)h=r.charCodeAt(s);else for(b=t+1;b<n.length&&!(n[b].type==="softbreak"||n[b].type==="hardbreak");b++)if(n[b].content){h=n[b].content.charCodeAt(0);break}if(d=Ia(u)||La(String.fromCharCode(u)),p=Ia(h)||La(String.fromCharCode(h)),f=Ta(u),m=Ta(h),m?y=!1:p&&(f||d||(y=!1)),f?v=!1:d&&(m||p||(v=!1)),h===34&&o[0]==='"'&&u>=48&&u<=57&&(v=y=!1),y&&v&&(y=d,v=p),!y&&!v){k&&(i.content=hi(i.content,o.index,Ma));continue}if(v){for(b=w.length-1;b>=0&&(c=w[b],!(w[b].level<l));b--)if(c.single===k&&w[b].level===l){c=w[b],k?(E=e.md.options.quotes[2],x=e.md.options.quotes[3]):(E=e.md.options.quotes[0],x=e.md.options.quotes[1]),i.content=hi(i.content,o.index,x),n[c.token].content=hi(n[c.token].content,c.pos,E),s+=x.length-1,c.token===t&&(s+=E.length-1),r=i.content,a=r.length,w.length=b;continue e}}y?w.push({token:t,pos:o.index,single:k,level:l}):v&&k&&(i.content=hi(i.content,o.index,Ma))}}}}Fa.exports=function(e){var t;if(e.md.options.typographer)for(t=e.tokens.length-1;t>=0;t--)e.tokens[t].type!=="inline"||!Ld.test(e.tokens[t].content)||Id(e.tokens[t].children,e)}});var Pa=_((Jb,Ba)=>{"use strict";Ba.exports=function(e){var t,i,r,o,s,a,l=e.tokens;for(t=0,i=l.length;t<i;t++)if(l[t].type==="inline"){for(r=l[t].children,s=r.length,o=0;o<s;o++)r[o].type==="text_special"&&(r[o].type="text");for(o=a=0;o<s;o++)r[o].type==="text"&&o+1<s&&r[o+1].type==="text"?r[o+1].content=r[o].content+r[o+1].content:(o!==a&&(r[a]=r[o]),a++);o!==a&&(r.length=a)}}});var di=_((Qb,Oa)=>{"use strict";function vt(n,e,t){this.type=n,this.tag=e,this.attrs=null,this.map=null,this.nesting=t,this.level=0,this.children=null,this.content="",this.markup="",this.info="",this.meta=null,this.block=!1,this.hidden=!1}vt.prototype.attrIndex=function(e){var t,i,r;if(!this.attrs)return-1;for(t=this.attrs,i=0,r=t.length;i<r;i++)if(t[i][0]===e)return i;return-1};vt.prototype.attrPush=function(e){this.attrs?this.attrs.push(e):this.attrs=[e]};vt.prototype.attrSet=function(e,t){var i=this.attrIndex(e),r=[e,t];i<0?this.attrPush(r):this.attrs[i]=r};vt.prototype.attrGet=function(e){var t=this.attrIndex(e),i=null;return t>=0&&(i=this.attrs[t][1]),i};vt.prototype.attrJoin=function(e,t){var i=this.attrIndex(e);i<0?this.attrPush([e,t]):this.attrs[i][1]=this.attrs[i][1]+" "+t};Oa.exports=vt});var za=_((ev,Na)=>{"use strict";var $d=di();function Ra(n,e,t){this.src=n,this.env=t,this.tokens=[],this.inlineMode=!1,this.md=e}Ra.prototype.Token=$d;Na.exports=Ra});var Ua=_((tv,Ha)=>{"use strict";var Md=ui(),Yr=[["normalize",wa()],["block",xa()],["inline",Ca()],["linkify",_a()],["replacements",Da()],["smartquotes",qa()],["text_join",Pa()]];function Jr(){this.ruler=new Md;for(var n=0;n<Yr.length;n++)this.ruler.push(Yr[n][0],Yr[n][1])}Jr.prototype.process=function(n){var e,t,i;for(i=this.ruler.getRules(""),e=0,t=i.length;e<t;e++)i[e](n)};Jr.prototype.State=za();Ha.exports=Jr});var Wa=_((nv,Va)=>{"use strict";var Qr=R().isSpace;function eo(n,e){var t=n.bMarks[e]+n.tShift[e],i=n.eMarks[e];return n.src.slice(t,i)}function ja(n){var e=[],t=0,i=n.length,r,o=!1,s=0,a="";for(r=n.charCodeAt(t);t<i;)r===124&&(o?(a+=n.substring(s,t-1),s=t):(e.push(a+n.substring(s,t)),a="",s=t+1)),o=r===92,t++,r=n.charCodeAt(t);return e.push(a+n.substring(s)),e}Va.exports=function(e,t,i,r){var o,s,a,l,c,u,h,d,p,f,m,y,v,b,k,w,E,x;if(t+2>i||(u=t+1,e.sCount[u]<e.blkIndent)||e.sCount[u]-e.blkIndent>=4||(a=e.bMarks[u]+e.tShift[u],a>=e.eMarks[u])||(E=e.src.charCodeAt(a++),E!==124&&E!==45&&E!==58)||a>=e.eMarks[u]||(x=e.src.charCodeAt(a++),x!==124&&x!==45&&x!==58&&!Qr(x))||E===45&&Qr(x))return!1;for(;a<e.eMarks[u];){if(o=e.src.charCodeAt(a),o!==124&&o!==45&&o!==58&&!Qr(o))return!1;a++}for(s=eo(e,t+1),h=s.split("|"),f=[],l=0;l<h.length;l++){if(m=h[l].trim(),!m){if(l===0||l===h.length-1)continue;return!1}if(!/^:?-+:?$/.test(m))return!1;m.charCodeAt(m.length-1)===58?f.push(m.charCodeAt(0)===58?"center":"right"):m.charCodeAt(0)===58?f.push("left"):f.push("")}if(s=eo(e,t).trim(),s.indexOf("|")===-1||e.sCount[t]-e.blkIndent>=4||(h=ja(s),h.length&&h[0]===""&&h.shift(),h.length&&h[h.length-1]===""&&h.pop(),d=h.length,d===0||d!==f.length))return!1;if(r)return!0;for(b=e.parentType,e.parentType="table",w=e.md.block.ruler.getRules("blockquote"),p=e.push("table_open","table",1),p.map=y=[t,0],p=e.push("thead_open","thead",1),p.map=[t,t+1],p=e.push("tr_open","tr",1),p.map=[t,t+1],l=0;l<h.length;l++)p=e.push("th_open","th",1),f[l]&&(p.attrs=[["style","text-align:"+f[l]]]),p=e.push("inline","",0),p.content=h[l].trim(),p.children=[],p=e.push("th_close","th",-1);for(p=e.push("tr_close","tr",-1),p=e.push("thead_close","thead",-1),u=t+2;u<i&&!(e.sCount[u]<e.blkIndent);u++){for(k=!1,l=0,c=w.length;l<c;l++)if(w[l](e,u,i,!0)){k=!0;break}if(k||(s=eo(e,u).trim(),!s)||e.sCount[u]-e.blkIndent>=4)break;for(h=ja(s),h.length&&h[0]===""&&h.shift(),h.length&&h[h.length-1]===""&&h.pop(),u===t+2&&(p=e.push("tbody_open","tbody",1),p.map=v=[t+2,0]),p=e.push("tr_open","tr",1),p.map=[u,u+1],l=0;l<d;l++)p=e.push("td_open","td",1),f[l]&&(p.attrs=[["style","text-align:"+f[l]]]),p=e.push("inline","",0),p.content=h[l]?h[l].trim():"",p.children=[],p=e.push("td_close","td",-1);p=e.push("tr_close","tr",-1)}return v&&(p=e.push("tbody_close","tbody",-1),v[1]=u),p=e.push("table_close","table",-1),y[1]=u,e.parentType=b,e.line=u,!0}});var Ka=_((iv,Ga)=>{"use strict";Ga.exports=function(e,t,i){var r,o,s;if(e.sCount[t]-e.blkIndent<4)return!1;for(o=r=t+1;r<i;){if(e.isEmpty(r)){r++;continue}if(e.sCount[r]-e.blkIndent>=4){r++,o=r;continue}break}return e.line=o,s=e.push("code_block","code",0),s.content=e.getLines(t,o,4+e.blkIndent,!1)+`
-`,s.map=[t,e.line],!0}});var Xa=_((rv,Za)=>{"use strict";Za.exports=function(e,t,i,r){var o,s,a,l,c,u,h,d=!1,p=e.bMarks[t]+e.tShift[t],f=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||p+3>f||(o=e.src.charCodeAt(p),o!==126&&o!==96)||(c=p,p=e.skipChars(p,o),s=p-c,s<3)||(h=e.src.slice(c,p),a=e.src.slice(p,f),o===96&&a.indexOf(String.fromCharCode(o))>=0))return!1;if(r)return!0;for(l=t;l++,!(l>=i||(p=c=e.bMarks[l]+e.tShift[l],f=e.eMarks[l],p<f&&e.sCount[l]<e.blkIndent));)if(e.src.charCodeAt(p)===o&&!(e.sCount[l]-e.blkIndent>=4)&&(p=e.skipChars(p,o),!(p-c<s)&&(p=e.skipSpaces(p),!(p<f)))){d=!0;break}return s=e.sCount[t],e.line=l+(d?1:0),u=e.push("fence","code",0),u.info=a,u.content=e.getLines(t+1,l,s,!0),u.markup=h,u.map=[t,e.line],!0}});var Qa=_((ov,Ja)=>{"use strict";var Ya=R().isSpace;Ja.exports=function(e,t,i,r){var o,s,a,l,c,u,h,d,p,f,m,y,v,b,k,w,E,x,S,D,q=e.lineMax,L=e.bMarks[t]+e.tShift[t],I=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||e.src.charCodeAt(L++)!==62)return!1;if(r)return!0;for(l=p=e.sCount[t]+1,e.src.charCodeAt(L)===32?(L++,l++,p++,o=!1,w=!0):e.src.charCodeAt(L)===9?(w=!0,(e.bsCount[t]+p)%4===3?(L++,l++,p++,o=!1):o=!0):w=!1,f=[e.bMarks[t]],e.bMarks[t]=L;L<I&&(s=e.src.charCodeAt(L),Ya(s));){s===9?p+=4-(p+e.bsCount[t]+(o?1:0))%4:p++;L++}for(m=[e.bsCount[t]],e.bsCount[t]=e.sCount[t]+1+(w?1:0),u=L>=I,b=[e.sCount[t]],e.sCount[t]=p-l,k=[e.tShift[t]],e.tShift[t]=L-e.bMarks[t],x=e.md.block.ruler.getRules("blockquote"),v=e.parentType,e.parentType="blockquote",d=t+1;d<i&&(D=e.sCount[d]<e.blkIndent,L=e.bMarks[d]+e.tShift[d],I=e.eMarks[d],!(L>=I));d++){if(e.src.charCodeAt(L++)===62&&!D){for(l=p=e.sCount[d]+1,e.src.charCodeAt(L)===32?(L++,l++,p++,o=!1,w=!0):e.src.charCodeAt(L)===9?(w=!0,(e.bsCount[d]+p)%4===3?(L++,l++,p++,o=!1):o=!0):w=!1,f.push(e.bMarks[d]),e.bMarks[d]=L;L<I&&(s=e.src.charCodeAt(L),Ya(s));){s===9?p+=4-(p+e.bsCount[d]+(o?1:0))%4:p++;L++}u=L>=I,m.push(e.bsCount[d]),e.bsCount[d]=e.sCount[d]+1+(w?1:0),b.push(e.sCount[d]),e.sCount[d]=p-l,k.push(e.tShift[d]),e.tShift[d]=L-e.bMarks[d];continue}if(u)break;for(E=!1,a=0,c=x.length;a<c;a++)if(x[a](e,d,i,!0)){E=!0;break}if(E){e.lineMax=d,e.blkIndent!==0&&(f.push(e.bMarks[d]),m.push(e.bsCount[d]),k.push(e.tShift[d]),b.push(e.sCount[d]),e.sCount[d]-=e.blkIndent);break}f.push(e.bMarks[d]),m.push(e.bsCount[d]),k.push(e.tShift[d]),b.push(e.sCount[d]),e.sCount[d]=-1}for(y=e.blkIndent,e.blkIndent=0,S=e.push("blockquote_open","blockquote",1),S.markup=">",S.map=h=[t,0],e.md.block.tokenize(e,t,d),S=e.push("blockquote_close","blockquote",-1),S.markup=">",e.lineMax=q,e.parentType=v,h[1]=e.line,a=0;a<k.length;a++)e.bMarks[a+t]=f[a],e.tShift[a+t]=k[a],e.sCount[a+t]=b[a],e.bsCount[a+t]=m[a];return e.blkIndent=y,!0}});var tl=_((sv,el)=>{"use strict";var Fd=R().isSpace;el.exports=function(e,t,i,r){var o,s,a,l,c=e.bMarks[t]+e.tShift[t],u=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||(o=e.src.charCodeAt(c++),o!==42&&o!==45&&o!==95))return!1;for(s=1;c<u;){if(a=e.src.charCodeAt(c++),a!==o&&!Fd(a))return!1;a===o&&s++}return s<3?!1:(r||(e.line=t+1,l=e.push("hr","hr",0),l.map=[t,e.line],l.markup=Array(s+1).join(String.fromCharCode(o))),!0)}});var sl=_((av,ol)=>{"use strict";var rl=R().isSpace;function nl(n,e){var t,i,r,o;return i=n.bMarks[e]+n.tShift[e],r=n.eMarks[e],t=n.src.charCodeAt(i++),t!==42&&t!==45&&t!==43||i<r&&(o=n.src.charCodeAt(i),!rl(o))?-1:i}function il(n,e){var t,i=n.bMarks[e]+n.tShift[e],r=i,o=n.eMarks[e];if(r+1>=o||(t=n.src.charCodeAt(r++),t<48||t>57))return-1;for(;;){if(r>=o)return-1;if(t=n.src.charCodeAt(r++),t>=48&&t<=57){if(r-i>=10)return-1;continue}if(t===41||t===46)break;return-1}return r<o&&(t=n.src.charCodeAt(r),!rl(t))?-1:r}function qd(n,e){var t,i,r=n.level+2;for(t=e+2,i=n.tokens.length-2;t<i;t++)n.tokens[t].level===r&&n.tokens[t].type==="paragraph_open"&&(n.tokens[t+2].hidden=!0,n.tokens[t].hidden=!0,t+=2)}ol.exports=function(e,t,i,r){var o,s,a,l,c,u,h,d,p,f,m,y,v,b,k,w,E,x,S,D,q,L,I,H,N,ee,ge,V,Oe=!1,Re=!0;if(e.sCount[t]-e.blkIndent>=4||e.listIndent>=0&&e.sCount[t]-e.listIndent>=4&&e.sCount[t]<e.blkIndent)return!1;if(r&&e.parentType==="paragraph"&&e.sCount[t]>=e.blkIndent&&(Oe=!0),(I=il(e,t))>=0){if(h=!0,N=e.bMarks[t]+e.tShift[t],v=Number(e.src.slice(N,I-1)),Oe&&v!==1)return!1}else if((I=nl(e,t))>=0)h=!1;else return!1;if(Oe&&e.skipSpaces(I)>=e.eMarks[t])return!1;if(y=e.src.charCodeAt(I-1),r)return!0;for(m=e.tokens.length,h?(V=e.push("ordered_list_open","ol",1),v!==1&&(V.attrs=[["start",v]])):V=e.push("bullet_list_open","ul",1),V.map=f=[t,0],V.markup=String.fromCharCode(y),k=t,H=!1,ge=e.md.block.ruler.getRules("list"),x=e.parentType,e.parentType="list";k<i;){for(L=I,b=e.eMarks[k],u=w=e.sCount[k]+I-(e.bMarks[t]+e.tShift[t]);L<b;){if(o=e.src.charCodeAt(L),o===9)w+=4-(w+e.bsCount[k])%4;else if(o===32)w++;else break;L++}if(s=L,s>=b?c=1:c=w-u,c>4&&(c=1),l=u+c,V=e.push("list_item_open","li",1),V.markup=String.fromCharCode(y),V.map=d=[t,0],h&&(V.info=e.src.slice(N,I-1)),q=e.tight,D=e.tShift[t],S=e.sCount[t],E=e.listIndent,e.listIndent=e.blkIndent,e.blkIndent=l,e.tight=!0,e.tShift[t]=s-e.bMarks[t],e.sCount[t]=w,s>=b&&e.isEmpty(t+1)?e.line=Math.min(e.line+2,i):e.md.block.tokenize(e,t,i,!0),(!e.tight||H)&&(Re=!1),H=e.line-t>1&&e.isEmpty(e.line-1),e.blkIndent=e.listIndent,e.listIndent=E,e.tShift[t]=D,e.sCount[t]=S,e.tight=q,V=e.push("list_item_close","li",-1),V.markup=String.fromCharCode(y),k=t=e.line,d[1]=k,s=e.bMarks[t],k>=i||e.sCount[k]<e.blkIndent||e.sCount[t]-e.blkIndent>=4)break;for(ee=!1,a=0,p=ge.length;a<p;a++)if(ge[a](e,k,i,!0)){ee=!0;break}if(ee)break;if(h){if(I=il(e,k),I<0)break;N=e.bMarks[k]+e.tShift[k]}else if(I=nl(e,k),I<0)break;if(y!==e.src.charCodeAt(I-1))break}return h?V=e.push("ordered_list_close","ol",-1):V=e.push("bullet_list_close","ul",-1),V.markup=String.fromCharCode(y),f[1]=k,e.line=k,e.parentType=x,Re&&qd(e,m),!0}});var ll=_((lv,al)=>{"use strict";var Bd=R().normalizeReference,pi=R().isSpace;al.exports=function(e,t,i,r){var o,s,a,l,c,u,h,d,p,f,m,y,v,b,k,w,E=0,x=e.bMarks[t]+e.tShift[t],S=e.eMarks[t],D=t+1;if(e.sCount[t]-e.blkIndent>=4||e.src.charCodeAt(x)!==91)return!1;for(;++x<S;)if(e.src.charCodeAt(x)===93&&e.src.charCodeAt(x-1)!==92){if(x+1===S||e.src.charCodeAt(x+1)!==58)return!1;break}for(l=e.lineMax,k=e.md.block.ruler.getRules("reference"),f=e.parentType,e.parentType="reference";D<l&&!e.isEmpty(D);D++)if(!(e.sCount[D]-e.blkIndent>3)&&!(e.sCount[D]<0)){for(b=!1,u=0,h=k.length;u<h;u++)if(k[u](e,D,l,!0)){b=!0;break}if(b)break}for(v=e.getLines(t,D,e.blkIndent,!1).trim(),S=v.length,x=1;x<S;x++){if(o=v.charCodeAt(x),o===91)return!1;if(o===93){p=x;break}else o===10?E++:o===92&&(x++,x<S&&v.charCodeAt(x)===10&&E++)}if(p<0||v.charCodeAt(p+1)!==58)return!1;for(x=p+2;x<S;x++)if(o=v.charCodeAt(x),o===10)E++;else if(!pi(o))break;if(m=e.md.helpers.parseLinkDestination(v,x,S),!m.ok||(c=e.md.normalizeLink(m.str),!e.md.validateLink(c)))return!1;for(x=m.pos,E+=m.lines,s=x,a=E,y=x;x<S;x++)if(o=v.charCodeAt(x),o===10)E++;else if(!pi(o))break;for(m=e.md.helpers.parseLinkTitle(v,x,S),x<S&&y!==x&&m.ok?(w=m.str,x=m.pos,E+=m.lines):(w="",x=s,E=a);x<S&&(o=v.charCodeAt(x),!!pi(o));)x++;if(x<S&&v.charCodeAt(x)!==10&&w)for(w="",x=s,E=a;x<S&&(o=v.charCodeAt(x),!!pi(o));)x++;return x<S&&v.charCodeAt(x)!==10||(d=Bd(v.slice(1,p)),!d)?!1:(r||(typeof e.env.references>"u"&&(e.env.references={}),typeof e.env.references[d]>"u"&&(e.env.references[d]={title:w,href:c}),e.parentType=f,e.line=t+E+1),!0)}});var ul=_((cv,cl)=>{"use strict";cl.exports=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","section","source","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"]});var no=_((uv,to)=>{"use strict";var Pd="[a-zA-Z_:][a-zA-Z0-9:._-]*",Od="[^\"'=<>`\\x00-\\x20]+",Rd="'[^']*'",Nd='"[^"]*"',zd="(?:"+Od+"|"+Rd+"|"+Nd+")",Hd="(?:\\s+"+Pd+"(?:\\s*=\\s*"+zd+")?)",hl="<[A-Za-z][A-Za-z0-9\\-]*"+Hd+"*\\s*\\/?>",dl="<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>",Ud="<!---->|<!--(?:-?[^>-])(?:-?[^-])*-->",jd="<[?][\\s\\S]*?[?]>",Vd="<![A-Z]+\\s+[^>]*>",Wd="<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",Gd=new RegExp("^(?:"+hl+"|"+dl+"|"+Ud+"|"+jd+"|"+Vd+"|"+Wd+")"),Kd=new RegExp("^(?:"+hl+"|"+dl+")");to.exports.HTML_TAG_RE=Gd;to.exports.HTML_OPEN_CLOSE_TAG_RE=Kd});var fl=_((hv,pl)=>{"use strict";var Zd=ul(),Xd=no().HTML_OPEN_CLOSE_TAG_RE,wt=[[/^<(script|pre|style|textarea)(?=(\s|>|$))/i,/<\/(script|pre|style|textarea)>/i,!0],[/^<!--/,/-->/,!0],[/^<\?/,/\?>/,!0],[/^<![A-Z]/,/>/,!0],[/^<!\[CDATA\[/,/\]\]>/,!0],[new RegExp("^</?("+Zd.join("|")+")(?=(\\s|/?>|$))","i"),/^$/,!0],[new RegExp(Xd.source+"\\s*$"),/^$/,!1]];pl.exports=function(e,t,i,r){var o,s,a,l,c=e.bMarks[t]+e.tShift[t],u=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||!e.md.options.html||e.src.charCodeAt(c)!==60)return!1;for(l=e.src.slice(c,u),o=0;o<wt.length&&!wt[o][0].test(l);o++);if(o===wt.length)return!1;if(r)return wt[o][2];if(s=t+1,!wt[o][1].test(l)){for(;s<i&&!(e.sCount[s]<e.blkIndent);s++)if(c=e.bMarks[s]+e.tShift[s],u=e.eMarks[s],l=e.src.slice(c,u),wt[o][1].test(l)){l.length!==0&&s++;break}}return e.line=s,a=e.push("html_block","",0),a.map=[t,s],a.content=e.getLines(t,s,e.blkIndent,!0),!0}});var bl=_((dv,gl)=>{"use strict";var ml=R().isSpace;gl.exports=function(e,t,i,r){var o,s,a,l,c=e.bMarks[t]+e.tShift[t],u=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||(o=e.src.charCodeAt(c),o!==35||c>=u))return!1;for(s=1,o=e.src.charCodeAt(++c);o===35&&c<u&&s<=6;)s++,o=e.src.charCodeAt(++c);return s>6||c<u&&!ml(o)?!1:(r||(u=e.skipSpacesBack(u,c),a=e.skipCharsBack(u,35,c),a>c&&ml(e.src.charCodeAt(a-1))&&(u=a),e.line=t+1,l=e.push("heading_open","h"+String(s),1),l.markup="########".slice(0,s),l.map=[t,e.line],l=e.push("inline","",0),l.content=e.src.slice(c,u).trim(),l.map=[t,e.line],l.children=[],l=e.push("heading_close","h"+String(s),-1),l.markup="########".slice(0,s)),!0)}});var wl=_((pv,vl)=>{"use strict";vl.exports=function(e,t,i){var r,o,s,a,l,c,u,h,d,p=t+1,f,m=e.md.block.ruler.getRules("paragraph");if(e.sCount[t]-e.blkIndent>=4)return!1;for(f=e.parentType,e.parentType="paragraph";p<i&&!e.isEmpty(p);p++)if(!(e.sCount[p]-e.blkIndent>3)){if(e.sCount[p]>=e.blkIndent&&(c=e.bMarks[p]+e.tShift[p],u=e.eMarks[p],c<u&&(d=e.src.charCodeAt(c),(d===45||d===61)&&(c=e.skipChars(c,d),c=e.skipSpaces(c),c>=u)))){h=d===61?1:2;break}if(!(e.sCount[p]<0)){for(o=!1,s=0,a=m.length;s<a;s++)if(m[s](e,p,i,!0)){o=!0;break}if(o)break}}return h?(r=e.getLines(t,p,e.blkIndent,!1).trim(),e.line=p+1,l=e.push("heading_open","h"+String(h),1),l.markup=String.fromCharCode(d),l.map=[t,e.line],l=e.push("inline","",0),l.content=r,l.map=[t,e.line-1],l.children=[],l=e.push("heading_close","h"+String(h),-1),l.markup=String.fromCharCode(d),e.parentType=f,!0):!1}});var xl=_((fv,yl)=>{"use strict";yl.exports=function(e,t){var i,r,o,s,a,l,c=t+1,u=e.md.block.ruler.getRules("paragraph"),h=e.lineMax;for(l=e.parentType,e.parentType="paragraph";c<h&&!e.isEmpty(c);c++)if(!(e.sCount[c]-e.blkIndent>3)&&!(e.sCount[c]<0)){for(r=!1,o=0,s=u.length;o<s;o++)if(u[o](e,c,h,!0)){r=!0;break}if(r)break}return i=e.getLines(t,c,e.blkIndent,!1).trim(),e.line=c,a=e.push("paragraph_open","p",1),a.map=[t,e.line],a=e.push("inline","",0),a.content=i,a.map=[t,e.line],a.children=[],a=e.push("paragraph_close","p",-1),e.parentType=l,!0}});var El=_((mv,Cl)=>{"use strict";var kl=di(),fi=R().isSpace;function Te(n,e,t,i){var r,o,s,a,l,c,u,h;for(this.src=n,this.md=e,this.env=t,this.tokens=i,this.bMarks=[],this.eMarks=[],this.tShift=[],this.sCount=[],this.bsCount=[],this.blkIndent=0,this.line=0,this.lineMax=0,this.tight=!1,this.ddIndent=-1,this.listIndent=-1,this.parentType="root",this.level=0,this.result="",o=this.src,h=!1,s=a=c=u=0,l=o.length;a<l;a++){if(r=o.charCodeAt(a),!h)if(fi(r)){c++,r===9?u+=4-u%4:u++;continue}else h=!0;(r===10||a===l-1)&&(r!==10&&a++,this.bMarks.push(s),this.eMarks.push(a),this.tShift.push(c),this.sCount.push(u),this.bsCount.push(0),h=!1,c=0,u=0,s=a+1)}this.bMarks.push(o.length),this.eMarks.push(o.length),this.tShift.push(0),this.sCount.push(0),this.bsCount.push(0),this.lineMax=this.bMarks.length-1}Te.prototype.push=function(n,e,t){var i=new kl(n,e,t);return i.block=!0,t<0&&this.level--,i.level=this.level,t>0&&this.level++,this.tokens.push(i),i};Te.prototype.isEmpty=function(e){return this.bMarks[e]+this.tShift[e]>=this.eMarks[e]};Te.prototype.skipEmptyLines=function(e){for(var t=this.lineMax;e<t&&!(this.bMarks[e]+this.tShift[e]<this.eMarks[e]);e++);return e};Te.prototype.skipSpaces=function(e){for(var t,i=this.src.length;e<i&&(t=this.src.charCodeAt(e),!!fi(t));e++);return e};Te.prototype.skipSpacesBack=function(e,t){if(e<=t)return e;for(;e>t;)if(!fi(this.src.charCodeAt(--e)))return e+1;return e};Te.prototype.skipChars=function(e,t){for(var i=this.src.length;e<i&&this.src.charCodeAt(e)===t;e++);return e};Te.prototype.skipCharsBack=function(e,t,i){if(e<=i)return e;for(;e>i;)if(t!==this.src.charCodeAt(--e))return e+1;return e};Te.prototype.getLines=function(e,t,i,r){var o,s,a,l,c,u,h,d=e;if(e>=t)return"";for(u=new Array(t-e),o=0;d<t;d++,o++){for(s=0,h=l=this.bMarks[d],d+1<t||r?c=this.eMarks[d]+1:c=this.eMarks[d];l<c&&s<i;){if(a=this.src.charCodeAt(l),fi(a))a===9?s+=4-(s+this.bsCount[d])%4:s++;else if(l-h<this.tShift[d])s++;else break;l++}s>i?u[o]=new Array(s-i+1).join(" ")+this.src.slice(l,c):u[o]=this.src.slice(l,c)}return u.join("")};Te.prototype.Token=kl;Cl.exports=Te});var Sl=_((gv,_l)=>{"use strict";var Yd=ui(),mi=[["table",Wa(),["paragraph","reference"]],["code",Ka()],["fence",Xa(),["paragraph","reference","blockquote","list"]],["blockquote",Qa(),["paragraph","reference","blockquote","list"]],["hr",tl(),["paragraph","reference","blockquote","list"]],["list",sl(),["paragraph","reference","blockquote"]],["reference",ll()],["html_block",fl(),["paragraph","reference","blockquote"]],["heading",bl(),["paragraph","reference","blockquote"]],["lheading",wl()],["paragraph",xl()]];function gi(){this.ruler=new Yd;for(var n=0;n<mi.length;n++)this.ruler.push(mi[n][0],mi[n][1],{alt:(mi[n][2]||[]).slice()})}gi.prototype.tokenize=function(n,e,t){for(var i,r,o=this.ruler.getRules(""),s=o.length,a=e,l=!1,c=n.md.options.maxNesting;a<t&&(n.line=a=n.skipEmptyLines(a),!(a>=t||n.sCount[a]<n.blkIndent));){if(n.level>=c){n.line=t;break}for(r=0;r<s&&(i=o[r](n,a,t,!1),!i);r++);n.tight=!l,n.isEmpty(n.line-1)&&(l=!0),a=n.line,a<t&&n.isEmpty(a)&&(l=!0,a++,n.line=a)}};gi.prototype.parse=function(n,e,t,i){var r;n&&(r=new this.State(n,e,t,i),this.tokenize(r,r.line,r.lineMax))};gi.prototype.State=El();_l.exports=gi});var Dl=_((bv,Al)=>{"use strict";function Jd(n){switch(n){case 10:case 33:case 35:case 36:case 37:case 38:case 42:case 43:case 45:case 58:case 60:case 61:case 62:case 64:case 91:case 92:case 93:case 94:case 95:case 96:case 123:case 125:case 126:return!0;default:return!1}}Al.exports=function(e,t){for(var i=e.pos;i<e.posMax&&!Jd(e.src.charCodeAt(i));)i++;return i===e.pos?!1:(t||(e.pending+=e.src.slice(e.pos,i)),e.pos=i,!0)}});var Ll=_((vv,Tl)=>{"use strict";var Qd=/(?:^|[^a-z0-9.+-])([a-z][a-z0-9.+-]*)$/i;Tl.exports=function(e,t){var i,r,o,s,a,l,c,u;return!e.md.options.linkify||e.linkLevel>0||(i=e.pos,r=e.posMax,i+3>r)||e.src.charCodeAt(i)!==58||e.src.charCodeAt(i+1)!==47||e.src.charCodeAt(i+2)!==47||(o=e.pending.match(Qd),!o)||(s=o[1],a=e.md.linkify.matchAtStart(e.src.slice(i-s.length)),!a)||(l=a.url,l=l.replace(/\*+$/,""),c=e.md.normalizeLink(l),!e.md.validateLink(c))?!1:(t||(e.pending=e.pending.slice(0,-s.length),u=e.push("link_open","a",1),u.attrs=[["href",c]],u.markup="linkify",u.info="auto",u=e.push("text","",0),u.content=e.md.normalizeLinkText(l),u=e.push("link_close","a",-1),u.markup="linkify",u.info="auto"),e.pos+=l.length-s.length,!0)}});var $l=_((wv,Il)=>{"use strict";var ep=R().isSpace;Il.exports=function(e,t){var i,r,o,s=e.pos;if(e.src.charCodeAt(s)!==10)return!1;if(i=e.pending.length-1,r=e.posMax,!t)if(i>=0&&e.pending.charCodeAt(i)===32)if(i>=1&&e.pending.charCodeAt(i-1)===32){for(o=i-1;o>=1&&e.pending.charCodeAt(o-1)===32;)o--;e.pending=e.pending.slice(0,o),e.push("hardbreak","br",0)}else e.pending=e.pending.slice(0,-1),e.push("softbreak","br",0);else e.push("softbreak","br",0);for(s++;s<r&&ep(e.src.charCodeAt(s));)s++;return e.pos=s,!0}});var Fl=_((yv,Ml)=>{"use strict";var tp=R().isSpace,ro=[];for(io=0;io<256;io++)ro.push(0);var io;"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach(function(n){ro[n.charCodeAt(0)]=1});Ml.exports=function(e,t){var i,r,o,s,a,l=e.pos,c=e.posMax;if(e.src.charCodeAt(l)!==92||(l++,l>=c))return!1;if(i=e.src.charCodeAt(l),i===10){for(t||e.push("hardbreak","br",0),l++;l<c&&(i=e.src.charCodeAt(l),!!tp(i));)l++;return e.pos=l,!0}return s=e.src[l],i>=55296&&i<=56319&&l+1<c&&(r=e.src.charCodeAt(l+1),r>=56320&&r<=57343&&(s+=e.src[l+1],l++)),o="\\"+s,t||(a=e.push("text_special","",0),i<256&&ro[i]!==0?a.content=s:a.content=o,a.markup=o,a.info="escape"),e.pos=l+1,!0}});var Bl=_((xv,ql)=>{"use strict";ql.exports=function(e,t){var i,r,o,s,a,l,c,u,h=e.pos,d=e.src.charCodeAt(h);if(d!==96)return!1;for(i=h,h++,r=e.posMax;h<r&&e.src.charCodeAt(h)===96;)h++;if(o=e.src.slice(i,h),c=o.length,e.backticksScanned&&(e.backticks[c]||0)<=i)return t||(e.pending+=o),e.pos+=c,!0;for(a=l=h;(a=e.src.indexOf("`",l))!==-1;){for(l=a+1;l<r&&e.src.charCodeAt(l)===96;)l++;if(u=l-a,u===c)return t||(s=e.push("code_inline","code",0),s.markup=o,s.content=e.src.slice(h,a).replace(/\n/g," ").replace(/^ (.+) $/,"$1")),e.pos=l,!0;e.backticks[u]=a}return e.backticksScanned=!0,t||(e.pending+=o),e.pos+=c,!0}});var so=_((kv,oo)=>{"use strict";oo.exports.tokenize=function(e,t){var i,r,o,s,a,l=e.pos,c=e.src.charCodeAt(l);if(t||c!==126||(r=e.scanDelims(e.pos,!0),s=r.length,a=String.fromCharCode(c),s<2))return!1;for(s%2&&(o=e.push("text","",0),o.content=a,s--),i=0;i<s;i+=2)o=e.push("text","",0),o.content=a+a,e.delimiters.push({marker:c,length:0,token:e.tokens.length-1,end:-1,open:r.can_open,close:r.can_close});return e.pos+=r.length,!0};function Pl(n,e){var t,i,r,o,s,a=[],l=e.length;for(t=0;t<l;t++)r=e[t],r.marker===126&&r.end!==-1&&(o=e[r.end],s=n.tokens[r.token],s.type="s_open",s.tag="s",s.nesting=1,s.markup="~~",s.content="",s=n.tokens[o.token],s.type="s_close",s.tag="s",s.nesting=-1,s.markup="~~",s.content="",n.tokens[o.token-1].type==="text"&&n.tokens[o.token-1].content==="~"&&a.push(o.token-1));for(;a.length;){for(t=a.pop(),i=t+1;i<n.tokens.length&&n.tokens[i].type==="s_close";)i++;i--,t!==i&&(s=n.tokens[i],n.tokens[i]=n.tokens[t],n.tokens[t]=s)}}oo.exports.postProcess=function(e){var t,i=e.tokens_meta,r=e.tokens_meta.length;for(Pl(e,e.delimiters),t=0;t<r;t++)i[t]&&i[t].delimiters&&Pl(e,i[t].delimiters)}});var lo=_((Cv,ao)=>{"use strict";ao.exports.tokenize=function(e,t){var i,r,o,s=e.pos,a=e.src.charCodeAt(s);if(t||a!==95&&a!==42)return!1;for(r=e.scanDelims(e.pos,a===42),i=0;i<r.length;i++)o=e.push("text","",0),o.content=String.fromCharCode(a),e.delimiters.push({marker:a,length:r.length,token:e.tokens.length-1,end:-1,open:r.can_open,close:r.can_close});return e.pos+=r.length,!0};function Ol(n,e){var t,i,r,o,s,a,l=e.length;for(t=l-1;t>=0;t--)i=e[t],!(i.marker!==95&&i.marker!==42)&&i.end!==-1&&(r=e[i.end],a=t>0&&e[t-1].end===i.end+1&&e[t-1].marker===i.marker&&e[t-1].token===i.token-1&&e[i.end+1].token===r.token+1,s=String.fromCharCode(i.marker),o=n.tokens[i.token],o.type=a?"strong_open":"em_open",o.tag=a?"strong":"em",o.nesting=1,o.markup=a?s+s:s,o.content="",o=n.tokens[r.token],o.type=a?"strong_close":"em_close",o.tag=a?"strong":"em",o.nesting=-1,o.markup=a?s+s:s,o.content="",a&&(n.tokens[e[t-1].token].content="",n.tokens[e[i.end+1].token].content="",t--))}ao.exports.postProcess=function(e){var t,i=e.tokens_meta,r=e.tokens_meta.length;for(Ol(e,e.delimiters),t=0;t<r;t++)i[t]&&i[t].delimiters&&Ol(e,i[t].delimiters)}});var Nl=_((Ev,Rl)=>{"use strict";var np=R().normalizeReference,co=R().isSpace;Rl.exports=function(e,t){var i,r,o,s,a,l,c,u,h,d="",p="",f=e.pos,m=e.posMax,y=e.pos,v=!0;if(e.src.charCodeAt(e.pos)!==91||(a=e.pos+1,s=e.md.helpers.parseLinkLabel(e,e.pos,!0),s<0))return!1;if(l=s+1,l<m&&e.src.charCodeAt(l)===40){for(v=!1,l++;l<m&&(r=e.src.charCodeAt(l),!(!co(r)&&r!==10));l++);if(l>=m)return!1;if(y=l,c=e.md.helpers.parseLinkDestination(e.src,l,e.posMax),c.ok){for(d=e.md.normalizeLink(c.str),e.md.validateLink(d)?l=c.pos:d="",y=l;l<m&&(r=e.src.charCodeAt(l),!(!co(r)&&r!==10));l++);if(c=e.md.helpers.parseLinkTitle(e.src,l,e.posMax),l<m&&y!==l&&c.ok)for(p=c.str,l=c.pos;l<m&&(r=e.src.charCodeAt(l),!(!co(r)&&r!==10));l++);}(l>=m||e.src.charCodeAt(l)!==41)&&(v=!0),l++}if(v){if(typeof e.env.references>"u")return!1;if(l<m&&e.src.charCodeAt(l)===91?(y=l+1,l=e.md.helpers.parseLinkLabel(e,l),l>=0?o=e.src.slice(y,l++):l=s+1):l=s+1,o||(o=e.src.slice(a,s)),u=e.env.references[np(o)],!u)return e.pos=f,!1;d=u.href,p=u.title}return t||(e.pos=a,e.posMax=s,h=e.push("link_open","a",1),h.attrs=i=[["href",d]],p&&i.push(["title",p]),e.linkLevel++,e.md.inline.tokenize(e),e.linkLevel--,h=e.push("link_close","a",-1)),e.pos=l,e.posMax=m,!0}});var Hl=_((_v,zl)=>{"use strict";var ip=R().normalizeReference,uo=R().isSpace;zl.exports=function(e,t){var i,r,o,s,a,l,c,u,h,d,p,f,m,y="",v=e.pos,b=e.posMax;if(e.src.charCodeAt(e.pos)!==33||e.src.charCodeAt(e.pos+1)!==91||(l=e.pos+2,a=e.md.helpers.parseLinkLabel(e,e.pos+1,!1),a<0))return!1;if(c=a+1,c<b&&e.src.charCodeAt(c)===40){for(c++;c<b&&(r=e.src.charCodeAt(c),!(!uo(r)&&r!==10));c++);if(c>=b)return!1;for(m=c,h=e.md.helpers.parseLinkDestination(e.src,c,e.posMax),h.ok&&(y=e.md.normalizeLink(h.str),e.md.validateLink(y)?c=h.pos:y=""),m=c;c<b&&(r=e.src.charCodeAt(c),!(!uo(r)&&r!==10));c++);if(h=e.md.helpers.parseLinkTitle(e.src,c,e.posMax),c<b&&m!==c&&h.ok)for(d=h.str,c=h.pos;c<b&&(r=e.src.charCodeAt(c),!(!uo(r)&&r!==10));c++);else d="";if(c>=b||e.src.charCodeAt(c)!==41)return e.pos=v,!1;c++}else{if(typeof e.env.references>"u")return!1;if(c<b&&e.src.charCodeAt(c)===91?(m=c+1,c=e.md.helpers.parseLinkLabel(e,c),c>=0?s=e.src.slice(m,c++):c=a+1):c=a+1,s||(s=e.src.slice(l,a)),u=e.env.references[ip(s)],!u)return e.pos=v,!1;y=u.href,d=u.title}return t||(o=e.src.slice(l,a),e.md.inline.parse(o,e.md,e.env,f=[]),p=e.push("image","img",0),p.attrs=i=[["src",y],["alt",""]],p.children=f,p.content=o,d&&i.push(["title",d])),e.pos=c,e.posMax=b,!0}});var jl=_((Sv,Ul)=>{"use strict";var rp=/^([a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)$/,op=/^([a-zA-Z][a-zA-Z0-9+.\-]{1,31}):([^<>\x00-\x20]*)$/;Ul.exports=function(e,t){var i,r,o,s,a,l,c=e.pos;if(e.src.charCodeAt(c)!==60)return!1;for(a=e.pos,l=e.posMax;;){if(++c>=l||(s=e.src.charCodeAt(c),s===60))return!1;if(s===62)break}return i=e.src.slice(a+1,c),op.test(i)?(r=e.md.normalizeLink(i),e.md.validateLink(r)?(t||(o=e.push("link_open","a",1),o.attrs=[["href",r]],o.markup="autolink",o.info="auto",o=e.push("text","",0),o.content=e.md.normalizeLinkText(i),o=e.push("link_close","a",-1),o.markup="autolink",o.info="auto"),e.pos+=i.length+2,!0):!1):rp.test(i)?(r=e.md.normalizeLink("mailto:"+i),e.md.validateLink(r)?(t||(o=e.push("link_open","a",1),o.attrs=[["href",r]],o.markup="autolink",o.info="auto",o=e.push("text","",0),o.content=e.md.normalizeLinkText(i),o=e.push("link_close","a",-1),o.markup="autolink",o.info="auto"),e.pos+=i.length+2,!0):!1):!1}});var Wl=_((Av,Vl)=>{"use strict";var sp=no().HTML_TAG_RE;function ap(n){return/^<a[>\s]/i.test(n)}function lp(n){return/^<\/a\s*>/i.test(n)}function cp(n){var e=n|32;return e>=97&&e<=122}Vl.exports=function(e,t){var i,r,o,s,a=e.pos;return!e.md.options.html||(o=e.posMax,e.src.charCodeAt(a)!==60||a+2>=o)||(i=e.src.charCodeAt(a+1),i!==33&&i!==63&&i!==47&&!cp(i))||(r=e.src.slice(a).match(sp),!r)?!1:(t||(s=e.push("html_inline","",0),s.content=e.src.slice(a,a+r[0].length),ap(s.content)&&e.linkLevel++,lp(s.content)&&e.linkLevel--),e.pos+=r[0].length,!0)}});var Xl=_((Dv,Zl)=>{"use strict";var Gl=Wr(),up=R().has,hp=R().isValidEntityCode,Kl=R().fromCodePoint,dp=/^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i,pp=/^&([a-z][a-z0-9]{1,31});/i;Zl.exports=function(e,t){var i,r,o,s,a=e.pos,l=e.posMax;if(e.src.charCodeAt(a)!==38||a+1>=l)return!1;if(i=e.src.charCodeAt(a+1),i===35){if(o=e.src.slice(a).match(dp),o)return t||(r=o[1][0].toLowerCase()==="x"?parseInt(o[1].slice(1),16):parseInt(o[1],10),s=e.push("text_special","",0),s.content=hp(r)?Kl(r):Kl(65533),s.markup=o[0],s.info="entity"),e.pos+=o[0].length,!0}else if(o=e.src.slice(a).match(pp),o&&up(Gl,o[1]))return t||(s=e.push("text_special","",0),s.content=Gl[o[1]],s.markup=o[0],s.info="entity"),e.pos+=o[0].length,!0;return!1}});var Ql=_((Tv,Jl)=>{"use strict";function Yl(n,e){var t,i,r,o,s,a,l,c,u={},h=e.length;if(h){var d=0,p=-2,f=[];for(t=0;t<h;t++)if(r=e[t],f.push(0),(e[d].marker!==r.marker||p!==r.token-1)&&(d=t),p=r.token,r.length=r.length||0,!!r.close){for(u.hasOwnProperty(r.marker)||(u[r.marker]=[-1,-1,-1,-1,-1,-1]),s=u[r.marker][(r.open?3:0)+r.length%3],i=d-f[d]-1,a=i;i>s;i-=f[i]+1)if(o=e[i],o.marker===r.marker&&o.open&&o.end<0&&(l=!1,(o.close||r.open)&&(o.length+r.length)%3===0&&(o.length%3!==0||r.length%3!==0)&&(l=!0),!l)){c=i>0&&!e[i-1].open?f[i-1]+1:0,f[t]=t-i+c,f[i]=c,r.open=!1,o.end=t,o.close=!1,a=-1,p=-2;break}a!==-1&&(u[r.marker][(r.open?3:0)+(r.length||0)%3]=a)}}}Jl.exports=function(e){var t,i=e.tokens_meta,r=e.tokens_meta.length;for(Yl(e,e.delimiters),t=0;t<r;t++)i[t]&&i[t].delimiters&&Yl(e,i[t].delimiters)}});var tc=_((Lv,ec)=>{"use strict";ec.exports=function(e){var t,i,r=0,o=e.tokens,s=e.tokens.length;for(t=i=0;t<s;t++)o[t].nesting<0&&r--,o[t].level=r,o[t].nesting>0&&r++,o[t].type==="text"&&t+1<s&&o[t+1].type==="text"?o[t+1].content=o[t].content+o[t+1].content:(t!==i&&(o[i]=o[t]),i++);t!==i&&(o.length=i)}});var sc=_((Iv,oc)=>{"use strict";var ho=di(),nc=R().isWhiteSpace,ic=R().isPunctChar,rc=R().isMdAsciiPunct;function Zt(n,e,t,i){this.src=n,this.env=t,this.md=e,this.tokens=i,this.tokens_meta=Array(i.length),this.pos=0,this.posMax=this.src.length,this.level=0,this.pending="",this.pendingLevel=0,this.cache={},this.delimiters=[],this._prev_delimiters=[],this.backticks={},this.backticksScanned=!1,this.linkLevel=0}Zt.prototype.pushPending=function(){var n=new ho("text","",0);return n.content=this.pending,n.level=this.pendingLevel,this.tokens.push(n),this.pending="",n};Zt.prototype.push=function(n,e,t){this.pending&&this.pushPending();var i=new ho(n,e,t),r=null;return t<0&&(this.level--,this.delimiters=this._prev_delimiters.pop()),i.level=this.level,t>0&&(this.level++,this._prev_delimiters.push(this.delimiters),this.delimiters=[],r={delimiters:this.delimiters}),this.pendingLevel=this.level,this.tokens.push(i),this.tokens_meta.push(r),i};Zt.prototype.scanDelims=function(n,e){var t=n,i,r,o,s,a,l,c,u,h,d=!0,p=!0,f=this.posMax,m=this.src.charCodeAt(n);for(i=n>0?this.src.charCodeAt(n-1):32;t<f&&this.src.charCodeAt(t)===m;)t++;return o=t-n,r=t<f?this.src.charCodeAt(t):32,c=rc(i)||ic(String.fromCharCode(i)),h=rc(r)||ic(String.fromCharCode(r)),l=nc(i),u=nc(r),u?d=!1:h&&(l||c||(d=!1)),l?p=!1:c&&(u||h||(p=!1)),e?(s=d,a=p):(s=d&&(!p||c),a=p&&(!d||h)),{can_open:s,can_close:a,length:o}};Zt.prototype.Token=ho;oc.exports=Zt});var cc=_(($v,lc)=>{"use strict";var ac=ui(),po=[["text",Dl()],["linkify",Ll()],["newline",$l()],["escape",Fl()],["backticks",Bl()],["strikethrough",so().tokenize],["emphasis",lo().tokenize],["link",Nl()],["image",Hl()],["autolink",jl()],["html_inline",Wl()],["entity",Xl()]],fo=[["balance_pairs",Ql()],["strikethrough",so().postProcess],["emphasis",lo().postProcess],["fragments_join",tc()]];function Xt(){var n;for(this.ruler=new ac,n=0;n<po.length;n++)this.ruler.push(po[n][0],po[n][1]);for(this.ruler2=new ac,n=0;n<fo.length;n++)this.ruler2.push(fo[n][0],fo[n][1])}Xt.prototype.skipToken=function(n){var e,t,i=n.pos,r=this.ruler.getRules(""),o=r.length,s=n.md.options.maxNesting,a=n.cache;if(typeof a[i]<"u"){n.pos=a[i];return}if(n.level<s)for(t=0;t<o&&(n.level++,e=r[t](n,!0),n.level--,!e);t++);else n.pos=n.posMax;e||n.pos++,a[i]=n.pos};Xt.prototype.tokenize=function(n){for(var e,t,i=this.ruler.getRules(""),r=i.length,o=n.posMax,s=n.md.options.maxNesting;n.pos<o;){if(n.level<s)for(t=0;t<r&&(e=i[t](n,!1),!e);t++);if(e){if(n.pos>=o)break;continue}n.pending+=n.src[n.pos++]}n.pending&&n.pushPending()};Xt.prototype.parse=function(n,e,t,i){var r,o,s,a=new this.State(n,e,t,i);for(this.tokenize(a),o=this.ruler2.getRules(""),s=o.length,r=0;r<s;r++)o[r](a)};Xt.prototype.State=sc();lc.exports=Xt});var hc=_((Mv,uc)=>{"use strict";uc.exports=function(n){var e={};n=n||{},e.src_Any=Kr().source,e.src_Cc=Zr().source,e.src_Z=Xr().source,e.src_P=oi().source,e.src_ZPCc=[e.src_Z,e.src_P,e.src_Cc].join("|"),e.src_ZCc=[e.src_Z,e.src_Cc].join("|");var t="[><\uFF5C]";return e.src_pseudo_letter="(?:(?!"+t+"|"+e.src_ZPCc+")"+e.src_Any+")",e.src_ip4="(?:(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)",e.src_auth="(?:(?:(?!"+e.src_ZCc+"|[@/\\[\\]()]).)+@)?",e.src_port="(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?",e.src_host_terminator="(?=$|"+t+"|"+e.src_ZPCc+")(?!"+(n["---"]?"-(?!--)|":"-|")+"_|:\\d|\\.-|\\.(?!$|"+e.src_ZPCc+"))",e.src_path="(?:[/?#](?:(?!"+e.src_ZCc+"|"+t+`|[()[\\]{}.,"'?!\\-;]).|\\[(?:(?!`+e.src_ZCc+"|\\]).)*\\]|\\((?:(?!"+e.src_ZCc+"|[)]).)*\\)|\\{(?:(?!"+e.src_ZCc+'|[}]).)*\\}|\\"(?:(?!'+e.src_ZCc+`|["]).)+\\"|\\'(?:(?!`+e.src_ZCc+"|[']).)+\\'|\\'(?="+e.src_pseudo_letter+"|[-])|\\.{2,}[a-zA-Z0-9%/&]|\\.(?!"+e.src_ZCc+"|[.]|$)|"+(n["---"]?"\\-(?!--(?:[^-]|$))(?:-*)|":"\\-+|")+",(?!"+e.src_ZCc+"|$)|;(?!"+e.src_ZCc+"|$)|\\!+(?!"+e.src_ZCc+"|[!]|$)|\\?(?!"+e.src_ZCc+"|[?]|$))+|\\/)?",e.src_email_name='[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]*',e.src_xn="xn--[a-z0-9\\-]{1,59}",e.src_domain_root="(?:"+e.src_xn+"|"+e.src_pseudo_letter+"{1,63})",e.src_domain="(?:"+e.src_xn+"|(?:"+e.src_pseudo_letter+")|(?:"+e.src_pseudo_letter+"(?:-|"+e.src_pseudo_letter+"){0,61}"+e.src_pseudo_letter+"))",e.src_host="(?:(?:(?:(?:"+e.src_domain+")\\.)*"+e.src_domain+"))",e.tpl_host_fuzzy="(?:"+e.src_ip4+"|(?:(?:(?:"+e.src_domain+")\\.)+(?:%TLDS%)))",e.tpl_host_no_ip_fuzzy="(?:(?:(?:"+e.src_domain+")\\.)+(?:%TLDS%))",e.src_host_strict=e.src_host+e.src_host_terminator,e.tpl_host_fuzzy_strict=e.tpl_host_fuzzy+e.src_host_terminator,e.src_host_port_strict=e.src_host+e.src_port+e.src_host_terminator,e.tpl_host_port_fuzzy_strict=e.tpl_host_fuzzy+e.src_port+e.src_host_terminator,e.tpl_host_port_no_ip_fuzzy_strict=e.tpl_host_no_ip_fuzzy+e.src_port+e.src_host_terminator,e.tpl_host_fuzzy_test="localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:"+e.src_ZPCc+"|>|$))",e.tpl_email_fuzzy="(^|"+t+'|"|\\(|'+e.src_ZCc+")("+e.src_email_name+"@"+e.tpl_host_fuzzy_strict+")",e.tpl_link_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`|\uFF5C]|"+e.src_ZPCc+"))((?![$+<=>^`|\uFF5C])"+e.tpl_host_port_fuzzy_strict+e.src_path+")",e.tpl_link_no_ip_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`|\uFF5C]|"+e.src_ZPCc+"))((?![$+<=>^`|\uFF5C])"+e.tpl_host_port_no_ip_fuzzy_strict+e.src_path+")",e}});var gc=_((Fv,mc)=>{"use strict";function mo(n){var e=Array.prototype.slice.call(arguments,1);return e.forEach(function(t){t&&Object.keys(t).forEach(function(i){n[i]=t[i]})}),n}function vi(n){return Object.prototype.toString.call(n)}function fp(n){return vi(n)==="[object String]"}function mp(n){return vi(n)==="[object Object]"}function gp(n){return vi(n)==="[object RegExp]"}function dc(n){return vi(n)==="[object Function]"}function bp(n){return n.replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}var fc={fuzzyLink:!0,fuzzyEmail:!0,fuzzyIP:!1};function vp(n){return Object.keys(n||{}).reduce(function(e,t){return e||fc.hasOwnProperty(t)},!1)}var wp={"http:":{validate:function(n,e,t){var i=n.slice(e);return t.re.http||(t.re.http=new RegExp("^\\/\\/"+t.re.src_auth+t.re.src_host_port_strict+t.re.src_path,"i")),t.re.http.test(i)?i.match(t.re.http)[0].length:0}},"https:":"http:","ftp:":"http:","//":{validate:function(n,e,t){var i=n.slice(e);return t.re.no_http||(t.re.no_http=new RegExp("^"+t.re.src_auth+"(?:localhost|(?:(?:"+t.re.src_domain+")\\.)+"+t.re.src_domain_root+")"+t.re.src_port+t.re.src_host_terminator+t.re.src_path,"i")),t.re.no_http.test(i)?e>=3&&n[e-3]===":"||e>=3&&n[e-3]==="/"?0:i.match(t.re.no_http)[0].length:0}},"mailto:":{validate:function(n,e,t){var i=n.slice(e);return t.re.mailto||(t.re.mailto=new RegExp("^"+t.re.src_email_name+"@"+t.re.src_host_strict,"i")),t.re.mailto.test(i)?i.match(t.re.mailto)[0].length:0}}},yp="a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eosuw]|s[abcdeghijklmnortuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]",xp="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|\u0440\u0444".split("|");function kp(n){n.__index__=-1,n.__text_cache__=""}function Cp(n){return function(e,t){var i=e.slice(t);return n.test(i)?i.match(n)[0].length:0}}function pc(){return function(n,e){e.normalize(n)}}function bi(n){var e=n.re=hc()(n.__opts__),t=n.__tlds__.slice();n.onCompile(),n.__tlds_replaced__||t.push(yp),t.push(e.src_xn),e.src_tlds=t.join("|");function i(a){return a.replace("%TLDS%",e.src_tlds)}e.email_fuzzy=RegExp(i(e.tpl_email_fuzzy),"i"),e.link_fuzzy=RegExp(i(e.tpl_link_fuzzy),"i"),e.link_no_ip_fuzzy=RegExp(i(e.tpl_link_no_ip_fuzzy),"i"),e.host_fuzzy_test=RegExp(i(e.tpl_host_fuzzy_test),"i");var r=[];n.__compiled__={};function o(a,l){throw new Error('(LinkifyIt) Invalid schema "'+a+'": '+l)}Object.keys(n.__schemas__).forEach(function(a){var l=n.__schemas__[a];if(l!==null){var c={validate:null,link:null};if(n.__compiled__[a]=c,mp(l)){gp(l.validate)?c.validate=Cp(l.validate):dc(l.validate)?c.validate=l.validate:o(a,l),dc(l.normalize)?c.normalize=l.normalize:l.normalize?o(a,l):c.normalize=pc();return}if(fp(l)){r.push(a);return}o(a,l)}}),r.forEach(function(a){n.__compiled__[n.__schemas__[a]]&&(n.__compiled__[a].validate=n.__compiled__[n.__schemas__[a]].validate,n.__compiled__[a].normalize=n.__compiled__[n.__schemas__[a]].normalize)}),n.__compiled__[""]={validate:null,normalize:pc()};var s=Object.keys(n.__compiled__).filter(function(a){return a.length>0&&n.__compiled__[a]}).map(bp).join("|");n.re.schema_test=RegExp("(^|(?!_)(?:[><\uFF5C]|"+e.src_ZPCc+"))("+s+")","i"),n.re.schema_search=RegExp("(^|(?!_)(?:[><\uFF5C]|"+e.src_ZPCc+"))("+s+")","ig"),n.re.schema_at_start=RegExp("^"+n.re.schema_search.source,"i"),n.re.pretest=RegExp("("+n.re.schema_test.source+")|("+n.re.host_fuzzy_test.source+")|@","i"),kp(n)}function Ep(n,e){var t=n.__index__,i=n.__last_index__,r=n.__text_cache__.slice(t,i);this.schema=n.__schema__.toLowerCase(),this.index=t+e,this.lastIndex=i+e,this.raw=r,this.text=r,this.url=r}function go(n,e){var t=new Ep(n,e);return n.__compiled__[t.schema].normalize(t,n),t}function me(n,e){if(!(this instanceof me))return new me(n,e);e||vp(n)&&(e=n,n={}),this.__opts__=mo({},fc,e),this.__index__=-1,this.__last_index__=-1,this.__schema__="",this.__text_cache__="",this.__schemas__=mo({},wp,n),this.__compiled__={},this.__tlds__=xp,this.__tlds_replaced__=!1,this.re={},bi(this)}me.prototype.add=function(e,t){return this.__schemas__[e]=t,bi(this),this};me.prototype.set=function(e){return this.__opts__=mo(this.__opts__,e),this};me.prototype.test=function(e){if(this.__text_cache__=e,this.__index__=-1,!e.length)return!1;var t,i,r,o,s,a,l,c,u;if(this.re.schema_test.test(e)){for(l=this.re.schema_search,l.lastIndex=0;(t=l.exec(e))!==null;)if(o=this.testSchemaAt(e,t[2],l.lastIndex),o){this.__schema__=t[2],this.__index__=t.index+t[1].length,this.__last_index__=t.index+t[0].length+o;break}}return this.__opts__.fuzzyLink&&this.__compiled__["http:"]&&(c=e.search(this.re.host_fuzzy_test),c>=0&&(this.__index__<0||c<this.__index__)&&(i=e.match(this.__opts__.fuzzyIP?this.re.link_fuzzy:this.re.link_no_ip_fuzzy))!==null&&(s=i.index+i[1].length,(this.__index__<0||s<this.__index__)&&(this.__schema__="",this.__index__=s,this.__last_index__=i.index+i[0].length))),this.__opts__.fuzzyEmail&&this.__compiled__["mailto:"]&&(u=e.indexOf("@"),u>=0&&(r=e.match(this.re.email_fuzzy))!==null&&(s=r.index+r[1].length,a=r.index+r[0].length,(this.__index__<0||s<this.__index__||s===this.__index__&&a>this.__last_index__)&&(this.__schema__="mailto:",this.__index__=s,this.__last_index__=a))),this.__index__>=0};me.prototype.pretest=function(e){return this.re.pretest.test(e)};me.prototype.testSchemaAt=function(e,t,i){return this.__compiled__[t.toLowerCase()]?this.__compiled__[t.toLowerCase()].validate(e,i,this):0};me.prototype.match=function(e){var t=0,i=[];this.__index__>=0&&this.__text_cache__===e&&(i.push(go(this,t)),t=this.__last_index__);for(var r=t?e.slice(t):e;this.test(r);)i.push(go(this,t)),r=r.slice(this.__last_index__),t+=this.__last_index__;return i.length?i:null};me.prototype.matchAtStart=function(e){if(this.__text_cache__=e,this.__index__=-1,!e.length)return null;var t=this.re.schema_at_start.exec(e);if(!t)return null;var i=this.testSchemaAt(e,t[2],t[0].length);return i?(this.__schema__=t[2],this.__index__=t.index+t[1].length,this.__last_index__=t.index+t[0].length+i,go(this,0)):null};me.prototype.tlds=function(e,t){return e=Array.isArray(e)?e:[e],t?(this.__tlds__=this.__tlds__.concat(e).sort().filter(function(i,r,o){return i!==o[r-1]}).reverse(),bi(this),this):(this.__tlds__=e.slice(),this.__tlds_replaced__=!0,bi(this),this)};me.prototype.normalize=function(e){e.schema||(e.url="http://"+e.url),e.schema==="mailto:"&&!/^mailto:/i.test(e.url)&&(e.url="mailto:"+e.url)};me.prototype.onCompile=function(){};mc.exports=me});var Ec={};St(Ec,{decode:()=>yo,default:()=>$p,encode:()=>xo,toASCII:()=>Cc,toUnicode:()=>kc,ucs2decode:()=>wo,ucs2encode:()=>yc});function Ve(n){throw new RangeError(Dp[n])}function Tp(n,e){let t=[],i=n.length;for(;i--;)t[i]=e(n[i]);return t}function wc(n,e){let t=n.split("@"),i="";t.length>1&&(i=t[0]+"@",n=t[1]),n=n.replace(Ap,".");let r=n.split("."),o=Tp(r,e).join(".");return i+o}function wo(n){let e=[],t=0,i=n.length;for(;t<i;){let r=n.charCodeAt(t++);if(r>=55296&&r<=56319&&t<i){let o=n.charCodeAt(t++);(o&64512)==56320?e.push(((r&1023)<<10)+(o&1023)+65536):(e.push(r),t--)}else e.push(r)}return e}var vc,_p,Sp,Ap,Dp,bo,Le,vo,yc,Lp,bc,xc,yo,xo,kc,Cc,Ip,$p,_c=qu(()=>{"use strict";vc="-",_p=/^xn--/,Sp=/[^\0-\x7F]/,Ap=/[\x2E\u3002\uFF0E\uFF61]/g,Dp={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},bo=36-1,Le=Math.floor,vo=String.fromCharCode;yc=n=>String.fromCodePoint(...n),Lp=function(n){return n>=48&&n<58?26+(n-48):n>=65&&n<91?n-65:n>=97&&n<123?n-97:36},bc=function(n,e){return n+22+75*(n<26)-((e!=0)<<5)},xc=function(n,e,t){let i=0;for(n=t?Le(n/700):n>>1,n+=Le(n/e);n>bo*26>>1;i+=36)n=Le(n/bo);return Le(i+(bo+1)*n/(n+38))},yo=function(n){let e=[],t=n.length,i=0,r=128,o=72,s=n.lastIndexOf(vc);s<0&&(s=0);for(let a=0;a<s;++a)n.charCodeAt(a)>=128&&Ve("not-basic"),e.push(n.charCodeAt(a));for(let a=s>0?s+1:0;a<t;){let l=i;for(let u=1,h=36;;h+=36){a>=t&&Ve("invalid-input");let d=Lp(n.charCodeAt(a++));d>=36&&Ve("invalid-input"),d>Le((2147483647-i)/u)&&Ve("overflow"),i+=d*u;let p=h<=o?1:h>=o+26?26:h-o;if(d<p)break;let f=36-p;u>Le(2147483647/f)&&Ve("overflow"),u*=f}let c=e.length+1;o=xc(i-l,c,l==0),Le(i/c)>2147483647-r&&Ve("overflow"),r+=Le(i/c),i%=c,e.splice(i++,0,r)}return String.fromCodePoint(...e)},xo=function(n){let e=[];n=wo(n);let t=n.length,i=128,r=0,o=72;for(let l of n)l<128&&e.push(vo(l));let s=e.length,a=s;for(s&&e.push(vc);a<t;){let l=2147483647;for(let u of n)u>=i&&u<l&&(l=u);let c=a+1;l-i>Le((2147483647-r)/c)&&Ve("overflow"),r+=(l-i)*c,i=l;for(let u of n)if(u<i&&++r>2147483647&&Ve("overflow"),u===i){let h=r;for(let d=36;;d+=36){let p=d<=o?1:d>=o+26?26:d-o;if(h<p)break;let f=h-p,m=36-p;e.push(vo(bc(p+f%m,0))),h=Le(f/m)}e.push(vo(bc(h,0))),o=xc(r,c,a===s),r=0,++a}++r,++i}return e.join("")},kc=function(n){return wc(n,function(e){return _p.test(e)?yo(e.slice(4).toLowerCase()):e})},Cc=function(n){return wc(n,function(e){return Sp.test(e)?"xn--"+xo(e):e})},Ip={version:"2.1.0",ucs2:{decode:wo,encode:yc},decode:yo,encode:xo,toASCII:Cc,toUnicode:kc},$p=Ip});var Ac=_((qv,Sc)=>{"use strict";Sc.exports={options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"\u201C\u201D\u2018\u2019",highlight:null,maxNesting:100},components:{core:{},block:{},inline:{}}}});var Tc=_((Bv,Dc)=>{"use strict";Dc.exports={options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"\u201C\u201D\u2018\u2019",highlight:null,maxNesting:20},components:{core:{rules:["normalize","block","inline","text_join"]},block:{rules:["paragraph"]},inline:{rules:["text"],rules2:["balance_pairs","fragments_join"]}}}});var Ic=_((Pv,Lc)=>{"use strict";Lc.exports={options:{html:!0,xhtmlOut:!0,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"\u201C\u201D\u2018\u2019",highlight:null,maxNesting:20},components:{core:{rules:["normalize","block","inline","text_join"]},block:{rules:["blockquote","code","fence","heading","hr","html_block","lheading","list","reference","paragraph"]},inline:{rules:["autolink","backticks","emphasis","entity","escape","html_inline","image","link","newline","text"],rules2:["balance_pairs","emphasis","fragments_join"]}}}});var qc=_((Ov,Fc)=>{"use strict";var Yt=R(),Mp=fa(),Fp=ga(),qp=Ua(),Bp=Sl(),Pp=cc(),Op=gc(),Qe=Gr(),$c=(_c(),Bu(Ec)),Rp={default:Ac(),zero:Tc(),commonmark:Ic()},Np=/^(vbscript|javascript|file|data):/,zp=/^data:image\/(gif|png|jpeg|webp);/;function Hp(n){var e=n.trim().toLowerCase();return Np.test(e)?!!zp.test(e):!0}var Mc=["http:","https:","mailto:"];function Up(n){var e=Qe.parse(n,!0);if(e.hostname&&(!e.protocol||Mc.indexOf(e.protocol)>=0))try{e.hostname=$c.toASCII(e.hostname)}catch{}return Qe.encode(Qe.format(e))}function jp(n){var e=Qe.parse(n,!0);if(e.hostname&&(!e.protocol||Mc.indexOf(e.protocol)>=0))try{e.hostname=$c.toUnicode(e.hostname)}catch{}return Qe.decode(Qe.format(e),Qe.decode.defaultChars+"%")}function be(n,e){if(!(this instanceof be))return new be(n,e);e||Yt.isString(n)||(e=n||{},n="default"),this.inline=new Pp,this.block=new Bp,this.core=new qp,this.renderer=new Fp,this.linkify=new Op,this.validateLink=Hp,this.normalizeLink=Up,this.normalizeLinkText=jp,this.utils=Yt,this.helpers=Yt.assign({},Mp),this.options={},this.configure(n),e&&this.set(e)}be.prototype.set=function(n){return Yt.assign(this.options,n),this};be.prototype.configure=function(n){var e=this,t;if(Yt.isString(n)&&(t=n,n=Rp[t],!n))throw new Error('Wrong `markdown-it` preset "'+t+'", check name');if(!n)throw new Error("Wrong `markdown-it` preset, can't be empty");return n.options&&e.set(n.options),n.components&&Object.keys(n.components).forEach(function(i){n.components[i].rules&&e[i].ruler.enableOnly(n.components[i].rules),n.components[i].rules2&&e[i].ruler2.enableOnly(n.components[i].rules2)}),this};be.prototype.enable=function(n,e){var t=[];Array.isArray(n)||(n=[n]),["core","block","inline"].forEach(function(r){t=t.concat(this[r].ruler.enable(n,!0))},this),t=t.concat(this.inline.ruler2.enable(n,!0));var i=n.filter(function(r){return t.indexOf(r)<0});if(i.length&&!e)throw new Error("MarkdownIt. Failed to enable unknown rule(s): "+i);return this};be.prototype.disable=function(n,e){var t=[];Array.isArray(n)||(n=[n]),["core","block","inline"].forEach(function(r){t=t.concat(this[r].ruler.disable(n,!0))},this),t=t.concat(this.inline.ruler2.disable(n,!0));var i=n.filter(function(r){return t.indexOf(r)<0});if(i.length&&!e)throw new Error("MarkdownIt. Failed to disable unknown rule(s): "+i);return this};be.prototype.use=function(n){var e=[this].concat(Array.prototype.slice.call(arguments,1));return n.apply(n,e),this};be.prototype.parse=function(n,e){if(typeof n!="string")throw new Error("Input data should be a String");var t=new this.core.State(n,this,e);return this.core.process(t),t.tokens};be.prototype.render=function(n,e){return e=e||{},this.renderer.render(this.parse(n,e),this.options,e)};be.prototype.parseInline=function(n,e){var t=new this.core.State(n,this,e);return t.inlineMode=!0,this.core.process(t),t.tokens};be.prototype.renderInline=function(n,e){return e=e||{},this.renderer.render(this.parseInline(n,e),this.options,e)};Fc.exports=be});var Pc=_((Rv,Bc)=>{"use strict";Bc.exports=qc()});var Hc=_((Nv,zc)=>{var ko=!0,Rc=!1,Nc=!1;zc.exports=function(n,e){e&&(ko=!e.enabled,Rc=!!e.label,Nc=!!e.labelAfter),n.core.ruler.after("inline","github-task-lists",function(t){for(var i=t.tokens,r=2;r<i.length;r++)Wp(i,r)&&(Gp(i[r],t.Token),Oc(i[r-2],"class","task-list-item"+(ko?"":" enabled")),Oc(i[Vp(i,r-2)],"class","contains-task-list"))})};function Oc(n,e,t){var i=n.attrIndex(e),r=[e,t];i<0?n.attrPush(r):n.attrs[i]=r}function Vp(n,e){for(var t=n[e].level-1,i=e-1;i>=0;i--)if(n[i].level===t)return i;return-1}function Wp(n,e){return Jp(n[e])&&Qp(n[e-1])&&ef(n[e-2])&&tf(n[e])}function Gp(n,e){if(n.children.unshift(Kp(n,e)),n.children[1].content=n.children[1].content.slice(3),n.content=n.content.slice(3),Rc)if(Nc){n.children.pop();var t="task-item-"+Math.ceil(Math.random()*(1e4*1e3)-1e3);n.children[0].content=n.children[0].content.slice(0,-1)+' id="'+t+'">',n.children.push(Yp(n.content,t,e))}else n.children.unshift(Zp(e)),n.children.push(Xp(e))}function Kp(n,e){var t=new e("html_inline","",0),i=ko?' disabled="" ':"";return n.content.indexOf("[ ] ")===0?t.content='<input class="task-list-item-checkbox"'+i+'type="checkbox">':(n.content.indexOf("[x] ")===0||n.content.indexOf("[X] ")===0)&&(t.content='<input class="task-list-item-checkbox" checked=""'+i+'type="checkbox">'),t}function Zp(n){var e=new n("html_inline","",0);return e.content="<label>",e}function Xp(n){var e=new n("html_inline","",0);return e.content="</label>",e}function Yp(n,e,t){var i=new t("html_inline","",0);return i.content='<label class="task-list-item-label" for="'+e+'">'+n+"</label>",i.attrs=[{for:e}],i}function Jp(n){return n.type==="inline"}function Qp(n){return n.type==="paragraph_open"}function ef(n){return n.type==="list_item_open"}function tf(n){return n.content.indexOf("[ ] ")===0||n.content.indexOf("[x] ")===0||n.content.indexOf("[X] ")===0}});var dr={};St(dr,{emit:()=>ur,emitPublic:()=>Nu,error:()=>hr,listen:()=>Ru,showResponseError:()=>Uu,showValidationErrors:()=>Hu,success:()=>zu});var on={},Ou=[];function ur(n,e){Ou.push({name:n,data:e});let t=on[n]||[];for(let i of t)i(e)}function Ru(n,e){typeof on[n]>"u"&&(on[n]=[]),on[n].push(e)}function Nu(n,e,t){let i=new CustomEvent(e,{detail:t,bubbles:!0});n.dispatchEvent(i)}function zu(n){ur("success",n)}function hr(n){ur("error",n)}function Hu(n){if(n.status&&n.status===422&&n.data){let e=Object.values(n.data).flat().join(`
-`);hr(e)}}function Uu(n){n.status&&n.status>=400&&n.data&&n.data.message&&hr(n.data.message)}var pr={};St(pr,{HttpError:()=>sn,createXMLHttpRequest:()=>Vu,delete:()=>Xu,get:()=>Wu,patch:()=>Zu,post:()=>Gu,put:()=>Ku});async function ju(n){if(n.status===204)return null;let t=(n.headers.get("Content-Type")||"").split(";")[0].split("/").pop();return t==="javascript"||t==="json"?n.json():n.text()}var sn=class extends Error{constructor(e,t){super(e.statusText),this.data=t,this.headers=e.headers,this.redirected=e.redirected,this.status=e.status,this.statusText=e.statusText,this.url=e.url,this.original=e}};function Vu(n,e,t={}){let i=document.querySelector("meta[name=token]").getAttribute("content"),r=new XMLHttpRequest;for(let[o,s]of Object.entries(t))r.addEventListener(o,s.bind(r));return r.open(n,e),r.withCredentials=!0,r.setRequestHeader("X-CSRF-TOKEN",i),r}async function Go(n,e={}){let t=n;if(t.startsWith("http")||(t=window.baseUrl(t)),e.params){let l=new URL(t);for(let c of Object.keys(e.params)){let u=e.params[c];typeof u<"u"&&u!==null&&l.searchParams.set(c,u)}t=l.toString()}let i=document.querySelector("meta[name=token]").getAttribute("content"),r={...e,credentials:"same-origin"};r.headers={...r.headers||{},baseURL:window.baseUrl(""),"X-CSRF-TOKEN":i};let o=await fetch(t,r),s=await ju(o),a={data:s,headers:o.headers,redirected:o.redirected,status:o.status,statusText:o.statusText,url:o.url,original:o};if(!o.ok)throw new sn(o,s);return a}async function an(n,e,t=null){let i={method:n,body:t};return typeof t=="object"&&!(t instanceof FormData)&&(i.headers={"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},i.body=JSON.stringify(t)),t instanceof FormData&&n!=="post"&&(t.append("_method",n),i.method="post"),Go(e,i)}async function Wu(n,e={}){return Go(n,{method:"GET",params:e})}async function Gu(n,e=null){return an("POST",n,e)}async function Ku(n,e=null){return an("PUT",n,e)}async function Zu(n,e=null){return an("PATCH",n,e)}async function Xu(n,e=null){return an("DELETE",n,e)}var fr=class{constructor(){this.store=new Map,this.parseTranslations()}parseTranslations(){let e=document.querySelectorAll('meta[name="translation"]');for(let t of e){let i=t.getAttribute("key"),r=t.getAttribute("value");this.store.set(i,r)}}get(e,t){let i=this.getTransText(e);return this.performReplacements(i,t)}getPlural(e,t,i){let r=this.getTransText(e);return this.parsePlural(r,t,i)}parsePlural(e,t,i){let r=e.split("|"),o=/^{([0-9]+)}/,s=/^\[([0-9]+),([0-9*]+)]/,a=null;for(let l of r){let c=l.match(o);if(c!==null&&Number(c[1])===t){a=l.replace(o,"").trim();break}let u=l.match(s);if(u!==null&&Number(u[1])<=t&&(u[2]==="*"||Number(u[2])>=t)){a=l.replace(s,"").trim();break}}return a===null&&r.length>1&&(a=t===1?r[0]:r[1]),a===null&&(a=r[0]),this.performReplacements(a,i)}getTransText(e){let t=this.store.get(e);return t===void 0&&console.warn(`Translation with key "${e}" does not exist`),t}performReplacements(e,t){if(!t)return e;let i=e.match(/:(\S+)/g);if(i===null)return e;let r=e;return i.forEach(o=>{let s=o.substring(1);typeof t[s]>"u"||(r=r.replace(o,t[s]))}),r}},Ko=fr;var wr={};St(wr,{first:()=>eh,firstOnElement:()=>nh,get:()=>th,init:()=>br,register:()=>vr});function mr(n){let e=i=>i.slice(0,1).toUpperCase()+i.slice(1),t=n.split("-");return t[0]+t.slice(1).map(e).join("")}function Zo(n){return n.replace(/[A-Z]/g,(e,t)=>(t>0?"-":"")+e.toLowerCase())}var At={},Xo={},gr=new WeakMap;function Yu(n,e){let t={},i={},r=`${n}@`,o=`[refs*="${r}"]`,s=[...e.querySelectorAll(o)];e.matches(o)&&s.push(e);for(let a of s){let l=a.getAttribute("refs").split(" ").filter(c=>c.startsWith(r)).map(c=>c.replace(r,"")).map(mr);for(let c of l)t[c]=a,typeof i[c]>"u"&&(i[c]=[]),i[c].push(a)}return{refs:t,manyRefs:i}}function Ju(n,e){let t={},i=`option:${n}:`;for(let{name:r,value:o}of e.attributes)if(r.startsWith(i)){let s=r.replace(i,"");t[mr(s)]=o||""}return t}function Qu(n,e){let t=Xo[n];if(t===void 0)return;let i;try{i=new t,i.$name=n,i.$el=e;let o=Yu(n,e);i.$refs=o.refs,i.$manyRefs=o.manyRefs,i.$opts=Ju(n,e),i.setup()}catch(o){console.error("Failed to create component",o,n,e)}typeof At[n]>"u"&&(At[n]=[]),At[n].push(i);let r=gr.get(e)||{};r[n]=i,gr.set(e,r)}function br(n=document){let e=n.querySelectorAll("[component],[components]");for(let t of e){let i=`${t.getAttribute("component")||""} ${t.getAttribute("components")}`.toLowerCase().split(" ").filter(Boolean);for(let r of i)Qu(r,t)}}function vr(n){let e=Object.keys(n);for(let t of e)Xo[Zo(t)]=n[t]}function eh(n){return(At[n]||[null])[0]}function th(n){return At[n]||[]}function nh(n,e){return(gr.get(n)||{})[e]||null}var Uo={};St(Uo,{AddRemoveRows:()=>cn,AjaxDeleteRow:()=>un,AjaxForm:()=>hn,Attachments:()=>dn,AttachmentsList:()=>pn,AutoSubmit:()=>mn,AutoSuggest:()=>fn,BackToTop:()=>gn,BookSort:()=>Fn,ChapterContents:()=>Bn,CodeEditor:()=>Pn,CodeHighlighter:()=>On,CodeTextarea:()=>Rn,Collapsible:()=>Nn,ConfirmDialog:()=>zn,CustomCheckbox:()=>Hn,DetailsHighlighter:()=>Un,Dropdown:()=>jn,DropdownSearch:()=>Vn,Dropzone:()=>Wn,EditorToolbox:()=>Gn,EntityPermissions:()=>Kn,EntitySearch:()=>Zn,EntitySelector:()=>Xn,EntitySelectorPopup:()=>Yn,EventEmitSelect:()=>Jn,ExpandToggle:()=>Qn,GlobalSearch:()=>ei,HeaderMobileToggle:()=>ti,ImageManager:()=>ni,ImagePicker:()=>ii,ListSortControl:()=>ri,MarkdownEditor:()=>Mi,NewUserPassword:()=>Fi,Notification:()=>qi,OptionalInput:()=>Bi,PageComment:()=>Pi,PageComments:()=>Oi,PageDisplay:()=>Ri,PageEditor:()=>Ni,PagePicker:()=>Hi,PermissionsTable:()=>Ui,Pointer:()=>ji,Popup:()=>Vi,SettingAppColorScheme:()=>Wi,SettingColorPicker:()=>Gi,SettingHomepageControl:()=>Ki,ShelfSort:()=>Zi,ShortcutInput:()=>Yi,Shortcuts:()=>Xi,SortableList:()=>Ji,SubmitOnChange:()=>Qi,Tabs:()=>er,TagManager:()=>tr,TemplateManager:()=>nr,ToggleSwitch:()=>ir,TriLayout:()=>rr,UserSelect:()=>or,WebhookEvents:()=>sr,WysiwygEditor:()=>cr});function Ee(n,e={},t=[]){let i=document.createElement(n);for(let[r,o]of Object.entries(e))o===null?i.removeAttribute(r):i.setAttribute(r,o);for(let r of t)typeof r=="string"?i.append(document.createTextNode(r)):i.append(r);return i}function yr(n,e){let t=document.querySelectorAll(n);for(let i of t)e(i)}function ln(n,e,t){for(let i of e)n.addEventListener(i,t)}function O(n,e){Array.isArray(n)||(n=[n]);for(let t of n)t.addEventListener("click",e),t.addEventListener("keydown",i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),e(i))})}function Yo(n,e,t){Array.isArray(e)||(e=[e]);let i=r=>{r.key===n&&t(r)};e.forEach(r=>r.addEventListener("keydown",i))}function st(n,e){Yo("Enter",n,e)}function Jo(n,e){Yo("Escape",n,e)}function K(n,e,t,i){n.addEventListener(t,r=>{let o=r.target.closest(e);o&&i.call(o,r,o)})}function Qo(n,e){let t=document.querySelectorAll(n);e=e.toLowerCase();for(let i of t)if(i.textContent.toLowerCase().includes(e))return i;return null}function Dt(n){n.innerHTML='<div class="loading-container"><div></div><div></div><div></div></div>'}function at(){let n=document.createElement("div");return n.classList.add("loading-container"),n.innerHTML="<div></div><div></div><div></div>",n}function Tt(n){let e=n.querySelectorAll(".loading-container");for(let t of e)t.remove()}function _e(n){let e=document.createElement("div");return e.innerHTML=n,window.$components.init(e),e.children[0]}function Ne(n,e,t){let i;return function(...o){let s=this,a=function(){i=null,t||n.apply(s,o)},l=t&&!i;clearTimeout(i),i=setTimeout(a,e),l&&n.apply(s,o)}}function kr(n){if(!n)return;n.scrollIntoView({behavior:"smooth"});let e=getComputedStyle(document.body).getPropertyValue("--color-primary-light"),t=window.getComputedStyle(n).getPropertyValue("background-color");n.style.backgroundColor=e,setTimeout(()=>{n.classList.add("selectFade"),n.style.backgroundColor=t},10),setTimeout(()=>{n.classList.remove("selectFade"),n.style.backgroundColor=""},3e3)}function es(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function ts(){let n=()=>((1+Math.random())*65536|0).toString(16).substring(1);return`${n()+n()}-${n()}-${n()}-${n()}-${n()}${n()}${n()}`}function ns(n){return new Promise(e=>{setTimeout(e,n)})}var g=class{constructor(){se(this,"$name","");se(this,"$el",null);se(this,"$refs",{});se(this,"$manyRefs",{});se(this,"$opts",{})}setup(){}$emit(e,t={}){t.from=this;let i=this.$name,r=new CustomEvent(`${i}-${e}`,{bubbles:!0,detail:t});this.$el.dispatchEvent(r)}};var cn=class extends g{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)),K(this.$el,this.removeSelector,"click",e=>{e.target.closest(this.rowSelector).remove()})}add(){let e=this.modelRow.cloneNode(!0);e.classList.remove("hidden"),this.setClonedInputNames(e),this.modelRow.parentNode.insertBefore(e,this.modelRow),window.$components.init(e)}setClonedInputNames(e){let t=ts(),i=e.querySelectorAll('[name*="randrowid"]');for(let r of i)r.name=r.name.split("randrowid").join(t)}};var un=class extends g{setup(){this.row=this.$el,this.url=this.$opts.url,this.deleteButtons=this.$manyRefs.delete,O(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.opacity=null,this.row.style.pointerEvents=null})}};var hn=class extends g{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}st(this.container,e=>{this.submitFakeForm(),e.preventDefault()}),this.submitButtons.forEach(e=>O(e,this.submitFakeForm.bind(this)))}submitFakeForm(){let e=new FormData,t=this.container.querySelectorAll("[name]");for(let i of t)e.append(i.getAttribute("name"),i.value);this.submit(e)}submitRealForm(e){e.preventDefault();let t=new FormData(this.container);this.submit(t)}async submit(e){this.responseContainer.style.opacity="0.7",this.responseContainer.style.pointerEvents="none";try{let t=await window.$http[this.method.toLowerCase()](this.url,e);this.$emit("success",{formData:e}),this.responseContainer.innerHTML=t.data,this.successMessage&&window.$events.emit("success",this.successMessage)}catch(t){this.responseContainer.innerHTML=t.data}window.$components.init(this.responseContainer),this.responseContainer.style.opacity=null,this.responseContainer.style.pointerEvents=null}};var dn=class extends g{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 e=this.reloadList.bind(this);this.container.addEventListener("dropzone-upload-success",e),this.container.addEventListener("ajax-form-success",e),this.container.addEventListener("sortable-list-sort",t=>{this.updateOrder(t.detail.ids)}),this.container.addEventListener("event-emit-select-edit",t=>{this.startEdit(t.detail.id)}),this.container.addEventListener("event-emit-select-edit-back",()=>{this.stopEdit()}),this.container.addEventListener("event-emit-select-insert",t=>{let i=t.target.closest("[data-drag-content]").getAttribute("data-drag-content"),r=JSON.parse(i);window.$events.emit("editor::insert",{html:r["text/html"],markdown:r["text/plain"]})}),this.attachLinkButton.addEventListener("click",()=>{this.showSection("links")})}showSection(e){let t={links:this.linksContainer,edit:this.editContainer,list:this.listContainer};for(let[i,r]of Object.entries(t))r.toggleAttribute("hidden",i!==e)}reloadList(){this.stopEdit(),window.$http.get(`/attachments/get/page/${this.pageId}`).then(e=>{this.listPanel.innerHTML=e.data,window.$components.init(this.listPanel)})}updateOrder(e){window.$http.put(`/attachments/sort/page/${this.pageId}`,{order:e}).then(t=>{window.$events.emit("success",t.data.message)})}async startEdit(e){this.showSection("edit"),Dt(this.editContainer);let t=await window.$http.get(`/attachments/edit/${e}`);this.editContainer.innerHTML=t.data,window.$components.init(this.editContainer)}stopEdit(){this.showSection("list")}};var pn=class extends g{setup(){this.container=this.$el,this.setupListeners()}setupListeners(){let e=t=>t.key==="Control"||t.key==="Meta";window.addEventListener("keydown",t=>{e(t)&&this.addOpenQueryToLinks()},{passive:!0}),window.addEventListener("keyup",t=>{e(t)&&this.removeOpenQueryFromLinks()},{passive:!0})}addOpenQueryToLinks(){let e=this.container.querySelectorAll("a.attachment-file");for(let t of e)t.href.split("?")[1]!=="open=true"&&(t.href+="?open=true",t.setAttribute("target","_blank"))}removeOpenQueryFromLinks(){let e=this.container.querySelectorAll("a.attachment-file");for(let t of e)t.href=t.href.split("?")[0],t.removeAttribute("target")}};var Lt,Cr,It,Er,ze=class{constructor(e,t=null,i=null){re(this,Lt);re(this,It);this.containers=[e],this.onEscape=t,this.onEnter=i,e.addEventListener("keydown",T(this,Lt,Cr).bind(this))}shareHandlingToEl(e){this.containers.push(e),e.addEventListener("keydown",T(this,Lt,Cr).bind(this))}focusNext(){let e=T(this,It,Er).call(this),i=e.indexOf(document.activeElement)+1;i>=e.length&&(i=0),e[i].focus()}focusPrevious(){let e=T(this,It,Er).call(this),i=e.indexOf(document.activeElement)-1;i<0&&(i=e.length-1),e[i].focus()}};Lt=new WeakSet,Cr=function(e){e.target.matches("input")&&(e.key==="ArrowRight"||e.key==="ArrowLeft")||(e.key==="ArrowDown"||e.key==="ArrowRight"?(this.focusNext(),e.preventDefault()):e.key==="ArrowUp"||e.key==="ArrowLeft"?(this.focusPrevious(),e.preventDefault()):e.key==="Escape"?this.onEscape?this.onEscape(e):document.activeElement&&document.activeElement.blur():e.key==="Enter"&&this.onEnter&&this.onEnter(e))},It=new WeakSet,Er=function(){let e=[],t='[tabindex]:not([tabindex="-1"]),[href],button:not([tabindex="-1"],[disabled]),input:not([type=hidden])';for(let i of this.containers)e.push(...i.querySelectorAll(t));return e};var _r={},fn=class extends g{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 ze(this.list,()=>{this.input.focus(),setTimeout(()=>this.hideSuggestions(),1)},t=>{t.preventDefault(),this.selectSuggestion(t.target.textContent)}).shareHandlingToEl(this.input),K(this.list,".text-item","click",(t,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",t=>{t.key==="Tab"&&this.hideSuggestions()})}selectSuggestion(e){this.input.value=e,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 e=this.getNameFilterIfNeeded(),t=this.input.value.toLowerCase(),r=(await this.loadSuggestions(t,e)).filter(o=>t===""||o.toLowerCase().startsWith(t)).slice(0,10);this.displaySuggestions(r)}getNameFilterIfNeeded(){return this.type!=="value"?null:this.parent.querySelector("input").value}async loadSuggestions(e,t=null){e=e.slice(0,4);let i={search:e,name:t},r=`${this.url}:${JSON.stringify(i)}`;if(_r[r])return _r[r];let o=await window.$http.get(this.url,i);return _r[r]=o.data,o.data}displaySuggestions(e){if(e.length===0){this.hideSuggestions();return}this.list.innerHTML=e.map(t=>`<li><div tabindex="0" class="text-item">${es(t)}</div></li>`).join(""),this.list.style.display="block";for(let t of this.list.querySelectorAll(".text-item"))t.addEventListener("blur",this.hideSuggestionsIfFocusedLost.bind(this))}hideSuggestions(){this.list.style.display="none"}hideSuggestionsIfFocusedLost(e){this.container.contains(e.relatedTarget)||this.hideSuggestions()}};var mn=class extends g{setup(){this.form=this.$el,this.form.submit()}};var gn=class extends g{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 e=document.documentElement.scrollTop||document.body.scrollTop||0;!this.showing&&e>this.breakPoint?(this.button.style.display="block",this.showing=!0,setTimeout(()=>{this.button.style.opacity=.4},1)):this.showing&&e<this.breakPoint&&(this.button.style.opacity=0,this.showing=!1,setTimeout(()=>{this.button.style.display="none"},500))}scrollToTop(){let e=this.targetElem.getBoundingClientRect().top,t=document.documentElement.scrollTop?document.documentElement:document.body,i=300,r=Date.now(),o=this.targetElem.getBoundingClientRect().top;function s(){let a=1-(Date.now()-r)/i,l=Math.abs(a*o);a>0?(t.scrollTop=l,requestAnimationFrame(s.bind(this))):t.scrollTop=e}requestAnimationFrame(s.bind(this))}};function is(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(n,r).enumerable})),t.push.apply(t,i)}return t}function Ae(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?is(Object(t),!0).forEach(function(i){ih(n,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):is(Object(t)).forEach(function(i){Object.defineProperty(n,i,Object.getOwnPropertyDescriptor(t,i))})}return n}function Cn(n){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Cn=function(e){return typeof e}:Cn=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Cn(n)}function ih(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function ke(){return ke=Object.assign||function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i])}return n},ke.apply(this,arguments)}function rh(n,e){if(n==null)return{};var t={},i=Object.keys(n),r,o;for(o=0;o<i.length;o++)r=i[o],!(e.indexOf(r)>=0)&&(t[r]=n[r]);return t}function oh(n,e){if(n==null)return{};var t=rh(n,e),i,r;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(n);for(r=0;r<o.length;r++)i=o[r],!(e.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(n,i)&&(t[i]=n[i])}return t}function sh(n){return ah(n)||lh(n)||ch(n)||uh()}function ah(n){if(Array.isArray(n))return Br(n)}function lh(n){if(typeof Symbol<"u"&&n[Symbol.iterator]!=null||n["@@iterator"]!=null)return Array.from(n)}function ch(n,e){if(n){if(typeof n=="string")return Br(n,e);var t=Object.prototype.toString.call(n).slice(8,-1);if(t==="Object"&&n.constructor&&(t=n.constructor.name),t==="Map"||t==="Set")return Array.from(n);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Br(n,e)}}function Br(n,e){(e==null||e>n.length)&&(e=n.length);for(var t=0,i=new Array(e);t<e;t++)i[t]=n[t];return i}function uh(){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 hh="1.15.0";function $e(n){if(typeof window<"u"&&window.navigator)return!!navigator.userAgent.match(n)}var Me=$e(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),jt=$e(/Edge/i),rs=$e(/firefox/i),Rt=$e(/safari/i)&&!$e(/chrome/i)&&!$e(/android/i),fs=$e(/iP(ad|od|hone)/i),ms=$e(/chrome/i)&&$e(/android/i),gs={capture:!1,passive:!1};function P(n,e,t){n.addEventListener(e,t,!Me&&gs)}function B(n,e,t){n.removeEventListener(e,t,!Me&&gs)}function Dn(n,e){if(e){if(e[0]===">"&&(e=e.substring(1)),n)try{if(n.matches)return n.matches(e);if(n.msMatchesSelector)return n.msMatchesSelector(e);if(n.webkitMatchesSelector)return n.webkitMatchesSelector(e)}catch{return!1}return!1}}function dh(n){return n.host&&n!==document&&n.host.nodeType?n.host:n.parentNode}function xe(n,e,t,i){if(n){t=t||document;do{if(e!=null&&(e[0]===">"?n.parentNode===t&&Dn(n,e):Dn(n,e))||i&&n===t)return n;if(n===t)break}while(n=dh(n))}return null}var os=/\s+/g;function X(n,e,t){if(n&&e)if(n.classList)n.classList[t?"add":"remove"](e);else{var i=(" "+n.className+" ").replace(os," ").replace(" "+e+" "," ");n.className=(i+(t?" "+e:"")).replace(os," ")}}function A(n,e,t){var i=n&&n.style;if(i){if(t===void 0)return document.defaultView&&document.defaultView.getComputedStyle?t=document.defaultView.getComputedStyle(n,""):n.currentStyle&&(t=n.currentStyle),e===void 0?t:t[e];!(e in i)&&e.indexOf("webkit")===-1&&(e="-webkit-"+e),i[e]=t+(typeof t=="string"?"":"px")}}function Xe(n,e){var t="";if(typeof n=="string")t=n;else do{var i=A(n,"transform");i&&i!=="none"&&(t=i+" "+t)}while(!e&&(n=n.parentNode));var r=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return r&&new r(t)}function bs(n,e,t){if(n){var i=n.getElementsByTagName(e),r=0,o=i.length;if(t)for(;r<o;r++)t(i[r],r);return i}return[]}function Se(){var n=document.scrollingElement;return n||document.documentElement}function j(n,e,t,i,r){if(!(!n.getBoundingClientRect&&n!==window)){var o,s,a,l,c,u,h;if(n!==window&&n.parentNode&&n!==Se()?(o=n.getBoundingClientRect(),s=o.top,a=o.left,l=o.bottom,c=o.right,u=o.height,h=o.width):(s=0,a=0,l=window.innerHeight,c=window.innerWidth,u=window.innerHeight,h=window.innerWidth),(e||t)&&n!==window&&(r=r||n.parentNode,!Me))do if(r&&r.getBoundingClientRect&&(A(r,"transform")!=="none"||t&&A(r,"position")!=="static")){var d=r.getBoundingClientRect();s-=d.top+parseInt(A(r,"border-top-width")),a-=d.left+parseInt(A(r,"border-left-width")),l=s+o.height,c=a+o.width;break}while(r=r.parentNode);if(i&&n!==window){var p=Xe(r||n),f=p&&p.a,m=p&&p.d;p&&(s/=m,a/=f,h/=f,u/=m,l=s+u,c=a+h)}return{top:s,left:a,bottom:l,right:c,width:h,height:u}}}function ss(n,e,t){for(var i=je(n,!0),r=j(n)[e];i;){var o=j(i)[t],s=void 0;if(t==="top"||t==="left"?s=r>=o:s=r<=o,!s)return i;if(i===Se())break;i=je(i,!1)}return!1}function pt(n,e,t,i){for(var r=0,o=0,s=n.children;o<s.length;){if(s[o].style.display!=="none"&&s[o]!==$.ghost&&(i||s[o]!==$.dragged)&&xe(s[o],t.draggable,n,!1)){if(r===e)return s[o];r++}o++}return null}function zr(n,e){for(var t=n.lastElementChild;t&&(t===$.ghost||A(t,"display")==="none"||e&&!Dn(t,e));)t=t.previousElementSibling;return t||null}function Y(n,e){var t=0;if(!n||!n.parentNode)return-1;for(;n=n.previousElementSibling;)n.nodeName.toUpperCase()!=="TEMPLATE"&&n!==$.clone&&(!e||Dn(n,e))&&t++;return t}function as(n){var e=0,t=0,i=Se();if(n)do{var r=Xe(n),o=r.a,s=r.d;e+=n.scrollLeft*o,t+=n.scrollTop*s}while(n!==i&&(n=n.parentNode));return[e,t]}function ph(n,e){for(var t in n)if(n.hasOwnProperty(t)){for(var i in e)if(e.hasOwnProperty(i)&&e[i]===n[t][i])return Number(t)}return-1}function je(n,e){if(!n||!n.getBoundingClientRect)return Se();var t=n,i=!1;do if(t.clientWidth<t.scrollWidth||t.clientHeight<t.scrollHeight){var r=A(t);if(t.clientWidth<t.scrollWidth&&(r.overflowX=="auto"||r.overflowX=="scroll")||t.clientHeight<t.scrollHeight&&(r.overflowY=="auto"||r.overflowY=="scroll")){if(!t.getBoundingClientRect||t===document.body)return Se();if(i||e)return t;i=!0}}while(t=t.parentNode);return Se()}function fh(n,e){if(n&&e)for(var t in e)e.hasOwnProperty(t)&&(n[t]=e[t]);return n}function Sr(n,e){return Math.round(n.top)===Math.round(e.top)&&Math.round(n.left)===Math.round(e.left)&&Math.round(n.height)===Math.round(e.height)&&Math.round(n.width)===Math.round(e.width)}var Nt;function vs(n,e){return function(){if(!Nt){var t=arguments,i=this;t.length===1?n.call(i,t[0]):n.apply(i,t),Nt=setTimeout(function(){Nt=void 0},e)}}}function mh(){clearTimeout(Nt),Nt=void 0}function ws(n,e,t){n.scrollLeft+=e,n.scrollTop+=t}function Hr(n){var e=window.Polymer,t=window.jQuery||window.Zepto;return e&&e.dom?e.dom(n).cloneNode(!0):t?t(n).clone(!0)[0]:n.cloneNode(!0)}function ls(n,e){A(n,"position","absolute"),A(n,"top",e.top),A(n,"left",e.left),A(n,"width",e.width),A(n,"height",e.height)}function Ar(n){A(n,"position",""),A(n,"top",""),A(n,"left",""),A(n,"width",""),A(n,"height","")}var ne="Sortable"+new Date().getTime();function gh(){var n=[],e;return{captureAnimationState:function(){if(n=[],!!this.options.animation){var i=[].slice.call(this.el.children);i.forEach(function(r){if(!(A(r,"display")==="none"||r===$.ghost)){n.push({target:r,rect:j(r)});var o=Ae({},n[n.length-1].rect);if(r.thisAnimationDuration){var s=Xe(r,!0);s&&(o.top-=s.f,o.left-=s.e)}r.fromRect=o}})}},addAnimationState:function(i){n.push(i)},removeAnimationState:function(i){n.splice(ph(n,{target:i}),1)},animateAll:function(i){var r=this;if(!this.options.animation){clearTimeout(e),typeof i=="function"&&i();return}var o=!1,s=0;n.forEach(function(a){var l=0,c=a.target,u=c.fromRect,h=j(c),d=c.prevFromRect,p=c.prevToRect,f=a.rect,m=Xe(c,!0);m&&(h.top-=m.f,h.left-=m.e),c.toRect=h,c.thisAnimationDuration&&Sr(d,h)&&!Sr(u,h)&&(f.top-h.top)/(f.left-h.left)===(u.top-h.top)/(u.left-h.left)&&(l=vh(f,d,p,r.options)),Sr(h,u)||(c.prevFromRect=u,c.prevToRect=h,l||(l=r.options.animation),r.animate(c,f,h,l)),l&&(o=!0,s=Math.max(s,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(e),o?e=setTimeout(function(){typeof i=="function"&&i()},s):typeof i=="function"&&i(),n=[]},animate:function(i,r,o,s){if(s){A(i,"transition",""),A(i,"transform","");var a=Xe(this.el),l=a&&a.a,c=a&&a.d,u=(r.left-o.left)/(l||1),h=(r.top-o.top)/(c||1);i.animatingX=!!u,i.animatingY=!!h,A(i,"transform","translate3d("+u+"px,"+h+"px,0)"),this.forRepaintDummy=bh(i),A(i,"transition","transform "+s+"ms"+(this.options.easing?" "+this.options.easing:"")),A(i,"transform","translate3d(0,0,0)"),typeof i.animated=="number"&&clearTimeout(i.animated),i.animated=setTimeout(function(){A(i,"transition",""),A(i,"transform",""),i.animated=!1,i.animatingX=!1,i.animatingY=!1},s)}}}}function bh(n){return n.offsetWidth}function vh(n,e,t,i){return Math.sqrt(Math.pow(e.top-n.top,2)+Math.pow(e.left-n.left,2))/Math.sqrt(Math.pow(e.top-t.top,2)+Math.pow(e.left-t.left,2))*i.animation}var lt=[],Dr={initializeByDefault:!0},Vt={mount:function(e){for(var t in Dr)Dr.hasOwnProperty(t)&&!(t in e)&&(e[t]=Dr[t]);lt.forEach(function(i){if(i.pluginName===e.pluginName)throw"Sortable: Cannot mount plugin ".concat(e.pluginName," more than once")}),lt.push(e)},pluginEvent:function(e,t,i){var r=this;this.eventCanceled=!1,i.cancel=function(){r.eventCanceled=!0};var o=e+"Global";lt.forEach(function(s){t[s.pluginName]&&(t[s.pluginName][o]&&t[s.pluginName][o](Ae({sortable:t},i)),t.options[s.pluginName]&&t[s.pluginName][e]&&t[s.pluginName][e](Ae({sortable:t},i)))})},initializePlugins:function(e,t,i,r){lt.forEach(function(a){var l=a.pluginName;if(!(!e.options[l]&&!a.initializeByDefault)){var c=new a(e,t,e.options);c.sortable=e,c.options=e.options,e[l]=c,ke(i,c.defaults)}});for(var o in e.options)if(e.options.hasOwnProperty(o)){var s=this.modifyOption(e,o,e.options[o]);typeof s<"u"&&(e.options[o]=s)}},getEventProperties:function(e,t){var i={};return lt.forEach(function(r){typeof r.eventProperties=="function"&&ke(i,r.eventProperties.call(t[r.pluginName],e))}),i},modifyOption:function(e,t,i){var r;return lt.forEach(function(o){e[o.pluginName]&&o.optionListeners&&typeof o.optionListeners[t]=="function"&&(r=o.optionListeners[t].call(e[o.pluginName],i))}),r}};function qt(n){var e=n.sortable,t=n.rootEl,i=n.name,r=n.targetEl,o=n.cloneEl,s=n.toEl,a=n.fromEl,l=n.oldIndex,c=n.newIndex,u=n.oldDraggableIndex,h=n.newDraggableIndex,d=n.originalEvent,p=n.putSortable,f=n.extraEventProperties;if(e=e||t&&t[ne],!!e){var m,y=e.options,v="on"+i.charAt(0).toUpperCase()+i.substr(1);window.CustomEvent&&!Me&&!jt?m=new CustomEvent(i,{bubbles:!0,cancelable:!0}):(m=document.createEvent("Event"),m.initEvent(i,!0,!0)),m.to=s||t,m.from=a||t,m.item=r||t,m.clone=o,m.oldIndex=l,m.newIndex=c,m.oldDraggableIndex=u,m.newDraggableIndex=h,m.originalEvent=d,m.pullMode=p?p.lastPutMode:void 0;var b=Ae(Ae({},f),Vt.getEventProperties(i,e));for(var k in b)m[k]=b[k];t&&t.dispatchEvent(m),y[v]&&y[v].call(e,m)}}var wh=["evt"],ae=function(e,t){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=i.evt,o=oh(i,wh);Vt.pluginEvent.bind($)(e,t,Ae({dragEl:C,parentEl:G,ghostEl:F,rootEl:U,nextEl:Ze,lastDownEl:En,cloneEl:W,cloneHidden:Ue,dragStarted:Bt,putSortable:Q,activeSortable:$.active,originalEvent:r,oldIndex:dt,oldDraggableIndex:zt,newIndex:fe,newDraggableIndex:He,hideGhostForTarget:Cs,unhideGhostForTarget:Es,cloneNowHidden:function(){Ue=!0},cloneNowShown:function(){Ue=!1},dispatchSortableEvent:function(a){oe({sortable:t,name:a,originalEvent:r})}},o))};function oe(n){qt(Ae({putSortable:Q,cloneEl:W,targetEl:C,rootEl:U,oldIndex:dt,oldDraggableIndex:zt,newIndex:fe,newDraggableIndex:He},n))}var C,G,F,U,Ze,En,W,Ue,dt,fe,zt,He,bn,Q,ht=!1,Tn=!1,Ln=[],Ge,we,Tr,Lr,cs,us,Bt,ct,Ht,Ut=!1,vn=!1,_n,te,Ir=[],Pr=!1,In=[],Mn=typeof document<"u",wn=fs,hs=jt||Me?"cssFloat":"float",yh=Mn&&!ms&&!fs&&"draggable"in document.createElement("div"),ys=function(){if(Mn){if(Me)return!1;var n=document.createElement("x");return n.style.cssText="pointer-events:auto",n.style.pointerEvents==="auto"}}(),xs=function(e,t){var i=A(e),r=parseInt(i.width)-parseInt(i.paddingLeft)-parseInt(i.paddingRight)-parseInt(i.borderLeftWidth)-parseInt(i.borderRightWidth),o=pt(e,0,t),s=pt(e,1,t),a=o&&A(o),l=s&&A(s),c=a&&parseInt(a.marginLeft)+parseInt(a.marginRight)+j(o).width,u=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+j(s).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(o&&a.float&&a.float!=="none"){var h=a.float==="left"?"left":"right";return s&&(l.clear==="both"||l.clear===h)?"vertical":"horizontal"}return o&&(a.display==="block"||a.display==="flex"||a.display==="table"||a.display==="grid"||c>=r&&i[hs]==="none"||s&&i[hs]==="none"&&c+u>r)?"vertical":"horizontal"},xh=function(e,t,i){var r=i?e.left:e.top,o=i?e.right:e.bottom,s=i?e.width:e.height,a=i?t.left:t.top,l=i?t.right:t.bottom,c=i?t.width:t.height;return r===a||o===l||r+s/2===a+c/2},kh=function(e,t){var i;return Ln.some(function(r){var o=r[ne].options.emptyInsertThreshold;if(!(!o||zr(r))){var s=j(r),a=e>=s.left-o&&e<=s.right+o,l=t>=s.top-o&&t<=s.bottom+o;if(a&&l)return i=r}}),i},ks=function(e){function t(o,s){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(o==null&&(s||h))return!0;if(o==null||o===!1)return!1;if(s&&o==="clone")return o;if(typeof o=="function")return t(o(a,l,c,u),s)(a,l,c,u);var d=(s?a:l).options.group.name;return o===!0||typeof o=="string"&&o===d||o.join&&o.indexOf(d)>-1}}var i={},r=e.group;(!r||Cn(r)!="object")&&(r={name:r}),i.name=r.name,i.checkPull=t(r.pull,!0),i.checkPut=t(r.put),i.revertClone=r.revertClone,e.group=i},Cs=function(){!ys&&F&&A(F,"display","none")},Es=function(){!ys&&F&&A(F,"display","")};Mn&&!ms&&document.addEventListener("click",function(n){if(Tn)return n.preventDefault(),n.stopPropagation&&n.stopPropagation(),n.stopImmediatePropagation&&n.stopImmediatePropagation(),Tn=!1,!1},!0);var Ke=function(e){if(C){e=e.touches?e.touches[0]:e;var t=kh(e.clientX,e.clientY);if(t){var i={};for(var r in e)e.hasOwnProperty(r)&&(i[r]=e[r]);i.target=i.rootEl=t,i.preventDefault=void 0,i.stopPropagation=void 0,t[ne]._onDragOver(i)}}},Ch=function(e){C&&C.parentNode[ne]._isOutsideThisEl(e.target)};function $(n,e){if(!(n&&n.nodeType&&n.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(n));this.el=n,this.options=e=ke({},e),n[ne]=this;var t={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 xs(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(s,a){s.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:$.supportPointer!==!1&&"PointerEvent"in window&&!Rt,emptyInsertThreshold:5};Vt.initializePlugins(this,n,t);for(var i in t)!(i in e)&&(e[i]=t[i]);ks(e);for(var r in this)r.charAt(0)==="_"&&typeof this[r]=="function"&&(this[r]=this[r].bind(this));this.nativeDraggable=e.forceFallback?!1:yh,this.nativeDraggable&&(this.options.touchStartThreshold=1),e.supportPointer?P(n,"pointerdown",this._onTapStart):(P(n,"mousedown",this._onTapStart),P(n,"touchstart",this._onTapStart)),this.nativeDraggable&&(P(n,"dragover",this),P(n,"dragenter",this)),Ln.push(this.el),e.store&&e.store.get&&this.sort(e.store.get(this)||[]),ke(this,gh())}$.prototype={constructor:$,_isOutsideThisEl:function(e){!this.el.contains(e)&&e!==this.el&&(ct=null)},_getDirection:function(e,t){return typeof this.options.direction=="function"?this.options.direction.call(this,e,t,C):this.options.direction},_onTapStart:function(e){if(e.cancelable){var t=this,i=this.el,r=this.options,o=r.preventOnFilter,s=e.type,a=e.touches&&e.touches[0]||e.pointerType&&e.pointerType==="touch"&&e,l=(a||e).target,c=e.target.shadowRoot&&(e.path&&e.path[0]||e.composedPath&&e.composedPath()[0])||l,u=r.filter;if(Ih(i),!C&&!(/mousedown|pointerdown/.test(s)&&e.button!==0||r.disabled)&&!c.isContentEditable&&!(!this.nativeDraggable&&Rt&&l&&l.tagName.toUpperCase()==="SELECT")&&(l=xe(l,r.draggable,i,!1),!(l&&l.animated)&&En!==l)){if(dt=Y(l),zt=Y(l,r.draggable),typeof u=="function"){if(u.call(this,e,l,this)){oe({sortable:t,rootEl:c,name:"filter",targetEl:l,toEl:i,fromEl:i}),ae("filter",t,{evt:e}),o&&e.cancelable&&e.preventDefault();return}}else if(u&&(u=u.split(",").some(function(h){if(h=xe(c,h.trim(),i,!1),h)return oe({sortable:t,rootEl:h,name:"filter",targetEl:l,fromEl:i,toEl:i}),ae("filter",t,{evt:e}),!0}),u)){o&&e.cancelable&&e.preventDefault();return}r.handle&&!xe(c,r.handle,i,!1)||this._prepareDragStart(e,a,l)}}},_prepareDragStart:function(e,t,i){var r=this,o=r.el,s=r.options,a=o.ownerDocument,l;if(i&&!C&&i.parentNode===o){var c=j(i);if(U=o,C=i,G=C.parentNode,Ze=C.nextSibling,En=i,bn=s.group,$.dragged=C,Ge={target:C,clientX:(t||e).clientX,clientY:(t||e).clientY},cs=Ge.clientX-c.left,us=Ge.clientY-c.top,this._lastX=(t||e).clientX,this._lastY=(t||e).clientY,C.style["will-change"]="all",l=function(){if(ae("delayEnded",r,{evt:e}),$.eventCanceled){r._onDrop();return}r._disableDelayedDragEvents(),!rs&&r.nativeDraggable&&(C.draggable=!0),r._triggerDragStart(e,t),oe({sortable:r,name:"choose",originalEvent:e}),X(C,s.chosenClass,!0)},s.ignore.split(",").forEach(function(u){bs(C,u.trim(),$r)}),P(a,"dragover",Ke),P(a,"mousemove",Ke),P(a,"touchmove",Ke),P(a,"mouseup",r._onDrop),P(a,"touchend",r._onDrop),P(a,"touchcancel",r._onDrop),rs&&this.nativeDraggable&&(this.options.touchStartThreshold=4,C.draggable=!0),ae("delayStart",this,{evt:e}),s.delay&&(!s.delayOnTouchOnly||t)&&(!this.nativeDraggable||!(jt||Me))){if($.eventCanceled){this._onDrop();return}P(a,"mouseup",r._disableDelayedDrag),P(a,"touchend",r._disableDelayedDrag),P(a,"touchcancel",r._disableDelayedDrag),P(a,"mousemove",r._delayedDragTouchMoveHandler),P(a,"touchmove",r._delayedDragTouchMoveHandler),s.supportPointer&&P(a,"pointermove",r._delayedDragTouchMoveHandler),r._dragStartTimer=setTimeout(l,s.delay)}else l()}},_delayedDragTouchMoveHandler:function(e){var t=e.touches?e.touches[0]:e;Math.max(Math.abs(t.clientX-this._lastX),Math.abs(t.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){C&&$r(C),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var e=this.el.ownerDocument;B(e,"mouseup",this._disableDelayedDrag),B(e,"touchend",this._disableDelayedDrag),B(e,"touchcancel",this._disableDelayedDrag),B(e,"mousemove",this._delayedDragTouchMoveHandler),B(e,"touchmove",this._delayedDragTouchMoveHandler),B(e,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(e,t){t=t||e.pointerType=="touch"&&e,!this.nativeDraggable||t?this.options.supportPointer?P(document,"pointermove",this._onTouchMove):t?P(document,"touchmove",this._onTouchMove):P(document,"mousemove",this._onTouchMove):(P(C,"dragend",this),P(U,"dragstart",this._onDragStart));try{document.selection?Sn(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(e,t){if(ht=!1,U&&C){ae("dragStarted",this,{evt:t}),this.nativeDraggable&&P(document,"dragover",Ch);var i=this.options;!e&&X(C,i.dragClass,!1),X(C,i.ghostClass,!0),$.active=this,e&&this._appendGhost(),oe({sortable:this,name:"start",originalEvent:t})}else this._nulling()},_emulateDragOver:function(){if(we){this._lastX=we.clientX,this._lastY=we.clientY,Cs();for(var e=document.elementFromPoint(we.clientX,we.clientY),t=e;e&&e.shadowRoot&&(e=e.shadowRoot.elementFromPoint(we.clientX,we.clientY),e!==t);)t=e;if(C.parentNode[ne]._isOutsideThisEl(e),t)do{if(t[ne]){var i=void 0;if(i=t[ne]._onDragOver({clientX:we.clientX,clientY:we.clientY,target:e,rootEl:t}),i&&!this.options.dragoverBubble)break}e=t}while(t=t.parentNode);Es()}},_onTouchMove:function(e){if(Ge){var t=this.options,i=t.fallbackTolerance,r=t.fallbackOffset,o=e.touches?e.touches[0]:e,s=F&&Xe(F,!0),a=F&&s&&s.a,l=F&&s&&s.d,c=wn&&te&&as(te),u=(o.clientX-Ge.clientX+r.x)/(a||1)+(c?c[0]-Ir[0]:0)/(a||1),h=(o.clientY-Ge.clientY+r.y)/(l||1)+(c?c[1]-Ir[1]:0)/(l||1);if(!$.active&&!ht){if(i&&Math.max(Math.abs(o.clientX-this._lastX),Math.abs(o.clientY-this._lastY))<i)return;this._onDragStart(e,!0)}if(F){s?(s.e+=u-(Tr||0),s.f+=h-(Lr||0)):s={a:1,b:0,c:0,d:1,e:u,f:h};var d="matrix(".concat(s.a,",").concat(s.b,",").concat(s.c,",").concat(s.d,",").concat(s.e,",").concat(s.f,")");A(F,"webkitTransform",d),A(F,"mozTransform",d),A(F,"msTransform",d),A(F,"transform",d),Tr=u,Lr=h,we=o}e.cancelable&&e.preventDefault()}},_appendGhost:function(){if(!F){var e=this.options.fallbackOnBody?document.body:U,t=j(C,!0,wn,!0,e),i=this.options;if(wn){for(te=e;A(te,"position")==="static"&&A(te,"transform")==="none"&&te!==document;)te=te.parentNode;te!==document.body&&te!==document.documentElement?(te===document&&(te=Se()),t.top+=te.scrollTop,t.left+=te.scrollLeft):te=Se(),Ir=as(te)}F=C.cloneNode(!0),X(F,i.ghostClass,!1),X(F,i.fallbackClass,!0),X(F,i.dragClass,!0),A(F,"transition",""),A(F,"transform",""),A(F,"box-sizing","border-box"),A(F,"margin",0),A(F,"top",t.top),A(F,"left",t.left),A(F,"width",t.width),A(F,"height",t.height),A(F,"opacity","0.8"),A(F,"position",wn?"absolute":"fixed"),A(F,"zIndex","100000"),A(F,"pointerEvents","none"),$.ghost=F,e.appendChild(F),A(F,"transform-origin",cs/parseInt(F.style.width)*100+"% "+us/parseInt(F.style.height)*100+"%")}},_onDragStart:function(e,t){var i=this,r=e.dataTransfer,o=i.options;if(ae("dragStart",this,{evt:e}),$.eventCanceled){this._onDrop();return}ae("setupClone",this),$.eventCanceled||(W=Hr(C),W.removeAttribute("id"),W.draggable=!1,W.style["will-change"]="",this._hideClone(),X(W,this.options.chosenClass,!1),$.clone=W),i.cloneId=Sn(function(){ae("clone",i),!$.eventCanceled&&(i.options.removeCloneOnHide||U.insertBefore(W,C),i._hideClone(),oe({sortable:i,name:"clone"}))}),!t&&X(C,o.dragClass,!0),t?(Tn=!0,i._loopId=setInterval(i._emulateDragOver,50)):(B(document,"mouseup",i._onDrop),B(document,"touchend",i._onDrop),B(document,"touchcancel",i._onDrop),r&&(r.effectAllowed="move",o.setData&&o.setData.call(i,r,C)),P(document,"drop",i),A(C,"transform","translateZ(0)")),ht=!0,i._dragStartId=Sn(i._dragStarted.bind(i,t,e)),P(document,"selectstart",i),Bt=!0,Rt&&A(document.body,"user-select","none")},_onDragOver:function(e){var t=this.el,i=e.target,r,o,s,a=this.options,l=a.group,c=$.active,u=bn===l,h=a.sort,d=Q||c,p,f=this,m=!1;if(Pr)return;function y(Re,Au){ae(Re,f,Ae({evt:e,isOwner:u,axis:p?"vertical":"horizontal",revert:s,dragRect:r,targetRect:o,canSort:h,fromSortable:d,target:i,completed:b,onMove:function(jo,Du){return yn(U,t,C,r,jo,j(jo),e,Du)},changed:k},Au))}function v(){y("dragOverAnimationCapture"),f.captureAnimationState(),f!==d&&d.captureAnimationState()}function b(Re){return y("dragOverCompleted",{insertion:Re}),Re&&(u?c._hideClone():c._showClone(f),f!==d&&(X(C,Q?Q.options.ghostClass:c.options.ghostClass,!1),X(C,a.ghostClass,!0)),Q!==f&&f!==$.active?Q=f:f===$.active&&Q&&(Q=null),d===f&&(f._ignoreWhileAnimating=i),f.animateAll(function(){y("dragOverAnimationComplete"),f._ignoreWhileAnimating=null}),f!==d&&(d.animateAll(),d._ignoreWhileAnimating=null)),(i===C&&!C.animated||i===t&&!i.animated)&&(ct=null),!a.dragoverBubble&&!e.rootEl&&i!==document&&(C.parentNode[ne]._isOutsideThisEl(e.target),!Re&&Ke(e)),!a.dragoverBubble&&e.stopPropagation&&e.stopPropagation(),m=!0}function k(){fe=Y(C),He=Y(C,a.draggable),oe({sortable:f,name:"change",toEl:t,newIndex:fe,newDraggableIndex:He,originalEvent:e})}if(e.preventDefault!==void 0&&e.cancelable&&e.preventDefault(),i=xe(i,a.draggable,t,!0),y("dragOver"),$.eventCanceled)return m;if(C.contains(e.target)||i.animated&&i.animatingX&&i.animatingY||f._ignoreWhileAnimating===i)return b(!1);if(Tn=!1,c&&!a.disabled&&(u?h||(s=G!==U):Q===this||(this.lastPutMode=bn.checkPull(this,c,C,e))&&l.checkPut(this,c,C,e))){if(p=this._getDirection(e,i)==="vertical",r=j(C),y("dragOverValid"),$.eventCanceled)return m;if(s)return G=U,v(),this._hideClone(),y("revert"),$.eventCanceled||(Ze?U.insertBefore(C,Ze):U.appendChild(C)),b(!0);var w=zr(t,a.draggable);if(!w||Ah(e,p,this)&&!w.animated){if(w===C)return b(!1);if(w&&t===e.target&&(i=w),i&&(o=j(i)),yn(U,t,C,r,i,o,e,!!i)!==!1)return v(),w&&w.nextSibling?t.insertBefore(C,w.nextSibling):t.appendChild(C),G=t,k(),b(!0)}else if(w&&Sh(e,p,this)){var E=pt(t,0,a,!0);if(E===C)return b(!1);if(i=E,o=j(i),yn(U,t,C,r,i,o,e,!1)!==!1)return v(),t.insertBefore(C,E),G=t,k(),b(!0)}else if(i.parentNode===t){o=j(i);var x=0,S,D=C.parentNode!==t,q=!xh(C.animated&&C.toRect||r,i.animated&&i.toRect||o,p),L=p?"top":"left",I=ss(i,"top","top")||ss(C,"top","top"),H=I?I.scrollTop:void 0;ct!==i&&(S=o[L],Ut=!1,vn=!q&&a.invertSwap||D),x=Dh(e,i,o,p,q?1:a.swapThreshold,a.invertedSwapThreshold==null?a.swapThreshold:a.invertedSwapThreshold,vn,ct===i);var N;if(x!==0){var ee=Y(C);do ee-=x,N=G.children[ee];while(N&&(A(N,"display")==="none"||N===F))}if(x===0||N===i)return b(!1);ct=i,Ht=x;var ge=i.nextElementSibling,V=!1;V=x===1;var Oe=yn(U,t,C,r,i,o,e,V);if(Oe!==!1)return(Oe===1||Oe===-1)&&(V=Oe===1),Pr=!0,setTimeout(_h,30),v(),V&&!ge?t.appendChild(C):i.parentNode.insertBefore(C,V?ge:i),I&&ws(I,0,H-I.scrollTop),G=C.parentNode,S!==void 0&&!vn&&(_n=Math.abs(S-j(i)[L])),k(),b(!0)}if(t.contains(C))return b(!1)}return!1},_ignoreWhileAnimating:null,_offMoveEvents:function(){B(document,"mousemove",this._onTouchMove),B(document,"touchmove",this._onTouchMove),B(document,"pointermove",this._onTouchMove),B(document,"dragover",Ke),B(document,"mousemove",Ke),B(document,"touchmove",Ke)},_offUpEvents:function(){var e=this.el.ownerDocument;B(e,"mouseup",this._onDrop),B(e,"touchend",this._onDrop),B(e,"pointerup",this._onDrop),B(e,"touchcancel",this._onDrop),B(document,"selectstart",this)},_onDrop:function(e){var t=this.el,i=this.options;if(fe=Y(C),He=Y(C,i.draggable),ae("drop",this,{evt:e}),G=C&&C.parentNode,fe=Y(C),He=Y(C,i.draggable),$.eventCanceled){this._nulling();return}ht=!1,vn=!1,Ut=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),Or(this.cloneId),Or(this._dragStartId),this.nativeDraggable&&(B(document,"drop",this),B(t,"dragstart",this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),Rt&&A(document.body,"user-select",""),A(C,"transform",""),e&&(Bt&&(e.cancelable&&e.preventDefault(),!i.dropBubble&&e.stopPropagation()),F&&F.parentNode&&F.parentNode.removeChild(F),(U===G||Q&&Q.lastPutMode!=="clone")&&W&&W.parentNode&&W.parentNode.removeChild(W),C&&(this.nativeDraggable&&B(C,"dragend",this),$r(C),C.style["will-change"]="",Bt&&!ht&&X(C,Q?Q.options.ghostClass:this.options.ghostClass,!1),X(C,this.options.chosenClass,!1),oe({sortable:this,name:"unchoose",toEl:G,newIndex:null,newDraggableIndex:null,originalEvent:e}),U!==G?(fe>=0&&(oe({rootEl:G,name:"add",toEl:G,fromEl:U,originalEvent:e}),oe({sortable:this,name:"remove",toEl:G,originalEvent:e}),oe({rootEl:G,name:"sort",toEl:G,fromEl:U,originalEvent:e}),oe({sortable:this,name:"sort",toEl:G,originalEvent:e})),Q&&Q.save()):fe!==dt&&fe>=0&&(oe({sortable:this,name:"update",toEl:G,originalEvent:e}),oe({sortable:this,name:"sort",toEl:G,originalEvent:e})),$.active&&((fe==null||fe===-1)&&(fe=dt,He=zt),oe({sortable:this,name:"end",toEl:G,originalEvent:e}),this.save()))),this._nulling()},_nulling:function(){ae("nulling",this),U=C=G=F=Ze=W=En=Ue=Ge=we=Bt=fe=He=dt=zt=ct=Ht=Q=bn=$.dragged=$.ghost=$.clone=$.active=null,In.forEach(function(e){e.checked=!0}),In.length=Tr=Lr=0},handleEvent:function(e){switch(e.type){case"drop":case"dragend":this._onDrop(e);break;case"dragenter":case"dragover":C&&(this._onDragOver(e),Eh(e));break;case"selectstart":e.preventDefault();break}},toArray:function(){for(var e=[],t,i=this.el.children,r=0,o=i.length,s=this.options;r<o;r++)t=i[r],xe(t,s.draggable,this.el,!1)&&e.push(t.getAttribute(s.dataIdAttr)||Lh(t));return e},sort:function(e,t){var i={},r=this.el;this.toArray().forEach(function(o,s){var a=r.children[s];xe(a,this.options.draggable,r,!1)&&(i[o]=a)},this),t&&this.captureAnimationState(),e.forEach(function(o){i[o]&&(r.removeChild(i[o]),r.appendChild(i[o]))}),t&&this.animateAll()},save:function(){var e=this.options.store;e&&e.set&&e.set(this)},closest:function(e,t){return xe(e,t||this.options.draggable,this.el,!1)},option:function(e,t){var i=this.options;if(t===void 0)return i[e];var r=Vt.modifyOption(this,e,t);typeof r<"u"?i[e]=r:i[e]=t,e==="group"&&ks(i)},destroy:function(){ae("destroy",this);var e=this.el;e[ne]=null,B(e,"mousedown",this._onTapStart),B(e,"touchstart",this._onTapStart),B(e,"pointerdown",this._onTapStart),this.nativeDraggable&&(B(e,"dragover",this),B(e,"dragenter",this)),Array.prototype.forEach.call(e.querySelectorAll("[draggable]"),function(t){t.removeAttribute("draggable")}),this._onDrop(),this._disableDelayedDragEvents(),Ln.splice(Ln.indexOf(this.el),1),this.el=e=null},_hideClone:function(){if(!Ue){if(ae("hideClone",this),$.eventCanceled)return;A(W,"display","none"),this.options.removeCloneOnHide&&W.parentNode&&W.parentNode.removeChild(W),Ue=!0}},_showClone:function(e){if(e.lastPutMode!=="clone"){this._hideClone();return}if(Ue){if(ae("showClone",this),$.eventCanceled)return;C.parentNode==U&&!this.options.group.revertClone?U.insertBefore(W,C):Ze?U.insertBefore(W,Ze):U.appendChild(W),this.options.group.revertClone&&this.animate(C,W),A(W,"display",""),Ue=!1}}};function Eh(n){n.dataTransfer&&(n.dataTransfer.dropEffect="move"),n.cancelable&&n.preventDefault()}function yn(n,e,t,i,r,o,s,a){var l,c=n[ne],u=c.options.onMove,h;return window.CustomEvent&&!Me&&!jt?l=new CustomEvent("move",{bubbles:!0,cancelable:!0}):(l=document.createEvent("Event"),l.initEvent("move",!0,!0)),l.to=e,l.from=n,l.dragged=t,l.draggedRect=i,l.related=r||e,l.relatedRect=o||j(e),l.willInsertAfter=a,l.originalEvent=s,n.dispatchEvent(l),u&&(h=u.call(c,l,s)),h}function $r(n){n.draggable=!1}function _h(){Pr=!1}function Sh(n,e,t){var i=j(pt(t.el,0,t.options,!0)),r=10;return e?n.clientX<i.left-r||n.clientY<i.top&&n.clientX<i.right:n.clientY<i.top-r||n.clientY<i.bottom&&n.clientX<i.left}function Ah(n,e,t){var i=j(zr(t.el,t.options.draggable)),r=10;return e?n.clientX>i.right+r||n.clientX<=i.right&&n.clientY>i.bottom&&n.clientX>=i.left:n.clientX>i.right&&n.clientY>i.top||n.clientX<=i.right&&n.clientY>i.bottom+r}function Dh(n,e,t,i,r,o,s,a){var l=i?n.clientY:n.clientX,c=i?t.height:t.width,u=i?t.top:t.left,h=i?t.bottom:t.right,d=!1;if(!s){if(a&&_n<c*r){if(!Ut&&(Ht===1?l>u+c*o/2:l<h-c*o/2)&&(Ut=!0),Ut)d=!0;else if(Ht===1?l<u+_n:l>h-_n)return-Ht}else if(l>u+c*(1-r)/2&&l<h-c*(1-r)/2)return Th(e)}return d=d||s,d&&(l<u+c*o/2||l>h-c*o/2)?l>u+c/2?1:-1:0}function Th(n){return Y(C)<Y(n)?1:-1}function Lh(n){for(var e=n.tagName+n.className+n.src+n.href+n.textContent,t=e.length,i=0;t--;)i+=e.charCodeAt(t);return i.toString(36)}function Ih(n){In.length=0;for(var e=n.getElementsByTagName("input"),t=e.length;t--;){var i=e[t];i.checked&&In.push(i)}}function Sn(n){return setTimeout(n,0)}function Or(n){return clearTimeout(n)}Mn&&P(document,"touchmove",function(n){($.active||ht)&&n.cancelable&&n.preventDefault()});$.utils={on:P,off:B,css:A,find:bs,is:function(e,t){return!!xe(e,t,e,!1)},extend:fh,throttle:vs,closest:xe,toggleClass:X,clone:Hr,index:Y,nextTick:Sn,cancelNextTick:Or,detectDirection:xs,getChild:pt};$.get=function(n){return n[ne]};$.mount=function(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];e[0].constructor===Array&&(e=e[0]),e.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&&($.utils=Ae(Ae({},$.utils),i.utils)),Vt.mount(i)})};$.create=function(n,e){return new $(n,e)};$.version=hh;var Z=[],Pt,Rr,Nr=!1,Mr,Fr,$n,Ot;function $h(){function n(){this.defaults={scroll:!0,forceAutoScrollFallback:!1,scrollSensitivity:30,scrollSpeed:10,bubbleScroll:!0};for(var e in this)e.charAt(0)==="_"&&typeof this[e]=="function"&&(this[e]=this[e].bind(this))}return n.prototype={dragStarted:function(t){var i=t.originalEvent;this.sortable.nativeDraggable?P(document,"dragover",this._handleAutoScroll):this.options.supportPointer?P(document,"pointermove",this._handleFallbackAutoScroll):i.touches?P(document,"touchmove",this._handleFallbackAutoScroll):P(document,"mousemove",this._handleFallbackAutoScroll)},dragOverCompleted:function(t){var i=t.originalEvent;!this.options.dragOverBubble&&!i.rootEl&&this._handleAutoScroll(i)},drop:function(){this.sortable.nativeDraggable?B(document,"dragover",this._handleAutoScroll):(B(document,"pointermove",this._handleFallbackAutoScroll),B(document,"touchmove",this._handleFallbackAutoScroll),B(document,"mousemove",this._handleFallbackAutoScroll)),ds(),An(),mh()},nulling:function(){$n=Rr=Pt=Nr=Ot=Mr=Fr=null,Z.length=0},_handleFallbackAutoScroll:function(t){this._handleAutoScroll(t,!0)},_handleAutoScroll:function(t,i){var r=this,o=(t.touches?t.touches[0]:t).clientX,s=(t.touches?t.touches[0]:t).clientY,a=document.elementFromPoint(o,s);if($n=t,i||this.options.forceAutoScrollFallback||jt||Me||Rt){qr(t,this.options,a,i);var l=je(a,!0);Nr&&(!Ot||o!==Mr||s!==Fr)&&(Ot&&ds(),Ot=setInterval(function(){var c=je(document.elementFromPoint(o,s),!0);c!==l&&(l=c,An()),qr(t,r.options,c,i)},10),Mr=o,Fr=s)}else{if(!this.options.bubbleScroll||je(a,!0)===Se()){An();return}qr(t,this.options,je(a,!1),!1)}}},ke(n,{pluginName:"scroll",initializeByDefault:!0})}function An(){Z.forEach(function(n){clearInterval(n.pid)}),Z=[]}function ds(){clearInterval(Ot)}var qr=vs(function(n,e,t,i){if(e.scroll){var r=(n.touches?n.touches[0]:n).clientX,o=(n.touches?n.touches[0]:n).clientY,s=e.scrollSensitivity,a=e.scrollSpeed,l=Se(),c=!1,u;Rr!==t&&(Rr=t,An(),Pt=e.scroll,u=e.scrollFn,Pt===!0&&(Pt=je(t,!0)));var h=0,d=Pt;do{var p=d,f=j(p),m=f.top,y=f.bottom,v=f.left,b=f.right,k=f.width,w=f.height,E=void 0,x=void 0,S=p.scrollWidth,D=p.scrollHeight,q=A(p),L=p.scrollLeft,I=p.scrollTop;p===l?(E=k<S&&(q.overflowX==="auto"||q.overflowX==="scroll"||q.overflowX==="visible"),x=w<D&&(q.overflowY==="auto"||q.overflowY==="scroll"||q.overflowY==="visible")):(E=k<S&&(q.overflowX==="auto"||q.overflowX==="scroll"),x=w<D&&(q.overflowY==="auto"||q.overflowY==="scroll"));var H=E&&(Math.abs(b-r)<=s&&L+k<S)-(Math.abs(v-r)<=s&&!!L),N=x&&(Math.abs(y-o)<=s&&I+w<D)-(Math.abs(m-o)<=s&&!!I);if(!Z[h])for(var ee=0;ee<=h;ee++)Z[ee]||(Z[ee]={});(Z[h].vx!=H||Z[h].vy!=N||Z[h].el!==p)&&(Z[h].el=p,Z[h].vx=H,Z[h].vy=N,clearInterval(Z[h].pid),(H!=0||N!=0)&&(c=!0,Z[h].pid=setInterval(function(){i&&this.layer===0&&$.active._onTouchMove($n);var ge=Z[this.layer].vy?Z[this.layer].vy*a:0,V=Z[this.layer].vx?Z[this.layer].vx*a:0;typeof u=="function"&&u.call($.dragged.parentNode[ne],V,ge,n,$n,Z[this.layer].el)!=="continue"||ws(Z[this.layer].el,V,ge)}.bind({layer:h}),24))),h++}while(e.bubbleScroll&&d!==l&&(d=je(d,!1)));Nr=c}},30),_s=function(e){var t=e.originalEvent,i=e.putSortable,r=e.dragEl,o=e.activeSortable,s=e.dispatchSortableEvent,a=e.hideGhostForTarget,l=e.unhideGhostForTarget;if(t){var c=i||o;a();var u=t.changedTouches&&t.changedTouches.length?t.changedTouches[0]:t,h=document.elementFromPoint(u.clientX,u.clientY);l(),c&&!c.el.contains(h)&&(s("spill"),this.onSpill({dragEl:r,putSortable:i}))}};function Ur(){}Ur.prototype={startIndex:null,dragStart:function(e){var t=e.oldDraggableIndex;this.startIndex=t},onSpill:function(e){var t=e.dragEl,i=e.putSortable;this.sortable.captureAnimationState(),i&&i.captureAnimationState();var r=pt(this.sortable.el,this.startIndex,this.options);r?this.sortable.el.insertBefore(t,r):this.sortable.el.appendChild(t),this.sortable.animateAll(),i&&i.animateAll()},drop:_s};ke(Ur,{pluginName:"revertOnSpill"});function jr(){}jr.prototype={onSpill:function(e){var t=e.dragEl,i=e.putSortable,r=i||this.sortable;r.captureAnimationState(),t.parentNode&&t.parentNode.removeChild(t),r.animateAll()},drop:_s};ke(jr,{pluginName:"removeOnSpill"});var M=[],pe=[],$t,ye,Mt=!1,le=!1,ut=!1,z,Ft,xn;function Ss(){function n(e){for(var t in this)t.charAt(0)==="_"&&typeof this[t]=="function"&&(this[t]=this[t].bind(this));e.options.avoidImplicitDeselect||(e.options.supportPointer?P(document,"pointerup",this._deselectMultiDrag):(P(document,"mouseup",this._deselectMultiDrag),P(document,"touchend",this._deselectMultiDrag))),P(document,"keydown",this._checkKeyDown),P(document,"keyup",this._checkKeyUp),this.defaults={selectedClass:"sortable-selected",multiDragKey:null,avoidImplicitDeselect:!1,setData:function(r,o){var s="";M.length&&ye===e?M.forEach(function(a,l){s+=(l?", ":"")+a.textContent}):s=o.textContent,r.setData("Text",s)}}}return n.prototype={multiDragKeyDown:!1,isMultiDrag:!1,delayStartGlobal:function(t){var i=t.dragEl;z=i},delayEnded:function(){this.isMultiDrag=~M.indexOf(z)},setupClone:function(t){var i=t.sortable,r=t.cancel;if(this.isMultiDrag){for(var o=0;o<M.length;o++)pe.push(Hr(M[o])),pe[o].sortableIndex=M[o].sortableIndex,pe[o].draggable=!1,pe[o].style["will-change"]="",X(pe[o],this.options.selectedClass,!1),M[o]===z&&X(pe[o],this.options.chosenClass,!1);i._hideClone(),r()}},clone:function(t){var i=t.sortable,r=t.rootEl,o=t.dispatchSortableEvent,s=t.cancel;this.isMultiDrag&&(this.options.removeCloneOnHide||M.length&&ye===i&&(ps(!0,r),o("clone"),s()))},showClone:function(t){var i=t.cloneNowShown,r=t.rootEl,o=t.cancel;this.isMultiDrag&&(ps(!1,r),pe.forEach(function(s){A(s,"display","")}),i(),xn=!1,o())},hideClone:function(t){var i=this,r=t.sortable,o=t.cloneNowHidden,s=t.cancel;this.isMultiDrag&&(pe.forEach(function(a){A(a,"display","none"),i.options.removeCloneOnHide&&a.parentNode&&a.parentNode.removeChild(a)}),o(),xn=!0,s())},dragStartGlobal:function(t){var i=t.sortable;!this.isMultiDrag&&ye&&ye.multiDrag._deselectMultiDrag(),M.forEach(function(r){r.sortableIndex=Y(r)}),M=M.sort(function(r,o){return r.sortableIndex-o.sortableIndex}),ut=!0},dragStarted:function(t){var i=this,r=t.sortable;if(this.isMultiDrag){if(this.options.sort&&(r.captureAnimationState(),this.options.animation)){M.forEach(function(s){s!==z&&A(s,"position","absolute")});var o=j(z,!1,!0,!0);M.forEach(function(s){s!==z&&ls(s,o)}),le=!0,Mt=!0}r.animateAll(function(){le=!1,Mt=!1,i.options.animation&&M.forEach(function(s){Ar(s)}),i.options.sort&&kn()})}},dragOver:function(t){var i=t.target,r=t.completed,o=t.cancel;le&&~M.indexOf(i)&&(r(!1),o())},revert:function(t){var i=t.fromSortable,r=t.rootEl,o=t.sortable,s=t.dragRect;M.length>1&&(M.forEach(function(a){o.addAnimationState({target:a,rect:le?j(a):s}),Ar(a),a.fromRect=s,i.removeAnimationState(a)}),le=!1,Mh(!this.options.removeCloneOnHide,r))},dragOverCompleted:function(t){var i=t.sortable,r=t.isOwner,o=t.insertion,s=t.activeSortable,a=t.parentEl,l=t.putSortable,c=this.options;if(o){if(r&&s._hideClone(),Mt=!1,c.animation&&M.length>1&&(le||!r&&!s.options.sort&&!l)){var u=j(z,!1,!0,!0);M.forEach(function(d){d!==z&&(ls(d,u),a.appendChild(d))}),le=!0}if(!r)if(le||kn(),M.length>1){var h=xn;s._showClone(i),s.options.animation&&!xn&&h&&pe.forEach(function(d){s.addAnimationState({target:d,rect:Ft}),d.fromRect=Ft,d.thisAnimationDuration=null})}else s._showClone(i)}},dragOverAnimationCapture:function(t){var i=t.dragRect,r=t.isOwner,o=t.activeSortable;if(M.forEach(function(a){a.thisAnimationDuration=null}),o.options.animation&&!r&&o.multiDrag.isMultiDrag){Ft=ke({},i);var s=Xe(z,!0);Ft.top-=s.f,Ft.left-=s.e}},dragOverAnimationComplete:function(){le&&(le=!1,kn())},drop:function(t){var i=t.originalEvent,r=t.rootEl,o=t.parentEl,s=t.sortable,a=t.dispatchSortableEvent,l=t.oldIndex,c=t.putSortable,u=c||this.sortable;if(i){var h=this.options,d=o.children;if(!ut)if(h.multiDragKey&&!this.multiDragKeyDown&&this._deselectMultiDrag(),X(z,h.selectedClass,!~M.indexOf(z)),~M.indexOf(z))M.splice(M.indexOf(z),1),$t=null,qt({sortable:s,rootEl:r,name:"deselect",targetEl:z,originalEvent:i});else{if(M.push(z),qt({sortable:s,rootEl:r,name:"select",targetEl:z,originalEvent:i}),i.shiftKey&&$t&&s.el.contains($t)){var p=Y($t),f=Y(z);if(~p&&~f&&p!==f){var m,y;for(f>p?(y=p,m=f):(y=f,m=p+1);y<m;y++)~M.indexOf(d[y])||(X(d[y],h.selectedClass,!0),M.push(d[y]),qt({sortable:s,rootEl:r,name:"select",targetEl:d[y],originalEvent:i}))}}else $t=z;ye=u}if(ut&&this.isMultiDrag){if(le=!1,(o[ne].options.sort||o!==r)&&M.length>1){var v=j(z),b=Y(z,":not(."+this.options.selectedClass+")");if(!Mt&&h.animation&&(z.thisAnimationDuration=null),u.captureAnimationState(),!Mt&&(h.animation&&(z.fromRect=v,M.forEach(function(w){if(w.thisAnimationDuration=null,w!==z){var E=le?j(w):v;w.fromRect=E,u.addAnimationState({target:w,rect:E})}})),kn(),M.forEach(function(w){d[b]?o.insertBefore(w,d[b]):o.appendChild(w),b++}),l===Y(z))){var k=!1;M.forEach(function(w){if(w.sortableIndex!==Y(w)){k=!0;return}}),k&&a("update")}M.forEach(function(w){Ar(w)}),u.animateAll()}ye=u}(r===o||c&&c.lastPutMode!=="clone")&&pe.forEach(function(w){w.parentNode&&w.parentNode.removeChild(w)})}},nullingGlobal:function(){this.isMultiDrag=ut=!1,pe.length=0},destroyGlobal:function(){this._deselectMultiDrag(),B(document,"pointerup",this._deselectMultiDrag),B(document,"mouseup",this._deselectMultiDrag),B(document,"touchend",this._deselectMultiDrag),B(document,"keydown",this._checkKeyDown),B(document,"keyup",this._checkKeyUp)},_deselectMultiDrag:function(t){if(!(typeof ut<"u"&&ut)&&ye===this.sortable&&!(t&&xe(t.target,this.options.draggable,this.sortable.el,!1))&&!(t&&t.button!==0))for(;M.length;){var i=M[0];X(i,this.options.selectedClass,!1),M.shift(),qt({sortable:this.sortable,rootEl:this.sortable.el,name:"deselect",targetEl:i,originalEvent:t})}},_checkKeyDown:function(t){t.key===this.options.multiDragKey&&(this.multiDragKeyDown=!0)},_checkKeyUp:function(t){t.key===this.options.multiDragKey&&(this.multiDragKeyDown=!1)}},ke(n,{pluginName:"multiDrag",utils:{select:function(t){var i=t.parentNode[ne];!i||!i.options.multiDrag||~M.indexOf(t)||(ye&&ye!==i&&(ye.multiDrag._deselectMultiDrag(),ye=i),X(t,i.options.selectedClass,!0),M.push(t))},deselect:function(t){var i=t.parentNode[ne],r=M.indexOf(t);!i||!i.options.multiDrag||!~r||(X(t,i.options.selectedClass,!1),M.splice(r,1))}},eventProperties:function(){var t=this,i=[],r=[];return M.forEach(function(o){i.push({multiDragElement:o,index:o.sortableIndex});var s;le&&o!==z?s=-1:le?s=Y(o,":not(."+t.options.selectedClass+")"):s=Y(o),r.push({multiDragElement:o,index:s})}),{items:sh(M),clones:[].concat(pe),oldIndicies:i,newIndicies:r}},optionListeners:{multiDragKey:function(t){return t=t.toLowerCase(),t==="ctrl"?t="Control":t.length>1&&(t=t.charAt(0).toUpperCase()+t.substr(1)),t}}})}function Mh(n,e){M.forEach(function(t,i){var r=e.children[t.sortableIndex+(n?Number(i):0)];r?e.insertBefore(t,r):e.appendChild(t)})}function ps(n,e){pe.forEach(function(t,i){var r=e.children[t.sortableIndex+(n?Number(i):0)];r?e.insertBefore(t,r):e.appendChild(t)})}function kn(){M.forEach(function(n){n!==z&&n.parentNode&&n.parentNode.removeChild(n)})}$.mount(new $h);$.mount(jr,Ur);var Ye=$;var As={name(n,e){let t=n.getAttribute("data-name").trim().toLowerCase(),i=e.getAttribute("data-name").trim().toLowerCase();return t.localeCompare(i)},created(n,e){let t=Number(n.getAttribute("data-created"));return Number(e.getAttribute("data-created"))-t},updated(n,e){let t=Number(n.getAttribute("data-updated"));return Number(e.getAttribute("data-updated"))-t},chaptersFirst(n,e){let t=n.getAttribute("data-type"),i=e.getAttribute("data-type");return t===i?0:t==="chapter"?-1:1},chaptersLast(n,e){let t=n.getAttribute("data-type"),i=e.getAttribute("data-type");return t===i?0:t==="chapter"?1:-1}},Ds={up:{active(n,e){return!(n.previousElementSibling===null&&!e)},run(n,e){(n.previousElementSibling||e).insertAdjacentElement("beforebegin",n)}},down:{active(n,e){return!(n.nextElementSibling===null&&!e)},run(n,e){(n.nextElementSibling||e).insertAdjacentElement("afterend",n)}},next_book:{active(n,e,t){return t.nextElementSibling!==null},run(n,e,t){t.nextElementSibling.querySelector("ul").prepend(n)}},prev_book:{active(n,e,t){return t.previousElementSibling!==null},run(n,e,t){t.previousElementSibling.querySelector("ul").appendChild(n)}},next_chapter:{active(n,e){return n.dataset.type==="page"&&this.getNextChapter(n,e)},run(n,e){this.getNextChapter(n,e).querySelector("ul").prepend(n)},getNextChapter(n,e){let t=e||n,i=Array.from(t.parentElement.children),r=i.indexOf(t);return i.slice(r+1).find(o=>o.dataset.type==="chapter")}},prev_chapter:{active(n,e){return n.dataset.type==="page"&&this.getPrevChapter(n,e)},run(n,e){this.getPrevChapter(n,e).querySelector("ul").append(n)},getPrevChapter(n,e){let t=e||n,i=Array.from(t.parentElement.children),r=i.indexOf(t);return i.slice(0,r).reverse().find(o=>o.dataset.type==="chapter")}},book_end:{active(n,e){return e||e===null&&n.nextElementSibling},run(n,e,t){t.querySelector("ul").append(n)}},book_start:{active(n,e){return e||e===null&&n.previousElementSibling},run(n,e,t){t.querySelector("ul").prepend(n)}},before_chapter:{active(n,e){return e},run(n,e){e.insertAdjacentElement("beforebegin",n)}},after_chapter:{active(n,e){return e},run(n,e){e.insertAdjacentElement("afterend",n)}}},Fn=class extends g{setup(){this.container=this.$el,this.sortContainer=this.$refs.sortContainer,this.input=this.$refs.input,Ye.mount(new Ss);let e=this.container.querySelector(".sort-box");this.setupBookSortable(e),this.setupSortPresets(),this.setupMoveActions(),window.$events.listen("entity-select-change",this.bookSelect.bind(this))}setupMoveActions(){this.container.addEventListener("click",e=>{if(e.target.matches("[data-move]")){let t=e.target.getAttribute("data-move"),i=e.target.closest("[data-id]");this.runSortAction(i,t)}}),this.updateMoveActionStateForAll()}setupSortPresets(){let e="",t=!1,i=["name","created","updated"];this.sortContainer.addEventListener("click",r=>{let o=r.target.closest(".sort-box-options [data-sort]");if(!o)return;r.preventDefault();let s=o.closest(".sort-box").querySelectorAll("ul"),a=o.getAttribute("data-sort");t=e===a?!t:!1;let l=As[a];t&&i.includes(a)&&(l=function(u,h){return 0-As[a](u,h)});for(let c of s)Array.from(c.children).filter(h=>h.matches("li")).sort(l).forEach(h=>{c.appendChild(h)});e=a,this.updateMapInput()})}bookSelect(e){if(this.container.querySelector(`[data-type="book"][data-id="${e.id}"]`)!==null)return;let i=`${e.link}/sort-item`;window.$http.get(i).then(r=>{let o=_e(r.data);this.sortContainer.append(o),this.setupBookSortable(o),this.updateMoveActionStateForAll(),o.querySelector("summary").focus()})}setupBookSortable(e){let t=Array.from(e.querySelectorAll(".sort-list, .sortable-page-sublist")),i={name:"book",pull:["book","chapter"],put:["book","chapter"]},r={name:"chapter",pull:["book","chapter"],put(o,s,a){return a.getAttribute("data-type")==="page"}};for(let o of t)Ye.create(o,{group:o.classList.contains("sort-list")?i:r,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 e=this.container.querySelectorAll('[data-type="chapter"] [data-type="chapter"]');for(let t of e)t.parentElement.closest('[data-type="chapter"]').insertAdjacentElement("afterend",t)}updateMapInput(){let e=this.buildEntityMap();this.input.value=JSON.stringify(e)}buildEntityMap(){let e=[],t=this.container.querySelectorAll(".sort-list");for(let i of t){let r=i.closest('[data-type="book"]').getAttribute("data-id"),o=Array.from(i.children).filter(s=>s.matches('[data-type="page"], [data-type="chapter"]'));for(let s=0;s<o.length;s++)this.addBookChildToMap(o[s],s,r,e)}return e}addBookChildToMap(e,t,i,r){let o=e.getAttribute("data-type"),s=!1,a=e.getAttribute("data-id");r.push({id:a,sort:t,parentChapter:s,type:o,book:i});let l=e.querySelectorAll('[data-type="page"]');for(let c=0;c<l.length;c++)r.push({id:l[c].getAttribute("data-id"),sort:c,parentChapter:a,type:"page",book:i})}runSortAction(e,t){let i=e.parentElement.closest("li[data-id]"),r=e.parentElement.closest('[data-type="book"]');Ds[t].run(e,i,r),this.updateMapInput(),this.updateMoveActionStateForAll(),e.scrollIntoView({behavior:"smooth",block:"nearest"}),e.focus()}updateMoveActionState(e){let t=e.parentElement.closest("li[data-id]"),i=e.parentElement.closest('[data-type="book"]');for(let[r,o]of Object.entries(Ds)){let s=e.querySelector(`[data-move="${r}"]`);s.disabled=!o.active(e,t,i)}}updateMoveActionStateForAll(){let e=this.container.querySelectorAll('[data-type="chapter"],[data-type="page"]');for(let t of e)this.updateMoveActionState(t)}};var qn=new WeakMap;function Wt(n,e,t=400,i=null){let r=Object.keys(e);for(let s of r)n.style[s]=e[s][0];let o=()=>{for(let s of r)n.style[s]=null;n.style.transition=null,n.removeEventListener("transitionend",o),qn.delete(n),i&&i()};setTimeout(()=>{n.style.transition=`all ease-in-out ${t}ms`;for(let s of r)n.style[s]=e[s][1];n.addEventListener("transitionend",o),qn.set(n,o)},15)}function Gt(n){qn.has(n)&&qn.get(n)()}function Ts(n,e=400,t=null){Gt(n),n.style.display="block",Wt(n,{opacity:["0","1"]},e,()=>{t&&t()})}function Ls(n,e=400,t=null){Gt(n),Wt(n,{opacity:["1","0"]},e,()=>{n.style.display="none",t&&t()})}function ft(n,e=400){Gt(n);let t=n.getBoundingClientRect().height,i=getComputedStyle(n),r=i.getPropertyValue("padding-top"),o=i.getPropertyValue("padding-bottom"),s={maxHeight:[`${t}px`,"0px"],overflow:["hidden","hidden"],paddingTop:[r,"0px"],paddingBottom:[o,"0px"]};Wt(n,s,e,()=>{n.style.display="none"})}function mt(n,e=400){Gt(n),n.style.display="block";let t=n.getBoundingClientRect().height,i=getComputedStyle(n),r=i.getPropertyValue("padding-top"),o=i.getPropertyValue("padding-bottom"),s={maxHeight:["0px",`${t}px`],overflow:["hidden","hidden"],paddingTop:["0px",r],paddingBottom:["0px",o]};Wt(n,s,e)}function Is(n,e=400){let t=n.getBoundingClientRect().height,i=getComputedStyle(n),r=i.getPropertyValue("padding-top"),o=i.getPropertyValue("padding-bottom");return()=>{Gt(n);let s=n.getBoundingClientRect().height,a=getComputedStyle(n),l=a.getPropertyValue("padding-top"),c=a.getPropertyValue("padding-bottom"),u={height:[`${t}px`,`${s}px`],overflow:["hidden","hidden"],paddingTop:[r,l],paddingBottom:[o,c]};Wt(n,u,e)}}var Bn=class extends g{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"),mt(this.list,180),this.isOpen=!0}close(){this.toggle.classList.remove("open"),this.toggle.setAttribute("aria-expanded","false"),ft(this.list,180),this.isOpen=!1}click(e){e.preventDefault(),this.isOpen?this.close():this.open()}};var Pn=class extends g{constructor(){super(...arguments);se(this,"editor",null);se(this,"saveCallback",null);se(this,"cancelCallback",null);se(this,"history",{});se(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",t=>{t.ctrlKey&&t.key==="Enter"&&this.save()}),O(this.languageButtons,t=>{let i=t.target.dataset.lang;this.languageInput.value=i,this.languageInputChange(i)}),st(this.languageInput,()=>this.save()),this.languageInput.addEventListener("input",()=>this.languageInputChange(this.languageInput.value)),O(this.saveButton,()=>this.save()),K(this.historyList,"button","click",(t,i)=>{t.preventDefault();let r=i.dataset.time;this.editor&&this.editor.setContent(this.history[r])})}setupFavourites(){for(let t of this.languageButtons)this.setupFavouritesForButton(t);this.sortLanguageList()}setupFavouritesForButton(t){let i=t.dataset.lang,r=this.favourites.has(i);t.setAttribute("data-favourite",r?"true":"false"),K(t.parentElement,".lang-option-favorite-toggle","click",()=>{r=!r,r?this.favourites.add(i):this.favourites.delete(i),t.setAttribute("data-favourite",r?"true":"false"),window.$http.patch("/preferences/update-code-language-favourite",{language:i,active:r}),this.sortLanguageList(),r&&t.scrollIntoView({block:"center",behavior:"smooth"})})}sortLanguageList(){let t=this.languageButtons.sort((i,r)=>{let o=i.dataset.favourite==="true",s=r.dataset.favourite==="true";return o&&!s?-1:s&&!o||i.dataset.lang>r.dataset.lang?1:-1}).map(i=>i.parentElement);for(let i of t)this.languageOptionsContainer.append(i)}save(){this.saveCallback&&this.saveCallback(this.editor.getContent(),this.languageInput.value),this.hide()}async open(t,i,r,o){this.languageInput.value=i,this.saveCallback=r,this.cancelCallback=o,await this.show(),this.languageInputChange(i),this.editor.setContent(t)}async show(){let t=await window.importVersioned("code");this.editor||(this.editor=t.popupEditor(this.editorInput,this.languageInput.value)),this.loadHistory(),this.getPopup().show(()=>{this.editor.focus()},()=>{this.addHistory(),this.cancelCallback&&this.cancelCallback()})}hide(){this.getPopup().hide(),this.addHistory()}getPopup(){return window.$components.firstOnElement(this.popup,"popup")}async updateEditorMode(t){this.editor.setMode(t,this.editor.getContent())}languageInputChange(t){this.updateEditorMode(t);let i=t.toLowerCase();for(let r of this.languageButtons){let o=r.dataset.lang.toLowerCase().trim(),s=i===o;r.classList.toggle("active",s),s&&r.scrollIntoView({block:"center",behavior:"smooth"})}}loadHistory(){this.history=JSON.parse(window.sessionStorage.getItem(this.historyKey)||"{}");let t=Object.keys(this.history).reverse();this.historyDropDown.classList.toggle("hidden",t.length===0),this.historyList.innerHTML=t.map(i=>{let r=new Date(parseInt(i,10)).toLocaleTimeString();return`<li><button type="button" data-time="${i}" class="text-item">${r}</button></li>`}).join("")}addHistory(){if(!this.editor)return;let t=this.editor.getContent();if(!t)return;let i=Object.keys(this.history).pop();if(this.history[i]===t)return;this.history[String(Date.now())]=t;let r=JSON.stringify(this.history);window.sessionStorage.setItem(this.historyKey,r)}};var On=class extends g{setup(){let e=this.$el;e.querySelectorAll("pre").length>0&&window.importVersioned("code").then(i=>{i.highlightWithin(e)})}};var Rn=class extends g{async setup(){let{mode:e}=this.$opts;(await window.importVersioned("code")).inlineEditor(this.$el,e)}};var Nn=class extends g{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"),mt(this.content,300)}close(){this.container.classList.remove("open"),this.trigger.setAttribute("aria-expanded","false"),ft(this.content,300)}toggle(){this.container.classList.contains("open")?this.close():this.open()}openIfContainsError(){this.content.querySelector(".text-neg.text-small")&&this.open()}};var zn=class extends g{setup(){this.container=this.$el,this.confirmButton=this.$refs.confirm,this.res=null,O(this.confirmButton,()=>{this.sendResult(!0),this.getPopup().hide()})}show(){return this.getPopup().show(null,()=>{this.sendResult(!1)}),new Promise(e=>{this.res=e})}getPopup(){return window.$components.firstOnElement(this.container,"popup")}sendResult(e){this.res&&(this.res(e),this.res=null)}};var Hn=class extends g{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(e){(e.key===" "||e.key==="Enter")&&(e.preventDefault(),this.toggle())}toggle(){this.checkbox.checked=!this.checkbox.checked,this.checkbox.dispatchEvent(new Event("change")),this.stateChange()}stateChange(){let e=this.checkbox.checked?"true":"false";this.display.setAttribute("aria-checked",e)}};var Un=class extends g{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(e=>{e.highlightWithin(this.container)}),this.dealtWith=!0)}};var jn=class extends g{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(e=null){this.hideAll(),this.menu.style.display="block",this.menu.classList.add("anim","menuIn"),this.toggle.setAttribute("aria-expanded","true");let t=this.menu.getBoundingClientRect(),i=0,r=this.toggle.getBoundingClientRect().height,o=t.bottom>window.innerHeight;this.moveMenu&&(this.body.appendChild(this.menu),this.menu.style.position="fixed",this.menu.style.width=`${t.width}px`,this.menu.style.left=`${t.left}px`,o?i=window.innerHeight-t.top-r/2:i=t.top),o?(this.menu.style.top="initial",this.menu.style.bottom=`${i}px`):(this.menu.style.top=`${i}px`,this.menu.style.bottom="initial"),this.menu.addEventListener("mouseleave",this.hide),window.addEventListener("click",l=>{this.menu.contains(l.target)||this.hide()});let s=this.menu.querySelector("input");s!==null&&s.focus(),this.showing=!0;let a=new Event("show");this.container.dispatchEvent(a),e&&e.stopPropagation()}hideAll(){for(let e of window.$components.get("dropdown"))e.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.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 e=new ze(this.container,t=>{this.hide(),this.toggle.focus(),this.bubbleEscapes||t.stopPropagation()},t=>{t.target.nodeName==="INPUT"&&(t.preventDefault(),t.stopPropagation()),this.hide()});this.moveMenu&&e.shareHandlingToEl(this.menu),this.container.addEventListener("click",t=>{Array.from(this.menu.querySelectorAll("a")).includes(t.target)&&this.hide()}),O(this.toggle,t=>{t.stopPropagation(),t.preventDefault(),this.show(t),t instanceof KeyboardEvent&&e.focusNext()})}};var Vn=class extends g{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=Ne(this.runAjaxSearch,300,!1)}onShow(){this.loadList()}onSearch(){let e=this.searchInput.value.toLowerCase().trim();this.localSearchSelector?this.runLocalSearch(e):(this.toggleLoading(!0),this.listContainerElem.innerHTML="",this.runAjaxSearch(e))}runAjaxSearch(e){this.loadList(e)}runLocalSearch(e){let t=this.listContainerElem.querySelectorAll(this.localSearchSelector);for(let i of t){let r=!e||i.textContent.toLowerCase().includes(e);i.style.display=r?"flex":"none",i.classList.toggle("hidden",!r)}}async loadList(e=""){this.listContainerElem.innerHTML="",this.toggleLoading(!0);try{let t=await window.$http.get(this.getAjaxUrl(e)),i=Is(this.listContainerElem,80);this.listContainerElem.innerHTML=t.data,i()}catch(t){console.error(t)}this.toggleLoading(!1),this.localSearchSelector&&this.onSearch()}getAjaxUrl(e=null){if(!e)return this.url;let t=this.url.includes("?")?"&":"?";return`${this.url}${t}search=${encodeURIComponent(e)}`}toggleLoading(e=!1){this.loadingElem.style.display=e?"block":"none"}};var Fe=class{constructor(e){this.data=e}hasItems(){return!!this.data&&!!this.data.types&&this.data.types.length>0}containsTabularData(){let e=this.data.getData("text/rtf");return e&&e.includes("\\trowd")}getImages(){let{types:e}=this.data,t=[];for(let r of e)if(r.includes("image")){let o=this.data.getData(r);t.push(o.getAsFile())}let i=this.getFiles().filter(r=>r.type.includes("image"));return t.push(...i),t}getFiles(){let{files:e}=this.data;return[...e]}};async function Vr(n){if(window.isSecureContext&&navigator.clipboard){await navigator.clipboard.writeText(n);return}let e=document.createElement("textarea");e.style="position: absolute; left: -1000px; top: -1000px;",e.value=n,document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e)}var Wn=class extends g{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(e){this.isActive=e}setupListeners(){O(this.selectButtons,this.manualSelectHandler.bind(this)),this.setupDropTargetHandlers()}setupDropTargetHandlers(){let e=0,t=()=>{this.hideOverlay(),e=0};this.dropTarget.addEventListener("dragenter",i=>{i.preventDefault(),e+=1,e===1&&this.isActive&&this.showOverlay()}),this.dropTarget.addEventListener("dragover",i=>{i.preventDefault()}),this.dropTarget.addEventListener("dragend",t),this.dropTarget.addEventListener("dragleave",()=>{e-=1,e===0&&t()}),this.dropTarget.addEventListener("drop",i=>{if(i.preventDefault(),t(),!this.isActive)return;let o=new Fe(i.dataTransfer).getFiles();for(let s of o)this.createUploadFromFile(s)})}manualSelectHandler(){let e=Ee("input",{type:"file",style:"left: -400px; visibility: hidden; position: fixed;",accept:this.fileAcceptTypes,multiple:this.allowMultiple?"":null});this.container.append(e),e.click(),e.addEventListener("change",()=>{for(let t of e.files)this.createUploadFromFile(t);e.remove()})}showOverlay(){if(!this.dropTarget.querySelector(".dropzone-overlay")){let t=Ee("div",{class:"dropzone-overlay"},[this.zoneText]);this.dropTarget.append(t)}}hideOverlay(){let e=this.dropTarget.querySelector(".dropzone-overlay");e&&e.remove()}createUploadFromFile(e){let{dom:t,status:i,progress:r,dismiss:o}=this.createDomForFile(e);this.statusArea.append(t);let s=this,a={file:e,dom:t,updateProgress(l){r.textContent=`${l}%`,r.style.width=`${l}%`},markError(l){i.setAttribute("data-status","error"),i.textContent=l,Tt(t),this.updateProgress(100)},markSuccess(l){i.setAttribute("data-status","success"),i.textContent=l,Tt(t),setTimeout(o,2400),s.$emit("upload-success",{name:e.name})}};return e.size>this.uploadLimitMb*1e6?(a.markError(this.uploadLimitMessage),a):(this.startXhrForUpload(a),a)}startXhrForUpload(e){let t=new FormData;t.append("file",e.file,e.file.name),this.method!=="POST"&&t.append("_method",this.method);let i=this,r=window.$http.createXMLHttpRequest("POST",this.url,{error(){e.markError(i.errorMessage)},readystatechange(){if(this.readyState===XMLHttpRequest.DONE&&this.status===200)e.markSuccess(i.successMessage);else if(this.readyState===XMLHttpRequest.DONE&&this.status>=400){let o=this.responseText,s=o.startsWith("{")?JSON.parse(o):{message:o},a=s?.message||s?.error||o;e.markError(a)}}});r.upload.addEventListener("progress",o=>{let s=Math.min(Math.ceil(o.loaded/o.total*100),100);e.updateProgress(s)}),r.setRequestHeader("Accept","application/json"),r.send(t)}createDomForFile(e){let t=Ee("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=Ee("div",{class:"dropzone-file-item-status"},[]),r=Ee("div",{class:"dropzone-file-item-progress"}),o=Ee("div",{class:"dropzone-file-item-image-wrap"},[t]),s=Ee("div",{class:"dropzone-file-item"},[o,Ee("div",{class:"dropzone-file-item-text-wrap"},[Ee("div",{class:"dropzone-file-item-label"},[e.name]),at(),i]),r]);e.type.startsWith("image/")&&(t.src=URL.createObjectURL(e));let a=()=>{s.classList.add("dismiss"),s.addEventListener("animationend",()=>{s.remove()})};return s.addEventListener("click",a),{dom:s,progress:r,status:i,dismiss:a}}};var Gn=class extends g{setup(){this.container=this.$el,this.buttons=this.$manyRefs.tabButton,this.contentElements=this.$manyRefs.tabContent,this.toggleButton=this.$refs.toggle,this.setupListeners(),this.setActiveTab(this.contentElements[0].dataset.tabContent)}setupListeners(){this.toggleButton.addEventListener("click",()=>this.toggle()),this.container.addEventListener("click",e=>{let t=e.target.closest("button");if(this.buttons.includes(t)){let i=t.dataset.tab;this.setActiveTab(i,!0)}})}toggle(){this.container.classList.toggle("open");let e=this.container.classList.contains("open")?"true":"false";this.toggleButton.setAttribute("aria-expanded",e)}setActiveTab(e,t=!1){for(let i of this.buttons)i.classList.remove("active"),i.dataset.tab===e&&i.classList.add("active");for(let i of this.contentElements)i.style.display="none",i.dataset.tabContent===e&&(i.style.display="block");t&&!this.container.classList.contains("open")&&this.toggle()}};var Kn=class extends g{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",e=>{let t=e.target.checked,i=document.querySelectorAll('input[name^="permissions[0]["]');for(let r of i)r.disabled=t,r.checked=!1}),this.container.addEventListener("click",e=>{let t=e.target.closest("button");t&&t.dataset.roleId&&this.removeRowOnButtonClick(t)}),this.roleSelect.addEventListener("change",()=>{let e=this.roleSelect.value;e&&this.addRoleRow(e)})}async addRoleRow(e){this.roleSelect.disabled=!0;let t=this.roleSelect.querySelector(`option[value="${e}"]`);t&&t.remove();let i=await window.$http.get(`/permissions/form-row/${this.entityType}/${e}`),r=_e(i.data);this.roleContainer.append(r),this.roleSelect.disabled=!1}removeRowOnButtonClick(e){let t=e.closest(".item-list-row"),{roleId:i}=e.dataset,{roleName:r}=e.dataset,o=document.createElement("option");o.value=i,o.textContent=r,this.roleSelect.append(o),t.remove()}};var Zn=class extends g{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",e=>{e.preventDefault(),this.runSearch()}),O(this.clearButton,this.clearSearch.bind(this))}runSearch(){let e=this.searchInput.value.trim();if(e.length===0){this.clearSearch();return}this.searchView.classList.remove("hidden"),this.contentView.classList.add("hidden"),this.loadingBlock.classList.remove("hidden");let t=window.baseUrl(`/search/${this.entityType}/${this.entityId}`);window.$http.get(t,{term:e}).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 Xn=class extends g{setup(){this.elem=this.$el,this.entityTypes=this.$opts.entityTypes||"page,book,chapter",this.entityPermission=this.$opts.entityPermission||"view",this.input=this.$refs.input,this.searchInput=this.$refs.search,this.loading=this.$refs.loading,this.resultsContainer=this.$refs.results,this.search="",this.lastClick=0,this.selectedItemData=null,this.setupListeners(),this.showLoading(),this.initialLoad()}setupListeners(){this.elem.addEventListener("click",this.onClick.bind(this));let e=0;this.searchInput.addEventListener("input",()=>{e=Date.now(),this.showLoading(),setTimeout(()=>{Date.now()-e<199||this.searchEntities(this.searchInput.value)},200)}),this.searchInput.addEventListener("keydown",t=>{t.keyCode===13&&t.preventDefault()}),K(this.$el,"[data-entity-type]","keydown",t=>{if(t.ctrlKey&&t.code==="Enter"){let i=this.$el.closest("form");if(i){i.submit(),t.preventDefault();return}}t.code==="ArrowDown"&&this.focusAdjacent(!0),t.code==="ArrowUp"&&this.focusAdjacent(!1)}),this.searchInput.addEventListener("keydown",t=>{t.code==="ArrowDown"&&this.focusAdjacent(!0)})}focusAdjacent(e=!0){let t=Array.from(this.resultsContainer.querySelectorAll("[data-entity-type]")),i=t.indexOf(document.activeElement),r=t[i+(e?1:-1)]||t[0];r&&r.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(){window.$http.get(this.searchUrl()).then(e=>{this.resultsContainer.innerHTML=e.data,this.hideLoading()})}searchUrl(){return`/search/entity-selector?types=${encodeURIComponent(this.entityTypes)}&permission=${encodeURIComponent(this.entityPermission)}`}searchEntities(e){this.input.value="";let t=`${this.searchUrl()}&term=${encodeURIComponent(e)}`;window.$http.get(t).then(i=>{this.resultsContainer.innerHTML=i.data,this.hideLoading()})}isDoubleClick(){let e=Date.now(),t=e-this.lastClick<300;return this.lastClick=e,t}onClick(e){let t=e.target.closest("[data-entity-type]");t&&(e.preventDefault(),e.stopPropagation(),this.selectItem(t))}selectItem(e){let t=this.isDoubleClick(),i=e.getAttribute("data-entity-type"),r=e.getAttribute("data-entity-id"),o=!e.classList.contains("selected")||t;this.unselectAll(),this.input.value=o?`${i}:${r}`:"";let s=e.getAttribute("href"),a=e.querySelector(".entity-list-item-name").textContent,l={id:Number(r),name:a,link:s};o?(e.classList.add("selected"),this.selectedItemData=l):window.$events.emit("entity-select-change",null),!(!t&&!o)&&(t&&this.confirmSelection(l),o&&window.$events.emit("entity-select-change",l))}confirmSelection(e){window.$events.emit("entity-select-confirm",e)}unselectAll(){let e=this.elem.querySelectorAll(".selected");for(let t of e)t.classList.remove("selected","primary-background");this.selectedItemData=null}};var Yn=class extends g{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(e){this.callback=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(e){this.selection=e,e===null?this.selectButton.setAttribute("disabled","true"):this.selectButton.removeAttribute("disabled")}handleConfirmedSelection(e){this.hide(),this.getSelector().reset(),this.callback&&e&&this.callback(e)}};var Jn=class extends g{setup(){this.container=this.$el,this.name=this.$opts.name,O(this.$el,()=>{this.$emit(this.name,this.$opts)})}};var Qn=class extends g{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(e){mt(e,200)}close(e){ft(e,200)}click(e){e.preventDefault();let t=document.querySelectorAll(this.targetSelector);for(let i of t)(this.isOpen?this.close:this.open)(i);this.isOpen=!this.isOpen,this.updateSystemAjax(this.isOpen)}updateSystemAjax(e){window.$http.patch(this.updateEndpoint,{expand:e?"true":"false"})}};var ei=class extends g{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 e=Ne(this.updateSuggestions.bind(this),200,!1);this.input.addEventListener("input",()=>{let{value:t}=this.input;t.length>0?(this.loadingWrap.style.display="block",this.suggestionResultsWrap.style.opacity="0.5",e(t)):this.hideSuggestions()}),this.input.addEventListener("dblclick",()=>{this.input.setAttribute("autocomplete","on"),this.button.focus(),this.input.focus()}),new ze(this.container,()=>{this.hideSuggestions()})}async updateSuggestions(e){let{data:t}=await window.$http.get("/search/suggest",{term:e});if(!this.input.value)return;let i=_e(t);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 ti=class extends g{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(e){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)),e.stopPropagation()}onKeyDown(e){e.code==="Escape"&&this.onToggle(e)}onWindowClick(e){this.onToggle(e)}};var ni=class extends g{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(){O(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()}),O(this.cancelSearch,()=>{this.resetListView(),this.resetSearchView(),this.loadGallery()}),K(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),O(this.selectButton,()=>{this.callback&&this.callback(this.lastSelected),this.hide()}),K(this.formContainer,"#image-manager-delete","click",()=>{this.lastSelected&&this.loadImageEditForm(this.lastSelected.id,!0)}),this.formContainer.addEventListener("ajax-form-success",()=>{this.refreshGallery(),this.resetEditForm()}),this.container.addEventListener("dropzone-upload-success",this.refreshGallery.bind(this));let e=this.listContainer.parentElement,t=[];e.addEventListener("wheel",i=>{if(!(Math.ceil(e.scrollHeight-e.scrollTop)===e.clientHeight)||i.deltaY<1)return;let s=Date.now()-1e3;t.push(Date.now()),t=t.filter(a=>a>=s),t.length>5&&this.canLoadMore()&&this.runLoadMore()})}show(e,t="gallery"){this.resetAll(),this.callback=e,this.type=t,this.getPopup().show();let i=t!=="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 e={page:this.page,search:this.searchInput.value||null,uploaded_to:this.uploadedTo,filter_type:this.filter==="all"?null:this.filter},{data:t}=await window.$http.get(`images/${this.type}`,e);e.page===1&&(this.listContainer.innerHTML=""),this.addReturnedHtmlElementsToList(t),Tt(this.listContainer)}addReturnedHtmlElementsToList(e){let t=document.createElement("div");t.innerHTML=e;let i=t.querySelector(".load-more");i&&(i.remove(),this.loadMore.innerHTML=i.innerHTML),this.loadMore.toggleAttribute("hidden",!i),window.$components.init(t);for(let r of[...t.children])this.listContainer.appendChild(r)}setActiveFilterTab(e){for(let t of this.filterTabs){let i=t.dataset.filter===e;t.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(){Dt(this.listContainer),this.page=1}refreshGallery(){this.resetListView(),this.loadGallery()}onImageSelectEvent(e){let t=JSON.parse(e.detail.data),i=t&&t.id===this.lastSelected.id&&Date.now()-this.lastSelectedTime<400,r=e.target.classList.contains("selected");[...this.listContainer.querySelectorAll(".selected")].forEach(o=>{o.classList.remove("selected")}),r?this.resetEditForm():(e.target.classList.add("selected"),this.loadImageEditForm(t.id)),this.selectButton.classList.toggle("hidden",r),i&&this.callback&&(this.callback(t),this.hide()),this.lastSelected=t,this.lastSelectedTime=Date.now()}async loadImageEditForm(e,t=!1){t||(this.formContainer.innerHTML="");let i=t?{delete:!0}:{},{data:r}=await window.$http.get(`/images/edit/${e}`,i);this.formContainer.innerHTML=r,this.formContainerPlaceholder.setAttribute("hidden",""),window.$components.init(this.formContainer)}runLoadMore(){Dt(this.loadMore),this.page+=1,this.loadGallery()}canLoadMore(){return this.loadMore.querySelector("button")&&!this.loadMore.hasAttribute("hidden")}};var ii=class extends g{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 e of this.imageInput.files)this.imageElem.src=window.URL.createObjectURL(e);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 ri=class extends g{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",e=>{e.target.closest("[data-sort-value]")!==null&&this.sortOptionClick(e)}),this.elem.addEventListener("click",e=>{e.target.closest("[data-sort-dir]")!==null&&this.sortDirectionClick(e)})}sortOptionClick(e){let t=e.target.closest("[data-sort-value]");this.sortInput.value=t.getAttribute("data-sort-value"),e.preventDefault(),this.form.submit()}sortDirectionClick(e){let t=this.orderInput.value;this.orderInput.value=t==="asc"?"desc":"asc",e.preventDefault(),this.form.submit()}};var Uc=Wo(Pc()),jc=Wo(Hc()),wi=class{constructor(){this.renderer=new Uc.default({html:!0}),this.renderer.use(jc.default,{label:!0})}getRenderer(){return this.renderer}render(e){return this.renderer.render(e)}};function nf(n,e){return document.createElement(n,e)}function rf(n,e,t){return document.createElementNS(n,e,t)}function of(){return et(document.createDocumentFragment())}function sf(n){return document.createTextNode(n)}function af(n){return document.createComment(n)}function lf(n,e,t){if(qe(n)){let i=n;for(;i&&qe(i);)i=et(i).parent;n=i??n}qe(e)&&(e=et(e,n)),t&&qe(t)&&(t=et(t).firstChildNode),n.insertBefore(e,t)}function cf(n,e){n.removeChild(e)}function uf(n,e){qe(e)&&(e=et(e,n)),n.appendChild(e)}function Vc(n){if(qe(n)){for(;n&&qe(n);)n=et(n).parent;return n??null}return n.parentNode}function hf(n){var e;if(qe(n)){let t=et(n),i=Vc(t);if(i&&t.lastChildNode){let r=Array.from(i.childNodes),o=r.indexOf(t.lastChildNode);return(e=r[o+1])!==null&&e!==void 0?e:null}return null}return n.nextSibling}function df(n){return n.tagName}function pf(n,e){n.textContent=e}function ff(n){return n.textContent}function mf(n){return n.nodeType===1}function gf(n){return n.nodeType===3}function bf(n){return n.nodeType===8}function qe(n){return n.nodeType===11}function et(n,e){var t,i,r;let o=n;return(t=o.parent)!==null&&t!==void 0||(o.parent=e??null),(i=o.firstChildNode)!==null&&i!==void 0||(o.firstChildNode=n.firstChild),(r=o.lastChildNode)!==null&&r!==void 0||(o.lastChildNode=n.lastChild),o}var yi={createElement:nf,createElementNS:rf,createTextNode:sf,createDocumentFragment:of,createComment:af,insertBefore:lf,removeChild:cf,appendChild:uf,parentNode:Vc,nextSibling:hf,tagName:df,setTextContent:pf,getTextContent:ff,isElement:mf,isText:gf,isComment:bf,isDocumentFragment:qe};function Be(n,e,t,i,r){let o=e===void 0?void 0:e.key;return{sel:n,data:e,children:t,text:i,elm:r,key:o}}var Wc=Array.isArray;function Gc(n){return typeof n=="string"||typeof n=="number"||n instanceof String||n instanceof Number}function Co(n){return n===void 0}function ce(n){return n!==void 0}var Eo=Be("",{},[],void 0,void 0);function Jt(n,e){var t,i;let r=n.key===e.key,o=((t=n.data)===null||t===void 0?void 0:t.is)===((i=e.data)===null||i===void 0?void 0:i.is),s=n.sel===e.sel,a=!n.sel&&n.sel===e.sel?typeof n.text==typeof e.text:!0;return s&&r&&o&&a}function wf(){throw new Error("The document fragment is not supported on this platform.")}function yf(n,e){return n.isElement(e)}function xf(n,e){return n.isDocumentFragment(e)}function kf(n,e,t){var i;let r={};for(let o=e;o<=t;++o){let s=(i=n[o])===null||i===void 0?void 0:i.key;s!==void 0&&(r[s]=o)}return r}var Cf=["create","update","remove","destroy","pre","post"];function _o(n,e,t){let i={create:[],update:[],remove:[],destroy:[],pre:[],post:[]},r=e!==void 0?e:yi;for(let f of Cf)for(let m of n){let y=m[f];y!==void 0&&i[f].push(y)}function o(f){let m=f.id?"#"+f.id:"",y=f.getAttribute("class"),v=y?"."+y.split(" ").join("."):"";return Be(r.tagName(f).toLowerCase()+m+v,{},[],void 0,f)}function s(f){return Be(void 0,{},[],void 0,f)}function a(f,m){return function(){if(--m===0){let v=r.parentNode(f);r.removeChild(v,f)}}}function l(f,m){var y,v,b,k;let w,E=f.data;if(E!==void 0){let D=(y=E.hook)===null||y===void 0?void 0:y.init;ce(D)&&(D(f),E=f.data)}let x=f.children,S=f.sel;if(S==="!")Co(f.text)&&(f.text=""),f.elm=r.createComment(f.text);else if(S!==void 0){let D=S.indexOf("#"),q=S.indexOf(".",D),L=D>0?D:S.length,I=q>0?q:S.length,H=D!==-1||q!==-1?S.slice(0,Math.min(L,I)):S,N=f.elm=ce(E)&&ce(w=E.ns)?r.createElementNS(w,H,E):r.createElement(H,E);for(L<I&&N.setAttribute("id",S.slice(L+1,I)),q>0&&N.setAttribute("class",S.slice(I+1).replace(/\./g," ")),w=0;w<i.create.length;++w)i.create[w](Eo,f);if(Wc(x))for(w=0;w<x.length;++w){let ge=x[w];ge!=null&&r.appendChild(N,l(ge,m))}else Gc(f.text)&&r.appendChild(N,r.createTextNode(f.text));let ee=f.data.hook;ce(ee)&&((v=ee.create)===null||v===void 0||v.call(ee,Eo,f),ee.insert&&m.push(f))}else if(!((b=t?.experimental)===null||b===void 0)&&b.fragments&&f.children){for(f.elm=((k=r.createDocumentFragment)!==null&&k!==void 0?k:wf)(),w=0;w<i.create.length;++w)i.create[w](Eo,f);for(w=0;w<f.children.length;++w){let D=f.children[w];D!=null&&r.appendChild(f.elm,l(D,m))}}else f.elm=r.createTextNode(f.text);return f.elm}function c(f,m,y,v,b,k){for(;v<=b;++v){let w=y[v];w!=null&&r.insertBefore(f,l(w,k),m)}}function u(f){var m,y;let v=f.data;if(v!==void 0){(y=(m=v?.hook)===null||m===void 0?void 0:m.destroy)===null||y===void 0||y.call(m,f);for(let b=0;b<i.destroy.length;++b)i.destroy[b](f);if(f.children!==void 0)for(let b=0;b<f.children.length;++b){let k=f.children[b];k!=null&&typeof k!="string"&&u(k)}}}function h(f,m,y,v){for(var b,k;y<=v;++y){let w,E,x=m[y];if(x!=null)if(ce(x.sel)){u(x),w=i.remove.length+1,E=a(x.elm,w);for(let D=0;D<i.remove.length;++D)i.remove[D](x,E);let S=(k=(b=x?.data)===null||b===void 0?void 0:b.hook)===null||k===void 0?void 0:k.remove;ce(S)?S(x,E):E()}else x.children?(u(x),h(f,x.children,0,x.children.length-1)):r.removeChild(f,x.elm)}}function d(f,m,y,v){let b=0,k=0,w=m.length-1,E=m[0],x=m[w],S=y.length-1,D=y[0],q=y[S],L,I,H,N;for(;b<=w&&k<=S;)E==null?E=m[++b]:x==null?x=m[--w]:D==null?D=y[++k]:q==null?q=y[--S]:Jt(E,D)?(p(E,D,v),E=m[++b],D=y[++k]):Jt(x,q)?(p(x,q,v),x=m[--w],q=y[--S]):Jt(E,q)?(p(E,q,v),r.insertBefore(f,E.elm,r.nextSibling(x.elm)),E=m[++b],q=y[--S]):Jt(x,D)?(p(x,D,v),r.insertBefore(f,x.elm,E.elm),x=m[--w],D=y[++k]):(L===void 0&&(L=kf(m,b,w)),I=L[D.key],Co(I)?r.insertBefore(f,l(D,v),E.elm):(H=m[I],H.sel!==D.sel?r.insertBefore(f,l(D,v),E.elm):(p(H,D,v),m[I]=void 0,r.insertBefore(f,H.elm,E.elm))),D=y[++k]);k<=S&&(N=y[S+1]==null?null:y[S+1].elm,c(f,N,y,k,S,v)),b<=w&&h(f,m,b,w)}function p(f,m,y){var v,b,k,w,E,x,S,D;let q=(v=m.data)===null||v===void 0?void 0:v.hook;(b=q?.prepatch)===null||b===void 0||b.call(q,f,m);let L=m.elm=f.elm;if(f===m)return;if(m.data!==void 0||ce(m.text)&&m.text!==f.text){(k=m.data)!==null&&k!==void 0||(m.data={}),(w=f.data)!==null&&w!==void 0||(f.data={});for(let N=0;N<i.update.length;++N)i.update[N](f,m);(S=(x=(E=m.data)===null||E===void 0?void 0:E.hook)===null||x===void 0?void 0:x.update)===null||S===void 0||S.call(x,f,m)}let I=f.children,H=m.children;Co(m.text)?ce(I)&&ce(H)?I!==H&&d(L,I,H,y):ce(H)?(ce(f.text)&&r.setTextContent(L,""),c(L,null,H,0,H.length-1,y)):ce(I)?h(L,I,0,I.length-1):ce(f.text)&&r.setTextContent(L,""):f.text!==m.text&&(ce(I)&&h(L,I,0,I.length-1),r.setTextContent(L,m.text)),(D=q?.postpatch)===null||D===void 0||D.call(q,f,m)}return function(m,y){let v,b,k,w=[];for(v=0;v<i.pre.length;++v)i.pre[v]();for(yf(r,m)?m=o(m):xf(r,m)&&(m=s(m)),Jt(m,y)?p(m,y,w):(b=m.elm,k=r.parentNode(b),l(y,w),k!==null&&(r.insertBefore(k,y.elm,r.nextSibling(b)),h(k,[m],0,0))),v=0;v<w.length;++v)w[v].data.hook.insert(w[v]);for(v=0;v<i.post.length;++v)i.post[v]();return y}}function So(n,e,t){if(n.ns="http://www.w3.org/2000/svg",t!=="foreignObject"&&e!==void 0)for(let i=0;i<e.length;++i){let r=e[i];if(typeof r=="string")continue;let o=r.data;o!==void 0&&So(o,r.children,r.sel)}}function Qt(n,e){let t=e!==void 0?e:yi,i;if(t.isElement(n)){let r=n.id?"#"+n.id:"",o=n.getAttribute("class"),s=o?"."+o.split(" ").join("."):"",a=t.tagName(n).toLowerCase()+r+s,l={},c={},u={},h=[],d,p,f,m=n.attributes,y=n.childNodes;for(p=0,f=m.length;p<f;p++)d=m[p].nodeName,d[0]==="d"&&d[1]==="a"&&d[2]==="t"&&d[3]==="a"&&d[4]==="-"?c[d.slice(5)]=m[p].nodeValue||"":d!=="id"&&d!=="class"&&(l[d]=m[p].nodeValue);for(p=0,f=y.length;p<f;p++)h.push(Qt(y[p],e));return Object.keys(l).length>0&&(u.attrs=l),Object.keys(c).length>0&&(u.dataset=c),a[0]==="s"&&a[1]==="v"&&a[2]==="g"&&(a.length===3||a[3]==="."||a[3]==="#")&&So(u,h,a),Be(a,u,h,void 0,n)}else return t.isText(n)?(i=t.getTextContent(n),Be(void 0,void 0,void 0,i,n)):t.isComment(n)?(i=t.getTextContent(n),Be("!",{},[],i,n)):Be("",{},[],void 0,n)}var Ef="http://www.w3.org/1999/xlink",_f="http://www.w3.org/XML/1998/namespace";function Kc(n,e){let t,i=e.elm,r=n.data.attrs,o=e.data.attrs;if(!(!r&&!o)&&r!==o){r=r||{},o=o||{};for(t in o){let s=o[t];r[t]!==s&&(s===!0?i.setAttribute(t,""):s===!1?i.removeAttribute(t):t.charCodeAt(0)!==120?i.setAttribute(t,s):t.charCodeAt(3)===58?i.setAttributeNS(_f,t,s):t.charCodeAt(5)===58?i.setAttributeNS(Ef,t,s):i.setAttribute(t,s))}for(t in r)t in o||i.removeAttribute(t)}}var Ao={create:Kc,update:Kc};var xi;function Sf(){return xi||(xi=_o([Ao]),xi)}function Zc(n,e){let t=document.createElement("div");t.innerHTML=e,Sf()(Qt(n),Qt(t))}var ki=class{constructor(e){this.editor=e,this.container=e.config.displayEl,this.doc=null,this.lastDisplayClick=0,this.container.contentDocument.readyState==="complete"?this.onLoad():this.container.addEventListener("load",this.onLoad.bind(this)),this.updateVisibility(e.settings.get("showPreview")),e.settings.onChange("showPreview",t=>this.updateVisibility(t))}updateVisibility(e){let t=this.container.closest(".markdown-editor-wrap");t.style.display=e?null:"none"}onLoad(){this.doc=this.container.contentDocument,this.loadStylesIntoDisplay(),this.doc.body.className="page-content",this.doc.addEventListener("click",this.onDisplayClick.bind(this))}onDisplayClick(e){let t=Date.now()-this.lastDisplayClick<300,i=e.target.closest("a");if(i!==null){e.preventDefault(),window.open(i.getAttribute("href"));return}let r=e.target.closest("[drawio-diagram]");if(r!==null&&t){this.editor.actions.editDrawing(r);return}this.lastDisplayClick=Date.now()}loadStylesIntoDisplay(){this.doc.documentElement.classList.add("markdown-editor-display"),document.documentElement.classList.contains("dark-mode")&&(this.doc.documentElement.style.backgroundColor="#222",this.doc.documentElement.classList.add("dark-mode")),this.doc.head.innerHTML="";let e=document.head.querySelectorAll("style,link[rel=stylesheet]");for(let t of e){let i=t.cloneNode(!0);this.doc.head.appendChild(i)}}patchWithHtml(e){let{body:t}=this.doc;if(t.children.length===0){let r=document.createElement("div");this.doc.body.append(r)}let i=t.children[0];Zc(i,e)}scrollToIndex(e){let t=this.doc.body?.children[0]?.children;if(t&&t.length<=e)return;(e===-1?t[t.length-1]:t[e]).scrollIntoView({block:"start",inline:"nearest",behavior:"smooth"})}};function Ci(n){return new Promise((e,t)=>{n.oncomplete=n.onsuccess=()=>e(n.result),n.onabort=n.onerror=()=>t(n.error)})}function Af(n,e){let t=indexedDB.open(n);t.onupgradeneeded=()=>t.result.createObjectStore(e);let i=Ci(t);return(r,o)=>i.then(s=>o(s.transaction(e,r).objectStore(e)))}var Do;function To(){return Do||(Do=Af("keyval-store","keyval")),Do}function Lo(n,e=To()){return e("readonly",t=>Ci(t.get(n)))}function Io(n,e,t=To()){return t("readwrite",i=>(i.put(e,n),Ci(i.transaction)))}function $o(n,e=To()){return e("readwrite",t=>(t.delete(n),Ci(t.transaction)))}var Ie=null,qo,Ei,Mo,Fo="last-drawing-save";function Bo(n){Ie.contentWindow.postMessage(JSON.stringify(n),qo)}function Tf(n){Io(Fo,n.data),Mo&&Mo(n.data).then(()=>{$o(Fo)})}function Lf(n){Bo({action:"export",format:"xmlpng",xml:n.xml,spin:"Updating drawing"})}function If(){Ei&&Ei().then(n=>{Bo({action:"load",autosave:1,xml:n})})}function $f(){let n={};window.$events.emitPublic(Ie,"editor-drawio::configure",{config:n}),Bo({action:"configure",config:n})}function Xc(){window.removeEventListener("message",Yc),Ie&&document.body.removeChild(Ie)}function Yc(n){if(!n.data||n.data.length<1||n.origin!==qo)return;let e=JSON.parse(n.data);e.event==="init"?If():e.event==="exit"?Xc():e.event==="save"?Lf(e):e.event==="export"?Tf(e):e.event==="configure"&&$f()}async function Mf(){let n=await Lo(Fo),e=document.getElementById("unsaved-drawing-dialog");e||console.error("Missing expected unsaved-drawing dialog"),n&&await window.$components.firstOnElement(e,"confirm-dialog").show()&&(Ei=async()=>n)}async function en(n,e,t){Ei=e,Mo=t,await Mf(),Ie=document.createElement("iframe"),Ie.setAttribute("frameborder","0"),window.addEventListener("message",Yc),Ie.setAttribute("src",n),Ie.setAttribute("class","fullscreen"),Ie.style.backgroundColor="#FFFFFF",document.body.appendChild(Ie),qo=new URL(n).origin}async function Po(n,e){let t={image:n,uploaded_to:e};return(await window.$http.post(window.baseUrl("/images/drawio"),t)).data}function tt(){Xc()}async function _i(n){try{return`data:image/png;base64,${(await window.$http.get(window.baseUrl(`/images/drawio/base64/${n}`))).data.content}`}catch(e){throw e instanceof window.$http.HttpError&&window.$events.showResponseError(e),tt(),e}}var tn,Oo,xt,Si,kt,Ai,Pe,nt,We,yt,ie,ue,nn,Ro,rn,No,Ct,Di,he,ve,Li,Qc,Ti=class{constructor(e){re(this,tn);re(this,xt);re(this,kt);re(this,Pe);re(this,We);re(this,ie);re(this,nn);re(this,rn);re(this,Ct);re(this,he);re(this,Li);this.editor=e,this.lastContent={html:"",markdown:""}}updateAndRender(){let e=T(this,xt,Si).call(this);this.editor.config.inputEl.value=e;let t=this.editor.markdown.render(e);window.$events.emit("editor-html-change",""),window.$events.emit("editor-markdown-change",""),this.lastContent.html=t,this.lastContent.markdown=e,this.editor.display.patchWithHtml(t)}getContent(){return this.lastContent}showImageInsert(){window.$components.first("image-manager").show(t=>{let i=t.thumbs.display||t.url,o=`[](${t.url})`;T(this,Pe,nt).call(this,o,o.length)},"gallery")}insertImage(){let e=``;T(this,Pe,nt).call(this,e,e.length-1)}insertLink(){let e=T(this,We,yt).call(this),t=`[${e}]()`,i=e===""?-3:-1;T(this,Pe,nt).call(this,t,t.length+i)}showImageManager(){let e=T(this,ie,ue).call(this);window.$components.first("image-manager").show(i=>{T(this,tn,Oo).call(this,i,e)},"drawio")}showLinkSelector(){let e=T(this,ie,ue).call(this);window.$components.first("entity-selector-popup").show(i=>{let o=`[${T(this,We,yt).call(this,e)||i.name}](${i.link})`;T(this,Pe,nt).call(this,o,o.length,e)})}startDrawing(){let e=this.editor.config.drawioUrl;if(!e)return;let t=T(this,ie,ue).call(this);en(e,()=>Promise.resolve(""),async i=>{let r={image:i,uploaded_to:Number(this.editor.config.pageId)};try{let o=await window.$http.post("/images/drawio",r);T(this,tn,Oo).call(this,o.data,t),tt()}catch(o){throw this.handleDrawingUploadError(o),new Error(`Failed to save image with error: ${o}`)}})}editDrawing(e){let{drawioUrl:t}=this.editor.config;if(!t)return;let i=T(this,ie,ue).call(this),r=e.getAttribute("drawio-diagram");en(t,()=>_i(r),async o=>{let s={image:o,uploaded_to:Number(this.editor.config.pageId)};try{let a=await window.$http.post("/images/drawio",s),l=`<div drawio-diagram="${a.data.id}"><img src="${a.data.url}"></div>`,c=T(this,xt,Si).call(this).split(`
+`);return i};bt.prototype.render=function(n,e,t){var i,r,o,s="",a=this.rules;for(i=0,r=n.length;i<r;i++)o=n[i].type,o==="inline"?s+=this.renderInline(n[i].children,e,t):typeof a[o]<"u"?s+=a[n[i].type](n,i,e,t,this):s+=this.renderToken(n,i,e,t);return s};ma.exports=bt});var ui=_((Gb,ba)=>{"use strict";function Ce(){this.__rules__=[],this.__cache__=null}Ce.prototype.__find__=function(n){for(var e=0;e<this.__rules__.length;e++)if(this.__rules__[e].name===n)return e;return-1};Ce.prototype.__compile__=function(){var n=this,e=[""];n.__rules__.forEach(function(t){t.enabled&&t.alt.forEach(function(i){e.indexOf(i)<0&&e.push(i)})}),n.__cache__={},e.forEach(function(t){n.__cache__[t]=[],n.__rules__.forEach(function(i){i.enabled&&(t&&i.alt.indexOf(t)<0||n.__cache__[t].push(i.fn))})})};Ce.prototype.at=function(n,e,t){var i=this.__find__(n),r=t||{};if(i===-1)throw new Error("Parser rule not found: "+n);this.__rules__[i].fn=e,this.__rules__[i].alt=r.alt||[],this.__cache__=null};Ce.prototype.before=function(n,e,t,i){var r=this.__find__(n),o=i||{};if(r===-1)throw new Error("Parser rule not found: "+n);this.__rules__.splice(r,0,{name:e,enabled:!0,fn:t,alt:o.alt||[]}),this.__cache__=null};Ce.prototype.after=function(n,e,t,i){var r=this.__find__(n),o=i||{};if(r===-1)throw new Error("Parser rule not found: "+n);this.__rules__.splice(r+1,0,{name:e,enabled:!0,fn:t,alt:o.alt||[]}),this.__cache__=null};Ce.prototype.push=function(n,e,t){var i=t||{};this.__rules__.push({name:n,enabled:!0,fn:e,alt:i.alt||[]}),this.__cache__=null};Ce.prototype.enable=function(n,e){Array.isArray(n)||(n=[n]);var t=[];return n.forEach(function(i){var r=this.__find__(i);if(r<0){if(e)return;throw new Error("Rules manager: invalid rule name "+i)}this.__rules__[r].enabled=!0,t.push(i)},this),this.__cache__=null,t};Ce.prototype.enableOnly=function(n,e){Array.isArray(n)||(n=[n]),this.__rules__.forEach(function(t){t.enabled=!1}),this.enable(n,e)};Ce.prototype.disable=function(n,e){Array.isArray(n)||(n=[n]);var t=[];return n.forEach(function(i){var r=this.__find__(i);if(r<0){if(e)return;throw new Error("Rules manager: invalid rule name "+i)}this.__rules__[r].enabled=!1,t.push(i)},this),this.__cache__=null,t};Ce.prototype.getRules=function(n){return this.__cache__===null&&this.__compile__(),this.__cache__[n]||[]};ba.exports=Ce});var wa=_((Kb,va)=>{"use strict";var yd=/\r\n?|\n/g,xd=/\0/g;va.exports=function(e){var t;t=e.src.replace(yd,`
+`),t=t.replace(xd,"\uFFFD"),e.src=t}});var xa=_((Zb,ya)=>{"use strict";ya.exports=function(e){var t;e.inlineMode?(t=new e.Token("inline","",0),t.content=e.src,t.map=[0,1],t.children=[],e.tokens.push(t)):e.md.block.parse(e.src,e.md,e.env,e.tokens)}});var Ca=_((Xb,ka)=>{"use strict";ka.exports=function(e){var t=e.tokens,i,r,o;for(r=0,o=t.length;r<o;r++)i=t[r],i.type==="inline"&&e.md.inline.parse(i.content,e.md,e.env,i.children)}});var _a=_((Yb,Ea)=>{"use strict";var kd=R().arrayReplaceAt;function Cd(n){return/^<a[>\s]/i.test(n)}function Ed(n){return/^<\/a\s*>/i.test(n)}Ea.exports=function(e){var t,i,r,o,s,a,l,c,u,h,d,p,f,m,y,v,b=e.tokens,k;if(e.md.options.linkify){for(i=0,r=b.length;i<r;i++)if(!(b[i].type!=="inline"||!e.md.linkify.pretest(b[i].content)))for(o=b[i].children,f=0,t=o.length-1;t>=0;t--){if(a=o[t],a.type==="link_close"){for(t--;o[t].level!==a.level&&o[t].type!=="link_open";)t--;continue}if(a.type==="html_inline"&&(Cd(a.content)&&f>0&&f--,Ed(a.content)&&f++),!(f>0)&&a.type==="text"&&e.md.linkify.test(a.content)){for(u=a.content,k=e.md.linkify.match(u),l=[],p=a.level,d=0,k.length>0&&k[0].index===0&&t>0&&o[t-1].type==="text_special"&&(k=k.slice(1)),c=0;c<k.length;c++)m=k[c].url,y=e.md.normalizeLink(m),e.md.validateLink(y)&&(v=k[c].text,k[c].schema?k[c].schema==="mailto:"&&!/^mailto:/i.test(v)?v=e.md.normalizeLinkText("mailto:"+v).replace(/^mailto:/,""):v=e.md.normalizeLinkText(v):v=e.md.normalizeLinkText("http://"+v).replace(/^http:\/\//,""),h=k[c].index,h>d&&(s=new e.Token("text","",0),s.content=u.slice(d,h),s.level=p,l.push(s)),s=new e.Token("link_open","a",1),s.attrs=[["href",y]],s.level=p++,s.markup="linkify",s.info="auto",l.push(s),s=new e.Token("text","",0),s.content=v,s.level=p,l.push(s),s=new e.Token("link_close","a",-1),s.level=--p,s.markup="linkify",s.info="auto",l.push(s),d=k[c].lastIndex);d<u.length&&(s=new e.Token("text","",0),s.content=u.slice(d),s.level=p,l.push(s)),b[i].children=o=kd(o,t,l)}}}}});var Da=_((Jb,Aa)=>{"use strict";var Sa=/\+-|\.\.|\?\?\?\?|!!!!|,,|--/,_d=/\((c|tm|r)\)/i,Sd=/\((c|tm|r)\)/ig,Ad={c:"\xA9",r:"\xAE",tm:"\u2122"};function Dd(n,e){return Ad[e.toLowerCase()]}function Td(n){var e,t,i=0;for(e=n.length-1;e>=0;e--)t=n[e],t.type==="text"&&!i&&(t.content=t.content.replace(Sd,Dd)),t.type==="link_open"&&t.info==="auto"&&i--,t.type==="link_close"&&t.info==="auto"&&i++}function Ld(n){var e,t,i=0;for(e=n.length-1;e>=0;e--)t=n[e],t.type==="text"&&!i&&Sa.test(t.content)&&(t.content=t.content.replace(/\+-/g,"\xB1").replace(/\.{2,}/g,"\u2026").replace(/([?!])…/g,"$1..").replace(/([?!]){4,}/g,"$1$1$1").replace(/,{2,}/g,",").replace(/(^|[^-])---(?=[^-]|$)/mg,"$1\u2014").replace(/(^|\s)--(?=\s|$)/mg,"$1\u2013").replace(/(^|[^-\s])--(?=[^-\s]|$)/mg,"$1\u2013")),t.type==="link_open"&&t.info==="auto"&&i--,t.type==="link_close"&&t.info==="auto"&&i++}Aa.exports=function(e){var t;if(e.md.options.typographer)for(t=e.tokens.length-1;t>=0;t--)e.tokens[t].type==="inline"&&(_d.test(e.tokens[t].content)&&Td(e.tokens[t].children),Sa.test(e.tokens[t].content)&&Ld(e.tokens[t].children))}});var qa=_((Qb,Fa)=>{"use strict";var Ta=R().isWhiteSpace,La=R().isPunctChar,Ia=R().isMdAsciiPunct,Id=/['"]/,$a=/['"]/g,Ma="\u2019";function hi(n,e,t){return n.slice(0,e)+t+n.slice(e+1)}function $d(n,e){var t,i,r,o,s,a,l,c,u,h,d,p,f,m,y,v,b,k,w,E,x;for(w=[],t=0;t<n.length;t++){for(i=n[t],l=n[t].level,b=w.length-1;b>=0&&!(w[b].level<=l);b--);if(w.length=b+1,i.type==="text"){r=i.content,s=0,a=r.length;e:for(;s<a&&($a.lastIndex=s,o=$a.exec(r),!!o);){if(y=v=!0,s=o.index+1,k=o[0]==="'",u=32,o.index-1>=0)u=r.charCodeAt(o.index-1);else for(b=t-1;b>=0&&!(n[b].type==="softbreak"||n[b].type==="hardbreak");b--)if(n[b].content){u=n[b].content.charCodeAt(n[b].content.length-1);break}if(h=32,s<a)h=r.charCodeAt(s);else for(b=t+1;b<n.length&&!(n[b].type==="softbreak"||n[b].type==="hardbreak");b++)if(n[b].content){h=n[b].content.charCodeAt(0);break}if(d=Ia(u)||La(String.fromCharCode(u)),p=Ia(h)||La(String.fromCharCode(h)),f=Ta(u),m=Ta(h),m?y=!1:p&&(f||d||(y=!1)),f?v=!1:d&&(m||p||(v=!1)),h===34&&o[0]==='"'&&u>=48&&u<=57&&(v=y=!1),y&&v&&(y=d,v=p),!y&&!v){k&&(i.content=hi(i.content,o.index,Ma));continue}if(v){for(b=w.length-1;b>=0&&(c=w[b],!(w[b].level<l));b--)if(c.single===k&&w[b].level===l){c=w[b],k?(E=e.md.options.quotes[2],x=e.md.options.quotes[3]):(E=e.md.options.quotes[0],x=e.md.options.quotes[1]),i.content=hi(i.content,o.index,x),n[c.token].content=hi(n[c.token].content,c.pos,E),s+=x.length-1,c.token===t&&(s+=E.length-1),r=i.content,a=r.length,w.length=b;continue e}}y?w.push({token:t,pos:o.index,single:k,level:l}):v&&k&&(i.content=hi(i.content,o.index,Ma))}}}}Fa.exports=function(e){var t;if(e.md.options.typographer)for(t=e.tokens.length-1;t>=0;t--)e.tokens[t].type!=="inline"||!Id.test(e.tokens[t].content)||$d(e.tokens[t].children,e)}});var Pa=_((ev,Ba)=>{"use strict";Ba.exports=function(e){var t,i,r,o,s,a,l=e.tokens;for(t=0,i=l.length;t<i;t++)if(l[t].type==="inline"){for(r=l[t].children,s=r.length,o=0;o<s;o++)r[o].type==="text_special"&&(r[o].type="text");for(o=a=0;o<s;o++)r[o].type==="text"&&o+1<s&&r[o+1].type==="text"?r[o+1].content=r[o].content+r[o+1].content:(o!==a&&(r[a]=r[o]),a++);o!==a&&(r.length=a)}}});var di=_((tv,Oa)=>{"use strict";function vt(n,e,t){this.type=n,this.tag=e,this.attrs=null,this.map=null,this.nesting=t,this.level=0,this.children=null,this.content="",this.markup="",this.info="",this.meta=null,this.block=!1,this.hidden=!1}vt.prototype.attrIndex=function(e){var t,i,r;if(!this.attrs)return-1;for(t=this.attrs,i=0,r=t.length;i<r;i++)if(t[i][0]===e)return i;return-1};vt.prototype.attrPush=function(e){this.attrs?this.attrs.push(e):this.attrs=[e]};vt.prototype.attrSet=function(e,t){var i=this.attrIndex(e),r=[e,t];i<0?this.attrPush(r):this.attrs[i]=r};vt.prototype.attrGet=function(e){var t=this.attrIndex(e),i=null;return t>=0&&(i=this.attrs[t][1]),i};vt.prototype.attrJoin=function(e,t){var i=this.attrIndex(e);i<0?this.attrPush([e,t]):this.attrs[i][1]=this.attrs[i][1]+" "+t};Oa.exports=vt});var za=_((nv,Na)=>{"use strict";var Md=di();function Ra(n,e,t){this.src=n,this.env=t,this.tokens=[],this.inlineMode=!1,this.md=e}Ra.prototype.Token=Md;Na.exports=Ra});var Ua=_((iv,Ha)=>{"use strict";var Fd=ui(),Yr=[["normalize",wa()],["block",xa()],["inline",Ca()],["linkify",_a()],["replacements",Da()],["smartquotes",qa()],["text_join",Pa()]];function Jr(){this.ruler=new Fd;for(var n=0;n<Yr.length;n++)this.ruler.push(Yr[n][0],Yr[n][1])}Jr.prototype.process=function(n){var e,t,i;for(i=this.ruler.getRules(""),e=0,t=i.length;e<t;e++)i[e](n)};Jr.prototype.State=za();Ha.exports=Jr});var Wa=_((rv,Va)=>{"use strict";var Qr=R().isSpace;function eo(n,e){var t=n.bMarks[e]+n.tShift[e],i=n.eMarks[e];return n.src.slice(t,i)}function ja(n){var e=[],t=0,i=n.length,r,o=!1,s=0,a="";for(r=n.charCodeAt(t);t<i;)r===124&&(o?(a+=n.substring(s,t-1),s=t):(e.push(a+n.substring(s,t)),a="",s=t+1)),o=r===92,t++,r=n.charCodeAt(t);return e.push(a+n.substring(s)),e}Va.exports=function(e,t,i,r){var o,s,a,l,c,u,h,d,p,f,m,y,v,b,k,w,E,x;if(t+2>i||(u=t+1,e.sCount[u]<e.blkIndent)||e.sCount[u]-e.blkIndent>=4||(a=e.bMarks[u]+e.tShift[u],a>=e.eMarks[u])||(E=e.src.charCodeAt(a++),E!==124&&E!==45&&E!==58)||a>=e.eMarks[u]||(x=e.src.charCodeAt(a++),x!==124&&x!==45&&x!==58&&!Qr(x))||E===45&&Qr(x))return!1;for(;a<e.eMarks[u];){if(o=e.src.charCodeAt(a),o!==124&&o!==45&&o!==58&&!Qr(o))return!1;a++}for(s=eo(e,t+1),h=s.split("|"),f=[],l=0;l<h.length;l++){if(m=h[l].trim(),!m){if(l===0||l===h.length-1)continue;return!1}if(!/^:?-+:?$/.test(m))return!1;m.charCodeAt(m.length-1)===58?f.push(m.charCodeAt(0)===58?"center":"right"):m.charCodeAt(0)===58?f.push("left"):f.push("")}if(s=eo(e,t).trim(),s.indexOf("|")===-1||e.sCount[t]-e.blkIndent>=4||(h=ja(s),h.length&&h[0]===""&&h.shift(),h.length&&h[h.length-1]===""&&h.pop(),d=h.length,d===0||d!==f.length))return!1;if(r)return!0;for(b=e.parentType,e.parentType="table",w=e.md.block.ruler.getRules("blockquote"),p=e.push("table_open","table",1),p.map=y=[t,0],p=e.push("thead_open","thead",1),p.map=[t,t+1],p=e.push("tr_open","tr",1),p.map=[t,t+1],l=0;l<h.length;l++)p=e.push("th_open","th",1),f[l]&&(p.attrs=[["style","text-align:"+f[l]]]),p=e.push("inline","",0),p.content=h[l].trim(),p.children=[],p=e.push("th_close","th",-1);for(p=e.push("tr_close","tr",-1),p=e.push("thead_close","thead",-1),u=t+2;u<i&&!(e.sCount[u]<e.blkIndent);u++){for(k=!1,l=0,c=w.length;l<c;l++)if(w[l](e,u,i,!0)){k=!0;break}if(k||(s=eo(e,u).trim(),!s)||e.sCount[u]-e.blkIndent>=4)break;for(h=ja(s),h.length&&h[0]===""&&h.shift(),h.length&&h[h.length-1]===""&&h.pop(),u===t+2&&(p=e.push("tbody_open","tbody",1),p.map=v=[t+2,0]),p=e.push("tr_open","tr",1),p.map=[u,u+1],l=0;l<d;l++)p=e.push("td_open","td",1),f[l]&&(p.attrs=[["style","text-align:"+f[l]]]),p=e.push("inline","",0),p.content=h[l]?h[l].trim():"",p.children=[],p=e.push("td_close","td",-1);p=e.push("tr_close","tr",-1)}return v&&(p=e.push("tbody_close","tbody",-1),v[1]=u),p=e.push("table_close","table",-1),y[1]=u,e.parentType=b,e.line=u,!0}});var Ka=_((ov,Ga)=>{"use strict";Ga.exports=function(e,t,i){var r,o,s;if(e.sCount[t]-e.blkIndent<4)return!1;for(o=r=t+1;r<i;){if(e.isEmpty(r)){r++;continue}if(e.sCount[r]-e.blkIndent>=4){r++,o=r;continue}break}return e.line=o,s=e.push("code_block","code",0),s.content=e.getLines(t,o,4+e.blkIndent,!1)+`
+`,s.map=[t,e.line],!0}});var Xa=_((sv,Za)=>{"use strict";Za.exports=function(e,t,i,r){var o,s,a,l,c,u,h,d=!1,p=e.bMarks[t]+e.tShift[t],f=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||p+3>f||(o=e.src.charCodeAt(p),o!==126&&o!==96)||(c=p,p=e.skipChars(p,o),s=p-c,s<3)||(h=e.src.slice(c,p),a=e.src.slice(p,f),o===96&&a.indexOf(String.fromCharCode(o))>=0))return!1;if(r)return!0;for(l=t;l++,!(l>=i||(p=c=e.bMarks[l]+e.tShift[l],f=e.eMarks[l],p<f&&e.sCount[l]<e.blkIndent));)if(e.src.charCodeAt(p)===o&&!(e.sCount[l]-e.blkIndent>=4)&&(p=e.skipChars(p,o),!(p-c<s)&&(p=e.skipSpaces(p),!(p<f)))){d=!0;break}return s=e.sCount[t],e.line=l+(d?1:0),u=e.push("fence","code",0),u.info=a,u.content=e.getLines(t+1,l,s,!0),u.markup=h,u.map=[t,e.line],!0}});var Qa=_((av,Ja)=>{"use strict";var Ya=R().isSpace;Ja.exports=function(e,t,i,r){var o,s,a,l,c,u,h,d,p,f,m,y,v,b,k,w,E,x,S,D,q=e.lineMax,L=e.bMarks[t]+e.tShift[t],I=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||e.src.charCodeAt(L++)!==62)return!1;if(r)return!0;for(l=p=e.sCount[t]+1,e.src.charCodeAt(L)===32?(L++,l++,p++,o=!1,w=!0):e.src.charCodeAt(L)===9?(w=!0,(e.bsCount[t]+p)%4===3?(L++,l++,p++,o=!1):o=!0):w=!1,f=[e.bMarks[t]],e.bMarks[t]=L;L<I&&(s=e.src.charCodeAt(L),Ya(s));){s===9?p+=4-(p+e.bsCount[t]+(o?1:0))%4:p++;L++}for(m=[e.bsCount[t]],e.bsCount[t]=e.sCount[t]+1+(w?1:0),u=L>=I,b=[e.sCount[t]],e.sCount[t]=p-l,k=[e.tShift[t]],e.tShift[t]=L-e.bMarks[t],x=e.md.block.ruler.getRules("blockquote"),v=e.parentType,e.parentType="blockquote",d=t+1;d<i&&(D=e.sCount[d]<e.blkIndent,L=e.bMarks[d]+e.tShift[d],I=e.eMarks[d],!(L>=I));d++){if(e.src.charCodeAt(L++)===62&&!D){for(l=p=e.sCount[d]+1,e.src.charCodeAt(L)===32?(L++,l++,p++,o=!1,w=!0):e.src.charCodeAt(L)===9?(w=!0,(e.bsCount[d]+p)%4===3?(L++,l++,p++,o=!1):o=!0):w=!1,f.push(e.bMarks[d]),e.bMarks[d]=L;L<I&&(s=e.src.charCodeAt(L),Ya(s));){s===9?p+=4-(p+e.bsCount[d]+(o?1:0))%4:p++;L++}u=L>=I,m.push(e.bsCount[d]),e.bsCount[d]=e.sCount[d]+1+(w?1:0),b.push(e.sCount[d]),e.sCount[d]=p-l,k.push(e.tShift[d]),e.tShift[d]=L-e.bMarks[d];continue}if(u)break;for(E=!1,a=0,c=x.length;a<c;a++)if(x[a](e,d,i,!0)){E=!0;break}if(E){e.lineMax=d,e.blkIndent!==0&&(f.push(e.bMarks[d]),m.push(e.bsCount[d]),k.push(e.tShift[d]),b.push(e.sCount[d]),e.sCount[d]-=e.blkIndent);break}f.push(e.bMarks[d]),m.push(e.bsCount[d]),k.push(e.tShift[d]),b.push(e.sCount[d]),e.sCount[d]=-1}for(y=e.blkIndent,e.blkIndent=0,S=e.push("blockquote_open","blockquote",1),S.markup=">",S.map=h=[t,0],e.md.block.tokenize(e,t,d),S=e.push("blockquote_close","blockquote",-1),S.markup=">",e.lineMax=q,e.parentType=v,h[1]=e.line,a=0;a<k.length;a++)e.bMarks[a+t]=f[a],e.tShift[a+t]=k[a],e.sCount[a+t]=b[a],e.bsCount[a+t]=m[a];return e.blkIndent=y,!0}});var tl=_((lv,el)=>{"use strict";var qd=R().isSpace;el.exports=function(e,t,i,r){var o,s,a,l,c=e.bMarks[t]+e.tShift[t],u=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||(o=e.src.charCodeAt(c++),o!==42&&o!==45&&o!==95))return!1;for(s=1;c<u;){if(a=e.src.charCodeAt(c++),a!==o&&!qd(a))return!1;a===o&&s++}return s<3?!1:(r||(e.line=t+1,l=e.push("hr","hr",0),l.map=[t,e.line],l.markup=Array(s+1).join(String.fromCharCode(o))),!0)}});var sl=_((cv,ol)=>{"use strict";var rl=R().isSpace;function nl(n,e){var t,i,r,o;return i=n.bMarks[e]+n.tShift[e],r=n.eMarks[e],t=n.src.charCodeAt(i++),t!==42&&t!==45&&t!==43||i<r&&(o=n.src.charCodeAt(i),!rl(o))?-1:i}function il(n,e){var t,i=n.bMarks[e]+n.tShift[e],r=i,o=n.eMarks[e];if(r+1>=o||(t=n.src.charCodeAt(r++),t<48||t>57))return-1;for(;;){if(r>=o)return-1;if(t=n.src.charCodeAt(r++),t>=48&&t<=57){if(r-i>=10)return-1;continue}if(t===41||t===46)break;return-1}return r<o&&(t=n.src.charCodeAt(r),!rl(t))?-1:r}function Bd(n,e){var t,i,r=n.level+2;for(t=e+2,i=n.tokens.length-2;t<i;t++)n.tokens[t].level===r&&n.tokens[t].type==="paragraph_open"&&(n.tokens[t+2].hidden=!0,n.tokens[t].hidden=!0,t+=2)}ol.exports=function(e,t,i,r){var o,s,a,l,c,u,h,d,p,f,m,y,v,b,k,w,E,x,S,D,q,L,I,H,N,ee,ge,V,Oe=!1,Re=!0;if(e.sCount[t]-e.blkIndent>=4||e.listIndent>=0&&e.sCount[t]-e.listIndent>=4&&e.sCount[t]<e.blkIndent)return!1;if(r&&e.parentType==="paragraph"&&e.sCount[t]>=e.blkIndent&&(Oe=!0),(I=il(e,t))>=0){if(h=!0,N=e.bMarks[t]+e.tShift[t],v=Number(e.src.slice(N,I-1)),Oe&&v!==1)return!1}else if((I=nl(e,t))>=0)h=!1;else return!1;if(Oe&&e.skipSpaces(I)>=e.eMarks[t])return!1;if(y=e.src.charCodeAt(I-1),r)return!0;for(m=e.tokens.length,h?(V=e.push("ordered_list_open","ol",1),v!==1&&(V.attrs=[["start",v]])):V=e.push("bullet_list_open","ul",1),V.map=f=[t,0],V.markup=String.fromCharCode(y),k=t,H=!1,ge=e.md.block.ruler.getRules("list"),x=e.parentType,e.parentType="list";k<i;){for(L=I,b=e.eMarks[k],u=w=e.sCount[k]+I-(e.bMarks[t]+e.tShift[t]);L<b;){if(o=e.src.charCodeAt(L),o===9)w+=4-(w+e.bsCount[k])%4;else if(o===32)w++;else break;L++}if(s=L,s>=b?c=1:c=w-u,c>4&&(c=1),l=u+c,V=e.push("list_item_open","li",1),V.markup=String.fromCharCode(y),V.map=d=[t,0],h&&(V.info=e.src.slice(N,I-1)),q=e.tight,D=e.tShift[t],S=e.sCount[t],E=e.listIndent,e.listIndent=e.blkIndent,e.blkIndent=l,e.tight=!0,e.tShift[t]=s-e.bMarks[t],e.sCount[t]=w,s>=b&&e.isEmpty(t+1)?e.line=Math.min(e.line+2,i):e.md.block.tokenize(e,t,i,!0),(!e.tight||H)&&(Re=!1),H=e.line-t>1&&e.isEmpty(e.line-1),e.blkIndent=e.listIndent,e.listIndent=E,e.tShift[t]=D,e.sCount[t]=S,e.tight=q,V=e.push("list_item_close","li",-1),V.markup=String.fromCharCode(y),k=t=e.line,d[1]=k,s=e.bMarks[t],k>=i||e.sCount[k]<e.blkIndent||e.sCount[t]-e.blkIndent>=4)break;for(ee=!1,a=0,p=ge.length;a<p;a++)if(ge[a](e,k,i,!0)){ee=!0;break}if(ee)break;if(h){if(I=il(e,k),I<0)break;N=e.bMarks[k]+e.tShift[k]}else if(I=nl(e,k),I<0)break;if(y!==e.src.charCodeAt(I-1))break}return h?V=e.push("ordered_list_close","ol",-1):V=e.push("bullet_list_close","ul",-1),V.markup=String.fromCharCode(y),f[1]=k,e.line=k,e.parentType=x,Re&&Bd(e,m),!0}});var ll=_((uv,al)=>{"use strict";var Pd=R().normalizeReference,pi=R().isSpace;al.exports=function(e,t,i,r){var o,s,a,l,c,u,h,d,p,f,m,y,v,b,k,w,E=0,x=e.bMarks[t]+e.tShift[t],S=e.eMarks[t],D=t+1;if(e.sCount[t]-e.blkIndent>=4||e.src.charCodeAt(x)!==91)return!1;for(;++x<S;)if(e.src.charCodeAt(x)===93&&e.src.charCodeAt(x-1)!==92){if(x+1===S||e.src.charCodeAt(x+1)!==58)return!1;break}for(l=e.lineMax,k=e.md.block.ruler.getRules("reference"),f=e.parentType,e.parentType="reference";D<l&&!e.isEmpty(D);D++)if(!(e.sCount[D]-e.blkIndent>3)&&!(e.sCount[D]<0)){for(b=!1,u=0,h=k.length;u<h;u++)if(k[u](e,D,l,!0)){b=!0;break}if(b)break}for(v=e.getLines(t,D,e.blkIndent,!1).trim(),S=v.length,x=1;x<S;x++){if(o=v.charCodeAt(x),o===91)return!1;if(o===93){p=x;break}else o===10?E++:o===92&&(x++,x<S&&v.charCodeAt(x)===10&&E++)}if(p<0||v.charCodeAt(p+1)!==58)return!1;for(x=p+2;x<S;x++)if(o=v.charCodeAt(x),o===10)E++;else if(!pi(o))break;if(m=e.md.helpers.parseLinkDestination(v,x,S),!m.ok||(c=e.md.normalizeLink(m.str),!e.md.validateLink(c)))return!1;for(x=m.pos,E+=m.lines,s=x,a=E,y=x;x<S;x++)if(o=v.charCodeAt(x),o===10)E++;else if(!pi(o))break;for(m=e.md.helpers.parseLinkTitle(v,x,S),x<S&&y!==x&&m.ok?(w=m.str,x=m.pos,E+=m.lines):(w="",x=s,E=a);x<S&&(o=v.charCodeAt(x),!!pi(o));)x++;if(x<S&&v.charCodeAt(x)!==10&&w)for(w="",x=s,E=a;x<S&&(o=v.charCodeAt(x),!!pi(o));)x++;return x<S&&v.charCodeAt(x)!==10||(d=Pd(v.slice(1,p)),!d)?!1:(r||(typeof e.env.references>"u"&&(e.env.references={}),typeof e.env.references[d]>"u"&&(e.env.references[d]={title:w,href:c}),e.parentType=f,e.line=t+E+1),!0)}});var ul=_((hv,cl)=>{"use strict";cl.exports=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","section","source","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"]});var no=_((dv,to)=>{"use strict";var Od="[a-zA-Z_:][a-zA-Z0-9:._-]*",Rd="[^\"'=<>`\\x00-\\x20]+",Nd="'[^']*'",zd='"[^"]*"',Hd="(?:"+Rd+"|"+Nd+"|"+zd+")",Ud="(?:\\s+"+Od+"(?:\\s*=\\s*"+Hd+")?)",hl="<[A-Za-z][A-Za-z0-9\\-]*"+Ud+"*\\s*\\/?>",dl="<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>",jd="<!---->|<!--(?:-?[^>-])(?:-?[^-])*-->",Vd="<[?][\\s\\S]*?[?]>",Wd="<![A-Z]+\\s+[^>]*>",Gd="<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",Kd=new RegExp("^(?:"+hl+"|"+dl+"|"+jd+"|"+Vd+"|"+Wd+"|"+Gd+")"),Zd=new RegExp("^(?:"+hl+"|"+dl+")");to.exports.HTML_TAG_RE=Kd;to.exports.HTML_OPEN_CLOSE_TAG_RE=Zd});var fl=_((pv,pl)=>{"use strict";var Xd=ul(),Yd=no().HTML_OPEN_CLOSE_TAG_RE,wt=[[/^<(script|pre|style|textarea)(?=(\s|>|$))/i,/<\/(script|pre|style|textarea)>/i,!0],[/^<!--/,/-->/,!0],[/^<\?/,/\?>/,!0],[/^<![A-Z]/,/>/,!0],[/^<!\[CDATA\[/,/\]\]>/,!0],[new RegExp("^</?("+Xd.join("|")+")(?=(\\s|/?>|$))","i"),/^$/,!0],[new RegExp(Yd.source+"\\s*$"),/^$/,!1]];pl.exports=function(e,t,i,r){var o,s,a,l,c=e.bMarks[t]+e.tShift[t],u=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||!e.md.options.html||e.src.charCodeAt(c)!==60)return!1;for(l=e.src.slice(c,u),o=0;o<wt.length&&!wt[o][0].test(l);o++);if(o===wt.length)return!1;if(r)return wt[o][2];if(s=t+1,!wt[o][1].test(l)){for(;s<i&&!(e.sCount[s]<e.blkIndent);s++)if(c=e.bMarks[s]+e.tShift[s],u=e.eMarks[s],l=e.src.slice(c,u),wt[o][1].test(l)){l.length!==0&&s++;break}}return e.line=s,a=e.push("html_block","",0),a.map=[t,s],a.content=e.getLines(t,s,e.blkIndent,!0),!0}});var bl=_((fv,gl)=>{"use strict";var ml=R().isSpace;gl.exports=function(e,t,i,r){var o,s,a,l,c=e.bMarks[t]+e.tShift[t],u=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||(o=e.src.charCodeAt(c),o!==35||c>=u))return!1;for(s=1,o=e.src.charCodeAt(++c);o===35&&c<u&&s<=6;)s++,o=e.src.charCodeAt(++c);return s>6||c<u&&!ml(o)?!1:(r||(u=e.skipSpacesBack(u,c),a=e.skipCharsBack(u,35,c),a>c&&ml(e.src.charCodeAt(a-1))&&(u=a),e.line=t+1,l=e.push("heading_open","h"+String(s),1),l.markup="########".slice(0,s),l.map=[t,e.line],l=e.push("inline","",0),l.content=e.src.slice(c,u).trim(),l.map=[t,e.line],l.children=[],l=e.push("heading_close","h"+String(s),-1),l.markup="########".slice(0,s)),!0)}});var wl=_((mv,vl)=>{"use strict";vl.exports=function(e,t,i){var r,o,s,a,l,c,u,h,d,p=t+1,f,m=e.md.block.ruler.getRules("paragraph");if(e.sCount[t]-e.blkIndent>=4)return!1;for(f=e.parentType,e.parentType="paragraph";p<i&&!e.isEmpty(p);p++)if(!(e.sCount[p]-e.blkIndent>3)){if(e.sCount[p]>=e.blkIndent&&(c=e.bMarks[p]+e.tShift[p],u=e.eMarks[p],c<u&&(d=e.src.charCodeAt(c),(d===45||d===61)&&(c=e.skipChars(c,d),c=e.skipSpaces(c),c>=u)))){h=d===61?1:2;break}if(!(e.sCount[p]<0)){for(o=!1,s=0,a=m.length;s<a;s++)if(m[s](e,p,i,!0)){o=!0;break}if(o)break}}return h?(r=e.getLines(t,p,e.blkIndent,!1).trim(),e.line=p+1,l=e.push("heading_open","h"+String(h),1),l.markup=String.fromCharCode(d),l.map=[t,e.line],l=e.push("inline","",0),l.content=r,l.map=[t,e.line-1],l.children=[],l=e.push("heading_close","h"+String(h),-1),l.markup=String.fromCharCode(d),e.parentType=f,!0):!1}});var xl=_((gv,yl)=>{"use strict";yl.exports=function(e,t){var i,r,o,s,a,l,c=t+1,u=e.md.block.ruler.getRules("paragraph"),h=e.lineMax;for(l=e.parentType,e.parentType="paragraph";c<h&&!e.isEmpty(c);c++)if(!(e.sCount[c]-e.blkIndent>3)&&!(e.sCount[c]<0)){for(r=!1,o=0,s=u.length;o<s;o++)if(u[o](e,c,h,!0)){r=!0;break}if(r)break}return i=e.getLines(t,c,e.blkIndent,!1).trim(),e.line=c,a=e.push("paragraph_open","p",1),a.map=[t,e.line],a=e.push("inline","",0),a.content=i,a.map=[t,e.line],a.children=[],a=e.push("paragraph_close","p",-1),e.parentType=l,!0}});var El=_((bv,Cl)=>{"use strict";var kl=di(),fi=R().isSpace;function Te(n,e,t,i){var r,o,s,a,l,c,u,h;for(this.src=n,this.md=e,this.env=t,this.tokens=i,this.bMarks=[],this.eMarks=[],this.tShift=[],this.sCount=[],this.bsCount=[],this.blkIndent=0,this.line=0,this.lineMax=0,this.tight=!1,this.ddIndent=-1,this.listIndent=-1,this.parentType="root",this.level=0,this.result="",o=this.src,h=!1,s=a=c=u=0,l=o.length;a<l;a++){if(r=o.charCodeAt(a),!h)if(fi(r)){c++,r===9?u+=4-u%4:u++;continue}else h=!0;(r===10||a===l-1)&&(r!==10&&a++,this.bMarks.push(s),this.eMarks.push(a),this.tShift.push(c),this.sCount.push(u),this.bsCount.push(0),h=!1,c=0,u=0,s=a+1)}this.bMarks.push(o.length),this.eMarks.push(o.length),this.tShift.push(0),this.sCount.push(0),this.bsCount.push(0),this.lineMax=this.bMarks.length-1}Te.prototype.push=function(n,e,t){var i=new kl(n,e,t);return i.block=!0,t<0&&this.level--,i.level=this.level,t>0&&this.level++,this.tokens.push(i),i};Te.prototype.isEmpty=function(e){return this.bMarks[e]+this.tShift[e]>=this.eMarks[e]};Te.prototype.skipEmptyLines=function(e){for(var t=this.lineMax;e<t&&!(this.bMarks[e]+this.tShift[e]<this.eMarks[e]);e++);return e};Te.prototype.skipSpaces=function(e){for(var t,i=this.src.length;e<i&&(t=this.src.charCodeAt(e),!!fi(t));e++);return e};Te.prototype.skipSpacesBack=function(e,t){if(e<=t)return e;for(;e>t;)if(!fi(this.src.charCodeAt(--e)))return e+1;return e};Te.prototype.skipChars=function(e,t){for(var i=this.src.length;e<i&&this.src.charCodeAt(e)===t;e++);return e};Te.prototype.skipCharsBack=function(e,t,i){if(e<=i)return e;for(;e>i;)if(t!==this.src.charCodeAt(--e))return e+1;return e};Te.prototype.getLines=function(e,t,i,r){var o,s,a,l,c,u,h,d=e;if(e>=t)return"";for(u=new Array(t-e),o=0;d<t;d++,o++){for(s=0,h=l=this.bMarks[d],d+1<t||r?c=this.eMarks[d]+1:c=this.eMarks[d];l<c&&s<i;){if(a=this.src.charCodeAt(l),fi(a))a===9?s+=4-(s+this.bsCount[d])%4:s++;else if(l-h<this.tShift[d])s++;else break;l++}s>i?u[o]=new Array(s-i+1).join(" ")+this.src.slice(l,c):u[o]=this.src.slice(l,c)}return u.join("")};Te.prototype.Token=kl;Cl.exports=Te});var Sl=_((vv,_l)=>{"use strict";var Jd=ui(),mi=[["table",Wa(),["paragraph","reference"]],["code",Ka()],["fence",Xa(),["paragraph","reference","blockquote","list"]],["blockquote",Qa(),["paragraph","reference","blockquote","list"]],["hr",tl(),["paragraph","reference","blockquote","list"]],["list",sl(),["paragraph","reference","blockquote"]],["reference",ll()],["html_block",fl(),["paragraph","reference","blockquote"]],["heading",bl(),["paragraph","reference","blockquote"]],["lheading",wl()],["paragraph",xl()]];function gi(){this.ruler=new Jd;for(var n=0;n<mi.length;n++)this.ruler.push(mi[n][0],mi[n][1],{alt:(mi[n][2]||[]).slice()})}gi.prototype.tokenize=function(n,e,t){for(var i,r,o=this.ruler.getRules(""),s=o.length,a=e,l=!1,c=n.md.options.maxNesting;a<t&&(n.line=a=n.skipEmptyLines(a),!(a>=t||n.sCount[a]<n.blkIndent));){if(n.level>=c){n.line=t;break}for(r=0;r<s&&(i=o[r](n,a,t,!1),!i);r++);n.tight=!l,n.isEmpty(n.line-1)&&(l=!0),a=n.line,a<t&&n.isEmpty(a)&&(l=!0,a++,n.line=a)}};gi.prototype.parse=function(n,e,t,i){var r;n&&(r=new this.State(n,e,t,i),this.tokenize(r,r.line,r.lineMax))};gi.prototype.State=El();_l.exports=gi});var Dl=_((wv,Al)=>{"use strict";function Qd(n){switch(n){case 10:case 33:case 35:case 36:case 37:case 38:case 42:case 43:case 45:case 58:case 60:case 61:case 62:case 64:case 91:case 92:case 93:case 94:case 95:case 96:case 123:case 125:case 126:return!0;default:return!1}}Al.exports=function(e,t){for(var i=e.pos;i<e.posMax&&!Qd(e.src.charCodeAt(i));)i++;return i===e.pos?!1:(t||(e.pending+=e.src.slice(e.pos,i)),e.pos=i,!0)}});var Ll=_((yv,Tl)=>{"use strict";var ep=/(?:^|[^a-z0-9.+-])([a-z][a-z0-9.+-]*)$/i;Tl.exports=function(e,t){var i,r,o,s,a,l,c,u;return!e.md.options.linkify||e.linkLevel>0||(i=e.pos,r=e.posMax,i+3>r)||e.src.charCodeAt(i)!==58||e.src.charCodeAt(i+1)!==47||e.src.charCodeAt(i+2)!==47||(o=e.pending.match(ep),!o)||(s=o[1],a=e.md.linkify.matchAtStart(e.src.slice(i-s.length)),!a)||(l=a.url,l=l.replace(/\*+$/,""),c=e.md.normalizeLink(l),!e.md.validateLink(c))?!1:(t||(e.pending=e.pending.slice(0,-s.length),u=e.push("link_open","a",1),u.attrs=[["href",c]],u.markup="linkify",u.info="auto",u=e.push("text","",0),u.content=e.md.normalizeLinkText(l),u=e.push("link_close","a",-1),u.markup="linkify",u.info="auto"),e.pos+=l.length-s.length,!0)}});var $l=_((xv,Il)=>{"use strict";var tp=R().isSpace;Il.exports=function(e,t){var i,r,o,s=e.pos;if(e.src.charCodeAt(s)!==10)return!1;if(i=e.pending.length-1,r=e.posMax,!t)if(i>=0&&e.pending.charCodeAt(i)===32)if(i>=1&&e.pending.charCodeAt(i-1)===32){for(o=i-1;o>=1&&e.pending.charCodeAt(o-1)===32;)o--;e.pending=e.pending.slice(0,o),e.push("hardbreak","br",0)}else e.pending=e.pending.slice(0,-1),e.push("softbreak","br",0);else e.push("softbreak","br",0);for(s++;s<r&&tp(e.src.charCodeAt(s));)s++;return e.pos=s,!0}});var Fl=_((kv,Ml)=>{"use strict";var np=R().isSpace,ro=[];for(io=0;io<256;io++)ro.push(0);var io;"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach(function(n){ro[n.charCodeAt(0)]=1});Ml.exports=function(e,t){var i,r,o,s,a,l=e.pos,c=e.posMax;if(e.src.charCodeAt(l)!==92||(l++,l>=c))return!1;if(i=e.src.charCodeAt(l),i===10){for(t||e.push("hardbreak","br",0),l++;l<c&&(i=e.src.charCodeAt(l),!!np(i));)l++;return e.pos=l,!0}return s=e.src[l],i>=55296&&i<=56319&&l+1<c&&(r=e.src.charCodeAt(l+1),r>=56320&&r<=57343&&(s+=e.src[l+1],l++)),o="\\"+s,t||(a=e.push("text_special","",0),i<256&&ro[i]!==0?a.content=s:a.content=o,a.markup=o,a.info="escape"),e.pos=l+1,!0}});var Bl=_((Cv,ql)=>{"use strict";ql.exports=function(e,t){var i,r,o,s,a,l,c,u,h=e.pos,d=e.src.charCodeAt(h);if(d!==96)return!1;for(i=h,h++,r=e.posMax;h<r&&e.src.charCodeAt(h)===96;)h++;if(o=e.src.slice(i,h),c=o.length,e.backticksScanned&&(e.backticks[c]||0)<=i)return t||(e.pending+=o),e.pos+=c,!0;for(a=l=h;(a=e.src.indexOf("`",l))!==-1;){for(l=a+1;l<r&&e.src.charCodeAt(l)===96;)l++;if(u=l-a,u===c)return t||(s=e.push("code_inline","code",0),s.markup=o,s.content=e.src.slice(h,a).replace(/\n/g," ").replace(/^ (.+) $/,"$1")),e.pos=l,!0;e.backticks[u]=a}return e.backticksScanned=!0,t||(e.pending+=o),e.pos+=c,!0}});var so=_((Ev,oo)=>{"use strict";oo.exports.tokenize=function(e,t){var i,r,o,s,a,l=e.pos,c=e.src.charCodeAt(l);if(t||c!==126||(r=e.scanDelims(e.pos,!0),s=r.length,a=String.fromCharCode(c),s<2))return!1;for(s%2&&(o=e.push("text","",0),o.content=a,s--),i=0;i<s;i+=2)o=e.push("text","",0),o.content=a+a,e.delimiters.push({marker:c,length:0,token:e.tokens.length-1,end:-1,open:r.can_open,close:r.can_close});return e.pos+=r.length,!0};function Pl(n,e){var t,i,r,o,s,a=[],l=e.length;for(t=0;t<l;t++)r=e[t],r.marker===126&&r.end!==-1&&(o=e[r.end],s=n.tokens[r.token],s.type="s_open",s.tag="s",s.nesting=1,s.markup="~~",s.content="",s=n.tokens[o.token],s.type="s_close",s.tag="s",s.nesting=-1,s.markup="~~",s.content="",n.tokens[o.token-1].type==="text"&&n.tokens[o.token-1].content==="~"&&a.push(o.token-1));for(;a.length;){for(t=a.pop(),i=t+1;i<n.tokens.length&&n.tokens[i].type==="s_close";)i++;i--,t!==i&&(s=n.tokens[i],n.tokens[i]=n.tokens[t],n.tokens[t]=s)}}oo.exports.postProcess=function(e){var t,i=e.tokens_meta,r=e.tokens_meta.length;for(Pl(e,e.delimiters),t=0;t<r;t++)i[t]&&i[t].delimiters&&Pl(e,i[t].delimiters)}});var lo=_((_v,ao)=>{"use strict";ao.exports.tokenize=function(e,t){var i,r,o,s=e.pos,a=e.src.charCodeAt(s);if(t||a!==95&&a!==42)return!1;for(r=e.scanDelims(e.pos,a===42),i=0;i<r.length;i++)o=e.push("text","",0),o.content=String.fromCharCode(a),e.delimiters.push({marker:a,length:r.length,token:e.tokens.length-1,end:-1,open:r.can_open,close:r.can_close});return e.pos+=r.length,!0};function Ol(n,e){var t,i,r,o,s,a,l=e.length;for(t=l-1;t>=0;t--)i=e[t],!(i.marker!==95&&i.marker!==42)&&i.end!==-1&&(r=e[i.end],a=t>0&&e[t-1].end===i.end+1&&e[t-1].marker===i.marker&&e[t-1].token===i.token-1&&e[i.end+1].token===r.token+1,s=String.fromCharCode(i.marker),o=n.tokens[i.token],o.type=a?"strong_open":"em_open",o.tag=a?"strong":"em",o.nesting=1,o.markup=a?s+s:s,o.content="",o=n.tokens[r.token],o.type=a?"strong_close":"em_close",o.tag=a?"strong":"em",o.nesting=-1,o.markup=a?s+s:s,o.content="",a&&(n.tokens[e[t-1].token].content="",n.tokens[e[i.end+1].token].content="",t--))}ao.exports.postProcess=function(e){var t,i=e.tokens_meta,r=e.tokens_meta.length;for(Ol(e,e.delimiters),t=0;t<r;t++)i[t]&&i[t].delimiters&&Ol(e,i[t].delimiters)}});var Nl=_((Sv,Rl)=>{"use strict";var ip=R().normalizeReference,co=R().isSpace;Rl.exports=function(e,t){var i,r,o,s,a,l,c,u,h,d="",p="",f=e.pos,m=e.posMax,y=e.pos,v=!0;if(e.src.charCodeAt(e.pos)!==91||(a=e.pos+1,s=e.md.helpers.parseLinkLabel(e,e.pos,!0),s<0))return!1;if(l=s+1,l<m&&e.src.charCodeAt(l)===40){for(v=!1,l++;l<m&&(r=e.src.charCodeAt(l),!(!co(r)&&r!==10));l++);if(l>=m)return!1;if(y=l,c=e.md.helpers.parseLinkDestination(e.src,l,e.posMax),c.ok){for(d=e.md.normalizeLink(c.str),e.md.validateLink(d)?l=c.pos:d="",y=l;l<m&&(r=e.src.charCodeAt(l),!(!co(r)&&r!==10));l++);if(c=e.md.helpers.parseLinkTitle(e.src,l,e.posMax),l<m&&y!==l&&c.ok)for(p=c.str,l=c.pos;l<m&&(r=e.src.charCodeAt(l),!(!co(r)&&r!==10));l++);}(l>=m||e.src.charCodeAt(l)!==41)&&(v=!0),l++}if(v){if(typeof e.env.references>"u")return!1;if(l<m&&e.src.charCodeAt(l)===91?(y=l+1,l=e.md.helpers.parseLinkLabel(e,l),l>=0?o=e.src.slice(y,l++):l=s+1):l=s+1,o||(o=e.src.slice(a,s)),u=e.env.references[ip(o)],!u)return e.pos=f,!1;d=u.href,p=u.title}return t||(e.pos=a,e.posMax=s,h=e.push("link_open","a",1),h.attrs=i=[["href",d]],p&&i.push(["title",p]),e.linkLevel++,e.md.inline.tokenize(e),e.linkLevel--,h=e.push("link_close","a",-1)),e.pos=l,e.posMax=m,!0}});var Hl=_((Av,zl)=>{"use strict";var rp=R().normalizeReference,uo=R().isSpace;zl.exports=function(e,t){var i,r,o,s,a,l,c,u,h,d,p,f,m,y="",v=e.pos,b=e.posMax;if(e.src.charCodeAt(e.pos)!==33||e.src.charCodeAt(e.pos+1)!==91||(l=e.pos+2,a=e.md.helpers.parseLinkLabel(e,e.pos+1,!1),a<0))return!1;if(c=a+1,c<b&&e.src.charCodeAt(c)===40){for(c++;c<b&&(r=e.src.charCodeAt(c),!(!uo(r)&&r!==10));c++);if(c>=b)return!1;for(m=c,h=e.md.helpers.parseLinkDestination(e.src,c,e.posMax),h.ok&&(y=e.md.normalizeLink(h.str),e.md.validateLink(y)?c=h.pos:y=""),m=c;c<b&&(r=e.src.charCodeAt(c),!(!uo(r)&&r!==10));c++);if(h=e.md.helpers.parseLinkTitle(e.src,c,e.posMax),c<b&&m!==c&&h.ok)for(d=h.str,c=h.pos;c<b&&(r=e.src.charCodeAt(c),!(!uo(r)&&r!==10));c++);else d="";if(c>=b||e.src.charCodeAt(c)!==41)return e.pos=v,!1;c++}else{if(typeof e.env.references>"u")return!1;if(c<b&&e.src.charCodeAt(c)===91?(m=c+1,c=e.md.helpers.parseLinkLabel(e,c),c>=0?s=e.src.slice(m,c++):c=a+1):c=a+1,s||(s=e.src.slice(l,a)),u=e.env.references[rp(s)],!u)return e.pos=v,!1;y=u.href,d=u.title}return t||(o=e.src.slice(l,a),e.md.inline.parse(o,e.md,e.env,f=[]),p=e.push("image","img",0),p.attrs=i=[["src",y],["alt",""]],p.children=f,p.content=o,d&&i.push(["title",d])),e.pos=c,e.posMax=b,!0}});var jl=_((Dv,Ul)=>{"use strict";var op=/^([a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)$/,sp=/^([a-zA-Z][a-zA-Z0-9+.\-]{1,31}):([^<>\x00-\x20]*)$/;Ul.exports=function(e,t){var i,r,o,s,a,l,c=e.pos;if(e.src.charCodeAt(c)!==60)return!1;for(a=e.pos,l=e.posMax;;){if(++c>=l||(s=e.src.charCodeAt(c),s===60))return!1;if(s===62)break}return i=e.src.slice(a+1,c),sp.test(i)?(r=e.md.normalizeLink(i),e.md.validateLink(r)?(t||(o=e.push("link_open","a",1),o.attrs=[["href",r]],o.markup="autolink",o.info="auto",o=e.push("text","",0),o.content=e.md.normalizeLinkText(i),o=e.push("link_close","a",-1),o.markup="autolink",o.info="auto"),e.pos+=i.length+2,!0):!1):op.test(i)?(r=e.md.normalizeLink("mailto:"+i),e.md.validateLink(r)?(t||(o=e.push("link_open","a",1),o.attrs=[["href",r]],o.markup="autolink",o.info="auto",o=e.push("text","",0),o.content=e.md.normalizeLinkText(i),o=e.push("link_close","a",-1),o.markup="autolink",o.info="auto"),e.pos+=i.length+2,!0):!1):!1}});var Wl=_((Tv,Vl)=>{"use strict";var ap=no().HTML_TAG_RE;function lp(n){return/^<a[>\s]/i.test(n)}function cp(n){return/^<\/a\s*>/i.test(n)}function up(n){var e=n|32;return e>=97&&e<=122}Vl.exports=function(e,t){var i,r,o,s,a=e.pos;return!e.md.options.html||(o=e.posMax,e.src.charCodeAt(a)!==60||a+2>=o)||(i=e.src.charCodeAt(a+1),i!==33&&i!==63&&i!==47&&!up(i))||(r=e.src.slice(a).match(ap),!r)?!1:(t||(s=e.push("html_inline","",0),s.content=e.src.slice(a,a+r[0].length),lp(s.content)&&e.linkLevel++,cp(s.content)&&e.linkLevel--),e.pos+=r[0].length,!0)}});var Xl=_((Lv,Zl)=>{"use strict";var Gl=Wr(),hp=R().has,dp=R().isValidEntityCode,Kl=R().fromCodePoint,pp=/^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i,fp=/^&([a-z][a-z0-9]{1,31});/i;Zl.exports=function(e,t){var i,r,o,s,a=e.pos,l=e.posMax;if(e.src.charCodeAt(a)!==38||a+1>=l)return!1;if(i=e.src.charCodeAt(a+1),i===35){if(o=e.src.slice(a).match(pp),o)return t||(r=o[1][0].toLowerCase()==="x"?parseInt(o[1].slice(1),16):parseInt(o[1],10),s=e.push("text_special","",0),s.content=dp(r)?Kl(r):Kl(65533),s.markup=o[0],s.info="entity"),e.pos+=o[0].length,!0}else if(o=e.src.slice(a).match(fp),o&&hp(Gl,o[1]))return t||(s=e.push("text_special","",0),s.content=Gl[o[1]],s.markup=o[0],s.info="entity"),e.pos+=o[0].length,!0;return!1}});var Ql=_((Iv,Jl)=>{"use strict";function Yl(n,e){var t,i,r,o,s,a,l,c,u={},h=e.length;if(h){var d=0,p=-2,f=[];for(t=0;t<h;t++)if(r=e[t],f.push(0),(e[d].marker!==r.marker||p!==r.token-1)&&(d=t),p=r.token,r.length=r.length||0,!!r.close){for(u.hasOwnProperty(r.marker)||(u[r.marker]=[-1,-1,-1,-1,-1,-1]),s=u[r.marker][(r.open?3:0)+r.length%3],i=d-f[d]-1,a=i;i>s;i-=f[i]+1)if(o=e[i],o.marker===r.marker&&o.open&&o.end<0&&(l=!1,(o.close||r.open)&&(o.length+r.length)%3===0&&(o.length%3!==0||r.length%3!==0)&&(l=!0),!l)){c=i>0&&!e[i-1].open?f[i-1]+1:0,f[t]=t-i+c,f[i]=c,r.open=!1,o.end=t,o.close=!1,a=-1,p=-2;break}a!==-1&&(u[r.marker][(r.open?3:0)+(r.length||0)%3]=a)}}}Jl.exports=function(e){var t,i=e.tokens_meta,r=e.tokens_meta.length;for(Yl(e,e.delimiters),t=0;t<r;t++)i[t]&&i[t].delimiters&&Yl(e,i[t].delimiters)}});var tc=_(($v,ec)=>{"use strict";ec.exports=function(e){var t,i,r=0,o=e.tokens,s=e.tokens.length;for(t=i=0;t<s;t++)o[t].nesting<0&&r--,o[t].level=r,o[t].nesting>0&&r++,o[t].type==="text"&&t+1<s&&o[t+1].type==="text"?o[t+1].content=o[t].content+o[t+1].content:(t!==i&&(o[i]=o[t]),i++);t!==i&&(o.length=i)}});var sc=_((Mv,oc)=>{"use strict";var ho=di(),nc=R().isWhiteSpace,ic=R().isPunctChar,rc=R().isMdAsciiPunct;function Zt(n,e,t,i){this.src=n,this.env=t,this.md=e,this.tokens=i,this.tokens_meta=Array(i.length),this.pos=0,this.posMax=this.src.length,this.level=0,this.pending="",this.pendingLevel=0,this.cache={},this.delimiters=[],this._prev_delimiters=[],this.backticks={},this.backticksScanned=!1,this.linkLevel=0}Zt.prototype.pushPending=function(){var n=new ho("text","",0);return n.content=this.pending,n.level=this.pendingLevel,this.tokens.push(n),this.pending="",n};Zt.prototype.push=function(n,e,t){this.pending&&this.pushPending();var i=new ho(n,e,t),r=null;return t<0&&(this.level--,this.delimiters=this._prev_delimiters.pop()),i.level=this.level,t>0&&(this.level++,this._prev_delimiters.push(this.delimiters),this.delimiters=[],r={delimiters:this.delimiters}),this.pendingLevel=this.level,this.tokens.push(i),this.tokens_meta.push(r),i};Zt.prototype.scanDelims=function(n,e){var t=n,i,r,o,s,a,l,c,u,h,d=!0,p=!0,f=this.posMax,m=this.src.charCodeAt(n);for(i=n>0?this.src.charCodeAt(n-1):32;t<f&&this.src.charCodeAt(t)===m;)t++;return o=t-n,r=t<f?this.src.charCodeAt(t):32,c=rc(i)||ic(String.fromCharCode(i)),h=rc(r)||ic(String.fromCharCode(r)),l=nc(i),u=nc(r),u?d=!1:h&&(l||c||(d=!1)),l?p=!1:c&&(u||h||(p=!1)),e?(s=d,a=p):(s=d&&(!p||c),a=p&&(!d||h)),{can_open:s,can_close:a,length:o}};Zt.prototype.Token=ho;oc.exports=Zt});var cc=_((Fv,lc)=>{"use strict";var ac=ui(),po=[["text",Dl()],["linkify",Ll()],["newline",$l()],["escape",Fl()],["backticks",Bl()],["strikethrough",so().tokenize],["emphasis",lo().tokenize],["link",Nl()],["image",Hl()],["autolink",jl()],["html_inline",Wl()],["entity",Xl()]],fo=[["balance_pairs",Ql()],["strikethrough",so().postProcess],["emphasis",lo().postProcess],["fragments_join",tc()]];function Xt(){var n;for(this.ruler=new ac,n=0;n<po.length;n++)this.ruler.push(po[n][0],po[n][1]);for(this.ruler2=new ac,n=0;n<fo.length;n++)this.ruler2.push(fo[n][0],fo[n][1])}Xt.prototype.skipToken=function(n){var e,t,i=n.pos,r=this.ruler.getRules(""),o=r.length,s=n.md.options.maxNesting,a=n.cache;if(typeof a[i]<"u"){n.pos=a[i];return}if(n.level<s)for(t=0;t<o&&(n.level++,e=r[t](n,!0),n.level--,!e);t++);else n.pos=n.posMax;e||n.pos++,a[i]=n.pos};Xt.prototype.tokenize=function(n){for(var e,t,i=this.ruler.getRules(""),r=i.length,o=n.posMax,s=n.md.options.maxNesting;n.pos<o;){if(n.level<s)for(t=0;t<r&&(e=i[t](n,!1),!e);t++);if(e){if(n.pos>=o)break;continue}n.pending+=n.src[n.pos++]}n.pending&&n.pushPending()};Xt.prototype.parse=function(n,e,t,i){var r,o,s,a=new this.State(n,e,t,i);for(this.tokenize(a),o=this.ruler2.getRules(""),s=o.length,r=0;r<s;r++)o[r](a)};Xt.prototype.State=sc();lc.exports=Xt});var hc=_((qv,uc)=>{"use strict";uc.exports=function(n){var e={};n=n||{},e.src_Any=Kr().source,e.src_Cc=Zr().source,e.src_Z=Xr().source,e.src_P=oi().source,e.src_ZPCc=[e.src_Z,e.src_P,e.src_Cc].join("|"),e.src_ZCc=[e.src_Z,e.src_Cc].join("|");var t="[><\uFF5C]";return e.src_pseudo_letter="(?:(?!"+t+"|"+e.src_ZPCc+")"+e.src_Any+")",e.src_ip4="(?:(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)",e.src_auth="(?:(?:(?!"+e.src_ZCc+"|[@/\\[\\]()]).)+@)?",e.src_port="(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?",e.src_host_terminator="(?=$|"+t+"|"+e.src_ZPCc+")(?!"+(n["---"]?"-(?!--)|":"-|")+"_|:\\d|\\.-|\\.(?!$|"+e.src_ZPCc+"))",e.src_path="(?:[/?#](?:(?!"+e.src_ZCc+"|"+t+`|[()[\\]{}.,"'?!\\-;]).|\\[(?:(?!`+e.src_ZCc+"|\\]).)*\\]|\\((?:(?!"+e.src_ZCc+"|[)]).)*\\)|\\{(?:(?!"+e.src_ZCc+'|[}]).)*\\}|\\"(?:(?!'+e.src_ZCc+`|["]).)+\\"|\\'(?:(?!`+e.src_ZCc+"|[']).)+\\'|\\'(?="+e.src_pseudo_letter+"|[-])|\\.{2,}[a-zA-Z0-9%/&]|\\.(?!"+e.src_ZCc+"|[.]|$)|"+(n["---"]?"\\-(?!--(?:[^-]|$))(?:-*)|":"\\-+|")+",(?!"+e.src_ZCc+"|$)|;(?!"+e.src_ZCc+"|$)|\\!+(?!"+e.src_ZCc+"|[!]|$)|\\?(?!"+e.src_ZCc+"|[?]|$))+|\\/)?",e.src_email_name='[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]*',e.src_xn="xn--[a-z0-9\\-]{1,59}",e.src_domain_root="(?:"+e.src_xn+"|"+e.src_pseudo_letter+"{1,63})",e.src_domain="(?:"+e.src_xn+"|(?:"+e.src_pseudo_letter+")|(?:"+e.src_pseudo_letter+"(?:-|"+e.src_pseudo_letter+"){0,61}"+e.src_pseudo_letter+"))",e.src_host="(?:(?:(?:(?:"+e.src_domain+")\\.)*"+e.src_domain+"))",e.tpl_host_fuzzy="(?:"+e.src_ip4+"|(?:(?:(?:"+e.src_domain+")\\.)+(?:%TLDS%)))",e.tpl_host_no_ip_fuzzy="(?:(?:(?:"+e.src_domain+")\\.)+(?:%TLDS%))",e.src_host_strict=e.src_host+e.src_host_terminator,e.tpl_host_fuzzy_strict=e.tpl_host_fuzzy+e.src_host_terminator,e.src_host_port_strict=e.src_host+e.src_port+e.src_host_terminator,e.tpl_host_port_fuzzy_strict=e.tpl_host_fuzzy+e.src_port+e.src_host_terminator,e.tpl_host_port_no_ip_fuzzy_strict=e.tpl_host_no_ip_fuzzy+e.src_port+e.src_host_terminator,e.tpl_host_fuzzy_test="localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:"+e.src_ZPCc+"|>|$))",e.tpl_email_fuzzy="(^|"+t+'|"|\\(|'+e.src_ZCc+")("+e.src_email_name+"@"+e.tpl_host_fuzzy_strict+")",e.tpl_link_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`|\uFF5C]|"+e.src_ZPCc+"))((?![$+<=>^`|\uFF5C])"+e.tpl_host_port_fuzzy_strict+e.src_path+")",e.tpl_link_no_ip_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`|\uFF5C]|"+e.src_ZPCc+"))((?![$+<=>^`|\uFF5C])"+e.tpl_host_port_no_ip_fuzzy_strict+e.src_path+")",e}});var gc=_((Bv,mc)=>{"use strict";function mo(n){var e=Array.prototype.slice.call(arguments,1);return e.forEach(function(t){t&&Object.keys(t).forEach(function(i){n[i]=t[i]})}),n}function vi(n){return Object.prototype.toString.call(n)}function mp(n){return vi(n)==="[object String]"}function gp(n){return vi(n)==="[object Object]"}function bp(n){return vi(n)==="[object RegExp]"}function dc(n){return vi(n)==="[object Function]"}function vp(n){return n.replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}var fc={fuzzyLink:!0,fuzzyEmail:!0,fuzzyIP:!1};function wp(n){return Object.keys(n||{}).reduce(function(e,t){return e||fc.hasOwnProperty(t)},!1)}var yp={"http:":{validate:function(n,e,t){var i=n.slice(e);return t.re.http||(t.re.http=new RegExp("^\\/\\/"+t.re.src_auth+t.re.src_host_port_strict+t.re.src_path,"i")),t.re.http.test(i)?i.match(t.re.http)[0].length:0}},"https:":"http:","ftp:":"http:","//":{validate:function(n,e,t){var i=n.slice(e);return t.re.no_http||(t.re.no_http=new RegExp("^"+t.re.src_auth+"(?:localhost|(?:(?:"+t.re.src_domain+")\\.)+"+t.re.src_domain_root+")"+t.re.src_port+t.re.src_host_terminator+t.re.src_path,"i")),t.re.no_http.test(i)?e>=3&&n[e-3]===":"||e>=3&&n[e-3]==="/"?0:i.match(t.re.no_http)[0].length:0}},"mailto:":{validate:function(n,e,t){var i=n.slice(e);return t.re.mailto||(t.re.mailto=new RegExp("^"+t.re.src_email_name+"@"+t.re.src_host_strict,"i")),t.re.mailto.test(i)?i.match(t.re.mailto)[0].length:0}}},xp="a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eosuw]|s[abcdeghijklmnortuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]",kp="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|\u0440\u0444".split("|");function Cp(n){n.__index__=-1,n.__text_cache__=""}function Ep(n){return function(e,t){var i=e.slice(t);return n.test(i)?i.match(n)[0].length:0}}function pc(){return function(n,e){e.normalize(n)}}function bi(n){var e=n.re=hc()(n.__opts__),t=n.__tlds__.slice();n.onCompile(),n.__tlds_replaced__||t.push(xp),t.push(e.src_xn),e.src_tlds=t.join("|");function i(a){return a.replace("%TLDS%",e.src_tlds)}e.email_fuzzy=RegExp(i(e.tpl_email_fuzzy),"i"),e.link_fuzzy=RegExp(i(e.tpl_link_fuzzy),"i"),e.link_no_ip_fuzzy=RegExp(i(e.tpl_link_no_ip_fuzzy),"i"),e.host_fuzzy_test=RegExp(i(e.tpl_host_fuzzy_test),"i");var r=[];n.__compiled__={};function o(a,l){throw new Error('(LinkifyIt) Invalid schema "'+a+'": '+l)}Object.keys(n.__schemas__).forEach(function(a){var l=n.__schemas__[a];if(l!==null){var c={validate:null,link:null};if(n.__compiled__[a]=c,gp(l)){bp(l.validate)?c.validate=Ep(l.validate):dc(l.validate)?c.validate=l.validate:o(a,l),dc(l.normalize)?c.normalize=l.normalize:l.normalize?o(a,l):c.normalize=pc();return}if(mp(l)){r.push(a);return}o(a,l)}}),r.forEach(function(a){n.__compiled__[n.__schemas__[a]]&&(n.__compiled__[a].validate=n.__compiled__[n.__schemas__[a]].validate,n.__compiled__[a].normalize=n.__compiled__[n.__schemas__[a]].normalize)}),n.__compiled__[""]={validate:null,normalize:pc()};var s=Object.keys(n.__compiled__).filter(function(a){return a.length>0&&n.__compiled__[a]}).map(vp).join("|");n.re.schema_test=RegExp("(^|(?!_)(?:[><\uFF5C]|"+e.src_ZPCc+"))("+s+")","i"),n.re.schema_search=RegExp("(^|(?!_)(?:[><\uFF5C]|"+e.src_ZPCc+"))("+s+")","ig"),n.re.schema_at_start=RegExp("^"+n.re.schema_search.source,"i"),n.re.pretest=RegExp("("+n.re.schema_test.source+")|("+n.re.host_fuzzy_test.source+")|@","i"),Cp(n)}function _p(n,e){var t=n.__index__,i=n.__last_index__,r=n.__text_cache__.slice(t,i);this.schema=n.__schema__.toLowerCase(),this.index=t+e,this.lastIndex=i+e,this.raw=r,this.text=r,this.url=r}function go(n,e){var t=new _p(n,e);return n.__compiled__[t.schema].normalize(t,n),t}function me(n,e){if(!(this instanceof me))return new me(n,e);e||wp(n)&&(e=n,n={}),this.__opts__=mo({},fc,e),this.__index__=-1,this.__last_index__=-1,this.__schema__="",this.__text_cache__="",this.__schemas__=mo({},yp,n),this.__compiled__={},this.__tlds__=kp,this.__tlds_replaced__=!1,this.re={},bi(this)}me.prototype.add=function(e,t){return this.__schemas__[e]=t,bi(this),this};me.prototype.set=function(e){return this.__opts__=mo(this.__opts__,e),this};me.prototype.test=function(e){if(this.__text_cache__=e,this.__index__=-1,!e.length)return!1;var t,i,r,o,s,a,l,c,u;if(this.re.schema_test.test(e)){for(l=this.re.schema_search,l.lastIndex=0;(t=l.exec(e))!==null;)if(o=this.testSchemaAt(e,t[2],l.lastIndex),o){this.__schema__=t[2],this.__index__=t.index+t[1].length,this.__last_index__=t.index+t[0].length+o;break}}return this.__opts__.fuzzyLink&&this.__compiled__["http:"]&&(c=e.search(this.re.host_fuzzy_test),c>=0&&(this.__index__<0||c<this.__index__)&&(i=e.match(this.__opts__.fuzzyIP?this.re.link_fuzzy:this.re.link_no_ip_fuzzy))!==null&&(s=i.index+i[1].length,(this.__index__<0||s<this.__index__)&&(this.__schema__="",this.__index__=s,this.__last_index__=i.index+i[0].length))),this.__opts__.fuzzyEmail&&this.__compiled__["mailto:"]&&(u=e.indexOf("@"),u>=0&&(r=e.match(this.re.email_fuzzy))!==null&&(s=r.index+r[1].length,a=r.index+r[0].length,(this.__index__<0||s<this.__index__||s===this.__index__&&a>this.__last_index__)&&(this.__schema__="mailto:",this.__index__=s,this.__last_index__=a))),this.__index__>=0};me.prototype.pretest=function(e){return this.re.pretest.test(e)};me.prototype.testSchemaAt=function(e,t,i){return this.__compiled__[t.toLowerCase()]?this.__compiled__[t.toLowerCase()].validate(e,i,this):0};me.prototype.match=function(e){var t=0,i=[];this.__index__>=0&&this.__text_cache__===e&&(i.push(go(this,t)),t=this.__last_index__);for(var r=t?e.slice(t):e;this.test(r);)i.push(go(this,t)),r=r.slice(this.__last_index__),t+=this.__last_index__;return i.length?i:null};me.prototype.matchAtStart=function(e){if(this.__text_cache__=e,this.__index__=-1,!e.length)return null;var t=this.re.schema_at_start.exec(e);if(!t)return null;var i=this.testSchemaAt(e,t[2],t[0].length);return i?(this.__schema__=t[2],this.__index__=t.index+t[1].length,this.__last_index__=t.index+t[0].length+i,go(this,0)):null};me.prototype.tlds=function(e,t){return e=Array.isArray(e)?e:[e],t?(this.__tlds__=this.__tlds__.concat(e).sort().filter(function(i,r,o){return i!==o[r-1]}).reverse(),bi(this),this):(this.__tlds__=e.slice(),this.__tlds_replaced__=!0,bi(this),this)};me.prototype.normalize=function(e){e.schema||(e.url="http://"+e.url),e.schema==="mailto:"&&!/^mailto:/i.test(e.url)&&(e.url="mailto:"+e.url)};me.prototype.onCompile=function(){};mc.exports=me});var Ec={};St(Ec,{decode:()=>yo,default:()=>Mp,encode:()=>xo,toASCII:()=>Cc,toUnicode:()=>kc,ucs2decode:()=>wo,ucs2encode:()=>yc});function Ve(n){throw new RangeError(Tp[n])}function Lp(n,e){let t=[],i=n.length;for(;i--;)t[i]=e(n[i]);return t}function wc(n,e){let t=n.split("@"),i="";t.length>1&&(i=t[0]+"@",n=t[1]),n=n.replace(Dp,".");let r=n.split("."),o=Lp(r,e).join(".");return i+o}function wo(n){let e=[],t=0,i=n.length;for(;t<i;){let r=n.charCodeAt(t++);if(r>=55296&&r<=56319&&t<i){let o=n.charCodeAt(t++);(o&64512)==56320?e.push(((r&1023)<<10)+(o&1023)+65536):(e.push(r),t--)}else e.push(r)}return e}var vc,Sp,Ap,Dp,Tp,bo,Le,vo,yc,Ip,bc,xc,yo,xo,kc,Cc,$p,Mp,_c=Bu(()=>{"use strict";vc="-",Sp=/^xn--/,Ap=/[^\0-\x7F]/,Dp=/[\x2E\u3002\uFF0E\uFF61]/g,Tp={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},bo=36-1,Le=Math.floor,vo=String.fromCharCode;yc=n=>String.fromCodePoint(...n),Ip=function(n){return n>=48&&n<58?26+(n-48):n>=65&&n<91?n-65:n>=97&&n<123?n-97:36},bc=function(n,e){return n+22+75*(n<26)-((e!=0)<<5)},xc=function(n,e,t){let i=0;for(n=t?Le(n/700):n>>1,n+=Le(n/e);n>bo*26>>1;i+=36)n=Le(n/bo);return Le(i+(bo+1)*n/(n+38))},yo=function(n){let e=[],t=n.length,i=0,r=128,o=72,s=n.lastIndexOf(vc);s<0&&(s=0);for(let a=0;a<s;++a)n.charCodeAt(a)>=128&&Ve("not-basic"),e.push(n.charCodeAt(a));for(let a=s>0?s+1:0;a<t;){let l=i;for(let u=1,h=36;;h+=36){a>=t&&Ve("invalid-input");let d=Ip(n.charCodeAt(a++));d>=36&&Ve("invalid-input"),d>Le((2147483647-i)/u)&&Ve("overflow"),i+=d*u;let p=h<=o?1:h>=o+26?26:h-o;if(d<p)break;let f=36-p;u>Le(2147483647/f)&&Ve("overflow"),u*=f}let c=e.length+1;o=xc(i-l,c,l==0),Le(i/c)>2147483647-r&&Ve("overflow"),r+=Le(i/c),i%=c,e.splice(i++,0,r)}return String.fromCodePoint(...e)},xo=function(n){let e=[];n=wo(n);let t=n.length,i=128,r=0,o=72;for(let l of n)l<128&&e.push(vo(l));let s=e.length,a=s;for(s&&e.push(vc);a<t;){let l=2147483647;for(let u of n)u>=i&&u<l&&(l=u);let c=a+1;l-i>Le((2147483647-r)/c)&&Ve("overflow"),r+=(l-i)*c,i=l;for(let u of n)if(u<i&&++r>2147483647&&Ve("overflow"),u===i){let h=r;for(let d=36;;d+=36){let p=d<=o?1:d>=o+26?26:d-o;if(h<p)break;let f=h-p,m=36-p;e.push(vo(bc(p+f%m,0))),h=Le(f/m)}e.push(vo(bc(h,0))),o=xc(r,c,a===s),r=0,++a}++r,++i}return e.join("")},kc=function(n){return wc(n,function(e){return Sp.test(e)?yo(e.slice(4).toLowerCase()):e})},Cc=function(n){return wc(n,function(e){return Ap.test(e)?"xn--"+xo(e):e})},$p={version:"2.1.0",ucs2:{decode:wo,encode:yc},decode:yo,encode:xo,toASCII:Cc,toUnicode:kc},Mp=$p});var Ac=_((Pv,Sc)=>{"use strict";Sc.exports={options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"\u201C\u201D\u2018\u2019",highlight:null,maxNesting:100},components:{core:{},block:{},inline:{}}}});var Tc=_((Ov,Dc)=>{"use strict";Dc.exports={options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"\u201C\u201D\u2018\u2019",highlight:null,maxNesting:20},components:{core:{rules:["normalize","block","inline","text_join"]},block:{rules:["paragraph"]},inline:{rules:["text"],rules2:["balance_pairs","fragments_join"]}}}});var Ic=_((Rv,Lc)=>{"use strict";Lc.exports={options:{html:!0,xhtmlOut:!0,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"\u201C\u201D\u2018\u2019",highlight:null,maxNesting:20},components:{core:{rules:["normalize","block","inline","text_join"]},block:{rules:["blockquote","code","fence","heading","hr","html_block","lheading","list","reference","paragraph"]},inline:{rules:["autolink","backticks","emphasis","entity","escape","html_inline","image","link","newline","text"],rules2:["balance_pairs","emphasis","fragments_join"]}}}});var qc=_((Nv,Fc)=>{"use strict";var Yt=R(),Fp=fa(),qp=ga(),Bp=Ua(),Pp=Sl(),Op=cc(),Rp=gc(),Qe=Gr(),$c=(_c(),Pu(Ec)),Np={default:Ac(),zero:Tc(),commonmark:Ic()},zp=/^(vbscript|javascript|file|data):/,Hp=/^data:image\/(gif|png|jpeg|webp);/;function Up(n){var e=n.trim().toLowerCase();return zp.test(e)?!!Hp.test(e):!0}var Mc=["http:","https:","mailto:"];function jp(n){var e=Qe.parse(n,!0);if(e.hostname&&(!e.protocol||Mc.indexOf(e.protocol)>=0))try{e.hostname=$c.toASCII(e.hostname)}catch{}return Qe.encode(Qe.format(e))}function Vp(n){var e=Qe.parse(n,!0);if(e.hostname&&(!e.protocol||Mc.indexOf(e.protocol)>=0))try{e.hostname=$c.toUnicode(e.hostname)}catch{}return Qe.decode(Qe.format(e),Qe.decode.defaultChars+"%")}function be(n,e){if(!(this instanceof be))return new be(n,e);e||Yt.isString(n)||(e=n||{},n="default"),this.inline=new Op,this.block=new Pp,this.core=new Bp,this.renderer=new qp,this.linkify=new Rp,this.validateLink=Up,this.normalizeLink=jp,this.normalizeLinkText=Vp,this.utils=Yt,this.helpers=Yt.assign({},Fp),this.options={},this.configure(n),e&&this.set(e)}be.prototype.set=function(n){return Yt.assign(this.options,n),this};be.prototype.configure=function(n){var e=this,t;if(Yt.isString(n)&&(t=n,n=Np[t],!n))throw new Error('Wrong `markdown-it` preset "'+t+'", check name');if(!n)throw new Error("Wrong `markdown-it` preset, can't be empty");return n.options&&e.set(n.options),n.components&&Object.keys(n.components).forEach(function(i){n.components[i].rules&&e[i].ruler.enableOnly(n.components[i].rules),n.components[i].rules2&&e[i].ruler2.enableOnly(n.components[i].rules2)}),this};be.prototype.enable=function(n,e){var t=[];Array.isArray(n)||(n=[n]),["core","block","inline"].forEach(function(r){t=t.concat(this[r].ruler.enable(n,!0))},this),t=t.concat(this.inline.ruler2.enable(n,!0));var i=n.filter(function(r){return t.indexOf(r)<0});if(i.length&&!e)throw new Error("MarkdownIt. Failed to enable unknown rule(s): "+i);return this};be.prototype.disable=function(n,e){var t=[];Array.isArray(n)||(n=[n]),["core","block","inline"].forEach(function(r){t=t.concat(this[r].ruler.disable(n,!0))},this),t=t.concat(this.inline.ruler2.disable(n,!0));var i=n.filter(function(r){return t.indexOf(r)<0});if(i.length&&!e)throw new Error("MarkdownIt. Failed to disable unknown rule(s): "+i);return this};be.prototype.use=function(n){var e=[this].concat(Array.prototype.slice.call(arguments,1));return n.apply(n,e),this};be.prototype.parse=function(n,e){if(typeof n!="string")throw new Error("Input data should be a String");var t=new this.core.State(n,this,e);return this.core.process(t),t.tokens};be.prototype.render=function(n,e){return e=e||{},this.renderer.render(this.parse(n,e),this.options,e)};be.prototype.parseInline=function(n,e){var t=new this.core.State(n,this,e);return t.inlineMode=!0,this.core.process(t),t.tokens};be.prototype.renderInline=function(n,e){return e=e||{},this.renderer.render(this.parseInline(n,e),this.options,e)};Fc.exports=be});var Pc=_((zv,Bc)=>{"use strict";Bc.exports=qc()});var Hc=_((Hv,zc)=>{var ko=!0,Rc=!1,Nc=!1;zc.exports=function(n,e){e&&(ko=!e.enabled,Rc=!!e.label,Nc=!!e.labelAfter),n.core.ruler.after("inline","github-task-lists",function(t){for(var i=t.tokens,r=2;r<i.length;r++)Gp(i,r)&&(Kp(i[r],t.Token),Oc(i[r-2],"class","task-list-item"+(ko?"":" enabled")),Oc(i[Wp(i,r-2)],"class","contains-task-list"))})};function Oc(n,e,t){var i=n.attrIndex(e),r=[e,t];i<0?n.attrPush(r):n.attrs[i]=r}function Wp(n,e){for(var t=n[e].level-1,i=e-1;i>=0;i--)if(n[i].level===t)return i;return-1}function Gp(n,e){return Qp(n[e])&&ef(n[e-1])&&tf(n[e-2])&&nf(n[e])}function Kp(n,e){if(n.children.unshift(Zp(n,e)),n.children[1].content=n.children[1].content.slice(3),n.content=n.content.slice(3),Rc)if(Nc){n.children.pop();var t="task-item-"+Math.ceil(Math.random()*(1e4*1e3)-1e3);n.children[0].content=n.children[0].content.slice(0,-1)+' id="'+t+'">',n.children.push(Jp(n.content,t,e))}else n.children.unshift(Xp(e)),n.children.push(Yp(e))}function Zp(n,e){var t=new e("html_inline","",0),i=ko?' disabled="" ':"";return n.content.indexOf("[ ] ")===0?t.content='<input class="task-list-item-checkbox"'+i+'type="checkbox">':(n.content.indexOf("[x] ")===0||n.content.indexOf("[X] ")===0)&&(t.content='<input class="task-list-item-checkbox" checked=""'+i+'type="checkbox">'),t}function Xp(n){var e=new n("html_inline","",0);return e.content="<label>",e}function Yp(n){var e=new n("html_inline","",0);return e.content="</label>",e}function Jp(n,e,t){var i=new t("html_inline","",0);return i.content='<label class="task-list-item-label" for="'+e+'">'+n+"</label>",i.attrs=[{for:e}],i}function Qp(n){return n.type==="inline"}function ef(n){return n.type==="paragraph_open"}function tf(n){return n.type==="list_item_open"}function nf(n){return n.content.indexOf("[ ] ")===0||n.content.indexOf("[x] ")===0||n.content.indexOf("[X] ")===0}});var dr={};St(dr,{emit:()=>ur,emitPublic:()=>zu,error:()=>hr,listen:()=>Nu,showResponseError:()=>ju,showValidationErrors:()=>Uu,success:()=>Hu});var on={},Ru=[];function ur(n,e){Ru.push({name:n,data:e});let t=on[n]||[];for(let i of t)i(e)}function Nu(n,e){typeof on[n]>"u"&&(on[n]=[]),on[n].push(e)}function zu(n,e,t){let i=new CustomEvent(e,{detail:t,bubbles:!0});n.dispatchEvent(i)}function Hu(n){ur("success",n)}function hr(n){ur("error",n)}function Uu(n){if(n.status&&n.status===422&&n.data){let e=Object.values(n.data).flat().join(`
+`);hr(e)}}function ju(n){n.status&&n.status>=400&&n.data&&n.data.message&&hr(n.data.message)}var pr={};St(pr,{HttpError:()=>sn,createXMLHttpRequest:()=>Wu,delete:()=>Yu,get:()=>Gu,patch:()=>Xu,post:()=>Ku,put:()=>Zu});async function Vu(n){if(n.status===204)return null;let t=(n.headers.get("Content-Type")||"").split(";")[0].split("/").pop();return t==="javascript"||t==="json"?n.json():n.text()}var sn=class extends Error{constructor(e,t){super(e.statusText),this.data=t,this.headers=e.headers,this.redirected=e.redirected,this.status=e.status,this.statusText=e.statusText,this.url=e.url,this.original=e}};function Wu(n,e,t={}){let i=document.querySelector("meta[name=token]").getAttribute("content"),r=new XMLHttpRequest;for(let[o,s]of Object.entries(t))r.addEventListener(o,s.bind(r));return r.open(n,e),r.withCredentials=!0,r.setRequestHeader("X-CSRF-TOKEN",i),r}async function Go(n,e={}){let t=n;if(t.startsWith("http")||(t=window.baseUrl(t)),e.params){let l=new URL(t);for(let c of Object.keys(e.params)){let u=e.params[c];typeof u<"u"&&u!==null&&l.searchParams.set(c,u)}t=l.toString()}let i=document.querySelector("meta[name=token]").getAttribute("content"),r={...e,credentials:"same-origin"};r.headers={...r.headers||{},baseURL:window.baseUrl(""),"X-CSRF-TOKEN":i};let o=await fetch(t,r),s=await Vu(o),a={data:s,headers:o.headers,redirected:o.redirected,status:o.status,statusText:o.statusText,url:o.url,original:o};if(!o.ok)throw new sn(o,s);return a}async function an(n,e,t=null){let i={method:n,body:t};return typeof t=="object"&&!(t instanceof FormData)&&(i.headers={"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},i.body=JSON.stringify(t)),t instanceof FormData&&n!=="post"&&(t.append("_method",n),i.method="post"),Go(e,i)}async function Gu(n,e={}){return Go(n,{method:"GET",params:e})}async function Ku(n,e=null){return an("POST",n,e)}async function Zu(n,e=null){return an("PUT",n,e)}async function Xu(n,e=null){return an("PATCH",n,e)}async function Yu(n,e=null){return an("DELETE",n,e)}var fr=class{constructor(){this.store=new Map,this.parseTranslations()}parseTranslations(){let e=document.querySelectorAll('meta[name="translation"]');for(let t of e){let i=t.getAttribute("key"),r=t.getAttribute("value");this.store.set(i,r)}}get(e,t){let i=this.getTransText(e);return this.performReplacements(i,t)}getPlural(e,t,i){let r=this.getTransText(e);return this.parsePlural(r,t,i)}parsePlural(e,t,i){let r=e.split("|"),o=/^{([0-9]+)}/,s=/^\[([0-9]+),([0-9*]+)]/,a=null;for(let l of r){let c=l.match(o);if(c!==null&&Number(c[1])===t){a=l.replace(o,"").trim();break}let u=l.match(s);if(u!==null&&Number(u[1])<=t&&(u[2]==="*"||Number(u[2])>=t)){a=l.replace(s,"").trim();break}}return a===null&&r.length>1&&(a=t===1?r[0]:r[1]),a===null&&(a=r[0]),this.performReplacements(a,i)}getTransText(e){let t=this.store.get(e);return t===void 0&&console.warn(`Translation with key "${e}" does not exist`),t}performReplacements(e,t){if(!t)return e;let i=e.match(/:(\S+)/g);if(i===null)return e;let r=e;return i.forEach(o=>{let s=o.substring(1);typeof t[s]>"u"||(r=r.replace(o,t[s]))}),r}},Ko=fr;var wr={};St(wr,{first:()=>th,firstOnElement:()=>ih,get:()=>nh,init:()=>br,register:()=>vr});function mr(n){let e=i=>i.slice(0,1).toUpperCase()+i.slice(1),t=n.split("-");return t[0]+t.slice(1).map(e).join("")}function Zo(n){return n.replace(/[A-Z]/g,(e,t)=>(t>0?"-":"")+e.toLowerCase())}var At={},Xo={},gr=new WeakMap;function Ju(n,e){let t={},i={},r=`${n}@`,o=`[refs*="${r}"]`,s=[...e.querySelectorAll(o)];e.matches(o)&&s.push(e);for(let a of s){let l=a.getAttribute("refs").split(" ").filter(c=>c.startsWith(r)).map(c=>c.replace(r,"")).map(mr);for(let c of l)t[c]=a,typeof i[c]>"u"&&(i[c]=[]),i[c].push(a)}return{refs:t,manyRefs:i}}function Qu(n,e){let t={},i=`option:${n}:`;for(let{name:r,value:o}of e.attributes)if(r.startsWith(i)){let s=r.replace(i,"");t[mr(s)]=o||""}return t}function eh(n,e){let t=Xo[n];if(t===void 0)return;let i;try{i=new t,i.$name=n,i.$el=e;let o=Ju(n,e);i.$refs=o.refs,i.$manyRefs=o.manyRefs,i.$opts=Qu(n,e),i.setup()}catch(o){console.error("Failed to create component",o,n,e)}typeof At[n]>"u"&&(At[n]=[]),At[n].push(i);let r=gr.get(e)||{};r[n]=i,gr.set(e,r)}function br(n=document){let e=n.querySelectorAll("[component],[components]");for(let t of e){let i=`${t.getAttribute("component")||""} ${t.getAttribute("components")}`.toLowerCase().split(" ").filter(Boolean);for(let r of i)eh(r,t)}}function vr(n){let e=Object.keys(n);for(let t of e)Xo[Zo(t)]=n[t]}function th(n){return(At[n]||[null])[0]}function nh(n){return At[n]||[]}function ih(n,e){return(gr.get(n)||{})[e]||null}var Uo={};St(Uo,{AddRemoveRows:()=>cn,AjaxDeleteRow:()=>un,AjaxForm:()=>hn,Attachments:()=>dn,AttachmentsList:()=>pn,AutoSubmit:()=>mn,AutoSuggest:()=>fn,BackToTop:()=>gn,BookSort:()=>Fn,ChapterContents:()=>Bn,CodeEditor:()=>Pn,CodeHighlighter:()=>On,CodeTextarea:()=>Rn,Collapsible:()=>Nn,ConfirmDialog:()=>zn,CustomCheckbox:()=>Hn,DetailsHighlighter:()=>Un,Dropdown:()=>jn,DropdownSearch:()=>Vn,Dropzone:()=>Wn,EditorToolbox:()=>Gn,EntityPermissions:()=>Kn,EntitySearch:()=>Zn,EntitySelector:()=>Xn,EntitySelectorPopup:()=>Yn,EventEmitSelect:()=>Jn,ExpandToggle:()=>Qn,GlobalSearch:()=>ei,HeaderMobileToggle:()=>ti,ImageManager:()=>ni,ImagePicker:()=>ii,ListSortControl:()=>ri,MarkdownEditor:()=>Mi,NewUserPassword:()=>Fi,Notification:()=>qi,OptionalInput:()=>Bi,PageComment:()=>Pi,PageComments:()=>Oi,PageDisplay:()=>Ri,PageEditor:()=>Ni,PagePicker:()=>Hi,PermissionsTable:()=>Ui,Pointer:()=>ji,Popup:()=>Vi,SettingAppColorScheme:()=>Wi,SettingColorPicker:()=>Gi,SettingHomepageControl:()=>Ki,ShelfSort:()=>Zi,ShortcutInput:()=>Yi,Shortcuts:()=>Xi,SortableList:()=>Ji,SubmitOnChange:()=>Qi,Tabs:()=>er,TagManager:()=>tr,TemplateManager:()=>nr,ToggleSwitch:()=>ir,TriLayout:()=>rr,UserSelect:()=>or,WebhookEvents:()=>sr,WysiwygEditor:()=>cr});function Ee(n,e={},t=[]){let i=document.createElement(n);for(let[r,o]of Object.entries(e))o===null?i.removeAttribute(r):i.setAttribute(r,o);for(let r of t)typeof r=="string"?i.append(document.createTextNode(r)):i.append(r);return i}function yr(n,e){let t=document.querySelectorAll(n);for(let i of t)e(i)}function ln(n,e,t){for(let i of e)n.addEventListener(i,t)}function O(n,e){Array.isArray(n)||(n=[n]);for(let t of n)t.addEventListener("click",e),t.addEventListener("keydown",i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),e(i))})}function Yo(n,e,t){Array.isArray(e)||(e=[e]);let i=r=>{r.key===n&&t(r)};e.forEach(r=>r.addEventListener("keydown",i))}function st(n,e){Yo("Enter",n,e)}function Jo(n,e){Yo("Escape",n,e)}function K(n,e,t,i){n.addEventListener(t,r=>{let o=r.target.closest(e);o&&i.call(o,r,o)})}function Qo(n,e){let t=document.querySelectorAll(n);e=e.toLowerCase();for(let i of t)if(i.textContent.toLowerCase().includes(e))return i;return null}function Dt(n){n.innerHTML='<div class="loading-container"><div></div><div></div><div></div></div>'}function at(){let n=document.createElement("div");return n.classList.add("loading-container"),n.innerHTML="<div></div><div></div><div></div>",n}function Tt(n){let e=n.querySelectorAll(".loading-container");for(let t of e)t.remove()}function _e(n){let e=document.createElement("div");return e.innerHTML=n,window.$components.init(e),e.children[0]}function Ne(n,e,t){let i;return function(...o){let s=this,a=function(){i=null,t||n.apply(s,o)},l=t&&!i;clearTimeout(i),i=setTimeout(a,e),l&&n.apply(s,o)}}function kr(n){if(!n)return;n.scrollIntoView({behavior:"smooth"});let e=getComputedStyle(document.body).getPropertyValue("--color-primary-light"),t=window.getComputedStyle(n).getPropertyValue("background-color");n.style.backgroundColor=e,setTimeout(()=>{n.classList.add("selectFade"),n.style.backgroundColor=t},10),setTimeout(()=>{n.classList.remove("selectFade"),n.style.backgroundColor=""},3e3)}function es(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function ts(){let n=()=>((1+Math.random())*65536|0).toString(16).substring(1);return`${n()+n()}-${n()}-${n()}-${n()}-${n()}${n()}${n()}`}function ns(n){return new Promise(e=>{setTimeout(e,n)})}var g=class{constructor(){se(this,"$name","");se(this,"$el",null);se(this,"$refs",{});se(this,"$manyRefs",{});se(this,"$opts",{})}setup(){}$emit(e,t={}){t.from=this;let i=this.$name,r=new CustomEvent(`${i}-${e}`,{bubbles:!0,detail:t});this.$el.dispatchEvent(r)}};var cn=class extends g{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)),K(this.$el,this.removeSelector,"click",e=>{e.target.closest(this.rowSelector).remove()})}add(){let e=this.modelRow.cloneNode(!0);e.classList.remove("hidden"),this.setClonedInputNames(e),this.modelRow.parentNode.insertBefore(e,this.modelRow),window.$components.init(e)}setClonedInputNames(e){let t=ts(),i=e.querySelectorAll('[name*="randrowid"]');for(let r of i)r.name=r.name.split("randrowid").join(t)}};var un=class extends g{setup(){this.row=this.$el,this.url=this.$opts.url,this.deleteButtons=this.$manyRefs.delete,O(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.opacity=null,this.row.style.pointerEvents=null})}};var hn=class extends g{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}st(this.container,e=>{this.submitFakeForm(),e.preventDefault()}),this.submitButtons.forEach(e=>O(e,this.submitFakeForm.bind(this)))}submitFakeForm(){let e=new FormData,t=this.container.querySelectorAll("[name]");for(let i of t)e.append(i.getAttribute("name"),i.value);this.submit(e)}submitRealForm(e){e.preventDefault();let t=new FormData(this.container);this.submit(t)}async submit(e){this.responseContainer.style.opacity="0.7",this.responseContainer.style.pointerEvents="none";try{let t=await window.$http[this.method.toLowerCase()](this.url,e);this.$emit("success",{formData:e}),this.responseContainer.innerHTML=t.data,this.successMessage&&window.$events.emit("success",this.successMessage)}catch(t){this.responseContainer.innerHTML=t.data}window.$components.init(this.responseContainer),this.responseContainer.style.opacity=null,this.responseContainer.style.pointerEvents=null}};var dn=class extends g{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 e=this.reloadList.bind(this);this.container.addEventListener("dropzone-upload-success",e),this.container.addEventListener("ajax-form-success",e),this.container.addEventListener("sortable-list-sort",t=>{this.updateOrder(t.detail.ids)}),this.container.addEventListener("event-emit-select-edit",t=>{this.startEdit(t.detail.id)}),this.container.addEventListener("event-emit-select-edit-back",()=>{this.stopEdit()}),this.container.addEventListener("event-emit-select-insert",t=>{let i=t.target.closest("[data-drag-content]").getAttribute("data-drag-content"),r=JSON.parse(i);window.$events.emit("editor::insert",{html:r["text/html"],markdown:r["text/plain"]})}),this.attachLinkButton.addEventListener("click",()=>{this.showSection("links")})}showSection(e){let t={links:this.linksContainer,edit:this.editContainer,list:this.listContainer};for(let[i,r]of Object.entries(t))r.toggleAttribute("hidden",i!==e)}reloadList(){this.stopEdit(),window.$http.get(`/attachments/get/page/${this.pageId}`).then(e=>{this.listPanel.innerHTML=e.data,window.$components.init(this.listPanel)})}updateOrder(e){window.$http.put(`/attachments/sort/page/${this.pageId}`,{order:e}).then(t=>{window.$events.emit("success",t.data.message)})}async startEdit(e){this.showSection("edit"),Dt(this.editContainer);let t=await window.$http.get(`/attachments/edit/${e}`);this.editContainer.innerHTML=t.data,window.$components.init(this.editContainer)}stopEdit(){this.showSection("list")}};var pn=class extends g{setup(){this.container=this.$el,this.setupListeners()}setupListeners(){let e=t=>t.key==="Control"||t.key==="Meta";window.addEventListener("keydown",t=>{e(t)&&this.addOpenQueryToLinks()},{passive:!0}),window.addEventListener("keyup",t=>{e(t)&&this.removeOpenQueryFromLinks()},{passive:!0})}addOpenQueryToLinks(){let e=this.container.querySelectorAll("a.attachment-file");for(let t of e)t.href.split("?")[1]!=="open=true"&&(t.href+="?open=true",t.setAttribute("target","_blank"))}removeOpenQueryFromLinks(){let e=this.container.querySelectorAll("a.attachment-file");for(let t of e)t.href=t.href.split("?")[0],t.removeAttribute("target")}};var Lt,Cr,It,Er,ze=class{constructor(e,t=null,i=null){re(this,Lt);re(this,It);this.containers=[e],this.onEscape=t,this.onEnter=i,e.addEventListener("keydown",T(this,Lt,Cr).bind(this))}shareHandlingToEl(e){this.containers.push(e),e.addEventListener("keydown",T(this,Lt,Cr).bind(this))}focusNext(){let e=T(this,It,Er).call(this),i=e.indexOf(document.activeElement)+1;i>=e.length&&(i=0),e[i].focus()}focusPrevious(){let e=T(this,It,Er).call(this),i=e.indexOf(document.activeElement)-1;i<0&&(i=e.length-1),e[i].focus()}};Lt=new WeakSet,Cr=function(e){e.target.matches("input")&&(e.key==="ArrowRight"||e.key==="ArrowLeft")||(e.key==="ArrowDown"||e.key==="ArrowRight"?(this.focusNext(),e.preventDefault()):e.key==="ArrowUp"||e.key==="ArrowLeft"?(this.focusPrevious(),e.preventDefault()):e.key==="Escape"?this.onEscape?this.onEscape(e):document.activeElement&&document.activeElement.blur():e.key==="Enter"&&this.onEnter&&this.onEnter(e))},It=new WeakSet,Er=function(){let e=[],t='[tabindex]:not([tabindex="-1"]),[href],button:not([tabindex="-1"],[disabled]),input:not([type=hidden])';for(let i of this.containers)e.push(...i.querySelectorAll(t));return e};var _r={},fn=class extends g{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 ze(this.list,()=>{this.input.focus(),setTimeout(()=>this.hideSuggestions(),1)},t=>{t.preventDefault(),this.selectSuggestion(t.target.textContent)}).shareHandlingToEl(this.input),K(this.list,".text-item","click",(t,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",t=>{t.key==="Tab"&&this.hideSuggestions()})}selectSuggestion(e){this.input.value=e,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 e=this.getNameFilterIfNeeded(),t=this.input.value.toLowerCase(),r=(await this.loadSuggestions(t,e)).filter(o=>t===""||o.toLowerCase().startsWith(t)).slice(0,10);this.displaySuggestions(r)}getNameFilterIfNeeded(){return this.type!=="value"?null:this.parent.querySelector("input").value}async loadSuggestions(e,t=null){e=e.slice(0,4);let i={search:e,name:t},r=`${this.url}:${JSON.stringify(i)}`;if(_r[r])return _r[r];let o=await window.$http.get(this.url,i);return _r[r]=o.data,o.data}displaySuggestions(e){if(e.length===0){this.hideSuggestions();return}this.list.innerHTML=e.map(t=>`<li><div tabindex="0" class="text-item">${es(t)}</div></li>`).join(""),this.list.style.display="block";for(let t of this.list.querySelectorAll(".text-item"))t.addEventListener("blur",this.hideSuggestionsIfFocusedLost.bind(this))}hideSuggestions(){this.list.style.display="none"}hideSuggestionsIfFocusedLost(e){this.container.contains(e.relatedTarget)||this.hideSuggestions()}};var mn=class extends g{setup(){this.form=this.$el,this.form.submit()}};var gn=class extends g{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 e=document.documentElement.scrollTop||document.body.scrollTop||0;!this.showing&&e>this.breakPoint?(this.button.style.display="block",this.showing=!0,setTimeout(()=>{this.button.style.opacity=.4},1)):this.showing&&e<this.breakPoint&&(this.button.style.opacity=0,this.showing=!1,setTimeout(()=>{this.button.style.display="none"},500))}scrollToTop(){let e=this.targetElem.getBoundingClientRect().top,t=document.documentElement.scrollTop?document.documentElement:document.body,i=300,r=Date.now(),o=this.targetElem.getBoundingClientRect().top;function s(){let a=1-(Date.now()-r)/i,l=Math.abs(a*o);a>0?(t.scrollTop=l,requestAnimationFrame(s.bind(this))):t.scrollTop=e}requestAnimationFrame(s.bind(this))}};function is(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(n,r).enumerable})),t.push.apply(t,i)}return t}function Ae(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?is(Object(t),!0).forEach(function(i){rh(n,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):is(Object(t)).forEach(function(i){Object.defineProperty(n,i,Object.getOwnPropertyDescriptor(t,i))})}return n}function Cn(n){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Cn=function(e){return typeof e}:Cn=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Cn(n)}function rh(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function ke(){return ke=Object.assign||function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i])}return n},ke.apply(this,arguments)}function oh(n,e){if(n==null)return{};var t={},i=Object.keys(n),r,o;for(o=0;o<i.length;o++)r=i[o],!(e.indexOf(r)>=0)&&(t[r]=n[r]);return t}function sh(n,e){if(n==null)return{};var t=oh(n,e),i,r;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(n);for(r=0;r<o.length;r++)i=o[r],!(e.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(n,i)&&(t[i]=n[i])}return t}function ah(n){return lh(n)||ch(n)||uh(n)||hh()}function lh(n){if(Array.isArray(n))return Br(n)}function ch(n){if(typeof Symbol<"u"&&n[Symbol.iterator]!=null||n["@@iterator"]!=null)return Array.from(n)}function uh(n,e){if(n){if(typeof n=="string")return Br(n,e);var t=Object.prototype.toString.call(n).slice(8,-1);if(t==="Object"&&n.constructor&&(t=n.constructor.name),t==="Map"||t==="Set")return Array.from(n);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Br(n,e)}}function Br(n,e){(e==null||e>n.length)&&(e=n.length);for(var t=0,i=new Array(e);t<e;t++)i[t]=n[t];return i}function hh(){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 dh="1.15.0";function $e(n){if(typeof window<"u"&&window.navigator)return!!navigator.userAgent.match(n)}var Me=$e(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),jt=$e(/Edge/i),rs=$e(/firefox/i),Rt=$e(/safari/i)&&!$e(/chrome/i)&&!$e(/android/i),fs=$e(/iP(ad|od|hone)/i),ms=$e(/chrome/i)&&$e(/android/i),gs={capture:!1,passive:!1};function P(n,e,t){n.addEventListener(e,t,!Me&&gs)}function B(n,e,t){n.removeEventListener(e,t,!Me&&gs)}function Dn(n,e){if(e){if(e[0]===">"&&(e=e.substring(1)),n)try{if(n.matches)return n.matches(e);if(n.msMatchesSelector)return n.msMatchesSelector(e);if(n.webkitMatchesSelector)return n.webkitMatchesSelector(e)}catch{return!1}return!1}}function ph(n){return n.host&&n!==document&&n.host.nodeType?n.host:n.parentNode}function xe(n,e,t,i){if(n){t=t||document;do{if(e!=null&&(e[0]===">"?n.parentNode===t&&Dn(n,e):Dn(n,e))||i&&n===t)return n;if(n===t)break}while(n=ph(n))}return null}var os=/\s+/g;function X(n,e,t){if(n&&e)if(n.classList)n.classList[t?"add":"remove"](e);else{var i=(" "+n.className+" ").replace(os," ").replace(" "+e+" "," ");n.className=(i+(t?" "+e:"")).replace(os," ")}}function A(n,e,t){var i=n&&n.style;if(i){if(t===void 0)return document.defaultView&&document.defaultView.getComputedStyle?t=document.defaultView.getComputedStyle(n,""):n.currentStyle&&(t=n.currentStyle),e===void 0?t:t[e];!(e in i)&&e.indexOf("webkit")===-1&&(e="-webkit-"+e),i[e]=t+(typeof t=="string"?"":"px")}}function Xe(n,e){var t="";if(typeof n=="string")t=n;else do{var i=A(n,"transform");i&&i!=="none"&&(t=i+" "+t)}while(!e&&(n=n.parentNode));var r=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return r&&new r(t)}function bs(n,e,t){if(n){var i=n.getElementsByTagName(e),r=0,o=i.length;if(t)for(;r<o;r++)t(i[r],r);return i}return[]}function Se(){var n=document.scrollingElement;return n||document.documentElement}function j(n,e,t,i,r){if(!(!n.getBoundingClientRect&&n!==window)){var o,s,a,l,c,u,h;if(n!==window&&n.parentNode&&n!==Se()?(o=n.getBoundingClientRect(),s=o.top,a=o.left,l=o.bottom,c=o.right,u=o.height,h=o.width):(s=0,a=0,l=window.innerHeight,c=window.innerWidth,u=window.innerHeight,h=window.innerWidth),(e||t)&&n!==window&&(r=r||n.parentNode,!Me))do if(r&&r.getBoundingClientRect&&(A(r,"transform")!=="none"||t&&A(r,"position")!=="static")){var d=r.getBoundingClientRect();s-=d.top+parseInt(A(r,"border-top-width")),a-=d.left+parseInt(A(r,"border-left-width")),l=s+o.height,c=a+o.width;break}while(r=r.parentNode);if(i&&n!==window){var p=Xe(r||n),f=p&&p.a,m=p&&p.d;p&&(s/=m,a/=f,h/=f,u/=m,l=s+u,c=a+h)}return{top:s,left:a,bottom:l,right:c,width:h,height:u}}}function ss(n,e,t){for(var i=je(n,!0),r=j(n)[e];i;){var o=j(i)[t],s=void 0;if(t==="top"||t==="left"?s=r>=o:s=r<=o,!s)return i;if(i===Se())break;i=je(i,!1)}return!1}function pt(n,e,t,i){for(var r=0,o=0,s=n.children;o<s.length;){if(s[o].style.display!=="none"&&s[o]!==$.ghost&&(i||s[o]!==$.dragged)&&xe(s[o],t.draggable,n,!1)){if(r===e)return s[o];r++}o++}return null}function zr(n,e){for(var t=n.lastElementChild;t&&(t===$.ghost||A(t,"display")==="none"||e&&!Dn(t,e));)t=t.previousElementSibling;return t||null}function Y(n,e){var t=0;if(!n||!n.parentNode)return-1;for(;n=n.previousElementSibling;)n.nodeName.toUpperCase()!=="TEMPLATE"&&n!==$.clone&&(!e||Dn(n,e))&&t++;return t}function as(n){var e=0,t=0,i=Se();if(n)do{var r=Xe(n),o=r.a,s=r.d;e+=n.scrollLeft*o,t+=n.scrollTop*s}while(n!==i&&(n=n.parentNode));return[e,t]}function fh(n,e){for(var t in n)if(n.hasOwnProperty(t)){for(var i in e)if(e.hasOwnProperty(i)&&e[i]===n[t][i])return Number(t)}return-1}function je(n,e){if(!n||!n.getBoundingClientRect)return Se();var t=n,i=!1;do if(t.clientWidth<t.scrollWidth||t.clientHeight<t.scrollHeight){var r=A(t);if(t.clientWidth<t.scrollWidth&&(r.overflowX=="auto"||r.overflowX=="scroll")||t.clientHeight<t.scrollHeight&&(r.overflowY=="auto"||r.overflowY=="scroll")){if(!t.getBoundingClientRect||t===document.body)return Se();if(i||e)return t;i=!0}}while(t=t.parentNode);return Se()}function mh(n,e){if(n&&e)for(var t in e)e.hasOwnProperty(t)&&(n[t]=e[t]);return n}function Sr(n,e){return Math.round(n.top)===Math.round(e.top)&&Math.round(n.left)===Math.round(e.left)&&Math.round(n.height)===Math.round(e.height)&&Math.round(n.width)===Math.round(e.width)}var Nt;function vs(n,e){return function(){if(!Nt){var t=arguments,i=this;t.length===1?n.call(i,t[0]):n.apply(i,t),Nt=setTimeout(function(){Nt=void 0},e)}}}function gh(){clearTimeout(Nt),Nt=void 0}function ws(n,e,t){n.scrollLeft+=e,n.scrollTop+=t}function Hr(n){var e=window.Polymer,t=window.jQuery||window.Zepto;return e&&e.dom?e.dom(n).cloneNode(!0):t?t(n).clone(!0)[0]:n.cloneNode(!0)}function ls(n,e){A(n,"position","absolute"),A(n,"top",e.top),A(n,"left",e.left),A(n,"width",e.width),A(n,"height",e.height)}function Ar(n){A(n,"position",""),A(n,"top",""),A(n,"left",""),A(n,"width",""),A(n,"height","")}var ne="Sortable"+new Date().getTime();function bh(){var n=[],e;return{captureAnimationState:function(){if(n=[],!!this.options.animation){var i=[].slice.call(this.el.children);i.forEach(function(r){if(!(A(r,"display")==="none"||r===$.ghost)){n.push({target:r,rect:j(r)});var o=Ae({},n[n.length-1].rect);if(r.thisAnimationDuration){var s=Xe(r,!0);s&&(o.top-=s.f,o.left-=s.e)}r.fromRect=o}})}},addAnimationState:function(i){n.push(i)},removeAnimationState:function(i){n.splice(fh(n,{target:i}),1)},animateAll:function(i){var r=this;if(!this.options.animation){clearTimeout(e),typeof i=="function"&&i();return}var o=!1,s=0;n.forEach(function(a){var l=0,c=a.target,u=c.fromRect,h=j(c),d=c.prevFromRect,p=c.prevToRect,f=a.rect,m=Xe(c,!0);m&&(h.top-=m.f,h.left-=m.e),c.toRect=h,c.thisAnimationDuration&&Sr(d,h)&&!Sr(u,h)&&(f.top-h.top)/(f.left-h.left)===(u.top-h.top)/(u.left-h.left)&&(l=wh(f,d,p,r.options)),Sr(h,u)||(c.prevFromRect=u,c.prevToRect=h,l||(l=r.options.animation),r.animate(c,f,h,l)),l&&(o=!0,s=Math.max(s,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(e),o?e=setTimeout(function(){typeof i=="function"&&i()},s):typeof i=="function"&&i(),n=[]},animate:function(i,r,o,s){if(s){A(i,"transition",""),A(i,"transform","");var a=Xe(this.el),l=a&&a.a,c=a&&a.d,u=(r.left-o.left)/(l||1),h=(r.top-o.top)/(c||1);i.animatingX=!!u,i.animatingY=!!h,A(i,"transform","translate3d("+u+"px,"+h+"px,0)"),this.forRepaintDummy=vh(i),A(i,"transition","transform "+s+"ms"+(this.options.easing?" "+this.options.easing:"")),A(i,"transform","translate3d(0,0,0)"),typeof i.animated=="number"&&clearTimeout(i.animated),i.animated=setTimeout(function(){A(i,"transition",""),A(i,"transform",""),i.animated=!1,i.animatingX=!1,i.animatingY=!1},s)}}}}function vh(n){return n.offsetWidth}function wh(n,e,t,i){return Math.sqrt(Math.pow(e.top-n.top,2)+Math.pow(e.left-n.left,2))/Math.sqrt(Math.pow(e.top-t.top,2)+Math.pow(e.left-t.left,2))*i.animation}var lt=[],Dr={initializeByDefault:!0},Vt={mount:function(e){for(var t in Dr)Dr.hasOwnProperty(t)&&!(t in e)&&(e[t]=Dr[t]);lt.forEach(function(i){if(i.pluginName===e.pluginName)throw"Sortable: Cannot mount plugin ".concat(e.pluginName," more than once")}),lt.push(e)},pluginEvent:function(e,t,i){var r=this;this.eventCanceled=!1,i.cancel=function(){r.eventCanceled=!0};var o=e+"Global";lt.forEach(function(s){t[s.pluginName]&&(t[s.pluginName][o]&&t[s.pluginName][o](Ae({sortable:t},i)),t.options[s.pluginName]&&t[s.pluginName][e]&&t[s.pluginName][e](Ae({sortable:t},i)))})},initializePlugins:function(e,t,i,r){lt.forEach(function(a){var l=a.pluginName;if(!(!e.options[l]&&!a.initializeByDefault)){var c=new a(e,t,e.options);c.sortable=e,c.options=e.options,e[l]=c,ke(i,c.defaults)}});for(var o in e.options)if(e.options.hasOwnProperty(o)){var s=this.modifyOption(e,o,e.options[o]);typeof s<"u"&&(e.options[o]=s)}},getEventProperties:function(e,t){var i={};return lt.forEach(function(r){typeof r.eventProperties=="function"&&ke(i,r.eventProperties.call(t[r.pluginName],e))}),i},modifyOption:function(e,t,i){var r;return lt.forEach(function(o){e[o.pluginName]&&o.optionListeners&&typeof o.optionListeners[t]=="function"&&(r=o.optionListeners[t].call(e[o.pluginName],i))}),r}};function qt(n){var e=n.sortable,t=n.rootEl,i=n.name,r=n.targetEl,o=n.cloneEl,s=n.toEl,a=n.fromEl,l=n.oldIndex,c=n.newIndex,u=n.oldDraggableIndex,h=n.newDraggableIndex,d=n.originalEvent,p=n.putSortable,f=n.extraEventProperties;if(e=e||t&&t[ne],!!e){var m,y=e.options,v="on"+i.charAt(0).toUpperCase()+i.substr(1);window.CustomEvent&&!Me&&!jt?m=new CustomEvent(i,{bubbles:!0,cancelable:!0}):(m=document.createEvent("Event"),m.initEvent(i,!0,!0)),m.to=s||t,m.from=a||t,m.item=r||t,m.clone=o,m.oldIndex=l,m.newIndex=c,m.oldDraggableIndex=u,m.newDraggableIndex=h,m.originalEvent=d,m.pullMode=p?p.lastPutMode:void 0;var b=Ae(Ae({},f),Vt.getEventProperties(i,e));for(var k in b)m[k]=b[k];t&&t.dispatchEvent(m),y[v]&&y[v].call(e,m)}}var yh=["evt"],ae=function(e,t){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=i.evt,o=sh(i,yh);Vt.pluginEvent.bind($)(e,t,Ae({dragEl:C,parentEl:G,ghostEl:F,rootEl:U,nextEl:Ze,lastDownEl:En,cloneEl:W,cloneHidden:Ue,dragStarted:Bt,putSortable:Q,activeSortable:$.active,originalEvent:r,oldIndex:dt,oldDraggableIndex:zt,newIndex:fe,newDraggableIndex:He,hideGhostForTarget:Cs,unhideGhostForTarget:Es,cloneNowHidden:function(){Ue=!0},cloneNowShown:function(){Ue=!1},dispatchSortableEvent:function(a){oe({sortable:t,name:a,originalEvent:r})}},o))};function oe(n){qt(Ae({putSortable:Q,cloneEl:W,targetEl:C,rootEl:U,oldIndex:dt,oldDraggableIndex:zt,newIndex:fe,newDraggableIndex:He},n))}var C,G,F,U,Ze,En,W,Ue,dt,fe,zt,He,bn,Q,ht=!1,Tn=!1,Ln=[],Ge,we,Tr,Lr,cs,us,Bt,ct,Ht,Ut=!1,vn=!1,_n,te,Ir=[],Pr=!1,In=[],Mn=typeof document<"u",wn=fs,hs=jt||Me?"cssFloat":"float",xh=Mn&&!ms&&!fs&&"draggable"in document.createElement("div"),ys=function(){if(Mn){if(Me)return!1;var n=document.createElement("x");return n.style.cssText="pointer-events:auto",n.style.pointerEvents==="auto"}}(),xs=function(e,t){var i=A(e),r=parseInt(i.width)-parseInt(i.paddingLeft)-parseInt(i.paddingRight)-parseInt(i.borderLeftWidth)-parseInt(i.borderRightWidth),o=pt(e,0,t),s=pt(e,1,t),a=o&&A(o),l=s&&A(s),c=a&&parseInt(a.marginLeft)+parseInt(a.marginRight)+j(o).width,u=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+j(s).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(o&&a.float&&a.float!=="none"){var h=a.float==="left"?"left":"right";return s&&(l.clear==="both"||l.clear===h)?"vertical":"horizontal"}return o&&(a.display==="block"||a.display==="flex"||a.display==="table"||a.display==="grid"||c>=r&&i[hs]==="none"||s&&i[hs]==="none"&&c+u>r)?"vertical":"horizontal"},kh=function(e,t,i){var r=i?e.left:e.top,o=i?e.right:e.bottom,s=i?e.width:e.height,a=i?t.left:t.top,l=i?t.right:t.bottom,c=i?t.width:t.height;return r===a||o===l||r+s/2===a+c/2},Ch=function(e,t){var i;return Ln.some(function(r){var o=r[ne].options.emptyInsertThreshold;if(!(!o||zr(r))){var s=j(r),a=e>=s.left-o&&e<=s.right+o,l=t>=s.top-o&&t<=s.bottom+o;if(a&&l)return i=r}}),i},ks=function(e){function t(o,s){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(o==null&&(s||h))return!0;if(o==null||o===!1)return!1;if(s&&o==="clone")return o;if(typeof o=="function")return t(o(a,l,c,u),s)(a,l,c,u);var d=(s?a:l).options.group.name;return o===!0||typeof o=="string"&&o===d||o.join&&o.indexOf(d)>-1}}var i={},r=e.group;(!r||Cn(r)!="object")&&(r={name:r}),i.name=r.name,i.checkPull=t(r.pull,!0),i.checkPut=t(r.put),i.revertClone=r.revertClone,e.group=i},Cs=function(){!ys&&F&&A(F,"display","none")},Es=function(){!ys&&F&&A(F,"display","")};Mn&&!ms&&document.addEventListener("click",function(n){if(Tn)return n.preventDefault(),n.stopPropagation&&n.stopPropagation(),n.stopImmediatePropagation&&n.stopImmediatePropagation(),Tn=!1,!1},!0);var Ke=function(e){if(C){e=e.touches?e.touches[0]:e;var t=Ch(e.clientX,e.clientY);if(t){var i={};for(var r in e)e.hasOwnProperty(r)&&(i[r]=e[r]);i.target=i.rootEl=t,i.preventDefault=void 0,i.stopPropagation=void 0,t[ne]._onDragOver(i)}}},Eh=function(e){C&&C.parentNode[ne]._isOutsideThisEl(e.target)};function $(n,e){if(!(n&&n.nodeType&&n.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(n));this.el=n,this.options=e=ke({},e),n[ne]=this;var t={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 xs(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(s,a){s.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:$.supportPointer!==!1&&"PointerEvent"in window&&!Rt,emptyInsertThreshold:5};Vt.initializePlugins(this,n,t);for(var i in t)!(i in e)&&(e[i]=t[i]);ks(e);for(var r in this)r.charAt(0)==="_"&&typeof this[r]=="function"&&(this[r]=this[r].bind(this));this.nativeDraggable=e.forceFallback?!1:xh,this.nativeDraggable&&(this.options.touchStartThreshold=1),e.supportPointer?P(n,"pointerdown",this._onTapStart):(P(n,"mousedown",this._onTapStart),P(n,"touchstart",this._onTapStart)),this.nativeDraggable&&(P(n,"dragover",this),P(n,"dragenter",this)),Ln.push(this.el),e.store&&e.store.get&&this.sort(e.store.get(this)||[]),ke(this,bh())}$.prototype={constructor:$,_isOutsideThisEl:function(e){!this.el.contains(e)&&e!==this.el&&(ct=null)},_getDirection:function(e,t){return typeof this.options.direction=="function"?this.options.direction.call(this,e,t,C):this.options.direction},_onTapStart:function(e){if(e.cancelable){var t=this,i=this.el,r=this.options,o=r.preventOnFilter,s=e.type,a=e.touches&&e.touches[0]||e.pointerType&&e.pointerType==="touch"&&e,l=(a||e).target,c=e.target.shadowRoot&&(e.path&&e.path[0]||e.composedPath&&e.composedPath()[0])||l,u=r.filter;if($h(i),!C&&!(/mousedown|pointerdown/.test(s)&&e.button!==0||r.disabled)&&!c.isContentEditable&&!(!this.nativeDraggable&&Rt&&l&&l.tagName.toUpperCase()==="SELECT")&&(l=xe(l,r.draggable,i,!1),!(l&&l.animated)&&En!==l)){if(dt=Y(l),zt=Y(l,r.draggable),typeof u=="function"){if(u.call(this,e,l,this)){oe({sortable:t,rootEl:c,name:"filter",targetEl:l,toEl:i,fromEl:i}),ae("filter",t,{evt:e}),o&&e.cancelable&&e.preventDefault();return}}else if(u&&(u=u.split(",").some(function(h){if(h=xe(c,h.trim(),i,!1),h)return oe({sortable:t,rootEl:h,name:"filter",targetEl:l,fromEl:i,toEl:i}),ae("filter",t,{evt:e}),!0}),u)){o&&e.cancelable&&e.preventDefault();return}r.handle&&!xe(c,r.handle,i,!1)||this._prepareDragStart(e,a,l)}}},_prepareDragStart:function(e,t,i){var r=this,o=r.el,s=r.options,a=o.ownerDocument,l;if(i&&!C&&i.parentNode===o){var c=j(i);if(U=o,C=i,G=C.parentNode,Ze=C.nextSibling,En=i,bn=s.group,$.dragged=C,Ge={target:C,clientX:(t||e).clientX,clientY:(t||e).clientY},cs=Ge.clientX-c.left,us=Ge.clientY-c.top,this._lastX=(t||e).clientX,this._lastY=(t||e).clientY,C.style["will-change"]="all",l=function(){if(ae("delayEnded",r,{evt:e}),$.eventCanceled){r._onDrop();return}r._disableDelayedDragEvents(),!rs&&r.nativeDraggable&&(C.draggable=!0),r._triggerDragStart(e,t),oe({sortable:r,name:"choose",originalEvent:e}),X(C,s.chosenClass,!0)},s.ignore.split(",").forEach(function(u){bs(C,u.trim(),$r)}),P(a,"dragover",Ke),P(a,"mousemove",Ke),P(a,"touchmove",Ke),P(a,"mouseup",r._onDrop),P(a,"touchend",r._onDrop),P(a,"touchcancel",r._onDrop),rs&&this.nativeDraggable&&(this.options.touchStartThreshold=4,C.draggable=!0),ae("delayStart",this,{evt:e}),s.delay&&(!s.delayOnTouchOnly||t)&&(!this.nativeDraggable||!(jt||Me))){if($.eventCanceled){this._onDrop();return}P(a,"mouseup",r._disableDelayedDrag),P(a,"touchend",r._disableDelayedDrag),P(a,"touchcancel",r._disableDelayedDrag),P(a,"mousemove",r._delayedDragTouchMoveHandler),P(a,"touchmove",r._delayedDragTouchMoveHandler),s.supportPointer&&P(a,"pointermove",r._delayedDragTouchMoveHandler),r._dragStartTimer=setTimeout(l,s.delay)}else l()}},_delayedDragTouchMoveHandler:function(e){var t=e.touches?e.touches[0]:e;Math.max(Math.abs(t.clientX-this._lastX),Math.abs(t.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){C&&$r(C),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var e=this.el.ownerDocument;B(e,"mouseup",this._disableDelayedDrag),B(e,"touchend",this._disableDelayedDrag),B(e,"touchcancel",this._disableDelayedDrag),B(e,"mousemove",this._delayedDragTouchMoveHandler),B(e,"touchmove",this._delayedDragTouchMoveHandler),B(e,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(e,t){t=t||e.pointerType=="touch"&&e,!this.nativeDraggable||t?this.options.supportPointer?P(document,"pointermove",this._onTouchMove):t?P(document,"touchmove",this._onTouchMove):P(document,"mousemove",this._onTouchMove):(P(C,"dragend",this),P(U,"dragstart",this._onDragStart));try{document.selection?Sn(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(e,t){if(ht=!1,U&&C){ae("dragStarted",this,{evt:t}),this.nativeDraggable&&P(document,"dragover",Eh);var i=this.options;!e&&X(C,i.dragClass,!1),X(C,i.ghostClass,!0),$.active=this,e&&this._appendGhost(),oe({sortable:this,name:"start",originalEvent:t})}else this._nulling()},_emulateDragOver:function(){if(we){this._lastX=we.clientX,this._lastY=we.clientY,Cs();for(var e=document.elementFromPoint(we.clientX,we.clientY),t=e;e&&e.shadowRoot&&(e=e.shadowRoot.elementFromPoint(we.clientX,we.clientY),e!==t);)t=e;if(C.parentNode[ne]._isOutsideThisEl(e),t)do{if(t[ne]){var i=void 0;if(i=t[ne]._onDragOver({clientX:we.clientX,clientY:we.clientY,target:e,rootEl:t}),i&&!this.options.dragoverBubble)break}e=t}while(t=t.parentNode);Es()}},_onTouchMove:function(e){if(Ge){var t=this.options,i=t.fallbackTolerance,r=t.fallbackOffset,o=e.touches?e.touches[0]:e,s=F&&Xe(F,!0),a=F&&s&&s.a,l=F&&s&&s.d,c=wn&&te&&as(te),u=(o.clientX-Ge.clientX+r.x)/(a||1)+(c?c[0]-Ir[0]:0)/(a||1),h=(o.clientY-Ge.clientY+r.y)/(l||1)+(c?c[1]-Ir[1]:0)/(l||1);if(!$.active&&!ht){if(i&&Math.max(Math.abs(o.clientX-this._lastX),Math.abs(o.clientY-this._lastY))<i)return;this._onDragStart(e,!0)}if(F){s?(s.e+=u-(Tr||0),s.f+=h-(Lr||0)):s={a:1,b:0,c:0,d:1,e:u,f:h};var d="matrix(".concat(s.a,",").concat(s.b,",").concat(s.c,",").concat(s.d,",").concat(s.e,",").concat(s.f,")");A(F,"webkitTransform",d),A(F,"mozTransform",d),A(F,"msTransform",d),A(F,"transform",d),Tr=u,Lr=h,we=o}e.cancelable&&e.preventDefault()}},_appendGhost:function(){if(!F){var e=this.options.fallbackOnBody?document.body:U,t=j(C,!0,wn,!0,e),i=this.options;if(wn){for(te=e;A(te,"position")==="static"&&A(te,"transform")==="none"&&te!==document;)te=te.parentNode;te!==document.body&&te!==document.documentElement?(te===document&&(te=Se()),t.top+=te.scrollTop,t.left+=te.scrollLeft):te=Se(),Ir=as(te)}F=C.cloneNode(!0),X(F,i.ghostClass,!1),X(F,i.fallbackClass,!0),X(F,i.dragClass,!0),A(F,"transition",""),A(F,"transform",""),A(F,"box-sizing","border-box"),A(F,"margin",0),A(F,"top",t.top),A(F,"left",t.left),A(F,"width",t.width),A(F,"height",t.height),A(F,"opacity","0.8"),A(F,"position",wn?"absolute":"fixed"),A(F,"zIndex","100000"),A(F,"pointerEvents","none"),$.ghost=F,e.appendChild(F),A(F,"transform-origin",cs/parseInt(F.style.width)*100+"% "+us/parseInt(F.style.height)*100+"%")}},_onDragStart:function(e,t){var i=this,r=e.dataTransfer,o=i.options;if(ae("dragStart",this,{evt:e}),$.eventCanceled){this._onDrop();return}ae("setupClone",this),$.eventCanceled||(W=Hr(C),W.removeAttribute("id"),W.draggable=!1,W.style["will-change"]="",this._hideClone(),X(W,this.options.chosenClass,!1),$.clone=W),i.cloneId=Sn(function(){ae("clone",i),!$.eventCanceled&&(i.options.removeCloneOnHide||U.insertBefore(W,C),i._hideClone(),oe({sortable:i,name:"clone"}))}),!t&&X(C,o.dragClass,!0),t?(Tn=!0,i._loopId=setInterval(i._emulateDragOver,50)):(B(document,"mouseup",i._onDrop),B(document,"touchend",i._onDrop),B(document,"touchcancel",i._onDrop),r&&(r.effectAllowed="move",o.setData&&o.setData.call(i,r,C)),P(document,"drop",i),A(C,"transform","translateZ(0)")),ht=!0,i._dragStartId=Sn(i._dragStarted.bind(i,t,e)),P(document,"selectstart",i),Bt=!0,Rt&&A(document.body,"user-select","none")},_onDragOver:function(e){var t=this.el,i=e.target,r,o,s,a=this.options,l=a.group,c=$.active,u=bn===l,h=a.sort,d=Q||c,p,f=this,m=!1;if(Pr)return;function y(Re,Du){ae(Re,f,Ae({evt:e,isOwner:u,axis:p?"vertical":"horizontal",revert:s,dragRect:r,targetRect:o,canSort:h,fromSortable:d,target:i,completed:b,onMove:function(jo,Tu){return yn(U,t,C,r,jo,j(jo),e,Tu)},changed:k},Du))}function v(){y("dragOverAnimationCapture"),f.captureAnimationState(),f!==d&&d.captureAnimationState()}function b(Re){return y("dragOverCompleted",{insertion:Re}),Re&&(u?c._hideClone():c._showClone(f),f!==d&&(X(C,Q?Q.options.ghostClass:c.options.ghostClass,!1),X(C,a.ghostClass,!0)),Q!==f&&f!==$.active?Q=f:f===$.active&&Q&&(Q=null),d===f&&(f._ignoreWhileAnimating=i),f.animateAll(function(){y("dragOverAnimationComplete"),f._ignoreWhileAnimating=null}),f!==d&&(d.animateAll(),d._ignoreWhileAnimating=null)),(i===C&&!C.animated||i===t&&!i.animated)&&(ct=null),!a.dragoverBubble&&!e.rootEl&&i!==document&&(C.parentNode[ne]._isOutsideThisEl(e.target),!Re&&Ke(e)),!a.dragoverBubble&&e.stopPropagation&&e.stopPropagation(),m=!0}function k(){fe=Y(C),He=Y(C,a.draggable),oe({sortable:f,name:"change",toEl:t,newIndex:fe,newDraggableIndex:He,originalEvent:e})}if(e.preventDefault!==void 0&&e.cancelable&&e.preventDefault(),i=xe(i,a.draggable,t,!0),y("dragOver"),$.eventCanceled)return m;if(C.contains(e.target)||i.animated&&i.animatingX&&i.animatingY||f._ignoreWhileAnimating===i)return b(!1);if(Tn=!1,c&&!a.disabled&&(u?h||(s=G!==U):Q===this||(this.lastPutMode=bn.checkPull(this,c,C,e))&&l.checkPut(this,c,C,e))){if(p=this._getDirection(e,i)==="vertical",r=j(C),y("dragOverValid"),$.eventCanceled)return m;if(s)return G=U,v(),this._hideClone(),y("revert"),$.eventCanceled||(Ze?U.insertBefore(C,Ze):U.appendChild(C)),b(!0);var w=zr(t,a.draggable);if(!w||Dh(e,p,this)&&!w.animated){if(w===C)return b(!1);if(w&&t===e.target&&(i=w),i&&(o=j(i)),yn(U,t,C,r,i,o,e,!!i)!==!1)return v(),w&&w.nextSibling?t.insertBefore(C,w.nextSibling):t.appendChild(C),G=t,k(),b(!0)}else if(w&&Ah(e,p,this)){var E=pt(t,0,a,!0);if(E===C)return b(!1);if(i=E,o=j(i),yn(U,t,C,r,i,o,e,!1)!==!1)return v(),t.insertBefore(C,E),G=t,k(),b(!0)}else if(i.parentNode===t){o=j(i);var x=0,S,D=C.parentNode!==t,q=!kh(C.animated&&C.toRect||r,i.animated&&i.toRect||o,p),L=p?"top":"left",I=ss(i,"top","top")||ss(C,"top","top"),H=I?I.scrollTop:void 0;ct!==i&&(S=o[L],Ut=!1,vn=!q&&a.invertSwap||D),x=Th(e,i,o,p,q?1:a.swapThreshold,a.invertedSwapThreshold==null?a.swapThreshold:a.invertedSwapThreshold,vn,ct===i);var N;if(x!==0){var ee=Y(C);do ee-=x,N=G.children[ee];while(N&&(A(N,"display")==="none"||N===F))}if(x===0||N===i)return b(!1);ct=i,Ht=x;var ge=i.nextElementSibling,V=!1;V=x===1;var Oe=yn(U,t,C,r,i,o,e,V);if(Oe!==!1)return(Oe===1||Oe===-1)&&(V=Oe===1),Pr=!0,setTimeout(Sh,30),v(),V&&!ge?t.appendChild(C):i.parentNode.insertBefore(C,V?ge:i),I&&ws(I,0,H-I.scrollTop),G=C.parentNode,S!==void 0&&!vn&&(_n=Math.abs(S-j(i)[L])),k(),b(!0)}if(t.contains(C))return b(!1)}return!1},_ignoreWhileAnimating:null,_offMoveEvents:function(){B(document,"mousemove",this._onTouchMove),B(document,"touchmove",this._onTouchMove),B(document,"pointermove",this._onTouchMove),B(document,"dragover",Ke),B(document,"mousemove",Ke),B(document,"touchmove",Ke)},_offUpEvents:function(){var e=this.el.ownerDocument;B(e,"mouseup",this._onDrop),B(e,"touchend",this._onDrop),B(e,"pointerup",this._onDrop),B(e,"touchcancel",this._onDrop),B(document,"selectstart",this)},_onDrop:function(e){var t=this.el,i=this.options;if(fe=Y(C),He=Y(C,i.draggable),ae("drop",this,{evt:e}),G=C&&C.parentNode,fe=Y(C),He=Y(C,i.draggable),$.eventCanceled){this._nulling();return}ht=!1,vn=!1,Ut=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),Or(this.cloneId),Or(this._dragStartId),this.nativeDraggable&&(B(document,"drop",this),B(t,"dragstart",this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),Rt&&A(document.body,"user-select",""),A(C,"transform",""),e&&(Bt&&(e.cancelable&&e.preventDefault(),!i.dropBubble&&e.stopPropagation()),F&&F.parentNode&&F.parentNode.removeChild(F),(U===G||Q&&Q.lastPutMode!=="clone")&&W&&W.parentNode&&W.parentNode.removeChild(W),C&&(this.nativeDraggable&&B(C,"dragend",this),$r(C),C.style["will-change"]="",Bt&&!ht&&X(C,Q?Q.options.ghostClass:this.options.ghostClass,!1),X(C,this.options.chosenClass,!1),oe({sortable:this,name:"unchoose",toEl:G,newIndex:null,newDraggableIndex:null,originalEvent:e}),U!==G?(fe>=0&&(oe({rootEl:G,name:"add",toEl:G,fromEl:U,originalEvent:e}),oe({sortable:this,name:"remove",toEl:G,originalEvent:e}),oe({rootEl:G,name:"sort",toEl:G,fromEl:U,originalEvent:e}),oe({sortable:this,name:"sort",toEl:G,originalEvent:e})),Q&&Q.save()):fe!==dt&&fe>=0&&(oe({sortable:this,name:"update",toEl:G,originalEvent:e}),oe({sortable:this,name:"sort",toEl:G,originalEvent:e})),$.active&&((fe==null||fe===-1)&&(fe=dt,He=zt),oe({sortable:this,name:"end",toEl:G,originalEvent:e}),this.save()))),this._nulling()},_nulling:function(){ae("nulling",this),U=C=G=F=Ze=W=En=Ue=Ge=we=Bt=fe=He=dt=zt=ct=Ht=Q=bn=$.dragged=$.ghost=$.clone=$.active=null,In.forEach(function(e){e.checked=!0}),In.length=Tr=Lr=0},handleEvent:function(e){switch(e.type){case"drop":case"dragend":this._onDrop(e);break;case"dragenter":case"dragover":C&&(this._onDragOver(e),_h(e));break;case"selectstart":e.preventDefault();break}},toArray:function(){for(var e=[],t,i=this.el.children,r=0,o=i.length,s=this.options;r<o;r++)t=i[r],xe(t,s.draggable,this.el,!1)&&e.push(t.getAttribute(s.dataIdAttr)||Ih(t));return e},sort:function(e,t){var i={},r=this.el;this.toArray().forEach(function(o,s){var a=r.children[s];xe(a,this.options.draggable,r,!1)&&(i[o]=a)},this),t&&this.captureAnimationState(),e.forEach(function(o){i[o]&&(r.removeChild(i[o]),r.appendChild(i[o]))}),t&&this.animateAll()},save:function(){var e=this.options.store;e&&e.set&&e.set(this)},closest:function(e,t){return xe(e,t||this.options.draggable,this.el,!1)},option:function(e,t){var i=this.options;if(t===void 0)return i[e];var r=Vt.modifyOption(this,e,t);typeof r<"u"?i[e]=r:i[e]=t,e==="group"&&ks(i)},destroy:function(){ae("destroy",this);var e=this.el;e[ne]=null,B(e,"mousedown",this._onTapStart),B(e,"touchstart",this._onTapStart),B(e,"pointerdown",this._onTapStart),this.nativeDraggable&&(B(e,"dragover",this),B(e,"dragenter",this)),Array.prototype.forEach.call(e.querySelectorAll("[draggable]"),function(t){t.removeAttribute("draggable")}),this._onDrop(),this._disableDelayedDragEvents(),Ln.splice(Ln.indexOf(this.el),1),this.el=e=null},_hideClone:function(){if(!Ue){if(ae("hideClone",this),$.eventCanceled)return;A(W,"display","none"),this.options.removeCloneOnHide&&W.parentNode&&W.parentNode.removeChild(W),Ue=!0}},_showClone:function(e){if(e.lastPutMode!=="clone"){this._hideClone();return}if(Ue){if(ae("showClone",this),$.eventCanceled)return;C.parentNode==U&&!this.options.group.revertClone?U.insertBefore(W,C):Ze?U.insertBefore(W,Ze):U.appendChild(W),this.options.group.revertClone&&this.animate(C,W),A(W,"display",""),Ue=!1}}};function _h(n){n.dataTransfer&&(n.dataTransfer.dropEffect="move"),n.cancelable&&n.preventDefault()}function yn(n,e,t,i,r,o,s,a){var l,c=n[ne],u=c.options.onMove,h;return window.CustomEvent&&!Me&&!jt?l=new CustomEvent("move",{bubbles:!0,cancelable:!0}):(l=document.createEvent("Event"),l.initEvent("move",!0,!0)),l.to=e,l.from=n,l.dragged=t,l.draggedRect=i,l.related=r||e,l.relatedRect=o||j(e),l.willInsertAfter=a,l.originalEvent=s,n.dispatchEvent(l),u&&(h=u.call(c,l,s)),h}function $r(n){n.draggable=!1}function Sh(){Pr=!1}function Ah(n,e,t){var i=j(pt(t.el,0,t.options,!0)),r=10;return e?n.clientX<i.left-r||n.clientY<i.top&&n.clientX<i.right:n.clientY<i.top-r||n.clientY<i.bottom&&n.clientX<i.left}function Dh(n,e,t){var i=j(zr(t.el,t.options.draggable)),r=10;return e?n.clientX>i.right+r||n.clientX<=i.right&&n.clientY>i.bottom&&n.clientX>=i.left:n.clientX>i.right&&n.clientY>i.top||n.clientX<=i.right&&n.clientY>i.bottom+r}function Th(n,e,t,i,r,o,s,a){var l=i?n.clientY:n.clientX,c=i?t.height:t.width,u=i?t.top:t.left,h=i?t.bottom:t.right,d=!1;if(!s){if(a&&_n<c*r){if(!Ut&&(Ht===1?l>u+c*o/2:l<h-c*o/2)&&(Ut=!0),Ut)d=!0;else if(Ht===1?l<u+_n:l>h-_n)return-Ht}else if(l>u+c*(1-r)/2&&l<h-c*(1-r)/2)return Lh(e)}return d=d||s,d&&(l<u+c*o/2||l>h-c*o/2)?l>u+c/2?1:-1:0}function Lh(n){return Y(C)<Y(n)?1:-1}function Ih(n){for(var e=n.tagName+n.className+n.src+n.href+n.textContent,t=e.length,i=0;t--;)i+=e.charCodeAt(t);return i.toString(36)}function $h(n){In.length=0;for(var e=n.getElementsByTagName("input"),t=e.length;t--;){var i=e[t];i.checked&&In.push(i)}}function Sn(n){return setTimeout(n,0)}function Or(n){return clearTimeout(n)}Mn&&P(document,"touchmove",function(n){($.active||ht)&&n.cancelable&&n.preventDefault()});$.utils={on:P,off:B,css:A,find:bs,is:function(e,t){return!!xe(e,t,e,!1)},extend:mh,throttle:vs,closest:xe,toggleClass:X,clone:Hr,index:Y,nextTick:Sn,cancelNextTick:Or,detectDirection:xs,getChild:pt};$.get=function(n){return n[ne]};$.mount=function(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];e[0].constructor===Array&&(e=e[0]),e.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&&($.utils=Ae(Ae({},$.utils),i.utils)),Vt.mount(i)})};$.create=function(n,e){return new $(n,e)};$.version=dh;var Z=[],Pt,Rr,Nr=!1,Mr,Fr,$n,Ot;function Mh(){function n(){this.defaults={scroll:!0,forceAutoScrollFallback:!1,scrollSensitivity:30,scrollSpeed:10,bubbleScroll:!0};for(var e in this)e.charAt(0)==="_"&&typeof this[e]=="function"&&(this[e]=this[e].bind(this))}return n.prototype={dragStarted:function(t){var i=t.originalEvent;this.sortable.nativeDraggable?P(document,"dragover",this._handleAutoScroll):this.options.supportPointer?P(document,"pointermove",this._handleFallbackAutoScroll):i.touches?P(document,"touchmove",this._handleFallbackAutoScroll):P(document,"mousemove",this._handleFallbackAutoScroll)},dragOverCompleted:function(t){var i=t.originalEvent;!this.options.dragOverBubble&&!i.rootEl&&this._handleAutoScroll(i)},drop:function(){this.sortable.nativeDraggable?B(document,"dragover",this._handleAutoScroll):(B(document,"pointermove",this._handleFallbackAutoScroll),B(document,"touchmove",this._handleFallbackAutoScroll),B(document,"mousemove",this._handleFallbackAutoScroll)),ds(),An(),gh()},nulling:function(){$n=Rr=Pt=Nr=Ot=Mr=Fr=null,Z.length=0},_handleFallbackAutoScroll:function(t){this._handleAutoScroll(t,!0)},_handleAutoScroll:function(t,i){var r=this,o=(t.touches?t.touches[0]:t).clientX,s=(t.touches?t.touches[0]:t).clientY,a=document.elementFromPoint(o,s);if($n=t,i||this.options.forceAutoScrollFallback||jt||Me||Rt){qr(t,this.options,a,i);var l=je(a,!0);Nr&&(!Ot||o!==Mr||s!==Fr)&&(Ot&&ds(),Ot=setInterval(function(){var c=je(document.elementFromPoint(o,s),!0);c!==l&&(l=c,An()),qr(t,r.options,c,i)},10),Mr=o,Fr=s)}else{if(!this.options.bubbleScroll||je(a,!0)===Se()){An();return}qr(t,this.options,je(a,!1),!1)}}},ke(n,{pluginName:"scroll",initializeByDefault:!0})}function An(){Z.forEach(function(n){clearInterval(n.pid)}),Z=[]}function ds(){clearInterval(Ot)}var qr=vs(function(n,e,t,i){if(e.scroll){var r=(n.touches?n.touches[0]:n).clientX,o=(n.touches?n.touches[0]:n).clientY,s=e.scrollSensitivity,a=e.scrollSpeed,l=Se(),c=!1,u;Rr!==t&&(Rr=t,An(),Pt=e.scroll,u=e.scrollFn,Pt===!0&&(Pt=je(t,!0)));var h=0,d=Pt;do{var p=d,f=j(p),m=f.top,y=f.bottom,v=f.left,b=f.right,k=f.width,w=f.height,E=void 0,x=void 0,S=p.scrollWidth,D=p.scrollHeight,q=A(p),L=p.scrollLeft,I=p.scrollTop;p===l?(E=k<S&&(q.overflowX==="auto"||q.overflowX==="scroll"||q.overflowX==="visible"),x=w<D&&(q.overflowY==="auto"||q.overflowY==="scroll"||q.overflowY==="visible")):(E=k<S&&(q.overflowX==="auto"||q.overflowX==="scroll"),x=w<D&&(q.overflowY==="auto"||q.overflowY==="scroll"));var H=E&&(Math.abs(b-r)<=s&&L+k<S)-(Math.abs(v-r)<=s&&!!L),N=x&&(Math.abs(y-o)<=s&&I+w<D)-(Math.abs(m-o)<=s&&!!I);if(!Z[h])for(var ee=0;ee<=h;ee++)Z[ee]||(Z[ee]={});(Z[h].vx!=H||Z[h].vy!=N||Z[h].el!==p)&&(Z[h].el=p,Z[h].vx=H,Z[h].vy=N,clearInterval(Z[h].pid),(H!=0||N!=0)&&(c=!0,Z[h].pid=setInterval(function(){i&&this.layer===0&&$.active._onTouchMove($n);var ge=Z[this.layer].vy?Z[this.layer].vy*a:0,V=Z[this.layer].vx?Z[this.layer].vx*a:0;typeof u=="function"&&u.call($.dragged.parentNode[ne],V,ge,n,$n,Z[this.layer].el)!=="continue"||ws(Z[this.layer].el,V,ge)}.bind({layer:h}),24))),h++}while(e.bubbleScroll&&d!==l&&(d=je(d,!1)));Nr=c}},30),_s=function(e){var t=e.originalEvent,i=e.putSortable,r=e.dragEl,o=e.activeSortable,s=e.dispatchSortableEvent,a=e.hideGhostForTarget,l=e.unhideGhostForTarget;if(t){var c=i||o;a();var u=t.changedTouches&&t.changedTouches.length?t.changedTouches[0]:t,h=document.elementFromPoint(u.clientX,u.clientY);l(),c&&!c.el.contains(h)&&(s("spill"),this.onSpill({dragEl:r,putSortable:i}))}};function Ur(){}Ur.prototype={startIndex:null,dragStart:function(e){var t=e.oldDraggableIndex;this.startIndex=t},onSpill:function(e){var t=e.dragEl,i=e.putSortable;this.sortable.captureAnimationState(),i&&i.captureAnimationState();var r=pt(this.sortable.el,this.startIndex,this.options);r?this.sortable.el.insertBefore(t,r):this.sortable.el.appendChild(t),this.sortable.animateAll(),i&&i.animateAll()},drop:_s};ke(Ur,{pluginName:"revertOnSpill"});function jr(){}jr.prototype={onSpill:function(e){var t=e.dragEl,i=e.putSortable,r=i||this.sortable;r.captureAnimationState(),t.parentNode&&t.parentNode.removeChild(t),r.animateAll()},drop:_s};ke(jr,{pluginName:"removeOnSpill"});var M=[],pe=[],$t,ye,Mt=!1,le=!1,ut=!1,z,Ft,xn;function Ss(){function n(e){for(var t in this)t.charAt(0)==="_"&&typeof this[t]=="function"&&(this[t]=this[t].bind(this));e.options.avoidImplicitDeselect||(e.options.supportPointer?P(document,"pointerup",this._deselectMultiDrag):(P(document,"mouseup",this._deselectMultiDrag),P(document,"touchend",this._deselectMultiDrag))),P(document,"keydown",this._checkKeyDown),P(document,"keyup",this._checkKeyUp),this.defaults={selectedClass:"sortable-selected",multiDragKey:null,avoidImplicitDeselect:!1,setData:function(r,o){var s="";M.length&&ye===e?M.forEach(function(a,l){s+=(l?", ":"")+a.textContent}):s=o.textContent,r.setData("Text",s)}}}return n.prototype={multiDragKeyDown:!1,isMultiDrag:!1,delayStartGlobal:function(t){var i=t.dragEl;z=i},delayEnded:function(){this.isMultiDrag=~M.indexOf(z)},setupClone:function(t){var i=t.sortable,r=t.cancel;if(this.isMultiDrag){for(var o=0;o<M.length;o++)pe.push(Hr(M[o])),pe[o].sortableIndex=M[o].sortableIndex,pe[o].draggable=!1,pe[o].style["will-change"]="",X(pe[o],this.options.selectedClass,!1),M[o]===z&&X(pe[o],this.options.chosenClass,!1);i._hideClone(),r()}},clone:function(t){var i=t.sortable,r=t.rootEl,o=t.dispatchSortableEvent,s=t.cancel;this.isMultiDrag&&(this.options.removeCloneOnHide||M.length&&ye===i&&(ps(!0,r),o("clone"),s()))},showClone:function(t){var i=t.cloneNowShown,r=t.rootEl,o=t.cancel;this.isMultiDrag&&(ps(!1,r),pe.forEach(function(s){A(s,"display","")}),i(),xn=!1,o())},hideClone:function(t){var i=this,r=t.sortable,o=t.cloneNowHidden,s=t.cancel;this.isMultiDrag&&(pe.forEach(function(a){A(a,"display","none"),i.options.removeCloneOnHide&&a.parentNode&&a.parentNode.removeChild(a)}),o(),xn=!0,s())},dragStartGlobal:function(t){var i=t.sortable;!this.isMultiDrag&&ye&&ye.multiDrag._deselectMultiDrag(),M.forEach(function(r){r.sortableIndex=Y(r)}),M=M.sort(function(r,o){return r.sortableIndex-o.sortableIndex}),ut=!0},dragStarted:function(t){var i=this,r=t.sortable;if(this.isMultiDrag){if(this.options.sort&&(r.captureAnimationState(),this.options.animation)){M.forEach(function(s){s!==z&&A(s,"position","absolute")});var o=j(z,!1,!0,!0);M.forEach(function(s){s!==z&&ls(s,o)}),le=!0,Mt=!0}r.animateAll(function(){le=!1,Mt=!1,i.options.animation&&M.forEach(function(s){Ar(s)}),i.options.sort&&kn()})}},dragOver:function(t){var i=t.target,r=t.completed,o=t.cancel;le&&~M.indexOf(i)&&(r(!1),o())},revert:function(t){var i=t.fromSortable,r=t.rootEl,o=t.sortable,s=t.dragRect;M.length>1&&(M.forEach(function(a){o.addAnimationState({target:a,rect:le?j(a):s}),Ar(a),a.fromRect=s,i.removeAnimationState(a)}),le=!1,Fh(!this.options.removeCloneOnHide,r))},dragOverCompleted:function(t){var i=t.sortable,r=t.isOwner,o=t.insertion,s=t.activeSortable,a=t.parentEl,l=t.putSortable,c=this.options;if(o){if(r&&s._hideClone(),Mt=!1,c.animation&&M.length>1&&(le||!r&&!s.options.sort&&!l)){var u=j(z,!1,!0,!0);M.forEach(function(d){d!==z&&(ls(d,u),a.appendChild(d))}),le=!0}if(!r)if(le||kn(),M.length>1){var h=xn;s._showClone(i),s.options.animation&&!xn&&h&&pe.forEach(function(d){s.addAnimationState({target:d,rect:Ft}),d.fromRect=Ft,d.thisAnimationDuration=null})}else s._showClone(i)}},dragOverAnimationCapture:function(t){var i=t.dragRect,r=t.isOwner,o=t.activeSortable;if(M.forEach(function(a){a.thisAnimationDuration=null}),o.options.animation&&!r&&o.multiDrag.isMultiDrag){Ft=ke({},i);var s=Xe(z,!0);Ft.top-=s.f,Ft.left-=s.e}},dragOverAnimationComplete:function(){le&&(le=!1,kn())},drop:function(t){var i=t.originalEvent,r=t.rootEl,o=t.parentEl,s=t.sortable,a=t.dispatchSortableEvent,l=t.oldIndex,c=t.putSortable,u=c||this.sortable;if(i){var h=this.options,d=o.children;if(!ut)if(h.multiDragKey&&!this.multiDragKeyDown&&this._deselectMultiDrag(),X(z,h.selectedClass,!~M.indexOf(z)),~M.indexOf(z))M.splice(M.indexOf(z),1),$t=null,qt({sortable:s,rootEl:r,name:"deselect",targetEl:z,originalEvent:i});else{if(M.push(z),qt({sortable:s,rootEl:r,name:"select",targetEl:z,originalEvent:i}),i.shiftKey&&$t&&s.el.contains($t)){var p=Y($t),f=Y(z);if(~p&&~f&&p!==f){var m,y;for(f>p?(y=p,m=f):(y=f,m=p+1);y<m;y++)~M.indexOf(d[y])||(X(d[y],h.selectedClass,!0),M.push(d[y]),qt({sortable:s,rootEl:r,name:"select",targetEl:d[y],originalEvent:i}))}}else $t=z;ye=u}if(ut&&this.isMultiDrag){if(le=!1,(o[ne].options.sort||o!==r)&&M.length>1){var v=j(z),b=Y(z,":not(."+this.options.selectedClass+")");if(!Mt&&h.animation&&(z.thisAnimationDuration=null),u.captureAnimationState(),!Mt&&(h.animation&&(z.fromRect=v,M.forEach(function(w){if(w.thisAnimationDuration=null,w!==z){var E=le?j(w):v;w.fromRect=E,u.addAnimationState({target:w,rect:E})}})),kn(),M.forEach(function(w){d[b]?o.insertBefore(w,d[b]):o.appendChild(w),b++}),l===Y(z))){var k=!1;M.forEach(function(w){if(w.sortableIndex!==Y(w)){k=!0;return}}),k&&a("update")}M.forEach(function(w){Ar(w)}),u.animateAll()}ye=u}(r===o||c&&c.lastPutMode!=="clone")&&pe.forEach(function(w){w.parentNode&&w.parentNode.removeChild(w)})}},nullingGlobal:function(){this.isMultiDrag=ut=!1,pe.length=0},destroyGlobal:function(){this._deselectMultiDrag(),B(document,"pointerup",this._deselectMultiDrag),B(document,"mouseup",this._deselectMultiDrag),B(document,"touchend",this._deselectMultiDrag),B(document,"keydown",this._checkKeyDown),B(document,"keyup",this._checkKeyUp)},_deselectMultiDrag:function(t){if(!(typeof ut<"u"&&ut)&&ye===this.sortable&&!(t&&xe(t.target,this.options.draggable,this.sortable.el,!1))&&!(t&&t.button!==0))for(;M.length;){var i=M[0];X(i,this.options.selectedClass,!1),M.shift(),qt({sortable:this.sortable,rootEl:this.sortable.el,name:"deselect",targetEl:i,originalEvent:t})}},_checkKeyDown:function(t){t.key===this.options.multiDragKey&&(this.multiDragKeyDown=!0)},_checkKeyUp:function(t){t.key===this.options.multiDragKey&&(this.multiDragKeyDown=!1)}},ke(n,{pluginName:"multiDrag",utils:{select:function(t){var i=t.parentNode[ne];!i||!i.options.multiDrag||~M.indexOf(t)||(ye&&ye!==i&&(ye.multiDrag._deselectMultiDrag(),ye=i),X(t,i.options.selectedClass,!0),M.push(t))},deselect:function(t){var i=t.parentNode[ne],r=M.indexOf(t);!i||!i.options.multiDrag||!~r||(X(t,i.options.selectedClass,!1),M.splice(r,1))}},eventProperties:function(){var t=this,i=[],r=[];return M.forEach(function(o){i.push({multiDragElement:o,index:o.sortableIndex});var s;le&&o!==z?s=-1:le?s=Y(o,":not(."+t.options.selectedClass+")"):s=Y(o),r.push({multiDragElement:o,index:s})}),{items:ah(M),clones:[].concat(pe),oldIndicies:i,newIndicies:r}},optionListeners:{multiDragKey:function(t){return t=t.toLowerCase(),t==="ctrl"?t="Control":t.length>1&&(t=t.charAt(0).toUpperCase()+t.substr(1)),t}}})}function Fh(n,e){M.forEach(function(t,i){var r=e.children[t.sortableIndex+(n?Number(i):0)];r?e.insertBefore(t,r):e.appendChild(t)})}function ps(n,e){pe.forEach(function(t,i){var r=e.children[t.sortableIndex+(n?Number(i):0)];r?e.insertBefore(t,r):e.appendChild(t)})}function kn(){M.forEach(function(n){n!==z&&n.parentNode&&n.parentNode.removeChild(n)})}$.mount(new Mh);$.mount(jr,Ur);var Ye=$;var As={name(n,e){let t=n.getAttribute("data-name").trim().toLowerCase(),i=e.getAttribute("data-name").trim().toLowerCase();return t.localeCompare(i)},created(n,e){let t=Number(n.getAttribute("data-created"));return Number(e.getAttribute("data-created"))-t},updated(n,e){let t=Number(n.getAttribute("data-updated"));return Number(e.getAttribute("data-updated"))-t},chaptersFirst(n,e){let t=n.getAttribute("data-type"),i=e.getAttribute("data-type");return t===i?0:t==="chapter"?-1:1},chaptersLast(n,e){let t=n.getAttribute("data-type"),i=e.getAttribute("data-type");return t===i?0:t==="chapter"?1:-1}},Ds={up:{active(n,e){return!(n.previousElementSibling===null&&!e)},run(n,e){(n.previousElementSibling||e).insertAdjacentElement("beforebegin",n)}},down:{active(n,e){return!(n.nextElementSibling===null&&!e)},run(n,e){(n.nextElementSibling||e).insertAdjacentElement("afterend",n)}},next_book:{active(n,e,t){return t.nextElementSibling!==null},run(n,e,t){t.nextElementSibling.querySelector("ul").prepend(n)}},prev_book:{active(n,e,t){return t.previousElementSibling!==null},run(n,e,t){t.previousElementSibling.querySelector("ul").appendChild(n)}},next_chapter:{active(n,e){return n.dataset.type==="page"&&this.getNextChapter(n,e)},run(n,e){this.getNextChapter(n,e).querySelector("ul").prepend(n)},getNextChapter(n,e){let t=e||n,i=Array.from(t.parentElement.children),r=i.indexOf(t);return i.slice(r+1).find(o=>o.dataset.type==="chapter")}},prev_chapter:{active(n,e){return n.dataset.type==="page"&&this.getPrevChapter(n,e)},run(n,e){this.getPrevChapter(n,e).querySelector("ul").append(n)},getPrevChapter(n,e){let t=e||n,i=Array.from(t.parentElement.children),r=i.indexOf(t);return i.slice(0,r).reverse().find(o=>o.dataset.type==="chapter")}},book_end:{active(n,e){return e||e===null&&n.nextElementSibling},run(n,e,t){t.querySelector("ul").append(n)}},book_start:{active(n,e){return e||e===null&&n.previousElementSibling},run(n,e,t){t.querySelector("ul").prepend(n)}},before_chapter:{active(n,e){return e},run(n,e){e.insertAdjacentElement("beforebegin",n)}},after_chapter:{active(n,e){return e},run(n,e){e.insertAdjacentElement("afterend",n)}}},Fn=class extends g{setup(){this.container=this.$el,this.sortContainer=this.$refs.sortContainer,this.input=this.$refs.input,Ye.mount(new Ss);let e=this.container.querySelector(".sort-box");this.setupBookSortable(e),this.setupSortPresets(),this.setupMoveActions(),window.$events.listen("entity-select-change",this.bookSelect.bind(this))}setupMoveActions(){this.container.addEventListener("click",e=>{if(e.target.matches("[data-move]")){let t=e.target.getAttribute("data-move"),i=e.target.closest("[data-id]");this.runSortAction(i,t)}}),this.updateMoveActionStateForAll()}setupSortPresets(){let e="",t=!1,i=["name","created","updated"];this.sortContainer.addEventListener("click",r=>{let o=r.target.closest(".sort-box-options [data-sort]");if(!o)return;r.preventDefault();let s=o.closest(".sort-box").querySelectorAll("ul"),a=o.getAttribute("data-sort");t=e===a?!t:!1;let l=As[a];t&&i.includes(a)&&(l=function(u,h){return 0-As[a](u,h)});for(let c of s)Array.from(c.children).filter(h=>h.matches("li")).sort(l).forEach(h=>{c.appendChild(h)});e=a,this.updateMapInput()})}bookSelect(e){if(this.container.querySelector(`[data-type="book"][data-id="${e.id}"]`)!==null)return;let i=`${e.link}/sort-item`;window.$http.get(i).then(r=>{let o=_e(r.data);this.sortContainer.append(o),this.setupBookSortable(o),this.updateMoveActionStateForAll(),o.querySelector("summary").focus()})}setupBookSortable(e){let t=Array.from(e.querySelectorAll(".sort-list, .sortable-page-sublist")),i={name:"book",pull:["book","chapter"],put:["book","chapter"]},r={name:"chapter",pull:["book","chapter"],put(o,s,a){return a.getAttribute("data-type")==="page"}};for(let o of t)Ye.create(o,{group:o.classList.contains("sort-list")?i:r,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 e=this.container.querySelectorAll('[data-type="chapter"] [data-type="chapter"]');for(let t of e)t.parentElement.closest('[data-type="chapter"]').insertAdjacentElement("afterend",t)}updateMapInput(){let e=this.buildEntityMap();this.input.value=JSON.stringify(e)}buildEntityMap(){let e=[],t=this.container.querySelectorAll(".sort-list");for(let i of t){let r=i.closest('[data-type="book"]').getAttribute("data-id"),o=Array.from(i.children).filter(s=>s.matches('[data-type="page"], [data-type="chapter"]'));for(let s=0;s<o.length;s++)this.addBookChildToMap(o[s],s,r,e)}return e}addBookChildToMap(e,t,i,r){let o=e.getAttribute("data-type"),s=!1,a=e.getAttribute("data-id");r.push({id:a,sort:t,parentChapter:s,type:o,book:i});let l=e.querySelectorAll('[data-type="page"]');for(let c=0;c<l.length;c++)r.push({id:l[c].getAttribute("data-id"),sort:c,parentChapter:a,type:"page",book:i})}runSortAction(e,t){let i=e.parentElement.closest("li[data-id]"),r=e.parentElement.closest('[data-type="book"]');Ds[t].run(e,i,r),this.updateMapInput(),this.updateMoveActionStateForAll(),e.scrollIntoView({behavior:"smooth",block:"nearest"}),e.focus()}updateMoveActionState(e){let t=e.parentElement.closest("li[data-id]"),i=e.parentElement.closest('[data-type="book"]');for(let[r,o]of Object.entries(Ds)){let s=e.querySelector(`[data-move="${r}"]`);s.disabled=!o.active(e,t,i)}}updateMoveActionStateForAll(){let e=this.container.querySelectorAll('[data-type="chapter"],[data-type="page"]');for(let t of e)this.updateMoveActionState(t)}};var qn=new WeakMap;function Wt(n,e,t=400,i=null){let r=Object.keys(e);for(let s of r)n.style[s]=e[s][0];let o=()=>{for(let s of r)n.style[s]=null;n.style.transition=null,n.removeEventListener("transitionend",o),qn.delete(n),i&&i()};setTimeout(()=>{n.style.transition=`all ease-in-out ${t}ms`;for(let s of r)n.style[s]=e[s][1];n.addEventListener("transitionend",o),qn.set(n,o)},15)}function Gt(n){qn.has(n)&&qn.get(n)()}function Ts(n,e=400,t=null){Gt(n),n.style.display="block",Wt(n,{opacity:["0","1"]},e,()=>{t&&t()})}function Ls(n,e=400,t=null){Gt(n),Wt(n,{opacity:["1","0"]},e,()=>{n.style.display="none",t&&t()})}function ft(n,e=400){Gt(n);let t=n.getBoundingClientRect().height,i=getComputedStyle(n),r=i.getPropertyValue("padding-top"),o=i.getPropertyValue("padding-bottom"),s={maxHeight:[`${t}px`,"0px"],overflow:["hidden","hidden"],paddingTop:[r,"0px"],paddingBottom:[o,"0px"]};Wt(n,s,e,()=>{n.style.display="none"})}function mt(n,e=400){Gt(n),n.style.display="block";let t=n.getBoundingClientRect().height,i=getComputedStyle(n),r=i.getPropertyValue("padding-top"),o=i.getPropertyValue("padding-bottom"),s={maxHeight:["0px",`${t}px`],overflow:["hidden","hidden"],paddingTop:["0px",r],paddingBottom:["0px",o]};Wt(n,s,e)}function Is(n,e=400){let t=n.getBoundingClientRect().height,i=getComputedStyle(n),r=i.getPropertyValue("padding-top"),o=i.getPropertyValue("padding-bottom");return()=>{Gt(n);let s=n.getBoundingClientRect().height,a=getComputedStyle(n),l=a.getPropertyValue("padding-top"),c=a.getPropertyValue("padding-bottom"),u={height:[`${t}px`,`${s}px`],overflow:["hidden","hidden"],paddingTop:[r,l],paddingBottom:[o,c]};Wt(n,u,e)}}var Bn=class extends g{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"),mt(this.list,180),this.isOpen=!0}close(){this.toggle.classList.remove("open"),this.toggle.setAttribute("aria-expanded","false"),ft(this.list,180),this.isOpen=!1}click(e){e.preventDefault(),this.isOpen?this.close():this.open()}};var Pn=class extends g{constructor(){super(...arguments);se(this,"editor",null);se(this,"saveCallback",null);se(this,"cancelCallback",null);se(this,"history",{});se(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",t=>{t.ctrlKey&&t.key==="Enter"&&this.save()}),O(this.languageButtons,t=>{let i=t.target.dataset.lang;this.languageInput.value=i,this.languageInputChange(i)}),st(this.languageInput,()=>this.save()),this.languageInput.addEventListener("input",()=>this.languageInputChange(this.languageInput.value)),O(this.saveButton,()=>this.save()),K(this.historyList,"button","click",(t,i)=>{t.preventDefault();let r=i.dataset.time;this.editor&&this.editor.setContent(this.history[r])})}setupFavourites(){for(let t of this.languageButtons)this.setupFavouritesForButton(t);this.sortLanguageList()}setupFavouritesForButton(t){let i=t.dataset.lang,r=this.favourites.has(i);t.setAttribute("data-favourite",r?"true":"false"),K(t.parentElement,".lang-option-favorite-toggle","click",()=>{r=!r,r?this.favourites.add(i):this.favourites.delete(i),t.setAttribute("data-favourite",r?"true":"false"),window.$http.patch("/preferences/update-code-language-favourite",{language:i,active:r}),this.sortLanguageList(),r&&t.scrollIntoView({block:"center",behavior:"smooth"})})}sortLanguageList(){let t=this.languageButtons.sort((i,r)=>{let o=i.dataset.favourite==="true",s=r.dataset.favourite==="true";return o&&!s?-1:s&&!o||i.dataset.lang>r.dataset.lang?1:-1}).map(i=>i.parentElement);for(let i of t)this.languageOptionsContainer.append(i)}save(){this.saveCallback&&this.saveCallback(this.editor.getContent(),this.languageInput.value),this.hide()}async open(t,i,r,o){this.languageInput.value=i,this.saveCallback=r,this.cancelCallback=o,await this.show(),this.languageInputChange(i),this.editor.setContent(t)}async show(){let t=await window.importVersioned("code");this.editor||(this.editor=t.popupEditor(this.editorInput,this.languageInput.value)),this.loadHistory(),this.getPopup().show(()=>{this.editor.focus()},()=>{this.addHistory(),this.cancelCallback&&this.cancelCallback()})}hide(){this.getPopup().hide(),this.addHistory()}getPopup(){return window.$components.firstOnElement(this.popup,"popup")}async updateEditorMode(t){this.editor.setMode(t,this.editor.getContent())}languageInputChange(t){this.updateEditorMode(t);let i=t.toLowerCase();for(let r of this.languageButtons){let o=r.dataset.lang.toLowerCase().trim(),s=i===o;r.classList.toggle("active",s),s&&r.scrollIntoView({block:"center",behavior:"smooth"})}}loadHistory(){this.history=JSON.parse(window.sessionStorage.getItem(this.historyKey)||"{}");let t=Object.keys(this.history).reverse();this.historyDropDown.classList.toggle("hidden",t.length===0),this.historyList.innerHTML=t.map(i=>{let r=new Date(parseInt(i,10)).toLocaleTimeString();return`<li><button type="button" data-time="${i}" class="text-item">${r}</button></li>`}).join("")}addHistory(){if(!this.editor)return;let t=this.editor.getContent();if(!t)return;let i=Object.keys(this.history).pop();if(this.history[i]===t)return;this.history[String(Date.now())]=t;let r=JSON.stringify(this.history);window.sessionStorage.setItem(this.historyKey,r)}};var On=class extends g{setup(){let e=this.$el;e.querySelectorAll("pre").length>0&&window.importVersioned("code").then(i=>{i.highlightWithin(e)})}};var Rn=class extends g{async setup(){let{mode:e}=this.$opts;(await window.importVersioned("code")).inlineEditor(this.$el,e)}};var Nn=class extends g{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"),mt(this.content,300)}close(){this.container.classList.remove("open"),this.trigger.setAttribute("aria-expanded","false"),ft(this.content,300)}toggle(){this.container.classList.contains("open")?this.close():this.open()}openIfContainsError(){this.content.querySelector(".text-neg.text-small")&&this.open()}};var zn=class extends g{setup(){this.container=this.$el,this.confirmButton=this.$refs.confirm,this.res=null,O(this.confirmButton,()=>{this.sendResult(!0),this.getPopup().hide()})}show(){return this.getPopup().show(null,()=>{this.sendResult(!1)}),new Promise(e=>{this.res=e})}getPopup(){return window.$components.firstOnElement(this.container,"popup")}sendResult(e){this.res&&(this.res(e),this.res=null)}};var Hn=class extends g{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(e){(e.key===" "||e.key==="Enter")&&(e.preventDefault(),this.toggle())}toggle(){this.checkbox.checked=!this.checkbox.checked,this.checkbox.dispatchEvent(new Event("change")),this.stateChange()}stateChange(){let e=this.checkbox.checked?"true":"false";this.display.setAttribute("aria-checked",e)}};var Un=class extends g{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(e=>{e.highlightWithin(this.container)}),this.dealtWith=!0)}};var jn=class extends g{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(e=null){this.hideAll(),this.menu.style.display="block",this.menu.classList.add("anim","menuIn"),this.toggle.setAttribute("aria-expanded","true");let t=this.menu.getBoundingClientRect(),i=0,r=this.toggle.getBoundingClientRect().height,o=t.bottom>window.innerHeight;this.moveMenu&&(this.body.appendChild(this.menu),this.menu.style.position="fixed",this.menu.style.width=`${t.width}px`,this.menu.style.left=`${t.left}px`,o?i=window.innerHeight-t.top-r/2:i=t.top),o?(this.menu.style.top="initial",this.menu.style.bottom=`${i}px`):(this.menu.style.top=`${i}px`,this.menu.style.bottom="initial"),this.menu.addEventListener("mouseleave",this.hide),window.addEventListener("click",l=>{this.menu.contains(l.target)||this.hide()});let s=this.menu.querySelector("input");s!==null&&s.focus(),this.showing=!0;let a=new Event("show");this.container.dispatchEvent(a),e&&e.stopPropagation()}hideAll(){for(let e of window.$components.get("dropdown"))e.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.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 e=new ze(this.container,t=>{this.hide(),this.toggle.focus(),this.bubbleEscapes||t.stopPropagation()},t=>{t.target.nodeName==="INPUT"&&(t.preventDefault(),t.stopPropagation()),this.hide()});this.moveMenu&&e.shareHandlingToEl(this.menu),this.container.addEventListener("click",t=>{Array.from(this.menu.querySelectorAll("a")).includes(t.target)&&this.hide()}),O(this.toggle,t=>{t.stopPropagation(),t.preventDefault(),this.show(t),t instanceof KeyboardEvent&&e.focusNext()})}};var Vn=class extends g{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=Ne(this.runAjaxSearch,300,!1)}onShow(){this.loadList()}onSearch(){let e=this.searchInput.value.toLowerCase().trim();this.localSearchSelector?this.runLocalSearch(e):(this.toggleLoading(!0),this.listContainerElem.innerHTML="",this.runAjaxSearch(e))}runAjaxSearch(e){this.loadList(e)}runLocalSearch(e){let t=this.listContainerElem.querySelectorAll(this.localSearchSelector);for(let i of t){let r=!e||i.textContent.toLowerCase().includes(e);i.style.display=r?"flex":"none",i.classList.toggle("hidden",!r)}}async loadList(e=""){this.listContainerElem.innerHTML="",this.toggleLoading(!0);try{let t=await window.$http.get(this.getAjaxUrl(e)),i=Is(this.listContainerElem,80);this.listContainerElem.innerHTML=t.data,i()}catch(t){console.error(t)}this.toggleLoading(!1),this.localSearchSelector&&this.onSearch()}getAjaxUrl(e=null){if(!e)return this.url;let t=this.url.includes("?")?"&":"?";return`${this.url}${t}search=${encodeURIComponent(e)}`}toggleLoading(e=!1){this.loadingElem.style.display=e?"block":"none"}};var Fe=class{constructor(e){this.data=e}hasItems(){return!!this.data&&!!this.data.types&&this.data.types.length>0}containsTabularData(){let e=this.data.getData("text/rtf");return e&&e.includes("\\trowd")}getImages(){let{types:e}=this.data,t=[];for(let r of e)if(r.includes("image")){let o=this.data.getData(r);t.push(o.getAsFile())}let i=this.getFiles().filter(r=>r.type.includes("image"));return t.push(...i),t}getFiles(){let{files:e}=this.data;return[...e]}};async function Vr(n){if(window.isSecureContext&&navigator.clipboard){await navigator.clipboard.writeText(n);return}let e=document.createElement("textarea");e.style="position: absolute; left: -1000px; top: -1000px;",e.value=n,document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e)}var Wn=class extends g{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(e){this.isActive=e}setupListeners(){O(this.selectButtons,this.manualSelectHandler.bind(this)),this.setupDropTargetHandlers()}setupDropTargetHandlers(){let e=0,t=()=>{this.hideOverlay(),e=0};this.dropTarget.addEventListener("dragenter",i=>{i.preventDefault(),e+=1,e===1&&this.isActive&&this.showOverlay()}),this.dropTarget.addEventListener("dragover",i=>{i.preventDefault()}),this.dropTarget.addEventListener("dragend",t),this.dropTarget.addEventListener("dragleave",()=>{e-=1,e===0&&t()}),this.dropTarget.addEventListener("drop",i=>{if(i.preventDefault(),t(),!this.isActive)return;let o=new Fe(i.dataTransfer).getFiles();for(let s of o)this.createUploadFromFile(s)})}manualSelectHandler(){let e=Ee("input",{type:"file",style:"left: -400px; visibility: hidden; position: fixed;",accept:this.fileAcceptTypes,multiple:this.allowMultiple?"":null});this.container.append(e),e.click(),e.addEventListener("change",()=>{for(let t of e.files)this.createUploadFromFile(t);e.remove()})}showOverlay(){if(!this.dropTarget.querySelector(".dropzone-overlay")){let t=Ee("div",{class:"dropzone-overlay"},[this.zoneText]);this.dropTarget.append(t)}}hideOverlay(){let e=this.dropTarget.querySelector(".dropzone-overlay");e&&e.remove()}createUploadFromFile(e){let{dom:t,status:i,progress:r,dismiss:o}=this.createDomForFile(e);this.statusArea.append(t);let s=this,a={file:e,dom:t,updateProgress(l){r.textContent=`${l}%`,r.style.width=`${l}%`},markError(l){i.setAttribute("data-status","error"),i.textContent=l,Tt(t),this.updateProgress(100)},markSuccess(l){i.setAttribute("data-status","success"),i.textContent=l,Tt(t),setTimeout(o,2400),s.$emit("upload-success",{name:e.name})}};return e.size>this.uploadLimitMb*1e6?(a.markError(this.uploadLimitMessage),a):(this.startXhrForUpload(a),a)}startXhrForUpload(e){let t=new FormData;t.append("file",e.file,e.file.name),this.method!=="POST"&&t.append("_method",this.method);let i=this,r=window.$http.createXMLHttpRequest("POST",this.url,{error(){e.markError(i.errorMessage)},readystatechange(){if(this.readyState===XMLHttpRequest.DONE&&this.status===200)e.markSuccess(i.successMessage);else if(this.readyState===XMLHttpRequest.DONE&&this.status>=400){let o=this.responseText,s=o.startsWith("{")?JSON.parse(o):{message:o},a=s?.message||s?.error||o;e.markError(a)}}});r.upload.addEventListener("progress",o=>{let s=Math.min(Math.ceil(o.loaded/o.total*100),100);e.updateProgress(s)}),r.setRequestHeader("Accept","application/json"),r.send(t)}createDomForFile(e){let t=Ee("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=Ee("div",{class:"dropzone-file-item-status"},[]),r=Ee("div",{class:"dropzone-file-item-progress"}),o=Ee("div",{class:"dropzone-file-item-image-wrap"},[t]),s=Ee("div",{class:"dropzone-file-item"},[o,Ee("div",{class:"dropzone-file-item-text-wrap"},[Ee("div",{class:"dropzone-file-item-label"},[e.name]),at(),i]),r]);e.type.startsWith("image/")&&(t.src=URL.createObjectURL(e));let a=()=>{s.classList.add("dismiss"),s.addEventListener("animationend",()=>{s.remove()})};return s.addEventListener("click",a),{dom:s,progress:r,status:i,dismiss:a}}};var Gn=class extends g{setup(){this.container=this.$el,this.buttons=this.$manyRefs.tabButton,this.contentElements=this.$manyRefs.tabContent,this.toggleButton=this.$refs.toggle,this.setupListeners(),this.setActiveTab(this.contentElements[0].dataset.tabContent)}setupListeners(){this.toggleButton.addEventListener("click",()=>this.toggle()),this.container.addEventListener("click",e=>{let t=e.target.closest("button");if(this.buttons.includes(t)){let i=t.dataset.tab;this.setActiveTab(i,!0)}})}toggle(){this.container.classList.toggle("open");let e=this.container.classList.contains("open")?"true":"false";this.toggleButton.setAttribute("aria-expanded",e)}setActiveTab(e,t=!1){for(let i of this.buttons)i.classList.remove("active"),i.dataset.tab===e&&i.classList.add("active");for(let i of this.contentElements)i.style.display="none",i.dataset.tabContent===e&&(i.style.display="block");t&&!this.container.classList.contains("open")&&this.toggle()}};var Kn=class extends g{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",e=>{let t=e.target.checked,i=document.querySelectorAll('input[name^="permissions[0]["]');for(let r of i)r.disabled=t,r.checked=!1}),this.container.addEventListener("click",e=>{let t=e.target.closest("button");t&&t.dataset.roleId&&this.removeRowOnButtonClick(t)}),this.roleSelect.addEventListener("change",()=>{let e=this.roleSelect.value;e&&this.addRoleRow(e)})}async addRoleRow(e){this.roleSelect.disabled=!0;let t=this.roleSelect.querySelector(`option[value="${e}"]`);t&&t.remove();let i=await window.$http.get(`/permissions/form-row/${this.entityType}/${e}`),r=_e(i.data);this.roleContainer.append(r),this.roleSelect.disabled=!1}removeRowOnButtonClick(e){let t=e.closest(".item-list-row"),{roleId:i}=e.dataset,{roleName:r}=e.dataset,o=document.createElement("option");o.value=i,o.textContent=r,this.roleSelect.append(o),t.remove()}};var Zn=class extends g{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",e=>{e.preventDefault(),this.runSearch()}),O(this.clearButton,this.clearSearch.bind(this))}runSearch(){let e=this.searchInput.value.trim();if(e.length===0){this.clearSearch();return}this.searchView.classList.remove("hidden"),this.contentView.classList.add("hidden"),this.loadingBlock.classList.remove("hidden");let t=window.baseUrl(`/search/${this.entityType}/${this.entityId}`);window.$http.get(t,{term:e}).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 Xn=class extends g{setup(){this.elem=this.$el,this.entityTypes=this.$opts.entityTypes||"page,book,chapter",this.entityPermission=this.$opts.entityPermission||"view",this.input=this.$refs.input,this.searchInput=this.$refs.search,this.loading=this.$refs.loading,this.resultsContainer=this.$refs.results,this.search="",this.lastClick=0,this.selectedItemData=null,this.setupListeners(),this.showLoading(),this.initialLoad()}setupListeners(){this.elem.addEventListener("click",this.onClick.bind(this));let e=0;this.searchInput.addEventListener("input",()=>{e=Date.now(),this.showLoading(),setTimeout(()=>{Date.now()-e<199||this.searchEntities(this.searchInput.value)},200)}),this.searchInput.addEventListener("keydown",t=>{t.keyCode===13&&t.preventDefault()}),K(this.$el,"[data-entity-type]","keydown",t=>{if(t.ctrlKey&&t.code==="Enter"){let i=this.$el.closest("form");if(i){i.submit(),t.preventDefault();return}}t.code==="ArrowDown"&&this.focusAdjacent(!0),t.code==="ArrowUp"&&this.focusAdjacent(!1)}),this.searchInput.addEventListener("keydown",t=>{t.code==="ArrowDown"&&this.focusAdjacent(!0)})}focusAdjacent(e=!0){let t=Array.from(this.resultsContainer.querySelectorAll("[data-entity-type]")),i=t.indexOf(document.activeElement),r=t[i+(e?1:-1)]||t[0];r&&r.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(){window.$http.get(this.searchUrl()).then(e=>{this.resultsContainer.innerHTML=e.data,this.hideLoading()})}searchUrl(){return`/search/entity-selector?types=${encodeURIComponent(this.entityTypes)}&permission=${encodeURIComponent(this.entityPermission)}`}searchEntities(e){this.input.value="";let t=`${this.searchUrl()}&term=${encodeURIComponent(e)}`;window.$http.get(t).then(i=>{this.resultsContainer.innerHTML=i.data,this.hideLoading()})}isDoubleClick(){let e=Date.now(),t=e-this.lastClick<300;return this.lastClick=e,t}onClick(e){let t=e.target.closest("[data-entity-type]");t&&(e.preventDefault(),e.stopPropagation(),this.selectItem(t))}selectItem(e){let t=this.isDoubleClick(),i=e.getAttribute("data-entity-type"),r=e.getAttribute("data-entity-id"),o=!e.classList.contains("selected")||t;this.unselectAll(),this.input.value=o?`${i}:${r}`:"";let s=e.getAttribute("href"),a=e.querySelector(".entity-list-item-name").textContent,l={id:Number(r),name:a,link:s};o?(e.classList.add("selected"),this.selectedItemData=l):window.$events.emit("entity-select-change",null),!(!t&&!o)&&(t&&this.confirmSelection(l),o&&window.$events.emit("entity-select-change",l))}confirmSelection(e){window.$events.emit("entity-select-confirm",e)}unselectAll(){let e=this.elem.querySelectorAll(".selected");for(let t of e)t.classList.remove("selected","primary-background");this.selectedItemData=null}};var Yn=class extends g{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(e){this.callback=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(e){this.selection=e,e===null?this.selectButton.setAttribute("disabled","true"):this.selectButton.removeAttribute("disabled")}handleConfirmedSelection(e){this.hide(),this.getSelector().reset(),this.callback&&e&&this.callback(e)}};var Jn=class extends g{setup(){this.container=this.$el,this.name=this.$opts.name,O(this.$el,()=>{this.$emit(this.name,this.$opts)})}};var Qn=class extends g{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(e){mt(e,200)}close(e){ft(e,200)}click(e){e.preventDefault();let t=document.querySelectorAll(this.targetSelector);for(let i of t)(this.isOpen?this.close:this.open)(i);this.isOpen=!this.isOpen,this.updateSystemAjax(this.isOpen)}updateSystemAjax(e){window.$http.patch(this.updateEndpoint,{expand:e?"true":"false"})}};var ei=class extends g{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 e=Ne(this.updateSuggestions.bind(this),200,!1);this.input.addEventListener("input",()=>{let{value:t}=this.input;t.length>0?(this.loadingWrap.style.display="block",this.suggestionResultsWrap.style.opacity="0.5",e(t)):this.hideSuggestions()}),this.input.addEventListener("dblclick",()=>{this.input.setAttribute("autocomplete","on"),this.button.focus(),this.input.focus()}),new ze(this.container,()=>{this.hideSuggestions()})}async updateSuggestions(e){let{data:t}=await window.$http.get("/search/suggest",{term:e});if(!this.input.value)return;let i=_e(t);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 ti=class extends g{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(e){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)),e.stopPropagation()}onKeyDown(e){e.code==="Escape"&&this.onToggle(e)}onWindowClick(e){this.onToggle(e)}};var ni=class extends g{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(){O(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()}),O(this.cancelSearch,()=>{this.resetListView(),this.resetSearchView(),this.loadGallery()}),K(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),O(this.selectButton,()=>{this.callback&&this.callback(this.lastSelected),this.hide()}),K(this.formContainer,"#image-manager-delete","click",()=>{this.lastSelected&&this.loadImageEditForm(this.lastSelected.id,!0)}),this.formContainer.addEventListener("ajax-form-success",()=>{this.refreshGallery(),this.resetEditForm()}),this.container.addEventListener("dropzone-upload-success",this.refreshGallery.bind(this));let e=this.listContainer.parentElement,t=[];e.addEventListener("wheel",i=>{if(!(Math.ceil(e.scrollHeight-e.scrollTop)===e.clientHeight)||i.deltaY<1)return;let s=Date.now()-1e3;t.push(Date.now()),t=t.filter(a=>a>=s),t.length>5&&this.canLoadMore()&&this.runLoadMore()})}show(e,t="gallery"){this.resetAll(),this.callback=e,this.type=t,this.getPopup().show();let i=t!=="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 e={page:this.page,search:this.searchInput.value||null,uploaded_to:this.uploadedTo,filter_type:this.filter==="all"?null:this.filter},{data:t}=await window.$http.get(`images/${this.type}`,e);e.page===1&&(this.listContainer.innerHTML=""),this.addReturnedHtmlElementsToList(t),Tt(this.listContainer)}addReturnedHtmlElementsToList(e){let t=document.createElement("div");t.innerHTML=e;let i=t.querySelector(".load-more");i&&(i.remove(),this.loadMore.innerHTML=i.innerHTML),this.loadMore.toggleAttribute("hidden",!i),window.$components.init(t);for(let r of[...t.children])this.listContainer.appendChild(r)}setActiveFilterTab(e){for(let t of this.filterTabs){let i=t.dataset.filter===e;t.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(){Dt(this.listContainer),this.page=1}refreshGallery(){this.resetListView(),this.loadGallery()}onImageSelectEvent(e){let t=JSON.parse(e.detail.data),i=t&&t.id===this.lastSelected.id&&Date.now()-this.lastSelectedTime<400,r=e.target.classList.contains("selected");[...this.listContainer.querySelectorAll(".selected")].forEach(o=>{o.classList.remove("selected")}),r?this.resetEditForm():(e.target.classList.add("selected"),this.loadImageEditForm(t.id)),this.selectButton.classList.toggle("hidden",r),i&&this.callback&&(this.callback(t),this.hide()),this.lastSelected=t,this.lastSelectedTime=Date.now()}async loadImageEditForm(e,t=!1){t||(this.formContainer.innerHTML="");let i=t?{delete:!0}:{},{data:r}=await window.$http.get(`/images/edit/${e}`,i);this.formContainer.innerHTML=r,this.formContainerPlaceholder.setAttribute("hidden",""),window.$components.init(this.formContainer)}runLoadMore(){Dt(this.loadMore),this.page+=1,this.loadGallery()}canLoadMore(){return this.loadMore.querySelector("button")&&!this.loadMore.hasAttribute("hidden")}};var ii=class extends g{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 e of this.imageInput.files)this.imageElem.src=window.URL.createObjectURL(e);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 ri=class extends g{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",e=>{e.target.closest("[data-sort-value]")!==null&&this.sortOptionClick(e)}),this.elem.addEventListener("click",e=>{e.target.closest("[data-sort-dir]")!==null&&this.sortDirectionClick(e)})}sortOptionClick(e){let t=e.target.closest("[data-sort-value]");this.sortInput.value=t.getAttribute("data-sort-value"),e.preventDefault(),this.form.submit()}sortDirectionClick(e){let t=this.orderInput.value;this.orderInput.value=t==="asc"?"desc":"asc",e.preventDefault(),this.form.submit()}};var Uc=Wo(Pc()),jc=Wo(Hc()),wi=class{constructor(){this.renderer=new Uc.default({html:!0}),this.renderer.use(jc.default,{label:!0})}getRenderer(){return this.renderer}render(e){return this.renderer.render(e)}};function rf(n,e){return document.createElement(n,e)}function of(n,e,t){return document.createElementNS(n,e,t)}function sf(){return et(document.createDocumentFragment())}function af(n){return document.createTextNode(n)}function lf(n){return document.createComment(n)}function cf(n,e,t){if(qe(n)){let i=n;for(;i&&qe(i);)i=et(i).parent;n=i??n}qe(e)&&(e=et(e,n)),t&&qe(t)&&(t=et(t).firstChildNode),n.insertBefore(e,t)}function uf(n,e){n.removeChild(e)}function hf(n,e){qe(e)&&(e=et(e,n)),n.appendChild(e)}function Vc(n){if(qe(n)){for(;n&&qe(n);)n=et(n).parent;return n??null}return n.parentNode}function df(n){var e;if(qe(n)){let t=et(n),i=Vc(t);if(i&&t.lastChildNode){let r=Array.from(i.childNodes),o=r.indexOf(t.lastChildNode);return(e=r[o+1])!==null&&e!==void 0?e:null}return null}return n.nextSibling}function pf(n){return n.tagName}function ff(n,e){n.textContent=e}function mf(n){return n.textContent}function gf(n){return n.nodeType===1}function bf(n){return n.nodeType===3}function vf(n){return n.nodeType===8}function qe(n){return n.nodeType===11}function et(n,e){var t,i,r;let o=n;return(t=o.parent)!==null&&t!==void 0||(o.parent=e??null),(i=o.firstChildNode)!==null&&i!==void 0||(o.firstChildNode=n.firstChild),(r=o.lastChildNode)!==null&&r!==void 0||(o.lastChildNode=n.lastChild),o}var yi={createElement:rf,createElementNS:of,createTextNode:af,createDocumentFragment:sf,createComment:lf,insertBefore:cf,removeChild:uf,appendChild:hf,parentNode:Vc,nextSibling:df,tagName:pf,setTextContent:ff,getTextContent:mf,isElement:gf,isText:bf,isComment:vf,isDocumentFragment:qe};function Be(n,e,t,i,r){let o=e===void 0?void 0:e.key;return{sel:n,data:e,children:t,text:i,elm:r,key:o}}var Wc=Array.isArray;function Gc(n){return typeof n=="string"||typeof n=="number"||n instanceof String||n instanceof Number}function Co(n){return n===void 0}function ce(n){return n!==void 0}var Eo=Be("",{},[],void 0,void 0);function Jt(n,e){var t,i;let r=n.key===e.key,o=((t=n.data)===null||t===void 0?void 0:t.is)===((i=e.data)===null||i===void 0?void 0:i.is),s=n.sel===e.sel,a=!n.sel&&n.sel===e.sel?typeof n.text==typeof e.text:!0;return s&&r&&o&&a}function yf(){throw new Error("The document fragment is not supported on this platform.")}function xf(n,e){return n.isElement(e)}function kf(n,e){return n.isDocumentFragment(e)}function Cf(n,e,t){var i;let r={};for(let o=e;o<=t;++o){let s=(i=n[o])===null||i===void 0?void 0:i.key;s!==void 0&&(r[s]=o)}return r}var Ef=["create","update","remove","destroy","pre","post"];function _o(n,e,t){let i={create:[],update:[],remove:[],destroy:[],pre:[],post:[]},r=e!==void 0?e:yi;for(let f of Ef)for(let m of n){let y=m[f];y!==void 0&&i[f].push(y)}function o(f){let m=f.id?"#"+f.id:"",y=f.getAttribute("class"),v=y?"."+y.split(" ").join("."):"";return Be(r.tagName(f).toLowerCase()+m+v,{},[],void 0,f)}function s(f){return Be(void 0,{},[],void 0,f)}function a(f,m){return function(){if(--m===0){let v=r.parentNode(f);r.removeChild(v,f)}}}function l(f,m){var y,v,b,k;let w,E=f.data;if(E!==void 0){let D=(y=E.hook)===null||y===void 0?void 0:y.init;ce(D)&&(D(f),E=f.data)}let x=f.children,S=f.sel;if(S==="!")Co(f.text)&&(f.text=""),f.elm=r.createComment(f.text);else if(S!==void 0){let D=S.indexOf("#"),q=S.indexOf(".",D),L=D>0?D:S.length,I=q>0?q:S.length,H=D!==-1||q!==-1?S.slice(0,Math.min(L,I)):S,N=f.elm=ce(E)&&ce(w=E.ns)?r.createElementNS(w,H,E):r.createElement(H,E);for(L<I&&N.setAttribute("id",S.slice(L+1,I)),q>0&&N.setAttribute("class",S.slice(I+1).replace(/\./g," ")),w=0;w<i.create.length;++w)i.create[w](Eo,f);if(Wc(x))for(w=0;w<x.length;++w){let ge=x[w];ge!=null&&r.appendChild(N,l(ge,m))}else Gc(f.text)&&r.appendChild(N,r.createTextNode(f.text));let ee=f.data.hook;ce(ee)&&((v=ee.create)===null||v===void 0||v.call(ee,Eo,f),ee.insert&&m.push(f))}else if(!((b=t?.experimental)===null||b===void 0)&&b.fragments&&f.children){for(f.elm=((k=r.createDocumentFragment)!==null&&k!==void 0?k:yf)(),w=0;w<i.create.length;++w)i.create[w](Eo,f);for(w=0;w<f.children.length;++w){let D=f.children[w];D!=null&&r.appendChild(f.elm,l(D,m))}}else f.elm=r.createTextNode(f.text);return f.elm}function c(f,m,y,v,b,k){for(;v<=b;++v){let w=y[v];w!=null&&r.insertBefore(f,l(w,k),m)}}function u(f){var m,y;let v=f.data;if(v!==void 0){(y=(m=v?.hook)===null||m===void 0?void 0:m.destroy)===null||y===void 0||y.call(m,f);for(let b=0;b<i.destroy.length;++b)i.destroy[b](f);if(f.children!==void 0)for(let b=0;b<f.children.length;++b){let k=f.children[b];k!=null&&typeof k!="string"&&u(k)}}}function h(f,m,y,v){for(var b,k;y<=v;++y){let w,E,x=m[y];if(x!=null)if(ce(x.sel)){u(x),w=i.remove.length+1,E=a(x.elm,w);for(let D=0;D<i.remove.length;++D)i.remove[D](x,E);let S=(k=(b=x?.data)===null||b===void 0?void 0:b.hook)===null||k===void 0?void 0:k.remove;ce(S)?S(x,E):E()}else x.children?(u(x),h(f,x.children,0,x.children.length-1)):r.removeChild(f,x.elm)}}function d(f,m,y,v){let b=0,k=0,w=m.length-1,E=m[0],x=m[w],S=y.length-1,D=y[0],q=y[S],L,I,H,N;for(;b<=w&&k<=S;)E==null?E=m[++b]:x==null?x=m[--w]:D==null?D=y[++k]:q==null?q=y[--S]:Jt(E,D)?(p(E,D,v),E=m[++b],D=y[++k]):Jt(x,q)?(p(x,q,v),x=m[--w],q=y[--S]):Jt(E,q)?(p(E,q,v),r.insertBefore(f,E.elm,r.nextSibling(x.elm)),E=m[++b],q=y[--S]):Jt(x,D)?(p(x,D,v),r.insertBefore(f,x.elm,E.elm),x=m[--w],D=y[++k]):(L===void 0&&(L=Cf(m,b,w)),I=L[D.key],Co(I)?r.insertBefore(f,l(D,v),E.elm):(H=m[I],H.sel!==D.sel?r.insertBefore(f,l(D,v),E.elm):(p(H,D,v),m[I]=void 0,r.insertBefore(f,H.elm,E.elm))),D=y[++k]);k<=S&&(N=y[S+1]==null?null:y[S+1].elm,c(f,N,y,k,S,v)),b<=w&&h(f,m,b,w)}function p(f,m,y){var v,b,k,w,E,x,S,D;let q=(v=m.data)===null||v===void 0?void 0:v.hook;(b=q?.prepatch)===null||b===void 0||b.call(q,f,m);let L=m.elm=f.elm;if(f===m)return;if(m.data!==void 0||ce(m.text)&&m.text!==f.text){(k=m.data)!==null&&k!==void 0||(m.data={}),(w=f.data)!==null&&w!==void 0||(f.data={});for(let N=0;N<i.update.length;++N)i.update[N](f,m);(S=(x=(E=m.data)===null||E===void 0?void 0:E.hook)===null||x===void 0?void 0:x.update)===null||S===void 0||S.call(x,f,m)}let I=f.children,H=m.children;Co(m.text)?ce(I)&&ce(H)?I!==H&&d(L,I,H,y):ce(H)?(ce(f.text)&&r.setTextContent(L,""),c(L,null,H,0,H.length-1,y)):ce(I)?h(L,I,0,I.length-1):ce(f.text)&&r.setTextContent(L,""):f.text!==m.text&&(ce(I)&&h(L,I,0,I.length-1),r.setTextContent(L,m.text)),(D=q?.postpatch)===null||D===void 0||D.call(q,f,m)}return function(m,y){let v,b,k,w=[];for(v=0;v<i.pre.length;++v)i.pre[v]();for(xf(r,m)?m=o(m):kf(r,m)&&(m=s(m)),Jt(m,y)?p(m,y,w):(b=m.elm,k=r.parentNode(b),l(y,w),k!==null&&(r.insertBefore(k,y.elm,r.nextSibling(b)),h(k,[m],0,0))),v=0;v<w.length;++v)w[v].data.hook.insert(w[v]);for(v=0;v<i.post.length;++v)i.post[v]();return y}}function So(n,e,t){if(n.ns="http://www.w3.org/2000/svg",t!=="foreignObject"&&e!==void 0)for(let i=0;i<e.length;++i){let r=e[i];if(typeof r=="string")continue;let o=r.data;o!==void 0&&So(o,r.children,r.sel)}}function Qt(n,e){let t=e!==void 0?e:yi,i;if(t.isElement(n)){let r=n.id?"#"+n.id:"",o=n.getAttribute("class"),s=o?"."+o.split(" ").join("."):"",a=t.tagName(n).toLowerCase()+r+s,l={},c={},u={},h=[],d,p,f,m=n.attributes,y=n.childNodes;for(p=0,f=m.length;p<f;p++)d=m[p].nodeName,d[0]==="d"&&d[1]==="a"&&d[2]==="t"&&d[3]==="a"&&d[4]==="-"?c[d.slice(5)]=m[p].nodeValue||"":d!=="id"&&d!=="class"&&(l[d]=m[p].nodeValue);for(p=0,f=y.length;p<f;p++)h.push(Qt(y[p],e));return Object.keys(l).length>0&&(u.attrs=l),Object.keys(c).length>0&&(u.dataset=c),a[0]==="s"&&a[1]==="v"&&a[2]==="g"&&(a.length===3||a[3]==="."||a[3]==="#")&&So(u,h,a),Be(a,u,h,void 0,n)}else return t.isText(n)?(i=t.getTextContent(n),Be(void 0,void 0,void 0,i,n)):t.isComment(n)?(i=t.getTextContent(n),Be("!",{},[],i,n)):Be("",{},[],void 0,n)}var _f="http://www.w3.org/1999/xlink",Sf="http://www.w3.org/XML/1998/namespace";function Kc(n,e){let t,i=e.elm,r=n.data.attrs,o=e.data.attrs;if(!(!r&&!o)&&r!==o){r=r||{},o=o||{};for(t in o){let s=o[t];r[t]!==s&&(s===!0?i.setAttribute(t,""):s===!1?i.removeAttribute(t):t.charCodeAt(0)!==120?i.setAttribute(t,s):t.charCodeAt(3)===58?i.setAttributeNS(Sf,t,s):t.charCodeAt(5)===58?i.setAttributeNS(_f,t,s):i.setAttribute(t,s))}for(t in r)t in o||i.removeAttribute(t)}}var Ao={create:Kc,update:Kc};var xi;function Af(){return xi||(xi=_o([Ao]),xi)}function Zc(n,e){let t=document.createElement("div");t.innerHTML=e,Af()(Qt(n),Qt(t))}var ki=class{constructor(e){this.editor=e,this.container=e.config.displayEl,this.doc=null,this.lastDisplayClick=0,this.container.contentDocument.readyState==="complete"?this.onLoad():this.container.addEventListener("load",this.onLoad.bind(this)),this.updateVisibility(e.settings.get("showPreview")),e.settings.onChange("showPreview",t=>this.updateVisibility(t))}updateVisibility(e){let t=this.container.closest(".markdown-editor-wrap");t.style.display=e?null:"none"}onLoad(){this.doc=this.container.contentDocument,this.loadStylesIntoDisplay(),this.doc.body.className="page-content",this.doc.addEventListener("click",this.onDisplayClick.bind(this))}onDisplayClick(e){let t=Date.now()-this.lastDisplayClick<300,i=e.target.closest("a");if(i!==null){e.preventDefault(),window.open(i.getAttribute("href"));return}let r=e.target.closest("[drawio-diagram]");if(r!==null&&t){this.editor.actions.editDrawing(r);return}this.lastDisplayClick=Date.now()}loadStylesIntoDisplay(){this.doc.documentElement.classList.add("markdown-editor-display"),document.documentElement.classList.contains("dark-mode")&&(this.doc.documentElement.style.backgroundColor="#222",this.doc.documentElement.classList.add("dark-mode")),this.doc.head.innerHTML="";let e=document.head.querySelectorAll("style,link[rel=stylesheet]");for(let t of e){let i=t.cloneNode(!0);this.doc.head.appendChild(i)}}patchWithHtml(e){let{body:t}=this.doc;if(t.children.length===0){let r=document.createElement("div");this.doc.body.append(r)}let i=t.children[0];Zc(i,e)}scrollToIndex(e){let t=this.doc.body?.children[0]?.children;if(t&&t.length<=e)return;(e===-1?t[t.length-1]:t[e]).scrollIntoView({block:"start",inline:"nearest",behavior:"smooth"})}};function Ci(n){return new Promise((e,t)=>{n.oncomplete=n.onsuccess=()=>e(n.result),n.onabort=n.onerror=()=>t(n.error)})}function Df(n,e){let t=indexedDB.open(n);t.onupgradeneeded=()=>t.result.createObjectStore(e);let i=Ci(t);return(r,o)=>i.then(s=>o(s.transaction(e,r).objectStore(e)))}var Do;function To(){return Do||(Do=Df("keyval-store","keyval")),Do}function Lo(n,e=To()){return e("readonly",t=>Ci(t.get(n)))}function Io(n,e,t=To()){return t("readwrite",i=>(i.put(e,n),Ci(i.transaction)))}function $o(n,e=To()){return e("readwrite",t=>(t.delete(n),Ci(t.transaction)))}var Ie=null,qo,Ei,Mo,Fo="last-drawing-save";function Bo(n){Ie.contentWindow.postMessage(JSON.stringify(n),qo)}function Lf(n){Io(Fo,n.data),Mo&&Mo(n.data).then(()=>{$o(Fo)})}function If(n){Bo({action:"export",format:"xmlpng",xml:n.xml,spin:"Updating drawing"})}function $f(){Ei&&Ei().then(n=>{Bo({action:"load",autosave:1,xml:n})})}function Mf(){let n={};window.$events.emitPublic(Ie,"editor-drawio::configure",{config:n}),Bo({action:"configure",config:n})}function Xc(){window.removeEventListener("message",Yc),Ie&&document.body.removeChild(Ie)}function Yc(n){if(!n.data||n.data.length<1||n.origin!==qo)return;let e=JSON.parse(n.data);e.event==="init"?$f():e.event==="exit"?Xc():e.event==="save"?If(e):e.event==="export"?Lf(e):e.event==="configure"&&Mf()}async function Ff(){let n=await Lo(Fo),e=document.getElementById("unsaved-drawing-dialog");e||console.error("Missing expected unsaved-drawing dialog"),n&&await window.$components.firstOnElement(e,"confirm-dialog").show()&&(Ei=async()=>n)}async function en(n,e,t){Ei=e,Mo=t,await Ff(),Ie=document.createElement("iframe"),Ie.setAttribute("frameborder","0"),window.addEventListener("message",Yc),Ie.setAttribute("src",n),Ie.setAttribute("class","fullscreen"),Ie.style.backgroundColor="#FFFFFF",document.body.appendChild(Ie),qo=new URL(n).origin}async function Po(n,e){let t={image:n,uploaded_to:e};return(await window.$http.post(window.baseUrl("/images/drawio"),t)).data}function tt(){Xc()}async function _i(n){try{return`data:image/png;base64,${(await window.$http.get(window.baseUrl(`/images/drawio/base64/${n}`))).data.content}`}catch(e){throw e instanceof window.$http.HttpError&&window.$events.showResponseError(e),tt(),e}}var tn,Oo,xt,Si,kt,Ai,Pe,nt,We,yt,ie,ue,nn,Ro,rn,No,Ct,Di,he,ve,Li,Qc,Ti=class{constructor(e){re(this,tn);re(this,xt);re(this,kt);re(this,Pe);re(this,We);re(this,ie);re(this,nn);re(this,rn);re(this,Ct);re(this,he);re(this,Li);this.editor=e,this.lastContent={html:"",markdown:""}}updateAndRender(){let e=T(this,xt,Si).call(this);this.editor.config.inputEl.value=e;let t=this.editor.markdown.render(e);window.$events.emit("editor-html-change",""),window.$events.emit("editor-markdown-change",""),this.lastContent.html=t,this.lastContent.markdown=e,this.editor.display.patchWithHtml(t)}getContent(){return this.lastContent}showImageInsert(){window.$components.first("image-manager").show(t=>{let i=t.thumbs.display||t.url,o=`[](${t.url})`;T(this,Pe,nt).call(this,o,o.length)},"gallery")}insertImage(){let e=``;T(this,Pe,nt).call(this,e,e.length-1)}insertLink(){let e=T(this,We,yt).call(this),t=`[${e}]()`,i=e===""?-3:-1;T(this,Pe,nt).call(this,t,t.length+i)}showImageManager(){let e=T(this,ie,ue).call(this);window.$components.first("image-manager").show(i=>{T(this,tn,Oo).call(this,i,e)},"drawio")}showLinkSelector(){let e=T(this,ie,ue).call(this);window.$components.first("entity-selector-popup").show(i=>{let o=`[${T(this,We,yt).call(this,e)||i.name}](${i.link})`;T(this,Pe,nt).call(this,o,o.length,e)})}startDrawing(){let e=this.editor.config.drawioUrl;if(!e)return;let t=T(this,ie,ue).call(this);en(e,()=>Promise.resolve(""),async i=>{let r={image:i,uploaded_to:Number(this.editor.config.pageId)};try{let o=await window.$http.post("/images/drawio",r);T(this,tn,Oo).call(this,o.data,t),tt()}catch(o){throw this.handleDrawingUploadError(o),new Error(`Failed to save image with error: ${o}`)}})}editDrawing(e){let{drawioUrl:t}=this.editor.config;if(!t)return;let i=T(this,ie,ue).call(this),r=e.getAttribute("drawio-diagram");en(t,()=>_i(r),async o=>{let s={image:o,uploaded_to:Number(this.editor.config.pageId)};try{let a=await window.$http.post("/images/drawio",s),l=`<div drawio-diagram="${a.data.id}"><img src="${a.data.url}"></div>`,c=T(this,xt,Si).call(this).split(`