lakelib 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/lake.min.js CHANGED
@@ -2,7 +2,7 @@ var Lake=function(t){"use strict";class e extends HTMLElement{}void 0!==customEl
2
2
  <span class="lake-box-strip"><br /></span>
3
3
  <div class="lake-box-container" contenteditable="false"></div>
4
4
  <span class="lake-box-strip"><br /></span>
5
- `;class Yt{constructor(t){if(this.event=new qt,"string"==typeof t){const e=Kt.get(t);if(void 0===e)throw new Error(`Box '${t}' has not been defined yet.`);const i=r(e.type),n=r(e.name);this.node=I(a`<lake-box type="${i}" name="${n}"></lake-box>`),e.value&&(this.value=e.value)}else{this.node=I(t);const e=Kt.get(this.name);if(void 0===e)throw new Error(`Box '${this.name}' has not been defined yet.`);e.value&&!this.node.hasAttr("value")&&(this.value=e.value)}Xt[this.node.id]||(Xt[this.node.id]={}),Jt[this.node.id]||(Jt[this.node.id]={setup:[],cleanup:[]})}addFramework(){let t=this.getContainer();0===t.length?(this.node.html(Qt),t=this.getContainer()):(t.off("mouseenter"),t.off("mouseleave"),t.off("click")),t.on("mousedown",(t=>{t.preventDefault()})),t.on("mouseenter",(()=>{t.hasClass("lake-box-selected")||t.hasClass("lake-box-focused")||t.hasClass("lake-box-activated")||t.addClass("lake-box-hovered")})),t.on("mouseleave",(()=>{t.removeClass("lake-box-hovered")})),t.on("click",(()=>{A(`Box '${this.name}' (id = ${this.node.id}) value:`),A(this.value)}))}get type(){return this.node.attr("type")}get name(){return this.node.attr("name")}get value(){const t=this.node.attr("value");return""===t?{}:JSON.parse(jt(t))}set value(t){this.node.attr("value",Ft(JSON.stringify(t)))}updateValue(t,e){const i=this.value;"string"==typeof t?i[t]=e:g(t,((t,e)=>{i[t]=e})),this.value=i}getData(t){return Xt[this.node.id][t]}setData(t,e){Xt[this.node.id][t]=e}getEditor(){const t=this.node.closest("div[contenteditable]");return t.length>0?Gt.get(t.id):void 0}getContainer(){return this.node.find(".lake-box-container")}useEffect(t){Jt[this.node.id].setup.push(t)}render(){Jt[this.node.id].setup=[],Jt[this.node.id].cleanup=[];const t=Kt.get(this.name);if(void 0===t)return;this.addFramework();const e=t.render(this);if(void 0!==e){const t=this.getContainer(),i=t.clone(!1);i.append(e),ht(t,i)}for(const t of Jt[this.node.id].setup){const e=t();void 0!==e&&Jt[this.node.id].cleanup.push(e)}A(`Box '${this.name}' (id = ${this.node.id}) rendered`)}unmount(){for(const t of Jt[this.node.id].cleanup)t();Xt[this.node.id]={},Jt[this.node.id].setup=[],Jt[this.node.id].cleanup=[],this.node.empty(),A(`Box '${this.name}' (id = ${this.node.id}) unmounted`)}getHTML(){const t=Kt.get(this.name);return void 0===t?"":void 0===t.html?this.node.outerHTML():t.html(this)}}const te={id:/^[\w-]+$/,class:/^[\w-]+$/,style:{"text-align":["left","center","right","justify","start","end"],"margin-left":/^-?\d+px$/i,"text-indent":/^-?\d+em$/i}};function ee(){return{h1:Object.assign({},te),h2:Object.assign({},te),h3:Object.assign({},te),h4:Object.assign({},te),h5:Object.assign({},te),h6:Object.assign({},te),p:Object.assign({},te),blockquote:Object.assign(Object.assign({},te),{type:["info","tip","success","warning","error","danger"]}),ul:Object.assign(Object.assign({},te),{type:"checklist",indent:/^\d+$/}),ol:Object.assign(Object.assign({},te),{start:/^\d+$/,indent:/^\d+$/}),li:{value:["true","false"]},table:{style:{width:/^-?\d+(px|%)$/i,height:/^-?\d+(px|%)$/i,border:/^[^"]+$/,"border-width":/^-?\d+px$/i,"border-style":/^[\w-]+$/,"border-color":/^[^"]+$/,"background-color":/^[^"]+$/}},tr:{style:{height:/^-?\d+(px|%)$/i}},th:"td",td:{colspan:/^\d+$/,rowspan:/^\d+$/,style:{width:/^-?\d+(px|%)$/i,height:/^-?\d+(px|%)$/i,border:/^[^"]+$/,"border-width":/^-?\d+px$/i,"border-style":/^[\w-]+$/,"border-color":/^[^"]+$/,"background-color":/^[^"]+$/,"text-align":["left","center","right","justify"]}},"lake-box":{type:["inline","block"],name:/^[\w-]+$/,value:/^[^"]+$/,focus:["start","center","end"]},br:{},hr:{},img:{src:/^[^"]+$/,width:/^-?\d+px$/i,height:/^-?\d+px$/i,"data-lake-value":/^[^"]+$/,alt:/^[^"]+$/,style:{width:/^-?\d+px$/i,height:/^-?\d+px$/i}},span:{class:/^[\w-]+$/,style:{color:/^[^"]+$/,"background-color":/^[^"]+$/,"font-family":/^[^;]+$/,"font-size":/^[^"]+$/}},b:"strong",strong:{},em:"i",i:{},u:{},s:{},sub:{},sup:{},code:{},a:{class:/^[\w-]+$/,name:/^[\w-]+$/,href:/^[^"]+$/,target:/^[\w-]+$/,rel:/^[^"]+$/,download:/^[^"]+$/},"lake-bookmark":{type:["anchor","focus"]}}}class ie{constructor(t,e=ee()){this.rules=e,this.source="string"==typeof t?this.parseHTML(t):t}parseHTML(t){const e=(new DOMParser).parseFromString(t,"text/html");return new E(e.querySelector("body"))}static matchRule(t,e){return"string"==typeof t?t===e:Array.isArray(t)?t.indexOf(e)>=0:t instanceof RegExp&&t.test(e)}static getOpenTagString(t,e){let i=t.name,n=e[i];if(!n)return"";"string"==typeof n&&(i=n,n=e[i]);const s=t.get(0);if(!s.hasAttributes())return i;const o=new Map;for(const t of s.attributes)if(n[t.name]&&("style"!==t.name&&ie.matchRule(n[t.name],t.value)&&o.set(t.name,t.value),"style"===t.name)){const e=n.style,i=new Map;g(p(t.value),((t,n)=>{e[t]&&ie.matchRule(e[t],n)&&i.set(t,n)})),o.set("style",i)}let r=i;for(const[t,e]of o)if("style"===t){let t="";for(const[i,n]of e)t+=`${i}: ${n.replace(/"/g,"&quot;")}; `;""!==t&&(r+=` style="${t.trim()}"`)}else r+=` ${t}="${e}"`;return r}static getClosedTagString(t,e){let i=t.name;const n=e[i];return n?("string"==typeof n&&(i=n),i):""}static getTrimmedText(t){const e=t.parent(),i=t.prev(),n=t.next();let s=t.text();return(i.isBlock||i.isBlockBox)&&(n.isBlock||n.isBlockBox)||0===i.length&&0===n.length&&e.isBlock?s=s.replace(/^[\u0020\t\r\n]+|[\u0020\t\r\n]+$/g,""):i.isBlock||i.isBlockBox||0===i.length&&e.isBlock?s=s.replace(/^[\u0020\t\r\n]+/,""):(n.isBlock||n.isBlockBox||0===n.length&&e.isBlock)&&(s=s.replace(/[\u0020\t\r\n]+$/,"")),s}getHTML(){const t=this.rules;let e="";for(const i of function*e(i){let n=i.first();for(;n.length>0;){const i=n.next();if(n.isText)yield r(ie.getTrimmedText(n));else if(n.isVoid){const e=ie.getOpenTagString(n,t);""!==e&&(yield`<${e} />`)}else if(n.isElement){const i=ie.getOpenTagString(n,t),s=ie.getClosedTagString(n,t);""!==i&&(yield`<${i}>`),n.isBox||(yield*e(n)),""!==s&&(yield`</${s}>`)}n=i}}(this.source))e+=i;return e.trim()}getNodeList(){const t=this.getHTML();return this.parseHTML(t).children()}getFragment(){const t=this.getHTML(),e=this.parseHTML(t),i=document.createDocumentFragment();let n=e.first();for(;n.length>0;){const t=n.next();i.appendChild(n.get(0)),n=t}return i}}class ne{constructor(t){this.content=t}getHTML(){let t=this.content;return t=t.replace(/ {2}/g,"  "),t=r(t.trim()),t=`<p>${t}</p>`,t=t.replace(/(\r\n){2,}/g,"</p><p><br /></p><p>"),t=t.replace(/\r\n/g,"</p><p>"),t=t.replace(/[\r\n]{2,}/g,"</p><p><br /></p><p>"),t=t.replace(/[\r\n]/g,"</p><p>"),t}getFragment(){return new ie(this.getHTML()).getFragment()}}function se(t,e){if(t.commonAncestor.isOutside)return;const i=(e=I(e)).get(0),n=t.get();n.insertNode(i),n.setEndAfter(i),n.collapse(!1)}function oe(t){if(t.commonAncestor.isOutside)return{anchor:new E,focus:new E};const e=t.startNode.closest("lake-box");if(e.length>0)return t.isBoxStart?e.attr("focus","start"):t.isBoxEnd?e.attr("focus","end"):e.attr("focus","center"),{anchor:new E,focus:e};if(t.isCollapsed){const e=t.clone();e.collapseToEnd();const i=I('<lake-bookmark type="focus" />');return se(e,i),{anchor:new E,focus:i}}const i=t.clone();i.collapseToStart();const n=I('<lake-bookmark type="anchor" />');se(i,n);const s=t.clone();s.collapseToEnd();const o=I('<lake-bookmark type="focus" />');return se(s,o),{anchor:n,focus:o}}function re(t,e){const i=t.prev(),n=t.next();if(i.isText&&n.isText){const e=t.parent();D(e),t.remove(),e.get(0).normalize()}else if(0===i.length&&0===n.length){if(t.parent().isMark&&e){const i=new E(document.createTextNode("​"));t.before(i),e.setStartAfter(i),e.collapseToStart()}t.remove()}else t.remove()}function ae(t,e){const i=e.anchor,n=e.focus;if(i.length>0&&0===n.length)re(i);else{if(n.length>0&&0===i.length){if(n.isBox){const e=new Yt(n);0===e.getContainer().length&&e.render();const i=n.attr("focus");return"start"===i?t.selectBoxStart(n):"center"===i?t.selectBox(n):t.selectBoxEnd(n),void n.removeAttr("focus")}return t.setStartBefore(n),t.collapseToStart(),void re(n,t)}if(i.length>0&&n.length>0){const e=new L;e.selectNode(i),e.collapseToEnd(),-1===e.compareAfterNode(n)?(t.setStartBefore(n),re(n),t.setEndBefore(i),re(i)):(t.setStartBefore(i),re(i),t.setEndBefore(n),re(n))}}}function le(t){if(t.commonAncestor.isOutside)return;V(t.getBlocks())}function ce(t){if(t.isCollapsed)return;if(t.adapt(),t.isInoperative)return;const e=t.startNode.closestBlock(),i=t.endNode.closestBlock(),n=e.get(0)===i.get(0);if(t.get().deleteContents(),t.adaptBlock(),n){const e=t.getBlocks()[0];return void(e&&e.isEmpty&&(P(e,I("<br />")),t.shrinkAfter(e)))}const s=t.getBlocks()[0];if(!s)return;const o=s.prev();if(0===o.length)return;const r=oe(t);Z(o,s),ae(t,r),le(t)}function he(t,e){if(t.commonAncestor.isOutside)return;t.isCollapsed?t.adaptBox():ce(t);O(t.startNode.closestBlock());const i=oe(t);i.focus.before(e),ae(t,i),t.adaptBlock()}function de(t,e){const i=I(e),n=document.createDocumentFragment();i.each((t=>{n.appendChild(t)})),he(t,n)}function pe(t,e){if(t.commonAncestor.isOutside)return;if(t.isCollapsed&&t.isBox)return;if("string"!=typeof e){const i=t.getBlocks();for(const t of i)t.css(e);return}const i=I(e),n=i.name,s=i.get(0).attributes,o=t.getBlocks();if(o.length>0){const e=oe(t);for(const t of o)if(t.name===n&&0===i.first().length)for(const e of s)t.attr(e.name,e.value);else{const e=i.clone(!0);t.isList&&""!==t.attr("indent")&&e.attr("indent",t.attr("indent"));const n=N(e);let s=t.first();for(;s.length>0;){const t=s.next();n.append(s),n.name!==s.name&&"li"!==s.name||s.remove(!0),s=t}t.replaceWith(e)}return ae(t,e),void le(t)}const r=oe(t),a=function(t){const e=t.commonAncestor.closest('div[contenteditable="true"],td');let i=[];if(0===e.length)return i;let n=e.first(),s=!0;for(;n.length>0;){if(n.isMark||n.isText||n.isBookmark||n.isInlineBox)i.push(n);else{if(!s)break;i=[]}t.intersectsNode(n)&&(s=!1),n=n.next()}return i}(t),l=H(a,i);ae(t,r),le(t),l.isEmpty&&(P(l,I("<br />")),t.shrinkAfter(l))}function ue(t){if(t.commonAncestor.isOutside)return{start:null,end:null};t.isCollapsed?t.adaptBox():ce(t);const e=t.startNode,i=e.closestOperableBlock();if(0===i.length)return{start:null,end:null};let n=i.parent();n.isOutside&&(n=e.closestContainer());const s=M(e,t.startOffset,n);let o=null,r=null;return s&&(o=s.start,r=s.end),!s&&e.isBlock&&(t.startOffset>0&&(o=e.children()[t.startOffset-1]),r=e.children()[t.startOffset],r&&!r.isBlock&&(r=null)),o&&o.isEmpty&&P(o,I("<br />")),r&&(r.isEmpty?(P(r,I("<br />")),t.shrinkAfter(r)):t.shrinkBefore(r)),le(t),{start:o,end:r}}function me(t){if(t.isMark&&t.isEmpty)t.remove();else for(const e of t.getWalker())e.isMark&&e.isEmpty&&e.remove()}function fe(t,e,i){let n=null,s=null,o=t.closestBlock();0===o.length&&(o=t.closestContainer());const r=M(t,e,o);return r&&(i?(me(r.start),me(r.end),r.start.isEmpty||(n=r.start),r.end.isEmpty||(s=r.end)):(n=r.start,s=r.end)),{start:n,end:s}}function ge(t,e=!0){if(t.commonAncestor.isOutside)return{start:null,center:null,end:null};if(t.adaptBox(),t.isCollapsed){const i=fe(t.startNode,t.startOffset,e);return i.start?(t.setStartAfter(i.start),t.collapseToStart()):i.end&&(t.setStartBefore(i.end),t.collapseToStart()),{start:i.start,center:null,end:i.end}}const i=fe(t.startNode,t.startOffset,e);i.start?t.setStartAfter(i.start):i.end&&t.setStartBefore(i.end);const n=fe(t.endNode,t.endOffset,e);return n.start?t.setEndAfter(n.start):n.end&&t.setEndBefore(n.end),{start:i.start,center:n.start,end:n.end}}function ve(t,e){const i=t.text();let n=t;for(;n.length>0;){const t=n.parent();if(!t.isMark||i!==t.text()||!n.isText&&n.name===e&&""!==n.attr("style"))break;n=t}return n}function ye(t,e){if(t.commonAncestor.isOutside)return;let i=I(e);const n=i.name,s=p(i.attr("style"));if(t.isCollapsed){if(t.isBox){const e=t.startNode.closest("lake-box");if("block"===new Yt(e).type){const i=I("<p><br /></p>");t.isBoxStart?e.before(i):e.after(i),t.shrinkAfter(i)}else t.adaptBox()}O(t.startNode.closestBlock());const e=new E(document.createTextNode("​")),o=ge(t);if(o.start){const t=function(t){if(!t.isMark)return null;let e=t.clone(),i=t.last();for(;i.length>0;){if(i.isMark){const t=i.clone();e.append(t),e=t}i=i.last()}return e}(o.start);t&&(t.name===n?(t.css(s),i=t):(P(t,e),i.append(t)))}return""===i.text()&&i.append(e),se(t,i),function(t){const e=t.prev();e.length>0&&e.isText&&e.isEmpty&&e.remove();const i=t.next();i.length>0&&i.isText&&i.isEmpty&&i.remove()}(i),void t.shrinkAfter(i)}ge(t);const o=t.getMarks(!0),r=oe(t);for(const t of o)if(!t.isEmpty&&t.isText){const e=ve(t,n);if(e.isMark&&e.name===n)e.css(s);else{const t=i.clone();e.before(t),t.append(e)}}ae(t,r)}function we(t){if(t.isMark&&t.isEmpty)t.remove();else for(const e of t.getWalker())e.isMark&&e.isEmpty&&e.remove()}function xe(t,e){if(t.commonAncestor.isOutside)return;let i;if(e){i=I(e).name}if(t.isCollapsed){if(t.isBox)return;if(i&&0===t.commonAncestor.closest(i).length)return;const e=ge(t,!1);if(!e.start)return;e.end&&we(e.end);const n=new E(document.createTextNode("​")),s=function(t,e){if(!t.isMark||!e)return null;let i=t.clone(),n=t.last();for(;n.length>0;){if(n.isMark&&n.name!==e){const t=n.clone();i.append(t),i=t}n=n.last()}if(i.name===e){if(!(i.first().length>0))return null;i=i.first()}return i}(e.start,i);return s?(P(s,n),e.start.after(s),we(e.start),void t.shrinkAfter(s)):(e.start.after(n),we(e.start),n.prev().isText?(t.setStartAfter(n.prev()),t.collapseToStart(),void n.remove()):(t.setStartAfter(n),void t.collapseToStart()))}ge(t);const n=t.getMarks(),s=oe(t);for(const t of n)if(!i||t.name===i){const e=t.parent();t.remove(!t.isEmpty),e.length>0&&e.get(0).normalize()}D(t.commonAncestor),ae(t,s)}function be(t,e){if(t.commonAncestor.isOutside)return null;const i=I(e);if(t.isCollapsed){let e=t.commonAncestor.closest("a");if(0===e.length){e=i.clone(!0);return O(t.startNode.closestBlock()),se(t,e),e}return""!==i.attr("href")&&e.attr({href:i.attr("href")}),e}ge(t);const n=oe(t);for(const e of t.commonAncestor.getWalker())"a"===e.name&&t.intersectsNode(e)&&e.remove(!0);const s=i.clone(!1);n.anchor.after(s);let o=s.next();for(;o.length>0;){const t=o.next();if(!o.isMark&&!o.isText)break;s.append(o),o=t}return 0===s.first().length&&s.remove(),ae(t,n),s}class ke{constructor(t){this.config=t,this.root=t.root,this.node=I(a`
5
+ `;class Yt{constructor(t){if(this.event=new qt,"string"==typeof t){const e=Kt.get(t);if(void 0===e)throw new Error(`Box '${t}' has not been defined yet.`);const i=r(e.type),n=r(e.name);this.node=I(a`<lake-box type="${i}" name="${n}"></lake-box>`),e.value&&(this.value=e.value)}else{this.node=I(t);const e=Kt.get(this.name);if(void 0===e)throw new Error(`Box '${this.name}' has not been defined yet.`);e.value&&!this.node.hasAttr("value")&&(this.value=e.value)}Xt[this.node.id]||(Xt[this.node.id]={}),Jt[this.node.id]||(Jt[this.node.id]={setup:[],cleanup:[]})}addFramework(){let t=this.getContainer();0===t.length?(this.node.html(Qt),t=this.getContainer()):(t.off("mouseenter"),t.off("mouseleave"),t.off("click")),t.on("mousedown",(t=>{t.preventDefault()})),t.on("mouseenter",(()=>{t.hasClass("lake-box-selected")||t.hasClass("lake-box-focused")||t.hasClass("lake-box-activated")||t.addClass("lake-box-hovered")})),t.on("mouseleave",(()=>{t.removeClass("lake-box-hovered")})),t.on("click",(()=>{A(`Box '${this.name}' (id = ${this.node.id}) value:`),A(this.value)}))}get type(){return this.node.attr("type")}get name(){return this.node.attr("name")}get value(){const t=this.node.attr("value");return""===t?{}:JSON.parse(jt(t))}set value(t){this.node.attr("value",Ft(JSON.stringify(t)))}updateValue(t,e){const i=this.value;"string"==typeof t?i[t]=e:g(t,((t,e)=>{i[t]=e})),this.value=i}getData(t){return Xt[this.node.id][t]}setData(t,e){Xt[this.node.id][t]=e}getEditor(){const t=this.node.closest("div[contenteditable]");return t.length>0?Gt.get(t.id):void 0}getContainer(){return this.node.find(".lake-box-container")}useEffect(t){Jt[this.node.id].setup.push(t)}render(){Jt[this.node.id].setup=[],Jt[this.node.id].cleanup=[];const t=Kt.get(this.name);if(void 0===t)return;this.addFramework();const e=t.render(this);if(void 0!==e){const t=this.getContainer(),i=t.clone(!1);i.append(e),ht(t,i)}for(const t of Jt[this.node.id].setup){const e=t();void 0!==e&&Jt[this.node.id].cleanup.push(e)}A(`Box '${this.name}' (id = ${this.node.id}) rendered`)}unmount(){for(const t of Jt[this.node.id].cleanup)t();Xt[this.node.id]={},Jt[this.node.id].setup=[],Jt[this.node.id].cleanup=[],this.node.empty(),A(`Box '${this.name}' (id = ${this.node.id}) unmounted`)}getHTML(){const t=Kt.get(this.name);return void 0===t?"":void 0===t.html?this.node.outerHTML():t.html(this)}}const te={id:/^[\w-]+$/,class:/^[\w-]+$/,style:{"text-align":["left","center","right","justify","start","end"],"margin-left":/^-?\d+px$/i,"text-indent":/^-?\d+em$/i}};function ee(){return{h1:Object.assign({},te),h2:Object.assign({},te),h3:Object.assign({},te),h4:Object.assign({},te),h5:Object.assign({},te),h6:Object.assign({},te),p:Object.assign({},te),blockquote:Object.assign(Object.assign({},te),{type:["info","tip","success","warning","error","danger"]}),ul:Object.assign(Object.assign({},te),{type:"checklist",indent:/^\d+$/}),ol:Object.assign(Object.assign({},te),{start:/^\d+$/,indent:/^\d+$/}),li:{value:["true","false"]},table:{style:{width:/^-?\d+(px|%)$/i,height:/^-?\d+(px|%)$/i,border:/^[^"]+$/,"border-width":/^-?\d+px$/i,"border-style":/^[\w-]+$/,"border-color":/^[^"]+$/,"background-color":/^[^"]+$/}},tr:{style:{height:/^-?\d+(px|%)$/i}},th:"td",td:{colspan:/^\d+$/,rowspan:/^\d+$/,style:{width:/^-?\d+(px|%)$/i,height:/^-?\d+(px|%)$/i,border:/^[^"]+$/,"border-width":/^-?\d+px$/i,"border-style":/^[\w-]+$/,"border-color":/^[^"]+$/,"background-color":/^[^"]+$/,"text-align":["left","center","right","justify"]}},"lake-box":{type:["inline","block"],name:/^[\w-]+$/,value:/^[^"]+$/,focus:["start","center","end"]},br:{},hr:{},img:{src:/^[^"]+$/,width:/^-?\d+px$/i,height:/^-?\d+px$/i,"data-lake-value":/^[^"]+$/,alt:/^[^"]+$/,style:{width:/^-?\d+px$/i,height:/^-?\d+px$/i}},span:{class:/^[\w-]+$/,style:{color:/^[^"]+$/,"background-color":/^[^"]+$/,"font-family":/^[^;]+$/,"font-size":/^[^"]+$/}},b:"strong",strong:{},em:"i",i:{},u:{},s:{},sub:{},sup:{},code:{},a:{class:/^[\w-]+$/,name:/^[\w-]+$/,href:/^[^"]+$/,target:/^[\w-]+$/,rel:/^[^"]+$/,download:/^[^"]+$/},"lake-bookmark":{type:["anchor","focus"]}}}class ie{constructor(t,e=ee()){this.rules=e,this.source="string"==typeof t?this.parseHTML(t):t}parseHTML(t){const e=(new DOMParser).parseFromString(t,"text/html");return new E(e.querySelector("body"))}static matchRule(t,e){return"string"==typeof t?t===e:Array.isArray(t)?t.indexOf(e)>=0:t instanceof RegExp&&t.test(e)}static getOpenTagString(t,e){let i=t.name,n=e[i];if(!n)return"";"string"==typeof n&&(i=n,n=e[i]);const s=t.get(0);if(!s.hasAttributes())return i;const o=new Map;for(const t of s.attributes)if(n[t.name]&&("style"!==t.name&&ie.matchRule(n[t.name],t.value)&&o.set(t.name,t.value),"style"===t.name)){const e=n.style,i=new Map;g(p(t.value),((t,n)=>{e[t]&&ie.matchRule(e[t],n)&&i.set(t,n)})),o.set("style",i)}let r=i;for(const[t,e]of o)if("style"===t){let t="";for(const[i,n]of e)t+=`${i}: ${n.replace(/"/g,"&quot;")}; `;""!==t&&(r+=` style="${t.trim()}"`)}else r+=` ${t}="${e}"`;return r}static getClosedTagString(t,e){let i=t.name;const n=e[i];return n?("string"==typeof n&&(i=n),i):""}static getTrimmedText(t){const e=t.parent(),i=t.prev(),n=t.next();let s=t.text();return(i.isBlock||i.isBlockBox)&&(n.isBlock||n.isBlockBox)||0===i.length&&0===n.length&&e.isBlock?s=s.replace(/^[\u0020\t\r\n]+|[\u0020\t\r\n]+$/g,""):i.isBlock||i.isBlockBox||0===i.length&&e.isBlock?s=s.replace(/^[\u0020\t\r\n]+/,""):(n.isBlock||n.isBlockBox||0===n.length&&e.isBlock)&&(s=s.replace(/[\u0020\t\r\n]+$/,"")),s}getHTML(){const t=this.rules;let e="";for(const i of function*e(i){let n=i.first();for(;n.length>0;){const i=n.next();if(n.isText)yield r(ie.getTrimmedText(n));else if(n.isVoid){const e=ie.getOpenTagString(n,t);""!==e&&(yield`<${e} />`)}else if(n.isElement){const i=ie.getOpenTagString(n,t),s=ie.getClosedTagString(n,t);""!==i&&(yield`<${i}>`),n.isBox||(yield*e(n)),""!==s&&(yield`</${s}>`)}n=i}}(this.source))e+=i;return e.trim()}getNodeList(){const t=this.getHTML();return this.parseHTML(t).children()}getFragment(){const t=this.getHTML(),e=this.parseHTML(t),i=document.createDocumentFragment();let n=e.first();for(;n.length>0;){const t=n.next();i.appendChild(n.get(0)),n=t}return i}}class ne{constructor(t){this.content=t}getHTML(){let t=this.content;return t=t.replace(/ {2}/g,"  "),t=r(t.trim()),t=`<p>${t}</p>`,t=t.replace(/(\r\n){2,}/g,"</p><p><br /></p><p>"),t=t.replace(/\r\n/g,"</p><p>"),t=t.replace(/[\r\n]{2,}/g,"</p><p><br /></p><p>"),t=t.replace(/[\r\n]/g,"</p><p>"),t}getFragment(){return new ie(this.getHTML()).getFragment()}}function se(t,e){if(t.commonAncestor.isOutside)return;const i=(e=I(e)).get(0),n=t.get();n.insertNode(i),n.setEndAfter(i),n.collapse(!1)}function oe(t){if(t.commonAncestor.isOutside)return{anchor:new E,focus:new E};const e=t.startNode.closest("lake-box");if(e.length>0)return t.isBoxStart?e.attr("focus","start"):t.isBoxEnd?e.attr("focus","end"):e.attr("focus","center"),{anchor:new E,focus:e};if(t.isCollapsed){const e=t.clone();e.collapseToEnd();const i=I('<lake-bookmark type="focus" />');return se(e,i),{anchor:new E,focus:i}}const i=t.clone();i.collapseToStart();const n=I('<lake-bookmark type="anchor" />');se(i,n);const s=t.clone();s.collapseToEnd();const o=I('<lake-bookmark type="focus" />');return se(s,o),{anchor:n,focus:o}}function re(t,e){const i=t.prev(),n=t.next();if(i.isText&&n.isText){const e=t.parent();D(e),t.remove(),e.get(0).normalize()}else if(0===i.length&&0===n.length){if(t.parent().isMark&&e){const i=new E(document.createTextNode("​"));t.before(i),e.setStartAfter(i),e.collapseToStart()}t.remove()}else t.remove()}function ae(t,e){const i=e.anchor,n=e.focus;if(i.length>0&&0===n.length)re(i);else{if(n.length>0&&0===i.length){if(n.isBox){const e=new Yt(n);0===e.getContainer().length&&e.render();const i=n.attr("focus");return"start"===i?t.selectBoxStart(n):"center"===i?t.selectBox(n):t.selectBoxEnd(n),void n.removeAttr("focus")}return t.setStartBefore(n),t.collapseToStart(),void re(n,t)}if(i.length>0&&n.length>0){const e=new L;e.selectNode(i),e.collapseToEnd(),-1===e.compareAfterNode(n)?(t.setStartBefore(n),re(n),t.setEndBefore(i),re(i)):(t.setStartBefore(i),re(i),t.setEndBefore(n),re(n))}}}function le(t){if(t.commonAncestor.isOutside)return;V(t.getBlocks())}function ce(t){if(t.isCollapsed)return;if(t.adaptBox(),t.adaptTable(),t.isInoperative)return;const e=t.startNode.closestBlock(),i=t.endNode.closestBlock(),n=e.get(0)===i.get(0);if(t.get().deleteContents(),t.adaptBlock(),n){const e=t.getBlocks()[0];return void(e&&e.isEmpty&&(P(e,I("<br />")),t.shrinkAfter(e)))}const s=t.getBlocks()[0];if(!s)return;const o=s.prev();if(0===o.length)return;const r=oe(t);Z(o,s),ae(t,r),le(t)}function he(t,e){if(t.commonAncestor.isOutside)return;t.isCollapsed?t.adaptBox():ce(t);O(t.startNode.closestBlock());const i=oe(t);i.focus.before(e),ae(t,i),t.adaptBlock()}function de(t,e){const i=I(e),n=document.createDocumentFragment();i.each((t=>{n.appendChild(t)})),he(t,n)}function pe(t,e){if(t.commonAncestor.isOutside)return;if(t.isCollapsed&&t.isBox)return;if("string"!=typeof e){const i=t.getBlocks();for(const t of i)t.css(e);return}const i=I(e),n=i.name,s=i.get(0).attributes,o=t.getBlocks();if(o.length>0){const e=oe(t);for(const t of o)if(t.name===n&&0===i.first().length)for(const e of s)t.attr(e.name,e.value);else{const e=i.clone(!0);t.isList&&""!==t.attr("indent")&&e.attr("indent",t.attr("indent"));const n=N(e);let s=t.first();for(;s.length>0;){const t=s.next();n.append(s),n.name!==s.name&&"li"!==s.name||s.remove(!0),s=t}t.replaceWith(e)}return ae(t,e),void le(t)}const r=oe(t),a=function(t){const e=t.commonAncestor.closest('div[contenteditable="true"],td');let i=[];if(0===e.length)return i;let n=e.first(),s=!0;for(;n.length>0;){if(n.isMark||n.isText||n.isBookmark||n.isInlineBox)i.push(n);else{if(!s)break;i=[]}t.intersectsNode(n)&&(s=!1),n=n.next()}return i}(t),l=H(a,i);ae(t,r),le(t),l.isEmpty&&(P(l,I("<br />")),t.shrinkAfter(l))}function ue(t){if(t.commonAncestor.isOutside)return{start:null,end:null};t.isCollapsed?t.adaptBox():ce(t);const e=t.startNode,i=e.closestOperableBlock();if(0===i.length)return{start:null,end:null};let n=i.parent();n.isOutside&&(n=e.closestContainer());const s=M(e,t.startOffset,n);let o=null,r=null;return s&&(o=s.start,r=s.end),!s&&e.isBlock&&(t.startOffset>0&&(o=e.children()[t.startOffset-1]),r=e.children()[t.startOffset],r&&!r.isBlock&&(r=null)),o&&o.isEmpty&&P(o,I("<br />")),r&&(r.isEmpty?(P(r,I("<br />")),t.shrinkAfter(r)):t.shrinkBefore(r)),le(t),{start:o,end:r}}function me(t){if(t.isMark&&t.isEmpty)t.remove();else for(const e of t.getWalker())e.isMark&&e.isEmpty&&e.remove()}function fe(t,e,i){let n=null,s=null,o=t.closestBlock();0===o.length&&(o=t.closestContainer());const r=M(t,e,o);return r&&(i?(me(r.start),me(r.end),r.start.isEmpty||(n=r.start),r.end.isEmpty||(s=r.end)):(n=r.start,s=r.end)),{start:n,end:s}}function ge(t,e=!0){if(t.commonAncestor.isOutside)return{start:null,center:null,end:null};if(t.adaptBox(),t.isCollapsed){const i=fe(t.startNode,t.startOffset,e);return i.start?(t.setStartAfter(i.start),t.collapseToStart()):i.end&&(t.setStartBefore(i.end),t.collapseToStart()),{start:i.start,center:null,end:i.end}}const i=fe(t.startNode,t.startOffset,e);i.start?t.setStartAfter(i.start):i.end&&t.setStartBefore(i.end);const n=fe(t.endNode,t.endOffset,e);return n.start?t.setEndAfter(n.start):n.end&&t.setEndBefore(n.end),{start:i.start,center:n.start,end:n.end}}function ve(t,e){const i=t.text();let n=t;for(;n.length>0;){const t=n.parent();if(!t.isMark||i!==t.text()||!n.isText&&n.name===e&&""!==n.attr("style"))break;n=t}return n}function ye(t,e){if(t.commonAncestor.isOutside)return;let i=I(e);const n=i.name,s=p(i.attr("style"));if(t.isCollapsed){if(t.isBox){const e=t.startNode.closest("lake-box");if("block"===new Yt(e).type){const i=I("<p><br /></p>");t.isBoxStart?e.before(i):e.after(i),t.shrinkAfter(i)}else t.adaptBox()}O(t.startNode.closestBlock());const e=new E(document.createTextNode("​")),o=ge(t);if(o.start){const t=function(t){if(!t.isMark)return null;let e=t.clone(),i=t.last();for(;i.length>0;){if(i.isMark){const t=i.clone();e.append(t),e=t}i=i.last()}return e}(o.start);t&&(t.name===n?(t.css(s),i=t):(P(t,e),i.append(t)))}return""===i.text()&&i.append(e),se(t,i),function(t){const e=t.prev();e.length>0&&e.isText&&e.isEmpty&&e.remove();const i=t.next();i.length>0&&i.isText&&i.isEmpty&&i.remove()}(i),void t.shrinkAfter(i)}ge(t);const o=t.getMarks(!0),r=oe(t);for(const t of o)if(!t.isEmpty&&t.isText){const e=ve(t,n);if(e.isMark&&e.name===n)e.css(s);else{const t=i.clone();e.before(t),t.append(e)}}ae(t,r)}function we(t){if(t.isMark&&t.isEmpty)t.remove();else for(const e of t.getWalker())e.isMark&&e.isEmpty&&e.remove()}function xe(t,e){if(t.commonAncestor.isOutside)return;let i;if(e){i=I(e).name}if(t.isCollapsed){if(t.isBox)return;if(i&&0===t.commonAncestor.closest(i).length)return;const e=ge(t,!1);if(!e.start)return;e.end&&we(e.end);const n=new E(document.createTextNode("​")),s=function(t,e){if(!t.isMark||!e)return null;let i=t.clone(),n=t.last();for(;n.length>0;){if(n.isMark&&n.name!==e){const t=n.clone();i.append(t),i=t}n=n.last()}if(i.name===e){if(!(i.first().length>0))return null;i=i.first()}return i}(e.start,i);return s?(P(s,n),e.start.after(s),we(e.start),void t.shrinkAfter(s)):(e.start.after(n),we(e.start),n.prev().isText?(t.setStartAfter(n.prev()),t.collapseToStart(),void n.remove()):(t.setStartAfter(n),void t.collapseToStart()))}ge(t);const n=t.getMarks(),s=oe(t);for(const t of n)if(!i||t.name===i){const e=t.parent();t.remove(!t.isEmpty),e.length>0&&e.get(0).normalize()}D(t.commonAncestor),ae(t,s)}function be(t,e){if(t.commonAncestor.isOutside)return null;const i=I(e);if(t.isCollapsed){let e=t.commonAncestor.closest("a");if(0===e.length){e=i.clone(!0);return O(t.startNode.closestBlock()),se(t,e),e}return""!==i.attr("href")&&e.attr({href:i.attr("href")}),e}ge(t);const n=oe(t);for(const e of t.commonAncestor.getWalker())"a"===e.name&&t.intersectsNode(e)&&e.remove(!0);const s=i.clone(!1);n.anchor.after(s);let o=s.next();for(;o.length>0;){const t=o.next();if(!o.isMark&&!o.isText)break;s.append(o),o=t}return 0===s.first().length&&s.remove(),ae(t,n),s}class ke{constructor(t){this.config=t,this.root=t.root,this.node=I(a`
6
6
  <button type="button" name="${t.name}" class="lake-button" />
7
7
  `),void 0!==t.tabIndex&&this.node.attr("tabindex",t.tabIndex.toString())}render(){const t=this.config,e=this.node;e.addClass(`lake-${t.text?"text":"icon"}-button`),t.tooltip&&e.attr("title",t.tooltip),t.icon&&e.append(t.icon),t.text&&e.append(`<span>${t.text}</span>`),this.root.append(e),e.on("mouseenter",(()=>{e.attr("disabled")||e.hasClass("lake-button-selected")||e.addClass("lake-button-hovered")})),e.on("mouseleave",(()=>{e.attr("disabled")||e.removeClass("lake-button-hovered")})),e.on("click",(e=>{e.preventDefault(),t.onClick()}))}}const _e=/^\{.*\}$/,Se=/(\{(?:[^{}]+|\{(?:[^{}]+)*\})*\})/g,Ce=t=>t.substring(1,t.length-1),Ae=(t,e=!0,i="",n="")=>t.split(Se).map((t=>{if(!t.match(Se))return t;const e=Ce(t);if(e.startsWith("{"))return((t,e)=>{let[i,n]=t.split(":");n||(n=i,i=e);const s=n.split("|"),[o,r,a,l,c,h]=s,d=s.filter((t=>void 0!==t)).length;return 1===d?{k:i,r:o}:2===d?{k:i,o:o,r:r}:3===d?{k:i,z:o,o:r,r:a}:{k:i,z:o,o:r,t:a,f:l,m:c,r:h}})(Ce(e),n);const s=(t=>{const[e="",...i]=t.split("|"),[n="",s]=e.split(":"),[o,r]=n.split("?");return{k:o,i:s,n:""===r,f:i}})(e);return n=s.k||n,!i&&(i=n),s})).map((t=>{if("string"==typeof t)return t;t.k||(t.k=i||"0");const n=(t=>Object.fromEntries(Object.keys(t).map((e=>{const i=t[e];return[e,Array.isArray(i)?i.map((t=>null==t?void 0:t.trim())):i===!!i?i:null==i?void 0:i.trim()]}))))(t);return e?(s=n,Object.fromEntries(Object.entries(s).map((([t,e])=>"i"!==t&&e&&"0"!=e&&[t,e])).filter(Boolean))):n;var s})),Be=(t,e,i)=>e.reduce(((e,i)=>{var n,s,o;return null!==(s=i.match(_e)?(t=>{var i;return null!==(i=t[e])&&void 0!==i?i:t["*"]})((o=i,Object.fromEntries(Ce(o).split(",").map((t=>t.split(":"))).reduce(((t,e)=>2===e.length?[...t,e.map((t=>t.trim()))]:(t[t.length-1][1]+=","+e[0],t)),[])))):null===(n=t[i])||void 0===n?void 0:n.call(t,e))&&void 0!==s?s:e}),i),Te=/\?\?/g,Ee=(t,e,i,n)=>{const s=n[0],o=s&&"object"==typeof s&&s.constructor===Object;return((t,e,i,n)=>t.map((t=>{if("string"==typeof t)return t;const{k:s="0",f:o=[]}=t,r=n[s];if((t=>!(!t.o&&!t.r))(t))return(("boolean"==typeof r?r?t.o:t.r:((t,{z:e,o:i,t:n,f:s,m:o,r:r},a)=>{switch(e&&0==a?"zero":t.select(a)){case"zero":return e;case"one":return i;case"two":return n;case"few":return null!=s?s:r;case"many":return null!=o?o:r;default:return r}})(e,t,r))||"").replace(Te,r);const a=o.length?Be(i,o,r):r;return(""+(null!=a?a:"")).trim()})).join(""))(t,e,i,1===n.length&&o?s:n)},Ie=(t,e)=>{const i={},n=new Intl.PluralRules(t);return(t,...s)=>Ee(((t,e)=>t[e]||(t[e]=Ae(e)))(i,t),n,e,s)};const Le=(t={},e)=>"string"==typeof t?e.bind(null,t):Object.assign(Object.defineProperty((()=>""),"name",{writable:!0}),t),Me=(t,e)=>new Proxy(Le(t,e),{get:(t,i)=>i===Symbol.iterator?[][Symbol.iterator].bind(Object.values(t).map((t=>Le(t,e)))):Me(t[i],e)});const Pe={"en-US":{toolbar:{undo:`Undo (${f("mod+Z")})`,redo:`Redo (${f("mod+Y")})`,selectAll:`Select all (${f("mod+A")})`,paragraph:"Paragraph",blockQuote:"Block quotation",numberedList:"Numbered list",bulletedList:"Bulleted list",checklist:"Checklist",alignLeft:"Align left",alignCenter:"Align center",alignRight:"Align right",alignJustify:"Align justify",increaseIndent:"Increase indent",decreaseIndent:"Decrease indent",bold:`Bold (${f("mod+B")})`,italic:`Italic (${f("mod+I")})`,underline:`Underline (${f("mod+U")})`,strikethrough:"Strikethrough",superscript:"Superscript",subscript:"Subscript",code:"Inline code",removeFormat:"Remove format",formatPainter:"Format painter",link:"Link",hr:"Horizontal line",codeBlock:"Code block",heading:"Heading",heading1:"Heading 1",heading2:"Heading 2",heading3:"Heading 3",heading4:"Heading 4",heading5:"Heading 5",heading6:"Heading 6",list:"List",align:"Alignment",indent:"Indent",fontFamily:"Font family",fontSize:"Font size",moreStyle:"More style",fontColor:"Font color",highlight:"Highlight",image:"Image",removeColor:"Remove color"},link:{newLink:"New link",url:"Link URL",title:"Link title",copy:"Copy link to clipboard",open:"Open link in new tab",save:"Save",unlink:"Remove link"},image:{view:"Full screen",remove:"Delete",previous:"Previous",next:"Next",close:"Close (Esc)",loadingError:"The image cannot be loaded",zoomOut:"Zoom out",zoomIn:"Zoom in"},codeBlock:{langType:"Select language"}},"zh-CN":{toolbar:{undo:`撤消 (${f("mod+Z")})`,redo:`重做 (${f("mod+Y")})`,selectAll:`全选 (${f("mod+A")})`,paragraph:"正文",blockQuote:"引用",numberedList:"编号",bulletedList:"项目符号",checklist:"任务列表",alignLeft:"左对齐",alignCenter:"居中",alignRight:"右对齐",alignJustify:"两端对齐",increaseIndent:"增加缩进",decreaseIndent:"减少缩进",bold:`粗体 (${f("mod+B")})`,italic:`斜体 (${f("mod+I")})`,underline:`下划线 (${f("mod+U")})`,strikethrough:"删除线",superscript:"上标",subscript:"下标",code:"行内代码",removeFormat:"清除格式",formatPainter:"格式刷",link:"链接",hr:"分割线",codeBlock:"代码块",heading:"标题",heading1:"标题 1",heading2:"标题 2",heading3:"标题 3",heading4:"标题 4",heading5:"标题 5",heading6:"标题 6",list:"列表",align:"对齐方式",indent:"缩进",fontFamily:"字体",fontSize:"文字大小",moreStyle:"更多样式",fontColor:"文字颜色",highlight:"文字背景",image:"图片",removeColor:"默认"},link:{newLink:"新链接",url:"链接 URL",title:"链接文本",copy:"复制到剪贴板",open:"打开链接",save:"确定",unlink:"取消链接"},image:{view:"查看大图",remove:"删除",previous:"上一张",next:"下一张",close:"关闭 (Esc)",loadingError:"图片加载失败",zoomOut:"缩小",zoomIn:"放大"},codeBlock:{langType:"选择代码语言"}},ja:{toolbar:{undo:`元に戻す (${f("mod+Z")})`,redo:`やり直し (${f("mod+Y")})`,selectAll:`すべて選択 (${f("mod+A")})`,paragraph:"テキスト",blockQuote:"ブロック引用",numberedList:"番号付きリスト",bulletedList:"箇条書きリスト",checklist:"タスクリスト",alignLeft:"左揃え",alignCenter:"中心揃え",alignRight:"右揃え",alignJustify:"左右に並べ替え",increaseIndent:"インデントを増やす",decreaseIndent:"インデントを減らす",bold:`太字 (${f("mod+B")})`,italic:`斜体 (${f("mod+I")})`,underline:`下線 (${f("mod+U")})`,strikethrough:"取り消し線",superscript:"上付き文字",subscript:"下付き文字",code:"インラインコード",removeFormat:"形式を削除",formatPainter:"形式ペインタ",link:"リンク",hr:"区切り線",codeBlock:"コードブロック",heading:"タイトル",heading1:"タイトル 1",heading2:"タイトル 2",heading3:"タイトル 3",heading4:"タイトル 4",heading5:"タイトル 5",heading6:"タイトル 6",list:"リスト",align:"文字揃え",indent:"インデント",fontFamily:"フォント",fontSize:"文字サイズ",moreStyle:"その他のスタイル",fontColor:"文字色",highlight:"文字の背景",image:"画像",removeColor:"デフォルト"},link:{newLink:"新しいリンク",url:"リンク URL",title:"リンク文字",copy:"クリップボードにコピー",open:"リンクを開く",save:"確認",unlink:"リンクを削除"},image:{view:"大きな画像を見る",remove:"削除",previous:"前の画像",next:"次の画像",close:"閉じる (Esc)",loadingError:"画像を読み込めません",zoomOut:"縮小",zoomIn:"拡大"},codeBlock:{langType:"コード言語を選択"}},ko:{toolbar:{undo:`작업취소 (${f("mod+Z")})`,redo:`작업재개 (${f("mod+Y")})`,selectAll:`전체 선택 (${f("mod+A")})`,paragraph:"텍스트",blockQuote:"인용문",numberedList:"순서 목록",bulletedList:"비순서 목록",checklist:"체크리스트",alignLeft:"왼쪽 정렬",alignCenter:"가운데 정렬",alignRight:"오른쪽 정렬",alignJustify:"좌우로 정렬",increaseIndent:"들여쓰기 증가",decreaseIndent:"들여쓰기 줄이기",bold:`굵게 (${f("mod+B")})`,italic:`기울임꼴 (${f("mod+I")})`,underline:`밑줄 (${f("mod+U")})`,strikethrough:"취소선",superscript:"위첨자",subscript:"아래 첨자",code:"인라인 코드",removeFormat:"형식 지우기",formatPainter:"형식 페인터",link:"링크",hr:"구분선",codeBlock:"코드 블록",heading:"제목",heading1:"제목 1",heading2:"제목 2",heading3:"제목 3",heading4:"제목 4",heading5:"제목 5",heading6:"제목 6",list:"목록",align:"정렬",indent:"들여쓰기",fontFamily:"글꼴",fontSize:"글자 크기",moreStyle:"더 많은 스타일",fontColor:"글자 색상",highlight:"글자 배경",image:"이미지",removeColor:"기본색"},link:{newLink:"새 링크",url:"링크 URL",title:"링크 텍스트",copy:"클립보드에 복사",open:"링크 열기",save:"확인",unlink:"링크 제거"},image:{view:"큰 이미지 보기",remove:"삭제",previous:"이전 이미지",next:"다음 이미지",close:"닫기 (Esc)",loadingError:"이미지를 로드할 수 없습니다",zoomOut:"축소",zoomIn:"확대"},codeBlock:{langType:"코드언어 선택"}}},Oe=Object.keys(Pe),ze={},Ze={},Ne=t=>{ze[t]||(ze[t]=Pe[t],(t=>{Ze[t]={}})(t))},He=t=>function(t,e,i={}){return Me(e,Ie(t,i))}(t,ze[t],Ze[t]);Oe.forEach(Ne);class De{constructor(t){if(this.documentClickListener=t=>{const e=new E(t.target),i=this.node.find(".lake-dropdown-title"),n=this.node.find(".lake-dropdown-menu");e.closest(".lake-dropdown-title").get(0)!==i.get(0)&&(n.hide(),document.removeEventListener("click",this.documentClickListener))},this.config=t,this.root=t.root,this.locale=t.locale||He("en-US"),this.node=I(a`
8
8
  <div class="lake-dropdown lake-${t.menuType}-dropdown" name="${t.name}">
@@ -15,7 +15,7 @@ var Lake=function(t){"use strict";class e extends HTMLElement{}void 0!==customEl
15
15
  <li value="${r(i.value)}">
16
16
  <div class="lake-dropdown-menu-text">${o}</div>
17
17
  </li>
18
- `);if(t.append(a),"color"===e.menuType&&(a.attr("title",o),a.find(".lake-dropdown-menu-text").css("background-color",i.value)),i.icon){const t=I('<div class="lake-dropdown-menu-icon"></div>');t.append(i.icon),a.prepend(t)}const l=n.get("check");if(l){const t=I('<div class="lake-dropdown-menu-check"></div>');t.append(l),a.prepend(t)}}}showMenu(){const t=this.config,e=this.node,i=e.find(".lake-dropdown-menu");if(e.attr("disabled"))return;const n=De.getValue(e);i.find(".lake-dropdown-menu-check").css("visibility","hidden"),i.find("li").each((t=>{const e=I(t);e.on("mouseenter",(()=>{e.hasClass("lake-dropdown-item-selected")||e.addClass("lake-dropdown-item-hovered")})),e.on("mouseleave",(()=>{e.removeClass("lake-dropdown-item-hovered")})),n.indexOf(e.attr("value"))>=0&&e.find(".lake-dropdown-menu-check").css("visibility","visible")})),i.css("visibility","hidden"),i.show("color"===t.menuType?"flex":"block");e.get(0).getBoundingClientRect().x+i.width()+50>window.innerWidth?(i.css("left","auto"),i.css("right","0")):(i.css("left",""),i.css("right","")),i.css("visibility",""),document.addEventListener("click",this.documentClickListener)}bindEvents(){const t=this.config,e=this.node,i=e.find(".lake-dropdown-title"),n=i.find(".lake-dropdown-text"),s=i.find(".lake-dropdown-icon"),o=i.find(".lake-dropdown-down-icon"),r=e.find(".lake-dropdown-menu");"color"===t.menuType?(s.on("mouseenter",(()=>{e.attr("disabled")||s.addClass("lake-dropdown-icon-hovered")})),s.on("mouseleave",(()=>{s.removeClass("lake-dropdown-icon-hovered")})),o.on("mouseenter",(()=>{e.attr("disabled")||o.addClass("lake-dropdown-down-icon-hovered")})),o.on("mouseleave",(()=>{o.removeClass("lake-dropdown-down-icon-hovered")}))):(i.on("mouseenter",(()=>{e.attr("disabled")||i.addClass("lake-dropdown-title-hovered")})),i.on("mouseleave",(()=>{i.removeClass("lake-dropdown-title-hovered")}))),"color"===t.menuType&&s.on("click",(i=>{if(i.preventDefault(),e.attr("disabled"))return;const n=e.attr("color")||t.defaultValue;t.onSelect(n)}));("color"===t.menuType&&o?o:i).on("click",(t=>{t.preventDefault(),this.showMenu()})),r.on("click",(s=>{s.preventDefault();const o=I(s.target).closest("li"),a=o.attr("value");De.setValue(e,[a]),n.length>0&&n.text(o.text()),"color"===t.menuType&&""!==a&&(e.attr("color",a),this.updateColorAccent(i,a)),t.onSelect(a),r.hide(),document.removeEventListener("click",this.documentClickListener)}))}render(){var t;const e=this.config,i=this.node,n=i.find(".lake-dropdown-title");e.downIcon||n.addClass("lake-dropdown-title-no-down"),n.css("width",e.width);const s="string"==typeof e.tooltip?e.tooltip:e.tooltip(this.locale);n.attr("title",s);const o=n.find(".lake-dropdown-text"),r=n.find(".lake-dropdown-icon");e.icon&&r.append(e.icon),e.accentIcon&&r.append(e.accentIcon);const a=n.find(".lake-dropdown-down-icon");e.downIcon&&a.append(e.downIcon);const l=I('<ul class="lake-dropdown-menu" />');if(l.addClass(`lake-${e.menuType}-dropdown-menu`),De.setValue(i,[e.defaultValue]),o.length>0){const i=De.getMenuMap(e.menuItems,this.locale);o.text(null!==(t=i.get(e.defaultValue))&&void 0!==t?t:e.defaultValue)}"color"===e.menuType&&this.updateColorAccent(n,e.defaultValue),this.apppendMenuItems(l),i.append(n),i.append(l),this.root.append(i),this.bindEvents()}unmount(){this.node.remove(),document.removeEventListener("click",this.documentClickListener)}}var $e=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)},Ve="object"==typeof Rt&&Rt&&Rt.Object===Object&&Rt,Fe=Ve,je="object"==typeof self&&self&&self.Object===Object&&self,Re=Fe||je||Function("return this")(),We=Re,Ue=function(){return We.Date.now()},qe=/\s/;var Ke=function(t){for(var e=t.length;e--&&qe.test(t.charAt(e)););return e},Ge=Ke,Xe=/^\s+/;var Je=function(t){return t?t.slice(0,Ge(t)+1).replace(Xe,""):t},Qe=Re.Symbol,Ye=Qe,ti=Object.prototype,ei=ti.hasOwnProperty,ii=ti.toString,ni=Ye?Ye.toStringTag:void 0;var si=function(t){var e=ei.call(t,ni),i=t[ni];try{t[ni]=void 0;var n=!0}catch(t){}var s=ii.call(t);return n&&(e?t[ni]=i:delete t[ni]),s},oi=Object.prototype.toString;var ri=si,ai=function(t){return oi.call(t)},li=Qe?Qe.toStringTag:void 0;var ci=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":li&&li in Object(t)?ri(t):ai(t)};var hi=function(t){return null!=t&&"object"==typeof t},di=ci,pi=hi;var ui=Je,mi=$e,fi=function(t){return"symbol"==typeof t||pi(t)&&"[object Symbol]"==di(t)},gi=/^[-+]0x[0-9a-f]+$/i,vi=/^0b[01]+$/i,yi=/^0o[0-7]+$/i,wi=parseInt;var xi=$e,bi=Ue,ki=function(t){if("number"==typeof t)return t;if(fi(t))return NaN;if(mi(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=mi(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=ui(t);var i=vi.test(t);return i||yi.test(t)?wi(t.slice(2),i?2:8):gi.test(t)?NaN:+t},_i=Math.max,Si=Math.min;var Ci=function(t,e,i){var n,s,o,r,a,l,c=0,h=!1,d=!1,p=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function u(e){var i=n,o=s;return n=s=void 0,c=e,r=t.apply(o,i)}function m(t){var i=t-l;return void 0===l||i>=e||i<0||d&&t-c>=o}function f(){var t=bi();if(m(t))return g(t);a=setTimeout(f,function(t){var i=e-(t-l);return d?Si(i,o-(t-c)):i}(t))}function g(t){return a=void 0,p&&n?u(t):(n=s=void 0,r)}function v(){var t=bi(),i=m(t);if(n=arguments,s=this,l=t,i){if(void 0===a)return function(t){return c=t,a=setTimeout(f,e),h?u(t):r}(l);if(d)return clearTimeout(a),a=setTimeout(f,e),u(l)}return void 0===a&&(a=setTimeout(f,e)),r}return e=ki(e)||0,xi(i)&&(h=!!i.leading,o=(d="maxWait"in i)?_i(ki(i.maxWait)||0,e):o,p="trailing"in i?!!i.trailing:p),v.cancel=function(){void 0!==a&&clearTimeout(a),c=0,n=l=s=a=void 0},v.flush=function(){return void 0===a?r:g(bi())},v},Ai=Wt(Ci);var Bi=function(){this.__data__=[],this.size=0};var Ti=function(t,e){return t===e||t!=t&&e!=e},Ei=Ti;var Ii=function(t,e){for(var i=t.length;i--;)if(Ei(t[i][0],e))return i;return-1},Li=Ii,Mi=Array.prototype.splice;var Pi=function(t){var e=this.__data__,i=Li(e,t);return!(i<0)&&(i==e.length-1?e.pop():Mi.call(e,i,1),--this.size,!0)},Oi=Ii;var zi=function(t){var e=this.__data__,i=Oi(e,t);return i<0?void 0:e[i][1]},Zi=Ii;var Ni=Ii;var Hi=function(t,e){var i=this.__data__,n=Ni(i,t);return n<0?(++this.size,i.push([t,e])):i[n][1]=e,this},Di=Bi,$i=Pi,Vi=zi,Fi=function(t){return Zi(this.__data__,t)>-1},ji=Hi;function Ri(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var n=t[e];this.set(n[0],n[1])}}Ri.prototype.clear=Di,Ri.prototype.delete=$i,Ri.prototype.get=Vi,Ri.prototype.has=Fi,Ri.prototype.set=ji;var Wi=Ri,Ui=Wi;var qi=function(){this.__data__=new Ui,this.size=0};var Ki=function(t){var e=this.__data__,i=e.delete(t);return this.size=e.size,i};var Gi=function(t){return this.__data__.get(t)};var Xi=function(t){return this.__data__.has(t)},Ji=ci,Qi=$e;var Yi,tn=function(t){if(!Qi(t))return!1;var e=Ji(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e},en=Re["__core-js_shared__"],nn=(Yi=/[^.]+$/.exec(en&&en.keys&&en.keys.IE_PROTO||""))?"Symbol(src)_1."+Yi:"";var sn=function(t){return!!nn&&nn in t},on=Function.prototype.toString;var rn=function(t){if(null!=t){try{return on.call(t)}catch(t){}try{return t+""}catch(t){}}return""},an=tn,ln=sn,cn=$e,hn=rn,dn=/^\[object .+?Constructor\]$/,pn=Function.prototype,un=Object.prototype,mn=pn.toString,fn=un.hasOwnProperty,gn=RegExp("^"+mn.call(fn).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var vn=function(t){return!(!cn(t)||ln(t))&&(an(t)?gn:dn).test(hn(t))},yn=function(t,e){return null==t?void 0:t[e]};var wn=function(t,e){var i=yn(t,e);return vn(i)?i:void 0},xn=wn(Re,"Map"),bn=wn(Object,"create"),kn=bn;var _n=function(){this.__data__=kn?kn(null):{},this.size=0};var Sn=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},Cn=bn,An=Object.prototype.hasOwnProperty;var Bn=function(t){var e=this.__data__;if(Cn){var i=e[t];return"__lodash_hash_undefined__"===i?void 0:i}return An.call(e,t)?e[t]:void 0},Tn=bn,En=Object.prototype.hasOwnProperty;var In=bn;var Ln=_n,Mn=Sn,Pn=Bn,On=function(t){var e=this.__data__;return Tn?void 0!==e[t]:En.call(e,t)},zn=function(t,e){var i=this.__data__;return this.size+=this.has(t)?0:1,i[t]=In&&void 0===e?"__lodash_hash_undefined__":e,this};function Zn(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var n=t[e];this.set(n[0],n[1])}}Zn.prototype.clear=Ln,Zn.prototype.delete=Mn,Zn.prototype.get=Pn,Zn.prototype.has=On,Zn.prototype.set=zn;var Nn=Zn,Hn=Wi,Dn=xn;var $n=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t};var Vn=function(t,e){var i=t.__data__;return $n(e)?i["string"==typeof e?"string":"hash"]:i.map},Fn=Vn;var jn=Vn;var Rn=Vn;var Wn=Vn;var Un=function(){this.size=0,this.__data__={hash:new Nn,map:new(Dn||Hn),string:new Nn}},qn=function(t){var e=Fn(this,t).delete(t);return this.size-=e?1:0,e},Kn=function(t){return jn(this,t).get(t)},Gn=function(t){return Rn(this,t).has(t)},Xn=function(t,e){var i=Wn(this,t),n=i.size;return i.set(t,e),this.size+=i.size==n?0:1,this};function Jn(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var n=t[e];this.set(n[0],n[1])}}Jn.prototype.clear=Un,Jn.prototype.delete=qn,Jn.prototype.get=Kn,Jn.prototype.has=Gn,Jn.prototype.set=Xn;var Qn=Jn,Yn=Wi,ts=xn,es=Qn;var is=Wi,ns=qi,ss=Ki,os=Gi,rs=Xi,as=function(t,e){var i=this.__data__;if(i instanceof Yn){var n=i.__data__;if(!ts||n.length<199)return n.push([t,e]),this.size=++i.size,this;i=this.__data__=new es(n)}return i.set(t,e),this.size=i.size,this};function ls(t){var e=this.__data__=new is(t);this.size=e.size}ls.prototype.clear=ns,ls.prototype.delete=ss,ls.prototype.get=os,ls.prototype.has=rs,ls.prototype.set=as;var cs=ls;var hs=Qn,ds=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},ps=function(t){return this.__data__.has(t)};function us(t){var e=-1,i=null==t?0:t.length;for(this.__data__=new hs;++e<i;)this.add(t[e])}us.prototype.add=us.prototype.push=ds,us.prototype.has=ps;var ms=function(t,e){for(var i=-1,n=null==t?0:t.length;++i<n;)if(e(t[i],i,t))return!0;return!1};var fs=us,gs=ms,vs=function(t,e){return t.has(e)};var ys=function(t,e,i,n,s,o){var r=1&i,a=t.length,l=e.length;if(a!=l&&!(r&&l>a))return!1;var c=o.get(t),h=o.get(e);if(c&&h)return c==e&&h==t;var d=-1,p=!0,u=2&i?new fs:void 0;for(o.set(t,e),o.set(e,t);++d<a;){var m=t[d],f=e[d];if(n)var g=r?n(f,m,d,e,t,o):n(m,f,d,t,e,o);if(void 0!==g){if(g)continue;p=!1;break}if(u){if(!gs(e,(function(t,e){if(!vs(u,e)&&(m===t||s(m,t,i,n,o)))return u.push(e)}))){p=!1;break}}else if(m!==f&&!s(m,f,i,n,o)){p=!1;break}}return o.delete(t),o.delete(e),p};var ws=function(t){var e=-1,i=Array(t.size);return t.forEach((function(t,n){i[++e]=[n,t]})),i};var xs=function(t){var e=-1,i=Array(t.size);return t.forEach((function(t){i[++e]=t})),i},bs=Re.Uint8Array,ks=Ti,_s=ys,Ss=ws,Cs=xs,As=Qe?Qe.prototype:void 0,Bs=As?As.valueOf:void 0;var Ts=function(t,e,i,n,s,o,r){switch(i){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=e.byteLength||!o(new bs(t),new bs(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return ks(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case"[object Map]":var a=Ss;case"[object Set]":var l=1&n;if(a||(a=Cs),t.size!=e.size&&!l)return!1;var c=r.get(t);if(c)return c==e;n|=2,r.set(t,e);var h=_s(a(t),a(e),n,s,o,r);return r.delete(t),h;case"[object Symbol]":if(Bs)return Bs.call(t)==Bs.call(e)}return!1};var Es=function(t,e){for(var i=-1,n=e.length,s=t.length;++i<n;)t[s+i]=e[i];return t},Is=Array.isArray,Ls=Es,Ms=Is;var Ps=function(t,e,i){var n=e(t);return Ms(t)?n:Ls(n,i(t))};var Os=function(t,e){for(var i=-1,n=null==t?0:t.length,s=0,o=[];++i<n;){var r=t[i];e(r,i,t)&&(o[s++]=r)}return o};var zs=Os,Zs=function(){return[]},Ns=Object.prototype.propertyIsEnumerable,Hs=Object.getOwnPropertySymbols,Ds=Hs?function(t){return null==t?[]:(t=Object(t),zs(Hs(t),(function(e){return Ns.call(t,e)})))}:Zs;var $s=function(t,e){for(var i=-1,n=Array(t);++i<t;)n[i]=e(i);return n},Vs=ci,Fs=hi;var js=function(t){return Fs(t)&&"[object Arguments]"==Vs(t)},Rs=hi,Ws=Object.prototype,Us=Ws.hasOwnProperty,qs=Ws.propertyIsEnumerable,Ks=js(function(){return arguments}())?js:function(t){return Rs(t)&&Us.call(t,"callee")&&!qs.call(t,"callee")},Gs=Ks,Xs={exports:{}};var Js=function(){return!1};!function(t,e){var i=Re,n=Js,s=e&&!e.nodeType&&e,o=s&&t&&!t.nodeType&&t,r=o&&o.exports===s?i.Buffer:void 0,a=(r?r.isBuffer:void 0)||n;t.exports=a}(Xs,Xs.exports);var Qs=Xs.exports,Ys=/^(?:0|[1-9]\d*)$/;var to=function(t,e){var i=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==i||"symbol"!=i&&Ys.test(t))&&t>-1&&t%1==0&&t<e};var eo=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991},io=ci,no=eo,so=hi,oo={};oo["[object Float32Array]"]=oo["[object Float64Array]"]=oo["[object Int8Array]"]=oo["[object Int16Array]"]=oo["[object Int32Array]"]=oo["[object Uint8Array]"]=oo["[object Uint8ClampedArray]"]=oo["[object Uint16Array]"]=oo["[object Uint32Array]"]=!0,oo["[object Arguments]"]=oo["[object Array]"]=oo["[object ArrayBuffer]"]=oo["[object Boolean]"]=oo["[object DataView]"]=oo["[object Date]"]=oo["[object Error]"]=oo["[object Function]"]=oo["[object Map]"]=oo["[object Number]"]=oo["[object Object]"]=oo["[object RegExp]"]=oo["[object Set]"]=oo["[object String]"]=oo["[object WeakMap]"]=!1;var ro=function(t){return so(t)&&no(t.length)&&!!oo[io(t)]};var ao=function(t){return function(e){return t(e)}},lo={exports:{}};!function(t,e){var i=Ve,n=e&&!e.nodeType&&e,s=n&&t&&!t.nodeType&&t,o=s&&s.exports===n&&i.process,r=function(){try{var t=s&&s.require&&s.require("util").types;return t||o&&o.binding&&o.binding("util")}catch(t){}}();t.exports=r}(lo,lo.exports);var co=lo.exports,ho=ro,po=ao,uo=co&&co.isTypedArray,mo=uo?po(uo):ho,fo=$s,go=Gs,vo=Is,yo=Qs,wo=to,xo=mo,bo=Object.prototype.hasOwnProperty;var ko=function(t,e){var i=vo(t),n=!i&&go(t),s=!i&&!n&&yo(t),o=!i&&!n&&!s&&xo(t),r=i||n||s||o,a=r?fo(t.length,String):[],l=a.length;for(var c in t)!e&&!bo.call(t,c)||r&&("length"==c||s&&("offset"==c||"parent"==c)||o&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||wo(c,l))||a.push(c);return a},_o=Object.prototype;var So=function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||_o)};var Co=function(t,e){return function(i){return t(e(i))}}(Object.keys,Object),Ao=So,Bo=Co,To=Object.prototype.hasOwnProperty;var Eo=tn,Io=eo;var Lo=ko,Mo=function(t){if(!Ao(t))return Bo(t);var e=[];for(var i in Object(t))To.call(t,i)&&"constructor"!=i&&e.push(i);return e},Po=function(t){return null!=t&&Io(t.length)&&!Eo(t)};var Oo=Ps,zo=Ds,Zo=function(t){return Po(t)?Lo(t):Mo(t)};var No=function(t){return Oo(t,Zo,zo)},Ho=Object.prototype.hasOwnProperty;var Do=function(t,e,i,n,s,o){var r=1&i,a=No(t),l=a.length;if(l!=No(e).length&&!r)return!1;for(var c=l;c--;){var h=a[c];if(!(r?h in e:Ho.call(e,h)))return!1}var d=o.get(t),p=o.get(e);if(d&&p)return d==e&&p==t;var u=!0;o.set(t,e),o.set(e,t);for(var m=r;++c<l;){var f=t[h=a[c]],g=e[h];if(n)var v=r?n(g,f,h,e,t,o):n(f,g,h,t,e,o);if(!(void 0===v?f===g||s(f,g,i,n,o):v)){u=!1;break}m||(m="constructor"==h)}if(u&&!m){var y=t.constructor,w=e.constructor;y==w||!("constructor"in t)||!("constructor"in e)||"function"==typeof y&&y instanceof y&&"function"==typeof w&&w instanceof w||(u=!1)}return o.delete(t),o.delete(e),u},$o=wn(Re,"DataView"),Vo=xn,Fo=wn(Re,"Promise"),jo=wn(Re,"Set"),Ro=wn(Re,"WeakMap"),Wo=ci,Uo=rn,qo="[object Map]",Ko="[object Promise]",Go="[object Set]",Xo="[object WeakMap]",Jo="[object DataView]",Qo=Uo($o),Yo=Uo(Vo),tr=Uo(Fo),er=Uo(jo),ir=Uo(Ro),nr=Wo;($o&&nr(new $o(new ArrayBuffer(1)))!=Jo||Vo&&nr(new Vo)!=qo||Fo&&nr(Fo.resolve())!=Ko||jo&&nr(new jo)!=Go||Ro&&nr(new Ro)!=Xo)&&(nr=function(t){var e=Wo(t),i="[object Object]"==e?t.constructor:void 0,n=i?Uo(i):"";if(n)switch(n){case Qo:return Jo;case Yo:return qo;case tr:return Ko;case er:return Go;case ir:return Xo}return e});var sr=cs,or=ys,rr=Ts,ar=Do,lr=nr,cr=Is,hr=Qs,dr=mo,pr="[object Arguments]",ur="[object Array]",mr="[object Object]",fr=Object.prototype.hasOwnProperty;var gr=function(t,e,i,n,s,o){var r=cr(t),a=cr(e),l=r?ur:lr(t),c=a?ur:lr(e),h=(l=l==pr?mr:l)==mr,d=(c=c==pr?mr:c)==mr,p=l==c;if(p&&hr(t)){if(!hr(e))return!1;r=!0,h=!1}if(p&&!h)return o||(o=new sr),r||dr(t)?or(t,e,i,n,s,o):rr(t,e,l,i,n,s,o);if(!(1&i)){var u=h&&fr.call(t,"__wrapped__"),m=d&&fr.call(e,"__wrapped__");if(u||m){var f=u?t.value():t,g=m?e.value():e;return o||(o=new sr),s(f,g,i,n,o)}}return!!p&&(o||(o=new sr),ar(t,e,i,n,s,o))},vr=hi;var yr=function t(e,i,n,s,o){return e===i||(null==e||null==i||!vr(e)&&!vr(i)?e!=e&&i!=i:gr(e,i,n,s,t,o))},wr=yr;var xr=Wt((function(t,e){return wr(t,e)}));function br(t){const e=t.get(0),i={};if(e.hasAttributes())for(const t of e.attributes)i[t.name]=t.value;return i}class kr{constructor(t){const e=window.getSelection();if(!e)throw new Error("Selection object is null.");this.selection=e,this.container=t,this.range=this.getRangeFromNativeSelection()}getRangeFromNativeSelection(){if(this.selection.rangeCount>0){const t=this.selection.getRangeAt(0);return new L(t)}return new L}addRangeToNativeSelection(){this.selection.removeAllRanges(),this.selection.addRange(this.range.get())}syncByRange(){const t=this.getRangeFromNativeSelection();this.range.get()!==t.get()&&(this.range=t)}synByBookmark(){const t=this.range,e=this.container,i=e.find("lake-box[focus]");if(i.length>0)return ae(t,{anchor:new E,focus:i}),void this.addRangeToNativeSelection();ae(t,{anchor:e.find('lake-bookmark[type="anchor"]'),focus:e.find('lake-bookmark[type="focus"]')}),this.addRangeToNativeSelection()}getAppliedItems(){const t=[];return function(t,e){let i=e.startNode;for(i.isText&&(i=i.parent());i.length>0&&i.isInside;)t.push({node:i,name:i.name,attributes:br(i),styles:p(i.attr("style"))}),i=i.parent()}(t,this.range),function(t,e){const i=e.startNode;let n;if(i.isText&&i.text().length===e.startOffset){const t=i.next();t.length>0&&t.isElement&&(n=t)}if(i.isElement){const t=i.children();if(t.length>0){const i=t[e.startOffset];i&&i.isElement&&(n=i)}}if(n){let e=n;for(;e.length>0;)e.isElement&&t.push({node:e,name:e.name,attributes:br(e),styles:p(e.attr("style"))}),e=e.first()}}(t,this.range),t}insertBookmark(){return oe(this.range)}toBookmark(t){return ae(this.range,t)}insertNode(t){return se(this.range,t)}insertFragment(t){return he(this.range,t)}insertContents(t){return de(this.range,t)}deleteContents(){return ce(this.range)}setBlocks(t){return pe(this.range,t)}splitBlock(){return ue(this.range)}splitMarks(t){return ge(this.range,t)}addMark(t){return ye(this.range,t)}removeMark(t){return xe(this.range,t)}fixList(){return le(this.range)}insertLink(t){return be(this.range,t)}}class _r{constructor(t){this.commandMap=new Map,this.event=new qt,this.selection=t}add(t,e){this.commandMap.set(t,e)}delete(t){this.commandMap.delete(t)}getNames(){return Array.from(this.commandMap.keys())}has(t){return void 0!==this.commandMap.get(t)}getItem(t){const e=this.commandMap.get(t);if(void 0===e)throw new Error(`Command '${t}' does not exist.`);return e}isDisabled(t){const e=this.getItem(t);if(!e.isDisabled)return!1;const i=this.selection.getAppliedItems();return e.isDisabled(i)}isSelected(t){const e=this.getItem(t);if(!e.isSelected)return!1;const i=this.selection.getAppliedItems();return e.isSelected(i)}selectedValues(t){const e=this.getItem(t);if(!e.selectedValues)return[];const i=this.selection.getAppliedItems();return e.selectedValues(i)}execute(t,...e){const i=this.getItem(t);this.event.emit("beforeexecute",t),i.execute.apply(this,e),this.event.emit("execute",t),A(`Command '${t}' executed`)}}var Sr,Cr={exports:{}};Sr=Cr,function(t){function e(t,e){var i=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(i>>16)<<16|65535&i}function i(t,i,n,s,o,r){return e((a=e(e(i,t),e(s,r)))<<(l=o)|a>>>32-l,n);var a,l}function n(t,e,n,s,o,r,a){return i(e&n|~e&s,t,e,o,r,a)}function s(t,e,n,s,o,r,a){return i(e&s|n&~s,t,e,o,r,a)}function o(t,e,n,s,o,r,a){return i(e^n^s,t,e,o,r,a)}function r(t,e,n,s,o,r,a){return i(n^(e|~s),t,e,o,r,a)}function a(t,i){var a,l,c,h,d;t[i>>5]|=128<<i%32,t[14+(i+64>>>9<<4)]=i;var p=1732584193,u=-271733879,m=-1732584194,f=271733878;for(a=0;a<t.length;a+=16)l=p,c=u,h=m,d=f,p=n(p,u,m,f,t[a],7,-680876936),f=n(f,p,u,m,t[a+1],12,-389564586),m=n(m,f,p,u,t[a+2],17,606105819),u=n(u,m,f,p,t[a+3],22,-1044525330),p=n(p,u,m,f,t[a+4],7,-176418897),f=n(f,p,u,m,t[a+5],12,1200080426),m=n(m,f,p,u,t[a+6],17,-1473231341),u=n(u,m,f,p,t[a+7],22,-45705983),p=n(p,u,m,f,t[a+8],7,1770035416),f=n(f,p,u,m,t[a+9],12,-1958414417),m=n(m,f,p,u,t[a+10],17,-42063),u=n(u,m,f,p,t[a+11],22,-1990404162),p=n(p,u,m,f,t[a+12],7,1804603682),f=n(f,p,u,m,t[a+13],12,-40341101),m=n(m,f,p,u,t[a+14],17,-1502002290),p=s(p,u=n(u,m,f,p,t[a+15],22,1236535329),m,f,t[a+1],5,-165796510),f=s(f,p,u,m,t[a+6],9,-1069501632),m=s(m,f,p,u,t[a+11],14,643717713),u=s(u,m,f,p,t[a],20,-373897302),p=s(p,u,m,f,t[a+5],5,-701558691),f=s(f,p,u,m,t[a+10],9,38016083),m=s(m,f,p,u,t[a+15],14,-660478335),u=s(u,m,f,p,t[a+4],20,-405537848),p=s(p,u,m,f,t[a+9],5,568446438),f=s(f,p,u,m,t[a+14],9,-1019803690),m=s(m,f,p,u,t[a+3],14,-187363961),u=s(u,m,f,p,t[a+8],20,1163531501),p=s(p,u,m,f,t[a+13],5,-1444681467),f=s(f,p,u,m,t[a+2],9,-51403784),m=s(m,f,p,u,t[a+7],14,1735328473),p=o(p,u=s(u,m,f,p,t[a+12],20,-1926607734),m,f,t[a+5],4,-378558),f=o(f,p,u,m,t[a+8],11,-2022574463),m=o(m,f,p,u,t[a+11],16,1839030562),u=o(u,m,f,p,t[a+14],23,-35309556),p=o(p,u,m,f,t[a+1],4,-1530992060),f=o(f,p,u,m,t[a+4],11,1272893353),m=o(m,f,p,u,t[a+7],16,-155497632),u=o(u,m,f,p,t[a+10],23,-1094730640),p=o(p,u,m,f,t[a+13],4,681279174),f=o(f,p,u,m,t[a],11,-358537222),m=o(m,f,p,u,t[a+3],16,-722521979),u=o(u,m,f,p,t[a+6],23,76029189),p=o(p,u,m,f,t[a+9],4,-640364487),f=o(f,p,u,m,t[a+12],11,-421815835),m=o(m,f,p,u,t[a+15],16,530742520),p=r(p,u=o(u,m,f,p,t[a+2],23,-995338651),m,f,t[a],6,-198630844),f=r(f,p,u,m,t[a+7],10,1126891415),m=r(m,f,p,u,t[a+14],15,-1416354905),u=r(u,m,f,p,t[a+5],21,-57434055),p=r(p,u,m,f,t[a+12],6,1700485571),f=r(f,p,u,m,t[a+3],10,-1894986606),m=r(m,f,p,u,t[a+10],15,-1051523),u=r(u,m,f,p,t[a+1],21,-2054922799),p=r(p,u,m,f,t[a+8],6,1873313359),f=r(f,p,u,m,t[a+15],10,-30611744),m=r(m,f,p,u,t[a+6],15,-1560198380),u=r(u,m,f,p,t[a+13],21,1309151649),p=r(p,u,m,f,t[a+4],6,-145523070),f=r(f,p,u,m,t[a+11],10,-1120210379),m=r(m,f,p,u,t[a+2],15,718787259),u=r(u,m,f,p,t[a+9],21,-343485551),p=e(p,l),u=e(u,c),m=e(m,h),f=e(f,d);return[p,u,m,f]}function l(t){var e,i="",n=32*t.length;for(e=0;e<n;e+=8)i+=String.fromCharCode(t[e>>5]>>>e%32&255);return i}function c(t){var e,i=[];for(i[(t.length>>2)-1]=void 0,e=0;e<i.length;e+=1)i[e]=0;var n=8*t.length;for(e=0;e<n;e+=8)i[e>>5]|=(255&t.charCodeAt(e/8))<<e%32;return i}function h(t){var e,i,n="0123456789abcdef",s="";for(i=0;i<t.length;i+=1)e=t.charCodeAt(i),s+=n.charAt(e>>>4&15)+n.charAt(15&e);return s}function d(t){return unescape(encodeURIComponent(t))}function p(t){return function(t){return l(a(c(t),8*t.length))}(d(t))}function u(t,e){return function(t,e){var i,n,s=c(t),o=[],r=[];for(o[15]=r[15]=void 0,s.length>16&&(s=a(s,8*t.length)),i=0;i<16;i+=1)o[i]=909522486^s[i],r[i]=1549556828^s[i];return n=a(o.concat(c(e)),512+8*e.length),l(a(r.concat(n),640))}(d(t),d(e))}function m(t,e,i){return e?i?u(e,t):h(u(e,t)):i?p(t):h(p(t))}Sr.exports?Sr.exports=m:t.md5=m}(Rt);var Ar=Wt(Cr.exports);const Br=new Map;class Tr{constructor(t){this.list=[],this.index=0,this.canSave=!0,this.limit=100,this.event=new qt,this.selection=t,this.container=t.container}removeBookmark(t){return t.replace(/(<lake-box[^>]+)\s+focus="\w+"([^>]*>)/gi,"$1$2").replace(/<lake-bookmark\s+type="anchor">\s*<\/lake-bookmark>/gi,"").replace(/<lake-bookmark\s+type="focus">\s*<\/lake-bookmark>/gi,"")}getValue(t){return new ie(t).getHTML()}addIdToBoxes(t){t.find("lake-box").each((t=>{const e=new E(t),i=Ar(`${e.attr("type")}-${e.attr("name")}-${e.attr("value")}`);e.attr("id",i)}))}removeIdfromBoxes(t){t.find("lake-box").each((t=>{new E(t).removeAttr("id")}))}morphContainer(t){const e=this.container,i={beforeChildrenUpdated:t=>{if("lake-box"===new E(t).name)return!1},afterAttributeUpdated:(t,i)=>{const n=new E(i);if("value"===t&&"lake-box"===n.name){const t=Br.get(e.id);if(!t)return;t.delete(n.id)}}},n=t.clone(!0);this.addIdToBoxes(e),this.addIdToBoxes(n),ht(e,n,{callbacks:i}),this.removeIdfromBoxes(e),this.removeIdfromBoxes(n)}cloneContainer(){const t=this.selection.range,e=this.container.clone(!0);if(e.find("lake-box").each((t=>{new Yt(t).getContainer().empty()})),t.commonAncestor.isOutside)return e;if(t.isInsideBox)return e;const i=t.startNode.path(),n=t.endNode.path(),s=e.find(i),o=e.find(n),r=t.clone();return r.setStart(s,t.startOffset),r.setEnd(o,t.endOffset),oe(r),e}get count(){return this.list.length}get canUndo(){return this.index>1&&!!this.list[this.index-1]}get canRedo(){return!!this.list[this.index]}undo(){if(!this.list[this.index-1])return;this.selection.insertBookmark();const t=this.getValue(this.container);for(;this.index>0;){const e=this.list[this.index-1];if(!e)break;const i=this.getValue(e);if(this.removeBookmark(i)!==this.removeBookmark(t)){this.morphContainer(e),this.event.emit("undo",i);break}if(1===this.index)break;this.index--}this.selection.synByBookmark(),A(`History undone, the last index is ${this.index}`)}redo(){if(!this.list[this.index])return;this.selection.insertBookmark();const t=this.getValue(this.container);for(;this.index<this.list.length;){const e=this.list[this.index];if(!e)break;this.index++;const i=this.getValue(e);if(this.removeBookmark(i)!==this.removeBookmark(t)){this.morphContainer(e),this.event.emit("redo",i);break}}this.selection.synByBookmark(),A(`History redone, the last index is ${this.index}`)}continue(){this.canSave=!0}pause(){this.canSave=!1}save(t=!0){if(!this.canSave)return;const e=this.cloneContainer(),i=this.getValue(e);this.list[this.index-1]&&this.removeBookmark(this.getValue(this.list[this.index-1]))===this.removeBookmark(i)||(this.list.splice(this.index,1/0,e),this.index++,this.list.length>this.limit&&(this.list.shift(),this.index=this.list.length),t&&this.event.emit("save",m(i)),A(`History saved, the last index is ${this.index}`))}}var Er=["Shift","Meta","Alt","Control"],Ir="object"==typeof navigator?navigator.platform:"",Lr=/Mac|iPod|iPhone|iPad/.test(Ir),Mr=Lr?"Meta":"Control",Pr="Win32"===Ir?["Control","Alt"]:Lr?["Alt"]:[];function Or(t,e){return"function"==typeof t.getModifierState&&(t.getModifierState(e)||Pr.includes(e)&&t.getModifierState("AltGraph"))}function zr(t){return t.trim().split(" ").map((function(t){var e=t.split(/\b\+/),i=e.pop();return[e=e.map((function(t){return"$mod"===t?Mr:t})),i]}))}function Zr(t,e){var i;void 0===e&&(e={});var n=null!=(i=e.timeout)?i:1e3,s=Object.keys(t).map((function(e){return[zr(e),t[e]]})),o=new Map,r=null;return function(t){t instanceof KeyboardEvent&&(s.forEach((function(e){var i=e[0],n=e[1],s=o.get(i)||i;!function(t,e){return!(e[1].toUpperCase()!==t.key.toUpperCase()&&e[1]!==t.code||e[0].find((function(e){return!Or(t,e)}))||Er.find((function(i){return!e[0].includes(i)&&e[1]!==i&&Or(t,i)})))}(t,s[0])?Or(t,t.key)||o.delete(i):s.length>1?o.set(i,s.slice(1)):(o.delete(i),n(t))})),r&&clearTimeout(r),r=setTimeout(o.clear.bind(o),n))}}const Nr=new Map([["#","shift+#"]]);class Hr{constructor(t){this.keydownEventList=[],this.keyupEventList=[],this.container=t}normalizeType(t){var e;return t=(t=null!==(e=Nr.get(t))&&void 0!==e?e:t).replace(/(^|\+|\s)mod(\+|\s|$)/g,"$1$mod$2").replace(/shift|control|alt|meta|enter|tab|backspace|delete|space|escape|arrow-left|arrow-right|arrow-up|arrow-down/,(t=>t.charAt(0).toUpperCase()+l(t.substring(1)))).replace(/(^|\+|\s)([a-z])(\+|\s|$)/g,((t,e,i,n)=>`${e}Key${i.toUpperCase()}${n}`))}setKeydown(t,e){t=this.normalizeType(t);const i=Zr({[t]:t=>e(t)});this.keydownEventList.push({type:t,listener:e}),this.container.on("keydown",i)}setKeyup(t,e){t=this.normalizeType(t);const i=Zr({[t]:t=>e(t)});this.keyupEventList.push({type:t,listener:e}),this.container.on("keyup",i)}keydown(t){t=this.normalizeType(t);for(const e of this.keydownEventList)if(e.type===t&&!1===e.listener(new Event(t)))break}keyup(t){t=this.normalizeType(t);for(const e of this.keyupEventList)if(e.type===t&&!1===e.listener(new Event(t)))break}}const Dr={value:"<p><br /><focus /></p>",readonly:!1,spellcheck:!1,tabIndex:0,indentWithTab:!0,lang:"en-US",minChangeSize:5};class $r{constructor(t){if(this.unsavedInputData="",this.stateData={appliedItems:[],disabledNameMap:new Map,selectedNameMap:new Map,selectedValuesMap:new Map},this.isComposing=!1,this.event=new qt,this.box=$r.box,this.beforeunloadListener=()=>{this.history.save()},this.selectionchangeListener=()=>{this.selection.syncByRange(),this.updateBoxSelectionStyle(),this.emitStateChangeEvent()},this.clickListener=t=>{const e=new E(t.target);e.closest(".lake-popup").length>0||this.event.emit("click",e)},this.resizeListener=()=>{this.event.emit("resize")},this.updateBoxSelectionStyle=Ai((()=>{if(0===this.root.first().length)return;const t=this.selection.range,e=t.clone();e.adaptBox(),this.box.findAll(this).each((i=>{const n=new Yt(i),s=n.getContainer();if(0!==s.length){if(t.compareBeforeNode(s)<0&&t.compareAfterNode(s)>0&&(!t.isCollapsed||t.startNode.get(0)!==s.get(0)||0!==t.startOffset))return s.removeClass("lake-box-hovered"),s.removeClass("lake-box-selected"),s.removeClass("lake-box-focused"),void s.addClass("lake-box-activated");if(e.intersectsNode(n.node))return s.removeClass("lake-box-activated"),void(t.isCollapsed?(s.removeClass("lake-box-hovered"),s.removeClass("lake-box-selected"),s.addClass("lake-box-focused")):(s.removeClass("lake-box-focused"),s.addClass("lake-box-selected")));s.removeClass("lake-box-activated"),s.removeClass("lake-box-focused"),s.removeClass("lake-box-selected")}})),this.event.emit("boxselectionstylechange")}),50,{leading:!1,trailing:!0,maxWait:50}),this.emitStateChangeEvent=Ai((()=>{const t=this.command.getNames();let e=this.selection.getAppliedItems();e.length>0&&e[0].node.closestContainer().get(0)!==this.container.get(0)&&(e=[]);const i=new Map,n=new Map,s=new Map;if(e.length>0)for(const o of t){const t=this.command.getItem(o);if(t.isDisabled&&t.isDisabled(e)&&i.set(o,!0),t.isSelected&&t.isSelected(e)&&n.set(o,!0),t.selectedValues){const i=t.selectedValues(e);i.length>0&&s.set(o,i)}}const o={appliedItems:e,disabledNameMap:i,selectedNameMap:n,selectedValuesMap:s};xr(o,this.stateData)||(this.toolbar&&this.toolbar.updateState(o),this.event.emit("statechange",o),this.stateData=o)}),100,{leading:!1,trailing:!0,maxWait:100}),this.emitChangeEvent=t=>{this.rectifyContent(),this.emitStateChangeEvent(),this.event.emit("change",t)},!t.root)throw new Error("The root of the config must be specified.");this.root=I(t.root),this.toolbar=t.toolbar,this.config=Object.assign({},Dr);for(const e of Object.keys(t))this.config[e]=t[e];this.containerWrapper=I('<div class="lake-container-wrapper" />'),this.container=I('<div class="lake-container" />'),this.overlayContainer=I('<div class="lake-overlay" />'),this.popupContainer=I('<div class="lake-popup lake-custom-properties" />'),this.readonly=this.config.readonly,this.root.addClass("lake-custom-properties"),this.container.attr({contenteditable:this.readonly?"false":"true",spellcheck:this.config.spellcheck?"true":"false",tabindex:this.config.tabIndex.toString()}),this.selection=new kr(this.container),this.command=new _r(this.selection),this.history=new Tr(this.selection),this.keystroke=new Hr(this.container),Gt.set(this.container.id,this)}inputInBoxStrip(){const t=this.selection,e=t.range,i=e.startNode.closest(".lake-box-strip"),n=i.closest("lake-box");if("inline"===new Yt(n).type)e.isBoxStart?(e.setStartBefore(n),e.collapseToStart()):(e.setStartAfter(n),e.collapseToStart());else{const t=I("<p />");e.isBoxStart?n.before(t):n.after(t),e.shrinkAfter(t)}const s=i.text();i.html("<br />"),t.insertNode(document.createTextNode(s))}bindInputEvents(){this.container.on("compositionstart",(()=>{this.isComposing=!0})),this.container.on("compositionend",(()=>{this.isComposing=!1})),this.container.on("beforeinput",(t=>{const e=t,i=this.selection.range;(i.isBoxStart||i.isBoxEnd||"insertText"!==e.inputType&&"insertCompositionText"!==e.inputType)&&this.commitUnsavedInputData()})),this.container.on("input",(t=>{const e=t;window.setTimeout((()=>{var t;const i=this.selection.range;if(!i.isInsideBox)if(this.isComposing)this.event.emit("input",e);else{if(i.isBoxStart||i.isBoxEnd)return this.inputInBoxStrip(),this.history.save(),void this.event.emit("input",e);if(("insertText"===e.inputType||"insertCompositionText"===e.inputType)&&(this.unsavedInputData+=null!==(t=e.data)&&void 0!==t?t:"",this.unsavedInputData.length<this.config.minChangeSize))return this.event.emit("input",e),void this.emitChangeEvent(this.getValue());this.history.save(),this.event.emit("input",e)}}),0)})),this.command.event.on("beforeexecute",(()=>this.commitUnsavedInputData()))}bindHistoryEvents(){this.history.event.on("undo",(t=>{this.box.renderAll(this),this.emitChangeEvent(t)})),this.history.event.on("redo",(t=>{this.box.renderAll(this),this.emitChangeEvent(t)})),this.history.event.on("save",(t=>{this.box.rectifyInstances(this),this.emitChangeEvent(t)}))}get hasFocus(){const t=document.activeElement;return!!t&&I(t).closest(".lake-container").get(0)===this.container.get(0)}get locale(){return He(this.config.lang)}rectifyContent(){let t=this.container.children();for(const e of t)(e.isBlock||e.isMark)&&""===e.html()&&(e.remove(),A("Rectifying content: empty tag was removed"));if(t=this.container.children(),0===t.length)return this.container.html("<p><br /></p>"),this.selection.range.shrinkAfter(this.container),void A("Rectifying content: default paragraph was added");if(1===t.length){const e=t[0];if(e.isVoid){const t=I("<p />");e.before(t),t.append(e),this.selection.range.shrinkAfter(t),A("Rectifying content: void element was wrapped in paragraph")}}}commitUnsavedInputData(){this.unsavedInputData.length>0&&(this.history.save(!1),this.unsavedInputData="")}prepareOperation(){this.commitUnsavedInputData(),this.history.pause()}commitOperation(){this.history.continue(),this.history.save()}setPluginConfig(t,e){this.config[t]||(this.config[t]={});for(const i of Object.keys(e))void 0===this.config[t][i]&&(this.config[t][i]=e[i])}focus(){this.container.focus()}blur(){this.container.blur()}setValue(t){t=u(t);const e=new ie(t).getFragment();this.container.empty(),this.container.append(e),$r.box.renderAll(this),this.selection.synByBookmark()}getValue(){const t=this.selection.insertBookmark();let e=new ie(this.container).getHTML();return e=m(e),this.selection.toBookmark(t),e}insertBox(t,e){const i=function(t,e,i){if(t.commonAncestor.isOutside)return null;const n=new Yt(e);i&&(n.value=i);const s=document.createDocumentFragment();if(s.appendChild(n.node.get(0)),"inline"===n.type)return he(t,s),n.render(),t.selectBoxEnd(n.node),n;const o=ue(t);return o.start&&(t.setEndAfter(o.start),t.collapseToEnd()),o.end&&o.end.isEmpty&&o.end.remove(),he(t,s),n.render(),t.selectBoxEnd(n.node),o.start&&o.start.isEmpty&&o.start.remove(),n}(this.selection.range,t,e);if(!i)throw new Error(`Box '${t}' cannot be inserted outside the editor.`);return this.box.getInstances(this).set(i.node.id,i),i}removeBox(){const t=function(t){if(t.commonAncestor.isOutside)return null;const e=t.commonAncestor.closest("lake-box");if(0===e.length)return null;const i=new Yt(e);if("block"===i.type){const n=I("<p><br /></p>");return e.before(n),t.shrinkAfter(n),i.unmount(),e.remove(),i}t.setStartBefore(e),t.collapseToStart();const n=e.parent();return i.unmount(),e.remove(),n.isEmpty&&(P(n,I("<br />")),t.shrinkAfter(n)),i}(this.selection.range);if(t){this.box.getInstances(this).delete(t.node.id)}return t}render(){const t=u(this.config.value),e=new ie(t).getFragment();this.root.empty(),this.root.append(this.containerWrapper),this.containerWrapper.append(this.container),this.containerWrapper.append(this.overlayContainer),I(document.body).append(this.popupContainer),this.container.append(e),$r.plugin.loadAll(this),this.readonly||(this.selection.synByBookmark(),this.history.save()),$r.box.renderAll(this),this.toolbar&&this.toolbar.render(this),this.readonly||(window.addEventListener("beforeunload",this.beforeunloadListener),document.addEventListener("selectionchange",this.selectionchangeListener),document.addEventListener("click",this.clickListener),window.addEventListener("resize",this.resizeListener),this.bindInputEvents(),this.bindHistoryEvents())}unmount(){this.root.empty(),this.popupContainer.remove(),this.readonly||(window.removeEventListener("beforeunload",this.beforeunloadListener),document.removeEventListener("selectionchange",this.selectionchangeListener),document.removeEventListener("click",this.clickListener),window.removeEventListener("resize",this.resizeListener))}}$r.version="0.1.4",$r.box=new class{add(t){Kt.set(t.name,t)}remove(t){Kt.delete(t)}getNames(){return Array.from(Kt.keys())}getInstances(t){let e=Br.get(t.container.id);return e||(e=new Map,Br.set(t.container.id,e),e)}rectifyInstances(t){const e=this.getInstances(t);for(const t of e.values())t.node.get(0).isConnected||(t.unmount(),e.delete(t.node.id))}findAll(t){return t.container.find("lake-box")}renderAll(t){this.rectifyInstances(t);const e=this.getInstances(t);this.findAll(t).each((t=>{const i=new E(t);if(e.get(i.id))return;const n=new Yt(i);n.render(),e.set(n.node.id,n)}))}},$r.plugin=new class{constructor(){this.pluginList=[]}add(t){this.pluginList.push(t)}loadAll(t){this.pluginList.forEach((e=>{e(t)}))}};const Vr=[{icon:n.get("numberedList"),value:"numbered",text:t=>t.toolbar.numberedList()},{icon:n.get("bulletedList"),value:"bulleted",text:t=>t.toolbar.bulletedList()},{icon:n.get("checklist"),value:"checklist",text:t=>t.toolbar.checklist()}],Fr=[{icon:n.get("alignLeft"),value:"left",text:t=>t.toolbar.alignLeft()},{icon:n.get("alignCenter"),value:"center",text:t=>t.toolbar.alignCenter()},{icon:n.get("alignRight"),value:"right",text:t=>t.toolbar.alignRight()},{icon:n.get("alignJustify"),value:"justify",text:t=>t.toolbar.alignJustify()}],jr=[{icon:n.get("increaseIndent"),value:"increase",text:t=>t.toolbar.increaseIndent()},{icon:n.get("decreaseIndent"),value:"decrease",text:t=>t.toolbar.decreaseIndent()}],Rr=[{icon:n.get("italic"),value:"italic",text:t=>t.toolbar.italic()},{icon:n.get("underline"),value:"underline",text:t=>t.toolbar.underline()},{icon:n.get("strikethrough"),value:"strikethrough",text:t=>t.toolbar.strikethrough()},{icon:n.get("superscript"),value:"superscript",text:t=>t.toolbar.superscript()},{icon:n.get("subscript"),value:"subscript",text:t=>t.toolbar.subscript()},{icon:n.get("code"),value:"code",text:t=>t.toolbar.code()}],Wr=["#f5222d","#fa541c","#fa8c16","#faad14","#fadb14","#a0d911","#52c41a","#13c2c2","#1677ff","#2f54eb","#722ed1","#eb2f96","#fff1f0","#fff2e8","#fff7e6","#fffbe6","#feffe6","#fcffe6","#f6ffed","#e6fffb","#e6f4ff","#f0f5ff","#f9f0ff","#fff0f6","#ffccc7","#ffd8bf","#ffe7ba","#fff1b8","#ffffb8","#f4ffb8","#d9f7be","#b5f5ec","#bae0ff","#d6e4ff","#efdbff","#ffd6e7","#ffa39e","#ffbb96","#ffd591","#ffe58f","#fffb8f","#eaff8f","#b7eb8f","#87e8de","#91caff","#adc6ff","#d3adf7","#ffadd2","#ff7875","#ff9c6e","#ffc069","#ffd666","#fff566","#d3f261","#95de64","#5cdbd3","#69b1ff","#85a5ff","#b37feb","#ff85c0","#ff4d4f","#ff7a45","#ffa940","#ffc53d","#ffec3d","#bae637","#73d13d","#36cfc9","#4096ff","#597ef7","#9254de","#f759ab","#cf1322","#d4380d","#d46b08","#d48806","#d4b106","#7cb305","#389e0d","#08979c","#0958d9","#1d39c4","#531dab","#c41d7f","#a8071a","#ad2102","#ad4e00","#ad6800","#ad8b00","#5b8c00","#237804","#006d75","#003eb3","#10239e","#391085","#9e1068","#820014","#871400","#873800","#874d00","#876800","#3f6600","#135200","#00474f","#002c8c","#061178","#22075e","#780650","#5c0011","#610b00","#612500","#613400","#614700","#254000","#092b00","#002329","#001d66","#030852","#120338","#520339","#000000","#1f1f1f","#262626","#434343","#595959","#8c8c8c","#bfbfbf","#d9d9d9","#f0f0f0","#f5f5f5","#fafafa","#ffffff"],Ur=[{icon:n.get("removeFormat"),value:"",text:t=>t.toolbar.removeColor()}];for(const t of Wr)Ur.push({value:t.toLowerCase(),text:t.toUpperCase()});const qr=new Map([["strong","bold"],["em","italic"],["i","italic"],["u","underline"],["s","strikethrough"],["sup","superscript"],["sub","subscript"],["code","code"]]),Kr=[{name:"undo",type:"button",icon:n.get("undo"),tooltip:t=>t.toolbar.undo(),onClick:(t,e)=>{t.command.execute(e)}},{name:"redo",type:"button",icon:n.get("redo"),tooltip:t=>t.toolbar.redo(),onClick:(t,e)=>{t.command.execute(e)}},{name:"selectAll",type:"button",icon:n.get("selectAll"),tooltip:t=>t.toolbar.selectAll(),onClick:(t,e)=>{t.command.execute(e)}},{name:"paragraph",type:"button",icon:n.get("paragraph"),tooltip:t=>t.toolbar.paragraph(),isSelected:t=>!!t.find((t=>"p"===t.name)),onClick:t=>{t.command.execute("heading","p")}},{name:"blockQuote",type:"button",icon:n.get("blockQuote"),tooltip:t=>t.toolbar.blockQuote(),onClick:(t,e)=>{t.command.execute(e)}},{name:"numberedList",type:"button",icon:n.get("numberedList"),tooltip:t=>t.toolbar.numberedList(),isSelected:t=>!!t.find((t=>"ol"===t.name)),onClick:t=>{t.command.execute("list","numbered")}},{name:"bulletedList",type:"button",icon:n.get("bulletedList"),tooltip:t=>t.toolbar.bulletedList(),isSelected:t=>!!t.find((t=>"ul"===t.name&&!t.node.hasAttr("type"))),onClick:t=>{t.command.execute("list","bulleted")}},{name:"checklist",type:"button",icon:n.get("checklist"),tooltip:t=>t.toolbar.checklist(),isSelected:t=>!!t.find((t=>"ul"===t.name&&"checklist"===t.node.attr("type"))),onClick:t=>{t.command.execute("list","checklist")}},{name:"alignLeft",type:"button",icon:n.get("alignLeft"),tooltip:t=>t.toolbar.alignLeft(),isSelected:t=>!!t.find((t=>t.node.isBlock&&"left"===t.node.css("text-align"))),onClick:t=>{t.command.execute("align","left")}},{name:"alignCenter",type:"button",icon:n.get("alignCenter"),tooltip:t=>t.toolbar.alignCenter(),isSelected:t=>!!t.find((t=>t.node.isBlock&&"center"===t.node.css("text-align"))),onClick:t=>{t.command.execute("align","center")}},{name:"alignRight",type:"button",icon:n.get("alignRight"),tooltip:t=>t.toolbar.alignRight(),isSelected:t=>!!t.find((t=>t.node.isBlock&&"right"===t.node.css("text-align"))),onClick:t=>{t.command.execute("align","right")}},{name:"alignJustify",type:"button",icon:n.get("alignJustify"),tooltip:t=>t.toolbar.alignJustify(),isSelected:t=>!!t.find((t=>t.node.isBlock&&"justify"===t.node.css("text-align"))),onClick:t=>{t.command.execute("align","justify")}},{name:"increaseIndent",type:"button",icon:n.get("increaseIndent"),tooltip:t=>t.toolbar.increaseIndent(),onClick:t=>{t.command.execute("indent","increase")}},{name:"decreaseIndent",type:"button",icon:n.get("decreaseIndent"),tooltip:t=>t.toolbar.decreaseIndent(),onClick:t=>{t.command.execute("indent","decrease")}},{name:"bold",type:"button",icon:n.get("bold"),tooltip:t=>t.toolbar.bold(),onClick:(t,e)=>{t.command.execute(e)}},{name:"italic",type:"button",icon:n.get("italic"),tooltip:t=>t.toolbar.italic(),onClick:(t,e)=>{t.command.execute(e)}},{name:"underline",type:"button",icon:n.get("underline"),tooltip:t=>t.toolbar.underline(),onClick:(t,e)=>{t.command.execute(e)}},{name:"strikethrough",type:"button",icon:n.get("strikethrough"),tooltip:t=>t.toolbar.strikethrough(),onClick:(t,e)=>{t.command.execute(e)}},{name:"superscript",type:"button",icon:n.get("superscript"),tooltip:t=>t.toolbar.superscript(),onClick:(t,e)=>{t.command.execute(e)}},{name:"subscript",type:"button",icon:n.get("subscript"),tooltip:t=>t.toolbar.subscript(),onClick:(t,e)=>{t.command.execute(e)}},{name:"code",type:"button",icon:n.get("code"),tooltip:t=>t.toolbar.code(),onClick:(t,e)=>{t.command.execute(e)}},{name:"removeFormat",type:"button",icon:n.get("removeFormat"),tooltip:t=>t.toolbar.removeFormat(),onClick:(t,e)=>{t.command.execute(e)}},{name:"formatPainter",type:"button",icon:n.get("formatPainter"),tooltip:t=>t.toolbar.formatPainter(),onClick:(t,e)=>{t.command.execute(e)}},{name:"link",type:"button",icon:n.get("link"),tooltip:t=>t.toolbar.link(),onClick:(t,e)=>{t.command.execute(e)}},{name:"hr",type:"button",icon:n.get("hr"),tooltip:t=>t.toolbar.hr(),onClick:(t,e)=>{t.command.execute(e)}},{name:"codeBlock",type:"button",icon:n.get("codeBlock"),tooltip:t=>t.toolbar.codeBlock(),onClick:(t,e)=>{t.command.execute(e)}},{name:"heading",type:"dropdown",downIcon:n.get("down"),defaultValue:"p",tooltip:t=>t.toolbar.heading(),width:"100px",menuType:"list",menuItems:[{value:"h1",text:t=>`<span style="font-weight: bold; font-size: 26px;">${t.toolbar.heading1()}</span>`},{value:"h2",text:t=>`<span style="font-weight: bold; font-size: 24px;">${t.toolbar.heading2()}</span>`},{value:"h3",text:t=>`<span style="font-weight: bold; font-size: 22px;">${t.toolbar.heading3()}</span>`},{value:"h4",text:t=>`<span style="font-weight: bold; font-size: 20px;">${t.toolbar.heading4()}</span>`},{value:"h5",text:t=>`<span style="font-weight: bold; font-size: 18px;">${t.toolbar.heading5()}</span>`},{value:"h6",text:t=>`<span style="font-weight: bold; font-size: 16px;">${t.toolbar.heading6()}</span>`},{value:"p",text:t=>t.toolbar.paragraph()}],onSelect:(t,e)=>{t.command.execute("heading",e)}},{name:"list",type:"dropdown",downIcon:n.get("down"),icon:n.get("list"),defaultValue:"",tooltip:t=>t.toolbar.list(),width:"auto",menuType:"list",menuItems:Vr,onSelect:(t,e)=>{t.command.execute("list",e)}},{name:"align",type:"dropdown",downIcon:n.get("down"),icon:n.get("alignLeft"),defaultValue:"",tooltip:t=>t.toolbar.align(),width:"auto",menuType:"list",menuItems:Fr,onSelect:(t,e)=>{t.command.execute("align",e)}},{name:"indent",type:"dropdown",downIcon:n.get("down"),icon:n.get("increaseIndent"),defaultValue:"",tooltip:t=>t.toolbar.indent(),width:"auto",menuType:"list",menuItems:jr,onSelect:(t,e)=>{t.command.execute("indent",e)}},{name:"fontFamily",type:"dropdown",downIcon:n.get("down"),defaultValue:"Segoe UI",tooltip:t=>t.toolbar.fontFamily(),width:"100px",menuType:"list",menuItems:[{value:"Arial",text:'<span style="font-family: Arial;">Arial</span>'},{value:"Arial Black",text:"<span style=\"font-family: 'Arial Black';\">Arial Black</span>"},{value:"Comic Sans MS",text:"<span style=\"font-family: 'Comic Sans MS';\">Comic Sans MS</span>"},{value:"Courier New",text:"<span style=\"font-family: 'Courier New';\">Courier New</span>"},{value:"Georgia",text:'<span style="font-family: Georgia;">Georgia</span>'},{value:"Helvetica",text:'<span style="font-family: Helvetica;">Helvetica</span>'},{value:"Impact",text:'<span style="font-family: Impact;">Impact</span>'},{value:"Segoe UI",text:"<span style=\"font-family: 'Segoe UI';\">Segoe UI</span>"},{value:"Tahoma",text:'<span style="font-family: Tahoma;">Tahoma</span>'},{value:"Times New Roman",text:"<span style=\"font-family: 'Times New Roman';\">Times New Roman</span>"},{value:"Trebuchet MS",text:"<span style=\"font-family: 'Trebuchet MS';\">Trebuchet MS</span>"},{value:"Verdana",text:'<span style="font-family: Verdana;">Verdana</span>'}],onSelect:(t,e)=>{t.command.execute("fontFamily",e)}},{name:"fontSize",type:"dropdown",downIcon:n.get("down"),defaultValue:"16px",tooltip:t=>t.toolbar.fontSize(),width:"65px",menuType:"list",menuItems:[{value:"12px",text:"12px"},{value:"14px",text:"14px"},{value:"16px",text:"16px"},{value:"18px",text:"18px"},{value:"22px",text:"22px"},{value:"24px",text:"24px"},{value:"32px",text:"32px"}],onSelect:(t,e)=>{t.command.execute("fontSize",e)}},{name:"moreStyle",type:"dropdown",icon:n.get("more"),defaultValue:"",tooltip:t=>t.toolbar.moreStyle(),width:"auto",menuType:"list",menuItems:Rr,selectedValues:t=>{var e;const i=[];for(const n of t)if(n.node.isMark){const t=null!==(e=qr.get(n.name))&&void 0!==e?e:n.name;i.push(t)}return i},onSelect:(t,e)=>{t.command.execute(e)}},{name:"fontColor",type:"dropdown",downIcon:n.get("down"),icon:n.get("fontColor"),accentIcon:n.get("fontColorAccent"),defaultValue:"#f5222d",tooltip:t=>t.toolbar.fontColor(),width:"auto",menuType:"color",menuItems:Ur,onSelect:(t,e)=>{t.command.execute("fontColor",e)}},{name:"highlight",type:"dropdown",downIcon:n.get("down"),icon:n.get("highlight"),accentIcon:n.get("highlightAccent"),defaultValue:"#fadb14",tooltip:t=>t.toolbar.highlight(),width:"auto",menuType:"color",menuItems:Ur,onSelect:(t,e)=>{t.command.execute("highlight",e)}},{name:"image",type:"upload",icon:n.get("image"),tooltip:t=>t.toolbar.image(),accept:"image/*",multiple:!0}];function Gr(t){const{editor:e,file:i,onError:n,onSuccess:s}=t,{requestMethod:o,requestAction:r,requestTypes:a}=e.config.image;if(a.indexOf(i.type)<0)throw new Error(`Cannot upload file because its type '${i.type}' is not found in ['${a.join("', '")}'].`);const l=e.insertBox("image",{url:URL.createObjectURL(i),status:"uploading",name:i.name,size:i.size,type:i.type,lastModified:i.lastModified}),c=pt({onProgress:t=>{const e=l.node.find(".lake-percent"),i=Math.round(t.percent);e.text(`${i<100?i:99} %`)},onError:(t,e)=>{A(t.toString(),e),l.updateValue("status","error"),l.render(),n&&n()},onSuccess:t=>{if(!t.url)return l.updateValue("status","error"),l.render(),void(n&&n());l.updateValue({status:"done",url:t.url}),l.render(),e.history.save(),s&&s()},file:i,action:r,method:o});return l.setData("xhr",c),l}const Xr=["undo","redo","|","heading","|","formatPainter","removeFormat","bold","moreStyle","|","fontColor","highlight","|","align","list","indent","link","blockQuote","hr"],Jr=new Map;Kr.forEach((t=>{Jr.set(t.name,t)}));function Qr(t,e,i,n){return new(i||(i=Promise))((function(s,o){function r(t){try{l(n.next(t))}catch(t){o(t)}}function a(t){try{l(n.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,a)}l((n=n.apply(t,e||[])).next())}))}
18
+ `);if(t.append(a),"color"===e.menuType&&(a.attr("title",o),a.find(".lake-dropdown-menu-text").css("background-color",i.value)),i.icon){const t=I('<div class="lake-dropdown-menu-icon"></div>');t.append(i.icon),a.prepend(t)}const l=n.get("check");if(l){const t=I('<div class="lake-dropdown-menu-check"></div>');t.append(l),a.prepend(t)}}}showMenu(){const t=this.config,e=this.node,i=e.find(".lake-dropdown-menu");if(e.attr("disabled"))return;const n=De.getValue(e);i.find(".lake-dropdown-menu-check").css("visibility","hidden"),i.find("li").each((t=>{const e=I(t);e.on("mouseenter",(()=>{e.hasClass("lake-dropdown-item-selected")||e.addClass("lake-dropdown-item-hovered")})),e.on("mouseleave",(()=>{e.removeClass("lake-dropdown-item-hovered")})),n.indexOf(e.attr("value"))>=0&&e.find(".lake-dropdown-menu-check").css("visibility","visible")})),i.css("visibility","hidden"),i.show("color"===t.menuType?"flex":"block");e.get(0).getBoundingClientRect().x+i.width()+50>window.innerWidth?(i.css("left","auto"),i.css("right","0")):(i.css("left",""),i.css("right","")),i.css("visibility",""),document.addEventListener("click",this.documentClickListener)}bindEvents(){const t=this.config,e=this.node,i=e.find(".lake-dropdown-title"),n=i.find(".lake-dropdown-text"),s=i.find(".lake-dropdown-icon"),o=i.find(".lake-dropdown-down-icon"),r=e.find(".lake-dropdown-menu");"color"===t.menuType?(s.on("mouseenter",(()=>{e.attr("disabled")||s.addClass("lake-dropdown-icon-hovered")})),s.on("mouseleave",(()=>{s.removeClass("lake-dropdown-icon-hovered")})),o.on("mouseenter",(()=>{e.attr("disabled")||o.addClass("lake-dropdown-down-icon-hovered")})),o.on("mouseleave",(()=>{o.removeClass("lake-dropdown-down-icon-hovered")}))):(i.on("mouseenter",(()=>{e.attr("disabled")||i.addClass("lake-dropdown-title-hovered")})),i.on("mouseleave",(()=>{i.removeClass("lake-dropdown-title-hovered")}))),"color"===t.menuType&&s.on("click",(i=>{if(i.preventDefault(),e.attr("disabled"))return;const n=e.attr("color")||t.defaultValue;t.onSelect(n)}));("color"===t.menuType&&o?o:i).on("click",(t=>{t.preventDefault(),this.showMenu()})),r.on("click",(s=>{s.preventDefault();const o=I(s.target).closest("li"),a=o.attr("value");De.setValue(e,[a]),n.length>0&&n.text(o.text()),"color"===t.menuType&&""!==a&&(e.attr("color",a),this.updateColorAccent(i,a)),t.onSelect(a),r.hide(),document.removeEventListener("click",this.documentClickListener)}))}render(){var t;const e=this.config,i=this.node,n=i.find(".lake-dropdown-title");e.downIcon||n.addClass("lake-dropdown-title-no-down"),n.css("width",e.width);const s="string"==typeof e.tooltip?e.tooltip:e.tooltip(this.locale);n.attr("title",s);const o=n.find(".lake-dropdown-text"),r=n.find(".lake-dropdown-icon");e.icon&&r.append(e.icon),e.accentIcon&&r.append(e.accentIcon);const a=n.find(".lake-dropdown-down-icon");e.downIcon&&a.append(e.downIcon);const l=I('<ul class="lake-dropdown-menu" />');if(l.addClass(`lake-${e.menuType}-dropdown-menu`),De.setValue(i,[e.defaultValue]),o.length>0){const i=De.getMenuMap(e.menuItems,this.locale);o.text(null!==(t=i.get(e.defaultValue))&&void 0!==t?t:e.defaultValue)}"color"===e.menuType&&this.updateColorAccent(n,e.defaultValue),this.apppendMenuItems(l),i.append(n),i.append(l),this.root.append(i),this.bindEvents()}unmount(){this.node.remove(),document.removeEventListener("click",this.documentClickListener)}}var $e=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)},Ve="object"==typeof Rt&&Rt&&Rt.Object===Object&&Rt,Fe=Ve,je="object"==typeof self&&self&&self.Object===Object&&self,Re=Fe||je||Function("return this")(),We=Re,Ue=function(){return We.Date.now()},qe=/\s/;var Ke=function(t){for(var e=t.length;e--&&qe.test(t.charAt(e)););return e},Ge=Ke,Xe=/^\s+/;var Je=function(t){return t?t.slice(0,Ge(t)+1).replace(Xe,""):t},Qe=Re.Symbol,Ye=Qe,ti=Object.prototype,ei=ti.hasOwnProperty,ii=ti.toString,ni=Ye?Ye.toStringTag:void 0;var si=function(t){var e=ei.call(t,ni),i=t[ni];try{t[ni]=void 0;var n=!0}catch(t){}var s=ii.call(t);return n&&(e?t[ni]=i:delete t[ni]),s},oi=Object.prototype.toString;var ri=si,ai=function(t){return oi.call(t)},li=Qe?Qe.toStringTag:void 0;var ci=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":li&&li in Object(t)?ri(t):ai(t)};var hi=function(t){return null!=t&&"object"==typeof t},di=ci,pi=hi;var ui=Je,mi=$e,fi=function(t){return"symbol"==typeof t||pi(t)&&"[object Symbol]"==di(t)},gi=/^[-+]0x[0-9a-f]+$/i,vi=/^0b[01]+$/i,yi=/^0o[0-7]+$/i,wi=parseInt;var xi=$e,bi=Ue,ki=function(t){if("number"==typeof t)return t;if(fi(t))return NaN;if(mi(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=mi(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=ui(t);var i=vi.test(t);return i||yi.test(t)?wi(t.slice(2),i?2:8):gi.test(t)?NaN:+t},_i=Math.max,Si=Math.min;var Ci=function(t,e,i){var n,s,o,r,a,l,c=0,h=!1,d=!1,p=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function u(e){var i=n,o=s;return n=s=void 0,c=e,r=t.apply(o,i)}function m(t){var i=t-l;return void 0===l||i>=e||i<0||d&&t-c>=o}function f(){var t=bi();if(m(t))return g(t);a=setTimeout(f,function(t){var i=e-(t-l);return d?Si(i,o-(t-c)):i}(t))}function g(t){return a=void 0,p&&n?u(t):(n=s=void 0,r)}function v(){var t=bi(),i=m(t);if(n=arguments,s=this,l=t,i){if(void 0===a)return function(t){return c=t,a=setTimeout(f,e),h?u(t):r}(l);if(d)return clearTimeout(a),a=setTimeout(f,e),u(l)}return void 0===a&&(a=setTimeout(f,e)),r}return e=ki(e)||0,xi(i)&&(h=!!i.leading,o=(d="maxWait"in i)?_i(ki(i.maxWait)||0,e):o,p="trailing"in i?!!i.trailing:p),v.cancel=function(){void 0!==a&&clearTimeout(a),c=0,n=l=s=a=void 0},v.flush=function(){return void 0===a?r:g(bi())},v},Ai=Wt(Ci);var Bi=function(){this.__data__=[],this.size=0};var Ti=function(t,e){return t===e||t!=t&&e!=e},Ei=Ti;var Ii=function(t,e){for(var i=t.length;i--;)if(Ei(t[i][0],e))return i;return-1},Li=Ii,Mi=Array.prototype.splice;var Pi=function(t){var e=this.__data__,i=Li(e,t);return!(i<0)&&(i==e.length-1?e.pop():Mi.call(e,i,1),--this.size,!0)},Oi=Ii;var zi=function(t){var e=this.__data__,i=Oi(e,t);return i<0?void 0:e[i][1]},Zi=Ii;var Ni=Ii;var Hi=function(t,e){var i=this.__data__,n=Ni(i,t);return n<0?(++this.size,i.push([t,e])):i[n][1]=e,this},Di=Bi,$i=Pi,Vi=zi,Fi=function(t){return Zi(this.__data__,t)>-1},ji=Hi;function Ri(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var n=t[e];this.set(n[0],n[1])}}Ri.prototype.clear=Di,Ri.prototype.delete=$i,Ri.prototype.get=Vi,Ri.prototype.has=Fi,Ri.prototype.set=ji;var Wi=Ri,Ui=Wi;var qi=function(){this.__data__=new Ui,this.size=0};var Ki=function(t){var e=this.__data__,i=e.delete(t);return this.size=e.size,i};var Gi=function(t){return this.__data__.get(t)};var Xi=function(t){return this.__data__.has(t)},Ji=ci,Qi=$e;var Yi,tn=function(t){if(!Qi(t))return!1;var e=Ji(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e},en=Re["__core-js_shared__"],nn=(Yi=/[^.]+$/.exec(en&&en.keys&&en.keys.IE_PROTO||""))?"Symbol(src)_1."+Yi:"";var sn=function(t){return!!nn&&nn in t},on=Function.prototype.toString;var rn=function(t){if(null!=t){try{return on.call(t)}catch(t){}try{return t+""}catch(t){}}return""},an=tn,ln=sn,cn=$e,hn=rn,dn=/^\[object .+?Constructor\]$/,pn=Function.prototype,un=Object.prototype,mn=pn.toString,fn=un.hasOwnProperty,gn=RegExp("^"+mn.call(fn).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var vn=function(t){return!(!cn(t)||ln(t))&&(an(t)?gn:dn).test(hn(t))},yn=function(t,e){return null==t?void 0:t[e]};var wn=function(t,e){var i=yn(t,e);return vn(i)?i:void 0},xn=wn(Re,"Map"),bn=wn(Object,"create"),kn=bn;var _n=function(){this.__data__=kn?kn(null):{},this.size=0};var Sn=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},Cn=bn,An=Object.prototype.hasOwnProperty;var Bn=function(t){var e=this.__data__;if(Cn){var i=e[t];return"__lodash_hash_undefined__"===i?void 0:i}return An.call(e,t)?e[t]:void 0},Tn=bn,En=Object.prototype.hasOwnProperty;var In=bn;var Ln=_n,Mn=Sn,Pn=Bn,On=function(t){var e=this.__data__;return Tn?void 0!==e[t]:En.call(e,t)},zn=function(t,e){var i=this.__data__;return this.size+=this.has(t)?0:1,i[t]=In&&void 0===e?"__lodash_hash_undefined__":e,this};function Zn(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var n=t[e];this.set(n[0],n[1])}}Zn.prototype.clear=Ln,Zn.prototype.delete=Mn,Zn.prototype.get=Pn,Zn.prototype.has=On,Zn.prototype.set=zn;var Nn=Zn,Hn=Wi,Dn=xn;var $n=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t};var Vn=function(t,e){var i=t.__data__;return $n(e)?i["string"==typeof e?"string":"hash"]:i.map},Fn=Vn;var jn=Vn;var Rn=Vn;var Wn=Vn;var Un=function(){this.size=0,this.__data__={hash:new Nn,map:new(Dn||Hn),string:new Nn}},qn=function(t){var e=Fn(this,t).delete(t);return this.size-=e?1:0,e},Kn=function(t){return jn(this,t).get(t)},Gn=function(t){return Rn(this,t).has(t)},Xn=function(t,e){var i=Wn(this,t),n=i.size;return i.set(t,e),this.size+=i.size==n?0:1,this};function Jn(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var n=t[e];this.set(n[0],n[1])}}Jn.prototype.clear=Un,Jn.prototype.delete=qn,Jn.prototype.get=Kn,Jn.prototype.has=Gn,Jn.prototype.set=Xn;var Qn=Jn,Yn=Wi,ts=xn,es=Qn;var is=Wi,ns=qi,ss=Ki,os=Gi,rs=Xi,as=function(t,e){var i=this.__data__;if(i instanceof Yn){var n=i.__data__;if(!ts||n.length<199)return n.push([t,e]),this.size=++i.size,this;i=this.__data__=new es(n)}return i.set(t,e),this.size=i.size,this};function ls(t){var e=this.__data__=new is(t);this.size=e.size}ls.prototype.clear=ns,ls.prototype.delete=ss,ls.prototype.get=os,ls.prototype.has=rs,ls.prototype.set=as;var cs=ls;var hs=Qn,ds=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},ps=function(t){return this.__data__.has(t)};function us(t){var e=-1,i=null==t?0:t.length;for(this.__data__=new hs;++e<i;)this.add(t[e])}us.prototype.add=us.prototype.push=ds,us.prototype.has=ps;var ms=function(t,e){for(var i=-1,n=null==t?0:t.length;++i<n;)if(e(t[i],i,t))return!0;return!1};var fs=us,gs=ms,vs=function(t,e){return t.has(e)};var ys=function(t,e,i,n,s,o){var r=1&i,a=t.length,l=e.length;if(a!=l&&!(r&&l>a))return!1;var c=o.get(t),h=o.get(e);if(c&&h)return c==e&&h==t;var d=-1,p=!0,u=2&i?new fs:void 0;for(o.set(t,e),o.set(e,t);++d<a;){var m=t[d],f=e[d];if(n)var g=r?n(f,m,d,e,t,o):n(m,f,d,t,e,o);if(void 0!==g){if(g)continue;p=!1;break}if(u){if(!gs(e,(function(t,e){if(!vs(u,e)&&(m===t||s(m,t,i,n,o)))return u.push(e)}))){p=!1;break}}else if(m!==f&&!s(m,f,i,n,o)){p=!1;break}}return o.delete(t),o.delete(e),p};var ws=function(t){var e=-1,i=Array(t.size);return t.forEach((function(t,n){i[++e]=[n,t]})),i};var xs=function(t){var e=-1,i=Array(t.size);return t.forEach((function(t){i[++e]=t})),i},bs=Re.Uint8Array,ks=Ti,_s=ys,Ss=ws,Cs=xs,As=Qe?Qe.prototype:void 0,Bs=As?As.valueOf:void 0;var Ts=function(t,e,i,n,s,o,r){switch(i){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=e.byteLength||!o(new bs(t),new bs(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return ks(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case"[object Map]":var a=Ss;case"[object Set]":var l=1&n;if(a||(a=Cs),t.size!=e.size&&!l)return!1;var c=r.get(t);if(c)return c==e;n|=2,r.set(t,e);var h=_s(a(t),a(e),n,s,o,r);return r.delete(t),h;case"[object Symbol]":if(Bs)return Bs.call(t)==Bs.call(e)}return!1};var Es=function(t,e){for(var i=-1,n=e.length,s=t.length;++i<n;)t[s+i]=e[i];return t},Is=Array.isArray,Ls=Es,Ms=Is;var Ps=function(t,e,i){var n=e(t);return Ms(t)?n:Ls(n,i(t))};var Os=function(t,e){for(var i=-1,n=null==t?0:t.length,s=0,o=[];++i<n;){var r=t[i];e(r,i,t)&&(o[s++]=r)}return o};var zs=Os,Zs=function(){return[]},Ns=Object.prototype.propertyIsEnumerable,Hs=Object.getOwnPropertySymbols,Ds=Hs?function(t){return null==t?[]:(t=Object(t),zs(Hs(t),(function(e){return Ns.call(t,e)})))}:Zs;var $s=function(t,e){for(var i=-1,n=Array(t);++i<t;)n[i]=e(i);return n},Vs=ci,Fs=hi;var js=function(t){return Fs(t)&&"[object Arguments]"==Vs(t)},Rs=hi,Ws=Object.prototype,Us=Ws.hasOwnProperty,qs=Ws.propertyIsEnumerable,Ks=js(function(){return arguments}())?js:function(t){return Rs(t)&&Us.call(t,"callee")&&!qs.call(t,"callee")},Gs=Ks,Xs={exports:{}};var Js=function(){return!1};!function(t,e){var i=Re,n=Js,s=e&&!e.nodeType&&e,o=s&&t&&!t.nodeType&&t,r=o&&o.exports===s?i.Buffer:void 0,a=(r?r.isBuffer:void 0)||n;t.exports=a}(Xs,Xs.exports);var Qs=Xs.exports,Ys=/^(?:0|[1-9]\d*)$/;var to=function(t,e){var i=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==i||"symbol"!=i&&Ys.test(t))&&t>-1&&t%1==0&&t<e};var eo=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991},io=ci,no=eo,so=hi,oo={};oo["[object Float32Array]"]=oo["[object Float64Array]"]=oo["[object Int8Array]"]=oo["[object Int16Array]"]=oo["[object Int32Array]"]=oo["[object Uint8Array]"]=oo["[object Uint8ClampedArray]"]=oo["[object Uint16Array]"]=oo["[object Uint32Array]"]=!0,oo["[object Arguments]"]=oo["[object Array]"]=oo["[object ArrayBuffer]"]=oo["[object Boolean]"]=oo["[object DataView]"]=oo["[object Date]"]=oo["[object Error]"]=oo["[object Function]"]=oo["[object Map]"]=oo["[object Number]"]=oo["[object Object]"]=oo["[object RegExp]"]=oo["[object Set]"]=oo["[object String]"]=oo["[object WeakMap]"]=!1;var ro=function(t){return so(t)&&no(t.length)&&!!oo[io(t)]};var ao=function(t){return function(e){return t(e)}},lo={exports:{}};!function(t,e){var i=Ve,n=e&&!e.nodeType&&e,s=n&&t&&!t.nodeType&&t,o=s&&s.exports===n&&i.process,r=function(){try{var t=s&&s.require&&s.require("util").types;return t||o&&o.binding&&o.binding("util")}catch(t){}}();t.exports=r}(lo,lo.exports);var co=lo.exports,ho=ro,po=ao,uo=co&&co.isTypedArray,mo=uo?po(uo):ho,fo=$s,go=Gs,vo=Is,yo=Qs,wo=to,xo=mo,bo=Object.prototype.hasOwnProperty;var ko=function(t,e){var i=vo(t),n=!i&&go(t),s=!i&&!n&&yo(t),o=!i&&!n&&!s&&xo(t),r=i||n||s||o,a=r?fo(t.length,String):[],l=a.length;for(var c in t)!e&&!bo.call(t,c)||r&&("length"==c||s&&("offset"==c||"parent"==c)||o&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||wo(c,l))||a.push(c);return a},_o=Object.prototype;var So=function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||_o)};var Co=function(t,e){return function(i){return t(e(i))}}(Object.keys,Object),Ao=So,Bo=Co,To=Object.prototype.hasOwnProperty;var Eo=tn,Io=eo;var Lo=ko,Mo=function(t){if(!Ao(t))return Bo(t);var e=[];for(var i in Object(t))To.call(t,i)&&"constructor"!=i&&e.push(i);return e},Po=function(t){return null!=t&&Io(t.length)&&!Eo(t)};var Oo=Ps,zo=Ds,Zo=function(t){return Po(t)?Lo(t):Mo(t)};var No=function(t){return Oo(t,Zo,zo)},Ho=Object.prototype.hasOwnProperty;var Do=function(t,e,i,n,s,o){var r=1&i,a=No(t),l=a.length;if(l!=No(e).length&&!r)return!1;for(var c=l;c--;){var h=a[c];if(!(r?h in e:Ho.call(e,h)))return!1}var d=o.get(t),p=o.get(e);if(d&&p)return d==e&&p==t;var u=!0;o.set(t,e),o.set(e,t);for(var m=r;++c<l;){var f=t[h=a[c]],g=e[h];if(n)var v=r?n(g,f,h,e,t,o):n(f,g,h,t,e,o);if(!(void 0===v?f===g||s(f,g,i,n,o):v)){u=!1;break}m||(m="constructor"==h)}if(u&&!m){var y=t.constructor,w=e.constructor;y==w||!("constructor"in t)||!("constructor"in e)||"function"==typeof y&&y instanceof y&&"function"==typeof w&&w instanceof w||(u=!1)}return o.delete(t),o.delete(e),u},$o=wn(Re,"DataView"),Vo=xn,Fo=wn(Re,"Promise"),jo=wn(Re,"Set"),Ro=wn(Re,"WeakMap"),Wo=ci,Uo=rn,qo="[object Map]",Ko="[object Promise]",Go="[object Set]",Xo="[object WeakMap]",Jo="[object DataView]",Qo=Uo($o),Yo=Uo(Vo),tr=Uo(Fo),er=Uo(jo),ir=Uo(Ro),nr=Wo;($o&&nr(new $o(new ArrayBuffer(1)))!=Jo||Vo&&nr(new Vo)!=qo||Fo&&nr(Fo.resolve())!=Ko||jo&&nr(new jo)!=Go||Ro&&nr(new Ro)!=Xo)&&(nr=function(t){var e=Wo(t),i="[object Object]"==e?t.constructor:void 0,n=i?Uo(i):"";if(n)switch(n){case Qo:return Jo;case Yo:return qo;case tr:return Ko;case er:return Go;case ir:return Xo}return e});var sr=cs,or=ys,rr=Ts,ar=Do,lr=nr,cr=Is,hr=Qs,dr=mo,pr="[object Arguments]",ur="[object Array]",mr="[object Object]",fr=Object.prototype.hasOwnProperty;var gr=function(t,e,i,n,s,o){var r=cr(t),a=cr(e),l=r?ur:lr(t),c=a?ur:lr(e),h=(l=l==pr?mr:l)==mr,d=(c=c==pr?mr:c)==mr,p=l==c;if(p&&hr(t)){if(!hr(e))return!1;r=!0,h=!1}if(p&&!h)return o||(o=new sr),r||dr(t)?or(t,e,i,n,s,o):rr(t,e,l,i,n,s,o);if(!(1&i)){var u=h&&fr.call(t,"__wrapped__"),m=d&&fr.call(e,"__wrapped__");if(u||m){var f=u?t.value():t,g=m?e.value():e;return o||(o=new sr),s(f,g,i,n,o)}}return!!p&&(o||(o=new sr),ar(t,e,i,n,s,o))},vr=hi;var yr=function t(e,i,n,s,o){return e===i||(null==e||null==i||!vr(e)&&!vr(i)?e!=e&&i!=i:gr(e,i,n,s,t,o))},wr=yr;var xr=Wt((function(t,e){return wr(t,e)}));function br(t){const e=t.get(0),i={};if(e.hasAttributes())for(const t of e.attributes)i[t.name]=t.value;return i}class kr{constructor(t){const e=window.getSelection();if(!e)throw new Error("Selection object is null.");this.selection=e,this.container=t,this.range=this.getRangeFromNativeSelection()}getRangeFromNativeSelection(){if(this.selection.rangeCount>0){const t=this.selection.getRangeAt(0);return new L(t)}return new L}addRangeToNativeSelection(){this.selection.removeAllRanges(),this.selection.addRange(this.range.get())}syncByRange(){const t=this.getRangeFromNativeSelection();this.range.get()!==t.get()&&(this.range=t)}synByBookmark(){const t=this.range,e=this.container,i=e.find("lake-box[focus]");if(i.length>0)return ae(t,{anchor:new E,focus:i}),void this.addRangeToNativeSelection();ae(t,{anchor:e.find('lake-bookmark[type="anchor"]'),focus:e.find('lake-bookmark[type="focus"]')}),this.addRangeToNativeSelection()}getAppliedItems(){const t=[];return function(t,e){let i=e.startNode;for(i.isText&&(i=i.parent());i.length>0&&i.isInside;)t.push({node:i,name:i.name,attributes:br(i),styles:p(i.attr("style"))}),i=i.parent()}(t,this.range),function(t,e){const i=e.startNode;let n;if(i.isText&&i.text().length===e.startOffset){const t=i.next();t.length>0&&t.isElement&&(n=t)}if(i.isElement){const t=i.children();if(t.length>0){const i=t[e.startOffset];i&&i.isElement&&(n=i)}}if(n){let e=n;for(;e.length>0;)e.isElement&&t.push({node:e,name:e.name,attributes:br(e),styles:p(e.attr("style"))}),e=e.first()}}(t,this.range),t}insertBookmark(){return oe(this.range)}toBookmark(t){return ae(this.range,t)}insertNode(t){return se(this.range,t)}insertFragment(t){return he(this.range,t)}insertContents(t){return de(this.range,t)}deleteContents(){return ce(this.range)}setBlocks(t){return pe(this.range,t)}splitBlock(){return ue(this.range)}splitMarks(t){return ge(this.range,t)}addMark(t){return ye(this.range,t)}removeMark(t){return xe(this.range,t)}fixList(){return le(this.range)}insertLink(t){return be(this.range,t)}}class _r{constructor(t){this.commandMap=new Map,this.event=new qt,this.selection=t}add(t,e){this.commandMap.set(t,e)}delete(t){this.commandMap.delete(t)}getNames(){return Array.from(this.commandMap.keys())}has(t){return void 0!==this.commandMap.get(t)}getItem(t){const e=this.commandMap.get(t);if(void 0===e)throw new Error(`Command '${t}' does not exist.`);return e}isDisabled(t){const e=this.getItem(t);if(!e.isDisabled)return!1;const i=this.selection.getAppliedItems();return e.isDisabled(i)}isSelected(t){const e=this.getItem(t);if(!e.isSelected)return!1;const i=this.selection.getAppliedItems();return e.isSelected(i)}selectedValues(t){const e=this.getItem(t);if(!e.selectedValues)return[];const i=this.selection.getAppliedItems();return e.selectedValues(i)}execute(t,...e){const i=this.getItem(t);this.event.emit("beforeexecute",t),i.execute.apply(this,e),this.event.emit("execute",t),A(`Command '${t}' executed`)}}var Sr,Cr={exports:{}};Sr=Cr,function(t){function e(t,e){var i=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(i>>16)<<16|65535&i}function i(t,i,n,s,o,r){return e((a=e(e(i,t),e(s,r)))<<(l=o)|a>>>32-l,n);var a,l}function n(t,e,n,s,o,r,a){return i(e&n|~e&s,t,e,o,r,a)}function s(t,e,n,s,o,r,a){return i(e&s|n&~s,t,e,o,r,a)}function o(t,e,n,s,o,r,a){return i(e^n^s,t,e,o,r,a)}function r(t,e,n,s,o,r,a){return i(n^(e|~s),t,e,o,r,a)}function a(t,i){var a,l,c,h,d;t[i>>5]|=128<<i%32,t[14+(i+64>>>9<<4)]=i;var p=1732584193,u=-271733879,m=-1732584194,f=271733878;for(a=0;a<t.length;a+=16)l=p,c=u,h=m,d=f,p=n(p,u,m,f,t[a],7,-680876936),f=n(f,p,u,m,t[a+1],12,-389564586),m=n(m,f,p,u,t[a+2],17,606105819),u=n(u,m,f,p,t[a+3],22,-1044525330),p=n(p,u,m,f,t[a+4],7,-176418897),f=n(f,p,u,m,t[a+5],12,1200080426),m=n(m,f,p,u,t[a+6],17,-1473231341),u=n(u,m,f,p,t[a+7],22,-45705983),p=n(p,u,m,f,t[a+8],7,1770035416),f=n(f,p,u,m,t[a+9],12,-1958414417),m=n(m,f,p,u,t[a+10],17,-42063),u=n(u,m,f,p,t[a+11],22,-1990404162),p=n(p,u,m,f,t[a+12],7,1804603682),f=n(f,p,u,m,t[a+13],12,-40341101),m=n(m,f,p,u,t[a+14],17,-1502002290),p=s(p,u=n(u,m,f,p,t[a+15],22,1236535329),m,f,t[a+1],5,-165796510),f=s(f,p,u,m,t[a+6],9,-1069501632),m=s(m,f,p,u,t[a+11],14,643717713),u=s(u,m,f,p,t[a],20,-373897302),p=s(p,u,m,f,t[a+5],5,-701558691),f=s(f,p,u,m,t[a+10],9,38016083),m=s(m,f,p,u,t[a+15],14,-660478335),u=s(u,m,f,p,t[a+4],20,-405537848),p=s(p,u,m,f,t[a+9],5,568446438),f=s(f,p,u,m,t[a+14],9,-1019803690),m=s(m,f,p,u,t[a+3],14,-187363961),u=s(u,m,f,p,t[a+8],20,1163531501),p=s(p,u,m,f,t[a+13],5,-1444681467),f=s(f,p,u,m,t[a+2],9,-51403784),m=s(m,f,p,u,t[a+7],14,1735328473),p=o(p,u=s(u,m,f,p,t[a+12],20,-1926607734),m,f,t[a+5],4,-378558),f=o(f,p,u,m,t[a+8],11,-2022574463),m=o(m,f,p,u,t[a+11],16,1839030562),u=o(u,m,f,p,t[a+14],23,-35309556),p=o(p,u,m,f,t[a+1],4,-1530992060),f=o(f,p,u,m,t[a+4],11,1272893353),m=o(m,f,p,u,t[a+7],16,-155497632),u=o(u,m,f,p,t[a+10],23,-1094730640),p=o(p,u,m,f,t[a+13],4,681279174),f=o(f,p,u,m,t[a],11,-358537222),m=o(m,f,p,u,t[a+3],16,-722521979),u=o(u,m,f,p,t[a+6],23,76029189),p=o(p,u,m,f,t[a+9],4,-640364487),f=o(f,p,u,m,t[a+12],11,-421815835),m=o(m,f,p,u,t[a+15],16,530742520),p=r(p,u=o(u,m,f,p,t[a+2],23,-995338651),m,f,t[a],6,-198630844),f=r(f,p,u,m,t[a+7],10,1126891415),m=r(m,f,p,u,t[a+14],15,-1416354905),u=r(u,m,f,p,t[a+5],21,-57434055),p=r(p,u,m,f,t[a+12],6,1700485571),f=r(f,p,u,m,t[a+3],10,-1894986606),m=r(m,f,p,u,t[a+10],15,-1051523),u=r(u,m,f,p,t[a+1],21,-2054922799),p=r(p,u,m,f,t[a+8],6,1873313359),f=r(f,p,u,m,t[a+15],10,-30611744),m=r(m,f,p,u,t[a+6],15,-1560198380),u=r(u,m,f,p,t[a+13],21,1309151649),p=r(p,u,m,f,t[a+4],6,-145523070),f=r(f,p,u,m,t[a+11],10,-1120210379),m=r(m,f,p,u,t[a+2],15,718787259),u=r(u,m,f,p,t[a+9],21,-343485551),p=e(p,l),u=e(u,c),m=e(m,h),f=e(f,d);return[p,u,m,f]}function l(t){var e,i="",n=32*t.length;for(e=0;e<n;e+=8)i+=String.fromCharCode(t[e>>5]>>>e%32&255);return i}function c(t){var e,i=[];for(i[(t.length>>2)-1]=void 0,e=0;e<i.length;e+=1)i[e]=0;var n=8*t.length;for(e=0;e<n;e+=8)i[e>>5]|=(255&t.charCodeAt(e/8))<<e%32;return i}function h(t){var e,i,n="0123456789abcdef",s="";for(i=0;i<t.length;i+=1)e=t.charCodeAt(i),s+=n.charAt(e>>>4&15)+n.charAt(15&e);return s}function d(t){return unescape(encodeURIComponent(t))}function p(t){return function(t){return l(a(c(t),8*t.length))}(d(t))}function u(t,e){return function(t,e){var i,n,s=c(t),o=[],r=[];for(o[15]=r[15]=void 0,s.length>16&&(s=a(s,8*t.length)),i=0;i<16;i+=1)o[i]=909522486^s[i],r[i]=1549556828^s[i];return n=a(o.concat(c(e)),512+8*e.length),l(a(r.concat(n),640))}(d(t),d(e))}function m(t,e,i){return e?i?u(e,t):h(u(e,t)):i?p(t):h(p(t))}Sr.exports?Sr.exports=m:t.md5=m}(Rt);var Ar=Wt(Cr.exports);const Br=new Map;class Tr{constructor(t){this.list=[],this.index=0,this.canSave=!0,this.limit=100,this.event=new qt,this.selection=t,this.container=t.container}removeBookmark(t){return t.replace(/(<lake-box[^>]+)\s+focus="\w+"([^>]*>)/gi,"$1$2").replace(/<lake-bookmark\s+type="anchor">\s*<\/lake-bookmark>/gi,"").replace(/<lake-bookmark\s+type="focus">\s*<\/lake-bookmark>/gi,"")}getValue(t){return new ie(t).getHTML()}addIdToBoxes(t){t.find("lake-box").each((t=>{const e=new E(t),i=Ar(`${e.attr("type")}-${e.attr("name")}-${e.attr("value")}`);e.attr("id",i)}))}removeIdfromBoxes(t){t.find("lake-box").each((t=>{new E(t).removeAttr("id")}))}morphContainer(t){const e=this.container,i={beforeChildrenUpdated:t=>{if("lake-box"===new E(t).name)return!1},afterAttributeUpdated:(t,i)=>{const n=new E(i);if("value"===t&&"lake-box"===n.name){const t=Br.get(e.id);if(!t)return;t.delete(n.id)}}},n=t.clone(!0);this.addIdToBoxes(e),this.addIdToBoxes(n),ht(e,n,{callbacks:i}),this.removeIdfromBoxes(e),this.removeIdfromBoxes(n)}cloneContainer(){const t=this.selection.range,e=this.container.clone(!0);if(e.find("lake-box").each((t=>{new Yt(t).getContainer().empty()})),t.commonAncestor.isOutside)return e;if(t.isInsideBox)return e;const i=t.startNode.path(),n=t.endNode.path(),s=e.find(i),o=e.find(n),r=t.clone();return r.setStart(s,t.startOffset),r.setEnd(o,t.endOffset),oe(r),e}get count(){return this.list.length}get canUndo(){return this.index>1&&!!this.list[this.index-1]}get canRedo(){return!!this.list[this.index]}undo(){if(!this.list[this.index-1])return;this.selection.insertBookmark();const t=this.getValue(this.container);for(;this.index>0;){const e=this.list[this.index-1];if(!e)break;const i=this.getValue(e);if(this.removeBookmark(i)!==this.removeBookmark(t)){this.morphContainer(e),this.event.emit("undo",i);break}if(1===this.index)break;this.index--}this.selection.synByBookmark(),A(`History undone, the last index is ${this.index}`)}redo(){if(!this.list[this.index])return;this.selection.insertBookmark();const t=this.getValue(this.container);for(;this.index<this.list.length;){const e=this.list[this.index];if(!e)break;this.index++;const i=this.getValue(e);if(this.removeBookmark(i)!==this.removeBookmark(t)){this.morphContainer(e),this.event.emit("redo",i);break}}this.selection.synByBookmark(),A(`History redone, the last index is ${this.index}`)}continue(){this.canSave=!0}pause(){this.canSave=!1}save(t=!0){if(!this.canSave)return;const e=this.cloneContainer(),i=this.getValue(e);this.list[this.index-1]&&this.removeBookmark(this.getValue(this.list[this.index-1]))===this.removeBookmark(i)||(this.list.splice(this.index,1/0,e),this.index++,this.list.length>this.limit&&(this.list.shift(),this.index=this.list.length),t&&this.event.emit("save",m(i)),A(`History saved, the last index is ${this.index}`))}}var Er=["Shift","Meta","Alt","Control"],Ir="object"==typeof navigator?navigator.platform:"",Lr=/Mac|iPod|iPhone|iPad/.test(Ir),Mr=Lr?"Meta":"Control",Pr="Win32"===Ir?["Control","Alt"]:Lr?["Alt"]:[];function Or(t,e){return"function"==typeof t.getModifierState&&(t.getModifierState(e)||Pr.includes(e)&&t.getModifierState("AltGraph"))}function zr(t){return t.trim().split(" ").map((function(t){var e=t.split(/\b\+/),i=e.pop();return[e=e.map((function(t){return"$mod"===t?Mr:t})),i]}))}function Zr(t,e){var i;void 0===e&&(e={});var n=null!=(i=e.timeout)?i:1e3,s=Object.keys(t).map((function(e){return[zr(e),t[e]]})),o=new Map,r=null;return function(t){t instanceof KeyboardEvent&&(s.forEach((function(e){var i=e[0],n=e[1],s=o.get(i)||i;!function(t,e){return!(e[1].toUpperCase()!==t.key.toUpperCase()&&e[1]!==t.code||e[0].find((function(e){return!Or(t,e)}))||Er.find((function(i){return!e[0].includes(i)&&e[1]!==i&&Or(t,i)})))}(t,s[0])?Or(t,t.key)||o.delete(i):s.length>1?o.set(i,s.slice(1)):(o.delete(i),n(t))})),r&&clearTimeout(r),r=setTimeout(o.clear.bind(o),n))}}const Nr=new Map([["#","shift+#"]]);class Hr{constructor(t){this.keydownEventList=[],this.keyupEventList=[],this.container=t}normalizeType(t){var e;return t=(t=null!==(e=Nr.get(t))&&void 0!==e?e:t).replace(/(^|\+|\s)mod(\+|\s|$)/g,"$1$mod$2").replace(/shift|control|alt|meta|enter|tab|backspace|delete|space|escape|arrow-left|arrow-right|arrow-up|arrow-down/,(t=>t.charAt(0).toUpperCase()+l(t.substring(1)))).replace(/(^|\+|\s)([a-z])(\+|\s|$)/g,((t,e,i,n)=>`${e}Key${i.toUpperCase()}${n}`))}setKeydown(t,e){t=this.normalizeType(t);const i=Zr({[t]:t=>e(t)});this.keydownEventList.push({type:t,listener:e}),this.container.on("keydown",i)}setKeyup(t,e){t=this.normalizeType(t);const i=Zr({[t]:t=>e(t)});this.keyupEventList.push({type:t,listener:e}),this.container.on("keyup",i)}keydown(t){t=this.normalizeType(t);for(const e of this.keydownEventList)if(e.type===t&&!1===e.listener(new Event(t)))break}keyup(t){t=this.normalizeType(t);for(const e of this.keyupEventList)if(e.type===t&&!1===e.listener(new Event(t)))break}}const Dr={value:"<p><br /></p>",readonly:!1,spellcheck:!1,tabIndex:0,indentWithTab:!0,lang:"en-US",minChangeSize:5};class $r{constructor(t){if(this.unsavedInputData="",this.state={appliedItems:[],disabledNameMap:new Map,selectedNameMap:new Map,selectedValuesMap:new Map},this.isComposing=!1,this.event=new qt,this.box=$r.box,this.beforeunloadListener=()=>{this.history.save()},this.selectionchangeListener=()=>{this.selection.syncByRange(),this.updateBoxSelectionStyle(),this.emitStateChangeEvent()},this.clickListener=t=>{const e=new E(t.target);e.closest(".lake-popup").length>0||this.event.emit("click",e)},this.resizeListener=()=>{this.event.emit("resize")},this.updateBoxSelectionStyle=Ai((()=>{if(0===this.root.first().length)return;const t=this.selection.range,e=t.clone();e.adaptBox(),this.box.findAll(this).each((i=>{const n=new Yt(i),s=n.getContainer();if(0!==s.length){if(t.compareBeforeNode(s)<0&&t.compareAfterNode(s)>0&&(!t.isCollapsed||t.startNode.get(0)!==s.get(0)||0!==t.startOffset))return s.removeClass("lake-box-hovered"),s.removeClass("lake-box-selected"),s.removeClass("lake-box-focused"),void s.addClass("lake-box-activated");if(e.intersectsNode(n.node))return s.removeClass("lake-box-activated"),void(t.isCollapsed?(s.removeClass("lake-box-hovered"),s.removeClass("lake-box-selected"),s.addClass("lake-box-focused")):(s.removeClass("lake-box-focused"),s.addClass("lake-box-selected")));s.removeClass("lake-box-activated"),s.removeClass("lake-box-focused"),s.removeClass("lake-box-selected")}})),this.event.emit("boxselectionstylechange")}),50,{leading:!1,trailing:!0,maxWait:50}),this.emitStateChangeEvent=Ai((()=>{const t=this.command.getNames();let e=this.selection.getAppliedItems();e.length>0&&e[0].node.closestContainer().get(0)!==this.container.get(0)&&(e=[]);const i=new Map,n=new Map,s=new Map;if(e.length>0)for(const o of t){const t=this.command.getItem(o);if(t.isDisabled&&t.isDisabled(e)&&i.set(o,!0),t.isSelected&&t.isSelected(e)&&n.set(o,!0),t.selectedValues){const i=t.selectedValues(e);i.length>0&&s.set(o,i)}}const o={appliedItems:e,disabledNameMap:i,selectedNameMap:n,selectedValuesMap:s};xr(o,this.state)||(this.toolbar&&this.toolbar.updateState(o),this.event.emit("statechange",o),this.state=o)}),100,{leading:!1,trailing:!0,maxWait:100}),this.emitChangeEvent=t=>{this.rectifyContent(),this.emitStateChangeEvent(),this.event.emit("change",t)},!t.root)throw new Error("The root of the config must be specified.");this.root=I(t.root),this.toolbar=t.toolbar,this.config=Object.assign({},Dr);for(const e of Object.keys(t))this.config[e]=t[e];this.containerWrapper=I('<div class="lake-container-wrapper" />'),this.container=I('<div class="lake-container" />'),this.overlayContainer=I('<div class="lake-overlay" />'),this.popupContainer=I('<div class="lake-popup lake-custom-properties" />'),this.readonly=this.config.readonly,this.root.addClass("lake-custom-properties"),this.container.attr({contenteditable:this.readonly?"false":"true",spellcheck:this.config.spellcheck?"true":"false",tabindex:this.config.tabIndex.toString()}),this.selection=new kr(this.container),this.command=new _r(this.selection),this.history=new Tr(this.selection),this.keystroke=new Hr(this.container),Gt.set(this.container.id,this)}inputInBoxStrip(){const t=this.selection,e=t.range,i=e.startNode.closest(".lake-box-strip"),n=i.closest("lake-box");if("inline"===new Yt(n).type)e.isBoxStart?(e.setStartBefore(n),e.collapseToStart()):(e.setStartAfter(n),e.collapseToStart());else{const t=I("<p />");e.isBoxStart?n.before(t):n.after(t),e.shrinkAfter(t)}const s=i.text();i.html("<br />"),t.insertNode(document.createTextNode(s))}bindInputEvents(){this.container.on("compositionstart",(()=>{this.isComposing=!0})),this.container.on("compositionend",(()=>{this.isComposing=!1})),this.container.on("beforeinput",(t=>{const e=t,i=this.selection.range;(i.isBoxStart||i.isBoxEnd||"insertText"!==e.inputType&&"insertCompositionText"!==e.inputType)&&this.commitUnsavedInputData()})),this.container.on("input",(t=>{const e=t;window.setTimeout((()=>{var t;const i=this.selection.range;if(!i.isInsideBox)if(this.isComposing)this.event.emit("input",e);else{if(i.isBoxStart||i.isBoxEnd)return this.inputInBoxStrip(),this.history.save(),void this.event.emit("input",e);if(("insertText"===e.inputType||"insertCompositionText"===e.inputType)&&(this.unsavedInputData+=null!==(t=e.data)&&void 0!==t?t:"",this.unsavedInputData.length<this.config.minChangeSize))return this.event.emit("input",e),void this.emitChangeEvent(this.getValue());this.history.save(),this.event.emit("input",e)}}),0)})),this.command.event.on("beforeexecute",(()=>this.commitUnsavedInputData()))}bindHistoryEvents(){this.history.event.on("undo",(t=>{this.box.renderAll(this),this.emitChangeEvent(t)})),this.history.event.on("redo",(t=>{this.box.renderAll(this),this.emitChangeEvent(t)})),this.history.event.on("save",(t=>{this.box.rectifyInstances(this),this.emitChangeEvent(t)}))}get hasFocus(){const t=document.activeElement;return!!t&&I(t).closest(".lake-container").get(0)===this.container.get(0)}get locale(){return He(this.config.lang)}rectifyContent(){let t=this.container.children();for(const e of t)(e.isBlock||e.isMark)&&""===e.html()&&(e.remove(),A("Rectifying content: empty tag was removed"));if(t=this.container.children(),0===t.length)return this.container.html("<p><br /></p>"),this.selection.range.shrinkAfter(this.container),void A("Rectifying content: default paragraph was added");if(1===t.length){const e=t[0];if(e.isVoid){const t=I("<p />");e.before(t),t.append(e),this.selection.range.shrinkAfter(t),A("Rectifying content: void element was wrapped in paragraph")}}}commitUnsavedInputData(){this.unsavedInputData.length>0&&(this.history.save(!1),this.unsavedInputData="")}prepareOperation(){this.commitUnsavedInputData(),this.history.pause()}commitOperation(){this.history.continue(),this.history.save()}setPluginConfig(t,e){this.config[t]||(this.config[t]={});for(const i of Object.keys(e))void 0===this.config[t][i]&&(this.config[t][i]=e[i])}focus(){this.container.focus()}blur(){this.container.blur()}setValue(t){t=u(t);const e=new ie(t).getFragment();this.container.empty(),this.container.append(e),$r.box.renderAll(this),this.selection.synByBookmark()}getValue(){const t=this.selection.insertBookmark();let e=new ie(this.container).getHTML();return e=m(e),this.selection.toBookmark(t),e}insertBox(t,e){const i=function(t,e,i){if(t.commonAncestor.isOutside)return null;const n=new Yt(e);i&&(n.value=i);const s=document.createDocumentFragment();if(s.appendChild(n.node.get(0)),"inline"===n.type)return he(t,s),n.render(),t.selectBoxEnd(n.node),n;const o=ue(t);return o.start&&(t.setEndAfter(o.start),t.collapseToEnd()),o.end&&o.end.isEmpty&&o.end.remove(),he(t,s),n.render(),t.selectBoxEnd(n.node),o.start&&o.start.isEmpty&&o.start.remove(),n}(this.selection.range,t,e);if(!i)throw new Error(`Box '${t}' cannot be inserted outside the editor.`);return this.box.getInstances(this).set(i.node.id,i),i}removeBox(){const t=function(t){if(t.commonAncestor.isOutside)return null;const e=t.commonAncestor.closest("lake-box");if(0===e.length)return null;const i=new Yt(e);if("block"===i.type){const n=I("<p><br /></p>");return e.before(n),t.shrinkAfter(n),i.unmount(),e.remove(),i}t.setStartBefore(e),t.collapseToStart();const n=e.parent();return i.unmount(),e.remove(),n.isEmpty&&(P(n,I("<br />")),t.shrinkAfter(n)),i}(this.selection.range);if(t){this.box.getInstances(this).delete(t.node.id)}return t}render(){const t=u(this.config.value),e=new ie(t).getFragment();this.root.empty(),this.root.append(this.containerWrapper),this.containerWrapper.append(this.container),this.containerWrapper.append(this.overlayContainer),I(document.body).append(this.popupContainer),this.container.append(e),$r.plugin.loadAll(this),this.readonly||(this.selection.synByBookmark(),this.history.save()),$r.box.renderAll(this),this.toolbar&&this.toolbar.render(this),this.readonly||(window.addEventListener("beforeunload",this.beforeunloadListener),document.addEventListener("selectionchange",this.selectionchangeListener),document.addEventListener("click",this.clickListener),window.addEventListener("resize",this.resizeListener),this.bindInputEvents(),this.bindHistoryEvents())}unmount(){this.root.empty(),this.popupContainer.remove(),this.readonly||(window.removeEventListener("beforeunload",this.beforeunloadListener),document.removeEventListener("selectionchange",this.selectionchangeListener),document.removeEventListener("click",this.clickListener),window.removeEventListener("resize",this.resizeListener))}}$r.version="0.1.5",$r.box=new class{add(t){Kt.set(t.name,t)}remove(t){Kt.delete(t)}getNames(){return Array.from(Kt.keys())}getInstances(t){let e=Br.get(t.container.id);return e||(e=new Map,Br.set(t.container.id,e),e)}rectifyInstances(t){const e=this.getInstances(t);for(const t of e.values())t.node.get(0).isConnected||(t.unmount(),e.delete(t.node.id))}findAll(t){return t.container.find("lake-box")}renderAll(t){this.rectifyInstances(t);const e=this.getInstances(t);this.findAll(t).each((t=>{const i=new E(t);if(e.get(i.id))return;const n=new Yt(i);n.render(),e.set(n.node.id,n)}))}},$r.plugin=new class{constructor(){this.pluginList=[]}add(t){this.pluginList.push(t)}loadAll(t){this.pluginList.forEach((e=>{e(t)}))}};const Vr=[{icon:n.get("numberedList"),value:"numbered",text:t=>t.toolbar.numberedList()},{icon:n.get("bulletedList"),value:"bulleted",text:t=>t.toolbar.bulletedList()},{icon:n.get("checklist"),value:"checklist",text:t=>t.toolbar.checklist()}],Fr=[{icon:n.get("alignLeft"),value:"left",text:t=>t.toolbar.alignLeft()},{icon:n.get("alignCenter"),value:"center",text:t=>t.toolbar.alignCenter()},{icon:n.get("alignRight"),value:"right",text:t=>t.toolbar.alignRight()},{icon:n.get("alignJustify"),value:"justify",text:t=>t.toolbar.alignJustify()}],jr=[{icon:n.get("increaseIndent"),value:"increase",text:t=>t.toolbar.increaseIndent()},{icon:n.get("decreaseIndent"),value:"decrease",text:t=>t.toolbar.decreaseIndent()}],Rr=[{icon:n.get("italic"),value:"italic",text:t=>t.toolbar.italic()},{icon:n.get("underline"),value:"underline",text:t=>t.toolbar.underline()},{icon:n.get("strikethrough"),value:"strikethrough",text:t=>t.toolbar.strikethrough()},{icon:n.get("superscript"),value:"superscript",text:t=>t.toolbar.superscript()},{icon:n.get("subscript"),value:"subscript",text:t=>t.toolbar.subscript()},{icon:n.get("code"),value:"code",text:t=>t.toolbar.code()}],Wr=["#f5222d","#fa541c","#fa8c16","#faad14","#fadb14","#a0d911","#52c41a","#13c2c2","#1677ff","#2f54eb","#722ed1","#eb2f96","#fff1f0","#fff2e8","#fff7e6","#fffbe6","#feffe6","#fcffe6","#f6ffed","#e6fffb","#e6f4ff","#f0f5ff","#f9f0ff","#fff0f6","#ffccc7","#ffd8bf","#ffe7ba","#fff1b8","#ffffb8","#f4ffb8","#d9f7be","#b5f5ec","#bae0ff","#d6e4ff","#efdbff","#ffd6e7","#ffa39e","#ffbb96","#ffd591","#ffe58f","#fffb8f","#eaff8f","#b7eb8f","#87e8de","#91caff","#adc6ff","#d3adf7","#ffadd2","#ff7875","#ff9c6e","#ffc069","#ffd666","#fff566","#d3f261","#95de64","#5cdbd3","#69b1ff","#85a5ff","#b37feb","#ff85c0","#ff4d4f","#ff7a45","#ffa940","#ffc53d","#ffec3d","#bae637","#73d13d","#36cfc9","#4096ff","#597ef7","#9254de","#f759ab","#cf1322","#d4380d","#d46b08","#d48806","#d4b106","#7cb305","#389e0d","#08979c","#0958d9","#1d39c4","#531dab","#c41d7f","#a8071a","#ad2102","#ad4e00","#ad6800","#ad8b00","#5b8c00","#237804","#006d75","#003eb3","#10239e","#391085","#9e1068","#820014","#871400","#873800","#874d00","#876800","#3f6600","#135200","#00474f","#002c8c","#061178","#22075e","#780650","#5c0011","#610b00","#612500","#613400","#614700","#254000","#092b00","#002329","#001d66","#030852","#120338","#520339","#000000","#1f1f1f","#262626","#434343","#595959","#8c8c8c","#bfbfbf","#d9d9d9","#f0f0f0","#f5f5f5","#fafafa","#ffffff"],Ur=[{icon:n.get("removeFormat"),value:"",text:t=>t.toolbar.removeColor()}];for(const t of Wr)Ur.push({value:t.toLowerCase(),text:t.toUpperCase()});const qr=new Map([["strong","bold"],["em","italic"],["i","italic"],["u","underline"],["s","strikethrough"],["sup","superscript"],["sub","subscript"],["code","code"]]),Kr=[{name:"undo",type:"button",icon:n.get("undo"),tooltip:t=>t.toolbar.undo(),onClick:(t,e)=>{t.command.execute(e)}},{name:"redo",type:"button",icon:n.get("redo"),tooltip:t=>t.toolbar.redo(),onClick:(t,e)=>{t.command.execute(e)}},{name:"selectAll",type:"button",icon:n.get("selectAll"),tooltip:t=>t.toolbar.selectAll(),onClick:(t,e)=>{t.command.execute(e)}},{name:"paragraph",type:"button",icon:n.get("paragraph"),tooltip:t=>t.toolbar.paragraph(),isSelected:t=>!!t.find((t=>"p"===t.name)),onClick:t=>{t.command.execute("heading","p")}},{name:"blockQuote",type:"button",icon:n.get("blockQuote"),tooltip:t=>t.toolbar.blockQuote(),onClick:(t,e)=>{t.command.execute(e)}},{name:"numberedList",type:"button",icon:n.get("numberedList"),tooltip:t=>t.toolbar.numberedList(),isSelected:t=>!!t.find((t=>"ol"===t.name)),onClick:t=>{t.command.execute("list","numbered")}},{name:"bulletedList",type:"button",icon:n.get("bulletedList"),tooltip:t=>t.toolbar.bulletedList(),isSelected:t=>!!t.find((t=>"ul"===t.name&&!t.node.hasAttr("type"))),onClick:t=>{t.command.execute("list","bulleted")}},{name:"checklist",type:"button",icon:n.get("checklist"),tooltip:t=>t.toolbar.checklist(),isSelected:t=>!!t.find((t=>"ul"===t.name&&"checklist"===t.node.attr("type"))),onClick:t=>{t.command.execute("list","checklist")}},{name:"alignLeft",type:"button",icon:n.get("alignLeft"),tooltip:t=>t.toolbar.alignLeft(),isSelected:t=>!!t.find((t=>t.node.isBlock&&"left"===t.node.css("text-align"))),onClick:t=>{t.command.execute("align","left")}},{name:"alignCenter",type:"button",icon:n.get("alignCenter"),tooltip:t=>t.toolbar.alignCenter(),isSelected:t=>!!t.find((t=>t.node.isBlock&&"center"===t.node.css("text-align"))),onClick:t=>{t.command.execute("align","center")}},{name:"alignRight",type:"button",icon:n.get("alignRight"),tooltip:t=>t.toolbar.alignRight(),isSelected:t=>!!t.find((t=>t.node.isBlock&&"right"===t.node.css("text-align"))),onClick:t=>{t.command.execute("align","right")}},{name:"alignJustify",type:"button",icon:n.get("alignJustify"),tooltip:t=>t.toolbar.alignJustify(),isSelected:t=>!!t.find((t=>t.node.isBlock&&"justify"===t.node.css("text-align"))),onClick:t=>{t.command.execute("align","justify")}},{name:"increaseIndent",type:"button",icon:n.get("increaseIndent"),tooltip:t=>t.toolbar.increaseIndent(),onClick:t=>{t.command.execute("indent","increase")}},{name:"decreaseIndent",type:"button",icon:n.get("decreaseIndent"),tooltip:t=>t.toolbar.decreaseIndent(),onClick:t=>{t.command.execute("indent","decrease")}},{name:"bold",type:"button",icon:n.get("bold"),tooltip:t=>t.toolbar.bold(),onClick:(t,e)=>{t.command.execute(e)}},{name:"italic",type:"button",icon:n.get("italic"),tooltip:t=>t.toolbar.italic(),onClick:(t,e)=>{t.command.execute(e)}},{name:"underline",type:"button",icon:n.get("underline"),tooltip:t=>t.toolbar.underline(),onClick:(t,e)=>{t.command.execute(e)}},{name:"strikethrough",type:"button",icon:n.get("strikethrough"),tooltip:t=>t.toolbar.strikethrough(),onClick:(t,e)=>{t.command.execute(e)}},{name:"superscript",type:"button",icon:n.get("superscript"),tooltip:t=>t.toolbar.superscript(),onClick:(t,e)=>{t.command.execute(e)}},{name:"subscript",type:"button",icon:n.get("subscript"),tooltip:t=>t.toolbar.subscript(),onClick:(t,e)=>{t.command.execute(e)}},{name:"code",type:"button",icon:n.get("code"),tooltip:t=>t.toolbar.code(),onClick:(t,e)=>{t.command.execute(e)}},{name:"removeFormat",type:"button",icon:n.get("removeFormat"),tooltip:t=>t.toolbar.removeFormat(),onClick:(t,e)=>{t.command.execute(e)}},{name:"formatPainter",type:"button",icon:n.get("formatPainter"),tooltip:t=>t.toolbar.formatPainter(),onClick:(t,e)=>{t.command.execute(e)}},{name:"link",type:"button",icon:n.get("link"),tooltip:t=>t.toolbar.link(),onClick:(t,e)=>{t.command.execute(e)}},{name:"hr",type:"button",icon:n.get("hr"),tooltip:t=>t.toolbar.hr(),onClick:(t,e)=>{t.command.execute(e)}},{name:"codeBlock",type:"button",icon:n.get("codeBlock"),tooltip:t=>t.toolbar.codeBlock(),onClick:(t,e)=>{t.command.execute(e)}},{name:"heading",type:"dropdown",downIcon:n.get("down"),defaultValue:"p",tooltip:t=>t.toolbar.heading(),width:"100px",menuType:"list",menuItems:[{value:"h1",text:t=>`<span style="font-weight: bold; font-size: 26px;">${t.toolbar.heading1()}</span>`},{value:"h2",text:t=>`<span style="font-weight: bold; font-size: 24px;">${t.toolbar.heading2()}</span>`},{value:"h3",text:t=>`<span style="font-weight: bold; font-size: 22px;">${t.toolbar.heading3()}</span>`},{value:"h4",text:t=>`<span style="font-weight: bold; font-size: 20px;">${t.toolbar.heading4()}</span>`},{value:"h5",text:t=>`<span style="font-weight: bold; font-size: 18px;">${t.toolbar.heading5()}</span>`},{value:"h6",text:t=>`<span style="font-weight: bold; font-size: 16px;">${t.toolbar.heading6()}</span>`},{value:"p",text:t=>t.toolbar.paragraph()}],onSelect:(t,e)=>{t.command.execute("heading",e)}},{name:"list",type:"dropdown",downIcon:n.get("down"),icon:n.get("list"),defaultValue:"",tooltip:t=>t.toolbar.list(),width:"auto",menuType:"list",menuItems:Vr,onSelect:(t,e)=>{t.command.execute("list",e)}},{name:"align",type:"dropdown",downIcon:n.get("down"),icon:n.get("alignLeft"),defaultValue:"",tooltip:t=>t.toolbar.align(),width:"auto",menuType:"list",menuItems:Fr,onSelect:(t,e)=>{t.command.execute("align",e)}},{name:"indent",type:"dropdown",downIcon:n.get("down"),icon:n.get("increaseIndent"),defaultValue:"",tooltip:t=>t.toolbar.indent(),width:"auto",menuType:"list",menuItems:jr,onSelect:(t,e)=>{t.command.execute("indent",e)}},{name:"fontFamily",type:"dropdown",downIcon:n.get("down"),defaultValue:"Segoe UI",tooltip:t=>t.toolbar.fontFamily(),width:"100px",menuType:"list",menuItems:[{value:"Arial",text:'<span style="font-family: Arial;">Arial</span>'},{value:"Arial Black",text:"<span style=\"font-family: 'Arial Black';\">Arial Black</span>"},{value:"Comic Sans MS",text:"<span style=\"font-family: 'Comic Sans MS';\">Comic Sans MS</span>"},{value:"Courier New",text:"<span style=\"font-family: 'Courier New';\">Courier New</span>"},{value:"Georgia",text:'<span style="font-family: Georgia;">Georgia</span>'},{value:"Helvetica",text:'<span style="font-family: Helvetica;">Helvetica</span>'},{value:"Impact",text:'<span style="font-family: Impact;">Impact</span>'},{value:"Segoe UI",text:"<span style=\"font-family: 'Segoe UI';\">Segoe UI</span>"},{value:"Tahoma",text:'<span style="font-family: Tahoma;">Tahoma</span>'},{value:"Times New Roman",text:"<span style=\"font-family: 'Times New Roman';\">Times New Roman</span>"},{value:"Trebuchet MS",text:"<span style=\"font-family: 'Trebuchet MS';\">Trebuchet MS</span>"},{value:"Verdana",text:'<span style="font-family: Verdana;">Verdana</span>'}],onSelect:(t,e)=>{t.command.execute("fontFamily",e)}},{name:"fontSize",type:"dropdown",downIcon:n.get("down"),defaultValue:"16px",tooltip:t=>t.toolbar.fontSize(),width:"65px",menuType:"list",menuItems:[{value:"12px",text:"12px"},{value:"14px",text:"14px"},{value:"16px",text:"16px"},{value:"18px",text:"18px"},{value:"22px",text:"22px"},{value:"24px",text:"24px"},{value:"32px",text:"32px"}],onSelect:(t,e)=>{t.command.execute("fontSize",e)}},{name:"moreStyle",type:"dropdown",icon:n.get("more"),defaultValue:"",tooltip:t=>t.toolbar.moreStyle(),width:"auto",menuType:"list",menuItems:Rr,selectedValues:t=>{var e;const i=[];for(const n of t)if(n.node.isMark){const t=null!==(e=qr.get(n.name))&&void 0!==e?e:n.name;i.push(t)}return i},onSelect:(t,e)=>{t.command.execute(e)}},{name:"fontColor",type:"dropdown",downIcon:n.get("down"),icon:n.get("fontColor"),accentIcon:n.get("fontColorAccent"),defaultValue:"#f5222d",tooltip:t=>t.toolbar.fontColor(),width:"auto",menuType:"color",menuItems:Ur,onSelect:(t,e)=>{t.command.execute("fontColor",e)}},{name:"highlight",type:"dropdown",downIcon:n.get("down"),icon:n.get("highlight"),accentIcon:n.get("highlightAccent"),defaultValue:"#fadb14",tooltip:t=>t.toolbar.highlight(),width:"auto",menuType:"color",menuItems:Ur,onSelect:(t,e)=>{t.command.execute("highlight",e)}},{name:"image",type:"upload",icon:n.get("image"),tooltip:t=>t.toolbar.image(),accept:"image/*",multiple:!0}];function Gr(t){const{editor:e,file:i,onError:n,onSuccess:s}=t,{requestMethod:o,requestAction:r,requestTypes:a}=e.config.image;if(a.indexOf(i.type)<0)throw new Error(`Cannot upload file because its type '${i.type}' is not found in ['${a.join("', '")}'].`);const l=e.insertBox("image",{url:URL.createObjectURL(i),status:"uploading",name:i.name,size:i.size,type:i.type,lastModified:i.lastModified}),c=pt({onProgress:t=>{const e=l.node.find(".lake-percent"),i=Math.round(t.percent);e.text(`${i<100?i:99} %`)},onError:(t,e)=>{A(t.toString(),e),l.updateValue("status","error"),l.render(),n&&n()},onSuccess:t=>{if(!t.url)return l.updateValue("status","error"),l.render(),void(n&&n());l.updateValue({status:"done",url:t.url}),l.render(),e.history.save(),s&&s()},file:i,action:r,method:o});return l.setData("xhr",c),l}const Xr=["undo","redo","|","heading","|","formatPainter","removeFormat","bold","moreStyle","|","fontColor","highlight","|","align","list","indent","link","blockQuote","hr"],Jr=new Map;Kr.forEach((t=>{Jr.set(t.name,t)}));function Qr(t,e,i,n){return new(i||(i=Promise))((function(s,o){function r(t){try{l(n.next(t))}catch(t){o(t)}}function a(t){try{l(n.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,a)}l((n=n.apply(t,e||[])).next())}))}
19
19
  /*!
20
20
  * PhotoSwipe Lightbox 5.4.3 - https://photoswipe.com
21
21
  * (c) 2023 Dmytro Semenov