File manager - Edit - /usr/local/CyberCP/public/snappymail/snappymail/v/2.38.2/static/js/min/libs.min.js
Back
(e=>{Array.prototype.unique=function(){return this.filter(((e,t,n)=>n.indexOf(e)===t))},Array.prototype.validUnique=function(e){return this.filter(((t,n,o)=>(e?e(t):t)&&o.indexOf(t)===n))};let t={LT:{hour:"numeric",minute:"numeric"},LLL:{dateStyle:"long",timeStyle:"short"}};Date.prototype.format=function(n,o,i){"string"==typeof n&&(n=t[n]?t[n]:{}),i&&(n.hourCycle=i);let r=e.documentElement;return this.toLocaleString(r.dataset.dateLang||r.lang,n)},Element.prototype.closestWithin=function(e,t){const n=this.closest(e);return n&&n!==t&&t.contains(n)?n:null},Element.fromHTML=t=>{const n=e.createElement("template");return n.innerHTML=t.trim(),n.content.firstChild},RegExp.escape||(RegExp.escape=e=>String(e).replace(/[\\^$*+?.()|[\]{}]/g,"\\$&")),Function.prototype.debounce||(Function.prototype.debounce=function(e){let t,n=this;return function(...o){t&&clearTimeout(t),t=setTimeout((()=>{n.apply(this,o),t=0}),e)}}),Function.prototype.throttle||(Function.prototype.throttle=function(e){let t,n=this;return function(...o){t=t||setTimeout((()=>{n.apply(this,o),t=0}),e)}})})(document),(e=>{let t=navigator.userAgent.toLowerCase();if(t.includes("mobile")&&t.includes("gecko/")){let t,n,o,i,r,s,a,l,c={passive:!1,capture:!1},h="move",u="all",f={};class DataTransfer{get dropEffect(){return h}set dropEffect(e){h=e}get effectAllowed(){return u}set effectAllowed(e){u=e}get files(){return[]}get items(){return[]}get types(){return Object.keys(f)}clearData(e){null!=e?delete f[e]:f={}}getData(e){return f[e]||""}setData(e,t){f[e]=t}constructor(){this.setDragImage=g}}const p=t=>e.documentElement.classList.toggle("firefox-drag",t),g=(e,t,n)=>{l?.remove(),e&&(l=e.cloneNode(!0),C(e,l),l._x=t??e.clientWidth/2,l._y=n??e.clientHeight/2)},m=()=>{n&&(clearInterval(a),l?.remove(),o&&N(s,"dragend",n),l=n=s=r=t=a=null,o=i=!1,p(!1))},v=e=>({x:(e=e.touches?e.touches[0]:e).clientX,y:e.clientY}),y=e=>{n&&(i&&"touchcancel"!==e.type&&N(s,"drop",r),m())},S=t=>{let n=e.elementFromPoint(t.x,t.y);for(;n&&"none"==getComputedStyle(n).pointerEvents;)n=n.parentElement;return n},E=e=>{requestAnimationFrame((()=>{l&&(l.style.left=Math.round(e.x-l._x)+"px",l.style.top=Math.round(e.y-l._y)+"px")}))},C=(e,t)=>{if(["id","class","style","draggable"].forEach((e=>t.removeAttribute(e))),e instanceof HTMLCanvasElement){let n=e,o=t;o.width=n.width,o.height=n.height,o.getContext("2d").drawImage(n,0,0)}let n=getComputedStyle(e);Object.entries(n).forEach((([e,n])=>e.includes("transition")||(t.style[e]=n))),t.style.pointerEvents="none";let o=e.children.length;for(;o--;)C(e.children[o],t.children[o])},N=(e,o,i)=>{if(e&&i){let r=new Event(o,{bubbles:!0,cancelable:!0});r.button=0,r.buttons=1,["altKey","ctrlKey","metaKey","shiftKey"].forEach((t=>r[t]=e[t]));let s=e.touches?e.touches[0]:e;return["pageX","pageY","clientX","clientY","screenX","screenY","offsetX","offsetY"].forEach((e=>r[e]=s[e])),n&&(r.dataTransfer=t),i.dispatchEvent(r)}return!1};e.addEventListener("touchstart",(i=>{m(),i&&!i.defaultPrevented&&i.touches&&i.touches.length<2&&(n=i.target.closest("[draggable]"),n&&(s=i,a=setTimeout((()=>{if(t=new DataTransfer,o=N(i,"dragstart",n)){p(!0);let t=v(i);l||g(n);let o=l.style;o.top=o.left="-9999px",o.position="fixed",o.pointerEvents="none",o.zIndex="999999999",E(t),e.body.append(l),N(i,"dragenter",S(t))}else m()}),1e3)))}),c),e.addEventListener("touchmove",(e=>{if(o){let t=v(e),n=S(t);s=e,n!=r&&(N(e,"dragleave",r),N(e,"dragenter",n),r=n),E(t),i=!N(e,"dragover",n)}else m()}),c),e.addEventListener("touchend",y),e.addEventListener("touchcancel",y)}})(document),(e=>{let t={},n="all";const o=document,i=/Mac OS X/.test(navigator.userAgent)?"meta":"ctrl",r={all:{}},s=e=>Array.isArray(e)?e:e.split(/\s*,\s*/),a=(e,t)=>{try{e.defaultPrevented||!1!==t(e)||(e.preventDefault(),e.stopPropagation())}catch(e){}},l={on:()=>o.addEventListener("keydown",c),off:()=>o.removeEventListener("keydown",c),add:(e,t,n,o)=>{null==o&&(o=n,n="all"),s(n).forEach((n=>{r[n]||(r[n]={}),s(e).forEach((e=>{e=e.toLowerCase(),r[n][e]||(r[n][e]={}),t=s(t).map((e=>"meta"==e?i:e)).unique().sort().join("+"),r[n][e][t]||(r[n][e][t]=[]),r[n][e][t].push(o)}))}))},setScope:e=>{n=e||"all",t=r[n]||{}},getScope:()=>n,getMetaKey:()=>"meta"===i?"⌘":"Ctrl"},c=e=>{let o=(e.key||"").toLowerCase().replace(" ","space"),i=["alt","ctrl","meta","shift"].filter((t=>e[t+"Key"])).join("+");t[o]?.[i]?.forEach((t=>a(e,t))),!e.defaultPrevented&&"all"!==n&&r.all[o]?.[i]?.forEach((t=>a(e,t)))};e.shortcuts=l,l.on()})(this),(e=>{const t=/#(.*)$/,n=/^[#/]+/,o=/^\/+/g,i=e=>e?.replace(o,"")||"",r=()=>{var e=t.exec(location.href);return e?.[1]?decodeURIComponent(e[1]):""},s=e=>{if(h!==e){var t=h;h=e,l(i(e),i(t))}},a=(e,t)=>{(e=e?"/"+e.replace(n,""):e)!==h&&(s(e),e===h&&(e="#"+encodeURI(e),t?location.replace(e):location.hash=e))},l=(...e)=>c.active&&u.forEach((t=>t(...e))),c={clear:()=>{u=[],c.active=!0},active:!0,add:e=>u.push(e),init:()=>l(i(h)),setHash:e=>a(e),replaceHash:e=>a(e,!0)};var h=r(),u=[];addEventListener("hashchange",(()=>s(r()))),e.hasher=c})(this),(e=>{const t=e=>"function"==typeof e;this.Crossroads=class Crossroads{constructor(){this._routes=[]}addRoute(e,t){var n=new Route(e,t,this);return this._routes.push(n),n}parse(e){e=e||"";for(var t,n=0,o=this._routes,i=o.length;i--;)t=o[i],n&&!t.greedy||!t.match(e)||(t.callback?.(...t._getParamsArray(e)),++n)}};class Route{constructor(e,n,o){var i=e instanceof RegExp;Object.assign(this,{greedy:!1,rules:{},_router:o,_pattern:e,_paramsIds:i?null:y(l,e),_optionalParamsIds:i?null:y(a,e),_matchRegexp:i?e:E(e),callback:t(n)?n:null})}match(e){var n=this._getParamsObject(e);return this._matchRegexp.test(e)&&0==Object.entries(this.rules).filter((([o,i])=>{var r=n[o],s=!1;return"normalize_"===o||null==r&&this._optionalParamsIds?.includes(o)?s=!0:i instanceof RegExp?s=i.test(r):Array.isArray(i)?s=i.includes(r):t(i)&&(s=i(r,e,n)),!s})).length}_getParamsObject(e){var t=S(e,this._matchRegexp)||[],n=t.length;if(this._paramsIds)for(;n--;)t[this._paramsIds[n]]=t[n];return t}_getParamsArray(e){var n=this.rules.normalize_;return t(n)?n(e,this._getParamsObject(e)):S(e,this._matchRegexp)}}const n=/[\\.+*?^$[\](){}/'#]/g,o=/\/$/g,i=/([:}]|\w(?=\/))\/?(:)/g,r=/([:}])\/?(\{)/g,s=/\{([^}]+)\}/g,a=/:([^:]+):/g,l=/(?:\{|:)([^}:]+)(?:\}|:)/g,c="__CR_RP__",h="__CR_OP__",u="__CR_RS__",f="__CR_OS__",p=new RegExp(c,"g"),g=new RegExp(h,"g"),m=new RegExp(f,"g"),v=new RegExp(u,"g"),y=(e,t)=>{for(var n,o=[];n=e.exec(t);)o.push(n[1]);return o},S=(e,t)=>{var n=t.exec(e);return n?.shift(),n},E=e=>new RegExp("^"+(e?e.replace(o,"").replace(i,"$1"+f+"$2").replace(r,"$1"+u+"$2").replace(a,h).replace(s,c).replace(n,"\\$&").replace(m,"\\/?").replace(v,"\\/").replace(g,"([^\\/]+)?/?").replace(p,"([^\\/]+)"):"")+"/?$")})(),(e=>{const t=e=>void 0!==e,n=(e,t,n)=>{if(e?.length){let i,r=0,s=!1;[...e].forEach((e=>{e&&(n&&n<++r?s||(s=!0):(i=o(e),i&&t(i)))}))}},o=e=>e.size?{fileName:(e.name||"").replace(/^.*\/([^/]*)$/,"$1"),size:e.size,file:e}:null,i=e=>e.dataTransfer.types.includes("Files");class Queue extends Array{push(e,...t){super.push([e,t]),this.call()}call(){if(!this.running){let e;for(this.running=!0;e=this.shift();)e[0](...e[1]);this.running=!1}}}class Jua{constructor(t){let o,r=t.clickElement;const s=this,a=()=>{o&&clearTimeout(o),o=0};var l,c;s.oEvents={onSelect:null,onStart:null,onComplete:null,onProgress:null,onDragEnter:null,onDragLeave:null,onBodyDragEnter:null,onBodyDragLeave:null},s.oXhrs={},s.oUids={},s.options=Object.assign({action:"",name:"uploader",limit:0},t||{}),s.oQueue=new Queue,r&&(r.style.position="relative",r.style.overflow="hidden","inline"===r.style.display&&(r.style.display="inline-block"),s.generateNewInput(r)),r=t.dragAndDropElement,r&&(l=e,c={dragover:e=>{i(e)&&(a(),r.contains(e.target)?(e.dataTransfer.dropEffect="copy",e.stopPropagation()):e.dataTransfer.dropEffect="none",e.preventDefault())},dragenter:e=>{i(e)&&(a(),e.preventDefault(),s.runEvent("onBodyDragEnter",e),r.contains(e.target)&&(a(),s.runEvent("onDragEnter",r,e)))},dragleave:t=>{if(i(t)){let i=e.elementFromPoint(t.clientX,t.clientY);i&&r.contains(i)||s.runEvent("onDragLeave",r,t),n=()=>s.runEvent("onBodyDragLeave",t),a(),o=setTimeout(n,200)}var n},drop:e=>{i(e)&&(a(),e.preventDefault(),r.contains(e.target)&&n(e.files||e.dataTransfer.files,(e=>{e&&s.addFile(e)}),s.options.limit)),s.runEvent("onDragLeave",e),s.runEvent("onBodyDragLeave",e)}},Object.entries(c).forEach((([e,t])=>l.addEventListener(e,t))))}on(e,t){return this.oEvents[e]=t,this}runEvent(e,...t){this.oEvents[e]?.apply(null,t)}getEvent(e){return this.oEvents[e]||null}addFile(e){const t="jua-uid-"+Jua.randomId(16)+"-"+Date.now().toString(),n=this.getEvent("onSelect");!e||n&&!1===n(t,e)?this.cancel(t):(this.oUids[t]=!0,this.oQueue.push(((...e)=>this.uploadTask(...e)),t,e))}uploadTask(e,n){if(!1===this.oUids[e]||!n||!n.file)return!1;try{const o=this,i=new XMLHttpRequest,r=new FormData,s=this.options.action,a=this.getEvent("onStart"),l=this.getEvent("onProgress");return i.open("POST",s,!0),l&&i.upload&&(i.upload.onprogress=n=>{n&&n.lengthComputable&&t(n.loaded)&&t(n.total)&&l(e,n.loaded,n.total)}),i.onreadystatechange=()=>{if(4===i.readyState){delete o.oXhrs[e];let t=!1,n=null;if(200===i.status)try{n=JSON.parse(i.responseText),t=!0}catch(e){}this.getEvent("onComplete")(e,t,n)}},a&&a(e),r.append(this.options.name,n.file),i.send(r),this.oXhrs[e]=i,!0}catch(e){}return!1}generateNewInput(t){if(t){const o=this,i=o.options.limit,r=e.createElement("input"),s=()=>r.click();r.type="file",r.tabIndex=-1,r.style.display="none",r.multiple=1!=i,t.addEventListener("click",s),r.addEventListener("input",(()=>{const e=e=>{o.addFile(e),setTimeout((()=>{r.remove(),t.removeEventListener("click",s),o.generateNewInput(t)}),10)};r.files?.length?n(r.files,e,i):e({fileName:r.value.split(/\\\//).pop(),size:null,file:null})}))}}cancel(e){if(this.oUids[e]=!1,this.oXhrs[e]){try{this.oXhrs[e].abort&&this.oXhrs[e].abort()}catch(e){}delete this.oXhrs[e]}}}Jua.randomId=e=>{let t=new Uint8Array((e||32)/2);return crypto.getRandomValues(t),t.map((e=>e.toString(16).padStart(2,"0"))).join("")},this.Jua=Jua})(document),(e=>{const t=e=>e.focus?e.focus():e.setActive(),n=e=>"ArrowUp"===e.key||"ArrowDown"===e.key;this.BSN={Dropdown:function(o){let i,r=[];const s=this,a=o.parentNode,l=e=>{const t=e.target;"#"===(t.href||t.parentNode?.href)?.slice(-1)&&e.preventDefault()},c=e=>{i?.classList.toggle("show",e),a.classList.toggle("show",e),o.setAttribute("aria-expanded",e),o.open=e,e?o.removeEventListener("click",f):setTimeout((()=>o.addEventListener("click",f)),1)},h=()=>{const t=(o.open?"add":"remove")+"EventListener";e[t]("click",u),e[t]("keydown",p),e[t]("keyup",g),e[t]("focus",u)},u=e=>{const t=e.target;(i.contains(t)||o.contains(t))&&"focus"===e.type||(s.hide(),l(e))},f=e=>{s.show(),l(e)},p=e=>n(e)&&e.preventDefault(),g=i=>{if("Escape"===i.key)s.toggle();else if(n(i)){let n=e.activeElement,s=n===o,l=s?0:r.indexOf(n);a.contains(n)&&(s||(l="ArrowUp"===i.key?l>1?l-1:0:l<r.length-1?l+1:l),r[l]&&t(r[l]))}};s.show=()=>{i=a.querySelector(".dropdown-menu"),r=[...i.querySelectorAll("A")].filter((e=>"none"!=e.parentNode.style.display)),!("tabindex"in i)&&i.setAttribute("tabindex","0"),c(!0),setTimeout((()=>{t(i.getElementsByTagName("INPUT")[0]||o),h()}),1)},s.hide=()=>{c(!1),h(),t(o)},s.toggle=()=>o.open?s.hide():s.show(),c(!1),o.Dropdown=s}}})(document),(e=>{function t(e,t){return e===t&&e!==Object(e)}function n(e,t){t?.dispose?.()}function o(e,t){var n=this.Lb,o=n[f];o.X||(this.Ma&&this.va[t]?(n.kb(t,e,this.va[t]),this.va[t]=null,--this.Ma):o.v[t]||n.kb(t,e,o.A?{S:e}:n.Cb(e)),e.ea&&e.Gb())}var i=e.document,r={},s=void 0!==r?r:{};s.U=(e,t)=>{e=e.split(".");for(var n=s,o=0,i=e.length-1;o<i;o++)n=n[e[o]];n[e[i]]=t},s.g={extend:(e,t)=>t?Object.assign(e,t):e,K:(e,t)=>e&&Object.entries(e).forEach((e=>t(e[0],e[1]))),Qa:e=>[...e.childNodes].forEach((e=>s.removeNode(e))),Wb:e=>{e=[...e];var t=(e[0]?.ownerDocument||i).createElement("div");return e.forEach((e=>t.append(s.ha(e)))),t},ua:(e,t)=>Array.prototype.map.call(e,t?e=>s.ha(e.cloneNode(!0)):e=>e.cloneNode(!0)),pa:(e,t)=>{s.g.Qa(e),t&&e.append(...t)},xa:(e,t)=>{if(e.length){for(t=8===t.nodeType&&t.parentNode||t;e.length&&e[0].parentNode!==t;)e.splice(0,1);for(;1<e.length&&e[e.length-1].parentNode!==t;)--e.length;if(1<e.length){t=e[0];var n=e[e.length-1];for(e.length=0;t!==n;)e.push(t),t=t.nextSibling;e.push(n)}}return e},Bb:e=>null==e?"":e.trim?e.trim():e.toString().replace(/^[\s\xa0]+|[\s\xa0]+$/g,""),Pa:e=>e.ownerDocument.documentElement.contains(1!==e.nodeType?e.parentNode:e),Db:(e,t)=>{if(!e?.nodeType)throw Error("element must be a DOM node when calling triggerEvent");e.dispatchEvent(new Event(t))},h:e=>s.W(e)?e():e,Za:(e,t)=>e.textContent=s.g.h(t)},s.U("utils",s.g),s.U("unwrap",s.g.h),(()=>{let e=0,t="__ko__"+Date.now(),n=new WeakMap;s.g.l={get:(e,t)=>(n.get(e)||{})[t],set:(e,t,o)=>(n.has(e)?n.get(e)[t]=o:n.set(e,{[t]:o}),o),Ra(e,t,n){return this.get(e,t)||this.set(e,t,n)},clear:e=>n.delete(e),Z:()=>e+++t}})(),s.g.N=(()=>{var e=s.g.l.Z(),t={1:1,8:1,9:1},n={1:1,9:1};const o=(t,n)=>{var o=s.g.l.get(t,e);return n&&!o&&(o=new Set,s.g.l.set(t,e,o)),o},i=e=>{var t=o(e);t&&new Set(t).forEach((t=>t(e))),s.g.l.clear(e),n[e.nodeType]&&r(e.childNodes,!0)},r=(e,t)=>{for(var n,o=[],r=0;r<e.length;r++)if((!t||8===e[r].nodeType)&&(i(o[o.length]=n=e[r]),e[r]!==n))for(;r--&&!o.includes(e[r]););};return{addDisposeCallback:(e,t)=>{if("function"!=typeof t)throw Error("Callback must be a function");o(e,1).add(t)},Ya:(t,n)=>{var i=o(t);i&&(i.delete(n),i.size||s.g.l.set(t,e,null))},ha:e=>(s.u.I((()=>{t[e.nodeType]&&(i(e),n[e.nodeType]&&r(e.getElementsByTagName("*")))})),e),removeNode:e=>{s.ha(e),e.parentNode&&e.parentNode.removeChild(e)}}})(),s.ha=s.g.N.ha,s.removeNode=s.g.N.removeNode,s.U("utils.domNodeDisposal",s.g.N),s.extenders={debounce:(e,t)=>e.Da((e=>function(e,t){var n;return()=>{clearTimeout(n),n=setTimeout(e,t)}}(e,t))),rateLimit:(e,t)=>e.Da((e=>function(e,t){var n;return()=>{n||(n=setTimeout((()=>{n=0,e()}),t))}}(e,t))),notify:(e,n)=>{e.ka="always"==n?null:t}};class ha{constructor(e,t,n){this.S=e,this.eb=t,this.za=n,this.Ha=!1,this.H=this.da=null}dispose(){this.Ha||(this.H&&s.g.N.Ya(this.da,this.H),this.Ha=!0,this.za(),this.S=this.eb=this.za=this.da=this.H=null)}s(e){this.da=e,s.g.N.addDisposeCallback(e,this.H=this.dispose.bind(this))}}s.P=function(){Object.setPrototypeOf(this,a),a.init(this)};var a={init:e=>{e.R=new Map,e.R.set("change",new Set),e.jb=1},subscribe:function(e,t,n){var o=this;n=n||"change";var i=new ha(o,t?e.bind(t):e,(()=>{o.R.get(n).delete(i),o.Ia?.(n)}));return o.Ja?.(n),o.R.has(n)||o.R.set(n,new Set),o.R.get(n).add(i),i},B(e,t){if("change"===(t=t||"change")&&this.Ea(),this.na(t)){t="change"===t&&this.Eb||new Set(this.R.get(t));try{s.u.nb(),t.forEach((t=>{t.Ha||t.eb(e)}))}finally{s.u.end()}}},ya(){return this.jb},Rb(e){return this.ya()!==e},Ea(){++this.jb},Da(e){var t,n,o,i,r,a=this,l=s.W(a);a.ra||(a.ra=a.B,a.B=(e,t)=>{t&&"change"!==t?"beforeChange"===t?a.gb(e):a.ra(e,t):a.hb(e)});var c=e((()=>{a.ea=!1,l&&i===a&&(i=a.fb?a.fb():a());var e=n||r&&a.Ba(o,i);r=n=t=!1,e&&a.ra(o=i)}));a.hb=(e,n)=>{n&&a.ea||(r=!n),a.Eb=new Set(a.R.get("change")),a.ea=t=!0,i=e,c()},a.gb=e=>{t||(o=e,a.ra(e,"beforeChange"))},a.ib=()=>{r=!0},a.Gb=()=>{a.Ba(o,a.L(!0))&&(n=!0)}},na(e){return(this.R.get(e)||[]).size},Ba(e,t){return!this.ka||!this.ka(e,t)},toString:()=>"[object Object]",extend:function(e){var t=this;return e&&s.g.K(e,((e,n)=>{"function"==typeof(e=s.extenders[e])&&(t=e(t,n)||t)})),t}};s.P.fn=Object.setPrototypeOf(a,Function.prototype),s.Vb=e=>"function"==typeof e?.subscribe&&"function"==typeof e.B,(()=>{let e,t=[],n=0;s.u={nb:n=>{t.push(e),e=n},end:()=>e=t.pop(),zb:t=>{if(e){if(!s.Vb(t))throw Error("Only subscribable things can act as dependencies");e.Jb.call(e.Kb,t,t.Fb||(t.Fb=++n))}},I(n,o,i){try{return t.push(e),e=void 0,n.apply(o,i||[])}finally{e=t.pop()}},ma:()=>e?.o.ma(),Ca:()=>e?.Ca,o:()=>e?.o}})();const l=Symbol("_latestValue");s.$=e=>{function t(){return 0<arguments.length?(t.Ba(t[l],arguments[0])&&(t.cb(),t[l]=arguments[0],t.valueHasMutated()),this):(s.u.zb(t),t[l])}return t[l]=e,Object.defineProperty(t,"length",{get:()=>t[l]?.length}),s.P.fn.init(t),Object.setPrototypeOf(t,c)};var c={toJSON:function(){let e=this[l];return e?.toJSON?.()||e},ka:t,L(){return this[l]},valueHasMutated:function(){this.B(this[l],"spectate"),this.B(this[l])},cb(){this.B(this[l],"beforeChange")}};Object.setPrototypeOf(c,s.P.fn);var h=s.$.Zb="__ko_proto__";c[h]=s.$,s.W=e=>{if((e="function"==typeof e&&e[h])&&e!==c[h]&&e!==s.o.fn[h])throw Error("Invalid object that looks like an observable; possibly from another Knockout instance");return!!e},s.vb=e=>"function"==typeof e&&(e[h]===c[h]||e[h]===s.o.fn[h]&&e.Sb),s.U("observable",s.$),s.U("isObservable",s.W),s.U("observable.fn",c),s.observableArray=e=>{if(e=e||[],!Array.isArray(e))throw Error("The argument passed when initializing an observable array must be an array, or null, or undefined.");return Object.setPrototypeOf(s.$(e),s.observableArray.fn).extend({trackArrayChanges:!0})};const u=Symbol("IS_OBSERVABLE_ARRAY");s.observableArray.fn=Object.setPrototypeOf({[u]:1,remove:function(e){for(var t=this.L(),n=!1,o="function"!=typeof e||s.W(e)?t=>t===e:e,i=t.length;i--;){var r=t[i];if(o(r)){if(t[i]!==r)throw Error("Array modified during remove; cannot remove item");n||this.cb(),n=!0,t.splice(i,1)}}n&&this.valueHasMutated()}},s.$.fn),Object.getOwnPropertyNames(Array.prototype).forEach((e=>{"function"==typeof Array.prototype[e]&&"constructor"!=e&&("copyWithin fill pop push reverse shift sort splice unshift".split(" ").includes(e)?s.observableArray.fn[e]=function(...t){var n=this.L();return this.cb(),this.pb(n,e,t),t=n[e](...t),this.valueHasMutated(),t===n?this:t}:s.observableArray.fn[e]=function(...t){return this()[e](...t)})})),s.isObservableArray=e=>!(!e||!e[u]),s.extenders.trackArrayChanges=(e,t)=>{function n(){if(c){var t=[].concat(e.L()||[]);if(e.na("arrayChange")){(!l||1<c)&&(l=s.g.qb(r,t,e.Ka));var n=l}r=t,l=null,c=0,n?.length&&e.B(n,"arrayChange")}}if(e.Ka={},"object"==typeof t&&s.g.extend(e.Ka,t),e.Ka.sparse=!0,!e.pb){var o,i,r,a=!1,l=null,c=0,h=e.Ja,u=e.Ia;e.Ja=t=>{h?.call(e,t),"arrayChange"===t&&(a?n():(a=!0,i=e.subscribe((()=>++c),null,"spectate"),r=[].concat(e.L()||[]),l=null,o=e.subscribe(n)))},e.Ia=t=>{u?.call(e,t),"arrayChange"!==t||e.na("arrayChange")||(o?.dispose(),i?.dispose(),i=o=null,a=!1,r=void 0)},e.pb=(e,t,n)=>{if(a&&!c){var o=[],i=e.length,r=n.length,h=0,u=(e,t,n)=>o[o.length]={status:e,value:t,index:n};switch(t){case"push":h=i;case"unshift":for(e=0;e<r;++e)u("added",n[e],h+e);break;case"pop":h=i-1;case"shift":i&&u("deleted",e[h],h);break;case"splice":h=Math.min(Math.max(0,0>n[0]?i+n[0]:n[0]),i),i=1===r?i:Math.min(h+(n[1]||0),i),r=h+r-2,t=Math.max(i,r);for(var f=[],p=[],g=2;h<t;++h,++g)h<i&&p.push(u("deleted",e[h],h)),h<r&&f.push(u("added",n[g],h));s.g.tb(p,f);break;default:return}l=o}}}};var f=Symbol("_state");s.o=(e,t)=>{function n(){if(0<arguments.length){if("function"!=typeof o)throw Error("Cannot write a value to a ko.computed unless you specify a 'write' option. If you wish to read the current value, don't pass any parameters.");return o(...arguments),this}return i.X||s.u.zb(n),(i.V||i.A&&n.oa())&&n.T(),i.J}if("object"==typeof e?t=e:(t=t||{},e&&(t.read=e)),"function"!=typeof t.read)throw Error("Pass a function that returns the value of the ko.computed");var o=t.write,i={J:void 0,Y:!0,V:!0,Aa:!1,ab:!1,X:!1,Xa:!1,A:!1,yb:t.read,s:t.s||null,ia:t.ia,Oa:null,v:{},G:0,bc:null};return n[f]=i,n.Sb="function"==typeof o,s.P.fn.init(n),Object.setPrototypeOf(n,p),t.pure&&(i.Xa=!0,i.A=!0,s.g.extend(n,g)),i.s&&(i.ab=!0,i.s.nodeType||(i.s=null)),i.A||n.T(),i.s&&n.isActive()&&s.g.N.addDisposeCallback(i.s,i.Oa=()=>{n.dispose()}),n};var p={ka:t,ma(){return this[f].G},Pb(){var e=[];return s.g.K(this[f].v,((t,n)=>e[n.fa]=n.S)),e},Sa(e){if(!this[f].G)return!1;var t=this.Pb();return t.includes(e)||!!t.find((t=>t.Sa&&t.Sa(e)))},kb(e,t,n){if(this[f].Xa&&t===this)throw Error("A 'pure' computed must not be called recursively");this[f].v[e]=n,n.fa=this[f].G++,n.ga=t.ya()},oa(){var e,t=this[f].v;for(e in t)if(Object.prototype.hasOwnProperty.call(t,e)){var n=t[e];if(this.qa&&n.S.ea||n.S.Rb(n.ga))return!0}},dc(){this[f].Aa||this.qa?.(!1)},isActive(){var e=this[f];return e.V||0<e.G},ec(){this.ea?this[f].V&&(this[f].Y=!0):this.sb()},Cb(e){return e.subscribe(this.sb,this)},sb(){this.qa?this.qa(!0):this.T(!0)},T(e){var t=this[f],n=t.ia,o=!1;if(!t.Aa&&!t.X){if(t.s&&!s.g.Pa(t.s)||n?.()){if(!t.ab)return void this.dispose()}else t.ab=!1;try{t.Aa=!0,o=this.Nb(e)}finally{t.Aa=!1}return o}},Nb(e){var t=this[f],i=t.Xa?void 0:!t.G,r={Lb:this,va:t.v,Ma:t.G};s.u.nb({Kb:r,Jb:o,o:this,Ca:i}),t.v={},t.G=0;e:{try{var a=t.yb();break e}finally{s.u.end(),r.Ma&&!t.A&&s.g.K(r.va,n),t.Y=t.V=!1}a=void 0}return t.G?r=this.Ba(t.J,a):(this.dispose(),r=!0),r&&(t.A?this.Ea():this.B(t.J,"beforeChange"),t.J=a,this.B(t.J,"spectate"),!t.A&&e&&this.B(t.J),this.ib&&this.ib()),i&&this.B(t.J,"awake"),r},L(e){var t=this[f];return(t.V&&(e||!t.G)||t.A&&this.oa())&&this.T(),t.J},Da(e){var t=this;s.P.fn.Da.call(t,e),t.fb=()=>(t[f].A||(t[f].Y?t.T():t[f].V=!1),t[f].J),t.qa=e=>{t.gb(t[f].J),t[f].V=!0,e&&(t[f].Y=!0),t.hb(t,!e)}},dispose:function(){var e=this[f];!e.A&&e.v&&s.g.K(e.v,((e,t)=>t.dispose?.())),e.s&&e.Oa&&s.g.N.Ya(e.s,e.Oa),e.v=void 0,e.G=0,e.X=!0,e.Y=!1,e.V=!1,e.A=!1,e.s=void 0,e.ia=void 0,e.yb=void 0}},g={Ja(e){var t=this,n=t[f];if(!n.X&&n.A&&"change"==e){if(n.A=!1,n.Y||t.oa())n.v=null,n.G=0,t.T()&&t.Ea();else{var o=[];s.g.K(n.v,((e,t)=>o[t.fa]=e)),o.forEach(((e,o)=>{var i=n.v[e],r=t.Cb(i.S);r.fa=o,r.ga=i.ga,n.v[e]=r})),t.oa()&&t.T()&&t.Ea()}n.X||t.B(n.J,"awake")}},Ia(e){var t=this[f];t.X||"change"!=e||this.na("change")||(s.g.K(t.v,((e,n)=>{n.dispose&&(t.v[e]={S:n.S,fa:n.fa,ga:n.ga},n.dispose())})),t.A=!0,this.B(void 0,"asleep"))},ya(){var e=this[f];return e.A&&(e.Y||this.oa())&&this.T(),s.P.fn.ya.call(this)}};Object.setPrototypeOf(p,s.P.fn);var m,v,y,S=s.$.Zb;p[S]=s.o,s.o.fn=p,s.U("computed",s.o),s.isComputed=e=>"function"==typeof e&&e[S]===p[S],s.xb=e=>"function"==typeof e?s.o(e,{pure:!0}):(e={...e,pure:!0},s.o(e)),s.C={M:e=>{switch(e.nodeName){case"OPTION":return!0===e.__ko__hasDomDataOptionValue__?s.g.l.get(e,s.i.options.Wa):e.value;case"SELECT":return 0<=e.selectedIndex?s.C.M(e.options[e.selectedIndex]):void 0;default:return e.value}},Fa:(e,t)=>{switch(e.nodeName){case"OPTION":"string"==typeof t?(s.g.l.set(e,s.i.options.Wa,void 0),delete e.__ko__hasDomDataOptionValue__,e.value=t):(s.g.l.set(e,s.i.options.Wa,t),e.__ko__hasDomDataOptionValue__=!0,e.value="number"==typeof t?t:"");break;case"SELECT":for(var n,o=-1,i=""===(t??""),r=e.options.length;r--;)if((n=s.C.M(e.options[r]))==t||""===n&&i){o=r;break}(0<=o||i&&1<e.size)&&(e.selectedIndex=o);break;default:e.value=t??""}}},s.la=(m=RegExp("\"(?:\\\\.|[^\"])*\"|'(?:\\\\.|[^'])*'|`(?:\\\\.|[^`])*`|/\\*(?:[^*]|\\*+[^*/])*\\*+/|//.*\n|/(?:\\\\.|[^/])+/w*|[^\\s:,/][^,\"'`{}()/:[\\]]*[^\\s,\"'`{}()/:[\\]]|[^\\s]","g"),v=/[\])"'A-Za-z0-9_$]+$/,y={in:1,return:1,typeof:1},{Yb:e=>{123===(e=s.g.Bb(e)).charCodeAt(0)&&(e=e.slice(1,-1));var t=[],n=(e+="\n,").match(m),o=[],i=0;if(1<n.length){for(var r,a=0;r=n[a++];){var l=r.charCodeAt(0);if(44===l){if(0>=i){c&&o.length&&t.push("'"+c+"':()=>("+o.join("")+")");var c=i=0;o=[];continue}}else if(58===l){if(!i&&!c&&1===o.length){c=o.pop();continue}}else{if(47===l&&1<r.length&&(47===r.charCodeAt(1)||42===r.charCodeAt(1)))continue;47===l&&a&&1<r.length?(l=n[a-1].match(v))&&!y[l[0]]&&(n=(e=e.slice(e.indexOf(r)+1)).match(m),a=-1,r="/"):40===l||123===l||91===l?++i:41===l||125===l||93===l?--i:c||o.length||34!==l&&39!==l||(r=r.slice(1,-1))}o.push(r)}if(0<i)throw Error("Unbalanced parentheses, braces, or brackets")}return t.push("'$data':()=>$data"),t.join(",")},cc:(e,t)=>-1<e.findIndex((e=>e.key==t)),Ga:(e,t,n,o,i,r)=>{t&&s.W(t)?!s.vb(t)||r&&t.L()===i||t(i):n.get("$data")[o]=i}}),(()=>{function e(e){return 8==e.nodeType&&o.test(e.nodeValue)}function t(e){return 8==e.nodeType&&i.test(e.nodeValue)}function n(n,o){for(var i=n,a=1,l=[];i=i.nextSibling;){if(t(i)&&(s.g.l.set(i,r,!0),! --a))return l;l.push(i),e(i)&&++a}if(!o)throw Error("Cannot find closing comment tag to match: "+n.nodeValue);return null}var o=/^\s*ko(?:\s+([\s\S]+))?\s*$/,i=/^\s*\/ko\s*$/,r="__ko_matchedEndComment__";s.m={aa:{},childNodes:t=>e(t)?n(t):t.childNodes,ja:t=>{e(t)?(t=n(t))&&[...t].forEach((e=>s.removeNode(e))):s.g.Qa(t)},pa:(t,n)=>{e(t)?(s.m.ja(t),t.after(...n)):s.g.pa(t,n)},prepend:(t,n)=>{e(t)?t.nextSibling.before(n):t.prepend(n)},Ub:(e,t,n)=>{n?n.after(t):s.m.prepend(e,t)},firstChild:n=>{if(e(n))return!(n=n.nextSibling)||t(n)?null:n;let o=n.firstChild;if(o&&t(o))throw Error("Found invalid end comment, as the first child of "+n);return o},nextSibling:o=>{if(e(o)){var i=n(o,void 0);o=i?(i.length?i[i.length-1]:o).nextSibling:null}if((i=o.nextSibling)&&t(i)){if(t(i)&&!s.g.l.get(i,r))throw Error("Found end comment without a matching opening comment, as child of "+o);return null}return i},Qb:e,ac:e=>(e=e.nodeValue.match(o))?e[1]:null}})();const E=new Map;s.ob=new class{Xb(e){switch(e.nodeType){case 1:return null!=e.getAttribute("data-bind");case 8:return s.m.Qb(e)}return!1}Ob(e,t){e:{switch(e.nodeType){case 1:var n=e.getAttribute("data-bind");break e;case 8:n=s.m.ac(e);break e}n=null}if(n)try{let i=E.get(n);if(!i){var o="with($data){return{"+s.la.Yb(n)+"}}";i=new Function("$context","$root","$parent","$data","$element",o),E.set(n,i)}return i(t,t.$root,t.$parent,t.$data||{},e)}catch(e){throw e.message="Unable to parse bindings.\nBindings value: "+n+"\nMessage: "+e.message,e}return null}};const C=Symbol("_subscribable"),N=Symbol("_ancestorBindingInfo"),_=Symbol("_dataDependency"),T={},x=s.g.l.Z();s.i={},s.ba=class{constructor(e,t,n,o){var i=this,r=e===T,a=r?void 0:e,l="function"==typeof a&&!s.W(a),c=o?.dataDependency;if(e=()=>{var e=l?a():a;return e=s.g.h(e),t?(s.g.extend(i,t),N in t&&(i[N]=t[N])):i.$root=e,i[C]=h,r?e=i.$data:i.$data=e,n?.(i,t,e),t?.[C]&&!s.u.o().Sa(t[C])&&t[C](),c&&(i[_]=c),i.$data},o?.exportDependencies)e();else{var h=s.xb(e);h.L(),h.isActive()?h.ka=null:i[C]=void 0}}createChildContext(e,t){return new s.ba(e,this,((e,n)=>{e.$parent=n.$data,t.extend?.(e)}),t)}extend(e,t){return new s.ba(T,this,(t=>s.g.extend(t,"function"==typeof e?e(t):e)),t)}};const L=e=>{e=s.g.l.get(e,x);var t=e?.D;t&&(e.D=null,t.wb())};class ma{constructor(e,t,n){this.H=e,this.da=t,this.ta=new Set,this.F=!1,t.D||s.g.N.addDisposeCallback(e,L),n?.D&&(n.D.ta.add(e),this.za=n)}wb(){this.za?.D?.Mb(this.H)}Mb(e){this.ta.delete(e),this.ta.size||this.rb?.()}rb(){this.F=!0,this.da.D&&!this.ta.size&&(this.da.D=null,s.g.N.Ya(this.H,L),s.j.notify(this.H,s.j.ca),this.wb())}}s.j={F:"childrenComplete",ca:"descendantsComplete",subscribe:(e,t,n,o,i)=>{var r=s.g.l.Ra(e,x,{});return r.wa||(r.wa=new s.P),i?.notifyImmediately&&r.Va[t]&&s.u.I(n,o,[e]),r.wa.subscribe(n,o,t)},notify:(e,t)=>{var n=s.g.l.get(e,x);if(n&&(n.Va[t]=!0,n.wa?.B(e,t),t==s.j.F))if(n.D)n.D.rb();else if(void 0===n.D&&n.wa?.na(s.j.ca))throw Error("descendantsComplete event not supported for bindings on this node")},$a:(e,t)=>{var n=s.g.l.Ra(e,x,{});return n.D||(n.D=new ma(e,n,t[N])),t[N]==n?t:t.extend((e=>{e[N]=n}))}};const A=(e,t)=>{for(var n,o=s.m.firstChild(t);n=o;)o=s.m.nextSibling(n),k(e,n);s.j.notify(t,s.j.F)},k=(e,t)=>{var n=e;(1===t.nodeType||s.ob.Xb(t))&&(n=O(t,null,e)),n&&!t.matches?.("SCRIPT,TEXTAREA,TEMPLATE")&&A(n,t)},O=(e,t,n)=>{var o=s.g.l.Ra(e,x,{}),i=o.Hb;if(!t){if(i)throw Error("You cannot apply bindings multiple times to the same element.");o.Hb=!0}if(i||(o.context=n),o.Va||(o.Va={}),t&&"function"!=typeof t)var r=t;else{var a=s.o((()=>((r=t?t(n,e):s.ob.Ob(e,n))&&(n[C]?.(),n[_]?.()),r)),{s:e});r&&a.isActive()||(a=null)}var l,c=n;if(r){var h=a?e=>()=>a()[e]():e=>r[e],u={get:e=>r[e]&&h(e)(),has:e=>e in r};s.j.F in r&&s.j.subscribe(e,s.j.F,(()=>{var t=r[s.j.F]();if(t){var n=s.m.childNodes(e);n.length&&t(n,s.dataFor(n[0]))}})),s.j.ca in r&&(c=s.j.$a(e,n),s.j.subscribe(e,s.j.ca,(()=>{var t=r[s.j.ca]();t&&s.m.firstChild(e)&&t(e)}))),(e=>{var t=[],n={},o=[],i=r=>{if(!n[r]){var a=s.i[r];a&&(a.after&&(o.push(r),a.after.forEach((t=>{if(e[t]){if(o.includes(t))throw Error("Cannot combine the following bindings, because they have a cyclic dependency: "+o.join(", "));i(t)}})),o.length--),t.push({key:r,ub:a})),n[r]=!0}};return s.g.K(e,i),t})(r).forEach((t=>{var n=t.ub.init,o=t.ub.update,i=t.key;if(8===e.nodeType&&!s.m.aa[i])throw Error("The binding '"+i+"' cannot be used with comment nodes");try{"function"==typeof n&&s.u.I((()=>{var t=n(e,h(i),u,c.$data,c);if(t&&t.controlsDescendantBindings){if(void 0!==l)throw Error("Multiple bindings ("+l+" and "+i+") are trying to control descendant bindings of the same element. You cannot use these bindings together on the same element.");l=i}})),"function"==typeof o&&s.o((()=>o(e,h(i),u,c.$data,c)),{s:e})}catch(e){throw e.message='Unable to process binding "'+i+": "+r[i]+'"\nMessage: '+e.message,e}}))}return void 0===l&&c};s.$b=e=>s.g.l.get(e,x)?.context;const w=e=>e&&e instanceof s.ba?e:new s.ba(e);s.applyBindingAccessorsToNode=(e,t,n)=>O(e,t,w(n)),s.mb=(e,t)=>{1!==t.nodeType&&8!==t.nodeType||A(w(e),t)},s.Ib=(e,t)=>k(w(e),t),s.dataFor=e=>([1,8].includes(e?.nodeType)&&s.$b(e))?.$data,s.U("bindingHandlers",s.i),(()=>{var e=Object.create(null),t=new Map;s.components={get:(n,o)=>{if(t.has(n))o(t.get(n));else{var i=e[n];i?i.subscribe(o):((i=e[n]=new s.P).subscribe(o),r(n,(o=>{t.set(n,o),delete e[n],i.B(o)})))}},register:(e,t)=>{if(!t)throw Error("Invalid configuration for "+e);if(n[e])throw Error("Component "+e+" is already registered");n[e]=t}};var n=Object.create(null),o=(e,t)=>{throw Error(`Component '${e}': ${t}`)},r=(e,t)=>{var r={},a=n[e]||{},l=a.template;if(a=a.viewModel,l){l.element||o(e,"Unknown template value: "+l),l=l.element;var c=i.getElementById(l);c||o(e,"Cannot find element with ID "+l),c.matches("TEMPLATE")||o(e,"Template Source Element not a <template>"),r.template=s.g.ua(c.content.childNodes)}a&&("function"!=typeof a.createViewModel&&o(e,"Unknown viewModel value: "+a),r.createViewModel=a.createViewModel),t(r.template&&r.createViewModel?r:null)}})(),(()=>{var e=0;s.i.component={init:(t,n,o,i,r)=>{var a,l,c,h=()=>{var e=a&&a.dispose;"function"==typeof e&&e.call(a),c&&c.dispose(),l=a=c=null};return s.m.ja(t),s.g.N.addDisposeCallback(t,h),s.o((()=>{var o=s.g.h(n());if("string"!=typeof o){var i=s.g.h(o.params);o=s.g.h(o.name)}if(!o)throw Error("No component name specified");var c=s.j.$a(t,r),u=l=++e;s.components.get(o,(e=>{if(l===u){if(h(),!e)throw Error("Unknown component '"+o+"'");var n=e.template;if(!n)throw Error("Component '"+o+"' has no template");s.m.pa(t,s.g.ua(n)),a=e.createViewModel(i,{element:t}),s.mb(c.createChildContext(a,{}),t)}}))}),{s:t}),{controlsDescendantBindings:!0}}},s.m.aa.component=!0})(),s.i.attr={update:(e,t)=>{t=s.g.h(t())||{},s.g.K(t,(function(t,n){n=s.g.h(n);var o=t.indexOf(":");o="lookupNamespaceURI"in e&&0<o&&e.lookupNamespaceURI(t.slice(0,o)),!1===n||null==n?o?e.removeAttributeNS(o,t):e.removeAttribute(t):(n=n.toString(),o?e.setAttributeNS(o,t,n):e.setAttribute(t,n))}))}},s.i.checked={after:["value","attr"],init:function(e,t,n){var o="checkbox"==e.type,i="radio"==e.type;if(o||i){const f=s.xb((()=>n.has("checkedValue")?s.g.h(n.get("checkedValue")):h?n.has("value")?s.g.h(n.get("value")):e.value:void 0));var r=()=>{if(!s.u.Ca()){var r=e.checked,a=f();if(r||!i&&!s.u.ma()){var h=s.u.I(t);if(l){var p=c?h.L():h,g=u;u=a,g!==a?r&&(p.push(a),p.remove(g)):r?p.push(a):p.remove(a),c&&s.vb(h)&&h(p)}else o&&(void 0===a?a=r:r||(a=void 0)),s.la.Ga(e,h,n,"checked",a,!0)}}},a=t(),l=o&&s.g.h(a)instanceof Array,c=!(l&&a.push&&a.splice),h=i||l,u=l?f():void 0;s.o(r,null,{s:e}),e.addEventListener("click",r),s.o((()=>{var n=s.g.h(t()),i=f();l?(e.checked=n.includes(i),u=i):e.checked=o&&void 0===i?!!n:f()===n}),null,{s:e}),a=void 0}}},s.i.checkedValue={update:function(e,t){e.value=s.g.h(t())}};var D=(e,t,n)=>t&&t.split(/\s+/).forEach((t=>e.classList.toggle(t,n)));s.i.css={update:(e,t)=>{"object"==typeof(t=s.g.h(t()))?s.g.K(t,((t,n)=>{n=s.g.h(n),D(e,t,!!n)})):(t=s.g.Bb(t),D(e,e.__ko__cssValue,!1),e.__ko__cssValue=t,D(e,t,!0))}},s.i.enable={update:(e,t)=>{(t=s.g.h(t()))&&e.disabled?e.removeAttribute("disabled"):t||e.disabled||(e.disabled=!0)}},s.i.disable={update:(e,t)=>s.i.enable.update(e,(()=>!s.g.h(t())))},s.i.event={init:function(e,t,n,o,i){s.g.K(t()||{},(n=>{"string"==typeof n&&e.addEventListener(n,((...e)=>{var r=t()[n];if(r)try{o=i.$data;var s=r.apply(o,[o,...e])}finally{!0!==s&&e[0].preventDefault()}}))}))}};const R=e=>()=>{var t=e(),n=s.W(t)?t.L():t;return!n||Array.isArray(n)?{foreach:t}:(s.g.h(t),{foreach:n.data})};s.i.foreach={init:(e,t)=>s.i.template.init(e,R(t)),update:(e,t,n,o,i)=>s.i.template.update(e,R(t),n,o,i)},s.m.aa.foreach=!0,s.i.hasfocus={init:(e,t,n)=>{var o=o=>{e.__ko_hasfocusUpdating=!0,o=e.ownerDocument.activeElement===e,s.la.Ga(e,t(),n,"hasfocus",o,!0),e.__ko_hasfocusLastValue=o,e.__ko_hasfocusUpdating=!1},i=o.bind(null,!0);o=o.bind(null,!1),e.addEventListener("focus",i),e.addEventListener("focusin",i),e.addEventListener("blur",o),e.addEventListener("focusout",o),e.__ko_hasfocusLastValue=!1},update:(e,t)=>{t=!!s.g.h(t()),e.__ko_hasfocusUpdating||e.__ko_hasfocusLastValue===t||(t?e.focus():e.blur())}},s.i.html={init:()=>({controlsDescendantBindings:!0}),update:(e,t)=>{if(s.g.Qa(e),null!=(t=s.g.h(t()))){const n=i.createElement("template");n.innerHTML="string"!=typeof t?t.toString():t,e.appendChild(n.content)}}},(()=>{function e(e,t,n){s.i[e]={init:(e,o,i,r,a)=>{var l,c={};t&&(c={exportDependencies:!0});var h=i.has(s.j.ca);return s.o((()=>{var i=s.g.h(o()),r=!n!=!i,u=!l;if(h&&(a=s.j.$a(e,a)),r){c.dataDependency=s.u.o();var f=t?a.createChildContext("function"==typeof i?i:o,c):s.u.ma()?a.extend(null,c):a}u&&s.u.ma()&&(l=s.g.ua(s.m.childNodes(e),!0)),r?(u||s.m.pa(e,s.g.ua(l)),s.mb(f,e)):(s.m.ja(e),s.j.notify(e,s.j.F))}),{s:e}),{controlsDescendantBindings:!0}}},s.m.aa[e]=!0}e("if"),e("ifnot",!1,!0),e("with",!0)})();var B={};s.i.options={init:e=>{if(!e.matches("SELECT"))throw Error("options binding applies only to SELECT elements");let t=e.length;for(;t--;)e.remove(t);return{controlsDescendantBindings:!0}},update:(e,t,n)=>{var o=e.multiple,i=0!=e.length&&o?e.scrollTop:null,r=s.g.h(t()),a=[];t=()=>Array.from(e.options).filter((e=>e.selected));var l=(e,t,n)=>{var o=typeof t;return"function"==o?t(e):"string"==o?e[t]:n},c=(t,n)=>{a.length&&(t=a.includes(s.C.M(n[0])),n[0].selected=t,u&&!t&&s.u.I(s.g.Db,null,[e,"change"]))};if(o?a=t().map(s.C.M):0<=e.selectedIndex&&a.push(s.C.M(e.options[e.selectedIndex])),r){Array.isArray(r)||(r=[r]);var h=r.filter((e=>e??1))}var u=!1;r=c,n.has("optionsAfterRender")&&"function"==typeof n.get("optionsAfterRender")&&(r=(e,t)=>{c(e,t),s.u.I(n.get("optionsAfterRender"),null,[t[0],e!==B?e:void 0])}),s.g.Ab(e,h,((t,o,i)=>(i.length&&(a=i[0].selected?[s.C.M(i[0])]:[],u=!0),o=e.ownerDocument.createElement("option"),t===B?(s.g.Za(o),s.C.Fa(o,void 0)):(i=l(t,n.get("optionsValue"),t),s.C.Fa(o,s.g.h(i)),t=l(t,n.get("optionsText"),i),s.g.Za(o,t)),[o])),{},r),h=a.length,(o?h&&t().length<h:h&&0<=e.selectedIndex?s.C.M(e.options[e.selectedIndex])!==a[0]:h||0<=e.selectedIndex)&&s.u.I(s.g.Db,null,[e,"change"]),s.u.Ca()&&s.j.notify(e,s.j.F),i&&20<Math.abs(i-e.scrollTop)&&(e.scrollTop=i)}},s.i.options.Wa=s.g.l.Z(),s.i.style={update:(e,t)=>{s.g.K(s.g.h(t()||{}),((t,n)=>{if(null!=(n=s.g.h(n))&&!1!==n||(n=""),/^--/.test(t))e.style.setProperty(t,n);else{t=t.replace(/-(\w)/g,((e,t)=>t.toUpperCase()));var o=e.style[t];e.style[t]=n,n===o||e.style[t]!=o||isNaN(n)||(e.style[t]=n+"px")}}))}},s.i.submit={init:(e,t,n,o,i)=>{if("function"!=typeof t())throw Error("The value for a submit binding must be a function");e.addEventListener("submit",(n=>{var o=t();try{var r=o.call(i.$data,e)}finally{!0!==r&&n.preventDefault()}}))}},s.i.text={init:()=>({controlsDescendantBindings:!0}),update:(e,t)=>{8===e.nodeType&&(e.text||e.after(e.text=i.createTextNode("")),e=e.text),s.g.Za(e,t())}},s.m.aa.text=!0,s.i.textInput={init:(e,t,n)=>{var o,i,r=e.value,a=()=>{clearTimeout(o),i=o=void 0;var a=e.value;e.checkValidity()&&r!==a&&(r=a,s.la.Ga(e,t(),n,"textInput",a))},l=()=>{var n=s.g.h(t())??"";void 0!==i&&n===i?setTimeout(l,4):e.value!==n&&(e.value=n,r=e.value)};e.addEventListener("input",a),e.addEventListener("change",a),s.o(l,{s:e})}},s.i.value={init:(e,t,n)=>{var o=e.matches("SELECT"),i=e.matches("INPUT");if(!i||"checkbox"!=e.type&&"radio"!=e.type){var r=new Set,a=n.get("valueUpdate"),l=null,c=()=>{l=null;var o=t(),i=s.C.M(e);s.la.Ga(e,o,n,"value",i)};a&&("string"==typeof a?r.add(a):a.forEach((e=>r.add(e))),r.delete("change")),r.forEach((t=>{var n=c;(t||"").startsWith("after")&&(n=()=>{l=s.C.M(e),setTimeout(c,0)},t=t.slice(5)),e.addEventListener(t,n)}));var h,u=i&&"file"==e.type?()=>{var n=s.g.h(t());null==n||""===n?e.value="":s.u.I(c)}:()=>{var n=s.g.h(t()),i=s.C.M(e);null!==l&&n===l?setTimeout(u,0):n===i&&void 0!==i||(o?(s.C.Fa(e,n),n!==s.C.M(e)&&s.u.I(c)):s.C.Fa(e,n))};if(o)s.j.subscribe(e,s.j.F,(()=>{h?n.get("valueAllowUnset")?u():c():(e.addEventListener("change",c),h=s.o(u,{s:e}))}),null,{notifyImmediately:!0});else e.addEventListener("change",c),s.o(u,{s:e})}else s.applyBindingAccessorsToNode(e,{checkedValue:t})},update:()=>{}},s.i.visible={update:(e,t)=>{t=s.g.h(t());var n="none"!=e.style.display;t&&!n?e.style.display="":n&&!t&&(e.style.display="none")}},s.i.hidden={update:(e,t)=>e.hidden=!!s.g.h(t())},function(e){s.i[e]={init:function(t,n,o,i,r){return s.i.event.init.call(this,t,(()=>({[e]:n()})),o,i,r)}}}("click"),(()=>{let e=s.g.l.Z();class b{constructor(e){this.Na=e}Ua(...t){let n=this.Na;if(!t.length)return s.g.l.get(n,e)||(11===this.H?n.content:1===this.H?n:void 0);s.g.l.set(n,e,t[0])}}s.bb={Na:class d extends b{constructor(e){super(e),e&&(this.H=e.matches("TEMPLATE")&&e.content?e.content.nodeType:1)}},lb:b}})(),(()=>{const e=(e,t)=>{if(e.length){var n=e[0],o=n.parentNode;((e,t,n)=>{var o;for(t=s.m.nextSibling(t);e&&(o=e)!==t;)n(o,e=s.m.nextSibling(o))})(n,e[e.length-1],(e=>(1===e.nodeType||8===e.nodeType)&&s.Ib(t,e))),s.g.xa(e,o)}},t=(t,n,o,r)=>{var a=(t&&(t.nodeType?t:0<t.length?t[0]:null)||o||{}).ownerDocument;if("string"==typeof o){if(!(a=(a=a||i).getElementById(o)))throw Error("Cannot find template with ID "+o);o=new s.bb.Na(a)}else{if(![1,8].includes(o.nodeType))throw Error("Unknown template type: "+o);o=new s.bb.lb(o)}if(o=(o=o.Ua?o.Ua():null)?[...o.cloneNode(!0).childNodes]:null,!Array.isArray(o)||0<o.length&&"number"!=typeof o[0].nodeType)throw Error("Template engine must return an array of DOM nodes");return n&&(s.m.pa(t,o),e(o,r),s.j.notify(t,s.j.F)),o},n=(e,t,n)=>s.W(e)?e():"function"==typeof e?e(t,n):e,o=s.g.l.Z();s.i.template={init:(e,t)=>{if("string"==typeof(t=s.g.h(t()))||"name"in t)s.m.ja(e);else{if(!(t=s.m.childNodes(e)).length)throw Error("Anonymous template defined, but no template content was provided");t=s.g.Wb(t),new s.bb.lb(e).Ua(t)}return{controlsDescendantBindings:!0}},update:(i,r,a,l,c)=>{l=r(),a=null,"string"==typeof(r=s.g.h(l))?r={}:l="name"in r?r.name:i;var h=!!l;"foreach"in r?a=((o,i,r,a,l)=>{var c,h=(e,i)=>(c=l.createChildContext(e,{extend:e=>e.$index=i}),e=n(o,e,c),t(a,!1,e,c)),u=(t,n)=>{e(n,c),c=null},f=(e,t)=>{s.u.I(s.g.Ab,null,[a,e,h,r,u,t]),s.j.notify(a,s.j.F)};if(s.isObservableArray(i)){f(i.L());var p=i.subscribe((e=>{f(i(),e)}),null,"arrayChange");return p.s(a),p}return s.o((()=>{var e=s.g.h(i)||[];Array.isArray(e)||(e=[e]),f(e)}),{s:a})})(l,h&&r.foreach||[],r,i,c):h?(a=c,"data"in r&&(a=c.createChildContext(r.data,{exportDependencies:!0})),a=((e,o,i,r)=>{if(i=i||{},r){var a=r.nodeType?r:0<r.length?r[0]:null;return s.o((()=>{var i=o instanceof s.ba?o:new s.ba(o,null,null,{exportDependencies:!0}),a=n(e,i.$data,i);t(r,!0,a,i)}),{ia:()=>!a||!s.g.Pa(a),s:a})}})(l,a,r,i)):s.m.ja(i),c=a,s.g.l.get(i,o)?.dispose?.(),s.g.l.set(i,o,!c||c.isActive&&!c.isActive()?void 0:c)}},s.m.aa.template=!0})(),s.g.tb=(e,t,n)=>{var o,i=0,r=t.length;r&&e.every((e=>(0<=(o=t.findIndex((t=>e.value===t.value)))&&(e.moved=t[o].index,t[o].moved=e.index,t.splice(o,1),i=o=0,--r),i+=r,r&&(!n||i<n))))},s.g.qb=(()=>{var e=(e,t,n,o,i)=>{for(var r,a,l,c,h=Math.min,u=Math.max,f=[],p=-1,g=e.length,m=t.length,v=m-g||1,y=g+m+1;++p<=g;)for(l=a,f.push(a=[]),c=h(m,p+v),r=u(0,p-1);r<=c;r++)a[r]=r?p?e[p-1]===t[r-1]?l[r-1]:h(l[r]||y,a[r-1]||y)+1:r+1:p+1;for(h=[],u=[],v=[],p=g,r=m;p||r;)m=f[p][r]-1,r&&m===f[p][r-1]?u.push(h[h.length]={status:n,value:t[--r],index:r}):p&&m===f[p-1][r]?v.push(h[h.length]={status:o,value:e[--p],index:p}):(--r,--p,i.sparse||h.push({status:"retained",value:t[r]}));return s.g.tb(v,u,10*g),h.reverse()};return(t,n,o)=>(n=n||[],(t=t||[]).length<n.length?e(t,n,"added","deleted",o):e(n,t,"deleted","added",o))})(),(()=>{var e=s.g.l.Z(),t=s.g.l.Z();s.g.Ab=(n,o,i,r,a,l)=>{o=o||[],Array.isArray(o)||(o=[o]);var c,h=s.g.l.get(n,e),u=[],f=0,p=0,g=[],m=[],v=e=>{c={sa:e,Ta:s.$(p++)},u.push(c)},y=e=>{(c=h[e]).Ta(p++),s.g.xa(c.O,n),u.push(c)};if(h){let e,t;for((!l||h&&h._countWaitingForRemove)&&(l=s.g.qb(Array.prototype.map.call(h,(e=>e.sa)),o,{sparse:!0})),l.forEach((o=>{switch(e=o.moved,t=o.index,o.status){case"deleted":for(;f<t;)y(f++);void 0===e&&((c=h[f]).La&&(c.La.dispose(),c.La=void 0),s.g.xa(c.O,n).length&&c&&g.push.apply(g,c.O)),f++;break;case"added":for(;p<t;)y(f++);void 0!==e?(m.push(u.length),y(e)):v(o.value)}}));p<o.length;)y(f++);u._countWaitingForRemove=0}else o.forEach(v);s.g.l.set(n,e,u),g.forEach(s.removeNode);var S=e=>{s.m.Ub(n,e,E),E=e};if(l=n.ownerDocument.activeElement,m.length)for(;null!=(o=m.shift());){for(c=u[o];o--;)if(r=u[o].O,r?.length){var E=r[r.length-1];break}c.O.forEach(S)}u.forEach((e=>{e.O||s.g.extend(e,function(e,t,n,o,i){var r=[],a=s.o((()=>{var a=t(n,i,s.g.xa(r,e))||[];if(0<r.length){var l=r.nodeType?[r]:r;if(0<l.length){var c=l[0],h=c.parentNode;a.forEach((e=>h.insertBefore(e,c))),l.forEach((e=>s.removeNode(e)))}o&&s.u.I(o,null,[n,a,i])}r.length=0,r.push(...a)}),{s:e,ia:()=>!!r.find(s.g.Pa)});return{O:r,La:a.isActive()?a:void 0}}(n,i,e.sa,a,e.Ta)),e.O.forEach(S),!e.Tb&&a&&(a(e.sa,e.O,e.Ta),e.Tb=!0,E=e.O[e.O.length-1])})),n.ownerDocument.activeElement!=l&&l?.focus(),[].forEach((e=>e&&(e.sa=t)))}})(),e.ko=r})(this),(()=>{var e=NodeFilter.FILTER_ACCEPT;TreeWalker.prototype.previousPONode=function(){const t=this.root;let n,o=this.currentNode;for(;;){for(n=o.lastChild;!n&&o&&o!==t;)n=o.previousSibling,n||(o=o.parentNode);if(!n)return null;const i=n.nodeType;if((i===Node.ELEMENT_NODE?NodeFilter.SHOW_ELEMENT:i===Node.TEXT_NODE?NodeFilter.SHOW_TEXT:0)&this.whatToShow&&e===this.filter.acceptNode(n))return this.currentNode=n,n;o=n}};var t=(t,n,o)=>document.createTreeWalker(t,n,{acceptNode:t=>!o||o(t)?e:NodeFilter.FILTER_SKIP}),n="",o=navigator.userAgent,i=/Mac OS X/.test(o),r=/Windows NT/.test(o),s=/iP(?:ad|hone)/.test(o)||i&&!!navigator.maxTouchPoints,a=(/Android/.test(o),i||s?"Meta-":"Ctrl-"),l=/WebKit\//.test(o),c=/[^ \t\r\n]/,h=/^(?:#text|A(?:BBR|CRONYM)?|B(?:R|D[IO])?|C(?:ITE|ODE)|D(?:ATA|EL|FN)|EM|FONT|HR|I(?:MG|NS)?|KBD|Q|R(?:P|T|UBY)|S(?:AMP|MALL|PAN|TR(?:IKE|ONG)|U[BP])?|TIME|U|VAR|WBR)$/,u=new Set(["BR","HR","IMG"]),f=new WeakMap,p=e=>u.has(e.nodeName),g=e=>{switch(e.nodeType){case 3:return 1;case 1:case 11:if(f.has(e))return f.get(e);break;default:return 0}let t;return t=Array.from(e.childNodes).every(m)?h.test(e.nodeName)?1:2:3,f.set(e,t),t},m=e=>1===g(e),v=e=>2===g(e),y=e=>3===g(e),S=(e,t,n)=>{const o=document.createElement(e);return t instanceof Array&&(n=t,t=null),w(o,t),n&&o.append(...n),o},E=(e,t)=>!p(e)&&(e.nodeType===t.nodeType&&e.nodeName===t.nodeName&&(!(e instanceof HTMLElement&&t instanceof HTMLElement)||"A"!==e.nodeName&&e.className===t.className&&e.style.cssText===t.style.cssText)),C=(e,t,n)=>{if(e.nodeName!==t)return!1;for(const t in n)if(!("getAttribute"in e)||e.getAttribute(t)!==n[t])return!1;return!0},N=(e,t,n,o)=>{for(;e&&e!==t;){if(C(e,n,o))return e;e=e.parentNode}return null},_=(e,t)=>{let n=e.childNodes;for(;t&&e instanceof Element;)n=(e=n[t-1]).childNodes,t=n.length;return e},T=(e,t)=>{let n=e;if(n instanceof Element){const e=n.childNodes;if(t<e.length)n=e[t];else{for(;n&&!n.nextSibling;)n=n.parentNode;n&&(n=n.nextSibling)}}return n},x=e=>e instanceof Element||e instanceof DocumentFragment?e.childNodes.length:e instanceof CharacterData?e.length:0,L=e=>{const t=document.createDocumentFragment();return t.append(...e.childNodes),t},A=e=>(e.parentNode?.removeChild(e),e),k=(e,t)=>e.parentNode?.replaceChild(t,e),O=(e,t,n)=>(e=(e&&!e.closest?e.parentElement:e)?.closest(n),e&&t.contains(e)?e:null),w=(e,t)=>{t&&Object.entries(t).forEach((([t,n])=>{null==n?e.removeAttribute(t):"style"===t&&"object"==typeof n?Object.entries(n).forEach((([t,n])=>e.style[t]=n)):e.setAttribute(t,n)}))},D=e=>e instanceof Element?"BR"===e.nodeName:c.test(e.data),R=e=>{let n=e.parentNode;for(;m(n);)n=n.parentNode;const o=t(n,5,D);return o.currentNode=e,!!o.nextNode()},B=(e,o)=>{const i=t(e,4);let r,s;for(;r=i.nextNode();)for(;(s=r.data.indexOf(n))>-1&&(!o||r.parentNode!==o);){if(1===r.length){let e=r,t=e.parentNode;for(;t&&(t.removeChild(e),i.currentNode=t,m(t)&&!x(t));)e=t,t=e.parentNode;break}r.deleteData(s,1)}},I=(e,t,n)=>{if(n)return e.intersectsNode(t);{const n=document.createRange();n.selectNode(t);const o=e.compareBoundaryPoints(0,n)<1,i=e.compareBoundaryPoints(2,n)>-1;return o&&i}},U=e=>{let{startContainer:t,startOffset:n,endContainer:o,endOffset:i}=e;for(;!(t instanceof Text);){let e=t.childNodes[n];if(!e||p(e)){if(n&&(e=t.childNodes[n-1],e instanceof Text)){let o,i=e;for(;!i.length&&(o=i.previousSibling)&&o instanceof Text;)i.remove(),i=o;t=i,n=i.length}break}t=e,n=0}if(i)for(;!(o instanceof Text);){const e=o.childNodes[i-1];if(!e||p(e)){if(e&&"BR"===e.nodeName&&!R(e)){--i;continue}break}o=e,i=x(o)}else for(;!(o instanceof Text);){const e=o.firstChild;if(!e||p(e))break;o=e}e.setStart(t,n),e.setEnd(o,i)},P=(e,t,n,o)=>{let i,r=e.startContainer,s=e.startOffset,a=e.endContainer,l=e.endOffset;for(t||(t=e.commonAncestorContainer),n||(n=t);!s&&r!==t&&r!==o;)i=r.parentNode,s=Array.from(i.childNodes).indexOf(r),r=i;for(;a!==n&&a!==o&&(3!==a.nodeType&&a.childNodes[l]&&"BR"===a.childNodes[l].nodeName&&!R(a.childNodes[l])&&++l,l===x(a));)i=a.parentNode,l=Array.from(i.childNodes).indexOf(a)+1,a=i;e.setStart(r,s),e.setEnd(a,l)},M=(e,t,n)=>{let o=O(e.endContainer,n,t);if(o&&(o=o.parentNode)){const t=e.cloneRange();P(t,o,o,n),t.endContainer===o&&(e.setStart(t.endContainer,t.endOffset),e.setEnd(t.endContainer,t.endOffset))}return e},F={"font-weight":{regexp:/^bold|^700/i,replace:()=>S("B")},"font-style":{regexp:/^italic/i,replace:()=>S("I")},"font-family":{regexp:c,replace:(e,t)=>S("SPAN",{class:e.fontFamily,style:"font-family:"+t})},"font-size":{regexp:c,replace:(e,t)=>S("SPAN",{class:e.fontSize,style:"font-size:"+t})},"text-decoration":{regexp:/^underline/i,replace:()=>S("U")}},H=e=>(t,n)=>{const o=S(e),i=t.attributes;for(let e=0,t=i.length;e<t;++e){const t=i[e];o.setAttribute(t.name,t.value)}return n.replaceChild(o,t),o.append(L(t)),o},j={1:"x-small",2:"small",3:"medium",4:"large",5:"x-large",6:"xx-large",7:"xxx-large","-1":"smaller","+1":"larger"},$={STRONG:H("B"),EM:H("I"),INS:H("U"),STRIKE:H("S"),SPAN:(e,t,n)=>{const o=e.style;let i,r;for(const t in F){const s=F[t],a=o.getPropertyValue(t);if(a&&s.regexp.test(a)){const o=s.replace(n.classNames,a);if(o.nodeName===e.nodeName&&o.className===e.className)continue;r||(r=o),i&&i.append(o),i=o,e.style.removeProperty(t)}}return r&&i&&(i.append(L(e)),e.style.cssText?e.append(r):k(e,r)),i||e},FONT:(e,t,n)=>{const o=e,i=o.face,r=o.size;let s=o.color,a=S("SPAN"),l=a.style;return a.style.cssText=e.style.cssText,i&&(l.fontFamily=i),r&&(l.fontSize=j[r]),s&&/^#?([\dA-F]{3}){1,2}$/i.test(s)&&("#"!==s.charAt(0)&&(s="#"+s),l.color=s),k(e,a),a.append(L(e)),a},TT:(e,t,n)=>{const o=S("SPAN",{class:n.classNames.fontFamily,style:'font-family:menlo,consolas,"courier new",monospace'});return k(e,o),o.append(L(e)),o}},V=/^(?:A(?:DDRESS|RTICLE|SIDE|UDIO)|BLOCKQUOTE|CAPTION|D(?:[DLT]|IV)|F(?:IGURE|IGCAPTION|OOTER)|H[1-6]|HEADER|L(?:ABEL|EGEND|I)|O(?:L|UTPUT)|P(?:RE)?|SECTION|T(?:ABLE|BODY|D|FOOT|H|HEAD|R)|COL(?:GROUP)?|UL)$/,q=new Set(["HEAD","META","STYLE"]),W=(e,n,o)=>{const i=e.childNodes;let r=e;for(;m(r);)r=r.parentNode;t(r,5);let s=i.length;for(;s--;){let t=i[s];const r=t.nodeName;if(t instanceof HTMLElement){const i=t.childNodes.length;if($[r])t=$[r](t,e,n);else{if(q.has(r)){t.remove();continue}if(!V.test(r)&&!m(t)){s+=i,k(t,L(t));continue}}i&&W(t,n,o||"PRE"===r)}}return e},z=e=>{const t=e.childNodes;let n=t.length;for(;n--;){const o=t[n];o instanceof Element&&!p(o)?(z(o),m(o)&&!o.firstChild&&e.removeChild(o)):o instanceof Text&&!o.length&&e.removeChild(o)}},K=e=>{const t=e.querySelectorAll("BR:last-child");let n=t.length;for(;n--;){const e=t[n];R(e)||e.remove()}},G=e=>(!(e instanceof Element||e instanceof DocumentFragment)||m(e)||e.children.length||e.textContent.length||e.appendChild(S("BR")),e),Q=e=>{let t=null;return[...e.childNodes].forEach((n=>{m(n)?(t||(t=S("DIV")),t.append(n)):t&&((t.children.length||t.textContent.trim().length)&&e.insertBefore(t,n),t=null)})),t&&e.append(t),e},X=(e,t,n,o)=>{if(e instanceof Text&&e!==n){if("number"!=typeof t)throw new Error("Offset must be a number to split text node!");if(!e.parentNode)throw new Error("Cannot split text node with no parent!");return X(e.parentNode,e.splitText(t),n,o)}let i="number"==typeof t?t<e.childNodes.length?e.childNodes[t]:null:t;const r=e.parentNode;if(!(r&&e!==n&&e instanceof Element))return i;const s=e.cloneNode(!1);for(;i;){const e=i.nextSibling;s.append(i),i=e}return e instanceof HTMLOListElement&&O(e,o,"BLOCKQUOTE")&&(s.start=(+e.start||1)+e.childNodes.length-1),G(e),G(s),e.after(s),X(r,s,n,o)},Y=(e,t)=>{const n=e.childNodes;let o=n.length;const i=[];for(;o--;){const r=n[o],s=o?n[o-1]:null;if(s&&m(r)&&E(r,s))t.startContainer===r&&(t.startContainer=s,t.startOffset+=x(s)),t.endContainer===r&&(t.endContainer=s,t.endOffset+=x(s)),t.startContainer===e&&(t.startOffset>o?--t.startOffset:t.startOffset===o&&(t.startContainer=s,t.startOffset=x(s))),t.endContainer===e&&(t.endOffset>o?--t.endOffset:t.endOffset===o&&(t.endContainer=s,t.endOffset=x(s))),A(r),r instanceof Text?s.appendData(r.data):i.push(L(r));else if(r instanceof Element){let e;for(;e=i.pop();)r.append(e);Y(r,t)}}},J=(e,t)=>{const n=e instanceof Text?e.parentNode:e;if(n instanceof Element){const e={startContainer:t.startContainer,startOffset:t.startOffset,endContainer:t.endContainer,endOffset:t.endOffset};Y(n,e),t.setStart(e.startContainer,e.startOffset),t.setEnd(e.endContainer,e.endOffset)}},Z=(e,t,n,o)=>{let i,r,s=t;for(;(i=s.parentNode)&&i!==o&&i instanceof Element&&1===i.childNodes.length;)s=i;A(s),r=e.childNodes.length;const a=e.lastChild;a&&"BR"===a.nodeName&&(a.remove(),--r),e.append(L(t)),n.setStart(e,r),n.collapse(!0),J(e,n)},ee=(e,t)=>{const n=e.previousSibling,o=e.firstChild,i="LI"===e.nodeName;if(!i||o&&/^[OU]L$/.test(o.nodeName))if(n&&E(n,e)){if(!y(n)){if(!i)return;const e=S("DIV");e.append(L(n)),n.append(e)}A(e);const r=!y(e);n.append(L(e)),r&&Q(n),o&&ee(o,t)}else if(i){const t=S("DIV");e.insertBefore(t,o),G(t)}},te=(e,n)=>{const o=t(n,1,v);return o.currentNode=e,o},ne=(e,t)=>{const n=te(e,t).previousNode();return n!==t?n:null},oe=(e,t)=>{const n=te(e,t).nextNode();return n!==t?n:null},ie=e=>!e.textContent&&!e.querySelector("IMG"),re=(e,t)=>{const n=e.startContainer;let o;if(m(n))o=ne(n,t);else if(n!==t&&n instanceof HTMLElement&&v(n))o=n;else{const i=_(n,e.startOffset);o=oe(i,t)}return o&&I(e,o,!0)?o:null},se=(e,t)=>{const n=e.endContainer;let o;if(m(n))o=ne(n,t);else if(n!==t&&n instanceof HTMLElement&&v(n))o=n;else{let i=T(n,e.endOffset);if(!i||!t.contains(i)){let e;for(i=t;e=i.lastChild;)i=e}o=ne(i,t)}return o&&I(e,o,!0)?o:null},ae=e=>e instanceof Text?c.test(e.data):"IMG"===e.nodeName,le=(e,o)=>{const i=e.startContainer,r=e.startOffset;let s;if(i instanceof Text){const e=i.data;for(let t=r;t>0;--t)if(e.charAt(t-1)!==n)return!1;s=i}else if(s=T(i,r),s&&!o.contains(s)&&(s=null),!s&&(s=_(i,r),s instanceof Text&&s.length))return!1;const a=re(e,o);if(!a)return!1;const l=t(a,5,ae);return l.currentNode=s,!l.previousNode()},ce=(e,o)=>{const i=e.endContainer,r=e.endOffset;let s;if(i instanceof Text){const e=i.data,t=e.length;for(let o=r;o<t;++o)if(e.charAt(o)!==n)return!1;s=i}else s=_(i,r);const a=se(e,o);if(!a)return!1;const l=t(a,5,ae);return l.currentNode=s,!l.nextNode()};function de(e,t,n,o){const i=document.createRange();return i.setStart(e,t),n&&"number"==typeof o?i.setEnd(n,o):i.setEnd(e,t),i}var he=(e,t)=>{let n,{startContainer:o,startOffset:i,endContainer:r,endOffset:s}=e;if(o instanceof Text){const t=o.parentNode;if(n=t.childNodes,i===o.length)i=Array.from(n).indexOf(o)+1,e.collapsed&&(r=t,s=i);else{if(i){const e=o.splitText(i);r===o?(s-=i,r=e):r===t&&++s,o=e}i=Array.from(n).indexOf(o)}o=t}else n=o.childNodes;const a=n.length;i===a?o.append(t):o.insertBefore(t,n[i]),o===r&&(s+=n.length-a),e.setStart(o,i),e.setEnd(r,s)},ue=(e,t,n)=>{const o=document.createDocumentFragment();if(e.collapsed)return o;t||(t=e.commonAncestorContainer),t instanceof Text&&(t=t.parentNode);const i=e.startContainer,r=e.startOffset;let s=X(e.endContainer,e.endOffset,t,n),a=0,l=X(i,r,t,n);for(;l&&l!==s;){const e=l.nextSibling;o.append(l),l=e}return l=s&&s.previousSibling,l&&l instanceof Text&&s instanceof Text&&(a=l.length,l.appendData(s.data),A(s),s=l),e.setStart(i,r),s?e.setEnd(s,a):e.setEnd(t,t.childNodes.length),G(t),o},fe=(e,t,n)=>{let o;for(e.currentNode=n;o=e[t]();){if(o instanceof Text||p(o))return o;if(!m(o))return null}return null},pe=(e,n)=>{const o=re(e,n);let i=se(e,n);const r=o!==i;o&&i&&(U(e),P(e,o,i,n));const s=ue(e,null,n);U(e),r&&(i=se(e,n),o&&i&&o!==i&&Z(o,i,e,n)),o&&G(o);const a=n.firstChild;a&&"BR"!==a.nodeName||(G(n),n.firstChild&&e.selectNodeContents(n.firstChild)),e.collapse(!0);const l=e.startContainer,c=e.startOffset,h=t(n,5);let u=l,f=c;u instanceof Text&&f!==u.length||(u=fe(h,"nextNode",u),f=0);let p=l,g=c-1;p instanceof Text&&-1!==g||(p=fe(h,"previousPONode",u||(l instanceof Text?l:l.childNodes[c]||l)),p instanceof Text&&(g=p.length));let m=null,v=0;return u instanceof Text&&" "===u.data.charAt(f)&&le(e,n)?(m=u,v=f):p instanceof Text&&" "===p.data.charAt(g)&&(u instanceof Text&&" "===u.data.charAt(f)||ce(e,n))&&(m=p,v=g),m&&m.replaceData(v,1," "),e.setStart(l,c),e.collapse(!0),s},ge=n=>{if(n.collapsed)return"";const o=n.startContainer,i=n.endContainer,r=t(n.commonAncestorContainer,5,(e=>I(n,e,!0)));r.currentNode=o;let s,a=o,l="",c=!1;for((a instanceof Element||a instanceof Text)&&e===r.filter.acceptNode(a)||(a=r.nextNode());a;)a instanceof Text?(s=a.data,s&&/\S/.test(s)&&(a===i&&(s=s.slice(0,n.endOffset)),a===o&&(s=s.slice(n.startOffset)),l+=s,c=!0)):("BR"===a.nodeName||c&&!m(a))&&(l+="\n",c=!1),a=r.nextNode();return l=l.replace(/ /g," "),l},me=(Array.prototype.indexOf,(e,t,n,o,i,s,a)=>{const l=e.clipboardData;if(!l)return!1;let c=s?"":ge(t);const h=re(t,n);let u,f=n;h===se(t,n)&&h?.contains(t.commonAncestorContainer)&&(f=h),o?u=pe(t,n):(t=t.cloneRange(),U(t),P(t,f,f,n),u=t.cloneContents());let p,g=t.commonAncestorContainer;for(g instanceof Text&&(g=g.parentNode);g&&g!==f;){const e=g.cloneNode(!1);e.append(u),u=e,g=g.parentNode}if(1===u.childNodes.length&&u.childNodes[0]instanceof Text)c=u.childNodes[0].data.replace(/ /g," "),a=!0;else{const e=S("DIV");e.append(u),p=e.innerHTML,i&&(p=i(p))}return s&&void 0!==p&&(c=s(p)),r&&(c=c.replace(/\r?\n/g,"\r\n")),!a&&p&&c!==p&&(p="\x3c!-- squire --\x3e"+p,l.setData("text/html",p)),l.setData("text/plain",c),e.preventDefault(),!0}),ve=function(e){const t=this.getSelection(),n=this._root;if(t.collapsed)return void e.preventDefault();this.saveUndoState(t);me(e,t,n,!0,this._config.willCutCopy,this._config.toPlainText,!1)||setTimeout((()=>{try{this._ensureBottomLine()}catch(e){this._config.didError(e)}}),0),this.setSelection(t)},be=function(e){me(e,this.getSelection(),this._root,!1,this._config.willCutCopy,this._config.toPlainText,!1)},ye=function(e){this._isShiftDown=e.shiftKey},Se=function(e){const t=e.clipboardData,n=t.items,o=this._isShiftDown;let i=!1,r=!1,s=null,a=null,l=n.length;for(;l--;){const e=n[l],t=e.type;"text/html"===t?a=e:"text/plain"===t||"text/uri-list"===t?s=e:"text/rtf"===t?i=!0:/^image\/.*/.test(t)&&(r=!0)}if(r&&(!i||!a))return e.preventDefault(),void this.fireEvent("pasteImage",{clipboardData:t});e.preventDefault(),!a||o&&s?s&&s.getAsString((e=>{let t=!1;const n=this.getSelection();if(!n.collapsed&&c.test(n.toString())){const n=this.linkRegExp.exec(e);t=!!n&&n[0].length===e.length}t?this.makeLink(e):this.insertPlainText(e,!0)})):a.getAsString((e=>{this.insertHTML(e,!0)}))},Ee=function(e){if(!e.dataTransfer)return;const t=e.dataTransfer.types;let n=t.length,o=!1,i=!1;for(;n--;)switch(t[n]){case"text/plain":o=!0;break;case"text/html":i=!0;break;default:return}(i||o&&this.saveUndoState)&&this.saveUndoState()},Ce=(e,t)=>{try{t||(t=e.getSelection());let o=t.startContainer;o instanceof Text&&(o=o.parentNode);let i=o;for(;m(i)&&(!i.textContent||i.textContent===n);)o=i,i=o.parentNode;o!==i&&(t.setStart(i,Array.from(i.childNodes).indexOf(o)),t.collapse(!0),i.removeChild(o),v(i)||(i=ne(i,e._root)||e._root),G(i),U(t)),o===e._root&&(o=o.firstChild)&&"BR"===o.nodeName&&A(o),e._ensureBottomLine(),e.setSelection(t),e._updatePath(t,!0)}catch(t){e._config.didError(t)}},Ne=(e,t)=>{let n;for(;(n=e.parentNode)&&n!==t&&!n.isContentEditable;)e=n;A(e)},_e=(e,t,n)=>{if(O(t,e._root,"A"))return;const o=t.data||"",i=Math.max(o.lastIndexOf(" ",n-1),o.lastIndexOf(" ",n-1))+1,r=o.slice(i,n),s=e.linkRegExp.exec(r);if(s){const n=e.getSelection();e._docWasChanged(),e._recordUndoState(n),e._getRangeAndRemoveBookmark(n);const r=i+s.index,a=r+s[0].length,l=n.startContainer===t,c=n.startOffset-a;r&&(t=t.splitText(r));const h=e._config.tagAttributes.a,u=S("A",Object.assign({href:s[1]?/^(?:ht|f)tps?:/i.test(s[1])?s[1]:"http://"+s[1]:"mailto:"+s[0]},h));u.textContent=o.slice(r,a),t.parentNode.insertBefore(u,t),t.data=o.slice(a),l&&(n.setStart(t,c),n.setEnd(t,c)),e.setSelection(n)}},Te=function(e){if(e.defaultPrevented||e.isComposing)return;let t=e.key,n="";const o=e.code;/^Digit\d$/.test(o)&&(t=o.slice(-1)),"Backspace"!==t&&"Delete"!==t&&(e.altKey&&(n+="Alt-"),e.ctrlKey&&(n+="Ctrl-"),e.metaKey&&(n+="Meta-"),e.shiftKey&&(n+="Shift-")),r&&e.shiftKey&&"Delete"===t&&(n+="Shift-"),t=n+t;const i=this.getSelection();this._keyHandlers[t]?this._keyHandlers[t](this,e,i):i.collapsed||e.ctrlKey||e.metaKey||1!==t.length||(this.saveUndoState(i),pe(i,this._root),this._ensureBottomLine(),this.setSelection(i),this._updatePath(i,!0))},xe={Backspace:(e,t,n)=>{const o=e._root;if(e._removeZWS(),e.saveUndoState(n),n.collapsed)if(le(n,o)){t.preventDefault();const i=re(n,o);if(!i)return;let r=i;Q(r.parentNode);const s=ne(r,o);if(s){if(!s.isContentEditable)return void Ne(s,o);for(Z(s,r,n,o),r=s.parentNode;r!==o&&!r.nextSibling;)r=r.parentNode;r!==o&&(r=r.nextSibling)&&ee(r,o),e.setSelection(n)}else if(r){if(O(r,o,"UL")||O(r,o,"OL"))return void e.decreaseListLevel(n);if(O(r,o,"BLOCKQUOTE"))return void e.removeQuote(n);e.setSelection(n),e._updatePath(n,!0)}}else{U(n);const o=n.startContainer,i=n.startOffset,r=o.parentNode;o instanceof Text&&r instanceof HTMLAnchorElement&&i&&r.href.includes(o.data)?(o.deleteData(i-1,1),e.setSelection(n),e.removeLink(),t.preventDefault()):(e.setSelection(n),setTimeout((()=>{Ce(e)}),0))}else t.preventDefault(),pe(n,o),Ce(e,n)},Delete:(e,t,n)=>{const o=e._root;let i,r,s,a,l,c;if(e._removeZWS(),e.saveUndoState(n),n.collapsed)if(ce(n,o)){if(t.preventDefault(),i=re(n,o),!i)return;if(Q(i.parentNode),r=oe(i,o),r){if(!r.isContentEditable)return void Ne(r,o);for(Z(i,r,n,o),r=i.parentNode;r!==o&&!r.nextSibling;)r=r.parentNode;r!==o&&(r=r.nextSibling)&&ee(r,o),e.setSelection(n),e._updatePath(n,!0)}}else{if(s=n.cloneRange(),P(n,o,o,o),a=n.endContainer,l=n.endOffset,a instanceof Element&&(c=a.childNodes[l],c&&"IMG"===c.nodeName))return t.preventDefault(),A(c),U(n),void Ce(e,n);e.setSelection(s),setTimeout((()=>{Ce(e)}),0)}else t.preventDefault(),pe(n,o),Ce(e,n)},Tab:(e,t,n)=>{const o=e._root;e._removeZWS(),n.collapsed&&le(n,o)&&O(n.startContainer,o,"UL,OL,BLOCKQUOTE")&&e.changeIndentationLevel("increase")&&t.preventDefault()},"Shift-Tab":(e,t,n)=>{const o=e._root;e._removeZWS(),n.collapsed&&le(n,o)&&decreaseLevel(e,n,n.startContainer)&&t.preventDefault()}," ":(e,o,i)=>{let r;const s=e._root;if(e._recordUndoState(i),e._getRangeAndRemoveBookmark(i),i.collapsed){if(ce(i,s)){const r=re(i,s);if(r&&"PRE"!==r.nodeName){const s=r.textContent?.trimEnd().replace(n,"");if("*"===s||"1."===s){o.preventDefault(),e.insertPlainText(" ",!1),e._docWasChanged(),e.saveUndoState(i);const n=t(r,4);let a;for(;a=n.nextNode();)A(a);return void("*"===s?e.makeUnorderedList():e.makeOrderedList())}}}}else pe(i,s),e._ensureBottomLine(),e.setSelection(i),e._updatePath(i,!0);if(r=i.endContainer,i.endOffset===x(r))do{if("A"===r.nodeName){i.setStartAfter(r);break}}while(!r.nextSibling&&(r=r.parentNode)&&r!==s);if(e._config.addLinks){const t=i.cloneRange();U(t);const n=t.startContainer,o=t.startOffset;setTimeout((()=>{_e(e,n,o)}),0)}e.setSelection(i)},ArrowLeft(e){e._removeZWS()},ArrowRight(e,t,n){e._removeZWS();const o=e.getRoot();if(ce(n,o)){U(n);let i=n.endContainer;do{if("CODE"===i.nodeName){let o=i.nextSibling;if(!(o instanceof Text)){const e=document.createTextNode(" ");i.parentNode.insertBefore(e,o),o=e}n.setStart(o,1),e.setSelection(n),t.preventDefault();break}}while(!i.nextSibling&&(i=i.parentNode)&&i!==o)}}};i||s||(xe.PageUp=e=>{e.moveCursorToStart()},xe.PageDown=e=>{e.moveCursorToEnd()});var Le=(e,t)=>(t=t||null,(n,o)=>{o.preventDefault();const i=n.getSelection();n.hasFormat(e,null,i)?n.changeFormat(null,{tag:e},i):n.changeFormat({tag:e},t,i)});xe[a+"b"]=Le("B"),xe[a+"i"]=Le("I"),xe[a+"u"]=Le("U"),xe[a+"Shift-7"]=Le("S"),xe[a+"Shift-5"]=Le("SUB",{tag:"SUP"}),xe[a+"Shift-6"]=Le("SUP",{tag:"SUB"}),xe[a+"Shift-8"]=(e,t)=>{t.preventDefault();const n=e.getPath();/(?:^|>)UL/.test(n)?e.removeList():e.makeUnorderedList()},xe[a+"Shift-9"]=(e,t)=>{t.preventDefault();const n=e.getPath();/(?:^|>)OL/.test(n)?e.removeList():e.makeOrderedList()},xe[a+"["]=(e,t)=>{t.preventDefault();const n=e.getPath();/(?:^|>)BLOCKQUOTE/.test(n)||!/(?:^|>)[OU]L/.test(n)?e.decreaseQuoteLevel():e.decreaseListLevel()},xe[a+"]"]=(e,t)=>{t.preventDefault();const n=e.getPath();/(?:^|>)BLOCKQUOTE/.test(n)||!/(?:^|>)[OU]L/.test(n)?e.increaseQuoteLevel():e.increaseListLevel()},xe[a+"d"]=(e,t)=>{t.preventDefault(),e.toggleCode()},xe[a+"z"]=(e,t)=>{t.preventDefault(),e.undo()},xe[a+"y"]=xe[a+"Shift-z"]=xe[a+"Shift-Z"]=(e,t)=>{t.preventDefault(),e.redo()};window.Squire=class{constructor(e,t){this.customEvents=new Set(["pathChange","select","input","pasteImage","undoStateChange"]),this.startSelectionId="squire-selection-start",this.endSelectionId="squire-selection-end",this.linkRegExp=/\b(?:((?:(?:ht|f)tps?:\/\/|www\d{0,3}[.]|[a-z0-9][a-z0-9.\-]*[.][a-z]{2,}\/)(?:[^\s()<>]+|\([^\s()<>]+\))+(?:[^\s?&`!()\[\]{};:'".,<>«»“”‘’]|\([^\s()<>]+\)))|([\w\-.%+]+@(?:[\w\-]+\.)+[a-z]{2,}\b(?:[?][^&?\s]+=[^\s?&`!()\[\]{};:'".,<>«»“”‘’]+(?:&[^&?\s]+=[^\s?&`!()\[\]{};:'".,<>«»“”‘’]+)*)?))/i,this.tagAfterSplit={DT:"DD",DD:"DT",LI:"LI",PRE:"PRE"},this._root=e,this._config=this._makeConfig(t),this._isFocused=!1,this._lastSelection=de(e,0),this._willRestoreSelection=!1,this._mayHaveZWS=!1,this._lastAnchorNode=null,this._lastFocusNode=null,this._path="",this._events=new Map,this._undoIndex=-1,this._undoStack=[],this._undoStackLength=0,this._isInUndoState=!1,this._ignoreChange=!1,this._ignoreAllChanges=!1,this.addEventListener("selectionchange",this._updatePathOnEvent),this.addEventListener("blur",this._enableRestoreSelection),this.addEventListener("mousedown",this._disableRestoreSelection),this.addEventListener("touchstart",this._disableRestoreSelection),this.addEventListener("focus",this._restoreSelection),this.addEventListener("blur",this._removeZWS),this._isShiftDown=!1,this.addEventListener("cut",ve),this.addEventListener("copy",be),this.addEventListener("paste",Se),this.addEventListener("drop",Ee),this.addEventListener("keydown",ye),this.addEventListener("keyup",ye),this.addEventListener("keydown",Te),this._keyHandlers=Object.create(xe);const n=new MutationObserver((()=>this._docWasChanged()));n.observe(e,{childList:!0,attributes:!0,characterData:!0,subtree:!0}),this._mutation=n,e.setAttribute("contenteditable","true"),this.addEventListener("beforeinput",this._beforeInput),this.setHTML("")}destroy(){this._events.forEach(((e,t)=>{this.removeEventListener(t)})),this._mutation.disconnect(),this._undoIndex=-1,this._undoStack=[],this._undoStackLength=0}_makeConfig(e){const t={blockTag:"DIV",classNames:{color:"color",fontFamily:"font",fontSize:"size",highlight:"highlight"},undo:{documentSizeThreshold:-1,undoLimit:-1},addLinks:!0,willCutCopy:null,toPlainText:null,sanitizeToDOMFragment:e=>{const t=DOMPurify.sanitize(e,{ALLOW_UNKNOWN_PROTOCOLS:!0,WHOLE_DOCUMENT:!1,RETURN_DOM:!0,RETURN_DOM_FRAGMENT:!0,FORCE_BODY:!1});return t?document.importNode(t,!0):document.createDocumentFragment()},didError:e=>{}};return e&&(Object.assign(t,e),t.blockTag=t.blockTag.toUpperCase()),t}setKeyHandler(e,t){return this._keyHandlers[e]=t,this}_beforeInput(e){switch(e.inputType){case"insertLineBreak":e.preventDefault(),this.splitBlock(!0);break;case"insertParagraph":e.preventDefault(),this.splitBlock(!1);break;case"insertOrderedList":e.preventDefault(),this.makeOrderedList();break;case"insertUnoderedList":e.preventDefault(),this.makeUnorderedList();break;case"historyUndo":e.preventDefault(),this.undo();break;case"historyRedo":e.preventDefault(),this.redo();break;case"formatBold":e.preventDefault(),this.bold();break;case"formaItalic":e.preventDefault(),this.italic();break;case"formatUnderline":e.preventDefault(),this.underline();break;case"formatStrikeThrough":e.preventDefault(),this.strikethrough();break;case"formatSuperscript":e.preventDefault(),this.superscript();break;case"formatSubscript":e.preventDefault(),this.subscript();break;case"formatJustifyFull":case"formatJustifyCenter":case"formatJustifyRight":case"formatJustifyLeft":{e.preventDefault();let t=e.inputType.slice(13).toLowerCase();"full"===t&&(t="justify"),this.setTextAlignment(t);break}case"formatRemove":e.preventDefault(),this.setStyle();break;case"formatSetBlockTextDirection":{e.preventDefault();let t=e.data;"null"===t&&(t=null),this.setTextDirection(t);break}case"formatBackColor":e.preventDefault(),this.setStyle({backgroundColor:e.data});break;case"formatFontColor":e.preventDefault(),this.setStyle({color:e.data});break;case"formatFontName":e.preventDefault(),this.setStyle({fontFamily:e.data})}}handleEvent(e){this.fireEvent(e.type,e)}fireEvent(e,t){let n=this._events.get(e);if(/^(?:focus|blur)/.test(e)){const t=this._root===document.activeElement;if("focus"===e){if(!t||this._isFocused)return this;this._isFocused=!0}else{if(t||!this._isFocused)return this;this._isFocused=!1}}if(n){const o=t instanceof Event?t:new CustomEvent(e,{detail:t});n=n.slice();for(const e of n)try{"handleEvent"in e?e.handleEvent(o):e.call(this,o)}catch(e){this._config.didError(e)}}return this}addEventListener(e,t){let n=this._events.get(e),o=this._root;return n||(n=[],this._events.set(e,n),this.customEvents.has(e)||("selectionchange"===e&&(o=document),o.addEventListener(e,this,!0))),n.push(t),this}removeEventListener(e,t){const n=this._events.get(e);let o=this._root;if(n){if(t){let e=n.length;for(;e--;)n[e]===t&&n.splice(e,1)}else n.length=0;n.length||(this._events.delete(e),this.customEvents.has(e)||("selectionchange"===e&&(o=document),o.removeEventListener(e,this,!0)))}return this}focus(){return this._root.focus({preventScroll:!0}),this}blur(){return this._root.blur(),this}_enableRestoreSelection(){this._willRestoreSelection=!0}_disableRestoreSelection(){this._willRestoreSelection=!1}_restoreSelection(){this._willRestoreSelection&&this.setSelection(this._lastSelection)}_removeZWS(){this._mayHaveZWS&&(B(this._root),this._mayHaveZWS=!1)}_saveRangeToBookmark(e){let t,n=S("INPUT",{id:this.startSelectionId,type:"hidden"}),o=S("INPUT",{id:this.endSelectionId,type:"hidden"});he(e,n),e.collapse(!1),he(e,o),n.compareDocumentPosition(o)&Node.DOCUMENT_POSITION_PRECEDING&&(n.id=this.endSelectionId,o.id=this.startSelectionId,t=n,n=o,o=t),e.setStartAfter(n),e.setEndBefore(o)}_getRangeAndRemoveBookmark(e){const t=this._root,n=t.querySelector("#"+this.startSelectionId),o=t.querySelector("#"+this.endSelectionId);if(n&&o){let t=n.parentNode,i=o.parentNode;const r=Array.from(t.childNodes).indexOf(n);let s=Array.from(i.childNodes).indexOf(o);t===i&&--s,n.remove(),o.remove(),e||(e=document.createRange()),e.setStart(t,r),e.setEnd(i,s),J(t,e),t!==i&&J(i,e),e.collapsed&&(t=e.startContainer,t instanceof Text&&(i=t.childNodes[e.startOffset],i&&i instanceof Text||(i=t.childNodes[e.startOffset-1]),i&&i instanceof Text&&(e.setStart(i,0),e.collapse(!0))))}return e||null}getSelection(){const e=window.getSelection(),t=this._root;let n=null;if(this._isFocused&&e&&e.rangeCount){n=e.getRangeAt(0).cloneRange();const t=n.startContainer,o=n.endContainer;t&&p(t)&&n.setStartBefore(t),o&&p(o)&&n.setEndBefore(o)}return n&&t.contains(n.commonAncestorContainer)?this._lastSelection=n:(n=this._lastSelection,document.contains(n.commonAncestorContainer)||(n=null)),n||de(t.firstElementChild||t,0)}setSelection(e){if(this._lastSelection=e,this._isFocused){const t=window.getSelection();t&&("setBaseAndExtent"in Selection.prototype?t.setBaseAndExtent(e.startContainer,e.startOffset,e.endContainer,e.endOffset):(t.removeAllRanges(),t.addRange(e)))}else this._enableRestoreSelection();return this}_moveCursorTo(e){const t=this._root,n=de(t,e?0:t.childNodes.length);return U(n),this.setSelection(n),this}moveCursorToStart(){return this._moveCursorTo(!0)}moveCursorToEnd(){return this._moveCursorTo(!1)}getCursorPosition(){const e=this.getSelection();let t=e.getBoundingClientRect();if(t&&!t.top){this._ignoreChange=!0;const o=S("SPAN");o.textContent=n,he(e,o),t=o.getBoundingClientRect();const i=o.parentNode;i.removeChild(o),J(i,e)}return t}getPath(){return this._path}_updatePathOnEvent(){this._isFocused&&this._updatePath(this.getSelection())}_updatePath(e,t){const n=e.startContainer,o=e.endContainer;let i;(t||n!==this._lastAnchorNode||o!==this._lastFocusNode)&&(this._lastAnchorNode=n,this._lastFocusNode=o,i=n&&o?n===o?this._getPath(o):"(selection)":"",this._path===i&&n===o||(this._path=i,this.fireEvent("pathChange",{path:i}))),this.fireEvent(e.collapsed?"cursor":"select",{range:e})}_getPath(e){const t=this._root,n=this._config;let o="";if(e&&e!==t){const t=e.parentNode;if(o=t?this._getPath(t):"",e instanceof HTMLElement){const t=e.id,i=e.classList,r=Array.from(i).sort(),s=e.dir,a=n.classNames;o+=(o?">":"")+e.nodeName,t&&(o+="#"+t),r.length&&(o+=".",o+=r.join(".")),s&&(o+="[dir="+s+"]"),i.contains(a.highlight)&&(o+="[backgroundColor="+e.style.backgroundColor.replace(/ /g,"")+"]"),i.contains(a.color)&&(o+="[color="+e.style.color.replace(/ /g,"")+"]"),i.contains(a.fontFamily)&&(o+="[fontFamily="+e.style.fontFamily.replace(/ /g,"")+"]"),i.contains(a.fontSize)&&(o+="[fontSize="+e.style.fontSize+"]")}}return o}modifyDocument(e){const t=this._mutation;return t&&(t.takeRecords().length&&this._docWasChanged(),t.disconnect()),this._ignoreAllChanges=!0,e(),this._ignoreAllChanges=!1,t&&(t.observe(this._root,{childList:!0,attributes:!0,characterData:!0,subtree:!0}),this._ignoreChange=!1),this}_docWasChanged(){f=new WeakMap,this._mayHaveZWS=!0,this._ignoreAllChanges||(this._ignoreChange?this._ignoreChange=!1:(this._isInUndoState&&(this._isInUndoState=!1,this.fireEvent("undoStateChange",{canUndo:!0,canRedo:!1})),this.fireEvent("input")))}_recordUndoState(e,t){const n=this._isInUndoState;if(!n||t){let o=this._undoIndex+1;const i=this._undoStack,r=this._config.undo,s=r.documentSizeThreshold,a=r.undoLimit;if(o<this._undoStackLength&&(i.length=this._undoStackLength=o),e&&this._saveRangeToBookmark(e),n)return this;const l=this._getRawHTML();t&&--o,s>-1&&2*l.length>s&&a>-1&&o>a&&(i.splice(0,o-a),o=a,this._undoStackLength=a),i[o]=l,this._undoIndex=o,++this._undoStackLength,this._isInUndoState=!0}return this}saveUndoState(e){return e||(e=this.getSelection()),this._recordUndoState(e,this._isInUndoState),this._getRangeAndRemoveBookmark(e),this}undo(){if(0!==this._undoIndex||!this._isInUndoState){this._recordUndoState(this.getSelection(),!1),--this._undoIndex,this._setRawHTML(this._undoStack[this._undoIndex]);const e=this._getRangeAndRemoveBookmark();e&&this.setSelection(e),this._isInUndoState=!0,this.fireEvent("undoStateChange",{canUndo:0!==this._undoIndex,canRedo:!0}),this.fireEvent("input")}return this.focus()}redo(){const e=this._undoIndex,t=this._undoStackLength;if(e+1<t&&this._isInUndoState){++this._undoIndex,this._setRawHTML(this._undoStack[this._undoIndex]);const n=this._getRangeAndRemoveBookmark();n&&this.setSelection(n),this.fireEvent("undoStateChange",{canUndo:!0,canRedo:e+2<t}),this.fireEvent("input")}return this.focus()}getRoot(){return this._root}_getRawHTML(){return this._root.innerHTML}_setRawHTML(e){if(void 0!==e){const t=this._root;let n=t;t.innerHTML=e;do{G(n)}while(n=oe(n,t));this._ignoreChange=!0}return this}getHTML(e){let t;e&&(t=this.getSelection(),this._saveRangeToBookmark(t));const n=this._getRawHTML().replace(/\u200B/g,"");return e&&this._getRangeAndRemoveBookmark(t),n}setHTML(e){const t=this._config.sanitizeToDOMFragment(e,this),n=this._root;W(t,this._config),K(t),Q(t);let o=t,i=o.firstChild;if(i&&"BR"!==i.nodeName)for(;o=oe(o,n);)G(o);else{const e=this.createDefaultBlock();i?o.replaceChild(e,i):o.append(e)}for(this._ignoreChange=!0;i=n.lastChild;)n.removeChild(i);n.append(t),this._undoIndex=-1,this._undoStack.length=0,this._undoStackLength=0,this._isInUndoState=!1;const r=this._getRangeAndRemoveBookmark()||de(n.firstElementChild||n,0);return this.saveUndoState(r),this.setSelection(r),this._updatePath(r,!0),this}insertHTML(e,t){const n=this._config;let o=n.sanitizeToDOMFragment(e,this);const i=this.getSelection();this.saveUndoState(i);try{const r=this._root;n.addLinks&&this.addDetectedLinks(o,o),W(o,this._config),K(o),z(o),o.normalize();let s=o;for(;s=oe(s,o);)G(s);let a=!0;if(t){const t=new CustomEvent("willPaste",{cancelable:!0,detail:{html:e,fragment:o}});this.fireEvent("willPaste",t),o=t.detail.fragment,a=!t.defaultPrevented}a&&(((e,t,n)=>{const o=t.firstChild&&m(t.firstChild);let i;for(Q(t),i=t;i=oe(i,n);)G(i);e.collapsed||pe(e,n),U(e),e.collapse(!1);const r=O(e.endContainer,n,"BLOCKQUOTE")||n;let s=re(e,n),a=null;const l=oe(t,t),c=!o&&!!s&&ie(s);if(s&&l&&!c&&!O(l,t,"PRE")&&!O(l,t,"TABLE")){P(e,s,s,n),e.collapse(!0);let t=e.endContainer,o=e.endOffset;if(K(s),m(t)){const e=X(t,o,ne(t,n)||n,n);t=e.parentNode,o=Array.from(t.childNodes).indexOf(e)}if(o!==x(t))for(a=document.createDocumentFragment();i=t.childNodes[o];)a.append(i);Z(t,l,e,n),o=Array.from(t.parentNode.childNodes).indexOf(t)+1,t=t.parentNode,e.setEnd(t,o)}if(x(t)){c&&s&&(e.setEndBefore(s),e.collapse(!1),A(s)),P(e,r,r,n);let o=X(e.endContainer,e.endOffset,r,n);const i=o?o.previousSibling:r.lastChild;r.insertBefore(t,o),o?e.setEndBefore(o):e.setEnd(r,x(r)),s=se(e,n),U(e);const a=e.endContainer,l=e.endOffset;o&&y(o)&&ee(o,n),o=i&&i.nextSibling,o&&y(o)&&ee(o,n),e.setEnd(a,l)}if(a&&s){const t=e.cloneRange();G(a),Z(s,a,t,n),e.setEnd(t.endContainer,t.endOffset)}U(e)})(i,o,r),i.collapse(!1),M(i,"A",r),this._ensureBottomLine()),this.setSelection(i),this._updatePath(i,!0),t&&this.focus()}catch(e){this._config.didError(e)}return this}insertElement(e,t){if(t||(t=this.getSelection()),t.collapse(!0),m(e))he(t,e),t.setStartAfter(e);else{const n=this._root,o=re(t,n);let i=o||n,r=null;for(;i!==n&&!i.nextSibling;)i=i.parentNode;if(i!==n){const e=i.parentNode;r=X(e,i.nextSibling,n,n)}o&&ie(o)&&A(o),n.insertBefore(e,r);const s=this.createDefaultBlock();n.insertBefore(s,r),t.setStart(s,0),t.setEnd(s,0),U(t)}return this.focus(),this.setSelection(t),this._updatePath(t),this}insertImage(e,t){const n=S("IMG",Object.assign({src:e},t));return this.insertElement(n),n}insertPlainText(e,t){const n=this.getSelection();if(n.collapsed&&O(n.startContainer,this._root,"PRE")){const o=n.startContainer;let i,r=n.startOffset;if(o&&o instanceof Text)i=o;else{const e=document.createTextNode("");o.insertBefore(e,o.childNodes[r]),i=e,r=0}let s=!0;if(t){const t=new CustomEvent("willPaste",{cancelable:!0,detail:{text:e}});this.fireEvent("willPaste",t),e=t.detail.text,s=!t.defaultPrevented}return s&&(i.insertData(r,e),n.setStart(i,r+e.length),n.collapse(!0)),this.setSelection(n),this}const o=e.split("\n"),i=this._config.blockTag,r="</"+i+">",s="<"+i+">";for(let e=0,t=o.length;e<t;++e){let t=o[e];t=(a=t,a.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""")).replace(/ (?=(?: |$))/g," "),e&&(t=s+(t||"<BR>")+r),o[e]=t}var a;return this.insertHTML(o.join(""),t)}getSelectedText(e){return ge(e||this.getSelection())}getFontInfo(e){const t={color:void 0,backgroundColor:void 0,fontFamily:void 0,fontSize:void 0};e||(e=this.getSelection()),U(e);let n=0,o=e.commonAncestorContainer;if(e.collapsed||o instanceof Text)for(o instanceof Text&&(o=o.parentNode);n<4&&o;){const e=o.style;if(e){const o=e.color;!t.color&&o&&(t.color=o,++n);const i=e.backgroundColor;!t.backgroundColor&&i&&(t.backgroundColor=i,++n);const r=e.fontFamily;!t.fontFamily&&r&&(t.fontFamily=r,++n);const s=e.fontSize;!t.fontSize&&s&&(t.fontSize=s,++n)}o=o.parentNode}return t}hasFormat(e,n,o){e=e.toUpperCase(),n||(n={}),o||(o=this.getSelection()),!o.collapsed&&o.startContainer instanceof Text&&o.startOffset===o.startContainer.length&&o.startContainer.nextSibling&&o.setStartBefore(o.startContainer.nextSibling),!o.collapsed&&o.endContainer instanceof Text&&0===o.endOffset&&o.endContainer.previousSibling&&o.setEndAfter(o.endContainer.previousSibling);const i=this._root,r=o.commonAncestorContainer;if(N(r,i,e,n))return!0;if(r instanceof Text)return!1;const s=t(r,4,(e=>I(o,e,!0)));let a,l=!1;for(;a=s.nextNode();){if(!N(a,i,e,n))return!1;l=!0}return l}changeFormat(e,t,n,o){return n||(n=this.getSelection()),this.saveUndoState(n),t&&(n=this._removeFormat(t.tag.toUpperCase(),t.attributes||{},n,o)),e&&(n=this._addFormat(e.tag.toUpperCase(),e.attributes||{},n)),this.setSelection(n),this._updatePath(n,!0),this.focus()}_addFormat(n,o,i){const r=this._root;if(i.collapsed){const e=G(S(n,o));he(i,e);const t=e.firstChild||e,r=t instanceof Text?t.length:0;i.setStart(t,r),i.collapse(!0);let s=e;for(;m(s);)s=s.parentNode;B(s,e)}else{const s=t(i.commonAncestorContainer,5,(e=>(e instanceof Text||"BR"===e.nodeName||"IMG"===e.nodeName)&&I(i,e,!0)));let{startContainer:a,startOffset:l,endContainer:c,endOffset:h}=i;if(s.currentNode=a,!((a instanceof Element||a instanceof Text)&&e===s.filter.acceptNode(a))){const e=s.nextNode();if(!e)return i;a=e,l=0}do{let e=s.currentNode;if(!N(e,r,n,o)){e===c&&e.length>h&&e.splitText(h),e===a&&l&&(e=e.splitText(l),c===a?(c=e,h-=l):c===a.parentNode&&++h,a=e,l=0);const t=S(n,o);k(e,t),t.append(e)}}while(s.nextNode());i=de(a,l,c,h)}return i}_removeFormat(e,t,o,i){let r;this._saveRangeToBookmark(o),o.collapsed&&(r=l?document.createTextNode(n):document.createTextNode(""),he(o,r));let s=o.commonAncestorContainer;for(;m(s);)s=s.parentNode;const a=o.startContainer,c=o.startOffset,h=o.endContainer,u=o.endOffset,f=[],p=(e,t)=>{if(I(o,e,!1))return;let n,i;if(I(o,e,!0))if(e instanceof Text)e===h&&u!==e.length&&f.push([t,e.splitText(u)]),e===a&&c&&(e.splitText(c),f.push([t,e]));else for(n=e.firstChild;n;n=i)i=n.nextSibling,p(n,t);else e instanceof HTMLInputElement||e instanceof Text&&!e.data||f.push([t,e])},g=Array.from(s.getElementsByTagName(e)).filter((n=>I(o,n,!0)&&C(n,e,t)));if(i||g.forEach((e=>p(e,e))),f.forEach((([e,t])=>{e=e.cloneNode(!1),k(t,e),e.append(t)})),g.forEach((e=>k(e,L(e)))),l&&r){r=r.parentNode;let e=r;for(;e&&m(e);)e=e.parentNode;e&&B(e,r)}return this._getRangeAndRemoveBookmark(o),r&&o.collapse(!1),J(s,o),o}bold(){this.toggleTag("B")}italic(){this.toggleTag("I")}underline(){this.toggleTag("U")}strikethrough(){this.toggleTag("S")}subscript(){this.toggleTag("SUB","SUP")}superscript(){this.toggleTag("SUP","SUB")}makeLink(e,t){const n=this.getSelection();if(n.collapsed){let t=e.indexOf(":")+1;if(t)for(;"/"===e[t];)++t;he(n,document.createTextNode(e.slice(t)))}return t=Object.assign({href:e},t),this.changeFormat({tag:"A",attributes:t},{tag:"A"},n)}removeLink(){return this.changeFormat(null,{tag:"A"},this.getSelection(),!0)}addDetectedLinks(e,n){const o=t(e,4,(e=>!O(e,n||this._root,"A"))),i=this.linkRegExp;let r;for(;r=o.nextNode();){const e=r.parentNode;let t,n=r.data;for(;t=i.exec(n);){const o=t.index,i=o+t[0].length;o&&e.insertBefore(document.createTextNode(n.slice(0,o)),r);const s=S("A",{href:t[1]?/^(?:ht|f)tps?:/i.test(t[1])?t[1]:"http://"+t[1]:"mailto:"+t[0]});s.textContent=n.slice(o,i),e.insertBefore(s,r),r.data=n=n.slice(i)}}return this}_ensureBottomLine(){const e=this._root,t=e.lastElementChild;t&&t.nodeName===this._config.blockTag&&v(t)||e.append(this.createDefaultBlock())}createDefaultBlock(e){const t=this._config;return G(S(t.blockTag,null,e))}splitBlock(e,t){t||(t=this.getSelection());const o=this._root;let i,r,s,a;if(this._recordUndoState(t),this._removeZWS(),this._getRangeAndRemoveBookmark(t),t.collapsed||pe(t,o),this._config.addLinks){U(t);const e=t.startContainer,n=t.startOffset;setTimeout((()=>{_e(this,e,n)}),0)}if(i=re(t,o),i&&(r=O(i,o,"PRE"))){U(t),s=t.startContainer;const n=t.startOffset;return s instanceof Text||(s=document.createTextNode(""),r.insertBefore(s,r.firstChild)),!e&&s instanceof Text&&("\n"===s.data.charAt(n-1)||le(t,o))&&("\n"===s.data.charAt(n)||ce(t,o))?(s.deleteData(n&&n-1,n?2:1),a=X(s,n&&n-1,o,o),s=a.previousSibling,s.textContent||A(s),s=this.createDefaultBlock(),a.parentNode.insertBefore(s,a),a.textContent||A(a),t.setStart(s,0)):(s.insertData(n,"\n"),G(r),s.length===n+1?t.setStartAfter(s):t.setStart(s,n+1)),t.collapse(!0),this.setSelection(t),this._updatePath(t,!0),this._docWasChanged(),this}if(!i||e||/^T[HD]$/.test(i.nodeName))return M(t,"A",o),he(t,S("BR")),t.collapse(!1),this.setSelection(t),this._updatePath(t,!0),this;if((r=O(i,o,"LI"))&&(i=r),ie(i)){if(O(i,o,"UL")||O(i,o,"OL"))return this.decreaseListLevel(t),this;if(O(i,o,"BLOCKQUOTE"))return this.replaceWithBlankLine(t),this}s=t.startContainer;const l=t.startOffset;let c=this.tagAfterSplit[i.nodeName]||this._config.blockTag;for(a=X(s,l,i.parentNode,this._root),C(a,c)||(i=S(c),a.dir&&(i.dir=a.dir),k(a,i),i.append(L(a)),a=i),B(i),z(i),G(i);a instanceof Element;){let e,t=a.firstChild;if("A"===a.nodeName&&(!a.textContent||a.textContent===n)){t=document.createTextNode(""),k(a,t),a=t;break}for(;t&&t instanceof Text&&!t.length&&(e=t.nextSibling,e&&"BR"!==e.nodeName);)A(t),t=e;if(!t||"BR"===t.nodeName||t instanceof Text)break;a=t}return t=de(a,0),this.setSelection(t),this._updatePath(t,!0),this}forEachBlock(e,t,n){n||(n=this.getSelection()),t&&this.saveUndoState(n);const o=this._root;let i=re(n,o);const r=se(n,o);if(i&&r)do{if(e(i)||i===r)break}while(i=oe(i,o));return t&&(this.setSelection(n),this._updatePath(n,!0)),this}modifyBlocks(e,t){t||(t=this.getSelection()),this._recordUndoState(t,this._isInUndoState);const n=this._root;((e,t)=>{const n=re(e,t),o=se(e,t);let i;n&&o&&(i=n.parentNode,e.setStart(i,Array.from(i.childNodes).indexOf(n)),i=o.parentNode,e.setEnd(i,Array.from(i.childNodes).indexOf(o)+1))})(t,n),P(t,n,n,n);const o=ue(t,n,n);if(!t.collapsed){let e=t.endContainer;if(e===n)t.collapse(!1);else{for(;e.parentNode!==n;)e=e.parentNode;t.setStartBefore(e),t.collapse(!0)}}return he(t,e.call(this,o)),t.endOffset<t.endContainer.childNodes.length&&ee(t.endContainer.childNodes[t.endOffset],n),ee(t.startContainer.childNodes[t.startOffset],n),this._getRangeAndRemoveBookmark(t),this.setSelection(t),this._updatePath(t,!0),this}setTextAlignment(e){return this.forEachBlock((t=>{const n=t.className.split(/\s+/).filter((e=>!!e&&!/^align/.test(e))).join(" ");e?(t.className=n+" align-"+e,t.style.textAlign=e):(t.className=n,t.style.textAlign="")}),!0),this.focus()}setTextDirection(e){return this.forEachBlock((t=>{e?t.dir=e:t.removeAttribute("dir")}),!0),this.focus()}_getListSelection(e,t){let n=e.commonAncestorContainer,o=e.startContainer,i=e.endContainer;for(;n&&n!==t&&!/^[OU]L$/.test(n.nodeName);)n=n.parentNode;if(!n||n===t)return null;for(o===n&&(o=o.childNodes[e.startOffset]),i===n&&(i=i.childNodes[e.endOffset]);o&&o.parentNode!==n;)o=o.parentNode;for(;i&&i.parentNode!==n;)i=i.parentNode;return[n,o,i]}increaseListLevel(e){e||(e=this.getSelection());const t=this._root,n=this._getListSelection(e,t);if(!n)return this.focus();let[o,i,r]=n;if(!i||i===o.firstChild)return this.focus();this._recordUndoState(e,this._isInUndoState);const s=o.nodeName;let a,l=i.previousSibling;l.nodeName!==s&&(l=S(s),o.insertBefore(l,i));do{a=i===r?null:i.nextSibling,l.append(i)}while(i=a);return a=l.nextSibling,a&&ee(a,t),this._getRangeAndRemoveBookmark(e),this.setSelection(e),this._updatePath(e,!0),this.focus()}decreaseListLevel(e){e||(e=this.getSelection());const t=this._root,n=this._getListSelection(e,t);if(!n)return this.focus();let o,[i,r,s]=n;r||(r=i.firstChild),s||(s=i.lastChild),this._recordUndoState(e,this._isInUndoState);let a=null;if(r){let e=i.parentNode;if(a=s.nextSibling?X(i,s.nextSibling,e,t):i.nextSibling,e!==t&&"LI"===e.nodeName){for(e=e.parentNode;a;)o=a.nextSibling,s.append(a),a=o;a=i.parentNode.nextSibling}const n=!/^[OU]L$/.test(e.nodeName);do{o=r===s?null:r.nextSibling,i.removeChild(r),n&&"LI"===r.nodeName&&(r=this.createDefaultBlock([L(r)])),e.insertBefore(r,a)}while(r=o)}return i.firstChild||A(i),a&&ee(a,t),this._getRangeAndRemoveBookmark(e),this.setSelection(e),this._updatePath(e,!0),this.focus()}_makeList(e,t){const n=te(e,this._root);let o;for(;o=n.nextNode();)if(o.parentNode instanceof HTMLLIElement&&(o=o.parentNode,n.currentNode=o.lastChild),o instanceof HTMLLIElement){o=o.parentNode;const e=o.nodeName;e!==t&&/^[OU]L$/.test(e)&&k(o,S(t,null,[L(o)]))}else{const e=S("LI");o.dir&&(e.dir=o.dir);const i=o.previousSibling;i&&i.nodeName===t?(i.append(e),A(o)):k(o,S(t,null,[e])),e.append(L(o)),n.currentNode=e}return e}makeUnorderedList(){return this.modifyBlocks((e=>this._makeList(e,"UL"))),this.focus()}makeOrderedList(){return this.modifyBlocks((e=>this._makeList(e,"OL"))),this.focus()}removeList(){return this.modifyBlocks((e=>{const t=e.querySelectorAll("UL, OL"),n=e.querySelectorAll("LI");this._root;for(let e=0,n=t.length;e<n;++e){const n=t[e],o=L(n);Q(o),k(n,o)}for(let e=0,t=n.length;e<t;++e){const t=n[e];v(t)?k(t,this.createDefaultBlock([L(t)])):(Q(t),k(t,L(t)))}return e})),this.focus()}increaseQuoteLevel(e){return this.modifyBlocks((e=>S("BLOCKQUOTE",null,[e])),e),this.focus()}decreaseQuoteLevel(e){return this.modifyBlocks((e=>(Array.from(e.querySelectorAll("blockquote")).filter((t=>!O(t.parentNode,e,"BLOCKQUOTE"))).forEach((e=>{k(e,L(e))})),e)),e),this.focus()}removeQuote(e){return this.modifyBlocks((e=>(Array.from(e.querySelectorAll("blockquote")).forEach((e=>{k(e,L(e))})),e)),e),this.focus()}replaceWithBlankLine(e){return this.modifyBlocks((()=>this.createDefaultBlock([S("INPUT",{id:this.startSelectionId,type:"hidden"}),S("INPUT",{id:this.endSelectionId,type:"hidden"})])),e),this.focus()}code(){const e=this.getSelection();return e.collapsed||y(e.commonAncestorContainer)?(this.modifyBlocks((e=>{const n=this._root,o=document.createDocumentFragment(),i=te(e,n);let r;for(;r=i.nextNode();){let e=r.querySelectorAll("BR");const t=[];let n=e.length;for(let o=0;o<n;++o)t[o]=R(e[o]);for(;n--;){const o=e[n];t[n]?k(o,document.createTextNode("\n")):A(o)}for(e=r.querySelectorAll("CODE"),n=e.length;n--;)k(e[n],L(e[n]));o.childNodes.length&&o.append(document.createTextNode("\n")),o.append(L(r))}const s=t(o,4);for(;r=s.nextNode();)r.data=r.data.replace(/ /g," ");return o.normalize(),G(S("PRE",null,[o]))}),e),this.focus()):this.changeFormat({tag:"CODE",attributes:null},null,e),this}removeCode(){const e=this.getSelection(),n=e.commonAncestorContainer;return O(n,this._root,"PRE")?(this.modifyBlocks((e=>{this._root;const n=e.querySelectorAll("PRE");let o=n.length;for(;o--;){const e=n[o],i=t(e,4);let r;for(;r=i.nextNode();){let e=r.data;e=e.replace(/ (?= )/g," ");const t=document.createDocumentFragment();let n;for(;(n=e.indexOf("\n"))>-1;)t.append(document.createTextNode(e.slice(0,n))),t.append(S("BR")),e=e.slice(n+1);r.parentNode.insertBefore(t,r),r.data=e}Q(e),k(e,L(e))}return e}),e),this.focus()):this.changeFormat(null,{tag:"CODE"},e),this}toggleCode(){return this.hasFormat("PRE")||this.hasFormat("CODE")?this.removeCode():this.code(),this}changeIndentationLevel(e){let t=this.getSelectionClosest("UL,OL,BLOCKQUOTE");if(t||"increase"===e)return this[(e+=t&&"BLOCKQUOTE"!==t.nodeName?"List":"Quote")+"Level"]()}getSelectionClosest(e){return O(this.getSelection().commonAncestorContainer,this._root,e)}setAttribute(e,t){let n=this.getSelection(),o=n?.startContainer||{},i=n?.endContainer||{};if("dir"==e||o instanceof Text&&0===n.startOffset&&o===i&&i.length===n.endOffset)this._recordUndoState(n),w(o.parentNode,{[e]:t}),this._docWasChanged();else if(null==t){this._recordUndoState(n);let o=O(n.commonAncestorContainer,this._root,"*");n.collapsed?w(o,{[e]:t}):o.querySelectorAll("*").forEach((n=>w(n,{[e]:t}))),this._docWasChanged()}else this.changeFormat({tag:"SPAN",attributes:{[e]:t}},null,n);return this.focus()}setStyle(e){this.setAttribute("style",e)}toggleTag(e,t){let n=this.getSelection();this.hasFormat(e,null,n)?this.changeFormat(null,{tag:e},n):this.changeFormat({tag:e},t?{tag:t}:null,n)}setRange(e){this.setSelection(e),this._updatePath(e,!0)}setConfig(e){return this._config=mergeObjects({addLinks:!0},e,!0),this}}})(),(()=>{"use strict";const e=2147483647,t=36,n=/^xn--/,o=/[^\0-\x7F]/,i=/[\x2E\u3002\uFF0E\uFF61]/g,r={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},s=Math.floor,a=String.fromCharCode,l=e=>{throw new RangeError(r[e])},c=(e,t)=>{const n=(e||"").split("@");return n.push(n.pop().split(i).map((e=>t(e))).join(".")),n.join("@")},h=(e,t)=>e+22+75*(e<26)-((0!=t)<<5),u=(e,n,o)=>{let i=0;for(e=o?s(e/700):e>>1,e+=s(e/n);e>455;i+=t)e=s(e/35);return s(i+36*e/(e+38))};window.IDN={version:"2.3.1",toUnicode:o=>c(o,(o=>n.test(o)?(n=>{const o=[],i=n.length;let r=0,a=128,c=72,h=n.lastIndexOf("-");h<0&&(h=0);for(let e=0;e<h;++e)n.charCodeAt(e)>=128&&l("not-basic"),o.push(n.charCodeAt(e));for(let p=h>0?h+1:0;p<i;){const h=r;for(let o=1,a=t;;a+=t){p>=i&&l("invalid-input");const h=(f=n.charCodeAt(p++))>=48&&f<58?f-48+26:f>=65&&f<91?f-65:f>=97&&f<123?f-97:t;h>=t&&l("invalid-input"),h>s((e-r)/o)&&l("overflow"),r+=h*o;const u=a<=c?1:a>=c+26?26:a-c;if(h<u)break;const g=t-u;o>s(e/g)&&l("overflow"),o*=g}const g=o.length+1;c=u(r-h,g,0==h),s(r/g)>e-a&&l("overflow"),a+=s(r/g),r%=g,o.splice(r++,0,a)}var f;return String.fromCodePoint(...o)})(o.slice(4).toLowerCase()):o)),toASCII:n=>c(n,(n=>(o.test(n)?"xn--"+(n=>{const o=[];n=(e=>{const t=[];let n=0;const o=e.length;for(;n<o;){const i=e.charCodeAt(n++);if(i>=55296&&i<=56319&&n<o){const o=e.charCodeAt(n++);56320==(64512&o)?t.push(((1023&i)<<10)+(1023&o)+65536):(t.push(i),n--)}else t.push(i)}return t})(n);const i=n.length;let r=128,c=0,f=72;for(const e of n)e<128&&o.push(a(e));const p=o.length;let g=p;for(p&&o.push("-");g<i;){let i=e;for(const e of n)e>=r&&e<i&&(i=e);const m=g+1;i-r>s((e-c)/m)&&l("overflow"),c+=(i-r)*m,r=i;for(const i of n)if(i<r&&++c>e&&l("overflow"),i===r){let e=c;for(let n=t;;n+=t){const i=n<=f?1:n>=f+26?26:n-f;if(e<i)break;const r=e-i,l=t-i;o.push(a(h(i+r%l,0))),e=s(r/l)}o.push(a(h(e,0))),f=u(c,m,g===p),c=0,++g}++c,++r}return o.join("")})(n):n).toLowerCase()))}})();const TurndownService=(()=>{const e=(e,t)=>Array(t+1).join(e),t=["ADDRESS","ARTICLE","ASIDE","AUDIO","BLOCKQUOTE","BODY","CANVAS","CENTER","DD","DIR","DIV","DL","DT","FIELDSET","FIGCAPTION","FIGURE","FOOTER","FORM","FRAMESET","H1","H2","H3","H4","H5","H6","HEADER","HGROUP","HR","HTML","ISINDEX","LI","MAIN","MENU","NAV","NOFRAMES","NOSCRIPT","OL","OUTPUT","P","PRE","SECTION","TABLE","TBODY","TD","TFOOT","TH","THEAD","TR","UL"],n=e=>s(e,t),o=["AREA","BASE","BR","COL","COMMAND","EMBED","HR","IMG","INPUT","KEYGEN","LINK","META","PARAM","SOURCE","TRACK","WBR"],i=e=>s(e,o),r=["A","TABLE","THEAD","TBODY","TFOOT","TH","TD","IFRAME","SCRIPT","AUDIO","VIDEO"],s=(e,t)=>t.indexOf(e.nodeName)>=0,a=(e,t)=>e.getElementsByTagName&&t.some((t=>e.getElementsByTagName(t).length)),l={paragraph:{filter:"p",replacement:e=>"\n\n"+e+"\n\n"},lineBreak:{filter:"br",replacement:(e,t,n)=>n.br+"\n"},heading:{filter:["h1","h2","h3","h4","h5","h6"],replacement:(t,n,o)=>{var i=Number(n.nodeName.charAt(1));return"setext"===o.headingStyle&&i<3?"\n\n"+t+"\n"+e(1===i?"=":"-",t.length)+"\n\n":"\n\n"+e("#",i)+" "+t+"\n\n"}},blockquote:{filter:"blockquote",replacement:e=>"\n\n"+(e=(e=e.replace(/^\n+|\n+$/g,"")).replace(/^/gm,"> "))+"\n\n"},list:{filter:["ul","ol"],replacement:(e,t)=>{var n=t.parentNode;return"LI"===n.nodeName&&n.lastElementChild===t?"\n"+e:"\n\n"+e+"\n\n"}},listItem:{filter:"li",replacement:(e,t,n)=>{e=e.replace(/^\n+/,"").replace(/\n+$/,"\n").replace(/\n/gm,"\n ");var o=n.bulletListMarker+" ",i=t.parentNode;if("OL"===i.nodeName){var r=i.getAttribute("start"),s=Array.prototype.indexOf.call(i.children,t);o=(r?Number(r)+s:s+1)+". "}return o+e+(t.nextSibling&&!/\n$/.test(e)?"\n":"")}},indentedCodeBlock:{filter:(e,t)=>"indented"===t.codeBlockStyle&&"PRE"===e.nodeName&&e.firstChild&&"CODE"===e.firstChild.nodeName,replacement:(e,t)=>"\n\n "+t.firstChild.textContent.replace(/\n/g,"\n ")+"\n\n"},fencedCodeBlock:{filter:(e,t)=>"fenced"===t.codeBlockStyle&&"PRE"===e.nodeName&&e.firstChild&&"CODE"===e.firstChild.nodeName,replacement:(t,n,o)=>{for(var i,r=((n.firstChild.getAttribute("class")||"").match(/language-(\S+)/)||[null,""])[1],s=n.firstChild.textContent,a=o.fence.charAt(0),l=3,c=new RegExp("^"+a+"{3,}","gm");i=c.exec(s);)i[0].length>=l&&(l=i[0].length+1);var h=e(a,l);return"\n\n"+h+r+"\n"+s.replace(/\n$/,"")+"\n"+h+"\n\n"}},horizontalRule:{filter:"hr",replacement:(e,t,n)=>"\n\n"+n.hr+"\n\n"},inlineLink:{filter:(e,t)=>"inlined"===t.linkStyle&&"A"===e.nodeName&&e.getAttribute("href"),replacement:(e,t)=>{var n=t.getAttribute("href");n&&(n=n.replace(/([()])/g,"\\$1"));var o=c(t.getAttribute("title"));return o&&(o=' "'+o.replace(/"/g,'\\"')+'"'),"["+e+"]("+n+o+")"}},referenceLink:{filter:(e,t)=>"referenced"===t.linkStyle&&"A"===e.nodeName&&e.getAttribute("href"),replacement(e,t,n){var o,i,r=t.getAttribute("href"),s=c(t.getAttribute("title"));switch(s&&(s=' "'+s+'"'),n.linkReferenceStyle){case"collapsed":o="["+e+"][]",i="["+e+"]: "+r+s;break;case"shortcut":o="["+e+"]",i="["+e+"]: "+r+s;break;default:var a=this.references.length+1;o="["+e+"]["+a+"]",i="["+a+"]: "+r+s}return this.references.push(i),o},references:[],append(){var e="";return this.references.length&&(e="\n\n"+this.references.join("\n")+"\n\n",this.references=[]),e}},emphasis:{filter:["em","i"],replacement:(e,t,n)=>e.trim()?n.emDelimiter+e+n.emDelimiter:""},strong:{filter:["strong","b"],replacement:(e,t,n)=>e.trim()?n.strongDelimiter+e+n.strongDelimiter:""},code:{filter:e=>{var t=e.previousSibling||e.nextSibling,n="PRE"===e.parentNode.nodeName&&!t;return"CODE"===e.nodeName&&!n},replacement:e=>{if(!e)return"";e=e.replace(/\r?\n|\r/g," ");for(var t=/^`|^ .*?[^ ].* $|`$/.test(e)?" ":"",n="`",o=e.match(/`+/gm)||[];-1!==o.indexOf(n);)n+="`";return n+t+e+t+n}},image:{filter:"img",replacement:(e,t)=>{var n=c(t.getAttribute("alt")),o=t.getAttribute("src")||"",i=c(t.getAttribute("title"));return o?"+")":""}},style:{filter:"style",replacement:()=>""}},c=e=>e?e.replace(/(\n+\s*)+/g,"\n"):"";class Rules{constructor(e){for(var t in this.options=e,this._keep=[],this._remove=[],this.blankRule={replacement:e.blankReplacement},this.keepReplacement=e.keepReplacement,this.defaultRule={replacement:e.defaultReplacement},this.array=[],e.rules)this.array.push(e.rules[t])}add(e,t){this.array.unshift(t)}keep(e){this._keep.unshift({filter:e,replacement:this.keepReplacement})}remove(e){this._remove.unshift({filter:e,replacement:()=>""})}forNode(e){return e.isBlank?this.blankRule:h(this.array,e,this.options)||h(this._keep,e,this.options)||h(this._remove,e,this.options)||this.defaultRule}forEach(e){for(var t=0;t<this.array.length;t++)e(this.array[t],t)}}const h=(e,t,n)=>{for(var o=0;o<e.length;o++){var i=e[o];if(u(i,t,n))return i}},u=(e,t,n)=>{var o=e.filter;if("string"==typeof o)return o===t.nodeName.toLowerCase();if(Array.isArray(o))return o.indexOf(t.nodeName.toLowerCase())>-1;if("function"==typeof o)return!!o.call(e,t,n);throw new TypeError("`filter` needs to be a string, array, or function")},f=e=>{var t=e.nextSibling||e.parentNode;return e.parentNode.removeChild(e),t},p=(e,t,n)=>e&&e.parentNode===t||n(t)?t.nextSibling||t.parentNode:t.firstChild||t.nextSibling||t.parentNode,g=(e,t)=>{var o;"string"==typeof e?o=v().parseFromString('<x-turndown id="turndown-root">'+e+"</x-turndown>","text/html").getElementById("turndown-root"):o=e.cloneNode(!0);return(e=>{var t=e.element,n=e.isBlock,o=e.isVoid,i=e.isPre||(e=>"PRE"===e.nodeName);if(t.firstChild&&!i(t)){for(var r=null,s=!1,a=null,l=p(a,t,i);l!==t;){if(3===l.nodeType||4===l.nodeType){var c=l.data.replace(/[ \r\n\t]+/g," ");if(r&&!/ $/.test(r.data)||s||" "!==c[0]||(c=c.substr(1)),!c){l=f(l);continue}l.data=c,r=l}else{if(1!==l.nodeType){l=f(l);continue}n(l)||"BR"===l.nodeName?(r&&(r.data=r.data.replace(/ $/,"")),r=null,s=!1):o(l)||i(l)?(r=null,s=!0):r&&(s=!1)}var h=p(a,l,i);a=l,l=h}r&&(r.data=r.data.replace(/ $/,""),r.data||f(r))}})({element:o,isBlock:n,isVoid:i,isPre:t.preformattedCode?y:null}),o};var m;const v=()=>m=m||new DOMParser,y=e=>"PRE"===e.nodeName||"CODE"===e.nodeName,S=e=>!i(e)&&!(e=>s(e,r))(e)&&/^\s*$/i.test(e.textContent)&&!(e=>a(e,o))(e)&&!(e=>a(e,r))(e),E=(e,t)=>{if(e.isBlock||t.preformattedCode&&e.isCode)return{leading:"",trailing:""};var n=C(e.textContent);return n.leadingAscii&&N("left",e,t)&&(n.leading=n.leadingNonAscii),n.trailingAscii&&N("right",e,t)&&(n.trailing=n.trailingNonAscii),{leading:n.leading,trailing:n.trailing}},C=e=>{var t=e.match(/^(([ \t\r\n]*)(\s*))(?:(?=\S)[\s\S]*\S)?((\s*?)([ \t\r\n]*))$/);return{leading:t[1],leadingAscii:t[2],leadingNonAscii:t[3],trailing:t[4],trailingNonAscii:t[5],trailingAscii:t[6]}},N=(e,t,o)=>{var i,r,s;return"left"===e?(i=t.previousSibling,r=/ $/):(i=t.nextSibling,r=/^ /),i&&(3===i.nodeType?s=r.test(i.nodeValue):o.preformattedCode&&"CODE"===i.nodeName?s=!1:1!==i.nodeType||n(i)||(s=r.test(i.textContent))),s},_=Array.prototype.reduce,T=[[/\\/g,"\\\\"],[/\*/g,"\\*"],[/^-/g,"\\-"],[/^\+ /g,"\\+ "],[/^(=+)/g,"\\$1"],[/^(#{1,6}) /g,"\\$1 "],[/`/g,"\\`"],[/^~~~/g,"\\~~~"],[/\[/g,"\\["],[/\]/g,"\\]"],[/^>/g,"\\>"],[/_/g,"\\_"],[/^(\d+)\. /g,"$1\\. "]];const x=(e,t)=>{var n=(e=>{for(var t=e.length;t>0&&"\n"===e[t-1];)t--;return e.substring(0,t)})(e),o=t.replace(/^\n*/,""),i=Math.max(e.length-n.length,t.length-o.length);return n+"\n\n".substring(0,i)+o},L=e=>null!=e&&("string"==typeof e||e.nodeType&&(1===e.nodeType||9===e.nodeType||11===e.nodeType));return class TurndownService{constructor(e){this.options=Object.assign({rules:l,headingStyle:"setext",hr:"* * *",bulletListMarker:"*",codeBlockStyle:"indented",fence:"```",emDelimiter:"_",strongDelimiter:"**",linkStyle:"inlined",linkReferenceStyle:"full",br:" ",preformattedCode:!1,blankReplacement:(e,t)=>t.isBlock?"\n\n":"",keepReplacement:(e,t)=>t.isBlock?"\n\n"+t.outerHTML+"\n\n":t.outerHTML,defaultReplacement:(e,t)=>t.isBlock?"\n\n"+e+"\n\n":e},e),this.rules=new Rules(this.options)}turndown(e){if(!L(e))throw new TypeError(e+" is not a string, or an element/document/fragment node.");if(""===e)return"";var t=this.process(g(e,this.options));return this.postProcess(t)}use(e){if(Array.isArray(e))for(var t=0;t<e.length;t++)this.use(e[t]);else{if("function"!=typeof e)throw new TypeError("plugin must be a Function or an Array of Functions");e(this)}return this}addRule(e,t){return this.rules.add(e,t),this}keep(e){return this.rules.keep(e),this}remove(e){return this.rules.remove(e),this}escape(e){return T.reduce(((e,t)=>e.replace(t[0],t[1])),e)}process(e){var t=this;return _.call(e.childNodes,((e,o)=>{var i="";return 3===(o=((e,t)=>(e.isBlock=n(e),e.isCode="CODE"===e.nodeName||e.parentNode.isCode,e.isBlank=S(e),e.flankingWhitespace=E(e,t),e))(o,t.options)).nodeType?i=o.isCode?o.nodeValue:t.escape(o.nodeValue):1===o.nodeType&&(i=t.replacementForNode(o)),x(e,i)}),"")}postProcess(e){var t=this;return this.rules.forEach((n=>{"function"==typeof n.append&&(e=x(e,n.append(t.options)))})),e.replace(/^[\t\r\n]+/,"").replace(/[\t\r\n\s]+$/,"")}replacementForNode(e){var t=this.rules.forNode(e),n=this.process(e),o=e.flankingWhitespace;return(o.leading||o.trailing)&&(n=n.trim()),o.leading+t.replacement(n,e,this.options)+o.trailing}}})();(e=>{const t=(e,t)=>rl.i18n(e)||t,n=shortcuts.getMetaKey()+" + ",o=t=>e.createElement(t),i=o("template"),r=e=>e.trim().replace(/^(<div>\s*<br\s*\/?>\s*<\/div>)+/,"").trim(),s=e=>rl.Utils.htmlToPlain(e).trim(),a=e=>rl.Utils.plainToHtml(e),l=(e,t)=>Object.values(e).forEach(t),c={sanitizeToDOMFragment:(e,t)=>(e=(e||"").replace(/<\/?(BODY|HTML)[^>]*>/gi,"").replace(/<!--[^>]+-->/g,"").replace(/<span[^>]*>\s*<\/span>/gi,"").trim(),i.innerHTML=t?rl.Utils.cleanHtml(e).html:e,i.content)};this.SquireUI=class SquireUI{constructor(i){const r=o("input"),s=e=>t=>{r.style.left=t.offsetLeft+t.parentNode.offsetLeft+"px",r.style.width=t.offsetWidth+"px",r.value="",r.onchange=()=>g.setStyle({[e]:r.value}),setTimeout((()=>r.click()),1)},a={mode:{plain:{select:[[t("SETTINGS_GENERAL/EDITOR_HTML"),"wysiwyg"],[t("SETTINGS_GENERAL/EDITOR_PLAIN"),"plain"]],cmd:e=>this.setMode("plain"==e.value?"plain":"wysiwyg")}},font:{fontFamily:{select:{"sans-serif":{Arial:"'Nimbus Sans L', 'Liberation sans', 'Arial Unicode MS', Arial, Helvetica, Garuda, Utkal, FreeSans, sans-serif",Tahoma:"'Luxi Sans', Tahoma, Loma, Geneva, Meera, sans-serif",Trebuchet:"'DejaVu Sans Condensed', Trebuchet, 'Trebuchet MS', sans-serif",Lucida:"'Lucida Sans Unicode', 'Lucida Sans', 'DejaVu Sans', 'Bitstream Vera Sans', 'DejaVu LGC Sans', sans-serif",Verdana:"'DejaVu Sans', Verdana, Geneva, 'Bitstream Vera Sans', 'DejaVu LGC Sans', sans-serif"},monospace:{Courier:"'Liberation Mono', 'Courier New', FreeMono, Courier, monospace",Lucida:"'DejaVu Sans Mono', 'DejaVu LGC Sans Mono', 'Bitstream Vera Sans Mono', 'Lucida Console', Monaco, monospace"},sans:{Times:"'Nimbus Roman No9 L', 'Times New Roman', Times, FreeSerif, serif",Palatino:"'Bitstream Charter', 'Palatino Linotype', Palatino, Palladio, 'URW Palladio L', 'Book Antiqua', Times, serif",Georgia:"'URW Palladio L', Georgia, Times, serif"}},cmd:e=>g.setStyle({fontFamily:e.value})},fontSize:{select:[[t("GLOBAL/DEFAULT"),""],"11px","13px","16px","20px","24px","30px"],defaultValueIndex:0,cmd:e=>g.setStyle({fontSize:e.value})}},dir:{dir_ltr:{html:"⁋",cmd:()=>g.setTextDirection("ltr")},dir_rtl:{html:"¶",cmd:()=>g.setTextDirection("rtl")}},colors:{textColor:{html:"A<sub>▾</sub>",cmd:s("color")},backgroundColor:{html:"🎨",cmd:s("backgroundColor")}},inline:{bold:{html:"B",cmd:()=>this.doAction("bold"),key:"B",matches:"B,STRONG"},italic:{html:"I",cmd:()=>this.doAction("italic"),key:"I",matches:"I"},underline:{html:"<u>U</u>",cmd:()=>this.doAction("underline"),key:"U",matches:"U"},strike:{html:"<s>S</s>",cmd:()=>this.doAction("strikethrough"),key:"Shift + 7",matches:"S"},sub:{html:"Xₙ",cmd:()=>this.doAction("subscript"),key:"Shift + 5",matches:"SUB"},sup:{html:"Xⁿ",cmd:()=>this.doAction("superscript"),key:"Shift + 6",matches:"SUP"}},block:{ol:{html:"#",cmd:()=>this.doList("OL"),key:"Shift + 8",matches:"OL"},ul:{html:"⋮",cmd:()=>this.doList("UL"),key:"Shift + 9",matches:"UL"},quote:{html:'"',cmd:()=>{let e=g.getSelectionClosest("UL,OL,BLOCKQUOTE")?.nodeName;"BLOCKQUOTE"==e?g.decreaseQuoteLevel():g.increaseQuoteLevel()},matches:"BLOCKQUOTE"},indentDecrease:{html:"⇤",cmd:()=>g.changeIndentationLevel("decrease"),key:"]"},indentIncrease:{html:"⇥",cmd:()=>g.changeIndentationLevel("increase"),key:"["}},targets:{link:{html:"🔗",cmd:()=>{let e=g.getSelectionClosest("A"),t=prompt("Link",e?.href||"https://");null!=t&&(t.length?g.makeLink(t):e&&g.removeLink())},matches:"A"},imageUrl:{html:"🖼️",cmd:()=>{let e=g.getSelectionClosest("IMG"),t=prompt("Image",e?.src||"https://");t?.length?g.insertImage(t):e?.remove()},matches:"IMG"},imageUpload:{html:"📂️",cmd:()=>p.click(),matches:"IMG"}},changes:{undo:{html:"↶",cmd:()=>g.undo(),key:"Z"},redo:{html:"↷",cmd:()=>g.redo(),key:"Y"},source:{html:"👁",cmd:e=>{this.setMode("source"==this.mode?"wysiwyg":"source"),e.classList.toggle("active","source"==this.mode)}}},clear:{removeStyle:{html:"⎚",cmd:()=>g.setStyle()}}},h=o("textarea"),u=o("div"),f=o("div"),p=o("input"),g=new Squire(u,c);r.type="color",f.append(r);let m,v,y="squire-colors",S=e.getElementById(y),E=e=>S.append(new Option(e));for(m in S||(S=o("datalist"),S.id=y,E("#4E79A7"),E("#F28E2B"),E("#E15759"),E("#76B7B2"),E("#59A14F"),E("#EDC948"),E("#B07AA1"),E("#FF9DA7"),E("#9C755F"),E("#BAB0AC"),e.body.append(S)),r.setAttribute("list",y),p.type="file",p.accept="image/*",p.style.display="none",p.onchange=()=>{if(p.files.length){let e=new FileReader;e.readAsDataURL(p.files[0]),e.onloadend=()=>e.result&&g.insertImage(e.result)}},h.className="squire-plain",u.className="squire-wysiwyg",u.dir="auto",this.mode="",this.container=i,this.squire=g,this.plain=h,this.wysiwyg=u,dispatchEvent(new CustomEvent("squire-toolbar",{detail:{squire:this,actions:a}})),f.className="squire-toolbar btn-toolbar",a){let e=o("div");for(v in e.className="btn-group",e.id="squire-toolgroup-"+m,a[m]){let i,r=a[m][v],s="click";r.input?(i=o("input"),i.type=r.input,s="change"):r.select?(i=o("select"),i.className="btn",Array.isArray(r.select)?r.select.forEach((e=>{e=Array.isArray(e)?e:[e,e];var t=new Option(e[0],e[1]);t.style[v]=e[1],i.append(t)})):(i.add(new Option(t("GLOBAL/DEFAULT"),"")),Object.entries(r.select).forEach((([e,t])=>{let n=o("optgroup");n.label=e,Object.entries(t).forEach((([e,t])=>{var o=new Option(e,t);o.style[v]=t,n.append(o)})),i.add(n)}))),s="input"):(i=o("button"),i.type="button",i.className="btn",i.innerHTML=r.html,i.action_cmd=r.cmd),i.addEventListener(s,(()=>r.cmd(i))),r.hint=t("EDITOR/"+v.toUpperCase()),r.hint?i.title=r.key?r.hint+" ("+n+r.key+")":r.hint:r.key&&(i.title=n+r.key),i.dataset.action=v,i.tabIndex=-1,r.input=i,e.append(i)}e.children.length&&f.append(e)}this.modeSelect=a.mode.plain.input;let C=a.changes;C.undo.input.disabled=C.redo.input.disabled=!0,g.addEventListener("undoStateChange",(e=>{C.undo.input.disabled=!e.detail.canUndo,C.redo.input.disabled=!e.detail.canRedo})),g.addEventListener("pasteImage",(e=>{const t=e.detail.clipboardData.items;let n=t.length;for(;n--;){const e=t[n];if(/^image\/(png|jpeg|webp)/.test(e.type)){let t=new FileReader;t.onload=e=>{let t=o("img"),n=o("canvas"),i=n.getContext("2d");t.onload=()=>{i.drawImage(t,0,0);let e=t.width,o=t.height;e>o?e>1024&&(o=1024*o/e,e=1024):o>1024&&(e=1024*e/o,o=1024),n.width=e,n.height=o,i.drawImage(t,0,0,e,o),g.insertHTML('<img alt="" style="width:100%;max-width:'+e+'px" src="'+n.toDataURL()+'">',!0)},t.src=e.target.result},t.readAsDataURL(e.getAsFile());break}}})),a.font.fontSize.input.selectedIndex=a.font.fontSize.defaultValueIndex,i.append(f,u,h);const N=e=>e.trim().replace(/(^["']*|["']*$)/g,"").trim().toLowerCase(),_=Object.values(a.font.fontFamily.input.options).map((e=>e.value.toLowerCase()));let T=0;const x=getComputedStyle(g.getRoot()).fontFamily.split(",").map(N);_.some(((e,t)=>{const n=e.split(",").some((e=>{const t=N(e);return x.some((e=>e===t))}));return n&&(T=t),n}));const L={},A=(e,t)=>{e.split(",").forEach((e=>{const n=N(e);void 0===L[n]&&(L[n]=t)}))};A(_[T],T),_.forEach(((e,t)=>{t!==T&&A(e,t)})),g.addEventListener("pathChange",(()=>{const e=g.getRoot();let t=g.getSelection(),n=t.collapsed,o=n?t.endContainer:t?.commonAncestorContainer;if(!o||o instanceof Element||(o=o.parentElement),l(a,(i=>{l(i,(i=>{i.matches&&i.input.classList.toggle("active",!(!o||!(!n&&[...o.querySelectorAll(i.matches)].some((e=>t.intersectsNode(e)))||o.closestWithin(i.matches,e))))}))})),o){let t=a.font.fontSize.defaultValueIndex,n=T,i=!1,r=!1;do{if(!i&&o.style.fontFamily){i=!0,n=-1;const e=o.style.fontFamily.split(",");for(let t=0;t<e.length;t++){const o=L[N(e[t])];if(void 0!==o){n=o;break}}}!r&&o.style.fontSize&&(r=!0,t=a.font.fontSize.select.indexOf(o.style.fontSize)),o=o.parentElement}while((!i||!r)&&o&&o!==e);a.font.fontFamily.input.selectedIndex=n,a.font.fontSize.input.selectedIndex=t}}))}doAction(e){this.squire[e](),this.squire.focus()}doList(e){let t=this.squire.getSelectionClosest("UL,OL")?.nodeName;t==e?this.squire.removeList():this.squire[{UL:"makeUnorderedList",OL:"makeOrderedList"}[e]]()}setMode(e){if(this.mode!=e){let t=this.container.classList,n="source"==this.mode;t.remove("squire-mode-"+this.mode),"plain"==e?this.plain.value=s(n?this.plain.value:this.squire.getHTML()):"source"==e?this.plain.value=this.squire.getHTML():(this.setData(n?this.plain.value:a(this.plain.value)),e="wysiwyg"),this.mode=e,t.add("squire-mode-"+e),this.onModeChange?.(),setTimeout((()=>this.focus()),1)}this.modeSelect.selectedIndex="plain"==this.mode?1:0}on(e,t){"mode"==e?this.onModeChange=t:(this.squire.addEventListener(e,t),this.plain.addEventListener(e,t))}execCommand(e,t){if("insertSignature"==e)if((t=Object.assign({clearCache:!1,isHtml:!1,insertBefore:!1,signature:""},t)).clearCache)this._prev_txt_sig=null;else try{const e=t.isHtml?s(t.signature):t.signature;if("plain"===this.mode){let n=this.plain.value,o=this._prev_txt_sig;o&&(n=n.replace(o,"").trim()),this.plain.value=t.insertBefore?"\n\n"+e+"\n\n"+n:n+"\n\n"+e}else{const e=this.squire.getRoot(),n=o("br"),i=o("div");i.className="rl-signature",i.innerHTML=t.isHtml?t.signature:a(t.signature),e.querySelectorAll("div.rl-signature").forEach((e=>e.remove())),t.insertBefore?e.prepend(i):e.append(i),i.before(n),i.before(n.cloneNode())}this._prev_txt_sig=e}catch(e){}}getData(){return"source"==this.mode?this.plain.value:r(this.squire.getHTML())}setData(e){const t=this.squire;t.setHTML(r(e));const n=t.getRoot(),o=t.getSelection();o.setStart(n,0),o.setEnd(n,0),t.setSelection(o)}getPlainData(){return this.plain.value}setPlainData(e){this.plain.value=e}blur(){this.squire.blur()}focus(){"plain"==this.mode?(this.plain.focus(),this.plain.setSelectionRange(0,0)):this.squire.focus()}}})(document);
| ver. 1.4 |
Github
|
.
| PHP 8.2.28 | Generation time: 0.03 |
proxy
|
phpinfo
|
Settings