84 lines
382 KiB
JavaScript
84 lines
382 KiB
JavaScript
!function(){try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".ce-hint--align-start{text-align:left}.ce-hint--align-center{text-align:center}.ce-hint__description{opacity:.6;margin-top:3px}")),document.head.appendChild(e)}}catch(t){}}();var e=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function o(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var o=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};o.prototype=t.prototype}else o={};return Object.defineProperty(o,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(o,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),o}function n(){}Object.assign(n,{default:n,register:n,revert:function(){},__esModule:!0}),Element.prototype.matches||(Element.prototype.matches=Element.prototype.matchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector||Element.prototype.webkitMatchesSelector||function(e){const t=(this.document||this.ownerDocument).querySelectorAll(e);let o=t.length;for(;--o>=0&&t.item(o)!==this;);return o>-1}),Element.prototype.closest||(Element.prototype.closest=function(e){let t=this;if(!document.documentElement.contains(t))return null;do{if(t.matches(e))return t;t=t.parentElement||t.parentNode}while(null!==t);return null}),Element.prototype.prepend||(Element.prototype.prepend=function(e){const t=document.createDocumentFragment();Array.isArray(e)||(e=[e]),e.forEach((e=>{const o=e instanceof Node;t.appendChild(o?e:document.createTextNode(e))})),this.insertBefore(t,this.firstChild)}),Element.prototype.scrollIntoViewIfNeeded||(Element.prototype.scrollIntoViewIfNeeded=function(e){e=0===arguments.length||!!e;const t=this.parentNode,o=window.getComputedStyle(t,null),n=parseInt(o.getPropertyValue("border-top-width")),i=parseInt(o.getPropertyValue("border-left-width")),r=this.offsetTop-t.offsetTop<t.scrollTop,s=this.offsetTop-t.offsetTop+this.clientHeight-n>t.scrollTop+t.clientHeight,a=this.offsetLeft-t.offsetLeft<t.scrollLeft,l=this.offsetLeft-t.offsetLeft+this.clientWidth-i>t.scrollLeft+t.clientWidth,c=r&&!s;(r||s)&&e&&(t.scrollTop=this.offsetTop-t.offsetTop-t.clientHeight/2-n+this.clientHeight/2),(a||l)&&e&&(t.scrollLeft=this.offsetLeft-t.offsetLeft-t.clientWidth/2-i+this.clientWidth/2),(r||s||a||l)&&!e&&this.scrollIntoView(c)}),window.requestIdleCallback=window.requestIdleCallback||function(e){const t=Date.now();return setTimeout((function(){e({didTimeout:!1,timeRemaining:function(){return Math.max(0,50-(Date.now()-t))}})}),1)},window.cancelIdleCallback=window.cancelIdleCallback||function(e){clearTimeout(e)};var i=(e=>(e.VERBOSE="VERBOSE",e.INFO="INFO",e.WARN="WARN",e.ERROR="ERROR",e))(i||{});const r=8,s=9,a=13,l=27,c=37,d=38,u=40,h=39,p=46,f=0;function g(e,t,o="log",n,i="color: inherit"){if(!("console"in window)||!window.console[o])return;const r=["info","log","warn","error"].includes(o),s=[];switch(g.logLevel){case"ERROR":if("error"!==o)return;break;case"WARN":if(!["error","warn"].includes(o))return;break;case"INFO":if(!r||e)return}n&&s.push(n);const a="Editor.js 2.31.0";e&&(r?(s.unshift("line-height: 1em;\n color: #006FEA;\n display: inline-block;\n font-size: 11px;\n line-height: 1em;\n background-color: #fff;\n padding: 4px 9px;\n border-radius: 30px;\n border: 1px solid rgba(56, 138, 229, 0.16);\n margin: 4px 5px 4px 0;",i),t=`%c${a}%c ${t}`):t=`( ${a} )${t}`)}g.logLevel="VERBOSE";const m=g.bind(window,!1),b=g.bind(window,!0);function v(e){return Object.prototype.toString.call(e).match(/\s([a-zA-Z]+)/)[1].toLowerCase()}function y(e){return"function"===v(e)||"asyncfunction"===v(e)}function k(e){return"object"===v(e)}function w(e){return"string"===v(e)}function x(e){return"number"===v(e)}function E(e){return"undefined"===v(e)}function C(e){return!e||0===Object.keys(e).length&&e.constructor===Object}function S(e){return e>47&&e<58||32===e||13===e||229===e||e>64&&e<91||e>95&&e<112||e>185&&e<193||e>218&&e<223}async function T(e,t=()=>{},o=()=>{}){return e.reduce((async(e,n)=>(await e,async function(e,t,o){try{await e.function(e.data),await t(E(e.data)?{}:e.data)}catch{o(E(e.data)?{}:e.data)}}(n,t,o))),Promise.resolve())}function _(e){return Array.prototype.slice.call(e)}function O(e,t){return function(){const o=this,n=arguments;window.setTimeout((()=>e.apply(o,n)),t)}}function B(e,t,o){let n;return(...i)=>{const r=this,s=o&&!n;window.clearTimeout(n),n=window.setTimeout((()=>{n=null,o||e.apply(r,i)}),t),s&&e.apply(r,i)}}function I(e,t,o=void 0){let n,i,r,s=null,a=0;o||(o={});const l=function(){a=!1===o.leading?0:Date.now(),s=null,r=e.apply(n,i),s||(n=i=null)};return function(){const c=Date.now();!a&&!1===o.leading&&(a=c);const d=t-(c-a);return n=this,i=arguments,d<=0||d>t?(s&&(clearTimeout(s),s=null),a=c,r=e.apply(n,i),s||(n=i=null)):!s&&!1!==o.trailing&&(s=setTimeout(l,d)),r}}function M(e){return e[0].toUpperCase()+e.slice(1)}function P(e,...t){if(!t.length)return e;const o=t.shift();if(k(e)&&k(o))for(const n in o)k(o[n])?(e[n]||Object.assign(e,{[n]:{}}),P(e[n],o[n])):Object.assign(e,{[n]:o[n]});return P(e,...t)}function L(e){const t=function(){const e={win:!1,mac:!1,x11:!1,linux:!1},t=Object.keys(e).find((e=>-1!==window.navigator.appVersion.toLowerCase().indexOf(e)));return t&&(e[t]=!0),e}();return e=e.replace(/shift/gi,"⇧").replace(/backspace/gi,"⌫").replace(/enter/gi,"⏎").replace(/up/gi,"↑").replace(/left/gi,"→").replace(/down/gi,"↓").replace(/right/gi,"←").replace(/escape/gi,"⎋").replace(/insert/gi,"Ins").replace(/delete/gi,"␡").replace(/\+/gi," + "),e=t.mac?e.replace(/ctrl|cmd/gi,"⌘").replace(/alt/gi,"⌥"):e.replace(/cmd/gi,"Ctrl").replace(/windows/gi,"WIN")}function A(){return((e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce(((e,t)=>e+((t&=63)<36?t.toString(36):t<62?(t-26).toString(36).toUpperCase():t>62?"-":"_")),""))(10)}function N(e,t,o){e&&b(`«${t}» is deprecated and will be removed in the next major release. Please use the «${o}» instead.`,"warn")}function j(e,t,o){const n=o.value?"value":"get",i=o[n],r=`#${t}Cache`;if(o[n]=function(...e){return void 0===this[r]&&(this[r]=i.apply(this,...e)),this[r]},"get"===n&&o.set){const t=o.set;o.set=function(o){delete e[r],t.apply(this,o)}}return o}function D(){return window.matchMedia("(max-width: 650px)").matches}const R=typeof window<"u"&&window.navigator&&window.navigator.platform&&(/iP(ad|hone|od)/.test(window.navigator.platform)||"MacIntel"===window.navigator.platform&&window.navigator.maxTouchPoints>1);class F{static isSingleTag(e){return e.tagName&&["AREA","BASE","BR","COL","COMMAND","EMBED","HR","IMG","INPUT","KEYGEN","LINK","META","PARAM","SOURCE","TRACK","WBR"].includes(e.tagName)}static isLineBreakTag(e){return e&&e.tagName&&["BR","WBR"].includes(e.tagName)}static make(e,t=null,o={}){const n=document.createElement(e);if(Array.isArray(t)){const e=t.filter((e=>void 0!==e));n.classList.add(...e)}else t&&n.classList.add(t);for(const i in o)Object.prototype.hasOwnProperty.call(o,i)&&(n[i]=o[i]);return n}static text(e){return document.createTextNode(e)}static append(e,t){Array.isArray(t)?t.forEach((t=>e.appendChild(t))):e.appendChild(t)}static prepend(e,t){Array.isArray(t)?(t=t.reverse()).forEach((t=>e.prepend(t))):e.prepend(t)}static swap(e,t){const o=document.createElement("div"),n=e.parentNode;n.insertBefore(o,e),n.insertBefore(e,t),n.insertBefore(t,o),n.removeChild(o)}static find(e=document,t){return e.querySelector(t)}static get(e){return document.getElementById(e)}static findAll(e=document,t){return e.querySelectorAll(t)}static get allInputsSelector(){return"[contenteditable=true], textarea, input:not([type]), "+["text","password","email","number","search","tel","url"].map((e=>`input[type="${e}"]`)).join(", ")}static findAllInputs(e){return _(e.querySelectorAll(F.allInputsSelector)).reduce(((e,t)=>F.isNativeInput(t)||F.containsOnlyInlineElements(t)?[...e,t]:[...e,...F.getDeepestBlockElements(t)]),[])}static getDeepestNode(e,t=!1){const o=t?"lastChild":"firstChild",n=t?"previousSibling":"nextSibling";if(e&&e.nodeType===Node.ELEMENT_NODE&&e[o]){let i=e[o];if(F.isSingleTag(i)&&!F.isNativeInput(i)&&!F.isLineBreakTag(i))if(i[n])i=i[n];else{if(!i.parentNode[n])return i.parentNode;i=i.parentNode[n]}return this.getDeepestNode(i,t)}return e}static isElement(e){return!x(e)&&(e&&e.nodeType&&e.nodeType===Node.ELEMENT_NODE)}static isFragment(e){return!x(e)&&(e&&e.nodeType&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE)}static isContentEditable(e){return"true"===e.contentEditable}static isNativeInput(e){return!(!e||!e.tagName)&&["INPUT","TEXTAREA"].includes(e.tagName)}static canSetCaret(e){let t=!0;if(F.isNativeInput(e))switch(e.type){case"file":case"checkbox":case"radio":case"hidden":case"submit":case"button":case"image":case"reset":t=!1}else t=F.isContentEditable(e);return t}static isNodeEmpty(e,t){let o;return!(this.isSingleTag(e)&&!this.isLineBreakTag(e))&&(o=this.isElement(e)&&this.isNativeInput(e)?e.value:e.textContent.replace("",""),t&&(o=o.replace(new RegExp(t,"g"),"")),0===o.length)}static isLeaf(e){return!!e&&0===e.childNodes.length}static isEmpty(e,t){const o=[e];for(;o.length>0;)if(e=o.shift()){if(this.isLeaf(e)&&!this.isNodeEmpty(e,t))return!1;e.childNodes&&o.push(...Array.from(e.childNodes))}return!0}static isHTMLString(e){const t=F.make("div");return t.innerHTML=e,t.childElementCount>0}static getContentLength(e){return F.isNativeInput(e)?e.value.length:e.nodeType===Node.TEXT_NODE?e.length:e.textContent.length}static get blockElements(){return["address","article","aside","blockquote","canvas","div","dl","dt","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","li","main","nav","noscript","ol","output","p","pre","ruby","section","table","tbody","thead","tr","tfoot","ul","video"]}static containsOnlyInlineElements(e){let t;w(e)?(t=document.createElement("div"),t.innerHTML=e):t=e;const o=e=>!F.blockElements.includes(e.tagName.toLowerCase())&&Array.from(e.children).every(o);return Array.from(t.children).every(o)}static getDeepestBlockElements(e){return F.containsOnlyInlineElements(e)?[e]:Array.from(e.children).reduce(((e,t)=>[...e,...F.getDeepestBlockElements(t)]),[])}static getHolder(e){return w(e)?document.getElementById(e):e}static isAnchor(e){return"a"===e.tagName.toLowerCase()}static offset(e){const t=e.getBoundingClientRect(),o=window.pageXOffset||document.documentElement.scrollLeft,n=window.pageYOffset||document.documentElement.scrollTop,i=t.top+n,r=t.left+o;return{top:i,left:r,bottom:i+t.height,right:r+t.width}}static getNodeByOffset(e,t){let o=0,n=null;const i=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null);let r=i.nextNode();for(;r;){const e=r.textContent,s=null===e?0:e.length;if(n=r,o+s>=t)break;o+=s,r=i.nextNode()}if(!n)return{node:null,offset:0};const s=n.textContent;if(null===s||0===s.length)return{node:null,offset:0};return{node:n,offset:Math.min(t-o,s.length)}}}function H(e){e.dataset.empty=F.isEmpty(e)?"true":"false"}const U={ui:{blockTunes:{toggler:{"Click to tune":"","or drag to move":""}},inlineToolbar:{converter:{"Convert to":""}},toolbar:{toolbox:{Add:""}},popover:{Filter:"","Nothing found":"","Convert to":""}},toolNames:{Text:"",Link:"",Bold:"",Italic:""},tools:{link:{"Add a link":""},stub:{"The block can not be displayed correctly.":""}},blockTunes:{delete:{Delete:"","Click to delete":""},moveUp:{"Move up":""},moveDown:{"Move down":""}}},z=class e{static ui(t,o){return e._t(t,o)}static t(t,o){return e._t(t,o)}static setDictionary(t){e.currentDictionary=t}static _t(t,o){const n=e.getNamespace(t);return n&&n[o]?n[o]:o}static getNamespace(t){return t.split(".").reduce(((e,t)=>e&&Object.keys(e).length?e[t]:{}),e.currentDictionary)}};z.currentDictionary=U;let W=z;class $ extends Error{}let q=class{constructor(){this.subscribers={}}on(e,t){e in this.subscribers||(this.subscribers[e]=[]),this.subscribers[e].push(t)}once(e,t){e in this.subscribers||(this.subscribers[e]=[]);const o=n=>{const i=t(n),r=this.subscribers[e].indexOf(o);return-1!==r&&this.subscribers[e].splice(r,1),i};this.subscribers[e].push(o)}emit(e,t){C(this.subscribers)||!this.subscribers[e]||this.subscribers[e].reduce(((e,t)=>{const o=t(e);return void 0!==o?o:e}),t)}off(e,t){if(void 0!==this.subscribers[e])for(let o=0;o<this.subscribers[e].length;o++)if(this.subscribers[e][o]===t){delete this.subscribers[e][o];break}}destroy(){this.subscribers={}}};function K(e){Object.setPrototypeOf(this,{get id(){return e.id},get name(){return e.name},get config(){return e.config},get holder(){return e.holder},get isEmpty(){return e.isEmpty},get selected(){return e.selected},set stretched(t){e.stretched=t},get stretched(){return e.stretched},get focusable(){return e.focusable},call:(t,o)=>e.call(t,o),save:()=>e.save(),validate:t=>e.validate(t),dispatchChange(){e.dispatchChange()},getActiveToolboxEntry:()=>e.getActiveToolboxEntry()})}let Y=class{constructor(){this.allListeners=[]}on(e,t,o,n=!1){const i=function(e=""){return`${e}${Math.floor(1e8*Math.random()).toString(16)}`}("l"),r={id:i,element:e,eventType:t,handler:o,options:n};if(!this.findOne(e,t,o))return this.allListeners.push(r),e.addEventListener(t,o,n),i}off(e,t,o,n){const i=this.findAll(e,t,o);i.forEach(((e,t)=>{const o=this.allListeners.indexOf(i[t]);o>-1&&(this.allListeners.splice(o,1),e.element.removeEventListener(e.eventType,e.handler,e.options))}))}offById(e){const t=this.findById(e);t&&t.element.removeEventListener(t.eventType,t.handler,t.options)}findOne(e,t,o){const n=this.findAll(e,t,o);return n.length>0?n[0]:null}findAll(e,t,o){let n;const i=e?this.findByEventTarget(e):[];return n=e&&t&&o?i.filter((e=>e.eventType===t&&e.handler===o)):e&&t?i.filter((e=>e.eventType===t)):i,n}removeAll(){this.allListeners.map((e=>{e.element.removeEventListener(e.eventType,e.handler,e.options)})),this.allListeners=[]}destroy(){this.removeAll()}findByEventTarget(e){return this.allListeners.filter((t=>{if(t.element===e)return t}))}findByType(e){return this.allListeners.filter((t=>{if(t.eventType===e)return t}))}findByHandler(e){return this.allListeners.filter((t=>{if(t.handler===e)return t}))}findById(e){return this.allListeners.find((t=>t.id===e))}},X=class e{constructor({config:t,eventsDispatcher:o}){if(this.nodes={},this.listeners=new Y,this.readOnlyMutableListeners={on:(e,t,o,n=!1)=>{this.mutableListenerIds.push(this.listeners.on(e,t,o,n))},clearAll:()=>{for(const e of this.mutableListenerIds)this.listeners.offById(e);this.mutableListenerIds=[]}},this.mutableListenerIds=[],new.target===e)throw new TypeError("Constructors for abstract class Module are not allowed.");this.config=t,this.eventsDispatcher=o}set state(e){this.Editor=e}removeAllNodes(){for(const e in this.nodes){const t=this.nodes[e];t instanceof HTMLElement&&t.remove()}}get isRtl(){return"rtl"===this.config.i18n.direction}},V=class e{constructor(){this.instance=null,this.selection=null,this.savedSelectionRange=null,this.isFakeBackgroundEnabled=!1,this.commandBackground="backColor",this.commandRemoveFormat="removeFormat"}static get CSS(){return{editorWrapper:"codex-editor",editorZone:"codex-editor__redactor"}}static get anchorNode(){const e=window.getSelection();return e?e.anchorNode:null}static get anchorElement(){const e=window.getSelection();if(!e)return null;const t=e.anchorNode;return t?F.isElement(t)?t:t.parentElement:null}static get anchorOffset(){const e=window.getSelection();return e?e.anchorOffset:null}static get isCollapsed(){const e=window.getSelection();return e?e.isCollapsed:null}static get isAtEditor(){return this.isSelectionAtEditor(e.get())}static isSelectionAtEditor(t){if(!t)return!1;let o=t.anchorNode||t.focusNode;o&&o.nodeType===Node.TEXT_NODE&&(o=o.parentNode);let n=null;return o&&o instanceof Element&&(n=o.closest(`.${e.CSS.editorZone}`)),!!n&&n.nodeType===Node.ELEMENT_NODE}static isRangeAtEditor(t){if(!t)return;let o=t.startContainer;o&&o.nodeType===Node.TEXT_NODE&&(o=o.parentNode);let n=null;return o&&o instanceof Element&&(n=o.closest(`.${e.CSS.editorZone}`)),!!n&&n.nodeType===Node.ELEMENT_NODE}static get isSelectionExists(){return!!e.get().anchorNode}static get range(){return this.getRangeFromSelection(this.get())}static getRangeFromSelection(e){return e&&e.rangeCount?e.getRangeAt(0):null}static get rect(){let e,t=document.selection,o={x:0,y:0,width:0,height:0};if(t&&"Control"!==t.type)return e=t.createRange(),o.x=e.boundingLeft,o.y=e.boundingTop,o.width=e.boundingWidth,o.height=e.boundingHeight,o;if(!window.getSelection)return m("Method window.getSelection is not supported","warn"),o;if(t=window.getSelection(),null===t.rangeCount||isNaN(t.rangeCount))return m("Method SelectionUtils.rangeCount is not supported","warn"),o;if(0===t.rangeCount)return o;if(e=t.getRangeAt(0).cloneRange(),e.getBoundingClientRect&&(o=e.getBoundingClientRect()),0===o.x&&0===o.y){const t=document.createElement("span");if(t.getBoundingClientRect){t.appendChild(document.createTextNode("")),e.insertNode(t),o=t.getBoundingClientRect();const n=t.parentNode;n.removeChild(t),n.normalize()}}return o}static get text(){return window.getSelection?window.getSelection().toString():""}static get(){return window.getSelection()}static setCursor(e,t=0){const o=document.createRange(),n=window.getSelection();return F.isNativeInput(e)?F.canSetCaret(e)?(e.focus(),e.selectionStart=e.selectionEnd=t,e.getBoundingClientRect()):void 0:(o.setStart(e,t),o.setEnd(e,t),n.removeAllRanges(),n.addRange(o),o.getBoundingClientRect())}static isRangeInsideContainer(t){const o=e.range;return null!==o&&t.contains(o.startContainer)}static addFakeCursor(){const t=e.range;if(null===t)return;const o=F.make("span","codex-editor__fake-cursor");o.dataset.mutationFree="true",t.collapse(),t.insertNode(o)}static isFakeCursorInsideContainer(e){return null!==F.find(e,".codex-editor__fake-cursor")}static removeFakeCursor(e=document.body){const t=F.find(e,".codex-editor__fake-cursor");t&&t.remove()}removeFakeBackground(){this.isFakeBackgroundEnabled&&(this.isFakeBackgroundEnabled=!1,document.execCommand(this.commandRemoveFormat))}setFakeBackground(){document.execCommand(this.commandBackground,!1,"#a8d6ff"),this.isFakeBackgroundEnabled=!0}save(){this.savedSelectionRange=e.range}restore(){if(!this.savedSelectionRange)return;const e=window.getSelection();e.removeAllRanges(),e.addRange(this.savedSelectionRange)}clearSaved(){this.savedSelectionRange=null}collapseToEnd(){const e=window.getSelection(),t=document.createRange();t.selectNodeContents(e.focusNode),t.collapse(!1),e.removeAllRanges(),e.addRange(t)}findParentTag(e,t,o=10){const n=window.getSelection();let i=null;return n&&n.anchorNode&&n.focusNode?([n.anchorNode,n.focusNode].forEach((n=>{let r=o;for(;r>0&&n.parentNode&&(n.tagName!==e||(i=n,t&&n.classList&&!n.classList.contains(t)&&(i=null),!i));)n=n.parentNode,r--})),i):null}expandToTag(e){const t=window.getSelection();t.removeAllRanges();const o=document.createRange();o.selectNodeContents(e),t.addRange(o)}};const G="redactor dom changed",Z="block changed",J="fake cursor is about to be toggled",Q="fake cursor have been set",ee="editor mobile layout toggled";function te(e,t){if(!e.conversionConfig)return!1;const o=e.conversionConfig[t];return y(o)||w(o)}function oe(e,t){return te(e.tool,t)}function ne(e,t){return Object.entries(e).some((([e,o])=>t[e]&&function(e,t){const o=Array.isArray(e)||k(e),n=Array.isArray(t)||k(t);return o||n?JSON.stringify(e)===JSON.stringify(t):e===t}(t[e],o)))}async function ie(e,t){const o=(await e.save()).data,n=t.find((t=>t.name===e.name));return void 0===n||te(n,"export")?t.reduce(((t,n)=>{if(!te(n,"import")||void 0===n.toolbox)return t;const i=n.toolbox.filter((t=>{if(C(t)||void 0===t.icon)return!1;if(void 0!==t.data){if(ne(t.data,o))return!1}else if(n.name===e.name)return!1;return!0}));return t.push({...n,toolbox:i}),t}),[]):[]}function re(e,t){return!!e.mergeable&&(e.name===t.name||oe(t,"export")&&oe(e,"import"))}function se(e,t,o){const n=null==t?void 0:t.import;return y(n)?n(e,o):w(n)?{[n]:e}:(void 0!==n&&m("Conversion «import» property must be a string or function. String means key of tool data to import. Function accepts a imported string and return composed tool data."),{})}var ae=(e=>(e.Default="default",e.Separator="separator",e.Html="html",e))(ae||{}),le=(e=>(e.APPEND_CALLBACK="appendCallback",e.RENDERED="rendered",e.MOVED="moved",e.UPDATED="updated",e.REMOVED="removed",e.ON_PASTE="onPaste",e))(le||{});let ce=class e extends q{constructor({id:e=A(),data:t,tool:o,readOnly:n,tunesData:i},r){super(),this.cachedInputs=[],this.toolRenderedElement=null,this.tunesInstances=new Map,this.defaultTunesInstances=new Map,this.unavailableTunesData={},this.inputIndex=0,this.editorEventBus=null,this.handleFocus=()=>{this.dropInputsCache(),this.updateCurrentInput()},this.didMutated=(e=void 0)=>{const t=void 0===e,o=e instanceof InputEvent;let n;!t&&!o&&this.detectToolRootChange(e),n=!(!t&&!o)||!(e.length>0&&e.every((e=>{const{addedNodes:t,removedNodes:o,target:n}=e;return[...Array.from(t),...Array.from(o),n].some((e=>(F.isElement(e)||(e=e.parentElement),e&&null!==e.closest('[data-mutation-free="true"]'))))}))),n&&(this.dropInputsCache(),this.updateCurrentInput(),this.toggleInputsEmptyMark(),this.call("updated"),this.emit("didMutated",this))},this.name=o.name,this.id=e,this.settings=o.settings,this.config=o.settings.config||{},this.editorEventBus=r||null,this.blockAPI=new K(this),this.tool=o,this.toolInstance=o.create(t,this.blockAPI,n),this.tunes=o.tunes,this.composeTunes(i),this.holder=this.compose(),window.requestIdleCallback((()=>{this.watchBlockMutations(),this.addInputEvents(),this.toggleInputsEmptyMark()}))}static get CSS(){return{wrapper:"ce-block",wrapperStretched:"ce-block--stretched",content:"ce-block__content",selected:"ce-block--selected",dropTarget:"ce-block--drop-target"}}get inputs(){if(0!==this.cachedInputs.length)return this.cachedInputs;const e=F.findAllInputs(this.holder);return this.inputIndex>e.length-1&&(this.inputIndex=e.length-1),this.cachedInputs=e,e}get currentInput(){return this.inputs[this.inputIndex]}set currentInput(e){const t=this.inputs.findIndex((t=>t===e||t.contains(e)));-1!==t&&(this.inputIndex=t)}get firstInput(){return this.inputs[0]}get lastInput(){const e=this.inputs;return e[e.length-1]}get nextInput(){return this.inputs[this.inputIndex+1]}get previousInput(){return this.inputs[this.inputIndex-1]}get data(){return this.save().then((e=>e&&!C(e.data)?e.data:{}))}get sanitize(){return this.tool.sanitizeConfig}get mergeable(){return y(this.toolInstance.merge)}get focusable(){return 0!==this.inputs.length}get isEmpty(){const e=F.isEmpty(this.pluginsContent,"/"),t=!this.hasMedia;return e&&t}get hasMedia(){return!!this.holder.querySelector(["img","iframe","video","audio","source","input","textarea","twitterwidget"].join(","))}set selected(t){var o,n;this.holder.classList.toggle(e.CSS.selected,t);const i=!0===t&&V.isRangeInsideContainer(this.holder),r=!1===t&&V.isFakeCursorInsideContainer(this.holder);(i||r)&&(null==(o=this.editorEventBus)||o.emit(J,{state:t}),i?V.addFakeCursor():V.removeFakeCursor(this.holder),null==(n=this.editorEventBus)||n.emit(Q,{state:t}))}get selected(){return this.holder.classList.contains(e.CSS.selected)}set stretched(t){this.holder.classList.toggle(e.CSS.wrapperStretched,t)}get stretched(){return this.holder.classList.contains(e.CSS.wrapperStretched)}set dropTarget(t){this.holder.classList.toggle(e.CSS.dropTarget,t)}get pluginsContent(){return this.toolRenderedElement}call(e,t){if(y(this.toolInstance[e])){"appendCallback"===e&&m("`appendCallback` hook is deprecated and will be removed in the next major release. Use `rendered` hook instead","warn");try{this.toolInstance[e].call(this.toolInstance,t)}catch(o){m(`Error during '${e}' call: ${o.message}`,"error")}}}async mergeWith(e){await this.toolInstance.merge(e)}async save(){const e=await this.toolInstance.save(this.pluginsContent),t=this.unavailableTunesData;[...this.tunesInstances.entries(),...this.defaultTunesInstances.entries()].forEach((([e,o])=>{if(y(o.save))try{t[e]=o.save()}catch(n){m(`Tune ${o.constructor.name} save method throws an Error %o`,"warn",n)}}));const o=window.performance.now();let n;return Promise.resolve(e).then((e=>(n=window.performance.now(),{id:this.id,tool:this.name,data:e,tunes:t,time:n-o}))).catch((e=>{m(`Saving process for ${this.name} tool failed due to the ${e}`,"log","red")}))}async validate(e){let t=!0;return this.toolInstance.validate instanceof Function&&(t=await this.toolInstance.validate(e)),t}getTunes(){const e=[],t=[],o="function"==typeof this.toolInstance.renderSettings?this.toolInstance.renderSettings():[];return F.isElement(o)?e.push({type:ae.Html,element:o}):Array.isArray(o)?e.push(...o):e.push(o),[...this.tunesInstances.values(),...this.defaultTunesInstances.values()].map((e=>e.render())).forEach((e=>{F.isElement(e)?t.push({type:ae.Html,element:e}):Array.isArray(e)?t.push(...e):t.push(e)})),{toolTunes:e,commonTunes:t}}updateCurrentInput(){this.currentInput=F.isNativeInput(document.activeElement)||!V.anchorNode?document.activeElement:V.anchorNode}dispatchChange(){this.didMutated()}destroy(){this.unwatchBlockMutations(),this.removeInputEvents(),super.destroy(),y(this.toolInstance.destroy)&&this.toolInstance.destroy()}async getActiveToolboxEntry(){const e=this.tool.toolbox;if(1===e.length)return Promise.resolve(this.tool.toolbox[0]);const t=await this.data;return null==e?void 0:e.find((e=>ne(e.data,t)))}async exportDataAsString(){return function(e,t){const o=null==t?void 0:t.export;return y(o)?o(e):w(o)?e[o]:(void 0!==o&&m("Conversion «export» property must be a string or function. String means key of saved data object to export. Function should export processed string to export."),"")}(await this.data,this.tool.conversionConfig)}compose(){const t=F.make("div",e.CSS.wrapper),o=F.make("div",e.CSS.content),n=this.toolInstance.render();t.dataset.id=this.id,this.toolRenderedElement=n,o.appendChild(this.toolRenderedElement);let i=o;return[...this.tunesInstances.values(),...this.defaultTunesInstances.values()].forEach((e=>{if(y(e.wrap))try{i=e.wrap(i)}catch(t){m(`Tune ${e.constructor.name} wrap method throws an Error %o`,"warn",t)}})),t.appendChild(i),t}composeTunes(e){Array.from(this.tunes.values()).forEach((t=>{(t.isInternal?this.defaultTunesInstances:this.tunesInstances).set(t.name,t.create(e[t.name],this.blockAPI))})),Object.entries(e).forEach((([e,t])=>{this.tunesInstances.has(e)||(this.unavailableTunesData[e]=t)}))}addInputEvents(){this.inputs.forEach((e=>{e.addEventListener("focus",this.handleFocus),F.isNativeInput(e)&&e.addEventListener("input",this.didMutated)}))}removeInputEvents(){this.inputs.forEach((e=>{e.removeEventListener("focus",this.handleFocus),F.isNativeInput(e)&&e.removeEventListener("input",this.didMutated)}))}watchBlockMutations(){var e;this.redactorDomChangedCallback=e=>{const{mutations:t}=e;t.some((e=>function(e,t){const{type:o,target:n,addedNodes:i,removedNodes:r}=e;return("attributes"!==e.type||"data-empty"!==e.attributeName)&&!!(t.contains(n)||"childList"===o&&(Array.from(i).some((e=>e===t))||Array.from(r).some((e=>e===t))))}(e,this.toolRenderedElement)))&&this.didMutated(t)},null==(e=this.editorEventBus)||e.on(G,this.redactorDomChangedCallback)}unwatchBlockMutations(){var e;null==(e=this.editorEventBus)||e.off(G,this.redactorDomChangedCallback)}detectToolRootChange(e){e.forEach((e=>{if(Array.from(e.removedNodes).includes(this.toolRenderedElement)){const t=e.addedNodes[e.addedNodes.length-1];this.toolRenderedElement=t}}))}dropInputsCache(){this.cachedInputs=[]}toggleInputsEmptyMark(){this.inputs.forEach(H)}};var de={exports:{}};window;const ue=t(de.exports=function(e){var t={};function o(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,o),i.l=!0,i.exports}return o.m=e,o.c=t,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t||4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)o.d(n,i,function(t){return e[t]}.bind(null,i));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="/",o(o.s=0)}([function(e,t,o){var n,i,r;o(1),
|
||
/*!
|
||
* Codex JavaScript Notification module
|
||
* https://github.com/codex-team/js-notifier
|
||
*/
|
||
e.exports=(n=o(6),i="cdx-notify--bounce-in",r=null,{show:function(e){if(e.message){!function(){if(r)return!0;r=n.getWrapper(),document.body.appendChild(r)}();var t=null,o=e.time||8e3;switch(e.type){case"confirm":t=n.confirm(e);break;case"prompt":t=n.prompt(e);break;default:t=n.alert(e),window.setTimeout((function(){t.remove()}),o)}r.appendChild(t),t.classList.add(i)}}})},function(e,t,o){var n=o(2);"string"==typeof n&&(n=[[e.i,n,""]]);var i={hmr:!0,transform:void 0,insertInto:void 0};o(4)(n,i),n.locals&&(e.exports=n.locals)},function(e,t,o){(e.exports=o(3)(!1)).push([e.i,'.cdx-notify--error{background:#fffbfb!important}.cdx-notify--error::before{background:#fb5d5d!important}.cdx-notify__input{max-width:130px;padding:5px 10px;background:#f7f7f7;border:0;border-radius:3px;font-size:13px;color:#656b7c;outline:0}.cdx-notify__input:-ms-input-placeholder{color:#656b7c}.cdx-notify__input::placeholder{color:#656b7c}.cdx-notify__input:focus:-ms-input-placeholder{color:rgba(101,107,124,.3)}.cdx-notify__input:focus::placeholder{color:rgba(101,107,124,.3)}.cdx-notify__button{border:none;border-radius:3px;font-size:13px;padding:5px 10px;cursor:pointer}.cdx-notify__button:last-child{margin-left:10px}.cdx-notify__button--cancel{background:#f2f5f7;box-shadow:0 2px 1px 0 rgba(16,19,29,0);color:#656b7c}.cdx-notify__button--cancel:hover{background:#eee}.cdx-notify__button--confirm{background:#34c992;box-shadow:0 1px 1px 0 rgba(18,49,35,.05);color:#fff}.cdx-notify__button--confirm:hover{background:#33b082}.cdx-notify__btns-wrapper{display:-ms-flexbox;display:flex;-ms-flex-flow:row nowrap;flex-flow:row nowrap;margin-top:5px}.cdx-notify__cross{position:absolute;top:5px;right:5px;width:10px;height:10px;padding:5px;opacity:.54;cursor:pointer}.cdx-notify__cross::after,.cdx-notify__cross::before{content:\'\';position:absolute;left:9px;top:5px;height:12px;width:2px;background:#575d67}.cdx-notify__cross::before{transform:rotate(-45deg)}.cdx-notify__cross::after{transform:rotate(45deg)}.cdx-notify__cross:hover{opacity:1}.cdx-notifies{position:fixed;z-index:2;bottom:20px;left:20px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen,Ubuntu,Cantarell,"Fira Sans","Droid Sans","Helvetica Neue",sans-serif}.cdx-notify{position:relative;width:220px;margin-top:15px;padding:13px 16px;background:#fff;box-shadow:0 11px 17px 0 rgba(23,32,61,.13);border-radius:5px;font-size:14px;line-height:1.4em;word-wrap:break-word}.cdx-notify::before{content:\'\';position:absolute;display:block;top:0;left:0;width:3px;height:calc(100% - 6px);margin:3px;border-radius:5px;background:0 0}@keyframes bounceIn{0%{opacity:0;transform:scale(.3)}50%{opacity:1;transform:scale(1.05)}70%{transform:scale(.9)}100%{transform:scale(1)}}.cdx-notify--bounce-in{animation-name:bounceIn;animation-duration:.6s;animation-iteration-count:1}.cdx-notify--success{background:#fafffe!important}.cdx-notify--success::before{background:#41ffb1!important}',""])},function(e,t){e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var o=function(e,t){var o,n=e[1]||"",i=e[3];if(!i)return n;if(t&&"function"==typeof btoa){var r=(o=i,"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(o))))+" */"),s=i.sources.map((function(e){return"/*# sourceURL="+i.sourceRoot+e+" */"}));return[n].concat(s).concat([r]).join("\n")}return[n].join("\n")}(t,e);return t[2]?"@media "+t[2]+"{"+o+"}":o})).join("")},t.i=function(e,o){"string"==typeof e&&(e=[[null,e,""]]);for(var n={},i=0;i<this.length;i++){var r=this[i][0];"number"==typeof r&&(n[r]=!0)}for(i=0;i<e.length;i++){var s=e[i];"number"==typeof s[0]&&n[s[0]]||(o&&!s[2]?s[2]=o:o&&(s[2]="("+s[2]+") and ("+o+")"),t.push(s))}},t}},function(e,t,o){var n,i,r,s={},a=(n=function(){return window&&document&&document.all&&!window.atob},function(){return void 0===i&&(i=n.apply(this,arguments)),i}),l=(r={},function(e){if("function"==typeof e)return e();if(void 0===r[e]){var t=function(e){return document.querySelector(e)}.call(this,e);if(window.HTMLIFrameElement&&t instanceof window.HTMLIFrameElement)try{t=t.contentDocument.head}catch{t=null}r[e]=t}return r[e]}),c=null,d=0,u=[],h=o(5);function p(e,t){for(var o=0;o<e.length;o++){var n=e[o],i=s[n.id];if(i){i.refs++;for(var r=0;r<i.parts.length;r++)i.parts[r](n.parts[r]);for(;r<n.parts.length;r++)i.parts.push(y(n.parts[r],t))}else{var a=[];for(r=0;r<n.parts.length;r++)a.push(y(n.parts[r],t));s[n.id]={id:n.id,refs:1,parts:a}}}}function f(e,t){for(var o=[],n={},i=0;i<e.length;i++){var r=e[i],s=t.base?r[0]+t.base:r[0],a={css:r[1],media:r[2],sourceMap:r[3]};n[s]?n[s].parts.push(a):o.push(n[s]={id:s,parts:[a]})}return o}function g(e,t){var o=l(e.insertInto);if(!o)throw new Error("Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid.");var n=u[u.length-1];if("top"===e.insertAt)n?n.nextSibling?o.insertBefore(t,n.nextSibling):o.appendChild(t):o.insertBefore(t,o.firstChild),u.push(t);else if("bottom"===e.insertAt)o.appendChild(t);else{if("object"!=typeof e.insertAt||!e.insertAt.before)throw new Error("[Style Loader]\n\n Invalid value for parameter 'insertAt' ('options.insertAt') found.\n Must be 'top', 'bottom', or Object.\n (https://github.com/webpack-contrib/style-loader#insertat)\n");var i=l(e.insertInto+" "+e.insertAt.before);o.insertBefore(t,i)}}function m(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e);var t=u.indexOf(e);t>=0&&u.splice(t,1)}function b(e){var t=document.createElement("style");return void 0===e.attrs.type&&(e.attrs.type="text/css"),v(t,e.attrs),g(e,t),t}function v(e,t){Object.keys(t).forEach((function(o){e.setAttribute(o,t[o])}))}function y(e,t){var o,n,i,r,s,a;if(t.transform&&e.css){if(!(r=t.transform(e.css)))return function(){};e.css=r}if(t.singleton){var l=d++;o=c||(c=b(t)),n=x.bind(null,o,l,!1),i=x.bind(null,o,l,!0)}else e.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(s=t,a=document.createElement("link"),void 0===s.attrs.type&&(s.attrs.type="text/css"),s.attrs.rel="stylesheet",v(a,s.attrs),g(s,a),n=function(e,t,o){var n=o.css,i=o.sourceMap,r=void 0===t.convertToAbsoluteUrls&&i;(t.convertToAbsoluteUrls||r)&&(n=h(n)),i&&(n+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(i))))+" */");var s=new Blob([n],{type:"text/css"}),a=e.href;e.href=URL.createObjectURL(s),a&&URL.revokeObjectURL(a)}.bind(null,o=a,t),i=function(){m(o),o.href&&URL.revokeObjectURL(o.href)}):(o=b(t),n=function(e,t){var o=t.css,n=t.media;if(n&&e.setAttribute("media",n),e.styleSheet)e.styleSheet.cssText=o;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(o))}}.bind(null,o),i=function(){m(o)});return n(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;n(e=t)}else i()}}e.exports=function(e,t){if(typeof DEBUG<"u"&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");(t=t||{}).attrs="object"==typeof t.attrs?t.attrs:{},t.singleton||"boolean"==typeof t.singleton||(t.singleton=a()),t.insertInto||(t.insertInto="head"),t.insertAt||(t.insertAt="bottom");var o=f(e,t);return p(o,t),function(e){for(var n=[],i=0;i<o.length;i++){var r=o[i];(a=s[r.id]).refs--,n.push(a)}for(e&&p(f(e,t),t),i=0;i<n.length;i++){var a;if(0===(a=n[i]).refs){for(var l=0;l<a.parts.length;l++)a.parts[l]();delete s[a.id]}}}};var k,w=(k=[],function(e,t){return k[e]=t,k.filter(Boolean).join("\n")});function x(e,t,o,n){var i=o?"":n.css;if(e.styleSheet)e.styleSheet.cssText=w(t,i);else{var r=document.createTextNode(i),s=e.childNodes;s[t]&&e.removeChild(s[t]),s.length?e.insertBefore(r,s[t]):e.appendChild(r)}}},function(e,t){e.exports=function(e){var t=typeof window<"u"&&window.location;if(!t)throw new Error("fixUrls requires window.location");if(!e||"string"!=typeof e)return e;var o=t.protocol+"//"+t.host,n=o+t.pathname.replace(/\/[^\/]*$/,"/");return e.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi,(function(e,t){var i,r=t.trim().replace(/^"(.*)"$/,(function(e,t){return t})).replace(/^'(.*)'$/,(function(e,t){return t}));return/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/|\s*$)/i.test(r)?e:(i=0===r.indexOf("//")?r:0===r.indexOf("/")?o+r:n+r.replace(/^\.\//,""),"url("+JSON.stringify(i)+")")}))}},function(e,t,o){var n,i,r,s,a,l,c,d,u;e.exports=(n="cdx-notifies",i="cdx-notify",r="cdx-notify__cross",s="cdx-notify__button--confirm",a="cdx-notify__button--cancel",l="cdx-notify__input",c="cdx-notify__button",d="cdx-notify__btns-wrapper",{alert:u=function(e){var t=document.createElement("DIV"),o=document.createElement("DIV"),n=e.message,s=e.style;return t.classList.add(i),s&&t.classList.add(i+"--"+s),t.innerHTML=n,o.classList.add(r),o.addEventListener("click",t.remove.bind(t)),t.appendChild(o),t},confirm:function(e){var t=u(e),o=document.createElement("div"),n=document.createElement("button"),i=document.createElement("button"),l=t.querySelector("."+r),h=e.cancelHandler,p=e.okHandler;return o.classList.add(d),n.innerHTML=e.okText||"Confirm",i.innerHTML=e.cancelText||"Cancel",n.classList.add(c),i.classList.add(c),n.classList.add(s),i.classList.add(a),h&&"function"==typeof h&&(i.addEventListener("click",h),l.addEventListener("click",h)),p&&"function"==typeof p&&n.addEventListener("click",p),n.addEventListener("click",t.remove.bind(t)),i.addEventListener("click",t.remove.bind(t)),o.appendChild(n),o.appendChild(i),t.appendChild(o),t},prompt:function(e){var t=u(e),o=document.createElement("div"),n=document.createElement("button"),i=document.createElement("input"),a=t.querySelector("."+r),h=e.cancelHandler,p=e.okHandler;return o.classList.add(d),n.innerHTML=e.okText||"Ok",n.classList.add(c),n.classList.add(s),i.classList.add(l),e.placeholder&&i.setAttribute("placeholder",e.placeholder),e.default&&(i.value=e.default),e.inputType&&(i.type=e.inputType),h&&"function"==typeof h&&a.addEventListener("click",h),p&&"function"==typeof p&&n.addEventListener("click",(function(){p(i.value)})),n.addEventListener("click",t.remove.bind(t)),o.appendChild(i),o.appendChild(n),t.appendChild(o),t},getWrapper:function(){var e=document.createElement("DIV");return e.classList.add(n),e}})}]));class he{show(e){ue.show(e)}}var pe={exports:{}};const fe=t(pe.exports=function(){function e(e){var t=e.tags;if(!Object.keys(t).map((function(e){return typeof t[e]})).every((function(e){return"object"===e||"boolean"===e||"function"===e})))throw new Error("The configuration was invalid");this.config=e}var t=["P","LI","TD","TH","DIV","H1","H2","H3","H4","H5","H6","PRE"];function o(e){return-1!==t.indexOf(e.nodeName)}var n=["A","B","STRONG","I","EM","SUB","SUP","U","STRIKE"];function i(e){return-1!==n.indexOf(e.nodeName)}function r(e,t){return e.createTreeWalker(t,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT,null,!1)}function s(e,t,o){return"function"==typeof e.tags[t]?e.tags[t](o):e.tags[t]}function a(e,t){return typeof t>"u"||"boolean"==typeof t&&!t}function l(e,t,o){var n=e.name.toLowerCase();return!0!==t&&("function"==typeof t[n]?!t[n](e.value,o):typeof t[n]>"u"||!1===t[n]||"string"==typeof t[n]&&t[n]!==e.value)}return e.prototype.clean=function(e){const t=document.implementation.createHTMLDocument(),o=t.createElement("div");return o.innerHTML=e,this._sanitize(t,o),o.innerHTML},e.prototype._sanitize=function(e,t){var n=r(e,t),c=n.firstChild();if(c)do{if(c.nodeType!==Node.TEXT_NODE){if(c.nodeType===Node.COMMENT_NODE){t.removeChild(c),this._sanitize(e,t);break}var d,u=i(c);u&&(d=Array.prototype.some.call(c.childNodes,o));var h=!!t.parentNode,p=o(t)&&o(c)&&h,f=c.nodeName.toLowerCase(),g=s(this.config,f,c);if(u&&d||a(c,g)||!this.config.keepNestedBlockElements&&p){if("SCRIPT"!==c.nodeName&&"STYLE"!==c.nodeName)for(;c.childNodes.length>0;)t.insertBefore(c.childNodes[0],c);t.removeChild(c),this._sanitize(e,t);break}for(var m=0;m<c.attributes.length;m+=1){var b=c.attributes[m];l(b,g,c)&&(c.removeAttribute(b.name),m-=1)}this._sanitize(e,c)}else if(""===c.data.trim()&&(c.previousElementSibling&&o(c.previousElementSibling)||c.nextElementSibling&&o(c.nextElementSibling))){t.removeChild(c),this._sanitize(e,t);break}}while(c=n.nextSibling())},e}());function ge(e,t){return e.map((e=>{const o=y(t)?t(e.tool):t;return C(o)||(e.data=be(e.data,o)),e}))}function me(e,t={}){return new fe({tags:t}).clean(e)}function be(e,t){return Array.isArray(e)?function(e,t){return e.map((e=>be(e,t)))}(e,t):k(e)?function(e,t){const o={};for(const n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;const i=e[n],r=ve(t[n])?t[n]:t;o[n]=be(i,r)}return o}(e,t):w(e)?function(e,t){return k(t)?me(e,t):!1===t?me(e,{}):e}(e,t):e}function ve(e){return k(e)||function(e){return"boolean"===v(e)}(e)||y(e)}var ye={exports:{}};
|
||
/*!
|
||
* CodeX.Tooltips
|
||
*
|
||
* @version 1.0.5
|
||
*
|
||
* @licence MIT
|
||
* @author CodeX <https://codex.so>
|
||
*
|
||
*
|
||
*/window;const ke=t(ye.exports=function(e){var t={};function o(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,o),i.l=!0,i.exports}return o.m=e,o.c=t,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t||4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)o.d(n,i,function(t){return e[t]}.bind(null,i));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=0)}([function(e,t,o){e.exports=o(1)},function(e,t,o){o.r(t),o.d(t,"default",(function(){return n}));class n{constructor(){this.nodes={wrapper:null,content:null},this.showed=!1,this.offsetTop=10,this.offsetLeft=10,this.offsetRight=10,this.hidingDelay=0,this.handleWindowScroll=()=>{this.showed&&this.hide(!0)},this.loadStyles(),this.prepare(),window.addEventListener("scroll",this.handleWindowScroll,{passive:!0})}get CSS(){return{tooltip:"ct",tooltipContent:"ct__content",tooltipShown:"ct--shown",placement:{left:"ct--left",bottom:"ct--bottom",right:"ct--right",top:"ct--top"}}}show(e,t,o){this.nodes.wrapper||this.prepare(),this.hidingTimeout&&clearTimeout(this.hidingTimeout);const n=Object.assign({placement:"bottom",marginTop:0,marginLeft:0,marginRight:0,marginBottom:0,delay:70,hidingDelay:0},o);if(n.hidingDelay&&(this.hidingDelay=n.hidingDelay),this.nodes.content.innerHTML="","string"==typeof t)this.nodes.content.appendChild(document.createTextNode(t));else{if(!(t instanceof Node))throw Error("[CodeX Tooltip] Wrong type of «content» passed. It should be an instance of Node or String. But "+typeof t+" given.");this.nodes.content.appendChild(t)}switch(this.nodes.wrapper.classList.remove(...Object.values(this.CSS.placement)),n.placement){case"top":this.placeTop(e,n);break;case"left":this.placeLeft(e,n);break;case"right":this.placeRight(e,n);break;default:this.placeBottom(e,n)}n&&n.delay?this.showingTimeout=setTimeout((()=>{this.nodes.wrapper.classList.add(this.CSS.tooltipShown),this.showed=!0}),n.delay):(this.nodes.wrapper.classList.add(this.CSS.tooltipShown),this.showed=!0)}hide(e=!1){if(this.hidingDelay&&!e)return this.hidingTimeout&&clearTimeout(this.hidingTimeout),void(this.hidingTimeout=setTimeout((()=>{this.hide(!0)}),this.hidingDelay));this.nodes.wrapper.classList.remove(this.CSS.tooltipShown),this.showed=!1,this.showingTimeout&&clearTimeout(this.showingTimeout)}onHover(e,t,o){e.addEventListener("mouseenter",(()=>{this.show(e,t,o)})),e.addEventListener("mouseleave",(()=>{this.hide()}))}destroy(){this.nodes.wrapper.remove(),window.removeEventListener("scroll",this.handleWindowScroll)}prepare(){this.nodes.wrapper=this.make("div",this.CSS.tooltip),this.nodes.content=this.make("div",this.CSS.tooltipContent),this.append(this.nodes.wrapper,this.nodes.content),this.append(document.body,this.nodes.wrapper)}loadStyles(){const e="codex-tooltips-style";if(document.getElementById(e))return;const t=o(2),n=this.make("style",null,{textContent:t.toString(),id:e});this.prepend(document.head,n)}placeBottom(e,t){const o=e.getBoundingClientRect(),n=o.left+e.clientWidth/2-this.nodes.wrapper.offsetWidth/2,i=o.bottom+window.pageYOffset+this.offsetTop+t.marginTop;this.applyPlacement("bottom",n,i)}placeTop(e,t){const o=e.getBoundingClientRect(),n=o.left+e.clientWidth/2-this.nodes.wrapper.offsetWidth/2,i=o.top+window.pageYOffset-this.nodes.wrapper.clientHeight-this.offsetTop;this.applyPlacement("top",n,i)}placeLeft(e,t){const o=e.getBoundingClientRect(),n=o.left-this.nodes.wrapper.offsetWidth-this.offsetLeft-t.marginLeft,i=o.top+window.pageYOffset+e.clientHeight/2-this.nodes.wrapper.offsetHeight/2;this.applyPlacement("left",n,i)}placeRight(e,t){const o=e.getBoundingClientRect(),n=o.right+this.offsetRight+t.marginRight,i=o.top+window.pageYOffset+e.clientHeight/2-this.nodes.wrapper.offsetHeight/2;this.applyPlacement("right",n,i)}applyPlacement(e,t,o){this.nodes.wrapper.classList.add(this.CSS.placement[e]),this.nodes.wrapper.style.left=t+"px",this.nodes.wrapper.style.top=o+"px"}make(e,t=null,o={}){const n=document.createElement(e);Array.isArray(t)?n.classList.add(...t):t&&n.classList.add(t);for(const i in o)o.hasOwnProperty(i)&&(n[i]=o[i]);return n}append(e,t){Array.isArray(t)?t.forEach((t=>e.appendChild(t))):e.appendChild(t)}prepend(e,t){Array.isArray(t)?(t=t.reverse()).forEach((t=>e.prepend(t))):e.prepend(t)}}},function(e,t){e.exports='.ct{z-index:999;opacity:0;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;pointer-events:none;-webkit-transition:opacity 50ms ease-in,-webkit-transform 70ms cubic-bezier(.215,.61,.355,1);transition:opacity 50ms ease-in,-webkit-transform 70ms cubic-bezier(.215,.61,.355,1);transition:opacity 50ms ease-in,transform 70ms cubic-bezier(.215,.61,.355,1);transition:opacity 50ms ease-in,transform 70ms cubic-bezier(.215,.61,.355,1),-webkit-transform 70ms cubic-bezier(.215,.61,.355,1);will-change:opacity,top,left;-webkit-box-shadow:0 8px 12px 0 rgba(29,32,43,.17),0 4px 5px -3px rgba(5,6,12,.49);box-shadow:0 8px 12px 0 rgba(29,32,43,.17),0 4px 5px -3px rgba(5,6,12,.49);border-radius:9px}.ct,.ct:before{position:absolute;top:0;left:0}.ct:before{content:"";bottom:0;right:0;background-color:#1d202b;z-index:-1;border-radius:4px}@supports(-webkit-mask-box-image:url("")){.ct:before{border-radius:0;-webkit-mask-box-image:url(\'data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24"><path d="M10.71 0h2.58c3.02 0 4.64.42 6.1 1.2a8.18 8.18 0 013.4 3.4C23.6 6.07 24 7.7 24 10.71v2.58c0 3.02-.42 4.64-1.2 6.1a8.18 8.18 0 01-3.4 3.4c-1.47.8-3.1 1.21-6.11 1.21H10.7c-3.02 0-4.64-.42-6.1-1.2a8.18 8.18 0 01-3.4-3.4C.4 17.93 0 16.3 0 13.29V10.7c0-3.02.42-4.64 1.2-6.1a8.18 8.18 0 013.4-3.4C6.07.4 7.7 0 10.71 0z"/></svg>\') 48% 41% 37.9% 53.3%}}@media (--mobile){.ct{display:none}}.ct__content{padding:6px 10px;color:#cdd1e0;font-size:12px;text-align:center;letter-spacing:.02em;line-height:1em}.ct:after{content:"";width:8px;height:8px;position:absolute;background-color:#1d202b;z-index:-1}.ct--bottom{-webkit-transform:translateY(5px);transform:translateY(5px)}.ct--bottom:after{top:-3px;left:50%;-webkit-transform:translateX(-50%) rotate(-45deg);transform:translateX(-50%) rotate(-45deg)}.ct--top{-webkit-transform:translateY(-5px);transform:translateY(-5px)}.ct--top:after{top:auto;bottom:-3px;left:50%;-webkit-transform:translateX(-50%) rotate(-45deg);transform:translateX(-50%) rotate(-45deg)}.ct--left{-webkit-transform:translateX(-5px);transform:translateX(-5px)}.ct--left:after{top:50%;left:auto;right:0;-webkit-transform:translate(41.6%,-50%) rotate(-45deg);transform:translate(41.6%,-50%) rotate(-45deg)}.ct--right{-webkit-transform:translateX(5px);transform:translateX(5px)}.ct--right:after{top:50%;left:0;-webkit-transform:translate(-41.6%,-50%) rotate(-45deg);transform:translate(-41.6%,-50%) rotate(-45deg)}.ct--shown{opacity:1;-webkit-transform:none;transform:none}'}]).default);let we=null;function xe(){we||(we=new ke)}function Ee(e=!1){xe(),null==we||we.hide(e)}function Ce(e,t,o){xe(),null==we||we.onHover(e,t,o)}const Se=function e(t,o){const n={};return Object.entries(t).forEach((([t,i])=>{if(k(i)){const r=o?`${o}.${t}`:t;Object.values(i).every((e=>w(e)))?n[t]=r:n[t]=e(i,r)}else n[t]=i})),n}(U);const Te=class e{constructor(e,t){this.cursor=-1,this.items=[],this.items=e||[],this.focusedCssClass=t}get currentItem(){return-1===this.cursor?null:this.items[this.cursor]}setCursor(e){e<this.items.length&&e>=-1&&(this.dropCursor(),this.cursor=e,this.items[this.cursor].classList.add(this.focusedCssClass))}setItems(e){this.items=e}next(){this.cursor=this.leafNodesAndReturnIndex(e.directions.RIGHT)}previous(){this.cursor=this.leafNodesAndReturnIndex(e.directions.LEFT)}dropCursor(){-1!==this.cursor&&(this.items[this.cursor].classList.remove(this.focusedCssClass),this.cursor=-1)}leafNodesAndReturnIndex(t){if(0===this.items.length)return this.cursor;let o=this.cursor;return-1===o?o=t===e.directions.RIGHT?-1:0:this.items[o].classList.remove(this.focusedCssClass),o=t===e.directions.RIGHT?(o+1)%this.items.length:(this.items.length+o-1)%this.items.length,F.canSetCaret(this.items[o])&&O((()=>V.setCursor(this.items[o])),50)(),this.items[o].classList.add(this.focusedCssClass),o}};Te.directions={RIGHT:"right",LEFT:"left"};let _e=Te,Oe=class e{constructor(t){this.iterator=null,this.activated=!1,this.flipCallbacks=[],this.onKeyDown=t=>{if(this.isEventReadyForHandling(t)&&!0!==t.shiftKey)switch(e.usedKeys.includes(t.keyCode)&&t.preventDefault(),t.keyCode){case s:this.handleTabPress(t);break;case c:case d:this.flipLeft();break;case h:case u:this.flipRight();break;case a:this.handleEnterPress(t)}},this.iterator=new _e(t.items,t.focusedItemClass),this.activateCallback=t.activateCallback,this.allowedKeys=t.allowedKeys||e.usedKeys}get isActivated(){return this.activated}static get usedKeys(){return[s,c,h,a,d,u]}activate(e,t){this.activated=!0,e&&this.iterator.setItems(e),void 0!==t&&this.iterator.setCursor(t),document.addEventListener("keydown",this.onKeyDown,!0)}deactivate(){this.activated=!1,this.dropCursor(),document.removeEventListener("keydown",this.onKeyDown)}focusFirst(){this.dropCursor(),this.flipRight()}flipLeft(){this.iterator.previous(),this.flipCallback()}flipRight(){this.iterator.next(),this.flipCallback()}hasFocus(){return!!this.iterator.currentItem}onFlip(e){this.flipCallbacks.push(e)}removeOnFlip(e){this.flipCallbacks=this.flipCallbacks.filter((t=>t!==e))}dropCursor(){this.iterator.dropCursor()}isEventReadyForHandling(e){return this.activated&&this.allowedKeys.includes(e.keyCode)}handleTabPress(e){switch(e.shiftKey?_e.directions.LEFT:_e.directions.RIGHT){case _e.directions.RIGHT:this.flipRight();break;case _e.directions.LEFT:this.flipLeft()}}handleEnterPress(e){this.activated&&(this.iterator.currentItem&&(e.stopPropagation(),e.preventDefault(),this.iterator.currentItem.click()),y(this.activateCallback)&&this.activateCallback(this.iterator.currentItem))}flipCallback(){this.iterator.currentItem&&this.iterator.currentItem.scrollIntoViewIfNeeded(),this.flipCallbacks.forEach((e=>e()))}};const Be='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M7.69998 12.6L7.67896 12.62C6.53993 13.7048 6.52012 15.5155 7.63516 16.625V16.625C8.72293 17.7073 10.4799 17.7102 11.5712 16.6314L13.0263 15.193C14.0703 14.1609 14.2141 12.525 13.3662 11.3266L13.22 11.12"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M16.22 11.12L16.3564 10.9805C17.2895 10.0265 17.3478 8.5207 16.4914 7.49733V7.49733C15.5691 6.39509 13.9269 6.25143 12.8271 7.17675L11.3901 8.38588C10.0935 9.47674 9.95706 11.4241 11.0888 12.6852L11.12 12.72"/></svg>',Ie='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M11.5 17.5L5 11M5 11V15.5M5 11H9.5"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M12.5 6.5L19 13M19 13V8.5M19 13H14.5"/></svg>';function Me(e){return(t,o)=>[[e,t].filter((e=>!!e)).join("__"),o].filter((e=>!!e)).join("--")}const Pe=Me("ce-hint"),Le={root:Pe(),alignedStart:Pe(null,"align-left"),alignedCenter:Pe(null,"align-center"),title:Pe("title"),description:Pe("description")};class Ae{constructor(e){this.nodes={root:F.make("div",[Le.root,"center"===e.alignment?Le.alignedCenter:Le.alignedStart]),title:F.make("div",Le.title,{textContent:e.title})},this.nodes.root.appendChild(this.nodes.title),void 0!==e.description&&(this.nodes.description=F.make("div",Le.description,{textContent:e.description}),this.nodes.root.appendChild(this.nodes.description))}getElement(){return this.nodes.root}}let Ne=class{constructor(e){this.params=e}get name(){if(void 0!==this.params&&"name"in this.params)return this.params.name}destroy(){Ee()}onChildrenOpen(){var e;void 0!==this.params&&"children"in this.params&&"function"==typeof(null==(e=this.params.children)?void 0:e.onOpen)&&this.params.children.onOpen()}onChildrenClose(){var e;void 0!==this.params&&"children"in this.params&&"function"==typeof(null==(e=this.params.children)?void 0:e.onClose)&&this.params.children.onClose()}handleClick(){var e,t;void 0!==this.params&&"onActivate"in this.params&&(null==(t=(e=this.params).onActivate)||t.call(e,this.params))}addHint(e,t){Ce(e,new Ae(t).getElement(),{placement:t.position,hidingDelay:100})}get children(){var e;return void 0!==this.params&&"children"in this.params&&void 0!==(null==(e=this.params.children)?void 0:e.items)?this.params.children.items:[]}get hasChildren(){return this.children.length>0}get isChildrenOpen(){var e;return void 0!==this.params&&"children"in this.params&&!0===(null==(e=this.params.children)?void 0:e.isOpen)}get isChildrenFlippable(){var e;return!(void 0===this.params||!("children"in this.params)||!1===(null==(e=this.params.children)?void 0:e.isFlippable))}get isChildrenSearchable(){var e;return void 0!==this.params&&"children"in this.params&&!0===(null==(e=this.params.children)?void 0:e.searchable)}get closeOnActivate(){return void 0!==this.params&&"closeOnActivate"in this.params&&this.params.closeOnActivate}get isActive(){return void 0!==this.params&&"isActive"in this.params&&("function"==typeof this.params.isActive?this.params.isActive():!0===this.params.isActive)}};const je=Me("ce-popover-item"),De={container:je(),active:je(null,"active"),disabled:je(null,"disabled"),focused:je(null,"focused"),hidden:je(null,"hidden"),confirmationState:je(null,"confirmation"),noHover:je(null,"no-hover"),noFocus:je(null,"no-focus"),title:je("title"),secondaryTitle:je("secondary-title"),icon:je("icon"),iconTool:je("icon","tool"),iconChevronRight:je("icon","chevron-right"),wobbleAnimation:Me("wobble")()};let Re=class extends Ne{constructor(e,t){super(e),this.params=e,this.nodes={root:null,icon:null},this.confirmationState=null,this.removeSpecialFocusBehavior=()=>{var e;null==(e=this.nodes.root)||e.classList.remove(De.noFocus)},this.removeSpecialHoverBehavior=()=>{var e;null==(e=this.nodes.root)||e.classList.remove(De.noHover)},this.onErrorAnimationEnd=()=>{var e,t;null==(e=this.nodes.icon)||e.classList.remove(De.wobbleAnimation),null==(t=this.nodes.icon)||t.removeEventListener("animationend",this.onErrorAnimationEnd)},this.nodes.root=this.make(e,t)}get isDisabled(){return!0===this.params.isDisabled}get toggle(){return this.params.toggle}get title(){return this.params.title}get isConfirmationStateEnabled(){return null!==this.confirmationState}get isFocused(){return null!==this.nodes.root&&this.nodes.root.classList.contains(De.focused)}getElement(){return this.nodes.root}handleClick(){this.isConfirmationStateEnabled&&null!==this.confirmationState?this.activateOrEnableConfirmationMode(this.confirmationState):this.activateOrEnableConfirmationMode(this.params)}toggleActive(e){var t;null==(t=this.nodes.root)||t.classList.toggle(De.active,e)}toggleHidden(e){var t;null==(t=this.nodes.root)||t.classList.toggle(De.hidden,e)}reset(){this.isConfirmationStateEnabled&&this.disableConfirmationMode()}onFocus(){this.disableSpecialHoverAndFocusBehavior()}make(e,t){var o,n;const i=(null==t?void 0:t.wrapperTag)||"div",r=F.make(i,De.container,{type:"button"===i?"button":void 0});return e.name&&(r.dataset.itemName=e.name),this.nodes.icon=F.make("div",[De.icon,De.iconTool],{innerHTML:e.icon||'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><circle cx="12" cy="12" r="4" stroke="currentColor" stroke-width="2"/></svg>'}),r.appendChild(this.nodes.icon),void 0!==e.title&&r.appendChild(F.make("div",De.title,{innerHTML:e.title||""})),e.secondaryLabel&&r.appendChild(F.make("div",De.secondaryTitle,{textContent:e.secondaryLabel})),this.hasChildren&&r.appendChild(F.make("div",[De.icon,De.iconChevronRight],{innerHTML:'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M9.58284 17.5L14.4414 12.6414C14.5195 12.5633 14.5195 12.4367 14.4414 12.3586L9.58284 7.5"/></svg>'})),this.isActive&&r.classList.add(De.active),e.isDisabled&&r.classList.add(De.disabled),void 0!==e.hint&&!1!==(null==(o=null==t?void 0:t.hint)?void 0:o.enabled)&&this.addHint(r,{...e.hint,position:(null==(n=null==t?void 0:t.hint)?void 0:n.position)||"right"}),r}enableConfirmationMode(e){if(null===this.nodes.root)return;const t={...this.params,...e,confirmation:"confirmation"in e?e.confirmation:void 0},o=this.make(t);this.nodes.root.innerHTML=o.innerHTML,this.nodes.root.classList.add(De.confirmationState),this.confirmationState=e,this.enableSpecialHoverAndFocusBehavior()}disableConfirmationMode(){if(null===this.nodes.root)return;const e=this.make(this.params);this.nodes.root.innerHTML=e.innerHTML,this.nodes.root.classList.remove(De.confirmationState),this.confirmationState=null,this.disableSpecialHoverAndFocusBehavior()}enableSpecialHoverAndFocusBehavior(){var e,t,o;null==(e=this.nodes.root)||e.classList.add(De.noHover),null==(t=this.nodes.root)||t.classList.add(De.noFocus),null==(o=this.nodes.root)||o.addEventListener("mouseleave",this.removeSpecialHoverBehavior,{once:!0})}disableSpecialHoverAndFocusBehavior(){var e;this.removeSpecialFocusBehavior(),this.removeSpecialHoverBehavior(),null==(e=this.nodes.root)||e.removeEventListener("mouseleave",this.removeSpecialHoverBehavior)}activateOrEnableConfirmationMode(e){var t;if("confirmation"in e&&void 0!==e.confirmation)this.enableConfirmationMode(e.confirmation);else try{null==(t=e.onActivate)||t.call(e,e),this.disableConfirmationMode()}catch{this.animateError()}}animateError(){var e,t,o;null!=(e=this.nodes.icon)&&e.classList.contains(De.wobbleAnimation)||(null==(t=this.nodes.icon)||t.classList.add(De.wobbleAnimation),null==(o=this.nodes.icon)||o.addEventListener("animationend",this.onErrorAnimationEnd))}};const Fe=Me("ce-popover-item-separator"),He={container:Fe(),line:Fe("line"),hidden:Fe(null,"hidden")};class Ue extends Ne{constructor(){super(),this.nodes={root:F.make("div",He.container),line:F.make("div",He.line)},this.nodes.root.appendChild(this.nodes.line)}getElement(){return this.nodes.root}toggleHidden(e){var t;null==(t=this.nodes.root)||t.classList.toggle(He.hidden,e)}}var ze=(e=>(e.Closed="closed",e.ClosedOnActivate="closed-on-activate",e))(ze||{});const We=Me("ce-popover"),$e={popover:We(),popoverContainer:We("container"),popoverOpenTop:We(null,"open-top"),popoverOpenLeft:We(null,"open-left"),popoverOpened:We(null,"opened"),search:We("search"),nothingFoundMessage:We("nothing-found-message"),nothingFoundMessageDisplayed:We("nothing-found-message","displayed"),items:We("items"),overlay:We("overlay"),overlayHidden:We("overlay","hidden"),popoverNested:We(null,"nested"),getPopoverNestedClass:e=>We(null,`nested-level-${e.toString()}`),popoverInline:We(null,"inline"),popoverHeader:We("header")};var qe=(e=>(e.NestingLevel="--nesting-level",e.PopoverHeight="--popover-height",e.InlinePopoverWidth="--inline-popover-width",e.TriggerItemLeft="--trigger-item-left",e.TriggerItemTop="--trigger-item-top",e))(qe||{});const Ke=Me("ce-popover-item-html"),Ye={root:Ke(),hidden:Ke(null,"hidden")};let Xe=class extends Ne{constructor(e,t){var o,n;super(e),this.nodes={root:F.make("div",Ye.root)},this.nodes.root.appendChild(e.element),e.name&&(this.nodes.root.dataset.itemName=e.name),void 0!==e.hint&&!1!==(null==(o=null==t?void 0:t.hint)?void 0:o.enabled)&&this.addHint(this.nodes.root,{...e.hint,position:(null==(n=null==t?void 0:t.hint)?void 0:n.position)||"right"})}getElement(){return this.nodes.root}toggleHidden(e){var t;null==(t=this.nodes.root)||t.classList.toggle(Ye.hidden,e)}getControls(){const e=this.nodes.root.querySelectorAll(`button, ${F.allInputsSelector}`);return Array.from(e)}};class Ve extends q{constructor(e,t={}){super(),this.params=e,this.itemsRenderParams=t,this.listeners=new Y,this.messages={nothingFound:"Nothing found",search:"Search"},this.items=this.buildItems(e.items),e.messages&&(this.messages={...this.messages,...e.messages}),this.nodes={},this.nodes.popoverContainer=F.make("div",[$e.popoverContainer]),this.nodes.nothingFoundMessage=F.make("div",[$e.nothingFoundMessage],{textContent:this.messages.nothingFound}),this.nodes.popoverContainer.appendChild(this.nodes.nothingFoundMessage),this.nodes.items=F.make("div",[$e.items]),this.items.forEach((e=>{const t=e.getElement();null!==t&&this.nodes.items.appendChild(t)})),this.nodes.popoverContainer.appendChild(this.nodes.items),this.listeners.on(this.nodes.popoverContainer,"click",(e=>this.handleClick(e))),this.nodes.popover=F.make("div",[$e.popover,this.params.class]),this.nodes.popover.appendChild(this.nodes.popoverContainer)}get itemsDefault(){return this.items.filter((e=>e instanceof Re))}getElement(){return this.nodes.popover}show(){this.nodes.popover.classList.add($e.popoverOpened),void 0!==this.search&&this.search.focus()}hide(){this.nodes.popover.classList.remove($e.popoverOpened),this.nodes.popover.classList.remove($e.popoverOpenTop),this.itemsDefault.forEach((e=>e.reset())),void 0!==this.search&&this.search.clear(),this.emit(ze.Closed)}destroy(){var e;this.items.forEach((e=>e.destroy())),this.nodes.popover.remove(),this.listeners.removeAll(),null==(e=this.search)||e.destroy()}activateItemByName(e){const t=this.items.find((t=>t.name===e));this.handleItemClick(t)}buildItems(e){return e.map((e=>{switch(e.type){case ae.Separator:return new Ue;case ae.Html:return new Xe(e,this.itemsRenderParams[ae.Html]);default:return new Re(e,this.itemsRenderParams[ae.Default])}}))}getTargetItem(e){return this.items.filter((e=>e instanceof Re||e instanceof Xe)).find((t=>{const o=t.getElement();return null!==o&&e.composedPath().includes(o)}))}handleItemClick(e){if(!("isDisabled"in e)||!e.isDisabled){if(e.hasChildren)return this.showNestedItems(e),void("handleClick"in e&&"function"==typeof e.handleClick&&e.handleClick());this.itemsDefault.filter((t=>t!==e)).forEach((e=>e.reset())),"handleClick"in e&&"function"==typeof e.handleClick&&e.handleClick(),this.toggleItemActivenessIfNeeded(e),e.closeOnActivate&&(this.hide(),this.emit(ze.ClosedOnActivate))}}handleClick(e){const t=this.getTargetItem(e);void 0!==t&&this.handleItemClick(t)}toggleItemActivenessIfNeeded(e){if(e instanceof Re&&(!0===e.toggle&&e.toggleActive(),"string"==typeof e.toggle)){const t=this.itemsDefault.filter((t=>t.toggle===e.toggle));if(1===t.length)return void e.toggleActive();t.forEach((t=>{t.toggleActive(t===e)}))}}}var Ge=(e=>(e.Search="search",e))(Ge||{});const Ze=Me("cdx-search-field"),Je={wrapper:Ze(),icon:Ze("icon"),input:Ze("input")};class Qe extends q{constructor({items:e,placeholder:t}){super(),this.listeners=new Y,this.items=e,this.wrapper=F.make("div",Je.wrapper);const o=F.make("div",Je.icon,{innerHTML:'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><circle cx="10.5" cy="10.5" r="5.5" stroke="currentColor" stroke-width="2"/><line x1="15.4142" x2="19" y1="15" y2="18.5858" stroke="currentColor" stroke-linecap="round" stroke-width="2"/></svg>'});this.input=F.make("input",Je.input,{placeholder:t,tabIndex:-1}),this.wrapper.appendChild(o),this.wrapper.appendChild(this.input),this.listeners.on(this.input,"input",(()=>{this.searchQuery=this.input.value,this.emit(Ge.Search,{query:this.searchQuery,items:this.foundItems})}))}getElement(){return this.wrapper}focus(){this.input.focus()}clear(){this.input.value="",this.searchQuery="",this.emit(Ge.Search,{query:"",items:this.foundItems})}destroy(){this.listeners.removeAll()}get foundItems(){return this.items.filter((e=>this.checkItem(e)))}checkItem(e){var t,o;const n=(null==(t=e.title)?void 0:t.toLowerCase())||"",i=null==(o=this.searchQuery)?void 0:o.toLowerCase();return void 0!==i&&n.includes(i)}}var et=Object.defineProperty,tt=Object.getOwnPropertyDescriptor;const ot=class e extends Ve{constructor(e,t){super(e,t),this.nestingLevel=0,this.nestedPopoverTriggerItem=null,this.previouslyHoveredItem=null,this.scopeElement=document.body,this.hide=()=>{var e;super.hide(),this.destroyNestedPopoverIfExists(),null==(e=this.flipper)||e.deactivate(),this.previouslyHoveredItem=null},this.onFlip=()=>{const e=this.itemsDefault.find((e=>e.isFocused));null==e||e.onFocus()},this.onSearch=e=>{var t;const o=""===e.query,n=0===e.items.length;this.items.forEach((t=>{let i=!1;t instanceof Re?i=!e.items.includes(t):(t instanceof Ue||t instanceof Xe)&&(i=n||!o),t.toggleHidden(i)})),this.toggleNothingFoundMessage(n);const i=""===e.query?this.flippableElements:e.items.map((e=>e.getElement()));null!=(t=this.flipper)&&t.isActivated&&(this.flipper.deactivate(),this.flipper.activate(i))},void 0!==e.nestingLevel&&(this.nestingLevel=e.nestingLevel),this.nestingLevel>0&&this.nodes.popover.classList.add($e.popoverNested),void 0!==e.scopeElement&&(this.scopeElement=e.scopeElement),null!==this.nodes.popoverContainer&&this.listeners.on(this.nodes.popoverContainer,"mouseover",(e=>this.handleHover(e))),e.searchable&&this.addSearch(),!1!==e.flippable&&(this.flipper=new Oe({items:this.flippableElements,focusedItemClass:De.focused,allowedKeys:[s,d,u,a]}),this.flipper.onFlip(this.onFlip))}hasFocus(){return void 0!==this.flipper&&this.flipper.hasFocus()}get scrollTop(){return null===this.nodes.items?0:this.nodes.items.scrollTop}get offsetTop(){return null===this.nodes.popoverContainer?0:this.nodes.popoverContainer.offsetTop}show(){var e;this.nodes.popover.style.setProperty(qe.PopoverHeight,this.size.height+"px"),this.shouldOpenBottom||this.nodes.popover.classList.add($e.popoverOpenTop),this.shouldOpenRight||this.nodes.popover.classList.add($e.popoverOpenLeft),super.show(),null==(e=this.flipper)||e.activate(this.flippableElements)}destroy(){this.hide(),super.destroy()}showNestedItems(e){null!==this.nestedPopover&&void 0!==this.nestedPopover||(this.nestedPopoverTriggerItem=e,this.showNestedPopoverForItem(e))}handleHover(e){const t=this.getTargetItem(e);void 0!==t&&this.previouslyHoveredItem!==t&&(this.destroyNestedPopoverIfExists(),this.previouslyHoveredItem=t,t.hasChildren&&this.showNestedPopoverForItem(t))}setTriggerItemPosition(e,t){const o=t.getElement(),n=(o?o.offsetTop:0)-this.scrollTop,i=this.offsetTop+n;e.style.setProperty(qe.TriggerItemTop,i+"px")}destroyNestedPopoverIfExists(){var e,t;void 0===this.nestedPopover||null===this.nestedPopover||(this.nestedPopover.off(ze.ClosedOnActivate,this.hide),this.nestedPopover.hide(),this.nestedPopover.destroy(),this.nestedPopover.getElement().remove(),this.nestedPopover=null,null==(e=this.flipper)||e.activate(this.flippableElements),null==(t=this.nestedPopoverTriggerItem)||t.onChildrenClose())}showNestedPopoverForItem(t){var o;this.nestedPopover=new e({searchable:t.isChildrenSearchable,items:t.children,nestingLevel:this.nestingLevel+1,flippable:t.isChildrenFlippable,messages:this.messages}),t.onChildrenOpen(),this.nestedPopover.on(ze.ClosedOnActivate,this.hide);const n=this.nestedPopover.getElement();return this.nodes.popover.appendChild(n),this.setTriggerItemPosition(n,t),n.style.setProperty(qe.NestingLevel,this.nestedPopover.nestingLevel.toString()),this.nestedPopover.show(),null==(o=this.flipper)||o.deactivate(),this.nestedPopover}get shouldOpenBottom(){if(void 0===this.nodes.popover||null===this.nodes.popover)return!1;const e=this.nodes.popoverContainer.getBoundingClientRect(),t=this.scopeElement.getBoundingClientRect(),o=this.size.height,n=e.top+o,i=e.top-o,r=Math.min(window.innerHeight,t.bottom);return i<t.top||n<=r}get shouldOpenRight(){if(void 0===this.nodes.popover||null===this.nodes.popover)return!1;const e=this.nodes.popover.getBoundingClientRect(),t=this.scopeElement.getBoundingClientRect(),o=this.size.width,n=e.right+o,i=e.left-o,r=Math.min(window.innerWidth,t.right);return i<t.left||n<=r}get size(){var e;const t={height:0,width:0};if(null===this.nodes.popover)return t;const o=this.nodes.popover.cloneNode(!0);o.style.visibility="hidden",o.style.position="absolute",o.style.top="-1000px",o.classList.add($e.popoverOpened),null==(e=o.querySelector("."+$e.popoverNested))||e.remove(),document.body.appendChild(o);const n=o.querySelector("."+$e.popoverContainer);return t.height=n.offsetHeight,t.width=n.offsetWidth,o.remove(),t}get flippableElements(){return this.items.map((e=>e instanceof Re?e.getElement():e instanceof Xe?e.getControls():void 0)).flat().filter((e=>null!=e))}addSearch(){this.search=new Qe({items:this.itemsDefault,placeholder:this.messages.search}),this.search.on(Ge.Search,this.onSearch);const e=this.search.getElement();e.classList.add($e.search),this.nodes.popoverContainer.insertBefore(e,this.nodes.popoverContainer.firstChild)}toggleNothingFoundMessage(e){this.nodes.nothingFoundMessage.classList.toggle($e.nothingFoundMessageDisplayed,e)}};((e,t,o,n)=>{for(var i,r=n>1?void 0:n?tt(t,o):t,s=e.length-1;s>=0;s--)(i=e[s])&&(r=(n?i(t,o,r):i(r))||r);n&&r&&et(t,o,r)})([j],ot.prototype,"size",1);let nt=ot;class it extends nt{constructor(e){const t=!D();super({...e,class:$e.popoverInline},{[ae.Default]:{wrapperTag:"button",hint:{position:"top",alignment:"center",enabled:t}},[ae.Html]:{hint:{position:"top",alignment:"center",enabled:t}}}),this.items.forEach((e=>{!(e instanceof Re)&&!(e instanceof Xe)||e.hasChildren&&e.isChildrenOpen&&this.showNestedItems(e)}))}get offsetLeft(){return null===this.nodes.popoverContainer?0:this.nodes.popoverContainer.offsetLeft}show(){0===this.nestingLevel&&this.nodes.popover.style.setProperty(qe.InlinePopoverWidth,this.size.width+"px"),super.show()}handleHover(){}setTriggerItemPosition(e,t){const o=t.getElement(),n=o?o.offsetLeft:0,i=this.offsetLeft+n;e.style.setProperty(qe.TriggerItemLeft,i+"px")}showNestedItems(e){if(this.nestedPopoverTriggerItem===e)return this.destroyNestedPopoverIfExists(),void(this.nestedPopoverTriggerItem=null);super.showNestedItems(e)}showNestedPopoverForItem(e){const t=super.showNestedPopoverForItem(e);return t.getElement().classList.add($e.getPopoverNestedClass(t.nestingLevel)),t}handleItemClick(e){var t;e!==this.nestedPopoverTriggerItem&&(null==(t=this.nestedPopoverTriggerItem)||t.handleClick(),super.destroyNestedPopoverIfExists()),super.handleItemClick(e)}}const rt=class e{constructor(){this.scrollPosition=null}lock(){R?this.lockHard():document.body.classList.add(e.CSS.scrollLocked)}unlock(){R?this.unlockHard():document.body.classList.remove(e.CSS.scrollLocked)}lockHard(){this.scrollPosition=window.pageYOffset,document.documentElement.style.setProperty("--window-scroll-offset",`${this.scrollPosition}px`),document.body.classList.add(e.CSS.scrollLockedHard)}unlockHard(){document.body.classList.remove(e.CSS.scrollLockedHard),null!==this.scrollPosition&&window.scrollTo(0,this.scrollPosition),this.scrollPosition=null}};rt.CSS={scrollLocked:"ce-scroll-locked",scrollLockedHard:"ce-scroll-locked--hard"};let st=rt;const at=Me("ce-popover-header"),lt={root:at(),text:at("text"),backButton:at("back-button")};class ct{constructor({text:e,onBackButtonClick:t}){this.listeners=new Y,this.text=e,this.onBackButtonClick=t,this.nodes={root:F.make("div",[lt.root]),backButton:F.make("button",[lt.backButton]),text:F.make("div",[lt.text])},this.nodes.backButton.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M14.5 17.5L9.64142 12.6414C9.56331 12.5633 9.56331 12.4367 9.64142 12.3586L14.5 7.5"/></svg>',this.nodes.root.appendChild(this.nodes.backButton),this.listeners.on(this.nodes.backButton,"click",this.onBackButtonClick),this.nodes.text.innerText=this.text,this.nodes.root.appendChild(this.nodes.text)}getElement(){return this.nodes.root}destroy(){this.nodes.root.remove(),this.listeners.destroy()}}class dt{constructor(){this.history=[]}push(e){this.history.push(e)}pop(){return this.history.pop()}get currentTitle(){return 0===this.history.length?"":this.history[this.history.length-1].title}get currentItems(){return 0===this.history.length?[]:this.history[this.history.length-1].items}reset(){for(;this.history.length>1;)this.pop()}}let ut=class extends Ve{constructor(e){super(e,{[ae.Default]:{hint:{enabled:!1}},[ae.Html]:{hint:{enabled:!1}}}),this.scrollLocker=new st,this.history=new dt,this.isHidden=!0,this.nodes.overlay=F.make("div",[$e.overlay,$e.overlayHidden]),this.nodes.popover.insertBefore(this.nodes.overlay,this.nodes.popover.firstChild),this.listeners.on(this.nodes.overlay,"click",(()=>{this.hide()})),this.history.push({items:e.items})}show(){this.nodes.overlay.classList.remove($e.overlayHidden),super.show(),this.scrollLocker.lock(),this.isHidden=!1}hide(){this.isHidden||(super.hide(),this.nodes.overlay.classList.add($e.overlayHidden),this.scrollLocker.unlock(),this.history.reset(),this.isHidden=!0)}destroy(){super.destroy(),this.scrollLocker.unlock()}showNestedItems(e){this.updateItemsAndHeader(e.children,e.title),this.history.push({title:e.title,items:e.children})}updateItemsAndHeader(e,t){if(null!==this.header&&void 0!==this.header&&(this.header.destroy(),this.header=null),void 0!==t){this.header=new ct({text:t,onBackButtonClick:()=>{this.history.pop(),this.updateItemsAndHeader(this.history.currentItems,this.history.currentTitle)}});const e=this.header.getElement();null!==e&&this.nodes.popoverContainer.insertBefore(e,this.nodes.popoverContainer.firstChild)}this.items.forEach((e=>{var t;return null==(t=e.getElement())?void 0:t.remove()})),this.items=this.buildItems(e),this.items.forEach((e=>{var t;const o=e.getElement();null!==o&&(null==(t=this.nodes.items)||t.appendChild(o))}))}};var ht={exports:{}};
|
||
/*!
|
||
* Library for handling keyboard shortcuts
|
||
* @copyright CodeX (https://codex.so)
|
||
* @license MIT
|
||
* @author CodeX (https://codex.so)
|
||
* @version 1.2.0
|
||
*/window;const pt=t(ht.exports=function(e){var t={};function o(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,o),i.l=!0,i.exports}return o.m=e,o.c=t,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t||4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)o.d(n,i,function(t){return e[t]}.bind(null,i));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=0)}([function(e,t,o){function n(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function i(e,t,o){return t&&n(e.prototype,t),o&&n(e,o),e}o.r(t);var r=function(){function e(t){var o=this;(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),this.commands={},this.keys={},this.name=t.name,this.parseShortcutName(t.name),this.element=t.on,this.callback=t.callback,this.executeShortcut=function(e){o.execute(e)},this.element.addEventListener("keydown",this.executeShortcut,!1)}return i(e,null,[{key:"supportedCommands",get:function(){return{SHIFT:["SHIFT"],CMD:["CMD","CONTROL","COMMAND","WINDOWS","CTRL"],ALT:["ALT","OPTION"]}}},{key:"keyCodes",get:function(){return{0:48,1:49,2:50,3:51,4:52,5:53,6:54,7:55,8:56,9:57,A:65,B:66,C:67,D:68,E:69,F:70,G:71,H:72,I:73,J:74,K:75,L:76,M:77,N:78,O:79,P:80,Q:81,R:82,S:83,T:84,U:85,V:86,W:87,X:88,Y:89,Z:90,BACKSPACE:8,ENTER:13,ESCAPE:27,LEFT:37,UP:38,RIGHT:39,DOWN:40,INSERT:45,DELETE:46,".":190}}}]),i(e,[{key:"parseShortcutName",value:function(t){t=t.split("+");for(var o=0;o<t.length;o++){t[o]=t[o].toUpperCase();var n=!1;for(var i in e.supportedCommands)if(e.supportedCommands[i].includes(t[o])){n=this.commands[i]=!0;break}n||(this.keys[t[o]]=!0)}for(var r in e.supportedCommands)this.commands[r]||(this.commands[r]=!1)}},{key:"execute",value:function(t){var o,n={CMD:t.ctrlKey||t.metaKey,SHIFT:t.shiftKey,ALT:t.altKey},i=!0;for(o in this.commands)this.commands[o]!==n[o]&&(i=!1);var r,s=!0;for(r in this.keys)s=s&&t.keyCode===e.keyCodes[r];i&&s&&this.callback(t)}},{key:"remove",value:function(){this.element.removeEventListener("keydown",this.executeShortcut)}}]),e}();t.default=r}]).default);const ft=new class{constructor(){this.registeredShortcuts=new Map}add(e){if(this.findShortcut(e.on,e.name))throw Error(`Shortcut ${e.name} is already registered for ${e.on}. Please remove it before add a new handler.`);const t=new pt({name:e.name,on:e.on,callback:e.handler}),o=this.registeredShortcuts.get(e.on)||[];this.registeredShortcuts.set(e.on,[...o,t])}remove(e,t){const o=this.findShortcut(e,t);if(!o)return;o.remove();const n=this.registeredShortcuts.get(e).filter((e=>e!==o));0!==n.length?this.registeredShortcuts.set(e,n):this.registeredShortcuts.delete(e)}findShortcut(e,t){return(this.registeredShortcuts.get(e)||[]).find((({name:e})=>e===t))}};var gt=Object.defineProperty,mt=Object.getOwnPropertyDescriptor,bt=(e,t,o,n)=>{for(var i,r=n>1?void 0:n?mt(t,o):t,s=e.length-1;s>=0;s--)(i=e[s])&&(r=(n?i(t,o,r):i(r))||r);return n&&r&>(t,o,r),r},vt=(e=>(e.Opened="toolbox-opened",e.Closed="toolbox-closed",e.BlockAdded="toolbox-block-added",e))(vt||{});const yt=class e extends q{constructor({api:t,tools:o,i18nLabels:n}){super(),this.opened=!1,this.listeners=new Y,this.popover=null,this.handleMobileLayoutToggle=()=>{this.destroyPopover(),this.initPopover()},this.onPopoverClose=()=>{this.opened=!1,this.emit("toolbox-closed")},this.api=t,this.tools=o,this.i18nLabels=n,this.enableShortcuts(),this.nodes={toolbox:F.make("div",e.CSS.toolbox)},this.initPopover(),this.api.events.on(ee,this.handleMobileLayoutToggle)}get isEmpty(){return 0===this.toolsToBeDisplayed.length}static get CSS(){return{toolbox:"ce-toolbox"}}getElement(){return this.nodes.toolbox}hasFocus(){if(null!==this.popover)return"hasFocus"in this.popover?this.popover.hasFocus():void 0}destroy(){var e;super.destroy(),this.nodes&&this.nodes.toolbox&&this.nodes.toolbox.remove(),this.removeAllShortcuts(),null==(e=this.popover)||e.off(ze.Closed,this.onPopoverClose),this.listeners.destroy(),this.api.events.off(ee,this.handleMobileLayoutToggle)}toolButtonActivated(e,t){this.insertNewBlock(e,t)}open(){var e;this.isEmpty||(null==(e=this.popover)||e.show(),this.opened=!0,this.emit("toolbox-opened"))}close(){var e;null==(e=this.popover)||e.hide(),this.opened=!1,this.emit("toolbox-closed")}toggle(){this.opened?this.close():this.open()}initPopover(){var e;const t=D()?ut:nt;this.popover=new t({scopeElement:this.api.ui.nodes.redactor,searchable:!0,messages:{nothingFound:this.i18nLabels.nothingFound,search:this.i18nLabels.filter},items:this.toolboxItemsToBeDisplayed}),this.popover.on(ze.Closed,this.onPopoverClose),null==(e=this.nodes.toolbox)||e.append(this.popover.getElement())}destroyPopover(){null!==this.popover&&(this.popover.hide(),this.popover.off(ze.Closed,this.onPopoverClose),this.popover.destroy(),this.popover=null),null!==this.nodes.toolbox&&(this.nodes.toolbox.innerHTML="")}get toolsToBeDisplayed(){const e=[];return this.tools.forEach((t=>{t.toolbox&&e.push(t)})),e}get toolboxItemsToBeDisplayed(){const e=(e,t,o=!0)=>({icon:e.icon,title:W.t(Se.toolNames,e.title||M(t.name)),name:t.name,onActivate:()=>{this.toolButtonActivated(t.name,e.data)},secondaryLabel:t.shortcut&&o?L(t.shortcut):""});return this.toolsToBeDisplayed.reduce(((t,o)=>(Array.isArray(o.toolbox)?o.toolbox.forEach(((n,i)=>{t.push(e(n,o,0===i))})):void 0!==o.toolbox&&t.push(e(o.toolbox,o)),t)),[])}enableShortcuts(){this.toolsToBeDisplayed.forEach((e=>{const t=e.shortcut;t&&this.enableShortcutForTool(e.name,t)}))}enableShortcutForTool(e,t){ft.add({name:t,on:this.api.ui.nodes.redactor,handler:async t=>{t.preventDefault();const o=this.api.blocks.getCurrentBlockIndex(),n=this.api.blocks.getBlockByIndex(o);if(n)try{const t=await this.api.blocks.convert(n.id,e);return void this.api.caret.setToBlock(t,"end")}catch{}this.insertNewBlock(e)}})}removeAllShortcuts(){this.toolsToBeDisplayed.forEach((e=>{const t=e.shortcut;t&&ft.remove(this.api.ui.nodes.redactor,t)}))}async insertNewBlock(e,t){const o=this.api.blocks.getCurrentBlockIndex(),n=this.api.blocks.getBlockByIndex(o);if(!n)return;const i=n.isEmpty?o:o+1;let r;if(t){const o=await this.api.blocks.composeBlockData(e);r=Object.assign(o,t)}const s=this.api.blocks.insert(e,r,void 0,i,void 0,n.isEmpty);s.call(le.APPEND_CALLBACK),this.api.caret.setToBlock(i),this.emit("toolbox-block-added",{block:s}),this.api.toolbar.close()}};bt([j],yt.prototype,"toolsToBeDisplayed",1),bt([j],yt.prototype,"toolboxItemsToBeDisplayed",1);let kt=yt;const wt="block hovered";var xt=(e=>(e[e.Block=0]="Block",e[e.Inline=1]="Inline",e[e.Tune=2]="Tune",e))(xt||{}),Et=(e=>(e.Shortcut="shortcut",e.Toolbox="toolbox",e.EnabledInlineTools="inlineToolbar",e.EnabledBlockTunes="tunes",e.Config="config",e))(Et||{}),Ct=(e=>(e.Shortcut="shortcut",e.SanitizeConfig="sanitize",e))(Ct||{}),St=(e=>(e.IsEnabledLineBreaks="enableLineBreaks",e.Toolbox="toolbox",e.ConversionConfig="conversionConfig",e.IsReadOnlySupported="isReadOnlySupported",e.PasteConfig="pasteConfig",e))(St||{}),Tt=(e=>(e.IsInline="isInline",e.Title="title",e.IsReadOnlySupported="isReadOnlySupported",e))(Tt||{}),_t=(e=>(e.IsTune="isTune",e))(_t||{});let Ot=class{constructor({name:e,constructable:t,config:o,api:n,isDefault:i,isInternal:r=!1,defaultPlaceholder:s}){this.api=n,this.name=e,this.constructable=t,this.config=o,this.isDefault=i,this.isInternal=r,this.defaultPlaceholder=s}get settings(){const e=this.config.config||{};return this.isDefault&&!("placeholder"in e)&&this.defaultPlaceholder&&(e.placeholder=this.defaultPlaceholder),e}reset(){if(y(this.constructable.reset))return this.constructable.reset()}prepare(){if(y(this.constructable.prepare))return this.constructable.prepare({toolName:this.name,config:this.settings})}get shortcut(){const e=this.constructable.shortcut;return this.config.shortcut||e}get sanitizeConfig(){return this.constructable.sanitize||{}}isInline(){return this.type===xt.Inline}isBlock(){return this.type===xt.Block}isTune(){return this.type===xt.Tune}};function Bt(){const e=window.getSelection();if(null===e)return[null,0];let t=e.focusNode,o=e.focusOffset;return null===t?[null,0]:(t.nodeType!==Node.TEXT_NODE&&t.childNodes.length>0&&(t.childNodes[o]?(t=t.childNodes[o],o=0):(t=t.childNodes[o-1],o=t.textContent.length)),[t,o])}function It(e,t,o,n){const i=document.createRange();"left"===n?(i.setStart(e,0),i.setEnd(t,o)):(i.setStart(t,o),i.setEnd(e,e.childNodes.length));const r=i.cloneContents(),s=document.createElement("div");s.appendChild(r);return function(e){return!/[^\t\n\r ]/.test(e)}(s.textContent||"")}function Mt(e){const t=F.getDeepestNode(e);if(null===t||F.isEmpty(e))return!0;if(F.isNativeInput(t))return 0===t.selectionEnd;if(F.isEmpty(e))return!0;const[o,n]=Bt();return null!==o&&It(e,o,n,"left")}function Pt(e){const t=F.getDeepestNode(e,!0);if(null===t)return!0;if(F.isNativeInput(t))return t.selectionEnd===t.value.length;const[o,n]=Bt();return null!==o&&It(e,o,n,"right")}var Lt={},At={},Nt={},jt={},Dt={},Rt={};Object.defineProperty(Rt,"__esModule",{value:!0}),Rt.allInputsSelector=function(){return"[contenteditable=true], textarea, input:not([type]), "+["text","password","email","number","search","tel","url"].map((function(e){return'input[type="'.concat(e,'"]')})).join(", ")},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.allInputsSelector=void 0;var t=Rt;Object.defineProperty(e,"allInputsSelector",{enumerable:!0,get:function(){return t.allInputsSelector}})}(Dt);var Ft={},Ht={};Object.defineProperty(Ht,"__esModule",{value:!0}),Ht.isNativeInput=function(e){return!(!e||!e.tagName)&&["INPUT","TEXTAREA"].includes(e.tagName)},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.isNativeInput=void 0;var t=Ht;Object.defineProperty(e,"isNativeInput",{enumerable:!0,get:function(){return t.isNativeInput}})}(Ft);var Ut={},zt={};Object.defineProperty(zt,"__esModule",{value:!0}),zt.append=function(e,t){Array.isArray(t)?t.forEach((function(t){e.appendChild(t)})):e.appendChild(t)},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.append=void 0;var t=zt;Object.defineProperty(e,"append",{enumerable:!0,get:function(){return t.append}})}(Ut);var Wt={},$t={};Object.defineProperty($t,"__esModule",{value:!0}),$t.blockElements=function(){return["address","article","aside","blockquote","canvas","div","dl","dt","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","li","main","nav","noscript","ol","output","p","pre","ruby","section","table","tbody","thead","tr","tfoot","ul","video"]},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.blockElements=void 0;var t=$t;Object.defineProperty(e,"blockElements",{enumerable:!0,get:function(){return t.blockElements}})}(Wt);var qt={},Kt={};Object.defineProperty(Kt,"__esModule",{value:!0}),Kt.calculateBaseline=function(e){var t=window.getComputedStyle(e),o=parseFloat(t.fontSize),n=parseFloat(t.lineHeight)||1.2*o,i=parseFloat(t.paddingTop),r=parseFloat(t.borderTopWidth);return parseFloat(t.marginTop)+r+i+(n-o)/2+.8*o},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.calculateBaseline=void 0;var t=Kt;Object.defineProperty(e,"calculateBaseline",{enumerable:!0,get:function(){return t.calculateBaseline}})}(qt);var Yt={},Xt={},Vt={},Gt={};Object.defineProperty(Gt,"__esModule",{value:!0}),Gt.isContentEditable=function(e){return"true"===e.contentEditable},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.isContentEditable=void 0;var t=Gt;Object.defineProperty(e,"isContentEditable",{enumerable:!0,get:function(){return t.isContentEditable}})}(Vt),Object.defineProperty(Xt,"__esModule",{value:!0}),Xt.canSetCaret=function(e){var t=!0;if((0,Zt.isNativeInput)(e))switch(e.type){case"file":case"checkbox":case"radio":case"hidden":case"submit":case"button":case"image":case"reset":t=!1}else t=(0,Jt.isContentEditable)(e);return t};var Zt=Ft,Jt=Vt;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.canSetCaret=void 0;var t=Xt;Object.defineProperty(e,"canSetCaret",{enumerable:!0,get:function(){return t.canSetCaret}})}(Yt);var Qt={},eo={};function to(){const e={win:!1,mac:!1,x11:!1,linux:!1},t=Object.keys(e).find((e=>-1!==window.navigator.appVersion.toLowerCase().indexOf(e)));return void 0!==t&&(e[t]=!0),e}function oo(e){return null!=e&&""!==e&&("object"!=typeof e||Object.keys(e).length>0)}function no(e){return Object.prototype.toString.call(e).match(/\s([a-zA-Z]+)/)[1].toLowerCase()}function io(e){return"function"===no(e)||"asyncfunction"===no(e)}function ro(e){return"object"===no(e)}const so=Object.freeze(Object.defineProperty({__proto__:null,PromiseQueue:class{constructor(){this.completed=Promise.resolve()}add(e){return new Promise(((t,o)=>{this.completed=this.completed.then(e).then(t).catch(o)}))}},beautifyShortcut:function(e){const t=to();return e=e.replace(/shift/gi,"⇧").replace(/backspace/gi,"⌫").replace(/enter/gi,"⏎").replace(/up/gi,"↑").replace(/left/gi,"→").replace(/down/gi,"↓").replace(/right/gi,"←").replace(/escape/gi,"⎋").replace(/insert/gi,"Ins").replace(/delete/gi,"␡").replace(/\+/gi,"+"),e=t.mac?e.replace(/ctrl|cmd/gi,"⌘").replace(/alt/gi,"⌥"):e.replace(/cmd/gi,"Ctrl").replace(/windows/gi,"WIN")},cacheable:function(e,t,o){const n=void 0!==o.value?"value":"get",i=o[n],r=`#${t}Cache`;if(o[n]=function(...e){return void 0===this[r]&&(this[r]=i.apply(this,e)),this[r]},"get"===n&&o.set){const t=o.set;o.set=function(o){delete e[r],t.apply(this,o)}}return o},capitalize:function(e){return e[0].toUpperCase()+e.slice(1)},copyTextToClipboard:function(e){const t=document.createElement("div");t.style.position="absolute",t.style.left="-999px",t.style.bottom="-999px",t.innerHTML=e,document.body.appendChild(t);const o=window.getSelection(),n=document.createRange();if(n.selectNode(t),null===o)throw new Error("Cannot copy text to clipboard");o.removeAllRanges(),o.addRange(n),document.execCommand("copy"),document.body.removeChild(t)},debounce:function(e,t,o){let n;return(...i)=>{const r=this,s=!0===o&&void 0!==n;window.clearTimeout(n),n=window.setTimeout((()=>{n=void 0,!0!==o&&e.apply(r,i)}),t),s&&e.apply(r,i)}},deepMerge:function e(t,...o){if(!o.length)return t;const n=o.shift();if(ro(t)&&ro(n))for(const i in n)ro(n[i])?(void 0===t[i]&&Object.assign(t,{[i]:{}}),e(t[i],n[i])):Object.assign(t,{[i]:n[i]});return e(t,...o)},deprecationAssert:function(e,t,o){},getUserOS:to,getValidUrl:function(e){try{return new URL(e).href}catch{}return"//"===e.substring(0,2)?window.location.protocol+e:window.location.origin+e},isBoolean:function(e){return"boolean"===no(e)},isClass:function(e){return io(e)&&/^\s*class\s+/.test(e.toString())},isEmpty:function(e){return!oo(e)},isFunction:io,isIosDevice:()=>typeof window<"u"&&null!==window.navigator&&oo(window.navigator.platform)&&(/iP(ad|hone|od)/.test(window.navigator.platform)||"MacIntel"===window.navigator.platform&&window.navigator.maxTouchPoints>1),isNumber:function(e){return"number"===no(e)},isObject:ro,isPrintableKey:function(e){return e>47&&e<58||32===e||13===e||229===e||e>64&&e<91||e>95&&e<112||e>185&&e<193||e>218&&e<223},isPromise:function(e){return Promise.resolve(e)===e},isString:function(e){return"string"===no(e)},isUndefined:function(e){return"undefined"===no(e)},keyCodes:{BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,ESC:27,SPACE:32,LEFT:37,UP:38,DOWN:40,RIGHT:39,DELETE:46,META:91,SLASH:191},mouseButtons:{LEFT:0,WHEEL:1,RIGHT:2,BACKWARD:3,FORWARD:4},notEmpty:oo,throttle:function(e,t,o=void 0){let n,i,r,s=null,a=0;o||(o={});const l=function(){a=!1===o.leading?0:Date.now(),s=null,r=e.apply(n,i),null===s&&(n=i=null)};return function(){const c=Date.now();!a&&!1===o.leading&&(a=c);const d=t-(c-a);return n=this,i=arguments,d<=0||d>t?(s&&(clearTimeout(s),s=null),a=c,r=e.apply(n,i),null===s&&(n=i=null)):!s&&!1!==o.trailing&&(s=setTimeout(l,d)),r}},typeOf:no},Symbol.toStringTag,{value:"Module"})),ao=o(so);Object.defineProperty(eo,"__esModule",{value:!0}),eo.containsOnlyInlineElements=function(e){var t;(0,lo.isString)(e)?(t=document.createElement("div")).innerHTML=e:t=e;var o=function(e){return!(0,co.blockElements)().includes(e.tagName.toLowerCase())&&Array.from(e.children).every(o)};return Array.from(t.children).every(o)};var lo=ao,co=Wt;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.containsOnlyInlineElements=void 0;var t=eo;Object.defineProperty(e,"containsOnlyInlineElements",{enumerable:!0,get:function(){return t.containsOnlyInlineElements}})}(Qt);var uo={},ho={},po={},fo={};Object.defineProperty(fo,"__esModule",{value:!0}),fo.make=function(e,t,o){var n;void 0===t&&(t=null),void 0===o&&(o={});var i=document.createElement(e);if(Array.isArray(t)){var r=t.filter((function(e){return void 0!==e}));(n=i.classList).add.apply(n,r)}else null!==t&&i.classList.add(t);for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(i[s]=o[s]);return i},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.make=void 0;var t=fo;Object.defineProperty(e,"make",{enumerable:!0,get:function(){return t.make}})}(po),Object.defineProperty(ho,"__esModule",{value:!0}),ho.fragmentToString=function(e){var t=(0,go.make)("div");return t.appendChild(e),t.innerHTML};var go=po;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.fragmentToString=void 0;var t=ho;Object.defineProperty(e,"fragmentToString",{enumerable:!0,get:function(){return t.fragmentToString}})}(uo);var mo={},bo={};Object.defineProperty(bo,"__esModule",{value:!0}),bo.getContentLength=function(e){var t,o;return(0,vo.isNativeInput)(e)?e.value.length:e.nodeType===Node.TEXT_NODE?e.length:null!==(o=null===(t=e.textContent)||void 0===t?void 0:t.length)&&void 0!==o?o:0};var vo=Ft;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.getContentLength=void 0;var t=bo;Object.defineProperty(e,"getContentLength",{enumerable:!0,get:function(){return t.getContentLength}})}(mo);var yo={},ko={},wo=e&&e.__spreadArray||function(e,t,o){if(o||2===arguments.length)for(var n,i=0,r=t.length;i<r;i++)(n||!(i in t))&&(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))};Object.defineProperty(ko,"__esModule",{value:!0}),ko.getDeepestBlockElements=function e(t){return(0,xo.containsOnlyInlineElements)(t)?[t]:Array.from(t.children).reduce((function(t,o){return wo(wo([],t,!0),e(o),!0)}),[])};var xo=Qt;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.getDeepestBlockElements=void 0;var t=ko;Object.defineProperty(e,"getDeepestBlockElements",{enumerable:!0,get:function(){return t.getDeepestBlockElements}})}(yo);var Eo={},Co={},So={},To={};Object.defineProperty(To,"__esModule",{value:!0}),To.isLineBreakTag=function(e){return["BR","WBR"].includes(e.tagName)},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.isLineBreakTag=void 0;var t=To;Object.defineProperty(e,"isLineBreakTag",{enumerable:!0,get:function(){return t.isLineBreakTag}})}(So);var _o={},Oo={};Object.defineProperty(Oo,"__esModule",{value:!0}),Oo.isSingleTag=function(e){return["AREA","BASE","BR","COL","COMMAND","EMBED","HR","IMG","INPUT","KEYGEN","LINK","META","PARAM","SOURCE","TRACK","WBR"].includes(e.tagName)},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.isSingleTag=void 0;var t=Oo;Object.defineProperty(e,"isSingleTag",{enumerable:!0,get:function(){return t.isSingleTag}})}(_o),Object.defineProperty(Co,"__esModule",{value:!0}),Co.getDeepestNode=function e(t,o){void 0===o&&(o=!1);var n=o?"lastChild":"firstChild",i=o?"previousSibling":"nextSibling";if(t.nodeType===Node.ELEMENT_NODE&&t[n]){var r=t[n];if((0,Mo.isSingleTag)(r)&&!(0,Bo.isNativeInput)(r)&&!(0,Io.isLineBreakTag)(r))if(r[i])r=r[i];else{if(null===r.parentNode||!r.parentNode[i])return r.parentNode;r=r.parentNode[i]}return e(r,o)}return t};var Bo=Ft,Io=So,Mo=_o;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.getDeepestNode=void 0;var t=Co;Object.defineProperty(e,"getDeepestNode",{enumerable:!0,get:function(){return t.getDeepestNode}})}(Eo);var Po={},Lo={},Ao=e&&e.__spreadArray||function(e,t,o){if(o||2===arguments.length)for(var n,i=0,r=t.length;i<r;i++)(n||!(i in t))&&(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))};Object.defineProperty(Lo,"__esModule",{value:!0}),Lo.findAllInputs=function(e){return Array.from(e.querySelectorAll((0,Do.allInputsSelector)())).reduce((function(e,t){return(0,Ro.isNativeInput)(t)||(0,No.containsOnlyInlineElements)(t)?Ao(Ao([],e,!0),[t],!1):Ao(Ao([],e,!0),(0,jo.getDeepestBlockElements)(t),!0)}),[])};var No=Qt,jo=yo,Do=Dt,Ro=Ft;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.findAllInputs=void 0;var t=Lo;Object.defineProperty(e,"findAllInputs",{enumerable:!0,get:function(){return t.findAllInputs}})}(Po);var Fo={},Ho={};Object.defineProperty(Ho,"__esModule",{value:!0}),Ho.isCollapsedWhitespaces=function(e){return!/[^\t\n\r ]/.test(e)},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.isCollapsedWhitespaces=void 0;var t=Ho;Object.defineProperty(e,"isCollapsedWhitespaces",{enumerable:!0,get:function(){return t.isCollapsedWhitespaces}})}(Fo);var Uo={},zo={};Object.defineProperty(zo,"__esModule",{value:!0}),zo.isElement=function(e){return!(0,Wo.isNumber)(e)&&(!!e&&!!e.nodeType&&e.nodeType===Node.ELEMENT_NODE)};var Wo=ao;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.isElement=void 0;var t=zo;Object.defineProperty(e,"isElement",{enumerable:!0,get:function(){return t.isElement}})}(Uo);var $o={},qo={},Ko={},Yo={};Object.defineProperty(Yo,"__esModule",{value:!0}),Yo.isLeaf=function(e){return null!==e&&0===e.childNodes.length},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.isLeaf=void 0;var t=Yo;Object.defineProperty(e,"isLeaf",{enumerable:!0,get:function(){return t.isLeaf}})}(Ko);var Xo={},Vo={};Object.defineProperty(Vo,"__esModule",{value:!0}),Vo.isNodeEmpty=function(e,t){var o="";return!((0,Qo.isSingleTag)(e)&&!(0,Go.isLineBreakTag)(e))&&((0,Zo.isElement)(e)&&(0,Jo.isNativeInput)(e)?o=e.value:null!==e.textContent&&(o=e.textContent.replace("","")),void 0!==t&&(o=o.replace(new RegExp(t,"g"),"")),0===o.trim().length)};var Go=So,Zo=Uo,Jo=Ft,Qo=_o;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.isNodeEmpty=void 0;var t=Vo;Object.defineProperty(e,"isNodeEmpty",{enumerable:!0,get:function(){return t.isNodeEmpty}})}(Xo),Object.defineProperty(qo,"__esModule",{value:!0}),qo.isEmpty=function(e,t){e.normalize();for(var o=[e];o.length>0;){var n=o.shift();if(n){if(e=n,(0,en.isLeaf)(e)&&!(0,tn.isNodeEmpty)(e,t))return!1;o.push.apply(o,Array.from(e.childNodes))}}return!0};var en=Ko,tn=Xo;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.isEmpty=void 0;var t=qo;Object.defineProperty(e,"isEmpty",{enumerable:!0,get:function(){return t.isEmpty}})}($o);var on={},nn={};Object.defineProperty(nn,"__esModule",{value:!0}),nn.isFragment=function(e){return!(0,rn.isNumber)(e)&&(!!e&&!!e.nodeType&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE)};var rn=ao;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.isFragment=void 0;var t=nn;Object.defineProperty(e,"isFragment",{enumerable:!0,get:function(){return t.isFragment}})}(on);var sn={},an={};Object.defineProperty(an,"__esModule",{value:!0}),an.isHTMLString=function(e){var t=(0,ln.make)("div");return t.innerHTML=e,t.childElementCount>0};var ln=po;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.isHTMLString=void 0;var t=an;Object.defineProperty(e,"isHTMLString",{enumerable:!0,get:function(){return t.isHTMLString}})}(sn);var cn={},dn={};Object.defineProperty(dn,"__esModule",{value:!0}),dn.offset=function(e){var t=e.getBoundingClientRect(),o=window.pageXOffset||document.documentElement.scrollLeft,n=window.pageYOffset||document.documentElement.scrollTop,i=t.top+n,r=t.left+o;return{top:i,left:r,bottom:i+t.height,right:r+t.width}},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.offset=void 0;var t=dn;Object.defineProperty(e,"offset",{enumerable:!0,get:function(){return t.offset}})}(cn);var un={},hn={};Object.defineProperty(hn,"__esModule",{value:!0}),hn.prepend=function(e,t){Array.isArray(t)?(t=t.reverse()).forEach((function(t){return e.prepend(t)})):e.prepend(t)},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.prepend=void 0;var t=hn;Object.defineProperty(e,"prepend",{enumerable:!0,get:function(){return t.prepend}})}(un),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.prepend=e.offset=e.make=e.isLineBreakTag=e.isSingleTag=e.isNodeEmpty=e.isLeaf=e.isHTMLString=e.isFragment=e.isEmpty=e.isElement=e.isContentEditable=e.isCollapsedWhitespaces=e.findAllInputs=e.isNativeInput=e.allInputsSelector=e.getDeepestNode=e.getDeepestBlockElements=e.getContentLength=e.fragmentToString=e.containsOnlyInlineElements=e.canSetCaret=e.calculateBaseline=e.blockElements=e.append=void 0;var t=Dt;Object.defineProperty(e,"allInputsSelector",{enumerable:!0,get:function(){return t.allInputsSelector}});var o=Ft;Object.defineProperty(e,"isNativeInput",{enumerable:!0,get:function(){return o.isNativeInput}});var n=Ut;Object.defineProperty(e,"append",{enumerable:!0,get:function(){return n.append}});var i=Wt;Object.defineProperty(e,"blockElements",{enumerable:!0,get:function(){return i.blockElements}});var r=qt;Object.defineProperty(e,"calculateBaseline",{enumerable:!0,get:function(){return r.calculateBaseline}});var s=Yt;Object.defineProperty(e,"canSetCaret",{enumerable:!0,get:function(){return s.canSetCaret}});var a=Qt;Object.defineProperty(e,"containsOnlyInlineElements",{enumerable:!0,get:function(){return a.containsOnlyInlineElements}});var l=uo;Object.defineProperty(e,"fragmentToString",{enumerable:!0,get:function(){return l.fragmentToString}});var c=mo;Object.defineProperty(e,"getContentLength",{enumerable:!0,get:function(){return c.getContentLength}});var d=yo;Object.defineProperty(e,"getDeepestBlockElements",{enumerable:!0,get:function(){return d.getDeepestBlockElements}});var u=Eo;Object.defineProperty(e,"getDeepestNode",{enumerable:!0,get:function(){return u.getDeepestNode}});var h=Po;Object.defineProperty(e,"findAllInputs",{enumerable:!0,get:function(){return h.findAllInputs}});var p=Fo;Object.defineProperty(e,"isCollapsedWhitespaces",{enumerable:!0,get:function(){return p.isCollapsedWhitespaces}});var f=Vt;Object.defineProperty(e,"isContentEditable",{enumerable:!0,get:function(){return f.isContentEditable}});var g=Uo;Object.defineProperty(e,"isElement",{enumerable:!0,get:function(){return g.isElement}});var m=$o;Object.defineProperty(e,"isEmpty",{enumerable:!0,get:function(){return m.isEmpty}});var b=on;Object.defineProperty(e,"isFragment",{enumerable:!0,get:function(){return b.isFragment}});var v=sn;Object.defineProperty(e,"isHTMLString",{enumerable:!0,get:function(){return v.isHTMLString}});var y=Ko;Object.defineProperty(e,"isLeaf",{enumerable:!0,get:function(){return y.isLeaf}});var k=Xo;Object.defineProperty(e,"isNodeEmpty",{enumerable:!0,get:function(){return k.isNodeEmpty}});var w=So;Object.defineProperty(e,"isLineBreakTag",{enumerable:!0,get:function(){return w.isLineBreakTag}});var x=_o;Object.defineProperty(e,"isSingleTag",{enumerable:!0,get:function(){return x.isSingleTag}});var E=po;Object.defineProperty(e,"make",{enumerable:!0,get:function(){return E.make}});var C=cn;Object.defineProperty(e,"offset",{enumerable:!0,get:function(){return C.offset}});var S=un;Object.defineProperty(e,"prepend",{enumerable:!0,get:function(){return S.prepend}})}(jt);var pn={};Object.defineProperty(pn,"__esModule",{value:!0}),pn.getContenteditableSlice=function(e,t,o,n,i){var r;void 0===i&&(i=!1);var s=document.createRange();if("left"===n?(s.setStart(e,0),s.setEnd(t,o)):(s.setStart(t,o),s.setEnd(e,e.childNodes.length)),!0===i){var a=s.extractContents();return(0,fn.fragmentToString)(a)}var l=s.cloneContents(),c=document.createElement("div");return c.appendChild(l),null!==(r=c.textContent)&&void 0!==r?r:""};var fn=jt;Object.defineProperty(Nt,"__esModule",{value:!0}),Nt.checkContenteditableSliceForEmptiness=function(e,t,o,n){var i=(0,mn.getContenteditableSlice)(e,t,o,n);return(0,gn.isCollapsedWhitespaces)(i)};var gn=jt,mn=pn;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.checkContenteditableSliceForEmptiness=void 0;var t=Nt;Object.defineProperty(e,"checkContenteditableSliceForEmptiness",{enumerable:!0,get:function(){return t.checkContenteditableSliceForEmptiness}})}(At);var bn={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.getContenteditableSlice=void 0;var t=pn;Object.defineProperty(e,"getContenteditableSlice",{enumerable:!0,get:function(){return t.getContenteditableSlice}})}(bn);var vn={},yn={};Object.defineProperty(yn,"__esModule",{value:!0}),yn.focus=function(e,t){var o,n;if(void 0===t&&(t=!0),(0,kn.isNativeInput)(e)){e.focus();var i=t?0:e.value.length;e.setSelectionRange(i,i)}else{var r=document.createRange(),s=window.getSelection();if(!s)return;var a=function(e){var t=document.createTextNode("");e.appendChild(t),r.setStart(t,0),r.setEnd(t,0)},l=function(e){return null!=e},c=e.childNodes,d=t?c[0]:c[c.length-1];if(l(d)){for(;l(d)&&d.nodeType!==Node.TEXT_NODE;)d=t?d.firstChild:d.lastChild;if(l(d)&&d.nodeType===Node.TEXT_NODE){var u=null!==(n=null===(o=d.textContent)||void 0===o?void 0:o.length)&&void 0!==n?n:0;i=t?0:u;r.setStart(d,i),r.setEnd(d,i)}else a(e)}else a(e);s.removeAllRanges(),s.addRange(r)}};var kn=jt;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.focus=void 0;var t=yn;Object.defineProperty(e,"focus",{enumerable:!0,get:function(){return t.focus}})}(vn);var wn={},xn={};Object.defineProperty(xn,"__esModule",{value:!0}),xn.getCaretNodeAndOffset=function(){var e=window.getSelection();if(null===e)return[null,0];var t=e.focusNode,o=e.focusOffset;return null===t?[null,0]:(t.nodeType!==Node.TEXT_NODE&&t.childNodes.length>0&&(void 0!==t.childNodes[o]?(t=t.childNodes[o],o=0):null!==(t=t.childNodes[o-1]).textContent&&(o=t.textContent.length)),[t,o])},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.getCaretNodeAndOffset=void 0;var t=xn;Object.defineProperty(e,"getCaretNodeAndOffset",{enumerable:!0,get:function(){return t.getCaretNodeAndOffset}})}(wn);var En={},Cn={};Object.defineProperty(Cn,"__esModule",{value:!0}),Cn.getRange=function(){var e=window.getSelection();return e&&e.rangeCount?e.getRangeAt(0):null},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.getRange=void 0;var t=Cn;Object.defineProperty(e,"getRange",{enumerable:!0,get:function(){return t.getRange}})}(En);var Sn={},Tn={};Object.defineProperty(Tn,"__esModule",{value:!0}),Tn.isCaretAtEndOfInput=function(e){var t=(0,_n.getDeepestNode)(e,!0);if(null===t)return!0;if((0,_n.isNativeInput)(t))return t.selectionEnd===t.value.length;var o=(0,On.getCaretNodeAndOffset)(),n=o[0],i=o[1];return null!==n&&(0,Bn.checkContenteditableSliceForEmptiness)(e,n,i,"right")};var _n=jt,On=wn,Bn=At;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.isCaretAtEndOfInput=void 0;var t=Tn;Object.defineProperty(e,"isCaretAtEndOfInput",{enumerable:!0,get:function(){return t.isCaretAtEndOfInput}})}(Sn);var In={},Mn={};Object.defineProperty(Mn,"__esModule",{value:!0}),Mn.isCaretAtStartOfInput=function(e){var t=(0,Pn.getDeepestNode)(e);if(null===t||(0,Pn.isEmpty)(e))return!0;if((0,Pn.isNativeInput)(t))return 0===t.selectionEnd;if((0,Pn.isEmpty)(e))return!0;var o=(0,Ln.getCaretNodeAndOffset)(),n=o[0],i=o[1];return null!==n&&(0,An.checkContenteditableSliceForEmptiness)(e,n,i,"left")};var Pn=jt,Ln=xn,An=Nt;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.isCaretAtStartOfInput=void 0;var t=Mn;Object.defineProperty(e,"isCaretAtStartOfInput",{enumerable:!0,get:function(){return t.isCaretAtStartOfInput}})}(In);var Nn={},jn={};Object.defineProperty(jn,"__esModule",{value:!0}),jn.save=function(){var e=(0,Rn.getRange)(),t=(0,Dn.make)("span");if(t.id="cursor",t.hidden=!0,e)return e.insertNode(t),function(){var o=window.getSelection();o&&(e.setStartAfter(t),e.setEndAfter(t),o.removeAllRanges(),o.addRange(e),setTimeout((function(){t.remove()}),150))}};var Dn=jt,Rn=Cn;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.save=void 0;var t=jn;Object.defineProperty(e,"save",{enumerable:!0,get:function(){return t.save}})}(Nn),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.save=e.isCaretAtStartOfInput=e.isCaretAtEndOfInput=e.getRange=e.getCaretNodeAndOffset=e.focus=e.getContenteditableSlice=e.checkContenteditableSliceForEmptiness=void 0;var t=At;Object.defineProperty(e,"checkContenteditableSliceForEmptiness",{enumerable:!0,get:function(){return t.checkContenteditableSliceForEmptiness}});var o=bn;Object.defineProperty(e,"getContenteditableSlice",{enumerable:!0,get:function(){return o.getContenteditableSlice}});var n=vn;Object.defineProperty(e,"focus",{enumerable:!0,get:function(){return n.focus}});var i=wn;Object.defineProperty(e,"getCaretNodeAndOffset",{enumerable:!0,get:function(){return i.getCaretNodeAndOffset}});var r=En;Object.defineProperty(e,"getRange",{enumerable:!0,get:function(){return r.getRange}});var s=Sn;Object.defineProperty(e,"isCaretAtEndOfInput",{enumerable:!0,get:function(){return s.isCaretAtEndOfInput}});var a=In;Object.defineProperty(e,"isCaretAtStartOfInput",{enumerable:!0,get:function(){return a.isCaretAtStartOfInput}});var l=Nn;Object.defineProperty(e,"save",{enumerable:!0,get:function(){return l.save}})}(Lt);let Fn=class{constructor(e){this.blocks=[],this.workingArea=e}get length(){return this.blocks.length}get array(){return this.blocks}get nodes(){return _(this.workingArea.children)}static set(e,t,o){return isNaN(Number(t))?(Reflect.set(e,t,o),!0):(e.insert(+t,o),!0)}static get(e,t){return isNaN(Number(t))?Reflect.get(e,t):e.get(+t)}push(e){this.blocks.push(e),this.insertToDOM(e)}swap(e,t){const o=this.blocks[t];F.swap(this.blocks[e].holder,o.holder),this.blocks[t]=this.blocks[e],this.blocks[e]=o}move(e,t){const o=this.blocks.splice(t,1)[0],n=e-1,i=Math.max(0,n),r=this.blocks[i];e>0?this.insertToDOM(o,"afterend",r):this.insertToDOM(o,"beforebegin",r),this.blocks.splice(e,0,o);const s=this.composeBlockEvent("move",{fromIndex:t,toIndex:e});o.call(le.MOVED,s)}insert(e,t,o=!1){if(!this.length)return void this.push(t);e>this.length&&(e=this.length),o&&(this.blocks[e].holder.remove(),this.blocks[e].call(le.REMOVED));const n=o?1:0;if(this.blocks.splice(e,n,t),e>0){const o=this.blocks[e-1];this.insertToDOM(t,"afterend",o)}else{const o=this.blocks[e+1];o?this.insertToDOM(t,"beforebegin",o):this.insertToDOM(t)}}replace(e,t){if(void 0===this.blocks[e])throw Error("Incorrect index");this.blocks[e].holder.replaceWith(t.holder),this.blocks[e]=t}insertMany(e,t){const o=new DocumentFragment;for(const n of e)o.appendChild(n.holder);if(this.length>0){if(t>0){const e=Math.min(t-1,this.length-1);this.blocks[e].holder.after(o)}else 0===t&&this.workingArea.prepend(o);this.blocks.splice(t,0,...e)}else this.blocks.push(...e),this.workingArea.appendChild(o);e.forEach((e=>e.call(le.RENDERED)))}remove(e){isNaN(e)&&(e=this.length-1),this.blocks[e].holder.remove(),this.blocks[e].call(le.REMOVED),this.blocks.splice(e,1)}removeAll(){this.workingArea.innerHTML="",this.blocks.forEach((e=>e.call(le.REMOVED))),this.blocks.length=0}insertAfter(e,t){const o=this.blocks.indexOf(e);this.insert(o+1,t)}get(e){return this.blocks[e]}indexOf(e){return this.blocks.indexOf(e)}insertToDOM(e,t,o){t?o.holder.insertAdjacentElement(t,e.holder):this.workingArea.appendChild(e.holder),e.call(le.RENDERED)}composeBlockEvent(e,t){return new CustomEvent(e,{detail:t})}};const Hn="block-removed",Un="block-added",zn="block-changed";class Wn{constructor(){this.completed=Promise.resolve()}add(e){return new Promise(((t,o)=>{this.completed=this.completed.then(e).then(t).catch(o)}))}}const $n=class e extends X{constructor(){super(...arguments),this.MIME_TYPE="application/x-editor-js",this.toolsTags={},this.tagsByTool={},this.toolsPatterns=[],this.toolsFiles={},this.exceptionList=[],this.processTool=e=>{try{const t=e.create({},{},!1);if(!1===e.pasteConfig)return void this.exceptionList.push(e.name);if(!y(t.onPaste))return;this.getTagsConfig(e),this.getFilesConfig(e),this.getPatternsConfig(e)}catch(t){m(`Paste handling for «${e.name}» Tool hasn't been set up because of the error`,"warn",t)}},this.handlePasteEvent=async e=>{const{BlockManager:t,Toolbar:o}=this.Editor,n=t.setCurrentBlockByChildNode(e.target);!n||this.isNativeBehaviour(e.target)&&!e.clipboardData.types.includes("Files")||n&&this.exceptionList.includes(n.name)||(e.preventDefault(),this.processDataTransfer(e.clipboardData),o.close())}}async prepare(){this.processTools()}toggleReadOnly(e){e?this.unsetCallback():this.setCallback()}async processDataTransfer(e,t=!1){const{Tools:o}=this.Editor,n=e.types;if((n.includes?n.includes("Files"):n.contains("Files"))&&!C(this.toolsFiles))return void(await this.processFiles(e.files));const i=e.getData(this.MIME_TYPE),r=e.getData("text/plain");let s=e.getData("text/html");if(i)try{return void this.insertEditorJSData(JSON.parse(i))}catch{}t&&r.trim()&&s.trim()&&(s="<p>"+(s.trim()?s:r)+"</p>");const a=Object.keys(this.toolsTags).reduce(((e,t)=>(e[t.toLowerCase()]=this.toolsTags[t].sanitizationConfig??{},e)),{}),l=me(s,Object.assign({},a,o.getAllInlineToolsSanitizeConfig(),{br:{}}));l.trim()&&l.trim()!==r&&F.isHTMLString(l)?await this.processText(l,!0):await this.processText(r)}async processText(e,t=!1){const{Caret:o,BlockManager:n}=this.Editor,i=t?this.processHTML(e):this.processPlain(e);if(!i.length)return;if(1===i.length)return void(i[0].isBlock?this.processSingleBlock(i.pop()):this.processInlinePaste(i.pop()));const r=n.currentBlock&&n.currentBlock.tool.isDefault&&n.currentBlock.isEmpty;i.map((async(e,t)=>this.insertBlock(e,0===t&&r))),n.currentBlock&&o.setToBlock(n.currentBlock,o.positions.END)}setCallback(){this.listeners.on(this.Editor.UI.nodes.holder,"paste",this.handlePasteEvent)}unsetCallback(){this.listeners.off(this.Editor.UI.nodes.holder,"paste",this.handlePasteEvent)}processTools(){const e=this.Editor.Tools.blockTools;Array.from(e.values()).forEach(this.processTool)}collectTagNames(e){return w(e)?[e]:k(e)?Object.keys(e):[]}getTagsConfig(e){if(!1===e.pasteConfig)return;const t=e.pasteConfig.tags||[],o=[];t.forEach((t=>{const n=this.collectTagNames(t);o.push(...n),n.forEach((o=>{if(Object.prototype.hasOwnProperty.call(this.toolsTags,o))return void m(`Paste handler for «${e.name}» Tool on «${o}» tag is skipped because it is already used by «${this.toolsTags[o].tool.name}» Tool.`,"warn");const n=k(t)?t[o]:null;this.toolsTags[o.toUpperCase()]={tool:e,sanitizationConfig:n}}))})),this.tagsByTool[e.name]=o.map((e=>e.toUpperCase()))}getFilesConfig(e){if(!1===e.pasteConfig)return;const{files:t={}}=e.pasteConfig;let{extensions:o,mimeTypes:n}=t;!o&&!n||(o&&!Array.isArray(o)&&(m(`«extensions» property of the onDrop config for «${e.name}» Tool should be an array`),o=[]),n&&!Array.isArray(n)&&(m(`«mimeTypes» property of the onDrop config for «${e.name}» Tool should be an array`),n=[]),n&&(n=n.filter((t=>!!/^[-\w]+\/([-+\w]+|\*)$/.test(t)||(m(`MIME type value «${t}» for the «${e.name}» Tool is not a valid MIME type`,"warn"),!1)))),this.toolsFiles[e.name]={extensions:o||[],mimeTypes:n||[]})}getPatternsConfig(e){!1===e.pasteConfig||!e.pasteConfig.patterns||C(e.pasteConfig.patterns)||Object.entries(e.pasteConfig.patterns).forEach((([t,o])=>{o instanceof RegExp||m(`Pattern ${o} for «${e.name}» Tool is skipped because it should be a Regexp instance.`,"warn"),this.toolsPatterns.push({key:t,pattern:o,tool:e})}))}isNativeBehaviour(e){return F.isNativeInput(e)}async processFiles(e){const{BlockManager:t}=this.Editor;let o;o=await Promise.all(Array.from(e).map((e=>this.processFile(e)))),o=o.filter((e=>!!e));const n=t.currentBlock.tool.isDefault&&t.currentBlock.isEmpty;o.forEach(((e,o)=>{t.paste(e.type,e.event,0===o&&n)}))}async processFile(e){const t=e.name.split(".").pop(),o=Object.entries(this.toolsFiles).find((([o,{mimeTypes:n,extensions:i}])=>{const[r,s]=e.type.split("/"),a=i.find((e=>e.toLowerCase()===t.toLowerCase())),l=n.find((e=>{const[t,o]=e.split("/");return t===r&&(o===s||"*"===o)}));return!!a||!!l}));if(!o)return;const[n]=o;return{event:this.composePasteEvent("file",{file:e}),type:n}}processHTML(e){const{Tools:t}=this.Editor,o=F.make("DIV");return o.innerHTML=e,this.getNodes(o).map((e=>{let o,n=t.defaultTool,i=!1;switch(e.nodeType){case Node.DOCUMENT_FRAGMENT_NODE:o=F.make("div"),o.appendChild(e);break;case Node.ELEMENT_NODE:o=e,i=!0,this.toolsTags[o.tagName]&&(n=this.toolsTags[o.tagName].tool)}const{tags:r}=n.pasteConfig||{tags:[]},s=r.reduce(((e,t)=>(this.collectTagNames(t).forEach((o=>{const n=k(t)?t[o]:null;e[o.toLowerCase()]=n||{}})),e)),{}),a=Object.assign({},s,n.baseSanitizeConfig);if("table"===o.tagName.toLowerCase()){const e=me(o.outerHTML,a);o=F.make("div",void 0,{innerHTML:e}).firstChild}else o.innerHTML=me(o.innerHTML,a);const l=this.composePasteEvent("tag",{data:o});return{content:o,isBlock:i,tool:n.name,event:l}})).filter((e=>{const t=F.isEmpty(e.content),o=F.isSingleTag(e.content);return!t||o}))}processPlain(e){const{defaultBlock:t}=this.config;if(!e)return[];const o=t;return e.split(/\r?\n/).filter((e=>e.trim())).map((e=>{const t=F.make("div");t.textContent=e;const n=this.composePasteEvent("tag",{data:t});return{content:t,tool:o,isBlock:!1,event:n}}))}async processSingleBlock(e){const{Caret:t,BlockManager:o}=this.Editor,{currentBlock:n}=o;n&&e.tool===n.name&&F.containsOnlyInlineElements(e.content.innerHTML)?t.insertContentAtCaretPosition(e.content.innerHTML):this.insertBlock(e,(null==n?void 0:n.tool.isDefault)&&n.isEmpty)}async processInlinePaste(t){const{BlockManager:o,Caret:n}=this.Editor,{content:i}=t;if(o.currentBlock&&o.currentBlock.tool.isDefault&&i.textContent.length<e.PATTERN_PROCESSING_MAX_LENGTH){const e=await this.processPattern(i.textContent);if(e){const t=o.currentBlock&&o.currentBlock.tool.isDefault&&o.currentBlock.isEmpty,i=o.paste(e.tool,e.event,t);return void n.setToBlock(i,n.positions.END)}}if(o.currentBlock&&o.currentBlock.currentInput){const e=o.currentBlock.tool.baseSanitizeConfig;document.execCommand("insertHTML",!1,me(i.innerHTML,e))}else this.insertBlock(t)}async processPattern(e){const t=this.toolsPatterns.find((t=>{const o=t.pattern.exec(e);return!!o&&e===o.shift()}));return t?{event:this.composePasteEvent("pattern",{key:t.key,data:e}),tool:t.tool.name}:void 0}insertBlock(e,t=!1){const{BlockManager:o,Caret:n}=this.Editor,{currentBlock:i}=o;let r;if(t&&i&&i.isEmpty)return r=o.paste(e.tool,e.event,!0),void n.setToBlock(r,n.positions.END);r=o.paste(e.tool,e.event),n.setToBlock(r,n.positions.END)}insertEditorJSData(e){const{BlockManager:t,Caret:o,Tools:n}=this.Editor;ge(e,(e=>n.blockTools.get(e).sanitizeConfig)).forEach((({tool:e,data:n},i)=>{let r=!1;0===i&&(r=t.currentBlock&&t.currentBlock.tool.isDefault&&t.currentBlock.isEmpty);const s=t.insert({tool:e,data:n,replace:r});o.setToBlock(s,o.positions.END)}))}processElementNode(e,t,o){const n=Object.keys(this.toolsTags),i=e,{tool:r}=this.toolsTags[i.tagName]||{},s=this.tagsByTool[null==r?void 0:r.name]||[],a=n.includes(i.tagName),l=F.blockElements.includes(i.tagName.toLowerCase()),c=Array.from(i.children).some((({tagName:e})=>n.includes(e)&&!s.includes(e))),d=Array.from(i.children).some((({tagName:e})=>F.blockElements.includes(e.toLowerCase())));return l||a||c?a&&!c||l&&!d&&!c?[...t,o,i]:void 0:(o.appendChild(i),[...t,o])}getNodes(e){const t=Array.from(e.childNodes);let o;const n=(e,t)=>{if(F.isEmpty(t)&&!F.isSingleTag(t))return e;const i=e[e.length-1];let r=new DocumentFragment;switch(i&&F.isFragment(i)&&(r=e.pop()),t.nodeType){case Node.ELEMENT_NODE:if(o=this.processElementNode(t,e,r),o)return o;break;case Node.TEXT_NODE:return r.appendChild(t),[...e,r];default:return[...e,r]}return[...e,...Array.from(t.childNodes).reduce(n,[])]};return t.reduce(n,[])}composePasteEvent(e,t){return new CustomEvent(e,{detail:t})}};$n.PATTERN_PROCESSING_MAX_LENGTH=450;let qn=$n;!function(){try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".ce-paragraph{line-height:1.6em;outline:none}.ce-block:only-of-type .ce-paragraph[data-placeholder-active]:empty:before,.ce-block:only-of-type .ce-paragraph[data-placeholder-active][data-empty=true]:before{content:attr(data-placeholder-active)}.ce-paragraph p:first-of-type{margin-top:0}.ce-paragraph p:last-of-type{margin-bottom:0}")),document.head.appendChild(e)}}catch(t){}}();
|
||
/**
|
||
* Base Paragraph Block for the Editor.js.
|
||
* Represents a regular text block
|
||
*
|
||
* @author CodeX (team@codex.so)
|
||
* @copyright CodeX 2018
|
||
* @license The MIT License (MIT)
|
||
*/
|
||
class Kn{static get DEFAULT_PLACEHOLDER(){return""}constructor({data:e,config:t,api:o,readOnly:n}){this.api=o,this.readOnly=n,this._CSS={block:this.api.styles.block,wrapper:"ce-paragraph"},this.readOnly||(this.onKeyUp=this.onKeyUp.bind(this)),this._placeholder=t.placeholder?t.placeholder:Kn.DEFAULT_PLACEHOLDER,this._data=e??{},this._element=null,this._preserveBlank=t.preserveBlank??!1}onKeyUp(e){if("Backspace"!==e.code&&"Delete"!==e.code||!this._element)return;const{textContent:t}=this._element;""===t&&(this._element.innerHTML="")}drawView(){const e=document.createElement("DIV");return e.classList.add(this._CSS.wrapper,this._CSS.block),e.contentEditable="false",e.dataset.placeholderActive=this.api.i18n.t(this._placeholder),this._data.text&&(e.innerHTML=this._data.text),this.readOnly||(e.contentEditable="true",e.addEventListener("keyup",this.onKeyUp)),e}render(){return this._element=this.drawView(),this._element}merge(e){if(!this._element)return;this._data.text+=e.text;const t=function(e){const t=document.createElement("div");t.innerHTML=e.trim();const o=document.createDocumentFragment();return o.append(...Array.from(t.childNodes)),o}(e.text);this._element.appendChild(t),this._element.normalize()}validate(e){return!(""===e.text.trim()&&!this._preserveBlank)}save(e){return{text:e.innerHTML}}onPaste(e){const t={text:e.detail.data.innerHTML};this._data=t,window.requestAnimationFrame((()=>{this._element&&(this._element.innerHTML=this._data.text||"")}))}static get conversionConfig(){return{export:"text",import:"text"}}static get sanitize(){return{text:{br:!0}}}static get isReadOnlySupported(){return!0}static get pasteConfig(){return{tags:["P"]}}static get toolbox(){return{icon:'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M8 9V7.2C8 7.08954 8.08954 7 8.2 7L12 7M16 9V7.2C16 7.08954 15.9105 7 15.8 7L12 7M12 7L12 17M12 17H10M12 17H14"/></svg>',title:"Text"}}}class Yn{constructor(){this.commandName="bold"}static get sanitize(){return{b:{}}}render(){return{icon:'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M9 12L9 7.1C9 7.04477 9.04477 7 9.1 7H10.4C11.5 7 14 7.1 14 9.5C14 9.5 14 12 11 12M9 12V16.8C9 16.9105 9.08954 17 9.2 17H12.5C14 17 15 16 15 14.5C15 11.7046 11 12 11 12M9 12H11"/></svg>',name:"bold",onActivate:()=>{document.execCommand(this.commandName)},isActive:()=>document.queryCommandState(this.commandName)}}get shortcut(){return"CMD+B"}}Yn.isInline=!0,Yn.title="Bold";class Xn{constructor(){this.commandName="italic",this.CSS={button:"ce-inline-tool",buttonActive:"ce-inline-tool--active",buttonModifier:"ce-inline-tool--italic"},this.nodes={button:null}}static get sanitize(){return{i:{}}}render(){return this.nodes.button=document.createElement("button"),this.nodes.button.type="button",this.nodes.button.classList.add(this.CSS.button,this.CSS.buttonModifier),this.nodes.button.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M13.34 10C12.4223 12.7337 11 17 11 17"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M14.21 7H14.2"/></svg>',this.nodes.button}surround(){document.execCommand(this.commandName)}checkState(){const e=document.queryCommandState(this.commandName);return this.nodes.button.classList.toggle(this.CSS.buttonActive,e),e}get shortcut(){return"CMD+I"}}Xn.isInline=!0,Xn.title="Italic";class Vn{constructor({api:e}){this.commandLink="createLink",this.commandUnlink="unlink",this.ENTER_KEY=13,this.CSS={button:"ce-inline-tool",buttonActive:"ce-inline-tool--active",buttonModifier:"ce-inline-tool--link",buttonUnlink:"ce-inline-tool--unlink",input:"ce-inline-tool-input",inputShowed:"ce-inline-tool-input--showed"},this.nodes={button:null,input:null},this.inputOpened=!1,this.toolbar=e.toolbar,this.inlineToolbar=e.inlineToolbar,this.notifier=e.notifier,this.i18n=e.i18n,this.selection=new V}static get sanitize(){return{a:{href:!0,target:"_blank",rel:"nofollow"}}}render(){return this.nodes.button=document.createElement("button"),this.nodes.button.type="button",this.nodes.button.classList.add(this.CSS.button,this.CSS.buttonModifier),this.nodes.button.innerHTML=Be,this.nodes.button}renderActions(){return this.nodes.input=document.createElement("input"),this.nodes.input.placeholder=this.i18n.t("Add a link"),this.nodes.input.enterKeyHint="done",this.nodes.input.classList.add(this.CSS.input),this.nodes.input.addEventListener("keydown",(e=>{e.keyCode===this.ENTER_KEY&&this.enterPressed(e)})),this.nodes.input}surround(e){if(e){this.inputOpened?(this.selection.restore(),this.selection.removeFakeBackground()):(this.selection.setFakeBackground(),this.selection.save());const e=this.selection.findParentTag("A");if(e)return this.selection.expandToTag(e),this.unlink(),this.closeActions(),this.checkState(),void this.toolbar.close()}this.toggleActions()}checkState(){const e=this.selection.findParentTag("A");if(e){this.nodes.button.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M15.7795 11.5C15.7795 11.5 16.053 11.1962 16.5497 10.6722C17.4442 9.72856 17.4701 8.2475 16.5781 7.30145V7.30145C15.6482 6.31522 14.0873 6.29227 13.1288 7.25073L11.8796 8.49999"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M8.24517 12.3883C8.24517 12.3883 7.97171 12.6922 7.47504 13.2161C6.58051 14.1598 6.55467 15.6408 7.44666 16.5869V16.5869C8.37653 17.5731 9.93744 17.5961 10.8959 16.6376L12.1452 15.3883"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M17.7802 15.1032L16.597 14.9422C16.0109 14.8624 15.4841 15.3059 15.4627 15.8969L15.4199 17.0818"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M6.39064 9.03238L7.58432 9.06668C8.17551 9.08366 8.6522 8.58665 8.61056 7.99669L8.5271 6.81397"/><line x1="12.1142" x2="11.7" y1="12.2" y2="11.7858" stroke="currentColor" stroke-linecap="round" stroke-width="2"/></svg>',this.nodes.button.classList.add(this.CSS.buttonUnlink),this.nodes.button.classList.add(this.CSS.buttonActive),this.openActions();const t=e.getAttribute("href");this.nodes.input.value="null"!==t?t:"",this.selection.save()}else this.nodes.button.innerHTML=Be,this.nodes.button.classList.remove(this.CSS.buttonUnlink),this.nodes.button.classList.remove(this.CSS.buttonActive);return!!e}clear(){this.closeActions()}get shortcut(){return"CMD+K"}toggleActions(){this.inputOpened?this.closeActions(!1):this.openActions(!0)}openActions(e=!1){this.nodes.input.classList.add(this.CSS.inputShowed),e&&this.nodes.input.focus(),this.inputOpened=!0}closeActions(e=!0){if(this.selection.isFakeBackgroundEnabled){const e=new V;e.save(),this.selection.restore(),this.selection.removeFakeBackground(),e.restore()}this.nodes.input.classList.remove(this.CSS.inputShowed),this.nodes.input.value="",e&&this.selection.clearSaved(),this.inputOpened=!1}enterPressed(e){let t=this.nodes.input.value||"";return t.trim()?this.validateURL(t)?(t=this.prepareLink(t),this.selection.restore(),this.selection.removeFakeBackground(),this.insertLink(t),e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),this.selection.collapseToEnd(),void this.inlineToolbar.close()):(this.notifier.show({message:"Pasted link is not valid.",style:"error"}),void m("Incorrect Link pasted","warn",t)):(this.selection.restore(),this.unlink(),e.preventDefault(),void this.closeActions())}validateURL(e){return!/\s/.test(e)}prepareLink(e){return e=e.trim(),e=this.addProtocol(e)}addProtocol(e){if(/^(\w+):(\/\/)?/.test(e))return e;const t=/^\/[^/\s]/.test(e),o="#"===e.substring(0,1),n=/^\/\/[^/\s]/.test(e);return!t&&!o&&!n&&(e="http://"+e),e}insertLink(e){const t=this.selection.findParentTag("A");t&&this.selection.expandToTag(t),document.execCommand(this.commandLink,!1,e)}unlink(){document.execCommand(this.commandUnlink)}}Vn.isInline=!0,Vn.title="Link";let Gn=class{constructor({api:e}){this.i18nAPI=e.i18n,this.blocksAPI=e.blocks,this.selectionAPI=e.selection,this.toolsAPI=e.tools,this.caretAPI=e.caret}async render(){const e=V.get(),t=this.blocksAPI.getBlockByElement(e.anchorNode);if(void 0===t)return[];const o=this.toolsAPI.getBlockTools(),n=await ie(t,o);if(0===n.length)return[];const i=n.reduce(((e,o)=>{var n;return null==(n=o.toolbox)||n.forEach((n=>{e.push({icon:n.icon,title:W.t(Se.toolNames,n.title),name:o.name,closeOnActivate:!0,onActivate:async()=>{const e=await this.blocksAPI.convert(t.id,o.name,n.data);this.caretAPI.setToBlock(e,"end")}})})),e}),[]),r=await t.getActiveToolboxEntry(),s=void 0!==r?r.icon:Ie,a=!D();return{icon:s,name:"convert-to",hint:{title:this.i18nAPI.t("Convert to")},children:{searchable:a,items:i,onOpen:()=>{a&&(this.selectionAPI.setFakeBackground(),this.selectionAPI.save())},onClose:()=>{a&&(this.selectionAPI.restore(),this.selectionAPI.removeFakeBackground())}}}}};Gn.isInline=!0;let Zn=class{constructor({data:e,api:t}){this.CSS={wrapper:"ce-stub",info:"ce-stub__info",title:"ce-stub__title",subtitle:"ce-stub__subtitle"},this.api=t,this.title=e.title||this.api.i18n.t("Error"),this.subtitle=this.api.i18n.t("The block can not be displayed correctly."),this.savedData=e.savedData,this.wrapper=this.make()}render(){return this.wrapper}save(){return this.savedData}make(){const e=F.make("div",this.CSS.wrapper),t=F.make("div",this.CSS.info),o=F.make("div",this.CSS.title,{textContent:this.title}),n=F.make("div",this.CSS.subtitle,{textContent:this.subtitle});return e.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><rect width="14" height="14" x="5" y="5" stroke="currentColor" stroke-width="2" rx="4"/><line x1="12" x2="12" y1="9" y2="12" stroke="currentColor" stroke-linecap="round" stroke-width="2"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M12 15.02V15.01"/></svg>',t.appendChild(o),t.appendChild(n),e.appendChild(t),e}};Zn.isReadOnlySupported=!0;class Jn extends Ot{constructor(){super(...arguments),this.type=xt.Inline}get title(){return this.constructable[Tt.Title]}create(){return new this.constructable({api:this.api,config:this.settings})}get isReadOnlySupported(){return this.constructable[Tt.IsReadOnlySupported]??!1}}class Qn extends Ot{constructor(){super(...arguments),this.type=xt.Tune}create(e,t){return new this.constructable({api:this.api,config:this.settings,block:t,data:e})}}let ei=class e extends Map{get blockTools(){const t=Array.from(this.entries()).filter((([,e])=>e.isBlock()));return new e(t)}get inlineTools(){const t=Array.from(this.entries()).filter((([,e])=>e.isInline()));return new e(t)}get blockTunes(){const t=Array.from(this.entries()).filter((([,e])=>e.isTune()));return new e(t)}get internalTools(){const t=Array.from(this.entries()).filter((([,e])=>e.isInternal));return new e(t)}get externalTools(){const t=Array.from(this.entries()).filter((([,e])=>!e.isInternal));return new e(t)}};var ti=Object.defineProperty,oi=Object.getOwnPropertyDescriptor,ni=(e,t,o,n)=>{for(var i,r=n>1?void 0:n?oi(t,o):t,s=e.length-1;s>=0;s--)(i=e[s])&&(r=(n?i(t,o,r):i(r))||r);return n&&r&&ti(t,o,r),r};class ii extends Ot{constructor(){super(...arguments),this.type=xt.Block,this.inlineTools=new ei,this.tunes=new ei}create(e,t,o){return new this.constructable({data:e,block:t,readOnly:o,api:this.api,config:this.settings})}get isReadOnlySupported(){return!0===this.constructable[St.IsReadOnlySupported]}get isLineBreaksEnabled(){return this.constructable[St.IsEnabledLineBreaks]}get toolbox(){const e=this.constructable[St.Toolbox],t=this.config[Et.Toolbox];if(!C(e)&&!1!==t)return t?Array.isArray(e)?Array.isArray(t)?t.map(((t,o)=>{const n=e[o];return n?{...n,...t}:t})):[t]:Array.isArray(t)?t:[{...e,...t}]:Array.isArray(e)?e:[e]}get conversionConfig(){return this.constructable[St.ConversionConfig]}get enabledInlineTools(){return this.config[Et.EnabledInlineTools]||!1}get enabledBlockTunes(){return this.config[Et.EnabledBlockTunes]}get pasteConfig(){return this.constructable[St.PasteConfig]??{}}get sanitizeConfig(){const e=super.sanitizeConfig,t=this.baseSanitizeConfig;if(C(e))return t;const o={};for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)){const i=e[n];k(i)?o[n]=Object.assign({},t,i):o[n]=i}return o}get baseSanitizeConfig(){const e={};return Array.from(this.inlineTools.values()).forEach((t=>Object.assign(e,t.sanitizeConfig))),Array.from(this.tunes.values()).forEach((t=>Object.assign(e,t.sanitizeConfig))),e}}ni([j],ii.prototype,"sanitizeConfig",1),ni([j],ii.prototype,"baseSanitizeConfig",1);class ri{constructor(e,t,o){this.api=o,this.config=e,this.editorConfig=t}get(e){const{class:t,isInternal:o=!1,...n}=this.config[e],i=this.getConstructor(t),r=t[_t.IsTune];return new i({name:e,constructable:t,config:n,api:this.api.getMethodsForTool(e,r),isDefault:e===this.editorConfig.defaultBlock,defaultPlaceholder:this.editorConfig.placeholder,isInternal:o})}getConstructor(e){switch(!0){case e[Tt.IsInline]:return Jn;case e[_t.IsTune]:return Qn;default:return ii}}}let si=class{constructor({api:e}){this.CSS={animation:"wobble"},this.api=e}render(){return{icon:'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M7 10L11.8586 14.8586C11.9367 14.9367 12.0633 14.9367 12.1414 14.8586L17 10"/></svg>',title:this.api.i18n.t("Move down"),onActivate:()=>this.handleClick(),name:"move-down"}}handleClick(){const e=this.api.blocks.getCurrentBlockIndex(),t=this.api.blocks.getBlockByIndex(e+1);if(!t)throw new Error("Unable to move Block down since it is already the last");const o=t.holder,n=o.getBoundingClientRect();let i=Math.abs(window.innerHeight-o.offsetHeight);n.top<window.innerHeight&&(i=window.scrollY+o.offsetHeight),window.scrollTo(0,i),this.api.blocks.move(e+1),this.api.toolbar.toggleBlockSettings(!0)}};si.isTune=!0;let ai=class{constructor({api:e}){this.api=e}render(){return{icon:'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M8 8L12 12M12 12L16 16M12 12L16 8M12 12L8 16"/></svg>',title:this.api.i18n.t("Delete"),name:"delete",confirmation:{title:this.api.i18n.t("Click to delete"),onActivate:()=>this.handleClick()}}}handleClick(){this.api.blocks.delete()}};ai.isTune=!0;let li=class{constructor({api:e}){this.CSS={animation:"wobble"},this.api=e}render(){return{icon:'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M7 15L11.8586 10.1414C11.9367 10.0633 12.0633 10.0633 12.1414 10.1414L17 15"/></svg>',title:this.api.i18n.t("Move up"),onActivate:()=>this.handleClick(),name:"move-up"}}handleClick(){const e=this.api.blocks.getCurrentBlockIndex(),t=this.api.blocks.getBlockByIndex(e),o=this.api.blocks.getBlockByIndex(e-1);if(0===e||!t||!o)throw new Error("Unable to move Block up since it is already the first");const n=t.holder,i=o.holder,r=n.getBoundingClientRect(),s=i.getBoundingClientRect();let a;a=s.top>0?Math.abs(r.top)-Math.abs(s.top):Math.abs(r.top)+s.height,window.scrollBy(0,-1*a),this.api.blocks.move(e-1),this.api.toolbar.toggleBlockSettings(!0)}};li.isTune=!0;var ci=Object.defineProperty,di=Object.getOwnPropertyDescriptor;let ui=class extends X{constructor(){super(...arguments),this.stubTool="stub",this.toolsAvailable=new ei,this.toolsUnavailable=new ei}get available(){return this.toolsAvailable}get unavailable(){return this.toolsUnavailable}get inlineTools(){return this.available.inlineTools}get blockTools(){return this.available.blockTools}get blockTunes(){return this.available.blockTunes}get defaultTool(){return this.blockTools.get(this.config.defaultBlock)}get internal(){return this.available.internalTools}async prepare(){if(this.validateTools(),this.config.tools=P({},this.internalTools,this.config.tools),!Object.prototype.hasOwnProperty.call(this.config,"tools")||0===Object.keys(this.config.tools).length)throw Error("Can't start without tools");const e=this.prepareConfig();this.factory=new ri(e,this.config,this.Editor.API);const t=this.getListOfPrepareFunctions(e);if(0===t.length)return Promise.resolve();await T(t,(e=>{this.toolPrepareMethodSuccess(e)}),(e=>{this.toolPrepareMethodFallback(e)})),this.prepareBlockTools()}getAllInlineToolsSanitizeConfig(){const e={};return Array.from(this.inlineTools.values()).forEach((t=>{Object.assign(e,t.sanitizeConfig)})),e}destroy(){Object.values(this.available).forEach((async e=>{y(e.reset)&&await e.reset()}))}get internalTools(){return{convertTo:{class:Gn,isInternal:!0},link:{class:Vn,isInternal:!0},bold:{class:Yn,isInternal:!0},italic:{class:Xn,isInternal:!0},paragraph:{class:Kn,inlineToolbar:!0,isInternal:!0},stub:{class:Zn,isInternal:!0},moveUp:{class:li,isInternal:!0},delete:{class:ai,isInternal:!0},moveDown:{class:si,isInternal:!0}}}toolPrepareMethodSuccess(e){const t=this.factory.get(e.toolName);if(t.isInline()){const e=["render"].filter((e=>!t.create()[e]));if(e.length)return m(`Incorrect Inline Tool: ${t.name}. Some of required methods is not implemented %o`,"warn",e),void this.toolsUnavailable.set(t.name,t)}this.toolsAvailable.set(t.name,t)}toolPrepareMethodFallback(e){this.toolsUnavailable.set(e.toolName,this.factory.get(e.toolName))}getListOfPrepareFunctions(e){const t=[];return Object.entries(e).forEach((([e,o])=>{t.push({function:y(o.class.prepare)?o.class.prepare:()=>{},data:{toolName:e,config:o.config}})})),t}prepareBlockTools(){Array.from(this.blockTools.values()).forEach((e=>{this.assignInlineToolsToBlockTool(e),this.assignBlockTunesToBlockTool(e)}))}assignInlineToolsToBlockTool(e){if(!1!==this.config.inlineToolbar){if(!0===e.enabledInlineTools)return void(e.inlineTools=new ei(Array.isArray(this.config.inlineToolbar)?this.config.inlineToolbar.map((e=>[e,this.inlineTools.get(e)])):Array.from(this.inlineTools.entries())));Array.isArray(e.enabledInlineTools)&&(e.inlineTools=new ei(["convertTo",...e.enabledInlineTools].map((e=>[e,this.inlineTools.get(e)]))))}}assignBlockTunesToBlockTool(e){if(!1!==e.enabledBlockTunes){if(Array.isArray(e.enabledBlockTunes)){const t=new ei(e.enabledBlockTunes.map((e=>[e,this.blockTunes.get(e)])));return void(e.tunes=new ei([...t,...this.blockTunes.internalTools]))}if(Array.isArray(this.config.tunes)){const t=new ei(this.config.tunes.map((e=>[e,this.blockTunes.get(e)])));return void(e.tunes=new ei([...t,...this.blockTunes.internalTools]))}e.tunes=this.blockTunes.internalTools}}validateTools(){for(const e in this.config.tools)if(Object.prototype.hasOwnProperty.call(this.config.tools,e)){if(e in this.internalTools)return;const t=this.config.tools[e];if(!y(t)&&!y(t.class))throw Error(`Tool «${e}» must be a constructor function or an object with function in the «class» property`)}}prepareConfig(){const e={};for(const t in this.config.tools)k(this.config.tools[t])?e[t]=this.config.tools[t]:e[t]={class:this.config.tools[t]};return e}};((e,t,o,n)=>{for(var i,r=n>1?void 0:n?di(t,o):t,s=e.length-1;s>=0;s--)(i=e[s])&&(r=(n?i(t,o,r):i(r))||r);n&&r&&ci(t,o,r)})([j],ui.prototype,"getAllInlineToolsSanitizeConfig",1);const hi=':root{--selectionColor: #e1f2ff;--inlineSelectionColor: #d4ecff;--bg-light: #eff2f5;--grayText: #707684;--color-dark: #1D202B;--color-active-icon: #388AE5;--color-gray-border: rgba(201, 201, 204, .48);--content-width: 650px;--narrow-mode-right-padding: 50px;--toolbox-buttons-size: 26px;--toolbox-buttons-size--mobile: 36px;--icon-size: 20px;--icon-size--mobile: 28px;--block-padding-vertical: .4em;--color-line-gray: #EFF0F1 }.codex-editor{position:relative;-webkit-box-sizing:border-box;box-sizing:border-box;z-index:1}.codex-editor .hide{display:none}.codex-editor__redactor [contenteditable]:empty:after{content:"\\feff"}@media (min-width: 651px){.codex-editor--narrow .codex-editor__redactor{margin-right:50px}}@media (min-width: 651px){.codex-editor--narrow.codex-editor--rtl .codex-editor__redactor{margin-left:50px;margin-right:0}}@media (min-width: 651px){.codex-editor--narrow .ce-toolbar__actions{right:-5px}}.codex-editor-copyable{position:absolute;height:1px;width:1px;top:-400%;opacity:.001}.codex-editor-overlay{position:fixed;top:0;left:0;right:0;bottom:0;z-index:999;pointer-events:none;overflow:hidden}.codex-editor-overlay__container{position:relative;pointer-events:auto;z-index:0}.codex-editor-overlay__rectangle{position:absolute;pointer-events:none;background-color:#2eaadc33;border:1px solid transparent}.codex-editor svg{max-height:100%}.codex-editor path{stroke:currentColor}.codex-editor ::-moz-selection{background-color:#d4ecff}.codex-editor ::selection{background-color:#d4ecff}.codex-editor--toolbox-opened [contentEditable=true][data-placeholder]:focus:before{opacity:0!important}.ce-scroll-locked{overflow:hidden}.ce-scroll-locked--hard{overflow:hidden;top:calc(-1 * var(--window-scroll-offset));position:fixed;width:100%}.ce-toolbar{position:absolute;left:0;right:0;top:0;-webkit-transition:opacity .1s ease;transition:opacity .1s ease;will-change:opacity,top;display:none}.ce-toolbar--opened{display:block}.ce-toolbar__content{max-width:650px;margin:0 auto;position:relative}.ce-toolbar__plus{color:#1d202b;cursor:pointer;width:26px;height:26px;border-radius:7px;display:-webkit-inline-box;display:-ms-inline-flexbox;display:inline-flex;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-ms-flex-negative:0;flex-shrink:0}@media (max-width: 650px){.ce-toolbar__plus{width:36px;height:36px}}@media (hover: hover){.ce-toolbar__plus:hover{background-color:#eff2f5}}.ce-toolbar__plus--active{background-color:#eff2f5;-webkit-animation:bounceIn .75s 1;animation:bounceIn .75s 1;-webkit-animation-fill-mode:forwards;animation-fill-mode:forwards}.ce-toolbar__plus-shortcut{opacity:.6;word-spacing:-2px;margin-top:5px}@media (max-width: 650px){.ce-toolbar__plus{position:absolute;background-color:#fff;border:1px solid #E8E8EB;-webkit-box-shadow:0 3px 15px -3px rgba(13,20,33,.13);box-shadow:0 3px 15px -3px #0d142121;border-radius:6px;z-index:2;position:static}.ce-toolbar__plus--left-oriented:before{left:15px;margin-left:0}.ce-toolbar__plus--right-oriented:before{left:auto;right:15px;margin-left:0}}.ce-toolbar__actions{position:absolute;right:100%;opacity:0;display:-webkit-box;display:-ms-flexbox;display:flex;padding-right:5px}.ce-toolbar__actions--opened{opacity:1}@media (max-width: 650px){.ce-toolbar__actions{right:auto}}.ce-toolbar__settings-btn{color:#1d202b;width:26px;height:26px;border-radius:7px;display:-webkit-inline-box;display:-ms-inline-flexbox;display:inline-flex;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;margin-left:3px;cursor:pointer;user-select:none}@media (max-width: 650px){.ce-toolbar__settings-btn{width:36px;height:36px}}@media (hover: hover){.ce-toolbar__settings-btn:hover{background-color:#eff2f5}}.ce-toolbar__settings-btn--active{background-color:#eff2f5;-webkit-animation:bounceIn .75s 1;animation:bounceIn .75s 1;-webkit-animation-fill-mode:forwards;animation-fill-mode:forwards}@media (min-width: 651px){.ce-toolbar__settings-btn{width:24px}}.ce-toolbar__settings-btn--hidden{display:none}@media (max-width: 650px){.ce-toolbar__settings-btn{position:absolute;background-color:#fff;border:1px solid #E8E8EB;-webkit-box-shadow:0 3px 15px -3px rgba(13,20,33,.13);box-shadow:0 3px 15px -3px #0d142121;border-radius:6px;z-index:2;position:static}.ce-toolbar__settings-btn--left-oriented:before{left:15px;margin-left:0}.ce-toolbar__settings-btn--right-oriented:before{left:auto;right:15px;margin-left:0}}.ce-toolbar__plus svg,.ce-toolbar__settings-btn svg{width:24px;height:24px}@media (min-width: 651px){.codex-editor--narrow .ce-toolbar__plus{left:5px}}@media (min-width: 651px){.codex-editor--narrow .ce-toolbox .ce-popover{right:0;left:auto;left:initial}}.ce-inline-toolbar{--y-offset: 8px;--color-background-icon-active: rgba(56, 138, 229, .1);--color-text-icon-active: #388AE5;--color-text-primary: black;position:absolute;visibility:hidden;-webkit-transition:opacity .25s ease;transition:opacity .25s ease;will-change:opacity,left,top;top:0;left:0;z-index:3;opacity:1;visibility:visible}.ce-inline-toolbar [hidden]{display:none!important}.ce-inline-toolbar__toggler-and-button-wrapper{display:-webkit-box;display:-ms-flexbox;display:flex;width:100%;padding:0 6px}.ce-inline-toolbar__buttons{display:-webkit-box;display:-ms-flexbox;display:flex}.ce-inline-toolbar__dropdown{display:-webkit-box;display:-ms-flexbox;display:flex;padding:6px;margin:0 6px 0 -6px;-webkit-box-align:center;-ms-flex-align:center;align-items:center;cursor:pointer;border-right:1px solid rgba(201,201,204,.48);-webkit-box-sizing:border-box;box-sizing:border-box}@media (hover: hover){.ce-inline-toolbar__dropdown:hover{background:#eff2f5}}.ce-inline-toolbar__dropdown--hidden{display:none}.ce-inline-toolbar__dropdown-content,.ce-inline-toolbar__dropdown-arrow{display:-webkit-box;display:-ms-flexbox;display:flex}.ce-inline-toolbar__dropdown-content svg,.ce-inline-toolbar__dropdown-arrow svg{width:20px;height:20px}.ce-inline-toolbar__shortcut{opacity:.6;word-spacing:-3px;margin-top:3px}.ce-inline-tool{color:var(--color-text-primary);display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;border:0;border-radius:4px;line-height:normal;height:100%;padding:0;width:28px;background-color:transparent;cursor:pointer}@media (max-width: 650px){.ce-inline-tool{width:36px;height:36px}}@media (hover: hover){.ce-inline-tool:hover{background-color:#f8f8f8}}.ce-inline-tool svg{display:block;width:20px;height:20px}@media (max-width: 650px){.ce-inline-tool svg{width:28px;height:28px}}.ce-inline-tool--link .icon--unlink,.ce-inline-tool--unlink .icon--link{display:none}.ce-inline-tool--unlink .icon--unlink{display:inline-block;margin-bottom:-1px}.ce-inline-tool-input{background:#F8F8F8;border:1px solid rgba(226,226,229,.2);border-radius:6px;padding:4px 8px;font-size:14px;line-height:22px;outline:none;margin:0;width:100%;-webkit-box-sizing:border-box;box-sizing:border-box;display:none;font-weight:500;-webkit-appearance:none;font-family:inherit}@media (max-width: 650px){.ce-inline-tool-input{font-size:15px;font-weight:500}}.ce-inline-tool-input::-webkit-input-placeholder{color:#707684}.ce-inline-tool-input::-moz-placeholder{color:#707684}.ce-inline-tool-input:-ms-input-placeholder{color:#707684}.ce-inline-tool-input::-ms-input-placeholder{color:#707684}.ce-inline-tool-input::placeholder{color:#707684}.ce-inline-tool-input--showed{display:block}.ce-inline-tool--active{background:var(--color-background-icon-active);color:var(--color-text-icon-active)}@-webkit-keyframes fade-in{0%{opacity:0}to{opacity:1}}@keyframes fade-in{0%{opacity:0}to{opacity:1}}.ce-block{-webkit-animation:fade-in .3s ease;animation:fade-in .3s ease;-webkit-animation-fill-mode:none;animation-fill-mode:none;-webkit-animation-fill-mode:initial;animation-fill-mode:initial}.ce-block:first-of-type{margin-top:0}.ce-block--selected .ce-block__content{background:#e1f2ff}.ce-block--selected .ce-block__content [contenteditable]{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.ce-block--selected .ce-block__content img,.ce-block--selected .ce-block__content .ce-stub{opacity:.55}.ce-block--stretched .ce-block__content{max-width:none}.ce-block__content{position:relative;max-width:650px;margin:0 auto;-webkit-transition:background-color .15s ease;transition:background-color .15s ease}.ce-block--drop-target .ce-block__content:before{content:"";position:absolute;top:100%;left:-20px;margin-top:-1px;height:8px;width:8px;border:solid #388AE5;border-width:1px 1px 0 0;-webkit-transform-origin:right;transform-origin:right;-webkit-transform:rotate(45deg);transform:rotate(45deg)}.ce-block--drop-target .ce-block__content:after{content:"";position:absolute;top:100%;height:1px;width:100%;color:#388ae5;background:repeating-linear-gradient(90deg,#388AE5,#388AE5 1px,#fff 1px,#fff 6px)}.ce-block a{cursor:pointer;-webkit-text-decoration:underline;text-decoration:underline}.ce-block b{font-weight:700}.ce-block i{font-style:italic}@-webkit-keyframes bounceIn{0%,20%,40%,60%,80%,to{-webkit-animation-timing-function:cubic-bezier(.215,.61,.355,1);animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{-webkit-transform:scale3d(.9,.9,.9);transform:scale3d(.9,.9,.9)}20%{-webkit-transform:scale3d(1.03,1.03,1.03);transform:scale3d(1.03,1.03,1.03)}60%{-webkit-transform:scale3d(1,1,1);transform:scaleZ(1)}}@keyframes bounceIn{0%,20%,40%,60%,80%,to{-webkit-animation-timing-function:cubic-bezier(.215,.61,.355,1);animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{-webkit-transform:scale3d(.9,.9,.9);transform:scale3d(.9,.9,.9)}20%{-webkit-transform:scale3d(1.03,1.03,1.03);transform:scale3d(1.03,1.03,1.03)}60%{-webkit-transform:scale3d(1,1,1);transform:scaleZ(1)}}@-webkit-keyframes selectionBounce{0%,20%,40%,60%,80%,to{-webkit-animation-timing-function:cubic-bezier(.215,.61,.355,1);animation-timing-function:cubic-bezier(.215,.61,.355,1)}50%{-webkit-transform:scale3d(1.01,1.01,1.01);transform:scale3d(1.01,1.01,1.01)}70%{-webkit-transform:scale3d(1,1,1);transform:scaleZ(1)}}@keyframes selectionBounce{0%,20%,40%,60%,80%,to{-webkit-animation-timing-function:cubic-bezier(.215,.61,.355,1);animation-timing-function:cubic-bezier(.215,.61,.355,1)}50%{-webkit-transform:scale3d(1.01,1.01,1.01);transform:scale3d(1.01,1.01,1.01)}70%{-webkit-transform:scale3d(1,1,1);transform:scaleZ(1)}}@-webkit-keyframes buttonClicked{0%,20%,40%,60%,80%,to{-webkit-animation-timing-function:cubic-bezier(.215,.61,.355,1);animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{-webkit-transform:scale3d(.95,.95,.95);transform:scale3d(.95,.95,.95)}60%{-webkit-transform:scale3d(1.02,1.02,1.02);transform:scale3d(1.02,1.02,1.02)}80%{-webkit-transform:scale3d(1,1,1);transform:scaleZ(1)}}@keyframes buttonClicked{0%,20%,40%,60%,80%,to{-webkit-animation-timing-function:cubic-bezier(.215,.61,.355,1);animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{-webkit-transform:scale3d(.95,.95,.95);transform:scale3d(.95,.95,.95)}60%{-webkit-transform:scale3d(1.02,1.02,1.02);transform:scale3d(1.02,1.02,1.02)}80%{-webkit-transform:scale3d(1,1,1);transform:scaleZ(1)}}.cdx-block{padding:.4em 0}.cdx-block::-webkit-input-placeholder{line-height:normal!important}.cdx-input{border:1px solid rgba(201,201,204,.48);-webkit-box-shadow:inset 0 1px 2px 0 rgba(35,44,72,.06);box-shadow:inset 0 1px 2px #232c480f;border-radius:3px;padding:10px 12px;outline:none;width:100%;-webkit-box-sizing:border-box;box-sizing:border-box}.cdx-input[data-placeholder]:before{position:static!important}.cdx-input[data-placeholder]:before{display:inline-block;width:0;white-space:nowrap;pointer-events:none}.cdx-settings-button{display:-webkit-inline-box;display:-ms-inline-flexbox;display:inline-flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;border-radius:3px;cursor:pointer;border:0;outline:none;background-color:transparent;vertical-align:bottom;color:inherit;margin:0;min-width:26px;min-height:26px}.cdx-settings-button--focused{background:rgba(34,186,255,.08)!important}.cdx-settings-button--focused{-webkit-box-shadow:inset 0 0 0px 1px rgba(7,161,227,.08);box-shadow:inset 0 0 0 1px #07a1e314}.cdx-settings-button--focused-animated{-webkit-animation-name:buttonClicked;animation-name:buttonClicked;-webkit-animation-duration:.25s;animation-duration:.25s}.cdx-settings-button--active{color:#388ae5}.cdx-settings-button svg{width:auto;height:auto}@media (max-width: 650px){.cdx-settings-button svg{width:28px;height:28px}}@media (max-width: 650px){.cdx-settings-button{width:36px;height:36px;border-radius:8px}}@media (hover: hover){.cdx-settings-button:hover{background-color:#eff2f5}}.cdx-loader{position:relative;border:1px solid rgba(201,201,204,.48)}.cdx-loader:before{content:"";position:absolute;left:50%;top:50%;width:18px;height:18px;margin:-11px 0 0 -11px;border:2px solid rgba(201,201,204,.48);border-left-color:#388ae5;border-radius:50%;-webkit-animation:cdxRotation 1.2s infinite linear;animation:cdxRotation 1.2s infinite linear}@-webkit-keyframes cdxRotation{0%{-webkit-transform:rotate(0deg);transform:rotate(0)}to{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@keyframes cdxRotation{0%{-webkit-transform:rotate(0deg);transform:rotate(0)}to{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}.cdx-button{padding:13px;border-radius:3px;border:1px solid rgba(201,201,204,.48);font-size:14.9px;background:#fff;-webkit-box-shadow:0 2px 2px 0 rgba(18,30,57,.04);box-shadow:0 2px 2px #121e390a;color:#707684;text-align:center;cursor:pointer}@media (hover: hover){.cdx-button:hover{background:#FBFCFE;-webkit-box-shadow:0 1px 3px 0 rgba(18,30,57,.08);box-shadow:0 1px 3px #121e3914}}.cdx-button svg{height:20px;margin-right:.2em;margin-top:-2px}.ce-stub{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;padding:12px 18px;margin:10px 0;border-radius:10px;background:#eff2f5;border:1px solid #EFF0F1;color:#707684;font-size:14px}.ce-stub svg{width:20px;height:20px}.ce-stub__info{margin-left:14px}.ce-stub__title{font-weight:500;text-transform:capitalize}.codex-editor.codex-editor--rtl{direction:rtl}.codex-editor.codex-editor--rtl .cdx-list{padding-left:0;padding-right:40px}.codex-editor.codex-editor--rtl .ce-toolbar__plus{right:-26px;left:auto}.codex-editor.codex-editor--rtl .ce-toolbar__actions{right:auto;left:-26px}@media (max-width: 650px){.codex-editor.codex-editor--rtl .ce-toolbar__actions{margin-left:0;margin-right:auto;padding-right:0;padding-left:10px}}.codex-editor.codex-editor--rtl .ce-settings{left:5px;right:auto}.codex-editor.codex-editor--rtl .ce-settings:before{right:auto;left:25px}.codex-editor.codex-editor--rtl .ce-settings__button:not(:nth-child(3n+3)){margin-left:3px;margin-right:0}.codex-editor.codex-editor--rtl .ce-conversion-tool__icon{margin-right:0;margin-left:10px}.codex-editor.codex-editor--rtl .ce-inline-toolbar__dropdown{border-right:0px solid transparent;border-left:1px solid rgba(201,201,204,.48);margin:0 -6px 0 6px}.codex-editor.codex-editor--rtl .ce-inline-toolbar__dropdown .icon--toggler-down{margin-left:0;margin-right:4px}@media (min-width: 651px){.codex-editor--narrow.codex-editor--rtl .ce-toolbar__plus{left:0;right:5px}}@media (min-width: 651px){.codex-editor--narrow.codex-editor--rtl .ce-toolbar__actions{left:-5px}}.cdx-search-field{--icon-margin-right: 10px;background:#F8F8F8;border:1px solid rgba(226,226,229,.2);border-radius:6px;padding:2px;display:grid;grid-template-columns:auto auto 1fr;grid-template-rows:auto}.cdx-search-field__icon{width:26px;height:26px;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;margin-right:var(--icon-margin-right)}.cdx-search-field__icon svg{width:20px;height:20px;color:#707684}.cdx-search-field__input{font-size:14px;outline:none;font-weight:500;font-family:inherit;border:0;background:transparent;margin:0;padding:0;line-height:22px;min-width:calc(100% - 26px - var(--icon-margin-right))}.cdx-search-field__input::-webkit-input-placeholder{color:#707684;font-weight:500}.cdx-search-field__input::-moz-placeholder{color:#707684;font-weight:500}.cdx-search-field__input:-ms-input-placeholder{color:#707684;font-weight:500}.cdx-search-field__input::-ms-input-placeholder{color:#707684;font-weight:500}.cdx-search-field__input::placeholder{color:#707684;font-weight:500}.ce-popover{--border-radius: 6px;--width: 200px;--max-height: 270px;--padding: 6px;--offset-from-target: 8px;--color-border: #EFF0F1;--color-shadow: rgba(13, 20, 33, .1);--color-background: white;--color-text-primary: black;--color-text-secondary: #707684;--color-border-icon: rgba(201, 201, 204, .48);--color-border-icon-disabled: #EFF0F1;--color-text-icon-active: #388AE5;--color-background-icon-active: rgba(56, 138, 229, .1);--color-background-item-focus: rgba(34, 186, 255, .08);--color-shadow-item-focus: rgba(7, 161, 227, .08);--color-background-item-hover: #F8F8F8;--color-background-item-confirm: #E24A4A;--color-background-item-confirm-hover: #CE4343;--popover-top: calc(100% + var(--offset-from-target));--popover-left: 0;--nested-popover-overlap: 4px;--icon-size: 20px;--item-padding: 3px;--item-height: calc(var(--icon-size) + 2 * var(--item-padding))}.ce-popover__container{min-width:var(--width);width:var(--width);max-height:var(--max-height);border-radius:var(--border-radius);overflow:hidden;-webkit-box-sizing:border-box;box-sizing:border-box;-webkit-box-shadow:0px 3px 15px -3px var(--color-shadow);box-shadow:0 3px 15px -3px var(--color-shadow);position:absolute;left:var(--popover-left);top:var(--popover-top);background:var(--color-background);display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;z-index:4;opacity:0;max-height:0;pointer-events:none;padding:0;border:none}.ce-popover--opened>.ce-popover__container{opacity:1;padding:var(--padding);max-height:var(--max-height);pointer-events:auto;-webkit-animation:panelShowing .1s ease;animation:panelShowing .1s ease;border:1px solid var(--color-border)}@media (max-width: 650px){.ce-popover--opened>.ce-popover__container{-webkit-animation:panelShowingMobile .25s ease;animation:panelShowingMobile .25s ease}}.ce-popover--open-top .ce-popover__container{--popover-top: calc(-1 * (var(--offset-from-target) + var(--popover-height)))}.ce-popover--open-left .ce-popover__container{--popover-left: calc(-1 * var(--width) + 100%)}.ce-popover__items{overflow-y:auto;-ms-scroll-chaining:none;overscroll-behavior:contain}@media (max-width: 650px){.ce-popover__overlay{position:fixed;top:0;bottom:0;left:0;right:0;background:#1D202B;z-index:3;opacity:.5;-webkit-transition:opacity .12s ease-in;transition:opacity .12s ease-in;will-change:opacity;visibility:visible}}.ce-popover__overlay--hidden{display:none}@media (max-width: 650px){.ce-popover .ce-popover__container{--offset: 5px;position:fixed;max-width:none;min-width:calc(100% - var(--offset) * 2);left:var(--offset);right:var(--offset);bottom:calc(var(--offset) + env(safe-area-inset-bottom));top:auto;border-radius:10px}}.ce-popover__search{margin-bottom:5px}.ce-popover__nothing-found-message{color:#707684;display:none;cursor:default;padding:3px;font-size:14px;line-height:20px;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ce-popover__nothing-found-message--displayed{display:block}.ce-popover--nested .ce-popover__container{--popover-left: calc(var(--nesting-level) * (var(--width) - var(--nested-popover-overlap)));top:calc(var(--trigger-item-top) - var(--nested-popover-overlap));position:absolute}.ce-popover--open-top.ce-popover--nested .ce-popover__container{top:calc(var(--trigger-item-top) - var(--popover-height) + var(--item-height) + var(--offset-from-target) + var(--nested-popover-overlap))}.ce-popover--open-left .ce-popover--nested .ce-popover__container{--popover-left: calc(-1 * (var(--nesting-level) + 1) * var(--width) + 100%)}.ce-popover-item-separator{padding:4px 3px}.ce-popover-item-separator--hidden{display:none}.ce-popover-item-separator__line{height:1px;background:var(--color-border);width:100%}.ce-popover-item-html--hidden{display:none}.ce-popover-item{--border-radius: 6px;border-radius:var(--border-radius);display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;padding:var(--item-padding);color:var(--color-text-primary);-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;border:none;background:transparent}@media (max-width: 650px){.ce-popover-item{padding:4px}}.ce-popover-item:not(:last-of-type){margin-bottom:1px}.ce-popover-item__icon{width:26px;height:26px;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center}.ce-popover-item__icon svg{width:20px;height:20px}@media (max-width: 650px){.ce-popover-item__icon{width:36px;height:36px;border-radius:8px}.ce-popover-item__icon svg{width:28px;height:28px}}.ce-popover-item__icon--tool{margin-right:4px}.ce-popover-item__title{font-size:14px;line-height:20px;font-weight:500;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin-right:auto}@media (max-width: 650px){.ce-popover-item__title{font-size:16px}}.ce-popover-item__secondary-title{color:var(--color-text-secondary);font-size:12px;white-space:nowrap;letter-spacing:-.1em;padding-right:5px;opacity:.6}@media (max-width: 650px){.ce-popover-item__secondary-title{display:none}}.ce-popover-item--active{background:var(--color-background-icon-active);color:var(--color-text-icon-active)}.ce-popover-item--disabled{color:var(--color-text-secondary);cursor:default;pointer-events:none}.ce-popover-item--focused:not(.ce-popover-item--no-focus){background:var(--color-background-item-focus)!important}.ce-popover-item--hidden{display:none}@media (hover: hover){.ce-popover-item:hover{cursor:pointer}.ce-popover-item:hover:not(.ce-popover-item--no-hover){background-color:var(--color-background-item-hover)}}.ce-popover-item--confirmation{background:var(--color-background-item-confirm)}.ce-popover-item--confirmation .ce-popover-item__title,.ce-popover-item--confirmation .ce-popover-item__icon{color:#fff}@media (hover: hover){.ce-popover-item--confirmation:not(.ce-popover-item--no-hover):hover{background:var(--color-background-item-confirm-hover)}}.ce-popover-item--confirmation:not(.ce-popover-item--no-focus).ce-popover-item--focused{background:var(--color-background-item-confirm-hover)!important}@-webkit-keyframes panelShowing{0%{opacity:0;-webkit-transform:translateY(-8px) scale(.9);transform:translateY(-8px) scale(.9)}70%{opacity:1;-webkit-transform:translateY(2px);transform:translateY(2px)}to{-webkit-transform:translateY(0);transform:translateY(0)}}@keyframes panelShowing{0%{opacity:0;-webkit-transform:translateY(-8px) scale(.9);transform:translateY(-8px) scale(.9)}70%{opacity:1;-webkit-transform:translateY(2px);transform:translateY(2px)}to{-webkit-transform:translateY(0);transform:translateY(0)}}@-webkit-keyframes panelShowingMobile{0%{opacity:0;-webkit-transform:translateY(14px) scale(.98);transform:translateY(14px) scale(.98)}70%{opacity:1;-webkit-transform:translateY(-4px);transform:translateY(-4px)}to{-webkit-transform:translateY(0);transform:translateY(0)}}@keyframes panelShowingMobile{0%{opacity:0;-webkit-transform:translateY(14px) scale(.98);transform:translateY(14px) scale(.98)}70%{opacity:1;-webkit-transform:translateY(-4px);transform:translateY(-4px)}to{-webkit-transform:translateY(0);transform:translateY(0)}}.wobble{-webkit-animation-name:wobble;animation-name:wobble;-webkit-animation-duration:.4s;animation-duration:.4s}@-webkit-keyframes wobble{0%{-webkit-transform:translate3d(0,0,0);transform:translateZ(0)}15%{-webkit-transform:translate3d(-9%,0,0);transform:translate3d(-9%,0,0)}30%{-webkit-transform:translate3d(9%,0,0);transform:translate3d(9%,0,0)}45%{-webkit-transform:translate3d(-4%,0,0);transform:translate3d(-4%,0,0)}60%{-webkit-transform:translate3d(4%,0,0);transform:translate3d(4%,0,0)}75%{-webkit-transform:translate3d(-1%,0,0);transform:translate3d(-1%,0,0)}to{-webkit-transform:translate3d(0,0,0);transform:translateZ(0)}}@keyframes wobble{0%{-webkit-transform:translate3d(0,0,0);transform:translateZ(0)}15%{-webkit-transform:translate3d(-9%,0,0);transform:translate3d(-9%,0,0)}30%{-webkit-transform:translate3d(9%,0,0);transform:translate3d(9%,0,0)}45%{-webkit-transform:translate3d(-4%,0,0);transform:translate3d(-4%,0,0)}60%{-webkit-transform:translate3d(4%,0,0);transform:translate3d(4%,0,0)}75%{-webkit-transform:translate3d(-1%,0,0);transform:translate3d(-1%,0,0)}to{-webkit-transform:translate3d(0,0,0);transform:translateZ(0)}}.ce-popover-header{margin-bottom:8px;margin-top:4px;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.ce-popover-header__text{font-size:18px;font-weight:600}.ce-popover-header__back-button{border:0;background:transparent;width:36px;height:36px;color:var(--color-text-primary)}.ce-popover-header__back-button svg{display:block;width:28px;height:28px}.ce-popover--inline{--height: 38px;--height-mobile: 46px;--container-padding: 4px;position:relative}.ce-popover--inline .ce-popover__custom-content{margin-bottom:0}.ce-popover--inline .ce-popover__items{display:-webkit-box;display:-ms-flexbox;display:flex}.ce-popover--inline .ce-popover__container{-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-direction:row;flex-direction:row;padding:var(--container-padding);height:var(--height);top:0;min-width:-webkit-max-content;min-width:-moz-max-content;min-width:max-content;width:-webkit-max-content;width:-moz-max-content;width:max-content;-webkit-animation:none;animation:none}@media (max-width: 650px){.ce-popover--inline .ce-popover__container{height:var(--height-mobile);position:absolute}}.ce-popover--inline .ce-popover-item-separator{padding:0 4px}.ce-popover--inline .ce-popover-item-separator__line{height:100%;width:1px}.ce-popover--inline .ce-popover-item{border-radius:4px;padding:4px}.ce-popover--inline .ce-popover-item__icon--tool{-webkit-box-shadow:none;box-shadow:none;background:transparent;margin-right:0}.ce-popover--inline .ce-popover-item__icon{width:auto;width:initial;height:auto;height:initial}.ce-popover--inline .ce-popover-item__icon svg{width:20px;height:20px}@media (max-width: 650px){.ce-popover--inline .ce-popover-item__icon svg{width:28px;height:28px}}.ce-popover--inline .ce-popover-item:not(:last-of-type){margin-bottom:0;margin-bottom:initial}.ce-popover--inline .ce-popover-item-html{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.ce-popover--inline .ce-popover-item__icon--chevron-right{-webkit-transform:rotate(90deg);transform:rotate(90deg)}.ce-popover--inline .ce-popover--nested-level-1 .ce-popover__container{--offset: 3px;left:0;top:calc(var(--height) + var(--offset))}@media (max-width: 650px){.ce-popover--inline .ce-popover--nested-level-1 .ce-popover__container{top:calc(var(--height-mobile) + var(--offset))}}.ce-popover--inline .ce-popover--nested .ce-popover__container{min-width:var(--width);width:var(--width);height:-webkit-fit-content;height:-moz-fit-content;height:fit-content;padding:6px;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column}.ce-popover--inline .ce-popover--nested .ce-popover__items{display:block;width:100%}.ce-popover--inline .ce-popover--nested .ce-popover-item{border-radius:6px;padding:3px}@media (max-width: 650px){.ce-popover--inline .ce-popover--nested .ce-popover-item{padding:4px}}.ce-popover--inline .ce-popover--nested .ce-popover-item__icon--tool{margin-right:4px}.ce-popover--inline .ce-popover--nested .ce-popover-item__icon{width:26px;height:26px}.ce-popover--inline .ce-popover--nested .ce-popover-item-separator{padding:4px 3px}.ce-popover--inline .ce-popover--nested .ce-popover-item-separator__line{width:100%;height:1px}.codex-editor [data-placeholder]:empty:before,.codex-editor [data-placeholder][data-empty=true]:before{pointer-events:none;color:#707684;cursor:text;content:attr(data-placeholder)}.codex-editor [data-placeholder-active]:empty:before,.codex-editor [data-placeholder-active][data-empty=true]:before{pointer-events:none;color:#707684;cursor:text}.codex-editor [data-placeholder-active]:empty:focus:before,.codex-editor [data-placeholder-active][data-empty=true]:focus:before{content:attr(data-placeholder-active)}\n';const pi={BlocksAPI:class extends X{constructor(){super(...arguments),this.insert=(e=this.config.defaultBlock,t={},o={},n,i,r,s)=>new K(this.Editor.BlockManager.insert({id:s,tool:e,data:t,index:n,needToFocus:i,replace:r})),this.composeBlockData=async e=>{const t=this.Editor.Tools.blockTools.get(e);return new ce({tool:t,api:this.Editor.API,readOnly:!0,data:{},tunesData:{}}).data},this.update=async(e,t,o)=>{const{BlockManager:n}=this.Editor,i=n.getBlockById(e);if(void 0===i)throw new Error(`Block with id "${e}" not found`);return new K(await n.update(i,t,o))},this.convert=async(e,t,o)=>{var n,i;const{BlockManager:r,Tools:s}=this.Editor,a=r.getBlockById(e);if(!a)throw new Error(`Block with id "${e}" not found`);const l=s.blockTools.get(a.name),c=s.blockTools.get(t);if(!c)throw new Error(`Block Tool with type "${t}" not found`);const d=void 0!==(null==(n=null==l?void 0:l.conversionConfig)?void 0:n.export),u=void 0!==(null==(i=c.conversionConfig)?void 0:i.import);if(d&&u){return new K(await r.convert(a,t,o))}{const e=[!d&&M(a.name),!u&&M(t)].filter(Boolean).join(" and ");throw new Error(`Conversion from "${a.name}" to "${t}" is not possible. ${e} tool(s) should provide a "conversionConfig"`)}},this.insertMany=(e,t=this.Editor.BlockManager.blocks.length-1)=>{this.validateIndex(t);const o=e.map((({id:e,type:t,data:o})=>this.Editor.BlockManager.composeBlock({id:e,tool:t||this.config.defaultBlock,data:o})));return this.Editor.BlockManager.insertMany(o,t),o.map((e=>new K(e)))}}get methods(){return{clear:()=>this.clear(),render:e=>this.render(e),renderFromHTML:e=>this.renderFromHTML(e),delete:e=>this.delete(e),swap:(e,t)=>this.swap(e,t),move:(e,t)=>this.move(e,t),getBlockByIndex:e=>this.getBlockByIndex(e),getById:e=>this.getById(e),getCurrentBlockIndex:()=>this.getCurrentBlockIndex(),getBlockIndex:e=>this.getBlockIndex(e),getBlocksCount:()=>this.getBlocksCount(),getBlockByElement:e=>this.getBlockByElement(e),stretchBlock:(e,t=!0)=>this.stretchBlock(e,t),insertNewBlock:()=>this.insertNewBlock(),insert:this.insert,insertMany:this.insertMany,update:this.update,composeBlockData:this.composeBlockData,convert:this.convert}}getBlocksCount(){return this.Editor.BlockManager.blocks.length}getCurrentBlockIndex(){return this.Editor.BlockManager.currentBlockIndex}getBlockIndex(e){const t=this.Editor.BlockManager.getBlockById(e);if(t)return this.Editor.BlockManager.getBlockIndex(t);b("There is no block with id `"+e+"`","warn")}getBlockByIndex(e){const t=this.Editor.BlockManager.getBlockByIndex(e);if(void 0!==t)return new K(t);b("There is no block at index `"+e+"`","warn")}getById(e){const t=this.Editor.BlockManager.getBlockById(e);return void 0===t?(b("There is no block with id `"+e+"`","warn"),null):new K(t)}getBlockByElement(e){const t=this.Editor.BlockManager.getBlock(e);if(void 0!==t)return new K(t);b("There is no block corresponding to element `"+e+"`","warn")}swap(e,t){m("`blocks.swap()` method is deprecated and will be removed in the next major release. Use `block.move()` method instead","info"),this.Editor.BlockManager.swap(e,t)}move(e,t){this.Editor.BlockManager.move(e,t)}delete(e=this.Editor.BlockManager.currentBlockIndex){try{const t=this.Editor.BlockManager.getBlockByIndex(e);this.Editor.BlockManager.removeBlock(t)}catch(t){return void b(t,"warn")}0===this.Editor.BlockManager.blocks.length&&this.Editor.BlockManager.insert(),this.Editor.BlockManager.currentBlock&&this.Editor.Caret.setToBlock(this.Editor.BlockManager.currentBlock,this.Editor.Caret.positions.END),this.Editor.Toolbar.close()}async clear(){await this.Editor.BlockManager.clear(!0),this.Editor.InlineToolbar.close()}async render(e){if(void 0===e||void 0===e.blocks)throw new Error("Incorrect data passed to the render() method");this.Editor.ModificationsObserver.disable(),await this.Editor.BlockManager.clear(),await this.Editor.Renderer.render(e.blocks),this.Editor.ModificationsObserver.enable()}async renderFromHTML(e){return await this.Editor.BlockManager.clear(),this.Editor.Paste.processText(e,!0)}stretchBlock(e,t=!0){N(!0,"blocks.stretchBlock()","BlockAPI");const o=this.Editor.BlockManager.getBlockByIndex(e);o&&(o.stretched=t)}insertNewBlock(){m("Method blocks.insertNewBlock() is deprecated and it will be removed in the next major release. Use blocks.insert() instead.","warn"),this.insert()}validateIndex(e){if("number"!=typeof e)throw new Error("Index should be a number");if(e<0)throw new Error("Index should be greater than or equal to 0");if(null===e)throw new Error("Index should be greater than or equal to 0")}},CaretAPI:class extends X{constructor(){super(...arguments),this.setToFirstBlock=(e=this.Editor.Caret.positions.DEFAULT,t=0)=>!!this.Editor.BlockManager.firstBlock&&(this.Editor.Caret.setToBlock(this.Editor.BlockManager.firstBlock,e,t),!0),this.setToLastBlock=(e=this.Editor.Caret.positions.DEFAULT,t=0)=>!!this.Editor.BlockManager.lastBlock&&(this.Editor.Caret.setToBlock(this.Editor.BlockManager.lastBlock,e,t),!0),this.setToPreviousBlock=(e=this.Editor.Caret.positions.DEFAULT,t=0)=>!!this.Editor.BlockManager.previousBlock&&(this.Editor.Caret.setToBlock(this.Editor.BlockManager.previousBlock,e,t),!0),this.setToNextBlock=(e=this.Editor.Caret.positions.DEFAULT,t=0)=>!!this.Editor.BlockManager.nextBlock&&(this.Editor.Caret.setToBlock(this.Editor.BlockManager.nextBlock,e,t),!0),this.setToBlock=(e,t=this.Editor.Caret.positions.DEFAULT,o=0)=>{const n=function(e,t){return"number"==typeof e?t.BlockManager.getBlockByIndex(e):"string"==typeof e?t.BlockManager.getBlockById(e):t.BlockManager.getBlockById(e.id)}(e,this.Editor);return void 0!==n&&(this.Editor.Caret.setToBlock(n,t,o),!0)},this.focus=(e=!1)=>e?this.setToLastBlock(this.Editor.Caret.positions.END):this.setToFirstBlock(this.Editor.Caret.positions.START)}get methods(){return{setToFirstBlock:this.setToFirstBlock,setToLastBlock:this.setToLastBlock,setToPreviousBlock:this.setToPreviousBlock,setToNextBlock:this.setToNextBlock,setToBlock:this.setToBlock,focus:this.focus}}},EventsAPI:class extends X{get methods(){return{emit:(e,t)=>this.emit(e,t),off:(e,t)=>this.off(e,t),on:(e,t)=>this.on(e,t)}}on(e,t){this.eventsDispatcher.on(e,t)}emit(e,t){this.eventsDispatcher.emit(e,t)}off(e,t){this.eventsDispatcher.off(e,t)}},I18nAPI:class e extends X{static getNamespace(e,t){return t?`blockTunes.${e}`:`tools.${e}`}get methods(){return{t:()=>{b("I18n.t() method can be accessed only from Tools","warn")}}}getMethodsForTool(t,o){return Object.assign(this.methods,{t:n=>W.t(e.getNamespace(t,o),n)})}},API:class extends X{get methods(){return{blocks:this.Editor.BlocksAPI.methods,caret:this.Editor.CaretAPI.methods,tools:this.Editor.ToolsAPI.methods,events:this.Editor.EventsAPI.methods,listeners:this.Editor.ListenersAPI.methods,notifier:this.Editor.NotifierAPI.methods,sanitizer:this.Editor.SanitizerAPI.methods,saver:this.Editor.SaverAPI.methods,selection:this.Editor.SelectionAPI.methods,styles:this.Editor.StylesAPI.classes,toolbar:this.Editor.ToolbarAPI.methods,inlineToolbar:this.Editor.InlineToolbarAPI.methods,tooltip:this.Editor.TooltipAPI.methods,i18n:this.Editor.I18nAPI.methods,readOnly:this.Editor.ReadOnlyAPI.methods,ui:this.Editor.UiAPI.methods}}getMethodsForTool(e,t){return Object.assign(this.methods,{i18n:this.Editor.I18nAPI.getMethodsForTool(e,t)})}},InlineToolbarAPI:class extends X{get methods(){return{close:()=>this.close(),open:()=>this.open()}}open(){this.Editor.InlineToolbar.tryToShow()}close(){this.Editor.InlineToolbar.close()}},ListenersAPI:class extends X{get methods(){return{on:(e,t,o,n)=>this.on(e,t,o,n),off:(e,t,o,n)=>this.off(e,t,o,n),offById:e=>this.offById(e)}}on(e,t,o,n){return this.listeners.on(e,t,o,n)}off(e,t,o,n){this.listeners.off(e,t,o,n)}offById(e){this.listeners.offById(e)}},NotifierAPI:class extends X{constructor({config:e,eventsDispatcher:t}){super({config:e,eventsDispatcher:t}),this.notifier=new he}get methods(){return{show:e=>this.show(e)}}show(e){return this.notifier.show(e)}},ReadOnlyAPI:class extends X{get methods(){const e=()=>this.isEnabled;return{toggle:e=>this.toggle(e),get isEnabled(){return e()}}}toggle(e){return this.Editor.ReadOnly.toggle(e)}get isEnabled(){return this.Editor.ReadOnly.isEnabled}},SanitizerAPI:class extends X{get methods(){return{clean:(e,t)=>this.clean(e,t)}}clean(e,t){return me(e,t)}},SaverAPI:class extends X{get methods(){return{save:()=>this.save()}}save(){const e="Editor's content can not be saved in read-only mode";return this.Editor.ReadOnly.isEnabled?(b(e,"warn"),Promise.reject(new Error(e))):this.Editor.Saver.save()}},SelectionAPI:class extends X{constructor(){super(...arguments),this.selectionUtils=new V}get methods(){return{findParentTag:(e,t)=>this.findParentTag(e,t),expandToTag:e=>this.expandToTag(e),save:()=>this.selectionUtils.save(),restore:()=>this.selectionUtils.restore(),setFakeBackground:()=>this.selectionUtils.setFakeBackground(),removeFakeBackground:()=>this.selectionUtils.removeFakeBackground()}}findParentTag(e,t){return this.selectionUtils.findParentTag(e,t)}expandToTag(e){this.selectionUtils.expandToTag(e)}},ToolsAPI:class extends X{get methods(){return{getBlockTools:()=>Array.from(this.Editor.Tools.blockTools.values())}}},StylesAPI:class extends X{get classes(){return{block:"cdx-block",inlineToolButton:"ce-inline-tool",inlineToolButtonActive:"ce-inline-tool--active",input:"cdx-input",loader:"cdx-loader",button:"cdx-button",settingsButton:"cdx-settings-button",settingsButtonActive:"cdx-settings-button--active"}}},ToolbarAPI:class extends X{get methods(){return{close:()=>this.close(),open:()=>this.open(),toggleBlockSettings:e=>this.toggleBlockSettings(e),toggleToolbox:e=>this.toggleToolbox(e)}}open(){this.Editor.Toolbar.moveAndOpen()}close(){this.Editor.Toolbar.close()}toggleBlockSettings(e){-1!==this.Editor.BlockManager.currentBlockIndex?e??!this.Editor.BlockSettings.opened?(this.Editor.Toolbar.moveAndOpen(),this.Editor.BlockSettings.open()):this.Editor.BlockSettings.close():b("Could't toggle the Toolbar because there is no block selected ","warn")}toggleToolbox(e){-1!==this.Editor.BlockManager.currentBlockIndex?e??!this.Editor.Toolbar.toolbox.opened?(this.Editor.Toolbar.moveAndOpen(),this.Editor.Toolbar.toolbox.open()):this.Editor.Toolbar.toolbox.close():b("Could't toggle the Toolbox because there is no block selected ","warn")}},TooltipAPI:class extends X{constructor({config:e,eventsDispatcher:t}){super({config:e,eventsDispatcher:t})}get methods(){return{show:(e,t,o)=>this.show(e,t,o),hide:()=>this.hide(),onHover:(e,t,o)=>this.onHover(e,t,o)}}show(e,t,o){!function(e,t,o){xe(),null==we||we.show(e,t,o)}(e,t,o)}hide(){Ee()}onHover(e,t,o){Ce(e,t,o)}},UiAPI:class extends X{get methods(){return{nodes:this.editorNodes}}get editorNodes(){return{wrapper:this.Editor.UI.nodes.wrapper,redactor:this.Editor.UI.nodes.redactor}}},BlockSettings:class extends X{constructor(){super(...arguments),this.opened=!1,this.selection=new V,this.popover=null,this.close=()=>{this.opened&&(this.opened=!1,V.isAtEditor||this.selection.restore(),this.selection.clearSaved(),!this.Editor.CrossBlockSelection.isCrossBlockSelectionStarted&&this.Editor.BlockManager.currentBlock&&this.Editor.BlockSelection.unselectBlock(this.Editor.BlockManager.currentBlock),this.eventsDispatcher.emit(this.events.closed),this.popover&&(this.popover.off(ze.Closed,this.onPopoverClose),this.popover.destroy(),this.popover.getElement().remove(),this.popover=null))},this.onPopoverClose=()=>{this.close()}}get events(){return{opened:"block-settings-opened",closed:"block-settings-closed"}}get CSS(){return{settings:"ce-settings"}}get flipper(){var e;if(null!==this.popover)return"flipper"in this.popover?null==(e=this.popover)?void 0:e.flipper:void 0}make(){this.nodes.wrapper=F.make("div",[this.CSS.settings]),this.eventsDispatcher.on(ee,this.close)}destroy(){this.removeAllNodes(),this.listeners.destroy(),this.eventsDispatcher.off(ee,this.close)}async open(e=this.Editor.BlockManager.currentBlock){var t;this.opened=!0,this.selection.save(),this.Editor.BlockSelection.selectBlock(e),this.Editor.BlockSelection.clearCache();const{toolTunes:o,commonTunes:n}=e.getTunes();this.eventsDispatcher.emit(this.events.opened);const i=D()?ut:nt;this.popover=new i({searchable:!0,items:await this.getTunesItems(e,n,o),scopeElement:this.Editor.API.methods.ui.nodes.redactor,messages:{nothingFound:W.ui(Se.ui.popover,"Nothing found"),search:W.ui(Se.ui.popover,"Filter")}}),this.popover.on(ze.Closed,this.onPopoverClose),null==(t=this.nodes.wrapper)||t.append(this.popover.getElement()),this.popover.show()}getElement(){return this.nodes.wrapper}async getTunesItems(e,t,o){const n=[];void 0!==o&&o.length>0&&(n.push(...o),n.push({type:ae.Separator}));const i=Array.from(this.Editor.Tools.blockTools.values()),r=(await ie(e,i)).reduce(((t,o)=>(o.toolbox.forEach((n=>{t.push({icon:n.icon,title:W.t(Se.toolNames,n.title),name:o.name,closeOnActivate:!0,onActivate:async()=>{const{BlockManager:t,Caret:i,Toolbar:r}=this.Editor,s=await t.convert(e,o.name,n.data);r.close(),i.setToBlock(s,i.positions.END)}})})),t)),[]);return r.length>0&&(n.push({icon:Ie,name:"convert-to",title:W.ui(Se.ui.popover,"Convert to"),children:{searchable:!0,items:r}}),n.push({type:ae.Separator})),n.push(...t),n.map((e=>this.resolveTuneAliases(e)))}resolveTuneAliases(e){if(e.type===ae.Separator||e.type===ae.Html)return e;const t=function(e,t){const o={};return Object.keys(e).forEach((n=>{const i=t[n];void 0!==i?o[i]=e[n]:o[n]=e[n]})),o}(e,{label:"title"});return e.confirmation&&(t.confirmation=this.resolveTuneAliases(e.confirmation)),t}},Toolbar:class extends X{constructor({config:e,eventsDispatcher:t}){super({config:e,eventsDispatcher:t}),this.toolboxInstance=null}get CSS(){return{toolbar:"ce-toolbar",content:"ce-toolbar__content",actions:"ce-toolbar__actions",actionsOpened:"ce-toolbar__actions--opened",toolbarOpened:"ce-toolbar--opened",openedToolboxHolderModifier:"codex-editor--toolbox-opened",plusButton:"ce-toolbar__plus",plusButtonShortcut:"ce-toolbar__plus-shortcut",settingsToggler:"ce-toolbar__settings-btn",settingsTogglerHidden:"ce-toolbar__settings-btn--hidden"}}get opened(){return this.nodes.wrapper.classList.contains(this.CSS.toolbarOpened)}get toolbox(){var e;return{opened:null==(e=this.toolboxInstance)?void 0:e.opened,close:()=>{var e;null==(e=this.toolboxInstance)||e.close()},open:()=>{null!==this.toolboxInstance?(this.Editor.BlockManager.currentBlock=this.hoveredBlock,this.toolboxInstance.open()):m("toolbox.open() called before initialization is finished","warn")},toggle:()=>{null!==this.toolboxInstance?this.toolboxInstance.toggle():m("toolbox.toggle() called before initialization is finished","warn")},hasFocus:()=>{var e;return null==(e=this.toolboxInstance)?void 0:e.hasFocus()}}}get blockActions(){return{hide:()=>{this.nodes.actions.classList.remove(this.CSS.actionsOpened)},show:()=>{this.nodes.actions.classList.add(this.CSS.actionsOpened)}}}get blockTunesToggler(){return{hide:()=>this.nodes.settingsToggler.classList.add(this.CSS.settingsTogglerHidden),show:()=>this.nodes.settingsToggler.classList.remove(this.CSS.settingsTogglerHidden)}}toggleReadOnly(e){e?(this.destroy(),this.Editor.BlockSettings.destroy(),this.disableModuleBindings()):window.requestIdleCallback((()=>{this.drawUI(),this.enableModuleBindings()}),{timeout:2e3})}moveAndOpen(e=this.Editor.BlockManager.currentBlock){if(null===this.toolboxInstance)return void m("Can't open Toolbar since Editor initialization is not finished yet","warn");if(this.toolboxInstance.opened&&this.toolboxInstance.close(),this.Editor.BlockSettings.opened&&this.Editor.BlockSettings.close(),!e)return;this.hoveredBlock=e;const t=e.holder,{isMobile:o}=this.Editor.UI;let n;const i=e.firstInput,r=t.getBoundingClientRect(),s=void 0!==i?i.getBoundingClientRect():null,a=null!==s?s.top-r.top:null,l=null!==a?a>20:void 0;if(o)n=t.offsetTop+t.offsetHeight;else if(void 0===i||l){const o=parseInt(window.getComputedStyle(e.pluginsContent).paddingTop);n=t.offsetTop+o}else{const e=function(e){const t=window.getComputedStyle(e),o=parseFloat(t.fontSize),n=parseFloat(t.lineHeight)||1.2*o,i=parseFloat(t.paddingTop),r=parseFloat(t.borderTopWidth);return parseFloat(t.marginTop)+r+i+(n-o)/2+.8*o}(i),o=parseInt(window.getComputedStyle(this.nodes.plusButton).height,10),r=8;n=t.offsetTop+e-o+r+a}this.nodes.wrapper.style.top=`${Math.floor(n)}px`,1===this.Editor.BlockManager.blocks.length&&e.isEmpty?this.blockTunesToggler.hide():this.blockTunesToggler.show(),this.open()}close(){var e,t;this.Editor.ReadOnly.isEnabled||(null==(e=this.nodes.wrapper)||e.classList.remove(this.CSS.toolbarOpened),this.blockActions.hide(),null==(t=this.toolboxInstance)||t.close(),this.Editor.BlockSettings.close(),this.reset())}reset(){this.nodes.wrapper.style.top="unset"}open(e=!0){this.nodes.wrapper.classList.add(this.CSS.toolbarOpened),e?this.blockActions.show():this.blockActions.hide()}async make(){this.nodes.wrapper=F.make("div",this.CSS.toolbar),["content","actions"].forEach((e=>{this.nodes[e]=F.make("div",this.CSS[e])})),F.append(this.nodes.wrapper,this.nodes.content),F.append(this.nodes.content,this.nodes.actions),this.nodes.plusButton=F.make("div",this.CSS.plusButton,{innerHTML:'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M12 7V12M12 17V12M17 12H12M12 12H7"/></svg>'}),F.append(this.nodes.actions,this.nodes.plusButton),this.readOnlyMutableListeners.on(this.nodes.plusButton,"click",(()=>{Ee(!0),this.plusButtonClicked()}),!1);const e=F.make("div");e.appendChild(document.createTextNode(W.ui(Se.ui.toolbar.toolbox,"Add"))),e.appendChild(F.make("div",this.CSS.plusButtonShortcut,{textContent:"/"})),Ce(this.nodes.plusButton,e,{hidingDelay:400}),this.nodes.settingsToggler=F.make("span",this.CSS.settingsToggler,{innerHTML:'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2.6" d="M9.40999 7.29999H9.4"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2.6" d="M14.6 7.29999H14.59"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2.6" d="M9.30999 12H9.3"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2.6" d="M14.6 12H14.59"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2.6" d="M9.40999 16.7H9.4"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2.6" d="M14.6 16.7H14.59"/></svg>'}),F.append(this.nodes.actions,this.nodes.settingsToggler);const t=F.make("div"),o=F.text(W.ui(Se.ui.blockTunes.toggler,"Click to tune")),n=await async function(e,t){const n=navigator.keyboard;if(!n)return t;try{return(await n.getLayoutMap()).get(e)||t}catch(o){return t}}("Slash","/");t.appendChild(o),t.appendChild(F.make("div",this.CSS.plusButtonShortcut,{textContent:L(`CMD + ${n}`)})),Ce(this.nodes.settingsToggler,t,{hidingDelay:400}),F.append(this.nodes.actions,this.makeToolbox()),F.append(this.nodes.actions,this.Editor.BlockSettings.getElement()),F.append(this.Editor.UI.nodes.wrapper,this.nodes.wrapper)}makeToolbox(){return this.toolboxInstance=new kt({api:this.Editor.API.methods,tools:this.Editor.Tools.blockTools,i18nLabels:{filter:W.ui(Se.ui.popover,"Filter"),nothingFound:W.ui(Se.ui.popover,"Nothing found")}}),this.toolboxInstance.on(vt.Opened,(()=>{this.Editor.UI.nodes.wrapper.classList.add(this.CSS.openedToolboxHolderModifier)})),this.toolboxInstance.on(vt.Closed,(()=>{this.Editor.UI.nodes.wrapper.classList.remove(this.CSS.openedToolboxHolderModifier)})),this.toolboxInstance.on(vt.BlockAdded,(({block:e})=>{const{BlockManager:t,Caret:o}=this.Editor,n=t.getBlockById(e.id);0===n.inputs.length&&(n===t.lastBlock?(t.insertAtEnd(),o.setToBlock(t.lastBlock)):o.setToBlock(t.nextBlock))})),this.toolboxInstance.getElement()}plusButtonClicked(){var e;this.Editor.BlockManager.currentBlock=this.hoveredBlock,null==(e=this.toolboxInstance)||e.toggle()}enableModuleBindings(){this.readOnlyMutableListeners.on(this.nodes.settingsToggler,"mousedown",(e=>{var t;e.stopPropagation(),this.settingsTogglerClicked(),null!=(t=this.toolboxInstance)&&t.opened&&this.toolboxInstance.close(),Ee(!0)}),!0),D()||this.eventsDispatcher.on(wt,(e=>{var t;this.Editor.BlockSettings.opened||null!=(t=this.toolboxInstance)&&t.opened||this.moveAndOpen(e.block)}))}disableModuleBindings(){this.readOnlyMutableListeners.clearAll()}settingsTogglerClicked(){this.Editor.BlockManager.currentBlock=this.hoveredBlock,this.Editor.BlockSettings.opened?this.Editor.BlockSettings.close():this.Editor.BlockSettings.open(this.hoveredBlock)}drawUI(){this.Editor.BlockSettings.make(),this.make()}destroy(){this.removeAllNodes(),this.toolboxInstance&&this.toolboxInstance.destroy()}},InlineToolbar:class extends X{constructor({config:e,eventsDispatcher:t}){super({config:e,eventsDispatcher:t}),this.CSS={inlineToolbar:"ce-inline-toolbar"},this.opened=!1,this.popover=null,this.toolbarVerticalMargin=D()?20:6,this.tools=new Map,window.requestIdleCallback((()=>{this.make()}),{timeout:2e3})}async tryToShow(e=!1){e&&this.close(),this.allowedToShow()&&(await this.open(),this.Editor.Toolbar.close())}close(){var e,t;if(this.opened){for(const[e,t]of this.tools){const o=this.getToolShortcut(e.name);void 0!==o&&ft.remove(this.Editor.UI.nodes.redactor,o),y(t.clear)&&t.clear()}this.tools=new Map,this.reset(),this.opened=!1,null==(e=this.popover)||e.hide(),null==(t=this.popover)||t.destroy(),this.popover=null}}containsNode(e){return void 0!==this.nodes.wrapper&&this.nodes.wrapper.contains(e)}destroy(){var e;this.removeAllNodes(),null==(e=this.popover)||e.destroy(),this.popover=null}make(){this.nodes.wrapper=F.make("div",[this.CSS.inlineToolbar,...this.isRtl?[this.Editor.UI.CSS.editorRtlFix]:[]]),F.append(this.Editor.UI.nodes.wrapper,this.nodes.wrapper)}async open(){var e;if(this.opened)return;this.opened=!0,null!==this.popover&&this.popover.destroy(),this.createToolsInstances();const t=await this.getPopoverItems();this.popover=new it({items:t,scopeElement:this.Editor.API.methods.ui.nodes.redactor,messages:{nothingFound:W.ui(Se.ui.popover,"Nothing found"),search:W.ui(Se.ui.popover,"Filter")}}),this.move(this.popover.size.width),null==(e=this.nodes.wrapper)||e.append(this.popover.getElement()),this.popover.show()}move(e){const t=V.rect,o=this.Editor.UI.nodes.wrapper.getBoundingClientRect(),n={x:t.x-o.x,y:t.y+t.height-o.top+this.toolbarVerticalMargin};n.x+e+o.x>this.Editor.UI.contentRect.right&&(n.x=this.Editor.UI.contentRect.right-e-o.x),this.nodes.wrapper.style.left=Math.floor(n.x)+"px",this.nodes.wrapper.style.top=Math.floor(n.y)+"px"}reset(){this.nodes.wrapper.style.left="0",this.nodes.wrapper.style.top="0"}allowedToShow(){const e=V.get(),t=V.text;if(!e||!e.anchorNode||e.isCollapsed||t.length<1)return!1;const o=F.isElement(e.anchorNode)?e.anchorNode:e.anchorNode.parentElement;if(null===o||null!==e&&["IMG","INPUT"].includes(o.tagName))return!1;const n=this.Editor.BlockManager.getBlock(e.anchorNode);return!(!n||!1===this.getTools().some((e=>n.tool.inlineTools.has(e.name))))&&null!==o.closest("[contenteditable]")}getTools(){const e=this.Editor.BlockManager.currentBlock;return e?Array.from(e.tool.inlineTools.values()).filter((e=>!(this.Editor.ReadOnly.isEnabled&&!0!==e.isReadOnlySupported))):[]}createToolsInstances(){this.tools=new Map,this.getTools().forEach((e=>{const t=e.create();this.tools.set(e,t)}))}async getPopoverItems(){const e=[];let t=0;for(const[o,n]of this.tools){const i=await n.render(),r=this.getToolShortcut(o.name);if(void 0!==r)try{this.enableShortcuts(o.name,r)}catch{}const s=void 0!==r?L(r):void 0,a=W.t(Se.toolNames,o.title||M(o.name));[i].flat().forEach((i=>{var r,l;const c={name:o.name,onActivate:()=>{this.toolClicked(n)},hint:{title:a,description:s}};if(F.isElement(i)){const t={...c,element:i,type:ae.Html};if(y(n.renderActions)){const e=n.renderActions();t.children={isOpen:null==(r=n.checkState)?void 0:r.call(n,V.get()),isFlippable:!1,items:[{type:ae.Html,element:e}]}}else null==(l=n.checkState)||l.call(n,V.get());e.push(t)}else if(i.type===ae.Html)e.push({...c,...i,type:ae.Html});else if(i.type===ae.Separator)e.push({type:ae.Separator});else{const o={...c,...i,type:ae.Default};"children"in o&&0!==t&&e.push({type:ae.Separator}),e.push(o),"children"in o&&t<this.tools.size-1&&e.push({type:ae.Separator})}})),t++}return e}getToolShortcut(e){const{Tools:t}=this.Editor,o=t.inlineTools.get(e),n=t.internal.inlineTools;return Array.from(n.keys()).includes(e)?this.inlineTools[e][Ct.Shortcut]:null==o?void 0:o.shortcut}enableShortcuts(e,t){ft.add({name:t,handler:t=>{var o;const{currentBlock:n}=this.Editor.BlockManager;n&&n.tool.enabledInlineTools&&(t.preventDefault(),null==(o=this.popover)||o.activateItemByName(e))},on:document})}toolClicked(e){var t;const o=V.range;null==(t=e.surround)||t.call(e,o),this.checkToolsState()}checkToolsState(){var e;null==(e=this.tools)||e.forEach((e=>{var t;null==(t=e.checkState)||t.call(e,V.get())}))}get inlineTools(){const e={};return Array.from(this.Editor.Tools.inlineTools.entries()).forEach((([t,o])=>{e[t]=o.create()})),e}},BlockEvents:class extends X{keydown(e){switch(this.beforeKeydownProcessing(e),e.keyCode){case r:this.backspace(e);break;case p:this.delete(e);break;case a:this.enter(e);break;case u:case h:this.arrowRightAndDown(e);break;case d:case c:this.arrowLeftAndUp(e);break;case s:this.tabPressed(e)}"/"===e.key&&!e.ctrlKey&&!e.metaKey&&this.slashPressed(e),"Slash"===e.code&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),this.commandSlashPressed())}beforeKeydownProcessing(e){this.needToolbarClosing(e)&&S(e.keyCode)&&(this.Editor.Toolbar.close(),e.ctrlKey||e.metaKey||e.altKey||e.shiftKey||this.Editor.BlockSelection.clearSelection(e))}keyup(e){e.shiftKey||this.Editor.UI.checkEmptiness()}dragOver(e){this.Editor.BlockManager.getBlockByChildNode(e.target).dropTarget=!0}dragLeave(e){this.Editor.BlockManager.getBlockByChildNode(e.target).dropTarget=!1}handleCommandC(e){const{BlockSelection:t}=this.Editor;t.anyBlockSelected&&t.copySelectedBlocks(e)}handleCommandX(e){const{BlockSelection:t,BlockManager:o,Caret:n}=this.Editor;t.anyBlockSelected&&t.copySelectedBlocks(e).then((()=>{const i=o.removeSelectedBlocks(),r=o.insertDefaultBlockAtIndex(i,!0);n.setToBlock(r,n.positions.START),t.clearSelection(e)}))}tabPressed(e){const{InlineToolbar:t,Caret:o}=this.Editor;t.opened||(e.shiftKey?o.navigatePrevious(!0):o.navigateNext(!0))&&e.preventDefault()}commandSlashPressed(){this.Editor.BlockSelection.selectedBlocks.length>1||this.activateBlockSettings()}slashPressed(e){!this.Editor.UI.nodes.wrapper.contains(e.target)||!this.Editor.BlockManager.currentBlock.isEmpty||(e.preventDefault(),this.Editor.Caret.insertContentAtCaretPosition("/"),this.activateToolbox())}enter(e){const{BlockManager:t,UI:o}=this.Editor,n=t.currentBlock;if(void 0===n||n.tool.isLineBreaksEnabled||o.someToolbarOpened&&o.someFlipperButtonFocused||e.shiftKey&&!R)return;let i=n;void 0!==n.currentInput&&Mt(n.currentInput)&&!n.hasMedia?this.Editor.BlockManager.insertDefaultBlockAtIndex(this.Editor.BlockManager.currentBlockIndex):i=n.currentInput&&Pt(n.currentInput)?this.Editor.BlockManager.insertDefaultBlockAtIndex(this.Editor.BlockManager.currentBlockIndex+1):this.Editor.BlockManager.split(),this.Editor.Caret.setToBlock(i),this.Editor.Toolbar.moveAndOpen(i),e.preventDefault()}backspace(e){const{BlockManager:t,Caret:o}=this.Editor,{currentBlock:n,previousBlock:i}=t;if(void 0!==n&&V.isCollapsed&&n.currentInput&&Mt(n.currentInput))if(e.preventDefault(),this.Editor.Toolbar.close(),n.currentInput===n.firstInput){if(null!==i)if(i.isEmpty)t.removeBlock(i);else if(n.isEmpty){t.removeBlock(n);const e=t.currentBlock;o.setToBlock(e,o.positions.END)}else re(i,n)?this.mergeBlocks(i,n):o.setToBlock(i,o.positions.END)}else o.navigatePrevious()}delete(e){const{BlockManager:t,Caret:o}=this.Editor,{currentBlock:n,nextBlock:i}=t;if(V.isCollapsed&&Pt(n.currentInput))if(e.preventDefault(),this.Editor.Toolbar.close(),n.currentInput===n.lastInput){if(null!==i){if(!i.isEmpty)return n.isEmpty?(t.removeBlock(n),void o.setToBlock(i,o.positions.START)):void(re(n,i)?this.mergeBlocks(n,i):o.setToBlock(i,o.positions.START));t.removeBlock(i)}}else o.navigateNext()}mergeBlocks(e,t){const{BlockManager:o,Toolbar:n}=this.Editor;void 0!==e.lastInput&&(Lt.focus(e.lastInput,!1),o.mergeBlocks(e,t).then((()=>{n.close()})))}arrowRightAndDown(e){const t=Oe.usedKeys.includes(e.keyCode)&&(!e.shiftKey||e.keyCode===s);if(this.Editor.UI.someToolbarOpened&&t)return;this.Editor.Toolbar.close();const{currentBlock:o}=this.Editor.BlockManager,n=(void 0!==(null==o?void 0:o.currentInput)?Pt(o.currentInput):void 0)||this.Editor.BlockSelection.anyBlockSelected;e.shiftKey&&e.keyCode===u&&n?this.Editor.CrossBlockSelection.toggleBlockSelectedState():(e.keyCode===u||e.keyCode===h&&!this.isRtl?this.Editor.Caret.navigateNext():this.Editor.Caret.navigatePrevious())?e.preventDefault():(O((()=>{this.Editor.BlockManager.currentBlock&&this.Editor.BlockManager.currentBlock.updateCurrentInput()}),20)(),this.Editor.BlockSelection.clearSelection(e))}arrowLeftAndUp(e){if(this.Editor.UI.someToolbarOpened){if(Oe.usedKeys.includes(e.keyCode)&&(!e.shiftKey||e.keyCode===s))return;this.Editor.UI.closeAllToolbars()}this.Editor.Toolbar.close();const{currentBlock:t}=this.Editor.BlockManager,o=(void 0!==(null==t?void 0:t.currentInput)?Mt(t.currentInput):void 0)||this.Editor.BlockSelection.anyBlockSelected;e.shiftKey&&e.keyCode===d&&o?this.Editor.CrossBlockSelection.toggleBlockSelectedState(!1):(e.keyCode===d||e.keyCode===c&&!this.isRtl?this.Editor.Caret.navigatePrevious():this.Editor.Caret.navigateNext())?e.preventDefault():(O((()=>{this.Editor.BlockManager.currentBlock&&this.Editor.BlockManager.currentBlock.updateCurrentInput()}),20)(),this.Editor.BlockSelection.clearSelection(e))}needToolbarClosing(e){const t=e.keyCode===a&&this.Editor.Toolbar.toolbox.opened,o=e.keyCode===a&&this.Editor.BlockSettings.opened,n=e.keyCode===a&&this.Editor.InlineToolbar.opened,i=e.keyCode===s;return!(e.shiftKey||i||t||o||n)}activateToolbox(){this.Editor.Toolbar.opened||this.Editor.Toolbar.moveAndOpen(),this.Editor.Toolbar.toolbox.open()}activateBlockSettings(){this.Editor.Toolbar.opened||this.Editor.Toolbar.moveAndOpen(),this.Editor.BlockSettings.opened||this.Editor.BlockSettings.open()}},BlockManager:class extends X{constructor(){super(...arguments),this._currentBlockIndex=-1,this._blocks=null}get currentBlockIndex(){return this._currentBlockIndex}set currentBlockIndex(e){this._currentBlockIndex=e}get firstBlock(){return this._blocks[0]}get lastBlock(){return this._blocks[this._blocks.length-1]}get currentBlock(){return this._blocks[this.currentBlockIndex]}set currentBlock(e){this.currentBlockIndex=this.getBlockIndex(e)}get nextBlock(){return this.currentBlockIndex===this._blocks.length-1?null:this._blocks[this.currentBlockIndex+1]}get nextContentfulBlock(){return this.blocks.slice(this.currentBlockIndex+1).find((e=>!!e.inputs.length))}get previousContentfulBlock(){return this.blocks.slice(0,this.currentBlockIndex).reverse().find((e=>!!e.inputs.length))}get previousBlock(){return 0===this.currentBlockIndex?null:this._blocks[this.currentBlockIndex-1]}get blocks(){return this._blocks.array}get isEditorEmpty(){return this.blocks.every((e=>e.isEmpty))}prepare(){const e=new Fn(this.Editor.UI.nodes.redactor);this._blocks=new Proxy(e,{set:Fn.set,get:Fn.get}),this.listeners.on(document,"copy",(e=>this.Editor.BlockEvents.handleCommandC(e)))}toggleReadOnly(e){e?this.disableModuleBindings():this.enableModuleBindings()}composeBlock({tool:e,data:t={},id:o,tunes:n={}}){const i=this.Editor.ReadOnly.isEnabled,r=this.Editor.Tools.blockTools.get(e),s=new ce({id:o,data:t,tool:r,api:this.Editor.API,readOnly:i,tunesData:n},this.eventsDispatcher);return i||window.requestIdleCallback((()=>{this.bindBlockEvents(s)}),{timeout:2e3}),s}insert({id:e,tool:t=this.config.defaultBlock,data:o={},index:n,needToFocus:i=!0,replace:r=!1,tunes:s={}}={}){let a=n;void 0===a&&(a=this.currentBlockIndex+(r?0:1));const l=this.composeBlock({id:e,tool:t,data:o,tunes:s});return r&&this.blockDidMutated(Hn,this.getBlockByIndex(a),{index:a}),this._blocks.insert(a,l,r),this.blockDidMutated(Un,l,{index:a}),i?this.currentBlockIndex=a:a<=this.currentBlockIndex&&this.currentBlockIndex++,l}insertMany(e,t=0){this._blocks.insertMany(e,t)}async update(e,t,o){if(!t&&!o)return e;const n=await e.data,i=this.composeBlock({id:e.id,tool:e.name,data:Object.assign({},n,t??{}),tunes:o??e.tunes}),r=this.getBlockIndex(e);return this._blocks.replace(r,i),this.blockDidMutated(zn,i,{index:r}),i}replace(e,t,o){const n=this.getBlockIndex(e);return this.insert({tool:t,data:o,index:n,replace:!0})}paste(e,t,o=!1){const n=this.insert({tool:e,replace:o});try{window.requestIdleCallback((()=>{n.call(le.ON_PASTE,t)}))}catch(i){m(`${e}: onPaste callback call is failed`,"error",i)}return n}insertDefaultBlockAtIndex(e,t=!1){const o=this.composeBlock({tool:this.config.defaultBlock});return this._blocks[e]=o,this.blockDidMutated(Un,o,{index:e}),t?this.currentBlockIndex=e:e<=this.currentBlockIndex&&this.currentBlockIndex++,o}insertAtEnd(){return this.currentBlockIndex=this.blocks.length-1,this.insert()}async mergeBlocks(e,t){let o;if(e.name===t.name&&e.mergeable){const n=await t.data;if(C(n))return;const[i]=ge([n],e.tool.sanitizeConfig);o=i}else if(e.mergeable&&oe(t,"export")&&oe(e,"import")){o=se(me(await t.exportDataAsString(),e.tool.sanitizeConfig),e.tool.conversionConfig)}void 0!==o&&(await e.mergeWith(o),this.removeBlock(t),this.currentBlockIndex=this._blocks.indexOf(e))}removeBlock(e,t=!0){return new Promise((o=>{const n=this._blocks.indexOf(e);if(!this.validateIndex(n))throw new Error("Can't find a Block to remove");this._blocks.remove(n),e.destroy(),this.blockDidMutated(Hn,e,{index:n}),this.currentBlockIndex>=n&&this.currentBlockIndex--,this.blocks.length?0===n&&(this.currentBlockIndex=0):(this.unsetCurrentBlock(),t&&this.insert()),o()}))}removeSelectedBlocks(){let e;for(let t=this.blocks.length-1;t>=0;t--)this.blocks[t].selected&&(this.removeBlock(this.blocks[t]),e=t);return e}removeAllBlocks(){for(let e=this.blocks.length-1;e>=0;e--)this._blocks.remove(e);this.unsetCurrentBlock(),this.insert(),this.currentBlock.firstInput.focus()}split(){const e=this.Editor.Caret.extractFragmentFromCaretPosition(),t=F.make("div");t.appendChild(e);const o={text:F.isEmpty(t)?"":t.innerHTML};return this.insert({data:o})}getBlockByIndex(e){return-1===e&&(e=this._blocks.length-1),this._blocks[e]}getBlockIndex(e){return this._blocks.indexOf(e)}getBlockById(e){return this._blocks.array.find((t=>t.id===e))}getBlock(e){F.isElement(e)||(e=e.parentNode);const t=this._blocks.nodes,o=e.closest(`.${ce.CSS.wrapper}`),n=t.indexOf(o);if(n>=0)return this._blocks[n]}setCurrentBlockByChildNode(e){F.isElement(e)||(e=e.parentNode);const t=e.closest(`.${ce.CSS.wrapper}`);if(!t)return;const o=t.closest(`.${this.Editor.UI.CSS.editorWrapper}`);return null!=o&&o.isEqualNode(this.Editor.UI.nodes.wrapper)?(this.currentBlockIndex=this._blocks.nodes.indexOf(t),this.currentBlock.updateCurrentInput(),this.currentBlock):void 0}getBlockByChildNode(e){if(!(e&&e instanceof Node))return;F.isElement(e)||(e=e.parentNode);const t=e.closest(`.${ce.CSS.wrapper}`);return this.blocks.find((e=>e.holder===t))}swap(e,t){this._blocks.swap(e,t),this.currentBlockIndex=t}move(e,t=this.currentBlockIndex){isNaN(e)||isNaN(t)?m("Warning during 'move' call: incorrect indices provided.","warn"):this.validateIndex(e)&&this.validateIndex(t)?(this._blocks.move(e,t),this.currentBlockIndex=e,this.blockDidMutated("block-moved",this.currentBlock,{fromIndex:t,toIndex:e})):m("Warning during 'move' call: indices cannot be lower than 0 or greater than the amount of blocks.","warn")}async convert(e,t,o){if(!(await e.save()))throw new Error("Could not convert Block. Failed to extract original Block data.");const n=this.Editor.Tools.blockTools.get(t);if(!n)throw new Error(`Could not convert Block. Tool «${t}» not found.`);let i=se(me(await e.exportDataAsString(),n.sanitizeConfig),n.conversionConfig,n.settings);return o&&(i=Object.assign(i,o)),this.replace(e,n.name,i)}unsetCurrentBlock(){this.currentBlockIndex=-1}async clear(e=!1){const t=new Wn;[...this.blocks].forEach((e=>{t.add((async()=>{await this.removeBlock(e,!1)}))})),await t.completed,this.unsetCurrentBlock(),e&&this.insert(),this.Editor.UI.checkEmptiness()}async destroy(){await Promise.all(this.blocks.map((e=>e.destroy())))}bindBlockEvents(e){const{BlockEvents:t}=this.Editor;this.readOnlyMutableListeners.on(e.holder,"keydown",(e=>{t.keydown(e)})),this.readOnlyMutableListeners.on(e.holder,"keyup",(e=>{t.keyup(e)})),this.readOnlyMutableListeners.on(e.holder,"dragover",(e=>{t.dragOver(e)})),this.readOnlyMutableListeners.on(e.holder,"dragleave",(e=>{t.dragLeave(e)})),e.on("didMutated",(e=>this.blockDidMutated(zn,e,{index:this.getBlockIndex(e)})))}disableModuleBindings(){this.readOnlyMutableListeners.clearAll()}enableModuleBindings(){this.readOnlyMutableListeners.on(document,"cut",(e=>this.Editor.BlockEvents.handleCommandX(e))),this.blocks.forEach((e=>{this.bindBlockEvents(e)}))}validateIndex(e){return!(e<0||e>=this._blocks.length)}blockDidMutated(e,t,o){const n=new CustomEvent(e,{detail:{target:new K(t),...o}});return this.eventsDispatcher.emit(Z,{event:n}),t}},BlockSelection:class extends X{constructor(){super(...arguments),this.anyBlockSelectedCache=null,this.needToSelectAll=!1,this.nativeInputSelected=!1,this.readyToBlockSelection=!1}get sanitizerConfig(){return{p:{},h1:{},h2:{},h3:{},h4:{},h5:{},h6:{},ol:{},ul:{},li:{},br:!0,img:{src:!0,width:!0,height:!0},a:{href:!0},b:{},i:{},u:{}}}get allBlocksSelected(){const{BlockManager:e}=this.Editor;return e.blocks.every((e=>!0===e.selected))}set allBlocksSelected(e){const{BlockManager:t}=this.Editor;t.blocks.forEach((t=>{t.selected=e})),this.clearCache()}get anyBlockSelected(){const{BlockManager:e}=this.Editor;return null===this.anyBlockSelectedCache&&(this.anyBlockSelectedCache=e.blocks.some((e=>!0===e.selected))),this.anyBlockSelectedCache}get selectedBlocks(){return this.Editor.BlockManager.blocks.filter((e=>e.selected))}prepare(){this.selection=new V,ft.add({name:"CMD+A",handler:e=>{const{BlockManager:t,ReadOnly:o}=this.Editor;if(o.isEnabled)return e.preventDefault(),void this.selectAllBlocks();t.currentBlock&&this.handleCommandA(e)},on:this.Editor.UI.nodes.redactor})}toggleReadOnly(){V.get().removeAllRanges(),this.allBlocksSelected=!1}unSelectBlockByIndex(e){const{BlockManager:t}=this.Editor;let o;o=isNaN(e)?t.currentBlock:t.getBlockByIndex(e),o.selected=!1,this.clearCache()}clearSelection(e,t=!1){const{BlockManager:o,Caret:n,RectangleSelection:i}=this.Editor;this.needToSelectAll=!1,this.nativeInputSelected=!1,this.readyToBlockSelection=!1;const r=e&&e instanceof KeyboardEvent,s=r&&S(e.keyCode);if(this.anyBlockSelected&&r&&s&&!V.isSelectionExists){const t=o.removeSelectedBlocks();o.insertDefaultBlockAtIndex(t,!0),n.setToBlock(o.currentBlock),O((()=>{const t=e.key;n.insertContentAtCaretPosition(t.length>1?"":t)}),20)()}this.Editor.CrossBlockSelection.clear(e),this.anyBlockSelected&&!i.isRectActivated()?(t&&this.selection.restore(),this.allBlocksSelected=!1):this.Editor.RectangleSelection.clearSelection()}copySelectedBlocks(e){e.preventDefault();const t=F.make("div");this.selectedBlocks.forEach((e=>{const o=me(e.holder.innerHTML,this.sanitizerConfig),n=F.make("p");n.innerHTML=o,t.appendChild(n)}));const o=Array.from(t.childNodes).map((e=>e.textContent)).join("\n\n"),n=t.innerHTML;return e.clipboardData.setData("text/plain",o),e.clipboardData.setData("text/html",n),Promise.all(this.selectedBlocks.map((e=>e.save()))).then((t=>{try{e.clipboardData.setData(this.Editor.Paste.MIME_TYPE,JSON.stringify(t))}catch{}}))}selectBlockByIndex(e){const{BlockManager:t}=this.Editor,o=t.getBlockByIndex(e);void 0!==o&&this.selectBlock(o)}selectBlock(e){this.selection.save(),V.get().removeAllRanges(),e.selected=!0,this.clearCache(),this.Editor.InlineToolbar.close()}unselectBlock(e){e.selected=!1,this.clearCache()}clearCache(){this.anyBlockSelectedCache=null}destroy(){ft.remove(this.Editor.UI.nodes.redactor,"CMD+A")}handleCommandA(e){if(this.Editor.RectangleSelection.clearSelection(),F.isNativeInput(e.target)&&!this.readyToBlockSelection)return void(this.readyToBlockSelection=!0);const t=this.Editor.BlockManager.getBlock(e.target),o=t.inputs;o.length>1&&!this.readyToBlockSelection?this.readyToBlockSelection=!0:1!==o.length||this.needToSelectAll?this.needToSelectAll?(e.preventDefault(),this.selectAllBlocks(),this.needToSelectAll=!1,this.readyToBlockSelection=!1):this.readyToBlockSelection&&(e.preventDefault(),this.selectBlock(t),this.needToSelectAll=!0):this.needToSelectAll=!0}selectAllBlocks(){this.selection.save(),V.get().removeAllRanges(),this.allBlocksSelected=!0,this.Editor.InlineToolbar.close()}},Caret:class e extends X{get positions(){return{START:"start",END:"end",DEFAULT:"default"}}static get CSS(){return{shadowCaret:"cdx-shadow-caret"}}setToBlock(e,t=this.positions.DEFAULT,o=0){var n;const{BlockManager:i,BlockSelection:r}=this.Editor;if(r.clearSelection(),!e.focusable)return null==(n=window.getSelection())||n.removeAllRanges(),r.selectBlock(e),void(i.currentBlock=e);let s;switch(t){case this.positions.START:s=e.firstInput;break;case this.positions.END:s=e.lastInput;break;default:s=e.currentInput}if(!s)return;let a,l=o;if(t===this.positions.START)a=F.getDeepestNode(s,!1),l=0;else if(t===this.positions.END)a=F.getDeepestNode(s,!0),l=F.getContentLength(a);else{const{node:e,offset:t}=F.getNodeByOffset(s,o);e?(a=e,l=t):(a=F.getDeepestNode(s,!1),l=0)}this.set(a,l),i.setCurrentBlockByChildNode(e.holder),i.currentBlock.currentInput=s}setToInput(e,t=this.positions.DEFAULT,o=0){const{currentBlock:n}=this.Editor.BlockManager,i=F.getDeepestNode(e);switch(t){case this.positions.START:this.set(i,0);break;case this.positions.END:this.set(i,F.getContentLength(i));break;default:o&&this.set(i,o)}n.currentInput=e}set(e,t=0){const{top:o,bottom:n}=V.setCursor(e,t),{innerHeight:i}=window;o<0?window.scrollBy(0,o-30):n>i&&window.scrollBy(0,n-i+30)}setToTheLastBlock(){const e=this.Editor.BlockManager.lastBlock;if(e)if(e.tool.isDefault&&e.isEmpty)this.setToBlock(e);else{const e=this.Editor.BlockManager.insertAtEnd();this.setToBlock(e)}}extractFragmentFromCaretPosition(){const e=V.get();if(e.rangeCount){const t=e.getRangeAt(0),o=this.Editor.BlockManager.currentBlock.currentInput;if(t.deleteContents(),o){if(F.isNativeInput(o)){const e=o,t=document.createDocumentFragment(),n=e.value.substring(0,e.selectionStart),i=e.value.substring(e.selectionStart);return t.textContent=i,e.value=n,t}{const e=t.cloneRange();return e.selectNodeContents(o),e.setStart(t.endContainer,t.endOffset),e.extractContents()}}}}navigateNext(e=!1){const{BlockManager:t}=this.Editor,{currentBlock:o,nextBlock:n}=t;if(void 0===o)return!1;const{nextInput:i,currentInput:r}=o,s=void 0!==r?Pt(r):void 0;let a=n;const l=e||s||!o.focusable;if(i&&l)return this.setToInput(i,this.positions.START),!0;if(null===a){if(o.tool.isDefault||!l)return!1;a=t.insertAtEnd()}return!!l&&(this.setToBlock(a,this.positions.START),!0)}navigatePrevious(e=!1){const{currentBlock:t,previousBlock:o}=this.Editor.BlockManager;if(!t)return!1;const{previousInput:n,currentInput:i}=t,r=void 0!==i?Mt(i):void 0,s=e||r||!t.focusable;return n&&s?(this.setToInput(n,this.positions.END),!0):!(null===o||!s)&&(this.setToBlock(o,this.positions.END),!0)}createShadow(t){const o=document.createElement("span");o.classList.add(e.CSS.shadowCaret),t.insertAdjacentElement("beforeend",o)}restoreCaret(t){const o=t.querySelector(`.${e.CSS.shadowCaret}`);if(!o)return;(new V).expandToTag(o);const n=document.createRange();n.selectNode(o),n.extractContents()}insertContentAtCaretPosition(e){const t=document.createDocumentFragment(),o=document.createElement("div"),n=V.get(),i=V.range;o.innerHTML=e,Array.from(o.childNodes).forEach((e=>t.appendChild(e))),0===t.childNodes.length&&t.appendChild(new Text);const r=t.lastChild;i.deleteContents(),i.insertNode(t);const s=document.createRange(),a=r.nodeType===Node.TEXT_NODE?r:r.firstChild;null!==a&&null!==a.textContent&&s.setStart(a,a.textContent.length),n.removeAllRanges(),n.addRange(s)}},CrossBlockSelection:class extends X{constructor(){super(...arguments),this.onMouseUp=()=>{this.listeners.off(document,"mouseover",this.onMouseOver),this.listeners.off(document,"mouseup",this.onMouseUp)},this.onMouseOver=e=>{const{BlockManager:t,BlockSelection:o}=this.Editor;if(null===e.relatedTarget&&null===e.target)return;const n=t.getBlockByChildNode(e.relatedTarget)||this.lastSelectedBlock,i=t.getBlockByChildNode(e.target);if(n&&i&&i!==n){if(n===this.firstSelectedBlock)return V.get().removeAllRanges(),n.selected=!0,i.selected=!0,void o.clearCache();if(i===this.firstSelectedBlock)return n.selected=!1,i.selected=!1,void o.clearCache();this.Editor.InlineToolbar.close(),this.toggleBlocksSelectedState(n,i),this.lastSelectedBlock=i}}}async prepare(){this.listeners.on(document,"mousedown",(e=>{this.enableCrossBlockSelection(e)}))}watchSelection(e){if(e.button!==f)return;const{BlockManager:t}=this.Editor;this.firstSelectedBlock=t.getBlock(e.target),this.lastSelectedBlock=this.firstSelectedBlock,this.listeners.on(document,"mouseover",this.onMouseOver),this.listeners.on(document,"mouseup",this.onMouseUp)}get isCrossBlockSelectionStarted(){return!!this.firstSelectedBlock&&!!this.lastSelectedBlock&&this.firstSelectedBlock!==this.lastSelectedBlock}toggleBlockSelectedState(e=!0){const{BlockManager:t,BlockSelection:o}=this.Editor;this.lastSelectedBlock||(this.lastSelectedBlock=this.firstSelectedBlock=t.currentBlock),this.firstSelectedBlock===this.lastSelectedBlock&&(this.firstSelectedBlock.selected=!0,o.clearCache(),V.get().removeAllRanges());const n=t.blocks.indexOf(this.lastSelectedBlock)+(e?1:-1),i=t.blocks[n];i&&(this.lastSelectedBlock.selected!==i.selected?(i.selected=!0,o.clearCache()):(this.lastSelectedBlock.selected=!1,o.clearCache()),this.lastSelectedBlock=i,this.Editor.InlineToolbar.close(),i.holder.scrollIntoView({block:"nearest"}))}clear(e){const{BlockManager:t,BlockSelection:o,Caret:n}=this.Editor,i=t.blocks.indexOf(this.firstSelectedBlock),r=t.blocks.indexOf(this.lastSelectedBlock);if(o.anyBlockSelected&&i>-1&&r>-1&&e&&e instanceof KeyboardEvent)switch(e.keyCode){case u:case h:n.setToBlock(t.blocks[Math.max(i,r)],n.positions.END);break;case d:case c:n.setToBlock(t.blocks[Math.min(i,r)],n.positions.START);break;default:n.setToBlock(t.blocks[Math.max(i,r)],n.positions.END)}this.firstSelectedBlock=this.lastSelectedBlock=null}enableCrossBlockSelection(e){const{UI:t}=this.Editor;V.isCollapsed||this.Editor.BlockSelection.clearSelection(e),t.nodes.redactor.contains(e.target)?this.watchSelection(e):this.Editor.BlockSelection.clearSelection(e)}toggleBlocksSelectedState(e,t){const{BlockManager:o,BlockSelection:n}=this.Editor,i=o.blocks.indexOf(e),r=o.blocks.indexOf(t),s=e.selected!==t.selected;for(let a=Math.min(i,r);a<=Math.max(i,r);a++){const i=o.blocks[a];i!==this.firstSelectedBlock&&i!==(s?e:t)&&(o.blocks[a].selected=!o.blocks[a].selected,n.clearCache())}}},DragNDrop:class extends X{constructor(){super(...arguments),this.isStartedAtEditor=!1}toggleReadOnly(e){e?this.disableModuleBindings():this.enableModuleBindings()}enableModuleBindings(){const{UI:e}=this.Editor;this.readOnlyMutableListeners.on(e.nodes.holder,"drop",(async e=>{await this.processDrop(e)}),!0),this.readOnlyMutableListeners.on(e.nodes.holder,"dragstart",(()=>{this.processDragStart()})),this.readOnlyMutableListeners.on(e.nodes.holder,"dragover",(e=>{this.processDragOver(e)}),!0)}disableModuleBindings(){this.readOnlyMutableListeners.clearAll()}async processDrop(e){const{BlockManager:t,Paste:o,Caret:n}=this.Editor;e.preventDefault(),t.blocks.forEach((e=>{e.dropTarget=!1})),V.isAtEditor&&!V.isCollapsed&&this.isStartedAtEditor&&document.execCommand("delete"),this.isStartedAtEditor=!1;const i=t.setCurrentBlockByChildNode(e.target);if(i)this.Editor.Caret.setToBlock(i,n.positions.END);else{const e=t.setCurrentBlockByChildNode(t.lastBlock.holder);this.Editor.Caret.setToBlock(e,n.positions.END)}await o.processDataTransfer(e.dataTransfer,!0)}processDragStart(){V.isAtEditor&&!V.isCollapsed&&(this.isStartedAtEditor=!0),this.Editor.InlineToolbar.close()}processDragOver(e){e.preventDefault()}},ModificationsObserver:class extends X{constructor({config:e,eventsDispatcher:t}){super({config:e,eventsDispatcher:t}),this.disabled=!1,this.batchingTimeout=null,this.batchingOnChangeQueue=new Map,this.batchTime=400,this.mutationObserver=new MutationObserver((e=>{this.redactorChanged(e)})),this.eventsDispatcher.on(Z,(e=>{this.particularBlockChanged(e.event)})),this.eventsDispatcher.on(J,(()=>{this.disable()})),this.eventsDispatcher.on(Q,(()=>{this.enable()}))}enable(){this.mutationObserver.observe(this.Editor.UI.nodes.redactor,{childList:!0,subtree:!0,characterData:!0,attributes:!0}),this.disabled=!1}disable(){this.mutationObserver.disconnect(),this.disabled=!0}particularBlockChanged(e){this.disabled||!y(this.config.onChange)||(this.batchingOnChangeQueue.set(`block:${e.detail.target.id}:event:${e.type}`,e),this.batchingTimeout&&clearTimeout(this.batchingTimeout),this.batchingTimeout=setTimeout((()=>{let e;e=1===this.batchingOnChangeQueue.size?this.batchingOnChangeQueue.values().next().value:Array.from(this.batchingOnChangeQueue.values()),this.config.onChange&&this.config.onChange(this.Editor.API.methods,e),this.batchingOnChangeQueue.clear()}),this.batchTime))}redactorChanged(e){this.eventsDispatcher.emit(G,{mutations:e})}},Paste:qn,ReadOnly:class extends X{constructor(){super(...arguments),this.toolsDontSupportReadOnly=[],this.readOnlyEnabled=!1}get isEnabled(){return this.readOnlyEnabled}async prepare(){const{Tools:e}=this.Editor,{blockTools:t}=e,o=[];Array.from(t.entries()).forEach((([e,t])=>{t.isReadOnlySupported||o.push(e)})),this.toolsDontSupportReadOnly=o,this.config.readOnly&&o.length>0&&this.throwCriticalError(),this.toggle(this.config.readOnly,!0)}async toggle(e=!this.readOnlyEnabled,t=!1){e&&this.toolsDontSupportReadOnly.length>0&&this.throwCriticalError();const o=this.readOnlyEnabled;this.readOnlyEnabled=e;for(const i in this.Editor)this.Editor[i].toggleReadOnly&&this.Editor[i].toggleReadOnly(e);if(o===e)return this.readOnlyEnabled;if(t)return this.readOnlyEnabled;this.Editor.ModificationsObserver.disable();const n=await this.Editor.Saver.save();return await this.Editor.BlockManager.clear(),await this.Editor.Renderer.render(n.blocks),this.Editor.ModificationsObserver.enable(),this.readOnlyEnabled}throwCriticalError(){throw new $(`To enable read-only mode all connected tools should support it. Tools ${this.toolsDontSupportReadOnly.join(", ")} don't support read-only mode.`)}},RectangleSelection:class e extends X{constructor(){super(...arguments),this.isRectSelectionActivated=!1,this.SCROLL_SPEED=3,this.HEIGHT_OF_SCROLL_ZONE=40,this.BOTTOM_SCROLL_ZONE=1,this.TOP_SCROLL_ZONE=2,this.MAIN_MOUSE_BUTTON=0,this.mousedown=!1,this.isScrolling=!1,this.inScrollZone=null,this.startX=0,this.startY=0,this.mouseX=0,this.mouseY=0,this.stackOfSelected=[],this.listenerIds=[]}static get CSS(){return{overlay:"codex-editor-overlay",overlayContainer:"codex-editor-overlay__container",rect:"codex-editor-overlay__rectangle",topScrollZone:"codex-editor-overlay__scroll-zone--top",bottomScrollZone:"codex-editor-overlay__scroll-zone--bottom"}}prepare(){this.enableModuleBindings()}startSelection(e,t){const o=document.elementFromPoint(e-window.pageXOffset,t-window.pageYOffset);o.closest(`.${this.Editor.Toolbar.CSS.toolbar}`)||(this.Editor.BlockSelection.allBlocksSelected=!1,this.clearSelection(),this.stackOfSelected=[]);const n=[`.${ce.CSS.content}`,`.${this.Editor.Toolbar.CSS.toolbar}`,`.${this.Editor.InlineToolbar.CSS.inlineToolbar}`],i=o.closest("."+this.Editor.UI.CSS.editorWrapper),r=n.some((e=>!!o.closest(e)));!i||r||(this.mousedown=!0,this.startX=e,this.startY=t)}endSelection(){this.mousedown=!1,this.startX=0,this.startY=0,this.overlayRectangle.style.display="none"}isRectActivated(){return this.isRectSelectionActivated}clearSelection(){this.isRectSelectionActivated=!1}enableModuleBindings(){const{container:e}=this.genHTML();this.listeners.on(e,"mousedown",(e=>{this.processMouseDown(e)}),!1),this.listeners.on(document.body,"mousemove",I((e=>{this.processMouseMove(e)}),10),{passive:!0}),this.listeners.on(document.body,"mouseleave",(()=>{this.processMouseLeave()})),this.listeners.on(window,"scroll",I((e=>{this.processScroll(e)}),10),{passive:!0}),this.listeners.on(document.body,"mouseup",(()=>{this.processMouseUp()}),!1)}processMouseDown(e){e.button===this.MAIN_MOUSE_BUTTON&&(null!==e.target.closest(F.allInputsSelector)||this.startSelection(e.pageX,e.pageY))}processMouseMove(e){this.changingRectangle(e),this.scrollByZones(e.clientY)}processMouseLeave(){this.clearSelection(),this.endSelection()}processScroll(e){this.changingRectangle(e)}processMouseUp(){this.clearSelection(),this.endSelection()}scrollByZones(e){this.inScrollZone=null,e<=this.HEIGHT_OF_SCROLL_ZONE&&(this.inScrollZone=this.TOP_SCROLL_ZONE),document.documentElement.clientHeight-e<=this.HEIGHT_OF_SCROLL_ZONE&&(this.inScrollZone=this.BOTTOM_SCROLL_ZONE),this.inScrollZone?this.isScrolling||(this.scrollVertical(this.inScrollZone===this.TOP_SCROLL_ZONE?-this.SCROLL_SPEED:this.SCROLL_SPEED),this.isScrolling=!0):this.isScrolling=!1}genHTML(){const{UI:t}=this.Editor,o=t.nodes.holder.querySelector("."+t.CSS.editorWrapper),n=F.make("div",e.CSS.overlay,{}),i=F.make("div",e.CSS.overlayContainer,{}),r=F.make("div",e.CSS.rect,{});return i.appendChild(r),n.appendChild(i),o.appendChild(n),this.overlayRectangle=r,{container:o,overlay:n}}scrollVertical(e){if(!this.inScrollZone||!this.mousedown)return;const t=window.pageYOffset;window.scrollBy(0,e),this.mouseY+=window.pageYOffset-t,setTimeout((()=>{this.scrollVertical(e)}),0)}changingRectangle(e){if(!this.mousedown)return;void 0!==e.pageY&&(this.mouseX=e.pageX,this.mouseY=e.pageY);const{rightPos:t,leftPos:o,index:n}=this.genInfoForMouseSelection(),i=this.startX>t&&this.mouseX>t,r=this.startX<o&&this.mouseX<o;this.rectCrossesBlocks=!(i||r),this.isRectSelectionActivated||(this.rectCrossesBlocks=!1,this.isRectSelectionActivated=!0,this.shrinkRectangleToPoint(),this.overlayRectangle.style.display="block"),this.updateRectangleSize(),this.Editor.Toolbar.close(),void 0!==n&&(this.trySelectNextBlock(n),this.inverseSelection(),V.get().removeAllRanges())}shrinkRectangleToPoint(){this.overlayRectangle.style.left=this.startX-window.pageXOffset+"px",this.overlayRectangle.style.top=this.startY-window.pageYOffset+"px",this.overlayRectangle.style.bottom=`calc(100% - ${this.startY-window.pageYOffset}px`,this.overlayRectangle.style.right=`calc(100% - ${this.startX-window.pageXOffset}px`}inverseSelection(){const e=this.Editor.BlockManager.getBlockByIndex(this.stackOfSelected[0]).selected;if(this.rectCrossesBlocks&&!e)for(const t of this.stackOfSelected)this.Editor.BlockSelection.selectBlockByIndex(t);if(!this.rectCrossesBlocks&&e)for(const t of this.stackOfSelected)this.Editor.BlockSelection.unSelectBlockByIndex(t)}updateRectangleSize(){this.mouseY>=this.startY?(this.overlayRectangle.style.top=this.startY-window.pageYOffset+"px",this.overlayRectangle.style.bottom=`calc(100% - ${this.mouseY-window.pageYOffset}px`):(this.overlayRectangle.style.bottom=`calc(100% - ${this.startY-window.pageYOffset}px`,this.overlayRectangle.style.top=this.mouseY-window.pageYOffset+"px"),this.mouseX>=this.startX?(this.overlayRectangle.style.left=this.startX-window.pageXOffset+"px",this.overlayRectangle.style.right=`calc(100% - ${this.mouseX-window.pageXOffset}px`):(this.overlayRectangle.style.right=`calc(100% - ${this.startX-window.pageXOffset}px`,this.overlayRectangle.style.left=this.mouseX-window.pageXOffset+"px")}genInfoForMouseSelection(){const e=document.body.offsetWidth/2,t=this.mouseY-window.pageYOffset,o=document.elementFromPoint(e,t),n=this.Editor.BlockManager.getBlockByChildNode(o);let i;void 0!==n&&(i=this.Editor.BlockManager.blocks.findIndex((e=>e.holder===n.holder)));const r=this.Editor.BlockManager.lastBlock.holder.querySelector("."+ce.CSS.content),s=Number.parseInt(window.getComputedStyle(r).width,10)/2;return{index:i,leftPos:e-s,rightPos:e+s}}addBlockInSelection(e){this.rectCrossesBlocks&&this.Editor.BlockSelection.selectBlockByIndex(e),this.stackOfSelected.push(e)}trySelectNextBlock(e){const t=this.stackOfSelected[this.stackOfSelected.length-1]===e,o=this.stackOfSelected.length;if(t)return;const n=this.stackOfSelected[o-1]-this.stackOfSelected[o-2]>0;let i=0;o>1&&(i=n?1:-1);const r=e>this.stackOfSelected[o-1]&&1===i,s=e<this.stackOfSelected[o-1]&&-1===i,a=!(r||s||0===i);if(!a&&(e>this.stackOfSelected[o-1]||void 0===this.stackOfSelected[o-1])){let t=this.stackOfSelected[o-1]+1||e;for(;t<=e;t++)this.addBlockInSelection(t);return}if(!a&&e<this.stackOfSelected[o-1]){for(let t=this.stackOfSelected[o-1]-1;t>=e;t--)this.addBlockInSelection(t);return}if(!a)return;let l,c=o-1;for(l=e>this.stackOfSelected[o-1]?()=>e>this.stackOfSelected[c]:()=>e<this.stackOfSelected[c];l();)this.rectCrossesBlocks&&this.Editor.BlockSelection.unSelectBlockByIndex(this.stackOfSelected[c]),this.stackOfSelected.pop(),c--}},Renderer:class extends X{async render(e){return new Promise((t=>{const{Tools:o,BlockManager:n}=this.Editor;if(0===e.length)n.insert();else{const t=e.map((({type:e,data:t,tunes:i,id:r})=>{let s;!1===o.available.has(e)&&(b(`Tool «${e}» is not found. Check 'tools' property at the Editor.js config.`,"warn"),t=this.composeStubDataForTool(e,t,r),e=o.stubTool);try{s=n.composeBlock({id:r,tool:e,data:t,tunes:i})}catch(a){m(`Block «${e}» skipped because of plugins error`,"error",{data:t,error:a}),t=this.composeStubDataForTool(e,t,r),e=o.stubTool,s=n.composeBlock({id:r,tool:e,data:t,tunes:i})}return s}));n.insertMany(t)}window.requestIdleCallback((()=>{t()}),{timeout:2e3})}))}composeStubDataForTool(e,t,o){const{Tools:n}=this.Editor;let i=e;if(n.unavailable.has(e)){const t=n.unavailable.get(e).toolbox;void 0!==t&&void 0!==t[0].title&&(i=t[0].title)}return{savedData:{id:o,type:e,data:t},title:i}}},Saver:class extends X{async save(){const{BlockManager:e,Tools:t}=this.Editor,o=e.blocks,n=[];try{o.forEach((e=>{n.push(this.getSavedData(e))}));const e=await Promise.all(n),i=await ge(e,(e=>t.blockTools.get(e).sanitizeConfig));return this.makeOutput(i)}catch(i){b("Saving failed due to the Error %o","error",i)}}async getSavedData(e){const t=await e.save(),o=t&&await e.validate(t.data);return{...t,isValid:o}}makeOutput(e){const t=[];return e.forEach((({id:e,tool:o,data:n,tunes:i,isValid:r})=>{if(!r)return void m(`Block «${o}» skipped because saved data is invalid`);if(o===this.Editor.Tools.stubTool)return void t.push(n);const s={id:e,type:o,data:n,...!C(i)&&{tunes:i}};t.push(s)})),{time:+new Date,blocks:t,version:"2.31.0"}}},Tools:ui,UI:class extends X{constructor(){super(...arguments),this.isMobile=!1,this.contentRectCache=null,this.resizeDebouncer=B((()=>{this.windowResize()}),200),this.selectionChangeDebounced=B((()=>{this.selectionChanged()}),180),this.documentTouchedListener=e=>{this.documentTouched(e)}}get CSS(){return{editorWrapper:"codex-editor",editorWrapperNarrow:"codex-editor--narrow",editorZone:"codex-editor__redactor",editorZoneHidden:"codex-editor__redactor--hidden",editorEmpty:"codex-editor--empty",editorRtlFix:"codex-editor--rtl"}}get contentRect(){if(null!==this.contentRectCache)return this.contentRectCache;const e=this.nodes.wrapper.querySelector(`.${ce.CSS.content}`);return e?(this.contentRectCache=e.getBoundingClientRect(),this.contentRectCache):{width:650,left:0,right:0}}async prepare(){this.setIsMobile(),this.make(),this.loadStyles()}toggleReadOnly(e){e?this.unbindReadOnlySensitiveListeners():window.requestIdleCallback((()=>{this.bindReadOnlySensitiveListeners()}),{timeout:2e3})}checkEmptiness(){const{BlockManager:e}=this.Editor;this.nodes.wrapper.classList.toggle(this.CSS.editorEmpty,e.isEditorEmpty)}get someToolbarOpened(){const{Toolbar:e,BlockSettings:t,InlineToolbar:o}=this.Editor;return!!(t.opened||o.opened||e.toolbox.opened)}get someFlipperButtonFocused(){return!!this.Editor.Toolbar.toolbox.hasFocus()||Object.entries(this.Editor).filter((([e,t])=>t.flipper instanceof Oe)).some((([e,t])=>t.flipper.hasFocus()))}destroy(){this.nodes.holder.innerHTML="",this.unbindReadOnlyInsensitiveListeners()}closeAllToolbars(){const{Toolbar:e,BlockSettings:t,InlineToolbar:o}=this.Editor;t.close(),o.close(),e.toolbox.close()}setIsMobile(){const e=window.innerWidth<650;e!==this.isMobile&&this.eventsDispatcher.emit(ee,{isEnabled:this.isMobile}),this.isMobile=e}make(){this.nodes.holder=F.getHolder(this.config.holder),this.nodes.wrapper=F.make("div",[this.CSS.editorWrapper,...this.isRtl?[this.CSS.editorRtlFix]:[]]),this.nodes.redactor=F.make("div",this.CSS.editorZone),this.nodes.holder.offsetWidth<this.contentRect.width&&this.nodes.wrapper.classList.add(this.CSS.editorWrapperNarrow),this.nodes.redactor.style.paddingBottom=this.config.minHeight+"px",this.nodes.wrapper.appendChild(this.nodes.redactor),this.nodes.holder.appendChild(this.nodes.wrapper),this.bindReadOnlyInsensitiveListeners()}loadStyles(){const e="editor-js-styles";if(F.get(e))return;const t=F.make("style",null,{id:e,textContent:hi.toString()});this.config.style&&!C(this.config.style)&&this.config.style.nonce&&t.setAttribute("nonce",this.config.style.nonce),F.prepend(document.head,t)}bindReadOnlyInsensitiveListeners(){this.listeners.on(document,"selectionchange",this.selectionChangeDebounced),this.listeners.on(window,"resize",this.resizeDebouncer,{passive:!0}),this.listeners.on(this.nodes.redactor,"mousedown",this.documentTouchedListener,{capture:!0,passive:!0}),this.listeners.on(this.nodes.redactor,"touchstart",this.documentTouchedListener,{capture:!0,passive:!0})}unbindReadOnlyInsensitiveListeners(){this.listeners.off(document,"selectionchange",this.selectionChangeDebounced),this.listeners.off(window,"resize",this.resizeDebouncer),this.listeners.off(this.nodes.redactor,"mousedown",this.documentTouchedListener),this.listeners.off(this.nodes.redactor,"touchstart",this.documentTouchedListener)}bindReadOnlySensitiveListeners(){this.readOnlyMutableListeners.on(this.nodes.redactor,"click",(e=>{this.redactorClicked(e)}),!1),this.readOnlyMutableListeners.on(document,"keydown",(e=>{this.documentKeydown(e)}),!0),this.readOnlyMutableListeners.on(document,"mousedown",(e=>{this.documentClicked(e)}),!0),this.watchBlockHoveredEvents(),this.enableInputsEmptyMark()}watchBlockHoveredEvents(){let e;this.readOnlyMutableListeners.on(this.nodes.redactor,"mousemove",I((t=>{const o=t.target.closest(".ce-block");this.Editor.BlockSelection.anyBlockSelected||o&&e!==o&&(e=o,this.eventsDispatcher.emit(wt,{block:this.Editor.BlockManager.getBlockByChildNode(o)}))}),20),{passive:!0})}unbindReadOnlySensitiveListeners(){this.readOnlyMutableListeners.clearAll()}windowResize(){this.contentRectCache=null,this.setIsMobile()}documentKeydown(e){switch(e.keyCode){case a:this.enterPressed(e);break;case r:case p:this.backspacePressed(e);break;case l:this.escapePressed(e);break;default:this.defaultBehaviour(e)}}defaultBehaviour(e){const{currentBlock:t}=this.Editor.BlockManager,o=e.target.closest(`.${this.CSS.editorWrapper}`),n=e.altKey||e.ctrlKey||e.metaKey||e.shiftKey;void 0===t||null!==o?o||t&&n||(this.Editor.BlockManager.unsetCurrentBlock(),this.Editor.Toolbar.close()):this.Editor.BlockEvents.keydown(e)}backspacePressed(e){const{BlockManager:t,BlockSelection:o,Caret:n}=this.Editor;if(o.anyBlockSelected&&!V.isSelectionExists){const i=t.removeSelectedBlocks(),r=t.insertDefaultBlockAtIndex(i,!0);n.setToBlock(r,n.positions.START),o.clearSelection(e),e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation()}}escapePressed(e){this.Editor.BlockSelection.clearSelection(e),this.Editor.Toolbar.toolbox.opened?(this.Editor.Toolbar.toolbox.close(),this.Editor.Caret.setToBlock(this.Editor.BlockManager.currentBlock,this.Editor.Caret.positions.END)):this.Editor.BlockSettings.opened?this.Editor.BlockSettings.close():this.Editor.InlineToolbar.opened?this.Editor.InlineToolbar.close():this.Editor.Toolbar.close()}enterPressed(e){const{BlockManager:t,BlockSelection:o}=this.Editor;if(this.someToolbarOpened)return;const n=t.currentBlockIndex>=0;if(o.anyBlockSelected&&!V.isSelectionExists)return o.clearSelection(e),e.preventDefault(),e.stopImmediatePropagation(),void e.stopPropagation();if(!this.someToolbarOpened&&n&&"BODY"===e.target.tagName){const t=this.Editor.BlockManager.insert();e.preventDefault(),this.Editor.Caret.setToBlock(t),this.Editor.Toolbar.moveAndOpen(t)}this.Editor.BlockSelection.clearSelection(e)}documentClicked(e){var t,o;if(!e.isTrusted)return;const n=e.target;this.nodes.holder.contains(n)||V.isAtEditor||(this.Editor.BlockManager.unsetCurrentBlock(),this.Editor.Toolbar.close());const i=null==(t=this.Editor.BlockSettings.nodes.wrapper)?void 0:t.contains(n),r=null==(o=this.Editor.Toolbar.nodes.settingsToggler)?void 0:o.contains(n),s=i||r;if(this.Editor.BlockSettings.opened&&!s){this.Editor.BlockSettings.close();const e=this.Editor.BlockManager.getBlockByChildNode(n);this.Editor.Toolbar.moveAndOpen(e)}this.Editor.BlockSelection.clearSelection(e)}documentTouched(e){let t=e.target;if(t===this.nodes.redactor){const o=e instanceof MouseEvent?e.clientX:e.touches[0].clientX,n=e instanceof MouseEvent?e.clientY:e.touches[0].clientY;t=document.elementFromPoint(o,n)}try{this.Editor.BlockManager.setCurrentBlockByChildNode(t)}catch{this.Editor.RectangleSelection.isRectActivated()||this.Editor.Caret.setToTheLastBlock()}this.Editor.ReadOnly.isEnabled||this.Editor.Toolbar.moveAndOpen()}redactorClicked(e){if(!V.isCollapsed)return;const t=e.target,o=e.metaKey||e.ctrlKey;if(F.isAnchor(t)&&o){e.stopImmediatePropagation(),e.stopPropagation();const o=function(e){try{return new URL(e).href}catch{}return"//"===e.substring(0,2)?window.location.protocol+e:window.location.origin+e}(t.getAttribute("href"));return n=o,void window.open(n,"_blank")}var n;this.processBottomZoneClick(e)}processBottomZoneClick(e){const t=this.Editor.BlockManager.getBlockByIndex(-1),o=F.offset(t.holder).bottom,n=e.pageY,{BlockSelection:i}=this.Editor;if(e.target instanceof Element&&e.target.isEqualNode(this.nodes.redactor)&&!i.anyBlockSelected&&o<n){e.stopImmediatePropagation(),e.stopPropagation();const{BlockManager:t,Caret:o,Toolbar:n}=this.Editor;(!t.lastBlock.tool.isDefault||!t.lastBlock.isEmpty)&&t.insertAtEnd(),o.setToTheLastBlock(),n.moveAndOpen(t.lastBlock)}}selectionChanged(){const{CrossBlockSelection:e,BlockSelection:t}=this.Editor,o=V.anchorElement;if(e.isCrossBlockSelectionStarted&&t.anyBlockSelected&&V.get().removeAllRanges(),!o)return void(V.range||this.Editor.InlineToolbar.close());const n=o.closest(`.${ce.CSS.content}`);(null===n||n.closest(`.${V.CSS.editorWrapper}`)!==this.nodes.wrapper)&&(this.Editor.InlineToolbar.containsNode(o)||this.Editor.InlineToolbar.close(),"true"!==o.dataset.inlineToolbar)||(this.Editor.BlockManager.currentBlock||this.Editor.BlockManager.setCurrentBlockByChildNode(o),this.Editor.InlineToolbar.tryToShow(!0))}enableInputsEmptyMark(){function e(e){H(e.target)}this.readOnlyMutableListeners.on(this.nodes.wrapper,"input",e),this.readOnlyMutableListeners.on(this.nodes.wrapper,"focusin",e),this.readOnlyMutableListeners.on(this.nodes.wrapper,"focusout",e)}}};class fi{constructor(e){let t,o;this.moduleInstances={},this.eventsDispatcher=new q,this.isReady=new Promise(((e,n)=>{t=e,o=n})),Promise.resolve().then((async()=>{this.configuration=e,this.validate(),this.init(),await this.start(),await this.render();const{BlockManager:o,Caret:n,UI:i,ModificationsObserver:r}=this.moduleInstances;i.checkEmptiness(),r.enable(),!0===this.configuration.autofocus&&!0!==this.configuration.readOnly&&n.setToBlock(o.blocks[0],n.positions.START),t()})).catch((e=>{m(`Editor.js is not ready because of ${e}`,"error"),o(e)}))}set configuration(e){var t,o,n;k(e)?this.config={...e}:this.config={holder:e},N(!!this.config.holderId,"config.holderId","config.holder"),this.config.holderId&&!this.config.holder&&(this.config.holder=this.config.holderId,this.config.holderId=null),null==this.config.holder&&(this.config.holder="editorjs"),this.config.logLevel||(this.config.logLevel=i.VERBOSE),n=this.config.logLevel,g.logLevel=n,N(!!this.config.initialBlock,"config.initialBlock","config.defaultBlock"),this.config.defaultBlock=this.config.defaultBlock||this.config.initialBlock||"paragraph",this.config.minHeight=void 0!==this.config.minHeight?this.config.minHeight:300;const r={type:this.config.defaultBlock,data:{}};this.config.placeholder=this.config.placeholder||!1,this.config.sanitizer=this.config.sanitizer||{p:!0,b:!0,a:!0},this.config.hideToolbar=!!this.config.hideToolbar&&this.config.hideToolbar,this.config.tools=this.config.tools||{},this.config.i18n=this.config.i18n||{},this.config.data=this.config.data||{blocks:[]},this.config.onReady=this.config.onReady||(()=>{}),this.config.onChange=this.config.onChange||(()=>{}),this.config.inlineToolbar=void 0===this.config.inlineToolbar||this.config.inlineToolbar,(C(this.config.data)||!this.config.data.blocks||0===this.config.data.blocks.length)&&(this.config.data={blocks:[r]}),this.config.readOnly=this.config.readOnly||!1,null!=(t=this.config.i18n)&&t.messages&&W.setDictionary(this.config.i18n.messages),this.config.i18n.direction=(null==(o=this.config.i18n)?void 0:o.direction)||"ltr"}get configuration(){return this.config}validate(){const{holderId:e,holder:t}=this.config;if(e&&t)throw Error("«holderId» and «holder» param can't assign at the same time.");if(w(t)&&!F.get(t))throw Error(`element with ID «${t}» is missing. Pass correct holder's ID.`);if(t&&k(t)&&!F.isElement(t))throw Error("«holder» value must be an Element node")}init(){this.constructModules(),this.configureModules()}async start(){await["Tools","UI","BlockManager","Paste","BlockSelection","RectangleSelection","CrossBlockSelection","ReadOnly"].reduce(((e,t)=>e.then((async()=>{try{await this.moduleInstances[t].prepare()}catch(e){if(e instanceof $)throw new Error(e.message);m(`Module ${t} was skipped because of %o`,"warn",e)}}))),Promise.resolve())}render(){return this.moduleInstances.Renderer.render(this.config.data.blocks)}constructModules(){Object.entries(pi).forEach((([e,t])=>{try{this.moduleInstances[e]=new t({config:this.configuration,eventsDispatcher:this.eventsDispatcher})}catch(o){m("[constructModules]",`Module ${e} skipped because`,"error",o)}}))}configureModules(){for(const e in this.moduleInstances)Object.prototype.hasOwnProperty.call(this.moduleInstances,e)&&(this.moduleInstances[e].state=this.getModulesDiff(e))}getModulesDiff(e){const t={};for(const o in this.moduleInstances)o!==e&&(t[o]=this.moduleInstances[o]);return t}}
|
||
/**
|
||
* Editor.js
|
||
*
|
||
* @license Apache-2.0
|
||
* @see Editor.js <https://editorjs.io>
|
||
* @author CodeX Team <https://codex.so>
|
||
*/class gi{static get version(){return"2.31.0"}constructor(e){let t=()=>{};k(e)&&y(e.onReady)&&(t=e.onReady);const o=new fi(e);this.isReady=o.isReady.then((()=>{this.exportAPI(o),t()}))}exportAPI(e){["configuration"].forEach((t=>{this[t]=e[t]})),this.destroy=()=>{Object.values(e.moduleInstances).forEach((e=>{y(e.destroy)&&e.destroy(),e.listeners.removeAll()})),null==we||we.destroy(),we=null,e=null;for(const e in this)Object.prototype.hasOwnProperty.call(this,e)&&delete this[e];Object.setPrototypeOf(this,null)},Object.setPrototypeOf(this,e.moduleInstances.API.methods),delete this.exportAPI,Object.entries({blocks:{clear:"clear",render:"render"},caret:{focus:"focus"},events:{on:"on",off:"off",emit:"emit"},saver:{save:"save"}}).forEach((([t,o])=>{Object.entries(o).forEach((([o,n])=>{this[n]=e.moduleInstances.API.methods[t][o]}))}))}}!function(){try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".ce-header{padding:.6em 0 3px;margin:0;line-height:1.25em;outline:none}.ce-header p,.ce-header div{padding:0!important;margin:0!important}")),document.head.appendChild(e)}}catch(t){}}(),function(){try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode('.cdx-list{margin:0;padding:0;outline:none;display:grid;counter-reset:item;gap:var(--spacing-s);padding:var(--spacing-xs);--spacing-s: 8px;--spacing-xs: 6px;--list-counter-type: numeric;--radius-border: 5px;--checkbox-background: #fff;--color-border: #C9C9C9;--color-bg-checked: #369FFF;--line-height: 1.45em;--color-bg-checked-hover: #0059AB;--color-tick: #fff;--size-checkbox: 1.2em}.cdx-list__item{line-height:var(--line-height);display:grid;grid-template-columns:auto 1fr;grid-template-rows:auto auto;grid-template-areas:"checkbox content" ". child"}.cdx-list__item-children{display:grid;grid-area:child;gap:var(--spacing-s);padding-top:var(--spacing-s)}.cdx-list__item [contenteditable]{outline:none}.cdx-list__item-content{word-break:break-word;white-space:pre-wrap;grid-area:content;padding-left:var(--spacing-s)}.cdx-list__item:before{counter-increment:item;white-space:nowrap}.cdx-list-ordered .cdx-list__item:before{content:counters(item,".",var(--list-counter-type)) "."}.cdx-list-ordered{counter-reset:item}.cdx-list-unordered .cdx-list__item:before{content:"•"}.cdx-list-checklist .cdx-list__item:before{content:""}.cdx-list__settings .cdx-settings-button{width:50%}.cdx-list__checkbox{padding-top:calc((var(--line-height) - var(--size-checkbox)) / 2);grid-area:checkbox;width:var(--size-checkbox);height:var(--size-checkbox);display:flex;cursor:pointer}.cdx-list__checkbox svg{opacity:0;height:var(--size-checkbox);width:var(--size-checkbox);left:-1px;top:-1px;position:absolute}@media (hover: hover){.cdx-list__checkbox:not(.cdx-list__checkbox--no-hover):hover .cdx-list__checkbox-check svg{opacity:1}}.cdx-list__checkbox--checked{line-height:var(--line-height)}@media (hover: hover){.cdx-list__checkbox--checked:not(.cdx-list__checkbox--checked--no-hover):hover .cdx-checklist__checkbox-check{background:var(--color-bg-checked-hover);border-color:var(--color-bg-checked-hover)}}.cdx-list__checkbox--checked .cdx-list__checkbox-check{background:var(--color-bg-checked);border-color:var(--color-bg-checked)}.cdx-list__checkbox--checked .cdx-list__checkbox-check svg{opacity:1}.cdx-list__checkbox--checked .cdx-list__checkbox-check svg path{stroke:var(--color-tick)}.cdx-list__checkbox--checked .cdx-list__checkbox-check:before{opacity:0;visibility:visible;transform:scale(2.5)}.cdx-list__checkbox-check{cursor:pointer;display:inline-block;position:relative;margin:0 auto;width:var(--size-checkbox);height:var(--size-checkbox);box-sizing:border-box;border-radius:var(--radius-border);border:1px solid var(--color-border);background:var(--checkbox-background)}.cdx-list__checkbox-check:before{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:100%;background-color:var(--color-bg-checked);visibility:hidden;pointer-events:none;transform:scale(1);transition:transform .4s ease-out,opacity .4s}.cdx-list-start-with-field{background:#F8F8F8;border:1px solid rgba(226,226,229,.2);border-radius:6px;padding:2px;display:grid;grid-template-columns:auto auto 1fr;grid-template-rows:auto}.cdx-list-start-with-field--invalid{background:#FFECED;border:1px solid #E13F3F}.cdx-list-start-with-field--invalid .cdx-list-start-with-field__input{color:#e13f3f}.cdx-list-start-with-field__input{font-size:14px;outline:none;font-weight:500;font-family:inherit;border:0;background:transparent;margin:0;padding:0;line-height:22px;min-width:calc(100% - var(--toolbox-buttons-size) - var(--icon-margin-right))}.cdx-list-start-with-field__input::placeholder{color:var(--grayText);font-weight:500}')),document.head.appendChild(e)}}catch(t){}}();const mi='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M9.2 12L11.0586 13.8586C11.1367 13.9367 11.2633 13.9367 11.3414 13.8586L14.7 10.5"/><rect width="14" height="14" x="5" y="5" stroke="currentColor" stroke-width="2" rx="4"/></svg>',bi='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><line x1="9" x2="19" y1="7" y2="7" stroke="currentColor" stroke-linecap="round" stroke-width="2"/><line x1="9" x2="19" y1="12" y2="12" stroke="currentColor" stroke-linecap="round" stroke-width="2"/><line x1="9" x2="19" y1="17" y2="17" stroke="currentColor" stroke-linecap="round" stroke-width="2"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M5.00001 17H4.99002"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M5.00001 12H4.99002"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M5.00001 7H4.99002"/></svg>',vi='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><line x1="12" x2="19" y1="7" y2="7" stroke="currentColor" stroke-linecap="round" stroke-width="2"/><line x1="12" x2="19" y1="12" y2="12" stroke="currentColor" stroke-linecap="round" stroke-width="2"/><line x1="12" x2="19" y1="17" y2="17" stroke="currentColor" stroke-linecap="round" stroke-width="2"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M7.79999 14L7.79999 7.2135C7.79999 7.12872 7.7011 7.0824 7.63597 7.13668L4.79999 9.5"/></svg>';var yi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ki(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var o=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};o.prototype=t.prototype}else o={};return Object.defineProperty(o,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(o,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),o}var wi={},xi={},Ei={};Object.defineProperty(Ei,"__esModule",{value:!0}),Ei.allInputsSelector=function(){return"[contenteditable=true], textarea, input:not([type]), "+["text","password","email","number","search","tel","url"].map((function(e){return'input[type="'.concat(e,'"]')})).join(", ")},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.allInputsSelector=void 0;var t=Ei;Object.defineProperty(e,"allInputsSelector",{enumerable:!0,get:function(){return t.allInputsSelector}})}(xi);var Ci={},Si={};Object.defineProperty(Si,"__esModule",{value:!0}),Si.isNativeInput=function(e){return!(!e||!e.tagName)&&["INPUT","TEXTAREA"].includes(e.tagName)},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.isNativeInput=void 0;var t=Si;Object.defineProperty(e,"isNativeInput",{enumerable:!0,get:function(){return t.isNativeInput}})}(Ci);var Ti={},_i={};Object.defineProperty(_i,"__esModule",{value:!0}),_i.append=function(e,t){Array.isArray(t)?t.forEach((function(t){e.appendChild(t)})):e.appendChild(t)},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.append=void 0;var t=_i;Object.defineProperty(e,"append",{enumerable:!0,get:function(){return t.append}})}(Ti);var Oi={},Bi={};Object.defineProperty(Bi,"__esModule",{value:!0}),Bi.blockElements=function(){return["address","article","aside","blockquote","canvas","div","dl","dt","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","li","main","nav","noscript","ol","output","p","pre","ruby","section","table","tbody","thead","tr","tfoot","ul","video"]},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.blockElements=void 0;var t=Bi;Object.defineProperty(e,"blockElements",{enumerable:!0,get:function(){return t.blockElements}})}(Oi);var Ii={},Mi={};Object.defineProperty(Mi,"__esModule",{value:!0}),Mi.calculateBaseline=function(e){var t=window.getComputedStyle(e),o=parseFloat(t.fontSize),n=parseFloat(t.lineHeight)||1.2*o,i=parseFloat(t.paddingTop),r=parseFloat(t.borderTopWidth);return parseFloat(t.marginTop)+r+i+(n-o)/2+.8*o},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.calculateBaseline=void 0;var t=Mi;Object.defineProperty(e,"calculateBaseline",{enumerable:!0,get:function(){return t.calculateBaseline}})}(Ii);var Pi={},Li={},Ai={},Ni={};Object.defineProperty(Ni,"__esModule",{value:!0}),Ni.isContentEditable=function(e){return"true"===e.contentEditable},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.isContentEditable=void 0;var t=Ni;Object.defineProperty(e,"isContentEditable",{enumerable:!0,get:function(){return t.isContentEditable}})}(Ai),Object.defineProperty(Li,"__esModule",{value:!0}),Li.canSetCaret=function(e){var t=!0;if((0,ji.isNativeInput)(e))switch(e.type){case"file":case"checkbox":case"radio":case"hidden":case"submit":case"button":case"image":case"reset":t=!1}else t=(0,Di.isContentEditable)(e);return t};var ji=Ci,Di=Ai;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.canSetCaret=void 0;var t=Li;Object.defineProperty(e,"canSetCaret",{enumerable:!0,get:function(){return t.canSetCaret}})}(Pi);var Ri={},Fi={};function Hi(){const e={win:!1,mac:!1,x11:!1,linux:!1},t=Object.keys(e).find((e=>-1!==window.navigator.appVersion.toLowerCase().indexOf(e)));return void 0!==t&&(e[t]=!0),e}function Ui(e){return null!=e&&""!==e&&("object"!=typeof e||Object.keys(e).length>0)}function zi(e){return Object.prototype.toString.call(e).match(/\s([a-zA-Z]+)/)[1].toLowerCase()}function Wi(e){return"function"===zi(e)||"asyncfunction"===zi(e)}function $i(e){return"object"===zi(e)}const qi=Object.freeze(Object.defineProperty({__proto__:null,PromiseQueue:class{constructor(){this.completed=Promise.resolve()}add(e){return new Promise(((t,o)=>{this.completed=this.completed.then(e).then(t).catch(o)}))}},beautifyShortcut:function(e){const t=Hi();return e=e.replace(/shift/gi,"⇧").replace(/backspace/gi,"⌫").replace(/enter/gi,"⏎").replace(/up/gi,"↑").replace(/left/gi,"→").replace(/down/gi,"↓").replace(/right/gi,"←").replace(/escape/gi,"⎋").replace(/insert/gi,"Ins").replace(/delete/gi,"␡").replace(/\+/gi,"+"),e=t.mac?e.replace(/ctrl|cmd/gi,"⌘").replace(/alt/gi,"⌥"):e.replace(/cmd/gi,"Ctrl").replace(/windows/gi,"WIN")},cacheable:function(e,t,o){const n=void 0!==o.value?"value":"get",i=o[n],r=`#${t}Cache`;if(o[n]=function(...e){return void 0===this[r]&&(this[r]=i.apply(this,e)),this[r]},"get"===n&&o.set){const t=o.set;o.set=function(o){delete e[r],t.apply(this,o)}}return o},capitalize:function(e){return e[0].toUpperCase()+e.slice(1)},copyTextToClipboard:function(e){const t=document.createElement("div");t.style.position="absolute",t.style.left="-999px",t.style.bottom="-999px",t.innerHTML=e,document.body.appendChild(t);const o=window.getSelection(),n=document.createRange();if(n.selectNode(t),null===o)throw new Error("Cannot copy text to clipboard");o.removeAllRanges(),o.addRange(n),document.execCommand("copy"),document.body.removeChild(t)},debounce:function(e,t,o){let n;return(...i)=>{const r=this,s=!0===o&&void 0!==n;window.clearTimeout(n),n=window.setTimeout((()=>{n=void 0,!0!==o&&e.apply(r,i)}),t),s&&e.apply(r,i)}},deepMerge:function e(t,...o){if(!o.length)return t;const n=o.shift();if($i(t)&&$i(n))for(const i in n)$i(n[i])?(void 0===t[i]&&Object.assign(t,{[i]:{}}),e(t[i],n[i])):Object.assign(t,{[i]:n[i]});return e(t,...o)},deprecationAssert:function(e,t,o){},getUserOS:Hi,getValidUrl:function(e){try{return new URL(e).href}catch{}return"//"===e.substring(0,2)?window.location.protocol+e:window.location.origin+e},isBoolean:function(e){return"boolean"===zi(e)},isClass:function(e){return Wi(e)&&/^\s*class\s+/.test(e.toString())},isEmpty:function(e){return!Ui(e)},isFunction:Wi,isIosDevice:()=>typeof window<"u"&&null!==window.navigator&&Ui(window.navigator.platform)&&(/iP(ad|hone|od)/.test(window.navigator.platform)||"MacIntel"===window.navigator.platform&&window.navigator.maxTouchPoints>1),isNumber:function(e){return"number"===zi(e)},isObject:$i,isPrintableKey:function(e){return e>47&&e<58||32===e||13===e||229===e||e>64&&e<91||e>95&&e<112||e>185&&e<193||e>218&&e<223},isPromise:function(e){return Promise.resolve(e)===e},isString:function(e){return"string"===zi(e)},isUndefined:function(e){return"undefined"===zi(e)},keyCodes:{BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,ESC:27,SPACE:32,LEFT:37,UP:38,DOWN:40,RIGHT:39,DELETE:46,META:91,SLASH:191},mouseButtons:{LEFT:0,WHEEL:1,RIGHT:2,BACKWARD:3,FORWARD:4},notEmpty:Ui,throttle:function(e,t,o=void 0){let n,i,r,s=null,a=0;o||(o={});const l=function(){a=!1===o.leading?0:Date.now(),s=null,r=e.apply(n,i),null===s&&(n=i=null)};return function(){const c=Date.now();!a&&!1===o.leading&&(a=c);const d=t-(c-a);return n=this,i=arguments,d<=0||d>t?(s&&(clearTimeout(s),s=null),a=c,r=e.apply(n,i),null===s&&(n=i=null)):!s&&!1!==o.trailing&&(s=setTimeout(l,d)),r}},typeOf:zi},Symbol.toStringTag,{value:"Module"})),Ki=ki(qi);Object.defineProperty(Fi,"__esModule",{value:!0}),Fi.containsOnlyInlineElements=function(e){var t;(0,Yi.isString)(e)?(t=document.createElement("div")).innerHTML=e:t=e;var o=function(e){return!(0,Xi.blockElements)().includes(e.tagName.toLowerCase())&&Array.from(e.children).every(o)};return Array.from(t.children).every(o)};var Yi=Ki,Xi=Oi;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.containsOnlyInlineElements=void 0;var t=Fi;Object.defineProperty(e,"containsOnlyInlineElements",{enumerable:!0,get:function(){return t.containsOnlyInlineElements}})}(Ri);var Vi={},Gi={},Zi={},Ji={};Object.defineProperty(Ji,"__esModule",{value:!0}),Ji.make=function(e,t,o){var n;void 0===t&&(t=null),void 0===o&&(o={});var i=document.createElement(e);if(Array.isArray(t)){var r=t.filter((function(e){return void 0!==e}));(n=i.classList).add.apply(n,r)}else null!==t&&i.classList.add(t);for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(i[s]=o[s]);return i},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.make=void 0;var t=Ji;Object.defineProperty(e,"make",{enumerable:!0,get:function(){return t.make}})}(Zi),Object.defineProperty(Gi,"__esModule",{value:!0}),Gi.fragmentToString=function(e){var t=(0,Qi.make)("div");return t.appendChild(e),t.innerHTML};var Qi=Zi;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.fragmentToString=void 0;var t=Gi;Object.defineProperty(e,"fragmentToString",{enumerable:!0,get:function(){return t.fragmentToString}})}(Vi);var er={},tr={};Object.defineProperty(tr,"__esModule",{value:!0}),tr.getContentLength=function(e){var t,o;return(0,or.isNativeInput)(e)?e.value.length:e.nodeType===Node.TEXT_NODE?e.length:null!==(o=null===(t=e.textContent)||void 0===t?void 0:t.length)&&void 0!==o?o:0};var or=Ci;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.getContentLength=void 0;var t=tr;Object.defineProperty(e,"getContentLength",{enumerable:!0,get:function(){return t.getContentLength}})}(er);var nr={},ir={},rr=yi&&yi.__spreadArray||function(e,t,o){if(o||2===arguments.length)for(var n,i=0,r=t.length;i<r;i++)(n||!(i in t))&&(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))};Object.defineProperty(ir,"__esModule",{value:!0}),ir.getDeepestBlockElements=function e(t){return(0,sr.containsOnlyInlineElements)(t)?[t]:Array.from(t.children).reduce((function(t,o){return rr(rr([],t,!0),e(o),!0)}),[])};var sr=Ri;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.getDeepestBlockElements=void 0;var t=ir;Object.defineProperty(e,"getDeepestBlockElements",{enumerable:!0,get:function(){return t.getDeepestBlockElements}})}(nr);var ar={},lr={},cr={},dr={};Object.defineProperty(dr,"__esModule",{value:!0}),dr.isLineBreakTag=function(e){return["BR","WBR"].includes(e.tagName)},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.isLineBreakTag=void 0;var t=dr;Object.defineProperty(e,"isLineBreakTag",{enumerable:!0,get:function(){return t.isLineBreakTag}})}(cr);var ur={},hr={};Object.defineProperty(hr,"__esModule",{value:!0}),hr.isSingleTag=function(e){return["AREA","BASE","BR","COL","COMMAND","EMBED","HR","IMG","INPUT","KEYGEN","LINK","META","PARAM","SOURCE","TRACK","WBR"].includes(e.tagName)},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.isSingleTag=void 0;var t=hr;Object.defineProperty(e,"isSingleTag",{enumerable:!0,get:function(){return t.isSingleTag}})}(ur),Object.defineProperty(lr,"__esModule",{value:!0}),lr.getDeepestNode=function e(t,o){void 0===o&&(o=!1);var n=o?"lastChild":"firstChild",i=o?"previousSibling":"nextSibling";if(t.nodeType===Node.ELEMENT_NODE&&t[n]){var r=t[n];if((0,gr.isSingleTag)(r)&&!(0,pr.isNativeInput)(r)&&!(0,fr.isLineBreakTag)(r))if(r[i])r=r[i];else{if(null===r.parentNode||!r.parentNode[i])return r.parentNode;r=r.parentNode[i]}return e(r,o)}return t};var pr=Ci,fr=cr,gr=ur;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.getDeepestNode=void 0;var t=lr;Object.defineProperty(e,"getDeepestNode",{enumerable:!0,get:function(){return t.getDeepestNode}})}(ar);var mr={},br={},vr=yi&&yi.__spreadArray||function(e,t,o){if(o||2===arguments.length)for(var n,i=0,r=t.length;i<r;i++)(n||!(i in t))&&(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))};Object.defineProperty(br,"__esModule",{value:!0}),br.findAllInputs=function(e){return Array.from(e.querySelectorAll((0,wr.allInputsSelector)())).reduce((function(e,t){return(0,xr.isNativeInput)(t)||(0,yr.containsOnlyInlineElements)(t)?vr(vr([],e,!0),[t],!1):vr(vr([],e,!0),(0,kr.getDeepestBlockElements)(t),!0)}),[])};var yr=Ri,kr=nr,wr=xi,xr=Ci;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.findAllInputs=void 0;var t=br;Object.defineProperty(e,"findAllInputs",{enumerable:!0,get:function(){return t.findAllInputs}})}(mr);var Er={},Cr={};Object.defineProperty(Cr,"__esModule",{value:!0}),Cr.isCollapsedWhitespaces=function(e){return!/[^\t\n\r ]/.test(e)},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.isCollapsedWhitespaces=void 0;var t=Cr;Object.defineProperty(e,"isCollapsedWhitespaces",{enumerable:!0,get:function(){return t.isCollapsedWhitespaces}})}(Er);var Sr={},Tr={};Object.defineProperty(Tr,"__esModule",{value:!0}),Tr.isElement=function(e){return!(0,_r.isNumber)(e)&&(!!e&&!!e.nodeType&&e.nodeType===Node.ELEMENT_NODE)};var _r=Ki;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.isElement=void 0;var t=Tr;Object.defineProperty(e,"isElement",{enumerable:!0,get:function(){return t.isElement}})}(Sr);var Or={},Br={},Ir={},Mr={};Object.defineProperty(Mr,"__esModule",{value:!0}),Mr.isLeaf=function(e){return null!==e&&0===e.childNodes.length},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.isLeaf=void 0;var t=Mr;Object.defineProperty(e,"isLeaf",{enumerable:!0,get:function(){return t.isLeaf}})}(Ir);var Pr={},Lr={};Object.defineProperty(Lr,"__esModule",{value:!0}),Lr.isNodeEmpty=function(e,t){var o="";return!((0,Dr.isSingleTag)(e)&&!(0,Ar.isLineBreakTag)(e))&&((0,Nr.isElement)(e)&&(0,jr.isNativeInput)(e)?o=e.value:null!==e.textContent&&(o=e.textContent.replace("","")),void 0!==t&&(o=o.replace(new RegExp(t,"g"),"")),0===o.trim().length)};var Ar=cr,Nr=Sr,jr=Ci,Dr=ur;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.isNodeEmpty=void 0;var t=Lr;Object.defineProperty(e,"isNodeEmpty",{enumerable:!0,get:function(){return t.isNodeEmpty}})}(Pr),Object.defineProperty(Br,"__esModule",{value:!0}),Br.isEmpty=function(e,t){e.normalize();for(var o=[e];o.length>0;){var n=o.shift();if(n){if(e=n,(0,Rr.isLeaf)(e)&&!(0,Fr.isNodeEmpty)(e,t))return!1;o.push.apply(o,Array.from(e.childNodes))}}return!0};var Rr=Ir,Fr=Pr;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.isEmpty=void 0;var t=Br;Object.defineProperty(e,"isEmpty",{enumerable:!0,get:function(){return t.isEmpty}})}(Or);var Hr={},Ur={};Object.defineProperty(Ur,"__esModule",{value:!0}),Ur.isFragment=function(e){return!(0,zr.isNumber)(e)&&(!!e&&!!e.nodeType&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE)};var zr=Ki;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.isFragment=void 0;var t=Ur;Object.defineProperty(e,"isFragment",{enumerable:!0,get:function(){return t.isFragment}})}(Hr);var Wr={},$r={};Object.defineProperty($r,"__esModule",{value:!0}),$r.isHTMLString=function(e){var t=(0,qr.make)("div");return t.innerHTML=e,t.childElementCount>0};var qr=Zi;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.isHTMLString=void 0;var t=$r;Object.defineProperty(e,"isHTMLString",{enumerable:!0,get:function(){return t.isHTMLString}})}(Wr);var Kr={},Yr={};Object.defineProperty(Yr,"__esModule",{value:!0}),Yr.offset=function(e){var t=e.getBoundingClientRect(),o=window.pageXOffset||document.documentElement.scrollLeft,n=window.pageYOffset||document.documentElement.scrollTop,i=t.top+n,r=t.left+o;return{top:i,left:r,bottom:i+t.height,right:r+t.width}},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.offset=void 0;var t=Yr;Object.defineProperty(e,"offset",{enumerable:!0,get:function(){return t.offset}})}(Kr);var Xr={},Vr={};Object.defineProperty(Vr,"__esModule",{value:!0}),Vr.prepend=function(e,t){Array.isArray(t)?(t=t.reverse()).forEach((function(t){return e.prepend(t)})):e.prepend(t)},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.prepend=void 0;var t=Vr;Object.defineProperty(e,"prepend",{enumerable:!0,get:function(){return t.prepend}})}(Xr),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.prepend=e.offset=e.make=e.isLineBreakTag=e.isSingleTag=e.isNodeEmpty=e.isLeaf=e.isHTMLString=e.isFragment=e.isEmpty=e.isElement=e.isContentEditable=e.isCollapsedWhitespaces=e.findAllInputs=e.isNativeInput=e.allInputsSelector=e.getDeepestNode=e.getDeepestBlockElements=e.getContentLength=e.fragmentToString=e.containsOnlyInlineElements=e.canSetCaret=e.calculateBaseline=e.blockElements=e.append=void 0;var t=xi;Object.defineProperty(e,"allInputsSelector",{enumerable:!0,get:function(){return t.allInputsSelector}});var o=Ci;Object.defineProperty(e,"isNativeInput",{enumerable:!0,get:function(){return o.isNativeInput}});var n=Ti;Object.defineProperty(e,"append",{enumerable:!0,get:function(){return n.append}});var i=Oi;Object.defineProperty(e,"blockElements",{enumerable:!0,get:function(){return i.blockElements}});var r=Ii;Object.defineProperty(e,"calculateBaseline",{enumerable:!0,get:function(){return r.calculateBaseline}});var s=Pi;Object.defineProperty(e,"canSetCaret",{enumerable:!0,get:function(){return s.canSetCaret}});var a=Ri;Object.defineProperty(e,"containsOnlyInlineElements",{enumerable:!0,get:function(){return a.containsOnlyInlineElements}});var l=Vi;Object.defineProperty(e,"fragmentToString",{enumerable:!0,get:function(){return l.fragmentToString}});var c=er;Object.defineProperty(e,"getContentLength",{enumerable:!0,get:function(){return c.getContentLength}});var d=nr;Object.defineProperty(e,"getDeepestBlockElements",{enumerable:!0,get:function(){return d.getDeepestBlockElements}});var u=ar;Object.defineProperty(e,"getDeepestNode",{enumerable:!0,get:function(){return u.getDeepestNode}});var h=mr;Object.defineProperty(e,"findAllInputs",{enumerable:!0,get:function(){return h.findAllInputs}});var p=Er;Object.defineProperty(e,"isCollapsedWhitespaces",{enumerable:!0,get:function(){return p.isCollapsedWhitespaces}});var f=Ai;Object.defineProperty(e,"isContentEditable",{enumerable:!0,get:function(){return f.isContentEditable}});var g=Sr;Object.defineProperty(e,"isElement",{enumerable:!0,get:function(){return g.isElement}});var m=Or;Object.defineProperty(e,"isEmpty",{enumerable:!0,get:function(){return m.isEmpty}});var b=Hr;Object.defineProperty(e,"isFragment",{enumerable:!0,get:function(){return b.isFragment}});var v=Wr;Object.defineProperty(e,"isHTMLString",{enumerable:!0,get:function(){return v.isHTMLString}});var y=Ir;Object.defineProperty(e,"isLeaf",{enumerable:!0,get:function(){return y.isLeaf}});var k=Pr;Object.defineProperty(e,"isNodeEmpty",{enumerable:!0,get:function(){return k.isNodeEmpty}});var w=cr;Object.defineProperty(e,"isLineBreakTag",{enumerable:!0,get:function(){return w.isLineBreakTag}});var x=ur;Object.defineProperty(e,"isSingleTag",{enumerable:!0,get:function(){return x.isSingleTag}});var E=Zi;Object.defineProperty(e,"make",{enumerable:!0,get:function(){return E.make}});var C=Kr;Object.defineProperty(e,"offset",{enumerable:!0,get:function(){return C.offset}});var S=Xr;Object.defineProperty(e,"prepend",{enumerable:!0,get:function(){return S.prepend}})}(wi);const Gr="cdx-list",Zr={wrapper:Gr,item:`${Gr}__item`,itemContent:`${Gr}__item-content`,itemChildren:`${Gr}__item-children`};let Jr=class e{static get CSS(){return{...Zr,orderedList:`${Gr}-ordered`}}constructor(e,t){this.config=t,this.readOnly=e}renderWrapper(t){let o;return o=!0===t?wi.make("ol",[e.CSS.wrapper,e.CSS.orderedList]):wi.make("ol",[e.CSS.orderedList,e.CSS.itemChildren]),o}renderItem(t,o){const n=wi.make("li",e.CSS.item),i=wi.make("div",e.CSS.itemContent,{innerHTML:t,contentEditable:(!this.readOnly).toString()});return n.appendChild(i),n}getItemContent(t){const o=t.querySelector(`.${e.CSS.itemContent}`);return!o||wi.isEmpty(o)?"":o.innerHTML}getItemMeta(){return{}}composeDefaultMeta(){return{}}},Qr=class e{static get CSS(){return{...Zr,unorderedList:`${Gr}-unordered`}}constructor(e,t){this.config=t,this.readOnly=e}renderWrapper(t){let o;return o=!0===t?wi.make("ul",[e.CSS.wrapper,e.CSS.unorderedList]):wi.make("ul",[e.CSS.unorderedList,e.CSS.itemChildren]),o}renderItem(t,o){const n=wi.make("li",e.CSS.item),i=wi.make("div",e.CSS.itemContent,{innerHTML:t,contentEditable:(!this.readOnly).toString()});return n.appendChild(i),n}getItemContent(t){const o=t.querySelector(`.${e.CSS.itemContent}`);return!o||wi.isEmpty(o)?"":o.innerHTML}getItemMeta(){return{}}composeDefaultMeta(){return{}}};function es(e){return e.nodeType===Node.ELEMENT_NODE}var ts={},os={},ns={},is={};Object.defineProperty(is,"__esModule",{value:!0}),is.getContenteditableSlice=function(e,t,o,n,i){var r;void 0===i&&(i=!1);var s=document.createRange();if("left"===n?(s.setStart(e,0),s.setEnd(t,o)):(s.setStart(t,o),s.setEnd(e,e.childNodes.length)),!0===i){var a=s.extractContents();return(0,rs.fragmentToString)(a)}var l=s.cloneContents(),c=document.createElement("div");return c.appendChild(l),null!==(r=c.textContent)&&void 0!==r?r:""};var rs=wi;Object.defineProperty(ns,"__esModule",{value:!0}),ns.checkContenteditableSliceForEmptiness=function(e,t,o,n){var i=(0,as.getContenteditableSlice)(e,t,o,n);return(0,ss.isCollapsedWhitespaces)(i)};var ss=wi,as=is;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.checkContenteditableSliceForEmptiness=void 0;var t=ns;Object.defineProperty(e,"checkContenteditableSliceForEmptiness",{enumerable:!0,get:function(){return t.checkContenteditableSliceForEmptiness}})}(os);var ls={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.getContenteditableSlice=void 0;var t=is;Object.defineProperty(e,"getContenteditableSlice",{enumerable:!0,get:function(){return t.getContenteditableSlice}})}(ls);var cs={},ds={};Object.defineProperty(ds,"__esModule",{value:!0}),ds.focus=function(e,t){var o,n;if(void 0===t&&(t=!0),(0,us.isNativeInput)(e)){e.focus();var i=t?0:e.value.length;e.setSelectionRange(i,i)}else{var r=document.createRange(),s=window.getSelection();if(!s)return;var a=function(e,t){void 0===t&&(t=!1);var o=document.createTextNode("");t?e.insertBefore(o,e.firstChild):e.appendChild(o),r.setStart(o,0),r.setEnd(o,0)},l=function(e){return null!=e},c=e.childNodes,d=t?c[0]:c[c.length-1];if(l(d)){for(;l(d)&&d.nodeType!==Node.TEXT_NODE;)d=t?d.firstChild:d.lastChild;if(l(d)&&d.nodeType===Node.TEXT_NODE){var u=null!==(n=null===(o=d.textContent)||void 0===o?void 0:o.length)&&void 0!==n?n:0;i=t?0:u;r.setStart(d,i),r.setEnd(d,i)}else a(e,t)}else a(e);s.removeAllRanges(),s.addRange(r)}};var us=wi;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.focus=void 0;var t=ds;Object.defineProperty(e,"focus",{enumerable:!0,get:function(){return t.focus}})}(cs);var hs={},ps={};Object.defineProperty(ps,"__esModule",{value:!0}),ps.getCaretNodeAndOffset=function(){var e=window.getSelection();if(null===e)return[null,0];var t=e.focusNode,o=e.focusOffset;return null===t?[null,0]:(t.nodeType!==Node.TEXT_NODE&&t.childNodes.length>0&&(void 0!==t.childNodes[o]?(t=t.childNodes[o],o=0):null!==(t=t.childNodes[o-1]).textContent&&(o=t.textContent.length)),[t,o])},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.getCaretNodeAndOffset=void 0;var t=ps;Object.defineProperty(e,"getCaretNodeAndOffset",{enumerable:!0,get:function(){return t.getCaretNodeAndOffset}})}(hs);var fs={},gs={};Object.defineProperty(gs,"__esModule",{value:!0}),gs.getRange=function(){var e=window.getSelection();return e&&e.rangeCount?e.getRangeAt(0):null},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.getRange=void 0;var t=gs;Object.defineProperty(e,"getRange",{enumerable:!0,get:function(){return t.getRange}})}(fs);var ms={},bs={};Object.defineProperty(bs,"__esModule",{value:!0}),bs.isCaretAtEndOfInput=function(e){var t=(0,vs.getDeepestNode)(e,!0);if(null===t)return!0;if((0,vs.isNativeInput)(t))return t.selectionEnd===t.value.length;var o=(0,ys.getCaretNodeAndOffset)(),n=o[0],i=o[1];return null!==n&&(0,ks.checkContenteditableSliceForEmptiness)(e,n,i,"right")};var vs=wi,ys=hs,ks=os;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.isCaretAtEndOfInput=void 0;var t=bs;Object.defineProperty(e,"isCaretAtEndOfInput",{enumerable:!0,get:function(){return t.isCaretAtEndOfInput}})}(ms);var ws={},xs={};Object.defineProperty(xs,"__esModule",{value:!0}),xs.isCaretAtStartOfInput=function(e){var t=(0,Es.getDeepestNode)(e);if(null===t||(0,Es.isEmpty)(e))return!0;if((0,Es.isNativeInput)(t))return 0===t.selectionEnd;if((0,Es.isEmpty)(e))return!0;var o=(0,Cs.getCaretNodeAndOffset)(),n=o[0],i=o[1];return null!==n&&(0,Ss.checkContenteditableSliceForEmptiness)(e,n,i,"left")};var Es=wi,Cs=ps,Ss=ns;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.isCaretAtStartOfInput=void 0;var t=xs;Object.defineProperty(e,"isCaretAtStartOfInput",{enumerable:!0,get:function(){return t.isCaretAtStartOfInput}})}(ws);var Ts={},_s={};Object.defineProperty(_s,"__esModule",{value:!0}),_s.save=function(){var e=(0,Bs.getRange)(),t=(0,Os.make)("span");if(t.id="cursor",t.hidden=!0,e)return e.insertNode(t),function(){var o=window.getSelection();o&&(e.setStartAfter(t),e.setEndAfter(t),o.removeAllRanges(),o.addRange(e),setTimeout((function(){t.remove()}),150))}};var Os=wi,Bs=gs;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.save=void 0;var t=_s;Object.defineProperty(e,"save",{enumerable:!0,get:function(){return t.save}})}(Ts),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.save=e.isCaretAtStartOfInput=e.isCaretAtEndOfInput=e.getRange=e.getCaretNodeAndOffset=e.focus=e.getContenteditableSlice=e.checkContenteditableSliceForEmptiness=void 0;var t=os;Object.defineProperty(e,"checkContenteditableSliceForEmptiness",{enumerable:!0,get:function(){return t.checkContenteditableSliceForEmptiness}});var o=ls;Object.defineProperty(e,"getContenteditableSlice",{enumerable:!0,get:function(){return o.getContenteditableSlice}});var n=cs;Object.defineProperty(e,"focus",{enumerable:!0,get:function(){return n.focus}});var i=hs;Object.defineProperty(e,"getCaretNodeAndOffset",{enumerable:!0,get:function(){return i.getCaretNodeAndOffset}});var r=fs;Object.defineProperty(e,"getRange",{enumerable:!0,get:function(){return r.getRange}});var s=ms;Object.defineProperty(e,"isCaretAtEndOfInput",{enumerable:!0,get:function(){return s.isCaretAtEndOfInput}});var a=ws;Object.defineProperty(e,"isCaretAtStartOfInput",{enumerable:!0,get:function(){return a.isCaretAtStartOfInput}});var l=Ts;Object.defineProperty(e,"save",{enumerable:!0,get:function(){return l.save}})}(ts);class Is{static get CSS(){return{...Zr,checklist:`${Gr}-checklist`,itemChecked:`${Gr}__checkbox--checked`,noHover:`${Gr}__checkbox--no-hover`,checkbox:`${Gr}__checkbox-check`,checkboxContainer:`${Gr}__checkbox`}}constructor(e,t){this.config=t,this.readOnly=e}renderWrapper(e){let t;return!0===e?(t=wi.make("ul",[Is.CSS.wrapper,Is.CSS.checklist]),t.addEventListener("click",(e=>{const t=e.target;if(t){const e=t.closest(`.${Is.CSS.checkboxContainer}`);e&&e.contains(t)&&this.toggleCheckbox(e)}}))):t=wi.make("ul",[Is.CSS.checklist,Is.CSS.itemChildren]),t}renderItem(e,t){const o=wi.make("li",[Is.CSS.item,Is.CSS.item]),n=wi.make("div",Is.CSS.itemContent,{innerHTML:e,contentEditable:(!this.readOnly).toString()}),i=wi.make("span",Is.CSS.checkbox),r=wi.make("div",Is.CSS.checkboxContainer);return!0===t.checked&&r.classList.add(Is.CSS.itemChecked),i.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M7 12L10.4884 15.8372C10.5677 15.9245 10.705 15.9245 10.7844 15.8372L17 9"/></svg>',r.appendChild(i),o.appendChild(r),o.appendChild(n),o}getItemContent(e){const t=e.querySelector(`.${Is.CSS.itemContent}`);return!t||wi.isEmpty(t)?"":t.innerHTML}getItemMeta(e){const t=e.querySelector(`.${Is.CSS.checkboxContainer}`);return{checked:!!t&&t.classList.contains(Is.CSS.itemChecked)}}composeDefaultMeta(){return{checked:!1}}toggleCheckbox(e){e.classList.toggle(Is.CSS.itemChecked),e.classList.add(Is.CSS.noHover),e.addEventListener("mouseleave",(()=>this.removeSpecialHoverBehavior(e)),{once:!0})}removeSpecialHoverBehavior(e){e.classList.remove(Is.CSS.noHover)}}function Ms(e,t="after"){const o=[];let n;function i(e){switch(t){case"after":return e.nextElementSibling;case"before":return e.previousElementSibling}}for(n=i(e);null!==n;)o.push(n),n=i(n);return 0!==o.length?o:null}function Ps(e,t=!0){let o=e;return e.classList.contains(Zr.item)&&(o=e.querySelector(`.${Zr.itemChildren}`)),null===o?[]:t?Array.from(o.querySelectorAll(`:scope > .${Zr.item}`)):Array.from(o.querySelectorAll(`.${Zr.item}`))}function Ls(e){return e.querySelector(`.${Zr.itemChildren}`)}function As(e){let t=e;e.classList.contains(Zr.item)&&(t=Ls(e)),null!==t&&0===Ps(t).length&&t.remove()}function Ns(e){return e.querySelector(`.${Zr.itemContent}`)}function js(e,t=!0){const o=Ns(e);o&&ts.focus(o,t)}let Ds=class{get currentItem(){const e=window.getSelection();if(!e)return null;let t=e.anchorNode;return t&&(es(t)||(t=t.parentNode),t)&&es(t)?t.closest(`.${Zr.item}`):null}get currentItemLevel(){const e=this.currentItem;if(null===e)return null;let t=e.parentNode,o=0;for(;null!==t&&t!==this.listWrapper;)es(t)&&t.classList.contains(Zr.item)&&(o+=1),t=t.parentNode;return o+1}constructor({data:e,config:t,api:o,readOnly:n,block:i},r){this.config=t,this.data=e,this.readOnly=n,this.api=o,this.block=i,this.renderer=r}render(){return this.listWrapper=this.renderer.renderWrapper(!0),this.data.items.length?this.appendItems(this.data.items,this.listWrapper):this.appendItems([{content:"",meta:{},items:[]}],this.listWrapper),this.readOnly||this.listWrapper.addEventListener("keydown",(e=>{switch(e.key){case"Enter":e.shiftKey||this.enterPressed(e);break;case"Backspace":this.backspace(e);break;case"Tab":e.shiftKey?this.shiftTab(e):this.addTab(e)}}),!1),"start"in this.data.meta&&void 0!==this.data.meta.start&&this.changeStartWith(this.data.meta.start),"counterType"in this.data.meta&&void 0!==this.data.meta.counterType&&this.changeCounters(this.data.meta.counterType),this.listWrapper}save(e){const t=e??this.listWrapper,o=e=>Ps(e).map((e=>{const t=Ls(e);return{content:this.renderer.getItemContent(e),meta:this.renderer.getItemMeta(e),items:t?o(t):[]}})),n=t?o(t):[];let i={style:this.data.style,meta:{},items:n};return"ordered"===this.data.style&&(i.meta={start:this.data.meta.start,counterType:this.data.meta.counterType}),i}static get pasteConfig(){return{tags:["OL","UL","LI"]}}merge(e){const t=this.block.holder.querySelectorAll(`.${Zr.item}`),o=t[t.length-1],n=Ns(o);if(null===o||null===n||(n.insertAdjacentHTML("beforeend",e.items[0].content),void 0===this.listWrapper))return;const i=Ps(this.listWrapper);if(0===i.length)return;let r=Ls(i[i.length-1]);const s=e.items.shift();void 0!==s&&(0!==s.items.length&&(null===r&&(r=this.renderer.renderWrapper(!1)),this.appendItems(s.items,r)),e.items.length>0&&this.appendItems(e.items,this.listWrapper))}onPaste(e){const t=e.detail.data;this.data=this.pasteHandler(t);const o=this.listWrapper;o&&o.parentNode&&o.parentNode.replaceChild(this.render(),o)}pasteHandler(e){const{tagName:t}=e;let o,n="unordered";switch(t){case"OL":n="ordered",o="ol";break;case"UL":case"LI":n="unordered",o="ul"}const i={style:n,meta:{},items:[]};"ordered"===n&&(this.data.meta.counterType="numeric",this.data.meta.start=1);const r=e=>Array.from(e.querySelectorAll(":scope > li")).map((e=>{const t=e.querySelector(`:scope > ${o}`),n=t?r(t):[];return{content:e.innerHTML??"",meta:{},items:n}}));return i.items=r(e),i}changeStartWith(e){this.listWrapper.style.setProperty("counter-reset","item "+(e-1)),this.data.meta.start=e}changeCounters(e){this.listWrapper.style.setProperty("--list-counter-type",e),this.data.meta.counterType=e}enterPressed(e){var t;const o=this.currentItem;if(e.stopPropagation(),e.preventDefault(),e.isComposing||null===o)return;const n=0===(null==(t=this.renderer)?void 0:t.getItemContent(o).trim().length),i=o.parentNode===this.listWrapper,r=null===o.previousElementSibling,s=this.api.blocks.getCurrentBlockIndex();if(i&&n)return null!==o.nextElementSibling||function(e){return null!==e.querySelector(`.${Zr.itemChildren}`)}(o)?void this.splitList(o):void(r?this.convertItemToDefaultBlock(s,!0):this.convertItemToDefaultBlock());n?this.unshiftItem(o):this.splitItem(o)}backspace(e){var t;const o=this.currentItem;if(null!==o&&ts.isCaretAtStartOfInput(o)&&!1!==(null==(t=window.getSelection())?void 0:t.isCollapsed)){if(e.stopPropagation(),o.parentNode===this.listWrapper&&null===o.previousElementSibling)return void this.convertFirstItemToDefaultBlock();e.preventDefault(),this.mergeItemWithPrevious(o)}}shiftTab(e){e.stopPropagation(),e.preventDefault(),null!==this.currentItem&&this.unshiftItem(this.currentItem)}unshiftItem(e){if(!e.parentNode||!es(e.parentNode))return;const t=e.parentNode.closest(`.${Zr.item}`);if(!t)return;let o=Ls(e);if(null===e.parentElement)return;const n=Ms(e);null!==n&&(null===o&&(o=this.renderer.renderWrapper(!1)),n.forEach((e=>{o.appendChild(e)})),e.appendChild(o)),t.after(e),js(e,!1),As(t)}splitList(e){const t=Ps(e),o=this.block,n=this.api.blocks.getCurrentBlockIndex();if(0!==t.length){const o=t[0];this.unshiftItem(o),js(e,!1)}if(null===e.previousElementSibling&&e.parentNode===this.listWrapper)return void this.convertItemToDefaultBlock(n);const i=Ms(e);if(null===i)return;const r=this.renderer.renderWrapper(!0);i.forEach((e=>{r.appendChild(e)}));const s=this.save(r);s.meta.start="ordered"==this.data.style?1:void 0,this.api.blocks.insert(null==o?void 0:o.name,s,this.config,n+1),this.convertItemToDefaultBlock(n+1),r.remove()}splitItem(e){const[t,o]=ts.getCaretNodeAndOffset();if(null===t)return;const n=Ns(e);let i;i=null===n?"":ts.getContenteditableSlice(n,t,o,"right",!0);const r=Ls(e),s=this.renderItem(i);null==e||e.after(s),r&&s.appendChild(r),js(s)}mergeItemWithPrevious(e){const t=e.previousElementSibling,o=e.parentNode;if(null===o||!es(o))return;const n=o.closest(`.${Zr.item}`);if(!t&&!n||t&&!es(t))return;let i;if(t){const e=Ps(t,!1);i=0!==e.length&&0!==e.length?e[e.length-1]:t}else i=n;const r=this.renderer.getItemContent(e);if(!i)return;js(i,!1);const s=Ns(i);if(null===s)return;s.insertAdjacentHTML("beforeend",r);const a=Ps(e);if(0===a.length)return e.remove(),void As(i);const l=t||n,c=Ls(l)??this.renderer.renderWrapper(!1);t?a.forEach((e=>{c.appendChild(e)})):a.forEach((e=>{c.prepend(e)})),null===Ls(l)&&i.appendChild(c),e.remove()}addTab(e){var t;e.stopPropagation(),e.preventDefault();const o=this.currentItem;if(!o)return;if(void 0!==(null==(t=this.config)?void 0:t.maxLevel)){const e=this.currentItemLevel;if(null!==e&&e===this.config.maxLevel)return}const n=o.previousSibling;if(null===n||!es(n))return;const i=Ls(n);if(i)i.appendChild(o),Ps(o).forEach((e=>{i.appendChild(e)}));else{const e=this.renderer.renderWrapper(!1);e.appendChild(o),Ps(o).forEach((t=>{e.appendChild(t)})),n.appendChild(e)}As(o),js(o,!1)}convertItemToDefaultBlock(e,t){let o;const n=this.currentItem,i=null!==n?this.renderer.getItemContent(n):"";!0===t&&this.api.blocks.delete(),o=void 0!==e?this.api.blocks.insert(void 0,{text:i},void 0,e):this.api.blocks.insert(),null==n||n.remove(),this.api.caret.setToBlock(o,"start")}convertFirstItemToDefaultBlock(){const e=this.currentItem;if(null===e)return;const t=Ps(e);if(0!==t.length){const o=t[0];this.unshiftItem(o),js(e)}const o=Ms(e),n=this.api.blocks.getCurrentBlockIndex(),i=null===o;this.convertItemToDefaultBlock(n,i)}renderItem(e,t){const o=t??this.renderer.composeDefaultMeta();switch(!0){case this.renderer instanceof Jr:case this.renderer instanceof Qr:}return this.renderer.renderItem(e,o)}appendItems(e,t){e.forEach((e=>{var o;const n=this.renderItem(e.content,e.meta);if(t.appendChild(n),e.items.length){const t=null==(o=this.renderer)?void 0:o.renderWrapper(!1);this.appendItems(e.items,t),n.appendChild(t)}}))}};const Rs={wrapper:`${Gr}-start-with-field`,input:`${Gr}-start-with-field__input`,startWithElementWrapperInvalid:`${Gr}-start-with-field--invalid`};const Fs=new Map([["Numeric","numeric"],["Lower Roman","lower-roman"],["Upper Roman","upper-roman"],["Lower Alpha","lower-alpha"],["Upper Alpha","upper-alpha"]]),Hs=new Map([["numeric",'<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M10 14.2L10 7.4135C10 7.32872 9.90111 7.28241 9.83598 7.33668L7 9.7" stroke="black" stroke-width="1.6" stroke-linecap="round"/><path d="M13.2087 14.2H13.2" stroke="black" stroke-width="1.6" stroke-linecap="round"/></svg>'],["lower-roman",'<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M13.2087 14.2H13.2" stroke="black" stroke-width="1.6" stroke-linecap="round"/><path d="M10 14.2L10 9.5" stroke="black" stroke-width="1.6" stroke-linecap="round"/><path d="M10 7.01L10 7" stroke="black" stroke-width="1.8" stroke-linecap="round"/></svg>'],["upper-roman",'<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M13.2087 14.2H13.2" stroke="black" stroke-width="1.6" stroke-linecap="round"/><path d="M10 14.2L10 7.2" stroke="black" stroke-width="1.6" stroke-linecap="round"/></svg>'],["lower-alpha",'<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M14.2087 14.2H14.2" stroke="black" stroke-width="1.6" stroke-linecap="round"/><path d="M11.5 14.5C11.5 14.5 11 13.281 11 12.5M7 9.5C7 9.5 7.5 8.5 9 8.5C10.5 8.5 11 9.5 11 10.5L11 11.5M11 11.5L11 12.5M11 11.5C11 11.5 7 11 7 13C7 15.3031 11 15 11 12.5" stroke="black" stroke-width="1.6" stroke-linecap="round"/></svg>'],["upper-alpha",'<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M16.0087 14.2H16" stroke="black" stroke-width="1.6" stroke-linecap="round"/><path d="M7 14.2L7.78865 12M13 14.2L12.1377 12M7.78865 12C7.78865 12 9.68362 7 10 7C10.3065 7 12.1377 12 12.1377 12M7.78865 12L12.1377 12" stroke="black" stroke-width="1.6" stroke-linecap="round"/></svg>']]);let Us=class e{static get isReadOnlySupported(){return!0}static get enableLineBreaks(){return!0}static get toolbox(){return[{icon:bi,title:"Unordered List",data:{style:"unordered"}},{icon:vi,title:"Ordered List",data:{style:"ordered"}},{icon:mi,title:"Checklist",data:{style:"checklist"}}]}static get pasteConfig(){return{tags:["OL","UL","LI"]}}static get conversionConfig(){return{export:t=>e.joinRecursive(t),import:(e,t)=>({meta:{},items:[{content:e,meta:{},items:[]}],style:void 0!==(null==t?void 0:t.defaultStyle)?t.defaultStyle:"unordered"})}}get listStyle(){return this.data.style||this.defaultListStyle}set listStyle(e){var t;this.data.style=e,this.changeTabulatorByStyle();const o=this.list.render();null==(t=this.listElement)||t.replaceWith(o),this.listElement=o}constructor({data:e,config:t,api:o,readOnly:n,block:i}){var r;this.api=o,this.readOnly=n,this.config=t,this.block=i,this.defaultListStyle=(null==(r=this.config)?void 0:r.defaultStyle)||"unordered",this.defaultCounterTypes=this.config.counterTypes||Array.from(Fs.values());const s={style:this.defaultListStyle,meta:{},items:[]};this.data=Object.keys(e).length?function(e){const t=[];return function(e){return"string"==typeof e.items[0]}(e)?(e.items.forEach((e=>{t.push({content:e,meta:{},items:[]})})),{style:e.style,meta:{},items:t}):function(e){return"string"!=typeof e.items[0]&&"text"in e.items[0]&&"checked"in e.items[0]&&"string"==typeof e.items[0].text&&"boolean"==typeof e.items[0].checked}(e)?(e.items.forEach((e=>{t.push({content:e.text,meta:{checked:e.checked},items:[]})})),{style:"checklist",meta:{},items:t}):function(e){return!("meta"in e)}(e)?{style:e.style,meta:{},items:e.items}:structuredClone(e)}(e):s,"ordered"===this.listStyle&&void 0===this.data.meta.counterType&&(this.data.meta.counterType="numeric"),this.changeTabulatorByStyle()}static joinRecursive(t){return t.items.map((t=>`${t.content} ${e.joinRecursive(t)}`)).join("")}render(){return this.listElement=this.list.render(),this.listElement}save(){return this.data=this.list.save(),this.data}merge(e){this.list.merge(e)}renderSettings(){const e=[{label:this.api.i18n.t("Unordered"),icon:bi,closeOnActivate:!0,isActive:"unordered"==this.listStyle,onActivate:()=>{this.listStyle="unordered"}},{label:this.api.i18n.t("Ordered"),icon:vi,closeOnActivate:!0,isActive:"ordered"==this.listStyle,onActivate:()=>{this.listStyle="ordered"}},{label:this.api.i18n.t("Checklist"),icon:mi,closeOnActivate:!0,isActive:"checklist"==this.listStyle,onActivate:()=>{this.listStyle="checklist"}}];if("ordered"===this.listStyle){const t=function(e,{value:t,placeholder:o,attributes:n,sanitize:i}){const r=wi.make("div",Rs.wrapper),s=wi.make("input",Rs.input,{placeholder:o,tabIndex:-1,value:t});for(const a in n)s.setAttribute(a,n[a]);return r.appendChild(s),s.addEventListener("input",(()=>{void 0!==i&&(s.value=i(s.value));const t=s.checkValidity();!t&&!r.classList.contains(Rs.startWithElementWrapperInvalid)&&r.classList.add(Rs.startWithElementWrapperInvalid),t&&r.classList.contains(Rs.startWithElementWrapperInvalid)&&r.classList.remove(Rs.startWithElementWrapperInvalid),t&&e(s.value)})),r}((e=>this.changeStartWith(Number(e))),{value:String(this.data.meta.start??1),placeholder:"",attributes:{required:"true"},sanitize:e=>e.replace(/\D+/g,"")}),o=[{label:this.api.i18n.t("Start with"),icon:'<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M8 14.2L8 7.4135C8 7.32872 7.90111 7.28241 7.83598 7.33668L5 9.7" stroke="black" stroke-width="1.6" stroke-linecap="round"/><path d="M14 13L16.4167 10.7778M16.4167 10.7778L14 8.5M16.4167 10.7778H11.6562" stroke="black" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>',children:{items:[{element:t,type:"html"}]}}],n={label:this.api.i18n.t("Counter type"),icon:Hs.get(this.data.meta.counterType),children:{items:[]}};Fs.forEach(((e,t)=>{const o=Fs.get(t);this.defaultCounterTypes.includes(o)&&n.children.items.push({title:this.api.i18n.t(t),icon:Hs.get(o),isActive:this.data.meta.counterType===Fs.get(t),closeOnActivate:!0,onActivate:()=>{this.changeCounters(Fs.get(t))}})})),n.children.items.length>1&&o.push(n),e.push({type:"separator"},...o)}return e}onPaste(e){const{tagName:t}=e.detail.data;switch(t){case"OL":this.listStyle="ordered";break;case"UL":case"LI":this.listStyle="unordered"}this.list.onPaste(e)}pasteHandler(e){return this.list.pasteHandler(e)}changeCounters(e){var t;null==(t=this.list)||t.changeCounters(e),this.data.meta.counterType=e}changeStartWith(e){var t;null==(t=this.list)||t.changeStartWith(e),this.data.meta.start=e}changeTabulatorByStyle(){switch(this.listStyle){case"ordered":this.list=new Ds({data:this.data,readOnly:this.readOnly,api:this.api,config:this.config,block:this.block},new Jr(this.readOnly,this.config));break;case"unordered":this.list=new Ds({data:this.data,readOnly:this.readOnly,api:this.api,config:this.config,block:this.block},new Qr(this.readOnly,this.config));break;case"checklist":this.list=new Ds({data:this.data,readOnly:this.readOnly,api:this.api,config:this.config,block:this.block},new Is(this.readOnly,this.config))}}};!function(){try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".ce-paragraph{line-height:1.6em;outline:none}.ce-block:only-of-type .ce-paragraph[data-placeholder-active]:empty:before,.ce-block:only-of-type .ce-paragraph[data-placeholder-active][data-empty=true]:before{content:attr(data-placeholder-active)}.ce-paragraph p:first-of-type{margin-top:0}.ce-paragraph p:last-of-type{margin-bottom:0}")),document.head.appendChild(e)}}catch(t){}}();
|
||
/**
|
||
* Base Paragraph Block for the Editor.js.
|
||
* Represents a regular text block
|
||
*
|
||
* @author CodeX (team@codex.so)
|
||
* @copyright CodeX 2018
|
||
* @license The MIT License (MIT)
|
||
*/
|
||
class zs{static get DEFAULT_PLACEHOLDER(){return""}constructor({data:e,config:t,api:o,readOnly:n}){this.api=o,this.readOnly=n,this._CSS={block:this.api.styles.block,wrapper:"ce-paragraph"},this.readOnly||(this.onKeyUp=this.onKeyUp.bind(this)),this._placeholder=t.placeholder?t.placeholder:zs.DEFAULT_PLACEHOLDER,this._data=e??{},this._element=null,this._preserveBlank=t.preserveBlank??!1}onKeyUp(e){if("Backspace"!==e.code&&"Delete"!==e.code||!this._element)return;const{textContent:t}=this._element;""===t&&(this._element.innerHTML="")}drawView(){const e=document.createElement("DIV");return e.classList.add(this._CSS.wrapper,this._CSS.block),e.contentEditable="false",e.dataset.placeholderActive=this.api.i18n.t(this._placeholder),this._data.text&&(e.innerHTML=this._data.text),this.readOnly||(e.contentEditable="true",e.addEventListener("keyup",this.onKeyUp)),e}render(){return this._element=this.drawView(),this._element}merge(e){if(!this._element)return;this._data.text+=e.text;const t=function(e){const t=document.createElement("div");t.innerHTML=e.trim();const o=document.createDocumentFragment();return o.append(...Array.from(t.childNodes)),o}(e.text);this._element.appendChild(t),this._element.normalize()}validate(e){return!(""===e.text.trim()&&!this._preserveBlank)}save(e){return{text:e.innerHTML}}onPaste(e){const t={text:e.detail.data.innerHTML};this._data=t,window.requestAnimationFrame((()=>{this._element&&(this._element.innerHTML=this._data.text||"")}))}static get conversionConfig(){return{export:"text",import:"text"}}static get sanitize(){return{text:{br:!0}}}static get isReadOnlySupported(){return!0}static get pasteConfig(){return{tags:["P"]}}static get toolbox(){return{icon:'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M8 9V7.2C8 7.08954 8.08954 7 8.2 7L12 7M16 9V7.2C16 7.08954 15.9105 7 15.8 7L12 7M12 7L12 17M12 17H10M12 17H14"/></svg>',title:"Text"}}}!function(){try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode('.image-tool{--bg-color: #cdd1e0;--front-color: #388ae5;--border-color: #e8e8eb}.image-tool__image{border-radius:3px;overflow:hidden;margin-bottom:10px;padding-bottom:0}.image-tool__image-picture{max-width:100%;vertical-align:bottom;display:block}.image-tool__image-preloader{width:50px;height:50px;border-radius:50%;background-size:cover;margin:auto;position:relative;background-color:var(--bg-color);background-position:center center}.image-tool__image-preloader:after{content:"";position:absolute;z-index:3;width:60px;height:60px;border-radius:50%;border:2px solid var(--bg-color);border-top-color:var(--front-color);left:50%;top:50%;margin-top:-30px;margin-left:-30px;animation:image-preloader-spin 2s infinite linear;box-sizing:border-box}.image-tool__caption{visibility:hidden;position:absolute;bottom:0;left:0;margin-bottom:10px}.image-tool__caption[contentEditable=true][data-placeholder]:before{position:absolute!important;content:attr(data-placeholder);color:#707684;font-weight:400;display:none}.image-tool__caption[contentEditable=true][data-placeholder]:empty:before{display:block}.image-tool__caption[contentEditable=true][data-placeholder]:empty:focus:before{display:none}.image-tool--empty .image-tool__image,.image-tool--empty .image-tool__image-preloader{display:none}.image-tool--empty .image-tool__caption,.image-tool--uploading .image-tool__caption{visibility:hidden!important}.image-tool .cdx-button{display:flex;align-items:center;justify-content:center}.image-tool .cdx-button svg{height:auto;margin:0 6px 0 0}.image-tool--filled .cdx-button,.image-tool--filled .image-tool__image-preloader{display:none}.image-tool--uploading .image-tool__image{min-height:200px;display:flex;border:1px solid var(--border-color);background-color:#fff}.image-tool--uploading .image-tool__image-picture,.image-tool--uploading .cdx-button{display:none}.image-tool--withBorder .image-tool__image{border:1px solid var(--border-color)}.image-tool--withBackground .image-tool__image{padding:15px;background:var(--bg-color)}.image-tool--withBackground .image-tool__image-picture{max-width:60%;margin:0 auto}.image-tool--stretched .image-tool__image-picture{width:100%}.image-tool--caption .image-tool__caption{visibility:visible}.image-tool--caption{padding-bottom:50px}@keyframes image-preloader-spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}')),document.head.appendChild(e)}}catch(t){}}();const Ws='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><rect width="14" height="14" x="5" y="5" stroke="currentColor" stroke-width="2" rx="4"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5.13968 15.32L8.69058 11.5661C9.02934 11.2036 9.48873 11 9.96774 11C10.4467 11 10.9061 11.2036 11.2449 11.5661L15.3871 16M13.5806 14.0664L15.0132 12.533C15.3519 12.1705 15.8113 11.9668 16.2903 11.9668C16.7693 11.9668 17.2287 12.1705 17.5675 12.533L18.841 13.9634"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13.7778 9.33331H13.7867"/></svg>';function $s(e,t=null,o={}){const n=document.createElement(e);Array.isArray(t)?n.classList.add(...t):null!==t&&n.classList.add(t);for(const i in o)o.hasOwnProperty(i)&&(n[i]=o[i]);return n}var qs=(e=>(e.Empty="empty",e.Uploading="uploading",e.Filled="filled",e))(qs||{});let Ks=class{constructor({api:e,config:t,onSelectFile:o,readOnly:n}){this.api=e,this.config=t,this.onSelectFile=o,this.readOnly=n,this.nodes={wrapper:$s("div",[this.CSS.baseClass,this.CSS.wrapper]),imageContainer:$s("div",[this.CSS.imageContainer]),fileButton:this.createFileButton(),imageEl:void 0,imagePreloader:$s("div",this.CSS.imagePreloader),caption:$s("div",[this.CSS.input,this.CSS.caption],{contentEditable:!this.readOnly})},this.nodes.caption.dataset.placeholder=this.config.captionPlaceholder,this.nodes.imageContainer.appendChild(this.nodes.imagePreloader),this.nodes.wrapper.appendChild(this.nodes.imageContainer),this.nodes.wrapper.appendChild(this.nodes.caption),this.nodes.wrapper.appendChild(this.nodes.fileButton)}applyTune(e,t){this.nodes.wrapper.classList.toggle(`${this.CSS.wrapper}--${e}`,t)}render(){return this.toggleStatus("empty"),this.nodes.wrapper}showPreloader(e){this.nodes.imagePreloader.style.backgroundImage=`url(${e})`,this.toggleStatus("uploading")}hidePreloader(){this.nodes.imagePreloader.style.backgroundImage="",this.toggleStatus("empty")}fillImage(e){const t=/\.mp4$/.test(e)?"VIDEO":"IMG",o={src:e};let n="load";"VIDEO"===t&&(o.autoplay=!0,o.loop=!0,o.muted=!0,o.playsinline=!0,n="loadeddata"),this.nodes.imageEl=$s(t,this.CSS.imageEl,o),this.nodes.imageEl.addEventListener(n,(()=>{this.toggleStatus("filled"),void 0!==this.nodes.imagePreloader&&(this.nodes.imagePreloader.style.backgroundImage="")})),this.nodes.imageContainer.appendChild(this.nodes.imageEl)}fillCaption(e){void 0!==this.nodes.caption&&(this.nodes.caption.innerHTML=e)}toggleStatus(e){for(const t in qs)if(Object.prototype.hasOwnProperty.call(qs,t)){const o=qs[t];this.nodes.wrapper.classList.toggle(`${this.CSS.wrapper}--${o}`,o===e)}}get CSS(){return{baseClass:this.api.styles.block,loading:this.api.styles.loader,input:this.api.styles.input,button:this.api.styles.button,wrapper:"image-tool",imageContainer:"image-tool__image",imagePreloader:"image-tool__image-preloader",imageEl:"image-tool__image-picture",caption:"image-tool__caption"}}createFileButton(){const e=$s("div",[this.CSS.button]);return e.innerHTML=this.config.buttonContent??`${Ws} ${this.api.i18n.t("Select an Image")}`,e.addEventListener("click",(()=>{this.onSelectFile()})),e}};function Ys(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Xs={exports:{}};window;const Vs=Ys(Xs.exports=function(e){var t={};function o(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,o),i.l=!0,i.exports}return o.m=e,o.c=t,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t||4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)o.d(n,i,function(t){return e[t]}.bind(null,i));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=3)}([function(e,t){var o;o=function(){return this}();try{o=o||new Function("return this")()}catch{"object"==typeof window&&(o=window)}e.exports=o},function(e,t,o){(function(e){var n=o(2),i=setTimeout;function r(){}function s(e){if(!(this instanceof s))throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],h(e,this)}function a(e,t){for(;3===e._state;)e=e._value;0!==e._state?(e._handled=!0,s._immediateFn((function(){var o=1===e._state?t.onFulfilled:t.onRejected;if(null!==o){var n;try{n=o(e._value)}catch(i){return void c(t.promise,i)}l(t.promise,n)}else(1===e._state?l:c)(t.promise,e._value)}))):e._deferreds.push(t)}function l(e,t){try{if(t===e)throw new TypeError("A promise cannot be resolved with itself.");if(t&&("object"==typeof t||"function"==typeof t)){var o=t.then;if(t instanceof s)return e._state=3,e._value=t,void d(e);if("function"==typeof o)return void h((n=o,i=t,function(){n.apply(i,arguments)}),e)}e._state=1,e._value=t,d(e)}catch(r){c(e,r)}var n,i}function c(e,t){e._state=2,e._value=t,d(e)}function d(e){2===e._state&&0===e._deferreds.length&&s._immediateFn((function(){e._handled||s._unhandledRejectionFn(e._value)}));for(var t=0,o=e._deferreds.length;t<o;t++)a(e,e._deferreds[t]);e._deferreds=null}function u(e,t,o){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.promise=o}function h(e,t){var o=!1;try{e((function(e){o||(o=!0,l(t,e))}),(function(e){o||(o=!0,c(t,e))}))}catch(n){if(o)return;o=!0,c(t,n)}}s.prototype.catch=function(e){return this.then(null,e)},s.prototype.then=function(e,t){var o=new this.constructor(r);return a(this,new u(e,t,o)),o},s.prototype.finally=n.a,s.all=function(e){return new s((function(t,o){if(!e||void 0===e.length)throw new TypeError("Promise.all accepts an array");var n=Array.prototype.slice.call(e);if(0===n.length)return t([]);var i=n.length;function r(e,s){try{if(s&&("object"==typeof s||"function"==typeof s)){var a=s.then;if("function"==typeof a)return void a.call(s,(function(t){r(e,t)}),o)}n[e]=s,0==--i&&t(n)}catch(l){o(l)}}for(var s=0;s<n.length;s++)r(s,n[s])}))},s.resolve=function(e){return e&&"object"==typeof e&&e.constructor===s?e:new s((function(t){t(e)}))},s.reject=function(e){return new s((function(t,o){o(e)}))},s.race=function(e){return new s((function(t,o){for(var n=0,i=e.length;n<i;n++)e[n].then(t,o)}))},s._immediateFn="function"==typeof e&&function(t){e(t)}||function(e){i(e,0)},s._unhandledRejectionFn=function(e){typeof console<"u"&&console},t.a=s}).call(this,o(5).setImmediate)},function(e,t,o){t.a=function(e){var t=this.constructor;return this.then((function(o){return t.resolve(e()).then((function(){return o}))}),(function(o){return t.resolve(e()).then((function(){return t.reject(o)}))}))}},function(e,t,o){function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}o(4);var i,r,s,a,l,c,d,u=o(8),h=(r=function(e){return new Promise((function(t,o){e=a(e),(e=l(e)).beforeSend&&e.beforeSend();var n=window.XMLHttpRequest?new window.XMLHttpRequest:new window.ActiveXObject("Microsoft.XMLHTTP");n.open(e.method,e.url),n.setRequestHeader("X-Requested-With","XMLHttpRequest"),Object.keys(e.headers).forEach((function(t){var o=e.headers[t];n.setRequestHeader(t,o)}));var i=e.ratio;n.upload.addEventListener("progress",(function(t){var o=Math.round(t.loaded/t.total*100),n=Math.ceil(o*i/100);e.progress(Math.min(n,100))}),!1),n.addEventListener("progress",(function(t){var o=Math.round(t.loaded/t.total*100),n=Math.ceil(o*(100-i)/100)+i;e.progress(Math.min(n,100))}),!1),n.onreadystatechange=function(){if(4===n.readyState){var e=n.response;try{e=JSON.parse(e)}catch{}var i=u.parseHeaders(n.getAllResponseHeaders()),r={body:e,code:n.status,headers:i};d(n.status)?t(r):o(r)}},n.send(e.data)}))},s=function(e){return e.method="POST",r(e)},a=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(e.url&&"string"!=typeof e.url)throw new Error("Url must be a string");if(e.url=e.url||"",e.method&&"string"!=typeof e.method)throw new Error("`method` must be a string or null");if(e.method=e.method?e.method.toUpperCase():"GET",e.headers&&"object"!==n(e.headers))throw new Error("`headers` must be an object or null");if(e.headers=e.headers||{},e.type&&("string"!=typeof e.type||!Object.values(i).includes(e.type)))throw new Error("`type` must be taken from module's «contentType» library");if(e.progress&&"function"!=typeof e.progress)throw new Error("`progress` must be a function or null");if(e.progress=e.progress||function(e){},e.beforeSend=e.beforeSend||function(e){},e.ratio&&"number"!=typeof e.ratio)throw new Error("`ratio` must be a number");if(e.ratio<0||e.ratio>100)throw new Error("`ratio` must be in a 0-100 interval");if(e.ratio=e.ratio||90,e.accept&&"string"!=typeof e.accept)throw new Error("`accept` must be a string with a list of allowed mime-types");if(e.accept=e.accept||"*/*",e.multiple&&"boolean"!=typeof e.multiple)throw new Error("`multiple` must be a true or false");if(e.multiple=e.multiple||!1,e.fieldName&&"string"!=typeof e.fieldName)throw new Error("`fieldName` must be a string");return e.fieldName=e.fieldName||"files",e},l=function(e){switch(e.method){case"GET":var t=c(e.data,i.URLENCODED);delete e.data,e.url=/\?/.test(e.url)?e.url+"&"+t:e.url+"?"+t;break;case"POST":case"PUT":case"DELETE":case"UPDATE":var o=function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).type||i.JSON}(e);(u.isFormData(e.data)||u.isFormElement(e.data))&&(o=i.FORM),e.data=c(e.data,o),o!==h.contentType.FORM&&(e.headers["content-type"]=o)}return e},c=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};switch(arguments.length>1?arguments[1]:void 0){case i.URLENCODED:return u.urlEncode(e);case i.JSON:return u.jsonEncode(e);case i.FORM:return u.formEncode(e);default:return e}},d=function(e){return e>=200&&e<300},{contentType:i={URLENCODED:"application/x-www-form-urlencoded; charset=utf-8",FORM:"multipart/form-data",JSON:"application/json; charset=utf-8"},request:r,get:function(e){return e.method="GET",r(e)},post:s,transport:function(e){return e=a(e),u.selectFiles(e).then((function(t){for(var o=new FormData,n=0;n<t.length;n++)o.append(e.fieldName,t[n],t[n].name);u.isObject(e.data)&&Object.keys(e.data).forEach((function(t){var n=e.data[t];o.append(t,n)}));var i=e.beforeSend;return e.beforeSend=function(){return i(t)},e.data=o,s(e)}))},selectFiles:function(e){return delete(e=a(e)).beforeSend,u.selectFiles(e)}});e.exports=h},function(e,t,o){o.r(t);var n=o(1);window.Promise=window.Promise||n.a},function(e,t,o){(function(e){var n=void 0!==e&&e||typeof self<"u"&&self||window,i=Function.prototype.apply;function r(e,t){this._id=e,this._clearFn=t}t.setTimeout=function(){return new r(i.call(setTimeout,n,arguments),clearTimeout)},t.setInterval=function(){return new r(i.call(setInterval,n,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e&&e.close()},r.prototype.unref=r.prototype.ref=function(){},r.prototype.close=function(){this._clearFn.call(n,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout((function(){e._onTimeout&&e._onTimeout()}),t))},o(6),t.setImmediate=typeof self<"u"&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate=typeof self<"u"&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,o(0))},function(e,t,o){(function(e,t){!function(e,o){if(!e.setImmediate){var n,i,r,s,a,l=1,c={},d=!1,u=e.document,h=Object.getPrototypeOf&&Object.getPrototypeOf(e);h=h&&h.setTimeout?h:e,"[object process]"==={}.toString.call(e.process)?n=function(e){t.nextTick((function(){f(e)}))}:function(){if(e.postMessage&&!e.importScripts){var t=!0,o=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=o,t}}()?(s="setImmediate$"+Math.random()+"$",a=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(s)&&f(+t.data.slice(s.length))},e.addEventListener?e.addEventListener("message",a,!1):e.attachEvent("onmessage",a),n=function(t){e.postMessage(s+t,"*")}):e.MessageChannel?((r=new MessageChannel).port1.onmessage=function(e){f(e.data)},n=function(e){r.port2.postMessage(e)}):u&&"onreadystatechange"in u.createElement("script")?(i=u.documentElement,n=function(e){var t=u.createElement("script");t.onreadystatechange=function(){f(e),t.onreadystatechange=null,i.removeChild(t),t=null},i.appendChild(t)}):n=function(e){setTimeout(f,0,e)},h.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),o=0;o<t.length;o++)t[o]=arguments[o+1];var i={callback:e,args:t};return c[l]=i,n(l),l++},h.clearImmediate=p}function p(e){delete c[e]}function f(e){if(d)setTimeout(f,0,e);else{var t=c[e];if(t){d=!0;try{!function(e){var t=e.callback,n=e.args;switch(n.length){case 0:t();break;case 1:t(n[0]);break;case 2:t(n[0],n[1]);break;case 3:t(n[0],n[1],n[2]);break;default:t.apply(o,n)}}(t)}finally{p(e),d=!1}}}}}(typeof self>"u"?void 0===e?this:e:self)}).call(this,o(0),o(7))},function(e,t){var o,n,i=e.exports={};function r(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function a(e){if(o===setTimeout)return setTimeout(e,0);if((o===r||!o)&&setTimeout)return o=setTimeout,setTimeout(e,0);try{return o(e,0)}catch{try{return o.call(null,e,0)}catch{return o.call(this,e,0)}}}!function(){try{o="function"==typeof setTimeout?setTimeout:r}catch{o=r}try{n="function"==typeof clearTimeout?clearTimeout:s}catch{n=s}}();var l,c=[],d=!1,u=-1;function h(){d&&l&&(d=!1,l.length?c=l.concat(c):u=-1,c.length&&p())}function p(){if(!d){var e=a(h);d=!0;for(var t=c.length;t;){for(l=c,c=[];++u<t;)l&&l[u].run();u=-1,t=c.length}l=null,d=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===s||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch{try{return n.call(null,e)}catch{return n.call(this,e)}}}(e)}}function f(e,t){this.fun=e,this.array=t}function g(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var o=1;o<arguments.length;o++)t[o-1]=arguments[o];c.push(new f(e,t)),1!==c.length||d||a(p)},f.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=g,i.addListener=g,i.once=g,i.off=g,i.removeListener=g,i.removeAllListeners=g,i.emit=g,i.prependListener=g,i.prependOnceListener=g,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},function(e,t,o){function n(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var i=o(9);e.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,o,r;return t=e,r=[{key:"urlEncode",value:function(e){return i(e)}},{key:"jsonEncode",value:function(e){return JSON.stringify(e)}},{key:"formEncode",value:function(e){if(this.isFormData(e))return e;if(this.isFormElement(e))return new FormData(e);if(this.isObject(e)){var t=new FormData;return Object.keys(e).forEach((function(o){var n=e[o];t.append(o,n)})),t}throw new Error("`data` must be an instance of Object, FormData or <FORM> HTMLElement")}},{key:"isObject",value:function(e){return"[object Object]"===Object.prototype.toString.call(e)}},{key:"isFormData",value:function(e){return e instanceof FormData}},{key:"isFormElement",value:function(e){return e instanceof HTMLFormElement}},{key:"selectFiles",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Promise((function(t,o){var n=document.createElement("INPUT");n.type="file",e.multiple&&n.setAttribute("multiple","multiple"),e.accept&&n.setAttribute("accept",e.accept),n.style.display="none",document.body.appendChild(n),n.addEventListener("change",(function(e){var o=e.target.files;t(o),document.body.removeChild(n)}),!1),n.click()}))}},{key:"parseHeaders",value:function(e){var t=e.trim().split(/[\r\n]+/),o={};return t.forEach((function(e){var t=e.split(": "),n=t.shift(),i=t.join(": ");n&&(o[n]=i)})),o}}],(o=null)&&n(t.prototype,o),r&&n(t,r),e}()},function(e,t){var o=function(e){return encodeURIComponent(e).replace(/[!'()*]/g,escape).replace(/%20/g,"+")},n=function(e,t,i,r){return t=t||null,i=i||"&",r=r||null,e?function(e){for(var t=new Array,o=0;o<e.length;o++)e[o]&&t.push(e[o]);return t}(Object.keys(e).map((function(s){var a,l,c=s;if(r&&(c=r+"["+c+"]"),"object"==typeof e[s]&&null!==e[s])a=n(e[s],null,i,c);else{t&&(l=c,c=!isNaN(parseFloat(l))&&isFinite(l)?t+Number(c):c);var d=e[s];d=(d=0===(d=!1===(d=!0===d?"1":d)?"0":d)?"0":d)||"",a=o(c)+"="+o(d)}return a}))).join(i).replace(/[!'()*]/g,""):""};e.exports=n}]));function Gs(e){return void 0!==e&&"function"==typeof e.then}let Zs=class{constructor({config:e,onUpload:t,onError:o}){this.config=e,this.onUpload=t,this.onError=o}uploadSelectedFile({onPreview:e}){const t=function(t){const o=new FileReader;o.readAsDataURL(t),o.onload=t=>{e(t.target.result)}};let o;if(this.config.uploader&&"function"==typeof this.config.uploader.uploadByFile){const e=this.config.uploader.uploadByFile;o=Vs.selectFiles({accept:this.config.types??"image/*"}).then((o=>{t(o[0]);const n=e(o[0]);return Gs(n),n}))}else o=Vs.transport({url:this.config.endpoints.byFile,data:this.config.additionalRequestData,accept:this.config.types??"image/*",headers:this.config.additionalRequestHeaders,beforeSend:e=>{t(e[0])},fieldName:this.config.field??"image"}).then((e=>e.body));o.then((e=>{this.onUpload(e)})).catch((e=>{this.onError(e)}))}uploadByUrl(e){let t;this.config.uploader&&"function"==typeof this.config.uploader.uploadByUrl?(t=this.config.uploader.uploadByUrl(e),Gs(t)):t=Vs.post({url:this.config.endpoints.byUrl,data:Object.assign({url:e},this.config.additionalRequestData),type:Vs.contentType.JSON,headers:this.config.additionalRequestHeaders}).then((e=>e.body)),t.then((e=>{this.onUpload(e)})).catch((e=>{this.onError(e)}))}uploadByFile(e,{onPreview:t}){const o=new FileReader;let n;if(o.readAsDataURL(e),o.onload=e=>{t(e.target.result)},this.config.uploader&&"function"==typeof this.config.uploader.uploadByFile)n=this.config.uploader.uploadByFile(e),Gs(n);else{const t=new FormData;t.append(this.config.field??"image",e),this.config.additionalRequestData&&Object.keys(this.config.additionalRequestData).length&&Object.entries(this.config.additionalRequestData).forEach((([e,o])=>{t.append(e,o)})),n=Vs.post({url:this.config.endpoints.byFile,data:t,type:Vs.contentType.JSON,headers:this.config.additionalRequestHeaders}).then((e=>e.body))}n.then((e=>{this.onUpload(e)})).catch((e=>{this.onError(e)}))}},Js=class e{constructor({data:e,config:t,api:o,readOnly:n,block:i}){this.isCaptionEnabled=null,this.api=o,this.block=i,this.config={endpoints:t.endpoints,additionalRequestData:t.additionalRequestData,additionalRequestHeaders:t.additionalRequestHeaders,field:t.field,types:t.types,captionPlaceholder:this.api.i18n.t(t.captionPlaceholder??"Caption"),buttonContent:t.buttonContent,uploader:t.uploader,actions:t.actions,features:t.features||{}},this.uploader=new Zs({config:this.config,onUpload:e=>this.onUpload(e),onError:e=>this.uploadingFailed(e)}),this.ui=new Ks({api:o,config:this.config,onSelectFile:()=>{this.uploader.uploadSelectedFile({onPreview:e=>{this.ui.showPreloader(e)}})},readOnly:n}),this._data={caption:"",withBorder:!1,withBackground:!1,stretched:!1,file:{url:""}},this.data=e}static get isReadOnlySupported(){return!0}static get toolbox(){return{icon:Ws,title:"Image"}}static get tunes(){return[{name:"withBorder",icon:'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M18.9919 9.5H19.0015"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14.5 5H14.5096"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M14.625 5H15C17.2091 5 19 6.79086 19 9V9.375"/><path stroke="currentColor" stroke-width="2" d="M9.375 5L9 5C6.79086 5 5 6.79086 5 9V9.375"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9.3725 5H9.38207"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 9.5H5.00957"/><path stroke="currentColor" stroke-width="2" d="M9.375 19H9C6.79086 19 5 17.2091 5 15V14.625"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9.3725 19H9.38207"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 14.55H5.00957"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M16 13V16M16 19V16M19 16H16M16 16H13"/></svg>',title:"With border",toggle:!0},{name:"stretched",icon:'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 9L20 12L17 15"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14 12H20"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 9L4 12L7 15"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 12H10"/></svg>',title:"Stretch image",toggle:!0},{name:"withBackground",icon:'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 19V19C9.13623 19 8.20435 19 7.46927 18.6955C6.48915 18.2895 5.71046 17.5108 5.30448 16.5307C5 15.7956 5 14.8638 5 13V12C5 9.19108 5 7.78661 5.67412 6.77772C5.96596 6.34096 6.34096 5.96596 6.77772 5.67412C7.78661 5 9.19108 5 12 5H13.5C14.8956 5 15.5933 5 16.1611 5.17224C17.4395 5.56004 18.44 6.56046 18.8278 7.83886C19 8.40666 19 9.10444 19 10.5V10.5"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M16 13V16M16 19V16M19 16H16M16 16H13"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6.5 17.5L17.5 6.5"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M18.9919 10.5H19.0015"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.9919 19H11.0015"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13L13 5"/></svg>',title:"With background",toggle:!0}]}render(){var e,t,o;return(!0===(null==(e=this.config.features)?void 0:e.caption)||void 0===(null==(t=this.config.features)?void 0:t.caption)||"optional"===(null==(o=this.config.features)?void 0:o.caption)&&this.data.caption)&&(this.isCaptionEnabled=!0,this.ui.applyTune("caption",!0)),this.ui.render()}validate(e){return!!e.file.url}save(){const e=this.ui.nodes.caption;return this._data.caption=e.innerHTML,this.data}renderSettings(){var t;const o=e.tunes.concat(this.config.actions||[]),n={border:"withBorder",background:"withBackground",stretch:"stretched",caption:"caption"};"optional"===(null==(t=this.config.features)?void 0:t.caption)&&o.push({name:"caption",icon:'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M8 9V7.2C8 7.08954 8.08954 7 8.2 7L12 7M16 9V7.2C16 7.08954 15.9105 7 15.8 7L12 7M12 7L12 17M12 17H10M12 17H14"/></svg>',title:"With caption",toggle:!0});const i=o.filter((e=>{var t,o;const i=Object.keys(n).find((t=>n[t]===e.name));return"caption"===i?!1!==(null==(t=this.config.features)?void 0:t.caption):null==i||!1!==(null==(o=this.config.features)?void 0:o[i])})),r=e=>{let t=this.data[e.name];return"caption"===e.name&&(t=this.isCaptionEnabled??t),t};return i.map((e=>({icon:e.icon,label:this.api.i18n.t(e.title),name:e.name,toggle:e.toggle,isActive:r(e),onActivate:()=>{if("function"==typeof e.action)return void e.action(e.name);let t=!r(e);"caption"===e.name&&(this.isCaptionEnabled=!this.isCaptionEnabled,t=this.isCaptionEnabled),this.tuneToggled(e.name,t)}})))}appendCallback(){this.ui.nodes.fileButton.click()}static get pasteConfig(){return{tags:[{img:{src:!0}}],patterns:{image:/https?:\/\/\S+\.(gif|jpe?g|tiff|png|svg|webp)(\?[a-z0-9=]*)?$/i},files:{mimeTypes:["image/*"]}}}async onPaste(e){switch(e.type){case"tag":{const t=e.detail.data;if(/^blob:/.test(t.src)){const e=await(await fetch(t.src)).blob();this.uploadFile(e);break}this.uploadUrl(t.src);break}case"pattern":{const t=e.detail.data;this.uploadUrl(t);break}case"file":{const t=e.detail.file;this.uploadFile(t);break}}}set data(t){var o;this.image=t.file,this._data.caption=t.caption||"",this.ui.fillCaption(this._data.caption),e.tunes.forEach((({name:e})=>{const o=typeof t[e]<"u"&&(!0===t[e]||"true"===t[e]);this.setTune(e,o)})),(t.caption||!0===(null==(o=this.config.features)?void 0:o.caption))&&this.setTune("caption",!0)}get data(){return this._data}set image(e){this._data.file=e||{url:""},e&&e.url&&this.ui.fillImage(e.url)}onUpload(e){e.success&&e.file?this.image=e.file:this.uploadingFailed("incorrect response: "+JSON.stringify(e))}uploadingFailed(e){this.api.notifier.show({message:this.api.i18n.t("Couldn’t upload image. Please try another."),style:"error"}),this.ui.hidePreloader()}tuneToggled(e,t){"caption"===e?(this.ui.applyTune(e,t),0==t&&(this._data.caption="",this.ui.fillCaption(""))):this.setTune(e,t)}setTune(e,t){this._data[e]=t,this.ui.applyTune(e,t),"stretched"===e&&Promise.resolve().then((()=>{this.block.stretched=t})).catch((e=>{}))}uploadFile(e){this.uploader.uploadByFile(e,{onPreview:e=>{this.ui.showPreloader(e)}})}uploadUrl(e){this.ui.showPreloader(e),this.uploader.uploadByUrl(e)}};
|
||
/**
|
||
* Image Tool for the Editor.js
|
||
* @author CodeX <team@codex.so>
|
||
* @license MIT
|
||
* @see {@link https://github.com/editor-js/image}
|
||
*
|
||
* To developers.
|
||
* To simplify Tool structure, we split it to 4 parts:
|
||
* 1) index.ts — main Tool's interface, public API and methods for working with data
|
||
* 2) uploader.ts — module that has methods for sending files via AJAX: from device, by URL or File pasting
|
||
* 3) ui.ts — module for UI manipulations: render, showing preloader, etc
|
||
*
|
||
* For debug purposes there is a testing server
|
||
* that can save uploaded files and return a Response {@link UploadResponseFormat}
|
||
*
|
||
* $ node dev/server.js
|
||
*
|
||
* It will expose 8008 port, so you can pass http://localhost:8008 with the Tools config:
|
||
*
|
||
* image: {
|
||
* class: ImageTool,
|
||
* config: {
|
||
* endpoints: {
|
||
* byFile: 'http://localhost:8008/uploadFile',
|
||
* byUrl: 'http://localhost:8008/fetchUrl',
|
||
* }
|
||
* },
|
||
* },
|
||
*/!function(){try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".cdx-quote-icon svg{transform:rotate(180deg)}.cdx-quote{margin:0}.cdx-quote__text{min-height:158px;margin-bottom:10px}.cdx-quote [contentEditable=true][data-placeholder]:before{position:absolute;content:attr(data-placeholder);color:#707684;font-weight:400;opacity:0}.cdx-quote [contentEditable=true][data-placeholder]:empty:before{opacity:1}.cdx-quote [contentEditable=true][data-placeholder]:empty:focus:before{opacity:0}.cdx-quote-settings{display:flex}.cdx-quote-settings .cdx-settings-button{width:50%}")),document.head.appendChild(e)}}catch(t){}}();var Qs=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ea(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var o=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};o.prototype=t.prototype}else o={};return Object.defineProperty(o,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(o,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),o}var ta={},oa={},na={};Object.defineProperty(na,"__esModule",{value:!0}),na.allInputsSelector=function(){return"[contenteditable=true], textarea, input:not([type]), "+["text","password","email","number","search","tel","url"].map((function(e){return'input[type="'.concat(e,'"]')})).join(", ")},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.allInputsSelector=void 0;var t=na;Object.defineProperty(e,"allInputsSelector",{enumerable:!0,get:function(){return t.allInputsSelector}})}(oa);var ia={},ra={};Object.defineProperty(ra,"__esModule",{value:!0}),ra.isNativeInput=function(e){return!(!e||!e.tagName)&&["INPUT","TEXTAREA"].includes(e.tagName)},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.isNativeInput=void 0;var t=ra;Object.defineProperty(e,"isNativeInput",{enumerable:!0,get:function(){return t.isNativeInput}})}(ia);var sa={},aa={};Object.defineProperty(aa,"__esModule",{value:!0}),aa.append=function(e,t){Array.isArray(t)?t.forEach((function(t){e.appendChild(t)})):e.appendChild(t)},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.append=void 0;var t=aa;Object.defineProperty(e,"append",{enumerable:!0,get:function(){return t.append}})}(sa);var la={},ca={};Object.defineProperty(ca,"__esModule",{value:!0}),ca.blockElements=function(){return["address","article","aside","blockquote","canvas","div","dl","dt","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","li","main","nav","noscript","ol","output","p","pre","ruby","section","table","tbody","thead","tr","tfoot","ul","video"]},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.blockElements=void 0;var t=ca;Object.defineProperty(e,"blockElements",{enumerable:!0,get:function(){return t.blockElements}})}(la);var da={},ua={};Object.defineProperty(ua,"__esModule",{value:!0}),ua.calculateBaseline=function(e){var t=window.getComputedStyle(e),o=parseFloat(t.fontSize),n=parseFloat(t.lineHeight)||1.2*o,i=parseFloat(t.paddingTop),r=parseFloat(t.borderTopWidth);return parseFloat(t.marginTop)+r+i+(n-o)/2+.8*o},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.calculateBaseline=void 0;var t=ua;Object.defineProperty(e,"calculateBaseline",{enumerable:!0,get:function(){return t.calculateBaseline}})}(da);var ha={},pa={},fa={},ga={};Object.defineProperty(ga,"__esModule",{value:!0}),ga.isContentEditable=function(e){return"true"===e.contentEditable},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.isContentEditable=void 0;var t=ga;Object.defineProperty(e,"isContentEditable",{enumerable:!0,get:function(){return t.isContentEditable}})}(fa),Object.defineProperty(pa,"__esModule",{value:!0}),pa.canSetCaret=function(e){var t=!0;if((0,ma.isNativeInput)(e))switch(e.type){case"file":case"checkbox":case"radio":case"hidden":case"submit":case"button":case"image":case"reset":t=!1}else t=(0,ba.isContentEditable)(e);return t};var ma=ia,ba=fa;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.canSetCaret=void 0;var t=pa;Object.defineProperty(e,"canSetCaret",{enumerable:!0,get:function(){return t.canSetCaret}})}(ha);var va={},ya={};function ka(){const e={win:!1,mac:!1,x11:!1,linux:!1},t=Object.keys(e).find((e=>-1!==window.navigator.appVersion.toLowerCase().indexOf(e)));return void 0!==t&&(e[t]=!0),e}function wa(e){return null!=e&&""!==e&&("object"!=typeof e||Object.keys(e).length>0)}function xa(e){return Object.prototype.toString.call(e).match(/\s([a-zA-Z]+)/)[1].toLowerCase()}function Ea(e){return"function"===xa(e)||"asyncfunction"===xa(e)}function Ca(e){return"object"===xa(e)}const Sa=Object.freeze(Object.defineProperty({__proto__:null,PromiseQueue:class{constructor(){this.completed=Promise.resolve()}add(e){return new Promise(((t,o)=>{this.completed=this.completed.then(e).then(t).catch(o)}))}},beautifyShortcut:function(e){const t=ka();return e=e.replace(/shift/gi,"⇧").replace(/backspace/gi,"⌫").replace(/enter/gi,"⏎").replace(/up/gi,"↑").replace(/left/gi,"→").replace(/down/gi,"↓").replace(/right/gi,"←").replace(/escape/gi,"⎋").replace(/insert/gi,"Ins").replace(/delete/gi,"␡").replace(/\+/gi,"+"),e=t.mac?e.replace(/ctrl|cmd/gi,"⌘").replace(/alt/gi,"⌥"):e.replace(/cmd/gi,"Ctrl").replace(/windows/gi,"WIN")},cacheable:function(e,t,o){const n=void 0!==o.value?"value":"get",i=o[n],r=`#${t}Cache`;if(o[n]=function(...e){return void 0===this[r]&&(this[r]=i.apply(this,e)),this[r]},"get"===n&&o.set){const t=o.set;o.set=function(o){delete e[r],t.apply(this,o)}}return o},capitalize:function(e){return e[0].toUpperCase()+e.slice(1)},copyTextToClipboard:function(e){const t=document.createElement("div");t.style.position="absolute",t.style.left="-999px",t.style.bottom="-999px",t.innerHTML=e,document.body.appendChild(t);const o=window.getSelection(),n=document.createRange();if(n.selectNode(t),null===o)throw new Error("Cannot copy text to clipboard");o.removeAllRanges(),o.addRange(n),document.execCommand("copy"),document.body.removeChild(t)},debounce:function(e,t,o){let n;return(...i)=>{const r=this,s=!0===o&&void 0!==n;window.clearTimeout(n),n=window.setTimeout((()=>{n=void 0,!0!==o&&e.apply(r,i)}),t),s&&e.apply(r,i)}},deepMerge:function e(t,...o){if(!o.length)return t;const n=o.shift();if(Ca(t)&&Ca(n))for(const i in n)Ca(n[i])?(void 0===t[i]&&Object.assign(t,{[i]:{}}),e(t[i],n[i])):Object.assign(t,{[i]:n[i]});return e(t,...o)},deprecationAssert:function(e,t,o){},getUserOS:ka,getValidUrl:function(e){try{return new URL(e).href}catch{}return"//"===e.substring(0,2)?window.location.protocol+e:window.location.origin+e},isBoolean:function(e){return"boolean"===xa(e)},isClass:function(e){return Ea(e)&&/^\s*class\s+/.test(e.toString())},isEmpty:function(e){return!wa(e)},isFunction:Ea,isIosDevice:()=>typeof window<"u"&&null!==window.navigator&&wa(window.navigator.platform)&&(/iP(ad|hone|od)/.test(window.navigator.platform)||"MacIntel"===window.navigator.platform&&window.navigator.maxTouchPoints>1),isNumber:function(e){return"number"===xa(e)},isObject:Ca,isPrintableKey:function(e){return e>47&&e<58||32===e||13===e||229===e||e>64&&e<91||e>95&&e<112||e>185&&e<193||e>218&&e<223},isPromise:function(e){return Promise.resolve(e)===e},isString:function(e){return"string"===xa(e)},isUndefined:function(e){return"undefined"===xa(e)},keyCodes:{BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,ESC:27,SPACE:32,LEFT:37,UP:38,DOWN:40,RIGHT:39,DELETE:46,META:91,SLASH:191},mouseButtons:{LEFT:0,WHEEL:1,RIGHT:2,BACKWARD:3,FORWARD:4},notEmpty:wa,throttle:function(e,t,o=void 0){let n,i,r,s=null,a=0;o||(o={});const l=function(){a=!1===o.leading?0:Date.now(),s=null,r=e.apply(n,i),null===s&&(n=i=null)};return function(){const c=Date.now();!a&&!1===o.leading&&(a=c);const d=t-(c-a);return n=this,i=arguments,d<=0||d>t?(s&&(clearTimeout(s),s=null),a=c,r=e.apply(n,i),null===s&&(n=i=null)):!s&&!1!==o.trailing&&(s=setTimeout(l,d)),r}},typeOf:xa},Symbol.toStringTag,{value:"Module"})),Ta=ea(Sa);Object.defineProperty(ya,"__esModule",{value:!0}),ya.containsOnlyInlineElements=function(e){var t;(0,_a.isString)(e)?(t=document.createElement("div")).innerHTML=e:t=e;var o=function(e){return!(0,Oa.blockElements)().includes(e.tagName.toLowerCase())&&Array.from(e.children).every(o)};return Array.from(t.children).every(o)};var _a=Ta,Oa=la;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.containsOnlyInlineElements=void 0;var t=ya;Object.defineProperty(e,"containsOnlyInlineElements",{enumerable:!0,get:function(){return t.containsOnlyInlineElements}})}(va);var Ba={},Ia={},Ma={},Pa={};Object.defineProperty(Pa,"__esModule",{value:!0}),Pa.make=function(e,t,o){var n;void 0===t&&(t=null),void 0===o&&(o={});var i=document.createElement(e);if(Array.isArray(t)){var r=t.filter((function(e){return void 0!==e}));(n=i.classList).add.apply(n,r)}else null!==t&&i.classList.add(t);for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(i[s]=o[s]);return i},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.make=void 0;var t=Pa;Object.defineProperty(e,"make",{enumerable:!0,get:function(){return t.make}})}(Ma),Object.defineProperty(Ia,"__esModule",{value:!0}),Ia.fragmentToString=function(e){var t=(0,La.make)("div");return t.appendChild(e),t.innerHTML};var La=Ma;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.fragmentToString=void 0;var t=Ia;Object.defineProperty(e,"fragmentToString",{enumerable:!0,get:function(){return t.fragmentToString}})}(Ba);var Aa={},Na={};Object.defineProperty(Na,"__esModule",{value:!0}),Na.getContentLength=function(e){var t,o;return(0,ja.isNativeInput)(e)?e.value.length:e.nodeType===Node.TEXT_NODE?e.length:null!==(o=null===(t=e.textContent)||void 0===t?void 0:t.length)&&void 0!==o?o:0};var ja=ia;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.getContentLength=void 0;var t=Na;Object.defineProperty(e,"getContentLength",{enumerable:!0,get:function(){return t.getContentLength}})}(Aa);var Da={},Ra={},Fa=Qs&&Qs.__spreadArray||function(e,t,o){if(o||2===arguments.length)for(var n,i=0,r=t.length;i<r;i++)(n||!(i in t))&&(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))};Object.defineProperty(Ra,"__esModule",{value:!0}),Ra.getDeepestBlockElements=function e(t){return(0,Ha.containsOnlyInlineElements)(t)?[t]:Array.from(t.children).reduce((function(t,o){return Fa(Fa([],t,!0),e(o),!0)}),[])};var Ha=va;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.getDeepestBlockElements=void 0;var t=Ra;Object.defineProperty(e,"getDeepestBlockElements",{enumerable:!0,get:function(){return t.getDeepestBlockElements}})}(Da);var Ua={},za={},Wa={},$a={};Object.defineProperty($a,"__esModule",{value:!0}),$a.isLineBreakTag=function(e){return["BR","WBR"].includes(e.tagName)},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.isLineBreakTag=void 0;var t=$a;Object.defineProperty(e,"isLineBreakTag",{enumerable:!0,get:function(){return t.isLineBreakTag}})}(Wa);var qa={},Ka={};Object.defineProperty(Ka,"__esModule",{value:!0}),Ka.isSingleTag=function(e){return["AREA","BASE","BR","COL","COMMAND","EMBED","HR","IMG","INPUT","KEYGEN","LINK","META","PARAM","SOURCE","TRACK","WBR"].includes(e.tagName)},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.isSingleTag=void 0;var t=Ka;Object.defineProperty(e,"isSingleTag",{enumerable:!0,get:function(){return t.isSingleTag}})}(qa),Object.defineProperty(za,"__esModule",{value:!0}),za.getDeepestNode=function e(t,o){void 0===o&&(o=!1);var n=o?"lastChild":"firstChild",i=o?"previousSibling":"nextSibling";if(t.nodeType===Node.ELEMENT_NODE&&t[n]){var r=t[n];if((0,Va.isSingleTag)(r)&&!(0,Ya.isNativeInput)(r)&&!(0,Xa.isLineBreakTag)(r))if(r[i])r=r[i];else{if(null===r.parentNode||!r.parentNode[i])return r.parentNode;r=r.parentNode[i]}return e(r,o)}return t};var Ya=ia,Xa=Wa,Va=qa;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.getDeepestNode=void 0;var t=za;Object.defineProperty(e,"getDeepestNode",{enumerable:!0,get:function(){return t.getDeepestNode}})}(Ua);var Ga={},Za={},Ja=Qs&&Qs.__spreadArray||function(e,t,o){if(o||2===arguments.length)for(var n,i=0,r=t.length;i<r;i++)(n||!(i in t))&&(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))};Object.defineProperty(Za,"__esModule",{value:!0}),Za.findAllInputs=function(e){return Array.from(e.querySelectorAll((0,tl.allInputsSelector)())).reduce((function(e,t){return(0,ol.isNativeInput)(t)||(0,Qa.containsOnlyInlineElements)(t)?Ja(Ja([],e,!0),[t],!1):Ja(Ja([],e,!0),(0,el.getDeepestBlockElements)(t),!0)}),[])};var Qa=va,el=Da,tl=oa,ol=ia;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.findAllInputs=void 0;var t=Za;Object.defineProperty(e,"findAllInputs",{enumerable:!0,get:function(){return t.findAllInputs}})}(Ga);var nl={},il={};Object.defineProperty(il,"__esModule",{value:!0}),il.isCollapsedWhitespaces=function(e){return!/[^\t\n\r ]/.test(e)},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.isCollapsedWhitespaces=void 0;var t=il;Object.defineProperty(e,"isCollapsedWhitespaces",{enumerable:!0,get:function(){return t.isCollapsedWhitespaces}})}(nl);var rl={},sl={};Object.defineProperty(sl,"__esModule",{value:!0}),sl.isElement=function(e){return!(0,al.isNumber)(e)&&(!!e&&!!e.nodeType&&e.nodeType===Node.ELEMENT_NODE)};var al=Ta;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.isElement=void 0;var t=sl;Object.defineProperty(e,"isElement",{enumerable:!0,get:function(){return t.isElement}})}(rl);var ll={},cl={},dl={},ul={};Object.defineProperty(ul,"__esModule",{value:!0}),ul.isLeaf=function(e){return null!==e&&0===e.childNodes.length},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.isLeaf=void 0;var t=ul;Object.defineProperty(e,"isLeaf",{enumerable:!0,get:function(){return t.isLeaf}})}(dl);var hl={},pl={};Object.defineProperty(pl,"__esModule",{value:!0}),pl.isNodeEmpty=function(e,t){var o="";return!((0,bl.isSingleTag)(e)&&!(0,fl.isLineBreakTag)(e))&&((0,gl.isElement)(e)&&(0,ml.isNativeInput)(e)?o=e.value:null!==e.textContent&&(o=e.textContent.replace("","")),void 0!==t&&(o=o.replace(new RegExp(t,"g"),"")),0===o.trim().length)};var fl=Wa,gl=rl,ml=ia,bl=qa;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.isNodeEmpty=void 0;var t=pl;Object.defineProperty(e,"isNodeEmpty",{enumerable:!0,get:function(){return t.isNodeEmpty}})}(hl),Object.defineProperty(cl,"__esModule",{value:!0}),cl.isEmpty=function(e,t){e.normalize();for(var o=[e];o.length>0;){var n=o.shift();if(n){if(e=n,(0,vl.isLeaf)(e)&&!(0,yl.isNodeEmpty)(e,t))return!1;o.push.apply(o,Array.from(e.childNodes))}}return!0};var vl=dl,yl=hl;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.isEmpty=void 0;var t=cl;Object.defineProperty(e,"isEmpty",{enumerable:!0,get:function(){return t.isEmpty}})}(ll);var kl={},wl={};Object.defineProperty(wl,"__esModule",{value:!0}),wl.isFragment=function(e){return!(0,xl.isNumber)(e)&&(!!e&&!!e.nodeType&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE)};var xl=Ta;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.isFragment=void 0;var t=wl;Object.defineProperty(e,"isFragment",{enumerable:!0,get:function(){return t.isFragment}})}(kl);var El={},Cl={};Object.defineProperty(Cl,"__esModule",{value:!0}),Cl.isHTMLString=function(e){var t=(0,Sl.make)("div");return t.innerHTML=e,t.childElementCount>0};var Sl=Ma;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.isHTMLString=void 0;var t=Cl;Object.defineProperty(e,"isHTMLString",{enumerable:!0,get:function(){return t.isHTMLString}})}(El);var Tl={},_l={};Object.defineProperty(_l,"__esModule",{value:!0}),_l.offset=function(e){var t=e.getBoundingClientRect(),o=window.pageXOffset||document.documentElement.scrollLeft,n=window.pageYOffset||document.documentElement.scrollTop,i=t.top+n,r=t.left+o;return{top:i,left:r,bottom:i+t.height,right:r+t.width}},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.offset=void 0;var t=_l;Object.defineProperty(e,"offset",{enumerable:!0,get:function(){return t.offset}})}(Tl);var Ol={},Bl={};Object.defineProperty(Bl,"__esModule",{value:!0}),Bl.prepend=function(e,t){Array.isArray(t)?(t=t.reverse()).forEach((function(t){return e.prepend(t)})):e.prepend(t)},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.prepend=void 0;var t=Bl;Object.defineProperty(e,"prepend",{enumerable:!0,get:function(){return t.prepend}})}(Ol),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.prepend=e.offset=e.make=e.isLineBreakTag=e.isSingleTag=e.isNodeEmpty=e.isLeaf=e.isHTMLString=e.isFragment=e.isEmpty=e.isElement=e.isContentEditable=e.isCollapsedWhitespaces=e.findAllInputs=e.isNativeInput=e.allInputsSelector=e.getDeepestNode=e.getDeepestBlockElements=e.getContentLength=e.fragmentToString=e.containsOnlyInlineElements=e.canSetCaret=e.calculateBaseline=e.blockElements=e.append=void 0;var t=oa;Object.defineProperty(e,"allInputsSelector",{enumerable:!0,get:function(){return t.allInputsSelector}});var o=ia;Object.defineProperty(e,"isNativeInput",{enumerable:!0,get:function(){return o.isNativeInput}});var n=sa;Object.defineProperty(e,"append",{enumerable:!0,get:function(){return n.append}});var i=la;Object.defineProperty(e,"blockElements",{enumerable:!0,get:function(){return i.blockElements}});var r=da;Object.defineProperty(e,"calculateBaseline",{enumerable:!0,get:function(){return r.calculateBaseline}});var s=ha;Object.defineProperty(e,"canSetCaret",{enumerable:!0,get:function(){return s.canSetCaret}});var a=va;Object.defineProperty(e,"containsOnlyInlineElements",{enumerable:!0,get:function(){return a.containsOnlyInlineElements}});var l=Ba;Object.defineProperty(e,"fragmentToString",{enumerable:!0,get:function(){return l.fragmentToString}});var c=Aa;Object.defineProperty(e,"getContentLength",{enumerable:!0,get:function(){return c.getContentLength}});var d=Da;Object.defineProperty(e,"getDeepestBlockElements",{enumerable:!0,get:function(){return d.getDeepestBlockElements}});var u=Ua;Object.defineProperty(e,"getDeepestNode",{enumerable:!0,get:function(){return u.getDeepestNode}});var h=Ga;Object.defineProperty(e,"findAllInputs",{enumerable:!0,get:function(){return h.findAllInputs}});var p=nl;Object.defineProperty(e,"isCollapsedWhitespaces",{enumerable:!0,get:function(){return p.isCollapsedWhitespaces}});var f=fa;Object.defineProperty(e,"isContentEditable",{enumerable:!0,get:function(){return f.isContentEditable}});var g=rl;Object.defineProperty(e,"isElement",{enumerable:!0,get:function(){return g.isElement}});var m=ll;Object.defineProperty(e,"isEmpty",{enumerable:!0,get:function(){return m.isEmpty}});var b=kl;Object.defineProperty(e,"isFragment",{enumerable:!0,get:function(){return b.isFragment}});var v=El;Object.defineProperty(e,"isHTMLString",{enumerable:!0,get:function(){return v.isHTMLString}});var y=dl;Object.defineProperty(e,"isLeaf",{enumerable:!0,get:function(){return y.isLeaf}});var k=hl;Object.defineProperty(e,"isNodeEmpty",{enumerable:!0,get:function(){return k.isNodeEmpty}});var w=Wa;Object.defineProperty(e,"isLineBreakTag",{enumerable:!0,get:function(){return w.isLineBreakTag}});var x=qa;Object.defineProperty(e,"isSingleTag",{enumerable:!0,get:function(){return x.isSingleTag}});var E=Ma;Object.defineProperty(e,"make",{enumerable:!0,get:function(){return E.make}});var C=Tl;Object.defineProperty(e,"offset",{enumerable:!0,get:function(){return C.offset}});var S=Ol;Object.defineProperty(e,"prepend",{enumerable:!0,get:function(){return S.prepend}})}(ta);var Il=(e=>(e.Left="left",e.Center="center",e))(Il||{});let Ml=class e{constructor({data:t,config:o,api:n,readOnly:i,block:r}){const{DEFAULT_ALIGNMENT:s}=e;this.api=n,this.readOnly=i,this.quotePlaceholder=n.i18n.t((null==o?void 0:o.quotePlaceholder)??e.DEFAULT_QUOTE_PLACEHOLDER),this.captionPlaceholder=n.i18n.t((null==o?void 0:o.captionPlaceholder)??e.DEFAULT_CAPTION_PLACEHOLDER),this.data={text:t.text||"",caption:t.caption||"",alignment:Object.values(Il).includes(t.alignment)?t.alignment:(null==o?void 0:o.defaultAlignment)??s},this.css={baseClass:this.api.styles.block,wrapper:"cdx-quote",text:"cdx-quote__text",input:this.api.styles.input,caption:"cdx-quote__caption"},this.block=r}static get isReadOnlySupported(){return!0}static get toolbox(){return{icon:'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 10.8182L9 10.8182C8.80222 10.8182 8.60888 10.7649 8.44443 10.665C8.27998 10.5651 8.15181 10.4231 8.07612 10.257C8.00043 10.0909 7.98063 9.90808 8.01922 9.73174C8.0578 9.55539 8.15304 9.39341 8.29289 9.26627C8.43275 9.13913 8.61093 9.05255 8.80491 9.01747C8.99889 8.98239 9.19996 9.00039 9.38268 9.0692C9.56541 9.13801 9.72159 9.25453 9.83147 9.40403C9.94135 9.55353 10 9.72929 10 9.90909L10 12.1818C10 12.664 9.78929 13.1265 9.41421 13.4675C9.03914 13.8084 8.53043 14 8 14"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 10.8182L15 10.8182C14.8022 10.8182 14.6089 10.7649 14.4444 10.665C14.28 10.5651 14.1518 10.4231 14.0761 10.257C14.0004 10.0909 13.9806 9.90808 14.0192 9.73174C14.0578 9.55539 14.153 9.39341 14.2929 9.26627C14.4327 9.13913 14.6109 9.05255 14.8049 9.01747C14.9989 8.98239 15.2 9.00039 15.3827 9.0692C15.5654 9.13801 15.7216 9.25453 15.8315 9.40403C15.9414 9.55353 16 9.72929 16 9.90909L16 12.1818C16 12.664 15.7893 13.1265 15.4142 13.4675C15.0391 13.8084 14.5304 14 14 14"/></svg>',title:"Quote"}}static get contentless(){return!0}static get enableLineBreaks(){return!0}static get DEFAULT_QUOTE_PLACEHOLDER(){return"Enter a quote"}static get DEFAULT_CAPTION_PLACEHOLDER(){return"Enter a caption"}static get DEFAULT_ALIGNMENT(){return"left"}static get conversionConfig(){return{import:"text",export:function(e){return e.caption?`${e.text} — ${e.caption}`:e.text}}}get CSS(){return{baseClass:this.api.styles.block,wrapper:"cdx-quote",text:"cdx-quote__text",input:this.api.styles.input,caption:"cdx-quote__caption"}}get settings(){return[{name:"left",icon:'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M17 7L5 7"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M17 17H5"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M13 12L5 12"/></svg>'},{name:"center",icon:'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M18 7L6 7"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M18 17H6"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M16 12L8 12"/></svg>'}]}render(){const e=ta.make("blockquote",[this.css.baseClass,this.css.wrapper]),t=ta.make("div",[this.css.input,this.css.text],{contentEditable:!this.readOnly,innerHTML:this.data.text}),o=ta.make("div",[this.css.input,this.css.caption],{contentEditable:!this.readOnly,innerHTML:this.data.caption});return t.dataset.placeholder=this.quotePlaceholder,o.dataset.placeholder=this.captionPlaceholder,e.appendChild(t),e.appendChild(o),e}save(e){const t=e.querySelector(`.${this.css.text}`),o=e.querySelector(`.${this.css.caption}`);return Object.assign(this.data,{text:(null==t?void 0:t.innerHTML)??"",caption:(null==o?void 0:o.innerHTML)??""})}static get sanitize(){return{text:{br:!0},caption:{br:!0},alignment:{}}}renderSettings(){const e=e=>e&&e[0].toUpperCase()+e.slice(1);return this.settings.map((t=>({icon:t.icon,label:this.api.i18n.t(`Align ${e(t.name)}`),onActivate:()=>this._toggleTune(t.name),isActive:this.data.alignment===t.name,closeOnActivate:!0})))}_toggleTune(e){this.data.alignment=e,this.block.dispatchChange()}};!function(){try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".ce-code__textarea{min-height:200px;font-family:Menlo,Monaco,Consolas,Courier New,monospace;color:#41314e;line-height:1.6em;font-size:12px;background:#f8f7fa;border:1px solid #f1f1f4;box-shadow:none;white-space:pre;word-wrap:normal;overflow-x:auto;resize:vertical}")),document.head.appendChild(e)}}catch(t){}}();
|
||
/**
|
||
* CodeTool for Editor.js
|
||
* @version 2.0.0
|
||
* @license MIT
|
||
*/
|
||
class Pl{static get isReadOnlySupported(){return!0}static get enableLineBreaks(){return!0}constructor({data:e,config:t,api:o,readOnly:n}){this.api=o,this.readOnly=n,this.placeholder=this.api.i18n.t(t.placeholder||Pl.DEFAULT_PLACEHOLDER),this.CSS={baseClass:this.api.styles.block,input:this.api.styles.input,wrapper:"ce-code",textarea:"ce-code__textarea"},this.nodes={holder:null,textarea:null},this.data={code:e.code??""},this.nodes.holder=this.drawView()}render(){return this.nodes.holder}save(e){return{code:e.querySelector("textarea").value}}onPaste(e){const t=e.detail;if("data"in t){const e=t.data;this.data={code:e||""}}}get data(){return this._data}set data(e){this._data=e,this.nodes.textarea&&(this.nodes.textarea.value=e.code)}static get toolbox(){return{icon:'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 8L5 12L9 16"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 8L19 12L15 16"/></svg>',title:"Code"}}static get DEFAULT_PLACEHOLDER(){return"Enter a code"}static get pasteConfig(){return{tags:["pre"]}}static get sanitize(){return{code:!0}}tabHandler(e){e.stopPropagation(),e.preventDefault();const t=e.target,o=e.shiftKey,n=t.selectionStart,i=t.value,r=" ";let s;if(o){const e=function(e,t){let o="";for(;"\n"!==o&&t>0;)t-=1,o=e.substr(t,1);return"\n"===o&&(t+=1),t}(i,n);if(i.substr(e,2)!==r)return;t.value=i.substring(0,e)+i.substring(e+2),s=n-2}else s=n+2,t.value=i.substring(0,n)+r+i.substring(n);t.setSelectionRange(s,s)}drawView(){const e=document.createElement("div"),t=document.createElement("textarea");return e.classList.add(this.CSS.baseClass,this.CSS.wrapper),t.classList.add(this.CSS.textarea,this.CSS.input),t.value=this.data.code,t.placeholder=this.placeholder,this.readOnly&&(t.disabled=!0),e.appendChild(t),t.addEventListener("keydown",(e=>{if("Tab"===e.code)this.tabHandler(e)})),this.nodes.textarea=t,e}}!function(){try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode('.embed-tool--loading .embed-tool__caption{display:none}.embed-tool--loading .embed-tool__preloader{display:block}.embed-tool--loading .embed-tool__content{display:none}.embed-tool__preloader{display:none;position:relative;height:200px;box-sizing:border-box;border-radius:5px;border:1px solid #e6e9eb}.embed-tool__preloader:before{content:"";position:absolute;z-index:3;left:50%;top:50%;width:30px;height:30px;margin-top:-25px;margin-left:-15px;border-radius:50%;border:2px solid #cdd1e0;border-top-color:#388ae5;box-sizing:border-box;animation:embed-preloader-spin 2s infinite linear}.embed-tool__url{position:absolute;bottom:20px;left:50%;transform:translate(-50%);max-width:250px;color:#7b7e89;font-size:11px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.embed-tool__content{width:100%}.embed-tool__caption{margin-top:7px}.embed-tool__caption[contentEditable=true][data-placeholder]:before{position:absolute;content:attr(data-placeholder);color:#707684;font-weight:400;opacity:0}.embed-tool__caption[contentEditable=true][data-placeholder]:empty:before{opacity:1}.embed-tool__caption[contentEditable=true][data-placeholder]:empty:focus:before{opacity:0}@keyframes embed-preloader-spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}')),document.head.appendChild(e)}}catch(t){}}();const Ll={vimeo:{regex:/(?:http[s]?:\/\/)?(?:www.)?(?:player.)?vimeo\.co(?:.+\/([^\/]\d+)(?:#t=[\d]+)?s?$)/,embedUrl:"https://player.vimeo.com/video/<%= remote_id %>?title=0&byline=0",html:'<iframe style="width:100%;" height="320" frameborder="0"></iframe>',height:320,width:580},youtube:{regex:/(?:https?:\/\/)?(?:www\.)?(?:(?:youtu\.be\/)|(?:youtube\.com)\/(?:v\/|u\/\w\/|embed\/|watch))(?:(?:\?v=)?([^#&?=]*))?((?:[?&]\w*=\w*)*)/,embedUrl:"https://www.youtube.com/embed/<%= remote_id %>",html:'<iframe style="width:100%;" height="320" frameborder="0" allowfullscreen></iframe>',height:320,width:580,id:([e,t])=>{if(!t&&e)return e;const o={start:"start",end:"end",t:"start",time_continue:"start",list:"list"};let n=t.slice(1).split("&").map((t=>{const[n,i]=t.split("=");return e||"v"!==n?!o[n]||"LL"===i||i.startsWith("RDMM")||i.startsWith("FL")?null:`${o[n]}=${i}`:(e=i,null)})).filter((e=>!!e));return e+"?"+n.join("&")}},coub:{regex:/https?:\/\/coub\.com\/view\/([^\/\?\&]+)/,embedUrl:"https://coub.com/embed/<%= remote_id %>",html:'<iframe style="width:100%;" height="320" frameborder="0" allowfullscreen></iframe>',height:320,width:580},vine:{regex:/https?:\/\/vine\.co\/v\/([^\/\?\&]+)/,embedUrl:"https://vine.co/v/<%= remote_id %>/embed/simple/",html:'<iframe style="width:100%;" height="320" frameborder="0" allowfullscreen></iframe>',height:320,width:580},imgur:{regex:/https?:\/\/(?:i\.)?imgur\.com.*\/([a-zA-Z0-9]+)(?:\.gifv)?/,embedUrl:"http://imgur.com/<%= remote_id %>/embed",html:'<iframe allowfullscreen="true" scrolling="no" id="imgur-embed-iframe-pub-<%= remote_id %>" class="imgur-embed-iframe-pub" style="height: 500px; width: 100%; border: 1px solid #000"></iframe>',height:500,width:540},gfycat:{regex:/https?:\/\/gfycat\.com(?:\/detail)?\/([a-zA-Z]+)/,embedUrl:"https://gfycat.com/ifr/<%= remote_id %>",html:"<iframe frameborder='0' scrolling='no' style=\"width:100%;\" height='436' allowfullscreen ></iframe>",height:436,width:580},"twitch-channel":{regex:/https?:\/\/www\.twitch\.tv\/([^\/\?\&]*)\/?$/,embedUrl:"https://player.twitch.tv/?channel=<%= remote_id %>",html:'<iframe frameborder="0" allowfullscreen="true" scrolling="no" height="366" style="width:100%;"></iframe>',height:366,width:600},"twitch-video":{regex:/https?:\/\/www\.twitch\.tv\/(?:[^\/\?\&]*\/v|videos)\/([0-9]*)/,embedUrl:"https://player.twitch.tv/?video=v<%= remote_id %>",html:'<iframe frameborder="0" allowfullscreen="true" scrolling="no" height="366" style="width:100%;"></iframe>',height:366,width:600},"yandex-music-album":{regex:/https?:\/\/music\.yandex\.ru\/album\/([0-9]*)\/?$/,embedUrl:"https://music.yandex.ru/iframe/#album/<%= remote_id %>/",html:'<iframe frameborder="0" style="border:none;width:540px;height:400px;" style="width:100%;" height="400"></iframe>',height:400,width:540},"yandex-music-track":{regex:/https?:\/\/music\.yandex\.ru\/album\/([0-9]*)\/track\/([0-9]*)/,embedUrl:"https://music.yandex.ru/iframe/#track/<%= remote_id %>/",html:'<iframe frameborder="0" style="border:none;width:540px;height:100px;" style="width:100%;" height="100"></iframe>',height:100,width:540,id:e=>e.join("/")},"yandex-music-playlist":{regex:/https?:\/\/music\.yandex\.ru\/users\/([^\/\?\&]*)\/playlists\/([0-9]*)/,embedUrl:"https://music.yandex.ru/iframe/#playlist/<%= remote_id %>/show/cover/description/",html:'<iframe frameborder="0" style="border:none;width:540px;height:400px;" width="540" height="400"></iframe>',height:400,width:540,id:e=>e.join("/")},codepen:{regex:/https?:\/\/codepen\.io\/([^\/\?\&]*)\/pen\/([^\/\?\&]*)/,embedUrl:"https://codepen.io/<%= remote_id %>?height=300&theme-id=0&default-tab=css,result&embed-version=2",html:"<iframe height='300' scrolling='no' frameborder='no' allowtransparency='true' allowfullscreen='true' style='width: 100%;'></iframe>",height:300,width:600,id:e=>e.join("/embed/")},instagram:{regex:/^https:\/\/(?:www\.)?instagram\.com\/(?:reel|p)\/(.*)/,embedUrl:"https://www.instagram.com/p/<%= remote_id %>/embed",html:'<iframe width="400" height="505" style="margin: 0 auto;" frameborder="0" scrolling="no" allowtransparency="true"></iframe>',height:505,width:400,id:e=>{var t;return null==(t=null==e?void 0:e[0])?void 0:t.split("/")[0]}},twitter:{regex:/^https?:\/\/(www\.)?(?:twitter\.com|x\.com)\/.+\/status\/(\d+)/,embedUrl:"https://platform.twitter.com/embed/Tweet.html?id=<%= remote_id %>",html:'<iframe width="600" height="600" style="margin: 0 auto;" frameborder="0" scrolling="no" allowtransparency="true"></iframe>',height:300,width:600,id:e=>e[1]},pinterest:{regex:/https?:\/\/([^\/\?\&]*).pinterest.com\/pin\/([^\/\?\&]*)\/?$/,embedUrl:"https://assets.pinterest.com/ext/embed.html?id=<%= remote_id %>",html:"<iframe scrolling='no' frameborder='no' allowtransparency='true' allowfullscreen='true' style='width: 100%; min-height: 400px; max-height: 1000px;'></iframe>",id:e=>e[1]},facebook:{regex:/https?:\/\/www.facebook.com\/([^\/\?\&]*)\/(.*)/,embedUrl:"https://www.facebook.com/plugins/post.php?href=https://www.facebook.com/<%= remote_id %>&width=500",html:"<iframe scrolling='no' frameborder='no' allowtransparency='true' allowfullscreen='true' style='width: 100%; min-height: 500px; max-height: 1000px;'></iframe>",id:e=>e.join("/")},aparat:{regex:/(?:http[s]?:\/\/)?(?:www.)?aparat\.com\/v\/([^\/\?\&]+)\/?/,embedUrl:"https://www.aparat.com/video/video/embed/videohash/<%= remote_id %>/vt/frame",html:'<iframe width="600" height="300" style="margin: 0 auto;" frameborder="0" scrolling="no" allowtransparency="true"></iframe>',height:300,width:600},miro:{regex:/https:\/\/miro.com\/\S+(\S{12})\/(\S+)?/,embedUrl:"https://miro.com/app/live-embed/<%= remote_id %>",html:'<iframe width="700" height="500" style="margin: 0 auto;" allowFullScreen frameBorder="0" scrolling="no"></iframe>'},github:{regex:/https?:\/\/gist.github.com\/([^\/\?\&]*)\/([^\/\?\&]*)/,embedUrl:'data:text/html;charset=utf-8,<head><base target="_blank" /></head><body><script src="https://gist.github.com/<%= remote_id %>" ><\/script></body>',html:'<iframe width="100%" height="350" frameborder="0" style="margin: 0 auto;"></iframe>',height:300,width:600,id:e=>`${e.join("/")}.js`}};function Al(e,t,o){var n,i,r,s,a;function l(){var c=Date.now()-s;c<t&&c>=0?n=setTimeout(l,t-c):(n=null,o||(a=e.apply(r,i),r=i=null))}null==t&&(t=100);var c=function(){r=this,i=arguments,s=Date.now();var c=o&&!n;return n||(n=setTimeout(l,t)),c&&(a=e.apply(r,i),r=i=null),a};return c.clear=function(){n&&(clearTimeout(n),n=null)},c.flush=function(){n&&(a=e.apply(r,i),r=i=null,clearTimeout(n),n=null)},c}Al.debounce=Al;var Nl=Al;class jl{constructor({data:e,api:t,readOnly:o}){this.api=t,this._data={},this.element=null,this.readOnly=o,this.data=e}set data(e){var t;if(!(e instanceof Object))throw Error("Embed Tool data should be object");const{service:o,source:n,embed:i,width:r,height:s,caption:a=""}=e;this._data={service:o||this.data.service,source:n||this.data.source,embed:i||this.data.embed,width:r||this.data.width,height:s||this.data.height,caption:a||this.data.caption||""};const l=this.element;l&&(null==(t=l.parentNode)||t.replaceChild(this.render(),l))}get data(){if(this.element){const e=this.element.querySelector(`.${this.api.styles.input}`);this._data.caption=e?e.innerHTML:""}return this._data}get CSS(){return{baseClass:this.api.styles.block,input:this.api.styles.input,container:"embed-tool",containerLoading:"embed-tool--loading",preloader:"embed-tool__preloader",caption:"embed-tool__caption",url:"embed-tool__url",content:"embed-tool__content"}}render(){if(!this.data.service){const e=document.createElement("div");return this.element=e,e}const{html:e}=jl.services[this.data.service],t=document.createElement("div"),o=document.createElement("div"),n=document.createElement("template"),i=this.createPreloader();t.classList.add(this.CSS.baseClass,this.CSS.container,this.CSS.containerLoading),o.classList.add(this.CSS.input,this.CSS.caption),t.appendChild(i),o.contentEditable=(!this.readOnly).toString(),o.dataset.placeholder=this.api.i18n.t("Enter a caption"),o.innerHTML=this.data.caption||"",n.innerHTML=e,n.content.firstChild.setAttribute("src",this.data.embed),n.content.firstChild.classList.add(this.CSS.content);const r=this.embedIsReady(t);return n.content.firstChild&&t.appendChild(n.content.firstChild),t.appendChild(o),r.then((()=>{t.classList.remove(this.CSS.containerLoading)})),this.element=t,t}createPreloader(){const e=document.createElement("preloader"),t=document.createElement("div");return t.textContent=this.data.source,e.classList.add(this.CSS.preloader),t.classList.add(this.CSS.url),e.appendChild(t),e}save(){return this.data}onPaste(e){var t;const{key:o,data:n}=e.detail,{regex:i,embedUrl:r,width:s,height:a,id:l=e=>e.shift()||""}=jl.services[o],c=null==(t=i.exec(n))?void 0:t.slice(1),d=c?r.replace(/<%= remote_id %>/g,l(c)):"";this.data={service:o,source:n,embed:d,width:s,height:a}}static prepare({config:e={}}){const{services:t={}}=e;let o=Object.entries(Ll);const n=Object.entries(t).filter((([e,t])=>"boolean"==typeof t&&!0===t)).map((([e])=>e)),i=Object.entries(t).filter((([e,t])=>"object"==typeof t)).filter((([e,t])=>jl.checkServiceConfig(t))).map((([e,t])=>{const{regex:o,embedUrl:n,html:i,height:r,width:s,id:a}=t;return[e,{regex:o,embedUrl:n,html:i,height:r,width:s,id:a}]}));n.length&&(o=o.filter((([e])=>n.includes(e)))),o=o.concat(i),jl.services=o.reduce(((e,[t,o])=>t in e?(e[t]=Object.assign({},e[t],o),e):(e[t]=o,e)),{}),jl.patterns=o.reduce(((e,[t,o])=>(o&&"boolean"!=typeof o&&(e[t]=o.regex),e)),{})}static checkServiceConfig(e){const{regex:t,embedUrl:o,html:n,height:i,width:r,id:s}=e;let a=!!(t&&t instanceof RegExp)&&!(!o||"string"!=typeof o)&&!(!n||"string"!=typeof n);return a=a&&(void 0===s||s instanceof Function),a=a&&(void 0===i||Number.isFinite(i)),a=a&&(void 0===r||Number.isFinite(r)),a}static get pasteConfig(){return{patterns:jl.patterns}}static get isReadOnlySupported(){return!0}embedIsReady(e){let t;return new Promise(((o,n)=>{t=new MutationObserver(Nl.debounce(o,450)),t.observe(e,{childList:!0,subtree:!0})})).then((()=>{t.disconnect()}))}}!function(){try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".link-tool{position:relative}.link-tool__input{padding-left:38px;background-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='none'%3E%3Cpath stroke='%23707684' stroke-linecap='round' stroke-width='2' d='m7.7 12.6-.021.02a2.795 2.795 0 0 0-.044 4.005v0a2.795 2.795 0 0 0 3.936.006l1.455-1.438a3 3 0 0 0 .34-3.866l-.146-.207'/%3E%3Cpath stroke='%23707684' stroke-linecap='round' stroke-width='2' d='m16.22 11.12.136-.14c.933-.954.992-2.46.135-3.483v0a2.597 2.597 0 0 0-3.664-.32L11.39 8.386a3 3 0 0 0-.301 4.3l.031.034'/%3E%3C/svg%3E\");background-repeat:no-repeat;background-position:10px;white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.link-tool__input-holder{position:relative}.link-tool__input-holder--error .link-tool__input{background-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='none'%3E%3Cpath stroke='rgb(224, 147, 147)' stroke-linecap='round' stroke-width='2' d='m7.7 12.6-.021.02a2.795 2.795 0 0 0-.044 4.005v0a2.795 2.795 0 0 0 3.936.006l1.455-1.438a3 3 0 0 0 .34-3.866l-.146-.207'/%3E%3Cpath stroke='rgb(224, 147, 147)' stroke-linecap='round' stroke-width='2' d='m16.22 11.12.136-.14c.933-.954.992-2.46.135-3.483v0a2.597 2.597 0 0 0-3.664-.32L11.39 8.386a3 3 0 0 0-.301 4.3l.031.034'/%3E%3C/svg%3E\");background-color:#fff3f6;border-color:#f3e0e0;color:#a95a5a;box-shadow:inset 0 1px 3px #923e3e0d}.link-tool__input[contentEditable=true][data-placeholder]:before{position:absolute;content:attr(data-placeholder);color:#707684;font-weight:400;opacity:0}.link-tool__input[contentEditable=true][data-placeholder]:empty:before{opacity:1}.link-tool__input[contentEditable=true][data-placeholder]:empty:focus:before{opacity:0}.link-tool__progress{position:absolute;box-shadow:inset 0 1px 3px #66556b0a;height:100%;width:0;background-color:#f4f5f7;z-index:-1}.link-tool__progress--loading{-webkit-animation:progress .5s ease-in;-webkit-animation-fill-mode:forwards}.link-tool__progress--loaded{width:100%}.link-tool__content{display:block;padding:25px;border-radius:2px;box-shadow:0 0 0 2px #fff;color:initial!important;text-decoration:none!important}.link-tool__content:after{content:\"\";clear:both;display:table}.link-tool__content--rendered{background:#fff;border:1px solid rgba(201,201,204,.48);box-shadow:0 1px 3px #0000001a;border-radius:6px;will-change:filter;animation:link-in .45s 1 cubic-bezier(.215,.61,.355,1)}.link-tool__content--rendered:hover{box-shadow:0 0 3px #00000029}.link-tool__image{background-position:center center;background-repeat:no-repeat;background-size:cover;margin:0 0 0 30px;width:65px;height:65px;border-radius:3px;float:right}.link-tool__title{font-size:17px;font-weight:600;line-height:1.5em;margin:0 0 10px}.link-tool__title+.link-tool__anchor{margin-top:25px}.link-tool__description{margin:0 0 20px;font-size:15px;line-height:1.55em;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden}.link-tool__anchor{display:block;font-size:15px;line-height:1em;color:#888!important;border:0!important;padding:0!important}@keyframes link-in{0%{filter:blur(5px)}to{filter:none}}.codex-editor--narrow .link-tool__image{display:none}@-webkit-keyframes progress{0%{width:0}to{width:85%}}")),document.head.appendChild(e)}}catch(t){}}();var Dl=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Rl(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}!function(e){var t,o,n=function(){try{return!!Symbol.iterator}catch{return!1}}(),i=function(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return n&&(t[Symbol.iterator]=function(){return t}),t},r=function(e){return encodeURIComponent(e).replace(/%20/g,"+")},s=function(e){return decodeURIComponent(String(e).replace(/\+/g," "))};(function(){try{var t=e.URLSearchParams;return"a=1"===new t("?a=1").toString()&&"function"==typeof t.prototype.set}catch{return!1}})()||((o=(t=function(e){Object.defineProperty(this,"_entries",{writable:!0,value:{}});var o=typeof e;if("undefined"!==o)if("string"===o)""!==e&&this._fromString(e);else if(e instanceof t){var n=this;e.forEach((function(e,t){n.append(t,e)}))}else{if(null===e||"object"!==o)throw new TypeError("Unsupported input's type for URLSearchParams");if("[object Array]"===Object.prototype.toString.call(e))for(var i=0;i<e.length;i++){var r=e[i];if("[object Array]"!==Object.prototype.toString.call(r)&&2===r.length)throw new TypeError("Expected [string, any] as entry at index "+i+" of URLSearchParams's input");this.append(r[0],r[1])}else for(var s in e)e.hasOwnProperty(s)&&this.append(s,e[s])}}).prototype).append=function(e,t){e in this._entries?this._entries[e].push(String(t)):this._entries[e]=[String(t)]},o.delete=function(e){delete this._entries[e]},o.get=function(e){return e in this._entries?this._entries[e][0]:null},o.getAll=function(e){return e in this._entries?this._entries[e].slice(0):[]},o.has=function(e){return e in this._entries},o.set=function(e,t){this._entries[e]=[String(t)]},o.forEach=function(e,t){var o;for(var n in this._entries)if(this._entries.hasOwnProperty(n)){o=this._entries[n];for(var i=0;i<o.length;i++)e.call(t,o[i],n,this)}},o.keys=function(){var e=[];return this.forEach((function(t,o){e.push(o)})),i(e)},o.values=function(){var e=[];return this.forEach((function(t){e.push(t)})),i(e)},o.entries=function(){var e=[];return this.forEach((function(t,o){e.push([o,t])})),i(e)},n&&(o[Symbol.iterator]=o.entries),o.toString=function(){var e=[];return this.forEach((function(t,o){e.push(r(o)+"="+r(t))})),e.join("&")},e.URLSearchParams=t);var a=e.URLSearchParams.prototype;"function"!=typeof a.sort&&(a.sort=function(){var e=this,t=[];this.forEach((function(o,n){t.push([n,o]),e._entries||e.delete(n)})),t.sort((function(e,t){return e[0]<t[0]?-1:e[0]>t[0]?1:0})),e._entries&&(e._entries={});for(var o=0;o<t.length;o++)this.append(t[o][0],t[o][1])}),"function"!=typeof a._fromString&&Object.defineProperty(a,"_fromString",{enumerable:!1,configurable:!1,writable:!1,value:function(e){if(this._entries)this._entries={};else{var t=[];this.forEach((function(e,o){t.push(o)}));for(var o=0;o<t.length;o++)this.delete(t[o])}var n,i=(e=e.replace(/^\?/,"")).split("&");for(o=0;o<i.length;o++)n=i[o].split("="),this.append(s(n[0]),n.length>1?s(n[1]):"")}})}(typeof Dl<"u"?Dl:typeof window<"u"?window:typeof self<"u"?self:Dl),function(e){var t,o,n;if(function(){try{var t=new e.URL("b","http://a");return t.pathname="c d","http://a/c%20d"===t.href&&t.searchParams}catch{return!1}}()||(t=e.URL,o=function(t,o){"string"!=typeof t&&(t=String(t));var n,i=document;if(o&&(void 0===e.location||o!==e.location.href)){(n=(i=document.implementation.createHTMLDocument("")).createElement("base")).href=o,i.head.appendChild(n);try{if(0!==n.href.indexOf(o))throw new Error(n.href)}catch(h){throw new Error("URL unable to set base "+o+" due to "+h)}}var r=i.createElement("a");r.href=t,n&&(i.body.appendChild(r),r.href=r.href);var s=i.createElement("input");if(s.type="url",s.value=t,":"===r.protocol||!/:/.test(r.href)||!s.checkValidity()&&!o)throw new TypeError("Invalid URL");Object.defineProperty(this,"_anchorElement",{value:r});var a=new e.URLSearchParams(this.search),l=!0,c=!0,d=this;["append","delete","set"].forEach((function(e){var t=a[e];a[e]=function(){t.apply(a,arguments),l&&(c=!1,d.search=a.toString(),c=!0)}})),Object.defineProperty(this,"searchParams",{value:a,enumerable:!0});var u=void 0;Object.defineProperty(this,"_updateSearchParams",{enumerable:!1,configurable:!1,writable:!1,value:function(){this.search!==u&&(u=this.search,c&&(l=!1,this.searchParams._fromString(this.search),l=!0))}})},n=o.prototype,["hash","host","hostname","port","protocol"].forEach((function(e){!function(e){Object.defineProperty(n,e,{get:function(){return this._anchorElement[e]},set:function(t){this._anchorElement[e]=t},enumerable:!0})}(e)})),Object.defineProperty(n,"search",{get:function(){return this._anchorElement.search},set:function(e){this._anchorElement.search=e,this._updateSearchParams()},enumerable:!0}),Object.defineProperties(n,{toString:{get:function(){var e=this;return function(){return e.href}}},href:{get:function(){return this._anchorElement.href.replace(/\?$/,"")},set:function(e){this._anchorElement.href=e,this._updateSearchParams()},enumerable:!0},pathname:{get:function(){return this._anchorElement.pathname.replace(/(^\/?)/,"/")},set:function(e){this._anchorElement.pathname=e},enumerable:!0},origin:{get:function(){var e={"http:":80,"https:":443,"ftp:":21}[this._anchorElement.protocol],t=this._anchorElement.port!=e&&""!==this._anchorElement.port;return this._anchorElement.protocol+"//"+this._anchorElement.hostname+(t?":"+this._anchorElement.port:"")},enumerable:!0},password:{get:function(){return""},set:function(e){},enumerable:!0},username:{get:function(){return""},set:function(e){},enumerable:!0}}),o.createObjectURL=function(e){return t.createObjectURL.apply(t,arguments)},o.revokeObjectURL=function(e){return t.revokeObjectURL.apply(t,arguments)},e.URL=o),void 0!==e.location&&!("origin"in e.location)){var i=function(){return e.location.protocol+"//"+e.location.hostname+(e.location.port?":"+e.location.port:"")};try{Object.defineProperty(e.location,"origin",{get:i,enumerable:!0})}catch{setInterval((function(){e.location.origin=i()}),100)}}}(typeof Dl<"u"?Dl:typeof window<"u"?window:typeof self<"u"?self:Dl);var Fl={exports:{}};window;const Hl=Rl(Fl.exports=function(e){var t={};function o(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,o),i.l=!0,i.exports}return o.m=e,o.c=t,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t||4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)o.d(n,i,function(t){return e[t]}.bind(null,i));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=3)}([function(e,t){var o;o=function(){return this}();try{o=o||new Function("return this")()}catch{"object"==typeof window&&(o=window)}e.exports=o},function(e,t,o){(function(e){var n=o(2),i=setTimeout;function r(){}function s(e){if(!(this instanceof s))throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],h(e,this)}function a(e,t){for(;3===e._state;)e=e._value;0!==e._state?(e._handled=!0,s._immediateFn((function(){var o=1===e._state?t.onFulfilled:t.onRejected;if(null!==o){var n;try{n=o(e._value)}catch(i){return void c(t.promise,i)}l(t.promise,n)}else(1===e._state?l:c)(t.promise,e._value)}))):e._deferreds.push(t)}function l(e,t){try{if(t===e)throw new TypeError("A promise cannot be resolved with itself.");if(t&&("object"==typeof t||"function"==typeof t)){var o=t.then;if(t instanceof s)return e._state=3,e._value=t,void d(e);if("function"==typeof o)return void h((n=o,i=t,function(){n.apply(i,arguments)}),e)}e._state=1,e._value=t,d(e)}catch(r){c(e,r)}var n,i}function c(e,t){e._state=2,e._value=t,d(e)}function d(e){2===e._state&&0===e._deferreds.length&&s._immediateFn((function(){e._handled||s._unhandledRejectionFn(e._value)}));for(var t=0,o=e._deferreds.length;t<o;t++)a(e,e._deferreds[t]);e._deferreds=null}function u(e,t,o){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.promise=o}function h(e,t){var o=!1;try{e((function(e){o||(o=!0,l(t,e))}),(function(e){o||(o=!0,c(t,e))}))}catch(n){if(o)return;o=!0,c(t,n)}}s.prototype.catch=function(e){return this.then(null,e)},s.prototype.then=function(e,t){var o=new this.constructor(r);return a(this,new u(e,t,o)),o},s.prototype.finally=n.a,s.all=function(e){return new s((function(t,o){if(!e||void 0===e.length)throw new TypeError("Promise.all accepts an array");var n=Array.prototype.slice.call(e);if(0===n.length)return t([]);var i=n.length;function r(e,s){try{if(s&&("object"==typeof s||"function"==typeof s)){var a=s.then;if("function"==typeof a)return void a.call(s,(function(t){r(e,t)}),o)}n[e]=s,0==--i&&t(n)}catch(l){o(l)}}for(var s=0;s<n.length;s++)r(s,n[s])}))},s.resolve=function(e){return e&&"object"==typeof e&&e.constructor===s?e:new s((function(t){t(e)}))},s.reject=function(e){return new s((function(t,o){o(e)}))},s.race=function(e){return new s((function(t,o){for(var n=0,i=e.length;n<i;n++)e[n].then(t,o)}))},s._immediateFn="function"==typeof e&&function(t){e(t)}||function(e){i(e,0)},s._unhandledRejectionFn=function(e){typeof console<"u"&&console},t.a=s}).call(this,o(5).setImmediate)},function(e,t,o){t.a=function(e){var t=this.constructor;return this.then((function(o){return t.resolve(e()).then((function(){return o}))}),(function(o){return t.resolve(e()).then((function(){return t.reject(o)}))}))}},function(e,t,o){function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}o(4);var i,r,s,a,l,c,d=o(8),u=(r=function(e){return new Promise((function(t,o){e=a(e),e=l(e);var n=window.XMLHttpRequest?new window.XMLHttpRequest:new window.ActiveXObject("Microsoft.XMLHTTP");n.open(e.method,e.url),n.setRequestHeader("X-Requested-With","XMLHttpRequest"),Object.keys(e.headers).forEach((function(t){var o=e.headers[t];n.setRequestHeader(t,o)}));var i=e.ratio;n.upload.addEventListener("progress",(function(t){var o=Math.round(t.loaded/t.total*100),n=Math.ceil(o*i/100);e.progress(n)}),!1),n.addEventListener("progress",(function(t){var o=Math.round(t.loaded/t.total*100),n=Math.ceil(o*(100-i)/100)+i;e.progress(n)}),!1),n.onreadystatechange=function(){if(4===n.readyState){var e=n.response;try{e=JSON.parse(e)}catch{}var i=d.parseHeaders(n.getAllResponseHeaders()),r={body:e,code:n.status,headers:i};200===n.status?t(r):o(r)}},n.send(e.data)}))},s=function(e){return e.method="POST",r(e)},a=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(e.url&&"string"!=typeof e.url)throw new Error("Url must be a string");if(e.url=e.url||"",e.method&&"string"!=typeof e.method)throw new Error("`method` must be a string or null");if(e.method=e.method?e.method.toUpperCase():"GET",e.headers&&"object"!==n(e.headers))throw new Error("`headers` must be an object or null");if(e.headers=e.headers||{},e.type&&("string"!=typeof e.type||!Object.values(i).includes(e.type)))throw new Error("`type` must be taken from module's «contentType» library");if(e.progress&&"function"!=typeof e.progress)throw new Error("`progress` must be a function or null");if(e.progress=e.progress||function(e){},e.beforeSend=e.beforeSend||function(e){},e.ratio&&"number"!=typeof e.ratio)throw new Error("`ratio` must be a number");if(e.ratio<0||e.ratio>100)throw new Error("`ratio` must be in a 0-100 interval");if(e.ratio=e.ratio||90,e.accept&&"string"!=typeof e.accept)throw new Error("`accept` must be a string with a list of allowed mime-types");if(e.accept=e.accept||"*/*",e.multiple&&"boolean"!=typeof e.multiple)throw new Error("`multiple` must be a true or false");if(e.multiple=e.multiple||!1,e.fieldName&&"string"!=typeof e.fieldName)throw new Error("`fieldName` must be a string");return e.fieldName=e.fieldName||"files",e},l=function(e){switch(e.method){case"GET":var t=c(e.data,i.URLENCODED);delete e.data,e.url=/\?/.test(e.url)?e.url+"&"+t:e.url+"?"+t;break;case"POST":case"PUT":case"DELETE":case"UPDATE":var o=function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).type||i.JSON}(e);(d.isFormData(e.data)||d.isFormElement(e.data))&&(o=i.FORM),e.data=c(e.data,o),o!==u.contentType.FORM&&(e.headers["content-type"]=o)}return e},c=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};switch(arguments.length>1?arguments[1]:void 0){case i.URLENCODED:return d.urlEncode(e);case i.JSON:return d.jsonEncode(e);case i.FORM:return d.formEncode(e);default:return e}},{contentType:i={URLENCODED:"application/x-www-form-urlencoded; charset=utf-8",FORM:"multipart/form-data",JSON:"application/json; charset=utf-8"},request:r,get:function(e){return e.method="GET",r(e)},post:s,transport:function(e){return e=a(e),d.selectFiles(e).then((function(t){for(var o=new FormData,n=0;n<t.length;n++)o.append(e.fieldName,t[n],t[n].name);return d.isObject(e.data)&&Object.keys(e.data).forEach((function(t){var n=e.data[t];o.append(t,n)})),e.beforeSend&&e.beforeSend(t),e.data=o,s(e)}))},selectFiles:function(e){return delete(e=a(e)).beforeSend,d.selectFiles(e)}});e.exports=u},function(e,t,o){o.r(t);var n=o(1);window.Promise=window.Promise||n.a},function(e,t,o){(function(e){var n=void 0!==e&&e||typeof self<"u"&&self||window,i=Function.prototype.apply;function r(e,t){this._id=e,this._clearFn=t}t.setTimeout=function(){return new r(i.call(setTimeout,n,arguments),clearTimeout)},t.setInterval=function(){return new r(i.call(setInterval,n,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e&&e.close()},r.prototype.unref=r.prototype.ref=function(){},r.prototype.close=function(){this._clearFn.call(n,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout((function(){e._onTimeout&&e._onTimeout()}),t))},o(6),t.setImmediate=typeof self<"u"&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate=typeof self<"u"&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,o(0))},function(e,t,o){(function(e,t){!function(e,o){if(!e.setImmediate){var n,i,r,s,a,l=1,c={},d=!1,u=e.document,h=Object.getPrototypeOf&&Object.getPrototypeOf(e);h=h&&h.setTimeout?h:e,"[object process]"==={}.toString.call(e.process)?n=function(e){t.nextTick((function(){f(e)}))}:function(){if(e.postMessage&&!e.importScripts){var t=!0,o=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=o,t}}()?(s="setImmediate$"+Math.random()+"$",a=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(s)&&f(+t.data.slice(s.length))},e.addEventListener?e.addEventListener("message",a,!1):e.attachEvent("onmessage",a),n=function(t){e.postMessage(s+t,"*")}):e.MessageChannel?((r=new MessageChannel).port1.onmessage=function(e){f(e.data)},n=function(e){r.port2.postMessage(e)}):u&&"onreadystatechange"in u.createElement("script")?(i=u.documentElement,n=function(e){var t=u.createElement("script");t.onreadystatechange=function(){f(e),t.onreadystatechange=null,i.removeChild(t),t=null},i.appendChild(t)}):n=function(e){setTimeout(f,0,e)},h.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),o=0;o<t.length;o++)t[o]=arguments[o+1];var i={callback:e,args:t};return c[l]=i,n(l),l++},h.clearImmediate=p}function p(e){delete c[e]}function f(e){if(d)setTimeout(f,0,e);else{var t=c[e];if(t){d=!0;try{!function(e){var t=e.callback,n=e.args;switch(n.length){case 0:t();break;case 1:t(n[0]);break;case 2:t(n[0],n[1]);break;case 3:t(n[0],n[1],n[2]);break;default:t.apply(o,n)}}(t)}finally{p(e),d=!1}}}}}(typeof self>"u"?void 0===e?this:e:self)}).call(this,o(0),o(7))},function(e,t){var o,n,i=e.exports={};function r(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function a(e){if(o===setTimeout)return setTimeout(e,0);if((o===r||!o)&&setTimeout)return o=setTimeout,setTimeout(e,0);try{return o(e,0)}catch{try{return o.call(null,e,0)}catch{return o.call(this,e,0)}}}!function(){try{o="function"==typeof setTimeout?setTimeout:r}catch{o=r}try{n="function"==typeof clearTimeout?clearTimeout:s}catch{n=s}}();var l,c=[],d=!1,u=-1;function h(){d&&l&&(d=!1,l.length?c=l.concat(c):u=-1,c.length&&p())}function p(){if(!d){var e=a(h);d=!0;for(var t=c.length;t;){for(l=c,c=[];++u<t;)l&&l[u].run();u=-1,t=c.length}l=null,d=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===s||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch{try{return n.call(null,e)}catch{return n.call(this,e)}}}(e)}}function f(e,t){this.fun=e,this.array=t}function g(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var o=1;o<arguments.length;o++)t[o-1]=arguments[o];c.push(new f(e,t)),1!==c.length||d||a(p)},f.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=g,i.addListener=g,i.once=g,i.off=g,i.removeListener=g,i.removeAllListeners=g,i.emit=g,i.prependListener=g,i.prependOnceListener=g,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},function(e,t,o){function n(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var i=o(9);e.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,o,r;return t=e,r=[{key:"urlEncode",value:function(e){return i(e)}},{key:"jsonEncode",value:function(e){return JSON.stringify(e)}},{key:"formEncode",value:function(e){if(this.isFormData(e))return e;if(this.isFormElement(e))return new FormData(e);if(this.isObject(e)){var t=new FormData;return Object.keys(e).forEach((function(o){var n=e[o];t.append(o,n)})),t}throw new Error("`data` must be an instance of Object, FormData or <FORM> HTMLElement")}},{key:"isObject",value:function(e){return"[object Object]"===Object.prototype.toString.call(e)}},{key:"isFormData",value:function(e){return e instanceof FormData}},{key:"isFormElement",value:function(e){return e instanceof HTMLFormElement}},{key:"selectFiles",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Promise((function(t,o){var n=document.createElement("INPUT");n.type="file",e.multiple&&n.setAttribute("multiple","multiple"),e.accept&&n.setAttribute("accept",e.accept),n.style.display="none",document.body.appendChild(n),n.addEventListener("change",(function(e){var o=e.target.files;t(o),document.body.removeChild(n)}),!1),n.click()}))}},{key:"parseHeaders",value:function(e){var t=e.trim().split(/[\r\n]+/),o={};return t.forEach((function(e){var t=e.split(": "),n=t.shift(),i=t.join(": ");n&&(o[n]=i)})),o}}],(o=null)&&n(t.prototype,o),r&&n(t,r),e}()},function(e,t){var o=function(e){return encodeURIComponent(e).replace(/[!'()*]/g,escape).replace(/%20/g,"+")},n=function(e,t,i,r){return t=t||null,i=i||"&",r=r||null,e?function(e){for(var t=new Array,o=0;o<e.length;o++)e[o]&&t.push(e[o]);return t}(Object.keys(e).map((function(s){var a,l,c=s;if(r&&(c=r+"["+c+"]"),"object"==typeof e[s]&&null!==e[s])a=n(e[s],null,i,c);else{t&&(l=c,c=!isNaN(parseFloat(l))&&isFinite(l)?t+Number(c):c);var d=e[s];d=(d=0===(d=!1===(d=!0===d?"1":d)?"0":d)?"0":d)||"",a=o(c)+"="+o(d)}return a}))).join(i).replace(/[!'()*]/g,""):""};e.exports=n}]));class Ul{static get isReadOnlySupported(){return!0}static get toolbox(){return{icon:'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M7.69998 12.6L7.67896 12.62C6.53993 13.7048 6.52012 15.5155 7.63516 16.625V16.625C8.72293 17.7073 10.4799 17.7102 11.5712 16.6314L13.0263 15.193C14.0703 14.1609 14.2141 12.525 13.3662 11.3266L13.22 11.12"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M16.22 11.12L16.3564 10.9805C17.2895 10.0265 17.3478 8.5207 16.4914 7.49733V7.49733C15.569 6.39509 13.9269 6.25143 12.8271 7.17675L11.39 8.38588C10.0935 9.47674 9.95704 11.4241 11.0887 12.6852L11.12 12.72"/></svg>',title:"Link"}}static get enableLineBreaks(){return!0}constructor({data:e,config:t,api:o,readOnly:n}){this.api=o,this.readOnly=n,this.config={endpoint:t.endpoint||"",headers:t.headers||{}},this.nodes={wrapper:null,container:null,progress:null,input:null,inputHolder:null,linkContent:null,linkImage:null,linkTitle:null,linkDescription:null,linkText:null},this._data={link:"",meta:{}},this.data=e}render(){return this.nodes.wrapper=this.make("div",this.CSS.baseClass),this.nodes.container=this.make("div",this.CSS.container),this.nodes.inputHolder=this.makeInputHolder(),this.nodes.linkContent=this.prepareLinkPreview(),Object.keys(this.data.meta).length?(this.nodes.container.appendChild(this.nodes.linkContent),this.showLinkPreview(this.data.meta)):this.nodes.container.appendChild(this.nodes.inputHolder),this.nodes.wrapper.appendChild(this.nodes.container),this.nodes.wrapper}save(){return this.data}validate(){return""!==this.data.link.trim()}set data(e){this._data=Object.assign({},{link:e.link||this._data.link,meta:e.meta||this._data.meta})}get data(){return this._data}get CSS(){return{baseClass:this.api.styles.block,input:this.api.styles.input,container:"link-tool",inputEl:"link-tool__input",inputHolder:"link-tool__input-holder",inputError:"link-tool__input-holder--error",linkContent:"link-tool__content",linkContentRendered:"link-tool__content--rendered",linkImage:"link-tool__image",linkTitle:"link-tool__title",linkDescription:"link-tool__description",linkText:"link-tool__anchor",progress:"link-tool__progress",progressLoading:"link-tool__progress--loading",progressLoaded:"link-tool__progress--loaded"}}makeInputHolder(){const e=this.make("div",this.CSS.inputHolder);return this.nodes.progress=this.make("label",this.CSS.progress),this.nodes.input=this.make("div",[this.CSS.input,this.CSS.inputEl],{contentEditable:!this.readOnly}),this.nodes.input.dataset.placeholder=this.api.i18n.t("Link"),this.readOnly||(this.nodes.input.addEventListener("paste",(e=>{this.startFetching(e)})),this.nodes.input.addEventListener("keydown",(e=>{const[t,o]=[13,65],n=e.ctrlKey||e.metaKey;switch(e.keyCode){case t:e.preventDefault(),e.stopPropagation(),this.startFetching(e);break;case o:n&&this.selectLinkUrl(e)}}))),e.appendChild(this.nodes.progress),e.appendChild(this.nodes.input),e}startFetching(e){let t=this.nodes.input.textContent;"paste"===e.type&&(t=(e.clipboardData||window.clipboardData).getData("text")),this.removeErrorStyle(),this.fetchLinkData(t)}removeErrorStyle(){this.nodes.inputHolder.classList.remove(this.CSS.inputError),this.nodes.inputHolder.insertBefore(this.nodes.progress,this.nodes.input)}selectLinkUrl(e){e.preventDefault(),e.stopPropagation();const t=window.getSelection(),o=new Range,n=t.anchorNode.parentNode.closest(`.${this.CSS.inputHolder}`).querySelector(`.${this.CSS.inputEl}`);o.selectNodeContents(n),t.removeAllRanges(),t.addRange(o)}prepareLinkPreview(){const e=this.make("a",this.CSS.linkContent,{target:"_blank",rel:"nofollow noindex noreferrer"});return this.nodes.linkImage=this.make("div",this.CSS.linkImage),this.nodes.linkTitle=this.make("div",this.CSS.linkTitle),this.nodes.linkDescription=this.make("p",this.CSS.linkDescription),this.nodes.linkText=this.make("span",this.CSS.linkText),e}showLinkPreview({image:e,title:t,description:o}){this.nodes.container.appendChild(this.nodes.linkContent),e&&e.url&&(this.nodes.linkImage.style.backgroundImage="url("+e.url+")",this.nodes.linkContent.appendChild(this.nodes.linkImage)),t&&(this.nodes.linkTitle.textContent=t,this.nodes.linkContent.appendChild(this.nodes.linkTitle)),o&&(this.nodes.linkDescription.textContent=o,this.nodes.linkContent.appendChild(this.nodes.linkDescription)),this.nodes.linkContent.classList.add(this.CSS.linkContentRendered),this.nodes.linkContent.setAttribute("href",this.data.link),this.nodes.linkContent.appendChild(this.nodes.linkText);try{this.nodes.linkText.textContent=new URL(this.data.link).hostname}catch{this.nodes.linkText.textContent=this.data.link}}showProgress(){this.nodes.progress.classList.add(this.CSS.progressLoading)}hideProgress(){return new Promise((e=>{this.nodes.progress.classList.remove(this.CSS.progressLoading),this.nodes.progress.classList.add(this.CSS.progressLoaded),setTimeout(e,500)}))}applyErrorStyle(){this.nodes.inputHolder.classList.add(this.CSS.inputError),this.nodes.progress.remove()}async fetchLinkData(e){this.showProgress(),this.data={link:e};try{const{body:t}=await Hl.get({url:this.config.endpoint,headers:this.config.headers,data:{url:e}});this.onFetch(t)}catch{this.fetchingFailed(this.api.i18n.t("Couldn't fetch the link data"))}}onFetch(e){if(!e||!e.success)return void this.fetchingFailed(this.api.i18n.t("Couldn't get this link data, try the other one"));const t=e.meta,o=e.link||this.data.link;this.data={meta:t,link:o},t?this.hideProgress().then((()=>{this.nodes.inputHolder.remove(),this.showLinkPreview(t)})):this.fetchingFailed(this.api.i18n.t("Wrong response format from the server"))}fetchingFailed(e){this.api.notifier.show({message:e,style:"error"}),this.applyErrorStyle()}make(e,t=null,o={}){const n=document.createElement(e);Array.isArray(t)?n.classList.add(...t):t&&n.classList.add(t);for(const i in o)n[i]=o[i];return n}}export{gi as A,Us as G,Ul as I,Js as P,jl as a,Pl as d,Ml as m,zs as n};
|