@jackuait/blok 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/LICENSE +190 -0
  2. package/README.md +23 -0
  3. package/dist/blok.mjs +5 -0
  4. package/dist/blok.umd.js +53 -0
  5. package/dist/bundle-6e604287.mjs +340 -0
  6. package/dist/codex-7de6c88e.mjs +15668 -0
  7. package/dist/vendor.LICENSE.txt +545 -0
  8. package/package.json +108 -0
  9. package/types/api/block.d.ts +87 -0
  10. package/types/api/blocks.d.ts +136 -0
  11. package/types/api/caret.d.ts +67 -0
  12. package/types/api/events.d.ts +28 -0
  13. package/types/api/i18n.d.ts +11 -0
  14. package/types/api/index.d.ts +17 -0
  15. package/types/api/inline-toolbar.d.ts +15 -0
  16. package/types/api/listeners.d.ts +32 -0
  17. package/types/api/notifier.d.ts +14 -0
  18. package/types/api/readonly.d.ts +17 -0
  19. package/types/api/sanitizer.d.ts +14 -0
  20. package/types/api/saver.d.ts +13 -0
  21. package/types/api/selection.d.ts +41 -0
  22. package/types/api/styles.d.ts +44 -0
  23. package/types/api/toolbar.d.ts +26 -0
  24. package/types/api/tools.d.ts +11 -0
  25. package/types/api/tooltip.d.ts +30 -0
  26. package/types/api/ui.d.ts +24 -0
  27. package/types/block-tunes/block-tune-data.d.ts +1 -0
  28. package/types/block-tunes/block-tune.d.ts +60 -0
  29. package/types/block-tunes/index.d.ts +1 -0
  30. package/types/configs/conversion-config.ts +26 -0
  31. package/types/configs/editor-config.d.ts +107 -0
  32. package/types/configs/i18n-config.d.ts +16 -0
  33. package/types/configs/i18n-dictionary.d.ts +93 -0
  34. package/types/configs/index.d.ts +7 -0
  35. package/types/configs/log-levels.d.ts +9 -0
  36. package/types/configs/paste-config.d.ts +38 -0
  37. package/types/configs/sanitizer-config.d.ts +43 -0
  38. package/types/data-formats/block-data.d.ts +23 -0
  39. package/types/data-formats/block-id.ts +4 -0
  40. package/types/data-formats/index.d.ts +2 -0
  41. package/types/data-formats/output-data.d.ts +46 -0
  42. package/types/events/block/Base.ts +11 -0
  43. package/types/events/block/BlockAdded.ts +21 -0
  44. package/types/events/block/BlockChanged.ts +21 -0
  45. package/types/events/block/BlockMoved.ts +26 -0
  46. package/types/events/block/BlockRemoved.ts +21 -0
  47. package/types/events/block/index.ts +44 -0
  48. package/types/index.d.ts +191 -0
  49. package/types/tools/adapters/base-tool-adapter.d.ts +76 -0
  50. package/types/tools/adapters/block-tool-adapter.d.ts +78 -0
  51. package/types/tools/adapters/block-tune-adapter.d.ts +14 -0
  52. package/types/tools/adapters/inline-tool-adapter.d.ts +10 -0
  53. package/types/tools/adapters/tool-factory.d.ts +5 -0
  54. package/types/tools/adapters/tool-type.ts +18 -0
  55. package/types/tools/adapters/tools-collection.d.ts +34 -0
  56. package/types/tools/block-tool-data.d.ts +5 -0
  57. package/types/tools/block-tool.d.ts +121 -0
  58. package/types/tools/hook-events.d.ts +23 -0
  59. package/types/tools/index.d.ts +16 -0
  60. package/types/tools/inline-tool.d.ts +37 -0
  61. package/types/tools/menu-config.d.ts +46 -0
  62. package/types/tools/paste-events.d.ts +52 -0
  63. package/types/tools/tool-config.d.ts +4 -0
  64. package/types/tools/tool-settings.d.ts +79 -0
  65. package/types/tools/tool.d.ts +65 -0
  66. package/types/utils/popover/hint.d.ts +29 -0
  67. package/types/utils/popover/index.d.ts +5 -0
  68. package/types/utils/popover/popover-event.ts +15 -0
  69. package/types/utils/popover/popover-item-type.ts +13 -0
  70. package/types/utils/popover/popover-item.d.ts +253 -0
  71. package/types/utils/popover/popover.d.ts +112 -0
@@ -0,0 +1,53 @@
1
+ (function(){"use strict";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){console.error("vite-plugin-css-injected-by-js",t)}})();
2
+ (function(xt,pe){typeof exports=="object"&&typeof module<"u"?module.exports=pe():typeof define=="function"&&define.amd?define(pe):(xt=typeof globalThis<"u"?globalThis:xt||self,xt.Blok=pe())})(this,function(){"use strict";function xt(n,e){for(var t=0;t<e.length;t++){const o=e[t];if(typeof o!="string"&&!Array.isArray(o)){for(const r in o)if(r!=="default"&&!(r in n)){const i=Object.getOwnPropertyDescriptor(o,r);i&&Object.defineProperty(n,r,i.get?i:{enumerable:!0,get:()=>o[r]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}var pe=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function li(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function Tl(n){if(n.__esModule)return n;var e=n.default;if(typeof e=="function"){var t=function o(){if(this instanceof o){var r=[null];r.push.apply(r,arguments);var i=Function.bind.apply(e,r);return new i}return e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(n).forEach(function(o){var r=Object.getOwnPropertyDescriptor(n,o);Object.defineProperty(t,o,r.get?r:{enumerable:!0,get:function(){return n[o]}})}),t}function oo(){}Object.assign(oo,{default:oo,register:oo,revert:function(){},__esModule:!0}),typeof Element.prototype.scrollIntoViewIfNeeded>"u"&&(Element.prototype.scrollIntoViewIfNeeded=function(n){const e=n??!0,t=this.parentElement;if(!t)return;const o=window.getComputedStyle(t,null),r=parseInt(o.getPropertyValue("border-top-width")),i=parseInt(o.getPropertyValue("border-left-width")),s=this.offsetTop-t.offsetTop<t.scrollTop,a=this.offsetTop-t.offsetTop+this.clientHeight-r>t.scrollTop+t.clientHeight,l=this.offsetLeft-t.offsetLeft<t.scrollLeft,c=this.offsetLeft-t.offsetLeft+this.clientWidth-i>t.scrollLeft+t.clientWidth,d=s&&!a;(s||a)&&e&&(t.scrollTop=this.offsetTop-t.offsetTop-t.clientHeight/2-r+this.clientHeight/2),(l||c)&&e&&(t.scrollLeft=this.offsetLeft-t.offsetLeft-t.clientWidth/2-i+this.clientWidth/2),(s||a||l||c)&&!e&&this.scrollIntoView(d)});const kl=globalThis.setTimeout.bind(globalThis),wl=globalThis.clearTimeout.bind(globalThis),Qt=new Map,Cl=n=>{const e=Number(n);return Number.isFinite(e)&&e>0?e:Date.now()};typeof window.requestIdleCallback>"u"&&(window.requestIdleCallback=function(n){const e=Date.now(),t={},o=kl(()=>{const i=t.value;typeof i=="number"&&Qt.delete(i),n({didTimeout:!1,timeRemaining:function(){return Math.max(0,50-(Date.now()-e))}})},1),r=Cl(o);return t.value=r,Qt.set(r,o),r}),typeof window.cancelIdleCallback>"u"&&(window.cancelIdleCallback=function(n){const e=Qt.get(n);e!==void 0&&(Qt.delete(n),wl(e)),globalThis.clearTimeout(n)});let Sl=(n=21)=>crypto.getRandomValues(new Uint8Array(n)).reduce((e,t)=>(t&=63,t<36?e+=t.toString(36):t<62?e+=(t-26).toString(36).toUpperCase():t>62?e+="-":e+="_",e),"");var xl="Expected a function";function Bl(n,e,t){if(typeof n!="function")throw new TypeError(xl);return setTimeout(function(){n.apply(void 0,t)},e)}var _l=Bl;function Al(n){return n}var ci=Al;function Il(n,e,t){switch(t.length){case 0:return n.call(e);case 1:return n.call(e,t[0]);case 2:return n.call(e,t[0],t[1]);case 3:return n.call(e,t[0],t[1],t[2])}return n.apply(e,t)}var Ol=Il,Nl=Ol,di=Math.max;function Rl(n,e,t){return e=di(e===void 0?n.length-1:e,0),function(){for(var o=arguments,r=-1,i=di(o.length-e,0),s=Array(i);++r<i;)s[r]=o[e+r];r=-1;for(var a=Array(e+1);++r<e;)a[r]=o[r];return a[e]=t(s),Nl(n,this,a)}}var Ll=Rl;function Pl(n){return function(){return n}}var Ml=Pl,Dl=typeof pe=="object"&&pe&&pe.Object===Object&&pe,ui=Dl,$l=ui,Fl=typeof self=="object"&&self&&self.Object===Object&&self,Hl=$l||Fl||Function("return this")(),ke=Hl,jl=ke,zl=jl.Symbol,en=zl,hi=en,fi=Object.prototype,Wl=fi.hasOwnProperty,Ul=fi.toString,Bt=hi?hi.toStringTag:void 0;function Kl(n){var e=Wl.call(n,Bt),t=n[Bt];try{n[Bt]=void 0;var o=!0}catch{}var r=Ul.call(n);return o&&(e?n[Bt]=t:delete n[Bt]),r}var Gl=Kl,Yl=Object.prototype,Xl=Yl.toString;function Vl(n){return Xl.call(n)}var ql=Vl,pi=en,Zl=Gl,Jl=ql,Ql="[object Null]",ec="[object Undefined]",gi=pi?pi.toStringTag:void 0;function tc(n){return n==null?n===void 0?ec:Ql:gi&&gi in Object(n)?Zl(n):Jl(n)}var Re=tc;function nc(n){var e=typeof n;return n!=null&&(e=="object"||e=="function")}var Be=nc,oc=Re,rc=Be,ic="[object AsyncFunction]",sc="[object Function]",ac="[object GeneratorFunction]",lc="[object Proxy]";function cc(n){if(!rc(n))return!1;var e=oc(n);return e==sc||e==ac||e==ic||e==lc}var tn=cc,dc=ke,uc=dc["__core-js_shared__"],hc=uc,ro=hc,mi=function(){var n=/[^.]+$/.exec(ro&&ro.keys&&ro.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function fc(n){return!!mi&&mi in n}var pc=fc,gc=Function.prototype,mc=gc.toString;function vc(n){if(n!=null){try{return mc.call(n)}catch{}try{return n+""}catch{}}return""}var vi=vc,bc=tn,yc=pc,Ec=Be,Tc=vi,kc=/[\\^$.*+?()[\]{}|]/g,wc=/^\[object .+?Constructor\]$/,Cc=Function.prototype,Sc=Object.prototype,xc=Cc.toString,Bc=Sc.hasOwnProperty,_c=RegExp("^"+xc.call(Bc).replace(kc,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Ac(n){if(!Ec(n)||yc(n))return!1;var e=bc(n)?_c:wc;return e.test(Tc(n))}var Ic=Ac;function Oc(n,e){return n==null?void 0:n[e]}var Nc=Oc,Rc=Ic,Lc=Nc;function Pc(n,e){var t=Lc(n,e);return Rc(t)?t:void 0}var Ge=Pc,Mc=Ge,Dc=function(){try{var n=Mc(Object,"defineProperty");return n({},"",{}),n}catch{}}(),bi=Dc,$c=Ml,yi=bi,Fc=ci,Hc=yi?function(n,e){return yi(n,"toString",{configurable:!0,enumerable:!1,value:$c(e),writable:!0})}:Fc,jc=Hc,zc=800,Wc=16,Uc=Date.now;function Kc(n){var e=0,t=0;return function(){var o=Uc(),r=Wc-(o-t);if(t=o,r>0){if(++e>=zc)return arguments[0]}else e=0;return n.apply(void 0,arguments)}}var Gc=Kc,Yc=jc,Xc=Gc,Vc=Xc(Yc),qc=Vc,Zc=ci,Jc=Ll,Qc=qc;function ed(n,e){return Qc(Jc(n,e,Zc),n+"")}var Ei=ed,td=/\s/;function nd(n){for(var e=n.length;e--&&td.test(n.charAt(e)););return e}var od=nd,rd=od,id=/^\s+/;function sd(n){return n&&n.slice(0,rd(n)+1).replace(id,"")}var ad=sd;function ld(n){return n!=null&&typeof n=="object"}var _e=ld,cd=Re,dd=_e,ud="[object Symbol]";function hd(n){return typeof n=="symbol"||dd(n)&&cd(n)==ud}var fd=hd,pd=ad,Ti=Be,gd=fd,ki=0/0,md=/^[-+]0x[0-9a-f]+$/i,vd=/^0b[01]+$/i,bd=/^0o[0-7]+$/i,yd=parseInt;function Ed(n){if(typeof n=="number")return n;if(gd(n))return ki;if(Ti(n)){var e=typeof n.valueOf=="function"?n.valueOf():n;n=Ti(e)?e+"":e}if(typeof n!="string")return n===0?n:+n;n=pd(n);var t=vd.test(n);return t||bd.test(n)?yd(n.slice(2),t?2:8):md.test(n)?ki:+n}var wi=Ed,Td=_l,kd=Ei,wd=wi,Cd=kd(function(n,e,t){return Td(n,wd(e)||0,t)}),Sd=Cd,xd=Re,Bd=_e,_d="[object Boolean]";function Ad(n){return n===!0||n===!1||Bd(n)&&xd(n)==_d}var Id=Ad,Od=Object.prototype;function Nd(n){var e=n&&n.constructor,t=typeof e=="function"&&e.prototype||Od;return n===t}var nn=Nd;function Rd(n,e){return function(t){return n(e(t))}}var Ci=Rd,Ld=Ci,Pd=Ld(Object.keys,Object),Md=Pd,Dd=nn,$d=Md,Fd=Object.prototype,Hd=Fd.hasOwnProperty;function jd(n){if(!Dd(n))return $d(n);var e=[];for(var t in Object(n))Hd.call(n,t)&&t!="constructor"&&e.push(t);return e}var Si=jd,zd=Ge,Wd=ke,Ud=zd(Wd,"DataView"),Kd=Ud,Gd=Ge,Yd=ke,Xd=Gd(Yd,"Map"),io=Xd,Vd=Ge,qd=ke,Zd=Vd(qd,"Promise"),Jd=Zd,Qd=Ge,eu=ke,tu=Qd(eu,"Set"),nu=tu,ou=Ge,ru=ke,iu=ou(ru,"WeakMap"),su=iu,so=Kd,ao=io,lo=Jd,co=nu,uo=su,xi=Re,rt=vi,Bi="[object Map]",au="[object Object]",_i="[object Promise]",Ai="[object Set]",Ii="[object WeakMap]",Oi="[object DataView]",lu=rt(so),cu=rt(ao),du=rt(lo),uu=rt(co),hu=rt(uo),Ye=xi;(so&&Ye(new so(new ArrayBuffer(1)))!=Oi||ao&&Ye(new ao)!=Bi||lo&&Ye(lo.resolve())!=_i||co&&Ye(new co)!=Ai||uo&&Ye(new uo)!=Ii)&&(Ye=function(n){var e=xi(n),t=e==au?n.constructor:void 0,o=t?rt(t):"";if(o)switch(o){case lu:return Oi;case cu:return Bi;case du:return _i;case uu:return Ai;case hu:return Ii}return e});var ho=Ye,fu=Re,pu=_e,gu="[object Arguments]";function mu(n){return pu(n)&&fu(n)==gu}var vu=mu,Ni=vu,bu=_e,Ri=Object.prototype,yu=Ri.hasOwnProperty,Eu=Ri.propertyIsEnumerable,Tu=Ni(function(){return arguments}())?Ni:function(n){return bu(n)&&yu.call(n,"callee")&&!Eu.call(n,"callee")},fo=Tu,ku=Array.isArray,it=ku,wu=9007199254740991;function Cu(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=wu}var Li=Cu,Su=tn,xu=Li;function Bu(n){return n!=null&&xu(n.length)&&!Su(n)}var st=Bu,Xe={},_u={get exports(){return Xe},set exports(n){Xe=n}};function Au(){return!1}var Iu=Au;(function(n,e){var t=ke,o=Iu,r=e&&!e.nodeType&&e,i=r&&!0&&n&&!n.nodeType&&n,s=i&&i.exports===r,a=s?t.Buffer:void 0,l=a?a.isBuffer:void 0,c=l||o;n.exports=c})(_u,Xe);var Ou=Re,Nu=Li,Ru=_e,Lu="[object Arguments]",Pu="[object Array]",Mu="[object Boolean]",Du="[object Date]",$u="[object Error]",Fu="[object Function]",Hu="[object Map]",ju="[object Number]",zu="[object Object]",Wu="[object RegExp]",Uu="[object Set]",Ku="[object String]",Gu="[object WeakMap]",Yu="[object ArrayBuffer]",Xu="[object DataView]",Vu="[object Float32Array]",qu="[object Float64Array]",Zu="[object Int8Array]",Ju="[object Int16Array]",Qu="[object Int32Array]",eh="[object Uint8Array]",th="[object Uint8ClampedArray]",nh="[object Uint16Array]",oh="[object Uint32Array]",U={};U[Vu]=U[qu]=U[Zu]=U[Ju]=U[Qu]=U[eh]=U[th]=U[nh]=U[oh]=!0,U[Lu]=U[Pu]=U[Yu]=U[Mu]=U[Xu]=U[Du]=U[$u]=U[Fu]=U[Hu]=U[ju]=U[zu]=U[Wu]=U[Uu]=U[Ku]=U[Gu]=!1;function rh(n){return Ru(n)&&Nu(n.length)&&!!U[Ou(n)]}var ih=rh;function sh(n){return function(e){return n(e)}}var ah=sh,on={},lh={get exports(){return on},set exports(n){on=n}};(function(n,e){var t=ui,o=e&&!e.nodeType&&e,r=o&&!0&&n&&!n.nodeType&&n,i=r&&r.exports===o,s=i&&t.process,a=function(){try{var l=r&&r.require&&r.require("util").types;return l||s&&s.binding&&s.binding("util")}catch{}}();n.exports=a})(lh,on);var ch=ih,dh=ah,Pi=on,Mi=Pi&&Pi.isTypedArray,uh=Mi?dh(Mi):ch,rn=uh,hh=Si,fh=ho,ph=fo,gh=it,mh=st,vh=Xe,bh=nn,yh=rn,Eh="[object Map]",Th="[object Set]",kh=Object.prototype,wh=kh.hasOwnProperty;function Ch(n){if(n==null)return!0;if(mh(n)&&(gh(n)||typeof n=="string"||typeof n.splice=="function"||vh(n)||yh(n)||ph(n)))return!n.length;var e=fh(n);if(e==Eh||e==Th)return!n.size;if(bh(n))return!hh(n).length;for(var t in n)if(wh.call(n,t))return!1;return!0}var Sh=Ch;function xh(){this.__data__=[],this.size=0}var Bh=xh;function _h(n,e){return n===e||n!==n&&e!==e}var _t=_h,Ah=_t;function Ih(n,e){for(var t=n.length;t--;)if(Ah(n[t][0],e))return t;return-1}var sn=Ih,Oh=sn,Nh=Array.prototype,Rh=Nh.splice;function Lh(n){var e=this.__data__,t=Oh(e,n);if(t<0)return!1;var o=e.length-1;return t==o?e.pop():Rh.call(e,t,1),--this.size,!0}var Ph=Lh,Mh=sn;function Dh(n){var e=this.__data__,t=Mh(e,n);return t<0?void 0:e[t][1]}var $h=Dh,Fh=sn;function Hh(n){return Fh(this.__data__,n)>-1}var jh=Hh,zh=sn;function Wh(n,e){var t=this.__data__,o=zh(t,n);return o<0?(++this.size,t.push([n,e])):t[o][1]=e,this}var Uh=Wh,Kh=Bh,Gh=Ph,Yh=$h,Xh=jh,Vh=Uh;function at(n){var e=-1,t=n==null?0:n.length;for(this.clear();++e<t;){var o=n[e];this.set(o[0],o[1])}}at.prototype.clear=Kh,at.prototype.delete=Gh,at.prototype.get=Yh,at.prototype.has=Xh,at.prototype.set=Vh;var an=at,qh=an;function Zh(){this.__data__=new qh,this.size=0}var Jh=Zh;function Qh(n){var e=this.__data__,t=e.delete(n);return this.size=e.size,t}var ef=Qh;function tf(n){return this.__data__.get(n)}var nf=tf;function of(n){return this.__data__.has(n)}var rf=of,sf=Ge,af=sf(Object,"create"),ln=af,Di=ln;function lf(){this.__data__=Di?Di(null):{},this.size=0}var cf=lf;function df(n){var e=this.has(n)&&delete this.__data__[n];return this.size-=e?1:0,e}var uf=df,hf=ln,ff="__lodash_hash_undefined__",pf=Object.prototype,gf=pf.hasOwnProperty;function mf(n){var e=this.__data__;if(hf){var t=e[n];return t===ff?void 0:t}return gf.call(e,n)?e[n]:void 0}var vf=mf,bf=ln,yf=Object.prototype,Ef=yf.hasOwnProperty;function Tf(n){var e=this.__data__;return bf?e[n]!==void 0:Ef.call(e,n)}var kf=Tf,wf=ln,Cf="__lodash_hash_undefined__";function Sf(n,e){var t=this.__data__;return this.size+=this.has(n)?0:1,t[n]=wf&&e===void 0?Cf:e,this}var xf=Sf,Bf=cf,_f=uf,Af=vf,If=kf,Of=xf;function lt(n){var e=-1,t=n==null?0:n.length;for(this.clear();++e<t;){var o=n[e];this.set(o[0],o[1])}}lt.prototype.clear=Bf,lt.prototype.delete=_f,lt.prototype.get=Af,lt.prototype.has=If,lt.prototype.set=Of;var Nf=lt,$i=Nf,Rf=an,Lf=io;function Pf(){this.size=0,this.__data__={hash:new $i,map:new(Lf||Rf),string:new $i}}var Mf=Pf;function Df(n){var e=typeof n;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?n!=="__proto__":n===null}var $f=Df,Ff=$f;function Hf(n,e){var t=n.__data__;return Ff(e)?t[typeof e=="string"?"string":"hash"]:t.map}var cn=Hf,jf=cn;function zf(n){var e=jf(this,n).delete(n);return this.size-=e?1:0,e}var Wf=zf,Uf=cn;function Kf(n){return Uf(this,n).get(n)}var Gf=Kf,Yf=cn;function Xf(n){return Yf(this,n).has(n)}var Vf=Xf,qf=cn;function Zf(n,e){var t=qf(this,n),o=t.size;return t.set(n,e),this.size+=t.size==o?0:1,this}var Jf=Zf,Qf=Mf,ep=Wf,tp=Gf,np=Vf,op=Jf;function ct(n){var e=-1,t=n==null?0:n.length;for(this.clear();++e<t;){var o=n[e];this.set(o[0],o[1])}}ct.prototype.clear=Qf,ct.prototype.delete=ep,ct.prototype.get=tp,ct.prototype.has=np,ct.prototype.set=op;var Fi=ct,rp=an,ip=io,sp=Fi,ap=200;function lp(n,e){var t=this.__data__;if(t instanceof rp){var o=t.__data__;if(!ip||o.length<ap-1)return o.push([n,e]),this.size=++t.size,this;t=this.__data__=new sp(o)}return t.set(n,e),this.size=t.size,this}var cp=lp,dp=an,up=Jh,hp=ef,fp=nf,pp=rf,gp=cp;function dt(n){var e=this.__data__=new dp(n);this.size=e.size}dt.prototype.clear=up,dt.prototype.delete=hp,dt.prototype.get=fp,dt.prototype.has=pp,dt.prototype.set=gp;var Hi=dt,mp="__lodash_hash_undefined__";function vp(n){return this.__data__.set(n,mp),this}var bp=vp;function yp(n){return this.__data__.has(n)}var Ep=yp,Tp=Fi,kp=bp,wp=Ep;function dn(n){var e=-1,t=n==null?0:n.length;for(this.__data__=new Tp;++e<t;)this.add(n[e])}dn.prototype.add=dn.prototype.push=kp,dn.prototype.has=wp;var Cp=dn;function Sp(n,e){for(var t=-1,o=n==null?0:n.length;++t<o;)if(e(n[t],t,n))return!0;return!1}var xp=Sp;function Bp(n,e){return n.has(e)}var _p=Bp,Ap=Cp,Ip=xp,Op=_p,Np=1,Rp=2;function Lp(n,e,t,o,r,i){var s=t&Np,a=n.length,l=e.length;if(a!=l&&!(s&&l>a))return!1;var c=i.get(n),d=i.get(e);if(c&&d)return c==e&&d==n;var u=-1,h=!0,g=t&Rp?new Ap:void 0;for(i.set(n,e),i.set(e,n);++u<a;){var f=n[u],m=e[u];if(o)var b=s?o(m,f,u,e,n,i):o(f,m,u,n,e,i);if(b!==void 0){if(b)continue;h=!1;break}if(g){if(!Ip(e,function(E,k){if(!Op(g,k)&&(f===E||r(f,E,t,o,i)))return g.push(k)})){h=!1;break}}else if(!(f===m||r(f,m,t,o,i))){h=!1;break}}return i.delete(n),i.delete(e),h}var ji=Lp,Pp=ke,Mp=Pp.Uint8Array,zi=Mp;function Dp(n){var e=-1,t=Array(n.size);return n.forEach(function(o,r){t[++e]=[r,o]}),t}var Wi=Dp;function $p(n){var e=-1,t=Array(n.size);return n.forEach(function(o){t[++e]=o}),t}var Ui=$p,Ki=en,Gi=zi,Fp=_t,Hp=ji,jp=Wi,zp=Ui,Wp=1,Up=2,Kp="[object Boolean]",Gp="[object Date]",Yp="[object Error]",Xp="[object Map]",Vp="[object Number]",qp="[object RegExp]",Zp="[object Set]",Jp="[object String]",Qp="[object Symbol]",eg="[object ArrayBuffer]",tg="[object DataView]",Yi=Ki?Ki.prototype:void 0,po=Yi?Yi.valueOf:void 0;function ng(n,e,t,o,r,i,s){switch(t){case tg:if(n.byteLength!=e.byteLength||n.byteOffset!=e.byteOffset)return!1;n=n.buffer,e=e.buffer;case eg:return!(n.byteLength!=e.byteLength||!i(new Gi(n),new Gi(e)));case Kp:case Gp:case Vp:return Fp(+n,+e);case Yp:return n.name==e.name&&n.message==e.message;case qp:case Jp:return n==e+"";case Xp:var a=jp;case Zp:var l=o&Wp;if(a||(a=zp),n.size!=e.size&&!l)return!1;var c=s.get(n);if(c)return c==e;o|=Up,s.set(n,e);var d=Hp(a(n),a(e),o,r,i,s);return s.delete(n),d;case Qp:if(po)return po.call(n)==po.call(e)}return!1}var og=ng;function rg(n,e){for(var t=-1,o=e.length,r=n.length;++t<o;)n[r+t]=e[t];return n}var ig=rg,sg=ig,ag=it;function lg(n,e,t){var o=e(n);return ag(n)?o:sg(o,t(n))}var cg=lg;function dg(n,e){for(var t=-1,o=n==null?0:n.length,r=0,i=[];++t<o;){var s=n[t];e(s,t,n)&&(i[r++]=s)}return i}var ug=dg;function hg(){return[]}var fg=hg,pg=ug,gg=fg,mg=Object.prototype,vg=mg.propertyIsEnumerable,Xi=Object.getOwnPropertySymbols,bg=Xi?function(n){return n==null?[]:(n=Object(n),pg(Xi(n),function(e){return vg.call(n,e)}))}:gg,yg=bg;function Eg(n,e){for(var t=-1,o=Array(n);++t<n;)o[t]=e(t);return o}var Tg=Eg,kg=9007199254740991,wg=/^(?:0|[1-9]\d*)$/;function Cg(n,e){var t=typeof n;return e=e??kg,!!e&&(t=="number"||t!="symbol"&&wg.test(n))&&n>-1&&n%1==0&&n<e}var Vi=Cg,Sg=Tg,xg=fo,Bg=it,_g=Xe,Ag=Vi,Ig=rn,Og=Object.prototype,Ng=Og.hasOwnProperty;function Rg(n,e){var t=Bg(n),o=!t&&xg(n),r=!t&&!o&&_g(n),i=!t&&!o&&!r&&Ig(n),s=t||o||r||i,a=s?Sg(n.length,String):[],l=a.length;for(var c in n)(e||Ng.call(n,c))&&!(s&&(c=="length"||r&&(c=="offset"||c=="parent")||i&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||Ag(c,l)))&&a.push(c);return a}var qi=Rg,Lg=qi,Pg=Si,Mg=st;function Dg(n){return Mg(n)?Lg(n):Pg(n)}var Zi=Dg,$g=cg,Fg=yg,Hg=Zi;function jg(n){return $g(n,Hg,Fg)}var zg=jg,Ji=zg,Wg=1,Ug=Object.prototype,Kg=Ug.hasOwnProperty;function Gg(n,e,t,o,r,i){var s=t&Wg,a=Ji(n),l=a.length,c=Ji(e),d=c.length;if(l!=d&&!s)return!1;for(var u=l;u--;){var h=a[u];if(!(s?h in e:Kg.call(e,h)))return!1}var g=i.get(n),f=i.get(e);if(g&&f)return g==e&&f==n;var m=!0;i.set(n,e),i.set(e,n);for(var b=s;++u<l;){h=a[u];var E=n[h],k=e[h];if(o)var N=s?o(k,E,h,e,n,i):o(E,k,h,n,e,i);if(!(N===void 0?E===k||r(E,k,t,o,i):N)){m=!1;break}b||(b=h=="constructor")}if(m&&!b){var x=n.constructor,P=e.constructor;x!=P&&"constructor"in n&&"constructor"in e&&!(typeof x=="function"&&x instanceof x&&typeof P=="function"&&P instanceof P)&&(m=!1)}return i.delete(n),i.delete(e),m}var Yg=Gg,go=Hi,Xg=ji,Vg=og,qg=Yg,Qi=ho,es=it,ts=Xe,Zg=rn,Jg=1,ns="[object Arguments]",os="[object Array]",un="[object Object]",Qg=Object.prototype,rs=Qg.hasOwnProperty;function em(n,e,t,o,r,i){var s=es(n),a=es(e),l=s?os:Qi(n),c=a?os:Qi(e);l=l==ns?un:l,c=c==ns?un:c;var d=l==un,u=c==un,h=l==c;if(h&&ts(n)){if(!ts(e))return!1;s=!0,d=!1}if(h&&!d)return i||(i=new go),s||Zg(n)?Xg(n,e,t,o,r,i):Vg(n,e,l,t,o,r,i);if(!(t&Jg)){var g=d&&rs.call(n,"__wrapped__"),f=u&&rs.call(e,"__wrapped__");if(g||f){var m=g?n.value():n,b=f?e.value():e;return i||(i=new go),r(m,b,t,o,i)}}return h?(i||(i=new go),qg(n,e,t,o,r,i)):!1}var tm=em,nm=tm,is=_e;function ss(n,e,t,o,r){return n===e?!0:n==null||e==null||!is(n)&&!is(e)?n!==n&&e!==e:nm(n,e,t,o,ss,r)}var om=ss,rm=om;function im(n,e){return rm(n,e)}var sm=im,am=Re,lm=_e,cm="[object Number]";function dm(n){return typeof n=="number"||lm(n)&&am(n)==cm}var um=dm,hm=Ci,fm=hm(Object.getPrototypeOf,Object),as=fm,pm=Re,gm=as,mm=_e,vm="[object Object]",bm=Function.prototype,ym=Object.prototype,ls=bm.toString,Em=ym.hasOwnProperty,Tm=ls.call(Object);function km(n){if(!mm(n)||pm(n)!=vm)return!1;var e=gm(n);if(e===null)return!0;var t=Em.call(e,"constructor")&&e.constructor;return typeof t=="function"&&t instanceof t&&ls.call(t)==Tm}var cs=km,wm=Re,Cm=it,Sm=_e,xm="[object String]";function Bm(n){return typeof n=="string"||!Cm(n)&&Sm(n)&&wm(n)==xm}var ds=Bm;function _m(n){return n===void 0}var Am=_m,us=bi;function Im(n,e,t){e=="__proto__"&&us?us(n,e,{configurable:!0,enumerable:!0,value:t,writable:!0}):n[e]=t}var mo=Im,Om=mo,Nm=_t;function Rm(n,e,t){(t!==void 0&&!Nm(n[e],t)||t===void 0&&!(e in n))&&Om(n,e,t)}var hs=Rm;function Lm(n){return function(e,t,o){for(var r=-1,i=Object(e),s=o(e),a=s.length;a--;){var l=s[n?a:++r];if(t(i[l],l,i)===!1)break}return e}}var Pm=Lm,Mm=Pm,Dm=Mm(),$m=Dm,hn={},Fm={get exports(){return hn},set exports(n){hn=n}};(function(n,e){var t=ke,o=e&&!e.nodeType&&e,r=o&&!0&&n&&!n.nodeType&&n,i=r&&r.exports===o,s=i?t.Buffer:void 0,a=s?s.allocUnsafe:void 0;function l(c,d){if(d)return c.slice();var u=c.length,h=a?a(u):new c.constructor(u);return c.copy(h),h}n.exports=l})(Fm,hn);var fs=zi;function Hm(n){var e=new n.constructor(n.byteLength);return new fs(e).set(new fs(n)),e}var jm=Hm,zm=jm;function Wm(n,e){var t=e?zm(n.buffer):n.buffer;return new n.constructor(t,n.byteOffset,n.length)}var Um=Wm;function Km(n,e){var t=-1,o=n.length;for(e||(e=Array(o));++t<o;)e[t]=n[t];return e}var ps=Km,Gm=Be,gs=Object.create,Ym=function(){function n(){}return function(e){if(!Gm(e))return{};if(gs)return gs(e);n.prototype=e;var t=new n;return n.prototype=void 0,t}}(),Xm=Ym,Vm=Xm,qm=as,Zm=nn;function Jm(n){return typeof n.constructor=="function"&&!Zm(n)?Vm(qm(n)):{}}var Qm=Jm,ev=st,tv=_e;function nv(n){return tv(n)&&ev(n)}var ov=nv;function rv(n,e){if(!(e==="constructor"&&typeof n[e]=="function")&&e!="__proto__")return n[e]}var ms=rv,iv=mo,sv=_t,av=Object.prototype,lv=av.hasOwnProperty;function cv(n,e,t){var o=n[e];(!(lv.call(n,e)&&sv(o,t))||t===void 0&&!(e in n))&&iv(n,e,t)}var dv=cv,uv=dv,hv=mo;function fv(n,e,t,o){var r=!t;t||(t={});for(var i=-1,s=e.length;++i<s;){var a=e[i],l=o?o(t[a],n[a],a,t,n):void 0;l===void 0&&(l=n[a]),r?hv(t,a,l):uv(t,a,l)}return t}var pv=fv;function gv(n){var e=[];if(n!=null)for(var t in Object(n))e.push(t);return e}var mv=gv,vv=Be,bv=nn,yv=mv,Ev=Object.prototype,Tv=Ev.hasOwnProperty;function kv(n){if(!vv(n))return yv(n);var e=bv(n),t=[];for(var o in n)o=="constructor"&&(e||!Tv.call(n,o))||t.push(o);return t}var wv=kv,Cv=qi,Sv=wv,xv=st;function Bv(n){return xv(n)?Cv(n,!0):Sv(n)}var vs=Bv,_v=pv,Av=vs;function Iv(n){return _v(n,Av(n))}var Ov=Iv,bs=hs,Nv=hn,Rv=Um,Lv=ps,Pv=Qm,ys=fo,Es=it,Mv=ov,Dv=Xe,$v=tn,Fv=Be,Hv=cs,jv=rn,Ts=ms,zv=Ov;function Wv(n,e,t,o,r,i,s){var a=Ts(n,t),l=Ts(e,t),c=s.get(l);if(c){bs(n,t,c);return}var d=i?i(a,l,t+"",n,e,s):void 0,u=d===void 0;if(u){var h=Es(l),g=!h&&Dv(l),f=!h&&!g&&jv(l);d=l,h||g||f?Es(a)?d=a:Mv(a)?d=Lv(a):g?(u=!1,d=Nv(l,!0)):f?(u=!1,d=Rv(l,!0)):d=[]:Hv(l)||ys(l)?(d=a,ys(a)?d=zv(a):(!Fv(a)||$v(a))&&(d=Pv(l))):u=!1}u&&(s.set(l,d),r(d,l,o,i,s),s.delete(l)),bs(n,t,d)}var Uv=Wv,Kv=Hi,Gv=hs,Yv=$m,Xv=Uv,Vv=Be,qv=vs,Zv=ms;function ks(n,e,t,o,r){n!==e&&Yv(e,function(i,s){if(r||(r=new Kv),Vv(i))Xv(n,e,s,t,ks,o,r);else{var a=o?o(Zv(n,s),i,s+"",n,e,r):void 0;a===void 0&&(a=i),Gv(n,s,a)}},qv)}var Jv=ks,Qv=_t,eb=st,tb=Vi,nb=Be;function ob(n,e,t){if(!nb(t))return!1;var o=typeof e;return(o=="number"?eb(t)&&tb(e,t.length):o=="string"&&e in t)?Qv(t[e],n):!1}var rb=ob,ib=Ei,sb=rb;function ab(n){return ib(function(e,t){var o=-1,r=t.length,i=r>1?t[r-1]:void 0,s=r>2?t[2]:void 0;for(i=n.length>3&&typeof i=="function"?(r--,i):void 0,s&&sb(t[0],t[1],s)&&(i=r<3?void 0:i,r=1),e=Object(e);++o<r;){var a=t[o];a&&n(e,a,o,i)}return e})}var lb=ab,cb=Jv,db=lb,ub=db(function(n,e,t,o){cb(n,e,t,o)}),hb=ub,fb=ke,pb=function(){return fb.Date.now()},gb=pb,mb=Be,vo=gb,ws=wi,vb="Expected a function",bb=Math.max,yb=Math.min;function Eb(n,e,t){var o,r,i,s,a,l,c=0,d=!1,u=!1,h=!0;if(typeof n!="function")throw new TypeError(vb);e=ws(e)||0,mb(t)&&(d=!!t.leading,u="maxWait"in t,i=u?bb(ws(t.maxWait)||0,e):i,h="trailing"in t?!!t.trailing:h);function g(I){var X=o,C=r;return o=r=void 0,c=I,s=n.apply(C,X),s}function f(I){return c=I,a=setTimeout(E,e),d?g(I):s}function m(I){var X=I-l,C=I-c,T=e-X;return u?yb(T,i-C):T}function b(I){var X=I-l,C=I-c;return l===void 0||X>=e||X<0||u&&C>=i}function E(){var I=vo();if(b(I))return k(I);a=setTimeout(E,m(I))}function k(I){return a=void 0,h&&o?g(I):(o=r=void 0,s)}function N(){a!==void 0&&clearTimeout(a),c=0,o=l=r=a=void 0}function x(){return a===void 0?s:k(vo())}function P(){var I=vo(),X=b(I);if(o=arguments,r=this,l=I,X){if(a===void 0)return f(l);if(u)return clearTimeout(a),a=setTimeout(E,e),g(l)}return a===void 0&&(a=setTimeout(E,e)),s}return P.cancel=N,P.flush=x,P}var Tb=Eb,kb=Tb,wb=Be,Cb="Expected a function";function Sb(n,e,t){var o=!0,r=!0;if(typeof n!="function")throw new TypeError(Cb);return wb(t)&&(o="leading"in t?!!t.leading:o,r="trailing"in t?!!t.trailing:r),kb(n,e,{leading:o,maxWait:e,trailing:r})}var xb=Sb;function Bb(n){for(var e,t=[];!(e=n.next()).done;)t.push(e.value);return t}var _b=Bb;function Ab(n){return n.split("")}var Ib=Ab,Ob="\\ud800-\\udfff",Nb="\\u0300-\\u036f",Rb="\\ufe20-\\ufe2f",Lb="\\u20d0-\\u20ff",Pb=Nb+Rb+Lb,Mb="\\ufe0e\\ufe0f",Db="\\u200d",$b=RegExp("["+Db+Ob+Pb+Mb+"]");function Fb(n){return $b.test(n)}var Hb=Fb,Cs="\\ud800-\\udfff",jb="\\u0300-\\u036f",zb="\\ufe20-\\ufe2f",Wb="\\u20d0-\\u20ff",Ub=jb+zb+Wb,Kb="\\ufe0e\\ufe0f",Gb="["+Cs+"]",bo="["+Ub+"]",yo="\\ud83c[\\udffb-\\udfff]",Yb="(?:"+bo+"|"+yo+")",Ss="[^"+Cs+"]",xs="(?:\\ud83c[\\udde6-\\uddff]){2}",Bs="[\\ud800-\\udbff][\\udc00-\\udfff]",Xb="\\u200d",_s=Yb+"?",As="["+Kb+"]?",Vb="(?:"+Xb+"(?:"+[Ss,xs,Bs].join("|")+")"+As+_s+")*",qb=As+_s+Vb,Zb="(?:"+[Ss+bo+"?",bo,xs,Bs,Gb].join("|")+")",Jb=RegExp(yo+"(?="+yo+")|"+Zb+qb,"g");function Qb(n){return n.match(Jb)||[]}var ey=Qb,ty=Ib,ny=Hb,oy=ey;function ry(n){return ny(n)?oy(n):ty(n)}var iy=ry;function sy(n,e){for(var t=-1,o=n==null?0:n.length,r=Array(o);++t<o;)r[t]=e(n[t],t,n);return r}var ay=sy,ly=ay;function cy(n,e){return ly(e,function(t){return n[t]})}var dy=cy,uy=dy,hy=Zi;function fy(n){return n==null?[]:uy(n,hy(n))}var py=fy,Is=en,gy=ps,my=ho,vy=st,by=ds,yy=_b,Ey=Wi,Ty=Ui,ky=iy,wy=py,Cy="[object Map]",Sy="[object Set]",Eo=Is?Is.iterator:void 0;function xy(n){if(!n)return[];if(vy(n))return by(n)?ky(n):gy(n);if(Eo&&n[Eo])return yy(n[Eo]());var e=my(n),t=e==Cy?Ey:e==Sy?Ty:wy;return t(n)}var By=xy,Os=(n=>(n.VERBOSE="VERBOSE",n.INFO="INFO",n.WARN="WARN",n.ERROR="ERROR",n))(Os||{});const fn=()=>"0.1.1",S={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,NUMBER_KEY_MIN:47,NUMBER_KEY_MAX:58,LETTER_KEY_MIN:64,LETTER_KEY_MAX:91,META:91,NUMPAD_KEY_MIN:95,NUMPAD_KEY_MAX:112,PUNCTUATION_KEY_MIN:185,PUNCTUATION_KEY_MAX:193,BRACKET_KEY_MIN:218,BRACKET_KEY_MAX:223,PROCESSING_KEY:229,SLASH:191},_y={LEFT:0,WHEEL:1,RIGHT:2,BACKWARD:3,FORWARD:4},Ay=1e8,Iy=16,ye=(()=>{try{return Function("return this")()}catch{return}})();ye&&typeof ye.window>"u"&&(ye.window=ye);const pn=()=>{if(ye!=null&&ye.window)return ye.window},Ns=()=>{if(ye!=null&&ye.navigator)return ye.navigator;const n=pn();return n==null?void 0:n.navigator},At=(n,e,t="log",o,r="color: inherit")=>{const i=typeof console>"u"?void 0:console;if(!i||typeof i[t]!="function")return;const s=["info","log","warn","error"].includes(t),a=[];switch(At.logLevel){case"ERROR":if(t!=="error")return;break;case"WARN":if(!["error","warn"].includes(t))return;break;case"INFO":if(!s||n)return;break}o&&a.push(o);const l=`Editor.js ${fn()}`,c=`line-height: 1em;
3
+ color: #006FEA;
4
+ display: inline-block;
5
+ font-size: 11px;
6
+ line-height: 1em;
7
+ background-color: #fff;
8
+ padding: 4px 9px;
9
+ border-radius: 30px;
10
+ border: 1px solid rgba(56, 138, 229, 0.16);
11
+ margin: 4px 5px 4px 0;`,d=(()=>n?s?(a.unshift(c,r),`%c${l}%c ${e}`):`( ${l} )${e}`:e)(),u=(()=>s?o!==void 0?[`${d} %o`,...a]:[d,...a]:[d])();try{i[t](...u)}catch{}};At.logLevel="VERBOSE";const Oy=n=>{At.logLevel=n},$=(n,e="log",t,o)=>{At(!1,n,e,t,o)},Ee=(n,e="log",t,o)=>{At(!0,n,e,t,o)},j=n=>tn(n),W=n=>cs(n),we=n=>ds(n),Rs=n=>Id(n),Ls=n=>um(n),Ny=function(n){return Am(n)},Q=n=>Sh(n),Ps=n=>By(n),gn=(n,e)=>function(...t){Sd(()=>n.apply(this,t),e)},Ry=n=>n.name.split(".").pop()??"",Ly=n=>/^[-\w]+\/([-+\w]+|\*)$/.test(n),Ms=(n,e,t)=>{const o={timeoutId:null};return function(...r){const i=()=>{o.timeoutId=null,t!==!0&&n.apply(this,r)},s=t===!0&&o.timeoutId===null;o.timeoutId!==null&&clearTimeout(o.timeoutId),o.timeoutId=setTimeout(i,e),s&&n.apply(this,r)}},To=(n,e,t)=>xb(n,e,t),Py=()=>{var r;const n={win:!1,mac:!1,x11:!1,linux:!1},e=Ns(),t=((r=e==null?void 0:e.userAgent)==null?void 0:r.toLowerCase())??"",o=t?Object.keys(n).find(i=>t.indexOf(i)!==-1):void 0;return o!==void 0&&(n[o]=!0),n},mn=n=>n&&n.slice(0,1).toUpperCase()+n.slice(1),My=(n,e)=>{if(Array.isArray(e))return e},It=(n,...e)=>!W(n)||e.length===0?n:e.reduce((t,o)=>W(o)?hb(t,o,My):t,n),ko=n=>{const e=Py(),t=n.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," + ");return e.mac?t.replace(/ctrl|cmd/gi,"⌘").replace(/alt/gi,"⌥"):t.replace(/cmd/gi,"Ctrl").replace(/windows/gi,"WIN")},Dy=n=>{try{return new URL(n).href}catch{}const e=pn();return n.substring(0,2)==="//"?e?`${e.location.protocol}${n}`:n:e?`${e.location.origin}${n}`:n},$y=()=>Sl(10),Fy=n=>{const e=pn();e&&e.open(n,"_blank")},Hy=(n="")=>`${n}${Math.floor(Math.random()*Ay).toString(Iy)}`,Ds=650,ut=()=>{const n=pn();return!n||typeof n.matchMedia!="function"?!1:n.matchMedia(`(max-width: ${Ds}px)`).matches},wo=(()=>{const n=Ns();if(!n)return!1;const e=n.userAgent||"",t=n.userAgentData,o=t==null?void 0:t.platform;return!!(/iP(ad|hone|od)/.test(e)||o!==void 0&&o!==""&&/iP(ad|hone|od)/.test(o)||((n.maxTouchPoints??0)>1?(o!==void 0&&o!==""?o:void 0)??(()=>n.platform)():void 0)==="MacIntel")})(),jy=(n,e)=>sm(n,e);class v{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&&["BR","WBR"].includes(e.tagName)}static make(e,t=null,o={}){const r=document.createElement(e);if(Array.isArray(t)){const i=t.filter(s=>s!==void 0);r.classList.add(...i)}typeof t=="string"&&r.classList.add(t);for(const i in o){if(!Object.prototype.hasOwnProperty.call(o,i))continue;const s=o[i];if(s!=null){if(i in r){r[i]=s;continue}r.setAttribute(i,String(s))}}return r}static text(e){return document.createTextNode(e)}static append(e,t){Array.isArray(t)?t.forEach(o=>e.appendChild(o)):e.appendChild(t)}static prepend(e,t){Array.isArray(t)?[...t].reverse().forEach(r=>e.prepend(r)):e.prepend(t)}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(t=>`input[type="${t}"]`).join(", ")}static findAllInputs(e){return Ps(e.querySelectorAll(v.allInputsSelector)).reduce((t,o)=>v.isNativeInput(o)||v.containsOnlyInlineElements(o)?[...t,o]:[...t,...v.getDeepestBlockElements(o)],[])}static getDeepestNode(e,t=!1){var d;const o=t?"lastChild":"firstChild",r=t?"previousSibling":"nextSibling";if(e===null||e.nodeType!==Node.ELEMENT_NODE)return e;const i=e[o];if(i===null)return e;const s=i;if(!(v.isSingleTag(s)&&!v.isNativeInput(s)&&!v.isLineBreakTag(s)))return this.getDeepestNode(s,t);const l=s[r];if(l)return this.getDeepestNode(l,t);const c=(d=s.parentNode)==null?void 0:d[r];return c?this.getDeepestNode(c,t):s.parentNode}static isElement(e){return Ls(e)?!1:e!=null&&e.nodeType!=null&&e.nodeType===Node.ELEMENT_NODE}static isFragment(e){return Ls(e)?!1:e!=null&&e.nodeType!=null&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}static isContentEditable(e){return e.contentEditable==="true"}static isNativeInput(e){const t=["INPUT","TEXTAREA"];return e!=null&&typeof e.tagName=="string"?t.includes(e.tagName):!1}static canSetCaret(e){return v.isNativeInput(e)?!new Set(["file","checkbox","radio","hidden","submit","button","image","reset"]).has(e.type):v.isContentEditable(e)}static isNodeEmpty(e,t){var i;if(this.isSingleTag(e)&&!this.isLineBreakTag(e))return!1;const o=this.isElement(e)&&this.isNativeInput(e)?e.value:(i=e.textContent)==null?void 0:i.replace("​",""),r=t?o==null?void 0:o.replace(new RegExp(t,"g"),""):o;return((r==null?void 0:r.length)??0)===0}static isLeaf(e){return e?e.childNodes.length===0:!1}static isEmpty(e,t){const o=[e];for(;o.length>0;){const r=o.shift();if(r){if(this.isLeaf(r)&&!this.isNodeEmpty(r,t))return!1;r.childNodes&&o.push(...Array.from(r.childNodes))}}return!0}static isHTMLString(e){const t=v.make("div");return t.innerHTML=e,t.childElementCount>0}static getContentLength(e){var t;return v.isNativeInput(e)?e.value.length:e.nodeType===Node.TEXT_NODE?e.length:((t=e.textContent)==null?void 0:t.length)??0}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){const t=we(e)?(()=>{const r=document.createElement("div");return r.innerHTML=e,r})():e,o=r=>!v.blockElements.includes(r.tagName.toLowerCase())&&Array.from(r.children).every(o);return Array.from(t.children).every(o)}static getDeepestBlockElements(e){return v.containsOnlyInlineElements(e)?[e]:Array.from(e.children).reduce((t,o)=>[...t,...v.getDeepestBlockElements(o)],[])}static getHolder(e){if(!we(e))return e;const t=document.getElementById(e);if(t!==null)return t;throw new Error(`Element with id "${e}" not found`)}static isAnchor(e){return e.tagName.toLowerCase()==="a"}static offset(e){const t=e.getBoundingClientRect(),o=window.scrollX||document.documentElement.scrollLeft,r=window.scrollY||document.documentElement.scrollTop,i=t.top+r,s=t.left+o;return{top:i,left:s,bottom:i+t.height,right:s+t.width}}static getNodeByOffset(e,t){const o=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null),r=(c,d,u,h)=>{if(!c&&u){const b=d-h,E=Math.max(t-b,0),k=Math.min(E,h);return{node:u,offset:k}}if(!c)return{node:null,offset:0};const f=(c.textContent??"").length;return d+f>=t?{node:c,offset:Math.min(t-d,f)}:r(o.nextNode(),d+f,c,f)},i=o.nextNode(),{node:s,offset:a}=r(i,0,null,0);if(!s)return{node:null,offset:0};const l=s.textContent;return!l||l.length===0?{node:null,offset:0}:{node:s,offset:a}}}const Co=n=>!/[^\t\n\r \u200B]/.test(n),zy=n=>{const e=window.getComputedStyle(n),t=parseFloat(e.fontSize),o=parseFloat(e.lineHeight)||t*1.2,r=parseFloat(e.paddingTop),i=parseFloat(e.borderTopWidth),s=parseFloat(e.marginTop),a=t*.8,l=(o-t)/2;return s+i+r+l+a},$s=n=>{const{dataset:e}=n;e.empty=v.isEmpty(n)?"true":"false"},Fs={ui:{blockTunes:{toggler:{"Click to tune":""}},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":""}}},ht=class{static ui(n,e){return ht._t(n,e)}static t(n,e){return ht._t(n,e)}static setDictionary(n){ht.currentDictionary=n}static _t(n,e){const t=ht.getNamespace(n);return!t||!t[e]?e:t[e]}static getNamespace(n){return n.split(".").reduce((t,o)=>{if(!t||!Object.keys(t).length)return{};const r=t[o];return typeof r=="string"?{}:r},ht.currentDictionary)}};let ne=ht;ne.currentDictionary=Fs;class Ot extends Error{}class Nt{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=r=>{const i=t(r),s=this.subscribers[e].indexOf(o);return s!==-1&&this.subscribers[e].splice(s,1),i};this.subscribers[e].push(o)}emit(e,t){Q(this.subscribers)||!this.subscribers[e]||this.subscribers[e].reduce((o,r)=>{const i=r(o);return i!==void 0?i:o},t)}off(e,t){const o=this.subscribers[e];if(o===void 0){console.warn(`EventDispatcher .off(): there is no subscribers for event "${e.toString()}". Probably, .off() called before .on()`);return}const r=o.indexOf(t);r!==-1&&o.splice(r,1)}destroy(){this.subscribers={}}}const Le=function(e){return 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(o){e.setStretchState(o)},get stretched(){return e.stretched},get focusable(){return e.focusable},call(o,r){return e.call(o,r)},save(){return e.save()},validate(o){return e.validate(o)},dispatchChange(){e.dispatchChange()},getActiveToolboxEntry(){return e.getActiveToolboxEntry()}}),Object.defineProperties(this,{id:{get(){return e.id},enumerable:!0,configurable:!0},name:{get(){return e.name},enumerable:!0,configurable:!0}}),this};class Rt{constructor(){this.allListeners=[]}on(e,t,o,r=!1){if(this.findOne(e,t,o,r))return;const s=Hy("l"),a={id:s,element:e,eventType:t,handler:o,options:r};return this.allListeners.push(a),e.addEventListener(t,o,r),s}off(e,t,o,r){const i=this.findAll(e,t,o,r);i.forEach((s,a)=>{const l=this.allListeners.indexOf(i[a]);l>-1&&(this.allListeners.splice(l,1),s.element.removeEventListener(s.eventType,s.handler,s.options))})}offById(e){const t=this.findById(e);if(!t)return;t.element.removeEventListener(t.eventType,t.handler,t.options);const o=this.allListeners.indexOf(t);o>-1&&this.allListeners.splice(o,1)}findOne(e,t,o,r){return this.findAll(e,t,o,r)[0]??null}findAll(e,t,o,r){return e?this.findByEventTarget(e).filter(s=>{const a=t===void 0||s.eventType===t,l=o===void 0||s.handler===o,c=this.areOptionsEqual(s.options,r);return a&&l&&c}):[]}removeAll(){this.allListeners.forEach(e=>{e.element.removeEventListener(e.eventType,e.handler,e.options)}),this.allListeners=[]}destroy(){this.removeAll()}findByEventTarget(e){return this.allListeners.filter(t=>t.element===e)}findByType(e){return this.allListeners.filter(t=>t.eventType===e)}findByHandler(e){return this.allListeners.filter(t=>t.handler===e)}findById(e){return this.allListeners.find(t=>t.id===e)}normalizeListenerOptions(e){return typeof e=="boolean"?{capture:e,once:!1,passive:!1}:e?{capture:e.capture??!1,once:e.once??!1,passive:e.passive??!1,signal:e.signal}:{capture:!1,once:!1,passive:!1}}areOptionsEqual(e,t){if(t===void 0)return!0;const o=this.normalizeListenerOptions(e),r=this.normalizeListenerOptions(t);return o.capture===r.capture&&o.once===r.once&&o.passive===r.passive&&o.signal===r.signal}}class F{constructor({config:e,eventsDispatcher:t}){if(this.nodes={},this.listeners=new Rt,this.readOnlyMutableListeners={on:(o,r,i,s=!1)=>{const a=this.listeners.on(o,r,i,s);a&&this.mutableListenerIds.push(a)},clearAll:()=>{for(const o of this.mutableListenerIds)this.listeners.offById(o);this.mutableListenerIds=[]}},this.mutableListenerIds=[],new.target===F)throw new TypeError("Constructors for abstract class Module are not allowed.");this.config=e,this.eventsDispatcher=t,this.Editor={}}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(){var e;return((e=this.config.i18n)==null?void 0:e.direction)==="rtl"}}class w{constructor(){this.instance=null,this.selection=null,this.savedSelectionRange=null,this.isFakeBackgroundEnabled=!1,this.fakeBackgroundElements=[]}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?v.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(w.get())}static isSelectionAtEditor(e){if(!e)return!1;const t=e.anchorNode||e.focusNode,o=t&&t.nodeType===Node.TEXT_NODE?t.parentNode:t,r=o&&o instanceof Element?o.closest(`.${w.CSS.editorZone}`):null;return r?r.nodeType===Node.ELEMENT_NODE:!1}static isRangeAtEditor(e){if(!e)return;const t=e.startContainer&&e.startContainer.nodeType===Node.TEXT_NODE?e.startContainer.parentNode:e.startContainer,o=t&&t instanceof Element?t.closest(`.${w.CSS.editorZone}`):null;return o?o.nodeType===Node.ELEMENT_NODE:!1}static get isSelectionExists(){const e=w.get();return!!(e!=null&&e.anchorNode)}static get range(){return this.getRangeFromSelection(this.get())}static getRangeFromSelection(e){return e&&e.rangeCount?e.getRangeAt(0):null}static get rect(){const e=document.selection,t={x:0,y:0,width:0,height:0};if(e&&e.type!=="Control"){const a=e.createRange();return t.x=a.boundingLeft,t.y=a.boundingTop,t.width=a.boundingWidth,t.height=a.boundingHeight,t}const o=window.getSelection();if(!o)return $("Method window.getSelection returned null","warn"),t;if(o.rangeCount===null||isNaN(o.rangeCount))return $("Method SelectionUtils.rangeCount is not supported","warn"),t;if(o.rangeCount===0)return t;const r=o.getRangeAt(0).cloneRange(),i=r.getBoundingClientRect();if(i.x===0&&i.y===0){const s=document.createElement("span");s.appendChild(document.createTextNode("​")),r.insertNode(s);const a=s.getBoundingClientRect(),l=s.parentNode;return l==null||l.removeChild(s),l==null||l.normalize(),a}return i}static get text(){const e=window.getSelection();return(e==null?void 0:e.toString())??""}static get(){return window.getSelection()}static setCursor(e,t=0){const o=document.createRange(),r=window.getSelection(),i=v.isNativeInput(e);if(i&&!v.canSetCaret(e))return e.getBoundingClientRect();if(i){const s=e;return s.focus(),s.selectionStart=t,s.selectionEnd=t,s.getBoundingClientRect()}return o.setStart(e,t),o.setEnd(e,t),r?(r.removeAllRanges(),r.addRange(o),o.getBoundingClientRect()):e.getBoundingClientRect()}static isRangeInsideContainer(e){const t=w.range;return t===null?!1:e.contains(t.startContainer)}static addFakeCursor(){const e=w.range;if(e===null)return;const t=v.make("span","codex-editor__fake-cursor");t.dataset.mutationFree="true",e.collapse(),e.insertNode(t)}static isFakeCursorInsideContainer(e){return v.find(e,".codex-editor__fake-cursor")!==null}static removeFakeCursor(e=document.body){const t=v.find(e,".codex-editor__fake-cursor");t&&t.remove()}removeFakeBackground(){var i;if(!this.fakeBackgroundElements.length){this.isFakeBackgroundEnabled=!1;return}const e=this.fakeBackgroundElements[0],t=this.fakeBackgroundElements[this.fakeBackgroundElements.length-1],o=e.firstChild,r=t.lastChild;if(this.fakeBackgroundElements.forEach(s=>{this.unwrapFakeBackground(s)}),o&&r){const s=document.createRange();s.setStart(o,0),s.setEnd(r,((i=r.textContent)==null?void 0:i.length)||0),this.savedSelectionRange=s}this.fakeBackgroundElements=[],this.isFakeBackgroundEnabled=!1}setFakeBackground(){this.removeFakeBackground();const e=window.getSelection();if(!e||e.rangeCount===0)return;const t=e.getRangeAt(0);if(t.collapsed)return;const o=this.collectTextNodes(t);if(o.length===0)return;const r=t.startContainer,i=t.startOffset,s=t.endContainer,a=t.endOffset;if(this.fakeBackgroundElements=[],o.forEach(c=>{var E;const d=document.createRange(),u=c===r,h=c===s,g=u?i:0,f=((E=c.textContent)==null?void 0:E.length)??0,m=h?a:f;if(g===m)return;d.setStart(c,g),d.setEnd(c,m);const b=this.wrapRangeWithFakeBackground(d);b&&this.fakeBackgroundElements.push(b)}),!this.fakeBackgroundElements.length)return;const l=document.createRange();l.setStartBefore(this.fakeBackgroundElements[0]),l.setEndAfter(this.fakeBackgroundElements[this.fakeBackgroundElements.length-1]),e.removeAllRanges(),e.addRange(l),this.isFakeBackgroundEnabled=!0}collectTextNodes(e){const t=[],{commonAncestorContainer:o}=e;if(o.nodeType===Node.TEXT_NODE)return t.push(o),t;const r=document.createTreeWalker(o,NodeFilter.SHOW_TEXT,{acceptNode:i=>e.intersectsNode(i)&&i.textContent&&i.textContent.length>0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT});for(;r.nextNode();)t.push(r.currentNode);return t}wrapRangeWithFakeBackground(e){if(e.collapsed)return null;const t=v.make("span","codex-editor__fake-background");t.dataset.fakeBackground="true",t.dataset.mutationFree="true",t.style.backgroundColor="#a8d6ff",t.style.color="inherit",t.style.display="inline",t.style.padding="0",t.style.margin="0";const o=e.extractContents();return o.childNodes.length===0?null:(t.appendChild(o),e.insertNode(t),t)}unwrapFakeBackground(e){const t=e.parentNode;if(t){for(;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}}save(){this.savedSelectionRange=w.range}restore(){if(!this.savedSelectionRange)return;const e=window.getSelection();e&&(e.removeAllRanges(),e.addRange(this.savedSelectionRange))}clearSaved(){this.savedSelectionRange=null}collapseToEnd(){const e=window.getSelection();if(!e||!e.focusNode)return;const t=document.createRange();t.selectNodeContents(e.focusNode),t.collapse(!1),e.removeAllRanges(),e.addRange(t)}findParentTag(e,t,o=10){const r=window.getSelection();if(!r||!r.anchorNode||!r.focusNode)return null;const i=[r.anchorNode,r.focusNode],s=a=>{const l=(c,d)=>{if(d<=0||!c.parentNode)return null;const u=c.parentNode,h=!t||u.classList&&u.classList.contains(t);return u.tagName===e&&h?u:l(u,d-1)};return l(a,o)};for(const a of i){const l=s(a);if(l)return l}return null}expandToTag(e){const t=window.getSelection();if(!t)return;t.removeAllRanges();const o=document.createRange();o.selectNodeContents(e),t.addRange(o)}}const Wy=(n,e)=>{const{type:t,target:o,addedNodes:r,removedNodes:i}=n;return n.type==="attributes"&&n.attributeName==="data-empty"?!1:e.contains(o)?!0:t!=="childList"?!1:Array.from(r).some(l=>l===e)?!0:Array.from(i).some(l=>l===e)},So="redactor dom changed",Hs="block changed",js="fake cursor is about to be toggled",zs="fake cursor have been set",Lt="editor mobile layout toggled",xo="block-settings-opened",Bo="block-settings-closed",_o=(n,e)=>{if(!n.conversionConfig)return!1;const t=n.conversionConfig[e];return j(t)||we(t)},vn=(n,e)=>_o(n.tool,e),Ws=(n,e)=>Object.entries(n).some(([t,o])=>e[t]&&jy(e[t],o)),Us=async(n,e)=>{const o=(await n.save()).data,r=e.find(i=>i.name===n.name);return r!==void 0&&!_o(r,"export")?[]:e.reduce((i,s)=>{if(!_o(s,"import")||s.toolbox===void 0)return i;const a=s.toolbox.filter(l=>{if(Q(l)||l.icon===void 0)return!1;const c=l.data!==void 0;return!(c&&Ws(l.data,o)||!c&&s.name===n.name)});return i.push({...s,toolbox:a}),i},[])},Ks=(n,e)=>n.mergeable?n.name===e.name?!0:vn(e,"export")&&vn(n,"import"):!1,Uy=(n,e)=>{const t=e==null?void 0:e.export;return j(t)?t(n):we(t)?n[t]:(t!==void 0&&$("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."),"")},Gs=(n,e,t)=>{const o=e==null?void 0:e.import;return j(o)?o(n,t):we(o)?{[o]:n}:(o!==void 0&&$("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 oe=(n=>(n.Default="default",n.Separator="separator",n.Html="html",n))(oe||{});const ft="data-block-tool";var Pe=(n=>(n.RENDERED="rendered",n.MOVED="moved",n.UPDATED="updated",n.REMOVED="removed",n.ON_PASTE="onPaste",n))(Pe||{});class re extends Nt{constructor({id:e=$y(),data:t,tool:o,readOnly:r,tunesData:i},s){super(),this.cachedInputs=[],this.lastSavedTunes={},this.toolRenderedElement=null,this.tunesInstances=new Map,this.defaultTunesInstances=new Map,this.unavailableTunesData={},this.inputIndex=0,this.editorEventBus=null,this.redactorDomChangedCallback=()=>{},this.handleFocus=()=>{this.dropInputsCache(),this.updateCurrentInput()},this.didMutated=(l=void 0)=>{const c=l===void 0,d=l instanceof InputEvent;!c&&!d&&this.detectToolRootChange(l),(()=>c||d?!0:!(l.length>0&&l.every(g=>{const{addedNodes:f,removedNodes:m,target:b}=g;return[...Array.from(f),...Array.from(m),b].some(k=>{const N=v.isElement(k)?k:k.parentElement??null;return N===null?!1:N.closest('[data-mutation-free="true"]')!==null})})))()&&(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=this.settings,this.editorEventBus=s||null,this.blockAPI=new Le(this),this.lastSavedData=t??{},this.lastSavedTunes=i??{},this.tool=o,this.toolInstance=o.create(t,this.blockAPI,r),this.tunes=o.tunes,this.composeTunes(i);const a=this.compose();if(a==null)throw new Error(`Tool "${this.name}" did not return a block holder element during render()`);this.holder=a,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"}}call(e,t){const o=this.toolInstance[e];if(j(o))try{o.call(this.toolInstance,t)}catch(r){const i=r instanceof Error?r.message:String(r);$(`Error during '${e}' call: ${i}`,"error")}}async mergeWith(e){if(!j(this.toolInstance.merge))throw new Error(`Block tool "${this.name}" does not support merging`);await this.toolInstance.merge(e)}async save(){const e=await this.extractToolData();if(e===void 0)return;const t={...this.unavailableTunesData};[...this.tunesInstances.entries(),...this.defaultTunesInstances.entries()].forEach(([i,s])=>{if(j(s.save))try{t[i]=s.save()}catch(a){$(`Tune ${s.constructor.name} save method throws an Error %o`,"warn",a)}});const o=window.performance.now();this.lastSavedData=e,this.lastSavedTunes={...t};const r=window.performance.now();return{id:this.id,tool:this.name,data:e,tunes:t,time:r-o}}async extractToolData(){try{const e=await this.toolInstance.save(this.pluginsContent);if(!this.isEmpty||e===void 0||e===null||typeof e!="object")return e;const t={...e},o=r=>{const i=t[r];if(typeof i!="string")return;const s=document.createElement("div");s.innerHTML=i,v.isEmpty(s)&&(t[r]="")};return o("text"),o("html"),t}catch(e){const t=e instanceof Error?e:new Error(String(e));$(`Saving process for ${this.name} tool failed due to the ${t}`,"log",t);return}}async validate(e){return this.toolInstance.validate instanceof Function?await this.toolInstance.validate(e):!0}getTunes(){const e=[],t=[],o=(s,a)=>{if(s){if(v.isElement(s)){a.push({type:oe.Html,element:s});return}if(Array.isArray(s)){a.push(...s);return}a.push(s)}},r=typeof this.toolInstance.renderSettings=="function"?this.toolInstance.renderSettings():[];return o(r,e),[...this.tunesInstances.values(),...this.defaultTunesInstances.values()].map(s=>s.render()).forEach(s=>{o(s,t)}),{toolTunes:e,commonTunes:t}}updateCurrentInput(){const e=w.anchorNode,t=document.activeElement,o=i=>{if(!i)return;const s=i instanceof HTMLElement?i:i.parentElement;if(s===null)return;const a=this.inputs.find(d=>d===s||d.contains(s));if(a!==void 0)return a;const l=s.closest(v.allInputsSelector);if(!(l instanceof HTMLElement))return;const c=this.inputs.find(d=>d===l);if(c!==void 0)return c};if(v.isNativeInput(t)){this.currentInput=t;return}const r=o(e)??(t instanceof HTMLElement?o(t):void 0);if(r!==void 0){this.currentInput=r;return}t instanceof HTMLElement&&this.inputs.includes(t)&&(this.currentInput=t)}dispatchChange(){this.didMutated()}destroy(){this.unwatchBlockMutations(),this.removeInputEvents(),super.destroy(),j(this.toolInstance.destroy)&&this.toolInstance.destroy()}async getActiveToolboxEntry(){const e=this.tool.toolbox;if(!e)return;if(e.length===1)return Promise.resolve(e[0]);const t=await this.data;return e.find(o=>Ws(o.data,t))}async exportDataAsString(){const e=await this.data;return Uy(e,this.tool.conversionConfig)}get inputs(){if(this.cachedInputs.length!==0)return this.cachedInputs;const e=v.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){if(e===void 0)return;const t=this.inputs.findIndex(o=>o===e||o.contains(e));t!==-1&&(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&&!Q(e.data)?e.data:{})}get preservedData(){return this.lastSavedData??{}}get preservedTunes(){return this.lastSavedTunes??{}}get sanitize(){return this.tool.sanitizeConfig}get mergeable(){return j(this.toolInstance.merge)}get focusable(){return this.inputs.length!==0}get isEmpty(){const e=v.isEmpty(this.pluginsContent,"/"),t=!this.hasMedia;return e&&t}get hasMedia(){const e=["img","iframe","video","audio","source","input","textarea","twitterwidget"];return!!this.holder.querySelector(e.join(","))}set selected(e){var r,i;this.holder.classList.toggle(re.CSS.selected,e);const t=e===!0&&w.isRangeInsideContainer(this.holder),o=e===!1&&w.isFakeCursorInsideContainer(this.holder);!t&&!o||((r=this.editorEventBus)==null||r.emit(js,{state:e}),t&&w.addFakeCursor(),o&&w.removeFakeCursor(this.holder),(i=this.editorEventBus)==null||i.emit(zs,{state:e}))}get selected(){return this.holder.classList.contains(re.CSS.selected)}setStretchState(e){this.holder.classList.toggle(re.CSS.wrapperStretched,e)}set stretched(e){this.setStretchState(e)}get stretched(){return this.holder.classList.contains(re.CSS.wrapperStretched)}get pluginsContent(){if(this.toolRenderedElement===null)throw new Error("Block pluginsContent is not yet initialized");return this.toolRenderedElement}compose(){const e=v.make("div",re.CSS.wrapper),t=v.make("div",re.CSS.content),o=this.toolInstance.render();this.name&&!e.hasAttribute(ft)&&e.setAttribute(ft,this.name),e.dataset.id=this.id,o instanceof Promise?o.then(i=>{this.toolRenderedElement=i,this.addToolDataAttributes(i,e),t.appendChild(i)}).catch(i=>{$("Tool render promise rejected: %o","error",i)}):(this.toolRenderedElement=o,this.addToolDataAttributes(o,e),t.appendChild(o));const r=[...this.tunesInstances.values(),...this.defaultTunesInstances.values()].reduce((i,s)=>{if(j(s.wrap))try{return s.wrap(i)}catch(a){return $(`Tune ${s.constructor.name} wrap method throws an Error %o`,"warn",a),i}return i},t);return e.appendChild(r),e}addToolDataAttributes(e,t){var s;this.name&&!t.hasAttribute(ft)&&t.setAttribute(ft,this.name),this.name&&!e.hasAttribute(ft)&&e.setAttribute(ft,this.name);const o="data-placeholder",r=(s=this.config)==null?void 0:s.placeholder,i=typeof r=="string"?r.trim():"";if(i.length>0){e.setAttribute(o,i);return}r===!1&&e.hasAttribute(o)&&e.removeAttribute(o)}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(([t,o])=>{this.tunesInstances.has(t)||(this.unavailableTunesData[t]=o)})}addInputEvents(){this.inputs.forEach(e=>{e.addEventListener("focus",this.handleFocus),v.isNativeInput(e)&&e.addEventListener("input",this.didMutated)})}removeInputEvents(){this.inputs.forEach(e=>{e.removeEventListener("focus",this.handleFocus),v.isNativeInput(e)&&e.removeEventListener("input",this.didMutated)})}watchBlockMutations(){var e;this.redactorDomChangedCallback=t=>{const{mutations:o}=t,r=this.toolRenderedElement;r!==null&&o.some(s=>Wy(s,r))&&this.didMutated(o)},(e=this.editorEventBus)==null||e.on(So,this.redactorDomChangedCallback)}unwatchBlockMutations(){var e;(e=this.editorEventBus)==null||e.off(So,this.redactorDomChangedCallback)}detectToolRootChange(e){const t=this.toolRenderedElement;t!==null&&e.forEach(o=>{if(Array.from(o.removedNodes).includes(t)){const i=o.addedNodes[o.addedNodes.length-1];this.toolRenderedElement=i}})}dropInputsCache(){this.cachedInputs=[]}toggleInputsEmptyMark(){this.inputs.forEach($s)}}class Ky extends F{constructor(){super(...arguments),this.insert=(e,t={},o={},r,i,s,a)=>{const l=e??this.config.defaultBlock,c=this.Editor.BlockManager.insert({id:a,tool:l,data:t,index:r,needToFocus:i,replace:s});return new Le(c)},this.composeBlockData=async e=>{const t=this.Editor.Tools.blockTools.get(e);if(t===void 0)throw new Error(`Block Tool with type "${e}" not found`);return new re({tool:t,api:this.Editor.API,readOnly:!0,data:{},tunesData:{}}).data},this.update=async(e,t,o)=>{const{BlockManager:r}=this.Editor,i=r.getBlockById(e);if(i===void 0)throw new Error(`Block with id "${e}" not found`);const s=await r.update(i,t,o);return new Le(s)},this.convert=async(e,t,o)=>{var u,h;const{BlockManager:r,Tools:i}=this.Editor,s=r.getBlockById(e);if(!s)throw new Error(`Block with id "${e}" not found`);const a=i.blockTools.get(s.name),l=i.blockTools.get(t);if(!l)throw new Error(`Block Tool with type "${t}" not found`);const c=((u=a==null?void 0:a.conversionConfig)==null?void 0:u.export)!==void 0,d=((h=l.conversionConfig)==null?void 0:h.import)!==void 0;if(c&&d){const g=await r.convert(s,t,o);return new Le(g)}else{const g=[c?!1:mn(s.name),d?!1:mn(t)].filter(Boolean).join(" and ");throw new Error(`Conversion from "${s.name}" to "${t}" is not possible. ${g} tool(s) should provide a "conversionConfig"`)}},this.insertMany=(e,t=this.Editor.BlockManager.blocks.length-1)=>{this.validateIndex(t);const o=e.map(({id:r,type:i,data:s})=>this.Editor.BlockManager.composeBlock({id:r,tool:i||this.config.defaultBlock,data:s}));return this.Editor.BlockManager.insertMany(o,t),o.map(r=>new Le(r))}}get methods(){return{clear:()=>this.clear(),render:e=>this.render(e),renderFromHTML:e=>this.renderFromHTML(e),delete:e=>this.delete(e),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),insert:this.insert,insertMany:this.insertMany,update:this.update,composeBlockData:this.composeBlockData,convert:this.convert,stretchBlock:(e,t=!0)=>this.stretchBlock(e,t)}}getBlocksCount(){return this.Editor.BlockManager.blocks.length}getCurrentBlockIndex(){return this.Editor.BlockManager.currentBlockIndex}getBlockIndex(e){const t=this.Editor.BlockManager.getBlockById(e);if(!t){Ee("There is no block with id `"+e+"`","warn");return}return this.Editor.BlockManager.getBlockIndex(t)}getBlockByIndex(e){const t=this.Editor.BlockManager.getBlockByIndex(e);if(t===void 0){Ee("There is no block at index `"+e+"`","warn");return}return new Le(t)}getById(e){const t=this.Editor.BlockManager.getBlockById(e);return t===void 0?(Ee("There is no block with id `"+e+"`","warn"),null):new Le(t)}getBlockByElement(e){const t=this.Editor.BlockManager.getBlock(e);if(t===void 0){Ee("There is no block corresponding to element `"+e+"`","warn");return}return new Le(t)}move(e,t){this.Editor.BlockManager.move(e,t)}delete(e=this.Editor.BlockManager.currentBlockIndex){const t=this.Editor.BlockManager.getBlockByIndex(e);if(t===void 0){Ee(`There is no block at index \`${e}\``,"warn");return}try{this.Editor.BlockManager.removeBlock(t)}catch(o){Ee(o,"warn");return}this.Editor.BlockManager.blocks.length===0&&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(e===void 0||e.blocks===void 0)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){const o=this.Editor.BlockManager.getBlockByIndex(e);o&&o.setStretchState(t)}validateIndex(e){if(typeof e!="number")throw new Error("Index should be a number");if(e<0)throw new Error("Index should be greater than or equal to 0");if(e===null)throw new Error("Index should be greater than or equal to 0")}}const Gy=(n,e)=>typeof n=="number"?e.BlockManager.getBlockByIndex(n):typeof n=="string"?e.BlockManager.getBlockById(n):e.BlockManager.getBlockById(n.id);class Yy extends F{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):!1,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):!1,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):!1,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):!1,this.setToBlock=(e,t=this.Editor.Caret.positions.DEFAULT,o=0)=>{const r=Gy(e,this.Editor);return r===void 0?!1:(this.Editor.Caret.setToBlock(r,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}}}class Xy extends F{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)}}class Ao extends F{static getNamespace(e,t){return t?`blockTunes.${e}`:`tools.${e}`}get methods(){return{t:e=>(Ee("I18n.t() method can be accessed only from Tools","warn"),"")}}getMethodsForTool(e,t){return Object.assign(this.methods,{t:o=>ne.t(Ao.getNamespace(e,t),o)})}}class Vy extends F{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)})}}class qy extends F{get methods(){return{close:()=>this.close(),open:()=>this.open()}}open(){this.Editor.InlineToolbar.tryToShow()}close(){this.Editor.InlineToolbar.close()}}class Zy extends F{get methods(){return{on:(e,t,o,r)=>this.on(e,t,o,r),off:(e,t,o,r)=>this.off(e,t,o,r),offById:e=>this.offById(e)}}on(e,t,o,r){return this.listeners.on(e,t,o,r)}off(e,t,o,r){this.listeners.off(e,t,o,r)}offById(e){this.listeners.offById(e)}}class Jy{constructor(){this.notifierModule=null,this.loadingPromise=null}loadNotifierModule(){return this.notifierModule!==null?Promise.resolve(this.notifierModule):(this.loadingPromise===null&&(this.loadingPromise=Promise.resolve().then(()=>Mw).then(e=>{const t=(e==null?void 0:e.default)??e;if(!this.isNotifierModule(t))throw new Error('codex-notifier module does not expose a "show" method.');return this.notifierModule=t,t}).catch(e=>{throw this.loadingPromise=null,e})),this.loadingPromise)}show(e){this.loadNotifierModule().then(t=>{t.show(e)}).catch(t=>{console.error("[Editor.js] Failed to display notification. Reason:",t)})}isNotifierModule(e){return typeof e=="object"&&e!==null&&"show"in e&&typeof e.show=="function"}}class Qy extends F{constructor({config:e,eventsDispatcher:t}){super({config:e,eventsDispatcher:t}),this.notifier=new Jy}get methods(){return{show:e=>this.show(e)}}show(e){return this.notifier.show(e)}}class eE extends F{get methods(){const e=()=>this.isEnabled;return{toggle:t=>this.toggle(t),get isEnabled(){return e()}}}toggle(e){return this.Editor.ReadOnly.toggle(e)}get isEnabled(){return this.Editor.ReadOnly.isEnabled}}var Io={},tE={get exports(){return Io},set exports(n){Io=n}};(function(n,e){(function(t,o){n.exports=o()})(pe,function(){function t(u){var h=u.tags,g=Object.keys(h),f=g.map(function(m){return typeof h[m]}).every(function(m){return m==="object"||m==="boolean"||m==="function"});if(!f)throw new Error("The configuration was invalid");this.config=u}var o=["P","LI","TD","TH","DIV","H1","H2","H3","H4","H5","H6","PRE"];function r(u){return o.indexOf(u.nodeName)!==-1}var i=["A","B","STRONG","I","EM","SUB","SUP","U","STRIKE"];function s(u){return i.indexOf(u.nodeName)!==-1}t.prototype.clean=function(u){const h=document.implementation.createHTMLDocument(),g=h.createElement("div");return g.innerHTML=u,this._sanitize(h,g),g.innerHTML},t.prototype._sanitize=function(u,h){var g=a(u,h),f=g.firstChild();if(f)do{if(f.nodeType===Node.TEXT_NODE)if(f.data.trim()===""&&(f.previousElementSibling&&r(f.previousElementSibling)||f.nextElementSibling&&r(f.nextElementSibling))){h.removeChild(f),this._sanitize(u,h);break}else continue;if(f.nodeType===Node.COMMENT_NODE){h.removeChild(f),this._sanitize(u,h);break}var m=s(f),b;m&&(b=Array.prototype.some.call(f.childNodes,r));var E=!!h.parentNode,k=r(h)&&r(f)&&E,N=f.nodeName.toLowerCase(),x=l(this.config,N,f),P=m&&b;if(P||c(f,x)||!this.config.keepNestedBlockElements&&k){if(!(f.nodeName==="SCRIPT"||f.nodeName==="STYLE"))for(;f.childNodes.length>0;)h.insertBefore(f.childNodes[0],f);h.removeChild(f),this._sanitize(u,h);break}for(var I=0;I<f.attributes.length;I+=1){var X=f.attributes[I];d(X,x,f)&&(f.removeAttribute(X.name),I=I-1)}this._sanitize(u,f)}while(f=g.nextSibling())};function a(u,h){return u.createTreeWalker(h,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT,null,!1)}function l(u,h,g){return typeof u.tags[h]=="function"?u.tags[h](g):u.tags[h]}function c(u,h){return typeof h>"u"?!0:typeof h=="boolean"?!h:!1}function d(u,h,g){var f=u.name.toLowerCase();return h===!0?!1:typeof h[f]=="function"?!h[f](u.value,g):typeof h[f]>"u"||h[f]===!1?!0:typeof h[f]=="string"?h[f]!==u.value:!1}return t})})(tE);const nE=Io,oE=/^\s*(?:javascript\s*:|data\s*:\s*text\s*\/\s*html)/i,rE=/\s*(?:href|src)\s*=\s*(?:"\s*(?:javascript\s*:|data\s*:\s*text\s*\/\s*html)[^"]*"|'\s*(?:javascript\s*:|data\s*:\s*text\s*\/\s*html)[^']*|(?:javascript\s*:|data\s*:\s*text\s*\/\s*html)[^ \t\r\n>]*)/gi,Oo=(n,e,t={})=>n.map(o=>{const i=(j(e)?e(o.tool):e)??{};return W(i)&&Q(i)&&Q(t)?o:{...o,data:No(o.data,i,t)}}),Ae=(n,e={})=>{const t={tags:e};return new nE(t).clean(n)},No=(n,e,t)=>Array.isArray(n)?iE(n,e,t):W(n)?sE(n,e,t):we(n)?aE(n,e,t):n,iE=(n,e,t)=>n.map(o=>No(o,e,t)),sE=(n,e,t)=>{const o={},r=n;for(const i in n){if(!Object.prototype.hasOwnProperty.call(n,i))continue;const s=r[i],a=W(e)?e:void 0,l=a==null?void 0:a[i],c=l!==void 0&&lE(l)?l:e;o[i]=No(s,c,t)}return o},aE=(n,e,t)=>{const o=pE(e,t);if(o){const r=Ae(n,o);return Ro(Xs(r,o))}if(!Q(t)){const r=Ae(n,t);return Ro(Xs(r,t))}return Ro(n)},lE=n=>W(n)||Rs(n)||j(n),cE=n=>n?oE.test(n):!1,Ro=n=>{if(!n||n.indexOf("<")===-1)return n;if(typeof document<"u"){const e=document.createElement("template");return e.innerHTML=n,e.content.querySelectorAll("[href],[src]").forEach(o=>{["href","src"].forEach(r=>{const i=o.getAttribute(r);cE(i)&&o.removeAttribute(r)})}),e.innerHTML}return n.replace(rE,"")},Lo=n=>{if(Q(n))return{};const e={};for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=Ve(n[t]));return e},Ys=n=>function(t){const o=n.call(this,t);return o??{}},dE=new Set(["class","id","title","role","dir","lang"]),uE=n=>{const e=n.toLowerCase();return e.startsWith("data-")||e.startsWith("aria-")||dE.has(e)},hE=n=>{const e={};return Array.from(n.attributes).forEach(t=>{uE(t.name)&&(e[t.name]=!0)}),e},Ve=n=>n===!0?Ys(hE):n===!1?!1:j(n)?Ys(n):we(n)?n:W(n)?It({},n):n,fE=(n,e)=>{if(Q(n))return Lo(e);const t={};for(const o in n){if(!Object.prototype.hasOwnProperty.call(n,o))continue;const r=n[o],i=e?e[o]:void 0;if(j(i)){t[o]=Ve(i);continue}if(j(r)){t[o]=Ve(r);continue}if(W(r)&&W(i)){t[o]=It({},i,r);continue}if(i!==void 0){t[o]=Ve(i);continue}t[o]=Ve(r)}return t},pE=(n,e)=>W(n)&&!j(n)?fE(e,n):n===!1?{}:Q(e)?null:Lo(e),Po=(n,...e)=>{if(Q(n))return Object.assign({},...e);const t=Lo(n);return e.forEach(o=>{if(o)for(const r in o){if(!Object.prototype.hasOwnProperty.call(o,r)||!Object.prototype.hasOwnProperty.call(t,r))continue;const i=o[r],s=t[r];if(j(i)){t[r]=i;continue}if(!(i===!0&&j(s))){if(i===!0){const a=W(s)&&!j(s);t[r]=a?It({},s):Ve(i);continue}if(W(i)&&W(s)){t[r]=It({},s,i);continue}t[r]=Ve(i)}}}),t},Xs=(n,e)=>{if(typeof document>"u"||!n||n.indexOf("<")===-1)return n;const t=Object.entries(e).filter(([,r])=>j(r));if(t.length===0)return n;const o=document.createElement("template");return o.innerHTML=n,t.forEach(([r,i])=>{o.content.querySelectorAll(r).forEach(a=>{const l=i(a);if(!(Rs(l)||j(l)||l==null))for(const[c,d]of Object.entries(l)){if(d===!1){a.removeAttribute(c);continue}d!==!0&&we(d)&&a.setAttribute(c,d)}})}),o.innerHTML};class gE extends F{get methods(){return{clean:(e,t)=>this.clean(e,t)}}clean(e,t){return Ae(e,t)}}class mE extends F{get methods(){return{save:()=>this.save()}}async save(){var i,s;const e="Editor's content can not be saved in read-only mode";if(this.Editor.ReadOnly.isEnabled)throw Ee(e,"warn"),new Error(e);const t=await this.Editor.Saver.save();if(t!==void 0)return t;const o=(s=(i=this.Editor.Saver).getLastSaveError)==null?void 0:s.call(i);if(o instanceof Error)throw o;const r=o!==void 0?String(o):"Editor's content can not be saved because collecting data failed";throw new Error(r)}}class vE extends F{constructor(){super(...arguments),this.selectionUtils=new w}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)}}class bE extends F{get methods(){return{getBlockTools:()=>Array.from(this.Editor.Tools.blockTools.values())}}}class yE extends F{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"}}}class EE extends F{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){if(this.Editor.BlockManager.currentBlockIndex===-1){Ee("Could't toggle the Toolbar because there is no block selected ","warn");return}e??!this.Editor.BlockSettings.opened?(this.Editor.Toolbar.moveAndOpen(),this.Editor.BlockSettings.open()):this.Editor.BlockSettings.close()}toggleToolbox(e){if(this.Editor.BlockManager.currentBlockIndex===-1){Ee("Could't toggle the Toolbox because there is no block selected ","warn");return}e??!this.Editor.Toolbar.toolbox.opened?(this.Editor.Toolbar.moveAndOpen(),this.Editor.Toolbar.toolbox.open()):this.Editor.Toolbar.toolbox.close()}}const TE=`:root{--ct-color-bg: #1d202b;--ct-color-font: #cdd1e0}.ct{position:absolute;z-index:999;top:0;left:0;background-color:#1d202b;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 #1d202b2b,0 4px 5px -3px #05060c7d;border-radius:9px}.ct:before{content:"";top:0;right:0;bottom:0;left:0;position:absolute;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" fill="#000" fill-rule="nonzero"/></svg>') 48% 41% 37.9% 53.3%}}@media (max-width: 768px){.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:translate(-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:translate(-50%) rotate(-45deg)}.ct--left{-webkit-transform:translateX(-5px);transform:translate(-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:translate(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}
12
+ `,kE=180,wE=400,pt="data-interface",CE="editorjs",SE="inline-toolbar",Mo="tooltip",Vs="[data-interface=editorjs]",xE="[data-interface=inline-toolbar]";typeof process<"u"&&process.platform?process.platform==="darwin"?"Meta":"Control":typeof navigator<"u"&&navigator.userAgent.toLowerCase().includes("mac")?"Meta":"Control";const Do=10,BE="tooltip",_E="aria-hidden",AE="false",IE="true",OE="visibility",NE="visible",RE="hidden";/**
13
+ * Tiny any beautiful tooltips module.
14
+ *
15
+ * Can be showed near passed Element with any specified HTML content
16
+ * @author CodeX <codex.so>
17
+ * @license MIT
18
+ */const gt=class{constructor(){this.nodes={wrapper:null,content:null},this.showed=!1,this.offsetTop=Do,this.offsetLeft=Do,this.offsetRight=Do,this.showingTimeout=null,this.hidingDelay=0,this.hidingTimeout=null,this.ariaObserver=null,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"}}}static getInstance(){return gt.instance||(gt.instance=new gt),gt.instance}show(n,e,t={}){this.nodes.wrapper||this.prepare(),this.hidingTimeout&&(clearTimeout(this.hidingTimeout),this.hidingTimeout=null);const r=Object.assign({placement:"bottom",marginTop:0,marginLeft:0,marginRight:0,marginBottom:0,delay:70,hidingDelay:0},t);if(r.hidingDelay&&(this.hidingDelay=r.hidingDelay),!!this.nodes.content&&(this.nodes.content.innerHTML="",this.nodes.content.appendChild(this.createContentNode(e)),!!this.nodes.wrapper)){switch(this.nodes.wrapper.classList.remove(...Object.values(this.CSS.placement)),r.placement){case"top":this.placeTop(n,r);break;case"left":this.placeLeft(n,r);break;case"right":this.placeRight(n,r);break;case"bottom":default:this.placeBottom(n,r);break}if(r&&r.delay){this.showingTimeout=setTimeout(()=>{this.nodes.wrapper&&(this.nodes.wrapper.classList.add(this.CSS.tooltipShown),this.updateTooltipVisibility()),this.showed=!0},r.delay);return}this.nodes.wrapper&&(this.nodes.wrapper.classList.add(this.CSS.tooltipShown),this.updateTooltipVisibility()),this.showed=!0}}createContentNode(n){if(typeof n=="string")return document.createTextNode(n);if(n instanceof Node)return n;throw Error("[CodeX Tooltip] Wrong type of «content» passed. It should be an instance of Node or String. But "+typeof n+" given.")}hide(n=!1){const e=!!this.hidingDelay&&!n;if(e&&this.hidingTimeout&&clearTimeout(this.hidingTimeout),e){this.hidingTimeout=setTimeout(()=>{this.hide(!0)},this.hidingDelay);return}this.nodes.wrapper&&(this.nodes.wrapper.classList.remove(this.CSS.tooltipShown),this.updateTooltipVisibility()),this.showed=!1,this.showingTimeout&&(clearTimeout(this.showingTimeout),this.showingTimeout=null)}onHover(n,e,t={}){n.addEventListener("mouseenter",()=>{this.show(n,e,t)}),n.addEventListener("mouseleave",()=>{this.hide()})}destroy(){var n;(n=this.ariaObserver)==null||n.disconnect(),this.ariaObserver=null,this.nodes.wrapper&&this.nodes.wrapper.remove(),window.removeEventListener("scroll",this.handleWindowScroll),gt.instance=null}prepare(){this.nodes.wrapper=this.make("div",this.CSS.tooltip),this.nodes.wrapper.setAttribute(pt,Mo),this.nodes.content=this.make("div",this.CSS.tooltipContent),this.nodes.wrapper&&this.nodes.content&&(this.append(this.nodes.wrapper,this.nodes.content),this.append(document.body,this.nodes.wrapper),this.ensureTooltipAttributes())}updateTooltipVisibility(){if(!this.nodes.wrapper)return;const n=this.nodes.wrapper.classList.contains(this.CSS.tooltipShown);this.nodes.wrapper.style.setProperty(OE,n?NE:RE),this.nodes.wrapper.setAttribute(_E,n?AE:IE)}watchTooltipVisibility(){var n;this.nodes.wrapper&&((n=this.ariaObserver)==null||n.disconnect(),this.updateTooltipVisibility(),this.ariaObserver=new MutationObserver(()=>{this.updateTooltipVisibility()}),this.ariaObserver.observe(this.nodes.wrapper,{attributes:!0,attributeFilter:["class"]}))}ensureTooltipAttributes(){this.nodes.wrapper&&((!this.nodes.wrapper.hasAttribute(pt)||this.nodes.wrapper.getAttribute(pt)!==Mo)&&this.nodes.wrapper.setAttribute(pt,Mo),this.nodes.wrapper.setAttribute("role",BE),this.watchTooltipVisibility())}loadStyles(){const n="codex-tooltips-style";if(document.getElementById(n))return;const e=this.make("style",null,{textContent:TE,id:n});this.prepend(document.head,e)}placeBottom(n,e){if(!this.nodes.wrapper)return;const t=n.getBoundingClientRect(),o=t.left+n.clientWidth/2-this.nodes.wrapper.offsetWidth/2,r=t.bottom+this.getScrollTop()+this.offsetTop+(e.marginTop??0);this.applyPlacement("bottom",o,r)}placeTop(n,e){if(!this.nodes.wrapper)return;const t=n.getBoundingClientRect(),o=t.left+n.clientWidth/2-this.nodes.wrapper.offsetWidth/2,r=t.top+this.getScrollTop()-this.nodes.wrapper.clientHeight-this.offsetTop;this.applyPlacement("top",o,r)}placeLeft(n,e){if(!this.nodes.wrapper)return;const t=n.getBoundingClientRect(),o=t.left-this.nodes.wrapper.offsetWidth-this.offsetLeft-(e.marginLeft??0),r=t.top+this.getScrollTop()+n.clientHeight/2-this.nodes.wrapper.offsetHeight/2;this.applyPlacement("left",o,r)}placeRight(n,e){if(!this.nodes.wrapper)return;const t=n.getBoundingClientRect(),o=t.right+this.offsetRight+(e.marginRight??0),r=t.top+this.getScrollTop()+n.clientHeight/2-this.nodes.wrapper.offsetHeight/2;this.applyPlacement("right",o,r)}applyPlacement(n,e,t){this.nodes.wrapper&&(this.nodes.wrapper.classList.add(this.CSS.placement[n]),this.nodes.wrapper.style.left=`${e}px`,this.nodes.wrapper.style.top=`${t}px`)}getScrollTop(){var n;return typeof window.scrollY=="number"?window.scrollY:((n=document.documentElement)==null?void 0:n.scrollTop)??document.body.scrollTop??0}make(n,e=null,t={}){const o=document.createElement(n);Array.isArray(e)&&o.classList.add(...e),typeof e=="string"&&o.classList.add(e);for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(o[r]=t[r]);return o}append(n,e){Array.isArray(e)?e.forEach(t=>n.appendChild(t)):n.appendChild(e)}prepend(n,e){Array.isArray(e)?e.reverse().forEach(o=>n.prepend(o)):n.prepend(e)}};let qs=gt;qs.instance=null;const bn=()=>qs.getInstance(),LE=(n,e,t)=>{bn().show(n,e,t??{})},Pt=(n=!1)=>{bn().hide(n)},yn=(n,e,t)=>{bn().onHover(n,e,t??{})},PE=()=>{bn().destroy()};class ME extends F{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){LE(e,t,o)}hide(){Pt()}onHover(e,t,o){yn(e,t,o)}}class DE extends F{get methods(){return{nodes:this.editorNodes}}get editorNodes(){return{wrapper:this.Editor.UI.nodes.wrapper,redactor:this.Editor.UI.nodes.redactor}}}const Zs=(n,e)=>{const t={};return Object.entries(n).forEach(([o,r])=>{if(!W(r)){t[o]=r;return}const i=e?`${e}.${o}`:o;if(!Object.values(r).every(a=>we(a))){t[o]=Zs(r,i);return}t[o]=i}),t},ae=Zs(Fs),Mt=class{constructor(n,e){this.cursor=-1,this.items=[],this.items=n??[],this.focusedCssClass=e}get currentItem(){return this.cursor===-1?null:this.items[this.cursor]}setCursor(n){n<this.items.length&&n>=-1&&(this.dropCursor(),this.cursor=n,this.items[this.cursor].classList.add(this.focusedCssClass))}setItems(n){this.items=n}hasItems(){return this.items.length>0}next(){this.cursor=this.leafNodesAndReturnIndex(Mt.directions.RIGHT)}previous(){this.cursor=this.leafNodesAndReturnIndex(Mt.directions.LEFT)}dropCursor(){this.cursor!==-1&&(this.items[this.cursor].classList.remove(this.focusedCssClass),this.cursor=-1)}leafNodesAndReturnIndex(n){if(this.items.length===0)return this.cursor;const e=n===Mt.directions.RIGHT?-1:0,t=this.cursor===-1?e:this.cursor;t!==-1&&this.items[t].classList.remove(this.focusedCssClass);const o=n===Mt.directions.RIGHT?(t+1)%this.items.length:(this.items.length+t-1)%this.items.length;return v.canSetCaret(this.items[o])&&gn(()=>w.setCursor(this.items[o]),50)(),this.items[o].classList.add(this.focusedCssClass),o}};let mt=Mt;mt.directions={RIGHT:"right",LEFT:"left"};class Fe{constructor(e){this.iterator=null,this.activated=!1,this.skipNextTabFocus=!1,this.flipCallbacks=[],this.onKeyDown=t=>{const o=t.target;if(this.shouldSkipTarget(o,t))return;const r=this.getKeyCode(t),i=r===S.LEFT||r===S.RIGHT||r===S.UP||r===S.DOWN;if(!(t.shiftKey&&i||!this.isEventReadyForHandling(t)))switch(t.stopPropagation(),t.stopImmediatePropagation(),r!==null&&Fe.usedKeys.includes(r)&&t.preventDefault(),r){case S.TAB:this.handleTabPress(t);break;case S.LEFT:case S.UP:this.flipLeft();break;case S.RIGHT:case S.DOWN:this.flipRight();break;case S.ENTER:this.handleEnterPress(t);break}},this.iterator=new mt(e.items||[],e.focusedItemClass??""),this.activateCallback=e.activateCallback,this.allowedKeys=e.allowedKeys||Fe.usedKeys,this.handleContentEditableTargets=e.handleContentEditableTargets??!1}get isActivated(){return this.activated}static get usedKeys(){return[S.TAB,S.LEFT,S.RIGHT,S.ENTER,S.UP,S.DOWN]}activate(e,t){var o,r;this.activated=!0,e&&((o=this.iterator)==null||o.setItems(e)),t!==void 0&&((r=this.iterator)==null||r.setCursor(t)),document.addEventListener("keydown",this.onKeyDown,!0),window.addEventListener("keydown",this.onKeyDown,!0)}deactivate(){this.activated=!1,this.dropCursor(),this.skipNextTabFocus=!1,document.removeEventListener("keydown",this.onKeyDown,!0),window.removeEventListener("keydown",this.onKeyDown,!0)}focusFirst(){this.dropCursor(),this.flipRight()}focusItem(e){const t=this.iterator;if(t&&t.hasItems()){if(e<0){t.dropCursor();return}!t.currentItem&&e===0&&(this.skipNextTabFocus=!0),t.setCursor(e)}}flipLeft(){var e;(e=this.iterator)==null||e.previous(),this.flipCallback()}flipRight(){var e;(e=this.iterator)==null||e.next(),this.flipCallback()}hasFocus(){var e;return!!((e=this.iterator)!=null&&e.currentItem)}onFlip(e){this.flipCallbacks.push(e)}removeOnFlip(e){this.flipCallbacks=this.flipCallbacks.filter(t=>t!==e)}dropCursor(){var e;(e=this.iterator)==null||e.dropCursor()}getKeyCode(e){return{Tab:S.TAB,Enter:S.ENTER,ArrowLeft:S.LEFT,ArrowRight:S.RIGHT,ArrowUp:S.UP,ArrowDown:S.DOWN}[e.key]??null}isEventReadyForHandling(e){const t=this.getKeyCode(e);return this.activated&&t!==null&&this.allowedKeys.includes(t)}setHandleContentEditableTargets(e){this.handleContentEditableTargets=e}handleTabPress(e){const o=e.shiftKey?mt.directions.LEFT:mt.directions.RIGHT;if(this.skipNextTabFocus){this.skipNextTabFocus=!1;return}switch(o){case mt.directions.RIGHT:this.flipRight();break;case mt.directions.LEFT:this.flipLeft();break}}handleExternalKeydown(e){this.onKeyDown(e)}handleEnterPress(e){var t,o;this.activated&&((t=this.iterator)!=null&&t.currentItem&&(e.stopPropagation(),e.preventDefault(),this.iterator.currentItem.click()),j(this.activateCallback)&&((o=this.iterator)!=null&&o.currentItem)&&this.activateCallback(this.iterator.currentItem))}flipCallback(){var e,t,o;(e=this.iterator)!=null&&e.currentItem&&((o=(t=this.iterator.currentItem).scrollIntoViewIfNeeded)==null||o.call(t)),this.flipCallbacks.forEach(r=>r())}shouldSkipTarget(e,t){var l;if(!e)return!1;const o=e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement,r=((l=e.dataset)==null?void 0:l.flipperTabTarget)==="true"&&t.key==="Tab",i=e.isContentEditable,s=e.closest('[data-link-tool-input-opened="true"]')!==null,a=i&&!this.handleContentEditableTargets;return o&&!r||a||s}}const $E='<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>',FE='<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>',HE='<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>',jE='<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>',zE='<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>',WE='<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>',UE='<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>',KE='<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>',GE='<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>',Js='<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>',YE='<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>',XE='<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>',VE="__",qE="--",He=n=>(e,t)=>[[n,e].filter(r=>!!r).join(VE),t].filter(r=>!!r).join(qE),Dt=He("ce-hint"),$t={root:Dt(),alignedStart:Dt(null,"align-left"),alignedCenter:Dt(null,"align-center"),title:Dt("title"),description:Dt("description")},jw="";class ZE{constructor(e){this.nodes={root:v.make("div",[$t.root,e.alignment==="center"?$t.alignedCenter:$t.alignedStart]),title:v.make("div",$t.title,{textContent:e.title})},this.nodes.root.appendChild(this.nodes.title),e.description!==void 0&&(this.nodes.description=v.make("div",$t.description,{textContent:e.description}),this.nodes.root.appendChild(this.nodes.description))}getElement(){return this.nodes.root}}class $o{constructor(e){this.params=e}get name(){if(this.params!==void 0&&"name"in this.params)return this.params.name}destroy(){Pt()}onChildrenOpen(){var e;this.params!==void 0&&"children"in this.params&&typeof((e=this.params.children)==null?void 0:e.onOpen)=="function"&&this.params.children.onOpen()}onChildrenClose(){var e;this.params!==void 0&&"children"in this.params&&typeof((e=this.params.children)==null?void 0:e.onClose)=="function"&&this.params.children.onClose()}handleClick(){var e,t;this.params!==void 0&&"onActivate"in this.params&&((t=(e=this.params).onActivate)==null||t.call(e,this.params))}addHint(e,t){const o=new ZE(t);yn(e,o.getElement(),{placement:t.position,hidingDelay:100})}get children(){var e;return this.params!==void 0&&"children"in this.params&&((e=this.params.children)==null?void 0:e.items)!==void 0?this.params.children.items:[]}get hasChildren(){return this.children.length>0}get isChildrenOpen(){var e;return this.params!==void 0&&"children"in this.params&&((e=this.params.children)==null?void 0:e.isOpen)===!0}get isChildrenFlippable(){var e;return!(this.params===void 0||!("children"in this.params)||((e=this.params.children)==null?void 0:e.isFlippable)===!1)}get isChildrenSearchable(){var e;return this.params!==void 0&&"children"in this.params&&((e=this.params.children)==null?void 0:e.searchable)===!0}get closeOnActivate(){return this.params!==void 0&&"closeOnActivate"in this.params&&this.params.closeOnActivate}get isActive(){return this.params===void 0||!("isActive"in this.params)?!1:typeof this.params.isActive=="function"?this.params.isActive():this.params.isActive===!0}}const ge=He("ce-popover-item"),G={container:ge(),active:ge(null,"active"),disabled:ge(null,"disabled"),focused:ge(null,"focused"),hidden:ge(null,"hidden"),confirmationState:ge(null,"confirmation"),noHover:ge(null,"no-hover"),noFocus:ge(null,"no-focus"),title:ge("title"),secondaryTitle:ge("secondary-title"),icon:ge("icon"),iconTool:ge("icon","tool"),iconChevronRight:ge("icon","chevron-right"),wobbleAnimation:He("wobble")()},Fo="data-popover-item-active";class je extends $o{constructor(e,t){super(e),this.params=e,this.nodes={root:null,icon:null},this.confirmationState=null,this.removeSpecialFocusBehavior=()=>{var o;(o=this.nodes.root)==null||o.classList.remove(G.noFocus)},this.removeSpecialHoverBehavior=()=>{var o;(o=this.nodes.root)==null||o.classList.remove(G.noHover)},this.onErrorAnimationEnd=()=>{var o,r;(o=this.nodes.icon)==null||o.classList.remove(G.wobbleAnimation),(r=this.nodes.icon)==null||r.removeEventListener("animationend",this.onErrorAnimationEnd)},this.nodes.root=this.make(e,t)}get isDisabled(){return this.params.isDisabled===!0}get toggle(){return this.params.toggle}get title(){return this.params.title||this.params.label}get isConfirmationStateEnabled(){return this.confirmationState!==null}get isFocused(){return this.nodes.root===null?!1:this.nodes.root.classList.contains(G.focused)}getElement(){return this.nodes.root}handleClick(){if(this.isConfirmationStateEnabled&&this.confirmationState!==null){this.activateOrEnableConfirmationMode(this.confirmationState);return}this.activateOrEnableConfirmationMode(this.params)}toggleActive(e){if(this.nodes.root===null)return;const t=e!==void 0?e:!this.nodes.root.classList.contains(G.active);this.nodes.root.classList.toggle(G.active,t),t?this.nodes.root.setAttribute(Fo,"true"):this.nodes.root.removeAttribute(Fo)}toggleHidden(e){var t;(t=this.nodes.root)==null||t.classList.toggle(G.hidden,e)}reset(){this.isConfirmationStateEnabled&&this.disableConfirmationMode()}onFocus(){this.disableSpecialHoverAndFocusBehavior()}make(e,t){var s,a;const o=(t==null?void 0:t.wrapperTag)||"div",r=v.make(o,G.container,{type:o==="button"?"button":void 0});e.name&&(r.dataset.itemName=e.name),this.nodes.icon=v.make("div",[G.icon,G.iconTool],{innerHTML:e.icon||zE}),r.appendChild(this.nodes.icon);const i=e.title||e.label;return i!==void 0&&r.appendChild(v.make("div",G.title,{innerHTML:i||""})),e.secondaryLabel&&r.appendChild(v.make("div",G.secondaryTitle,{textContent:e.secondaryLabel})),this.hasChildren&&r.appendChild(v.make("div",[G.icon,G.iconChevronRight],{innerHTML:HE})),this.isActive&&(r.classList.add(G.active),r.setAttribute(Fo,"true")),e.isDisabled&&r.classList.add(G.disabled),e.hint!==void 0&&((s=t==null?void 0:t.hint)==null?void 0:s.enabled)!==!1&&this.addHint(r,{...e.hint,position:((a=t==null?void 0:t.hint)==null?void 0:a.position)||"right"}),r}enableConfirmationMode(e){if(this.nodes.root===null)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(G.confirmationState),this.confirmationState=e,this.enableSpecialHoverAndFocusBehavior()}disableConfirmationMode(){if(this.nodes.root===null)return;const e=this.make(this.params);this.nodes.root.innerHTML=e.innerHTML,this.nodes.root.classList.remove(G.confirmationState),this.confirmationState=null,this.disableSpecialHoverAndFocusBehavior()}enableSpecialHoverAndFocusBehavior(){var e,t,o;(e=this.nodes.root)==null||e.classList.add(G.noHover),(t=this.nodes.root)==null||t.classList.add(G.noFocus),(o=this.nodes.root)==null||o.addEventListener("mouseleave",this.removeSpecialHoverBehavior,{once:!0})}disableSpecialHoverAndFocusBehavior(){var e;this.removeSpecialFocusBehavior(),this.removeSpecialHoverBehavior(),(e=this.nodes.root)==null||e.removeEventListener("mouseleave",this.removeSpecialHoverBehavior)}activateOrEnableConfirmationMode(e){var t;if(!("confirmation"in e)||e.confirmation===void 0)try{(t=e.onActivate)==null||t.call(e,e),this.disableConfirmationMode()}catch{this.animateError()}else this.enableConfirmationMode(e.confirmation)}animateError(){var e,t,o;(e=this.nodes.icon)!=null&&e.classList.contains(G.wobbleAnimation)||((t=this.nodes.icon)==null||t.classList.add(G.wobbleAnimation),(o=this.nodes.icon)==null||o.addEventListener("animationend",this.onErrorAnimationEnd))}}const Ho=He("ce-popover-item-separator"),jo={container:Ho(),line:Ho("line"),hidden:Ho(null,"hidden")};class Qs extends $o{constructor(){super(),this.nodes={root:v.make("div",jo.container),line:v.make("div",jo.line)},this.nodes.root.appendChild(this.nodes.line)}getElement(){return this.nodes.root}toggleHidden(e){var t;(t=this.nodes.root)==null||t.classList.toggle(jo.hidden,e)}}var Ce=(n=>(n.Closed="closed",n.ClosedOnActivate="closed-on-activate",n))(Ce||{});const de=He("ce-popover"),J={popover:de(),popoverContainer:de("container"),popoverOpenTop:de(null,"open-top"),popoverOpenLeft:de(null,"open-left"),popoverOpened:de(null,"opened"),search:de("search"),nothingFoundMessage:de("nothing-found-message"),nothingFoundMessageDisplayed:de("nothing-found-message","displayed"),items:de("items"),overlay:de("overlay"),overlayHidden:de("overlay","hidden"),popoverNested:de(null,"nested"),getPopoverNestedClass:n=>de(null,`nested-level-${n.toString()}`),popoverInline:de(null,"inline"),popoverHeader:de("header")};var vt=(n=>(n.NestingLevel="--nesting-level",n.PopoverHeight="--popover-height",n.InlinePopoverWidth="--inline-popover-width",n.TriggerItemLeft="--trigger-item-left",n.TriggerItemTop="--trigger-item-top",n))(vt||{});const ea=He("ce-popover-item-html"),ta={root:ea(),hidden:ea(null,"hidden")};class Ft extends $o{constructor(e,t){var o,r;super(e),this.nodes={root:v.make("div",ta.root)},this.nodes.root.appendChild(e.element),e.name&&(this.nodes.root.dataset.itemName=e.name),e.hint!==void 0&&((o=t==null?void 0:t.hint)==null?void 0:o.enabled)!==!1&&this.addHint(this.nodes.root,{...e.hint,position:((r=t==null?void 0:t.hint)==null?void 0:r.position)||"right"})}getElement(){return this.nodes.root}toggleHidden(e){var t;(t=this.nodes.root)==null||t.classList.toggle(ta.hidden,e)}getControls(){const e=this.nodes.root.querySelectorAll(`button, ${v.allInputsSelector}`);return Array.from(e)}}class na extends Nt{constructor(e,t={}){super(),this.params=e,this.itemsRenderParams=t,this.listeners=new Rt,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=v.make("div",[J.popoverContainer]),this.nodes.nothingFoundMessage=v.make("div",[J.nothingFoundMessage],{textContent:this.messages.nothingFound}),this.nodes.popoverContainer.appendChild(this.nodes.nothingFoundMessage),this.nodes.items=v.make("div",[J.items]),this.items.forEach(o=>{const r=o.getElement();r!==null&&this.nodes.items.appendChild(r)}),this.nodes.popoverContainer.appendChild(this.nodes.items),this.listeners.on(this.nodes.popoverContainer,"click",o=>this.handleClick(o)),this.nodes.popover=v.make("div",[J.popover,this.params.class]),this.nodes.popover.appendChild(this.nodes.popoverContainer)}get itemsDefault(){return this.items.filter(e=>e instanceof je)}getElement(){return this.nodes.popover}show(){!this.nodes.popover.isConnected&&!this.nodes.popover.parentNode&&document.body.appendChild(this.nodes.popover),this.nodes.popover.classList.add(J.popoverOpened),this.nodes.popover.setAttribute("data-popover-opened","true"),this.search!==void 0&&this.search.focus()}hide(){this.nodes.popover.classList.remove(J.popoverOpened),this.nodes.popover.classList.remove(J.popoverOpenTop),this.nodes.popover.removeAttribute("data-popover-opened"),this.itemsDefault.forEach(e=>e.reset()),this.search!==void 0&&this.search.clear(),this.emit(Ce.Closed)}destroy(){var e;this.items.forEach(t=>t.destroy()),this.nodes.popover.remove(),this.listeners.removeAll(),(e=this.search)==null||e.destroy()}activateItemByName(e){const t=this.items.find(o=>o.name===e);t!==void 0&&this.handleItemClick(t)}buildItems(e){return e.map(t=>{switch(t.type){case oe.Separator:return new Qs;case oe.Html:return new Ft(t,this.itemsRenderParams[oe.Html]);default:return new je(t,this.itemsRenderParams[oe.Default])}})}getTargetItem(e){return this.items.filter(t=>t instanceof je||t instanceof Ft).find(t=>{const o=t.getElement();return o===null?!1:e.composedPath().includes(o)})}handleItemClick(e){if(!(e instanceof je&&e.isDisabled)){if(e.hasChildren){this.showNestedItems(e),this.callHandleClickIfPresent(e);return}this.itemsDefault.filter(t=>t!==e).forEach(t=>t.reset()),this.callHandleClickIfPresent(e),this.toggleItemActivenessIfNeeded(e),e.closeOnActivate===!0&&(this.hide(),this.emit(Ce.ClosedOnActivate))}}handleClick(e){const t=this.getTargetItem(e);t!==void 0&&this.handleItemClick(t)}toggleItemActivenessIfNeeded(e){if(!(e instanceof je)||(e.toggle===!0&&e.toggleActive(),typeof e.toggle!="string"))return;const t=this.itemsDefault.filter(o=>o.toggle===e.toggle);if(t.length===1){e.toggleActive();return}t.forEach(o=>{o.toggleActive(o===e)})}callHandleClickIfPresent(e){"handleClick"in e&&typeof e.handleClick=="function"&&e.handleClick()}hasNode(e){return this.nodes.popover.contains(e)}}var zo=(n=>(n.Search="search",n))(zo||{});const Wo=He("cdx-search-field"),Uo={wrapper:Wo(),icon:Wo("icon"),input:Wo("input")};class JE extends Nt{constructor({items:e,placeholder:t}){super(),this.searchQuery="",this.handleValueChange=()=>{this.applySearch(this.input.value)},this.listeners=new Rt,this.items=e,this.wrapper=v.make("div",Uo.wrapper);const o=v.make("div",Uo.icon,{innerHTML:YE});this.input=v.make("input",Uo.input,{type:"search",placeholder:t,tabIndex:-1}),this.input.dataset.flipperTabTarget="true",this.wrapper.appendChild(o),this.wrapper.appendChild(this.input),this.overrideValueProperty(),["input","keyup","search","change"].forEach(i=>{this.listeners.on(this.input,i,this.handleValueChange)})}getElement(){return this.wrapper}focus(){this.input.focus()}clear(){this.input.value=""}applySearch(e){this.searchQuery!==e&&(this.searchQuery=e,this.emit(zo.Search,{query:e,items:this.foundItems}))}overrideValueProperty(){const e=Object.getPrototypeOf(this.input),t=Object.getOwnPropertyDescriptor(e,"value");if((t==null?void 0:t.set)===void 0||t.get===void 0)return;const o=this.applySearch.bind(this);Object.defineProperty(this.input,"value",{configurable:t.configurable??!0,enumerable:t.enumerable??!1,get(){var r;return((r=t.get)==null?void 0:r.call(this))??""},set(r){var i;(i=t.set)==null||i.call(this,r),o(r)}})}destroy(){this.listeners.removeAll()}get foundItems(){return this.items.filter(e=>this.checkItem(e))}checkItem(e){var r,i;const t=((r=e.title)==null?void 0:r.toLowerCase())||"",o=(i=this.searchQuery)==null?void 0:i.toLowerCase();return o!==void 0?t.includes(o):!1}}class qe extends na{constructor(e,t){super(e,t),this.nestingLevel=0,this.nestedPopoverTriggerItem=null,this.previouslyHoveredItem=null,this.scopeElement=document.body,this.hide=()=>{var o;super.hide(),this.destroyNestedPopoverIfExists(),(o=this.flipper)==null||o.deactivate(),this.previouslyHoveredItem=null},this.onFlip=()=>{const o=this.itemsDefault.find(r=>r.isFocused);o==null||o.onFocus()},this.onSearch=o=>{var a;const r=o.query==="",i=o.items.length===0;this.items.forEach(l=>{const c=l instanceof je,d=l instanceof Qs||l instanceof Ft,u=c?!o.items.includes(l):d&&(i||!r);l.toggleHidden(u)}),this.toggleNothingFoundMessage(i);const s=o.query===""?this.flippableElements:o.items.map(l=>l.getElement());(a=this.flipper)!=null&&a.isActivated&&(this.flipper.deactivate(),this.flipper.activate(s))},e.trigger&&(this.trigger=e.trigger),e.nestingLevel!==void 0&&(this.nestingLevel=e.nestingLevel),this.nestingLevel>0&&this.nodes.popover.classList.add(J.popoverNested),e.scopeElement!==void 0&&(this.scopeElement=e.scopeElement),this.nodes.popoverContainer!==null&&this.listeners.on(this.nodes.popoverContainer,"mouseover",o=>this.handleHover(o)),e.searchable&&this.addSearch(),e.flippable!==!1&&(e.flipper!==void 0?(e.flipper.deactivate(),e.flipper.removeOnFlip(this.onFlip),this.flipper=e.flipper):this.flipper=new Fe({items:this.flippableElements,focusedItemClass:G.focused,allowedKeys:[S.TAB,S.UP,S.DOWN,S.ENTER]}),this.flipper.onFlip(this.onFlip))}hasFocus(){return this.flipper===void 0?!1:this.flipper.hasFocus()}get scrollTop(){return this.nodes.items===null?0:this.nodes.items.scrollTop}get offsetTop(){return this.nodes.popoverContainer===null?0:this.nodes.popoverContainer.offsetTop}show(){var e;if(this.trigger){document.body.appendChild(this.nodes.popover);const{top:t,left:o}=this.calculatePosition();this.nodes.popover.style.position="absolute",this.nodes.popover.style.top=`${t}px`,this.nodes.popover.style.left=`${o}px`,this.nodes.popover.style.setProperty("--popover-top","0px"),this.nodes.popover.style.setProperty("--popover-left","0px")}this.nodes.popover.style.setProperty(vt.PopoverHeight,this.size.height+"px"),!this.trigger&&!this.shouldOpenBottom&&this.nodes.popover.classList.add(J.popoverOpenTop),!this.trigger&&!this.shouldOpenRight&&this.nodes.popover.classList.add(J.popoverOpenLeft),super.show(),(e=this.flipper)==null||e.activate(this.flippableElements)}calculatePosition(){if(!this.trigger)return{top:0,left:0};const e=this.trigger.getBoundingClientRect(),t=this.size,o=window.innerWidth,r=window.innerHeight,i=8,s=e.bottom+i+window.scrollY,l=e.bottom+i+t.height>r+window.scrollY&&e.top-i-t.height>window.scrollY?e.top-i-t.height+window.scrollY:s,c=e.left+window.scrollX,u=c+t.width>o+window.scrollX?Math.max(0,e.right-t.width+window.scrollX):c;return{top:l,left:u}}destroy(){this.hide(),super.destroy()}hasNode(e){return super.hasNode(e)?!0:this.nestedPopover!==void 0&&this.nestedPopover!==null?this.nestedPopover.hasNode(e):!1}showNestedItems(e){this.nestedPopover!==null&&this.nestedPopover!==void 0||(this.nestedPopoverTriggerItem=e,this.showNestedPopoverForItem(e))}handleHover(e){const t=this.getTargetItem(e);t!==void 0&&this.previouslyHoveredItem!==t&&(this.destroyNestedPopoverIfExists(),this.previouslyHoveredItem=t,t.hasChildren&&this.showNestedPopoverForItem(t))}setTriggerItemPosition(e,t){const o=t.getElement(),r=(o?o.offsetTop:0)-this.scrollTop,i=this.offsetTop+r;e.style.setProperty(vt.TriggerItemTop,i+"px")}destroyNestedPopoverIfExists(){var e,t;this.nestedPopover===void 0||this.nestedPopover===null||(this.nestedPopover.off(Ce.ClosedOnActivate,this.hide),this.nestedPopover.hide(),this.nestedPopover.destroy(),this.nestedPopover.getElement().remove(),this.nestedPopover=null,(e=this.flipper)==null||e.activate(this.flippableElements),requestAnimationFrame(()=>{var o;(o=this.flipper)==null||o.focusFirst()}),(t=this.nestedPopoverTriggerItem)==null||t.onChildrenClose())}showNestedPopoverForItem(e){var o;this.nestedPopover=new qe({searchable:e.isChildrenSearchable,items:e.children,nestingLevel:this.nestingLevel+1,flippable:e.isChildrenFlippable,messages:this.messages}),e.onChildrenOpen(),this.nestedPopover.on(Ce.ClosedOnActivate,this.hide);const t=this.nestedPopover.getElement();return this.nodes.popover.appendChild(t),this.setTriggerItemPosition(t,e),t.style.setProperty(vt.NestingLevel,this.nestedPopover.nestingLevel.toString()),this.nestedPopover.show(),(o=this.flipper)==null||o.deactivate(),this.nestedPopover}get shouldOpenBottom(){if(this.nodes.popover===void 0||this.nodes.popover===null)return!1;const e=this.nodes.popoverContainer.getBoundingClientRect(),t=this.scopeElement.getBoundingClientRect(),o=this.size.height,r=e.top+o,i=e.top-o,s=Math.min(window.innerHeight,t.bottom);return i<t.top||r<=s}get shouldOpenRight(){if(this.nodes.popover===void 0||this.nodes.popover===null)return!1;const e=this.nodes.popover.getBoundingClientRect(),t=this.scopeElement.getBoundingClientRect(),o=this.size.width,r=e.right+o,i=e.left-o,s=Math.min(window.innerWidth,t.right);return i<t.left||r<=s}get size(){var r;if(this._size)return this._size;const e={height:0,width:0};if(this.nodes.popover===null)return e;const t=this.nodes.popover.cloneNode(!0);t.style.visibility="hidden",t.style.position="absolute",t.style.top="-1000px",t.classList.add(J.popoverOpened),(r=t.querySelector("."+J.popoverNested))==null||r.remove(),document.body.appendChild(t);const o=t.querySelector("."+J.popoverContainer);return e.height=o.offsetHeight,e.width=o.offsetWidth,t.remove(),this._size=e,e}get flippableElements(){return this.items.flatMap(t=>{if(!(t instanceof je))return t instanceof Ft?t.getControls():[];if(t.isDisabled)return[];const o=t.getElement();return o?[o]:[]}).filter(t=>t!=null)}addSearch(){this.search=new JE({items:this.itemsDefault,placeholder:this.messages.search}),this.search.on(zo.Search,this.onSearch);const e=this.search.getElement();e.classList.add(J.search),this.nodes.popoverContainer.insertBefore(e,this.nodes.popoverContainer.firstChild)}toggleNothingFoundMessage(e){this.nodes.nothingFoundMessage.classList.toggle(J.nothingFoundMessageDisplayed,e)}}class Ko extends qe{constructor(e){var o;const t=!ut();super({...e,class:J.popoverInline},{[oe.Default]:{wrapperTag:"button",hint:{position:"top",alignment:"center",enabled:t}},[oe.Html]:{hint:{position:"top",alignment:"center",enabled:t}}}),(o=this.flipper)==null||o.setHandleContentEditableTargets(!0),this.items.forEach(r=>{!(r instanceof je)&&!(r instanceof Ft)||r.hasChildren&&r.isChildrenOpen&&this.showNestedItems(r)})}get offsetLeft(){return this.nodes.popoverContainer===null?0:this.nodes.popoverContainer.offsetLeft}show(){var t;super.show();const e=this.nestingLevel===0?(t=this.nodes.popoverContainer)==null?void 0:t.getBoundingClientRect():void 0;if(e!==void 0){const o=`${e.width}px`,r=`${e.height}px`;this.nodes.popover.style.setProperty(vt.InlinePopoverWidth,o),this.nodes.popover.style.width=o,this.nodes.popover.style.height=r}requestAnimationFrame(()=>{var o,r;(o=this.flipper)==null||o.deactivate(),(r=this.flipper)==null||r.activate(this.flippableElements)})}handleHover(){}setTriggerItemPosition(e,t){const o=t.getElement(),r=o?o.offsetLeft:0,i=this.offsetLeft+r;e.style.setProperty(vt.TriggerItemLeft,i+"px")}showNestedItems(e){if(this.nestedPopoverTriggerItem===e){this.destroyNestedPopoverIfExists(),this.nestedPopoverTriggerItem=null;return}super.showNestedItems(e)}showNestedPopoverForItem(e){var i;const t=super.showNestedPopoverForItem(e),o=t.getElement();(i=t.flipper)==null||i.setHandleContentEditableTargets(!0);const r=s=>{var a,l;if(!(s.key!=="Tab"||s.shiftKey)){if(this.nestedPopover!==t){document.removeEventListener("keydown",r,!0);return}s.preventDefault(),s.stopPropagation(),(a=t.flipper)==null||a.activate(t.flippableElements),(l=t.flipper)==null||l.focusFirst(),document.removeEventListener("keydown",r,!0)}};return document.addEventListener("keydown",r,!0),t.on(Ce.Closed,()=>{document.removeEventListener("keydown",r,!0)}),o.classList.add(J.getPopoverNestedClass(t.nestingLevel)),t}handleItemClick(e){var t;e!==this.nestedPopoverTriggerItem&&((t=this.nestedPopoverTriggerItem)==null||t.handleClick(),super.destroyNestedPopoverIfExists()),super.handleItemClick(e)}}const Ht=class{constructor(){this.scrollPosition=null}lock(){wo?this.lockHard():document.body.classList.add(Ht.CSS.scrollLocked)}unlock(){wo?this.unlockHard():document.body.classList.remove(Ht.CSS.scrollLocked)}lockHard(){this.scrollPosition=window.pageYOffset,document.documentElement.style.setProperty("--window-scroll-offset",`${this.scrollPosition}px`),document.body.classList.add(Ht.CSS.scrollLockedHard)}unlockHard(){document.body.classList.remove(Ht.CSS.scrollLockedHard),this.scrollPosition!==null&&window.scrollTo(0,this.scrollPosition),this.scrollPosition=null}};let oa=Ht;oa.CSS={scrollLocked:"ce-scroll-locked",scrollLockedHard:"ce-scroll-locked--hard"};const Go=He("ce-popover-header"),Yo={root:Go(),text:Go("text"),backButton:Go("back-button")};class QE{constructor({text:e,onBackButtonClick:t}){this.listeners=new Rt,this.text=e,this.onBackButtonClick=t,this.nodes={root:v.make("div",[Yo.root]),backButton:v.make("button",[Yo.backButton]),text:v.make("div",[Yo.text])},this.nodes.backButton.innerHTML=FE,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 eT{constructor(){this.history=[]}push(e){this.history.push(e)}pop(){return this.history.pop()}get currentTitle(){return this.history.length===0?"":this.history[this.history.length-1].title}get currentItems(){return this.history.length===0?[]:this.history[this.history.length-1].items}reset(){for(;this.history.length>1;)this.pop()}}class ra extends na{constructor(e){super(e,{[oe.Default]:{hint:{enabled:!1}},[oe.Html]:{hint:{enabled:!1}}}),this.scrollLocker=new oa,this.history=new eT,this.isHidden=!0,this.nodes.overlay=v.make("div",[J.overlay,J.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(J.overlayHidden),super.show(),this.scrollLocker.lock(),this.isHidden=!1}hide(){this.isHidden||(super.hide(),this.nodes.overlay.classList.add(J.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){var i;this.header!==null&&this.header!==void 0&&(this.header.destroy(),this.header=null);const o=t!==void 0;o&&(this.header=new QE({text:t,onBackButtonClick:()=>{this.history.pop(),this.updateItemsAndHeader(this.history.currentItems,this.history.currentTitle)}}));const r=((i=this.header)==null?void 0:i.getElement())??null;o&&r!==null&&this.nodes.popoverContainer.insertBefore(r,this.nodes.popoverContainer.firstChild),this.items.forEach(s=>{var a;return(a=s.getElement())==null?void 0:a.remove()}),this.items=this.buildItems(e),this.items.forEach(s=>{var l;const a=s.getElement();a!==null&&((l=this.nodes.items)==null||l.appendChild(a))})}}class tT extends F{constructor(){super(...arguments),this.opened=!1,this.selection=new w,this.popover=null,this.flipperInstance=new Fe({focusedItemClass:G.focused,allowedKeys:[S.TAB,S.UP,S.DOWN,S.ENTER]}),this.flipperKeydownHandler=null,this.flipperKeydownSource=null,this.close=()=>{this.opened&&(this.opened=!1,w.isAtEditor||this.selection.restore(),this.selection.clearSaved(),this.detachFlipperKeydownListener(),!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(Ce.Closed,this.onPopoverClose),this.popover.destroy(),this.popover.getElement().remove(),this.popover=null))},this.onPopoverClose=()=>{this.close()}}get events(){return{opened:xo,closed:Bo}}get CSS(){return{settings:"ce-settings"}}get flipper(){return this.flipperInstance}make(){this.nodes.wrapper=v.make("div",[this.CSS.settings]),this.eventsDispatcher.on(Lt,this.close)}destroy(){this.detachFlipperKeydownListener(),this.removeAllNodes(),this.listeners.destroy(),this.eventsDispatcher.off(Lt,this.close)}async open(e,t){const o=e??this.Editor.BlockManager.currentBlock;if(o===void 0)return;this.opened=!0,this.selection.save(),this.Editor.BlockSelection.selectBlock(o),this.Editor.BlockSelection.clearCache();const{toolTunes:r,commonTunes:i}=o.getTunes();this.eventsDispatcher.emit(this.events.opened);const s=ut()?ra:qe,a={searchable:!0,trigger:t||this.nodes.wrapper,items:await this.getTunesItems(o,i,r),scopeElement:this.Editor.API.methods.ui.nodes.redactor,messages:{nothingFound:ne.ui(ae.ui.popover,"Nothing found"),search:ne.ui(ae.ui.popover,"Filter")}};s===qe&&(a.flipper=this.flipperInstance),this.popover=new s(a),this.popover.on(Ce.Closed,this.onPopoverClose),this.popover.show(),s===qe&&this.flipperInstance.focusItem(0),this.attachFlipperKeydownListener(o)}getElement(){return this.nodes.wrapper}contains(e){var t,o;return!!((t=this.nodes.wrapper)!=null&&t.contains(e)||(o=this.popover)!=null&&o.hasNode(e))}async getTunesItems(e,t,o){const r=[];o!==void 0&&o.length>0&&(r.push(...o),r.push({type:oe.Separator}));const i=Array.from(this.Editor.Tools.blockTools.values()),a=(await Us(e,i)).reduce((l,c)=>(c.toolbox===void 0||c.toolbox.forEach(d=>{const u=d.title??c.name;l.push({icon:d.icon,title:ne.t(ae.toolNames,u),name:c.name,closeOnActivate:!0,onActivate:async()=>{const{BlockManager:h,Caret:g,Toolbar:f}=this.Editor,m=await h.convert(e,c.name,d.data);f.close(),g.setToBlock(m,g.positions.END)}})}),l),[]);return a.length>0&&(r.push({icon:Js,name:"convert-to",title:ne.ui(ae.ui.popover,"Convert to"),children:{searchable:!0,items:a}}),r.push({type:oe.Separator})),r.push(...t),r}attachFlipperKeydownListener(e){this.detachFlipperKeydownListener();const t=e==null?void 0:e.pluginsContent;t instanceof HTMLElement&&(this.flipperInstance.setHandleContentEditableTargets(!0),this.flipperKeydownHandler=o=>{this.flipperInstance.handleExternalKeydown(o)},t.addEventListener("keydown",this.flipperKeydownHandler,!0),this.flipperKeydownSource=t)}detachFlipperKeydownListener(){this.flipperKeydownSource!==null&&this.flipperKeydownHandler!==null&&this.flipperKeydownSource.removeEventListener("keydown",this.flipperKeydownHandler,!0),this.flipperInstance.setHandleContentEditableTargets(!1),this.flipperKeydownSource=null,this.flipperKeydownHandler=null}}var Xo={},nT={get exports(){return Xo},set exports(n){Xo=n}};/*!
19
+ * Library for handling keyboard shortcuts
20
+ * @copyright CodeX (https://codex.so)
21
+ * @license MIT
22
+ * @author CodeX (https://codex.so)
23
+ * @version 1.1.1
24
+ */(function(n,e){(function(t,o){n.exports=o()})(window,function(){return function(t){var o={};function r(i){if(o[i])return o[i].exports;var s=o[i]={i,l:!1,exports:{}};return t[i].call(s.exports,s,s.exports,r),s.l=!0,s.exports}return r.m=t,r.c=o,r.d=function(i,s,a){r.o(i,s)||Object.defineProperty(i,s,{enumerable:!0,get:a})},r.r=function(i){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(i,"__esModule",{value:!0})},r.t=function(i,s){if(1&s&&(i=r(i)),8&s||4&s&&typeof i=="object"&&i&&i.__esModule)return i;var a=Object.create(null);if(r.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:i}),2&s&&typeof i!="string")for(var l in i)r.d(a,l,function(c){return i[c]}.bind(null,l));return a},r.n=function(i){var s=i&&i.__esModule?function(){return i.default}:function(){return i};return r.d(s,"a",s),s},r.o=function(i,s){return Object.prototype.hasOwnProperty.call(i,s)},r.p="",r(r.s=0)}([function(t,o,r){function i(l,c){for(var d=0;d<c.length;d++){var u=c[d];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(l,u.key,u)}}function s(l,c,d){return c&&i(l.prototype,c),d&&i(l,d),l}r.r(o);var a=function(){function l(c){var d=this;(function(u,h){if(!(u instanceof h))throw new TypeError("Cannot call a class as a function")})(this,l),this.commands={},this.keys={},this.name=c.name,this.parseShortcutName(c.name),this.element=c.on,this.callback=c.callback,this.executeShortcut=function(u){d.execute(u)},this.element.addEventListener("keydown",this.executeShortcut,!1)}return s(l,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}}}]),s(l,[{key:"parseShortcutName",value:function(c){c=c.split("+");for(var d=0;d<c.length;d++){c[d]=c[d].toUpperCase();var u=!1;for(var h in l.supportedCommands)if(l.supportedCommands[h].includes(c[d])){u=this.commands[h]=!0;break}u||(this.keys[c[d]]=!0)}for(var g in l.supportedCommands)this.commands[g]||(this.commands[g]=!1)}},{key:"execute",value:function(c){var d,u={CMD:c.ctrlKey||c.metaKey,SHIFT:c.shiftKey,ALT:c.altKey},h=!0;for(d in this.commands)this.commands[d]!==u[d]&&(h=!1);var g,f=!0;for(g in this.keys)f=f&&c.keyCode===l.keyCodes[g];h&&f&&this.callback(c)}},{key:"remove",value:function(){this.element.removeEventListener("keydown",this.executeShortcut)}}]),l}();o.default=a}]).default})})(nT);const oT=li(Xo);class rT{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 o=new oT({name:e.name,on:e.on,callback:e.handler}),r=this.registeredShortcuts.get(e.on)||[];this.registeredShortcuts.set(e.on,[...r,o])}remove(e,t){const o=this.findShortcut(e,t);if(!o)return;o.remove();const r=this.registeredShortcuts.get(e);if(!r)return;const i=r.filter(s=>s!==o);if(i.length===0){this.registeredShortcuts.delete(e);return}this.registeredShortcuts.set(e,i)}findShortcut(e,t){return(this.registeredShortcuts.get(e)||[]).find(({name:r})=>r===t)}}const bt=new rT;var En=(n=>(n.Opened="toolbox-opened",n.Closed="toolbox-closed",n.BlockAdded="toolbox-block-added",n))(En||{});class Vo extends Nt{constructor({api:e,tools:t,i18nLabels:o,triggerElement:r}){super(),this.opened=!1,this.listeners=new Rt,this.popover=null,this.handleMobileLayoutToggle=()=>{this.destroyPopover(),this.initPopover()},this.onPopoverClose=()=>{this.opened=!1,this.emit("toolbox-closed")},this.api=e,this.tools=t,this.i18nLabels=o,this.triggerElement=r,this.enableShortcuts(),this.nodes={toolbox:v.make("div",Vo.CSS.toolbox)},this.initPopover(),this.api.events.on(Lt,this.handleMobileLayoutToggle)}get isEmpty(){return this.toolsToBeDisplayed.length===0}static get CSS(){return{toolbox:"ce-toolbox"}}getElement(){return this.nodes.toolbox}contains(e){var t;return!!(this.nodes.toolbox.contains(e)||(t=this.popover)!=null&&t.getElement().contains(e))}hasFocus(){if(this.popover!==null)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(),(e=this.popover)==null||e.off(Ce.Closed,this.onPopoverClose),this.listeners.destroy(),this.api.events.off(Lt,this.handleMobileLayoutToggle)}async toolButtonActivated(e,t){await this.insertNewBlock(e,t)}open(){var e;this.isEmpty||((e=this.popover)==null||e.show(),this.opened=!0,this.emit("toolbox-opened"))}close(){var e;(e=this.popover)==null||e.hide(),this.opened=!1,this.emit("toolbox-closed")}toggle(){this.opened?this.close():this.open()}initPopover(){const e=ut()?ra:qe;this.popover=new e({scopeElement:this.api.ui.nodes.redactor,trigger:this.triggerElement||this.nodes.toolbox,searchable:!0,messages:{nothingFound:this.i18nLabels.nothingFound,search:this.i18nLabels.filter},items:this.toolboxItemsToBeDisplayed}),this.popover.on(Ce.Closed,this.onPopoverClose)}destroyPopover(){this.popover!==null&&(this.popover.hide(),this.popover.off(Ce.Closed,this.onPopoverClose),this.popover.destroy(),this.popover=null),this.nodes.toolbox!==null&&(this.nodes.toolbox.innerHTML="")}get toolsToBeDisplayed(){if(this._toolsToBeDisplayed)return this._toolsToBeDisplayed;const e=[];return this.tools.forEach(t=>{t.toolbox&&e.push(t)}),this._toolsToBeDisplayed=e,e}get toolboxItemsToBeDisplayed(){if(this._toolboxItemsToBeDisplayed)return this._toolboxItemsToBeDisplayed;const e=(o,r,i=!0)=>({icon:o.icon,title:ne.t(ae.toolNames,o.title||mn(r.name)),name:r.name,onActivate:()=>{this.toolButtonActivated(r.name,o.data)},secondaryLabel:r.shortcut&&i?ko(r.shortcut):""}),t=this.toolsToBeDisplayed.reduce((o,r)=>{const{toolbox:i}=r;return i===void 0||(Array.isArray(i)?i:[i]).forEach((a,l)=>{o.push(e(a,r,l===0))}),o},[]);return this._toolboxItemsToBeDisplayed=t,t}enableShortcuts(){this.toolsToBeDisplayed.forEach(e=>{const t=e.shortcut;t&&this.enableShortcutForTool(e.name,t)})}enableShortcutForTool(e,t){bt.add({name:t,on:this.api.ui.nodes.redactor,handler:async o=>{o.preventDefault();const r=this.api.blocks.getCurrentBlockIndex(),i=this.api.blocks.getBlockByIndex(r);if(i)try{const s=await this.api.blocks.convert(i.id,e);this.api.caret.setToBlock(s,"end");return}catch{}await this.insertNewBlock(e)}})}removeAllShortcuts(){this.toolsToBeDisplayed.forEach(e=>{const t=e.shortcut;t&&bt.remove(this.api.ui.nodes.redactor,t)})}async insertNewBlock(e,t){const o=this.api.blocks.getCurrentBlockIndex(),r=this.api.blocks.getBlockByIndex(o);if(!r)return;const i=r.isEmpty?o:o+1,a=t!==void 0&&Object.keys(t).length>0?Object.assign(await this.api.blocks.composeBlockData(e),t):void 0,l=this.api.blocks.insert(e,a,void 0,i,void 0,r.isEmpty);this.api.caret.setToBlock(i),this.emit("toolbox-block-added",{block:l}),this.api.toolbar.close()}}const ia="block hovered",iT=async(n,e)=>{const t=navigator.keyboard;if(!t)return e;try{return(await t.getLayoutMap()).get(n)||e}catch(o){return console.error(o),e}};class sT extends F{constructor({config:e,eventsDispatcher:t}){super({config:e,eventsDispatcher:t}),this.hoveredBlock=null,this.toolboxInstance=null,this.onBlockSettingsOpen=()=>{var o;(o=this.nodes.settingsToggler)==null||o.classList.add(this.CSS.settingsTogglerOpened)},this.onBlockSettingsClose=()=>{var o;(o=this.nodes.settingsToggler)==null||o.classList.remove(this.CSS.settingsTogglerOpened)}}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",settingsTogglerOpened:"ce-toolbar__settings-btn--opened"}}get opened(){var e;return((e=this.nodes.wrapper)==null?void 0:e.classList.contains(this.CSS.toolbarOpened))??!1}contains(e){var t,o;return!!((t=this.nodes.wrapper)!=null&&t.contains(e)||(o=this.toolboxInstance)!=null&&o.contains(e)||this.Editor.BlockSettings.contains(e))}get toolbox(){var e;return{opened:(e=this.toolboxInstance)==null?void 0:e.opened,close:()=>{var t;(t=this.toolboxInstance)==null||t.close()},open:()=>{if(this.toolboxInstance===null){$("toolbox.open() called before initialization is finished","warn");return}this.hoveredBlock&&(this.Editor.BlockManager.currentBlock=this.hoveredBlock),this.toolboxInstance.open()},toggle:()=>{if(this.toolboxInstance===null){$("toolbox.toggle() called before initialization is finished","warn");return}this.toolboxInstance.toggle()},hasFocus:()=>{var t;return(t=this.toolboxInstance)==null?void 0:t.hasFocus()}}}get blockActions(){return{hide:()=>{var e;(e=this.nodes.actions)==null||e.classList.remove(this.CSS.actionsOpened)},show:()=>{var e;(e=this.nodes.actions)==null||e.classList.add(this.CSS.actionsOpened)}}}get blockTunesToggler(){return{hide:()=>{var e;return(e=this.nodes.settingsToggler)==null?void 0:e.classList.add(this.CSS.settingsTogglerHidden)},show:()=>{var e;return(e=this.nodes.settingsToggler)==null?void 0:e.classList.remove(this.CSS.settingsTogglerHidden)}}}toggleReadOnly(e){e?(this.destroy(),this.Editor.BlockSettings.destroy(),this.disableModuleBindings()):window.requestIdleCallback(async()=>{await this.drawUI(),this.enableModuleBindings()},{timeout:2e3})}moveAndOpen(e){if(this.toolboxInstance===null){$("Can't open Toolbar since Editor initialization is not finished yet","warn");return}this.toolboxInstance.opened&&this.toolboxInstance.close(),this.Editor.BlockSettings.opened&&this.Editor.BlockSettings.close();const t=e??this.Editor.BlockManager.currentBlock;if(!t)return;this.hoveredBlock=t;const{wrapper:o,plusButton:r}=this.nodes;if(!o||!r)return;const i=t.holder,{isMobile:s}=this.Editor.UI,a=20,l=t.firstInput,c=i.getBoundingClientRect(),d=l!==void 0?l.getBoundingClientRect():null,u=d!==null?d.top-c.top:null,h=(()=>{if(s)return i.offsetHeight;const m=parseInt(window.getComputedStyle(t.pluginsContent).paddingTop,10);if(l===void 0||u===null||u>a)return m;const b=zy(l),E=parseInt(window.getComputedStyle(r).height,10),k=8;return b-E+k+u})();o.style.top=`${Math.floor(h)}px`,i.appendChild(o);const g=t.getTunes(),f=g.toolTunes.length>0||g.commonTunes.length>0;this.Editor.BlockManager.blocks.length===1&&t.isEmpty&&!f?this.blockTunesToggler.hide():this.blockTunesToggler.show(),this.open()}close(){var e,t;this.Editor.ReadOnly.isEnabled||((e=this.nodes.wrapper)==null||e.classList.remove(this.CSS.toolbarOpened),this.blockActions.hide(),(t=this.toolboxInstance)==null||t.close(),this.Editor.BlockSettings.close(),this.reset())}reset(){this.nodes.wrapper&&(this.nodes.wrapper.style.top="unset",this.Editor.UI.nodes.wrapper.appendChild(this.nodes.wrapper))}open(e=!0){var t;(t=this.nodes.wrapper)==null||t.classList.add(this.CSS.toolbarOpened),e?this.blockActions.show():this.blockActions.hide()}async make(){const e=v.make("div",this.CSS.toolbar);this.nodes.wrapper=e;const t=v.make("div",this.CSS.content),o=v.make("div",this.CSS.actions);this.nodes.content=t,this.nodes.actions=o,v.append(e,t),v.append(t,o);const r=v.make("div",this.CSS.plusButton,{innerHTML:GE});this.nodes.plusButton=r,v.append(o,r),this.readOnlyMutableListeners.on(r,"click",()=>{Pt(!0),this.plusButtonClicked()},!1);const i=v.make("div");i.appendChild(document.createTextNode(ne.ui(ae.ui.toolbar.toolbox,"Add"))),i.appendChild(v.make("div",this.CSS.plusButtonShortcut,{textContent:"/"})),yn(r,i,{hidingDelay:400});const s=v.make("span",this.CSS.settingsToggler,{innerHTML:KE});this.nodes.settingsToggler=s,v.append(o,s);const a=v.make("div"),l=v.text(ne.ui(ae.ui.blockTunes.toggler,"Click to tune")),c=await iT("Slash","/");a.appendChild(l),a.appendChild(v.make("div",this.CSS.plusButtonShortcut,{textContent:ko(`CMD + ${c}`)})),yn(s,a,{hidingDelay:400}),v.append(o,this.makeToolbox());const d=this.Editor.BlockSettings.getElement();if(!d)throw new Error("Block Settings element was not created");v.append(o,d),v.append(this.Editor.UI.nodes.wrapper,e)}makeToolbox(){this.toolboxInstance=new Vo({api:this.Editor.API.methods,tools:this.Editor.Tools.blockTools,i18nLabels:{filter:ne.ui(ae.ui.popover,"Filter"),nothingFound:ne.ui(ae.ui.popover,"Nothing found")},triggerElement:this.nodes.plusButton}),this.toolboxInstance.on(En.Opened,()=>{this.Editor.UI.nodes.wrapper.classList.add(this.CSS.openedToolboxHolderModifier)}),this.toolboxInstance.on(En.Closed,()=>{this.Editor.UI.nodes.wrapper.classList.remove(this.CSS.openedToolboxHolderModifier)}),this.toolboxInstance.on(En.BlockAdded,({block:t})=>{const{BlockManager:o,Caret:r}=this.Editor,i=o.getBlockById(t.id);if(!i||i.inputs.length!==0)return;if(i===o.lastBlock){o.insertAtEnd(),r.setToBlock(o.lastBlock);return}const s=o.nextBlock;s&&r.setToBlock(s)});const e=this.toolboxInstance.getElement();if(e===null)throw new Error("Toolbox element was not created");return e}plusButtonClicked(){var e;this.hoveredBlock&&(this.Editor.BlockManager.currentBlock=this.hoveredBlock),(e=this.toolboxInstance)==null||e.toggle()}enableModuleBindings(){const e=this.nodes.settingsToggler;e&&(this.readOnlyMutableListeners.on(e,"mousedown",t=>{t.stopPropagation(),Pt(!0)},!0),this.readOnlyMutableListeners.on(e,"click",t=>{var o;t.stopPropagation(),this.settingsTogglerClicked(),(o=this.toolboxInstance)!=null&&o.opened&&this.toolboxInstance.close()},!0)),ut()||this.eventsDispatcher.on(ia,t=>{var r;const o=t.block;o instanceof re&&(this.Editor.BlockSettings.opened||(r=this.toolboxInstance)!=null&&r.opened||this.moveAndOpen(o))}),this.eventsDispatcher.on(xo,this.onBlockSettingsOpen),this.eventsDispatcher.on(Bo,this.onBlockSettingsClose)}disableModuleBindings(){this.readOnlyMutableListeners.clearAll(),this.eventsDispatcher.off(xo,this.onBlockSettingsOpen),this.eventsDispatcher.off(Bo,this.onBlockSettingsClose)}settingsTogglerClicked(){const e=this.hoveredBlock;e&&(this.Editor.BlockManager.currentBlock=e,this.Editor.BlockSettings.opened?this.Editor.BlockSettings.close():this.Editor.BlockSettings.open(e,this.nodes.settingsToggler))}async drawUI(){this.Editor.BlockSettings.make(),await this.make()}destroy(){this.removeAllNodes(),this.toolboxInstance&&this.toolboxInstance.destroy()}}var Ze=(n=>(n[n.Block=0]="Block",n[n.Inline=1]="Inline",n[n.Tune=2]="Tune",n))(Ze||{}),Tn=(n=>(n.Shortcut="shortcut",n.Toolbox="toolbox",n.EnabledInlineTools="inlineToolbar",n.EnabledBlockTunes="tunes",n.Config="config",n))(Tn||{}),sa=(n=>(n.Shortcut="shortcut",n.SanitizeConfig="sanitize",n))(sa||{}),yt=(n=>(n.IsEnabledLineBreaks="enableLineBreaks",n.Toolbox="toolbox",n.ConversionConfig="conversionConfig",n.IsReadOnlySupported="isReadOnlySupported",n.PasteConfig="pasteConfig",n))(yt||{}),aa=(n=>(n.IsInline="isInline",n.Title="title",n.IsReadOnlySupported="isReadOnlySupported",n))(aa||{}),qo=(n=>(n.IsTune="isTune",n))(qo||{});class Zo{constructor({name:e,constructable:t,config:o,api:r,isDefault:i,isInternal:s=!1,defaultPlaceholder:a}){this.api=r,this.name=e,this.constructable=t,this.config=o,this.isDefault=i,this.isInternal=s,this.defaultPlaceholder=a}get settings(){const e=this.config.config??{};return this.isDefault&&!("placeholder"in e)&&this.defaultPlaceholder&&(e.placeholder=this.defaultPlaceholder),e}reset(){if(j(this.constructable.reset))return this.constructable.reset()}prepare(){const e=this.constructable.prepare;if(!j(e))return;const t={toolName:this.name,config:this.settings};return e.call(this.constructable,t)}get shortcut(){const e=this.constructable.shortcut;return this.config.shortcut||e}get sanitizeConfig(){return this.constructable.sanitize||{}}isInline(){return this.type===Ze.Inline}isBlock(){return this.type===Ze.Block}isTune(){return this.type===Ze.Tune}}class aT extends F{constructor({config:e,eventsDispatcher:t}){super({config:e,eventsDispatcher:t}),this.CSS={inlineToolbar:"ce-inline-toolbar"},this.opened=!1,this.popover=null,this.toolbarVerticalMargin=ut()?20:6,this.initialized=!1,this.initializationScheduled=!1,this.tools=new Map,this.registeredShortcuts=new Map,this.shortcutsRegistered=!1,this.shortcutRegistrationScheduled=!1,this.listeners.on(document,"keydown",o=>{const r=o;r.shiftKey&&(r.key==="ArrowDown"||r.key==="ArrowUp")&&this.tryToShow()},!0),this.scheduleInitialization(),this.tryRegisterShortcuts()}set state(e){super.state=e,this.tryRegisterShortcuts()}initialize(){var e,t,o;if(!this.initialized){if(!((o=(t=(e=this.Editor)==null?void 0:e.UI)==null?void 0:t.nodes)!=null&&o.wrapper)||this.Editor.Tools===void 0){this.scheduleInitialization();return}this.make(),this.tryRegisterShortcuts(),this.initialized=!0}}tryRegisterShortcuts(){var t;if(this.shortcutsRegistered)return;if(((t=this.Editor)==null?void 0:t.Tools)===void 0){this.scheduleShortcutRegistration();return}this.registerInitialShortcuts()&&(this.shortcutsRegistered=!0)}scheduleShortcutRegistration(){if(this.shortcutsRegistered||this.shortcutRegistrationScheduled)return;this.shortcutRegistrationScheduled=!0;const e=()=>{this.shortcutRegistrationScheduled=!1,this.tryRegisterShortcuts()};typeof window<"u"&&typeof window.setTimeout=="function"?window.setTimeout(e,0):e()}scheduleInitialization(){if(this.initialized||this.initializationScheduled)return;this.initializationScheduled=!0;const e=()=>{this.initializationScheduled=!1,this.initialize()},t=()=>{window.setTimeout(e,0)};typeof window<"u"&&"requestIdleCallback"in window?window.requestIdleCallback(()=>{t()},{timeout:2e3}):t()}async tryToShow(e=!1){e&&this.close(),this.initialize(),this.allowedToShow()&&(await this.open(),this.Editor.Toolbar.close())}close(){var r,i,s,a,l,c;if(!this.opened)return;for(const d of this.tools.values());this.tools=new Map,this.reset(),this.opened=!1;const e=this.popover??this.createFallbackPopover();(r=e==null?void 0:e.hide)==null||r.call(e),(i=e==null?void 0:e.destroy)==null||i.call(e);const t=Ko.mock,o=(a=(s=t==null?void 0:t.results)==null?void 0:s.at(-1))==null?void 0:a.value;o&&o!==e&&((l=o.hide)==null||l.call(o),(c=o.destroy)==null||c.call(o)),this.popover=null}containsNode(e){return this.nodes.wrapper===void 0?!1:this.nodes.wrapper.contains(e)}destroy(){var e;this.removeAllNodes(),(e=this.popover)==null||e.destroy(),this.popover=null}make(){this.nodes.wrapper=v.make("div",[this.CSS.inlineToolbar,...this.isRtl?[this.Editor.UI.CSS.editorRtlFix]:[]]),this.nodes.wrapper.setAttribute(pt,SE),this.nodes.wrapper.setAttribute("data-cy","inline-toolbar"),v.append(this.Editor.UI.nodes.wrapper,this.nodes.wrapper)}async open(){var r,i,s,a,l,c,d,u,h,g;if(this.opened)return;this.initialize(),this.opened=!0,this.popover!==null&&this.popover.destroy(),this.createToolsInstances();const e=await this.getPopoverItems();this.popover=new Ko({items:e,scopeElement:((a=(s=(i=(r=this.Editor.API)==null?void 0:r.methods)==null?void 0:i.ui)==null?void 0:s.nodes)==null?void 0:a.redactor)??this.Editor.UI.nodes.redactor,messages:{nothingFound:ne.ui(ae.ui.popover,"Nothing found"),search:ne.ui(ae.ui.popover,"Filter")}});const t=(c=(l=this.popover).getElement)==null?void 0:c.call(l),o=((d=this.popover.size)==null?void 0:d.width)??(t==null?void 0:t.getBoundingClientRect().width)??0;this.move(o),t&&((u=this.nodes.wrapper)==null||u.append(t)),(g=(h=this.popover).show)==null||g.call(h)}move(e){const t=w.rect,o=this.Editor.UI.nodes.wrapper.getBoundingClientRect(),r={x:t.x-o.x,y:t.y+t.height-o.top+this.toolbarVerticalMargin};r.x+e+o.x>this.Editor.UI.contentRect.right&&(r.x=this.Editor.UI.contentRect.right-e-o.x),this.nodes.wrapper.style.left=Math.floor(r.x)+"px",this.nodes.wrapper.style.top=Math.floor(r.y)+"px"}reset(){this.nodes.wrapper!==void 0&&(this.nodes.wrapper.style.left="0",this.nodes.wrapper.style.top="0")}allowedToShow(){const e=["IMG","INPUT"],t=this.resolveSelection(),o=w.text;if(!t||!t.anchorNode||t.isCollapsed||o.length<1)return!1;const r=v.isElement(t.anchorNode)?t.anchorNode:t.anchorNode.parentElement;if(r===null||t!==null&&e.includes(r.tagName))return!1;const i=v.isElement(t.anchorNode)?t.anchorNode:t.anchorNode.parentElement,a=(i?this.Editor.BlockManager.getBlock(i):null)??this.Editor.BlockManager.currentBlock;if(a==null||this.getTools().some(f=>a.tool.inlineTools.has(f.name))===!1)return!1;const d="[contenteditable]";if(r.closest(d)!==null)return!0;const h=a.holder;return h&&(h.matches(d)?h:h.closest(d))?!0:this.Editor.ReadOnly.isEnabled?w.isSelectionAtEditor(t):!1}getTools(){const e=this.Editor.BlockManager.currentBlock??(()=>{const o=this.resolveSelection(),r=o==null?void 0:o.anchorNode;if(!r)return null;const i=v.isElement(r)?r:r.parentElement;return i?this.Editor.BlockManager.getBlock(i):null})();return e?Array.from(e.tool.inlineTools.values()).filter(o=>!(this.Editor.ReadOnly.isEnabled&&o.isReadOnlySupported!==!0)):[]}createToolsInstances(){this.tools=new Map,this.getTools().forEach(t=>{const o=t.create();this.tools.set(t,o)})}async getPopoverItems(){const e=[],t=Array.from(this.tools.entries());for(const[o,[r,i]]of t.entries()){const s=await i.render(),a=this.getToolShortcut(r.name);this.tryEnableShortcut(r.name,a);const l=a!==void 0?ko(a):void 0,c=ne.t(ae.toolNames,r.title||mn(r.name));[s].flat().forEach(d=>{this.processPopoverItem(d,r.name,i,c,l,e,o)})}return e}tryEnableShortcut(e,t){if(t!==void 0)try{this.enableShortcuts(e,t)}catch{}}processPopoverItem(e,t,o,r,i,s,a){const l={name:t,hint:{title:r,description:i}};if(!v.isElement(e)){if(e.type===oe.Html){s.push({...l,...e,type:oe.Html});return}if(e.type===oe.Separator){s.push({type:oe.Separator});return}this.processDefaultItem(e,l,s,a)}}processDefaultItem(e,t,o,r){const i={...t,...e,type:oe.Default};"children"in i&&r!==0&&o.push({type:oe.Separator}),o.push(i)}getToolShortcut(e){const{Tools:t}=this.Editor,o=t.inlineTools.get(e),r=t.internal.inlineTools;return Array.from(r.keys()).includes(e)?this.inlineTools[e][sa.Shortcut]:o==null?void 0:o.shortcut}enableShortcuts(e,t){const o=this.registeredShortcuts.get(e);o!==t&&(this.isShortcutTakenByAnotherTool(e,t)||(o!==void 0&&(bt.remove(document,o),this.registeredShortcuts.delete(e)),bt.add({name:t,handler:r=>{const{currentBlock:i}=this.Editor.BlockManager;i&&i.tool.enabledInlineTools!==!1&&(r.preventDefault(),this.activateToolByShortcut(e))},on:document}),this.registeredShortcuts.set(e,t)))}isShortcutTakenByAnotherTool(e,t){return Array.from(this.registeredShortcuts.entries()).some(([o,r])=>o!==e&&r===t)}async activateToolByShortcut(e){var o,r;if(this.opened||await this.tryToShow(),!w.get()){(o=this.popover)==null||o.activateItemByName(e);return}(r=this.popover)==null||r.activateItemByName(e)}get inlineTools(){const e={};return Array.from(this.Editor.Tools.inlineTools.entries()).forEach(([t,o])=>{e[t]=o.create()}),e}registerInitialShortcuts(){var o;const e=(o=this.Editor.Tools)==null?void 0:o.inlineTools;return e?(Array.from(e.keys()).forEach(r=>{const i=this.getToolShortcut(r);this.tryEnableShortcut(r,i)}),!0):(this.scheduleShortcutRegistration(),!1)}createFallbackPopover(){var e,t,o,r;try{const i=((r=(o=(t=(e=this.Editor.API)==null?void 0:e.methods)==null?void 0:t.ui)==null?void 0:o.nodes)==null?void 0:r.redactor)??this.Editor.UI.nodes.redactor;return new Ko({items:[],scopeElement:i,messages:{nothingFound:ne.ui(ae.ui.popover,"Nothing found"),search:ne.ui(ae.ui.popover,"Filter")}})}catch{return null}}resolveSelection(){const e=w.selection;if(e!==void 0)return e;const t=w.instance;return t!==void 0?t:w.get()}}const Jo=" ",Qo=new WeakSet,er=()=>{const n=window.getSelection();if(n===null)return[null,0];const e=n.focusNode,t=n.focusOffset;if(e===null)return[null,0];if(e.nodeType===Node.TEXT_NODE||e.childNodes.length===0)return[e,t];const o=e.childNodes[t];if(o!==void 0)return[o,0];const r=e.childNodes[t-1]??null,i=(r==null?void 0:r.textContent)??null;return[r,i!==null?i.length:0]},la=n=>{if(!(n instanceof HTMLElement)||v.isSingleTag(n)||v.isNativeInput(n))return!1;if(n.childNodes.length===0)return!0;const e=n.textContent??"";return e.includes(Jo)||!Co(e)?!1:Array.from(n.children).every(t=>la(t))},ca=typeof window<"u"&&typeof window.MutationObserver<"u"?new window.MutationObserver(n=>{for(const e of n){const t=e.nextSibling;e.removedNodes.forEach(o=>{var l;if(!(o instanceof Element)||!la(o))return;const r=t instanceof Text?t:null;if(r===null||!r.isConnected)return;const i=r.parentElement;if(!((i==null?void 0:i.isContentEditable)??!1))return;const s=((l=r.textContent)==null?void 0:l[0])??null;(s===Jo||s===" ")&&Qo.add(r)})}}):null,da=new WeakSet,ua=n=>{if(ca===null||da.has(n))return;const e=()=>{n.body!==null&&(ca.observe(n.body,{childList:!0,subtree:!0}),da.add(n))};n.readyState==="loading"?n.addEventListener("DOMContentLoaded",e,{once:!0}):e()};typeof window<"u"&&typeof window.document<"u"&&ua(window.document);const lT=n=>{ua(n.ownerDocument);const[e,t]=er();if(e===null||!n.contains(e)||e.nodeType===Node.TEXT_NODE&&t<(e.textContent??"").length)return null;const o=document.createTreeWalker(n,NodeFilter.SHOW_TEXT);for(o.currentNode=e;;){const r=o.nextNode();if(r===null)return null;const i=r.textContent??"";if(i.length===0)continue;const s=i[0];if(!(s===Jo||s===" ")||r===e)return null;const l=document.createRange();try{l.setStart(e,t),l.setEnd(r,0)}catch{return null}const c=l.cloneContents(),d=document.createElement("div");d.appendChild(c);const u=Array.from(d.querySelectorAll("*")).some(g=>{const f=g.textContent??"";return f.length===0||Co(f)}),h=Qo.has(r);if(!(!u&&!h))return h&&Qo.delete(r),{node:r,offset:0}}},ha=(n,e,t,o)=>{const r=document.createRange();o==="left"?(r.selectNodeContents(n),r.setEnd(e,t)):(r.selectNodeContents(n),r.setStart(e,t));const i=r.cloneContents(),s=document.createElement("div");s.appendChild(i);const a=s.textContent||"";if(s.querySelectorAll("img, br, hr, input, area, base, col, embed, link, meta, param, source, track, wbr").length>0)return!1;const c=a.includes(" ")||s.innerHTML.includes("&nbsp;")||r.toString().includes(" "),d=e.nodeType===Node.TEXT_NODE&&(o==="left"?(e.textContent||"").slice(0,t):(e.textContent||"").slice(t)).includes(" ");if(c||d)return!1;s.style.position="absolute",s.style.visibility="hidden",s.style.height="auto",s.style.width="auto",s.style.whiteSpace=window.getComputedStyle(n).whiteSpace,document.body.appendChild(s);const u=s.getBoundingClientRect().width;return document.body.removeChild(s),!(u>0||!Co(a)||window.getComputedStyle(n).whiteSpace.startsWith("pre")&&a.length>0)},kn=n=>{const e=v.getDeepestNode(n);if(e===null||v.isEmpty(n))return!0;if(v.isNativeInput(e))return e.selectionEnd===0;if(v.isEmpty(n))return!0;const[t,o]=er();if(t===null)return!1;const r=window.getSelection(),i=(r==null?void 0:r.focusNode)??null;return i!==null&&i!==n&&!(i.nodeType===Node.TEXT_NODE&&i.parentNode===n)?!1:ha(n,t,o,"left")},wn=n=>{const e=v.getDeepestNode(n,!0);if(e===null)return!0;if(v.isNativeInput(e))return e.selectionEnd===e.value.length;const[t,o]=er();return t===null?!1:ha(n,t,o,"right")};var fa={},tr={},Cn={},Je={},nr={},or={};Object.defineProperty(or,"__esModule",{value:!0}),or.allInputsSelector=cT;function cT(){var n=["text","password","email","number","search","tel","url"];return"[contenteditable=true], textarea, input:not([type]), "+n.map(function(e){return'input[type="'.concat(e,'"]')}).join(", ")}(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.allInputsSelector=void 0;var e=or;Object.defineProperty(n,"allInputsSelector",{enumerable:!0,get:function(){return e.allInputsSelector}})})(nr);var Qe={},rr={};Object.defineProperty(rr,"__esModule",{value:!0}),rr.isNativeInput=dT;function dT(n){var e=["INPUT","TEXTAREA"];return n&&n.tagName?e.includes(n.tagName):!1}(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.isNativeInput=void 0;var e=rr;Object.defineProperty(n,"isNativeInput",{enumerable:!0,get:function(){return e.isNativeInput}})})(Qe);var pa={},ir={};Object.defineProperty(ir,"__esModule",{value:!0}),ir.append=uT;function uT(n,e){Array.isArray(e)?e.forEach(function(t){n.appendChild(t)}):n.appendChild(e)}(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.append=void 0;var e=ir;Object.defineProperty(n,"append",{enumerable:!0,get:function(){return e.append}})})(pa);var sr={},ar={};Object.defineProperty(ar,"__esModule",{value:!0}),ar.blockElements=hT;function hT(){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(n){Object.defineProperty(n,"__esModule",{value:!0}),n.blockElements=void 0;var e=ar;Object.defineProperty(n,"blockElements",{enumerable:!0,get:function(){return e.blockElements}})})(sr);var ga={},lr={};Object.defineProperty(lr,"__esModule",{value:!0}),lr.calculateBaseline=fT;function fT(n){var e=window.getComputedStyle(n),t=parseFloat(e.fontSize),o=parseFloat(e.lineHeight)||t*1.2,r=parseFloat(e.paddingTop),i=parseFloat(e.borderTopWidth),s=parseFloat(e.marginTop),a=t*.8,l=(o-t)/2,c=s+i+r+l+a;return c}(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.calculateBaseline=void 0;var e=lr;Object.defineProperty(n,"calculateBaseline",{enumerable:!0,get:function(){return e.calculateBaseline}})})(ga);var ma={},cr={},dr={},ur={};Object.defineProperty(ur,"__esModule",{value:!0}),ur.isContentEditable=pT;function pT(n){return n.contentEditable==="true"}(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.isContentEditable=void 0;var e=ur;Object.defineProperty(n,"isContentEditable",{enumerable:!0,get:function(){return e.isContentEditable}})})(dr),Object.defineProperty(cr,"__esModule",{value:!0}),cr.canSetCaret=vT;var gT=Qe,mT=dr;function vT(n){var e=!0;if((0,gT.isNativeInput)(n))switch(n.type){case"file":case"checkbox":case"radio":case"hidden":case"submit":case"button":case"image":case"reset":e=!1;break}else e=(0,mT.isContentEditable)(n);return e}(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.canSetCaret=void 0;var e=cr;Object.defineProperty(n,"canSetCaret",{enumerable:!0,get:function(){return e.canSetCaret}})})(ma);var Sn={},hr={};function bT(n,e,t){const o=t.value!==void 0?"value":"get",r=t[o],i=`#${e}Cache`;if(t[o]=function(...s){return this[i]===void 0&&(this[i]=r.apply(this,s)),this[i]},o==="get"&&t.set){const s=t.set;t.set=function(a){delete n[i],s.apply(this,a)}}return t}function va(){const n={win:!1,mac:!1,x11:!1,linux:!1},e=Object.keys(n).find(t=>window.navigator.appVersion.toLowerCase().indexOf(t)!==-1);return e!==void 0&&(n[e]=!0),n}function fr(n){return n!=null&&n!==""&&(typeof n!="object"||Object.keys(n).length>0)}function yT(n){return!fr(n)}const ET=()=>typeof window<"u"&&window.navigator!==null&&fr(window.navigator.platform)&&(/iP(ad|hone|od)/.test(window.navigator.platform)||window.navigator.platform==="MacIntel"&&window.navigator.maxTouchPoints>1);function TT(n){const e=va();return n=n.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.mac?n=n.replace(/ctrl|cmd/gi,"⌘").replace(/alt/gi,"⌥"):n=n.replace(/cmd/gi,"Ctrl").replace(/windows/gi,"WIN"),n}function kT(n){return n[0].toUpperCase()+n.slice(1)}function wT(n){const e=document.createElement("div");e.style.position="absolute",e.style.left="-999px",e.style.bottom="-999px",e.innerHTML=n,document.body.appendChild(e);const t=window.getSelection(),o=document.createRange();if(o.selectNode(e),t===null)throw new Error("Cannot copy text to clipboard");t.removeAllRanges(),t.addRange(o),document.execCommand("copy"),document.body.removeChild(e)}function CT(n,e,t){let o;return(...r)=>{const i=this,s=()=>{o=void 0,t!==!0&&n.apply(i,r)},a=t===!0&&o!==void 0;window.clearTimeout(o),o=window.setTimeout(s,e),a&&n.apply(i,r)}}function ze(n){return Object.prototype.toString.call(n).match(/\s([a-zA-Z]+)/)[1].toLowerCase()}function ST(n){return ze(n)==="boolean"}function ba(n){return ze(n)==="function"||ze(n)==="asyncfunction"}function xT(n){return ba(n)&&/^\s*class\s+/.test(n.toString())}function BT(n){return ze(n)==="number"}function xn(n){return ze(n)==="object"}function _T(n){return Promise.resolve(n)===n}function AT(n){return ze(n)==="string"}function IT(n){return ze(n)==="undefined"}function pr(n,...e){if(!e.length)return n;const t=e.shift();if(xn(n)&&xn(t))for(const o in t)xn(t[o])?(n[o]===void 0&&Object.assign(n,{[o]:{}}),pr(n[o],t[o])):Object.assign(n,{[o]:t[o]});return pr(n,...e)}function OT(n,e,t){const o=`«${e}» is deprecated and will be removed in the next major release. Please use the «${t}» instead.`;n&&console.warn(o)}function NT(n){try{return new URL(n).href}catch{}return n.substring(0,2)==="//"?window.location.protocol+n:window.location.origin+n}function RT(n){return n>47&&n<58||n===32||n===13||n===229||n>64&&n<91||n>95&&n<112||n>185&&n<193||n>218&&n<223}const LT={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},PT={LEFT:0,WHEEL:1,RIGHT:2,BACKWARD:3,FORWARD:4};let MT=class{constructor(){this.completed=Promise.resolve()}add(e){return new Promise((t,o)=>{this.completed=this.completed.then(e).then(t).catch(o)})}};function DT(n,e,t=void 0){let o,r,i,s=null,a=0;t||(t={});const l=function(){a=t.leading===!1?0:Date.now(),s=null,i=n.apply(o,r),s===null&&(o=r=null)};return function(){const c=Date.now();!a&&t.leading===!1&&(a=c);const d=e-(c-a);return o=this,r=arguments,d<=0||d>e?(s&&(clearTimeout(s),s=null),a=c,i=n.apply(o,r),s===null&&(o=r=null)):!s&&t.trailing!==!1&&(s=setTimeout(l,d)),i}}const gr=Tl(Object.freeze(Object.defineProperty({__proto__:null,PromiseQueue:MT,beautifyShortcut:TT,cacheable:bT,capitalize:kT,copyTextToClipboard:wT,debounce:CT,deepMerge:pr,deprecationAssert:OT,getUserOS:va,getValidUrl:NT,isBoolean:ST,isClass:xT,isEmpty:yT,isFunction:ba,isIosDevice:ET,isNumber:BT,isObject:xn,isPrintableKey:RT,isPromise:_T,isString:AT,isUndefined:IT,keyCodes:LT,mouseButtons:PT,notEmpty:fr,throttle:DT,typeOf:ze},Symbol.toStringTag,{value:"Module"})));Object.defineProperty(hr,"__esModule",{value:!0}),hr.containsOnlyInlineElements=HT;var $T=gr,FT=sr;function HT(n){var e;(0,$T.isString)(n)?(e=document.createElement("div"),e.innerHTML=n):e=n;var t=function(o){return!(0,FT.blockElements)().includes(o.tagName.toLowerCase())&&Array.from(o.children).every(t)};return Array.from(e.children).every(t)}(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.containsOnlyInlineElements=void 0;var e=hr;Object.defineProperty(n,"containsOnlyInlineElements",{enumerable:!0,get:function(){return e.containsOnlyInlineElements}})})(Sn);var ya={},mr={},Bn={},vr={};Object.defineProperty(vr,"__esModule",{value:!0}),vr.make=jT;function jT(n,e,t){var o;e===void 0&&(e=null),t===void 0&&(t={});var r=document.createElement(n);if(Array.isArray(e)){var i=e.filter(function(a){return a!==void 0});(o=r.classList).add.apply(o,i)}else e!==null&&r.classList.add(e);for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(r[s]=t[s]);return r}(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.make=void 0;var e=vr;Object.defineProperty(n,"make",{enumerable:!0,get:function(){return e.make}})})(Bn),Object.defineProperty(mr,"__esModule",{value:!0}),mr.fragmentToString=WT;var zT=Bn;function WT(n){var e=(0,zT.make)("div");return e.appendChild(n),e.innerHTML}(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.fragmentToString=void 0;var e=mr;Object.defineProperty(n,"fragmentToString",{enumerable:!0,get:function(){return e.fragmentToString}})})(ya);var Ea={},br={};Object.defineProperty(br,"__esModule",{value:!0}),br.getContentLength=KT;var UT=Qe;function KT(n){var e,t;return(0,UT.isNativeInput)(n)?n.value.length:n.nodeType===Node.TEXT_NODE?n.length:(t=(e=n.textContent)===null||e===void 0?void 0:e.length)!==null&&t!==void 0?t:0}(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.getContentLength=void 0;var e=br;Object.defineProperty(n,"getContentLength",{enumerable:!0,get:function(){return e.getContentLength}})})(Ea);var yr={},Er={},Ta=pe&&pe.__spreadArray||function(n,e,t){if(t||arguments.length===2)for(var o=0,r=e.length,i;o<r;o++)(i||!(o in e))&&(i||(i=Array.prototype.slice.call(e,0,o)),i[o]=e[o]);return n.concat(i||Array.prototype.slice.call(e))};Object.defineProperty(Er,"__esModule",{value:!0}),Er.getDeepestBlockElements=ka;var GT=Sn;function ka(n){return(0,GT.containsOnlyInlineElements)(n)?[n]:Array.from(n.children).reduce(function(e,t){return Ta(Ta([],e,!0),ka(t),!0)},[])}(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.getDeepestBlockElements=void 0;var e=Er;Object.defineProperty(n,"getDeepestBlockElements",{enumerable:!0,get:function(){return e.getDeepestBlockElements}})})(yr);var wa={},Tr={},_n={},kr={};Object.defineProperty(kr,"__esModule",{value:!0}),kr.isLineBreakTag=YT;function YT(n){return["BR","WBR"].includes(n.tagName)}(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.isLineBreakTag=void 0;var e=kr;Object.defineProperty(n,"isLineBreakTag",{enumerable:!0,get:function(){return e.isLineBreakTag}})})(_n);var An={},wr={};Object.defineProperty(wr,"__esModule",{value:!0}),wr.isSingleTag=XT;function XT(n){return["AREA","BASE","BR","COL","COMMAND","EMBED","HR","IMG","INPUT","KEYGEN","LINK","META","PARAM","SOURCE","TRACK","WBR"].includes(n.tagName)}(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.isSingleTag=void 0;var e=wr;Object.defineProperty(n,"isSingleTag",{enumerable:!0,get:function(){return e.isSingleTag}})})(An),Object.defineProperty(Tr,"__esModule",{value:!0}),Tr.getDeepestNode=Ca;var VT=Qe,qT=_n,ZT=An;function Ca(n,e){e===void 0&&(e=!1);var t=e?"lastChild":"firstChild",o=e?"previousSibling":"nextSibling";if(n.nodeType===Node.ELEMENT_NODE&&n[t]){var r=n[t];if((0,ZT.isSingleTag)(r)&&!(0,VT.isNativeInput)(r)&&!(0,qT.isLineBreakTag)(r))if(r[o])r=r[o];else if(r.parentNode!==null&&r.parentNode[o])r=r.parentNode[o];else return r.parentNode;return Ca(r,e)}return n}(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.getDeepestNode=void 0;var e=Tr;Object.defineProperty(n,"getDeepestNode",{enumerable:!0,get:function(){return e.getDeepestNode}})})(wa);var Sa={},Cr={},In=pe&&pe.__spreadArray||function(n,e,t){if(t||arguments.length===2)for(var o=0,r=e.length,i;o<r;o++)(i||!(o in e))&&(i||(i=Array.prototype.slice.call(e,0,o)),i[o]=e[o]);return n.concat(i||Array.prototype.slice.call(e))};Object.defineProperty(Cr,"__esModule",{value:!0}),Cr.findAllInputs=nk;var JT=Sn,QT=yr,ek=nr,tk=Qe;function nk(n){return Array.from(n.querySelectorAll((0,ek.allInputsSelector)())).reduce(function(e,t){return(0,tk.isNativeInput)(t)||(0,JT.containsOnlyInlineElements)(t)?In(In([],e,!0),[t],!1):In(In([],e,!0),(0,QT.getDeepestBlockElements)(t),!0)},[])}(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.findAllInputs=void 0;var e=Cr;Object.defineProperty(n,"findAllInputs",{enumerable:!0,get:function(){return e.findAllInputs}})})(Sa);var xa={},Sr={};Object.defineProperty(Sr,"__esModule",{value:!0}),Sr.isCollapsedWhitespaces=ok;function ok(n){return!/[^\t\n\r ]/.test(n)}(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.isCollapsedWhitespaces=void 0;var e=Sr;Object.defineProperty(n,"isCollapsedWhitespaces",{enumerable:!0,get:function(){return e.isCollapsedWhitespaces}})})(xa);var xr={},Br={};Object.defineProperty(Br,"__esModule",{value:!0}),Br.isElement=ik;var rk=gr;function ik(n){return(0,rk.isNumber)(n)?!1:!!n&&!!n.nodeType&&n.nodeType===Node.ELEMENT_NODE}(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.isElement=void 0;var e=Br;Object.defineProperty(n,"isElement",{enumerable:!0,get:function(){return e.isElement}})})(xr);var Ba={},_r={},Ar={},Ir={};Object.defineProperty(Ir,"__esModule",{value:!0}),Ir.isLeaf=sk;function sk(n){return n===null?!1:n.childNodes.length===0}(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.isLeaf=void 0;var e=Ir;Object.defineProperty(n,"isLeaf",{enumerable:!0,get:function(){return e.isLeaf}})})(Ar);var Or={},Nr={};Object.defineProperty(Nr,"__esModule",{value:!0}),Nr.isNodeEmpty=uk;var ak=_n,lk=xr,ck=Qe,dk=An;function uk(n,e){var t="";return(0,dk.isSingleTag)(n)&&!(0,ak.isLineBreakTag)(n)?!1:((0,lk.isElement)(n)&&(0,ck.isNativeInput)(n)?t=n.value:n.textContent!==null&&(t=n.textContent.replace("​","")),e!==void 0&&(t=t.replace(new RegExp(e,"g"),"")),t.trim().length===0)}(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.isNodeEmpty=void 0;var e=Nr;Object.defineProperty(n,"isNodeEmpty",{enumerable:!0,get:function(){return e.isNodeEmpty}})})(Or),Object.defineProperty(_r,"__esModule",{value:!0}),_r.isEmpty=pk;var hk=Ar,fk=Or;function pk(n,e){n.normalize();for(var t=[n];t.length>0;){var o=t.shift();if(o){if(n=o,(0,hk.isLeaf)(n)&&!(0,fk.isNodeEmpty)(n,e))return!1;t.push.apply(t,Array.from(n.childNodes))}}return!0}(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.isEmpty=void 0;var e=_r;Object.defineProperty(n,"isEmpty",{enumerable:!0,get:function(){return e.isEmpty}})})(Ba);var _a={},Rr={};Object.defineProperty(Rr,"__esModule",{value:!0}),Rr.isFragment=mk;var gk=gr;function mk(n){return(0,gk.isNumber)(n)?!1:!!n&&!!n.nodeType&&n.nodeType===Node.DOCUMENT_FRAGMENT_NODE}(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.isFragment=void 0;var e=Rr;Object.defineProperty(n,"isFragment",{enumerable:!0,get:function(){return e.isFragment}})})(_a);var Aa={},Lr={};Object.defineProperty(Lr,"__esModule",{value:!0}),Lr.isHTMLString=bk;var vk=Bn;function bk(n){var e=(0,vk.make)("div");return e.innerHTML=n,e.childElementCount>0}(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.isHTMLString=void 0;var e=Lr;Object.defineProperty(n,"isHTMLString",{enumerable:!0,get:function(){return e.isHTMLString}})})(Aa);var Ia={},Pr={};Object.defineProperty(Pr,"__esModule",{value:!0}),Pr.offset=yk;function yk(n){var e=n.getBoundingClientRect(),t=window.pageXOffset||document.documentElement.scrollLeft,o=window.pageYOffset||document.documentElement.scrollTop,r=e.top+o,i=e.left+t;return{top:r,left:i,bottom:r+e.height,right:i+e.width}}(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.offset=void 0;var e=Pr;Object.defineProperty(n,"offset",{enumerable:!0,get:function(){return e.offset}})})(Ia);var Oa={},Mr={};Object.defineProperty(Mr,"__esModule",{value:!0}),Mr.prepend=Ek;function Ek(n,e){Array.isArray(e)?(e=e.reverse(),e.forEach(function(t){return n.prepend(t)})):n.prepend(e)}(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.prepend=void 0;var e=Mr;Object.defineProperty(n,"prepend",{enumerable:!0,get:function(){return e.prepend}})})(Oa),function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.prepend=n.offset=n.make=n.isLineBreakTag=n.isSingleTag=n.isNodeEmpty=n.isLeaf=n.isHTMLString=n.isFragment=n.isEmpty=n.isElement=n.isContentEditable=n.isCollapsedWhitespaces=n.findAllInputs=n.isNativeInput=n.allInputsSelector=n.getDeepestNode=n.getDeepestBlockElements=n.getContentLength=n.fragmentToString=n.containsOnlyInlineElements=n.canSetCaret=n.calculateBaseline=n.blockElements=n.append=void 0;var e=nr;Object.defineProperty(n,"allInputsSelector",{enumerable:!0,get:function(){return e.allInputsSelector}});var t=Qe;Object.defineProperty(n,"isNativeInput",{enumerable:!0,get:function(){return t.isNativeInput}});var o=pa;Object.defineProperty(n,"append",{enumerable:!0,get:function(){return o.append}});var r=sr;Object.defineProperty(n,"blockElements",{enumerable:!0,get:function(){return r.blockElements}});var i=ga;Object.defineProperty(n,"calculateBaseline",{enumerable:!0,get:function(){return i.calculateBaseline}});var s=ma;Object.defineProperty(n,"canSetCaret",{enumerable:!0,get:function(){return s.canSetCaret}});var a=Sn;Object.defineProperty(n,"containsOnlyInlineElements",{enumerable:!0,get:function(){return a.containsOnlyInlineElements}});var l=ya;Object.defineProperty(n,"fragmentToString",{enumerable:!0,get:function(){return l.fragmentToString}});var c=Ea;Object.defineProperty(n,"getContentLength",{enumerable:!0,get:function(){return c.getContentLength}});var d=yr;Object.defineProperty(n,"getDeepestBlockElements",{enumerable:!0,get:function(){return d.getDeepestBlockElements}});var u=wa;Object.defineProperty(n,"getDeepestNode",{enumerable:!0,get:function(){return u.getDeepestNode}});var h=Sa;Object.defineProperty(n,"findAllInputs",{enumerable:!0,get:function(){return h.findAllInputs}});var g=xa;Object.defineProperty(n,"isCollapsedWhitespaces",{enumerable:!0,get:function(){return g.isCollapsedWhitespaces}});var f=dr;Object.defineProperty(n,"isContentEditable",{enumerable:!0,get:function(){return f.isContentEditable}});var m=xr;Object.defineProperty(n,"isElement",{enumerable:!0,get:function(){return m.isElement}});var b=Ba;Object.defineProperty(n,"isEmpty",{enumerable:!0,get:function(){return b.isEmpty}});var E=_a;Object.defineProperty(n,"isFragment",{enumerable:!0,get:function(){return E.isFragment}});var k=Aa;Object.defineProperty(n,"isHTMLString",{enumerable:!0,get:function(){return k.isHTMLString}});var N=Ar;Object.defineProperty(n,"isLeaf",{enumerable:!0,get:function(){return N.isLeaf}});var x=Or;Object.defineProperty(n,"isNodeEmpty",{enumerable:!0,get:function(){return x.isNodeEmpty}});var P=_n;Object.defineProperty(n,"isLineBreakTag",{enumerable:!0,get:function(){return P.isLineBreakTag}});var I=An;Object.defineProperty(n,"isSingleTag",{enumerable:!0,get:function(){return I.isSingleTag}});var X=Bn;Object.defineProperty(n,"make",{enumerable:!0,get:function(){return X.make}});var C=Ia;Object.defineProperty(n,"offset",{enumerable:!0,get:function(){return C.offset}});var T=Oa;Object.defineProperty(n,"prepend",{enumerable:!0,get:function(){return T.prepend}})}(Je);var On={};Object.defineProperty(On,"__esModule",{value:!0}),On.getContenteditableSlice=kk;var Tk=Je;function kk(n,e,t,o,r){var i;r===void 0&&(r=!1);var s=document.createRange();if(o==="left"?(s.setStart(n,0),s.setEnd(e,t)):(s.setStart(e,t),s.setEnd(n,n.childNodes.length)),r===!0){var a=s.extractContents();return(0,Tk.fragmentToString)(a)}var l=s.cloneContents(),c=document.createElement("div");c.appendChild(l);var d=(i=c.textContent)!==null&&i!==void 0?i:"";return d}Object.defineProperty(Cn,"__esModule",{value:!0}),Cn.checkContenteditableSliceForEmptiness=Sk;var wk=Je,Ck=On;function Sk(n,e,t,o){var r=(0,Ck.getContenteditableSlice)(n,e,t,o);return(0,wk.isCollapsedWhitespaces)(r)}(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.checkContenteditableSliceForEmptiness=void 0;var e=Cn;Object.defineProperty(n,"checkContenteditableSliceForEmptiness",{enumerable:!0,get:function(){return e.checkContenteditableSliceForEmptiness}})})(tr);var Na={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.getContenteditableSlice=void 0;var e=On;Object.defineProperty(n,"getContenteditableSlice",{enumerable:!0,get:function(){return e.getContenteditableSlice}})})(Na);var Ra={},Dr={};Object.defineProperty(Dr,"__esModule",{value:!0}),Dr.focus=Bk;var xk=Je;function Bk(n,e){var t,o;if(e===void 0&&(e=!0),(0,xk.isNativeInput)(n)){n.focus();var r=e?0:n.value.length;n.setSelectionRange(r,r)}else{var i=document.createRange(),s=window.getSelection();if(!s)return;var a=function(h){var g=document.createTextNode("");h.appendChild(g),i.setStart(g,0),i.setEnd(g,0)},l=function(h){return h!=null},c=n.childNodes,d=e?c[0]:c[c.length-1];if(l(d)){for(;l(d)&&d.nodeType!==Node.TEXT_NODE;)d=e?d.firstChild:d.lastChild;if(l(d)&&d.nodeType===Node.TEXT_NODE){var u=(o=(t=d.textContent)===null||t===void 0?void 0:t.length)!==null&&o!==void 0?o:0,r=e?0:u;i.setStart(d,r),i.setEnd(d,r)}else a(n)}else a(n);s.removeAllRanges(),s.addRange(i)}}(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.focus=void 0;var e=Dr;Object.defineProperty(n,"focus",{enumerable:!0,get:function(){return e.focus}})})(Ra);var $r={},Nn={};Object.defineProperty(Nn,"__esModule",{value:!0}),Nn.getCaretNodeAndOffset=_k;function _k(){var n=window.getSelection();if(n===null)return[null,0];var e=n.focusNode,t=n.focusOffset;return e===null?[null,0]:(e.nodeType!==Node.TEXT_NODE&&e.childNodes.length>0&&(e.childNodes[t]!==void 0?(e=e.childNodes[t],t=0):(e=e.childNodes[t-1],e.textContent!==null&&(t=e.textContent.length))),[e,t])}(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.getCaretNodeAndOffset=void 0;var e=Nn;Object.defineProperty(n,"getCaretNodeAndOffset",{enumerable:!0,get:function(){return e.getCaretNodeAndOffset}})})($r);var La={},Rn={};Object.defineProperty(Rn,"__esModule",{value:!0}),Rn.getRange=Ak;function Ak(){var n=window.getSelection();return n&&n.rangeCount?n.getRangeAt(0):null}(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.getRange=void 0;var e=Rn;Object.defineProperty(n,"getRange",{enumerable:!0,get:function(){return e.getRange}})})(La);var Pa={},Fr={};Object.defineProperty(Fr,"__esModule",{value:!0}),Fr.isCaretAtEndOfInput=Nk;var Ma=Je,Ik=$r,Ok=tr;function Nk(n){var e=(0,Ma.getDeepestNode)(n,!0);if(e===null)return!0;if((0,Ma.isNativeInput)(e))return e.selectionEnd===e.value.length;var t=(0,Ik.getCaretNodeAndOffset)(),o=t[0],r=t[1];return o===null?!1:(0,Ok.checkContenteditableSliceForEmptiness)(n,o,r,"right")}(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.isCaretAtEndOfInput=void 0;var e=Fr;Object.defineProperty(n,"isCaretAtEndOfInput",{enumerable:!0,get:function(){return e.isCaretAtEndOfInput}})})(Pa);var Da={},Hr={};Object.defineProperty(Hr,"__esModule",{value:!0}),Hr.isCaretAtStartOfInput=Pk;var Ln=Je,Rk=Nn,Lk=Cn;function Pk(n){var e=(0,Ln.getDeepestNode)(n);if(e===null||(0,Ln.isEmpty)(n))return!0;if((0,Ln.isNativeInput)(e))return e.selectionEnd===0;if((0,Ln.isEmpty)(n))return!0;var t=(0,Rk.getCaretNodeAndOffset)(),o=t[0],r=t[1];return o===null?!1:(0,Lk.checkContenteditableSliceForEmptiness)(n,o,r,"left")}(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.isCaretAtStartOfInput=void 0;var e=Hr;Object.defineProperty(n,"isCaretAtStartOfInput",{enumerable:!0,get:function(){return e.isCaretAtStartOfInput}})})(Da);var $a={},jr={};Object.defineProperty(jr,"__esModule",{value:!0}),jr.save=$k;var Mk=Je,Dk=Rn;function $k(){var n=(0,Dk.getRange)(),e=(0,Mk.make)("span");if(e.id="cursor",e.hidden=!0,!!n)return n.insertNode(e),function(){var o=window.getSelection();o&&(n.setStartAfter(e),n.setEndAfter(e),o.removeAllRanges(),o.addRange(n),setTimeout(function(){e.remove()},150))}}(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.save=void 0;var e=jr;Object.defineProperty(n,"save",{enumerable:!0,get:function(){return e.save}})})($a),function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.save=n.isCaretAtStartOfInput=n.isCaretAtEndOfInput=n.getRange=n.getCaretNodeAndOffset=n.focus=n.getContenteditableSlice=n.checkContenteditableSliceForEmptiness=void 0;var e=tr;Object.defineProperty(n,"checkContenteditableSliceForEmptiness",{enumerable:!0,get:function(){return e.checkContenteditableSliceForEmptiness}});var t=Na;Object.defineProperty(n,"getContenteditableSlice",{enumerable:!0,get:function(){return t.getContenteditableSlice}});var o=Ra;Object.defineProperty(n,"focus",{enumerable:!0,get:function(){return o.focus}});var r=$r;Object.defineProperty(n,"getCaretNodeAndOffset",{enumerable:!0,get:function(){return r.getCaretNodeAndOffset}});var i=La;Object.defineProperty(n,"getRange",{enumerable:!0,get:function(){return i.getRange}});var s=Pa;Object.defineProperty(n,"isCaretAtEndOfInput",{enumerable:!0,get:function(){return s.isCaretAtEndOfInput}});var a=Da;Object.defineProperty(n,"isCaretAtStartOfInput",{enumerable:!0,get:function(){return a.isCaretAtStartOfInput}});var l=$a;Object.defineProperty(n,"save",{enumerable:!0,get:function(){return l.save}})}(fa);const Fa={Backspace:S.BACKSPACE,Delete:S.DELETE,Enter:S.ENTER,Tab:S.TAB,ArrowDown:S.DOWN,ArrowRight:S.RIGHT,ArrowUp:S.UP,ArrowLeft:S.LEFT},Fk=new Set(["Enter","Process","Spacebar","Space","Dead"]),Pn='[contenteditable="true"], textarea, input';class Hk extends F{keydown(e){if(this.beforeKeydownProcessing(e),this.handleSelectedBlocksDeletion(e)||e.defaultPrevented)return;switch(this.getKeyCode(e)){case S.BACKSPACE:this.backspace(e);break;case S.DELETE:this.delete(e);break;case S.ENTER:this.enter(e);break;case S.DOWN:case S.RIGHT:this.arrowRightAndDown(e);break;case S.UP:case S.LEFT:this.arrowLeftAndUp(e);break;case S.TAB:this.tabPressed(e);break}e.key==="/"&&!e.ctrlKey&&!e.metaKey&&this.slashPressed(e),e.code==="Slash"&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),this.commandSlashPressed())}handleSelectedBlocksDeletion(e){const{BlockSelection:t,BlockManager:o,Caret:r}=this.Editor,i=e.key==="Backspace"||e.key==="Delete",s=w.isSelectionExists,a=w.isCollapsed===!0;if(!(i&&t.anyBlockSelected&&(!s||a)))return!1;const c=o.removeSelectedBlocks();if(c!==void 0){const d=o.insertDefaultBlockAtIndex(c,!0);r.setToBlock(d,r.positions.START)}return t.clearSelection(e),e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation(),!0}beforeKeydownProcessing(e){!this.needToolbarClosing(e)||!this.isPrintableKeyEvent(e)||(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()}handleCommandC(e){const{BlockSelection:t}=this.Editor;t.anyBlockSelected&&t.copySelectedBlocks(e)}handleCommandX(e){const{BlockSelection:t,BlockManager:o,Caret:r}=this.Editor;t.anyBlockSelected&&t.copySelectedBlocks(e).then(()=>{const i=o.removeSelectedBlocks();if(i!==void 0){const s=o.insertDefaultBlockAtIndex(i,!0);r.setToBlock(s,r.positions.START)}t.clearSelection(e)}).catch(()=>{})}tabPressed(e){const{InlineToolbar:t,Caret:o}=this.Editor;if(t.opened)return;(e.shiftKey?o.navigatePrevious(!0):o.navigateNext(!0))&&e.preventDefault()}commandSlashPressed(){this.Editor.BlockSelection.selectedBlocks.length>1||this.activateBlockSettings()}slashPressed(e){if(!this.Editor.UI.nodes.wrapper.contains(e.target))return;const o=this.Editor.BlockManager.currentBlock;o!=null&&o.isEmpty&&(e.preventDefault(),this.Editor.Caret.insertContentAtCaretPosition("/"),this.activateToolbox())}enter(e){const{BlockManager:t,UI:o}=this.Editor,r=t.currentBlock;if(r===void 0||r.tool.isLineBreaksEnabled||o.someToolbarOpened&&o.someFlipperButtonFocused||e.shiftKey&&!wo)return;const i=(()=>r.currentInput!==void 0&&kn(r.currentInput)&&!r.hasMedia?(this.Editor.BlockManager.insertDefaultBlockAtIndex(this.Editor.BlockManager.currentBlockIndex),r):r.currentInput&&wn(r.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:r,previousBlock:i}=t;if(r===void 0||!w.isCollapsed||!r.currentInput||!kn(r.currentInput))return;if(e.preventDefault(),this.Editor.Toolbar.close(),!(r.currentInput===r.firstInput)){o.navigatePrevious();return}if(i===null)return;if(i.isEmpty){t.removeBlock(i);return}if(r.isEmpty){t.removeBlock(r);const l=t.currentBlock;l&&o.setToBlock(l,o.positions.END);return}Ks(i,r)?this.mergeBlocks(i,r):o.setToBlock(i,o.positions.END)}delete(e){const{BlockManager:t,Caret:o}=this.Editor,{currentBlock:r,nextBlock:i}=t;if(r===void 0||!w.isCollapsed||!r.currentInput||!wn(r.currentInput))return;if(e.preventDefault(),this.Editor.Toolbar.close(),!(r.currentInput===r.lastInput)){o.navigateNext();return}if(i===null)return;if(i.isEmpty){t.removeBlock(i);return}if(r.isEmpty){t.removeBlock(r),o.setToBlock(i,o.positions.START);return}Ks(r,i)?this.mergeBlocks(r,i):o.setToBlock(i,o.positions.START)}mergeBlocks(e,t){const{BlockManager:o,Toolbar:r}=this.Editor;e.lastInput!==void 0&&(fa.focus(e.lastInput,!1),o.mergeBlocks(e,t).then(()=>{r.close()}).catch(()=>{}))}arrowRightAndDown(e){const t=this.getKeyCode(e);if(t===null)return;const o=Fe.usedKeys.includes(t)&&(!e.shiftKey||t===S.TAB);if(this.Editor.UI.someToolbarOpened&&o)return;e.shiftKey||this.Editor.Toolbar.close();const r=w.get();r!=null&&r.anchorNode&&!this.Editor.BlockSelection.anyBlockSelected&&this.Editor.BlockManager.setCurrentBlockByChildNode(r.anchorNode);const{currentBlock:i}=this.Editor.BlockManager,s=e.target,a=document.activeElement instanceof HTMLElement?document.activeElement:null,l=[i==null?void 0:i.inputs.find(E=>s!==null&&E.contains(s)),i==null?void 0:i.inputs.find(E=>a!==null&&E.contains(a)),s==null?void 0:s.closest(Pn),a==null?void 0:a.closest(Pn)],c=(i==null?void 0:i.currentInput)??l.find(E=>E instanceof HTMLElement),u=(c!==void 0?wn(c):void 0)||this.Editor.BlockSelection.anyBlockSelected,h=e.shiftKey&&t===S.DOWN;if(h&&u){this.Editor.CrossBlockSelection.toggleBlockSelectedState();return}h&&this.Editor.InlineToolbar.tryToShow();const f=t===S.RIGHT&&!e.shiftKey&&!this.isRtl&&c instanceof HTMLElement?lT(c):null;if(f!==null){w.setCursor(f.node,f.offset),e.preventDefault();return}if(t===S.DOWN||t===S.RIGHT&&!this.isRtl?this.Editor.Caret.navigateNext():this.Editor.Caret.navigatePrevious()){e.preventDefault();return}gn(()=>{this.Editor.BlockManager.currentBlock&&this.Editor.BlockManager.currentBlock.updateCurrentInput()},20)(),this.Editor.BlockSelection.clearSelection(e)}arrowLeftAndUp(e){const t=this.Editor.UI.someToolbarOpened,o=this.getKeyCode(e);if(o===null||t&&Fe.usedKeys.includes(o)&&(!e.shiftKey||o===S.TAB))return;t&&this.Editor.UI.closeAllToolbars(),e.shiftKey||this.Editor.Toolbar.close();const r=window.getSelection();r!=null&&r.anchorNode&&!this.Editor.BlockSelection.anyBlockSelected&&this.Editor.BlockManager.setCurrentBlockByChildNode(r.anchorNode);const{currentBlock:i}=this.Editor.BlockManager,s=e.target,a=document.activeElement instanceof HTMLElement?document.activeElement:null,l=[i==null?void 0:i.inputs.find(m=>s!==null&&m.contains(s)),i==null?void 0:i.inputs.find(m=>a!==null&&m.contains(a)),s==null?void 0:s.closest(Pn),a==null?void 0:a.closest(Pn)],c=(i==null?void 0:i.currentInput)??l.find(m=>m instanceof HTMLElement),u=(c!==void 0?kn(c):void 0)||this.Editor.BlockSelection.anyBlockSelected,h=e.shiftKey&&o===S.UP;if(h&&u){this.Editor.CrossBlockSelection.toggleBlockSelectedState(!1);return}if(h&&this.Editor.InlineToolbar.tryToShow(),o===S.UP||o===S.LEFT&&!this.isRtl?this.Editor.Caret.navigatePrevious():this.Editor.Caret.navigateNext()){e.preventDefault();return}gn(()=>{this.Editor.BlockManager.currentBlock&&this.Editor.BlockManager.currentBlock.updateCurrentInput()},20)(),this.Editor.BlockSelection.clearSelection(e)}needToolbarClosing(e){const t=this.getKeyCode(e),o=t===S.ENTER,r=t===S.TAB,i=o&&this.Editor.Toolbar.toolbox.opened,s=o&&this.Editor.BlockSettings.opened,a=o&&this.Editor.InlineToolbar.opened,l=r;return!(e.shiftKey||l||i||s||a)}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||Promise.resolve(this.Editor.BlockSettings.open()).catch(()=>{})}getKeyCode(e){const t=e.key&&Fa[e.key];if(t!==void 0&&typeof t=="number")return t;const o=e.code&&Fa[e.code];return o!==void 0&&typeof o=="number"?o:null}isPrintableKeyEvent(e){return e.key?e.key.length===1||Fk.has(e.key):!1}}class zr{constructor(e){this.blocks=[],this.workingArea=e}get length(){return this.blocks.length}get array(){return this.blocks}get nodes(){return Ps(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)}move(e,t,o=!1){const r=this.blocks.splice(t,1)[0];if(!o){const s=e-1,a=Math.max(0,s),l=this.blocks[a],c=e>0?"afterend":"beforebegin";this.insertToDOM(r,c,l)}this.blocks.splice(e,0,r);const i=this.composeBlockEvent("move",{fromIndex:t,toIndex:e});r.call(Pe.MOVED,i)}insert(e,t,o=!1){if(!this.length){this.push(t);return}const r=e>this.length?this.length:e;o&&(this.blocks[r].holder.remove(),this.blocks[r].call(Pe.REMOVED));const i=o?1:0;if(this.blocks.splice(r,i,t),r>0){const a=this.blocks[r-1];this.insertToDOM(t,"afterend",a);return}const s=this.blocks[r+1];if(s!==void 0){this.insertToDOM(t,"beforebegin",s);return}this.insertToDOM(t)}replace(e,t){if(this.blocks[e]===void 0)throw Error("Incorrect index");this.blocks[e].holder.replaceWith(t.holder),this.blocks[e]=t}insertMany(e,t){const o=new DocumentFragment;for(const r of e)o.appendChild(r.holder);if(!this.length){this.blocks.push(...e),this.workingArea.appendChild(o),e.forEach(r=>r.call(Pe.RENDERED));return}if(t>0){const r=Math.min(t-1,this.length-1);this.blocks[r].holder.after(o)}t===0&&this.workingArea.prepend(o),this.blocks.splice(t,0,...e),e.forEach(r=>r.call(Pe.RENDERED))}remove(e){const t=isNaN(e)?this.length-1:e;this.blocks[t].holder.remove(),this.blocks[t].call(Pe.REMOVED),this.blocks.splice(t,1)}removeAll(){this.workingArea.innerHTML="",this.blocks.forEach(e=>e.call(Pe.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!==void 0?o.holder.insertAdjacentElement(t,e.holder):this.workingArea.appendChild(e.holder),e.call(Pe.RENDERED)}composeBlockEvent(e,t){return new CustomEvent(e,{detail:t})}}/**!
25
+ * Sortable 1.15.6
26
+ * @author RubaXa <trash@rubaxa.org>
27
+ * @author owenm <owen23355@gmail.com>
28
+ * @license MIT
29
+ */function Ha(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(n);e&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(n,r).enumerable})),t.push.apply(t,o)}return t}function Ie(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Ha(Object(t),!0).forEach(function(o){jk(n,o,t[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):Ha(Object(t)).forEach(function(o){Object.defineProperty(n,o,Object.getOwnPropertyDescriptor(t,o))})}return n}function Mn(n){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Mn=function(e){return typeof e}:Mn=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Mn(n)}function jk(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function Me(){return Me=Object.assign||function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(n[o]=t[o])}return n},Me.apply(this,arguments)}function zk(n,e){if(n==null)return{};var t={},o=Object.keys(n),r,i;for(i=0;i<o.length;i++)r=o[i],!(e.indexOf(r)>=0)&&(t[r]=n[r]);return t}function Wk(n,e){if(n==null)return{};var t=zk(n,e),o,r;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);for(r=0;r<i.length;r++)o=i[r],!(e.indexOf(o)>=0)&&Object.prototype.propertyIsEnumerable.call(n,o)&&(t[o]=n[o])}return t}var Uk="1.15.6";function De(n){if(typeof window<"u"&&window.navigator)return!!navigator.userAgent.match(n)}var $e=De(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),jt=De(/Edge/i),ja=De(/firefox/i),zt=De(/safari/i)&&!De(/chrome/i)&&!De(/android/i),Wr=De(/iP(ad|od|hone)/i),za=De(/chrome/i)&&De(/android/i),Wa={capture:!1,passive:!1};function H(n,e,t){n.addEventListener(e,t,!$e&&Wa)}function D(n,e,t){n.removeEventListener(e,t,!$e&&Wa)}function Dn(n,e){if(e){if(e[0]===">"&&(e=e.substring(1)),n)try{if(n.matches)return n.matches(e);if(n.msMatchesSelector)return n.msMatchesSelector(e);if(n.webkitMatchesSelector)return n.webkitMatchesSelector(e)}catch{return!1}return!1}}function Ua(n){return n.host&&n!==document&&n.host.nodeType?n.host:n.parentNode}function Se(n,e,t,o){if(n){t=t||document;do{if(e!=null&&(e[0]===">"?n.parentNode===t&&Dn(n,e):Dn(n,e))||o&&n===t)return n;if(n===t)break}while(n=Ua(n))}return null}var Ka=/\s+/g;function me(n,e,t){if(n&&e)if(n.classList)n.classList[t?"add":"remove"](e);else{var o=(" "+n.className+" ").replace(Ka," ").replace(" "+e+" "," ");n.className=(o+(t?" "+e:"")).replace(Ka," ")}}function B(n,e,t){var o=n&&n.style;if(o){if(t===void 0)return document.defaultView&&document.defaultView.getComputedStyle?t=document.defaultView.getComputedStyle(n,""):n.currentStyle&&(t=n.currentStyle),e===void 0?t:t[e];!(e in o)&&e.indexOf("webkit")===-1&&(e="-webkit-"+e),o[e]=t+(typeof t=="string"?"":"px")}}function Et(n,e){var t="";if(typeof n=="string")t=n;else do{var o=B(n,"transform");o&&o!=="none"&&(t=o+" "+t)}while(!e&&(n=n.parentNode));var r=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return r&&new r(t)}function Ga(n,e,t){if(n){var o=n.getElementsByTagName(e),r=0,i=o.length;if(t)for(;r<i;r++)t(o[r],r);return o}return[]}function Oe(){var n=document.scrollingElement;return n||document.documentElement}function ee(n,e,t,o,r){if(!(!n.getBoundingClientRect&&n!==window)){var i,s,a,l,c,d,u;if(n!==window&&n.parentNode&&n!==Oe()?(i=n.getBoundingClientRect(),s=i.top,a=i.left,l=i.bottom,c=i.right,d=i.height,u=i.width):(s=0,a=0,l=window.innerHeight,c=window.innerWidth,d=window.innerHeight,u=window.innerWidth),(e||t)&&n!==window&&(r=r||n.parentNode,!$e))do if(r&&r.getBoundingClientRect&&(B(r,"transform")!=="none"||t&&B(r,"position")!=="static")){var h=r.getBoundingClientRect();s-=h.top+parseInt(B(r,"border-top-width")),a-=h.left+parseInt(B(r,"border-left-width")),l=s+i.height,c=a+i.width;break}while(r=r.parentNode);if(o&&n!==window){var g=Et(r||n),f=g&&g.a,m=g&&g.d;g&&(s/=m,a/=f,u/=f,d/=m,l=s+d,c=a+u)}return{top:s,left:a,bottom:l,right:c,width:u,height:d}}}function Ya(n,e,t){for(var o=We(n,!0),r=ee(n)[e];o;){var i=ee(o)[t],s=void 0;if(t==="top"||t==="left"?s=r>=i:s=r<=i,!s)return o;if(o===Oe())break;o=We(o,!1)}return!1}function Tt(n,e,t,o){for(var r=0,i=0,s=n.children;i<s.length;){if(s[i].style.display!=="none"&&s[i]!==_.ghost&&(o||s[i]!==_.dragged)&&Se(s[i],t.draggable,n,!1)){if(r===e)return s[i];r++}i++}return null}function Ur(n,e){for(var t=n.lastElementChild;t&&(t===_.ghost||B(t,"display")==="none"||e&&!Dn(t,e));)t=t.previousElementSibling;return t||null}function Te(n,e){var t=0;if(!n||!n.parentNode)return-1;for(;n=n.previousElementSibling;)n.nodeName.toUpperCase()!=="TEMPLATE"&&n!==_.clone&&(!e||Dn(n,e))&&t++;return t}function Xa(n){var e=0,t=0,o=Oe();if(n)do{var r=Et(n),i=r.a,s=r.d;e+=n.scrollLeft*i,t+=n.scrollTop*s}while(n!==o&&(n=n.parentNode));return[e,t]}function Kk(n,e){for(var t in n)if(n.hasOwnProperty(t)){for(var o in e)if(e.hasOwnProperty(o)&&e[o]===n[t][o])return Number(t)}return-1}function We(n,e){if(!n||!n.getBoundingClientRect)return Oe();var t=n,o=!1;do if(t.clientWidth<t.scrollWidth||t.clientHeight<t.scrollHeight){var r=B(t);if(t.clientWidth<t.scrollWidth&&(r.overflowX=="auto"||r.overflowX=="scroll")||t.clientHeight<t.scrollHeight&&(r.overflowY=="auto"||r.overflowY=="scroll")){if(!t.getBoundingClientRect||t===document.body)return Oe();if(o||e)return t;o=!0}}while(t=t.parentNode);return Oe()}function Gk(n,e){if(n&&e)for(var t in e)e.hasOwnProperty(t)&&(n[t]=e[t]);return n}function Kr(n,e){return Math.round(n.top)===Math.round(e.top)&&Math.round(n.left)===Math.round(e.left)&&Math.round(n.height)===Math.round(e.height)&&Math.round(n.width)===Math.round(e.width)}var Wt;function Va(n,e){return function(){if(!Wt){var t=arguments,o=this;t.length===1?n.call(o,t[0]):n.apply(o,t),Wt=setTimeout(function(){Wt=void 0},e)}}}function Yk(){clearTimeout(Wt),Wt=void 0}function qa(n,e,t){n.scrollLeft+=e,n.scrollTop+=t}function Za(n){var e=window.Polymer,t=window.jQuery||window.Zepto;return e&&e.dom?e.dom(n).cloneNode(!0):t?t(n).clone(!0)[0]:n.cloneNode(!0)}function Ja(n,e,t){var o={};return Array.from(n.children).forEach(function(r){var i,s,a,l;if(!(!Se(r,e.draggable,n,!1)||r.animated||r===t)){var c=ee(r);o.left=Math.min((i=o.left)!==null&&i!==void 0?i:1/0,c.left),o.top=Math.min((s=o.top)!==null&&s!==void 0?s:1/0,c.top),o.right=Math.max((a=o.right)!==null&&a!==void 0?a:-1/0,c.right),o.bottom=Math.max((l=o.bottom)!==null&&l!==void 0?l:-1/0,c.bottom)}}),o.width=o.right-o.left,o.height=o.bottom-o.top,o.x=o.left,o.y=o.top,o}var he="Sortable"+new Date().getTime();function Xk(){var n=[],e;return{captureAnimationState:function(){if(n=[],!!this.options.animation){var o=[].slice.call(this.el.children);o.forEach(function(r){if(!(B(r,"display")==="none"||r===_.ghost)){n.push({target:r,rect:ee(r)});var i=Ie({},n[n.length-1].rect);if(r.thisAnimationDuration){var s=Et(r,!0);s&&(i.top-=s.f,i.left-=s.e)}r.fromRect=i}})}},addAnimationState:function(o){n.push(o)},removeAnimationState:function(o){n.splice(Kk(n,{target:o}),1)},animateAll:function(o){var r=this;if(!this.options.animation){clearTimeout(e),typeof o=="function"&&o();return}var i=!1,s=0;n.forEach(function(a){var l=0,c=a.target,d=c.fromRect,u=ee(c),h=c.prevFromRect,g=c.prevToRect,f=a.rect,m=Et(c,!0);m&&(u.top-=m.f,u.left-=m.e),c.toRect=u,c.thisAnimationDuration&&Kr(h,u)&&!Kr(d,u)&&(f.top-u.top)/(f.left-u.left)===(d.top-u.top)/(d.left-u.left)&&(l=qk(f,h,g,r.options)),Kr(u,d)||(c.prevFromRect=d,c.prevToRect=u,l||(l=r.options.animation),r.animate(c,f,u,l)),l&&(i=!0,s=Math.max(s,l),clearTimeout(c.animationResetTimer),c.animationResetTimer=setTimeout(function(){c.animationTime=0,c.prevFromRect=null,c.fromRect=null,c.prevToRect=null,c.thisAnimationDuration=null},l),c.thisAnimationDuration=l)}),clearTimeout(e),i?e=setTimeout(function(){typeof o=="function"&&o()},s):typeof o=="function"&&o(),n=[]},animate:function(o,r,i,s){if(s){B(o,"transition",""),B(o,"transform","");var a=Et(this.el),l=a&&a.a,c=a&&a.d,d=(r.left-i.left)/(l||1),u=(r.top-i.top)/(c||1);o.animatingX=!!d,o.animatingY=!!u,B(o,"transform","translate3d("+d+"px,"+u+"px,0)"),this.forRepaintDummy=Vk(o),B(o,"transition","transform "+s+"ms"+(this.options.easing?" "+this.options.easing:"")),B(o,"transform","translate3d(0,0,0)"),typeof o.animated=="number"&&clearTimeout(o.animated),o.animated=setTimeout(function(){B(o,"transition",""),B(o,"transform",""),o.animated=!1,o.animatingX=!1,o.animatingY=!1},s)}}}}function Vk(n){return n.offsetWidth}function qk(n,e,t,o){return Math.sqrt(Math.pow(e.top-n.top,2)+Math.pow(e.left-n.left,2))/Math.sqrt(Math.pow(e.top-t.top,2)+Math.pow(e.left-t.left,2))*o.animation}var kt=[],Gr={initializeByDefault:!0},Ut={mount:function(e){for(var t in Gr)Gr.hasOwnProperty(t)&&!(t in e)&&(e[t]=Gr[t]);kt.forEach(function(o){if(o.pluginName===e.pluginName)throw"Sortable: Cannot mount plugin ".concat(e.pluginName," more than once")}),kt.push(e)},pluginEvent:function(e,t,o){var r=this;this.eventCanceled=!1,o.cancel=function(){r.eventCanceled=!0};var i=e+"Global";kt.forEach(function(s){t[s.pluginName]&&(t[s.pluginName][i]&&t[s.pluginName][i](Ie({sortable:t},o)),t.options[s.pluginName]&&t[s.pluginName][e]&&t[s.pluginName][e](Ie({sortable:t},o)))})},initializePlugins:function(e,t,o,r){kt.forEach(function(a){var l=a.pluginName;if(!(!e.options[l]&&!a.initializeByDefault)){var c=new a(e,t,e.options);c.sortable=e,c.options=e.options,e[l]=c,Me(o,c.defaults)}});for(var i in e.options)if(e.options.hasOwnProperty(i)){var s=this.modifyOption(e,i,e.options[i]);typeof s<"u"&&(e.options[i]=s)}},getEventProperties:function(e,t){var o={};return kt.forEach(function(r){typeof r.eventProperties=="function"&&Me(o,r.eventProperties.call(t[r.pluginName],e))}),o},modifyOption:function(e,t,o){var r;return kt.forEach(function(i){e[i.pluginName]&&i.optionListeners&&typeof i.optionListeners[t]=="function"&&(r=i.optionListeners[t].call(e[i.pluginName],o))}),r}};function Zk(n){var e=n.sortable,t=n.rootEl,o=n.name,r=n.targetEl,i=n.cloneEl,s=n.toEl,a=n.fromEl,l=n.oldIndex,c=n.newIndex,d=n.oldDraggableIndex,u=n.newDraggableIndex,h=n.originalEvent,g=n.putSortable,f=n.extraEventProperties;if(e=e||t&&t[he],!!e){var m,b=e.options,E="on"+o.charAt(0).toUpperCase()+o.substr(1);window.CustomEvent&&!$e&&!jt?m=new CustomEvent(o,{bubbles:!0,cancelable:!0}):(m=document.createEvent("Event"),m.initEvent(o,!0,!0)),m.to=s||t,m.from=a||t,m.item=r||t,m.clone=i,m.oldIndex=l,m.newIndex=c,m.oldDraggableIndex=d,m.newDraggableIndex=u,m.originalEvent=h,m.pullMode=g?g.lastPutMode:void 0;var k=Ie(Ie({},f),Ut.getEventProperties(o,e));for(var N in k)m[N]=k[N];t&&t.dispatchEvent(m),b[E]&&b[E].call(e,m)}}var Jk=["evt"],fe=function(e,t){var o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=o.evt,i=Wk(o,Jk);Ut.pluginEvent.bind(_)(e,t,Ie({dragEl:y,parentEl:q,ghostEl:O,rootEl:Y,nextEl:et,lastDownEl:$n,cloneEl:V,cloneHidden:Ue,dragStarted:Gt,putSortable:ie,activeSortable:_.active,originalEvent:r,oldIndex:wt,oldDraggableIndex:Kt,newIndex:ve,newDraggableIndex:Ke,hideGhostForTarget:il,unhideGhostForTarget:sl,cloneNowHidden:function(){Ue=!0},cloneNowShown:function(){Ue=!1},dispatchSortableEvent:function(a){ue({sortable:t,name:a,originalEvent:r})}},i))};function ue(n){Zk(Ie({putSortable:ie,cloneEl:V,targetEl:y,rootEl:Y,oldIndex:wt,oldDraggableIndex:Kt,newIndex:ve,newDraggableIndex:Ke},n))}var y,q,O,Y,et,$n,V,Ue,wt,ve,Kt,Ke,Fn,ie,Ct=!1,Hn=!1,jn=[],tt,xe,Yr,Xr,Qa,el,Gt,St,Yt,Xt=!1,zn=!1,Wn,le,Vr=[],qr=!1,Un=[],Kn=typeof document<"u",Gn=Wr,tl=jt||$e?"cssFloat":"float",Qk=Kn&&!za&&!Wr&&"draggable"in document.createElement("div"),nl=function(){if(Kn){if($e)return!1;var n=document.createElement("x");return n.style.cssText="pointer-events:auto",n.style.pointerEvents==="auto"}}(),ol=function(e,t){var o=B(e),r=parseInt(o.width)-parseInt(o.paddingLeft)-parseInt(o.paddingRight)-parseInt(o.borderLeftWidth)-parseInt(o.borderRightWidth),i=Tt(e,0,t),s=Tt(e,1,t),a=i&&B(i),l=s&&B(s),c=a&&parseInt(a.marginLeft)+parseInt(a.marginRight)+ee(i).width,d=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+ee(s).width;if(o.display==="flex")return o.flexDirection==="column"||o.flexDirection==="column-reverse"?"vertical":"horizontal";if(o.display==="grid")return o.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(i&&a.float&&a.float!=="none"){var u=a.float==="left"?"left":"right";return s&&(l.clear==="both"||l.clear===u)?"vertical":"horizontal"}return i&&(a.display==="block"||a.display==="flex"||a.display==="table"||a.display==="grid"||c>=r&&o[tl]==="none"||s&&o[tl]==="none"&&c+d>r)?"vertical":"horizontal"},ew=function(e,t,o){var r=o?e.left:e.top,i=o?e.right:e.bottom,s=o?e.width:e.height,a=o?t.left:t.top,l=o?t.right:t.bottom,c=o?t.width:t.height;return r===a||i===l||r+s/2===a+c/2},tw=function(e,t){var o;return jn.some(function(r){var i=r[he].options.emptyInsertThreshold;if(!(!i||Ur(r))){var s=ee(r),a=e>=s.left-i&&e<=s.right+i,l=t>=s.top-i&&t<=s.bottom+i;if(a&&l)return o=r}}),o},rl=function(e){function t(i,s){return function(a,l,c,d){var u=a.options.group.name&&l.options.group.name&&a.options.group.name===l.options.group.name;if(i==null&&(s||u))return!0;if(i==null||i===!1)return!1;if(s&&i==="clone")return i;if(typeof i=="function")return t(i(a,l,c,d),s)(a,l,c,d);var h=(s?a:l).options.group.name;return i===!0||typeof i=="string"&&i===h||i.join&&i.indexOf(h)>-1}}var o={},r=e.group;(!r||Mn(r)!="object")&&(r={name:r}),o.name=r.name,o.checkPull=t(r.pull,!0),o.checkPut=t(r.put),o.revertClone=r.revertClone,e.group=o},il=function(){!nl&&O&&B(O,"display","none")},sl=function(){!nl&&O&&B(O,"display","")};Kn&&!za&&document.addEventListener("click",function(n){if(Hn)return n.preventDefault(),n.stopPropagation&&n.stopPropagation(),n.stopImmediatePropagation&&n.stopImmediatePropagation(),Hn=!1,!1},!0);var nt=function(e){if(y){e=e.touches?e.touches[0]:e;var t=tw(e.clientX,e.clientY);if(t){var o={};for(var r in e)e.hasOwnProperty(r)&&(o[r]=e[r]);o.target=o.rootEl=t,o.preventDefault=void 0,o.stopPropagation=void 0,t[he]._onDragOver(o)}}},nw=function(e){y&&y.parentNode[he]._isOutsideThisEl(e.target)};function _(n,e){if(!(n&&n.nodeType&&n.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(n));this.el=n,this.options=e=Me({},e),n[he]=this;var t={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(n.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return ol(n,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(s,a){s.setData("Text",a.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:_.supportPointer!==!1&&"PointerEvent"in window&&(!zt||Wr),emptyInsertThreshold:5};Ut.initializePlugins(this,n,t);for(var o in t)!(o in e)&&(e[o]=t[o]);rl(e);for(var r in this)r.charAt(0)==="_"&&typeof this[r]=="function"&&(this[r]=this[r].bind(this));this.nativeDraggable=e.forceFallback?!1:Qk,this.nativeDraggable&&(this.options.touchStartThreshold=1),e.supportPointer?H(n,"pointerdown",this._onTapStart):(H(n,"mousedown",this._onTapStart),H(n,"touchstart",this._onTapStart)),this.nativeDraggable&&(H(n,"dragover",this),H(n,"dragenter",this)),jn.push(this.el),e.store&&e.store.get&&this.sort(e.store.get(this)||[]),Me(this,Xk())}_.prototype={constructor:_,_isOutsideThisEl:function(e){!this.el.contains(e)&&e!==this.el&&(St=null)},_getDirection:function(e,t){return typeof this.options.direction=="function"?this.options.direction.call(this,e,t,y):this.options.direction},_onTapStart:function(e){if(e.cancelable){var t=this,o=this.el,r=this.options,i=r.preventOnFilter,s=e.type,a=e.touches&&e.touches[0]||e.pointerType&&e.pointerType==="touch"&&e,l=(a||e).target,c=e.target.shadowRoot&&(e.path&&e.path[0]||e.composedPath&&e.composedPath()[0])||l,d=r.filter;if(dw(o),!y&&!(/mousedown|pointerdown/.test(s)&&e.button!==0||r.disabled)&&!c.isContentEditable&&!(!this.nativeDraggable&&zt&&l&&l.tagName.toUpperCase()==="SELECT")&&(l=Se(l,r.draggable,o,!1),!(l&&l.animated)&&$n!==l)){if(wt=Te(l),Kt=Te(l,r.draggable),typeof d=="function"){if(d.call(this,e,l,this)){ue({sortable:t,rootEl:c,name:"filter",targetEl:l,toEl:o,fromEl:o}),fe("filter",t,{evt:e}),i&&e.preventDefault();return}}else if(d&&(d=d.split(",").some(function(u){if(u=Se(c,u.trim(),o,!1),u)return ue({sortable:t,rootEl:u,name:"filter",targetEl:l,fromEl:o,toEl:o}),fe("filter",t,{evt:e}),!0}),d)){i&&e.preventDefault();return}r.handle&&!Se(c,r.handle,o,!1)||this._prepareDragStart(e,a,l)}}},_prepareDragStart:function(e,t,o){var r=this,i=r.el,s=r.options,a=i.ownerDocument,l;if(o&&!y&&o.parentNode===i){var c=ee(o);if(Y=i,y=o,q=y.parentNode,et=y.nextSibling,$n=o,Fn=s.group,_.dragged=y,tt={target:y,clientX:(t||e).clientX,clientY:(t||e).clientY},Qa=tt.clientX-c.left,el=tt.clientY-c.top,this._lastX=(t||e).clientX,this._lastY=(t||e).clientY,y.style["will-change"]="all",l=function(){if(fe("delayEnded",r,{evt:e}),_.eventCanceled){r._onDrop();return}r._disableDelayedDragEvents(),!ja&&r.nativeDraggable&&(y.draggable=!0),r._triggerDragStart(e,t),ue({sortable:r,name:"choose",originalEvent:e}),me(y,s.chosenClass,!0)},s.ignore.split(",").forEach(function(d){Ga(y,d.trim(),Zr)}),H(a,"dragover",nt),H(a,"mousemove",nt),H(a,"touchmove",nt),s.supportPointer?(H(a,"pointerup",r._onDrop),!this.nativeDraggable&&H(a,"pointercancel",r._onDrop)):(H(a,"mouseup",r._onDrop),H(a,"touchend",r._onDrop),H(a,"touchcancel",r._onDrop)),ja&&this.nativeDraggable&&(this.options.touchStartThreshold=4,y.draggable=!0),fe("delayStart",this,{evt:e}),s.delay&&(!s.delayOnTouchOnly||t)&&(!this.nativeDraggable||!(jt||$e))){if(_.eventCanceled){this._onDrop();return}s.supportPointer?(H(a,"pointerup",r._disableDelayedDrag),H(a,"pointercancel",r._disableDelayedDrag)):(H(a,"mouseup",r._disableDelayedDrag),H(a,"touchend",r._disableDelayedDrag),H(a,"touchcancel",r._disableDelayedDrag)),H(a,"mousemove",r._delayedDragTouchMoveHandler),H(a,"touchmove",r._delayedDragTouchMoveHandler),s.supportPointer&&H(a,"pointermove",r._delayedDragTouchMoveHandler),r._dragStartTimer=setTimeout(l,s.delay)}else l()}},_delayedDragTouchMoveHandler:function(e){var t=e.touches?e.touches[0]:e;Math.max(Math.abs(t.clientX-this._lastX),Math.abs(t.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){y&&Zr(y),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var e=this.el.ownerDocument;D(e,"mouseup",this._disableDelayedDrag),D(e,"touchend",this._disableDelayedDrag),D(e,"touchcancel",this._disableDelayedDrag),D(e,"pointerup",this._disableDelayedDrag),D(e,"pointercancel",this._disableDelayedDrag),D(e,"mousemove",this._delayedDragTouchMoveHandler),D(e,"touchmove",this._delayedDragTouchMoveHandler),D(e,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(e,t){t=t||e.pointerType=="touch"&&e,!this.nativeDraggable||t?this.options.supportPointer?H(document,"pointermove",this._onTouchMove):t?H(document,"touchmove",this._onTouchMove):H(document,"mousemove",this._onTouchMove):(H(y,"dragend",this),H(Y,"dragstart",this._onDragStart));try{document.selection?Xn(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(e,t){if(Ct=!1,Y&&y){fe("dragStarted",this,{evt:t}),this.nativeDraggable&&H(document,"dragover",nw);var o=this.options;!e&&me(y,o.dragClass,!1),me(y,o.ghostClass,!0),_.active=this,e&&this._appendGhost(),ue({sortable:this,name:"start",originalEvent:t})}else this._nulling()},_emulateDragOver:function(){if(xe){this._lastX=xe.clientX,this._lastY=xe.clientY,il();for(var e=document.elementFromPoint(xe.clientX,xe.clientY),t=e;e&&e.shadowRoot&&(e=e.shadowRoot.elementFromPoint(xe.clientX,xe.clientY),e!==t);)t=e;if(y.parentNode[he]._isOutsideThisEl(e),t)do{if(t[he]){var o=void 0;if(o=t[he]._onDragOver({clientX:xe.clientX,clientY:xe.clientY,target:e,rootEl:t}),o&&!this.options.dragoverBubble)break}e=t}while(t=Ua(t));sl()}},_onTouchMove:function(e){if(tt){var t=this.options,o=t.fallbackTolerance,r=t.fallbackOffset,i=e.touches?e.touches[0]:e,s=O&&Et(O,!0),a=O&&s&&s.a,l=O&&s&&s.d,c=Gn&&le&&Xa(le),d=(i.clientX-tt.clientX+r.x)/(a||1)+(c?c[0]-Vr[0]:0)/(a||1),u=(i.clientY-tt.clientY+r.y)/(l||1)+(c?c[1]-Vr[1]:0)/(l||1);if(!_.active&&!Ct){if(o&&Math.max(Math.abs(i.clientX-this._lastX),Math.abs(i.clientY-this._lastY))<o)return;this._onDragStart(e,!0)}if(O){s?(s.e+=d-(Yr||0),s.f+=u-(Xr||0)):s={a:1,b:0,c:0,d:1,e:d,f:u};var h="matrix(".concat(s.a,",").concat(s.b,",").concat(s.c,",").concat(s.d,",").concat(s.e,",").concat(s.f,")");B(O,"webkitTransform",h),B(O,"mozTransform",h),B(O,"msTransform",h),B(O,"transform",h),Yr=d,Xr=u,xe=i}e.cancelable&&e.preventDefault()}},_appendGhost:function(){if(!O){var e=this.options.fallbackOnBody?document.body:Y,t=ee(y,!0,Gn,!0,e),o=this.options;if(Gn){for(le=e;B(le,"position")==="static"&&B(le,"transform")==="none"&&le!==document;)le=le.parentNode;le!==document.body&&le!==document.documentElement?(le===document&&(le=Oe()),t.top+=le.scrollTop,t.left+=le.scrollLeft):le=Oe(),Vr=Xa(le)}O=y.cloneNode(!0),me(O,o.ghostClass,!1),me(O,o.fallbackClass,!0),me(O,o.dragClass,!0),B(O,"transition",""),B(O,"transform",""),B(O,"box-sizing","border-box"),B(O,"margin",0),B(O,"top",t.top),B(O,"left",t.left),B(O,"width",t.width),B(O,"height",t.height),B(O,"opacity","0.8"),B(O,"position",Gn?"absolute":"fixed"),B(O,"zIndex","100000"),B(O,"pointerEvents","none"),_.ghost=O,e.appendChild(O),B(O,"transform-origin",Qa/parseInt(O.style.width)*100+"% "+el/parseInt(O.style.height)*100+"%")}},_onDragStart:function(e,t){var o=this,r=e.dataTransfer,i=o.options;if(fe("dragStart",this,{evt:e}),_.eventCanceled){this._onDrop();return}fe("setupClone",this),_.eventCanceled||(V=Za(y),V.removeAttribute("id"),V.draggable=!1,V.style["will-change"]="",this._hideClone(),me(V,this.options.chosenClass,!1),_.clone=V),o.cloneId=Xn(function(){fe("clone",o),!_.eventCanceled&&(o.options.removeCloneOnHide||Y.insertBefore(V,y),o._hideClone(),ue({sortable:o,name:"clone"}))}),!t&&me(y,i.dragClass,!0),t?(Hn=!0,o._loopId=setInterval(o._emulateDragOver,50)):(D(document,"mouseup",o._onDrop),D(document,"touchend",o._onDrop),D(document,"touchcancel",o._onDrop),r&&(r.effectAllowed="move",i.setData&&i.setData.call(o,r,y)),H(document,"drop",o),B(y,"transform","translateZ(0)")),Ct=!0,o._dragStartId=Xn(o._dragStarted.bind(o,t,e)),H(document,"selectstart",o),Gt=!0,window.getSelection().removeAllRanges(),zt&&B(document.body,"user-select","none")},_onDragOver:function(e){var t=this.el,o=e.target,r,i,s,a=this.options,l=a.group,c=_.active,d=Fn===l,u=a.sort,h=ie||c,g,f=this,m=!1;if(qr)return;function b(be,Jt){fe(be,f,Ie({evt:e,isOwner:d,axis:g?"vertical":"horizontal",revert:s,dragRect:r,targetRect:i,canSort:u,fromSortable:h,target:o,completed:k,onMove:function(to,no){return Yn(Y,t,y,r,to,ee(to),e,no)},changed:N},Jt))}function E(){b("dragOverAnimationCapture"),f.captureAnimationState(),f!==h&&h.captureAnimationState()}function k(be){return b("dragOverCompleted",{insertion:be}),be&&(d?c._hideClone():c._showClone(f),f!==h&&(me(y,ie?ie.options.ghostClass:c.options.ghostClass,!1),me(y,a.ghostClass,!0)),ie!==f&&f!==_.active?ie=f:f===_.active&&ie&&(ie=null),h===f&&(f._ignoreWhileAnimating=o),f.animateAll(function(){b("dragOverAnimationComplete"),f._ignoreWhileAnimating=null}),f!==h&&(h.animateAll(),h._ignoreWhileAnimating=null)),(o===y&&!y.animated||o===t&&!o.animated)&&(St=null),!a.dragoverBubble&&!e.rootEl&&o!==document&&(y.parentNode[he]._isOutsideThisEl(e.target),!be&&nt(e)),!a.dragoverBubble&&e.stopPropagation&&e.stopPropagation(),m=!0}function N(){ve=Te(y),Ke=Te(y,a.draggable),ue({sortable:f,name:"change",toEl:t,newIndex:ve,newDraggableIndex:Ke,originalEvent:e})}if(e.preventDefault!==void 0&&e.cancelable&&e.preventDefault(),o=Se(o,a.draggable,t,!0),b("dragOver"),_.eventCanceled)return m;if(y.contains(e.target)||o.animated&&o.animatingX&&o.animatingY||f._ignoreWhileAnimating===o)return k(!1);if(Hn=!1,c&&!a.disabled&&(d?u||(s=q!==Y):ie===this||(this.lastPutMode=Fn.checkPull(this,c,y,e))&&l.checkPut(this,c,y,e))){if(g=this._getDirection(e,o)==="vertical",r=ee(y),b("dragOverValid"),_.eventCanceled)return m;if(s)return q=Y,E(),this._hideClone(),b("revert"),_.eventCanceled||(et?Y.insertBefore(y,et):Y.appendChild(y)),k(!0);var x=Ur(t,a.draggable);if(!x||sw(e,g,this)&&!x.animated){if(x===y)return k(!1);if(x&&t===e.target&&(o=x),o&&(i=ee(o)),Yn(Y,t,y,r,o,i,e,!!o)!==!1)return E(),x&&x.nextSibling?t.insertBefore(y,x.nextSibling):t.appendChild(y),q=t,N(),k(!0)}else if(x&&iw(e,g,this)){var P=Tt(t,0,a,!0);if(P===y)return k(!1);if(o=P,i=ee(o),Yn(Y,t,y,r,o,i,e,!1)!==!1)return E(),t.insertBefore(y,P),q=t,N(),k(!0)}else if(o.parentNode===t){i=ee(o);var I=0,X,C=y.parentNode!==t,T=!ew(y.animated&&y.toRect||r,o.animated&&o.toRect||i,g),A=g?"top":"left",R=Ya(o,"top","top")||Ya(y,"top","top"),z=R?R.scrollTop:void 0;St!==o&&(X=i[A],Xt=!1,zn=!T&&a.invertSwap||C),I=aw(e,o,i,g,T?1:a.swapThreshold,a.invertedSwapThreshold==null?a.swapThreshold:a.invertedSwapThreshold,zn,St===o);var L;if(I!==0){var K=Te(y);do K-=I,L=q.children[K];while(L&&(B(L,"display")==="none"||L===O))}if(I===0||L===o)return k(!1);St=o,Yt=I;var M=o.nextElementSibling,Z=!1;Z=I===1;var Ne=Yn(Y,t,y,r,o,i,e,Z);if(Ne!==!1)return(Ne===1||Ne===-1)&&(Z=Ne===1),qr=!0,setTimeout(rw,30),E(),Z&&!M?t.appendChild(y):o.parentNode.insertBefore(y,Z?M:o),R&&qa(R,0,z-R.scrollTop),q=y.parentNode,X!==void 0&&!zn&&(Wn=Math.abs(X-ee(o)[A])),N(),k(!0)}if(t.contains(y))return k(!1)}return!1},_ignoreWhileAnimating:null,_offMoveEvents:function(){D(document,"mousemove",this._onTouchMove),D(document,"touchmove",this._onTouchMove),D(document,"pointermove",this._onTouchMove),D(document,"dragover",nt),D(document,"mousemove",nt),D(document,"touchmove",nt)},_offUpEvents:function(){var e=this.el.ownerDocument;D(e,"mouseup",this._onDrop),D(e,"touchend",this._onDrop),D(e,"pointerup",this._onDrop),D(e,"pointercancel",this._onDrop),D(e,"touchcancel",this._onDrop),D(document,"selectstart",this)},_onDrop:function(e){var t=this.el,o=this.options;if(ve=Te(y),Ke=Te(y,o.draggable),fe("drop",this,{evt:e}),q=y&&y.parentNode,ve=Te(y),Ke=Te(y,o.draggable),_.eventCanceled){this._nulling();return}Ct=!1,zn=!1,Xt=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),Jr(this.cloneId),Jr(this._dragStartId),this.nativeDraggable&&(D(document,"drop",this),D(t,"dragstart",this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),zt&&B(document.body,"user-select",""),B(y,"transform",""),e&&(Gt&&(e.cancelable&&e.preventDefault(),!o.dropBubble&&e.stopPropagation()),O&&O.parentNode&&O.parentNode.removeChild(O),(Y===q||ie&&ie.lastPutMode!=="clone")&&V&&V.parentNode&&V.parentNode.removeChild(V),y&&(this.nativeDraggable&&D(y,"dragend",this),Zr(y),y.style["will-change"]="",Gt&&!Ct&&me(y,ie?ie.options.ghostClass:this.options.ghostClass,!1),me(y,this.options.chosenClass,!1),ue({sortable:this,name:"unchoose",toEl:q,newIndex:null,newDraggableIndex:null,originalEvent:e}),Y!==q?(ve>=0&&(ue({rootEl:q,name:"add",toEl:q,fromEl:Y,originalEvent:e}),ue({sortable:this,name:"remove",toEl:q,originalEvent:e}),ue({rootEl:q,name:"sort",toEl:q,fromEl:Y,originalEvent:e}),ue({sortable:this,name:"sort",toEl:q,originalEvent:e})),ie&&ie.save()):ve!==wt&&ve>=0&&(ue({sortable:this,name:"update",toEl:q,originalEvent:e}),ue({sortable:this,name:"sort",toEl:q,originalEvent:e})),_.active&&((ve==null||ve===-1)&&(ve=wt,Ke=Kt),ue({sortable:this,name:"end",toEl:q,originalEvent:e}),this.save()))),this._nulling()},_nulling:function(){fe("nulling",this),Y=y=q=O=et=V=$n=Ue=tt=xe=Gt=ve=Ke=wt=Kt=St=Yt=ie=Fn=_.dragged=_.ghost=_.clone=_.active=null,Un.forEach(function(e){e.checked=!0}),Un.length=Yr=Xr=0},handleEvent:function(e){switch(e.type){case"drop":case"dragend":this._onDrop(e);break;case"dragenter":case"dragover":y&&(this._onDragOver(e),ow(e));break;case"selectstart":e.preventDefault();break}},toArray:function(){for(var e=[],t,o=this.el.children,r=0,i=o.length,s=this.options;r<i;r++)t=o[r],Se(t,s.draggable,this.el,!1)&&e.push(t.getAttribute(s.dataIdAttr)||cw(t));return e},sort:function(e,t){var o={},r=this.el;this.toArray().forEach(function(i,s){var a=r.children[s];Se(a,this.options.draggable,r,!1)&&(o[i]=a)},this),t&&this.captureAnimationState(),e.forEach(function(i){o[i]&&(r.removeChild(o[i]),r.appendChild(o[i]))}),t&&this.animateAll()},save:function(){var e=this.options.store;e&&e.set&&e.set(this)},closest:function(e,t){return Se(e,t||this.options.draggable,this.el,!1)},option:function(e,t){var o=this.options;if(t===void 0)return o[e];var r=Ut.modifyOption(this,e,t);typeof r<"u"?o[e]=r:o[e]=t,e==="group"&&rl(o)},destroy:function(){fe("destroy",this);var e=this.el;e[he]=null,D(e,"mousedown",this._onTapStart),D(e,"touchstart",this._onTapStart),D(e,"pointerdown",this._onTapStart),this.nativeDraggable&&(D(e,"dragover",this),D(e,"dragenter",this)),Array.prototype.forEach.call(e.querySelectorAll("[draggable]"),function(t){t.removeAttribute("draggable")}),this._onDrop(),this._disableDelayedDragEvents(),jn.splice(jn.indexOf(this.el),1),this.el=e=null},_hideClone:function(){if(!Ue){if(fe("hideClone",this),_.eventCanceled)return;B(V,"display","none"),this.options.removeCloneOnHide&&V.parentNode&&V.parentNode.removeChild(V),Ue=!0}},_showClone:function(e){if(e.lastPutMode!=="clone"){this._hideClone();return}if(Ue){if(fe("showClone",this),_.eventCanceled)return;y.parentNode==Y&&!this.options.group.revertClone?Y.insertBefore(V,y):et?Y.insertBefore(V,et):Y.appendChild(V),this.options.group.revertClone&&this.animate(y,V),B(V,"display",""),Ue=!1}}};function ow(n){n.dataTransfer&&(n.dataTransfer.dropEffect="move"),n.cancelable&&n.preventDefault()}function Yn(n,e,t,o,r,i,s,a){var l,c=n[he],d=c.options.onMove,u;return window.CustomEvent&&!$e&&!jt?l=new CustomEvent("move",{bubbles:!0,cancelable:!0}):(l=document.createEvent("Event"),l.initEvent("move",!0,!0)),l.to=e,l.from=n,l.dragged=t,l.draggedRect=o,l.related=r||e,l.relatedRect=i||ee(e),l.willInsertAfter=a,l.originalEvent=s,n.dispatchEvent(l),d&&(u=d.call(c,l,s)),u}function Zr(n){n.draggable=!1}function rw(){qr=!1}function iw(n,e,t){var o=ee(Tt(t.el,0,t.options,!0)),r=Ja(t.el,t.options,O),i=10;return e?n.clientX<r.left-i||n.clientY<o.top&&n.clientX<o.right:n.clientY<r.top-i||n.clientY<o.bottom&&n.clientX<o.left}function sw(n,e,t){var o=ee(Ur(t.el,t.options.draggable)),r=Ja(t.el,t.options,O),i=10;return e?n.clientX>r.right+i||n.clientY>o.bottom&&n.clientX>o.left:n.clientY>r.bottom+i||n.clientX>o.right&&n.clientY>o.top}function aw(n,e,t,o,r,i,s,a){var l=o?n.clientY:n.clientX,c=o?t.height:t.width,d=o?t.top:t.left,u=o?t.bottom:t.right,h=!1;if(!s){if(a&&Wn<c*r){if(!Xt&&(Yt===1?l>d+c*i/2:l<u-c*i/2)&&(Xt=!0),Xt)h=!0;else if(Yt===1?l<d+Wn:l>u-Wn)return-Yt}else if(l>d+c*(1-r)/2&&l<u-c*(1-r)/2)return lw(e)}return h=h||s,h&&(l<d+c*i/2||l>u-c*i/2)?l>d+c/2?1:-1:0}function lw(n){return Te(y)<Te(n)?1:-1}function cw(n){for(var e=n.tagName+n.className+n.src+n.href+n.textContent,t=e.length,o=0;t--;)o+=e.charCodeAt(t);return o.toString(36)}function dw(n){Un.length=0;for(var e=n.getElementsByTagName("input"),t=e.length;t--;){var o=e[t];o.checked&&Un.push(o)}}function Xn(n){return setTimeout(n,0)}function Jr(n){return clearTimeout(n)}Kn&&H(document,"touchmove",function(n){(_.active||Ct)&&n.cancelable&&n.preventDefault()}),_.utils={on:H,off:D,css:B,find:Ga,is:function(e,t){return!!Se(e,t,e,!1)},extend:Gk,throttle:Va,closest:Se,toggleClass:me,clone:Za,index:Te,nextTick:Xn,cancelNextTick:Jr,detectDirection:ol,getChild:Tt,expando:he},_.get=function(n){return n[he]},_.mount=function(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];e[0].constructor===Array&&(e=e[0]),e.forEach(function(o){if(!o.prototype||!o.prototype.constructor)throw"Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(o));o.utils&&(_.utils=Ie(Ie({},_.utils),o.utils)),Ut.mount(o)})},_.create=function(n,e){return new _(n,e)},_.version=Uk;var te=[],Vt,Qr,ei=!1,ti,ni,Vn,qt;function uw(){function n(){this.defaults={scroll:!0,forceAutoScrollFallback:!1,scrollSensitivity:30,scrollSpeed:10,bubbleScroll:!0};for(var e in this)e.charAt(0)==="_"&&typeof this[e]=="function"&&(this[e]=this[e].bind(this))}return n.prototype={dragStarted:function(t){var o=t.originalEvent;this.sortable.nativeDraggable?H(document,"dragover",this._handleAutoScroll):this.options.supportPointer?H(document,"pointermove",this._handleFallbackAutoScroll):o.touches?H(document,"touchmove",this._handleFallbackAutoScroll):H(document,"mousemove",this._handleFallbackAutoScroll)},dragOverCompleted:function(t){var o=t.originalEvent;!this.options.dragOverBubble&&!o.rootEl&&this._handleAutoScroll(o)},drop:function(){this.sortable.nativeDraggable?D(document,"dragover",this._handleAutoScroll):(D(document,"pointermove",this._handleFallbackAutoScroll),D(document,"touchmove",this._handleFallbackAutoScroll),D(document,"mousemove",this._handleFallbackAutoScroll)),al(),qn(),Yk()},nulling:function(){Vn=Qr=Vt=ei=qt=ti=ni=null,te.length=0},_handleFallbackAutoScroll:function(t){this._handleAutoScroll(t,!0)},_handleAutoScroll:function(t,o){var r=this,i=(t.touches?t.touches[0]:t).clientX,s=(t.touches?t.touches[0]:t).clientY,a=document.elementFromPoint(i,s);if(Vn=t,o||this.options.forceAutoScrollFallback||jt||$e||zt){oi(t,this.options,a,o);var l=We(a,!0);ei&&(!qt||i!==ti||s!==ni)&&(qt&&al(),qt=setInterval(function(){var c=We(document.elementFromPoint(i,s),!0);c!==l&&(l=c,qn()),oi(t,r.options,c,o)},10),ti=i,ni=s)}else{if(!this.options.bubbleScroll||We(a,!0)===Oe()){qn();return}oi(t,this.options,We(a,!1),!1)}}},Me(n,{pluginName:"scroll",initializeByDefault:!0})}function qn(){te.forEach(function(n){clearInterval(n.pid)}),te=[]}function al(){clearInterval(qt)}var oi=Va(function(n,e,t,o){if(e.scroll){var r=(n.touches?n.touches[0]:n).clientX,i=(n.touches?n.touches[0]:n).clientY,s=e.scrollSensitivity,a=e.scrollSpeed,l=Oe(),c=!1,d;Qr!==t&&(Qr=t,qn(),Vt=e.scroll,d=e.scrollFn,Vt===!0&&(Vt=We(t,!0)));var u=0,h=Vt;do{var g=h,f=ee(g),m=f.top,b=f.bottom,E=f.left,k=f.right,N=f.width,x=f.height,P=void 0,I=void 0,X=g.scrollWidth,C=g.scrollHeight,T=B(g),A=g.scrollLeft,R=g.scrollTop;g===l?(P=N<X&&(T.overflowX==="auto"||T.overflowX==="scroll"||T.overflowX==="visible"),I=x<C&&(T.overflowY==="auto"||T.overflowY==="scroll"||T.overflowY==="visible")):(P=N<X&&(T.overflowX==="auto"||T.overflowX==="scroll"),I=x<C&&(T.overflowY==="auto"||T.overflowY==="scroll"));var z=P&&(Math.abs(k-r)<=s&&A+N<X)-(Math.abs(E-r)<=s&&!!A),L=I&&(Math.abs(b-i)<=s&&R+x<C)-(Math.abs(m-i)<=s&&!!R);if(!te[u])for(var K=0;K<=u;K++)te[K]||(te[K]={});(te[u].vx!=z||te[u].vy!=L||te[u].el!==g)&&(te[u].el=g,te[u].vx=z,te[u].vy=L,clearInterval(te[u].pid),(z!=0||L!=0)&&(c=!0,te[u].pid=setInterval(function(){o&&this.layer===0&&_.active._onTouchMove(Vn);var M=te[this.layer].vy?te[this.layer].vy*a:0,Z=te[this.layer].vx?te[this.layer].vx*a:0;typeof d=="function"&&d.call(_.dragged.parentNode[he],Z,M,n,Vn,te[this.layer].el)!=="continue"||qa(te[this.layer].el,Z,M)}.bind({layer:u}),24))),u++}while(e.bubbleScroll&&h!==l&&(h=We(h,!1)));ei=c}},30),ll=function(e){var t=e.originalEvent,o=e.putSortable,r=e.dragEl,i=e.activeSortable,s=e.dispatchSortableEvent,a=e.hideGhostForTarget,l=e.unhideGhostForTarget;if(t){var c=o||i;a();var d=t.changedTouches&&t.changedTouches.length?t.changedTouches[0]:t,u=document.elementFromPoint(d.clientX,d.clientY);l(),c&&!c.el.contains(u)&&(s("spill"),this.onSpill({dragEl:r,putSortable:o}))}};function ri(){}ri.prototype={startIndex:null,dragStart:function(e){var t=e.oldDraggableIndex;this.startIndex=t},onSpill:function(e){var t=e.dragEl,o=e.putSortable;this.sortable.captureAnimationState(),o&&o.captureAnimationState();var r=Tt(this.sortable.el,this.startIndex,this.options);r?this.sortable.el.insertBefore(t,r):this.sortable.el.appendChild(t),this.sortable.animateAll(),o&&o.animateAll()},drop:ll},Me(ri,{pluginName:"revertOnSpill"});function ii(){}ii.prototype={onSpill:function(e){var t=e.dragEl,o=e.putSortable,r=o||this.sortable;r.captureAnimationState(),t.parentNode&&t.parentNode.removeChild(t),r.animateAll()},drop:ll},Me(ii,{pluginName:"removeOnSpill"}),_.mount(new uw),_.mount(ii,ri);const cl="block-removed",hw="block-added",fw="block-moved",dl="block-changed";class ul{constructor(){this.tail=Promise.resolve()}get completed(){return this.failure?Promise.reject(this.failure):this.tail}add(e){if(this.failure)return Promise.reject(this.failure);const t=this.tail.then(()=>e());return this.tail=t.catch(o=>{this.failure=o}),t}}class pw extends F{constructor(){super(...arguments),this._currentBlockIndex=-1,this._blocks=null,this.sortable=null}get currentBlockIndex(){return this._currentBlockIndex}set currentBlockIndex(e){this._currentBlockIndex=e}get firstBlock(){return this.blocksStore[0]}get lastBlock(){return this.blocksStore[this.blocksStore.length-1]}get currentBlock(){return this.blocksStore[this.currentBlockIndex]}set currentBlock(e){if(e===void 0){this.unsetCurrentBlock();return}this.currentBlockIndex=this.getBlockIndex(e)}get nextBlock(){return this.currentBlockIndex===this.blocksStore.length-1?null:this.blocksStore[this.currentBlockIndex+1]??null}get nextContentfulBlock(){return this.blocks.slice(this.currentBlockIndex+1).find(t=>!!t.inputs.length)}get previousContentfulBlock(){return this.blocks.slice(0,this.currentBlockIndex).reverse().find(t=>!!t.inputs.length)}get previousBlock(){return this.currentBlockIndex===0?null:this.blocksStore[this.currentBlockIndex-1]??null}get blocks(){return this.blocksStore.array}get isEditorEmpty(){return this.blocks.every(e=>e.isEmpty)}prepare(){const e=new zr(this.Editor.UI.nodes.redactor);this._blocks=new Proxy(e,{set:zr.set,get:zr.get}),this.listeners.on(document,"copy",t=>{this.Editor.BlockEvents.handleCommandC(t)}),this.sortable=new _(this.Editor.UI.nodes.redactor,{animation:150,forceFallback:!0,handle:`.${this.Editor.Toolbar.CSS.settingsToggler}`,onStart:()=>{this.Editor.UI.nodes.wrapper.classList.add(this.Editor.UI.CSS.editorDragging),Pt(!0)},onEnd:t=>{this.Editor.UI.nodes.wrapper.classList.remove(this.Editor.UI.CSS.editorDragging),!(t.newIndex===void 0||t.oldIndex===void 0)&&this.move(t.newIndex,t.oldIndex,!0)}})}toggleReadOnly(e){e?this.disableModuleBindings():this.enableModuleBindings()}composeBlock({tool:e,data:t={},id:o=void 0,tunes:r={}}){const i=this.Editor.ReadOnly.isEnabled,s=this.Editor.Tools.blockTools.get(e);if(s===void 0)throw new Error(`Could not compose Block. Tool «${e}» not found.`);const a=new re({id:o,data:t,tool:s,api:this.Editor.API,readOnly:i,tunesData:r},this.eventsDispatcher);return i||window.requestIdleCallback(()=>{this.bindBlockEvents(a)},{timeout:2e3}),a}insert({id:e=void 0,tool:t,data:o,index:r,needToFocus:i=!0,replace:s=!1,tunes:a}={}){const l=r??this.currentBlockIndex+(s?0:1),c=t??this.config.defaultBlock;if(c===void 0)throw new Error("Could not insert Block. Tool name is not specified.");const d={tool:c};e!==void 0&&(d.id=e),o!==void 0&&(d.data=o),a!==void 0&&(d.tunes=a);const u=this.composeBlock(d),h=s?this.getBlockByIndex(l):void 0;if(s&&h===void 0)throw new Error(`Could not replace Block at index ${l}. Block not found.`);return s&&h!==void 0&&this.blockDidMutated(cl,h,{index:l}),this.blocksStore.insert(l,u,s),this.blockDidMutated(hw,u,{index:l}),i&&(this.currentBlockIndex=l),!i&&l<=this.currentBlockIndex&&this.currentBlockIndex++,u}insertMany(e,t=0){this.blocksStore.insertMany(e,t)}async update(e,t,o){if(!t&&!o)return e;const r=await e.data,i=this.composeBlock({id:e.id,tool:e.name,data:Object.assign({},r,t??{}),tunes:o??e.tunes}),s=this.getBlockIndex(e);return this.blocksStore.replace(s,i),this.blockDidMutated(dl,i,{index:s}),i}replace(e,t,o){const r=this.getBlockIndex(e);return this.insert({tool:t,data:o,index:r,replace:!0})}get blocksStore(){if(this._blocks===null)throw new Error("BlockManager: blocks store is not initialized. Call prepare() before accessing blocks.");return this._blocks}paste(e,t,o=!1){const r=this.insert({tool:e,replace:o});try{window.requestIdleCallback(()=>{r.call(Pe.ON_PASTE,t)})}catch(i){$(`${e}: onPaste callback call is failed`,"error",i)}return r}insertDefaultBlockAtIndex(e,t=!1){const o=this.config.defaultBlock;if(o===void 0)throw new Error("Could not insert default Block. Default block tool is not defined in the configuration.");return this.insert({tool:o,index:e,needToFocus:t})}insertAtEnd(){return this.currentBlockIndex=this.blocks.length-1,this.insert()}async mergeBlocks(e,t){const o=async s=>{await e.mergeWith(s),await this.removeBlock(t),this.currentBlockIndex=this.blocksStore.indexOf(e)},r=e.name===t.name&&e.mergeable,i=r?await t.data:void 0;if(r&&Q(i)){console.error("Could not merge Block. Failed to extract original Block data.");return}if(r&&i!==void 0){const[s]=Oo([{data:i,tool:t.name}],e.tool.sanitizeConfig,this.config.sanitizer);await o(s.data);return}if(e.mergeable&&vn(t,"export")&&vn(e,"import")){const s=await t.exportDataAsString(),a=Ae(s,e.tool.sanitizeConfig),l=Gs(a,e.tool.conversionConfig);await o(l)}}removeBlock(e,t=!0){return new Promise(o=>{const r=this.blocksStore.indexOf(e);if(!this.validateIndex(r))throw new Error("Can't find a Block to remove");this.blocksStore.remove(r),e.destroy(),this.blockDidMutated(cl,e,{index:r}),this.currentBlockIndex>=r&&this.currentBlockIndex--;const i=this.blocks.length===0;i&&this.unsetCurrentBlock(),i&&t&&this.insert(),!i&&r===0&&(this.currentBlockIndex=0),o()})}removeSelectedBlocks(){const e=this.blocks.map((t,o)=>({block:t,index:o})).filter(({block:t})=>t.selected).sort((t,o)=>o.index-t.index);return e.forEach(({block:t})=>{this.removeBlock(t,!1)}),e.length>0?e[e.length-1].index:void 0}removeAllBlocks(){const e=r=>{r<0||(this.blocksStore.remove(r),e(r-1))};e(this.blocksStore.length-1),this.unsetCurrentBlock(),this.insert();const t=this.currentBlock,o=t==null?void 0:t.firstInput;o!==void 0&&o.focus()}split(){const e=this.Editor.Caret.extractFragmentFromCaretPosition(),t=v.make("div");t.appendChild(e);const o={text:v.isEmpty(t)?"":t.innerHTML};return this.insert({data:o})}getBlockByIndex(e){const t=e===-1?this.blocksStore.length-1:e;return this.blocksStore[t]}getBlockIndex(e){return this.blocksStore.indexOf(e)}getBlockById(e){return this.blocksStore.array.find(t=>t.id===e)}getBlock(e){const t=v.isElement(e)?e:e.parentNode;if(!t)return;const o=this.blocksStore.nodes,r=t.closest(`.${re.CSS.wrapper}`);if(!r)return;const i=o.indexOf(r);if(i>=0)return this.blocksStore[i]}setCurrentBlockByChildNode(e){const t=v.isElement(e)?e:e.parentNode;if(!t)return;const o=t.closest(`.${re.CSS.wrapper}`);if(!o)return;const r=o.closest(`.${this.Editor.UI.CSS.editorWrapper}`);if(!(r==null?void 0:r.isEqualNode(this.Editor.UI.nodes.wrapper))||!(o instanceof HTMLElement))return;this.currentBlockIndex=this.blocksStore.nodes.indexOf(o);const s=this.currentBlock;return s==null||s.updateCurrentInput(),s}getBlockByChildNode(e){if(!(e instanceof Node))return;const t=v.isElement(e)?e:e.parentNode;if(!t)return;const o=t.closest(`.${re.CSS.wrapper}`);if(o)return this.blocks.find(r=>r.holder===o)}move(e,t=this.currentBlockIndex,o=!1){if(isNaN(e)||isNaN(t)){$("Warning during 'move' call: incorrect indices provided.","warn");return}if(!this.validateIndex(e)||!this.validateIndex(t)){$("Warning during 'move' call: indices cannot be lower than 0 or greater than the amount of blocks.","warn");return}this.blocksStore.move(e,t,o),this.currentBlockIndex=e;const r=this.currentBlock;if(r===void 0)throw new Error(`Could not move Block. Block at index ${e} is not available.`);this.blockDidMutated(fw,r,{fromIndex:t,toIndex:e})}async convert(e,t,o){const r=await e.save();if(!r||r.data===void 0)throw new Error("Could not convert Block. Failed to extract original Block data.");const i=this.Editor.Tools.blockTools.get(t);if(!i)throw new Error(`Could not convert Block. Tool «${t}» not found.`);const s=await e.exportDataAsString(),a=Ae(s,Po(this.config.sanitizer,i.sanitizeConfig)),l=Gs(a,i.conversionConfig,i.settings),c=o?Object.assign(l,o):l;return this.replace(e,i.name,c)}unsetCurrentBlock(){this.currentBlockIndex=-1}async clear(e=!1){const t=new ul;[...this.blocks].forEach(r=>{t.add(async()=>{await this.removeBlock(r,!1)})}),await t.completed,this.unsetCurrentBlock(),e&&this.insert(),this.Editor.UI.checkEmptiness()}async destroy(){this.sortable&&(this.sortable.destroy(),this.sortable=null),await Promise.all(this.blocks.map(e=>e.destroy()))}bindBlockEvents(e){const{BlockEvents:t}=this.Editor;this.readOnlyMutableListeners.on(e.holder,"keydown",o=>{o instanceof KeyboardEvent&&t.keydown(o)}),this.readOnlyMutableListeners.on(e.holder,"keyup",o=>{o instanceof KeyboardEvent&&t.keyup(o)}),e.on("didMutated",o=>this.blockDidMutated(dl,o,{index:this.getBlockIndex(o)}))}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.blocksStore.length)}blockDidMutated(e,t,o){const r={target:new Le(t),...o},i=new CustomEvent(e,{detail:{...r}});return Object.prototype.propertyIsEnumerable.call(i,"type")||Object.defineProperty(i,"type",{value:e,enumerable:!0,configurable:!0}),Object.prototype.propertyIsEnumerable.call(i,"detail")||Object.defineProperty(i,"detail",{value:r,enumerable:!0,configurable:!0}),this.eventsDispatcher.emit(Hs,{event:i}),t}}class gw extends F{constructor(){super(...arguments),this.anyBlockSelectedCache=null,this.needToSelectAll=!1,this.nativeInputSelected=!1,this.readyToBlockSelection=!1,this.selection=new w}get sanitizerConfig(){const e={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:{}};return Po(this.config.sanitizer,e)}get allBlocksSelected(){const{BlockManager:e}=this.Editor;return e.blocks.every(t=>t.selected===!0)}set allBlocksSelected(e){const{BlockManager:t}=this.Editor;for(const o of t.blocks)o.selected=e;this.clearCache()}get anyBlockSelected(){const{BlockManager:e}=this.Editor;return this.anyBlockSelectedCache===null&&(this.anyBlockSelectedCache=e.blocks.some(t=>t.selected===!0)),this.anyBlockSelectedCache}get selectedBlocks(){return this.Editor.BlockManager.blocks.filter(e=>e.selected)}prepare(){this.selection=new w,bt.add({name:"CMD+A",handler:e=>{const{BlockManager:t,ReadOnly:o}=this.Editor;if(o.isEnabled){e.preventDefault(),this.selectAllBlocks();return}t.currentBlock&&this.handleCommandA(e)},on:this.Editor.UI.nodes.redactor})}toggleReadOnly(){const e=w.get();e==null||e.removeAllRanges(),this.allBlocksSelected=!1}unSelectBlockByIndex(e){const{BlockManager:t}=this.Editor,o=typeof e=="number"?t.getBlockByIndex(e):t.currentBlock;o&&(o.selected=!1,this.clearCache())}clearSelection(e,t=!1){const{RectangleSelection:o}=this.Editor;this.needToSelectAll=!1,this.nativeInputSelected=!1,this.readyToBlockSelection=!1;const r=e&&e instanceof KeyboardEvent,i=e,s=r&&i.key&&i.key.length===1;if(this.anyBlockSelected&&r&&s&&!w.isSelectionExists&&this.replaceSelectedBlocksWithPrintableKey(e),this.Editor.CrossBlockSelection.clear(e),t&&this.selection.restore(),!this.anyBlockSelected||o.isRectActivated()){this.Editor.RectangleSelection.clearSelection();return}this.allBlocksSelected=!1}async copySelectedBlocks(e){e.preventDefault();const t=e.clipboardData;if(!t)return;const o=v.make("div"),r=[];this.selectedBlocks.forEach(a=>{const l=Ae(a.holder.innerHTML,this.sanitizerConfig),c=v.make("div");c.innerHTML=l;const d=c.textContent??"";if(r.push(d),!Array.from(c.childNodes).some(g=>g.nodeType===Node.ELEMENT_NODE)&&d.trim().length>0){const g=v.make("p");g.innerHTML=c.innerHTML,o.appendChild(g)}else for(;c.firstChild;)o.appendChild(c.firstChild)});const i=r.join(`
30
+
31
+ `),s=o.innerHTML;t.setData("text/plain",i),t.setData("text/html",s);try{const a=await Promise.all(this.selectedBlocks.map(l=>l.save()));t.setData(this.Editor.Paste.MIME_TYPE,JSON.stringify(a))}catch{}}selectBlockByIndex(e){const{BlockManager:t}=this.Editor,o=t.getBlockByIndex(e);o!==void 0&&this.selectBlock(o)}selectBlock(e){this.selection.save();const t=w.get();t==null||t.removeAllRanges();const o=e;o.selected=!0,this.clearCache(),this.Editor.InlineToolbar.close()}unselectBlock(e){const t=e;t.selected=!1,this.clearCache()}clearCache(){this.anyBlockSelectedCache=null}destroy(){bt.remove(this.Editor.UI.nodes.redactor,"CMD+A")}handleCommandA(e){if(this.Editor.RectangleSelection.clearSelection(),v.isNativeInput(e.target)&&!this.readyToBlockSelection){this.readyToBlockSelection=!0;return}const t=this.Editor.BlockManager.getBlock(e.target);if(!t)return;const o=t.inputs;if(o.length>1&&!this.readyToBlockSelection){this.readyToBlockSelection=!0;return}if(o.length===1&&!this.needToSelectAll){this.needToSelectAll=!0;return}if(this.needToSelectAll){e.preventDefault(),this.selectAllBlocks(),this.needToSelectAll=!1,this.readyToBlockSelection=!1;return}this.readyToBlockSelection&&(e.preventDefault(),this.selectBlock(t),this.needToSelectAll=!0)}selectAllBlocks(){this.selection.save();const e=w.get();e==null||e.removeAllRanges(),this.allBlocksSelected=!0,this.Editor.InlineToolbar.close()}replaceSelectedBlocksWithPrintableKey(e){const{BlockManager:t,Caret:o}=this.Editor,r=t.removeSelectedBlocks();if(r===void 0)return;t.insertDefaultBlockAtIndex(r,!0);const i=t.currentBlock;i&&o.setToBlock(i),gn(()=>{const s=e.key;o.insertContentAtCaretPosition(s.length>1?"":s)},20)()}}const mw=127,hl=n=>{for(const e of n){if(e.trim().length===0)continue;if(e>="0"&&e<="9"||e.toLowerCase()!==e.toUpperCase())return!1;const t=e.codePointAt(0);if(typeof t=="number"&&t>mw)return!1}return!0},fl=n=>{var e;return n.nodeType===Node.TEXT_NODE?[n]:(e=n.hasChildNodes)!=null&&e.call(n)?Array.from(n.childNodes).flatMap(t=>fl(t)):[]},vw=n=>{const e=fl(n);if(e.length===0)return null;const t=e[e.length-1],o=[...e].reverse().find(r=>!hl(r.textContent??""))??null;return o&&o!==t&&hl(t.textContent??"")&&o.parentNode!==n?o:t};class Zn extends F{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 u;const{BlockManager:r,BlockSelection:i}=this.Editor;if(i.clearSelection(),!e.focusable){(u=window.getSelection())==null||u.removeAllRanges(),i.selectBlock(e),r.currentBlock=e;return}const a=(()=>t===this.positions.START?e.firstInput:t===this.positions.END?e.lastInput:e.currentInput)();if(!a)return;const l=h=>{if(t===this.positions.START)return{node:v.getDeepestNode(h,!1),offset:0};if(t===this.positions.END)return this.resolveEndPositionNode(h);const{node:g,offset:f}=v.getNodeByOffset(h,o);return g?{node:g,offset:f}:{node:v.getDeepestNode(h,!1),offset:0}},{node:c,offset:d}=l(a);c&&(this.set(c,d),r.setCurrentBlockByChildNode(e.holder),r.currentBlock.currentInput=a)}resolveEndPositionNode(e){const t=v.getDeepestNode(e,!0);if(t instanceof HTMLElement&&v.isNativeInput(t))return{node:t,offset:v.getContentLength(t)};const o=vw(e);return o?{node:o,offset:v.getContentLength(o)}:t?{node:t,offset:v.getContentLength(t)}:{node:null,offset:0}}setToInput(e,t=this.positions.DEFAULT,o=0){const{currentBlock:r}=this.Editor.BlockManager,i=v.getDeepestNode(e);switch(t){case this.positions.START:this.set(i,0);break;case this.positions.END:i&&this.set(i,v.getContentLength(i));break;default:o&&this.set(i,o)}r&&(r.currentInput=e)}set(e,t=0){const{top:r,bottom:i}=w.setCursor(e,t),{innerHeight:s}=window;if(r<0){window.scrollBy(0,r-30);return}i>s&&window.scrollBy(0,i-s+30)}setToTheLastBlock(){const e=this.Editor.BlockManager.lastBlock;if(e)if(e.tool.isDefault&&e.isEmpty)this.setToBlock(e);else{const t=this.Editor.BlockManager.insertAtEnd();this.setToBlock(t)}}extractFragmentFromCaretPosition(){const e=w.get();if(!e||!e.rangeCount)return;const t=e.getRangeAt(0),o=this.Editor.BlockManager.currentBlock;if(!o)return;const r=o.currentInput;if(t.deleteContents(),!r)return;if(v.isNativeInput(r)){const s=r,a=document.createDocumentFragment(),l=s.selectionStart??0,c=s.value.substring(0,l),d=s.value.substring(l);return a.textContent=d,s.value=c,a}const i=t.cloneRange();return i.selectNodeContents(r),i.setStart(t.endContainer,t.endOffset),i.extractContents()}navigateNext(e=!1){const{BlockManager:t}=this.Editor,{currentBlock:o,nextBlock:r}=t;if(o===void 0)return!1;const{nextInput:i,currentInput:s}=o,a=s!==void 0?wn(s):void 0,l=e||a||!o.focusable;if(i&&l)return this.setToInput(i,this.positions.START),!0;const d=(()=>r!==null?r:o.tool.isDefault||!l?null:t.insertAtEnd())();return d!==null&&l?(this.setToBlock(d,this.positions.START),!0):!1}navigatePrevious(e=!1){const{currentBlock:t,previousBlock:o}=this.Editor.BlockManager;if(!t)return!1;const{previousInput:r,currentInput:i}=t,s=i!==void 0?kn(i):void 0,a=e||s||!t.focusable;return r&&a?(this.setToInput(r,this.positions.END),!0):o!==null&&a?(this.setToBlock(o,this.positions.END),!0):!1}createShadow(e){const t=document.createElement("span");t.classList.add(Zn.CSS.shadowCaret),e.insertAdjacentElement("beforeend",t)}restoreCaret(e){const t=e.querySelector(`.${Zn.CSS.shadowCaret}`);if(!t)return;new w().expandToTag(t);const r=document.createRange();r.selectNode(t),r.extractContents()}insertContentAtCaretPosition(e){const t=document.createDocumentFragment(),o=document.createElement("div"),r=w.get(),i=w.range;if(!r||!i)return;o.innerHTML=e,Array.from(o.childNodes).forEach(c=>t.appendChild(c)),t.childNodes.length===0&&t.appendChild(new Text);const s=t.lastChild;i.deleteContents(),i.insertNode(t);const a=document.createRange(),l=s.nodeType===Node.TEXT_NODE?s:s.firstChild;l!==null&&l.textContent!==null&&a.setStart(l,l.textContent.length),r.removeAllRanges(),r.addRange(a)}}class bw extends F{constructor(){super(...arguments),this.firstSelectedBlock=null,this.lastSelectedBlock=null,this.onMouseUp=()=>{this.listeners.off(document,"mouseover",this.onMouseOver),this.listeners.off(document,"mouseup",this.onMouseUp)},this.onMouseOver=e=>{var a;const t=e,{BlockManager:o,BlockSelection:r}=this.Editor;if(t.relatedTarget===null&&t.target===null)return;const i=o.getBlockByChildNode(t.relatedTarget)||this.lastSelectedBlock,s=o.getBlockByChildNode(t.target);if(!(!i||!s)&&s!==i){if(this.firstSelectedBlock&&i===this.firstSelectedBlock){(a=w.get())==null||a.removeAllRanges(),i.selected=!0,s.selected=!0,r.clearCache();return}if(this.firstSelectedBlock&&s===this.firstSelectedBlock){i.selected=!1,s.selected=!1,r.clearCache();return}this.Editor.InlineToolbar.close(),this.toggleBlocksSelectedState(i,s),this.lastSelectedBlock=s}}}async prepare(){this.listeners.on(document,"mousedown",e=>{this.enableCrossBlockSelection(e)})}watchSelection(e){if(e.button!==_y.LEFT)return;const{BlockManager:t}=this.Editor,o=t.getBlock(e.target);o&&(this.firstSelectedBlock=o,this.lastSelectedBlock=o,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){var a;const{BlockManager:t,BlockSelection:o}=this.Editor,r=t.currentBlock;if(!this.lastSelectedBlock&&!r||(!this.lastSelectedBlock&&r&&(this.lastSelectedBlock=this.firstSelectedBlock=r),this.firstSelectedBlock===this.lastSelectedBlock&&this.firstSelectedBlock&&(this.firstSelectedBlock.selected=!0,o.clearCache(),(a=w.get())==null||a.removeAllRanges(),this.Editor.Toolbar.close()),!this.lastSelectedBlock))return;const i=t.blocks.indexOf(this.lastSelectedBlock)+(e?1:-1),s=t.blocks[i];s&&(this.lastSelectedBlock.selected!==s.selected?(s.selected=!0,o.clearCache(),this.Editor.Toolbar.close()):(this.lastSelectedBlock.selected=!1,o.clearCache(),this.Editor.Toolbar.close()),this.lastSelectedBlock=s,this.Editor.InlineToolbar.close(),s.holder.scrollIntoView({block:"nearest"}))}clear(e){const{BlockManager:t,BlockSelection:o,Caret:r}=this.Editor;if(!this.firstSelectedBlock||!this.lastSelectedBlock)return;const i=t.blocks.indexOf(this.firstSelectedBlock),s=t.blocks.indexOf(this.lastSelectedBlock);if(!o.anyBlockSelected||i===-1||s===-1){this.firstSelectedBlock=this.lastSelectedBlock=null;return}if(e&&e instanceof KeyboardEvent)switch(e.key){case"ArrowDown":case"ArrowRight":r.setToBlock(t.blocks[Math.max(i,s)],r.positions.END);break;case"ArrowUp":case"ArrowLeft":r.setToBlock(t.blocks[Math.min(i,s)],r.positions.START);break;default:r.setToBlock(t.blocks[Math.max(i,s)],r.positions.END)}this.firstSelectedBlock=this.lastSelectedBlock=null}enableCrossBlockSelection(e){const{UI:t}=this.Editor;w.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:r}=this.Editor,i=o.blocks.indexOf(e),s=o.blocks.indexOf(t),a=e.selected!==t.selected,l=Math.min(i,s),c=Math.max(i,s);for(const d of Array.from({length:c-l+1},(u,h)=>l+h)){const u=o.blocks[d];u!==this.firstSelectedBlock&&u!==(a?e:t)&&(o.blocks[d].selected=!o.blocks[d].selected,r.clearCache())}this.Editor.Toolbar.close()}}class yw extends F{constructor({config:e,eventsDispatcher:t}){super({config:e,eventsDispatcher:t}),this.disabled=!1,this.batchingTimeout=null,this.batchingOnChangeQueue=new Map,this.batchTime=wE,this.mutationObserver=new MutationObserver(o=>{this.redactorChanged(o)}),this.eventsDispatcher.on(Hs,o=>{this.particularBlockChanged(o.event)}),this.eventsDispatcher.on(js,()=>{this.disable()}),this.eventsDispatcher.on(zs,()=>{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||!j(this.config.onChange)||(this.batchingOnChangeQueue.set(`block:${e.detail.target.id}:event:${e.type}`,e),this.batchingTimeout&&clearTimeout(this.batchingTimeout),this.batchingTimeout=setTimeout(()=>{const t=this.batchingOnChangeQueue.size===1?this.batchingOnChangeQueue.values().next().value:Array.from(this.batchingOnChangeQueue.values());this.config.onChange&&this.config.onChange(this.Editor.API.methods,t),this.batchingOnChangeQueue.clear()},this.batchTime))}redactorChanged(e){this.eventsDispatcher.emit(So,{mutations:e})}}const pl=new Set(["table","thead","tbody","tfoot","tr","th","td","caption","colgroup","col","ul","ol","li","dl","dt","dd"]),gl=class extends F{constructor(){super(...arguments),this.MIME_TYPE="application/x-editor-js",this.toolsTags={},this.tagsByTool={},this.toolsPatterns=[],this.toolsFiles={},this.exceptionList=[],this.handlePasteEventWrapper=n=>{this.handlePasteEvent(n)},this.processTool=n=>{try{const e=n.create({},{},!1);if(n.pasteConfig===!1){this.exceptionList.push(n.name);return}if(!j(e.onPaste))return;this.getTagsConfig(n),this.getFilesConfig(n),this.getPatternsConfig(n)}catch(e){$(`Paste handling for «${n.name}» Tool hasn't been set up because of the error`,"warn",e)}},this.handlePasteEvent=async n=>{const{BlockManager:e,Toolbar:t}=this.Editor,o=e.setCurrentBlockByChildNode(n.target);!o||n.target&&this.isNativeBehaviour(n.target)&&n.clipboardData&&!n.clipboardData.types.includes("Files")||this.exceptionList.includes(o.name)||(n.preventDefault(),n.clipboardData&&await this.processDataTransfer(n.clipboardData),t.close())}}async prepare(){this.processTools()}shouldReplaceCurrentBlockForFile(n){const{BlockManager:e}=this.Editor,t=e.currentBlock;return t?n&&t.name===n?!0:!!t.tool.isDefault&&t.isEmpty:!1}getStructuralTagsSanitizeConfig(n){const e={},t=[n];for(;t.length>0;){const o=t.pop();if(!o)continue;const r=o.tagName.toLowerCase();pl.has(r)&&(e[r]=e[r]??{}),t.push(...Array.from(o.children))}return e}toggleReadOnly(n){n?this.unsetCallback():this.setCallback()}containsFiles(n){var t;if(Array.from(n.types).includes("Files")||(t=n.files)!=null&&t.length)return!0;try{const o=n.types;if(typeof(o==null?void 0:o.contains)=="function"&&o.contains("Files"))return!0}catch{}return!1}async processDataTransfer(n){const{Tools:e}=this.Editor;if(this.containsFiles(n)&&!Q(this.toolsFiles)){await this.processFiles(n.files);return}const o=n.getData(this.MIME_TYPE),r=n.getData("text/plain"),s=n.getData("text/html");if(o)try{this.insertEditorJSData(JSON.parse(o));return}catch{}const a=Object.fromEntries(Object.keys(this.toolsTags).map(g=>[g.toLowerCase(),this.toolsTags[g].sanitizationConfig??{}])),l=e.getAllInlineToolsSanitizeConfig(),c=Po(this.config.sanitizer,a,l,{br:{}}),d=Ae(s,c),u=v.isHTMLString(d);!d.trim()||d.trim()===r||!u?await this.processText(r):await this.processText(d,!0)}async processText(n,e=!1){var s,a;const{Caret:t,BlockManager:o}=this.Editor,r=e?this.processHTML(n):this.processPlain(n);if(!r.length)return;if(r.length>1){const c=!!((s=o.currentBlock)!=null&&s.tool.isDefault)&&!!((a=o.currentBlock)!=null&&a.isEmpty);r.forEach((d,u)=>{this.insertBlock(d,u===0&&c)}),o.currentBlock&&t.setToBlock(o.currentBlock,t.positions.END);return}const[i]=r;if(i.isBlock){await this.processSingleBlock(i);return}await this.processInlinePaste(i)}setCallback(){this.listeners.on(this.Editor.UI.nodes.holder,"paste",this.handlePasteEventWrapper)}unsetCallback(){this.listeners.off(this.Editor.UI.nodes.holder,"paste",this.handlePasteEventWrapper)}processTools(){const n=this.Editor.Tools.blockTools;Array.from(n.values()).forEach(this.processTool)}collectTagNames(n){return we(n)?[n]:W(n)?Object.keys(n):[]}getTagsConfig(n){if(n.pasteConfig===!1)return;const e=n.pasteConfig.tags||[],t=[];e.forEach(o=>{const r=this.collectTagNames(o);t.push(...r),r.forEach(i=>{if(Object.prototype.hasOwnProperty.call(this.toolsTags,i)){$(`Paste handler for «${n.name}» Tool on «${i}» tag is skipped because it is already used by «${this.toolsTags[i].tool.name}» Tool.`,"warn");return}const s=W(o)?o[i]:void 0;this.toolsTags[i.toUpperCase()]={tool:n,sanitizationConfig:s}})}),this.tagsByTool[n.name]=t.map(o=>o.toUpperCase())}getFilesConfig(n){if(n.pasteConfig===!1)return;const{files:e={}}=n.pasteConfig,{extensions:t,mimeTypes:o}=e;if(!t&&!o)return;const r=(()=>t==null?[]:Array.isArray(t)?t:($(`«extensions» property of the paste config for «${n.name}» Tool should be an array`),[]))(),i=(()=>o==null?[]:Array.isArray(o)?o.filter(s=>Ly(s)?!0:($(`MIME type value «${s}» for the «${n.name}» Tool is not a valid MIME type`,"warn"),!1)):($(`«mimeTypes» property of the paste config for «${n.name}» Tool should be an array`),[]))();this.toolsFiles[n.name]={extensions:r,mimeTypes:i}}getPatternsConfig(n){n.pasteConfig===!1||!n.pasteConfig.patterns||Q(n.pasteConfig.patterns)||Object.entries(n.pasteConfig.patterns).forEach(([e,t])=>{t instanceof RegExp||$(`Pattern ${t} for «${n.name}» Tool is skipped because it should be a Regexp instance.`,"warn"),this.toolsPatterns.push({key:e,pattern:t,tool:n})})}isNativeBehaviour(n){return v.isNativeInput(n)}async processFiles(n){var i;const{BlockManager:e}=this.Editor,o=(await Promise.all(Array.from(n).map(s=>this.processFile(s)))).filter(s=>s!=null);if(o.length===0)return;const r=this.shouldReplaceCurrentBlockForFile((i=o[0])==null?void 0:i.type);o.forEach((s,a)=>{e.paste(s.type,s.event,a===0&&r)})}async processFile(n){const e=Ry(n),t=Object.entries(this.toolsFiles).find(([i,{mimeTypes:s,extensions:a}])=>{const[l,c]=n.type.split("/"),d=a.find(h=>h.toLowerCase()===e.toLowerCase()),u=s.find(h=>{const[g,f]=h.split("/");return g===l&&(f===c||f==="*")});return d!==void 0||u!==void 0});if(!t)return;const[o]=t;return{event:this.composePasteEvent("file",{file:n}),type:o}}processHTML(n){const{Tools:e}=this.Editor,t=v.make("DIV");return t.innerHTML=n,this.getNodes(t).map(r=>{var m;const i=(()=>{switch(r.nodeType){case Node.DOCUMENT_FRAGMENT_NODE:{const b=v.make("div");return b.appendChild(r),{content:b,tool:e.defaultTool,isBlock:!1}}case Node.ELEMENT_NODE:{const b=r,E=this.toolsTags[b.tagName];return{content:b,tool:(E==null?void 0:E.tool)??e.defaultTool,isBlock:!0}}default:return null}})();if(!i)return null;const{content:s,tool:a,isBlock:l}=i,d=(a.pasteConfig===!1?[]:((m=a.pasteConfig)==null?void 0:m.tags)||[]).reduce((b,E)=>{const k=this.collectTagNames(E),N={...b};return k.forEach(x=>{const P=W(E)?E[x]:null;N[x.toLowerCase()]=P??{}}),N},{}),u=this.getStructuralTagsSanitizeConfig(s),h=Object.assign({},u,d,a.baseSanitizeConfig),g=(()=>{if(s.tagName.toLowerCase()!=="table")return s.innerHTML=Ae(s.innerHTML,h),s;const b=Ae(s.outerHTML,h),k=v.make("div",void 0,{innerHTML:b}).firstChild;return!k||!(k instanceof HTMLElement)?null:k})();if(!g)return null;const f=this.composePasteEvent("tag",{data:g});return{content:g,isBlock:l,tool:a.name,event:f}}).filter(r=>{if(!r)return!1;const i=v.isEmpty(r.content),s=v.isSingleTag(r.content);return!i||s})}processPlain(n){const{defaultBlock:e}=this.config;if(!n)return[];const t=e;return n.split(/\r?\n/).filter(o=>o.trim()).map(o=>{const r=v.make("div");r.textContent=o;const i=this.composePasteEvent("tag",{data:r});return{content:r,tool:t,isBlock:!1,event:i}})}async processSingleBlock(n){const{Caret:e,BlockManager:t}=this.Editor,{currentBlock:o}=t;if(!o||n.tool!==o.name||!v.containsOnlyInlineElements(n.content.innerHTML)){this.insertBlock(n,o?o.tool.isDefault&&o.isEmpty:!1);return}e.insertContentAtCaretPosition(n.content.innerHTML)}async processInlinePaste(n){var l;const{BlockManager:e,Caret:t}=this.Editor,{content:o}=n,r=((l=e.currentBlock)==null?void 0:l.tool.isDefault)??!1,i=o.textContent,a=r&&i!==null&&i.length<gl.PATTERN_PROCESSING_MAX_LENGTH&&i!==null?await this.processPattern(i):void 0;if(a){const c=e.currentBlock&&e.currentBlock.tool.isDefault&&e.currentBlock.isEmpty,d=e.paste(a.tool,a.event,c);t.setToBlock(d,t.positions.END);return}if(e.currentBlock&&e.currentBlock.currentInput){const c=e.currentBlock.tool.baseSanitizeConfig;t.insertContentAtCaretPosition(Ae(o.innerHTML,c))}else this.insertBlock(n)}async processPattern(n){const e=this.toolsPatterns.find(o=>{const r=o.pattern.exec(n);return r?n===r.shift():!1});return e?{event:this.composePasteEvent("pattern",{key:e.key,data:n}),tool:e.tool.name}:void 0}insertBlock(n,e=!1){const{BlockManager:t,Caret:o}=this.Editor,{currentBlock:r}=t;if(e&&r&&r.isEmpty){const s=t.paste(n.tool,n.event,!0);o.setToBlock(s,o.positions.END);return}const i=t.paste(n.tool,n.event);o.setToBlock(i,o.positions.END)}insertEditorJSData(n){const{BlockManager:e,Caret:t,Tools:o}=this.Editor;Oo(n,i=>{var s;return((s=o.blockTools.get(i))==null?void 0:s.sanitizeConfig)??{}},this.config.sanitizer).forEach(({tool:i,data:s},a)=>{var d,u;const l=a===0&&!!((d=e.currentBlock)!=null&&d.tool.isDefault)&&!!((u=e.currentBlock)!=null&&u.isEmpty),c=e.insert({tool:i,data:s,replace:l});t.setToBlock(c,t.positions.END)})}processElementNode(n,e,t){const o=Object.keys(this.toolsTags),r=n,i=this.toolsTags[r.tagName],s=i==null?void 0:i.tool,a=this.tagsByTool[(s==null?void 0:s.name)??""]??[],l=o.includes(r.tagName),c=v.blockElements.includes(r.tagName.toLowerCase()),d=pl.has(r.tagName.toLowerCase()),u=Array.from(r.children).some(({tagName:g})=>o.includes(g)&&!a.includes(g)),h=Array.from(r.children).some(({tagName:g})=>v.blockElements.includes(g.toLowerCase()));if(!c&&!l&&!u)return t.appendChild(r),[...e,t];if(l&&!u||c&&!h&&!u||d&&!u)return[...e,t,r]}getNodes(n){const e=Array.from(n.childNodes),t=(o,r)=>{if(v.isEmpty(r)&&!v.isSingleTag(r))return o;const i=o[o.length-1],s=i!==void 0&&v.isFragment(i),{destNode:a,remainingNodes:l}=s?{destNode:i,remainingNodes:o.slice(0,-1)}:{destNode:new DocumentFragment,remainingNodes:o};if(r.nodeType===Node.TEXT_NODE)return a.appendChild(r),[...l,a];if(r.nodeType!==Node.ELEMENT_NODE)return[...l,a];const c=this.processElementNode(r,l,a);if(c)return c;const d=Array.from(r.childNodes).reduce(t,[]);return[...l,...d]};return e.reduce(t,[])}composePasteEvent(n,e){return new CustomEvent(n,{detail:e})}};let ml=gl;ml.PATTERN_PROCESSING_MAX_LENGTH=450;class Ew extends F{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(([r,i])=>{i.isReadOnlySupported||o.push(r)}),this.toolsDontSupportReadOnly=o,this.config.readOnly===!0&&o.length>0&&this.throwCriticalError(),await 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 of Object.values(this.Editor))i!=null&&typeof i.toggleReadOnly=="function"&&i.toggleReadOnly(e);if(o===e)return this.readOnlyEnabled;if(t)return this.readOnlyEnabled;this.Editor.ModificationsObserver.disable();const r=await this.Editor.Saver.save();return r===void 0?(this.Editor.ModificationsObserver.enable(),this.readOnlyEnabled):(await this.Editor.BlockManager.clear(),await this.Editor.Renderer.render(r.blocks),this.Editor.ModificationsObserver.enable(),this.readOnlyEnabled)}throwCriticalError(){throw new Ot(`To enable read-only mode all connected tools should support it. Tools ${this.toolsDontSupportReadOnly.join(", ")} don't support read-only mode.`)}}class Zt extends F{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.rectCrossesBlocks=!1,this.overlayRectangle=null,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=this.getScrollLeft(),r=this.getScrollTop(),i=document.elementFromPoint(e-o,t-r);if(!i)return;i.closest(`.${this.Editor.Toolbar.CSS.toolbar}`)||(this.Editor.BlockSelection.allBlocksSelected=!1,this.clearSelection(),this.stackOfSelected=[]);const a=[`.${re.CSS.content}`,`.${this.Editor.Toolbar.CSS.toolbar}`,`.${this.Editor.InlineToolbar.CSS.inlineToolbar}`],l=i.closest("."+this.Editor.UI.CSS.editorWrapper),c=a.some(d=>!!i.closest(d));!l||c||(this.mousedown=!0,this.startX=e,this.startY=t)}endSelection(){this.mousedown=!1,this.startX=0,this.startY=0,this.overlayRectangle!==null&&(this.overlayRectangle.style.display="none")}isRectActivated(){return this.isRectSelectionActivated}clearSelection(){this.isRectSelectionActivated=!1}enableModuleBindings(){const{container:e}=this.genHTML();this.listeners.on(e,"mousedown",r=>{this.processMouseDown(r)},!1);const t=To(r=>{r instanceof MouseEvent&&this.processMouseMove(r)},10);this.listeners.on(document.body,"mousemove",t,{passive:!0}),this.listeners.on(document.body,"mouseleave",()=>{this.processMouseLeave()});const o=To(r=>{this.processScroll(r)},10);this.listeners.on(window,"scroll",o,{passive:!0}),this.listeners.on(document.body,"mouseup",()=>{this.processMouseUp()},!1)}processMouseDown(e){if(e.button!==this.MAIN_MOUSE_BUTTON)return;e.target.closest(v.allInputsSelector)!==null||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){if(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=!1;return}this.isScrolling||(this.scrollVertical(this.inScrollZone===this.TOP_SCROLL_ZONE?-this.SCROLL_SPEED:this.SCROLL_SPEED),this.isScrolling=!0)}genHTML(){const{UI:e}=this.Editor,t=e.nodes.holder.querySelector("."+e.CSS.editorWrapper),o=v.make("div",Zt.CSS.overlay,{}),r=v.make("div",Zt.CSS.overlayContainer,{}),i=v.make("div",Zt.CSS.rect,{});if(!t)throw new Error("RectangleSelection: editor wrapper not found");return r.appendChild(i),o.appendChild(r),t.appendChild(o),this.overlayRectangle=i,{container:t,overlay:o}}scrollVertical(e){if(!(this.inScrollZone&&this.mousedown))return;const t=this.getScrollTop();window.scrollBy(0,e),this.mouseY+=this.getScrollTop()-t,setTimeout(()=>{this.scrollVertical(e)},0)}changingRectangle(e){if(!this.mousedown)return;const t=this.overlayRectangle;if(t===null)return;e.pageY!==void 0&&(this.mouseX=e.pageX,this.mouseY=e.pageY);const{rightPos:o,leftPos:r,index:i}=this.genInfoForMouseSelection(),s=this.startX>o&&this.mouseX>o,a=this.startX<r&&this.mouseX<r;if(this.rectCrossesBlocks=!(s||a),this.isRectSelectionActivated||(this.rectCrossesBlocks=!1,this.isRectSelectionActivated=!0,this.shrinkRectangleToPoint(),t.style.display="block"),this.updateRectangleSize(),this.Editor.Toolbar.close(),i===void 0)return;this.trySelectNextBlock(i),this.inverseSelection();const l=w.get();l&&l.removeAllRanges()}shrinkRectangleToPoint(){if(this.overlayRectangle===null)return;const e=this.getScrollLeft(),t=this.getScrollTop();this.overlayRectangle.style.left=`${this.startX-e}px`,this.overlayRectangle.style.top=`${this.startY-t}px`,this.overlayRectangle.style.bottom=`calc(100% - ${this.startY-t}px)`,this.overlayRectangle.style.right=`calc(100% - ${this.startX-e}px)`}inverseSelection(){if(this.stackOfSelected.length===0)return;const e=this.Editor.BlockManager.getBlockByIndex(this.stackOfSelected[0]);if(!e)return;const t=e.selected;if(this.rectCrossesBlocks&&!t)for(const o of this.stackOfSelected)this.Editor.BlockSelection.selectBlockByIndex(o);if(!this.rectCrossesBlocks&&t)for(const o of this.stackOfSelected)this.Editor.BlockSelection.unSelectBlockByIndex(o)}updateRectangleSize(){if(this.overlayRectangle===null)return;const e=this.getScrollLeft(),t=this.getScrollTop();this.mouseY>=this.startY?(this.overlayRectangle.style.top=`${this.startY-t}px`,this.overlayRectangle.style.bottom=`calc(100% - ${this.mouseY-t}px)`):(this.overlayRectangle.style.bottom=`calc(100% - ${this.startY-t}px)`,this.overlayRectangle.style.top=`${this.mouseY-t}px`),this.mouseX>=this.startX?(this.overlayRectangle.style.left=`${this.startX-e}px`,this.overlayRectangle.style.right=`calc(100% - ${this.mouseX-e}px)`):(this.overlayRectangle.style.right=`calc(100% - ${this.startX-e}px)`,this.overlayRectangle.style.left=`${this.mouseX-e}px`)}genInfoForMouseSelection(){var f;const t=document.body.offsetWidth/2,o=this.getScrollTop(),r=this.mouseY-o,i=document.elementFromPoint(t,r),s=(f=this.Editor.BlockManager.lastBlock)==null?void 0:f.holder,a=s==null?void 0:s.querySelector("."+re.CSS.content),c=(a?Number.parseInt(window.getComputedStyle(a).width,10):0)/2,d=t-c,u=t+c;if(!i)return{index:void 0,leftPos:d,rightPos:u};const h=this.Editor.BlockManager.getBlockByChildNode(i);return{index:h!==void 0?this.Editor.BlockManager.blocks.findIndex(m=>m.holder===h.holder):void 0,leftPos:d,rightPos:u}}getScrollTop(){var e,t;return typeof window.scrollY=="number"?window.scrollY:((e=document.documentElement)==null?void 0:e.scrollTop)??((t=document.body)==null?void 0:t.scrollTop)??0}getScrollLeft(){var e,t;return typeof window.scrollX=="number"?window.scrollX:((e=document.documentElement)==null?void 0:e.scrollLeft)??((t=document.body)==null?void 0:t.scrollLeft)??0}addBlockInSelection(e){this.rectCrossesBlocks&&this.Editor.BlockSelection.selectBlockByIndex(e),this.stackOfSelected.push(e)}trySelectNextBlock(e){const t=this.stackOfSelected.length,o=this.stackOfSelected[t-1];if(o===e)return;const i=this.stackOfSelected[t-2],s=i!==void 0&&o!==void 0?o-i>0:!1,a=t<=1,l=o!==void 0&&e>o&&s,c=o!==void 0&&e<o&&t>1&&!s,u=!(l||c||a);if(!u&&(o===void 0||e>o)){const f=o!==void 0?o+1:e;Array.from({length:e-f+1},(m,b)=>f+b).forEach(m=>{this.addBlockInSelection(m)});return}if(!u&&o!==void 0&&e<o){Array.from({length:o-e},(f,m)=>o-1-m).forEach(f=>{this.addBlockInSelection(f)});return}if(!u)return;const h=f=>o===void 0?!1:e>o?e>f:e<f,g=[];for(const f of[...this.stackOfSelected].reverse()){if(!h(f))break;this.rectCrossesBlocks&&this.Editor.BlockSelection.unSelectBlockByIndex(f),g.push(f)}g.length>0&&this.stackOfSelected.splice(this.stackOfSelected.length-g.length,g.length)}}class Tw extends F{render(e){return new Promise(t=>{const{Tools:o,BlockManager:r}=this.Editor;if(e.length===0)r.insert();else{const i=e.map(s=>{const{tunes:a,id:l}=s,c=s.type,d=(()=>o.available.has(c)?{tool:c,data:s.data}:(Ee(`Tool «${c}» is not found. Check 'tools' property at the Editor.js config.`,"warn"),{tool:o.stubTool,data:this.composeStubDataForTool(c,s.data,l)}))();return((h,g)=>{try{return r.composeBlock({id:l,tool:h,data:g,tunes:a})}catch(f){$(`Block «${h}» skipped because of plugins error`,"error",{data:g,error:f});const m=this.composeStubDataForTool(h,g,l);return r.composeBlock({id:l,tool:o.stubTool,data:m,tunes:a})}})(d.tool,d.data)});r.insertMany(i)}window.requestIdleCallback(()=>{t()},{timeout:2e3})})}composeStubDataForTool(e,t,o){const{Tools:r}=this.Editor,i=(()=>{if(!r.unavailable.has(e))return e;const s=r.unavailable.get(e).toolbox;return s!==void 0&&s[0].title!==void 0?s[0].title:e})();return{savedData:{id:o,type:e,data:t},title:i}}}class kw extends F{async save(){const{BlockManager:e,Tools:t}=this.Editor,o=e.blocks;if(o.length===1&&o[0].isEmpty)return{time:+new Date,blocks:[],version:fn()};const r=o.map(i=>this.getSavedData(i));this.lastSaveError=void 0;try{const i=await Promise.all(r),s=this.sanitizeExtractedData(i,a=>{var l;return(l=t.blockTools.get(a))==null?void 0:l.sanitizeConfig},this.config.sanitizer);return this.makeOutput(s)}catch(i){this.lastSaveError=i;const s=i instanceof Error?i:new Error(String(i));Ee("Saving failed due to the Error %o","error",s);return}}async getSavedData(e){const t=await e.save(),o=e.name,r=(t==null?void 0:t.data)!==void 0?t:this.getPreservedSavedData(e);if(r===void 0)return{tool:o,isValid:!1};const i=await e.validate(r.data);return{...r,isValid:i}}makeOutput(e){const t=[];return e.forEach(({id:o,tool:r,data:i,tunes:s,isValid:a})=>{if(!a){$(`Block «${r}» skipped because saved data is invalid`);return}if(r===void 0||i===void 0){$("Block skipped because saved data is missing required fields");return}if(r===this.Editor.Tools.stubTool&&this.isStubSavedData(i)){t.push(i);return}if(r===this.Editor.Tools.stubTool){$("Stub block data is malformed and was skipped");return}const l=s===void 0||Q(s),c={id:o,type:r,data:i,...!l&&{tunes:s}};t.push(c)}),{time:+new Date,blocks:t,version:fn()}}sanitizeExtractedData(e,t,o){const r=[];if(e.forEach((a,l)=>{this.hasSanitizableData(a)&&r.push({index:l,data:a})}),r.length===0)return e;const i=Oo(r.map(({data:a})=>a),t,o),s=e.map(a=>({...a}));return r.forEach(({index:a},l)=>{const c=i[l];s[a]={...s[a],data:c.data}}),s}hasSanitizableData(e){return e.data!==void 0&&typeof e.tool=="string"}isStubSavedData(e){if(!W(e))return!1;const t=e;return typeof t.type=="string"&&t.data!==void 0}getLastSaveError(){return this.lastSaveError}getPreservedSavedData(e){const t=e.preservedData;if(Q(t))return;const o=e.preservedTunes;return{id:e.id,tool:e.name,data:t,...Q(o)?{}:{tunes:o},time:0}}}(function(){try{if(typeof document<"u"){var n=document.createElement("style");n.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(n)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();const ww='<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>';function Cw(n){const e=document.createElement("div");e.innerHTML=n.trim();const t=document.createDocumentFragment();return t.append(...Array.from(e.childNodes)),t}/**
32
+ * Base Paragraph Block for the Editor.js.
33
+ * Represents a regular text block
34
+ *
35
+ * @author CodeX (team@codex.so)
36
+ * @copyright CodeX 2018
37
+ * @license The MIT License (MIT)
38
+ */class si{static get DEFAULT_PLACEHOLDER(){return""}constructor({data:e,config:t,api:o,readOnly:r}){this.api=o,this.readOnly=r,this._CSS={block:this.api.styles.block,wrapper:"ce-paragraph"},this.readOnly||(this.onKeyUp=this.onKeyUp.bind(this)),this._placeholder=t.placeholder?t.placeholder:si.DEFAULT_PLACEHOLDER,this._data=e??{},this._element=null,this._preserveBlank=t.preserveBlank??!1}onKeyUp(e){if(e.code!=="Backspace"&&e.code!=="Delete"||!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=Cw(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:ww,title:"Text"}}}const p=class{static get sanitize(){return{strong:{},b:{}}}static normalizeAllBoldTags(){if(typeof document>"u")return;const n=w.CSS.editorWrapper,e=`${Vs} b, .${n} b`;document.querySelectorAll(e).forEach(t=>{p.ensureStrongElement(t)})}static normalizeBoldInNode(n){var r;const e=n.nodeType===Node.ELEMENT_NODE?n:n.parentElement;if(!e||typeof e.closest!="function")return;const t=w.CSS.editorWrapper;e.closest(`${Vs}, .${t}`)&&(e.tagName==="B"&&p.ensureStrongElement(e),(r=e.querySelectorAll)==null||r.call(e,"b").forEach(i=>{p.ensureStrongElement(i)}))}constructor(){typeof document>"u"||(p.instances.add(this),p.initializeGlobalListeners())}static initializeGlobalListeners(){return typeof document>"u"?!1:(p.shortcutListenerRegistered||(document.addEventListener("keydown",p.handleShortcut,!0),p.shortcutListenerRegistered=!0),p.selectionListenerRegistered||(document.addEventListener("selectionchange",p.handleGlobalSelectionChange,!0),p.selectionListenerRegistered=!0),p.inputListenerRegistered||(document.addEventListener("input",p.handleGlobalInput,!0),p.inputListenerRegistered=!0),p.beforeInputListenerRegistered||(document.addEventListener("beforeinput",p.handleBeforeInput,!0),p.beforeInputListenerRegistered=!0),p.ensureMutationObserver(),!0)}static maintainCollapsedExitState(){if(!(typeof document>"u"))for(const n of Array.from(p.collapsedExitRecords)){const e=p.resolveBoundary(n);if(!e){p.collapsedExitRecords.delete(n);continue}n.boundary=e.boundary,n.boldElement=e.boldElement;const t=e.boundary,o=e.boldElement,r=n.allowedLength,i=o.textContent??"";if(i.length>r){const b=i.slice(0,r),E=i.slice(r);o.textContent=b,t.textContent=(t.textContent??"")+E}const s=t.textContent??"";s.length>1&&s.startsWith("​")&&(t.textContent=s.slice(1));const a=window.getSelection();p.ensureCaretAtBoundary(a,t),p.scheduleBoundaryCaretAdjustment(t);const l=t.textContent??"",c=l.replace(/\u200B/g,""),d=c.match(/^\s+/),u=/\S/.test(c),h=l.startsWith("​");d&&(n.hasLeadingSpace=!0,n.leadingWhitespace=d[0]),u&&(n.hasTypedContent=!0);const g=/^\s/.test(c),f=n.hasTypedContent&&!h&&(o.textContent??"").length<=r,m=n.hasLeadingSpace&&n.hasTypedContent&&!g;if(f&&m){const b=l.replace(/^[\u200B\s]+/,""),E=n.leadingWhitespace||" ";t.textContent=`${E}${b}`,p.ensureCaretAtBoundary(a,t)}f&&p.collapsedExitRecords.delete(n)}}static ensureCaretAtBoundary(n,e){!n||!n.isCollapsed||p.setCaretToBoundaryEnd(n,e)}static scheduleBoundaryCaretAdjustment(n){p.pendingBoundaryCaretAdjustments.has(n)||(p.pendingBoundaryCaretAdjustments.add(n),setTimeout(()=>{var r;p.pendingBoundaryCaretAdjustments.delete(n);const e=n.ownerDocument??(typeof document<"u"?document:null);if(!e)return;const t=e.getSelection();if(!t||!t.isCollapsed||t.anchorNode!==n)return;const o=((r=n.textContent)==null?void 0:r.length)??0;t.anchorOffset!==o&&p.setCaret(t,n,o)},0))}static ensureTextNodeAfter(n){const e=n.nextSibling;if((e==null?void 0:e.nodeType)===Node.TEXT_NODE)return e;const t=n.parentNode;if(!t)return null;const o=n.ownerDocument??(typeof document<"u"?document:null);if(!o)return null;const r=o.createTextNode("");return t.insertBefore(r,e),r}static resolveBoundary(n){if(!n.boldElement.isConnected)return null;const e=p.ensureStrongElement(n.boldElement),t=n.boundary,r=t.isConnected&&t.previousSibling===e?t:p.ensureTextNodeAfter(e);return r?{boundary:r,boldElement:e}:null}static setCaretToBoundaryEnd(n,e){var r;const t=document.createRange(),o=((r=e.textContent)==null?void 0:r.length)??0;t.setStart(e,o),t.collapse(!0),n.removeAllRanges(),n.addRange(t)}static hasBoldParent(n){return n?n.nodeType===Node.ELEMENT_NODE&&p.isBoldTag(n)?!0:p.hasBoldParent(n.parentNode):!1}static findBoldElement(n){return n?n.nodeType===Node.ELEMENT_NODE&&p.isBoldTag(n)?p.ensureStrongElement(n):p.findBoldElement(n.parentNode):null}static isBoldTag(n){const e=n.tagName;return e==="B"||e==="STRONG"}static ensureStrongElement(n){if(n.tagName==="STRONG")return n;const e=document.createElement("strong");for(n.hasAttributes()&&Array.from(n.attributes).forEach(t=>{e.setAttribute(t.name,t.value)});n.firstChild;)e.appendChild(n.firstChild);return n.replaceWith(e),e}static mergeStrongNodes(n,e){const t=p.ensureStrongElement(n),o=p.ensureStrongElement(e);for(;o.firstChild;)t.appendChild(o.firstChild);return o.remove(),t}render(){return{icon:$E,name:"bold",onActivate:()=>{this.toggleBold()},isActive:()=>{const n=window.getSelection();return n?this.isSelectionVisuallyBold(n):!1}}}toggleBold(){const n=window.getSelection();if(!n||n.rangeCount===0)return;const e=n.getRangeAt(0);if(e.collapsed){this.toggleCollapsedSelection();return}this.isRangeBold(e,{ignoreWhitespace:!0})?this.unwrapBoldTags(e):this.wrapWithBold(e)}isSelectionVisuallyBold(n){if(!n||n.rangeCount===0)return!1;const e=n.getRangeAt(0);return this.isRangeBold(e,{ignoreWhitespace:!0})}wrapWithBold(n){const e=this.getRangeHtmlWithoutBold(n),t=this.replaceRangeWithHtml(n,`<strong>${e}</strong>`),o=window.getSelection();o&&t&&(o.removeAllRanges(),o.addRange(t)),p.normalizeAllBoldTags();const r=o?p.findBoldElement(o.focusNode):null;if(!r)return;const i=this.mergeAdjacentBold(r);this.normalizeWhitespaceAround(i),this.selectElementContents(i),p.normalizeBoldTagsWithinEditor(window.getSelection()),p.replaceNbspInBlock(window.getSelection()),this.notifySelectionChange()}unwrapBoldTags(n){const e=this.collectBoldAncestors(n),t=window.getSelection();if(!t)return;const o=document.createElement("span"),r=n.extractContents();o.dataset.boldMarker=`unwrap-${p.markerSequence++}`,o.appendChild(r),this.removeNestedBold(o),n.insertNode(o);const i=document.createRange();for(i.selectNodeContents(o),t.removeAllRanges(),t.addRange(i);;){const c=p.findBoldElement(o);if(!c)break;this.moveMarkerOutOfBold(o,c)}const s=o.firstChild,a=o.lastChild;this.unwrapElement(o);const l=s&&a?(()=>{const c=document.createRange();return c.setStartBefore(s),c.setEndAfter(a),t.removeAllRanges(),t.addRange(c),c})():void 0;l||t.removeAllRanges(),this.replaceNbspWithinRange(l),p.normalizeBoldTagsWithinEditor(t),p.replaceNbspInBlock(t),p.removeEmptyBoldElements(t),e.forEach(c=>{p.isElementEmpty(c)&&c.remove()}),this.notifySelectionChange()}replaceRangeWithHtml(n,e){const t=p.createFragmentFromHtml(e),o=t.firstChild??null,r=t.lastChild??null;if(n.deleteContents(),!o||!r)return;n.insertNode(t);const i=document.createRange();return i.setStartBefore(o),i.setEndAfter(r),i}moveMarkerOutOfBold(n,e){const t=e.parentNode;if(!t)return;if(e.childNodes.length===1&&e.firstChild===n){e.replaceWith(n);return}if(e.firstChild===n){t.insertBefore(n,e);return}if(e.lastChild===n){t.insertBefore(n,e.nextSibling);return}const s=e.cloneNode(!1);for(;n.nextSibling;)s.appendChild(n.nextSibling);t.insertBefore(s,e.nextSibling),t.insertBefore(n,s)}selectElementContents(n){const e=window.getSelection();if(!e)return;const t=document.createRange();t.selectNodeContents(n),e.removeAllRanges(),e.addRange(t)}get shortcut(){return"CMD+B"}isRangeBold(n,e){if(n.collapsed)return!!p.findBoldElement(n.startContainer);const t=document.createTreeWalker(n.commonAncestorContainer,NodeFilter.SHOW_TEXT,{acceptNode:r=>{try{return n.intersectsNode(r)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}catch{const s=document.createRange();s.selectNodeContents(r);const a=n.compareBoundaryPoints(Range.END_TO_START,s)>0,l=n.compareBoundaryPoints(Range.START_TO_END,s)<0;return a&&l?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}}}),o=[];for(;t.nextNode();){const r=t.currentNode,i=r.textContent??"";e.ignoreWhitespace&&i.trim().length===0||i.length!==0&&o.push(r)}return o.length===0?!!p.findBoldElement(n.startContainer):o.every(r=>p.hasBoldParent(r))}removeNestedBold(n){var t;const e=(t=n.querySelectorAll)==null?void 0:t.call(n,"b,strong");e&&e.forEach(o=>{this.unwrapElement(o)})}unwrapElement(n){const e=n.parentNode;if(!e){n.remove();return}for(;n.firstChild;)e.insertBefore(n.firstChild,n);e.removeChild(n)}mergeAdjacentBold(n){const e=p.ensureStrongElement(n),t=e.previousSibling,o=t&&t.nodeType===Node.ELEMENT_NODE&&p.isBoldTag(t)?p.mergeStrongNodes(t,e):e,r=o.nextSibling;return r&&r.nodeType===Node.ELEMENT_NODE&&p.isBoldTag(r)?p.mergeStrongNodes(o,r):o}toggleCollapsedSelection(){const n=window.getSelection();if(!n||n.rangeCount===0)return;const e=n.getRangeAt(0),t=p.findBoldElement(e.startContainer),o=(()=>{if(t&&t.getAttribute(p.DATA_ATTR_COLLAPSED_ACTIVE)!=="true")return p.exitCollapsedBold(n,t);const r=t??p.getBoundaryBold(e);return r?p.exitCollapsedBold(n,r):this.startCollapsedBold(e)})();document.dispatchEvent(new Event("selectionchange")),o&&(n.removeAllRanges(),n.addRange(o)),p.normalizeBoldTagsWithinEditor(n),p.replaceNbspInBlock(n),p.removeEmptyBoldElements(n),this.notifySelectionChange()}startCollapsedBold(n){if(!n.collapsed)return;const e=document.createElement("strong"),t=document.createTextNode("");e.appendChild(t),e.setAttribute(p.DATA_ATTR_COLLAPSED_ACTIVE,"true");const o=n.startContainer,r=n.startOffset;if(!(()=>o.nodeType===Node.TEXT_NODE?this.insertCollapsedBoldIntoText(o,e,r):o.nodeType===Node.ELEMENT_NODE?(this.insertCollapsedBoldIntoElement(o,e,r),!0):!1)())return;const s=window.getSelection(),a=document.createRange();a.setStart(t,0),a.collapse(!0);const l=this.mergeAdjacentBold(e);return p.normalizeBoldTagsWithinEditor(s),p.replaceNbspInBlock(s),p.removeEmptyBoldElements(s),s&&(s.removeAllRanges(),s.addRange(a)),this.notifySelectionChange(),l.firstChild instanceof Text?(()=>{var d;const c=document.createRange();return c.setStart(l.firstChild,((d=l.firstChild.textContent)==null?void 0:d.length)??0),c.collapse(!0),c})():a}insertCollapsedBoldIntoText(n,e,t){const o=n,r=o.parentNode;if(!r)return!1;const i=o.textContent??"",s=i.slice(0,t),a=i.slice(t);o.textContent=s;const l=a.length?document.createTextNode(a):null;return l&&r.insertBefore(l,o.nextSibling),r.insertBefore(e,l??o.nextSibling),e.setAttribute(p.DATA_ATTR_PREV_LENGTH,s.length.toString()),!0}insertCollapsedBoldIntoElement(n,e,t){const o=n.childNodes[t]??null;n.insertBefore(e,o),e.setAttribute(p.DATA_ATTR_PREV_LENGTH,"0")}static isElementEmpty(n){return(n.textContent??"").length===0}notifySelectionChange(){p.enforceCollapsedBoldLengths(window.getSelection()),document.dispatchEvent(new Event("selectionchange")),this.updateToolbarButtonState()}updateToolbarButtonState(){const n=window.getSelection();if(!n)return;const e=n.anchorNode,t=(e==null?void 0:e.nodeType)===Node.ELEMENT_NODE?e:e==null?void 0:e.parentElement,o=t==null?void 0:t.closest(`.${w.CSS.editorWrapper}`);if(!o)return;const r=o.querySelector("[data-cy=inline-toolbar]");if(!(r instanceof HTMLElement))return;const i=r.querySelector('[data-item-name="bold"]');if(!(i instanceof HTMLElement))return;const s=this.isSelectionVisuallyBold(n);i.classList.toggle("ce-popover-item--active",s),s?i.setAttribute("data-popover-item-active","true"):i.removeAttribute("data-popover-item-active")}normalizeWhitespaceAround(n){p.replaceNbspWithSpace(n.previousSibling),p.replaceNbspWithSpace(n.nextSibling)}static replaceNbspWithSpace(n){if(!n||n.nodeType!==Node.TEXT_NODE)return;const e=n,t=e.textContent??"";t.includes(" ")&&(e.textContent=t.replace(/\u00A0/g," "))}restoreSelectionFromMarkers(n){const e=document.querySelector(`[data-bold-marker="${n}-start"]`),t=document.querySelector(`[data-bold-marker="${n}-end"]`);if(!e||!t){e==null||e.remove(),t==null||t.remove();return}const o=window.getSelection();if(!o){e.remove(),t.remove();return}const r=document.createRange();return r.setStartAfter(e),r.setEndBefore(t),o.removeAllRanges(),o.addRange(r),e.remove(),t.remove(),r}replaceNbspWithinRange(n){if(!n)return;const e=document.createTreeWalker(n.commonAncestorContainer,NodeFilter.SHOW_TEXT,{acceptNode:t=>{try{return n.intersectsNode(t)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}catch{const r=document.createRange();r.selectNodeContents(t);const i=n.compareBoundaryPoints(Range.END_TO_START,r)>0,s=n.compareBoundaryPoints(Range.START_TO_END,r)<0;return i&&s?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}}});for(;e.nextNode();)p.replaceNbspWithSpace(e.currentNode)}static normalizeBoldTagsWithinEditor(n){const e=(n==null?void 0:n.anchorNode)??(n==null?void 0:n.focusNode);if(!e)return;const t=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement,o=t==null?void 0:t.closest(`.${w.CSS.editorWrapper}`);o&&o.querySelectorAll("b").forEach(r=>{p.ensureStrongElement(r)})}static replaceNbspInBlock(n){const e=(n==null?void 0:n.anchorNode)??(n==null?void 0:n.focusNode);if(!e)return;const t=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement,o=t==null?void 0:t.closest('[data-block-tool="paragraph"]');if(!o)return;const r=document.createTreeWalker(o,NodeFilter.SHOW_TEXT);for(;r.nextNode();)p.replaceNbspWithSpace(r.currentNode);o.querySelectorAll("b").forEach(i=>{p.ensureStrongElement(i)})}static removeEmptyBoldElements(n){const e=(n==null?void 0:n.anchorNode)??(n==null?void 0:n.focusNode);if(!e)return;const t=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement,o=t==null?void 0:t.closest('[data-block-tool="paragraph"]');if(!o)return;const r=(n==null?void 0:n.focusNode)??null;o.querySelectorAll("strong").forEach(i=>{const s=i.getAttribute(p.DATA_ATTR_COLLAPSED_ACTIVE)==="true",a=i.hasAttribute(p.DATA_ATTR_COLLAPSED_LENGTH);s||a||(i.textContent??"").length===0&&!p.isNodeWithin(r,i)&&i.remove()})}static synchronizeCollapsedBold(n){const e=(n==null?void 0:n.anchorNode)??(n==null?void 0:n.focusNode),t=e&&e.nodeType===Node.ELEMENT_NODE?e:e==null?void 0:e.parentElement,o=(t==null?void 0:t.closest(`.${w.CSS.editorWrapper}`))??(t==null?void 0:t.ownerDocument);if(!o)return;const r=`strong[${p.DATA_ATTR_COLLAPSED_ACTIVE}="true"]`;o.querySelectorAll(r).forEach(i=>{var I;const s=i.getAttribute(p.DATA_ATTR_PREV_LENGTH),a=i.previousSibling;if(!s||!a||a.nodeType!==Node.TEXT_NODE)return;const l=Number(s);if(!Number.isFinite(l))return;const c=a,d=c.textContent??"";if(d.length<=l)return;const u=d.slice(0,l),h=d.slice(l);c.textContent=u;const g=h.match(/^[\u00A0\s]+/);if(g&&!i.hasAttribute(p.DATA_ATTR_LEADING_WHITESPACE)&&i.setAttribute(p.DATA_ATTR_LEADING_WHITESPACE,g[0]),h.length===0)return;const f=i.textContent??"",m=f+h,b=i.getAttribute(p.DATA_ATTR_LEADING_WHITESPACE)??"",k=b.length>0&&f.length===0&&!m.startsWith(b)?b+m:m,N=document.createTextNode(k);for(;i.firstChild;)i.removeChild(i.firstChild);if(i.appendChild(N),!(n!=null&&n.isCollapsed)||!p.isNodeWithin(n.focusNode,c))return;const x=document.createRange(),P=((I=N.textContent)==null?void 0:I.length)??0;x.setStart(N,P),x.collapse(!0),n.removeAllRanges(),n.addRange(x)})}static moveCaretAfterBoundaryBold(n){if(!n.rangeCount)return;const e=n.getRangeAt(0);if(!e.collapsed)return;const t=p.findBoldElement(e.startContainer);(t==null?void 0:t.getAttribute(p.DATA_ATTR_COLLAPSED_ACTIVE))!=="true"&&(p.moveCaretFromElementContainer(n,e)||p.moveCaretFromTextContainer(n,e))}static getAdjacentBold(n){const e=n.startContainer;return e.nodeType===Node.TEXT_NODE?p.getBoldAdjacentToText(n,e):e.nodeType===Node.ELEMENT_NODE?p.getBoldAdjacentToElement(n,e):null}static getBoldAdjacentToText(n,e){var i;const t=((i=e.textContent)==null?void 0:i.length)??0,o=e.previousSibling;if(n.startOffset===0&&p.isBoldElement(o))return o;if(n.startOffset!==t)return null;const r=e.nextSibling;return p.isBoldElement(r)?r:null}static getBoldAdjacentToElement(n,e){const t=n.startOffset>0?e.childNodes[n.startOffset-1]??null:null;if(p.isBoldElement(t))return t;const o=e.childNodes[n.startOffset]??null;return p.isBoldElement(o)?o:null}static exitCollapsedIfNeeded(n,e){if(!!p.findBoldElement(e.startContainer))return;const o=p.getBoundaryBold(e)??p.getAdjacentBold(e);if(!o)return;const r=p.exitCollapsedBold(n,o);r&&(n.removeAllRanges(),n.addRange(r))}static moveCaretFromElementContainer(n,e){if(e.startContainer.nodeType!==Node.ELEMENT_NODE)return!1;const t=e.startContainer;return p.moveCaretAfterPreviousBold(n,t,e.startOffset)?!0:p.moveCaretBeforeNextBold(n,t,e.startOffset)}static moveCaretAfterPreviousBold(n,e,t){var s;const o=t>0?e.childNodes[t-1]??null:null;if(!p.isBoldElement(o))return!1;const r=p.ensureFollowingTextNode(o,o.nextSibling);if(!r)return!1;const i=((s=r.textContent)==null?void 0:s.length)??0;return p.setCaret(n,r,i),!0}static moveCaretBeforeNextBold(n,e,t){const o=e.childNodes[t]??null;if(!p.isBoldElement(o))return!1;const r=p.ensureFollowingTextNode(o,o.nextSibling);return r?(p.setCaret(n,r,0),!0):(p.setCaretAfterNode(n,o),!0)}static moveCaretFromTextContainer(n,e){var l;if(e.startContainer.nodeType!==Node.TEXT_NODE)return;const t=e.startContainer,o=t.previousSibling,r=t.textContent??"",i=/^\s/.test(r);if(e.startOffset===0&&p.isBoldElement(o)&&(r.length===0||i)){p.setCaret(n,t,r.length);return}const s=p.findBoldElement(t);if(!s||e.startOffset!==(((l=t.textContent)==null?void 0:l.length)??0))return;const a=p.ensureFollowingTextNode(s,s.nextSibling);if(a){p.setCaret(n,a,0);return}p.setCaretAfterNode(n,s)}static guardCollapsedBoundaryKeydown(n){if(n.defaultPrevented||n.metaKey||n.ctrlKey||n.altKey||n.key.length!==1)return;const t=window.getSelection();if(!t||!t.isCollapsed||t.rangeCount===0)return;const o=t.getRangeAt(0);if(o.startContainer.nodeType!==Node.TEXT_NODE)return;const r=o.startContainer,i=r.textContent??"";if(i.length===0||o.startOffset!==0)return;const s=r.previousSibling;p.isBoldElement(s)&&/^\s/.test(i)&&p.setCaret(t,r,i.length)}static isBoldElement(n){return!!(n&&n.nodeType===Node.ELEMENT_NODE&&p.isBoldTag(n))}static setCaret(n,e,t){const o=document.createRange();o.setStart(e,t),o.collapse(!0),n.removeAllRanges(),n.addRange(o)}static setCaretAfterNode(n,e){if(!e)return;const t=document.createRange();t.setStartAfter(e),t.collapse(!0),n.removeAllRanges(),n.addRange(t)}static ensureFollowingTextNode(n,e){const t=n.parentNode;if(!t)return null;if(e&&e.nodeType===Node.TEXT_NODE)return e;const o=document.createTextNode("");return t.insertBefore(o,e),o}static enforceCollapsedBoldLengths(n){const e=(n==null?void 0:n.anchorNode)??(n==null?void 0:n.focusNode);if(!e)return;const t=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement,o=t==null?void 0:t.closest(`.${w.CSS.editorWrapper}`);if(!o)return;o.querySelectorAll(`strong[${p.DATA_ATTR_COLLAPSED_LENGTH}]`).forEach(i=>{var k,N;const s=i,a=s.getAttribute(p.DATA_ATTR_COLLAPSED_LENGTH);if(!a)return;const l=Number(a),c=s.textContent??"";if(!Number.isFinite(l))return;const d=c.length>l,u=d?p.splitCollapsedBoldText(s,l,c):null,h=s.getAttribute(p.DATA_ATTR_PREV_LENGTH),g=h?Number(h):NaN,f=s.previousSibling,m=(f==null?void 0:f.nodeType)===Node.TEXT_NODE?f:null,b=(m==null?void 0:m.textContent)??"",E=!!(h&&Number.isFinite(g)&&m&&b.length>g);if(E&&m){const x=b.slice(0,g),P=b.slice(g);m.textContent=x;const I=document.createTextNode(P);(k=s.parentNode)==null||k.insertBefore(I,s.nextSibling)}if(E&&s.removeAttribute(p.DATA_ATTR_PREV_LENGTH),n!=null&&n.isCollapsed&&u&&p.isNodeWithin(n.focusNode,s)){const x=document.createRange(),P=((N=u.textContent)==null?void 0:N.length)??0;x.setStart(u,P),x.collapse(!0),n.removeAllRanges(),n.addRange(x)}d&&s.removeAttribute(p.DATA_ATTR_COLLAPSED_LENGTH)})}static splitCollapsedBoldText(n,e,t){const o=n,r=o.parentNode;if(!r)return null;const i=t.slice(0,e),s=t.slice(e);o.textContent=i;const a=document.createTextNode(s);return r.insertBefore(a,o.nextSibling),a}static isNodeWithin(n,e){return n?n===e||e.contains(n):!1}static handleGlobalSelectionChange(){p.refreshSelectionState("selectionchange")}static handleGlobalInput(){p.refreshSelectionState("input")}static refreshSelectionState(n){const e=window.getSelection();p.enforceCollapsedBoldLengths(e),p.maintainCollapsedExitState(),p.synchronizeCollapsedBold(e),p.normalizeBoldTagsWithinEditor(e),p.replaceNbspInBlock(e),p.removeEmptyBoldElements(e),n==="input"&&e&&p.moveCaretAfterBoundaryBold(e),p.normalizeAllBoldTags()}static ensureMutationObserver(){if(typeof MutationObserver>"u"||p.mutationObserver)return;const n=new MutationObserver(e=>{if(!p.isProcessingMutation){p.isProcessingMutation=!0;try{e.forEach(t=>{t.addedNodes.forEach(o=>{p.normalizeBoldInNode(o)}),t.type==="characterData"&&t.target&&p.normalizeBoldInNode(t.target)})}finally{p.isProcessingMutation=!1}}});n.observe(document.body,{subtree:!0,childList:!0,characterData:!0}),p.mutationObserver=n}static handleBeforeInput(n){if(n.inputType!=="formatBold")return;const e=window.getSelection(),t=!!(e&&p.isSelectionInsideEditor(e)),o=p.isEventTargetInsideEditor(n.target);!t&&!o||(n.preventDefault(),n.stopPropagation(),n.stopImmediatePropagation(),p.normalizeAllBoldTags())}static exitCollapsedBold(n,e){const t=p.ensureStrongElement(e),o=t.parentNode;if(o)return p.isElementEmpty(t)?p.removeEmptyBoldElement(n,t,o):p.exitCollapsedBoldWithContent(n,t,o)}static removeEmptyBoldElement(n,e,t){const o=document.createRange();return o.setStartBefore(e),o.collapse(!0),t.removeChild(e),n.removeAllRanges(),n.addRange(o),o}static exitCollapsedBoldWithContent(n,e,t){var u,h;e.setAttribute(p.DATA_ATTR_COLLAPSED_LENGTH,(((u=e.textContent)==null?void 0:u.length)??0).toString()),e.removeAttribute(p.DATA_ATTR_PREV_LENGTH),e.removeAttribute(p.DATA_ATTR_COLLAPSED_ACTIVE),e.removeAttribute(p.DATA_ATTR_LEADING_WHITESPACE);const o=e.nextSibling,r=!o||o.nodeType!==Node.TEXT_NODE,i=r?document.createTextNode("​"):null;i&&t.insertBefore(i,o);const s=i??o;!r&&(s.textContent??"").length===0&&(s.textContent="​");const a=document.createRange(),c=(s.textContent??"").startsWith("​")?1:0;a.setStart(s,c),a.collapse(!0),n.removeAllRanges(),n.addRange(a);const d=p.ensureStrongElement(e);return p.collapsedExitRecords.add({boundary:s,boldElement:d,allowedLength:((h=d.textContent)==null?void 0:h.length)??0,hasLeadingSpace:!1,hasTypedContent:!1,leadingWhitespace:""}),a}static getBoundaryBold(n){const e=n.startContainer;return e.nodeType===Node.TEXT_NODE?p.getBoundaryBoldForText(n,e):e.nodeType===Node.ELEMENT_NODE?p.getBoundaryBoldForElement(n,e):null}static getBoundaryBoldForText(n,e){var r;const t=((r=e.textContent)==null?void 0:r.length)??0;if(n.startOffset===t)return p.findBoldElement(e);if(n.startOffset!==0)return null;const o=e.previousSibling;return p.isBoldElement(o)?o:null}static getBoundaryBoldForElement(n,e){if(n.startOffset<=0)return null;const t=e.childNodes[n.startOffset-1];return p.isBoldElement(t)?t:null}static handleShortcut(n){if(p.guardCollapsedBoundaryKeydown(n),!p.isBoldShortcut(n))return;const e=window.getSelection();if(!e||!e.rangeCount||!p.isSelectionInsideEditor(e))return;const t=p.instances.values().next().value??new p;t&&(n.preventDefault(),n.stopPropagation(),n.stopImmediatePropagation(),t.toggleBold())}static isBoldShortcut(n){return!((typeof navigator<"u"?navigator.userAgent.toLowerCase():"").includes("mac")?n.metaKey:n.ctrlKey)||n.altKey?!1:n.key.toLowerCase()==="b"}static isSelectionInsideEditor(n){const e=n.anchorNode;if(!e)return!1;const t=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;return!!(t!=null&&t.closest(`.${w.CSS.editorWrapper}`))}static isEventTargetInsideEditor(n){var t;if(!n||typeof Node>"u")return!1;if(n instanceof Element)return!!n.closest(`.${w.CSS.editorWrapper}`);if(n instanceof Text)return!!((t=n.parentElement)!=null&&t.closest(`.${w.CSS.editorWrapper}`));if(typeof ShadowRoot<"u"&&n instanceof ShadowRoot)return p.isEventTargetInsideEditor(n.host);if(!(n instanceof Node))return!1;const e=n.parentNode;return e?e instanceof Element?!!e.closest(`.${w.CSS.editorWrapper}`):p.isEventTargetInsideEditor(e):!1}getRangeHtmlWithoutBold(n){const e=n.cloneContents();this.removeNestedBold(e);const t=document.createElement("div");return t.appendChild(e),t.innerHTML}static createFragmentFromHtml(n){const e=document.createElement("template");return e.innerHTML=n,e.content}collectBoldAncestors(n){const e=new Set,t=document.createTreeWalker(n.commonAncestorContainer,NodeFilter.SHOW_TEXT,{acceptNode:o=>{try{return n.intersectsNode(o)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}catch{const i=document.createRange();i.selectNodeContents(o);const s=n.compareBoundaryPoints(Range.END_TO_START,i)>0,a=n.compareBoundaryPoints(Range.START_TO_END,i)<0;return s&&a?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}}});for(;t.nextNode();){const o=p.findBoldElement(t.currentNode);o&&e.add(o)}return Array.from(e)}};let se=p;se.isInline=!0,se.title="Bold",se.shortcutListenerRegistered=!1,se.selectionListenerRegistered=!1,se.inputListenerRegistered=!1,se.beforeInputListenerRegistered=!1,se.globalListenersInitialized=p.initializeGlobalListeners(),se.collapsedExitRecords=new Set,se.markerSequence=0,se.isProcessingMutation=!1,se.DATA_ATTR_COLLAPSED_LENGTH="data-bold-collapsed-length",se.DATA_ATTR_COLLAPSED_ACTIVE="data-bold-collapsed-active",se.DATA_ATTR_PREV_LENGTH="data-bold-prev-length",se.DATA_ATTR_LEADING_WHITESPACE="data-bold-leading-ws",se.instances=new Set,se.pendingBoundaryCaretAdjustments=new WeakSet;class ai{static get sanitize(){return{i:{},em:{}}}render(){return{icon:WE,name:"italic",onActivate:()=>{this.toggleItalic()},isActive:()=>{const e=window.getSelection();return e?this.isSelectionVisuallyItalic(e):!1}}}get shortcut(){return"CMD+I"}toggleItalic(){const e=window.getSelection();if(!e||e.rangeCount===0)return;const t=e.getRangeAt(0);if(t.collapsed){this.toggleCollapsedItalic(t,e);return}this.isRangeItalic(t,{ignoreWhitespace:!0})?this.unwrapItalicTags(t):this.wrapWithItalic(t)}toggleCollapsedItalic(e,t){if(this.isRangeItalic(e,{ignoreWhitespace:!0})){const r=document.createTextNode("​");e.insertNode(r),e.selectNode(r),this.unwrapItalicTags(e);const i=document.createRange();i.setStart(r,1),i.setEnd(r,1),t.removeAllRanges(),t.addRange(i)}else{const r=document.createElement("i"),i=document.createTextNode("​");r.appendChild(i),e.insertNode(r);const s=document.createRange();s.setStart(i,1),s.setEnd(i,1),t.removeAllRanges(),t.addRange(s)}}isSelectionVisuallyItalic(e){if(!e||e.rangeCount===0)return!1;const t=e.getRangeAt(0);return this.isRangeItalic(t,{ignoreWhitespace:!0})}isRangeItalic(e,t){if(e.collapsed)return!!this.findItalicElement(e.startContainer);const o=document.createTreeWalker(e.commonAncestorContainer,NodeFilter.SHOW_TEXT,{acceptNode:i=>{try{return e.intersectsNode(i)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}catch{const a=document.createRange();a.selectNodeContents(i);const l=e.compareBoundaryPoints(Range.END_TO_START,a)>0,c=e.compareBoundaryPoints(Range.START_TO_END,a)<0;return l&&c?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}}}),r=[];for(;o.nextNode();){const i=o.currentNode,s=i.textContent??"";t.ignoreWhitespace&&s.trim().length===0||s.length!==0&&r.push(i)}return r.length===0?!!this.findItalicElement(e.startContainer):r.every(i=>this.hasItalicParent(i))}wrapWithItalic(e){const t=this.getRangeHtmlWithoutItalic(e),o=this.replaceRangeWithHtml(e,`<i>${t}</i>`),r=window.getSelection();r&&o&&(r.removeAllRanges(),r.addRange(o))}unwrapItalicTags(e){const t=this.collectItalicAncestors(e),o=window.getSelection();if(!o)return;const r=document.createElement("span"),i=e.extractContents();r.appendChild(i),this.removeNestedItalic(r),e.insertNode(r);const s=document.createRange();for(s.selectNodeContents(r),o.removeAllRanges(),o.addRange(s);;){const d=this.findItalicElement(r);if(!d)break;this.moveMarkerOutOfItalic(r,d)}const a=r.firstChild,l=r.lastChild;this.unwrapElement(r),(a&&l?(()=>{const d=document.createRange();return d.setStartBefore(a),d.setEndAfter(l),o.removeAllRanges(),o.addRange(d),d})():void 0)||o.removeAllRanges(),t.forEach(d=>{(d.textContent??"").length===0&&d.remove()})}hasItalicParent(e){return e?e.nodeType===Node.ELEMENT_NODE&&this.isItalicTag(e)?!0:this.hasItalicParent(e.parentNode):!1}findItalicElement(e){return e?e.nodeType===Node.ELEMENT_NODE&&this.isItalicTag(e)?e:this.findItalicElement(e.parentNode):null}isItalicTag(e){const t=e.tagName;return t==="I"||t==="EM"}collectItalicAncestors(e){const t=new Set,o=document.createTreeWalker(e.commonAncestorContainer,NodeFilter.SHOW_TEXT,{acceptNode:r=>{try{return e.intersectsNode(r)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}catch{const s=document.createRange();s.selectNodeContents(r);const a=e.compareBoundaryPoints(Range.END_TO_START,s)>0,l=e.compareBoundaryPoints(Range.START_TO_END,s)<0;return a&&l?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}}});for(;o.nextNode();){const r=this.findItalicElement(o.currentNode);r&&t.add(r)}return Array.from(t)}getRangeHtmlWithoutItalic(e){const t=e.cloneContents();this.removeNestedItalic(t);const o=document.createElement("div");return o.appendChild(t),o.innerHTML}removeNestedItalic(e){var o;const t=(o=e.querySelectorAll)==null?void 0:o.call(e,"i,em");t&&t.forEach(r=>{this.unwrapElement(r)})}unwrapElement(e){const t=e.parentNode;if(!t){e.remove();return}for(;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}replaceRangeWithHtml(e,t){const o=this.createFragmentFromHtml(t),r=o.firstChild??null,i=o.lastChild??null;if(e.deleteContents(),!r||!i)return;e.insertNode(o);const s=document.createRange();return s.setStartBefore(r),s.setEndAfter(i),s}createFragmentFromHtml(e){const t=document.createElement("template");return t.innerHTML=e,t.content}moveMarkerOutOfItalic(e,t){const o=t.parentNode;if(!o)return;if(Array.from(t.childNodes).forEach(l=>{l.nodeType===Node.TEXT_NODE&&(l.textContent??"").length===0&&l.remove()}),t.childNodes.length===1&&t.firstChild===e){t.replaceWith(e);return}if(t.firstChild===e){o.insertBefore(e,t);return}if(t.lastChild===e){o.insertBefore(e,t.nextSibling);return}const a=t.cloneNode(!1);for(;e.nextSibling;)a.appendChild(e.nextSibling);o.insertBefore(a,t.nextSibling),o.insertBefore(e,a)}}ai.isInline=!0,ai.title="Italic";var Jn;const Sw=(Jn=class{constructor({api:n}){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.DATA_ATTRIBUTES={buttonActive:"data-link-tool-active",buttonUnlink:"data-link-tool-unlink",inputOpened:"data-link-tool-input-opened"},this.nodes={input:null,button:null},this.inputOpened=!1,this.unlinkAvailable=!1,this.handleButtonClick=e=>{!this.inputOpened||!this.unlinkAvailable||(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),this.restoreSelection(),this.unlink(),this.inlineToolbar.close())},this.toolbar=n.toolbar,this.inlineToolbar=n.inlineToolbar,this.notifier=n.notifier,this.i18n=n.i18n,this.selection=new w,this.nodes.input=this.createInput()}static get sanitize(){return{a:{href:!0,target:"_blank",rel:"nofollow"}}}render(){return{icon:UE,isActive:()=>!!this.selection.findParentTag("A"),children:{items:[{type:oe.Html,element:this.nodes.input}],onOpen:()=>{this.openActions(!0)},onClose:()=>{this.closeActions()}}}}createInput(){const n=document.createElement("input");return n.placeholder=this.i18n.t("Add a link"),n.enterKeyHint="done",n.classList.add(this.CSS.input),this.setBooleanStateAttribute(n,this.DATA_ATTRIBUTES.inputOpened,!1),n.addEventListener("keydown",e=>{e.key==="Enter"&&this.enterPressed(e)}),n}get shortcut(){return"CMD+K"}openActions(n=!1){if(!this.nodes.input)return;const e=this.selection.findParentTag("A"),t=!!e;if(this.updateButtonStateAttributes(t),this.unlinkAvailable=t,e){const o=e.getAttribute("href");this.nodes.input.value=o!==null?o:""}else this.nodes.input.value="";this.nodes.input.classList.add(this.CSS.inputShowed),this.setBooleanStateAttribute(this.nodes.input,this.DATA_ATTRIBUTES.inputOpened,!0),this.selection.save(),n&&this.focusInputWithRetry(),this.inputOpened=!0}focusInputWithRetry(){this.nodes.input&&(this.nodes.input.focus(),!(typeof window>"u"||typeof document>"u")&&window.setTimeout(()=>{var n;document.activeElement!==this.nodes.input&&((n=this.nodes.input)==null||n.focus())},0))}getButtonElement(){if(this.nodes.button&&document.contains(this.nodes.button))return this.nodes.button;const n=document.querySelector(`${xE} [data-item-name="link"]`);return n&&n.addEventListener("click",this.handleButtonClick,!0),this.nodes.button=n??null,this.nodes.button}updateButtonStateAttributes(n){const e=this.getButtonElement();if(!e)return;const t=typeof n=="boolean"?n:!!this.selection.findParentTag("A");this.setBooleanStateAttribute(e,this.DATA_ATTRIBUTES.buttonActive,t),this.setBooleanStateAttribute(e,this.DATA_ATTRIBUTES.buttonUnlink,t)}closeActions(n=!0){(this.selection.isFakeBackgroundEnabled||n&&this.selection.savedSelectionRange)&&this.restoreSelection(),this.nodes.input&&(this.nodes.input.classList.remove(this.CSS.inputShowed),this.setBooleanStateAttribute(this.nodes.input,this.DATA_ATTRIBUTES.inputOpened,!1),this.nodes.input.value="",this.updateButtonStateAttributes(!1),this.unlinkAvailable=!1,n&&this.selection.clearSaved(),this.inputOpened=!1)}restoreSelection(){const n=new w,e=w.isAtEditor;if(e&&n.save(),this.selection.removeFakeBackground(),this.selection.restore(),!e&&this.selection.savedSelectionRange){const r=this.selection.savedSelectionRange.commonAncestorContainer,i=r.nodeType===Node.ELEMENT_NODE?r:r.parentElement;i==null||i.focus()}if(!e)return;n.restore();const t=n.savedSelectionRange;if(t){const o=t.commonAncestorContainer,r=o.nodeType===Node.ELEMENT_NODE?o:o.parentElement;r==null||r.focus()}}enterPressed(n){if(!this.nodes.input)return;const e=this.nodes.input.value||"";if(!e.trim()){this.selection.restore(),this.unlink(),n.preventDefault(),this.closeActions(),this.inlineToolbar.close();return}if(!this.validateURL(e)){this.notifier.show({message:"Pasted link is not valid.",style:"error"}),$("Incorrect Link pasted","warn",e);return}const t=this.prepareLink(e);this.selection.removeFakeBackground(),this.selection.restore(),this.insertLink(t),n.preventDefault(),n.stopPropagation(),n.stopImmediatePropagation(),this.selection.collapseToEnd(),this.inlineToolbar.close()}validateURL(n){return!/\s/.test(n)}prepareLink(n){return this.addProtocol(n.trim())}addProtocol(n){if(/^(\w+):(\/\/)?/.test(n))return n;const e=/^\/[^/\s]/.test(n),t=n.substring(0,1)==="#",o=/^\/\/[^/\s]/.test(n);return!e&&!t&&!o?"http://"+n:n}insertLink(n){const e=this.selection.findParentTag("A");if(e){this.selection.expandToTag(e),e.href=n,e.target="_blank",e.rel="nofollow";return}const t=w.range;if(!t)return;const o=document.createElement("a");o.href=n,o.target="_blank",o.rel="nofollow",o.appendChild(t.extractContents()),t.insertNode(o),this.selection.expandToTag(o)}unlink(){const n=this.selection.findParentTag("A");n&&(this.unwrap(n),this.updateButtonStateAttributes(!1),this.unlinkAvailable=!1)}unwrap(n){var t;const e=document.createDocumentFragment();for(;n.firstChild;)e.appendChild(n.firstChild);(t=n.parentNode)==null||t.replaceChild(e,n)}setBooleanStateAttribute(n,e,t){n&&n.setAttribute(e,t?"true":"false")}},Jn.isInline=!0,Jn.title="Link",Jn);class vl{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=w.get();if(e===null)return[];const t=this.blocksAPI.getBlockByElement(e.anchorNode);if(t===void 0)return[];const o=this.toolsAPI.getBlockTools(),r=await Us(t,o);if(r.length===0)return[];const i=r.reduce((c,d)=>{var u;return(u=d.toolbox)==null||u.forEach(h=>{h.title!==void 0&&c.push({icon:h.icon,title:ne.t(ae.toolNames,h.title),name:d.name,closeOnActivate:!0,onActivate:async()=>{const g=await this.blocksAPI.convert(t.id,d.name,h.data);this.caretAPI.setToBlock(g,"end")}})}),c},[]),s=await t.getActiveToolboxEntry(),a=s!==void 0?s.icon:Js,l=!ut();return{icon:a,name:"convert-to",hint:{title:ne.ui(ae.ui.inlineToolbar.converter,"Convert to")},children:{searchable:l,items:i,onOpen:()=>{l&&(this.selectionAPI.setFakeBackground(),this.selectionAPI.save())},onClose:()=>{l&&(this.selectionAPI.restore(),this.selectionAPI.removeFakeBackground())}}}}}vl.isInline=!0;class bl{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=v.make("div",this.CSS.wrapper),t=XE,o=v.make("div",this.CSS.info),r=v.make("div",this.CSS.title,{textContent:this.title}),i=v.make("div",this.CSS.subtitle,{textContent:this.subtitle});return e.innerHTML=t,o.appendChild(r),o.appendChild(i),e.appendChild(o),e}}bl.isReadOnlySupported=!0;class xw extends Zo{constructor(){super(...arguments),this.type=Ze.Inline}getMissingMethods(e){const t=this.constructable,o=t==null?void 0:t.prototype;return o?e.filter(r=>typeof o[r]!="function"):[...e]}create(){const e=this.constructable;return new e({api:this.api,config:this.settings})}get isReadOnlySupported(){const e=this.constructable;return(e==null?void 0:e.isReadOnlySupported)??!1}get title(){return this.constructable.title||""}}class Bw extends Zo{constructor(){super(...arguments),this.type=Ze.Tune}create(e,t){const o=this.constructable;return new o({api:this.api,config:this.settings,block:t,data:e})}}class ce extends Map{get blockTools(){const e=Array.from(this.entries()).filter(([,t])=>t.isBlock());return new ce(e)}get inlineTools(){const e=Array.from(this.entries()).filter(([,t])=>t.isInline());return new ce(e)}get blockTunes(){const e=Array.from(this.entries()).filter(([,t])=>t.isTune());return new ce(e)}get internalTools(){const e=Array.from(this.entries()).filter(([,t])=>t.isInternal);return new ce(e)}get externalTools(){const e=Array.from(this.entries()).filter(([,t])=>!t.isInternal);return new ce(e)}}class _w extends Zo{constructor(){super(...arguments),this.type=Ze.Block,this.inlineTools=new ce,this.tunes=new ce}create(e,t,o){return new this.constructable({data:e,block:t,readOnly:o,api:this.api,config:this.settings})}get isReadOnlySupported(){return this.constructable[yt.IsReadOnlySupported]===!0}get isLineBreaksEnabled(){return this.constructable[yt.IsEnabledLineBreaks]??!1}get toolbox(){const e=this.constructable[yt.Toolbox],t=this.config[Tn.Toolbox];if(!(!e||Q(e))&&t!==!1)return t==null?Array.isArray(e)?e:[e]:!Array.isArray(t)&&Array.isArray(e)?[t]:Array.isArray(t)?Array.isArray(e)?t.map((o,r)=>{const i=e[r];return i?{...i,...o}:o}):t:[{...e,...t}]}get conversionConfig(){return this.constructable[yt.ConversionConfig]}get enabledInlineTools(){return this.config[Tn.EnabledInlineTools]||!1}get enabledBlockTunes(){return this.config[Tn.EnabledBlockTunes]}get pasteConfig(){return this.constructable[yt.PasteConfig]??{}}get sanitizeConfig(){if(this._sanitizeConfig)return this._sanitizeConfig;const e=super.sanitizeConfig,t=this.baseSanitizeConfig;if(Q(e))return this._sanitizeConfig=t,t;const o={};for(const r in e){if(!Object.prototype.hasOwnProperty.call(e,r))continue;const i=e[r];W(i)?o[r]=Object.assign({},t,i):o[r]=i}return this._sanitizeConfig=o,o}get baseSanitizeConfig(){if(this._baseSanitizeConfig)return this._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)),this._baseSanitizeConfig=e,e}}class Aw{constructor(e,t,o){this.api=o,this.config=e,this.editorConfig=t}get(e){const{class:t,isInternal:o=!1,...r}=this.config[e],i=t;if(i===void 0)throw new Error(`Tool "${e}" does not provide a class.`);const s=this.getConstructor(i),a=!!Reflect.get(i,qo.IsTune);return new s({name:e,constructable:i,config:r,api:this.api.getMethodsForTool(e,a),isDefault:e===this.editorConfig.defaultBlock,defaultPlaceholder:this.editorConfig.placeholder,isInternal:o})}getConstructor(e){switch(!0){case!!Reflect.get(e,aa.IsInline):return xw;case!!Reflect.get(e,qo.IsTune):return Bw;default:return _w}}}class yl{constructor({api:e}){this.api=e}render(){return{icon:jE,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()}}yl.isTune=!0;const ot=n=>{if(!j(n))throw new Error("Tool constructable must be a function");return n};class Iw extends F{constructor(){super(...arguments),this.stubTool="stub",this.factory=null,this.toolsAvailable=new ce,this.toolsUnavailable=new ce,this.inlineToolsSanitizeConfigCache=null}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(){const e=this.config.defaultBlock;if(!e)throw new Error("Default block tool name is not configured");const t=this.blockTools.get(e);if(!t)throw new Error(`Default block tool "${e}" not found in available block tools`);return t}get internal(){return this.available.internalTools}async prepare(){const e=this.config.tools??{};this.config.tools=It({},this.internalTools,e),this.validateTools();const t=this.config.tools;if(!t||Object.keys(t).length===0)throw Error("Can't start without tools");const o=this.prepareConfig(t);this.factory=new Aw(o,this.config,this.Editor.API);const r=this.getListOfPrepareFunctions(o);if(r.length===0)return Promise.resolve();const i=l=>{this.isToolPrepareData(l)&&this.toolPrepareMethodSuccess({toolName:l.toolName})},s=l=>{this.isToolPrepareData(l)&&this.toolPrepareMethodFallback({toolName:l.toolName})},a=new ul;r.forEach(l=>{a.add(async()=>{const c=Ny(l.data)?{}:l.data;try{await l.function(l.data),i(c)}catch{s(c)}})}),await a.completed,this.prepareBlockTools()}getAllInlineToolsSanitizeConfig(){if(this.inlineToolsSanitizeConfigCache)return this.inlineToolsSanitizeConfigCache;const e={};return Array.from(this.inlineTools.values()).forEach(t=>{Object.assign(e,t.sanitizeConfig)}),this.inlineToolsSanitizeConfigCache=e,e}destroy(){for(const e of this.available.values()){const t=(()=>{try{return e.reset()}catch(o){$(`Tool "${e.name}" reset failed`,"warn",o);return}})();t instanceof Promise&&t.catch(o=>{$(`Tool "${e.name}" reset failed`,"warn",o)})}}get internalTools(){return{convertTo:{class:ot(vl),isInternal:!0},link:{class:ot(Sw),isInternal:!0},bold:{class:ot(se),isInternal:!0},italic:{class:ot(ai),isInternal:!0},paragraph:{class:ot(si),inlineToolbar:!0,config:{preserveBlank:!0},isInternal:!0},stub:{class:ot(bl),isInternal:!0},delete:{class:ot(yl),isInternal:!0}}}toolPrepareMethodSuccess(e){const t=this.getFactory().get(e.toolName);if(!t.isInline()){this.toolsAvailable.set(t.name,t);return}const o=["render"],r=t.getMissingMethods(o);if(r.length){$(`Incorrect Inline Tool: ${t.name}. Some of required methods is not implemented %o`,"warn",r),this.toolsUnavailable.set(t.name,t);return}this.toolsAvailable.set(t.name,t)}toolPrepareMethodFallback(e){const t=this.getFactory();this.toolsUnavailable.set(e.toolName,t.get(e.toolName))}getListOfPrepareFunctions(e){return Object.entries(e).map(([t,o])=>{const r={toolName:t,config:o.config??{}};return{function:async s=>{const a=o.class;if(!a||!j(a.prepare))return;const l=s??r;return a.prepare.call(a,l)},data:r}})}prepareBlockTools(){Array.from(this.blockTools.values()).forEach(e=>{this.assignInlineToolsToBlockTool(e),this.assignBlockTunesToBlockTool(e)})}assignInlineToolsToBlockTool(e){const t=e;if(this.config.inlineToolbar!==!1){if(t.enabledInlineTools===!0){const o=Array.isArray(this.config.inlineToolbar)?this.createInlineToolsCollection(this.config.inlineToolbar):new ce(Array.from(this.inlineTools.entries()));t.inlineTools=o;return}if(Array.isArray(t.enabledInlineTools)){const o=this.createInlineToolsCollection(["convertTo",...t.enabledInlineTools]);t.inlineTools=o}}}assignBlockTunesToBlockTool(e){const t=e;if(t.enabledBlockTunes!==!1){if(Array.isArray(t.enabledBlockTunes)){const o=this.createBlockTunesCollection(t.enabledBlockTunes),r=[...Array.from(o.entries()),...Array.from(this.blockTunes.internalTools.entries())];t.tunes=new ce(r);return}if(Array.isArray(this.config.tunes)){const o=this.createBlockTunesCollection(this.config.tunes),r=[...Array.from(o.entries()),...Array.from(this.blockTunes.internalTools.entries())];t.tunes=new ce(r);return}t.tunes=new ce(Array.from(this.blockTunes.internalTools.entries()))}}validateTools(){const e=this.config.tools;if(!e)return;const t=this.internalTools;for(const o in e){if(!Object.prototype.hasOwnProperty.call(e,o)||o in t)continue;const r=e[o],i=j(r),a=j(r.class);if(!i&&!a)throw new Ot(`Tool «${o}» must be a constructor function or an object with function in the «class» property`)}}prepareConfig(e){const t={};for(const o in e){if(!Object.prototype.hasOwnProperty.call(e,o))continue;const r=e[o];if(W(r)){t[o]=r;continue}t[o]={class:r}}return t}isToolPrepareData(e){const t=e;return typeof(t==null?void 0:t.toolName)=="string"}getFactory(){if(this.factory===null)throw new Error("Tools factory is not initialized");return this.factory}createInlineToolsCollection(e){const t=[];for(const o of e){const r=this.inlineTools.get(o);if(!r){$(`Inline tool "${o}" is not available and will be skipped`,"warn");continue}t.push([o,r])}return new ce(t)}createBlockTunesCollection(e){const t=[];for(const o of e){const r=this.blockTunes.get(o);if(!r){$(`Block tune "${o}" is not available and will be skipped`,"warn");continue}t.push([o,r])}return new ce(t)}}const Ow=`:root{--selectionColor: #e1f2ff;--inlineSelectionColor: #d4ecff;--bg-light: #eff2f5;--grayText: #707684;--color-dark: #1d202b;--color-active-icon: #388ae5;--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;right:0;bottom:0;left: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--dragging,.codex-editor--dragging .ce-toolbar__settings-btn{cursor:-webkit-grabbing;cursor:grabbing}.codex-editor--dragging .ce-toolbar{pointer-events:none}.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 (hover: hover){.ce-toolbar__settings-btn:hover{cursor:-webkit-grab;cursor:grab}}.ce-toolbar__settings-btn:active{cursor:-webkit-grabbing;cursor:grabbing}@media (hover: hover){.ce-toolbar__settings-btn--opened:hover{cursor:pointer}}@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 (hover: hover){.codex-editor--toolbox-opened .ce-toolbar__settings-btn:hover{cursor:pointer}}@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;-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 #eff0f1;-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{position:relative;-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 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 #eff0f1;-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 0 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 #eff0f1}.cdx-loader:before{content:"";position:absolute;left:50%;top:50%;width:18px;height:18px;margin:-11px 0 0 -11px;border:2px solid #eff0f1;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 #eff0f1;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:0 solid transparent;border-left:1px solid #eff0f1;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);border-radius:var(--border-radius);overflow:hidden;-webkit-box-sizing:border-box;box-sizing:border-box;-webkit-box-shadow:0 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;right:0;bottom:0;left: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);top:auto;right:var(--offset);bottom:calc(var(--offset) + env(safe-area-inset-bottom));left:var(--offset);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--opened{display:inline-block;width:-webkit-max-content;width:-moz-max-content;width:max-content;height:var(--height)}@media (max-width: 650px){.ce-popover--inline.ce-popover--opened{height:var(--height-mobile)}}.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 [data-item-name=link] .ce-popover-item__icon--chevron-right{display:none}.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)}
39
+ `;class Nw extends F{constructor(){super(...arguments),this.isMobile=!1,this.contentRectCache=null,this.resizeDebouncer=Ms(()=>{this.windowResize()},200),this.selectionChangeDebounced=Ms(()=>{this.selectionChanged()},kE),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",editorDragging:"codex-editor--dragging"}}get contentRect(){if(this.contentRectCache!==null)return this.contentRectCache;const e=this.nodes.wrapper.querySelector(`.${re.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){if(e){this.unbindReadOnlySensitiveListeners();return}const t=()=>{this.bindReadOnlySensitiveListeners()};t();const o=window.requestIdleCallback;typeof o=="function"&&o(t,{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()?!0:Object.entries(this.Editor).filter(([e,t])=>t.flipper instanceof Fe).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<Ds;e!==this.isMobile&&this.eventsDispatcher.emit(Lt,{isEnabled:this.isMobile}),this.isMobile=e}make(){const e=this.config.holder;if(!e)throw new Error("Editor holder is not specified in the configuration.");this.nodes.holder=v.getHolder(e),this.nodes.wrapper=v.make("div",[this.CSS.editorWrapper,...this.isRtl?[this.CSS.editorRtlFix]:[]]),this.nodes.wrapper.setAttribute(pt,CE),this.nodes.redactor=v.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(v.get(e))return;const t=v.make("style",null,{id:e,textContent:Ow.toString()});this.config.style&&!Q(this.config.style)&&this.config.style.nonce&&t.setAttribute("nonce",this.config.style.nonce),v.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=>{e instanceof MouseEvent&&this.redactorClicked(e)},!1),this.readOnlyMutableListeners.on(document,"keydown",e=>{e instanceof KeyboardEvent&&this.documentKeydown(e)},!0),this.readOnlyMutableListeners.on(document,"mousedown",e=>{e instanceof MouseEvent&&this.documentClicked(e)},!0),this.watchBlockHoveredEvents(),this.enableInputsEmptyMark()}watchBlockHoveredEvents(){const e={lastHovered:null},o=To(r=>{var a;if(!(r instanceof MouseEvent)&&!(r instanceof TouchEvent))return;const i=(a=r.target)==null?void 0:a.closest(".ce-block");if(this.Editor.BlockSelection.anyBlockSelected||!i||e.lastHovered===i)return;e.lastHovered=i;const s=this.Editor.BlockManager.getBlockByChildNode(i);s&&this.eventsDispatcher.emit(ia,{block:s})},20);this.readOnlyMutableListeners.on(this.nodes.redactor,"mousemove",r=>{o(r)},{passive:!0})}unbindReadOnlySensitiveListeners(){this.readOnlyMutableListeners.clearAll()}windowResize(){this.contentRectCache=null,this.setIsMobile()}documentKeydown(e){switch(e.key??""){case"Enter":this.enterPressed(e);break;case"Backspace":case"Delete":this.backspacePressed(e);break;case"Escape":this.escapePressed(e);break;default:this.defaultBehaviour(e);break}}defaultBehaviour(e){const{currentBlock:t}=this.Editor.BlockManager,o=e.target.closest(`.${this.CSS.editorWrapper}`),r=e.altKey||e.ctrlKey||e.metaKey||e.shiftKey;if(t!==void 0&&o===null){this.Editor.BlockEvents.keydown(e);return}o||t&&r||(this.Editor.BlockManager.unsetCurrentBlock(),this.Editor.Toolbar.close())}backspacePressed(e){const{BlockManager:t,BlockSelection:o,Caret:r}=this.Editor,i=w.isSelectionExists,s=w.isCollapsed;if(!(o.anyBlockSelected&&(!i||s===!0||this.Editor.CrossBlockSelection.isCrossBlockSelectionStarted)))return;const l=t.removeSelectedBlocks();if(l===void 0)return;const c=t.insertDefaultBlockAtIndex(l,!0);r.setToBlock(c,r.positions.START),o.clearSelection(e),e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation()}escapePressed(e){if(this.Editor.BlockSelection.clearSelection(e),this.Editor.Toolbar.toolbox.opened){this.Editor.Toolbar.toolbox.close(),this.Editor.BlockManager.currentBlock&&this.Editor.Caret.setToBlock(this.Editor.BlockManager.currentBlock,this.Editor.Caret.positions.END);return}if(this.Editor.BlockSettings.opened){this.Editor.BlockSettings.close();return}if(this.Editor.InlineToolbar.opened){this.Editor.InlineToolbar.close();return}this.Editor.Toolbar.close()}enterPressed(e){const{BlockManager:t,BlockSelection:o}=this.Editor;if(this.someToolbarOpened)return;const r=t.currentBlockIndex>=0,i=w.isSelectionExists,s=w.isCollapsed;if(o.anyBlockSelected&&(!i||s===!0)){o.clearSelection(e),e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation();return}if(!this.someToolbarOpened&&r&&e.target.tagName==="BODY"){const a=this.Editor.BlockManager.insert();e.preventDefault(),this.Editor.Caret.setToBlock(a),this.Editor.Toolbar.moveAndOpen(a)}this.Editor.BlockSelection.clearSelection(e)}documentClicked(e){var h;if(!e.isTrusted)return;const t=e.target,o=this.nodes.holder.contains(t)||w.isAtEditor,r=this.nodes.redactor.contains(t),i=this.Editor.Toolbar.contains(t);(!(o||i)||!r&&!i)&&(this.Editor.BlockManager.unsetCurrentBlock(),this.Editor.Toolbar.close());const l=this.Editor.BlockSettings.contains(t),c=(h=this.Editor.Toolbar.nodes.settingsToggler)==null?void 0:h.contains(t),d=l||c,u=this.Editor.BlockSettings.opened&&!d;if(u&&this.Editor.BlockSettings.close(),u&&r){const g=this.Editor.BlockManager.getBlockByChildNode(t);this.Editor.Toolbar.moveAndOpen(g)}this.Editor.BlockSelection.clearSelection(e)}documentTouched(e){const t=e.target,o=(()=>{if(t!==this.nodes.redactor)return t;if(e instanceof MouseEvent)return document.elementFromPoint(e.clientX,e.clientY)??t;if(e instanceof TouchEvent&&e.touches.length>0){const{clientX:r,clientY:i}=e.touches[0];return document.elementFromPoint(r,i)??t}return t})();try{this.Editor.BlockManager.setCurrentBlockByChildNode(o)}catch{this.Editor.RectangleSelection.isRectActivated()||this.Editor.Caret.setToTheLastBlock()}!this.Editor.ReadOnly.isEnabled&&!this.Editor.Toolbar.contains(t)&&this.Editor.Toolbar.moveAndOpen()}redactorClicked(e){if(!w.isCollapsed)return;const t=e.target,o=e.metaKey||e.ctrlKey;if(!(v.isAnchor(t)&&o)){this.processBottomZoneClick(e);return}e.stopImmediatePropagation(),e.stopPropagation();const i=t.getAttribute("href");if(!i)return;const s=Dy(i);Fy(s)}processBottomZoneClick(e){var d,u;const t=this.Editor.BlockManager.getBlockByIndex(-1),o=v.offset(t.holder).bottom,r=e.pageY,{BlockSelection:i}=this.Editor;if(!(e.target instanceof Element&&e.target.isEqualNode(this.nodes.redactor)&&!i.anyBlockSelected&&o<r))return;e.stopImmediatePropagation(),e.stopPropagation();const{BlockManager:a,Caret:l,Toolbar:c}=this.Editor;(!((d=a.lastBlock)!=null&&d.tool.isDefault)||!((u=a.lastBlock)!=null&&u.isEmpty))&&a.insertAtEnd(),l.setToTheLastBlock(),c.moveAndOpen(a.lastBlock)}selectionChanged(){var l;const{CrossBlockSelection:e,BlockSelection:t}=this.Editor,o=w.anchorElement;if(e.isCrossBlockSelectionStarted&&t.anyBlockSelected&&((l=w.get())==null||l.removeAllRanges()),!o&&!w.range&&this.Editor.InlineToolbar.close(),!o)return;const r=o.closest(`.${re.CSS.content}`),i=r===null||r.closest(`.${w.CSS.editorWrapper}`)!==this.nodes.wrapper,s=o.dataset.inlineToolbar==="true";i&&!this.Editor.InlineToolbar.containsNode(o)&&this.Editor.InlineToolbar.close(),!(i&&!s)&&(this.Editor.BlockManager.currentBlock||this.Editor.BlockManager.setCurrentBlockByChildNode(o),this.Editor.InlineToolbar.tryToShow(!0))}enableInputsEmptyMark(){const e=t=>{const o=t.target;$s(o)};this.readOnlyMutableListeners.on(this.nodes.wrapper,"input",e),this.readOnlyMutableListeners.on(this.nodes.wrapper,"focusin",e),this.readOnlyMutableListeners.on(this.nodes.wrapper,"focusout",e)}}const Rw={BlocksAPI:Ky,CaretAPI:Yy,EventsAPI:Xy,I18nAPI:Ao,API:Vy,InlineToolbarAPI:qy,ListenersAPI:Zy,NotifierAPI:Qy,ReadOnlyAPI:eE,SanitizerAPI:gE,SaverAPI:mE,SelectionAPI:vE,ToolsAPI:bE,StylesAPI:yE,ToolbarAPI:EE,TooltipAPI:ME,UiAPI:DE,BlockSettings:tT,Toolbar:sT,InlineToolbar:aT,BlockEvents:Hk,BlockManager:pw,BlockSelection:gw,Caret:Zn,CrossBlockSelection:bw,ModificationsObserver:yw,Paste:ml,ReadOnly:Ew,RectangleSelection:Zt,Renderer:Tw,Saver:kw,Tools:Iw,UI:Nw};class Lw{constructor(e){this.moduleInstances={},this.eventsDispatcher=new Nt,this.config={},this.isReady=new Promise((t,o)=>{Promise.resolve().then(async()=>{this.configuration=e,this.validate(),this.init(),await this.start(),await this.render();const{BlockManager:r,Caret:i,UI:s,ModificationsObserver:a}=this.moduleInstances;s.checkEmptiness(),a.enable(),this.configuration.autofocus===!0&&this.configuration.readOnly!==!0&&i.setToBlock(r.blocks[0],i.positions.START),t()}).catch(r=>{$(`Editor.js is not ready because of ${r}`,"error"),o(r)})})}set configuration(e){var l,c,d;W(e)?this.config={...e}:this.config={holder:e},this.config.holder==null&&(this.config.holder="editorjs"),this.config.logLevel==null&&(this.config.logLevel=Os.VERBOSE),Oy(this.config.logLevel),this.config.defaultBlock=this.config.defaultBlock??"paragraph";const t=this.config.tools,o=this.config.defaultBlock,r=t!=null&&Object.prototype.hasOwnProperty.call(t,o??""),i=(l=this.config.data)==null?void 0:l.blocks,s=Array.isArray(i)&&i.length>0;if(o&&o!=="paragraph"&&!r&&!s){$(`Default block "${o}" is not configured. Falling back to "paragraph" tool.`,"warn"),this.config.defaultBlock="paragraph";const h={...this.config.tools??{}},g=h.paragraph;h.paragraph=this.createParagraphToolConfig(g),this.config.tools=h}this.config.minHeight=this.config.minHeight!==void 0?this.config.minHeight:300;const a={type:this.config.defaultBlock,data:{}};this.config.placeholder===void 0&&(this.config.placeholder=!1),this.config.sanitizer=this.config.sanitizer??{},this.config.hideToolbar=this.config.hideToolbar??!1,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=this.config.inlineToolbar!==void 0?this.config.inlineToolbar:!0,(Q(this.config.data)||!this.config.data.blocks||this.config.data.blocks.length===0)&&(this.config.data={blocks:[a]}),this.config.readOnly=this.config.readOnly||!1,(c=this.config.i18n)!=null&&c.messages&&ne.setDictionary(this.config.i18n.messages),this.config.i18n.direction=((d=this.config.i18n)==null?void 0:d.direction)||"ltr"}get configuration(){return this.config}validate(){const{holder:e}=this.config;if(we(e)&&!v.get(e))throw Error(`element with ID «${e}» is missing. Pass correct holder's ID.`);if(e&&W(e)&&!v.isElement(e))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((t,o)=>t.then(async()=>{try{await this.moduleInstances[o].prepare()}catch(r){if(r instanceof Ot)throw new Error(r.message);$(`Module ${o} was skipped because of %o`,"warn",r)}}),Promise.resolve())}render(){const e=this.moduleInstances.Renderer;if(!e)throw new Ot("Renderer module is not initialized");if(!this.config.data)throw new Ot("Editor data is not initialized");return e.render(this.config.data.blocks)}constructModules(){Object.entries(Rw).forEach(([e,t])=>{try{this.moduleInstances[e]=new t({config:this.configuration,eventsDispatcher:this.eventsDispatcher})}catch(o){$(`[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))}createParagraphToolConfig(e){if(e===void 0)return{config:{preserveBlank:!0}};if(j(e))return{class:e,config:{preserveBlank:!0}};if(W(e)){const t=e,o=t.config;return{...t,config:{...W(o)?o:{},preserveBlank:!0}}}return{config:{preserveBlank:!0}}}getModulesDiff(e){const t={};for(const o in this.moduleInstances)o!==e&&(t[o]=this.moduleInstances[o]);return t}}/**
40
+ * Editor.js
41
+ * @license Apache-2.0
42
+ * @see Editor.js <https://editorjs.io>
43
+ * @author CodeX Team <https://codex.so>
44
+ */class Qn{static get version(){return fn()}constructor(e){this.initialConfiguration=W(e)?{...e}:e;const t=W(e)&&j(e.onReady)?e.onReady:()=>{},o=new Lw(e);this.destroy=()=>{},this.isReady=o.isReady.then(()=>{this.exportAPI(o),t()})}exportAPI(e){var f;const t=["configuration"],o=()=>{Object.values(e.moduleInstances).forEach(m=>{if(m==null)return;j(m.destroy)&&m.destroy();const b=m.listeners;b&&j(b.removeAll)&&b.removeAll()}),PE();for(const m in this)Object.prototype.hasOwnProperty.call(this,m)&&delete this[m];Object.setPrototypeOf(this,null)};t.forEach(m=>{if(m!=="configuration"){this[m]=e[m];return}const b=e.configuration,E=W(this.initialConfiguration)?this.initialConfiguration:b??this.initialConfiguration;E!==void 0&&(this[m]=E)}),this.destroy=o;const r=e.moduleInstances.API.methods,i=((f=e.moduleInstances.EventsAPI)==null?void 0:f.methods)??r.events;if(i!==void 0){const m=b=>{Object.prototype.hasOwnProperty.call(b,"eventsDispatcher")||Object.defineProperty(b,"eventsDispatcher",{value:i,configurable:!0,enumerable:!0,writable:!1})};m(r),m(this)}Object.getPrototypeOf(r)!==Qn.prototype&&Object.setPrototypeOf(r,Qn.prototype),Object.setPrototypeOf(this,r);const s=Object.create(null),a=e.moduleInstances,l=a,c=m=>/^[A-Z]+$/.test(m)?m.toLowerCase():m.charAt(0).toLowerCase()+m.slice(1);Object.keys(l).forEach(m=>{const b=c(m);Object.defineProperty(s,b,{configurable:!0,enumerable:!0,get:()=>l[m]})});const d=a.Toolbar,u=a.BlockSettings;d!==void 0&&u!==void 0&&d.blockSettings===void 0&&(d.blockSettings=u);const h=a.InlineToolbar;d!==void 0&&h!==void 0&&d.inlineToolbar===void 0&&(d.inlineToolbar=h),Object.defineProperty(this,"module",{value:s,configurable:!0,enumerable:!1,writable:!1}),delete this.exportAPI,Object.entries({blocks:{clear:"clear",render:"render"},caret:{focus:"focus"},events:{on:"on",off:"off",emit:"emit"},saver:{save:"save"}}).forEach(([m,b])=>{Object.entries(b).forEach(([E,k])=>{const N=m,x=e.moduleInstances.API.methods[N];this[k]=x[E]})})}}var eo={},Pw={get exports(){return eo},set exports(n){eo=n}};(function(n,e){(function(t,o){n.exports=o()})(window,function(){return function(t){var o={};function r(i){if(o[i])return o[i].exports;var s=o[i]={i,l:!1,exports:{}};return t[i].call(s.exports,s,s.exports,r),s.l=!0,s.exports}return r.m=t,r.c=o,r.d=function(i,s,a){r.o(i,s)||Object.defineProperty(i,s,{enumerable:!0,get:a})},r.r=function(i){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(i,"__esModule",{value:!0})},r.t=function(i,s){if(1&s&&(i=r(i)),8&s||4&s&&typeof i=="object"&&i&&i.__esModule)return i;var a=Object.create(null);if(r.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:i}),2&s&&typeof i!="string")for(var l in i)r.d(a,l,function(c){return i[c]}.bind(null,l));return a},r.n=function(i){var s=i&&i.__esModule?function(){return i.default}:function(){return i};return r.d(s,"a",s),s},r.o=function(i,s){return Object.prototype.hasOwnProperty.call(i,s)},r.p="/",r(r.s=0)}([function(t,o,r){r(1),t.exports=function(){var i=r(6),s="cdx-notify--bounce-in",a=null;return{show:function(l){if(l.message){(function(){if(a)return!0;a=i.getWrapper(),document.body.appendChild(a)})();var c=null,d=l.time||8e3;switch(l.type){case"confirm":c=i.confirm(l);break;case"prompt":c=i.prompt(l);break;default:c=i.alert(l),window.setTimeout(function(){c.remove()},d)}a.appendChild(c),c.classList.add(s)}}}}()},function(t,o,r){var i=r(2);typeof i=="string"&&(i=[[t.i,i,""]]);var s={hmr:!0,transform:void 0,insertInto:void 0};r(4)(i,s),i.locals&&(t.exports=i.locals)},function(t,o,r){(t.exports=r(3)(!1)).push([t.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(t,o){t.exports=function(r){var i=[];return i.toString=function(){return this.map(function(s){var a=function(l,c){var d=l[1]||"",u=l[3];if(!u)return d;if(c&&typeof btoa=="function"){var h=(f=u,"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(f))))+" */"),g=u.sources.map(function(m){return"/*# sourceURL="+u.sourceRoot+m+" */"});return[d].concat(g).concat([h]).join(`
45
+ `)}var f;return[d].join(`
46
+ `)}(s,r);return s[2]?"@media "+s[2]+"{"+a+"}":a}).join("")},i.i=function(s,a){typeof s=="string"&&(s=[[null,s,""]]);for(var l={},c=0;c<this.length;c++){var d=this[c][0];typeof d=="number"&&(l[d]=!0)}for(c=0;c<s.length;c++){var u=s[c];typeof u[0]=="number"&&l[u[0]]||(a&&!u[2]?u[2]=a:a&&(u[2]="("+u[2]+") and ("+a+")"),i.push(u))}},i}},function(t,o,r){var i,s,a={},l=(i=function(){return window&&document&&document.all&&!window.atob},function(){return s===void 0&&(s=i.apply(this,arguments)),s}),c=function(C){var T={};return function(A){if(typeof A=="function")return A();if(T[A]===void 0){var R=function(z){return document.querySelector(z)}.call(this,A);if(window.HTMLIFrameElement&&R instanceof window.HTMLIFrameElement)try{R=R.contentDocument.head}catch{R=null}T[A]=R}return T[A]}}(),d=null,u=0,h=[],g=r(5);function f(C,T){for(var A=0;A<C.length;A++){var R=C[A],z=a[R.id];if(z){z.refs++;for(var L=0;L<z.parts.length;L++)z.parts[L](R.parts[L]);for(;L<R.parts.length;L++)z.parts.push(x(R.parts[L],T))}else{var K=[];for(L=0;L<R.parts.length;L++)K.push(x(R.parts[L],T));a[R.id]={id:R.id,refs:1,parts:K}}}}function m(C,T){for(var A=[],R={},z=0;z<C.length;z++){var L=C[z],K=T.base?L[0]+T.base:L[0],M={css:L[1],media:L[2],sourceMap:L[3]};R[K]?R[K].parts.push(M):A.push(R[K]={id:K,parts:[M]})}return A}function b(C,T){var A=c(C.insertInto);if(!A)throw new Error("Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid.");var R=h[h.length-1];if(C.insertAt==="top")R?R.nextSibling?A.insertBefore(T,R.nextSibling):A.appendChild(T):A.insertBefore(T,A.firstChild),h.push(T);else if(C.insertAt==="bottom")A.appendChild(T);else{if(typeof C.insertAt!="object"||!C.insertAt.before)throw new Error(`[Style Loader]
47
+
48
+ Invalid value for parameter 'insertAt' ('options.insertAt') found.
49
+ Must be 'top', 'bottom', or Object.
50
+ (https://github.com/webpack-contrib/style-loader#insertat)
51
+ `);var z=c(C.insertInto+" "+C.insertAt.before);A.insertBefore(T,z)}}function E(C){if(C.parentNode===null)return!1;C.parentNode.removeChild(C);var T=h.indexOf(C);T>=0&&h.splice(T,1)}function k(C){var T=document.createElement("style");return C.attrs.type===void 0&&(C.attrs.type="text/css"),N(T,C.attrs),b(C,T),T}function N(C,T){Object.keys(T).forEach(function(A){C.setAttribute(A,T[A])})}function x(C,T){var A,R,z,L;if(T.transform&&C.css){if(!(L=T.transform(C.css)))return function(){};C.css=L}if(T.singleton){var K=u++;A=d||(d=k(T)),R=X.bind(null,A,K,!1),z=X.bind(null,A,K,!0)}else C.sourceMap&&typeof URL=="function"&&typeof URL.createObjectURL=="function"&&typeof URL.revokeObjectURL=="function"&&typeof Blob=="function"&&typeof btoa=="function"?(A=function(M){var Z=document.createElement("link");return M.attrs.type===void 0&&(M.attrs.type="text/css"),M.attrs.rel="stylesheet",N(Z,M.attrs),b(M,Z),Z}(T),R=function(M,Z,Ne){var be=Ne.css,Jt=Ne.sourceMap,El=Z.convertToAbsoluteUrls===void 0&&Jt;(Z.convertToAbsoluteUrls||El)&&(be=g(be)),Jt&&(be+=`
52
+ /*# sourceMappingURL=data:application/json;base64,`+btoa(unescape(encodeURIComponent(JSON.stringify(Jt))))+" */");var to=new Blob([be],{type:"text/css"}),no=M.href;M.href=URL.createObjectURL(to),no&&URL.revokeObjectURL(no)}.bind(null,A,T),z=function(){E(A),A.href&&URL.revokeObjectURL(A.href)}):(A=k(T),R=function(M,Z){var Ne=Z.css,be=Z.media;if(be&&M.setAttribute("media",be),M.styleSheet)M.styleSheet.cssText=Ne;else{for(;M.firstChild;)M.removeChild(M.firstChild);M.appendChild(document.createTextNode(Ne))}}.bind(null,A),z=function(){E(A)});return R(C),function(M){if(M){if(M.css===C.css&&M.media===C.media&&M.sourceMap===C.sourceMap)return;R(C=M)}else z()}}t.exports=function(C,T){if(typeof DEBUG<"u"&&DEBUG&&typeof document!="object")throw new Error("The style-loader cannot be used in a non-browser environment");(T=T||{}).attrs=typeof T.attrs=="object"?T.attrs:{},T.singleton||typeof T.singleton=="boolean"||(T.singleton=l()),T.insertInto||(T.insertInto="head"),T.insertAt||(T.insertAt="bottom");var A=m(C,T);return f(A,T),function(R){for(var z=[],L=0;L<A.length;L++){var K=A[L];(M=a[K.id]).refs--,z.push(M)}for(R&&f(m(R,T),T),L=0;L<z.length;L++){var M;if((M=z[L]).refs===0){for(var Z=0;Z<M.parts.length;Z++)M.parts[Z]();delete a[M.id]}}}};var P,I=(P=[],function(C,T){return P[C]=T,P.filter(Boolean).join(`
53
+ `)});function X(C,T,A,R){var z=A?"":R.css;if(C.styleSheet)C.styleSheet.cssText=I(T,z);else{var L=document.createTextNode(z),K=C.childNodes;K[T]&&C.removeChild(K[T]),K.length?C.insertBefore(L,K[T]):C.appendChild(L)}}},function(t,o){t.exports=function(r){var i=typeof window<"u"&&window.location;if(!i)throw new Error("fixUrls requires window.location");if(!r||typeof r!="string")return r;var s=i.protocol+"//"+i.host,a=s+i.pathname.replace(/\/[^\/]*$/,"/");return r.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi,function(l,c){var d,u=c.trim().replace(/^"(.*)"$/,function(h,g){return g}).replace(/^'(.*)'$/,function(h,g){return g});return/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/|\s*$)/i.test(u)?l:(d=u.indexOf("//")===0?u:u.indexOf("/")===0?s+u:a+u.replace(/^\.\//,""),"url("+JSON.stringify(d)+")")})}},function(t,o,r){var i,s,a,l,c,d,u,h,g;t.exports=(i="cdx-notifies",s="cdx-notify",a="cdx-notify__cross",l="cdx-notify__button--confirm",c="cdx-notify__button--cancel",d="cdx-notify__input",u="cdx-notify__button",h="cdx-notify__btns-wrapper",{alert:g=function(f){var m=document.createElement("DIV"),b=document.createElement("DIV"),E=f.message,k=f.style;return m.classList.add(s),k&&m.classList.add(s+"--"+k),m.innerHTML=E,b.classList.add(a),b.addEventListener("click",m.remove.bind(m)),m.appendChild(b),m},confirm:function(f){var m=g(f),b=document.createElement("div"),E=document.createElement("button"),k=document.createElement("button"),N=m.querySelector("."+a),x=f.cancelHandler,P=f.okHandler;return b.classList.add(h),E.innerHTML=f.okText||"Confirm",k.innerHTML=f.cancelText||"Cancel",E.classList.add(u),k.classList.add(u),E.classList.add(l),k.classList.add(c),x&&typeof x=="function"&&(k.addEventListener("click",x),N.addEventListener("click",x)),P&&typeof P=="function"&&E.addEventListener("click",P),E.addEventListener("click",m.remove.bind(m)),k.addEventListener("click",m.remove.bind(m)),b.appendChild(E),b.appendChild(k),m.appendChild(b),m},prompt:function(f){var m=g(f),b=document.createElement("div"),E=document.createElement("button"),k=document.createElement("input"),N=m.querySelector("."+a),x=f.cancelHandler,P=f.okHandler;return b.classList.add(h),E.innerHTML=f.okText||"Ok",E.classList.add(u),E.classList.add(l),k.classList.add(d),f.placeholder&&k.setAttribute("placeholder",f.placeholder),f.default&&(k.value=f.default),f.inputType&&(k.type=f.inputType),x&&typeof x=="function"&&N.addEventListener("click",x),P&&typeof P=="function"&&E.addEventListener("click",function(){P(k.value)}),E.addEventListener("click",m.remove.bind(m)),b.appendChild(k),b.appendChild(E),m.appendChild(b),m},getWrapper:function(){var f=document.createElement("DIV");return f.classList.add(i),f}})}])})})(Pw);const Mw=xt({__proto__:null,default:li(eo)},[eo]);return Qn});