ckeditor5 41.3.0 → 41.4.0-alpha.0

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.

Potentially problematic release.


This version of ckeditor5 might be problematic. Click here for more details.

Files changed (177) hide show
  1. package/CHANGELOG.md +230 -211
  2. package/README.md +1 -1
  3. package/build/ckeditor5-dll.js +1 -1
  4. package/build/ckeditor5-dll.manifest.json +2 -2
  5. package/dist/browser/index-content.css +5 -0
  6. package/dist/browser/index-editor.css +67 -0
  7. package/dist/browser/index.css +6 -0
  8. package/dist/browser/index.css.map +1 -0
  9. package/dist/browser/index.js +6 -0
  10. package/dist/browser/index.js.map +1 -0
  11. package/dist/browser/index.umd.js +548 -0
  12. package/dist/browser/index.umd.js.map +1 -0
  13. package/dist/index-content.css +375 -0
  14. package/dist/index-editor.css +4711 -0
  15. package/dist/index.css +8887 -0
  16. package/dist/index.css.map +1 -0
  17. package/dist/index.js +61 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/translations/af.d.ts +8 -0
  20. package/dist/translations/af.js +5 -0
  21. package/dist/translations/ar.d.ts +8 -0
  22. package/dist/translations/ar.js +5 -0
  23. package/dist/translations/ast.d.ts +8 -0
  24. package/dist/translations/ast.js +5 -0
  25. package/dist/translations/az.d.ts +8 -0
  26. package/dist/translations/az.js +5 -0
  27. package/dist/translations/bg.d.ts +8 -0
  28. package/dist/translations/bg.js +5 -0
  29. package/dist/translations/bn.d.ts +8 -0
  30. package/dist/translations/bn.js +5 -0
  31. package/dist/translations/bs.d.ts +8 -0
  32. package/dist/translations/bs.js +5 -0
  33. package/dist/translations/ca.d.ts +8 -0
  34. package/dist/translations/ca.js +5 -0
  35. package/dist/translations/cs.d.ts +8 -0
  36. package/dist/translations/cs.js +5 -0
  37. package/dist/translations/da.d.ts +8 -0
  38. package/dist/translations/da.js +5 -0
  39. package/dist/translations/de-ch.d.ts +8 -0
  40. package/dist/translations/de-ch.js +5 -0
  41. package/dist/translations/de.d.ts +8 -0
  42. package/dist/translations/de.js +5 -0
  43. package/dist/translations/el.d.ts +8 -0
  44. package/dist/translations/el.js +5 -0
  45. package/dist/translations/en-au.d.ts +8 -0
  46. package/dist/translations/en-au.js +5 -0
  47. package/dist/translations/en-gb.d.ts +8 -0
  48. package/dist/translations/en-gb.js +5 -0
  49. package/dist/translations/en.d.ts +8 -0
  50. package/dist/translations/en.js +5 -0
  51. package/dist/translations/eo.d.ts +8 -0
  52. package/dist/translations/eo.js +5 -0
  53. package/dist/translations/es-co.d.ts +8 -0
  54. package/dist/translations/es-co.js +5 -0
  55. package/dist/translations/es.d.ts +8 -0
  56. package/dist/translations/es.js +5 -0
  57. package/dist/translations/et.d.ts +8 -0
  58. package/dist/translations/et.js +5 -0
  59. package/dist/translations/eu.d.ts +8 -0
  60. package/dist/translations/eu.js +5 -0
  61. package/dist/translations/fa.d.ts +8 -0
  62. package/dist/translations/fa.js +5 -0
  63. package/dist/translations/fi.d.ts +8 -0
  64. package/dist/translations/fi.js +5 -0
  65. package/dist/translations/fr.d.ts +8 -0
  66. package/dist/translations/fr.js +5 -0
  67. package/dist/translations/gl.d.ts +8 -0
  68. package/dist/translations/gl.js +5 -0
  69. package/dist/translations/gu.d.ts +8 -0
  70. package/dist/translations/gu.js +5 -0
  71. package/dist/translations/he.d.ts +8 -0
  72. package/dist/translations/he.js +5 -0
  73. package/dist/translations/hi.d.ts +8 -0
  74. package/dist/translations/hi.js +5 -0
  75. package/dist/translations/hr.d.ts +8 -0
  76. package/dist/translations/hr.js +5 -0
  77. package/dist/translations/hu.d.ts +8 -0
  78. package/dist/translations/hu.js +5 -0
  79. package/dist/translations/hy.d.ts +8 -0
  80. package/dist/translations/hy.js +5 -0
  81. package/dist/translations/id.d.ts +8 -0
  82. package/dist/translations/id.js +5 -0
  83. package/dist/translations/it.d.ts +8 -0
  84. package/dist/translations/it.js +5 -0
  85. package/dist/translations/ja.d.ts +8 -0
  86. package/dist/translations/ja.js +5 -0
  87. package/dist/translations/jv.d.ts +8 -0
  88. package/dist/translations/jv.js +5 -0
  89. package/dist/translations/kk.d.ts +8 -0
  90. package/dist/translations/kk.js +5 -0
  91. package/dist/translations/km.d.ts +8 -0
  92. package/dist/translations/km.js +5 -0
  93. package/dist/translations/kn.d.ts +8 -0
  94. package/dist/translations/kn.js +5 -0
  95. package/dist/translations/ko.d.ts +8 -0
  96. package/dist/translations/ko.js +5 -0
  97. package/dist/translations/ku.d.ts +8 -0
  98. package/dist/translations/ku.js +5 -0
  99. package/dist/translations/lt.d.ts +8 -0
  100. package/dist/translations/lt.js +5 -0
  101. package/dist/translations/lv.d.ts +8 -0
  102. package/dist/translations/lv.js +5 -0
  103. package/dist/translations/ms.d.ts +8 -0
  104. package/dist/translations/ms.js +5 -0
  105. package/dist/translations/nb.d.ts +8 -0
  106. package/dist/translations/nb.js +5 -0
  107. package/dist/translations/ne.d.ts +8 -0
  108. package/dist/translations/ne.js +5 -0
  109. package/dist/translations/nl.d.ts +8 -0
  110. package/dist/translations/nl.js +5 -0
  111. package/dist/translations/no.d.ts +8 -0
  112. package/dist/translations/no.js +5 -0
  113. package/dist/translations/oc.d.ts +8 -0
  114. package/dist/translations/oc.js +5 -0
  115. package/dist/translations/pl.d.ts +8 -0
  116. package/dist/translations/pl.js +5 -0
  117. package/dist/translations/pt-br.d.ts +8 -0
  118. package/dist/translations/pt-br.js +5 -0
  119. package/dist/translations/pt.d.ts +8 -0
  120. package/dist/translations/pt.js +5 -0
  121. package/dist/translations/ro.d.ts +8 -0
  122. package/dist/translations/ro.js +5 -0
  123. package/dist/translations/ru.d.ts +8 -0
  124. package/dist/translations/ru.js +5 -0
  125. package/dist/translations/si.d.ts +8 -0
  126. package/dist/translations/si.js +5 -0
  127. package/dist/translations/sk.d.ts +8 -0
  128. package/dist/translations/sk.js +5 -0
  129. package/dist/translations/sl.d.ts +8 -0
  130. package/dist/translations/sl.js +5 -0
  131. package/dist/translations/sq.d.ts +8 -0
  132. package/dist/translations/sq.js +5 -0
  133. package/dist/translations/sr-latn.d.ts +8 -0
  134. package/dist/translations/sr-latn.js +5 -0
  135. package/dist/translations/sr.d.ts +8 -0
  136. package/dist/translations/sr.js +5 -0
  137. package/dist/translations/sv.d.ts +8 -0
  138. package/dist/translations/sv.js +5 -0
  139. package/dist/translations/th.d.ts +8 -0
  140. package/dist/translations/th.js +5 -0
  141. package/dist/translations/tk.d.ts +8 -0
  142. package/dist/translations/tk.js +5 -0
  143. package/dist/translations/tr.d.ts +8 -0
  144. package/dist/translations/tr.js +5 -0
  145. package/dist/translations/tt.d.ts +8 -0
  146. package/dist/translations/tt.js +5 -0
  147. package/dist/translations/ug.d.ts +8 -0
  148. package/dist/translations/ug.js +5 -0
  149. package/dist/translations/uk.d.ts +8 -0
  150. package/dist/translations/uk.js +5 -0
  151. package/dist/translations/ur.d.ts +8 -0
  152. package/dist/translations/ur.js +5 -0
  153. package/dist/translations/uz.d.ts +8 -0
  154. package/dist/translations/uz.js +5 -0
  155. package/dist/translations/vi.d.ts +8 -0
  156. package/dist/translations/vi.js +5 -0
  157. package/dist/translations/zh-cn.d.ts +8 -0
  158. package/dist/translations/zh-cn.js +5 -0
  159. package/dist/translations/zh.d.ts +8 -0
  160. package/dist/translations/zh.js +5 -0
  161. package/dist/types/clipboard.d.ts +12 -0
  162. package/dist/types/core.d.ts +12 -0
  163. package/dist/types/engine.d.ts +12 -0
  164. package/dist/types/enter.d.ts +12 -0
  165. package/dist/types/index.d.ts +65 -0
  166. package/dist/types/paragraph.d.ts +12 -0
  167. package/dist/types/select-all.d.ts +12 -0
  168. package/dist/types/typing.d.ts +12 -0
  169. package/dist/types/ui.d.ts +12 -0
  170. package/dist/types/undo.d.ts +12 -0
  171. package/dist/types/upload.d.ts +12 -0
  172. package/dist/types/utils.d.ts +12 -0
  173. package/dist/types/watchdog.d.ts +12 -0
  174. package/dist/types/widget.d.ts +12 -0
  175. package/package.json +66 -14
  176. package/src/index.d.ts +61 -0
  177. package/src/index.js +61 -0
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ function e(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(i){if("default"!==i&&!(i in e)){var n=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,n.get?n:{enumerable:!0,get:function(){return t[i]}})}}))})),Object.freeze(e)}const t=function(){try{return navigator.userAgent.toLowerCase()}catch(e){return""}}(),i={isMac:n(t),isWindows:function(e){return e.indexOf("windows")>-1}(t),isGecko:function(e){return!!e.match(/gecko\/\d+/)}(t),isSafari:function(e){return e.indexOf(" applewebkit/")>-1&&-1===e.indexOf("chrome")}(t),isiOS:function(e){return!!e.match(/iphone|ipad/i)||n(e)&&navigator.maxTouchPoints>0}(t),isAndroid:function(e){return e.indexOf("android")>-1}(t),isBlink:function(e){return e.indexOf("chrome/")>-1&&e.indexOf("edge/")<0}(t),features:{isRegExpUnicodePropertySupported:function(){let e=!1;try{e=0==="ć".search(new RegExp("[\\p{L}]","u"))}catch(e){}return e}()}};function n(e){return e.indexOf("macintosh")>-1}function s(e,t,i,n){i=i||function(e,t){return e===t};const s=Array.isArray(e)?e:Array.prototype.slice.call(e),a=Array.isArray(t)?t:Array.prototype.slice.call(t),l=function(e,t,i){const n=o(e,t,i);if(-1===n)return{firstIndex:-1,lastIndexOld:-1,lastIndexNew:-1};const s=r(e,n),a=r(t,n),l=o(s,a,i),c=e.length-l,d=t.length-l;return{firstIndex:n,lastIndexOld:c,lastIndexNew:d}}(s,a,i),c=n?function(e,t){const{firstIndex:i,lastIndexOld:n,lastIndexNew:s}=e;if(-1===i)return Array(t).fill("equal");let o=[];i>0&&(o=o.concat(Array(i).fill("equal")));s-i>0&&(o=o.concat(Array(s-i).fill("insert")));n-i>0&&(o=o.concat(Array(n-i).fill("delete")));s<t&&(o=o.concat(Array(t-s).fill("equal")));return o}(l,a.length):function(e,t){const i=[],{firstIndex:n,lastIndexOld:s,lastIndexNew:o}=t;o-n>0&&i.push({index:n,type:"insert",values:e.slice(n,o)});s-n>0&&i.push({index:n+(o-n),type:"delete",howMany:s-n});return i}(a,l);return c}function o(e,t,i){for(let n=0;n<Math.max(e.length,t.length);n++)if(void 0===e[n]||void 0===t[n]||!i(e[n],t[n]))return n;return-1}function r(e,t){return e.slice(t).reverse()}function a(e,t,i){i=i||function(e,t){return e===t};const n=e.length,s=t.length;if(n>200||s>200||n+s>300)return a.fastDiff(e,t,i,!0);let o,r;if(s<n){const i=e;e=t,t=i,o="delete",r="insert"}else o="insert",r="delete";const l=e.length,c=t.length,d=c-l,h={},u={};function m(n){const s=(void 0!==u[n-1]?u[n-1]:-1)+1,a=void 0!==u[n+1]?u[n+1]:-1,d=s>a?-1:1;h[n+d]&&(h[n]=h[n+d].slice(0)),h[n]||(h[n]=[]),h[n].push(s>a?o:r);let m=Math.max(s,a),g=m-n;for(;g<l&&m<c&&i(e[g],t[m]);)g++,m++,h[n].push("equal");return m}let g,f=0;do{for(g=-f;g<d;g++)u[g]=m(g);for(g=d+f;g>d;g--)u[g]=m(g);u[d]=m(d),f++}while(u[d]!==c);return h[d].slice(1)}function l(e,t){const i=[];let n=0,s=null;return e.forEach((e=>{"equal"==e?(o(),n++):"insert"==e?(s&&"insert"==s.type?s.values.push(t[n]):(o(),s={type:"insert",index:n,values:[t[n]]}),n++):s&&"delete"==s.type?s.howMany++:(o(),s={type:"delete",index:n,howMany:1})})),o(),i;function o(){s&&(i.push(s),s=null)}}function c(e,...t){t.forEach((t=>{const i=Object.getOwnPropertyNames(t),n=Object.getOwnPropertySymbols(t);i.concat(n).forEach((i=>{if(i in e.prototype)return;if("function"==typeof t&&("length"==i||"name"==i||"prototype"==i))return;const n=Object.getOwnPropertyDescriptor(t,i);n.enumerable=!1,Object.defineProperty(e.prototype,i,n)}))}))}a.fastDiff=s;class d{constructor(e,t){this.source=e,this.name=t,this.path=[],this.stop=function e(){e.called=!0},this.off=function e(){e.called=!0}}}const h=new Array(256).fill("").map(((e,t)=>("0"+t.toString(16)).slice(-2)));function u(){const e=4294967296*Math.random()>>>0,t=4294967296*Math.random()>>>0,i=4294967296*Math.random()>>>0,n=4294967296*Math.random()>>>0;return"e"+h[255&e]+h[e>>8&255]+h[e>>16&255]+h[e>>24&255]+h[255&t]+h[t>>8&255]+h[t>>16&255]+h[t>>24&255]+h[255&i]+h[i>>8&255]+h[i>>16&255]+h[i>>24&255]+h[255&n]+h[n>>8&255]+h[n>>16&255]+h[n>>24&255]}const m={get(e="normal"){return"number"!=typeof e?this[e]||this.normal:e},highest:1e5,high:1e3,normal:0,low:-1e3,lowest:-1e5};function g(e,t){const i=m.get(t.priority);for(let n=0;n<e.length;n++)if(m.get(e[n].priority)<i)return void e.splice(n,0,t);e.push(t)}const f="https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html";class p extends Error{is(e){return"CKEditorError"===e}static rethrowUnexpectedError(e,t){if(e.is&&e.is("CKEditorError"))throw e;const i=new p(e.message,t);throw i.stack=e.stack,i}constructor(e,t,i){super(function(e,t){const i=new WeakSet,n=(e,t)=>{if("object"==typeof t&&null!==t){if(i.has(t))return`[object ${t.constructor.name}]`;i.add(t)}return t},s=t?` ${JSON.stringify(t,n)}`:"",o=v(e);return e+s+o}(e,i)),this.name="CKEditorError",this.context=t,this.data=i}}function b(e,t){console.warn(..._(e,t))}function w(e,t){console.error(..._(e,t))}function v(e){return`\nRead more: ${f}#error-${e}`}function _(e,t){const i=v(e);return t?[e,t,i]:[e,i]}const y="41.4.0-alpha.0",k=new Date(2024,3,18);if(globalThis.CKEDITOR_VERSION)throw new p("ckeditor-duplicated-modules",null);globalThis.CKEDITOR_VERSION=y;const C=Symbol("listeningTo"),x=Symbol("emitterId"),A=Symbol("delegations"),E=T(Object);function T(e){if(!e)return E;return class extends e{on(e,t,i){this.listenTo(this,e,t,i)}once(e,t,i){let n=!1;this.listenTo(this,e,((e,...i)=>{n||(n=!0,e.off(),t.call(this,e,...i))}),i)}off(e,t){this.stopListening(this,e,t)}listenTo(e,t,i,n={}){let s,o;this[C]||(this[C]={});const r=this[C];I(e)||S(e);const a=I(e);(s=r[a])||(s=r[a]={emitter:e,callbacks:{}}),(o=s.callbacks[t])||(o=s.callbacks[t]=[]),o.push(i),function(e,t,i,n,s){t._addEventListener?t._addEventListener(i,n,s):e._addEventListener.call(t,i,n,s)}(this,e,t,i,n)}stopListening(e,t,i){const n=this[C];let s=e&&I(e);const o=n&&s?n[s]:void 0,r=o&&t?o.callbacks[t]:void 0;if(!(!n||e&&!o||t&&!r))if(i){O(this,e,t,i);-1!==r.indexOf(i)&&(1===r.length?delete o.callbacks[t]:O(this,e,t,i))}else if(r){for(;i=r.pop();)O(this,e,t,i);delete o.callbacks[t]}else if(o){for(t in o.callbacks)this.stopListening(e,t);delete n[s]}else{for(s in n)this.stopListening(n[s].emitter);delete this[C]}}fire(e,...t){try{const i=e instanceof d?e:new d(this,e),n=i.name;let s=R(this,n);if(i.path.push(this),s){const e=[i,...t];s=Array.from(s);for(let t=0;t<s.length&&(s[t].callback.apply(this,e),i.off.called&&(delete i.off.called,this._removeEventListener(n,s[t].callback)),!i.stop.called);t++);}const o=this[A];if(o){const e=o.get(n),s=o.get("*");e&&B(e,i,t),s&&B(s,i,t)}return i.return}catch(e){p.rethrowUnexpectedError(e,this)}}delegate(...e){return{to:(t,i)=>{this[A]||(this[A]=new Map),e.forEach((e=>{const n=this[A].get(e);n?n.set(t,i):this[A].set(e,new Map([[t,i]]))}))}}}stopDelegating(e,t){if(this[A])if(e)if(t){const i=this[A].get(e);i&&i.delete(t)}else this[A].delete(e);else this[A].clear()}_addEventListener(e,t,i){!function(e,t){const i=P(e);if(i[t])return;let n=t,s=null;const o=[];for(;""!==n&&!i[n];)i[n]={callbacks:[],childEvents:[]},o.push(i[n]),s&&i[n].childEvents.push(s),s=n,n=n.substr(0,n.lastIndexOf(":"));if(""!==n){for(const e of o)e.callbacks=i[n].callbacks.slice();i[n].childEvents.push(s)}}(this,e);const n=V(this,e),s={callback:t,priority:m.get(i.priority)};for(const e of n)g(e,s)}_removeEventListener(e,t){const i=V(this,e);for(const e of i)for(let i=0;i<e.length;i++)e[i].callback==t&&(e.splice(i,1),i--)}}}function S(e,t){e[x]||(e[x]=t||u())}function I(e){return e[x]}function P(e){return e._events||Object.defineProperty(e,"_events",{value:{}}),e._events}function V(e,t){const i=P(e)[t];if(!i)return[];let n=[i.callbacks];for(let t=0;t<i.childEvents.length;t++){const s=V(e,i.childEvents[t]);n=n.concat(s)}return n}function R(e,t){let i;return e._events&&(i=e._events[t])&&i.callbacks.length?i.callbacks:t.indexOf(":")>-1?R(e,t.substr(0,t.lastIndexOf(":"))):null}function B(e,t,i){for(let[n,s]of e){s?"function"==typeof s&&(s=s(t.name)):s=t.name;const e=new d(t.source,s);e.path=[...t.path],n.fire(e,...i)}}function O(e,t,i,n){t._removeEventListener?t._removeEventListener(i,n):e._removeEventListener.call(t,i,n)}["on","once","off","listenTo","stopListening","fire","delegate","stopDelegating","_addEventListener","_removeEventListener"].forEach((e=>{T[e]=E.prototype[e]}));var M="object"==typeof global&&global&&global.Object===Object&&global,L="object"==typeof self&&self&&self.Object===Object&&self,N=M||L||Function("return this")(),F=N.Symbol,D=Object.prototype,z=D.hasOwnProperty,H=D.toString,$=F?F.toStringTag:void 0;var U=Object.prototype.toString;var W="[object Null]",j="[object Undefined]",q=F?F.toStringTag:void 0;function G(e){return null==e?void 0===e?j:W:q&&q in Object(e)?function(e){var t=z.call(e,$),i=e[$];try{e[$]=void 0;var n=!0}catch(e){}var s=H.call(e);return n&&(t?e[$]=i:delete e[$]),s}(e):function(e){return U.call(e)}(e)}function K(e){return null!=e&&"object"==typeof e}var Z="[object Symbol]";function J(e){return"symbol"==typeof e||K(e)&&G(e)==Z}function Q(e,t){for(var i=-1,n=null==e?0:e.length,s=Array(n);++i<n;)s[i]=t(e[i],i,e);return s}var Y=Array.isArray,X=1/0,ee=F?F.prototype:void 0,te=ee?ee.toString:void 0;function ie(e){if("string"==typeof e)return e;if(Y(e))return Q(e,ie)+"";if(J(e))return te?te.call(e):"";var t=e+"";return"0"==t&&1/e==-X?"-0":t}var ne=/\s/;var se=/^\s+/;function oe(e){return e?e.slice(0,function(e){for(var t=e.length;t--&&ne.test(e.charAt(t)););return t}(e)+1).replace(se,""):e}function re(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}var ae=NaN,le=/^[-+]0x[0-9a-f]+$/i,ce=/^0b[01]+$/i,de=/^0o[0-7]+$/i,he=parseInt;function ue(e){if("number"==typeof e)return e;if(J(e))return ae;if(re(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=re(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=oe(e);var i=ce.test(e);return i||de.test(e)?he(e.slice(2),i?2:8):le.test(e)?ae:+e}function me(e){return e}var ge="[object AsyncFunction]",fe="[object Function]",pe="[object GeneratorFunction]",be="[object Proxy]";function we(e){if(!re(e))return!1;var t=G(e);return t==fe||t==pe||t==ge||t==be}var ve=N["__core-js_shared__"],_e=function(){var e=/[^.]+$/.exec(ve&&ve.keys&&ve.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();var ye=Function.prototype.toString;function ke(e){if(null!=e){try{return ye.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var Ce=/^\[object .+?Constructor\]$/,xe=Function.prototype,Ae=Object.prototype,Ee=xe.toString,Te=Ae.hasOwnProperty,Se=RegExp("^"+Ee.call(Te).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Ie(e){return!(!re(e)||(t=e,_e&&_e in t))&&(we(e)?Se:Ce).test(ke(e));var t}function Pe(e,t){var i=function(e,t){return null==e?void 0:e[t]}(e,t);return Ie(i)?i:void 0}var Ve=Pe(N,"WeakMap"),Re=Object.create,Be=function(){function e(){}return function(t){if(!re(t))return{};if(Re)return Re(t);e.prototype=t;var i=new e;return e.prototype=void 0,i}}();function Oe(e,t){var i=-1,n=e.length;for(t||(t=Array(n));++i<n;)t[i]=e[i];return t}var Me=Date.now;var Le=function(){try{var e=Pe(Object,"defineProperty");return e({},"",{}),e}catch(e){}}(),Ne=function(e){var t=0,i=0;return function(){var n=Me(),s=16-(n-i);if(i=n,s>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}(Le?function(e,t){return Le(e,"toString",{configurable:!0,enumerable:!1,value:(i=t,function(){return i}),writable:!0});var i}:me);var Fe=9007199254740991,De=/^(?:0|[1-9]\d*)$/;function ze(e,t){var i=typeof e;return!!(t=null==t?Fe:t)&&("number"==i||"symbol"!=i&&De.test(e))&&e>-1&&e%1==0&&e<t}function He(e,t,i){"__proto__"==t&&Le?Le(e,t,{configurable:!0,enumerable:!0,value:i,writable:!0}):e[t]=i}function $e(e,t){return e===t||e!=e&&t!=t}var Ue=Object.prototype.hasOwnProperty;function We(e,t,i){var n=e[t];Ue.call(e,t)&&$e(n,i)&&(void 0!==i||t in e)||He(e,t,i)}function je(e,t,i,n){var s=!i;i||(i={});for(var o=-1,r=t.length;++o<r;){var a=t[o],l=n?n(i[a],e[a],a,i,e):void 0;void 0===l&&(l=e[a]),s?He(i,a,l):We(i,a,l)}return i}var qe=Math.max;function Ge(e,t){return Ne(function(e,t,i){return t=qe(void 0===t?e.length-1:t,0),function(){for(var n=arguments,s=-1,o=qe(n.length-t,0),r=Array(o);++s<o;)r[s]=n[t+s];s=-1;for(var a=Array(t+1);++s<t;)a[s]=n[s];return a[t]=i(r),function(e,t,i){switch(i.length){case 0:return e.call(t);case 1:return e.call(t,i[0]);case 2:return e.call(t,i[0],i[1]);case 3:return e.call(t,i[0],i[1],i[2])}return e.apply(t,i)}(e,this,a)}}(e,t,me),e+"")}var Ke=9007199254740991;function Ze(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=Ke}function Je(e){return null!=e&&Ze(e.length)&&!we(e)}function Qe(e){return Ge((function(t,i){var n=-1,s=i.length,o=s>1?i[s-1]:void 0,r=s>2?i[2]:void 0;for(o=e.length>3&&"function"==typeof o?(s--,o):void 0,r&&function(e,t,i){if(!re(i))return!1;var n=typeof t;return!!("number"==n?Je(i)&&ze(t,i.length):"string"==n&&t in i)&&$e(i[t],e)}(i[0],i[1],r)&&(o=s<3?void 0:o,s=1),t=Object(t);++n<s;){var a=i[n];a&&e(t,a,n,o)}return t}))}var Ye=Object.prototype;function Xe(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Ye)}function et(e){return K(e)&&"[object Arguments]"==G(e)}var tt=Object.prototype,it=tt.hasOwnProperty,nt=tt.propertyIsEnumerable,st=et(function(){return arguments}())?et:function(e){return K(e)&&it.call(e,"callee")&&!nt.call(e,"callee")};var ot="object"==typeof exports&&exports&&!exports.nodeType&&exports,rt=ot&&"object"==typeof module&&module&&!module.nodeType&&module,at=rt&&rt.exports===ot?N.Buffer:void 0,lt=(at?at.isBuffer:void 0)||function(){return!1},ct={};function dt(e){return function(t){return e(t)}}ct["[object Float32Array]"]=ct["[object Float64Array]"]=ct["[object Int8Array]"]=ct["[object Int16Array]"]=ct["[object Int32Array]"]=ct["[object Uint8Array]"]=ct["[object Uint8ClampedArray]"]=ct["[object Uint16Array]"]=ct["[object Uint32Array]"]=!0,ct["[object Arguments]"]=ct["[object Array]"]=ct["[object ArrayBuffer]"]=ct["[object Boolean]"]=ct["[object DataView]"]=ct["[object Date]"]=ct["[object Error]"]=ct["[object Function]"]=ct["[object Map]"]=ct["[object Number]"]=ct["[object Object]"]=ct["[object RegExp]"]=ct["[object Set]"]=ct["[object String]"]=ct["[object WeakMap]"]=!1;var ht="object"==typeof exports&&exports&&!exports.nodeType&&exports,ut=ht&&"object"==typeof module&&module&&!module.nodeType&&module,mt=ut&&ut.exports===ht&&M.process,gt=function(){try{var e=ut&&ut.require&&ut.require("util").types;return e||mt&&mt.binding&&mt.binding("util")}catch(e){}}(),ft=gt&&gt.isTypedArray,pt=ft?dt(ft):function(e){return K(e)&&Ze(e.length)&&!!ct[G(e)]},bt=Object.prototype.hasOwnProperty;function wt(e,t){var i=Y(e),n=!i&&st(e),s=!i&&!n&&lt(e),o=!i&&!n&&!s&&pt(e),r=i||n||s||o,a=r?function(e,t){for(var i=-1,n=Array(e);++i<e;)n[i]=t(i);return n}(e.length,String):[],l=a.length;for(var c in e)!t&&!bt.call(e,c)||r&&("length"==c||s&&("offset"==c||"parent"==c)||o&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||ze(c,l))||a.push(c);return a}function vt(e,t){return function(i){return e(t(i))}}var _t=vt(Object.keys,Object),yt=Object.prototype.hasOwnProperty;function kt(e){return Je(e)?wt(e):function(e){if(!Xe(e))return _t(e);var t=[];for(var i in Object(e))yt.call(e,i)&&"constructor"!=i&&t.push(i);return t}(e)}var Ct=Object.prototype.hasOwnProperty;function xt(e){if(!re(e))return function(e){var t=[];if(null!=e)for(var i in Object(e))t.push(i);return t}(e);var t=Xe(e),i=[];for(var n in e)("constructor"!=n||!t&&Ct.call(e,n))&&i.push(n);return i}function At(e){return Je(e)?wt(e,!0):xt(e)}var Et=Qe((function(e,t){je(t,At(t),e)})),Tt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,St=/^\w*$/;function It(e,t){if(Y(e))return!1;var i=typeof e;return!("number"!=i&&"symbol"!=i&&"boolean"!=i&&null!=e&&!J(e))||(St.test(e)||!Tt.test(e)||null!=t&&e in Object(t))}var Pt=Pe(Object,"create");var Vt=Object.prototype.hasOwnProperty;var Rt=Object.prototype.hasOwnProperty;function Bt(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t<i;){var n=e[t];this.set(n[0],n[1])}}function Ot(e,t){for(var i=e.length;i--;)if($e(e[i][0],t))return i;return-1}Bt.prototype.clear=function(){this.__data__=Pt?Pt(null):{},this.size=0},Bt.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Bt.prototype.get=function(e){var t=this.__data__;if(Pt){var i=t[e];return"__lodash_hash_undefined__"===i?void 0:i}return Vt.call(t,e)?t[e]:void 0},Bt.prototype.has=function(e){var t=this.__data__;return Pt?void 0!==t[e]:Rt.call(t,e)},Bt.prototype.set=function(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=Pt&&void 0===t?"__lodash_hash_undefined__":t,this};var Mt=Array.prototype.splice;function Lt(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t<i;){var n=e[t];this.set(n[0],n[1])}}Lt.prototype.clear=function(){this.__data__=[],this.size=0},Lt.prototype.delete=function(e){var t=this.__data__,i=Ot(t,e);return!(i<0)&&(i==t.length-1?t.pop():Mt.call(t,i,1),--this.size,!0)},Lt.prototype.get=function(e){var t=this.__data__,i=Ot(t,e);return i<0?void 0:t[i][1]},Lt.prototype.has=function(e){return Ot(this.__data__,e)>-1},Lt.prototype.set=function(e,t){var i=this.__data__,n=Ot(i,e);return n<0?(++this.size,i.push([e,t])):i[n][1]=t,this};var Nt=Pe(N,"Map");function Ft(e,t){var i,n,s=e.__data__;return("string"==(n=typeof(i=t))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==i:null===i)?s["string"==typeof t?"string":"hash"]:s.map}function Dt(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t<i;){var n=e[t];this.set(n[0],n[1])}}Dt.prototype.clear=function(){this.size=0,this.__data__={hash:new Bt,map:new(Nt||Lt),string:new Bt}},Dt.prototype.delete=function(e){var t=Ft(this,e).delete(e);return this.size-=t?1:0,t},Dt.prototype.get=function(e){return Ft(this,e).get(e)},Dt.prototype.has=function(e){return Ft(this,e).has(e)},Dt.prototype.set=function(e,t){var i=Ft(this,e),n=i.size;return i.set(e,t),this.size+=i.size==n?0:1,this};var zt="Expected a function";function Ht(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError(zt);var i=function(){var n=arguments,s=t?t.apply(this,n):n[0],o=i.cache;if(o.has(s))return o.get(s);var r=e.apply(this,n);return i.cache=o.set(s,r)||o,r};return i.cache=new(Ht.Cache||Dt),i}Ht.Cache=Dt;var $t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Ut=/\\(\\)?/g,Wt=function(e){var t=Ht(e,(function(e){return 500===i.size&&i.clear(),e})),i=t.cache;return t}((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace($t,(function(e,i,n,s){t.push(n?s.replace(Ut,"$1"):i||e)})),t}));function jt(e){return null==e?"":ie(e)}function qt(e,t){return Y(e)?e:It(e,t)?[e]:Wt(jt(e))}var Gt=1/0;function Kt(e){if("string"==typeof e||J(e))return e;var t=e+"";return"0"==t&&1/e==-Gt?"-0":t}function Zt(e,t){for(var i=0,n=(t=qt(t,e)).length;null!=e&&i<n;)e=e[Kt(t[i++])];return i&&i==n?e:void 0}function Jt(e,t,i){var n=null==e?void 0:Zt(e,t);return void 0===n?i:n}function Qt(e,t){for(var i=-1,n=t.length,s=e.length;++i<n;)e[s+i]=t[i];return e}var Yt=vt(Object.getPrototypeOf,Object),Xt="[object Object]",ei=Function.prototype,ti=Object.prototype,ii=ei.toString,ni=ti.hasOwnProperty,si=ii.call(Object);function oi(e){if(!K(e)||G(e)!=Xt)return!1;var t=Yt(e);if(null===t)return!0;var i=ni.call(t,"constructor")&&t.constructor;return"function"==typeof i&&i instanceof i&&ii.call(i)==si}function ri(e,t,i){var n=-1,s=e.length;t<0&&(t=-t>s?0:s+t),(i=i>s?s:i)<0&&(i+=s),s=t>i?0:i-t>>>0,t>>>=0;for(var o=Array(s);++n<s;)o[n]=e[n+t];return o}var ai=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");function li(e){return ai.test(e)}var ci="\\ud800-\\udfff",di="["+ci+"]",hi="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",ui="\\ud83c[\\udffb-\\udfff]",mi="[^"+ci+"]",gi="(?:\\ud83c[\\udde6-\\uddff]){2}",fi="[\\ud800-\\udbff][\\udc00-\\udfff]",pi="(?:"+hi+"|"+ui+")"+"?",bi="[\\ufe0e\\ufe0f]?",wi=bi+pi+("(?:\\u200d(?:"+[mi,gi,fi].join("|")+")"+bi+pi+")*"),vi="(?:"+[mi+hi+"?",hi,gi,fi,di].join("|")+")",_i=RegExp(ui+"(?="+ui+")|"+vi+wi,"g");function yi(e){return li(e)?function(e){return e.match(_i)||[]}(e):function(e){return e.split("")}(e)}var ki,Ci=(ki="toUpperCase",function(e){var t,i,n,s,o=li(e=jt(e))?yi(e):void 0,r=o?o[0]:e.charAt(0),a=o?(t=o,i=1,s=t.length,n=void 0===n?s:n,!i&&n>=s?t:ri(t,i,n)).join(""):e.slice(1);return r[ki]()+a});function xi(e){return function(t){return null==e?void 0:e[t]}}var Ai=xi({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),Ei=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Ti=RegExp("[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]","g");var Si=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;var Ii=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;var Pi="\\ud800-\\udfff",Vi="\\u2700-\\u27bf",Ri="a-z\\xdf-\\xf6\\xf8-\\xff",Bi="A-Z\\xc0-\\xd6\\xd8-\\xde",Oi="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Mi="["+Oi+"]",Li="\\d+",Ni="["+Vi+"]",Fi="["+Ri+"]",Di="[^"+Pi+Oi+Li+Vi+Ri+Bi+"]",zi="(?:\\ud83c[\\udde6-\\uddff]){2}",Hi="[\\ud800-\\udbff][\\udc00-\\udfff]",$i="["+Bi+"]",Ui="(?:"+Fi+"|"+Di+")",Wi="(?:"+$i+"|"+Di+")",ji="(?:['’](?:d|ll|m|re|s|t|ve))?",qi="(?:['’](?:D|LL|M|RE|S|T|VE))?",Gi="(?:[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]|\\ud83c[\\udffb-\\udfff])?",Ki="[\\ufe0e\\ufe0f]?",Zi=Ki+Gi+("(?:\\u200d(?:"+["[^"+Pi+"]",zi,Hi].join("|")+")"+Ki+Gi+")*"),Ji="(?:"+[Ni,zi,Hi].join("|")+")"+Zi,Qi=RegExp([$i+"?"+Fi+"+"+ji+"(?="+[Mi,$i,"$"].join("|")+")",Wi+"+"+qi+"(?="+[Mi,$i+Ui,"$"].join("|")+")",$i+"?"+Ui+"+"+ji,$i+"+"+qi,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Li,Ji].join("|"),"g");function Yi(e,t,i){return e=jt(e),void 0===(t=i?void 0:t)?function(e){return Ii.test(e)}(e)?function(e){return e.match(Qi)||[]}(e):function(e){return e.match(Si)||[]}(e):e.match(t)||[]}var Xi=RegExp("['’]","g");function en(e){var t=this.__data__=new Lt(e);this.size=t.size}en.prototype.clear=function(){this.__data__=new Lt,this.size=0},en.prototype.delete=function(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i},en.prototype.get=function(e){return this.__data__.get(e)},en.prototype.has=function(e){return this.__data__.has(e)},en.prototype.set=function(e,t){var i=this.__data__;if(i instanceof Lt){var n=i.__data__;if(!Nt||n.length<199)return n.push([e,t]),this.size=++i.size,this;i=this.__data__=new Dt(n)}return i.set(e,t),this.size=i.size,this};var tn="object"==typeof exports&&exports&&!exports.nodeType&&exports,nn=tn&&"object"==typeof module&&module&&!module.nodeType&&module,sn=nn&&nn.exports===tn?N.Buffer:void 0,on=sn?sn.allocUnsafe:void 0;function rn(e,t){if(t)return e.slice();var i=e.length,n=on?on(i):new e.constructor(i);return e.copy(n),n}function an(){return[]}var ln=Object.prototype.propertyIsEnumerable,cn=Object.getOwnPropertySymbols,dn=cn?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var i=-1,n=null==e?0:e.length,s=0,o=[];++i<n;){var r=e[i];t(r,i,e)&&(o[s++]=r)}return o}(cn(e),(function(t){return ln.call(e,t)})))}:an;var hn=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)Qt(t,dn(e)),e=Yt(e);return t}:an;function un(e,t,i){var n=t(e);return Y(e)?n:Qt(n,i(e))}function mn(e){return un(e,kt,dn)}function gn(e){return un(e,At,hn)}var fn=Pe(N,"DataView"),pn=Pe(N,"Promise"),bn=Pe(N,"Set"),wn="[object Map]",vn="[object Promise]",_n="[object Set]",yn="[object WeakMap]",kn="[object DataView]",Cn=ke(fn),xn=ke(Nt),An=ke(pn),En=ke(bn),Tn=ke(Ve),Sn=G;(fn&&Sn(new fn(new ArrayBuffer(1)))!=kn||Nt&&Sn(new Nt)!=wn||pn&&Sn(pn.resolve())!=vn||bn&&Sn(new bn)!=_n||Ve&&Sn(new Ve)!=yn)&&(Sn=function(e){var t=G(e),i="[object Object]"==t?e.constructor:void 0,n=i?ke(i):"";if(n)switch(n){case Cn:return kn;case xn:return wn;case An:return vn;case En:return _n;case Tn:return yn}return t});var In=Sn,Pn=Object.prototype.hasOwnProperty;var Vn=N.Uint8Array;function Rn(e){var t=new e.constructor(e.byteLength);return new Vn(t).set(new Vn(e)),t}var Bn=/\w*$/;var On=F?F.prototype:void 0,Mn=On?On.valueOf:void 0;function Ln(e,t){var i=t?Rn(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.length)}var Nn="[object Boolean]",Fn="[object Date]",Dn="[object Map]",zn="[object Number]",Hn="[object RegExp]",$n="[object Set]",Un="[object String]",Wn="[object Symbol]",jn="[object ArrayBuffer]",qn="[object DataView]",Gn="[object Float32Array]",Kn="[object Float64Array]",Zn="[object Int8Array]",Jn="[object Int16Array]",Qn="[object Int32Array]",Yn="[object Uint8Array]",Xn="[object Uint8ClampedArray]",es="[object Uint16Array]",ts="[object Uint32Array]";function is(e,t,i){var n,s,o,r=e.constructor;switch(t){case jn:return Rn(e);case Nn:case Fn:return new r(+e);case qn:return function(e,t){var i=t?Rn(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.byteLength)}(e,i);case Gn:case Kn:case Zn:case Jn:case Qn:case Yn:case Xn:case es:case ts:return Ln(e,i);case Dn:return new r;case zn:case Un:return new r(e);case Hn:return(o=new(s=e).constructor(s.source,Bn.exec(s))).lastIndex=s.lastIndex,o;case $n:return new r;case Wn:return n=e,Mn?Object(Mn.call(n)):{}}}function ns(e){return"function"!=typeof e.constructor||Xe(e)?{}:Be(Yt(e))}var ss=gt&&gt.isMap,os=ss?dt(ss):function(e){return K(e)&&"[object Map]"==In(e)};var rs=gt&&gt.isSet,as=rs?dt(rs):function(e){return K(e)&&"[object Set]"==In(e)},ls=1,cs=2,ds=4,hs="[object Arguments]",us="[object Function]",ms="[object GeneratorFunction]",gs="[object Object]",fs={};function ps(e,t,i,n,s,o){var r,a=t&ls,l=t&cs,c=t&ds;if(i&&(r=s?i(e,n,s,o):i(e)),void 0!==r)return r;if(!re(e))return e;var d=Y(e);if(d){if(r=function(e){var t=e.length,i=new e.constructor(t);return t&&"string"==typeof e[0]&&Pn.call(e,"index")&&(i.index=e.index,i.input=e.input),i}(e),!a)return Oe(e,r)}else{var h=In(e),u=h==us||h==ms;if(lt(e))return rn(e,a);if(h==gs||h==hs||u&&!s){if(r=l||u?{}:ns(e),!a)return l?function(e,t){return je(e,hn(e),t)}(e,function(e,t){return e&&je(t,At(t),e)}(r,e)):function(e,t){return je(e,dn(e),t)}(e,function(e,t){return e&&je(t,kt(t),e)}(r,e))}else{if(!fs[h])return s?e:{};r=is(e,h,a)}}o||(o=new en);var m=o.get(e);if(m)return m;o.set(e,r),as(e)?e.forEach((function(n){r.add(ps(n,t,i,n,e,o))})):os(e)&&e.forEach((function(n,s){r.set(s,ps(n,t,i,s,e,o))}));var g=d?void 0:(c?l?gn:mn:l?At:kt)(e);return function(e,t){for(var i=-1,n=null==e?0:e.length;++i<n&&!1!==t(e[i],i,e););}(g||e,(function(n,s){g&&(n=e[s=n]),We(r,s,ps(n,t,i,s,e,o))})),r}fs[hs]=fs["[object Array]"]=fs["[object ArrayBuffer]"]=fs["[object DataView]"]=fs["[object Boolean]"]=fs["[object Date]"]=fs["[object Float32Array]"]=fs["[object Float64Array]"]=fs["[object Int8Array]"]=fs["[object Int16Array]"]=fs["[object Int32Array]"]=fs["[object Map]"]=fs["[object Number]"]=fs[gs]=fs["[object RegExp]"]=fs["[object Set]"]=fs["[object String]"]=fs["[object Symbol]"]=fs["[object Uint8Array]"]=fs["[object Uint8ClampedArray]"]=fs["[object Uint16Array]"]=fs["[object Uint32Array]"]=!0,fs["[object Error]"]=fs[us]=fs["[object WeakMap]"]=!1;function bs(e){return ps(e,4)}var ws=1,vs=4;function _s(e){return ps(e,ws|vs)}var ys=1,ks=4;function Cs(e,t){return ps(e,ys|ks,t="function"==typeof t?t:void 0)}function xs(e){var t=-1,i=null==e?0:e.length;for(this.__data__=new Dt;++t<i;)this.add(e[t])}function As(e,t){for(var i=-1,n=null==e?0:e.length;++i<n;)if(t(e[i],i,e))return!0;return!1}function Es(e,t){return e.has(t)}xs.prototype.add=xs.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},xs.prototype.has=function(e){return this.__data__.has(e)};var Ts=1,Ss=2;function Is(e,t,i,n,s,o){var r=i&Ts,a=e.length,l=t.length;if(a!=l&&!(r&&l>a))return!1;var c=o.get(e),d=o.get(t);if(c&&d)return c==t&&d==e;var h=-1,u=!0,m=i&Ss?new xs:void 0;for(o.set(e,t),o.set(t,e);++h<a;){var g=e[h],f=t[h];if(n)var p=r?n(f,g,h,t,e,o):n(g,f,h,e,t,o);if(void 0!==p){if(p)continue;u=!1;break}if(m){if(!As(t,(function(e,t){if(!Es(m,t)&&(g===e||s(g,e,i,n,o)))return m.push(t)}))){u=!1;break}}else if(g!==f&&!s(g,f,i,n,o)){u=!1;break}}return o.delete(e),o.delete(t),u}function Ps(e){var t=-1,i=Array(e.size);return e.forEach((function(e,n){i[++t]=[n,e]})),i}function Vs(e){var t=-1,i=Array(e.size);return e.forEach((function(e){i[++t]=e})),i}var Rs=1,Bs=2,Os="[object Boolean]",Ms="[object Date]",Ls="[object Error]",Ns="[object Map]",Fs="[object Number]",Ds="[object RegExp]",zs="[object Set]",Hs="[object String]",$s="[object Symbol]",Us="[object ArrayBuffer]",Ws="[object DataView]",js=F?F.prototype:void 0,qs=js?js.valueOf:void 0;var Gs=1,Ks=Object.prototype.hasOwnProperty;var Zs=1,Js="[object Arguments]",Qs="[object Array]",Ys="[object Object]",Xs=Object.prototype.hasOwnProperty;function eo(e,t,i,n,s,o){var r=Y(e),a=Y(t),l=r?Qs:In(e),c=a?Qs:In(t),d=(l=l==Js?Ys:l)==Ys,h=(c=c==Js?Ys:c)==Ys,u=l==c;if(u&&lt(e)){if(!lt(t))return!1;r=!0,d=!1}if(u&&!d)return o||(o=new en),r||pt(e)?Is(e,t,i,n,s,o):function(e,t,i,n,s,o,r){switch(i){case Ws:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case Us:return!(e.byteLength!=t.byteLength||!o(new Vn(e),new Vn(t)));case Os:case Ms:case Fs:return $e(+e,+t);case Ls:return e.name==t.name&&e.message==t.message;case Ds:case Hs:return e==t+"";case Ns:var a=Ps;case zs:var l=n&Rs;if(a||(a=Vs),e.size!=t.size&&!l)return!1;var c=r.get(e);if(c)return c==t;n|=Bs,r.set(e,t);var d=Is(a(e),a(t),n,s,o,r);return r.delete(e),d;case $s:if(qs)return qs.call(e)==qs.call(t)}return!1}(e,t,l,i,n,s,o);if(!(i&Zs)){var m=d&&Xs.call(e,"__wrapped__"),g=h&&Xs.call(t,"__wrapped__");if(m||g){var f=m?e.value():e,p=g?t.value():t;return o||(o=new en),s(f,p,i,n,o)}}return!!u&&(o||(o=new en),function(e,t,i,n,s,o){var r=i&Gs,a=mn(e),l=a.length;if(l!=mn(t).length&&!r)return!1;for(var c=l;c--;){var d=a[c];if(!(r?d in t:Ks.call(t,d)))return!1}var h=o.get(e),u=o.get(t);if(h&&u)return h==t&&u==e;var m=!0;o.set(e,t),o.set(t,e);for(var g=r;++c<l;){var f=e[d=a[c]],p=t[d];if(n)var b=r?n(p,f,d,t,e,o):n(f,p,d,e,t,o);if(!(void 0===b?f===p||s(f,p,i,n,o):b)){m=!1;break}g||(g="constructor"==d)}if(m&&!g){var w=e.constructor,v=t.constructor;w==v||!("constructor"in e)||!("constructor"in t)||"function"==typeof w&&w instanceof w&&"function"==typeof v&&v instanceof v||(m=!1)}return o.delete(e),o.delete(t),m}(e,t,i,n,s,o))}function to(e,t,i,n,s){return e===t||(null==e||null==t||!K(e)&&!K(t)?e!=e&&t!=t:eo(e,t,i,n,to,s))}var io=1,no=2;function so(e){return e==e&&!re(e)}function oo(e,t){return function(i){return null!=i&&(i[e]===t&&(void 0!==t||e in Object(i)))}}function ro(e){var t=function(e){for(var t=kt(e),i=t.length;i--;){var n=t[i],s=e[n];t[i]=[n,s,so(s)]}return t}(e);return 1==t.length&&t[0][2]?oo(t[0][0],t[0][1]):function(i){return i===e||function(e,t,i,n){var s=i.length,o=s,r=!n;if(null==e)return!o;for(e=Object(e);s--;){var a=i[s];if(r&&a[2]?a[1]!==e[a[0]]:!(a[0]in e))return!1}for(;++s<o;){var l=(a=i[s])[0],c=e[l],d=a[1];if(r&&a[2]){if(void 0===c&&!(l in e))return!1}else{var h=new en;if(n)var u=n(c,d,l,e,t,h);if(!(void 0===u?to(d,c,io|no,n,h):u))return!1}}return!0}(i,e,t)}}function ao(e,t){return null!=e&&t in Object(e)}function lo(e,t){return null!=e&&function(e,t,i){for(var n=-1,s=(t=qt(t,e)).length,o=!1;++n<s;){var r=Kt(t[n]);if(!(o=null!=e&&i(e,r)))break;e=e[r]}return o||++n!=s?o:!!(s=null==e?0:e.length)&&Ze(s)&&ze(r,s)&&(Y(e)||st(e))}(e,t,ao)}var co=1,ho=2;function uo(e){return It(e)?(t=Kt(e),function(e){return null==e?void 0:e[t]}):function(e){return function(t){return Zt(t,e)}}(e);var t}function mo(e){return"function"==typeof e?e:null==e?me:"object"==typeof e?Y(e)?(t=e[0],i=e[1],It(t)&&so(i)?oo(Kt(t),i):function(e){var n=Jt(e,t);return void 0===n&&n===i?lo(e,t):to(i,n,co|ho)}):ro(e):uo(e);var t,i}var go,fo=function(e,t,i){for(var n=-1,s=Object(e),o=i(e),r=o.length;r--;){var a=o[go?r:++n];if(!1===t(s[a],a,s))break}return e};function po(e,t){return e&&fo(e,t,kt)}var bo=function(e,t){return function(i,n){if(null==i)return i;if(!Je(i))return e(i,n);for(var s=i.length,o=t?s:-1,r=Object(i);(t?o--:++o<s)&&!1!==n(r[o],o,r););return i}}(po),wo=function(){return N.Date.now()},vo="Expected a function",_o=Math.max,yo=Math.min;function ko(e,t,i){var n,s,o,r,a,l,c=0,d=!1,h=!1,u=!0;if("function"!=typeof e)throw new TypeError(vo);function m(t){var i=n,o=s;return n=s=void 0,c=t,r=e.apply(o,i)}function g(e){var i=e-l;return void 0===l||i>=t||i<0||h&&e-c>=o}function f(){var e=wo();if(g(e))return p(e);a=setTimeout(f,function(e){var i=t-(e-l);return h?yo(i,o-(e-c)):i}(e))}function p(e){return a=void 0,u&&n?m(e):(n=s=void 0,r)}function b(){var e=wo(),i=g(e);if(n=arguments,s=this,l=e,i){if(void 0===a)return function(e){return c=e,a=setTimeout(f,t),d?m(e):r}(l);if(h)return clearTimeout(a),a=setTimeout(f,t),m(l)}return void 0===a&&(a=setTimeout(f,t)),r}return t=ue(t)||0,re(i)&&(d=!!i.leading,o=(h="maxWait"in i)?_o(ue(i.maxWait)||0,t):o,u="trailing"in i?!!i.trailing:u),b.cancel=function(){void 0!==a&&clearTimeout(a),c=0,n=l=s=a=void 0},b.flush=function(){return void 0===a?r:p(wo())},b}function Co(e,t,i){(void 0!==i&&!$e(e[t],i)||void 0===i&&!(t in e))&&He(e,t,i)}function xo(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}function Ao(e,t,i,n,s,o,r){var a=xo(e,i),l=xo(t,i),c=r.get(l);if(c)Co(e,i,c);else{var d,h=o?o(a,l,i+"",e,t,r):void 0,u=void 0===h;if(u){var m=Y(l),g=!m&&lt(l),f=!m&&!g&&pt(l);h=l,m||g||f?Y(a)?h=a:K(d=a)&&Je(d)?h=Oe(a):g?(u=!1,h=rn(l,!0)):f?(u=!1,h=Ln(l,!0)):h=[]:oi(l)||st(l)?(h=a,st(a)?h=function(e){return je(e,At(e))}(a):re(a)&&!we(a)||(h=ns(l))):u=!1}u&&(r.set(l,h),s(h,l,n,o,r),r.delete(l)),Co(e,i,h)}}function Eo(e,t,i,n,s){e!==t&&fo(t,(function(o,r){if(s||(s=new en),re(o))Ao(e,t,r,i,Eo,n,s);else{var a=n?n(xo(e,r),o,r+"",e,t,s):void 0;void 0===a&&(a=o),Co(e,r,a)}}),At)}var To=Qe((function(e,t,i,n){Eo(e,t,i,n)}));var So=xi({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"}),Io=/[&<>"']/g,Po=RegExp(Io.source);function Vo(e){return(e=jt(e))&&Po.test(e)?e.replace(Io,So):e}var Ro=/[\\^$.*+?()[\]{}|]/g,Bo=RegExp(Ro.source);function Oo(e){return(e=jt(e))&&Bo.test(e)?e.replace(Ro,"\\$&"):e}function Mo(e,t){var i=-1,n=Je(e)?Array(e.length):[];return bo(e,(function(e,s,o){n[++i]=t(e,s,o)})),n}var Lo="[object String]";function No(e){return"string"==typeof e||!Y(e)&&K(e)&&G(e)==Lo}function Fo(e){return K(e)&&1===e.nodeType&&!oi(e)}function Do(e,t){return to(e,t)}var zo=Qe((function(e,t,i){Eo(e,t,i)}));function Ho(e,t){return null==(e=function(e,t){return t.length<2?e:Zt(e,ri(t,0,-1))}(e,t=qt(t,e)))||delete e[Kt((i=t,n=null==i?0:i.length,n?i[n-1]:void 0))];var i,n}function $o(e,t,i){return null==e?e:function(e,t,i,n){if(!re(e))return e;for(var s=-1,o=(t=qt(t,e)).length,r=o-1,a=e;null!=a&&++s<o;){var l=Kt(t[s]),c=i;if("__proto__"===l||"constructor"===l||"prototype"===l)return e;if(s!=r){var d=a[l];void 0===(c=n?n(d,l,a):void 0)&&(c=re(d)?d:ze(t[s+1])?[]:{})}We(a,l,c),a=a[l]}return e}(e,t,i)}var Uo,Wo=(Uo=function(e,t,i){return e+(i?" ":"")+Ci(t)},function(e){return function(e,t,i,n){var s=-1,o=null==e?0:e.length;for(n&&o&&(i=e[++s]);++s<o;)i=t(i,e[s],s,e);return i}(Yi(function(e){return(e=jt(e))&&e.replace(Ei,Ai).replace(Ti,"")}(e).replace(Xi,"")),Uo,"")});function jo(e,t,i){var n=!0,s=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return re(i)&&(n="leading"in i?!!i.leading:n,s="trailing"in i?!!i.trailing:s),ko(e,t,{leading:n,maxWait:t,trailing:s})}const qo=Symbol("observableProperties"),Go=Symbol("boundObservables"),Ko=Symbol("boundProperties"),Zo=Symbol("decoratedMethods"),Jo=Symbol("decoratedOriginal"),Qo=Yo(T());function Yo(e){if(!e)return Qo;return class extends e{set(e,t){if(re(e))return void Object.keys(e).forEach((t=>{this.set(t,e[t])}),this);Xo(this);const i=this[qo];if(e in this&&!i.has(e))throw new p("observable-set-cannot-override",this);Object.defineProperty(this,e,{enumerable:!0,configurable:!0,get:()=>i.get(e),set(t){const n=i.get(e);let s=this.fire(`set:${e}`,e,t,n);void 0===s&&(s=t),n===s&&i.has(e)||(i.set(e,s),this.fire(`change:${e}`,e,s,n))}}),this[e]=t}bind(...e){if(!e.length||!ir(e))throw new p("observable-bind-wrong-properties",this);if(new Set(e).size!==e.length)throw new p("observable-bind-duplicate-properties",this);Xo(this);const t=this[Ko];e.forEach((e=>{if(t.has(e))throw new p("observable-bind-rebind",this)}));const i=new Map;return e.forEach((e=>{const n={property:e,to:[]};t.set(e,n),i.set(e,n)})),{to:er,toMany:tr,_observable:this,_bindProperties:e,_to:[],_bindings:i}}unbind(...e){if(!this[qo])return;const t=this[Ko],i=this[Go];if(e.length){if(!ir(e))throw new p("observable-unbind-wrong-properties",this);e.forEach((e=>{const n=t.get(e);n&&(n.to.forEach((([e,t])=>{const s=i.get(e),o=s[t];o.delete(n),o.size||delete s[t],Object.keys(s).length||(i.delete(e),this.stopListening(e,"change"))})),t.delete(e))}))}else i.forEach(((e,t)=>{this.stopListening(t,"change")})),i.clear(),t.clear()}decorate(e){Xo(this);const t=this[e];if(!t)throw new p("observablemixin-cannot-decorate-undefined",this,{object:this,methodName:e});this.on(e,((e,i)=>{e.return=t.apply(this,i)})),this[e]=function(...t){return this.fire(e,t)},this[e][Jo]=t,this[Zo]||(this[Zo]=[]),this[Zo].push(e)}stopListening(e,t,i){if(!e&&this[Zo]){for(const e of this[Zo])this[e]=this[e][Jo];delete this[Zo]}super.stopListening(e,t,i)}}}function Xo(e){e[qo]||(Object.defineProperty(e,qo,{value:new Map}),Object.defineProperty(e,Go,{value:new Map}),Object.defineProperty(e,Ko,{value:new Map}))}function er(...e){const t=function(...e){if(!e.length)throw new p("observable-bind-to-parse-error",null);const t={to:[]};let i;"function"==typeof e[e.length-1]&&(t.callback=e.pop());return e.forEach((e=>{if("string"==typeof e)i.properties.push(e);else{if("object"!=typeof e)throw new p("observable-bind-to-parse-error",null);i={observable:e,properties:[]},t.to.push(i)}})),t}(...e),i=Array.from(this._bindings.keys()),n=i.length;if(!t.callback&&t.to.length>1)throw new p("observable-bind-to-no-callback",this);if(n>1&&t.callback)throw new p("observable-bind-to-extra-callback",this);var s;t.to.forEach((e=>{if(e.properties.length&&e.properties.length!==n)throw new p("observable-bind-to-properties-length",this);e.properties.length||(e.properties=this._bindProperties)})),this._to=t.to,t.callback&&(this._bindings.get(i[0]).callback=t.callback),s=this._observable,this._to.forEach((e=>{const t=s[Go];let i;t.get(e.observable)||s.listenTo(e.observable,"change",((n,o)=>{i=t.get(e.observable)[o],i&&i.forEach((e=>{nr(s,e.property)}))}))})),function(e){let t;e._bindings.forEach(((i,n)=>{e._to.forEach((s=>{t=s.properties[i.callback?0:e._bindProperties.indexOf(n)],i.to.push([s.observable,t]),function(e,t,i,n){const s=e[Go],o=s.get(i),r=o||{};r[n]||(r[n]=new Set);r[n].add(t),o||s.set(i,r)}(e._observable,i,s.observable,t)}))}))}(this),this._bindProperties.forEach((e=>{nr(this._observable,e)}))}function tr(e,t,i){if(this._bindings.size>1)throw new p("observable-bind-to-many-not-one-binding",this);this.to(...function(e,t){const i=e.map((e=>[e,t]));return Array.prototype.concat.apply([],i)}(e,t),i)}function ir(e){return e.every((e=>"string"==typeof e))}function nr(e,t){const i=e[Ko].get(t);let n;i.callback?n=i.callback.apply(e,i.to.map((e=>e[0][e[1]]))):(n=i.to[0],n=n[0][n[1]]),Object.prototype.hasOwnProperty.call(e,t)?e[t]=n:e.set(t,n)}["set","bind","unbind","decorate","on","once","off","listenTo","stopListening","fire","delegate","stopDelegating","_addEventListener","_removeEventListener"].forEach((e=>{Yo[e]=Qo.prototype[e]}));class sr{replace(e,t){this._replacedElements.push({element:e,newElement:t}),e.style.display="none",t&&e.parentNode.insertBefore(t,e.nextSibling)}restore(){this._replacedElements.forEach((({element:e,newElement:t})=>{e.style.display="",t&&t.remove()})),this._replacedElements=[]}constructor(){this._replacedElements=[]}}function or(e){let t=new AbortController;function i(...i){return t.abort(),t=new AbortController,e(t.signal,...i)}return i.abort=()=>t.abort(),i}function rr(e){let t=0;for(const i of e)t++;return t}function ar(e,t){const i=Math.min(e.length,t.length);for(let n=0;n<i;n++)if(e[n]!=t[n])return n;return e.length==t.length?"same":e.length<t.length?"prefix":"extension"}function lr(e){return!(!e||!e[Symbol.iterator])}function cr(e,t,i={},n=[]){const s=i&&i.xmlns,o=s?e.createElementNS(s,t):e.createElement(t);for(const e in i)o.setAttribute(e,i[e]);!No(n)&&lr(n)||(n=[n]);for(let t of n)No(t)&&(t=e.createTextNode(t)),o.appendChild(t);return o}class dr{set(e,t){this._setToTarget(this._config,e,t)}define(e,t){this._setToTarget(this._config,e,t,!0)}get(e){return this._getFromSource(this._config,e)}*names(){for(const e of Object.keys(this._config))yield e}_setToTarget(e,t,i,n=!1){if(oi(t))return void this._setObjectToTarget(e,t,n);const s=t.split(".");t=s.pop();for(const t of s)oi(e[t])||(e[t]={}),e=e[t];if(oi(i))return oi(e[t])||(e[t]={}),e=e[t],void this._setObjectToTarget(e,i,n);n&&void 0!==e[t]||(e[t]=i)}_getFromSource(e,t){const i=t.split(".");t=i.pop();for(const t of i){if(!oi(e[t])){e=null;break}e=e[t]}return e?hr(e[t]):void 0}_setObjectToTarget(e,t,i){Object.keys(t).forEach((n=>{this._setToTarget(e,n,t[n],i)}))}constructor(e,t){this._config={},t&&this.define(hr(t)),e&&this._setObjectToTarget(this._config,e)}}function hr(e){return Cs(e,ur)}function ur(e){return Fo(e)||"function"==typeof e?e:void 0}function mr(e){if(e){if(e.defaultView)return e instanceof e.defaultView.Document;if(e.ownerDocument&&e.ownerDocument.defaultView)return e instanceof e.ownerDocument.defaultView.Node}return!1}function gr(e){const t=Object.prototype.toString.apply(e);return"[object Window]"==t||"[object global]"==t}const fr=pr(T());function pr(e){if(!e)return fr;return class extends e{listenTo(e,t,i,n={}){if(mr(e)||gr(e)){const s={capture:!!n.useCapture,passive:!!n.usePassive},o=this._getProxyEmitter(e,s)||new br(e,s);this.listenTo(o,t,i,n)}else super.listenTo(e,t,i,n)}stopListening(e,t,i){if(mr(e)||gr(e)){const n=this._getAllProxyEmitters(e);for(const e of n)this.stopListening(e,t,i)}else super.stopListening(e,t,i)}_getProxyEmitter(e,t){return function(e,t){const i=e[C];return i&&i[t]?i[t].emitter:null}(this,wr(e,t))}_getAllProxyEmitters(e){return[{capture:!1,passive:!1},{capture:!1,passive:!0},{capture:!0,passive:!1},{capture:!0,passive:!0}].map((t=>this._getProxyEmitter(e,t))).filter((e=>!!e))}}}["_getProxyEmitter","_getAllProxyEmitters","on","once","off","listenTo","stopListening","fire","delegate","stopDelegating","_addEventListener","_removeEventListener"].forEach((e=>{pr[e]=fr.prototype[e]}));class br extends(T()){attach(e){if(this._domListeners&&this._domListeners[e])return;const t=this._createDomListener(e);this._domNode.addEventListener(e,t,this._options),this._domListeners||(this._domListeners={}),this._domListeners[e]=t}detach(e){let t;!this._domListeners[e]||(t=this._events[e])&&t.callbacks.length||this._domListeners[e].removeListener()}_addEventListener(e,t,i){this.attach(e),T().prototype._addEventListener.call(this,e,t,i)}_removeEventListener(e,t){T().prototype._removeEventListener.call(this,e,t),this.detach(e)}_createDomListener(e){const t=t=>{this.fire(e,t)};return t.removeListener=()=>{this._domNode.removeEventListener(e,t,this._options),delete this._domListeners[e]},t}constructor(e,t){super(),S(this,wr(e,t)),this._domNode=e,this._options=t}}function wr(e,t){let i=function(e){return e["data-ck-expando"]||(e["data-ck-expando"]=u())}(e);for(const e of Object.keys(t).sort())t[e]&&(i+="-"+e);return i}let vr;try{vr={window:window,document:document}}catch(e){vr={window:{},document:{}}}var _r=vr;function yr(e){let t=e.parentElement;if(!t)return null;for(;"BODY"!=t.tagName;){const e=t.style.overflowY||_r.window.getComputedStyle(t).overflowY;if("auto"===e||"scroll"===e)break;if(t=t.parentElement,!t)return null}return t}function kr(e){const t=[];let i=e;for(;i&&i.nodeType!=Node.DOCUMENT_NODE;)t.unshift(i),i=i.parentNode;return t}function Cr(e){return e instanceof HTMLTextAreaElement?e.value:e.innerHTML}function xr(e){const t=e.ownerDocument.defaultView.getComputedStyle(e);return{top:parseInt(t.borderTopWidth,10),right:parseInt(t.borderRightWidth,10),bottom:parseInt(t.borderBottomWidth,10),left:parseInt(t.borderLeftWidth,10)}}function Ar(e){return"[object Text]"==Object.prototype.toString.call(e)}function Er(e){return"[object Range]"==Object.prototype.toString.apply(e)}function Tr(e){return e&&e.parentNode?e.offsetParent===_r.document.body?null:e.offsetParent:null}const Sr=["top","right","bottom","left","width","height"];class Ir{clone(){return new Ir(this)}moveTo(e,t){return this.top=t,this.right=e+this.width,this.bottom=t+this.height,this.left=e,this}moveBy(e,t){return this.top+=t,this.right+=e,this.left+=e,this.bottom+=t,this}getIntersection(e){const t={top:Math.max(this.top,e.top),right:Math.min(this.right,e.right),bottom:Math.min(this.bottom,e.bottom),left:Math.max(this.left,e.left),width:0,height:0};if(t.width=t.right-t.left,t.height=t.bottom-t.top,t.width<0||t.height<0)return null;{const e=new Ir(t);return e._source=this._source,e}}getIntersectionArea(e){const t=this.getIntersection(e);return t?t.getArea():0}getArea(){return this.width*this.height}getVisible(){const e=this._source;let t=this.clone();if(Vr(e))return t;let i,n=e,s=e.parentNode||e.commonAncestorContainer;for(;s&&!Vr(s);){const e="visible"===((o=s)instanceof HTMLElement?o.ownerDocument.defaultView.getComputedStyle(o).overflow:"visible");n instanceof HTMLElement&&"absolute"===Br(n)&&(i=n);const r=Br(s);if(e||i&&("relative"===r&&e||"relative"!==r)){n=s,s=s.parentNode;continue}const a=new Ir(s),l=t.getIntersection(a);if(!l)return null;l.getArea()<t.getArea()&&(t=l),n=s,s=s.parentNode}var o;return t}isEqual(e){for(const t of Sr)if(this[t]!==e[t])return!1;return!0}contains(e){const t=this.getIntersection(e);return!(!t||!t.isEqual(e))}toAbsoluteRect(){const{scrollX:e,scrollY:t}=_r.window,i=this.clone().moveBy(e,t);if(Rr(i._source)){const e=Tr(i._source);e&&function(e,t){const i=new Ir(t),n=xr(t);let s=0,o=0;s-=i.left,o-=i.top,s+=t.scrollLeft,o+=t.scrollTop,s-=n.left,o-=n.top,e.moveBy(s,o)}(i,e)}return i}excludeScrollbarsAndBorders(){const e=this._source;let t,i,n;if(gr(e))t=e.innerWidth-e.document.documentElement.clientWidth,i=e.innerHeight-e.document.documentElement.clientHeight,n=e.getComputedStyle(e.document.documentElement).direction;else{const s=xr(e);t=e.offsetWidth-e.clientWidth-s.left-s.right,i=e.offsetHeight-e.clientHeight-s.top-s.bottom,n=e.ownerDocument.defaultView.getComputedStyle(e).direction,this.left+=s.left,this.top+=s.top,this.right-=s.right,this.bottom-=s.bottom,this.width=this.right-this.left,this.height=this.bottom-this.top}return this.width-=t,"ltr"===n?this.right-=t:this.left+=t,this.height-=i,this.bottom-=i,this}static getDomRangeRects(e){const t=[],i=Array.from(e.getClientRects());if(i.length)for(const e of i)t.push(new Ir(e));else{let i=e.startContainer;Ar(i)&&(i=i.parentNode);const n=new Ir(i.getBoundingClientRect());n.right=n.left,n.width=0,t.push(n)}return t}static getBoundingRect(e){const t={left:Number.POSITIVE_INFINITY,top:Number.POSITIVE_INFINITY,right:Number.NEGATIVE_INFINITY,bottom:Number.NEGATIVE_INFINITY,width:0,height:0};let i=0;for(const n of e)i++,t.left=Math.min(t.left,n.left),t.top=Math.min(t.top,n.top),t.right=Math.max(t.right,n.right),t.bottom=Math.max(t.bottom,n.bottom);return 0==i?null:(t.width=t.right-t.left,t.height=t.bottom-t.top,new Ir(t))}constructor(e){const t=Er(e);if(Object.defineProperty(this,"_source",{value:e._source||e,writable:!0,enumerable:!1}),Rr(e)||t)if(t){const t=Ir.getDomRangeRects(e);Pr(this,Ir.getBoundingRect(t))}else Pr(this,e.getBoundingClientRect());else if(gr(e)){const{innerWidth:t,innerHeight:i}=e;Pr(this,{top:0,right:t,bottom:i,left:0,width:t,height:i})}else Pr(this,e)}}function Pr(e,t){for(const i of Sr)e[i]=t[i]}function Vr(e){return!!Rr(e)&&e===e.ownerDocument.body}function Rr(e){return null!==e&&"object"==typeof e&&1===e.nodeType&&"function"==typeof e.getBoundingClientRect}function Br(e){return e instanceof HTMLElement?e.ownerDocument.defaultView.getComputedStyle(e).position:"static"}class Or{get element(){return this._element}destroy(){Or._deleteElementCallback(this._element,this._callback)}static _addElementCallback(e,t){Or._elementCallbacks||(Or._elementCallbacks=new Map);let i=Or._elementCallbacks.get(e);i||(i=new Set,Or._elementCallbacks.set(e,i)),i.add(t)}static _deleteElementCallback(e,t){const i=Or._getElementCallbacks(e);i&&(i.delete(t),i.size||(Or._elementCallbacks.delete(e),Or._observerInstance.unobserve(e))),Or._elementCallbacks&&!Or._elementCallbacks.size&&(Or._observerInstance=null,Or._elementCallbacks=null)}static _getElementCallbacks(e){return Or._elementCallbacks?Or._elementCallbacks.get(e):null}static _createObserver(){Or._observerInstance=new _r.window.ResizeObserver((e=>{for(const t of e){const e=Or._getElementCallbacks(t.target);if(e)for(const i of e)i(t)}}))}constructor(e,t){Or._observerInstance||Or._createObserver(),this._element=e,this._callback=t,Or._addElementCallback(e,t),Or._observerInstance.observe(e)}}function Mr(e,t){e instanceof HTMLTextAreaElement&&(e.value=t),e.innerHTML=t}function Lr(e){return t=>t+e}function Nr(e){let t=0;for(;e.previousSibling;)e=e.previousSibling,t++;return t}function Fr(e,t,i){e.insertBefore(i,e.childNodes[t]||null)}function Dr(e){return e&&e.nodeType===Node.COMMENT_NODE}function zr(e){try{_r.document.createAttribute(e)}catch(e){return!1}return!0}function Hr(e){return!!(e&&e.getClientRects&&e.getClientRects().length)}function $r({element:e,target:t,positions:i,limiter:n,fitInViewport:s,viewportOffsetConfig:o}){we(t)&&(t=t()),we(n)&&(n=n());const r=Tr(e),a=function(e){e=Object.assign({top:0,bottom:0,left:0,right:0},e);const t=new Ir(_r.window);return t.top+=e.top,t.height-=e.top,t.bottom-=e.bottom,t.height-=e.bottom,t}(o),l=new Ir(e),c=Ur(t,a);let d;if(!c||!a.getIntersection(c))return null;const h={targetRect:c,elementRect:l,positionedElementAncestor:r,viewportRect:a};if(n||s){if(n){const e=Ur(n,a);e&&(h.limiterRect=e)}d=function(e,t){const{elementRect:i}=t,n=i.getArea(),s=e.map((e=>new Wr(e,t))).filter((e=>!!e.name));let o=0,r=null;for(const e of s){const{limiterIntersectionArea:t,viewportIntersectionArea:i}=e;if(t===n)return e;const s=i**2+t**2;s>o&&(o=s,r=e)}return r}(i,h)}else d=new Wr(i[0],h);return d}function Ur(e,t){const i=new Ir(e).getVisible();return i?i.getIntersection(t):null}Or._observerInstance=null,Or._elementCallbacks=null;class Wr{get left(){return this._absoluteRect.left}get top(){return this._absoluteRect.top}get limiterIntersectionArea(){const e=this._options.limiterRect;return e?e.getIntersectionArea(this._rect):0}get viewportIntersectionArea(){return this._options.viewportRect.getIntersectionArea(this._rect)}get _rect(){return this._cachedRect||(this._cachedRect=this._options.elementRect.clone().moveTo(this._positioningFunctionCoordinates.left,this._positioningFunctionCoordinates.top)),this._cachedRect}get _absoluteRect(){return this._cachedAbsoluteRect||(this._cachedAbsoluteRect=this._rect.toAbsoluteRect()),this._cachedAbsoluteRect}constructor(e,t){const i=e(t.targetRect,t.elementRect,t.viewportRect,t.limiterRect);if(!i)return;const{left:n,top:s,name:o,config:r}=i;this.name=o,this.config=r,this._positioningFunctionCoordinates={left:n,top:s},this._options=t}}function jr(e){const t=e.parentNode;t&&t.removeChild(e)}function qr({target:e,viewportOffset:t=0,ancestorOffset:i=0,alignToTop:n,forceScroll:s}){const o=ea(e);let r=o,a=null;for(t=function(e){if("number"==typeof e)return{top:e,bottom:e,left:e,right:e};return e}(t);r;){let l;l=ta(r==o?e:a),Zr({parent:l,getRect:()=>ia(e,r),alignToTop:n,ancestorOffset:i,forceScroll:s});const c=ia(e,r);if(Kr({window:r,rect:c,viewportOffset:t,alignToTop:n,forceScroll:s}),r.parent!=r){if(a=r.frameElement,r=r.parent,!a)return}else r=null}}function Gr(e,t,i){Zr({parent:ta(e),getRect:()=>new Ir(e),ancestorOffset:t,limiterElement:i})}function Kr({window:e,rect:t,alignToTop:i,forceScroll:n,viewportOffset:s}){const o=t.clone().moveBy(0,s.bottom),r=t.clone().moveBy(0,-s.top),a=new Ir(e).excludeScrollbarsAndBorders(),l=i&&n,c=[r,o].every((e=>a.contains(e)));let{scrollX:d,scrollY:h}=e;const u=d,m=h;l?h-=a.top-t.top+s.top:c||(Qr(r,a)?h-=a.top-t.top+s.top:Jr(o,a)&&(h+=i?t.top-a.top-s.top:t.bottom-a.bottom+s.bottom)),c||(Yr(t,a)?d-=a.left-t.left+s.left:Xr(t,a)&&(d+=t.right-a.right+s.right)),d==u&&h===m||e.scrollTo(d,h)}function Zr({parent:e,getRect:t,alignToTop:i,forceScroll:n,ancestorOffset:s=0,limiterElement:o}){const r=ea(e),a=i&&n;let l,c,d;const h=o||r.document.body;for(;e!=h;)c=t(),l=new Ir(e).excludeScrollbarsAndBorders(),d=l.contains(c),a?e.scrollTop-=l.top-c.top+s:d||(Qr(c,l)?e.scrollTop-=l.top-c.top+s:Jr(c,l)&&(e.scrollTop+=i?c.top-l.top-s:c.bottom-l.bottom+s)),d||(Yr(c,l)?e.scrollLeft-=l.left-c.left+s:Xr(c,l)&&(e.scrollLeft+=c.right-l.right+s)),e=e.parentNode}function Jr(e,t){return e.bottom>t.bottom}function Qr(e,t){return e.top<t.top}function Yr(e,t){return e.left<t.left}function Xr(e,t){return e.right>t.right}function ea(e){return Er(e)?e.startContainer.ownerDocument.defaultView:e.ownerDocument.defaultView}function ta(e){if(Er(e)){let t=e.commonAncestorContainer;return Ar(t)&&(t=t.parentNode),t}return e.parentNode}function ia(e,t){const i=ea(e),n=new Ir(e);if(i===t)return n;{let e=i;for(;e!=t;){const t=e.frameElement,i=new Ir(t).excludeScrollbarsAndBorders();n.moveBy(i.left,i.top),e=e.parent}}return n}const na={ctrl:"⌃",cmd:"⌘",alt:"⌥",shift:"⇧"},sa={ctrl:"Ctrl+",alt:"Alt+",shift:"Shift+"},oa={37:"←",38:"↑",39:"→",40:"↓",9:"⇥",33:"Page Up",34:"Page Down"},ra=function(){const e={pageup:33,pagedown:34,arrowleft:37,arrowup:38,arrowright:39,arrowdown:40,backspace:8,delete:46,enter:13,space:32,esc:27,tab:9,ctrl:1114112,shift:2228224,alt:4456448,cmd:8912896};for(let t=65;t<=90;t++){e[String.fromCharCode(t).toLowerCase()]=t}for(let t=48;t<=57;t++)e[t-48]=t;for(let t=112;t<=123;t++)e["f"+(t-111)]=t;return Object.assign(e,{"'":222,",":108,"-":109,".":110,"/":111,";":186,"=":187,"[":219,"\\":220,"]":221,"`":223}),e}(),aa=Object.fromEntries(Object.entries(ra).map((([e,t])=>{let i;return i=t in oa?oa[t]:e.charAt(0).toUpperCase()+e.slice(1),[t,i]})));function la(e){let t;if("string"==typeof e){if(t=ra[e.toLowerCase()],!t)throw new p("keyboard-unknown-key",null,{key:e})}else t=e.keyCode+(e.altKey?ra.alt:0)+(e.ctrlKey?ra.ctrl:0)+(e.shiftKey?ra.shift:0)+(e.metaKey?ra.cmd:0);return t}function ca(e){return"string"==typeof e&&(e=function(e){return e.split("+").map((e=>e.trim()))}(e)),e.map((e=>"string"==typeof e?function(e){if(e.endsWith("!"))return la(e.slice(0,-1));const t=la(e);return(i.isMac||i.isiOS)&&t==ra.ctrl?ra.cmd:t}(e):e)).reduce(((e,t)=>t+e),0)}function da(e){let t=ca(e);return Object.entries(i.isMac||i.isiOS?na:sa).reduce(((e,[i,n])=>(t&ra[i]&&(t&=~ra[i],e+=n),e)),"")+(t?aa[t]:"")}function ha(e){return e==ra.arrowright||e==ra.arrowleft||e==ra.arrowup||e==ra.arrowdown}function ua(e,t){const i="ltr"===t;switch(e){case ra.arrowleft:return i?"left":"right";case ra.arrowright:return i?"right":"left";case ra.arrowup:return"up";case ra.arrowdown:return"down"}}function ma(e,t){const i=ua(e,t);return"down"===i||"right"===i}const ga=["ar","ara","dv","div","fa","per","fas","he","heb","ku","kur","ug","uig"];function fa(e){return ga.includes(e)?"rtl":"ltr"}function pa(e){return Array.isArray(e)?e:[e]}function ba(e,t,i=1,n){if("number"!=typeof i)throw new p("translation-service-quantity-not-a-number",null,{quantity:i});const s=n||_r.window.CKEDITOR_TRANSLATIONS,o=function(e){return Object.keys(e).length}(s);1===o&&(e=Object.keys(s)[0]);const r=t.id||t.string;if(0===o||!function(e,t,i){return!!i[e]&&!!i[e].dictionary[t]}(e,r,s))return 1!==i?t.plural:t.string;const a=s[e].dictionary,l=s[e].getPluralForm||(e=>1===e?0:1),c=a[r];if("string"==typeof c)return c;return c[Number(l(i))]}_r.window.CKEDITOR_TRANSLATIONS||(_r.window.CKEDITOR_TRANSLATIONS={});class wa{get language(){return console.warn("locale-deprecated-language-property: The Locale#language property has been deprecated and will be removed in the near future. Please use #uiLanguage and #contentLanguage properties instead."),this.uiLanguage}_t(e,t=[]){t=pa(t),"string"==typeof e&&(e={string:e});const i=!!e.plural?t[0]:1;return function(e,t){return e.replace(/%(\d+)/g,((e,i)=>i<t.length?t[i]:e))}(ba(this.uiLanguage,e,i,this.translations),t)}constructor({uiLanguage:e="en",contentLanguage:t,translations:i}={}){this.uiLanguage=e,this.contentLanguage=t||this.uiLanguage,this.uiLanguageDirection=fa(this.uiLanguage),this.contentLanguageDirection=fa(this.contentLanguage),this.translations=function(e){return Array.isArray(e)?e.reduce(((e,t)=>zo(e,t))):e}(i),this.t=(e,t)=>this._t(e,t)}}class va extends(T()){get length(){return this._items.length}get first(){return this._items[0]||null}get last(){return this._items[this.length-1]||null}add(e,t){return this.addMany([e],t)}addMany(e,t){if(void 0===t)t=this._items.length;else if(t>this._items.length||t<0)throw new p("collection-add-item-invalid-index",this);let i=0;for(const n of e){const e=this._getItemIdBeforeAdding(n),s=t+i;this._items.splice(s,0,n),this._itemMap.set(e,n),this.fire("add",n,s),i++}return this.fire("change",{added:e,removed:[],index:t}),this}get(e){let t;if("string"==typeof e)t=this._itemMap.get(e);else{if("number"!=typeof e)throw new p("collection-get-invalid-arg",this);t=this._items[e]}return t||null}has(e){if("string"==typeof e)return this._itemMap.has(e);{const t=e[this._idProperty];return t&&this._itemMap.has(t)}}getIndex(e){let t;return t="string"==typeof e?this._itemMap.get(e):e,t?this._items.indexOf(t):-1}remove(e){const[t,i]=this._remove(e);return this.fire("change",{added:[],removed:[t],index:i}),t}map(e,t){return this._items.map(e,t)}forEach(e,t){this._items.forEach(e,t)}find(e,t){return this._items.find(e,t)}filter(e,t){return this._items.filter(e,t)}clear(){this._bindToCollection&&(this.stopListening(this._bindToCollection),this._bindToCollection=null);const e=Array.from(this._items);for(;this.length;)this._remove(0);this.fire("change",{added:[],removed:e,index:0})}bindTo(e){if(this._bindToCollection)throw new p("collection-bind-to-rebind",this);return this._bindToCollection=e,{as:e=>{this._setUpBindToBinding((t=>new e(t)))},using:e=>{"function"==typeof e?this._setUpBindToBinding(e):this._setUpBindToBinding((t=>t[e]))}}}_setUpBindToBinding(e){const t=this._bindToCollection,i=(i,n,s)=>{const o=t._bindToCollection==this,r=t._bindToInternalToExternalMap.get(n);if(o&&r)this._bindToExternalToInternalMap.set(n,r),this._bindToInternalToExternalMap.set(r,n);else{const i=e(n);if(!i)return void this._skippedIndexesFromExternal.push(s);let o=s;for(const e of this._skippedIndexesFromExternal)s>e&&o--;for(const e of t._skippedIndexesFromExternal)o>=e&&o++;this._bindToExternalToInternalMap.set(n,i),this._bindToInternalToExternalMap.set(i,n),this.add(i,o);for(let e=0;e<t._skippedIndexesFromExternal.length;e++)o<=t._skippedIndexesFromExternal[e]&&t._skippedIndexesFromExternal[e]++}};for(const e of t)i(0,e,t.getIndex(e));this.listenTo(t,"add",i),this.listenTo(t,"remove",((e,t,i)=>{const n=this._bindToExternalToInternalMap.get(t);n&&this.remove(n),this._skippedIndexesFromExternal=this._skippedIndexesFromExternal.reduce(((e,t)=>(i<t&&e.push(t-1),i>t&&e.push(t),e)),[])}))}_getItemIdBeforeAdding(e){const t=this._idProperty;let i;if(t in e){if(i=e[t],"string"!=typeof i)throw new p("collection-add-invalid-id",this);if(this.get(i))throw new p("collection-add-item-already-exists",this)}else e[t]=i=u();return i}_remove(e){let t,i,n,s=!1;const o=this._idProperty;if("string"==typeof e?(i=e,n=this._itemMap.get(i),s=!n,n&&(t=this._items.indexOf(n))):"number"==typeof e?(t=e,n=this._items[t],s=!n,n&&(i=n[o])):(n=e,i=n[o],t=this._items.indexOf(n),s=-1==t||!this._itemMap.get(i)),s)throw new p("collection-remove-404",this);this._items.splice(t,1),this._itemMap.delete(i);const r=this._bindToInternalToExternalMap.get(n);return this._bindToInternalToExternalMap.delete(n),this._bindToExternalToInternalMap.delete(r),this.fire("remove",n,t),[n,t]}[Symbol.iterator](){return this._items[Symbol.iterator]()}constructor(e={},t={}){super();const i=lr(e);if(i||(t=e),this._items=[],this._itemMap=new Map,this._idProperty=t.idProperty||"id",this._bindToExternalToInternalMap=new WeakMap,this._bindToInternalToExternalMap=new WeakMap,this._skippedIndexesFromExternal=[],i)for(const t of e)this._items.push(t),this._itemMap.set(this._getItemIdBeforeAdding(t),t)}}function _a(e){const t=e.next();return t.done?null:t.value}class ya extends(pr(Yo())){add(e){if(this._elements.has(e))throw new p("focustracker-add-element-already-exist",this);this.listenTo(e,"focus",(()=>this._focus(e)),{useCapture:!0}),this.listenTo(e,"blur",(()=>this._blur()),{useCapture:!0}),this._elements.add(e)}remove(e){e===this.focusedElement&&this._blur(),this._elements.has(e)&&(this.stopListening(e),this._elements.delete(e))}destroy(){this.stopListening()}_focus(e){clearTimeout(this._nextEventLoopTimeout),this.focusedElement=e,this.isFocused=!0}_blur(){clearTimeout(this._nextEventLoopTimeout),this._nextEventLoopTimeout=setTimeout((()=>{this.focusedElement=null,this.isFocused=!1}),0)}constructor(){super(),this._elements=new Set,this._nextEventLoopTimeout=null,this.set("isFocused",!1),this.set("focusedElement",null)}}class ka{listenTo(e){this._listener.listenTo(e,"keydown",((e,t)=>{this._listener.fire("_keydown:"+la(t),t)}))}set(e,t,i={}){const n=ca(e),s=i.priority;this._listener.listenTo(this._listener,"_keydown:"+n,((e,i)=>{t(i,(()=>{i.preventDefault(),i.stopPropagation(),e.stop()})),e.return=!0}),{priority:s})}press(e){return!!this._listener.fire("_keydown:"+la(e),e)}stopListening(e){this._listener.stopListening(e)}destroy(){this.stopListening()}constructor(){this._listener=new(pr())}}function Ca(e){return lr(e)?new Map(e):function(e){const t=new Map;for(const i in e)t.set(i,e[i]);return t}(e)}function xa(e,t={}){return new Promise(((i,n)=>{const s=t.signal||(new AbortController).signal;s.throwIfAborted();const o=setTimeout((function(){s.removeEventListener("abort",r),i()}),e);function r(){clearTimeout(o),n(s.reason)}s.addEventListener("abort",r,{once:!0})}))}async function Aa(e,t={}){const{maxAttempts:i=4,retryDelay:n=Ea(),signal:s=(new AbortController).signal}=t;s.throwIfAborted();for(let t=0;;t++){try{return await e()}catch(e){if(t+1>=i)throw e}await xa(n(t),{signal:s})}}function Ea(e={}){const{delay:t=1e3,factor:i=2,maxDelay:n=1e4}=e;return e=>Math.min(i**e*t,n)}function Ta(e,t,i,n){if(Math.max(t.length,e.length)>1e4)return e.slice(0,i).concat(t).concat(e.slice(i+n,e.length));{const s=Array.from(e);return s.splice(i,n,...t),s}}function Sa(e,t){let i;function n(...s){n.cancel(),i=setTimeout((()=>e(...s)),t)}return n.cancel=()=>{clearTimeout(i)},n}function Ia(e){function t(e){return e.length>=40&&e.length<=255?"VALID":"INVALID"}if(!e)return"INVALID";let i="";try{i=atob(e)}catch(e){return"INVALID"}const n=i.split("-"),s=n[0],o=n[1];if(!o)return t(e);try{atob(o)}catch(i){try{if(atob(s),!atob(s).length)return t(e)}catch(i){return t(e)}}if(s.length<40||s.length>255)return"INVALID";let r="";try{atob(s),r=atob(o)}catch(e){return"INVALID"}if(8!==r.length)return"INVALID";const a=Number(r.substring(0,4)),l=Number(r.substring(4,6))-1,c=Number(r.substring(6,8)),d=new Date(a,l,c);return d<k||isNaN(Number(d))?"INVALID":"VALID"}function Pa(e){return!!e&&1==e.length&&/[\u0300-\u036f\u1ab0-\u1aff\u1dc0-\u1dff\u20d0-\u20ff\ufe20-\ufe2f]/.test(e)}function Va(e){return!!e&&1==e.length&&/[\ud800-\udbff]/.test(e)}function Ra(e){return!!e&&1==e.length&&/[\udc00-\udfff]/.test(e)}function Ba(e,t){return Va(e.charAt(t-1))&&Ra(e.charAt(t))}function Oa(e,t){return Pa(e.charAt(t))}const Ma=function(){const e=[RegExp("\\p{Emoji}[\\u{E0020}-\\u{E007E}]+\\u{E007F}","u"),RegExp("\\p{Emoji}\\u{FE0F}?\\u{20E3}","u"),RegExp("\\p{Emoji}\\u{FE0F}","u"),RegExp("(?=\\p{General_Category=Other_Symbol})\\p{Emoji}\\p{Emoji_Modifier}*","u")],t=RegExp("\\p{Regional_Indicator}{2}","u").source,i="(?:"+e.map((e=>e.source)).join("|")+")";return new RegExp(`${t}|${i}(?:‍${i})*`,"ug")}();function La(e,t){const i=String(e).matchAll(Ma);return Array.from(i).some((e=>e.index<t&&t<e.index+e[0].length))}class Na extends(Yo()){forceDisabled(e){this._disableStack.add(e),1==this._disableStack.size&&(this.on("set:isEnabled",Fa,{priority:"highest"}),this.isEnabled=!1)}clearForceDisabled(e){this._disableStack.delete(e),0==this._disableStack.size&&(this.off("set:isEnabled",Fa),this.isEnabled=!0)}destroy(){this.stopListening()}static get isContextPlugin(){return!1}constructor(e){super(),this._disableStack=new Set,this.editor=e,this.set("isEnabled",!0)}}function Fa(e){e.return=!1,e.stop()}class Da extends(Yo()){get affectsData(){return this._affectsData}set affectsData(e){this._affectsData=e}refresh(){this.isEnabled=!0}forceDisabled(e){this._disableStack.add(e),1==this._disableStack.size&&(this.on("set:isEnabled",za,{priority:"highest"}),this.isEnabled=!1)}clearForceDisabled(e){this._disableStack.delete(e),0==this._disableStack.size&&(this.off("set:isEnabled",za),this.refresh())}execute(...e){}destroy(){this.stopListening()}constructor(e){super(),this.editor=e,this.set("value",void 0),this.set("isEnabled",!1),this._affectsData=!0,this._isEnabledBasedOnSelection=!0,this._disableStack=new Set,this.decorate("execute"),this.listenTo(this.editor.model.document,"change",(()=>{this.refresh()})),this.listenTo(e,"change:isReadOnly",(()=>{this.refresh()})),this.on("set:isEnabled",(t=>{if(!this.affectsData)return;const i=e.model.document.selection,n=!("$graveyard"==i.getFirstPosition().root.rootName)&&e.model.canEditAt(i);(e.isReadOnly||this._isEnabledBasedOnSelection&&!n)&&(t.return=!1,t.stop())}),{priority:"highest"}),this.on("execute",(e=>{this.isEnabled||e.stop()}),{priority:"high"})}}function za(e){e.return=!1,e.stop()}class Ha extends Da{refresh(){}execute(...e){const t=this._getFirstEnabledCommand();return!!t&&t.execute(e)}registerChildCommand(e,t={}){g(this._childCommandsDefinitions,{command:e,priority:t.priority||"normal"}),e.on("change:isEnabled",(()=>this._checkEnabled())),this._checkEnabled()}_checkEnabled(){this.isEnabled=!!this._getFirstEnabledCommand()}_getFirstEnabledCommand(){const e=this._childCommandsDefinitions.find((({command:e})=>e.isEnabled));return e&&e.command}constructor(...e){super(...e),this._childCommandsDefinitions=[]}}class $a extends(T()){*[Symbol.iterator](){for(const e of this._plugins)"function"==typeof e[0]&&(yield e)}get(e){const t=this._plugins.get(e);if(!t){let t=e;throw"function"==typeof e&&(t=e.pluginName||e.name),new p("plugincollection-plugin-not-loaded",this._context,{plugin:t})}return t}has(e){return this._plugins.has(e)}init(e,t=[],i=[]){const n=this,s=this._context;!function e(t,i=new Set){t.forEach((t=>{a(t)&&(i.has(t)||(i.add(t),t.pluginName&&!n._availablePlugins.has(t.pluginName)&&n._availablePlugins.set(t.pluginName,t),t.requires&&e(t.requires,i)))}))}(e),h(e);const o=[...function e(t,i=new Set){return t.map((e=>a(e)?e:n._availablePlugins.get(e))).reduce(((t,n)=>i.has(n)?t:(i.add(n),n.requires&&(h(n.requires,n),e(n.requires,i).forEach((e=>t.add(e)))),t.add(n))),new Set)}(e.filter((e=>!c(e,t))))];!function(e,t){for(const i of t){if("function"!=typeof i)throw new p("plugincollection-replace-plugin-invalid-type",null,{pluginItem:i});const t=i.pluginName;if(!t)throw new p("plugincollection-replace-plugin-missing-name",null,{pluginItem:i});if(i.requires&&i.requires.length)throw new p("plugincollection-plugin-for-replacing-cannot-have-dependencies",null,{pluginName:t});const s=n._availablePlugins.get(t);if(!s)throw new p("plugincollection-plugin-for-replacing-not-exist",null,{pluginName:t});const o=e.indexOf(s);if(-1===o){if(n._contextPlugins.has(s))return;throw new p("plugincollection-plugin-for-replacing-not-loaded",null,{pluginName:t})}if(s.requires&&s.requires.length)throw new p("plugincollection-replaced-plugin-cannot-have-dependencies",null,{pluginName:t});e.splice(o,1,i),n._availablePlugins.set(t,i)}}(o,i);const r=function(e){return e.map((e=>{let t=n._contextPlugins.get(e);return t=t||new e(s),n._add(e,t),t}))}(o);return u(r,"init").then((()=>u(r,"afterInit"))).then((()=>r));function a(e){return"function"==typeof e}function l(e){return a(e)&&!!e.isContextPlugin}function c(e,t){return t.some((t=>t===e||(d(e)===t||d(t)===e)))}function d(e){return a(e)?e.pluginName||e.name:e}function h(e,i=null){e.map((e=>a(e)?e:n._availablePlugins.get(e)||e)).forEach((e=>{!function(e,t){if(a(e))return;if(t)throw new p("plugincollection-soft-required",s,{missingPlugin:e,requiredBy:d(t)});throw new p("plugincollection-plugin-not-found",s,{plugin:e})}(e,i),function(e,t){if(!l(t))return;if(l(e))return;throw new p("plugincollection-context-required",s,{plugin:d(e),requiredBy:d(t)})}(e,i),function(e,i){if(!i)return;if(!c(e,t))return;throw new p("plugincollection-required",s,{plugin:d(e),requiredBy:d(i)})}(e,i)}))}function u(e,t){return e.reduce(((e,i)=>i[t]?n._contextPlugins.has(i)?e:e.then(i[t].bind(i)):e),Promise.resolve())}}destroy(){const e=[];for(const[,t]of this)"function"!=typeof t.destroy||this._contextPlugins.has(t)||e.push(t.destroy());return Promise.all(e)}_add(e,t){this._plugins.set(e,t);const i=e.pluginName;if(i){if(this._plugins.has(i))throw new p("plugincollection-plugin-name-conflict",null,{pluginName:i,plugin1:this._plugins.get(i).constructor,plugin2:e});this._plugins.set(i,t)}}constructor(e,t=[],i=[]){super(),this._plugins=new Map,this._context=e,this._availablePlugins=new Map;for(const e of t)e.pluginName&&this._availablePlugins.set(e.pluginName,e);this._contextPlugins=new Map;for(const[e,t]of i)this._contextPlugins.set(e,t),this._contextPlugins.set(t,e),e.pluginName&&this._availablePlugins.set(e.pluginName,e)}}class Ua{initPlugins(){const e=this.config.get("plugins")||[],t=this.config.get("substitutePlugins")||[];for(const i of e.concat(t)){if("function"!=typeof i)throw new p("context-initplugins-constructor-only",null,{Plugin:i});if(!0!==i.isContextPlugin)throw new p("context-initplugins-invalid-plugin",null,{Plugin:i})}return this.plugins.init(e,[],t)}destroy(){return Promise.all(Array.from(this.editors,(e=>e.destroy()))).then((()=>this.plugins.destroy()))}_addEditor(e,t){if(this._contextOwner)throw new p("context-addeditor-private-context");this.editors.add(e),t&&(this._contextOwner=e)}_removeEditor(e){return this.editors.has(e)&&this.editors.remove(e),this._contextOwner===e?this.destroy():Promise.resolve()}_getEditorConfig(){const e={};for(const t of this.config.names())["plugins","removePlugins","extraPlugins"].includes(t)||(e[t]=this.config.get(t));return e}static create(e){return new Promise((t=>{const i=new this(e);t(i.initPlugins().then((()=>i)))}))}constructor(e){this._contextOwner=null;const{translations:t,...i}=e||{};this.config=new dr(i,this.constructor.defaultConfig);const n=this.constructor.builtinPlugins;this.config.define("plugins",n),this.plugins=new $a(this,n);const s=this.config.get("language")||{};this.locale=new wa({uiLanguage:"string"==typeof s?s:s.ui,contentLanguage:this.config.get("language.content"),translations:t}),this.t=this.locale.t,this.editors=new va}}class Wa extends(Yo()){destroy(){this.stopListening()}static get isContextPlugin(){return!0}constructor(e){super(),this.context=e}}const ja=new WeakMap;let qa=!1;function Ga({view:e,element:t,text:i,isDirectHost:n=!0,keepOnFocus:s=!1}){const o=e.document;function r(i){ja.get(o).set(t,{text:i,isDirectHost:n,keepOnFocus:s,hostElement:n?t:null}),e.change((e=>Ya(o,e)))}ja.has(o)||(ja.set(o,new Map),o.registerPostFixer((e=>Ya(o,e))),o.on("change:isComposing",(()=>{e.change((e=>Ya(o,e)))}),{priority:"high"})),t.is("editableElement")&&t.on("change:placeholder",((e,t,i)=>{r(i)})),t.placeholder?r(t.placeholder):i&&r(i),i&&function(){qa||b("enableplaceholder-deprecated-text-option");qa=!0}()}function Ka(e,t){const i=t.document;ja.has(i)&&e.change((e=>{const n=ja.get(i),s=n.get(t);e.removeAttribute("data-placeholder",s.hostElement),Ja(e,s.hostElement),n.delete(t)}))}function Za(e,t){return!t.hasClass("ck-placeholder")&&(e.addClass("ck-placeholder",t),!0)}function Ja(e,t){return!!t.hasClass("ck-placeholder")&&(e.removeClass("ck-placeholder",t),!0)}function Qa(e,t){if(!e.isAttached())return!1;const i=Array.from(e.getChildren()).some((e=>!e.is("uiElement")));if(i)return!1;const n=e.document,s=n.selection.anchor;return(!n.isComposing||!s||s.parent!==e)&&(!!t||(!n.isFocused||!!s&&s.parent!==e))}function Ya(e,t){const i=ja.get(e),n=[];let s=!1;for(const[e,o]of i)o.isDirectHost&&(n.push(e),Xa(t,e,o)&&(s=!0));for(const[e,o]of i){if(o.isDirectHost)continue;const i=el(e);i&&(n.includes(i)||(o.hostElement=i,Xa(t,e,o)&&(s=!0)))}return s}function Xa(e,t,i){const{text:n,isDirectHost:s,hostElement:o}=i;let r=!1;o.getAttribute("data-placeholder")!==n&&(e.setAttribute("data-placeholder",n,o),r=!0);return(s||1==t.childCount)&&Qa(o,i.keepOnFocus)?Za(e,o)&&(r=!0):Ja(e,o)&&(r=!0),r}function el(e){if(e.childCount){const t=e.getChild(0);if(t.is("element")&&!t.is("uiElement")&&!t.is("attributeElement"))return t}return null}let tl=class{is(){throw new Error("is() method is abstract")}},il=class extends(T(tl)){get index(){let e;if(!this.parent)return null;if(-1==(e=this.parent.getChildIndex(this)))throw new p("view-node-not-found-in-parent",this);return e}get nextSibling(){const e=this.index;return null!==e&&this.parent.getChild(e+1)||null}get previousSibling(){const e=this.index;return null!==e&&this.parent.getChild(e-1)||null}get root(){let e=this;for(;e.parent;)e=e.parent;return e}isAttached(){return this.root.is("rootElement")}getPath(){const e=[];let t=this;for(;t.parent;)e.unshift(t.index),t=t.parent;return e}getAncestors(e={}){const t=[];let i=e.includeSelf?this:this.parent;for(;i;)t[e.parentFirst?"push":"unshift"](i),i=i.parent;return t}getCommonAncestor(e,t={}){const i=this.getAncestors(t),n=e.getAncestors(t);let s=0;for(;i[s]==n[s]&&i[s];)s++;return 0===s?null:i[s-1]}isBefore(e){if(this==e)return!1;if(this.root!==e.root)return!1;const t=this.getPath(),i=e.getPath(),n=ar(t,i);switch(n){case"prefix":return!0;case"extension":return!1;default:return t[n]<i[n]}}isAfter(e){return this!=e&&(this.root===e.root&&!this.isBefore(e))}_remove(){this.parent._removeChildren(this.index)}_fireChange(e,t){this.fire(`change:${e}`,t),this.parent&&this.parent._fireChange(e,t)}toJSON(){const e=bs(this);return delete e.parent,e}constructor(e){super(),this.document=e,this.parent=null}};il.prototype.is=function(e){return"node"===e||"view:node"===e};let nl=class e extends il{get data(){return this._textData}get _data(){return this.data}set _data(e){this._fireChange("text",this),this._textData=e}isSimilar(t){return t instanceof e&&(this===t||this.data===t.data)}_clone(){return new e(this.document,this.data)}constructor(e,t){super(e),this._textData=t}};nl.prototype.is=function(e){return"$text"===e||"view:$text"===e||"text"===e||"view:text"===e||"node"===e||"view:node"===e};let sl=class extends tl{get offsetSize(){return this.data.length}get isPartial(){return this.data.length!==this.textNode.data.length}get parent(){return this.textNode.parent}get root(){return this.textNode.root}get document(){return this.textNode.document}getAncestors(e={}){const t=[];let i=e.includeSelf?this.textNode:this.parent;for(;null!==i;)t[e.parentFirst?"push":"unshift"](i),i=i.parent;return t}constructor(e,t,i){if(super(),this.textNode=e,t<0||t>e.data.length)throw new p("view-textproxy-wrong-offsetintext",this);if(i<0||t+i>e.data.length)throw new p("view-textproxy-wrong-length",this);this.data=e.data.substring(t,t+i),this.offsetInText=t}};sl.prototype.is=function(e){return"$textProxy"===e||"view:$textProxy"===e||"textProxy"===e||"view:textProxy"===e};class ol{add(...e){for(let t of e)("string"==typeof t||t instanceof RegExp)&&(t={name:t}),this._patterns.push(t)}match(...e){for(const t of e)for(const e of this._patterns){const i=rl(t,e);if(i)return{element:t,pattern:e,match:i}}return null}matchAll(...e){const t=[];for(const i of e)for(const e of this._patterns){const n=rl(i,e);n&&t.push({element:i,pattern:e,match:n})}return t.length>0?t:null}getElementName(){if(1!==this._patterns.length)return null;const e=this._patterns[0],t=e.name;return"function"==typeof e||!t||t instanceof RegExp?null:t}constructor(...e){this._patterns=[],this.add(...e)}}function rl(e,t){if("function"==typeof t)return t(e);const i={};return t.name&&(i.name=function(e,t){if(e instanceof RegExp)return!!t.match(e);return e===t}(t.name,e.name),!i.name)||t.attributes&&(i.attributes=function(e,t){const i=new Set(t.getAttributeKeys());oi(e)?(void 0!==e.style&&b("matcher-pattern-deprecated-attributes-style-key",e),void 0!==e.class&&b("matcher-pattern-deprecated-attributes-class-key",e)):(i.delete("style"),i.delete("class"));return al(e,i,(e=>t.getAttribute(e)))}(t.attributes,e),!i.attributes)||t.classes&&(i.classes=function(e,t){return al(e,t.getClassNames(),(()=>{}))}(t.classes,e),!i.classes)||t.styles&&(i.styles=function(e,t){return al(e,t.getStyleNames(!0),(e=>t.getStyle(e)))}(t.styles,e),!i.styles)?null:i}function al(e,t,i){const n=function(e){if(Array.isArray(e))return e.map((e=>oi(e)?(void 0!==e.key&&void 0!==e.value||b("matcher-pattern-missing-key-or-value",e),[e.key,e.value]):[e,!0]));if(oi(e))return Object.entries(e);return[[e,!0]]}(e),s=Array.from(t),o=[];if(n.forEach((([e,t])=>{s.forEach((n=>{(function(e,t){return!0===e||e===t||e instanceof RegExp&&t.match(e)})(e,n)&&function(e,t,i){if(!0===e)return!0;const n=i(t);return e===n||e instanceof RegExp&&!!String(n).match(e)}(t,n,i)&&o.push(n)}))})),n.length&&!(o.length<n.length))return o}class ll{get isEmpty(){return!Object.entries(this._styles).length}get size(){return this.isEmpty?0:this.getStyleNames().length}setTo(e){this.clear();const t=function(e){let t=null,i=0,n=0,s=null;const o=new Map;if(""===e)return o;";"!=e.charAt(e.length-1)&&(e+=";");for(let r=0;r<e.length;r++){const a=e.charAt(r);if(null===t)switch(a){case":":s||(s=e.substr(i,r-i),n=r+1);break;case'"':case"'":t=a;break;case";":{const t=e.substr(n,r-n);s&&o.set(s.trim(),t.trim()),s=null,i=r+1;break}}else a===t&&(t=null)}return o}(e);for(const[e,i]of t)this._styleProcessor.toNormalizedForm(e,i,this._styles)}has(e){if(this.isEmpty)return!1;const t=this._styleProcessor.getReducedForm(e,this._styles).find((([t])=>t===e));return Array.isArray(t)}set(e,t){if(re(e))for(const[t,i]of Object.entries(e))this._styleProcessor.toNormalizedForm(t,i,this._styles);else this._styleProcessor.toNormalizedForm(e,t,this._styles)}remove(e){const t=dl(e);!function(e,t){null==e||Ho(e,t)}(this._styles,t),delete this._styles[e],this._cleanEmptyObjectsOnPath(t)}getNormalized(e){return this._styleProcessor.getNormalized(e,this._styles)}toString(){return this.isEmpty?"":this.getStylesEntries().map((e=>e.join(":"))).sort().join(";")+";"}getAsString(e){if(this.isEmpty)return;if(this._styles[e]&&!re(this._styles[e]))return this._styles[e];const t=this._styleProcessor.getReducedForm(e,this._styles).find((([t])=>t===e));return Array.isArray(t)?t[1]:void 0}getStyleNames(e=!1){if(this.isEmpty)return[];if(e)return this._styleProcessor.getStyleNames(this._styles);return this.getStylesEntries().map((([e])=>e))}clear(){this._styles={}}getStylesEntries(){const e=[],t=Object.keys(this._styles);for(const i of t)e.push(...this._styleProcessor.getReducedForm(i,this._styles));return e}_cleanEmptyObjectsOnPath(e){const t=e.split(".");if(!(t.length>1))return;const i=t.splice(0,t.length-1).join("."),n=Jt(this._styles,i);if(!n)return;!Object.keys(n).length&&this.remove(i)}constructor(e){this._styles={},this._styleProcessor=e}}class cl{toNormalizedForm(e,t,i){if(re(t))hl(i,dl(e),t);else if(this._normalizers.has(e)){const n=this._normalizers.get(e),{path:s,value:o}=n(t);hl(i,s,o)}else hl(i,e,t)}getNormalized(e,t){if(!e)return zo({},t);if(void 0!==t[e])return t[e];if(this._extractors.has(e)){const i=this._extractors.get(e);if("string"==typeof i)return Jt(t,i);const n=i(e,t);if(n)return n}return Jt(t,dl(e))}getReducedForm(e,t){const i=this.getNormalized(e,t);if(void 0===i)return[];if(this._reducers.has(e)){return this._reducers.get(e)(i)}return[[e,i]]}getStyleNames(e){const t=Array.from(this._consumables.keys()).filter((t=>{const i=this.getNormalized(t,e);return i&&"object"==typeof i?Object.keys(i).length:i})),i=new Set([...t,...Object.keys(e)]);return Array.from(i)}getRelatedStyles(e){return this._consumables.get(e)||[]}setNormalizer(e,t){this._normalizers.set(e,t)}setExtractor(e,t){this._extractors.set(e,t)}setReducer(e,t){this._reducers.set(e,t)}setStyleRelation(e,t){this._mapStyleNames(e,t);for(const i of t)this._mapStyleNames(i,[e])}_mapStyleNames(e,t){this._consumables.has(e)||this._consumables.set(e,[]),this._consumables.get(e).push(...t)}constructor(){this._normalizers=new Map,this._extractors=new Map,this._reducers=new Map,this._consumables=new Map}}function dl(e){return e.replace("-",".")}function hl(e,t,i){let n=i;re(i)&&(n=zo({},Jt(e,t),i)),$o(e,t,n)}let ul=class e extends il{get childCount(){return this._children.length}get isEmpty(){return 0===this._children.length}getChild(e){return this._children[e]}getChildIndex(e){return this._children.indexOf(e)}getChildren(){return this._children[Symbol.iterator]()}*getAttributeKeys(){this._classes.size>0&&(yield"class"),this._styles.isEmpty||(yield"style"),yield*this._attrs.keys()}*getAttributes(){yield*this._attrs.entries(),this._classes.size>0&&(yield["class",this.getAttribute("class")]),this._styles.isEmpty||(yield["style",this.getAttribute("style")])}getAttribute(e){if("class"==e)return this._classes.size>0?[...this._classes].join(" "):void 0;if("style"==e){const e=this._styles.toString();return""==e?void 0:e}return this._attrs.get(e)}hasAttribute(e){return"class"==e?this._classes.size>0:"style"==e?!this._styles.isEmpty:this._attrs.has(e)}isSimilar(t){if(!(t instanceof e))return!1;if(this===t)return!0;if(this.name!=t.name)return!1;if(this._attrs.size!==t._attrs.size||this._classes.size!==t._classes.size||this._styles.size!==t._styles.size)return!1;for(const[e,i]of this._attrs)if(!t._attrs.has(e)||t._attrs.get(e)!==i)return!1;for(const e of this._classes)if(!t._classes.has(e))return!1;for(const e of this._styles.getStyleNames())if(!t._styles.has(e)||t._styles.getAsString(e)!==this._styles.getAsString(e))return!1;return!0}hasClass(...e){for(const t of e)if(!this._classes.has(t))return!1;return!0}getClassNames(){return this._classes.keys()}getStyle(e){return this._styles.getAsString(e)}getNormalizedStyle(e){return this._styles.getNormalized(e)}getStyleNames(e){return this._styles.getStyleNames(e)}hasStyle(...e){for(const t of e)if(!this._styles.has(t))return!1;return!0}findAncestor(...e){const t=new ol(...e);let i=this.parent;for(;i&&!i.is("documentFragment");){if(t.match(i))return i;i=i.parent}return null}getCustomProperty(e){return this._customProperties.get(e)}*getCustomProperties(){yield*this._customProperties.entries()}getIdentity(){const e=Array.from(this._classes).sort().join(","),t=this._styles.toString(),i=Array.from(this._attrs).map((e=>`${e[0]}="${e[1]}"`)).sort().join(" ");return this.name+(""==e?"":` class="${e}"`)+(t?` style="${t}"`:"")+(""==i?"":` ${i}`)}shouldRenderUnsafeAttribute(e){return this._unsafeAttributesToRender.includes(e)}_clone(e=!1){const t=[];if(e)for(const i of this.getChildren())t.push(i._clone(e));const i=new this.constructor(this.document,this.name,this._attrs,t);return i._classes=new Set(this._classes),i._styles.set(this._styles.getNormalized()),i._customProperties=new Map(this._customProperties),i.getFillerOffset=this.getFillerOffset,i._unsafeAttributesToRender=this._unsafeAttributesToRender,i}_appendChild(e){return this._insertChild(this.childCount,e)}_insertChild(e,t){this._fireChange("children",this);let i=0;const n=function(e,t){if("string"==typeof t)return[new nl(e,t)];lr(t)||(t=[t]);return Array.from(t).map((t=>"string"==typeof t?new nl(e,t):t instanceof sl?new nl(e,t.data):t))}(this.document,t);for(const t of n)null!==t.parent&&t._remove(),t.parent=this,t.document=this.document,this._children.splice(e,0,t),e++,i++;return i}_removeChildren(e,t=1){this._fireChange("children",this);for(let i=e;i<e+t;i++)this._children[i].parent=null;return this._children.splice(e,t)}_setAttribute(e,t){const i=String(t);this._fireChange("attributes",this),"class"==e?ml(this._classes,i):"style"==e?this._styles.setTo(i):this._attrs.set(e,i)}_removeAttribute(e){return this._fireChange("attributes",this),"class"==e?this._classes.size>0&&(this._classes.clear(),!0):"style"==e?!this._styles.isEmpty&&(this._styles.clear(),!0):this._attrs.delete(e)}_addClass(e){this._fireChange("attributes",this);for(const t of pa(e))this._classes.add(t)}_removeClass(e){this._fireChange("attributes",this);for(const t of pa(e))this._classes.delete(t)}_setStyle(e,t){this._fireChange("attributes",this),"string"!=typeof e?this._styles.set(e):this._styles.set(e,t)}_removeStyle(e){this._fireChange("attributes",this);for(const t of pa(e))this._styles.remove(t)}_setCustomProperty(e,t){this._customProperties.set(e,t)}_removeCustomProperty(e){return this._customProperties.delete(e)}constructor(e,t,i,n){if(super(e),this._unsafeAttributesToRender=[],this._customProperties=new Map,this.name=t,this._attrs=function(e){const t=Ca(e);for(const[e,i]of t)null===i?t.delete(e):"string"!=typeof i&&t.set(e,String(i));return t}(i),this._children=[],n&&this._insertChild(0,n),this._classes=new Set,this._attrs.has("class")){const e=this._attrs.get("class");ml(this._classes,e),this._attrs.delete("class")}this._styles=new ll(this.document.stylesProcessor),this._attrs.has("style")&&(this._styles.setTo(this._attrs.get("style")),this._attrs.delete("style"))}};function ml(e,t){const i=t.split(/\s+/);e.clear(),i.forEach((t=>e.add(t)))}ul.prototype.is=function(e,t){return t?t===this.name&&("element"===e||"view:element"===e):"element"===e||"view:element"===e||"node"===e||"view:node"===e};class gl extends ul{constructor(e,t,i,n){super(e,t,i,n),this.getFillerOffset=fl}}function fl(){const e=[...this.getChildren()],t=e[this.childCount-1];if(t&&t.is("element","br"))return this.childCount;for(const t of e)if(!t.is("uiElement"))return null;return this.childCount}gl.prototype.is=function(e,t){return t?t===this.name&&("containerElement"===e||"view:containerElement"===e||"element"===e||"view:element"===e):"containerElement"===e||"view:containerElement"===e||"element"===e||"view:element"===e||"node"===e||"view:node"===e};class pl extends(Yo(gl)){destroy(){this.stopListening()}constructor(e,t,i,n){super(e,t,i,n),this.set("isReadOnly",!1),this.set("isFocused",!1),this.set("placeholder",void 0),this.bind("isReadOnly").to(e),this.bind("isFocused").to(e,"isFocused",(t=>t&&e.selection.editableElement==this)),this.listenTo(e.selection,"change",(()=>{this.isFocused=e.isFocused&&e.selection.editableElement==this}))}}pl.prototype.is=function(e,t){return t?t===this.name&&("editableElement"===e||"view:editableElement"===e||"containerElement"===e||"view:containerElement"===e||"element"===e||"view:element"===e):"editableElement"===e||"view:editableElement"===e||"containerElement"===e||"view:containerElement"===e||"element"===e||"view:element"===e||"node"===e||"view:node"===e};const bl=Symbol("rootName");class wl extends pl{get rootName(){return this.getCustomProperty(bl)}set rootName(e){this._setCustomProperty(bl,e)}set _name(e){this.name=e}constructor(e,t){super(e,t),this.rootName="main"}}wl.prototype.is=function(e,t){return t?t===this.name&&("rootElement"===e||"view:rootElement"===e||"editableElement"===e||"view:editableElement"===e||"containerElement"===e||"view:containerElement"===e||"element"===e||"view:element"===e):"rootElement"===e||"view:rootElement"===e||"editableElement"===e||"view:editableElement"===e||"containerElement"===e||"view:containerElement"===e||"element"===e||"view:element"===e||"node"===e||"view:node"===e};let vl=class{[Symbol.iterator](){return this}get position(){return this._position}skip(e){let t,i;do{i=this.position,t=this.next()}while(!t.done&&e(t.value));t.done||(this._position=i)}next(){return"forward"==this.direction?this._next():this._previous()}_next(){let e=this.position.clone();const t=this.position,i=e.parent;if(null===i.parent&&e.offset===i.childCount)return{done:!0,value:void 0};if(i===this._boundaryEndParent&&e.offset==this.boundaries.end.offset)return{done:!0,value:void 0};let n;if(i instanceof nl){if(e.isAtEnd)return this._position=_l._createAfter(i),this._next();n=i.data[e.offset]}else n=i.getChild(e.offset);if(n instanceof ul){if(this.shallow){if(this.boundaries&&this.boundaries.end.isBefore(e))return{done:!0,value:void 0};e.offset++}else e=new _l(n,0);return this._position=e,this._formatReturnValue("elementStart",n,t,e,1)}if(n instanceof nl){if(this.singleCharacters)return e=new _l(n,0),this._position=e,this._next();let i,s=n.data.length;return n==this._boundaryEndParent?(s=this.boundaries.end.offset,i=new sl(n,0,s),e=_l._createAfter(i)):(i=new sl(n,0,n.data.length),e.offset++),this._position=e,this._formatReturnValue("text",i,t,e,s)}if("string"==typeof n){let n;if(this.singleCharacters)n=1;else{n=(i===this._boundaryEndParent?this.boundaries.end.offset:i.data.length)-e.offset}const s=new sl(i,e.offset,n);return e.offset+=n,this._position=e,this._formatReturnValue("text",s,t,e,n)}return e=_l._createAfter(i),this._position=e,this.ignoreElementEnd?this._next():this._formatReturnValue("elementEnd",i,t,e)}_previous(){let e=this.position.clone();const t=this.position,i=e.parent;if(null===i.parent&&0===e.offset)return{done:!0,value:void 0};if(i==this._boundaryStartParent&&e.offset==this.boundaries.start.offset)return{done:!0,value:void 0};let n;if(i instanceof nl){if(e.isAtStart)return this._position=_l._createBefore(i),this._previous();n=i.data[e.offset-1]}else n=i.getChild(e.offset-1);if(n instanceof ul)return this.shallow?(e.offset--,this._position=e,this._formatReturnValue("elementStart",n,t,e,1)):(e=new _l(n,n.childCount),this._position=e,this.ignoreElementEnd?this._previous():this._formatReturnValue("elementEnd",n,t,e));if(n instanceof nl){if(this.singleCharacters)return e=new _l(n,n.data.length),this._position=e,this._previous();let i,s=n.data.length;if(n==this._boundaryStartParent){const t=this.boundaries.start.offset;i=new sl(n,t,n.data.length-t),s=i.data.length,e=_l._createBefore(i)}else i=new sl(n,0,n.data.length),e.offset--;return this._position=e,this._formatReturnValue("text",i,t,e,s)}if("string"==typeof n){let n;if(this.singleCharacters)n=1;else{const t=i===this._boundaryStartParent?this.boundaries.start.offset:0;n=e.offset-t}e.offset-=n;const s=new sl(i,e.offset,n);return this._position=e,this._formatReturnValue("text",s,t,e,n)}return e=_l._createBefore(i),this._position=e,this._formatReturnValue("elementStart",i,t,e,1)}_formatReturnValue(e,t,i,n,s){return t instanceof sl&&(t.offsetInText+t.data.length==t.textNode.data.length&&("forward"!=this.direction||this.boundaries&&this.boundaries.end.isEqual(this.position)?i=_l._createAfter(t.textNode):(n=_l._createAfter(t.textNode),this._position=n)),0===t.offsetInText&&("backward"!=this.direction||this.boundaries&&this.boundaries.start.isEqual(this.position)?i=_l._createBefore(t.textNode):(n=_l._createBefore(t.textNode),this._position=n))),{done:!1,value:{type:e,item:t,previousPosition:i,nextPosition:n,length:s}}}constructor(e={}){if(!e.boundaries&&!e.startPosition)throw new p("view-tree-walker-no-start-position",null);if(e.direction&&"forward"!=e.direction&&"backward"!=e.direction)throw new p("view-tree-walker-unknown-direction",e.startPosition,{direction:e.direction});this.boundaries=e.boundaries||null,e.startPosition?this._position=_l._createAt(e.startPosition):this._position=_l._createAt(e.boundaries["backward"==e.direction?"end":"start"]),this.direction=e.direction||"forward",this.singleCharacters=!!e.singleCharacters,this.shallow=!!e.shallow,this.ignoreElementEnd=!!e.ignoreElementEnd,this._boundaryStartParent=this.boundaries?this.boundaries.start.parent:null,this._boundaryEndParent=this.boundaries?this.boundaries.end.parent:null}},_l=class e extends tl{get nodeAfter(){return this.parent.is("$text")?null:this.parent.getChild(this.offset)||null}get nodeBefore(){return this.parent.is("$text")?null:this.parent.getChild(this.offset-1)||null}get isAtStart(){return 0===this.offset}get isAtEnd(){const e=this.parent.is("$text")?this.parent.data.length:this.parent.childCount;return this.offset===e}get root(){return this.parent.root}get editableElement(){let e=this.parent;for(;!(e instanceof pl);){if(!e.parent)return null;e=e.parent}return e}getShiftedBy(t){const i=e._createAt(this),n=i.offset+t;return i.offset=n<0?0:n,i}getLastMatchingPosition(e,t={}){t.startPosition=this;const i=new vl(t);return i.skip(e),i.position}getAncestors(){return this.parent.is("documentFragment")?[this.parent]:this.parent.getAncestors({includeSelf:!0})}getCommonAncestor(e){const t=this.getAncestors(),i=e.getAncestors();let n=0;for(;t[n]==i[n]&&t[n];)n++;return 0===n?null:t[n-1]}isEqual(e){return this.parent==e.parent&&this.offset==e.offset}isBefore(e){return"before"==this.compareWith(e)}isAfter(e){return"after"==this.compareWith(e)}compareWith(e){if(this.root!==e.root)return"different";if(this.isEqual(e))return"same";const t=this.parent.is("node")?this.parent.getPath():[],i=e.parent.is("node")?e.parent.getPath():[];t.push(this.offset),i.push(e.offset);const n=ar(t,i);switch(n){case"prefix":return"before";case"extension":return"after";default:return t[n]<i[n]?"before":"after"}}getWalker(e={}){return e.startPosition=this,new vl(e)}clone(){return new e(this.parent,this.offset)}static _createAt(t,i){if(t instanceof e)return new this(t.parent,t.offset);{const n=t;if("end"==i)i=n.is("$text")?n.data.length:n.childCount;else{if("before"==i)return this._createBefore(n);if("after"==i)return this._createAfter(n);if(0!==i&&!i)throw new p("view-createpositionat-offset-required",n)}return new e(n,i)}}static _createAfter(t){if(t.is("$textProxy"))return new e(t.textNode,t.offsetInText+t.data.length);if(!t.parent)throw new p("view-position-after-root",t,{root:t});return new e(t.parent,t.index+1)}static _createBefore(t){if(t.is("$textProxy"))return new e(t.textNode,t.offsetInText);if(!t.parent)throw new p("view-position-before-root",t,{root:t});return new e(t.parent,t.index)}constructor(e,t){super(),this.parent=e,this.offset=t}};_l.prototype.is=function(e){return"position"===e||"view:position"===e};let yl=class e extends tl{*[Symbol.iterator](){yield*new vl({boundaries:this,ignoreElementEnd:!0})}get isCollapsed(){return this.start.isEqual(this.end)}get isFlat(){return this.start.parent===this.end.parent}get root(){return this.start.root}getEnlarged(){let t=this.start.getLastMatchingPosition(kl,{direction:"backward"}),i=this.end.getLastMatchingPosition(kl);return t.parent.is("$text")&&t.isAtStart&&(t=_l._createBefore(t.parent)),i.parent.is("$text")&&i.isAtEnd&&(i=_l._createAfter(i.parent)),new e(t,i)}getTrimmed(){let t=this.start.getLastMatchingPosition(kl);if(t.isAfter(this.end)||t.isEqual(this.end))return new e(t,t);let i=this.end.getLastMatchingPosition(kl,{direction:"backward"});const n=t.nodeAfter,s=i.nodeBefore;return n&&n.is("$text")&&(t=new _l(n,0)),s&&s.is("$text")&&(i=new _l(s,s.data.length)),new e(t,i)}isEqual(e){return this==e||this.start.isEqual(e.start)&&this.end.isEqual(e.end)}containsPosition(e){return e.isAfter(this.start)&&e.isBefore(this.end)}containsRange(e,t=!1){e.isCollapsed&&(t=!1);const i=this.containsPosition(e.start)||t&&this.start.isEqual(e.start),n=this.containsPosition(e.end)||t&&this.end.isEqual(e.end);return i&&n}getDifference(t){const i=[];return this.isIntersecting(t)?(this.containsPosition(t.start)&&i.push(new e(this.start,t.start)),this.containsPosition(t.end)&&i.push(new e(t.end,this.end))):i.push(this.clone()),i}getIntersection(t){if(this.isIntersecting(t)){let i=this.start,n=this.end;return this.containsPosition(t.start)&&(i=t.start),this.containsPosition(t.end)&&(n=t.end),new e(i,n)}return null}getWalker(e={}){return e.boundaries=this,new vl(e)}getCommonAncestor(){return this.start.getCommonAncestor(this.end)}getContainedElement(){if(this.isCollapsed)return null;let e=this.start.nodeAfter,t=this.end.nodeBefore;return this.start.parent.is("$text")&&this.start.isAtEnd&&this.start.parent.nextSibling&&(e=this.start.parent.nextSibling),this.end.parent.is("$text")&&this.end.isAtStart&&this.end.parent.previousSibling&&(t=this.end.parent.previousSibling),e&&e.is("element")&&e===t?e:null}clone(){return new e(this.start,this.end)}*getItems(e={}){e.boundaries=this,e.ignoreElementEnd=!0;const t=new vl(e);for(const e of t)yield e.item}*getPositions(e={}){e.boundaries=this;const t=new vl(e);yield t.position;for(const e of t)yield e.nextPosition}isIntersecting(e){return this.start.isBefore(e.end)&&this.end.isAfter(e.start)}static _createFromParentsAndOffsets(e,t,i,n){return new this(new _l(e,t),new _l(i,n))}static _createFromPositionAndShift(e,t){const i=e,n=e.getShiftedBy(t);return t>0?new this(i,n):new this(n,i)}static _createIn(e){return this._createFromParentsAndOffsets(e,0,e,e.childCount)}static _createOn(e){const t=e.is("$textProxy")?e.offsetSize:1;return this._createFromPositionAndShift(_l._createBefore(e),t)}constructor(e,t=null){super(),this.start=e.clone(),this.end=t?t.clone():e.clone()}};function kl(e){return!(!e.item.is("attributeElement")&&!e.item.is("uiElement"))}yl.prototype.is=function(e){return"range"===e||"view:range"===e};let Cl=class e extends(T(tl)){get isFake(){return this._isFake}get fakeSelectionLabel(){return this._fakeSelectionLabel}get anchor(){if(!this._ranges.length)return null;const e=this._ranges[this._ranges.length-1];return(this._lastRangeBackward?e.end:e.start).clone()}get focus(){if(!this._ranges.length)return null;const e=this._ranges[this._ranges.length-1];return(this._lastRangeBackward?e.start:e.end).clone()}get isCollapsed(){return 1===this.rangeCount&&this._ranges[0].isCollapsed}get rangeCount(){return this._ranges.length}get isBackward(){return!this.isCollapsed&&this._lastRangeBackward}get editableElement(){return this.anchor?this.anchor.editableElement:null}*getRanges(){for(const e of this._ranges)yield e.clone()}getFirstRange(){let e=null;for(const t of this._ranges)e&&!t.start.isBefore(e.start)||(e=t);return e?e.clone():null}getLastRange(){let e=null;for(const t of this._ranges)e&&!t.end.isAfter(e.end)||(e=t);return e?e.clone():null}getFirstPosition(){const e=this.getFirstRange();return e?e.start.clone():null}getLastPosition(){const e=this.getLastRange();return e?e.end.clone():null}isEqual(e){if(this.isFake!=e.isFake)return!1;if(this.isFake&&this.fakeSelectionLabel!=e.fakeSelectionLabel)return!1;if(this.rangeCount!=e.rangeCount)return!1;if(0===this.rangeCount)return!0;if(!this.anchor.isEqual(e.anchor)||!this.focus.isEqual(e.focus))return!1;for(const t of this._ranges){let i=!1;for(const n of e._ranges)if(t.isEqual(n)){i=!0;break}if(!i)return!1}return!0}isSimilar(e){if(this.isBackward!=e.isBackward)return!1;const t=rr(this.getRanges());if(t!=rr(e.getRanges()))return!1;if(0==t)return!0;for(let t of this.getRanges()){t=t.getTrimmed();let i=!1;for(let n of e.getRanges())if(n=n.getTrimmed(),t.start.isEqual(n.start)&&t.end.isEqual(n.end)){i=!0;break}if(!i)return!1}return!0}getSelectedElement(){return 1!==this.rangeCount?null:this.getFirstRange().getContainedElement()}setTo(...t){let[i,n,s]=t;if("object"==typeof n&&(s=n,n=void 0),null===i)this._setRanges([]),this._setFakeOptions(s);else if(i instanceof e||i instanceof xl)this._setRanges(i.getRanges(),i.isBackward),this._setFakeOptions({fake:i.isFake,label:i.fakeSelectionLabel});else if(i instanceof yl)this._setRanges([i],s&&s.backward),this._setFakeOptions(s);else if(i instanceof _l)this._setRanges([new yl(i)]),this._setFakeOptions(s);else if(i instanceof il){const e=!!s&&!!s.backward;let t;if(void 0===n)throw new p("view-selection-setto-required-second-parameter",this);t="in"==n?yl._createIn(i):"on"==n?yl._createOn(i):new yl(_l._createAt(i,n)),this._setRanges([t],e),this._setFakeOptions(s)}else{if(!lr(i))throw new p("view-selection-setto-not-selectable",this);this._setRanges(i,s&&s.backward),this._setFakeOptions(s)}this.fire("change")}setFocus(e,t){if(null===this.anchor)throw new p("view-selection-setfocus-no-ranges",this);const i=_l._createAt(e,t);if("same"==i.compareWith(this.focus))return;const n=this.anchor;this._ranges.pop(),"before"==i.compareWith(n)?this._addRange(new yl(i,n),!0):this._addRange(new yl(n,i)),this.fire("change")}_setRanges(e,t=!1){e=Array.from(e),this._ranges=[];for(const t of e)this._addRange(t);this._lastRangeBackward=!!t}_setFakeOptions(e={}){this._isFake=!!e.fake,this._fakeSelectionLabel=e.fake&&e.label||""}_addRange(e,t=!1){if(!(e instanceof yl))throw new p("view-selection-add-range-not-range",this);this._pushRange(e),this._lastRangeBackward=!!t}_pushRange(e){for(const t of this._ranges)if(e.isIntersecting(t))throw new p("view-selection-range-intersects",this,{addedRange:e,intersectingRange:t});this._ranges.push(new yl(e.start,e.end))}constructor(...e){super(),this._ranges=[],this._lastRangeBackward=!1,this._isFake=!1,this._fakeSelectionLabel="",e.length&&this.setTo(...e)}};Cl.prototype.is=function(e){return"selection"===e||"view:selection"===e};let xl=class extends(T(tl)){get isFake(){return this._selection.isFake}get fakeSelectionLabel(){return this._selection.fakeSelectionLabel}get anchor(){return this._selection.anchor}get focus(){return this._selection.focus}get isCollapsed(){return this._selection.isCollapsed}get rangeCount(){return this._selection.rangeCount}get isBackward(){return this._selection.isBackward}get editableElement(){return this._selection.editableElement}get _ranges(){return this._selection._ranges}*getRanges(){yield*this._selection.getRanges()}getFirstRange(){return this._selection.getFirstRange()}getLastRange(){return this._selection.getLastRange()}getFirstPosition(){return this._selection.getFirstPosition()}getLastPosition(){return this._selection.getLastPosition()}getSelectedElement(){return this._selection.getSelectedElement()}isEqual(e){return this._selection.isEqual(e)}isSimilar(e){return this._selection.isSimilar(e)}_setTo(...e){this._selection.setTo(...e)}_setFocus(e,t){this._selection.setFocus(e,t)}constructor(...e){super(),this._selection=new Cl,this._selection.delegate("change").to(this),e.length&&this._selection.setTo(...e)}};xl.prototype.is=function(e){return"selection"===e||"documentSelection"==e||"view:selection"==e||"view:documentSelection"==e};class Al extends d{get eventPhase(){return this._eventPhase}get currentTarget(){return this._currentTarget}constructor(e,t,i){super(e,t),this.startRange=i,this._eventPhase="none",this._currentTarget=null}}const El=Symbol("bubbling contexts");function Tl(e){return class extends e{fire(e,...t){try{const i=e instanceof d?e:new d(this,e),n=Vl(this);if(!n.size)return;if(Sl(i,"capturing",this),Il(n,"$capture",i,...t))return i.return;const s=i.startRange||this.selection.getFirstRange(),o=s?s.getContainedElement():null,r=!!o&&Boolean(Pl(n,o));let a=o||function(e){if(!e)return null;const t=e.start.parent,i=e.end.parent,n=t.getPath(),s=i.getPath();return n.length>s.length?t:i}(s);if(Sl(i,"atTarget",a),!r){if(Il(n,"$text",i,...t))return i.return;Sl(i,"bubbling",a)}for(;a;){if(a.is("rootElement")){if(Il(n,"$root",i,...t))return i.return}else if(a.is("element")&&Il(n,a.name,i,...t))return i.return;if(Il(n,a,i,...t))return i.return;a=a.parent,Sl(i,"bubbling",a)}return Sl(i,"bubbling",this),Il(n,"$document",i,...t),i.return}catch(e){p.rethrowUnexpectedError(e,this)}}_addEventListener(e,t,i){const n=pa(i.context||"$document"),s=Vl(this);for(const o of n){let n=s.get(o);n||(n=new(T()),s.set(o,n)),this.listenTo(n,e,t,i)}}_removeEventListener(e,t){const i=Vl(this);for(const n of i.values())this.stopListening(n,e,t)}}}{const e=Tl(Object);["fire","_addEventListener","_removeEventListener"].forEach((t=>{Tl[t]=e.prototype[t]}))}function Sl(e,t,i){e instanceof Al&&(e._eventPhase=t,e._currentTarget=i)}function Il(e,t,i,...n){const s="string"==typeof t?e.get(t):Pl(e,t);return!!s&&(s.fire(i,...n),i.stop.called)}function Pl(e,t){for(const[i,n]of e)if("function"==typeof i&&i(t))return n;return null}function Vl(e){return e[El]||(e[El]=new Map),e[El]}let Rl=class extends(Tl(Yo())){getRoot(e="main"){return this.roots.get(e)}registerPostFixer(e){this._postFixers.add(e)}destroy(){this.roots.forEach((e=>e.destroy())),this.stopListening()}_callPostFixers(e){let t=!1;do{for(const i of this._postFixers)if(t=i(e),t)break}while(t)}constructor(e){super(),this._postFixers=new Set,this.selection=new xl,this.roots=new va({idProperty:"rootName"}),this.stylesProcessor=e,this.set("isReadOnly",!1),this.set("isFocused",!1),this.set("isSelecting",!1),this.set("isComposing",!1)}};class Bl extends ul{get priority(){return this._priority}get id(){return this._id}getElementsWithSameId(){if(null===this.id)throw new p("attribute-element-get-elements-with-same-id-no-id",this);return new Set(this._clonesGroup)}isSimilar(e){return null!==this.id||null!==e.id?this.id===e.id:super.isSimilar(e)&&this.priority==e.priority}_clone(e=!1){const t=super._clone(e);return t._priority=this._priority,t._id=this._id,t}constructor(e,t,i,n){super(e,t,i,n),this._priority=10,this._id=null,this._clonesGroup=null,this.getFillerOffset=Ol}}function Ol(){if(Ml(this))return null;let e=this.parent;for(;e&&e.is("attributeElement");){if(Ml(e)>1)return null;e=e.parent}return!e||Ml(e)>1?null:this.childCount}function Ml(e){return Array.from(e.getChildren()).filter((e=>!e.is("uiElement"))).length}Bl.DEFAULT_PRIORITY=10,Bl.prototype.is=function(e,t){return t?t===this.name&&("attributeElement"===e||"view:attributeElement"===e||"element"===e||"view:element"===e):"attributeElement"===e||"view:attributeElement"===e||"element"===e||"view:element"===e||"node"===e||"view:node"===e};class Ll extends ul{_insertChild(e,t){if(t&&(t instanceof il||Array.from(t).length>0))throw new p("view-emptyelement-cannot-add",[this,t]);return 0}constructor(e,t,i,n){super(e,t,i,n),this.getFillerOffset=Nl}}function Nl(){return null}Ll.prototype.is=function(e,t){return t?t===this.name&&("emptyElement"===e||"view:emptyElement"===e||"element"===e||"view:element"===e):"emptyElement"===e||"view:emptyElement"===e||"element"===e||"view:element"===e||"node"===e||"view:node"===e};class Fl extends ul{_insertChild(e,t){if(t&&(t instanceof il||Array.from(t).length>0))throw new p("view-uielement-cannot-add",[this,t]);return 0}render(e,t){return this.toDomElement(e)}toDomElement(e){const t=e.createElement(this.name);for(const e of this.getAttributeKeys())t.setAttribute(e,this.getAttribute(e));return t}constructor(e,t,i,n){super(e,t,i,n),this.getFillerOffset=zl}}function Dl(e){e.document.on("arrowKey",((t,i)=>function(e,t,i){if(t.keyCode==ra.arrowright){const e=t.domTarget.ownerDocument.defaultView.getSelection(),n=1==e.rangeCount&&e.getRangeAt(0).collapsed;if(n||t.shiftKey){const t=e.focusNode,s=e.focusOffset,o=i.domPositionToView(t,s);if(null===o)return;let r=!1;const a=o.getLastMatchingPosition((e=>(e.item.is("uiElement")&&(r=!0),!(!e.item.is("uiElement")&&!e.item.is("attributeElement")))));if(r){const t=i.viewPositionToDom(a);n?e.collapse(t.parent,t.offset):e.extend(t.parent,t.offset)}}}}(0,i,e.domConverter)),{priority:"low"})}function zl(){return null}Fl.prototype.is=function(e,t){return t?t===this.name&&("uiElement"===e||"view:uiElement"===e||"element"===e||"view:element"===e):"uiElement"===e||"view:uiElement"===e||"element"===e||"view:element"===e||"node"===e||"view:node"===e};class Hl extends ul{_insertChild(e,t){if(t&&(t instanceof il||Array.from(t).length>0))throw new p("view-rawelement-cannot-add",[this,t]);return 0}render(e,t){}constructor(e,t,i,n){super(e,t,i,n),this.getFillerOffset=$l}}function $l(){return null}Hl.prototype.is=function(e,t){return t?t===this.name&&("rawElement"===e||"view:rawElement"===e||"element"===e||"view:element"===e):"rawElement"===e||"view:rawElement"===e||e===this.name||e==="view:"+this.name||"element"===e||"view:element"===e||"node"===e||"view:node"===e};let Ul=class extends(T(tl)){[Symbol.iterator](){return this._children[Symbol.iterator]()}get childCount(){return this._children.length}get isEmpty(){return 0===this.childCount}get root(){return this}get parent(){return null}get name(){}get getFillerOffset(){}getCustomProperty(e){return this._customProperties.get(e)}*getCustomProperties(){yield*this._customProperties.entries()}_appendChild(e){return this._insertChild(this.childCount,e)}getChild(e){return this._children[e]}getChildIndex(e){return this._children.indexOf(e)}getChildren(){return this._children[Symbol.iterator]()}_insertChild(e,t){this._fireChange("children",this);let i=0;const n=function(e,t){if("string"==typeof t)return[new nl(e,t)];lr(t)||(t=[t]);return Array.from(t).map((t=>"string"==typeof t?new nl(e,t):t instanceof sl?new nl(e,t.data):t))}(this.document,t);for(const t of n)null!==t.parent&&t._remove(),t.parent=this,this._children.splice(e,0,t),e++,i++;return i}_removeChildren(e,t=1){this._fireChange("children",this);for(let i=e;i<e+t;i++)this._children[i].parent=null;return this._children.splice(e,t)}_fireChange(e,t){this.fire("change:"+e,t)}_setCustomProperty(e,t){this._customProperties.set(e,t)}_removeCustomProperty(e){return this._customProperties.delete(e)}constructor(e,t){super(),this._children=[],this._customProperties=new Map,this.document=e,t&&this._insertChild(0,t)}};Ul.prototype.is=function(e){return"documentFragment"===e||"view:documentFragment"===e};class Wl{setSelection(...e){this.document.selection._setTo(...e)}setSelectionFocus(e,t){this.document.selection._setFocus(e,t)}createDocumentFragment(e){return new Ul(this.document,e)}createText(e){return new nl(this.document,e)}createAttributeElement(e,t,i={}){const n=new Bl(this.document,e,t);return"number"==typeof i.priority&&(n._priority=i.priority),i.id&&(n._id=i.id),i.renderUnsafeAttributes&&n._unsafeAttributesToRender.push(...i.renderUnsafeAttributes),n}createContainerElement(e,t,i={},n={}){let s=null;oi(i)?n=i:s=i;const o=new gl(this.document,e,t,s);return n.renderUnsafeAttributes&&o._unsafeAttributesToRender.push(...n.renderUnsafeAttributes),o}createEditableElement(e,t,i={}){const n=new pl(this.document,e,t);return i.renderUnsafeAttributes&&n._unsafeAttributesToRender.push(...i.renderUnsafeAttributes),n}createEmptyElement(e,t,i={}){const n=new Ll(this.document,e,t);return i.renderUnsafeAttributes&&n._unsafeAttributesToRender.push(...i.renderUnsafeAttributes),n}createUIElement(e,t,i){const n=new Fl(this.document,e,t);return i&&(n.render=i),n}createRawElement(e,t,i,n={}){const s=new Hl(this.document,e,t);return i&&(s.render=i),n.renderUnsafeAttributes&&s._unsafeAttributesToRender.push(...n.renderUnsafeAttributes),s}setAttribute(e,t,i){i._setAttribute(e,t)}removeAttribute(e,t){t._removeAttribute(e)}addClass(e,t){t._addClass(e)}removeClass(e,t){t._removeClass(e)}setStyle(e,t,i){oi(e)&&void 0===i?t._setStyle(e):i._setStyle(e,t)}removeStyle(e,t){t._removeStyle(e)}setCustomProperty(e,t,i){i._setCustomProperty(e,t)}removeCustomProperty(e,t){return t._removeCustomProperty(e)}breakAttributes(e){return e instanceof _l?this._breakAttributes(e):this._breakAttributesRange(e)}breakContainer(e){const t=e.parent;if(!t.is("containerElement"))throw new p("view-writer-break-non-container-element",this.document);if(!t.parent)throw new p("view-writer-break-root",this.document);if(e.isAtStart)return _l._createBefore(t);if(!e.isAtEnd){const i=t._clone(!1);this.insert(_l._createAfter(t),i);const n=new yl(e,_l._createAt(t,"end")),s=new _l(i,0);this.move(n,s)}return _l._createAfter(t)}mergeAttributes(e){const t=e.offset,i=e.parent;if(i.is("$text"))return e;if(i.is("attributeElement")&&0===i.childCount){const e=i.parent,t=i.index;return i._remove(),this._removeFromClonedElementsGroup(i),this.mergeAttributes(new _l(e,t))}const n=i.getChild(t-1),s=i.getChild(t);if(!n||!s)return e;if(n.is("$text")&&s.is("$text"))return Zl(n,s);if(n.is("attributeElement")&&s.is("attributeElement")&&n.isSimilar(s)){const e=n.childCount;return n._appendChild(s.getChildren()),s._remove(),this._removeFromClonedElementsGroup(s),this.mergeAttributes(new _l(n,e))}return e}mergeContainers(e){const t=e.nodeBefore,i=e.nodeAfter;if(!(t&&i&&t.is("containerElement")&&i.is("containerElement")))throw new p("view-writer-merge-containers-invalid-position",this.document);const n=t.getChild(t.childCount-1),s=n instanceof nl?_l._createAt(n,"end"):_l._createAt(t,"end");return this.move(yl._createIn(i),_l._createAt(t,"end")),this.remove(yl._createOn(i)),s}insert(e,t){Ql(t=lr(t)?[...t]:[t],this.document);const i=t.reduce(((e,t)=>{const i=e[e.length-1],n=!t.is("uiElement");return i&&i.breakAttributes==n?i.nodes.push(t):e.push({breakAttributes:n,nodes:[t]}),e}),[]);let n=null,s=e;for(const{nodes:e,breakAttributes:t}of i){const i=this._insertNodes(s,e,t);n||(n=i.start),s=i.end}return n?new yl(n,s):new yl(e)}remove(e){const t=e instanceof yl?e:yl._createOn(e);if(Xl(t,this.document),t.isCollapsed)return new Ul(this.document);const{start:i,end:n}=this._breakAttributesRange(t,!0),s=i.parent,o=n.offset-i.offset,r=s._removeChildren(i.offset,o);for(const e of r)this._removeFromClonedElementsGroup(e);const a=this.mergeAttributes(i);return t.start=a,t.end=a.clone(),new Ul(this.document,r)}clear(e,t){Xl(e,this.document);const i=e.getWalker({direction:"backward",ignoreElementEnd:!0});for(const n of i){const i=n.item;let s;if(i.is("element")&&t.isSimilar(i))s=yl._createOn(i);else if(!n.nextPosition.isAfter(e.start)&&i.is("$textProxy")){const e=i.getAncestors().find((e=>e.is("element")&&t.isSimilar(e)));e&&(s=yl._createIn(e))}s&&(s.end.isAfter(e.end)&&(s.end=e.end),s.start.isBefore(e.start)&&(s.start=e.start),this.remove(s))}}move(e,t){let i;if(t.isAfter(e.end)){const n=(t=this._breakAttributes(t,!0)).parent,s=n.childCount;e=this._breakAttributesRange(e,!0),i=this.remove(e),t.offset+=n.childCount-s}else i=this.remove(e);return this.insert(t,i)}wrap(e,t){if(!(t instanceof Bl))throw new p("view-writer-wrap-invalid-attribute",this.document);if(Xl(e,this.document),e.isCollapsed){let i=e.start;i.parent.is("element")&&!function(e){return Array.from(e.getChildren()).some((e=>!e.is("uiElement")))}(i.parent)&&(i=i.getLastMatchingPosition((e=>e.item.is("uiElement")))),i=this._wrapPosition(i,t);const n=this.document.selection;return n.isCollapsed&&n.getFirstPosition().isEqual(e.start)&&this.setSelection(i),new yl(i)}return this._wrapRange(e,t)}unwrap(e,t){if(!(t instanceof Bl))throw new p("view-writer-unwrap-invalid-attribute",this.document);if(Xl(e,this.document),e.isCollapsed)return e;const{start:i,end:n}=this._breakAttributesRange(e,!0),s=i.parent,o=this._unwrapChildren(s,i.offset,n.offset,t),r=this.mergeAttributes(o.start);r.isEqual(o.start)||o.end.offset--;const a=this.mergeAttributes(o.end);return new yl(r,a)}rename(e,t){const i=new gl(this.document,e,t.getAttributes());return this.insert(_l._createAfter(t),i),this.move(yl._createIn(t),_l._createAt(i,0)),this.remove(yl._createOn(t)),i}clearClonedElementsGroup(e){this._cloneGroups.delete(e)}createPositionAt(e,t){return _l._createAt(e,t)}createPositionAfter(e){return _l._createAfter(e)}createPositionBefore(e){return _l._createBefore(e)}createRange(e,t){return new yl(e,t)}createRangeOn(e){return yl._createOn(e)}createRangeIn(e){return yl._createIn(e)}createSelection(...e){return new Cl(...e)}createSlot(e="children"){if(!this._slotFactory)throw new p("view-writer-invalid-create-slot-context",this.document);return this._slotFactory(this,e)}_registerSlotFactory(e){this._slotFactory=e}_clearSlotFactory(){this._slotFactory=null}_insertNodes(e,t,i){let n,s;if(n=i?jl(e):e.parent.is("$text")?e.parent.parent:e.parent,!n)throw new p("view-writer-invalid-position-container",this.document);s=i?this._breakAttributes(e,!0):e.parent.is("$text")?Kl(e):e;const o=n._insertChild(s.offset,t);for(const e of t)this._addToClonedElementsGroup(e);const r=s.getShiftedBy(o),a=this.mergeAttributes(s);a.isEqual(s)||r.offset--;const l=this.mergeAttributes(r);return new yl(a,l)}_wrapChildren(e,t,i,n){let s=t;const o=[];for(;s<i;){const t=e.getChild(s),i=t.is("$text"),r=t.is("attributeElement");if(r&&this._wrapAttributeElement(n,t))o.push(new _l(e,s));else if(i||!r||ql(n,t)){const i=n._clone();t._remove(),i._appendChild(t),e._insertChild(s,i),this._addToClonedElementsGroup(i),o.push(new _l(e,s))}else this._wrapChildren(t,0,t.childCount,n);s++}let r=0;for(const e of o){if(e.offset-=r,e.offset==t)continue;this.mergeAttributes(e).isEqual(e)||(r++,i--)}return yl._createFromParentsAndOffsets(e,t,e,i)}_unwrapChildren(e,t,i,n){let s=t;const o=[];for(;s<i;){const t=e.getChild(s);if(t.is("attributeElement"))if(t.isSimilar(n)){const n=t.getChildren(),r=t.childCount;t._remove(),e._insertChild(s,n),this._removeFromClonedElementsGroup(t),o.push(new _l(e,s),new _l(e,s+r)),s+=r,i+=r-1}else this._unwrapAttributeElement(n,t)?(o.push(new _l(e,s),new _l(e,s+1)),s++):(this._unwrapChildren(t,0,t.childCount,n),s++);else s++}let r=0;for(const e of o){if(e.offset-=r,e.offset==t||e.offset==i)continue;this.mergeAttributes(e).isEqual(e)||(r++,i--)}return yl._createFromParentsAndOffsets(e,t,e,i)}_wrapRange(e,t){const{start:i,end:n}=this._breakAttributesRange(e,!0),s=i.parent,o=this._wrapChildren(s,i.offset,n.offset,t),r=this.mergeAttributes(o.start);r.isEqual(o.start)||o.end.offset--;const a=this.mergeAttributes(o.end);return new yl(r,a)}_wrapPosition(e,t){if(t.isSimilar(e.parent))return Gl(e.clone());e.parent.is("$text")&&(e=Kl(e));const i=this.createAttributeElement("_wrapPosition-fake-element");i._priority=Number.POSITIVE_INFINITY,i.isSimilar=()=>!1,e.parent._insertChild(e.offset,i);const n=new yl(e,e.getShiftedBy(1));this.wrap(n,t);const s=new _l(i.parent,i.index);i._remove();const o=s.nodeBefore,r=s.nodeAfter;return o instanceof nl&&r instanceof nl?Zl(o,r):Gl(s)}_wrapAttributeElement(e,t){if(!ec(e,t))return!1;if(e.name!==t.name||e.priority!==t.priority)return!1;for(const i of e.getAttributeKeys())if("class"!==i&&"style"!==i&&t.hasAttribute(i)&&t.getAttribute(i)!==e.getAttribute(i))return!1;for(const i of e.getStyleNames())if(t.hasStyle(i)&&t.getStyle(i)!==e.getStyle(i))return!1;for(const i of e.getAttributeKeys())"class"!==i&&"style"!==i&&(t.hasAttribute(i)||this.setAttribute(i,e.getAttribute(i),t));for(const i of e.getStyleNames())t.hasStyle(i)||this.setStyle(i,e.getStyle(i),t);for(const i of e.getClassNames())t.hasClass(i)||this.addClass(i,t);return!0}_unwrapAttributeElement(e,t){if(!ec(e,t))return!1;if(e.name!==t.name||e.priority!==t.priority)return!1;for(const i of e.getAttributeKeys())if("class"!==i&&"style"!==i&&(!t.hasAttribute(i)||t.getAttribute(i)!==e.getAttribute(i)))return!1;if(!t.hasClass(...e.getClassNames()))return!1;for(const i of e.getStyleNames())if(!t.hasStyle(i)||t.getStyle(i)!==e.getStyle(i))return!1;for(const i of e.getAttributeKeys())"class"!==i&&"style"!==i&&this.removeAttribute(i,t);return this.removeClass(Array.from(e.getClassNames()),t),this.removeStyle(Array.from(e.getStyleNames()),t),!0}_breakAttributesRange(e,t=!1){const i=e.start,n=e.end;if(Xl(e,this.document),e.isCollapsed){const i=this._breakAttributes(e.start,t);return new yl(i,i)}const s=this._breakAttributes(n,t),o=s.parent.childCount,r=this._breakAttributes(i,t);return s.offset+=s.parent.childCount-o,new yl(r,s)}_breakAttributes(e,t=!1){const i=e.offset,n=e.parent;if(e.parent.is("emptyElement"))throw new p("view-writer-cannot-break-empty-element",this.document);if(e.parent.is("uiElement"))throw new p("view-writer-cannot-break-ui-element",this.document);if(e.parent.is("rawElement"))throw new p("view-writer-cannot-break-raw-element",this.document);if(!t&&n.is("$text")&&Yl(n.parent))return e.clone();if(Yl(n))return e.clone();if(n.is("$text"))return this._breakAttributes(Kl(e),t);if(i==n.childCount){const e=new _l(n.parent,n.index+1);return this._breakAttributes(e,t)}if(0===i){const e=new _l(n.parent,n.index);return this._breakAttributes(e,t)}{const e=n.index+1,s=n._clone();n.parent._insertChild(e,s),this._addToClonedElementsGroup(s);const o=n.childCount-i,r=n._removeChildren(i,o);s._appendChild(r);const a=new _l(n.parent,e);return this._breakAttributes(a,t)}}_addToClonedElementsGroup(e){if(!e.root.is("rootElement"))return;if(e.is("element"))for(const t of e.getChildren())this._addToClonedElementsGroup(t);const t=e.id;if(!t)return;let i=this._cloneGroups.get(t);i||(i=new Set,this._cloneGroups.set(t,i)),i.add(e),e._clonesGroup=i}_removeFromClonedElementsGroup(e){if(e.is("element"))for(const t of e.getChildren())this._removeFromClonedElementsGroup(t);const t=e.id;if(!t)return;const i=this._cloneGroups.get(t);i&&i.delete(e)}constructor(e){this._cloneGroups=new Map,this._slotFactory=null,this.document=e}}function jl(e){let t=e.parent;for(;!Yl(t);){if(!t)return;t=t.parent}return t}function ql(e,t){return e.priority<t.priority||!(e.priority>t.priority)&&e.getIdentity()<t.getIdentity()}function Gl(e){const t=e.nodeBefore;if(t&&t.is("$text"))return new _l(t,t.data.length);const i=e.nodeAfter;return i&&i.is("$text")?new _l(i,0):e}function Kl(e){if(e.offset==e.parent.data.length)return new _l(e.parent.parent,e.parent.index+1);if(0===e.offset)return new _l(e.parent.parent,e.parent.index);const t=e.parent.data.slice(e.offset);return e.parent._data=e.parent.data.slice(0,e.offset),e.parent.parent._insertChild(e.parent.index+1,new nl(e.root.document,t)),new _l(e.parent.parent,e.parent.index+1)}function Zl(e,t){const i=e.data.length;return e._data+=t.data,t._remove(),new _l(e,i)}const Jl=[nl,Bl,gl,Ll,Hl,Fl];function Ql(e,t){for(const i of e){if(!Jl.some((e=>i instanceof e)))throw new p("view-writer-insert-invalid-node-type",t);i.is("$text")||Ql(i.getChildren(),t)}}function Yl(e){return e&&(e.is("containerElement")||e.is("documentFragment"))}function Xl(e,t){const i=jl(e.start),n=jl(e.end);if(!i||!n||i!==n)throw new p("view-writer-invalid-range-container",t)}function ec(e,t){return null===e.id&&null===t.id}const tc=e=>e.createTextNode(" "),ic=e=>{const t=e.createElement("span");return t.dataset.ckeFiller="true",t.innerText=" ",t},nc=e=>{const t=e.createElement("br");return t.dataset.ckeFiller="true",t},sc=7,oc="⁠".repeat(sc);function rc(e){return"string"==typeof e?e.substr(0,sc)===oc:Ar(e)&&e.data.substr(0,sc)===oc}function ac(e){return e.data.length==sc&&rc(e)}function lc(e){const t="string"==typeof e?e:e.data;return rc(e)?t.slice(sc):t}function cc(e,t){if(t.keyCode==ra.arrowleft){const e=t.domTarget.ownerDocument.defaultView.getSelection();if(1==e.rangeCount&&e.getRangeAt(0).collapsed){const t=e.getRangeAt(0).startContainer,i=e.getRangeAt(0).startOffset;rc(t)&&i<=sc&&e.collapse(t,0)}}}let dc=class extends(Yo()){markToSync(e,t){if("text"===e)this.domConverter.mapViewToDom(t.parent)&&this.markedTexts.add(t);else{if(!this.domConverter.mapViewToDom(t))return;if("attributes"===e)this.markedAttributes.add(t);else{if("children"!==e)throw new p("view-renderer-unknown-type",this);this.markedChildren.add(t)}}}render(){if(this.isComposing&&!i.isAndroid)return;let e=null;const t=!(i.isBlink&&!i.isAndroid)||!this.isSelecting;for(const e of this.markedChildren)this._updateChildrenMappings(e);t?(this._inlineFiller&&!this._isSelectionInInlineFiller()&&this._removeInlineFiller(),this._inlineFiller?e=this._getInlineFillerPosition():this._needsInlineFillerAtSelection()&&(e=this.selection.getFirstPosition(),this.markedChildren.add(e.parent))):this._inlineFiller&&this._inlineFiller.parentNode&&(e=this.domConverter.domPositionToView(this._inlineFiller),e&&e.parent.is("$text")&&(e=_l._createBefore(e.parent)));for(const e of this.markedAttributes)this._updateAttrs(e);for(const t of this.markedChildren)this._updateChildren(t,{inlineFillerPosition:e});for(const t of this.markedTexts)!this.markedChildren.has(t.parent)&&this.domConverter.mapViewToDom(t.parent)&&this._updateText(t,{inlineFillerPosition:e});if(t)if(e){const t=this.domConverter.viewPositionToDom(e),i=t.parent.ownerDocument;rc(t.parent)?this._inlineFiller=t.parent:this._inlineFiller=hc(i,t.parent,t.offset)}else this._inlineFiller=null;this._updateFocus(),this._updateSelection(),this.domConverter._clearTemporaryCustomProperties(),this.markedTexts.clear(),this.markedAttributes.clear(),this.markedChildren.clear()}_updateChildrenMappings(e){const t=this.domConverter.mapViewToDom(e);if(!t)return;const i=Array.from(t.childNodes),n=Array.from(this.domConverter.viewChildrenToDom(e,{withChildren:!1})),s=this._diffNodeLists(i,n),o=this._findUpdateActions(s,i,n,uc);if(-1!==o.indexOf("update")){const t={equal:0,insert:0,delete:0};for(const s of o)if("update"===s){const s=t.equal+t.insert,o=t.equal+t.delete,r=e.getChild(s);!r||r.is("uiElement")||r.is("rawElement")||this._updateElementMappings(r,i[o]),jr(n[s]),t.equal++}else t[s]++}}_updateElementMappings(e,t){this.domConverter.unbindDomElement(t),this.domConverter.bindElements(t,e),this.markedChildren.add(e),this.markedAttributes.add(e)}_getInlineFillerPosition(){const e=this.selection.getFirstPosition();return e.parent.is("$text")?_l._createBefore(e.parent):e}_isSelectionInInlineFiller(){if(1!=this.selection.rangeCount||!this.selection.isCollapsed)return!1;const e=this.selection.getFirstPosition(),t=this.domConverter.viewPositionToDom(e);return!!(t&&Ar(t.parent)&&rc(t.parent))}_removeInlineFiller(){const e=this._inlineFiller;if(!rc(e))throw new p("view-renderer-filler-was-lost",this);ac(e)?e.remove():e.data=e.data.substr(sc),this._inlineFiller=null}_needsInlineFillerAtSelection(){if(1!=this.selection.rangeCount||!this.selection.isCollapsed)return!1;const e=this.selection.getFirstPosition(),t=e.parent,n=e.offset;if(!this.domConverter.mapViewToDom(t.root))return!1;if(!t.is("element"))return!1;if(!function(e){if("false"==e.getAttribute("contenteditable"))return!1;const t=e.findAncestor((e=>e.hasAttribute("contenteditable")));return!t||"true"==t.getAttribute("contenteditable")}(t))return!1;const s=e.nodeBefore,o=e.nodeAfter;return!(s instanceof nl||o instanceof nl)&&(!!(n!==t.getFillerOffset()||s&&s.is("element","br"))&&(!i.isAndroid||!s&&!o))}_updateText(e,t){const i=this.domConverter.findCorrespondingDomText(e);let n=this.domConverter.viewToDom(e).data;const s=t.inlineFillerPosition;s&&s.parent==e.parent&&s.offset==e.index&&(n=oc+n),fc(i,n)}_updateAttrs(e){const t=this.domConverter.mapViewToDom(e);if(!t)return;const i=Array.from(t.attributes).map((e=>e.name)),n=e.getAttributeKeys();for(const i of n)this.domConverter.setDomElementAttribute(t,i,e.getAttribute(i),e);for(const n of i)e.hasAttribute(n)||this.domConverter.removeDomElementAttribute(t,n)}_updateChildren(e,t){const n=this.domConverter.mapViewToDom(e);if(!n)return;if(i.isAndroid){let e=null;for(const t of Array.from(n.childNodes)){if(e&&Ar(e)&&Ar(t)){n.normalize();break}e=t}}const s=t.inlineFillerPosition,o=n.childNodes,r=Array.from(this.domConverter.viewChildrenToDom(e,{bind:!0}));s&&s.parent===e&&hc(n.ownerDocument,r,s.offset);const a=this._diffNodeLists(o,r),l=this._findUpdateActions(a,o,r,mc);let c=0;const d=new Set;for(const e of l)"delete"===e?(d.add(o[c]),jr(o[c])):"equal"!==e&&"update"!==e||c++;c=0;for(const e of l)"insert"===e?(Fr(n,c,r[c]),c++):"update"===e?(fc(o[c],r[c].data),c++):"equal"===e&&(this._markDescendantTextToSync(this.domConverter.domToView(r[c])),c++);for(const e of d)e.parentNode||this.domConverter.unbindDomElement(e)}_diffNodeLists(e,t){return e=function(e,t){const i=Array.from(e);if(0==i.length||!t)return i;const n=i[i.length-1];n==t&&i.pop();return i}(e,this._fakeSelectionContainer),a(e,t,gc.bind(null,this.domConverter))}_findUpdateActions(e,t,i,n){if(-1===e.indexOf("insert")||-1===e.indexOf("delete"))return e;let s=[],o=[],r=[];const l={equal:0,insert:0,delete:0};for(const c of e)"insert"===c?r.push(i[l.equal+l.insert]):"delete"===c?o.push(t[l.equal+l.delete]):(s=s.concat(a(o,r,n).map((e=>"equal"===e?"update":e))),s.push("equal"),o=[],r=[]),l[c]++;return s.concat(a(o,r,n).map((e=>"equal"===e?"update":e)))}_markDescendantTextToSync(e){if(e)if(e.is("$text"))this.markedTexts.add(e);else if(e.is("element"))for(const t of e.getChildren())this._markDescendantTextToSync(t)}_updateSelection(){if(i.isBlink&&!i.isAndroid&&this.isSelecting&&!this.markedChildren.size)return;if(0===this.selection.rangeCount)return this._removeDomSelection(),void this._removeFakeSelection();const e=this.domConverter.mapViewToDom(this.selection.editableElement);this.isFocused&&e&&(this.selection.isFake?this._updateFakeSelection(e):this._fakeSelectionContainer&&this._fakeSelectionContainer.isConnected?(this._removeFakeSelection(),this._updateDomSelection(e)):this.isComposing&&i.isAndroid||this._updateDomSelection(e))}_updateFakeSelection(e){const t=e.ownerDocument;this._fakeSelectionContainer||(this._fakeSelectionContainer=function(e){const t=e.createElement("div");return t.className="ck-fake-selection-container",Object.assign(t.style,{position:"fixed",top:0,left:"-9999px",width:"42px"}),t.textContent=" ",t}(t));const i=this._fakeSelectionContainer;if(this.domConverter.bindFakeSelection(i,this.selection),!this._fakeSelectionNeedsUpdate(e))return;i.parentElement&&i.parentElement==e||e.appendChild(i),i.textContent=this.selection.fakeSelectionLabel||" ";const n=t.getSelection(),s=t.createRange();n.removeAllRanges(),s.selectNodeContents(i),n.addRange(s)}_updateDomSelection(e){const t=e.ownerDocument.defaultView.getSelection();if(!this._domSelectionNeedsUpdate(t))return;const n=this.domConverter.viewPositionToDom(this.selection.anchor),s=this.domConverter.viewPositionToDom(this.selection.focus);t.setBaseAndExtent(n.parent,n.offset,s.parent,s.offset),i.isGecko&&function(e,t){let i=e.parent,n=e.offset;Ar(i)&&ac(i)&&(n=Nr(i)+1,i=i.parentNode);if(i.nodeType!=Node.ELEMENT_NODE||n!=i.childNodes.length-1)return;const s=i.childNodes[n];s&&"BR"==s.tagName&&t.addRange(t.getRangeAt(0))}(s,t)}_domSelectionNeedsUpdate(e){if(!this.domConverter.isDomSelectionCorrect(e))return!0;const t=e&&this.domConverter.domSelectionToView(e);return(!t||!this.selection.isEqual(t))&&!(!this.selection.isCollapsed&&this.selection.isSimilar(t))}_fakeSelectionNeedsUpdate(e){const t=this._fakeSelectionContainer,i=e.ownerDocument.getSelection();return!t||t.parentElement!==e||(i.anchorNode!==t&&!t.contains(i.anchorNode)||t.textContent!==this.selection.fakeSelectionLabel)}_removeDomSelection(){for(const e of this.domDocuments){const t=e.getSelection();if(t.rangeCount){const i=e.activeElement,n=this.domConverter.mapDomToView(i);i&&n&&t.removeAllRanges()}}}_removeFakeSelection(){const e=this._fakeSelectionContainer;e&&e.remove()}_updateFocus(){if(this.isFocused){const e=this.selection.editableElement;e&&this.domConverter.focus(e)}}constructor(e,t){super(),this.domDocuments=new Set,this.markedAttributes=new Set,this.markedChildren=new Set,this.markedTexts=new Set,this._inlineFiller=null,this._fakeSelectionContainer=null,this.domConverter=e,this.selection=t,this.set("isFocused",!1),this.set("isSelecting",!1),i.isBlink&&!i.isAndroid&&this.on("change:isSelecting",(()=>{this.isSelecting||this.render()})),this.set("isComposing",!1),this.on("change:isComposing",(()=>{this.isComposing||this.render()}))}};function hc(e,t,i){const n=t instanceof Array?t:t.childNodes,s=n[i];if(Ar(s))return s.data=oc+s.data,s;{const s=e.createTextNode(oc);return Array.isArray(t)?n.splice(i,0,s):Fr(t,i,s),s}}function uc(e,t){return mr(e)&&mr(t)&&!Ar(e)&&!Ar(t)&&!Dr(e)&&!Dr(t)&&e.tagName.toLowerCase()===t.tagName.toLowerCase()}function mc(e,t){return mr(e)&&mr(t)&&Ar(e)&&Ar(t)}function gc(e,t,i){return t===i||(Ar(t)&&Ar(i)?t.data===i.data:!(!e.isBlockFiller(t)||!e.isBlockFiller(i)))}function fc(e,t){const i=e.data;if(i==t)return;const n=s(i,t);for(const t of n)"insert"===t.type?e.insertData(t.index,t.values.join("")):e.deleteData(t.index,t.howMany)}const pc=nc(_r.document),bc=tc(_r.document),wc=ic(_r.document),vc="data-ck-unsafe-attribute-",_c="data-ck-unsafe-element";class yc{bindFakeSelection(e,t){this._fakeSelectionMapping.set(e,new Cl(t))}fakeSelectionToView(e){return this._fakeSelectionMapping.get(e)}bindElements(e,t){this._domToViewMapping.set(e,t),this._viewToDomMapping.set(t,e)}unbindDomElement(e){const t=this._domToViewMapping.get(e);if(t){this._domToViewMapping.delete(e),this._viewToDomMapping.delete(t);for(const t of Array.from(e.children))this.unbindDomElement(t)}}bindDocumentFragments(e,t){this._domToViewMapping.set(e,t),this._viewToDomMapping.set(t,e)}shouldRenderAttribute(e,t,i){return"data"===this.renderingMode||!(e=e.toLowerCase()).startsWith("on")&&(("srcdoc"!==e||!t.match(/\bon\S+\s*=|javascript:|<\s*\/*script/i))&&("img"===i&&("src"===e||"srcset"===e)||("source"===i&&"srcset"===e||!t.match(/^\s*(javascript:|data:(image\/svg|text\/x?html))/i))))}setContentOf(e,t){if("data"===this.renderingMode)return void(e.innerHTML=t);const i=(new DOMParser).parseFromString(t,"text/html"),n=i.createDocumentFragment(),s=i.body.childNodes;for(;s.length>0;)n.appendChild(s[0]);const o=i.createTreeWalker(n,NodeFilter.SHOW_ELEMENT),r=[];let a;for(;a=o.nextNode();)r.push(a);for(const e of r){for(const t of e.getAttributeNames())this.setDomElementAttribute(e,t,e.getAttribute(t));const t=e.tagName.toLowerCase();this._shouldRenameElement(t)&&(Ac(t),e.replaceWith(this._createReplacementDomElement(t,e)))}for(;e.firstChild;)e.firstChild.remove();e.append(n)}viewToDom(e,t={}){if(e.is("$text")){const t=this._processDataFromViewText(e);return this._domDocument.createTextNode(t)}{const i=e;if(this.mapViewToDom(i)){if(!i.getCustomProperty("editingPipeline:doNotReuseOnce"))return this.mapViewToDom(i);this._elementsWithTemporaryCustomProperties.add(i)}let n;if(i.is("documentFragment"))n=this._domDocument.createDocumentFragment(),t.bind&&this.bindDocumentFragments(n,i);else{if(i.is("uiElement"))return n="$comment"===i.name?this._domDocument.createComment(i.getCustomProperty("$rawContent")):i.render(this._domDocument,this),t.bind&&this.bindElements(n,i),n;this._shouldRenameElement(i.name)?(Ac(i.name),n=this._createReplacementDomElement(i.name)):n=i.hasAttribute("xmlns")?this._domDocument.createElementNS(i.getAttribute("xmlns"),i.name):this._domDocument.createElement(i.name),i.is("rawElement")&&i.render(n,this),t.bind&&this.bindElements(n,i);for(const e of i.getAttributeKeys())this.setDomElementAttribute(n,e,i.getAttribute(e),i)}if(!1!==t.withChildren)for(const e of this.viewChildrenToDom(i,t))n.appendChild(e);return n}}setDomElementAttribute(e,t,i,n){const s=this.shouldRenderAttribute(t,i,e.tagName.toLowerCase())||n&&n.shouldRenderUnsafeAttribute(t);s||b("domconverter-unsafe-attribute-detected",{domElement:e,key:t,value:i}),zr(t)?(e.hasAttribute(t)&&!s?e.removeAttribute(t):e.hasAttribute(vc+t)&&s&&e.removeAttribute(vc+t),e.setAttribute(s?t:vc+t,i)):b("domconverter-invalid-attribute-detected",{domElement:e,key:t,value:i})}removeDomElementAttribute(e,t){t!=_c&&(e.removeAttribute(t),e.removeAttribute(vc+t))}*viewChildrenToDom(e,t={}){const i=e.getFillerOffset&&e.getFillerOffset();let n=0;for(const s of e.getChildren()){i===n&&(yield this._getBlockFiller());const e=s.is("element")&&!!s.getCustomProperty("dataPipeline:transparentRendering")&&!_a(s.getAttributes());e&&"data"==this.renderingMode?yield*this.viewChildrenToDom(s,t):(e&&b("domconverter-transparent-rendering-unsupported-in-editing-pipeline",{viewElement:s}),yield this.viewToDom(s,t)),n++}i===n&&(yield this._getBlockFiller())}viewRangeToDom(e){const t=this.viewPositionToDom(e.start),i=this.viewPositionToDom(e.end),n=this._domDocument.createRange();return n.setStart(t.parent,t.offset),n.setEnd(i.parent,i.offset),n}viewPositionToDom(e){const t=e.parent;if(t.is("$text")){const i=this.findCorrespondingDomText(t);if(!i)return null;let n=e.offset;return rc(i)&&(n+=sc),{parent:i,offset:n}}{let i,n,s;if(0===e.offset){if(i=this.mapViewToDom(t),!i)return null;s=i.childNodes[0]}else{const t=e.nodeBefore;if(n=t.is("$text")?this.findCorrespondingDomText(t):this.mapViewToDom(t),!n)return null;i=n.parentNode,s=n.nextSibling}if(Ar(s)&&rc(s))return{parent:s,offset:sc};return{parent:i,offset:n?Nr(n)+1:0}}}domToView(e,t={}){const i=[],n=this._domToView(e,t,i),s=n.next().value;return s?(n.next(),this._processDomInlineNodes(null,i,t),s.is("$text")&&0==s.data.length?null:s):null}*domChildrenToView(e,t={},i=[]){for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n],o=this._domToView(s,t,i),r=o.next().value;null!==r&&(this._isBlockViewElement(r)&&this._processDomInlineNodes(e,i,t),yield r,o.next())}this._processDomInlineNodes(e,i,t)}domSelectionToView(e){if(function(e){if(!i.isGecko)return!1;if(!e.rangeCount)return!1;const t=e.getRangeAt(0).startContainer;try{Object.prototype.toString.call(t)}catch(e){return!0}return!1}(e))return new Cl([]);if(1===e.rangeCount){let t=e.getRangeAt(0).startContainer;Ar(t)&&(t=t.parentNode);const i=this.fakeSelectionToView(t);if(i)return i}const t=this.isDomSelectionBackward(e),n=[];for(let t=0;t<e.rangeCount;t++){const i=e.getRangeAt(t),s=this.domRangeToView(i);s&&n.push(s)}return new Cl(n,{backward:t})}domRangeToView(e){const t=this.domPositionToView(e.startContainer,e.startOffset),i=this.domPositionToView(e.endContainer,e.endOffset);return t&&i?new yl(t,i):null}domPositionToView(e,t=0){if(this.isBlockFiller(e))return this.domPositionToView(e.parentNode,Nr(e));const i=this.mapDomToView(e);if(i&&(i.is("uiElement")||i.is("rawElement")))return _l._createBefore(i);if(Ar(e)){if(ac(e))return this.domPositionToView(e.parentNode,Nr(e));const i=this.findCorrespondingViewText(e);let n=t;return i?(rc(e)&&(n-=sc,n=n<0?0:n),new _l(i,n)):null}if(0===t){const t=this.mapDomToView(e);if(t)return new _l(t,0)}else{const i=e.childNodes[t-1];if(Ar(i)&&ac(i)||i&&this.isBlockFiller(i))return this.domPositionToView(i.parentNode,Nr(i));const n=Ar(i)?this.findCorrespondingViewText(i):this.mapDomToView(i);if(n&&n.parent)return new _l(n.parent,n.index+1)}return null}mapDomToView(e){return this.getHostViewElement(e)||this._domToViewMapping.get(e)}findCorrespondingViewText(e){if(ac(e))return null;const t=this.getHostViewElement(e);if(t)return t;const i=e.previousSibling;if(i){if(!this.isElement(i))return null;const e=this.mapDomToView(i);if(e){const t=e.nextSibling;return t instanceof nl?t:null}}else{const t=this.mapDomToView(e.parentNode);if(t){const e=t.getChild(0);return e instanceof nl?e:null}}return null}mapViewToDom(e){return this._viewToDomMapping.get(e)}findCorrespondingDomText(e){const t=e.previousSibling;return t&&this.mapViewToDom(t)?this.mapViewToDom(t).nextSibling:!t&&e.parent&&this.mapViewToDom(e.parent)?this.mapViewToDom(e.parent).childNodes[0]:null}focus(e){const t=this.mapViewToDom(e);if(t&&t.ownerDocument.activeElement!==t){const{scrollX:e,scrollY:i}=_r.window,n=[];Cc(t,(e=>{const{scrollLeft:t,scrollTop:i}=e;n.push([t,i])})),t.focus(),Cc(t,(e=>{const[t,i]=n.shift();e.scrollLeft=t,e.scrollTop=i})),_r.window.scrollTo(e,i)}}_clearDomSelection(){const e=this.mapViewToDom(this.document.selection.editableElement);if(!e)return;const t=e.ownerDocument.defaultView.getSelection(),i=this.domSelectionToView(t);i&&i.rangeCount>0&&t.removeAllRanges()}isElement(e){return e&&e.nodeType==Node.ELEMENT_NODE}isDocumentFragment(e){return e&&e.nodeType==Node.DOCUMENT_FRAGMENT_NODE}isBlockFiller(e){return"br"==this.blockFillerMode?e.isEqualNode(pc):!("BR"!==e.tagName||!xc(e,this.blockElements)||1!==e.parentNode.childNodes.length)||(e.isEqualNode(wc)||function(e,t){const i=e.isEqualNode(bc);return i&&xc(e,t)&&1===e.parentNode.childNodes.length}(e,this.blockElements))}isDomSelectionBackward(e){if(e.isCollapsed)return!1;const t=this._domDocument.createRange();try{t.setStart(e.anchorNode,e.anchorOffset),t.setEnd(e.focusNode,e.focusOffset)}catch(e){return!1}const i=t.collapsed;return t.detach(),i}getHostViewElement(e){const t=kr(e);for(t.pop();t.length;){const e=t.pop(),i=this._domToViewMapping.get(e);if(i&&(i.is("uiElement")||i.is("rawElement")))return i}return null}isDomSelectionCorrect(e){return this._isDomSelectionPositionCorrect(e.anchorNode,e.anchorOffset)&&this._isDomSelectionPositionCorrect(e.focusNode,e.focusOffset)}registerRawContentMatcher(e){this._rawContentElementMatcher.add(e)}registerInlineObjectMatcher(e){this._inlineObjectElementMatcher.add(e)}_clearTemporaryCustomProperties(){for(const e of this._elementsWithTemporaryCustomProperties)e._removeCustomProperty("editingPipeline:doNotReuseOnce");this._elementsWithTemporaryCustomProperties.clear()}_getBlockFiller(){switch(this.blockFillerMode){case"nbsp":return tc(this._domDocument);case"markedNbsp":return ic(this._domDocument);case"br":return nc(this._domDocument)}}_isDomSelectionPositionCorrect(e,t){if(Ar(e)&&rc(e)&&t<sc)return!1;if(this.isElement(e)&&rc(e.childNodes[t]))return!1;const i=this.mapDomToView(e);return!i||!i.is("uiElement")&&!i.is("rawElement")}*_domToView(e,t,i){if(this.isBlockFiller(e))return null;const n=this.getHostViewElement(e);if(n)return n;if(Dr(e)&&t.skipComments)return null;if(Ar(e)){if(ac(e))return null;{const t=e.data;if(""===t)return null;const n=new nl(this.document,t);return i.push(n),n}}{let n=this.mapDomToView(e);if(n)return this._isInlineObjectElement(n)&&i.push(n),n;if(this.isDocumentFragment(e))n=new Ul(this.document),t.bind&&this.bindDocumentFragments(e,n);else{n=this._createViewElement(e,t),t.bind&&this.bindElements(e,n);const s=e.attributes;if(s)for(let e=s.length,t=0;t<e;t++)n._setAttribute(s[t].name,s[t].value);if(this._isViewElementWithRawContent(n,t))return n._setCustomProperty("$rawContent",e.innerHTML),this._isBlockViewElement(n)||i.push(n),n;if(Dr(e))return n._setCustomProperty("$rawContent",e.data),n}yield n;const s=[];if(!1!==t.withChildren)for(const i of this.domChildrenToView(e,t,s))n._appendChild(i);if(this._isInlineObjectElement(n))i.push(n);else for(const e of s)i.push(e)}}_processDomInlineNodes(e,t,i){if(!t.length)return;if(e&&!this.isDocumentFragment(e)&&!this._isBlockDomElement(e))return;let n=!1;for(let e=0;e<t.length;e++){const s=t[e];if(!s.is("$text")){n=!1;continue}let o,r=!1;if(kc(s,this.preElements))o=lc(s.data);else{o=s.data.replace(/[ \n\t\r]{1,}/g," "),r=/[^\S\u00A0]/.test(o.charAt(o.length-1));const a=e>0?t[e-1]:null,l=e+1<t.length?t[e+1]:null,c=!a||a.is("element")&&"br"==a.name||n,d=!l&&!rc(s.data);!1!==i.withChildren&&(c&&(o=o.replace(/^ /,"")),d&&(o=o.replace(/ $/,""))),o=lc(o),o=o.replace(/ \u00A0/g," ");const h=l&&l.is("element")&&"br"!=l.name,u=l&&l.is("$text")&&" "==l.data.charAt(0);(/[ \u00A0]\u00A0$/.test(o)||!l||h||u)&&(o=o.replace(/\u00A0$/," ")),(c||a&&a.is("element")&&"br"!=a.name)&&(o=o.replace(/^\u00A0/," "))}0==o.length&&s.parent?(s._remove(),t.splice(e,1),e--):(s._data=o,n=r)}t.length=0}_processDataFromViewText(e){let t=e.data;if(e.getAncestors().some((e=>this.preElements.includes(e.name))))return t;if(" "==t.charAt(0)){const i=this._getTouchingInlineViewNode(e,!1);!(i&&i.is("$textProxy")&&this._nodeEndsWithSpace(i))&&i||(t=" "+t.substr(1))}if(" "==t.charAt(t.length-1)){const i=this._getTouchingInlineViewNode(e,!0),n=i&&i.is("$textProxy")&&" "==i.data.charAt(0);" "!=t.charAt(t.length-2)&&i&&!n||(t=t.substr(0,t.length-1)+" ")}return t.replace(/ {2}/g,"  ")}_nodeEndsWithSpace(e){if(e.getAncestors().some((e=>this.preElements.includes(e.name))))return!1;const t=this._processDataFromViewText(e);return" "==t.charAt(t.length-1)}_getTouchingInlineViewNode(e,t){const i=new vl({startPosition:t?_l._createAfter(e):_l._createBefore(e),direction:t?"forward":"backward"});for(const e of i){if(e.item.is("element","br"))return null;if(this._isInlineObjectElement(e.item))return e.item;if(e.item.is("containerElement"))return null;if(e.item.is("$textProxy"))return e.item}return null}_isBlockDomElement(e){return this.isElement(e)&&this.blockElements.includes(e.tagName.toLowerCase())}_isBlockViewElement(e){return e.is("element")&&this.blockElements.includes(e.name)}_isInlineObjectElement(e){return!!e.is("element")&&("br"==e.name||this.inlineObjectElements.includes(e.name)||!!this._inlineObjectElementMatcher.match(e))}_createViewElement(e,t){if(Dr(e))return new Fl(this.document,"$comment");const i=t.keepOriginalCase?e.tagName:e.tagName.toLowerCase();return new ul(this.document,i)}_isViewElementWithRawContent(e,t){return!1!==t.withChildren&&e.is("element")&&!!this._rawContentElementMatcher.match(e)}_shouldRenameElement(e){const t=e.toLowerCase();return"editing"===this.renderingMode&&this.unsafeElements.includes(t)}_createReplacementDomElement(e,t){const i=this._domDocument.createElement("span");if(i.setAttribute(_c,e),t){for(;t.firstChild;)i.appendChild(t.firstChild);for(const e of t.getAttributeNames())i.setAttribute(e,t.getAttribute(e))}return i}constructor(e,{blockFillerMode:t,renderingMode:i="editing"}={}){this._domToViewMapping=new WeakMap,this._viewToDomMapping=new WeakMap,this._fakeSelectionMapping=new WeakMap,this._rawContentElementMatcher=new ol,this._inlineObjectElementMatcher=new ol,this._elementsWithTemporaryCustomProperties=new Set,this.document=e,this.renderingMode=i,this.blockFillerMode=t||("editing"===i?"br":"nbsp"),this.preElements=["pre"],this.blockElements=["address","article","aside","blockquote","caption","center","dd","details","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","legend","li","main","menu","nav","ol","p","pre","section","summary","table","tbody","td","tfoot","th","thead","tr","ul"],this.inlineObjectElements=["object","iframe","input","button","textarea","select","option","video","embed","audio","img","canvas"],this.unsafeElements=["script","style"],this._domDocument="editing"===this.renderingMode?_r.document:_r.document.implementation.createHTMLDocument("")}}function kc(e,t){return e.getAncestors().some((e=>e.is("element")&&t.includes(e.name)))}function Cc(e,t){let i=e;for(;i;)t(i),i=i.parentElement}function xc(e,t){const i=e.parentNode;return!!i&&!!i.tagName&&t.includes(i.tagName.toLowerCase())}function Ac(e){"script"===e&&b("domconverter-unsafe-script-element-detected"),"style"===e&&b("domconverter-unsafe-style-element-detected")}class Ec extends(pr()){get isEnabled(){return this._isEnabled}enable(){this._isEnabled=!0}disable(){this._isEnabled=!1}destroy(){this.disable(),this.stopListening()}checkShouldIgnoreEventFromTarget(e){return e&&3===e.nodeType&&(e=e.parentNode),!(!e||1!==e.nodeType)&&e.matches("[data-cke-ignore-events], [data-cke-ignore-events] *")}constructor(e){super(),this._isEnabled=!1,this.view=e,this.document=e.document}}class Tc{get target(){return this.view.domConverter.mapDomToView(this.domTarget)}preventDefault(){this.domEvent.preventDefault()}stopPropagation(){this.domEvent.stopPropagation()}constructor(e,t,i){this.view=e,this.document=e.document,this.domEvent=t,this.domTarget=t.target,Et(this,i)}}class Sc extends Ec{observe(e){("string"==typeof this.domEventType?[this.domEventType]:this.domEventType).forEach((t=>{this.listenTo(e,t,((e,t)=>{this.isEnabled&&!this.checkShouldIgnoreEventFromTarget(t.target)&&this.onDomEvent(t)}),{useCapture:this.useCapture})}))}stopObserving(e){this.stopListening(e)}fire(e,t,i){this.isEnabled&&this.document.fire(e,new Tc(this.view,t,i))}constructor(...e){super(...e),this.useCapture=!1}}class Ic extends Sc{onDomEvent(e){const t={keyCode:e.keyCode,altKey:e.altKey,ctrlKey:e.ctrlKey,shiftKey:e.shiftKey,metaKey:e.metaKey,get keystroke(){return la(this)}};this.fire(e.type,e,t)}constructor(...e){super(...e),this.domEventType=["keydown","keyup"]}}class Pc extends Ec{observe(){const e=this.document;e.on("arrowKey",((t,i)=>{e.selection.isFake&&this.isEnabled&&i.preventDefault()}),{context:"$capture"}),e.on("arrowKey",((t,i)=>{e.selection.isFake&&this.isEnabled&&this._handleSelectionMove(i.keyCode)}),{priority:"lowest"})}stopObserving(){}destroy(){super.destroy(),this._fireSelectionChangeDoneDebounced.cancel()}_handleSelectionMove(e){const t=this.document.selection,i=new Cl(t.getRanges(),{backward:t.isBackward,fake:!1});e!=ra.arrowleft&&e!=ra.arrowup||i.setTo(i.getFirstPosition()),e!=ra.arrowright&&e!=ra.arrowdown||i.setTo(i.getLastPosition());const n={oldSelection:t,newSelection:i,domSelection:null};this.document.fire("selectionChange",n),this._fireSelectionChangeDoneDebounced(n)}constructor(e){super(e),this._fireSelectionChangeDoneDebounced=ko((e=>{this.document.fire("selectionChangeDone",e)}),200)}}let Vc=class extends Ec{flush(){this._onMutations(this._mutationObserver.takeRecords())}observe(e){this._domElements.add(e),this.isEnabled&&this._mutationObserver.observe(e,this._config)}stopObserving(e){if(this._domElements.delete(e),this.isEnabled){this._mutationObserver.disconnect();for(const e of this._domElements)this._mutationObserver.observe(e,this._config)}}enable(){super.enable();for(const e of this._domElements)this._mutationObserver.observe(e,this._config)}disable(){super.disable(),this._mutationObserver.disconnect()}destroy(){super.destroy(),this._mutationObserver.disconnect()}_onMutations(e){if(0===e.length)return;const t=this.domConverter,i=new Set,n=new Set;for(const i of e){const e=t.mapDomToView(i.target);e&&(e.is("uiElement")||e.is("rawElement")||"childList"!==i.type||this._isBogusBrMutation(i)||n.add(e))}for(const s of e){const e=t.mapDomToView(s.target);if((!e||!e.is("uiElement")&&!e.is("rawElement"))&&"characterData"===s.type){const e=t.findCorrespondingViewText(s.target);e&&!n.has(e.parent)?i.add(e):!e&&rc(s.target)&&n.add(t.mapDomToView(s.target.parentNode))}}let s=!1;for(const e of i)s=!0,this.renderer.markToSync("text",e);for(const e of n){const i=t.mapViewToDom(e),n=Array.from(e.getChildren()),c=Array.from(t.domChildrenToView(i,{withChildren:!1}));o=n,r=c,l=void 0,(void 0===(l=(a="function"==typeof(a=Rc)?a:void 0)?a(o,r):void 0)?to(o,r,void 0,a):l)||(s=!0,this.renderer.markToSync("children",e))}var o,r,a,l;s&&this.view.forceRender()}_isBogusBrMutation(e){let t=null;return null===e.nextSibling&&0===e.removedNodes.length&&1==e.addedNodes.length&&(t=this.domConverter.domToView(e.addedNodes[0],{withChildren:!1})),t&&t.is("element","br")}constructor(e){super(e),this._config={childList:!0,characterData:!0,subtree:!0},this.domConverter=e.domConverter,this.renderer=e._renderer,this._domElements=new Set,this._mutationObserver=new window.MutationObserver(this._onMutations.bind(this))}};function Rc(e,t){if(!Array.isArray(e))return e===t||!(!e.is("$text")||!t.is("$text"))&&e.data===t.data}class Bc extends Sc{flush(){this._isFocusChanging&&(this._isFocusChanging=!1,this.document.isFocused=!0)}onDomEvent(e){this.fire(e.type,e)}destroy(){this._renderTimeoutId&&clearTimeout(this._renderTimeoutId),super.destroy()}constructor(e){super(e),this._isFocusChanging=!1,this.domEventType=["focus","blur"],this.useCapture=!0;const t=this.document;t.on("focus",(()=>{this._isFocusChanging=!0,this._renderTimeoutId=setTimeout((()=>{this.flush(),e.change((()=>{}))}),50)})),t.on("blur",((i,n)=>{const s=t.selection.editableElement;null!==s&&s!==n.target||(t.isFocused=!1,this._isFocusChanging=!1,e.change((()=>{})))}))}}class Oc extends Ec{observe(e){const t=e.ownerDocument,n=()=>{this.document.isSelecting&&(this._handleSelectionChange(null,t),this.document.isSelecting=!1,this._documentIsSelectingInactivityTimeoutDebounced.cancel())};this.listenTo(e,"selectstart",(()=>{this.document.isSelecting=!0,this._documentIsSelectingInactivityTimeoutDebounced()}),{priority:"highest"}),this.listenTo(e,"keydown",n,{priority:"highest",useCapture:!0}),this.listenTo(e,"keyup",n,{priority:"highest",useCapture:!0}),this._documents.has(t)||(this.listenTo(t,"mouseup",n,{priority:"highest",useCapture:!0}),this.listenTo(t,"selectionchange",((e,n)=>{this.document.isComposing&&!i.isAndroid||(this._handleSelectionChange(n,t),this._documentIsSelectingInactivityTimeoutDebounced())})),this._documents.add(t))}stopObserving(e){this.stopListening(e)}destroy(){super.destroy(),clearInterval(this._clearInfiniteLoopInterval),this._fireSelectionChangeDoneDebounced.cancel(),this._documentIsSelectingInactivityTimeoutDebounced.cancel()}_reportInfiniteLoop(){}_handleSelectionChange(e,t){if(!this.isEnabled)return;const i=t.defaultView.getSelection();if(this.checkShouldIgnoreEventFromTarget(i.anchorNode))return;this.mutationObserver.flush();const n=this.domConverter.domSelectionToView(i);if(0!=n.rangeCount){if(this.view.hasDomSelection=!0,this.focusObserver.flush(),!this.selection.isEqual(n)||!this.domConverter.isDomSelectionCorrect(i))if(++this._loopbackCounter>60)this._reportInfiniteLoop();else if(this.selection.isSimilar(n))this.view.forceRender();else{const e={oldSelection:this.selection,newSelection:n,domSelection:i};this.document.fire("selectionChange",e),this._fireSelectionChangeDoneDebounced(e)}}else this.view.hasDomSelection=!1}_clearInfiniteLoop(){this._loopbackCounter=0}constructor(e){super(e),this.mutationObserver=e.getObserver(Vc),this.focusObserver=e.getObserver(Bc),this.selection=this.document.selection,this.domConverter=e.domConverter,this._documents=new WeakSet,this._fireSelectionChangeDoneDebounced=ko((e=>{this.document.fire("selectionChangeDone",e)}),200),this._clearInfiniteLoopInterval=setInterval((()=>this._clearInfiniteLoop()),1e3),this._documentIsSelectingInactivityTimeoutDebounced=ko((()=>this.document.isSelecting=!1),5e3),this._loopbackCounter=0}}class Mc extends Sc{onDomEvent(e){this.fire(e.type,e,{data:e.data})}constructor(e){super(e),this.domEventType=["compositionstart","compositionupdate","compositionend"];const t=this.document;t.on("compositionstart",(()=>{t.isComposing=!0}),{priority:"low"}),t.on("compositionend",(()=>{t.isComposing=!1}),{priority:"low"})}}class Lc{get files(){return this._files||(this._files=Nc(this._native)),this._files}get types(){return this._native.types}getData(e){return this._native.getData(e)}setData(e,t){this._native.setData(e,t)}set effectAllowed(e){this._native.effectAllowed=e}get effectAllowed(){return this._native.effectAllowed}set dropEffect(e){this._native.dropEffect=e}get dropEffect(){return this._native.dropEffect}setDragImage(e,t,i){this._native.setDragImage(e,t,i)}get isCanceled(){return"none"==this._native.dropEffect||!!this._native.mozUserCancelled}constructor(e,t={}){this._files=t.cacheFiles?Nc(e):null,this._native=e}}function Nc(e){const t=Array.from(e.files||[]),i=Array.from(e.items||[]);return t.length?t:i.filter((e=>"file"===e.kind)).map((e=>e.getAsFile()))}class Fc extends Sc{onDomEvent(e){const t=e.getTargetRanges(),n=this.view,s=n.document;let o=null,r=null,a=[];if(e.dataTransfer&&(o=new Lc(e.dataTransfer)),null!==e.data?r=e.data:o&&(r=o.getData("text/plain")),s.selection.isFake)a=Array.from(s.selection.getRanges());else if(t.length)a=t.map((e=>{const t=n.domConverter.domPositionToView(e.startContainer,e.startOffset),i=n.domConverter.domPositionToView(e.endContainer,e.endOffset);return t?n.createRange(t,i):i?n.createRange(i):void 0})).filter((e=>!!e));else if(i.isAndroid){const t=e.target.ownerDocument.defaultView.getSelection();a=Array.from(n.domConverter.domSelectionToView(t).getRanges())}if(i.isAndroid&&"insertCompositionText"==e.inputType&&r&&r.endsWith("\n"))this.fire(e.type,e,{inputType:"insertParagraph",targetRanges:[n.createRange(a[0].end)]});else if("insertText"==e.inputType&&r&&r.includes("\n")){const t=r.split(/\n{1,2}/g);let i=a;for(let n=0;n<t.length;n++){const r=t[n];""!=r&&(this.fire(e.type,e,{data:r,dataTransfer:o,targetRanges:i,inputType:e.inputType,isComposing:e.isComposing}),i=[s.selection.getFirstRange()]),n+1<t.length&&(this.fire(e.type,e,{inputType:"insertParagraph",targetRanges:i}),i=[s.selection.getFirstRange()])}}else this.fire(e.type,e,{data:r,dataTransfer:o,targetRanges:a,inputType:e.inputType,isComposing:e.isComposing})}constructor(...e){super(...e),this.domEventType="beforeinput"}}class Dc extends Ec{observe(){}stopObserving(){}constructor(e){super(e),this.document.on("keydown",((e,t)=>{if(this.isEnabled&&ha(t.keyCode)){const i=new Al(this.document,"arrowKey",this.document.selection.getFirstRange());this.document.fire(i,t),i.stop.called&&e.stop()}}))}}class zc extends Ec{observe(){}stopObserving(){}constructor(e){super(e);const t=this.document;t.on("keydown",((e,i)=>{if(!this.isEnabled||i.keyCode!=ra.tab||i.ctrlKey)return;const n=new Al(t,"tab",t.selection.getFirstRange());t.fire(n,i),n.stop.called&&e.stop()}))}}let Hc=class extends(Yo()){attachDomRoot(e,t="main"){const i=this.document.getRoot(t);i._name=e.tagName.toLowerCase();const n={};for(const{name:t,value:s}of Array.from(e.attributes))n[t]=s,"class"===t?this._writer.addClass(s.split(" "),i):this._writer.setAttribute(t,s,i);this._initialDomRootAttributes.set(e,n);const s=()=>{this._writer.setAttribute("contenteditable",(!i.isReadOnly).toString(),i),i.isReadOnly?this._writer.addClass("ck-read-only",i):this._writer.removeClass("ck-read-only",i)};s(),this.domRoots.set(t,e),this.domConverter.bindElements(e,i),this._renderer.markToSync("children",i),this._renderer.markToSync("attributes",i),this._renderer.domDocuments.add(e.ownerDocument),i.on("change:children",((e,t)=>this._renderer.markToSync("children",t))),i.on("change:attributes",((e,t)=>this._renderer.markToSync("attributes",t))),i.on("change:text",((e,t)=>this._renderer.markToSync("text",t))),i.on("change:isReadOnly",(()=>this.change(s))),i.on("change",(()=>{this._hasChangedSinceTheLastRendering=!0}));for(const i of this._observers.values())i.observe(e,t)}detachDomRoot(e){const t=this.domRoots.get(e);Array.from(t.attributes).forEach((({name:e})=>t.removeAttribute(e)));const i=this._initialDomRootAttributes.get(t);for(const e in i)t.setAttribute(e,i[e]);this.domRoots.delete(e),this.domConverter.unbindDomElement(t);for(const e of this._observers.values())e.stopObserving(t)}getDomRoot(e="main"){return this.domRoots.get(e)}addObserver(e){let t=this._observers.get(e);if(t)return t;t=new e(this),this._observers.set(e,t);for(const[e,i]of this.domRoots)t.observe(i,e);return t.enable(),t}getObserver(e){return this._observers.get(e)}disableObservers(){for(const e of this._observers.values())e.disable()}enableObservers(){for(const e of this._observers.values())e.enable()}scrollToTheSelection({alignToTop:e,forceScroll:t,viewportOffset:i=20,ancestorOffset:n=20}={}){const s=this.document.selection.getFirstRange();if(!s)return;const o=_s({alignToTop:e,forceScroll:t,viewportOffset:i,ancestorOffset:n});"number"==typeof i&&(i={top:i,bottom:i,left:i,right:i});const r={target:this.domConverter.viewRangeToDom(s),viewportOffset:i,ancestorOffset:n,alignToTop:e,forceScroll:t};this.fire("scrollToTheSelection",r,o),qr(r)}focus(){if(!this.document.isFocused){const e=this.document.selection.editableElement;e&&(this.domConverter.focus(e),this.forceRender())}}change(e){if(this.isRenderingInProgress||this._postFixersInProgress)throw new p("cannot-change-view-tree",this);try{if(this._ongoingChange)return e(this._writer);this._ongoingChange=!0;const t=e(this._writer);return this._ongoingChange=!1,!this._renderingDisabled&&this._hasChangedSinceTheLastRendering&&(this._postFixersInProgress=!0,this.document._callPostFixers(this._writer),this._postFixersInProgress=!1,this.fire("render")),t}catch(e){p.rethrowUnexpectedError(e,this)}}forceRender(){this._hasChangedSinceTheLastRendering=!0,this.getObserver(Bc).flush(),this.change((()=>{}))}destroy(){for(const e of this._observers.values())e.destroy();this.document.destroy(),this.stopListening()}createPositionAt(e,t){return _l._createAt(e,t)}createPositionAfter(e){return _l._createAfter(e)}createPositionBefore(e){return _l._createBefore(e)}createRange(e,t){return new yl(e,t)}createRangeOn(e){return yl._createOn(e)}createRangeIn(e){return yl._createIn(e)}createSelection(...e){return new Cl(...e)}_disableRendering(e){this._renderingDisabled=e,0==e&&this.change((()=>{}))}_render(){this.isRenderingInProgress=!0,this.disableObservers(),this._renderer.render(),this.enableObservers(),this.isRenderingInProgress=!1}constructor(e){super(),this.domRoots=new Map,this._initialDomRootAttributes=new WeakMap,this._observers=new Map,this._ongoingChange=!1,this._postFixersInProgress=!1,this._renderingDisabled=!1,this._hasChangedSinceTheLastRendering=!1,this.document=new Rl(e),this.domConverter=new yc(this.document),this.set("isRenderingInProgress",!1),this.set("hasDomSelection",!1),this._renderer=new dc(this.domConverter,this.document.selection),this._renderer.bind("isFocused","isSelecting","isComposing").to(this.document,"isFocused","isSelecting","isComposing"),this._writer=new Wl(this.document),this.addObserver(Vc),this.addObserver(Bc),this.addObserver(Oc),this.addObserver(Ic),this.addObserver(Pc),this.addObserver(Mc),this.addObserver(Dc),this.addObserver(Fc),this.addObserver(zc),this.document.on("arrowKey",cc,{priority:"low"}),Dl(this),this.on("render",(()=>{this._render(),this.document.fire("layoutChanged"),this._hasChangedSinceTheLastRendering=!1})),this.listenTo(this.document.selection,"change",(()=>{this._hasChangedSinceTheLastRendering=!0})),this.listenTo(this.document,"change:isFocused",(()=>{this._hasChangedSinceTheLastRendering=!0})),i.isiOS&&this.listenTo(this.document,"blur",((e,t)=>{this.domConverter.mapDomToView(t.domEvent.relatedTarget)||this.domConverter._clearDomSelection()}))}};class $c{is(){throw new Error("is() method is abstract")}}let Uc=class extends $c{get document(){return null}get index(){let e;if(!this.parent)return null;if(null===(e=this.parent.getChildIndex(this)))throw new p("model-node-not-found-in-parent",this);return e}get startOffset(){let e;if(!this.parent)return null;if(null===(e=this.parent.getChildStartOffset(this)))throw new p("model-node-not-found-in-parent",this);return e}get offsetSize(){return 1}get endOffset(){return this.parent?this.startOffset+this.offsetSize:null}get nextSibling(){const e=this.index;return null!==e&&this.parent.getChild(e+1)||null}get previousSibling(){const e=this.index;return null!==e&&this.parent.getChild(e-1)||null}get root(){let e=this;for(;e.parent;)e=e.parent;return e}isAttached(){return null!==this.parent&&this.root.isAttached()}getPath(){const e=[];let t=this;for(;t.parent;)e.unshift(t.startOffset),t=t.parent;return e}getAncestors(e={}){const t=[];let i=e.includeSelf?this:this.parent;for(;i;)t[e.parentFirst?"push":"unshift"](i),i=i.parent;return t}getCommonAncestor(e,t={}){const i=this.getAncestors(t),n=e.getAncestors(t);let s=0;for(;i[s]==n[s]&&i[s];)s++;return 0===s?null:i[s-1]}isBefore(e){if(this==e)return!1;if(this.root!==e.root)return!1;const t=this.getPath(),i=e.getPath(),n=ar(t,i);switch(n){case"prefix":return!0;case"extension":return!1;default:return t[n]<i[n]}}isAfter(e){return this!=e&&(this.root===e.root&&!this.isBefore(e))}hasAttribute(e){return this._attrs.has(e)}getAttribute(e){return this._attrs.get(e)}getAttributes(){return this._attrs.entries()}getAttributeKeys(){return this._attrs.keys()}toJSON(){const e={};return this._attrs.size&&(e.attributes=Array.from(this._attrs).reduce(((e,t)=>(e[t[0]]=t[1],e)),{})),e}_clone(e){return new this.constructor(this._attrs)}_remove(){this.parent._removeChildren(this.index)}_setAttribute(e,t){this._attrs.set(e,t)}_setAttributesTo(e){this._attrs=Ca(e)}_removeAttribute(e){return this._attrs.delete(e)}_clearAttributes(){this._attrs.clear()}constructor(e){super(),this.parent=null,this._attrs=Ca(e)}};Uc.prototype.is=function(e){return"node"===e||"model:node"===e};class Wc{[Symbol.iterator](){return this._nodes[Symbol.iterator]()}get length(){return this._nodes.length}get maxOffset(){return this._nodes.reduce(((e,t)=>e+t.offsetSize),0)}getNode(e){return this._nodes[e]||null}getNodeIndex(e){const t=this._nodes.indexOf(e);return-1==t?null:t}getNodeStartOffset(e){const t=this.getNodeIndex(e);return null===t?null:this._nodes.slice(0,t).reduce(((e,t)=>e+t.offsetSize),0)}indexToOffset(e){if(e==this._nodes.length)return this.maxOffset;const t=this._nodes[e];if(!t)throw new p("model-nodelist-index-out-of-bounds",this);return this.getNodeStartOffset(t)}offsetToIndex(e){let t=0;for(const i of this._nodes){if(e>=t&&e<t+i.offsetSize)return this.getNodeIndex(i);t+=i.offsetSize}if(t!=e)throw new p("model-nodelist-offset-out-of-bounds",this,{offset:e,nodeList:this});return this.length}_insertNodes(e,t){for(const e of t)if(!(e instanceof Uc))throw new p("model-nodelist-insertnodes-not-node",this);this._nodes=Ta(this._nodes,Array.from(t),e,0)}_removeNodes(e,t=1){return this._nodes.splice(e,t)}toJSON(){return this._nodes.map((e=>e.toJSON()))}constructor(e){this._nodes=[],e&&this._insertNodes(0,e)}}class jc extends Uc{get offsetSize(){return this.data.length}get data(){return this._data}toJSON(){const e=super.toJSON();return e.data=this.data,e}_clone(){return new jc(this.data,this.getAttributes())}static fromJSON(e){return new jc(e.data,e.attributes)}constructor(e,t){super(t),this._data=e||""}}jc.prototype.is=function(e){return"$text"===e||"model:$text"===e||"text"===e||"model:text"===e||"node"===e||"model:node"===e};class qc extends $c{get startOffset(){return null!==this.textNode.startOffset?this.textNode.startOffset+this.offsetInText:null}get offsetSize(){return this.data.length}get endOffset(){return null!==this.startOffset?this.startOffset+this.offsetSize:null}get isPartial(){return this.offsetSize!==this.textNode.offsetSize}get parent(){return this.textNode.parent}get root(){return this.textNode.root}getPath(){const e=this.textNode.getPath();return e.length>0&&(e[e.length-1]+=this.offsetInText),e}getAncestors(e={}){const t=[];let i=e.includeSelf?this:this.parent;for(;i;)t[e.parentFirst?"push":"unshift"](i),i=i.parent;return t}hasAttribute(e){return this.textNode.hasAttribute(e)}getAttribute(e){return this.textNode.getAttribute(e)}getAttributes(){return this.textNode.getAttributes()}getAttributeKeys(){return this.textNode.getAttributeKeys()}constructor(e,t,i){if(super(),this.textNode=e,t<0||t>e.offsetSize)throw new p("model-textproxy-wrong-offsetintext",this);if(i<0||t+i>e.offsetSize)throw new p("model-textproxy-wrong-length",this);this.data=e.data.substring(t,t+i),this.offsetInText=t}}qc.prototype.is=function(e){return"$textProxy"===e||"model:$textProxy"===e||"textProxy"===e||"model:textProxy"===e};class Gc extends Uc{get childCount(){return this._children.length}get maxOffset(){return this._children.maxOffset}get isEmpty(){return 0===this.childCount}getChild(e){return this._children.getNode(e)}getChildren(){return this._children[Symbol.iterator]()}getChildIndex(e){return this._children.getNodeIndex(e)}getChildStartOffset(e){return this._children.getNodeStartOffset(e)}offsetToIndex(e){return this._children.offsetToIndex(e)}getNodeByPath(e){let t=this;for(const i of e)t=t.getChild(t.offsetToIndex(i));return t}findAncestor(e,t={}){let i=t.includeSelf?this:this.parent;for(;i;){if(i.name===e)return i;i=i.parent}return null}toJSON(){const e=super.toJSON();if(e.name=this.name,this._children.length>0){e.children=[];for(const t of this._children)e.children.push(t.toJSON())}return e}_clone(e=!1){const t=e?Array.from(this._children).map((e=>e._clone(!0))):void 0;return new Gc(this.name,this.getAttributes(),t)}_appendChild(e){this._insertChild(this.childCount,e)}_insertChild(e,t){const i=function(e){if("string"==typeof e)return[new jc(e)];lr(e)||(e=[e]);return Array.from(e).map((e=>"string"==typeof e?new jc(e):e instanceof qc?new jc(e.data,e.getAttributes()):e))}(t);for(const e of i)null!==e.parent&&e._remove(),e.parent=this;this._children._insertNodes(e,i)}_removeChildren(e,t=1){const i=this._children._removeNodes(e,t);for(const e of i)e.parent=null;return i}static fromJSON(e){let t;if(e.children){t=[];for(const i of e.children)i.name?t.push(Gc.fromJSON(i)):t.push(jc.fromJSON(i))}return new Gc(e.name,e.attributes,t)}constructor(e,t,i){super(t),this._children=new Wc,this.name=e,i&&this._insertChild(0,i)}}Gc.prototype.is=function(e,t){return t?t===this.name&&("element"===e||"model:element"===e):"element"===e||"model:element"===e||"node"===e||"model:node"===e};class Kc{[Symbol.iterator](){return this}get position(){return this._position}skip(e){let t,i,n,s;do{n=this.position,s=this._visitedParent,({done:t,value:i}=this.next())}while(!t&&e(i));t||(this._position=n,this._visitedParent=s)}next(){return"forward"==this.direction?this._next():this._previous()}_next(){const e=this.position,t=this.position.clone(),i=this._visitedParent;if(null===i.parent&&t.offset===i.maxOffset)return{done:!0,value:void 0};if(i===this._boundaryEndParent&&t.offset==this.boundaries.end.offset)return{done:!0,value:void 0};const n=Qc(t,i),s=n||Yc(t,i,n);if(s instanceof Gc){if(this.shallow){if(this.boundaries&&this.boundaries.end.isBefore(t))return{done:!0,value:void 0};t.offset++}else t.path.push(0),this._visitedParent=s;return this._position=t,Zc("elementStart",s,e,t,1)}if(s instanceof jc){let n;if(this.singleCharacters)n=1;else{let e=s.endOffset;this._boundaryEndParent==i&&this.boundaries.end.offset<e&&(e=this.boundaries.end.offset),n=e-t.offset}const o=t.offset-s.startOffset,r=new qc(s,o,n);return t.offset+=n,this._position=t,Zc("text",r,e,t,n)}return t.path.pop(),t.offset++,this._position=t,this._visitedParent=i.parent,this.ignoreElementEnd?this._next():Zc("elementEnd",i,e,t)}_previous(){const e=this.position,t=this.position.clone(),i=this._visitedParent;if(null===i.parent&&0===t.offset)return{done:!0,value:void 0};if(i==this._boundaryStartParent&&t.offset==this.boundaries.start.offset)return{done:!0,value:void 0};const n=t.parent,s=Qc(t,n),o=s||Xc(t,n,s);if(o instanceof Gc)return t.offset--,this.shallow?(this._position=t,Zc("elementStart",o,e,t,1)):(t.path.push(o.maxOffset),this._position=t,this._visitedParent=o,this.ignoreElementEnd?this._previous():Zc("elementEnd",o,e,t));if(o instanceof jc){let n;if(this.singleCharacters)n=1;else{let e=o.startOffset;this._boundaryStartParent==i&&this.boundaries.start.offset>e&&(e=this.boundaries.start.offset),n=t.offset-e}const s=t.offset-o.startOffset,r=new qc(o,s-n,n);return t.offset-=n,this._position=t,Zc("text",r,e,t,n)}return t.path.pop(),this._position=t,this._visitedParent=i.parent,Zc("elementStart",i,e,t,1)}constructor(e){if(!e||!e.boundaries&&!e.startPosition)throw new p("model-tree-walker-no-start-position",null);const t=e.direction||"forward";if("forward"!=t&&"backward"!=t)throw new p("model-tree-walker-unknown-direction",e,{direction:t});this.direction=t,this.boundaries=e.boundaries||null,e.startPosition?this._position=e.startPosition.clone():this._position=Jc._createAt(this.boundaries["backward"==this.direction?"end":"start"]),this.position.stickiness="toNone",this.singleCharacters=!!e.singleCharacters,this.shallow=!!e.shallow,this.ignoreElementEnd=!!e.ignoreElementEnd,this._boundaryStartParent=this.boundaries?this.boundaries.start.parent:null,this._boundaryEndParent=this.boundaries?this.boundaries.end.parent:null,this._visitedParent=this.position.parent}}function Zc(e,t,i,n,s){return{done:!1,value:{type:e,item:t,previousPosition:i,nextPosition:n,length:s}}}class Jc extends $c{get offset(){return this.path[this.path.length-1]}set offset(e){this.path[this.path.length-1]=e}get parent(){let e=this.root;for(let t=0;t<this.path.length-1;t++)if(e=e.getChild(e.offsetToIndex(this.path[t])),!e)throw new p("model-position-path-incorrect",this,{position:this});if(e.is("$text"))throw new p("model-position-path-incorrect",this,{position:this});return e}get index(){return this.parent.offsetToIndex(this.offset)}get textNode(){return Qc(this,this.parent)}get nodeAfter(){const e=this.parent;return Yc(this,e,Qc(this,e))}get nodeBefore(){const e=this.parent;return Xc(this,e,Qc(this,e))}get isAtStart(){return 0===this.offset}get isAtEnd(){return this.offset==this.parent.maxOffset}compareWith(e){if(this.root!=e.root)return"different";const t=ar(this.path,e.path);switch(t){case"same":return"same";case"prefix":return"before";case"extension":return"after";default:return this.path[t]<e.path[t]?"before":"after"}}getLastMatchingPosition(e,t={}){t.startPosition=this;const i=new Kc(t);return i.skip(e),i.position}getParentPath(){return this.path.slice(0,-1)}getAncestors(){const e=this.parent;return e.is("documentFragment")?[e]:e.getAncestors({includeSelf:!0})}findAncestor(e){const t=this.parent;return t.is("element")?t.findAncestor(e,{includeSelf:!0}):null}getCommonPath(e){if(this.root!=e.root)return[];const t=ar(this.path,e.path),i="string"==typeof t?Math.min(this.path.length,e.path.length):t;return this.path.slice(0,i)}getCommonAncestor(e){const t=this.getAncestors(),i=e.getAncestors();let n=0;for(;t[n]==i[n]&&t[n];)n++;return 0===n?null:t[n-1]}getShiftedBy(e){const t=this.clone(),i=t.offset+e;return t.offset=i<0?0:i,t}isAfter(e){return"after"==this.compareWith(e)}isBefore(e){return"before"==this.compareWith(e)}isEqual(e){return"same"==this.compareWith(e)}isTouching(e){if(this.root!==e.root)return!1;const t=Math.min(this.path.length,e.path.length);for(let i=0;i<t;i++){const t=this.path[i]-e.path[i];if(t<-1||t>1)return!1;if(1===t)return ed(e,this,i);if(-1===t)return ed(this,e,i)}return this.path.length===e.path.length||(this.path.length>e.path.length?td(this.path,t):td(e.path,t))}hasSameParentAs(e){if(this.root!==e.root)return!1;return"same"==ar(this.getParentPath(),e.getParentPath())}getTransformedByOperation(e){let t;switch(e.type){case"insert":t=this._getTransformedByInsertOperation(e);break;case"move":case"remove":case"reinsert":t=this._getTransformedByMoveOperation(e);break;case"split":t=this._getTransformedBySplitOperation(e);break;case"merge":t=this._getTransformedByMergeOperation(e);break;default:t=Jc._createAt(this)}return t}_getTransformedByInsertOperation(e){return this._getTransformedByInsertion(e.position,e.howMany)}_getTransformedByMoveOperation(e){return this._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany)}_getTransformedBySplitOperation(e){const t=e.movedRange;return t.containsPosition(this)||t.start.isEqual(this)&&"toNext"==this.stickiness?this._getCombined(e.splitPosition,e.moveTargetPosition):e.graveyardPosition?this._getTransformedByMove(e.graveyardPosition,e.insertionPosition,1):this._getTransformedByInsertion(e.insertionPosition,1)}_getTransformedByMergeOperation(e){const t=e.movedRange;let i;return t.containsPosition(this)||t.start.isEqual(this)?(i=this._getCombined(e.sourcePosition,e.targetPosition),e.sourcePosition.isBefore(e.targetPosition)&&(i=i._getTransformedByDeletion(e.deletionPosition,1))):i=this.isEqual(e.deletionPosition)?Jc._createAt(e.deletionPosition):this._getTransformedByMove(e.deletionPosition,e.graveyardPosition,1),i}_getTransformedByDeletion(e,t){const i=Jc._createAt(this);if(this.root!=e.root)return i;if("same"==ar(e.getParentPath(),this.getParentPath())){if(e.offset<this.offset){if(e.offset+t>this.offset)return null;i.offset-=t}}else if("prefix"==ar(e.getParentPath(),this.getParentPath())){const n=e.path.length-1;if(e.offset<=this.path[n]){if(e.offset+t>this.path[n])return null;i.path[n]-=t}}return i}_getTransformedByInsertion(e,t){const i=Jc._createAt(this);if(this.root!=e.root)return i;if("same"==ar(e.getParentPath(),this.getParentPath()))(e.offset<this.offset||e.offset==this.offset&&"toPrevious"!=this.stickiness)&&(i.offset+=t);else if("prefix"==ar(e.getParentPath(),this.getParentPath())){const n=e.path.length-1;e.offset<=this.path[n]&&(i.path[n]+=t)}return i}_getTransformedByMove(e,t,i){if(t=t._getTransformedByDeletion(e,i),e.isEqual(t))return Jc._createAt(this);const n=this._getTransformedByDeletion(e,i);return null===n||e.isEqual(this)&&"toNext"==this.stickiness||e.getShiftedBy(i).isEqual(this)&&"toPrevious"==this.stickiness?this._getCombined(e,t):n._getTransformedByInsertion(t,i)}_getCombined(e,t){const i=e.path.length-1,n=Jc._createAt(t);return n.stickiness=this.stickiness,n.offset=n.offset+this.path[i]-e.offset,n.path=[...n.path,...this.path.slice(i+1)],n}toJSON(){return{root:this.root.toJSON(),path:Array.from(this.path),stickiness:this.stickiness}}clone(){return new this.constructor(this.root,this.path,this.stickiness)}static _createAt(e,t,i="toNone"){if(e instanceof Jc)return new Jc(e.root,e.path,e.stickiness);{const n=e;if("end"==t)t=n.maxOffset;else{if("before"==t)return this._createBefore(n,i);if("after"==t)return this._createAfter(n,i);if(0!==t&&!t)throw new p("model-createpositionat-offset-required",[this,e])}if(!n.is("element")&&!n.is("documentFragment"))throw new p("model-position-parent-incorrect",[this,e]);const s=n.getPath();return s.push(t),new this(n.root,s,i)}}static _createAfter(e,t){if(!e.parent)throw new p("model-position-after-root",[this,e],{root:e});return this._createAt(e.parent,e.endOffset,t)}static _createBefore(e,t){if(!e.parent)throw new p("model-position-before-root",e,{root:e});return this._createAt(e.parent,e.startOffset,t)}static fromJSON(e,t){if("$graveyard"===e.root){const i=new Jc(t.graveyard,e.path);return i.stickiness=e.stickiness,i}if(!t.getRoot(e.root))throw new p("model-position-fromjson-no-root",t,{rootName:e.root});return new Jc(t.getRoot(e.root),e.path,e.stickiness)}constructor(e,t,i="toNone"){if(super(),!e.is("element")&&!e.is("documentFragment"))throw new p("model-position-root-invalid",e);if(!(t instanceof Array)||0===t.length)throw new p("model-position-path-incorrect-format",e,{path:t});e.is("rootElement")?t=t.slice():(t=[...e.getPath(),...t],e=e.root),this.root=e,this.path=t,this.stickiness=i}}function Qc(e,t){const i=t.getChild(t.offsetToIndex(e.offset));return i&&i.is("$text")&&i.startOffset<e.offset?i:null}function Yc(e,t,i){return null!==i?null:t.getChild(t.offsetToIndex(e.offset))}function Xc(e,t,i){return null!==i?null:t.getChild(t.offsetToIndex(e.offset)-1)}function ed(e,t,i){return i+1!==e.path.length&&(!!td(t.path,i+1)&&!!function(e,t){let i=e.parent,n=e.path.length-1,s=0;for(;n>=t;){if(e.path[n]+s!==i.maxOffset)return!1;s=1,n--,i=i.parent}return!0}(e,i+1))}function td(e,t){for(;t<e.length;){if(0!==e[t])return!1;t++}return!0}Jc.prototype.is=function(e){return"position"===e||"model:position"===e};class id extends $c{*[Symbol.iterator](){yield*new Kc({boundaries:this,ignoreElementEnd:!0})}get isCollapsed(){return this.start.isEqual(this.end)}get isFlat(){return"same"==ar(this.start.getParentPath(),this.end.getParentPath())}get root(){return this.start.root}containsPosition(e){return e.isAfter(this.start)&&e.isBefore(this.end)}containsRange(e,t=!1){e.isCollapsed&&(t=!1);const i=this.containsPosition(e.start)||t&&this.start.isEqual(e.start),n=this.containsPosition(e.end)||t&&this.end.isEqual(e.end);return i&&n}containsItem(e){const t=Jc._createBefore(e);return this.containsPosition(t)||this.start.isEqual(t)}isEqual(e){return this.start.isEqual(e.start)&&this.end.isEqual(e.end)}isIntersecting(e){return this.start.isBefore(e.end)&&this.end.isAfter(e.start)}getDifference(e){const t=[];return this.isIntersecting(e)?(this.containsPosition(e.start)&&t.push(new id(this.start,e.start)),this.containsPosition(e.end)&&t.push(new id(e.end,this.end))):t.push(new id(this.start,this.end)),t}getIntersection(e){if(this.isIntersecting(e)){let t=this.start,i=this.end;return this.containsPosition(e.start)&&(t=e.start),this.containsPosition(e.end)&&(i=e.end),new id(t,i)}return null}getJoined(e,t=!1){let i=this.isIntersecting(e);if(i||(i=this.start.isBefore(e.start)?t?this.end.isTouching(e.start):this.end.isEqual(e.start):t?e.end.isTouching(this.start):e.end.isEqual(this.start)),!i)return null;let n=this.start,s=this.end;return e.start.isBefore(n)&&(n=e.start),e.end.isAfter(s)&&(s=e.end),new id(n,s)}getMinimalFlatRanges(){const e=[],t=this.start.getCommonPath(this.end).length,i=Jc._createAt(this.start);let n=i.parent;for(;i.path.length>t+1;){const t=n.maxOffset-i.offset;0!==t&&e.push(new id(i,i.getShiftedBy(t))),i.path=i.path.slice(0,-1),i.offset++,n=n.parent}for(;i.path.length<=this.end.path.length;){const t=this.end.path[i.path.length-1],n=t-i.offset;0!==n&&e.push(new id(i,i.getShiftedBy(n))),i.offset=t,i.path.push(0)}return e}getWalker(e={}){return e.boundaries=this,new Kc(e)}*getItems(e={}){e.boundaries=this,e.ignoreElementEnd=!0;const t=new Kc(e);for(const e of t)yield e.item}*getPositions(e={}){e.boundaries=this;const t=new Kc(e);yield t.position;for(const e of t)yield e.nextPosition}getTransformedByOperation(e){switch(e.type){case"insert":return this._getTransformedByInsertOperation(e);case"move":case"remove":case"reinsert":return this._getTransformedByMoveOperation(e);case"split":return[this._getTransformedBySplitOperation(e)];case"merge":return[this._getTransformedByMergeOperation(e)]}return[new id(this.start,this.end)]}getTransformedByOperations(e){const t=[new id(this.start,this.end)];for(const i of e)for(let e=0;e<t.length;e++){const n=t[e].getTransformedByOperation(i);t.splice(e,1,...n),e+=n.length-1}for(let e=0;e<t.length;e++){const i=t[e];for(let n=e+1;n<t.length;n++){const e=t[n];(i.containsRange(e)||e.containsRange(i)||i.isEqual(e))&&t.splice(n,1)}}return t}getCommonAncestor(){return this.start.getCommonAncestor(this.end)}getContainedElement(){if(this.isCollapsed)return null;const e=this.start.nodeAfter,t=this.end.nodeBefore;return e&&e.is("element")&&e===t?e:null}toJSON(){return{start:this.start.toJSON(),end:this.end.toJSON()}}clone(){return new this.constructor(this.start,this.end)}_getTransformedByInsertOperation(e,t=!1){return this._getTransformedByInsertion(e.position,e.howMany,t)}_getTransformedByMoveOperation(e,t=!1){const i=e.sourcePosition,n=e.howMany,s=e.targetPosition;return this._getTransformedByMove(i,s,n,t)}_getTransformedBySplitOperation(e){const t=this.start._getTransformedBySplitOperation(e);let i=this.end._getTransformedBySplitOperation(e);return this.end.isEqual(e.insertionPosition)&&(i=this.end.getShiftedBy(1)),t.root!=i.root&&(i=this.end.getShiftedBy(-1)),new id(t,i)}_getTransformedByMergeOperation(e){if(this.start.isEqual(e.targetPosition)&&this.end.isEqual(e.deletionPosition))return new id(this.start);let t=this.start._getTransformedByMergeOperation(e),i=this.end._getTransformedByMergeOperation(e);return t.root!=i.root&&(i=this.end.getShiftedBy(-1)),t.isAfter(i)?(e.sourcePosition.isBefore(e.targetPosition)?(t=Jc._createAt(i),t.offset=0):(e.deletionPosition.isEqual(t)||(i=e.deletionPosition),t=e.targetPosition),new id(t,i)):new id(t,i)}_getTransformedByInsertion(e,t,i=!1){if(i&&this.containsPosition(e))return[new id(this.start,e),new id(e.getShiftedBy(t),this.end._getTransformedByInsertion(e,t))];{const i=new id(this.start,this.end);return i.start=i.start._getTransformedByInsertion(e,t),i.end=i.end._getTransformedByInsertion(e,t),[i]}}_getTransformedByMove(e,t,i,n=!1){if(this.isCollapsed){const n=this.start._getTransformedByMove(e,t,i);return[new id(n)]}const s=id._createFromPositionAndShift(e,i),o=t._getTransformedByDeletion(e,i);if(this.containsPosition(t)&&!n&&(s.containsPosition(this.start)||s.containsPosition(this.end))){const n=this.start._getTransformedByMove(e,t,i),s=this.end._getTransformedByMove(e,t,i);return[new id(n,s)]}let r;const a=this.getDifference(s);let l=null;const c=this.getIntersection(s);if(1==a.length?l=new id(a[0].start._getTransformedByDeletion(e,i),a[0].end._getTransformedByDeletion(e,i)):2==a.length&&(l=new id(this.start,this.end._getTransformedByDeletion(e,i))),r=l?l._getTransformedByInsertion(o,i,null!==c||n):[],c){const e=new id(c.start._getCombined(s.start,o),c.end._getCombined(s.start,o));2==r.length?r.splice(1,0,e):r.push(e)}return r}_getTransformedByDeletion(e,t){let i=this.start._getTransformedByDeletion(e,t),n=this.end._getTransformedByDeletion(e,t);return null==i&&null==n?null:(null==i&&(i=e),null==n&&(n=e),new id(i,n))}static _createFromPositionAndShift(e,t){const i=e,n=e.getShiftedBy(t);return t>0?new this(i,n):new this(n,i)}static _createIn(e){return new this(Jc._createAt(e,0),Jc._createAt(e,e.maxOffset))}static _createOn(e){return this._createFromPositionAndShift(Jc._createBefore(e),e.offsetSize)}static _createFromRanges(e){if(0===e.length)throw new p("range-create-from-ranges-empty-array",null);if(1==e.length)return e[0].clone();const t=e[0];e.sort(((e,t)=>e.start.isAfter(t.start)?1:-1));const i=e.indexOf(t),n=new this(t.start,t.end);if(i>0)for(let t=i-1;e[t].end.isEqual(n.start);t++)n.start=Jc._createAt(e[t].start);for(let t=i+1;t<e.length&&e[t].start.isEqual(n.end);t++)n.end=Jc._createAt(e[t].end);return n}static fromJSON(e,t){return new this(Jc.fromJSON(e.start,t),Jc.fromJSON(e.end,t))}constructor(e,t){super(),this.start=Jc._createAt(e),this.end=t?Jc._createAt(t):Jc._createAt(e),this.start.stickiness=this.isCollapsed?"toNone":"toNext",this.end.stickiness=this.isCollapsed?"toNone":"toPrevious"}}id.prototype.is=function(e){return"range"===e||"model:range"===e};class nd extends(T()){bindElements(e,t){this._modelToViewMapping.set(e,t),this._viewToModelMapping.set(t,e)}unbindViewElement(e,t={}){const i=this.toModelElement(e);if(this._elementToMarkerNames.has(e))for(const t of this._elementToMarkerNames.get(e))this._unboundMarkerNames.add(t);t.defer?this._deferredBindingRemovals.set(e,e.root):(this._viewToModelMapping.delete(e),this._modelToViewMapping.get(i)==e&&this._modelToViewMapping.delete(i))}unbindModelElement(e){const t=this.toViewElement(e);this._modelToViewMapping.delete(e),this._viewToModelMapping.get(t)==e&&this._viewToModelMapping.delete(t)}bindElementToMarker(e,t){const i=this._markerNameToElements.get(t)||new Set;i.add(e);const n=this._elementToMarkerNames.get(e)||new Set;n.add(t),this._markerNameToElements.set(t,i),this._elementToMarkerNames.set(e,n)}unbindElementFromMarkerName(e,t){const i=this._markerNameToElements.get(t);i&&(i.delete(e),0==i.size&&this._markerNameToElements.delete(t));const n=this._elementToMarkerNames.get(e);n&&(n.delete(t),0==n.size&&this._elementToMarkerNames.delete(e))}flushUnboundMarkerNames(){const e=Array.from(this._unboundMarkerNames);return this._unboundMarkerNames.clear(),e}flushDeferredBindings(){for(const[e,t]of this._deferredBindingRemovals)e.root==t&&this.unbindViewElement(e);this._deferredBindingRemovals=new Map}clearBindings(){this._modelToViewMapping=new WeakMap,this._viewToModelMapping=new WeakMap,this._markerNameToElements=new Map,this._elementToMarkerNames=new Map,this._unboundMarkerNames=new Set,this._deferredBindingRemovals=new Map}toModelElement(e){return this._viewToModelMapping.get(e)}toViewElement(e){return this._modelToViewMapping.get(e)}toModelRange(e){return new id(this.toModelPosition(e.start),this.toModelPosition(e.end))}toViewRange(e){return new yl(this.toViewPosition(e.start),this.toViewPosition(e.end))}toModelPosition(e){const t={viewPosition:e,mapper:this};return this.fire("viewToModelPosition",t),t.modelPosition}toViewPosition(e,t={}){const i={modelPosition:e,mapper:this,isPhantom:t.isPhantom};return this.fire("modelToViewPosition",i),i.viewPosition}markerNameToElements(e){const t=this._markerNameToElements.get(e);if(!t)return null;const i=new Set;for(const e of t)if(e.is("attributeElement"))for(const t of e.getElementsWithSameId())i.add(t);else i.add(e);return i}registerViewToModelLength(e,t){this._viewToModelLengthCallbacks.set(e,t)}findMappedViewAncestor(e){let t=e.parent;for(;!this._viewToModelMapping.has(t);)t=t.parent;return t}_toModelOffset(e,t,i){if(i!=e){return this._toModelOffset(e.parent,e.index,i)+this._toModelOffset(e,t,e)}if(e.is("$text"))return t;let n=0;for(let i=0;i<t;i++)n+=this.getModelLength(e.getChild(i));return n}getModelLength(e){if(this._viewToModelLengthCallbacks.get(e.name)){return this._viewToModelLengthCallbacks.get(e.name)(e)}if(this._viewToModelMapping.has(e))return 1;if(e.is("$text"))return e.data.length;if(e.is("uiElement"))return 0;{let t=0;for(const i of e.getChildren())t+=this.getModelLength(i);return t}}findPositionIn(e,t){let i,n=0,s=0,o=0;if(e.is("$text"))return new _l(e,t);for(;s<t;)i=e.getChild(o),n=this.getModelLength(i),s+=n,o++;return s==t?this._moveViewPositionToTextNode(new _l(e,o)):this.findPositionIn(i,t-(s-n))}_moveViewPositionToTextNode(e){const t=e.nodeBefore,i=e.nodeAfter;return t instanceof nl?new _l(t,t.data.length):i instanceof nl?new _l(i,0):e}constructor(){super(),this._modelToViewMapping=new WeakMap,this._viewToModelMapping=new WeakMap,this._viewToModelLengthCallbacks=new Map,this._markerNameToElements=new Map,this._elementToMarkerNames=new Map,this._deferredBindingRemovals=new Map,this._unboundMarkerNames=new Set,this.on("modelToViewPosition",((e,t)=>{if(t.viewPosition)return;const i=this._modelToViewMapping.get(t.modelPosition.parent);if(!i)throw new p("mapping-model-position-view-parent-not-found",this,{modelPosition:t.modelPosition});t.viewPosition=this.findPositionIn(i,t.modelPosition.offset)}),{priority:"low"}),this.on("viewToModelPosition",((e,t)=>{if(t.modelPosition)return;const i=this.findMappedViewAncestor(t.viewPosition),n=this._viewToModelMapping.get(i),s=this._toModelOffset(t.viewPosition.parent,t.viewPosition.offset,i);t.modelPosition=Jc._createAt(n,s)}),{priority:"low"})}}class sd{add(e,t){t=od(t),e instanceof qc&&(e=this._getSymbolForTextProxy(e)),this._consumable.has(e)||this._consumable.set(e,new Map),this._consumable.get(e).set(t,!0)}consume(e,t){return t=od(t),e instanceof qc&&(e=this._getSymbolForTextProxy(e)),!!this.test(e,t)&&(this._consumable.get(e).set(t,!1),!0)}test(e,t){t=od(t),e instanceof qc&&(e=this._getSymbolForTextProxy(e));const i=this._consumable.get(e);if(void 0===i)return null;const n=i.get(t);return void 0===n?null:n}revert(e,t){t=od(t),e instanceof qc&&(e=this._getSymbolForTextProxy(e));const i=this.test(e,t);return!1===i?(this._consumable.get(e).set(t,!0),!0):!0!==i&&null}verifyAllConsumed(e){const t=[];for(const[i,n]of this._consumable)for(const[s,o]of n){const n=s.split(":")[0];o&&e==n&&t.push({event:s,item:i.name||i.description})}if(t.length)throw new p("conversion-model-consumable-not-consumed",null,{items:t})}_getSymbolForTextProxy(e){let t=null;const i=this._textProxyRegistry.get(e.startOffset);if(i){const n=i.get(e.endOffset);n&&(t=n.get(e.parent))}return t||(t=this._addSymbolForTextProxy(e)),t}_addSymbolForTextProxy(e){const t=e.startOffset,i=e.endOffset,n=e.parent,s=Symbol("$textProxy:"+e.data);let o,r;return o=this._textProxyRegistry.get(t),o||(o=new Map,this._textProxyRegistry.set(t,o)),r=o.get(i),r||(r=new Map,o.set(i,r)),r.set(n,s),s}constructor(){this._consumable=new Map,this._textProxyRegistry=new Map}}function od(e){const t=e.split(":");return"insert"==t[0]?t[0]:"addMarker"==t[0]||"removeMarker"==t[0]?e:t.length>1?t[0]+":"+t[1]:t[0]}class rd extends(T()){convertChanges(e,t,i){const n=this._createConversionApi(i,e.getRefreshedItems());for(const t of e.getMarkersToRemove())this._convertMarkerRemove(t.name,t.range,n);const s=this._reduceChanges(e.getChanges());for(const e of s)"insert"===e.type?this._convertInsert(id._createFromPositionAndShift(e.position,e.length),n):"reinsert"===e.type?this._convertReinsert(id._createFromPositionAndShift(e.position,e.length),n):"remove"===e.type?this._convertRemove(e.position,e.length,e.name,n):this._convertAttribute(e.range,e.attributeKey,e.attributeOldValue,e.attributeNewValue,n);n.mapper.flushDeferredBindings();for(const e of n.mapper.flushUnboundMarkerNames()){const i=t.get(e).getRange();this._convertMarkerRemove(e,i,n),this._convertMarkerAdd(e,i,n)}for(const t of e.getMarkersToAdd())this._convertMarkerAdd(t.name,t.range,n);n.consumable.verifyAllConsumed("insert")}convert(e,t,i,n={}){const s=this._createConversionApi(i,void 0,n);this._convertInsert(e,s);for(const[e,i]of t)this._convertMarkerAdd(e,i,s);s.consumable.verifyAllConsumed("insert")}convertSelection(e,t,i){const n=this._createConversionApi(i);this.fire("cleanSelection",{selection:e},n);const s=e.getFirstPosition().root;if(!n.mapper.toViewElement(s))return;const o=Array.from(t.getMarkersAtPosition(e.getFirstPosition()));if(this._addConsumablesForSelection(n.consumable,e,o),this.fire("selection",{selection:e},n),e.isCollapsed){for(const t of o)if(n.consumable.test(e,"addMarker:"+t.name)){const i=t.getRange();if(!ad(e.getFirstPosition(),t,n.mapper))continue;const s={item:e,markerName:t.name,markerRange:i};this.fire(`addMarker:${t.name}`,s,n)}for(const t of e.getAttributeKeys())if(n.consumable.test(e,"attribute:"+t)){const i={item:e,range:e.getFirstRange(),attributeKey:t,attributeOldValue:null,attributeNewValue:e.getAttribute(t)};this.fire(`attribute:${t}:$text`,i,n)}}}_convertInsert(e,t,i={}){i.doNotAddConsumables||this._addConsumablesForInsert(t.consumable,e);for(const i of Array.from(e.getWalker({shallow:!0})).map(ld))this._testAndFire("insert",i,t)}_convertRemove(e,t,i,n){this.fire(`remove:${i}`,{position:e,length:t},n)}_convertAttribute(e,t,i,n,s){this._addConsumablesForRange(s.consumable,e,`attribute:${t}`);for(const o of e){const e={item:o.item,range:id._createFromPositionAndShift(o.previousPosition,o.length),attributeKey:t,attributeOldValue:i,attributeNewValue:n};this._testAndFire(`attribute:${t}`,e,s)}}_convertReinsert(e,t){const i=Array.from(e.getWalker({shallow:!0}));this._addConsumablesForInsert(t.consumable,i);for(const e of i.map(ld))this._testAndFire("insert",{...e,reconversion:!0},t)}_convertMarkerAdd(e,t,i){if("$graveyard"==t.root.rootName)return;const n=`addMarker:${e}`;if(i.consumable.add(t,n),this.fire(n,{markerName:e,markerRange:t},i),i.consumable.consume(t,n)){this._addConsumablesForRange(i.consumable,t,n);for(const s of t.getItems()){if(!i.consumable.test(s,n))continue;const o={item:s,range:id._createOn(s),markerName:e,markerRange:t};this.fire(n,o,i)}}}_convertMarkerRemove(e,t,i){"$graveyard"!=t.root.rootName&&this.fire(`removeMarker:${e}`,{markerName:e,markerRange:t},i)}_reduceChanges(e){const t={changes:e};return this.fire("reduceChanges",t),t.changes}_addConsumablesForInsert(e,t){for(const i of t){const t=i.item;if(null===e.test(t,"insert")){e.add(t,"insert");for(const i of t.getAttributeKeys())e.add(t,"attribute:"+i)}}return e}_addConsumablesForRange(e,t,i){for(const n of t.getItems())e.add(n,i);return e}_addConsumablesForSelection(e,t,i){e.add(t,"selection");for(const n of i)e.add(t,"addMarker:"+n.name);for(const i of t.getAttributeKeys())e.add(t,"attribute:"+i);return e}_testAndFire(e,t,i){const n=function(e,t){const i=t.item.is("element")?t.item.name:"$text";return`${e}:${i}`}(e,t),s=t.item.is("$textProxy")?i.consumable._getSymbolForTextProxy(t.item):t.item,o=this._firedEventsMap.get(i),r=o.get(s);if(r){if(r.has(n))return;r.add(n)}else o.set(s,new Set([n]));this.fire(n,t,i)}_testAndFireAddAttributes(e,t){const i={item:e,range:id._createOn(e)};for(const e of i.item.getAttributeKeys())i.attributeKey=e,i.attributeOldValue=null,i.attributeNewValue=i.item.getAttribute(e),this._testAndFire(`attribute:${e}`,i,t)}_createConversionApi(e,t=new Set,i={}){const n={...this._conversionApi,consumable:new sd,writer:e,options:i,convertItem:e=>this._convertInsert(id._createOn(e),n),convertChildren:e=>this._convertInsert(id._createIn(e),n,{doNotAddConsumables:!0}),convertAttributes:e=>this._testAndFireAddAttributes(e,n),canReuseView:e=>!t.has(n.mapper.toModelElement(e))};return this._firedEventsMap.set(n,new Map),n}constructor(e){super(),this._conversionApi={dispatcher:this,...e},this._firedEventsMap=new WeakMap}}function ad(e,t,i){const n=t.getRange(),s=Array.from(e.getAncestors());s.shift(),s.reverse();return!s.some((e=>{if(n.containsItem(e)){return!!i.toViewElement(e).getCustomProperty("addHighlight")}}))}function ld(e){return{item:e.item,range:id._createFromPositionAndShift(e.previousPosition,e.length)}}class cd extends(T($c)){get anchor(){if(this._ranges.length>0){const e=this._ranges[this._ranges.length-1];return this._lastRangeBackward?e.end:e.start}return null}get focus(){if(this._ranges.length>0){const e=this._ranges[this._ranges.length-1];return this._lastRangeBackward?e.start:e.end}return null}get isCollapsed(){return 1===this._ranges.length&&this._ranges[0].isCollapsed}get rangeCount(){return this._ranges.length}get isBackward(){return!this.isCollapsed&&this._lastRangeBackward}isEqual(e){if(this.rangeCount!=e.rangeCount)return!1;if(0===this.rangeCount)return!0;if(!this.anchor.isEqual(e.anchor)||!this.focus.isEqual(e.focus))return!1;for(const t of this._ranges){let i=!1;for(const n of e._ranges)if(t.isEqual(n)){i=!0;break}if(!i)return!1}return!0}*getRanges(){for(const e of this._ranges)yield new id(e.start,e.end)}getFirstRange(){let e=null;for(const t of this._ranges)e&&!t.start.isBefore(e.start)||(e=t);return e?new id(e.start,e.end):null}getLastRange(){let e=null;for(const t of this._ranges)e&&!t.end.isAfter(e.end)||(e=t);return e?new id(e.start,e.end):null}getFirstPosition(){const e=this.getFirstRange();return e?e.start.clone():null}getLastPosition(){const e=this.getLastRange();return e?e.end.clone():null}setTo(...e){let[t,i,n]=e;if("object"==typeof i&&(n=i,i=void 0),null===t)this._setRanges([]);else if(t instanceof cd)this._setRanges(t.getRanges(),t.isBackward);else if(t&&"function"==typeof t.getRanges)this._setRanges(t.getRanges(),t.isBackward);else if(t instanceof id)this._setRanges([t],!!n&&!!n.backward);else if(t instanceof Jc)this._setRanges([new id(t)]);else if(t instanceof Uc){const e=!!n&&!!n.backward;let s;if("in"==i)s=id._createIn(t);else if("on"==i)s=id._createOn(t);else{if(void 0===i)throw new p("model-selection-setto-required-second-parameter",[this,t]);s=new id(Jc._createAt(t,i))}this._setRanges([s],e)}else{if(!lr(t))throw new p("model-selection-setto-not-selectable",[this,t]);this._setRanges(t,n&&!!n.backward)}}_setRanges(e,t=!1){const i=Array.from(e),n=i.some((t=>{if(!(t instanceof id))throw new p("model-selection-set-ranges-not-range",[this,e]);return this._ranges.every((e=>!e.isEqual(t)))}));(i.length!==this._ranges.length||n)&&(this._replaceAllRanges(i),this._lastRangeBackward=!!t,this.fire("change:range",{directChange:!0}))}setFocus(e,t){if(null===this.anchor)throw new p("model-selection-setfocus-no-ranges",[this,e]);const i=Jc._createAt(e,t);if("same"==i.compareWith(this.focus))return;const n=this.anchor;this._ranges.length&&this._popRange(),"before"==i.compareWith(n)?(this._pushRange(new id(i,n)),this._lastRangeBackward=!0):(this._pushRange(new id(n,i)),this._lastRangeBackward=!1),this.fire("change:range",{directChange:!0})}getAttribute(e){return this._attrs.get(e)}getAttributes(){return this._attrs.entries()}getAttributeKeys(){return this._attrs.keys()}hasAttribute(e){return this._attrs.has(e)}removeAttribute(e){this.hasAttribute(e)&&(this._attrs.delete(e),this.fire("change:attribute",{attributeKeys:[e],directChange:!0}))}setAttribute(e,t){this.getAttribute(e)!==t&&(this._attrs.set(e,t),this.fire("change:attribute",{attributeKeys:[e],directChange:!0}))}getSelectedElement(){return 1!==this.rangeCount?null:this.getFirstRange().getContainedElement()}*getSelectedBlocks(){const e=new WeakSet;for(const t of this.getRanges()){const i=ud(t.start,e);gd(i,t)&&(yield i);for(const i of t.getWalker()){const n=i.item;"elementEnd"==i.type&&hd(n,e,t)&&(yield n)}const n=ud(t.end,e);fd(n,t)&&(yield n)}}containsEntireContent(e=this.anchor.root){const t=Jc._createAt(e,0),i=Jc._createAt(e,"end");return t.isTouching(this.getFirstPosition())&&i.isTouching(this.getLastPosition())}_pushRange(e){this._checkRange(e),this._ranges.push(new id(e.start,e.end))}_checkRange(e){for(let t=0;t<this._ranges.length;t++)if(e.isIntersecting(this._ranges[t]))throw new p("model-selection-range-intersects",[this,e],{addedRange:e,intersectingRange:this._ranges[t]})}_replaceAllRanges(e){this._removeAllRanges();for(const t of e)this._pushRange(t)}_removeAllRanges(){for(;this._ranges.length>0;)this._popRange()}_popRange(){this._ranges.pop()}constructor(...e){super(),this._lastRangeBackward=!1,this._attrs=new Map,this._ranges=[],e.length&&this.setTo(...e)}}function dd(e,t){return!t.has(e)&&(t.add(e),e.root.document.model.schema.isBlock(e)&&!!e.parent)}function hd(e,t,i){return dd(e,t)&&md(e,i)}function ud(e,t){const i=e.parent.root.document.model.schema,n=e.parent.getAncestors({parentFirst:!0,includeSelf:!0});let s=!1;const o=n.find((e=>!s&&(s=i.isLimit(e),!s&&dd(e,t))));return n.forEach((e=>t.add(e))),o}function md(e,t){const i=function(e){const t=e.root.document.model.schema;let i=e.parent;for(;i;){if(t.isBlock(i))return i;i=i.parent}}(e);if(!i)return!0;return!t.containsRange(id._createOn(i),!0)}function gd(e,t){return!!e&&(!(!t.isCollapsed&&!e.isEmpty)||!t.start.isTouching(Jc._createAt(e,e.maxOffset))&&md(e,t))}function fd(e,t){return!!e&&(!(!t.isCollapsed&&!e.isEmpty)||!t.end.isTouching(Jc._createAt(e,0))&&md(e,t))}cd.prototype.is=function(e){return"selection"===e||"model:selection"===e};class pd extends(T(id)){detach(){this.stopListening()}toRange(){return new id(this.start,this.end)}static fromRange(e){return new pd(e.start,e.end)}constructor(e,t){super(e,t),bd.call(this)}}function bd(){this.listenTo(this.root.document.model,"applyOperation",((e,t)=>{const i=t[0];i.isDocumentOperation&&wd.call(this,i)}),{priority:"low"})}function wd(e){const t=this.getTransformedByOperation(e),i=id._createFromRanges(t),n=!i.isEqual(this),s=function(e,t){switch(t.type){case"insert":return e.containsPosition(t.position);case"move":case"remove":case"reinsert":case"merge":return e.containsPosition(t.sourcePosition)||e.start.isEqual(t.sourcePosition)||e.containsPosition(t.targetPosition);case"split":return e.containsPosition(t.splitPosition)||e.containsPosition(t.insertionPosition)}return!1}(this,e);let o=null;if(n){"$graveyard"==i.root.rootName&&(o="remove"==e.type?e.sourcePosition:e.deletionPosition);const t=this.toRange();this.start=i.start,this.end=i.end,this.fire("change:range",t,{deletionPosition:o})}else s&&this.fire("change:content",this.toRange(),{deletionPosition:o})}pd.prototype.is=function(e){return"liveRange"===e||"model:liveRange"===e||"range"==e||"model:range"===e};const vd="selection:";class _d extends(T($c)){get isCollapsed(){return this._selection.isCollapsed}get anchor(){return this._selection.anchor}get focus(){return this._selection.focus}get rangeCount(){return this._selection.rangeCount}get hasOwnRange(){return this._selection.hasOwnRange}get isBackward(){return this._selection.isBackward}get isGravityOverridden(){return this._selection.isGravityOverridden}get markers(){return this._selection.markers}get _ranges(){return this._selection._ranges}getRanges(){return this._selection.getRanges()}getFirstPosition(){return this._selection.getFirstPosition()}getLastPosition(){return this._selection.getLastPosition()}getFirstRange(){return this._selection.getFirstRange()}getLastRange(){return this._selection.getLastRange()}getSelectedBlocks(){return this._selection.getSelectedBlocks()}getSelectedElement(){return this._selection.getSelectedElement()}containsEntireContent(e){return this._selection.containsEntireContent(e)}destroy(){this._selection.destroy()}getAttributeKeys(){return this._selection.getAttributeKeys()}getAttributes(){return this._selection.getAttributes()}getAttribute(e){return this._selection.getAttribute(e)}hasAttribute(e){return this._selection.hasAttribute(e)}refresh(){this._selection.updateMarkers(),this._selection._updateAttributes(!1)}observeMarkers(e){this._selection.observeMarkers(e)}_setFocus(e,t){this._selection.setFocus(e,t)}_setTo(...e){this._selection.setTo(...e)}_setAttribute(e,t){this._selection.setAttribute(e,t)}_removeAttribute(e){this._selection.removeAttribute(e)}_getStoredAttributes(){return this._selection.getStoredAttributes()}_overrideGravity(){return this._selection.overrideGravity()}_restoreGravity(e){this._selection.restoreGravity(e)}static _getStoreAttributeKey(e){return vd+e}static _isStoreAttributeKey(e){return e.startsWith(vd)}constructor(e){super(),this._selection=new yd(e),this._selection.delegate("change:range").to(this),this._selection.delegate("change:attribute").to(this),this._selection.delegate("change:marker").to(this)}}_d.prototype.is=function(e){return"selection"===e||"model:selection"==e||"documentSelection"==e||"model:documentSelection"==e};class yd extends cd{get isCollapsed(){return 0===this._ranges.length?this._document._getDefaultRange().isCollapsed:super.isCollapsed}get anchor(){return super.anchor||this._document._getDefaultRange().start}get focus(){return super.focus||this._document._getDefaultRange().end}get rangeCount(){return this._ranges.length?this._ranges.length:1}get hasOwnRange(){return this._ranges.length>0}get isGravityOverridden(){return!!this._overriddenGravityRegister.size}destroy(){for(let e=0;e<this._ranges.length;e++)this._ranges[e].detach();this.stopListening()}*getRanges(){this._ranges.length?yield*super.getRanges():yield this._document._getDefaultRange()}getFirstRange(){return super.getFirstRange()||this._document._getDefaultRange()}getLastRange(){return super.getLastRange()||this._document._getDefaultRange()}setTo(...e){super.setTo(...e),this._updateAttributes(!0),this.updateMarkers()}setFocus(e,t){super.setFocus(e,t),this._updateAttributes(!0),this.updateMarkers()}setAttribute(e,t){if(this._setAttribute(e,t)){const t=[e];this.fire("change:attribute",{attributeKeys:t,directChange:!0})}}removeAttribute(e){if(this._removeAttribute(e)){const t=[e];this.fire("change:attribute",{attributeKeys:t,directChange:!0})}}overrideGravity(){const e=u();return this._overriddenGravityRegister.add(e),1===this._overriddenGravityRegister.size&&this._updateAttributes(!0),e}restoreGravity(e){if(!this._overriddenGravityRegister.has(e))throw new p("document-selection-gravity-wrong-restore",this,{uid:e});this._overriddenGravityRegister.delete(e),this.isGravityOverridden||this._updateAttributes(!0)}observeMarkers(e){this._observedMarkers.add(e),this.updateMarkers()}_replaceAllRanges(e){this._validateSelectionRanges(e),super._replaceAllRanges(e)}_popRange(){this._ranges.pop().detach()}_pushRange(e){const t=this._prepareRange(e);t&&this._ranges.push(t)}_validateSelectionRanges(e){for(const t of e)if(!this._document._validateSelectionRange(t))throw new p("document-selection-wrong-position",this,{range:t})}_prepareRange(e){if(this._checkRange(e),e.root==this._document.graveyard)return;const t=pd.fromRange(e);return t.on("change:range",((e,i,n)=>{if(this._hasChangedRange=!0,t.root==this._document.graveyard){this._selectionRestorePosition=n.deletionPosition;const e=this._ranges.indexOf(t);this._ranges.splice(e,1),t.detach()}})),t}updateMarkers(){if(!this._observedMarkers.size)return;const e=[];let t=!1;for(const t of this._model.markers){const i=t.name.split(":",1)[0];if(!this._observedMarkers.has(i))continue;const n=t.getRange();for(const i of this.getRanges())n.containsRange(i,!i.isCollapsed)&&e.push(t)}const i=Array.from(this.markers);for(const i of e)this.markers.has(i)||(this.markers.add(i),t=!0);for(const i of Array.from(this.markers))e.includes(i)||(this.markers.remove(i),t=!0);t&&this.fire("change:marker",{oldMarkers:i,directChange:!1})}_updateMarker(e,t){const i=e.name.split(":",1)[0];if(!this._observedMarkers.has(i))return;let n=!1;const s=Array.from(this.markers),o=this.markers.has(e);if(t){let i=!1;for(const e of this.getRanges())if(t.containsRange(e,!e.isCollapsed)){i=!0;break}i&&!o?(this.markers.add(e),n=!0):!i&&o&&(this.markers.remove(e),n=!0)}else o&&(this.markers.remove(e),n=!0);n&&this.fire("change:marker",{oldMarkers:s,directChange:!1})}_updateAttributes(e){const t=Ca(this._getSurroundingAttributes()),i=Ca(this.getAttributes());if(e)this._attributePriority=new Map,this._attrs=new Map;else for(const[e,t]of this._attributePriority)"low"==t&&(this._attrs.delete(e),this._attributePriority.delete(e));this._setAttributesTo(t);const n=[];for(const[e,t]of this.getAttributes())i.has(e)&&i.get(e)===t||n.push(e);for(const[e]of i)this.hasAttribute(e)||n.push(e);n.length>0&&this.fire("change:attribute",{attributeKeys:n,directChange:!1})}_setAttribute(e,t,i=!0){const n=i?"normal":"low";if("low"==n&&"normal"==this._attributePriority.get(e))return!1;return super.getAttribute(e)!==t&&(this._attrs.set(e,t),this._attributePriority.set(e,n),!0)}_removeAttribute(e,t=!0){const i=t?"normal":"low";return("low"!=i||"normal"!=this._attributePriority.get(e))&&(this._attributePriority.set(e,i),!!super.hasAttribute(e)&&(this._attrs.delete(e),!0))}_setAttributesTo(e){const t=new Set;for(const[t,i]of this.getAttributes())e.get(t)!==i&&this._removeAttribute(t,!1);for(const[i,n]of e){this._setAttribute(i,n,!1)&&t.add(i)}return t}*getStoredAttributes(){const e=this.getFirstPosition().parent;if(this.isCollapsed&&e.isEmpty)for(const t of e.getAttributeKeys())if(t.startsWith(vd)){const i=t.substr(10);yield[i,e.getAttribute(t)]}}_getSurroundingAttributes(){const e=this.getFirstPosition(),t=this._model.schema;if("$graveyard"==e.root.rootName)return null;let i=null;if(this.isCollapsed){const n=e.textNode?e.textNode:e.nodeBefore,s=e.textNode?e.textNode:e.nodeAfter;if(this.isGravityOverridden||(i=kd(n,t)),i||(i=kd(s,t)),!this.isGravityOverridden&&!i){let e=n;for(;e&&!i;)e=e.previousSibling,i=kd(e,t)}if(!i){let e=s;for(;e&&!i;)e=e.nextSibling,i=kd(e,t)}i||(i=this.getStoredAttributes())}else{const e=this.getFirstRange();for(const n of e){if(n.item.is("element")&&t.isObject(n.item)){i=kd(n.item,t);break}if("text"==n.type){i=n.item.getAttributes();break}}}return i}_fixGraveyardSelection(e){const t=this._model.schema.getNearestSelectionRange(e);t&&this._pushRange(t)}constructor(e){super(),this.markers=new va({idProperty:"name"}),this._attributePriority=new Map,this._selectionRestorePosition=null,this._hasChangedRange=!1,this._overriddenGravityRegister=new Set,this._observedMarkers=new Set,this._model=e.model,this._document=e,this.listenTo(this._model,"applyOperation",((e,t)=>{const i=t[0];i.isDocumentOperation&&"marker"!=i.type&&"rename"!=i.type&&"noop"!=i.type&&(0==this._ranges.length&&this._selectionRestorePosition&&this._fixGraveyardSelection(this._selectionRestorePosition),this._selectionRestorePosition=null,this._hasChangedRange&&(this._hasChangedRange=!1,this.fire("change:range",{directChange:!1})))}),{priority:"lowest"}),this.on("change:range",(()=>{this._validateSelectionRanges(this.getRanges())})),this.listenTo(this._model.markers,"update",((e,t,i,n)=>{this._updateMarker(t,n)})),this.listenTo(this._document,"change",((e,t)=>{!function(e,t){const i=e.document.differ;for(const n of i.getChanges()){if("insert"!=n.type)continue;const i=n.position.parent;n.length===i.maxOffset&&e.enqueueChange(t,(e=>{const t=Array.from(i.getAttributeKeys()).filter((e=>e.startsWith(vd)));for(const n of t)e.removeAttribute(n,i)}))}}(this._model,t)}))}}function kd(e,t){if(!e)return null;if(e instanceof qc||e instanceof jc)return e.getAttributes();if(!t.isInline(e))return null;if(!t.isObject(e))return[];const i=[];for(const[n,s]of e.getAttributes())t.checkAttribute("$text",n)&&!1!==t.getAttributeProperties(n).copyFromObject&&i.push([n,s]);return i}class Cd{add(e){for(const t of this._dispatchers)e(t);return this}constructor(e){this._dispatchers=e}}class xd extends Cd{elementToElement(e){return this.add(function(e){const t=Td(e.model),i=Sd(e.view,"container");t.attributes.length&&(t.children=!0);return n=>{n.on(`insert:${t.name}`,function(e,t=Ld){return(i,n,s)=>{if(!t(n.item,s.consumable,{preflight:!0}))return;const o=e(n.item,s,n);if(!o)return;t(n.item,s.consumable);const r=s.mapper.toViewPosition(n.range.start);s.mapper.bindElements(n.item,o),s.writer.insert(r,o),s.convertAttributes(n.item),Od(o,n.item.getChildren(),s,{reconversion:n.reconversion})}}(i,Bd(t)),{priority:e.converterPriority||"normal"}),(t.children||t.attributes.length)&&n.on("reduceChanges",Rd(t),{priority:"low"})}}(e))}elementToStructure(e){return this.add(function(e){const t=Td(e.model),i=Sd(e.view,"container");return t.children=!0,n=>{if(n._conversionApi.schema.checkChild(t.name,"$text"))throw new p("conversion-element-to-structure-disallowed-text",n,{elementName:t.name});var s,o;n.on(`insert:${t.name}`,(s=i,o=Bd(t),(e,t,i)=>{if(!o(t.item,i.consumable,{preflight:!0}))return;const n=new Map;i.writer._registerSlotFactory(function(e,t,i){return(n,s)=>{const o=n.createContainerElement("$slot");let r=null;if("children"===s)r=Array.from(e.getChildren());else{if("function"!=typeof s)throw new p("conversion-slot-mode-unknown",i.dispatcher,{modeOrFilter:s});r=Array.from(e.getChildren()).filter((e=>s(e)))}return t.set(o,r),o}}(t.item,n,i));const r=s(t.item,i,t);if(i.writer._clearSlotFactory(),!r)return;!function(e,t,i){const n=Array.from(t.values()).flat(),s=new Set(n);if(s.size!=n.length)throw new p("conversion-slot-filter-overlap",i.dispatcher,{element:e});if(s.size!=e.childCount)throw new p("conversion-slot-filter-incomplete",i.dispatcher,{element:e})}(t.item,n,i),o(t.item,i.consumable);const a=i.mapper.toViewPosition(t.range.start);i.mapper.bindElements(t.item,r),i.writer.insert(a,r),i.convertAttributes(t.item),function(e,t,i,n){i.mapper.on("modelToViewPosition",r,{priority:"highest"});let s=null,o=null;for([s,o]of t)Od(e,o,i,n),i.writer.move(i.writer.createRangeIn(s),i.writer.createPositionBefore(s)),i.writer.remove(s);function r(e,t){const i=t.modelPosition.nodeAfter,n=o.indexOf(i);n<0||(t.viewPosition=t.mapper.findPositionIn(s,n))}i.mapper.off("modelToViewPosition",r)}(r,n,i,{reconversion:t.reconversion})}),{priority:e.converterPriority||"normal"}),n.on("reduceChanges",Rd(t),{priority:"low"})}}(e))}attributeToElement(e){return this.add(function(e){e=_s(e);let t=e.model;"string"==typeof t&&(t={key:t});let i=`attribute:${t.key}`;t.name&&(i+=":"+t.name);if(t.values)for(const i of t.values)e.view[i]=Sd(e.view[i],"attribute");else e.view=Sd(e.view,"attribute");const n=Id(e);return t=>{t.on(i,function(e){return(t,i,n)=>{if(!n.consumable.test(i.item,t.name))return;const s=e(i.attributeOldValue,n,i),o=e(i.attributeNewValue,n,i);if(!s&&!o)return;n.consumable.consume(i.item,t.name);const r=n.writer,a=r.document.selection;if(i.item instanceof cd||i.item instanceof _d)r.wrap(a.getFirstRange(),o);else{let e=n.mapper.toViewRange(i.range);null!==i.attributeOldValue&&s&&(e=r.unwrap(e,s)),null!==i.attributeNewValue&&o&&r.wrap(e,o)}}}(n),{priority:e.converterPriority||"normal"})}}(e))}attributeToAttribute(e){return this.add(function(e){e=_s(e);let t=e.model;"string"==typeof t&&(t={key:t});let i=`attribute:${t.key}`;t.name&&(i+=":"+t.name);if(t.values)for(const i of t.values)e.view[i]=Pd(e.view[i]);else e.view=Pd(e.view);const n=Id(e);return t=>{var s;t.on(i,(s=n,(e,t,i)=>{if(!i.consumable.test(t.item,e.name))return;const n=s(t.attributeOldValue,i,t),o=s(t.attributeNewValue,i,t);if(!n&&!o)return;i.consumable.consume(t.item,e.name);const r=i.mapper.toViewElement(t.item),a=i.writer;if(!r)throw new p("conversion-attribute-to-attribute-on-text",i.dispatcher,t);if(null!==t.attributeOldValue&&n)if("class"==n.key){const e="string"==typeof n.value?n.value.split(/\s+/):n.value;for(const t of e)a.removeClass(t,r)}else if("style"==n.key)if("string"==typeof n.value){const e=new ll(a.document.stylesProcessor);e.setTo(n.value);for(const[t]of e.getStylesEntries())a.removeStyle(t,r)}else{const e=Object.keys(n.value);for(const t of e)a.removeStyle(t,r)}else a.removeAttribute(n.key,r);if(null!==t.attributeNewValue&&o)if("class"==o.key){const e="string"==typeof o.value?o.value.split(/\s+/):o.value;for(const t of e)a.addClass(t,r)}else if("style"==o.key)if("string"==typeof o.value){const e=new ll(a.document.stylesProcessor);e.setTo(o.value);for(const[t,i]of e.getStylesEntries())a.setStyle(t,i,r)}else{const e=Object.keys(o.value);for(const t of e)a.setStyle(t,o.value[t],r)}else a.setAttribute(o.key,o.value,r)}),{priority:e.converterPriority||"normal"})}}(e))}markerToElement(e){return this.add(function(e){const t=Sd(e.view,"ui");return i=>{var n;i.on(`addMarker:${e.model}`,(n=t,(e,t,i)=>{t.isOpening=!0;const s=n(t,i);t.isOpening=!1;const o=n(t,i);if(!s||!o)return;const r=t.markerRange;if(r.isCollapsed&&!i.consumable.consume(r,e.name))return;for(const t of r)if(!i.consumable.consume(t.item,e.name))return;const a=i.mapper,l=i.writer;l.insert(a.toViewPosition(r.start),s),i.mapper.bindElementToMarker(s,t.markerName),r.isCollapsed||(l.insert(a.toViewPosition(r.end),o),i.mapper.bindElementToMarker(o,t.markerName)),e.stop()}),{priority:e.converterPriority||"normal"}),i.on(`removeMarker:${e.model}`,((e,t,i)=>{const n=i.mapper.markerNameToElements(t.markerName);if(n){for(const e of n)i.mapper.unbindElementFromMarkerName(e,t.markerName),i.writer.clear(i.writer.createRangeOn(e),e);i.writer.clearClonedElementsGroup(t.markerName),e.stop()}}),{priority:e.converterPriority||"normal"})}}(e))}markerToHighlight(e){return this.add(function(e){return t=>{var i;t.on(`addMarker:${e.model}`,(i=e.view,(e,t,n)=>{if(!t.item)return;if(!(t.item instanceof cd||t.item instanceof _d||t.item.is("$textProxy")))return;const s=Vd(i,t,n);if(!s)return;if(!n.consumable.consume(t.item,e.name))return;const o=n.writer,r=Ad(o,s),a=o.document.selection;if(t.item instanceof cd||t.item instanceof _d)o.wrap(a.getFirstRange(),r);else{const e=n.mapper.toViewRange(t.range),i=o.wrap(e,r);for(const e of i.getItems())if(e.is("attributeElement")&&e.isSimilar(r)){n.mapper.bindElementToMarker(e,t.markerName);break}}}),{priority:e.converterPriority||"normal"}),t.on(`addMarker:${e.model}`,function(e){return(t,i,n)=>{if(!i.item)return;if(!(i.item instanceof Gc))return;const s=Vd(e,i,n);if(!s)return;if(!n.consumable.test(i.item,t.name))return;const o=n.mapper.toViewElement(i.item);if(o&&o.getCustomProperty("addHighlight")){n.consumable.consume(i.item,t.name);for(const e of id._createIn(i.item))n.consumable.consume(e.item,t.name);o.getCustomProperty("addHighlight")(o,s,n.writer),n.mapper.bindElementToMarker(o,i.markerName)}}}(e.view),{priority:e.converterPriority||"normal"}),t.on(`removeMarker:${e.model}`,function(e){return(t,i,n)=>{if(i.markerRange.isCollapsed)return;const s=Vd(e,i,n);if(!s)return;const o=Ad(n.writer,s),r=n.mapper.markerNameToElements(i.markerName);if(r){for(const e of r)if(n.mapper.unbindElementFromMarkerName(e,i.markerName),e.is("attributeElement"))n.writer.unwrap(n.writer.createRangeOn(e),o);else{e.getCustomProperty("removeHighlight")(e,s.id,n.writer)}n.writer.clearClonedElementsGroup(i.markerName),t.stop()}}}(e.view),{priority:e.converterPriority||"normal"})}}(e))}markerToData(e){return this.add(function(e){e=_s(e);const t=e.model;let i=e.view;i||(i=i=>({group:t,name:i.substr(e.model.length+1)}));return n=>{var s;n.on(`addMarker:${t}`,(s=i,(e,t,i)=>{const n=s(t.markerName,i);if(!n)return;const o=t.markerRange;i.consumable.consume(o,e.name)&&(Ed(o,!1,i,t,n),Ed(o,!0,i,t,n),e.stop())}),{priority:e.converterPriority||"normal"}),n.on(`removeMarker:${t}`,function(e){return(t,i,n)=>{const s=e(i.markerName,n);if(!s)return;const o=n.mapper.markerNameToElements(i.markerName);if(o){for(const e of o)n.mapper.unbindElementFromMarkerName(e,i.markerName),e.is("containerElement")?(r(`data-${s.group}-start-before`,e),r(`data-${s.group}-start-after`,e),r(`data-${s.group}-end-before`,e),r(`data-${s.group}-end-after`,e)):n.writer.clear(n.writer.createRangeOn(e),e);n.writer.clearClonedElementsGroup(i.markerName),t.stop()}function r(e,t){if(t.hasAttribute(e)){const i=new Set(t.getAttribute(e).split(","));i.delete(s.name),0==i.size?n.writer.removeAttribute(e,t):n.writer.setAttribute(e,Array.from(i).join(","),t)}}}}(i),{priority:e.converterPriority||"normal"})}}(e))}}function Ad(e,t){const i=e.createAttributeElement("span",t.attributes);return t.classes&&i._addClass(t.classes),"number"==typeof t.priority&&(i._priority=t.priority),i._id=t.id,i}function Ed(e,t,i,n,s){const o=t?e.start:e.end,r=o.nodeAfter&&o.nodeAfter.is("element")?o.nodeAfter:null,a=o.nodeBefore&&o.nodeBefore.is("element")?o.nodeBefore:null;if(r||a){let e,o;t&&r||!t&&!a?(e=r,o=!0):(e=a,o=!1);const l=i.mapper.toViewElement(e);if(l)return void function(e,t,i,n,s,o){const r=`data-${o.group}-${t?"start":"end"}-${i?"before":"after"}`,a=e.hasAttribute(r)?e.getAttribute(r).split(","):[];a.unshift(o.name),n.writer.setAttribute(r,a.join(","),e),n.mapper.bindElementToMarker(e,s.markerName)}(l,t,o,i,n,s)}!function(e,t,i,n,s){const o=`${s.group}-${t?"start":"end"}`,r=s.name?{name:s.name}:null,a=i.writer.createUIElement(o,r);i.writer.insert(e,a),i.mapper.bindElementToMarker(a,n.markerName)}(i.mapper.toViewPosition(o),t,i,n,s)}function Td(e){return"string"==typeof e&&(e={name:e}),{name:e.name,attributes:e.attributes?pa(e.attributes):[],children:!!e.children}}function Sd(e,t){return"function"==typeof e?e:(i,n)=>function(e,t,i){"string"==typeof e&&(e={name:e});let n;const s=t.writer,o=Object.assign({},e.attributes);if("container"==i)n=s.createContainerElement(e.name,o);else if("attribute"==i){const t={priority:e.priority||Bl.DEFAULT_PRIORITY};n=s.createAttributeElement(e.name,o,t)}else n=s.createUIElement(e.name,o);if(e.styles){const t=Object.keys(e.styles);for(const i of t)s.setStyle(i,e.styles[i],n)}if(e.classes){const t=e.classes;if("string"==typeof t)s.addClass(t,n);else for(const e of t)s.addClass(e,n)}return n}(e,n,t)}function Id(e){return e.model.values?(t,i,n)=>{const s=e.view[t];return s?s(t,i,n):null}:e.view}function Pd(e){return"string"==typeof e?t=>({key:e,value:t}):"object"==typeof e?e.value?()=>e:t=>({key:e.key,value:t}):e}function Vd(e,t,i){const n="function"==typeof e?e(t,i):e;return n?(n.priority||(n.priority=10),n.id||(n.id=t.markerName),n):null}function Rd(e){const t=function(e){return(t,i)=>{if(!t.is("element",e.name))return!1;if("attribute"==i.type){if(e.attributes.includes(i.attributeKey))return!0}else if(e.children)return!0;return!1}}(e);return(e,i)=>{const n=[];i.reconvertedElements||(i.reconvertedElements=new Set);for(const e of i.changes){const s="attribute"==e.type?e.range.start.nodeAfter:e.position.parent;if(s&&t(s,e)){if(!i.reconvertedElements.has(s)){i.reconvertedElements.add(s);const e=Jc._createBefore(s);let t=n.length;for(let i=n.length-1;i>=0;i--){const s=n[i],o=("attribute"==s.type?s.range.start:s.position).compareWith(e);if("before"==o||"remove"==s.type&&"same"==o)break;t=i}n.splice(t,0,{type:"remove",name:s.name,position:e,length:1},{type:"reinsert",name:s.name,position:e,length:1})}}else n.push(e)}i.changes=n}}function Bd(e){return(t,i,n={})=>{const s=["insert"];for(const i of e.attributes)t.hasAttribute(i)&&s.push(`attribute:${i}`);return!!s.every((e=>i.test(t,e)))&&(n.preflight||s.forEach((e=>i.consume(t,e))),!0)}}function Od(e,t,i,n){for(const s of t)Md(e.root,s,i,n)||i.convertItem(s)}function Md(e,t,i,n){const{writer:s,mapper:o}=i;if(!n.reconversion)return!1;const r=o.toViewElement(t);return!(!r||r.root==e)&&(!!i.canReuseView(r)&&(s.move(s.createRangeOn(r),o.toViewPosition(Jc._createBefore(t))),!0))}function Ld(e,t,{preflight:i}={}){return i?t.test(e,"insert"):t.consume(e,"insert")}function Nd(e){const{schema:t,document:i}=e.model;for(const n of i.getRoots())if(n.isEmpty&&!t.checkChild(n,"$text")&&t.checkChild(n,"paragraph"))return e.insertElement("paragraph",n),!0;return!1}function Fd(e,t,i){const n=i.createContext(e);return!!i.checkChild(n,"paragraph")&&!!i.checkChild(n.push("paragraph"),t)}function Dd(e,t){const i=t.createElement("paragraph");return t.insert(i,e),t.createPositionAt(i,0)}class zd extends Cd{elementToElement(e){return this.add(Hd(e))}elementToAttribute(e){return this.add(function(e){e=_s(e),Wd(e);const t=jd(e,!1),i=$d(e.view),n=i?`element:${i}`:"element";return i=>{i.on(n,t,{priority:e.converterPriority||"low"})}}(e))}attributeToAttribute(e){return this.add(function(e){e=_s(e);let t=null;("string"==typeof e.view||e.view.key)&&(t=function(e){"string"==typeof e.view&&(e.view={key:e.view});const t=e.view.key,i=void 0===e.view.value?/[\s\S]*/:e.view.value;let n;if("class"==t||"style"==t){const e="class"==t?"classes":"styles";n={[e]:i}}else n={attributes:{[t]:i}};e.view.name&&(n.name=e.view.name);return e.view=n,t}(e));Wd(e,t);const i=jd(e,!0);return t=>{t.on("element",i,{priority:e.converterPriority||"low"})}}(e))}elementToMarker(e){return this.add(function(e){const t=function(e){return(t,i)=>{const n="string"==typeof e?e:e(t,i);return i.writer.createElement("$marker",{"data-name":n})}}(e.model);return Hd({...e,model:t})}(e))}dataToMarker(e){return this.add(function(e){e=_s(e),e.model||(e.model=t=>t?e.view+":"+t:e.view);const t={view:e.view,model:e.model},i=Ud(qd(t,"start")),n=Ud(qd(t,"end"));return s=>{s.on(`element:${e.view}-start`,i,{priority:e.converterPriority||"normal"}),s.on(`element:${e.view}-end`,n,{priority:e.converterPriority||"normal"});const o=m.low,r=m.highest,a=m.get(e.converterPriority)/r;s.on("element",function(e){return(t,i,n)=>{const s=`data-${e.view}`;function o(t,s){for(const o of s){const s=e.model(o,n),r=n.writer.createElement("$marker",{"data-name":s});n.writer.insert(r,t),i.modelCursor.isEqual(t)?i.modelCursor=i.modelCursor.getShiftedBy(1):i.modelCursor=i.modelCursor._getTransformedByInsertion(t,1),i.modelRange=i.modelRange._getTransformedByInsertion(t,1)[0]}}(n.consumable.test(i.viewItem,{attributes:s+"-end-after"})||n.consumable.test(i.viewItem,{attributes:s+"-start-after"})||n.consumable.test(i.viewItem,{attributes:s+"-end-before"})||n.consumable.test(i.viewItem,{attributes:s+"-start-before"}))&&(i.modelRange||Object.assign(i,n.convertChildren(i.viewItem,i.modelCursor)),n.consumable.consume(i.viewItem,{attributes:s+"-end-after"})&&o(i.modelRange.end,i.viewItem.getAttribute(s+"-end-after").split(",")),n.consumable.consume(i.viewItem,{attributes:s+"-start-after"})&&o(i.modelRange.end,i.viewItem.getAttribute(s+"-start-after").split(",")),n.consumable.consume(i.viewItem,{attributes:s+"-end-before"})&&o(i.modelRange.start,i.viewItem.getAttribute(s+"-end-before").split(",")),n.consumable.consume(i.viewItem,{attributes:s+"-start-before"})&&o(i.modelRange.start,i.viewItem.getAttribute(s+"-start-before").split(",")))}}(t),{priority:o+a})}}(e))}}function Hd(e){const t=Ud(e=_s(e)),i=$d(e.view),n=i?`element:${i}`:"element";return i=>{i.on(n,t,{priority:e.converterPriority||"normal"})}}function $d(e){return"string"==typeof e?e:"object"==typeof e&&"string"==typeof e.name?e.name:null}function Ud(e){const t=new ol(e.view);return(i,n,s)=>{const o=t.match(n.viewItem);if(!o)return;const r=o.match;if(r.name=!0,!s.consumable.test(n.viewItem,r))return;const a=function(e,t,i){return e instanceof Function?e(t,i):i.writer.createElement(e)}(e.model,n.viewItem,s);a&&s.safeInsert(a,n.modelCursor)&&(s.consumable.consume(n.viewItem,r),s.convertChildren(n.viewItem,a),s.updateConversionResult(a,n))}}function Wd(e,t=null){const i=null===t||(e=>e.getAttribute(t)),n="object"!=typeof e.model?e.model:e.model.key,s="object"!=typeof e.model||void 0===e.model.value?i:e.model.value;e.model={key:n,value:s}}function jd(e,t){const i=new ol(e.view);return(n,s,o)=>{if(!s.modelRange&&t)return;const r=i.match(s.viewItem);if(!r)return;if(!function(e,t){const i="function"==typeof e?e(t):e;if("object"==typeof i&&!$d(i))return!1;return!i.classes&&!i.attributes&&!i.styles}(e.view,s.viewItem)?delete r.match.name:r.match.name=!0,!o.consumable.test(s.viewItem,r.match))return;const a=e.model.key,l="function"==typeof e.model.value?e.model.value(s.viewItem,o):e.model.value;if(null===l)return;s.modelRange||Object.assign(s,o.convertChildren(s.viewItem,s.modelCursor));const c=function(e,t,i,n){let s=!1;for(const o of Array.from(e.getItems({shallow:i})))n.schema.checkAttribute(o,t.key)&&(s=!0,o.hasAttribute(t.key)||n.writer.setAttribute(t.key,t.value,o));return s}(s.modelRange,{key:a,value:l},t,o);c&&(o.consumable.test(s.viewItem,{name:!0})&&(r.match.name=!0),o.consumable.consume(s.viewItem,r.match))}}function qd(e,t){return{view:`${e.view}-${t}`,model:(t,i)=>{const n=t.getAttribute("name"),s=e.model(n,i);return i.writer.createElement("$marker",{"data-name":s})}}}function Gd(e){e.document.registerPostFixer((t=>function(e,t){const i=t.document.selection,n=t.schema,s=[];let o=!1;for(const e of i.getRanges()){const t=Kd(e,n);t&&!t.isEqual(e)?(s.push(t),o=!0):s.push(e)}o&&e.setSelection(function(e){const t=[...e],i=new Set;let n=1;for(;n<t.length;){const e=t[n],s=t.slice(0,n);for(const[o,r]of s.entries())if(!i.has(o))if(e.isEqual(r))i.add(o);else if(e.isIntersecting(r)){i.add(o),i.add(n);const s=e.getJoined(r);t.push(s)}n++}return t.filter(((e,t)=>!i.has(t)))}(s),{backward:i.isBackward});return!1}(t,e)))}function Kd(e,t){return e.isCollapsed?function(e,t){const i=e.start,n=t.getNearestSelectionRange(i);if(!n){const e=i.getAncestors().reverse().find((e=>t.isObject(e)));return e?id._createOn(e):null}if(!n.isCollapsed)return n;const s=n.start;if(i.isEqual(s))return null;return new id(s)}(e,t):function(e,t){const{start:i,end:n}=e,s=t.checkChild(i,"$text"),o=t.checkChild(n,"$text"),r=t.getLimitElement(i),a=t.getLimitElement(n);if(r===a){if(s&&o)return null;if(function(e,t,i){const n=e.nodeAfter&&!i.isLimit(e.nodeAfter)||i.checkChild(e,"$text"),s=t.nodeBefore&&!i.isLimit(t.nodeBefore)||i.checkChild(t,"$text");return n||s}(i,n,t)){const e=i.nodeAfter&&t.isSelectable(i.nodeAfter)?null:t.getNearestSelectionRange(i,"forward"),s=n.nodeBefore&&t.isSelectable(n.nodeBefore)?null:t.getNearestSelectionRange(n,"backward"),o=e?e.start:i,r=s?s.end:n;return new id(o,r)}}const l=r&&!r.is("rootElement"),c=a&&!a.is("rootElement");if(l||c){const e=i.nodeAfter&&n.nodeBefore&&i.nodeAfter.parent===n.nodeBefore.parent,s=l&&(!e||!Jd(i.nodeAfter,t)),o=c&&(!e||!Jd(n.nodeBefore,t));let d=i,h=n;return s&&(d=Jc._createBefore(Zd(r,t))),o&&(h=Jc._createAfter(Zd(a,t))),new id(d,h)}return null}(e,t)}function Zd(e,t){let i=e,n=i;for(;t.isLimit(n)&&n.parent;)i=n,n=n.parent;return i}function Jd(e,t){return e&&t.isSelectable(e)}class Qd extends(Yo()){destroy(){this.view.destroy(),this.stopListening()}reconvertMarker(e){const t="string"==typeof e?e:e.name,i=this.model.markers.get(t);if(!i)throw new p("editingcontroller-reconvertmarker-marker-not-exist",this,{markerName:t});this.model.change((()=>{this.model.markers._refresh(i)}))}reconvertItem(e){this.model.change((()=>{this.model.document.differ._refreshItem(e)}))}constructor(e,t){super(),this.model=e,this.view=new Hc(t),this.mapper=new nd,this.downcastDispatcher=new rd({mapper:this.mapper,schema:e.schema});const n=this.model.document,s=n.selection,o=this.model.markers;var r,a,l;this.listenTo(this.model,"_beforeChanges",(()=>{this.view._disableRendering(!0)}),{priority:"highest"}),this.listenTo(this.model,"_afterChanges",(()=>{this.view._disableRendering(!1)}),{priority:"lowest"}),this.listenTo(n,"change",(()=>{this.view.change((e=>{this.downcastDispatcher.convertChanges(n.differ,o,e),this.downcastDispatcher.convertSelection(s,o,e)}))}),{priority:"low"}),this.listenTo(this.view.document,"selectionChange",function(e,t){return(i,n)=>{const s=n.newSelection,o=[];for(const e of s.getRanges())o.push(t.toModelRange(e));const r=e.createSelection(o,{backward:s.isBackward});r.isEqual(e.document.selection)||e.change((e=>{e.setSelection(r)}))}}(this.model,this.mapper)),this.listenTo(this.view.document,"beforeinput",(r=this.mapper,a=this.model.schema,l=this.view,(e,t)=>{if(!l.document.isComposing||i.isAndroid)for(let e=0;e<t.targetRanges.length;e++){const i=t.targetRanges[e],n=r.toModelRange(i),s=Kd(n,a);s&&!s.isEqual(n)&&(t.targetRanges[e]=r.toViewRange(s))}}),{priority:"high"}),this.downcastDispatcher.on("insert:$text",((e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const n=i.writer,s=i.mapper.toViewPosition(t.range.start),o=n.createText(t.item.data);n.insert(s,o)}),{priority:"lowest"}),this.downcastDispatcher.on("insert",((e,t,i)=>{i.convertAttributes(t.item),t.reconversion||!t.item.is("element")||t.item.isEmpty||i.convertChildren(t.item)}),{priority:"lowest"}),this.downcastDispatcher.on("remove",((e,t,i)=>{const n=i.mapper.toViewPosition(t.position),s=t.position.getShiftedBy(t.length),o=i.mapper.toViewPosition(s,{isPhantom:!0}),r=i.writer.createRange(n,o),a=i.writer.remove(r.getTrimmed());for(const e of i.writer.createRangeIn(a).getItems())i.mapper.unbindViewElement(e,{defer:!0})}),{priority:"low"}),this.downcastDispatcher.on("cleanSelection",((e,t,i)=>{const n=i.writer,s=n.document.selection;for(const e of s.getRanges())e.isCollapsed&&e.end.parent.isAttached()&&i.writer.mergeAttributes(e.start);n.setSelection(null)})),this.downcastDispatcher.on("selection",((e,t,i)=>{const n=t.selection;if(n.isCollapsed)return;if(!i.consumable.consume(n,"selection"))return;const s=[];for(const e of n.getRanges())s.push(i.mapper.toViewRange(e));i.writer.setSelection(s,{backward:n.isBackward})}),{priority:"low"}),this.downcastDispatcher.on("selection",((e,t,i)=>{const n=t.selection;if(!n.isCollapsed)return;if(!i.consumable.consume(n,"selection"))return;const s=i.writer,o=n.getFirstPosition(),r=i.mapper.toViewPosition(o),a=s.breakAttributes(r);s.setSelection(a)}),{priority:"low"}),this.view.document.roots.bindTo(this.model.document.roots).using((e=>{if("$graveyard"==e.rootName)return null;const t=new wl(this.view.document,e.name);return t.rootName=e.rootName,this.mapper.bindElements(e,t),t}))}}class Yd{add(e,t){let i;e.is("$text")||e.is("documentFragment")?this._consumables.set(e,!0):(this._consumables.has(e)?i=this._consumables.get(e):(i=new eh(e),this._consumables.set(e,i)),i.add(t))}test(e,t){const i=this._consumables.get(e);return void 0===i?null:e.is("$text")||e.is("documentFragment")?i:i.test(t)}consume(e,t){return!!this.test(e,t)&&(e.is("$text")||e.is("documentFragment")?this._consumables.set(e,!1):this._consumables.get(e).consume(t),!0)}revert(e,t){const i=this._consumables.get(e);void 0!==i&&(e.is("$text")||e.is("documentFragment")?this._consumables.set(e,!0):i.revert(t))}static consumablesFromElement(e){const t={element:e,name:!0,attributes:[],classes:[],styles:[]},i=e.getAttributeKeys();for(const e of i)"style"!=e&&"class"!=e&&t.attributes.push(e);const n=e.getClassNames();for(const e of n)t.classes.push(e);const s=e.getStyleNames();for(const e of s)t.styles.push(e);return t}static createFrom(e,t){if(t||(t=new Yd),e.is("$text"))return t.add(e),t;e.is("element")&&t.add(e,Yd.consumablesFromElement(e)),e.is("documentFragment")&&t.add(e);for(const i of e.getChildren())t=Yd.createFrom(i,t);return t}constructor(){this._consumables=new Map}}const Xd=["attributes","classes","styles"];class eh{add(e){e.name&&(this._canConsumeName=!0);for(const t of Xd)t in e&&this._add(t,e[t])}test(e){if(e.name&&!this._canConsumeName)return this._canConsumeName;for(const t of Xd)if(t in e){const i=this._test(t,e[t]);if(!0!==i)return i}return!0}consume(e){e.name&&(this._canConsumeName=!1);for(const t of Xd)t in e&&this._consume(t,e[t])}revert(e){e.name&&(this._canConsumeName=!0);for(const t of Xd)t in e&&this._revert(t,e[t])}_add(e,t){const i=pa(t),n=this._consumables[e];for(const t of i){if("attributes"===e&&("class"===t||"style"===t))throw new p("viewconsumable-invalid-attribute",this);if(n.set(t,!0),"styles"===e)for(const e of this.element.document.stylesProcessor.getRelatedStyles(t))n.set(e,!0)}}_test(e,t){const i=pa(t),n=this._consumables[e];for(const t of i)if("attributes"!==e||"class"!==t&&"style"!==t){const e=n.get(t);if(void 0===e)return null;if(!e)return!1}else{const e="class"==t?"classes":"styles",i=this._test(e,[...this._consumables[e].keys()]);if(!0!==i)return i}return!0}_consume(e,t){const i=pa(t),n=this._consumables[e];for(const t of i)if("attributes"!==e||"class"!==t&&"style"!==t){if(n.set(t,!1),"styles"==e)for(const e of this.element.document.stylesProcessor.getRelatedStyles(t))n.set(e,!1)}else{const e="class"==t?"classes":"styles";this._consume(e,[...this._consumables[e].keys()])}}_revert(e,t){const i=pa(t),n=this._consumables[e];for(const t of i)if("attributes"!==e||"class"!==t&&"style"!==t){!1===n.get(t)&&n.set(t,!0)}else{const e="class"==t?"classes":"styles";this._revert(e,[...this._consumables[e].keys()])}}constructor(e){this.element=e,this._canConsumeName=null,this._consumables={attributes:new Map,styles:new Map,classes:new Map}}}class th extends(Yo()){register(e,t){if(this._sourceDefinitions[e])throw new p("schema-cannot-register-item-twice",this,{itemName:e});this._sourceDefinitions[e]=[Object.assign({},t)],this._clearCache()}extend(e,t){if(!this._sourceDefinitions[e])throw new p("schema-cannot-extend-missing-item",this,{itemName:e});this._sourceDefinitions[e].push(Object.assign({},t)),this._clearCache()}getDefinitions(){return this._compiledDefinitions||this._compile(),this._compiledDefinitions}getDefinition(e){let t;return t="string"==typeof e?e:"is"in e&&(e.is("$text")||e.is("$textProxy"))?"$text":e.name,this.getDefinitions()[t]}isRegistered(e){return!!this.getDefinition(e)}isBlock(e){const t=this.getDefinition(e);return!(!t||!t.isBlock)}isLimit(e){const t=this.getDefinition(e);return!!t&&!(!t.isLimit&&!t.isObject)}isObject(e){const t=this.getDefinition(e);return!!t&&!!(t.isObject||t.isLimit&&t.isSelectable&&t.isContent)}isInline(e){const t=this.getDefinition(e);return!(!t||!t.isInline)}isSelectable(e){const t=this.getDefinition(e);return!!t&&!(!t.isSelectable&&!t.isObject)}isContent(e){const t=this.getDefinition(e);return!!t&&!(!t.isContent&&!t.isObject)}checkChild(e,t){return!!t&&this._checkContextMatch(t,e)}checkAttribute(e,t){const i=this.getDefinition(e.last);return!!i&&i.allowAttributes.includes(t)}checkMerge(e,t){if(e instanceof Jc){const t=e.nodeBefore,i=e.nodeAfter;if(!(t instanceof Gc))throw new p("schema-check-merge-no-element-before",this);if(!(i instanceof Gc))throw new p("schema-check-merge-no-element-after",this);return this.checkMerge(t,i)}for(const i of t.getChildren())if(!this.checkChild(e,i))return!1;return!0}addChildCheck(e){this.on("checkChild",((t,[i,n])=>{if(!n)return;const s=e(i,n);"boolean"==typeof s&&(t.stop(),t.return=s)}),{priority:"high"})}addAttributeCheck(e){this.on("checkAttribute",((t,[i,n])=>{const s=e(i,n);"boolean"==typeof s&&(t.stop(),t.return=s)}),{priority:"high"})}setAttributeProperties(e,t){this._attributeProperties[e]=Object.assign(this.getAttributeProperties(e),t)}getAttributeProperties(e){return this._attributeProperties[e]||{}}getLimitElement(e){let t;if(e instanceof Jc)t=e.parent;else{t=(e instanceof id?[e]:Array.from(e.getRanges())).reduce(((e,t)=>{const i=t.getCommonAncestor();return e?e.getCommonAncestor(i,{includeSelf:!0}):i}),null)}for(;!this.isLimit(t)&&t.parent;)t=t.parent;return t}checkAttributeInSelection(e,t){if(e.isCollapsed){const i=[...e.getFirstPosition().getAncestors(),new jc("",e.getAttributes())];return this.checkAttribute(i,t)}{const i=e.getRanges();for(const e of i)for(const i of e)if(this.checkAttribute(i.item,t))return!0}return!1}*getValidRanges(e,t){e=function*(e){for(const t of e)yield*t.getMinimalFlatRanges()}(e);for(const i of e)yield*this._getValidRangesForRange(i,t)}getNearestSelectionRange(e,t="both"){if("$graveyard"==e.root.rootName)return null;if(this.checkChild(e,"$text"))return new id(e);let i,n;const s=e.getAncestors().reverse().find((e=>this.isLimit(e)))||e.root;"both"!=t&&"backward"!=t||(i=new Kc({boundaries:id._createIn(s),startPosition:e,direction:"backward"})),"both"!=t&&"forward"!=t||(n=new Kc({boundaries:id._createIn(s),startPosition:e}));for(const e of function*(e,t){let i=!1;for(;!i;){if(i=!0,e){const t=e.next();t.done||(i=!1,yield{walker:e,value:t.value})}if(t){const e=t.next();e.done||(i=!1,yield{walker:t,value:e.value})}}}(i,n)){const t=e.walker==i?"elementEnd":"elementStart",n=e.value;if(n.type==t&&this.isObject(n.item))return id._createOn(n.item);if(this.checkChild(n.nextPosition,"$text"))return new id(n.nextPosition)}return null}findAllowedParent(e,t){let i=e.parent;for(;i;){if(this.checkChild(i,t))return i;if(this.isLimit(i))return null;i=i.parent}return null}setAllowedAttributes(e,t,i){const n=i.model;for(const[s,o]of Object.entries(t))n.schema.checkAttribute(e,s)&&i.setAttribute(s,o,e)}removeDisallowedAttributes(e,t){for(const i of e)if(i.is("$text"))fh(this,i,t);else{const e=id._createIn(i).getPositions();for(const i of e){fh(this,i.nodeBefore||i.parent,t)}}}getAttributesWithProperty(e,t,i){const n={};for(const[s,o]of e.getAttributes()){const e=this.getAttributeProperties(s);void 0!==e[t]&&(void 0!==i&&i!==e[t]||(n[s]=o))}return n}createContext(e){return new ih(e)}_clearCache(){this._compiledDefinitions=null}_compile(){const e={},t=this._sourceDefinitions,i=Object.keys(t);for(const n of i)e[n]=nh(t[n],n);for(const t of i)sh(e,t);for(const t of i)oh(e,t);for(const t of i)rh(e,t);for(const t of i)ah(e,t),lh(e,t);for(const t of i)ch(e,t),dh(e,t),hh(e,t);this._compiledDefinitions=e}_checkContextMatch(e,t,i=t.length-1){const n=t.getItem(i);if(e.allowIn.includes(n.name)){if(0==i)return!0;{const e=this.getDefinition(n);return this._checkContextMatch(e,t,i-1)}}return!1}*_getValidRangesForRange(e,t){let i=e.start,n=e.start;for(const s of e.getItems({shallow:!0}))s.is("element")&&(yield*this._getValidRangesForRange(id._createIn(s),t)),this.checkAttribute(s,t)||(i.isEqual(n)||(yield new id(i,n)),i=Jc._createAfter(s)),n=Jc._createAfter(s);i.isEqual(n)||(yield new id(i,n))}findOptimalInsertionRange(e,t){const i=e.getSelectedElement();if(i&&this.isObject(i)&&!this.isInline(i))return"before"==t||"after"==t?new id(Jc._createAt(i,t)):id._createOn(i);const n=_a(e.getSelectedBlocks());if(!n)return new id(e.focus);if(n.isEmpty)return new id(Jc._createAt(n,0));const s=Jc._createAfter(n);return e.focus.isTouching(s)?new id(s):new id(Jc._createBefore(n))}constructor(){super(),this._sourceDefinitions={},this._attributeProperties={},this.decorate("checkChild"),this.decorate("checkAttribute"),this.on("checkAttribute",((e,t)=>{t[0]=new ih(t[0])}),{priority:"highest"}),this.on("checkChild",((e,t)=>{t[0]=new ih(t[0]),t[1]=this.getDefinition(t[1])}),{priority:"highest"})}}class ih{get length(){return this._items.length}get last(){return this._items[this._items.length-1]}[Symbol.iterator](){return this._items[Symbol.iterator]()}push(e){const t=new ih([e]);return t._items=[...this._items,...t._items],t}getItem(e){return this._items[e]}*getNames(){yield*this._items.map((e=>e.name))}endsWith(e){return Array.from(this.getNames()).join(" ").endsWith(e)}startsWith(e){return Array.from(this.getNames()).join(" ").startsWith(e)}constructor(e){if(e instanceof ih)return e;let t;t="string"==typeof e?[e]:Array.isArray(e)?e:e.getAncestors({includeSelf:!0}),this._items=t.map(gh)}}function nh(e,t){const i={name:t,allowIn:[],allowContentOf:[],allowWhere:[],allowAttributes:[],allowAttributesOf:[],allowChildren:[],inheritTypesFrom:[]};return function(e,t){for(const i of e){const e=Object.keys(i).filter((e=>e.startsWith("is")));for(const n of e)t[n]=!!i[n]}}(e,i),uh(e,i,"allowIn"),uh(e,i,"allowContentOf"),uh(e,i,"allowWhere"),uh(e,i,"allowAttributes"),uh(e,i,"allowAttributesOf"),uh(e,i,"allowChildren"),uh(e,i,"inheritTypesFrom"),function(e,t){for(const i of e){const e=i.inheritAllFrom;e&&(t.allowContentOf.push(e),t.allowWhere.push(e),t.allowAttributesOf.push(e),t.inheritTypesFrom.push(e))}}(e,i),i}function sh(e,t){const i=e[t];for(const n of i.allowChildren){const i=e[n];i&&i.allowIn.push(t)}i.allowChildren.length=0}function oh(e,t){for(const i of e[t].allowContentOf)if(e[i]){mh(e,i).forEach((e=>{e.allowIn.push(t)}))}delete e[t].allowContentOf}function rh(e,t){for(const i of e[t].allowWhere){const n=e[i];if(n){const i=n.allowIn;e[t].allowIn.push(...i)}}delete e[t].allowWhere}function ah(e,t){for(const i of e[t].allowAttributesOf){const n=e[i];if(n){const i=n.allowAttributes;e[t].allowAttributes.push(...i)}}delete e[t].allowAttributesOf}function lh(e,t){const i=e[t];for(const t of i.inheritTypesFrom){const n=e[t];if(n){const e=Object.keys(n).filter((e=>e.startsWith("is")));for(const t of e)t in i||(i[t]=n[t])}}delete i.inheritTypesFrom}function ch(e,t){const i=e[t],n=i.allowIn.filter((t=>e[t]));i.allowIn=Array.from(new Set(n))}function dh(e,t){const i=e[t];for(const n of i.allowIn){e[n].allowChildren.push(t)}}function hh(e,t){const i=e[t];i.allowAttributes=Array.from(new Set(i.allowAttributes))}function uh(e,t,i){for(const n of e){const e=n[i];"string"==typeof e?t[i].push(e):Array.isArray(e)&&t[i].push(...e)}}function mh(e,t){const i=e[t];return(n=e,Object.keys(n).map((e=>n[e]))).filter((e=>e.allowIn.includes(i.name)));var n}function gh(e){return"string"==typeof e||e.is("documentFragment")?{name:"string"==typeof e?e:"$documentFragment",*getAttributeKeys(){},getAttribute(){}}:{name:e.is("element")?e.name:"$text",*getAttributeKeys(){yield*e.getAttributeKeys()},getAttribute:t=>e.getAttribute(t)}}function fh(e,t,i){for(const n of t.getAttributeKeys())e.checkAttribute(t,n)||i.removeAttribute(n,t)}class ph extends(T()){convert(e,t,i=["$root"]){this.fire("viewCleanup",e),this._modelCursor=function(e,t){let i;for(const n of new ih(e)){const e={};for(const t of n.getAttributeKeys())e[t]=n.getAttribute(t);const s=t.createElement(n.name,e);i&&t.insert(s,i),i=Jc._createAt(s,0)}return i}(i,t),this.conversionApi.writer=t,this.conversionApi.consumable=Yd.createFrom(e),this.conversionApi.store={};const{modelRange:n}=this._convertItem(e,this._modelCursor),s=t.createDocumentFragment();if(n){this._removeEmptyElements();for(const e of Array.from(this._modelCursor.parent.getChildren()))t.append(e,s);s.markers=function(e,t){const i=new Set,n=new Map,s=id._createIn(e).getItems();for(const e of s)e.is("element","$marker")&&i.add(e);for(const e of i){const i=e.getAttribute("data-name"),s=t.createPositionBefore(e);n.has(i)?n.get(i).end=s.clone():n.set(i,new id(s.clone())),t.remove(e)}return n}(s,t)}return this._modelCursor=null,this._splitParts.clear(),this._cursorParents.clear(),this._emptyElementsToKeep.clear(),this.conversionApi.writer=null,this.conversionApi.store=null,s}_convertItem(e,t){const i={viewItem:e,modelCursor:t,modelRange:null};if(e.is("element")?this.fire(`element:${e.name}`,i,this.conversionApi):e.is("$text")?this.fire("text",i,this.conversionApi):this.fire("documentFragment",i,this.conversionApi),i.modelRange&&!(i.modelRange instanceof id))throw new p("view-conversion-dispatcher-incorrect-result",this);return{modelRange:i.modelRange,modelCursor:i.modelCursor}}_convertChildren(e,t){let i=t.is("position")?t:Jc._createAt(t,0);const n=new id(i);for(const t of Array.from(e.getChildren())){const e=this._convertItem(t,i);e.modelRange instanceof id&&(n.end=e.modelRange.end,i=e.modelCursor)}return{modelRange:n,modelCursor:i}}_safeInsert(e,t){const i=this._splitToAllowedParent(e,t);return!!i&&(this.conversionApi.writer.insert(e,i.position),!0)}_updateConversionResult(e,t){const i=this._getSplitParts(e),n=this.conversionApi.writer;t.modelRange||(t.modelRange=n.createRange(n.createPositionBefore(e),n.createPositionAfter(i[i.length-1])));const s=this._cursorParents.get(e);t.modelCursor=s?n.createPositionAt(s,0):t.modelRange.end}_splitToAllowedParent(e,t){const{schema:i,writer:n}=this.conversionApi;let s=i.findAllowedParent(t,e);if(s){if(s===t.parent)return{position:t};this._modelCursor.parent.getAncestors().includes(s)&&(s=null)}if(!s)return Fd(t,e,i)?{position:Dd(t,n)}:null;const o=this.conversionApi.writer.split(t,s),r=[];for(const e of o.range.getWalker())if("elementEnd"==e.type)r.push(e.item);else{const t=r.pop(),i=e.item;this._registerSplitPair(t,i)}const a=o.range.end.parent;return this._cursorParents.set(e,a),{position:o.position,cursorParent:a}}_registerSplitPair(e,t){this._splitParts.has(e)||this._splitParts.set(e,[e]);const i=this._splitParts.get(e);this._splitParts.set(t,i),i.push(t)}_getSplitParts(e){let t;return t=this._splitParts.has(e)?this._splitParts.get(e):[e],t}_keepEmptyElement(e){this._emptyElementsToKeep.add(e)}_removeEmptyElements(){let e=!1;for(const t of this._splitParts.keys())t.isEmpty&&!this._emptyElementsToKeep.has(t)&&(this.conversionApi.writer.remove(t),this._splitParts.delete(t),e=!0);e&&this._removeEmptyElements()}constructor(e){super(),this._splitParts=new Map,this._cursorParents=new Map,this._modelCursor=null,this._emptyElementsToKeep=new Set,this.conversionApi={...e,consumable:null,writer:null,store:null,convertItem:(e,t)=>this._convertItem(e,t),convertChildren:(e,t)=>this._convertChildren(e,t),safeInsert:(e,t)=>this._safeInsert(e,t),updateConversionResult:(e,t)=>this._updateConversionResult(e,t),splitToAllowedParent:(e,t)=>this._splitToAllowedParent(e,t),getSplitParts:e=>this._getSplitParts(e),keepEmptyElement:e=>this._keepEmptyElement(e)}}}class bh{getHtml(e){const t=_r.document.implementation.createHTMLDocument("").createElement("div");return t.appendChild(e),t.innerHTML}}class wh{toData(e){const t=this.domConverter.viewToDom(e);return this.htmlWriter.getHtml(t)}toView(e){const t=this._toDom(e);return this.domConverter.domToView(t,{skipComments:this.skipComments})}registerRawContentMatcher(e){this.domConverter.registerRawContentMatcher(e)}useFillerType(e){this.domConverter.blockFillerMode="marked"==e?"markedNbsp":"nbsp"}_toDom(e){e.match(/<(?:html|body|head|meta)(?:\s[^>]*)?>/i)||(e=`<body>${e}</body>`);const t=this.domParser.parseFromString(e,"text/html"),i=t.createDocumentFragment(),n=t.body.childNodes;for(;n.length>0;)i.appendChild(n[0]);return i}constructor(e){this.skipComments=!0,this.domParser=new DOMParser,this.domConverter=new yc(e,{renderingMode:"data"}),this.htmlWriter=new bh}}class vh extends(T()){get(e={}){const{rootName:t="main",trim:i="empty"}=e;if(!this._checkIfRootsExists([t]))throw new p("datacontroller-get-non-existent-root",this);const n=this.model.document.getRoot(t);return n.isAttached()||b("datacontroller-get-detached-root",this),"empty"!==i||this.model.hasContent(n,{ignoreWhitespaces:!0})?this.stringify(n,e):""}stringify(e,t={}){const i=this.toView(e,t);return this.processor.toData(i)}toView(e,t={}){const i=this.viewDocument,n=this._viewWriter;this.mapper.clearBindings();const s=id._createIn(e),o=new Ul(i);this.mapper.bindElements(e,o);const r=e.is("documentFragment")?e.markers:function(e){const t=[],i=e.root.document;if(!i)return new Map;const n=id._createIn(e);for(const e of i.model.markers){const i=e.getRange(),s=i.isCollapsed,o=i.start.isEqual(n.start)||i.end.isEqual(n.end);if(s&&o)t.push([e.name,i]);else{const s=n.getIntersection(i);s&&t.push([e.name,s])}}return t.sort((([e,t],[i,n])=>{if("after"!==t.end.compareWith(n.start))return 1;if("before"!==t.start.compareWith(n.end))return-1;switch(t.start.compareWith(n.start)){case"before":return 1;case"after":return-1;default:switch(t.end.compareWith(n.end)){case"before":return 1;case"after":return-1;default:return i.localeCompare(e)}}})),new Map(t)}(e);return this.downcastDispatcher.convert(s,r,n,t),o}init(e){if(this.model.document.version)throw new p("datacontroller-init-document-not-empty",this);let t={};if("string"==typeof e?t.main=e:t=e,!this._checkIfRootsExists(Object.keys(t)))throw new p("datacontroller-init-non-existent-root",this);return this.model.enqueueChange({isUndoable:!1},(e=>{for(const i of Object.keys(t)){const n=this.model.document.getRoot(i);e.insert(this.parse(t[i],n),n,0)}})),Promise.resolve()}set(e,t={}){let i={};if("string"==typeof e?i.main=e:i=e,!this._checkIfRootsExists(Object.keys(i)))throw new p("datacontroller-set-non-existent-root",this);this.model.enqueueChange(t.batchType||{},(e=>{e.setSelection(null),e.removeSelectionAttribute(this.model.document.selection.getAttributeKeys());for(const t of Object.keys(i)){const n=this.model.document.getRoot(t);e.remove(e.createRangeIn(n)),e.insert(this.parse(i[t],n),n,0)}}))}parse(e,t="$root"){const i=this.processor.toView(e);return this.toModel(i,t)}toModel(e,t="$root"){return this.model.change((i=>this.upcastDispatcher.convert(e,i,t)))}addStyleProcessorRules(e){e(this.stylesProcessor)}registerRawContentMatcher(e){this.processor&&this.processor!==this.htmlProcessor&&this.processor.registerRawContentMatcher(e),this.htmlProcessor.registerRawContentMatcher(e)}destroy(){this.stopListening()}_checkIfRootsExists(e){for(const t of e)if(!this.model.document.getRoot(t))return!1;return!0}constructor(e,t){super(),this.model=e,this.mapper=new nd,this.downcastDispatcher=new rd({mapper:this.mapper,schema:e.schema}),this.downcastDispatcher.on("insert:$text",((e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const n=i.writer,s=i.mapper.toViewPosition(t.range.start),o=n.createText(t.item.data);n.insert(s,o)}),{priority:"lowest"}),this.downcastDispatcher.on("insert",((e,t,i)=>{i.convertAttributes(t.item),t.reconversion||!t.item.is("element")||t.item.isEmpty||i.convertChildren(t.item)}),{priority:"lowest"}),this.upcastDispatcher=new ph({schema:e.schema}),this.viewDocument=new Rl(t),this.stylesProcessor=t,this.htmlProcessor=new wh(this.viewDocument),this.processor=this.htmlProcessor,this._viewWriter=new Wl(this.viewDocument),this.upcastDispatcher.on("text",((e,t,{schema:i,consumable:n,writer:s})=>{let o=t.modelCursor;if(!n.test(t.viewItem))return;if(!i.checkChild(o,"$text")){if(!Fd(o,"$text",i))return;if(0==t.viewItem.data.trim().length)return;const e=o.nodeBefore;o=Dd(o,s),e&&e.is("element","$marker")&&(s.move(s.createRangeOn(e),o),o=s.createPositionAfter(e))}n.consume(t.viewItem);const r=s.createText(t.viewItem.data);s.insert(r,o),t.modelRange=s.createRange(o,o.getShiftedBy(r.offsetSize)),t.modelCursor=t.modelRange.end}),{priority:"lowest"}),this.upcastDispatcher.on("element",((e,t,i)=>{if(!t.modelRange&&i.consumable.consume(t.viewItem,{name:!0})){const{modelRange:e,modelCursor:n}=i.convertChildren(t.viewItem,t.modelCursor);t.modelRange=e,t.modelCursor=n}}),{priority:"lowest"}),this.upcastDispatcher.on("documentFragment",((e,t,i)=>{if(!t.modelRange&&i.consumable.consume(t.viewItem,{name:!0})){const{modelRange:e,modelCursor:n}=i.convertChildren(t.viewItem,t.modelCursor);t.modelRange=e,t.modelCursor=n}}),{priority:"lowest"}),Yo().prototype.decorate.call(this,"init"),Yo().prototype.decorate.call(this,"set"),Yo().prototype.decorate.call(this,"get"),Yo().prototype.decorate.call(this,"toView"),Yo().prototype.decorate.call(this,"toModel"),this.on("init",(()=>{this.fire("ready")}),{priority:"lowest"}),this.on("ready",(()=>{this.model.enqueueChange({isUndoable:!1},Nd)}),{priority:"lowest"})}}class _h{addAlias(e,t){const i=this._downcast.includes(t);if(!this._upcast.includes(t)&&!i)throw new p("conversion-add-alias-dispatcher-not-registered",this);this._createConversionHelpers({name:e,dispatchers:[t],isDowncast:i})}for(e){if(!this._helpers.has(e))throw new p("conversion-for-unknown-group",this);return this._helpers.get(e)}elementToElement(e){this.for("downcast").elementToElement(e);for(const{model:t,view:i}of yh(e))this.for("upcast").elementToElement({model:t,view:i,converterPriority:e.converterPriority})}attributeToElement(e){this.for("downcast").attributeToElement(e);for(const{model:t,view:i}of yh(e))this.for("upcast").elementToAttribute({view:i,model:t,converterPriority:e.converterPriority})}attributeToAttribute(e){this.for("downcast").attributeToAttribute(e);for(const{model:t,view:i}of yh(e))this.for("upcast").attributeToAttribute({view:i,model:t})}_createConversionHelpers({name:e,dispatchers:t,isDowncast:i}){if(this._helpers.has(e))throw new p("conversion-group-exists",this);const n=i?new xd(t):new zd(t);this._helpers.set(e,n)}constructor(e,t){this._helpers=new Map,this._downcast=pa(e),this._createConversionHelpers({name:"downcast",dispatchers:this._downcast,isDowncast:!0}),this._upcast=pa(t),this._createConversionHelpers({name:"upcast",dispatchers:this._upcast,isDowncast:!1})}}function*yh(e){if(e.model.values)for(const t of e.model.values){const i={key:e.model.key,value:t},n=e.view[t],s=e.upcastAlso?e.upcastAlso[t]:void 0;yield*kh(i,n,s)}else yield*kh(e.model,e.view,e.upcastAlso)}function*kh(e,t,i){if(yield{model:e,view:t},i)for(const t of pa(i))yield{model:e,view:t}}class Ch{_validate(){}toJSON(){const e=Object.assign({},this);return e.__className=this.constructor.className,delete e.batch,delete e.isDocumentOperation,e}static get className(){return"Operation"}static fromJSON(e,t){return new this(e.baseVersion)}constructor(e){this.baseVersion=e,this.isDocumentOperation=null!==this.baseVersion,this.batch=null}}function xh(e,t){const i=Th(t),n=i.reduce(((e,t)=>e+t.offsetSize),0),s=e.parent;Ih(e);const o=e.index;return s._insertChild(o,i),Sh(s,o+i.length),Sh(s,o),new id(e,e.getShiftedBy(n))}function Ah(e){if(!e.isFlat)throw new p("operation-utils-remove-range-not-flat",this);const t=e.start.parent;Ih(e.start),Ih(e.end);const i=t._removeChildren(e.start.index,e.end.index-e.start.index);return Sh(t,e.start.index),i}function Eh(e,t){if(!e.isFlat)throw new p("operation-utils-move-range-not-flat",this);const i=Ah(e);return xh(t=t._getTransformedByDeletion(e.start,e.end.offset-e.start.offset),i)}function Th(e){const t=[];!function e(i){if("string"==typeof i)t.push(new jc(i));else if(i instanceof qc)t.push(new jc(i.data,i.getAttributes()));else if(i instanceof Uc)t.push(i);else if(lr(i))for(const t of i)e(t)}(e);for(let e=1;e<t.length;e++){const i=t[e],n=t[e-1];i instanceof jc&&n instanceof jc&&Ph(i,n)&&(t.splice(e-1,2,new jc(n.data+i.data,n.getAttributes())),e--)}return t}function Sh(e,t){const i=e.getChild(t-1),n=e.getChild(t);if(i&&n&&i.is("$text")&&n.is("$text")&&Ph(i,n)){const s=new jc(i.data+n.data,i.getAttributes());e._removeChildren(t-1,2),e._insertChild(t-1,s)}}function Ih(e){const t=e.textNode,i=e.parent;if(t){const n=e.offset-t.startOffset,s=t.index;i._removeChildren(s,1);const o=new jc(t.data.substr(0,n),t.getAttributes()),r=new jc(t.data.substr(n),t.getAttributes());i._insertChild(s,[o,r])}}function Ph(e,t){const i=e.getAttributes(),n=t.getAttributes();for(const e of i){if(e[1]!==t.getAttribute(e[0]))return!1;n.next()}return n.next().done}class Vh extends Ch{get type(){return"$graveyard"==this.targetPosition.root.rootName?"remove":"$graveyard"==this.sourcePosition.root.rootName?"reinsert":"move"}get affectedSelectable(){return[id._createFromPositionAndShift(this.sourcePosition,this.howMany),id._createFromPositionAndShift(this.targetPosition,0)]}clone(){return new Vh(this.sourcePosition,this.howMany,this.targetPosition,this.baseVersion)}getMovedRangeStart(){return this.targetPosition._getTransformedByDeletion(this.sourcePosition,this.howMany)}getReversed(){const e=this.sourcePosition._getTransformedByInsertion(this.targetPosition,this.howMany);return new Vh(this.getMovedRangeStart(),this.howMany,e,this.baseVersion+1)}_validate(){const e=this.sourcePosition.parent,t=this.targetPosition.parent,i=this.sourcePosition.offset,n=this.targetPosition.offset;if(i+this.howMany>e.maxOffset)throw new p("move-operation-nodes-do-not-exist",this);if(e===t&&i<n&&n<i+this.howMany)throw new p("move-operation-range-into-itself",this);if(this.sourcePosition.root==this.targetPosition.root&&"prefix"==ar(this.sourcePosition.getParentPath(),this.targetPosition.getParentPath())){const e=this.sourcePosition.path.length-1;if(this.targetPosition.path[e]>=i&&this.targetPosition.path[e]<i+this.howMany)throw new p("move-operation-node-into-itself",this)}}_execute(){Eh(id._createFromPositionAndShift(this.sourcePosition,this.howMany),this.targetPosition)}toJSON(){const e=super.toJSON();return e.sourcePosition=this.sourcePosition.toJSON(),e.targetPosition=this.targetPosition.toJSON(),e}static get className(){return"MoveOperation"}static fromJSON(e,t){const i=Jc.fromJSON(e.sourcePosition,t),n=Jc.fromJSON(e.targetPosition,t);return new this(i,e.howMany,n,e.baseVersion)}constructor(e,t,i,n){super(n),this.sourcePosition=e.clone(),this.sourcePosition.stickiness="toNext",this.howMany=t,this.targetPosition=i.clone(),this.targetPosition.stickiness="toNone"}}class Rh extends Ch{get type(){return"insert"}get howMany(){return this.nodes.maxOffset}get affectedSelectable(){return this.position.clone()}clone(){const e=new Wc([...this.nodes].map((e=>e._clone(!0)))),t=new Rh(this.position,e,this.baseVersion);return t.shouldReceiveAttributes=this.shouldReceiveAttributes,t}getReversed(){const e=this.position.root.document.graveyard,t=new Jc(e,[0]);return new Vh(this.position,this.nodes.maxOffset,t,this.baseVersion+1)}_validate(){const e=this.position.parent;if(!e||e.maxOffset<this.position.offset)throw new p("insert-operation-position-invalid",this)}_execute(){const e=this.nodes;this.nodes=new Wc([...e].map((e=>e._clone(!0)))),xh(this.position,e)}toJSON(){const e=super.toJSON();return e.position=this.position.toJSON(),e.nodes=this.nodes.toJSON(),e}static get className(){return"InsertOperation"}static fromJSON(e,t){const i=[];for(const t of e.nodes)t.name?i.push(Gc.fromJSON(t)):i.push(jc.fromJSON(t));const n=new Rh(Jc.fromJSON(e.position,t),i,e.baseVersion);return n.shouldReceiveAttributes=e.shouldReceiveAttributes,n}constructor(e,t,i){super(i),this.position=e.clone(),this.position.stickiness="toNone",this.nodes=new Wc(Th(t)),this.shouldReceiveAttributes=!1}}class Bh extends Ch{get type(){return"split"}get moveTargetPosition(){const e=this.insertionPosition.path.slice();return e.push(0),new Jc(this.insertionPosition.root,e)}get movedRange(){const e=this.splitPosition.getShiftedBy(Number.POSITIVE_INFINITY);return new id(this.splitPosition,e)}get affectedSelectable(){const e=[id._createFromPositionAndShift(this.splitPosition,0),id._createFromPositionAndShift(this.insertionPosition,0)];return this.graveyardPosition&&e.push(id._createFromPositionAndShift(this.graveyardPosition,0)),e}clone(){return new Bh(this.splitPosition,this.howMany,this.insertionPosition,this.graveyardPosition,this.baseVersion)}getReversed(){const e=this.splitPosition.root.document.graveyard,t=new Jc(e,[0]);return new Oh(this.moveTargetPosition,this.howMany,this.splitPosition,t,this.baseVersion+1)}_validate(){const e=this.splitPosition.parent,t=this.splitPosition.offset;if(!e||e.maxOffset<t)throw new p("split-operation-position-invalid",this);if(!e.parent)throw new p("split-operation-split-in-root",this);if(this.howMany!=e.maxOffset-this.splitPosition.offset)throw new p("split-operation-how-many-invalid",this);if(this.graveyardPosition&&!this.graveyardPosition.nodeAfter)throw new p("split-operation-graveyard-position-invalid",this)}_execute(){const e=this.splitPosition.parent;if(this.graveyardPosition)Eh(id._createFromPositionAndShift(this.graveyardPosition,1),this.insertionPosition);else{const t=e._clone();xh(this.insertionPosition,t)}Eh(new id(Jc._createAt(e,this.splitPosition.offset),Jc._createAt(e,e.maxOffset)),this.moveTargetPosition)}toJSON(){const e=super.toJSON();return e.splitPosition=this.splitPosition.toJSON(),e.insertionPosition=this.insertionPosition.toJSON(),this.graveyardPosition&&(e.graveyardPosition=this.graveyardPosition.toJSON()),e}static get className(){return"SplitOperation"}static getInsertionPosition(e){const t=e.path.slice(0,-1);return t[t.length-1]++,new Jc(e.root,t,"toPrevious")}static fromJSON(e,t){const i=Jc.fromJSON(e.splitPosition,t),n=Jc.fromJSON(e.insertionPosition,t),s=e.graveyardPosition?Jc.fromJSON(e.graveyardPosition,t):null;return new this(i,e.howMany,n,s,e.baseVersion)}constructor(e,t,i,n,s){super(s),this.splitPosition=e.clone(),this.splitPosition.stickiness="toNext",this.howMany=t,this.insertionPosition=i,this.graveyardPosition=n?n.clone():null,this.graveyardPosition&&(this.graveyardPosition.stickiness="toNext")}}class Oh extends Ch{get type(){return"merge"}get deletionPosition(){return new Jc(this.sourcePosition.root,this.sourcePosition.path.slice(0,-1))}get movedRange(){const e=this.sourcePosition.getShiftedBy(Number.POSITIVE_INFINITY);return new id(this.sourcePosition,e)}get affectedSelectable(){const e=this.sourcePosition.parent;return[id._createOn(e),id._createFromPositionAndShift(this.targetPosition,0),id._createFromPositionAndShift(this.graveyardPosition,0)]}clone(){return new Oh(this.sourcePosition,this.howMany,this.targetPosition,this.graveyardPosition,this.baseVersion)}getReversed(){const e=this.targetPosition._getTransformedByMergeOperation(this),t=this.sourcePosition.path.slice(0,-1),i=new Jc(this.sourcePosition.root,t)._getTransformedByMergeOperation(this);return new Bh(e,this.howMany,i,this.graveyardPosition,this.baseVersion+1)}_validate(){const e=this.sourcePosition.parent,t=this.targetPosition.parent;if(!e.parent)throw new p("merge-operation-source-position-invalid",this);if(!t.parent)throw new p("merge-operation-target-position-invalid",this);if(this.howMany!=e.maxOffset)throw new p("merge-operation-how-many-invalid",this)}_execute(){const e=this.sourcePosition.parent;Eh(id._createIn(e),this.targetPosition),Eh(id._createOn(e),this.graveyardPosition)}toJSON(){const e=super.toJSON();return e.sourcePosition=e.sourcePosition.toJSON(),e.targetPosition=e.targetPosition.toJSON(),e.graveyardPosition=e.graveyardPosition.toJSON(),e}static get className(){return"MergeOperation"}static fromJSON(e,t){const i=Jc.fromJSON(e.sourcePosition,t),n=Jc.fromJSON(e.targetPosition,t),s=Jc.fromJSON(e.graveyardPosition,t);return new this(i,e.howMany,n,s,e.baseVersion)}constructor(e,t,i,n,s){super(s),this.sourcePosition=e.clone(),this.sourcePosition.stickiness="toPrevious",this.howMany=t,this.targetPosition=i.clone(),this.targetPosition.stickiness="toNext",this.graveyardPosition=n.clone()}}class Mh extends Ch{get type(){return"marker"}get affectedSelectable(){const e=[];return this.oldRange&&e.push(this.oldRange.clone()),this.newRange&&(this.oldRange?e.push(...this.newRange.getDifference(this.oldRange)):e.push(this.newRange.clone())),e}clone(){return new Mh(this.name,this.oldRange,this.newRange,this._markers,this.affectsData,this.baseVersion)}getReversed(){return new Mh(this.name,this.newRange,this.oldRange,this._markers,this.affectsData,this.baseVersion+1)}_execute(){this.newRange?this._markers._set(this.name,this.newRange,!0,this.affectsData):this._markers._remove(this.name)}toJSON(){const e=super.toJSON();return this.oldRange&&(e.oldRange=this.oldRange.toJSON()),this.newRange&&(e.newRange=this.newRange.toJSON()),delete e._markers,e}static get className(){return"MarkerOperation"}static fromJSON(e,t){return new Mh(e.name,e.oldRange?id.fromJSON(e.oldRange,t):null,e.newRange?id.fromJSON(e.newRange,t):null,t.model.markers,e.affectsData,e.baseVersion)}constructor(e,t,i,n,s,o){super(o),this.name=e,this.oldRange=t?t.clone():null,this.newRange=i?i.clone():null,this.affectsData=s,this._markers=n}}class Lh extends Ch{get type(){return null===this.oldValue?"addAttribute":null===this.newValue?"removeAttribute":"changeAttribute"}get affectedSelectable(){return this.range.clone()}clone(){return new Lh(this.range,this.key,this.oldValue,this.newValue,this.baseVersion)}getReversed(){return new Lh(this.range,this.key,this.newValue,this.oldValue,this.baseVersion+1)}toJSON(){const e=super.toJSON();return e.range=this.range.toJSON(),e}_validate(){if(!this.range.isFlat)throw new p("attribute-operation-range-not-flat",this);for(const e of this.range.getItems({shallow:!0})){if(null!==this.oldValue&&!Do(e.getAttribute(this.key),this.oldValue))throw new p("attribute-operation-wrong-old-value",this,{item:e,key:this.key,value:this.oldValue});if(null===this.oldValue&&null!==this.newValue&&e.hasAttribute(this.key))throw new p("attribute-operation-attribute-exists",this,{node:e,key:this.key})}}_execute(){Do(this.oldValue,this.newValue)||function(e,t,i){Ih(e.start),Ih(e.end);for(const n of e.getItems({shallow:!0})){const e=n.is("$textProxy")?n.textNode:n;null!==i?e._setAttribute(t,i):e._removeAttribute(t),Sh(e.parent,e.index)}Sh(e.end.parent,e.end.index)}(this.range,this.key,this.newValue)}static get className(){return"AttributeOperation"}static fromJSON(e,t){return new Lh(id.fromJSON(e.range,t),e.key,e.oldValue,e.newValue,e.baseVersion)}constructor(e,t,i,n,s){super(s),this.range=e.clone(),this.key=t,this.oldValue=void 0===i?null:i,this.newValue=void 0===n?null:n}}class Nh extends Ch{get type(){return"noop"}get affectedSelectable(){return null}clone(){return new Nh(this.baseVersion)}getReversed(){return new Nh(this.baseVersion+1)}_execute(){}static get className(){return"NoOperation"}}class Fh extends Ch{get type(){return"rename"}get affectedSelectable(){return this.position.nodeAfter}clone(){return new Fh(this.position.clone(),this.oldName,this.newName,this.baseVersion)}getReversed(){return new Fh(this.position.clone(),this.newName,this.oldName,this.baseVersion+1)}_validate(){const e=this.position.nodeAfter;if(!(e instanceof Gc))throw new p("rename-operation-wrong-position",this);if(e.name!==this.oldName)throw new p("rename-operation-wrong-name",this)}_execute(){this.position.nodeAfter.name=this.newName}toJSON(){const e=super.toJSON();return e.position=this.position.toJSON(),e}static get className(){return"RenameOperation"}static fromJSON(e,t){return new Fh(Jc.fromJSON(e.position,t),e.oldName,e.newName,e.baseVersion)}constructor(e,t,i,n){super(n),this.position=e,this.position.stickiness="toNext",this.oldName=t,this.newName=i}}class Dh extends Ch{get type(){return null===this.oldValue?"addRootAttribute":null===this.newValue?"removeRootAttribute":"changeRootAttribute"}get affectedSelectable(){return this.root}clone(){return new Dh(this.root,this.key,this.oldValue,this.newValue,this.baseVersion)}getReversed(){return new Dh(this.root,this.key,this.newValue,this.oldValue,this.baseVersion+1)}_validate(){if(this.root!=this.root.root||this.root.is("documentFragment"))throw new p("rootattribute-operation-not-a-root",this,{root:this.root,key:this.key});if(null!==this.oldValue&&this.root.getAttribute(this.key)!==this.oldValue)throw new p("rootattribute-operation-wrong-old-value",this,{root:this.root,key:this.key});if(null===this.oldValue&&null!==this.newValue&&this.root.hasAttribute(this.key))throw new p("rootattribute-operation-attribute-exists",this,{root:this.root,key:this.key})}_execute(){null!==this.newValue?this.root._setAttribute(this.key,this.newValue):this.root._removeAttribute(this.key)}toJSON(){const e=super.toJSON();return e.root=this.root.toJSON(),e}static get className(){return"RootAttributeOperation"}static fromJSON(e,t){if(!t.getRoot(e.root))throw new p("rootattribute-operation-fromjson-no-root",this,{rootName:e.root});return new Dh(t.getRoot(e.root),e.key,e.oldValue,e.newValue,e.baseVersion)}constructor(e,t,i,n,s){super(s),this.root=e,this.key=t,this.oldValue=void 0===i?null:i,this.newValue=void 0===n?null:n}}class zh extends Ch{get type(){return this.isAdd?"addRoot":"detachRoot"}get affectedSelectable(){return this._document.getRoot(this.rootName)}clone(){return new zh(this.rootName,this.elementName,this.isAdd,this._document,this.baseVersion)}getReversed(){return new zh(this.rootName,this.elementName,!this.isAdd,this._document,this.baseVersion+1)}_execute(){this._document.getRoot(this.rootName)._isAttached=this.isAdd}toJSON(){const e=super.toJSON();return delete e._document,e}static get className(){return"RootOperation"}static fromJSON(e,t){return new zh(e.rootName,e.elementName,e.isAdd,t,e.baseVersion)}constructor(e,t,i,n,s){if(super(s),this.rootName=e,this.elementName=t,this.isAdd=i,this._document=n,!this._document.getRoot(this.rootName)){this._document.createRoot(this.elementName,this.rootName)._isAttached=!1}}}const Hh={};Hh[Lh.className]=Lh,Hh[Rh.className]=Rh,Hh[Mh.className]=Mh,Hh[Vh.className]=Vh,Hh[Nh.className]=Nh,Hh[Ch.className]=Ch,Hh[Fh.className]=Fh,Hh[Dh.className]=Dh,Hh[zh.className]=zh,Hh[Bh.className]=Bh,Hh[Oh.className]=Oh;class $h{static fromJSON(e,t){return Hh[e.__className].fromJSON(e,t)}}const Uh=new Map;function Wh(e,t,i){let n=Uh.get(e);n||(n=new Map,Uh.set(e,n)),n.set(t,i)}function jh(e){return[e]}function qh(e,t,i={}){const n=function(e,t){const i=Uh.get(e);return i&&i.has(t)?i.get(t):jh}(e.constructor,t.constructor);try{return n(e=e.clone(),t,i)}catch(e){throw e}}function Gh(e,t,i){e=e.slice(),t=t.slice();const n=new Kh(i.document,i.useRelations,i.forceWeakRemove);n.setOriginalOperations(e),n.setOriginalOperations(t);const s=n.originalOperations;if(0==e.length||0==t.length)return{operationsA:e,operationsB:t,originalOperations:s};const o=new WeakMap;for(const t of e)o.set(t,0);const r={nextBaseVersionA:e[e.length-1].baseVersion+1,nextBaseVersionB:t[t.length-1].baseVersion+1,originalOperationsACount:e.length,originalOperationsBCount:t.length};let a=0;for(;a<e.length;){const i=e[a],s=o.get(i);if(s==t.length){a++;continue}const r=t[s],l=qh(i,r,n.getContext(i,r,!0)),c=qh(r,i,n.getContext(r,i,!1));n.updateRelation(i,r),n.setOriginalOperations(l,i),n.setOriginalOperations(c,r);for(const e of l)o.set(e,s+c.length);e.splice(a,1,...l),t.splice(s,1,...c)}if(i.padWithNoOps){const i=e.length-r.originalOperationsACount,n=t.length-r.originalOperationsBCount;Jh(e,n-i),Jh(t,i-n)}return Zh(e,r.nextBaseVersionB),Zh(t,r.nextBaseVersionA),{operationsA:e,operationsB:t,originalOperations:s}}class Kh{setOriginalOperations(e,t=null){const i=t?this.originalOperations.get(t):null;for(const t of e)this.originalOperations.set(t,i||t)}updateRelation(e,t){if(e instanceof Vh)t instanceof Oh?e.targetPosition.isEqual(t.sourcePosition)||t.movedRange.containsPosition(e.targetPosition)?this._setRelation(e,t,"insertAtSource"):e.targetPosition.isEqual(t.deletionPosition)?this._setRelation(e,t,"insertBetween"):e.targetPosition.isAfter(t.sourcePosition)&&this._setRelation(e,t,"moveTargetAfter"):t instanceof Vh&&(e.targetPosition.isEqual(t.sourcePosition)||e.targetPosition.isBefore(t.sourcePosition)?this._setRelation(e,t,"insertBefore"):this._setRelation(e,t,"insertAfter"));else if(e instanceof Bh){if(t instanceof Oh)e.splitPosition.isBefore(t.sourcePosition)&&this._setRelation(e,t,"splitBefore");else if(t instanceof Vh)if(e.splitPosition.isEqual(t.sourcePosition)||e.splitPosition.isBefore(t.sourcePosition))this._setRelation(e,t,"splitBefore");else{const i=id._createFromPositionAndShift(t.sourcePosition,t.howMany);if(e.splitPosition.hasSameParentAs(t.sourcePosition)&&i.containsPosition(e.splitPosition)){const n=i.end.offset-e.splitPosition.offset,s=e.splitPosition.offset-i.start.offset;this._setRelation(e,t,{howMany:n,offset:s})}}}else if(e instanceof Oh)t instanceof Oh?(e.targetPosition.isEqual(t.sourcePosition)||this._setRelation(e,t,"mergeTargetNotMoved"),e.sourcePosition.isEqual(t.targetPosition)&&this._setRelation(e,t,"mergeSourceNotMoved"),e.sourcePosition.isEqual(t.sourcePosition)&&this._setRelation(e,t,"mergeSameElement")):t instanceof Bh?e.sourcePosition.isEqual(t.splitPosition)&&this._setRelation(e,t,"splitAtSource"):t instanceof Vh&&t.howMany>0&&(e.sourcePosition.isEqual(t.sourcePosition.getShiftedBy(t.howMany))&&this._setRelation(e,t,"mergeSourceAffected"),e.targetPosition.isEqual(t.sourcePosition)&&this._setRelation(e,t,"mergeTargetWasBefore"));else if(e instanceof Mh){const i=e.newRange;if(!i)return;if(t instanceof Vh){const n=id._createFromPositionAndShift(t.sourcePosition,t.howMany),s=n.containsPosition(i.start)||n.start.isEqual(i.start),o=n.containsPosition(i.end)||n.end.isEqual(i.end);!s&&!o||n.containsRange(i)||this._setRelation(e,t,{side:s?"left":"right",path:s?i.start.path.slice():i.end.path.slice()})}else if(t instanceof Oh){const n=i.start.isEqual(t.targetPosition),s=i.start.isEqual(t.deletionPosition),o=i.end.isEqual(t.deletionPosition),r=i.end.isEqual(t.sourcePosition);(n||s||o||r)&&this._setRelation(e,t,{wasInLeftElement:n,wasStartBeforeMergedElement:s,wasEndBeforeMergedElement:o,wasInRightElement:r})}}}getContext(e,t,i){return{aIsStrong:i,aWasUndone:this._wasUndone(e),bWasUndone:this._wasUndone(t),abRelation:this._useRelations?this._getRelation(e,t):null,baRelation:this._useRelations?this._getRelation(t,e):null,forceWeakRemove:this._forceWeakRemove}}_wasUndone(e){const t=this.originalOperations.get(e);return t.wasUndone||this._history.isUndoneOperation(t)}_getRelation(e,t){const i=this.originalOperations.get(t),n=this._history.getUndoneOperation(i);if(!n)return null;const s=this.originalOperations.get(e),o=this._relations.get(s);return o&&o.get(n)||null}_setRelation(e,t,i){const n=this.originalOperations.get(e),s=this.originalOperations.get(t);let o=this._relations.get(n);o||(o=new Map,this._relations.set(n,o)),o.set(s,i)}constructor(e,t,i=!1){this.originalOperations=new Map,this._history=e.history,this._useRelations=t,this._forceWeakRemove=!!i,this._relations=new Map}}function Zh(e,t){for(const i of e)i.baseVersion=t++}function Jh(e,t){for(let i=0;i<t;i++)e.push(new Nh(0))}function Qh(e,t,i){const n=e.nodes.getNode(0).getAttribute(t);if(n==i)return null;const s=new id(e.position,e.position.getShiftedBy(e.howMany));return new Lh(s,t,n,i,0)}function Yh(e,t){return null===e.targetPosition._getTransformedByDeletion(t.sourcePosition,t.howMany)}function Xh(e,t){const i=[];for(let n=0;n<e.length;n++){const s=e[n],o=new Vh(s.start,s.end.offset-s.start.offset,t,0);i.push(o);for(let t=n+1;t<e.length;t++)e[t]=e[t]._getTransformedByMove(o.sourcePosition,o.targetPosition,o.howMany)[0];t=t._getTransformedByMove(o.sourcePosition,o.targetPosition,o.howMany)}return i}Wh(Lh,Lh,((e,t,i)=>{if(e.key===t.key&&e.range.start.hasSameParentAs(t.range.start)){const n=e.range.getDifference(t.range).map((t=>new Lh(t,e.key,e.oldValue,e.newValue,0))),s=e.range.getIntersection(t.range);return s&&i.aIsStrong&&n.push(new Lh(s,t.key,t.newValue,e.newValue,0)),0==n.length?[new Nh(0)]:n}return[e]})),Wh(Lh,Rh,((e,t)=>{if(e.range.start.hasSameParentAs(t.position)&&e.range.containsPosition(t.position)){const i=e.range._getTransformedByInsertion(t.position,t.howMany,!t.shouldReceiveAttributes).map((t=>new Lh(t,e.key,e.oldValue,e.newValue,e.baseVersion)));if(t.shouldReceiveAttributes){const n=Qh(t,e.key,e.oldValue);n&&i.unshift(n)}return i}return e.range=e.range._getTransformedByInsertion(t.position,t.howMany,!1)[0],[e]})),Wh(Lh,Oh,((e,t)=>{const i=[];e.range.start.hasSameParentAs(t.deletionPosition)&&(e.range.containsPosition(t.deletionPosition)||e.range.start.isEqual(t.deletionPosition))&&i.push(id._createFromPositionAndShift(t.graveyardPosition,1));const n=e.range._getTransformedByMergeOperation(t);return n.isCollapsed||i.push(n),i.map((t=>new Lh(t,e.key,e.oldValue,e.newValue,e.baseVersion)))})),Wh(Lh,Vh,((e,t)=>{const i=function(e,t){const i=id._createFromPositionAndShift(t.sourcePosition,t.howMany);let n=null,s=[];i.containsRange(e,!0)?n=e:e.start.hasSameParentAs(i.start)?(s=e.getDifference(i),n=e.getIntersection(i)):s=[e];const o=[];for(let e of s){e=e._getTransformedByDeletion(t.sourcePosition,t.howMany);const i=t.getMovedRangeStart(),n=e.start.hasSameParentAs(i),s=e._getTransformedByInsertion(i,t.howMany,n);o.push(...s)}n&&o.push(n._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany,!1)[0]);return o}(e.range,t);return i.map((t=>new Lh(t,e.key,e.oldValue,e.newValue,e.baseVersion)))})),Wh(Lh,Bh,((e,t)=>{if(e.range.end.isEqual(t.insertionPosition))return t.graveyardPosition||e.range.end.offset++,[e];if(e.range.start.hasSameParentAs(t.splitPosition)&&e.range.containsPosition(t.splitPosition)){const i=e.clone();return i.range=new id(t.moveTargetPosition.clone(),e.range.end._getCombined(t.splitPosition,t.moveTargetPosition)),e.range.end=t.splitPosition.clone(),e.range.end.stickiness="toPrevious",[e,i]}return e.range=e.range._getTransformedBySplitOperation(t),[e]})),Wh(Rh,Lh,((e,t)=>{const i=[e];if(e.shouldReceiveAttributes&&e.position.hasSameParentAs(t.range.start)&&t.range.containsPosition(e.position)){const n=Qh(e,t.key,t.newValue);n&&i.push(n)}return i})),Wh(Rh,Rh,((e,t,i)=>(e.position.isEqual(t.position)&&i.aIsStrong||(e.position=e.position._getTransformedByInsertOperation(t)),[e]))),Wh(Rh,Vh,((e,t)=>(e.position=e.position._getTransformedByMoveOperation(t),[e]))),Wh(Rh,Bh,((e,t)=>(e.position=e.position._getTransformedBySplitOperation(t),[e]))),Wh(Rh,Oh,((e,t)=>(e.position=e.position._getTransformedByMergeOperation(t),[e]))),Wh(Mh,Rh,((e,t)=>(e.oldRange&&(e.oldRange=e.oldRange._getTransformedByInsertOperation(t)[0]),e.newRange&&(e.newRange=e.newRange._getTransformedByInsertOperation(t)[0]),[e]))),Wh(Mh,Mh,((e,t,i)=>{if(e.name==t.name){if(!i.aIsStrong)return[new Nh(0)];e.oldRange=t.newRange?t.newRange.clone():null}return[e]})),Wh(Mh,Oh,((e,t)=>(e.oldRange&&(e.oldRange=e.oldRange._getTransformedByMergeOperation(t)),e.newRange&&(e.newRange=e.newRange._getTransformedByMergeOperation(t)),[e]))),Wh(Mh,Vh,((e,t,i)=>{if(e.oldRange&&(e.oldRange=id._createFromRanges(e.oldRange._getTransformedByMoveOperation(t))),e.newRange){if(i.abRelation){const n=id._createFromRanges(e.newRange._getTransformedByMoveOperation(t));if("left"==i.abRelation.side&&t.targetPosition.isEqual(e.newRange.start))return e.newRange.end=n.end,e.newRange.start.path=i.abRelation.path,[e];if("right"==i.abRelation.side&&t.targetPosition.isEqual(e.newRange.end))return e.newRange.start=n.start,e.newRange.end.path=i.abRelation.path,[e]}e.newRange=id._createFromRanges(e.newRange._getTransformedByMoveOperation(t))}return[e]})),Wh(Mh,Bh,((e,t,i)=>{if(e.oldRange&&(e.oldRange=e.oldRange._getTransformedBySplitOperation(t)),e.newRange){if(i.abRelation){const n=e.newRange._getTransformedBySplitOperation(t);return e.newRange.start.isEqual(t.splitPosition)&&i.abRelation.wasStartBeforeMergedElement?e.newRange.start=Jc._createAt(t.insertionPosition):e.newRange.start.isEqual(t.splitPosition)&&!i.abRelation.wasInLeftElement&&(e.newRange.start=Jc._createAt(t.moveTargetPosition)),e.newRange.end.isEqual(t.splitPosition)&&i.abRelation.wasInRightElement?e.newRange.end=Jc._createAt(t.moveTargetPosition):e.newRange.end.isEqual(t.splitPosition)&&i.abRelation.wasEndBeforeMergedElement?e.newRange.end=Jc._createAt(t.insertionPosition):e.newRange.end=n.end,[e]}e.newRange=e.newRange._getTransformedBySplitOperation(t)}return[e]})),Wh(Oh,Rh,((e,t)=>(e.sourcePosition.hasSameParentAs(t.position)&&(e.howMany+=t.howMany),e.sourcePosition=e.sourcePosition._getTransformedByInsertOperation(t),e.targetPosition=e.targetPosition._getTransformedByInsertOperation(t),[e]))),Wh(Oh,Oh,((e,t,i)=>{if(e.sourcePosition.isEqual(t.sourcePosition)&&e.targetPosition.isEqual(t.targetPosition)){if(i.bWasUndone){const i=t.graveyardPosition.path.slice();return i.push(0),e.sourcePosition=new Jc(t.graveyardPosition.root,i),e.howMany=0,[e]}return[new Nh(0)]}if(e.sourcePosition.isEqual(t.sourcePosition)&&!e.targetPosition.isEqual(t.targetPosition)&&!i.bWasUndone&&"splitAtSource"!=i.abRelation){const n="$graveyard"==e.targetPosition.root.rootName,s="$graveyard"==t.targetPosition.root.rootName;if(s&&!n||!(n&&!s)&&i.aIsStrong){const i=t.targetPosition._getTransformedByMergeOperation(t),n=e.targetPosition._getTransformedByMergeOperation(t);return[new Vh(i,e.howMany,n,0)]}return[new Nh(0)]}return e.sourcePosition.hasSameParentAs(t.targetPosition)&&(e.howMany+=t.howMany),e.sourcePosition=e.sourcePosition._getTransformedByMergeOperation(t),e.targetPosition=e.targetPosition._getTransformedByMergeOperation(t),e.graveyardPosition.isEqual(t.graveyardPosition)&&i.aIsStrong||(e.graveyardPosition=e.graveyardPosition._getTransformedByMergeOperation(t)),[e]})),Wh(Oh,Vh,((e,t,i)=>{const n=id._createFromPositionAndShift(t.sourcePosition,t.howMany);return"remove"==t.type&&!i.bWasUndone&&!i.forceWeakRemove&&e.deletionPosition.hasSameParentAs(t.sourcePosition)&&n.containsPosition(e.sourcePosition)?[new Nh(0)]:(t.sourcePosition.getShiftedBy(t.howMany).isEqual(e.sourcePosition)?e.sourcePosition.stickiness="toNone":t.targetPosition.isEqual(e.sourcePosition)&&"mergeSourceAffected"==i.abRelation?e.sourcePosition.stickiness="toNext":t.sourcePosition.isEqual(e.targetPosition)?(e.targetPosition.stickiness="toNone",e.howMany-=t.howMany):t.targetPosition.isEqual(e.targetPosition)&&"mergeTargetWasBefore"==i.abRelation?(e.targetPosition.stickiness="toPrevious",e.howMany+=t.howMany):(e.sourcePosition.hasSameParentAs(t.targetPosition)&&(e.howMany+=t.howMany),e.sourcePosition.hasSameParentAs(t.sourcePosition)&&(e.howMany-=t.howMany)),e.sourcePosition=e.sourcePosition._getTransformedByMoveOperation(t),e.targetPosition=e.targetPosition._getTransformedByMoveOperation(t),e.sourcePosition.stickiness="toPrevious",e.targetPosition.stickiness="toNext",e.graveyardPosition.isEqual(t.targetPosition)||(e.graveyardPosition=e.graveyardPosition._getTransformedByMoveOperation(t)),[e])})),Wh(Oh,Bh,((e,t,i)=>{if(t.graveyardPosition&&(e.graveyardPosition=e.graveyardPosition._getTransformedByDeletion(t.graveyardPosition,1),e.deletionPosition.isEqual(t.graveyardPosition)&&(e.howMany=t.howMany)),e.targetPosition.isEqual(t.splitPosition)){const n=0!=t.howMany,s=t.graveyardPosition&&e.deletionPosition.isEqual(t.graveyardPosition);if(n||s||"mergeTargetNotMoved"==i.abRelation)return e.sourcePosition=e.sourcePosition._getTransformedBySplitOperation(t),[e]}if(e.sourcePosition.isEqual(t.splitPosition)){if("mergeSourceNotMoved"==i.abRelation)return e.howMany=0,e.targetPosition=e.targetPosition._getTransformedBySplitOperation(t),[e];if("mergeSameElement"==i.abRelation||e.sourcePosition.offset>0)return e.sourcePosition=t.moveTargetPosition.clone(),e.targetPosition=e.targetPosition._getTransformedBySplitOperation(t),[e]}return e.sourcePosition.hasSameParentAs(t.splitPosition)&&(e.howMany=t.splitPosition.offset),e.sourcePosition=e.sourcePosition._getTransformedBySplitOperation(t),e.targetPosition=e.targetPosition._getTransformedBySplitOperation(t),[e]})),Wh(Vh,Rh,((e,t)=>{const i=id._createFromPositionAndShift(e.sourcePosition,e.howMany)._getTransformedByInsertOperation(t,!1)[0];return e.sourcePosition=i.start,e.howMany=i.end.offset-i.start.offset,e.targetPosition.isEqual(t.position)||(e.targetPosition=e.targetPosition._getTransformedByInsertOperation(t)),[e]})),Wh(Vh,Vh,((e,t,i)=>{const n=id._createFromPositionAndShift(e.sourcePosition,e.howMany),s=id._createFromPositionAndShift(t.sourcePosition,t.howMany);let o,r=i.aIsStrong,a=!i.aIsStrong;if("insertBefore"==i.abRelation||"insertAfter"==i.baRelation?a=!0:"insertAfter"!=i.abRelation&&"insertBefore"!=i.baRelation||(a=!1),o=e.targetPosition.isEqual(t.targetPosition)&&a?e.targetPosition._getTransformedByDeletion(t.sourcePosition,t.howMany):e.targetPosition._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),Yh(e,t)&&Yh(t,e))return[t.getReversed()];if(n.containsPosition(t.targetPosition)&&n.containsRange(s,!0))return n.start=n.start._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),n.end=n.end._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),Xh([n],o);if(s.containsPosition(e.targetPosition)&&s.containsRange(n,!0))return n.start=n.start._getCombined(t.sourcePosition,t.getMovedRangeStart()),n.end=n.end._getCombined(t.sourcePosition,t.getMovedRangeStart()),Xh([n],o);const l=ar(e.sourcePosition.getParentPath(),t.sourcePosition.getParentPath());if("prefix"==l||"extension"==l)return n.start=n.start._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),n.end=n.end._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),Xh([n],o);"remove"!=e.type||"remove"==t.type||i.aWasUndone||i.forceWeakRemove?"remove"==e.type||"remove"!=t.type||i.bWasUndone||i.forceWeakRemove||(r=!1):r=!0;const c=[],d=n.getDifference(s);for(const e of d){e.start=e.start._getTransformedByDeletion(t.sourcePosition,t.howMany),e.end=e.end._getTransformedByDeletion(t.sourcePosition,t.howMany);const i="same"==ar(e.start.getParentPath(),t.getMovedRangeStart().getParentPath()),n=e._getTransformedByInsertion(t.getMovedRangeStart(),t.howMany,i);c.push(...n)}const h=n.getIntersection(s);return null!==h&&r&&(h.start=h.start._getCombined(t.sourcePosition,t.getMovedRangeStart()),h.end=h.end._getCombined(t.sourcePosition,t.getMovedRangeStart()),0===c.length?c.push(h):1==c.length?s.start.isBefore(n.start)||s.start.isEqual(n.start)?c.unshift(h):c.push(h):c.splice(1,0,h)),0===c.length?[new Nh(e.baseVersion)]:Xh(c,o)})),Wh(Vh,Bh,((e,t,i)=>{let n=e.targetPosition.clone();e.targetPosition.isEqual(t.insertionPosition)&&t.graveyardPosition&&"moveTargetAfter"!=i.abRelation||(n=e.targetPosition._getTransformedBySplitOperation(t));const s=id._createFromPositionAndShift(e.sourcePosition,e.howMany);if(s.end.isEqual(t.insertionPosition))return t.graveyardPosition||e.howMany++,e.targetPosition=n,[e];if(s.start.hasSameParentAs(t.splitPosition)&&s.containsPosition(t.splitPosition)){let e=new id(t.splitPosition,s.end);e=e._getTransformedBySplitOperation(t);return Xh([new id(s.start,t.splitPosition),e],n)}e.targetPosition.isEqual(t.splitPosition)&&"insertAtSource"==i.abRelation&&(n=t.moveTargetPosition),e.targetPosition.isEqual(t.insertionPosition)&&"insertBetween"==i.abRelation&&(n=e.targetPosition);const o=[s._getTransformedBySplitOperation(t)];if(t.graveyardPosition){const n=s.start.isEqual(t.graveyardPosition)||s.containsPosition(t.graveyardPosition);e.howMany>1&&n&&!i.aWasUndone&&o.push(id._createFromPositionAndShift(t.insertionPosition,1))}return Xh(o,n)})),Wh(Vh,Oh,((e,t,i)=>{const n=id._createFromPositionAndShift(e.sourcePosition,e.howMany);if(t.deletionPosition.hasSameParentAs(e.sourcePosition)&&n.containsPosition(t.sourcePosition))if("remove"!=e.type||i.forceWeakRemove){if(1==e.howMany)return i.bWasUndone?(e.sourcePosition=t.graveyardPosition.clone(),e.targetPosition=e.targetPosition._getTransformedByMergeOperation(t),[e]):[new Nh(0)]}else if(!i.aWasUndone){const i=[];let n=t.graveyardPosition.clone(),s=t.targetPosition._getTransformedByMergeOperation(t);e.howMany>1&&(i.push(new Vh(e.sourcePosition,e.howMany-1,e.targetPosition,0)),n=n._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany-1),s=s._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany-1));const o=t.deletionPosition._getCombined(e.sourcePosition,e.targetPosition),r=new Vh(n,1,o,0),a=r.getMovedRangeStart().path.slice();a.push(0);const l=new Jc(r.targetPosition.root,a);s=s._getTransformedByMove(n,o,1);const c=new Vh(s,t.howMany,l,0);return i.push(r),i.push(c),i}const s=id._createFromPositionAndShift(e.sourcePosition,e.howMany)._getTransformedByMergeOperation(t);return e.sourcePosition=s.start,e.howMany=s.end.offset-s.start.offset,e.targetPosition=e.targetPosition._getTransformedByMergeOperation(t),[e]})),Wh(Fh,Rh,((e,t)=>(e.position=e.position._getTransformedByInsertOperation(t),[e]))),Wh(Fh,Oh,((e,t)=>e.position.isEqual(t.deletionPosition)?(e.position=t.graveyardPosition.clone(),e.position.stickiness="toNext",[e]):(e.position=e.position._getTransformedByMergeOperation(t),[e]))),Wh(Fh,Vh,((e,t)=>(e.position=e.position._getTransformedByMoveOperation(t),[e]))),Wh(Fh,Fh,((e,t,i)=>{if(e.position.isEqual(t.position)){if(!i.aIsStrong)return[new Nh(0)];e.oldName=t.newName}return[e]})),Wh(Fh,Bh,((e,t)=>{if("same"==ar(e.position.path,t.splitPosition.getParentPath())&&!t.graveyardPosition){const t=new Fh(e.position.getShiftedBy(1),e.oldName,e.newName,0);return[e,t]}return e.position=e.position._getTransformedBySplitOperation(t),[e]})),Wh(Dh,Dh,((e,t,i)=>{if(e.root===t.root&&e.key===t.key){if(!i.aIsStrong||e.newValue===t.newValue)return[new Nh(0)];e.oldValue=t.newValue}return[e]})),Wh(zh,zh,((e,t)=>e.rootName===t.rootName&&e.isAdd===t.isAdd?[new Nh(0)]:[e])),Wh(Bh,Rh,((e,t)=>(e.splitPosition.hasSameParentAs(t.position)&&e.splitPosition.offset<t.position.offset&&(e.howMany+=t.howMany),e.splitPosition=e.splitPosition._getTransformedByInsertOperation(t),e.insertionPosition=e.insertionPosition._getTransformedByInsertOperation(t),[e]))),Wh(Bh,Oh,((e,t,i)=>{if(!e.graveyardPosition&&!i.bWasUndone&&e.splitPosition.hasSameParentAs(t.sourcePosition)){const i=t.graveyardPosition.path.slice();i.push(0);const n=new Jc(t.graveyardPosition.root,i),s=Bh.getInsertionPosition(new Jc(t.graveyardPosition.root,i)),o=new Bh(n,0,s,null,0);return e.splitPosition=e.splitPosition._getTransformedByMergeOperation(t),e.insertionPosition=Bh.getInsertionPosition(e.splitPosition),e.graveyardPosition=o.insertionPosition.clone(),e.graveyardPosition.stickiness="toNext",[o,e]}return e.splitPosition.hasSameParentAs(t.deletionPosition)&&!e.splitPosition.isAfter(t.deletionPosition)&&e.howMany--,e.splitPosition.hasSameParentAs(t.targetPosition)&&(e.howMany+=t.howMany),e.splitPosition=e.splitPosition._getTransformedByMergeOperation(t),e.insertionPosition=Bh.getInsertionPosition(e.splitPosition),e.graveyardPosition&&(e.graveyardPosition=e.graveyardPosition._getTransformedByMergeOperation(t)),[e]})),Wh(Bh,Vh,((e,t,i)=>{const n=id._createFromPositionAndShift(t.sourcePosition,t.howMany);if(e.graveyardPosition){const s=n.start.isEqual(e.graveyardPosition)||n.containsPosition(e.graveyardPosition);if(!i.bWasUndone&&s){const i=e.splitPosition._getTransformedByMoveOperation(t),n=e.graveyardPosition._getTransformedByMoveOperation(t),s=n.path.slice();s.push(0);const o=new Jc(n.root,s);return[new Vh(i,e.howMany,o,0)]}e.graveyardPosition=e.graveyardPosition._getTransformedByMoveOperation(t)}const s=e.splitPosition.isEqual(t.targetPosition);if(s&&("insertAtSource"==i.baRelation||"splitBefore"==i.abRelation))return e.howMany+=t.howMany,e.splitPosition=e.splitPosition._getTransformedByDeletion(t.sourcePosition,t.howMany),e.insertionPosition=Bh.getInsertionPosition(e.splitPosition),[e];if(s&&i.abRelation&&i.abRelation.howMany){const{howMany:t,offset:n}=i.abRelation;return e.howMany+=t,e.splitPosition=e.splitPosition.getShiftedBy(n),[e]}if(e.splitPosition.hasSameParentAs(t.sourcePosition)&&n.containsPosition(e.splitPosition)){const i=t.howMany-(e.splitPosition.offset-t.sourcePosition.offset);return e.howMany-=i,e.splitPosition.hasSameParentAs(t.targetPosition)&&e.splitPosition.offset<t.targetPosition.offset&&(e.howMany+=t.howMany),e.splitPosition=t.sourcePosition.clone(),e.insertionPosition=Bh.getInsertionPosition(e.splitPosition),[e]}return t.sourcePosition.isEqual(t.targetPosition)||(e.splitPosition.hasSameParentAs(t.sourcePosition)&&e.splitPosition.offset<=t.sourcePosition.offset&&(e.howMany-=t.howMany),e.splitPosition.hasSameParentAs(t.targetPosition)&&e.splitPosition.offset<t.targetPosition.offset&&(e.howMany+=t.howMany)),e.splitPosition.stickiness="toNone",e.splitPosition=e.splitPosition._getTransformedByMoveOperation(t),e.splitPosition.stickiness="toNext",e.graveyardPosition?e.insertionPosition=e.insertionPosition._getTransformedByMoveOperation(t):e.insertionPosition=Bh.getInsertionPosition(e.splitPosition),[e]})),Wh(Bh,Bh,((e,t,i)=>{if(e.splitPosition.isEqual(t.splitPosition)){if(!e.graveyardPosition&&!t.graveyardPosition)return[new Nh(0)];if(e.graveyardPosition&&t.graveyardPosition&&e.graveyardPosition.isEqual(t.graveyardPosition))return[new Nh(0)];if("splitBefore"==i.abRelation)return e.howMany=0,e.graveyardPosition=e.graveyardPosition._getTransformedBySplitOperation(t),[e]}if(e.graveyardPosition&&t.graveyardPosition&&e.graveyardPosition.isEqual(t.graveyardPosition)){const n="$graveyard"==e.splitPosition.root.rootName,s="$graveyard"==t.splitPosition.root.rootName;if(s&&!n||!(n&&!s)&&i.aIsStrong){const i=[];return t.howMany&&i.push(new Vh(t.moveTargetPosition,t.howMany,t.splitPosition,0)),e.howMany&&i.push(new Vh(e.splitPosition,e.howMany,e.moveTargetPosition,0)),i}return[new Nh(0)]}if(e.graveyardPosition&&(e.graveyardPosition=e.graveyardPosition._getTransformedBySplitOperation(t)),e.splitPosition.isEqual(t.insertionPosition)&&"splitBefore"==i.abRelation)return e.howMany++,[e];if(t.splitPosition.isEqual(e.insertionPosition)&&"splitBefore"==i.baRelation){const i=t.insertionPosition.path.slice();i.push(0);const n=new Jc(t.insertionPosition.root,i);return[e,new Vh(e.insertionPosition,1,n,0)]}return e.splitPosition.hasSameParentAs(t.splitPosition)&&e.splitPosition.offset<t.splitPosition.offset&&(e.howMany-=t.howMany),e.splitPosition=e.splitPosition._getTransformedBySplitOperation(t),e.insertionPosition=Bh.getInsertionPosition(e.splitPosition),[e]}));class eu extends(T(Jc)){detach(){this.stopListening()}toPosition(){return new Jc(this.root,this.path.slice(),this.stickiness)}static fromPosition(e,t){return new this(e.root,e.path.slice(),t||e.stickiness)}constructor(e,t,i="toNone"){if(super(e,t,i),!this.root.is("rootElement"))throw new p("model-liveposition-root-not-rootelement",e);tu.call(this)}}function tu(){this.listenTo(this.root.document.model,"applyOperation",((e,t)=>{const i=t[0];i.isDocumentOperation&&iu.call(this,i)}),{priority:"low"})}function iu(e){const t=this.getTransformedByOperation(e);if(!this.isEqual(t)){const e=this.toPosition();this.path=t.path,this.root=t.root,this.fire("change",e)}}eu.prototype.is=function(e){return"livePosition"===e||"model:livePosition"===e||"position"==e||"model:position"===e};class nu{get type(){return b("batch-type-deprecated"),"default"}get baseVersion(){for(const e of this.operations)if(null!==e.baseVersion)return e.baseVersion;return null}addOperation(e){return e.batch=this,this.operations.push(e),e}constructor(e={}){"string"==typeof e&&(e="transparent"===e?{isUndoable:!1}:{},b("batch-constructor-deprecated-string-type"));const{isUndoable:t=!0,isLocal:i=!0,isUndo:n=!1,isTyping:s=!1}=e;this.operations=[],this.isUndoable=t,this.isLocal=i,this.isUndo=n,this.isTyping=s}}class su{get isEmpty(){return 0==this._changesInElement.size&&0==this._changedMarkers.size&&0==this._changedRoots.size}bufferOperation(e){const t=e;switch(t.type){case"insert":if(this._isInInsertedElement(t.position.parent))return;this._markInsert(t.position.parent,t.position.offset,t.nodes.maxOffset);break;case"addAttribute":case"removeAttribute":case"changeAttribute":for(const e of t.range.getItems({shallow:!0}))this._isInInsertedElement(e.parent)||this._markAttribute(e);break;case"remove":case"move":case"reinsert":{if(t.sourcePosition.isEqual(t.targetPosition)||t.sourcePosition.getShiftedBy(t.howMany).isEqual(t.targetPosition))return;const e=this._isInInsertedElement(t.sourcePosition.parent),i=this._isInInsertedElement(t.targetPosition.parent);e||this._markRemove(t.sourcePosition.parent,t.sourcePosition.offset,t.howMany),i||this._markInsert(t.targetPosition.parent,t.getMovedRangeStart().offset,t.howMany);break}case"rename":{if(this._isInInsertedElement(t.position.parent))return;this._markRemove(t.position.parent,t.position.offset,1),this._markInsert(t.position.parent,t.position.offset,1);const e=id._createFromPositionAndShift(t.position,1);for(const t of this._markerCollection.getMarkersIntersectingRange(e)){const e=t.getData();this.bufferMarkerChange(t.name,e,e)}break}case"split":{const e=t.splitPosition.parent;this._isInInsertedElement(e)||this._markRemove(e,t.splitPosition.offset,t.howMany),this._isInInsertedElement(t.insertionPosition.parent)||this._markInsert(t.insertionPosition.parent,t.insertionPosition.offset,1),t.graveyardPosition&&this._markRemove(t.graveyardPosition.parent,t.graveyardPosition.offset,1);break}case"merge":{const e=t.sourcePosition.parent;this._isInInsertedElement(e.parent)||this._markRemove(e.parent,e.startOffset,1);const i=t.graveyardPosition.parent;this._markInsert(i,t.graveyardPosition.offset,1);const n=t.targetPosition.parent;this._isInInsertedElement(n)||this._markInsert(n,t.targetPosition.offset,e.maxOffset);break}case"detachRoot":case"addRoot":{const e=t.affectedSelectable;if(!e._isLoaded)return;if(e.isAttached()==t.isAdd)return;this._bufferRootStateChange(t.rootName,t.isAdd);break}case"addRootAttribute":case"removeRootAttribute":case"changeRootAttribute":{if(!t.root._isLoaded)return;const e=t.root.rootName;this._bufferRootAttributeChange(e,t.key,t.oldValue,t.newValue);break}}this._cachedChanges=null}bufferMarkerChange(e,t,i){t.range&&t.range.root.is("rootElement")&&!t.range.root._isLoaded&&(t.range=null),i.range&&i.range.root.is("rootElement")&&!i.range.root._isLoaded&&(i.range=null);let n=this._changedMarkers.get(e);n?n.newMarkerData=i:(n={newMarkerData:i,oldMarkerData:t},this._changedMarkers.set(e,n)),null==n.oldMarkerData.range&&null==i.range&&this._changedMarkers.delete(e)}getMarkersToRemove(){const e=[];for(const[t,i]of this._changedMarkers)null!=i.oldMarkerData.range&&e.push({name:t,range:i.oldMarkerData.range});return e}getMarkersToAdd(){const e=[];for(const[t,i]of this._changedMarkers)null!=i.newMarkerData.range&&e.push({name:t,range:i.newMarkerData.range});return e}getChangedMarkers(){return Array.from(this._changedMarkers).map((([e,t])=>({name:e,data:{oldRange:t.oldMarkerData.range,newRange:t.newMarkerData.range}})))}hasDataChanges(){if(this.getChanges().length)return!0;if(this._changedRoots.size>0)return!0;for(const{newMarkerData:e,oldMarkerData:t}of this._changedMarkers.values()){if(e.affectsData!==t.affectsData)return!0;if(e.affectsData){const i=e.range&&!t.range,n=!e.range&&t.range,s=e.range&&t.range&&!e.range.isEqual(t.range);if(i||n||s)return!0}}return!1}getChanges(e={}){if(this._cachedChanges)return e.includeChangesInGraveyard?this._cachedChangesWithGraveyard.slice():this._cachedChanges.slice();let t=[];for(const e of this._changesInElement.keys()){const i=this._changesInElement.get(e).sort(((e,t)=>e.offset===t.offset?e.type!=t.type?"remove"==e.type?-1:1:0:e.offset<t.offset?-1:1)),n=this._elementSnapshots.get(e),s=ou(e.getChildren()),o=ru(n.length,i);let r=0,a=0;for(const i of o)if("i"===i)t.push(this._getInsertDiff(e,r,s[r])),r++;else if("r"===i)t.push(this._getRemoveDiff(e,r,n[a])),a++;else if("a"===i){const i=s[r].attributes,o=n[a].attributes;let l;if("$text"==s[r].name)l=new id(Jc._createAt(e,r),Jc._createAt(e,r+1));else{const t=e.offsetToIndex(r);l=new id(Jc._createAt(e,r),Jc._createAt(e.getChild(t),0))}t.push(...this._getAttributesDiff(l,o,i)),r++,a++}else r++,a++}t.sort(((e,t)=>e.position.root!=t.position.root?e.position.root.rootName<t.position.root.rootName?-1:1:e.position.isEqual(t.position)?e.changeCount-t.changeCount:e.position.isBefore(t.position)?-1:1));for(let e=1,i=0;e<t.length;e++){const n=t[i],s=t[e],o="remove"==n.type&&"remove"==s.type&&"$text"==n.name&&"$text"==s.name&&n.position.isEqual(s.position),r="insert"==n.type&&"insert"==s.type&&"$text"==n.name&&"$text"==s.name&&n.position.parent==s.position.parent&&n.position.offset+n.length==s.position.offset,a="attribute"==n.type&&"attribute"==s.type&&n.position.parent==s.position.parent&&n.range.isFlat&&s.range.isFlat&&n.position.offset+n.length==s.position.offset&&n.attributeKey==s.attributeKey&&n.attributeOldValue==s.attributeOldValue&&n.attributeNewValue==s.attributeNewValue;o||r||a?(n.length++,a&&(n.range.end=n.range.end.getShiftedBy(1)),t[e]=null):i=e}t=t.filter((e=>e));for(const e of t)delete e.changeCount,"attribute"==e.type&&(delete e.position,delete e.length);return this._changeCount=0,this._cachedChangesWithGraveyard=t,this._cachedChanges=t.filter(au),e.includeChangesInGraveyard?this._cachedChangesWithGraveyard.slice():this._cachedChanges.slice()}getChangedRoots(){return Array.from(this._changedRoots.values()).map((e=>{const t={...e};return void 0!==t.state&&delete t.attributes,t}))}getRefreshedItems(){return new Set(this._refreshedItems)}reset(){this._changesInElement.clear(),this._elementSnapshots.clear(),this._changedMarkers.clear(),this._changedRoots.clear(),this._refreshedItems=new Set,this._cachedChanges=null}_bufferRootStateChange(e,t){if(!this._changedRoots.has(e))return void this._changedRoots.set(e,{name:e,state:t?"attached":"detached"});const i=this._changedRoots.get(e);void 0!==i.state?(delete i.state,void 0===i.attributes&&this._changedRoots.delete(e)):i.state=t?"attached":"detached"}_bufferRootAttributeChange(e,t,i,n){const s=this._changedRoots.get(e)||{name:e},o=s.attributes||{};if(o[t]){const e=o[t];n===e.oldValue?delete o[t]:e.newValue=n}else o[t]={oldValue:i,newValue:n};0===Object.entries(o).length?(delete s.attributes,void 0===s.state&&this._changedRoots.delete(e)):(s.attributes=o,this._changedRoots.set(e,s))}_refreshItem(e){if(this._isInInsertedElement(e.parent))return;this._markRemove(e.parent,e.startOffset,e.offsetSize),this._markInsert(e.parent,e.startOffset,e.offsetSize),this._refreshedItems.add(e);const t=id._createOn(e);for(const e of this._markerCollection.getMarkersIntersectingRange(t)){const t=e.getData();this.bufferMarkerChange(e.name,t,t)}this._cachedChanges=null}_bufferRootLoad(e){if(e.isAttached()){this._bufferRootStateChange(e.rootName,!0),this._markInsert(e,0,e.maxOffset);for(const t of e.getAttributeKeys())this._bufferRootAttributeChange(e.rootName,t,null,e.getAttribute(t));for(const t of this._markerCollection)if(t.getRange().root==e){const e=t.getData();this.bufferMarkerChange(t.name,{...e,range:null},e)}}}_markInsert(e,t,i){if(e.root.is("rootElement")&&!e.root._isLoaded)return;const n={type:"insert",offset:t,howMany:i,count:this._changeCount++};this._markChange(e,n)}_markRemove(e,t,i){if(e.root.is("rootElement")&&!e.root._isLoaded)return;const n={type:"remove",offset:t,howMany:i,count:this._changeCount++};this._markChange(e,n),this._removeAllNestedChanges(e,t,i)}_markAttribute(e){if(e.root.is("rootElement")&&!e.root._isLoaded)return;const t={type:"attribute",offset:e.startOffset,howMany:e.offsetSize,count:this._changeCount++};this._markChange(e.parent,t)}_markChange(e,t){this._makeSnapshot(e);const i=this._getChangesForElement(e);this._handleChange(t,i),i.push(t);for(let e=0;e<i.length;e++)i[e].howMany<1&&(i.splice(e,1),e--)}_getChangesForElement(e){let t;return this._changesInElement.has(e)?t=this._changesInElement.get(e):(t=[],this._changesInElement.set(e,t)),t}_makeSnapshot(e){this._elementSnapshots.has(e)||this._elementSnapshots.set(e,ou(e.getChildren()))}_handleChange(e,t){e.nodesToHandle=e.howMany;for(const i of t){const n=e.offset+e.howMany,s=i.offset+i.howMany;if("insert"==e.type&&("insert"==i.type&&(e.offset<=i.offset?i.offset+=e.howMany:e.offset<s&&(i.howMany+=e.nodesToHandle,e.nodesToHandle=0)),"remove"==i.type&&e.offset<i.offset&&(i.offset+=e.howMany),"attribute"==i.type))if(e.offset<=i.offset)i.offset+=e.howMany;else if(e.offset<s){const s=i.howMany;i.howMany=e.offset-i.offset,t.unshift({type:"attribute",offset:n,howMany:s-i.howMany,count:this._changeCount++})}if("remove"==e.type){if("insert"==i.type)if(n<=i.offset)i.offset-=e.howMany;else if(n<=s)if(e.offset<i.offset){const t=n-i.offset;i.offset=e.offset,i.howMany-=t,e.nodesToHandle-=t}else i.howMany-=e.nodesToHandle,e.nodesToHandle=0;else if(e.offset<=i.offset)e.nodesToHandle-=i.howMany,i.howMany=0;else if(e.offset<s){const t=s-e.offset;i.howMany-=t,e.nodesToHandle-=t}if("remove"==i.type&&(n<=i.offset?i.offset-=e.howMany:e.offset<i.offset&&(e.nodesToHandle+=i.howMany,i.howMany=0)),"attribute"==i.type)if(n<=i.offset)i.offset-=e.howMany;else if(e.offset<i.offset){const t=n-i.offset;i.offset=e.offset,i.howMany-=t}else if(e.offset<s)if(n<=s){const n=i.howMany;i.howMany=e.offset-i.offset;const s=n-i.howMany-e.nodesToHandle;t.unshift({type:"attribute",offset:e.offset,howMany:s,count:this._changeCount++})}else i.howMany-=s-e.offset}if("attribute"==e.type){if("insert"==i.type)if(e.offset<i.offset&&n>i.offset){if(n>s){const e={type:"attribute",offset:s,howMany:n-s,count:this._changeCount++};this._handleChange(e,t),t.push(e)}e.nodesToHandle=i.offset-e.offset,e.howMany=e.nodesToHandle}else e.offset>=i.offset&&e.offset<s&&(n>s?(e.nodesToHandle=n-s,e.offset=s):e.nodesToHandle=0);if("remove"==i.type&&e.offset<i.offset&&n>i.offset){const s={type:"attribute",offset:i.offset,howMany:n-i.offset,count:this._changeCount++};this._handleChange(s,t),t.push(s),e.nodesToHandle=i.offset-e.offset,e.howMany=e.nodesToHandle}"attribute"==i.type&&(e.offset>=i.offset&&n<=s?(e.nodesToHandle=0,e.howMany=0,e.offset=0):e.offset<=i.offset&&n>=s&&(i.howMany=0))}}e.howMany=e.nodesToHandle,delete e.nodesToHandle}_getInsertDiff(e,t,i){return{type:"insert",position:Jc._createAt(e,t),name:i.name,attributes:new Map(i.attributes),length:1,changeCount:this._changeCount++,_element:i.element}}_getRemoveDiff(e,t,i){return{type:"remove",position:Jc._createAt(e,t),name:i.name,attributes:new Map(i.attributes),length:1,changeCount:this._changeCount++,_element:i.element}}_getAttributesDiff(e,t,i){const n=[];i=new Map(i);for(const[s,o]of t){const t=i.has(s)?i.get(s):null;t!==o&&n.push({type:"attribute",position:e.start,range:e.clone(),length:1,attributeKey:s,attributeOldValue:o,attributeNewValue:t,changeCount:this._changeCount++}),i.delete(s)}for(const[t,s]of i)n.push({type:"attribute",position:e.start,range:e.clone(),length:1,attributeKey:t,attributeOldValue:null,attributeNewValue:s,changeCount:this._changeCount++});return n}_isInInsertedElement(e){const t=e.parent;if(!t)return!1;const i=this._changesInElement.get(t),n=e.startOffset;if(i)for(const e of i)if("insert"==e.type&&n>=e.offset&&n<e.offset+e.howMany)return!0;return this._isInInsertedElement(t)}_removeAllNestedChanges(e,t,i){const n=new id(Jc._createAt(e,t),Jc._createAt(e,t+i));for(const e of n.getItems({shallow:!0}))e.is("element")&&(this._elementSnapshots.delete(e),this._changesInElement.delete(e),this._removeAllNestedChanges(e,0,e.maxOffset))}constructor(e){this._changesInElement=new Map,this._elementSnapshots=new Map,this._changedMarkers=new Map,this._changedRoots=new Map,this._changeCount=0,this._cachedChanges=null,this._cachedChangesWithGraveyard=null,this._refreshedItems=new Set,this._markerCollection=e}}function ou(e){const t=[];for(const i of e)if(i.is("$text"))for(let e=0;e<i.data.length;e++)t.push({name:"$text",attributes:new Map(i.getAttributes())});else t.push({name:i.name,attributes:new Map(i.getAttributes()),element:i});return t}function ru(e,t){const i=[];let n=0,s=0;for(const e of t){if(e.offset>n){for(let t=0;t<e.offset-n;t++)i.push("e");s+=e.offset-n}if("insert"==e.type){for(let t=0;t<e.howMany;t++)i.push("i");n=e.offset+e.howMany}else if("remove"==e.type){for(let t=0;t<e.howMany;t++)i.push("r");n=e.offset,s+=e.howMany}else i.push(..."a".repeat(e.howMany).split("")),n=e.offset+e.howMany,s+=e.howMany}if(s<e)for(let t=0;t<e-s-n;t++)i.push("e");return i}function au(e){const t="position"in e&&"$graveyard"==e.position.root.rootName,i="range"in e&&"$graveyard"==e.range.root.rootName;return!t&&!i}class lu{get version(){return this._version}set version(e){this._operations.length&&e>this._version+1&&this._gaps.set(this._version,e),this._version=e}get lastOperation(){return this._operations[this._operations.length-1]}addOperation(e){if(e.baseVersion!==this.version)throw new p("model-document-history-addoperation-incorrect-version",this,{operation:e,historyVersion:this.version});this._operations.push(e),this._version++,this._baseVersionToOperationIndex.set(e.baseVersion,this._operations.length-1)}getOperations(e,t=this.version){if(!this._operations.length)return[];const i=this._operations[0];void 0===e&&(e=i.baseVersion);let n=t-1;for(const[t,i]of this._gaps)e>t&&e<i&&(e=i),n>t&&n<i&&(n=t-1);if(n<i.baseVersion||e>this.lastOperation.baseVersion)return[];let s=this._baseVersionToOperationIndex.get(e);void 0===s&&(s=0);let o=this._baseVersionToOperationIndex.get(n);return void 0===o&&(o=this._operations.length-1),this._operations.slice(s,o+1)}getOperation(e){const t=this._baseVersionToOperationIndex.get(e);if(void 0!==t)return this._operations[t]}setOperationAsUndone(e,t){this._undoPairs.set(t,e),this._undoneOperations.add(e)}isUndoingOperation(e){return this._undoPairs.has(e)}isUndoneOperation(e){return this._undoneOperations.has(e)}getUndoneOperation(e){return this._undoPairs.get(e)}reset(){this._version=0,this._undoPairs=new Map,this._operations=[],this._undoneOperations=new Set,this._gaps=new Map,this._baseVersionToOperationIndex=new Map}constructor(){this._operations=[],this._undoPairs=new Map,this._undoneOperations=new Set,this._baseVersionToOperationIndex=new Map,this._version=0,this._gaps=new Map}}class cu extends Gc{get document(){return this._document}isAttached(){return this._isAttached}toJSON(){return this.rootName}constructor(e,t,i="main"){super(t),this._isAttached=!0,this._isLoaded=!0,this._document=e,this.rootName=i}}cu.prototype.is=function(e,t){return t?t===this.name&&("rootElement"===e||"model:rootElement"===e||"element"===e||"model:element"===e):"rootElement"===e||"model:rootElement"===e||"element"===e||"model:element"===e||"node"===e||"model:node"===e};const du="$graveyard";class hu extends(T()){get version(){return this.history.version}set version(e){this.history.version=e}get graveyard(){return this.getRoot(du)}createRoot(e="$root",t="main"){if(this.roots.get(t))throw new p("model-document-createroot-name-exists",this,{name:t});const i=new cu(this,e,t);return this.roots.add(i),i}destroy(){this.selection.destroy(),this.stopListening()}getRoot(e="main"){return this.roots.get(e)}getRootNames(e=!1){return this.getRoots(e).map((e=>e.rootName))}getRoots(e=!1){return this.roots.filter((t=>t!=this.graveyard&&(e||t.isAttached())&&t._isLoaded))}registerPostFixer(e){this._postFixers.add(e)}toJSON(){const e=bs(this);return e.selection="[engine.model.DocumentSelection]",e.model="[engine.model.Model]",e}_handleChangeBlock(e){this._hasDocumentChangedFromTheLastChangeBlock()&&(this._callPostFixers(e),this.selection.refresh(),this.differ.hasDataChanges()?this.fire("change:data",e.batch):this.fire("change",e.batch),this.selection.refresh(),this.differ.reset()),this._hasSelectionChangedFromTheLastChangeBlock=!1}_hasDocumentChangedFromTheLastChangeBlock(){return!this.differ.isEmpty||this._hasSelectionChangedFromTheLastChangeBlock}_getDefaultRoot(){const e=this.getRoots();return e.length?e[0]:this.graveyard}_getDefaultRange(){const e=this._getDefaultRoot(),t=this.model,i=t.schema,n=t.createPositionFromPath(e,[0]);return i.getNearestSelectionRange(n)||t.createRange(n)}_validateSelectionRange(e){return uu(e.start)&&uu(e.end)}_callPostFixers(e){let t=!1;do{for(const i of this._postFixers)if(this.selection.refresh(),t=i(e),t)break}while(t)}constructor(e){super(),this.model=e,this.history=new lu,this.selection=new _d(this),this.roots=new va({idProperty:"rootName"}),this.differ=new su(e.markers),this.isReadOnly=!1,this._postFixers=new Set,this._hasSelectionChangedFromTheLastChangeBlock=!1,this.createRoot("$root",du),this.listenTo(e,"applyOperation",((e,t)=>{const i=t[0];i.isDocumentOperation&&this.differ.bufferOperation(i)}),{priority:"high"}),this.listenTo(e,"applyOperation",((e,t)=>{const i=t[0];i.isDocumentOperation&&this.history.addOperation(i)}),{priority:"low"}),this.listenTo(this.selection,"change",(()=>{this._hasSelectionChangedFromTheLastChangeBlock=!0})),this.listenTo(e.markers,"update",((e,t,i,n,s)=>{const o={...t.getData(),range:n};this.differ.bufferMarkerChange(t.name,s,o),null===i&&t.on("change",((e,i)=>{const n=t.getData();this.differ.bufferMarkerChange(t.name,{...n,range:i},n)}))})),this.registerPostFixer((e=>{let t=!1;for(const i of this.roots)i.isAttached()||i.isEmpty||(e.remove(e.createRangeIn(i)),t=!0);for(const i of this.model.markers)i.getRange().root.isAttached()||(e.removeMarker(i),t=!0);return t}))}}function uu(e){const t=e.textNode;if(t){const i=t.data,n=e.offset-t.startOffset;return!Ba(i,n)&&!Oa(i,n)}return!0}class mu extends(T()){[Symbol.iterator](){return this._markers.values()}has(e){const t=e instanceof gu?e.name:e;return this._markers.has(t)}get(e){return this._markers.get(e)||null}_set(e,t,i=!1,n=!1){const s=e instanceof gu?e.name:e;if(s.includes(","))throw new p("markercollection-incorrect-marker-name",this);const o=this._markers.get(s);if(o){const e=o.getData(),r=o.getRange();let a=!1;return r.isEqual(t)||(o._attachLiveRange(pd.fromRange(t)),a=!0),i!=o.managedUsingOperations&&(o._managedUsingOperations=i,a=!0),"boolean"==typeof n&&n!=o.affectsData&&(o._affectsData=n,a=!0),a&&this.fire(`update:${s}`,o,r,t,e),o}const r=pd.fromRange(t),a=new gu(s,r,i,n);return this._markers.set(s,a),this.fire(`update:${s}`,a,null,t,{...a.getData(),range:null}),a}_remove(e){const t=e instanceof gu?e.name:e,i=this._markers.get(t);return!!i&&(this._markers.delete(t),this.fire(`update:${t}`,i,i.getRange(),null,i.getData()),this._destroyMarker(i),!0)}_refresh(e){const t=e instanceof gu?e.name:e,i=this._markers.get(t);if(!i)throw new p("markercollection-refresh-marker-not-exists",this);const n=i.getRange();this.fire(`update:${t}`,i,n,n,i.getData())}*getMarkersAtPosition(e){for(const t of this)t.getRange().containsPosition(e)&&(yield t)}*getMarkersIntersectingRange(e){for(const t of this)null!==t.getRange().getIntersection(e)&&(yield t)}destroy(){for(const e of this._markers.values())this._destroyMarker(e);this._markers=null,this.stopListening()}*getMarkersGroup(e){for(const t of this._markers.values())t.name.startsWith(e+":")&&(yield t)}_destroyMarker(e){e.stopListening(),e._detachLiveRange()}constructor(...e){super(...e),this._markers=new Map}}class gu extends(T($c)){get managedUsingOperations(){if(!this._liveRange)throw new p("marker-destroyed",this);return this._managedUsingOperations}get affectsData(){if(!this._liveRange)throw new p("marker-destroyed",this);return this._affectsData}getData(){return{range:this.getRange(),affectsData:this.affectsData,managedUsingOperations:this.managedUsingOperations}}getStart(){if(!this._liveRange)throw new p("marker-destroyed",this);return this._liveRange.start.clone()}getEnd(){if(!this._liveRange)throw new p("marker-destroyed",this);return this._liveRange.end.clone()}getRange(){if(!this._liveRange)throw new p("marker-destroyed",this);return this._liveRange.toRange()}_attachLiveRange(e){return this._liveRange&&this._detachLiveRange(),e.delegate("change:range").to(this),e.delegate("change:content").to(this),this._liveRange=e,e}_detachLiveRange(){this._liveRange.stopDelegating("change:range",this),this._liveRange.stopDelegating("change:content",this),this._liveRange.detach(),this._liveRange=null}constructor(e,t,i,n){super(),this.name=e,this._liveRange=this._attachLiveRange(t),this._managedUsingOperations=i,this._affectsData=n}}gu.prototype.is=function(e){return"marker"===e||"model:marker"===e};class fu extends Ch{get type(){return"detach"}get affectedSelectable(){return null}toJSON(){const e=super.toJSON();return e.sourcePosition=this.sourcePosition.toJSON(),e}_validate(){if(this.sourcePosition.root.document)throw new p("detach-operation-on-document-node",this)}_execute(){Ah(id._createFromPositionAndShift(this.sourcePosition,this.howMany))}static get className(){return"DetachOperation"}constructor(e,t){super(null),this.sourcePosition=e.clone(),this.howMany=t}}class pu extends $c{[Symbol.iterator](){return this.getChildren()}get childCount(){return this._children.length}get maxOffset(){return this._children.maxOffset}get isEmpty(){return 0===this.childCount}get nextSibling(){return null}get previousSibling(){return null}get root(){return this}get parent(){return null}get document(){return null}isAttached(){return!1}getAncestors(){return[]}getChild(e){return this._children.getNode(e)}getChildren(){return this._children[Symbol.iterator]()}getChildIndex(e){return this._children.getNodeIndex(e)}getChildStartOffset(e){return this._children.getNodeStartOffset(e)}getPath(){return[]}getNodeByPath(e){let t=this;for(const i of e)t=t.getChild(t.offsetToIndex(i));return t}offsetToIndex(e){return this._children.offsetToIndex(e)}toJSON(){const e=[];for(const t of this._children)e.push(t.toJSON());return e}static fromJSON(e){const t=[];for(const i of e)i.name?t.push(Gc.fromJSON(i)):t.push(jc.fromJSON(i));return new pu(t)}_appendChild(e){this._insertChild(this.childCount,e)}_insertChild(e,t){const i=function(e){if("string"==typeof e)return[new jc(e)];lr(e)||(e=[e]);return Array.from(e).map((e=>"string"==typeof e?new jc(e):e instanceof qc?new jc(e.data,e.getAttributes()):e))}(t);for(const e of i)null!==e.parent&&e._remove(),e.parent=this;this._children._insertNodes(e,i)}_removeChildren(e,t=1){const i=this._children._removeNodes(e,t);for(const e of i)e.parent=null;return i}constructor(e){super(),this.markers=new Map,this._children=new Wc,e&&this._insertChild(0,e)}}pu.prototype.is=function(e){return"documentFragment"===e||"model:documentFragment"===e};class bu{createText(e,t){return new jc(e,t)}createElement(e,t){return new Gc(e,t)}createDocumentFragment(){return new pu}cloneElement(e,t=!0){return e._clone(t)}insert(e,t,i=0){if(this._assertWriterUsedCorrectly(),e instanceof jc&&""==e.data)return;const n=Jc._createAt(t,i);if(e.parent){if(ku(e.root,n.root))return void this.move(id._createOn(e),n);if(e.root.document)throw new p("model-writer-insert-forbidden-move",this);this.remove(e)}const s=n.root.document?n.root.document.version:null,o=new Rh(n,e,s);if(e instanceof jc&&(o.shouldReceiveAttributes=!0),this.batch.addOperation(o),this.model.applyOperation(o),e instanceof pu)for(const[t,i]of e.markers){const e=Jc._createAt(i.root,0),s={range:new id(i.start._getCombined(e,n),i.end._getCombined(e,n)),usingOperation:!0,affectsData:!0};this.model.markers.has(t)?this.updateMarker(t,s):this.addMarker(t,s)}}insertText(e,t,i,n){t instanceof pu||t instanceof Gc||t instanceof Jc?this.insert(this.createText(e),t,i):this.insert(this.createText(e,t),i,n)}insertElement(e,t,i,n){t instanceof pu||t instanceof Gc||t instanceof Jc?this.insert(this.createElement(e),t,i):this.insert(this.createElement(e,t),i,n)}append(e,t){this.insert(e,t,"end")}appendText(e,t,i){t instanceof pu||t instanceof Gc?this.insert(this.createText(e),t,"end"):this.insert(this.createText(e,t),i,"end")}appendElement(e,t,i){t instanceof pu||t instanceof Gc?this.insert(this.createElement(e),t,"end"):this.insert(this.createElement(e,t),i,"end")}setAttribute(e,t,i){if(this._assertWriterUsedCorrectly(),i instanceof id){const n=i.getMinimalFlatRanges();for(const i of n)wu(this,e,t,i)}else vu(this,e,t,i)}setAttributes(e,t){for(const[i,n]of Ca(e))this.setAttribute(i,n,t)}removeAttribute(e,t){if(this._assertWriterUsedCorrectly(),t instanceof id){const i=t.getMinimalFlatRanges();for(const t of i)wu(this,e,null,t)}else vu(this,e,null,t)}clearAttributes(e){this._assertWriterUsedCorrectly();const t=e=>{for(const t of e.getAttributeKeys())this.removeAttribute(t,e)};if(e instanceof id)for(const i of e.getItems())t(i);else t(e)}move(e,t,i){if(this._assertWriterUsedCorrectly(),!(e instanceof id))throw new p("writer-move-invalid-range",this);if(!e.isFlat)throw new p("writer-move-range-not-flat",this);const n=Jc._createAt(t,i);if(n.isEqual(e.start))return;if(this._addOperationForAffectedMarkers("move",e),!ku(e.root,n.root))throw new p("writer-move-different-document",this);const s=e.root.document?e.root.document.version:null,o=new Vh(e.start,e.end.offset-e.start.offset,n,s);this.batch.addOperation(o),this.model.applyOperation(o)}remove(e){this._assertWriterUsedCorrectly();const t=(e instanceof id?e:id._createOn(e)).getMinimalFlatRanges().reverse();for(const e of t)this._addOperationForAffectedMarkers("move",e),yu(e.start,e.end.offset-e.start.offset,this.batch,this.model)}merge(e){this._assertWriterUsedCorrectly();const t=e.nodeBefore,i=e.nodeAfter;if(this._addOperationForAffectedMarkers("merge",e),!(t instanceof Gc))throw new p("writer-merge-no-element-before",this);if(!(i instanceof Gc))throw new p("writer-merge-no-element-after",this);e.root.document?this._merge(e):this._mergeDetached(e)}createPositionFromPath(e,t,i){return this.model.createPositionFromPath(e,t,i)}createPositionAt(e,t){return this.model.createPositionAt(e,t)}createPositionAfter(e){return this.model.createPositionAfter(e)}createPositionBefore(e){return this.model.createPositionBefore(e)}createRange(e,t){return this.model.createRange(e,t)}createRangeIn(e){return this.model.createRangeIn(e)}createRangeOn(e){return this.model.createRangeOn(e)}createSelection(...e){return this.model.createSelection(...e)}_mergeDetached(e){const t=e.nodeBefore,i=e.nodeAfter;this.move(id._createIn(i),Jc._createAt(t,"end")),this.remove(i)}_merge(e){const t=Jc._createAt(e.nodeBefore,"end"),i=Jc._createAt(e.nodeAfter,0),n=e.root.document.graveyard,s=new Jc(n,[0]),o=e.root.document.version,r=new Oh(i,e.nodeAfter.maxOffset,t,s,o);this.batch.addOperation(r),this.model.applyOperation(r)}rename(e,t){if(this._assertWriterUsedCorrectly(),!(e instanceof Gc))throw new p("writer-rename-not-element-instance",this);const i=e.root.document?e.root.document.version:null,n=new Fh(Jc._createBefore(e),e.name,t,i);this.batch.addOperation(n),this.model.applyOperation(n)}split(e,t){this._assertWriterUsedCorrectly();let i,n,s=e.parent;if(!s.parent)throw new p("writer-split-element-no-parent",this);if(t||(t=s.parent),!e.parent.getAncestors({includeSelf:!0}).includes(t))throw new p("writer-split-invalid-limit-element",this);do{const t=s.root.document?s.root.document.version:null,o=s.maxOffset-e.offset,r=Bh.getInsertionPosition(e),a=new Bh(e,o,r,null,t);this.batch.addOperation(a),this.model.applyOperation(a),i||n||(i=s,n=e.parent.nextSibling),s=(e=this.createPositionAfter(e.parent)).parent}while(s!==t);return{position:e,range:new id(Jc._createAt(i,"end"),Jc._createAt(n,0))}}wrap(e,t){if(this._assertWriterUsedCorrectly(),!e.isFlat)throw new p("writer-wrap-range-not-flat",this);const i=t instanceof Gc?t:new Gc(t);if(i.childCount>0)throw new p("writer-wrap-element-not-empty",this);if(null!==i.parent)throw new p("writer-wrap-element-attached",this);this.insert(i,e.start);const n=new id(e.start.getShiftedBy(1),e.end.getShiftedBy(1));this.move(n,Jc._createAt(i,0))}unwrap(e){if(this._assertWriterUsedCorrectly(),null===e.parent)throw new p("writer-unwrap-element-no-parent",this);this.move(id._createIn(e),this.createPositionAfter(e)),this.remove(e)}addMarker(e,t){if(this._assertWriterUsedCorrectly(),!t||"boolean"!=typeof t.usingOperation)throw new p("writer-addmarker-no-usingoperation",this);const i=t.usingOperation,n=t.range,s=void 0!==t.affectsData&&t.affectsData;if(this.model.markers.has(e))throw new p("writer-addmarker-marker-exists",this);if(!n)throw new p("writer-addmarker-no-range",this);return i?(_u(this,e,null,n,s),this.model.markers.get(e)):this.model.markers._set(e,n,i,s)}updateMarker(e,t){this._assertWriterUsedCorrectly();const i="string"==typeof e?e:e.name,n=this.model.markers.get(i);if(!n)throw new p("writer-updatemarker-marker-not-exists",this);if(!t)return b("writer-updatemarker-reconvert-using-editingcontroller",{markerName:i}),void this.model.markers._refresh(n);const s="boolean"==typeof t.usingOperation,o="boolean"==typeof t.affectsData,r=o?t.affectsData:n.affectsData;if(!s&&!t.range&&!o)throw new p("writer-updatemarker-wrong-options",this);const a=n.getRange(),l=t.range?t.range:a;s&&t.usingOperation!==n.managedUsingOperations?t.usingOperation?_u(this,i,null,l,r):(_u(this,i,a,null,r),this.model.markers._set(i,l,void 0,r)):n.managedUsingOperations?_u(this,i,a,l,r):this.model.markers._set(i,l,void 0,r)}removeMarker(e){this._assertWriterUsedCorrectly();const t="string"==typeof e?e:e.name;if(!this.model.markers.has(t))throw new p("writer-removemarker-no-marker",this);const i=this.model.markers.get(t);if(!i.managedUsingOperations)return void this.model.markers._remove(t);_u(this,t,i.getRange(),null,i.affectsData)}addRoot(e,t="$root"){this._assertWriterUsedCorrectly();const i=this.model.document.getRoot(e);if(i&&i.isAttached())throw new p("writer-addroot-root-exists",this);const n=this.model.document,s=new zh(e,t,!0,n,n.version);return this.batch.addOperation(s),this.model.applyOperation(s),this.model.document.getRoot(e)}detachRoot(e){this._assertWriterUsedCorrectly();const t="string"==typeof e?this.model.document.getRoot(e):e;if(!t||!t.isAttached())throw new p("writer-detachroot-no-root",this);for(const e of this.model.markers)e.getRange().root===t&&this.removeMarker(e);for(const e of t.getAttributeKeys())this.removeAttribute(e,t);this.remove(this.createRangeIn(t));const i=this.model.document,n=new zh(t.rootName,t.name,!1,i,i.version);this.batch.addOperation(n),this.model.applyOperation(n)}setSelection(...e){this._assertWriterUsedCorrectly(),this.model.document.selection._setTo(...e)}setSelectionFocus(e,t){this._assertWriterUsedCorrectly(),this.model.document.selection._setFocus(e,t)}setSelectionAttribute(e,t){if(this._assertWriterUsedCorrectly(),"string"==typeof e)this._setSelectionAttribute(e,t);else for(const[t,i]of Ca(e))this._setSelectionAttribute(t,i)}removeSelectionAttribute(e){if(this._assertWriterUsedCorrectly(),"string"==typeof e)this._removeSelectionAttribute(e);else for(const t of e)this._removeSelectionAttribute(t)}overrideSelectionGravity(){return this.model.document.selection._overrideGravity()}restoreSelectionGravity(e){this.model.document.selection._restoreGravity(e)}_setSelectionAttribute(e,t){const i=this.model.document.selection;if(i.isCollapsed&&i.anchor.parent.isEmpty){const n=_d._getStoreAttributeKey(e);this.setAttribute(n,t,i.anchor.parent)}i._setAttribute(e,t)}_removeSelectionAttribute(e){const t=this.model.document.selection;if(t.isCollapsed&&t.anchor.parent.isEmpty){const i=_d._getStoreAttributeKey(e);this.removeAttribute(i,t.anchor.parent)}t._removeAttribute(e)}_assertWriterUsedCorrectly(){if(this.model._currentWriter!==this)throw new p("writer-incorrect-use",this)}_addOperationForAffectedMarkers(e,t){for(const i of this.model.markers){if(!i.managedUsingOperations)continue;const n=i.getRange();let s=!1;if("move"===e){const e=t;s=e.containsPosition(n.start)||e.start.isEqual(n.start)||e.containsPosition(n.end)||e.end.isEqual(n.end)}else{const e=t,i=e.nodeBefore,o=e.nodeAfter,r=n.start.parent==i&&n.start.isAtEnd,a=n.end.parent==o&&0==n.end.offset,l=n.end.nodeAfter==o,c=n.start.nodeAfter==o;s=r||a||l||c}s&&this.updateMarker(i.name,{range:n})}}constructor(e,t){this.model=e,this.batch=t}}function wu(e,t,i,n){const s=e.model,o=s.document;let r,a,l,c=n.start;for(const e of n.getWalker({shallow:!0}))l=e.item.getAttribute(t),r&&a!=l&&(a!=i&&d(),c=r),r=e.nextPosition,a=l;function d(){const n=new id(c,r),l=n.root.document?o.version:null,d=new Lh(n,t,a,i,l);e.batch.addOperation(d),s.applyOperation(d)}r instanceof Jc&&r!=c&&a!=i&&d()}function vu(e,t,i,n){const s=e.model,o=s.document,r=n.getAttribute(t);let a,l;if(r!=i){if(n.root===n){const e=n.document?o.version:null;l=new Dh(n,t,r,i,e)}else{a=new id(Jc._createBefore(n),e.createPositionAfter(n));const s=a.root.document?o.version:null;l=new Lh(a,t,r,i,s)}e.batch.addOperation(l),s.applyOperation(l)}}function _u(e,t,i,n,s){const o=e.model,r=o.document,a=new Mh(t,i,n,o.markers,!!s,r.version);e.batch.addOperation(a),o.applyOperation(a)}function yu(e,t,i,n){let s;if(e.root.document){const i=n.document,o=new Jc(i.graveyard,[0]);s=new Vh(e,t,o,i.version)}else s=new fu(e,t);i.addOperation(s),n.applyOperation(s)}function ku(e,t){return e===t||e instanceof cu&&t instanceof cu}function Cu(e,t,i={}){if(t.isCollapsed)return;const n=t.getFirstRange();if("$graveyard"==n.root.rootName)return;const s=e.schema;e.change((e=>{if(!i.doNotResetEntireContent&&function(e,t){const i=e.getLimitElement(t);if(!t.containsEntireContent(i))return!1;const n=t.getFirstRange();if(n.start.parent==n.end.parent)return!1;return e.checkChild(i,"paragraph")}(s,t))return void function(e,t){const i=e.model.schema.getLimitElement(t);e.remove(e.createRangeIn(i)),Tu(e,e.createPositionAt(i,0),t)}(e,t);const o={};if(!i.doNotAutoparagraph){const e=t.getSelectedElement();e&&Object.assign(o,s.getAttributesWithProperty(e,"copyOnReplace",!0))}const[r,a]=function(e){const t=e.root.document.model,i=e.start;let n=e.end;if(t.hasContent(e,{ignoreMarkers:!0})){const i=function(e){const t=e.parent,i=t.root.document.model.schema,n=t.getAncestors({parentFirst:!0,includeSelf:!0});for(const e of n){if(i.isLimit(e))return null;if(i.isBlock(e))return e}}(n);if(i&&n.isTouching(t.createPositionAt(i,0))){const i=t.createSelection(e);t.modifySelection(i,{direction:"backward"});const s=i.getLastPosition(),o=t.createRange(s,n);t.hasContent(o,{ignoreMarkers:!0})||(n=s)}}return[eu.fromPosition(i,"toPrevious"),eu.fromPosition(n,"toNext")]}(n);r.isTouching(a)||e.remove(e.createRange(r,a)),i.leaveUnmerged||(!function(e,t,i){const n=e.model;if(!Eu(e.model.schema,t,i))return;const[s,o]=function(e,t){const i=e.getAncestors(),n=t.getAncestors();let s=0;for(;i[s]&&i[s]==n[s];)s++;return[i[s],n[s]]}(t,i);if(!s||!o)return;!n.hasContent(s,{ignoreMarkers:!0})&&n.hasContent(o,{ignoreMarkers:!0})?Au(e,t,i,s.parent):xu(e,t,i,s.parent)}(e,r,a),s.removeDisallowedAttributes(r.parent.getChildren(),e)),Su(e,t,r),!i.doNotAutoparagraph&&function(e,t){const i=e.checkChild(t,"$text"),n=e.checkChild(t,"paragraph");return!i&&n}(s,r)&&Tu(e,r,t,o),r.detach(),a.detach()}))}function xu(e,t,i,n){const s=t.parent,o=i.parent;if(s!=n&&o!=n){for(t=e.createPositionAfter(s),(i=e.createPositionBefore(o)).isEqual(t)||e.insert(o,t),e.merge(t);i.parent.isEmpty;){const t=i.parent;i=e.createPositionBefore(t),e.remove(t)}Eu(e.model.schema,t,i)&&xu(e,t,i,n)}}function Au(e,t,i,n){const s=t.parent,o=i.parent;if(s!=n&&o!=n){for(t=e.createPositionAfter(s),(i=e.createPositionBefore(o)).isEqual(t)||e.insert(s,i);t.parent.isEmpty;){const i=t.parent;t=e.createPositionBefore(i),e.remove(i)}i=e.createPositionBefore(o),function(e,t){const i=t.nodeBefore,n=t.nodeAfter;i.name!=n.name&&e.rename(i,n.name);e.clearAttributes(i),e.setAttributes(Object.fromEntries(n.getAttributes()),i),e.merge(t)}(e,i),Eu(e.model.schema,t,i)&&Au(e,t,i,n)}}function Eu(e,t,i){const n=t.parent,s=i.parent;return n!=s&&(!e.isLimit(n)&&!e.isLimit(s)&&function(e,t,i){const n=new id(e,t);for(const e of n.getWalker())if(i.isLimit(e.item))return!1;return!0}(t,i,e))}function Tu(e,t,i,n={}){const s=e.createElement("paragraph");e.model.schema.setAllowedAttributes(s,n,e),e.insert(s,t),Su(e,i,e.createPositionAt(s,0))}function Su(e,t,i){t instanceof _d?e.setSelection(i):t.setTo(i)}function Iu(e,t){const i=[];Array.from(e.getItems({direction:"backward"})).map((e=>t.createRangeOn(e))).filter((t=>(t.start.isAfter(e.start)||t.start.isEqual(e.start))&&(t.end.isBefore(e.end)||t.end.isEqual(e.end)))).forEach((e=>{i.push(e.start.parent),t.remove(e)})),i.forEach((e=>{let i=e;for(;i.parent&&i.isEmpty;){const e=t.createRangeOn(i);i=i.parent,t.remove(e)}}))}class Pu{handleNodes(e){for(const t of Array.from(e))this._handleNode(t);this._insertPartialFragment(),this._lastAutoParagraph&&this._updateLastNodeFromAutoParagraph(this._lastAutoParagraph),this._mergeOnRight(),this.schema.removeDisallowedAttributes(this._filterAttributesOf,this.writer),this._filterAttributesOf=[]}_updateLastNodeFromAutoParagraph(e){const t=this.writer.createPositionAfter(this._lastNode),i=this.writer.createPositionAfter(e);if(i.isAfter(t)){if(this._lastNode=e,this.position.parent!=e||!this.position.isAtEnd)throw new p("insertcontent-invalid-insertion-position",this);this.position=i,this._setAffectedBoundaries(this.position)}}getSelectionRange(){return this._nodeToSelect?id._createOn(this._nodeToSelect):this.model.schema.getNearestSelectionRange(this.position)}getAffectedRange(){return this._affectedStart?new id(this._affectedStart,this._affectedEnd):null}destroy(){this._affectedStart&&this._affectedStart.detach(),this._affectedEnd&&this._affectedEnd.detach()}_handleNode(e){if(this.schema.isObject(e))return void this._handleObject(e);let t=this._checkAndAutoParagraphToAllowedPosition(e);t||(t=this._checkAndSplitToAllowedPosition(e),t)?(this._appendToFragment(e),this._firstNode||(this._firstNode=e),this._lastNode=e):this._handleDisallowedNode(e)}_insertPartialFragment(){if(this._documentFragment.isEmpty)return;const e=eu.fromPosition(this.position,"toNext");this._setAffectedBoundaries(this.position),this._documentFragment.getChild(0)==this._firstNode&&(this.writer.insert(this._firstNode,this.position),this._mergeOnLeft(),this.position=e.toPosition()),this._documentFragment.isEmpty||this.writer.insert(this._documentFragment,this.position),this._documentFragmentPosition=this.writer.createPositionAt(this._documentFragment,0),this.position=e.toPosition(),e.detach()}_handleObject(e){this._checkAndSplitToAllowedPosition(e)?this._appendToFragment(e):this._tryAutoparagraphing(e)}_handleDisallowedNode(e){e.is("element")?this.handleNodes(e.getChildren()):this._tryAutoparagraphing(e)}_appendToFragment(e){if(!this.schema.checkChild(this.position,e))throw new p("insertcontent-wrong-position",this,{node:e,position:this.position});this.writer.insert(e,this._documentFragmentPosition),this._documentFragmentPosition=this._documentFragmentPosition.getShiftedBy(e.offsetSize),this.schema.isObject(e)&&!this.schema.checkChild(this.position,"$text")?this._nodeToSelect=e:this._nodeToSelect=null,this._filterAttributesOf.push(e)}_setAffectedBoundaries(e){this._affectedStart||(this._affectedStart=eu.fromPosition(e,"toPrevious")),this._affectedEnd&&!this._affectedEnd.isBefore(e)||(this._affectedEnd&&this._affectedEnd.detach(),this._affectedEnd=eu.fromPosition(e,"toNext"))}_mergeOnLeft(){const e=this._firstNode;if(!(e instanceof Gc))return;if(!this._canMergeLeft(e))return;const t=eu._createBefore(e);t.stickiness="toNext";const i=eu.fromPosition(this.position,"toNext");this._affectedStart.isEqual(t)&&(this._affectedStart.detach(),this._affectedStart=eu._createAt(t.nodeBefore,"end","toPrevious")),this._firstNode===this._lastNode&&(this._firstNode=t.nodeBefore,this._lastNode=t.nodeBefore),this.writer.merge(t),t.isEqual(this._affectedEnd)&&this._firstNode===this._lastNode&&(this._affectedEnd.detach(),this._affectedEnd=eu._createAt(t.nodeBefore,"end","toNext")),this.position=i.toPosition(),i.detach(),this._filterAttributesOf.push(this.position.parent),t.detach()}_mergeOnRight(){const e=this._lastNode;if(!(e instanceof Gc))return;if(!this._canMergeRight(e))return;const t=eu._createAfter(e);if(t.stickiness="toNext",!this.position.isEqual(t))throw new p("insertcontent-invalid-insertion-position",this);this.position=Jc._createAt(t.nodeBefore,"end");const i=eu.fromPosition(this.position,"toPrevious");this._affectedEnd.isEqual(t)&&(this._affectedEnd.detach(),this._affectedEnd=eu._createAt(t.nodeBefore,"end","toNext")),this._firstNode===this._lastNode&&(this._firstNode=t.nodeBefore,this._lastNode=t.nodeBefore),this.writer.merge(t),t.getShiftedBy(-1).isEqual(this._affectedStart)&&this._firstNode===this._lastNode&&(this._affectedStart.detach(),this._affectedStart=eu._createAt(t.nodeBefore,0,"toPrevious")),this.position=i.toPosition(),i.detach(),this._filterAttributesOf.push(this.position.parent),t.detach()}_canMergeLeft(e){const t=e.previousSibling;return t instanceof Gc&&this.canMergeWith.has(t)&&this.model.schema.checkMerge(t,e)}_canMergeRight(e){const t=e.nextSibling;return t instanceof Gc&&this.canMergeWith.has(t)&&this.model.schema.checkMerge(e,t)}_tryAutoparagraphing(e){const t=this.writer.createElement("paragraph");this._getAllowedIn(this.position.parent,t)&&this.schema.checkChild(t,e)&&(t._appendChild(e),this._handleNode(t))}_checkAndAutoParagraphToAllowedPosition(e){if(this.schema.checkChild(this.position.parent,e))return!0;if(!this.schema.checkChild(this.position.parent,"paragraph")||!this.schema.checkChild("paragraph",e))return!1;this._insertPartialFragment();const t=this.writer.createElement("paragraph");return this.writer.insert(t,this.position),this._setAffectedBoundaries(this.position),this._lastAutoParagraph=t,this.position=this.writer.createPositionAt(t,0),!0}_checkAndSplitToAllowedPosition(e){const t=this._getAllowedIn(this.position.parent,e);if(!t)return!1;for(t!=this.position.parent&&this._insertPartialFragment();t!=this.position.parent;)if(this.position.isAtStart){const e=this.position.parent;this.position=this.writer.createPositionBefore(e),e.isEmpty&&e.parent===t&&this.writer.remove(e)}else if(this.position.isAtEnd)this.position=this.writer.createPositionAfter(this.position.parent);else{const e=this.writer.createPositionAfter(this.position.parent);this._setAffectedBoundaries(this.position),this.writer.split(this.position),this.position=e,this.canMergeWith.add(this.position.nodeAfter)}return!0}_getAllowedIn(e,t){return this.schema.checkChild(e,t)?e:this.schema.isLimit(e)?null:this._getAllowedIn(e.parent,t)}constructor(e,t,i){this._firstNode=null,this._lastNode=null,this._lastAutoParagraph=null,this._filterAttributesOf=[],this._affectedStart=null,this._affectedEnd=null,this._nodeToSelect=null,this.model=e,this.writer=t,this.position=i,this.canMergeWith=new Set([this.position.parent]),this.schema=e.schema,this._documentFragment=t.createDocumentFragment(),this._documentFragmentPosition=t.createPositionAt(this._documentFragment,0)}}function Vu(e,t,i,n={}){if(!e.schema.isObject(t))throw new p("insertobject-element-not-an-object",e,{object:t});const s=i||e.document.selection;let o=s;n.findOptimalPosition&&e.schema.isBlock(t)&&(o=e.createSelection(e.schema.findOptimalInsertionRange(s,n.findOptimalPosition)));const r=_a(s.getSelectedBlocks()),a={};return r&&Object.assign(a,e.schema.getAttributesWithProperty(r,"copyOnReplace",!0)),e.change((i=>{o.isCollapsed||e.deleteContent(o,{doNotAutoparagraph:!0});let s=t;const r=o.anchor.parent;!e.schema.checkChild(r,t)&&e.schema.checkChild(r,"paragraph")&&e.schema.checkChild("paragraph",t)&&(s=i.createElement("paragraph"),i.insert(t,s)),e.schema.setAllowedAttributes(s,a,i);const l=e.insertContent(s,o);return l.isCollapsed||n.setSelection&&function(e,t,i,n){const s=e.model;if("on"==i)return void e.setSelection(t,"on");if("after"!=i)throw new p("insertobject-invalid-place-parameter-value",s);let o=t.nextSibling;if(s.schema.isInline(t))return void e.setSelection(t,"after");const r=o&&s.schema.checkChild(o,"$text");!r&&s.schema.checkChild(t.parent,"paragraph")&&(o=e.createElement("paragraph"),s.schema.setAllowedAttributes(o,n,e),s.insertContent(o,e.createPositionAfter(t)));o&&e.setSelection(o,0)}(i,t,n.setSelection,a),l}))}const Ru=' ,.?!:;"-()';function Bu(e,t){const{isForward:i,walker:n,unit:s,schema:o,treatEmojiAsSingleUnit:r}=e,{type:a,item:l,nextPosition:c}=t;if("text"==a)return"word"===e.unit?function(e,t){let i=e.position.textNode;i||(i=t?e.position.nodeAfter:e.position.nodeBefore);for(;i&&i.is("$text");){const n=e.position.offset-i.startOffset;if(Lu(i,n,t))i=t?e.position.nodeAfter:e.position.nodeBefore;else{if(Mu(i.data,n,t))break;e.next()}}return e.position}(n,i):function(e,t,i){const n=e.position.textNode;if(n){const s=n.data;let o=e.position.offset-n.startOffset;for(;Ba(s,o)||"character"==t&&Oa(s,o)||i&&La(s,o);)e.next(),o=e.position.offset-n.startOffset}return e.position}(n,s,r);if(a==(i?"elementStart":"elementEnd")){if(o.isSelectable(l))return Jc._createAt(l,i?"after":"before");if(o.checkChild(c,"$text"))return c}else{if(o.isLimit(l))return void n.skip((()=>!0));if(o.checkChild(c,"$text"))return c}}function Ou(e,t){const i=e.root,n=Jc._createAt(i,t?"end":0);return t?new id(e,n):new id(n,e)}function Mu(e,t,i){const n=t+(i?0:-1);return Ru.includes(e.charAt(n))}function Lu(e,t,i){return t===(i?e.offsetSize:0)}let Nu=class extends(Yo()){change(e){try{return 0===this._pendingChanges.length?(this._pendingChanges.push({batch:new nu,callback:e}),this._runPendingChanges()[0]):e(this._currentWriter)}catch(e){p.rethrowUnexpectedError(e,this)}}enqueueChange(e,t){try{e?"function"==typeof e?(t=e,e=new nu):e instanceof nu||(e=new nu(e)):e=new nu,this._pendingChanges.push({batch:e,callback:t}),1==this._pendingChanges.length&&this._runPendingChanges()}catch(e){p.rethrowUnexpectedError(e,this)}}applyOperation(e){e._execute()}insertContent(e,t,i,...n){const s=Fu(t,i);return this.fire("insertContent",[e,s,i,...n])}insertObject(e,t,i,n,...s){const o=Fu(t,i);return this.fire("insertObject",[e,o,n,n,...s])}deleteContent(e,t){Cu(this,e,t)}modifySelection(e,t){!function(e,t,i={}){const n=e.schema,s="backward"!=i.direction,o=i.unit?i.unit:"character",r=!!i.treatEmojiAsSingleUnit,a=t.focus,l=new Kc({boundaries:Ou(a,s),singleCharacters:!0,direction:s?"forward":"backward"}),c={walker:l,schema:n,isForward:s,unit:o,treatEmojiAsSingleUnit:r};let d;for(;d=l.next();){if(d.done)return;const i=Bu(c,d.value);if(i)return void(t instanceof _d?e.change((e=>{e.setSelectionFocus(i)})):t.setFocus(i))}}(this,e,t)}getSelectedContent(e){return function(e,t){return e.change((e=>{const i=e.createDocumentFragment(),n=t.getFirstRange();if(!n||n.isCollapsed)return i;const s=n.start.root,o=n.start.getCommonPath(n.end),r=s.getNodeByPath(o);let a;a=n.start.parent==n.end.parent?n:e.createRange(e.createPositionAt(r,n.start.path[o.length]),e.createPositionAt(r,n.end.path[o.length]+1));const l=a.end.offset-a.start.offset;for(const t of a.getItems({shallow:!0}))t.is("$textProxy")?e.appendText(t.data,t.getAttributes(),i):e.append(e.cloneElement(t,!0),i);if(a!=n){const t=n._getTransformedByMove(a.start,e.createPositionAt(i,0),l)[0],s=e.createRange(e.createPositionAt(i,0),t.start);Iu(e.createRange(t.end,e.createPositionAt(i,"end")),e),Iu(s,e)}return i}))}(this,e)}hasContent(e,t={}){const i=e instanceof id?e:id._createIn(e);if(i.isCollapsed)return!1;const{ignoreWhitespaces:n=!1,ignoreMarkers:s=!1}=t;if(!s)for(const e of this.markers.getMarkersIntersectingRange(i))if(e.affectsData)return!0;for(const e of i.getItems())if(this.schema.isContent(e)){if(!e.is("$textProxy"))return!0;if(!n)return!0;if(-1!==e.data.search(/\S/))return!0}return!1}canEditAt(e){const t=Fu(e);return this.fire("canEditAt",[t])}createPositionFromPath(e,t,i){return new Jc(e,t,i)}createPositionAt(e,t){return Jc._createAt(e,t)}createPositionAfter(e){return Jc._createAfter(e)}createPositionBefore(e){return Jc._createBefore(e)}createRange(e,t){return new id(e,t)}createRangeIn(e){return id._createIn(e)}createRangeOn(e){return id._createOn(e)}createSelection(...e){return new cd(...e)}createBatch(e){return new nu(e)}createOperationFromJSON(e){return $h.fromJSON(e,this.document)}destroy(){this.document.destroy(),this.stopListening()}_runPendingChanges(){const e=[];this.fire("_beforeChanges");try{for(;this._pendingChanges.length;){const t=this._pendingChanges[0].batch;this._currentWriter=new bu(this,t);const i=this._pendingChanges[0].callback(this._currentWriter);e.push(i),this.document._handleChangeBlock(this._currentWriter),this._pendingChanges.shift(),this._currentWriter=null}}finally{this._pendingChanges.length=0,this._currentWriter=null,this.fire("_afterChanges")}return e}constructor(){super(),this.markers=new mu,this.document=new hu(this),this.schema=new th,this._pendingChanges=[],this._currentWriter=null,["deleteContent","modifySelection","getSelectedContent","applyOperation"].forEach((e=>this.decorate(e))),this.on("applyOperation",((e,t)=>{t[0]._validate()}),{priority:"highest"}),this.schema.register("$root",{isLimit:!0}),this.schema.register("$container",{allowIn:["$root","$container"]}),this.schema.register("$block",{allowIn:["$root","$container"],isBlock:!0}),this.schema.register("$blockObject",{allowWhere:"$block",isBlock:!0,isObject:!0}),this.schema.register("$inlineObject",{allowWhere:"$text",allowAttributesOf:"$text",isInline:!0,isObject:!0}),this.schema.register("$text",{allowIn:"$block",isInline:!0,isContent:!0}),this.schema.register("$clipboardHolder",{allowContentOf:"$root",allowChildren:"$text",isLimit:!0}),this.schema.register("$documentFragment",{allowContentOf:"$root",allowChildren:"$text",isLimit:!0}),this.schema.register("$marker"),this.schema.addChildCheck(((e,t)=>{if("$marker"===t.name)return!0})),Gd(this),this.document.registerPostFixer(Nd),this.on("insertContent",((e,[t,i])=>{e.return=function(e,t,i){return e.change((n=>{const s=i||e.document.selection;s.isCollapsed||e.deleteContent(s,{doNotAutoparagraph:!0});const o=new Pu(e,n,s.anchor),r=[];let a;if(t.is("documentFragment")){if(t.markers.size){const e=[];for(const[i,n]of t.markers){const{start:t,end:s}=n,o=t.isEqual(s);e.push({position:t,name:i,isCollapsed:o},{position:s,name:i,isCollapsed:o})}e.sort((({position:e},{position:t})=>e.isBefore(t)?1:-1));for(const{position:i,name:s,isCollapsed:o}of e){let e=null,a=null;const l=i.parent===t&&i.isAtStart,c=i.parent===t&&i.isAtEnd;l||c?o&&(a=l?"start":"end"):(e=n.createElement("$marker"),n.insert(e,i)),r.push({name:s,element:e,collapsed:a})}}a=t.getChildren()}else a=[t];o.handleNodes(a);let l=o.getSelectionRange();if(t.is("documentFragment")&&r.length){const e=l?pd.fromRange(l):null,t={};for(let e=r.length-1;e>=0;e--){const{name:i,element:s,collapsed:a}=r[e],l=!t[i];if(l&&(t[i]=[]),s){const e=n.createPositionAt(s,"before");t[i].push(e),n.remove(s)}else{const e=o.getAffectedRange();if(!e){a&&t[i].push(o.position);continue}a?t[i].push(e[a]):t[i].push(l?e.start:e.end)}}for(const[e,[i,s]]of Object.entries(t))i&&s&&i.root===s.root&&i.root.document&&!n.model.markers.has(e)&&n.addMarker(e,{usingOperation:!0,affectsData:!0,range:new id(i,s)});e&&(l=e.toRange(),e.detach())}l&&(s instanceof _d?n.setSelection(l):s.setTo(l));const c=o.getAffectedRange()||e.createRange(s.anchor);return o.destroy(),c}))}(this,t,i)})),this.on("insertObject",((e,[t,i,n])=>{e.return=Vu(this,t,i,n)})),this.on("canEditAt",(e=>{const t=!this.document.isReadOnly;e.return=t,t||e.stop()}))}};function Fu(e,t){if(e)return e instanceof cd||e instanceof _d?e:e instanceof Uc?t||0===t?new cd(e,t):e.is("rootElement")?new cd(e,"in"):new cd(e,"on"):new cd(e)}class Du extends Sc{onDomEvent(e){this.fire(e.type,e)}constructor(...e){super(...e),this.domEventType="click"}}class zu extends Sc{onDomEvent(e){this.fire(e.type,e)}constructor(...e){super(...e),this.domEventType=["mousedown","mouseup","mouseover","mouseout"]}}class Hu{createDocumentFragment(e){return new Ul(this.document,e)}createElement(e,t,i){return new ul(this.document,e,t,i)}createText(e){return new nl(this.document,e)}clone(e,t=!1){return e._clone(t)}appendChild(e,t){return t._appendChild(e)}insertChild(e,t,i){return i._insertChild(e,t)}removeChildren(e,t,i){return i._removeChildren(e,t)}remove(e){const t=e.parent;return t?this.removeChildren(t.getChildIndex(e),1,t):[]}replace(e,t){const i=e.parent;if(i){const n=i.getChildIndex(e);return this.removeChildren(n,1,i),this.insertChild(n,t,i),!0}return!1}unwrapElement(e){const t=e.parent;if(t){const i=t.getChildIndex(e);this.remove(e),this.insertChild(i,e.getChildren(),t)}}rename(e,t){const i=new ul(this.document,e,t.getAttributes(),t.getChildren());return this.replace(t,i)?i:null}setAttribute(e,t,i){i._setAttribute(e,t)}removeAttribute(e,t){t._removeAttribute(e)}addClass(e,t){t._addClass(e)}removeClass(e,t){t._removeClass(e)}setStyle(e,t,i){oi(e)&&void 0===i?t._setStyle(e):i._setStyle(e,t)}removeStyle(e,t){t._removeStyle(e)}setCustomProperty(e,t,i){i._setCustomProperty(e,t)}removeCustomProperty(e,t){return t._removeCustomProperty(e)}createPositionAt(e,t){return _l._createAt(e,t)}createPositionAfter(e){return _l._createAfter(e)}createPositionBefore(e){return _l._createBefore(e)}createRange(e,t){return new yl(e,t)}createRangeOn(e){return yl._createOn(e)}createRangeIn(e){return yl._createIn(e)}createSelection(...e){return new Cl(...e)}constructor(e){this.document=e}}const $u=/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,Uu=/^rgb\([ ]?([0-9]{1,3}[ %]?,[ ]?){2,3}[0-9]{1,3}[ %]?\)$/i,Wu=/^rgba\([ ]?([0-9]{1,3}[ %]?,[ ]?){3}(1|[0-9]+%|[0]?\.?[0-9]+)\)$/i,ju=/^hsl\([ ]?([0-9]{1,3}[ %]?[,]?[ ]*){3}(1|[0-9]+%|[0]?\.?[0-9]+)?\)$/i,qu=/^hsla\([ ]?([0-9]{1,3}[ %]?,[ ]?){2,3}(1|[0-9]+%|[0]?\.?[0-9]+)\)$/i,Gu=/\w+\((?:[^()]|\([^()]*\))*\)|\S+/gi,Ku=new Set(["black","silver","gray","white","maroon","red","purple","fuchsia","green","lime","olive","yellow","navy","blue","teal","aqua","orange","aliceblue","antiquewhite","aquamarine","azure","beige","bisque","blanchedalmond","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","gainsboro","ghostwhite","gold","goldenrod","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","limegreen","linen","magenta","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","oldlace","olivedrab","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","thistle","tomato","turquoise","violet","wheat","whitesmoke","yellowgreen","activeborder","activecaption","appworkspace","background","buttonface","buttonhighlight","buttonshadow","buttontext","captiontext","graytext","highlight","highlighttext","inactiveborder","inactivecaption","inactivecaptiontext","infobackground","infotext","menu","menutext","scrollbar","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","window","windowframe","windowtext","rebeccapurple","currentcolor","transparent"]);function Zu(e){return e.startsWith("#")?$u.test(e):e.startsWith("rgb")?Uu.test(e)||Wu.test(e):e.startsWith("hsl")?ju.test(e)||qu.test(e):Ku.has(e.toLowerCase())}const Ju=["none","hidden","dotted","dashed","solid","double","groove","ridge","inset","outset"];function Qu(e){return Ju.includes(e)}const Yu=/^([+-]?[0-9]*([.][0-9]+)?(px|cm|mm|in|pc|pt|ch|em|ex|rem|vh|vw|vmin|vmax)|0)$/;function Xu(e){return Yu.test(e)}const em=/^[+-]?[0-9]*([.][0-9]+)?%$/;function tm(e){return em.test(e)}const im=["repeat-x","repeat-y","repeat","space","round","no-repeat"];function nm(e){return im.includes(e)}const sm=["center","top","bottom","left","right"];function om(e){return sm.includes(e)}const rm=["fixed","scroll","local"];function am(e){return rm.includes(e)}const lm=/^url\(/;function cm(e){return lm.test(e)}function dm(e=""){if(""===e)return{top:void 0,right:void 0,bottom:void 0,left:void 0};const t=gm(e),i=t[0],n=t[2]||i,s=t[1]||i;return{top:i,bottom:n,right:s,left:t[3]||s}}function hm(e){return t=>{const{top:i,right:n,bottom:s,left:o}=t,r=[];return[i,n,o,s].every((e=>!!e))?r.push([e,um(t)]):(i&&r.push([e+"-top",i]),n&&r.push([e+"-right",n]),s&&r.push([e+"-bottom",s]),o&&r.push([e+"-left",o])),r}}function um({top:e,right:t,bottom:i,left:n}){const s=[];return n!==t?s.push(e,t,i,n):i!==e?s.push(e,t,i):t!==e?s.push(e,t):s.push(e),s.join(" ")}function mm(e){return t=>({path:e,value:dm(t)})}function gm(e){const t=e.matchAll(Gu);return Array.from(t).map((e=>e[0]))}function fm(e){e.setNormalizer("background",(e=>{const t={},i=gm(e);for(const e of i)nm(e)?(t.repeat=t.repeat||[],t.repeat.push(e)):om(e)?(t.position=t.position||[],t.position.push(e)):am(e)?t.attachment=e:Zu(e)?t.color=e:cm(e)&&(t.image=e);return{path:"background",value:t}})),e.setNormalizer("background-color",(e=>({path:"background.color",value:e}))),e.setReducer("background",(e=>{const t=[];return t.push(["background-color",e.color]),t})),e.setStyleRelation("background",["background-color"])}function pm(e){e.setNormalizer("border",(e=>{const{color:t,style:i,width:n}=Cm(e);return{path:"border",value:{color:dm(t),style:dm(i),width:dm(n)}}})),e.setNormalizer("border-top",bm("top")),e.setNormalizer("border-right",bm("right")),e.setNormalizer("border-bottom",bm("bottom")),e.setNormalizer("border-left",bm("left")),e.setNormalizer("border-color",wm("color")),e.setNormalizer("border-width",wm("width")),e.setNormalizer("border-style",wm("style")),e.setNormalizer("border-top-color",_m("color","top")),e.setNormalizer("border-top-style",_m("style","top")),e.setNormalizer("border-top-width",_m("width","top")),e.setNormalizer("border-right-color",_m("color","right")),e.setNormalizer("border-right-style",_m("style","right")),e.setNormalizer("border-right-width",_m("width","right")),e.setNormalizer("border-bottom-color",_m("color","bottom")),e.setNormalizer("border-bottom-style",_m("style","bottom")),e.setNormalizer("border-bottom-width",_m("width","bottom")),e.setNormalizer("border-left-color",_m("color","left")),e.setNormalizer("border-left-style",_m("style","left")),e.setNormalizer("border-left-width",_m("width","left")),e.setExtractor("border-top",ym("top")),e.setExtractor("border-right",ym("right")),e.setExtractor("border-bottom",ym("bottom")),e.setExtractor("border-left",ym("left")),e.setExtractor("border-top-color","border.color.top"),e.setExtractor("border-right-color","border.color.right"),e.setExtractor("border-bottom-color","border.color.bottom"),e.setExtractor("border-left-color","border.color.left"),e.setExtractor("border-top-width","border.width.top"),e.setExtractor("border-right-width","border.width.right"),e.setExtractor("border-bottom-width","border.width.bottom"),e.setExtractor("border-left-width","border.width.left"),e.setExtractor("border-top-style","border.style.top"),e.setExtractor("border-right-style","border.style.right"),e.setExtractor("border-bottom-style","border.style.bottom"),e.setExtractor("border-left-style","border.style.left"),e.setReducer("border-color",hm("border-color")),e.setReducer("border-style",hm("border-style")),e.setReducer("border-width",hm("border-width")),e.setReducer("border-top",xm("top")),e.setReducer("border-right",xm("right")),e.setReducer("border-bottom",xm("bottom")),e.setReducer("border-left",xm("left")),e.setReducer("border",function(){return t=>{const i=km(t,"top"),n=km(t,"right"),s=km(t,"bottom"),o=km(t,"left"),r=[i,n,s,o],a={width:e(r,"width"),style:e(r,"style"),color:e(r,"color")},l=Am(a,"all");if(l.length)return l;const c=Object.entries(a).reduce(((e,[t,i])=>(i&&(e.push([`border-${t}`,i]),r.forEach((e=>delete e[t]))),e)),[]);return[...c,...Am(i,"top"),...Am(n,"right"),...Am(s,"bottom"),...Am(o,"left")]};function e(e,t){return e.map((e=>e[t])).reduce(((e,t)=>e==t?e:null))}}()),e.setStyleRelation("border",["border-color","border-style","border-width","border-top","border-right","border-bottom","border-left","border-top-color","border-right-color","border-bottom-color","border-left-color","border-top-style","border-right-style","border-bottom-style","border-left-style","border-top-width","border-right-width","border-bottom-width","border-left-width"]),e.setStyleRelation("border-color",["border-top-color","border-right-color","border-bottom-color","border-left-color"]),e.setStyleRelation("border-style",["border-top-style","border-right-style","border-bottom-style","border-left-style"]),e.setStyleRelation("border-width",["border-top-width","border-right-width","border-bottom-width","border-left-width"]),e.setStyleRelation("border-top",["border-top-color","border-top-style","border-top-width"]),e.setStyleRelation("border-right",["border-right-color","border-right-style","border-right-width"]),e.setStyleRelation("border-bottom",["border-bottom-color","border-bottom-style","border-bottom-width"]),e.setStyleRelation("border-left",["border-left-color","border-left-style","border-left-width"])}function bm(e){return t=>{const{color:i,style:n,width:s}=Cm(t),o={};return void 0!==i&&(o.color={[e]:i}),void 0!==n&&(o.style={[e]:n}),void 0!==s&&(o.width={[e]:s}),{path:"border",value:o}}}function wm(e){return t=>({path:"border",value:vm(t,e)})}function vm(e,t){return{[t]:dm(e)}}function _m(e,t){return i=>({path:"border",value:{[e]:{[t]:i}}})}function ym(e){return(t,i)=>{if(i.border)return km(i.border,e)}}function km(e,t){const i={};return e.width&&e.width[t]&&(i.width=e.width[t]),e.style&&e.style[t]&&(i.style=e.style[t]),e.color&&e.color[t]&&(i.color=e.color[t]),i}function Cm(e){const t={},i=gm(e);for(const e of i)Xu(e)||/thin|medium|thick/.test(e)?t.width=e:Qu(e)?t.style=e:t.color=e;return t}function xm(e){return t=>Am(t,e)}function Am(e,t){const i=[];if(e&&e.width&&i.push("width"),e&&e.style&&i.push("style"),e&&e.color&&i.push("color"),3==i.length){const n=i.map((t=>e[t])).join(" ");return["all"==t?["border",n]:[`border-${t}`,n]]}return"all"==t?[]:i.map((i=>[`border-${t}-${i}`,e[i]]))}function Em(e){e.setNormalizer("margin",mm("margin")),e.setNormalizer("margin-top",(e=>({path:"margin.top",value:e}))),e.setNormalizer("margin-right",(e=>({path:"margin.right",value:e}))),e.setNormalizer("margin-bottom",(e=>({path:"margin.bottom",value:e}))),e.setNormalizer("margin-left",(e=>({path:"margin.left",value:e}))),e.setReducer("margin",hm("margin")),e.setStyleRelation("margin",["margin-top","margin-right","margin-bottom","margin-left"])}function Tm(e){e.setNormalizer("padding",mm("padding")),e.setNormalizer("padding-top",(e=>({path:"padding.top",value:e}))),e.setNormalizer("padding-right",(e=>({path:"padding.right",value:e}))),e.setNormalizer("padding-bottom",(e=>({path:"padding.bottom",value:e}))),e.setNormalizer("padding-left",(e=>({path:"padding.left",value:e}))),e.setReducer("padding",hm("padding")),e.setStyleRelation("padding",["padding-top","padding-right","padding-bottom","padding-left"])}class Sm{add(e,t){this._commands.set(e,t)}get(e){return this._commands.get(e)}execute(e,...t){const i=this.get(e);if(!i)throw new p("commandcollection-command-not-found",this,{commandName:e});return i.execute(...t)}*names(){yield*this._commands.keys()}*commands(){yield*this._commands.values()}[Symbol.iterator](){return this._commands[Symbol.iterator]()}destroy(){for(const e of this.commands())e.destroy()}constructor(){this._commands=new Map}}class Im extends ka{set(e,t,i={}){if("string"==typeof t){const e=t;t=(t,i)=>{this.editor.execute(e),i()}}super.set(e,t,i)}constructor(e){super(),this.editor=e}}const Pm="contentEditing",Vm="common";class Rm{addKeystrokeInfoCategory({id:e,label:t,description:i,groups:n}){this.keystrokeInfos.set(e,{id:e,label:t,description:i,groups:new Map}),this.addKeystrokeInfoGroup({categoryId:e,id:Vm}),n&&n.forEach((t=>{this.addKeystrokeInfoGroup({categoryId:e,...t})}))}addKeystrokeInfoGroup({categoryId:e=Pm,id:t,label:i,keystrokes:n}){const s=this.keystrokeInfos.get(e);if(!s)throw new p("accessibility-unknown-keystroke-info-category",this._editor,{groupId:t,categoryId:e});s.groups.set(t,{id:t,label:i,keystrokes:n||[]})}addKeystrokeInfos({categoryId:e=Pm,groupId:t=Vm,keystrokes:i}){if(!this.keystrokeInfos.has(e))throw new p("accessibility-unknown-keystroke-info-category",this._editor,{categoryId:e,keystrokes:i});const n=this.keystrokeInfos.get(e);if(!n.groups.has(t))throw new p("accessibility-unknown-keystroke-info-group",this._editor,{groupId:t,categoryId:e,keystrokes:i});n.groups.get(t).keystrokes.push(...i)}constructor(e){this.keystrokeInfos=new Map,this._editor=e;const t=e.config.get("menuBar.isVisible"),i=e.locale.t;this.addKeystrokeInfoCategory({id:Pm,label:i("Content editing keystrokes"),description:i("These keyboard shortcuts allow for quick access to content editing features.")});const n=[{label:i("Close contextual balloons, dropdowns, and dialogs"),keystroke:"Esc"},{label:i("Open the accessibility help dialog"),keystroke:"Alt+0"},{label:i("Move focus between form fields (inputs, buttons, etc.)"),keystroke:[["Tab"],["Shift+Tab"]]},{label:i("Move focus to the toolbar, navigate between toolbars"),keystroke:"Alt+F10",mayRequireFn:!0},{label:i("Navigate through the toolbar or menu bar"),keystroke:[["arrowup"],["arrowright"],["arrowdown"],["arrowleft"]]},{label:i("Execute the currently focused button. Executing buttons that interact with the editor content moves the focus back to the content."),keystroke:[["Enter"],["Space"]]}];t&&n.push({label:i("Move focus to the menu bar, navigate between menu bars"),keystroke:"Alt+F9",mayRequireFn:!0}),this.addKeystrokeInfoCategory({id:"navigation",label:i("User interface and content navigation keystrokes"),description:i("Use the following keystrokes for more efficient navigation in the CKEditor 5 user interface."),groups:[{id:"common",keystrokes:n}]})}}class Bm extends(Yo()){get isReadOnly(){return this._readOnlyLocks.size>0}set isReadOnly(e){throw new p("editor-isreadonly-has-no-setter")}enableReadOnlyMode(e){if("string"!=typeof e&&"symbol"!=typeof e)throw new p("editor-read-only-lock-id-invalid",null,{lockId:e});this._readOnlyLocks.has(e)||(this._readOnlyLocks.add(e),1===this._readOnlyLocks.size&&this.fire("change:isReadOnly","isReadOnly",!0,!1))}disableReadOnlyMode(e){if("string"!=typeof e&&"symbol"!=typeof e)throw new p("editor-read-only-lock-id-invalid",null,{lockId:e});this._readOnlyLocks.has(e)&&(this._readOnlyLocks.delete(e),0===this._readOnlyLocks.size&&this.fire("change:isReadOnly","isReadOnly",!1,!0))}setData(e){this.data.set(e)}getData(e){return this.data.get(e)}initPlugins(){const e=this.config,t=e.get("plugins"),i=e.get("removePlugins")||[],n=e.get("extraPlugins")||[],s=e.get("substitutePlugins")||[];return this.plugins.init(t.concat(n),i,s)}destroy(){let e=Promise.resolve();return"initializing"==this.state&&(e=new Promise((e=>this.once("ready",e)))),e.then((()=>{this.fire("destroy"),this.stopListening(),this.commands.destroy()})).then((()=>this.plugins.destroy())).then((()=>{this.model.destroy(),this.data.destroy(),this.editing.destroy(),this.keystrokes.destroy()})).then((()=>this._context._removeEditor(this)))}execute(e,...t){try{return this.commands.execute(e,...t)}catch(e){p.rethrowUnexpectedError(e,this)}}focus(){this.editing.view.focus()}static create(...e){throw new Error("This is an abstract method.")}constructor(e={}){super();const t=this.constructor,{translations:i,...n}=t.defaultConfig||{},{translations:s=i,...o}=e,r=e.language||n.language;this._context=e.context||new Ua({language:r,translations:s}),this._context._addEditor(this,!e.context);const a=Array.from(t.builtinPlugins||[]);this.config=new dr(o,n),this.config.define("plugins",a),this.config.define(this._context._getEditorConfig()),this.plugins=new $a(this,a,this._context.plugins),this.locale=this._context.locale,this.t=this.locale.t,this._readOnlyLocks=new Set,this.commands=new Sm,this.set("state","initializing"),this.once("ready",(()=>this.state="ready"),{priority:"high"}),this.once("destroy",(()=>this.state="destroyed"),{priority:"high"}),this.model=new Nu,this.on("change:isReadOnly",(()=>{this.model.document.isReadOnly=this.isReadOnly}));const l=new cl;this.data=new vh(this.model,l),this.editing=new Qd(this.model,l),this.editing.view.document.bind("isReadOnly").to(this),this.conversion=new _h([this.editing.downcastDispatcher,this.data.downcastDispatcher],this.data.upcastDispatcher),this.conversion.addAlias("dataDowncast",this.data.downcastDispatcher),this.conversion.addAlias("editingDowncast",this.editing.downcastDispatcher),this.keystrokes=new Im(this),this.keystrokes.listenTo(this.editing.view.document),this.accessibility=new Rm(this)}}function Om(e){if(!we(e.updateSourceElement))throw new p("attachtoform-missing-elementapi-interface",e);const t=e.sourceElement;if(function(e){return!!e&&"textarea"===e.tagName.toLowerCase()}(t)&&t.form){let i;const n=t.form,s=()=>e.updateSourceElement();we(n.submit)&&(i=n.submit,n.submit=()=>{s(),i.apply(n)}),n.addEventListener("submit",s),e.on("destroy",(()=>{n.removeEventListener("submit",s),i&&(n.submit=i)}))}}function Mm(e){return e}function Lm(e){return class extends e{updateSourceElement(e){if(!this.sourceElement)throw new p("editor-missing-sourceelement",this);const t=this.config.get("updateSourceElementOnDestroy"),i=this.sourceElement instanceof HTMLTextAreaElement;if(!t&&!i)return void Mr(this.sourceElement,"");const n="string"==typeof e?e:this.data.get();Mr(this.sourceElement,n)}}}function Nm(e,t){if(t.ckeditorInstance)throw new p("editor-source-element-already-used",e);t.ckeditorInstance=e,e.once("destroy",(()=>{delete t.ckeditorInstance}))}Lm.updateSourceElement=Lm(Object).prototype.updateSourceElement;class Fm extends Wa{static get pluginName(){return"PendingActions"}init(){this.set("hasAny",!1),this._actions=new va({idProperty:"_id"}),this._actions.delegate("add","remove").to(this)}add(e){if("string"!=typeof e)throw new p("pendingactions-add-invalid-message",this);const t=new(Yo());return t.set("message",e),this._actions.add(t),this.hasAny=!0,t}remove(e){this._actions.remove(e),this.hasAny=!!this._actions.length}get first(){return this._actions.get(0)}[Symbol.iterator](){return this._actions[Symbol.iterator]()}}const Dm={bold:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M10.187 17H5.773c-.637 0-1.092-.138-1.364-.415-.273-.277-.409-.718-.409-1.323V4.738c0-.617.14-1.062.419-1.332.279-.27.73-.406 1.354-.406h4.68c.69 0 1.288.041 1.793.124.506.083.96.242 1.36.478.341.197.644.447.906.75a3.262 3.262 0 0 1 .808 2.162c0 1.401-.722 2.426-2.167 3.075C15.05 10.175 16 11.315 16 13.01a3.756 3.756 0 0 1-2.296 3.504 6.1 6.1 0 0 1-1.517.377c-.571.073-1.238.11-2 .11zm-.217-6.217H7v4.087h3.069c1.977 0 2.965-.69 2.965-2.072 0-.707-.256-1.22-.768-1.537-.512-.319-1.277-.478-2.296-.478zM7 5.13v3.619h2.606c.729 0 1.292-.067 1.69-.2a1.6 1.6 0 0 0 .91-.765c.165-.267.247-.566.247-.897 0-.707-.26-1.176-.778-1.409-.519-.232-1.31-.348-2.375-.348H7z"/></svg>',cancel:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m11.591 10.177 4.243 4.242a1 1 0 0 1-1.415 1.415l-4.242-4.243-4.243 4.243a1 1 0 0 1-1.414-1.415l4.243-4.242L4.52 5.934A1 1 0 0 1 5.934 4.52l4.243 4.243 4.242-4.243a1 1 0 1 1 1.415 1.414l-4.243 4.243z"/></svg>',caption:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2 16h9a1 1 0 0 1 0 2H2a1 1 0 0 1 0-2z"/><path d="M17 1a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2h14zm0 1.5H3a.5.5 0 0 0-.492.41L2.5 3v9a.5.5 0 0 0 .41.492L3 12.5h14a.5.5 0 0 0 .492-.41L17.5 12V3a.5.5 0 0 0-.41-.492L17 2.5z" fill-opacity=".6"/></svg>',check:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M6.972 16.615a.997.997 0 0 1-.744-.292l-4.596-4.596a1 1 0 1 1 1.414-1.414l3.926 3.926 9.937-9.937a1 1 0 0 1 1.414 1.415L7.717 16.323a.997.997 0 0 1-.745.292z"/></svg>',cog:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m11.333 2 .19 2.263a5.899 5.899 0 0 1 1.458.604L14.714 3.4 16.6 5.286l-1.467 1.733c.263.452.468.942.605 1.46L18 8.666v2.666l-2.263.19a5.899 5.899 0 0 1-.604 1.458l1.467 1.733-1.886 1.886-1.733-1.467a5.899 5.899 0 0 1-1.46.605L11.334 18H8.667l-.19-2.263a5.899 5.899 0 0 1-1.458-.604L5.286 16.6 3.4 14.714l1.467-1.733a5.899 5.899 0 0 1-.604-1.458L2 11.333V8.667l2.262-.189a5.899 5.899 0 0 1 .605-1.459L3.4 5.286 5.286 3.4l1.733 1.467a5.899 5.899 0 0 1 1.46-.605L8.666 2h2.666zM10 6.267a3.733 3.733 0 1 0 0 7.466 3.733 3.733 0 0 0 0-7.466z"/></svg>',colorPalette:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M10.209 18.717A8.5 8.5 0 1 1 18.686 9.6h-.008l.002.12a3 3 0 0 1-2.866 2.997h-.268l-.046-.002v.002h-4.791a2 2 0 1 0 0 4 1 1 0 1 1-.128 1.992 8.665 8.665 0 0 1-.372.008Zm-3.918-7.01a1.25 1.25 0 1 0-2.415-.648 1.25 1.25 0 0 0 2.415.647ZM5.723 8.18a1.25 1.25 0 1 0 .647-2.414 1.25 1.25 0 0 0-.647 2.414ZM9.76 6.155a1.25 1.25 0 1 0 .647-2.415 1.25 1.25 0 0 0-.647 2.415Zm4.028 1.759a1.25 1.25 0 1 0 .647-2.415 1.25 1.25 0 0 0-.647 2.415Z"/></svg>',eraser:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m8.636 9.531-2.758 3.94a.5.5 0 0 0 .122.696l3.224 2.284h1.314l2.636-3.736L8.636 9.53zm.288 8.451L5.14 15.396a2 2 0 0 1-.491-2.786l6.673-9.53a2 2 0 0 1 2.785-.49l3.742 2.62a2 2 0 0 1 .491 2.785l-7.269 10.053-2.147-.066z"/><path d="M4 18h5.523v-1H4zm-2 0h1v-1H2z"/></svg>',history:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M11 1a9 9 0 1 1-8.027 13.075l1.128-1.129A7.502 7.502 0 0 0 18.5 10a7.5 7.5 0 1 0-14.962.759l-.745-.746-.76.76A9 9 0 0 1 11 1z"/><path d="M.475 8.17a.75.75 0 0 1 .978.047l.075.082 1.284 1.643 1.681-1.284a.75.75 0 0 1 .978.057l.073.083a.75.75 0 0 1-.057.978l-.083.073-2.27 1.737a.75.75 0 0 1-.973-.052l-.074-.082-1.741-2.23a.75.75 0 0 1 .13-1.052z"/><path d="M11.5 5v4.999l3.196 3.196-1.06 1.06L10.1 10.72l-.1-.113V5z"/></svg>',image:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M6.66 9.118a.693.693 0 0 1 .956.032l3.65 3.411 2.422-2.238a.695.695 0 0 1 .945 0L17.5 13.6V2.5h-15v11.1l4.16-4.482ZM17.8 1c.652 0 1.2.47 1.2 1.1v14.362c0 .64-.532 1.038-1.184 1.038H2.184C1.532 17.5 1 17.103 1 16.462V2.1C1 1.47 1.537 1 2.2 1h15.6Zm-5.655 6a2.128 2.128 0 0 1 .157-2.364A2.133 2.133 0 1 1 12.145 7Z"/></svg>',imageUpload:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M1.201 1C.538 1 0 1.47 0 2.1v14.363c0 .64.534 1.037 1.186 1.037h9.494a2.97 2.97 0 0 1-.414-.287 2.998 2.998 0 0 1-1.055-2.03 3.003 3.003 0 0 1 .693-2.185l.383-.455-.02.018-3.65-3.41a.695.695 0 0 0-.957-.034L1.5 13.6V2.5h15v5.535a2.97 2.97 0 0 1 1.412.932l.088.105V2.1c0-.63-.547-1.1-1.2-1.1H1.202Zm11.713 2.803a2.146 2.146 0 0 0-2.049 1.992 2.14 2.14 0 0 0 1.28 2.096 2.13 2.13 0 0 0 2.644-3.11 2.134 2.134 0 0 0-1.875-.978Z"/><path d="M15.522 19.1a.79.79 0 0 0 .79-.79v-5.373l2.059 2.455a.79.79 0 1 0 1.211-1.015l-3.352-3.995a.79.79 0 0 0-.995-.179.784.784 0 0 0-.299.221l-3.35 3.99a.79.79 0 1 0 1.21 1.017l1.936-2.306v5.185c0 .436.353.79.79.79Z"/><path d="M15.522 19.1a.79.79 0 0 0 .79-.79v-5.373l2.059 2.455a.79.79 0 1 0 1.211-1.015l-3.352-3.995a.79.79 0 0 0-.995-.179.784.784 0 0 0-.299.221l-3.35 3.99a.79.79 0 1 0 1.21 1.017l1.936-2.306v5.185c0 .436.353.79.79.79Z"/></svg>',imageAssetManager:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M1.201 1c-.662 0-1.2.47-1.2 1.1v14.248c0 .64.533 1.152 1.185 1.152h6.623v-7.236L6.617 9.15a.694.694 0 0 0-.957-.033L1.602 13.55V2.553l14.798.003V9.7H18V2.1c0-.63-.547-1.1-1.2-1.1H1.202Zm11.723 2.805a2.094 2.094 0 0 0-1.621.832 2.127 2.127 0 0 0 1.136 3.357 2.13 2.13 0 0 0 2.611-1.506 2.133 2.133 0 0 0-.76-2.244 2.13 2.13 0 0 0-1.366-.44Z"/><path clip-rule="evenodd" d="M19.898 12.369v6.187a.844.844 0 0 1-.844.844h-8.719a.844.844 0 0 1-.843-.844v-7.312a.844.844 0 0 1 .843-.844h2.531a.843.843 0 0 1 .597.248l.838.852h4.75c.223 0 .441.114.6.272a.844.844 0 0 1 .247.597Zm-1.52.654-4.377.02-1.1-1.143H11v6h7.4l-.023-4.877Z"/></svg>',imageUrl:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M1.201 1C.538 1 0 1.47 0 2.1v14.363c0 .64.534 1.037 1.186 1.037h7.029a5.401 5.401 0 0 1 .615-4.338l.762-1.232-2.975-2.78a.696.696 0 0 0-.957-.033L1.5 13.6V2.5h15v6.023c.449.131.887.32 1.307.573l.058.033c.046.028.09.057.135.086V2.1c0-.63-.547-1.1-1.2-1.1H1.202Zm11.713 2.803a2.15 2.15 0 0 0-1.611.834 2.118 2.118 0 0 0-.438 1.158 2.14 2.14 0 0 0 1.277 2.096 2.132 2.132 0 0 0 2.645-3.11 2.13 2.13 0 0 0-1.873-.978Z"/><path d="M16.63 10.294a3.003 3.003 0 0 0-4.142.887l-.117.177a.647.647 0 0 0-.096.492.664.664 0 0 0 .278.418.7.7 0 0 0 .944-.234 1.741 1.741 0 0 1 2.478-.463 1.869 1.869 0 0 1 .476 2.55.637.637 0 0 0-.071.5.646.646 0 0 0 .309.396.627.627 0 0 0 .869-.19l.027-.041a3.226 3.226 0 0 0-.956-4.492Zm-6.061 3.78-.044.066a3.228 3.228 0 0 0 .82 4.403 3.005 3.005 0 0 0 4.275-.798l.13-.197a.626.626 0 0 0 .092-.475.638.638 0 0 0-.268-.402.713.713 0 0 0-.99.26l-.018.029a1.741 1.741 0 0 1-2.477.461 1.87 1.87 0 0 1-.475-2.55l.029-.047a.647.647 0 0 0 .086-.485.66.66 0 0 0-.275-.408l-.04-.027a.609.609 0 0 0-.845.17Z"/><path d="M15.312 13.925c.24-.36.154-.838-.19-1.067-.346-.23-.82-.124-1.059.236l-1.268 1.907c-.239.36-.153.838.192 1.067.345.23.818.123 1.057-.236l1.268-1.907Z"/></svg>',lowVision:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M5.085 6.22 2.943 4.078a.75.75 0 1 1 1.06-1.06l2.592 2.59A11.094 11.094 0 0 1 10 5.068c4.738 0 8.578 3.101 8.578 5.083 0 1.197-1.401 2.803-3.555 3.887l1.714 1.713a.75.75 0 0 1-.09 1.138.488.488 0 0 1-.15.084.75.75 0 0 1-.821-.16L6.17 7.304c-.258.11-.51.233-.757.365l6.239 6.24-.006.005.78.78c-.388.094-.78.166-1.174.215l-1.11-1.11h.011L4.55 8.197a7.2 7.2 0 0 0-.665.514l-.112.098 4.897 4.897-.005.006 1.276 1.276a10.164 10.164 0 0 1-1.477-.117l-.479-.479-.009.009-4.863-4.863-.022.031a2.563 2.563 0 0 0-.124.2c-.043.077-.08.158-.108.241a.534.534 0 0 0-.028.133.29.29 0 0 0 .008.072.927.927 0 0 0 .082.226c.067.133.145.26.234.379l3.242 3.365.025.01.59.623c-3.265-.918-5.59-3.155-5.59-4.668 0-1.194 1.448-2.838 3.663-3.93zm7.07.531a4.632 4.632 0 0 1 1.108 5.992l.345.344.046-.018a9.313 9.313 0 0 0 2-1.112c.256-.187.5-.392.727-.613.137-.134.27-.277.392-.431.072-.091.141-.185.203-.286.057-.093.107-.19.148-.292a.72.72 0 0 0 .036-.12.29.29 0 0 0 .008-.072.492.492 0 0 0-.028-.133.999.999 0 0 0-.036-.096 2.165 2.165 0 0 0-.071-.145 2.917 2.917 0 0 0-.125-.2 3.592 3.592 0 0 0-.263-.335 5.444 5.444 0 0 0-.53-.523 7.955 7.955 0 0 0-1.054-.768 9.766 9.766 0 0 0-1.879-.891c-.337-.118-.68-.219-1.027-.301zm-2.85.21-.069.002a.508.508 0 0 0-.254.097.496.496 0 0 0-.104.679.498.498 0 0 0 .326.199l.045.005c.091.003.181.003.272.012a2.45 2.45 0 0 1 2.017 1.513c.024.061.043.125.069.185a.494.494 0 0 0 .45.287h.008a.496.496 0 0 0 .35-.158.482.482 0 0 0 .13-.335.638.638 0 0 0-.048-.219 3.379 3.379 0 0 0-.36-.723 3.438 3.438 0 0 0-2.791-1.543l-.028-.001h-.013z"/></svg>',textAlternative:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M3.035 1C2.446 1 2 1.54 2 2.098V10.5h1.5v-8h13v8H18V2.098C18 1.539 17.48 1 16.9 1H3.035Zm10.453 2.61a1.885 1.885 0 0 0-1.442.736 1.89 1.89 0 0 0 1.011 2.976 1.903 1.903 0 0 0 2.253-1.114 1.887 1.887 0 0 0-1.822-2.598ZM7.463 8.163a.611.611 0 0 0-.432.154L5.071 10.5h5.119L7.88 8.348a.628.628 0 0 0-.417-.185Zm6.236 1.059a.62.62 0 0 0-.42.164L12.07 10.5h2.969l-.92-1.113a.618.618 0 0 0-.42-.165ZM.91 11.5a.91.91 0 0 0-.91.912v6.877c0 .505.405.91.91.91h18.178a.91.91 0 0 0 .912-.91v-6.877a.908.908 0 0 0-.912-.912H.91ZM3.668 13h1.947l2.135 5.7H5.898l-.28-.946H3.601l-.278.945H1.516L3.668 13Zm4.947 0h1.801v4.3h2.7v1.4h-4.5V13h-.001Zm4.5 0h5.4v1.4h-1.798v4.3h-1.701v-4.3h-1.9V13h-.001Zm-8.517 1.457-.614 2.059h1.262l-.648-2.059Z"/></svg>',loupe:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M12.68 13.74h-.001l4.209 4.208a1 1 0 1 0 1.414-1.414l-4.267-4.268a6 6 0 1 0-1.355 1.474ZM13 9a4 4 0 1 1-8 0 4 4 0 0 1 8 0Z"/></svg>',previousArrow:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M11.463 5.187a.888.888 0 1 1 1.254 1.255L9.16 10l3.557 3.557a.888.888 0 1 1-1.254 1.255L7.26 10.61a.888.888 0 0 1 .16-1.382l4.043-4.042z"/></svg>',nextArrow:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M8.537 14.813a.888.888 0 1 1-1.254-1.255L10.84 10 7.283 6.442a.888.888 0 1 1 1.254-1.255L12.74 9.39a.888.888 0 0 1-.16 1.382l-4.043 4.042z"/></svg>',importExport:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M19 4.5 14 0H3v12.673l.868-1.041c.185-.222.4-.402.632-.54V1.5h8v5h5v7.626a2.24 2.24 0 0 1 1.5.822V4.5ZM14 5V2l3.3 3H14Zm-3.692 12.5c.062.105.133.206.213.303L11.52 19H8v-.876a2.243 2.243 0 0 0 1.82-.624h.488Zm7.518-.657a.75.75 0 0 0-1.152-.96L15.5 17.29V12H14v5.29l-1.174-1.408a.75.75 0 0 0-1.152.96l2.346 2.816a.95.95 0 0 0 1.46 0l2.346-2.815Zm-15.056-.38a.75.75 0 0 1-.096-1.056l2.346-2.815a.95.95 0 0 1 1.46 0l2.346 2.815a.75.75 0 1 1-1.152.96L6.5 14.96V20H5v-5.04l-1.174 1.408a.75.75 0 0 1-1.056.096Z"/></svg>',paragraph:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M10.5 5.5H7v5h3.5a2.5 2.5 0 1 0 0-5zM5 3h6.5v.025a5 5 0 0 1 0 9.95V13H7v4a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1z"/></svg>',plus:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M10 2a1 1 0 0 0-1 1v6H3a1 1 0 1 0 0 2h6v6a1 1 0 1 0 2 0v-6h6a1 1 0 1 0 0-2h-6V3a1 1 0 0 0-1-1Z"/></svg>',text:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M9.816 11.5 7.038 4.785 4.261 11.5h5.555Zm.62 1.5H3.641l-1.666 4.028H.312l5.789-14h1.875l5.789 14h-1.663L10.436 13Z"/><path d="m12.09 17-.534-1.292.848-1.971.545 1.319L12.113 17h-.023Zm1.142-5.187.545 1.319L15.5 9.13l1.858 4.316h-3.45l.398.965h3.467L18.887 17H20l-3.873-9h-1.254l-1.641 3.813Z"/></svg>',alignBottom:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m9.239 13.938-2.88-1.663a.75.75 0 0 1 .75-1.3L9 12.067V4.75a.75.75 0 1 1 1.5 0v7.318l1.89-1.093a.75.75 0 0 1 .75 1.3l-2.879 1.663a.752.752 0 0 1-.511.187.752.752 0 0 1-.511-.187zM4.25 17a.75.75 0 1 1 0-1.5h10.5a.75.75 0 0 1 0 1.5H4.25z"/></svg>',alignMiddle:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M9.75 11.875a.752.752 0 0 1 .508.184l2.883 1.666a.75.75 0 0 1-.659 1.344l-.091-.044-1.892-1.093.001 4.318a.75.75 0 1 1-1.5 0v-4.317l-1.89 1.092a.75.75 0 0 1-.75-1.3l2.879-1.663a.752.752 0 0 1 .51-.187zM15.25 9a.75.75 0 1 1 0 1.5H4.75a.75.75 0 1 1 0-1.5h10.5zM9.75.375a.75.75 0 0 1 .75.75v4.318l1.89-1.093.092-.045a.75.75 0 0 1 .659 1.344l-2.883 1.667a.752.752 0 0 1-.508.184.752.752 0 0 1-.511-.187L6.359 5.65a.75.75 0 0 1 .75-1.299L9 5.442V1.125a.75.75 0 0 1 .75-.75z"/></svg>',alignTop:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m10.261 7.062 2.88 1.663a.75.75 0 0 1-.75 1.3L10.5 8.933v7.317a.75.75 0 1 1-1.5 0V8.932l-1.89 1.093a.75.75 0 0 1-.75-1.3l2.879-1.663a.752.752 0 0 1 .511-.187.752.752 0 0 1 .511.187zM15.25 4a.75.75 0 1 1 0 1.5H4.75a.75.75 0 0 1 0-1.5h10.5z"/></svg>',alignLeft:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2 3.75c0 .414.336.75.75.75h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75zm0 8c0 .414.336.75.75.75h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75zm0 4c0 .414.336.75.75.75h9.929a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75zm0-8c0 .414.336.75.75.75h9.929a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75z"/></svg>',alignCenter:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2 3.75c0 .414.336.75.75.75h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75zm0 8c0 .414.336.75.75.75h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75zm2.286 4c0 .414.336.75.75.75h9.928a.75.75 0 1 0 0-1.5H5.036a.75.75 0 0 0-.75.75zm0-8c0 .414.336.75.75.75h9.928a.75.75 0 1 0 0-1.5H5.036a.75.75 0 0 0-.75.75z"/></svg>',alignRight:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M18 3.75a.75.75 0 0 1-.75.75H2.75a.75.75 0 1 1 0-1.5h14.5a.75.75 0 0 1 .75.75zm0 8a.75.75 0 0 1-.75.75H2.75a.75.75 0 1 1 0-1.5h14.5a.75.75 0 0 1 .75.75zm0 4a.75.75 0 0 1-.75.75H7.321a.75.75 0 1 1 0-1.5h9.929a.75.75 0 0 1 .75.75zm0-8a.75.75 0 0 1-.75.75H7.321a.75.75 0 1 1 0-1.5h9.929a.75.75 0 0 1 .75.75z"/></svg>',alignJustify:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2 3.75c0 .414.336.75.75.75h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75zm0 8c0 .414.336.75.75.75h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75zm0 4c0 .414.336.75.75.75h9.929a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75zm0-8c0 .414.336.75.75.75h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75z"/></svg>',objectLeft:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path opacity=".5" d="M2 3h16v1.5H2zm11.5 9H18v1.5h-4.5zm0-3H18v1.5h-4.5zm0-3H18v1.5h-4.5zM2 15h16v1.5H2z"/><path d="M12.003 7v5.5a1 1 0 0 1-1 1H2.996a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h8.007a1 1 0 0 1 1 1zm-1.506.5H3.5V12h6.997V7.5z"/></svg>',objectCenter:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path opacity=".5" d="M2 3h16v1.5H2zm0 12h16v1.5H2z"/><path d="M15.003 7v5.5a1 1 0 0 1-1 1H5.996a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h8.007a1 1 0 0 1 1 1zm-1.506.5H6.5V12h6.997V7.5z"/></svg>',objectRight:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path opacity=".5" d="M2 3h16v1.5H2zm0 12h16v1.5H2zm0-9h5v1.5H2zm0 3h5v1.5H2zm0 3h5v1.5H2z"/><path d="M18.003 7v5.5a1 1 0 0 1-1 1H8.996a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h8.007a1 1 0 0 1 1 1zm-1.506.5H9.5V12h6.997V7.5z"/></svg>',objectFullWidth:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path opacity=".5" d="M2 3h16v1.5H2zm0 12h16v1.5H2z"/><path d="M18 7v5.5a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1zm-1.505.5H3.504V12h12.991V7.5z"/></svg>',objectInline:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path opacity=".5" d="M2 3h16v1.5H2zm11.5 9H18v1.5h-4.5zM2 15h16v1.5H2z"/><path d="M12.003 7v5.5a1 1 0 0 1-1 1H2.996a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h8.007a1 1 0 0 1 1 1zm-1.506.5H3.5V12h6.997V7.5z"/></svg>',objectBlockLeft:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path opacity=".5" d="M2 3h16v1.5H2zm0 12h16v1.5H2z"/><path d="M12.003 7v5.5a1 1 0 0 1-1 1H2.996a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h8.007a1 1 0 0 1 1 1zm-1.506.5H3.5V12h6.997V7.5z"/></svg>',objectBlockRight:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path opacity=".5" d="M2 3h16v1.5H2zm0 12h16v1.5H2z"/><path d="M18.003 7v5.5a1 1 0 0 1-1 1H8.996a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h8.007a1 1 0 0 1 1 1zm-1.506.5H9.5V12h6.997V7.5z"/></svg>',objectSizeCustom:'<svg xmlns="http://www.w3.org/2000/svg" xmlns:v="https://vecta.io/nano" viewBox="0 0 20 20"><path d="M.95 1.43a.95.95 0 0 0-.95.95v3.1a.95.95 0 0 0 .95.95h.75v6.3H.95a.95.95 0 0 0-.95.95v3.1a.95.95 0 0 0 .95.95h3.1a.95.95 0 0 0 .95-.95v-.65h1.932l1.539-1.5H5v-.95a.95.95 0 0 0-.95-.95H3.2v-6.3h.85A.95.95 0 0 0 5 5.48v-.55h10v.55a.95.95 0 0 0 .95.95h3.1a.95.95 0 0 0 .95-.95v-3.1a.95.95 0 0 0-.95-.95h-3.1a.95.95 0 0 0-.95.95v1.05H5V2.38a.95.95 0 0 0-.95-.95H.95zm.55 3.5v-2h2v2h-2zm0 9.3v2h2v-2h-2zm15-11.3v2h2v-2h-2z"/><path d="M8.139 20.004v-2.388l7.045-7.048 2.391 2.391-7.046 7.046h-2.39zm11.421-9.101a.64.64 0 0 1-.138.206l-1.165 1.168-2.391-2.391 1.167-1.163a.63.63 0 0 1 .206-.138.635.635 0 0 1 .243-.049.63.63 0 0 1 .449.187l1.491 1.488c.059.059.108.129.138.206s.049.16.049.243a.6.6 0 0 1-.049.243z"/></svg>',objectSizeFull:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M2.5 17v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zM1 15.5v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm0-2v1h-1v-1h1zm-19 0v1H0v-1h1zM14.5 2v1h-1V2h1zm2 0v1h-1V2h1zm2 0v1h-1V2h1zm-8 0v1h-1V2h1zm-2 0v1h-1V2h1zm-2 0v1h-1V2h1zm-2 0v1h-1V2h1zm8 0v1h-1V2h1zm-10 0v1h-1V2h1z"/><path d="M18.095 2H1.905C.853 2 0 2.895 0 4v12c0 1.105.853 2 1.905 2h16.19C19.147 18 20 17.105 20 16V4c0-1.105-.853-2-1.905-2zm0 1.5c.263 0 .476.224.476.5v12c0 .276-.213.5-.476.5H1.905a.489.489 0 0 1-.476-.5V4c0-.276.213-.5.476-.5h16.19z"/></svg>',objectSizeLarge:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2.5 16.5v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1ZM1 15v1H0v-1h1Zm19 0v1h-1v-1h1ZM1 13v1H0v-1h1Zm19 0v1h-1v-1h1ZM1 11v1H0v-1h1Zm19 0v1h-1v-1h1ZM1 9v1H0V9h1Zm19 0v1h-1V9h1ZM1 7v1H0V7h1Zm19 0v1h-1V7h1ZM1 5v1H0V5h1Zm19 0v1h-1V5h1Zm0-2v1h-1V3h1ZM1 3v1H0V3h1Zm13.5-1.5v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1Zm-8 0v1h-1v-1h1Zm-2 0v1h-1v-1h1Zm-2 0v1h-1v-1h1Zm-2 0v1h-1v-1h1Zm8 0v1h-1v-1h1Zm-10 0v1h-1v-1h1Z"/><path d="M13 5.5H2a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h11a2 2 0 0 0 2-2v-8a2 2 0 0 0-2-2ZM13 7a.5.5 0 0 1 .5.5v8a.5.5 0 0 1-.5.5H2a.5.5 0 0 1-.5-.5v-8A.5.5 0 0 1 2 7h11Z"/></svg>',objectSizeSmall:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2.5 16.5v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1ZM1 15v1H0v-1h1Zm19 0v1h-1v-1h1ZM1 13v1H0v-1h1Zm19 0v1h-1v-1h1ZM1 11v1H0v-1h1Zm19 0v1h-1v-1h1ZM1 9v1H0V9h1Zm19 0v1h-1V9h1ZM1 7v1H0V7h1Zm19 0v1h-1V7h1ZM1 5v1H0V5h1Zm19 0v1h-1V5h1Zm0-2v1h-1V3h1ZM1 3v1H0V3h1Zm13.5-1.5v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1Zm-8 0v1h-1v-1h1Zm-2 0v1h-1v-1h1Zm-2 0v1h-1v-1h1Zm-2 0v1h-1v-1h1Zm8 0v1h-1v-1h1Zm-10 0v1h-1v-1h1Z"/><path d="M7 9.5H2a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h5a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2ZM7 11a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5H2a.5.5 0 0 1-.5-.5v-4A.5.5 0 0 1 2 11h5Z"/></svg>',objectSizeMedium:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2.5 16.5v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1ZM1 15v1H0v-1h1Zm19 0v1h-1v-1h1ZM1 13v1H0v-1h1Zm19 0v1h-1v-1h1ZM1 11v1H0v-1h1Zm19 0v1h-1v-1h1ZM1 9v1H0V9h1Zm19 0v1h-1V9h1ZM1 7v1H0V7h1Zm19 0v1h-1V7h1ZM1 5v1H0V5h1Zm19 0v1h-1V5h1Zm0-2v1h-1V3h1ZM1 3v1H0V3h1Zm13.5-1.5v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1Zm-8 0v1h-1v-1h1Zm-2 0v1h-1v-1h1Zm-2 0v1h-1v-1h1Zm-2 0v1h-1v-1h1Zm8 0v1h-1v-1h1Zm-10 0v1h-1v-1h1Z"/><path d="M10 7.5H2a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2v-6a2 2 0 0 0-2-2ZM10 9a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-.5.5H2a.5.5 0 0 1-.5-.5v-6A.5.5 0 0 1 2 9h8Z"/></svg>',pencil:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m7.3 17.37-.061.088a1.518 1.518 0 0 1-.934.535l-4.178.663-.806-4.153a1.495 1.495 0 0 1 .187-1.058l.056-.086L8.77 2.639c.958-1.351 2.803-1.076 4.296-.03 1.497 1.047 2.387 2.693 1.433 4.055L7.3 17.37zM9.14 4.728l-5.545 8.346 3.277 2.294 5.544-8.346L9.14 4.728zM6.07 16.512l-3.276-2.295.53 2.73 2.746-.435zM9.994 3.506 13.271 5.8c.316-.452-.16-1.333-1.065-1.966-.905-.634-1.895-.78-2.212-.328zM8 18.5 9.375 17H19v1.5H8z"/></svg>',pilcrow:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M6.999 2H15a1 1 0 0 1 0 2h-1.004v13a1 1 0 1 1-2 0V4H8.999v13a1 1 0 1 1-2 0v-7A4 4 0 0 1 3 6a4 4 0 0 1 3.999-4z"/></svg>',quote:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M3 10.423a6.5 6.5 0 0 1 6.056-6.408l.038.67C6.448 5.423 5.354 7.663 5.22 10H9c.552 0 .5.432.5.986v4.511c0 .554-.448.503-1 .503h-5c-.552 0-.5-.449-.5-1.003v-4.574zm8 0a6.5 6.5 0 0 1 6.056-6.408l.038.67c-2.646.739-3.74 2.979-3.873 5.315H17c.552 0 .5.432.5.986v4.511c0 .554-.448.503-1 .503h-5c-.552 0-.5-.449-.5-1.003v-4.574z"/></svg>',threeVerticalDots:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><circle cx="9.5" cy="4.5" r="1.5"/><circle cx="9.5" cy="10.5" r="1.5"/><circle cx="9.5" cy="16.5" r="1.5"/></svg>',dragIndicator:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M5 3.25a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0"/><path d="M12 3.25a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0"/><path d="M5 10a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0"/><path d="M12 10a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0"/><path d="M5 16.75a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0"/><path d="M12 16.75a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0"/></svg>',redo:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m14.958 9.367-2.189 1.837a.75.75 0 0 0 .965 1.149l3.788-3.18a.747.747 0 0 0 .21-.284.75.75 0 0 0-.17-.945L13.77 4.762a.75.75 0 1 0-.964 1.15l2.331 1.955H6.22A.75.75 0 0 0 6 7.9a4 4 0 1 0 1.477 7.718l-.344-1.489A2.5 2.5 0 1 1 6.039 9.4l-.008-.032h8.927z"/></svg>',undo:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m5.042 9.367 2.189 1.837a.75.75 0 0 1-.965 1.149l-3.788-3.18a.747.747 0 0 1-.21-.284.75.75 0 0 1 .17-.945L6.23 4.762a.75.75 0 1 1 .964 1.15L4.863 7.866h8.917A.75.75 0 0 1 14 7.9a4 4 0 1 1-1.477 7.718l.344-1.489a2.5 2.5 0 1 0 1.094-4.73l.008-.032H5.042z"/></svg>',bulletedList:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M7 5.75c0 .414.336.75.75.75h9.5a.75.75 0 1 0 0-1.5h-9.5a.75.75 0 0 0-.75.75zm-6 0C1 4.784 1.777 4 2.75 4c.966 0 1.75.777 1.75 1.75 0 .966-.777 1.75-1.75 1.75C1.784 7.5 1 6.723 1 5.75zm6 9c0 .414.336.75.75.75h9.5a.75.75 0 1 0 0-1.5h-9.5a.75.75 0 0 0-.75.75zm-6 0c0-.966.777-1.75 1.75-1.75.966 0 1.75.777 1.75 1.75 0 .966-.777 1.75-1.75 1.75-.966 0-1.75-.777-1.75-1.75z"/></svg>',numberedList:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M7 5.75c0 .414.336.75.75.75h9.5a.75.75 0 1 0 0-1.5h-9.5a.75.75 0 0 0-.75.75zM3.5 3v5H2V3.7H1v-1h2.5V3zM.343 17.857l2.59-3.257H2.92a.6.6 0 1 0-1.04 0H.302a2 2 0 1 1 3.995 0h-.001c-.048.405-.16.734-.333.988-.175.254-.59.692-1.244 1.312H4.3v1h-4l.043-.043zM7 14.75a.75.75 0 0 1 .75-.75h9.5a.75.75 0 1 1 0 1.5h-9.5a.75.75 0 0 1-.75-.75z"/></svg>',todoList:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m2.315 14.705 2.224-2.24a.689.689 0 0 1 .963 0 .664.664 0 0 1 0 .949L2.865 16.07a.682.682 0 0 1-.112.089.647.647 0 0 1-.852-.051L.688 14.886a.635.635 0 0 1 0-.903.647.647 0 0 1 .91 0l.717.722zm5.185.045a.75.75 0 0 1 .75-.75h9.5a.75.75 0 1 1 0 1.5h-9.5a.75.75 0 0 1-.75-.75zM2.329 5.745l2.21-2.226a.689.689 0 0 1 .963 0 .664.664 0 0 1 0 .95L2.865 7.125a.685.685 0 0 1-.496.196.644.644 0 0 1-.468-.187L.688 5.912a.635.635 0 0 1 0-.903.647.647 0 0 1 .91 0l.73.736zM7.5 5.75A.75.75 0 0 1 8.25 5h9.5a.75.75 0 1 1 0 1.5h-9.5a.75.75 0 0 1-.75-.75z"/></svg>',codeBlock:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M12.87 12.61a.75.75 0 0 1-.089.976l-.085.07-3.154 2.254 3.412 2.414a.75.75 0 0 1 .237.95l-.057.095a.75.75 0 0 1-.95.237l-.096-.058-4.272-3.022-.003-1.223 4.01-2.867a.75.75 0 0 1 1.047.174zm2.795-.231.095.057 4.011 2.867-.003 1.223-4.272 3.022-.095.058a.75.75 0 0 1-.88-.151l-.07-.086-.058-.095a.75.75 0 0 1 .15-.88l.087-.07 3.412-2.414-3.154-2.253-.085-.071a.75.75 0 0 1 .862-1.207zM16 0a2 2 0 0 1 2 2v9.354l-.663-.492-.837-.001V2a.5.5 0 0 0-.5-.5H2a.5.5 0 0 0-.5.5v15a.5.5 0 0 0 .5.5h3.118L7.156 19H2a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2h14zM5.009 15l.003 1H3v-1h2.009zm2.188-2-1.471 1H5v-1h2.197zM10 11v.095L8.668 12H7v-1h3zm4-2v1H7V9h7zm0-2v1H7V7h7zm-4-2v1H5V5h5zM6 3v1H3V3h3z"/></svg>',browseFiles:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M11.627 16.5zm5.873-.196zm0-7.001V8h-13v8.5h4.341c.191.54.457 1.044.785 1.5H2a1.5 1.5 0 0 1-1.5-1.5v-13A1.5 1.5 0 0 1 2 2h4.5a1.5 1.5 0 0 1 1.06.44L9.122 4H16a1.5 1.5 0 0 1 1.5 1.5v1A1.5 1.5 0 0 1 19 8v2.531a6.027 6.027 0 0 0-1.5-1.228zM16 6.5v-1H8.5l-2-2H2v13h1V8a1.5 1.5 0 0 1 1.5-1.5H16z"/><path d="M14.5 19.5a5 5 0 1 1 0-10 5 5 0 0 1 0 10zM15 14v-2h-1v2h-2v1h2v2h1v-2h2v-1h-2z"/></svg>',heading1:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M19 9v10h-2v-8h-2V9h4zM4 8.5h5V4a1 1 0 0 1 1-1h.5a1 1 0 0 1 1 1v11.5a1 1 0 0 1-1 1H10a1 1 0 0 1-1-1V11H4v4.5a1 1 0 0 1-1 1h-.5a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1H3a1 1 0 0 1 1 1v4.5z"/></svg>',heading2:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M3 8.5h5V4a1 1 0 0 1 1-1h.5a1 1 0 0 1 1 1v11.5a1 1 0 0 1-1 1H9a1 1 0 0 1-1-1V11H3v4.5a1 1 0 0 1-1 1h-.5a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1H2a1 1 0 0 1 1 1v4.5zm16.076 8.343V18.5h-6.252c.067-.626.27-1.22.61-1.78.338-.561 1.006-1.305 2.005-2.232.804-.749 1.297-1.257 1.479-1.523.245-.368.368-.732.368-1.092 0-.398-.107-.703-.32-.917-.214-.214-.51-.32-.886-.32-.372 0-.669.111-.889.336-.22.224-.347.596-.38 1.117l-1.778-.178c.106-.982.438-1.686.997-2.114.558-.427 1.257-.64 2.095-.64.918 0 1.64.247 2.164.742.525.495.787 1.11.787 1.847 0 .419-.075.818-.225 1.197-.15.378-.388.775-.714 1.19-.216.275-.605.67-1.168 1.187-.563.516-.92.859-1.07 1.028a3.11 3.11 0 0 0-.365.495h3.542z"/></svg>',heading3:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M3 8.5h5V4a1 1 0 0 1 1-1h.5a1 1 0 0 1 1 1v11.5a1 1 0 0 1-1 1H9a1 1 0 0 1-1-1V11H3v4.5a1 1 0 0 1-1 1h-.5a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1H2a1 1 0 0 1 1 1v4.5zm9.989 7.53 1.726-.209c.055.44.203.777.445 1.01.24.232.533.349.876.349.368 0 .678-.14.93-.42.251-.279.377-.655.377-1.13 0-.448-.12-.803-.362-1.066a1.153 1.153 0 0 0-.882-.393c-.228 0-.501.044-.819.133l.197-1.453c.482.012.85-.092 1.105-.315.253-.222.38-.517.38-.885 0-.313-.093-.563-.279-.75-.186-.185-.434-.278-.743-.278a1.07 1.07 0 0 0-.78.317c-.216.212-.347.52-.394.927l-1.644-.28c.114-.562.287-1.012.517-1.348.231-.337.553-.601.965-.794a3.24 3.24 0 0 1 1.387-.289c.876 0 1.579.28 2.108.838.436.457.653.973.653 1.549 0 .817-.446 1.468-1.339 1.955.533.114.96.37 1.28.768.319.398.478.878.478 1.441 0 .817-.298 1.513-.895 2.088-.596.576-1.339.864-2.228.864-.842 0-1.54-.243-2.094-.727-.555-.485-.876-1.118-.965-1.901z"/></svg>',heading4:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M3.5 8.5h5V4a1 1 0 0 1 1-1h.5a1 1 0 0 1 1 1v11.5a1 1 0 0 1-1 1h-.5a1 1 0 0 1-1-1V11h-5v4.5a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h.5a1 1 0 0 1 1 1v4.5zm13.55 10v-1.873h-3.81v-1.561l4.037-5.91h1.498v5.904h1.156v1.567h-1.156V18.5H17.05zm0-3.44v-3.18l-2.14 3.18h2.14z"/></svg>',heading5:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M3.5 8.5h5V4a1 1 0 0 1 1-1h.5a1 1 0 0 1 1 1v11.5a1 1 0 0 1-1 1h-.5a1 1 0 0 1-1-1V11h-5v4.5a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h.5a1 1 0 0 1 1 1v4.5zm9.578 7.607 1.777-.184c.05.402.201.72.45.955a1.223 1.223 0 0 0 1.81-.101c.258-.303.387-.759.387-1.368 0-.572-.128-1-.384-1.286-.256-.285-.59-.428-1-.428-.512 0-.971.226-1.377.679l-1.448-.21.915-4.843h4.716v1.67H15.56l-.28 1.58a2.697 2.697 0 0 1 1.219-.298 2.68 2.68 0 0 1 2.012.863c.55.576.825 1.323.825 2.241a3.36 3.36 0 0 1-.666 2.05c-.605.821-1.445 1.232-2.52 1.232-.86 0-1.56-.23-2.101-.692-.542-.461-.866-1.081-.971-1.86z"/></svg>',heading6:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M3.5 8.5h5V4a1 1 0 0 1 1-1h.5a1 1 0 0 1 1 1v11.5a1 1 0 0 1-1 1h-.5a1 1 0 0 1-1-1V11h-5v4.5a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h.5a1 1 0 0 1 1 1v4.5zm15.595 2.973-1.726.19c-.043-.355-.153-.617-.33-.787-.178-.169-.409-.253-.692-.253-.377 0-.695.169-.956.507-.26.339-.424 1.043-.492 2.114.445-.525.997-.787 1.657-.787.745 0 1.383.284 1.914.85.531.568.797 1.3.797 2.197 0 .952-.28 1.716-.838 2.291-.559.576-1.276.864-2.152.864-.94 0-1.712-.365-2.317-1.095-.605-.73-.908-1.927-.908-3.59 0-1.705.316-2.935.946-3.688.63-.753 1.45-1.13 2.457-1.13.706 0 1.291.198 1.755.594.463.395.758.97.885 1.723zm-4.043 3.891c0 .58.133 1.028.4 1.343.266.315.57.473.914.473.33 0 .605-.13.825-.388.22-.258.33-.68.33-1.27 0-.604-.118-1.047-.355-1.329a1.115 1.115 0 0 0-.89-.422c-.342 0-.632.134-.869.403s-.355.666-.355 1.19z"/></svg>',horizontalLine:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2 9h16v2H2z"/></svg>',html:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M17 0a2 2 0 0 1 2 2v7a1 1 0 0 1 1 1v5a1 1 0 0 1-.883.993l-.118.006L19 17a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2l-.001-1.001-.116-.006A1 1 0 0 1 0 15v-5a1 1 0 0 1 .999-1L1 2a2 2 0 0 1 2-2h14zm.499 15.999h-15L2.5 17a.5.5 0 0 0 .5.5h14a.5.5 0 0 0 .5-.5l-.001-1.001zm-3.478-6.013-.014.014H14v.007l-1.525 1.525-1.46-1.46-.015.013V10h-1v5h1v-3.53l1.428 1.43.048.043.131-.129L14 11.421V15h1v-5h-.965l-.014-.014zM2 10H1v5h1v-2h2v2h1v-5H4v2H2v-2zm7 0H6v1h1v4h1v-4h1v-1zm8 0h-1v5h3v-1h-2v-4zm0-8.5H3a.5.5 0 0 0-.5.5l-.001 6.999h15L17.5 2a.5.5 0 0 0-.5-.5zM10 7v1H4V7h6zm3-2v1H4V5h9zm-3-2v1H4V3h6z"/></svg>',indent:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2 3.75c0 .414.336.75.75.75h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75zm5 6c0 .414.336.75.75.75h9.5a.75.75 0 1 0 0-1.5h-9.5a.75.75 0 0 0-.75.75zM2.75 16.5h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 1 0 0 1.5zM1.632 6.95 5.02 9.358a.4.4 0 0 1-.013.661l-3.39 2.207A.4.4 0 0 1 1 11.892V7.275a.4.4 0 0 1 .632-.326z"/></svg>',outdent:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2 3.75c0 .414.336.75.75.75h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75zm5 6c0 .414.336.75.75.75h9.5a.75.75 0 1 0 0-1.5h-9.5a.75.75 0 0 0-.75.75zM2.75 16.5h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 1 0 0 1.5zm1.618-9.55L.98 9.358a.4.4 0 0 0 .013.661l3.39 2.207A.4.4 0 0 0 5 11.892V7.275a.4.4 0 0 0-.632-.326z"/></svg>',table:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M3 5.5v3h4v-3H3Zm0 4v3h4v-3H3Zm0 4v3h4v-3H3Zm5 3h4v-3H8v3Zm5 0h4v-3h-4v3Zm4-4v-3h-4v3h4Zm0-4v-3h-4v3h4Zm1.5 8A1.5 1.5 0 0 1 17 18H3a1.5 1.5 0 0 1-1.5-1.5V3c.222-.863 1.068-1.5 2-1.5h13c.932 0 1.778.637 2 1.5v13.5Zm-6.5-4v-3H8v3h4Zm0-4v-3H8v3h4Z"/></svg>'};class zm extends(Yo()){get error(){return this._reader.error}get data(){return this._data}read(e){const t=this._reader;return this.total=e.size,new Promise(((i,n)=>{t.onload=()=>{const e=t.result;this._data=e,i(e)},t.onerror=()=>{n("error")},t.onabort=()=>{n("aborted")},this._reader.readAsDataURL(e)}))}abort(){this._reader.abort()}constructor(){super();const e=new window.FileReader;this._reader=e,this._data=void 0,this.set("loaded",0),e.onprogress=e=>{this.loaded=e.loaded}}}class Hm extends Na{static get pluginName(){return"FileRepository"}static get requires(){return[Fm]}init(){this.loaders.on("change",(()=>this._updatePendingAction())),this.set("uploaded",0),this.set("uploadTotal",null),this.bind("uploadedPercent").to(this,"uploaded",this,"uploadTotal",((e,t)=>t?e/t*100:0))}getLoader(e){return this._loadersMap.get(e)||null}createLoader(e){if(!this.createUploadAdapter)return b("filerepository-no-upload-adapter"),null;const t=new $m(Promise.resolve(e),this.createUploadAdapter);return this.loaders.add(t),this._loadersMap.set(e,t),e instanceof Promise&&t.file.then((e=>{this._loadersMap.set(e,t)})).catch((()=>{})),t.on("change:uploaded",(()=>{let e=0;for(const t of this.loaders)e+=t.uploaded;this.uploaded=e})),t.on("change:uploadTotal",(()=>{let e=0;for(const t of this.loaders)t.uploadTotal&&(e+=t.uploadTotal);this.uploadTotal=e})),t}destroyLoader(e){const t=e instanceof $m?e:this.getLoader(e);t._destroy(),this.loaders.remove(t),this._loadersMap.forEach(((e,i)=>{e===t&&this._loadersMap.delete(i)}))}_updatePendingAction(){const e=this.editor.plugins.get(Fm);if(this.loaders.length){if(!this._pendingAction){const t=this.editor.t,i=e=>`${t("Upload in progress")} ${parseInt(e)}%.`;this._pendingAction=e.add(i(this.uploadedPercent)),this._pendingAction.bind("message").to(this,"uploadedPercent",i)}}else e.remove(this._pendingAction),this._pendingAction=null}constructor(...e){super(...e),this.loaders=new va,this._loadersMap=new Map,this._pendingAction=null}}class $m extends(Yo()){get file(){return this._filePromiseWrapper?this._filePromiseWrapper.promise.then((e=>this._filePromiseWrapper?e:null)):Promise.resolve(null)}get data(){return this._reader.data}read(){if("idle"!=this.status)throw new p("filerepository-read-wrong-status",this);return this.status="reading",this.file.then((e=>this._reader.read(e))).then((e=>{if("reading"!==this.status)throw this.status;return this.status="idle",e})).catch((e=>{if("aborted"===e)throw this.status="aborted","aborted";throw this.status="error",this._reader.error?this._reader.error:e}))}upload(){if("idle"!=this.status)throw new p("filerepository-upload-wrong-status",this);return this.status="uploading",this.file.then((()=>this._adapter.upload())).then((e=>(this.uploadResponse=e,this.status="idle",e))).catch((e=>{if("aborted"===this.status)throw"aborted";throw this.status="error",e}))}abort(){const e=this.status;this.status="aborted",this._filePromiseWrapper.isFulfilled?"reading"==e?this._reader.abort():"uploading"==e&&this._adapter.abort&&this._adapter.abort():(this._filePromiseWrapper.promise.catch((()=>{})),this._filePromiseWrapper.rejecter("aborted")),this._destroy()}_destroy(){this._filePromiseWrapper=void 0,this._reader=void 0,this._adapter=void 0,this.uploadResponse=void 0}_createFilePromiseWrapper(e){const t={};return t.promise=new Promise(((i,n)=>{t.rejecter=n,t.isFulfilled=!1,e.then((e=>{t.isFulfilled=!0,i(e)})).catch((e=>{t.isFulfilled=!0,n(e)}))})),t}constructor(e,t){super(),this.id=u(),this._filePromiseWrapper=this._createFilePromiseWrapper(e),this._adapter=t(this),this._reader=new zm,this.set("status","idle"),this.set("uploaded",0),this.set("uploadTotal",null),this.bind("uploadedPercent").to(this,"uploaded",this,"uploadTotal",((e,t)=>t?e/t*100:0)),this.set("uploadResponse",null)}}class Um extends Na{static get requires(){return[Hm]}static get pluginName(){return"Base64UploadAdapter"}init(){this.editor.plugins.get(Hm).createUploadAdapter=e=>new Wm(e)}}let Wm=class{upload(){return new Promise(((e,t)=>{const i=this.reader=new window.FileReader;i.addEventListener("load",(()=>{e({default:i.result})})),i.addEventListener("error",(e=>{t(e)})),i.addEventListener("abort",(()=>{t()})),this.loader.file.then((e=>{i.readAsDataURL(e)}))}))}abort(){this.reader.abort()}constructor(e){this.loader=e}};class jm extends Na{static get requires(){return[Hm]}static get pluginName(){return"SimpleUploadAdapter"}init(){const e=this.editor.config.get("simpleUpload");e&&(e.uploadUrl?this.editor.plugins.get(Hm).createUploadAdapter=t=>new qm(t,e):b("simple-upload-adapter-missing-uploadurl"))}}let qm=class{upload(){return this.loader.file.then((e=>new Promise(((t,i)=>{this._initRequest(),this._initListeners(t,i,e),this._sendRequest(e)}))))}abort(){this.xhr&&this.xhr.abort()}_initRequest(){const e=this.xhr=new XMLHttpRequest;e.open("POST",this.options.uploadUrl,!0),e.responseType="json"}_initListeners(e,t,i){const n=this.xhr,s=this.loader,o=`Couldn't upload file: ${i.name}.`;n.addEventListener("error",(()=>t(o))),n.addEventListener("abort",(()=>t())),n.addEventListener("load",(()=>{const i=n.response;if(!i||i.error)return t(i&&i.error&&i.error.message?i.error.message:o);const s=i.url?{default:i.url}:i.urls;e({...i,urls:s})})),n.upload&&n.upload.addEventListener("progress",(e=>{e.lengthComputable&&(s.uploadTotal=e.total,s.uploaded=e.loaded)}))}_sendRequest(e){const t=this.options.headers||{},i=this.options.withCredentials||!1;for(const e of Object.keys(t))this.xhr.setRequestHeader(e,t[e]);this.xhr.withCredentials=i;const n=new FormData;n.append("upload",e),this.xhr.send(n)}constructor(e,t){this.loader=e,this.options=t}};const Gm="ckCsrfToken",Km="abcdefghijklmnopqrstuvwxyz0123456789";function Zm(){let e=function(e){e=e.toLowerCase();const t=document.cookie.split(";");for(const i of t){const t=i.split("=");if(decodeURIComponent(t[0].trim().toLowerCase())===e)return decodeURIComponent(t[1])}return null}(Gm);var t,i;return e&&40==e.length||(e=function(e){let t="";const i=new Uint8Array(e);window.crypto.getRandomValues(i);for(let e=0;e<i.length;e++){const n=Km.charAt(i[e]%Km.length);t+=Math.random()>.5?n.toUpperCase():n}return t}(40),t=Gm,i=e,document.cookie=encodeURIComponent(t)+"="+encodeURIComponent(i)+";path=/"),e}class Jm extends Na{static get requires(){return[Hm]}static get pluginName(){return"CKFinderUploadAdapter"}init(){const e=this.editor.config.get("ckfinder.uploadUrl");e&&(this.editor.plugins.get(Hm).createUploadAdapter=t=>new Qm(t,e,this.editor.t))}}class Qm{upload(){return this.loader.file.then((e=>new Promise(((t,i)=>{this._initRequest(),this._initListeners(t,i,e),this._sendRequest(e)}))))}abort(){this.xhr&&this.xhr.abort()}_initRequest(){const e=this.xhr=new XMLHttpRequest;e.open("POST",this.url,!0),e.responseType="json"}_initListeners(e,t,i){const n=this.xhr,s=this.loader,o=(0,this.t)("Cannot upload file:")+` ${i.name}.`;n.addEventListener("error",(()=>t(o))),n.addEventListener("abort",(()=>t())),n.addEventListener("load",(()=>{const i=n.response;if(!i||!i.uploaded)return t(i&&i.error&&i.error.message?i.error.message:o);e({default:i.url})})),n.upload&&n.upload.addEventListener("progress",(e=>{e.lengthComputable&&(s.uploadTotal=e.total,s.uploaded=e.loaded)}))}_sendRequest(e){const t=new FormData;t.append("upload",e),t.append("ckCsrfToken",Zm()),this.xhr.send(t)}constructor(e,t,i){this.loader=e,this.url=t,this.t=i}}const Ym=["left","right","center","justify"];function Xm(e){return Ym.includes(e)}function eg(e,t){return"rtl"==t.contentLanguageDirection?"right"===e:"left"===e}function tg(e){const t=e.map((e=>{let t;return t="string"==typeof e?{name:e}:e,t})).filter((e=>{const t=Ym.includes(e.name);return t||b("alignment-config-name-not-recognized",{option:e}),t})),i=t.filter((e=>Boolean(e.className))).length;if(i&&i<t.length)throw new p("alignment-config-classnames-are-missing",{configuredOptions:e});return t.forEach(((t,i,n)=>{const s=n.slice(i+1);if(s.some((e=>e.name==t.name)))throw new p("alignment-config-name-already-defined",{option:t,configuredOptions:e});if(t.className){if(s.some((e=>e.className==t.className)))throw new p("alignment-config-classname-already-defined",{option:t,configuredOptions:e})}})),t}const ig="alignment";class ng extends Da{refresh(){const e=this.editor.locale,t=_a(this.editor.model.document.selection.getSelectedBlocks());this.isEnabled=Boolean(t)&&this._canBeAligned(t),this.isEnabled&&t.hasAttribute("alignment")?this.value=t.getAttribute("alignment"):this.value="rtl"===e.contentLanguageDirection?"right":"left"}execute(e={}){const t=this.editor,i=t.locale,n=t.model,s=n.document,o=e.value;n.change((e=>{const t=Array.from(s.selection.getSelectedBlocks()).filter((e=>this._canBeAligned(e))),n=t[0].getAttribute("alignment");eg(o,i)||n===o||!o?function(e,t){for(const i of e)t.removeAttribute(ig,i)}(t,e):function(e,t,i){for(const n of e)t.setAttribute(ig,i,n)}(t,e,o)}))}_canBeAligned(e){return this.editor.model.schema.checkAttribute(e,ig)}}class sg extends Na{static get pluginName(){return"AlignmentEditing"}init(){const e=this.editor,t=e.locale,i=e.model.schema,n=tg(e.config.get("alignment.options")).filter((e=>Xm(e.name)&&!eg(e.name,t))),s=n.some((e=>!!e.className));i.extend("$block",{allowAttributes:"alignment"}),e.model.schema.setAttributeProperties("alignment",{isFormatting:!0}),s?e.conversion.attributeToAttribute(function(e){const t={};for(const i of e)t[i.name]={key:"class",value:i.className};const i={model:{key:"alignment",values:e.map((e=>e.name))},view:t};return i}(n)):e.conversion.for("downcast").attributeToAttribute(function(e){const t={};for(const{name:i}of e)t[i]={key:"style",value:{"text-align":i}};const i={model:{key:"alignment",values:e.map((e=>e.name))},view:t};return i}(n));const o=function(e){const t=[];for(const{name:i}of e)t.push({view:{key:"style",value:{"text-align":i}},model:{key:"alignment",value:i}});return t}(n);for(const t of o)e.conversion.for("upcast").attributeToAttribute(t);const r=function(e){const t=[];for(const{name:i}of e)t.push({view:{key:"align",value:i},model:{key:"alignment",value:i}});return t}(n);for(const t of r)e.conversion.for("upcast").attributeToAttribute(t);e.commands.add("alignment",new ng(e))}constructor(e){super(e),e.config.define("alignment",{options:Ym.map((e=>({name:e})))})}}class og extends va{destroy(){this.map((e=>e.destroy()))}setParent(e){this._parentElement=e;for(const e of this)this._renderViewIntoCollectionParent(e)}delegate(...e){if(!e.length||!e.every((e=>"string"==typeof e)))throw new p("ui-viewcollection-delegate-wrong-events",this);return{to:t=>{for(const i of this)for(const n of e)i.delegate(n).to(t);this.on("add",((i,n)=>{for(const i of e)n.delegate(i).to(t)})),this.on("remove",((i,n)=>{for(const i of e)n.stopDelegating(i,t)}))}}}_renderViewIntoCollectionParent(e,t){e.isRendered||e.render(),e.element&&this._parentElement&&this._parentElement.insertBefore(e.element,this._parentElement.children[t])}remove(e){return super.remove(e)}constructor(e=[]){super(e,{idProperty:"viewUid"}),this.on("add",((e,t,i)=>{this._renderViewIntoCollectionParent(t,i)})),this.on("remove",((e,t)=>{t.element&&this._parentElement&&t.element.remove()})),this._parentElement=null}}class rg extends(T()){render(){const e=this._renderNode({intoFragment:!0});return this._isRendered=!0,e}apply(e){return this._revertData={children:[],bindings:[],attributes:{}},this._renderNode({node:e,intoFragment:!1,isApplying:!0,revertData:this._revertData}),e}revert(e){if(!this._revertData)throw new p("ui-template-revert-not-applied",[this,e]);this._revertTemplateFromNode(e,this._revertData)}*getViews(){yield*function*e(t){if(t.children)for(const i of t.children)kg(i)?yield i:Cg(i)&&(yield*e(i))}(this)}static bind(e,t){return{to:(i,n)=>new lg({eventNameOrFunction:i,attribute:i,observable:e,emitter:t,callback:n}),if:(i,n,s)=>new cg({observable:e,emitter:t,attribute:i,valueIfTrue:n,callback:s})}}static extend(e,t){if(e._isRendered)throw new p("template-extend-render",[this,e]);_g(e,pg(fg(t)))}_renderNode(e){let t;if(t=e.node?this.tag&&this.text:this.tag?this.text:!this.text,t)throw new p("ui-template-wrong-syntax",this);return this.text?this._renderText(e):this._renderElement(e)}_renderElement(e){let t=e.node;return t||(t=e.node=document.createElementNS(this.ns||"http://www.w3.org/1999/xhtml",this.tag)),this._renderAttributes(e),this._renderElementChildren(e),this._setUpListeners(e),t}_renderText(e){let t=e.node;return t?e.revertData.text=t.textContent:t=e.node=document.createTextNode(""),dg(this.text)?this._bindToObservable({schema:this.text,updater:ug(t),data:e}):t.textContent=this.text.join(""),t}_renderAttributes(e){if(!this.attributes)return;const t=e.node,i=e.revertData;for(const n in this.attributes){const s=t.getAttribute(n),o=this.attributes[n];i&&(i.attributes[n]=s);const r=Ag(o)?o[0].ns:null;if(dg(o)){const a=Ag(o)?o[0].value:o;i&&Eg(n)&&a.unshift(s),this._bindToObservable({schema:a,updater:mg(t,n,r),data:e})}else if("style"==n&&"string"!=typeof o[0])this._renderStyleAttribute(o[0],e);else{i&&s&&Eg(n)&&o.unshift(s);const e=o.map((e=>e&&e.value||e)).reduce(((e,t)=>e.concat(t)),[]).reduce(wg,"");yg(e)||t.setAttributeNS(r,n,e)}}}_renderStyleAttribute(e,t){const i=t.node;for(const n in e){const s=e[n];dg(s)?this._bindToObservable({schema:[s],updater:gg(i,n),data:t}):i.style[n]=s}}_renderElementChildren(e){const t=e.node,i=e.intoFragment?document.createDocumentFragment():t,n=e.isApplying;let s=0;for(const o of this.children)if(xg(o)){if(!n){o.setParent(t);for(const e of o)i.appendChild(e.element)}}else if(kg(o))n||(o.isRendered||o.render(),i.appendChild(o.element));else if(mr(o))i.appendChild(o);else if(n){const t={children:[],bindings:[],attributes:{}};e.revertData.children.push(t),o._renderNode({intoFragment:!1,node:i.childNodes[s++],isApplying:!0,revertData:t})}else i.appendChild(o.render());e.intoFragment&&t.appendChild(i)}_setUpListeners(e){if(this.eventListeners)for(const t in this.eventListeners){const i=this.eventListeners[t].map((i=>{const[n,s]=t.split("@");return i.activateDomEventListener(n,s,e)}));e.revertData&&e.revertData.bindings.push(i)}}_bindToObservable({schema:e,updater:t,data:i}){const n=i.revertData;hg(e,t,i);const s=e.filter((e=>!yg(e))).filter((e=>e.observable)).map((n=>n.activateAttributeListener(e,t,i)));n&&n.bindings.push(s)}_revertTemplateFromNode(e,t){for(const e of t.bindings)for(const t of e)t();if(t.text)return void(e.textContent=t.text);const i=e;for(const e in t.attributes){const n=t.attributes[e];null===n?i.removeAttribute(e):i.setAttribute(e,n)}for(let e=0;e<t.children.length;++e)this._revertTemplateFromNode(i.childNodes[e],t.children[e])}constructor(e){super(),Object.assign(this,pg(fg(e))),this._isRendered=!1,this._revertData=null}}class ag{getValue(e){const t=this.observable[this.attribute];return this.callback?this.callback(t,e):t}activateAttributeListener(e,t,i){const n=()=>hg(e,t,i);return this.emitter.listenTo(this.observable,`change:${this.attribute}`,n),()=>{this.emitter.stopListening(this.observable,`change:${this.attribute}`,n)}}constructor(e){this.attribute=e.attribute,this.observable=e.observable,this.emitter=e.emitter,this.callback=e.callback}}class lg extends ag{activateDomEventListener(e,t,i){const n=(e,i)=>{t&&!i.target.matches(t)||("function"==typeof this.eventNameOrFunction?this.eventNameOrFunction(i):this.observable.fire(this.eventNameOrFunction,i))};return this.emitter.listenTo(i.node,e,n),()=>{this.emitter.stopListening(i.node,e,n)}}constructor(e){super(e),this.eventNameOrFunction=e.eventNameOrFunction}}class cg extends ag{getValue(e){return!yg(super.getValue(e))&&(this.valueIfTrue||!0)}constructor(e){super(e),this.valueIfTrue=e.valueIfTrue}}function dg(e){return!!e&&(e.value&&(e=e.value),Array.isArray(e)?e.some(dg):e instanceof ag)}function hg(e,t,{node:i}){const n=function(e,t){return e.map((e=>e instanceof ag?e.getValue(t):e))}(e,i);let s;s=1==e.length&&e[0]instanceof cg?n[0]:n.reduce(wg,""),yg(s)?t.remove():t.set(s)}function ug(e){return{set(t){e.textContent=t},remove(){e.textContent=""}}}function mg(e,t,i){return{set(n){e.setAttributeNS(i,t,n)},remove(){e.removeAttributeNS(i,t)}}}function gg(e,t){return{set(i){e.style[t]=i},remove(){e.style[t]=null}}}function fg(e){return Cs(e,(e=>{if(e&&(e instanceof ag||Cg(e)||kg(e)||xg(e)))return e}))}function pg(e){if("string"==typeof e?e=function(e){return{text:[e]}}(e):e.text&&function(e){e.text=pa(e.text)}(e),e.on&&(e.eventListeners=function(e){for(const t in e)bg(e,t);return e}(e.on),delete e.on),!e.text){e.attributes&&function(e){for(const t in e)e[t].value&&(e[t].value=pa(e[t].value)),bg(e,t)}(e.attributes);const t=[];if(e.children)if(xg(e.children))t.push(e.children);else for(const i of e.children)Cg(i)||kg(i)||mr(i)?t.push(i):t.push(new rg(i));e.children=t}return e}function bg(e,t){e[t]=pa(e[t])}function wg(e,t){return yg(t)?e:yg(e)?t:`${e} ${t}`}function vg(e,t){for(const i in t)e[i]?e[i].push(...t[i]):e[i]=t[i]}function _g(e,t){if(t.attributes&&(e.attributes||(e.attributes={}),vg(e.attributes,t.attributes)),t.eventListeners&&(e.eventListeners||(e.eventListeners={}),vg(e.eventListeners,t.eventListeners)),t.text&&e.text.push(...t.text),t.children&&t.children.length){if(e.children.length!=t.children.length)throw new p("ui-template-extend-children-mismatch",e);let i=0;for(const n of t.children)_g(e.children[i++],n)}}function yg(e){return!e&&0!==e}function kg(e){return e instanceof Tg}function Cg(e){return e instanceof rg}function xg(e){return e instanceof og}function Ag(e){return re(e[0])&&e[0].ns}function Eg(e){return"class"==e||"style"==e}class Tg extends(pr(Yo())){get bindTemplate(){return this._bindTemplate?this._bindTemplate:this._bindTemplate=rg.bind(this,this)}createCollection(e){const t=new og(e);return this._viewCollections.add(t),t}registerChild(e){lr(e)||(e=[e]);for(const t of e)this._unboundChildren.add(t)}deregisterChild(e){lr(e)||(e=[e]);for(const t of e)this._unboundChildren.remove(t)}setTemplate(e){this.template=new rg(e)}extendTemplate(e){rg.extend(this.template,e)}render(){if(this.isRendered)throw new p("ui-view-render-already-rendered",this);this.template&&(this.element=this.template.render(),this.registerChild(this.template.getViews())),this.isRendered=!0}destroy(){this.stopListening(),this._viewCollections.map((e=>e.destroy())),this.template&&this.template._revertData&&this.template.revert(this.element)}constructor(e){super(),this.element=null,this.isRendered=!1,this.locale=e,this.t=e&&e.t,this._viewCollections=new va,this._unboundChildren=this.createCollection(),this._viewCollections.on("add",((t,i)=>{i.locale=e,i.t=e&&e.t})),this.decorate("render")}}function Sg({emitter:e,activator:t,callback:i,contextElements:n}){e.listenTo(document,"mousedown",((e,s)=>{if(!t())return;const o="function"==typeof s.composedPath?s.composedPath():[],r="function"==typeof n?n():n;for(const e of r)if(e.contains(s.target)||o.includes(e))return;i()}))}function Ig(e){const t=e;t.set("_isCssTransitionsDisabled",!1),t.disableCssTransitions=()=>{t._isCssTransitionsDisabled=!0},t.enableCssTransitions=()=>{t._isCssTransitionsDisabled=!1},t.extendTemplate({attributes:{class:[t.bindTemplate.if("_isCssTransitionsDisabled","ck-transitions-disabled")]}})}function Pg(e){return class extends e{disableCssTransitions(){this._isCssTransitionsDisabled=!0}enableCssTransitions(){this._isCssTransitionsDisabled=!1}initializeCssTransitionDisablerMixin(){this.extendTemplate({attributes:{class:[this.bindTemplate.if("_isCssTransitionsDisabled","ck-transitions-disabled")]}})}constructor(...e){super(...e),this.set("_isCssTransitionsDisabled",!1),this.initializeCssTransitionDisablerMixin()}}}function Vg({view:e}){e.listenTo(e.element,"submit",((t,i)=>{i.preventDefault(),e.fire("submit")}),{useCapture:!0})}function Rg({keystrokeHandler:e,focusTracker:t,gridItems:i,numberOfColumns:n,uiLanguageDirection:s}){const o="number"==typeof n?()=>n:n;function r(e){return n=>{const s=i.find((e=>e.element===t.focusedElement)),o=i.getIndex(s),r=e(o,i);i.get(r).focus(),n.stopPropagation(),n.preventDefault()}}function a(e,t){return e===t-1?0:e+1}function l(e,t){return 0===e?t-1:e-1}e.set("arrowright",r(((e,t)=>"rtl"===s?l(e,t.length):a(e,t.length)))),e.set("arrowleft",r(((e,t)=>"rtl"===s?a(e,t.length):l(e,t.length)))),e.set("arrowup",r(((e,t)=>{let i=e-o();return i<0&&(i=e+o()*Math.floor(t.length/o()),i>t.length-1&&(i-=o())),i}))),e.set("arrowdown",r(((e,t)=>{let i=e+o();return i>t.length-1&&(i=e%o()),i})))}class Bg extends Tg{constructor(e){super(e),this.set("text",void 0),this.set("for",void 0),this.id=`ck-editor__label_${u()}`;const t=this.bindTemplate;this.setTemplate({tag:"label",attributes:{class:["ck","ck-label"],id:this.id,for:t.to("for")},children:[{text:t.to("text")}]})}}class Og extends Tg{focus(){this.element.focus()}_createCategories(e){return e.map((e=>{const t=[cr(document,"h3",{},e.label),...Array.from(e.groups.values()).map((e=>this._createGroup(e))).flat()];return e.description&&t.splice(1,0,cr(document,"p",{},e.description)),cr(document,"section",{},t)}))}_createGroup(e){const t=e.keystrokes.sort(((e,t)=>e.label.localeCompare(t.label))).map((e=>this._createGroupRow(e))).flat(),i=[cr(document,"dl",{},t)];return e.label&&i.unshift(cr(document,"h4",{},e.label)),i}_createGroupRow(e){const t=this.locale.t,n=cr(document,"dt"),s=cr(document,"dd"),o=function(e){if("string"==typeof e)return[[e]];if("string"==typeof e[0])return[e];return e}(e.keystroke),r=[];for(const e of o)r.push(e.map(Mg).join(""));return n.innerHTML=e.label,s.innerHTML=r.join(", ")+(e.mayRequireFn&&i.isMac?` ${t("(may require <kbd>Fn</kbd>)")}`:""),[n,s]}constructor(e,t){super(e);const i=e.t,n=new Bg;n.text=i("Help Contents. To close this dialog press ESC."),this.setTemplate({tag:"div",attributes:{class:["ck","ck-accessibility-help-dialog__content"],"aria-labelledby":n.id,role:"document",tabindex:-1},children:[cr(document,"p",{},i("Below, you can find a list of keyboard shortcuts that can be used in the editor.")),...this._createCategories(Array.from(t.values())),n]})}}function Mg(e){return da(e).split("+").map((e=>`<kbd>${e}</kbd>`)).join("+")}var Lg='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M10 6.628a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z"/><path d="M8.5 9.125a.3.3 0 0 0-.253-.296L5.11 8.327a.75.75 0 1 1 .388-1.449l4.04.716c.267.072.624.08.893.009l4.066-.724a.75.75 0 1 1 .388 1.45l-3.132.5a.3.3 0 0 0-.253.296v1.357a.3.3 0 0 0 .018.102l1.615 4.438a.75.75 0 0 1-1.41.513l-1.35-3.71a.3.3 0 0 0-.281-.197h-.209a.3.3 0 0 0-.282.198l-1.35 3.711a.75.75 0 0 1-1.41-.513l1.64-4.509a.3.3 0 0 0 .019-.103V9.125Z"/><path clip-rule="evenodd" d="M10 18.5a8.5 8.5 0 1 1 0-17 8.5 8.5 0 0 1 0 17Zm0 1.5c5.523 0 10-4.477 10-10S15.523 0 10 0 0 4.477 0 10s4.477 10 10 10Z"/></svg>';class Ng extends Na{static get requires(){return[Zp]}static get pluginName(){return"AccessibilityHelp"}init(){const e=this.editor,t=e.locale.t;e.ui.componentFactory.add("accessibilityHelp",(()=>{const e=this._createButton(Hg);return e.set({tooltip:!0,withText:!1,label:t("Accessibility help")}),e})),e.ui.componentFactory.add("menuBar:accessibilityHelp",(()=>{const e=this._createButton(uw);return e.label=t("Accessibility"),e})),e.keystrokes.set("Alt+0",((e,t)=>{this._showDialog(),t()})),this._setupRootLabels()}_createButton(e){const t=new e(this.editor.locale);return t.set({keystroke:"Alt+0",icon:Lg}),t.on("execute",(()=>this._showDialog())),t}_setupRootLabels(){const e=this.editor,t=e.editing.view,i=e.t;function n(e,t){const n=`${t.getAttribute("aria-label")}. ${i("Press %0 for help.",[da("Alt+0")])}`;e.setAttribute("aria-label",n,t)}e.ui.on("ready",(()=>{t.change((e=>{for(const i of t.document.roots)n(e,i)})),e.on("addRoot",((i,s)=>{const o=e.editing.view.document.getRoot(s.rootName);t.change((e=>n(e,o)))}),{priority:"low"})}))}_showDialog(){const e=this.editor,t=e.plugins.get("Dialog"),i=e.locale.t;this.contentView||(this.contentView=new Og(e.locale,e.accessibility.keystrokeInfos)),t.show({id:"accessibilityHelp",className:"ck-accessibility-help-dialog",title:i("Accessibility help"),icon:Lg,hasCloseButton:!0,content:this.contentView})}constructor(...e){super(...e),this.contentView=null}}class Fg extends og{get bodyCollectionContainer(){return this._bodyCollectionContainer}attachToDom(){this._bodyCollectionContainer=new rg({tag:"div",attributes:{class:["ck","ck-reset_all","ck-body","ck-rounded-corners"],dir:this.locale.uiLanguageDirection},children:this}).render();let e=document.querySelector(".ck-body-wrapper");e||(e=cr(document,"div",{class:"ck-body-wrapper"}),document.body.appendChild(e)),e.appendChild(this._bodyCollectionContainer)}detachFromDom(){super.destroy(),this._bodyCollectionContainer&&this._bodyCollectionContainer.remove();const e=document.querySelector(".ck-body-wrapper");e&&0==e.childElementCount&&e.remove()}constructor(e,t=[]){super(t),this.locale=e}}class Dg extends Tg{render(){super.render(),this._updateXMLContent(),this._colorFillPaths(),this.on("change:content",(()=>{this._updateXMLContent(),this._colorFillPaths()})),this.on("change:fillColor",(()=>{this._colorFillPaths()}))}_updateXMLContent(){if(this.content){const e=(new DOMParser).parseFromString(this.content.trim(),"image/svg+xml").querySelector("svg"),t=e.getAttribute("viewBox");t&&(this.viewBox=t);for(const{name:t,value:i}of Array.from(e.attributes))Dg.presentationalAttributeNames.includes(t)&&this.element.setAttribute(t,i);for(;this.element.firstChild;)this.element.removeChild(this.element.firstChild);for(;e.childNodes.length>0;)this.element.appendChild(e.childNodes[0])}}_colorFillPaths(){this.fillColor&&this.element.querySelectorAll(".ck-icon__fill").forEach((e=>{e.style.fill=this.fillColor}))}constructor(){super();const e=this.bindTemplate;this.set("content",""),this.set("viewBox","0 0 20 20"),this.set("fillColor",""),this.set("isColorInherited",!0),this.set("isVisible",!0),this.setTemplate({tag:"svg",ns:"http://www.w3.org/2000/svg",attributes:{class:["ck","ck-icon",e.if("isVisible","ck-hidden",(e=>!e)),"ck-reset_all-excluded",e.if("isColorInherited","ck-icon_inherit-color")],viewBox:e.to("viewBox")}})}}Dg.presentationalAttributeNames=["alignment-baseline","baseline-shift","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-rendering","cursor","direction","display","dominant-baseline","fill","fill-opacity","fill-rule","filter","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","image-rendering","letter-spacing","lighting-color","marker-end","marker-mid","marker-start","mask","opacity","overflow","paint-order","pointer-events","shape-rendering","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-anchor","text-decoration","text-overflow","text-rendering","transform","unicode-bidi","vector-effect","visibility","white-space","word-spacing","writing-mode"];class zg extends Tg{constructor(){super(),this.set({style:void 0,text:void 0,id:void 0});const e=this.bindTemplate;this.setTemplate({tag:"span",attributes:{class:["ck","ck-button__label"],style:e.to("style"),id:e.to("id")},children:[{text:e.to("text")}]})}}class Hg extends Tg{render(){super.render(),this.icon&&(this.iconView.bind("content").to(this,"icon"),this.children.add(this.iconView)),this.children.add(this.labelView),this.withKeystroke&&this.keystroke&&this.children.add(this.keystrokeView)}focus(){this.element.focus()}destroy(){this._focusDelayed&&this._focusDelayed.cancel(),super.destroy()}_setupLabelView(e){return e.bind("text","style","id").to(this,"label","labelStyle","ariaLabelledBy"),e}_createKeystrokeView(){const e=new Tg;return e.setTemplate({tag:"span",attributes:{class:["ck","ck-button__keystroke"]},children:[{text:this.bindTemplate.to("keystroke",(e=>da(e)))}]}),e}_getTooltipString(e,t,i){return e?"string"==typeof e?e:(i&&(i=da(i)),e instanceof Function?e(t,i):`${t}${i?` (${i})`:""}`):""}constructor(e,t=new zg){super(e),this._focusDelayed=null;const n=this.bindTemplate,s=u();this.set("ariaLabel",void 0),this.set("ariaLabelledBy",`ck-editor__aria-label_${s}`),this.set("class",void 0),this.set("labelStyle",void 0),this.set("icon",void 0),this.set("isEnabled",!0),this.set("isOn",!1),this.set("isVisible",!0),this.set("isToggleable",!1),this.set("keystroke",void 0),this.set("label",void 0),this.set("role",void 0),this.set("tabindex",-1),this.set("tooltip",!1),this.set("tooltipPosition","s"),this.set("type","button"),this.set("withText",!1),this.set("withKeystroke",!1),this.children=this.createCollection(),this.labelView=this._setupLabelView(t),this.iconView=new Dg,this.iconView.extendTemplate({attributes:{class:"ck-button__icon"}}),this.keystrokeView=this._createKeystrokeView(),this.bind("_tooltipString").to(this,"tooltip",this,"label",this,"keystroke",this._getTooltipString.bind(this));const o={tag:"button",attributes:{class:["ck","ck-button",n.to("class"),n.if("isEnabled","ck-disabled",(e=>!e)),n.if("isVisible","ck-hidden",(e=>!e)),n.to("isOn",(e=>e?"ck-on":"ck-off")),n.if("withText","ck-button_with-text"),n.if("withKeystroke","ck-button_with-keystroke")],role:n.to("role"),type:n.to("type",(e=>e||"button")),tabindex:n.to("tabindex"),"aria-checked":n.to("ariaChecked"),"aria-label":n.to("ariaLabel"),"aria-labelledby":n.to("ariaLabelledBy"),"aria-disabled":n.if("isEnabled",!0,(e=>!e)),"aria-pressed":n.to("isOn",(e=>!!this.isToggleable&&String(!!e))),"data-cke-tooltip-text":n.to("_tooltipString"),"data-cke-tooltip-position":n.to("tooltipPosition")},children:this.children,on:{click:n.to((e=>{this.isEnabled?this.fire("execute"):e.preventDefault()}))}};i.isSafari&&(this._focusDelayed||(this._focusDelayed=Sa((()=>this.focus()),0)),o.on.mousedown=n.to((()=>{this._focusDelayed()})),o.on.mouseup=n.to((()=>{this._focusDelayed.cancel()}))),this.setTemplate(o)}}class $g extends Hg{render(){super.render(),this.children.add(this.toggleSwitchView)}_createToggleView(){const e=new Tg;return e.setTemplate({tag:"span",attributes:{class:["ck","ck-button__toggle"]},children:[{tag:"span",attributes:{class:["ck","ck-button__toggle__inner"]}}]}),e}constructor(e){super(e),this.isToggleable=!0,this.toggleSwitchView=this._createToggleView(),this.extendTemplate({attributes:{class:"ck-switchbutton"}})}}class Ug extends Hg{render(){super.render(),this.children.add(this._fileInputView)}constructor(e){super(e),this.buttonView=this,this._fileInputView=new Wg(e),this._fileInputView.bind("acceptedType").to(this),this._fileInputView.bind("allowMultipleFiles").to(this),this._fileInputView.delegate("done").to(this),this.on("execute",(()=>{this._fileInputView.open()})),this.extendTemplate({attributes:{class:"ck-file-dialog-button"}})}}class Wg extends Tg{open(){this.element.click()}constructor(e){super(e),this.set("acceptedType",void 0),this.set("allowMultipleFiles",!1);const t=this.bindTemplate;this.setTemplate({tag:"input",attributes:{class:["ck-hidden"],type:"file",tabindex:"-1",accept:t.to("acceptedType"),multiple:t.to("allowMultipleFiles")},on:{change:t.to((()=>{this.element&&this.element.files&&this.element.files.length&&this.fire("done",this.element.files),this.element.value=""}))}})}}var jg='<svg viewBox="0 0 10 10" xmlns="http://www.w3.org/2000/svg"><path d="M.941 4.523a.75.75 0 1 1 1.06-1.06l3.006 3.005 3.005-3.005a.75.75 0 1 1 1.06 1.06l-3.549 3.55a.75.75 0 0 1-1.168-.136L.941 4.523z"/></svg>';class qg extends Tg{render(){super.render(),this._collapsibleAriaLabelUid=this.buttonView.labelView.element.id}focus(){this.buttonView.focus()}_createButtonView(){const e=new Hg(this.locale),t=e.bindTemplate;return e.set({withText:!0,icon:jg}),e.extendTemplate({attributes:{"aria-expanded":t.to("isOn",(e=>String(e)))}}),e.bind("label").to(this),e.bind("isOn").to(this,"isCollapsed",(e=>!e)),e.on("execute",(()=>{this.isCollapsed=!this.isCollapsed})),e}constructor(e,t){super(e);const i=this.bindTemplate;this.set("isCollapsed",!1),this.set("label",""),this.buttonView=this._createButtonView(),this.children=this.createCollection(),this.set("_collapsibleAriaLabelUid",void 0),t&&this.children.addMany(t),this.setTemplate({tag:"div",attributes:{class:["ck","ck-collapsible",i.if("isCollapsed","ck-collapsible_collapsed")]},children:[this.buttonView,{tag:"div",attributes:{class:["ck","ck-collapsible__children"],role:"region",hidden:i.if("isCollapsed","hidden"),"aria-labelledby":i.to("_collapsibleAriaLabelUid")},children:this.children}]})}}function Gg(e,t){const i=e.t,n={Black:i("Black"),"Dim grey":i("Dim grey"),Grey:i("Grey"),"Light grey":i("Light grey"),White:i("White"),Red:i("Red"),Orange:i("Orange"),Yellow:i("Yellow"),"Light green":i("Light green"),Green:i("Green"),Aquamarine:i("Aquamarine"),Turquoise:i("Turquoise"),"Light blue":i("Light blue"),Blue:i("Blue"),Purple:i("Purple")};return t.map((e=>{const t=n[e.label];return t&&t!=e.label&&(e.label=t),e}))}function Kg(e){return e.map(Zg).filter((e=>!!e))}function Zg(e){return"string"==typeof e?{model:e,label:e,hasBorder:!1,view:{name:"span",styles:{color:e}}}:{model:e.color,label:e.label||e.color,hasBorder:void 0!==e.hasBorder&&e.hasBorder,view:{name:"span",styles:{color:`${e.color}`}}}}class Jg extends Hg{render(){super.render(),this.iconView.fillColor="hsl(0, 0%, 100%)"}constructor(e){super(e);const t=this.bindTemplate;this.set("color",void 0),this.set("hasBorder",!1),this.icon='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path class="ck-icon__fill" d="M16.935 5.328a2 2 0 0 1 0 2.829l-7.778 7.778a2 2 0 0 1-2.829 0L3.5 13.107a1.999 1.999 0 1 1 2.828-2.829l.707.707a1 1 0 0 0 1.414 0l5.658-5.657a2 2 0 0 1 2.828 0z"/><path d="M14.814 6.035 8.448 12.4a1 1 0 0 1-1.414 0l-1.413-1.415A1 1 0 1 0 4.207 12.4l2.829 2.829a1 1 0 0 0 1.414 0l7.778-7.778a1 1 0 1 0-1.414-1.415z"/></svg>',this.extendTemplate({attributes:{style:{backgroundColor:t.to("color")},class:["ck","ck-color-grid__tile",t.if("hasBorder","ck-color-selector__color-tile_bordered")]}})}}class Qg extends Tg{focus(){this.items.length&&this.items.first.focus()}focusLast(){this.items.length&&this.items.last.focus()}render(){super.render();for(const e of this.items)this.focusTracker.add(e.element);this.items.on("add",((e,t)=>{this.focusTracker.add(t.element)})),this.items.on("remove",((e,t)=>{this.focusTracker.remove(t.element)})),this.keystrokes.listenTo(this.element),Rg({keystrokeHandler:this.keystrokes,focusTracker:this.focusTracker,gridItems:this.items,numberOfColumns:this.columns,uiLanguageDirection:this.locale&&this.locale.uiLanguageDirection})}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}constructor(e,t){super(e);const i=t&&t.colorDefinitions?t.colorDefinitions:[];this.columns=t&&t.columns?t.columns:5;const n={gridTemplateColumns:`repeat( ${this.columns}, 1fr)`};this.set("selectedColor",void 0),this.items=this.createCollection(),this.focusTracker=new ya,this.keystrokes=new ka,this.items.on("add",((e,t)=>{t.isOn=t.color===this.selectedColor})),i.forEach((e=>{const t=new Jg;t.set({color:e.color,label:e.label,tooltip:!0,hasBorder:e.options.hasBorder}),t.on("execute",(()=>{this.fire("execute",{value:e.color,hasBorder:e.options.hasBorder,label:e.label})})),this.items.add(t)})),this.setTemplate({tag:"div",children:this.items,attributes:{class:["ck","ck-color-grid"],style:n}}),this.on("change:selectedColor",((e,t,i)=>{for(const e of this.items)e.isOn=e.color===i}))}}var Yg={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},Xg={red:0,orange:60,yellow:120,green:180,blue:240,purple:300};function ef(e){var t,i,n=[],s=1;if("string"==typeof e)if(Yg[e])n=Yg[e].slice(),i="rgb";else if("transparent"===e)s=0,i="rgb",n=[0,0,0];else if(/^#[A-Fa-f0-9]+$/.test(e)){var o=e.slice(1);s=1,(l=o.length)<=4?(n=[parseInt(o[0]+o[0],16),parseInt(o[1]+o[1],16),parseInt(o[2]+o[2],16)],4===l&&(s=parseInt(o[3]+o[3],16)/255)):(n=[parseInt(o[0]+o[1],16),parseInt(o[2]+o[3],16),parseInt(o[4]+o[5],16)],8===l&&(s=parseInt(o[6]+o[7],16)/255)),n[0]||(n[0]=0),n[1]||(n[1]=0),n[2]||(n[2]=0),i="rgb"}else if(t=/^((?:rgb|hs[lvb]|hwb|cmyk?|xy[zy]|gray|lab|lchu?v?|[ly]uv|lms)a?)\s*\(([^\)]*)\)/.exec(e)){var r=t[1],a="rgb"===r;i=o=r.replace(/a$/,"");var l="cmyk"===o?4:"gray"===o?1:3;n=t[2].trim().split(/\s*[,\/]\s*|\s+/).map((function(e,t){if(/%$/.test(e))return t===l?parseFloat(e)/100:"rgb"===o?255*parseFloat(e)/100:parseFloat(e);if("h"===o[t]){if(/deg$/.test(e))return parseFloat(e);if(void 0!==Xg[e])return Xg[e]}return parseFloat(e)})),r===o&&n.push(1),s=a||void 0===n[l]?1:n[l],n=n.slice(0,l)}else e.length>10&&/[0-9](?:\s|\/)/.test(e)&&(n=e.match(/([0-9]+)/g).map((function(e){return parseFloat(e)})),i=e.match(/([a-z])/gi).join("").toLowerCase());else isNaN(e)?Array.isArray(e)||e.length?(n=[e[0],e[1],e[2]],i="rgb",s=4===e.length?e[3]:1):e instanceof Object&&(null!=e.r||null!=e.red||null!=e.R?(i="rgb",n=[e.r||e.red||e.R||0,e.g||e.green||e.G||0,e.b||e.blue||e.B||0]):(i="hsl",n=[e.h||e.hue||e.H||0,e.s||e.saturation||e.S||0,e.l||e.lightness||e.L||e.b||e.brightness]),s=e.a||e.alpha||e.opacity||1,null!=e.opacity&&(s/=100)):(i="rgb",n=[e>>>16,(65280&e)>>>8,255&e]);return{space:i,values:n,alpha:s}}const tf=Yg,nf={};for(const e of Object.keys(tf))nf[tf[e]]=e;const sf={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};var of=sf;for(const e of Object.keys(sf)){if(!("channels"in sf[e]))throw new Error("missing channels property: "+e);if(!("labels"in sf[e]))throw new Error("missing channel labels property: "+e);if(sf[e].labels.length!==sf[e].channels)throw new Error("channel and label counts mismatch: "+e);const{channels:t,labels:i}=sf[e];delete sf[e].channels,delete sf[e].labels,Object.defineProperty(sf[e],"channels",{value:t}),Object.defineProperty(sf[e],"labels",{value:i})}function rf(e,t){return(e[0]-t[0])**2+(e[1]-t[1])**2+(e[2]-t[2])**2}sf.rgb.hsl=function(e){const t=e[0]/255,i=e[1]/255,n=e[2]/255,s=Math.min(t,i,n),o=Math.max(t,i,n),r=o-s;let a,l;o===s?a=0:t===o?a=(i-n)/r:i===o?a=2+(n-t)/r:n===o&&(a=4+(t-i)/r),a=Math.min(60*a,360),a<0&&(a+=360);const c=(s+o)/2;return l=o===s?0:c<=.5?r/(o+s):r/(2-o-s),[a,100*l,100*c]},sf.rgb.hsv=function(e){let t,i,n,s,o;const r=e[0]/255,a=e[1]/255,l=e[2]/255,c=Math.max(r,a,l),d=c-Math.min(r,a,l),h=function(e){return(c-e)/6/d+.5};return 0===d?(s=0,o=0):(o=d/c,t=h(r),i=h(a),n=h(l),r===c?s=n-i:a===c?s=1/3+t-n:l===c&&(s=2/3+i-t),s<0?s+=1:s>1&&(s-=1)),[360*s,100*o,100*c]},sf.rgb.hwb=function(e){const t=e[0],i=e[1];let n=e[2];const s=sf.rgb.hsl(e)[0],o=1/255*Math.min(t,Math.min(i,n));return n=1-1/255*Math.max(t,Math.max(i,n)),[s,100*o,100*n]},sf.rgb.cmyk=function(e){const t=e[0]/255,i=e[1]/255,n=e[2]/255,s=Math.min(1-t,1-i,1-n);return[100*((1-t-s)/(1-s)||0),100*((1-i-s)/(1-s)||0),100*((1-n-s)/(1-s)||0),100*s]},sf.rgb.keyword=function(e){const t=nf[e];if(t)return t;let i,n=1/0;for(const t of Object.keys(tf)){const s=rf(e,tf[t]);s<n&&(n=s,i=t)}return i},sf.keyword.rgb=function(e){return tf[e]},sf.rgb.xyz=function(e){let t=e[0]/255,i=e[1]/255,n=e[2]/255;t=t>.04045?((t+.055)/1.055)**2.4:t/12.92,i=i>.04045?((i+.055)/1.055)**2.4:i/12.92,n=n>.04045?((n+.055)/1.055)**2.4:n/12.92;return[100*(.4124*t+.3576*i+.1805*n),100*(.2126*t+.7152*i+.0722*n),100*(.0193*t+.1192*i+.9505*n)]},sf.rgb.lab=function(e){const t=sf.rgb.xyz(e);let i=t[0],n=t[1],s=t[2];i/=95.047,n/=100,s/=108.883,i=i>.008856?i**(1/3):7.787*i+16/116,n=n>.008856?n**(1/3):7.787*n+16/116,s=s>.008856?s**(1/3):7.787*s+16/116;return[116*n-16,500*(i-n),200*(n-s)]},sf.hsl.rgb=function(e){const t=e[0]/360,i=e[1]/100,n=e[2]/100;let s,o,r;if(0===i)return r=255*n,[r,r,r];s=n<.5?n*(1+i):n+i-n*i;const a=2*n-s,l=[0,0,0];for(let e=0;e<3;e++)o=t+1/3*-(e-1),o<0&&o++,o>1&&o--,r=6*o<1?a+6*(s-a)*o:2*o<1?s:3*o<2?a+(s-a)*(2/3-o)*6:a,l[e]=255*r;return l},sf.hsl.hsv=function(e){const t=e[0];let i=e[1]/100,n=e[2]/100,s=i;const o=Math.max(n,.01);n*=2,i*=n<=1?n:2-n,s*=o<=1?o:2-o;return[t,100*(0===n?2*s/(o+s):2*i/(n+i)),100*((n+i)/2)]},sf.hsv.rgb=function(e){const t=e[0]/60,i=e[1]/100;let n=e[2]/100;const s=Math.floor(t)%6,o=t-Math.floor(t),r=255*n*(1-i),a=255*n*(1-i*o),l=255*n*(1-i*(1-o));switch(n*=255,s){case 0:return[n,l,r];case 1:return[a,n,r];case 2:return[r,n,l];case 3:return[r,a,n];case 4:return[l,r,n];case 5:return[n,r,a]}},sf.hsv.hsl=function(e){const t=e[0],i=e[1]/100,n=e[2]/100,s=Math.max(n,.01);let o,r;r=(2-i)*n;const a=(2-i)*s;return o=i*s,o/=a<=1?a:2-a,o=o||0,r/=2,[t,100*o,100*r]},sf.hwb.rgb=function(e){const t=e[0]/360;let i=e[1]/100,n=e[2]/100;const s=i+n;let o;s>1&&(i/=s,n/=s);const r=Math.floor(6*t),a=1-n;o=6*t-r,1&r&&(o=1-o);const l=i+o*(a-i);let c,d,h;switch(r){default:case 6:case 0:c=a,d=l,h=i;break;case 1:c=l,d=a,h=i;break;case 2:c=i,d=a,h=l;break;case 3:c=i,d=l,h=a;break;case 4:c=l,d=i,h=a;break;case 5:c=a,d=i,h=l}return[255*c,255*d,255*h]},sf.cmyk.rgb=function(e){const t=e[0]/100,i=e[1]/100,n=e[2]/100,s=e[3]/100;return[255*(1-Math.min(1,t*(1-s)+s)),255*(1-Math.min(1,i*(1-s)+s)),255*(1-Math.min(1,n*(1-s)+s))]},sf.xyz.rgb=function(e){const t=e[0]/100,i=e[1]/100,n=e[2]/100;let s,o,r;return s=3.2406*t+-1.5372*i+-.4986*n,o=-.9689*t+1.8758*i+.0415*n,r=.0557*t+-.204*i+1.057*n,s=s>.0031308?1.055*s**(1/2.4)-.055:12.92*s,o=o>.0031308?1.055*o**(1/2.4)-.055:12.92*o,r=r>.0031308?1.055*r**(1/2.4)-.055:12.92*r,s=Math.min(Math.max(0,s),1),o=Math.min(Math.max(0,o),1),r=Math.min(Math.max(0,r),1),[255*s,255*o,255*r]},sf.xyz.lab=function(e){let t=e[0],i=e[1],n=e[2];t/=95.047,i/=100,n/=108.883,t=t>.008856?t**(1/3):7.787*t+16/116,i=i>.008856?i**(1/3):7.787*i+16/116,n=n>.008856?n**(1/3):7.787*n+16/116;return[116*i-16,500*(t-i),200*(i-n)]},sf.lab.xyz=function(e){let t,i,n;i=(e[0]+16)/116,t=e[1]/500+i,n=i-e[2]/200;const s=i**3,o=t**3,r=n**3;return i=s>.008856?s:(i-16/116)/7.787,t=o>.008856?o:(t-16/116)/7.787,n=r>.008856?r:(n-16/116)/7.787,t*=95.047,i*=100,n*=108.883,[t,i,n]},sf.lab.lch=function(e){const t=e[0],i=e[1],n=e[2];let s;s=360*Math.atan2(n,i)/2/Math.PI,s<0&&(s+=360);return[t,Math.sqrt(i*i+n*n),s]},sf.lch.lab=function(e){const t=e[0],i=e[1],n=e[2]/360*2*Math.PI;return[t,i*Math.cos(n),i*Math.sin(n)]},sf.rgb.ansi16=function(e,t=null){const[i,n,s]=e;let o=null===t?sf.rgb.hsv(e)[2]:t;if(o=Math.round(o/50),0===o)return 30;let r=30+(Math.round(s/255)<<2|Math.round(n/255)<<1|Math.round(i/255));return 2===o&&(r+=60),r},sf.hsv.ansi16=function(e){return sf.rgb.ansi16(sf.hsv.rgb(e),e[2])},sf.rgb.ansi256=function(e){const t=e[0],i=e[1],n=e[2];if(t===i&&i===n)return t<8?16:t>248?231:Math.round((t-8)/247*24)+232;return 16+36*Math.round(t/255*5)+6*Math.round(i/255*5)+Math.round(n/255*5)},sf.ansi16.rgb=function(e){let t=e%10;if(0===t||7===t)return e>50&&(t+=3.5),t=t/10.5*255,[t,t,t];const i=.5*(1+~~(e>50));return[(1&t)*i*255,(t>>1&1)*i*255,(t>>2&1)*i*255]},sf.ansi256.rgb=function(e){if(e>=232){const t=10*(e-232)+8;return[t,t,t]}let t;e-=16;return[Math.floor(e/36)/5*255,Math.floor((t=e%36)/6)/5*255,t%6/5*255]},sf.rgb.hex=function(e){const t=(((255&Math.round(e[0]))<<16)+((255&Math.round(e[1]))<<8)+(255&Math.round(e[2]))).toString(16).toUpperCase();return"000000".substring(t.length)+t},sf.hex.rgb=function(e){const t=e.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!t)return[0,0,0];let i=t[0];3===t[0].length&&(i=i.split("").map((e=>e+e)).join(""));const n=parseInt(i,16);return[n>>16&255,n>>8&255,255&n]},sf.rgb.hcg=function(e){const t=e[0]/255,i=e[1]/255,n=e[2]/255,s=Math.max(Math.max(t,i),n),o=Math.min(Math.min(t,i),n),r=s-o;let a,l;return a=r<1?o/(1-r):0,l=r<=0?0:s===t?(i-n)/r%6:s===i?2+(n-t)/r:4+(t-i)/r,l/=6,l%=1,[360*l,100*r,100*a]},sf.hsl.hcg=function(e){const t=e[1]/100,i=e[2]/100,n=i<.5?2*t*i:2*t*(1-i);let s=0;return n<1&&(s=(i-.5*n)/(1-n)),[e[0],100*n,100*s]},sf.hsv.hcg=function(e){const t=e[1]/100,i=e[2]/100,n=t*i;let s=0;return n<1&&(s=(i-n)/(1-n)),[e[0],100*n,100*s]},sf.hcg.rgb=function(e){const t=e[0]/360,i=e[1]/100,n=e[2]/100;if(0===i)return[255*n,255*n,255*n];const s=[0,0,0],o=t%1*6,r=o%1,a=1-r;let l=0;switch(Math.floor(o)){case 0:s[0]=1,s[1]=r,s[2]=0;break;case 1:s[0]=a,s[1]=1,s[2]=0;break;case 2:s[0]=0,s[1]=1,s[2]=r;break;case 3:s[0]=0,s[1]=a,s[2]=1;break;case 4:s[0]=r,s[1]=0,s[2]=1;break;default:s[0]=1,s[1]=0,s[2]=a}return l=(1-i)*n,[255*(i*s[0]+l),255*(i*s[1]+l),255*(i*s[2]+l)]},sf.hcg.hsv=function(e){const t=e[1]/100,i=t+e[2]/100*(1-t);let n=0;return i>0&&(n=t/i),[e[0],100*n,100*i]},sf.hcg.hsl=function(e){const t=e[1]/100,i=e[2]/100*(1-t)+.5*t;let n=0;return i>0&&i<.5?n=t/(2*i):i>=.5&&i<1&&(n=t/(2*(1-i))),[e[0],100*n,100*i]},sf.hcg.hwb=function(e){const t=e[1]/100,i=t+e[2]/100*(1-t);return[e[0],100*(i-t),100*(1-i)]},sf.hwb.hcg=function(e){const t=e[1]/100,i=1-e[2]/100,n=i-t;let s=0;return n<1&&(s=(i-n)/(1-n)),[e[0],100*n,100*s]},sf.apple.rgb=function(e){return[e[0]/65535*255,e[1]/65535*255,e[2]/65535*255]},sf.rgb.apple=function(e){return[e[0]/255*65535,e[1]/255*65535,e[2]/255*65535]},sf.gray.rgb=function(e){return[e[0]/100*255,e[0]/100*255,e[0]/100*255]},sf.gray.hsl=function(e){return[0,0,e[0]]},sf.gray.hsv=sf.gray.hsl,sf.gray.hwb=function(e){return[0,100,e[0]]},sf.gray.cmyk=function(e){return[0,0,0,e[0]]},sf.gray.lab=function(e){return[e[0],0,0]},sf.gray.hex=function(e){const t=255&Math.round(e[0]/100*255),i=((t<<16)+(t<<8)+t).toString(16).toUpperCase();return"000000".substring(i.length)+i},sf.rgb.gray=function(e){return[(e[0]+e[1]+e[2])/3/255*100]};const af=of;function lf(e){const t=function(){const e={},t=Object.keys(af);for(let i=t.length,n=0;n<i;n++)e[t[n]]={distance:-1,parent:null};return e}(),i=[e];for(t[e].distance=0;i.length;){const e=i.pop(),n=Object.keys(af[e]);for(let s=n.length,o=0;o<s;o++){const s=n[o],r=t[s];-1===r.distance&&(r.distance=t[e].distance+1,r.parent=e,i.unshift(s))}}return t}function cf(e,t){return function(i){return t(e(i))}}function df(e,t){const i=[t[e].parent,e];let n=af[t[e].parent][e],s=t[e].parent;for(;t[s].parent;)i.unshift(t[s].parent),n=cf(af[t[s].parent][s],n),s=t[s].parent;return n.conversion=i,n}const hf=of,uf=function(e){const t=lf(e),i={},n=Object.keys(t);for(let e=n.length,s=0;s<e;s++){const e=n[s];null!==t[e].parent&&(i[e]=df(e,t))}return i},mf={};Object.keys(hf).forEach((e=>{mf[e]={},Object.defineProperty(mf[e],"channels",{value:hf[e].channels}),Object.defineProperty(mf[e],"labels",{value:hf[e].labels});const t=uf(e);Object.keys(t).forEach((i=>{const n=t[i];mf[e][i]=function(e){const t=function(...t){const i=t[0];if(null==i)return i;i.length>1&&(t=i);const n=e(t);if("object"==typeof n)for(let e=n.length,t=0;t<e;t++)n[t]=Math.round(n[t]);return n};return"conversion"in e&&(t.conversion=e.conversion),t}(n),mf[e][i].raw=function(e){const t=function(...t){const i=t[0];return null==i?i:(i.length>1&&(t=i),e(t))};return"conversion"in e&&(t.conversion=e.conversion),t}(n)}))}));var gf=e({__proto__:null,default:mf},[mf]);function ff(e,t){if(!e)return"";const i=pf(e);if(!i)return"";if(i.space===t)return e;if(n=i,!Object.keys(gf).includes(n.space))return"";var n;const s=gf[i.space][t];if(!s)return"";return function(e,t){switch(t){case"hex":return`#${e}`;case"rgb":return`rgb( ${e[0]}, ${e[1]}, ${e[2]} )`;case"hsl":return`hsl( ${e[0]}, ${e[1]}%, ${e[2]}% )`;case"hwb":return`hwb( ${e[0]}, ${e[1]}, ${e[2]} )`;case"lab":return`lab( ${e[0]}% ${e[1]} ${e[2]} )`;case"lch":return`lch( ${e[0]}% ${e[1]} ${e[2]} )`;default:return""}}(s("hex"===i.space?i.hexValue:i.values),t)}function pf(e){if(e.startsWith("#")){const t=ef(e);return{space:"hex",values:t.values,hexValue:e,alpha:t.alpha}}const t=ef(e);return t.space?t:null}class bf extends Tg{_createLabelView(e){const t=new Bg(this.locale);return t.for=e,t.bind("text").to(this,"label"),t}_createStatusView(e){const t=new Tg(this.locale),i=this.bindTemplate;return t.setTemplate({tag:"div",attributes:{class:["ck","ck-labeled-field-view__status",i.if("errorText","ck-labeled-field-view__status_error"),i.if("_statusText","ck-hidden",(e=>!e))],id:e,role:i.if("errorText","alert")},children:[{text:i.to("_statusText")}]}),t}focus(e){this.fieldView.focus(e)}constructor(e,t){super(e);const i=`ck-labeled-field-view-${u()}`,n=`ck-labeled-field-view-status-${u()}`;this.fieldView=t(this,i,n),this.set("label",void 0),this.set("isEnabled",!0),this.set("isEmpty",!0),this.set("isFocused",!1),this.set("errorText",null),this.set("infoText",null),this.set("class",void 0),this.set("placeholder",void 0),this.labelView=this._createLabelView(i),this.statusView=this._createStatusView(n),this.fieldWrapperChildren=this.createCollection([this.fieldView,this.labelView]),this.bind("_statusText").to(this,"errorText",this,"infoText",((e,t)=>e||t));const s=this.bindTemplate;this.setTemplate({tag:"div",attributes:{class:["ck","ck-labeled-field-view",s.to("class"),s.if("isEnabled","ck-disabled",(e=>!e)),s.if("isEmpty","ck-labeled-field-view_empty"),s.if("isFocused","ck-labeled-field-view_focused"),s.if("placeholder","ck-labeled-field-view_placeholder"),s.if("errorText","ck-error")]},children:[{tag:"div",attributes:{class:["ck","ck-labeled-field-view__input-wrapper"]},children:this.fieldWrapperChildren},this.statusView]})}}class wf extends Tg{render(){super.render(),this.focusTracker.add(this.element),this._setDomElementValue(this.value),this._updateIsEmpty(),this.on("change:value",((e,t,i)=>{this._setDomElementValue(i),this._updateIsEmpty()}))}destroy(){super.destroy(),this.focusTracker.destroy()}select(){this.element.select()}focus(){this.element.focus()}reset(){this.value=this.element.value="",this._updateIsEmpty()}_updateIsEmpty(){this.isEmpty=!this.element.value}_setDomElementValue(e){this.element.value=e||0===e?e:""}constructor(e){super(e),this.set("value",void 0),this.set("id",void 0),this.set("placeholder",void 0),this.set("tabIndex",void 0),this.set("isReadOnly",!1),this.set("hasError",!1),this.set("ariaDescribedById",void 0),this.set("ariaLabel",void 0),this.focusTracker=new ya,this.bind("isFocused").to(this.focusTracker),this.set("isEmpty",!0);const t=this.bindTemplate;this.setTemplate({tag:"input",attributes:{class:["ck","ck-input",t.if("isFocused","ck-input_focused"),t.if("isEmpty","ck-input-text_empty"),t.if("hasError","ck-error")],id:t.to("id"),placeholder:t.to("placeholder"),tabindex:t.to("tabIndex"),readonly:t.to("isReadOnly"),"aria-invalid":t.if("hasError",!0),"aria-describedby":t.to("ariaDescribedById"),"aria-label":t.to("ariaLabel")},on:{input:t.to(((...e)=>{this.fire("input",...e),this._updateIsEmpty()})),change:t.to(this._updateIsEmpty.bind(this))}})}}class vf extends wf{constructor(e){super(e),this.set("inputMode","text");const t=this.bindTemplate;this.extendTemplate({attributes:{inputmode:t.to("inputMode")}})}}class _f extends vf{constructor(e){super(e),this.extendTemplate({attributes:{type:"text",class:["ck-input-text"]}})}}class yf extends vf{constructor(e,{min:t,max:i,step:n}={}){super(e);const s=this.bindTemplate;this.set("min",t),this.set("max",i),this.set("step",n),this.extendTemplate({attributes:{type:"number",class:["ck-input-number"],min:s.to("min"),max:s.to("max"),step:s.to("step")}})}}class kf extends wf{render(){super.render();let e=!1;this.on("input",(()=>{this._updateAutoGrowHeight(!0),this.fire("update")})),this.on("change:value",(()=>{_r.window.requestAnimationFrame((()=>{Hr(this.element)?(this._updateAutoGrowHeight(),this.fire("update")):this._isUpdateAutoGrowHeightPending=!0}))})),this._resizeObserver=new Or(this.element,(t=>{const i=!!t.contentRect.width&&!!t.contentRect.height;!e&&i&&this._isUpdateAutoGrowHeightPending&&_r.window.requestAnimationFrame((()=>{this._updateAutoGrowHeight(),this.fire("update")})),e=i}))}destroy(){this._resizeObserver&&this._resizeObserver.destroy()}reset(){super.reset(),this._updateAutoGrowHeight(),this.fire("update")}_updateAutoGrowHeight(e){const t=this.element;if(!t.offsetParent)return void(this._isUpdateAutoGrowHeightPending=!0);this._isUpdateAutoGrowHeightPending=!1;const i=Cf(t,"1"),n=Cf(t,t.value),s=i.ownerDocument.defaultView.getComputedStyle(i),o=parseFloat(s.paddingTop)+parseFloat(s.paddingBottom),r=xr(i),a=parseFloat(s.lineHeight),l=r.top+r.bottom,c=new Ir(i).height,d=Math.round((n.scrollHeight-o)/a),h=this.maxRows*a+o+l,u=1===d?c:this.minRows*a+o+l;this._height=Math.min(Math.max(Math.max(d,this.minRows)*a+o+l,u),h),e&&(t.scrollTop=t.scrollHeight),i.remove(),n.remove()}_validateMinMaxRows(){if(this.minRows>this.maxRows)throw new p("ui-textarea-view-min-rows-greater-than-max-rows",{textareaView:this,minRows:this.minRows,maxRows:this.maxRows})}constructor(e){super(e),this._isUpdateAutoGrowHeightPending=!1;const t=Lr("px");this.set("minRows",2),this.set("maxRows",5),this.set("_height",null),this.set("resize","none"),this._resizeObserver=null,this.on("change:minRows",this._validateMinMaxRows.bind(this)),this.on("change:maxRows",this._validateMinMaxRows.bind(this));const i=this.bindTemplate;this.template.tag="textarea",this.extendTemplate({attributes:{class:["ck-textarea"],style:{height:i.to("_height",(e=>e?t(e):null)),resize:i.to("resize")},rows:i.to("minRows")}})}}function Cf(e,t){const i=e.cloneNode();return i.style.position="absolute",i.style.top="-99999px",i.style.left="-99999px",i.style.height="auto",i.style.overflow="hidden",i.style.width=e.ownerDocument.defaultView.getComputedStyle(e).width,i.tabIndex=-1,i.rows=1,i.value=t,e.parentNode.insertBefore(i,e),i}class xf extends Tg{focus(){if(this.children.length){const e=this.children.first;"function"==typeof e.focus?e.focus():b("ui-dropdown-panel-focus-child-missing-focus",{childView:this.children.first,dropdownPanel:this})}}focusLast(){if(this.children.length){const e=this.children.last;"function"==typeof e.focusLast?e.focusLast():e.focus()}}constructor(e){super(e);const t=this.bindTemplate;this.set("isVisible",!1),this.set("position","se"),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-reset","ck-dropdown__panel",t.to("position",(e=>`ck-dropdown__panel_${e}`)),t.if("isVisible","ck-dropdown__panel-visible")],tabindex:"-1"},children:this.children,on:{selectstart:t.to((e=>{"input"!==e.target.tagName.toLocaleLowerCase()&&e.preventDefault()}))}})}}class Af extends Tg{render(){super.render(),this.focusTracker.add(this.buttonView.element),this.focusTracker.add(this.panelView.element),this.listenTo(this.buttonView,"open",(()=>{this.isOpen=!this.isOpen})),this.on("change:isOpen",((e,t,i)=>{if(i)if("auto"===this.panelPosition){const e=Af._getOptimalPosition({element:this.panelView.element,target:this.buttonView.element,fitInViewport:!0,positions:this._panelPositions});this.panelView.position=e?e.name:this._panelPositions[0].name}else this.panelView.position=this.panelPosition})),this.keystrokes.listenTo(this.element);const e=(e,t)=>{this.isOpen&&(this.isOpen=!1,t())};this.keystrokes.set("arrowdown",((e,t)=>{this.buttonView.isEnabled&&!this.isOpen&&(this.isOpen=!0,t())})),this.keystrokes.set("arrowright",((e,t)=>{this.isOpen&&t()})),this.keystrokes.set("arrowleft",e),this.keystrokes.set("esc",e)}focus(){this.buttonView.focus()}get _panelPositions(){const{south:e,north:t,southEast:i,southWest:n,northEast:s,northWest:o,southMiddleEast:r,southMiddleWest:a,northMiddleEast:l,northMiddleWest:c}=Af.defaultPanelPositions;return"rtl"!==this.locale.uiLanguageDirection?[i,n,r,a,e,s,o,l,c,t]:[n,i,a,r,e,o,s,c,l,t]}constructor(e,t,i){super(e);const n=this.bindTemplate;this.buttonView=t,this.panelView=i,this.set("isOpen",!1),this.set("isEnabled",!0),this.set("class",void 0),this.set("id",void 0),this.set("panelPosition","auto"),this.panelView.bind("isVisible").to(this,"isOpen"),this.keystrokes=new ka,this.focusTracker=new ya,this.setTemplate({tag:"div",attributes:{class:["ck","ck-dropdown",n.to("class"),n.if("isEnabled","ck-disabled",(e=>!e))],id:n.to("id"),"aria-describedby":n.to("ariaDescribedById")},children:[t,i]}),t.extendTemplate({attributes:{class:["ck-dropdown__button"],"data-cke-tooltip-disabled":n.to("isOpen")}})}}Af.defaultPanelPositions={south:(e,t)=>({top:e.bottom,left:e.left-(t.width-e.width)/2,name:"s"}),southEast:e=>({top:e.bottom,left:e.left,name:"se"}),southWest:(e,t)=>({top:e.bottom,left:e.left-t.width+e.width,name:"sw"}),southMiddleEast:(e,t)=>({top:e.bottom,left:e.left-(t.width-e.width)/4,name:"sme"}),southMiddleWest:(e,t)=>({top:e.bottom,left:e.left-3*(t.width-e.width)/4,name:"smw"}),north:(e,t)=>({top:e.top-t.height,left:e.left-(t.width-e.width)/2,name:"n"}),northEast:(e,t)=>({top:e.top-t.height,left:e.left,name:"ne"}),northWest:(e,t)=>({top:e.top-t.height,left:e.left-t.width+e.width,name:"nw"}),northMiddleEast:(e,t)=>({top:e.top-t.height,left:e.left-(t.width-e.width)/4,name:"nme"}),northMiddleWest:(e,t)=>({top:e.top-t.height,left:e.left-3*(t.width-e.width)/4,name:"nmw"})},Af._getOptimalPosition=$r;class Ef extends Hg{render(){super.render(),this.children.add(this.arrowView)}_createArrowView(){const e=new Dg;return e.content=jg,e.extendTemplate({attributes:{class:"ck-dropdown__arrow"}}),e}constructor(e){super(e),this.arrowView=this._createArrowView(),this.extendTemplate({attributes:{"aria-haspopup":!0,"aria-expanded":this.bindTemplate.to("isOn",(e=>String(e)))}}),this.delegate("execute").to(this,"open")}}class Tf extends(T()){get first(){return this.focusables.find(Sf)||null}get last(){return this.focusables.filter(Sf).slice(-1)[0]||null}get next(){return this._getDomFocusableItem(1)}get previous(){return this._getDomFocusableItem(-1)}get current(){let e=null;return null===this.focusTracker.focusedElement?null:(this.focusables.find(((t,i)=>{const n=t.element===this.focusTracker.focusedElement;return n&&(e=i),n})),e)}focusFirst(){this._focus(this.first,1)}focusLast(){this._focus(this.last,-1)}focusNext(){const e=this.next;e&&this.focusables.getIndex(e)===this.current||e===this.first?this.fire("forwardCycle"):this._focus(e,1)}focusPrevious(){const e=this.previous;e&&this.focusables.getIndex(e)===this.current||e===this.last?this.fire("backwardCycle"):this._focus(e,-1)}_focus(e,t){e&&this.focusTracker.focusedElement!==e.element&&e.focus(t)}_getDomFocusableItem(e){const t=this.focusables.length;if(!t)return null;const i=this.current;if(null===i)return this[1===e?"first":"last"];let n=this.focusables.get(i),s=(i+t+e)%t;do{const i=this.focusables.get(s);if(Sf(i)){n=i;break}s=(s+t+e)%t}while(s!==i);return n}constructor(e){if(super(),this.focusables=e.focusables,this.focusTracker=e.focusTracker,this.keystrokeHandler=e.keystrokeHandler,this.actions=e.actions,e.actions&&e.keystrokeHandler)for(const t in e.actions){let i=e.actions[t];"string"==typeof i&&(i=[i]);for(const n of i)e.keystrokeHandler.set(n,((e,i)=>{this[t](),i()}))}this.on("forwardCycle",(()=>this.focusFirst()),{priority:"low"}),this.on("backwardCycle",(()=>this.focusLast()),{priority:"low"})}}function Sf(e){return If(e)&&Hr(e.element)}function If(e){return!(!("focus"in e)||"function"!=typeof e.focus)}function Pf(e){return If(e)&&"focusCycler"in e&&e.focusCycler instanceof Tf}class Vf extends Tg{constructor(e){super(e),this.setTemplate({tag:"span",attributes:{class:["ck","ck-toolbar__separator"]}})}}class Rf extends Tg{constructor(e){super(e),this.setTemplate({tag:"span",attributes:{class:["ck","ck-toolbar__line-break"]}})}}function Bf(e){if(Array.isArray(e))return{items:e,removeItems:[]};const t={items:[],removeItems:[]};return e?{...t,...e}:t}const Of={alignLeft:Dm.alignLeft,bold:Dm.bold,importExport:Dm.importExport,paragraph:Dm.paragraph,plus:Dm.plus,text:Dm.text,threeVerticalDots:Dm.threeVerticalDots,pilcrow:Dm.pilcrow,dragIndicator:Dm.dragIndicator};class Mf extends Tg{render(){super.render(),this.focusTracker.add(this.element);for(const e of this.items)this.focusTracker.add(e.element);this.items.on("add",((e,t)=>{this.focusTracker.add(t.element)})),this.items.on("remove",((e,t)=>{this.focusTracker.remove(t.element)})),this.keystrokes.listenTo(this.element),this._behavior.render(this)}destroy(){return this._behavior.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy(),super.destroy()}focus(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}fillFromConfig(e,t,i){this.items.addMany(this._buildItemsFromConfig(e,t,i))}_buildItemsFromConfig(e,t,i){const n=Bf(e),s=i||n.removeItems;return this._cleanItemsConfiguration(n.items,t,s).map((e=>re(e)?this._createNestedToolbarDropdown(e,t,s):"|"===e?new Vf:"-"===e?new Rf:t.create(e))).filter((e=>!!e))}_cleanItemsConfiguration(e,t,i){const n=e.filter(((e,n,s)=>"|"===e||-1===i.indexOf(e)&&("-"===e?!this.options.shouldGroupWhenFull||(b("toolbarview-line-break-ignored-when-grouping-items",s),!1):!(!re(e)&&!t.has(e))||(b("toolbarview-item-unavailable",{item:e}),!1))));return this._cleanSeparatorsAndLineBreaks(n)}_cleanSeparatorsAndLineBreaks(e){const t=e=>"-"!==e&&"|"!==e,i=e.length,n=e.findIndex(t);if(-1===n)return[];const s=i-e.slice().reverse().findIndex(t);return e.slice(n,s).filter(((e,i,n)=>{if(t(e))return!0;return!(i>0&&n[i-1]===e)}))}_createNestedToolbarDropdown(e,t,i){let{label:n,icon:s,items:o,tooltip:r=!0,withText:a=!1}=e;if(o=this._cleanItemsConfiguration(o,t,i),!o.length)return null;const l=Wf(this.locale);return n||b("toolbarview-nested-toolbar-dropdown-missing-label",e),l.class="ck-toolbar__nested-toolbar-dropdown",l.buttonView.set({label:n,tooltip:r,withText:!!a}),!1!==s?l.buttonView.icon=Of[s]||s||Dm.threeVerticalDots:l.buttonView.withText=!0,jf(l,(()=>l.toolbarView._buildItemsFromConfig(o,t,i))),l}constructor(e,t){super(e);const i=this.bindTemplate,n=this.t;this.options=t||{},this.set("ariaLabel",n("Editor toolbar")),this.set("maxWidth","auto"),this.items=this.createCollection(),this.focusTracker=new ya,this.keystrokes=new ka,this.set("class",void 0),this.set("isCompact",!1),this.itemsView=new Lf(e),this.children=this.createCollection(),this.children.add(this.itemsView),this.focusables=this.createCollection();const s="rtl"===e.uiLanguageDirection;this._focusCycler=new Tf({focusables:this.focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:[s?"arrowright":"arrowleft","arrowup"],focusNext:[s?"arrowleft":"arrowright","arrowdown"]}});const o=["ck","ck-toolbar",i.to("class"),i.if("isCompact","ck-toolbar_compact")];var r;this.options.shouldGroupWhenFull&&this.options.isFloating&&o.push("ck-toolbar_floating"),this.setTemplate({tag:"div",attributes:{class:o,role:"toolbar","aria-label":i.to("ariaLabel"),style:{maxWidth:i.to("maxWidth")},tabindex:-1},children:this.children,on:{mousedown:(r=this,r.bindTemplate.to((e=>{e.target===r.element&&e.preventDefault()})))}}),this._behavior=this.options.shouldGroupWhenFull?new Ff(this):new Nf(this)}}class Lf extends Tg{constructor(e){super(e),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-toolbar__items"]},children:this.children})}}class Nf{render(){}destroy(){}constructor(e){const t=e.bindTemplate;e.set("isVertical",!1),e.itemsView.children.bindTo(e.items).using((e=>e)),e.focusables.bindTo(e.items).using((e=>If(e)?e:null)),e.extendTemplate({attributes:{class:[t.if("isVertical","ck-toolbar_vertical")]}})}}class Ff{render(e){this.viewElement=e.element,this._enableGroupingOnResize(),this._enableGroupingOnMaxWidthChange(e)}destroy(){this.groupedItemsDropdown.destroy(),this.resizeObserver.destroy()}_updateGrouping(){if(!this.viewElement.ownerDocument.body.contains(this.viewElement))return;if(!Hr(this.viewElement))return void(this.shouldUpdateGroupingOnNextResize=!0);const e=this.groupedItems.length;let t;for(;this._areItemsOverflowing;)this._groupLastItem(),t=!0;if(!t&&this.groupedItems.length){for(;this.groupedItems.length&&!this._areItemsOverflowing;)this._ungroupFirstItem();this._areItemsOverflowing&&this._groupLastItem()}this.groupedItems.length!==e&&this.view.fire("groupedItemsUpdate")}get _areItemsOverflowing(){if(!this.ungroupedItems.length)return!1;const e=this.viewElement,t=this.viewLocale.uiLanguageDirection,i=new Ir(e.lastChild),n=new Ir(e);if(!this.cachedPadding){const i=_r.window.getComputedStyle(e),n="ltr"===t?"paddingRight":"paddingLeft";this.cachedPadding=Number.parseInt(i[n])}return"ltr"===t?i.right>n.right-this.cachedPadding:i.left<n.left+this.cachedPadding}_enableGroupingOnResize(){let e;this.resizeObserver=new Or(this.viewElement,(t=>{e&&e===t.contentRect.width&&!this.shouldUpdateGroupingOnNextResize||(this.shouldUpdateGroupingOnNextResize=!1,this._updateGrouping(),e=t.contentRect.width)})),this._updateGrouping()}_enableGroupingOnMaxWidthChange(e){e.on("change:maxWidth",(()=>{this._updateGrouping()}))}_groupLastItem(){this.groupedItems.length||(this.viewChildren.add(new Vf),this.viewChildren.add(this.groupedItemsDropdown),this.viewFocusTracker.add(this.groupedItemsDropdown.element)),this.groupedItems.add(this.ungroupedItems.remove(this.ungroupedItems.last),0)}_ungroupFirstItem(){this.ungroupedItems.add(this.groupedItems.remove(this.groupedItems.first)),this.groupedItems.length||(this.viewChildren.remove(this.groupedItemsDropdown),this.viewChildren.remove(this.viewChildren.last),this.viewFocusTracker.remove(this.groupedItemsDropdown.element))}_createGroupedItemsDropdown(){const e=this.viewLocale,t=e.t,i=Wf(e);return i.class="ck-toolbar__grouped-dropdown",i.panelPosition="ltr"===e.uiLanguageDirection?"sw":"se",jf(i,this.groupedItems),i.buttonView.set({label:t("Show more items"),tooltip:!0,tooltipPosition:"rtl"===e.uiLanguageDirection?"se":"sw",icon:Dm.threeVerticalDots}),i}_updateFocusCyclableItems(){this.viewFocusables.clear(),this.ungroupedItems.map((e=>{If(e)&&this.viewFocusables.add(e)})),this.groupedItems.length&&this.viewFocusables.add(this.groupedItemsDropdown)}constructor(e){this.resizeObserver=null,this.cachedPadding=null,this.shouldUpdateGroupingOnNextResize=!1,this.view=e,this.viewChildren=e.children,this.viewFocusables=e.focusables,this.viewItemsView=e.itemsView,this.viewFocusTracker=e.focusTracker,this.viewLocale=e.locale,this.ungroupedItems=e.createCollection(),this.groupedItems=e.createCollection(),this.groupedItemsDropdown=this._createGroupedItemsDropdown(),e.itemsView.children.bindTo(this.ungroupedItems).using((e=>e)),this.ungroupedItems.on("change",this._updateFocusCyclableItems.bind(this)),e.children.on("change",this._updateFocusCyclableItems.bind(this)),e.items.on("change",((e,t)=>{const i=t.index,n=Array.from(t.added);for(const e of t.removed)i>=this.ungroupedItems.length?this.groupedItems.remove(e):this.ungroupedItems.remove(e);for(let e=i;e<i+n.length;e++){const t=n[e-i];e>this.ungroupedItems.length?this.groupedItems.add(t,e-this.ungroupedItems.length):this.ungroupedItems.add(t,e)}this._updateGrouping()})),e.extendTemplate({attributes:{class:["ck-toolbar_grouping"]}})}}class Df extends Tg{focus(){this.children.first&&this.children.first.focus()}constructor(e){super(e);const t=this.bindTemplate;this.set("isVisible",!0),this.children=this.createCollection(),this.setTemplate({tag:"li",attributes:{class:["ck","ck-list__item",t.if("isVisible","ck-hidden",(e=>!e))],role:"presentation"},children:this.children})}}class zf extends Tg{constructor(e){super(e),this.setTemplate({tag:"li",attributes:{class:["ck","ck-list__separator"]}})}}class Hf extends Tg{focus(){if(this.items){const e=this.items.find((e=>!(e instanceof zf)));e&&e.focus()}}constructor(e,t=new Bg){super(e);const i=this.bindTemplate,n=new $f(e);this.set({label:"",isVisible:!0}),this.labelView=t,this.labelView.bind("text").to(this,"label"),this.children=this.createCollection(),this.children.addMany([this.labelView,n]),n.set({role:"group",ariaLabelledBy:t.id}),n.focusTracker.destroy(),n.keystrokes.destroy(),this.items=n.items,this.setTemplate({tag:"li",attributes:{role:"presentation",class:["ck","ck-list__group",i.if("isVisible","ck-hidden",(e=>!e))]},children:this.children})}}class $f extends Tg{render(){super.render();for(const e of this.items)e instanceof Hf?this._registerFocusableItemsGroup(e):e instanceof Df&&this._registerFocusableListItem(e);this.items.on("change",((e,t)=>{for(const e of t.removed)e instanceof Hf?this._deregisterFocusableItemsGroup(e):e instanceof Df&&this._deregisterFocusableListItem(e);for(const e of Array.from(t.added).reverse())e instanceof Hf?this._registerFocusableItemsGroup(e,t.index):this._registerFocusableListItem(e,t.index)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}focusFirst(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}_registerFocusableListItem(e,t){this.focusTracker.add(e.element),this.focusables.add(e,t)}_deregisterFocusableListItem(e){this.focusTracker.remove(e.element),this.focusables.remove(e)}_getOnGroupItemsChangeCallback(e){return(t,i)=>{for(const e of i.removed)this._deregisterFocusableListItem(e);for(const t of Array.from(i.added).reverse())this._registerFocusableListItem(t,this.items.getIndex(e)+i.index)}}_registerFocusableItemsGroup(e,t){Array.from(e.items).forEach(((e,i)=>{const n=void 0!==t?t+i:void 0;this._registerFocusableListItem(e,n)}));const i=this._getOnGroupItemsChangeCallback(e);this._listItemGroupToChangeListeners.set(e,i),e.items.on("change",i)}_deregisterFocusableItemsGroup(e){for(const t of e.items)this._deregisterFocusableListItem(t);e.items.off("change",this._listItemGroupToChangeListeners.get(e)),this._listItemGroupToChangeListeners.delete(e)}constructor(e){super(e),this._listItemGroupToChangeListeners=new WeakMap;const t=this.bindTemplate;this.focusables=new og,this.items=this.createCollection(),this.focusTracker=new ya,this.keystrokes=new ka,this._focusCycler=new Tf({focusables:this.focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"arrowup",focusNext:"arrowdown"}}),this.set("ariaLabel",void 0),this.set("ariaLabelledBy",void 0),this.set("role",void 0),this.setTemplate({tag:"ul",attributes:{class:["ck","ck-reset","ck-list"],role:t.to("role"),"aria-label":t.to("ariaLabel"),"aria-labelledby":t.to("ariaLabelledBy")},children:this.items})}}class Uf extends Tg{render(){super.render(),this.children.add(this.actionView),this.children.add(this.arrowView),this.focusTracker.add(this.actionView.element),this.focusTracker.add(this.arrowView.element),this.keystrokes.listenTo(this.element),this.keystrokes.set("arrowright",((e,t)=>{this.focusTracker.focusedElement===this.actionView.element&&(this.arrowView.focus(),t())})),this.keystrokes.set("arrowleft",((e,t)=>{this.focusTracker.focusedElement===this.arrowView.element&&(this.actionView.focus(),t())}))}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this.actionView.focus()}_createActionView(e){const t=e||new Hg;return e||t.bind("icon","isEnabled","isOn","isToggleable","keystroke","label","tabindex","tooltip","tooltipPosition","type","withText").to(this),t.extendTemplate({attributes:{class:"ck-splitbutton__action"}}),t.delegate("execute").to(this),t}_createArrowView(){const e=new Hg,t=e.bindTemplate;return e.icon=jg,e.extendTemplate({attributes:{class:["ck-splitbutton__arrow"],"data-cke-tooltip-disabled":t.to("isOn"),"aria-haspopup":!0,"aria-expanded":t.to("isOn",(e=>String(e)))}}),e.bind("isEnabled").to(this),e.bind("label").to(this),e.bind("tooltip").to(this),e.delegate("execute").to(this,"open"),e}constructor(e,t){super(e);const i=this.bindTemplate;this.set("class",void 0),this.set("labelStyle",void 0),this.set("icon",void 0),this.set("isEnabled",!0),this.set("isOn",!1),this.set("isToggleable",!1),this.set("isVisible",!0),this.set("keystroke",void 0),this.set("withKeystroke",!1),this.set("label",void 0),this.set("tabindex",-1),this.set("tooltip",!1),this.set("tooltipPosition","s"),this.set("type","button"),this.set("withText",!1),this.children=this.createCollection(),this.actionView=this._createActionView(t),this.arrowView=this._createArrowView(),this.keystrokes=new ka,this.focusTracker=new ya,this.setTemplate({tag:"div",attributes:{class:["ck","ck-splitbutton",i.to("class"),i.if("isVisible","ck-hidden",(e=>!e)),this.arrowView.bindTemplate.if("isOn","ck-splitbutton_open")]},children:this.children})}}function Wf(e,t=Ef){const i="function"==typeof t?new t(e):t,n=new xf(e),s=new Af(e,i,n);return i.bind("isEnabled").to(s),i instanceof Uf?i.arrowView.bind("isOn").to(s,"isOpen"):i.bind("isOn").to(s,"isOpen"),function(e){(function(e){e.on("render",(()=>{Sg({emitter:e,activator:()=>e.isOpen,callback:()=>{e.isOpen=!1},contextElements:()=>[e.element,...e.focusTracker._elements]})}))})(e),function(e){e.on("execute",(t=>{t.source instanceof $g||(e.isOpen=!1)}))}(e),function(e){e.focusTracker.on("change:isFocused",((t,i,n)=>{e.isOpen&&!n&&(e.isOpen=!1)}))}(e),function(e){e.keystrokes.set("arrowdown",((t,i)=>{e.isOpen&&(e.panelView.focus(),i())})),e.keystrokes.set("arrowup",((t,i)=>{e.isOpen&&(e.panelView.focusLast(),i())}))}(e),function(e){e.on("change:isOpen",((t,i,n)=>{if(n)return;const s=e.panelView.element;s&&s.contains(_r.document.activeElement)&&e.buttonView.focus()}))}(e),function(e){e.on("change:isOpen",((t,i,n)=>{n&&e.panelView.focus()}),{priority:"low"})}(e)}(s),s}function jf(e,t,i={}){e.extendTemplate({attributes:{class:["ck-toolbar-dropdown"]}}),e.isOpen?qf(e,t,i):e.once("change:isOpen",(()=>qf(e,t,i)),{priority:"highest"}),i.enableActiveItemFocusOnDropdownOpen&&Zf(e,(()=>e.toolbarView.items.find((e=>e.isOn))))}function qf(e,t,i){const n=e.locale,s=n.t,o=e.toolbarView=new Mf(n),r="function"==typeof t?t():t;o.ariaLabel=i.ariaLabel||s("Dropdown toolbar"),i.maxWidth&&(o.maxWidth=i.maxWidth),i.class&&(o.class=i.class),i.isCompact&&(o.isCompact=i.isCompact),i.isVertical&&(o.isVertical=!0),r instanceof og?o.items.bindTo(r).using((e=>e)):o.items.addMany(r),e.panelView.children.add(o),o.items.delegate("execute").to(e)}function Gf(e,t,i={}){e.isOpen?Kf(e,t,i):e.once("change:isOpen",(()=>Kf(e,t,i)),{priority:"highest"}),Zf(e,(()=>e.listView.items.find((e=>e instanceof Df&&e.children.first.isOn))))}function Kf(e,t,i){const n=e.locale,s=e.listView=new $f(n),o="function"==typeof t?t():t;s.ariaLabel=i.ariaLabel,s.role=i.role,Jf(e,s.items,o,n),e.panelView.children.add(s),s.items.delegate("execute").to(e)}function Zf(e,t){e.on("change:isOpen",(()=>{if(!e.isOpen)return;const i=t();i&&("function"==typeof i.focus?i.focus():b("ui-dropdown-focus-child-on-open-child-missing-focus",{view:i}))}),{priority:m.low-10})}function Jf(e,t,i,n){t.bindTo(i).using((t=>{if("separator"===t.type)return new zf(n);if("group"===t.type){const i=new Hf(n);return i.set({label:t.label}),Jf(e,i.items,t.items,n),i.items.delegate("execute").to(e),i}if("button"===t.type||"switchbutton"===t.type){const e=new Df(n);let i;return"button"===t.type?(i=new Hg(n),i.bind("ariaChecked").to(i,"isOn")):i=new $g(n),i.bind(...Object.keys(t.model)).to(t.model),i.delegate("execute").to(e),e.children.add(i),e}return null}))}const Qf=(e,t,i)=>{const n=new _f(e.locale);return n.set({id:t,ariaDescribedById:i}),n.bind("isReadOnly").to(e,"isEnabled",(e=>!e)),n.bind("hasError").to(e,"errorText",(e=>!!e)),n.on("input",(()=>{e.errorText=null})),e.bind("isEmpty","isFocused","placeholder").to(n),n},Yf=(e,t,i)=>{const n=new yf(e.locale);return n.set({id:t,ariaDescribedById:i,inputMode:"numeric"}),n.bind("isReadOnly").to(e,"isEnabled",(e=>!e)),n.bind("hasError").to(e,"errorText",(e=>!!e)),n.on("input",(()=>{e.errorText=null})),e.bind("isEmpty","isFocused","placeholder").to(n),n},Xf=(e,t,i)=>{const n=new kf(e.locale);return n.set({id:t,ariaDescribedById:i}),n.bind("isReadOnly").to(e,"isEnabled",(e=>!e)),n.bind("hasError").to(e,"errorText",(e=>!!e)),n.on("input",(()=>{e.errorText=null})),e.bind("isEmpty","isFocused","placeholder").to(n),n},ep=(e,t,i)=>{const n=Wf(e.locale);return n.set({id:t,ariaDescribedById:i}),n.bind("isEnabled").to(e),n},tp=(e,t=0,i=1)=>e>i?i:e<t?t:e,ip=(e,t=0,i=Math.pow(10,t))=>Math.round(i*e)/i,np=e=>("#"===e[0]&&(e=e.substring(1)),e.length<6?{r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16),a:4===e.length?ip(parseInt(e[3]+e[3],16)/255,2):1}:{r:parseInt(e.substring(0,2),16),g:parseInt(e.substring(2,4),16),b:parseInt(e.substring(4,6),16),a:8===e.length?ip(parseInt(e.substring(6,8),16)/255,2):1}),sp=e=>{const{h:t,s:i,l:n}=(({h:e,s:t,v:i,a:n})=>{const s=(200-t)*i/100;return{h:ip(e),s:ip(s>0&&s<200?t*i/100/(s<=100?s:200-s)*100:0),l:ip(s/2),a:ip(n,2)}})(e);return`hsl(${t}, ${i}%, ${n}%)`},op=({h:e,s:t,v:i,a:n})=>{e=e/360*6,t/=100,i/=100;const s=Math.floor(e),o=i*(1-t),r=i*(1-(e-s)*t),a=i*(1-(1-e+s)*t),l=s%6;return{r:ip(255*[i,r,o,o,a,i][l]),g:ip(255*[a,i,i,r,o,o][l]),b:ip(255*[o,o,a,i,i,r][l]),a:ip(n,2)}},rp=e=>{const t=e.toString(16);return t.length<2?"0"+t:t},ap=({r:e,g:t,b:i,a:n})=>{const s=n<1?rp(ip(255*n)):"";return"#"+rp(e)+rp(t)+rp(i)+s},lp=({r:e,g:t,b:i,a:n})=>{const s=Math.max(e,t,i),o=s-Math.min(e,t,i),r=o?s===e?(t-i)/o:s===t?2+(i-e)/o:4+(e-t)/o:0;return{h:ip(60*(r<0?r+6:r)),s:ip(s?o/s*100:0),v:ip(s/255*100),a:n}},cp=(e,t)=>{if(e===t)return!0;for(const i in e)if(e[i]!==t[i])return!1;return!0},dp={},hp=e=>{let t=dp[e];return t||(t=document.createElement("template"),t.innerHTML=e,dp[e]=t),t},up=(e,t,i)=>{e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:i}))};let mp=!1;const gp=e=>"touches"in e,fp=(e,t)=>{const i=gp(t)?t.touches[0]:t,n=e.el.getBoundingClientRect();up(e.el,"move",e.getMove({x:tp((i.pageX-(n.left+window.pageXOffset))/n.width),y:tp((i.pageY-(n.top+window.pageYOffset))/n.height)}))};class pp{set dragging(e){const t=e?document.addEventListener:document.removeEventListener;t(mp?"touchmove":"mousemove",this),t(mp?"touchend":"mouseup",this)}handleEvent(e){switch(e.type){case"mousedown":case"touchstart":if(e.preventDefault(),!(e=>!(mp&&!gp(e)||(mp||(mp=gp(e)),0)))(e)||!mp&&0!=e.button)return;this.el.focus(),fp(this,e),this.dragging=!0;break;case"mousemove":case"touchmove":e.preventDefault(),fp(this,e);break;case"mouseup":case"touchend":this.dragging=!1;break;case"keydown":((e,t)=>{const i=t.keyCode;i>40||e.xy&&i<37||i<33||(t.preventDefault(),up(e.el,"move",e.getMove({x:39===i?.01:37===i?-.01:34===i?.05:33===i?-.05:35===i?1:36===i?-1:0,y:40===i?.01:38===i?-.01:0},!0)))})(this,e)}}style(e){e.forEach(((e,t)=>{for(const i in e)this.nodes[t].style.setProperty(i,e[i])}))}constructor(e,t,i,n){const s=hp(`<div role="slider" tabindex="0" part="${t}" ${i}><div part="${t}-pointer"></div></div>`);e.appendChild(s.content.cloneNode(!0));const o=e.querySelector(`[part=${t}]`);o.addEventListener("mousedown",this),o.addEventListener("touchstart",this),o.addEventListener("keydown",this),this.el=o,this.xy=n,this.nodes=[o.firstChild,o]}}class bp extends pp{update({h:e}){this.h=e,this.style([{left:e/360*100+"%",color:sp({h:e,s:100,v:100,a:1})}]),this.el.setAttribute("aria-valuenow",`${ip(e)}`)}getMove(e,t){return{h:t?tp(this.h+360*e.x,0,360):360*e.x}}constructor(e){super(e,"hue",'aria-label="Hue" aria-valuemin="0" aria-valuemax="360"',!1)}}class wp extends pp{update(e){this.hsva=e,this.style([{top:100-e.v+"%",left:`${e.s}%`,color:sp(e)},{"background-color":sp({h:e.h,s:100,v:100,a:1})}]),this.el.setAttribute("aria-valuetext",`Saturation ${ip(e.s)}%, Brightness ${ip(e.v)}%`)}getMove(e,t){return{s:t?tp(this.hsva.s+100*e.x,0,100):100*e.x,v:t?tp(this.hsva.v-100*e.y,0,100):Math.round(100-100*e.y)}}constructor(e){super(e,"saturation",'aria-label="Color"',!0)}}const vp=Symbol("same"),_p=Symbol("color"),yp=Symbol("hsva"),kp=Symbol("update"),Cp=Symbol("parts"),xp=Symbol("css"),Ap=Symbol("sliders");class Ep extends HTMLElement{static get observedAttributes(){return["color"]}get[xp](){return[':host{display:flex;flex-direction:column;position:relative;width:200px;height:200px;user-select:none;-webkit-user-select:none;cursor:default}:host([hidden]){display:none!important}[role=slider]{position:relative;touch-action:none;user-select:none;-webkit-user-select:none;outline:0}[role=slider]:last-child{border-radius:0 0 8px 8px}[part$=pointer]{position:absolute;z-index:1;box-sizing:border-box;width:28px;height:28px;display:flex;place-content:center center;transform:translate(-50%,-50%);background-color:#fff;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 4px rgba(0,0,0,.2)}[part$=pointer]::after{content:"";width:100%;height:100%;border-radius:inherit;background-color:currentColor}[role=slider]:focus [part$=pointer]{transform:translate(-50%,-50%) scale(1.1)}',"[part=hue]{flex:0 0 24px;background:linear-gradient(to right,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red 100%)}[part=hue-pointer]{top:50%;z-index:2}","[part=saturation]{flex-grow:1;border-color:transparent;border-bottom:12px solid #000;border-radius:8px 8px 0 0;background-image:linear-gradient(to top,#000,transparent),linear-gradient(to right,#fff,rgba(255,255,255,0));box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}[part=saturation-pointer]{z-index:3}"]}get[Ap](){return[wp,bp]}get color(){return this[_p]}set color(e){if(!this[vp](e)){const t=this.colorModel.toHsva(e);this[kp](t),this[_p]=e}}connectedCallback(){if(this.hasOwnProperty("color")){const e=this.color;delete this.color,this.color=e}else this.color||(this.color=this.colorModel.defaultColor)}attributeChangedCallback(e,t,i){const n=this.colorModel.fromAttr(i);this[vp](n)||(this.color=n)}handleEvent(e){const t=this[yp],i={...t,...e.detail};let n;this[kp](i),cp(i,t)||this[vp](n=this.colorModel.fromHsva(i))||(this[_p]=n,up(this,"color-changed",{value:n}))}[vp](e){return this.color&&this.colorModel.equal(e,this.color)}[kp](e){this[yp]=e,this[Cp].forEach((t=>t.update(e)))}constructor(){super();const e=hp(`<style>${this[xp].join("")}</style>`),t=this.attachShadow({mode:"open"});t.appendChild(e.content.cloneNode(!0)),t.addEventListener("move",this),this[Cp]=this[Ap].map((e=>new e(t)))}}const Tp={defaultColor:"#000",toHsva:e=>lp(np(e)),fromHsva:({h:e,s:t,v:i})=>ap(op({h:e,s:t,v:i,a:1})),equal:(e,t)=>e.toLowerCase()===t.toLowerCase()||cp(np(e),np(t)),fromAttr:e=>e};class Sp extends Ep{get colorModel(){return Tp}}class Ip extends Tg{render(){var e,t;if(super.render(),e="hex-color-picker",t=Sp,void 0===customElements.get(e)&&customElements.define(e,t),this.picker=_r.document.createElement("hex-color-picker"),this.picker.setAttribute("class","hex-color-picker"),this.picker.setAttribute("tabindex","-1"),this._createSlidersView(),this.element){this.hexInputRow.element?this.element.insertBefore(this.picker,this.hexInputRow.element):this.element.appendChild(this.picker);const e=document.createElement("style");e.textContent='[role="slider"]:focus [part$="pointer"] {border: 1px solid #fff;outline: 1px solid var(--ck-color-focus-border);box-shadow: 0 0 0 2px #fff;}',this.picker.shadowRoot.appendChild(e)}this.picker.addEventListener("color-changed",(e=>{const t=e.detail.value;this._debounceColorPickerEvent(t)}))}focus(){if(!this._config.hideInput&&(i.isGecko||i.isiOS||i.isSafari)){this.hexInputRow.children.get(1).focus()}this.slidersView.first.focus()}_createSlidersView(){const e=[...this.picker.shadowRoot.children].filter((e=>"slider"===e.getAttribute("role"))).map((e=>new Vp(e)));this.slidersView=this.createCollection(),e.forEach((e=>{this.slidersView.add(e)}))}_createInputRow(){const e=this._createColorInput();return new Bp(this.locale,e)}_createColorInput(){const e=new bf(this.locale,Qf),{t:t}=this.locale;return e.set({label:t("HEX"),class:"color-picker-hex-input"}),e.fieldView.bind("value").to(this,"_hexColor",(t=>e.isFocused?e.fieldView.value:t.startsWith("#")?t.substring(1):t)),e.fieldView.on("input",(()=>{const t=e.fieldView.element.value;if(t){const e=Op(t);e&&this._debounceColorPickerEvent(e)}})),e}isValid(){const{t:e}=this.locale;return this.resetValidationStatus(),!!this.hexInputRow.getParsedColor()||(this.hexInputRow.inputView.errorText=e('Please enter a valid color (e.g. "ff0000").'),!1)}resetValidationStatus(){this.hexInputRow.inputView.errorText=null}constructor(e,t={}){super(e),this.set({color:"",_hexColor:""}),this.hexInputRow=this._createInputRow();const i=this.createCollection();t.hideInput||i.add(this.hexInputRow),this.setTemplate({tag:"div",attributes:{class:["ck","ck-color-picker"],tabindex:-1},children:i}),this._config=t,this._debounceColorPickerEvent=ko((e=>{this.set("color",e),this.fire("colorSelected",{color:this.color})}),150,{leading:!0}),this.on("set:color",((e,t,i)=>{e.return=ff(i,this._config.format||"hsl")})),this.on("change:color",(()=>{this._hexColor=Pp(this.color)})),this.on("change:_hexColor",(()=>{document.activeElement!==this.picker&&this.picker.setAttribute("color",this._hexColor),Pp(this.color)!=Pp(this._hexColor)&&(this.color=this._hexColor)}))}}function Pp(e){let t=function(e){if(!e)return"";const t=pf(e);return t?"hex"===t.space?t.hexValue:ff(e,"hex"):"#000"}(e);return t||(t="#000"),4===t.length&&(t="#"+[t[1],t[1],t[2],t[2],t[3],t[3]].join("")),t.toLowerCase()}class Vp extends Tg{focus(){this.element.focus()}constructor(e){super(),this.element=e}}class Rp extends Tg{constructor(e){super(e),this.setTemplate({tag:"div",attributes:{class:["ck","ck-color-picker__hash-view"]},children:"#"})}}class Bp extends Tg{getParsedColor(){return Op(this.inputView.fieldView.element.value)}constructor(e,t){super(e),this.inputView=t,this.children=this.createCollection([new Rp,this.inputView]),this.setTemplate({tag:"div",attributes:{class:["ck","ck-color-picker__row"]},children:this.children})}}function Op(e){if(!e)return null;const t=e.trim().replace(/^#/,"");return[3,4,6,8].includes(t.length)&&/^(([0-9a-fA-F]{2}){3,4}|([0-9a-fA-F]){3,4})$/.test(t)?`#${t}`:null}class Mp extends(Yo(va)){add(e,t){return this.find((t=>t.color===e.color))?this:super.add(e,t)}hasColor(e){return!!this.find((t=>t.color===e))}constructor(e){super(e),this.set("isEmpty",!0),this.on("change",(()=>{this.set("isEmpty",0===this.length)}))}}const{eraser:Lp,colorPalette:Np}=Dm;class Fp extends Tg{updateDocumentColors(e,t){const i=e.document,n=this.documentColorsCount;this.documentColors.clear();for(const s of i.getRoots()){const i=e.createRangeIn(s);for(const e of i.getItems())if(e.is("$textProxy")&&e.hasAttribute(t)&&(this._addColorToDocumentColors(e.getAttribute(t)),this.documentColors.length>=n))return}}updateSelectedColors(){const e=this.documentColorsGrid,t=this.staticColorsGrid,i=this.selectedColor;t.selectedColor=i,e&&(e.selectedColor=i)}render(){if(super.render(),this.staticColorsGrid=this._createStaticColorsGrid(),this.items.add(this.staticColorsGrid),this.documentColorsCount){const e=rg.bind(this.documentColors,this.documentColors),t=new Bg(this.locale);t.text=this._documentColorsLabel,t.extendTemplate({attributes:{class:["ck","ck-color-grid__label",e.if("isEmpty","ck-hidden")]}}),this.items.add(t),this.documentColorsGrid=this._createDocumentColorsGrid(),this.items.add(this.documentColorsGrid)}this._createColorPickerButton(),this._addColorSelectorElementsToFocusTracker()}focus(){this.removeColorButtonView.focus()}destroy(){super.destroy()}addColorPickerButton(){this.colorPickerButtonView&&(this.items.add(this.colorPickerButtonView),this.focusTracker.add(this.colorPickerButtonView.element),this._focusables.add(this.colorPickerButtonView))}_addColorSelectorElementsToFocusTracker(){this.focusTracker.add(this.removeColorButtonView.element),this._focusables.add(this.removeColorButtonView),this.staticColorsGrid&&(this.focusTracker.add(this.staticColorsGrid.element),this._focusables.add(this.staticColorsGrid)),this.documentColorsGrid&&(this.focusTracker.add(this.documentColorsGrid.element),this._focusables.add(this.documentColorsGrid))}_createColorPickerButton(){this.colorPickerButtonView=new Hg,this.colorPickerButtonView.set({label:this._colorPickerLabel,withText:!0,icon:Np,class:"ck-color-selector__color-picker"}),this.colorPickerButtonView.on("execute",(()=>{this.fire("colorPicker:show")}))}_createRemoveColorButton(){const e=new Hg;return e.set({withText:!0,icon:Lp,label:this._removeButtonLabel}),e.class="ck-color-selector__remove-color",e.on("execute",(()=>{this.fire("execute",{value:null,source:"removeColorButton"})})),e.render(),e}_createStaticColorsGrid(){const e=new Qg(this.locale,{colorDefinitions:this.colorDefinitions,columns:this.columns});return e.on("execute",((e,t)=>{this.fire("execute",{value:t.value,source:"staticColorsGrid"})})),e}_createDocumentColorsGrid(){const e=rg.bind(this.documentColors,this.documentColors),t=new Qg(this.locale,{columns:this.columns});return t.extendTemplate({attributes:{class:e.if("isEmpty","ck-hidden")}}),t.items.bindTo(this.documentColors).using((e=>{const t=new Jg;return t.set({color:e.color,hasBorder:e.options&&e.options.hasBorder}),e.label&&t.set({label:e.label,tooltip:!0}),t.on("execute",(()=>{this.fire("execute",{value:e.color,source:"documentColorsGrid"})})),t})),this.documentColors.on("change:isEmpty",((e,i,n)=>{n&&(t.selectedColor=null)})),t}_addColorToDocumentColors(e){const t=this.colorDefinitions.find((t=>t.color===e));t?this.documentColors.add(Object.assign({},t)):this.documentColors.add({color:e,label:e,options:{hasBorder:!1}})}constructor(e,{colors:t,columns:i,removeButtonLabel:n,documentColorsLabel:s,documentColorsCount:o,colorPickerLabel:r,focusTracker:a,focusables:l}){super(e);const c=this.bindTemplate;this.set("isVisible",!0),this.focusTracker=a,this.items=this.createCollection(),this.colorDefinitions=t,this.columns=i,this.documentColors=new Mp,this.documentColorsCount=o,this._focusables=l,this._removeButtonLabel=n,this._colorPickerLabel=r,this._documentColorsLabel=s,this.setTemplate({tag:"div",attributes:{class:["ck-color-grids-fragment",c.if("isVisible","ck-hidden",(e=>!e))]},children:this.items}),this.removeColorButtonView=this._createRemoveColorButton(),this.items.add(this.removeColorButtonView)}}class Dp extends Tg{render(){super.render();const e=new Ip(this.locale,{...this._colorPickerViewConfig});this.colorPickerView=e,this.colorPickerView.render(),this.selectedColor&&(e.color=this.selectedColor),this.listenTo(this,"change:selectedColor",((t,i,n)=>{e.color=n})),this.items.add(this.colorPickerView),this.items.add(this.actionBarView),this._addColorPickersElementsToFocusTracker(),this._stopPropagationOnArrowsKeys(),this._executeOnEnterPress(),this._executeUponColorChange()}destroy(){super.destroy()}focus(){this.colorPickerView.focus()}resetValidationStatus(){this.colorPickerView.resetValidationStatus()}_executeOnEnterPress(){this.keystrokes.set("enter",(e=>{this.isVisible&&this.focusTracker.focusedElement!==this.cancelButtonView.element&&this.colorPickerView.isValid()&&(this.fire("execute",{value:this.selectedColor}),e.stopPropagation(),e.preventDefault())}))}_stopPropagationOnArrowsKeys(){const e=e=>e.stopPropagation();this.keystrokes.set("arrowright",e),this.keystrokes.set("arrowleft",e),this.keystrokes.set("arrowup",e),this.keystrokes.set("arrowdown",e)}_addColorPickersElementsToFocusTracker(){for(const e of this.colorPickerView.slidersView)this.focusTracker.add(e.element),this._focusables.add(e);const e=this.colorPickerView.hexInputRow.children.get(1);e.element&&(this.focusTracker.add(e.element),this._focusables.add(e)),this.focusTracker.add(this.saveButtonView.element),this._focusables.add(this.saveButtonView),this.focusTracker.add(this.cancelButtonView.element),this._focusables.add(this.cancelButtonView)}_createActionBarView({saveButtonView:e,cancelButtonView:t}){const i=new Tg,n=this.createCollection();return n.add(e),n.add(t),i.setTemplate({tag:"div",attributes:{class:["ck","ck-color-selector_action-bar"]},children:n}),i}_createActionButtons(){const e=this.locale,t=e.t,i=new Hg(e),n=new Hg(e);return i.set({icon:Dm.check,class:"ck-button-save",type:"button",withText:!1,label:t("Accept")}),n.set({icon:Dm.cancel,class:"ck-button-cancel",type:"button",withText:!1,label:t("Cancel")}),i.on("execute",(()=>{this.colorPickerView.isValid()&&this.fire("execute",{source:"colorPickerSaveButton",value:this.selectedColor})})),n.on("execute",(()=>{this.fire("colorPicker:cancel")})),{saveButtonView:i,cancelButtonView:n}}_executeUponColorChange(){this.colorPickerView.on("colorSelected",((e,t)=>{this.fire("execute",{value:t.color,source:"colorPicker"}),this.set("selectedColor",t.color)}))}constructor(e,{focusTracker:t,focusables:i,keystrokes:n,colorPickerViewConfig:s}){super(e),this.items=this.createCollection(),this.focusTracker=t,this.keystrokes=n,this.set("isVisible",!1),this.set("selectedColor",void 0),this._focusables=i,this._colorPickerViewConfig=s;const o=this.bindTemplate,{saveButtonView:r,cancelButtonView:a}=this._createActionButtons();this.saveButtonView=r,this.cancelButtonView=a,this.actionBarView=this._createActionBarView({saveButtonView:r,cancelButtonView:a}),this.setTemplate({tag:"div",attributes:{class:["ck-color-picker-fragment",o.if("isVisible","ck-hidden",(e=>!e))]},children:this.items})}}class zp extends Tg{render(){super.render(),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}appendUI(){this._appendColorGridsFragment(),this._colorPickerViewConfig&&this._appendColorPickerFragment()}showColorPickerFragment(){this.colorPickerFragmentView.colorPickerView&&!this._isColorPickerFragmentVisible&&(this._isColorPickerFragmentVisible=!0,this.colorPickerFragmentView.focus(),this.colorPickerFragmentView.resetValidationStatus(),this._isColorGridsFragmentVisible=!1)}showColorGridsFragment(){this._isColorGridsFragmentVisible||(this._isColorGridsFragmentVisible=!0,this.colorGridsFragmentView.focus(),this._isColorPickerFragmentVisible=!1)}focus(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}updateDocumentColors(e,t){this.colorGridsFragmentView.updateDocumentColors(e,t)}updateSelectedColors(){this.colorGridsFragmentView.updateSelectedColors()}_appendColorGridsFragment(){this.items.length||(this.items.add(this.colorGridsFragmentView),this.colorGridsFragmentView.delegate("execute").to(this),this.colorGridsFragmentView.delegate("colorPicker:show").to(this))}_appendColorPickerFragment(){2!==this.items.length&&(this.items.add(this.colorPickerFragmentView),this.colorGridsFragmentView.colorPickerButtonView&&this.colorGridsFragmentView.colorPickerButtonView.on("execute",(()=>{this.showColorPickerFragment()})),this.colorGridsFragmentView.addColorPickerButton(),this.colorPickerFragmentView.delegate("execute").to(this),this.colorPickerFragmentView.delegate("colorPicker:cancel").to(this))}constructor(e,{colors:t,columns:i,removeButtonLabel:n,documentColorsLabel:s,documentColorsCount:o,colorPickerLabel:r,colorPickerViewConfig:a}){super(e),this.items=this.createCollection(),this.focusTracker=new ya,this.keystrokes=new ka,this._focusables=new og,this._colorPickerViewConfig=a,this._focusCycler=new Tf({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.colorGridsFragmentView=new Fp(e,{colors:t,columns:i,removeButtonLabel:n,documentColorsLabel:s,documentColorsCount:o,colorPickerLabel:r,focusTracker:this.focusTracker,focusables:this._focusables}),this.colorPickerFragmentView=new Dp(e,{focusables:this._focusables,focusTracker:this.focusTracker,keystrokes:this.keystrokes,colorPickerViewConfig:a}),this.set("_isColorGridsFragmentVisible",!0),this.set("_isColorPickerFragmentVisible",!1),this.set("selectedColor",void 0),this.colorGridsFragmentView.bind("isVisible").to(this,"_isColorGridsFragmentVisible"),this.colorPickerFragmentView.bind("isVisible").to(this,"_isColorPickerFragmentVisible"),this.on("change:selectedColor",((e,t,i)=>{this.colorGridsFragmentView.set("selectedColor",i),this.colorPickerFragmentView.set("selectedColor",i)})),this.colorGridsFragmentView.on("change:selectedColor",((e,t,i)=>{this.set("selectedColor",i)})),this.colorPickerFragmentView.on("change:selectedColor",((e,t,i)=>{this.set("selectedColor",i)})),this.setTemplate({tag:"div",attributes:{class:["ck","ck-color-selector"]},children:this.items})}}class Hp{*names(){for(const e of this._components.values())yield e.originalName}add(e,t){this._components.set($p(e),{callback:t,originalName:e})}create(e){if(!this.has(e))throw new p("componentfactory-item-missing",this,{name:e});return this._components.get($p(e)).callback(this.editor.locale)}has(e){return this._components.has($p(e))}constructor(e){this._components=new Map,this.editor=e}}function $p(e){return String(e).toLowerCase()}class Up extends Tg{constructor(e,t={}){super(e);const i=this.bindTemplate;this.set("label",t.label||""),this.set("class",t.class||null),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-form__header",i.to("class")]},children:this.children}),t.icon&&(this.iconView=new Dg,this.iconView.content=t.icon,this.children.add(this.iconView));const n=new Tg(e);n.setTemplate({tag:"h2",attributes:{class:["ck","ck-form__header__label"],role:"presentation"},children:[{text:i.to("label")}]}),this.children.add(n)}}class Wp extends Tg{render(){super.render(),this.keystrokes.listenTo(this.element)}setButtons(e){for(const t of e){const e=new Hg(this.locale);let i;for(i in e.on("execute",(()=>t.onExecute())),t.onCreate&&t.onCreate(e),t)"onExecute"!=i&&"onCreate"!=i&&e.set(i,t[i]);this.children.add(e)}this._updateFocusCyclableItems()}focus(e){-1===e?this.focusCycler.focusLast():this.focusCycler.focusFirst()}_updateFocusCyclableItems(){Array.from(this.children).forEach((e=>{this._focusables.add(e),this._focusTracker.add(e.element)}))}constructor(e){super(e),this.children=this.createCollection(),this.keystrokes=new ka,this._focusTracker=new ya,this._focusables=new og,this.focusCycler=new Tf({focusables:this._focusables,focusTracker:this._focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-dialog__actions"]},children:this.children})}}class jp extends Tg{reset(){for(;this.children.length;)this.children.remove(0)}constructor(e){super(e),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-dialog__content"]},children:this.children})}}const qp={SCREEN_CENTER:"screen-center",EDITOR_CENTER:"editor-center",EDITOR_TOP_SIDE:"editor-top-side",EDITOR_TOP_CENTER:"editor-top-center",EDITOR_BOTTOM_CENTER:"editor-bottom-center",EDITOR_ABOVE_CENTER:"editor-above-center",EDITOR_BELOW_CENTER:"editor-below-center"},Gp=Lr("px");class Kp extends(function(e){return class extends e{_attachListeners(){this.listenTo(this.element,"mousedown",this._onDragStart.bind(this)),this.listenTo(this.element,"touchstart",this._onDragStart.bind(this))}_attachDragListeners(){this.listenTo(_r.document,"mouseup",this._onDragEndBound),this.listenTo(_r.document,"touchend",this._onDragEndBound),this.listenTo(_r.document,"mousemove",this._onDragBound),this.listenTo(_r.document,"touchmove",this._onDragBound)}_detachDragListeners(){this.stopListening(_r.document,"mouseup",this._onDragEndBound),this.stopListening(_r.document,"touchend",this._onDragEndBound),this.stopListening(_r.document,"mousemove",this._onDragBound),this.stopListening(_r.document,"touchmove",this._onDragBound)}_onDragStart(e,t){if(!this._isHandleElementPressed(t))return;this._attachDragListeners();let i=0,n=0;t instanceof MouseEvent?(i=t.clientX,n=t.clientY):(i=t.touches[0].clientX,n=t.touches[0].clientY),this._lastDraggingCoordinates={x:i,y:n},this.isDragging=!0}_onDrag(e,t){if(!this.isDragging)return void this._detachDragListeners();let i=0,n=0;t instanceof MouseEvent?(i=t.clientX,n=t.clientY):(i=t.touches[0].clientX,n=t.touches[0].clientY),t.preventDefault(),this.fire("drag",{deltaX:Math.round(i-this._lastDraggingCoordinates.x),deltaY:Math.round(n-this._lastDraggingCoordinates.y)}),this._lastDraggingCoordinates={x:i,y:n}}_onDragEnd(){this._detachDragListeners(),this.isDragging=!1}_isHandleElementPressed(e){return!!this.dragHandleElement&&(this.dragHandleElement===e.target||e.target instanceof HTMLElement&&this.dragHandleElement.contains(e.target))}constructor(...e){super(...e),this._onDragBound=this._onDrag.bind(this),this._onDragEndBound=this._onDragEnd.bind(this),this._lastDraggingCoordinates={x:0,y:0},this.on("render",(()=>{this._attachListeners()})),this.set("isDragging",!1)}}}(Tg)){render(){super.render(),this.keystrokes.set("Esc",((e,t)=>{this.fire("close",{source:"escKeyPress"}),t()})),this.on("drag",((e,{deltaX:t,deltaY:i})=>{this.wasMoved=!0,this.moveBy(t,i)})),this.listenTo(_r.window,"resize",(()=>{this._isVisible&&!this.wasMoved&&this.updatePosition()})),this.listenTo(_r.document,"scroll",(()=>{this._isVisible&&!this.wasMoved&&this.updatePosition()})),this.on("change:_isVisible",((e,t,i)=>{i&&(this._isTransparent=!0,setTimeout((()=>{this.updatePosition(),this._isTransparent=!1,this.focus()}),10))})),this.keystrokes.listenTo(this.element)}get dragHandleElement(){return this.headerView?this.headerView.element:null}setupParts({icon:e,title:t,hasCloseButton:i=!0,content:n,actionButtons:s}){t&&(this.headerView=new Up(this.locale,{icon:e}),i&&(this.closeButtonView=this._createCloseButton(),this.headerView.children.add(this.closeButtonView)),this.headerView.label=t,this.ariaLabel=t,this.parts.add(this.headerView,0)),n&&(n instanceof Tg&&(n=[n]),this.contentView=new jp(this.locale),this.contentView.children.addMany(n),this.parts.add(this.contentView)),s&&(this.actionsView=new Wp(this.locale),this.actionsView.setButtons(s),this.parts.add(this.actionsView)),this._updateFocusCyclableItems()}focus(){this._focusCycler.focusFirst()}moveTo(e,t){const i=this._getViewportRect(),n=this._getDialogRect();e+n.width>i.right&&(e=i.right-n.width),e<i.left&&(e=i.left),t<i.top&&(t=i.top),this._moveTo(e,t)}_moveTo(e,t){this._left=e,this._top=t}moveBy(e,t){this.moveTo(this._left+e,this._top+t)}_moveOffScreen(){this._moveTo(-9999,-9999)}updatePosition(){if(!this.element||!this.element.parentNode)return;const e=this._getViewportRect();let t,i=this.position;this._getCurrentDomRoot()?t=this._getVisibleDomRootRect(e):i=qp.SCREEN_CENTER;const n=Kp.defaultOffset,s=this._getDialogRect();switch(i){case qp.EDITOR_TOP_SIDE:if(t){const e="ltr"===this.locale.contentLanguageDirection?t.right-s.width-n:t.left+n;this.moveTo(e,t.top+n)}else this._moveOffScreen();break;case qp.EDITOR_CENTER:t?this.moveTo(Math.round(t.left+t.width/2-s.width/2),Math.round(t.top+t.height/2-s.height/2)):this._moveOffScreen();break;case qp.SCREEN_CENTER:this.moveTo(Math.round((e.width-s.width)/2),Math.round((e.height-s.height)/2));break;case qp.EDITOR_TOP_CENTER:t?this.moveTo(Math.round(t.left+t.width/2-s.width/2),t.top+n):this._moveOffScreen();break;case qp.EDITOR_BOTTOM_CENTER:t?this.moveTo(Math.round(t.left+t.width/2-s.width/2),t.bottom-s.height-n):this._moveOffScreen();break;case qp.EDITOR_ABOVE_CENTER:t?this.moveTo(Math.round(t.left+t.width/2-s.width/2),t.top-s.height-n):this._moveOffScreen();break;case qp.EDITOR_BELOW_CENTER:t?this.moveTo(Math.round(t.left+t.width/2-s.width/2),t.bottom+n):this._moveOffScreen()}}_getVisibleDomRootRect(e){let t=new Ir(this._getCurrentDomRoot()).getVisible();return t?(t=e.getIntersection(t),t||null):null}_getDialogRect(){return new Ir(this.element.firstElementChild)}_getViewportRect(){return function(e){e=Object.assign({top:0,bottom:0,left:0,right:0},e);const t=new Ir(_r.window);return t.top+=e.top,t.height-=e.top,t.bottom-=e.bottom,t.height-=e.bottom,t.left+=e.left,t.right-=e.right,t.width-=e.left+e.right,t}(this._getViewportOffset())}_updateFocusCyclableItems(){const e=[];if(this.contentView)for(const t of this.contentView.children)If(t)&&e.push(t);this.actionsView&&e.push(this.actionsView),this.closeButtonView&&e.push(this.closeButtonView),e.forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element),Pf(e)&&(this.listenTo(e.focusCycler,"forwardCycle",(e=>{this._focusCycler.focusNext(),this._focusCycler.next!==this._focusCycler.focusables.get(this._focusCycler.current)&&e.stop()})),this.listenTo(e.focusCycler,"backwardCycle",(e=>{this._focusCycler.focusPrevious(),this._focusCycler.previous!==this._focusCycler.focusables.get(this._focusCycler.current)&&e.stop()})))}))}_createCloseButton(){const e=new Hg(this.locale),t=this.locale.t;return e.set({label:t("Close"),tooltip:!0,icon:Dm.cancel}),e.on("execute",(()=>this.fire("close",{source:"closeButton"}))),e}constructor(e,{getCurrentDomRoot:t,getViewportOffset:i}){super(e),this.wasMoved=!1;const n=this.bindTemplate,s=e.t;this.set("className",""),this.set("ariaLabel",s("Editor dialog")),this.set("isModal",!1),this.set("position",qp.SCREEN_CENTER),this.set("_isVisible",!1),this.set("_isTransparent",!1),this.set("_top",0),this.set("_left",0),this._getCurrentDomRoot=t,this._getViewportOffset=i,this.decorate("moveTo"),this.parts=this.createCollection(),this.keystrokes=new ka,this.focusTracker=new ya,this._focusables=new og,this._focusCycler=new Tf({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-dialog-overlay",n.if("isModal","ck-dialog-overlay__transparent",(e=>!e)),n.if("_isVisible","ck-hidden",(e=>!e))],tabindex:"-1"},children:[{tag:"div",attributes:{tabindex:"-1",class:["ck","ck-dialog",n.to("className")],role:"dialog","aria-label":n.to("ariaLabel"),style:{top:n.to("_top",(e=>Gp(e))),left:n.to("_left",(e=>Gp(e))),visibility:n.if("_isTransparent","hidden")}},children:this.parts}]})}}Kp.defaultOffset=15;class Zp extends Na{static get pluginName(){return"Dialog"}_initShowHideListeners(){this.on("show",((e,t)=>{this._show(t)})),this.on("show",((e,t)=>{t.onShow&&t.onShow(this)}),{priority:"low"}),this.on("hide",(()=>{Zp._visibleDialogPlugin&&Zp._visibleDialogPlugin._hide()})),this.on("hide",(()=>{this._onHide&&(this._onHide(this),this._onHide=void 0)}),{priority:"low"})}_initFocusToggler(){const e=this.editor;e.keystrokes.set("Ctrl+F6",((t,i)=>{this.isOpen&&!this.view.isModal&&(this.view.focusTracker.isFocused?e.editing.view.focus():this.view.focus(),i())}))}_initMultiRootIntegration(){const e=this.editor.model;e.document.on("change:data",(()=>{if(!this.view)return;const t=e.document.differ.getChangedRoots();for(const e of t)e.state&&this.view.updatePosition()}))}show(e){this.hide(),this.fire(`show:${e.id}`,e)}_show({id:e,icon:t,title:i,hasCloseButton:n=!0,content:s,actionButtons:o,className:r,isModal:a,position:l,onHide:c}){const d=this.editor;this.view=new Kp(d.locale,{getCurrentDomRoot:()=>d.editing.view.getDomRoot(d.model.document.selection.anchor.root.rootName),getViewportOffset:()=>d.ui.viewportOffset});const h=this.view;h.on("close",(()=>{this.hide()})),d.ui.view.body.add(h),d.ui.focusTracker.add(h.element),d.keystrokes.listenTo(h.element),l||(l=a?qp.SCREEN_CENTER:qp.EDITOR_CENTER),h.set({position:l,_isVisible:!0,className:r,isModal:a}),h.setupParts({icon:t,title:i,hasCloseButton:n,content:s,actionButtons:o}),this.id=e,c&&(this._onHide=c),this.isOpen=!0,Zp._visibleDialogPlugin=this}hide(){Zp._visibleDialogPlugin&&Zp._visibleDialogPlugin.fire(`hide:${Zp._visibleDialogPlugin.id}`)}_hide(){if(!this.view)return;const e=this.editor,t=this.view;t.contentView&&t.contentView.reset(),e.ui.view.body.remove(t),e.ui.focusTracker.remove(t.element),e.keystrokes.stopListening(t.element),t.destroy(),e.editing.view.focus(),this.id=null,this.isOpen=!1,Zp._visibleDialogPlugin=null}constructor(e){super(e);const t=e.t;this._initShowHideListeners(),this._initFocusToggler(),this._initMultiRootIntegration(),this.set("id",null),e.accessibility.addKeystrokeInfos({categoryId:"navigation",keystrokes:[{label:t("Move focus in and out of an active dialog window"),keystroke:"Ctrl+F6",mayRequireFn:!0}]})}}const Jp=Lr("px"),Qp=_r.document.body,Yp={top:-99999,left:-99999,name:"arrowless",config:{withArrow:!1}};class Xp extends Tg{show(){this.isVisible=!0}hide(){this.isVisible=!1}attachTo(e){this.show();const t=Xp.defaultPositions,i=Object.assign({},{element:this.element,positions:[t.southArrowNorth,t.southArrowNorthMiddleWest,t.southArrowNorthMiddleEast,t.southArrowNorthWest,t.southArrowNorthEast,t.northArrowSouth,t.northArrowSouthMiddleWest,t.northArrowSouthMiddleEast,t.northArrowSouthWest,t.northArrowSouthEast,t.viewportStickyNorth],limiter:Qp,fitInViewport:!0},e),n=Xp._getOptimalPosition(i)||Yp,s=parseInt(n.left),o=parseInt(n.top),r=n.name,a=n.config||{},{withArrow:l=!0}=a;this.top=o,this.left=s,this.position=r,this.withArrow=l}pin(e){this.unpin(),this._pinWhenIsVisibleCallback=()=>{this.isVisible?this._startPinning(e):this._stopPinning()},this._startPinning(e),this.listenTo(this,"change:isVisible",this._pinWhenIsVisibleCallback)}unpin(){this._pinWhenIsVisibleCallback&&(this._stopPinning(),this.stopListening(this,"change:isVisible",this._pinWhenIsVisibleCallback),this._pinWhenIsVisibleCallback=null,this.hide())}_startPinning(e){this.attachTo(e);const t=eb(e.target),i=e.limiter?eb(e.limiter):Qp;this.listenTo(_r.document,"scroll",((n,s)=>{const o=s.target,r=t&&o.contains(t),a=i&&o.contains(i);!r&&!a&&t&&i||this.attachTo(e)}),{useCapture:!0}),this.listenTo(_r.window,"resize",(()=>{this.attachTo(e)}))}_stopPinning(){this.stopListening(_r.document,"scroll"),this.stopListening(_r.window,"resize")}constructor(e){super(e);const t=this.bindTemplate;this.set("top",0),this.set("left",0),this.set("position","arrow_nw"),this.set("isVisible",!1),this.set("withArrow",!0),this.set("class",void 0),this._pinWhenIsVisibleCallback=null,this.content=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-balloon-panel",t.to("position",(e=>`ck-balloon-panel_${e}`)),t.if("isVisible","ck-balloon-panel_visible"),t.if("withArrow","ck-balloon-panel_with-arrow"),t.to("class")],style:{top:t.to("top",Jp),left:t.to("left",Jp)}},children:this.content})}}function eb(e){return Fo(e)?e:Er(e)?e.commonAncestorContainer:"function"==typeof e?eb(e()):null}function tb(e={}){const{sideOffset:t=Xp.arrowSideOffset,heightOffset:i=Xp.arrowHeightOffset,stickyVerticalOffset:n=Xp.stickyVerticalOffset,config:s}=e;return{northWestArrowSouthWest:(e,i)=>({top:o(e,i),left:e.left-t,name:"arrow_sw",...s&&{config:s}}),northWestArrowSouthMiddleWest:(e,i)=>({top:o(e,i),left:e.left-.25*i.width-t,name:"arrow_smw",...s&&{config:s}}),northWestArrowSouth:(e,t)=>({top:o(e,t),left:e.left-t.width/2,name:"arrow_s",...s&&{config:s}}),northWestArrowSouthMiddleEast:(e,i)=>({top:o(e,i),left:e.left-.75*i.width+t,name:"arrow_sme",...s&&{config:s}}),northWestArrowSouthEast:(e,i)=>({top:o(e,i),left:e.left-i.width+t,name:"arrow_se",...s&&{config:s}}),northArrowSouthWest:(e,i)=>({top:o(e,i),left:e.left+e.width/2-t,name:"arrow_sw",...s&&{config:s}}),northArrowSouthMiddleWest:(e,i)=>({top:o(e,i),left:e.left+e.width/2-.25*i.width-t,name:"arrow_smw",...s&&{config:s}}),northArrowSouth:(e,t)=>({top:o(e,t),left:e.left+e.width/2-t.width/2,name:"arrow_s",...s&&{config:s}}),northArrowSouthMiddleEast:(e,i)=>({top:o(e,i),left:e.left+e.width/2-.75*i.width+t,name:"arrow_sme",...s&&{config:s}}),northArrowSouthEast:(e,i)=>({top:o(e,i),left:e.left+e.width/2-i.width+t,name:"arrow_se",...s&&{config:s}}),northEastArrowSouthWest:(e,i)=>({top:o(e,i),left:e.right-t,name:"arrow_sw",...s&&{config:s}}),northEastArrowSouthMiddleWest:(e,i)=>({top:o(e,i),left:e.right-.25*i.width-t,name:"arrow_smw",...s&&{config:s}}),northEastArrowSouth:(e,t)=>({top:o(e,t),left:e.right-t.width/2,name:"arrow_s",...s&&{config:s}}),northEastArrowSouthMiddleEast:(e,i)=>({top:o(e,i),left:e.right-.75*i.width+t,name:"arrow_sme",...s&&{config:s}}),northEastArrowSouthEast:(e,i)=>({top:o(e,i),left:e.right-i.width+t,name:"arrow_se",...s&&{config:s}}),southWestArrowNorthWest:e=>({top:r(e),left:e.left-t,name:"arrow_nw",...s&&{config:s}}),southWestArrowNorthMiddleWest:(e,i)=>({top:r(e),left:e.left-.25*i.width-t,name:"arrow_nmw",...s&&{config:s}}),southWestArrowNorth:(e,t)=>({top:r(e),left:e.left-t.width/2,name:"arrow_n",...s&&{config:s}}),southWestArrowNorthMiddleEast:(e,i)=>({top:r(e),left:e.left-.75*i.width+t,name:"arrow_nme",...s&&{config:s}}),southWestArrowNorthEast:(e,i)=>({top:r(e),left:e.left-i.width+t,name:"arrow_ne",...s&&{config:s}}),southArrowNorthWest:e=>({top:r(e),left:e.left+e.width/2-t,name:"arrow_nw",...s&&{config:s}}),southArrowNorthMiddleWest:(e,i)=>({top:r(e),left:e.left+e.width/2-.25*i.width-t,name:"arrow_nmw",...s&&{config:s}}),southArrowNorth:(e,t)=>({top:r(e),left:e.left+e.width/2-t.width/2,name:"arrow_n",...s&&{config:s}}),southArrowNorthMiddleEast:(e,i)=>({top:r(e),left:e.left+e.width/2-.75*i.width+t,name:"arrow_nme",...s&&{config:s}}),southArrowNorthEast:(e,i)=>({top:r(e),left:e.left+e.width/2-i.width+t,name:"arrow_ne",...s&&{config:s}}),southEastArrowNorthWest:e=>({top:r(e),left:e.right-t,name:"arrow_nw",...s&&{config:s}}),southEastArrowNorthMiddleWest:(e,i)=>({top:r(e),left:e.right-.25*i.width-t,name:"arrow_nmw",...s&&{config:s}}),southEastArrowNorth:(e,t)=>({top:r(e),left:e.right-t.width/2,name:"arrow_n",...s&&{config:s}}),southEastArrowNorthMiddleEast:(e,i)=>({top:r(e),left:e.right-.75*i.width+t,name:"arrow_nme",...s&&{config:s}}),southEastArrowNorthEast:(e,i)=>({top:r(e),left:e.right-i.width+t,name:"arrow_ne",...s&&{config:s}}),westArrowEast:(e,t)=>({top:e.top+e.height/2-t.height/2,left:e.left-t.width-i,name:"arrow_e",...s&&{config:s}}),eastArrowWest:(e,t)=>({top:e.top+e.height/2-t.height/2,left:e.right+i,name:"arrow_w",...s&&{config:s}}),viewportStickyNorth:(e,t,i,o)=>{const r=o||i;return e.getIntersection(r)?r.height-e.height>n?null:{top:r.top+n,left:e.left+e.width/2-t.width/2,name:"arrowless",config:{withArrow:!1,...s}}:null}};function o(e,t){return e.top-t.height-i}function r(e){return e.bottom+i}}Xp.arrowSideOffset=25,Xp.arrowHeightOffset=10,Xp.stickyVerticalOffset=20,Xp._getOptimalPosition=$r,Xp.defaultPositions=tb();const ib="ck-tooltip";class nb extends(pr()){destroy(e){const t=e.ui.view&&e.ui.view.body;nb._editors.delete(e),this.stopListening(e.ui),t&&t.has(this.balloonPanelView)&&t.remove(this.balloonPanelView),nb._editors.size||(this._unpinTooltip(),this.balloonPanelView.destroy(),this.stopListening(),nb._instance=null)}static getPositioningFunctions(e){const t=nb.defaultBalloonPositions;return{s:[t.southArrowNorth,t.southArrowNorthEast,t.southArrowNorthWest],n:[t.northArrowSouth],e:[t.eastArrowWest],w:[t.westArrowEast],sw:[t.southArrowNorthEast],se:[t.southArrowNorthWest]}[e]}_onKeyDown(e,t){"Escape"===t.key&&this._currentElementWithTooltip&&(this._unpinTooltip(),t.stopPropagation())}_onEnterOrFocus(e,{target:t}){const i=sb(t);i?i!==this._currentElementWithTooltip&&(this._unpinTooltip(),this._pinTooltipDebounced(i,ob(i))):"focus"===e.name&&this._unpinTooltip()}_onLeaveOrBlur(e,{target:t,relatedTarget:i}){if("mouseleave"===e.name){if(!Fo(t))return;const e=this.balloonPanelView.element,n=e&&(e===i||e.contains(i)),s=!n&&t===e;if(n)return void this._unpinTooltipDebounced.cancel();if(!s&&this._currentElementWithTooltip&&t!==this._currentElementWithTooltip)return;const o=sb(t),r=sb(i);(s||o&&o!==r)&&this._unpinTooltipDebounced()}else{if(this._currentElementWithTooltip&&t!==this._currentElementWithTooltip)return;this._unpinTooltipDebounced()}}_onScroll(e,{target:t}){this._currentElementWithTooltip&&(t.contains(this.balloonPanelView.element)&&t.contains(this._currentElementWithTooltip)||this._unpinTooltip())}_pinTooltip(e,{text:t,position:i,cssClass:n}){this._unpinTooltip();const s=_a(nb._editors.values()).ui.view.body;s.has(this.balloonPanelView)||s.add(this.balloonPanelView),this.tooltipTextView.text=t,this.balloonPanelView.pin({target:e,positions:nb.getPositioningFunctions(i)}),this._resizeObserver=new Or(e,(()=>{Hr(e)||this._unpinTooltip()})),this._mutationObserver.attach(e),this.balloonPanelView.class=[ib,n].filter((e=>e)).join(" ");for(const e of nb._editors)this.listenTo(e.ui,"update",this._updateTooltipPosition.bind(this),{priority:"low"});this._currentElementWithTooltip=e,this._currentTooltipPosition=i}_unpinTooltip(){this._unpinTooltipDebounced.cancel(),this._pinTooltipDebounced.cancel(),this.balloonPanelView.unpin();for(const e of nb._editors)this.stopListening(e.ui,"update");this._currentElementWithTooltip=null,this._currentTooltipPosition=null,this.tooltipTextView.text="",this._resizeObserver&&this._resizeObserver.destroy(),this._mutationObserver.detach()}_updateTooltipPosition(){const e=ob(this._currentElementWithTooltip);Hr(this._currentElementWithTooltip)&&e.text?this.balloonPanelView.pin({target:this._currentElementWithTooltip,positions:nb.getPositioningFunctions(e.position)}):this._unpinTooltip()}constructor(e){if(super(),this._currentElementWithTooltip=null,this._currentTooltipPosition=null,this._resizeObserver=null,this._mutationObserver=null,nb._editors.add(e),nb._instance)return nb._instance;nb._instance=this,this.tooltipTextView=new Tg(e.locale),this.tooltipTextView.set("text",""),this.tooltipTextView.setTemplate({tag:"span",attributes:{class:["ck","ck-tooltip__text"]},children:[{text:this.tooltipTextView.bindTemplate.to("text")}]}),this.balloonPanelView=new Xp(e.locale),this.balloonPanelView.class=ib,this.balloonPanelView.content.add(this.tooltipTextView),this._mutationObserver=function(e){const t=new MutationObserver((()=>{e()}));return{attach(e){t.observe(e,{attributes:!0,attributeFilter:["data-cke-tooltip-text","data-cke-tooltip-position"]})},detach(){t.disconnect()}}}((()=>{this._updateTooltipPosition()})),this._pinTooltipDebounced=ko(this._pinTooltip,600),this._unpinTooltipDebounced=ko(this._unpinTooltip,400),this.listenTo(_r.document,"keydown",this._onKeyDown.bind(this),{useCapture:!0}),this.listenTo(_r.document,"mouseenter",this._onEnterOrFocus.bind(this),{useCapture:!0}),this.listenTo(_r.document,"mouseleave",this._onLeaveOrBlur.bind(this),{useCapture:!0}),this.listenTo(_r.document,"focus",this._onEnterOrFocus.bind(this),{useCapture:!0}),this.listenTo(_r.document,"blur",this._onLeaveOrBlur.bind(this),{useCapture:!0}),this.listenTo(_r.document,"scroll",this._onScroll.bind(this),{useCapture:!0}),this._watchdogExcluded=!0}}function sb(e){return Fo(e)?e.closest("[data-cke-tooltip-text]:not([data-cke-tooltip-disabled])"):null}function ob(e){return{text:e.dataset.ckeTooltipText,position:e.dataset.ckeTooltipPosition||"s",cssClass:e.dataset.ckeTooltipClass||""}}nb.defaultBalloonPositions=tb({heightOffset:5,sideOffset:13}),nb._editors=new Set,nb._instance=null;const rb=50,ab=350,lb="Powered by";class cb extends(pr()){destroy(){const e=this._balloonView;e&&(e.unpin(),this._balloonView=null),this._showBalloonThrottled.cancel(),this.stopListening()}_handleEditorReady(){const e=this.editor;(!!e.config.get("ui.poweredBy.forceVisible")||"VALID"!==Ia(e.config.get("licenseKey")))&&e.ui.view&&(e.ui.focusTracker.on("change:isFocused",((e,t,i)=>{this._updateLastFocusedEditableElement(),i?this._showBalloon():this._hideBalloon()})),e.ui.focusTracker.on("change:focusedElement",((e,t,i)=>{this._updateLastFocusedEditableElement(),i&&this._showBalloon()})),e.ui.on("update",(()=>{this._showBalloonThrottled()})))}_createBalloonView(){const e=this.editor,t=this._balloonView=new Xp,i=ub(e),n=new db(e.locale,i.label);t.content.add(n),t.set({class:"ck-powered-by-balloon"}),e.ui.view.body.add(t),e.ui.focusTracker.add(t.element),this._balloonView=t}_showBalloon(){if(!this._lastFocusedEditableElement)return;const e=function(e,t){const i=ub(e),n="right"===i.side?function(e,t){return hb(e,t,((e,i)=>e.left+e.width-i.width-t.horizontalOffset))}(t,i):function(e,t){return hb(e,t,(e=>e.left+t.horizontalOffset))}(t,i);return{target:t,positions:[n]}}(this.editor,this._lastFocusedEditableElement);e&&(this._balloonView||this._createBalloonView(),this._balloonView.pin(e))}_hideBalloon(){this._balloonView&&this._balloonView.unpin()}_updateLastFocusedEditableElement(){const e=this.editor,t=e.ui.focusTracker.isFocused,i=e.ui.focusTracker.focusedElement;if(!t||!i)return void(this._lastFocusedEditableElement=null);const n=Array.from(e.ui.getEditableElementsNames()).map((t=>e.ui.getEditableElement(t)));n.includes(i)?this._lastFocusedEditableElement=i:this._lastFocusedEditableElement=n[0]}constructor(e){super(),this.editor=e,this._balloonView=null,this._lastFocusedEditableElement=null,this._showBalloonThrottled=jo(this._showBalloon.bind(this),50,{leading:!0}),e.on("ready",this._handleEditorReady.bind(this))}}class db extends Tg{constructor(e,t){super(e);const i=new Dg,n=this.bindTemplate;i.set({content:'<svg xmlns="http://www.w3.org/2000/svg" width="53" height="10" viewBox="0 0 53 10"><path fill="#1C2331" d="M31.724 1.492a15.139 15.139 0 0 0 .045 1.16 2.434 2.434 0 0 0-.687-.34 3.68 3.68 0 0 0-1.103-.166 2.332 2.332 0 0 0-1.14.255 1.549 1.549 0 0 0-.686.87c-.15.41-.225.98-.225 1.712 0 .939.148 1.659.444 2.161.297.503.792.754 1.487.754.452.015.9-.094 1.294-.316.296-.174.557-.4.771-.669l.14.852h1.282V.007h-1.623v1.485ZM31 6.496a1.77 1.77 0 0 1-.494.061.964.964 0 0 1-.521-.127.758.758 0 0 1-.296-.466 3.984 3.984 0 0 1-.093-.992 4.208 4.208 0 0 1 .098-1.052.753.753 0 0 1 .307-.477 1.08 1.08 0 0 1 .55-.122c.233-.004.466.026.69.089l.483.144v2.553c-.11.076-.213.143-.307.2a1.73 1.73 0 0 1-.417.189ZM35.68 0l-.702.004c-.322.002-.482.168-.48.497l.004.581c.002.33.164.493.486.49l.702-.004c.322-.002.481-.167.48-.496L36.165.49c-.002-.33-.164-.493-.486-.491ZM36.145 2.313l-1.612.01.034 5.482 1.613-.01-.035-5.482ZM39.623.79 37.989.8 38 2.306l-.946.056.006 1.009.949-.006.024 2.983c.003.476.143.844.419 1.106.275.26.658.39 1.148.387.132 0 .293-.01.483-.03.19-.02.38-.046.57-.08.163-.028.324-.068.482-.119l-.183-1.095-.702.004a.664.664 0 0 1-.456-.123.553.553 0 0 1-.14-.422l-.016-2.621 1.513-.01-.006-1.064-1.514.01-.01-1.503ZM46.226 2.388c-.41-.184-.956-.274-1.636-.27-.673.004-1.215.101-1.627.29-.402.179-.72.505-.888.91-.18.419-.268.979-.264 1.68.004.688.1 1.24.285 1.655.172.404.495.724.9.894.414.18.957.268 1.63.264.68-.004 1.224-.099 1.632-.284.4-.176.714-.501.878-.905.176-.418.263-.971.258-1.658-.004-.702-.097-1.261-.28-1.677a1.696 1.696 0 0 0-.888-.9Zm-.613 3.607a.77.77 0 0 1-.337.501 1.649 1.649 0 0 1-1.317.009.776.776 0 0 1-.343-.497 4.066 4.066 0 0 1-.105-1.02 4.136 4.136 0 0 1 .092-1.03.786.786 0 0 1 .337-.507 1.59 1.59 0 0 1 1.316-.008.79.79 0 0 1 .344.502c.078.337.113.683.105 1.03.012.343-.019.685-.092 1.02ZM52.114 2.07a2.67 2.67 0 0 0-1.128.278c-.39.191-.752.437-1.072.73l-.157-.846-1.273.008.036 5.572 1.623-.01-.024-3.78c.35-.124.646-.22.887-.286.26-.075.53-.114.8-.118l.45-.003.144-1.546-.286.001ZM22.083 7.426l-1.576-2.532a2.137 2.137 0 0 0-.172-.253 1.95 1.95 0 0 0-.304-.29.138.138 0 0 1 .042-.04 1.7 1.7 0 0 0 .328-.374l1.75-2.71c.01-.015.025-.028.024-.048-.01-.01-.021-.007-.031-.007L20.49 1.17a.078.078 0 0 0-.075.045l-.868 1.384c-.23.366-.46.732-.688 1.099a.108.108 0 0 1-.112.06c-.098-.005-.196-.001-.294-.002-.018 0-.038.006-.055-.007.002-.02.002-.039.005-.058a4.6 4.6 0 0 0 .046-.701V1.203c0-.02-.009-.032-.03-.03h-.033L16.93 1.17c-.084 0-.073-.01-.073.076v6.491c-.001.018.006.028.025.027h1.494c.083 0 .072.007.072-.071v-2.19c0-.055-.003-.11-.004-.166a3.366 3.366 0 0 0-.05-.417h.06c.104 0 .209.002.313-.002a.082.082 0 0 1 .084.05c.535.913 1.07 1.824 1.607 2.736a.104.104 0 0 0 .103.062c.554-.003 1.107-.002 1.66-.002l.069-.003-.019-.032-.188-.304ZM27.112 6.555c-.005-.08-.004-.08-.082-.08h-2.414c-.053 0-.106-.003-.159-.011a.279.279 0 0 1-.246-.209.558.558 0 0 1-.022-.15c0-.382 0-.762-.002-1.143 0-.032.007-.049.042-.044h2.504c.029.003.037-.012.034-.038V3.814c0-.089.013-.078-.076-.078h-2.44c-.07 0-.062.003-.062-.06v-.837c0-.047.004-.093.013-.14a.283.283 0 0 1 .241-.246.717.717 0 0 1 .146-.011h2.484c.024.002.035-.009.036-.033l.003-.038.03-.496c.01-.183.024-.365.034-.548.005-.085.003-.087-.082-.094-.218-.018-.437-.038-.655-.05a17.845 17.845 0 0 0-.657-.026 72.994 72.994 0 0 0-1.756-.016 1.7 1.7 0 0 0-.471.064 1.286 1.286 0 0 0-.817.655c-.099.196-.149.413-.145.633v3.875c0 .072.003.144.011.216a1.27 1.27 0 0 0 .711 1.029c.228.113.48.167.734.158.757-.005 1.515.002 2.272-.042.274-.016.548-.034.82-.053.03-.002.043-.008.04-.041-.008-.104-.012-.208-.019-.312a69.964 69.964 0 0 1-.05-.768ZM16.14 7.415l-.127-1.075c-.004-.03-.014-.04-.044-.037a13.125 13.125 0 0 1-.998.073c-.336.01-.672.02-1.008.016-.116-.001-.233-.014-.347-.039a.746.746 0 0 1-.45-.262c-.075-.1-.132-.211-.167-.33a3.324 3.324 0 0 1-.126-.773 9.113 9.113 0 0 1-.015-.749c0-.285.022-.57.065-.852.023-.158.066-.312.127-.46a.728.728 0 0 1 .518-.443 1.64 1.64 0 0 1 .397-.048c.628-.001 1.255.003 1.882.05.022.001.033-.006.036-.026l.003-.031.06-.55c.019-.177.036-.355.057-.532.004-.034-.005-.046-.04-.056a5.595 5.595 0 0 0-1.213-.21 10.783 10.783 0 0 0-.708-.02c-.24-.003-.48.01-.719.041a3.477 3.477 0 0 0-.625.14 1.912 1.912 0 0 0-.807.497c-.185.2-.33.433-.424.688a4.311 4.311 0 0 0-.24 1.096c-.031.286-.045.572-.042.86-.006.43.024.86.091 1.286.04.25.104.497.193.734.098.279.26.53.473.734.214.205.473.358.756.446.344.11.702.17 1.063.177a8.505 8.505 0 0 0 1.578-.083 6.11 6.11 0 0 0 .766-.18c.03-.008.047-.023.037-.057a.157.157 0 0 1-.003-.025Z"/><path fill="#AFE229" d="M6.016 6.69a1.592 1.592 0 0 0-.614.21c-.23.132-.422.32-.56.546-.044.072-.287.539-.287.539l-.836 1.528.009.006c.038.025.08.046.123.063.127.046.26.07.395.073.505.023 1.011-.007 1.517-.003.29.009.58.002.869-.022a.886.886 0 0 0 .395-.116.962.962 0 0 0 .312-.286c.056-.083.114-.163.164-.249.24-.408.48-.816.718-1.226.075-.128.148-.257.222-.386l.112-.192a1.07 1.07 0 0 0 .153-.518l-1.304.023s-1.258-.005-1.388.01Z"/><path fill="#771BFF" d="m2.848 9.044.76-1.39.184-.352c-.124-.067-.245-.14-.367-.21-.346-.204-.706-.384-1.045-.6a.984.984 0 0 1-.244-.207c-.108-.134-.136-.294-.144-.46-.021-.409-.002-.818-.009-1.227-.003-.195 0-.39.003-.585.004-.322.153-.553.427-.713l.833-.488c.22-.13.44-.257.662-.385.05-.029.105-.052.158-.077.272-.128.519-.047.76.085l.044.028c.123.06.242.125.358.196.318.178.635.357.952.537.095.056.187.117.275.184.194.144.254.35.266.578.016.284.007.569.006.853-.001.28.004.558 0 .838.592-.003 1.259 0 1.259 0l.723-.013c-.003-.292-.007-.584-.007-.876 0-.524.015-1.048-.016-1.571-.024-.42-.135-.8-.492-1.067a5.02 5.02 0 0 0-.506-.339A400.52 400.52 0 0 0 5.94.787C5.722.664 5.513.524 5.282.423 5.255.406 5.228.388 5.2.373 4.758.126 4.305-.026 3.807.21c-.097.046-.197.087-.29.14A699.896 699.896 0 0 0 .783 1.948c-.501.294-.773.717-.778 1.31-.004.36-.009.718-.001 1.077.016.754-.017 1.508.024 2.261.016.304.07.6.269.848.127.15.279.28.448.382.622.4 1.283.734 1.92 1.11l.183.109Z"/></svg>\n',isColorInherited:!1}),i.extendTemplate({attributes:{style:{width:"53px",height:"10px"}}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-powered-by"],"aria-hidden":!0},children:[{tag:"a",attributes:{href:"https://ckeditor.com/?utm_source=ckeditor&utm_medium=referral&utm_campaign=701Dn000000hVgmIAE_powered_by_ckeditor_logo",target:"_blank",tabindex:"-1"},children:[...t?[{tag:"span",attributes:{class:["ck","ck-powered-by__label"]},children:[t]}]:[],i],on:{dragstart:n.to((e=>e.preventDefault()))}}]})}}function hb(e,t,i){return(n,s)=>{const o=new Ir(e);if(o.width<ab||o.height<rb)return null;let r;r="inside"===t.position?o.bottom-s.height:o.bottom-s.height/2,r-=t.verticalOffset;const a=i(o,s),l=n.clone().moveTo(a,r).getIntersection(s.clone().moveTo(a,r)).getVisible();return!l||l.getArea()<s.getArea()?null:{top:r,left:a,name:`position_${t.position}-side_${t.side}`,config:{withArrow:!1}}}}function ub(e){const t=e.config.get("ui.poweredBy"),i=t&&t.position||"border";return{position:i,label:lb,verticalOffset:"inside"===i?5:0,horizontalOffset:5,side:"ltr"===e.locale.contentLanguageDirection?"right":"left",...t}}const mb={POLITE:"polite",ASSERTIVE:"assertive"};class gb{announce(e,t=mb.POLITE){const i=this.editor;if(!i.ui.view)return;this.view||(this.view=new fb(i.locale),i.ui.view.body.add(this.view));const{politeness:n,isUnsafeHTML:s}="string"==typeof t?{politeness:t}:t;let o=this.view.regionViews.find((e=>e.politeness===n));o||(o=new pb(i,n),this.view.regionViews.add(o)),o.announce({announcement:e,isUnsafeHTML:s})}constructor(e){this.editor=e,e.once("ready",(()=>{for(const e of Object.values(mb))this.announce("",e)}))}}class fb extends Tg{constructor(e){super(e),this.regionViews=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-aria-live-announcer"]},children:this.regionViews})}}class pb extends Tg{announce({announcement:e,isUnsafeHTML:t}){if(!e.trim().length)return;const i=document.createElement("li");t?this._domConverter.setContentOf(i,e):i.innerText=e,this._listElement.appendChild(i)}get _listElement(){return this.element.querySelector("ul")}constructor(e,t){super(e.locale),this.setTemplate({tag:"div",attributes:{role:"region","aria-live":t,"aria-relevant":"additions"},children:[{tag:"ul",attributes:{class:["ck","ck-aria-live-region-list"]}}]}),e.on("destroy",(()=>{null!==this._pruneAnnouncementsInterval&&(clearInterval(this._pruneAnnouncementsInterval),this._pruneAnnouncementsInterval=null)})),this.politeness=t,this._domConverter=e.data.htmlProcessor.domConverter,this._pruneAnnouncementsInterval=setInterval((()=>{this.element&&this._listElement.firstChild&&this._listElement.firstChild.remove()}),5e3)}}class bb extends(Yo()){get element(){return null}update(){this.fire("update")}destroy(){this.stopListening(),this.focusTracker.destroy(),this.tooltipManager.destroy(this.editor),this.poweredBy.destroy();for(const e of this._editableElementsMap.values())e.ckeditorInstance=null,this.editor.keystrokes.stopListening(e);this._editableElementsMap=new Map,this._focusableToolbarDefinitions=[]}setEditableElement(e,t){this._editableElementsMap.set(e,t),t.ckeditorInstance||(t.ckeditorInstance=this.editor),this.focusTracker.add(t);const i=()=>{this.editor.editing.view.getDomRoot(e)||this.editor.keystrokes.listenTo(t)};this.isReady?i():this.once("ready",i)}removeEditableElement(e){const t=this._editableElementsMap.get(e);t&&(this._editableElementsMap.delete(e),this.editor.keystrokes.stopListening(t),this.focusTracker.remove(t),t.ckeditorInstance=null)}getEditableElement(e="main"){return this._editableElementsMap.get(e)}getEditableElementsNames(){return this._editableElementsMap.keys()}addToolbar(e,t={}){e.isRendered?(this.focusTracker.add(e.element),this.editor.keystrokes.listenTo(e.element)):e.once("render",(()=>{this.focusTracker.add(e.element),this.editor.keystrokes.listenTo(e.element)})),this._focusableToolbarDefinitions.push({toolbarView:e,options:t})}get _editableElements(){return console.warn("editor-ui-deprecated-editable-elements: The EditorUI#_editableElements property has been deprecated and will be removed in the near future.",{editorUI:this}),this._editableElementsMap}_readViewportOffsetFromConfig(){const e=this.editor,t=e.config.get("ui.viewportOffset");if(t)return t;const i=e.config.get("toolbar.viewportTopOffset");return i?(console.warn("editor-ui-deprecated-viewport-offset-config: The `toolbar.vieportTopOffset` configuration option is deprecated. It will be removed from future CKEditor versions. Use `ui.viewportOffset.top` instead."),{top:i}):{top:0}}_initFocusTracking(){const e=this.editor,t=e.editing.view;let i,n;e.keystrokes.set("Alt+F10",((e,s)=>{const o=this.focusTracker.focusedElement;Array.from(this._editableElementsMap.values()).includes(o)&&!Array.from(t.domRoots.values()).includes(o)&&(i=o);const r=this._getCurrentFocusedToolbarDefinition();r&&n||(n=this._getFocusableCandidateToolbarDefinitions());for(let e=0;e<n.length;e++){const e=n.shift();if(n.push(e),e!==r&&this._focusFocusableCandidateToolbar(e)){r&&r.options.afterBlur&&r.options.afterBlur();break}}s()})),e.keystrokes.set("Esc",((t,n)=>{const s=this._getCurrentFocusedToolbarDefinition();s&&(i?(i.focus(),i=null):e.editing.view.focus(),s.options.afterBlur&&s.options.afterBlur(),n())}))}_getFocusableCandidateToolbarDefinitions(){const e=[];for(const t of this._focusableToolbarDefinitions){const{toolbarView:i,options:n}=t;(Hr(i.element)||n.beforeFocus)&&e.push(t)}return e.sort(((e,t)=>wb(e)-wb(t))),e}_getCurrentFocusedToolbarDefinition(){for(const e of this._focusableToolbarDefinitions)if(e.toolbarView.element&&e.toolbarView.element.contains(this.focusTracker.focusedElement))return e;return null}_focusFocusableCandidateToolbar(e){const{toolbarView:t,options:{beforeFocus:i}}=e;return i&&i(),!!Hr(t.element)&&(t.focus(),!0)}_handleScrollToTheSelection(e,t){const i={top:0,bottom:0,left:0,right:0,...this.viewportOffset};t.viewportOffset.top+=i.top,t.viewportOffset.bottom+=i.bottom,t.viewportOffset.left+=i.left,t.viewportOffset.right+=i.right}constructor(e){super(),this.isReady=!1,this._editableElementsMap=new Map,this._focusableToolbarDefinitions=[];const t=e.editing.view;this.editor=e,this.componentFactory=new Hp(e),this.focusTracker=new ya,this.tooltipManager=new nb(e),this.poweredBy=new cb(e),this.ariaLiveAnnouncer=new gb(e),this.set("viewportOffset",this._readViewportOffsetFromConfig()),this.once("ready",(()=>{this.isReady=!0})),this.listenTo(t.document,"layoutChanged",this.update.bind(this)),this.listenTo(t,"scrollToTheSelection",this._handleScrollToTheSelection.bind(this)),this._initFocusTracking()}}function wb(e){const{toolbarView:t,options:i}=e;let n=10;return Hr(t.element)&&n--,i.isContextual&&n--,n}class vb extends Tg{render(){super.render(),this.body.attachToDom()}destroy(){return this.body.detachFromDom(),super.destroy()}constructor(e){super(e),this.body=new Fg(e)}}class _b extends vb{_createVoiceLabel(){const e=this.t,t=new Bg;return t.text=e("Rich Text Editor"),t.extendTemplate({attributes:{class:"ck-voice-label"}}),t}constructor(e){super(e),this.top=this.createCollection(),this.main=this.createCollection(),this._voiceLabelView=this._createVoiceLabel(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-reset","ck-editor","ck-rounded-corners"],role:"application",dir:e.uiLanguageDirection,lang:e.uiLanguage,"aria-labelledby":this._voiceLabelView.id},children:[this._voiceLabelView,{tag:"div",attributes:{class:["ck","ck-editor__top","ck-reset_all"],role:"presentation"},children:this.top},{tag:"div",attributes:{class:["ck","ck-editor__main"],role:"presentation"},children:this.main}]})}}class yb extends Tg{render(){super.render(),this._hasExternalElement?this.template.apply(this.element=this._editableElement):this._editableElement=this.element,this.on("change:isFocused",(()=>this._updateIsFocusedClasses())),this._updateIsFocusedClasses()}destroy(){this._hasExternalElement&&this.template.revert(this._editableElement),super.destroy()}get hasExternalElement(){return this._hasExternalElement}_updateIsFocusedClasses(){const e=this._editingView;function t(t){e.change((i=>{const n=e.document.getRoot(t.name);i.addClass(t.isFocused?"ck-focused":"ck-blurred",n),i.removeClass(t.isFocused?"ck-blurred":"ck-focused",n)}))}e.isRenderingInProgress?function i(n){e.once("change:isRenderingInProgress",((e,s,o)=>{o?i(n):t(n)}))}(this):t(this)}constructor(e,t,i){super(e),this.name=null,this.setTemplate({tag:"div",attributes:{class:["ck","ck-content","ck-editor__editable","ck-rounded-corners"],lang:e.contentLanguage,dir:e.contentLanguageDirection}}),this.set("isFocused",!1),this._editableElement=i,this._hasExternalElement=!!this._editableElement,this._editingView=t}}class kb extends yb{render(){super.render();const e=this._editingView;e.change((t=>{const i=e.document.getRoot(this.name);t.setAttribute("aria-label",this._generateLabel(this),i)}))}constructor(e,t,i,n={}){super(e,t,i);const s=e.t;this.extendTemplate({attributes:{role:"textbox",class:"ck-editor__editable_inline"}}),this._generateLabel=n.label||(()=>s("Editor editing area: %0",this.name))}}class Cb extends Tg{render(){return new Promise((e=>(this.on("loaded",e),super.render())))}constructor(e){super(e);const t=this.bindTemplate;this.setTemplate({tag:"iframe",attributes:{class:["ck","ck-reset_all"],sandbox:"allow-same-origin allow-scripts"},on:{load:t.to("loaded")}})}}class xb extends Wa{static get pluginName(){return"Notification"}init(){this.on("show:warning",((e,t)=>{window.alert(t.message)}),{priority:"lowest"})}showSuccess(e,t={}){this._showNotification({message:e,type:"success",namespace:t.namespace,title:t.title})}showInfo(e,t={}){this._showNotification({message:e,type:"info",namespace:t.namespace,title:t.title})}showWarning(e,t={}){this._showNotification({message:e,type:"warning",namespace:t.namespace,title:t.title})}_showNotification(e){const t=e.namespace?`show:${e.type}:${e.namespace}`:`show:${e.type}`;this.fire(t,{message:e.message,type:e.type,title:e.title||""})}}class Ab extends(Yo()){constructor(e,t){super(),t&&Et(this,t),e&&this.set(e)}}const Eb=Lr("px");class Tb extends Na{static get pluginName(){return"ContextualBalloon"}destroy(){super.destroy(),this._view&&this._view.destroy(),this._rotatorView&&this._rotatorView.destroy(),this._fakePanelsView&&this._fakePanelsView.destroy()}get view(){return this._view||this._createPanelView(),this._view}hasView(e){return Array.from(this._viewToStack.keys()).includes(e)}add(e){if(this._view||this._createPanelView(),this.hasView(e.view))throw new p("contextualballoon-add-view-exist",[this,e]);const t=e.stackId||"main";if(!this._idToStack.has(t))return this._idToStack.set(t,new Map([[e.view,e]])),this._viewToStack.set(e.view,this._idToStack.get(t)),this._numberOfStacks=this._idToStack.size,void(this._visibleStack&&!e.singleViewMode||this.showStack(t));const i=this._idToStack.get(t);e.singleViewMode&&this.showStack(t),i.set(e.view,e),this._viewToStack.set(e.view,i),i===this._visibleStack&&this._showView(e)}remove(e){if(!this.hasView(e))throw new p("contextualballoon-remove-view-not-exist",[this,e]);const t=this._viewToStack.get(e);this._singleViewMode&&this.visibleView===e&&(this._singleViewMode=!1),this.visibleView===e&&(1===t.size?this._idToStack.size>1?this._showNextStack():(this.view.hide(),this.visibleView=null,this._rotatorView.hideView()):this._showView(Array.from(t.values())[t.size-2])),1===t.size?(this._idToStack.delete(this._getStackId(t)),this._numberOfStacks=this._idToStack.size):t.delete(e),this._viewToStack.delete(e)}updatePosition(e){e&&(this._visibleStack.get(this.visibleView).position=e),this.view.pin(this._getBalloonPosition()),this._fakePanelsView.updatePosition()}showStack(e){this.visibleStack=e;const t=this._idToStack.get(e);if(!t)throw new p("contextualballoon-showstack-stack-not-exist",this);this._visibleStack!==t&&this._showView(Array.from(t.values()).pop())}_createPanelView(){this._view=new Xp(this.editor.locale),this.editor.ui.view.body.add(this._view),this.editor.ui.focusTracker.add(this._view.element),this._rotatorView=this._createRotatorView(),this._fakePanelsView=this._createFakePanelsView()}get _visibleStack(){return this._viewToStack.get(this.visibleView)}_getStackId(e){return Array.from(this._idToStack.entries()).find((t=>t[1]===e))[0]}_showNextStack(){const e=Array.from(this._idToStack.values());let t=e.indexOf(this._visibleStack)+1;e[t]||(t=0),this.showStack(this._getStackId(e[t]))}_showPrevStack(){const e=Array.from(this._idToStack.values());let t=e.indexOf(this._visibleStack)-1;e[t]||(t=e.length-1),this.showStack(this._getStackId(e[t]))}_createRotatorView(){const e=new Sb(this.editor.locale),t=this.editor.locale.t;return this.view.content.add(e),e.bind("isNavigationVisible").to(this,"_numberOfStacks",this,"_singleViewMode",((e,t)=>!t&&e>1)),e.on("change:isNavigationVisible",(()=>this.updatePosition()),{priority:"low"}),e.bind("counter").to(this,"visibleView",this,"_numberOfStacks",((e,i)=>{if(i<2)return"";const n=Array.from(this._idToStack.values()).indexOf(this._visibleStack)+1;return t("%0 of %1",[n,i])})),e.buttonNextView.on("execute",(()=>{e.focusTracker.isFocused&&this.editor.editing.view.focus(),this._showNextStack()})),e.buttonPrevView.on("execute",(()=>{e.focusTracker.isFocused&&this.editor.editing.view.focus(),this._showPrevStack()})),e}_createFakePanelsView(){const e=new Ib(this.editor.locale,this.view);return e.bind("numberOfPanels").to(this,"_numberOfStacks",this,"_singleViewMode",((e,t)=>!t&&e>=2?Math.min(e-1,2):0)),e.listenTo(this.view,"change:top",(()=>e.updatePosition())),e.listenTo(this.view,"change:left",(()=>e.updatePosition())),this.editor.ui.view.body.add(e),e}_showView({view:e,balloonClassName:t="",withArrow:i=!0,singleViewMode:n=!1}){this.view.class=t,this.view.withArrow=i,this._rotatorView.showView(e),this.visibleView=e,this.view.pin(this._getBalloonPosition()),this._fakePanelsView.updatePosition(),n&&(this._singleViewMode=!0)}_getBalloonPosition(){let e=Array.from(this._visibleStack.values()).pop().position;return e&&(e.limiter||(e=Object.assign({},e,{limiter:this.positionLimiter})),e=Object.assign({},e,{viewportOffsetConfig:this.editor.ui.viewportOffset})),e}constructor(e){super(e),this._viewToStack=new Map,this._idToStack=new Map,this._view=null,this._rotatorView=null,this._fakePanelsView=null,this.positionLimiter=()=>{const e=this.editor.editing.view,t=e.document.selection.editableElement;return t?e.domConverter.mapViewToDom(t.root):null},this.set("visibleView",null),this.set("_numberOfStacks",0),this.set("_singleViewMode",!1)}}class Sb extends Tg{render(){super.render(),this.focusTracker.add(this.element)}destroy(){super.destroy(),this.focusTracker.destroy()}showView(e){this.hideView(),this.content.add(e)}hideView(){this.content.clear()}_createButtonView(e,t){const i=new Hg(this.locale);return i.set({label:e,icon:t,tooltip:!0}),i}constructor(e){super(e);const t=e.t,i=this.bindTemplate;this.set("isNavigationVisible",!0),this.focusTracker=new ya,this.buttonPrevView=this._createButtonView(t("Previous"),Dm.previousArrow),this.buttonNextView=this._createButtonView(t("Next"),Dm.nextArrow),this.content=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-balloon-rotator"],"z-index":"-1"},children:[{tag:"div",attributes:{class:["ck-balloon-rotator__navigation",i.to("isNavigationVisible",(e=>e?"":"ck-hidden"))]},children:[this.buttonPrevView,{tag:"span",attributes:{class:["ck-balloon-rotator__counter"]},children:[{text:i.to("counter")}]},this.buttonNextView]},{tag:"div",attributes:{class:"ck-balloon-rotator__content"},children:this.content}]})}}class Ib extends Tg{_addPanels(e){for(;e--;){const e=new Tg;e.setTemplate({tag:"div"}),this.content.add(e),this.registerChild(e)}}_removePanels(e){for(;e--;){const e=this.content.last;this.content.remove(e),this.deregisterChild(e),e.destroy()}}updatePosition(){if(this.numberOfPanels){const{top:e,left:t}=this._balloonPanelView,{width:i,height:n}=new Ir(this._balloonPanelView.element);Object.assign(this,{top:e,left:t,width:i,height:n})}}constructor(e,t){super(e);const i=this.bindTemplate;this.set("top",0),this.set("left",0),this.set("height",0),this.set("width",0),this.set("numberOfPanels",0),this.content=this.createCollection(),this._balloonPanelView=t,this.setTemplate({tag:"div",attributes:{class:["ck-fake-panel",i.to("numberOfPanels",(e=>e?"":"ck-hidden"))],style:{top:i.to("top",Eb),left:i.to("left",Eb),width:i.to("width",Eb),height:i.to("height",Eb)}},children:this.content}),this.on("change:numberOfPanels",((e,t,i,n)=>{i>n?this._addPanels(i-n):this._removePanels(n-i),this.updatePosition()}))}}const Pb=Lr("px");class Vb extends Tg{render(){super.render(),this.checkIfShouldBeSticky(),this.listenTo(_r.document,"scroll",(()=>{this.checkIfShouldBeSticky()}),{useCapture:!0}),this.listenTo(this,"change:isActive",(()=>{this.checkIfShouldBeSticky()}))}checkIfShouldBeSticky(){if(!this.limiterElement||!this.isActive)return void this._unstick();const e=new Ir(this.limiterElement);let t=e.getVisible();if(t){const e=new Ir(_r.window);e.top+=this.viewportTopOffset,e.height-=this.viewportTopOffset,t=t.getIntersection(e)}if(t&&e.top<t.top){const i=t.top;if(i+this._contentPanelRect.height+this.limiterBottomOffset>t.bottom){const i=Math.max(e.bottom-t.bottom,0)+this.limiterBottomOffset;e.bottom-i>e.top+this._contentPanelRect.height?this._stickToBottomOfLimiter(i):this._unstick()}else this._contentPanelRect.height+this.limiterBottomOffset<e.height?this._stickToTopOfAncestors(i):this._unstick()}else this._unstick()}_stickToTopOfAncestors(e){this.isSticky=!0,this._isStickyToTheBottomOfLimiter=!1,this._stickyTopOffset=e,this._stickyBottomOffset=null,this._marginLeft=Pb(-_r.window.scrollX)}_stickToBottomOfLimiter(e){this.isSticky=!0,this._isStickyToTheBottomOfLimiter=!0,this._stickyTopOffset=null,this._stickyBottomOffset=e,this._marginLeft=Pb(-_r.window.scrollX)}_unstick(){this.isSticky=!1,this._isStickyToTheBottomOfLimiter=!1,this._stickyTopOffset=null,this._stickyBottomOffset=null,this._marginLeft=null}get _contentPanelRect(){return new Ir(this.contentPanelElement)}constructor(e){super(e);const t=this.bindTemplate;this.set("isActive",!1),this.set("isSticky",!1),this.set("limiterElement",null),this.set("limiterBottomOffset",50),this.set("viewportTopOffset",0),this.set("_marginLeft",null),this.set("_isStickyToTheBottomOfLimiter",!1),this.set("_stickyTopOffset",null),this.set("_stickyBottomOffset",null),this.content=this.createCollection(),this._contentPanelPlaceholder=new rg({tag:"div",attributes:{class:["ck","ck-sticky-panel__placeholder"],style:{display:t.to("isSticky",(e=>e?"block":"none")),height:t.to("isSticky",(e=>e?Pb(this._contentPanelRect.height):null))}}}).render(),this.contentPanelElement=new rg({tag:"div",attributes:{class:["ck","ck-sticky-panel__content",t.if("isSticky","ck-sticky-panel__content_sticky"),t.if("_isStickyToTheBottomOfLimiter","ck-sticky-panel__content_sticky_bottom-limit")],style:{width:t.to("isSticky",(e=>e?Pb(this._contentPanelPlaceholder.getBoundingClientRect().width):null)),top:t.to("_stickyTopOffset",(e=>e?Pb(e):e)),bottom:t.to("_stickyBottomOffset",(e=>e?Pb(e):e)),marginLeft:t.to("_marginLeft")}},children:this.content}).render(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-sticky-panel"]},children:[this._contentPanelPlaceholder,this.contentPanelElement]})}}class Rb extends bf{reset(){this.fieldView.reset(),this._viewConfig.showResetButton&&(this.resetButtonView.isVisible=!1)}constructor(e,t){const i=e.t,n=Object.assign({},{showResetButton:!0,showIcon:!0,creator:Qf},t);super(e,n.creator),this.label=t.label,this._viewConfig=n,this._viewConfig.showIcon&&(this.iconView=new Dg,this.iconView.content=Dm.loupe,this.fieldWrapperChildren.add(this.iconView,0),this.extendTemplate({attributes:{class:"ck-search__query_with-icon"}})),this._viewConfig.showResetButton&&(this.resetButtonView=new Hg(e),this.resetButtonView.set({label:i("Clear"),icon:Dm.cancel,class:"ck-search__reset",isVisible:!1,tooltip:!0}),this.resetButtonView.on("execute",(()=>{this.reset(),this.focus(),this.fire("reset")})),this.resetButtonView.bind("isVisible").to(this.fieldView,"isEmpty",(e=>!e)),this.fieldWrapperChildren.add(this.resetButtonView),this.extendTemplate({attributes:{class:"ck-search__query_with-reset"}}))}}class Bb extends Tg{focus(){this.element.focus()}constructor(){super();const e=this.bindTemplate;this.set({isVisible:!1,primaryText:"",secondaryText:""}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-search__info",e.if("isVisible","ck-hidden",(e=>!e))],tabindex:-1},children:[{tag:"span",children:[{text:[e.to("primaryText")]}]},{tag:"span",children:[{text:[e.to("secondaryText")]}]}]})}}class Ob extends Tg{render(){super.render();for(const e of this.children)this.focusTracker.add(e.element)}focus(){this._focusCycler.focusFirst()}focusFirst(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}constructor(e){super(e),this.children=this.createCollection(),this.focusTracker=new ya,this.setTemplate({tag:"div",attributes:{class:["ck","ck-search__results"],tabindex:-1},children:this.children}),this._focusCycler=new Tf({focusables:this.children,focusTracker:this.focusTracker})}}class Mb extends Tg{render(){super.render(),this.children.addMany([this.queryView,this.resultsView]);const e=e=>e.stopPropagation();for(const e of this.focusableChildren)this.focusTracker.add(e.element);this.keystrokes.listenTo(this.element),this.keystrokes.set("arrowright",e),this.keystrokes.set("arrowleft",e),this.keystrokes.set("arrowup",e),this.keystrokes.set("arrowdown",e)}focus(){this.queryView.focus()}reset(){this.queryView.reset(),this.search("")}search(e){const t=e?new RegExp(Oo(e),"ig"):null,i=this.filteredView.filter(t);this.fire("search",{query:e,...i})}_createSearchTextQueryView(){const e=new Rb(this.locale,this._config.queryView);return this.listenTo(e.fieldView,"input",(()=>{this.search(e.fieldView.element.value)})),e.on("reset",(()=>this.reset())),e.bind("isEnabled").to(this),e}_enableDefaultInfoViewBehavior(){const e=this.locale.t,t=this.infoView;function i(e,{query:t,resultsCount:i,totalItemsCount:n}){return"function"==typeof e?e(t,i,n):e}this.on("search",((n,s)=>{if(s.resultsCount)t.set({isVisible:!1});else{const n=this._config.infoView&&this._config.infoView.text;let o,r;s.totalItemsCount?n&&n.notFound?(o=n.notFound.primary,r=n.notFound.secondary):(o=e("No results found"),r=""):n&&n.noSearchableItems?(o=n.noSearchableItems.primary,r=n.noSearchableItems.secondary):(o=e("No searchable items"),r=""),t.set({primaryText:i(o,s),secondaryText:i(r,s),isVisible:!0})}}))}constructor(e,t){super(e),this._config=t,this.filteredView=t.filteredView,this.queryView=this._createSearchTextQueryView(),this.focusTracker=new ya,this.keystrokes=new ka,this.resultsView=new Ob(e),this.children=this.createCollection(),this.focusableChildren=this.createCollection([this.queryView,this.resultsView]),this.set("isEnabled",!0),this.set("resultsCount",0),this.set("totalItemsCount",0),t.infoView&&t.infoView.instance?this.infoView=t.infoView.instance:(this.infoView=new Bb,this._enableDefaultInfoViewBehavior(),this.on("render",(()=>{this.search("")}))),this.resultsView.children.addMany([this.infoView,this.filteredView]),this.focusCycler=new Tf({focusables:this.focusableChildren,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.on("search",((e,{resultsCount:t,totalItemsCount:i})=>{this.resultsCount=t,this.totalItemsCount=i})),this.setTemplate({tag:"div",attributes:{class:["ck","ck-search",t.class||null],tabindex:"-1"},children:this.children})}}class Lb extends Mb{_updateResultsViewWidthAndPosition(){if(!this.resultsView.isVisible)return;this.resultsView._width=new Ir(this.queryView.fieldView.element).width;const e=Lb._getOptimalPosition({element:this.resultsView.element,target:this.queryView.element,fitInViewport:!0,positions:Lb.defaultResultsPositions});this.resultsView._position=e?e.name:"s"}_updateResultsVisibility(){const e=void 0===this._config.queryMinChars?0:this._config.queryMinChars,t=this.queryView.fieldView.element.value.length;this.resultsView.isVisible=this.focusTracker.isFocused&&this.isEnabled&&t>=e}constructor(e,t){super(e,t),this._config=t;const i=Lr("px");this.extendTemplate({attributes:{class:["ck-autocomplete"]}});const n=this.resultsView.bindTemplate;this.resultsView.set("isVisible",!1),this.resultsView.set("_position","s"),this.resultsView.set("_width",0),this.resultsView.extendTemplate({attributes:{class:[n.if("isVisible","ck-hidden",(e=>!e)),n.to("_position",(e=>`ck-search__results_${e}`))],style:{width:n.to("_width",i)}}}),this.focusTracker.on("change:isFocused",((e,i,n)=>{this._updateResultsVisibility(),n?this.resultsView.element.scrollTop=0:t.resetOnBlur&&this.queryView.reset()})),this.on("search",(()=>{this._updateResultsVisibility(),this._updateResultsViewWidthAndPosition()})),this.keystrokes.set("esc",((e,t)=>{this.resultsView.isVisible&&(this.queryView.focus(),this.resultsView.isVisible=!1,t())})),this.listenTo(_r.document,"scroll",(()=>{this._updateResultsViewWidthAndPosition()})),this.on("change:isEnabled",(()=>{this._updateResultsVisibility()})),this.filteredView.on("execute",((e,{value:t})=>{this.focus(),this.reset(),this.queryView.fieldView.value=this.queryView.fieldView.element.value=t,this.resultsView.isVisible=!1})),this.resultsView.on("change:isVisible",(()=>{this._updateResultsViewWidthAndPosition()}))}}Lb.defaultResultsPositions=[e=>({top:e.bottom,left:e.left,name:"s"}),(e,t)=>({top:e.top-t.height,left:e.left,name:"n"})],Lb._getOptimalPosition=$r;class Nb extends Tg{highlightText(e){this._updateInnerHTML(function(e,t){if(!t)return Vo(e);const i=[];let n=0,s=t.exec(e);for(;null!==s;){const o=s.index;o!==n&&i.push({text:e.substring(n,o),isMatch:!1}),i.push({text:s[0],isMatch:!0}),n=t.lastIndex,s=t.exec(e)}n!==e.length&&i.push({text:e.substring(n),isMatch:!1});return i.map((e=>(e.text=Vo(e.text),e))).map((e=>e.isMatch?`<mark>${e.text}</mark>`:e.text)).join("")}(this.text||"",e))}_updateInnerHTML(e){this.element.innerHTML=e||""}constructor(){super(),this.set("text",void 0),this.setTemplate({tag:"span",attributes:{class:["ck","ck-highlighted-text"]}}),this.on("render",(()=>{this.on("change:text",(()=>{this._updateInnerHTML(this.text)})),this._updateInnerHTML(this.text)}))}}class Fb extends Tg{constructor(){super(),this.set("isVisible",!1);const e=this.bindTemplate;this.setTemplate({tag:"span",attributes:{class:["ck","ck-spinner-container",e.if("isVisible","ck-hidden",(e=>!e))]},children:[{tag:"span",attributes:{class:["ck","ck-spinner"]}}]})}}const Db=Lr("px");class zb extends Na{static get pluginName(){return"BalloonToolbar"}static get requires(){return[Tb]}init(){const e=this.editor,t=e.model.document.selection;this.listenTo(this.focusTracker,"change:isFocused",((e,t,i)=>{const n=this._balloon.visibleView===this.toolbarView;!i&&n?this.hide():i&&this.show()})),this.listenTo(t,"change:range",((e,i)=>{(i.directChange||t.isCollapsed)&&this.hide(),this._fireSelectionChangeDebounced()})),this.listenTo(this,"_selectionChangeDebounced",(()=>{this.editor.editing.view.document.isFocused&&this.show()})),this._balloonConfig.shouldNotGroupWhenFull||this.listenTo(e,"ready",(()=>{const t=e.ui.view.editable.element;this._resizeObserver=new Or(t,(e=>{this.toolbarView.maxWidth=Db(.9*e.contentRect.width)}))})),this.listenTo(this.toolbarView,"groupedItemsUpdate",(()=>{this._updatePosition()})),e.ui.once("ready",(()=>{this.toolbarView.fillFromConfig(this._balloonConfig,this.editor.ui.componentFactory)}))}_createToolbarView(){const e=this.editor.locale.t,t=!this._balloonConfig.shouldNotGroupWhenFull,i=new Mf(this.editor.locale,{shouldGroupWhenFull:t,isFloating:!0});return i.ariaLabel=e("Editor contextual toolbar"),i.render(),i}show(e=!1){const t=this.editor,i=t.model.document.selection,n=t.model.schema;this._balloon.hasView(this.toolbarView)||i.isCollapsed&&!e||function(e,t){if(1===e.rangeCount)return!1;return[...e.getRanges()].every((e=>{const i=e.getContainedElement();return i&&t.isSelectable(i)}))}(i,n)||Array.from(this.toolbarView.items).every((e=>void 0!==e.isEnabled&&!e.isEnabled))||(this.listenTo(this.editor.ui,"update",(()=>{this._updatePosition()})),this._balloon.add({view:this.toolbarView,position:this._getBalloonPositionData(),balloonClassName:"ck-toolbar-container"}))}hide(){this._balloon.hasView(this.toolbarView)&&(this.stopListening(this.editor.ui,"update"),this._balloon.remove(this.toolbarView))}_getBalloonPositionData(){const e=this.editor.editing.view,t=e.document,i=t.selection,n=t.selection.isBackward;return{target:()=>{const t=n?i.getFirstRange():i.getLastRange(),s=Ir.getDomRangeRects(e.domConverter.viewRangeToDom(t));return n?s[0]:(s.length>1&&0===s[s.length-1].width&&s.pop(),s[s.length-1])},positions:this._getBalloonPositions(n)}}_updatePosition(){this._balloon.updatePosition(this._getBalloonPositionData())}destroy(){super.destroy(),this.stopListening(),this._fireSelectionChangeDebounced.cancel(),this.toolbarView.destroy(),this.focusTracker.destroy(),this._resizeObserver&&this._resizeObserver.destroy()}_getBalloonPositions(e){const t=i.isSafari&&i.isiOS?tb({heightOffset:Math.max(Xp.arrowHeightOffset,Math.round(20/_r.window.visualViewport.scale))}):Xp.defaultPositions;return e?[t.northWestArrowSouth,t.northWestArrowSouthWest,t.northWestArrowSouthEast,t.northWestArrowSouthMiddleEast,t.northWestArrowSouthMiddleWest,t.southWestArrowNorth,t.southWestArrowNorthWest,t.southWestArrowNorthEast,t.southWestArrowNorthMiddleWest,t.southWestArrowNorthMiddleEast]:[t.southEastArrowNorth,t.southEastArrowNorthEast,t.southEastArrowNorthWest,t.southEastArrowNorthMiddleEast,t.southEastArrowNorthMiddleWest,t.northEastArrowSouth,t.northEastArrowSouthEast,t.northEastArrowSouthWest,t.northEastArrowSouthMiddleEast,t.northEastArrowSouthMiddleWest]}constructor(e){super(e),this._resizeObserver=null,this._balloonConfig=Bf(e.config.get("balloonToolbar")),this.toolbarView=this._createToolbarView(),this.focusTracker=new ya,e.ui.once("ready",(()=>{this.focusTracker.add(e.ui.getEditableElement()),this.focusTracker.add(this.toolbarView.element)})),e.ui.addToolbar(this.toolbarView,{beforeFocus:()=>this.show(!0),afterBlur:()=>this.hide(),isContextual:!0}),this._balloon=e.plugins.get(Tb),this._fireSelectionChangeDebounced=ko((()=>this.fire("_selectionChangeDebounced")),200),this.decorate("show")}}const Hb=Lr("px");class $b extends Hg{constructor(e){super(e);const t=this.bindTemplate;this.isVisible=!1,this.isToggleable=!0,this.set("top",0),this.set("left",0),this.extendTemplate({attributes:{class:"ck-block-toolbar-button",style:{top:t.to("top",(e=>Hb(e))),left:t.to("left",(e=>Hb(e)))}}})}}const Ub=Lr("px");class Wb extends Na{static get pluginName(){return"BlockToolbar"}init(){const e=this.editor,t=e.t,i=t("Click to edit block"),n=t("Drag to move"),s=t("Edit block"),o=e.plugins.has("DragDropBlockToolbar"),r=o?`${i}\n${n}`:s;this.buttonView.label=r,o&&(this.buttonView.element.dataset.ckeTooltipClass="ck-tooltip_multi-line"),this.listenTo(e.model.document.selection,"change:range",((e,t)=>{t.directChange&&this._hidePanel()})),this.listenTo(e.ui,"update",(()=>this._updateButton())),this.listenTo(e,"change:isReadOnly",(()=>this._updateButton()),{priority:"low"}),this.listenTo(e.ui.focusTracker,"change:isFocused",(()=>this._updateButton())),this.listenTo(this.buttonView,"change:isVisible",((e,t,i)=>{i?this.buttonView.listenTo(window,"resize",(()=>this._updateButton())):(this.buttonView.stopListening(window,"resize"),this._hidePanel())})),e.ui.addToolbar(this.toolbarView,{beforeFocus:()=>this._showPanel(),afterBlur:()=>this._hidePanel()}),e.ui.once("ready",(()=>{this.toolbarView.fillFromConfig(this._blockToolbarConfig,this.editor.ui.componentFactory);for(const e of this.toolbarView.items)e.on("execute",(()=>this._hidePanel(!0)),{priority:"high"})}))}destroy(){super.destroy(),this.panelView.destroy(),this.buttonView.destroy(),this.toolbarView.destroy(),this._resizeObserver&&this._resizeObserver.destroy()}_createToolbarView(){const e=this.editor.locale.t,t=!this._blockToolbarConfig.shouldNotGroupWhenFull,i=new Mf(this.editor.locale,{shouldGroupWhenFull:t,isFloating:!0});return i.ariaLabel=e("Editor block content toolbar"),i}_createPanelView(){const e=this.editor,t=new Xp(e.locale);return t.content.add(this.toolbarView),t.class="ck-toolbar-container",e.ui.view.body.add(t),e.ui.focusTracker.add(t.element),this.toolbarView.keystrokes.set("Esc",((e,t)=>{this._hidePanel(!0),t()})),t}_createButtonView(){const e=this.editor,t=e.t,i=new $b(e.locale),n=this._blockToolbarConfig.icon,s=Of[n]||n||Of.dragIndicator;return i.set({label:t("Edit block"),icon:s,withText:!1}),i.bind("isOn").to(this.panelView,"isVisible"),i.bind("tooltip").to(this.panelView,"isVisible",(e=>!e)),this.listenTo(i,"execute",(()=>{this.panelView.isVisible?this._hidePanel(!0):this._showPanel()})),e.ui.view.body.add(i),e.ui.focusTracker.add(i.element),i}_updateButton(){const e=this.editor,t=e.model,i=e.editing.view;if(!e.ui.focusTracker.isFocused)return void this._hideButton();if(!e.model.canEditAt(e.model.document.selection))return void this._hideButton();const n=Array.from(t.document.selection.getSelectedBlocks())[0];if(!n||Array.from(this.toolbarView.items).every((e=>!e.isEnabled)))return void this._hideButton();const s=i.domConverter.mapViewToDom(e.editing.mapper.toViewElement(n));this.buttonView.isVisible=!0,this._setupToolbarResize(),this._attachButtonToElement(s),this.panelView.isVisible&&this._showPanel()}_hideButton(){this.buttonView.isVisible=!1}_showPanel(){if(!this.buttonView.isVisible)return;const e=this.panelView.isVisible;this.panelView.show();const t=this._getSelectedEditableElement();this.toolbarView.maxWidth=this._getToolbarMaxWidth(t),this.panelView.pin({target:this.buttonView.element,limiter:t}),e||this.toolbarView.items.get(0).focus()}_getSelectedEditableElement(){const e=this.editor.model.document.selection.getFirstRange().root.rootName;return this.editor.ui.getEditableElement(e)}_hidePanel(e){this.panelView.isVisible=!1,e&&this.editor.editing.view.focus()}_attachButtonToElement(e){const t=window.getComputedStyle(e),i=new Ir(this._getSelectedEditableElement()),n=parseInt(t.paddingTop,10),s=parseInt(t.lineHeight,10)||1.2*parseInt(t.fontSize,10),o=new Ir(this.buttonView.element),r=new Ir(e);let a;a="ltr"===this.editor.locale.uiLanguageDirection?i.left-o.width:i.right;const l=r.top+n+(s-o.height)/2;o.moveTo(a,l);const c=o.toAbsoluteRect();this.buttonView.top=c.top,this.buttonView.left=c.left}_setupToolbarResize(){const e=this._getSelectedEditableElement();this._blockToolbarConfig.shouldNotGroupWhenFull||(this._resizeObserver&&this._resizeObserver.element!==e&&(this._resizeObserver.destroy(),this._resizeObserver=null),this._resizeObserver||(this._resizeObserver=new Or(e,(()=>{this.toolbarView.maxWidth=this._getToolbarMaxWidth(e)}))))}_getToolbarMaxWidth(e){const t=new Ir(e),i=new Ir(this.buttonView.element),n="rtl"===this.editor.locale.uiLanguageDirection?i.left-t.right+i.width:t.left-i.left;return Ub(t.width+n)}constructor(e){super(e),this._resizeObserver=null,this._blockToolbarConfig=Bf(this.editor.config.get("blockToolbar")),this.toolbarView=this._createToolbarView(),this.panelView=this._createPanelView(),this.buttonView=this._createButtonView(),Sg({emitter:this.panelView,contextElements:[this.panelView.element,this.buttonView.element],activator:()=>this.panelView.isVisible,callback:()=>this._hidePanel()})}}class jb extends Hg{render(){super.render(),this.children.add(this.arrowView)}_createArrowView(){const e=new Dg;return e.content=jg,e.extendTemplate({attributes:{class:"ck-menu-bar__menu__button__arrow"}}),e}constructor(e){super(e);const t=this.bindTemplate;this.set({withText:!0,role:"menuitem"}),this.arrowView=this._createArrowView(),this.extendTemplate({attributes:{class:["ck-menu-bar__menu__button"],"aria-haspopup":!0,"aria-expanded":this.bindTemplate.to("isOn",(e=>String(e))),"data-cke-tooltip-disabled":t.to("isOn")},on:{mouseenter:t.to("mouseenter")}})}}class qb extends Df{constructor(e,t){super(e);const i=this.bindTemplate;this.extendTemplate({attributes:{class:["ck-menu-bar__menu__item"]},on:{mouseenter:i.to("mouseenter")}}),this.delegate("mouseenter").to(t)}}const Gb={toggleMenusAndFocusItemsOnHover(e){e.on("menu:mouseenter",(t=>{if(e.isOpen){for(const i of e.menus){const e=t.path[0],n=e instanceof qb&&e.children.first===i;i.isOpen=(t.path.includes(i)||n)&&i.isEnabled}t.source.focus()}}))},focusCycleMenusOnArrows(e){const t="rtl"===e.locale.uiLanguageDirection;function i(t,i){const n=e.children.getIndex(t),s=t.isOpen,o=e.children.length,r=e.children.get((n+o+i)%o);t.isOpen=!1,s&&(r.isOpen=!0),r.buttonView.focus()}e.on("menu:arrowright",(e=>{i(e.source,t?-1:1)})),e.on("menu:arrowleft",(e=>{i(e.source,t?1:-1)}))},closeMenusWhenTheBarCloses(e){e.on("change:isOpen",(()=>{e.isOpen||e.menus.forEach((e=>{e.isOpen=!1}))}))},closeMenuWhenAnotherOnTheSameLevelOpens(e){e.on("menu:change:isOpen",((t,i,n)=>{n&&e.menus.filter((e=>t.source.parentMenuView===e.parentMenuView&&t.source!==e&&e.isOpen)).forEach((e=>{e.isOpen=!1}))}))},closeOnClickOutside(e){Sg({emitter:e,activator:()=>e.isOpen,callback:()=>e.close(),contextElements:()=>e.children.map((e=>e.element))})}},Kb={openAndFocusPanelOnArrowDownKey(e){e.keystrokes.set("arrowdown",((t,i)=>{e.focusTracker.focusedElement===e.buttonView.element&&(e.isOpen||(e.isOpen=!0),e.panelView.focus(),i())}))},openOnArrowRightKey(e){const t="rtl"===e.locale.uiLanguageDirection?"arrowleft":"arrowright";e.keystrokes.set(t,((t,i)=>{e.focusTracker.focusedElement===e.buttonView.element&&e.isEnabled&&(e.isOpen||(e.isOpen=!0),e.panelView.focus(),i())}))},openOnButtonClick(e){e.buttonView.on("execute",(()=>{e.isOpen=!0,e.panelView.focus()}))},toggleOnButtonClick(e){e.buttonView.on("execute",(()=>{e.isOpen=!e.isOpen,e.isOpen&&e.panelView.focus()}))},closeOnArrowLeftKey(e){const t="rtl"===e.locale.uiLanguageDirection?"arrowright":"arrowleft";e.keystrokes.set(t,((t,i)=>{e.isOpen&&(e.isOpen=!1,e.focus(),i())}))},closeOnEscKey(e){e.keystrokes.set("esc",((t,i)=>{e.isOpen&&(e.isOpen=!1,e.focus(),i())}))},closeOnParentClose(e){e.parentMenuView.on("change:isOpen",((t,i,n)=>{n||t.source!==e.parentMenuView||(e.isOpen=!1)}))}},Zb={southEast:e=>({top:e.bottom,left:e.left,name:"se"}),southWest:(e,t)=>({top:e.bottom,left:e.left-t.width+e.width,name:"sw"}),northEast:(e,t)=>({top:e.top-t.height,left:e.left,name:"ne"}),northWest:(e,t)=>({top:e.top-t.height,left:e.left-t.width+e.width,name:"nw"}),eastSouth:e=>({top:e.top,left:e.right-5,name:"es"}),eastNorth:(e,t)=>({top:e.top-t.height,left:e.right-5,name:"en"}),westSouth:(e,t)=>({top:e.top,left:e.left-t.width+5,name:"ws"}),westNorth:(e,t)=>({top:e.top-t.height,left:e.left-t.width+5,name:"wn"})},Jb=[{menuId:"file",label:"File",groups:[{groupId:"export",items:["menuBar:exportPdf","menuBar:exportWord"]},{groupId:"import",items:["menuBar:importWord"]},{groupId:"revisionHistory",items:["menuBar:revisionHistory"]}]},{menuId:"edit",label:"Edit",groups:[{groupId:"undo",items:["menuBar:undo","menuBar:redo"]},{groupId:"selectAll",items:["menuBar:selectAll"]},{groupId:"findAndReplace",items:["menuBar:findAndReplace"]}]},{menuId:"view",label:"View",groups:[{groupId:"sourceEditing",items:["menuBar:sourceEditing"]},{groupId:"showBlocks",items:["menuBar:showBlocks"]},{groupId:"restrictedEditingException",items:["menuBar:restrictedEditingException"]}]},{menuId:"insert",label:"Insert",groups:[{groupId:"insertMainWidgets",items:["menuBar:uploadImage","menuBar:ckbox","menuBar:ckfinder","menuBar:insertTable"]},{groupId:"insertInline",items:["menuBar:link","menuBar:comment"]},{groupId:"insertMinorWidgets",items:["menuBar:insertTemplate","menuBar:blockQuote","menuBar:codeBlock","menuBar:htmlEmbed"]},{groupId:"insertStructureWidgets",items:["menuBar:horizontalLine","menuBar:pageBreak","menuBar:tableOfContents"]},{groupId:"restrictedEditing",items:["menuBar:restrictedEditing"]}]},{menuId:"format",label:"Format",groups:[{groupId:"textAndFont",items:[{menuId:"text",label:"Text",groups:[{groupId:"basicStyles",items:["menuBar:bold","menuBar:italic","menuBar:underline","menuBar:strikethrough","menuBar:superscript","menuBar:subscript","menuBar:code"]},{groupId:"textPartLanguage",items:["menuBar:textPartLanguage"]}]},{menuId:"font",label:"Font",groups:[{groupId:"fontProperties",items:["menuBar:fontSize","menuBar:fontFamily"]},{groupId:"fontColors",items:["menuBar:fontColor","menuBar:fontBackgroundColor"]},{groupId:"highlight",items:["menuBar:highlight"]}]},"menuBar:heading"]},{groupId:"list",items:["menuBar:bulletedList","menuBar:numberedList","menuBar:todoList"]},{groupId:"indent",items:["menuBar:alignment","menuBar:indent","menuBar:outdent"]},{groupId:"caseChange",items:["menuBar:caseChange"]},{groupId:"removeFormat",items:["menuBar:removeFormat"]}]},{menuId:"tools",label:"Tools",groups:[{groupId:"aiTools",items:["menuBar:aiAssistant","menuBar:aiCommands"]},{groupId:"tools",items:["menuBar:trackChanges","menuBar:commentsArchive"]}]},{menuId:"help",label:"Help",groups:[{groupId:"help",items:["menuBar:accessibilityHelp"]}]}];function Qb(e){let t;return t="items"in e&&e.items?{items:e.items,removeItems:[],addItems:[],isVisible:!0,isUsingDefaultConfig:!1,...e}:{items:_s(Jb),addItems:[],removeItems:[],isVisible:!0,isUsingDefaultConfig:!0,...e},t}function Yb({normalizedConfig:e,locale:t,componentFactory:i}){const n=_s(e);return function(e,t){const i=t.removeItems,n=[];t.items=t.items.filter((({menuId:e})=>!i.includes(e)||(n.push(e),!1))),iw(t.items,(e=>{e.groups=e.groups.filter((({groupId:e})=>!i.includes(e)||(n.push(e),!1)));for(const t of e.groups)t.items=t.items.filter((e=>{const t=aw(e);return!i.includes(t)||(n.push(t),!1)}))}));for(const t of i)n.includes(t)||b("menu-bar-item-could-not-be-removed",{menuBarConfig:e,itemName:t})}(e,n),function(e,t){const i=t.addItems,n=[];for(const e of i){const i=ow(e.position),s=rw(e.position);if(nw(e))if(s){const o=t.items.findIndex((e=>e.menuId===s));if(-1!=o)"before"===i?(t.items.splice(o,0,e.menu),n.push(e)):"after"===i&&(t.items.splice(o+1,0,e.menu),n.push(e));else{Xb(t,e.menu,s,i)&&n.push(e)}}else"start"===i?(t.items.unshift(e.menu),n.push(e)):"end"===i&&(t.items.push(e.menu),n.push(e));else if(sw(e))iw(t.items,(t=>{if(t.menuId===s)"start"===i?(t.groups.unshift(e.group),n.push(e)):"end"===i&&(t.groups.push(e.group),n.push(e));else{const o=t.groups.findIndex((e=>e.groupId===s));-1!==o&&("before"===i?(t.groups.splice(o,0,e.group),n.push(e)):"after"===i&&(t.groups.splice(o+1,0,e.group),n.push(e)))}}));else{Xb(t,e.item,s,i)&&n.push(e)}}for(const t of i)n.includes(t)||b("menu-bar-item-could-not-be-added",{menuBarConfig:e,addedItemConfig:t})}(e,n),function(e,t,i){iw(t.items,(n=>{for(const s of n.groups)s.items=s.items.filter((s=>{const o="string"==typeof s&&!i.has(s);return o&&!t.isUsingDefaultConfig&&b("menu-bar-item-unavailable",{menuBarConfig:e,parentMenuConfig:_s(n),componentName:s}),!o}))}))}(e,n,i),ew(e,n),function(e,t){const i=t.t,n={File:i({string:"File",id:"MENU_BAR_MENU_FILE"}),Edit:i({string:"Edit",id:"MENU_BAR_MENU_EDIT"}),View:i({string:"View",id:"MENU_BAR_MENU_VIEW"}),Insert:i({string:"Insert",id:"MENU_BAR_MENU_INSERT"}),Format:i({string:"Format",id:"MENU_BAR_MENU_FORMAT"}),Tools:i({string:"Tools",id:"MENU_BAR_MENU_TOOLS"}),Help:i({string:"Help",id:"MENU_BAR_MENU_HELP"}),Text:i({string:"Text",id:"MENU_BAR_MENU_TEXT"}),Font:i({string:"Font",id:"MENU_BAR_MENU_FONT"})};iw(e.items,(e=>{e.label in n&&(e.label=n[e.label])}))}(n,t),n}function Xb(e,t,i,n){let s=!1;return iw(e.items,(e=>{for(const{groupId:o,items:r}of e.groups){if(s)return;if(o===i)"start"===n?(r.unshift(t),s=!0):"end"===n&&(r.push(t),s=!0);else{const e=r.findIndex((e=>aw(e)===i));-1!==e&&("before"===n?(r.splice(e,0,t),s=!0):"after"===n&&(r.splice(e+1,0,t),s=!0))}}})),s}function ew(e,t){const i=t.isUsingDefaultConfig;let n=!1;t.items=t.items.filter((t=>!!t.groups.length||(tw(e,t,i),!1))),t.items.length?(iw(t.items,(t=>{t.groups=t.groups.filter((e=>!!e.items.length||(n=!0,!1)));for(const s of t.groups)s.items=s.items.filter((t=>!(lw(t)&&!t.groups.length)||(tw(e,t,i),n=!0,!1)))})),n&&ew(e,t)):tw(e,e,i)}function tw(e,t,i){i||b("menu-bar-menu-empty",{menuBarConfig:e,emptyMenuConfig:t})}function iw(e,t){if(Array.isArray(e))for(const t of e)i(t);function i(e){t(e);for(const t of e.groups)for(const e of t.items)lw(e)&&i(e)}}function nw(e){return"object"==typeof e&&"menu"in e}function sw(e){return"object"==typeof e&&"group"in e}function ow(e){return e.startsWith("start")?"start":e.startsWith("end")?"end":e.startsWith("after")?"after":"before"}function rw(e){const t=e.match(/^[^:]+:(.+)/);return t?t[1]:null}function aw(e){return"string"==typeof e?e:e.menuId}function lw(e){return"object"==typeof e&&"menuId"in e}class cw extends Tg{focus(e=1){this.children.length&&(1===e?this.children.first.focus():this.children.last.focus())}constructor(e){super(e);const t=this.bindTemplate;this.set("isVisible",!1),this.set("position","se"),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-reset","ck-menu-bar__menu__panel",t.to("position",(e=>`ck-menu-bar__menu__panel_position_${e}`)),t.if("isVisible","ck-hidden",(e=>!e))],tabindex:"-1"},children:this.children,on:{selectstart:t.to((e=>{"input"!==e.target.tagName.toLocaleLowerCase()&&e.preventDefault()}))}})}}class dw extends Tg{render(){super.render(),this.focusTracker.add(this.buttonView.element),this.focusTracker.add(this.panelView.element),this.keystrokes.listenTo(this.element),Kb.closeOnEscKey(this),this._repositionPanelOnOpen()}_attachBehaviors(){this.parentMenuView?(Kb.openOnButtonClick(this),Kb.openOnArrowRightKey(this),Kb.closeOnArrowLeftKey(this),Kb.closeOnParentClose(this)):(this._propagateArrowKeystrokeEvents(),Kb.openAndFocusPanelOnArrowDownKey(this),Kb.toggleOnButtonClick(this))}_propagateArrowKeystrokeEvents(){this.keystrokes.set("arrowright",((e,t)=>{this.fire("arrowright"),t()})),this.keystrokes.set("arrowleft",((e,t)=>{this.fire("arrowleft"),t()}))}_repositionPanelOnOpen(){this.on("change:isOpen",((e,t,i)=>{if(!i)return;const n=dw._getOptimalPosition({element:this.panelView.element,target:this.buttonView.element,fitInViewport:!0,positions:this._panelPositions});this.panelView.position=n?n.name:this._panelPositions[0].name}))}focus(){this.buttonView.focus()}get _panelPositions(){const{southEast:e,southWest:t,northEast:i,northWest:n,westSouth:s,eastSouth:o,westNorth:r,eastNorth:a}=Zb;return"ltr"===this.locale.uiLanguageDirection?this.parentMenuView?[o,a,s,r]:[e,t,i,n]:this.parentMenuView?[s,r,o,a]:[t,e,n,i]}constructor(e){super(e);const t=this.bindTemplate;this.buttonView=new jb(e),this.buttonView.delegate("mouseenter").to(this),this.buttonView.bind("isOn","isEnabled").to(this,"isOpen","isEnabled"),this.panelView=new cw(e),this.panelView.bind("isVisible").to(this,"isOpen"),this.keystrokes=new ka,this.focusTracker=new ya,this.set("isOpen",!1),this.set("isEnabled",!0),this.set("panelPosition","w"),this.set("class",void 0),this.set("parentMenuView",null),this.setTemplate({tag:"div",attributes:{class:["ck","ck-menu-bar__menu",t.to("class"),t.if("isEnabled","ck-disabled",(e=>!e)),t.if("parentMenuView","ck-menu-bar__menu_top-level",(e=>!e))]},children:[this.buttonView,this.panelView]})}}dw._getOptimalPosition=$r;class hw extends $f{constructor(e){super(e),this.role="menu"}}class uw extends Hg{constructor(e){super(e),this.set({withText:!0,withKeystroke:!0,tooltip:!1,role:"menuitem"}),this.extendTemplate({attributes:{class:["ck-menu-bar__menu__item__button"]}})}}class mw extends Ug{constructor(e){super(e),this.set({withText:!0,withKeystroke:!0,tooltip:!1,role:"menuitem"}),this.extendTemplate({attributes:{class:["ck-menu-bar__menu__item__button"]}})}}const gw=["mouseenter","arrowleft","arrowright","change:isOpen"];class fw extends Tg{fillFromConfig(e,t){const i=Yb({normalizedConfig:e,locale:this.locale,componentFactory:t}).items.map((e=>this._createMenu({componentFactory:t,menuDefinition:e})));this.children.addMany(i)}render(){super.render(),Gb.toggleMenusAndFocusItemsOnHover(this),Gb.closeMenusWhenTheBarCloses(this),Gb.closeMenuWhenAnotherOnTheSameLevelOpens(this),Gb.focusCycleMenusOnArrows(this),Gb.closeOnClickOutside(this)}focus(){this.children.first&&this.children.first.focus()}close(){for(const e of this.children)e.isOpen=!1}registerMenu(e,t=null){t?(e.delegate(...gw).to(t),e.parentMenuView=t):e.delegate(...gw).to(this,(e=>"menu:"+e)),e._attachBehaviors(),this.menus.push(e)}_createMenu({componentFactory:e,menuDefinition:t,parentMenuView:i}){const n=this.locale,s=new dw(n);return this.registerMenu(s,i),s.buttonView.set({label:t.label}),s.once("change:isOpen",(()=>{const i=new hw(n);i.ariaLabel=t.label,s.panelView.children.add(i),i.items.addMany(this._createMenuItems({menuDefinition:t,parentMenuView:s,componentFactory:e}))})),s}_createMenuItems({menuDefinition:e,parentMenuView:t,componentFactory:i}){const n=this.locale,s=[];for(const o of e.groups){for(const e of o.items){const o=new qb(n,t);if(re(e))o.children.add(this._createMenu({componentFactory:i,menuDefinition:e,parentMenuView:t}));else{const n=this._createMenuItemContentFromFactory({componentName:e,componentFactory:i,parentMenuView:t});if(!n)continue;o.children.add(n)}s.push(o)}o!==e.groups[e.groups.length-1]&&s.push(new zf(n))}return s}_createMenuItemContentFromFactory({componentName:e,parentMenuView:t,componentFactory:i}){const n=i.create(e);return n instanceof dw||n instanceof uw||n instanceof mw?(this._registerMenuTree(n,t),n.on("execute",(()=>{this.close()})),n):(b("menu-bar-component-unsupported",{componentName:e,componentView:n}),null)}_registerMenuTree(e,t){if(!(e instanceof dw))return void e.delegate("mouseenter").to(t);this.registerMenu(e,t);const i=e.panelView.children.filter((e=>e instanceof hw))[0];if(!i)return void e.delegate("mouseenter").to(t);const n=i.items.filter((e=>e instanceof Df));for(const t of n)this._registerMenuTree(t.children.get(0),e)}_setupIsOpenUpdater(){let e;this.on("menu:change:isOpen",((t,i,n)=>{clearTimeout(e),n?this.isOpen=!0:e=setTimeout((()=>{this.isOpen=Array.from(this.children).some((e=>e.isOpen))}),0)}))}constructor(e){super(e),this.menus=[];const t=e.t;this.set("isOpen",!1),this._setupIsOpenUpdater(),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-menu-bar"],"aria-label":t("Editor menu bar"),role:"menubar"},children:this.children})}}const pw=new Map([["left",Dm.alignLeft],["right",Dm.alignRight],["center",Dm.alignCenter],["justify",Dm.alignJustify]]);class bw extends Na{get localizedOptionTitles(){const e=this.editor.t;return{left:e("Align left"),right:e("Align right"),center:e("Align center"),justify:e("Justify")}}static get pluginName(){return"AlignmentUI"}init(){const e=tg(this.editor.config.get("alignment.options"));e.map((e=>e.name)).filter(Xm).forEach((e=>this._addButton(e))),this._addToolbarDropdown(e),this._addMenuBarMenu(e)}_addButton(e){this.editor.ui.componentFactory.add(`alignment:${e}`,(t=>this._createButton(t,e)))}_createButton(e,t,i={}){const n=this.editor,s=n.commands.get("alignment"),o=new Hg(e);return o.set({label:this.localizedOptionTitles[t],icon:pw.get(t),tooltip:!0,isToggleable:!0,...i}),o.bind("isEnabled").to(s),o.bind("isOn").to(s,"value",(e=>e===t)),this.listenTo(o,"execute",(()=>{n.execute("alignment",{value:t}),n.editing.view.focus()})),o}_addToolbarDropdown(e){const t=this.editor;t.ui.componentFactory.add("alignment",(i=>{const n=Wf(i),s="rtl"===i.uiLanguageDirection?"w":"e",o=i.t;jf(n,(()=>e.map((e=>this._createButton(i,e.name,{tooltipPosition:s})))),{enableActiveItemFocusOnDropdownOpen:!0,isVertical:!0,ariaLabel:o("Text alignment toolbar")}),n.buttonView.set({label:o("Text alignment"),tooltip:!0}),n.extendTemplate({attributes:{class:"ck-alignment-dropdown"}});const r="rtl"===i.contentLanguageDirection?pw.get("right"):pw.get("left"),a=t.commands.get("alignment");return n.buttonView.bind("icon").to(a,"value",(e=>pw.get(e)||r)),n.bind("isEnabled").to(a,"isEnabled"),this.listenTo(n,"execute",(()=>{t.editing.view.focus()})),n}))}_addMenuBarMenu(e){const t=this.editor;t.ui.componentFactory.add("menuBar:alignment",(i=>{const n=t.commands.get("alignment"),s=i.t,o=new dw(i),r=new hw(i);o.bind("isEnabled").to(n),r.set({ariaLabel:s("Text alignment"),role:"menu"}),o.buttonView.set({label:s("Text alignment")});for(const s of e){const e=new qb(i,o),a=new uw(i);a.extendTemplate({attributes:{"aria-checked":a.bindTemplate.to("isOn")}}),a.delegate("execute").to(o),a.set({label:this.localizedOptionTitles[s.name],icon:pw.get(s.name)}),a.on("execute",(()=>{t.execute("alignment",{value:s.name}),t.editing.view.focus()})),a.bind("isOn").to(n,"value",(e=>e===s.name)),a.bind("isEnabled").to(n,"isEnabled"),e.children.add(a),r.items.add(e)}return o.panelView.children.add(r),o}))}}class ww extends Na{static get requires(){return[sg,bw]}static get pluginName(){return"Alignment"}}class vw{get batch(){return this._batch||(this._batch=this.model.createBatch({isTyping:!0})),this._batch}get size(){return this._size}input(e){this._size+=e,this._size>=this.limit&&this._reset(!0)}get isLocked(){return this._isLocked}lock(){this._isLocked=!0}unlock(){this._isLocked=!1}destroy(){this.model.document.off("change",this._changeCallback),this.model.document.selection.off("change:range",this._selectionChangeCallback),this.model.document.selection.off("change:attribute",this._selectionChangeCallback)}_reset(e=!1){this.isLocked&&!e||(this._batch=null,this._size=0)}constructor(e,t=20){this._batch=null,this.model=e,this._size=0,this.limit=t,this._isLocked=!1,this._changeCallback=(e,t)=>{t.isLocal&&t.isUndoable&&t!==this._batch&&this._reset(!0)},this._selectionChangeCallback=()=>{this._reset()},this.model.document.on("change",this._changeCallback),this.model.document.selection.on("change:range",this._selectionChangeCallback),this.model.document.selection.on("change:attribute",this._selectionChangeCallback)}}class _w extends Da{get buffer(){return this._buffer}destroy(){super.destroy(),this._buffer.destroy()}execute(e={}){const t=this.editor.model,i=t.document,n=e.text||"",s=n.length;let o=i.selection;if(e.selection?o=e.selection:e.range&&(o=t.createSelection(e.range)),!t.canEditAt(o))return;const r=e.resultRange;t.enqueueChange(this._buffer.batch,(e=>{this._buffer.lock();const a=Array.from(i.selection.getAttributes());t.deleteContent(o),n&&t.insertContent(e.createText(n,a),o),r?e.setSelection(r):o.is("documentSelection")||e.setSelection(o),this._buffer.unlock(),this._buffer.input(s)}))}constructor(e,t){super(e),this._buffer=new vw(e.model,t),this._isEnabledBasedOnSelection=!1}}const yw=["insertText","insertReplacementText"];class kw extends Ec{observe(){}stopObserving(){}constructor(e){super(e),this.focusObserver=e.getObserver(Bc),i.isAndroid&&yw.push("insertCompositionText");const t=e.document;t.on("beforeinput",((i,n)=>{if(!this.isEnabled)return;const{data:s,targetRanges:o,inputType:r,domEvent:a}=n;if(!yw.includes(r))return;this.focusObserver.flush();const l=new d(t,"insertText");t.fire(l,new Tc(e,a,{text:s,selection:e.createSelection(o)})),l.stop.called&&i.stop()})),t.on("compositionend",((n,{data:s,domEvent:o})=>{this.isEnabled&&!i.isAndroid&&s&&t.fire("insertText",new Tc(e,o,{text:s,selection:t.selection}))}),{priority:"lowest"})}}class Cw extends Na{static get pluginName(){return"Input"}init(){const e=this.editor,t=e.model,n=e.editing.view,s=t.document.selection;n.addObserver(kw);const o=new _w(e,e.config.get("typing.undoStep")||20);e.commands.add("insertText",o),e.commands.add("input",o),this.listenTo(n.document,"insertText",((s,o)=>{n.document.isComposing||o.preventDefault();const{text:r,selection:a,resultRange:l}=o,c=Array.from(a.getRanges()).map((t=>e.editing.mapper.toModelRange(t)));let d=r;if(i.isAndroid){const e=Array.from(c[0].getItems()).reduce(((e,t)=>e+(t.is("$textProxy")?t.data:"")),"");e&&(e.length<=d.length?d.startsWith(e)&&(d=d.substring(e.length),c[0].start=c[0].start.getShiftedBy(e.length)):e.startsWith(d)&&(c[0].start=c[0].start.getShiftedBy(d.length),d=""))}const h={text:d,selection:t.createSelection(c)};l&&(h.resultRange=e.editing.mapper.toModelRange(l)),e.execute("insertText",h),n.scrollToTheSelection()})),i.isAndroid?this.listenTo(n.document,"keydown",((e,i)=>{!s.isCollapsed&&229==i.keyCode&&n.document.isComposing&&xw(t,o)})):this.listenTo(n.document,"compositionstart",(()=>{s.isCollapsed||xw(t,o)}))}}function xw(e,t){if(!t.isEnabled)return;const i=t.buffer;i.lock(),e.enqueueChange(i.batch,(()=>{e.deleteContent(e.document.selection)})),i.unlock()}class Aw extends Da{get buffer(){return this._buffer}execute(e={}){const t=this.editor.model,i=t.document;t.enqueueChange(this._buffer.batch,(n=>{this._buffer.lock();const s=n.createSelection(e.selection||i.selection);if(!t.canEditAt(s))return;const o=e.sequence||1,r=s.isCollapsed;if(s.isCollapsed&&t.modifySelection(s,{direction:this.direction,unit:e.unit,treatEmojiAsSingleUnit:!0}),this._shouldEntireContentBeReplacedWithParagraph(o))return void this._replaceEntireContentWithParagraph(n);if(this._shouldReplaceFirstBlockWithParagraph(s,o))return void this.editor.execute("paragraph",{selection:s});if(s.isCollapsed)return;let a=0;s.getFirstRange().getMinimalFlatRanges().forEach((e=>{a+=rr(e.getWalker({singleCharacters:!0,ignoreElementEnd:!0,shallow:!0}))})),t.deleteContent(s,{doNotResetEntireContent:r,direction:this.direction}),this._buffer.input(a),n.setSelection(s),this._buffer.unlock()}))}_shouldEntireContentBeReplacedWithParagraph(e){if(e>1)return!1;const t=this.editor.model,i=t.document.selection,n=t.schema.getLimitElement(i);if(!(i.isCollapsed&&i.containsEntireContent(n)))return!1;if(!t.schema.checkChild(n,"paragraph"))return!1;const s=n.getChild(0);return!s||!s.is("element","paragraph")}_replaceEntireContentWithParagraph(e){const t=this.editor.model,i=t.document.selection,n=t.schema.getLimitElement(i),s=e.createElement("paragraph");e.remove(e.createRangeIn(n)),e.insert(s,n),e.setSelection(s,0)}_shouldReplaceFirstBlockWithParagraph(e,t){const i=this.editor.model;if(t>1||"backward"!=this.direction)return!1;if(!e.isCollapsed)return!1;const n=e.getFirstPosition(),s=i.schema.getLimitElement(n),o=s.getChild(0);return n.parent==o&&(!!e.containsEntireContent(o)&&(!!i.schema.checkChild(s,"paragraph")&&"paragraph"!=o.name))}constructor(e,t){super(e),this.direction=t,this._buffer=new vw(e.model,e.config.get("typing.undoStep")),this._isEnabledBasedOnSelection=!1}}const Ew="word",Tw="selection",Sw="backward",Iw="forward",Pw={deleteContent:{unit:Tw,direction:Sw},deleteContentBackward:{unit:"codePoint",direction:Sw},deleteWordBackward:{unit:Ew,direction:Sw},deleteHardLineBackward:{unit:Tw,direction:Sw},deleteSoftLineBackward:{unit:Tw,direction:Sw},deleteContentForward:{unit:"character",direction:Iw},deleteWordForward:{unit:Ew,direction:Iw},deleteHardLineForward:{unit:Tw,direction:Iw},deleteSoftLineForward:{unit:Tw,direction:Iw}};class Vw extends Ec{observe(){}stopObserving(){}constructor(e){super(e);const t=e.document;let n=0;t.on("keydown",(()=>{n++})),t.on("keyup",(()=>{n=0})),t.on("beforeinput",((s,o)=>{if(!this.isEnabled)return;const{targetRanges:r,domEvent:a,inputType:l}=o,c=Pw[l];if(!c)return;const d={direction:c.direction,unit:c.unit,sequence:n};d.unit==Tw&&(d.selectionToRemove=e.createSelection(r[0])),"deleteContentBackward"===l&&(i.isAndroid&&(d.sequence=1),function(e){if(1!=e.length||e[0].isCollapsed)return!1;const t=e[0].getWalker({direction:"backward",singleCharacters:!0,ignoreElementEnd:!0});let i=0;for(const{nextPosition:e}of t){if(e.parent.is("$text")){const t=e.parent.data,n=e.offset;if(Ba(t,n)||Oa(t,n)||La(t,n))continue;i++}else i++;if(i>1)return!0}return!1}(r)&&(d.unit=Tw,d.selectionToRemove=e.createSelection(r)));const h=new Al(t,"delete",r[0]);t.fire(h,new Tc(e,a,d)),h.stop.called&&s.stop()})),i.isBlink&&function(e){const t=e.view,i=t.document;let n=null,s=!1;function o(e){return e==ra.backspace||e==ra.delete}function r(e){return e==ra.backspace?Sw:Iw}i.on("keydown",((e,{keyCode:t})=>{n=t,s=!1})),i.on("keyup",((a,{keyCode:l,domEvent:c})=>{const d=i.selection,h=e.isEnabled&&l==n&&o(l)&&!d.isCollapsed&&!s;if(n=null,h){const e=d.getFirstRange(),n=new Al(i,"delete",e),s={unit:Tw,direction:r(l),selectionToRemove:d};i.fire(n,new Tc(t,c,s))}})),i.on("beforeinput",((e,{inputType:t})=>{const i=Pw[t];o(n)&&i&&i.direction==r(n)&&(s=!0)}),{priority:"high"}),i.on("beforeinput",((e,{inputType:t,data:i})=>{n==ra.delete&&"insertText"==t&&""==i&&e.stop()}),{priority:"high"})}(this)}}class Rw extends Na{static get pluginName(){return"Delete"}init(){const e=this.editor,t=e.editing.view,i=t.document,n=e.model.document;t.addObserver(Vw),this._undoOnBackspace=!1;const s=new Aw(e,"forward");e.commands.add("deleteForward",s),e.commands.add("forwardDelete",s),e.commands.add("delete",new Aw(e,"backward")),this.listenTo(i,"delete",((n,s)=>{i.isComposing||s.preventDefault();const{direction:o,sequence:r,selectionToRemove:a,unit:l}=s,c="forward"===o?"deleteForward":"delete",d={sequence:r};if("selection"==l){const t=Array.from(a.getRanges()).map((t=>e.editing.mapper.toModelRange(t)));d.selection=e.model.createSelection(t)}else d.unit=l;e.execute(c,d),t.scrollToTheSelection()}),{priority:"low"}),this.editor.plugins.has("UndoEditing")&&(this.listenTo(i,"delete",((t,i)=>{this._undoOnBackspace&&"backward"==i.direction&&1==i.sequence&&"codePoint"==i.unit&&(this._undoOnBackspace=!1,e.execute("undo"),i.preventDefault(),t.stop())}),{context:"$capture"}),this.listenTo(n,"change",(()=>{this._undoOnBackspace=!1})))}requestUndoOnBackspace(){this.editor.plugins.has("UndoEditing")&&(this._undoOnBackspace=!0)}}class Bw extends Na{static get requires(){return[Cw,Rw]}static get pluginName(){return"Typing"}}function Ow(e,t){let i=e.start;return{text:Array.from(e.getWalker({ignoreElementEnd:!1})).reduce(((e,{item:n})=>n.is("$text")||n.is("$textProxy")?e+n.data:(i=t.createPositionAfter(n),"")),""),range:t.createRange(i,e.end)}}class Mw extends(Yo()){get hasMatch(){return this._hasMatch}_startListening(){const e=this.model.document;this.listenTo(e.selection,"change:range",((t,{directChange:i})=>{i&&(e.selection.isCollapsed?this._evaluateTextBeforeSelection("selection"):this.hasMatch&&(this.fire("unmatched"),this._hasMatch=!1))})),this.listenTo(e,"change:data",((e,t)=>{!t.isUndo&&t.isLocal&&this._evaluateTextBeforeSelection("data",{batch:t})}))}_evaluateTextBeforeSelection(e,t={}){const i=this.model,n=i.document.selection,s=i.createRange(i.createPositionAt(n.focus.parent,0),n.focus),{text:o,range:r}=Ow(s,i),a=this.testCallback(o);if(!a&&this.hasMatch&&this.fire("unmatched"),this._hasMatch=!!a,a){const i=Object.assign(t,{text:o,range:r});"object"==typeof a&&Object.assign(i,a),this.fire(`matched:${e}`,i)}}constructor(e,t){super(),this.model=e,this.testCallback=t,this._hasMatch=!1,this.set("isEnabled",!0),this.on("change:isEnabled",(()=>{this.isEnabled?this._startListening():(this.stopListening(e.document.selection),this.stopListening(e.document))})),this._startListening()}}class Lw extends Na{static get pluginName(){return"TwoStepCaretMovement"}init(){const e=this.editor,t=e.model,i=e.editing.view,n=e.locale,s=t.document.selection;this.listenTo(i.document,"arrowKey",((e,t)=>{if(!s.isCollapsed)return;if(t.shiftKey||t.altKey||t.ctrlKey)return;const i=t.keyCode==ra.arrowright,o=t.keyCode==ra.arrowleft;if(!i&&!o)return;const r=n.contentLanguageDirection;let a=!1;a="ltr"===r&&i||"rtl"===r&&o?this._handleForwardMovement(t):this._handleBackwardMovement(t),!0===a&&e.stop()}),{context:"$text",priority:"highest"}),this.listenTo(s,"change:range",((e,t)=>{this._isNextGravityRestorationSkipped?this._isNextGravityRestorationSkipped=!1:this._isGravityOverridden&&(!t.directChange&&$w(s.getFirstPosition(),this.attributes)||this._restoreGravity())})),this._enableClickingAfterNode(),this._enableInsertContentSelectionAttributesFixer(),this._handleDeleteContentAfterNode()}registerAttribute(e){this.attributes.add(e)}_handleForwardMovement(e){const t=this.attributes,i=this.editor.model,n=i.document.selection,s=n.getFirstPosition();return!this._isGravityOverridden&&((!s.isAtStart||!Nw(n,t))&&(!!$w(s,t)&&(zw(e),Nw(n,t)&&$w(s,t,!0)?Dw(i,t):this._overrideGravity(),!0)))}_handleBackwardMovement(e){const t=this.attributes,i=this.editor.model,n=i.document.selection,s=n.getFirstPosition();return this._isGravityOverridden?(zw(e),this._restoreGravity(),$w(s,t,!0)?Dw(i,t):Fw(i,t,s),!0):s.isAtStart?!!Nw(n,t)&&(zw(e),Fw(i,t,s),!0):!Nw(n,t)&&$w(s,t,!0)?(zw(e),Fw(i,t,s),!0):!!Hw(s,t)&&(s.isAtEnd&&!Nw(n,t)&&$w(s,t)?(zw(e),Fw(i,t,s),!0):(this._isNextGravityRestorationSkipped=!0,this._overrideGravity(),!1))}_enableClickingAfterNode(){const e=this.editor,t=e.model,i=t.document.selection,n=e.editing.view.document;e.editing.view.addObserver(zu);let s=!1;this.listenTo(n,"mousedown",(()=>{s=!0})),this.listenTo(n,"selectionChange",(()=>{const e=this.attributes;if(!s)return;if(s=!1,!i.isCollapsed)return;if(!Nw(i,e))return;const n=i.getFirstPosition();$w(n,e)&&(n.isAtStart||$w(n,e,!0)?Dw(t,e):this._isGravityOverridden||this._overrideGravity())}))}_enableInsertContentSelectionAttributesFixer(){const e=this.editor.model,t=e.document.selection,i=this.attributes;this.listenTo(e,"insertContent",(()=>{const n=t.getFirstPosition();Nw(t,i)&&$w(n,i)&&Dw(e,i)}),{priority:"low"})}_handleDeleteContentAfterNode(){const e=this.editor,t=e.model,i=t.document.selection,n=e.editing.view;let s=!1,o=!1;this.listenTo(n.document,"delete",((e,t)=>{s="backward"===t.direction}),{priority:"high"}),this.listenTo(t,"deleteContent",(()=>{if(!s)return;const e=i.getFirstPosition();o=Nw(i,this.attributes)&&!Hw(e,this.attributes)}),{priority:"high"}),this.listenTo(t,"deleteContent",(()=>{s&&(s=!1,o||e.model.enqueueChange((()=>{const e=i.getFirstPosition();Nw(i,this.attributes)&&$w(e,this.attributes)&&(e.isAtStart||$w(e,this.attributes,!0)?Dw(t,this.attributes):this._isGravityOverridden||this._overrideGravity())})))}),{priority:"low"})}get _isGravityOverridden(){return!!this._overrideUid}_overrideGravity(){this._overrideUid=this.editor.model.change((e=>e.overrideSelectionGravity()))}_restoreGravity(){this.editor.model.change((e=>{e.restoreSelectionGravity(this._overrideUid),this._overrideUid=null}))}constructor(e){super(e),this._isNextGravityRestorationSkipped=!1,this.attributes=new Set,this._overrideUid=null}}function Nw(e,t){for(const i of t)if(e.hasAttribute(i))return!0;return!1}function Fw(e,t,i){const n=i.nodeBefore;e.change((i=>{if(n){const t=[],s=e.schema.isObject(n)&&e.schema.isInline(n);for(const[i,o]of n.getAttributes())!e.schema.checkAttribute("$text",i)||s&&!1===e.schema.getAttributeProperties(i).copyFromObject||t.push([i,o]);i.setSelectionAttribute(t)}else i.removeSelectionAttribute(t)}))}function Dw(e,t){e.change((e=>{e.removeSelectionAttribute(t)}))}function zw(e){e.preventDefault()}function Hw(e,t){return $w(e.getShiftedBy(-1),t)}function $w(e,t,i=!1){const{nodeBefore:n,nodeAfter:s}=e;for(const e of t){const t=n?n.getAttribute(e):void 0,o=s?s.getAttribute(e):void 0;if((!i||void 0!==t&&void 0!==o)&&o!==t)return!0}return!1}const Uw={copyright:{from:"(c)",to:"©"},registeredTrademark:{from:"(r)",to:"®"},trademark:{from:"(tm)",to:"™"},oneHalf:{from:/(^|[^/a-z0-9])(1\/2)([^/a-z0-9])$/i,to:[null,"½",null]},oneThird:{from:/(^|[^/a-z0-9])(1\/3)([^/a-z0-9])$/i,to:[null,"⅓",null]},twoThirds:{from:/(^|[^/a-z0-9])(2\/3)([^/a-z0-9])$/i,to:[null,"⅔",null]},oneForth:{from:/(^|[^/a-z0-9])(1\/4)([^/a-z0-9])$/i,to:[null,"¼",null]},threeQuarters:{from:/(^|[^/a-z0-9])(3\/4)([^/a-z0-9])$/i,to:[null,"¾",null]},lessThanOrEqual:{from:"<=",to:"≤"},greaterThanOrEqual:{from:">=",to:"≥"},notEqual:{from:"!=",to:"≠"},arrowLeft:{from:"<-",to:"←"},arrowRight:{from:"->",to:"→"},horizontalEllipsis:{from:"...",to:"…"},enDash:{from:/(^| )(--)( )$/,to:[null,"–",null]},emDash:{from:/(^| )(---)( )$/,to:[null,"—",null]},quotesPrimary:{from:Jw('"'),to:[null,"“",null,"”"]},quotesSecondary:{from:Jw("'"),to:[null,"‘",null,"’"]},quotesPrimaryEnGb:{from:Jw("'"),to:[null,"‘",null,"’"]},quotesSecondaryEnGb:{from:Jw('"'),to:[null,"“",null,"”"]},quotesPrimaryPl:{from:Jw('"'),to:[null,"„",null,"”"]},quotesSecondaryPl:{from:Jw("'"),to:[null,"‚",null,"’"]}},Ww={symbols:["copyright","registeredTrademark","trademark"],mathematical:["oneHalf","oneThird","twoThirds","oneForth","threeQuarters","lessThanOrEqual","greaterThanOrEqual","notEqual","arrowLeft","arrowRight"],typography:["horizontalEllipsis","enDash","emDash"],quotes:["quotesPrimary","quotesSecondary"]},jw=["symbols","mathematical","typography","quotes"];class qw extends Na{static get requires(){return["Delete","Input"]}static get pluginName(){return"TextTransformation"}init(){const e=this.editor.model.document.selection;e.on("change:range",(()=>{this.isEnabled=!e.anchor.parent.is("element","codeBlock")})),this._enableTransformationWatchers()}_enableTransformationWatchers(){const e=this.editor,t=e.model,i=e.plugins.get("Delete"),n=function(e){const t=e.extra||[],i=e.remove||[],n=e=>!i.includes(e);return function(e){const t=new Set;for(const i of e)if("string"==typeof i&&Ww[i])for(const e of Ww[i])t.add(e);else t.add(i);return Array.from(t)}(e.include.concat(t).filter(n)).filter(n).map((e=>"string"==typeof e&&Uw[e]?Uw[e]:e)).filter((e=>"object"==typeof e)).map((e=>({from:Gw(e.from),to:Kw(e.to)})))}(e.config.get("typing.transformations")),s=new Mw(e.model,(e=>{for(const t of n){if(t.from.test(e))return{normalizedTransformation:t}}}));s.on("matched:data",((e,n)=>{if(!n.batch.isTyping)return;const{from:s,to:o}=n.normalizedTransformation,r=s.exec(n.text),a=o(r.slice(1)),l=n.range;let c=r.index;t.enqueueChange((e=>{for(let i=1;i<r.length;i++){const n=r[i],s=a[i-1];if(null==s){c+=n.length;continue}const o=l.start.getShiftedBy(c),d=t.createRange(o,o.getShiftedBy(n.length)),h=Zw(o);t.insertContent(e.createText(s,h),d),c+=s.length}t.enqueueChange((()=>{i.requestUndoOnBackspace()}))}))})),s.bind("isEnabled").to(this)}constructor(e){super(e),e.config.define("typing",{transformations:{include:jw}})}}function Gw(e){return"string"==typeof e?new RegExp(`(${Oo(e)})$`):e}function Kw(e){return"string"==typeof e?()=>[e]:e instanceof Array?()=>e:e}function Zw(e){return(e.textNode?e.textNode:e.nodeAfter).getAttributes()}function Jw(e){return new RegExp(`(^|\\s)(${e})([^${e}]*)(${e})$`)}function Qw(e,t,i,n){return n.createRange(Yw(e,t,i,!0,n),Yw(e,t,i,!1,n))}function Yw(e,t,i,n,s){let o=e.textNode||(n?e.nodeBefore:e.nodeAfter),r=null;for(;o&&o.getAttribute(t)==i;)r=o,o=n?o.previousSibling:o.nextSibling;return r?s.createPositionAt(r,n?"before":"after"):e}function Xw(e,t,i,n){const s=e.editing.view,o=new Set;s.document.registerPostFixer((s=>{const r=e.model.document.selection;let a=!1;if(r.hasAttribute(t)){const l=Qw(r.getFirstPosition(),t,r.getAttribute(t),e.model),c=e.editing.mapper.toViewRange(l);for(const e of c.getItems())e.is("element",i)&&!e.hasClass(n)&&(s.addClass(n,e),o.add(e),a=!0)}return a})),e.conversion.for("editingDowncast").add((e=>{function t(){s.change((e=>{for(const t of o.values())e.removeClass(n,t),o.delete(t)}))}e.on("insert",t,{priority:"highest"}),e.on("remove",t,{priority:"highest"}),e.on("attribute",t,{priority:"highest"}),e.on("selection",t,{priority:"highest"})}))}function ev(e,t,i,n){let s,o=null;"function"==typeof n?s=n:(o=e.commands.get(n),s=()=>{e.execute(n)}),e.model.document.on("change:data",((r,a)=>{if(o&&!o.isEnabled||!t.isEnabled)return;const l=_a(e.model.document.selection.getRanges());if(!l.isCollapsed)return;if(a.isUndo||!a.isLocal)return;const c=Array.from(e.model.document.differ.getChanges()),d=c[0];if(1!=c.length||"insert"!==d.type||"$text"!=d.name||1!=d.length)return;const h=d.position.parent;if(h.is("element","codeBlock"))return;if(h.is("element","listItem")&&"function"!=typeof n&&!["numberedList","bulletedList","todoList"].includes(n))return;if(o&&!0===o.value)return;const u=h.getChild(0),m=e.model.createRangeOn(u);if(!m.containsRange(l)&&!l.end.isEqual(m.end))return;const g=i.exec(u.data.substr(0,l.end.offset));g&&e.model.enqueueChange((t=>{const i=t.createPositionAt(h,0),n=t.createPositionAt(h,g[0].length),o=new pd(i,n);if(!1!==s({match:g})){t.remove(o);const i=e.model.document.selection.getFirstRange(),n=t.createRangeIn(h);!h.isEmpty||n.isEqual(i)||n.containsRange(i,!0)||t.remove(h)}o.detach(),e.model.enqueueChange((()=>{e.plugins.get("Delete").requestUndoOnBackspace()}))}))}))}function tv(e,t,i,n){let s,o;i instanceof RegExp?s=i:o=i,o=o||(e=>{let t;const i=[],n=[];for(;null!==(t=s.exec(e))&&!(t&&t.length<4);){let{index:e,1:s,2:o,3:r}=t;const a=s+o+r;e+=t[0].length-a.length;const l=[e,e+s.length],c=[e+s.length+o.length,e+s.length+o.length+r.length];i.push(l),i.push(c),n.push([e+s.length,e+s.length+o.length])}return{remove:i,format:n}}),e.model.document.on("change:data",((i,s)=>{if(s.isUndo||!s.isLocal||!t.isEnabled)return;const r=e.model,a=r.document.selection;if(!a.isCollapsed)return;const l=Array.from(r.document.differ.getChanges()),c=l[0];if(1!=l.length||"insert"!==c.type||"$text"!=c.name||1!=c.length)return;const d=a.focus,h=d.parent,{text:u,range:m}=function(e,t){let i=e.start;const n=Array.from(e.getItems()).reduce(((e,n)=>!n.is("$text")&&!n.is("$textProxy")||n.getAttribute("code")?(i=t.createPositionAfter(n),""):e+n.data),"");return{text:n,range:t.createRange(i,e.end)}}(r.createRange(r.createPositionAt(h,0),d),r),g=o(u),f=iv(m.start,g.format,r),p=iv(m.start,g.remove,r);f.length&&p.length&&r.enqueueChange((t=>{if(!1!==n(t,f)){for(const e of p.reverse())t.remove(e);r.enqueueChange((()=>{e.plugins.get("Delete").requestUndoOnBackspace()}))}}))}))}function iv(e,t,i){return t.filter((e=>void 0!==e[0]&&void 0!==e[1])).map((t=>i.createRange(e.getShiftedBy(t[0]),e.getShiftedBy(t[1]))))}class nv extends Na{static get requires(){return[Rw]}static get pluginName(){return"Autoformat"}afterInit(){const e=this.editor,t=this.editor.t;this._addListAutoformats(),this._addBasicStylesAutoformats(),this._addHeadingAutoformats(),this._addBlockQuoteAutoformats(),this._addCodeBlockAutoformats(),this._addHorizontalLineAutoformats(),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Revert autoformatting action"),keystroke:"Backspace"}]})}_addListAutoformats(){const e=this.editor.commands;e.get("bulletedList")&&ev(this.editor,this,/^[*-]\s$/,"bulletedList"),e.get("numberedList")&&ev(this.editor,this,/^1[.|)]\s$/,"numberedList"),e.get("todoList")&&ev(this.editor,this,/^\[\s?\]\s$/,"todoList"),e.get("checkTodoList")&&ev(this.editor,this,/^\[\s?x\s?\]\s$/,(()=>{this.editor.execute("todoList"),this.editor.execute("checkTodoList")}))}_addBasicStylesAutoformats(){const e=this.editor.commands;if(e.get("bold")){const e=sv(this.editor,"bold");tv(this.editor,this,/(?:^|\s)(\*\*)([^*]+)(\*\*)$/g,e),tv(this.editor,this,/(?:^|\s)(__)([^_]+)(__)$/g,e)}if(e.get("italic")){const e=sv(this.editor,"italic");tv(this.editor,this,/(?:^|\s)(\*)([^*_]+)(\*)$/g,e),tv(this.editor,this,/(?:^|\s)(_)([^_]+)(_)$/g,e)}if(e.get("code")){const e=sv(this.editor,"code");tv(this.editor,this,/(`)([^`]+)(`)$/g,e)}if(e.get("strikethrough")){const e=sv(this.editor,"strikethrough");tv(this.editor,this,/(~~)([^~]+)(~~)$/g,e)}}_addHeadingAutoformats(){const e=this.editor.commands.get("heading");e&&e.modelElements.filter((e=>e.match(/^heading[1-6]$/))).forEach((t=>{const i=t[7],n=new RegExp(`^(#{${i}})\\s$`);ev(this.editor,this,n,(()=>{if(!e.isEnabled||e.value===t)return!1;this.editor.execute("heading",{value:t})}))}))}_addBlockQuoteAutoformats(){this.editor.commands.get("blockQuote")&&ev(this.editor,this,/^>\s$/,"blockQuote")}_addCodeBlockAutoformats(){const e=this.editor,t=e.model.document.selection;e.commands.get("codeBlock")&&ev(e,this,/^```$/,(()=>{if(t.getFirstPosition().parent.is("element","listItem"))return!1;this.editor.execute("codeBlock",{usePreviousLanguageChoice:!0})}))}_addHorizontalLineAutoformats(){this.editor.commands.get("horizontalLine")&&ev(this.editor,this,/^---$/,"horizontalLine")}}function sv(e,t){return(i,n)=>{if(!e.commands.get(t).isEnabled)return!1;const s=e.model.schema.getValidRanges(n,t);for(const e of s)i.setAttribute(t,!0,e);i.removeSelectionAttribute(t)}}class ov extends Na{static get pluginName(){return"Autosave"}static get requires(){return[Fm]}init(){const e=this.editor,t=e.model.document;this.listenTo(e,"ready",(()=>{this.listenTo(t,"change:data",((e,t)=>{this._saveCallbacks.length&&t.isLocal&&("synchronized"===this.state&&(this.state="waiting",this._setPendingAction()),"waiting"===this.state&&this._debouncedSave())}))})),this.listenTo(e,"destroy",(()=>this._flush()),{priority:"highest"}),this._domEmitter.listenTo(window,"beforeunload",((e,t)=>{this._pendingActions.hasAny&&(t.returnValue=this._pendingActions.first.message)}))}destroy(){this._domEmitter.stopListening(),super.destroy()}save(){return this._debouncedSave.cancel(),this._save()}_flush(){this._debouncedSave.flush()}_save(){return this._savePromise?(this._makeImmediateSave=this.editor.model.document.version>this._lastDocumentVersion,this._savePromise):(this._setPendingAction(),this.state="saving",this._lastDocumentVersion=this.editor.model.document.version,this._savePromise=Promise.resolve().then((()=>Promise.all(this._saveCallbacks.map((e=>e(this.editor)))))).finally((()=>{this._savePromise=null})).then((()=>{if(this._makeImmediateSave)return this._makeImmediateSave=!1,this._save();this.editor.model.document.version>this._lastDocumentVersion?(this.state="waiting",this._debouncedSave()):(this.state="synchronized",this._pendingActions.remove(this._action),this._action=null)})).catch((e=>{throw this.state="error",this.state="saving",this._debouncedSave(),e})),this._savePromise)}_setPendingAction(){const e=this.editor.t;this._action||(this._action=this._pendingActions.add(e("Saving changes")))}get _saveCallbacks(){const e=[];return this.adapter&&this.adapter.save&&e.push(this.adapter.save),this._config.save&&e.push(this._config.save),e}constructor(e){super(e),this._action=null;const t=e.config.get("autosave")||{},i=t.waitingTime||1e3;this.set("state","synchronized"),this._debouncedSave=ko(this._save.bind(this),i),this._lastDocumentVersion=e.model.document.version,this._savePromise=null,this._domEmitter=new(pr()),this._config=t,this._pendingActions=e.plugins.get(Fm),this._makeImmediateSave=!1}}class rv extends Da{refresh(){const e=this.editor.model,t=e.document;this.value=this._getValueFromFirstAllowedNode(),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,this.attributeKey)}execute(e={}){const t=this.editor.model,i=t.document.selection,n=void 0===e.forceValue?!this.value:e.forceValue;t.change((e=>{if(i.isCollapsed)n?e.setSelectionAttribute(this.attributeKey,!0):e.removeSelectionAttribute(this.attributeKey);else{const s=t.schema.getValidRanges(i.getRanges(),this.attributeKey);for(const t of s)n?e.setAttribute(this.attributeKey,n,t):e.removeAttribute(this.attributeKey,t)}}))}_getValueFromFirstAllowedNode(){const e=this.editor.model,t=e.schema,i=e.document.selection;if(i.isCollapsed)return i.hasAttribute(this.attributeKey);for(const e of i.getRanges())for(const i of e.getItems())if(t.checkAttribute(i,this.attributeKey))return i.hasAttribute(this.attributeKey);return!1}constructor(e,t){super(e),this.attributeKey=t}}const av="bold";class lv extends Na{static get pluginName(){return"BoldEditing"}init(){const e=this.editor,t=this.editor.t;e.model.schema.extend("$text",{allowAttributes:av}),e.model.schema.setAttributeProperties(av,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:av,view:"strong",upcastAlso:["b",e=>{const t=e.getStyle("font-weight");return t&&("bold"==t||Number(t)>=600)?{name:!0,styles:["font-weight"]}:null}]}),e.commands.add(av,new rv(e,av)),e.keystrokes.set("CTRL+B",av),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Bold text"),keystroke:"CTRL+B"}]})}}function cv({editor:e,commandName:t,plugin:i,icon:n,label:s,keystroke:o}){return r=>{const a=e.commands.get(t),l=new r(e.locale);return l.set({label:s,icon:n,keystroke:o,isToggleable:!0}),l.bind("isEnabled").to(a,"isEnabled"),i.listenTo(l,"execute",(()=>{e.execute(t),e.editing.view.focus()})),l}}const dv="bold";class hv extends Na{static get pluginName(){return"BoldUI"}init(){const e=this.editor,t=e.locale.t,i=e.commands.get(dv),n=cv({editor:e,commandName:dv,plugin:this,icon:Dm.bold,label:t("Bold"),keystroke:"CTRL+B"});e.ui.componentFactory.add(dv,(()=>{const e=n(Hg);return e.set({tooltip:!0}),e.bind("isOn").to(i,"value"),e})),e.ui.componentFactory.add("menuBar:"+dv,(()=>n(uw)))}}class uv extends Na{static get requires(){return[lv,hv]}static get pluginName(){return"Bold"}}const mv="code";class gv extends Na{static get pluginName(){return"CodeEditing"}static get requires(){return[Lw]}init(){const e=this.editor,t=this.editor.t;e.model.schema.extend("$text",{allowAttributes:mv}),e.model.schema.setAttributeProperties(mv,{isFormatting:!0,copyOnEnter:!1}),e.conversion.attributeToElement({model:mv,view:"code",upcastAlso:{styles:{"word-wrap":"break-word"}}}),e.commands.add(mv,new rv(e,mv)),e.plugins.get(Lw).registerAttribute(mv),Xw(e,mv,"code","ck-code_selected"),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Move out of an inline code style"),keystroke:[["arrowleft","arrowleft"],["arrowright","arrowright"]]}]})}}const fv="code";class pv extends Na{static get pluginName(){return"CodeUI"}init(){const e=this.editor,t=e.locale.t,i=cv({editor:e,commandName:fv,plugin:this,icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m12.5 5.7 5.2 3.9v1.3l-5.6 4c-.1.2-.3.2-.5.2-.3-.1-.6-.7-.6-1l.3-.4 4.7-3.5L11.5 7l-.2-.2c-.1-.3-.1-.6 0-.8.2-.2.5-.4.8-.4a.8.8 0 0 1 .4.1zm-5.2 0L2 9.6v1.3l5.6 4c.1.2.3.2.5.2.3-.1.7-.7.6-1 0-.1 0-.3-.2-.4l-5-3.5L8.2 7l.2-.2c.1-.3.1-.6 0-.8-.2-.2-.5-.4-.8-.4a.8.8 0 0 0-.3.1z"/></svg>',label:t("Code")});e.ui.componentFactory.add(fv,(()=>{const t=i(Hg),n=e.commands.get(fv);return t.set({tooltip:!0}),t.bind("isOn").to(n,"value"),t})),e.ui.componentFactory.add("menuBar:"+fv,(()=>i(uw)))}}class bv extends Na{static get requires(){return[gv,pv]}static get pluginName(){return"Code"}}const wv="italic";class vv extends Na{static get pluginName(){return"ItalicEditing"}init(){const e=this.editor,t=this.editor.t;e.model.schema.extend("$text",{allowAttributes:wv}),e.model.schema.setAttributeProperties(wv,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:wv,view:"i",upcastAlso:["em",{styles:{"font-style":"italic"}}]}),e.commands.add(wv,new rv(e,wv)),e.keystrokes.set("CTRL+I",wv),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Italic text"),keystroke:"CTRL+I"}]})}}const _v="italic";class yv extends Na{static get pluginName(){return"ItalicUI"}init(){const e=this.editor,t=e.commands.get(_v),i=e.locale.t,n=cv({editor:e,commandName:_v,plugin:this,icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m9.586 14.633.021.004c-.036.335.095.655.393.962.082.083.173.15.274.201h1.474a.6.6 0 1 1 0 1.2H5.304a.6.6 0 0 1 0-1.2h1.15c.474-.07.809-.182 1.005-.334.157-.122.291-.32.404-.597l2.416-9.55a1.053 1.053 0 0 0-.281-.823 1.12 1.12 0 0 0-.442-.296H8.15a.6.6 0 0 1 0-1.2h6.443a.6.6 0 1 1 0 1.2h-1.195c-.376.056-.65.155-.823.296-.215.175-.423.439-.623.79l-2.366 9.347z"/></svg>',keystroke:"CTRL+I",label:i("Italic")});e.ui.componentFactory.add(_v,(()=>{const e=n(Hg);return e.set({tooltip:!0}),e.bind("isOn").to(t,"value"),e})),e.ui.componentFactory.add("menuBar:"+_v,(()=>n(uw)))}}class kv extends Na{static get requires(){return[vv,yv]}static get pluginName(){return"Italic"}}const Cv="strikethrough";class xv extends Na{static get pluginName(){return"StrikethroughEditing"}init(){const e=this.editor,t=this.editor.t;e.model.schema.extend("$text",{allowAttributes:Cv}),e.model.schema.setAttributeProperties(Cv,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:Cv,view:"s",upcastAlso:["del","strike",{styles:{"text-decoration":"line-through"}}]}),e.commands.add(Cv,new rv(e,Cv)),e.keystrokes.set("CTRL+SHIFT+X","strikethrough"),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Strikethrough text"),keystroke:"CTRL+SHIFT+X"}]})}}const Av="strikethrough";class Ev extends Na{static get pluginName(){return"StrikethroughUI"}init(){const e=this.editor,t=e.locale.t,i=cv({editor:e,commandName:Av,plugin:this,icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M7 16.4c-.8-.4-1.5-.9-2.2-1.5a.6.6 0 0 1-.2-.5l.3-.6h1c1 1.2 2.1 1.7 3.7 1.7 1 0 1.8-.3 2.3-.6.6-.4.6-1.2.6-1.3.2-1.2-.9-2.1-.9-2.1h2.1c.3.7.4 1.2.4 1.7v.8l-.6 1.2c-.6.8-1.1 1-1.6 1.2a6 6 0 0 1-2.4.6c-1 0-1.8-.3-2.5-.6zM6.8 9 6 8.3c-.4-.5-.5-.8-.5-1.6 0-.7.1-1.3.5-1.8.4-.6 1-1 1.6-1.3a6.3 6.3 0 0 1 4.7 0 4 4 0 0 1 1.7 1l.3.7c0 .1.2.4-.2.7-.4.2-.9.1-1 0a3 3 0 0 0-1.2-1c-.4-.2-1-.3-2-.4-.7 0-1.4.2-2 .6-.8.6-1 .8-1 1.5 0 .8.5 1 1.2 1.5.6.4 1.1.7 1.9 1H6.8z"/><path d="M3 10.5V9h14v1.5z"/></svg>',keystroke:"CTRL+SHIFT+X",label:t("Strikethrough")});e.ui.componentFactory.add(Av,(()=>{const t=i(Hg),n=e.commands.get(Av);return t.set({tooltip:!0}),t.bind("isOn").to(n,"value"),t})),e.ui.componentFactory.add("menuBar:"+Av,(()=>i(uw)))}}class Tv extends Na{static get requires(){return[xv,Ev]}static get pluginName(){return"Strikethrough"}}const Sv="subscript";class Iv extends Na{static get pluginName(){return"SubscriptEditing"}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:Sv}),e.model.schema.setAttributeProperties(Sv,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:Sv,view:"sub",upcastAlso:[{styles:{"vertical-align":"sub"}}]}),e.commands.add(Sv,new rv(e,Sv))}}const Pv="subscript";class Vv extends Na{static get pluginName(){return"SubscriptUI"}init(){const e=this.editor,t=e.locale.t,i=cv({editor:e,commandName:Pv,plugin:this,icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m7.03 10.349 3.818-3.819a.8.8 0 1 1 1.132 1.132L8.16 11.48l3.819 3.818a.8.8 0 1 1-1.132 1.132L7.03 12.61l-3.818 3.82a.8.8 0 1 1-1.132-1.132L5.9 11.48 2.08 7.662A.8.8 0 1 1 3.212 6.53l3.818 3.82zm8.147 7.829h2.549c.254 0 .447.05.58.152a.49.49 0 0 1 .201.413.54.54 0 0 1-.159.393c-.105.108-.266.162-.48.162h-3.594c-.245 0-.435-.066-.572-.197a.621.621 0 0 1-.205-.463c0-.114.044-.265.132-.453a1.62 1.62 0 0 1 .288-.444c.433-.436.824-.81 1.172-1.122.348-.312.597-.517.747-.615.267-.183.49-.368.667-.553.177-.185.312-.375.405-.57.093-.194.139-.384.139-.57a1.008 1.008 0 0 0-.554-.917 1.197 1.197 0 0 0-.56-.133c-.426 0-.761.182-1.005.546a2.332 2.332 0 0 0-.164.39 1.609 1.609 0 0 1-.258.488c-.096.114-.237.17-.423.17a.558.558 0 0 1-.405-.156.568.568 0 0 1-.161-.427c0-.218.05-.446.151-.683.101-.238.252-.453.452-.646s.454-.349.762-.467a2.998 2.998 0 0 1 1.081-.178c.498 0 .923.076 1.274.228a1.916 1.916 0 0 1 1.004 1.032 1.984 1.984 0 0 1-.156 1.794c-.2.32-.405.572-.613.754-.208.182-.558.468-1.048.857-.49.39-.826.691-1.008.906a2.703 2.703 0 0 0-.24.309z"/></svg>',label:t("Subscript")});e.ui.componentFactory.add(Pv,(()=>{const t=i(Hg),n=e.commands.get(Pv);return t.set({tooltip:!0}),t.bind("isOn").to(n,"value"),t})),e.ui.componentFactory.add("menuBar:"+Pv,(()=>i(uw)))}}class Rv extends Na{static get requires(){return[Iv,Vv]}static get pluginName(){return"Subscript"}}const Bv="superscript";class Ov extends Na{static get pluginName(){return"SuperscriptEditing"}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:Bv}),e.model.schema.setAttributeProperties(Bv,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:Bv,view:"sup",upcastAlso:[{styles:{"vertical-align":"super"}}]}),e.commands.add(Bv,new rv(e,Bv))}}const Mv="superscript";class Lv extends Na{static get pluginName(){return"SuperscriptUI"}init(){const e=this.editor,t=e.locale.t,i=cv({editor:e,commandName:Mv,plugin:this,icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M15.677 8.678h2.549c.254 0 .447.05.58.152a.49.49 0 0 1 .201.413.54.54 0 0 1-.159.393c-.105.108-.266.162-.48.162h-3.594c-.245 0-.435-.066-.572-.197a.621.621 0 0 1-.205-.463c0-.114.044-.265.132-.453a1.62 1.62 0 0 1 .288-.444c.433-.436.824-.81 1.172-1.122.348-.312.597-.517.747-.615.267-.183.49-.368.667-.553.177-.185.312-.375.405-.57.093-.194.139-.384.139-.57a1.008 1.008 0 0 0-.554-.917 1.197 1.197 0 0 0-.56-.133c-.426 0-.761.182-1.005.546a2.332 2.332 0 0 0-.164.39 1.609 1.609 0 0 1-.258.488c-.096.114-.237.17-.423.17a.558.558 0 0 1-.405-.156.568.568 0 0 1-.161-.427c0-.218.05-.446.151-.683.101-.238.252-.453.452-.646s.454-.349.762-.467a2.998 2.998 0 0 1 1.081-.178c.498 0 .923.076 1.274.228a1.916 1.916 0 0 1 1.004 1.032 1.984 1.984 0 0 1-.156 1.794c-.2.32-.405.572-.613.754-.208.182-.558.468-1.048.857-.49.39-.826.691-1.008.906a2.703 2.703 0 0 0-.24.309zM7.03 10.349l3.818-3.819a.8.8 0 1 1 1.132 1.132L8.16 11.48l3.819 3.818a.8.8 0 1 1-1.132 1.132L7.03 12.61l-3.818 3.82a.8.8 0 1 1-1.132-1.132L5.9 11.48 2.08 7.662A.8.8 0 1 1 3.212 6.53l3.818 3.82z"/></svg>',label:t("Superscript")});e.ui.componentFactory.add(Mv,(()=>{const t=i(Hg),n=e.commands.get(Mv);return t.set({tooltip:!0}),t.bind("isOn").to(n,"value"),t})),e.ui.componentFactory.add("menuBar:"+Mv,(()=>i(uw)))}}class Nv extends Na{static get requires(){return[Ov,Lv]}static get pluginName(){return"Superscript"}}const Fv="underline";class Dv extends Na{static get pluginName(){return"UnderlineEditing"}init(){const e=this.editor,t=this.editor.t;e.model.schema.extend("$text",{allowAttributes:Fv}),e.model.schema.setAttributeProperties(Fv,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:Fv,view:"u",upcastAlso:{styles:{"text-decoration":"underline"}}}),e.commands.add(Fv,new rv(e,Fv)),e.keystrokes.set("CTRL+U","underline"),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Underline text"),keystroke:"CTRL+U"}]})}}const zv="underline";class Hv extends Na{static get pluginName(){return"UnderlineUI"}init(){const e=this.editor,t=e.commands.get(zv),i=e.locale.t,n=cv({editor:e,commandName:zv,plugin:this,icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M3 18v-1.5h14V18zm2.2-8V3.6c0-.4.4-.6.8-.6.3 0 .7.2.7.6v6.2c0 2 1.3 2.8 3.2 2.8 1.9 0 3.4-.9 3.4-2.9V3.6c0-.3.4-.5.8-.5.3 0 .7.2.7.5V10c0 2.7-2.2 4-4.9 4-2.6 0-4.7-1.2-4.7-4z"/></svg>',label:i("Underline"),keystroke:"CTRL+U"});e.ui.componentFactory.add(zv,(()=>{const e=n(Hg);return e.set({tooltip:!0}),e.bind("isOn").to(t,"value"),e})),e.ui.componentFactory.add("menuBar:"+zv,(()=>n(uw)))}}class $v extends Na{static get requires(){return[Dv,Hv]}static get pluginName(){return"Underline"}}function*Uv(e,t){for(const i of t)i&&e.getAttributeProperties(i[0]).copyOnEnter&&(yield i)}class Wv extends Da{execute(){this.editor.model.change((e=>{this.enterBlock(e),this.fire("afterExecute",{writer:e})}))}enterBlock(e){const t=this.editor.model,i=t.document.selection,n=t.schema,s=i.isCollapsed,o=i.getFirstRange(),r=o.start.parent,a=o.end.parent;if(n.isLimit(r)||n.isLimit(a))return s||r!=a||t.deleteContent(i),!1;if(s){const t=Uv(e.model.schema,i.getAttributes());return jv(e,o.start),e.setSelectionAttribute(t),!0}{const n=!(o.start.isAtStart&&o.end.isAtEnd),s=r==a;if(t.deleteContent(i,{leaveUnmerged:n}),n){if(s)return jv(e,i.focus),!0;e.setSelection(a,0)}}return!1}}function jv(e,t){e.split(t),e.setSelection(t.parent.nextSibling,0)}const qv={insertParagraph:{isSoft:!1},insertLineBreak:{isSoft:!0}};class Gv extends Ec{observe(){}stopObserving(){}constructor(e){super(e);const t=this.document;let n=!1;t.on("keydown",((e,t)=>{n=t.shiftKey})),t.on("beforeinput",((s,o)=>{if(!this.isEnabled)return;let r=o.inputType;i.isSafari&&n&&"insertParagraph"==r&&(r="insertLineBreak");const a=o.domEvent,l=qv[r];if(!l)return;const c=new Al(t,"enter",o.targetRanges[0]);t.fire(c,new Tc(e,a,{isSoft:l.isSoft})),c.stop.called&&s.stop()}))}}class Kv extends Na{static get pluginName(){return"Enter"}init(){const e=this.editor,t=e.editing.view,i=t.document,n=this.editor.t;t.addObserver(Gv),e.commands.add("enter",new Wv(e)),this.listenTo(i,"enter",((n,s)=>{i.isComposing||s.preventDefault(),s.isSoft||(e.execute("enter"),t.scrollToTheSelection())}),{priority:"low"}),e.accessibility.addKeystrokeInfos({keystrokes:[{label:n("Insert a hard break (a new paragraph)"),keystroke:"Enter"}]})}}class Zv extends Da{execute(){const e=this.editor.model,t=e.document;e.change((i=>{!function(e,t,i){const n=i.isCollapsed,s=i.getFirstRange(),o=s.start.parent,r=s.end.parent,a=o==r;if(n){const n=Uv(e.schema,i.getAttributes());Jv(e,t,s.end),t.removeSelectionAttribute(i.getAttributeKeys()),t.setSelectionAttribute(n)}else{const n=!(s.start.isAtStart&&s.end.isAtEnd);e.deleteContent(i,{leaveUnmerged:n}),a?Jv(e,t,i.focus):n&&t.setSelection(r,0)}}(e,i,t.selection),this.fire("afterExecute",{writer:i})}))}refresh(){const e=this.editor.model,t=e.document;this.isEnabled=function(e,t){if(t.rangeCount>1)return!1;const i=t.anchor;if(!i||!e.checkChild(i,"softBreak"))return!1;const n=t.getFirstRange(),s=n.start.parent,o=n.end.parent;if((Qv(s,e)||Qv(o,e))&&s!==o)return!1;return!0}(e.schema,t.selection)}}function Jv(e,t,i){const n=t.createElement("softBreak");e.insertContent(n,i),t.setSelection(n,"after")}function Qv(e,t){return!e.is("rootElement")&&(t.isLimit(e)||Qv(e.parent,t))}class Yv extends Na{static get pluginName(){return"ShiftEnter"}init(){const e=this.editor,t=e.model.schema,i=e.conversion,n=e.editing.view,s=n.document,o=this.editor.t;t.register("softBreak",{allowWhere:"$text",isInline:!0}),i.for("upcast").elementToElement({model:"softBreak",view:"br"}),i.for("downcast").elementToElement({model:"softBreak",view:(e,{writer:t})=>t.createEmptyElement("br")}),n.addObserver(Gv),e.commands.add("shiftEnter",new Zv(e)),this.listenTo(s,"enter",((t,i)=>{s.isComposing||i.preventDefault(),i.isSoft&&(e.execute("shiftEnter"),n.scrollToTheSelection())}),{priority:"low"}),e.accessibility.addKeystrokeInfos({keystrokes:[{label:o("Insert a soft break (a <code>&lt;br&gt;</code> element)"),keystroke:"Shift+Enter"}]})}}class Xv extends Da{refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,i=t.schema,n=t.document.selection,s=Array.from(n.getSelectedBlocks()),o=void 0===e.forceValue?!this.value:e.forceValue;t.change((e=>{if(o){const t=s.filter((e=>e_(e)||i_(i,e)));this._applyQuote(e,t)}else this._removeQuote(e,s.filter(e_))}))}_getValue(){const e=_a(this.editor.model.document.selection.getSelectedBlocks());return!(!e||!e_(e))}_checkEnabled(){if(this.value)return!0;const e=this.editor.model.document.selection,t=this.editor.model.schema,i=_a(e.getSelectedBlocks());return!!i&&i_(t,i)}_removeQuote(e,t){t_(e,t).reverse().forEach((t=>{if(t.start.isAtStart&&t.end.isAtEnd)return void e.unwrap(t.start.parent);if(t.start.isAtStart){const i=e.createPositionBefore(t.start.parent);return void e.move(t,i)}t.end.isAtEnd||e.split(t.end);const i=e.createPositionAfter(t.end.parent);e.move(t,i)}))}_applyQuote(e,t){const i=[];t_(e,t).reverse().forEach((t=>{let n=e_(t.start);n||(n=e.createElement("blockQuote"),e.wrap(t,n)),i.push(n)})),i.reverse().reduce(((t,i)=>t.nextSibling==i?(e.merge(e.createPositionAfter(t)),t):i))}}function e_(e){return"blockQuote"==e.parent.name?e.parent:null}function t_(e,t){let i,n=0;const s=[];for(;n<t.length;){const o=t[n],r=t[n+1];i||(i=e.createPositionBefore(o)),r&&o.nextSibling==r||(s.push(e.createRange(i,e.createPositionAfter(o))),i=null),n++}return s}function i_(e,t){const i=e.checkChild(t.parent,"blockQuote"),n=e.checkChild(["$root","blockQuote"],t);return i&&n}class n_ extends Na{static get pluginName(){return"BlockQuoteEditing"}static get requires(){return[Kv,Rw]}init(){const e=this.editor,t=e.model.schema;e.commands.add("blockQuote",new Xv(e)),t.register("blockQuote",{inheritAllFrom:"$container"}),e.conversion.elementToElement({model:"blockQuote",view:"blockquote"}),e.model.document.registerPostFixer((i=>{const n=e.model.document.differ.getChanges();for(const e of n)if("insert"==e.type){const n=e.position.nodeAfter;if(!n)continue;if(n.is("element","blockQuote")&&n.isEmpty)return i.remove(n),!0;if(n.is("element","blockQuote")&&!t.checkChild(e.position,n))return i.unwrap(n),!0;if(n.is("element")){const e=i.createRangeIn(n);for(const n of e.getItems())if(n.is("element","blockQuote")&&!t.checkChild(i.createPositionBefore(n),n))return i.unwrap(n),!0}}else if("remove"==e.type){const t=e.position.parent;if(t.is("element","blockQuote")&&t.isEmpty)return i.remove(t),!0}return!1}));const i=this.editor.editing.view.document,n=e.model.document.selection,s=e.commands.get("blockQuote");this.listenTo(i,"enter",((t,i)=>{if(!n.isCollapsed||!s.value)return;n.getLastPosition().parent.isEmpty&&(e.execute("blockQuote"),e.editing.view.scrollToTheSelection(),i.preventDefault(),t.stop())}),{context:"blockquote"}),this.listenTo(i,"delete",((t,i)=>{if("backward"!=i.direction||!n.isCollapsed||!s.value)return;const o=n.getLastPosition().parent;o.isEmpty&&!o.previousSibling&&(e.execute("blockQuote"),e.editing.view.scrollToTheSelection(),i.preventDefault(),t.stop())}),{context:"blockquote"})}}class s_ extends Na{static get pluginName(){return"BlockQuoteUI"}init(){const e=this.editor,t=e.commands.get("blockQuote");e.ui.componentFactory.add("blockQuote",(()=>{const e=this._createButton(Hg);return e.set({tooltip:!0}),e.bind("isOn").to(t,"value"),e})),e.ui.componentFactory.add("menuBar:blockQuote",(()=>this._createButton(uw)))}_createButton(e){const t=this.editor,i=t.locale,n=t.commands.get("blockQuote"),s=new e(t.locale),o=i.t;return s.set({label:o("Block quote"),icon:Dm.quote,isToggleable:!0}),s.bind("isEnabled").to(n,"isEnabled"),this.listenTo(s,"execute",(()=>{t.execute("blockQuote"),t.editing.view.focus()})),s}}class o_ extends Na{static get requires(){return[n_,s_]}static get pluginName(){return"BlockQuote"}}class r_ extends Na{static get pluginName(){return"CKBoxUI"}afterInit(){const e=this.editor;if(!e.commands.get("ckbox"))return;const t=e.t,i=e.ui.componentFactory;if(i.add("ckbox",(()=>{const e=this._createButton(Hg);return e.tooltip=!0,e})),i.add("menuBar:ckbox",(()=>this._createButton(uw))),e.plugins.has("ImageInsertUI")){const i=e.plugins.get("ImageInsertUI");i.registerIntegration({name:"assetManager",observable:()=>e.commands.get("ckbox"),buttonViewCreator:()=>{const e=this.editor.ui.componentFactory.create("ckbox");return e.icon=Dm.imageAssetManager,e.bind("label").to(i,"isImageSelected",(e=>t(e?"Replace image with file manager":"Insert image with file manager"))),e},formViewCreator:()=>{const e=this.editor.ui.componentFactory.create("ckbox");return e.icon=Dm.imageAssetManager,e.withText=!0,e.bind("label").to(i,"isImageSelected",(e=>t(e?"Replace with file manager":"Insert with file manager"))),e.on("execute",(()=>{i.dropdownView.isOpen=!1})),e}})}}_createButton(e){const t=this.editor,i=t.locale,n=new e(i),s=t.commands.get("ckbox"),o=i.t;return n.set({label:o("Open file manager"),icon:Dm.browseFiles}),n.bind("isOn","isEnabled").to(s,"value","isEnabled"),n.on("execute",(()=>{t.execute("ckbox")})),n}}var a_=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","#","$","%","*","+",",","-",".",":",";","=","?","@","[","]","^","_","{","|","}","~"],l_=e=>{let t=0;for(let i=0;i<e.length;i++){let n=e[i];t=83*t+a_.indexOf(n)}return t},c_=e=>{let t=e/255;return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)},d_=e=>{let t=Math.max(0,Math.min(1,e));return t<=.0031308?Math.trunc(12.92*t*255+.5):Math.trunc(255*(1.055*Math.pow(t,.4166666666666667)-.055)+.5)},h_=(e,t)=>(e=>e<0?-1:1)(e)*Math.pow(Math.abs(e),t),u_=class extends Error{constructor(e){super(e),this.name="ValidationError",this.message=e}},m_=e=>{let t=e>>8&255,i=255&e;return[c_(e>>16),c_(t),c_(i)]},g_=(e,t)=>{let i=Math.floor(e/361),n=Math.floor(e/19)%19,s=e%19;return[h_((i-9)/9,2)*t,h_((n-9)/9,2)*t,h_((s-9)/9,2)*t]},f_=(e,t,i,n)=>{(e=>{if(!e||e.length<6)throw new u_("The blurhash string must be at least 6 characters");let t=l_(e[0]),i=Math.floor(t/9)+1,n=t%9+1;if(e.length!==4+2*n*i)throw new u_(`blurhash length mismatch: length is ${e.length} but it should be ${4+2*n*i}`)})(e),n|=1;let s=l_(e[0]),o=Math.floor(s/9)+1,r=s%9+1,a=(l_(e[1])+1)/166,l=new Array(r*o);for(let t=0;t<l.length;t++)if(0===t){let i=l_(e.substring(2,6));l[t]=m_(i)}else{let i=l_(e.substring(4+2*t,6+2*t));l[t]=g_(i,a*n)}let c=4*t,d=new Uint8ClampedArray(c*i);for(let e=0;e<i;e++)for(let n=0;n<t;n++){let s=0,a=0,h=0;for(let c=0;c<o;c++)for(let o=0;o<r;o++){let d=Math.cos(Math.PI*n*o/t)*Math.cos(Math.PI*e*c/i),u=l[o+c*r];s+=u[0]*d,a+=u[1]*d,h+=u[2]*d}let u=d_(s),m=d_(a),g=d_(h);d[4*n+0+e*c]=u,d[4*n+1+e*c]=m,d[4*n+2+e*c]=g,d[4*n+3+e*c]=255}return d};function p_(e){const t=[];let i=0;for(const n in e){const s=parseInt(n,10);isNaN(s)||(s>i&&(i=s),t.push(`${e[n]} ${n}w`))}const n=[{srcset:t.join(","),sizes:`(max-width: ${i}px) 100vw, ${i}px`,type:"image/webp"}];return{imageFallbackUrl:e.default,imageSources:n}}const b_=32;function w_({url:e,method:t="GET",data:i,onUploadProgress:n,signal:s,authorization:o}){const r=new XMLHttpRequest;r.open(t,e.toString()),r.setRequestHeader("Authorization",o),r.setRequestHeader("CKBox-Version","CKEditor 5"),r.responseType="json";const a=()=>{r.abort()};return new Promise(((e,t)=>{s.throwIfAborted(),s.addEventListener("abort",a),r.addEventListener("loadstart",(()=>{s.addEventListener("abort",a)})),r.addEventListener("loadend",(()=>{s.removeEventListener("abort",a)})),r.addEventListener("error",(()=>{t()})),r.addEventListener("abort",(()=>{t()})),r.addEventListener("load",(()=>{const i=r.response;if(!i||i.statusCode>=400)return t(i&&i.message);e(i)})),n&&r.upload.addEventListener("progress",(e=>{n(e)})),r.send(i)}))}const v_={"image/gif":"gif","image/jpeg":"jpg","image/png":"png","image/webp":"webp","image/bmp":"bmp","image/tiff":"tiff"};class __ extends Da{refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(){this.fire("ckbox:open")}_getValue(){return null!==this._wrapper}_checkEnabled(){const e=this.editor.commands.get("insertImage"),t=this.editor.commands.get("link");return!(!e.isEnabled&&!t.isEnabled)}_prepareOptions(){const e=this.editor.config.get("ckbox");return{theme:e.theme,language:e.language,tokenUrl:e.tokenUrl,serviceOrigin:e.serviceOrigin,forceDemoLabel:e.forceDemoLabel,dialog:{onClose:()=>this.fire("ckbox:close")},assets:{onChoose:e=>this.fire("ckbox:choose",e)}}}_initListeners(){const e=this.editor,t=e.model,i=!e.config.get("ckbox.ignoreDataId");this.on("ckbox",(()=>{this.refresh()}),{priority:"low"}),this.on("ckbox:open",(()=>{this.isEnabled&&!this.value&&(this._wrapper=cr(document,"div",{class:"ck ckbox-wrapper"}),document.body.appendChild(this._wrapper),window.CKBox.mount(this._wrapper,this._prepareOptions()))})),this.on("ckbox:close",(()=>{this.value&&(this._wrapper.remove(),this._wrapper=null,e.editing.view.focus())})),this.on("ckbox:choose",((n,s)=>{if(!this.isEnabled)return;const o=e.commands.get("insertImage"),r=e.commands.get("link"),a=function({assets:e,isImageAllowed:t,isLinkAllowed:i}){return e.map((e=>function(e){const t=e.data.metadata;if(!t)return!1;return t.width&&t.height}(e)?{id:e.data.id,type:"image",attributes:y_(e)}:{id:e.data.id,type:"link",attributes:k_(e)})).filter((e=>"image"===e.type?t:i))}({assets:s,isImageAllowed:o.isEnabled,isLinkAllowed:r.isEnabled}),l=a.length;0!==l&&(t.change((e=>{for(const t of a){const n=t===a[l-1],s=1===l;this._insertAsset(t,n,e,s),i&&(setTimeout((()=>this._chosenAssets.delete(t)),1e3),this._chosenAssets.add(t))}})),e.editing.view.focus())})),this.listenTo(e,"destroy",(()=>{this.fire("ckbox:close"),this._chosenAssets.clear()}))}_insertAsset(e,t,i,n){const s=this.editor.model.document.selection;i.removeSelectionAttribute("linkHref"),"image"===e.type?this._insertImage(e):this._insertLink(e,i,n),t||i.setSelection(s.getLastPosition())}_insertImage(e){const t=this.editor,{imageFallbackUrl:i,imageSources:n,imageTextAlternative:s,imageWidth:o,imageHeight:r,imagePlaceholder:a}=e.attributes;t.execute("insertImage",{source:{src:i,sources:n,alt:s,width:o,height:r,...a?{placeholder:a}:null}})}_insertLink(e,t,i){const n=this.editor,s=n.model,o=s.document.selection,{linkName:r,linkHref:a}=e.attributes;if(o.isCollapsed){const e=Ca(o.getAttributes()),l=t.createText(r,e);if(!i){const e=o.getLastPosition(),i=e.parent;"paragraph"===i.name&&i.isEmpty||n.execute("insertParagraph",{position:e});const r=s.insertContent(l);return t.setSelection(r),void n.execute("link",a)}const c=s.insertContent(l);t.setSelection(c)}n.execute("link",a)}constructor(e){super(e),this._chosenAssets=new Set,this._wrapper=null,this._initListeners()}}function y_(e){const{imageFallbackUrl:t,imageSources:i}=p_(e.data.imageUrls),{description:n,width:s,height:o,blurHash:r}=e.data.metadata,a=function(e){if(e)try{const t=`${b_}px`,i=document.createElement("canvas");i.setAttribute("width",t),i.setAttribute("height",t);const n=i.getContext("2d");if(!n)return;const s=n.createImageData(b_,b_),o=f_(e,b_,b_);return s.data.set(o),n.putImageData(s,0,0),i.toDataURL()}catch(e){return}}(r);return{imageFallbackUrl:t,imageSources:i,imageTextAlternative:n||"",imageWidth:s,imageHeight:o,...a?{imagePlaceholder:a}:null}}function k_(e){return{linkName:e.data.name,linkHref:C_(e)}}function C_(e){const t=new URL(e.data.url);return t.searchParams.set("download","true"),t.toString()}class x_ extends Na{static get pluginName(){return"CKBoxUtils"}static get requires(){return["CloudServices"]}async init(){const e=this.editor,t=!!e.config.get("ckbox"),i=!!window.CKBox;if(!t&&!i)return;e.config.define("ckbox",{serviceOrigin:"https://api.ckbox.io",defaultUploadCategories:null,ignoreDataId:!1,language:e.locale.uiLanguage,theme:"lark",tokenUrl:e.config.get("cloudServices.tokenUrl")});const n=e.plugins.get("CloudServices"),s=e.config.get("cloudServices.tokenUrl"),o=e.config.get("ckbox.tokenUrl");if(!o)throw new p("ckbox-plugin-missing-token-url",this);this._token=o==s?n.token:await n.registerTokenUrl(o)}getToken(){return this._token}getWorkspaceId(){const e=(0,this.editor.t)("Cannot access default workspace."),t=this.editor.config.get("ckbox.defaultUploadWorkspaceId"),i=function(e,t){const[,i]=e.value.split("."),n=JSON.parse(atob(i)),s=n.auth&&n.auth.ckbox&&n.auth.ckbox.workspaces||[n.aud];return t?"superadmin"==(n.auth&&n.auth.ckbox&&n.auth.ckbox.role)||s.includes(t)?t:null:s[0]}(this._token,t);if(null==i)throw w("ckbox-access-default-workspace-error"),e;return i}async getCategoryIdForFile(e,t){const i=(0,this.editor.t)("Cannot determine a category for the uploaded file."),n=this.editor.config.get("ckbox.defaultUploadCategories"),s=this._getAvailableCategories(t),o="string"==typeof e?(r=await async function(e,t){try{const i=await fetch(e,{method:"HEAD",cache:"force-cache",...t});return i.ok&&i.headers.get("content-type")||""}catch{return""}}(e,t),v_[r]):function(e){const t=e.name,i=RegExp("\\.(?<ext>[^.]+)$");return t.match(i).groups.ext.toLowerCase()}(e);var r;const a=await s;if(!a)throw i;if(n){const e=Object.keys(n).find((e=>n[e].find((e=>e.toLowerCase()==o))));if(e){const t=a.find((t=>t.id===e||t.name===e));if(!t)throw i;return t.id}}const l=a.find((e=>e.extensions.find((e=>e.toLowerCase()==o))));if(!l)throw i;return l.id}async _getAvailableCategories(e){const t=this.editor,i=this._token,{signal:n}=e,s=t.config.get("ckbox.serviceOrigin"),o=this.getWorkspaceId();try{const e=[];let t,i=0;do{const n=await r(i);e.push(...n.items),t=n.totalCount-(i+50),i+=50}while(t>0);return e}catch{return n.throwIfAborted(),void w("ckbox-fetch-category-http-error")}function r(e){const t=new URL("categories",s);return t.searchParams.set("limit",50..toString()),t.searchParams.set("offset",e.toString()),t.searchParams.set("workspaceId",o),w_({url:t,signal:n,authorization:i.value})}}}class A_ extends Na{static get requires(){return["ImageUploadEditing","ImageUploadProgress",Hm,T_]}static get pluginName(){return"CKBoxUploadAdapter"}async afterInit(){const e=this.editor,t=!!e.config.get("ckbox"),i=!!window.CKBox;if(!t&&!i)return;const n=e.plugins.get(Hm),s=e.plugins.get(x_);n.createUploadAdapter=t=>new E_(t,e,s);const o=!e.config.get("ckbox.ignoreDataId"),r=e.plugins.get("ImageUploadEditing");o&&r.on("uploadComplete",((t,{imageElement:i,data:n})=>{e.model.change((e=>{e.setAttribute("ckboxImageId",n.ckboxImageId,i)}))}))}}let E_=class{async upload(){const e=this.ckboxUtils,t=this.editor.t,i=await this.loader.file,n=await e.getCategoryIdForFile(i,{signal:this.controller.signal}),s=new URL("assets",this.serviceOrigin),o=new FormData;s.searchParams.set("workspaceId",e.getWorkspaceId()),o.append("categoryId",n),o.append("file",i);return w_({method:"POST",url:s,data:o,onUploadProgress:e=>{e.lengthComputable&&(this.loader.uploadTotal=e.total,this.loader.uploaded=e.loaded)},signal:this.controller.signal,authorization:this.token.value}).then((async e=>{const t=p_(e.imageUrls);return{ckboxImageId:e.id,default:t.imageFallbackUrl,sources:t.imageSources}})).catch((()=>{const e=t("Cannot upload file:")+` ${i.name}.`;return Promise.reject(e)}))}abort(){this.controller.abort()}constructor(e,t,i){this.loader=e,this.token=i.getToken(),this.ckboxUtils=i,this.editor=t,this.controller=new AbortController,this.serviceOrigin=t.config.get("ckbox.serviceOrigin")}};class T_ extends Na{static get pluginName(){return"CKBoxEditing"}static get requires(){return["LinkEditing","PictureEditing",A_,x_]}init(){const e=this.editor;this._shouldBeInitialised()&&(this._checkImagePlugins(),V_()&&e.commands.add("ckbox",new __(e)))}afterInit(){const e=this.editor;this._shouldBeInitialised()&&(e.config.get("ckbox.ignoreDataId")||(this._initSchema(),this._initConversion(),this._initFixers()))}_shouldBeInitialised(){return!!this.editor.config.get("ckbox")||V_()}_checkImagePlugins(){const e=this.editor;e.plugins.has("ImageBlockEditing")||e.plugins.has("ImageInlineEditing")||w("ckbox-plugin-image-feature-missing",e)}_initSchema(){const e=this.editor.model.schema;e.extend("$text",{allowAttributes:"ckboxLinkId"}),e.isRegistered("imageBlock")&&e.extend("imageBlock",{allowAttributes:["ckboxImageId","ckboxLinkId"]}),e.isRegistered("imageInline")&&e.extend("imageInline",{allowAttributes:["ckboxImageId","ckboxLinkId"]}),e.addAttributeCheck(((e,t)=>{if(!!!e.last.getAttribute("linkHref")&&"ckboxLinkId"===t)return!1}))}_initConversion(){const e=this.editor;e.conversion.for("downcast").add((e=>{e.on("attribute:ckboxLinkId:imageBlock",((e,t,i)=>{const{writer:n,mapper:s,consumable:o}=i;if(!o.consume(t.item,e.name))return;const r=[...s.toViewElement(t.item).getChildren()].find((e=>"a"===e.name));r&&(t.item.hasAttribute("ckboxLinkId")?n.setAttribute("data-ckbox-resource-id",t.item.getAttribute("ckboxLinkId"),r):n.removeAttribute("data-ckbox-resource-id",r))}),{priority:"low"}),e.on("attribute:ckboxLinkId",((e,t,i)=>{const{writer:n,mapper:s,consumable:o}=i;if(o.consume(t.item,e.name)){if(t.attributeOldValue){const e=I_(n,t.attributeOldValue);n.unwrap(s.toViewRange(t.range),e)}if(t.attributeNewValue){const e=I_(n,t.attributeNewValue);if(t.item.is("selection")){const t=n.document.selection;n.wrap(t.getFirstRange(),e)}else n.wrap(s.toViewRange(t.range),e)}}}),{priority:"low"})})),e.conversion.for("upcast").add((e=>{e.on("element:a",((e,t,i)=>{const{writer:n,consumable:s}=i;if(!t.viewItem.getAttribute("href"))return;if(!s.consume(t.viewItem,{attributes:["data-ckbox-resource-id"]}))return;const o=t.viewItem.getAttribute("data-ckbox-resource-id");if(o)if(t.modelRange)for(let e of t.modelRange.getItems())e.is("$textProxy")&&(e=e.textNode),P_(e)&&n.setAttribute("ckboxLinkId",o,e);else{const e=t.modelCursor.nodeBefore||t.modelCursor.parent;n.setAttribute("ckboxLinkId",o,e)}}),{priority:"low"})})),e.conversion.for("downcast").attributeToAttribute({model:"ckboxImageId",view:"data-ckbox-resource-id"}),e.conversion.for("upcast").elementToAttribute({model:{key:"ckboxImageId",value:e=>e.getAttribute("data-ckbox-resource-id")},view:{attributes:{"data-ckbox-resource-id":/[\s\S]+/}}});const t=e.commands.get("replaceImageSource");t&&this.listenTo(t,"cleanupImage",((e,[t,i])=>{t.removeAttribute("ckboxImageId",i)}))}_initFixers(){const e=this.editor,t=e.model,i=t.document.selection;t.document.registerPostFixer(function(e){return t=>{let i=!1;const n=e.model,s=e.commands.get("ckbox");if(!s)return i;for(const e of n.document.differ.getChanges()){if("insert"!==e.type&&"attribute"!==e.type)continue;const n="insert"===e.type?new id(e.position,e.position.getShiftedBy(e.length)):e.range,o="attribute"===e.type&&"linkHref"===e.attributeKey&&null===e.attributeNewValue;for(const e of n.getItems()){if(o&&e.hasAttribute("ckboxLinkId")){t.removeAttribute("ckboxLinkId",e),i=!0;continue}const n=S_(e,s._chosenAssets);for(const s of n){const n="image"===s.type?"ckboxImageId":"ckboxLinkId";s.id!==e.getAttribute(n)&&(t.setAttribute(n,s.id,e),i=!0)}}}return i}}(e)),t.document.registerPostFixer(function(e){return t=>!(e.hasAttribute("linkHref")||!e.hasAttribute("ckboxLinkId"))&&(t.removeSelectionAttribute("ckboxLinkId"),!0)}(i))}}function S_(e,t){const i=e.is("element","imageInline")||e.is("element","imageBlock"),n=e.hasAttribute("linkHref");return[...t].filter((t=>"image"===t.type&&i?t.attributes.imageFallbackUrl===e.getAttribute("src"):"link"===t.type&&n?t.attributes.linkHref===e.getAttribute("linkHref"):void 0))}function I_(e,t){const i=e.createAttributeElement("a",{"data-ckbox-resource-id":t},{priority:5});return e.setCustomProperty("link",!0,i),i}function P_(e){return!!e.is("$text")||!(!e.is("element","imageInline")&&!e.is("element","imageBlock"))}function V_(){return!!window.CKBox}class R_ extends Na{static get pluginName(){return"CKBox"}static get requires(){return[T_,r_]}}function B_(e){if(Array.isArray(e)){const t=e.map(B_);return e=>t.some((t=>t(e)))}if("origin"==e){const e=_r.window.location.origin;return t=>new URL(t,_r.document.baseURI).origin==e}return"function"==typeof e?e:e instanceof RegExp?t=>!(!t.match(e)&&!t.replace(/^https?:\/\//,"").match(e)):()=>!1}class O_ extends Da{refresh(){const e=this.editor;this.value=this._getValue();const t=e.model.document.selection.getSelectedElement();this.isEnabled=!!t&&this._canEdit(t)&&!this._checkIfElementIsBeingProcessed(t)}execute(){if(this._getValue())return;const e=cr(document,"div",{class:"ck ckbox-wrapper"});this._wrapper=e,this.value=!0,document.body.appendChild(this._wrapper);const t={element:this.editor.model.document.selection.getSelectedElement(),controller:new AbortController};this._prepareOptions(t).then((t=>window.CKBox.mountImageEditor(e,t)),(e=>{const t=this.editor,i=t.t;t.plugins.get(xb).showWarning(i("Failed to determine category of edited image."),{namespace:"ckbox"}),console.error(e),this._handleImageEditorClose()}))}destroy(){this._handleImageEditorClose(),this._prepareOptions.abort();for(const e of this._processInProgress.values())e.controller.abort();super.destroy()}_getValue(){return null!==this._wrapper}async _prepareOptionsAbortable(e,t){const i=this.editor,n=i.config.get("ckbox"),s=i.plugins.get(x_),{element:o}=t;let r;const a=o.getAttribute("ckboxImageId");if(a)r={assetId:a};else{const t=new URL(o.getAttribute("src"),document.baseURI).href;r={imageUrl:t,uploadCategoryId:await s.getCategoryIdForFile(t,{signal:e})}}return{...r,imageEditing:{allowOverwrite:!1},tokenUrl:n.tokenUrl,...n.serviceOrigin&&{serviceOrigin:n.serviceOrigin},onClose:()=>this._handleImageEditorClose(),onSave:e=>this._handleImageEditorSave(t,e)}}_prepareListeners(){this.listenTo(this.editor.model.document,"change:data",(()=>{this._getProcessingStatesOfDeletedImages().forEach((e=>{e.controller.abort()}))}))}_getProcessingStatesOfDeletedImages(){const e=[];for(const t of this._processInProgress.values())"$graveyard"==t.element.root.rootName&&e.push(t);return e}_checkIfElementIsBeingProcessed(e){for(const{element:t}of this._processInProgress)if(Do(t,e))return!0;return!1}_handleImageEditorClose(){this._wrapper&&(this._wrapper.remove(),this._wrapper=null,this.editor.editing.view.focus(),this.refresh())}_handleImageEditorSave(e,t){const i=this.editor.locale.t,n=this.editor.plugins.get(xb),s=this.editor.plugins.get(Fm),o=s.add(i("Processing the edited image."));this._processInProgress.add(e),this._showImageProcessingIndicator(e.element,t),this.refresh(),this._waitForAssetProcessed(t.data.id,e.controller.signal).then((t=>{this._replaceImage(e.element,t)}),(t=>{this.editor.editing.reconvertItem(e.element),e.controller.signal.aborted||(!t||t instanceof p?n.showWarning(i("Server failed to process the image."),{namespace:"ckbox"}):console.error(t))})).finally((()=>{this._processInProgress.delete(e),s.remove(o),this.refresh()}))}async _getAssetStatusFromServer(e,t){const i=this.editor.plugins.get(x_),n=new URL("assets/"+e,this.editor.config.get("ckbox.serviceOrigin")),s=await w_({url:n,signal:t,authorization:i.getToken().value}),o=s.metadata.metadataProcessingStatus;if(!o||"queued"==o)throw new p("ckbox-image-not-processed");return{data:{...s}}}async _waitForAssetProcessed(e,t){const i=await Aa((()=>this._getAssetStatusFromServer(e,t)),{signal:t,maxAttempts:5});if("success"!=i.data.metadata.metadataProcessingStatus)throw new p("ckbox-image-processing-failed");return i}_showImageProcessingIndicator(e,t){const i=this.editor;i.editing.view.change((n=>{const s=i.editing.mapper.toViewElement(e),o=this.editor.plugins.get("ImageUtils").findViewImgElement(s);n.removeStyle("aspect-ratio",o),n.setAttribute("width",t.data.metadata.width,o),n.setAttribute("height",t.data.metadata.height,o),n.setStyle("width",`${t.data.metadata.width}px`,o),n.setStyle("height",`${t.data.metadata.height}px`,o),n.addClass("image-processing",s)}))}_replaceImage(e,t){const i=this.editor,{imageFallbackUrl:n,imageSources:s,imageWidth:o,imageHeight:r,imagePlaceholder:a}=y_(t),l=Array.from(i.model.document.selection.getRanges());i.model.change((c=>{c.setSelection(e,"on"),i.execute("insertImage",{source:{src:n,sources:s,width:o,height:r,...a?{placeholder:a}:null,...e.hasAttribute("alt")?{alt:e.getAttribute("alt")}:null}});const d=e.getChildren();e=i.model.document.selection.getSelectedElement();for(const t of d)c.append(c.cloneElement(t),e);c.setAttribute("ckboxImageId",t.data.id,e),c.setSelection(l)}))}constructor(e){super(e),this._wrapper=null,this._processInProgress=new Set,this.value=!1,this._canEdit=function(e){const t=B_(e);return e=>!(!e.is("element","imageInline")&&!e.is("element","imageBlock"))&&(!!e.hasAttribute("ckboxImageId")||!!e.hasAttribute("src")&&t(e.getAttribute("src")))}(e.config.get("ckbox.allowExternalImagesEditing")),this._prepareOptions=or(((e,t)=>this._prepareOptionsAbortable(e,t))),this._prepareListeners()}}class M_ extends Na{static get pluginName(){return"CKBoxImageEditEditing"}static get requires(){return[T_,x_,Fm,xb,"ImageUtils","ImageEditing"]}init(){const{editor:e}=this;e.commands.add("ckboxImageEdit",new O_(e))}}class L_ extends Na{static get pluginName(){return"CKBoxImageEditUI"}init(){const e=this.editor;e.ui.componentFactory.add("ckboxImageEdit",(t=>{const i=e.commands.get("ckboxImageEdit"),n=new Hg(t),s=t.t;return n.set({label:s("Edit image"),icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M1.201 1C.538 1 0 1.47 0 2.1v14.363c0 .64.534 1.037 1.186 1.037H5.06l5.058-5.078L6.617 9.15a.696.696 0 0 0-.957-.033L1.5 13.6V2.5h15v4.354a3.478 3.478 0 0 1 1.5.049V2.1c0-.63-.547-1.1-1.2-1.1H1.202Zm11.713 2.803a2.147 2.147 0 0 0-2.049 1.992 2.14 2.14 0 0 0 1.28 2.096 2.13 2.13 0 0 0 2.642-3.11 2.129 2.129 0 0 0-1.873-.978ZM8.089 17.635v2.388h2.389l7.046-7.046-2.39-2.39-7.045 7.048Zm11.282-6.507a.637.637 0 0 0 .139-.692.603.603 0 0 0-.139-.205l-1.49-1.488a.63.63 0 0 0-.899 0l-1.166 1.163 2.39 2.39 1.165-1.168Z"/></svg>',tooltip:!0}),n.bind("isOn").to(i,"value",i,"isEnabled",((e,t)=>e&&t)),n.bind("isEnabled").to(i),this.listenTo(n,"execute",(()=>{e.execute("ckboxImageEdit"),e.editing.view.focus()})),n}))}}class N_ extends Na{static get pluginName(){return"CKBoxImageEdit"}static get requires(){return[M_,L_]}}class F_ extends Na{static get pluginName(){return"CKFinderUI"}init(){const e=this.editor,t=e.ui.componentFactory,i=e.t;if(t.add("ckfinder",(e=>{const t=this._createButton(Hg),i=e.t;return t.set({label:i("Insert image or file"),tooltip:!0}),t})),t.add("menuBar:ckfinder",(e=>{const t=this._createButton(uw),i=e.t;return t.label=i("Image or file"),t})),e.plugins.has("ImageInsertUI")){const t=e.plugins.get("ImageInsertUI");t.registerIntegration({name:"assetManager",observable:()=>e.commands.get("ckfinder"),buttonViewCreator:()=>{const e=this.editor.ui.componentFactory.create("ckfinder");return e.icon=Dm.imageAssetManager,e.bind("label").to(t,"isImageSelected",(e=>i(e?"Replace image with file manager":"Insert image with file manager"))),e},formViewCreator:()=>{const e=this.editor.ui.componentFactory.create("ckfinder");return e.icon=Dm.imageAssetManager,e.withText=!0,e.bind("label").to(t,"isImageSelected",(e=>i(e?"Replace with file manager":"Insert with file manager"))),e.on("execute",(()=>{t.dropdownView.isOpen=!1})),e}})}}_createButton(e){const t=this.editor,i=new e(t.locale),n=t.commands.get("ckfinder");return i.icon=Dm.browseFiles,i.bind("isEnabled").to(n),i.on("execute",(()=>{t.execute("ckfinder"),t.editing.view.focus()})),i}}class D_ extends Da{refresh(){const e=this.editor.commands.get("insertImage"),t=this.editor.commands.get("link");this.isEnabled=e.isEnabled||t.isEnabled}execute(){const e=this.editor,t=this.editor.config.get("ckfinder.openerMethod")||"modal";if("popup"!=t&&"modal"!=t)throw new p("ckfinder-unknown-openermethod",e);const i=this.editor.config.get("ckfinder.options")||{};i.chooseFiles=!0;const n=i.onInit;i.language||(i.language=e.locale.uiLanguage),i.onInit=t=>{n&&n(t),t.on("files:choose",(i=>{const n=i.data.files.toArray(),s=n.filter((e=>!e.isImage())),o=n.filter((e=>e.isImage()));for(const t of s)e.execute("link",t.getUrl());const r=[];for(const e of o){const i=e.getUrl();r.push(i||t.request("file:getProxyUrl",{file:e}))}r.length&&z_(e,r)})),t.on("file:choose:resizedImage",(t=>{const i=t.data.resizedUrl;if(i)z_(e,[i]);else{const t=e.plugins.get("Notification"),i=e.locale.t;t.showWarning(i("Could not obtain resized image URL."),{title:i("Selecting resized image failed"),namespace:"ckfinder"})}}))},window.CKFinder[t](i)}constructor(e){super(e),this.affectsData=!1,this.stopListening(this.editor.model.document,"change"),this.listenTo(this.editor.model.document,"change",(()=>this.refresh()),{priority:"low"})}}function z_(e,t){if(e.commands.get("insertImage").isEnabled)e.execute("insertImage",{source:t});else{const t=e.plugins.get("Notification"),i=e.locale.t;t.showWarning(i("Could not insert image at the current position."),{title:i("Inserting image failed"),namespace:"ckfinder"})}}class H_ extends Na{static get pluginName(){return"CKFinderEditing"}static get requires(){return[xb,"LinkEditing"]}init(){const e=this.editor;if(!e.plugins.has("ImageBlockEditing")&&!e.plugins.has("ImageInlineEditing"))throw new p("ckfinder-missing-image-plugin",e);e.commands.add("ckfinder",new D_(e))}}class $_ extends Na{static get pluginName(){return"CKFinder"}static get requires(){return["Link","CKFinderUploadAdapter",H_,F_]}}class U_ extends Sc{onDomEvent(e){const t="clipboardData"in e?e.clipboardData:e.dataTransfer,i="drop"==e.type||"paste"==e.type,n={dataTransfer:new Lc(t,{cacheFiles:i})};"drop"!=e.type&&"dragover"!=e.type||(n.dropRange=function(e,t){const i=t.target.ownerDocument,n=t.clientX,s=t.clientY;let o;i.caretRangeFromPoint&&i.caretRangeFromPoint(n,s)?o=i.caretRangeFromPoint(n,s):t.rangeParent&&(o=i.createRange(),o.setStart(t.rangeParent,t.rangeOffset),o.collapse(!0));if(o)return e.domConverter.domRangeToView(o);return null}(this.view,e)),this.fire(e.type,e,n)}constructor(e){super(e),this.domEventType=["paste","copy","cut","drop","dragover","dragstart","dragend","dragenter","dragleave"];const t=this.document;function i(e){return(i,n)=>{n.preventDefault();const s=n.dropRange?[n.dropRange]:null,o=new d(t,e);t.fire(o,{dataTransfer:n.dataTransfer,method:i.name,targetRanges:s,target:n.target,domEvent:n.domEvent}),o.stop.called&&n.stopPropagation()}}this.listenTo(t,"paste",i("clipboardInput"),{priority:"low"}),this.listenTo(t,"drop",i("clipboardInput"),{priority:"low"}),this.listenTo(t,"dragover",i("dragging"),{priority:"low"})}}const W_=["figcaption","li"],j_=["ol","ul"];function q_(e){if(e.is("$text")||e.is("$textProxy"))return e.data;if(e.is("element","img")&&e.hasAttribute("alt"))return e.getAttribute("alt");if(e.is("element","br"))return"\n";let t="",i=null;for(const n of e.getChildren())t+=G_(n,i)+q_(n),i=n;return t}function G_(e,t){return t?e.is("element","li")&&!e.isEmpty&&e.getChild(0).is("containerElement")||j_.includes(e.name)&&j_.includes(t.name)?"\n\n":e.is("containerElement")||t.is("containerElement")?W_.includes(e.name)||W_.includes(t.name)?"\n":"\n\n":"":""}class K_ extends Na{static get pluginName(){return"ClipboardMarkersUtils"}_registerMarkerToCopy(e,t){this._markersToCopy.set(e,t)}_copySelectedFragmentWithMarkers(e,t,i=(e=>e.model.getSelectedContent(e.model.document.selection))){return this.editor.model.change((n=>{const s=n.model.document.selection;n.setSelection(t);const o=this._insertFakeMarkersIntoSelection(n,n.model.document.selection,e),r=i(n),a=this._removeFakeMarkersInsideElement(n,r);for(const[e,t]of Object.entries(o)){var l,c;(l=a)[c=e]||(l[c]=n.createRangeIn(r));for(const e of t)n.remove(e)}r.markers.clear();for(const[e,t]of Object.entries(a))r.markers.set(e,t);return n.setSelection(s),r}))}_pasteMarkersIntoTransformedElement(e,t){const i=this._getPasteMarkersFromRangeMap(e);return this.editor.model.change((e=>{const n=this._insertFakeMarkersElements(e,i),s=t(e),o=this._removeFakeMarkersInsideElement(e,s);for(const t of Object.values(n).flat())e.remove(t);for(const[t,i]of Object.entries(o))e.model.markers.has(t)||e.addMarker(t,{usingOperation:!0,affectsData:!0,range:i});return s}))}_pasteFragmentWithMarkers(e){const t=this._getPasteMarkersFromRangeMap(e.markers);e.markers.clear();for(const i of t)e.markers.set(i.name,i.range);return this.editor.model.insertContent(e)}_forceMarkersCopy(e,t,i={allowedActions:"all",copyPartiallySelected:!0,duplicateOnPaste:!0}){const n=this._markersToCopy.get(e);this._markersToCopy.set(e,i),t(),n?this._markersToCopy.set(e,n):this._markersToCopy.delete(e)}_isMarkerCopyable(e,t){const i=this._getMarkerClipboardConfig(e);if(!i)return!1;if(!t)return!0;const{allowedActions:n}=i;return"all"===n||n.includes(t)}_hasMarkerConfiguration(e){return!!this._getMarkerClipboardConfig(e)}_getMarkerClipboardConfig(e){const[t]=e.split(":");return this._markersToCopy.get(t)||null}_insertFakeMarkersIntoSelection(e,t,i){const n=this._getCopyableMarkersFromSelection(e,t,i);return this._insertFakeMarkersElements(e,n)}_getCopyableMarkersFromSelection(e,t,i){const n=Array.from(t.getRanges()),s=new Set(n.flatMap((t=>Array.from(e.model.markers.getMarkersIntersectingRange(t)))));return Array.from(s).filter((e=>{if(!this._isMarkerCopyable(e.name,i))return!1;const{copyPartiallySelected:t}=this._getMarkerClipboardConfig(e.name);if(!t){const t=e.getRange();return n.some((e=>e.containsRange(t,!0)))}return!0})).map((e=>({name:"dragstart"===i?this._getUniqueMarkerName(e.name):e.name,range:e.getRange()})))}_getPasteMarkersFromRangeMap(e,t=null){const{model:i}=this.editor;return(e instanceof Map?Array.from(e.entries()):Object.entries(e)).flatMap((([e,n])=>{if(!this._hasMarkerConfiguration(e))return[{name:e,range:n}];if(this._isMarkerCopyable(e,t)){const t=this._getMarkerClipboardConfig(e),s=i.markers.has(e)&&"$graveyard"===i.markers.get(e).getRange().root.rootName;return(t.duplicateOnPaste||s)&&(e=this._getUniqueMarkerName(e)),[{name:e,range:n}]}return[]}))}_insertFakeMarkersElements(e,t){const i={},n=t.flatMap((e=>{const{start:t,end:i}=e.range;return[{position:t,marker:e,type:"start"},{position:i,marker:e,type:"end"}]})).sort((({position:e},{position:t})=>e.isBefore(t)?1:-1));for(const{position:t,marker:s,type:o}of n){const n=e.createElement("$marker",{"data-name":s.name,"data-type":o});i[s.name]||(i[s.name]=[]),i[s.name].push(n),e.insert(n,t)}return i}_removeFakeMarkersInsideElement(e,t){const i=this._getAllFakeMarkersFromElement(e,t).reduce(((t,i)=>{const n=i.markerElement&&e.createPositionBefore(i.markerElement);let s=t[i.name],o=!1;if(s&&s.start&&s.end){this._getMarkerClipboardConfig(i.name).duplicateOnPaste?t[this._getUniqueMarkerName(i.name)]=t[i.name]:o=!0,s=null}return o||(t[i.name]={...s,[i.type]:n}),i.markerElement&&e.remove(i.markerElement),t}),{});return n=i,o={},s=mo(s=i=>new id(i.start||e.createPositionFromPath(t,[0]),i.end||e.createPositionAt(t,"end"))),po(n,(function(e,t,i){He(o,t,s(e,t,i))})),o;var n,s,o}_getAllFakeMarkersFromElement(e,t){const i=Array.from(e.createRangeIn(t)).flatMap((({item:e})=>{if(!e.is("element","$marker"))return[];const t=e.getAttribute("data-name"),i=e.getAttribute("data-type");return[{markerElement:e,name:t,type:i}]})),n=[],s=[];for(const e of i){if("end"===e.type){i.some((t=>t.name===e.name&&"start"===t.type))||n.push({markerElement:null,name:e.name,type:"start"})}if("start"===e.type){i.some((t=>t.name===e.name&&"end"===t.type))||s.unshift({markerElement:null,name:e.name,type:"end"})}}return[...n,...i,...s]}_getUniqueMarkerName(e){const t=e.split(":"),i=u().substring(1,6);return 3===t.length?`${t.slice(0,2).join(":")}:${i}`:`${t.join(":")}:${i}`}constructor(...e){super(...e),this._markersToCopy=new Map}}class Z_ extends Na{static get pluginName(){return"ClipboardPipeline"}static get requires(){return[K_]}init(){this.editor.editing.view.addObserver(U_),this._setupPasteDrop(),this._setupCopyCut()}_fireOutputTransformationEvent(e,t,i){const n=this.editor.plugins.get("ClipboardMarkersUtils");this.editor.model.enqueueChange({isUndoable:"cut"===i},(()=>{const s=n._copySelectedFragmentWithMarkers(i,t);this.fire("outputTransformation",{dataTransfer:e,content:s,method:i})}))}_setupPasteDrop(){const e=this.editor,t=e.model,i=e.editing.view,n=i.document,s=this.editor.plugins.get("ClipboardMarkersUtils");this.listenTo(n,"clipboardInput",((t,i)=>{"paste"!=i.method||e.model.canEditAt(e.model.document.selection)||t.stop()}),{priority:"highest"}),this.listenTo(n,"clipboardInput",((e,t)=>{const n=t.dataTransfer;let s;if(t.content)s=t.content;else{let e="";n.getData("text/html")?e=function(e){return e.replace(/<span(?: class="Apple-converted-space"|)>(\s+)<\/span>/g,((e,t)=>1==t.length?" ":t)).replace(/<!--[\s\S]*?-->/g,"")}(n.getData("text/html")):n.getData("text/plain")&&(e=function(e){return((e=e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\r?\n\r?\n/g,"</p><p>").replace(/\r?\n/g,"<br>").replace(/\t/g,"&nbsp;&nbsp;&nbsp;&nbsp;").replace(/^\s/,"&nbsp;").replace(/\s$/,"&nbsp;").replace(/\s\s/g," &nbsp;")).includes("</p><p>")||e.includes("<br>"))&&(e=`<p>${e}</p>`),e}(n.getData("text/plain"))),s=this.editor.data.htmlProcessor.toView(e)}const o=new d(this,"inputTransformation");this.fire(o,{content:s,dataTransfer:n,targetRanges:t.targetRanges,method:t.method}),o.stop.called&&e.stop(),i.scrollToTheSelection()}),{priority:"low"}),this.listenTo(this,"inputTransformation",((e,i)=>{if(i.content.isEmpty)return;const n=this.editor.data.toModel(i.content,"$clipboardHolder");0!=n.childCount&&(e.stop(),t.change((()=>{this.fire("contentInsertion",{content:n,method:i.method,dataTransfer:i.dataTransfer,targetRanges:i.targetRanges})})))}),{priority:"low"}),this.listenTo(this,"contentInsertion",((e,t)=>{t.resultRange=s._pasteFragmentWithMarkers(t.content)}),{priority:"low"})}_setupCopyCut(){const e=this.editor,t=e.model.document,i=e.editing.view.document,n=(e,i)=>{const n=i.dataTransfer;i.preventDefault(),this._fireOutputTransformationEvent(n,t.selection,e.name)};this.listenTo(i,"copy",n,{priority:"low"}),this.listenTo(i,"cut",((t,i)=>{e.model.canEditAt(e.model.document.selection)?n(t,i):i.preventDefault()}),{priority:"low"}),this.listenTo(this,"outputTransformation",((t,n)=>{const s=e.data.toView(n.content);i.fire("clipboardOutput",{dataTransfer:n.dataTransfer,content:s,method:n.method})}),{priority:"low"}),this.listenTo(i,"clipboardOutput",((i,n)=>{n.content.isEmpty||(n.dataTransfer.setData("text/html",this.editor.data.htmlProcessor.toData(n.content)),n.dataTransfer.setData("text/plain",q_(n.content))),"cut"==n.method&&e.model.deleteContent(t.selection)}),{priority:"low"})}}class J_ extends(T()){add(e,t){const i=this._stack,n=i[0];this._insertDescriptor(e);const s=i[0];n===s||Q_(n,s)||this.fire("change:top",{oldDescriptor:n,newDescriptor:s,writer:t})}remove(e,t){const i=this._stack,n=i[0];this._removeDescriptor(e);const s=i[0];n===s||Q_(n,s)||this.fire("change:top",{oldDescriptor:n,newDescriptor:s,writer:t})}_insertDescriptor(e){const t=this._stack,i=t.findIndex((t=>t.id===e.id));if(Q_(e,t[i]))return;i>-1&&t.splice(i,1);let n=0;for(;t[n]&&Y_(t[n],e);)n++;t.splice(n,0,e)}_removeDescriptor(e){const t=this._stack,i=t.findIndex((t=>t.id===e));i>-1&&t.splice(i,1)}constructor(...e){super(...e),this._stack=[]}}function Q_(e,t){return e&&t&&e.priority==t.priority&&X_(e.classes)==X_(t.classes)}function Y_(e,t){return e.priority>t.priority||!(e.priority<t.priority)&&X_(e.classes)>X_(t.classes)}function X_(e){return Array.isArray(e)?e.sort().join(","):e}var ey='<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M4 0v1H1v3H0V.5A.5.5 0 0 1 .5 0H4zm8 0h3.5a.5.5 0 0 1 .5.5V4h-1V1h-3V0zM4 16H.5a.5.5 0 0 1-.5-.5V12h1v3h3v1zm8 0v-1h3v-3h1v3.5a.5.5 0 0 1-.5.5H12z"/><path fill-opacity=".256" d="M1 1h14v14H1z"/><g class="ck-icon__selected-indicator"><path d="M7 0h2v1H7V0zM0 7h1v2H0V7zm15 0h1v2h-1V7zm-8 8h2v1H7v-1z"/><path fill-opacity=".254" d="M1 1h14v14H1z"/></g></svg>';const ty="ck-widget",iy="ck-widget_selected";function ny(e){return!!e.is("element")&&!!e.getCustomProperty("widget")}function sy(e,t,i={}){if(!e.is("containerElement"))throw new p("widget-to-widget-wrong-element-type",null,{element:e});return t.setAttribute("contenteditable","false",e),t.addClass(ty,e),t.setCustomProperty("widget",!0,e),e.getFillerOffset=my,t.setCustomProperty("widgetLabel",[],e),i.label&&ly(e,i.label),i.hasSelectionHandle&&function(e,t){const i=t.createUIElement("div",{class:"ck ck-widget__selection-handle"},(function(e){const t=this.toDomElement(e),i=new Dg;return i.set("content",ey),i.render(),t.appendChild(i.element),t}));t.insert(t.createPositionAt(e,0),i),t.addClass(["ck-widget_with-selection-handle"],e)}(e,t),ay(e,t),e}function oy(e,t,i){if(t.classes&&i.addClass(pa(t.classes),e),t.attributes)for(const n in t.attributes)i.setAttribute(n,t.attributes[n],e)}function ry(e,t,i){if(t.classes&&i.removeClass(pa(t.classes),e),t.attributes)for(const n in t.attributes)i.removeAttribute(n,e)}function ay(e,t,i=oy,n=ry){const s=new J_;s.on("change:top",((t,s)=>{s.oldDescriptor&&n(e,s.oldDescriptor,s.writer),s.newDescriptor&&i(e,s.newDescriptor,s.writer)}));t.setCustomProperty("addHighlight",((e,t,i)=>s.add(t,i)),e),t.setCustomProperty("removeHighlight",((e,t,i)=>s.remove(t,i)),e)}function ly(e,t){e.getCustomProperty("widgetLabel").push(t)}function cy(e){return e.getCustomProperty("widgetLabel").reduce(((e,t)=>"function"==typeof t?e?e+". "+t():t():e?e+". "+t:t),"")}function dy(e,t,i={}){return t.addClass(["ck-editor__editable","ck-editor__nested-editable"],e),t.setAttribute("role","textbox",e),t.setAttribute("tabindex","-1",e),i.label&&t.setAttribute("aria-label",i.label,e),t.setAttribute("contenteditable",e.isReadOnly?"false":"true",e),e.on("change:isReadOnly",((i,n,s)=>{t.setAttribute("contenteditable",s?"false":"true",e)})),e.on("change:isFocused",((i,n,s)=>{s?t.addClass("ck-editor__nested-editable_focused",e):t.removeClass("ck-editor__nested-editable_focused",e)})),ay(e,t),e}function hy(e,t){const i=e.getSelectedElement();if(i){const n=wy(e);if(n)return t.createRange(t.createPositionAt(i,n))}return t.schema.findOptimalInsertionRange(e)}function uy(e,t){return(i,n)=>{const{mapper:s,viewPosition:o}=n,r=s.findMappedViewAncestor(o);if(!t(r))return;const a=s.toModelElement(r);n.modelPosition=e.createPositionAt(a,o.isAtStart?"before":"after")}}function my(){return null}function gy(e){const t=e.parentElement;if(!t)return 0;let i=parseFloat(t.ownerDocument.defaultView.getComputedStyle(t).width);let n=0,s=t;for(;isNaN(i);){if(s=s.parentElement,++n>5)return 0;i=parseFloat(t.ownerDocument.defaultView.getComputedStyle(s).width)}return i}function fy(e,t=new Ir(e)){const i=gy(e);return i?t.width/i*100:0}const py="widget-type-around";function by(e,t,i){return!!e&&ny(e)&&!i.isInline(t)}function wy(e){return e.getAttribute(py)}const vy=["before","after"],_y=(new DOMParser).parseFromString('<svg viewBox="0 0 10 8" xmlns="http://www.w3.org/2000/svg"><path d="M9.055.263v3.972h-6.77M1 4.216l2-2.038m-2 2 2 2.038"/></svg>',"image/svg+xml").firstChild,yy="ck-widget__type-around_disabled";class ky extends Na{static get pluginName(){return"WidgetTypeAround"}static get requires(){return[Kv,Rw]}init(){const e=this.editor,t=e.editing.view;this.on("change:isEnabled",((i,n,s)=>{t.change((e=>{for(const i of t.document.roots)s?e.removeClass(yy,i):e.addClass(yy,i)})),s||e.model.change((e=>{e.removeSelectionAttribute(py)}))})),this._enableTypeAroundUIInjection(),this._enableInsertingParagraphsOnButtonClick(),this._enableInsertingParagraphsOnEnterKeypress(),this._enableInsertingParagraphsOnTypingKeystroke(),this._enableTypeAroundFakeCaretActivationUsingKeyboardArrows(),this._enableDeleteIntegration(),this._enableInsertContentIntegration(),this._enableInsertObjectIntegration(),this._enableDeleteContentIntegration()}destroy(){super.destroy(),this._currentFakeCaretModelElement=null}_insertParagraph(e,t){const i=this.editor,n=i.editing.view,s=i.model.schema.getAttributesWithProperty(e,"copyOnReplace",!0);i.execute("insertParagraph",{position:i.model.createPositionAt(e,t),attributes:s}),n.focus(),n.scrollToTheSelection()}_listenToIfEnabled(e,t,i,n){this.listenTo(e,t,((...e)=>{this.isEnabled&&i(...e)}),n)}_insertParagraphAccordingToFakeCaretPosition(){const e=this.editor.model.document.selection,t=wy(e);if(!t)return!1;const i=e.getSelectedElement();return this._insertParagraph(i,t),!0}_enableTypeAroundUIInjection(){const e=this.editor,t=e.model.schema,i=e.locale.t,n={before:i("Insert paragraph before block"),after:i("Insert paragraph after block")};e.editing.downcastDispatcher.on("insert",((e,s,o)=>{const r=o.mapper.toViewElement(s.item);if(r&&by(r,s.item,t)){!function(e,t,i){const n=e.createUIElement("div",{class:"ck ck-reset_all ck-widget__type-around"},(function(e){const i=this.toDomElement(e);return function(e,t){for(const i of vy){const n=new rg({tag:"div",attributes:{class:["ck","ck-widget__type-around__button",`ck-widget__type-around__button_${i}`],title:t[i],"aria-hidden":"true"},children:[e.ownerDocument.importNode(_y,!0)]});e.appendChild(n.render())}}(i,t),function(e){const t=new rg({tag:"div",attributes:{class:["ck","ck-widget__type-around__fake-caret"]}});e.appendChild(t.render())}(i),i}));e.insert(e.createPositionAt(i,"end"),n)}(o.writer,n,r);r.getCustomProperty("widgetLabel").push((()=>this.isEnabled?i("Press Enter to type after or press Shift + Enter to type before the widget"):""))}}),{priority:"low"})}_enableTypeAroundFakeCaretActivationUsingKeyboardArrows(){const e=this.editor,t=e.model,i=t.document.selection,n=t.schema,s=e.editing.view;function o(e){return`ck-widget_type-around_show-fake-caret_${e}`}this._listenToIfEnabled(s.document,"arrowKey",((e,t)=>{this._handleArrowKeyPress(e,t)}),{context:[ny,"$text"],priority:"high"}),this._listenToIfEnabled(i,"change:range",((t,i)=>{i.directChange&&e.model.change((e=>{e.removeSelectionAttribute(py)}))})),this._listenToIfEnabled(t.document,"change:data",(()=>{const t=i.getSelectedElement();if(t){if(by(e.editing.mapper.toViewElement(t),t,n))return}e.model.change((e=>{e.removeSelectionAttribute(py)}))})),this._listenToIfEnabled(e.editing.downcastDispatcher,"selection",((e,t,i)=>{const s=i.writer;if(this._currentFakeCaretModelElement){const e=i.mapper.toViewElement(this._currentFakeCaretModelElement);e&&(s.removeClass(vy.map(o),e),this._currentFakeCaretModelElement=null)}const r=t.selection.getSelectedElement();if(!r)return;const a=i.mapper.toViewElement(r);if(!by(a,r,n))return;const l=wy(t.selection);l&&(s.addClass(o(l),a),this._currentFakeCaretModelElement=r)})),this._listenToIfEnabled(e.ui.focusTracker,"change:isFocused",((t,i,n)=>{n||e.model.change((e=>{e.removeSelectionAttribute(py)}))}))}_handleArrowKeyPress(e,t){const i=this.editor,n=i.model,s=n.document.selection,o=n.schema,r=i.editing.view,a=ma(t.keyCode,i.locale.contentLanguageDirection),l=r.document.selection.getSelectedElement();let c;by(l,i.editing.mapper.toModelElement(l),o)?c=this._handleArrowKeyPressOnSelectedWidget(a):s.isCollapsed?c=this._handleArrowKeyPressWhenSelectionNextToAWidget(a):t.shiftKey||(c=this._handleArrowKeyPressWhenNonCollapsedSelection(a)),c&&(t.preventDefault(),e.stop())}_handleArrowKeyPressOnSelectedWidget(e){const t=this.editor.model,i=wy(t.document.selection);return t.change((t=>{if(!i)return t.setSelectionAttribute(py,e?"after":"before"),!0;if(!(i===(e?"after":"before")))return t.removeSelectionAttribute(py),!0;return!1}))}_handleArrowKeyPressWhenSelectionNextToAWidget(e){const t=this.editor,i=t.model,n=i.schema,s=t.plugins.get("Widget"),o=s._getObjectElementNextToSelection(e);return!!by(t.editing.mapper.toViewElement(o),o,n)&&(i.change((t=>{s._setSelectionOverElement(o),t.setSelectionAttribute(py,e?"before":"after")})),!0)}_handleArrowKeyPressWhenNonCollapsedSelection(e){const t=this.editor,i=t.model,n=i.schema,s=t.editing.mapper,o=i.document.selection,r=e?o.getLastPosition().nodeBefore:o.getFirstPosition().nodeAfter;return!!by(s.toViewElement(r),r,n)&&(i.change((t=>{t.setSelection(r,"on"),t.setSelectionAttribute(py,e?"after":"before")})),!0)}_enableInsertingParagraphsOnButtonClick(){const e=this.editor,t=e.editing.view;this._listenToIfEnabled(t.document,"mousedown",((i,n)=>{const s=n.domTarget.closest(".ck-widget__type-around__button");if(!s)return;const o=function(e){return e.classList.contains("ck-widget__type-around__button_before")?"before":"after"}(s),r=function(e,t){const i=e.closest(".ck-widget");return t.mapDomToView(i)}(s,t.domConverter),a=e.editing.mapper.toModelElement(r);this._insertParagraph(a,o),n.preventDefault(),i.stop()}))}_enableInsertingParagraphsOnEnterKeypress(){const e=this.editor,t=e.model.document.selection,i=e.editing.view;this._listenToIfEnabled(i.document,"enter",((i,n)=>{if("atTarget"!=i.eventPhase)return;const s=t.getSelectedElement(),o=e.editing.mapper.toViewElement(s),r=e.model.schema;let a;this._insertParagraphAccordingToFakeCaretPosition()?a=!0:by(o,s,r)&&(this._insertParagraph(s,n.isSoft?"before":"after"),a=!0),a&&(n.preventDefault(),i.stop())}),{context:ny})}_enableInsertingParagraphsOnTypingKeystroke(){const e=this.editor.editing.view.document;this._listenToIfEnabled(e,"insertText",((t,i)=>{this._insertParagraphAccordingToFakeCaretPosition()&&(i.selection=e.selection)}),{priority:"high"}),i.isAndroid?this._listenToIfEnabled(e,"keydown",((e,t)=>{229==t.keyCode&&this._insertParagraphAccordingToFakeCaretPosition()})):this._listenToIfEnabled(e,"compositionstart",(()=>{this._insertParagraphAccordingToFakeCaretPosition()}),{priority:"high"})}_enableDeleteIntegration(){const e=this.editor,t=e.editing.view,i=e.model,n=i.schema;this._listenToIfEnabled(t.document,"delete",((t,s)=>{if("atTarget"!=t.eventPhase)return;const o=wy(i.document.selection);if(!o)return;const r=s.direction,a=i.document.selection.getSelectedElement(),l="forward"==r;if("before"===o===l)e.execute("delete",{selection:i.createSelection(a,"on")});else{const t=n.getNearestSelectionRange(i.createPositionAt(a,o),r);if(t)if(t.isCollapsed){const s=i.createSelection(t.start);if(i.modifySelection(s,{direction:r}),s.focus.isEqual(t.start)){const e=function(e,t){let i=t;for(const n of t.getAncestors({parentFirst:!0})){if(n.childCount>1||e.isLimit(n))break;i=n}return i}(n,t.start.parent);i.deleteContent(i.createSelection(e,"on"),{doNotAutoparagraph:!0})}else i.change((i=>{i.setSelection(t),e.execute(l?"deleteForward":"delete")}))}else i.change((i=>{i.setSelection(t),e.execute(l?"deleteForward":"delete")}))}s.preventDefault(),t.stop()}),{context:ny})}_enableInsertContentIntegration(){const e=this.editor,t=this.editor.model,i=t.document.selection;this._listenToIfEnabled(e.model,"insertContent",((e,[n,s])=>{if(s&&!s.is("documentSelection"))return;const o=wy(i);return o?(e.stop(),t.change((e=>{const s=i.getSelectedElement(),r=t.createPositionAt(s,o),a=e.createSelection(r),l=t.insertContent(n,a);return e.setSelection(a),l}))):void 0}),{priority:"high"})}_enableInsertObjectIntegration(){const e=this.editor,t=this.editor.model.document.selection;this._listenToIfEnabled(e.model,"insertObject",((e,i)=>{const[,n,s={}]=i;if(n&&!n.is("documentSelection"))return;const o=wy(t);o&&(s.findOptimalPosition=o,i[3]=s)}),{priority:"high"})}_enableDeleteContentIntegration(){const e=this.editor,t=this.editor.model.document.selection;this._listenToIfEnabled(e.model,"deleteContent",((e,[i])=>{if(i&&!i.is("documentSelection"))return;wy(t)&&e.stop()}),{priority:"high"})}constructor(...e){super(...e),this._currentFakeCaretModelElement=null}}function Cy(e){const t=e.model;return(i,n)=>{const s=n.keyCode==ra.arrowup,o=n.keyCode==ra.arrowdown,r=n.shiftKey,a=t.document.selection;if(!s&&!o)return;const l=o;if(r&&function(e,t){return!e.isCollapsed&&e.isBackward==t}(a,l))return;const c=function(e,t,i){const n=e.model;if(i){const e=t.isCollapsed?t.focus:t.getLastPosition(),i=xy(n,e,"forward");if(!i)return null;const s=n.createRange(e,i),o=Ay(n.schema,s,"backward");return o?n.createRange(e,o):null}{const e=t.isCollapsed?t.focus:t.getFirstPosition(),i=xy(n,e,"backward");if(!i)return null;const s=n.createRange(i,e),o=Ay(n.schema,s,"forward");return o?n.createRange(o,e):null}}(e,a,l);if(c){if(c.isCollapsed){if(a.isCollapsed)return;if(r)return}(c.isCollapsed||function(e,t,i){const n=e.model,s=e.view.domConverter;if(i){const e=n.createSelection(t.start);n.modifySelection(e),e.focus.isAtEnd||t.start.isEqual(e.focus)||(t=n.createRange(e.focus,t.end))}const o=e.mapper.toViewRange(t),r=s.viewRangeToDom(o),a=Ir.getDomRangeRects(r);let l;for(const e of a)if(void 0!==l){if(Math.round(e.top)>=l)return!1;l=Math.max(l,Math.round(e.bottom))}else l=Math.round(e.bottom);return!0}(e,c,l))&&(t.change((e=>{const i=l?c.end:c.start;if(r){const n=t.createSelection(a.anchor);n.setFocus(i),e.setSelection(n)}else e.setSelection(i)})),i.stop(),n.preventDefault(),n.stopPropagation())}}}function xy(e,t,i){const n=e.schema,s=e.createRangeIn(t.root),o="forward"==i?"elementStart":"elementEnd";for(const{previousPosition:e,item:r,type:a}of s.getWalker({startPosition:t,direction:i})){if(n.isLimit(r)&&!n.isInline(r))return e;if(a==o&&n.isBlock(r))return null}return null}function Ay(e,t,i){const n="backward"==i?t.end:t.start;if(e.checkChild(n,"$text"))return n;for(const{nextPosition:n}of t.getWalker({direction:i}))if(e.checkChild(n,"$text"))return n;return null}class Ey extends Na{static get pluginName(){return"Widget"}static get requires(){return[ky,Rw]}init(){const e=this.editor,t=e.editing.view,i=t.document,n=e.t;this.editor.editing.downcastDispatcher.on("selection",((t,i,n)=>{const s=n.writer,o=i.selection;if(o.isCollapsed)return;const r=o.getSelectedElement();if(!r)return;const a=e.editing.mapper.toViewElement(r);ny(a)&&n.consumable.consume(o,"selection")&&s.setSelection(s.createRangeOn(a),{fake:!0,label:cy(a)})})),this.editor.editing.downcastDispatcher.on("selection",((e,t,i)=>{this._clearPreviouslySelectedWidgets(i.writer);const n=i.writer,s=n.document.selection;let o=null;for(const e of s.getRanges())for(const t of e){const e=t.item;ny(e)&&!Ty(e,o)&&(n.addClass(iy,e),this._previouslySelected.add(e),o=e)}}),{priority:"low"}),t.addObserver(zu),this.listenTo(i,"mousedown",((...e)=>this._onMousedown(...e))),this.listenTo(i,"arrowKey",((...e)=>{this._handleSelectionChangeOnArrowKeyPress(...e)}),{context:[ny,"$text"]}),this.listenTo(i,"arrowKey",((...e)=>{this._preventDefaultOnArrowKeyPress(...e)}),{context:"$root"}),this.listenTo(i,"arrowKey",Cy(this.editor.editing),{context:"$text"}),this.listenTo(i,"delete",((e,t)=>{this._handleDelete("forward"==t.direction)&&(t.preventDefault(),e.stop())}),{context:"$root"}),this.listenTo(i,"tab",((e,t)=>{"atTarget"==e.eventPhase&&(t.shiftKey||this._selectFirstNestedEditable()&&(t.preventDefault(),e.stop()))}),{context:ny,priority:"low"}),this.listenTo(i,"tab",((e,t)=>{t.shiftKey&&this._selectAncestorWidget()&&(t.preventDefault(),e.stop())}),{priority:"low"}),this.listenTo(i,"keydown",((e,t)=>{t.keystroke==ra.esc&&this._selectAncestorWidget()&&(t.preventDefault(),e.stop())}),{priority:"low"}),e.accessibility.addKeystrokeInfoGroup({id:"widget",label:n("Keystrokes that can be used when a widget is selected (for example: image, table, etc.)"),keystrokes:[{label:n("Insert a new paragraph directly after a widget"),keystroke:"Enter"},{label:n("Insert a new paragraph directly before a widget"),keystroke:"Shift+Enter"},{label:n("Move the caret to allow typing directly before a widget"),keystroke:[["arrowup"],["arrowleft"]]},{label:n("Move the caret to allow typing directly after a widget"),keystroke:[["arrowdown"],["arrowright"]]}]})}_onMousedown(e,t){const n=this.editor,s=n.editing.view,o=s.document;let r=t.target;if(t.domEvent.detail>=3)return void(this._selectBlockContent(r)&&t.preventDefault());if(function(e){let t=e;for(;t;){if(t.is("editableElement")&&!t.is("rootElement"))return!0;if(ny(t))return!1;t=t.parent}return!1}(r))return;if(!ny(r)&&(r=r.findAncestor(ny),!r))return;i.isAndroid&&t.preventDefault(),o.isFocused||s.focus();const a=n.editing.mapper.toModelElement(r);this._setSelectionOverElement(a)}_selectBlockContent(e){const t=this.editor,i=t.model,n=t.editing.mapper,s=i.schema,o=n.findMappedViewAncestor(this.editor.editing.view.createPositionAt(e,0)),r=function(e,t){for(const i of e.getAncestors({includeSelf:!0,parentFirst:!0})){if(t.checkChild(i,"$text"))return i;if(t.isLimit(i)&&!t.isObject(i))break}return null}(n.toModelElement(o),i.schema);return!!r&&(i.change((e=>{const t=s.isLimit(r)?null:function(e,t){const i=new Kc({startPosition:e});for(const{item:e}of i){if(t.isLimit(e)||!e.is("element"))return null;if(t.checkChild(e,"$text"))return e}return null}(e.createPositionAfter(r),s),i=e.createPositionAt(r,0),n=t?e.createPositionAt(t,0):e.createPositionAt(r,"end");e.setSelection(e.createRange(i,n))})),!0)}_handleSelectionChangeOnArrowKeyPress(e,t){const i=t.keyCode,n=this.editor.model,s=n.schema,o=n.document.selection,r=o.getSelectedElement(),a=ua(i,this.editor.locale.contentLanguageDirection),l="down"==a||"right"==a,c="up"==a||"down"==a;if(r&&s.isObject(r)){const i=l?o.getLastPosition():o.getFirstPosition(),r=s.getNearestSelectionRange(i,l?"forward":"backward");return void(r&&(n.change((e=>{e.setSelection(r)})),t.preventDefault(),e.stop()))}if(!o.isCollapsed&&!t.shiftKey){const i=o.getFirstPosition(),r=o.getLastPosition(),a=i.nodeAfter,c=r.nodeBefore;return void((a&&s.isObject(a)||c&&s.isObject(c))&&(n.change((e=>{e.setSelection(l?r:i)})),t.preventDefault(),e.stop()))}if(!o.isCollapsed)return;const d=this._getObjectElementNextToSelection(l);if(d&&s.isObject(d)){if(s.isInline(d)&&c)return;this._setSelectionOverElement(d),t.preventDefault(),e.stop()}}_preventDefaultOnArrowKeyPress(e,t){const i=this.editor.model,n=i.schema,s=i.document.selection.getSelectedElement();s&&n.isObject(s)&&(t.preventDefault(),e.stop())}_handleDelete(e){const t=this.editor.model.document.selection;if(!this.editor.model.canEditAt(t))return;if(!t.isCollapsed)return;const i=this._getObjectElementNextToSelection(e);return i?(this.editor.model.change((e=>{let n=t.anchor.parent;for(;n.isEmpty;){const t=n;n=t.parent,e.remove(t)}this._setSelectionOverElement(i)})),!0):void 0}_setSelectionOverElement(e){this.editor.model.change((t=>{t.setSelection(t.createRangeOn(e))}))}_getObjectElementNextToSelection(e){const t=this.editor.model,i=t.schema,n=t.document.selection,s=t.createSelection(n);if(t.modifySelection(s,{direction:e?"forward":"backward"}),s.isEqual(n))return null;const o=e?s.focus.nodeBefore:s.focus.nodeAfter;return o&&i.isObject(o)?o:null}_clearPreviouslySelectedWidgets(e){for(const t of this._previouslySelected)e.removeClass(iy,t);this._previouslySelected.clear()}_selectFirstNestedEditable(){const e=this.editor,t=this.editor.editing.view.document;for(const i of t.selection.getFirstRange().getItems())if(i.is("editableElement")){const t=e.editing.mapper.toModelElement(i);if(!t)continue;const n=e.model.createPositionAt(t,0),s=e.model.schema.getNearestSelectionRange(n,"forward");return e.model.change((e=>{e.setSelection(s)})),!0}return!1}_selectAncestorWidget(){const e=this.editor,t=e.editing.mapper,i=e.editing.view.document.selection.getFirstPosition().parent,n=(i.is("$text")?i.parent:i).findAncestor(ny);if(!n)return!1;const s=t.toModelElement(n);return!!s&&(e.model.change((e=>{e.setSelection(s,"on")})),!0)}constructor(...e){super(...e),this._previouslySelected=new Set}}function Ty(e,t){return!!t&&Array.from(e.getAncestors()).includes(t)}class Sy extends Na{static get requires(){return[Tb]}static get pluginName(){return"WidgetToolbarRepository"}init(){const e=this.editor;if(e.plugins.has("BalloonToolbar")){const t=e.plugins.get("BalloonToolbar");this.listenTo(t,"show",(t=>{(function(e){const t=e.getSelectedElement();return!(!t||!ny(t))})(e.editing.view.document.selection)&&t.stop()}),{priority:"high"})}this._balloon=this.editor.plugins.get("ContextualBalloon"),this.on("change:isEnabled",(()=>{this._updateToolbarsVisibility()})),this.listenTo(e.ui,"update",(()=>{this._updateToolbarsVisibility()})),this.listenTo(e.ui.focusTracker,"change:isFocused",(()=>{this._updateToolbarsVisibility()}),{priority:"low"})}destroy(){super.destroy();for(const e of this._toolbarDefinitions.values())e.view.destroy()}register(e,{ariaLabel:t,items:i,getRelatedElement:n,balloonClassName:s="ck-toolbar-container"}){if(!i.length)return void b("widget-toolbar-no-items",{toolbarId:e});const o=this.editor,r=o.t,a=new Mf(o.locale);if(a.ariaLabel=t||r("Widget toolbar"),this._toolbarDefinitions.has(e))throw new p("widget-toolbar-duplicated",this,{toolbarId:e});const l={view:a,getRelatedElement:n,balloonClassName:s,itemsConfig:i,initialized:!1};o.ui.addToolbar(a,{isContextual:!0,beforeFocus:()=>{const e=n(o.editing.view.document.selection);e&&this._showToolbar(l,e)},afterBlur:()=>{this._hideToolbar(l)}}),this._toolbarDefinitions.set(e,l)}_updateToolbarsVisibility(){let e=0,t=null,i=null;for(const n of this._toolbarDefinitions.values()){const s=n.getRelatedElement(this.editor.editing.view.document.selection);if(this.isEnabled&&s)if(this.editor.ui.focusTracker.isFocused){const o=s.getAncestors().length;o>e&&(e=o,t=s,i=n)}else this._isToolbarVisible(n)&&this._hideToolbar(n);else this._isToolbarInBalloon(n)&&this._hideToolbar(n)}i&&this._showToolbar(i,t)}_hideToolbar(e){this._balloon.remove(e.view),this.stopListening(this._balloon,"change:visibleView")}_showToolbar(e,t){this._isToolbarVisible(e)?Iy(this.editor,t):this._isToolbarInBalloon(e)||(e.initialized||(e.initialized=!0,e.view.fillFromConfig(e.itemsConfig,this.editor.ui.componentFactory)),this._balloon.add({view:e.view,position:Py(this.editor,t),balloonClassName:e.balloonClassName}),this.listenTo(this._balloon,"change:visibleView",(()=>{for(const e of this._toolbarDefinitions.values())if(this._isToolbarVisible(e)){const t=e.getRelatedElement(this.editor.editing.view.document.selection);Iy(this.editor,t)}})))}_isToolbarVisible(e){return this._balloon.visibleView===e.view}_isToolbarInBalloon(e){return this._balloon.hasView(e.view)}constructor(...e){super(...e),this._toolbarDefinitions=new Map}}function Iy(e,t){const i=e.plugins.get("ContextualBalloon"),n=Py(e,t);i.updatePosition(n)}function Py(e,t){const i=e.editing.view,n=Xp.defaultPositions;return{target:i.domConverter.mapViewToDom(t),positions:[n.northArrowSouth,n.northArrowSouthWest,n.northArrowSouthEast,n.southArrowNorth,n.southArrowNorthWest,n.southArrowNorthEast,n.viewportStickyNorth]}}class Vy extends(Yo()){get originalWidth(){return this._originalWidth}get originalHeight(){return this._originalHeight}get originalWidthPercents(){return this._originalWidthPercents}get aspectRatio(){return this._aspectRatio}begin(e,t,i){const n=new Ir(t);this.activeHandlePosition=function(e){const t=["top-left","top-right","bottom-right","bottom-left"];for(const i of t)if(e.classList.contains(Ry(i)))return i}(e),this._referenceCoordinates=function(e,t){const i=new Ir(e),n=t.split("-"),s={x:"right"==n[1]?i.right:i.left,y:"bottom"==n[0]?i.bottom:i.top};return s.x+=e.ownerDocument.defaultView.scrollX,s.y+=e.ownerDocument.defaultView.scrollY,s}(t,function(e){const t=e.split("-"),i={top:"bottom",bottom:"top",left:"right",right:"left"};return`${i[t[0]]}-${i[t[1]]}`}(this.activeHandlePosition)),this._originalWidth=n.width,this._originalHeight=n.height,this._aspectRatio=n.width/n.height;const s=i.style.width;s&&s.match(/^\d+(\.\d*)?%$/)?this._originalWidthPercents=parseFloat(s):this._originalWidthPercents=fy(i,n)}update(e){this.proposedWidth=e.width,this.proposedHeight=e.height,this.proposedWidthPercents=e.widthPercents,this.proposedHandleHostWidth=e.handleHostWidth,this.proposedHandleHostHeight=e.handleHostHeight}constructor(e){super(),this.set("activeHandlePosition",null),this.set("proposedWidthPercents",null),this.set("proposedWidth",null),this.set("proposedHeight",null),this.set("proposedHandleHostWidth",null),this.set("proposedHandleHostHeight",null),this._options=e,this._referenceCoordinates=null}}function Ry(e){return`ck-widget__resizer__handle-${e}`}class By extends Tg{_bindToState(e,t){this.bind("_isVisible").to(t,"proposedWidth",t,"proposedHeight",((e,t)=>null!==e&&null!==t)),this.bind("_label").to(t,"proposedHandleHostWidth",t,"proposedHandleHostHeight",t,"proposedWidthPercents",((t,i,n)=>"px"===e.unit?`${t}×${i}`:`${n}%`)),this.bind("_viewPosition").to(t,"activeHandlePosition",t,"proposedHandleHostWidth",t,"proposedHandleHostHeight",((e,t,i)=>t<50||i<50?"above-center":e))}_dismiss(){this.unbind(),this._isVisible=!1}constructor(){super();const e=this.bindTemplate;this.setTemplate({tag:"div",attributes:{class:["ck","ck-size-view",e.to("_viewPosition",(e=>e?`ck-orientation-${e}`:""))],style:{display:e.if("_isVisible","none",(e=>!e))}},children:[{text:e.to("_label")}]})}}class Oy extends(Yo()){get state(){return this._state}show(){this._options.editor.editing.view.change((e=>{e.removeClass("ck-hidden",this._viewResizerWrapper)}))}hide(){this._options.editor.editing.view.change((e=>{e.addClass("ck-hidden",this._viewResizerWrapper)}))}attach(){const e=this,t=this._options.viewElement;this._options.editor.editing.view.change((i=>{const n=i.createUIElement("div",{class:"ck ck-reset_all ck-widget__resizer"},(function(t){const i=this.toDomElement(t);return e._appendHandles(i),e._appendSizeUI(i),i}));i.insert(i.createPositionAt(t,"end"),n),i.addClass("ck-widget_with-resizer",t),this._viewResizerWrapper=n,this.isVisible||this.hide()})),this.on("change:isVisible",(()=>{this.isVisible?(this.show(),this.redraw()):this.hide()}))}begin(e){this._state=new Vy(this._options),this._sizeView._bindToState(this._options,this.state),this._initialViewWidth=this._options.viewElement.getStyle("width"),this.state.begin(e,this._getHandleHost(),this._getResizeHost())}updateSize(e){const t=this._proposeNewSize(e);this._options.editor.editing.view.change((e=>{const i=this._options.unit||"%",n=("%"===i?t.widthPercents:t.width)+i;e.setStyle("width",n,this._options.viewElement)}));const i=this._getHandleHost(),n=new Ir(i),s=Math.round(n.width),o=Math.round(n.height),r=new Ir(i);t.width=Math.round(r.width),t.height=Math.round(r.height),this.redraw(n),this.state.update({...t,handleHostWidth:s,handleHostHeight:o})}commit(){const e=this._options.unit||"%",t=("%"===e?this.state.proposedWidthPercents:this.state.proposedWidth)+e;this._options.editor.editing.view.change((()=>{this._cleanup(),this._options.onCommit(t)}))}cancel(){this._cleanup()}destroy(){this.cancel()}redraw(e){const t=this._domResizerWrapper;if(!((i=t)&&i.ownerDocument&&i.ownerDocument.contains(i)))return;var i;const n=t.parentElement,s=this._getHandleHost(),o=this._viewResizerWrapper,r=[o.getStyle("width"),o.getStyle("height"),o.getStyle("left"),o.getStyle("top")];let a;if(n.isSameNode(s)){const t=e||new Ir(s);a=[t.width+"px",t.height+"px",void 0,void 0]}else a=[s.offsetWidth+"px",s.offsetHeight+"px",s.offsetLeft+"px",s.offsetTop+"px"];"same"!==ar(r,a)&&this._options.editor.editing.view.change((e=>{e.setStyle({width:a[0],height:a[1],left:a[2],top:a[3]},o)}))}containsHandle(e){return this._domResizerWrapper.contains(e)}static isResizeHandle(e){return e.classList.contains("ck-widget__resizer__handle")}_cleanup(){this._sizeView._dismiss();this._options.editor.editing.view.change((e=>{e.setStyle("width",this._initialViewWidth,this._options.viewElement)}))}_proposeNewSize(e){const t=this.state,i={x:(n=e).pageX,y:n.pageY};var n;const s=!this._options.isCentered||this._options.isCentered(this),o={x:t._referenceCoordinates.x-(i.x+t.originalWidth),y:i.y-t.originalHeight-t._referenceCoordinates.y};s&&t.activeHandlePosition.endsWith("-right")&&(o.x=i.x-(t._referenceCoordinates.x+t.originalWidth)),s&&(o.x*=2);let r=Math.abs(t.originalWidth+o.x),a=Math.abs(t.originalHeight+o.y);return"width"==(r/t.aspectRatio>a?"width":"height")?a=r/t.aspectRatio:r=a*t.aspectRatio,{width:Math.round(r),height:Math.round(a),widthPercents:Math.min(Math.round(t.originalWidthPercents/t.originalWidth*r*100)/100,100)}}_getResizeHost(){const e=this._domResizerWrapper.parentElement;return this._options.getResizeHost(e)}_getHandleHost(){const e=this._domResizerWrapper.parentElement;return this._options.getHandleHost(e)}get _domResizerWrapper(){return this._options.editor.editing.view.domConverter.mapViewToDom(this._viewResizerWrapper)}_appendHandles(e){const t=["top-left","top-right","bottom-right","bottom-left"];for(const n of t)e.appendChild(new rg({tag:"div",attributes:{class:"ck-widget__resizer__handle "+(i=n,`ck-widget__resizer__handle-${i}`)}}).render());var i}_appendSizeUI(e){this._sizeView=new By,this._sizeView.render(),e.appendChild(this._sizeView.element)}constructor(e){super(),this._viewResizerWrapper=null,this._options=e,this.set("isEnabled",!0),this.set("isSelected",!1),this.bind("isVisible").to(this,"isEnabled",this,"isSelected",((e,t)=>e&&t)),this.decorate("begin"),this.decorate("cancel"),this.decorate("commit"),this.decorate("updateSize"),this.on("commit",(e=>{this.state.proposedWidth||this.state.proposedWidthPercents||(this._cleanup(),e.stop())}),{priority:"high"})}}class My extends Na{static get pluginName(){return"WidgetResize"}init(){const e=this.editor.editing,t=_r.window.document;this.set("selectedResizer",null),this.set("_activeResizer",null),e.view.addObserver(zu),this._observer=new(pr()),this.listenTo(e.view.document,"mousedown",this._mouseDownListener.bind(this),{priority:"high"}),this._observer.listenTo(t,"mousemove",this._mouseMoveListener.bind(this)),this._observer.listenTo(t,"mouseup",this._mouseUpListener.bind(this)),this._redrawSelectedResizerThrottled=jo((()=>this.redrawSelectedResizer()),200),this.editor.ui.on("update",this._redrawSelectedResizerThrottled),this.editor.model.document.on("change",(()=>{for(const[e,t]of this._resizers)e.isAttached()||(this._resizers.delete(e),t.destroy())}),{priority:"lowest"}),this._observer.listenTo(_r.window,"resize",this._redrawSelectedResizerThrottled);const i=this.editor.editing.view.document.selection;i.on("change",(()=>{const e=i.getSelectedElement(),t=this.getResizerByViewElement(e)||null;t?this.select(t):this.deselect()}))}redrawSelectedResizer(){this.selectedResizer&&this.selectedResizer.isVisible&&this.selectedResizer.redraw()}destroy(){super.destroy(),this._observer.stopListening();for(const e of this._resizers.values())e.destroy();this._redrawSelectedResizerThrottled.cancel()}select(e){this.deselect(),this.selectedResizer=e,this.selectedResizer.isSelected=!0}deselect(){this.selectedResizer&&(this.selectedResizer.isSelected=!1),this.selectedResizer=null}attachTo(e){const t=new Oy(e),i=this.editor.plugins;if(t.attach(),i.has("WidgetToolbarRepository")){const e=i.get("WidgetToolbarRepository");t.on("begin",(()=>{e.forceDisabled("resize")}),{priority:"lowest"}),t.on("cancel",(()=>{e.clearForceDisabled("resize")}),{priority:"highest"}),t.on("commit",(()=>{e.clearForceDisabled("resize")}),{priority:"highest"})}this._resizers.set(e.viewElement,t);const n=this.editor.editing.view.document.selection.getSelectedElement();return this.getResizerByViewElement(n)==t&&this.select(t),t}getResizerByViewElement(e){return this._resizers.get(e)}_getResizerByHandle(e){for(const t of this._resizers.values())if(t.containsHandle(e))return t}_mouseDownListener(e,t){const i=t.domTarget;Oy.isResizeHandle(i)&&(this._activeResizer=this._getResizerByHandle(i)||null,this._activeResizer&&(this._activeResizer.begin(i),e.stop(),t.preventDefault()))}_mouseMoveListener(e,t){this._activeResizer&&this._activeResizer.updateSize(t)}_mouseUpListener(){this._activeResizer&&(this._activeResizer.commit(),this._activeResizer=null)}constructor(...e){super(...e),this._resizers=new Map}}const Ly=Lr("px");class Ny extends Tg{constructor(){super();const e=this.bindTemplate;this.set({isVisible:!1,left:null,top:null,width:null}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-clipboard-drop-target-line",e.if("isVisible","ck-hidden",(e=>!e))],style:{left:e.to("left",(e=>Ly(e))),top:e.to("top",(e=>Ly(e))),width:e.to("width",(e=>Ly(e)))}}})}}class Fy extends Na{static get pluginName(){return"DragDropTarget"}init(){this._setupDropMarker()}destroy(){this._domEmitter.stopListening();for(const{resizeObserver:e}of this._scrollables.values())e.destroy();return this._updateDropMarkerThrottled.cancel(),this.removeDropMarkerDelayed.cancel(),this._reconvertMarkerThrottled.cancel(),super.destroy()}updateDropMarker(e,t,i,n,s,o){this.removeDropMarkerDelayed.cancel();const r=Dy(this.editor,e,t,i,n,s,o);if(r)return o&&o.containsRange(r)?this.removeDropMarker():void this._updateDropMarkerThrottled(r)}getFinalDropRange(e,t,i,n,s,o){const r=Dy(this.editor,e,t,i,n,s,o);return this.removeDropMarker(),r}removeDropMarker(){const e=this.editor.model;this.removeDropMarkerDelayed.cancel(),this._updateDropMarkerThrottled.cancel(),this._dropTargetLineView.isVisible=!1,e.markers.has("drop-target")&&e.change((e=>{e.removeMarker("drop-target")}))}_setupDropMarker(){const e=this.editor;e.ui.view.body.add(this._dropTargetLineView),e.conversion.for("editingDowncast").markerToHighlight({model:"drop-target",view:{classes:["ck-clipboard-drop-target-range"]}}),e.conversion.for("editingDowncast").markerToElement({model:"drop-target",view:(t,{writer:i})=>{if(e.model.schema.checkChild(t.markerRange.start,"$text"))return this._dropTargetLineView.isVisible=!1,this._createDropTargetPosition(i);t.markerRange.isCollapsed?this._updateDropTargetLine(t.markerRange):this._dropTargetLineView.isVisible=!1}})}_updateDropMarker(e){const t=this.editor,i=t.model.markers;t.model.change((t=>{i.has("drop-target")?i.get("drop-target").getRange().isEqual(e)||t.updateMarker("drop-target",{range:e}):t.addMarker("drop-target",{range:e,usingOperation:!1,affectsData:!1})}))}_createDropTargetPosition(e){return e.createUIElement("span",{class:"ck ck-clipboard-drop-target-position"},(function(e){const t=this.toDomElement(e);return t.append("⁠",e.createElement("span"),"⁠"),t}))}_updateDropTargetLine(e){const t=this.editor.editing,i=e.start.nodeBefore,n=e.start.nodeAfter,s=e.start.parent,o=i?t.mapper.toViewElement(i):null,r=o?t.view.domConverter.mapViewToDom(o):null,a=n?t.mapper.toViewElement(n):null,l=a?t.view.domConverter.mapViewToDom(a):null,c=t.mapper.toViewElement(s);if(!c)return;const d=t.view.domConverter.mapViewToDom(c),h=this._getScrollableRect(c),{scrollX:u,scrollY:m}=_r.window,g=r?new Ir(r):null,f=l?new Ir(l):null,p=new Ir(d).excludeScrollbarsAndBorders(),b=g?g.bottom:p.top,w=f?f.top:p.bottom,v=_r.window.getComputedStyle(d),_=b<=w?(b+w)/2:w;if(h.top<_&&_<h.bottom){const e=p.left+parseFloat(v.paddingLeft),t=p.right-parseFloat(v.paddingRight),i=Math.max(e+u,h.left),n=Math.min(t+u,h.right);this._dropTargetLineView.set({isVisible:!0,left:i,top:_+m,width:n-i})}else this._dropTargetLineView.isVisible=!1}_getScrollableRect(e){const t=e.root.rootName;let i;if(this._scrollables.has(t))i=this._scrollables.get(t).domElement;else{i=function(e){let t=e;do{t=t.parentElement;const e=_r.window.getComputedStyle(t).overflowY;if("auto"==e||"scroll"==e)break}while("BODY"!=t.tagName);return t}(this.editor.editing.view.domConverter.mapViewToDom(e)),this._domEmitter.listenTo(i,"scroll",this._reconvertMarkerThrottled,{usePassive:!0});const n=new Or(i,this._reconvertMarkerThrottled);this._scrollables.set(t,{domElement:i,resizeObserver:n})}return new Ir(i).excludeScrollbarsAndBorders()}constructor(...e){super(...e),this.removeDropMarkerDelayed=Sa((()=>this.removeDropMarker()),40),this._updateDropMarkerThrottled=jo((e=>this._updateDropMarker(e)),40),this._reconvertMarkerThrottled=jo((()=>{this.editor.model.markers.has("drop-target")&&this.editor.editing.reconvertMarker("drop-target")}),0),this._dropTargetLineView=new Ny,this._domEmitter=new(pr()),this._scrollables=new Map}}function Dy(e,t,i,n,s,o,r){const a=e.model,l=e.editing.mapper;let c=Uy(e,t);for(;c;){if(!o)if(a.schema.checkChild(c,"$text")){if(i){const t=i[0].start,o=l.toModelPosition(t);if(!r||Array.from(r.getItems()).every((e=>a.schema.checkChild(o,e)))){if(a.schema.checkChild(o,"$text"))return a.createRange(o);if(t)return Hy(e,Uy(e,t.parent),n,s)}}}else if(a.schema.isInline(c))return Hy(e,c,n,s);if(a.schema.isBlock(c))return Hy(e,c,n,s);if(a.schema.checkChild(c,"$block")){const t=Array.from(c.getChildren()).filter((t=>t.is("element")&&!zy(e,t)));let i=0,o=t.length;if(0==o)return a.createRange(a.createPositionAt(c,"end"));for(;i<o-1;){const r=Math.floor((i+o)/2);"before"==$y(e,t[r],n,s)?o=r:i=r}return Hy(e,t[i],n,s)}c=c.parent}return null}function zy(e,t){const i=e.editing.mapper,n=e.editing.view.domConverter,s=i.toViewElement(t);if(!s)return!0;const o=n.mapViewToDom(s);return"none"!=_r.window.getComputedStyle(o).float}function Hy(e,t,i,n){const s=e.model;return s.createRange(s.createPositionAt(t,$y(e,t,i,n)))}function $y(e,t,i,n){const s=e.editing.mapper,o=e.editing.view.domConverter,r=s.toViewElement(t),a=o.mapViewToDom(r),l=new Ir(a);return e.model.schema.isInline(t)?i<(l.left+l.right)/2?"before":"after":n<(l.top+l.bottom)/2?"before":"after"}function Uy(e,t){const i=e.editing.mapper,n=e.editing.view,s=i.toModelElement(t);if(s)return s;const o=n.createPositionBefore(t),r=i.findMappedViewAncestor(o);return i.toModelElement(r)}class Wy extends Na{static get pluginName(){return"DragDropBlockToolbar"}init(){const e=this.editor;if(this.listenTo(e,"change:isReadOnly",((e,t,i)=>{i?(this.forceDisabled("readOnlyMode"),this._isBlockDragging=!1):this.clearForceDisabled("readOnlyMode")})),i.isAndroid&&this.forceDisabled("noAndroidSupport"),e.plugins.has("BlockToolbar")){const t=e.plugins.get("BlockToolbar").buttonView.element;this._domEmitter.listenTo(t,"dragstart",((e,t)=>this._handleBlockDragStart(t))),this._domEmitter.listenTo(_r.document,"dragover",((e,t)=>this._handleBlockDragging(t))),this._domEmitter.listenTo(_r.document,"drop",((e,t)=>this._handleBlockDragging(t))),this._domEmitter.listenTo(_r.document,"dragend",(()=>this._handleBlockDragEnd()),{useCapture:!0}),this.isEnabled&&t.setAttribute("draggable","true"),this.on("change:isEnabled",((e,i,n)=>{t.setAttribute("draggable",n?"true":"false")}))}}destroy(){return this._domEmitter.stopListening(),super.destroy()}_handleBlockDragStart(e){if(!this.isEnabled)return;const t=this.editor.model,i=t.document.selection,n=this.editor.editing.view,s=Array.from(i.getSelectedBlocks()),o=t.createRange(t.createPositionBefore(s[0]),t.createPositionAfter(s[s.length-1]));t.change((e=>e.setSelection(o))),this._isBlockDragging=!0,n.focus(),n.getObserver(U_).onDomEvent(e)}_handleBlockDragging(e){if(!this.isEnabled||!this._isBlockDragging)return;const t=e.clientX+("ltr"==this.editor.locale.contentLanguageDirection?100:-100),i=e.clientY,n=document.elementFromPoint(t,i),s=this.editor.editing.view;n&&n.closest(".ck-editor__editable")&&s.getObserver(U_).onDomEvent({...e,type:e.type,dataTransfer:e.dataTransfer,target:n,clientX:t,clientY:i,preventDefault:()=>e.preventDefault(),stopPropagation:()=>e.stopPropagation()})}_handleBlockDragEnd(){this._isBlockDragging=!1}constructor(...e){super(...e),this._isBlockDragging=!1,this._domEmitter=new(pr())}}class jy extends Na{static get pluginName(){return"DragDrop"}static get requires(){return[Z_,Ey,Fy,Wy]}init(){const e=this.editor,t=e.editing.view;this._draggedRange=null,this._draggingUid="",this._draggableElement=null,t.addObserver(U_),t.addObserver(zu),this._setupDragging(),this._setupContentInsertionIntegration(),this._setupClipboardInputIntegration(),this._setupDraggableAttributeHandling(),this.listenTo(e,"change:isReadOnly",((e,t,i)=>{i?this.forceDisabled("readOnlyMode"):this.clearForceDisabled("readOnlyMode")})),this.on("change:isEnabled",((e,t,i)=>{i||this._finalizeDragging(!1)})),i.isAndroid&&this.forceDisabled("noAndroidSupport")}destroy(){return this._draggedRange&&(this._draggedRange.detach(),this._draggedRange=null),this._previewContainer&&this._previewContainer.remove(),this._domEmitter.stopListening(),this._clearDraggableAttributesDelayed.cancel(),super.destroy()}_setupDragging(){const e=this.editor,t=e.model,n=e.editing.view,s=n.document,o=e.plugins.get(Fy);this.listenTo(s,"dragstart",((e,i)=>{if(i.target&&i.target.is("editableElement"))return void i.preventDefault();if(this._prepareDraggedRange(i.target),!this._draggedRange)return void i.preventDefault();this._draggingUid=u(),i.dataTransfer.effectAllowed=this.isEnabled?"copyMove":"copy",i.dataTransfer.setData("application/ckeditor5-dragging-uid",this._draggingUid);const n=t.createSelection(this._draggedRange.toRange());this.editor.plugins.get("ClipboardPipeline")._fireOutputTransformationEvent(i.dataTransfer,n,"dragstart");const{dataTransfer:s,domTarget:o,domEvent:r}=i,{clientX:a}=r;this._updatePreview({dataTransfer:s,domTarget:o,clientX:a}),i.stopPropagation(),this.isEnabled||(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="")}),{priority:"low"}),this.listenTo(s,"dragend",((e,t)=>{this._finalizeDragging(!t.dataTransfer.isCanceled&&"move"==t.dataTransfer.dropEffect)}),{priority:"low"}),this._domEmitter.listenTo(_r.document,"dragend",(()=>{this._blockMode=!1}),{useCapture:!0}),this.listenTo(s,"dragenter",(()=>{this.isEnabled&&n.focus()})),this.listenTo(s,"dragleave",(()=>{o.removeDropMarkerDelayed()})),this.listenTo(s,"dragging",((e,t)=>{if(!this.isEnabled)return void(t.dataTransfer.dropEffect="none");const{clientX:n,clientY:s}=t.domEvent;o.updateDropMarker(t.target,t.targetRanges,n,s,this._blockMode,this._draggedRange),this._draggedRange||(t.dataTransfer.dropEffect="copy"),i.isGecko||("copy"==t.dataTransfer.effectAllowed?t.dataTransfer.dropEffect="copy":["all","copyMove"].includes(t.dataTransfer.effectAllowed)&&(t.dataTransfer.dropEffect="move")),e.stop()}),{priority:"low"})}_setupClipboardInputIntegration(){const e=this.editor,t=e.editing.view.document,i=e.plugins.get(Fy);this.listenTo(t,"clipboardInput",((t,n)=>{if("drop"!=n.method)return;const{clientX:s,clientY:o}=n.domEvent,r=i.getFinalDropRange(n.target,n.targetRanges,s,o,this._blockMode,this._draggedRange);if(!r)return this._finalizeDragging(!1),void t.stop();this._draggedRange&&this._draggingUid!=n.dataTransfer.getData("application/ckeditor5-dragging-uid")&&(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="");if("move"==qy(n.dataTransfer)&&this._draggedRange&&this._draggedRange.containsRange(r,!0))return this._finalizeDragging(!1),void t.stop();n.targetRanges=[e.editing.mapper.toViewRange(r)]}),{priority:"high"})}_setupContentInsertionIntegration(){const e=this.editor.plugins.get(Z_);e.on("contentInsertion",((e,t)=>{if(!this.isEnabled||"drop"!==t.method)return;const i=t.targetRanges.map((e=>this.editor.editing.mapper.toModelRange(e)));this.editor.model.change((e=>e.setSelection(i)))}),{priority:"high"}),e.on("contentInsertion",((e,t)=>{if(!this.isEnabled||"drop"!==t.method)return;const i="move"==qy(t.dataTransfer),n=!t.resultRange||!t.resultRange.isCollapsed;this._finalizeDragging(n&&i)}),{priority:"lowest"})}_setupDraggableAttributeHandling(){const e=this.editor,t=e.editing.view,n=t.document;this.listenTo(n,"mousedown",((s,o)=>{if(i.isAndroid||!o)return;this._clearDraggableAttributesDelayed.cancel();let r=Gy(o.target);if(i.isBlink&&!e.isReadOnly&&!r&&!n.selection.isCollapsed){const e=n.selection.getSelectedElement();e&&ny(e)||(r=n.selection.editableElement)}r&&(t.change((e=>{e.setAttribute("draggable","true",r)})),this._draggableElement=e.editing.mapper.toModelElement(r))})),this.listenTo(n,"mouseup",(()=>{i.isAndroid||this._clearDraggableAttributesDelayed()}))}_clearDraggableAttributes(){const e=this.editor.editing;e.view.change((t=>{this._draggableElement&&"$graveyard"!=this._draggableElement.root.rootName&&t.removeAttribute("draggable",e.mapper.toViewElement(this._draggableElement)),this._draggableElement=null}))}_finalizeDragging(e){const t=this.editor,i=t.model;if(t.plugins.get(Fy).removeDropMarker(),this._clearDraggableAttributes(),t.plugins.has("WidgetToolbarRepository")){t.plugins.get("WidgetToolbarRepository").clearForceDisabled("dragDrop")}this._draggingUid="",this._previewContainer&&(this._previewContainer.remove(),this._previewContainer=void 0),this._draggedRange&&(e&&this.isEnabled&&i.change((e=>{const t=i.createSelection(this._draggedRange);i.deleteContent(t,{doNotAutoparagraph:!0});const n=t.getFirstPosition().parent;n.isEmpty&&!i.schema.checkChild(n,"$text")&&i.schema.checkChild(n,"paragraph")&&e.insertElement("paragraph",n,0)})),this._draggedRange.detach(),this._draggedRange=null)}_prepareDraggedRange(e){const t=this.editor,i=t.model,n=i.document.selection,s=e?Gy(e):null;if(s){const e=t.editing.mapper.toModelElement(s);if(this._draggedRange=pd.fromRange(i.createRangeOn(e)),this._blockMode=i.schema.isBlock(e),t.plugins.has("WidgetToolbarRepository")){t.plugins.get("WidgetToolbarRepository").forceDisabled("dragDrop")}return}if(n.isCollapsed&&!n.getFirstPosition().parent.isEmpty)return;const o=Array.from(n.getSelectedBlocks()),r=n.getFirstRange();if(0==o.length)return void(this._draggedRange=pd.fromRange(r));const a=Ky(i,o);if(o.length>1)this._draggedRange=pd.fromRange(a),this._blockMode=!0;else if(1==o.length){const e=r.start.isTouching(a.start)&&r.end.isTouching(a.end);this._draggedRange=pd.fromRange(e?a:r),this._blockMode=e}i.change((e=>e.setSelection(this._draggedRange.toRange())))}_updatePreview({dataTransfer:e,domTarget:t,clientX:n}){const s=this.editor.editing.view,o=s.document.selection.editableElement,r=s.domConverter.mapViewToDom(o),a=_r.window.getComputedStyle(r);this._previewContainer?this._previewContainer.firstElementChild&&this._previewContainer.removeChild(this._previewContainer.firstElementChild):(this._previewContainer=cr(_r.document,"div",{style:"position: fixed; left: -999999px;"}),_r.document.body.appendChild(this._previewContainer));const l=new Ir(r);if(r.contains(t))return;const c=parseFloat(a.paddingLeft),d=cr(_r.document,"div");d.className="ck ck-content",d.style.width=a.width,d.style.paddingLeft=`${l.left-n+c}px`,i.isiOS&&(d.style.backgroundColor="white"),d.innerHTML=e.getData("text/html"),e.setDragImage(d,0,0),this._previewContainer.appendChild(d)}constructor(...e){super(...e),this._clearDraggableAttributesDelayed=Sa((()=>this._clearDraggableAttributes()),40),this._blockMode=!1,this._domEmitter=new(pr())}}function qy(e){return i.isGecko?e.dropEffect:["all","copyMove"].includes(e.effectAllowed)?"move":"copy"}function Gy(e){if(e.is("editableElement"))return null;if(e.hasClass("ck-widget__selection-handle"))return e.findAncestor(ny);if(ny(e))return e;const t=e.findAncestor((e=>ny(e)||e.is("editableElement")));return ny(t)?t:null}function Ky(e,t){const i=t[0],n=t[t.length-1],s=i.getCommonAncestor(n),o=e.createPositionBefore(i),r=e.createPositionAfter(n);if(s&&s.is("element")&&!e.schema.isLimit(s)){const t=e.createRangeOn(s),i=o.isTouching(t.start),n=r.isTouching(t.end);if(i&&n)return Ky(e,[s])}return e.createRange(o,r)}class Zy extends Na{static get pluginName(){return"PastePlainText"}static get requires(){return[Z_]}init(){const e=this.editor,t=e.model,i=e.editing.view,n=i.document,s=t.document.selection;let o=!1;i.addObserver(U_),this.listenTo(n,"keydown",((e,t)=>{o=t.shiftKey})),e.plugins.get(Z_).on("contentInsertion",((e,i)=>{(o||function(e,t){if(e.childCount>1)return!1;const i=e.getChild(0);if(t.isObject(i))return!1;return 0==Array.from(i.getAttributeKeys()).length}(i.content,t.schema))&&t.change((e=>{const n=Array.from(s.getAttributes()).filter((([e])=>t.schema.getAttributeProperties(e).isFormatting));s.isCollapsed||t.deleteContent(s,{doNotAutoparagraph:!0}),n.push(...s.getAttributes());const o=e.createRangeIn(i.content);for(const t of o.getItems())t.is("$textProxy")&&e.setAttributes(n,t)}))}))}}class Jy extends Na{static get pluginName(){return"Clipboard"}static get requires(){return[K_,Z_,jy,Zy]}init(){const e=this.editor,t=this.editor.t;e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Copy selected content"),keystroke:"CTRL+C"},{label:t("Paste content"),keystroke:"CTRL+V"},{label:t("Paste content as plain text"),keystroke:"CTRL+SHIFT+V"}]})}}const Qy={autoRefresh:!0},Yy=36e5;class Xy extends(Yo()){init(){return new Promise(((e,t)=>{this.value?(this._options.autoRefresh&&this._registerRefreshTokenTimeout(),e(this)):this.refreshToken().then(e).catch(t)}))}refreshToken(){return this._refresh().then((e=>(this._validateTokenValue(e),this.set("value",e),this._options.autoRefresh&&this._registerRefreshTokenTimeout(),this)))}destroy(){clearTimeout(this._tokenRefreshTimeout)}_validateTokenValue(e){const t="string"==typeof e,i=!/^".*"$/.test(e),n=t&&3===e.split(".").length;if(!i||!n)throw new p("token-not-in-jwt-format",this)}_registerRefreshTokenTimeout(){const e=this._getTokenRefreshTimeoutTime();clearTimeout(this._tokenRefreshTimeout),this._tokenRefreshTimeout=setTimeout((()=>{this.refreshToken()}),e)}_getTokenRefreshTimeoutTime(){try{const[,e]=this.value.split("."),{exp:t}=JSON.parse(atob(e));if(!t)return Yy;return Math.floor((1e3*t-Date.now())/2)}catch(e){return Yy}}static create(e,t={}){return new Xy(e,t).init()}constructor(e,t={}){if(super(),!e)throw new p("token-missing-token-url",this);t.initValue&&this._validateTokenValue(t.initValue),this.set("value",t.initValue),this._refresh="function"==typeof e?e:()=>{return t=e,new Promise(((e,i)=>{const n=new XMLHttpRequest;n.open("GET",t),n.addEventListener("load",(()=>{const t=n.status,s=n.response;return t<200||t>299?i(new p("token-cannot-download-new-token",null)):e(s)})),n.addEventListener("error",(()=>i(new Error("Network Error")))),n.addEventListener("abort",(()=>i(new Error("Abort")))),n.send()}));var t},this._options={...Qy,...t}}}const ek=/^data:(\S*?);base64,/;class tk extends(T()){onProgress(e){return this.on("progress",((t,i)=>e(i))),this}onError(e){return this.once("error",((t,i)=>e(i))),this}abort(){this.xhr.abort()}send(){return this._prepareRequest(),this._attachXHRListeners(),this._sendRequest()}_prepareRequest(){const e=new XMLHttpRequest;e.open("POST",this._apiAddress),e.setRequestHeader("Authorization",this._token.value),e.responseType="json",this.xhr=e}_attachXHRListeners(){const e=this.xhr,t=e=>()=>this.fire("error",e);e.addEventListener("error",t("Network Error")),e.addEventListener("abort",t("Abort")),e.upload&&e.upload.addEventListener("progress",(e=>{e.lengthComputable&&this.fire("progress",{total:e.total,uploaded:e.loaded})})),e.addEventListener("load",(()=>{const t=e.status,i=e.response;if(t<200||t>299)return this.fire("error",i.message||i.error)}))}_sendRequest(){const e=new FormData,t=this.xhr;return e.append("file",this.file),new Promise(((i,n)=>{t.addEventListener("load",(()=>{const e=t.status,s=t.response;return e<200||e>299?s.message?n(new p("fileuploader-uploading-data-failed",this,{message:s.message})):n(s.error):i(s)})),t.addEventListener("error",(()=>n(new Error("Network Error")))),t.addEventListener("abort",(()=>n(new Error("Abort")))),t.send(e)}))}constructor(e,t,i){if(super(),!e)throw new p("fileuploader-missing-file",null);if(!t)throw new p("fileuploader-missing-token",null);if(!i)throw new p("fileuploader-missing-api-address",null);this.file=function(e){if("string"!=typeof e)return!1;const t=e.match(ek);return!(!t||!t.length)}(e)?function(e,t=512){try{const i=e.match(ek)[1],n=atob(e.replace(ek,"")),s=[];for(let e=0;e<n.length;e+=t){const i=n.slice(e,e+t),o=new Array(i.length);for(let e=0;e<i.length;e++)o[e]=i.charCodeAt(e);s.push(new Uint8Array(o))}return new Blob(s,{type:i})}catch(e){throw new p("fileuploader-decoding-image-data-error",null)}}(e):e,this._token=t,this._apiAddress=i}}class ik{upload(e){return new tk(e,this._token,this._apiAddress)}constructor(e,t){if(!e)throw new p("uploadgateway-missing-token",null);if(!t)throw new p("uploadgateway-missing-api-address",null);this._token=e,this._apiAddress=t}}class nk extends Wa{static get pluginName(){return"CloudServicesCore"}createToken(e,t){return new Xy(e,t)}createUploadGateway(e,t){return new ik(e,t)}}class sk extends Wa{static get pluginName(){return"CloudServices"}static get requires(){return[nk]}async init(){const e=this.context.config.get("cloudServices")||{};for(const[t,i]of Object.entries(e))this[t]=i;if(!this.tokenUrl)return void(this.token=null);const t=this.context.plugins.get("CloudServicesCore");this.token=await t.createToken(this.tokenUrl).init(),this._tokens.set(this.tokenUrl,this.token)}async registerTokenUrl(e){if(this._tokens.has(e))return this.getTokenFor(e);const t=this.context.plugins.get("CloudServicesCore"),i=await t.createToken(e).init();return this._tokens.set(e,i),i}getTokenFor(e){const t=this._tokens.get(e);if(!t)throw new p("cloudservices-token-not-registered",this);return t}destroy(){super.destroy();for(const e of this._tokens.values())e.destroy()}constructor(...e){super(...e),this.token=null,this._tokens=new Map}}function ok(e){const t=e.t,i=e.config.get("codeBlock.languages");for(const e of i)"Plain text"===e.label&&(e.label=t("Plain text")),void 0===e.class&&(e.class=`language-${e.language}`);return i}function rk(e,t,i){const n={};for(const s of e)if("class"===t){n[s[t].split(" ").shift()]=s[i]}else n[s[t]]=s[i];return n}function ak(e){return e.data.match(/^(\s*)/)[0]}function lk(e){const t=e.document.selection,i=[];if(t.isCollapsed)return[t.anchor];const n=t.getFirstRange().getWalker({ignoreElementEnd:!0,direction:"backward"});for(const{item:t}of n){if(!t.is("$textProxy"))continue;const{parent:n,startOffset:s}=t.textNode;if(!n.is("element","codeBlock"))continue;const o=ak(t.textNode),r=e.createPositionAt(n,s+o.length);i.push(r)}return i}function ck(e){const t=_a(e.getSelectedBlocks());return!!t&&t.is("element","codeBlock")}function dk(e,t){return!t.is("rootElement")&&!e.isLimit(t)&&e.checkChild(t.parent,"codeBlock")}function hk(e,t,i,n){const s=rk(t,"language","label"),o=i.getAttribute("language");if(o in s){const t=s[o];return e("enter"===n?"Entering %0 code snippet":"Leaving %0 code snippet",t)}return e("enter"===n?"Entering code snippet":"Leaving code snippet")}class uk extends Da{refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor,i=t.model,n=i.document.selection,s=ok(t)[0],o=Array.from(n.getSelectedBlocks()),r=null==e.forceValue?!this.value:e.forceValue,a=function(e,t,i){if(e.language)return e.language;if(e.usePreviousLanguageChoice&&t)return t;return i}(e,this._lastLanguage,s.language);i.change((e=>{r?this._applyCodeBlock(e,o,a):this._removeCodeBlock(e,o)}))}_getValue(){const e=_a(this.editor.model.document.selection.getSelectedBlocks());return!!!(!e||!e.is("element","codeBlock"))&&e.getAttribute("language")}_checkEnabled(){if(this.value)return!0;const e=this.editor.model.document.selection,t=this.editor.model.schema,i=_a(e.getSelectedBlocks());return!!i&&dk(t,i)}_applyCodeBlock(e,t,i){this._lastLanguage=i;const n=this.editor.model.schema,s=t.filter((e=>dk(n,e)));for(const t of s)e.rename(t,"codeBlock"),e.setAttribute("language",i,t),n.removeDisallowedAttributes([t],e),Array.from(t.getChildren()).filter((e=>!n.checkChild(t,e))).forEach((t=>e.remove(t)));s.reverse().forEach(((t,i)=>{const n=s[i+1];t.previousSibling===n&&(e.appendElement("softBreak",n),e.merge(e.createPositionBefore(t)))}))}_removeCodeBlock(e,t){const i=t.filter((e=>e.is("element","codeBlock")));for(const t of i){const i=e.createRangeOn(t);for(const t of Array.from(i.getItems()).reverse())if(t.is("element","softBreak")&&t.parent.is("element","codeBlock")){const{position:i}=e.split(e.createPositionBefore(t)),n=i.nodeAfter;e.rename(n,"paragraph"),e.removeAttribute("language",n),e.remove(t)}e.rename(t,"paragraph"),e.removeAttribute("language",t)}}constructor(e){super(e),this._lastLanguage=null}}class mk extends Da{refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model;e.change((t=>{const i=lk(e);for(const n of i){const i=t.createText(this._indentSequence);e.insertContent(i,n)}}))}_checkEnabled(){return!!this._indentSequence&&ck(this.editor.model.document.selection)}constructor(e){super(e),this._indentSequence=e.config.get("codeBlock.indentSequence")}}class gk extends Da{refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model;e.change((()=>{const t=lk(e);for(const i of t){const t=fk(e,i,this._indentSequence);t&&e.deleteContent(e.createSelection(t))}}))}_checkEnabled(){if(!this._indentSequence)return!1;const e=this.editor.model;return!!ck(e.document.selection)&&lk(e).some((t=>fk(e,t,this._indentSequence)))}constructor(e){super(e),this._indentSequence=e.config.get("codeBlock.indentSequence")}}function fk(e,t,i){const n=function(e){let t=e.parent.getChild(e.index);t&&!t.is("element","softBreak")||(t=e.nodeBefore);if(!t||t.is("element","softBreak"))return null;return t}(t);if(!n)return null;const s=ak(n),o=s.lastIndexOf(i);if(o+i.length!==s.length)return null;if(-1===o)return null;const{parent:r,startOffset:a}=n;return e.createRange(e.createPositionAt(r,a+o),e.createPositionAt(r,a+o+i.length))}function pk(e,t,i=!1){const n=rk(t,"language","class"),s=rk(t,"language","label");return(t,o,r)=>{const{writer:a,mapper:l,consumable:c}=r;if(!c.consume(o.item,"insert"))return;const d=o.item.getAttribute("language"),h=l.toViewPosition(e.createPositionBefore(o.item)),u={};i&&(u["data-language"]=s[d],u.spellcheck="false");const m=n[d]?{class:n[d]}:void 0,g=a.createContainerElement("code",m),f=a.createContainerElement("pre",u,g);a.insert(h,f),l.bindElements(o.item,g)}}const bk="paragraph";class wk extends Na{static get pluginName(){return"CodeBlockEditing"}static get requires(){return[Yv]}init(){const e=this.editor,t=e.model.schema,i=e.model,n=e.editing.view,s=e.plugins.has("ListEditing")?e.plugins.get("ListEditing"):null,o=ok(e);e.commands.add("codeBlock",new uk(e)),e.commands.add("indentCodeBlock",new mk(e)),e.commands.add("outdentCodeBlock",new gk(e)),this.listenTo(n.document,"tab",((t,i)=>{const n=i.shiftKey?"outdentCodeBlock":"indentCodeBlock";e.commands.get(n).isEnabled&&(e.execute(n),i.stopPropagation(),i.preventDefault(),t.stop())}),{context:"pre"}),t.register("codeBlock",{allowWhere:"$block",allowChildren:"$text",isBlock:!0,allowAttributes:["language"]}),t.addAttributeCheck(((e,t)=>!!(e.endsWith("codeBlock")&&s&&s.getListAttributeNames().includes(t))||!e.endsWith("codeBlock $text")&&void 0)),e.model.schema.addChildCheck(((e,t)=>{if(e.endsWith("codeBlock")&&t.isObject)return!1})),e.editing.downcastDispatcher.on("insert:codeBlock",pk(i,o,!0)),e.data.downcastDispatcher.on("insert:codeBlock",pk(i,o)),e.data.downcastDispatcher.on("insert:softBreak",function(e){return(t,i,n)=>{if("codeBlock"!==i.item.parent.name)return;const{writer:s,mapper:o,consumable:r}=n;if(!r.consume(i.item,"insert"))return;const a=o.toViewPosition(e.createPositionBefore(i.item));s.insert(a,s.createText("\n"))}}(i),{priority:"high"}),e.data.upcastDispatcher.on("element:code",function(e,t){const i=rk(t,"class","language"),n=t[0].language;return(e,t,s)=>{const o=t.viewItem,r=o.parent;if(!r||!r.is("element","pre"))return;if(t.modelCursor.findAncestor("codeBlock"))return;const{consumable:a,writer:l}=s;if(!a.test(o,{name:!0}))return;const c=l.createElement("codeBlock"),d=[...o.getClassNames()];d.length||d.push("");for(const e of d){const t=i[e];if(t){l.setAttribute("language",t,c);break}}c.hasAttribute("language")||l.setAttribute("language",n,c),s.convertChildren(o,c),s.safeInsert(c,t.modelCursor)&&(a.consume(o,{name:!0}),s.updateConversionResult(c,t))}}(0,o)),e.data.upcastDispatcher.on("text",((e,t,{consumable:i,writer:n})=>{let s=t.modelCursor;if(!i.test(t.viewItem))return;if(!s.findAncestor("codeBlock"))return;i.consume(t.viewItem);const o=t.viewItem.data.split("\n").map((e=>n.createText(e))),r=o[o.length-1];for(const e of o)if(n.insert(e,s),s=s.getShiftedBy(e.offsetSize),e!==r){const e=n.createElement("softBreak");n.insert(e,s),s=n.createPositionAfter(e)}t.modelRange=n.createRange(t.modelCursor,s),t.modelCursor=s})),e.data.upcastDispatcher.on("element:pre",((e,t,{consumable:i})=>{const n=t.viewItem;if(n.findAncestor("pre"))return;const s=Array.from(n.getChildren()),o=s.find((e=>e.is("element","code")));if(o)for(const e of s)e!==o&&e.is("$text")&&i.consume(e,{name:!0})}),{priority:"high"}),this.listenTo(e.editing.view.document,"clipboardInput",((t,n)=>{let s=i.createRange(i.document.selection.anchor);if(n.targetRanges&&(s=e.editing.mapper.toModelRange(n.targetRanges[0])),!s.start.parent.is("element","codeBlock"))return;const o=n.dataTransfer.getData("text/plain"),r=new Hu(e.editing.view.document);n.content=function(e,t){const i=e.createDocumentFragment(),n=t.split("\n"),s=n.reduce(((t,i,s)=>(t.push(i),s<n.length-1&&t.push(e.createElement("br")),t)),[]);return e.appendChild(s,i),i}(r,o)})),this.listenTo(i,"getSelectedContent",((e,[n])=>{const s=n.anchor;!n.isCollapsed&&s.parent.is("element","codeBlock")&&s.hasSameParentAs(n.focus)&&i.change((i=>{const o=e.return;if(s.parent.is("element")&&(o.childCount>1||n.containsEntireContent(s.parent))){const t=i.createElement("codeBlock",s.parent.getAttributes());i.append(o,t);const n=i.createDocumentFragment();return i.append(t,n),void(e.return=n)}const r=o.getChild(0);t.checkAttribute(r,"code")&&i.setAttribute("code",!0,r)}))}))}afterInit(){const e=this.editor,t=e.commands,i=t.get("indent"),n=t.get("outdent");i&&i.registerChildCommand(t.get("indentCodeBlock"),{priority:"highest"}),n&&n.registerChildCommand(t.get("outdentCodeBlock")),this.listenTo(e.editing.view.document,"enter",((t,i)=>{e.model.document.selection.getLastPosition().parent.is("element","codeBlock")&&(function(e,t){const i=e.model,n=i.document,s=e.editing.view,o=n.selection.getLastPosition(),r=o.nodeAfter;if(t||!n.selection.isCollapsed||!o.isAtStart)return!1;if(!_k(r))return!1;return e.model.change((t=>{e.execute("enter");const i=n.selection.anchor.parent.previousSibling;t.rename(i,bk),t.setSelection(i,"in"),e.model.schema.removeDisallowedAttributes([i],t),t.remove(r)})),s.scrollToTheSelection(),!0}(e,i.isSoft)||function(e,t){const i=e.model,n=i.document,s=e.editing.view,o=n.selection.getLastPosition(),r=o.nodeBefore;let a;if(t||!n.selection.isCollapsed||!o.isAtEnd||!r||!r.previousSibling)return!1;if(_k(r)&&_k(r.previousSibling))a=i.createRange(i.createPositionBefore(r.previousSibling),i.createPositionAfter(r));else if(vk(r)&&_k(r.previousSibling)&&_k(r.previousSibling.previousSibling))a=i.createRange(i.createPositionBefore(r.previousSibling.previousSibling),i.createPositionAfter(r));else{if(!(vk(r)&&_k(r.previousSibling)&&vk(r.previousSibling.previousSibling)&&r.previousSibling.previousSibling&&_k(r.previousSibling.previousSibling.previousSibling)))return!1;a=i.createRange(i.createPositionBefore(r.previousSibling.previousSibling.previousSibling),i.createPositionAfter(r))}return e.model.change((t=>{t.remove(a),e.execute("enter");const i=n.selection.anchor.parent;t.rename(i,bk),e.model.schema.removeDisallowedAttributes([i],t)})),s.scrollToTheSelection(),!0}(e,i.isSoft)||function(e){const t=e.model,i=t.document,n=i.selection.getLastPosition(),s=n.nodeBefore||n.textNode;let o;s&&s.is("$text")&&(o=ak(s));e.model.change((t=>{e.execute("shiftEnter"),o&&t.insertText(o,i.selection.anchor)}))}(e),i.preventDefault(),t.stop())}),{context:"pre"}),this._initAriaAnnouncements()}_initAriaAnnouncements(){const{model:e,ui:t,t:i}=this.editor,n=ok(this.editor);let s=null;e.document.selection.on("change:range",(()=>{const o=e.document.selection.focus.parent;t&&s!==o&&o.is("element")&&(s&&s.is("element","codeBlock")&&t.ariaLiveAnnouncer.announce(hk(i,n,s,"leave")),o.is("element","codeBlock")&&t.ariaLiveAnnouncer.announce(hk(i,n,o,"enter")),s=o)}))}constructor(e){super(e),e.config.define("codeBlock",{languages:[{language:"plaintext",label:"Plain text"},{language:"c",label:"C"},{language:"cs",label:"C#"},{language:"cpp",label:"C++"},{language:"css",label:"CSS"},{language:"diff",label:"Diff"},{language:"html",label:"HTML"},{language:"java",label:"Java"},{language:"javascript",label:"JavaScript"},{language:"php",label:"PHP"},{language:"python",label:"Python"},{language:"ruby",label:"Ruby"},{language:"typescript",label:"TypeScript"},{language:"xml",label:"XML"}],indentSequence:"\t"})}}function vk(e){return e&&e.is("$text")&&!e.data.match(/\S/)}function _k(e){return e&&e.is("element","softBreak")}class yk extends Na{static get pluginName(){return"CodeBlockUI"}init(){const e=this.editor,t=e.t,i=e.ui.componentFactory,n=ok(e),s=this._getLanguageListItemDefinitions(n),o=e.commands.get("codeBlock");i.add("codeBlock",(i=>{const n=Wf(i,Uf),r=n.buttonView,a=t("Insert code block");return r.set({label:a,tooltip:!0,icon:Dm.codeBlock,isToggleable:!0}),r.bind("isOn").to(o,"value",(e=>!!e)),r.on("execute",(()=>{e.execute("codeBlock",{usePreviousLanguageChoice:!0}),e.editing.view.focus()})),n.on("execute",(t=>{e.execute("codeBlock",{language:t.source._codeBlockLanguage,forceValue:!0}),e.editing.view.focus()})),n.class="ck-code-block-dropdown",n.bind("isEnabled").to(o),Gf(n,s,{role:"menu",ariaLabel:a}),n})),i.add("menuBar:codeBlock",(i=>{const n=new dw(i);n.buttonView.set({label:t("Code block"),icon:Dm.codeBlock}),n.bind("isEnabled").to(o);const r=new hw(i);r.set({ariaLabel:t("Insert code block")});for(const t of s){const s=new qb(i,n),a=new uw(i);a.bind(...Object.keys(t.model)).to(t.model),a.bind("ariaChecked").to(a,"isOn"),a.delegate("execute").to(n),a.on("execute",(()=>{e.execute("codeBlock",{language:t.model._codeBlockLanguage,forceValue:o.value!=t.model._codeBlockLanguage}),e.editing.view.focus()})),s.children.add(a),r.items.add(s)}return n.panelView.children.add(r),n}))}_getLanguageListItemDefinitions(e){const t=this.editor.commands.get("codeBlock"),i=new va;for(const n of e){const e={type:"button",model:new Ab({_codeBlockLanguage:n.language,label:n.label,role:"menuitemradio",withText:!0})};e.model.bind("isOn").to(t,"value",(t=>t===e.model._codeBlockLanguage)),i.add(e)}return i}}class kk extends Na{static get requires(){return[wk,yk]}static get pluginName(){return"CodeBlock"}}class Ck extends Na{static get pluginName(){return"CloudServicesUploadAdapter"}static get requires(){return["CloudServices",Hm]}init(){const e=this.editor,t=e.plugins.get("CloudServices"),i=t.token,n=t.uploadUrl;if(!i)return;const s=e.plugins.get("CloudServicesCore");this._uploadGateway=s.createUploadGateway(i,n),e.plugins.get(Hm).createUploadAdapter=e=>new xk(this._uploadGateway,e)}}class xk{upload(){return this.loader.file.then((e=>(this.fileUploader=this.uploadGateway.upload(e),this.fileUploader.on("progress",((e,t)=>{this.loader.uploadTotal=t.total,this.loader.uploaded=t.uploaded})),this.fileUploader.send())))}abort(){this.fileUploader.abort()}constructor(e,t){this.uploadGateway=e,this.loader=t}}class Ak extends Na{static get pluginName(){return"EasyImage"}static get requires(){return[Ck,"ImageUpload"]}init(){const e=this.editor;e.plugins.has("ImageBlockEditing")||e.plugins.has("ImageInlineEditing")||b("easy-image-image-feature-missing",e)}}class Ek{destroy(){this._stopErrorHandling(),this._listeners={}}on(e,t){this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push(t)}off(e,t){this._listeners[e]=this._listeners[e].filter((e=>e!==t))}_fire(e,...t){const i=this._listeners[e]||[];for(const e of i)e.apply(this,[null,...t])}_startErrorHandling(){window.addEventListener("error",this._boundErrorHandler),window.addEventListener("unhandledrejection",this._boundErrorHandler)}_stopErrorHandling(){window.removeEventListener("error",this._boundErrorHandler),window.removeEventListener("unhandledrejection",this._boundErrorHandler)}_handleError(e,t){if(this._shouldReactToError(e)){this.crashes.push({message:e.message,stack:e.stack,filename:t instanceof ErrorEvent?t.filename:void 0,lineno:t instanceof ErrorEvent?t.lineno:void 0,colno:t instanceof ErrorEvent?t.colno:void 0,date:this._now()});const i=this._shouldRestart();this.state="crashed",this._fire("stateChange"),this._fire("error",{error:e,causesRestart:i}),i?this._restart():(this.state="crashedPermanently",this._fire("stateChange"))}}_shouldReactToError(e){return e.is&&e.is("CKEditorError")&&void 0!==e.context&&null!==e.context&&"ready"===this.state&&this._isErrorComingFromThisItem(e)}_shouldRestart(){if(this.crashes.length<=this._crashNumberLimit)return!0;return(this.crashes[this.crashes.length-1].date-this.crashes[this.crashes.length-1-this._crashNumberLimit].date)/this._crashNumberLimit>this._minimumNonErrorTimePeriod}constructor(e){if(this.crashes=[],this.state="initializing",this._now=Date.now,this.crashes=[],this._crashNumberLimit="number"==typeof e.crashNumberLimit?e.crashNumberLimit:3,this._minimumNonErrorTimePeriod="number"==typeof e.minimumNonErrorTimePeriod?e.minimumNonErrorTimePeriod:5e3,this._boundErrorHandler=e=>{const t="error"in e?e.error:e.reason;t instanceof Error&&this._handleError(t,e)},this._listeners={},!this._restart)throw new Error("The Watchdog class was split into the abstract `Watchdog` class and the `EditorWatchdog` class. Please, use `EditorWatchdog` if you have used the `Watchdog` class previously.")}}function Tk(e,t=new Set){const i=[e],n=new Set;let s=0;for(;i.length>s;){const e=i[s++];if(!n.has(e)&&Sk(e)&&!t.has(e))if(n.add(e),Symbol.iterator in e)try{for(const t of e)i.push(t)}catch(e){}else for(const t in e)"defaultValue"!==t&&i.push(e[t])}return n}function Sk(e){const t=Object.prototype.toString.call(e),i=typeof e;return!("number"===i||"boolean"===i||"string"===i||"symbol"===i||"function"===i||"[object Date]"===t||"[object RegExp]"===t||"[object Module]"===t||null==e||e._watchdogExcluded||e instanceof EventTarget||e instanceof Event)}function Ik(e,t,i=new Set){if(e===t&&("object"==typeof(n=e)&&null!==n))return!0;var n;const s=Tk(e,i),o=Tk(t,i);for(const e of s)if(o.has(e))return!0;return!1}class Pk extends Ek{get editor(){return this._editor}get _item(){return this._editor}setCreator(e){this._creator=e}setDestructor(e){this._destructor=e}_restart(){return Promise.resolve().then((()=>(this.state="initializing",this._fire("stateChange"),this._destroy()))).catch((e=>{console.error("An error happened during the editor destroying.",e)})).then((()=>{const e={},t=[],i=this._config.rootsAttributes||{},n={};for(const[s,o]of Object.entries(this._data.roots))o.isLoaded?(e[s]="",n[s]=i[s]||{}):t.push(s);const s={...this._config,extraPlugins:this._config.extraPlugins||[],lazyRoots:t,rootsAttributes:n,_watchdogInitialData:this._data};return delete s.initialData,s.extraPlugins.push(Vk),this._initUsingData?this.create(e,s,s.context):Fo(this._elementOrData)?this.create(this._elementOrData,s,s.context):this.create(this._editables,s,s.context)})).then((()=>{this._fire("restart")}))}create(e=this._elementOrData,t=this._config,i){return this._lifecyclePromise=Promise.resolve(this._lifecyclePromise).then((()=>(super._startErrorHandling(),this._elementOrData=e,this._initUsingData="string"==typeof e||Object.keys(e).length>0&&"string"==typeof Object.values(e)[0],this._config=this._cloneEditorConfiguration(t)||{},this._config.context=i,this._creator(e,this._config)))).then((e=>{this._editor=e,e.model.document.on("change:data",this._throttledSave),this._lastDocumentVersion=e.model.document.version,this._data=this._getData(),this._initUsingData||(this._editables=this._getEditables()),this.state="ready",this._fire("stateChange")})).finally((()=>{this._lifecyclePromise=null})),this._lifecyclePromise}destroy(){return this._lifecyclePromise=Promise.resolve(this._lifecyclePromise).then((()=>(this.state="destroyed",this._fire("stateChange"),super.destroy(),this._destroy()))).finally((()=>{this._lifecyclePromise=null})),this._lifecyclePromise}_destroy(){return Promise.resolve().then((()=>{this._stopErrorHandling(),this._throttledSave.cancel();const e=this._editor;return this._editor=null,e.model.document.off("change:data",this._throttledSave),this._destructor(e)}))}_save(){const e=this._editor.model.document.version;try{this._data=this._getData(),this._initUsingData||(this._editables=this._getEditables()),this._lastDocumentVersion=e}catch(e){console.error(e,"An error happened during restoring editor data. Editor will be restored from the previously saved data.")}}_setExcludedProperties(e){this._excludedProps=e}_getData(){const e=this._editor,t=e.model.document.roots.filter((e=>e.isAttached()&&"$graveyard"!=e.rootName)),{plugins:i}=e,n=i.has("CommentsRepository")&&i.get("CommentsRepository"),s=i.has("TrackChanges")&&i.get("TrackChanges"),o={roots:{},markers:{},commentThreads:JSON.stringify([]),suggestions:JSON.stringify([])};t.forEach((e=>{o.roots[e.rootName]={content:JSON.stringify(Array.from(e.getChildren())),attributes:JSON.stringify(Array.from(e.getAttributes())),isLoaded:e._isLoaded}}));for(const t of e.model.markers)t._affectsData&&(o.markers[t.name]={rangeJSON:t.getRange().toJSON(),usingOperation:t._managedUsingOperations,affectsData:t._affectsData});return n&&(o.commentThreads=JSON.stringify(n.getCommentThreads({toJSON:!0,skipNotAttached:!0}))),s&&(o.suggestions=JSON.stringify(s.getSuggestions({toJSON:!0,skipNotAttached:!0}))),o}_getEditables(){const e={};for(const t of this.editor.model.document.getRootNames()){const i=this.editor.ui.getEditableElement(t);i&&(e[t]=i)}return e}_isErrorComingFromThisItem(e){return Ik(this._editor,e.context,this._excludedProps)}_cloneEditorConfiguration(e){return Cs(e,((e,t)=>Fo(e)||"context"===t?e:void 0))}constructor(e,t={}){super(t),this._editor=null,this._lifecyclePromise=null,this._initUsingData=!0,this._editables={},this._throttledSave=jo(this._save.bind(this),"number"==typeof t.saveInterval?t.saveInterval:5e3),e&&(this._creator=(t,i)=>e.create(t,i)),this._destructor=e=>e.destroy()}}class Vk{init(){this.editor.data.on("init",(e=>{e.stop(),this.editor.model.enqueueChange({isUndoable:!1},(e=>{this._restoreCollaborationData(),this._restoreEditorData(e)})),this.editor.data.fire("ready")}),{priority:999})}_createNode(e,t){if("name"in t){const i=e.createElement(t.name,t.attributes);if(t.children)for(const n of t.children)i._appendChild(this._createNode(e,n));return i}return e.createText(t.data,t.attributes)}_restoreEditorData(e){const t=this.editor;Object.entries(this._data.roots).forEach((([i,{content:n,attributes:s}])=>{const o=JSON.parse(n),r=JSON.parse(s),a=t.model.document.getRoot(i);for(const[t,i]of r)e.setAttribute(t,i,a);for(const t of o){const i=this._createNode(e,t);e.insert(i,a,"end")}})),Object.entries(this._data.markers).forEach((([i,n])=>{const{document:s}=t.model,{rangeJSON:{start:o,end:r},...a}=n,l=s.getRoot(o.root),c=e.createPositionFromPath(l,o.path,o.stickiness),d=e.createPositionFromPath(l,r.path,r.stickiness),h=e.createRange(c,d);e.addMarker(i,{range:h,...a})}))}_restoreCollaborationData(){const e=JSON.parse(this._data.commentThreads),t=JSON.parse(this._data.suggestions);e.forEach((e=>{const t=this.editor.config.get("collaboration.channelId"),i=this.editor.plugins.get("CommentsRepository");if(i.hasCommentThread(e.threadId)){i.getCommentThread(e.threadId).remove()}i.addCommentThread({channelId:t,...e})})),t.forEach((e=>{const t=this.editor.plugins.get("TrackChangesEditing");if(t.hasSuggestion(e.id)){t.getSuggestion(e.id).attributes=e.attributes}else t.addSuggestionData(e)}))}constructor(e){this.editor=e,this._data=e.config.get("_watchdogInitialData")}}const Rk=Symbol("MainQueueId");class Bk extends Ek{setCreator(e){this._creator=e}setDestructor(e){this._destructor=e}get context(){return this._context}create(e={}){return this._actionQueues.enqueue(Rk,(()=>(this._contextConfig=e,this._create())))}getItem(e){return this._getWatchdog(e)._item}getItemState(e){return this._getWatchdog(e).state}add(e){const t=Mk(e);return Promise.all(t.map((e=>this._actionQueues.enqueue(e.id,(()=>{if("destroyed"===this.state)throw new Error("Cannot add items to destroyed watchdog.");if(!this._context)throw new Error("Context was not created yet. You should call the `ContextWatchdog#create()` method first.");let t;if(this._watchdogs.has(e.id))throw new Error(`Item with the given id is already added: '${e.id}'.`);if("editor"===e.type)return t=new Pk(null,this._watchdogConfig),t.setCreator(e.creator),t._setExcludedProperties(this._contextProps),e.destructor&&t.setDestructor(e.destructor),this._watchdogs.set(e.id,t),t.on("error",((i,{error:n,causesRestart:s})=>{this._fire("itemError",{itemId:e.id,error:n}),s&&this._actionQueues.enqueue(e.id,(()=>new Promise((i=>{const n=()=>{t.off("restart",n),this._fire("itemRestart",{itemId:e.id}),i()};t.on("restart",n)}))))})),t.create(e.sourceElementOrData,e.config,this._context);throw new Error(`Not supported item type: '${e.type}'.`)})))))}remove(e){const t=Mk(e);return Promise.all(t.map((e=>this._actionQueues.enqueue(e,(()=>{const t=this._getWatchdog(e);return this._watchdogs.delete(e),t.destroy()})))))}destroy(){return this._actionQueues.enqueue(Rk,(()=>(this.state="destroyed",this._fire("stateChange"),super.destroy(),this._destroy())))}_restart(){return this._actionQueues.enqueue(Rk,(()=>(this.state="initializing",this._fire("stateChange"),this._destroy().catch((e=>{console.error("An error happened during destroying the context or items.",e)})).then((()=>this._create())).then((()=>this._fire("restart"))))))}_create(){return Promise.resolve().then((()=>(this._startErrorHandling(),this._creator(this._contextConfig)))).then((e=>(this._context=e,this._contextProps=Tk(this._context),Promise.all(Array.from(this._watchdogs.values()).map((e=>(e._setExcludedProperties(this._contextProps),e.create(void 0,void 0,this._context))))))))}_destroy(){return Promise.resolve().then((()=>{this._stopErrorHandling();const e=this._context;return this._context=null,this._contextProps=new Set,Promise.all(Array.from(this._watchdogs.values()).map((e=>e.destroy()))).then((()=>this._destructor(e)))}))}_getWatchdog(e){const t=this._watchdogs.get(e);if(!t)throw new Error(`Item with the given id was not registered: ${e}.`);return t}_isErrorComingFromThisItem(e){for(const t of this._watchdogs.values())if(t._isErrorComingFromThisItem(e))return!1;return Ik(this._context,e.context)}constructor(e,t={}){super(t),this._watchdogs=new Map,this._context=null,this._contextProps=new Set,this._actionQueues=new Ok,this._watchdogConfig=t,this._creator=t=>e.create(t),this._destructor=e=>e.destroy(),this._actionQueues.onEmpty((()=>{"initializing"===this.state&&(this.state="ready",this._fire("stateChange"))}))}}class Ok{onEmpty(e){this._onEmptyCallbacks.push(e)}enqueue(e,t){const i=e===Rk;this._activeActions++,this._queues.get(e)||this._queues.set(e,Promise.resolve());const n=(i?Promise.all(this._queues.values()):Promise.all([this._queues.get(Rk),this._queues.get(e)])).then(t),s=n.catch((()=>{}));return this._queues.set(e,s),n.finally((()=>{this._activeActions--,this._queues.get(e)===s&&0===this._activeActions&&this._onEmptyCallbacks.forEach((e=>e()))}))}constructor(){this._onEmptyCallbacks=[],this._queues=new Map,this._activeActions=0}}function Mk(e){return Array.isArray(e)?e:[e]}class Lk extends bb{get element(){return this.view.editable.element}init(){const e=this.editor,t=this.view,i=e.editing.view,n=t.editable,s=i.document.getRoot();n.name=s.rootName,t.render();const o=n.element;this.setEditableElement(n.name,o),n.bind("isFocused").to(this.focusTracker),i.attachDomRoot(o),this._initPlaceholder(),this.fire("ready")}destroy(){super.destroy();const e=this.view;this.editor.editing.view.detachDomRoot(e.editable.name),e.destroy()}_initPlaceholder(){const e=this.editor,t=e.editing.view,i=t.document.getRoot(),n=e.config.get("placeholder");if(n){const e="string"==typeof n?n:n[i.rootName];e&&(i.placeholder=e)}Ga({view:t,element:i,isDirectHost:!1,keepOnFocus:!0})}constructor(e,t){super(e),this.view=t}}class Nk extends vb{render(){super.render(),this.registerChild(this.editable)}constructor(e,t,i){super(e);const n=e.t;this.editable=new kb(e,t,i,{label:e=>n("Rich Text Editor. Editing area: %0",e.name)})}}class Fk extends(Lm(Bm)){destroy(){const e=this.getData();return this.ui.destroy(),super.destroy().then((()=>{this.sourceElement&&this.updateSourceElement(e)}))}static create(e,t={}){return new Promise((i=>{if(Dk(e)&&"TEXTAREA"===e.tagName)throw new p("editor-wrong-element",null);const n=new this(e,t);i(n.initPlugins().then((()=>n.ui.init())).then((()=>n.data.init(n.config.get("initialData")))).then((()=>n.fire("ready"))).then((()=>n)))}))}constructor(e,t={}){if(!Dk(e)&&void 0!==t.initialData)throw new p("editor-create-initial-data",null);super(t),void 0===this.config.get("initialData")&&this.config.set("initialData",function(e){return Dk(e)?Cr(e):e}(e)),Dk(e)&&(this.sourceElement=e,Nm(this,e));const i=this.config.get("plugins");i.push(zb),this.config.set("plugins",i),this.config.define("balloonToolbar",this.config.get("toolbar")),this.model.document.createRoot();const n=new Nk(this.locale,this.editing.view,this.sourceElement);this.ui=new Lk(this,n),Om(this)}}function Dk(e){return Fo(e)}Fk.Context=Ua,Fk.EditorWatchdog=Pk,Fk.ContextWatchdog=Bk;class zk extends bb{get element(){return this.view.element}init(e){const t=this.editor,i=this.view,n=t.editing.view,s=i.editable,o=n.document.getRoot();s.name=o.rootName,i.render();const r=s.element;this.setEditableElement(s.name,r),i.editable.bind("isFocused").to(this.focusTracker),n.attachDomRoot(r),e&&this._elementReplacer.replace(e,this.element),this._initPlaceholder(),this._initToolbar(),this._initMenuBar(),this._initDialogPluginIntegration(),this.fire("ready")}destroy(){super.destroy();const e=this.view,t=this.editor.editing.view;this._elementReplacer.restore(),t.detachDomRoot(e.editable.name),e.destroy()}_initToolbar(){const e=this.view;e.stickyPanel.bind("isActive").to(this.focusTracker,"isFocused"),e.stickyPanel.limiterElement=e.element,e.stickyPanel.bind("viewportTopOffset").to(this,"viewportOffset",(({top:e})=>e||0)),e.toolbar.fillFromConfig(this._toolbarConfig,this.componentFactory),this.addToolbar(e.toolbar)}_initMenuBar(){const e=this.view;e.menuBarView&&(this._setupMenuBarBehaviors(e.menuBarView.element),e.menuBarView.fillFromConfig(this._menuBarConfig,this.componentFactory))}_initPlaceholder(){const e=this.editor,t=e.editing.view,i=t.document.getRoot(),n=e.sourceElement;let s;const o=e.config.get("placeholder");o&&(s="string"==typeof o?o:o[this.view.editable.name]),!s&&n&&"textarea"===n.tagName.toLowerCase()&&(s=n.getAttribute("placeholder")),s&&(i.placeholder=s),Ga({view:t,element:i,isDirectHost:!1,keepOnFocus:!0})}_handleScrollToTheSelectionWithStickyPanel(e,t,i){const n=this.view.stickyPanel;if(n.isSticky){const e=new Ir(n.element).height;t.viewportOffset.top+=e}else{const e=()=>{this.editor.editing.view.scrollToTheSelection(i)};this.listenTo(n,"change:isSticky",e),setTimeout((()=>{this.stopListening(n,"change:isSticky",e)}),20)}}_initDialogPluginIntegration(){if(!this.editor.plugins.has("Dialog"))return;const e=this.view.stickyPanel,t=this.editor.plugins.get("Dialog");t.on("show",(()=>{const i=t.view;i.on("moveTo",((t,n)=>{if(!e.isSticky||i.wasMoved)return;const s=new Ir(e.contentPanelElement);n[1]<s.bottom+Kp.defaultOffset&&(n[1]=s.bottom+Kp.defaultOffset)}),{priority:"high"})}),{priority:"low"})}_setupMenuBarBehaviors(e){const t=this.editor;this.focusTracker.add(e),t.keystrokes.listenTo(e),t.keystrokes.set("Esc",((i,n)=>{e.contains(this.focusTracker.focusedElement)&&(t.editing.view.focus(),n())})),t.keystrokes.set("Alt+F9",((t,i)=>{e.contains(this.focusTracker.focusedElement)||(this.view.menuBarView.focus(),i())}))}constructor(e,t){super(e),this.view=t,this._toolbarConfig=Bf(e.config.get("toolbar")),this._menuBarConfig=Qb(e.config.get("menuBar")||{}),this._elementReplacer=new sr,this.listenTo(e.editing.view,"scrollToTheSelection",this._handleScrollToTheSelectionWithStickyPanel.bind(this))}}class Hk extends _b{render(){super.render(),this.menuBarView?this.stickyPanel.content.addMany([this.menuBarView,this.toolbar]):this.stickyPanel.content.add(this.toolbar),this.top.add(this.stickyPanel),this.main.add(this.editable)}constructor(e,t,i={}){super(e),this.stickyPanel=new Vb(e),this.toolbar=new Mf(e,{shouldGroupWhenFull:i.shouldToolbarGroupWhenFull}),i.useMenuBar&&(this.menuBarView=new fw(e)),this.editable=new kb(e,t)}}class $k extends(Lm(Bm)){destroy(){return this.sourceElement&&this.updateSourceElement(),this.ui.destroy(),super.destroy()}static create(e,t={}){return new Promise((i=>{const n=new this(e,t);i(n.initPlugins().then((()=>n.ui.init(Uk(e)?e:null))).then((()=>n.data.init(n.config.get("initialData")))).then((()=>n.fire("ready"))).then((()=>n)))}))}constructor(e,t={}){if(!Uk(e)&&void 0!==t.initialData)throw new p("editor-create-initial-data",null);super(t),this.config.define("menuBar.isVisible",!1),void 0===this.config.get("initialData")&&this.config.set("initialData",function(e){return Uk(e)?Cr(e):e}(e)),Uk(e)&&(this.sourceElement=e),this.model.document.createRoot();const i=!this.config.get("toolbar.shouldNotGroupWhenFull"),n=this.config.get("menuBar"),s=new Hk(this.locale,this.editing.view,{shouldToolbarGroupWhenFull:i,useMenuBar:n.isVisible});this.ui=new zk(this,s),Om(this)}}function Uk(e){return Fo(e)}$k.Context=Ua,$k.EditorWatchdog=Pk,$k.ContextWatchdog=Bk;class Wk extends bb{init(){const e=this.editor,t=this.view,i=e.editing.view,n=t.editable,s=i.document.getRoot();n.name=s.rootName,t.render();const o=n.element;this.setEditableElement(n.name,o),t.editable.bind("isFocused").to(this.focusTracker),i.attachDomRoot(o),this._initPlaceholder(),this._initToolbar(),this._initMenuBar(),this.fire("ready")}destroy(){super.destroy();const e=this.view;this.editor.editing.view.detachDomRoot(e.editable.name),e.destroy()}_initToolbar(){const e=this.editor,t=this.view;t.toolbar.fillFromConfig(e.config.get("toolbar"),this.componentFactory),this.addToolbar(t.toolbar)}_initMenuBar(){const e=this.editor,t=this.view.menuBarView.element,i=this.view;this.focusTracker.add(t),e.keystrokes.listenTo(t);const n=Qb(e.config.get("menuBar")||{});i.menuBarView.fillFromConfig(n,this.componentFactory),e.keystrokes.set("Esc",((i,n)=>{t.contains(this.focusTracker.focusedElement)&&(e.editing.view.focus(),n())})),e.keystrokes.set("Alt+F9",((e,i)=>{t.contains(this.focusTracker.focusedElement)||(this.view.menuBarView.focus(),i())}))}_initPlaceholder(){const e=this.editor,t=e.editing.view,i=t.document.getRoot(),n=e.config.get("placeholder");if(n){const e="string"==typeof n?n:n[i.rootName];e&&(i.placeholder=e)}Ga({view:t,element:i,isDirectHost:!1,keepOnFocus:!0})}constructor(e,t){super(e),this.view=t}}class jk extends vb{render(){super.render(),this.registerChild([this.menuBarView,this.toolbar,this.editable])}constructor(e,t,i={}){super(e);const n=e.t;this.toolbar=new Mf(e,{shouldGroupWhenFull:i.shouldToolbarGroupWhenFull}),this.menuBarView=new fw(e),this.editable=new kb(e,t,i.editableElement,{label:e=>n("Rich Text Editor. Editing area: %0",e.name)}),this.toolbar.extendTemplate({attributes:{class:["ck-reset_all","ck-rounded-corners"],dir:e.uiLanguageDirection}}),this.menuBarView.extendTemplate({attributes:{class:["ck-reset_all","ck-rounded-corners"],dir:e.uiLanguageDirection}})}}class qk extends(Lm(Bm)){destroy(){const e=this.getData();return this.ui.destroy(),super.destroy().then((()=>{this.sourceElement&&this.updateSourceElement(e)}))}static create(e,t={}){return new Promise((i=>{if(Gk(e)&&"TEXTAREA"===e.tagName)throw new p("editor-wrong-element",null);const n=new this(e,t);i(n.initPlugins().then((()=>n.ui.init())).then((()=>n.data.init(n.config.get("initialData")))).then((()=>n.fire("ready"))).then((()=>n)))}))}constructor(e,t={}){if(!Gk(e)&&void 0!==t.initialData)throw new p("editor-create-initial-data",null);super(t),void 0===this.config.get("initialData")&&this.config.set("initialData",function(e){return Gk(e)?Cr(e):e}(e)),Gk(e)&&(this.sourceElement=e,Nm(this,e)),this.model.document.createRoot();const i=!this.config.get("toolbar.shouldNotGroupWhenFull"),n=new jk(this.locale,this.editing.view,{editableElement:this.sourceElement,shouldToolbarGroupWhenFull:i});this.ui=new Wk(this,n)}}function Gk(e){return Fo(e)}qk.Context=Ua,qk.EditorWatchdog=Pk,qk.ContextWatchdog=Bk;class Kk extends bb{get element(){return this.view.editable.element}init(){const e=this.editor,t=this.view,i=e.editing.view,n=t.editable,s=i.document.getRoot();n.name=s.rootName,t.render();const o=n.element;this.setEditableElement(n.name,o),n.bind("isFocused").to(this.focusTracker),i.attachDomRoot(o),this._initPlaceholder(),this._initToolbar(),this.fire("ready")}destroy(){super.destroy();const e=this.view;this.editor.editing.view.detachDomRoot(e.editable.name),e.destroy()}_initToolbar(){const e=this.editor,t=this.view,i=t.editable.element,n=t.toolbar;t.panel.bind("isVisible").to(this.focusTracker,"isFocused"),t.bind("viewportTopOffset").to(this,"viewportOffset",(({top:e})=>e||0)),t.listenTo(e.ui,"update",(()=>{t.panel.isVisible&&t.panel.pin({target:i,positions:t.panelPositions})})),n.fillFromConfig(this._toolbarConfig,this.componentFactory),this.addToolbar(n)}_initPlaceholder(){const e=this.editor,t=e.editing.view,i=t.document.getRoot(),n=e.config.get("placeholder");if(n){const e="string"==typeof n?n:n[i.rootName];e&&(i.placeholder=e)}Ga({view:t,element:i,isDirectHost:!1,keepOnFocus:!0})}constructor(e,t){super(e),this.view=t,this._toolbarConfig=Bf(e.config.get("toolbar"))}}const Zk=Lr("px");class Jk extends vb{render(){super.render(),this.body.add(this.panel),this.registerChild(this.editable),this.panel.content.add(this.toolbar);if(this.toolbar.options.shouldGroupWhenFull){const e=this.editable.element;this._resizeObserver=new Or(e,(()=>{this.toolbar.maxWidth=Zk(new Ir(e).width)}))}}destroy(){super.destroy(),this._resizeObserver&&this._resizeObserver.destroy()}_getPanelPositionTop(e,t){let i;return i=e.top>t.height+this.viewportTopOffset?e.top-t.height:e.bottom>t.height+this.viewportTopOffset+50?this.viewportTopOffset:e.bottom,i}_getPanelPositions(){const e=[(e,t)=>({top:this._getPanelPositionTop(e,t),left:e.left,name:"toolbar_west",config:{withArrow:!1}}),(e,t)=>({top:this._getPanelPositionTop(e,t),left:e.left+e.width-t.width,name:"toolbar_east",config:{withArrow:!1}})];return"ltr"===this.locale.uiLanguageDirection?e:e.reverse()}constructor(e,t,i,n={}){super(e);const s=e.t;this.toolbar=new Mf(e,{shouldGroupWhenFull:n.shouldToolbarGroupWhenFull,isFloating:!0}),this.set("viewportTopOffset",0),this.panel=new Xp(e),this.panelPositions=this._getPanelPositions(),this.panel.extendTemplate({attributes:{class:"ck-toolbar-container"}}),this.editable=new kb(e,t,i,{label:e=>s("Rich Text Editor. Editing area: %0",e.name)}),this._resizeObserver=null}}class Qk extends(Lm(Bm)){destroy(){const e=this.getData();return this.ui.destroy(),super.destroy().then((()=>{this.sourceElement&&this.updateSourceElement(e)}))}static create(e,t={}){return new Promise((i=>{if(Yk(e)&&"TEXTAREA"===e.tagName)throw new p("editor-wrong-element",null);const n=new this(e,t);i(n.initPlugins().then((()=>n.ui.init())).then((()=>n.data.init(n.config.get("initialData")))).then((()=>n.fire("ready"))).then((()=>n)))}))}constructor(e,t={}){if(!Yk(e)&&void 0!==t.initialData)throw new p("editor-create-initial-data",null);super(t),void 0===this.config.get("initialData")&&this.config.set("initialData",function(e){return Yk(e)?Cr(e):e}(e)),this.model.document.createRoot(),Yk(e)&&(this.sourceElement=e,Nm(this,e));const i=!this.config.get("toolbar.shouldNotGroupWhenFull"),n=new Jk(this.locale,this.editing.view,this.sourceElement,{shouldToolbarGroupWhenFull:i});this.ui=new Kk(this,n),Om(this)}}function Yk(e){return Fo(e)}Qk.Context=Ua,Qk.EditorWatchdog=Pk,Qk.ContextWatchdog=Bk;class Xk extends bb{init(){this.view.render(),this.focusTracker.on("change:focusedElement",((e,t,i)=>{for(const e of Object.values(this.view.editables))i===e.element&&(this._lastFocusedEditableElement=e.element)})),this.focusTracker.on("change:isFocused",((e,t,i)=>{i||(this._lastFocusedEditableElement=null)}));for(const e of Object.values(this.view.editables))this.addEditable(e);this._initToolbar(),this.fire("ready")}addEditable(e,t){const i=e.element;this.editor.editing.view.attachDomRoot(i,e.name),this.setEditableElement(e.name,i),e.bind("isFocused").to(this.focusTracker,"isFocused",this.focusTracker,"focusedElement",((e,t)=>!!e&&(t===i||this._lastFocusedEditableElement===i))),this._initPlaceholder(e,t)}removeEditable(e){this.editor.editing.view.detachDomRoot(e.name),e.unbind("isFocused"),this.removeEditableElement(e.name)}destroy(){super.destroy();for(const e of Object.values(this.view.editables))this.removeEditable(e);this.view.destroy()}_initToolbar(){const e=this.editor,t=this.view;t.toolbar.fillFromConfig(e.config.get("toolbar"),this.componentFactory),this.addToolbar(t.toolbar)}_initPlaceholder(e,t){if(!t){const i=this.editor.config.get("placeholder");i&&(t="string"==typeof i?i:i[e.name])}const i=this.editor.editing.view,n=i.document.getRoot(e.name);t&&(n.placeholder=t),Ga({view:i,element:n,isDirectHost:!1,keepOnFocus:!0})}constructor(e,t){super(e),this.view=t,this._lastFocusedEditableElement=null}}class eC extends vb{createEditable(e,t){const i=this.locale.t,n=new kb(this.locale,this._editingView,t,{label:e=>i("Rich Text Editor. Editing area: %0",e.name)});return this.editables[e]=n,n.name=e,this.isRendered&&this.registerChild(n),n}removeEditable(e){const t=this.editables[e];this.isRendered&&this.deregisterChild(t),delete this.editables[e],t.destroy()}render(){super.render(),this.registerChild(Object.values(this.editables)),this.registerChild(this.toolbar)}constructor(e,t,i,n={}){super(e),this._editingView=t,this.toolbar=new Mf(e,{shouldGroupWhenFull:n.shouldToolbarGroupWhenFull}),this.editables={};for(const e of i){const t=n.editableElements?n.editableElements[e]:void 0;this.createEditable(e,t)}this.editable=Object.values(this.editables)[0],this.toolbar.extendTemplate({attributes:{class:["ck-reset_all","ck-rounded-corners"],dir:e.uiLanguageDirection}})}}class tC extends Bm{destroy(){const e=this.config.get("updateSourceElementOnDestroy"),t={};for(const i of Object.keys(this.sourceElements))t[i]=e?this.getData({rootName:i}):"";return this.ui.destroy(),super.destroy().then((()=>{for(const e of Object.keys(this.sourceElements))Mr(this.sourceElements[e],t[e])}))}addRoot(e,{data:t="",attributes:i={},elementName:n="$root",isUndoable:s=!1}={}){const o=s=>{const o=s.addRoot(e,n);t&&s.insert(this.data.parse(t,o),o,0);for(const e of Object.keys(i))this.registerRootAttribute(e),s.setAttribute(e,i[e],o)};s?this.model.change(o):this.model.enqueueChange({isUndoable:!1},o)}detachRoot(e,t=!1){t?this.model.change((t=>t.detachRoot(e))):this.model.enqueueChange({isUndoable:!1},(t=>t.detachRoot(e)))}createEditable(e,t){const i=this.ui.view.createEditable(e.rootName);return this.ui.addEditable(i,t),this.editing.view.forceRender(),i.element}detachEditable(e){const t=e.rootName,i=this.ui.view.editables[t];return this.ui.removeEditable(i),this.ui.view.removeEditable(t),i.element}loadRoot(e,{data:t="",attributes:i={}}={}){const n=this.model.document.getRoot(e);this.model.enqueueChange({isUndoable:!1},(e=>{t&&e.insert(this.data.parse(t,n),n,0);for(const t of Object.keys(i))this.registerRootAttribute(t),e.setAttribute(t,i[t],n);n._isLoaded=!0,this.model.document.differ._bufferRootLoad(n)}))}getFullData(e){const t={};for(const i of this.model.document.getRootNames())t[i]=this.data.get({...e,rootName:i});return t}getRootsAttributes(){const e={};for(const t of this.model.document.getRootNames())e[t]=this.getRootAttributes(t);return e}getRootAttributes(e){const t={},i=this.model.document.getRoot(e);for(const e of this._registeredRootsAttributesKeys)t[e]=i.hasAttribute(e)?i.getAttribute(e):null;return t}registerRootAttribute(e){this._registeredRootsAttributesKeys.has(e)||(this._registeredRootsAttributesKeys.add(e),this.editing.model.schema.extend("$root",{allowAttributes:e}))}disableRoot(e,t){if("$graveyard"==e)throw new p("multi-root-editor-cannot-disable-graveyard-root",this);const i=this._readOnlyRootLocks.get(e);if(i)i.add(t);else{this._readOnlyRootLocks.set(e,new Set([t]));this.editing.view.document.getRoot(e).isReadOnly=!0,Array.from(this.commands.commands()).forEach((e=>e.affectsData&&e.refresh()))}}enableRoot(e,t){const i=this._readOnlyRootLocks.get(e);if(i&&i.has(t))if(1===i.size){this._readOnlyRootLocks.delete(e);this.editing.view.document.getRoot(e).isReadOnly=this.isReadOnly,Array.from(this.commands.commands()).forEach((e=>e.affectsData&&e.refresh()))}else i.delete(t)}static create(e,t={}){return new Promise((i=>{for(const t of Object.values(e))if(iC(t)&&"TEXTAREA"===t.tagName)throw new p("editor-wrong-element",null);const n=new this(e,t);i(n.initPlugins().then((()=>n.ui.init())).then((()=>(n._verifyRootsWithInitialData(),n.data.init(n.config.get("initialData"))))).then((()=>n.fire("ready"))).then((()=>n)))}))}_verifyRootsWithInitialData(){const e=this.config.get("initialData");for(const t of this.model.document.getRootNames())if(!(t in e))throw new p("multi-root-editor-root-initial-data-mismatch",null);for(const t of Object.keys(e)){const e=this.model.document.getRoot(t);if(!e||!e.isAttached())throw new p("multi-root-editor-root-initial-data-mismatch",null)}}constructor(e,t={}){const i=Object.keys(e),n=0===i.length||"string"==typeof e[i[0]];if(n&&void 0!==t.initialData&&Object.keys(t.initialData).length>0)throw new p("editor-create-initial-data",null);if(super(t),this._registeredRootsAttributesKeys=new Set,this._readOnlyRootLocks=new Map,this.sourceElements=n?{}:e,void 0===this.config.get("initialData")){const t={};for(const n of i)t[n]=iC(s=e[n])?Cr(s):s;this.config.set("initialData",t)}var s;if(!n)for(const t of i)Nm(this,e[t]);this.editing.view.document.roots.on("add",((e,t)=>{t.unbind("isReadOnly"),t.bind("isReadOnly").to(this.editing.view.document,"isReadOnly",(e=>e||this._readOnlyRootLocks.has(t.rootName))),t.on("change:isReadOnly",((e,i,n)=>{const s=this.editing.view.createRangeIn(t);for(const e of s.getItems())e.is("editableElement")&&(e.unbind("isReadOnly"),e.isReadOnly=n)}))}));for(const e of i)this.model.document.createRoot("$root",e);if(this.config.get("lazyRoots"))for(const e of this.config.get("lazyRoots")){this.model.document.createRoot("$root",e)._isLoaded=!1}if(this.config.get("rootsAttributes")){const e=this.config.get("rootsAttributes");for(const[t,i]of Object.entries(e)){if(!this.model.document.getRoot(t))throw new p("multi-root-editor-root-attributes-no-root",null);for(const e of Object.keys(i))this.registerRootAttribute(e)}this.data.on("init",(()=>{this.model.enqueueChange({isUndoable:!1},(t=>{for(const[i,n]of Object.entries(e)){const e=this.model.document.getRoot(i);for(const[i,s]of Object.entries(n))null!==s&&t.setAttribute(i,s,e)}}))}))}const o={shouldToolbarGroupWhenFull:!this.config.get("toolbar.shouldNotGroupWhenFull"),editableElements:n?void 0:e},r=new eC(this.locale,this.editing.view,i,o);this.ui=new Xk(this,r),this.model.document.on("change:data",(()=>{const e=this.model.document.differ.getChangedRoots();for(const t of e){const e=this.model.document.getRoot(t.name);"detached"==t.state&&this.fire("detachRoot",e)}for(const t of e){const e=this.model.document.getRoot(t.name);"attached"==t.state&&this.fire("addRoot",e)}})),this.listenTo(this.model,"canEditAt",((e,[t])=>{if(!t)return;let i=!1;for(const e of t.getRanges()){const t=e.root;if(this._readOnlyRootLocks.has(t.rootName)){i=!0;break}}i&&(e.return=!1,e.stop())}),{priority:"high"}),this.decorate("loadRoot"),this.on("loadRoot",((e,[t])=>{const i=this.model.document.getRoot(t);if(!i)throw new p("multi-root-editor-load-root-no-root",this,{rootName:t});i._isLoaded&&(b("multi-root-editor-load-root-already-loaded"),e.stop())}),{priority:"highest"})}}function iC(e){return Fo(e)}tC.Context=Ua,tC.EditorWatchdog=Pk,tC.ContextWatchdog=Bk;class nC extends Da{execute(){const e=this.editor.model,t=e.document.selection;let i=e.schema.getLimitElement(t);if(t.containsEntireContent(i)||!sC(e.schema,i))do{if(i=i.parent,!i)return}while(!sC(e.schema,i));e.change((e=>{e.setSelection(i,"in")}))}constructor(e){super(e),this.affectsData=!1}}function sC(e,t){return e.isLimit(t)&&(e.checkChild(t,"$text")||e.checkChild(t,"paragraph"))}const oC=ca("Ctrl+A");class rC extends Na{static get pluginName(){return"SelectAllEditing"}init(){const e=this.editor,t=e.t,i=e.editing.view.document;e.commands.add("selectAll",new nC(e)),this.listenTo(i,"keydown",((t,i)=>{la(i)===oC&&(e.execute("selectAll"),i.preventDefault())})),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Select all"),keystroke:"CTRL+A"}]})}}class aC extends Na{static get pluginName(){return"SelectAllUI"}init(){const e=this.editor;e.ui.componentFactory.add("selectAll",(()=>{const e=this._createButton(Hg);return e.set({tooltip:!0}),e})),e.ui.componentFactory.add("menuBar:selectAll",(()=>this._createButton(uw)))}_createButton(e){const t=this.editor,i=t.locale,n=t.commands.get("selectAll"),s=new e(t.locale),o=i.t;return s.set({label:o("Select all"),icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M.75 15.5a.75.75 0 0 1 .75.75V18l.008.09A.5.5 0 0 0 2 18.5h1.75a.75.75 0 1 1 0 1.5H1.5l-.144-.007a1.5 1.5 0 0 1-1.35-1.349L0 18.5v-2.25a.75.75 0 0 1 .75-.75zm18.5 0a.75.75 0 0 1 .75.75v2.25l-.007.144a1.5 1.5 0 0 1-1.349 1.35L18.5 20h-2.25a.75.75 0 1 1 0-1.5H18a.5.5 0 0 0 .492-.41L18.5 18v-1.75a.75.75 0 0 1 .75-.75zm-10.45 3c.11 0 .2.09.2.2v1.1a.2.2 0 0 1-.2.2H7.2a.2.2 0 0 1-.2-.2v-1.1c0-.11.09-.2.2-.2h1.6zm4 0c.11 0 .2.09.2.2v1.1a.2.2 0 0 1-.2.2h-1.6a.2.2 0 0 1-.2-.2v-1.1c0-.11.09-.2.2-.2h1.6zm.45-5.5a.75.75 0 1 1 0 1.5h-8.5a.75.75 0 1 1 0-1.5h8.5zM1.3 11c.11 0 .2.09.2.2v1.6a.2.2 0 0 1-.2.2H.2a.2.2 0 0 1-.2-.2v-1.6c0-.11.09-.2.2-.2h1.1zm18.5 0c.11 0 .2.09.2.2v1.6a.2.2 0 0 1-.2.2h-1.1a.2.2 0 0 1-.2-.2v-1.6c0-.11.09-.2.2-.2h1.1zm-4.55-2a.75.75 0 1 1 0 1.5H4.75a.75.75 0 1 1 0-1.5h10.5zM1.3 7c.11 0 .2.09.2.2v1.6a.2.2 0 0 1-.2.2H.2a.2.2 0 0 1-.2-.2V7.2c0-.11.09-.2.2-.2h1.1zm18.5 0c.11 0 .2.09.2.2v1.6a.2.2 0 0 1-.2.2h-1.1a.2.2 0 0 1-.2-.2V7.2c0-.11.09-.2.2-.2h1.1zm-4.55-2a.75.75 0 1 1 0 1.5h-2.5a.75.75 0 1 1 0-1.5h2.5zm-5 0a.75.75 0 1 1 0 1.5h-5.5a.75.75 0 0 1 0-1.5h5.5zm-6.5-5a.75.75 0 0 1 0 1.5H2a.5.5 0 0 0-.492.41L1.5 2v1.75a.75.75 0 0 1-1.5 0V1.5l.007-.144A1.5 1.5 0 0 1 1.356.006L1.5 0h2.25zM18.5 0l.144.007a1.5 1.5 0 0 1 1.35 1.349L20 1.5v2.25a.75.75 0 1 1-1.5 0V2l-.008-.09A.5.5 0 0 0 18 1.5h-1.75a.75.75 0 1 1 0-1.5h2.25zM8.8 0c.11 0 .2.09.2.2v1.1a.2.2 0 0 1-.2.2H7.2a.2.2 0 0 1-.2-.2V.2c0-.11.09-.2.2-.2h1.6zm4 0c.11 0 .2.09.2.2v1.1a.2.2 0 0 1-.2.2h-1.6a.2.2 0 0 1-.2-.2V.2c0-.11.09-.2.2-.2h1.6z"/></svg>',keystroke:"Ctrl+A"}),s.bind("isEnabled").to(n,"isEnabled"),this.listenTo(s,"execute",(()=>{t.execute("selectAll"),t.editing.view.focus()})),s}}class lC extends Na{static get requires(){return[rC,aC]}static get pluginName(){return"SelectAll"}}class cC extends Da{refresh(){this.isEnabled=this._stack.length>0}get createdBatches(){return this._createdBatches}addBatch(e){const t=this.editor.model.document.selection,i={ranges:t.hasOwnRange?Array.from(t.getRanges()):[],isBackward:t.isBackward};this._stack.push({batch:e,selection:i}),this.refresh()}clearStack(){this._stack=[],this.refresh()}_restoreSelection(e,t,i){const n=this.editor.model,s=n.document,o=[],r=e.map((e=>e.getTransformedByOperations(i))),a=r.flat();for(const e of r){const t=e.filter((e=>e.root!=s.graveyard)).filter((e=>!hC(e,a)));t.length&&(dC(t),o.push(t[0]))}o.length&&n.change((e=>{e.setSelection(o,{backward:t})}))}_undo(e,t){const i=this.editor.model,n=i.document;this._createdBatches.add(t);const s=e.operations.slice().filter((e=>e.isDocumentOperation));s.reverse();for(const e of s){const s=e.baseVersion+1,o=Array.from(n.history.getOperations(s)),r=Gh([e.getReversed()],o,{useRelations:!0,document:this.editor.model.document,padWithNoOps:!1,forceWeakRemove:!0}).operationsA;for(let s of r){const o=s.affectedSelectable;o&&!i.canEditAt(o)&&(s=new Nh(s.baseVersion)),t.addOperation(s),i.applyOperation(s),n.history.setOperationAsUndone(e,s)}}}constructor(e){super(e),this._stack=[],this._createdBatches=new WeakSet,this.refresh(),this._isEnabledBasedOnSelection=!1,this.listenTo(e.data,"set",((e,t)=>{t[1]={...t[1]};const i=t[1];i.batchType||(i.batchType={isUndoable:!1})}),{priority:"high"}),this.listenTo(e.data,"set",((e,t)=>{t[1].batchType.isUndoable||this.clearStack()}))}}function dC(e){e.sort(((e,t)=>e.start.isBefore(t.start)?-1:1));for(let t=1;t<e.length;t++){const i=e[t-1].getJoined(e[t],!0);i&&(t--,e.splice(t,2,i))}}function hC(e,t){return t.some((t=>t!==e&&t.containsRange(e,!0)))}class uC extends cC{execute(e=null){const t=e?this._stack.findIndex((t=>t.batch==e)):this._stack.length-1,i=this._stack.splice(t,1)[0],n=this.editor.model.createBatch({isUndo:!0});this.editor.model.enqueueChange(n,(()=>{this._undo(i.batch,n);const e=this.editor.model.document.history.getOperations(i.batch.baseVersion);this._restoreSelection(i.selection.ranges,i.selection.isBackward,e)})),this.fire("revert",i.batch,n),this.refresh()}}class mC extends cC{execute(){const e=this._stack.pop(),t=this.editor.model.createBatch({isUndo:!0});this.editor.model.enqueueChange(t,(()=>{const i=e.batch.operations[e.batch.operations.length-1].baseVersion+1,n=this.editor.model.document.history.getOperations(i);this._restoreSelection(e.selection.ranges,e.selection.isBackward,n),this._undo(e.batch,t)})),this.refresh()}}class gC extends Na{static get pluginName(){return"UndoEditing"}init(){const e=this.editor,t=e.t;this._undoCommand=new uC(e),this._redoCommand=new mC(e),e.commands.add("undo",this._undoCommand),e.commands.add("redo",this._redoCommand),this.listenTo(e.model,"applyOperation",((e,t)=>{const i=t[0];if(!i.isDocumentOperation)return;const n=i.batch,s=this._redoCommand.createdBatches.has(n),o=this._undoCommand.createdBatches.has(n);this._batchRegistry.has(n)||(this._batchRegistry.add(n),n.isUndoable&&(s?this._undoCommand.addBatch(n):o||(this._undoCommand.addBatch(n),this._redoCommand.clearStack())))}),{priority:"highest"}),this.listenTo(this._undoCommand,"revert",((e,t,i)=>{this._redoCommand.addBatch(i)})),e.keystrokes.set("CTRL+Z","undo"),e.keystrokes.set("CTRL+Y","redo"),e.keystrokes.set("CTRL+SHIFT+Z","redo"),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Undo"),keystroke:"CTRL+Z"},{label:t("Redo"),keystroke:[["CTRL+Y"],["CTRL+SHIFT+Z"]]}]})}constructor(...e){super(...e),this._batchRegistry=new WeakSet}}class fC extends Na{static get pluginName(){return"UndoUI"}init(){const e=this.editor,t=e.locale,i=e.t,n="ltr"==t.uiLanguageDirection?Dm.undo:Dm.redo,s="ltr"==t.uiLanguageDirection?Dm.redo:Dm.undo;this._addButtonsToFactory("undo",i("Undo"),"CTRL+Z",n),this._addButtonsToFactory("redo",i("Redo"),"CTRL+Y",s)}_addButtonsToFactory(e,t,i,n){const s=this.editor;s.ui.componentFactory.add(e,(()=>{const s=this._createButton(Hg,e,t,i,n);return s.set({tooltip:!0}),s})),s.ui.componentFactory.add("menuBar:"+e,(()=>this._createButton(uw,e,t,i,n)))}_createButton(e,t,i,n,s){const o=this.editor,r=o.locale,a=o.commands.get(t),l=new e(r);return l.set({label:i,icon:s,keystroke:n}),l.bind("isEnabled").to(a,"isEnabled"),this.listenTo(l,"execute",(()=>{o.execute(t),o.editing.view.focus()})),l}}class pC extends Na{static get requires(){return[gC,fC]}static get pluginName(){return"Undo"}}class bC extends Na{static get requires(){return[Ng,Jy,Kv,lC,Yv,Bw,pC]}static get pluginName(){return"Essentials"}}class wC extends Tg{render(){super.render(),Vg({view:this}),this._initFocusCycling(),this._initKeystrokeHandling()}destroy(){super.destroy(),this._focusTracker.destroy(),this._keystrokes.destroy()}focus(e){-1===e?this.focusCycler.focusLast():this.focusCycler.focusFirst()}reset(){this._findInputView.errorText=null,this.isDirty=!0}get _textToFind(){return this._findInputView.fieldView.element.value}get _textToReplace(){return this._replaceInputView.fieldView.element.value}_createInputsDiv(){const e=this.locale,t=e.t,i=new Tg(e);return this._findInputView.fieldView.on("input",(()=>{this.isDirty=!0})),this._findPrevButtonView.delegate("execute").to(this,"findPrevious"),this._findNextButtonView.delegate("execute").to(this,"findNext"),this._findPrevButtonView.bind("isEnabled").to(this,"_areCommandsEnabled",(({findPrevious:e})=>e)),this._findNextButtonView.bind("isEnabled").to(this,"_areCommandsEnabled",(({findNext:e})=>e)),this._injectFindResultsCounter(),this._replaceInputView.bind("isEnabled").to(this,"_areCommandsEnabled",this,"_searchResultsFound",(({replace:e},t)=>e&&t)),this._replaceInputView.bind("infoText").to(this._replaceInputView,"isEnabled",this._replaceInputView,"isFocused",((e,i)=>e||!i?"":t("Tip: Find some text first in order to replace it."))),i.setTemplate({tag:"div",attributes:{class:["ck","ck-find-and-replace-form__inputs"]},children:[this._findInputView,this._findPrevButtonView,this._findNextButtonView,this._replaceInputView]}),i}_onFindButtonExecute(){if(this._textToFind)this.isDirty=!1,this.fire("findNext",{searchText:this._textToFind,matchCase:this._matchCase,wholeWords:this._wholeWordsOnly});else{const e=this.t;this._findInputView.errorText=e("Text to find must not be empty.")}}_injectFindResultsCounter(){const e=this.locale,t=e.t,i=this.bindTemplate,n=new Tg(this.locale);this.bind("_resultsCounterText").to(this,"highlightOffset",this,"matchCount",((e,i)=>t("%0 of %1",[e,i]))),n.setTemplate({tag:"span",attributes:{class:["ck","ck-results-counter",i.if("isDirty","ck-hidden")]},children:[{text:i.to("_resultsCounterText")}]});const s=()=>{const t=this._findInputView.fieldView.element;if(!t||!Hr(t))return;const i=new Ir(n.element).width,s="ltr"===e.uiLanguageDirection?"paddingRight":"paddingLeft";t.style[s]=i?`calc( 2 * var(--ck-spacing-standard) + ${i}px )`:""};this.on("change:_resultsCounterText",s,{priority:"low"}),this.on("change:isDirty",s,{priority:"low"}),this._findInputView.template.children[0].children.push(n)}_createAdvancedOptionsCollapsible(){const e=this.locale.t,t=new qg(this.locale,[this._matchCaseSwitchView,this._wholeWordsOnlySwitchView]);return t.set({label:e("Advanced options"),isCollapsed:!0}),t}_createActionButtonsDiv(){const e=new Tg(this.locale);return this._replaceButtonView.bind("isEnabled").to(this,"_areCommandsEnabled",this,"_searchResultsFound",(({replace:e},t)=>e&&t)),this._replaceAllButtonView.bind("isEnabled").to(this,"_areCommandsEnabled",this,"_searchResultsFound",(({replaceAll:e},t)=>e&&t)),this._replaceButtonView.on("execute",(()=>{this.fire("replace",{searchText:this._textToFind,replaceText:this._textToReplace})})),this._replaceAllButtonView.on("execute",(()=>{this.fire("replaceAll",{searchText:this._textToFind,replaceText:this._textToReplace}),this.focus()})),this._findButtonView.on("execute",this._onFindButtonExecute.bind(this)),e.setTemplate({tag:"div",attributes:{class:["ck","ck-find-and-replace-form__actions"]},children:[this._replaceAllButtonView,this._replaceButtonView,this._findButtonView]}),e}_createMatchCaseSwitch(){const e=this.locale.t,t=new $g(this.locale);return t.set({label:e("Match case"),withText:!0}),t.bind("isOn").to(this,"_matchCase"),t.on("execute",(()=>{this._matchCase=!this._matchCase,this.isDirty=!0})),t}_createWholeWordsOnlySwitch(){const e=this.locale.t,t=new $g(this.locale);return t.set({label:e("Whole words only"),withText:!0}),t.bind("isOn").to(this,"_wholeWordsOnly"),t.on("execute",(()=>{this._wholeWordsOnly=!this._wholeWordsOnly,this.isDirty=!0})),t}_initFocusCycling(){[this._findInputView,this._findPrevButtonView,this._findNextButtonView,this._replaceInputView,this._advancedOptionsCollapsibleView.buttonView,this._matchCaseSwitchView,this._wholeWordsOnlySwitchView,this._replaceAllButtonView,this._replaceButtonView,this._findButtonView].forEach((e=>{this._focusables.add(e),this._focusTracker.add(e.element)}))}_initKeystrokeHandling(){const e=e=>e.stopPropagation(),t=e=>{e.stopPropagation(),e.preventDefault()};this._keystrokes.listenTo(this.element),this._keystrokes.set("f3",(e=>{t(e),this._findNextButtonView.fire("execute")})),this._keystrokes.set("shift+f3",(e=>{t(e),this._findPrevButtonView.fire("execute")})),this._keystrokes.set("enter",(e=>{const i=e.target;i===this._findInputView.fieldView.element?(this._areCommandsEnabled.findNext?this._findNextButtonView.fire("execute"):this._findButtonView.fire("execute"),t(e)):i!==this._replaceInputView.fieldView.element||this.isDirty||(this._replaceButtonView.fire("execute"),t(e))})),this._keystrokes.set("shift+enter",(e=>{e.target===this._findInputView.fieldView.element&&(this._areCommandsEnabled.findPrevious?this._findPrevButtonView.fire("execute"):this._findButtonView.fire("execute"),t(e))})),this._keystrokes.set("arrowright",e),this._keystrokes.set("arrowleft",e),this._keystrokes.set("arrowup",e),this._keystrokes.set("arrowdown",e)}_createButton(e){const t=new Hg(this.locale);return t.set(e),t}_createInputField(e,t){const i=new bf(this.locale,Qf);return i.label=e,i.class=t,i}constructor(e){super(e);const t=e.t;this.children=this.createCollection(),this.set("matchCount",0),this.set("highlightOffset",0),this.set("isDirty",!1),this.set("_areCommandsEnabled",{}),this.set("_resultsCounterText",""),this.set("_matchCase",!1),this.set("_wholeWordsOnly",!1),this.bind("_searchResultsFound").to(this,"matchCount",this,"isDirty",((e,t)=>e>0&&!t)),this._findInputView=this._createInputField(t("Find in text…")),this._findPrevButtonView=this._createButton({label:t("Previous result"),class:"ck-button-prev",icon:Dm.previousArrow,keystroke:"Shift+F3",tooltip:!0}),this._findNextButtonView=this._createButton({label:t("Next result"),class:"ck-button-next",icon:Dm.previousArrow,keystroke:"F3",tooltip:!0}),this._replaceInputView=this._createInputField(t("Replace with…"),"ck-labeled-field-replace"),this._inputsDivView=this._createInputsDiv(),this._matchCaseSwitchView=this._createMatchCaseSwitch(),this._wholeWordsOnlySwitchView=this._createWholeWordsOnlySwitch(),this._advancedOptionsCollapsibleView=this._createAdvancedOptionsCollapsible(),this._replaceAllButtonView=this._createButton({label:t("Replace all"),class:"ck-button-replaceall",withText:!0}),this._replaceButtonView=this._createButton({label:t("Replace"),class:"ck-button-replace",withText:!0}),this._findButtonView=this._createButton({label:t("Find"),class:"ck-button-find ck-button-action",withText:!0}),this._actionButtonsDivView=this._createActionButtonsDiv(),this._focusTracker=new ya,this._keystrokes=new ka,this._focusables=new og,this.focusCycler=new Tf({focusables:this._focusables,focusTracker:this._focusTracker,keystrokeHandler:this._keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.children.addMany([this._inputsDivView,this._advancedOptionsCollapsibleView,this._actionButtonsDivView]),this.setTemplate({tag:"form",attributes:{class:["ck","ck-find-and-replace-form"],tabindex:"-1"},children:this.children})}}var vC='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m12.87 13.786 1.532-1.286 3.857 4.596a1 1 0 1 1-1.532 1.286l-3.857-4.596z"/><path d="M16.004 8.5a6.5 6.5 0 0 1-9.216 5.905c-1.154-.53-.863-1.415-.663-1.615.194-.194.564-.592 1.635-.141a4.5 4.5 0 0 0 5.89-5.904l-.104-.227 1.332-1.331c.045-.046.196-.041.224.007a6.47 6.47 0 0 1 .902 3.306zm-3.4-5.715c.562.305.742 1.106.354 1.494-.388.388-.995.414-1.476.178a4.5 4.5 0 0 0-6.086 5.882l.114.236-1.348 1.349c-.038.037-.17.022-.198-.023a6.5 6.5 0 0 1 5.54-9.9 6.469 6.469 0 0 1 3.1.784z"/><path d="M4.001 11.93.948 8.877a.2.2 0 0 1 .141-.341h6.106a.2.2 0 0 1 .141.341L4.283 11.93a.2.2 0 0 1-.282 0zm11.083-6.789 3.053 3.053a.2.2 0 0 1-.14.342H11.89a.2.2 0 0 1-.14-.342l3.052-3.053a.2.2 0 0 1 .282 0z"/></svg>';class _C extends Na{static get requires(){return[Zp]}static get pluginName(){return"FindAndReplaceUI"}init(){const e=this.editor,t="dropdown"===e.config.get("findAndReplace.uiType"),i=e.commands.get("find"),n=this.editor.t;e.ui.componentFactory.add("findAndReplace",(()=>{let n;return t?(n=this._createDropdown(),n.bind("isEnabled").to(i)):n=this._createDialogButtonForToolbar(),e.keystrokes.set("Ctrl+F",((t,s)=>{if(i.isEnabled){if(n instanceof Af){const e=n.buttonView;e.isOn||e.fire("execute")}else n.isOn?e.plugins.get("Dialog").view.focus():n.fire("execute");s()}})),n})),t||e.ui.componentFactory.add("menuBar:findAndReplace",(()=>this._createDialogButtonForMenuBar())),e.accessibility.addKeystrokeInfos({keystrokes:[{label:n("Find in the document"),keystroke:"CTRL+F"}]})}_createDropdown(){const e=this.editor,t=e.locale.t,i=Wf(e.locale);return i.once("change:isOpen",(()=>{this.formView=this._createFormView(),this.formView.children.add(new Up(e.locale,{label:t("Find and replace")}),0),i.panelView.children.add(this.formView)})),i.on("change:isOpen",((e,t,i)=>{i?this._setupFormView():this.fire("searchReseted")}),{priority:"low"}),i.buttonView.set({icon:vC,label:t("Find and replace"),keystroke:"CTRL+F",tooltip:!0}),i}_createDialogButtonForToolbar(){const e=this.editor,t=this._createButton(Hg),i=e.plugins.get("Dialog");return t.set({tooltip:!0}),t.bind("isOn").to(i,"id",(e=>"findAndReplace"===e)),t.on("execute",(()=>{t.isOn?i.hide():this._showDialog()})),t}_createDialogButtonForMenuBar(){const e=this._createButton(uw),t=this.editor.plugins.get("Dialog");return e.on("execute",(()=>{"findAndReplace"!==t.id?this._showDialog():t.hide()})),e}_createButton(e){const t=this.editor,i=t.commands.get("find"),n=new e(t.locale),s=t.locale.t;return n.bind("isEnabled").to(i),n.set({icon:vC,label:s("Find and replace"),keystroke:"CTRL+F"}),n}_showDialog(){const e=this.editor,t=e.plugins.get("Dialog"),i=e.locale.t;this.formView||(this.formView=this._createFormView()),t.show({id:"findAndReplace",title:i("Find and replace"),content:this.formView,position:qp.EDITOR_TOP_SIDE,onShow:()=>{this._setupFormView()},onHide:()=>{this.fire("searchReseted")}})}_createFormView(){const e=this.editor,t=new(Pg(wC))(e.locale),i=e.commands,n=this.editor.plugins.get("FindAndReplaceEditing").state;t.bind("highlightOffset").to(n,"highlightedOffset"),t.listenTo(n.results,"change",(()=>{t.matchCount=n.results.length}));const s=i.get("findNext"),o=i.get("findPrevious"),r=i.get("replace"),a=i.get("replaceAll");return t.bind("_areCommandsEnabled").to(s,"isEnabled",o,"isEnabled",r,"isEnabled",a,"isEnabled",((e,t,i,n)=>({findNext:e,findPrevious:t,replace:i,replaceAll:n}))),t.delegate("findNext","findPrevious","replace","replaceAll").to(this),t.on("change:isDirty",((e,t,i)=>{i&&this.fire("searchReseted")})),t}_setupFormView(){this.formView.disableCssTransitions(),this.formView.reset(),this.formView._findInputView.fieldView.select(),this.formView.enableCssTransitions()}constructor(e){super(e),e.config.define("findAndReplace.uiType","dialog"),this.formView=null}}class yC extends Da{execute(e,{matchCase:t,wholeWords:i}={}){const{editor:n}=this,{model:s}=n,o=n.plugins.get("FindAndReplaceUtils");let r;"string"==typeof e?(r=o.findByTextCallback(e,{matchCase:t,wholeWords:i}),this._state.searchText=e):r=e;const a=s.document.getRootNames().reduce(((e,t)=>o.updateFindResultFromRange(s.createRangeIn(s.document.getRoot(t)),s,r,e)),null);return this._state.clear(s),this._state.results.addMany(a),this._state.highlightedResult=a.get(0),"string"==typeof e&&(this._state.searchText=e),r&&(this._state.lastSearchCallback=r),this._state.matchCase=!!t,this._state.matchWholeWords=!!i,{results:a,findCallback:r}}constructor(e,t){super(e),this.isEnabled=!0,this.affectsData=!1,this._state=t}}class kC extends Da{_replace(e,t){const{model:i}=this.editor,n=t.marker.getRange();i.canEditAt(n)&&i.change((s=>{if("$graveyard"===n.root.rootName)return void this._state.results.remove(t);let o={};for(const e of n.getItems())if(e.is("$text")||e.is("$textProxy")){o=e.getAttributes();break}i.insertContent(s.createText(e,o),n),this._state.results.has(t)&&this._state.results.remove(t)}))}constructor(e,t){super(e),this.isEnabled=!0,this._state=t,this._isEnabledBasedOnSelection=!1}}class CC extends kC{execute(e,t){this._replace(e,t)}}class xC extends kC{execute(e,t){const{editor:i}=this,{model:n}=i,s=i.plugins.get("FindAndReplaceUtils"),o=t instanceof va?t:n.document.getRootNames().reduce(((e,i)=>s.updateFindResultFromRange(n.createRangeIn(n.document.getRoot(i)),n,s.findByTextCallback(t,this._state),e)),null);o.length&&n.change((()=>{[...o].forEach((t=>{this._replace(e,t)}))}))}}class AC extends Da{refresh(){this.isEnabled=this._state.results.length>1}execute(){const e=this._state.results,t=e.getIndex(this._state.highlightedResult),i=t+1>=e.length?0:t+1;this._state.highlightedResult=this._state.results.get(i)}constructor(e,t){super(e),this.affectsData=!1,this._state=t,this.isEnabled=!1,this.listenTo(this._state.results,"change",(()=>{this.isEnabled=this._state.results.length>1}))}}class EC extends AC{execute(){const e=this._state.results.getIndex(this._state.highlightedResult),t=e-1<0?this._state.results.length-1:e-1;this._state.highlightedResult=this._state.results.get(t)}}class TC extends(Yo()){clear(e){this.searchText="",e.change((t=>{if(this.highlightedResult){const i=this.highlightedResult.marker.name.split(":")[1],n=e.markers.get(`findResultHighlighted:${i}`);n&&t.removeMarker(n)}[...this.results].forEach((({marker:e})=>{t.removeMarker(e)}))})),this.results.clear()}refreshHighlightOffset(){const{highlightedResult:e,results:t}=this,i={before:-1,same:0,after:1,different:1};this.highlightedOffset=e?Array.from(t).sort(((e,t)=>i[e.marker.getStart().compareWith(t.marker.getStart())])).indexOf(e)+1:0}constructor(e){super(),this.set("results",new va),this.set("highlightedResult",null),this.set("highlightedOffset",0),this.set("searchText",""),this.set("replaceText",""),this.set("lastSearchCallback",null),this.set("matchCase",!1),this.set("matchWholeWords",!1),this.results.on("change",((t,{removed:i,index:n})=>{if(Array.from(i).length){let t=!1;if(e.change((n=>{for(const s of i)this.highlightedResult===s&&(t=!0),e.markers.has(s.marker.name)&&n.removeMarker(s.marker)})),t){const e=n>=this.results.length?0:n;this.highlightedResult=this.results.get(e)}}})),this.on("change:highlightedResult",(()=>{this.refreshHighlightOffset()}))}}class SC extends Na{static get pluginName(){return"FindAndReplaceUtils"}updateFindResultFromRange(e,t,i,n){const s=n||new va;return t.change((n=>{[...e].forEach((({type:e,item:o})=>{if("elementStart"===e&&t.schema.checkChild(o,"$text")){const e=i({item:o,text:this.rangeToText(t.createRangeIn(o))});if(!e)return;e.forEach((e=>{const t=`findResult:${u()}`,i=n.addMarker(t,{usingOperation:!1,affectsData:!1,range:n.createRange(n.createPositionAt(o,e.start),n.createPositionAt(o,e.end))}),r=function(e,t){const i=e.find((({marker:e})=>t.getStart().isBefore(e.getStart())));return i?e.getIndex(i):e.length}(s,i);(e=>s.find((t=>{const{marker:i}=t,n=i.getRange(),s=e.getRange();return n.isEqual(s)})))(i)||s.add({id:t,label:e.label,marker:i},r)}))}}))})),s}rangeToText(e){return Array.from(e.getItems()).reduce(((e,t)=>t.is("$text")||t.is("$textProxy")?e+t.data:`${e}\n`),"")}findByTextCallback(e,t){let i="gu";t.matchCase||(i+="i");let n=`(${Oo(e)})`;if(t.wholeWords){const t="[^a-zA-ZÀ-ɏḀ-ỿ]";new RegExp("^"+t).test(e)||(n=`(^|${t}|_)${n}`),new RegExp(t+"$").test(e)||(n=`${n}(?=_|${t}|$)`)}const s=new RegExp(n,i);return function({text:e}){return[...e.matchAll(s)].map(IC)}}}function IC(e){const t=e.length-1;let i=e.index;return 3===e.length&&(i+=e[1].length),{label:e[t],start:i,end:i+e[t].length}}class PC extends Na{static get requires(){return[SC]}static get pluginName(){return"FindAndReplaceEditing"}init(){this.state=new TC(this.editor.model),this.set("_isSearchActive",!1),this._defineConverters(),this._defineCommands(),this.listenTo(this.state,"change:highlightedResult",((e,t,i,n)=>{const{model:s}=this.editor;s.change((e=>{if(n){const t=n.marker.name.split(":")[1],i=s.markers.get(`findResultHighlighted:${t}`);i&&e.removeMarker(i)}if(i){const t=i.marker.name.split(":")[1];e.addMarker(`findResultHighlighted:${t}`,{usingOperation:!1,affectsData:!1,range:i.marker.getRange()})}}))}));const e=ko(((e,t,i)=>{if(i){const e=this.editor.editing.view.domConverter,t=this.editor.editing.mapper.toViewRange(i.marker.getRange());qr({target:e.viewRangeToDom(t),viewportOffset:40})}}).bind(this),32);this.listenTo(this.state,"change:highlightedResult",e,{priority:"low"}),this.listenTo(this.editor,"destroy",e.cancel),this.on("change:_isSearchActive",((e,t,i)=>{i?this.listenTo(this.editor.model.document,"change:data",this._onDocumentChange):this.stopListening(this.editor.model.document,"change:data",this._onDocumentChange)}))}find(e,t){return this._isSearchActive=!0,this.editor.execute("find",e,t),this.state.results}stop(){this.state.clear(this.editor.model),this._isSearchActive=!1}_defineCommands(){this.editor.commands.add("find",new yC(this.editor,this.state)),this.editor.commands.add("findNext",new AC(this.editor,this.state)),this.editor.commands.add("findPrevious",new EC(this.editor,this.state)),this.editor.commands.add("replace",new CC(this.editor,this.state)),this.editor.commands.add("replaceAll",new xC(this.editor,this.state))}_defineConverters(){const{editor:e}=this;e.conversion.for("editingDowncast").markerToHighlight({model:"findResult",view:({markerName:e})=>{const[,t]=e.split(":");return{name:"span",classes:["ck-find-result"],attributes:{"data-find-result":t}}}}),e.conversion.for("editingDowncast").markerToHighlight({model:"findResultHighlighted",view:({markerName:e})=>{const[,t]=e.split(":");return{name:"span",classes:["ck-find-result_selected"],attributes:{"data-find-result":t}}}})}constructor(...e){super(...e),this._onDocumentChange=()=>{const e=new Set,t=new Set,i=this.editor.model,{results:n}=this.state,s=i.document.differ.getChanges(),o=i.document.differ.getChangedMarkers();s.forEach((n=>{n.position&&("$text"===n.name||n.position.nodeAfter&&i.schema.isInline(n.position.nodeAfter)?(e.add(n.position.parent),[...i.markers.getMarkersAtPosition(n.position)].forEach((e=>{t.add(e.name)}))):"insert"===n.type&&n.position.nodeAfter&&e.add(n.position.nodeAfter))})),o.forEach((({name:e,data:{newRange:i}})=>{i&&"$graveyard"===i.start.root.rootName&&t.add(e)})),e.forEach((e=>{[...i.markers.getMarkersIntersectingRange(i.createRangeIn(e))].forEach((e=>t.add(e.name)))})),t.forEach((e=>{n.has(e)&&(n.get(e)===this.state.highlightedResult&&(this.state.highlightedResult=null),n.remove(e))}));const r=[],a=this.editor.plugins.get("FindAndReplaceUtils");e.forEach((e=>{const t=a.updateFindResultFromRange(i.createRangeOn(e),i,this.state.lastSearchCallback,n);r.push(...t)})),o.forEach((e=>{if(e.data.newRange){const t=a.updateFindResultFromRange(e.data.newRange,i,this.state.lastSearchCallback,n);r.push(...t)}})),!this.state.highlightedResult&&r.length?this.state.highlightedResult=r[0]:this.state.refreshHighlightOffset()}}}class VC extends Na{static get requires(){return[PC,_C]}static get pluginName(){return"FindAndReplace"}init(){const e=this.editor.plugins.get("FindAndReplaceUI"),t=this.editor.plugins.get("FindAndReplaceEditing"),i=t.state;e.on("findNext",((e,n)=>{n?(i.searchText=n.searchText,t.find(n.searchText,n)):this.editor.execute("findNext")})),e.on("findPrevious",((e,n)=>{n&&i.searchText!==n.searchText?t.find(n.searchText):this.editor.execute("findPrevious")})),e.on("replace",((e,n)=>{i.searchText!==n.searchText&&t.find(n.searchText);const s=i.highlightedResult;s&&this.editor.execute("replace",n.replaceText,s)})),e.on("replaceAll",((e,n)=>{i.searchText!==n.searchText&&t.find(n.searchText),this.editor.execute("replaceAll",n.replaceText,i.results)})),e.on("searchReseted",(()=>{i.clear(this.editor.model),t.stop()}))}}class RC extends Da{refresh(){const e=this.editor.model,t=e.document;this.value=t.selection.getAttribute(this.attributeKey),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,this.attributeKey)}execute(e={}){const t=this.editor.model,i=t.document.selection,n=e.value,s=e.batch,o=e=>{if(i.isCollapsed)n?e.setSelectionAttribute(this.attributeKey,n):e.removeSelectionAttribute(this.attributeKey);else{const s=t.schema.getValidRanges(i.getRanges(),this.attributeKey);for(const t of s)n?e.setAttribute(this.attributeKey,n,t):e.removeAttribute(this.attributeKey,t)}};s?t.enqueueChange(s,(e=>{o(e)})):t.change((e=>{o(e)}))}constructor(e,t){super(e),this.attributeKey=t}}const BC="fontSize",OC="fontFamily",MC="fontColor",LC="fontBackgroundColor";function NC(e,t){const i={model:{key:e,values:[]},view:{},upcastAlso:{}};for(const e of t)i.model.values.push(e.model),i.view[e.model]=e.view,e.upcastAlso&&(i.upcastAlso[e.model]=e.upcastAlso);return i}function FC(e){return t=>t.getStyle(e).replace(/\s/g,"")}function DC(e){return(t,{writer:i})=>i.createAttributeElement("span",{style:`${e}:${t}`},{priority:7})}class zC extends RC{constructor(e){super(e,OC)}}function HC(e){return e.map($C).filter((e=>void 0!==e))}function $C(e){return"object"==typeof e?e:"default"===e?{title:"Default",model:void 0}:"string"==typeof e?function(e){const t=e.replace(/"|'/g,"").split(","),i=t[0],n=t.map(UC).join(", ");return{title:i,model:n,view:{name:"span",styles:{"font-family":n},priority:7}}}(e):void 0}function UC(e){return(e=e.trim()).indexOf(" ")>0&&(e=`'${e}'`),e}class WC extends Na{static get pluginName(){return"FontFamilyEditing"}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:OC}),e.model.schema.setAttributeProperties(OC,{isFormatting:!0,copyOnEnter:!0});const t=HC(e.config.get("fontFamily.options")).filter((e=>e.model)),i=NC(OC,t);e.config.get("fontFamily.supportAllValues")?(this._prepareAnyValueConverters(),this._prepareCompatibilityConverter()):e.conversion.attributeToElement(i),e.commands.add(OC,new zC(e))}_prepareAnyValueConverters(){const e=this.editor;e.conversion.for("downcast").attributeToElement({model:OC,view:(e,{writer:t})=>t.createAttributeElement("span",{style:"font-family:"+e},{priority:7})}),e.conversion.for("upcast").elementToAttribute({model:{key:OC,value:e=>e.getStyle("font-family")},view:{name:"span",styles:{"font-family":/.*/}}})}_prepareCompatibilityConverter(){this.editor.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{face:/.*/}},model:{key:OC,value:e=>e.getAttribute("face")}})}constructor(e){super(e),e.config.define(OC,{options:["default","Arial, Helvetica, sans-serif","Courier New, Courier, monospace","Georgia, serif","Lucida Sans Unicode, Lucida Grande, sans-serif","Tahoma, Geneva, sans-serif","Times New Roman, Times, serif","Trebuchet MS, Helvetica, sans-serif","Verdana, Geneva, sans-serif"],supportAllValues:!1})}}var jC='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M11.03 3h6.149a.75.75 0 1 1 0 1.5h-5.514L11.03 3zm1.27 3h4.879a.75.75 0 1 1 0 1.5h-4.244L12.3 6zm1.27 3h3.609a.75.75 0 1 1 0 1.5h-2.973L13.57 9zm-2.754 2.5L8.038 4.785 5.261 11.5h5.555zm.62 1.5H4.641l-1.666 4.028H1.312l5.789-14h1.875l5.789 14h-1.663L11.436 13z"/></svg>';class qC extends Na{static get pluginName(){return"FontFamilyUI"}init(){const e=this.editor,t=e.t,i=this._getLocalizedOptions(),n=e.commands.get(OC),s=t("Font Family"),o=function(e,t){const i=new va;for(const n of e){const e={type:"button",model:new Ab({commandName:OC,commandParam:n.model,label:n.title,role:"menuitemradio",withText:!0})};e.model.bind("isOn").to(t,"value",(e=>e===n.model||!(!e||!n.model)&&e.split(",")[0].replace(/'/g,"").toLowerCase()===n.model.toLowerCase())),n.view&&"string"!=typeof n.view&&n.view.styles&&e.model.set("labelStyle",`font-family: ${n.view.styles["font-family"]}`),i.add(e)}return i}(i,n);e.ui.componentFactory.add(OC,(t=>{const i=Wf(t);return Gf(i,o,{role:"menu",ariaLabel:s}),i.buttonView.set({label:s,icon:jC,tooltip:!0}),i.extendTemplate({attributes:{class:"ck-font-family-dropdown"}}),i.bind("isEnabled").to(n),this.listenTo(i,"execute",(t=>{e.execute(t.source.commandName,{value:t.source.commandParam}),e.editing.view.focus()})),i})),e.ui.componentFactory.add(`menuBar:${OC}`,(t=>{const i=new dw(t);i.buttonView.set({label:s,icon:jC}),i.bind("isEnabled").to(n);const r=new hw(t);for(const n of o){const s=new qb(t,i),o=new uw(t);o.bind(...Object.keys(n.model)).to(n.model),o.bind("ariaChecked").to(o,"isOn"),o.delegate("execute").to(i),o.on("execute",(()=>{e.execute(n.model.commandName,{value:n.model.commandParam}),e.editing.view.focus()})),s.children.add(o),r.items.add(s)}return i.panelView.children.add(r),i}))}_getLocalizedOptions(){const e=this.editor,t=e.t;return HC(e.config.get(OC).options).map((e=>("Default"===e.title&&(e.title=t("Default")),e)))}}class GC extends Na{static get requires(){return[WC,qC]}static get pluginName(){return"FontFamily"}}class KC extends RC{constructor(e){super(e,BC)}}function ZC(e){return e.map((e=>function(e){"number"==typeof e&&(e=String(e));if("object"==typeof e&&(t=e,t.title&&t.model&&t.view))return QC(e);var t;const i=function(e){return"string"==typeof e?JC[e]:JC[e.model]}(e);if(i)return QC(i);if("default"===e)return{model:void 0,title:"Default"};if(function(e){let t;if("object"==typeof e){if(!e.model)throw new p("font-size-invalid-definition",null,e);t=parseFloat(e.model)}else t=parseFloat(e);return isNaN(t)}(e))return;return function(e){"string"==typeof e&&(e={title:e,model:`${parseFloat(e)}px`});return e.view={name:"span",styles:{"font-size":e.model}},QC(e)}(e)}(e))).filter((e=>void 0!==e))}const JC={get tiny(){return{title:"Tiny",model:"tiny",view:{name:"span",classes:"text-tiny",priority:7}}},get small(){return{title:"Small",model:"small",view:{name:"span",classes:"text-small",priority:7}}},get big(){return{title:"Big",model:"big",view:{name:"span",classes:"text-big",priority:7}}},get huge(){return{title:"Huge",model:"huge",view:{name:"span",classes:"text-huge",priority:7}}}};function QC(e){return e.view&&"string"!=typeof e.view&&!e.view.priority&&(e.view.priority=7),e}const YC=["x-small","x-small","small","medium","large","x-large","xx-large","xxx-large"];class XC extends Na{static get pluginName(){return"FontSizeEditing"}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:BC}),e.model.schema.setAttributeProperties(BC,{isFormatting:!0,copyOnEnter:!0});const t=e.config.get("fontSize.supportAllValues"),i=ZC(this.editor.config.get("fontSize.options")).filter((e=>e.model)),n=NC(BC,i);t?(this._prepareAnyValueConverters(n),this._prepareCompatibilityConverter()):e.conversion.attributeToElement(n),e.commands.add(BC,new KC(e))}_prepareAnyValueConverters(e){const t=this.editor,i=e.model.values.filter((e=>!Xu(String(e))&&!tm(String(e))));if(i.length)throw new p("font-size-invalid-use-of-named-presets",null,{presets:i});t.conversion.for("downcast").attributeToElement({model:BC,view:(e,{writer:t})=>{if(e)return t.createAttributeElement("span",{style:"font-size:"+e},{priority:7})}}),t.conversion.for("upcast").elementToAttribute({model:{key:BC,value:e=>e.getStyle("font-size")},view:{name:"span",styles:{"font-size":/.*/}}})}_prepareCompatibilityConverter(){this.editor.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{size:/^[+-]?\d{1,3}$/}},model:{key:BC,value:e=>{const t=e.getAttribute("size"),i="-"===t[0]||"+"===t[0];let n=parseInt(t,10);i&&(n=3+n);const s=YC.length-1,o=Math.min(Math.max(n,0),s);return YC[o]}}})}constructor(e){super(e),e.config.define(BC,{options:["tiny","small","default","big","huge"],supportAllValues:!1})}}var ex='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M9.816 11.5 7.038 4.785 4.261 11.5h5.555zm.62 1.5H3.641l-1.666 4.028H.312l5.789-14h1.875l5.789 14h-1.663L10.436 13zm7.55 2.279.779-.779.707.707-2.265 2.265-2.193-2.265.707-.707.765.765V4.825c0-.042 0-.083.002-.123l-.77.77-.707-.707L17.207 2.5l2.265 2.265-.707.707-.782-.782c.002.043.003.089.003.135v10.454z"/></svg>';class tx extends Na{static get pluginName(){return"FontSizeUI"}init(){const e=this.editor,t=e.t,i=this._getLocalizedOptions(),n=e.commands.get(BC),s=t("Font Size"),o=function(e,t){const i=new va;for(const n of e){const e={type:"button",model:new Ab({commandName:BC,commandParam:n.model,label:n.title,class:"ck-fontsize-option",role:"menuitemradio",withText:!0})};n.view&&"string"!=typeof n.view&&(n.view.styles&&e.model.set("labelStyle",`font-size:${n.view.styles["font-size"]}`),n.view.classes&&e.model.set("class",`${e.model.class} ${n.view.classes}`)),e.model.bind("isOn").to(t,"value",(e=>e===n.model)),i.add(e)}return i}(i,n);e.ui.componentFactory.add(BC,(t=>{const i=Wf(t);return Gf(i,o,{role:"menu",ariaLabel:s}),i.buttonView.set({label:s,icon:ex,tooltip:!0}),i.extendTemplate({attributes:{class:["ck-font-size-dropdown"]}}),i.bind("isEnabled").to(n),this.listenTo(i,"execute",(t=>{e.execute(t.source.commandName,{value:t.source.commandParam}),e.editing.view.focus()})),i})),e.ui.componentFactory.add(`menuBar:${BC}`,(t=>{const i=new dw(t);i.buttonView.set({label:s,icon:ex}),i.bind("isEnabled").to(n);const r=new hw(t);for(const n of o){const s=new qb(t,i),o=new uw(t);o.bind(...Object.keys(n.model)).to(n.model),o.bind("ariaChecked").to(o,"isOn"),o.delegate("execute").to(i),o.on("execute",(()=>{e.execute(n.model.commandName,{value:n.model.commandParam}),e.editing.view.focus()})),s.children.add(o),r.items.add(s)}return i.panelView.children.add(r),i}))}_getLocalizedOptions(){const e=this.editor,t=e.t,i={Default:t("Default"),Tiny:t("Tiny"),Small:t("Small"),Big:t("Big"),Huge:t("Huge")};return ZC(e.config.get(BC).options).map((e=>{const t=i[e.title];return t&&t!=e.title&&(e=Object.assign({},e,{title:t})),e}))}}class ix extends Na{static get requires(){return[XC,tx]}static get pluginName(){return"FontSize"}normalizeSizeOptions(e){return ZC(e)}}class nx extends RC{constructor(e){super(e,MC)}}class sx extends Na{static get pluginName(){return"FontColorEditing"}constructor(e){super(e),e.config.define(MC,{colors:[{color:"hsl(0, 0%, 0%)",label:"Black"},{color:"hsl(0, 0%, 30%)",label:"Dim grey"},{color:"hsl(0, 0%, 60%)",label:"Grey"},{color:"hsl(0, 0%, 90%)",label:"Light grey"},{color:"hsl(0, 0%, 100%)",label:"White",hasBorder:!0},{color:"hsl(0, 75%, 60%)",label:"Red"},{color:"hsl(30, 75%, 60%)",label:"Orange"},{color:"hsl(60, 75%, 60%)",label:"Yellow"},{color:"hsl(90, 75%, 60%)",label:"Light green"},{color:"hsl(120, 75%, 60%)",label:"Green"},{color:"hsl(150, 75%, 60%)",label:"Aquamarine"},{color:"hsl(180, 75%, 60%)",label:"Turquoise"},{color:"hsl(210, 75%, 60%)",label:"Light blue"},{color:"hsl(240, 75%, 60%)",label:"Blue"},{color:"hsl(270, 75%, 60%)",label:"Purple"}],columns:5}),e.conversion.for("upcast").elementToAttribute({view:{name:"span",styles:{color:/[\s\S]+/}},model:{key:MC,value:FC("color")}}),e.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{color:/^#?\w+$/}},model:{key:MC,value:e=>e.getAttribute("color")}}),e.conversion.for("downcast").attributeToElement({model:MC,view:DC("color")}),e.commands.add(MC,new nx(e)),e.model.schema.extend("$text",{allowAttributes:MC}),e.model.schema.setAttributeProperties(MC,{isFormatting:!0,copyOnEnter:!0})}}class ox extends Na{init(){const e=this.editor,t=e.locale,i=t.t,n=e.commands.get(this.commandName),s=e.config.get(this.componentName),o=Gg(t,Kg(s.colors)),r=s.documentColors,a=!1!==s.colorPicker;e.ui.componentFactory.add(this.componentName,(t=>{const l=Wf(t);let c=!1;const d=function({dropdownView:e,colors:t,columns:i,removeButtonLabel:n,colorPickerLabel:s,documentColorsLabel:o,documentColorsCount:r,colorPickerViewConfig:a}){const l=e.locale,c=new zp(l,{colors:t,columns:i,removeButtonLabel:n,colorPickerLabel:s,documentColorsLabel:o,documentColorsCount:r,colorPickerViewConfig:a});return e.colorSelectorView=c,e.panelView.children.add(c),c}({dropdownView:l,colors:o.map((e=>({label:e.label,color:e.model,options:{hasBorder:e.hasBorder}}))),columns:this.columns,removeButtonLabel:i("Remove color"),colorPickerLabel:i("Color picker"),documentColorsLabel:0!==r?i("Document colors"):"",documentColorsCount:void 0===r?this.columns:r,colorPickerViewConfig:!!a&&(s.colorPicker||{})});return d.bind("selectedColor").to(n,"value"),l.buttonView.set({label:this.dropdownLabel,icon:this.icon,tooltip:!0}),l.extendTemplate({attributes:{class:"ck-color-ui-dropdown"}}),l.bind("isEnabled").to(n),d.on("execute",((t,i)=>{l.isOpen&&e.execute(this.commandName,{value:i.value,batch:this._undoStepBatch}),"colorPicker"!==i.source&&e.editing.view.focus(),"colorPickerSaveButton"===i.source&&(l.isOpen=!1)})),d.on("colorPicker:show",(()=>{this._undoStepBatch=e.model.createBatch()})),d.on("colorPicker:cancel",(()=>{this._undoStepBatch.operations.length&&(l.isOpen=!1,e.execute("undo",this._undoStepBatch)),e.editing.view.focus()})),l.on("change:isOpen",((t,i,n)=>{c||(c=!0,l.colorSelectorView.appendUI()),n&&(0!==r&&d.updateDocumentColors(e.model,this.componentName),d.updateSelectedColors(),d.showColorGridsFragment())})),Zf(l,(()=>l.colorSelectorView.colorGridsFragmentView.staticColorsGrid.items.find((e=>e.isOn)))),l})),e.ui.componentFactory.add(`menuBar:${this.componentName}`,(t=>{const s=new dw(t);s.buttonView.set({label:this.dropdownLabel,icon:this.icon}),s.bind("isEnabled").to(n);let a=!1;const l=new zp(t,{colors:o.map((e=>({label:e.label,color:e.model,options:{hasBorder:e.hasBorder}}))),columns:this.columns,removeButtonLabel:i("Remove color"),colorPickerLabel:i("Color picker"),documentColorsLabel:0!==r?i("Document colors"):"",documentColorsCount:void 0===r?this.columns:r,colorPickerViewConfig:!1});return l.bind("selectedColor").to(n,"value"),l.delegate("execute").to(s),l.on("execute",((t,i)=>{e.execute(this.commandName,{value:i.value,batch:this._undoStepBatch}),e.editing.view.focus()})),s.on("change:isOpen",((t,i,n)=>{a||(a=!0,l.appendUI()),n&&(0!==r&&l.updateDocumentColors(e.model,this.componentName),l.updateSelectedColors(),l.showColorGridsFragment())})),s.panelView.children.add(l),s}))}constructor(e,{commandName:t,componentName:i,icon:n,dropdownLabel:s}){super(e),this.commandName=t,this.componentName=i,this.icon=n,this.dropdownLabel=s,this.columns=e.config.get(`${this.componentName}.columns`)}}class rx extends ox{static get pluginName(){return"FontColorUI"}constructor(e){const t=e.locale.t;super(e,{commandName:MC,componentName:MC,icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M12.4 10.3 10 4.5l-2.4 5.8h4.8zm.5 1.2H7.1L5.7 15H4.2l5-12h1.6l5 12h-1.5L13 11.5zm3.1 7H4a1 1 0 0 1 0-2h12a1 1 0 0 1 0 2z"/></svg>',dropdownLabel:t("Font Color")})}}class ax extends Na{static get requires(){return[sx,rx]}static get pluginName(){return"FontColor"}}class lx extends RC{constructor(e){super(e,LC)}}class cx extends Na{static get pluginName(){return"FontBackgroundColorEditing"}constructor(e){super(e),e.config.define(LC,{colors:[{color:"hsl(0, 0%, 0%)",label:"Black"},{color:"hsl(0, 0%, 30%)",label:"Dim grey"},{color:"hsl(0, 0%, 60%)",label:"Grey"},{color:"hsl(0, 0%, 90%)",label:"Light grey"},{color:"hsl(0, 0%, 100%)",label:"White",hasBorder:!0},{color:"hsl(0, 75%, 60%)",label:"Red"},{color:"hsl(30, 75%, 60%)",label:"Orange"},{color:"hsl(60, 75%, 60%)",label:"Yellow"},{color:"hsl(90, 75%, 60%)",label:"Light green"},{color:"hsl(120, 75%, 60%)",label:"Green"},{color:"hsl(150, 75%, 60%)",label:"Aquamarine"},{color:"hsl(180, 75%, 60%)",label:"Turquoise"},{color:"hsl(210, 75%, 60%)",label:"Light blue"},{color:"hsl(240, 75%, 60%)",label:"Blue"},{color:"hsl(270, 75%, 60%)",label:"Purple"}],columns:5}),e.data.addStyleProcessorRules(fm),e.conversion.for("upcast").elementToAttribute({view:{name:"span",styles:{"background-color":/[\s\S]+/}},model:{key:LC,value:FC("background-color")}}),e.conversion.for("downcast").attributeToElement({model:LC,view:DC("background-color")}),e.commands.add(LC,new lx(e)),e.model.schema.extend("$text",{allowAttributes:LC}),e.model.schema.setAttributeProperties(LC,{isFormatting:!0,copyOnEnter:!0})}}class dx extends ox{static get pluginName(){return"FontBackgroundColorUI"}constructor(e){const t=e.locale.t;super(e,{commandName:LC,componentName:LC,icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M4 2h12a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2zm8.38 9.262H7.62L10 5.506l2.38 5.756zm.532 1.285L14.34 16h1.426L10.804 4H9.196L4.234 16H5.66l1.428-3.453h5.824z"/></svg>',dropdownLabel:t("Font Background Color")})}}class hx extends Na{static get requires(){return[cx,dx]}static get pluginName(){return"FontBackgroundColor"}}class ux extends Na{static get requires(){return[GC,ix,ax,hx]}static get pluginName(){return"Font"}}class mx extends Da{refresh(){const e=this.editor.model,t=_a(e.document.selection.getSelectedBlocks());this.value=!!t&&t.is("element","paragraph"),this.isEnabled=!!t&&gx(t,e.schema)}execute(e={}){const t=this.editor.model,i=t.document,n=e.selection||i.selection;t.canEditAt(n)&&t.change((e=>{const i=n.getSelectedBlocks();for(const n of i)!n.is("element","paragraph")&&gx(n,t.schema)&&e.rename(n,"paragraph")}))}constructor(e){super(e),this._isEnabledBasedOnSelection=!1}}function gx(e,t){return t.checkChild(e.parent,"paragraph")&&!t.isObject(e)}class fx extends Da{execute(e){const t=this.editor.model,i=e.attributes;let n=e.position;t.canEditAt(n)&&t.change((e=>{if(n=this._findPositionToInsertParagraph(n,e),!n)return;const s=e.createElement("paragraph");i&&t.schema.setAllowedAttributes(s,i,e),t.insertContent(s,n),e.setSelection(s,"in")}))}_findPositionToInsertParagraph(e,t){const i=this.editor.model;if(i.schema.checkChild(e,"paragraph"))return e;const n=i.schema.findAllowedParent(e,"paragraph");if(!n)return null;const s=e.parent,o=i.schema.checkChild(s,"$text");return s.isEmpty||o&&e.isAtEnd?i.createPositionAfter(s):!s.isEmpty&&o&&e.isAtStart?i.createPositionBefore(s):t.split(e,n).position}constructor(e){super(e),this._isEnabledBasedOnSelection=!1}}class px extends Na{static get pluginName(){return"Paragraph"}init(){const e=this.editor,t=e.model;e.commands.add("paragraph",new mx(e)),e.commands.add("insertParagraph",new fx(e)),t.schema.register("paragraph",{inheritAllFrom:"$block"}),e.conversion.elementToElement({model:"paragraph",view:"p"}),e.conversion.for("upcast").elementToElement({model:(e,{writer:t})=>px.paragraphLikeElements.has(e.name)?e.isEmpty?null:t.createElement("paragraph"):null,view:/.+/,converterPriority:"low"})}}px.paragraphLikeElements=new Set(["blockquote","dd","div","dt","h1","h2","h3","h4","h5","h6","li","p","td","th"]);const bx=Dm.paragraph;class wx extends Na{static get requires(){return[px]}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add("paragraph",(i=>{const n=new Hg(i),s=e.commands.get("paragraph");return n.label=t("Paragraph"),n.icon=bx,n.tooltip=!0,n.isToggleable=!0,n.bind("isEnabled").to(s),n.bind("isOn").to(s,"value"),n.on("execute",(()=>{e.execute("paragraph")})),n}))}}class vx extends Da{refresh(){const e=_a(this.editor.model.document.selection.getSelectedBlocks());this.value=!!e&&this.modelElements.includes(e.name)&&e.name,this.isEnabled=!!e&&this.modelElements.some((t=>_x(e,t,this.editor.model.schema)))}execute(e){const t=this.editor.model,i=t.document,n=e.value;t.change((e=>{const s=Array.from(i.selection.getSelectedBlocks()).filter((e=>_x(e,n,t.schema)));for(const t of s)t.is("element",n)||e.rename(t,n)}))}constructor(e,t){super(e),this.modelElements=t}}function _x(e,t,i){return i.checkChild(e.parent,t)&&!i.isObject(e)}const yx="paragraph";class kx extends Na{static get pluginName(){return"HeadingEditing"}static get requires(){return[px]}init(){const e=this.editor,t=e.config.get("heading.options"),i=[];for(const n of t)"paragraph"!==n.model&&(e.model.schema.register(n.model,{inheritAllFrom:"$block"}),e.conversion.elementToElement(n),i.push(n.model));this._addDefaultH1Conversion(e),e.commands.add("heading",new vx(e,i))}afterInit(){const e=this.editor,t=e.commands.get("enter"),i=e.config.get("heading.options");t&&this.listenTo(t,"afterExecute",((t,n)=>{const s=e.model.document.selection.getFirstPosition().parent;i.some((e=>s.is("element",e.model)))&&!s.is("element",yx)&&0===s.childCount&&n.writer.rename(s,yx)}))}_addDefaultH1Conversion(e){e.conversion.for("upcast").elementToElement({model:"heading1",view:"h1",converterPriority:m.low+1})}constructor(e){super(e),e.config.define("heading",{options:[{model:"paragraph",title:"Paragraph",class:"ck-heading_paragraph"},{model:"heading1",view:"h2",title:"Heading 1",class:"ck-heading_heading1"},{model:"heading2",view:"h3",title:"Heading 2",class:"ck-heading_heading2"},{model:"heading3",view:"h4",title:"Heading 3",class:"ck-heading_heading3"}]})}}function Cx(e){const t=e.t,i={Paragraph:t("Paragraph"),"Heading 1":t("Heading 1"),"Heading 2":t("Heading 2"),"Heading 3":t("Heading 3"),"Heading 4":t("Heading 4"),"Heading 5":t("Heading 5"),"Heading 6":t("Heading 6")};return e.config.get("heading.options").map((e=>{const t=i[e.title];return t&&t!=e.title&&(e.title=t),e}))}class xx extends Na{static get pluginName(){return"HeadingUI"}init(){const e=this.editor,t=e.t,i=Cx(e),n=t("Choose heading"),s=t("Heading");e.ui.componentFactory.add("heading",(t=>{const o={},r=new va,a=e.commands.get("heading"),l=e.commands.get("paragraph"),c=[a];for(const e of i){const t={type:"button",model:new Ab({label:e.title,class:e.class,role:"menuitemradio",withText:!0})};"paragraph"===e.model?(t.model.bind("isOn").to(l,"value"),t.model.set("commandName","paragraph"),c.push(l)):(t.model.bind("isOn").to(a,"value",(t=>t===e.model)),t.model.set({commandName:"heading",commandValue:e.model})),r.add(t),o[e.model]=e.title}const d=Wf(t);return Gf(d,r,{ariaLabel:s,role:"menu"}),d.buttonView.set({ariaLabel:s,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:s}),d.extendTemplate({attributes:{class:["ck-heading-dropdown"]}}),d.bind("isEnabled").toMany(c,"isEnabled",((...e)=>e.some((e=>e)))),d.buttonView.bind("label").to(a,"value",l,"value",((e,t)=>{const i=t?"paragraph":e;return"boolean"==typeof i?n:o[i]?o[i]:n})),d.buttonView.bind("ariaLabel").to(a,"value",l,"value",((e,t)=>{const i=t?"paragraph":e;return"boolean"==typeof i?s:o[i]?`${o[i]}, ${s}`:s})),this.listenTo(d,"execute",(t=>{const{commandName:i,commandValue:n}=t.source;e.execute(i,n?{value:n}:void 0),e.editing.view.focus()})),d})),e.ui.componentFactory.add("menuBar:heading",(n=>{const s=new dw(n),o=e.commands.get("heading"),r=e.commands.get("paragraph"),a=[o],l=new hw(n);s.set({class:"ck-heading-dropdown"}),l.set({ariaLabel:t("Heading"),role:"menu"}),s.buttonView.set({label:t("Heading")}),s.panelView.children.add(l);for(const t of i){const i=new qb(n,s),c=new uw(n);i.children.add(c),l.items.add(i),c.set({label:t.title,role:"menuitemradio",class:t.class}),c.bind("ariaChecked").to(c,"isOn"),c.delegate("execute").to(s),c.on("execute",(()=>{const i="paragraph"===t.model?"paragraph":"heading";e.execute(i,{value:t.model}),e.editing.view.focus()})),"paragraph"===t.model?(c.bind("isOn").to(r,"value"),a.push(r)):c.bind("isOn").to(o,"value",(e=>e===t.model))}return s.bind("isEnabled").toMany(a,"isEnabled",((...e)=>e.some((e=>e)))),s}))}}class Ax extends Na{static get requires(){return[kx,xx]}static get pluginName(){return"Heading"}}const Ex={heading1:Dm.heading1,heading2:Dm.heading2,heading3:Dm.heading3,heading4:Dm.heading4,heading5:Dm.heading5,heading6:Dm.heading6};class Tx extends Na{init(){Cx(this.editor).filter((e=>"paragraph"!==e.model)).map((e=>this._createButton(e)))}_createButton(e){const t=this.editor;t.ui.componentFactory.add(e.model,(i=>{const n=new Hg(i),s=t.commands.get("heading");return n.label=e.title,n.icon=e.icon||Ex[e.model],n.tooltip=!0,n.isToggleable=!0,n.bind("isEnabled").to(s),n.bind("isOn").to(s,"value",(t=>t==e.model)),n.on("execute",(()=>{t.execute("heading",{value:e.model}),t.editing.view.focus()})),n}))}}const Sx=new Set(["paragraph","heading1","heading2","heading3","heading4","heading5","heading6"]);class Ix extends Na{static get pluginName(){return"Title"}static get requires(){return["Paragraph"]}init(){const e=this.editor,t=e.model;t.schema.register("title",{isBlock:!0,allowIn:"$root"}),t.schema.register("title-content",{isBlock:!0,allowIn:"title",allowAttributes:["alignment"]}),t.schema.extend("$text",{allowIn:"title-content"}),t.schema.addAttributeCheck((e=>{if(e.endsWith("title-content $text"))return!1})),e.editing.mapper.on("modelToViewPosition",Vx(e.editing.view)),e.data.mapper.on("modelToViewPosition",Vx(e.editing.view)),e.conversion.for("downcast").elementToElement({model:"title-content",view:"h1"}),e.conversion.for("downcast").add((e=>e.on("insert:title",((e,t,i)=>{i.consumable.consume(t.item,e.name)})))),e.data.upcastDispatcher.on("element:h1",Px,{priority:"high"}),e.data.upcastDispatcher.on("element:h2",Px,{priority:"high"}),e.data.upcastDispatcher.on("element:h3",Px,{priority:"high"}),t.document.registerPostFixer((e=>this._fixTitleContent(e))),t.document.registerPostFixer((e=>this._fixTitleElement(e))),t.document.registerPostFixer((e=>this._fixBodyElement(e))),t.document.registerPostFixer((e=>this._fixExtraParagraph(e))),this._attachPlaceholders(),this._attachTabPressHandling()}getTitle(e={}){const t=e.rootName?e.rootName:void 0,i=this._getTitleElement(t).getChild(0);return this.editor.data.stringify(i,e)}getBody(e={}){const t=this.editor,i=t.data,n=t.model,s=e.rootName?e.rootName:void 0,o=t.model.document.getRoot(s),r=t.editing.view,a=new Wl(r.document),l=n.createRangeIn(o),c=a.createDocumentFragment(),d=n.createPositionAfter(o.getChild(0)),h=n.createRange(d,n.createPositionAt(o,"end")),u=new Map;for(const e of n.markers){const t=h.getIntersection(e.getRange());t&&u.set(e.name,t)}return i.mapper.clearBindings(),i.mapper.bindElements(o,c),i.downcastDispatcher.convert(l,u,a,e),a.remove(a.createRangeOn(c.getChild(0))),t.data.processor.toData(c)}_getTitleElement(e){const t=this.editor.model.document.getRoot(e);for(const e of t.getChildren())if(Rx(e))return e}_fixTitleContent(e){let t=!1;for(const i of this.editor.model.document.getRootNames()){const n=this._getTitleElement(i);if(!n||1===n.maxOffset)continue;const s=Array.from(n.getChildren());s.shift();for(const t of s)e.move(e.createRangeOn(t),n,"after"),e.rename(t,"paragraph");t=!0}return t}_fixTitleElement(e){let t=!1;const i=this.editor.model;for(const n of this.editor.model.document.getRoots()){const s=Array.from(n.getChildren()).filter(Rx),o=s[0],r=n.getChild(0);if(r.is("element","title"))s.length>1&&(Ox(s,e,i),t=!0);else if(o||Sx.has(r.name))Sx.has(r.name)?Bx(r,e,i):e.move(e.createRangeOn(o),n,0),Ox(s,e,i),t=!0;else{const i=e.createElement("title");e.insert(i,n),e.insertElement("title-content",i),t=!0}}return t}_fixBodyElement(e){let t=!1;for(const i of this.editor.model.document.getRootNames()){const n=this.editor.model.document.getRoot(i);if(n.childCount<2){const s=e.createElement("paragraph");e.insert(s,n,1),this._bodyPlaceholder.set(i,s),t=!0}}return t}_fixExtraParagraph(e){let t=!1;for(const i of this.editor.model.document.getRootNames()){const n=this.editor.model.document.getRoot(i),s=this._bodyPlaceholder.get(i);Lx(s,n)&&(this._bodyPlaceholder.delete(i),e.remove(s),t=!0)}return t}_attachPlaceholders(){const e=this.editor,t=e.t,i=e.editing.view,n=e.sourceElement,s=e.config.get("title.placeholder")||t("Type your title"),o=e.config.get("placeholder")||n&&"textarea"===n.tagName.toLowerCase()&&n.getAttribute("placeholder")||t("Type or paste your content here.");e.editing.downcastDispatcher.on("insert:title-content",((e,t,n)=>{const o=n.mapper.toViewElement(t.item);o.placeholder=s,Ga({view:i,element:o,keepOnFocus:!0})}));const r=new Map;i.document.registerPostFixer((e=>{let t=!1;for(const n of i.document.roots){if(n.isEmpty)continue;const i=n.getChild(1),s=r.get(n.rootName);i!==s&&(s&&(Ja(e,s),e.removeAttribute("data-placeholder",s)),e.setAttribute("data-placeholder",o,i),r.set(n.rootName,i),t=!0),t=Qa(i,!0)&&2===n.childCount&&"p"===i.name?!!Za(e,i)||t:!!Ja(e,i)||t}return t}))}_attachTabPressHandling(){const e=this.editor,t=e.model;e.keystrokes.set("TAB",((e,i)=>{t.change((e=>{const n=t.document.selection,s=Array.from(n.getSelectedBlocks());if(1===s.length&&s[0].is("element","title-content")){const t=n.getFirstPosition().root.getChild(1);e.setSelection(t,0),i()}}))})),e.keystrokes.set("SHIFT + TAB",((i,n)=>{t.change((i=>{const s=t.document.selection;if(!s.isCollapsed)return;const o=_a(s.getSelectedBlocks()),r=s.getFirstPosition(),a=e.model.document.getRoot(r.root.rootName),l=a.getChild(0);o===a.getChild(1)&&r.isAtStart&&(i.setSelection(l.getChild(0),0),n())}))}))}constructor(...e){super(...e),this._bodyPlaceholder=new Map}}function Px(e,t,i){const n=t.modelCursor,s=t.viewItem;if(!n.isAtStart||!n.parent.is("element","$root"))return;if(!i.consumable.consume(s,{name:!0}))return;const o=i.writer,r=o.createElement("title"),a=o.createElement("title-content");o.append(a,r),o.insert(r,n),i.convertChildren(s,a),i.updateConversionResult(r,t)}function Vx(e){return(t,i)=>{const n=i.modelPosition.parent;if(!n.is("element","title"))return;const s=n.parent,o=i.mapper.toViewElement(s);i.viewPosition=e.createPositionAt(o,0),t.stop()}}function Rx(e){return e.is("element","title")}function Bx(e,t,i){const n=t.createElement("title");t.insert(n,e,"before"),t.insert(e,n,0),t.rename(e,"title-content"),i.schema.removeDisallowedAttributes([e],t)}function Ox(e,t,i){let n=!1;for(const s of e)0!==s.index&&(Mx(s,t,i),n=!0);return n}function Mx(e,t,i){const n=e.getChild(0);n.isEmpty?t.remove(e):(t.move(t.createRangeOn(n),e,"before"),t.rename(n,"paragraph"),t.remove(e),i.schema.removeDisallowedAttributes([n],t))}function Lx(e,t){return!(!e||!e.is("element","paragraph")||e.childCount)&&!(t.childCount<=2||t.getChild(t.childCount-1)!==e)}class Nx extends Da{refresh(){const e=this.editor.model,t=e.document;this.value=t.selection.getAttribute("highlight"),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,"highlight")}execute(e={}){const t=this.editor.model,i=t.document.selection,n=e.value;t.change((e=>{if(i.isCollapsed){const t=i.getFirstPosition();if(i.hasAttribute("highlight")){const i=e=>e.item.hasAttribute("highlight")&&e.item.getAttribute("highlight")===this.value,s=t.getLastMatchingPosition(i,{direction:"backward"}),o=t.getLastMatchingPosition(i),r=e.createRange(s,o);n&&this.value!==n?(t.isEqual(o)||e.setAttribute("highlight",n,r),e.setSelectionAttribute("highlight",n)):(t.isEqual(o)||e.removeAttribute("highlight",r),e.removeSelectionAttribute("highlight"))}else n&&e.setSelectionAttribute("highlight",n)}else{const s=t.schema.getValidRanges(i.getRanges(),"highlight");for(const t of s)n?e.setAttribute("highlight",n,t):e.removeAttribute("highlight",t)}}))}}class Fx extends Na{static get pluginName(){return"HighlightEditing"}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:"highlight"});const t=e.config.get("highlight.options");e.conversion.attributeToElement(function(e){const t={model:{key:"highlight",values:[]},view:{}};for(const i of e)t.model.values.push(i.model),t.view[i.model]={name:"mark",classes:i.class};return t}(t)),e.commands.add("highlight",new Nx(e))}constructor(e){super(e),e.config.define("highlight",{options:[{model:"yellowMarker",class:"marker-yellow",title:"Yellow marker",color:"var(--ck-highlight-marker-yellow)",type:"marker"},{model:"greenMarker",class:"marker-green",title:"Green marker",color:"var(--ck-highlight-marker-green)",type:"marker"},{model:"pinkMarker",class:"marker-pink",title:"Pink marker",color:"var(--ck-highlight-marker-pink)",type:"marker"},{model:"blueMarker",class:"marker-blue",title:"Blue marker",color:"var(--ck-highlight-marker-blue)",type:"marker"},{model:"redPen",class:"pen-red",title:"Red pen",color:"var(--ck-highlight-pen-red)",type:"pen"},{model:"greenPen",class:"pen-green",title:"Green pen",color:"var(--ck-highlight-pen-green)",type:"pen"}]})}}class Dx extends Na{get localizedOptionTitles(){const e=this.editor.t;return{"Yellow marker":e("Yellow marker"),"Green marker":e("Green marker"),"Pink marker":e("Pink marker"),"Blue marker":e("Blue marker"),"Red pen":e("Red pen"),"Green pen":e("Green pen")}}static get pluginName(){return"HighlightUI"}init(){const e=this.editor.config.get("highlight.options");for(const t of e)this._addHighlighterButton(t);this._addRemoveHighlightButton(),this._addDropdown(e),this._addMenuBarButton(e)}_addRemoveHighlightButton(){const e=this.editor.t,t=this.editor.commands.get("highlight");this._addButton("removeHighlight",e("Remove highlight"),Dm.eraser,null,(e=>{e.bind("isEnabled").to(t,"isEnabled")}))}_addHighlighterButton(e){const t=this.editor.commands.get("highlight");this._addButton("highlight:"+e.model,e.title,zx(e.type),e.model,(function(i){i.bind("isEnabled").to(t,"isEnabled"),i.bind("isOn").to(t,"value",(t=>t===e.model)),i.iconView.fillColor=e.color,i.isToggleable=!0}))}_addButton(e,t,i,n,s){const o=this.editor;o.ui.componentFactory.add(e,(e=>{const r=new Hg(e),a=this.localizedOptionTitles[t]?this.localizedOptionTitles[t]:t;return r.set({label:a,icon:i,tooltip:!0}),r.on("execute",(()=>{o.execute("highlight",{value:n}),o.editing.view.focus()})),s(r),r}))}_addDropdown(e){const t=this.editor,i=t.t,n=t.ui.componentFactory,s=e[0],o=e.reduce(((e,t)=>(e[t.model]=t,e)),{});n.add("highlight",(r=>{const a=t.commands.get("highlight"),l=Wf(r,Uf),c=l.buttonView;c.set({label:i("Highlight"),tooltip:!0,lastExecuted:s.model,commandValue:s.model,isToggleable:!0}),c.bind("icon").to(a,"value",(e=>zx(d(e,"type")))),c.bind("color").to(a,"value",(e=>d(e,"color"))),c.bind("commandValue").to(a,"value",(e=>d(e,"model"))),c.bind("isOn").to(a,"value",(e=>!!e)),c.delegate("execute").to(l);function d(e,t){const i=e&&e!==c.lastExecuted?e:c.lastExecuted;return o[i][t]}return l.bind("isEnabled").to(a,"isEnabled"),jf(l,(()=>{const t=e.map((e=>{const t=n.create("highlight:"+e.model);return this.listenTo(t,"execute",(()=>{l.buttonView.set({lastExecuted:e.model})})),t}));return t.push(new Vf),t.push(n.create("removeHighlight")),t}),{enableActiveItemFocusOnDropdownOpen:!0,ariaLabel:i("Text highlight toolbar")}),function(e){const t=e.buttonView.actionView;t.iconView.bind("fillColor").to(e.buttonView,"color")}(l),c.on("execute",(()=>{t.execute("highlight",{value:c.commandValue})})),this.listenTo(l,"execute",(()=>{t.editing.view.focus()})),l}))}_addMenuBarButton(e){const t=this.editor,i=t.t;t.ui.componentFactory.add("menuBar:highlight",(n=>{const s=t.commands.get("highlight"),o=new dw(n);o.buttonView.set({label:i("Highlight"),icon:zx("marker")}),o.bind("isEnabled").to(s),o.buttonView.iconView.fillColor="transparent";const r=new hw(n);for(const i of e){const e=new qb(n,o),a=new uw(n);a.set({label:i.title,icon:zx(i.type)}),a.delegate("execute").to(o),a.bind("isOn").to(s,"value",(e=>e===i.model)),a.bind("ariaChecked").to(a,"isOn"),a.iconView.bind("fillColor").to(a,"isOn",(e=>e?"transparent":i.color)),a.on("execute",(()=>{t.execute("highlight",{value:i.model}),t.editing.view.focus()})),e.children.add(a),r.items.add(e)}r.items.add(new zf(n));const a=new qb(n,o),l=new uw(n);return l.set({label:i("Remove highlight"),icon:Dm.eraser}),l.delegate("execute").to(o),l.on("execute",(()=>{t.execute("highlight",{value:null}),t.editing.view.focus()})),a.children.add(l),r.items.add(a),o.panelView.children.add(r),o}))}}function zx(e){return"marker"===e?'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path class="ck-icon__fill" d="M10.798 1.59 3.002 12.875l1.895 1.852 2.521 1.402 6.997-12.194z"/><path d="m2.556 16.727.234-.348c-.297-.151-.462-.293-.498-.426-.036-.137.002-.416.115-.837.094-.25.15-.449.169-.595a4.495 4.495 0 0 0 0-.725c-.209-.621-.303-1.041-.284-1.26.02-.218.178-.506.475-.862l6.77-9.414c.539-.91 1.605-.85 3.199.18 1.594 1.032 2.188 1.928 1.784 2.686l-5.877 10.36c-.158.412-.333.673-.526.782-.193.108-.604.179-1.232.21-.362.131-.608.237-.738.318-.13.081-.305.238-.526.47-.293.265-.504.397-.632.397-.096 0-.27-.075-.524-.226l-.31.41-1.6-1.12zm-.279.415 1.575 1.103-.392.515H1.19l1.087-1.618zm8.1-13.656-4.953 6.9L8.75 12.57l4.247-7.574c.175-.25-.188-.647-1.092-1.192-.903-.546-1.412-.652-1.528-.32zM8.244 18.5 9.59 17h9.406v1.5H8.245z"/></svg>':'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path class="ck-icon__fill" d="M10.126 2.268 2.002 13.874l1.895 1.852 2.521 1.402L14.47 5.481l-1.543-2.568-2.801-.645z"/><path d="m4.5 18.088-2.645-1.852-.04-2.95-.006-.005.006-.008v-.025l.011.008L8.73 2.97c.165-.233.356-.417.567-.557l-1.212.308L4.604 7.9l-.83-.558 3.694-5.495 2.708-.69 1.65 1.145.046.018.85-1.216 2.16 1.512-.856 1.222c.828.967 1.144 2.141.432 3.158L7.55 17.286l.006.005-3.055.797H4.5zm-.634.166-1.976.516-.026-1.918 2.002 1.402zM9.968 3.817l-.006-.004-6.123 9.184 3.277 2.294 6.108-9.162.005.003c.317-.452-.16-1.332-1.064-1.966-.891-.624-1.865-.776-2.197-.349zM8.245 18.5 9.59 17h9.406v1.5H8.245z"/></svg>'}class Hx extends Na{static get requires(){return[Fx,Dx]}static get pluginName(){return"Highlight"}}class $x extends Da{refresh(){const e=this.editor.model,t=e.schema,i=e.document.selection;this.isEnabled=function(e,t,i){const n=function(e,t){const i=hy(e,t),n=i.start.parent;if(n.isEmpty&&!n.is("element","$root"))return n.parent;return n}(e,i);return t.checkChild(n,"horizontalLine")}(i,t,e)}execute(){const e=this.editor.model;e.change((t=>{const i=t.createElement("horizontalLine");e.insertObject(i,null,null,{setSelection:"after"})}))}}class Ux extends Na{static get pluginName(){return"HorizontalLineEditing"}init(){const e=this.editor,t=e.model.schema,i=e.t,n=e.conversion;t.register("horizontalLine",{inheritAllFrom:"$blockObject"}),n.for("dataDowncast").elementToElement({model:"horizontalLine",view:(e,{writer:t})=>t.createEmptyElement("hr")}),n.for("editingDowncast").elementToStructure({model:"horizontalLine",view:(e,{writer:t})=>{const n=i("Horizontal line"),s=t.createContainerElement("div",null,t.createEmptyElement("hr"));return t.addClass("ck-horizontal-line",s),t.setCustomProperty("hr",!0,s),function(e,t,i){return t.setCustomProperty("horizontalLine",!0,e),sy(e,t,{label:i})}(s,t,n)}}),n.for("upcast").elementToElement({view:"hr",model:"horizontalLine"}),e.commands.add("horizontalLine",new $x(e))}}class Wx extends Na{static get pluginName(){return"HorizontalLineUI"}init(){const e=this.editor;e.ui.componentFactory.add("horizontalLine",(()=>{const e=this._createButton(Hg);return e.set({tooltip:!0}),e})),e.ui.componentFactory.add("menuBar:horizontalLine",(()=>this._createButton(uw)))}_createButton(e){const t=this.editor,i=t.locale,n=t.commands.get("horizontalLine"),s=new e(t.locale),o=i.t;return s.set({label:o("Horizontal line"),icon:Dm.horizontalLine}),s.bind("isEnabled").to(n,"isEnabled"),this.listenTo(s,"execute",(()=>{t.execute("horizontalLine"),t.editing.view.focus()})),s}}class jx extends Na{static get requires(){return[Ux,Wx,Ey]}static get pluginName(){return"HorizontalLine"}}class qx extends Da{refresh(){const e=this.editor.model,t=e.schema,i=e.document.selection,n=Gx(i);this.isEnabled=function(e,t,i){const n=function(e,t){const i=hy(e,t),n=i.start.parent;if(n.isEmpty&&!n.is("rootElement"))return n.parent;return n}(e,i);return t.checkChild(n,"rawHtml")}(i,t,e),this.value=n?n.getAttribute("value")||"":null}execute(e){const t=this.editor.model,i=t.document.selection;t.change((n=>{let s;null!==this.value?s=Gx(i):(s=n.createElement("rawHtml"),t.insertObject(s,null,null,{setSelection:"on"})),n.setAttribute("value",e,s)}))}}function Gx(e){const t=e.getSelectedElement();return t&&t.is("element","rawHtml")?t:null}class Kx extends Na{static get pluginName(){return"HtmlEmbedEditing"}init(){const e=this.editor;e.model.schema.register("rawHtml",{inheritAllFrom:"$blockObject",allowAttributes:["value"]}),e.commands.add("htmlEmbed",new qx(e)),this._setupConversion()}_setupConversion(){const e=this.editor,t=e.t,i=e.editing.view,n=this._widgetButtonViewReferences,s=e.config.get("htmlEmbed");function o({editor:e,domElement:i,state:s,props:o}){i.textContent="";const a=i.ownerDocument;let l;if(s.isEditable){const e={isDisabled:!1,placeholder:o.textareaPlaceholder};l=r({domDocument:a,state:s,props:e}),i.append(l)}else if(s.showPreviews){const n={sanitizeHtml:o.sanitizeHtml};i.append(function({editor:e,domDocument:i,state:n,props:s}){const o=s.sanitizeHtml(n.getRawHtmlValue()),r=n.getRawHtmlValue().length>0?t("No preview available"):t("Empty snippet content"),a=cr(i,"div",{class:"ck ck-reset_all raw-html-embed__preview-placeholder"},r),l=cr(i,"div",{class:"raw-html-embed__preview-content",dir:e.locale.contentLanguageDirection}),c=i.createRange(),d=c.createContextualFragment(o.html);l.appendChild(d);const h=cr(i,"div",{class:"raw-html-embed__preview"},[a,l]);return h}({domDocument:a,state:s,props:n,editor:e}))}else{const e={isDisabled:!0,placeholder:o.textareaPlaceholder};i.append(r({domDocument:a,state:s,props:e}))}const c={onEditClick:o.onEditClick,onSaveClick:()=>{o.onSaveClick(l.value)},onCancelClick:o.onCancelClick};i.prepend(function({editor:e,domDocument:t,state:i,props:s}){const o=cr(t,"div",{class:"raw-html-embed__buttons-wrapper"});if(i.isEditable){const t=Zx(e,"save",s.onSaveClick),i=Zx(e,"cancel",s.onCancelClick);o.append(t.element,i.element),n.add(t).add(i)}else{const t=Zx(e,"edit",s.onEditClick);o.append(t.element),n.add(t)}return o}({editor:e,domDocument:a,state:s,props:c}))}function r({domDocument:e,state:t,props:i}){const n=cr(e,"textarea",{placeholder:i.placeholder,class:"ck ck-reset ck-input ck-input-text raw-html-embed__source"});return n.disabled=i.isDisabled,n.value=t.getRawHtmlValue(),n}this.editor.editing.view.on("render",(()=>{for(const e of n){if(e.element&&e.element.isConnected)return;e.destroy(),n.delete(e)}}),{priority:"lowest"}),e.data.registerRawContentMatcher({name:"div",classes:"raw-html-embed"}),e.conversion.for("upcast").elementToElement({view:{name:"div",classes:"raw-html-embed"},model:(e,{writer:t})=>t.createElement("rawHtml",{value:e.getCustomProperty("$rawContent")})}),e.conversion.for("dataDowncast").elementToElement({model:"rawHtml",view:(e,{writer:t})=>t.createRawElement("div",{class:"raw-html-embed"},(function(t){t.innerHTML=e.getAttribute("value")||""}))}),e.conversion.for("editingDowncast").elementToStructure({model:{name:"rawHtml",attributes:["value"]},view:(n,{writer:r})=>{let a,l,c;const d=r.createRawElement("div",{class:"raw-html-embed__content-wrapper"},(function(t){a=t,o({editor:e,domElement:t,state:l,props:c}),a.addEventListener("mousedown",(()=>{if(l.isEditable){const t=e.model;t.document.selection.getSelectedElement()!==n&&t.change((e=>e.setSelection(n,"on")))}}),!0)})),h={makeEditable(){l=Object.assign({},l,{isEditable:!0}),o({domElement:a,editor:e,state:l,props:c}),i.change((e=>{e.setAttribute("data-cke-ignore-events","true",d)})),a.querySelector("textarea").focus()},save(t){t!==l.getRawHtmlValue()?(e.execute("htmlEmbed",t),e.editing.view.focus()):this.cancel()},cancel(){l=Object.assign({},l,{isEditable:!1}),o({domElement:a,editor:e,state:l,props:c}),e.editing.view.focus(),i.change((e=>{e.removeAttribute("data-cke-ignore-events",d)}))}};l={showPreviews:s.showPreviews,isEditable:!1,getRawHtmlValue:()=>n.getAttribute("value")||""},c={sanitizeHtml:s.sanitizeHtml,textareaPlaceholder:t("Paste raw HTML here..."),onEditClick(){h.makeEditable()},onSaveClick(e){h.save(e)},onCancelClick(){h.cancel()}};const u=r.createContainerElement("div",{class:"raw-html-embed","data-html-embed-label":t("HTML snippet"),dir:e.locale.uiLanguageDirection},d);return r.setCustomProperty("rawHtmlApi",h,u),r.setCustomProperty("rawHtml",!0,u),sy(u,r,{label:t("HTML snippet"),hasSelectionHandle:!0})}})}constructor(e){super(e),this._widgetButtonViewReferences=new Set,e.config.define("htmlEmbed",{showPreviews:!1,sanitizeHtml:e=>(b("html-embed-provide-sanitize-function"),{html:e,hasChanged:!1})})}}function Zx(e,t,i){const{t:n}=e.locale,s=new Hg(e.locale),o=e.commands.get("htmlEmbed");return s.set({class:`raw-html-embed__${t}-button`,icon:Dm.pencil,tooltip:!0,tooltipPosition:"rtl"===e.locale.uiLanguageDirection?"e":"w"}),s.render(),"edit"===t?(s.set({icon:Dm.pencil,label:n("Edit source")}),s.bind("isEnabled").to(o)):"save"===t?(s.set({icon:Dm.check,label:n("Save changes")}),s.bind("isEnabled").to(o)):s.set({icon:Dm.cancel,label:n("Cancel")}),s.on("execute",i),s}class Jx extends Na{static get pluginName(){return"HtmlEmbedUI"}init(){const e=this.editor,t=e.locale.t;e.ui.componentFactory.add("htmlEmbed",(()=>{const e=this._createButton(Hg);return e.set({tooltip:!0,label:t("Insert HTML")}),e})),e.ui.componentFactory.add("menuBar:htmlEmbed",(()=>{const e=this._createButton(uw);return e.set({label:t("HTML snippet")}),e}))}_createButton(e){const t=this.editor,i=t.commands.get("htmlEmbed"),n=new e(t.locale);return n.set({icon:Dm.html}),n.bind("isEnabled").to(i,"isEnabled"),this.listenTo(n,"execute",(()=>{t.execute("htmlEmbed"),t.editing.view.focus();t.editing.view.document.selection.getSelectedElement().getCustomProperty("rawHtmlApi").makeEditable()})),n}}class Qx extends Na{static get requires(){return[Kx,Jx,Ey]}static get pluginName(){return"HtmlEmbed"}}function Yx(e,t,i,n){t&&function(e,t,i){if(t.attributes)for(const[n]of Object.entries(t.attributes))e.removeAttribute(n,i);if(t.styles)for(const n of Object.keys(t.styles))e.removeStyle(n,i);t.classes&&e.removeClass(t.classes,i)}(e,t,n),i&&Xx(e,i,n)}function Xx(e,t,i){if(t.attributes)for(const[n,s]of Object.entries(t.attributes))e.setAttribute(n,s,i);t.styles&&e.setStyle(t.styles,i),t.classes&&e.addClass(t.classes,i)}function eA(e,t,i,n,s){const o=t.getAttribute(i),r={};for(const e of["attributes","styles","classes"]){if(e!=n){o&&o[e]&&(r[e]=o[e]);continue}if("classes"==n){const t=new Set(o&&o.classes||[]);s(t),t.size&&(r[e]=Array.from(t));continue}const t=new Map(Object.entries(o&&o[e]||{}));s(t),t.size&&(r[e]=Object.fromEntries(t))}Object.keys(r).length?t.is("documentSelection")?e.setSelectionAttribute(i,r):e.setAttribute(i,r,t):o&&(t.is("documentSelection")?e.removeSelectionAttribute(i):e.removeAttribute(i,t))}function tA(e){return`html${t=e,Wo(t).replace(/ /g,"")}Attributes`;var t}function iA({model:e}){return(t,i)=>i.writer.createElement(e,{htmlContent:t.getCustomProperty("$rawContent")})}function nA(e,{view:t,isInline:i}){const n=e.t;return(e,{writer:s})=>{const o=n("HTML object"),r=sA(t,e,s),a=e.getAttribute(tA(t));s.addClass("html-object-embed__content",r),a&&Xx(s,a,r);return sy(s.createContainerElement(i?"span":"div",{class:"html-object-embed","data-html-object-embed-label":o},r),s,{label:o})}}function sA(e,t,i){return i.createRawElement(e,null,((e,i)=>{i.setContentOf(e,t.getAttribute("htmlContent"))}))}function oA({view:e,model:t,allowEmpty:i},n){return t=>{t.on(`element:${e}`,((e,t,o)=>{let r=n.processViewAttributes(t.viewItem,o);if(r||o.consumable.test(t.viewItem,{name:!0})){if(r=r||{},o.consumable.consume(t.viewItem,{name:!0}),t.modelRange||(t=Object.assign(t,o.convertChildren(t.viewItem,t.modelCursor))),i&&t.modelRange.isCollapsed&&Object.keys(r).length){const e=o.writer.createElement("htmlEmptyElement");if(!o.safeInsert(e,t.modelCursor))return;const i=o.getSplitParts(e);return t.modelRange=o.writer.createRange(t.modelRange.start,o.writer.createPositionAfter(i[i.length-1])),o.updateConversionResult(e,t),void s(e,r,o)}for(const e of t.modelRange.getItems())s(e,r,o)}}),{priority:"low"})};function s(e,i,n){if(n.schema.checkAttribute(e,t)){const s=function(e,t){const i=_s(e);let n="attributes";for(n in t)i[n]="classes"==n?Array.from(new Set([...e[n]||[],...t[n]])):{...e[n],...t[n]};return i}(i,e.getAttribute(t)||{});n.writer.setAttribute(t,s,e)}}}function rA({model:e,view:t},i){return(n,{writer:s,consumable:o})=>{if(!n.hasAttribute(e))return null;const r=s.createContainerElement(t),a=n.getAttribute(e);return o.consume(n,`attribute:${e}`),Xx(s,a,r),r.getFillerOffset=()=>null,i?sy(r,s):r}}function aA({priority:e,view:t}){return(i,n)=>{if(!i)return;const{writer:s}=n,o=s.createAttributeElement(t,null,{priority:e});return Xx(s,i,o),o}}function lA({view:e},t){return i=>{i.on(`element:${e}`,((e,i,n)=>{if(!i.modelRange||i.modelRange.isCollapsed)return;const s=t.processViewAttributes(i.viewItem,n);s&&n.writer.setAttribute(tA(i.viewItem.name),s,i.modelRange)}),{priority:"low"})}}function cA({view:e,model:t}){return i=>{i.on(`attribute:${tA(e)}:${t}`,((e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const{attributeOldValue:n,attributeNewValue:s}=t;Yx(i.writer,n,s,i.mapper.toViewElement(t.item))}))}}var dA=[{model:"codeBlock",view:"pre"},{model:"paragraph",view:"p"},{model:"blockQuote",view:"blockquote"},{model:"listItem",view:"li"},{model:"pageBreak",view:"div"},{model:"rawHtml",view:"div"},{model:"table",view:"table"},{model:"tableRow",view:"tr"},{model:"tableCell",view:"td"},{model:"tableCell",view:"th"},{model:"tableColumnGroup",view:"colgroup"},{model:"tableColumn",view:"col"},{model:"caption",view:"caption"},{model:"caption",view:"figcaption"},{model:"imageBlock",view:"img"},{model:"imageInline",view:"img"},{model:"htmlP",view:"p",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlBlockquote",view:"blockquote",modelSchema:{inheritAllFrom:"$container"}},{model:"htmlTable",view:"table",modelSchema:{allowWhere:"$block",isBlock:!0}},{model:"htmlTbody",view:"tbody",modelSchema:{allowIn:"htmlTable",isBlock:!1}},{model:"htmlThead",view:"thead",modelSchema:{allowIn:"htmlTable",isBlock:!1}},{model:"htmlTfoot",view:"tfoot",modelSchema:{allowIn:"htmlTable",isBlock:!1}},{model:"htmlCaption",view:"caption",modelSchema:{allowIn:"htmlTable",allowChildren:"$text",isBlock:!1}},{model:"htmlColgroup",view:"colgroup",modelSchema:{allowIn:"htmlTable",allowChildren:"col",isBlock:!1}},{model:"htmlCol",view:"col",modelSchema:{allowIn:"htmlColgroup",isBlock:!1}},{model:"htmlTr",view:"tr",modelSchema:{allowIn:["htmlTable","htmlThead","htmlTbody"],isLimit:!0}},{model:"htmlTd",view:"td",modelSchema:{allowIn:"htmlTr",allowContentOf:"$container",isLimit:!0,isBlock:!1}},{model:"htmlTh",view:"th",modelSchema:{allowIn:"htmlTr",allowContentOf:"$container",isLimit:!0,isBlock:!1}},{model:"htmlFigure",view:"figure",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlFigcaption",view:"figcaption",modelSchema:{allowIn:"htmlFigure",allowChildren:"$text",isBlock:!1}},{model:"htmlAddress",view:"address",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlAside",view:"aside",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlMain",view:"main",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlDetails",view:"details",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlSummary",view:"summary",modelSchema:{allowChildren:"$text",allowIn:"htmlDetails",isBlock:!1}},{model:"htmlDiv",view:"div",paragraphLikeModel:"htmlDivParagraph",modelSchema:{inheritAllFrom:"$container"}},{model:"htmlFieldset",view:"fieldset",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlLegend",view:"legend",modelSchema:{allowIn:"htmlFieldset",allowChildren:"$text"}},{model:"htmlHeader",view:"header",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlFooter",view:"footer",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlForm",view:"form",modelSchema:{inheritAllFrom:"$container",isBlock:!0}},{model:"htmlHgroup",view:"hgroup",modelSchema:{allowChildren:["htmlH1","htmlH2","htmlH3","htmlH4","htmlH5","htmlH6"],isBlock:!1}},{model:"htmlH1",view:"h1",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlH2",view:"h2",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlH3",view:"h3",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlH4",view:"h4",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlH5",view:"h5",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlH6",view:"h6",modelSchema:{inheritAllFrom:"$block"}},{model:"$htmlList",modelSchema:{allowWhere:"$container",allowChildren:["$htmlList","htmlLi"],isBlock:!1}},{model:"htmlDir",view:"dir",modelSchema:{inheritAllFrom:"$htmlList"}},{model:"htmlMenu",view:"menu",modelSchema:{inheritAllFrom:"$htmlList"}},{model:"htmlUl",view:"ul",modelSchema:{inheritAllFrom:"$htmlList"}},{model:"htmlOl",view:"ol",modelSchema:{inheritAllFrom:"$htmlList"}},{model:"htmlLi",view:"li",modelSchema:{allowIn:"$htmlList",allowChildren:"$text",isBlock:!1}},{model:"htmlPre",view:"pre",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlArticle",view:"article",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlSection",view:"section",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlNav",view:"nav",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlDivDl",view:"div",modelSchema:{allowChildren:["htmlDt","htmlDd"],allowIn:"htmlDl"}},{model:"htmlDl",view:"dl",modelSchema:{allowWhere:"$container",allowChildren:["htmlDt","htmlDd","htmlDivDl"],isBlock:!1}},{model:"htmlDt",view:"dt",modelSchema:{allowChildren:"$block",isBlock:!1}},{model:"htmlDd",view:"dd",modelSchema:{allowChildren:"$block",isBlock:!1}},{model:"htmlCenter",view:"center",modelSchema:{inheritAllFrom:"$container",isBlock:!1}}],hA=[{model:"htmlLiAttributes",view:"li",appliesToBlock:!0,coupledAttribute:"listItemId"},{model:"htmlOlAttributes",view:"ol",appliesToBlock:!0,coupledAttribute:"listItemId"},{model:"htmlUlAttributes",view:"ul",appliesToBlock:!0,coupledAttribute:"listItemId"},{model:"htmlFigureAttributes",view:"figure",appliesToBlock:"table"},{model:"htmlTheadAttributes",view:"thead",appliesToBlock:"table"},{model:"htmlTbodyAttributes",view:"tbody",appliesToBlock:"table"},{model:"htmlFigureAttributes",view:"figure",appliesToBlock:"imageBlock"},{model:"htmlAcronym",view:"acronym",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlTt",view:"tt",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlFont",view:"font",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlTime",view:"time",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlVar",view:"var",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlBig",view:"big",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlSmall",view:"small",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlSamp",view:"samp",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlQ",view:"q",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlOutput",view:"output",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlKbd",view:"kbd",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlBdi",view:"bdi",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlBdo",view:"bdo",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlAbbr",view:"abbr",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlA",view:"a",priority:5,coupledAttribute:"linkHref"},{model:"htmlStrong",view:"strong",coupledAttribute:"bold",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlB",view:"b",coupledAttribute:"bold",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlI",view:"i",coupledAttribute:"italic",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlEm",view:"em",coupledAttribute:"italic",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlS",view:"s",coupledAttribute:"strikethrough",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlDel",view:"del",coupledAttribute:"strikethrough",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlIns",view:"ins",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlU",view:"u",coupledAttribute:"underline",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlSub",view:"sub",coupledAttribute:"subscript",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlSup",view:"sup",coupledAttribute:"superscript",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlCode",view:"code",coupledAttribute:"code",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlMark",view:"mark",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlSpan",view:"span",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlCite",view:"cite",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlLabel",view:"label",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlDfn",view:"dfn",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlObject",view:"object",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlIframe",view:"iframe",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlInput",view:"input",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlButton",view:"button",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlTextarea",view:"textarea",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlSelect",view:"select",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlVideo",view:"video",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlEmbed",view:"embed",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlOembed",view:"oembed",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlAudio",view:"audio",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlImg",view:"img",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlCanvas",view:"canvas",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlMeter",view:"meter",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlProgress",view:"progress",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlScript",view:"script",modelSchema:{allowWhere:["$text","$block"],isInline:!0}},{model:"htmlStyle",view:"style",modelSchema:{allowWhere:["$text","$block"],isInline:!0}},{model:"htmlCustomElement",view:"$customElement",modelSchema:{allowWhere:["$text","$block"],allowAttributesOf:"$inlineObject",isInline:!0}}];class uA extends Na{static get pluginName(){return"DataSchema"}init(){for(const e of dA)this.registerBlockElement(e);for(const e of hA)this.registerInlineElement(e)}registerBlockElement(e){this._definitions.push({...e,isBlock:!0})}registerInlineElement(e){this._definitions.push({...e,isInline:!0})}extendBlockElement(e){this._extendDefinition({...e,isBlock:!0})}extendInlineElement(e){this._extendDefinition({...e,isInline:!0})}getDefinitionsForView(e,t=!1){const i=new Set;for(const n of this._getMatchingViewDefinitions(e)){if(t)for(const e of this._getReferences(n.model))i.add(e);i.add(n)}return i}getDefinitionsForModel(e){return this._definitions.filter((t=>t.model==e))}_getMatchingViewDefinitions(e){return this._definitions.filter((t=>t.view&&function(e,t){if("string"==typeof e)return e===t;if(e instanceof RegExp)return e.test(t);return!1}(e,t.view)))}*_getReferences(e){const t=["inheritAllFrom","inheritTypesFrom","allowWhere","allowContentOf","allowAttributesOf"],i=this._definitions.filter((t=>t.model==e));for(const{modelSchema:n}of i)if(n)for(const i of t)for(const t of pa(n[i]||[])){const i=this._definitions.filter((e=>e.model==t));for(const n of i)t!==e&&(yield*this._getReferences(n.model),yield n)}}_extendDefinition(e){const t=Array.from(this._definitions.entries()).filter((([,t])=>t.model==e.model));if(0!=t.length)for(const[i,n]of t)this._definitions[i]=To({},n,e,((e,t)=>Array.isArray(e)?e.concat(t):void 0));else this._definitions.push(e)}constructor(...e){super(...e),this._definitions=[]}}class mA extends Na{static get pluginName(){return"DataFilter"}static get requires(){return[uA,Ey]}loadAllowedConfig(e){for(const t of e){const e=t.name||/[\s\S]+/,i=wA(t);this.allowElement(e),i.forEach((e=>this.allowAttributes(e)))}}loadDisallowedConfig(e){for(const t of e){const e=t.name||/[\s\S]+/,i=wA(t);0==i.length?this.disallowElement(e):i.forEach((e=>this.disallowAttributes(e)))}}loadAllowedEmptyElementsConfig(e){for(const t of e)this.allowEmptyElement(t)}allowElement(e){for(const t of this._dataSchema.getDefinitionsForView(e,!0))this._addAllowedElement(t),this._coupledAttributes=null}disallowElement(e){for(const t of this._dataSchema.getDefinitionsForView(e,!1))this._disallowedElements.add(t.view)}allowEmptyElement(e){for(const t of this._dataSchema.getDefinitionsForView(e,!0))t.isInline&&this._dataSchema.extendInlineElement({...t,allowEmpty:!0})}allowAttributes(e){this._allowedAttributes.add(e)}disallowAttributes(e){this._disallowedAttributes.add(e)}processViewAttributes(e,t){const{consumable:i}=t;return gA(e,this._disallowedAttributes,i),function(e,{attributes:t,classes:i,styles:n}){if(!t.length&&!i.length&&!n.length)return null;return{...t.length&&{attributes:fA(e,t)},...n.length&&{styles:pA(e,n)},...i.length&&{classes:i}}}(e,gA(e,this._allowedAttributes,i))}_addAllowedElement(e){if(!this._allowedElements.has(e)){if(this._allowedElements.add(e),"appliesToBlock"in e&&"string"==typeof e.appliesToBlock)for(const t of this._dataSchema.getDefinitionsForModel(e.appliesToBlock))t.isBlock&&this._addAllowedElement(t);this._dataInitialized&&this.editor.data.once("set",(()=>{this._fireRegisterEvent(e)}),{priority:m.highest+1})}}_registerElementsAfterInit(){this.editor.data.on("init",(()=>{this._dataInitialized=!0;for(const e of this._allowedElements)this._fireRegisterEvent(e)}),{priority:m.highest+1})}_registerElementHandlers(){this.on("register",((e,t)=>{const i=this.editor.model.schema;if(t.isObject&&!i.isRegistered(t.model))this._registerObjectElement(t);else if(t.isBlock)this._registerBlockElement(t);else{if(!t.isInline)throw new p("data-filter-invalid-definition",null,t);this._registerInlineElement(t)}e.stop()}),{priority:"lowest"})}_registerCoupledAttributesPostFixer(){const e=this.editor.model,t=e.document.selection;e.document.registerPostFixer((t=>{const i=e.document.differ.getChanges();let n=!1;const s=this._getCoupledAttributesMap();for(const e of i){if("attribute"!=e.type||null!==e.attributeNewValue)continue;const i=s.get(e.attributeKey);if(i)for(const{item:s}of e.range.getWalker())for(const e of i)s.hasAttribute(e)&&(t.removeAttribute(e,s),n=!0)}return n})),this.listenTo(t,"change:attribute",((i,{attributeKeys:n})=>{const s=new Set,o=this._getCoupledAttributesMap();for(const e of n){if(t.hasAttribute(e))continue;const i=o.get(e);if(i)for(const e of i)t.hasAttribute(e)&&s.add(e)}0!=s.size&&e.change((e=>{for(const t of s)e.removeSelectionAttribute(t)}))}))}_registerAssociatedHtmlAttributesPostFixer(){const e=this.editor.model;e.document.registerPostFixer((t=>{const i=e.document.differ.getChanges();let n=!1;for(const s of i)if("insert"===s.type&&"$text"!==s.name)for(const i of s.attributes.keys())i.startsWith("html")&&i.endsWith("Attributes")&&(e.schema.checkAttribute(s.name,i)||(t.removeAttribute(i,s.position.nodeAfter),n=!0));return n}))}_getCoupledAttributesMap(){if(this._coupledAttributes)return this._coupledAttributes;this._coupledAttributes=new Map;for(const e of this._allowedElements)if(e.coupledAttribute&&e.model){const t=this._coupledAttributes.get(e.coupledAttribute);t?t.push(e.model):this._coupledAttributes.set(e.coupledAttribute,[e.model])}return this._coupledAttributes}_fireRegisterEvent(e){e.view&&this._disallowedElements.has(e.view)||this.fire(e.view?`register:${e.view}`:"register",e)}_registerObjectElement(e){const t=this.editor,i=t.model.schema,n=t.conversion,{view:s,model:o}=e;i.register(o,e.modelSchema),s&&(i.extend(e.model,{allowAttributes:[tA(s),"htmlContent"]}),t.data.registerRawContentMatcher({name:s}),n.for("upcast").elementToElement({view:s,model:iA(e),converterPriority:m.low+2}),n.for("upcast").add(lA(e,this)),n.for("editingDowncast").elementToStructure({model:{name:o,attributes:[tA(s)]},view:nA(t,e)}),n.for("dataDowncast").elementToElement({model:o,view:(e,{writer:t})=>sA(s,e,t)}),n.for("dataDowncast").add(cA(e)))}_registerBlockElement(e){const t=this.editor,i=t.model.schema,n=t.conversion,{view:s,model:o}=e;if(!i.isRegistered(e.model)){if(i.register(e.model,e.modelSchema),!s)return;n.for("upcast").elementToElement({model:o,view:s,converterPriority:m.low+2}),n.for("downcast").elementToElement({model:o,view:s})}s&&(i.extend(e.model,{allowAttributes:tA(s)}),n.for("upcast").add(lA(e,this)),n.for("downcast").add(cA(e)))}_registerInlineElement(e){const t=this.editor,i=t.model.schema,n=t.conversion,s=e.model;e.appliesToBlock||(i.extend("$text",{allowAttributes:s}),e.attributeProperties&&i.setAttributeProperties(s,e.attributeProperties),n.for("upcast").add(oA(e,this)),n.for("downcast").attributeToElement({model:s,view:aA(e)}),e.allowEmpty&&(i.setAttributeProperties(s,{copyFromObject:!1}),i.isRegistered("htmlEmptyElement")||i.register("htmlEmptyElement",{inheritAllFrom:"$inlineObject"}),t.data.htmlProcessor.domConverter.registerInlineObjectMatcher((t=>t.name==e.view&&t.isEmpty&&Array.from(t.getAttributeKeys()).length?{name:!0}:null)),n.for("editingDowncast").elementToElement({model:"htmlEmptyElement",view:rA(e,!0)}),n.for("dataDowncast").elementToElement({model:"htmlEmptyElement",view:rA(e)})))}constructor(e){super(e),this._dataSchema=e.plugins.get("DataSchema"),this._allowedAttributes=new ol,this._disallowedAttributes=new ol,this._allowedElements=new Set,this._disallowedElements=new Set,this._dataInitialized=!1,this._coupledAttributes=null,this._registerElementsAfterInit(),this._registerElementHandlers(),this._registerCoupledAttributesPostFixer(),this._registerAssociatedHtmlAttributesPostFixer()}}function gA(e,t,i){const n=t.matchAll(e)||[],s=e.document.stylesProcessor;return n.reduce(((t,{match:n})=>{for(const o of n.styles||[]){const n=s.getRelatedStyles(o).filter((e=>e.split("-").length>o.split("-").length)).sort(((e,t)=>t.split("-").length-e.split("-").length));for(const s of n)i.consume(e,{styles:[s]})&&t.styles.push(s);i.consume(e,{styles:[o]})&&t.styles.push(o)}for(const s of n.classes||[])i.consume(e,{classes:[s]})&&t.classes.push(s);for(const s of n.attributes||[])i.consume(e,{attributes:[s]})&&t.attributes.push(s);return t}),{attributes:[],classes:[],styles:[]})}function fA(e,t){const i={};for(const n of t){const t=e.getAttribute(n);void 0!==t&&zr(n)&&(i[n]=t)}return i}function pA(e,t){const i=new ll(e.document.stylesProcessor);for(const n of t){const t=e.getStyle(n);void 0!==t&&i.set(n,t)}return Object.fromEntries(i.getStylesEntries())}function bA(e,t){const{name:i}=e,n=e[t];return oi(n)?Object.entries(n).map((([e,n])=>({name:i,[t]:{[e]:n}}))):Array.isArray(n)?n.map((e=>({name:i,[t]:[e]}))):[e]}function wA(e){const{name:t,attributes:i,classes:n,styles:s}=e,o=[];return i&&o.push(...bA({name:t,attributes:i},"attributes")),n&&o.push(...bA({name:t,classes:n},"classes")),s&&o.push(...bA({name:t,styles:s},"styles")),o}class vA extends Na{static get requires(){return[mA]}static get pluginName(){return"CodeBlockElementSupport"}init(){if(!this.editor.plugins.has("CodeBlockEditing"))return;const e=this.editor.plugins.get(mA);e.on("register:pre",((t,i)=>{if("codeBlock"!==i.model)return;const n=this.editor,s=n.model.schema,o=n.conversion;s.extend("codeBlock",{allowAttributes:["htmlPreAttributes","htmlContentAttributes"]}),o.for("upcast").add(function(e){return t=>{t.on("element:code",((t,i,n)=>{const s=i.viewItem,o=s.parent;function r(t,s){const o=e.processViewAttributes(t,n);o&&n.writer.setAttribute(s,o,i.modelRange)}o&&o.is("element","pre")&&(r(o,"htmlPreAttributes"),r(s,"htmlContentAttributes"))}),{priority:"low"})}}(e)),o.for("downcast").add((e=>{e.on("attribute:htmlPreAttributes:codeBlock",((e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const{attributeOldValue:n,attributeNewValue:s}=t,o=i.mapper.toViewElement(t.item).parent;Yx(i.writer,n,s,o)})),e.on("attribute:htmlContentAttributes:codeBlock",((e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const{attributeOldValue:n,attributeNewValue:s}=t,o=i.mapper.toViewElement(t.item);Yx(i.writer,n,s,o)}))})),t.stop()}))}}class _A extends Na{static get requires(){return[mA]}static get pluginName(){return"DualContentModelElementSupport"}init(){this.editor.plugins.get(mA).on("register",((e,t)=>{const i=t,n=this.editor,s=n.model.schema,o=n.conversion;if(!i.paragraphLikeModel)return;if(s.isRegistered(i.model)||s.isRegistered(i.paragraphLikeModel))return;const r={model:i.paragraphLikeModel,view:i.view};s.register(i.model,i.modelSchema),s.register(r.model,{inheritAllFrom:"$block"}),o.for("upcast").elementToElement({view:i.view,model:(e,{writer:t})=>this._hasBlockContent(e)?t.createElement(i.model):t.createElement(r.model),converterPriority:m.low+.5}),o.for("downcast").elementToElement({view:i.view,model:i.model}),this._addAttributeConversion(i),o.for("downcast").elementToElement({view:r.view,model:r.model}),this._addAttributeConversion(r),e.stop()}))}_hasBlockContent(e){const t=this.editor.editing.view,i=t.domConverter.blockElements;for(const n of t.createRangeIn(e).getItems())if(n.is("element")&&i.includes(n.name))return!0;return!1}_addAttributeConversion(e){const t=this.editor,i=t.conversion,n=t.plugins.get(mA);t.model.schema.extend(e.model,{allowAttributes:tA(e.view)}),i.for("upcast").add(lA(e,n)),i.for("downcast").add(cA(e))}}class yA extends Na{static get requires(){return[uA,Kv]}static get pluginName(){return"HeadingElementSupport"}init(){const e=this.editor;if(!e.plugins.has("HeadingEditing"))return;const t=e.config.get("heading.options");this.registerHeadingElements(e,t)}registerHeadingElements(e,t){const i=e.plugins.get(uA),n=[];for(const e of t)"model"in e&&"view"in e&&(i.registerBlockElement({view:e.view,model:e.model}),n.push(e.model));i.extendBlockElement({model:"htmlHgroup",modelSchema:{allowChildren:n}})}}function kA(e,t,i){const n=e.createRangeOn(t);for(const{item:e}of n.getWalker())if(e.is("element",i))return e}class CA extends Na{static get requires(){return[mA]}static get pluginName(){return"ImageElementSupport"}init(){const e=this.editor;if(!e.plugins.has("ImageInlineEditing")&&!e.plugins.has("ImageBlockEditing"))return;const t=e.model.schema,i=e.conversion,n=e.plugins.get(mA);n.on("register:figure",(()=>{i.for("upcast").add(function(e){return t=>{t.on("element:figure",((t,i,n)=>{const s=i.viewItem;if(!i.modelRange||!s.hasClass("image"))return;const o=e.processViewAttributes(s,n);o&&n.writer.setAttribute("htmlFigureAttributes",o,i.modelRange)}),{priority:"low"})}}(n))})),n.on("register:img",((s,o)=>{"imageBlock"!==o.model&&"imageInline"!==o.model||(t.isRegistered("imageBlock")&&t.extend("imageBlock",{allowAttributes:["htmlImgAttributes","htmlFigureAttributes","htmlLinkAttributes"]}),t.isRegistered("imageInline")&&t.extend("imageInline",{allowAttributes:["htmlA","htmlImgAttributes"]}),i.for("upcast").add(function(e){return t=>{t.on("element:img",((t,i,n)=>{if(!i.modelRange)return;const s=i.viewItem,o=e.processViewAttributes(s,n);o&&n.writer.setAttribute("htmlImgAttributes",o,i.modelRange)}),{priority:"low"})}}(n)),i.for("downcast").add((e=>{function t(t){e.on(`attribute:${t}:imageInline`,((e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const{attributeOldValue:n,attributeNewValue:s}=t,o=i.mapper.toViewElement(t.item);Yx(i.writer,n,s,o)}),{priority:"low"})}function i(t,i){e.on(`attribute:${i}:imageBlock`,((e,i,n)=>{if(!n.consumable.test(i.item,e.name))return;const{attributeOldValue:s,attributeNewValue:o}=i,r=n.mapper.toViewElement(i.item),a=kA(n.writer,r,t);a&&(Yx(n.writer,s,o,a),n.consumable.consume(i.item,e.name))}),{priority:"low"}),"a"===t&&e.on("attribute:linkHref:imageBlock",((e,t,i)=>{if(!i.consumable.consume(t.item,"attribute:htmlLinkAttributes:imageBlock"))return;const n=i.mapper.toViewElement(t.item),s=kA(i.writer,n,"a");Xx(i.writer,t.item.getAttribute("htmlLinkAttributes"),s)}),{priority:"low"})}t("htmlImgAttributes"),i("img","htmlImgAttributes"),i("figure","htmlFigureAttributes"),i("a","htmlLinkAttributes")})),e.plugins.has("LinkImage")&&i.for("upcast").add(function(e,t){const i=t.plugins.get("ImageUtils");return t=>{t.on("element:a",((t,n,s)=>{const o=n.viewItem;if(!i.findViewImgElement(o))return;const r=n.modelCursor.parent;if(!r.is("element","imageBlock"))return;const a=e.processViewAttributes(o,s);a&&s.writer.setAttribute("htmlLinkAttributes",a,r)}),{priority:"low"})}}(n,e)),s.stop())}))}}class xA extends Na{static get requires(){return[mA]}static get pluginName(){return"MediaEmbedElementSupport"}init(){const e=this.editor;if(!e.plugins.has("MediaEmbed")||e.config.get("mediaEmbed.previewsInData"))return;const t=e.model.schema,i=e.conversion,n=this.editor.plugins.get(mA),s=this.editor.plugins.get(uA),o=e.config.get("mediaEmbed.elementName");s.registerBlockElement({model:"media",view:o}),n.on("register:figure",(()=>{i.for("upcast").add(function(e){return t=>{t.on("element:figure",((t,i,n)=>{const s=i.viewItem;if(!i.modelRange||!s.hasClass("media"))return;const o=e.processViewAttributes(s,n);o&&n.writer.setAttribute("htmlFigureAttributes",o,i.modelRange)}),{priority:"low"})}}(n))})),n.on(`register:${o}`,((e,s)=>{"media"===s.model&&(t.extend("media",{allowAttributes:[tA(o),"htmlFigureAttributes"]}),i.for("upcast").add(function(e,t){const i=(i,n,s)=>{function o(t,i){const o=e.processViewAttributes(t,s);o&&s.writer.setAttribute(i,o,n.modelRange)}o(n.viewItem,tA(t))};return e=>{e.on(`element:${t}`,i,{priority:"low"})}}(n,o)),i.for("dataDowncast").add(function(e){return t=>{function i(e,i){t.on(`attribute:${i}:media`,((t,i,n)=>{if(!n.consumable.consume(i.item,t.name))return;const{attributeOldValue:s,attributeNewValue:o}=i,r=n.mapper.toViewElement(i.item),a=kA(n.writer,r,e);Yx(n.writer,s,o,a)}))}i(e,tA(e)),i("figure","htmlFigureAttributes")}}(o)),e.stop())}))}}class AA extends Na{static get requires(){return[mA]}static get pluginName(){return"ScriptElementSupport"}init(){const e=this.editor.plugins.get(mA);e.on("register:script",((t,i)=>{const n=this.editor,s=n.model.schema,o=n.conversion;s.register("htmlScript",i.modelSchema),s.extend("htmlScript",{allowAttributes:["htmlScriptAttributes","htmlContent"],isContent:!0}),n.data.registerRawContentMatcher({name:"script"}),o.for("upcast").elementToElement({view:"script",model:iA(i)}),o.for("upcast").add(lA(i,e)),o.for("downcast").elementToElement({model:"htmlScript",view:(e,{writer:t})=>sA("script",e,t)}),o.for("downcast").add(cA(i)),t.stop()}))}}class EA extends Na{static get requires(){return[mA]}static get pluginName(){return"TableElementSupport"}init(){const e=this.editor;if(!e.plugins.has("TableEditing"))return;const t=e.model.schema,i=e.conversion,n=e.plugins.get(mA),s=e.plugins.get("TableUtils");n.on("register:figure",(()=>{i.for("upcast").add(function(e){return t=>{t.on("element:figure",((t,i,n)=>{const s=i.viewItem;if(!i.modelRange||!s.hasClass("table"))return;const o=e.processViewAttributes(s,n);o&&n.writer.setAttribute("htmlFigureAttributes",o,i.modelRange)}),{priority:"low"})}}(n))})),n.on("register:table",((o,r)=>{"table"===r.model&&(t.extend("table",{allowAttributes:["htmlTableAttributes","htmlFigureAttributes","htmlTheadAttributes","htmlTbodyAttributes"]}),i.for("upcast").add(function(e){return t=>{t.on("element:table",((t,i,n)=>{if(!i.modelRange)return;const s=i.viewItem;o(s,"htmlTableAttributes");for(const e of s.getChildren())e.is("element","thead")&&o(e,"htmlTheadAttributes"),e.is("element","tbody")&&o(e,"htmlTbodyAttributes");function o(t,s){const o=e.processViewAttributes(t,n);o&&n.writer.setAttribute(s,o,i.modelRange)}}),{priority:"low"})}}(n)),i.for("downcast").add((e=>{function t(t,i){e.on(`attribute:${i}:table`,((e,i,n)=>{if(!n.consumable.test(i.item,e.name))return;const s=n.mapper.toViewElement(i.item),o=kA(n.writer,s,t);o&&(n.consumable.consume(i.item,e.name),Yx(n.writer,i.attributeOldValue,i.attributeNewValue,o))}))}t("table","htmlTableAttributes"),t("figure","htmlFigureAttributes"),t("thead","htmlTheadAttributes"),t("tbody","htmlTbodyAttributes")})),e.model.document.registerPostFixer(function(e,t){return i=>{const n=e.document.differ.getChanges();let s=!1;for(const e of n){if("attribute"!=e.type||"headingRows"!=e.attributeKey)continue;const n=e.range.start.nodeAfter,o=n.getAttribute("htmlTheadAttributes"),r=n.getAttribute("htmlTbodyAttributes");o&&!e.attributeNewValue?(i.removeAttribute("htmlTheadAttributes",n),s=!0):r&&e.attributeNewValue==t.getRows(n)&&(i.removeAttribute("htmlTbodyAttributes",n),s=!0)}return s}}(e.model,s)),o.stop())}))}}class TA extends Na{static get requires(){return[mA]}static get pluginName(){return"StyleElementSupport"}init(){const e=this.editor.plugins.get(mA);e.on("register:style",((t,i)=>{const n=this.editor,s=n.model.schema,o=n.conversion;s.register("htmlStyle",i.modelSchema),s.extend("htmlStyle",{allowAttributes:["htmlStyleAttributes","htmlContent"],isContent:!0}),n.data.registerRawContentMatcher({name:"style"}),o.for("upcast").elementToElement({view:"style",model:iA(i)}),o.for("upcast").add(lA(i,e)),o.for("downcast").elementToElement({model:"htmlStyle",view:(e,{writer:t})=>sA("style",e,t)}),o.for("downcast").add(cA(i)),t.stop()}))}}class SA extends Na{static get requires(){return[mA]}static get pluginName(){return"ListElementSupport"}init(){const e=this.editor;if(!e.plugins.has("ListEditing"))return;const t=e.model.schema,i=e.conversion,n=e.plugins.get(mA),s=e.plugins.get("ListEditing"),o=e.plugins.get("ListUtils"),r=["ul","ol","li"];s.registerDowncastStrategy({scope:"item",attributeName:"htmlLiAttributes",setAttributeOnDowncast:Xx}),s.registerDowncastStrategy({scope:"list",attributeName:"htmlUlAttributes",setAttributeOnDowncast:Xx}),s.registerDowncastStrategy({scope:"list",attributeName:"htmlOlAttributes",setAttributeOnDowncast:Xx}),n.on("register",((e,s)=>{if(!r.includes(s.view))return;if(e.stop(),t.checkAttribute("$block","htmlLiAttributes"))return;const o=r.map((e=>tA(e)));t.extend("$listItem",{allowAttributes:o}),i.for("upcast").add((e=>{e.on("element:ul",IA("htmlUlAttributes",n),{priority:"low"}),e.on("element:ol",IA("htmlOlAttributes",n),{priority:"low"}),e.on("element:li",IA("htmlLiAttributes",n),{priority:"low"})}))})),s.on("postFixer",((e,{listNodes:t,writer:i})=>{for(const{node:n,previousNodeInList:s}of t)if(s){if(s.getAttribute("listType")==n.getAttribute("listType")){const t=PA(s.getAttribute("listType")),o=s.getAttribute(t);!Do(n.getAttribute(t),o)&&i.model.schema.checkAttribute(n,t)&&(i.setAttribute(t,o,n),e.return=!0)}if(s.getAttribute("listItemId")==n.getAttribute("listItemId")){const t=s.getAttribute("htmlLiAttributes");!Do(n.getAttribute("htmlLiAttributes"),t)&&i.model.schema.checkAttribute(n,"htmlLiAttributes")&&(i.setAttribute("htmlLiAttributes",t,n),e.return=!0)}}})),s.on("postFixer",((e,{listNodes:t,writer:i})=>{for(const{node:n}of t){const t=n.getAttribute("listType");!o.isNumberedListType(t)&&n.getAttribute("htmlOlAttributes")&&(i.removeAttribute("htmlOlAttributes",n),e.return=!0),o.isNumberedListType(t)&&n.getAttribute("htmlUlAttributes")&&(i.removeAttribute("htmlUlAttributes",n),e.return=!0)}}))}afterInit(){const e=this.editor;if(!e.commands.get("indentList"))return;const t=e.commands.get("indentList");this.listenTo(t,"afterExecute",((t,i)=>{e.model.change((t=>{for(const n of i){const i=PA(n.getAttribute("listType"));e.model.schema.checkAttribute(n,i)&&t.setAttribute(i,{},n)}}))}))}}function IA(e,t){return(i,n,s)=>{const o=n.viewItem;n.modelRange||Object.assign(n,s.convertChildren(n.viewItem,n.modelCursor));const r=t.processViewAttributes(o,s);for(const t of n.modelRange.getItems({shallow:!0}))t.hasAttribute("listItemId")&&(t.hasAttribute(e)||s.writer.model.schema.checkAttribute(t,e)&&s.writer.setAttribute(e,r||{},t))}}function PA(e){return"numbered"===e||"customNumbered"==e?"htmlOlAttributes":"htmlUlAttributes"}class VA extends Na{static get requires(){return[mA,uA]}static get pluginName(){return"CustomElementSupport"}init(){const e=this.editor.plugins.get(mA),t=this.editor.plugins.get(uA);e.on("register:$customElement",((i,n)=>{i.stop();const s=this.editor,o=s.model.schema,r=s.conversion,a=s.editing.view.domConverter.unsafeElements,l=s.data.htmlProcessor.domConverter.preElements;o.register(n.model,n.modelSchema),o.extend(n.model,{allowAttributes:["htmlElementName","htmlCustomElementAttributes","htmlContent"],isContent:!0}),s.data.htmlProcessor.domConverter.registerRawContentMatcher({name:"template"}),r.for("upcast").elementToElement({view:/.*/,model:(i,o)=>{if("$comment"==i.name)return null;if(!function(e){try{document.createElement(e)}catch(e){return!1}return!0}(i.name))return null;if(t.getDefinitionsForView(i.name).size)return null;a.includes(i.name)||a.push(i.name),l.includes(i.name)||l.push(i.name);const r=o.writer.createElement(n.model,{htmlElementName:i.name}),c=e.processViewAttributes(i,o);let d;if(c&&o.writer.setAttribute("htmlCustomElementAttributes",c,r),i.is("element","template")&&i.getCustomProperty("$rawContent"))d=i.getCustomProperty("$rawContent");else{const e=new Hu(i.document).createDocumentFragment(i),t=s.data.htmlProcessor.domConverter.viewToDom(e),n=t.firstChild;for(;n.firstChild;)t.appendChild(n.firstChild);n.remove(),d=s.data.htmlProcessor.htmlWriter.getHtml(t)}o.writer.setAttribute("htmlContent",d,r);for(const{item:e}of s.editing.view.createRangeIn(i))o.consumable.consume(e,{name:!0});return r},converterPriority:"low"}),r.for("editingDowncast").elementToElement({model:{name:n.model,attributes:["htmlElementName","htmlCustomElementAttributes","htmlContent"]},view:(e,{writer:t})=>{const i=e.getAttribute("htmlElementName"),n=t.createRawElement(i);return e.hasAttribute("htmlCustomElementAttributes")&&Xx(t,e.getAttribute("htmlCustomElementAttributes"),n),n}}),r.for("dataDowncast").elementToElement({model:{name:n.model,attributes:["htmlElementName","htmlCustomElementAttributes","htmlContent"]},view:(e,{writer:t})=>{const i=e.getAttribute("htmlElementName"),n=e.getAttribute("htmlContent"),s=t.createRawElement(i,null,((e,t)=>{t.setContentOf(e,n)}));return e.hasAttribute("htmlCustomElementAttributes")&&Xx(t,e.getAttribute("htmlCustomElementAttributes"),s),s}})}))}}class RA extends Na{static get pluginName(){return"GeneralHtmlSupport"}static get requires(){return[mA,vA,_A,yA,CA,xA,AA,EA,TA,SA,VA]}init(){const e=this.editor,t=e.plugins.get(mA);t.loadAllowedEmptyElementsConfig(e.config.get("htmlSupport.allowEmpty")||[]),t.loadAllowedConfig(e.config.get("htmlSupport.allow")||[]),t.loadDisallowedConfig(e.config.get("htmlSupport.disallow")||[])}getGhsAttributeNameForElement(e){const t=this.editor.plugins.get("DataSchema"),i=Array.from(t.getDefinitionsForView(e,!1)),n=i.find((e=>e.isInline&&!i[0].isObject));return n?n.model:tA(e)}addModelHtmlClass(e,t,i){const n=this.editor.model,s=this.getGhsAttributeNameForElement(e);n.change((e=>{for(const o of BA(n,i,s))eA(e,o,s,"classes",(e=>{for(const i of pa(t))e.add(i)}))}))}removeModelHtmlClass(e,t,i){const n=this.editor.model,s=this.getGhsAttributeNameForElement(e);n.change((e=>{for(const o of BA(n,i,s))eA(e,o,s,"classes",(e=>{for(const i of pa(t))e.delete(i)}))}))}setModelHtmlAttributes(e,t,i){const n=this.editor.model,s=this.getGhsAttributeNameForElement(e);n.change((e=>{for(const o of BA(n,i,s))eA(e,o,s,"attributes",(e=>{for(const[i,n]of Object.entries(t))e.set(i,n)}))}))}removeModelHtmlAttributes(e,t,i){const n=this.editor.model,s=this.getGhsAttributeNameForElement(e);n.change((e=>{for(const o of BA(n,i,s))eA(e,o,s,"attributes",(e=>{for(const i of pa(t))e.delete(i)}))}))}setModelHtmlStyles(e,t,i){const n=this.editor.model,s=this.getGhsAttributeNameForElement(e);n.change((e=>{for(const o of BA(n,i,s))eA(e,o,s,"styles",(e=>{for(const[i,n]of Object.entries(t))e.set(i,n)}))}))}removeModelHtmlStyles(e,t,i){const n=this.editor.model,s=this.getGhsAttributeNameForElement(e);n.change((e=>{for(const o of BA(n,i,s))eA(e,o,s,"styles",(e=>{for(const i of pa(t))e.delete(i)}))}))}}function*BA(e,t,i){if(t)if(!(Symbol.iterator in t)&&t.is("documentSelection")&&t.isCollapsed)e.schema.checkAttributeInSelection(t,i)&&(yield t);else for(const n of function(e,t,i){return!(Symbol.iterator in t)&&(t.is("node")||t.is("$text")||t.is("$textProxy"))?e.schema.checkAttribute(t,i)?[e.createRangeOn(t)]:[]:e.schema.getValidRanges(e.createSelection(t).getRanges(),i)}(e,t,i))yield*n.getItems({shallow:!0})}class OA extends Na{static get pluginName(){return"HtmlComment"}init(){const e=this.editor,t=new Map;e.data.processor.skipComments=!1,e.model.schema.addAttributeCheck(((e,t)=>{if(e.endsWith("$root")&&t.startsWith("$comment"))return!0})),e.conversion.for("upcast").elementToMarker({view:"$comment",model:e=>{const i=`$comment:${u()}`,n=e.getCustomProperty("$rawContent");return t.set(i,n),i}}),e.conversion.for("dataDowncast").markerToElement({model:"$comment",view:(e,{writer:t})=>{let i;for(const t of this.editor.model.document.getRootNames())if(i=this.editor.model.document.getRoot(t),i.hasAttribute(e.markerName))break;const n=e.markerName,s=i.getAttribute(n),o=t.createUIElement("$comment");return t.setCustomProperty("$rawContent",s,o),o}}),e.model.document.registerPostFixer((i=>{let n=!1;const s=e.model.document.differ.getChangedMarkers().filter((e=>e.name.startsWith("$comment:")));for(const e of s){const{oldRange:s,newRange:o}=e.data;if(!s||!o||s.root!=o.root){if(s){const t=s.root;t.hasAttribute(e.name)&&(i.removeAttribute(e.name,t),n=!0)}if(o){const s=o.root;"$graveyard"==s.rootName?(i.removeMarker(e.name),n=!0):s.hasAttribute(e.name)||(i.setAttribute(e.name,t.get(e.name)||"",s),n=!0)}}}return n})),e.data.on("set",(()=>{for(const t of e.model.markers.getMarkersGroup("$comment"))this.removeHtmlComment(t.name)}),{priority:"high"}),e.model.on("deleteContent",((t,[i])=>{for(const t of i.getRanges()){const i=e.model.schema.getLimitElement(t),n=e.model.createPositionAt(i,0),s=e.model.createPositionAt(i,"end");let o;o=n.isTouching(t.start)&&s.isTouching(t.end)?this.getHtmlCommentsInRange(e.model.createRange(n,s)):this.getHtmlCommentsInRange(t,{skipBoundaries:!0});for(const e of o)this.removeHtmlComment(e)}}),{priority:"high"})}createHtmlComment(e,t){const i=u(),n=this.editor.model,s=n.document.getRoot(e.root.rootName),o=`$comment:${i}`;return n.change((i=>{const n=i.createRange(e);return i.addMarker(o,{usingOperation:!0,affectsData:!0,range:n}),i.setAttribute(o,t,s),o}))}removeHtmlComment(e){const t=this.editor,i=t.model.markers.get(e);return!!i&&(t.model.change((e=>{e.removeMarker(i)})),!0)}getHtmlCommentData(e){const t=this.editor.model.markers.get(e);if(!t)return null;let i="";for(const t of this.editor.model.document.getRoots())if(t.hasAttribute(e)){i=t.getAttribute(e);break}return{content:i,position:t.getStart()}}getHtmlCommentsInRange(e,{skipBoundaries:t=!1}={}){const i=!t;return Array.from(this.editor.model.markers.getMarkersGroup("$comment")).filter((t=>function(e,t){const n=e.getRange().start;return(n.isAfter(t.start)||i&&n.isEqual(t.start))&&(n.isBefore(t.end)||i&&n.isEqual(t.end))}(t,e))).map((e=>e.name))}}class MA extends wh{toView(e){if(!e.match(/<(?:html|body|head|meta)(?:\s[^>]*)?>/i))return super.toView(e);let t="",i="";e=(e=e.replace(/<!DOCTYPE[^>]*>/i,(e=>(t=e,"")))).replace(/<\?xml\s[^?]*\?>/i,(e=>(i=e,"")));const n=this._toDom(e),s=this.domConverter.domToView(n,{skipComments:this.skipComments}),o=new Hu(s.document);return o.setCustomProperty("$fullPageDocument",n.ownerDocument.documentElement.outerHTML,s),t&&o.setCustomProperty("$fullPageDocType",t,s),i&&o.setCustomProperty("$fullPageXmlDeclaration",i,s),s}toData(e){let t=super.toData(e);const i=e.getCustomProperty("$fullPageDocument"),n=e.getCustomProperty("$fullPageDocType"),s=e.getCustomProperty("$fullPageXmlDeclaration");return i&&(t=i.replace(/<\/body\s*>/,t+"$&"),n&&(t=n+"\n"+t),s&&(t=s+"\n"+t)),t}}class LA extends Na{static get pluginName(){return"FullPage"}init(){const e=this.editor,t=["$fullPageDocument","$fullPageDocType","$fullPageXmlDeclaration"];e.data.processor=new MA(e.data.viewDocument),e.model.schema.extend("$root",{allowAttributes:t}),e.data.on("toModel",((i,[n])=>{const s=e.model.document.getRoot();e.model.change((e=>{for(const i of t){const t=n.getCustomProperty(i);t&&e.setAttribute(i,t,s)}}))}),{priority:"low"}),e.data.on("toView",((e,[i])=>{if(!i.is("rootElement"))return;const n=i,s=e.return;if(!n.hasAttribute("$fullPageDocument"))return;const o=new Hu(s.document);for(const e of t){const t=n.getAttribute(e);t&&o.setCustomProperty(e,t,s)}}),{priority:"low"}),e.data.on("set",(()=>{const i=e.model.document.getRoot();e.model.change((e=>{for(const n of t)i.hasAttribute(n)&&e.removeAttribute(n,i)}))}),{priority:"high"}),e.data.on("get",((e,t)=>{t[0]||(t[0]={}),t[0].trim=!1}),{priority:"high"})}}function NA(e){return e.createContainerElement("figure",{class:"image"},[e.createEmptyElement("img"),e.createSlot("children")])}function FA(e,t){const i=e.plugins.get("ImageUtils"),n=e.plugins.has("ImageInlineEditing")&&e.plugins.has("ImageBlockEditing");return e=>{if(!i.isInlineImageView(e))return null;if(!n)return s(e);return("block"==e.getStyle("display")||e.findAncestor(i.isBlockImageView)?"imageBlock":"imageInline")!==t?null:s(e)};function s(e){const t={name:!0};return e.hasAttribute("src")&&(t.attributes=["src"]),t}}function DA(e,t){const i=_a(t.getSelectedBlocks());return!i||e.isObject(i)||i.isEmpty&&"listItem"!=i.name?"imageBlock":"imageInline"}function zA(e){return e&&e.endsWith("px")?parseInt(e):null}function HA(e){const t=zA(e.getStyle("width")),i=zA(e.getStyle("height"));return!(!t||!i)}const $A=/^(image|image-inline)$/;class UA extends Na{static get pluginName(){return"ImageUtils"}isImage(e){return this.isInlineImage(e)||this.isBlockImage(e)}isInlineImageView(e){return!!e&&e.is("element","img")}isBlockImageView(e){return!!e&&e.is("element","figure")&&e.hasClass("image")}insertImage(e={},t=null,i=null,n={}){const s=this.editor,o=s.model,r=o.document.selection,a=WA(s,t||r,i);e={...Object.fromEntries(r.getAttributes()),...e};for(const t in e)o.schema.checkAttribute(a,t)||delete e[t];return o.change((i=>{const{setImageSizes:s=!0}=n,r=i.createElement(a,e);return o.insertObject(r,t,null,{setSelection:"on",findOptimalPosition:t||"imageInline"==a?void 0:"auto"}),r.parent?(s&&this.setImageNaturalSizeAttributes(r),r):null}))}setImageNaturalSizeAttributes(e){const t=e.getAttribute("src");t&&(e.getAttribute("width")||e.getAttribute("height")||this.editor.model.change((i=>{const n=new _r.window.Image;this._domEmitter.listenTo(n,"load",(()=>{e.getAttribute("width")||e.getAttribute("height")||this.editor.model.enqueueChange(i.batch,(t=>{t.setAttribute("width",n.naturalWidth,e),t.setAttribute("height",n.naturalHeight,e)})),this._domEmitter.stopListening(n,"load")})),n.src=t})))}getClosestSelectedImageWidget(e){const t=e.getFirstPosition();if(!t)return null;const i=e.getSelectedElement();if(i&&this.isImageWidget(i))return i;let n=t.parent;for(;n;){if(n.is("element")&&this.isImageWidget(n))return n;n=n.parent}return null}getClosestSelectedImageElement(e){const t=e.getSelectedElement();return this.isImage(t)?t:e.getFirstPosition().findAncestor("imageBlock")}getImageWidgetFromImageView(e){return e.findAncestor({classes:$A})}isImageAllowed(){const e=this.editor.model.document.selection;return function(e,t){const i=WA(e,t,null);if("imageBlock"==i){const i=function(e,t){const i=hy(e,t),n=i.start.parent;if(n.isEmpty&&!n.is("element","$root"))return n.parent;return n}(t,e.model);if(e.model.schema.checkChild(i,"imageBlock"))return!0}else if(e.model.schema.checkChild(t.focus,"imageInline"))return!0;return!1}(this.editor,e)&&function(e){return[...e.focus.getAncestors()].every((e=>!e.is("element","imageBlock")))}(e)}toImageWidget(e,t,i){t.setCustomProperty("image",!0,e);return sy(e,t,{label:()=>{const t=this.findViewImgElement(e).getAttribute("alt");return t?`${t} ${i}`:i}})}isImageWidget(e){return!!e.getCustomProperty("image")&&ny(e)}isBlockImage(e){return!!e&&e.is("element","imageBlock")}isInlineImage(e){return!!e&&e.is("element","imageInline")}findViewImgElement(e){if(this.isInlineImageView(e))return e;const t=this.editor.editing.view;for(const{item:i}of t.createRangeIn(e))if(this.isInlineImageView(i))return i}destroy(){return this._domEmitter.stopListening(),super.destroy()}constructor(...e){super(...e),this._domEmitter=new(pr())}}function WA(e,t,i){const n=e.model.schema,s=e.config.get("image.insert.type");return e.plugins.has("ImageBlockEditing")?e.plugins.has("ImageInlineEditing")?i||("inline"===s?"imageInline":"auto"!==s?"imageBlock":t.is("selection")?DA(n,t):n.checkChild(t,"imageInline")?"imageInline":"imageBlock"):"imageBlock":"imageInline"}const jA=new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@!$&'()*+,;=%-]+/.source+/\.(jpg|jpeg|png|gif|ico|webp|JPG|JPEG|PNG|GIF|ICO|WEBP)/.source+/(\?[\w.~:/[\]@!$&'()*+,;=%-]*)?/.source+/(#[\w.~:/[\]@!$&'()*+,;=%-]*)?$/.source));class qA extends Na{static get requires(){return[Jy,UA,pC,Rw]}static get pluginName(){return"AutoImage"}init(){const e=this.editor,t=e.model.document,i=e.plugins.get("ClipboardPipeline");this.listenTo(i,"inputTransformation",(()=>{const e=t.selection.getFirstRange(),i=eu.fromPosition(e.start);i.stickiness="toPrevious";const n=eu.fromPosition(e.end);n.stickiness="toNext",t.once("change:data",(()=>{this._embedImageBetweenPositions(i,n),i.detach(),n.detach()}),{priority:"high"})})),e.commands.get("undo").on("execute",(()=>{this._timeoutId&&(_r.window.clearTimeout(this._timeoutId),this._positionToInsert.detach(),this._timeoutId=null,this._positionToInsert=null)}),{priority:"high"})}_embedImageBetweenPositions(e,t){const i=this.editor,n=new pd(e,t),s=n.getWalker({ignoreElementEnd:!0}),o=Object.fromEntries(i.model.document.selection.getAttributes()),r=this.editor.plugins.get("ImageUtils");let a="";for(const e of s)e.item.is("$textProxy")&&(a+=e.item.data);a=a.trim(),a.match(jA)?(this._positionToInsert=eu.fromPosition(e),this._timeoutId=setTimeout((()=>{if(!i.commands.get("insertImage").isEnabled)return void n.detach();i.model.change((e=>{let t;this._timeoutId=null,e.remove(n),n.detach(),"$graveyard"!==this._positionToInsert.root.rootName&&(t=this._positionToInsert.toPosition()),r.insertImage({...o,src:a},t),this._positionToInsert.detach(),this._positionToInsert=null}));i.plugins.get("Delete").requestUndoOnBackspace()}),100)):n.detach()}constructor(e){super(e),this._timeoutId=null,this._positionToInsert=null}}class GA extends Da{refresh(){const e=this.editor.plugins.get("ImageUtils").getClosestSelectedImageElement(this.editor.model.document.selection);this.isEnabled=!!e,this.isEnabled&&e.hasAttribute("alt")?this.value=e.getAttribute("alt"):this.value=!1}execute(e){const t=this.editor,i=t.plugins.get("ImageUtils"),n=t.model,s=i.getClosestSelectedImageElement(n.document.selection);n.change((t=>{t.setAttribute("alt",e.newValue,s)}))}}class KA extends Na{static get requires(){return[UA]}static get pluginName(){return"ImageTextAlternativeEditing"}init(){this.editor.commands.add("imageTextAlternative",new GA(this.editor))}}class ZA extends Tg{render(){super.render(),this.keystrokes.listenTo(this.element),Vg({view:this}),[this.labeledInput,this.saveButtonView,this.cancelButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)}))}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}_createButton(e,t,i,n){const s=new Hg(this.locale);return s.set({label:e,icon:t,tooltip:!0}),s.extendTemplate({attributes:{class:i}}),n&&s.delegate("execute").to(this,n),s}_createLabeledInputView(){const e=this.locale.t,t=new bf(this.locale,Qf);return t.label=e("Text alternative"),t}constructor(e){super(e);const t=this.locale.t;this.focusTracker=new ya,this.keystrokes=new ka,this.labeledInput=this._createLabeledInputView(),this.saveButtonView=this._createButton(t("Save"),Dm.check,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(t("Cancel"),Dm.cancel,"ck-button-cancel","cancel"),this._focusables=new og,this._focusCycler=new Tf({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"form",attributes:{class:["ck","ck-text-alternative-form","ck-responsive-form"],tabindex:"-1"},children:[this.labeledInput,this.saveButtonView,this.cancelButtonView]})}}function JA(e){const t=e.editing.view,i=Xp.defaultPositions,n=e.plugins.get("ImageUtils");return{target:t.domConverter.mapViewToDom(n.getClosestSelectedImageWidget(t.document.selection)),positions:[i.northArrowSouth,i.northArrowSouthWest,i.northArrowSouthEast,i.southArrowNorth,i.southArrowNorthWest,i.southArrowNorthEast,i.viewportStickyNorth]}}class QA extends Na{static get requires(){return[Tb]}static get pluginName(){return"ImageTextAlternativeUI"}init(){this._createButton()}destroy(){super.destroy(),this._form&&this._form.destroy()}_createButton(){const e=this.editor,t=e.t;e.ui.componentFactory.add("imageTextAlternative",(i=>{const n=e.commands.get("imageTextAlternative"),s=new Hg(i);return s.set({label:t("Change image text alternative"),icon:Dm.textAlternative,tooltip:!0}),s.bind("isEnabled").to(n,"isEnabled"),s.bind("isOn").to(n,"value",(e=>!!e)),this.listenTo(s,"execute",(()=>{this._showForm()})),s}))}_createForm(){const e=this.editor,t=e.editing.view.document,i=e.plugins.get("ImageUtils");this._balloon=this.editor.plugins.get("ContextualBalloon"),this._form=new(Pg(ZA))(e.locale),this._form.render(),this.listenTo(this._form,"submit",(()=>{e.execute("imageTextAlternative",{newValue:this._form.labeledInput.fieldView.element.value}),this._hideForm(!0)})),this.listenTo(this._form,"cancel",(()=>{this._hideForm(!0)})),this._form.keystrokes.set("Esc",((e,t)=>{this._hideForm(!0),t()})),this.listenTo(e.ui,"update",(()=>{i.getClosestSelectedImageWidget(t.selection)?this._isVisible&&function(e){const t=e.plugins.get("ContextualBalloon");if(e.plugins.get("ImageUtils").getClosestSelectedImageWidget(e.editing.view.document.selection)){const i=JA(e);t.updatePosition(i)}}(e):this._hideForm(!0)})),Sg({emitter:this._form,activator:()=>this._isVisible,contextElements:()=>[this._balloon.view.element],callback:()=>this._hideForm()})}_showForm(){if(this._isVisible)return;this._form||this._createForm();const e=this.editor,t=e.commands.get("imageTextAlternative"),i=this._form.labeledInput;this._form.disableCssTransitions(),this._isInBalloon||this._balloon.add({view:this._form,position:JA(e)}),i.fieldView.value=i.fieldView.element.value=t.value||"",this._form.labeledInput.fieldView.select(),this._form.enableCssTransitions()}_hideForm(e=!1){this._isInBalloon&&(this._form.focusTracker.isFocused&&this._form.saveButtonView.focus(),this._balloon.remove(this._form),e&&this.editor.editing.view.focus())}get _isVisible(){return!!this._balloon&&this._balloon.visibleView===this._form}get _isInBalloon(){return!!this._balloon&&this._balloon.hasView(this._form)}}class YA extends Na{static get requires(){return[KA,QA]}static get pluginName(){return"ImageTextAlternative"}}function XA(e,t){const i=(t,i,n)=>{if(!n.consumable.consume(i.item,t.name))return;const s=n.writer,o=n.mapper.toViewElement(i.item),r=e.findViewImgElement(o);null===i.attributeNewValue?(s.removeAttribute("srcset",r),s.removeAttribute("sizes",r)):i.attributeNewValue&&(s.setAttribute("srcset",i.attributeNewValue,r),s.setAttribute("sizes","100vw",r))};return e=>{e.on(`attribute:srcset:${t}`,i)}}function eE(e,t,i){const n=(t,i,n)=>{if(!n.consumable.consume(i.item,t.name))return;const s=n.writer,o=n.mapper.toViewElement(i.item),r=e.findViewImgElement(o);s.setAttribute(i.attributeKey,i.attributeNewValue||"",r)};return e=>{e.on(`attribute:${i}:${t}`,n)}}class tE extends Ec{observe(e){this.listenTo(e,"load",((e,t)=>{const i=t.target;this.checkShouldIgnoreEventFromTarget(i)||"IMG"==i.tagName&&this._fireEvents(t)}),{useCapture:!0})}stopObserving(e){this.stopListening(e)}_fireEvents(e){this.isEnabled&&(this.document.fire("layoutChanged"),this.document.fire("imageLoaded",e))}}class iE extends Da{refresh(){const e=this.editor.plugins.get("ImageUtils");this.isEnabled=e.isImageAllowed()}execute(e){const t=pa(e.source),i=this.editor.model.document.selection,n=this.editor.plugins.get("ImageUtils"),s=Object.fromEntries(i.getAttributes());t.forEach(((e,t)=>{const o=i.getSelectedElement();if("string"==typeof e&&(e={src:e}),t&&o&&n.isImage(o)){const t=this.editor.model.createPositionAfter(o);n.insertImage({...e,...s},t)}else n.insertImage({...e,...s})}))}constructor(e){super(e);const t=e.config.get("image.insert.type");e.plugins.has("ImageBlockEditing")||"block"===t&&b("image-block-plugin-required"),e.plugins.has("ImageInlineEditing")||"inline"===t&&b("image-inline-plugin-required")}}class nE extends Da{refresh(){const e=this.editor.plugins.get("ImageUtils"),t=this.editor.model.document.selection.getSelectedElement();this.isEnabled=e.isImage(t),this.value=this.isEnabled?t.getAttribute("src"):null}execute(e){const t=this.editor.model.document.selection.getSelectedElement(),i=this.editor.plugins.get("ImageUtils");this.editor.model.change((n=>{n.setAttribute("src",e.source,t),this.cleanupImage(n,t),i.setImageNaturalSizeAttributes(t)}))}cleanupImage(e,t){e.removeAttribute("srcset",t),e.removeAttribute("sizes",t),e.removeAttribute("sources",t),e.removeAttribute("width",t),e.removeAttribute("height",t),e.removeAttribute("alt",t)}constructor(e){super(e),this.decorate("cleanupImage")}}class sE extends Na{static get requires(){return[UA]}static get pluginName(){return"ImageEditing"}init(){const e=this.editor,t=e.conversion;e.editing.view.addObserver(tE),t.for("upcast").attributeToAttribute({view:{name:"img",key:"alt"},model:"alt"}).attributeToAttribute({view:{name:"img",key:"srcset"},model:"srcset"});const i=new iE(e),n=new nE(e);e.commands.add("insertImage",i),e.commands.add("replaceImageSource",n),e.commands.add("imageInsert",i)}}class oE extends Na{static get requires(){return[UA]}static get pluginName(){return"ImageSizeAttributes"}afterInit(){this._registerSchema(),this._registerConverters("imageBlock"),this._registerConverters("imageInline")}_registerSchema(){this.editor.plugins.has("ImageBlockEditing")&&this.editor.model.schema.extend("imageBlock",{allowAttributes:["width","height"]}),this.editor.plugins.has("ImageInlineEditing")&&this.editor.model.schema.extend("imageInline",{allowAttributes:["width","height"]})}_registerConverters(e){const t=this.editor,i=t.plugins.get("ImageUtils"),n="imageBlock"===e?"figure":"img";function s(t,n,s,o){t.on(`attribute:${n}:${e}`,((t,n,r)=>{if(!r.consumable.consume(n.item,t.name))return;const a=r.writer,l=r.mapper.toViewElement(n.item),c=i.findViewImgElement(l);if(null!==n.attributeNewValue?a.setAttribute(s,n.attributeNewValue,c):a.removeAttribute(s,c),n.item.hasAttribute("sources"))return;const d=n.item.hasAttribute("resizedWidth");if("imageInline"===e&&!d&&!o)return;const h=n.item.getAttribute("width"),u=n.item.getAttribute("height");h&&u&&a.setStyle("aspect-ratio",`${h}/${u}`,c)}))}t.conversion.for("upcast").attributeToAttribute({view:{name:n,styles:{width:/.+/}},model:{key:"width",value:e=>HA(e)?zA(e.getStyle("width")):null}}).attributeToAttribute({view:{name:n,key:"width"},model:"width"}).attributeToAttribute({view:{name:n,styles:{height:/.+/}},model:{key:"height",value:e=>HA(e)?zA(e.getStyle("height")):null}}).attributeToAttribute({view:{name:n,key:"height"},model:"height"}),t.conversion.for("editingDowncast").add((e=>{s(e,"width","width",!0),s(e,"height","height",!0)})),t.conversion.for("dataDowncast").add((e=>{s(e,"width","width",!1),s(e,"height","height",!1)}))}}class rE extends Da{refresh(){const e=this.editor.plugins.get("ImageUtils"),t=e.getClosestSelectedImageElement(this.editor.model.document.selection);"imageBlock"===this._modelElementName?this.isEnabled=e.isInlineImage(t):this.isEnabled=e.isBlockImage(t)}execute(e={}){const t=this.editor,i=this.editor.model,n=t.plugins.get("ImageUtils"),s=n.getClosestSelectedImageElement(i.document.selection),o=Object.fromEntries(s.getAttributes());return o.src||o.uploadId?i.change((t=>{const{setImageSizes:r=!0}=e,a=Array.from(i.markers).filter((e=>e.getRange().containsItem(s))),l=n.insertImage(o,i.createSelection(s,"on"),this._modelElementName,{setImageSizes:r});if(!l)return null;const c=t.createRangeOn(l);for(const e of a){const i=e.getRange(),n="$graveyard"!=i.root.rootName?i.getJoined(c,!0):c;t.updateMarker(e,{range:n})}return{oldElement:s,newElement:l}})):null}constructor(e,t){super(e),this._modelElementName=t}}class aE extends Na{static get requires(){return[UA]}static get pluginName(){return"ImagePlaceholder"}afterInit(){this._setupSchema(),this._setupConversion(),this._setupLoadListener()}_setupSchema(){const e=this.editor.model.schema;e.isRegistered("imageBlock")&&e.extend("imageBlock",{allowAttributes:["placeholder"]}),e.isRegistered("imageInline")&&e.extend("imageInline",{allowAttributes:["placeholder"]})}_setupConversion(){const e=this.editor,t=e.conversion,i=e.plugins.get("ImageUtils");t.for("editingDowncast").add((e=>{e.on("attribute:placeholder",((e,t,n)=>{if(!n.consumable.test(t.item,e.name))return;if(!t.item.is("element","imageBlock")&&!t.item.is("element","imageInline"))return;n.consumable.consume(t.item,e.name);const s=n.writer,o=n.mapper.toViewElement(t.item),r=i.findViewImgElement(o);t.attributeNewValue?(s.addClass("image_placeholder",r),s.setStyle("background-image",`url(${t.attributeNewValue})`,r),s.setCustomProperty("editingPipeline:doNotReuseOnce",!0,r)):(s.removeClass("image_placeholder",r),s.removeStyle("background-image",r))}))}))}_setupLoadListener(){const e=this.editor,t=e.model,i=e.editing,n=i.view,s=e.plugins.get("ImageUtils");n.addObserver(tE),this.listenTo(n.document,"imageLoaded",((e,o)=>{const r=n.domConverter.mapDomToView(o.target);if(!r)return;const a=s.getImageWidgetFromImageView(r);if(!a)return;const l=i.mapper.toModelElement(a);l&&l.hasAttribute("placeholder")&&t.enqueueChange({isUndoable:!1},(e=>{e.removeAttribute("placeholder",l)}))}))}}class lE extends Na{static get requires(){return[sE,oE,UA,aE,Z_]}static get pluginName(){return"ImageBlockEditing"}init(){const e=this.editor;e.model.schema.register("imageBlock",{inheritAllFrom:"$blockObject",allowAttributes:["alt","src","srcset"]}),this._setupConversion(),e.plugins.has("ImageInlineEditing")&&(e.commands.add("imageTypeBlock",new rE(this.editor,"imageBlock")),this._setupClipboardIntegration())}_setupConversion(){const e=this.editor,t=e.t,i=e.conversion,n=e.plugins.get("ImageUtils");i.for("dataDowncast").elementToStructure({model:"imageBlock",view:(e,{writer:t})=>NA(t)}),i.for("editingDowncast").elementToStructure({model:"imageBlock",view:(e,{writer:i})=>n.toImageWidget(NA(i),i,t("image widget"))}),i.for("downcast").add(eE(n,"imageBlock","src")).add(eE(n,"imageBlock","alt")).add(XA(n,"imageBlock")),i.for("upcast").elementToElement({view:FA(e,"imageBlock"),model:(e,{writer:t})=>t.createElement("imageBlock",e.hasAttribute("src")?{src:e.getAttribute("src")}:void 0)}).add(function(e){const t=(t,i,n)=>{if(!n.consumable.test(i.viewItem,{name:!0,classes:"image"}))return;const s=e.findViewImgElement(i.viewItem);if(!s||!n.consumable.test(s,{name:!0}))return;n.consumable.consume(i.viewItem,{name:!0,classes:"image"});const o=_a(n.convertItem(s,i.modelCursor).modelRange.getItems());o?(n.convertChildren(i.viewItem,o),n.updateConversionResult(o,i)):n.consumable.revert(i.viewItem,{name:!0,classes:"image"})};return e=>{e.on("element:figure",t)}}(n))}_setupClipboardIntegration(){const e=this.editor,t=e.model,i=e.editing.view,n=e.plugins.get("ImageUtils"),s=e.plugins.get("ClipboardPipeline");this.listenTo(s,"inputTransformation",((s,o)=>{const r=Array.from(o.content.getChildren());let a;if(!r.every(n.isInlineImageView))return;a=o.targetRanges?e.editing.mapper.toModelRange(o.targetRanges[0]):t.document.selection.getFirstRange();const l=t.createSelection(a);if("imageBlock"===DA(t.schema,l)){const e=new Hu(i.document),t=r.map((t=>e.createElement("figure",{class:"image"},t)));o.content=e.createDocumentFragment(t)}})),this.listenTo(s,"contentInsertion",((e,i)=>{"paste"===i.method&&t.change((e=>{const t=e.createRangeIn(i.content);for(const e of t.getItems())e.is("element","imageBlock")&&n.setImageNaturalSizeAttributes(e)}))}))}}class cE extends Tg{render(){super.render(),Vg({view:this});for(const e of this._focusables)this.focusTracker.add(e.element);this.keystrokes.listenTo(this.element);const e=e=>e.stopPropagation();this.keystrokes.set("arrowright",e),this.keystrokes.set("arrowleft",e),this.keystrokes.set("arrowup",e),this.keystrokes.set("arrowdown",e)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}constructor(e,t=[]){super(e),this.focusTracker=new ya,this.keystrokes=new ka,this._focusables=new og,this.children=this.createCollection(),this._focusCycler=new Tf({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}});for(const e of t)this.children.add(e),this._focusables.add(e),e instanceof qg&&this._focusables.addMany(e.children);if(this._focusables.length>1)for(const e of this._focusables)dE(e)&&(e.focusCycler.on("forwardCycle",(e=>{this._focusCycler.focusNext(),e.stop()})),e.focusCycler.on("backwardCycle",(e=>{this._focusCycler.focusPrevious(),e.stop()})));this.setTemplate({tag:"form",attributes:{class:["ck","ck-image-insert-form"],tabindex:-1},children:this.children})}}function dE(e){return"focusCycler"in e}class hE extends Na{static get pluginName(){return"ImageInsertUI"}static get requires(){return[UA]}init(){const e=this.editor,t=e.model.document.selection,i=e.plugins.get("ImageUtils");this.set("isImageSelected",!1),this.listenTo(e.model.document,"change",(()=>{this.isImageSelected=i.isImage(t.getSelectedElement())}));const n=e=>this._createToolbarComponent(e);e.ui.componentFactory.add("insertImage",n),e.ui.componentFactory.add("imageInsert",n)}registerIntegration({name:e,observable:t,buttonViewCreator:i,formViewCreator:n,requiresForm:s}){this._integrations.has(e)&&b("image-insert-integration-exists",{name:e}),this._integrations.set(e,{observable:t,buttonViewCreator:i,formViewCreator:n,requiresForm:!!s})}_createToolbarComponent(e){const t=this.editor,i=e.t,n=this._prepareIntegrations();if(!n.length)return null;let s;const o=n[0];if(1==n.length){if(!o.requiresForm)return o.buttonViewCreator(!0);s=o.buttonViewCreator(!0)}else{const t=o.buttonViewCreator(!1);s=new Uf(e,t),s.tooltip=!0,s.bind("label").to(this,"isImageSelected",(e=>i(e?"Replace image":"Insert image")))}const r=this.dropdownView=Wf(e,s),a=n.map((({observable:e})=>"function"==typeof e?e():e));return r.bind("isEnabled").toMany(a,"isEnabled",((...e)=>e.some((e=>e)))),r.once("change:isOpen",(()=>{const e=n.map((({formViewCreator:e})=>e(1==n.length))),i=new cE(t.locale,e);r.panelView.children.add(i)})),r}_prepareIntegrations(){const e=this.editor.config.get("image.insert.integrations"),t=[];if(!e.length)return b("image-insert-integrations-not-specified"),t;for(const i of e)this._integrations.has(i)?t.push(this._integrations.get(i)):["upload","assetManager","url"].includes(i)||b("image-insert-unknown-integration",{item:i});return t.length||b("image-insert-integrations-not-registered"),t}constructor(e){super(e),this._integrations=new Map,e.config.define("image.insert.integrations",["upload","assetManager","url"])}}class uE extends Na{static get requires(){return[lE,Ey,YA,hE]}static get pluginName(){return"ImageBlock"}}class mE extends Na{static get requires(){return[sE,oE,UA,aE,Z_]}static get pluginName(){return"ImageInlineEditing"}init(){const e=this.editor,t=e.model.schema;t.register("imageInline",{inheritAllFrom:"$inlineObject",allowAttributes:["alt","src","srcset"]}),t.addChildCheck(((e,t)=>{if(e.endsWith("caption")&&"imageInline"===t.name)return!1})),this._setupConversion(),e.plugins.has("ImageBlockEditing")&&(e.commands.add("imageTypeInline",new rE(this.editor,"imageInline")),this._setupClipboardIntegration())}_setupConversion(){const e=this.editor,t=e.t,i=e.conversion,n=e.plugins.get("ImageUtils");i.for("dataDowncast").elementToElement({model:"imageInline",view:(e,{writer:t})=>t.createEmptyElement("img")}),i.for("editingDowncast").elementToStructure({model:"imageInline",view:(e,{writer:i})=>n.toImageWidget(function(e){return e.createContainerElement("span",{class:"image-inline"},e.createEmptyElement("img"))}(i),i,t("image widget"))}),i.for("downcast").add(eE(n,"imageInline","src")).add(eE(n,"imageInline","alt")).add(XA(n,"imageInline")),i.for("upcast").elementToElement({view:FA(e,"imageInline"),model:(e,{writer:t})=>t.createElement("imageInline",e.hasAttribute("src")?{src:e.getAttribute("src")}:void 0)})}_setupClipboardIntegration(){const e=this.editor,t=e.model,i=e.editing.view,n=e.plugins.get("ImageUtils"),s=e.plugins.get("ClipboardPipeline");this.listenTo(s,"inputTransformation",((s,o)=>{const r=Array.from(o.content.getChildren());let a;if(!r.every(n.isBlockImageView))return;a=o.targetRanges?e.editing.mapper.toModelRange(o.targetRanges[0]):t.document.selection.getFirstRange();const l=t.createSelection(a);if("imageInline"===DA(t.schema,l)){const e=new Hu(i.document),t=r.map((t=>1===t.childCount?(Array.from(t.getAttributes()).forEach((i=>e.setAttribute(...i,n.findViewImgElement(t)))),t.getChild(0)):t));o.content=e.createDocumentFragment(t)}})),this.listenTo(s,"contentInsertion",((e,i)=>{"paste"===i.method&&t.change((e=>{const t=e.createRangeIn(i.content);for(const e of t.getItems())e.is("element","imageInline")&&n.setImageNaturalSizeAttributes(e)}))}))}}class gE extends Na{static get requires(){return[mE,Ey,YA,hE]}static get pluginName(){return"ImageInline"}}class fE extends Na{static get requires(){return[uE,gE]}static get pluginName(){return"Image"}}class pE extends Na{static get pluginName(){return"ImageCaptionUtils"}static get requires(){return[UA]}getCaptionFromImageModelElement(e){for(const t of e.getChildren())if(t&&t.is("element","caption"))return t;return null}getCaptionFromModelSelection(e){const t=this.editor.plugins.get("ImageUtils"),i=e.getFirstPosition().findAncestor("caption");return i&&t.isBlockImage(i.parent)?i:null}matchImageCaptionViewElement(e){const t=this.editor.plugins.get("ImageUtils");return"figcaption"==e.name&&t.isBlockImageView(e.parent)?{name:!0}:null}}class bE extends Da{refresh(){const e=this.editor,t=e.plugins.get("ImageCaptionUtils"),i=e.plugins.get("ImageUtils");if(!e.plugins.has(lE))return this.isEnabled=!1,void(this.value=!1);const n=e.model.document.selection,s=n.getSelectedElement();if(!s){const e=t.getCaptionFromModelSelection(n);return this.isEnabled=!!e,void(this.value=!!e)}this.isEnabled=i.isImage(s),this.isEnabled?this.value=!!t.getCaptionFromImageModelElement(s):this.value=!1}execute(e={}){const{focusCaptionOnShow:t}=e;this.editor.model.change((e=>{this.value?this._hideImageCaption(e):this._showImageCaption(e,t)}))}_showImageCaption(e,t){const i=this.editor.model.document.selection,n=this.editor.plugins.get("ImageCaptionEditing"),s=this.editor.plugins.get("ImageUtils");let o=i.getSelectedElement();const r=n._getSavedCaption(o);s.isInlineImage(o)&&(this.editor.execute("imageTypeBlock"),o=i.getSelectedElement());const a=r||e.createElement("caption");e.append(a,o),t&&e.setSelection(a,"in")}_hideImageCaption(e){const t=this.editor,i=t.model.document.selection,n=t.plugins.get("ImageCaptionEditing"),s=t.plugins.get("ImageCaptionUtils");let o,r=i.getSelectedElement();r?o=s.getCaptionFromImageModelElement(r):(o=s.getCaptionFromModelSelection(i),r=o.parent),n._saveCaption(r,o),e.setSelection(r,"on"),e.remove(o)}}class wE extends Na{static get requires(){return[UA,pE]}static get pluginName(){return"ImageCaptionEditing"}init(){const e=this.editor,t=e.model.schema;t.isRegistered("caption")?t.extend("caption",{allowIn:"imageBlock"}):t.register("caption",{allowIn:"imageBlock",allowContentOf:"$block",isLimit:!0}),e.commands.add("toggleImageCaption",new bE(this.editor)),this._setupConversion(),this._setupImageTypeCommandsIntegration(),this._registerCaptionReconversion()}_setupConversion(){const e=this.editor,t=e.editing.view,i=e.plugins.get("ImageUtils"),n=e.plugins.get("ImageCaptionUtils"),s=e.t;e.conversion.for("upcast").elementToElement({view:e=>n.matchImageCaptionViewElement(e),model:"caption"}),e.conversion.for("dataDowncast").elementToElement({model:"caption",view:(e,{writer:t})=>i.isBlockImage(e.parent)?t.createContainerElement("figcaption"):null}),e.conversion.for("editingDowncast").elementToElement({model:"caption",view:(e,{writer:n})=>{if(!i.isBlockImage(e.parent))return null;const o=n.createEditableElement("figcaption");n.setCustomProperty("imageCaption",!0,o),o.placeholder=s("Enter image caption"),Ga({view:t,element:o,keepOnFocus:!0});const r=e.parent.getAttribute("alt");return dy(o,n,{label:r?s("Caption for image: %0",[r]):s("Caption for the image")})}})}_setupImageTypeCommandsIntegration(){const e=this.editor,t=e.plugins.get("ImageUtils"),i=e.plugins.get("ImageCaptionUtils"),n=e.commands.get("imageTypeInline"),s=e.commands.get("imageTypeBlock"),o=e=>{if(!e.return)return;const{oldElement:n,newElement:s}=e.return;if(!n)return;if(t.isBlockImage(n)){const e=i.getCaptionFromImageModelElement(n);if(e)return void this._saveCaption(s,e)}const o=this._getSavedCaption(n);o&&this._saveCaption(s,o)};n&&this.listenTo(n,"execute",o,{priority:"low"}),s&&this.listenTo(s,"execute",o,{priority:"low"})}_getSavedCaption(e){const t=this._savedCaptionsMap.get(e);return t?Gc.fromJSON(t):null}_saveCaption(e,t){this._savedCaptionsMap.set(e,t.toJSON())}_registerCaptionReconversion(){const e=this.editor,t=e.model,i=e.plugins.get("ImageUtils"),n=e.plugins.get("ImageCaptionUtils");t.document.on("change:data",(()=>{const s=t.document.differ.getChanges();for(const t of s){if("alt"!==t.attributeKey)continue;const s=t.range.start.nodeAfter;if(i.isBlockImage(s)){const t=n.getCaptionFromImageModelElement(s);if(!t)return;e.editing.reconvertItem(t)}}}))}constructor(e){super(e),this._savedCaptionsMap=new WeakMap}}class vE extends Na{static get requires(){return[pE]}static get pluginName(){return"ImageCaptionUI"}init(){const e=this.editor,t=e.editing.view,i=e.plugins.get("ImageCaptionUtils"),n=e.t;e.ui.componentFactory.add("toggleImageCaption",(s=>{const o=e.commands.get("toggleImageCaption"),r=new Hg(s);return r.set({icon:Dm.caption,tooltip:!0,isToggleable:!0}),r.bind("isOn","isEnabled").to(o,"value","isEnabled"),r.bind("label").to(o,"value",(e=>n(e?"Toggle caption off":"Toggle caption on"))),this.listenTo(r,"execute",(()=>{e.execute("toggleImageCaption",{focusCaptionOnShow:!0});const n=i.getCaptionFromModelSelection(e.model.document.selection);if(n){const i=e.editing.mapper.toViewElement(n);t.scrollToTheSelection(),t.change((e=>{e.addClass("image__caption_highlighted",i)}))}e.editing.view.focus()})),r}))}}class _E extends Na{static get requires(){return[wE,vE]}static get pluginName(){return"ImageCaption"}}function yE(e){const t=e.map((e=>e.replace("+","\\+")));return new RegExp(`^image\\/(${t.join("|")})$`)}function kE(e){return new Promise(((t,i)=>{const n=e.getAttribute("src");fetch(n).then((e=>e.blob())).then((e=>{const i=CE(e,n),s=i.replace("image/",""),o=new File([e],`image.${s}`,{type:i});t(o)})).catch((e=>e&&"TypeError"===e.name?function(e){return function(e){return new Promise(((t,i)=>{const n=_r.document.createElement("img");n.addEventListener("load",(()=>{const e=_r.document.createElement("canvas");e.width=n.width,e.height=n.height;e.getContext("2d").drawImage(n,0,0),e.toBlob((e=>e?t(e):i()))})),n.addEventListener("error",(()=>i())),n.src=e}))}(e).then((t=>{const i=CE(t,e),n=i.replace("image/","");return new File([t],`image.${n}`,{type:i})}))}(n).then(t).catch(i):i(e)))}))}function CE(e,t){return e.type?e.type:t.match(/data:(image\/\w+);base64/)?t.match(/data:(image\/\w+);base64/)[1].toLowerCase():"image/jpeg"}class xE extends Na{static get pluginName(){return"ImageUploadUI"}init(){const e=this.editor,t=e.t,i=()=>{const e=this._createButton(Ug);return e.set({label:t("Upload image from computer"),tooltip:!0}),e};if(e.ui.componentFactory.add("uploadImage",i),e.ui.componentFactory.add("imageUpload",i),e.ui.componentFactory.add("menuBar:uploadImage",(()=>{const e=this._createButton(mw);return e.label=t("Image from computer"),e})),e.plugins.has("ImageInsertUI")){const i=e.plugins.get("ImageInsertUI");i.registerIntegration({name:"upload",observable:()=>e.commands.get("uploadImage"),buttonViewCreator:()=>{const n=e.ui.componentFactory.create("uploadImage");return n.bind("label").to(i,"isImageSelected",(e=>t(e?"Replace image from computer":"Upload image from computer"))),n},formViewCreator:()=>{const n=e.ui.componentFactory.create("uploadImage");return n.withText=!0,n.bind("label").to(i,"isImageSelected",(e=>t(e?"Replace from computer":"Upload from computer"))),n.on("execute",(()=>{i.dropdownView.isOpen=!1})),n}})}}_createButton(e){const t=this.editor,i=t.locale,n=t.commands.get("uploadImage"),s=t.config.get("image.upload.types"),o=yE(s),r=new e(t.locale),a=i.t;return r.set({acceptedType:s.map((e=>`image/${e}`)).join(","),allowMultipleFiles:!0,label:a("Upload image from computer"),icon:Dm.imageUpload}),r.bind("isEnabled").to(n),r.on("done",((e,i)=>{const n=Array.from(i).filter((e=>o.test(e.type)));n.length&&(t.execute("uploadImage",{file:n}),t.editing.view.focus())})),r}}class AE extends Na{static get pluginName(){return"ImageUploadProgress"}init(){const e=this.editor;e.plugins.has("ImageBlockEditing")&&e.editing.downcastDispatcher.on("attribute:uploadStatus:imageBlock",this.uploadStatusChange),e.plugins.has("ImageInlineEditing")&&e.editing.downcastDispatcher.on("attribute:uploadStatus:imageInline",this.uploadStatusChange)}constructor(e){super(e),this.uploadStatusChange=(e,t,i)=>{const n=this.editor,s=t.item,o=s.getAttribute("uploadId");if(!i.consumable.consume(t.item,e.name))return;const r=n.plugins.get("ImageUtils"),a=n.plugins.get(Hm),l=o?t.attributeNewValue:null,c=this.placeholder,d=n.editing.mapper.toViewElement(s),h=i.writer;if("reading"==l)return EE(d,h),void TE(r,c,d,h);if("uploading"==l){const e=a.loaders.get(o);return EE(d,h),void(e?(SE(d,h),function(e,t,i,n){const s=function(e){const t=e.createUIElement("div",{class:"ck-progress-bar"});return e.setCustomProperty("progressBar",!0,t),t}(t);t.insert(t.createPositionAt(e,"end"),s),i.on("change:uploadedPercent",((e,t,i)=>{n.change((e=>{e.setStyle("width",i+"%",s)}))}))}(d,h,e,n.editing.view),function(e,t,i,n){if(n.data){const s=e.findViewImgElement(t);i.setAttribute("src",n.data,s)}}(r,d,h,e)):TE(r,c,d,h))}"complete"==l&&a.loaders.get(o)&&function(e,t,i){const n=t.createUIElement("div",{class:"ck-image-upload-complete-icon"});t.insert(t.createPositionAt(e,"end"),n),setTimeout((()=>{i.change((e=>e.remove(e.createRangeOn(n))))}),3e3)}(d,h,n.editing.view),function(e,t){PE(e,t,"progressBar")}(d,h),SE(d,h),function(e,t){t.removeClass("ck-appear",e)}(d,h)},this.placeholder="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="}}function EE(e,t){e.hasClass("ck-appear")||t.addClass("ck-appear",e)}function TE(e,t,i,n){i.hasClass("ck-image-upload-placeholder")||n.addClass("ck-image-upload-placeholder",i);const s=e.findViewImgElement(i);s.getAttribute("src")!==t&&n.setAttribute("src",t,s),IE(i,"placeholder")||n.insert(n.createPositionAfter(s),function(e){const t=e.createUIElement("div",{class:"ck-upload-placeholder-loader"});return e.setCustomProperty("placeholder",!0,t),t}(n))}function SE(e,t){e.hasClass("ck-image-upload-placeholder")&&t.removeClass("ck-image-upload-placeholder",e),PE(e,t,"placeholder")}function IE(e,t){for(const i of e.getChildren())if(i.getCustomProperty(t))return i}function PE(e,t,i){const n=IE(e,i);n&&t.remove(t.createRangeOn(n))}class VE extends Da{refresh(){const e=this.editor,t=e.plugins.get("ImageUtils"),i=e.model.document.selection.getSelectedElement();this.isEnabled=t.isImageAllowed()||t.isImage(i)}execute(e){const t=pa(e.file),i=this.editor.model.document.selection,n=this.editor.plugins.get("ImageUtils"),s=Object.fromEntries(i.getAttributes());t.forEach(((e,t)=>{const o=i.getSelectedElement();if(t&&o&&n.isImage(o)){const t=this.editor.model.createPositionAfter(o);this._uploadImage(e,s,t)}else this._uploadImage(e,s)}))}_uploadImage(e,t,i){const n=this.editor,s=n.plugins.get(Hm).createLoader(e),o=n.plugins.get("ImageUtils");s&&o.insertImage({...t,uploadId:s.id},i)}}class RE extends Na{static get requires(){return[Hm,xb,Z_,UA]}static get pluginName(){return"ImageUploadEditing"}init(){const e=this.editor,t=e.model.document,i=e.conversion,n=e.plugins.get(Hm),s=e.plugins.get("ImageUtils"),o=e.plugins.get("ClipboardPipeline"),r=yE(e.config.get("image.upload.types")),a=new VE(e);e.commands.add("uploadImage",a),e.commands.add("imageUpload",a),i.for("upcast").attributeToAttribute({view:{name:"img",key:"uploadId"},model:"uploadId"}),this.listenTo(e.editing.view.document,"clipboardInput",((t,i)=>{if(n=i.dataTransfer,Array.from(n.types).includes("text/html")&&""!==n.getData("text/html"))return;var n;const s=Array.from(i.dataTransfer.files).filter((e=>!!e&&r.test(e.type)));s.length&&(t.stop(),e.model.change((t=>{i.targetRanges&&t.setSelection(i.targetRanges.map((t=>e.editing.mapper.toModelRange(t)))),e.execute("uploadImage",{file:s})})))})),this.listenTo(o,"inputTransformation",((t,i)=>{const o=Array.from(e.editing.view.createRangeIn(i.content)).map((e=>e.item)).filter((e=>function(e,t){return!(!e.isInlineImageView(t)||!t.getAttribute("src")||!t.getAttribute("src").match(/^data:image\/\w+;base64,/g)&&!t.getAttribute("src").match(/^blob:/g))}(s,e)&&!e.getAttribute("uploadProcessed"))).map((e=>({promise:kE(e),imageElement:e})));if(!o.length)return;const r=new Hu(e.editing.view.document);for(const e of o){r.setAttribute("uploadProcessed",!0,e.imageElement);const t=n.createLoader(e.promise);t&&(r.setAttribute("src","",e.imageElement),r.setAttribute("uploadId",t.id,e.imageElement))}})),e.editing.view.document.on("dragover",((e,t)=>{t.preventDefault()})),t.on("change",(()=>{const i=t.differ.getChanges({includeChangesInGraveyard:!0}).reverse(),s=new Set;for(const t of i)if("insert"==t.type&&"$text"!=t.name){const i=t.position.nodeAfter,o="$graveyard"==t.position.root.rootName;for(const t of BE(e,i)){const e=t.getAttribute("uploadId");if(!e)continue;const i=n.loaders.get(e);i&&(o?s.has(e)||i.abort():(s.add(e),this._uploadImageElements.set(e,t),"idle"==i.status&&this._readAndUpload(i)))}}})),this.on("uploadComplete",((e,{imageElement:t,data:i})=>{const n=i.urls?i.urls:i;this.editor.model.change((e=>{e.setAttribute("src",n.default,t),this._parseAndSetSrcsetAttributeOnImage(n,t,e),s.setImageNaturalSizeAttributes(t)}))}),{priority:"low"})}afterInit(){const e=this.editor.model.schema;this.editor.plugins.has("ImageBlockEditing")&&e.extend("imageBlock",{allowAttributes:["uploadId","uploadStatus"]}),this.editor.plugins.has("ImageInlineEditing")&&e.extend("imageInline",{allowAttributes:["uploadId","uploadStatus"]})}_readAndUpload(e){const t=this.editor,n=t.model,s=t.locale.t,o=t.plugins.get(Hm),r=t.plugins.get(xb),a=t.plugins.get("ImageUtils"),l=this._uploadImageElements;return n.enqueueChange({isUndoable:!1},(t=>{t.setAttribute("uploadStatus","reading",l.get(e.id))})),e.read().then((()=>{const o=e.upload(),r=l.get(e.id);if(i.isSafari){const e=t.editing.mapper.toViewElement(r),i=a.findViewImgElement(e);t.editing.view.once("render",(()=>{if(!i.parent)return;const e=t.editing.view.domConverter.mapViewToDom(i.parent);if(!e)return;const n=e.style.display;e.style.display="none",e._ckHack=e.offsetHeight,e.style.display=n}))}return t.ui&&t.ui.ariaLiveAnnouncer.announce(s("Uploading image")),n.enqueueChange({isUndoable:!1},(e=>{e.setAttribute("uploadStatus","uploading",r)})),o})).then((i=>{n.enqueueChange({isUndoable:!1},(n=>{const o=l.get(e.id);n.setAttribute("uploadStatus","complete",o),t.ui&&t.ui.ariaLiveAnnouncer.announce(s("Image upload complete")),this.fire("uploadComplete",{data:i,imageElement:o})})),c()})).catch((i=>{if(t.ui&&t.ui.ariaLiveAnnouncer.announce(s("Error during image upload")),"error"!==e.status&&"aborted"!==e.status)throw i;"error"==e.status&&i&&r.showWarning(i,{title:s("Upload failed"),namespace:"upload"}),n.enqueueChange({isUndoable:!1},(t=>{t.remove(l.get(e.id))})),c()}));function c(){n.enqueueChange({isUndoable:!1},(t=>{const i=l.get(e.id);t.removeAttribute("uploadId",i),t.removeAttribute("uploadStatus",i),l.delete(e.id)})),o.destroyLoader(e)}}_parseAndSetSrcsetAttributeOnImage(e,t,i){let n=0;const s=Object.keys(e).filter((e=>{const t=parseInt(e,10);if(!isNaN(t))return n=Math.max(n,t),!0})).map((t=>`${e[t]} ${t}w`)).join(", ");if(""!=s){const e={srcset:s};t.hasAttribute("width")||t.hasAttribute("height")||(e.width=n),i.setAttributes(e,t)}}constructor(e){super(e),e.config.define("image",{upload:{types:["jpeg","png","gif","bmp","webp","tiff"]}}),this._uploadImageElements=new Map}}function BE(e,t){const i=e.plugins.get("ImageUtils");return Array.from(e.model.createRangeOn(t)).filter((e=>i.isImage(e.item))).map((e=>e.item))}class OE extends Na{static get pluginName(){return"ImageUpload"}static get requires(){return[RE,xE,AE]}}class ME extends Tg{render(){super.render();for(const e of this._focusables)this.focusTracker.add(e.element);this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}_createUrlInputView(){const e=this.locale,t=e.t,i=new bf(e,Qf);return i.bind("label").to(this,"isImageSelected",(e=>t(e?"Update image URL":"Insert image via URL"))),i.bind("isEnabled").to(this),i.fieldView.placeholder="https://example.com/image.png",i.fieldView.bind("value").to(this,"imageURLInputValue",(e=>e||"")),i.fieldView.on("input",(()=>{this.imageURLInputValue=i.fieldView.element.value.trim()})),i}_createInsertButton(){const e=this.locale,t=e.t,i=new Hg(e);return i.set({icon:Dm.check,class:"ck-button-save",type:"submit",withText:!0}),i.bind("label").to(this,"isImageSelected",(e=>t(e?"Update":"Insert"))),i.bind("isEnabled").to(this,"imageURLInputValue",this,"isEnabled",((...e)=>e.every((e=>e)))),i.delegate("execute").to(this,"submit"),i}_createCancelButton(){const e=this.locale,t=e.t,i=new Hg(e);return i.set({label:t("Cancel"),icon:Dm.cancel,class:"ck-button-cancel",withText:!0}),i.bind("isEnabled").to(this),i.delegate("execute").to(this,"cancel"),i}focus(e){-1===e?this.focusCycler.focusLast():this.focusCycler.focusFirst()}constructor(e){super(e),this.set("imageURLInputValue",""),this.set("isImageSelected",!1),this.set("isEnabled",!0),this.focusTracker=new ya,this.keystrokes=new ka,this._focusables=new og,this.focusCycler=new Tf({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.urlInputView=this._createUrlInputView(),this.insertButtonView=this._createInsertButton(),this.cancelButtonView=this._createCancelButton(),this._focusables.addMany([this.urlInputView,this.insertButtonView,this.cancelButtonView]),this.setTemplate({tag:"div",attributes:{class:["ck","ck-image-insert-url"]},children:[this.urlInputView,{tag:"div",attributes:{class:["ck","ck-image-insert-url__action-row"]},children:[this.insertButtonView,this.cancelButtonView]}]})}}class LE extends Na{static get pluginName(){return"ImageInsertViaUrlUI"}static get requires(){return[hE]}afterInit(){this._imageInsertUI=this.editor.plugins.get("ImageInsertUI"),this._imageInsertUI.registerIntegration({name:"url",observable:()=>this.editor.commands.get("insertImage"),requiresForm:!0,buttonViewCreator:e=>this._createInsertUrlButton(e),formViewCreator:e=>this._createInsertUrlView(e)})}_createInsertUrlView(e){const t=this.editor,i=t.locale,n=i.t,s=t.commands.get("replaceImageSource"),o=t.commands.get("insertImage"),r=new ME(i),a=e?null:new qg(i,[r]);return r.bind("isImageSelected").to(this._imageInsertUI),r.bind("isEnabled").toMany([o,s],"isEnabled",((...e)=>e.some((e=>e)))),r.imageURLInputValue=s.value||"",this._imageInsertUI.dropdownView.on("change:isOpen",(()=>{this._imageInsertUI.dropdownView.isOpen&&(r.imageURLInputValue=s.value||"",a&&(a.isCollapsed=!0))}),{priority:"low"}),r.on("submit",(()=>{s.isEnabled?t.execute("replaceImageSource",{source:r.imageURLInputValue}):t.execute("insertImage",{source:r.imageURLInputValue}),this._closePanel()})),r.on("cancel",(()=>this._closePanel())),a?(a.set({isCollapsed:!0}),a.bind("label").to(this._imageInsertUI,"isImageSelected",(e=>n(e?"Update image URL":"Insert image via URL"))),a):r}_createInsertUrlButton(e){const t=e?Ef:Hg,i=this.editor,n=new t(i.locale),s=i.locale.t;return n.set({icon:Dm.imageUrl,tooltip:!0}),n.bind("label").to(this._imageInsertUI,"isImageSelected",(e=>s(e?"Update image URL":"Insert image via URL"))),n}_closePanel(){this.editor.editing.view.focus(),this._imageInsertUI.dropdownView.isOpen=!1}}class NE extends Na{static get pluginName(){return"ImageInsertViaUrl"}static get requires(){return[LE,hE]}}class FE extends Na{static get pluginName(){return"ImageInsert"}static get requires(){return[OE,NE,hE]}}class DE extends Da{refresh(){const e=this.editor,t=e.plugins.get("ImageUtils").getClosestSelectedImageElement(e.model.document.selection);this.isEnabled=!!t,t&&t.hasAttribute("resizedWidth")?this.value={width:t.getAttribute("resizedWidth"),height:null}:this.value=null}execute(e){const t=this.editor,i=t.model,n=t.plugins.get("ImageUtils"),s=n.getClosestSelectedImageElement(i.document.selection);this.value={width:e.width,height:null},s&&i.change((t=>{t.setAttribute("resizedWidth",e.width,s),t.removeAttribute("resizedHeight",s),n.setImageNaturalSizeAttributes(s)}))}}class zE extends Na{static get requires(){return[UA]}static get pluginName(){return"ImageResizeEditing"}init(){const e=this.editor,t=new DE(e);this._registerConverters("imageBlock"),this._registerConverters("imageInline"),e.commands.add("resizeImage",t),e.commands.add("imageResize",t)}afterInit(){this._registerSchema()}_registerSchema(){this.editor.plugins.has("ImageBlockEditing")&&this.editor.model.schema.extend("imageBlock",{allowAttributes:["resizedWidth","resizedHeight"]}),this.editor.plugins.has("ImageInlineEditing")&&this.editor.model.schema.extend("imageInline",{allowAttributes:["resizedWidth","resizedHeight"]})}_registerConverters(e){const t=this.editor,i=t.plugins.get("ImageUtils");t.conversion.for("downcast").add((t=>t.on(`attribute:resizedWidth:${e}`,((e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const n=i.writer,s=i.mapper.toViewElement(t.item);null!==t.attributeNewValue?(n.setStyle("width",t.attributeNewValue,s),n.addClass("image_resized",s)):(n.removeStyle("width",s),n.removeClass("image_resized",s))})))),t.conversion.for("dataDowncast").attributeToAttribute({model:{name:e,key:"resizedHeight"},view:e=>({key:"style",value:{height:e}})}),t.conversion.for("editingDowncast").add((t=>t.on(`attribute:resizedHeight:${e}`,((t,n,s)=>{if(!s.consumable.consume(n.item,t.name))return;const o=s.writer,r=s.mapper.toViewElement(n.item),a="imageInline"===e?i.findViewImgElement(r):r;null!==n.attributeNewValue?o.setStyle("height",n.attributeNewValue,a):o.removeStyle("height",a)})))),t.conversion.for("upcast").attributeToAttribute({view:{name:"imageBlock"===e?"figure":"img",styles:{width:/.+/}},model:{key:"resizedWidth",value:e=>HA(e)?null:e.getStyle("width")}}),t.conversion.for("upcast").attributeToAttribute({view:{name:"imageBlock"===e?"figure":"img",styles:{height:/.+/}},model:{key:"resizedHeight",value:e=>HA(e)?null:e.getStyle("height")}})}constructor(e){super(e),e.config.define("image",{resizeUnit:"%",resizeOptions:[{name:"resizeImage:original",value:null,icon:"original"},{name:"resizeImage:custom",value:"custom",icon:"custom"},{name:"resizeImage:25",value:"25",icon:"small"},{name:"resizeImage:50",value:"50",icon:"medium"},{name:"resizeImage:75",value:"75",icon:"large"}]})}}const HE={small:Dm.objectSizeSmall,medium:Dm.objectSizeMedium,large:Dm.objectSizeLarge,custom:Dm.objectSizeCustom,original:Dm.objectSizeFull};class $E extends Na{static get requires(){return[zE]}static get pluginName(){return"ImageResizeButtons"}init(){const e=this.editor,t=e.config.get("image.resizeOptions"),i=e.commands.get("resizeImage");this.bind("isEnabled").to(i);for(const e of t)this._registerImageResizeButton(e);this._registerImageResizeDropdown(t)}_registerImageResizeButton(e){const t=this.editor,{name:i,value:n,icon:s}=e;t.ui.componentFactory.add(i,(i=>{const o=new Hg(i),r=t.commands.get("resizeImage"),a=this._getOptionLabelValue(e,!0);if(!HE[s])throw new p("imageresizebuttons-missing-icon",t,e);if(o.set({label:a,icon:HE[s],tooltip:a,isToggleable:!0}),o.bind("isEnabled").to(this),t.plugins.has("ImageCustomResizeUI")&&UE(e)){const e=t.plugins.get("ImageCustomResizeUI");this.listenTo(o,"execute",(()=>{e._showForm(this._resizeUnit)}))}else{const e=n?n+this._resizeUnit:null;o.bind("isOn").to(r,"value",WE(e)),this.listenTo(o,"execute",(()=>{t.execute("resizeImage",{width:e})}))}return o}))}_registerImageResizeDropdown(e){const t=this.editor,i=t.t,n=e.find((e=>!e.value)),s=s=>{const o=t.commands.get("resizeImage"),r=Wf(s,Ef),a=r.buttonView,l=i("Resize image");return a.set({tooltip:l,commandValue:n.value,icon:HE.medium,isToggleable:!0,label:this._getOptionLabelValue(n),withText:!0,class:"ck-resize-image-button",ariaLabel:l,ariaLabelledBy:void 0}),a.bind("label").to(o,"value",(e=>e&&e.width?e.width:this._getOptionLabelValue(n))),r.bind("isEnabled").to(this),Gf(r,(()=>this._getResizeDropdownListItemDefinitions(e,o)),{ariaLabel:i("Image resize list"),role:"menu"}),this.listenTo(r,"execute",(e=>{"onClick"in e.source?e.source.onClick():(t.execute(e.source.commandName,{width:e.source.commandValue}),t.editing.view.focus())})),r};t.ui.componentFactory.add("resizeImage",s),t.ui.componentFactory.add("imageResize",s)}_getOptionLabelValue(e,t=!1){const i=this.editor.t;return e.label?e.label:t?UE(e)?i("Custom image size"):e.value?i("Resize image to %0",e.value+this._resizeUnit):i("Resize image to the original size"):UE(e)?i("Custom"):e.value?e.value+this._resizeUnit:i("Original")}_getResizeDropdownListItemDefinitions(e,t){const{editor:i}=this,n=new va,s=e.map((e=>UE(e)?{...e,valueWithUnits:"custom"}:e.value?{...e,valueWithUnits:`${e.value}${this._resizeUnit}`}:{...e,valueWithUnits:null}));for(const e of s){let a=null;if(i.plugins.has("ImageCustomResizeUI")&&UE(e)){const n=i.plugins.get("ImageCustomResizeUI");a={type:"button",model:new Ab({label:this._getOptionLabelValue(e),role:"menuitemradio",withText:!0,icon:null,onClick:()=>{n._showForm(this._resizeUnit)}})};const l=(r="valueWithUnits",(Y(o=s)?Q:Mo)(o,mo(r)));a.model.bind("isOn").to(t,"value",jE(l))}else a={type:"button",model:new Ab({commandName:"resizeImage",commandValue:e.valueWithUnits,label:this._getOptionLabelValue(e),role:"menuitemradio",withText:!0,icon:null})},a.model.bind("isOn").to(t,"value",WE(e.valueWithUnits));a.model.bind("isEnabled").to(t,"isEnabled"),n.add(a)}var o,r;return n}constructor(e){super(e),this._resizeUnit=e.config.get("image.resizeUnit")}}function UE(e){return"custom"===e.value}function WE(e){return t=>null===e&&t===e||null!==t&&t.width===e}function jE(e){return t=>!e.some((e=>WE(e)(t)))}const qE="image_resized";class GE extends Na{static get requires(){return[My,UA]}static get pluginName(){return"ImageResizeHandles"}init(){const e=this.editor.commands.get("resizeImage");this.bind("isEnabled").to(e),this._setupResizerCreator()}_setupResizerCreator(){const e=this.editor,t=e.editing.view,i=e.plugins.get("ImageUtils");t.addObserver(tE),this.listenTo(t.document,"imageLoaded",((n,s)=>{if(!s.target.matches("figure.image.ck-widget > img,figure.image.ck-widget > picture > img,figure.image.ck-widget > a > img,figure.image.ck-widget > a > picture > img,span.image-inline.ck-widget > img,span.image-inline.ck-widget > picture > img"))return;const o=e.editing.view.domConverter,r=o.domToView(s.target),a=i.getImageWidgetFromImageView(r);let l=this.editor.plugins.get(My).getResizerByViewElement(a);if(l)return void l.redraw();const c=e.editing.mapper,d=c.toModelElement(a);l=e.plugins.get(My).attachTo({unit:e.config.get("image.resizeUnit"),modelElement:d,viewElement:a,editor:e,getHandleHost:e=>e.querySelector("img"),getResizeHost:()=>o.mapViewToDom(c.toViewElement(d.parent)),isCentered:()=>"alignCenter"==d.getAttribute("imageStyle"),onCommit(i){t.change((e=>{e.removeClass(qE,a)})),e.execute("resizeImage",{width:i})}}),l.on("updateSize",(()=>{a.hasClass(qE)||t.change((e=>{e.addClass(qE,a)}));const e="imageInline"===d.name?r:a;e.getStyle("height")&&t.change((t=>{t.removeStyle("height",e)}))})),l.bind("isEnabled").to(this)}))}}function KE(e){if(!e)return null;const[,t,i]=e.trim().match(/([.,\d]+)(%|px)$/)||[],n=Number.parseFloat(t);return Number.isNaN(n)?null:{value:n,unit:i}}function ZE(e,t,i){return"px"===i?{value:t.value,unit:"px"}:{value:t.value/e*100,unit:"%"}}function JE(e){const{editing:t}=e,i=e.plugins.get("ImageUtils").getClosestSelectedImageElement(e.model.document.selection);if(!i)return null;const n=t.mapper.toViewElement(i);return{model:i,view:n,dom:t.view.domConverter.mapViewToDom(n)}}class QE extends Tg{render(){super.render(),this.keystrokes.listenTo(this.element),Vg({view:this}),[this.labeledInput,this.saveButtonView,this.cancelButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)}))}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}_createButton(e,t,i,n){const s=new Hg(this.locale);return s.set({label:e,icon:t,tooltip:!0}),s.extendTemplate({attributes:{class:i}}),n&&s.delegate("execute").to(this,n),s}_createLabeledInputView(){const e=this.locale.t,t=new bf(this.locale,Yf);return t.label=e("Resize image (in %0)",this.unit),t.fieldView.set({step:.1}),t}isValid(){this.resetFormStatus();for(const e of this._validators){const t=e(this);if(t)return this.labeledInput.errorText=t,!1}return!0}resetFormStatus(){this.labeledInput.errorText=null}get rawSize(){const{element:e}=this.labeledInput.fieldView;return e?e.value:null}get parsedSize(){const{rawSize:e}=this;if(null===e)return null;const t=Number.parseFloat(e);return Number.isNaN(t)?null:t}get sizeWithUnits(){const{parsedSize:e,unit:t}=this;return null===e?null:`${e}${t}`}constructor(e,t,i){super(e);const n=this.locale.t;this.focusTracker=new ya,this.keystrokes=new ka,this.unit=t,this.labeledInput=this._createLabeledInputView(),this.saveButtonView=this._createButton(n("Save"),Dm.check,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(n("Cancel"),Dm.cancel,"ck-button-cancel","cancel"),this._focusables=new og,this._validators=i,this._focusCycler=new Tf({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"form",attributes:{class:["ck","ck-image-custom-resize-form","ck-responsive-form"],tabindex:"-1"},children:[this.labeledInput,this.saveButtonView,this.cancelButtonView]})}}class YE extends Na{static get requires(){return[Tb]}static get pluginName(){return"ImageCustomResizeUI"}destroy(){super.destroy(),this._form&&this._form.destroy()}_createForm(e){const t=this.editor;this._balloon=this.editor.plugins.get("ContextualBalloon"),this._form=new(Pg(QE))(t.locale,e,function(e){const t=e.t;return[e=>""===e.rawSize.trim()?t("The value must not be empty."):null===e.parsedSize?t("The value should be a plain number."):void 0]}(t)),this._form.render(),this.listenTo(this._form,"submit",(()=>{this._form.isValid()&&(t.execute("resizeImage",{width:this._form.sizeWithUnits}),this._hideForm(!0))})),this.listenTo(this._form.labeledInput,"change:errorText",(()=>{t.ui.update()})),this.listenTo(this._form,"cancel",(()=>{this._hideForm(!0)})),this._form.keystrokes.set("Esc",((e,t)=>{this._hideForm(!0),t()})),Sg({emitter:this._form,activator:()=>this._isVisible,contextElements:()=>[this._balloon.view.element],callback:()=>this._hideForm()})}_showForm(e){if(this._isVisible)return;this._form||this._createForm(e);const t=this.editor,i=this._form.labeledInput;this._form.disableCssTransitions(),this._form.resetFormStatus(),this._isInBalloon||this._balloon.add({view:this._form,position:JA(t)});const n=function(e,t){const i=JE(e);if(!i)return null;const n=KE(i.model.getAttribute("resizedWidth")||null);return n?n.unit===t?n:ZE(gy(i.dom),{unit:"px",value:new Ir(i.dom).width},t):null}(t,e),s=n?n.value.toFixed(1):"",o=function(e,t){const i=JE(e);if(!i)return null;const n=gy(i.dom),s=KE(window.getComputedStyle(i.dom).minWidth)||{value:1,unit:"px"};return{unit:t,lower:Math.max(.1,ZE(n,s,t).value),upper:"px"===t?n:100}}(t,e);i.fieldView.value=i.fieldView.element.value=s,o&&Object.assign(i.fieldView,{min:o.lower.toFixed(1),max:Math.ceil(o.upper).toFixed(1)}),this._form.labeledInput.fieldView.select(),this._form.enableCssTransitions()}_hideForm(e=!1){this._isInBalloon&&(this._form.focusTracker.isFocused&&this._form.saveButtonView.focus(),this._balloon.remove(this._form),e&&this.editor.editing.view.focus())}get _isVisible(){return!!this._balloon&&this._balloon.visibleView===this._form}get _isInBalloon(){return!!this._balloon&&this._balloon.hasView(this._form)}}class XE extends Na{static get requires(){return[zE,GE,YE,$E]}static get pluginName(){return"ImageResize"}}class eT extends Da{refresh(){const e=this.editor.plugins.get("ImageUtils").getClosestSelectedImageElement(this.editor.model.document.selection);this.isEnabled=!!e,this.isEnabled?e.hasAttribute("imageStyle")?this.value=e.getAttribute("imageStyle"):this.value=this._defaultStyles[e.name]:this.value=!1}execute(e={}){const t=this.editor,i=t.model,n=t.plugins.get("ImageUtils");i.change((t=>{const s=e.value,{setImageSizes:o=!0}=e;let r=n.getClosestSelectedImageElement(i.document.selection);s&&this.shouldConvertImageType(s,r)&&(this.editor.execute(n.isBlockImage(r)?"imageTypeInline":"imageTypeBlock",{setImageSizes:o}),r=n.getClosestSelectedImageElement(i.document.selection)),!s||this._styles.get(s).isDefault?t.removeAttribute("imageStyle",r):t.setAttribute("imageStyle",s,r),o&&n.setImageNaturalSizeAttributes(r)}))}shouldConvertImageType(e,t){return!this._styles.get(e).modelElements.includes(t.name)}constructor(e,t){super(e),this._defaultStyles={imageBlock:!1,imageInline:!1},this._styles=new Map(t.map((e=>{if(e.isDefault)for(const t of e.modelElements)this._defaultStyles[t]=e.name;return[e.name,e]})))}}const{objectFullWidth:tT,objectInline:iT,objectLeft:nT,objectRight:sT,objectCenter:oT,objectBlockLeft:rT,objectBlockRight:aT}=Dm,lT={get inline(){return{name:"inline",title:"In line",icon:iT,modelElements:["imageInline"],isDefault:!0}},get alignLeft(){return{name:"alignLeft",title:"Left aligned image",icon:nT,modelElements:["imageBlock","imageInline"],className:"image-style-align-left"}},get alignBlockLeft(){return{name:"alignBlockLeft",title:"Left aligned image",icon:rT,modelElements:["imageBlock"],className:"image-style-block-align-left"}},get alignCenter(){return{name:"alignCenter",title:"Centered image",icon:oT,modelElements:["imageBlock"],className:"image-style-align-center"}},get alignRight(){return{name:"alignRight",title:"Right aligned image",icon:sT,modelElements:["imageBlock","imageInline"],className:"image-style-align-right"}},get alignBlockRight(){return{name:"alignBlockRight",title:"Right aligned image",icon:aT,modelElements:["imageBlock"],className:"image-style-block-align-right"}},get block(){return{name:"block",title:"Centered image",icon:oT,modelElements:["imageBlock"],isDefault:!0}},get side(){return{name:"side",title:"Side image",icon:sT,modelElements:["imageBlock"],className:"image-style-side"}}},cT={full:tT,left:rT,right:aT,center:oT,inlineLeft:nT,inlineRight:sT,inline:iT},dT=[{name:"imageStyle:wrapText",title:"Wrap text",defaultItem:"imageStyle:alignLeft",items:["imageStyle:alignLeft","imageStyle:alignRight"]},{name:"imageStyle:breakText",title:"Break text",defaultItem:"imageStyle:block",items:["imageStyle:alignBlockLeft","imageStyle:block","imageStyle:alignBlockRight"]}];function hT(e){b("image-style-configuration-definition-invalid",e)}var uT={normalizeStyles:function(e){return(e.configuredStyles.options||[]).map((e=>function(e){e="string"==typeof e?lT[e]?{...lT[e]}:{name:e}:function(e,t){const i={...t};for(const n in e)Object.prototype.hasOwnProperty.call(t,n)||(i[n]=e[n]);return i}(lT[e.name],e);"string"==typeof e.icon&&(e.icon=cT[e.icon]||e.icon);return e}(e))).filter((t=>function(e,{isBlockPluginLoaded:t,isInlinePluginLoaded:i}){const{modelElements:n,name:s}=e;if(!(n&&n.length&&s))return hT({style:e}),!1;{const s=[t?"imageBlock":null,i?"imageInline":null];if(!n.some((e=>s.includes(e))))return b("image-style-missing-dependency",{style:e,missingPlugins:n.map((e=>"imageBlock"===e?"ImageBlockEditing":"ImageInlineEditing"))}),!1}return!0}(t,e)))},getDefaultStylesConfiguration:function(e,t){return e&&t?{options:["inline","alignLeft","alignRight","alignCenter","alignBlockLeft","alignBlockRight","block","side"]}:e?{options:["block","side"]}:t?{options:["inline","alignLeft","alignRight"]}:{}},getDefaultDropdownDefinitions:function(e){return e.has("ImageBlockEditing")&&e.has("ImageInlineEditing")?[...dT]:[]},warnInvalidStyle:hT,DEFAULT_OPTIONS:lT,DEFAULT_ICONS:cT,DEFAULT_DROPDOWN_DEFINITIONS:dT};function mT(e,t){for(const i of t)if(i.name===e)return i}class gT extends Na{static get pluginName(){return"ImageStyleEditing"}static get requires(){return[UA]}init(){const{normalizeStyles:e,getDefaultStylesConfiguration:t}=uT,i=this.editor,n=i.plugins.has("ImageBlockEditing"),s=i.plugins.has("ImageInlineEditing");i.config.define("image.styles",t(n,s)),this.normalizedStyles=e({configuredStyles:i.config.get("image.styles"),isBlockPluginLoaded:n,isInlinePluginLoaded:s}),this._setupConversion(n,s),this._setupPostFixer(),i.commands.add("imageStyle",new eT(i,this.normalizedStyles))}_setupConversion(e,t){const i=this.editor,n=i.model.schema,s=(o=this.normalizedStyles,(e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const n=mT(t.attributeNewValue,o),s=mT(t.attributeOldValue,o),r=i.mapper.toViewElement(t.item),a=i.writer;s&&a.removeClass(s.className,r),n&&a.addClass(n.className,r)});var o;const r=function(e){const t={imageInline:e.filter((e=>!e.isDefault&&e.modelElements.includes("imageInline"))),imageBlock:e.filter((e=>!e.isDefault&&e.modelElements.includes("imageBlock")))};return(e,i,n)=>{if(!i.modelRange)return;const s=i.viewItem,o=_a(i.modelRange.getItems());if(o&&n.schema.checkAttribute(o,"imageStyle"))for(const e of t[o.name])n.consumable.consume(s,{classes:e.className})&&n.writer.setAttribute("imageStyle",e.name,o)}}(this.normalizedStyles);i.editing.downcastDispatcher.on("attribute:imageStyle",s),i.data.downcastDispatcher.on("attribute:imageStyle",s),e&&(n.extend("imageBlock",{allowAttributes:"imageStyle"}),i.data.upcastDispatcher.on("element:figure",r,{priority:"low"})),t&&(n.extend("imageInline",{allowAttributes:"imageStyle"}),i.data.upcastDispatcher.on("element:img",r,{priority:"low"}))}_setupPostFixer(){const e=this.editor,t=e.model.document,i=e.plugins.get(UA),n=new Map(this.normalizedStyles.map((e=>[e.name,e])));t.registerPostFixer((e=>{let s=!1;for(const o of t.differ.getChanges())if("insert"==o.type||"attribute"==o.type&&"imageStyle"==o.attributeKey){let t="insert"==o.type?o.position.nodeAfter:o.range.start.nodeAfter;if(t&&t.is("element","paragraph")&&t.childCount>0&&(t=t.getChild(0)),!i.isImage(t))continue;const r=t.getAttribute("imageStyle");if(!r)continue;const a=n.get(r);a&&a.modelElements.includes(t.name)||(e.removeAttribute("imageStyle",t),s=!0)}return s}))}}class fT extends Na{static get requires(){return[gT]}static get pluginName(){return"ImageStyleUI"}get localizedDefaultStylesTitles(){const e=this.editor.t;return{"Wrap text":e("Wrap text"),"Break text":e("Break text"),"In line":e("In line"),"Full size image":e("Full size image"),"Side image":e("Side image"),"Left aligned image":e("Left aligned image"),"Centered image":e("Centered image"),"Right aligned image":e("Right aligned image")}}init(){const e=this.editor.plugins,t=this.editor.config.get("image.toolbar")||[],i=pT(e.get("ImageStyleEditing").normalizedStyles,this.localizedDefaultStylesTitles);for(const e of i)this._createButton(e);const n=pT([...t.filter(re),...uT.getDefaultDropdownDefinitions(e)],this.localizedDefaultStylesTitles);for(const e of n)this._createDropdown(e,i)}_createDropdown(e,t){const i=this.editor.ui.componentFactory;i.add(e.name,(n=>{let s;const{defaultItem:o,items:r,title:a}=e,l=r.filter((e=>t.find((({name:t})=>bT(t)===e)))).map((e=>{const t=i.create(e);return e===o&&(s=t),t}));r.length!==l.length&&uT.warnInvalidStyle({dropdown:e});const c=Wf(n,Uf),d=c.buttonView,h=d.arrowView;return jf(c,l,{enableActiveItemFocusOnDropdownOpen:!0}),d.set({label:wT(a,s.label),class:null,tooltip:!0}),h.unbind("label"),h.set({label:a}),d.bind("icon").toMany(l,"isOn",((...e)=>{const t=e.findIndex(me);return t<0?s.icon:l[t].icon})),d.bind("label").toMany(l,"isOn",((...e)=>{const t=e.findIndex(me);return wT(a,t<0?s.label:l[t].label)})),d.bind("isOn").toMany(l,"isOn",((...e)=>e.some(me))),d.bind("class").toMany(l,"isOn",((...e)=>e.some(me)?"ck-splitbutton_flatten":void 0)),d.on("execute",(()=>{l.some((({isOn:e})=>e))?c.isOpen=!c.isOpen:s.fire("execute")})),c.bind("isEnabled").toMany(l,"isEnabled",((...e)=>e.some(me))),this.listenTo(c,"execute",(()=>{this.editor.editing.view.focus()})),c}))}_createButton(e){const t=e.name;this.editor.ui.componentFactory.add(bT(t),(i=>{const n=this.editor.commands.get("imageStyle"),s=new Hg(i);return s.set({label:e.title,icon:e.icon,tooltip:!0,isToggleable:!0}),s.bind("isEnabled").to(n,"isEnabled"),s.bind("isOn").to(n,"value",(e=>e===t)),s.on("execute",this._executeCommand.bind(this,t)),s}))}_executeCommand(e){this.editor.execute("imageStyle",{value:e}),this.editor.editing.view.focus()}}function pT(e,t){for(const i of e)t[i.title]&&(i.title=t[i.title]);return e}function bT(e){return`imageStyle:${e}`}function wT(e,t){return(e?e+": ":"")+t}class vT extends Na{static get requires(){return[gT,fT]}static get pluginName(){return"ImageStyle"}}class _T extends Na{static get requires(){return[Sy,UA]}static get pluginName(){return"ImageToolbar"}afterInit(){const e=this.editor,t=e.t,i=e.plugins.get(Sy),n=e.plugins.get("ImageUtils");var s;i.register("image",{ariaLabel:t("Image toolbar"),items:(s=e.config.get("image.toolbar")||[],s.map((e=>re(e)?e.name:e))),getRelatedElement:e=>n.getClosestSelectedImageWidget(e)})}}class yT extends Na{static get requires(){return[sE,UA]}static get pluginName(){return"PictureEditing"}afterInit(){const e=this.editor;e.plugins.has("ImageBlockEditing")&&e.model.schema.extend("imageBlock",{allowAttributes:["sources"]}),e.plugins.has("ImageInlineEditing")&&e.model.schema.extend("imageInline",{allowAttributes:["sources"]}),this._setupConversion(),this._setupImageUploadEditingIntegration()}_setupConversion(){const e=this.editor,t=e.conversion,i=e.plugins.get("ImageUtils");t.for("upcast").add(function(e){const t=["srcset","media","type","sizes"],i=(i,n,s)=>{const o=n.viewItem;if(!s.consumable.test(o,{name:!0}))return;const r=new Map;for(const e of o.getChildren())if(e.is("element","source")){const i={};for(const n of t)e.hasAttribute(n)&&s.consumable.test(e,{attributes:n})&&(i[n]=e.getAttribute(n));Object.keys(i).length&&r.set(e,i)}const a=e.findViewImgElement(o);if(!a)return;let l=n.modelCursor.parent;if(!l.is("element","imageBlock")){const e=s.convertItem(a,n.modelCursor);n.modelRange=e.modelRange,n.modelCursor=e.modelCursor,l=_a(e.modelRange.getItems())}s.consumable.consume(o,{name:!0});for(const[e,t]of r)s.consumable.consume(e,{attributes:Object.keys(t)});r.size&&s.writer.setAttribute("sources",Array.from(r.values()),l),s.convertChildren(o,l)};return e=>{e.on("element:picture",i)}}(i)),t.for("downcast").add(function(e){const t=(t,i,n)=>{if(!n.consumable.consume(i.item,t.name))return;const s=n.writer,o=n.mapper.toViewElement(i.item),r=e.findViewImgElement(o),a=i.attributeNewValue;if(a&&a.length){const e=s.createContainerElement("picture",null,a.map((e=>s.createEmptyElement("source",e)))),t=[];let i=r.parent;for(;i&&i.is("attributeElement");){const e=i.parent;s.unwrap(s.createRangeOn(r),i),t.unshift(i),i=e}s.insert(s.createPositionBefore(r),e),s.move(s.createRangeOn(r),s.createPositionAt(e,"end"));for(const i of t)s.wrap(s.createRangeOn(e),i)}else if(r.parent.is("element","picture")){const e=r.parent;s.move(s.createRangeOn(r),s.createPositionBefore(e)),s.remove(e)}};return e=>{e.on("attribute:sources:imageBlock",t),e.on("attribute:sources:imageInline",t)}}(i))}_setupImageUploadEditingIntegration(){const e=this.editor;if(!e.plugins.has("ImageUploadEditing"))return;const t=e.plugins.get("ImageUploadEditing");this.listenTo(t,"uploadComplete",((t,{imageElement:i,data:n})=>{const s=n.sources;s&&e.model.change((e=>{e.setAttributes({sources:s},i)}))}))}}class kT extends Na{static get pluginName(){return"IndentEditing"}init(){const e=this.editor;e.commands.add("indent",new Ha(e)),e.commands.add("outdent",new Ha(e))}}class CT extends Na{static get pluginName(){return"IndentUI"}init(){const e=this.editor,t=e.locale,i=e.t,n="ltr"==t.uiLanguageDirection?Dm.indent:Dm.outdent,s="ltr"==t.uiLanguageDirection?Dm.outdent:Dm.indent;this._defineButton("indent",i("Increase indent"),n),this._defineButton("outdent",i("Decrease indent"),s)}_defineButton(e,t,i){const n=this.editor;n.ui.componentFactory.add(e,(()=>{const n=this._createButton(Hg,e,t,i);return n.set({tooltip:!0}),n})),n.ui.componentFactory.add("menuBar:"+e,(()=>this._createButton(uw,e,t,i)))}_createButton(e,t,i,n){const s=this.editor,o=s.commands.get(t),r=new e(s.locale);return r.set({label:i,icon:n}),r.bind("isEnabled").to(o,"isEnabled"),this.listenTo(r,"execute",(()=>{s.execute(t),s.editing.view.focus()})),r}}class xT extends Na{static get pluginName(){return"Indent"}static get requires(){return[kT,CT]}}class AT extends Da{refresh(){const e=_a(this.editor.model.document.selection.getSelectedBlocks());e&&this._isIndentationChangeAllowed(e)?this.isEnabled=this._indentBehavior.checkEnabled(e.getAttribute("blockIndent")):this.isEnabled=!1}execute(){const e=this.editor.model,t=this._getBlocksToChange();e.change((e=>{for(const i of t){const t=i.getAttribute("blockIndent"),n=this._indentBehavior.getNextIndent(t);n?e.setAttribute("blockIndent",n,i):e.removeAttribute("blockIndent",i)}}))}_getBlocksToChange(){const e=this.editor.model.document.selection;return Array.from(e.getSelectedBlocks()).filter((e=>this._isIndentationChangeAllowed(e)))}_isIndentationChangeAllowed(e){const t=this.editor;if(!t.model.schema.checkAttribute(e,"blockIndent"))return!1;if(!t.plugins.has("ListUtils"))return!0;if(!this._indentBehavior.isForward)return!0;return!t.plugins.get("ListUtils").isListItemBlock(e)}constructor(e,t){super(e),this._indentBehavior=t}}class ET{checkEnabled(e){const t=parseFloat(e||"0");return this.isForward||t>0}getNextIndent(e){const t=parseFloat(e||"0");if(!(!e||e.endsWith(this.unit)))return this.isForward?this.offset+this.unit:void 0;const i=t+(this.isForward?this.offset:-this.offset);return i>0?i+this.unit:void 0}constructor(e){this.isForward="forward"===e.direction,this.offset=e.offset,this.unit=e.unit}}class TT{checkEnabled(e){const t=this.classes.indexOf(e);return this.isForward?t<this.classes.length-1:t>=0}getNextIndent(e){const t=this.classes.indexOf(e),i=this.isForward?1:-1;return this.classes[t+i]}constructor(e){this.isForward="forward"===e.direction,this.classes=e.classes}}const ST=["paragraph","heading1","heading2","heading3","heading4","heading5","heading6"];class IT extends Na{static get pluginName(){return"IndentBlock"}init(){const e=this.editor,t=e.config.get("indentBlock");t.classes&&t.classes.length?(this._setupConversionUsingClasses(t.classes),e.commands.add("indentBlock",new AT(e,new TT({direction:"forward",classes:t.classes}))),e.commands.add("outdentBlock",new AT(e,new TT({direction:"backward",classes:t.classes})))):(e.data.addStyleProcessorRules(Em),this._setupConversionUsingOffset(),e.commands.add("indentBlock",new AT(e,new ET({direction:"forward",offset:t.offset,unit:t.unit}))),e.commands.add("outdentBlock",new AT(e,new ET({direction:"backward",offset:t.offset,unit:t.unit}))))}afterInit(){const e=this.editor,t=e.model.schema,i=e.commands.get("indent"),n=e.commands.get("outdent"),s=e.config.get("heading.options");(s&&s.map((e=>e.model))||ST).forEach((e=>{t.isRegistered(e)&&t.extend(e,{allowAttributes:"blockIndent"})})),t.setAttributeProperties("blockIndent",{isFormatting:!0}),i.registerChildCommand(e.commands.get("indentBlock")),n.registerChildCommand(e.commands.get("outdentBlock"))}_setupConversionUsingOffset(){const e=this.editor.conversion,t="rtl"===this.editor.locale.contentLanguageDirection?"margin-right":"margin-left";e.for("upcast").attributeToAttribute({view:{styles:{[t]:/[\s\S]+/}},model:{key:"blockIndent",value:e=>{if(!e.is("element","li"))return e.getStyle(t)}}}),e.for("downcast").attributeToAttribute({model:"blockIndent",view:e=>({key:"style",value:{[t]:e}})})}_setupConversionUsingClasses(e){const t={model:{key:"blockIndent",values:[]},view:{}};for(const i of e)t.model.values.push(i),t.view[i]={key:"class",value:[i]};this.editor.conversion.attributeToAttribute(t)}constructor(e){super(e),e.config.define("indentBlock",{offset:40,unit:"px"})}}function PT(e,t){return`${e}:${t=t||fa(e)}`}class VT extends Da{refresh(){const e=this.editor.model,t=e.document;this.value=this._getValueFromFirstAllowedNode(),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,"language")}execute({languageCode:e,textDirection:t}={}){const i=this.editor.model,n=i.document.selection,s=!!e&&PT(e,t);i.change((e=>{if(n.isCollapsed)s?e.setSelectionAttribute("language",s):e.removeSelectionAttribute("language");else{const t=i.schema.getValidRanges(n.getRanges(),"language");for(const i of t)s?e.setAttribute("language",s,i):e.removeAttribute("language",i)}}))}_getValueFromFirstAllowedNode(){const e=this.editor.model,t=e.schema,i=e.document.selection;if(i.isCollapsed)return i.getAttribute("language")||!1;for(const e of i.getRanges())for(const i of e.getItems())if(t.checkAttribute(i,"language"))return i.getAttribute("language")||!1;return!1}}class RT extends Na{static get pluginName(){return"TextPartLanguageEditing"}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:"language"}),e.model.schema.setAttributeProperties("language",{copyOnEnter:!0}),this._defineConverters(),e.commands.add("textPartLanguage",new VT(e))}_defineConverters(){const e=this.editor.conversion;e.for("upcast").elementToAttribute({model:{key:"language",value:e=>PT(e.getAttribute("lang"),e.getAttribute("dir"))},view:{name:"span",attributes:{lang:/[\s\S]+/}}}),e.for("downcast").attributeToElement({model:"language",view:(e,{writer:t},i)=>{if(!e)return;if(!i.item.is("$textProxy")&&!i.item.is("documentSelection"))return;const{languageCode:n,textDirection:s}=function(e){const[t,i]=e.split(":");return{languageCode:t,textDirection:i}}(e);return t.createAttributeElement("span",{lang:n,dir:s})}})}constructor(e){super(e),e.config.define("language",{textPartLanguage:[{title:"Arabic",languageCode:"ar"},{title:"French",languageCode:"fr"},{title:"Spanish",languageCode:"es"}]})}}class BT extends Na{static get pluginName(){return"TextPartLanguageUI"}init(){const e=this.editor,t=e.t,i=t("Choose language"),n=t("Language");e.ui.componentFactory.add("textPartLanguage",(t=>{const{definitions:s,titles:o}=this._getItemMetadata(),r=e.commands.get("textPartLanguage"),a=Wf(t);return Gf(a,s,{ariaLabel:n,role:"menu"}),a.buttonView.set({ariaLabel:n,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:n}),a.extendTemplate({attributes:{class:["ck-text-fragment-language-dropdown"]}}),a.bind("isEnabled").to(r,"isEnabled"),a.buttonView.bind("label").to(r,"value",(e=>e&&o[e]||i)),a.buttonView.bind("ariaLabel").to(r,"value",(e=>{const t=e&&o[e];return t?`${t}, ${n}`:n})),this.listenTo(a,"execute",(t=>{r.execute({languageCode:t.source.languageCode,textDirection:t.source.textDirection}),e.editing.view.focus()})),a})),e.ui.componentFactory.add("menuBar:textPartLanguage",(i=>{const{definitions:s}=this._getItemMetadata(),o=e.commands.get("textPartLanguage"),r=new dw(i);r.buttonView.set({label:n});const a=new hw(i);a.set({ariaLabel:t("Language"),role:"menu"});for(const e of s){if("button"!=e.type){a.items.add(new zf(i));continue}const t=new qb(i,r),n=new uw(i);n.bind(...Object.keys(e.model)).to(e.model),n.bind("ariaChecked").to(n,"isOn"),n.delegate("execute").to(r),t.children.add(n),a.items.add(t)}return r.bind("isEnabled").to(o,"isEnabled"),r.panelView.children.add(a),r.on("execute",(t=>{o.execute({languageCode:t.source.languageCode,textDirection:t.source.textDirection}),e.editing.view.focus()})),r}))}_getItemMetadata(){const e=this.editor,t=new va,i={},n=e.commands.get("textPartLanguage"),s=e.config.get("language.textPartLanguage"),o=(0,e.locale.t)("Remove language");t.add({type:"button",model:new Ab({label:o,languageCode:!1,withText:!0})}),t.add({type:"separator"});for(const e of s){const s={type:"button",model:new Ab({label:e.title,languageCode:e.languageCode,role:"menuitemradio",textDirection:e.textDirection,withText:!0})},o=PT(e.languageCode,e.textDirection);s.model.bind("isOn").to(n,"value",(e=>e===o)),t.add(s),i[o]=e.title}return{definitions:t,titles:i}}}class OT extends Na{static get requires(){return[RT,BT]}static get pluginName(){return"TextPartLanguage"}}class MT{get length(){return this._definitions.size}add(e){Array.isArray(e)?e.forEach((e=>this._definitions.add(e))):this._definitions.add(e)}getDispatcher(){return e=>{e.on("attribute:linkHref",((e,t,i)=>{if(!i.consumable.test(t.item,"attribute:linkHref"))return;if(!t.item.is("selection")&&!i.schema.isInline(t.item))return;const n=i.writer,s=n.document.selection;for(const e of this._definitions){const o=n.createAttributeElement("a",e.attributes,{priority:5});e.classes&&n.addClass(e.classes,o);for(const t in e.styles)n.setStyle(t,e.styles[t],o);n.setCustomProperty("link",!0,o),e.callback(t.attributeNewValue)?t.item.is("selection")?n.wrap(s.getFirstRange(),o):n.wrap(i.mapper.toViewRange(t.range),o):n.unwrap(i.mapper.toViewRange(t.range),o)}}),{priority:"high"})}}getDispatcherForLinkedImage(){return e=>{e.on("attribute:linkHref:imageBlock",((e,t,{writer:i,mapper:n})=>{const s=n.toViewElement(t.item),o=Array.from(s.getChildren()).find((e=>e.is("element","a")));for(const e of this._definitions){const n=Ca(e.attributes);if(e.callback(t.attributeNewValue)){for(const[e,t]of n)"class"===e?i.addClass(t,o):i.setAttribute(e,t,o);e.classes&&i.addClass(e.classes,o);for(const t in e.styles)i.setStyle(t,e.styles[t],o)}else{for(const[e,t]of n)"class"===e?i.removeClass(t,o):i.removeAttribute(e,o);e.classes&&i.removeClass(e.classes,o);for(const t in e.styles)i.removeStyle(t,o)}}}))}}constructor(){this._definitions=new Set}}const LT=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g,NT=/^[\S]+@((?![-_])(?:[-\w\u00a1-\uffff]{0,63}[^-_]\.))+(?:[a-z\u00a1-\uffff]{2,})$/i,FT=/^((\w+:(\/{2,})?)|(\W))/i,DT=["https?","ftps?","mailto"],zT="Ctrl+K";function HT(e,{writer:t}){const i=t.createAttributeElement("a",{href:e},{priority:5});return t.setCustomProperty("link",!0,i),i}function $T(e,t=DT){const i=String(e),n=t.join("|");return function(e,t){const i=e.replace(LT,"");return!!i.match(t)}(i,new RegExp(`${"^(?:(?:<protocols>):|[^a-z]|[a-z+.-]+(?:[^a-z+.:-]|$))".replace("<protocols>",n)}`,"i"))?i:"#"}function UT(e,t){return!!e&&t.checkAttribute(e.name,"linkHref")}function WT(e,t){const i=(n=e,NT.test(n)?"mailto:":t);var n;const s=!!i&&!jT(e);return e&&s?i+e:e}function jT(e){return FT.test(e)}function qT(e){window.open(e,"_blank","noopener")}class GT extends Da{restoreManualDecoratorStates(){for(const e of this.manualDecorators)e.value=this._getDecoratorStateFromModel(e.id)}refresh(){const e=this.editor.model,t=e.document.selection,i=t.getSelectedElement()||_a(t.getSelectedBlocks());UT(i,e.schema)?(this.value=i.getAttribute("linkHref"),this.isEnabled=e.schema.checkAttribute(i,"linkHref")):(this.value=t.getAttribute("linkHref"),this.isEnabled=e.schema.checkAttributeInSelection(t,"linkHref"));for(const e of this.manualDecorators)e.value=this._getDecoratorStateFromModel(e.id)}execute(e,t={}){const i=this.editor.model,n=i.document.selection,s=[],o=[];for(const e in t)t[e]?s.push(e):o.push(e);i.change((t=>{if(n.isCollapsed){const r=n.getFirstPosition();if(n.hasAttribute("linkHref")){const a=KT(n);let l=Qw(r,"linkHref",n.getAttribute("linkHref"),i);n.getAttribute("linkHref")===a&&(l=this._updateLinkContent(i,t,l,e)),t.setAttribute("linkHref",e,l),s.forEach((e=>{t.setAttribute(e,!0,l)})),o.forEach((e=>{t.removeAttribute(e,l)})),t.setSelection(t.createPositionAfter(l.end.nodeBefore))}else if(""!==e){const o=Ca(n.getAttributes());o.set("linkHref",e),s.forEach((e=>{o.set(e,!0)}));const{end:a}=i.insertContent(t.createText(e,o),r);t.setSelection(a)}["linkHref",...s,...o].forEach((e=>{t.removeSelectionAttribute(e)}))}else{const r=i.schema.getValidRanges(n.getRanges(),"linkHref"),a=[];for(const e of n.getSelectedBlocks())i.schema.checkAttribute(e,"linkHref")&&a.push(t.createRangeOn(e));const l=a.slice();for(const e of r)this._isRangeToUpdate(e,a)&&l.push(e);for(const r of l){let a=r;if(1===l.length){const s=KT(n);n.getAttribute("linkHref")===s&&(a=this._updateLinkContent(i,t,r,e),t.setSelection(t.createSelection(a)))}t.setAttribute("linkHref",e,a),s.forEach((e=>{t.setAttribute(e,!0,a)})),o.forEach((e=>{t.removeAttribute(e,a)}))}}}))}_getDecoratorStateFromModel(e){const t=this.editor.model,i=t.document.selection,n=i.getSelectedElement();return UT(n,t.schema)?n.getAttribute(e):i.getAttribute(e)}_isRangeToUpdate(e,t){for(const i of t)if(i.containsRange(e))return!1;return!0}_updateLinkContent(e,t,i,n){const s=t.createText(n,{linkHref:n});return e.insertContent(s,i)}constructor(...e){super(...e),this.manualDecorators=new va,this.automaticDecorators=new MT}}function KT(e){if(e.isCollapsed){const t=e.getFirstPosition();return t.textNode&&t.textNode.data}{const t=Array.from(e.getFirstRange().getItems());if(t.length>1)return null;const i=t[0];return i.is("$text")||i.is("$textProxy")?i.data:null}}class ZT extends Da{refresh(){const e=this.editor.model,t=e.document.selection,i=t.getSelectedElement();UT(i,e.schema)?this.isEnabled=e.schema.checkAttribute(i,"linkHref"):this.isEnabled=e.schema.checkAttributeInSelection(t,"linkHref")}execute(){const e=this.editor,t=this.editor.model,i=t.document.selection,n=e.commands.get("link");t.change((e=>{const s=i.isCollapsed?[Qw(i.getFirstPosition(),"linkHref",i.getAttribute("linkHref"),t)]:t.schema.getValidRanges(i.getRanges(),"linkHref");for(const t of s)if(e.removeAttribute("linkHref",t),n)for(const i of n.manualDecorators)e.removeAttribute(i.id,t)}))}}class JT extends(Yo()){_createPattern(){return{attributes:this.attributes,classes:this.classes,styles:this.styles}}constructor({id:e,label:t,attributes:i,classes:n,styles:s,defaultValue:o}){super(),this.id=e,this.set("value",void 0),this.defaultValue=o,this.label=t,this.attributes=i,this.classes=n,this.styles=s}}const QT="automatic",YT=/^(https?:)?\/\//;class XT extends Na{static get pluginName(){return"LinkEditing"}static get requires(){return[Lw,Cw,Z_]}init(){const e=this.editor,t=this.editor.config.get("link.allowedProtocols");e.model.schema.extend("$text",{allowAttributes:"linkHref"}),e.conversion.for("dataDowncast").attributeToElement({model:"linkHref",view:HT}),e.conversion.for("editingDowncast").attributeToElement({model:"linkHref",view:(e,i)=>HT($T(e,t),i)}),e.conversion.for("upcast").elementToAttribute({view:{name:"a",attributes:{href:!0}},model:{key:"linkHref",value:e=>e.getAttribute("href")}}),e.commands.add("link",new GT(e)),e.commands.add("unlink",new ZT(e));const i=function(e,t){const i={"Open in a new tab":e("Open in a new tab"),Downloadable:e("Downloadable")};return t.forEach((e=>("label"in e&&i[e.label]&&(e.label=i[e.label]),e))),t}(e.t,function(e){const t=[];if(e)for(const[i,n]of Object.entries(e)){const e=Object.assign({},n,{id:`link${Ci(i)}`});t.push(e)}return t}(e.config.get("link.decorators")));this._enableAutomaticDecorators(i.filter((e=>e.mode===QT))),this._enableManualDecorators(i.filter((e=>"manual"===e.mode)));e.plugins.get(Lw).registerAttribute("linkHref"),Xw(e,"linkHref","a","ck-link_selected"),this._enableLinkOpen(),this._enableSelectionAttributesFixer(),this._enableClipboardIntegration()}_enableAutomaticDecorators(e){const t=this.editor,i=t.commands.get("link").automaticDecorators;t.config.get("link.addTargetToExternalLinks")&&i.add({id:"linkIsExternal",mode:QT,callback:e=>!!e&&YT.test(e),attributes:{target:"_blank",rel:"noopener noreferrer"}}),i.add(e),i.length&&t.conversion.for("downcast").add(i.getDispatcher())}_enableManualDecorators(e){if(!e.length)return;const t=this.editor,i=t.commands.get("link").manualDecorators;e.forEach((e=>{t.model.schema.extend("$text",{allowAttributes:e.id});const n=new JT(e);i.add(n),t.conversion.for("downcast").attributeToElement({model:n.id,view:(e,{writer:t,schema:i},{item:s})=>{if((s.is("selection")||i.isInline(s))&&e){const e=t.createAttributeElement("a",n.attributes,{priority:5});n.classes&&t.addClass(n.classes,e);for(const i in n.styles)t.setStyle(i,n.styles[i],e);return t.setCustomProperty("link",!0,e),e}}}),t.conversion.for("upcast").elementToAttribute({view:{name:"a",...n._createPattern()},model:{key:n.id}})}))}_enableLinkOpen(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"click",((e,t)=>{if(!(i.isMac?t.domEvent.metaKey:t.domEvent.ctrlKey))return;let n=t.domTarget;if("a"!=n.tagName.toLowerCase()&&(n=n.closest("a")),!n)return;const s=n.getAttribute("href");s&&(e.stop(),t.preventDefault(),qT(s))}),{context:"$capture"}),this.listenTo(t,"keydown",((t,i)=>{const n=e.commands.get("link").value;!!n&&i.keyCode===ra.enter&&i.altKey&&(t.stop(),qT(n))}))}_enableSelectionAttributesFixer(){const e=this.editor.model,t=e.document.selection;this.listenTo(t,"change:attribute",((i,{attributeKeys:n})=>{n.includes("linkHref")&&!t.hasAttribute("linkHref")&&e.change((t=>{var i;!function(e,t){e.removeSelectionAttribute("linkHref");for(const i of t)e.removeSelectionAttribute(i)}(t,(i=e.schema,i.getDefinition("$text").allowAttributes.filter((e=>e.startsWith("link")))))}))}))}_enableClipboardIntegration(){const e=this.editor,t=e.model,i=this.editor.config.get("link.defaultProtocol");i&&this.listenTo(e.plugins.get("ClipboardPipeline"),"contentInsertion",((e,n)=>{t.change((e=>{const t=e.createRangeIn(n.content);for(const n of t.getItems())if(n.hasAttribute("linkHref")){const t=WT(n.getAttribute("linkHref"),i);e.setAttribute("linkHref",t,n)}}))}))}constructor(e){super(e),e.config.define("link",{allowCreatingEmptyLinks:!1,addTargetToExternalLinks:!1})}}class eS extends Tg{getDecoratorSwitchesState(){return Array.from(this._manualDecoratorSwitches).reduce(((e,t)=>(e[t.name]=t.isOn,e)),{})}render(){super.render(),Vg({view:this});[this.urlInputView,...this._manualDecoratorSwitches,this.saveButtonView,this.cancelButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}isValid(){this.resetFormStatus();for(const e of this._validators){const t=e(this);if(t)return this.urlInputView.errorText=t,!1}return!0}resetFormStatus(){this.urlInputView.errorText=null}_createUrlInput(){const e=this.locale.t,t=new bf(this.locale,Qf);return t.label=e("Link URL"),t}_createButton(e,t,i,n){const s=new Hg(this.locale);return s.set({label:e,icon:t,tooltip:!0}),s.extendTemplate({attributes:{class:i}}),n&&s.delegate("execute").to(this,n),s}_createManualDecoratorSwitches(e){const t=this.createCollection();for(const i of e.manualDecorators){const n=new $g(this.locale);n.set({name:i.id,label:i.label,withText:!0}),n.bind("isOn").toMany([i,e],"value",((e,t)=>void 0===t&&void 0===e?!!i.defaultValue:!!e)),n.on("execute",(()=>{i.set("value",!n.isOn)})),t.add(n)}return t}_createFormChildren(e){const t=this.createCollection();if(t.add(this.urlInputView),e.length){const e=new Tg;e.setTemplate({tag:"ul",children:this._manualDecoratorSwitches.map((e=>({tag:"li",children:[e],attributes:{class:["ck","ck-list__item"]}}))),attributes:{class:["ck","ck-reset","ck-list"]}}),t.add(e)}return t.add(this.saveButtonView),t.add(this.cancelButtonView),t}get url(){const{element:e}=this.urlInputView.fieldView;return e?e.value.trim():null}constructor(e,t,i){super(e),this.focusTracker=new ya,this.keystrokes=new ka,this._focusables=new og;const n=e.t;this._validators=i,this.urlInputView=this._createUrlInput(),this.saveButtonView=this._createButton(n("Save"),Dm.check,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(n("Cancel"),Dm.cancel,"ck-button-cancel","cancel"),this._manualDecoratorSwitches=this._createManualDecoratorSwitches(t),this.children=this._createFormChildren(t.manualDecorators),this._focusCycler=new Tf({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}});const s=["ck","ck-link-form","ck-responsive-form"];t.manualDecorators.length&&s.push("ck-link-form_layout-vertical","ck-vertical-form"),this.setTemplate({tag:"form",attributes:{class:s,tabindex:"-1"},children:this.children})}}class tS extends Tg{render(){super.render();[this.previewButtonView,this.editButtonView,this.unlinkButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createButton(e,t,i){const n=new Hg(this.locale);return n.set({label:e,icon:t,tooltip:!0}),n.delegate("execute").to(this,i),n}_createPreviewButton(){const e=new Hg(this.locale),t=this.bindTemplate,i=this.t;return e.set({withText:!0,tooltip:i("Open link in new tab")}),e.extendTemplate({attributes:{class:["ck","ck-link-actions__preview"],href:t.to("href",(e=>e&&$T(e,this._linkConfig.allowedProtocols))),target:"_blank",rel:"noopener noreferrer"}}),e.bind("label").to(this,"href",(e=>e||i("This link has no URL"))),e.bind("isEnabled").to(this,"href",(e=>!!e)),e.template.tag="a",e.template.eventListeners={},e}constructor(e,t={}){super(e),this.focusTracker=new ya,this.keystrokes=new ka,this._focusables=new og;const i=e.t;this.previewButtonView=this._createPreviewButton(),this.unlinkButtonView=this._createButton(i("Unlink"),'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m11.077 15 .991-1.416a.75.75 0 1 1 1.229.86l-1.148 1.64a.748.748 0 0 1-.217.206 5.251 5.251 0 0 1-8.503-5.955.741.741 0 0 1 .12-.274l1.147-1.639a.75.75 0 1 1 1.228.86L4.933 10.7l.006.003a3.75 3.75 0 0 0 6.132 4.294l.006.004zm5.494-5.335a.748.748 0 0 1-.12.274l-1.147 1.639a.75.75 0 1 1-1.228-.86l.86-1.23a3.75 3.75 0 0 0-6.144-4.301l-.86 1.229a.75.75 0 0 1-1.229-.86l1.148-1.64a.748.748 0 0 1 .217-.206 5.251 5.251 0 0 1 8.503 5.955zm-4.563-2.532a.75.75 0 0 1 .184 1.045l-3.155 4.505a.75.75 0 1 1-1.229-.86l3.155-4.506a.75.75 0 0 1 1.045-.184zm4.919 10.562-1.414 1.414a.75.75 0 1 1-1.06-1.06l1.414-1.415-1.415-1.414a.75.75 0 0 1 1.061-1.06l1.414 1.414 1.414-1.415a.75.75 0 0 1 1.061 1.061l-1.414 1.414 1.414 1.415a.75.75 0 0 1-1.06 1.06l-1.415-1.414z"/></svg>',"unlink"),this.editButtonView=this._createButton(i("Edit link"),Dm.pencil,"edit"),this.set("href",void 0),this._linkConfig=t,this._focusCycler=new Tf({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-link-actions","ck-responsive-form"],tabindex:"-1"},children:[this.previewButtonView,this.editButtonView,this.unlinkButtonView]})}}var iS='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m11.077 15 .991-1.416a.75.75 0 1 1 1.229.86l-1.148 1.64a.748.748 0 0 1-.217.206 5.251 5.251 0 0 1-8.503-5.955.741.741 0 0 1 .12-.274l1.147-1.639a.75.75 0 1 1 1.228.86L4.933 10.7l.006.003a3.75 3.75 0 0 0 6.132 4.294l.006.004zm5.494-5.335a.748.748 0 0 1-.12.274l-1.147 1.639a.75.75 0 1 1-1.228-.86l.86-1.23a3.75 3.75 0 0 0-6.144-4.301l-.86 1.229a.75.75 0 0 1-1.229-.86l1.148-1.64a.748.748 0 0 1 .217-.206 5.251 5.251 0 0 1 8.503 5.955zm-4.563-2.532a.75.75 0 0 1 .184 1.045l-3.155 4.505a.75.75 0 1 1-1.229-.86l3.155-4.506a.75.75 0 0 1 1.045-.184z"/></svg>';const nS="link-ui";class sS extends Na{static get requires(){return[Tb]}static get pluginName(){return"LinkUI"}init(){const e=this.editor,t=this.editor.t;e.editing.view.addObserver(Du),this._balloon=e.plugins.get(Tb),this._createToolbarLinkButton(),this._enableBalloonActivators(),e.conversion.for("editingDowncast").markerToHighlight({model:nS,view:{classes:["ck-fake-link-selection"]}}),e.conversion.for("editingDowncast").markerToElement({model:nS,view:{name:"span",classes:["ck-fake-link-selection","ck-fake-link-selection_collapsed"]}}),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Create link"),keystroke:zT},{label:t("Move out of a link"),keystroke:[["arrowleft","arrowleft"],["arrowright","arrowright"]]}]})}destroy(){super.destroy(),this.formView&&this.formView.destroy(),this.actionsView&&this.actionsView.destroy()}_createViews(){this.actionsView=this._createActionsView(),this.formView=this._createFormView(),this._enableUserBalloonInteractions()}_createActionsView(){const e=this.editor,t=new tS(e.locale,e.config.get("link")),i=e.commands.get("link"),n=e.commands.get("unlink");return t.bind("href").to(i,"value"),t.editButtonView.bind("isEnabled").to(i),t.unlinkButtonView.bind("isEnabled").to(n),this.listenTo(t,"edit",(()=>{this._addFormView()})),this.listenTo(t,"unlink",(()=>{e.execute("unlink"),this._hideUI()})),t.keystrokes.set("Esc",((e,t)=>{this._hideUI(),t()})),t.keystrokes.set(zT,((e,t)=>{this._addFormView(),t()})),t}_createFormView(){const e=this.editor,t=e.commands.get("link"),i=e.config.get("link.defaultProtocol"),n=new(Pg(eS))(e.locale,t,function(e){const t=e.t,i=e.config.get("link.allowCreatingEmptyLinks");return[e=>{if(!i&&!e.url.length)return t("Link URL must not be empty.")}]}(e));return n.urlInputView.fieldView.bind("value").to(t,"value"),n.urlInputView.bind("isEnabled").to(t,"isEnabled"),n.saveButtonView.bind("isEnabled").to(t,"isEnabled"),this.listenTo(n,"submit",(()=>{if(n.isValid()){const{value:t}=n.urlInputView.fieldView.element,s=WT(t,i);e.execute("link",s,n.getDecoratorSwitchesState()),this._closeFormView()}})),this.listenTo(n.urlInputView,"change:errorText",(()=>{e.ui.update()})),this.listenTo(n,"cancel",(()=>{this._closeFormView()})),n.keystrokes.set("Esc",((e,t)=>{this._closeFormView(),t()})),n}_createToolbarLinkButton(){const e=this.editor,t=e.commands.get("link");e.ui.componentFactory.add("link",(()=>{const e=this._createButton(Hg);return e.set({tooltip:!0,isToggleable:!0}),e.bind("isOn").to(t,"value",(e=>!!e)),e})),e.ui.componentFactory.add("menuBar:link",(()=>this._createButton(uw)))}_createButton(e){const t=this.editor,i=t.locale,n=t.commands.get("link"),s=new e(t.locale),o=i.t;return s.set({label:o("Link"),icon:iS,keystroke:zT}),s.bind("isEnabled").to(n,"isEnabled"),this.listenTo(s,"execute",(()=>this._showUI(!0))),s}_enableBalloonActivators(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"click",(()=>{this._getSelectedLinkElement()&&this._showUI()})),e.keystrokes.set(zT,((t,i)=>{i(),e.commands.get("link").isEnabled&&this._showUI(!0)}))}_enableUserBalloonInteractions(){this.editor.keystrokes.set("Tab",((e,t)=>{this._areActionsVisible&&!this.actionsView.focusTracker.isFocused&&(this.actionsView.focus(),t())}),{priority:"high"}),this.editor.keystrokes.set("Esc",((e,t)=>{this._isUIVisible&&(this._hideUI(),t())})),Sg({emitter:this.formView,activator:()=>this._isUIInPanel,contextElements:()=>[this._balloon.view.element],callback:()=>this._hideUI()})}_addActionsView(){this.actionsView||this._createViews(),this._areActionsInPanel||this._balloon.add({view:this.actionsView,position:this._getBalloonPositionData()})}_addFormView(){if(this.formView||this._createViews(),this._isFormInPanel)return;const e=this.editor.commands.get("link");this.formView.disableCssTransitions(),this.formView.resetFormStatus(),this._balloon.add({view:this.formView,position:this._getBalloonPositionData()}),this.formView.urlInputView.fieldView.value=e.value||"",this._balloon.visibleView===this.formView&&this.formView.urlInputView.fieldView.select(),this.formView.enableCssTransitions()}_closeFormView(){const e=this.editor.commands.get("link");e.restoreManualDecoratorStates(),void 0!==e.value?this._removeFormView():this._hideUI()}_removeFormView(){this._isFormInPanel&&(this.formView.saveButtonView.focus(),this.formView.urlInputView.fieldView.reset(),this._balloon.remove(this.formView),this.editor.editing.view.focus(),this._hideFakeVisualSelection())}_showUI(e=!1){this.formView||this._createViews(),this._getSelectedLinkElement()?(this._areActionsVisible?this._addFormView():this._addActionsView(),e&&this._balloon.showStack("main")):(this._showFakeVisualSelection(),this._addActionsView(),e&&this._balloon.showStack("main"),this._addFormView()),this._startUpdatingUI()}_hideUI(){if(!this._isUIInPanel)return;const e=this.editor;this.stopListening(e.ui,"update"),this.stopListening(this._balloon,"change:visibleView"),e.editing.view.focus(),this._removeFormView(),this._balloon.remove(this.actionsView),this._hideFakeVisualSelection()}_startUpdatingUI(){const e=this.editor,t=e.editing.view.document;let i=this._getSelectedLinkElement(),n=o();const s=()=>{const e=this._getSelectedLinkElement(),t=o();i&&!e||!i&&t!==n?this._hideUI():this._isUIVisible&&this._balloon.updatePosition(this._getBalloonPositionData()),i=e,n=t};function o(){return t.selection.focus.getAncestors().reverse().find((e=>e.is("element")))}this.listenTo(e.ui,"update",s),this.listenTo(this._balloon,"change:visibleView",s)}get _isFormInPanel(){return!!this.formView&&this._balloon.hasView(this.formView)}get _areActionsInPanel(){return!!this.actionsView&&this._balloon.hasView(this.actionsView)}get _areActionsVisible(){return!!this.actionsView&&this._balloon.visibleView===this.actionsView}get _isUIInPanel(){return this._isFormInPanel||this._areActionsInPanel}get _isUIVisible(){const e=this._balloon.visibleView;return!!this.formView&&e==this.formView||this._areActionsVisible}_getBalloonPositionData(){const e=this.editor.editing.view,t=this.editor.model,i=e.document;let n;if(t.markers.has(nS)){const t=Array.from(this.editor.editing.mapper.markerNameToElements(nS)),i=e.createRange(e.createPositionBefore(t[0]),e.createPositionAfter(t[t.length-1]));n=e.domConverter.viewRangeToDom(i)}else n=()=>{const t=this._getSelectedLinkElement();return t?e.domConverter.mapViewToDom(t):e.domConverter.viewRangeToDom(i.selection.getFirstRange())};return{target:n}}_getSelectedLinkElement(){const e=this.editor.editing.view,t=e.document.selection,i=t.getSelectedElement();if(t.isCollapsed||i&&ny(i))return oS(t.getFirstPosition());{const i=t.getFirstRange().getTrimmed(),n=oS(i.start),s=oS(i.end);return n&&n==s&&e.createRangeIn(n).getTrimmed().isEqual(i)?n:null}}_showFakeVisualSelection(){const e=this.editor.model;e.change((t=>{const i=e.document.selection.getFirstRange();if(e.markers.has(nS))t.updateMarker(nS,{range:i});else if(i.start.isAtEnd){const n=i.start.getLastMatchingPosition((({item:t})=>!e.schema.isContent(t)),{boundaries:i});t.addMarker(nS,{usingOperation:!1,affectsData:!1,range:t.createRange(n,i.end)})}else t.addMarker(nS,{usingOperation:!1,affectsData:!1,range:i})}))}_hideFakeVisualSelection(){const e=this.editor.model;e.markers.has(nS)&&e.change((e=>{e.removeMarker(nS)}))}constructor(...e){super(...e),this.actionsView=null,this.formView=null}}function oS(e){return e.getAncestors().find((e=>{return(t=e).is("attributeElement")&&!!t.getCustomProperty("link");var t}))||null}const rS=new RegExp("(^|\\s)(((?:(?:(?:https?|ftp):)?\\/\\/)(?:\\S+(?::\\S*)?@)?(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(((?!www\\.)|(www\\.))(?![-_])(?:[-_a-z0-9\\u00a1-\\uffff]{1,63}\\.)+(?:[a-z\\u00a1-\\uffff]{2,63})))(?::\\d{2,5})?(?:[/?#]\\S*)?)|((www.|(\\S+@))((?![-_])(?:[-_a-z0-9\\u00a1-\\uffff]{1,63}\\.))+(?:[a-z\\u00a1-\\uffff]{2,63})))$","i");class aS extends Na{static get requires(){return[Rw,XT]}static get pluginName(){return"AutoLink"}init(){const e=this.editor.model.document.selection;e.on("change:range",(()=>{this.isEnabled=!e.anchor.parent.is("element","codeBlock")})),this._enableTypingHandling()}afterInit(){this._enableEnterHandling(),this._enableShiftEnterHandling(),this._enablePasteLinking()}_expandLinkRange(e,t){return t.textNode&&t.textNode.hasAttribute("linkHref")?Qw(t,"linkHref",t.textNode.getAttribute("linkHref"),e):null}_selectEntireLinks(e,t){const i=this.editor.model,n=i.document.selection,s=n.getFirstPosition(),o=n.getLastPosition();let r=t.getJoined(this._expandLinkRange(i,s)||t);r&&(r=r.getJoined(this._expandLinkRange(i,o)||t)),r&&(r.start.isBefore(s)||r.end.isAfter(o))&&e.setSelection(r)}_enablePasteLinking(){const e=this.editor,t=e.model,i=t.document.selection,n=e.plugins.get("ClipboardPipeline"),s=e.commands.get("link");n.on("inputTransformation",((e,n)=>{if(!this.isEnabled||!s.isEnabled||i.isCollapsed||"paste"!==n.method)return;if(i.rangeCount>1)return;const o=i.getFirstRange(),r=n.dataTransfer.getData("text/plain");if(!r)return;const a=r.match(rS);a&&a[2]===r&&(t.change((e=>{this._selectEntireLinks(e,o),s.execute(r)})),e.stop())}),{priority:"high"})}_enableTypingHandling(){const e=this.editor,t=new Mw(e.model,(e=>{if(!function(e){return e.length>4&&" "===e[e.length-1]&&" "!==e[e.length-2]}(e))return;const t=lS(e.substr(0,e.length-1));return t?{url:t}:void 0}));t.on("matched:data",((t,i)=>{const{batch:n,range:s,url:o}=i;if(!n.isTyping)return;const r=s.end.getShiftedBy(-1),a=r.getShiftedBy(-o.length),l=e.model.createRange(a,r);this._applyAutoLink(o,l)})),t.bind("isEnabled").to(this)}_enableEnterHandling(){const e=this.editor,t=e.model,i=e.commands.get("enter");i&&i.on("execute",(()=>{const e=t.document.selection.getFirstPosition();if(!e.parent.previousSibling)return;const i=t.createRangeIn(e.parent.previousSibling);this._checkAndApplyAutoLinkOnRange(i)}))}_enableShiftEnterHandling(){const e=this.editor,t=e.model,i=e.commands.get("shiftEnter");i&&i.on("execute",(()=>{const e=t.document.selection.getFirstPosition(),i=t.createRange(t.createPositionAt(e.parent,0),e.getShiftedBy(-1));this._checkAndApplyAutoLinkOnRange(i)}))}_checkAndApplyAutoLinkOnRange(e){const t=this.editor.model,{text:i,range:n}=Ow(e,t),s=lS(i);if(s){const e=t.createRange(n.end.getShiftedBy(-s.length),n.end);this._applyAutoLink(s,e)}}_applyAutoLink(e,t){const i=this.editor.model,n=WT(e,this.editor.config.get("link.defaultProtocol"));this.isEnabled&&function(e,t){return t.schema.checkAttributeInSelection(t.createSelection(e),"linkHref")}(t,i)&&jT(n)&&!function(e){const t=e.start.nodeAfter;return!!t&&t.hasAttribute("linkHref")}(t)&&this._persistAutoLink(n,t)}_persistAutoLink(e,t){const i=this.editor.model,n=this.editor.plugins.get("Delete");i.enqueueChange((s=>{s.setAttribute("linkHref",e,t),i.enqueueChange((()=>{n.requestUndoOnBackspace()}))}))}}function lS(e){const t=rS.exec(e);return t?t[2]:null}class cS extends Na{static get requires(){return[XT,sS,aS]}static get pluginName(){return"Link"}}class dS extends Na{static get requires(){return["ImageEditing","ImageUtils",XT]}static get pluginName(){return"LinkImageEditing"}afterInit(){const e=this.editor,t=e.model.schema;e.plugins.has("ImageBlockEditing")&&t.extend("imageBlock",{allowAttributes:["linkHref"]}),e.conversion.for("upcast").add(function(e){const t=e.plugins.has("ImageInlineEditing"),i=e.plugins.get("ImageUtils");return e=>{e.on("element:a",((e,n,s)=>{const o=n.viewItem,r=i.findViewImgElement(o);if(!r)return;const a=r.findAncestor((e=>i.isBlockImageView(e)));if(t&&!a)return;const l={attributes:["href"]};if(!s.consumable.consume(o,l))return;const c=o.getAttribute("href");if(!c)return;let d=n.modelCursor.parent;if(!d.is("element","imageBlock")){const e=s.convertItem(r,n.modelCursor);n.modelRange=e.modelRange,n.modelCursor=e.modelCursor,d=n.modelCursor.nodeBefore}d&&d.is("element","imageBlock")&&s.writer.setAttribute("linkHref",c,d)}),{priority:"high"})}}(e)),e.conversion.for("downcast").add(function(e){const t=e.plugins.get("ImageUtils");return e=>{e.on("attribute:linkHref:imageBlock",((e,i,n)=>{if(!n.consumable.consume(i.item,e.name))return;const s=n.mapper.toViewElement(i.item),o=n.writer,r=Array.from(s.getChildren()).find((e=>e.is("element","a"))),a=t.findViewImgElement(s),l=a.parent.is("element","picture")?a.parent:a;if(r)i.attributeNewValue?o.setAttribute("href",i.attributeNewValue,r):(o.move(o.createRangeOn(l),o.createPositionAt(s,0)),o.remove(r));else{const e=o.createContainerElement("a",{href:i.attributeNewValue});o.insert(o.createPositionAt(s,0),e),o.move(o.createRangeOn(l),o.createPositionAt(e,0))}}),{priority:"high"})}}(e)),this._enableAutomaticDecorators(),this._enableManualDecorators()}_enableAutomaticDecorators(){const e=this.editor,t=e.commands.get("link").automaticDecorators;t.length&&e.conversion.for("downcast").add(t.getDispatcherForLinkedImage())}_enableManualDecorators(){const e=this.editor,t=e.commands.get("link");for(const i of t.manualDecorators)e.plugins.has("ImageBlockEditing")&&e.model.schema.extend("imageBlock",{allowAttributes:i.id}),e.plugins.has("ImageInlineEditing")&&e.model.schema.extend("imageInline",{allowAttributes:i.id}),e.conversion.for("downcast").add(hS(i)),e.conversion.for("upcast").add(uS(e,i))}}function hS(e){return t=>{t.on(`attribute:${e.id}:imageBlock`,((t,i,n)=>{const s=n.mapper.toViewElement(i.item),o=Array.from(s.getChildren()).find((e=>e.is("element","a")));if(o){for(const[t,i]of Ca(e.attributes))n.writer.setAttribute(t,i,o);e.classes&&n.writer.addClass(e.classes,o);for(const t in e.styles)n.writer.setStyle(t,e.styles[t],o)}}))}}function uS(e,t){const i=e.plugins.has("ImageInlineEditing"),n=e.plugins.get("ImageUtils");return e=>{e.on("element:a",((e,s,o)=>{const r=s.viewItem,a=n.findViewImgElement(r);if(!a)return;const l=a.findAncestor((e=>n.isBlockImageView(e)));if(i&&!l)return;const c=new ol(t._createPattern()).match(r);if(!c)return;if(!o.consumable.consume(r,c.match))return;const d=s.modelCursor.nodeBefore||s.modelCursor.parent;o.writer.setAttribute(t.id,!0,d)}),{priority:"high"})}}class mS extends Na{static get requires(){return[XT,sS,"ImageBlockEditing"]}static get pluginName(){return"LinkImageUI"}init(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"click",((t,i)=>{this._isSelectedLinkedImage(e.model.document.selection)&&(i.preventDefault(),t.stop())}),{priority:"high"}),this._createToolbarLinkImageButton()}_createToolbarLinkImageButton(){const e=this.editor,t=e.t;e.ui.componentFactory.add("linkImage",(i=>{const n=new Hg(i),s=e.plugins.get("LinkUI"),o=e.commands.get("link");return n.set({isEnabled:!0,label:t("Link image"),icon:iS,keystroke:zT,tooltip:!0,isToggleable:!0}),n.bind("isEnabled").to(o,"isEnabled"),n.bind("isOn").to(o,"value",(e=>!!e)),this.listenTo(n,"execute",(()=>{this._isSelectedLinkedImage(e.model.document.selection)?s._addActionsView():s._showUI(!0)})),n}))}_isSelectedLinkedImage(e){const t=e.getSelectedElement();return this.editor.plugins.get("ImageUtils").isImage(t)&&t.hasAttribute("linkHref")}}class gS extends Na{static get requires(){return[dS,mS]}static get pluginName(){return"LinkImage"}}class fS{static first(e,t){return _a(new this(e,t)[Symbol.iterator]())}*[Symbol.iterator](){const e=[];for(const{node:t}of pS(this._getStartNode(),this._isForward?"forward":"backward")){const i=t.getAttribute("listIndent");if(i<this._referenceIndent){if(!this._lowerIndent)break;this._referenceIndent=i}else if(i>this._referenceIndent){if(!this._higherIndent)continue;if(!this._isForward){e.push(t);continue}}else{if(!this._sameIndent){if(this._higherIndent){e.length&&(yield*e,e.length=0);break}continue}if(this._sameAttributes.some((e=>t.getAttribute(e)!==this._startElement.getAttribute(e))))break}e.length&&(yield*e,e.length=0),yield t}}_getStartNode(){return this._includeSelf?this._startElement:this._isForward?this._startElement.nextSibling:this._startElement.previousSibling}constructor(e,t){this._startElement=e,this._referenceIndent=e.getAttribute("listIndent"),this._isForward="forward"==t.direction,this._includeSelf=!!t.includeSelf,this._sameAttributes=pa(t.sameAttributes||[]),this._sameIndent=!!t.sameIndent,this._lowerIndent=!!t.lowerIndent,this._higherIndent=!!t.higherIndent}}function*pS(e,t="forward"){const i="forward"==t,n=[];let s=null;for(;vS(e);){let t=null;if(s){const i=e.getAttribute("listIndent"),o=s.getAttribute("listIndent");i>o?n[o]=s:i<o?(t=n[i],n.length=i):t=s}yield{node:e,previous:s,previousNodeInList:t},s=e,e=i?e.nextSibling:e.previousSibling}}class bS{[Symbol.iterator](){return pS(this._listHead,"forward")}constructor(e){this._listHead=e}}class wS{static next(){return u()}}function vS(e){return!!e&&e.is("element")&&e.hasAttribute("listItemId")}function _S(e,t={}){return[...yS(e,{...t,direction:"backward"}),...yS(e,{...t,direction:"forward"})]}function yS(e,t={}){const i="forward"==t.direction,n=Array.from(new fS(e,{...t,includeSelf:i,sameIndent:!0,sameAttributes:"listItemId"}));return i?n:n.reverse()}function kS(e,t){const i=new fS(e,{sameIndent:!0,sameAttributes:"listType",...t}),n=new fS(e,{sameIndent:!0,sameAttributes:"listType",includeSelf:!0,direction:"forward",...t});return[...Array.from(i).reverse(),...n]}function CS(e){return!fS.first(e,{sameIndent:!0,sameAttributes:"listItemId"})}function xS(e){return!fS.first(e,{direction:"forward",sameIndent:!0,sameAttributes:"listItemId"})}function AS(e,t={}){e=pa(e);const i=!1!==t.withNested,n=new Set;for(const t of e)for(const e of _S(t,{higherIndent:i}))n.add(e);return RS(n)}function ES(e){e=pa(e);const t=new Set;for(const i of e)for(const e of kS(i))t.add(e);return RS(t)}function TS(e,t){const i=yS(e,{direction:"forward"}),n=wS.next();for(const e of i)t.setAttribute("listItemId",n,e);return i}function SS(e,t,i){const n={};for(const[e,i]of t.getAttributes())e.startsWith("list")&&(n[e]=i);const s=yS(e,{direction:"forward"});for(const e of s)i.setAttributes(n,e);return s}function IS(e,t,{expand:i,indentBy:n=1}={}){e=pa(e);const s=i?AS(e):e;for(const e of s){const i=e.getAttribute("listIndent")+n;i<0?PS(e,t):t.setAttribute("listIndent",i,e)}return s}function PS(e,t){e=pa(e);for(const i of e)i.is("element","listItem")&&t.rename(i,"paragraph");for(const i of e)for(const e of i.getAttributeKeys())e.startsWith("list")&&t.removeAttribute(e,i);return e}function VS(e){if(!e.length)return!1;const t=e[0].getAttribute("listItemId");return!!t&&!e.some((e=>e.getAttribute("listItemId")!=t))}function RS(e){return Array.from(e).filter((e=>"$graveyard"!==e.root.rootName)).sort(((e,t)=>e.index-t.index))}function BS(e){const t=e.document.selection.getSelectedElement();return t&&e.schema.isObject(t)&&e.schema.isBlock(t)?t:null}function OS(e,t){return t.checkChild(e.parent,"listItem")&&t.checkChild(e,"$text")&&!t.isObject(e)}function MS(e){return"numbered"==e||"customNumbered"==e}function LS(e,t,i){return yS(t,{direction:"forward"}).pop().index>e.index?SS(e,t,i):[]}class NS extends Da{refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model,t=FS(e.document.selection);e.change((e=>{const i=[];VS(t)&&!CS(t[0])?("forward"==this._direction&&i.push(...IS(t,e)),i.push(...TS(t[0],e))):"forward"==this._direction?i.push(...IS(t,e,{expand:!0})):i.push(...function(e,t){const i=AS(e=pa(e)),n=new Set,s=Math.min(...i.map((e=>e.getAttribute("listIndent")))),o=new Map;for(const e of i)o.set(e,fS.first(e,{lowerIndent:!0}));for(const e of i){if(n.has(e))continue;n.add(e);const i=e.getAttribute("listIndent")-1;if(i<0)PS(e,t);else{if(e.getAttribute("listIndent")==s){const i=LS(e,o.get(e),t);for(const e of i)n.add(e);if(i.length)continue}t.setAttribute("listIndent",i,e)}}return RS(n)}(t,e));for(const t of i){if(!t.hasAttribute("listType"))continue;const i=fS.first(t,{sameIndent:!0});i&&e.setAttribute("listType",i.getAttribute("listType"),t)}this._fireAfterExecute(i)}))}_fireAfterExecute(e){this.fire("afterExecute",RS(new Set(e)))}_checkEnabled(){let e=FS(this.editor.model.document.selection),t=e[0];if(!t)return!1;if("backward"==this._direction)return!0;if(VS(e)&&!CS(e[0]))return!0;e=AS(e),t=e[0];const i=fS.first(t,{sameIndent:!0});return!!i&&i.getAttribute("listType")==t.getAttribute("listType")}constructor(e,t){super(e),this._direction=t}}function FS(e){const t=Array.from(e.getSelectedBlocks()),i=t.findIndex((e=>!vS(e)));return-1!=i&&(t.length=i),t}class DS extends Da{refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,i=t.document,n=BS(t),s=Array.from(i.selection.getSelectedBlocks()).filter((e=>t.schema.checkAttribute(e,"listType")||OS(e,t.schema))),o=void 0!==e.forceValue?!e.forceValue:this.value;t.change((r=>{if(o){const e=s[s.length-1],t=yS(e,{direction:"forward"}),i=[];t.length>1&&i.push(...TS(t[1],r)),i.push(...PS(s,r)),i.push(...function(e,t){const i=[];let n=Number.POSITIVE_INFINITY;for(const{node:s}of pS(e.nextSibling,"forward")){const e=s.getAttribute("listIndent");if(0==e)break;e<n&&(n=e);const o=e-n;t.setAttribute("listIndent",o,s),i.push(s)}return i}(e,r)),this._fireAfterExecute(i)}else if((n||i.selection.isCollapsed)&&vS(s[0])){const t=kS(n||s[0],this._listWalkerOptions);for(const i of t)r.setAttributes({...e.additionalAttributes,listType:this.type},i);this._fireAfterExecute(t)}else{const i=[];for(const n of s)if(n.hasAttribute("listType"))for(const t of AS(n,{withNested:!1}))t.getAttribute("listType")!=this.type&&(r.setAttributes({...e.additionalAttributes,listType:this.type},t),i.push(t));else!n.is("element","listItem")&&OS(n,t.schema)&&r.rename(n,"listItem"),r.setAttributes({...e.additionalAttributes,listIndent:0,listItemId:wS.next(),listType:this.type},n),i.push(n);this._fireAfterExecute(i)}}))}_fireAfterExecute(e){this.fire("afterExecute",RS(new Set(e)))}_getValue(){const e=this.editor.model.document.selection,t=Array.from(e.getSelectedBlocks());if(!t.length)return!1;for(const e of t)if(e.getAttribute("listType")!=this.type)return!1;return!0}_checkEnabled(){const e=this.editor.model,t=e.schema,i=e.document.selection,n=Array.from(i.getSelectedBlocks());if(!n.length)return!1;if(this.value)return!0;for(const e of n)if(t.checkAttribute(e,"listType")||OS(e,t))return!0;return!1}constructor(e,t,i={}){super(e),this.type=t,this._listWalkerOptions=i.multiLevel?{higherIndent:!0,lowerIndent:!0,sameAttributes:[]}:void 0}}class zS extends Da{refresh(){this.isEnabled=this._checkEnabled()}execute({shouldMergeOnBlocksContentLevel:e=!1}={}){const t=this.editor.model,i=t.document.selection,n=[];t.change((s=>{const{firstElement:o,lastElement:r}=this._getMergeSubjectElements(i,e),a=o.getAttribute("listIndent")||0,l=r.getAttribute("listIndent"),c=r.getAttribute("listItemId");if(a!=l){const e=(d=r,Array.from(new fS(d,{direction:"forward",higherIndent:!0})));n.push(...IS([r,...e],s,{indentBy:a-l,expand:a<l}))}var d;if(e){let e=i;i.isCollapsed&&(e=s.createSelection(s.createRange(s.createPositionAt(o,"end"),s.createPositionAt(r,0)))),t.deleteContent(e,{doNotResetEntireContent:i.isCollapsed});const a=e.getLastPosition().parent,l=a.nextSibling;n.push(a),l&&l!==r&&l.getAttribute("listItemId")==c&&n.push(...SS(l,a,s))}else n.push(...SS(r,o,s));this._fireAfterExecute(n)}))}_fireAfterExecute(e){this.fire("afterExecute",RS(new Set(e)))}_checkEnabled(){const e=this.editor.model,t=e.document.selection,i=BS(e);if(t.isCollapsed||i){const e=i||t.getFirstPosition().parent;if(!vS(e))return!1;const n="backward"==this._direction?e.previousSibling:e.nextSibling;if(!n)return!1;if(VS([e,n]))return!1}else{const e=t.getLastPosition(),i=t.getFirstPosition();if(e.parent===i.parent)return!1;if(!vS(e.parent))return!1}return!0}_getMergeSubjectElements(e,t){const i=BS(this.editor.model);let n,s;if(e.isCollapsed||i){const o=i||e.getFirstPosition().parent,r=CS(o);"backward"==this._direction?(s=o,n=r&&!t?fS.first(o,{sameIndent:!0,lowerIndent:!0}):o.previousSibling):(n=o,s=o.nextSibling)}else n=e.getFirstPosition().parent,s=e.getLastPosition().parent;return{firstElement:n,lastElement:s}}constructor(e,t){super(e),this._direction=t}}class HS extends Da{refresh(){this.isEnabled=this._checkEnabled()}execute(){this.editor.model.change((e=>{const t=TS(this._getStartBlock(),e);this._fireAfterExecute(t)}))}_fireAfterExecute(e){this.fire("afterExecute",RS(new Set(e)))}_checkEnabled(){const e=this.editor.model.document.selection,t=this._getStartBlock();return e.isCollapsed&&vS(t)&&!CS(t)}_getStartBlock(){const e=this.editor.model.document.selection.getFirstPosition().parent;return"before"==this._direction?e:e.nextSibling}constructor(e,t){super(e),this._direction=t}}class $S extends Na{static get pluginName(){return"ListUtils"}expandListBlocksToCompleteList(e){return ES(e)}isFirstBlockOfListItem(e){return CS(e)}isListItemBlock(e){return vS(e)}expandListBlocksToCompleteItems(e,t={}){return AS(e,t)}isNumberedListType(e){return MS(e)}}function US(e){return e.is("element","ol")||e.is("element","ul")}function WS(e){return e.is("element","li")}function jS(e,t,i,n=KS(i,t)){return e.createAttributeElement(GS(i),null,{priority:2*t/100-100,id:n})}function qS(e,t,i){return e.createAttributeElement("li",null,{priority:(2*t+1)/100-100,id:i})}function GS(e){return"numbered"==e||"customNumbered"==e?"ol":"ul"}function KS(e,t){return`list-${e}-${t}`}function ZS(e,t){const i=e.nodeBefore;if(vS(i)){let e=i;for(const{node:i}of pS(e,"backward"))if(e=i,t.has(e))return;t.set(i,e)}else{const i=e.nodeAfter;vS(i)&&t.set(i,i)}}function JS(){return(e,t,i)=>{const{writer:n,schema:s}=i;if(!t.modelRange)return;const o=Array.from(t.modelRange.getItems({shallow:!0})).filter((e=>s.checkAttribute(e,"listItemId")));if(!o.length)return;const r=wS.next(),a=function(e){let t=0,i=e.parent;for(;i;){if(WS(i))t++;else{const e=i.previousSibling;e&&WS(e)&&t++}i=i.parent}return t}(t.viewItem);let l=t.viewItem.parent&&t.viewItem.parent.is("element","ol")?"numbered":"bulleted";const c=o[0].getAttribute("listType");c&&(l=c);const d={listItemId:r,listIndent:a,listType:l};for(const e of o)e.hasAttribute("listItemId")||n.setAttributes(d,e);o.length>1&&o[1].getAttribute("listItemId")!=d.listItemId&&i.keepEmptyElement(o[0])}}function QS(){return(e,t,i)=>{if(!i.consumable.test(t.viewItem,{name:!0}))return;const n=new Hu(t.viewItem.document);for(const e of Array.from(t.viewItem.getChildren()))WS(e)||US(e)||n.remove(e)}}function YS(e,t,i,{dataPipeline:n}={}){const s=function(e){return(t,i)=>{const n=[];for(const i of e)t.hasAttribute(i)&&n.push(`attribute:${i}`);return!!n.every((e=>!1!==i.test(t,e)))&&(n.forEach((e=>i.consume(t,e))),!0)}}(e);return(o,r,a)=>{const{writer:l,mapper:c,consumable:d}=a,h=r.item;if(!e.includes(r.attributeKey))return;if(!s(h,d))return;const u=function(e,t,i){const n=i.createRangeOn(e),s=t.toViewRange(n).getTrimmed();return s.end.nodeBefore}(h,c,i);eI(u,l,c),function(e,t){let i=e.parent;for(;i.is("attributeElement")&&["ul","ol","li"].includes(i.name);){const n=i.parent;t.unwrap(t.createRangeOn(e),i),i=n}}(u,l);const m=function(e,t,i,n,{dataPipeline:s}){let o=n.createRangeOn(t);if(!CS(e))return o;for(const r of i){if("itemMarker"!=r.scope)continue;const i=r.createElement(n,e,{dataPipeline:s});if(!i)continue;if(n.setCustomProperty("listItemMarker",!0,i),r.canInjectMarkerIntoElement&&r.canInjectMarkerIntoElement(e)?n.insert(n.createPositionAt(t,0),i):(n.insert(o.start,i),o=n.createRange(n.createPositionBefore(i),n.createPositionAfter(t))),!r.createWrapperElement||!r.canWrapElement)continue;const a=r.createWrapperElement(n,e,{dataPipeline:s});n.setCustomProperty("listItemWrapper",!0,a),r.canWrapElement(e)?o=n.wrap(o,a):(o=n.wrap(n.createRangeOn(i),a),o=n.createRange(o.start,n.createPositionAfter(t)))}return o}(h,u,t,l,{dataPipeline:n});!function(e,t,i,n){if(!e.hasAttribute("listIndent"))return;const s=e.getAttribute("listIndent");let o=e;for(let e=s;e>=0;e--){const s=qS(n,e,o.getAttribute("listItemId")),r=jS(n,e,o.getAttribute("listType"));for(const e of i)"list"!=e.scope&&"item"!=e.scope||!o.hasAttribute(e.attributeName)||e.setAttributeOnDowncast(n,o.getAttribute(e.attributeName),"list"==e.scope?r:s);if(t=n.wrap(t,s),t=n.wrap(t,r),0==e)break;if(o=fS.first(o,{lowerIndent:!0}),!o)break}}(h,m,t,l)}}function XS(e,{dataPipeline:t}={}){return(i,{writer:n})=>{if(!tI(i,e))return null;if(!t)return n.createContainerElement("span",{class:"ck-list-bogus-paragraph"});const s=n.createContainerElement("p");return n.setCustomProperty("dataPipeline:transparentRendering",!0,s),s}}function eI(e,t,i){for(;e.parent.is("attributeElement")&&e.parent.getCustomProperty("listItemWrapper");)t.unwrap(t.createRangeOn(e),e.parent);const n=[];s(t.createPositionBefore(e).getWalker({direction:"backward"})),s(t.createRangeIn(e).getWalker());for(const e of n)t.remove(e);function s(e){for(const{item:t}of e){if(t.is("element")&&i.toModelElement(t))break;t.is("element")&&t.getCustomProperty("listItemMarker")&&n.push(t)}}}function tI(e,t,i=_S(e)){if(!vS(e))return!1;for(const i of e.getAttributeKeys())if(!i.startsWith("selection:")&&!t.includes(i))return!1;return i.length<2}const iI=["listType","listIndent","listItemId"];class nI extends Na{static get pluginName(){return"ListEditing"}static get requires(){return[Kv,Rw,$S,Z_]}init(){const e=this.editor,t=e.model,i=e.config.get("list.multiBlock");if(e.plugins.has("LegacyListEditing"))throw new p("list-feature-conflict",this,{conflictPlugin:"LegacyListEditing"});t.schema.register("$listItem",{allowAttributes:iI}),i?(t.schema.extend("$container",{allowAttributesOf:"$listItem"}),t.schema.extend("$block",{allowAttributesOf:"$listItem"}),t.schema.extend("$blockObject",{allowAttributesOf:"$listItem"})):t.schema.register("listItem",{inheritAllFrom:"$block",allowAttributesOf:"$listItem"});for(const e of iI)t.schema.setAttributeProperties(e,{copyOnReplace:!0});e.commands.add("numberedList",new DS(e,"numbered")),e.commands.add("bulletedList",new DS(e,"bulleted")),e.commands.add("customNumberedList",new DS(e,"customNumbered",{multiLevel:!0})),e.commands.add("customBulletedList",new DS(e,"customBulleted",{multiLevel:!0})),e.commands.add("indentList",new NS(e,"forward")),e.commands.add("outdentList",new NS(e,"backward")),e.commands.add("splitListItemBefore",new HS(e,"before")),e.commands.add("splitListItemAfter",new HS(e,"after")),i&&(e.commands.add("mergeListItemBackward",new zS(e,"backward")),e.commands.add("mergeListItemForward",new zS(e,"forward"))),this._setupDeleteIntegration(),this._setupEnterIntegration(),this._setupTabIntegration(),this._setupClipboardIntegration(),this._setupAccessibilityIntegration()}afterInit(){const e=this.editor.commands,t=e.get("indent"),i=e.get("outdent");t&&t.registerChildCommand(e.get("indentList"),{priority:"high"}),i&&i.registerChildCommand(e.get("outdentList"),{priority:"lowest"}),this._setupModelPostFixing(),this._setupConversion()}registerDowncastStrategy(e){this._downcastStrategies.push(e)}getListAttributeNames(){return[...iI,...this._downcastStrategies.map((e=>e.attributeName))]}_setupDeleteIntegration(){const e=this.editor,t=e.commands.get("mergeListItemBackward"),i=e.commands.get("mergeListItemForward");this.listenTo(e.editing.view.document,"delete",((n,s)=>{const o=e.model.document.selection;BS(e.model)||e.model.change((()=>{const r=o.getFirstPosition();if(o.isCollapsed&&"backward"==s.direction){if(!r.isAtStart)return;const i=r.parent;if(!vS(i))return;if(fS.first(i,{sameAttributes:"listType",sameIndent:!0})||0!==i.getAttribute("listIndent")){if(!t||!t.isEnabled)return;t.execute({shouldMergeOnBlocksContentLevel:sI(e.model,"backward")})}else xS(i)||e.execute("splitListItemAfter"),e.execute("outdentList");s.preventDefault(),n.stop()}else{if(o.isCollapsed&&!o.getLastPosition().isAtEnd)return;if(!i||!i.isEnabled)return;i.execute({shouldMergeOnBlocksContentLevel:sI(e.model,"forward")}),s.preventDefault(),n.stop()}}))}),{context:"li"})}_setupEnterIntegration(){const e=this.editor,t=e.model,i=e.commands,n=i.get("enter");this.listenTo(e.editing.view.document,"enter",((i,n)=>{const s=t.document,o=s.selection.getFirstPosition().parent;if(s.selection.isCollapsed&&vS(o)&&o.isEmpty&&!n.isSoft){const t=CS(o),s=xS(o);t&&s?(e.execute("outdentList"),n.preventDefault(),i.stop()):t&&!s?(e.execute("splitListItemAfter"),n.preventDefault(),i.stop()):s&&(e.execute("splitListItemBefore"),n.preventDefault(),i.stop())}}),{context:"li"}),this.listenTo(n,"afterExecute",(()=>{const t=i.get("splitListItemBefore");if(t.refresh(),!t.isEnabled)return;2===_S(e.model.document.selection.getLastPosition().parent).length&&t.execute()}))}_setupTabIntegration(){const e=this.editor;this.listenTo(e.editing.view.document,"tab",((t,i)=>{const n=i.shiftKey?"outdentList":"indentList";this.editor.commands.get(n).isEnabled&&(e.execute(n),i.stopPropagation(),i.preventDefault(),t.stop())}),{context:"li"})}_setupConversion(){const e=this.editor,t=e.model,i=this.getListAttributeNames(),n=e.config.get("list.multiBlock"),s=n?"paragraph":"listItem";e.conversion.for("upcast").elementToElement({view:"li",model:(e,{writer:t})=>t.createElement(s,{listType:""})}).elementToElement({view:"p",model:(e,{writer:t})=>e.parent&&e.parent.is("element","li")?t.createElement(s,{listType:""}):null,converterPriority:"high"}).add((e=>{e.on("element:li",JS()),e.on("element:ul",QS(),{priority:"high"}),e.on("element:ol",QS(),{priority:"high"})})),n||e.conversion.for("downcast").elementToElement({model:"listItem",view:"p"}),e.conversion.for("editingDowncast").elementToElement({model:s,view:XS(i),converterPriority:"high"}).add((e=>{var n;e.on("attribute",YS(i,this._downcastStrategies,t)),e.on("remove",(n=t.schema,(e,t,i)=>{const{writer:s,mapper:o}=i,r=e.name.split(":")[1];if(!n.checkAttribute(r,"listItemId"))return;const a=o.toViewPosition(t.position),l=t.position.getShiftedBy(t.length),c=o.toViewPosition(l,{isPhantom:!0}),d=s.createRange(a,c).getTrimmed().end.nodeBefore;d&&eI(d,s,o)}))})),e.conversion.for("dataDowncast").elementToElement({model:s,view:XS(i,{dataPipeline:!0}),converterPriority:"high"}).add((e=>{e.on("attribute",YS(i,this._downcastStrategies,t,{dataPipeline:!0}))}));const o=(r=this._downcastStrategies,a=e.editing.view,(e,t)=>{if(t.modelPosition.offset>0)return;const i=t.modelPosition.parent;if(!vS(i))return;if(!r.some((e=>"itemMarker"==e.scope&&e.canInjectMarkerIntoElement&&e.canInjectMarkerIntoElement(i))))return;const n=t.mapper.toViewElement(i),s=a.createRangeIn(n),o=s.getWalker();let l=s.start;for(const{item:e}of o){if(e.is("element")&&t.mapper.toModelElement(e)||e.is("$textProxy"))break;e.is("element")&&e.getCustomProperty("listItemMarker")&&(l=a.createPositionAfter(e),o.skip((({previousPosition:e})=>!e.isEqual(l))))}t.viewPosition=l});var r,a;e.editing.mapper.on("modelToViewPosition",o),e.data.mapper.on("modelToViewPosition",o),this.listenTo(t.document,"change:data",function(e,t,i,n){return()=>{const n=e.document.differ.getChanges(),r=[],a=new Map,l=new Set;for(const e of n)if("insert"==e.type&&"$text"!=e.name)ZS(e.position,a),e.attributes.has("listItemId")?l.add(e.position.nodeAfter):ZS(e.position.getShiftedBy(e.length),a);else if("remove"==e.type&&e.attributes.has("listItemId"))ZS(e.position,a);else if("attribute"==e.type){const t=e.range.start.nodeAfter;i.includes(e.attributeKey)?(ZS(e.range.start,a),null===e.attributeNewValue?(ZS(e.range.start.getShiftedBy(1),a),o(t)&&r.push(t)):l.add(t)):vS(t)&&o(t)&&r.push(t)}for(const e of a.values())r.push(...s(e,l));for(const e of new Set(r))t.reconvertItem(e)};function s(e,t){const n=[],s=new Set,a=[];for(const{node:l,previous:c}of pS(e,"forward")){if(s.has(l))continue;const e=l.getAttribute("listIndent");c&&e<c.getAttribute("listIndent")&&(a.length=e+1),a[e]=Object.fromEntries(Array.from(l.getAttributes()).filter((([e])=>i.includes(e))));const d=yS(l,{direction:"forward"});for(const e of d)s.add(e),(o(e,d)||r(e,a,t))&&n.push(e)}return n}function o(e,s){const o=t.mapper.toViewElement(e);if(!o)return!1;if(n.fire("checkElement",{modelElement:e,viewElement:o}))return!0;if(!e.is("element","paragraph")&&!e.is("element","listItem"))return!1;const r=tI(e,i,s);return!(!r||!o.is("element","p"))||!(r||!o.is("element","span"))}function r(e,i,s){if(s.has(e))return!1;const o=t.mapper.toViewElement(e);let r=i.length-1;for(let e=o.parent;!e.is("editableElement");e=e.parent){const t=WS(e),s=US(e);if(!s&&!t)continue;const o="checkAttributes:"+(t?"item":"list");if(n.fire(o,{viewElement:e,modelAttributes:i[r]}))break;if(s&&(r--,r<0))return!1}return!0}}(t,e.editing,i,this),{priority:"high"}),this.on("checkAttributes:item",((e,{viewElement:t,modelAttributes:i})=>{t.id!=i.listItemId&&(e.return=!0,e.stop())})),this.on("checkAttributes:list",((e,{viewElement:t,modelAttributes:i})=>{t.name==GS(i.listType)&&t.id==KS(i.listType,i.listIndent)||(e.return=!0,e.stop())}))}_setupModelPostFixing(){const e=this.editor.model,t=this.getListAttributeNames();e.document.registerPostFixer((i=>function(e,t,i,n){const s=e.document.differ.getChanges(),o=new Map,r=n.editor.config.get("list.multiBlock");let a=!1;for(const n of s){if("insert"==n.type&&"$text"!=n.name){const s=n.position.nodeAfter;if(!e.schema.checkAttribute(s,"listItemId"))for(const e of Array.from(s.getAttributeKeys()))i.includes(e)&&(t.removeAttribute(e,s),a=!0);ZS(n.position,o),n.attributes.has("listItemId")||ZS(n.position.getShiftedBy(n.length),o);for(const{item:t,previousPosition:i}of e.createRangeIn(s))vS(t)&&ZS(i,o)}else"remove"==n.type?ZS(n.position,o):"attribute"==n.type&&i.includes(n.attributeKey)&&(ZS(n.range.start,o),null===n.attributeNewValue&&ZS(n.range.start.getShiftedBy(1),o));if(!r&&"attribute"==n.type&&iI.includes(n.attributeKey)){const e=n.range.start.nodeAfter;null===n.attributeNewValue&&e&&e.is("element","listItem")?(t.rename(e,"paragraph"),a=!0):null===n.attributeOldValue&&e&&e.is("element")&&"listItem"!=e.name&&(t.rename(e,"listItem"),a=!0)}}const l=new Set;for(const e of o.values())a=n.fire("postFixer",{listNodes:new bS(e),listHead:e,writer:t,seenIds:l})||a;return a}(e,i,t,this))),this.on("postFixer",((e,{listNodes:t,writer:i})=>{e.return=function(e,t){let i=0,n=-1,s=null,o=!1;for(const{node:r}of e){const e=r.getAttribute("listIndent");if(e>i){let a;null===s?(s=e-i,a=i):(s>e&&(s=e),a=e-s),a>n+1&&(a=n+1),t.setAttribute("listIndent",a,r),o=!0,n=a}else s=null,i=e+1,n=e}return o}(t,i)||e.return}),{priority:"high"}),this.on("postFixer",((e,{listNodes:t,writer:i,seenIds:n})=>{e.return=function(e,t,i){const n=new Set;let s=!1;for(const{node:o}of e){if(n.has(o))continue;let e=o.getAttribute("listType"),r=o.getAttribute("listItemId");if(t.has(r)&&(r=wS.next()),t.add(r),o.is("element","listItem"))o.getAttribute("listItemId")!=r&&(i.setAttribute("listItemId",r,o),s=!0);else for(const t of yS(o,{direction:"forward"}))n.add(t),t.getAttribute("listType")!=e&&(r=wS.next(),e=t.getAttribute("listType")),t.getAttribute("listItemId")!=r&&(i.setAttribute("listItemId",r,t),s=!0)}return s}(t,n,i)||e.return}),{priority:"high"})}_setupClipboardIntegration(){const e=this.editor.model,t=this.editor.plugins.get("ClipboardPipeline");this.listenTo(e,"insertContent",function(e){return(t,[i,n])=>{const s=i.is("documentFragment")?Array.from(i.getChildren()):[i];if(!s.length)return;const o=(n?e.createSelection(n):e.document.selection).getFirstPosition();let r;if(vS(o.parent))r=o.parent;else{if(!vS(o.nodeBefore))return;r=o.nodeBefore}e.change((e=>{const t=r.getAttribute("listType"),i=r.getAttribute("listIndent"),n=s[0].getAttribute("listIndent")||0,o=Math.max(i-n,0);for(const i of s){const n=vS(i);r.is("element","listItem")&&i.is("element","paragraph")&&e.rename(i,"listItem"),e.setAttributes({listIndent:(n?i.getAttribute("listIndent"):0)+o,listItemId:n?i.getAttribute("listItemId"):wS.next(),listType:t},i)}}))}}(e),{priority:"high"}),this.listenTo(t,"outputTransformation",((t,i)=>{e.change((e=>{const t=Array.from(i.content.getChildren()),n=t[t.length-1];if(t.length>1&&n.is("element")&&n.isEmpty){t.slice(0,-1).every(vS)&&e.remove(n)}if("copy"==i.method||"cut"==i.method){const t=Array.from(i.content.getChildren());VS(t)&&PS(t,e)}}))}))}_setupAccessibilityIntegration(){const e=this.editor,t=e.t;e.accessibility.addKeystrokeInfoGroup({id:"list",label:t("Keystrokes that can be used in a list"),keystrokes:[{label:t("Increase list item indent"),keystroke:"Tab"},{label:t("Decrease list item indent"),keystroke:"Shift+Tab"}]})}constructor(e){super(e),this._downcastStrategies=[],e.config.define("list.multiBlock",!0)}}function sI(e,t){const i=e.document.selection;if(!i.isCollapsed)return!BS(e);if("forward"===t)return!0;const n=i.getFirstPosition().parent,s=n.previousSibling;return!e.schema.isObject(s)&&(!!s.isEmpty||VS([n,s]))}function oI(e,t,i,n){e.ui.componentFactory.add(t,(()=>{const s=rI(Hg,e,t,i,n);return s.set({tooltip:!0,isToggleable:!0}),s})),e.ui.componentFactory.add(`menuBar:${t}`,(()=>rI(uw,e,t,i,n)))}function rI(e,t,i,n,s){const o=t.commands.get(i),r=new e(t.locale);return r.set({label:n,icon:s}),r.bind("isOn","isEnabled").to(o,"value","isEnabled"),r.on("execute",(()=>{t.execute(i),t.editing.view.focus()})),r}class aI extends Na{static get pluginName(){return"ListUI"}init(){const e=this.editor.t;oI(this.editor,"numberedList",e("Numbered List"),Dm.numberedList),oI(this.editor,"bulletedList",e("Bulleted List"),Dm.bulletedList)}}class lI extends Na{static get requires(){return[nI,aI]}static get pluginName(){return"List"}}class cI extends Da{refresh(){const e=this._getValue();this.value=e,this.isEnabled=null!=e}execute({startIndex:e=1}={}){const t=this.editor.model,i=t.document;let n=Array.from(i.selection.getSelectedBlocks()).filter((e=>vS(e)&&MS(e.getAttribute("listType"))));n=ES(n),t.change((t=>{for(const i of n)t.setAttribute("listStart",e>=0?e:1,i)}))}_getValue(){const e=_a(this.editor.model.document.selection.getSelectedBlocks());return e&&vS(e)&&MS(e.getAttribute("listType"))?e.getAttribute("listStart"):null}}const dI={},hI={},uI={},mI=[{listStyle:"disc",typeAttribute:"disc",listType:"bulleted"},{listStyle:"circle",typeAttribute:"circle",listType:"bulleted"},{listStyle:"square",typeAttribute:"square",listType:"bulleted"},{listStyle:"decimal",typeAttribute:"1",listType:"numbered"},{listStyle:"decimal-leading-zero",typeAttribute:null,listType:"numbered"},{listStyle:"lower-roman",typeAttribute:"i",listType:"numbered"},{listStyle:"upper-roman",typeAttribute:"I",listType:"numbered"},{listStyle:"lower-alpha",typeAttribute:"a",listType:"numbered"},{listStyle:"upper-alpha",typeAttribute:"A",listType:"numbered"},{listStyle:"lower-latin",typeAttribute:"a",listType:"numbered"},{listStyle:"upper-latin",typeAttribute:"A",listType:"numbered"}];for(const{listStyle:e,typeAttribute:t,listType:i}of mI)dI[e]=i,hI[e]=t,t&&(uI[t]=e);function gI(){return mI.map((e=>e.listStyle))}function fI(e){return dI[e]||null}function pI(e){return uI[e]||null}function bI(e){return hI[e]||null}class wI extends Da{refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,i=t.document;t.change((t=>{this._tryToConvertItemsToList(e);let n=Array.from(i.selection.getSelectedBlocks()).filter((e=>e.hasAttribute("listType")));if(n.length){n=ES(n);for(const i of n)t.setAttribute("listStyle",e.type||this.defaultType,i)}}))}isStyleTypeSupported(e){return!this._supportedTypes||this._supportedTypes.includes(e)}_getValue(){const e=_a(this.editor.model.document.selection.getSelectedBlocks());return vS(e)?e.getAttribute("listStyle"):null}_checkEnabled(){const e=this.editor,t=e.commands.get("numberedList"),i=e.commands.get("bulletedList");return t.isEnabled||i.isEnabled}_tryToConvertItemsToList(e){if(!e.type)return;const t=fI(e.type);if(!t)return;const i=this.editor,n=`${t}List`;i.commands.get(n).value||i.execute(n)}constructor(e,t,i){super(e),this.defaultType=t,this._supportedTypes=i}}class vI extends Da{refresh(){const e=this._getValue();this.value=e,this.isEnabled=null!=e}execute(e={}){const t=this.editor.model,i=t.document;let n=Array.from(i.selection.getSelectedBlocks()).filter((e=>vS(e)&&"numbered"==e.getAttribute("listType")));n=ES(n),t.change((t=>{for(const i of n)t.setAttribute("listReversed",!!e.reversed,i)}))}_getValue(){const e=_a(this.editor.model.document.selection.getSelectedBlocks());return vS(e)&&"numbered"==e.getAttribute("listType")?e.getAttribute("listReversed"):null}}function _I(e){return(t,i,n)=>{const{writer:s,schema:o,consumable:r}=n;if(!1===r.test(i.viewItem,e.viewConsumables))return;i.modelRange||Object.assign(i,n.convertChildren(i.viewItem,i.modelCursor));let a=!1;for(const t of i.modelRange.getItems({shallow:!0}))o.checkAttribute(t,e.attributeName)&&e.appliesToListItem(t)&&(t.hasAttribute(e.attributeName)||(s.setAttribute(e.attributeName,e.getAttributeOnUpcast(i.viewItem),t),a=!0));a&&r.consume(i.viewItem,e.viewConsumables)}}class yI extends Na{static get pluginName(){return"ListPropertiesUtils"}getAllSupportedStyleTypes(){return gI()}getListTypeFromListStyleType(e){return fI(e)}getListStyleTypeFromTypeAttribute(e){return pI(e)}getTypeAttributeFromListStyleType(e){return bI(e)}}const kI="default";class CI extends Na{static get requires(){return[nI,yI]}static get pluginName(){return"ListPropertiesEditing"}init(){const e=this.editor,t=e.model,i=e.plugins.get(nI),n=function(e){const t=[];if(e.styles){const i="object"==typeof e.styles&&e.styles.useAttribute;t.push({attributeName:"listStyle",defaultValue:kI,viewConsumables:{styles:"list-style-type"},addCommand(e){let t=gI();i&&(t=t.filter((e=>!!bI(e)))),e.commands.add("listStyle",new wI(e,kI,t))},appliesToListItem:e=>"numbered"==e.getAttribute("listType")||"bulleted"==e.getAttribute("listType"),hasValidAttribute(e){if(!this.appliesToListItem(e))return!e.hasAttribute("listStyle");if(!e.hasAttribute("listStyle"))return!1;const t=e.getAttribute("listStyle");return t==kI||fI(t)==e.getAttribute("listType")},setAttributeOnDowncast(e,t,n){if(t&&t!==kI){if(!i)return void e.setStyle("list-style-type",t,n);{const i=bI(t);if(i)return void e.setAttribute("type",i,n)}}e.removeStyle("list-style-type",n),e.removeAttribute("type",n)},getAttributeOnUpcast(e){const t=e.getStyle("list-style-type");if(t)return t;const i=e.getAttribute("type");return i?pI(i):kI}})}e.reversed&&t.push({attributeName:"listReversed",defaultValue:!1,viewConsumables:{attributes:"reversed"},addCommand(e){e.commands.add("listReversed",new vI(e))},appliesToListItem:e=>"numbered"==e.getAttribute("listType"),hasValidAttribute(e){return this.appliesToListItem(e)==e.hasAttribute("listReversed")},setAttributeOnDowncast(e,t,i){t?e.setAttribute("reversed","reversed",i):e.removeAttribute("reversed",i)},getAttributeOnUpcast:e=>e.hasAttribute("reversed")});e.startIndex&&t.push({attributeName:"listStart",defaultValue:1,viewConsumables:{attributes:"start"},addCommand(e){e.commands.add("listStart",new cI(e))},appliesToListItem:e=>MS(e.getAttribute("listType")),hasValidAttribute(e){return this.appliesToListItem(e)==e.hasAttribute("listStart")},setAttributeOnDowncast(e,t,i){0==t||t>1?e.setAttribute("start",t,i):e.removeAttribute("start",i)},getAttributeOnUpcast(e){const t=e.getAttribute("start");return t>=0?t:1}});return t}(e.config.get("list.properties"));for(const s of n)s.addCommand(e),t.schema.extend("$listItem",{allowAttributes:s.attributeName}),i.registerDowncastStrategy({scope:"list",attributeName:s.attributeName,setAttributeOnDowncast(e,t,i){s.setAttributeOnDowncast(e,t,i)}});e.conversion.for("upcast").add((e=>{for(const t of n)e.on("element:ol",_I(t)),e.on("element:ul",_I(t))})),i.on("checkAttributes:list",((e,{viewElement:t,modelAttributes:i})=>{for(const s of n)s.getAttributeOnUpcast(t)!=i[s.attributeName]&&(e.return=!0,e.stop())})),this.listenTo(e.commands.get("indentList"),"afterExecute",((e,i)=>{t.change((e=>{for(const t of i)for(const i of n)i.appliesToListItem(t)&&e.setAttribute(i.attributeName,i.defaultValue,t)}))})),i.on("postFixer",((e,{listNodes:t,writer:i})=>{for(const{node:s}of t)for(const t of n)t.hasValidAttribute(s)||(t.appliesToListItem(s)?i.setAttribute(t.attributeName,t.defaultValue,s):i.removeAttribute(t.attributeName,s),e.return=!0)})),i.on("postFixer",((e,{listNodes:t,writer:i})=>{for(const{node:s,previousNodeInList:o}of t)if(o&&o.getAttribute("listType")==s.getAttribute("listType"))for(const t of n){const{attributeName:n}=t;if(!t.appliesToListItem(s))continue;const r=o.getAttribute(n);s.getAttribute(n)!=r&&(i.setAttribute(n,r,s),e.return=!0)}}))}constructor(e){super(e),e.config.define("list.properties",{styles:!0,startIndex:!1,reversed:!1})}}class xI extends Tg{render(){if(super.render(),this.stylesView){this.focusables.add(this.stylesView),this.focusTracker.add(this.stylesView.element),(this.startIndexFieldView||this.reversedSwitchButtonView)&&(this.focusables.add(this.children.last.buttonView),this.focusTracker.add(this.children.last.buttonView.element));for(const e of this.stylesView.children)this.stylesView.focusTracker.add(e.element);Rg({keystrokeHandler:this.stylesView.keystrokes,focusTracker:this.stylesView.focusTracker,gridItems:this.stylesView.children,numberOfColumns:()=>_r.window.getComputedStyle(this.stylesView.element).getPropertyValue("grid-template-columns").split(" ").length,uiLanguageDirection:this.locale&&this.locale.uiLanguageDirection})}if(this.startIndexFieldView){this.focusables.add(this.startIndexFieldView),this.focusTracker.add(this.startIndexFieldView.element);const e=e=>e.stopPropagation();this.keystrokes.set("arrowright",e),this.keystrokes.set("arrowleft",e),this.keystrokes.set("arrowup",e),this.keystrokes.set("arrowdown",e)}this.reversedSwitchButtonView&&(this.focusables.add(this.reversedSwitchButtonView),this.focusTracker.add(this.reversedSwitchButtonView.element)),this.keystrokes.listenTo(this.element)}focus(){this.focusCycler.focusFirst()}focusLast(){this.focusCycler.focusLast()}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}_createStylesView(e,t){const i=new Tg(this.locale);return i.children=i.createCollection(),i.children.addMany(e),i.setTemplate({tag:"div",attributes:{"aria-label":t,class:["ck","ck-list-styles-list"]},children:i.children}),i.children.delegate("execute").to(this),i.focus=function(){this.children.first.focus()},i.focusTracker=new ya,i.keystrokes=new ka,i.render(),i.keystrokes.listenTo(i.element),i}_addNumberedListPropertyViews(e){const t=this.locale.t,i=[];e.startIndex&&(this.startIndexFieldView=this._createStartIndexField(),i.push(this.startIndexFieldView)),e.reversed&&(this.reversedSwitchButtonView=this._createReversedSwitchButton(),i.push(this.reversedSwitchButtonView)),e.styles?(this.additionalPropertiesCollapsibleView=new qg(this.locale,i),this.additionalPropertiesCollapsibleView.set({label:t("List properties"),isCollapsed:!0}),this.additionalPropertiesCollapsibleView.buttonView.bind("isEnabled").toMany(i,"isEnabled",((...e)=>e.some((e=>e)))),this.additionalPropertiesCollapsibleView.buttonView.on("change:isEnabled",((e,t,i)=>{i||(this.additionalPropertiesCollapsibleView.isCollapsed=!0)})),this.children.add(this.additionalPropertiesCollapsibleView)):this.children.addMany(i)}_createStartIndexField(){const e=this.locale.t,t=new bf(this.locale,Yf);return t.set({label:e("Start at"),class:"ck-numbered-list-properties__start-index"}),t.fieldView.set({min:0,step:1,value:1,inputMode:"numeric"}),t.fieldView.on("input",(()=>{const i=t.fieldView.element,n=i.valueAsNumber;Number.isNaN(n)?t.errorText=e("Invalid start index value."):i.checkValidity()?this.fire("listStart",{startIndex:n}):t.errorText=e("Start index must be greater than 0.")})),t}_createReversedSwitchButton(){const e=this.locale.t,t=new $g(this.locale);return t.set({withText:!0,label:e("Reversed order"),class:"ck-numbered-list-properties__reversed-order"}),t.delegate("execute").to(this,"listReversed"),t}constructor(e,{enabledProperties:t,styleButtonViews:i,styleGridAriaLabel:n}){super(e),this.stylesView=null,this.additionalPropertiesCollapsibleView=null,this.startIndexFieldView=null,this.reversedSwitchButtonView=null,this.focusTracker=new ya,this.keystrokes=new ka,this.focusables=new og;const s=["ck","ck-list-properties"];this.children=this.createCollection(),this.focusCycler=new Tf({focusables:this.focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),t.styles?(this.stylesView=this._createStylesView(i,n),this.children.add(this.stylesView)):s.push("ck-list-properties_without-styles"),(t.startIndex||t.reversed)&&(this._addNumberedListPropertyViews(t),s.push("ck-list-properties_with-numbered-properties")),this.setTemplate({tag:"div",attributes:{class:s},children:this.children})}}class AI extends Na{static get pluginName(){return"ListPropertiesUI"}init(){const e=this.editor,t=e.locale.t,i=e.config.get("list.properties");if(i.styles){const n=[{label:t("Toggle the disc list style"),tooltip:t("Disc"),type:"disc",icon:'<svg viewBox="0 0 44 44" xmlns="http://www.w3.org/2000/svg"><path d="M35 29a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17zm0-9a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17zm0-9a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17z" fill-opacity=".163"/><path d="M11 27a3 3 0 1 1 0 6 3 3 0 0 1 0-6zm0-9a3 3 0 1 1 0 6 3 3 0 0 1 0-6zm0-9a3 3 0 1 1 0 6 3 3 0 0 1 0-6z"/></svg>'},{label:t("Toggle the circle list style"),tooltip:t("Circle"),type:"circle",icon:'<svg viewBox="0 0 44 44" xmlns="http://www.w3.org/2000/svg"><path d="M35 29a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17zm0-9a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17zm0-9a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17z" fill-opacity=".163"/><path d="M11 27a3 3 0 1 1 0 6 3 3 0 0 1 0-6zm0 1a2 2 0 1 0 0 4 2 2 0 0 0 0-4zm0-10a3 3 0 1 1 0 6 3 3 0 0 1 0-6zm0 1a2 2 0 1 0 0 4 2 2 0 0 0 0-4zm0-10a3 3 0 1 1 0 6 3 3 0 0 1 0-6zm0 1a2 2 0 1 0 0 4 2 2 0 0 0 0-4z"/></svg>'},{label:t("Toggle the square list style"),tooltip:t("Square"),type:"square",icon:'<svg viewBox="0 0 44 44" xmlns="http://www.w3.org/2000/svg"><path d="M35 29a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17zm0-9a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17zm0-9a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17z" fill-opacity=".163"/><path d="M14 27v6H8v-6h6zm0-9v6H8v-6h6zm0-9v6H8V9h6z"/></svg>'}],s=t("Bulleted List"),o=t("Bulleted list styles toolbar"),r="bulletedList";e.ui.componentFactory.add(r,EI({editor:e,propertiesConfig:i,parentCommandName:r,buttonLabel:s,buttonIcon:Dm.bulletedList,styleGridAriaLabel:o,styleDefinitions:n})),e.ui.componentFactory.add(`menuBar:${r}`,SI({editor:e,propertiesConfig:i,parentCommandName:r,buttonLabel:s,styleGridAriaLabel:o,styleDefinitions:n}))}if(i.styles||i.startIndex||i.reversed){const n=[{label:t("Toggle the decimal list style"),tooltip:t("Decimal"),type:"decimal",icon:'<svg viewBox="0 0 44 44" xmlns="http://www.w3.org/2000/svg"><path d="M35 29a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17zm0-9a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17zm0-9a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17z" fill-opacity=".163"/><path d="M10.29 15V8.531H9.286c-.14.393-.4.736-.778 1.03-.378.295-.728.495-1.05.6v1.121a4.257 4.257 0 0 0 1.595-.936V15h1.235zm3.343 0v-1.235h-1.235V15h1.235zM11.3 24v-1.147H8.848c.064-.111.148-.226.252-.343.104-.117.351-.354.74-.712.39-.357.66-.631.81-.821.225-.288.39-.562.494-.824.104-.263.156-.539.156-.829 0-.51-.182-.936-.545-1.279-.363-.342-.863-.514-1.499-.514-.58 0-1.063.148-1.45.444-.387.296-.617.784-.69 1.463l1.23.124c.024-.36.112-.619.264-.774.153-.155.358-.233.616-.233.26 0 .465.074.613.222.148.148.222.36.222.635 0 .25-.085.501-.255.756-.126.185-.468.536-1.024 1.055-.692.641-1.155 1.156-1.389 1.544-.234.389-.375.8-.422 1.233H11.3zm2.333 0v-1.235h-1.235V24h1.235zM9.204 34.11c.615 0 1.129-.2 1.542-.598.413-.398.62-.88.62-1.446 0-.39-.11-.722-.332-.997a1.5 1.5 0 0 0-.886-.532c.619-.337.928-.788.928-1.353 0-.399-.151-.756-.453-1.073-.366-.386-.852-.58-1.459-.58a2.25 2.25 0 0 0-.96.2 1.617 1.617 0 0 0-.668.55c-.16.232-.28.544-.358.933l1.138.194c.032-.282.123-.495.272-.642.15-.146.33-.22.54-.22.215 0 .386.065.515.194s.193.302.193.518c0 .255-.087.46-.263.613-.176.154-.43.227-.765.218l-.136 1.006c.22-.061.409-.092.567-.092.24 0 .444.09.61.272.168.182.251.428.251.739 0 .328-.087.589-.261.782a.833.833 0 0 1-.644.29.841.841 0 0 1-.607-.242c-.167-.16-.27-.394-.307-.698l-1.196.145c.062.542.285.98.668 1.316.384.335.868.503 1.45.503zm4.43-.11v-1.235h-1.236V34h1.235z"/></svg>'},{label:t("Toggle the decimal with leading zero list style"),tooltip:t("Decimal with leading zero"),type:"decimal-leading-zero",icon:'<svg viewBox="0 0 44 44" xmlns="http://www.w3.org/2000/svg"><path d="M35 29a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17zm0-9a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17zm0-9a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17z" fill-opacity=".163"/><path d="M5.714 15.11c.624 0 1.11-.22 1.46-.66.421-.533.632-1.408.632-2.627 0-1.222-.21-2.096-.629-2.624-.351-.445-.839-.668-1.463-.668-.624 0-1.11.22-1.459.66-.422.533-.633 1.406-.633 2.619 0 1.236.192 2.095.576 2.577.384.482.89.723 1.516.723zm0-1.024a.614.614 0 0 1-.398-.14c-.115-.094-.211-.283-.287-.565-.077-.283-.115-.802-.115-1.558s.043-1.294.128-1.613c.064-.246.155-.417.272-.512a.617.617 0 0 1 .4-.143.61.61 0 0 1 .398.143c.116.095.211.284.288.567.076.283.114.802.114 1.558s-.043 1.292-.128 1.608c-.064.246-.155.417-.272.512a.617.617 0 0 1-.4.143zm6.078.914V8.531H10.79c-.14.393-.4.736-.778 1.03-.378.295-.728.495-1.05.6v1.121a4.257 4.257 0 0 0 1.595-.936V15h1.235zm3.344 0v-1.235h-1.235V15h1.235zm-9.422 9.11c.624 0 1.11-.22 1.46-.66.421-.533.632-1.408.632-2.627 0-1.222-.21-2.096-.629-2.624-.351-.445-.839-.668-1.463-.668-.624 0-1.11.22-1.459.66-.422.533-.633 1.406-.633 2.619 0 1.236.192 2.095.576 2.577.384.482.89.723 1.516.723zm0-1.024a.614.614 0 0 1-.398-.14c-.115-.094-.211-.283-.287-.565-.077-.283-.115-.802-.115-1.558s.043-1.294.128-1.613c.064-.246.155-.417.272-.512a.617.617 0 0 1 .4-.143.61.61 0 0 1 .398.143c.116.095.211.284.288.567.076.283.114.802.114 1.558s-.043 1.292-.128 1.608c-.064.246-.155.417-.272.512a.617.617 0 0 1-.4.143zm7.088.914v-1.147H10.35c.065-.111.149-.226.253-.343.104-.117.35-.354.74-.712.39-.357.66-.631.81-.821.225-.288.39-.562.493-.824.104-.263.156-.539.156-.829 0-.51-.181-.936-.544-1.279-.364-.342-.863-.514-1.499-.514-.58 0-1.063.148-1.45.444-.387.296-.617.784-.69 1.463l1.23.124c.024-.36.112-.619.264-.774.152-.155.357-.233.615-.233.261 0 .465.074.613.222.148.148.222.36.222.635 0 .25-.085.501-.255.756-.126.185-.467.536-1.024 1.055-.691.641-1.154 1.156-1.388 1.544-.235.389-.375.8-.422 1.233h4.328zm2.334 0v-1.235h-1.235V24h1.235zM5.714 34.11c.624 0 1.11-.22 1.46-.66.421-.533.632-1.408.632-2.627 0-1.222-.21-2.096-.629-2.624-.351-.445-.839-.668-1.463-.668-.624 0-1.11.22-1.459.66-.422.533-.633 1.406-.633 2.619 0 1.236.192 2.095.576 2.577.384.482.89.723 1.516.723zm0-1.024a.614.614 0 0 1-.398-.14c-.115-.094-.211-.283-.287-.565-.077-.283-.115-.802-.115-1.558s.043-1.294.128-1.613c.064-.246.155-.417.272-.512a.617.617 0 0 1 .4-.143.61.61 0 0 1 .398.143c.116.095.211.284.288.567.076.283.114.802.114 1.558s-.043 1.292-.128 1.608c-.064.246-.155.417-.272.512a.617.617 0 0 1-.4.143zm4.992 1.024c.616 0 1.13-.2 1.543-.598.413-.398.62-.88.62-1.446 0-.39-.111-.722-.332-.997a1.5 1.5 0 0 0-.886-.532c.618-.337.927-.788.927-1.353 0-.399-.15-.756-.452-1.073-.366-.386-.853-.58-1.46-.58a2.25 2.25 0 0 0-.96.2 1.617 1.617 0 0 0-.667.55c-.16.232-.28.544-.359.933l1.139.194c.032-.282.123-.495.272-.642.15-.146.33-.22.54-.22.214 0 .386.065.515.194s.193.302.193.518c0 .255-.088.46-.264.613-.175.154-.43.227-.764.218l-.136 1.006c.22-.061.408-.092.566-.092.24 0 .444.09.611.272.167.182.25.428.25.739 0 .328-.086.589-.26.782a.833.833 0 0 1-.644.29.841.841 0 0 1-.607-.242c-.167-.16-.27-.394-.308-.698l-1.195.145c.062.542.284.98.668 1.316.384.335.867.503 1.45.503zm4.43-.11v-1.235h-1.235V34h1.235z"/></svg>'},{label:t("Toggle the lower–roman list style"),tooltip:t("Lower–roman"),type:"lower-roman",icon:'<svg viewBox="0 0 44 44" xmlns="http://www.w3.org/2000/svg"><path d="M35 29a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17zm0-9a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17zm0-9a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17z" fill-opacity=".163"/><path d="M11.88 8.7V7.558h-1.234V8.7h1.234zm0 5.3V9.333h-1.234V14h1.234zm2.5 0v-1.235h-1.234V14h1.235zm-4.75 4.7v-1.142H8.395V18.7H9.63zm0 5.3v-4.667H8.395V24H9.63zm2.5-5.3v-1.142h-1.234V18.7h1.235zm0 5.3v-4.667h-1.234V24h1.235zm2.501 0v-1.235h-1.235V24h1.235zM7.38 28.7v-1.142H6.145V28.7H7.38zm0 5.3v-4.667H6.145V34H7.38zm2.5-5.3v-1.142H8.646V28.7H9.88zm0 5.3v-4.667H8.646V34H9.88zm2.5-5.3v-1.142h-1.234V28.7h1.235zm0 5.3v-4.667h-1.234V34h1.235zm2.501 0v-1.235h-1.235V34h1.235z"/></svg>'},{label:t("Toggle the upper–roman list style"),tooltip:t("Upper-roman"),type:"upper-roman",icon:'<svg viewBox="0 0 44 44" xmlns="http://www.w3.org/2000/svg"><path d="M35 29a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17zm0-9a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17zm0-9a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17z" fill-opacity=".163"/><path d="M11.916 15V8.558h-1.301V15h1.3zm2.465 0v-1.235h-1.235V15h1.235zM9.665 25v-6.442h-1.3V25h1.3zm2.5 0v-6.442h-1.3V25h1.3zm2.466 0v-1.235h-1.235V25h1.235zm-7.216 9v-6.442h-1.3V34h1.3zm2.5 0v-6.442h-1.3V34h1.3zm2.501 0v-6.442h-1.3V34h1.3zm2.465 0v-1.235h-1.235V34h1.235z"/></svg>'},{label:t("Toggle the lower–latin list style"),tooltip:t("Lower-latin"),type:"lower-latin",icon:'<svg viewBox="0 0 44 44" xmlns="http://www.w3.org/2000/svg"><path d="M35 29a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17zm0-9a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17zm0-9a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17z" fill-opacity=".163"/><path d="M9.62 14.105c.272 0 .528-.05.768-.153s.466-.257.677-.462c.009.024.023.072.044.145.047.161.086.283.119.365h1.221a2.649 2.649 0 0 1-.222-.626c-.04-.195-.059-.498-.059-.908l.013-1.441c0-.536-.055-.905-.165-1.105-.11-.201-.3-.367-.569-.497-.27-.13-.68-.195-1.23-.195-.607 0-1.064.108-1.371.325-.308.217-.525.55-.65 1.002l1.12.202c.076-.217.176-.369.299-.455.123-.086.294-.13.514-.13.325 0 .546.05.663.152.118.101.176.27.176.508v.123c-.222.093-.622.194-1.2.303-.427.082-.755.178-.982.288-.227.11-.403.268-.53.474a1.327 1.327 0 0 0-.188.706c0 .398.138.728.415.988.277.261.656.391 1.136.391zm.368-.87a.675.675 0 0 1-.492-.189.606.606 0 0 1-.193-.448c0-.176.08-.32.241-.435.106-.07.33-.142.673-.215a7.19 7.19 0 0 0 .751-.19v.247c0 .296-.016.496-.048.602a.773.773 0 0 1-.295.409 1.07 1.07 0 0 1-.637.22zm4.645.765v-1.235h-1.235V14h1.235zM10.2 25.105c.542 0 1.003-.215 1.382-.646.38-.43.57-1.044.57-1.84 0-.771-.187-1.362-.559-1.774a1.82 1.82 0 0 0-1.41-.617c-.522 0-.973.216-1.354.65v-2.32H7.594V25h1.147v-.686a1.9 1.9 0 0 0 .67.592c.26.133.523.2.79.2zm-.299-.975c-.354 0-.638-.164-.852-.492-.153-.232-.229-.59-.229-1.073 0-.468.098-.818.295-1.048a.93.93 0 0 1 .738-.345c.302 0 .55.118.743.354.193.236.29.62.29 1.154 0 .5-.096.868-.288 1.1-.192.233-.424.35-.697.35zm4.478.87v-1.235h-1.234V25h1.234zm-4.017 9.105c.6 0 1.08-.142 1.437-.426.357-.284.599-.704.725-1.261l-1.213-.207c-.061.326-.167.555-.316.688a.832.832 0 0 1-.576.2.916.916 0 0 1-.75-.343c-.185-.228-.278-.62-.278-1.173 0-.498.091-.853.274-1.066.183-.212.429-.318.736-.318.232 0 .42.061.565.184.145.123.238.306.28.55l1.216-.22c-.146-.501-.387-.874-.722-1.119-.336-.244-.788-.366-1.356-.366-.695 0-1.245.214-1.653.643-.407.43-.61 1.03-.61 1.8 0 .762.202 1.358.608 1.788.406.431.95.646 1.633.646zM14.633 34v-1.235h-1.235V34h1.235z"/></svg>'},{label:t("Toggle the upper–latin list style"),tooltip:t("Upper-latin"),type:"upper-latin",icon:'<svg viewBox="0 0 44 44" xmlns="http://www.w3.org/2000/svg"><path d="M35 29a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17zm0-9a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17zm0-9a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17z" fill-opacity=".163"/><path d="m7.88 15 .532-1.463h2.575L11.549 15h1.415l-2.58-6.442H9.01L6.5 15h1.38zm2.69-2.549H8.811l.87-2.39.887 2.39zM14.88 15v-1.235h-1.234V15h1.234zM9.352 25c.83-.006 1.352-.02 1.569-.044.346-.038.636-.14.872-.305.236-.166.422-.387.558-.664.137-.277.205-.562.205-.855 0-.372-.106-.695-.317-.97-.21-.276-.512-.471-.905-.585a1.51 1.51 0 0 0 .661-.567 1.5 1.5 0 0 0 .244-.83c0-.28-.066-.53-.197-.754a1.654 1.654 0 0 0-.495-.539 1.676 1.676 0 0 0-.672-.266c-.25-.042-.63-.063-1.14-.063H7.158V25h2.193zm.142-3.88H8.46v-1.49h.747c.612 0 .983.007 1.112.022.217.026.38.102.49.226.11.125.165.287.165.486a.68.68 0 0 1-.192.503.86.86 0 0 1-.525.23 11.47 11.47 0 0 1-.944.023h.18zm.17 2.795H8.46v-1.723h1.05c.592 0 .977.03 1.154.092.177.062.313.16.406.295a.84.84 0 0 1 .14.492c0 .228-.06.41-.181.547a.806.806 0 0 1-.473.257c-.126.026-.423.04-.892.04zM14.88 25v-1.235h-1.234V25h1.234zm-5.018 9.11c.691 0 1.262-.17 1.711-.512.45-.341.772-.864.965-1.567l-1.261-.4c-.109.472-.287.818-.536 1.037-.25.22-.547.33-.892.33-.47 0-.85-.173-1.143-.519-.293-.345-.44-.925-.44-1.74 0-.767.15-1.322.447-1.665.297-.343.684-.514 1.162-.514.346 0 .64.096.881.29.242.193.4.457.477.79l1.288-.307c-.147-.516-.367-.911-.66-1.187-.492-.465-1.132-.698-1.92-.698-.902 0-1.63.296-2.184.89-.554.593-.83 1.426-.83 2.498 0 1.014.275 1.813.825 2.397.551.585 1.254.877 2.11.877zM14.88 34v-1.235h-1.234V34h1.234z"/></svg>'}],s=t("Numbered List"),o=t("Numbered list styles toolbar"),r="numberedList";e.ui.componentFactory.add(r,EI({editor:e,propertiesConfig:i,parentCommandName:r,buttonLabel:s,buttonIcon:Dm.numberedList,styleGridAriaLabel:o,styleDefinitions:n})),i.styles&&e.ui.componentFactory.add(`menuBar:${r}`,SI({editor:e,propertiesConfig:i,parentCommandName:r,buttonLabel:s,styleGridAriaLabel:o,styleDefinitions:n}))}}}function EI({editor:e,propertiesConfig:t,parentCommandName:i,buttonLabel:n,buttonIcon:s,styleGridAriaLabel:o,styleDefinitions:r}){const a=e.commands.get(i);return l=>{const c=Wf(l,Uf),d=c.buttonView;return c.bind("isEnabled").to(a),c.class="ck-list-styles-dropdown",d.on("execute",(()=>{e.execute(i),e.editing.view.focus()})),d.set({label:n,icon:s,tooltip:!0,isToggleable:!0}),d.bind("isOn").to(a,"value",(e=>!!e)),c.once("change:isOpen",(()=>{const n=function({editor:e,propertiesConfig:t,dropdownView:i,parentCommandName:n,styleDefinitions:s,styleGridAriaLabel:o}){const r=e.locale,a={...t};"numberedList"!=n&&(a.startIndex=!1,a.reversed=!1);let l=null;if(a.styles){const t=e.commands.get("listStyle"),i=TI({editor:e,parentCommandName:n,listStyleCommand:t}),o=II(t);l=s.filter(o).map(i)}const c=new xI(r,{styleGridAriaLabel:o,enabledProperties:a,styleButtonViews:l});a.styles&&Zf(i,(()=>c.stylesView.children.find((e=>e.isOn))));if(a.startIndex){const t=e.commands.get("listStart");c.startIndexFieldView.bind("isEnabled").to(t),c.startIndexFieldView.fieldView.bind("value").to(t),c.on("listStart",((t,i)=>e.execute("listStart",i)))}if(a.reversed){const t=e.commands.get("listReversed");c.reversedSwitchButtonView.bind("isEnabled").to(t),c.reversedSwitchButtonView.bind("isOn").to(t,"value",(e=>!!e)),c.on("listReversed",(()=>{const i=t.value;e.execute("listReversed",{reversed:!i})}))}return c.delegate("execute").to(i),c}({editor:e,propertiesConfig:t,dropdownView:c,parentCommandName:i,styleGridAriaLabel:o,styleDefinitions:r});c.panelView.children.add(n)})),c.on("execute",(()=>{e.editing.view.focus()})),c}}function TI({editor:e,listStyleCommand:t,parentCommandName:i}){const n=e.locale,s=e.commands.get(i);return({label:o,type:r,icon:a,tooltip:l})=>{const c=new Hg(n);return c.set({label:o,icon:a,tooltip:l}),t.on("change:value",(()=>{c.isOn=t.value===r})),c.on("execute",(()=>{s.value?t.value===r?e.execute(i):t.value!==r&&e.execute("listStyle",{type:r}):e.model.change((()=>{e.execute("listStyle",{type:r})}))})),c}}function SI({editor:e,propertiesConfig:t,parentCommandName:i,buttonLabel:n,styleGridAriaLabel:s,styleDefinitions:o}){return r=>{const a=new dw(r),l=e.commands.get(i),c=e.commands.get("listStyle"),d=II(c),h=TI({editor:e,parentCommandName:i,listStyleCommand:c}),u=o.filter(d).map(h),m=new xI(r,{styleGridAriaLabel:s,enabledProperties:{...t,startIndex:!1,reversed:!1},styleButtonViews:u});return m.delegate("execute").to(a),a.buttonView.set({label:n,icon:Dm[i]}),a.panelView.children.add(m),a.bind("isEnabled").to(l,"isEnabled"),a.on("execute",(()=>{e.editing.view.focus()})),a}}function II(e){return"function"==typeof e.isStyleTypeSupported?t=>e.isStyleTypeSupported(t.type):()=>!0}class PI extends Na{static get requires(){return[CI,AI]}static get pluginName(){return"ListProperties"}}class VI extends Da{refresh(){const e=this._getSelectedItems();this.value=this._getValue(e),this.isEnabled=!!e.length}execute(e={}){this.editor.model.change((t=>{const i=this._getSelectedItems(),n=void 0===e.forceValue?!this._getValue(i):e.forceValue;for(const e of i)n?t.setAttribute("todoListChecked",!0,e):t.removeAttribute("todoListChecked",e)}))}_getValue(e){return e.every((e=>e.getAttribute("todoListChecked")))}_getSelectedItems(){const e=this.editor.model,t=e.schema,i=e.document.selection.getFirstRange(),n=i.start.parent,s=[];t.checkAttribute(n,"todoListChecked")&&s.push(..._S(n));for(const e of i.getItems({shallow:!0}))t.checkAttribute(e,"todoListChecked")&&!s.includes(e)&&s.push(..._S(e));return s}constructor(e){super(e),this.on("execute",(()=>{this.refresh()}),{priority:"highest"})}}class RI extends Sc{onDomEvent(e){if(e.target){const t=this.view.domConverter.mapDomToView(e.target);t&&t.is("element","input")&&"checkbox"==t.getAttribute("type")&&t.findAncestor({classes:"todo-list__label"})&&this.fire("todoCheckboxChange",e)}}constructor(...e){super(...e),this.domEventType=["change"]}}const BI=ca("Ctrl+Enter");class OI extends Na{static get pluginName(){return"TodoListEditing"}static get requires(){return[nI]}init(){const e=this.editor,t=e.model,i=e.editing,n=e.plugins.get(nI),s=e.config.get("list.multiBlock")?"paragraph":"listItem";e.commands.add("todoList",new DS(e,"todo")),e.commands.add("checkTodoList",new VI(e)),i.view.addObserver(RI),t.schema.extend("$listItem",{allowAttributes:"todoListChecked"}),t.schema.addAttributeCheck(((e,t)=>{const i=e.last;if("todoListChecked"==t)return!(!i.getAttribute("listItemId")||"todo"!=i.getAttribute("listType"))&&void 0})),e.conversion.for("upcast").add((e=>{e.on("element:input",((e,t,i)=>{const n=t.modelCursor,s=n.parent,o=t.viewItem;if(!i.consumable.test(o,{name:!0}))return;if("checkbox"!=o.getAttribute("type")||!n.isAtStart||!s.hasAttribute("listType"))return;i.consumable.consume(o,{name:!0});const r=i.writer;r.setAttribute("listType","todo",s),t.viewItem.hasAttribute("checked")&&r.setAttribute("todoListChecked",!0,s),t.modelRange=r.createRange(n)})),e.on("element:label",MI({name:"label",classes:"todo-list__label"})),e.on("element:label",MI({name:"label",classes:["todo-list__label","todo-list__label_without-description"]})),e.on("element:span",MI({name:"span",classes:"todo-list__label__description"})),e.on("element:ul",function(e){const t=new ol(e);return(e,i,n)=>{const s=t.match(i.viewItem);if(!s)return;const o=s.match;o.name=!1,n.consumable.consume(i.viewItem,o)}}({name:"ul",classes:"todo-list"}))})),e.conversion.for("downcast").elementToElement({model:s,view:(e,{writer:t})=>{if(LI(e,n.getListAttributeNames()))return t.createContainerElement("span",{class:"todo-list__label__description"})},converterPriority:"highest"}),n.registerDowncastStrategy({scope:"list",attributeName:"listType",setAttributeOnDowncast(e,t,i){"todo"==t?e.addClass("todo-list",i):e.removeClass("todo-list",i)}}),n.registerDowncastStrategy({scope:"itemMarker",attributeName:"todoListChecked",createElement(e,t,{dataPipeline:i}){if("todo"!=t.getAttribute("listType"))return null;const n=e.createUIElement("input",{type:"checkbox",...t.getAttribute("todoListChecked")?{checked:"checked"}:null,...i?{disabled:"disabled"}:{tabindex:"-1"}});if(i)return n;const s=e.createContainerElement("span",{contenteditable:"false"},n);return s.getFillerOffset=()=>null,s},canWrapElement:e=>LI(e,n.getListAttributeNames()),createWrapperElement(e,t,{dataPipeline:i}){const s=["todo-list__label"];return LI(t,n.getListAttributeNames())||s.push("todo-list__label_without-description"),e.createAttributeElement(i?"label":"span",{class:s.join(" ")})}}),n.on("checkElement",((e,{modelElement:t,viewElement:i})=>{const s=LI(t,n.getListAttributeNames());i.hasClass("todo-list__label__description")!=s&&(e.return=!0,e.stop())})),n.on("checkElement",((t,{modelElement:i,viewElement:n})=>{const s="todo"==i.getAttribute("listType")&&CS(i);let o=!1;const r=e.editing.view.createPositionBefore(n).getWalker({direction:"backward"});for(const{item:t}of r){if(t.is("element")&&e.editing.mapper.toModelElement(t))break;t.is("element","input")&&"checkbox"==t.getAttribute("type")&&(o=!0)}o!=s&&(t.return=!0,t.stop())})),n.on("postFixer",((e,{listNodes:t,writer:i})=>{for(const{node:n,previousNodeInList:s}of t){if(!s)continue;if(s.getAttribute("listItemId")!=n.getAttribute("listItemId"))continue;const t=s.hasAttribute("todoListChecked"),o=n.hasAttribute("todoListChecked");o&&!t?(i.removeAttribute("todoListChecked",n),e.return=!0):!o&&t&&(i.setAttribute("todoListChecked",!0,n),e.return=!0)}})),t.document.registerPostFixer((e=>{const i=t.document.differ.getChanges();let n=!1;for(const t of i)if("attribute"==t.type&&"listType"==t.attributeKey){const i=t.range.start.nodeAfter;"todo"==t.attributeOldValue&&i.hasAttribute("todoListChecked")&&(e.removeAttribute("todoListChecked",i),n=!0)}else if("insert"==t.type&&"$text"!=t.name)for(const{item:i}of e.createRangeOn(t.position.nodeAfter))i.is("element")&&"todo"!=i.getAttribute("listType")&&i.hasAttribute("todoListChecked")&&(e.removeAttribute("todoListChecked",i),n=!0);return n})),this.listenTo(i.view.document,"keydown",((t,i)=>{la(i)===BI&&(e.execute("checkTodoList"),t.stop())}),{priority:"high"}),this.listenTo(i.view.document,"todoCheckboxChange",((e,t)=>{const n=t.target;if(!n||!n.is("element","input"))return;const s=i.view.createPositionAfter(n),o=i.mapper.toModelPosition(s).parent;o&&vS(o)&&"todo"==o.getAttribute("listType")&&this._handleCheckmarkChange(o)})),this.listenTo(i.view.document,"arrowKey",function(e,t){return(i,n)=>{const s=ua(n.keyCode,t.contentLanguageDirection),o=e.schema,r=e.document.selection;if(!r.isCollapsed)return;const a=r.getFirstPosition(),l=a.parent;if("right"==s&&a.isAtEnd){const t=o.getNearestSelectionRange(e.createPositionAfter(l),"forward");if(!t)return;const s=t.start.parent;s&&vS(s)&&"todo"==s.getAttribute("listType")&&(e.change((e=>e.setSelection(t))),n.preventDefault(),n.stopPropagation(),i.stop())}else if("left"==s&&a.isAtStart&&vS(l)&&"todo"==l.getAttribute("listType")){const t=o.getNearestSelectionRange(e.createPositionBefore(l),"backward");if(!t)return;e.change((e=>e.setSelection(t))),n.preventDefault(),n.stopPropagation(),i.stop()}}}(t,e.locale),{context:"$text"}),this.listenTo(i.mapper,"viewToModelPosition",((e,i)=>{const n=i.viewPosition.parent,s=n.is("attributeElement","li")&&0==i.viewPosition.offset,o=NI(n)&&i.viewPosition.offset<=1,r=n.is("element","span")&&"false"==n.getAttribute("contenteditable")&&NI(n.parent);if(!s&&!o&&!r)return;const a=i.modelPosition.nodeAfter;a&&"todo"==a.getAttribute("listType")&&(i.modelPosition=t.createPositionAt(a,0))}),{priority:"low"}),this._initAriaAnnouncements()}_handleCheckmarkChange(e){const t=this.editor,i=t.model,n=Array.from(i.document.selection.getRanges());i.change((i=>{i.setSelection(e,"end"),t.execute("checkTodoList"),i.setSelection(n)}))}_initAriaAnnouncements(){const{model:e,ui:t,t:i}=this.editor;let n=null;t&&e.document.selection.on("change:range",(()=>{const s=e.document.selection.focus.parent,o=FI(n),r=FI(s);o&&!r?t.ariaLiveAnnouncer.announce(i("Leaving a to-do list")):!o&&r&&t.ariaLiveAnnouncer.announce(i("Entering a to-do list")),n=s}))}}function MI(e){const t=new ol(e);return(e,i,n)=>{const s=t.match(i.viewItem);s&&n.consumable.consume(i.viewItem,s.match)&&Object.assign(i,n.convertChildren(i.viewItem,i.modelCursor))}}function LI(e,t){return(e.is("element","paragraph")||e.is("element","listItem"))&&"todo"==e.getAttribute("listType")&&CS(e)&&function(e,t){for(const i of e.getAttributeKeys())if(!i.startsWith("selection:")&&!t.includes(i))return!1;return!0}(e,t)}function NI(e){return!!e&&e.is("attributeElement")&&e.hasClass("todo-list__label")}function FI(e){return!!e&&(!(!e.is("element","paragraph")&&!e.is("element","listItem"))&&"todo"==e.getAttribute("listType"))}class DI extends Na{static get pluginName(){return"TodoListUI"}init(){const e=this.editor.t;oI(this.editor,"todoList",e("To-do List"),Dm.todoList)}}class zI extends Na{static get requires(){return[OI,DI]}static get pluginName(){return"TodoList"}}class HI extends Da{refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,i=t.document,n=Array.from(i.selection.getSelectedBlocks()).filter((e=>UI(e,t.schema))),s=void 0!==e.forceValue?!e.forceValue:this.value;t.change((e=>{if(s){let t=n[n.length-1].nextSibling,i=Number.POSITIVE_INFINITY,s=[];for(;t&&"listItem"==t.name&&0!==t.getAttribute("listIndent");){const e=t.getAttribute("listIndent");e<i&&(i=e);const n=e-i;s.push({element:t,listIndent:n}),t=t.nextSibling}s=s.reverse();for(const t of s)e.setAttribute("listIndent",t.listIndent,t.element)}if(!s){let e=Number.POSITIVE_INFINITY;for(const t of n)t.is("element","listItem")&&t.getAttribute("listIndent")<e&&(e=t.getAttribute("listIndent"));e=0===e?1:e,$I(n,!0,e),$I(n,!1,e)}for(const t of n.reverse())s&&"listItem"==t.name?e.rename(t,"paragraph"):s||"listItem"==t.name?s||"listItem"!=t.name||t.getAttribute("listType")==this.type||e.setAttribute("listType",this.type,t):(e.setAttributes({listType:this.type,listIndent:0},t),e.rename(t,"listItem"));this.fire("_executeCleanup",n)}))}_getValue(){const e=_a(this.editor.model.document.selection.getSelectedBlocks());return!!e&&e.is("element","listItem")&&e.getAttribute("listType")==this.type}_checkEnabled(){if(this.value)return!0;const e=this.editor.model.document.selection,t=this.editor.model.schema,i=_a(e.getSelectedBlocks());return!!i&&UI(i,t)}constructor(e,t){super(e),this.type=t}}function $I(e,t,i){const n=t?e[0]:e[e.length-1];if(n.is("element","listItem")){let s=n[t?"previousSibling":"nextSibling"],o=n.getAttribute("listIndent");for(;s&&s.is("element","listItem")&&s.getAttribute("listIndent")>=i;)o>s.getAttribute("listIndent")&&(o=s.getAttribute("listIndent")),s.getAttribute("listIndent")==o&&e[t?"unshift":"push"](s),s=s[t?"previousSibling":"nextSibling"]}}function UI(e,t){return t.checkChild(e.parent,"listItem")&&!t.isObject(e)}class WI extends Da{refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model,t=e.document;let i=Array.from(t.selection.getSelectedBlocks());e.change((e=>{const t=i[i.length-1];let n=t.nextSibling;for(;n&&"listItem"==n.name&&n.getAttribute("listIndent")>t.getAttribute("listIndent");)i.push(n),n=n.nextSibling;this._indentBy<0&&(i=i.reverse());for(const t of i){const i=t.getAttribute("listIndent")+this._indentBy;i<0?e.rename(t,"paragraph"):e.setAttribute("listIndent",i,t)}this.fire("_executeCleanup",i)}))}_checkEnabled(){const e=_a(this.editor.model.document.selection.getSelectedBlocks());if(!e||!e.is("element","listItem"))return!1;if(this._indentBy>0){const t=e.getAttribute("listIndent"),i=e.getAttribute("listType");let n=e.previousSibling;for(;n&&n.is("element","listItem")&&n.getAttribute("listIndent")>=t;){if(n.getAttribute("listIndent")==t)return n.getAttribute("listType")==i;n=n.previousSibling}return!1}return!0}constructor(e,t){super(e),this._indentBy="forward"==t?1:-1}}function jI(e,t){const i=t.mapper,n=t.writer,s="numbered"==e.getAttribute("listType")?"ol":"ul",o=function(e){const t=e.createContainerElement("li");return t.getFillerOffset=iP,t}(n),r=n.createContainerElement(s,null);return n.insert(n.createPositionAt(r,0),o),i.bindElements(e,o),o}function qI(e,t,i,n){const s=t.parent,o=i.mapper,r=i.writer;let a=o.toViewPosition(n.createPositionBefore(e));const l=ZI(e.previousSibling,{sameIndent:!0,smallerIndent:!0,listIndent:e.getAttribute("listIndent")}),c=e.previousSibling;if(l&&l.getAttribute("listIndent")==e.getAttribute("listIndent")){const e=o.toViewElement(l);a=r.breakContainer(r.createPositionAfter(e))}else if(c&&"listItem"==c.name){a=o.toViewPosition(n.createPositionAt(c,"end"));const e=o.findMappedViewAncestor(a),t=JI(e);a=t?r.createPositionBefore(t):r.createPositionAt(e,"end")}else a=o.toViewPosition(n.createPositionBefore(e));if(a=KI(a),r.insert(a,s),c&&"listItem"==c.name){const e=o.toViewElement(c),i=r.createRange(r.createPositionAt(e,0),a).getWalker({ignoreElementEnd:!0});for(const e of i)if(e.item.is("element","li")){const n=r.breakContainer(r.createPositionBefore(e.item)),s=e.item.parent,o=r.createPositionAt(t,"end");GI(r,o.nodeBefore,o.nodeAfter),r.move(r.createRangeOn(s),o),i._position=n}}else{const i=s.nextSibling;if(i&&(i.is("element","ul")||i.is("element","ol"))){let n=null;for(const t of i.getChildren()){const i=o.toModelElement(t);if(!(i&&i.getAttribute("listIndent")>e.getAttribute("listIndent")))break;n=t}n&&(r.breakContainer(r.createPositionAfter(n)),r.move(r.createRangeOn(n.parent),r.createPositionAt(t,"end")))}}GI(r,s,s.nextSibling),GI(r,s.previousSibling,s)}function GI(e,t,i){return!t||!i||"ul"!=t.name&&"ol"!=t.name||t.name!=i.name||t.getAttribute("class")!==i.getAttribute("class")?null:e.mergeContainers(e.createPositionAfter(t))}function KI(e){return e.getLastMatchingPosition((e=>e.item.is("uiElement")))}function ZI(e,t){const i=!!t.sameIndent,n=!!t.smallerIndent,s=t.listIndent;let o=e;for(;o&&"listItem"==o.name;){const e=o.getAttribute("listIndent");if(i&&s==e||n&&s>e)return o;o="forward"===t.direction?o.nextSibling:o.previousSibling}return null}function JI(e){for(const t of e.getChildren())if("ul"==t.name||"ol"==t.name)return t;return null}function QI(e,t){const i=[],n=e.parent,s={ignoreElementEnd:!1,startPosition:e,shallow:!0,direction:t},o=n.getAttribute("listIndent"),r=[...new Kc(s)].filter((e=>e.item.is("element"))).map((e=>e.item));for(const e of r){if(!e.is("element","listItem"))break;if(e.getAttribute("listIndent")<o)break;if(!(e.getAttribute("listIndent")>o)){if(e.getAttribute("listType")!==n.getAttribute("listType"))break;if(e.getAttribute("listStyle")!==n.getAttribute("listStyle"))break;if(e.getAttribute("listReversed")!==n.getAttribute("listReversed"))break;if(e.getAttribute("listStart")!==n.getAttribute("listStart"))break;"backward"===t?i.unshift(e):i.push(e)}}return i}function YI(e){let t=[...e.document.selection.getSelectedBlocks()].filter((e=>e.is("element","listItem"))).map((t=>{const i=e.change((e=>e.createPositionAt(t,0)));return[...QI(i,"backward"),...QI(i,"forward")]})).flat();return t=[...new Set(t)],t}const XI=["disc","circle","square"],eP=["decimal","decimal-leading-zero","lower-roman","upper-roman","lower-latin","upper-latin"];function tP(e){return XI.includes(e)?"bulleted":eP.includes(e)?"numbered":null}function iP(){const e=!this.isEmpty&&("ul"==this.getChild(0).name||"ol"==this.getChild(0).name);return this.isEmpty||e?0:fl.call(this)}class nP extends Na{static get pluginName(){return"LegacyListUtils"}getListTypeFromListStyleType(e){return tP(e)}getSelectedListItems(e){return YI(e)}getSiblingNodes(e,t){return QI(e,t)}}function sP(e){return(t,i,n)=>{const s=n.consumable;if(!s.test(i.item,"insert")||!s.test(i.item,"attribute:listType")||!s.test(i.item,"attribute:listIndent"))return;s.consume(i.item,"insert"),s.consume(i.item,"attribute:listType"),s.consume(i.item,"attribute:listIndent");const o=i.item;qI(o,jI(o,n),n,e)}}const oP=(e,t,i)=>{if(!i.consumable.test(t.item,e.name))return;const n=i.mapper.toViewElement(t.item),s=i.writer;s.breakContainer(s.createPositionBefore(n)),s.breakContainer(s.createPositionAfter(n));const o=n.parent,r="numbered"==t.attributeNewValue?"ol":"ul";s.rename(r,o)},rP=(e,t,i)=>{i.consumable.consume(t.item,e.name);const n=i.mapper.toViewElement(t.item).parent,s=i.writer;GI(s,n,n.nextSibling),GI(s,n.previousSibling,n)};const aP=(e,t,i)=>{if(i.consumable.test(t.item,e.name)&&"listItem"!=t.item.name){let e=i.mapper.toViewPosition(t.range.start);const n=i.writer,s=[];for(;("ul"==e.parent.name||"ol"==e.parent.name)&&(e=n.breakContainer(e),"li"==e.parent.name);){const t=e,i=n.createPositionAt(e.parent,"end");if(!t.isEqual(i)){const e=n.remove(n.createRange(t,i));s.push(e)}e=n.createPositionAfter(e.parent)}if(s.length>0){for(let t=0;t<s.length;t++){const i=e.nodeBefore;if(e=n.insert(e,s[t]).end,t>0){const t=GI(n,i,i.nextSibling);t&&t.parent==i&&e.offset--}}GI(n,e.nodeBefore,e.nodeAfter)}}},lP=(e,t,i)=>{const n=i.mapper.toViewPosition(t.position),s=n.nodeBefore,o=n.nodeAfter;GI(i.writer,s,o)},cP=(e,t,i)=>{if(i.consumable.consume(t.viewItem,{name:!0})){const e=i.writer,n=e.createElement("listItem"),s=function(e){let t=0,i=e.parent;for(;i;){if(i.is("element","li"))t++;else{const e=i.previousSibling;e&&e.is("element","li")&&t++}i=i.parent}return t}(t.viewItem);e.setAttribute("listIndent",s,n);const o=t.viewItem.parent&&"ol"==t.viewItem.parent.name?"numbered":"bulleted";if(e.setAttribute("listType",o,n),!i.safeInsert(n,t.modelCursor))return;const r=function(e,t,i){const{writer:n,schema:s}=i;let o=n.createPositionAfter(e);for(const r of t)if("ul"==r.name||"ol"==r.name)o=i.convertItem(r,o).modelCursor;else{const t=i.convertItem(r,n.createPositionAt(e,"end")),a=t.modelRange.start.nodeAfter;a&&a.is("element")&&!s.checkChild(e,a.name)&&(e=t.modelCursor.parent.is("element","listItem")?t.modelCursor.parent:gP(t.modelCursor),o=n.createPositionAfter(e))}return o}(n,t.viewItem.getChildren(),i);t.modelRange=e.createRange(t.modelCursor,r),i.updateConversionResult(n,t)}},dP=(e,t,i)=>{if(i.consumable.test(t.viewItem,{name:!0})){const e=Array.from(t.viewItem.getChildren());for(const t of e){!(t.is("element","li")||pP(t))&&t._remove()}}},hP=(e,t,i)=>{if(i.consumable.test(t.viewItem,{name:!0})){if(0===t.viewItem.childCount)return;const e=[...t.viewItem.getChildren()];let i=!1;for(const t of e)i&&!pP(t)&&t._remove(),pP(t)&&(i=!0)}};function uP(e){return(t,i)=>{if(i.isPhantom)return;const n=i.modelPosition.nodeBefore;if(n&&n.is("element","listItem")){const t=i.mapper.toViewElement(n),s=t.getAncestors().find(pP),o=e.createPositionAt(t,0).getWalker();for(const e of o){if("elementStart"==e.type&&e.item.is("element","li")){i.viewPosition=e.previousPosition;break}if("elementEnd"==e.type&&e.item==s){i.viewPosition=e.nextPosition;break}}}}}const mP=function(e,[t,i]){const n=this;let s,o=t.is("documentFragment")?t.getChild(0):t;if(s=i?n.createSelection(i):n.document.selection,o&&o.is("element","listItem")){const e=s.getFirstPosition();let t=null;if(e.parent.is("element","listItem")?t=e.parent:e.nodeBefore&&e.nodeBefore.is("element","listItem")&&(t=e.nodeBefore),t){const e=t.getAttribute("listIndent");if(e>0)for(;o&&o.is("element","listItem");)o._setAttribute("listIndent",o.getAttribute("listIndent")+e),o=o.nextSibling}}};function gP(e){const t=new Kc({startPosition:e});let i;do{i=t.next()}while(!i.value.item.is("element","listItem"));return i.value.item}function fP(e,t,i,n,s,o){const r=ZI(t.nodeBefore,{sameIndent:!0,smallerIndent:!0,listIndent:e}),a=s.mapper,l=s.writer,c=r?r.getAttribute("listIndent"):null;let d;if(r)if(c==e){const e=a.toViewElement(r).parent;d=l.createPositionAfter(e)}else{const e=o.createPositionAt(r,"end");d=a.toViewPosition(e)}else d=i;d=KI(d);for(const e of[...n.getChildren()])pP(e)&&(d=l.move(l.createRangeOn(e),d).end,GI(l,e,e.nextSibling),GI(l,e.previousSibling,e))}function pP(e){return e.is("element","ol")||e.is("element","ul")}class bP extends Na{static get pluginName(){return"LegacyListEditing"}static get requires(){return[Kv,Rw,nP]}init(){const e=this.editor;e.model.schema.register("listItem",{inheritAllFrom:"$block",allowAttributes:["listType","listIndent"]});const t=e.data,i=e.editing;var n;e.model.document.registerPostFixer((t=>function(e,t){const i=e.document.differ.getChanges(),n=new Map;let s=!1;for(const n of i)if("insert"==n.type&&"listItem"==n.name)o(n.position);else if("insert"==n.type&&"listItem"!=n.name){if("$text"!=n.name){const i=n.position.nodeAfter;i.hasAttribute("listIndent")&&(t.removeAttribute("listIndent",i),s=!0),i.hasAttribute("listType")&&(t.removeAttribute("listType",i),s=!0),i.hasAttribute("listStyle")&&(t.removeAttribute("listStyle",i),s=!0),i.hasAttribute("listReversed")&&(t.removeAttribute("listReversed",i),s=!0),i.hasAttribute("listStart")&&(t.removeAttribute("listStart",i),s=!0);for(const t of Array.from(e.createRangeIn(i)).filter((e=>e.item.is("element","listItem"))))o(t.previousPosition)}o(n.position.getShiftedBy(n.length))}else"remove"==n.type&&"listItem"==n.name?o(n.position):("attribute"==n.type&&"listIndent"==n.attributeKey||"attribute"==n.type&&"listType"==n.attributeKey)&&o(n.range.start);for(const e of n.values())r(e),a(e);return s;function o(e){const t=e.nodeBefore;if(t&&t.is("element","listItem")){let e=t;if(n.has(e))return;for(let t=e.previousSibling;t&&t.is("element","listItem");t=e.previousSibling)if(e=t,n.has(e))return;n.set(t,e)}else{const t=e.nodeAfter;t&&t.is("element","listItem")&&n.set(t,t)}}function r(e){let i=0,n=null;for(;e&&e.is("element","listItem");){const o=e.getAttribute("listIndent");if(o>i){let r;null===n?(n=o-i,r=i):(n>o&&(n=o),r=o-n),t.setAttribute("listIndent",r,e),s=!0}else n=null,i=e.getAttribute("listIndent")+1;e=e.nextSibling}}function a(e){let i=[],n=null;for(;e&&e.is("element","listItem");){const o=e.getAttribute("listIndent");if(n&&n.getAttribute("listIndent")>o&&(i=i.slice(0,o+1)),0!=o)if(i[o]){const n=i[o];e.getAttribute("listType")!=n&&(t.setAttribute("listType",n,e),s=!0)}else i[o]=e.getAttribute("listType");n=e,e=e.nextSibling}}}(e.model,t))),i.mapper.registerViewToModelLength("li",wP),t.mapper.registerViewToModelLength("li",wP),i.mapper.on("modelToViewPosition",uP(i.view)),i.mapper.on("viewToModelPosition",(n=e.model,(e,t)=>{const i=t.viewPosition,s=i.parent,o=t.mapper;if("ul"==s.name||"ol"==s.name){if(i.isAtEnd){const e=o.toModelElement(i.nodeBefore),s=o.getModelLength(i.nodeBefore);t.modelPosition=n.createPositionBefore(e).getShiftedBy(s)}else{const e=o.toModelElement(i.nodeAfter);t.modelPosition=n.createPositionBefore(e)}e.stop()}else if("li"==s.name&&i.nodeBefore&&("ul"==i.nodeBefore.name||"ol"==i.nodeBefore.name)){const r=o.toModelElement(s);let a=1,l=i.nodeBefore;for(;l&&pP(l);)a+=o.getModelLength(l),l=l.previousSibling;t.modelPosition=n.createPositionBefore(r).getShiftedBy(a),e.stop()}})),t.mapper.on("modelToViewPosition",uP(i.view)),e.conversion.for("editingDowncast").add((t=>{t.on("insert",aP,{priority:"high"}),t.on("insert:listItem",sP(e.model)),t.on("attribute:listType:listItem",oP,{priority:"high"}),t.on("attribute:listType:listItem",rP,{priority:"low"}),t.on("attribute:listIndent:listItem",function(e){return(t,i,n)=>{if(!n.consumable.consume(i.item,"attribute:listIndent"))return;const s=n.mapper.toViewElement(i.item),o=n.writer;o.breakContainer(o.createPositionBefore(s)),o.breakContainer(o.createPositionAfter(s));const r=s.parent,a=r.previousSibling,l=o.createRangeOn(r);o.remove(l),a&&a.nextSibling&&GI(o,a,a.nextSibling),fP(i.attributeOldValue+1,i.range.start,l.start,s,n,e),qI(i.item,s,n,e);for(const e of i.item.getChildren())n.consumable.consume(e,"insert")}}(e.model)),t.on("remove:listItem",function(e){return(t,i,n)=>{const s=n.mapper.toViewPosition(i.position).getLastMatchingPosition((e=>!e.item.is("element","li"))).nodeAfter,o=n.writer;o.breakContainer(o.createPositionBefore(s)),o.breakContainer(o.createPositionAfter(s));const r=s.parent,a=r.previousSibling,l=o.createRangeOn(r),c=o.remove(l);a&&a.nextSibling&&GI(o,a,a.nextSibling),fP(n.mapper.toModelElement(s).getAttribute("listIndent")+1,i.position,l.start,s,n,e);for(const e of o.createRangeIn(c).getItems())n.mapper.unbindViewElement(e);t.stop()}}(e.model)),t.on("remove",lP,{priority:"low"})})),e.conversion.for("dataDowncast").add((t=>{t.on("insert",aP,{priority:"high"}),t.on("insert:listItem",sP(e.model))})),e.conversion.for("upcast").add((e=>{e.on("element:ul",dP,{priority:"high"}),e.on("element:ol",dP,{priority:"high"}),e.on("element:li",hP,{priority:"high"}),e.on("element:li",cP)})),e.model.on("insertContent",mP,{priority:"high"}),e.commands.add("numberedList",new HI(e,"numbered")),e.commands.add("bulletedList",new HI(e,"bulleted")),e.commands.add("indentList",new WI(e,"forward")),e.commands.add("outdentList",new WI(e,"backward"));const s=i.view.document;this.listenTo(s,"enter",((e,t)=>{const i=this.editor.model.document,n=i.selection.getLastPosition().parent;i.selection.isCollapsed&&"listItem"==n.name&&n.isEmpty&&(this.editor.execute("outdentList"),t.preventDefault(),e.stop())}),{context:"li"}),this.listenTo(s,"delete",((e,t)=>{if("backward"!==t.direction)return;const i=this.editor.model.document.selection;if(!i.isCollapsed)return;const n=i.getFirstPosition();if(!n.isAtStart)return;const s=n.parent;if("listItem"!==s.name)return;s.previousSibling&&"listItem"===s.previousSibling.name||(this.editor.execute("outdentList"),t.preventDefault(),e.stop())}),{context:"li"}),this.listenTo(e.editing.view.document,"tab",((t,i)=>{const n=i.shiftKey?"outdentList":"indentList";this.editor.commands.get(n).isEnabled&&(e.execute(n),i.stopPropagation(),i.preventDefault(),t.stop())}),{context:"li"})}afterInit(){const e=this.editor.commands,t=e.get("indent"),i=e.get("outdent");t&&t.registerChildCommand(e.get("indentList")),i&&i.registerChildCommand(e.get("outdentList"))}}function wP(e){let t=1;for(const i of e.getChildren())if("ul"==i.name||"ol"==i.name)for(const e of i.getChildren())t+=wP(e);return t}class vP extends Na{static get requires(){return[bP,aI]}static get pluginName(){return"LegacyList"}}class _P extends Da{refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){this._tryToConvertItemsToList(e);const t=this.editor.model,i=YI(t);i.length&&t.change((t=>{for(const n of i)t.setAttribute("listStyle",e.type||this.defaultType,n)}))}_getValue(){const e=this.editor.model.document.selection.getFirstPosition().parent;return e&&e.is("element","listItem")?e.getAttribute("listStyle"):null}_checkEnabled(){const e=this.editor,t=e.commands.get("numberedList"),i=e.commands.get("bulletedList");return t.isEnabled||i.isEnabled}_tryToConvertItemsToList(e){if(!e.type)return;const t=tP(e.type);if(!t)return;const i=this.editor,n=`${t}List`;i.commands.get(n).value||i.execute(n)}constructor(e,t){super(e),this.defaultType=t}}class yP extends Da{refresh(){const e=this._getValue();this.value=e,this.isEnabled=null!=e}execute(e={}){const t=this.editor.model,i=YI(t).filter((e=>"numbered"==e.getAttribute("listType")));t.change((t=>{for(const n of i)t.setAttribute("listReversed",!!e.reversed,n)}))}_getValue(){const e=this.editor.model.document.selection.getFirstPosition().parent;return e&&e.is("element","listItem")&&"numbered"==e.getAttribute("listType")?e.getAttribute("listReversed"):null}}class kP extends Da{refresh(){const e=this._getValue();this.value=e,this.isEnabled=null!=e}execute({startIndex:e=1}={}){const t=this.editor.model,i=YI(t).filter((e=>"numbered"==e.getAttribute("listType")));t.change((t=>{for(const n of i)t.setAttribute("listStart",e>=0?e:1,n)}))}_getValue(){const e=this.editor.model.document.selection.getFirstPosition().parent;return e&&e.is("element","listItem")&&"numbered"==e.getAttribute("listType")?e.getAttribute("listStart"):null}}const CP="default";class xP extends Na{static get requires(){return[bP]}static get pluginName(){return"LegacyListPropertiesEditing"}init(){const e=this.editor,t=e.model,i=function(e){const t=[];e.styles&&t.push({attributeName:"listStyle",defaultValue:CP,addCommand(e){e.commands.add("listStyle",new _P(e,CP))},appliesToListItem:()=>!0,setAttributeOnDowncast(e,t,i){t&&t!==CP?e.setStyle("list-style-type",t,i):e.removeStyle("list-style-type",i)},getAttributeOnUpcast:e=>e.getStyle("list-style-type")||CP});e.reversed&&t.push({attributeName:"listReversed",defaultValue:!1,addCommand(e){e.commands.add("listReversed",new yP(e))},appliesToListItem:e=>"numbered"==e.getAttribute("listType"),setAttributeOnDowncast(e,t,i){t?e.setAttribute("reversed","reversed",i):e.removeAttribute("reversed",i)},getAttributeOnUpcast:e=>e.hasAttribute("reversed")});e.startIndex&&t.push({attributeName:"listStart",defaultValue:1,addCommand(e){e.commands.add("listStart",new kP(e))},appliesToListItem:e=>"numbered"==e.getAttribute("listType"),setAttributeOnDowncast(e,t,i){0==t||t>1?e.setAttribute("start",t,i):e.removeAttribute("start",i)},getAttributeOnUpcast(e){const t=e.getAttribute("start");return t>=0?t:1}});return t}(e.config.get("list.properties"));t.schema.extend("listItem",{allowAttributes:i.map((e=>e.attributeName))});for(const t of i)t.addCommand(e);var n;this.listenTo(e.commands.get("indentList"),"_executeCleanup",function(e,t){return(i,n)=>{const s=n[0],o=s.getAttribute("listIndent"),r=n.filter((e=>e.getAttribute("listIndent")===o));let a=null;s.previousSibling.getAttribute("listIndent")+1!==o&&(a=ZI(s.previousSibling,{sameIndent:!0,direction:"backward",listIndent:o})),e.model.change((e=>{for(const i of r)for(const n of t)if(n.appliesToListItem(i)){const t=null==a?n.defaultValue:a.getAttribute(n.attributeName);e.setAttribute(n.attributeName,t,i)}}))}}(e,i)),this.listenTo(e.commands.get("outdentList"),"_executeCleanup",function(e,t){return(i,n)=>{if(!(n=n.reverse().filter((e=>e.is("element","listItem")))).length)return;const s=n[0].getAttribute("listIndent"),o=n[0].getAttribute("listType");let r=n[0].previousSibling;if(r.is("element","listItem"))for(;r.getAttribute("listIndent")!==s;)r=r.previousSibling;else r=null;r||(r=n[n.length-1].nextSibling),r&&r.is("element","listItem")&&r.getAttribute("listType")===o&&e.model.change((e=>{const i=n.filter((e=>e.getAttribute("listIndent")===s));for(const n of i)for(const i of t)if(i.appliesToListItem(n)){const t=i.attributeName,s=r.getAttribute(t);e.setAttribute(t,s,n)}}))}}(e,i)),this.listenTo(e.commands.get("bulletedList"),"_executeCleanup",TP(e)),this.listenTo(e.commands.get("numberedList"),"_executeCleanup",TP(e)),t.document.registerPostFixer(function(e,t){return i=>{let n=!1;const s=SP(e.model.document.differ.getChanges()).filter((e=>"todo"!==e.getAttribute("listType")));if(!s.length)return n;let o=s[s.length-1].nextSibling;if((!o||!o.is("element","listItem"))&&(o=s[0].previousSibling,o)){const e=s[0].getAttribute("listIndent");for(;o.is("element","listItem")&&o.getAttribute("listIndent")!==e&&(o=o.previousSibling,o););}for(const e of t){const t=e.attributeName;for(const r of s)if(e.appliesToListItem(r))if(r.hasAttribute(t)){const s=r.previousSibling;EP(s,r,e.attributeName)&&(i.setAttribute(t,s.getAttribute(t),r),n=!0)}else AP(o,r,e)?i.setAttribute(t,o.getAttribute(t),r):i.setAttribute(t,e.defaultValue,r),n=!0;else i.removeAttribute(t,r)}return n}}(e,i)),e.conversion.for("upcast").add((n=i,e=>{e.on("element:li",((e,t,i)=>{if(!t.modelRange)return;const s=t.viewItem.parent,o=t.modelRange.start.nodeAfter||t.modelRange.end.nodeBefore;for(const e of n)if(e.appliesToListItem(o)){const t=e.getAttributeOnUpcast(s);i.writer.setAttribute(e.attributeName,t,o)}}),{priority:"low"})})),e.conversion.for("downcast").add(function(e){return i=>{for(const n of e)i.on(`attribute:${n.attributeName}:listItem`,((e,i,s)=>{const o=s.writer,r=i.item,a=ZI(r.previousSibling,{sameIndent:!0,listIndent:r.getAttribute("listIndent"),direction:"backward"}),l=s.mapper.toViewElement(r);t(r,a)||o.breakContainer(o.createPositionBefore(l)),n.setAttributeOnDowncast(o,i.attributeNewValue,l.parent)}),{priority:"low"})};function t(e,t){return t&&e.getAttribute("listType")===t.getAttribute("listType")&&e.getAttribute("listIndent")===t.getAttribute("listIndent")&&e.getAttribute("listStyle")===t.getAttribute("listStyle")&&e.getAttribute("listReversed")===t.getAttribute("listReversed")&&e.getAttribute("listStart")===t.getAttribute("listStart")}}(i)),this._mergeListAttributesWhileMergingLists(i)}afterInit(){const e=this.editor;e.commands.get("todoList")&&e.model.document.registerPostFixer(function(e){return t=>{const i=SP(e.model.document.differ.getChanges()).filter((e=>"todo"===e.getAttribute("listType")&&(e.hasAttribute("listStyle")||e.hasAttribute("listReversed")||e.hasAttribute("listStart"))));if(!i.length)return!1;for(const e of i)t.removeAttribute("listStyle",e),t.removeAttribute("listReversed",e),t.removeAttribute("listStart",e);return!0}}(e))}_mergeListAttributesWhileMergingLists(e){const t=this.editor.model;let i;this.listenTo(t,"deleteContent",((e,[t])=>{const n=t.getFirstPosition(),s=t.getLastPosition();if(n.parent===s.parent)return;if(!n.parent.is("element","listItem"))return;const o=s.parent.nextSibling;if(!o||!o.is("element","listItem"))return;const r=ZI(n.parent,{sameIndent:!0,listIndent:o.getAttribute("listIndent")});r&&r.getAttribute("listType")===o.getAttribute("listType")&&(i=r)}),{priority:"high"}),this.listenTo(t,"deleteContent",(()=>{i&&(t.change((t=>{const n=ZI(i.nextSibling,{sameIndent:!0,listIndent:i.getAttribute("listIndent"),direction:"forward"});if(!n)return void(i=null);const s=[n,...QI(t.createPositionAt(n,0),"forward")];for(const n of s)for(const s of e)if(s.appliesToListItem(n)){const e=s.attributeName,o=i.getAttribute(e);t.setAttribute(e,o,n)}})),i=null)}),{priority:"low"})}constructor(e){super(e),e.config.define("list",{properties:{styles:!0,startIndex:!1,reversed:!1}})}}function AP(e,t,i){if(!e)return!1;const n=e.getAttribute(i.attributeName);return!!n&&(n!=i.defaultValue&&e.getAttribute("listType")===t.getAttribute("listType"))}function EP(e,t,i){if(!e||!e.is("element","listItem"))return!1;if(t.getAttribute("listType")!==e.getAttribute("listType"))return!1;const n=e.getAttribute("listIndent");if(n<1||n!==t.getAttribute("listIndent"))return!1;const s=e.getAttribute(i);return!(!s||s===t.getAttribute(i))}function TP(e){return(t,i)=>{i=i.filter((e=>e.is("element","listItem"))),e.model.change((e=>{for(const t of i)e.removeAttribute("listStyle",t)}))}}function SP(e){const t=[];for(const i of e){const e=IP(i);e&&e.is("element","listItem")&&t.push(e)}return t}function IP(e){return"attribute"===e.type?e.range.start.nodeAfter:"insert"===e.type?e.position.nodeAfter:null}class PP extends Na{static get requires(){return[xP,AI]}static get pluginName(){return"LegacyListProperties"}}const VP="todoListChecked";class RP extends Da{refresh(){this._selectedElements=this._getSelectedItems(),this.value=this._selectedElements.every((e=>!!e.getAttribute(VP))),this.isEnabled=!!this._selectedElements.length}_getSelectedItems(){const e=this.editor.model,t=e.schema,i=e.document.selection.getFirstRange(),n=i.start.parent,s=[];t.checkAttribute(n,VP)&&s.push(n);for(const e of i.getItems())t.checkAttribute(e,VP)&&!s.includes(e)&&s.push(e);return s}execute(e={}){this.editor.model.change((t=>{for(const i of this._selectedElements){(void 0===e.forceValue?!this.value:e.forceValue)?t.setAttribute(VP,!0,i):t.removeAttribute(VP,i)}}))}constructor(e){super(e),this._selectedElements=[],this.on("execute",(()=>{this.refresh()}),{priority:"highest"})}}const BP=(e,t,i)=>{const n=t.modelCursor,s=n.parent,o=t.viewItem;if("checkbox"!=o.getAttribute("type")||"listItem"!=s.name||!n.isAtStart)return;if(!i.consumable.consume(o,{name:!0}))return;const r=i.writer;r.setAttribute("listType","todo",s),t.viewItem.hasAttribute("checked")&&r.setAttribute("todoListChecked",!0,s),t.modelRange=r.createRange(n)};function OP(e){return(t,i)=>{const n=i.modelPosition,s=n.parent;if(!s.is("element","listItem")||"todo"!=s.getAttribute("listType"))return;const o=LP(i.mapper.toViewElement(s),e);o&&(i.viewPosition=i.mapper.findPositionIn(o,n.offset))}}function MP(e,t,i,n){return t.createUIElement("label",{class:"todo-list__label",contenteditable:!1},(function(t){const s=cr(document,"input",{type:"checkbox",tabindex:"-1"});i&&s.setAttribute("checked","checked"),s.addEventListener("change",(()=>n(e)));const o=this.toDomElement(t);return o.appendChild(s),o}))}function LP(e,t){const i=t.createRangeIn(e);for(const e of i)if(e.item.is("containerElement","span")&&e.item.hasClass("todo-list__label__description"))return e.item}const NP=ca("Ctrl+Enter");class FP extends Na{static get pluginName(){return"LegacyTodoListEditing"}static get requires(){return[bP]}init(){const e=this.editor,{editing:t,data:i,model:n}=e;n.schema.extend("listItem",{allowAttributes:["todoListChecked"]}),n.schema.addAttributeCheck(((e,t)=>{const i=e.last;if("todoListChecked"==t&&"listItem"==i.name&&"todo"!=i.getAttribute("listType"))return!1})),e.commands.add("todoList",new HI(e,"todo"));const s=new RP(e);var o,r;e.commands.add("checkTodoList",s),e.commands.add("todoListCheck",s),i.downcastDispatcher.on("insert:listItem",function(e){return(t,i,n)=>{const s=n.consumable;if(!s.test(i.item,"insert")||!s.test(i.item,"attribute:listType")||!s.test(i.item,"attribute:listIndent"))return;if("todo"!=i.item.getAttribute("listType"))return;const o=i.item;s.consume(o,"insert"),s.consume(o,"attribute:listType"),s.consume(o,"attribute:listIndent"),s.consume(o,"attribute:todoListChecked");const r=n.writer,a=jI(o,n);r.addClass("todo-list",a.parent);const l=r.createContainerElement("label",{class:"todo-list__label"}),c=r.createEmptyElement("input",{type:"checkbox",disabled:"disabled"}),d=r.createContainerElement("span",{class:"todo-list__label__description"});o.getAttribute("todoListChecked")&&r.setAttribute("checked","checked",c),r.insert(r.createPositionAt(a,0),l),r.insert(r.createPositionAt(l,0),c),r.insert(r.createPositionAfter(c),d),qI(o,a,n,e)}}(n),{priority:"high"}),i.upcastDispatcher.on("element:input",BP,{priority:"high"}),t.downcastDispatcher.on("insert:listItem",function(e,t){return(i,n,s)=>{const o=s.consumable;if(!o.test(n.item,"insert")||!o.test(n.item,"attribute:listType")||!o.test(n.item,"attribute:listIndent"))return;if("todo"!=n.item.getAttribute("listType"))return;const r=n.item;o.consume(r,"insert"),o.consume(r,"attribute:listType"),o.consume(r,"attribute:listIndent"),o.consume(r,"attribute:todoListChecked");const a=s.writer,l=jI(r,s),c=!!r.getAttribute("todoListChecked"),d=MP(r,a,c,t),h=a.createContainerElement("span",{class:"todo-list__label__description"});a.addClass("todo-list",l.parent),a.insert(a.createPositionAt(l,0),d),a.insert(a.createPositionAfter(d),h),qI(r,l,s,e)}}(n,(e=>this._handleCheckmarkChange(e))),{priority:"high"}),t.downcastDispatcher.on("attribute:listType:listItem",(o=e=>this._handleCheckmarkChange(e),r=t.view,(e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const n=i.mapper.toViewElement(t.item),s=i.writer,a=function(e,t){const i=t.createRangeIn(e);for(const e of i)if(e.item.is("uiElement","label"))return e.item}(n,r);if("todo"==t.attributeNewValue){const e=!!t.item.getAttribute("todoListChecked"),i=MP(t.item,s,e,o),r=s.createContainerElement("span",{class:"todo-list__label__description"}),a=s.createRangeIn(n),l=JI(n),c=KI(a.start),d=l?s.createPositionBefore(l):a.end,h=s.createRange(c,d);s.addClass("todo-list",n.parent),s.move(h,s.createPositionAt(r,0)),s.insert(s.createPositionAt(n,0),i),s.insert(s.createPositionAfter(i),r)}else if("todo"==t.attributeOldValue){const e=LP(n,r);s.removeClass("todo-list",n.parent),s.remove(a),s.move(s.createRangeIn(e),s.createPositionBefore(e)),s.remove(e)}})),t.downcastDispatcher.on("attribute:todoListChecked:listItem",function(e){return(t,i,n)=>{if("todo"!=i.item.getAttribute("listType"))return;if(!n.consumable.consume(i.item,"attribute:todoListChecked"))return;const{mapper:s,writer:o}=n,r=!!i.item.getAttribute("todoListChecked"),a=s.toViewElement(i.item).getChild(0),l=MP(i.item,o,r,e);o.insert(o.createPositionAfter(a),l),o.remove(a)}}((e=>this._handleCheckmarkChange(e)))),t.mapper.on("modelToViewPosition",OP(t.view)),i.mapper.on("modelToViewPosition",OP(t.view)),this.listenTo(t.view.document,"arrowKey",function(e,t){return(i,n)=>{if("left"!=ua(n.keyCode,t.contentLanguageDirection))return;const s=e.schema,o=e.document.selection;if(!o.isCollapsed)return;const r=o.getFirstPosition(),a=r.parent;if("listItem"===a.name&&"todo"==a.getAttribute("listType")&&r.isAtStart){const t=s.getNearestSelectionRange(e.createPositionBefore(a),"backward");t&&e.change((e=>e.setSelection(t))),n.preventDefault(),n.stopPropagation(),i.stop()}}}(n,e.locale),{context:"li"}),this.listenTo(t.view.document,"keydown",((t,i)=>{la(i)===NP&&(e.execute("checkTodoList"),t.stop())}),{priority:"high"});const a=new Set;this.listenTo(n,"applyOperation",((e,t)=>{const i=t[0];if("rename"==i.type&&"listItem"==i.oldName){const e=i.position.nodeAfter;e.hasAttribute("todoListChecked")&&a.add(e)}else if("changeAttribute"==i.type&&"listType"==i.key&&"todo"===i.oldValue)for(const e of i.range.getItems())e.hasAttribute("todoListChecked")&&"todo"!==e.getAttribute("listType")&&a.add(e)})),n.document.registerPostFixer((e=>{let t=!1;for(const i of a)e.removeAttribute("todoListChecked",i),t=!0;return a.clear(),t})),this._initAriaAnnouncements()}_handleCheckmarkChange(e){const t=this.editor,i=t.model,n=Array.from(i.document.selection.getRanges());i.change((i=>{i.setSelection(e,"end"),t.execute("checkTodoList"),i.setSelection(n)}))}_initAriaAnnouncements(){const{model:e,ui:t,t:i}=this.editor;let n=null;t&&e.document.selection.on("change:range",(()=>{const s=e.document.selection.focus.parent,o=DP(n),r=DP(s);o&&!r?t.ariaLiveAnnouncer.announce(i("Leaving a to-do list")):!o&&r&&t.ariaLiveAnnouncer.announce(i("Entering a to-do list")),n=s}))}}function DP(e){return!!e&&e.is("element","listItem")&&"todo"===e.getAttribute("listType")}class zP extends Na{static get requires(){return[FP,DI]}static get pluginName(){return"LegacyTodoList"}}class HP extends Na{static get pluginName(){return"AdjacentListsSupport"}init(){const e=this.editor;e.model.schema.register("listSeparator",{allowWhere:"$block",isBlock:!0}),e.conversion.for("upcast").add((e=>{e.on("element:ol",$P()),e.on("element:ul",$P())})).elementToElement({model:"listSeparator",view:"ck-list-separator"}),e.conversion.for("editingDowncast").elementToElement({model:"listSeparator",view:{name:"div",classes:["ck-list-separator","ck-hidden"]}}),e.conversion.for("dataDowncast").elementToElement({model:"listSeparator",view:(e,t)=>{const i=t.writer.createContainerElement("ck-list-separator");return t.writer.setCustomProperty("dataPipeline:transparentRendering",!0,i),i.getFillerOffset=()=>null,i}})}}function $P(){return(e,t,i)=>{const n=t.viewItem,s=n.nextSibling;if(!s)return;if(n.name!==s.name)return;t.modelRange||Object.assign(t,i.convertChildren(t.viewItem,t.modelCursor));const o=i.writer,r=o.createElement("listSeparator");if(!i.safeInsert(r,t.modelCursor))return;const a=i.getSplitParts(r);t.modelRange=o.createRange(t.modelRange.start,o.createPositionAfter(a[a.length-1])),i.updateConversionResult(r,t)}}class UP extends Na{static get requires(){return[lI]}static get pluginName(){return"DocumentList"}constructor(e){super(e),b("plugin-obsolete-documentlist",{pluginName:"DocumentList"})}}class WP extends Na{static get requires(){return[PI]}static get pluginName(){return"DocumentListProperties"}constructor(e){super(e),b("plugin-obsolete-documentlistproperties",{pluginName:"DocumentListProperties"})}}class jP extends Na{static get requires(){return[zI]}static get pluginName(){return"TodoDocumentList"}constructor(e){super(e),b("plugin-obsolete-tododocumentlist",{pluginName:"TodoDocumentList"})}}function qP(){return{baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartLists:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}let GP={baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartLists:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1};const KP=/[&<>"']/,ZP=/[&<>"']/g,JP=/[<>"']|&(?!#?\w+;)/,QP=/[<>"']|&(?!#?\w+;)/g,YP={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},XP=e=>YP[e];function eV(e,t){if(t){if(KP.test(e))return e.replace(ZP,XP)}else if(JP.test(e))return e.replace(QP,XP);return e}const tV=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi;function iV(e){return e.replace(tV,((e,t)=>"colon"===(t=t.toLowerCase())?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""))}const nV=/(^|[^\[])\^/g;function sV(e,t){e=e.source||e,t=t||"";const i={replace:(t,n)=>(n=(n=n.source||n).replace(nV,"$1"),e=e.replace(t,n),i),getRegex:()=>new RegExp(e,t)};return i}const oV=/[^\w:]/g,rV=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function aV(e,t,i){if(e){let e;try{e=decodeURIComponent(iV(i)).replace(oV,"").toLowerCase()}catch(e){return null}if(0===e.indexOf("javascript:")||0===e.indexOf("vbscript:")||0===e.indexOf("data:"))return null}t&&!rV.test(i)&&(i=function(e,t){lV[" "+e]||(cV.test(e)?lV[" "+e]=e+"/":lV[" "+e]=fV(e,"/",!0));e=lV[" "+e];const i=-1===e.indexOf(":");return"//"===t.substring(0,2)?i?t:e.replace(dV,"$1")+t:"/"===t.charAt(0)?i?t:e.replace(hV,"$1")+t:e+t}(t,i));try{i=encodeURI(i).replace(/%25/g,"%")}catch(e){return null}return i}const lV={},cV=/^[^:]+:\/*[^/]*$/,dV=/^([^:]+:)[\s\S]*$/,hV=/^([^:]+:\/*[^/]*)[\s\S]*$/;const uV={exec:function(){}};function mV(e){let t,i,n=1;for(;n<arguments.length;n++)for(i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}function gV(e,t){const i=e.replace(/\|/g,((e,t,i)=>{let n=!1,s=t;for(;--s>=0&&"\\"===i[s];)n=!n;return n?"|":" |"})).split(/ \|/);let n=0;if(i[0].trim()||i.shift(),i.length>0&&!i[i.length-1].trim()&&i.pop(),i.length>t)i.splice(t);else for(;i.length<t;)i.push("");for(;n<i.length;n++)i[n]=i[n].trim().replace(/\\\|/g,"|");return i}function fV(e,t,i){const n=e.length;if(0===n)return"";let s=0;for(;s<n;){const o=e.charAt(n-s-1);if(o!==t||i){if(o===t||!i)break;s++}else s++}return e.substr(0,n-s)}function pV(e){e&&e.sanitize&&!e.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")}function bV(e,t){if(t<1)return"";let i="";for(;t>1;)1&t&&(i+=e),t>>=1,e+=e;return i+e}function wV(e,t,i,n){const s=t.href,o=t.title?eV(t.title):null,r=e[1].replace(/\\([\[\]])/g,"$1");if("!"!==e[0].charAt(0)){n.state.inLink=!0;const e={type:"link",raw:i,href:s,title:o,text:r,tokens:n.inlineTokens(r,[])};return n.state.inLink=!1,e}return{type:"image",raw:i,href:s,title:o,text:eV(r)}}class vV{space(e){const t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){const t=this.rules.block.code.exec(e);if(t){const e=t[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:fV(e,"\n")}}}fences(e){const t=this.rules.block.fences.exec(e);if(t){const e=t[0],i=function(e,t){const i=e.match(/^(\s+)(?:```)/);if(null===i)return t;const n=i[1];return t.split("\n").map((e=>{const t=e.match(/^\s+/);if(null===t)return e;const[i]=t;return i.length>=n.length?e.slice(n.length):e})).join("\n")}(e,t[3]||"");return{type:"code",raw:e,lang:t[2]?t[2].trim():t[2],text:i}}}heading(e){const t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(/#$/.test(e)){const t=fV(e,"#");this.options.pedantic?e=t.trim():t&&!/ $/.test(t)||(e=t.trim())}const i={type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:[]};return this.lexer.inline(i.text,i.tokens),i}}hr(e){const t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:t[0]}}blockquote(e){const t=this.rules.block.blockquote.exec(e);if(t){const e=t[0].replace(/^ *> ?/gm,"");return{type:"blockquote",raw:t[0],tokens:this.lexer.blockTokens(e,[]),text:e}}}list(e){let t=this.rules.block.list.exec(e);if(t){let i,n,s,o,r,a,l,c,d,h,u,m,g=t[1].trim();const f=g.length>1,p={type:"list",raw:"",ordered:f,start:f?+g.slice(0,-1):"",loose:!1,items:[]};g=f?`\\d{1,9}\\${g.slice(-1)}`:`\\${g}`,this.options.pedantic&&(g=f?g:"[*+-]");const b=new RegExp(`^( {0,3}${g})((?: [^\\n]*)?(?:\\n|$))`);for(;e&&(m=!1,t=b.exec(e))&&!this.rules.block.hr.test(e);){if(i=t[0],e=e.substring(i.length),c=t[2].split("\n",1)[0],d=e.split("\n",1)[0],this.options.pedantic?(o=2,u=c.trimLeft()):(o=t[2].search(/[^ ]/),o=o>4?1:o,u=c.slice(o),o+=t[1].length),a=!1,!c&&/^ *$/.test(d)&&(i+=d+"\n",e=e.substring(d.length+1),m=!0),!m){const t=new RegExp(`^ {0,${Math.min(3,o-1)}}(?:[*+-]|\\d{1,9}[.)])`);for(;e&&(h=e.split("\n",1)[0],c=h,this.options.pedantic&&(c=c.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!t.test(c));){if(c.search(/[^ ]/)>=o||!c.trim())u+="\n"+c.slice(o);else{if(a)break;u+="\n"+c}a||c.trim()||(a=!0),i+=h+"\n",e=e.substring(h.length+1)}}p.loose||(l?p.loose=!0:/\n *\n *$/.test(i)&&(l=!0)),this.options.gfm&&(n=/^\[[ xX]\] /.exec(u),n&&(s="[ ] "!==n[0],u=u.replace(/^\[[ xX]\] +/,""))),p.items.push({type:"list_item",raw:i,task:!!n,checked:s,loose:!1,text:u}),p.raw+=i}p.items[p.items.length-1].raw=i.trimRight(),p.items[p.items.length-1].text=u.trimRight(),p.raw=p.raw.trimRight();const w=p.items.length;for(r=0;r<w;r++){this.lexer.state.top=!1,p.items[r].tokens=this.lexer.blockTokens(p.items[r].text,[]);const e=p.items[r].tokens.filter((e=>"space"===e.type)),t=e.every((e=>{const t=e.raw.split("");let i=0;for(const e of t)if("\n"===e&&(i+=1),i>1)return!0;return!1}));!p.loose&&e.length&&t&&(p.loose=!0,p.items[r].loose=!0)}return p}}html(e){const t=this.rules.block.html.exec(e);if(t){const e={type:"html",raw:t[0],pre:!this.options.sanitizer&&("pre"===t[1]||"script"===t[1]||"style"===t[1]),text:t[0]};return this.options.sanitize&&(e.type="paragraph",e.text=this.options.sanitizer?this.options.sanitizer(t[0]):eV(t[0]),e.tokens=[],this.lexer.inline(e.text,e.tokens)),e}}def(e){const t=this.rules.block.def.exec(e);if(t){t[3]&&(t[3]=t[3].substring(1,t[3].length-1));return{type:"def",tag:t[1].toLowerCase().replace(/\s+/g," "),raw:t[0],href:t[2],title:t[3]}}}table(e){const t=this.rules.block.table.exec(e);if(t){const e={type:"table",header:gV(t[1]).map((e=>({text:e}))),align:t[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:t[3]&&t[3].trim()?t[3].replace(/\n[ \t]*$/,"").split("\n"):[]};if(e.header.length===e.align.length){e.raw=t[0];let i,n,s,o,r=e.align.length;for(i=0;i<r;i++)/^ *-+: *$/.test(e.align[i])?e.align[i]="right":/^ *:-+: *$/.test(e.align[i])?e.align[i]="center":/^ *:-+ *$/.test(e.align[i])?e.align[i]="left":e.align[i]=null;for(r=e.rows.length,i=0;i<r;i++)e.rows[i]=gV(e.rows[i],e.header.length).map((e=>({text:e})));for(r=e.header.length,n=0;n<r;n++)e.header[n].tokens=[],this.lexer.inlineTokens(e.header[n].text,e.header[n].tokens);for(r=e.rows.length,n=0;n<r;n++)for(o=e.rows[n],s=0;s<o.length;s++)o[s].tokens=[],this.lexer.inlineTokens(o[s].text,o[s].tokens);return e}}}lheading(e){const t=this.rules.block.lheading.exec(e);if(t){const e={type:"heading",raw:t[0],depth:"="===t[2].charAt(0)?1:2,text:t[1],tokens:[]};return this.lexer.inline(e.text,e.tokens),e}}paragraph(e){const t=this.rules.block.paragraph.exec(e);if(t){const e={type:"paragraph",raw:t[0],text:"\n"===t[1].charAt(t[1].length-1)?t[1].slice(0,-1):t[1],tokens:[]};return this.lexer.inline(e.text,e.tokens),e}}text(e){const t=this.rules.block.text.exec(e);if(t){const e={type:"text",raw:t[0],text:t[0],tokens:[]};return this.lexer.inline(e.text,e.tokens),e}}escape(e){const t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:eV(t[1])}}tag(e){const t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&/^<a /i.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:this.options.sanitize?"text":"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(t[0]):eV(t[0]):t[0]}}link(e){const t=this.rules.inline.link.exec(e);if(t){const e=t[2].trim();if(!this.options.pedantic&&/^</.test(e)){if(!/>$/.test(e))return;const t=fV(e.slice(0,-1),"\\");if((e.length-t.length)%2==0)return}else{const e=function(e,t){if(-1===e.indexOf(t[1]))return-1;const i=e.length;let n=0,s=0;for(;s<i;s++)if("\\"===e[s])s++;else if(e[s]===t[0])n++;else if(e[s]===t[1]&&(n--,n<0))return s;return-1}(t[2],"()");if(e>-1){const i=(0===t[0].indexOf("!")?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,i).trim(),t[3]=""}}let i=t[2],n="";if(this.options.pedantic){const e=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(i);e&&(i=e[1],n=e[3])}else n=t[3]?t[3].slice(1,-1):"";return i=i.trim(),/^</.test(i)&&(i=this.options.pedantic&&!/>$/.test(e)?i.slice(1):i.slice(1,-1)),wV(t,{href:i?i.replace(this.rules.inline._escapes,"$1"):i,title:n?n.replace(this.rules.inline._escapes,"$1"):n},t[0],this.lexer)}}reflink(e,t){let i;if((i=this.rules.inline.reflink.exec(e))||(i=this.rules.inline.nolink.exec(e))){let e=(i[2]||i[1]).replace(/\s+/g," ");if(e=t[e.toLowerCase()],!e||!e.href){const e=i[0].charAt(0);return{type:"text",raw:e,text:e}}return wV(i,e,i[0],this.lexer)}}emStrong(e,t,i=""){let n=this.rules.inline.emStrong.lDelim.exec(e);if(!n)return;if(n[3]&&i.match(RegExp("[\\p{L}\\p{N}]","u")))return;const s=n[1]||n[2]||"";if(!s||s&&(""===i||this.rules.inline.punctuation.exec(i))){const i=n[0].length-1;let s,o,r=i,a=0;const l="*"===n[0][0]?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(l.lastIndex=0,t=t.slice(-1*e.length+i);null!=(n=l.exec(t));){if(s=n[1]||n[2]||n[3]||n[4]||n[5]||n[6],!s)continue;if(o=s.length,n[3]||n[4]){r+=o;continue}if((n[5]||n[6])&&i%3&&!((i+o)%3)){a+=o;continue}if(r-=o,r>0)continue;if(o=Math.min(o,o+r+a),Math.min(i,o)%2){const t=e.slice(1,i+n.index+o);return{type:"em",raw:e.slice(0,i+n.index+o+1),text:t,tokens:this.lexer.inlineTokens(t,[])}}const t=e.slice(2,i+n.index+o-1);return{type:"strong",raw:e.slice(0,i+n.index+o+1),text:t,tokens:this.lexer.inlineTokens(t,[])}}}}codespan(e){const t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(/\n/g," ");const i=/[^ ]/.test(e),n=/^ /.test(e)&&/ $/.test(e);return i&&n&&(e=e.substring(1,e.length-1)),e=eV(e,!0),{type:"codespan",raw:t[0],text:e}}}br(e){const t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){const t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2],[])}}autolink(e,t){const i=this.rules.inline.autolink.exec(e);if(i){let e,n;return"@"===i[2]?(e=eV(this.options.mangle?t(i[1]):i[1]),n="mailto:"+e):(e=eV(i[1]),n=e),{type:"link",raw:i[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}url(e,t){let i;if(i=this.rules.inline.url.exec(e)){let e,n;if("@"===i[2])e=eV(this.options.mangle?t(i[0]):i[0]),n="mailto:"+e;else{let t;do{t=i[0],i[0]=this.rules.inline._backpedal.exec(i[0])[0]}while(t!==i[0]);e=eV(i[0]),n="www."===i[1]?"http://"+e:e}return{type:"link",raw:i[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(e,t){const i=this.rules.inline.text.exec(e);if(i){let e;return e=this.lexer.state.inRawBlock?this.options.sanitize?this.options.sanitizer?this.options.sanitizer(i[0]):eV(i[0]):i[0]:eV(this.options.smartypants?t(i[0]):i[0]),{type:"text",raw:i[0],text:e}}}constructor(e){this.options=e||GP}}const _V={newline:/^(?: *(?:\n|$))+/,code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hr:/^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3}bull)( [^\n]+?)?(?:\n|$)/,html:"^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",def:/^ {0,3}\[(label)\]: *(?:\n *)?<?([^\s>]+)>?(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,table:uV,lheading:/^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/,_label:/(?!\s*\])(?:\\.|[^\[\]\\])+/,_title:/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/};_V.def=sV(_V.def).replace("label",_V._label).replace("title",_V._title).getRegex(),_V.bullet=/(?:[*+-]|\d{1,9}[.)])/,_V.listItemStart=sV(/^( *)(bull) */).replace("bull",_V.bullet).getRegex(),_V.list=sV(_V.list).replace(/bull/g,_V.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+_V.def.source+")").getRegex(),_V._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",_V._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,_V.html=sV(_V.html,"i").replace("comment",_V._comment).replace("tag",_V._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),_V.paragraph=sV(_V._paragraph).replace("hr",_V.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",_V._tag).getRegex(),_V.blockquote=sV(_V.blockquote).replace("paragraph",_V.paragraph).getRegex(),_V.normal=mV({},_V),_V.gfm=mV({},_V.normal,{table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"}),_V.gfm.table=sV(_V.gfm.table).replace("hr",_V.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",_V._tag).getRegex(),_V.gfm.paragraph=sV(_V._paragraph).replace("hr",_V.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",_V.gfm.table).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",_V._tag).getRegex(),_V.pedantic=mV({},_V.normal,{html:sV("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",_V._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:uV,paragraph:sV(_V.normal._paragraph).replace("hr",_V.hr).replace("heading"," *#{1,6} *[^\n]").replace("lheading",_V.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});const yV={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:uV,tag:"^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(ref)\]/,nolink:/^!?\[(ref)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",emStrong:{lDelim:/^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,rDelimAst:/^[^_*]*?\_\_[^_*]*?\*[^_*]*?(?=\_\_)|[punct_](\*+)(?=[\s]|$)|[^punct*_\s](\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|[^punct*_\s](\*+)(?=[^punct*_\s])/,rDelimUnd:/^[^_*]*?\*\*[^_*]*?\_[^_*]*?(?=\*\*)|[punct*](\_+)(?=[\s]|$)|[^punct*_\s](\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:uV,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};function kV(e){return e.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…")}function CV(e){let t,i,n="";const s=e.length;for(t=0;t<s;t++)i=e.charCodeAt(t),Math.random()>.5&&(i="x"+i.toString(16)),n+="&#"+i+";";return n}yV._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",yV.punctuation=sV(yV.punctuation).replace(/punctuation/g,yV._punctuation).getRegex(),yV.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,yV.escapedEmSt=/\\\*|\\_/g,yV._comment=sV(_V._comment).replace("(?:--\x3e|$)","--\x3e").getRegex(),yV.emStrong.lDelim=sV(yV.emStrong.lDelim).replace(/punct/g,yV._punctuation).getRegex(),yV.emStrong.rDelimAst=sV(yV.emStrong.rDelimAst,"g").replace(/punct/g,yV._punctuation).getRegex(),yV.emStrong.rDelimUnd=sV(yV.emStrong.rDelimUnd,"g").replace(/punct/g,yV._punctuation).getRegex(),yV._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,yV._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,yV._email=/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/,yV.autolink=sV(yV.autolink).replace("scheme",yV._scheme).replace("email",yV._email).getRegex(),yV._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,yV.tag=sV(yV.tag).replace("comment",yV._comment).replace("attribute",yV._attribute).getRegex(),yV._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,yV._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,yV._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,yV.link=sV(yV.link).replace("label",yV._label).replace("href",yV._href).replace("title",yV._title).getRegex(),yV.reflink=sV(yV.reflink).replace("label",yV._label).replace("ref",_V._label).getRegex(),yV.nolink=sV(yV.nolink).replace("ref",_V._label).getRegex(),yV.reflinkSearch=sV(yV.reflinkSearch,"g").replace("reflink",yV.reflink).replace("nolink",yV.nolink).getRegex(),yV.normal=mV({},yV),yV.pedantic=mV({},yV.normal,{strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:sV(/^!?\[(label)\]\((.*?)\)/).replace("label",yV._label).getRegex(),reflink:sV(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",yV._label).getRegex()}),yV.gfm=mV({},yV.normal,{escape:sV(yV.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/}),yV.gfm.url=sV(yV.gfm.url,"i").replace("email",yV.gfm._extended_email).getRegex(),yV.breaks=mV({},yV.gfm,{br:sV(yV.br).replace("{2,}","*").getRegex(),text:sV(yV.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()});class xV{static get rules(){return{block:_V,inline:yV}}static lex(e,t){return new xV(t).lex(e)}static lexInline(e,t){return new xV(t).inlineTokens(e)}lex(e){let t;for(e=e.replace(/\r\n|\r/g,"\n").replace(/\t/g," "),this.blockTokens(e,this.tokens);t=this.inlineQueue.shift();)this.inlineTokens(t.src,t.tokens);return this.tokens}blockTokens(e,t=[]){let i,n,s,o;for(this.options.pedantic&&(e=e.replace(/^ +$/gm,""));e;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some((n=>!!(i=n.call({lexer:this},e,t))&&(e=e.substring(i.raw.length),t.push(i),!0)))))if(i=this.tokenizer.space(e))e=e.substring(i.raw.length),1===i.raw.length&&t.length>0?t[t.length-1].raw+="\n":t.push(i);else if(i=this.tokenizer.code(e))e=e.substring(i.raw.length),n=t[t.length-1],!n||"paragraph"!==n.type&&"text"!==n.type?t.push(i):(n.raw+="\n"+i.raw,n.text+="\n"+i.text,this.inlineQueue[this.inlineQueue.length-1].src=n.text);else if(i=this.tokenizer.fences(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.heading(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.hr(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.blockquote(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.list(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.html(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.def(e))e=e.substring(i.raw.length),n=t[t.length-1],!n||"paragraph"!==n.type&&"text"!==n.type?this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title}):(n.raw+="\n"+i.raw,n.text+="\n"+i.raw,this.inlineQueue[this.inlineQueue.length-1].src=n.text);else if(i=this.tokenizer.table(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.lheading(e))e=e.substring(i.raw.length),t.push(i);else{if(s=e,this.options.extensions&&this.options.extensions.startBlock){let t=1/0;const i=e.slice(1);let n;this.options.extensions.startBlock.forEach((function(e){n=e.call({lexer:this},i),"number"==typeof n&&n>=0&&(t=Math.min(t,n))})),t<1/0&&t>=0&&(s=e.substring(0,t+1))}if(this.state.top&&(i=this.tokenizer.paragraph(s)))n=t[t.length-1],o&&"paragraph"===n.type?(n.raw+="\n"+i.raw,n.text+="\n"+i.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=n.text):t.push(i),o=s.length!==e.length,e=e.substring(i.raw.length);else if(i=this.tokenizer.text(e))e=e.substring(i.raw.length),n=t[t.length-1],n&&"text"===n.type?(n.raw+="\n"+i.raw,n.text+="\n"+i.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=n.text):t.push(i);else if(e){const t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return this.state.top=!0,t}inline(e,t){this.inlineQueue.push({src:e,tokens:t})}inlineTokens(e,t=[]){let i,n,s,o,r,a,l=e;if(this.tokens.links){const e=Object.keys(this.tokens.links);if(e.length>0)for(;null!=(o=this.tokenizer.rules.inline.reflinkSearch.exec(l));)e.includes(o[0].slice(o[0].lastIndexOf("[")+1,-1))&&(l=l.slice(0,o.index)+"["+bV("a",o[0].length-2)+"]"+l.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(o=this.tokenizer.rules.inline.blockSkip.exec(l));)l=l.slice(0,o.index)+"["+bV("a",o[0].length-2)+"]"+l.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;null!=(o=this.tokenizer.rules.inline.escapedEmSt.exec(l));)l=l.slice(0,o.index)+"++"+l.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex);for(;e;)if(r||(a=""),r=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some((n=>!!(i=n.call({lexer:this},e,t))&&(e=e.substring(i.raw.length),t.push(i),!0)))))if(i=this.tokenizer.escape(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.tag(e))e=e.substring(i.raw.length),n=t[t.length-1],n&&"text"===i.type&&"text"===n.type?(n.raw+=i.raw,n.text+=i.text):t.push(i);else if(i=this.tokenizer.link(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.reflink(e,this.tokens.links))e=e.substring(i.raw.length),n=t[t.length-1],n&&"text"===i.type&&"text"===n.type?(n.raw+=i.raw,n.text+=i.text):t.push(i);else if(i=this.tokenizer.emStrong(e,l,a))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.codespan(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.br(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.del(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.autolink(e,CV))e=e.substring(i.raw.length),t.push(i);else if(this.state.inLink||!(i=this.tokenizer.url(e,CV))){if(s=e,this.options.extensions&&this.options.extensions.startInline){let t=1/0;const i=e.slice(1);let n;this.options.extensions.startInline.forEach((function(e){n=e.call({lexer:this},i),"number"==typeof n&&n>=0&&(t=Math.min(t,n))})),t<1/0&&t>=0&&(s=e.substring(0,t+1))}if(i=this.tokenizer.inlineText(s,kV))e=e.substring(i.raw.length),"_"!==i.raw.slice(-1)&&(a=i.raw.slice(-1)),r=!0,n=t[t.length-1],n&&"text"===n.type?(n.raw+=i.raw,n.text+=i.text):t.push(i);else if(e){const t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}else e=e.substring(i.raw.length),t.push(i);return t}constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||GP,this.options.tokenizer=this.options.tokenizer||new vV,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const t={block:_V.normal,inline:yV.normal};this.options.pedantic?(t.block=_V.pedantic,t.inline=yV.pedantic):this.options.gfm&&(t.block=_V.gfm,this.options.breaks?t.inline=yV.breaks:t.inline=yV.gfm),this.tokenizer.rules=t}}class AV{code(e,t,i){const n=(t||"").match(/\S*/)[0];if(this.options.highlight){const t=this.options.highlight(e,n);null!=t&&t!==e&&(i=!0,e=t)}return e=e.replace(/\n$/,"")+"\n",n?'<pre><code class="'+this.options.langPrefix+eV(n,!0)+'">'+(i?e:eV(e,!0))+"</code></pre>\n":"<pre><code>"+(i?e:eV(e,!0))+"</code></pre>\n"}blockquote(e){return"<blockquote>\n"+e+"</blockquote>\n"}html(e){return e}heading(e,t,i,n){return this.options.headerIds?"<h"+t+' id="'+this.options.headerPrefix+n.slug(i)+'">'+e+"</h"+t+">\n":"<h"+t+">"+e+"</h"+t+">\n"}hr(){return this.options.xhtml?"<hr/>\n":"<hr>\n"}list(e,t,i){const n=t?"ol":"ul";return"<"+n+(t&&1!==i?' start="'+i+'"':"")+">\n"+e+"</"+n+">\n"}listitem(e){return"<li>"+e+"</li>\n"}checkbox(e){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"'+(this.options.xhtml?" /":"")+"> "}paragraph(e){return"<p>"+e+"</p>\n"}table(e,t){return t&&(t="<tbody>"+t+"</tbody>"),"<table>\n<thead>\n"+e+"</thead>\n"+t+"</table>\n"}tablerow(e){return"<tr>\n"+e+"</tr>\n"}tablecell(e,t){const i=t.header?"th":"td";return(t.align?"<"+i+' align="'+t.align+'">':"<"+i+">")+e+"</"+i+">\n"}strong(e){return"<strong>"+e+"</strong>"}em(e){return"<em>"+e+"</em>"}codespan(e){return"<code>"+e+"</code>"}br(){return this.options.xhtml?"<br/>":"<br>"}del(e){return"<del>"+e+"</del>"}link(e,t,i){if(null===(e=aV(this.options.sanitize,this.options.baseUrl,e)))return i;let n='<a href="'+eV(e)+'"';return t&&(n+=' title="'+t+'"'),n+=">"+i+"</a>",n}image(e,t,i){if(null===(e=aV(this.options.sanitize,this.options.baseUrl,e)))return i;let n='<img src="'+e+'" alt="'+i+'"';return t&&(n+=' title="'+t+'"'),n+=this.options.xhtml?"/>":">",n}text(e){return e}constructor(e){this.options=e||GP}}class EV{strong(e){return e}em(e){return e}codespan(e){return e}del(e){return e}html(e){return e}text(e){return e}link(e,t,i){return""+i}image(e,t,i){return""+i}br(){return""}}class TV{serialize(e){return e.toLowerCase().trim().replace(/<[!\/a-z].*?>/gi,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-")}getNextSafeSlug(e,t){let i=e,n=0;if(this.seen.hasOwnProperty(i)){n=this.seen[e];do{n++,i=e+"-"+n}while(this.seen.hasOwnProperty(i))}return t||(this.seen[e]=n,this.seen[i]=0),i}slug(e,t={}){const i=this.serialize(e);return this.getNextSafeSlug(i,t.dryrun)}constructor(){this.seen={}}}class SV{static parse(e,t){return new SV(t).parse(e)}static parseInline(e,t){return new SV(t).parseInline(e)}parse(e,t=!0){let i,n,s,o,r,a,l,c,d,h,u,m,g,f,p,b,w,v,_,y="";const k=e.length;for(i=0;i<k;i++)if(h=e[i],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[h.type]&&(_=this.options.extensions.renderers[h.type].call({parser:this},h),!1!==_||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(h.type)))y+=_||"";else switch(h.type){case"space":continue;case"hr":y+=this.renderer.hr();continue;case"heading":y+=this.renderer.heading(this.parseInline(h.tokens),h.depth,iV(this.parseInline(h.tokens,this.textRenderer)),this.slugger);continue;case"code":y+=this.renderer.code(h.text,h.lang,h.escaped);continue;case"table":for(c="",l="",o=h.header.length,n=0;n<o;n++)l+=this.renderer.tablecell(this.parseInline(h.header[n].tokens),{header:!0,align:h.align[n]});for(c+=this.renderer.tablerow(l),d="",o=h.rows.length,n=0;n<o;n++){for(a=h.rows[n],l="",r=a.length,s=0;s<r;s++)l+=this.renderer.tablecell(this.parseInline(a[s].tokens),{header:!1,align:h.align[s]});d+=this.renderer.tablerow(l)}y+=this.renderer.table(c,d);continue;case"blockquote":d=this.parse(h.tokens),y+=this.renderer.blockquote(d);continue;case"list":for(u=h.ordered,m=h.start,g=h.loose,o=h.items.length,d="",n=0;n<o;n++)p=h.items[n],b=p.checked,w=p.task,f="",p.task&&(v=this.renderer.checkbox(b),g?p.tokens.length>0&&"paragraph"===p.tokens[0].type?(p.tokens[0].text=v+" "+p.tokens[0].text,p.tokens[0].tokens&&p.tokens[0].tokens.length>0&&"text"===p.tokens[0].tokens[0].type&&(p.tokens[0].tokens[0].text=v+" "+p.tokens[0].tokens[0].text)):p.tokens.unshift({type:"text",text:v}):f+=v),f+=this.parse(p.tokens,g),d+=this.renderer.listitem(f,w,b);y+=this.renderer.list(d,u,m);continue;case"html":y+=this.renderer.html(h.text);continue;case"paragraph":y+=this.renderer.paragraph(this.parseInline(h.tokens));continue;case"text":for(d=h.tokens?this.parseInline(h.tokens):h.text;i+1<k&&"text"===e[i+1].type;)h=e[++i],d+="\n"+(h.tokens?this.parseInline(h.tokens):h.text);y+=t?this.renderer.paragraph(d):d;continue;default:{const e='Token with "'+h.type+'" type was not found.';if(this.options.silent)return void console.error(e);throw new Error(e)}}return y}parseInline(e,t){t=t||this.renderer;let i,n,s,o="";const r=e.length;for(i=0;i<r;i++)if(n=e[i],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[n.type]&&(s=this.options.extensions.renderers[n.type].call({parser:this},n),!1!==s||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(n.type)))o+=s||"";else switch(n.type){case"escape":case"text":o+=t.text(n.text);break;case"html":o+=t.html(n.text);break;case"link":o+=t.link(n.href,n.title,this.parseInline(n.tokens,t));break;case"image":o+=t.image(n.href,n.title,n.text);break;case"strong":o+=t.strong(this.parseInline(n.tokens,t));break;case"em":o+=t.em(this.parseInline(n.tokens,t));break;case"codespan":o+=t.codespan(n.text);break;case"br":o+=t.br();break;case"del":o+=t.del(this.parseInline(n.tokens,t));break;default:{const e='Token with "'+n.type+'" type was not found.';if(this.options.silent)return void console.error(e);throw new Error(e)}}return o}constructor(e){this.options=e||GP,this.options.renderer=this.options.renderer||new AV,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new EV,this.slugger=new TV}}function IV(e,t,i){if(null==e)throw new Error("marked(): input parameter is undefined or null");if("string"!=typeof e)throw new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected");if("function"==typeof t&&(i=t,t=null),pV(t=mV({},IV.defaults,t||{})),i){const n=t.highlight;let s;try{s=xV.lex(e,t)}catch(e){return i(e)}const o=function(e){let o;if(!e)try{t.walkTokens&&IV.walkTokens(s,t.walkTokens),o=SV.parse(s,t)}catch(t){e=t}return t.highlight=n,e?i(e):i(null,o)};if(!n||n.length<3)return o();if(delete t.highlight,!s.length)return o();let r=0;return IV.walkTokens(s,(function(e){"code"===e.type&&(r++,setTimeout((()=>{n(e.text,e.lang,(function(t,i){if(t)return o(t);null!=i&&i!==e.text&&(e.text=i,e.escaped=!0),r--,0===r&&o()}))}),0))})),void(0===r&&o())}try{const i=xV.lex(e,t);return t.walkTokens&&IV.walkTokens(i,t.walkTokens),SV.parse(i,t)}catch(e){if(e.message+="\nPlease report this to https://github.com/markedjs/marked.",t.silent)return"<p>An error occurred:</p><pre>"+eV(e.message+"",!0)+"</pre>";throw e}}function PV(e,t){return Array(t+1).join(e)}IV.options=IV.setOptions=function(e){var t;return mV(IV.defaults,e),t=IV.defaults,GP=t,IV},IV.getDefaults=qP,IV.defaults=GP,IV.use=function(...e){const t=mV({},...e),i=IV.defaults.extensions||{renderers:{},childTokens:{}};let n;e.forEach((e=>{if(e.extensions&&(n=!0,e.extensions.forEach((e=>{if(!e.name)throw new Error("extension name required");if(e.renderer){const t=i.renderers?i.renderers[e.name]:null;i.renderers[e.name]=t?function(...i){let n=e.renderer.apply(this,i);return!1===n&&(n=t.apply(this,i)),n}:e.renderer}if(e.tokenizer){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw new Error("extension level must be 'block' or 'inline'");i[e.level]?i[e.level].unshift(e.tokenizer):i[e.level]=[e.tokenizer],e.start&&("block"===e.level?i.startBlock?i.startBlock.push(e.start):i.startBlock=[e.start]:"inline"===e.level&&(i.startInline?i.startInline.push(e.start):i.startInline=[e.start]))}e.childTokens&&(i.childTokens[e.name]=e.childTokens)}))),e.renderer){const i=IV.defaults.renderer||new AV;for(const t in e.renderer){const n=i[t];i[t]=(...s)=>{let o=e.renderer[t].apply(i,s);return!1===o&&(o=n.apply(i,s)),o}}t.renderer=i}if(e.tokenizer){const i=IV.defaults.tokenizer||new vV;for(const t in e.tokenizer){const n=i[t];i[t]=(...s)=>{let o=e.tokenizer[t].apply(i,s);return!1===o&&(o=n.apply(i,s)),o}}t.tokenizer=i}if(e.walkTokens){const i=IV.defaults.walkTokens;t.walkTokens=function(t){e.walkTokens.call(this,t),i&&i.call(this,t)}}n&&(t.extensions=i),IV.setOptions(t)}))},IV.walkTokens=function(e,t){for(const i of e)switch(t.call(IV,i),i.type){case"table":for(const e of i.header)IV.walkTokens(e.tokens,t);for(const e of i.rows)for(const i of e)IV.walkTokens(i.tokens,t);break;case"list":IV.walkTokens(i.items,t);break;default:IV.defaults.extensions&&IV.defaults.extensions.childTokens&&IV.defaults.extensions.childTokens[i.type]?IV.defaults.extensions.childTokens[i.type].forEach((function(e){IV.walkTokens(i[e],t)})):i.tokens&&IV.walkTokens(i.tokens,t)}},IV.parseInline=function(e,t){if(null==e)throw new Error("marked.parseInline(): input parameter is undefined or null");if("string"!=typeof e)throw new Error("marked.parseInline(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected");pV(t=mV({},IV.defaults,t||{}));try{const i=xV.lexInline(e,t);return t.walkTokens&&IV.walkTokens(i,t.walkTokens),SV.parseInline(i,t)}catch(e){if(e.message+="\nPlease report this to https://github.com/markedjs/marked.",t.silent)return"<p>An error occurred:</p><pre>"+eV(e.message+"",!0)+"</pre>";throw e}},IV.Parser=SV,IV.parser=SV.parse,IV.Renderer=AV,IV.TextRenderer=EV,IV.Lexer=xV,IV.lexer=xV.lex,IV.Tokenizer=vV,IV.Slugger=TV,IV.parse=IV,IV.options,IV.setOptions,IV.use,IV.walkTokens,IV.parseInline,SV.parse,xV.lex,IV.use({tokenizer:{autolink:()=>null,url:()=>null},renderer:{checkbox(...e){return Object.getPrototypeOf(this).checkbox.call(this,...e).trimRight()},code(...e){return Object.getPrototypeOf(this).code.call(this,...e).replace("\n</code>","</code>")}}});var VV=["address","article","aside","audio","blockquote","body","canvas","center","dd","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frameset","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","isindex","li","main","menu","nav","noframes","noscript","ol","output","p","pre","section","table","tbody","td","tfoot","th","thead","tr","ul"];function RV(e){return-1!==VV.indexOf(e.nodeName.toLowerCase())}var BV=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"];function OV(e){return-1!==BV.indexOf(e.nodeName.toLowerCase())}var MV=BV.join();var LV={};function NV(e){for(var t in this.options=e,this._keep=[],this._remove=[],this.blankRule={replacement:e.blankReplacement},this.keepReplacement=e.keepReplacement,this.defaultRule={replacement:e.defaultReplacement},this.array=[],e.rules)this.array.push(e.rules[t])}function FV(e,t,i){for(var n=0;n<e.length;n++){var s=e[n];if(DV(s,t,i))return s}}function DV(e,t,i){var n=e.filter;if("string"==typeof n){if(n===t.nodeName.toLowerCase())return!0}else if(Array.isArray(n)){if(n.indexOf(t.nodeName.toLowerCase())>-1)return!0}else{if("function"!=typeof n)throw new TypeError("`filter` needs to be a string, array, or function");if(n.call(e,t,i))return!0}}function zV(e){var t=e.nextSibling||e.parentNode;return e.parentNode.removeChild(e),t}function HV(e,t,i){return e&&e.parentNode===t||i(t)?t.nextSibling||t.parentNode:t.firstChild||t.nextSibling||t.parentNode}LV.paragraph={filter:"p",replacement:function(e){return"\n\n"+e+"\n\n"}},LV.lineBreak={filter:"br",replacement:function(e,t,i){return i.br+"\n"}},LV.heading={filter:["h1","h2","h3","h4","h5","h6"],replacement:function(e,t,i){var n=Number(t.nodeName.charAt(1));return"setext"===i.headingStyle&&n<3?"\n\n"+e+"\n"+PV(1===n?"=":"-",e.length)+"\n\n":"\n\n"+PV("#",n)+" "+e+"\n\n"}},LV.blockquote={filter:"blockquote",replacement:function(e){return"\n\n"+(e=(e=e.replace(/^\n+|\n+$/g,"")).replace(/^/gm,"> "))+"\n\n"}},LV.list={filter:["ul","ol"],replacement:function(e,t){var i=t.parentNode;return"LI"===i.nodeName&&i.lastElementChild===t?"\n"+e:"\n\n"+e+"\n\n"}},LV.listItem={filter:"li",replacement:function(e,t,i){e=e.replace(/^\n+/,"").replace(/\n+$/,"\n").replace(/\n/gm,"\n ");var n=i.bulletListMarker+" ",s=t.parentNode;if("OL"===s.nodeName){var o=s.getAttribute("start"),r=Array.prototype.indexOf.call(s.children,t);n=(o?Number(o)+r:r+1)+". "}return n+e+(t.nextSibling&&!/\n$/.test(e)?"\n":"")}},LV.indentedCodeBlock={filter:function(e,t){return"indented"===t.codeBlockStyle&&"PRE"===e.nodeName&&e.firstChild&&"CODE"===e.firstChild.nodeName},replacement:function(e,t,i){return"\n\n "+t.firstChild.textContent.replace(/\n/g,"\n ")+"\n\n"}},LV.fencedCodeBlock={filter:function(e,t){return"fenced"===t.codeBlockStyle&&"PRE"===e.nodeName&&e.firstChild&&"CODE"===e.firstChild.nodeName},replacement:function(e,t,i){for(var n,s=((t.firstChild.className||"").match(/language-(\S+)/)||[null,""])[1],o=t.firstChild.textContent,r=i.fence.charAt(0),a=3,l=new RegExp("^"+r+"{3,}","gm");n=l.exec(o);)n[0].length>=a&&(a=n[0].length+1);var c=PV(r,a);return"\n\n"+c+s+"\n"+o.replace(/\n$/,"")+"\n"+c+"\n\n"}},LV.horizontalRule={filter:"hr",replacement:function(e,t,i){return"\n\n"+i.hr+"\n\n"}},LV.inlineLink={filter:function(e,t){return"inlined"===t.linkStyle&&"A"===e.nodeName&&e.getAttribute("href")},replacement:function(e,t){return"["+e+"]("+t.getAttribute("href")+(t.title?' "'+t.title+'"':"")+")"}},LV.referenceLink={filter:function(e,t){return"referenced"===t.linkStyle&&"A"===e.nodeName&&e.getAttribute("href")},replacement:function(e,t,i){var n,s,o=t.getAttribute("href"),r=t.title?' "'+t.title+'"':"";switch(i.linkReferenceStyle){case"collapsed":n="["+e+"][]",s="["+e+"]: "+o+r;break;case"shortcut":n="["+e+"]",s="["+e+"]: "+o+r;break;default:var a=this.references.length+1;n="["+e+"]["+a+"]",s="["+a+"]: "+o+r}return this.references.push(s),n},references:[],append:function(e){var t="";return this.references.length&&(t="\n\n"+this.references.join("\n")+"\n\n",this.references=[]),t}},LV.emphasis={filter:["em","i"],replacement:function(e,t,i){return e.trim()?i.emDelimiter+e+i.emDelimiter:""}},LV.strong={filter:["strong","b"],replacement:function(e,t,i){return e.trim()?i.strongDelimiter+e+i.strongDelimiter:""}},LV.code={filter:function(e){var t=e.previousSibling||e.nextSibling,i="PRE"===e.parentNode.nodeName&&!t;return"CODE"===e.nodeName&&!i},replacement:function(e){if(!e.trim())return"";var t="`",i="",n="",s=e.match(/`+/gm);if(s)for(/^`/.test(e)&&(i=" "),/`$/.test(e)&&(n=" ");-1!==s.indexOf(t);)t+="`";return t+i+e+n+t}},LV.image={filter:"img",replacement:function(e,t){var i=t.alt||"",n=t.getAttribute("src")||"",s=t.title||"";return n?"!["+i+"]("+n+(s?' "'+s+'"':"")+")":""}},NV.prototype={add:function(e,t){this.array.unshift(t)},keep:function(e){this._keep.unshift({filter:e,replacement:this.keepReplacement})},remove:function(e){this._remove.unshift({filter:e,replacement:function(){return""}})},forNode:function(e){return e.isBlank?this.blankRule:(t=FV(this.array,e,this.options))||(t=FV(this._keep,e,this.options))||(t=FV(this._remove,e,this.options))?t:this.defaultRule;var t},forEach:function(e){for(var t=0;t<this.array.length;t++)e(this.array[t],t)}};var $V="undefined"!=typeof window?window:{};var UV,WV=function(){var e=$V.DOMParser,t=!1;try{(new e).parseFromString("","text/html")&&(t=!0)}catch(e){}return t}()?$V.DOMParser:function(){var e=function(){};return!function(){var e=!1;try{document.implementation.createHTMLDocument("").open()}catch(t){window.ActiveXObject&&(e=!0)}return e}()?e.prototype.parseFromString=function(e){var t=document.implementation.createHTMLDocument("");return t.open(),t.write(e),t.close(),t}:e.prototype.parseFromString=function(e){var t=new window.ActiveXObject("htmlfile");return t.designMode="on",t.open(),t.write(e),t.close(),t},e}();function jV(e){var t;"string"==typeof e?t=(UV=UV||new WV).parseFromString('<x-turndown id="turndown-root">'+e+"</x-turndown>","text/html").getElementById("turndown-root"):t=e.cloneNode(!0);return function(e){var t=e.element,i=e.isBlock,n=e.isVoid,s=e.isPre||function(e){return"PRE"===e.nodeName};if(t.firstChild&&!s(t)){for(var o=null,r=!1,a=null,l=HV(a,t,s);l!==t;){if(3===l.nodeType||4===l.nodeType){var c=l.data.replace(/[ \r\n\t]+/g," ");if(o&&!/ $/.test(o.data)||r||" "!==c[0]||(c=c.substr(1)),!c){l=zV(l);continue}l.data=c,o=l}else{if(1!==l.nodeType){l=zV(l);continue}i(l)||"BR"===l.nodeName?(o&&(o.data=o.data.replace(/ $/,"")),o=null,r=!1):n(l)&&(o=null,r=!0)}var d=HV(a,l,s);a=l,l=d}o&&(o.data=o.data.replace(/ $/,""),o.data||zV(o))}}({element:t,isBlock:RV,isVoid:OV}),t}function qV(e){return e.isBlock=RV(e),e.isCode="code"===e.nodeName.toLowerCase()||e.parentNode.isCode,e.isBlank=function(e){return-1===["A","TH","TD","IFRAME","SCRIPT","AUDIO","VIDEO"].indexOf(e.nodeName)&&/^\s*$/i.test(e.textContent)&&!OV(e)&&!function(e){return e.querySelector&&e.querySelector(MV)}(e)}(e),e.flankingWhitespace=function(e){var t="",i="";if(!e.isBlock){var n=/^\s/.test(e.textContent),s=/\s$/.test(e.textContent),o=e.isBlank&&n&&s;n&&!GV("left",e)&&(t=" "),o||!s||GV("right",e)||(i=" ")}return{leading:t,trailing:i}}(e),e}function GV(e,t){var i,n,s;return"left"===e?(i=t.previousSibling,n=/ $/):(i=t.nextSibling,n=/^ /),i&&(3===i.nodeType?s=n.test(i.nodeValue):1!==i.nodeType||RV(i)||(s=n.test(i.textContent))),s}var KV=Array.prototype.reduce,ZV=/^\n*/,JV=/\n*$/,QV=[[/\\/g,"\\\\"],[/\*/g,"\\*"],[/^-/g,"\\-"],[/^\+ /g,"\\+ "],[/^(=+)/g,"\\$1"],[/^(#{1,6}) /g,"\\$1 "],[/`/g,"\\`"],[/^~~~/g,"\\~~~"],[/\[/g,"\\["],[/\]/g,"\\]"],[/^>/g,"\\>"],[/_/g,"\\_"],[/^(\d+)\. /g,"$1\\. "]];function YV(e){if(!(this instanceof YV))return new YV(e);var t={rules:LV,headingStyle:"setext",hr:"* * *",bulletListMarker:"*",codeBlockStyle:"indented",fence:"```",emDelimiter:"_",strongDelimiter:"**",linkStyle:"inlined",linkReferenceStyle:"full",br:" ",blankReplacement:function(e,t){return t.isBlock?"\n\n":""},keepReplacement:function(e,t){return t.isBlock?"\n\n"+t.outerHTML+"\n\n":t.outerHTML},defaultReplacement:function(e,t){return t.isBlock?"\n\n"+e+"\n\n":e}};this.options=function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var n in i)i.hasOwnProperty(n)&&(e[n]=i[n])}return e}({},t,e),this.rules=new NV(this.options)}function XV(e){var t=this;return KV.call(e.childNodes,(function(e,i){var n="";return 3===(i=new qV(i)).nodeType?n=i.isCode?i.nodeValue:t.escape(i.nodeValue):1===i.nodeType&&(n=tR.call(t,i)),iR(e,n)}),"")}function eR(e){var t=this;return this.rules.forEach((function(i){"function"==typeof i.append&&(e=iR(e,i.append(t.options)))})),e.replace(/^[\t\r\n]+/,"").replace(/[\t\r\n\s]+$/,"")}function tR(e){var t=this.rules.forNode(e),i=XV.call(this,e),n=e.flankingWhitespace;return(n.leading||n.trailing)&&(i=i.trim()),n.leading+t.replacement(i,e,this.options)+n.trailing}function iR(e,t){var i,n,s,o=(i=t,n=[e.match(JV)[0],i.match(ZV)[0]].sort(),(s=n[n.length-1]).length<2?s:"\n\n");return(e=e.replace(JV,""))+o+(t=t.replace(ZV,""))}YV.prototype={turndown:function(e){if(!function(e){return null!=e&&("string"==typeof e||e.nodeType&&(1===e.nodeType||9===e.nodeType||11===e.nodeType))}(e))throw new TypeError(e+" is not a string, or an element/document/fragment node.");if(""===e)return"";var t=XV.call(this,new jV(e));return eR.call(this,t)},use:function(e){if(Array.isArray(e))for(var t=0;t<e.length;t++)this.use(e[t]);else{if("function"!=typeof e)throw new TypeError("plugin must be a Function or an Array of Functions");e(this)}return this},addRule:function(e,t){return this.rules.add(e,t),this},keep:function(e){return this.rules.keep(e),this},remove:function(e){return this.rules.remove(e),this},escape:function(e){return QV.reduce((function(e,t){return e.replace(t[0],t[1])}),e)}};var nR=/highlight-(?:text|source)-([a-z0-9]+)/;function sR(e){e.addRule("highlightedCodeBlock",{filter:function(e){var t=e.firstChild;return"DIV"===e.nodeName&&nR.test(e.className)&&t&&"PRE"===t.nodeName},replacement:function(e,t,i){var n=((t.className||"").match(nR)||[null,""])[1];return"\n\n"+i.fence+n+"\n"+t.firstChild.textContent+"\n"+i.fence+"\n\n"}})}function oR(e){e.addRule("strikethrough",{filter:["del","s","strike"],replacement:function(e){return"~"+e+"~"}})}var rR=Array.prototype.indexOf,aR=Array.prototype.every,lR={};function cR(e){var t,i,n=e.parentNode;return"THEAD"===n.nodeName||n.firstChild===e&&("TABLE"===n.nodeName||(i=(t=n).previousSibling,"TBODY"===t.nodeName&&(!i||"THEAD"===i.nodeName&&/^\s*$/i.test(i.textContent))))&&aR.call(e.childNodes,(function(e){return"TH"===e.nodeName}))}function dR(e,t){var i=" ";return 0===rR.call(t.parentNode.childNodes,t)&&(i="| "),i+e+" |"}function hR(e){for(var t in e.keep((function(e){return"TABLE"===e.nodeName&&!cR(e.rows[0])})),lR)e.addRule(t,lR[t])}function uR(e){e.addRule("taskListItems",{filter:function(e){return"checkbox"===e.type&&"LI"===e.parentNode.nodeName},replacement:function(e,t){return(t.checked?"[x]":"[ ]")+" "}})}lR.tableCell={filter:["th","td"],replacement:function(e,t){return dR(e,t)}},lR.tableRow={filter:"tr",replacement:function(e,t){var i="",n={left:":--",right:"--:",center:":-:"};if(cR(t))for(var s=0;s<t.childNodes.length;s++){var o="---",r=(t.childNodes[s].getAttribute("align")||"").toLowerCase();r&&(o=n[r]||o),i+=dR(o,t.childNodes[s])}return"\n"+e+(i?"\n"+i:"")}},lR.table={filter:function(e){return"TABLE"===e.nodeName&&cR(e.rows[0])},replacement:function(e){return"\n\n"+(e=e.replace("\n\n","\n"))+"\n\n"}},lR.tableSection={filter:["thead","tbody","tfoot"],replacement:function(e){return e}};const mR=YV.prototype.escape;function gR(e){return e=(e=mR(e)).replace(/</g,"\\<")}YV.prototype.escape=function(e){let t="",i=0;for(const n of function*(e){for(const t of e.matchAll(pR)){const e=t[0],i=bR(e);yield Object.assign([e.substring(0,i)],{index:t.index})}}(e)){const s=n.index;s>i&&(t+=gR(e.substring(i,s)));const o=n[0];t+=o,i=s+o.length}return i<e.length&&(t+=gR(e.substring(i,e.length))),t};const fR=new YV({codeBlockStyle:"fenced",hr:"---",headingStyle:"atx"});fR.use([function(e){e.use([sR,oR,hR,uR])},function(e){e.addRule("taskListItems",{filter:e=>"checkbox"===e.type&&("LI"===e.parentNode.nodeName||"LI"===e.parentNode.parentNode.nodeName),replacement:(e,t)=>(t.checked?"[x]":"[ ]")+" "})}]);const pR=new RegExp(/\b(?:(?:https?|ftp):\/\/|www\.)/.source+/(?![-_])(?:[-_a-z0-9\u00a1-\uffff]{1,63}\.)+(?:[a-z\u00a1-\uffff]{2,63})/.source+/(?:[^\s<>]*)/.source,"gi");function bR(e){let t=e.length;for(;t>0;){const i=e[t-1];if("?!.,:*_~'\"".includes(i))t--;else{if(")"!=i)break;{let i=0;for(let n=0;n<t;n++)"("==e[n]?i++:")"==e[n]&&i--;if(!(i<0))break;t--}}}return t}class wR{keepHtml(e){fR.keep([e])}toView(e){const t=(i=e,IV.parse(i,{gfm:!0,breaks:!0,tables:!0,xhtml:!0,headerIds:!1}));var i;return this._htmlDP.toView(t)}toData(e){return function(e){return fR.turndown(e)}(this._htmlDP.toData(e))}registerRawContentMatcher(e){this._htmlDP.registerRawContentMatcher(e)}useFillerType(){}constructor(e){this._htmlDP=new wh(e)}}class vR extends Na{static get pluginName(){return"Markdown"}constructor(e){super(e),e.data.processor=new wR(e.data.viewDocument)}}const _R=["SPAN","BR","PRE","CODE"];class yR extends Na{static get pluginName(){return"PasteFromMarkdownExperimental"}static get requires(){return[Z_]}init(){const e=this.editor,t=e.editing.view.document,i=e.plugins.get("ClipboardPipeline");let n=!1;this.listenTo(t,"keydown",((e,t)=>{n=t.shiftKey})),this.listenTo(i,"inputTransformation",((e,t)=>{if(n)return;const i=t.dataTransfer.getData("text/html");if(!i){const e=t.dataTransfer.getData("text/plain");return void(t.content=this._gfmDataProcessor.toView(e))}const s=this._parseMarkdownFromHtml(i);s&&(t.content=this._gfmDataProcessor.toView(s))}))}_parseMarkdownFromHtml(e){const t=this._removeOsSpecificTags(e);if(!this._containsOnlyAllowedFirstLevelTags(t))return null;const i=this._removeFirstLevelWrapperTagsAndBrs(t);return this._containsAnyRemainingHtmlTags(i)?null:this._replaceHtmlReservedEntitiesWithCharacters(i)}_removeOsSpecificTags(e){return e.replace(/^<meta\b[^>]*>/,"").trim().replace(/^<html>/,"").replace(/<\/html>$/,"").trim().replace(/^<body>/,"").replace(/<\/body>$/,"").trim().replace(/^<!--StartFragment-->/,"").replace(/<!--EndFragment-->$/,"").trim()}_containsOnlyAllowedFirstLevelTags(e){const t=new DOMParser,{body:i}=t.parseFromString(e,"text/html");return Array.from(i.children).map((e=>e.tagName)).every((e=>_R.includes(e)))}_removeFirstLevelWrapperTagsAndBrs(e){const t=new DOMParser,{body:i}=t.parseFromString(e,"text/html"),n=i.querySelectorAll("br");for(const e of n)e.replaceWith("\n");const s=i.querySelectorAll(":scope > *");for(const e of s){const t=e.cloneNode(!0);e.replaceWith(...t.childNodes)}return i.innerHTML}_containsAnyRemainingHtmlTags(e){return e.includes("<")}_replaceHtmlReservedEntitiesWithCharacters(e){return e.replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&nbsp;/g," ")}constructor(e){super(e),this._gfmDataProcessor=new wR(e.data.viewDocument)}}function kR(e,t){const i=(i,n,s)=>{if(!s.consumable.consume(n.item,i.name))return;const o=n.attributeNewValue,r=s.writer,a=s.mapper.toViewElement(n.item),l=[...a.getChildren()].find((e=>e.getCustomProperty("media-content")));r.remove(l);const c=e.getMediaViewElement(r,o,t);r.insert(r.createPositionAt(a,0),c)};return e=>{e.on("attribute:url:media",i)}}function CR(e){const t=e.getSelectedElement();return t&&function(e){return!!e.getCustomProperty("media")&&ny(e)}(t)?t:null}function xR(e,t,i,n){return e.createContainerElement("figure",{class:"media"},[t.getMediaViewElement(e,i,n),e.createSlot()])}function AR(e){const t=e.getSelectedElement();return t&&t.is("element","media")?t:null}function ER(e,t,i,n){e.change((s=>{const o=s.createElement("media",{url:t});e.insertObject(o,i,null,{setSelection:"on",findOptimalPosition:n?"auto":void 0})}))}class TR extends Da{refresh(){const e=this.editor.model,t=e.document.selection,i=AR(t);this.value=i?i.getAttribute("url"):void 0,this.isEnabled=function(e){const t=e.getSelectedElement();return!!t&&"media"===t.name}(t)||function(e,t){const i=hy(e,t);let n=i.start.parent;n.isEmpty&&!t.schema.isLimit(n)&&(n=n.parent);return t.schema.checkChild(n,"media")}(t,e)}execute(e){const t=this.editor.model,i=t.document.selection,n=AR(i);n?t.change((t=>{t.setAttribute("url",e,n)})):ER(t,e,i,!0)}}class SR{hasMedia(e){return!!this._getMedia(e)}getMediaViewElement(e,t,i){return this._getMedia(t).getViewElement(e,i)}_getMedia(e){if(!e)return new IR(this.locale);e=e.trim();for(const t of this.providerDefinitions){const i=t.html,n=pa(t.url);for(const t of n){const n=this._getUrlMatches(e,t);if(n)return new IR(this.locale,e,n,i)}}return null}_getUrlMatches(e,t){let i=e.match(t);if(i)return i;let n=e.replace(/^https?:\/\//,"");return i=n.match(t),i||(n=n.replace(/^www\./,""),i=n.match(t),i||null)}constructor(e,t){const i=t.providers,n=t.extraProviders||[],s=new Set(t.removeProviders),o=i.concat(n).filter((e=>{const t=e.name;return t?!s.has(t):(b("media-embed-no-provider-name",{provider:e}),!1)}));this.locale=e,this.providerDefinitions=o}}class IR{getViewElement(e,t){const i={};let n;if(t.renderForEditingView||t.renderMediaPreview&&this.url&&this._previewRenderer){this.url&&(i["data-oembed-url"]=this.url),t.renderForEditingView&&(i.class="ck-media__wrapper");const s=this._getPreviewHtml(t);n=e.createRawElement("div",i,((e,t)=>{t.setContentOf(e,s)}))}else this.url&&(i.url=this.url),n=e.createEmptyElement(t.elementName,i);return e.setCustomProperty("media-content",!0,n),n}_getPreviewHtml(e){return this._previewRenderer?this._previewRenderer(this._match):this.url&&e.renderForEditingView?this._getPlaceholderHtml():""}_getPlaceholderHtml(){const e=new Dg,t=this._locale.t;e.content='<svg viewBox="0 0 64 42" xmlns="http://www.w3.org/2000/svg"><path d="M47.426 17V3.713L63.102 0v19.389h-.001l.001.272c0 1.595-2.032 3.43-4.538 4.098-2.506.668-4.538-.083-4.538-1.678 0-1.594 2.032-3.43 4.538-4.098.914-.244 2.032-.565 2.888-.603V4.516L49.076 7.447v9.556A1.014 1.014 0 0 0 49 17h-1.574zM29.5 17h-8.343a7.073 7.073 0 1 0-4.657 4.06v3.781H3.3a2.803 2.803 0 0 1-2.8-2.804V8.63a2.803 2.803 0 0 1 2.8-2.805h4.082L8.58 2.768A1.994 1.994 0 0 1 10.435 1.5h8.985c.773 0 1.477.448 1.805 1.149l1.488 3.177H26.7c1.546 0 2.8 1.256 2.8 2.805V17zm-11.637 0H17.5a1 1 0 0 0-1 1v.05A4.244 4.244 0 1 1 17.863 17zm29.684 2c.97 0 .953-.048.953.889v20.743c0 .953.016.905-.953.905H19.453c-.97 0-.953.048-.953-.905V19.89c0-.937-.016-.889.97-.889h28.077zm-4.701 19.338V22.183H24.154v16.155h18.692zM20.6 21.375v1.616h1.616v-1.616H20.6zm0 3.231v1.616h1.616v-1.616H20.6zm0 3.231v1.616h1.616v-1.616H20.6zm0 3.231v1.616h1.616v-1.616H20.6zm0 3.231v1.616h1.616v-1.616H20.6zm0 3.231v1.616h1.616V37.53H20.6zm24.233-16.155v1.616h1.615v-1.616h-1.615zm0 3.231v1.616h1.615v-1.616h-1.615zm0 3.231v1.616h1.615v-1.616h-1.615zm0 3.231v1.616h1.615v-1.616h-1.615zm0 3.231v1.616h1.615v-1.616h-1.615zm0 3.231v1.616h1.615V37.53h-1.615zM29.485 25.283a.4.4 0 0 1 .593-.35l9.05 4.977a.4.4 0 0 1 0 .701l-9.05 4.978a.4.4 0 0 1-.593-.35v-9.956z"/></svg>',e.viewBox="0 0 64 42";return new rg({tag:"div",attributes:{class:"ck ck-reset_all ck-media__placeholder"},children:[{tag:"div",attributes:{class:"ck-media__placeholder__icon"},children:[e]},{tag:"a",attributes:{class:"ck-media__placeholder__url",target:"_blank",rel:"noopener noreferrer",href:this.url,"data-cke-tooltip-text":t("Open media in new tab")},children:[{tag:"span",attributes:{class:"ck-media__placeholder__url__text"},children:[this.url]}]}]}).render().outerHTML}_getValidUrl(e){return e?e.match(/^https?/)?e:"https://"+e:null}constructor(e,t,i,n){this.url=this._getValidUrl(t),this._locale=e,this._match=i,this._previewRenderer=n}}class PR extends Na{static get pluginName(){return"MediaEmbedEditing"}init(){const e=this.editor,t=e.model.schema,i=e.t,n=e.conversion,s=e.config.get("mediaEmbed.previewsInData"),o=e.config.get("mediaEmbed.elementName"),r=this.registry;e.commands.add("mediaEmbed",new TR(e)),t.register("media",{inheritAllFrom:"$blockObject",allowAttributes:["url"]}),n.for("dataDowncast").elementToStructure({model:"media",view:(e,{writer:t})=>{const i=e.getAttribute("url");return xR(t,r,i,{elementName:o,renderMediaPreview:!!i&&s})}}),n.for("dataDowncast").add(kR(r,{elementName:o,renderMediaPreview:s})),n.for("editingDowncast").elementToStructure({model:"media",view:(e,{writer:t})=>{const n=e.getAttribute("url");return function(e,t,i){return t.setCustomProperty("media",!0,e),sy(e,t,{label:i})}(xR(t,r,n,{elementName:o,renderForEditingView:!0}),t,i("media widget"))}}),n.for("editingDowncast").add(kR(r,{elementName:o,renderForEditingView:!0})),n.for("upcast").elementToElement({view:e=>["oembed",o].includes(e.name)&&e.getAttribute("url")?{name:!0}:null,model:(e,{writer:t})=>{const i=e.getAttribute("url");return r.hasMedia(i)?t.createElement("media",{url:i}):null}}).elementToElement({view:{name:"div",attributes:{"data-oembed-url":!0}},model:(e,{writer:t})=>{const i=e.getAttribute("data-oembed-url");return r.hasMedia(i)?t.createElement("media",{url:i}):null}}).add((e=>{e.on("element:figure",((e,t,i)=>{if(!i.consumable.consume(t.viewItem,{name:!0,classes:"media"}))return;const{modelRange:n,modelCursor:s}=i.convertChildren(t.viewItem,t.modelCursor);t.modelRange=n,t.modelCursor=s;_a(n.getItems())||i.consumable.revert(t.viewItem,{name:!0,classes:"media"})}))}))}constructor(e){super(e),e.config.define("mediaEmbed",{elementName:"oembed",providers:[{name:"dailymotion",url:[/^dailymotion\.com\/video\/(\w+)/,/^dai.ly\/(\w+)/],html:e=>`<div style="position: relative; padding-bottom: 100%; height: 0; "><iframe src="https://www.dailymotion.com/embed/video/${e[1]}" style="position: absolute; width: 100%; height: 100%; top: 0; left: 0;" frameborder="0" width="480" height="270" allowfullscreen allow="autoplay"></iframe></div>`},{name:"spotify",url:[/^open\.spotify\.com\/(artist\/\w+)/,/^open\.spotify\.com\/(album\/\w+)/,/^open\.spotify\.com\/(track\/\w+)/],html:e=>`<div style="position: relative; padding-bottom: 100%; height: 0; padding-bottom: 126%;"><iframe src="https://open.spotify.com/embed/${e[1]}" style="position: absolute; width: 100%; height: 100%; top: 0; left: 0;" frameborder="0" allowtransparency="true" allow="encrypted-media"></iframe></div>`},{name:"youtube",url:[/^(?:m\.)?youtube\.com\/watch\?v=([\w-]+)(?:&t=(\d+))?/,/^(?:m\.)?youtube\.com\/v\/([\w-]+)(?:\?t=(\d+))?/,/^youtube\.com\/embed\/([\w-]+)(?:\?start=(\d+))?/,/^youtu\.be\/([\w-]+)(?:\?t=(\d+))?/],html:e=>{const t=e[1],i=e[2];return`<div style="position: relative; padding-bottom: 100%; height: 0; padding-bottom: 56.2493%;"><iframe src="https://www.youtube.com/embed/${t}${i?`?start=${i}`:""}" style="position: absolute; width: 100%; height: 100%; top: 0; left: 0;" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe></div>`}},{name:"vimeo",url:[/^vimeo\.com\/(\d+)/,/^vimeo\.com\/[^/]+\/[^/]+\/video\/(\d+)/,/^vimeo\.com\/album\/[^/]+\/video\/(\d+)/,/^vimeo\.com\/channels\/[^/]+\/(\d+)/,/^vimeo\.com\/groups\/[^/]+\/videos\/(\d+)/,/^vimeo\.com\/ondemand\/[^/]+\/(\d+)/,/^player\.vimeo\.com\/video\/(\d+)/],html:e=>`<div style="position: relative; padding-bottom: 100%; height: 0; padding-bottom: 56.2493%;"><iframe src="https://player.vimeo.com/video/${e[1]}" style="position: absolute; width: 100%; height: 100%; top: 0; left: 0;" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe></div>`},{name:"instagram",url:/^instagram\.com\/p\/(\w+)/},{name:"twitter",url:/^twitter\.com/},{name:"googleMaps",url:[/^google\.com\/maps/,/^goo\.gl\/maps/,/^maps\.google\.com/,/^maps\.app\.goo\.gl/]},{name:"flickr",url:/^flickr\.com/},{name:"facebook",url:/^facebook\.com/}]}),this.registry=new SR(e.locale,e.config.get("mediaEmbed"))}}const VR=/^(?:http(s)?:\/\/)?[\w-]+\.[\w-.~:/?#[\]@!$&'()*+,;=%]+$/;class RR extends Na{static get requires(){return[Jy,Rw,pC]}static get pluginName(){return"AutoMediaEmbed"}init(){const e=this.editor,t=e.model.document,i=e.plugins.get("ClipboardPipeline");this.listenTo(i,"inputTransformation",(()=>{const e=t.selection.getFirstRange(),i=eu.fromPosition(e.start);i.stickiness="toPrevious";const n=eu.fromPosition(e.end);n.stickiness="toNext",t.once("change:data",(()=>{this._embedMediaBetweenPositions(i,n),i.detach(),n.detach()}),{priority:"high"})}));e.commands.get("undo").on("execute",(()=>{this._timeoutId&&(_r.window.clearTimeout(this._timeoutId),this._positionToInsert.detach(),this._timeoutId=null,this._positionToInsert=null)}),{priority:"high"})}_embedMediaBetweenPositions(e,t){const i=this.editor,n=i.plugins.get(PR).registry,s=new pd(e,t),o=s.getWalker({ignoreElementEnd:!0});let r="";for(const e of o)e.item.is("$textProxy")&&(r+=e.item.data);if(r=r.trim(),!r.match(VR))return void s.detach();if(!n.hasMedia(r))return void s.detach();i.commands.get("mediaEmbed").isEnabled?(this._positionToInsert=eu.fromPosition(e),this._timeoutId=_r.window.setTimeout((()=>{i.model.change((e=>{this._timeoutId=null,e.remove(s),s.detach();let t=null;"$graveyard"!==this._positionToInsert.root.rootName&&(t=this._positionToInsert),ER(i.model,r,t,!1),this._positionToInsert.detach(),this._positionToInsert=null})),i.plugins.get(Rw).requestUndoOnBackspace()}),100)):s.detach()}constructor(e){super(e),this._timeoutId=null,this._positionToInsert=null}}class BR extends Tg{render(){super.render(),Vg({view:this});[this.urlInputView,this.saveButtonView,this.cancelButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)})),this.keystrokes.listenTo(this.element);const e=e=>e.stopPropagation();this.keystrokes.set("arrowright",e),this.keystrokes.set("arrowleft",e),this.keystrokes.set("arrowup",e),this.keystrokes.set("arrowdown",e)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}get url(){return this.urlInputView.fieldView.element.value.trim()}set url(e){this.urlInputView.fieldView.element.value=e.trim()}isValid(){this.resetFormStatus();for(const e of this._validators){const t=e(this);if(t)return this.urlInputView.errorText=t,!1}return!0}resetFormStatus(){this.urlInputView.errorText=null,this.urlInputView.infoText=this._urlInputViewInfoDefault}_createUrlInput(){const e=this.locale.t,t=new bf(this.locale,Qf),i=t.fieldView;return this._urlInputViewInfoDefault=e("Paste the media URL in the input."),this._urlInputViewInfoTip=e("Tip: Paste the URL into the content to embed faster."),t.label=e("Media URL"),t.infoText=this._urlInputViewInfoDefault,i.on("input",(()=>{t.infoText=i.element.value?this._urlInputViewInfoTip:this._urlInputViewInfoDefault,this.mediaURLInputValue=i.element.value.trim()})),t}_createButton(e,t,i,n){const s=new Hg(this.locale);return s.set({label:e,icon:t,tooltip:!0}),s.extendTemplate({attributes:{class:i}}),n&&s.delegate("execute").to(this,n),s}constructor(e,t){super(t);const i=t.t;this.focusTracker=new ya,this.keystrokes=new ka,this.set("mediaURLInputValue",""),this.urlInputView=this._createUrlInput(),this.saveButtonView=this._createButton(i("Save"),Dm.check,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(i("Cancel"),Dm.cancel,"ck-button-cancel","cancel"),this._focusables=new og,this._focusCycler=new Tf({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this._validators=e,this.setTemplate({tag:"form",attributes:{class:["ck","ck-media-form","ck-responsive-form"],tabindex:"-1"},children:[this.urlInputView,this.saveButtonView,this.cancelButtonView]})}}class OR extends Na{static get requires(){return[PR]}static get pluginName(){return"MediaEmbedUI"}init(){const e=this.editor,t=e.commands.get("mediaEmbed");e.ui.componentFactory.add("mediaEmbed",(e=>{const i=Wf(e);return this._setUpDropdown(i,t),i}))}_setUpDropdown(e,t){const i=this.editor,n=i.t,s=e.buttonView,o=i.plugins.get(PR).registry;e.once("change:isOpen",(()=>{const n=new(Pg(BR))(function(e,t){return[t=>{if(!t.url.length)return e("The URL must not be empty.")},i=>{if(!t.hasMedia(i.url))return e("This media URL is not supported.")}]}(i.t,o),i.locale);e.panelView.children.add(n),s.on("open",(()=>{n.disableCssTransitions(),n.url=t.value||"",n.urlInputView.fieldView.select(),n.enableCssTransitions()}),{priority:"low"}),e.on("submit",(()=>{n.isValid()&&(i.execute("mediaEmbed",n.url),i.editing.view.focus())})),e.on("change:isOpen",(()=>n.resetFormStatus())),e.on("cancel",(()=>{i.editing.view.focus()})),n.delegate("submit","cancel").to(e),n.urlInputView.fieldView.bind("value").to(t,"value"),n.urlInputView.on("change:errorText",(()=>{i.ui.update()})),n.urlInputView.bind("isEnabled").to(t,"isEnabled")})),e.bind("isEnabled").to(t),s.set({label:n("Insert media"),icon:'<svg viewBox="0 0 22 20" xmlns="http://www.w3.org/2000/svg"><path d="M1.587 1.5c-.612 0-.601-.029-.601.551v14.84c0 .59-.01.559.591.559h18.846c.602 0 .591.03.591-.56V2.052c0-.58.01-.55-.591-.55H1.587Zm.701.971h1.003v1H2.288v-1Zm16.448 0h1.003v1h-1.003v-1Zm-14.24 1h13.008v12H4.467l.029-12Zm-2.208 1h1.003v1H2.288v-1Zm16.448 0h1.003v1h-1.003v-1Zm-16.448 2h1.003v1H2.288v-1Zm16.448 0h1.003v1h-1.003v-1Zm-16.448 2h1.003v1H2.288v-1Zm16.448 0h1.003v1h-1.003v-1Zm-16.448 2h1.003v1H2.288v-1Zm16.448 0h1.003v1h-1.003v-1Zm-16.448 2h1.003l-.029 1h-.974v-1Zm16.448 0h1.003v1h-1.003v-1Zm-16.448 2h.974v1h-.974v-1Zm16.448 0h1.003v1h-1.003v-1Z"/><path d="M8.374 6.648a.399.399 0 0 1 .395-.4.402.402 0 0 1 .2.049l5.148 2.824a.4.4 0 0 1 0 .7l-5.148 2.824a.403.403 0 0 1-.595-.35V6.648Z"/></svg>',tooltip:!0})}}class MR extends Na{static get requires(){return[PR,OR,RR,Ey]}static get pluginName(){return"MediaEmbed"}}class LR extends Na{static get requires(){return[Sy]}static get pluginName(){return"MediaEmbedToolbar"}afterInit(){const e=this.editor,t=e.t;e.plugins.get(Sy).register("mediaEmbed",{ariaLabel:t("Media toolbar"),items:e.config.get("mediaEmbed.toolbar")||[],getRelatedElement:CR})}}const NR={"(":")","[":"]","{":"}"};class FR extends Da{refresh(){const e=this.editor.model,t=e.document;this.isEnabled=e.schema.checkAttributeInSelection(t.selection,"mention")}execute(e){const t=this.editor.model,i=t.document.selection,n="string"==typeof e.mention?{id:e.mention}:e.mention,s=n.id,o=e.range||i.getFirstRange();if(!t.canEditAt(o))return;const r=e.text||s,a=zR({_text:r,id:s},n);if(1!=e.marker.length)throw new p("mentioncommand-incorrect-marker",this);if(s.charAt(0)!=e.marker)throw new p("mentioncommand-incorrect-id",this);t.change((e=>{const n=Ca(i.getAttributes()),s=new Map(n.entries());s.set("mention",a);const l=t.insertContent(e.createText(r,s),o),c=l.start.nodeBefore,d=l.end.nodeAfter,h=d&&d.is("$text")&&d.data.startsWith(" ");let u=!1;if(c&&d&&c.is("$text")&&d.is("$text")){const e=c.data.slice(-1),t=e in NR,i=t&&d.data.startsWith(NR[e]);u=t&&i}u||h||t.insertContent(e.createText(" ",n),o.start.getShiftedBy(r.length))}))}constructor(e){super(e),this._isEnabledBasedOnSelection=!1}}class DR extends Na{static get pluginName(){return"MentionEditing"}init(){const e=this.editor,t=e.model,i=t.document;t.schema.extend("$text",{allowAttributes:"mention"}),e.conversion.for("upcast").elementToAttribute({view:{name:"span",key:"data-mention",classes:"mention"},model:{key:"mention",value:e=>HR(e)}}),e.conversion.for("downcast").attributeToElement({model:"mention",view:UR}),e.conversion.for("downcast").add($R),i.registerPostFixer((e=>function(e,t,i){const n=t.differ.getChanges();let s=!1;for(const t of n){if("attribute"==t.type)continue;const n=t.position;if("$text"==t.name){const t=n.textNode&&n.textNode.nextSibling;s=jR(n.textNode,e)||s,s=jR(t,e)||s,s=jR(n.nodeBefore,e)||s,s=jR(n.nodeAfter,e)||s}if("$text"!=t.name&&"insert"==t.type){const t=n.nodeAfter;for(const i of e.createRangeIn(t).getItems())s=jR(i,e)||s}if("insert"==t.type&&i.isInline(t.name)){const t=n.nodeAfter&&n.nodeAfter.nextSibling;s=jR(n.nodeBefore,e)||s,s=jR(t,e)||s}}return s}(e,i,t.schema))),i.registerPostFixer((e=>function(e,t){const i=t.differ.getChanges();let n=!1;for(const t of i)if("attribute"===t.type&&"mention"!=t.attributeKey){const i=t.range.start.nodeBefore,s=t.range.end.nodeAfter;for(const o of[i,s])WR(o)&&o.getAttribute(t.attributeKey)!=t.attributeNewValue&&(e.setAttribute(t.attributeKey,t.attributeNewValue,o),n=!0)}return n}(e,i))),i.registerPostFixer((e=>function(e,t){const i=t.selection,n=i.focus;if(i.isCollapsed&&i.hasAttribute("mention")&&function(e){const t=e.isAtStart;return e.nodeBefore&&e.nodeBefore.is("$text")||t}(n))return e.removeSelectionAttribute("mention"),!0;return!1}(e,i))),e.commands.add("mention",new FR(e))}}function zR(e,t){return Object.assign({uid:u()},e,t||{})}function HR(e,t){const i=e.getAttribute("data-mention"),n=e.getChild(0);if(!n)return;return zR({id:i,_text:n.data},t)}function $R(e){e.on("attribute:mention",((e,t,i)=>{const n=t.attributeNewValue;if(!t.item.is("$textProxy")||!n)return;const s=t.range.start;(s.textNode||s.nodeAfter).data!=n._text&&i.consumable.consume(t.item,e.name)}),{priority:"highest"})}function UR(e,{writer:t}){if(!e)return;const i={class:"mention","data-mention":e.id},n={id:e.uid,priority:20};return t.createAttributeElement("span",i,n)}function WR(e){if(!e||!e.is("$text")&&!e.is("$textProxy")||!e.hasAttribute("mention"))return!1;return e.data!=e.getAttribute("mention")._text}function jR(e,t){return!!WR(e)&&(t.removeAttribute("mention",e),!0)}class qR extends $f{selectFirst(){this.select(0)}selectNext(){const e=this.selected,t=this.items.getIndex(e);this.select(t+1)}selectPrevious(){const e=this.selected,t=this.items.getIndex(e);this.select(t-1)}select(e){let t=0;e>0&&e<this.items.length?t=e:e<0&&(t=this.items.length-1);const i=this.items.get(t);this.selected!==i&&(this.selected&&this.selected.removeHighlight(),i.highlight(),this.selected=i,this._isItemVisibleInScrolledArea(i)||(this.element.scrollTop=i.element.offsetTop))}executeSelected(){this.selected.fire("execute")}_isItemVisibleInScrolledArea(e){return new Ir(this.element).contains(new Ir(e.element))}constructor(e){super(e),this.extendTemplate({attributes:{class:["ck-mentions"],tabindex:"-1"}})}}class GR extends Tg{render(){super.render(),this.element=this.domElement}focus(){this.domElement.focus()}constructor(e,t){super(e),this.template=void 0,this.domElement=t,this.domElement.classList.add("ck-button"),this.set("isOn",!1),this.on("change:isOn",((e,t,i)=>{i?(this.domElement.classList.add("ck-on"),this.domElement.classList.remove("ck-off")):(this.domElement.classList.add("ck-off"),this.domElement.classList.remove("ck-on"))})),this.listenTo(this.domElement,"click",(()=>{this.fire("execute")}))}}class KR extends Df{highlight(){this.children.first.isOn=!0}removeHighlight(){this.children.first.isOn=!1}}const ZR=[ra.arrowup,ra.arrowdown,ra.esc],JR=[ra.enter,ra.tab];class QR extends Na{static get pluginName(){return"MentionUI"}static get requires(){return[Tb]}init(){const e=this.editor,t=e.config.get("mention.commitKeys")||JR,i=ZR.concat(t);this._balloon=e.plugins.get(Tb),e.editing.view.document.on("keydown",((e,n)=>{var s;s=n.keyCode,i.includes(s)&&this._isUIVisible&&(n.preventDefault(),e.stop(),n.keyCode==ra.arrowdown&&this._mentionsView.selectNext(),n.keyCode==ra.arrowup&&this._mentionsView.selectPrevious(),t.includes(n.keyCode)&&this._mentionsView.executeSelected(),n.keyCode==ra.esc&&this._hideUIAndRemoveMarker())}),{priority:"highest"}),Sg({emitter:this._mentionsView,activator:()=>this._isUIVisible,contextElements:()=>[this._balloon.view.element],callback:()=>this._hideUIAndRemoveMarker()});const n=e.config.get("mention.feeds");for(const e of n){const{feed:t,marker:i,dropdownLimit:n}=e;if(!iB(i))throw new p("mentionconfig-incorrect-marker",null,{marker:i});const s={marker:i,feedCallback:"function"==typeof t?t.bind(this.editor):tB(t),itemRenderer:e.itemRenderer,dropdownLimit:n};this._mentionsConfigurations.set(i,s)}this._setupTextWatcher(n),this.listenTo(e,"change:isReadOnly",(()=>{this._hideUIAndRemoveMarker()})),this.on("requestFeed:response",((e,t)=>this._handleFeedResponse(t))),this.on("requestFeed:error",(()=>this._hideUIAndRemoveMarker()))}destroy(){super.destroy(),this._mentionsView.destroy()}get _isUIVisible(){return this._balloon.visibleView===this._mentionsView}_createMentionView(){const e=this.editor.locale,t=new qR(e);return t.items.bindTo(this._items).using((i=>{const{item:n,marker:s}=i,{dropdownLimit:o}=this._mentionsConfigurations.get(s),r=o||this.editor.config.get("mention.dropdownLimit")||10;if(t.items.length>=r)return null;const a=new KR(e),l=this._renderItem(n,s);return l.delegate("execute").to(a),a.children.add(l),a.item=n,a.marker=s,a.on("execute",(()=>{t.fire("execute",{item:n,marker:s})})),a})),t.on("execute",((e,t)=>{const i=this.editor,n=i.model,s=t.item,o=t.marker,r=i.model.markers.get("mention"),a=n.createPositionAt(n.document.selection.focus),l=n.createPositionAt(r.getStart()),c=n.createRange(l,a);this._hideUIAndRemoveMarker(),i.execute("mention",{mention:s,text:s.text,marker:o,range:c}),i.editing.view.focus()})),t}_getItemRenderer(e){const{itemRenderer:t}=this._mentionsConfigurations.get(e);return t}_requestFeed(e,t){this._lastRequested=t;const{feedCallback:i}=this._mentionsConfigurations.get(e),n=i(t);n instanceof Promise?n.then((i=>{this._lastRequested==t?this.fire("requestFeed:response",{feed:i,marker:e,feedText:t}):this.fire("requestFeed:discarded",{feed:i,marker:e,feedText:t})})).catch((t=>{this.fire("requestFeed:error",{error:t}),b("mention-feed-callback-error",{marker:e})})):this.fire("requestFeed:response",{feed:n,marker:e,feedText:t})}_setupTextWatcher(e){const t=this.editor,i=e.map((e=>({...e,pattern:eB(e.marker,e.minimumCharacters||0)}))),n=new Mw(t.model,function(e){const t=t=>{const i=XR(e,t);if(!i)return!1;let n=0;0!==i.position&&(n=i.position-1);const s=t.substring(n);return i.pattern.test(s)};return t}(i));n.on("matched",((e,n)=>{const s=XR(i,n.text),o=t.model.document.selection.focus,r=t.model.createPositionAt(o.parent,s.position);if(function(e){const t=e.textNode&&e.textNode.hasAttribute("mention"),i=e.nodeBefore;return t||i&&i.is("$text")&&i.hasAttribute("mention")}(o)||function(e){const t=e.nodeAfter;return t&&t.is("$text")&&t.hasAttribute("mention")}(r))return void this._hideUIAndRemoveMarker();const a=function(e,t){let i=0;0!==e.position&&(i=e.position-1);const n=eB(e.marker,0),s=t.substring(i);return s.match(n)[2]}(s,n.text),l=s.marker.length+a.length,c=o.getShiftedBy(-l),d=o.getShiftedBy(-a.length),h=t.model.createRange(c,d);if(nB(t)){const e=t.model.markers.get("mention");t.model.change((t=>{t.updateMarker(e,{range:h})}))}else t.model.change((e=>{e.addMarker("mention",{range:h,usingOperation:!1,affectsData:!1})}));this._requestFeedDebounced(s.marker,a)})),n.on("unmatched",(()=>{this._hideUIAndRemoveMarker()}));const s=t.commands.get("mention");return n.bind("isEnabled").to(s),n}_handleFeedResponse(e){const{feed:t,marker:i}=e;if(!nB(this.editor))return;this._items.clear();for(const e of t){const t="object"!=typeof e?{id:e,text:e}:e;this._items.add({item:t,marker:i})}const n=this.editor.model.markers.get("mention");this._items.length?this._showOrUpdateUI(n):this._hideUIAndRemoveMarker()}_showOrUpdateUI(e){this._isUIVisible?this._balloon.updatePosition(this._getBalloonPanelPositionData(e,this._mentionsView.position)):this._balloon.add({view:this._mentionsView,position:this._getBalloonPanelPositionData(e,this._mentionsView.position),singleViewMode:!0}),this._mentionsView.position=this._balloon.view.position,this._mentionsView.selectFirst()}_hideUIAndRemoveMarker(){this._balloon.hasView(this._mentionsView)&&this._balloon.remove(this._mentionsView),nB(this.editor)&&this.editor.model.change((e=>e.removeMarker("mention"))),this._mentionsView.position=void 0}_renderItem(e,t){const i=this.editor;let n,s=e.id;const o=this._getItemRenderer(t);if(o){const t=o(e);"string"!=typeof t?n=new GR(i.locale,t):s=t}if(!n){const e=new Hg(i.locale);e.label=s,e.withText=!0,n=e}return n}_getBalloonPanelPositionData(e,t){const i=this.editor,n=i.editing,s=n.view.domConverter,o=n.mapper;return{target:()=>{let t=e.getRange();"$graveyard"==t.start.root.rootName&&(t=i.model.document.selection.getFirstRange());const n=o.toViewRange(t);return Ir.getDomRangeRects(s.viewRangeToDom(n)).pop()},limiter:()=>{const e=this.editor.editing.view,t=e.document.selection.editableElement;return t?e.domConverter.mapViewToDom(t.root):null},positions:YR(t,i.locale.uiLanguageDirection)}}constructor(e){super(e),this._items=new va,this._mentionsView=this._createMentionView(),this._mentionsConfigurations=new Map,this._requestFeedDebounced=ko(this._requestFeed,100),e.config.define("mention",{feeds:[]})}}function YR(e,t){const i={caret_se:e=>({top:e.bottom+3,left:e.right,name:"caret_se",config:{withArrow:!1}}),caret_ne:(e,t)=>({top:e.top-t.height-3,left:e.right,name:"caret_ne",config:{withArrow:!1}}),caret_sw:(e,t)=>({top:e.bottom+3,left:e.right-t.width,name:"caret_sw",config:{withArrow:!1}}),caret_nw:(e,t)=>({top:e.top-t.height-3,left:e.right-t.width,name:"caret_nw",config:{withArrow:!1}})};return Object.prototype.hasOwnProperty.call(i,e)?[i[e]]:"rtl"!==t?[i.caret_se,i.caret_sw,i.caret_ne,i.caret_nw]:[i.caret_sw,i.caret_se,i.caret_nw,i.caret_ne]}function XR(e,t){let i;for(const n of e){const e=t.lastIndexOf(n.marker);e>0&&!t.substring(e-1).match(n.pattern)||(!i||e>=i.position)&&(i={marker:n.marker,position:e,minimumCharacters:n.minimumCharacters,pattern:n.pattern})}return i}function eB(e,t){const n=0==t?"*":`{${t},}`,s=i.features.isRegExpUnicodePropertySupported?"\\p{Ps}\\p{Pi}\"'":"\\(\\[{\"'";return new RegExp(`(?:^|[ ${s}])([${e}])(.${n})$`,"u")}function tB(e){return t=>e.filter((e=>("string"==typeof e?e:String(e.id)).toLowerCase().includes(t.toLowerCase())))}function iB(e){return e&&1==e.length}function nB(e){return e.model.markers.has("mention")}class sB extends Na{toMentionAttribute(e,t){return HR(e,t)}static get pluginName(){return"Mention"}static get requires(){return[DR,QR]}}const oB=Lr("px");class rB extends Cb{render(){return super.render().then((()=>{this._prepareDocument()}))}setHeight(e){this.height=e}setTopOffset(e){this.top=e}_prepareDocument(){const e=this.element.contentWindow.document,t=e.adoptNode(this._options.domRootClone),i=this._options.useSimplePreview?"\n\t\t\t.ck.ck-editor__editable_inline img {\n\t\t\t\tfilter: contrast( 0 );\n\t\t\t}\n\n\t\t\tp, li, a, figcaption, span {\n\t\t\t\tbackground: hsl(0, 0%, 80%) !important;\n\t\t\t\tcolor: hsl(0, 0%, 80%) !important;\n\t\t\t}\n\n\t\t\th1, h2, h3, h4 {\n\t\t\t\tbackground: hsl(0, 0%, 60%) !important;\n\t\t\t\tcolor: hsl(0, 0%, 60%) !important;\n\t\t\t}\n\t\t":"",n=`<!DOCTYPE html><html lang="en">\n\t\t\t<head>\n\t\t\t\t<meta charset="utf-8">\n\t\t\t\t<meta name="viewport" content="width=device-width, initial-scale=1">\n\t\t\t\t${this._options.pageStyles.map((e=>"string"==typeof e?`<style>${e}</style>`:`<link rel="stylesheet" type="text/css" href="${e.href}">`)).join("\n")}\n\t\t\t\t<style>\n\t\t\t\t\thtml, body {\n\t\t\t\t\t\tmargin: 0 !important;\n\t\t\t\t\t\tpadding: 0 !important;\n\t\t\t\t\t}\n\n\t\t\t\t\thtml {\n\t\t\t\t\t\toverflow: hidden;\n\t\t\t\t\t}\n\n\t\t\t\t\tbody {\n\t\t\t\t\t\ttransform: scale( ${this._options.scaleRatio} );\n\t\t\t\t\t\ttransform-origin: 0 0;\n\t\t\t\t\t\toverflow: visible;\n\t\t\t\t\t}\n\n\t\t\t\t\t.ck.ck-editor__editable_inline {\n\t\t\t\t\t\tmargin: 0 !important;\n\t\t\t\t\t\tborder-color: transparent !important;\n\t\t\t\t\t\toutline-color: transparent !important;\n\t\t\t\t\t\tbox-shadow: none !important;\n\t\t\t\t\t}\n\n\t\t\t\t\t.ck.ck-content {\n\t\t\t\t\t\tbackground: white;\n\t\t\t\t\t}\n\n\t\t\t\t\t${i}\n\t\t\t\t</style>\n\t\t\t</head>\n\t\t\t<body class="${this._options.extraClasses||""}"></body>\n\t\t</html>`;e.open(),e.write(n),e.close(),e.body.appendChild(t)}constructor(e,t){super(e);const i=this.bindTemplate;this.set("top",0),this.set("height",0),this._options=t,this.extendTemplate({attributes:{tabindex:-1,class:["ck-minimap__iframe"],style:{top:i.to("top",(e=>oB(e))),height:i.to("height",(e=>oB(e)))}}})}}const aB=Lr("px");class lB extends Tg{render(){super.render(),this.listenTo(_r.document,"mousemove",((e,t)=>{this._isDragging&&this.fire("drag",t.movementY)}),{useCapture:!0}),this.listenTo(_r.document,"mouseup",(()=>{this._isDragging=!1}),{useCapture:!0})}setHeight(e){this.height=e}setTopOffset(e){this.top=e}setScrollProgress(e){this.scrollProgress=e}constructor(e){super(e);const t=this.bindTemplate;this.set("height",0),this.set("top",0),this.set("scrollProgress",0),this.set("_isDragging",!1),this.setTemplate({tag:"div",attributes:{class:["ck","ck-minimap__position-tracker",t.if("_isDragging","ck-minimap__position-tracker_dragging")],style:{top:t.to("top",(e=>aB(e))),height:t.to("height",(e=>aB(e)))},"data-progress":t.to("scrollProgress")},on:{mousedown:t.to((()=>{this._isDragging=!0}))}})}}class cB extends Tg{destroy(){this._minimapIframeView.destroy(),super.destroy()}get height(){return new Ir(this.element).height}get scrollHeight(){return Math.max(0,Math.min(this.height,this._minimapIframeView.height)-this._positionTrackerView.height)}render(){super.render(),this._minimapIframeView.render(),this.element.appendChild(this._minimapIframeView.element)}setContentHeight(e){this._minimapIframeView.setHeight(e*this._scaleRatio)}setScrollProgress(e){const t=this._minimapIframeView,i=this._positionTrackerView;if(t.height<this.height)t.setTopOffset(0),i.setTopOffset((t.height-i.height)*e);else{const n=t.height-this.height;t.setTopOffset(-n*e),i.setTopOffset((this.height-i.height)*e)}i.setScrollProgress(Math.round(100*e))}setPositionTrackerHeight(e){this._positionTrackerView.setHeight(e*this._scaleRatio)}_handleMinimapClick(e){const t=this._positionTrackerView;if(e.target===t.element)return;const i=new Ir(t.element),n=(e.clientY-i.top-i.height/2)/this._minimapIframeView.height;this.fire("click",n)}_handleMinimapMouseWheel(e){this.fire("drag",e.deltaY*this._scaleRatio)}constructor({locale:e,scaleRatio:t,pageStyles:i,extraClasses:n,useSimplePreview:s,domRootClone:o}){super(e);const r=this.bindTemplate;this._positionTrackerView=new lB(e),this._positionTrackerView.delegate("drag").to(this),this._scaleRatio=t,this._minimapIframeView=new rB(e,{useSimplePreview:s,pageStyles:i,extraClasses:n,scaleRatio:t,domRootClone:o}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-minimap"]},children:[this._positionTrackerView],on:{click:r.to(this._handleMinimapClick.bind(this)),wheel:r.to(this._handleMinimapMouseWheel.bind(this))}})}}function dB(e,t){const i=e.editing.view.document,n=i.getRoot(t),s=new yc(i),o=new dc(s,i.selection),r=e.editing.view.getDomRoot().cloneNode();return s.bindElements(r,n),o.markToSync("children",n),o.markToSync("attributes",n),n.on("change:children",((e,t)=>o.markToSync("children",t))),n.on("change:attributes",((e,t)=>o.markToSync("attributes",t))),n.on("change:text",((e,t)=>o.markToSync("text",t))),o.render(),e.editing.view.on("render",(()=>o.render())),e.on("destroy",(()=>{s.unbindDomElement(r)})),r}function hB(e){return new Ir(e===_r.document.body?_r.window:e)}function uB(e){return e===_r.document.body?_r.window:e}class mB extends Na{static get pluginName(){return"Minimap"}init(){const e=this.editor;this._minimapView=null,this._scrollableRootAncestor=null,this.listenTo(e.ui,"ready",this._onUiReady.bind(this))}destroy(){super.destroy(),this._minimapView.destroy(),this._minimapView.element.remove()}_onUiReady(){const e=this.editor,t=this._editingRootElement=e.ui.getEditableElement();this._scrollableRootAncestor=yr(t),t.ownerDocument.body.contains(t)?(this._initializeMinimapView(),this.listenTo(e.editing.view,"render",(()=>{"ready"===e.state&&this._syncMinimapToEditingRootScrollPosition()})),this._syncMinimapToEditingRootScrollPosition()):e.ui.once("update",this._onUiReady.bind(this))}_initializeMinimapView(){const e=this.editor,t=e.locale,i=e.config.get("minimap.useSimplePreview"),n=e.config.get("minimap.container"),s=this._scrollableRootAncestor,o=hB(this._editingRootElement).width,r=hB(n).width/o,a=this._minimapView=new cB({locale:t,scaleRatio:r,pageStyles:Array.from(_r.document.styleSheets).map((e=>e.href&&!e.href.startsWith(_r.window.location.origin)?{href:e.href}:Array.from(e.cssRules).filter((e=>!(e instanceof CSSMediaRule))).map((e=>e.cssText)).join(" \n"))),extraClasses:e.config.get("minimap.extraClasses"),useSimplePreview:i,domRootClone:dB(e)});a.render(),a.listenTo(_r.document,"scroll",((e,t)=>{if(s===_r.document.body){if(t.target!==_r.document)return}else if(t.target!==s)return;this._syncMinimapToEditingRootScrollPosition()}),{useCapture:!0,usePassive:!0}),a.listenTo(_r.window,"resize",(()=>{this._syncMinimapToEditingRootScrollPosition()})),a.on("drag",((e,t)=>{let i;i=0===a.scrollHeight?0:t/a.scrollHeight;const n=i*(s.scrollHeight-((o=s)===_r.document.body?_r.window.innerHeight:o.clientHeight));var o;uB(s).scrollBy(0,Math.round(n))})),a.on("click",((e,t)=>{const i=t*s.scrollHeight;uB(s).scrollBy(0,Math.round(i))})),n.appendChild(a.element)}_syncMinimapToEditingRootScrollPosition(){const e=this._editingRootElement,t=this._minimapView;t.setContentHeight(e.offsetHeight);const i=hB(e),n=hB(this._scrollableRootAncestor);let s;n.contains(i)||i.top>n.top?s=0:(s=(i.top-n.top)/(n.height-i.height),s=Math.max(0,Math.min(s,1))),t.setPositionTrackerHeight(n.getIntersection(i).height),t.setScrollProgress(s)}}class gB extends Da{refresh(){const e=this.editor.model,t=e.schema,i=e.document.selection;this.isEnabled=function(e,t,i){const n=function(e,t){const i=hy(e,t),n=i.start.parent;if(n.isEmpty&&!n.is("element","$root"))return n.parent;return n}(e,i);return t.checkChild(n,"pageBreak")}(i,t,e)}execute(){const e=this.editor.model;e.change((t=>{const i=t.createElement("pageBreak");e.insertObject(i,null,null,{setSelection:"after"})}))}}class fB extends Na{static get pluginName(){return"PageBreakEditing"}init(){const e=this.editor,t=e.model.schema,i=e.t,n=e.conversion;t.register("pageBreak",{inheritAllFrom:"$blockObject"}),n.for("dataDowncast").elementToStructure({model:"pageBreak",view:(e,{writer:t})=>t.createContainerElement("div",{class:"page-break",style:"page-break-after: always"},t.createContainerElement("span",{style:"display: none"}))}),n.for("editingDowncast").elementToStructure({model:"pageBreak",view:(e,{writer:t})=>{const n=i("Page break"),s=t.createContainerElement("div"),o=t.createRawElement("span",{class:"page-break__label"},(function(e){e.innerText=i("Page break")}));return t.addClass("page-break",s),t.insert(t.createPositionAt(s,0),o),function(e,t,i){return t.setCustomProperty("pageBreak",!0,e),sy(e,t,{label:i})}(s,t,n)}}),n.for("upcast").elementToElement({view:e=>{const t="always"==e.getStyle("page-break-before"),i="always"==e.getStyle("page-break-after");if(!t&&!i)return null;if(1==e.childCount){const t=e.getChild(0);if(!t.is("element","span")||"none"!=t.getStyle("display"))return null}else if(e.childCount>1)return null;return{name:!0}},model:"pageBreak",converterPriority:"high"}),e.commands.add("pageBreak",new gB(e))}}class pB extends Na{static get pluginName(){return"PageBreakUI"}init(){const e=this.editor;e.ui.componentFactory.add("pageBreak",(()=>{const e=this._createButton(Hg);return e.set({tooltip:!0}),e})),e.ui.componentFactory.add("menuBar:pageBreak",(()=>this._createButton(uw)))}_createButton(e){const t=this.editor,i=t.locale,n=t.commands.get("pageBreak"),s=new e(t.locale),o=i.t;return s.set({label:o("Page break"),icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M3.598.687h1.5v5h-1.5zm14.5 0h1.5v5h-1.5z"/><path d="M19.598 4.187v1.5h-16v-1.5zm-16 14.569h1.5v-5h-1.5zm14.5 0h1.5v-5h-1.5z"/><path d="M19.598 15.256v-1.5h-16v1.5zM5.081 9h6v2h-6zm8 0h6v2h-6zm-9.483 1L0 12.5v-5z"/></svg>'}),s.bind("isEnabled").to(n,"isEnabled"),this.listenTo(s,"execute",(()=>{t.execute("pageBreak"),t.editing.view.focus()})),s}}class bB extends Na{static get requires(){return[fB,pB,Ey]}static get pluginName(){return"PageBreak"}}function wB(e){return void 0!==e&&e.endsWith("px")}function vB(e){return e.toFixed(2).replace(/\.?0+$/,"")+"px"}function _B(e,t,i){if(!e.childCount)return;const n=new Hu(e.document),s=function(e,t){const i=t.createRangeIn(e),n=[],s=new Set;for(const e of i.getItems()){if(!e.is("element")||!e.name.match(/^(p|h\d+|li|div)$/))continue;let t=SB(e);if(void 0===t||0!=parseFloat(t)||Array.from(e.getClassNames()).find((e=>e.startsWith("MsoList")))||(t=void 0),e.hasStyle("mso-list")||void 0!==t&&s.has(t)){const i=EB(e);n.push({element:e,id:i.id,order:i.order,indent:i.indent,marginLeft:t}),void 0!==t&&s.add(t)}else s.clear()}return n}(e,n);if(!s.length)return;const o={},r=[];for(const e of s)if(void 0!==e.indent){yB(e)||(r.length=0);const s=`${e.id}:${e.indent}`,a=Math.min(e.indent-1,r.length);if(a<r.length&&r[a].id!==e.id&&(r.length=a),a<r.length-1)r.length=a+1;else{const l=CB(e,t);if(a>r.length-1||r[a].listElement.name!=l.type){0==a&&"ol"==l.type&&void 0!==e.id&&o[s]&&(l.startIndex=o[s]);const t=AB(l,n,i);if(wB(e.marginLeft)&&(0==a||wB(r[a-1].marginLeft))){let i=e.marginLeft;a>0&&(i=vB(parseFloat(i)-parseFloat(r[a-1].marginLeft))),n.setStyle("padding-left",i,t)}if(0==r.length){const i=e.element.parent,s=i.getChildIndex(e.element)+1;n.insertChild(s,t,i)}else{const e=r[a-1].listItemElements;n.appendChild(t,e[e.length-1])}r[a]={...e,listElement:t,listItemElements:[]},0==a&&void 0!==e.id&&(o[s]=l.startIndex||1)}}const l="li"==e.element.name?e.element:n.createElement("li");n.appendChild(l,r[a].listElement),r[a].listItemElements.push(l),0==a&&void 0!==e.id&&o[s]++,e.element!=l&&n.appendChild(e.element,l),TB(e.element,n),n.removeStyle("text-indent",e.element),n.removeStyle("margin-left",e.element)}else{const t=r.find((t=>t.marginLeft==e.marginLeft));if(t){const i=t.listItemElements;n.appendChild(e.element,i[i.length-1]),n.removeStyle("margin-left",e.element)}else r.length=0}}function yB(e){const t=e.element.previousSibling;return kB(t||e.element.parent)}function kB(e){return e.is("element","ol")||e.is("element","ul")}function CB(e,t){const i=new RegExp(`@list l${e.id}:level${e.indent}\\s*({[^}]*)`,"gi"),n=/mso-level-number-format:([^;]{0,100});/gi,s=/mso-level-start-at:\s{0,100}([0-9]{0,10})\s{0,100};/gi,o=new RegExp(`@list\\s+l${e.id}:level\\d\\s*{[^{]*mso-level-text:"%\\d\\\\.`,"gi"),r=new RegExp(`@list l${e.id}:level\\d\\s*{[^{]*mso-level-number-format:`,"gi"),a=o.exec(t),l=r.exec(t),c=a&&!l,d=i.exec(t);let h="decimal",u="ol",m=null;if(d&&d[1]){const t=n.exec(d[1]);if(t&&t[1]&&(h=t[1].trim(),u="bullet"!==h&&"image"!==h?"ol":"ul"),"bullet"===h){const t=function(e){if("li"==e.name&&"ul"==e.parent.name&&e.parent.hasAttribute("type"))return e.parent.getAttribute("type");const t=function(e){if(e.getChild(0).is("$text"))return null;for(const t of e.getChildren()){if(!t.is("element","span"))continue;const e=t.getChild(0);if(e)return e.is("$text")?e:e.getChild(0)}return null}(e);if(!t)return null;const i=t._data;if("o"===i)return"circle";if("·"===i)return"disc";if("§"===i)return"square";return null}(e.element);t&&(h=t)}else{const e=s.exec(d[1]);e&&e[1]&&(m=parseInt(e[1]))}c&&(u="ol")}return{type:u,startIndex:m,style:xB(h),isLegalStyleList:c}}function xB(e){if(e.startsWith("arabic-leading-zero"))return"decimal-leading-zero";switch(e){case"alpha-upper":return"upper-alpha";case"alpha-lower":return"lower-alpha";case"roman-upper":return"upper-roman";case"roman-lower":return"lower-roman";case"circle":case"disc":case"square":return e;default:return null}}function AB(e,t,i){const n=t.createElement(e.type);return e.style&&t.setStyle("list-style-type",e.style,n),e.startIndex&&e.startIndex>1&&t.setAttribute("start",e.startIndex,n),e.isLegalStyleList&&i&&t.addClass("legal-list",n),n}function EB(e){const t=e.getStyle("mso-list");if(void 0===t)return{};const i=t.match(/(^|\s{1,100})l(\d+)/i),n=t.match(/\s{0,100}lfo(\d+)/i),s=t.match(/\s{0,100}level(\d+)/i);return i&&n&&s?{id:i[2],order:n[1],indent:parseInt(s[1])}:{indent:1}}function TB(e,t){const i=new ol({name:"span",styles:{"mso-list":"Ignore"}}),n=t.createRangeIn(e);for(const e of n)"elementStart"===e.type&&i.match(e.item)&&t.remove(e.item)}function SB(e){const t=e.getStyle("margin-left");return void 0===t||t.endsWith("px")?t:function(e){const t=parseFloat(e);return e.endsWith("pt")?vB(96*t/72):e.endsWith("pc")?vB(12*t*96/72):e.endsWith("in")?vB(96*t):e.endsWith("cm")?vB(96*t/2.54):e.endsWith("mm")?vB(t/10*96/2.54):e}(t)}function IB(e,t){if(!e.childCount)return;const i=new Hu(e.document),n=function(e,t){const i=t.createRangeIn(e),n=new ol({name:/v:(.+)/}),s=[];for(const e of i){if("elementStart"!=e.type)continue;const t=e.item,i=t.previousSibling,o=i&&i.is("element")?i.name:null,r=["Chart"],a=n.match(t),l=t.getAttribute("o:gfxdata"),c="v:shapetype"===o,d=l&&r.some((e=>t.getAttribute("id").includes(e)));a&&l&&!c&&!d&&s.push(e.item.getAttribute("id"))}return s}(e,i);!function(e,t,i){const n=i.createRangeIn(t),s=new ol({name:"img"}),o=[];for(const t of n)if(t.item.is("element")&&s.match(t.item)){const i=t.item,n=i.getAttribute("v:shapes")?i.getAttribute("v:shapes").split(" "):[];n.length&&n.every((t=>e.indexOf(t)>-1))?o.push(i):i.getAttribute("src")||o.push(i)}for(const e of o)i.remove(e)}(n,e,i),function(e,t,i){const n=i.createRangeIn(t),s=[];for(const t of n)if("elementStart"==t.type&&t.item.is("element","v:shape")){const i=t.item.getAttribute("id");if(e.includes(i))continue;o(t.item.parent.getChildren(),i)||s.push(t.item)}for(const e of s){const t={src:r(e)};e.hasAttribute("alt")&&(t.alt=e.getAttribute("alt"));const n=i.createElement("img",t);i.insertChild(e.index+1,n,e.parent)}function o(e,t){for(const i of e)if(i.is("element")){if("img"==i.name&&i.getAttribute("v:shapes")==t)return!0;if(o(i.getChildren(),t))return!0}return!1}function r(e){for(const t of e.getChildren())if(t.is("element")&&t.getAttribute("src"))return t.getAttribute("src")}}(n,e,i),function(e,t){const i=t.createRangeIn(e),n=new ol({name:/v:(.+)/}),s=[];for(const e of i)"elementStart"==e.type&&n.match(e.item)&&s.push(e.item);for(const e of s)t.remove(e)}(e,i);const s=function(e,t){const i=t.createRangeIn(e),n=new ol({name:"img"}),s=[];for(const e of i)e.item.is("element")&&n.match(e.item)&&e.item.getAttribute("src").startsWith("file://")&&s.push(e.item);return s}(e,i);s.length&&function(e,t,i){if(e.length===t.length)for(let n=0;n<e.length;n++){const s=`data:${t[n].type};base64,${PB(t[n].hex)}`;i.setAttribute("src",s,e[n])}}(s,function(e){if(!e)return[];const t=/{\\pict[\s\S]+?\\bliptag-?\d+(\\blipupi-?\d+)?({\\\*\\blipuid\s?[\da-fA-F]+)?[\s}]*?/,i=new RegExp("(?:("+t.source+"))([\\da-fA-F\\s]+)\\}","g"),n=e.match(i),s=[];if(n)for(const e of n){let i=!1;e.includes("\\pngblip")?i="image/png":e.includes("\\jpegblip")&&(i="image/jpeg"),i&&s.push({hex:e.replace(t,"").replace(/[^\da-fA-F]/g,""),type:i})}return s}(t),i)}function PB(e){return btoa(e.match(/\w{2}/g).map((e=>String.fromCharCode(parseInt(e,16)))).join(""))}const VB=/<meta\s*name="?generator"?\s*content="?microsoft\s*word\s*\d+"?\/?>/i,RB=/xmlns:o="urn:schemas-microsoft-com/i;class BB{isActive(e){return VB.test(e)||RB.test(e)}execute(e){const{body:t,stylesString:i}=e._parsedData;_B(t,i,this.hasMultiLevelListPlugin),IB(t,e.dataTransfer.getData("text/rtf")),function(e){const t=[],i=new Hu(e.document);for(const{item:n}of i.createRangeIn(e))if(n.is("element")){for(const e of n.getClassNames())/\bmso/gi.exec(e)&&i.removeClass(e,n);for(const e of n.getStyleNames())/\bmso/gi.exec(e)&&i.removeStyle(e,n);(n.is("element","w:sdt")||n.is("element","w:sdtpr")&&n.isEmpty||n.is("element","o:p")&&n.isEmpty)&&t.push(n)}for(const e of t){const t=e.parent,n=t.getChildIndex(e);i.insertChild(n,e.getChildren(),t),i.remove(e)}}(t),e.content=t}constructor(e,t=!1){this.document=e,this.hasMultiLevelListPlugin=t}}function OB(e,t,i,{blockElements:n,inlineObjectElements:s}){let o=i.createPositionAt(e,"forward"==t?"after":"before");return o=o.getLastMatchingPosition((({item:e})=>e.is("element")&&!n.includes(e.name)&&!s.includes(e.name)),{direction:t}),"forward"==t?o.nodeAfter:o.nodeBefore}function MB(e,t){return!!e&&e.is("element")&&t.includes(e.name)}const LB=/id=("|')docs-internal-guid-[-0-9a-f]+("|')/i;class NB{isActive(e){return LB.test(e)}execute(e){const t=new Hu(this.document),{body:i}=e._parsedData;!function(e,t){for(const i of e.getChildren())if(i.is("element","b")&&"normal"===i.getStyle("font-weight")){const n=e.getChildIndex(i);t.remove(i),t.insertChild(n,i.getChildren(),e)}}(i,t),function(e,t){for(const i of t.createRangeIn(e)){const e=i.item;if(e.is("element","li")){const i=e.getChild(0);i&&i.is("element","p")&&t.unwrapElement(i)}}}(i,t),function(e,t){const i=new Rl(t.document.stylesProcessor),n=new yc(i,{renderingMode:"data"}),s=n.blockElements,o=n.inlineObjectElements,r=[];for(const i of t.createRangeIn(e)){const e=i.item;if(e.is("element","br")){const i=OB(e,"forward",t,{blockElements:s,inlineObjectElements:o}),n=OB(e,"backward",t,{blockElements:s,inlineObjectElements:o}),a=MB(i,s);(MB(n,s)||a)&&r.push(e)}}for(const e of r)e.hasClass("Apple-interchange-newline")?t.remove(e):t.replace(e,t.createElement("p"))}(i,t),e.content=i}constructor(e){this.document=e}}const FB=/<google-sheets-html-origin/i;class DB{isActive(e){return FB.test(e)}execute(e){const t=new Hu(this.document),{body:i}=e._parsedData;!function(e,t){for(const i of e.getChildren())if(i.is("element","google-sheets-html-origin")){const n=e.getChildIndex(i);t.remove(i),t.insertChild(n,i.getChildren(),e)}}(i,t),function(e,t){for(const i of e.getChildren())i.is("element","table")&&i.hasAttribute("xmlns")&&t.removeAttribute("xmlns",i)}(i,t),function(e,t){for(const i of e.getChildren())i.is("element","table")&&"0px"===i.getStyle("width")&&t.removeStyle("width",i)}(i,t),function(e,t){for(const i of Array.from(e.getChildren()))i.is("element","style")&&t.remove(i)}(i,t),e.content=i}constructor(e){this.document=e}}function zB(e){return e.replace(/<span(?: class="Apple-converted-space"|)>(\s+)<\/span>/g,((e,t)=>1===t.length?" ":Array(t.length+1).join("  ").substr(0,t.length)))}function HB(e,t){const i=new DOMParser,n=function(e){return zB(zB(e)).replace(/(<span\s+style=['"]mso-spacerun:yes['"]>[^\S\r\n]*?)[\r\n]+([^\S\r\n]*<\/span>)/g,"$1$2").replace(/<span\s+style=['"]mso-spacerun:yes['"]><\/span>/g,"").replace(/(<span\s+style=['"]letter-spacing:[^'"]+?['"]>)[\r\n]+(<\/span>)/g,"$1 $2").replace(/ <\//g," </").replace(/ <o:p><\/o:p>/g," <o:p></o:p>").replace(/<o:p>(&nbsp;|\u00A0)<\/o:p>/g,"").replace(/>([^\S\r\n]*[\r\n]\s*)</g,"><")}(function(e){const t="</body>",i="</html>",n=e.indexOf(t);if(n<0)return e;const s=e.indexOf(i,n+t.length);return e.substring(0,n+t.length)+(s>=0?e.substring(s):"")}(e=(e=e.replace(/<!--\[if gte vml 1]>/g,"")).replace(/<o:SmartTagType(?:\s+[^\s>=]+(?:="[^"]*")?)*\s*\/?>/gi,""))),s=i.parseFromString(n,"text/html");!function(e){e.querySelectorAll("span[style*=spacerun]").forEach((e=>{const t=e,i=t.innerText.length||0;t.innerText=Array(i+1).join("  ").substr(0,i)}))}(s);const o=s.body.innerHTML,r=function(e,t){const i=new Rl(t),n=new yc(i,{renderingMode:"data"}),s=e.createDocumentFragment(),o=e.body.childNodes;for(;o.length>0;)s.appendChild(o[0]);return n.domToView(s,{skipComments:!0})}(s,t),a=function(e){const t=[],i=[],n=Array.from(e.getElementsByTagName("style"));for(const e of n)e.sheet&&e.sheet.cssRules&&e.sheet.cssRules.length&&(t.push(e.sheet),i.push(e.innerHTML));return{styles:t,stylesString:i.join(" ")}}(s);return{body:r,bodyString:o,styles:a.styles,stylesString:a.stylesString}}class $B extends Na{static get pluginName(){return"PasteFromOffice"}static get requires(){return[Z_]}init(){const e=this.editor,t=e.plugins.get("ClipboardPipeline"),i=e.editing.view.document,n=[],s=this.editor.plugins.has("MultiLevelList");n.push(new BB(i,s)),n.push(new NB(i)),n.push(new DB(i)),t.on("inputTransformation",((t,s)=>{if(s._isTransformedWithPasteFromOffice)return;if(e.model.document.selection.getFirstPosition().parent.is("element","codeBlock"))return;const o=s.dataTransfer.getData("text/html"),r=n.find((e=>e.isActive(o)));r&&(s._parsedData||(s._parsedData=HB(o,i.stylesProcessor)),r.execute(s),s._isTransformedWithPasteFromOffice=!0)}),{priority:"high"})}}const UB="removeFormat";class WB extends Na{static get pluginName(){return"RemoveFormatUI"}init(){const e=this.editor;e.ui.componentFactory.add(UB,(()=>{const e=this._createButton(Hg);return e.set({tooltip:!0}),e})),e.ui.componentFactory.add(`menuBar:${UB}`,(()=>this._createButton(uw)))}_createButton(e){const t=this.editor,i=t.locale,n=t.commands.get(UB),s=new e(t.locale),o=i.t;return s.set({label:o("Remove Format"),icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M8.69 14.915c.053.052.173.083.36.093a.366.366 0 0 1 .345.485l-.003.01a.738.738 0 0 1-.697.497h-2.67a.374.374 0 0 1-.353-.496l.013-.038a.681.681 0 0 1 .644-.458c.197-.012.325-.043.386-.093a.28.28 0 0 0 .072-.11L9.592 4.5H6.269c-.359-.017-.609.013-.75.09-.142.078-.289.265-.442.563-.192.29-.516.464-.864.464H4.17a.43.43 0 0 1-.407-.569L4.46 3h13.08l-.62 2.043a.81.81 0 0 1-.775.574h-.114a.486.486 0 0 1-.486-.486c.001-.284-.054-.464-.167-.54-.112-.076-.367-.106-.766-.091h-3.28l-2.68 10.257c-.006.074.007.127.038.158zM3 17h8a.5.5 0 1 1 0 1H3a.5.5 0 1 1 0-1zm11.299 1.17a.75.75 0 1 1-1.06-1.06l1.414-1.415-1.415-1.414a.75.75 0 0 1 1.06-1.06l1.415 1.414 1.414-1.415a.75.75 0 1 1 1.06 1.06l-1.413 1.415 1.414 1.415a.75.75 0 0 1-1.06 1.06l-1.415-1.414-1.414 1.414z"/></svg>'}),s.bind("isEnabled").to(n,"isEnabled"),this.listenTo(s,"execute",(()=>{t.execute(UB),t.editing.view.focus()})),s}}class jB extends Da{refresh(){const e=this.editor.model;this.isEnabled=!!_a(this._getFormattingItems(e.document.selection,e.schema))}execute(){const e=this.editor.model,t=e.schema;e.change((i=>{for(const n of this._getFormattingItems(e.document.selection,t))if(n.is("selection"))for(const e of this._getFormattingAttributes(n,t))i.removeSelectionAttribute(e);else{const e=i.createRangeOn(n);for(const s of this._getFormattingAttributes(n,t))i.removeAttribute(s,e)}}))}*_getFormattingItems(e,t){const i=e=>!!_a(this._getFormattingAttributes(e,t));for(const n of e.getRanges())for(const e of n.getItems())!t.isBlock(e)&&i(e)&&(yield e);for(const t of e.getSelectedBlocks())i(t)&&(yield t);i(e)&&(yield e)}*_getFormattingAttributes(e,t){for(const[i]of e.getAttributes()){const e=t.getAttributeProperties(i);e&&e.isFormatting&&(yield i)}}}class qB extends Na{static get pluginName(){return"RemoveFormatEditing"}init(){const e=this.editor;e.commands.add("removeFormat",new jB(e))}}class GB extends Na{static get requires(){return[qB,WB]}static get pluginName(){return"RemoveFormat"}}class KB extends Da{refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=ZB(this.editor.model,this._direction);e&&this.editor.model.change((t=>{t.setSelection(e)}))}_checkEnabled(){return!!ZB(this.editor.model,this._direction)}constructor(e,t){super(e),this.affectsData=!1,this._direction=t}}function ZB(e,t){const i=e.document.selection.getFirstPosition(),n=[];for(const s of e.markers.getMarkersGroup("restrictedEditingException")){const e=s.getRange(),o=i.isTouching(e.start)&&i.hasSameParentAs(e.start)||i.isTouching(e.end)&&i.hasSameParentAs(e.end);e.containsPosition(i)||o||("forward"===t&&e.start.isAfter(i)||"backward"===t&&e.end.isBefore(i))&&n.push(e)}if(n.length)return n.sort(((e,i)=>"forward"===t?e.start.isAfter(i.start)?1:-1:e.start.isBefore(i.start)?1:-1)).shift()}function JB(e,t){for(const i of e.model.markers){if(QB(i.getRange(),t)&&i.name.startsWith("restrictedEditingException:"))return i}}function QB(e,t){return e.containsPosition(t)||e.end.isEqual(t)||e.start.isEqual(t)}const YB="restricted-editing-exception_selected";function XB(e,t,i,n){const s=JB(e,t.getShiftedBy(i));return!(!s||!s.getStart().isEqual(t.getShiftedBy(i)))&&(n.updateMarker(s,{range:n.createRange(s.getStart().getShiftedBy(-i),s.getEnd())}),!0)}function eO(e,t,i,n){const s=JB(e,t);return!(!s||!s.getEnd().isEqual(t))&&(n.updateMarker(s,{range:n.createRange(s.getStart(),s.getEnd().getShiftedBy(i))}),!0)}const tO="RestrictedEditingMode";class iO extends Na{static get pluginName(){return"RestrictedEditingModeEditing"}init(){const e=this.editor,t=e.editing.view;e.config.get("restrictedEditing.allowedCommands").forEach((e=>this._allowedInException.add(e))),this._setupConversion(),this._setupCommandsToggling(),this._setupRestrictions(),e.commands.add("goToPreviousRestrictedEditingException",new KB(e,"backward")),e.commands.add("goToNextRestrictedEditingException",new KB(e,"forward")),e.keystrokes.set("Tab",nO(e,"goToNextRestrictedEditingException")),e.keystrokes.set("Shift+Tab",nO(e,"goToPreviousRestrictedEditingException")),e.keystrokes.set("Ctrl+A",function(e){return(t,i)=>{const n=e.model,s=e.model.document.selection,o=JB(e,s.focus);if(!o)return;const r=s.getFirstRange();(o.getRange().containsRange(r,!0)||s.isCollapsed)&&(i(),n.change((e=>{e.setSelection(o.getRange())})))}}(e)),t.change((e=>{for(const i of t.document.roots)e.addClass("ck-restricted-editing_mode_restricted",i)}))}enableCommand(e){this.editor.commands.get(e).clearForceDisabled(tO),this._alwaysEnabled.add(e)}_setupConversion(){const e=this.editor,t=e.model.document;let i=0;var n;e.conversion.for("upcast").add((n={view:{name:"span",classes:"restricted-editing-exception"},model:()=>(i++,`restrictedEditingException:${i}`)},e=>e.on("element:span",((e,t,i)=>{const{writer:s}=i,o=new ol(n.view).match(t.viewItem);if(!o)return;const r=o.match;r.name=!0;const{modelRange:a}=i.convertChildren(t.viewItem,t.modelCursor);i.consumable.consume(t.viewItem,r);const l=n.model(),c=s.createElement("$marker",{"data-name":l}),d=s.createElement("$marker",{"data-name":l});s.insert(d,a.end),s.insert(c,a.start),t.modelRange=s.createRange(s.createPositionBefore(c),s.createPositionAfter(d)),t.modelCursor=t.modelRange.end})))),e.conversion.for("downcast").markerToHighlight({model:"restrictedEditingException",view:()=>({name:"span",classes:"restricted-editing-exception",priority:-10})}),e.conversion.for("editingDowncast").markerToElement({model:"restrictedEditingException",view:(e,{writer:t})=>t.createUIElement("span",{class:"restricted-editing-exception restricted-editing-exception_collapsed"})}),e.conversion.for("dataDowncast").markerToElement({model:"restrictedEditingException",view:(e,{writer:t})=>t.createEmptyElement("span",{class:"restricted-editing-exception"})}),t.registerPostFixer(function(e){return t=>{let i=!1;const n=e.model.schema;for(const s of e.model.document.differ.getChanges())"insert"==s.type&&n.checkChild("$block",s.name)&&(i=XB(e,s.position,s.length,t)||i,i=eO(e,s.position,s.length,t)||i);return i}}(e)),t.registerPostFixer(function(e){return t=>{let i=!1;for(const{name:n,data:s}of e.model.document.differ.getChangedMarkers())n.startsWith("restrictedEditingException")&&s.newRange&&"$graveyard"==s.newRange.root.rootName&&(t.updateMarker(n,{range:t.createRange(t.createPositionAt(s.oldRange.start))}),i=!0);return i}}(e)),t.registerPostFixer(function(e){return t=>{let i=!1;const n=e.model.document.differ.getChangedMarkers();for(const{data:e,name:s}of n){if(!s.startsWith("restrictedEditingException"))continue;const n=e.newRange;if(!e.oldRange&&!n.isFlat){const e=n.start,o=n.end,r=e.path.length>o.path.length,a=r?n.start:t.createPositionAt(o.parent,0),l=r?t.createPositionAt(e.parent,"end"):n.end;t.updateMarker(s,{range:t.createRange(a,l)}),i=!0}}return i}}(e)),function(e){const t=e.editing.view,i=e.model,n=new Set;t.document.registerPostFixer((t=>{const s=i.document.selection,o=JB(e,s.anchor);if(!o)return!1;for(const i of e.editing.mapper.markerNameToElements(o.name))t.addClass(YB,i),n.add(i);return!1})),e.conversion.for("editingDowncast").add((e=>{function i(){t.change((e=>{for(const t of n.values())e.removeClass(YB,t),n.delete(t)}))}e.on("insert",i,{priority:"highest"}),e.on("remove",i,{priority:"highest"}),e.on("attribute",i,{priority:"highest"}),e.on("cleanSelection",i)}))}(e)}_setupRestrictions(){const e=this.editor,t=e.model,i=t.document.selection,n=e.editing.view.document,s=e.plugins.get("ClipboardPipeline");this.listenTo(t,"deleteContent",function(e){return(t,i)=>{const[n]=i,s=JB(e,n.focus)||JB(e,n.anchor);if(!s)return void t.stop();if(n.isCollapsed)return;const o=s.getRange().getIntersection(n.getFirstRange());n.is("documentSelection")?e.model.change((e=>{e.setSelection(o)})):n.setTo(o)}}(e),{priority:"high"});const o=e.commands.get("insertText");o&&this.listenTo(o,"execute",function(e){return(t,i)=>{const[n]=i,{range:s}=n;s&&(oO(e,s)||t.stop())}}(e),{priority:"high"}),this.listenTo(s,"contentInsertion",(t=>{oO(e,i.getFirstRange())||t.stop()})),this.listenTo(n,"clipboardOutput",((t,n)=>{"cut"!=n.method||oO(e,i.getFirstRange())||t.stop()}),{priority:"high"});const r=e.config.get("restrictedEditing.allowedAttributes");t.schema.addAttributeCheck(function(e){return(t,i)=>{if(t.startsWith("$clipboardHolder"))return e.includes(i)}}(r)),t.schema.addChildCheck(((e,t)=>{if(e.startsWith("$clipboardHolder"))return"$text"===t.name}))}_setupCommandsToggling(){const e=this.editor.model.document;this._disableCommands(),this.listenTo(e.selection,"change",this._checkCommands.bind(this)),this.listenTo(e,"change:data",this._checkCommands.bind(this))}_checkCommands(){const e=this.editor,t=e.model.document.selection;if(t.rangeCount>1)return void this._disableCommands();const i=JB(e,t.focus);this._disableCommands(),function(e,t){if(!t)return!1;const i=t.getRange();return e.isCollapsed?QB(i,e.focus):i.containsRange(e.getFirstRange(),!0)}(t,i)&&this._enableCommands(i)}_enableCommands(e){const t=this.editor;for(const[i,n]of t.commands)n.affectsData&&!this._alwaysEnabled.has(i)&&this._allowedInException.has(i)&&(sO(i,t.model.document.selection,e.getRange())||n.clearForceDisabled(tO))}_disableCommands(){const e=this.editor;for(const[t,i]of e.commands)i.affectsData&&!this._alwaysEnabled.has(t)&&i.forceDisabled(tO)}constructor(e){super(e),e.config.define("restrictedEditing",{allowedCommands:["bold","italic","link","unlink"],allowedAttributes:["bold","italic","linkHref"]}),this._alwaysEnabled=new Set(["undo","redo"]),this._allowedInException=new Set(["input","insertText","delete","deleteForward"])}}function nO(e,t){return(i,n)=>{e.commands.get(t).isEnabled&&(e.execute(t),n())}}function sO(e,t,i){return!("delete"!=e||!i.start.isEqual(t.focus))||!("deleteForward"!=e||!t.isCollapsed||!i.end.isEqual(t.focus))}function oO(e,t){const i=JB(e,t.start),n=JB(e,t.end);return i&&n&&n===i}var rO='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M15.5 6.5a3.5 3.5 0 0 1 3.495 3.308L19 10v2a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1h-7a1 1 0 0 1-1-1v-5a1 1 0 0 1 1-1v-2l.005-.192A3.5 3.5 0 0 1 15.5 6.5zm0 7.5a.5.5 0 0 0-.492.41L15 14.5v2a.5.5 0 0 0 .992.09L16 16.5v-2a.5.5 0 0 0-.5-.5zm0-6a2 2 0 0 0-2 2v2h4v-2a2 2 0 0 0-2-2zm-9.25 8a.75.75 0 1 1 0 1.5H.75a.75.75 0 1 1 0-1.5h5.5zm0-5a.75.75 0 1 1 0 1.5H.75a.75.75 0 1 1 0-1.5h5.5zm3-5a.75.75 0 0 1 0 1.5H.75a.75.75 0 0 1 0-1.5h8.5zm6-5a.75.75 0 1 1 0 1.5H.75a.75.75 0 0 1 0-1.5h14.5z"/></svg>';class aO extends Na{static get pluginName(){return"RestrictedEditingModeUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add("restrictedEditing",(i=>{const n=Wf(i),s=new va;return this._getButtonDefinitions().forEach((({commandName:e,label:t,keystroke:i})=>{s.add(this._getButtonDefinition(e,t,i))})),Gf(n,s),n.buttonView.set({label:t("Navigate editable regions"),icon:rO,tooltip:!0,isEnabled:!0,isOn:!1}),this.listenTo(n,"execute",(t=>{const{_commandName:i}=t.source;e.execute(i),e.editing.view.focus()})),n})),e.ui.componentFactory.add("menuBar:restrictedEditing",(e=>{const i=new dw(e),n=new hw(e);return n.set({ariaLabel:t("Navigate editable regions"),role:"menu"}),i.buttonView.set({label:t("Navigate editable regions"),icon:rO}),i.panelView.children.add(n),this._getButtonDefinitions().forEach((({commandName:t,label:s,keystroke:o})=>{const r=new qb(e,i),a=this._createMenuBarButton(s,t,o);a.delegate("execute").to(i),r.children.add(a),n.items.add(r)})),i}))}_createMenuBarButton(e,t,i){const n=this.editor,s=n.commands.get(t),o=new uw(n.locale);return o.set({label:e,keystroke:i,isEnabled:!0,isOn:!1}),o.bind("isEnabled").to(s),this.listenTo(o,"execute",(()=>{n.execute(t),n.editing.view.focus()})),o}_getButtonDefinition(e,t,i){const n=this.editor.commands.get(e),s={type:"button",model:new Ab({label:t,withText:!0,keystroke:i,withKeystroke:!0,_commandName:e})};return s.model.bind("isEnabled").to(n,"isEnabled"),s}_getButtonDefinitions(){const e=this.editor.locale.t;return[{commandName:"goToPreviousRestrictedEditingException",label:e("Previous editable region"),keystroke:"Shift+Tab"},{commandName:"goToNextRestrictedEditingException",label:e("Next editable region"),keystroke:"Tab"}]}}class lO extends Na{static get pluginName(){return"RestrictedEditingMode"}static get requires(){return[iO,aO]}}class cO extends Da{refresh(){const e=this.editor.model,t=e.document;this.value=!!t.selection.getAttribute("restrictedEditingException"),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,"restrictedEditingException")}execute(e={}){const t=this.editor.model,i=t.document.selection,n=void 0===e.forceValue?!this.value:e.forceValue;t.change((e=>{const s=t.schema.getValidRanges(i.getRanges(),"restrictedEditingException");if(i.isCollapsed)if(n)e.setSelectionAttribute("restrictedEditingException",n);else{const t=e=>e.item.getAttribute("restrictedEditingException")===this.value,n=i.focus,s=n.getLastMatchingPosition(t,{direction:"backward"}),o=n.getLastMatchingPosition(t);e.removeSelectionAttribute("restrictedEditingException"),n.isEqual(s)||n.isEqual(o)||e.removeAttribute("restrictedEditingException",e.createRange(s,o))}else for(const t of s)n?e.setAttribute("restrictedEditingException",n,t):e.removeAttribute("restrictedEditingException",t)}))}}class dO extends Na{static get pluginName(){return"StandardEditingModeEditing"}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:["restrictedEditingException"]}),e.conversion.for("upcast").elementToAttribute({model:"restrictedEditingException",view:{name:"span",classes:"restricted-editing-exception"}}),e.conversion.for("downcast").attributeToElement({model:"restrictedEditingException",view:(e,{writer:t})=>{if(e)return t.createAttributeElement("span",{class:"restricted-editing-exception"},{priority:-10})}}),e.commands.add("restrictedEditingException",new cO(e)),e.editing.view.change((t=>{for(const i of e.editing.view.document.roots)t.addClass("ck-restricted-editing_mode_standard",i)}))}}class hO extends Na{static get pluginName(){return"StandardEditingModeUI"}init(){const e=this.editor;e.ui.componentFactory.add("restrictedEditingException",(()=>{const e=this._createButton(Hg);return e.set({tooltip:!0,isToggleable:!0}),e})),e.ui.componentFactory.add("menuBar:restrictedEditingException",(()=>this._createButton(uw)))}_createButton(e){const t=this.editor,i=t.locale,n=this.editor.commands.get("restrictedEditingException"),s=new e(i),o=i.t;return s.icon='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M6.25 16a.75.75 0 1 1 0 1.5H.75a.75.75 0 1 1 0-1.5h5.5zm0-5a.75.75 0 1 1 0 1.5H.75a.75.75 0 1 1 0-1.5h5.5zm3-5a.75.75 0 0 1 0 1.5H.75a.75.75 0 0 1 0-1.5h8.5zm6-5a.75.75 0 1 1 0 1.5H.75a.75.75 0 0 1 0-1.5h14.5zm.25 5.5a3.5 3.5 0 0 1 3.143 1.959.75.75 0 0 1-1.36.636A2 2 0 0 0 13.5 10v2H19a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1h-7a1 1 0 0 1-1-1v-5a1 1 0 0 1 1-1v-2l.005-.192A3.5 3.5 0 0 1 15.5 6.5zm0 7.5a.5.5 0 0 0-.492.41L15 14.5v2a.5.5 0 0 0 .992.09L16 16.5v-2a.5.5 0 0 0-.5-.5z"/></svg>',s.bind("isOn","isEnabled").to(n,"value","isEnabled"),s.bind("label").to(n,"value",(e=>o(e?"Disable editing":"Enable editing"))),this.listenTo(s,"execute",(()=>{t.execute("restrictedEditingException"),t.editing.view.focus()})),s}}class uO extends Na{static get pluginName(){return"StandardEditingMode"}static get requires(){return[dO,hO]}}class mO extends Da{execute(){const e="ck-show-blocks",t=this.editor.editing.view;t.change((i=>{for(const n of t.document.roots)n.hasClass(e)?(i.removeClass(e,n),this.value=!1):(i.addClass(e,n),this.value=!0)}))}constructor(e){super(e),this.affectsData=!1,this.value=!1}}class gO extends Na{static get pluginName(){return"ShowBlocksEditing"}init(){const{editor:e}=this;e.commands.add("showBlocks",new mO(e))}}class fO extends Na{static get pluginName(){return"ShowBlocksUI"}init(){const e=this.editor;e.ui.componentFactory.add("showBlocks",(()=>{const e=this._createButton(Hg);return e.set({tooltip:!0,icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m6.395 9.196 2.545-.007V6.498a.598.598 0 0 1 .598-.598h.299a.598.598 0 0 1 .598.598v6.877a.598.598 0 0 1-.598.598h-.299a.598.598 0 0 1-.598-.598v-2.691l-2.545.007v2.691a.598.598 0 0 1-.598.598h-.299a.598.598 0 0 1-.598-.598V6.505a.598.598 0 0 1 .598-.598h.299a.598.598 0 0 1 .598.598v2.691Z"/><path d="M15.094 13.417V6.462a.562.562 0 0 0-.562-.562h-.782a1 1 0 0 0-.39.08l-1.017.43a.562.562 0 0 0-.343.517v.197c0 .4.406.67.775.519l.819-.337v6.111c0 .31.251.562.561.562h.377c.31 0 .562-.251.562-.562Z"/><path d="M0 15.417v1.5h1.5v-1.5H0Z"/><path d="M18.5 15.417v1.5H20v-1.5h-1.5Z"/><path d="M18.5 12.333v1.5H20v-1.5h-1.5Z"/><path d="M18.5 9.25v1.5H20v-1.5h-1.5Z"/><path d="M18.5 6.167v1.5H20v-1.5h-1.5Z"/><path d="M0 18.5v.5a1 1 0 0 0 1 1h.5v-1.5H0Z"/><path d="M3.083 18.5V20h1.5v-1.5h-1.5Z"/><path d="M6.167 18.5V20h1.5v-1.5h-1.5Z"/><path d="M9.25 18.5V20h1.5v-1.5h-1.5Z"/><path d="M12.333 18.5V20h1.5v-1.5h-1.5Z"/><path d="M15.417 18.5V20h1.5v-1.5h-1.5Z"/><path d="M18.5 18.5V20h.5a1 1 0 0 0 1-1v-.5h-1.5Z"/><path clip-rule="evenodd" d="M0 1a1 1 0 0 1 1-1h18a1 1 0 0 1 1 1v3.583h-1.5V1.5h-17v12.333H0V1Z"/></svg>'}),e})),e.ui.componentFactory.add("menuBar:showBlocks",(()=>this._createButton(uw)))}_createButton(e){const t=this.editor,i=t.locale,n=t.commands.get("showBlocks"),s=new e(i),o=i.t;return s.set({label:o("Show blocks")}),s.bind("isEnabled").to(n),s.bind("isOn").to(n,"value",n,"isEnabled",((e,t)=>e&&t)),this.listenTo(s,"execute",(()=>{t.execute("showBlocks"),t.editing.view.focus()})),s}}class pO extends Na{static get pluginName(){return"ShowBlocks"}static get requires(){return[gO,fO]}}function bO(e){const t=[{name:"address",isVoid:!1},{name:"article",isVoid:!1},{name:"aside",isVoid:!1},{name:"blockquote",isVoid:!1},{name:"details",isVoid:!1},{name:"dialog",isVoid:!1},{name:"dd",isVoid:!1},{name:"div",isVoid:!1},{name:"dl",isVoid:!1},{name:"dt",isVoid:!1},{name:"fieldset",isVoid:!1},{name:"figcaption",isVoid:!1},{name:"figure",isVoid:!1},{name:"footer",isVoid:!1},{name:"form",isVoid:!1},{name:"h1",isVoid:!1},{name:"h2",isVoid:!1},{name:"h3",isVoid:!1},{name:"h4",isVoid:!1},{name:"h5",isVoid:!1},{name:"h6",isVoid:!1},{name:"header",isVoid:!1},{name:"hgroup",isVoid:!1},{name:"hr",isVoid:!0},{name:"li",isVoid:!1},{name:"main",isVoid:!1},{name:"nav",isVoid:!1},{name:"ol",isVoid:!1},{name:"p",isVoid:!1},{name:"section",isVoid:!1},{name:"table",isVoid:!1},{name:"tbody",isVoid:!1},{name:"td",isVoid:!1},{name:"th",isVoid:!1},{name:"thead",isVoid:!1},{name:"tr",isVoid:!1},{name:"ul",isVoid:!1}],i=t.map((e=>e.name)).join("|"),n=e.replace(new RegExp(`</?(${i})( .*?)?>`,"g"),"\n$&\n").replace(/<br[^>]*>/g,"$&\n").split("\n");let s=0,o=!1;return n.filter((e=>e.length)).map((e=>(o=function(e,t){return new RegExp("<pre( .*?)?>").test(e)?"first":new RegExp("</pre>").test(e)?"last":("first"===t||"middle"===t)&&"middle"}(e,o),function(e,t){return t.some((t=>!t.isVoid&&!!new RegExp(`<${t.name}( .*?)?>`).test(e)))}(e,t)?wO(e,s++):function(e,t){return t.some((t=>new RegExp(`</${t.name}>`).test(e)))}(e,t)?wO(e,--s):"middle"===o||"last"===o?e:wO(e,s)))).join("\n")}function wO(e,t,i=" "){return`${i.repeat(Math.max(0,t))}${e}`}const vO="SourceEditingMode";class _O extends Na{static get pluginName(){return"SourceEditing"}static get requires(){return[Fm]}init(){this._checkCompatibility();const e=this.editor,t=e.locale.t;e.ui.componentFactory.add("sourceEditing",(()=>{const e=this._createButton(Hg);return e.set({label:t("Source"),icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m12.5 0 5 4.5v15.003h-16V0h11zM3 1.5v3.25l-1.497 1-.003 8 1.5 1v3.254L7.685 18l-.001 1.504H17.5V8.002L16 9.428l-.004-4.22-4.222-3.692L3 1.5z"/><path d="M4.06 6.64a.75.75 0 0 1 .958 1.15l-.085.07L2.29 9.75l2.646 1.89c.302.216.4.62.232.951l-.058.095a.75.75 0 0 1-.951.232l-.095-.058-3.5-2.5V9.14l3.496-2.5zm4.194 6.22a.75.75 0 0 1-.958-1.149l.085-.07 2.643-1.89-2.646-1.89a.75.75 0 0 1-.232-.952l.058-.095a.75.75 0 0 1 .95-.232l.096.058 3.5 2.5v1.22l-3.496 2.5zm7.644-.836 2.122 2.122-5.825 5.809-2.125-.005.003-2.116zm2.539-1.847 1.414 1.414a.5.5 0 0 1 0 .707l-1.06 1.06-2.122-2.12 1.061-1.061a.5.5 0 0 1 .707 0z"/></svg>',tooltip:!0,class:"ck-source-editing-button"}),e})),e.ui.componentFactory.add("menuBar:sourceEditing",(()=>{const e=this._createButton(uw);return e.set({label:t("Show source")}),e})),this._isAllowedToHandleSourceEditingMode()&&(this.on("change:isSourceEditingMode",((e,t,i)=>{i?(this._hideVisibleDialog(),this._showSourceEditing(),this._disableCommands()):(this._hideSourceEditing(),this._enableCommands())})),this.on("change:isEnabled",((e,t,i)=>this._handleReadOnlyMode(!i))),this.listenTo(e,"change:isReadOnly",((e,t,i)=>this._handleReadOnlyMode(i)))),e.data.on("get",(()=>{this.isSourceEditingMode&&this.updateEditorData()}),{priority:"high"})}updateEditorData(){const e=this.editor,t={};for(const[e,i]of this._replacedRoots){const n=this._dataFromRoots.get(e),s=i.dataset.value;n!==s&&(t[e]=s,this._dataFromRoots.set(e,s))}Object.keys(t).length&&e.data.set(t,{batchType:{isUndoable:!0},suppressErrorInCollaboration:!0})}_checkCompatibility(){const e=this.editor,t=e.config.get("sourceEditing.allowCollaborationFeatures");if(!t&&e.plugins.has("RealTimeCollaborativeEditing"))throw new p("source-editing-incompatible-with-real-time-collaboration",null);!t&&["CommentsEditing","TrackChangesEditing","RevisionHistory"].some((t=>e.plugins.has(t)))&&console.warn("You initialized the editor with the source editing feature and at least one of the collaboration features. Please be advised that the source editing feature may not work, and be careful when editing document source that contains markers created by the collaboration features."),e.plugins.has("RestrictedEditingModeEditing")&&console.warn("You initialized the editor with the source editing feature and restricted editing feature. Please be advised that the source editing feature may not work, and be careful when editing document source that contains markers created by the restricted editing feature.")}_showSourceEditing(){const e=this.editor,t=e.editing.view,i=e.model;i.change((e=>{e.setSelection(null),e.removeSelectionAttribute(i.document.selection.getAttributeKeys())}));for(const[i,n]of t.domRoots){const s=yO(e.data.get({rootName:i})),o=cr(n.ownerDocument,"textarea",{rows:"1","aria-label":"Source code editing area"}),r=cr(n.ownerDocument,"div",{class:"ck-source-editing-area","data-value":s},[o]);o.value=s,o.setSelectionRange(0,0),o.addEventListener("input",(()=>{r.dataset.value=o.value,e.ui.update()})),t.change((e=>{const n=t.document.getRoot(i);e.addClass("ck-hidden",n)})),e.ui.setEditableElement("sourceEditing:"+i,o),this._replacedRoots.set(i,r),this._elementReplacer.replace(n,r),this._dataFromRoots.set(i,s)}this._focusSourceEditing()}_hideSourceEditing(){const e=this.editor.editing.view;this.updateEditorData(),e.change((t=>{for(const[i]of this._replacedRoots)t.removeClass("ck-hidden",e.document.getRoot(i))})),this._elementReplacer.restore(),this._replacedRoots.clear(),this._dataFromRoots.clear(),e.focus()}_focusSourceEditing(){const e=this.editor,[t]=this._replacedRoots.values(),i=t.querySelector("textarea");e.editing.view.document.isFocused=!1,i.focus()}_disableCommands(){const e=this.editor;for(const t of e.commands.commands())t.forceDisabled(vO);e.plugins.has("CommentsArchiveUI")&&e.plugins.get("CommentsArchiveUI").forceDisabled(vO)}_enableCommands(){const e=this.editor;for(const t of e.commands.commands())t.clearForceDisabled(vO);e.plugins.has("CommentsArchiveUI")&&e.plugins.get("CommentsArchiveUI").clearForceDisabled(vO)}_handleReadOnlyMode(e){if(this.isSourceEditingMode)for(const[,t]of this._replacedRoots)t.querySelector("textarea").readOnly=e}_isAllowedToHandleSourceEditingMode(){const e=this.editor.ui.view.editable;return e&&!e.hasExternalElement}_hideVisibleDialog(){if(this.editor.plugins.has("Dialog")){const e=this.editor.plugins.get("Dialog");e.isOpen&&e.hide()}}_createButton(e){const t=this.editor,i=new e(t.locale);return i.set({withText:!0}),i.bind("isOn").to(this,"isSourceEditingMode"),i.bind("isEnabled").to(this,"isEnabled",t,"isReadOnly",t.plugins.get(Fm),"hasAny",((e,t,i)=>!!e&&(!t&&!i))),this.listenTo(i,"execute",(()=>{this.isSourceEditingMode=!this.isSourceEditingMode})),i}constructor(e){super(e),this.set("isSourceEditingMode",!1),this._elementReplacer=new sr,this._replacedRoots=new Map,this._dataFromRoots=new Map,e.config.define("sourceEditing.allowCollaborationFeatures",!1)}}function yO(e){return function(e){return e.startsWith("<")}(e)?bO(e):e}class kO extends Up{get currentGroupName(){return this.groupDropdownView.value}focus(){this.groupDropdownView.focus()}_createGroupDropdown(e){const t=this.locale,i=t.t,n=Wf(t),s=this._getCharacterGroupListItemDefinitions(n,e),o=i("Character categories");return n.set("value",s.first.model.name),n.buttonView.bind("label").to(n,"value",(t=>e.get(t))),n.buttonView.set({isOn:!1,withText:!0,tooltip:o,class:["ck-dropdown__button_label-width_auto"],ariaLabel:o,ariaLabelledBy:void 0}),n.on("execute",(e=>{n.value=e.source.name})),n.delegate("execute").to(this),Gf(n,s,{ariaLabel:o,role:"menu"}),n}_getCharacterGroupListItemDefinitions(e,t){const i=new va;for(const[n,s]of t){const t=new Ab({name:n,label:s,withText:!0,role:"menuitemradio"});t.bind("isOn").to(e,"value",(e=>e===t.name)),i.add({type:"button",model:t})}return i}constructor(e,t){super(e);const i=e.t;this.set("class","ck-special-characters-navigation"),this.groupDropdownView=this._createGroupDropdown(t),this.groupDropdownView.panelPosition="rtl"===e.uiLanguageDirection?"se":"sw",this.label=i("Special characters"),this.children.add(this.groupDropdownView)}}class CO extends Tg{createTile(e,t){const i=new Hg(this.locale);return i.set({label:e,withText:!0,class:"ck-character-grid__tile"}),i.extendTemplate({attributes:{title:t},on:{mouseover:i.bindTemplate.to("mouseover"),focus:i.bindTemplate.to("focus")}}),i.on("mouseover",(()=>{this.fire("tileHover",{name:t,character:e})})),i.on("focus",(()=>{this.fire("tileFocus",{name:t,character:e})})),i.on("execute",(()=>{this.fire("execute",{name:t,character:e})})),i}render(){super.render();for(const e of this.tiles)this.focusTracker.add(e.element);this.tiles.on("change",((e,{added:t,removed:i})=>{if(t.length>0)for(const e of t)this.focusTracker.add(e.element);if(i.length>0)for(const e of i)this.focusTracker.remove(e.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.keystrokes.destroy()}focus(){this.tiles.first.focus()}constructor(e){super(e),this.tiles=this.createCollection(),this.setTemplate({tag:"div",children:[{tag:"div",attributes:{class:["ck","ck-character-grid__tiles"]},children:this.tiles}],attributes:{class:["ck","ck-character-grid"]}}),this.focusTracker=new ya,this.keystrokes=new ka,Rg({keystrokeHandler:this.keystrokes,focusTracker:this.focusTracker,gridItems:this.tiles,numberOfColumns:()=>_r.window.getComputedStyle(this.element.firstChild).getPropertyValue("grid-template-columns").split(" ").length,uiLanguageDirection:this.locale&&this.locale.uiLanguageDirection})}}class xO extends Tg{constructor(e){super(e);const t=this.bindTemplate;this.set("character",null),this.set("name",null),this.bind("code").to(this,"character",AO),this.setTemplate({tag:"div",children:[{tag:"span",attributes:{class:["ck-character-info__name"]},children:[{text:t.to("name",(e=>e||"​"))}]},{tag:"span",attributes:{class:["ck-character-info__code"]},children:[{text:t.to("code")}]}],attributes:{class:["ck","ck-character-info"]}})}}function AO(e){if(null===e)return"";return"U+"+("0000"+e.codePointAt(0).toString(16)).slice(-4)}class EO extends Tg{render(){super.render(),this.focusTracker.add(this.navigationView.groupDropdownView.buttonView.element),this.focusTracker.add(this.gridView.element),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this.navigationView.focus()}constructor(e,t,i,n){super(e),this.navigationView=t,this.gridView=i,this.infoView=n,this.items=this.createCollection(),this.focusTracker=new ya,this.keystrokes=new ka,this._focusCycler=new Tf({focusables:this.items,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",children:[this.navigationView,this.gridView,this.infoView],attributes:{tabindex:"-1"}}),this.items.add(this.navigationView.groupDropdownView.buttonView),this.items.add(this.gridView)}}const TO="All";class SO extends Na{static get requires(){return[Bw]}static get pluginName(){return"SpecialCharacters"}init(){const e=this.editor,t=e.t,i=e.commands.get("insertText");e.ui.componentFactory.add("specialCharacters",(n=>{const s=Wf(n);let o;return s.buttonView.set({label:t("Special characters"),icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M10 2.5a7.47 7.47 0 0 1 4.231 1.31 7.268 7.268 0 0 1 2.703 3.454 7.128 7.128 0 0 1 .199 4.353c-.39 1.436-1.475 2.72-2.633 3.677h2.013c0-.226.092-.443.254-.603a.876.876 0 0 1 1.229 0c.163.16.254.377.254.603v.853c0 .209-.078.41-.22.567a.873.873 0 0 1-.547.28l-.101.006h-4.695a.517.517 0 0 1-.516-.518v-1.265c0-.21.128-.398.317-.489a5.601 5.601 0 0 0 2.492-2.371 5.459 5.459 0 0 0 .552-3.693 5.53 5.53 0 0 0-1.955-3.2A5.71 5.71 0 0 0 10 4.206 5.708 5.708 0 0 0 6.419 5.46 5.527 5.527 0 0 0 4.46 8.663a5.457 5.457 0 0 0 .554 3.695 5.6 5.6 0 0 0 2.497 2.37.55.55 0 0 1 .317.49v1.264c0 .286-.23.518-.516.518H2.618a.877.877 0 0 1-.614-.25.845.845 0 0 1-.254-.603v-.853c0-.226.091-.443.254-.603a.876.876 0 0 1 1.228 0c.163.16.255.377.255.603h1.925c-1.158-.958-2.155-2.241-2.545-3.678a7.128 7.128 0 0 1 .199-4.352 7.268 7.268 0 0 1 2.703-3.455A7.475 7.475 0 0 1 10 2.5z"/></svg>',tooltip:!0}),s.bind("isEnabled").to(i),s.on("execute",((t,i)=>{e.execute("insertText",{text:i.character}),e.editing.view.focus()})),s.on("change:isOpen",(()=>{if(!o){o=this._createDropdownPanelContent(n,s);const e=new EO(n,o.navigationView,o.gridView,o.infoView);s.panelView.children.add(e)}o.infoView.set({character:null,name:null})})),s}))}addItems(e,t,i={label:e}){if(e===TO)throw new p("special-character-invalid-group-name",null);const n=this._getGroup(e,i.label);for(const e of t)n.items.add(e.title),this._characters.set(e.title,e.character)}getGroups(){const e=Array.from(this._groups.keys()),t=this.editor.config.get("specialCharacters.order")||[],i=t.find((t=>!e.includes(t)));if(i)throw new p("special-character-invalid-order-group-name",null,{invalidGroup:i});return new Set([...t,...e])}getCharactersForGroup(e){if(e===TO)return new Set(this._characters.keys());const t=this._groups.get(e);return t?t.items:void 0}getCharacter(e){return this._characters.get(e)}_getGroup(e,t){return this._groups.has(e)||this._groups.set(e,{items:new Set,label:t}),this._groups.get(e)}_updateGrid(e,t){t.tiles.clear();const i=this.getCharactersForGroup(e);for(const e of i){const i=this.getCharacter(e);t.tiles.add(t.createTile(i,e))}}_createDropdownPanelContent(e,t){const i=Array.from(this.getGroups()).map((e=>[e,this._groups.get(e).label])),n=new Map([[TO,this._allSpecialCharactersGroupLabel],...i]),s=new kO(e,n),o=new CO(e),r=new xO(e);return o.delegate("execute").to(t),o.on("tileHover",((e,t)=>{r.set(t)})),o.on("tileFocus",((e,t)=>{r.set(t)})),s.on("execute",(()=>{this._updateGrid(s.currentGroupName,o)})),this._updateGrid(s.currentGroupName,o),{navigationView:s,gridView:o,infoView:r}}constructor(e){super(e);const t=e.t;this._characters=new Map,this._groups=new Map,this._allSpecialCharactersGroupLabel=t("All")}}class IO extends Na{static get pluginName(){return"SpecialCharactersArrows"}init(){const e=this.editor,t=e.t;e.plugins.get("SpecialCharacters").addItems("Arrows",[{title:t("leftwards simple arrow"),character:"←"},{title:t("rightwards simple arrow"),character:"→"},{title:t("upwards simple arrow"),character:"↑"},{title:t("downwards simple arrow"),character:"↓"},{title:t("leftwards double arrow"),character:"⇐"},{title:t("rightwards double arrow"),character:"⇒"},{title:t("upwards double arrow"),character:"⇑"},{title:t("downwards double arrow"),character:"⇓"},{title:t("leftwards dashed arrow"),character:"⇠"},{title:t("rightwards dashed arrow"),character:"⇢"},{title:t("upwards dashed arrow"),character:"⇡"},{title:t("downwards dashed arrow"),character:"⇣"},{title:t("leftwards arrow to bar"),character:"⇤"},{title:t("rightwards arrow to bar"),character:"⇥"},{title:t("upwards arrow to bar"),character:"⤒"},{title:t("downwards arrow to bar"),character:"⤓"},{title:t("up down arrow with base"),character:"↨"},{title:t("back with leftwards arrow above"),character:"🔙"},{title:t("end with leftwards arrow above"),character:"🔚"},{title:t("on with exclamation mark with left right arrow above"),character:"🔛"},{title:t("soon with rightwards arrow above"),character:"🔜"},{title:t("top with upwards arrow above"),character:"🔝"}],{label:t("Arrows")})}}class PO extends Na{static get pluginName(){return"SpecialCharactersText"}init(){const e=this.editor,t=e.t;e.plugins.get("SpecialCharacters").addItems("Text",[{character:"‹",title:t("Single left-pointing angle quotation mark")},{character:"›",title:t("Single right-pointing angle quotation mark")},{character:"«",title:t("Left-pointing double angle quotation mark")},{character:"»",title:t("Right-pointing double angle quotation mark")},{character:"‘",title:t("Left single quotation mark")},{character:"’",title:t("Right single quotation mark")},{character:"“",title:t("Left double quotation mark")},{character:"”",title:t("Right double quotation mark")},{character:"‚",title:t("Single low-9 quotation mark")},{character:"„",title:t("Double low-9 quotation mark")},{character:"¡",title:t("Inverted exclamation mark")},{character:"¿",title:t("Inverted question mark")},{character:"‥",title:t("Two dot leader")},{character:"…",title:t("Horizontal ellipsis")},{character:"‡",title:t("Double dagger")},{character:"‰",title:t("Per mille sign")},{character:"‱",title:t("Per ten thousand sign")},{character:"‼",title:t("Double exclamation mark")},{character:"⁈",title:t("Question exclamation mark")},{character:"⁉",title:t("Exclamation question mark")},{character:"⁇",title:t("Double question mark")},{character:"©",title:t("Copyright sign")},{character:"®",title:t("Registered sign")},{character:"™",title:t("Trade mark sign")},{character:"§",title:t("Section sign")},{character:"¶",title:t("Paragraph sign")},{character:"⁋",title:t("Reversed paragraph sign")}],{label:t("Text")})}}class VO extends Na{static get pluginName(){return"SpecialCharactersMathematical"}init(){const e=this.editor,t=e.t;e.plugins.get("SpecialCharacters").addItems("Mathematical",[{character:"<",title:t("Less-than sign")},{character:">",title:t("Greater-than sign")},{character:"≤",title:t("Less-than or equal to")},{character:"≥",title:t("Greater-than or equal to")},{character:"–",title:t("En dash")},{character:"—",title:t("Em dash")},{character:"¯",title:t("Macron")},{character:"‾",title:t("Overline")},{character:"°",title:t("Degree sign")},{character:"−",title:t("Minus sign")},{character:"±",title:t("Plus-minus sign")},{character:"÷",title:t("Division sign")},{character:"⁄",title:t("Fraction slash")},{character:"×",title:t("Multiplication sign")},{character:"ƒ",title:t("Latin small letter f with hook")},{character:"∫",title:t("Integral")},{character:"∑",title:t("N-ary summation")},{character:"∞",title:t("Infinity")},{character:"√",title:t("Square root")},{character:"∼",title:t("Tilde operator")},{character:"≅",title:t("Approximately equal to")},{character:"≈",title:t("Almost equal to")},{character:"≠",title:t("Not equal to")},{character:"≡",title:t("Identical to")},{character:"∈",title:t("Element of")},{character:"∉",title:t("Not an element of")},{character:"∋",title:t("Contains as member")},{character:"∏",title:t("N-ary product")},{character:"∧",title:t("Logical and")},{character:"∨",title:t("Logical or")},{character:"¬",title:t("Not sign")},{character:"∩",title:t("Intersection")},{character:"∪",title:t("Union")},{character:"∂",title:t("Partial differential")},{character:"∀",title:t("For all")},{character:"∃",title:t("There exists")},{character:"∅",title:t("Empty set")},{character:"∇",title:t("Nabla")},{character:"∗",title:t("Asterisk operator")},{character:"∝",title:t("Proportional to")},{character:"∠",title:t("Angle")},{character:"¼",title:t("Vulgar fraction one quarter")},{character:"½",title:t("Vulgar fraction one half")},{character:"¾",title:t("Vulgar fraction three quarters")}],{label:t("Mathematical")})}}class RO extends Na{static get pluginName(){return"SpecialCharactersLatin"}init(){const e=this.editor,t=e.t;e.plugins.get("SpecialCharacters").addItems("Latin",[{character:"Ā",title:t("Latin capital letter a with macron")},{character:"ā",title:t("Latin small letter a with macron")},{character:"Ă",title:t("Latin capital letter a with breve")},{character:"ă",title:t("Latin small letter a with breve")},{character:"Ą",title:t("Latin capital letter a with ogonek")},{character:"ą",title:t("Latin small letter a with ogonek")},{character:"Ć",title:t("Latin capital letter c with acute")},{character:"ć",title:t("Latin small letter c with acute")},{character:"Ĉ",title:t("Latin capital letter c with circumflex")},{character:"ĉ",title:t("Latin small letter c with circumflex")},{character:"Ċ",title:t("Latin capital letter c with dot above")},{character:"ċ",title:t("Latin small letter c with dot above")},{character:"Č",title:t("Latin capital letter c with caron")},{character:"č",title:t("Latin small letter c with caron")},{character:"Ď",title:t("Latin capital letter d with caron")},{character:"ď",title:t("Latin small letter d with caron")},{character:"Đ",title:t("Latin capital letter d with stroke")},{character:"đ",title:t("Latin small letter d with stroke")},{character:"Ē",title:t("Latin capital letter e with macron")},{character:"ē",title:t("Latin small letter e with macron")},{character:"Ĕ",title:t("Latin capital letter e with breve")},{character:"ĕ",title:t("Latin small letter e with breve")},{character:"Ė",title:t("Latin capital letter e with dot above")},{character:"ė",title:t("Latin small letter e with dot above")},{character:"Ę",title:t("Latin capital letter e with ogonek")},{character:"ę",title:t("Latin small letter e with ogonek")},{character:"Ě",title:t("Latin capital letter e with caron")},{character:"ě",title:t("Latin small letter e with caron")},{character:"Ĝ",title:t("Latin capital letter g with circumflex")},{character:"ĝ",title:t("Latin small letter g with circumflex")},{character:"Ğ",title:t("Latin capital letter g with breve")},{character:"ğ",title:t("Latin small letter g with breve")},{character:"Ġ",title:t("Latin capital letter g with dot above")},{character:"ġ",title:t("Latin small letter g with dot above")},{character:"Ģ",title:t("Latin capital letter g with cedilla")},{character:"ģ",title:t("Latin small letter g with cedilla")},{character:"Ĥ",title:t("Latin capital letter h with circumflex")},{character:"ĥ",title:t("Latin small letter h with circumflex")},{character:"Ħ",title:t("Latin capital letter h with stroke")},{character:"ħ",title:t("Latin small letter h with stroke")},{character:"Ĩ",title:t("Latin capital letter i with tilde")},{character:"ĩ",title:t("Latin small letter i with tilde")},{character:"Ī",title:t("Latin capital letter i with macron")},{character:"ī",title:t("Latin small letter i with macron")},{character:"Ĭ",title:t("Latin capital letter i with breve")},{character:"ĭ",title:t("Latin small letter i with breve")},{character:"Į",title:t("Latin capital letter i with ogonek")},{character:"į",title:t("Latin small letter i with ogonek")},{character:"İ",title:t("Latin capital letter i with dot above")},{character:"ı",title:t("Latin small letter dotless i")},{character:"IJ",title:t("Latin capital ligature ij")},{character:"ij",title:t("Latin small ligature ij")},{character:"Ĵ",title:t("Latin capital letter j with circumflex")},{character:"ĵ",title:t("Latin small letter j with circumflex")},{character:"Ķ",title:t("Latin capital letter k with cedilla")},{character:"ķ",title:t("Latin small letter k with cedilla")},{character:"ĸ",title:t("Latin small letter kra")},{character:"Ĺ",title:t("Latin capital letter l with acute")},{character:"ĺ",title:t("Latin small letter l with acute")},{character:"Ļ",title:t("Latin capital letter l with cedilla")},{character:"ļ",title:t("Latin small letter l with cedilla")},{character:"Ľ",title:t("Latin capital letter l with caron")},{character:"ľ",title:t("Latin small letter l with caron")},{character:"Ŀ",title:t("Latin capital letter l with middle dot")},{character:"ŀ",title:t("Latin small letter l with middle dot")},{character:"Ł",title:t("Latin capital letter l with stroke")},{character:"ł",title:t("Latin small letter l with stroke")},{character:"Ń",title:t("Latin capital letter n with acute")},{character:"ń",title:t("Latin small letter n with acute")},{character:"Ņ",title:t("Latin capital letter n with cedilla")},{character:"ņ",title:t("Latin small letter n with cedilla")},{character:"Ň",title:t("Latin capital letter n with caron")},{character:"ň",title:t("Latin small letter n with caron")},{character:"ʼn",title:t("Latin small letter n preceded by apostrophe")},{character:"Ŋ",title:t("Latin capital letter eng")},{character:"ŋ",title:t("Latin small letter eng")},{character:"Ō",title:t("Latin capital letter o with macron")},{character:"ō",title:t("Latin small letter o with macron")},{character:"Ŏ",title:t("Latin capital letter o with breve")},{character:"ŏ",title:t("Latin small letter o with breve")},{character:"Ő",title:t("Latin capital letter o with double acute")},{character:"ő",title:t("Latin small letter o with double acute")},{character:"Œ",title:t("Latin capital ligature oe")},{character:"œ",title:t("Latin small ligature oe")},{character:"Ŕ",title:t("Latin capital letter r with acute")},{character:"ŕ",title:t("Latin small letter r with acute")},{character:"Ŗ",title:t("Latin capital letter r with cedilla")},{character:"ŗ",title:t("Latin small letter r with cedilla")},{character:"Ř",title:t("Latin capital letter r with caron")},{character:"ř",title:t("Latin small letter r with caron")},{character:"Ś",title:t("Latin capital letter s with acute")},{character:"ś",title:t("Latin small letter s with acute")},{character:"Ŝ",title:t("Latin capital letter s with circumflex")},{character:"ŝ",title:t("Latin small letter s with circumflex")},{character:"Ş",title:t("Latin capital letter s with cedilla")},{character:"ş",title:t("Latin small letter s with cedilla")},{character:"Š",title:t("Latin capital letter s with caron")},{character:"š",title:t("Latin small letter s with caron")},{character:"Ţ",title:t("Latin capital letter t with cedilla")},{character:"ţ",title:t("Latin small letter t with cedilla")},{character:"Ť",title:t("Latin capital letter t with caron")},{character:"ť",title:t("Latin small letter t with caron")},{character:"Ŧ",title:t("Latin capital letter t with stroke")},{character:"ŧ",title:t("Latin small letter t with stroke")},{character:"Ũ",title:t("Latin capital letter u with tilde")},{character:"ũ",title:t("Latin small letter u with tilde")},{character:"Ū",title:t("Latin capital letter u with macron")},{character:"ū",title:t("Latin small letter u with macron")},{character:"Ŭ",title:t("Latin capital letter u with breve")},{character:"ŭ",title:t("Latin small letter u with breve")},{character:"Ů",title:t("Latin capital letter u with ring above")},{character:"ů",title:t("Latin small letter u with ring above")},{character:"Ű",title:t("Latin capital letter u with double acute")},{character:"ű",title:t("Latin small letter u with double acute")},{character:"Ų",title:t("Latin capital letter u with ogonek")},{character:"ų",title:t("Latin small letter u with ogonek")},{character:"Ŵ",title:t("Latin capital letter w with circumflex")},{character:"ŵ",title:t("Latin small letter w with circumflex")},{character:"Ŷ",title:t("Latin capital letter y with circumflex")},{character:"ŷ",title:t("Latin small letter y with circumflex")},{character:"Ÿ",title:t("Latin capital letter y with diaeresis")},{character:"Ź",title:t("Latin capital letter z with acute")},{character:"ź",title:t("Latin small letter z with acute")},{character:"Ż",title:t("Latin capital letter z with dot above")},{character:"ż",title:t("Latin small letter z with dot above")},{character:"Ž",title:t("Latin capital letter z with caron")},{character:"ž",title:t("Latin small letter z with caron")},{character:"ſ",title:t("Latin small letter long s")}],{label:t("Latin")})}}class BO extends Na{static get pluginName(){return"SpecialCharactersCurrency"}init(){const e=this.editor,t=e.t;e.plugins.get("SpecialCharacters").addItems("Currency",[{character:"$",title:t("Dollar sign")},{character:"€",title:t("Euro sign")},{character:"¥",title:t("Yen sign")},{character:"£",title:t("Pound sign")},{character:"¢",title:t("Cent sign")},{character:"₠",title:t("Euro-currency sign")},{character:"₡",title:t("Colon sign")},{character:"₢",title:t("Cruzeiro sign")},{character:"₣",title:t("French franc sign")},{character:"₤",title:t("Lira sign")},{character:"¤",title:t("Currency sign")},{character:"₿",title:t("Bitcoin sign")},{character:"₥",title:t("Mill sign")},{character:"₦",title:t("Naira sign")},{character:"₧",title:t("Peseta sign")},{character:"₨",title:t("Rupee sign")},{character:"₩",title:t("Won sign")},{character:"₪",title:t("New sheqel sign")},{character:"₫",title:t("Dong sign")},{character:"₭",title:t("Kip sign")},{character:"₮",title:t("Tugrik sign")},{character:"₯",title:t("Drachma sign")},{character:"₰",title:t("German penny sign")},{character:"₱",title:t("Peso sign")},{character:"₲",title:t("Guarani sign")},{character:"₳",title:t("Austral sign")},{character:"₴",title:t("Hryvnia sign")},{character:"₵",title:t("Cedi sign")},{character:"₶",title:t("Livre tournois sign")},{character:"₷",title:t("Spesmilo sign")},{character:"₸",title:t("Tenge sign")},{character:"₹",title:t("Indian rupee sign")},{character:"₺",title:t("Turkish lira sign")},{character:"₻",title:t("Nordic mark sign")},{character:"₼",title:t("Manat sign")},{character:"₽",title:t("Ruble sign")}],{label:t("Currency")})}}class OO extends Na{static get pluginName(){return"SpecialCharactersEssentials"}static get requires(){return[BO,PO,VO,IO,RO]}}class MO extends Hg{_createPreview(){const e=new Tg(this.locale);return e.setTemplate({tag:"div",attributes:{class:["ck","ck-reset_all-excluded","ck-style-grid__button__preview","ck-content"],"aria-hidden":"true"},children:[this.styleDefinition.previewTemplate]}),e}constructor(e,t){super(e),this.styleDefinition=t,this.previewView=this._createPreview(),this.set({label:t.name,class:"ck-style-grid__button",withText:!0}),this.extendTemplate({attributes:{role:"option"}}),this.children.add(this.previewView,0)}}class LO extends Tg{render(){super.render();for(const e of this.children)this.focusTracker.add(e.element);Rg({keystrokeHandler:this.keystrokes,focusTracker:this.focusTracker,gridItems:this.children,numberOfColumns:3,uiLanguageDirection:this.locale&&this.locale.uiLanguageDirection}),this.keystrokes.listenTo(this.element)}focus(){this.children.first.focus()}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}constructor(e,t){super(e),this.focusTracker=new ya,this.keystrokes=new ka,this.set("activeStyles",[]),this.set("enabledStyles",[]),this.children=this.createCollection(),this.children.delegate("execute").to(this);for(const i of t){const t=new MO(e,i);this.children.add(t)}this.on("change:activeStyles",(()=>{for(const e of this.children)e.isOn=this.activeStyles.includes(e.styleDefinition.name)})),this.on("change:enabledStyles",(()=>{for(const e of this.children)e.isEnabled=this.enabledStyles.includes(e.styleDefinition.name)})),this.setTemplate({tag:"div",attributes:{class:["ck","ck-style-grid"],role:"listbox"},children:this.children})}}class NO extends Tg{constructor(e,t,i){super(e),this.labelView=new Bg(e),this.labelView.text=t,this.gridView=new LO(e,i),this.setTemplate({tag:"div",attributes:{class:["ck","ck-style-panel__style-group"],role:"group","aria-labelledby":this.labelView.id},children:[this.labelView,this.gridView]})}}class FO extends Tg{render(){super.render(),this._focusables.add(this.blockStylesGroupView.gridView),this._focusables.add(this.inlineStylesGroupView.gridView),this.focusTracker.add(this.blockStylesGroupView.gridView.element),this.focusTracker.add(this.inlineStylesGroupView.gridView.element),this.keystrokes.listenTo(this.element)}focus(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}constructor(e,t){super(e);const i=e.t;this.focusTracker=new ya,this.keystrokes=new ka,this.children=this.createCollection(),this.blockStylesGroupView=new NO(e,i("Block styles"),t.block),this.inlineStylesGroupView=new NO(e,i("Text styles"),t.inline),this.set("activeStyles",[]),this.set("enabledStyles",[]),this._focusables=new og,this._focusCycler=new Tf({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:["shift + tab"],focusNext:["tab"]}}),t.block.length&&this.children.add(this.blockStylesGroupView),t.inline.length&&this.children.add(this.inlineStylesGroupView),this.blockStylesGroupView.gridView.delegate("execute").to(this),this.inlineStylesGroupView.gridView.delegate("execute").to(this),this.blockStylesGroupView.gridView.bind("activeStyles","enabledStyles").to(this,"activeStyles","enabledStyles"),this.inlineStylesGroupView.gridView.bind("activeStyles","enabledStyles").to(this,"activeStyles","enabledStyles"),this.setTemplate({tag:"div",attributes:{class:["ck","ck-style-panel"]},children:this.children})}}const DO=["caption","colgroup","dd","dt","figcaption","legend","li","optgroup","option","rp","rt","summary","tbody","td","tfoot","th","thead","tr"];class zO extends Na{static get pluginName(){return"StyleUtils"}init(){this._htmlSupport=this.editor.plugins.get("GeneralHtmlSupport")}normalizeConfig(e,t=[]){const i={block:[],inline:[]};for(const n of t){const t=[],s=[];for(const i of e.getDefinitionsForView(n.element)){const e="appliesToBlock"in i&&i.appliesToBlock;if(i.isBlock||e){if("string"==typeof e)t.push(e);else if(i.isBlock){const e=i;t.push(i.model),e.paragraphLikeModel&&t.push(e.paragraphLikeModel)}}else s.push(i.model)}const o=this.getStylePreview(n,[{text:"AaBbCcDdEeFfGgHhIiJj"}]);t.length?i.block.push({...n,previewTemplate:o,modelElements:t,isBlock:!0}):i.inline.push({...n,previewTemplate:o,ghsAttributes:s})}return i}isStyleEnabledForBlock(e,t){const i=this.editor.model,n=this._htmlSupport.getGhsAttributeNameForElement(e.element);return!!i.schema.checkAttribute(t,n)&&e.modelElements.includes(t.name)}isStyleActiveForBlock(e,t){const i=this._htmlSupport.getGhsAttributeNameForElement(e.element),n=t.getAttribute(i);return this.hasAllClasses(n,e.classes)}getAffectedBlocks(e,t){return e.modelElements.includes(t.name)?[t]:null}isStyleEnabledForInlineSelection(e,t){const i=this.editor.model;for(const n of e.ghsAttributes)if(i.schema.checkAttributeInSelection(t,n))return!0;return!1}isStyleActiveForInlineSelection(e,t){for(const i of e.ghsAttributes){const n=this._getValueFromFirstAllowedNode(t,i);if(this.hasAllClasses(n,e.classes))return!0}return!1}getAffectedInlineSelectable(e,t){return t}getStylePreview(e,t){const{element:i,classes:n}=e;return{tag:(s=i,DO.includes(s)?"div":i),attributes:{class:n},children:t};var s}hasAllClasses(e,t){return re(e)&&(i=e,Boolean(i.classes)&&Array.isArray(i.classes))&&t.every((t=>e.classes.includes(t)));var i}configureGHSDataFilter({block:e,inline:t}){const i=this.editor.plugins.get("DataFilter");i.loadAllowedConfig(e.map(HO)),i.loadAllowedConfig(t.map(HO))}_getValueFromFirstAllowedNode(e,t){const i=this.editor.model.schema;if(e.isCollapsed)return e.getAttribute(t);for(const n of e.getRanges())for(const e of n.getItems())if(i.checkAttribute(e,t))return e.getAttribute(t);return null}constructor(e){super(e),this.decorate("isStyleEnabledForBlock"),this.decorate("isStyleActiveForBlock"),this.decorate("getAffectedBlocks"),this.decorate("isStyleEnabledForInlineSelection"),this.decorate("isStyleActiveForInlineSelection"),this.decorate("getAffectedInlineSelectable"),this.decorate("getStylePreview"),this.decorate("configureGHSDataFilter")}}function HO({element:e,classes:t}){return{name:e,classes:t}}class $O extends Na{static get pluginName(){return"StyleUI"}static get requires(){return[zO]}init(){const e=this.editor,t=e.plugins.get("DataSchema"),i=e.plugins.get("StyleUtils"),n=e.config.get("style.definitions"),s=i.normalizeConfig(t,n);e.ui.componentFactory.add("style",(t=>{const i=t.t,n=Wf(t),o=e.commands.get("style");return n.once("change:isOpen",(()=>{const e=new FO(t,s);n.panelView.children.add(e),e.delegate("execute").to(n),e.bind("activeStyles").to(o,"value"),e.bind("enabledStyles").to(o,"enabledStyles")})),n.bind("isEnabled").to(o),n.buttonView.withText=!0,n.buttonView.bind("label").to(o,"value",(e=>e.length>1?i("Multiple styles"):1===e.length?e[0]:i("Styles"))),n.bind("class").to(o,"value",(e=>{const t=["ck-style-dropdown"];return e.length>1&&t.push("ck-style-dropdown_multiple-active"),t.join(" ")})),n.on("execute",(t=>{e.execute("style",{styleName:t.source.styleDefinition.name}),e.editing.view.focus()})),n}))}}class UO extends Da{refresh(){const e=this.editor.model,t=e.document.selection,i=new Set,n=new Set;for(const e of this._styleDefinitions.inline)this._styleUtils.isStyleEnabledForInlineSelection(e,t)&&n.add(e.name),this._styleUtils.isStyleActiveForInlineSelection(e,t)&&i.add(e.name);const s=_a(t.getSelectedBlocks())||t.getFirstPosition().parent;if(s){const t=s.getAncestors({includeSelf:!0,parentFirst:!0});for(const s of t){if(s.is("rootElement"))break;for(const e of this._styleDefinitions.block)this._styleUtils.isStyleEnabledForBlock(e,s)&&(n.add(e.name),this._styleUtils.isStyleActiveForBlock(e,s)&&i.add(e.name));if(e.schema.isObject(s))break}}this.enabledStyles=Array.from(n).sort(),this.isEnabled=this.enabledStyles.length>0,this.value=this.isEnabled?Array.from(i).sort():[]}execute({styleName:e,forceValue:t}){if(!this.enabledStyles.includes(e))return void b("style-command-executed-with-incorrect-style-name");const i=this.editor.model,n=i.document.selection,s=this.editor.plugins.get("GeneralHtmlSupport"),o=[...this._styleDefinitions.inline,...this._styleDefinitions.block],r=o.filter((({name:e})=>this.value.includes(e))),a=o.find((({name:t})=>t==e)),l=void 0===t?!this.value.includes(a.name):t;i.change((()=>{let e;e=function(e){return"isBlock"in e}(a)?this._findAffectedBlocks(function(e){const t=Array.from(e.getSelectedBlocks());if(t.length)return t;return[e.getFirstPosition().parent]}(n),a):[this._styleUtils.getAffectedInlineSelectable(a,n)];for(const t of e)l?s.addModelHtmlClass(a.element,a.classes,t):s.removeModelHtmlClass(a.element,WO(r,a),t)}))}_findAffectedBlocks(e,t){const i=new Set;for(const n of e){const e=n.getAncestors({includeSelf:!0,parentFirst:!0});for(const n of e){if(n.is("rootElement"))break;const e=this._styleUtils.getAffectedBlocks(t,n);if(e){for(const t of e)i.add(t);break}}}return i}constructor(e,t){super(e),this.set("value",[]),this.set("enabledStyles",[]),this._styleDefinitions=t,this._styleUtils=this.editor.plugins.get(zO)}}function WO(e,t){return e.reduce(((e,i)=>i.name===t.name?e:e.filter((e=>!i.classes.includes(e)))),t.classes)}class jO extends Na{static get pluginName(){return"ListStyleSupport"}static get requires(){return[zO,"GeneralHtmlSupport"]}init(){const e=this.editor;e.plugins.has("ListEditing")&&(this._styleUtils=e.plugins.get(zO),this._listUtils=this.editor.plugins.get("ListUtils"),this._htmlSupport=this.editor.plugins.get("GeneralHtmlSupport"),this.listenTo(this._styleUtils,"isStyleEnabledForBlock",((e,[t,i])=>{this._isStyleEnabledForBlock(t,i)&&(e.return=!0,e.stop())}),{priority:"high"}),this.listenTo(this._styleUtils,"isStyleActiveForBlock",((e,[t,i])=>{this._isStyleActiveForBlock(t,i)&&(e.return=!0,e.stop())}),{priority:"high"}),this.listenTo(this._styleUtils,"getAffectedBlocks",((e,[t,i])=>{const n=this._getAffectedBlocks(t,i);n&&(e.return=n,e.stop())}),{priority:"high"}),this.listenTo(this._styleUtils,"getStylePreview",((e,[t,i])=>{const n=this._getStylePreview(t,i);n&&(e.return=n,e.stop())}),{priority:"high"}))}_isStyleEnabledForBlock(e,t){const i=this.editor.model;if(!["ol","ul","li"].includes(e.element))return!1;if(!this._listUtils.isListItemBlock(t))return!1;const n=this._htmlSupport.getGhsAttributeNameForElement(e.element);if("ol"==e.element||"ul"==e.element){if(!i.schema.checkAttribute(t,n))return!1;const s=this._listUtils.isNumberedListType(t.getAttribute("listType"))?"ol":"ul";return e.element==s}return i.schema.checkAttribute(t,n)}_isStyleActiveForBlock(e,t){const i=this._htmlSupport.getGhsAttributeNameForElement(e.element),n=t.getAttribute(i);return this._styleUtils.hasAllClasses(n,e.classes)}_getAffectedBlocks(e,t){return this._isStyleEnabledForBlock(e,t)?"li"==e.element?this._listUtils.expandListBlocksToCompleteItems(t,{withNested:!1}):this._listUtils.expandListBlocksToCompleteList(t):null}_getStylePreview(e,t){const{element:i,classes:n}=e;return"ol"==i||"ul"==i?{tag:i,attributes:{class:n},children:[{tag:"li",children:t}]}:"li"==i?{tag:"ol",children:[{tag:i,attributes:{class:n},children:t}]}:null}}class qO extends Na{static get pluginName(){return"TableStyleSupport"}static get requires(){return[zO]}init(){const e=this.editor;e.plugins.has("TableEditing")&&(this._styleUtils=e.plugins.get(zO),this._tableUtils=this.editor.plugins.get("TableUtils"),this.listenTo(this._styleUtils,"isStyleEnabledForBlock",((e,[t,i])=>{this._isApplicable(t,i)&&(e.return=this._isStyleEnabledForBlock(t,i),e.stop())}),{priority:"high"}),this.listenTo(this._styleUtils,"getAffectedBlocks",((e,[t,i])=>{this._isApplicable(t,i)&&(e.return=this._getAffectedBlocks(t,i),e.stop())}),{priority:"high"}),this.listenTo(this._styleUtils,"configureGHSDataFilter",((e,[{block:t}])=>{this.editor.plugins.get("DataFilter").loadAllowedConfig(t.filter((e=>"figcaption"==e.element)).map((e=>({name:"caption",classes:e.classes}))))})))}_isApplicable(e,t){return["td","th"].includes(e.element)?"tableCell"==t.name:!!["thead","tbody"].includes(e.element)&&"table"==t.name}_isStyleEnabledForBlock(e,t){if(["td","th"].includes(e.element)){const i=this._tableUtils.getCellLocation(t),n=t.parent.parent,s=n.getAttribute("headingRows")||0,o=n.getAttribute("headingColumns")||0,r=i.row<s||i.column<o;return"th"==e.element?r:!r}if(["thead","tbody"].includes(e.element)){const i=t.getAttribute("headingRows")||0;return"thead"==e.element?i>0:i<this._tableUtils.getRows(t)}return!1}_getAffectedBlocks(e,t){return this._isStyleEnabledForBlock(e,t)?[t]:null}}class GO extends Na{static get pluginName(){return"LinkStyleSupport"}static get requires(){return[zO,"GeneralHtmlSupport"]}init(){const e=this.editor;e.plugins.has("LinkEditing")&&(this._styleUtils=e.plugins.get(zO),this._htmlSupport=this.editor.plugins.get("GeneralHtmlSupport"),this.listenTo(this._styleUtils,"isStyleEnabledForInlineSelection",((e,[t,i])=>{"a"==t.element&&(e.return=this._isStyleEnabled(t,i),e.stop())}),{priority:"high"}),this.listenTo(this._styleUtils,"isStyleActiveForInlineSelection",((e,[t,i])=>{"a"==t.element&&(e.return=this._isStyleActive(t,i),e.stop())}),{priority:"high"}),this.listenTo(this._styleUtils,"getAffectedInlineSelectable",((e,[t,i])=>{if("a"!=t.element)return;const n=this._getAffectedSelectable(t,i);n&&(e.return=n,e.stop())}),{priority:"high"}))}_isStyleEnabled(e,t){const i=this.editor.model;if(t.isCollapsed)return t.hasAttribute("linkHref");for(const e of t.getRanges())for(const t of e.getItems())if((t.is("$textProxy")||i.schema.isInline(t))&&t.hasAttribute("linkHref"))return!0;return!1}_isStyleActive(e,t){const i=this.editor.model,n=this._htmlSupport.getGhsAttributeNameForElement(e.element);if(t.isCollapsed){if(t.hasAttribute("linkHref")){const i=t.getAttribute(n);if(this._styleUtils.hasAllClasses(i,e.classes))return!0}return!1}for(const s of t.getRanges())for(const t of s.getItems())if((t.is("$textProxy")||i.schema.isInline(t))&&t.hasAttribute("linkHref")){const i=t.getAttribute(n);return this._styleUtils.hasAllClasses(i,e.classes)}return!1}_getAffectedSelectable(e,t){const i=this.editor.model;if(t.isCollapsed){const e=t.getAttribute("linkHref");return Qw(t.getFirstPosition(),"linkHref",e,i)}const n=[];for(const e of t.getRanges()){const t=i.createRange(KO(e.start,"linkHref",!0,i),KO(e.end,"linkHref",!1,i));for(const e of t.getItems())(e.is("$textProxy")||i.schema.isInline(e))&&e.hasAttribute("linkHref")&&n.push(this.editor.model.createRangeOn(e))}return function(e){for(let t=1;t<e.length;t++){const i=e[t-1].getJoined(e[t]);i&&e.splice(--t,2,i)}return e}(n)}}function KO(e,t,i,n){const s=e.textNode||(i?e.nodeAfter:e.nodeBefore);if(!s||!s.hasAttribute(t))return e;return Yw(e,t,s.getAttribute(t),i,n)}class ZO extends Na{static get pluginName(){return"StyleEditing"}static get requires(){return["GeneralHtmlSupport",zO,jO,qO,GO]}init(){const e=this.editor,t=e.plugins.get("DataSchema"),i=e.plugins.get("StyleUtils"),n=e.config.get("style.definitions"),s=i.normalizeConfig(t,n);e.commands.add("style",new UO(e,s)),i.configureGHSDataFilter(s)}}class JO extends Na{static get pluginName(){return"Style"}static get requires(){return[ZO,$O]}}function QO(e,t){const{modelAttribute:i,styleName:n,viewElement:s,defaultValue:o,reduceBoxSides:r=!1,shouldUpcast:a=(()=>!0)}=t;e.for("upcast").attributeToAttribute({view:{name:s,styles:{[n]:/[\s\S]+/}},model:{key:i,value:e=>{if(!a(e))return;const t=e.getNormalizedStyle(n),i=r?tM(t):t;return o!==i?i:void 0}}})}function YO(e,t,i,n){e.for("upcast").add((e=>e.on("element:"+t,((e,t,s)=>{if(!t.modelRange)return;const o=["border-top-width","border-top-color","border-top-style","border-bottom-width","border-bottom-color","border-bottom-style","border-right-width","border-right-color","border-right-style","border-left-width","border-left-color","border-left-style"].filter((e=>t.viewItem.hasStyle(e)));if(!o.length)return;const r={styles:o};if(!s.consumable.test(t.viewItem,r))return;const a=[...t.modelRange.getItems({shallow:!0})].pop();s.consumable.consume(t.viewItem,r);const l={style:t.viewItem.getNormalizedStyle("border-style"),color:t.viewItem.getNormalizedStyle("border-color"),width:t.viewItem.getNormalizedStyle("border-width")},c={style:tM(l.style),color:tM(l.color),width:tM(l.width)};c.style!==n.style&&s.writer.setAttribute(i.style,c.style,a),c.color!==n.color&&s.writer.setAttribute(i.color,c.color,a),c.width!==n.width&&s.writer.setAttribute(i.width,c.width,a)}))))}function XO(e,t){const{modelElement:i,modelAttribute:n,styleName:s}=t;e.for("downcast").attributeToAttribute({model:{name:i,key:n},view:e=>({key:"style",value:{[s]:e}})})}function eM(e,t){const{modelAttribute:i,styleName:n}=t;e.for("downcast").add((e=>e.on(`attribute:${i}:table`,((e,t,i)=>{const{item:s,attributeNewValue:o}=t,{mapper:r,writer:a}=i;if(!i.consumable.consume(t.item,e.name))return;const l=[...r.toViewElement(s).getChildren()].find((e=>e.is("element","table")));o?a.setStyle(n,o,l):a.removeStyle(n,l)}))))}function tM(e){if(!e)return;const t=["top","right","bottom","left"];if(!t.every((t=>e[t])))return e;const i=e.top;return t.every((t=>e[t]===i))?i:e}function iM(e,t,i,n,s=1){null!=t&&null!=s&&t>s?n.setAttribute(e,t,i):n.removeAttribute(e,i)}function nM(e,t,i={}){const n=e.createElement("tableCell",i);return e.insertElement("paragraph",n),e.insert(n,t),n}function sM(e,t){const i=t.parent.parent,n=parseInt(i.getAttribute("headingColumns")||"0"),{column:s}=e.getCellLocation(t);return!!n&&s<n}function oM(e,t,i){const{modelAttribute:n}=i;e.extend("tableCell",{allowAttributes:[n]}),QO(t,{viewElement:/^(td|th)$/,...i}),XO(t,{modelElement:"tableCell",...i})}function rM(e){const t=e.getSelectedElement();return t&&t.is("element","table")?t:e.getFirstPosition().findAncestor("table")}function aM(){return e=>{e.on("element:table",((e,t,i)=>{const n=t.viewItem;if(!i.consumable.test(n,{name:!0}))return;const{rows:s,headingRows:o,headingColumns:r}=function(e){let t,i=0;const n=[],s=[];let o;for(const r of Array.from(e.getChildren())){if("tbody"!==r.name&&"thead"!==r.name&&"tfoot"!==r.name)continue;"thead"!==r.name||o||(o=r);const e=Array.from(r.getChildren()).filter((e=>e.is("element","tr")));for(const a of e)if(o&&r===o||"tbody"===r.name&&Array.from(a.getChildren()).length&&Array.from(a.getChildren()).every((e=>e.is("element","th"))))i++,n.push(a);else{s.push(a);const e=cM(a);(!t||e<t)&&(t=e)}}return{headingRows:i,headingColumns:t||0,rows:[...n,...s]}}(n),a={};r&&(a.headingColumns=r),o&&(a.headingRows=o);const l=i.writer.createElement("table",a);if(i.safeInsert(l,t.modelCursor)){if(i.consumable.consume(n,{name:!0}),s.forEach((e=>i.convertItem(e,i.writer.createPositionAt(l,"end")))),i.convertChildren(n,i.writer.createPositionAt(l,"end")),l.isEmpty){const e=i.writer.createElement("tableRow");i.writer.insert(e,i.writer.createPositionAt(l,"end")),nM(i.writer,i.writer.createPositionAt(e,"end"))}i.updateConversionResult(l,t)}}))}}function lM(e){return t=>{t.on(`element:${e}`,((e,t,{writer:i})=>{if(!t.modelRange)return;const n=t.modelRange.start.nodeAfter,s=i.createPositionAt(n,0);if(t.viewItem.isEmpty)return void i.insertElement("paragraph",s);const o=Array.from(n.getChildren());if(o.every((e=>e.is("element","$marker")))){const e=i.createElement("paragraph");i.insert(e,i.createPositionAt(n,0));for(const t of o)i.move(i.createRangeOn(t),i.createPositionAt(e,"end"))}}),{priority:"low"})}}function cM(e){let t=0,i=0;const n=Array.from(e.getChildren()).filter((e=>"th"===e.name||"td"===e.name));for(;i<n.length&&"th"===n[i].name;){const e=n[i];t+=parseInt(e.getAttribute("colspan")||"1"),i++}return t}class dM{[Symbol.iterator](){return this}next(){this._canJumpToStartRow()&&this._jumpToNonSpannedRowClosestToStartRow();const e=this._table.getChild(this._rowIndex);if(!e||this._isOverEndRow())return{done:!0,value:void 0};if(!e.is("element","tableRow"))return this._rowIndex++,this.next();if(this._isOverEndColumn())return this._advanceToNextRow();let t=null;const i=this._getSpanned();if(i)this._includeAllSlots&&!this._shouldSkipSlot()&&(t=this._formatOutValue(i.cell,i.row,i.column));else{const i=e.getChild(this._cellIndex);if(!i)return this._advanceToNextRow();const n=parseInt(i.getAttribute("colspan")||"1"),s=parseInt(i.getAttribute("rowspan")||"1");(n>1||s>1)&&this._recordSpans(i,s,n),this._shouldSkipSlot()||(t=this._formatOutValue(i)),this._nextCellAtColumn=this._column+n}return this._column++,this._column==this._nextCellAtColumn&&this._cellIndex++,t||this.next()}skipRow(e){this._skipRows.add(e)}_advanceToNextRow(){return this._row++,this._rowIndex++,this._column=0,this._cellIndex=0,this._nextCellAtColumn=-1,this.next()}_isOverEndRow(){return void 0!==this._endRow&&this._row>this._endRow}_isOverEndColumn(){return void 0!==this._endColumn&&this._column>this._endColumn}_formatOutValue(e,t=this._row,i=this._column){return{done:!1,value:new hM(this,e,t,i)}}_shouldSkipSlot(){const e=this._skipRows.has(this._row),t=this._row<this._startRow,i=this._column<this._startColumn,n=void 0!==this._endColumn&&this._column>this._endColumn;return e||t||i||n}_getSpanned(){const e=this._spannedCells.get(this._row);return e&&e.get(this._column)||null}_recordSpans(e,t,i){const n={cell:e,row:this._row,column:this._column};for(let e=this._row;e<this._row+t;e++)for(let t=this._column;t<this._column+i;t++)e==this._row&&t==this._column||this._markSpannedCell(e,t,n)}_markSpannedCell(e,t,i){this._spannedCells.has(e)||this._spannedCells.set(e,new Map);this._spannedCells.get(e).set(t,i)}_canJumpToStartRow(){return!!this._startRow&&this._startRow>0&&!this._jumpedToStartRow}_jumpToNonSpannedRowClosestToStartRow(){const e=this._getRowLength(0);for(let t=this._startRow;!this._jumpedToStartRow;t--)e===this._getRowLength(t)&&(this._row=t,this._rowIndex=t,this._jumpedToStartRow=!0)}_getRowLength(e){return[...this._table.getChild(e).getChildren()].reduce(((e,t)=>e+parseInt(t.getAttribute("colspan")||"1")),0)}constructor(e,t={}){this._jumpedToStartRow=!1,this._table=e,this._startRow=void 0!==t.row?t.row:t.startRow||0,this._endRow=void 0!==t.row?t.row:t.endRow,this._startColumn=void 0!==t.column?t.column:t.startColumn||0,this._endColumn=void 0!==t.column?t.column:t.endColumn,this._includeAllSlots=!!t.includeAllSlots,this._skipRows=new Set,this._row=0,this._rowIndex=0,this._column=0,this._cellIndex=0,this._spannedCells=new Map,this._nextCellAtColumn=-1}}class hM{get isAnchor(){return this.row===this.cellAnchorRow&&this.column===this.cellAnchorColumn}get cellWidth(){return parseInt(this.cell.getAttribute("colspan")||"1")}get cellHeight(){return parseInt(this.cell.getAttribute("rowspan")||"1")}get rowIndex(){return this._rowIndex}getPositionBefore(){return this._table.root.document.model.createPositionAt(this._table.getChild(this.row),this._cellIndex)}constructor(e,t,i,n){this.cell=t,this.row=e._row,this.column=e._column,this.cellAnchorRow=i,this.cellAnchorColumn=n,this._cellIndex=e._cellIndex,this._rowIndex=e._rowIndex,this._table=e._table}}function uM(e,t){return(i,{writer:n})=>{const s=i.getAttribute("headingRows")||0,o=n.createContainerElement("table",null,[]),r=n.createContainerElement("figure",{class:"table"},o);s>0&&n.insert(n.createPositionAt(o,"end"),n.createContainerElement("thead",null,n.createSlot((e=>e.is("element","tableRow")&&e.index<s)))),s<e.getRows(i)&&n.insert(n.createPositionAt(o,"end"),n.createContainerElement("tbody",null,n.createSlot((e=>e.is("element","tableRow")&&e.index>=s))));for(const{positionOffset:e,filter:i}of t.additionalSlots)n.insert(n.createPositionAt(o,e),n.createSlot(i));return n.insert(n.createPositionAt(o,"after"),n.createSlot((e=>!e.is("element","tableRow")&&!t.additionalSlots.some((({filter:t})=>t(e)))))),t.asWidget?function(e,t){return t.setCustomProperty("table",!0,e),sy(e,t,{hasSelectionHandle:!0})}(r,n):r}}function mM(e={}){return(t,{writer:i})=>{const n=t.parent,s=n.parent,o=s.getChildIndex(n),r=new dM(s,{row:o}),a=s.getAttribute("headingRows")||0,l=s.getAttribute("headingColumns")||0;let c=null;for(const n of r)if(n.cell==t){const t=n.row<a||n.column<l?"th":"td";c=e.asWidget?dy(i.createEditableElement(t),i):i.createContainerElement(t);break}return c}}function gM(e={}){return(t,{writer:i})=>{if(!t.parent.is("element","tableCell"))return null;if(!fM(t))return null;if(e.asWidget)return i.createContainerElement("span",{class:"ck-table-bogus-paragraph"});{const e=i.createContainerElement("p");return i.setCustomProperty("dataPipeline:transparentRendering",!0,e),e}}}function fM(e){return 1==e.parent.childCount&&!!e.getAttributeKeys().next().done}class pM extends Da{refresh(){const e=this.editor.model,t=e.document.selection,i=e.schema;this.isEnabled=function(e,t){const i=e.getFirstPosition().parent,n=i===i.root?i:i.parent;return t.checkChild(n,"table")}(t,i)}execute(e={}){const t=this.editor,i=t.model,n=t.plugins.get("TableUtils"),s=t.config.get("table.defaultHeadings.rows"),o=t.config.get("table.defaultHeadings.columns");void 0===e.headingRows&&s&&(e.headingRows=s),void 0===e.headingColumns&&o&&(e.headingColumns=o),i.change((t=>{const s=n.createTable(t,e);i.insertObject(s,null,null,{findOptimalPosition:"auto"}),t.setSelection(t.createPositionAt(s.getNodeByPath([0,0,0]),0))}))}}class bM extends Da{refresh(){const e=this.editor.model.document.selection,t=!!this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(e).length;this.isEnabled=t}execute(){const e=this.editor,t=e.model.document.selection,i=e.plugins.get("TableUtils"),n="above"===this.order,s=i.getSelectionAffectedTableCells(t),o=i.getRowIndexes(s),r=n?o.first:o.last,a=s[0].findAncestor("table");i.insertRows(a,{at:n?r:r+1,copyStructureFromAbove:!n})}constructor(e,t={}){super(e),this.order=t.order||"below"}}class wM extends Da{refresh(){const e=this.editor.model.document.selection,t=!!this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(e).length;this.isEnabled=t}execute(){const e=this.editor,t=e.model.document.selection,i=e.plugins.get("TableUtils"),n="left"===this.order,s=i.getSelectionAffectedTableCells(t),o=i.getColumnIndexes(s),r=n?o.first:o.last,a=s[0].findAncestor("table");i.insertColumns(a,{columns:1,at:n?r:r+1})}constructor(e,t={}){super(e),this.order=t.order||"right"}}class vM extends Da{refresh(){const e=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(this.editor.model.document.selection);this.isEnabled=1===e.length}execute(){const e=this.editor.plugins.get("TableUtils"),t=e.getSelectionAffectedTableCells(this.editor.model.document.selection)[0];"horizontally"===this.direction?e.splitCellHorizontally(t,2):e.splitCellVertically(t,2)}constructor(e,t={}){super(e),this.direction=t.direction||"horizontally"}}function _M(e,t,i){const{startRow:n,startColumn:s,endRow:o,endColumn:r}=t,a=i.createElement("table"),l=o-n+1;for(let e=0;e<l;e++)i.insertElement("tableRow",a,"end");const c=[...new dM(e,{startRow:n,endRow:o,startColumn:s,endColumn:r,includeAllSlots:!0})];for(const{row:e,column:t,cell:l,isAnchor:d,cellAnchorRow:h,cellAnchorColumn:u}of c){const c=e-n,m=a.getChild(c);if(d){const n=i.cloneElement(l);i.append(n,m),AM(n,e,t,o,r,i)}else(h<n||u<s)&&nM(i,i.createPositionAt(m,"end"))}return function(e,t,i,n,s){const o=parseInt(t.getAttribute("headingRows")||"0");if(o>0){iM("headingRows",o-i,e,s,0)}const r=parseInt(t.getAttribute("headingColumns")||"0");if(r>0){iM("headingColumns",r-n,e,s,0)}}(a,e,n,s,i),a}function yM(e,t,i=0){const n=[],s=new dM(e,{startRow:i,endRow:t-1});for(const e of s){const{row:i,cellHeight:s}=e;i<t&&t<=i+s-1&&n.push(e)}return n}function kM(e,t,i){const n=e.parent,s=n.parent,o=n.index,r=t-o,a={},l=parseInt(e.getAttribute("rowspan"))-r;l>1&&(a.rowspan=l);const c=parseInt(e.getAttribute("colspan")||"1");c>1&&(a.colspan=c);const d=o+r,h=[...new dM(s,{startRow:o,endRow:d,includeAllSlots:!0})];let u,m=null;for(const t of h){const{row:n,column:s,cell:o}=t;o===e&&void 0===u&&(u=s),void 0!==u&&u===s&&n===d&&(m=nM(i,t.getPositionBefore(),a))}return iM("rowspan",r,e,i),m}function CM(e,t){const i=[],n=new dM(e);for(const e of n){const{column:n,cellWidth:s}=e;n<t&&t<=n+s-1&&i.push(e)}return i}function xM(e,t,i,n){const s=i-t,o={},r=parseInt(e.getAttribute("colspan"))-s;r>1&&(o.colspan=r);const a=parseInt(e.getAttribute("rowspan")||"1");a>1&&(o.rowspan=a);const l=nM(n,n.createPositionAfter(e),o);return iM("colspan",s,e,n),l}function AM(e,t,i,n,s,o){const r=parseInt(e.getAttribute("colspan")||"1"),a=parseInt(e.getAttribute("rowspan")||"1");if(i+r-1>s){iM("colspan",s-i+1,e,o,1)}if(t+a-1>n){iM("rowspan",n-t+1,e,o,1)}}function EM(e,t){const i=t.getColumns(e),n=new Array(i).fill(0);for(const{column:t}of new dM(e))n[t]++;const s=n.reduce(((e,t,i)=>t?e:[...e,i]),[]);if(s.length>0){const i=s[s.length-1];return t.removeColumns(e,{at:i}),!0}return!1}function TM(e,t){const i=[],n=t.getRows(e);for(let t=0;t<n;t++){e.getChild(t).isEmpty&&i.push(t)}if(i.length>0){const n=i[i.length-1];return t.removeRows(e,{at:n}),!0}return!1}function SM(e,t){EM(e,t)||TM(e,t)}function IM(e,t){const i=Array.from(new dM(e,{startColumn:t.firstColumn,endColumn:t.lastColumn,row:t.lastRow}));if(i.every((({cellHeight:e})=>1===e)))return t.lastRow;const n=i[0].cellHeight-1;return t.lastRow+n}function PM(e,t){const i=Array.from(new dM(e,{startRow:t.firstRow,endRow:t.lastRow,column:t.lastColumn}));if(i.every((({cellWidth:e})=>1===e)))return t.lastColumn;const n=i[0].cellWidth-1;return t.lastColumn+n}class VM extends Da{refresh(){const e=this._getMergeableCell();this.value=e,this.isEnabled=!!e}execute(){const e=this.editor.model,t=e.document,i=this.editor.plugins.get("TableUtils").getTableCellsContainingSelection(t.selection)[0],n=this.value,s=this.direction;e.change((e=>{const t="right"==s||"down"==s,o=t?i:n,r=t?n:i,a=r.parent;!function(e,t,i){RM(e)||(RM(t)&&i.remove(i.createRangeIn(t)),i.move(i.createRangeIn(e),i.createPositionAt(t,"end")));i.remove(e)}(r,o,e);const l=this.isHorizontal?"colspan":"rowspan",c=parseInt(i.getAttribute(l)||"1"),d=parseInt(n.getAttribute(l)||"1");e.setAttribute(l,c+d,o),e.setSelection(e.createRangeIn(o));const h=this.editor.plugins.get("TableUtils");SM(a.findAncestor("table"),h)}))}_getMergeableCell(){const e=this.editor.model.document,t=this.editor.plugins.get("TableUtils"),i=t.getTableCellsContainingSelection(e.selection)[0];if(!i)return;const n=this.isHorizontal?function(e,t,i){const n=e.parent,s=n.parent,o="right"==t?e.nextSibling:e.previousSibling,r=(s.getAttribute("headingColumns")||0)>0;if(!o)return;const a="right"==t?e:o,l="right"==t?o:e,{column:c}=i.getCellLocation(a),{column:d}=i.getCellLocation(l),h=parseInt(a.getAttribute("colspan")||"1"),u=sM(i,a),m=sM(i,l);if(r&&u!=m)return;return c+h===d?o:void 0}(i,this.direction,t):function(e,t,i){const n=e.parent,s=n.parent,o=s.getChildIndex(n);if("down"==t&&o===i.getRows(s)-1||"up"==t&&0===o)return null;const r=parseInt(e.getAttribute("rowspan")||"1"),a=s.getAttribute("headingRows")||0,l="down"==t&&o+r===a,c="up"==t&&o===a;if(a&&(l||c))return null;const d=parseInt(e.getAttribute("rowspan")||"1"),h="down"==t?o+d:o,u=[...new dM(s,{endRow:h})],m=u.find((t=>t.cell===e)),g=m.column,f=u.find((({row:e,cellHeight:i,column:n})=>n===g&&("down"==t?e===h:h===e+i)));return f&&f.cell?f.cell:null}(i,this.direction,t);if(!n)return;const s=this.isHorizontal?"rowspan":"colspan",o=parseInt(i.getAttribute(s)||"1");return parseInt(n.getAttribute(s)||"1")===o?n:void 0}constructor(e,t){super(e),this.direction=t.direction,this.isHorizontal="right"==this.direction||"left"==this.direction}}function RM(e){const t=e.getChild(0);return 1==e.childCount&&t.is("element","paragraph")&&t.isEmpty}class BM extends Da{refresh(){const e=this.editor.plugins.get("TableUtils"),t=e.getSelectionAffectedTableCells(this.editor.model.document.selection),i=t[0];if(i){const n=i.findAncestor("table"),s=e.getRows(n)-1,o=e.getRowIndexes(t),r=0===o.first&&o.last===s;this.isEnabled=!r}else this.isEnabled=!1}execute(){const e=this.editor.model,t=this.editor.plugins.get("TableUtils"),i=t.getSelectionAffectedTableCells(e.document.selection),n=t.getRowIndexes(i),s=i[0],o=s.findAncestor("table"),r=t.getCellLocation(s).column;e.change((e=>{const i=n.last-n.first+1;t.removeRows(o,{at:n.first,rows:i});const s=function(e,t,i,n){const s=e.getChild(Math.min(t,n-1));let o=s.getChild(0),r=0;for(const e of s.getChildren()){if(r>i)return o;o=e,r+=parseInt(e.getAttribute("colspan")||"1")}return o}(o,n.first,r,t.getRows(o));e.setSelection(e.createPositionAt(s,0))}))}}class OM extends Da{refresh(){const e=this.editor.plugins.get("TableUtils"),t=e.getSelectionAffectedTableCells(this.editor.model.document.selection),i=t[0];if(i){const n=i.findAncestor("table"),s=e.getColumns(n),{first:o,last:r}=e.getColumnIndexes(t);this.isEnabled=r-o<s-1}else this.isEnabled=!1}execute(){const e=this.editor.plugins.get("TableUtils"),[t,i]=function(e,t){const i=t.getSelectionAffectedTableCells(e),n=i[0],s=i.pop(),o=[n,s];return n.isBefore(s)?o:o.reverse()}(this.editor.model.document.selection,e),n=t.parent.parent,s=[...new dM(n)],o={first:s.find((e=>e.cell===t)).column,last:s.find((e=>e.cell===i)).column},r=function(e,t,i,n){const s=parseInt(i.getAttribute("colspan")||"1");return s>1?i:t.previousSibling||i.nextSibling?i.nextSibling||t.previousSibling:n.first?e.reverse().find((({column:e})=>e<n.first)).cell:e.reverse().find((({column:e})=>e>n.last)).cell}(s,t,i,o);this.editor.model.change((t=>{const i=o.last-o.first+1;e.removeColumns(n,{at:o.first,columns:i}),t.setSelection(t.createPositionAt(r,0))}))}}class MM extends Da{refresh(){const e=this.editor.plugins.get("TableUtils"),t=this.editor.model,i=e.getSelectionAffectedTableCells(t.document.selection),n=i.length>0;this.isEnabled=n,this.value=n&&i.every((e=>this._isInHeading(e,e.parent.parent)))}execute(e={}){if(e.forceValue===this.value)return;const t=this.editor.plugins.get("TableUtils"),i=this.editor.model,n=t.getSelectionAffectedTableCells(i.document.selection),s=n[0].findAncestor("table"),{first:o,last:r}=t.getRowIndexes(n),a=this.value?o:r+1,l=s.getAttribute("headingRows")||0;i.change((e=>{if(a){const t=yM(s,a,a>l?l:0);for(const{cell:i}of t)kM(i,a,e)}iM("headingRows",a,s,e,0)}))}_isInHeading(e,t){const i=parseInt(t.getAttribute("headingRows")||"0");return!!i&&e.parent.index<i}}class LM extends Da{refresh(){const e=this.editor.model,t=this.editor.plugins.get("TableUtils"),i=t.getSelectionAffectedTableCells(e.document.selection),n=i.length>0;this.isEnabled=n,this.value=n&&i.every((e=>sM(t,e)))}execute(e={}){if(e.forceValue===this.value)return;const t=this.editor.plugins.get("TableUtils"),i=this.editor.model,n=t.getSelectionAffectedTableCells(i.document.selection),s=n[0].findAncestor("table"),{first:o,last:r}=t.getColumnIndexes(n),a=this.value?o:r+1;i.change((e=>{if(a){const t=CM(s,a);for(const{cell:i,column:n}of t)xM(i,n,a,e)}iM("headingColumns",a,s,e,0)}))}}const NM=5,FM=2;function DM(e,t){return 4e3/zM(e,t)}function zM(e,t){const i=HM(e,"tbody",t)||HM(e,"thead",t);return $M(t.editing.view.domConverter.mapViewToDom(i))}function HM(e,t,i){return[...[...i.editing.mapper.toViewElement(e).getChildren()].find((e=>e.is("element","table"))).getChildren()].find((e=>e.is("element",t)))}function $M(e){const t=_r.window.getComputedStyle(e);return"border-box"===t.boxSizing?parseFloat(t.width)-parseFloat(t.paddingLeft)-parseFloat(t.paddingRight)-parseFloat(t.borderLeftWidth)-parseFloat(t.borderRightWidth):parseFloat(t.width)}function UM(e){const t=Math.pow(10,FM),i="number"==typeof e?e:parseFloat(e);return Math.round(i*t)/t}function WM(e){return e.map((e=>"number"==typeof e?e:parseFloat(e))).filter((e=>!Number.isNaN(e))).reduce(((e,t)=>e+t),0)}function jM(e){let t=function(e){const t=e.filter((e=>"auto"===e)).length;if(0===t)return e.map((e=>UM(e)));const i=WM(e),n=Math.max((100-i)/t,NM);return e.map((e=>"auto"===e?n:e)).map((e=>UM(e)))}(e.map((e=>"auto"===e?e:parseFloat(e.replace("%","")))));const i=WM(t);return 100!==i&&(t=t.map((e=>UM(100*e/i))).map(((e,t,i)=>{if(!(t===i.length-1))return e;return UM(e+100-WM(i))}))),t.map((e=>e+"%"))}function qM(e){const t=_r.window.getComputedStyle(e);return"border-box"===t.boxSizing?parseInt(t.width):parseFloat(t.width)+parseFloat(t.paddingLeft)+parseFloat(t.paddingRight)+parseFloat(t.borderWidth)}function GM(e,t,i,n){for(let s=0;s<Math.max(i.length,e.length);s++){const o=e[s],r=i[s];r?o?n.setAttribute("columnWidth",r,o):n.appendElement("tableColumn",{columnWidth:r},t):n.remove(o)}}function KM(e){if(e.is("element","tableColumnGroup"))return e;const t=e.getChildren();return Array.from(t).find((e=>e.is("element","tableColumnGroup")))}function ZM(e){const t=KM(e);return t?Array.from(t.getChildren()):[]}class JM extends Na{static get pluginName(){return"TableUtils"}init(){this.decorate("insertColumns"),this.decorate("insertRows")}getCellLocation(e){const t=e.parent,i=t.parent,n=i.getChildIndex(t),s=new dM(i,{row:n});for(const{cell:t,row:i,column:n}of s)if(t===e)return{row:i,column:n}}createTable(e,t){const i=e.createElement("table"),n=t.rows||2,s=t.columns||2;return QM(e,i,0,n,s),t.headingRows&&iM("headingRows",Math.min(t.headingRows,n),i,e,0),t.headingColumns&&iM("headingColumns",Math.min(t.headingColumns,s),i,e,0),i}insertRows(e,t={}){const i=this.editor.model,n=t.at||0,s=t.rows||1,o=void 0!==t.copyStructureFromAbove,r=t.copyStructureFromAbove?n-1:n,a=this.getRows(e),l=this.getColumns(e);if(n>a)throw new p("tableutils-insertrows-insert-out-of-range",this,{options:t});i.change((t=>{const i=e.getAttribute("headingRows")||0;if(i>n&&iM("headingRows",i+s,e,t,0),!o&&(0===n||n===a))return void QM(t,e,n,s,l);const c=o?Math.max(n,r):n,d=new dM(e,{endRow:c}),h=new Array(l).fill(1);for(const{row:e,column:i,cellHeight:a,cellWidth:l,cell:c}of d){const d=e+a-1,u=e<=r&&r<=d;e<n&&n<=d?(t.setAttribute("rowspan",a+s,c),h[i]=-l):o&&u&&(h[i]=l)}for(let i=0;i<s;i++){const i=t.createElement("tableRow");t.insert(i,e,n);for(let e=0;e<h.length;e++){const n=h[e],s=t.createPositionAt(i,"end");n>0&&nM(t,s,n>1?{colspan:n}:void 0),e+=Math.abs(n)-1}}}))}insertColumns(e,t={}){const i=this.editor.model,n=t.at||0,s=t.columns||1;i.change((t=>{const i=e.getAttribute("headingColumns");n<i&&t.setAttribute("headingColumns",i+s,e);const o=this.getColumns(e);if(0===n||o===n){for(const i of e.getChildren())i.is("element","tableRow")&&YM(s,t,t.createPositionAt(i,n?"end":0));return}const r=new dM(e,{column:n,includeAllSlots:!0});for(const e of r){const{row:i,cell:o,cellAnchorColumn:a,cellAnchorRow:l,cellWidth:c,cellHeight:d}=e;if(a<n){t.setAttribute("colspan",c+s,o);const e=l+d-1;for(let t=i;t<=e;t++)r.skipRow(t)}else YM(s,t,e.getPositionBefore())}}))}removeRows(e,t){const i=this.editor.model,n=t.rows||1,s=this.getRows(e),o=t.at,r=o+n-1;if(r>s-1)throw new p("tableutils-removerows-row-index-out-of-range",this,{table:e,options:t});i.change((t=>{const i={first:o,last:r},{cellsToMove:n,cellsToTrim:s}=function(e,{first:t,last:i}){const n=new Map,s=[];for(const{row:o,column:r,cellHeight:a,cell:l}of new dM(e,{endRow:i})){const e=o+a-1;if(o>=t&&o<=i&&e>i){const e=a-(i-o+1);n.set(r,{cell:l,rowspan:e})}if(o<t&&e>=t){let n;n=e>=i?i-t+1:e-t+1,s.push({cell:l,rowspan:a-n})}}return{cellsToMove:n,cellsToTrim:s}}(e,i);if(n.size){!function(e,t,i,n){const s=new dM(e,{includeAllSlots:!0,row:t}),o=[...s],r=e.getChild(t);let a;for(const{column:e,cell:t,isAnchor:s}of o)if(i.has(e)){const{cell:t,rowspan:s}=i.get(e),o=a?n.createPositionAfter(a):n.createPositionAt(r,0);n.move(n.createRangeOn(t),o),iM("rowspan",s,t,n),a=t}else s&&(a=t)}(e,r+1,n,t)}for(let i=r;i>=o;i--)t.remove(e.getChild(i));for(const{rowspan:e,cell:i}of s)iM("rowspan",e,i,t);!function(e,{first:t,last:i},n){const s=e.getAttribute("headingRows")||0;if(t<s){iM("headingRows",i<s?s-(i-t+1):t,e,n,0)}}(e,i,t),EM(e,this)||TM(e,this)}))}removeColumns(e,t){const i=this.editor.model,n=t.at,s=t.columns||1,o=t.at+s-1;i.change((t=>{!function(e,t,i){const n=e.getAttribute("headingColumns")||0;if(n&&t.first<n){const s=Math.min(n-1,t.last)-t.first+1;i.setAttribute("headingColumns",n-s,e)}}(e,{first:n,last:o},t);const i=ZM(e);for(let s=o;s>=n;s--){for(const{cell:i,column:n,cellWidth:o}of[...new dM(e)])n<=s&&o>1&&n+o>s?iM("colspan",o-1,i,t):n===s&&t.remove(i);if(i[s]){const e=0===s?i[1]:i[s-1],n=parseFloat(i[s].getAttribute("columnWidth")),o=parseFloat(e.getAttribute("columnWidth"));t.remove(i[s]),t.setAttribute("columnWidth",n+o+"%",e)}}TM(e,this)||EM(e,this)}))}splitCellVertically(e,t=2){const i=this.editor.model,n=e.parent.parent,s=parseInt(e.getAttribute("rowspan")||"1"),o=parseInt(e.getAttribute("colspan")||"1");i.change((i=>{if(o>1){const{newCellsSpan:n,updatedSpan:r}=XM(o,t);iM("colspan",r,e,i);const a={};n>1&&(a.colspan=n),s>1&&(a.rowspan=s);YM(o>t?t-1:o-1,i,i.createPositionAfter(e),a)}if(o<t){const r=t-o,a=[...new dM(n)],{column:l}=a.find((({cell:t})=>t===e)),c=a.filter((({cell:t,cellWidth:i,column:n})=>t!==e&&n===l||n<l&&n+i>l));for(const{cell:e,cellWidth:t}of c)i.setAttribute("colspan",t+r,e);const d={};s>1&&(d.rowspan=s),YM(r,i,i.createPositionAfter(e),d);const h=n.getAttribute("headingColumns")||0;h>l&&iM("headingColumns",h+r,n,i)}}))}splitCellHorizontally(e,t=2){const i=this.editor.model,n=e.parent,s=n.parent,o=s.getChildIndex(n),r=parseInt(e.getAttribute("rowspan")||"1"),a=parseInt(e.getAttribute("colspan")||"1");i.change((i=>{if(r>1){const n=[...new dM(s,{startRow:o,endRow:o+r-1,includeAllSlots:!0})],{newCellsSpan:l,updatedSpan:c}=XM(r,t);iM("rowspan",c,e,i);const{column:d}=n.find((({cell:t})=>t===e)),h={};l>1&&(h.rowspan=l),a>1&&(h.colspan=a);for(const e of n){const{column:t,row:n}=e;n>=o+c&&t===d&&(n+o+c)%l==0&&YM(1,i,e.getPositionBefore(),h)}}if(r<t){const n=t-r,l=[...new dM(s,{startRow:0,endRow:o})];for(const{cell:t,cellHeight:s,row:r}of l)if(t!==e&&r+s>o){const e=s+n;i.setAttribute("rowspan",e,t)}const c={};a>1&&(c.colspan=a),QM(i,s,o+1,n,1,c);const d=s.getAttribute("headingRows")||0;d>o&&iM("headingRows",d+n,s,i)}}))}getColumns(e){return[...e.getChild(0).getChildren()].filter((e=>e.is("element","tableCell"))).reduce(((e,t)=>e+parseInt(t.getAttribute("colspan")||"1")),0)}getRows(e){return Array.from(e.getChildren()).reduce(((e,t)=>t.is("element","tableRow")?e+1:e),0)}createTableWalker(e,t={}){return new dM(e,t)}getSelectedTableCells(e){const t=[];for(const i of this.sortRanges(e.getRanges())){const e=i.getContainedElement();e&&e.is("element","tableCell")&&t.push(e)}return t}getTableCellsContainingSelection(e){const t=[];for(const i of e.getRanges()){const e=i.start.findAncestor("tableCell");e&&t.push(e)}return t}getSelectionAffectedTableCells(e){const t=this.getSelectedTableCells(e);return t.length?t:this.getTableCellsContainingSelection(e)}getRowIndexes(e){const t=e.map((e=>e.parent.index));return this._getFirstLastIndexesObject(t)}getColumnIndexes(e){const t=e[0].findAncestor("table"),i=[...new dM(t)].filter((t=>e.includes(t.cell))).map((e=>e.column));return this._getFirstLastIndexesObject(i)}isSelectionRectangular(e){if(e.length<2||!this._areCellInTheSameTableSection(e))return!1;const t=new Set,i=new Set;let n=0;for(const s of e){const{row:e,column:o}=this.getCellLocation(s),r=parseInt(s.getAttribute("rowspan"))||1,a=parseInt(s.getAttribute("colspan"))||1;t.add(e),i.add(o),r>1&&t.add(e+r-1),a>1&&i.add(o+a-1),n+=r*a}const s=function(e,t){const i=Array.from(e.values()),n=Array.from(t.values()),s=Math.max(...i),o=Math.min(...i),r=Math.max(...n),a=Math.min(...n);return(s-o+1)*(r-a+1)}(t,i);return s==n}sortRanges(e){return Array.from(e).sort(eL)}_getFirstLastIndexesObject(e){const t=e.sort(((e,t)=>e-t));return{first:t[0],last:t[t.length-1]}}_areCellInTheSameTableSection(e){const t=e[0].findAncestor("table"),i=this.getRowIndexes(e),n=parseInt(t.getAttribute("headingRows"))||0;if(!this._areIndexesInSameSection(i,n))return!1;const s=this.getColumnIndexes(e),o=parseInt(t.getAttribute("headingColumns"))||0;return this._areIndexesInSameSection(s,o)}_areIndexesInSameSection({first:e,last:t},i){return e<i===t<i}}function QM(e,t,i,n,s,o={}){for(let r=0;r<n;r++){const n=e.createElement("tableRow");e.insert(n,t,i),YM(s,e,e.createPositionAt(n,"end"),o)}}function YM(e,t,i,n={}){for(let s=0;s<e;s++)nM(t,i,n)}function XM(e,t){if(e<t)return{newCellsSpan:1,updatedSpan:1};const i=Math.floor(e/t);return{newCellsSpan:i,updatedSpan:e-i*t+i}}function eL(e,t){const i=e.start,n=t.start;return i.isBefore(n)?-1:1}class tL extends Da{refresh(){const e=this.editor.plugins.get(JM),t=e.getSelectedTableCells(this.editor.model.document.selection);this.isEnabled=e.isSelectionRectangular(t)}execute(){const e=this.editor.model,t=this.editor.plugins.get(JM);e.change((i=>{const n=t.getSelectedTableCells(e.document.selection),s=n.shift(),{mergeWidth:o,mergeHeight:r}=function(e,t,i){let n=0,s=0;for(const e of t){const{row:t,column:o}=i.getCellLocation(e);n=sL(e,o,n,"colspan"),s=sL(e,t,s,"rowspan")}const{row:o,column:r}=i.getCellLocation(e),a=n-r,l=s-o;return{mergeWidth:a,mergeHeight:l}}(s,n,t);iM("colspan",o,s,i),iM("rowspan",r,s,i);for(const e of n)iL(e,s,i);SM(s.findAncestor("table"),t),i.setSelection(s,"in")}))}}function iL(e,t,i){nL(e)||(nL(t)&&i.remove(i.createRangeIn(t)),i.move(i.createRangeIn(e),i.createPositionAt(t,"end"))),i.remove(e)}function nL(e){const t=e.getChild(0);return 1==e.childCount&&t.is("element","paragraph")&&t.isEmpty}function sL(e,t,i,n){const s=parseInt(e.getAttribute(n)||"1");return Math.max(i,t+s)}class oL extends Da{refresh(){const e=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(this.editor.model.document.selection);this.isEnabled=e.length>0}execute(){const e=this.editor.model,t=this.editor.plugins.get("TableUtils"),i=t.getSelectionAffectedTableCells(e.document.selection),n=t.getRowIndexes(i),s=i[0].findAncestor("table"),o=[];for(let t=n.first;t<=n.last;t++)for(const i of s.getChild(t).getChildren())o.push(e.createRangeOn(i));e.change((e=>{e.setSelection(o)}))}constructor(e){super(e),this.affectsData=!1}}class rL extends Da{refresh(){const e=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(this.editor.model.document.selection);this.isEnabled=e.length>0}execute(){const e=this.editor.plugins.get("TableUtils"),t=this.editor.model,i=e.getSelectionAffectedTableCells(t.document.selection),n=i[0],s=i.pop(),o=n.findAncestor("table"),r=e.getCellLocation(n),a=e.getCellLocation(s),l=Math.min(r.column,a.column),c=Math.max(r.column,a.column),d=[];for(const e of new dM(o,{startColumn:l,endColumn:c}))d.push(t.createRangeOn(e.cell));t.change((e=>{e.setSelection(d)}))}constructor(e){super(e),this.affectsData=!1}}function aL(e){e.document.registerPostFixer((t=>function(e,t){const i=t.document.differ.getChanges();let n=!1;const s=new Set;for(const t of i){let i=null;"insert"==t.type&&"table"==t.name&&(i=t.position.nodeAfter),"insert"!=t.type&&"remove"!=t.type||"tableRow"!=t.name&&"tableCell"!=t.name||(i=t.position.findAncestor("table")),dL(t)&&(i=t.range.start.findAncestor("table")),i&&!s.has(i)&&(n=lL(i,e)||n,n=cL(i,e)||n,s.add(i))}return n}(t,e)))}function lL(e,t){let i=!1;const n=function(e){const t=parseInt(e.getAttribute("headingRows")||"0"),i=Array.from(e.getChildren()).reduce(((e,t)=>t.is("element","tableRow")?e+1:e),0),n=[];for(const{row:s,cell:o,cellHeight:r}of new dM(e)){if(r<2)continue;const e=s<t?t:i;if(s+r>e){const t=e-s;n.push({cell:o,rowspan:t})}}return n}(e);if(n.length){i=!0;for(const e of n)iM("rowspan",e.rowspan,e.cell,t,1)}return i}function cL(e,t){let i=!1;const n=function(e){const t=new Array(e.childCount).fill(0);for(const{rowIndex:i}of new dM(e,{includeAllSlots:!0}))t[i]++;return t}(e),s=[];for(const[t,i]of n.entries())!i&&e.getChild(t).is("element","tableRow")&&s.push(t);if(s.length){i=!0;for(const i of s.reverse())t.remove(e.getChild(i)),n.splice(i,1)}const o=n.filter(((t,i)=>e.getChild(i).is("element","tableRow"))),r=o[0];if(!o.every((e=>e===r))){const n=o.reduce(((e,t)=>t>e?t:e),0);for(const[s,r]of o.entries()){const o=n-r;if(o){for(let i=0;i<o;i++)nM(t,t.createPositionAt(e.getChild(s),"end"));i=!0}}}return i}function dL(e){if("attribute"!==e.type)return!1;const t=e.attributeKey;return"headingRows"===t||"colspan"===t||"rowspan"===t}function hL(e){e.document.registerPostFixer((t=>function(e,t){const i=t.document.differ.getChanges();let n=!1;for(const t of i)"insert"==t.type&&"table"==t.name&&(n=uL(t.position.nodeAfter,e)||n),"insert"==t.type&&"tableRow"==t.name&&(n=mL(t.position.nodeAfter,e)||n),"insert"==t.type&&"tableCell"==t.name&&(n=gL(t.position.nodeAfter,e)||n),"remove"!=t.type&&"insert"!=t.type||!fL(t)||(n=gL(t.position.parent,e)||n);return n}(t,e)))}function uL(e,t){let i=!1;for(const n of e.getChildren())n.is("element","tableRow")&&(i=mL(n,t)||i);return i}function mL(e,t){let i=!1;for(const n of e.getChildren())i=gL(n,t)||i;return i}function gL(e,t){if(0==e.childCount)return t.insertElement("paragraph",e),!0;const i=Array.from(e.getChildren()).filter((e=>e.is("$text")));for(const e of i)t.wrap(t.createRangeOn(e),"paragraph");return!!i.length}function fL(e){return!!e.position.parent.is("element","tableCell")&&("insert"==e.type&&"$text"==e.name||"remove"==e.type)}function pL(e,t){if(!e.is("element","paragraph"))return!1;const i=t.toViewElement(e);return!!i&&fM(e)!==i.is("element","span")}class bL extends Na{static get pluginName(){return"TableEditing"}static get requires(){return[JM]}init(){const e=this.editor,t=e.model,i=t.schema,n=e.conversion,s=e.plugins.get(JM);i.register("table",{inheritAllFrom:"$blockObject",allowAttributes:["headingRows","headingColumns"]}),i.register("tableRow",{allowIn:"table",isLimit:!0}),i.register("tableCell",{allowContentOf:"$container",allowIn:"tableRow",allowAttributes:["colspan","rowspan"],isLimit:!0,isSelectable:!0}),n.for("upcast").add((e=>{e.on("element:figure",((e,t,i)=>{if(!i.consumable.test(t.viewItem,{name:!0,classes:"table"}))return;const n=function(e){for(const t of e.getChildren())if(t.is("element","table"))return t}(t.viewItem);if(!n||!i.consumable.test(n,{name:!0}))return;i.consumable.consume(t.viewItem,{name:!0,classes:"table"});const s=_a(i.convertItem(n,t.modelCursor).modelRange.getItems());s?(i.convertChildren(t.viewItem,i.writer.createPositionAt(s,"end")),i.updateConversionResult(s,t)):i.consumable.revert(t.viewItem,{name:!0,classes:"table"})}))})),n.for("upcast").add(aM()),n.for("editingDowncast").elementToStructure({model:{name:"table",attributes:["headingRows"]},view:uM(s,{asWidget:!0,additionalSlots:this._additionalSlots})}),n.for("dataDowncast").elementToStructure({model:{name:"table",attributes:["headingRows"]},view:uM(s,{additionalSlots:this._additionalSlots})}),n.for("upcast").elementToElement({model:"tableRow",view:"tr"}),n.for("upcast").add((e=>{e.on("element:tr",((e,t)=>{t.viewItem.isEmpty&&0==t.modelCursor.index&&e.stop()}),{priority:"high"})})),n.for("downcast").elementToElement({model:"tableRow",view:(e,{writer:t})=>e.isEmpty?t.createEmptyElement("tr"):t.createContainerElement("tr")}),n.for("upcast").elementToElement({model:"tableCell",view:"td"}),n.for("upcast").elementToElement({model:"tableCell",view:"th"}),n.for("upcast").add(lM("td")),n.for("upcast").add(lM("th")),n.for("editingDowncast").elementToElement({model:"tableCell",view:mM({asWidget:!0})}),n.for("dataDowncast").elementToElement({model:"tableCell",view:mM()}),n.for("editingDowncast").elementToElement({model:"paragraph",view:gM({asWidget:!0}),converterPriority:"high"}),n.for("dataDowncast").elementToElement({model:"paragraph",view:gM(),converterPriority:"high"}),n.for("downcast").attributeToAttribute({model:"colspan",view:"colspan"}),n.for("upcast").attributeToAttribute({model:{key:"colspan",value:wL("colspan")},view:"colspan"}),n.for("downcast").attributeToAttribute({model:"rowspan",view:"rowspan"}),n.for("upcast").attributeToAttribute({model:{key:"rowspan",value:wL("rowspan")},view:"rowspan"}),e.config.define("table.defaultHeadings.rows",0),e.config.define("table.defaultHeadings.columns",0),e.commands.add("insertTable",new pM(e)),e.commands.add("insertTableRowAbove",new bM(e,{order:"above"})),e.commands.add("insertTableRowBelow",new bM(e,{order:"below"})),e.commands.add("insertTableColumnLeft",new wM(e,{order:"left"})),e.commands.add("insertTableColumnRight",new wM(e,{order:"right"})),e.commands.add("removeTableRow",new BM(e)),e.commands.add("removeTableColumn",new OM(e)),e.commands.add("splitTableCellVertically",new vM(e,{direction:"vertically"})),e.commands.add("splitTableCellHorizontally",new vM(e,{direction:"horizontally"})),e.commands.add("mergeTableCells",new tL(e)),e.commands.add("mergeTableCellRight",new VM(e,{direction:"right"})),e.commands.add("mergeTableCellLeft",new VM(e,{direction:"left"})),e.commands.add("mergeTableCellDown",new VM(e,{direction:"down"})),e.commands.add("mergeTableCellUp",new VM(e,{direction:"up"})),e.commands.add("setTableColumnHeader",new LM(e)),e.commands.add("setTableRowHeader",new MM(e)),e.commands.add("selectTableRow",new oL(e)),e.commands.add("selectTableColumn",new rL(e)),aL(t),hL(t),this.listenTo(t.document,"change:data",(()=>{!function(e,t){const i=e.document.differ;for(const e of i.getChanges()){let i,n=!1;if("attribute"==e.type){const t=e.range.start.nodeAfter;if(!t||!t.is("element","table"))continue;if("headingRows"!=e.attributeKey&&"headingColumns"!=e.attributeKey)continue;i=t,n="headingRows"==e.attributeKey}else"tableRow"!=e.name&&"tableCell"!=e.name||(i=e.position.findAncestor("table"),n="tableRow"==e.name);if(!i)continue;const s=i.getAttribute("headingRows")||0,o=i.getAttribute("headingColumns")||0,r=new dM(i);for(const e of r){const i=e.row<s||e.column<o?"th":"td",r=t.mapper.toViewElement(e.cell);r&&r.is("element")&&r.name!=i&&t.reconvertItem(n?e.cell.parent:e.cell)}}}(t,e.editing),function(e,t){const i=e.document.differ,n=new Set;for(const e of i.getChanges()){const t="attribute"==e.type?e.range.start.parent:e.position.parent;t.is("element","tableCell")&&n.add(t)}for(const e of n.values()){const i=Array.from(e.getChildren()).filter((e=>pL(e,t.mapper)));for(const e of i)t.reconvertItem(e)}}(t,e.editing)}))}registerAdditionalSlot(e){this._additionalSlots.push(e)}constructor(e){super(e),this._additionalSlots=[]}}function wL(e){return t=>{const i=parseInt(t.getAttribute(e));return Number.isNaN(i)||i<=0?null:i}}class vL extends Tg{render(){super.render(),Rg({keystrokeHandler:this.keystrokes,focusTracker:this.focusTracker,gridItems:this.items,numberOfColumns:10,uiLanguageDirection:this.locale&&this.locale.uiLanguageDirection});for(const e of this.items)this.focusTracker.add(e.element);this.keystrokes.listenTo(this.element)}reset(){this.set({rows:1,columns:1})}focus(){this.items.get(0).focus()}focusLast(){this.items.get(0).focus()}_highlightGridBoxes(){const e=this.rows,t=this.columns;this.items.map(((i,n)=>{const s=Math.floor(n/10)<e&&n%10<t;i.set("isOn",s)}))}_createGridButton(e,t,i,n){const s=new Hg(e);return s.set({label:n,class:"ck-insert-table-dropdown-grid-box"}),s.extendTemplate({attributes:{"data-row":t,"data-column":i}}),s}_createGridCollection(){const e=[];for(let t=0;t<100;t++){const i=Math.floor(t/10),n=t%10,s=`${i+1} × ${n+1}`;e.push(this._createGridButton(this.locale,i+1,n+1,s))}return this.createCollection(e)}constructor(e){super(e);const t=this.bindTemplate;this.items=this._createGridCollection(),this.keystrokes=new ka,this.focusTracker=new ya,this.set("rows",0),this.set("columns",0),this.bind("label").to(this,"columns",this,"rows",((e,t)=>`${t} × ${e}`)),this.setTemplate({tag:"div",attributes:{class:["ck"]},children:[{tag:"div",attributes:{class:["ck-insert-table-dropdown__grid"]},on:{"mouseover@.ck-insert-table-dropdown-grid-box":t.to("boxover")},children:this.items},{tag:"div",attributes:{class:["ck","ck-insert-table-dropdown__label"],"aria-hidden":!0},children:[{text:t.to("label")}]}],on:{mousedown:t.to((e=>{e.preventDefault()})),click:t.to((()=>{this.fire("execute")}))}}),this.on("boxover",((e,t)=>{const{row:i,column:n}=t.target.dataset;this.items.get(10*(parseInt(i,10)-1)+(parseInt(n,10)-1)).focus()})),this.focusTracker.on("change:focusedElement",((e,t,i)=>{if(!i)return;const{row:n,column:s}=i.dataset;this.set({rows:parseInt(n),columns:parseInt(s)})})),this.on("change:columns",(()=>this._highlightGridBoxes())),this.on("change:rows",(()=>this._highlightGridBoxes()))}}class _L extends Na{static get pluginName(){return"TableUI"}init(){const e=this.editor,t=this.editor.t,i="ltr"===e.locale.contentLanguageDirection;e.ui.componentFactory.add("insertTable",(i=>{const n=e.commands.get("insertTable"),s=Wf(i);let o;return s.bind("isEnabled").to(n),s.buttonView.set({icon:Dm.table,label:t("Insert table"),tooltip:!0}),s.on("change:isOpen",(()=>{o||(o=new vL(i),s.panelView.children.add(o),o.delegate("execute").to(s),s.on("execute",(()=>{e.execute("insertTable",{rows:o.rows,columns:o.columns}),e.editing.view.focus()})))})),s})),e.ui.componentFactory.add("menuBar:insertTable",(i=>{const n=e.commands.get("insertTable"),s=new dw(i),o=new vL(i);return o.delegate("execute").to(s),s.on("change:isOpen",((e,t,i)=>{i||o.reset()})),o.on("execute",(()=>{e.execute("insertTable",{rows:o.rows,columns:o.columns}),e.editing.view.focus()})),s.buttonView.set({label:t("Table"),icon:Dm.table}),s.panelView.children.add(o),s.bind("isEnabled").to(n),s})),e.ui.componentFactory.add("tableColumn",(e=>{const n=[{type:"switchbutton",model:{commandName:"setTableColumnHeader",label:t("Header column"),bindIsOn:!0}},{type:"separator"},{type:"button",model:{commandName:i?"insertTableColumnLeft":"insertTableColumnRight",label:t("Insert column left")}},{type:"button",model:{commandName:i?"insertTableColumnRight":"insertTableColumnLeft",label:t("Insert column right")}},{type:"button",model:{commandName:"removeTableColumn",label:t("Delete column")}},{type:"button",model:{commandName:"selectTableColumn",label:t("Select column")}}];return this._prepareDropdown(t("Column"),'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2.5 1h15A1.5 1.5 0 0 1 19 2.5v15a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 1 17.5v-15A1.5 1.5 0 0 1 2.5 1zM2 2v16h16V2H2z" opacity=".6"/><path d="M18 7v1H2V7h16zm0 5v1H2v-1h16z" opacity=".6"/><path d="M14 1v18a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V1a1 1 0 0 1 1-1h6a1 1 0 0 1 1 1zm-2 1H8v4h4V2zm0 6H8v4h4V8zm0 6H8v4h4v-4z"/></svg>',n,e)})),e.ui.componentFactory.add("tableRow",(e=>{const i=[{type:"switchbutton",model:{commandName:"setTableRowHeader",label:t("Header row"),bindIsOn:!0}},{type:"separator"},{type:"button",model:{commandName:"insertTableRowAbove",label:t("Insert row above")}},{type:"button",model:{commandName:"insertTableRowBelow",label:t("Insert row below")}},{type:"button",model:{commandName:"removeTableRow",label:t("Delete row")}},{type:"button",model:{commandName:"selectTableRow",label:t("Select row")}}];return this._prepareDropdown(t("Row"),'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2.5 1h15A1.5 1.5 0 0 1 19 2.5v15a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 1 17.5v-15A1.5 1.5 0 0 1 2.5 1zM2 2v16h16V2H2z" opacity=".6"/><path d="M7 2h1v16H7V2zm5 0h1v16h-1V2z" opacity=".6"/><path d="M1 6h18a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1H1a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1zm1 2v4h4V8H2zm6 0v4h4V8H8zm6 0v4h4V8h-4z"/></svg>',i,e)})),e.ui.componentFactory.add("mergeTableCells",(e=>{const n=[{type:"button",model:{commandName:"mergeTableCellUp",label:t("Merge cell up")}},{type:"button",model:{commandName:i?"mergeTableCellRight":"mergeTableCellLeft",label:t("Merge cell right")}},{type:"button",model:{commandName:"mergeTableCellDown",label:t("Merge cell down")}},{type:"button",model:{commandName:i?"mergeTableCellLeft":"mergeTableCellRight",label:t("Merge cell left")}},{type:"separator"},{type:"button",model:{commandName:"splitTableCellVertically",label:t("Split cell vertically")}},{type:"button",model:{commandName:"splitTableCellHorizontally",label:t("Split cell horizontally")}}];return this._prepareMergeSplitButtonDropdown(t("Merge cells"),'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2.5 1h15A1.5 1.5 0 0 1 19 2.5v15a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 1 17.5v-15A1.5 1.5 0 0 1 2.5 1zM2 2v16h16V2H2z" opacity=".6"/><path d="M7 2h1v16H7V2zm5 0h1v7h-1V2zm6 5v1H2V7h16zM8 12v1H2v-1h6z" opacity=".6"/><path d="M7 7h12a1 1 0 0 1 1 1v11a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V8a1 1 0 0 1 1-1zm1 2v9h10V9H8z"/></svg>',n,e)}))}_prepareDropdown(e,t,i,n){const s=this.editor,o=Wf(n),r=this._fillDropdownWithListOptions(o,i);return o.buttonView.set({label:e,icon:t,tooltip:!0}),o.bind("isEnabled").toMany(r,"isEnabled",((...e)=>e.some((e=>e)))),this.listenTo(o,"execute",(e=>{s.execute(e.source.commandName),e.source instanceof $g||s.editing.view.focus()})),o}_prepareMergeSplitButtonDropdown(e,t,i,n){const s=this.editor,o=Wf(n,Uf),r="mergeTableCells",a=s.commands.get(r),l=this._fillDropdownWithListOptions(o,i);return o.buttonView.set({label:e,icon:t,tooltip:!0,isEnabled:!0}),o.bind("isEnabled").toMany([a,...l],"isEnabled",((...e)=>e.some((e=>e)))),this.listenTo(o.buttonView,"execute",(()=>{s.execute(r),s.editing.view.focus()})),this.listenTo(o,"execute",(e=>{s.execute(e.source.commandName),s.editing.view.focus()})),o}_fillDropdownWithListOptions(e,t){const i=this.editor,n=[],s=new va;for(const e of t)yL(e,i,n,s);return Gf(e,s),n}}function yL(e,t,i,n){if("button"===e.type||"switchbutton"===e.type){const n=e.model=new Ab(e.model),{commandName:s,bindIsOn:o}=e.model,r=t.commands.get(s);i.push(r),n.set({commandName:s}),n.bind("isEnabled").to(r),o&&n.bind("isOn").to(r,"value"),n.set({withText:!0})}n.add(e)}class kL extends Na{static get pluginName(){return"TableSelection"}static get requires(){return[JM,JM]}init(){const e=this.editor,t=e.model,i=e.editing.view;this.listenTo(t,"deleteContent",((e,t)=>this._handleDeleteContent(e,t)),{priority:"high"}),this.listenTo(i.document,"insertText",((e,t)=>this._handleInsertTextEvent(e,t)),{priority:"high"}),this._defineSelectionConverter(),this._enablePluginDisabling()}getSelectedTableCells(){const e=this.editor.plugins.get(JM),t=this.editor.model.document.selection,i=e.getSelectedTableCells(t);return 0==i.length?null:i}getSelectionAsFragment(){const e=this.editor.plugins.get(JM),t=this.getSelectedTableCells();return t?this.editor.model.change((i=>{const n=i.createDocumentFragment(),{first:s,last:o}=e.getColumnIndexes(t),{first:r,last:a}=e.getRowIndexes(t),l=t[0].findAncestor("table");let c=a,d=o;if(e.isSelectionRectangular(t)){const e={firstColumn:s,lastColumn:o,firstRow:r,lastRow:a};c=IM(l,e),d=PM(l,e)}const h=_M(l,{startRow:r,startColumn:s,endRow:c,endColumn:d},i);return i.insert(h,n,0),n})):null}setCellSelection(e,t){const i=this._getCellsToSelect(e,t);this.editor.model.change((e=>{e.setSelection(i.cells.map((t=>e.createRangeOn(t))),{backward:i.backward})}))}getFocusCell(){const e=[...this.editor.model.document.selection.getRanges()].pop().getContainedElement();return e&&e.is("element","tableCell")?e:null}getAnchorCell(){const e=_a(this.editor.model.document.selection.getRanges()).getContainedElement();return e&&e.is("element","tableCell")?e:null}_defineSelectionConverter(){const e=this.editor,t=new Set;e.conversion.for("editingDowncast").add((e=>e.on("selection",((e,i,n)=>{const s=n.writer;!function(e){for(const i of t)e.removeClass("ck-editor__editable_selected",i);t.clear()}(s);const o=this.getSelectedTableCells();if(!o)return;for(const e of o){const i=n.mapper.toViewElement(e);s.addClass("ck-editor__editable_selected",i),t.add(i)}const r=n.mapper.toViewElement(o[o.length-1]);s.setSelection(r,0)}),{priority:"lowest"})))}_enablePluginDisabling(){const e=this.editor;this.on("change:isEnabled",(()=>{if(!this.isEnabled){const t=this.getSelectedTableCells();if(!t)return;e.model.change((i=>{const n=i.createPositionAt(t[0],0),s=e.model.schema.getNearestSelectionRange(n);i.setSelection(s)}))}}))}_handleDeleteContent(e,t){const i=this.editor.plugins.get(JM),n=t[0],s=t[1],o=this.editor.model,r=!s||"backward"==s.direction,a=i.getSelectedTableCells(n);a.length&&(e.stop(),o.change((e=>{const t=a[r?a.length-1:0];o.change((e=>{for(const t of a)o.deleteContent(e.createSelection(t,"in"))}));const i=o.schema.getNearestSelectionRange(e.createPositionAt(t,0));n.is("documentSelection")?e.setSelection(i):n.setTo(i)})))}_handleInsertTextEvent(e,t){const i=this.editor,n=this.getSelectedTableCells();if(!n)return;const s=i.editing.view,o=i.editing.mapper,r=n.map((e=>s.createRangeOn(o.toViewElement(e))));t.selection=s.createSelection(r)}_getCellsToSelect(e,t){const i=this.editor.plugins.get("TableUtils"),n=i.getCellLocation(e),s=i.getCellLocation(t),o=Math.min(n.row,s.row),r=Math.max(n.row,s.row),a=Math.min(n.column,s.column),l=Math.max(n.column,s.column),c=new Array(r-o+1).fill(null).map((()=>[])),d={startRow:o,endRow:r,startColumn:a,endColumn:l};for(const{row:t,cell:i}of new dM(e.findAncestor("table"),d))c[t-o].push(i);const h=s.row<n.row,u=s.column<n.column;return h&&c.reverse(),u&&c.forEach((e=>e.reverse())),{cells:c.flat(),backward:h||u}}}class CL extends Na{static get pluginName(){return"TableClipboard"}static get requires(){return[K_,Z_,kL,JM]}init(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"copy",((e,t)=>this._onCopyCut(e,t))),this.listenTo(t,"cut",((e,t)=>this._onCopyCut(e,t))),this.listenTo(e.model,"insertContent",((e,[t,i])=>this._onInsertContent(e,t,i)),{priority:"high"}),this.decorate("_replaceTableSlotCell")}_onCopyCut(e,t){const i=this.editor.editing.view,n=this.editor.plugins.get(kL),s=this.editor.plugins.get(K_);n.getSelectedTableCells()&&("cut"!=e.name||this.editor.model.canEditAt(this.editor.model.document.selection))&&(t.preventDefault(),e.stop(),this.editor.model.enqueueChange({isUndoable:"cut"===e.name},(()=>{const o=s._copySelectedFragmentWithMarkers(e.name,this.editor.model.document.selection,(()=>n.getSelectionAsFragment()));i.document.fire("clipboardOutput",{dataTransfer:t.dataTransfer,content:this.editor.data.toView(o),method:e.name})})))}_onInsertContent(e,t,i){if(i&&!i.is("documentSelection"))return;const n=this.editor.model,s=this.editor.plugins.get(JM),o=this.editor.plugins.get(K_),r=this.getTableIfOnlyTableInContent(t,n);if(!r)return;const a=s.getSelectionAffectedTableCells(n.document.selection);a.length?(e.stop(),t.is("documentFragment")?o._pasteMarkersIntoTransformedElement(t.markers,(e=>this._replaceSelectedCells(r,a,e))):this.editor.model.change((e=>{this._replaceSelectedCells(r,a,e)}))):SM(r,s)}_replaceSelectedCells(e,t,i){const n=this.editor.plugins.get(JM),s={width:n.getColumns(e),height:n.getRows(e)},o=function(e,t,i,n){const s=e[0].findAncestor("table"),o=n.getColumnIndexes(e),r=n.getRowIndexes(e),a={firstColumn:o.first,lastColumn:o.last,firstRow:r.first,lastRow:r.last},l=1===e.length;l&&(a.lastRow+=t.height-1,a.lastColumn+=t.width-1,function(e,t,i,n){const s=n.getColumns(e),o=n.getRows(e);i>s&&n.insertColumns(e,{at:s,columns:i-s});t>o&&n.insertRows(e,{at:o,rows:t-o})}(s,a.lastRow+1,a.lastColumn+1,n));l||!n.isSelectionRectangular(e)?function(e,t,i){const{firstRow:n,lastRow:s,firstColumn:o,lastColumn:r}=t,a={first:n,last:s},l={first:o,last:r};AL(e,o,a,i),AL(e,r+1,a,i),xL(e,n,l,i),xL(e,s+1,l,i,n)}(s,a,i):(a.lastRow=IM(s,a),a.lastColumn=PM(s,a));return a}(t,s,i,n),r=o.lastRow-o.firstRow+1,a=o.lastColumn-o.firstColumn+1;e=_M(e,{startRow:0,startColumn:0,endRow:Math.min(r,s.height)-1,endColumn:Math.min(a,s.width)-1},i);const l=t[0].findAncestor("table"),c=this._replaceSelectedCellsWithPasted(e,s,l,o,i);if(this.editor.plugins.get("TableSelection").isEnabled){const e=n.sortRanges(c.map((e=>i.createRangeOn(e))));i.setSelection(e)}else i.setSelection(c[0],0);return l}_replaceSelectedCellsWithPasted(e,t,i,n,s){const{width:o,height:r}=t,a=function(e,t,i){const n=new Array(i).fill(null).map((()=>new Array(t).fill(null)));for(const{column:t,row:i,cell:s}of new dM(e))n[i][t]=s;return n}(e,o,r),l=[...new dM(i,{startRow:n.firstRow,endRow:n.lastRow,startColumn:n.firstColumn,endColumn:n.lastColumn,includeAllSlots:!0})],c=[];let d;for(const e of l){const{row:t,column:i}=e;i===n.firstColumn&&(d=e.getPositionBefore());const l=t-n.firstRow,h=i-n.firstColumn,u=a[l%r][h%o],m=u?s.cloneElement(u):null,g=this._replaceTableSlotCell(e,m,d,s);g&&(AM(g,t,i,n.lastRow,n.lastColumn,s),c.push(g),d=s.createPositionAfter(g))}const h=parseInt(i.getAttribute("headingRows")||"0"),u=parseInt(i.getAttribute("headingColumns")||"0"),m=n.firstRow<h&&h<=n.lastRow,g=n.firstColumn<u&&u<=n.lastColumn;if(m){const e=xL(i,h,{first:n.firstColumn,last:n.lastColumn},s,n.firstRow);c.push(...e)}if(g){const e=AL(i,u,{first:n.firstRow,last:n.lastRow},s);c.push(...e)}return c}_replaceTableSlotCell(e,t,i,n){const{cell:s,isAnchor:o}=e;return o&&n.remove(s),t?(n.insert(t,i),t):null}getTableIfOnlyTableInContent(e,t){if(!e.is("documentFragment")&&!e.is("element"))return null;if(e.is("element","table"))return e;if(1==e.childCount&&e.getChild(0).is("element","table"))return e.getChild(0);const i=t.createRangeIn(e);for(const e of i.getItems())if(e.is("element","table")){const n=t.createRange(i.start,t.createPositionBefore(e));if(t.hasContent(n,{ignoreWhitespaces:!0}))return null;const s=t.createRange(t.createPositionAfter(e),i.end);return t.hasContent(s,{ignoreWhitespaces:!0})?null:e}return null}}function xL(e,t,i,n,s=0){if(t<1)return;return yM(e,t,s).filter((({column:e,cellWidth:t})=>EL(e,t,i))).map((({cell:e})=>kM(e,t,n)))}function AL(e,t,i,n){if(t<1)return;return CM(e,t).filter((({row:e,cellHeight:t})=>EL(e,t,i))).map((({cell:e,column:i})=>xM(e,i,t,n)))}function EL(e,t,i){const n=e+t-1,{first:s,last:o}=i;return e>=s&&e<=o||e<s&&n>=s}class TL extends Na{static get pluginName(){return"TableKeyboard"}static get requires(){return[kL,JM]}init(){const e=this.editor,t=e.editing.view.document,i=e.t;this.listenTo(t,"arrowKey",((...e)=>this._onArrowKey(...e)),{context:"table"}),this.listenTo(t,"tab",((...e)=>this._handleTabOnSelectedTable(...e)),{context:"figure"}),this.listenTo(t,"tab",((...e)=>this._handleTab(...e)),{context:["th","td"]}),e.accessibility.addKeystrokeInfoGroup({id:"table",label:i("Keystrokes that can be used in a table cell"),keystrokes:[{label:i("Move the selection to the next cell"),keystroke:"Tab"},{label:i("Move the selection to the previous cell"),keystroke:"Shift+Tab"},{label:i("Insert a new table row (when in the last cell of a table)"),keystroke:"Tab"},{label:i("Navigate through the table"),keystroke:[["arrowup"],["arrowright"],["arrowdown"],["arrowleft"]]}]})}_handleTabOnSelectedTable(e,t){const i=this.editor,n=i.model.document.selection.getSelectedElement();n&&n.is("element","table")&&(t.preventDefault(),t.stopPropagation(),e.stop(),i.model.change((e=>{e.setSelection(e.createRangeIn(n.getChild(0).getChild(0)))})))}_handleTab(e,t){const i=this.editor,n=this.editor.plugins.get(JM),s=this.editor.plugins.get("TableSelection"),o=i.model.document.selection,r=!t.shiftKey;let a=n.getTableCellsContainingSelection(o)[0];if(a||(a=s.getFocusCell()),!a)return;t.preventDefault(),t.stopPropagation(),e.stop();const l=a.parent,c=l.parent,d=c.getChildIndex(l),h=l.getChildIndex(a),u=0===h;if(!r&&u&&0===d)return void i.model.change((e=>{e.setSelection(e.createRangeOn(c))}));const m=h===l.childCount-1,g=d===n.getRows(c)-1;if(r&&g&&m&&(i.execute("insertTableRowBelow"),d===n.getRows(c)-1))return void i.model.change((e=>{e.setSelection(e.createRangeOn(c))}));let f;if(r&&m){const e=c.getChild(d+1);f=e.getChild(0)}else if(!r&&u){const e=c.getChild(d-1);f=e.getChild(e.childCount-1)}else f=l.getChild(h+(r?1:-1));i.model.change((e=>{e.setSelection(e.createRangeIn(f))}))}_onArrowKey(e,t){const i=this.editor,n=ua(t.keyCode,i.locale.contentLanguageDirection);this._handleArrowKeys(n,t.shiftKey)&&(t.preventDefault(),t.stopPropagation(),e.stop())}_handleArrowKeys(e,t){const i=this.editor.plugins.get(JM),n=this.editor.plugins.get("TableSelection"),s=this.editor.model,o=s.document.selection,r=["right","down"].includes(e),a=i.getSelectedTableCells(o);if(a.length){let i;return i=t?n.getFocusCell():r?a[a.length-1]:a[0],this._navigateFromCellInDirection(i,e,t),!0}const l=o.focus.findAncestor("tableCell");if(!l)return!1;if(!o.isCollapsed)if(t){if(o.isBackward==r&&!o.containsEntireContent(l))return!1}else{const e=o.getSelectedElement();if(!e||!s.schema.isObject(e))return!1}return!!this._isSelectionAtCellEdge(o,l,r)&&(this._navigateFromCellInDirection(l,e,t),!0)}_isSelectionAtCellEdge(e,t,i){const n=this.editor.model,s=this.editor.model.schema,o=i?e.getLastPosition():e.getFirstPosition();if(!s.getLimitElement(o).is("element","tableCell")){return n.createPositionAt(t,i?"end":0).isTouching(o)}const r=n.createSelection(o);return n.modifySelection(r,{direction:i?"forward":"backward"}),o.isEqual(r.focus)}_navigateFromCellInDirection(e,t,i=!1){const n=this.editor.model,s=e.findAncestor("table"),o=[...new dM(s,{includeAllSlots:!0})],{row:r,column:a}=o[o.length-1],l=o.find((({cell:t})=>t==e));let{row:c,column:d}=l;switch(t){case"left":d--;break;case"up":c--;break;case"right":d+=l.cellWidth;break;case"down":c+=l.cellHeight}if(c<0||c>r||d<0&&c<=0||d>a&&c>=r)return void n.change((e=>{e.setSelection(e.createRangeOn(s))}));d<0?(d=i?0:a,c--):d>a&&(d=i?a:0,c++);const h=o.find((e=>e.row==c&&e.column==d)).cell,u=["right","down"].includes(t),m=this.editor.plugins.get("TableSelection");if(i&&m.isEnabled){const t=m.getAnchorCell()||e;m.setCellSelection(t,h)}else{const e=n.createPositionAt(h,u?0:"end");n.change((t=>{t.setSelection(e)}))}}}class SL extends Sc{onDomEvent(e){this.fire(e.type,e)}constructor(...e){super(...e),this.domEventType=["mousemove","mouseleave"]}}class IL extends Na{static get pluginName(){return"TableMouse"}static get requires(){return[kL,JM]}init(){this.editor.editing.view.addObserver(SL),this._enableShiftClickSelection(),this._enableMouseDragSelection()}_enableShiftClickSelection(){const e=this.editor,t=e.plugins.get(JM);let i=!1;const n=e.plugins.get(kL);this.listenTo(e.editing.view.document,"mousedown",((s,o)=>{const r=e.model.document.selection;if(!this.isEnabled||!n.isEnabled)return;if(!o.domEvent.shiftKey)return;const a=n.getAnchorCell()||t.getTableCellsContainingSelection(r)[0];if(!a)return;const l=this._getModelTableCellFromDomEvent(o);l&&PL(a,l)&&(i=!0,n.setCellSelection(a,l),o.preventDefault())})),this.listenTo(e.editing.view.document,"mouseup",(()=>{i=!1})),this.listenTo(e.editing.view.document,"selectionChange",(e=>{i&&e.stop()}),{priority:"highest"})}_enableMouseDragSelection(){const e=this.editor;let t,i,n=!1,s=!1;const o=e.plugins.get(kL);this.listenTo(e.editing.view.document,"mousedown",((e,i)=>{this.isEnabled&&o.isEnabled&&(i.domEvent.shiftKey||i.domEvent.ctrlKey||i.domEvent.altKey||(t=this._getModelTableCellFromDomEvent(i)))})),this.listenTo(e.editing.view.document,"mousemove",((e,r)=>{if(!r.domEvent.buttons)return;if(!t)return;const a=this._getModelTableCellFromDomEvent(r);a&&PL(t,a)&&(i=a,n||i==t||(n=!0)),n&&(s=!0,o.setCellSelection(t,i),r.preventDefault())})),this.listenTo(e.editing.view.document,"mouseup",(()=>{n=!1,s=!1,t=null,i=null})),this.listenTo(e.editing.view.document,"selectionChange",(e=>{s&&e.stop()}),{priority:"highest"})}_getModelTableCellFromDomEvent(e){const t=e.target,i=this.editor.editing.view.createPositionAt(t,0);return this.editor.editing.mapper.toModelPosition(i).parent.findAncestor("tableCell",{includeSelf:!0})}}function PL(e,t){return e.parent.parent==t.parent.parent}class VL extends Na{static get requires(){return[bL,_L,kL,IL,TL,CL,Ey]}static get pluginName(){return"Table"}}class RL extends Na{static get pluginName(){return"PlainTableOutput"}static get requires(){return[VL]}init(){const e=this.editor;e.conversion.for("dataDowncast").elementToStructure({model:"table",view:BL,converterPriority:"high"}),e.plugins.has("TableCaption")&&e.conversion.for("dataDowncast").elementToElement({model:"caption",view:(e,{writer:t})=>{if("table"===e.parent.name)return t.createContainerElement("caption")},converterPriority:"high"}),e.plugins.has("TableProperties")&&function(e){const t={"border-width":"tableBorderWidth","border-color":"tableBorderColor","border-style":"tableBorderStyle","background-color":"tableBackgroundColor"};for(const[i,n]of Object.entries(t))e.conversion.for("dataDowncast").add((e=>e.on(`attribute:${n}:table`,((e,t,n)=>{const{item:s,attributeNewValue:o}=t,{mapper:r,writer:a}=n;if(!n.consumable.consume(s,e.name))return;const l=r.toViewElement(s);o?a.setStyle(i,o,l):a.removeStyle(i,l)}),{priority:"high"})))}(e)}}function BL(e,{writer:t}){const i=e.getAttribute("headingRows")||0,n=t.createSlot((e=>e.is("element","tableRow")&&e.index<i)),s=t.createSlot((e=>e.is("element","tableRow")&&e.index>=i)),o=t.createSlot((e=>!e.is("element","tableRow"))),r=t.createContainerElement("thead",null,n),a=t.createContainerElement("tbody",null,s),l=[];return i&&l.push(r),i<e.childCount&&l.push(a),t.createContainerElement("table",null,[o,...l])}function OL(e){const t=ML(e);return t||LL(e)}function ML(e){const t=e.getSelectedElement();return t&&NL(t)?t:null}function LL(e){const t=e.getFirstPosition();if(!t)return null;let i=t.parent;for(;i;){if(i.is("element")&&NL(i))return i;i=i.parent}return null}function NL(e){return!!e.getCustomProperty("table")&&ny(e)}class FL extends Na{static get requires(){return[Sy]}static get pluginName(){return"TableToolbar"}afterInit(){const e=this.editor,t=e.t,i=e.plugins.get(Sy),n=e.config.get("table.contentToolbar"),s=e.config.get("table.tableToolbar");n&&i.register("tableContent",{ariaLabel:t("Table toolbar"),items:n,getRelatedElement:LL}),s&&i.register("table",{ariaLabel:t("Table toolbar"),items:s,getRelatedElement:ML})}}class DL extends Tg{render(){super.render(),[this.inputView,this.dropdownView.buttonView].forEach((e=>{this.focusTracker.add(e.element),this._focusables.add(e)})),this.keystrokes.listenTo(this.element)}focus(e){-1===e?this.focusCycler.focusLast():this.focusCycler.focusFirst()}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}_createDropdownView(){const e=this.locale,t=e.t,i=this.bindTemplate,n=this._createColorSelector(e),s=Wf(e),o=new Tg;return o.setTemplate({tag:"span",attributes:{class:["ck","ck-input-color__button__preview"],style:{backgroundColor:i.to("value")}},children:[{tag:"span",attributes:{class:["ck","ck-input-color__button__preview__no-color-indicator",i.if("value","ck-hidden",(e=>""!=e))]}}]}),s.buttonView.extendTemplate({attributes:{class:"ck-input-color__button"}}),s.buttonView.children.add(o),s.buttonView.label=t("Color picker"),s.buttonView.tooltip=!0,s.panelPosition="rtl"===e.uiLanguageDirection?"se":"sw",s.panelView.children.add(n),s.bind("isEnabled").to(this,"isReadOnly",(e=>!e)),s.on("change:isOpen",((e,t,i)=>{i&&(n.updateSelectedColors(),n.showColorGridsFragment())})),s}_createInputTextView(){const e=this.locale,t=new _f(e);return t.extendTemplate({on:{blur:t.bindTemplate.to("blur")}}),t.value=this.value,t.bind("isReadOnly","hasError").to(this),this.bind("isFocused","isEmpty").to(t),t.on("input",(()=>{const e=t.element.value,i=this.options.colorDefinitions.find((t=>e===t.label));this._stillTyping=!0,this.value=i&&i.color||e})),t.on("blur",(()=>{this._stillTyping=!1,this._setInputValue(t.element.value)})),t.delegate("input").to(this),t}_createColorSelector(e){const t=e.t,i=this.options.defaultColorValue||"",n=t(i?"Restore default":"Remove color"),s=new zp(e,{colors:this.options.colorDefinitions,columns:this.options.columns,removeButtonLabel:n,colorPickerLabel:t("Color picker"),colorPickerViewConfig:!1!==this.options.colorPickerConfig&&{...this.options.colorPickerConfig,hideInput:!0}});s.appendUI(),s.on("execute",((e,t)=>{"colorPickerSaveButton"!==t.source?(this.value=t.value||i,this.fire("input"),"colorPicker"!==t.source&&(this.dropdownView.isOpen=!1)):this.dropdownView.isOpen=!1}));let o=this.value;return s.on("colorPicker:cancel",(()=>{this.value=o,this.fire("input"),this.dropdownView.isOpen=!1})),s.colorGridsFragmentView.colorPickerButtonView.on("execute",(()=>{o=this.value})),s.bind("selectedColor").to(this,"value"),s}_setInputValue(e){if(!this._stillTyping){const t=zL(e),i=this.options.colorDefinitions.find((e=>t===zL(e.color)));this.inputView.value=i?i.label:e||""}}constructor(e,t){super(e),this.set("value",""),this.set("isReadOnly",!1),this.set("isFocused",!1),this.set("isEmpty",!0),this.options=t,this.focusTracker=new ya,this._focusables=new og,this.dropdownView=this._createDropdownView(),this.inputView=this._createInputTextView(),this.keystrokes=new ka,this._stillTyping=!1,this.focusCycler=new Tf({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-input-color"]},children:[this.dropdownView,this.inputView]}),this.on("change:value",((e,t,i)=>this._setInputValue(i)))}}function zL(e){return e.replace(/([(,])\s+/g,"$1").replace(/^\s+|\s+(?=[),\s]|$)/g,"").replace(/,|\s/g," ")}const HL=e=>""===e;function $L(e){return{none:e("None"),solid:e("Solid"),dotted:e("Dotted"),dashed:e("Dashed"),double:e("Double"),groove:e("Groove"),ridge:e("Ridge"),inset:e("Inset"),outset:e("Outset")}}function UL(e){return e('The color is invalid. Try "#FF0000" or "rgb(255,0,0)" or "red".')}function WL(e){return e('The value is invalid. Try "10px" or "2em" or simply "2".')}function jL(e){return e=e.trim().toLowerCase(),HL(e)||Zu(e)}function qL(e){return e=e.trim(),HL(e)||YL(e)||Xu(e)||tm(e)}function GL(e){return e=e.trim(),HL(e)||YL(e)||Xu(e)}function KL(e,t){const i=new va,n=$L(e.t);for(const s in n){const o={type:"button",model:new Ab({_borderStyleValue:s,label:n[s],role:"menuitemradio",withText:!0})};"none"===s?o.model.bind("isOn").to(e,"borderStyle",(e=>"none"===t?!e:e===s)):o.model.bind("isOn").to(e,"borderStyle",(e=>e===s)),i.add(o)}return i}function ZL(e){const{view:t,icons:i,toolbar:n,labels:s,propertyName:o,nameToValue:r,defaultValue:a}=e;for(const e in s){const l=new Hg(t.locale);l.set({label:s[e],icon:i[e],tooltip:s[e]});const c=r?r(e):e;l.bind("isOn").to(t,o,(e=>{let t=e;return""===e&&a&&(t=a),c===t})),l.on("execute",(()=>{t[o]=c})),n.items.add(l)}}const JL=[{color:"hsl(0, 0%, 0%)",label:"Black"},{color:"hsl(0, 0%, 30%)",label:"Dim grey"},{color:"hsl(0, 0%, 60%)",label:"Grey"},{color:"hsl(0, 0%, 90%)",label:"Light grey"},{color:"hsl(0, 0%, 100%)",label:"White",hasBorder:!0},{color:"hsl(0, 75%, 60%)",label:"Red"},{color:"hsl(30, 75%, 60%)",label:"Orange"},{color:"hsl(60, 75%, 60%)",label:"Yellow"},{color:"hsl(90, 75%, 60%)",label:"Light green"},{color:"hsl(120, 75%, 60%)",label:"Green"},{color:"hsl(150, 75%, 60%)",label:"Aquamarine"},{color:"hsl(180, 75%, 60%)",label:"Turquoise"},{color:"hsl(210, 75%, 60%)",label:"Light blue"},{color:"hsl(240, 75%, 60%)",label:"Blue"},{color:"hsl(270, 75%, 60%)",label:"Purple"}];function QL(e){return(t,i,n)=>{const s=new DL(t.locale,{colorDefinitions:(o=e.colorConfig,o.map((e=>({color:e.model,label:e.label,options:{hasBorder:e.hasBorder}})))),columns:e.columns,defaultColorValue:e.defaultColorValue,colorPickerConfig:e.colorPickerConfig});var o;return s.inputView.set({id:i,ariaDescribedById:n}),s.bind("isReadOnly").to(t,"isEnabled",(e=>!e)),s.bind("hasError").to(t,"errorText",(e=>!!e)),s.on("input",(()=>{t.errorText=null})),t.bind("isEmpty","isFocused").to(s),s}}function YL(e){const t=parseFloat(e);return!Number.isNaN(t)&&e===String(t)}class XL extends Tg{constructor(e,t={}){super(e);const i=this.bindTemplate;this.set("class",t.class||null),this.children=this.createCollection(),t.children&&t.children.forEach((e=>this.children.add(e))),this.set("_role",null),this.set("_ariaLabelledBy",null),t.labelView&&this.set({_role:"group",_ariaLabelledBy:t.labelView.id}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-form__row",i.to("class")],role:i.to("_role"),"aria-labelledby":i.to("_ariaLabelledBy")},children:this.children})}}const eN={left:Dm.alignLeft,center:Dm.alignCenter,right:Dm.alignRight,justify:Dm.alignJustify,top:Dm.alignTop,middle:Dm.alignMiddle,bottom:Dm.alignBottom};class tN extends Tg{render(){super.render(),Vg({view:this}),[this.borderColorInput,this.backgroundInput].forEach((e=>{e.fieldView.focusCycler.on("forwardCycle",(e=>{this._focusCycler.focusNext(),e.stop()})),e.fieldView.focusCycler.on("backwardCycle",(e=>{this._focusCycler.focusPrevious(),e.stop()}))})),[this.borderStyleDropdown,this.borderColorInput,this.borderWidthInput,this.backgroundInput,this.widthInput,this.heightInput,this.paddingInput,this.horizontalAlignmentToolbar,this.verticalAlignmentToolbar,this.saveButtonView,this.cancelButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createBorderFields(){const e=this.options.defaultTableCellProperties,t={style:e.borderStyle,width:e.borderWidth,color:e.borderColor},i=QL({colorConfig:this.options.borderColors,columns:5,defaultColorValue:t.color,colorPickerConfig:this.options.colorPickerConfig}),n=this.locale,s=this.t,o=s("Style"),r=new Bg(n);r.text=s("Border");const a=$L(s),l=new bf(n,ep);l.set({label:o,class:"ck-table-form__border-style"}),l.fieldView.buttonView.set({ariaLabel:o,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:o}),l.fieldView.buttonView.bind("label").to(this,"borderStyle",(e=>a[e||"none"])),l.fieldView.on("execute",(e=>{this.borderStyle=e.source._borderStyleValue})),l.bind("isEmpty").to(this,"borderStyle",(e=>!e)),Gf(l.fieldView,KL(this,t.style),{role:"menu",ariaLabel:o});const c=new bf(n,Qf);c.set({label:s("Width"),class:"ck-table-form__border-width"}),c.fieldView.bind("value").to(this,"borderWidth"),c.bind("isEnabled").to(this,"borderStyle",iN),c.fieldView.on("input",(()=>{this.borderWidth=c.fieldView.element.value}));const d=new bf(n,i);return d.set({label:s("Color"),class:"ck-table-form__border-color"}),d.fieldView.bind("value").to(this,"borderColor"),d.bind("isEnabled").to(this,"borderStyle",iN),d.fieldView.on("input",(()=>{this.borderColor=d.fieldView.value})),this.on("change:borderStyle",((e,i,n,s)=>{iN(n)||(this.borderColor="",this.borderWidth=""),iN(s)||(this.borderColor=t.color,this.borderWidth=t.width)})),{borderRowLabel:r,borderStyleDropdown:l,borderColorInput:d,borderWidthInput:c}}_createBackgroundFields(){const e=this.locale,t=this.t,i=new Bg(e);i.text=t("Background");const n=QL({colorConfig:this.options.backgroundColors,columns:5,defaultColorValue:this.options.defaultTableCellProperties.backgroundColor,colorPickerConfig:this.options.colorPickerConfig}),s=new bf(e,n);return s.set({label:t("Color"),class:"ck-table-cell-properties-form__background"}),s.fieldView.bind("value").to(this,"backgroundColor"),s.fieldView.on("input",(()=>{this.backgroundColor=s.fieldView.value})),{backgroundRowLabel:i,backgroundInput:s}}_createDimensionFields(){const e=this.locale,t=this.t,i=new Bg(e);i.text=t("Dimensions");const n=new bf(e,Qf);n.set({label:t("Width"),class:"ck-table-form__dimensions-row__width"}),n.fieldView.bind("value").to(this,"width"),n.fieldView.on("input",(()=>{this.width=n.fieldView.element.value}));const s=new Tg(e);s.setTemplate({tag:"span",attributes:{class:["ck-table-form__dimension-operator"]},children:[{text:"×"}]});const o=new bf(e,Qf);return o.set({label:t("Height"),class:"ck-table-form__dimensions-row__height"}),o.fieldView.bind("value").to(this,"height"),o.fieldView.on("input",(()=>{this.height=o.fieldView.element.value})),{dimensionsLabel:i,widthInput:n,operatorLabel:s,heightInput:o}}_createPaddingField(){const e=this.locale,t=this.t,i=new bf(e,Qf);return i.set({label:t("Padding"),class:"ck-table-cell-properties-form__padding"}),i.fieldView.bind("value").to(this,"padding"),i.fieldView.on("input",(()=>{this.padding=i.fieldView.element.value})),i}_createAlignmentFields(){const e=this.locale,t=this.t,i=new Bg(e);i.text=t("Table cell text alignment");const n=new Mf(e),s="rtl"===e.contentLanguageDirection;n.set({isCompact:!0,ariaLabel:t("Horizontal text alignment toolbar")}),ZL({view:this,icons:eN,toolbar:n,labels:this._horizontalAlignmentLabels,propertyName:"horizontalAlignment",nameToValue:e=>{if(s){if("left"===e)return"right";if("right"===e)return"left"}return e},defaultValue:this.options.defaultTableCellProperties.horizontalAlignment});const o=new Mf(e);return o.set({isCompact:!0,ariaLabel:t("Vertical text alignment toolbar")}),ZL({view:this,icons:eN,toolbar:o,labels:this._verticalAlignmentLabels,propertyName:"verticalAlignment",defaultValue:this.options.defaultTableCellProperties.verticalAlignment}),{horizontalAlignmentToolbar:n,verticalAlignmentToolbar:o,alignmentLabel:i}}_createActionButtons(){const e=this.locale,t=this.t,i=new Hg(e),n=new Hg(e),s=[this.borderWidthInput,this.borderColorInput,this.backgroundInput,this.paddingInput];return i.set({label:t("Save"),icon:Dm.check,class:"ck-button-save",type:"submit",withText:!0}),i.bind("isEnabled").toMany(s,"errorText",((...e)=>e.every((e=>!e)))),n.set({label:t("Cancel"),icon:Dm.cancel,class:"ck-button-cancel",withText:!0}),n.delegate("execute").to(this,"cancel"),{saveButtonView:i,cancelButtonView:n}}get _horizontalAlignmentLabels(){const e=this.locale,t=this.t,i=t("Align cell text to the left"),n=t("Align cell text to the center"),s=t("Align cell text to the right"),o=t("Justify cell text");return"rtl"===e.uiLanguageDirection?{right:s,center:n,left:i,justify:o}:{left:i,center:n,right:s,justify:o}}get _verticalAlignmentLabels(){const e=this.t;return{top:e("Align cell text to the top"),middle:e("Align cell text to the middle"),bottom:e("Align cell text to the bottom")}}constructor(e,t){super(e),this.set({borderStyle:"",borderWidth:"",borderColor:"",padding:"",backgroundColor:"",width:"",height:"",horizontalAlignment:"",verticalAlignment:""}),this.options=t;const{borderStyleDropdown:i,borderWidthInput:n,borderColorInput:s,borderRowLabel:o}=this._createBorderFields(),{backgroundRowLabel:r,backgroundInput:a}=this._createBackgroundFields(),{widthInput:l,operatorLabel:c,heightInput:d,dimensionsLabel:h}=this._createDimensionFields(),{horizontalAlignmentToolbar:u,verticalAlignmentToolbar:m,alignmentLabel:g}=this._createAlignmentFields();this.focusTracker=new ya,this.keystrokes=new ka,this.children=this.createCollection(),this.borderStyleDropdown=i,this.borderWidthInput=n,this.borderColorInput=s,this.backgroundInput=a,this.paddingInput=this._createPaddingField(),this.widthInput=l,this.heightInput=d,this.horizontalAlignmentToolbar=u,this.verticalAlignmentToolbar=m;const{saveButtonView:f,cancelButtonView:p}=this._createActionButtons();this.saveButtonView=f,this.cancelButtonView=p,this._focusables=new og,this._focusCycler=new Tf({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.children.add(new Up(e,{label:this.t("Cell properties")})),this.children.add(new XL(e,{labelView:o,children:[o,i,s,n],class:"ck-table-form__border-row"})),this.children.add(new XL(e,{labelView:r,children:[r,a],class:"ck-table-form__background-row"})),this.children.add(new XL(e,{children:[new XL(e,{labelView:h,children:[h,l,c,d],class:"ck-table-form__dimensions-row"}),new XL(e,{children:[this.paddingInput],class:"ck-table-cell-properties-form__padding-row"})]})),this.children.add(new XL(e,{labelView:g,children:[g,u,m],class:"ck-table-cell-properties-form__alignment-row"})),this.children.add(new XL(e,{children:[this.saveButtonView,this.cancelButtonView],class:"ck-table-form__action-row"})),this.setTemplate({tag:"form",attributes:{class:["ck","ck-form","ck-table-form","ck-table-cell-properties-form"],tabindex:"-1"},children:this.children})}}function iN(e){return"none"!==e}const nN=Xp.defaultPositions,sN=[nN.northArrowSouth,nN.northArrowSouthWest,nN.northArrowSouthEast,nN.southArrowNorth,nN.southArrowNorthWest,nN.southArrowNorthEast,nN.viewportStickyNorth];function oN(e,t){const i=e.plugins.get("ContextualBalloon"),n=e.editing.view.document.selection;let s;"cell"===t?LL(n)&&(s=aN(e)):OL(n)&&(s=rN(e)),s&&i.updatePosition(s)}function rN(e){const t=rM(e.model.document.selection),i=e.editing.mapper.toViewElement(t);return{target:e.editing.view.domConverter.mapViewToDom(i),positions:sN}}function aN(e){const t=e.editing.mapper,i=e.editing.view.domConverter,n=e.model.document.selection;if(n.rangeCount>1)return{target:()=>function(e,t){const i=t.editing.mapper,n=t.editing.view.domConverter,s=Array.from(e).map((e=>{const t=lN(e.start),s=i.toViewElement(t);return new Ir(n.mapViewToDom(s))}));return Ir.getBoundingRect(s)}(n.getRanges(),e),positions:sN};const s=lN(n.getFirstPosition()),o=t.toViewElement(s);return{target:i.mapViewToDom(o),positions:sN}}function lN(e){return e.nodeAfter&&e.nodeAfter.is("element","tableCell")?e.nodeAfter:e.findAncestor("tableCell")}function cN(e){if(!e||!re(e))return e;const{top:t,right:i,bottom:n,left:s}=e;return t==i&&i==n&&n==s?t:void 0}function dN(e,t){const i=parseFloat(e);return Number.isNaN(i)||String(i)!==String(e)?e:`${i}${t}`}function hN(e,t={}){const i={borderStyle:"none",borderWidth:"",borderColor:"",backgroundColor:"",width:"",height:"",...e};return t.includeAlignmentProperty&&!i.alignment&&(i.alignment="center"),t.includePaddingProperty&&!i.padding&&(i.padding=""),t.includeVerticalAlignmentProperty&&!i.verticalAlignment&&(i.verticalAlignment="middle"),t.includeHorizontalAlignmentProperty&&!i.horizontalAlignment&&(i.horizontalAlignment=t.isRightToLeftContent?"right":"left"),i}const uN={borderStyle:"tableCellBorderStyle",borderColor:"tableCellBorderColor",borderWidth:"tableCellBorderWidth",height:"tableCellHeight",width:"tableCellWidth",padding:"tableCellPadding",backgroundColor:"tableCellBackgroundColor",horizontalAlignment:"tableCellHorizontalAlignment",verticalAlignment:"tableCellVerticalAlignment"};class mN extends Na{static get requires(){return[Tb]}static get pluginName(){return"TableCellPropertiesUI"}init(){const e=this.editor,t=e.t;this._defaultTableCellProperties=hN(e.config.get("table.tableCellProperties.defaultProperties"),{includeVerticalAlignmentProperty:!0,includeHorizontalAlignmentProperty:!0,includePaddingProperty:!0,isRightToLeftContent:"rtl"===e.locale.contentLanguageDirection}),this._balloon=e.plugins.get(Tb),this.view=null,this._isReady=!1,e.ui.componentFactory.add("tableCellProperties",(i=>{const n=new Hg(i);n.set({label:t("Cell properties"),icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m11.105 18-.17 1H2.5A1.5 1.5 0 0 1 1 17.5v-15A1.5 1.5 0 0 1 2.5 1h15A1.5 1.5 0 0 1 19 2.5v9.975l-.85-.124-.15-.302V8h-5v4h.021l-.172.351-1.916.28-.151.027c-.287.063-.54.182-.755.341L8 13v5h3.105zM2 12h5V8H2v4zm10-4H8v4h4V8zM2 2v5h5V2H2zm0 16h5v-5H2v5zM13 7h5V2h-5v5zM8 2v5h4V2H8z" opacity=".6"/><path d="m15.5 11.5 1.323 2.68 2.957.43-2.14 2.085.505 2.946L15.5 18.25l-2.645 1.39.505-2.945-2.14-2.086 2.957-.43L15.5 11.5zM13 6a1 1 0 0 1 1 1v3.172a2.047 2.047 0 0 0-.293.443l-.858 1.736-1.916.28-.151.027A1.976 1.976 0 0 0 9.315 14H7a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h6zm-1 2H8v4h4V8z"/></svg>',tooltip:!0}),this.listenTo(n,"execute",(()=>this._showView()));const s=Object.values(uN).map((t=>e.commands.get(t)));return n.bind("isEnabled").toMany(s,"isEnabled",((...e)=>e.some((e=>e)))),n}))}destroy(){super.destroy(),this.view&&this.view.destroy()}_createPropertiesView(){const e=this.editor,t=e.config.get("table.tableCellProperties"),i=Kg(t.borderColors),n=Gg(e.locale,i),s=Kg(t.backgroundColors),o=Gg(e.locale,s),r=!1!==t.colorPicker,a=new tN(e.locale,{borderColors:n,backgroundColors:o,defaultTableCellProperties:this._defaultTableCellProperties,colorPickerConfig:!!r&&(t.colorPicker||{})}),l=e.t;a.render(),this.listenTo(a,"submit",(()=>{this._hideView()})),this.listenTo(a,"cancel",(()=>{this._undoStepBatch.operations.length&&e.execute("undo",this._undoStepBatch),this._hideView()})),a.keystrokes.set("Esc",((e,t)=>{this._hideView(),t()})),Sg({emitter:a,activator:()=>this._isViewInBalloon,contextElements:[this._balloon.view.element],callback:()=>this._hideView()});const c=UL(l),d=WL(l);return a.on("change:borderStyle",this._getPropertyChangeCallback("tableCellBorderStyle")),a.on("change:borderColor",this._getValidatedPropertyChangeCallback({viewField:a.borderColorInput,commandName:"tableCellBorderColor",errorText:c,validator:jL})),a.on("change:borderWidth",this._getValidatedPropertyChangeCallback({viewField:a.borderWidthInput,commandName:"tableCellBorderWidth",errorText:d,validator:GL})),a.on("change:padding",this._getValidatedPropertyChangeCallback({viewField:a.paddingInput,commandName:"tableCellPadding",errorText:d,validator:qL})),a.on("change:width",this._getValidatedPropertyChangeCallback({viewField:a.widthInput,commandName:"tableCellWidth",errorText:d,validator:qL})),a.on("change:height",this._getValidatedPropertyChangeCallback({viewField:a.heightInput,commandName:"tableCellHeight",errorText:d,validator:qL})),a.on("change:backgroundColor",this._getValidatedPropertyChangeCallback({viewField:a.backgroundInput,commandName:"tableCellBackgroundColor",errorText:c,validator:jL})),a.on("change:horizontalAlignment",this._getPropertyChangeCallback("tableCellHorizontalAlignment")),a.on("change:verticalAlignment",this._getPropertyChangeCallback("tableCellVerticalAlignment")),a}_fillViewFormFromCommandValues(){const e=this.editor.commands,t=e.get("tableCellBorderStyle");Object.entries(uN).map((([t,i])=>{const n=this._defaultTableCellProperties[t]||"";return[t,e.get(i).value||n]})).forEach((([e,i])=>{("borderColor"!==e&&"borderWidth"!==e||"none"!==t.value)&&this.view.set(e,i)})),this._isReady=!0}_showView(){const e=this.editor;this.view||(this.view=this._createPropertiesView()),this.listenTo(e.ui,"update",(()=>{this._updateView()})),this._fillViewFormFromCommandValues(),this._balloon.add({view:this.view,position:aN(e)}),this._undoStepBatch=e.model.createBatch(),this.view.focus()}_hideView(){const e=this.editor;this.stopListening(e.ui,"update"),this._isReady=!1,this.view.saveButtonView.focus(),this._balloon.remove(this.view),this.editor.editing.view.focus()}_updateView(){const e=this.editor;LL(e.editing.view.document.selection)?this._isViewVisible&&oN(e,"cell"):this._hideView()}get _isViewVisible(){return!!this.view&&this._balloon.visibleView===this.view}get _isViewInBalloon(){return!!this.view&&this._balloon.hasView(this.view)}_getPropertyChangeCallback(e){return(t,i,n)=>{this._isReady&&this.editor.execute(e,{value:n,batch:this._undoStepBatch})}}_getValidatedPropertyChangeCallback(e){const{commandName:t,viewField:i,validator:n,errorText:s}=e,o=ko((()=>{i.errorText=s}),500);return(e,s,r)=>{o.cancel(),this._isReady&&(n(r)?(this.editor.execute(t,{value:r,batch:this._undoStepBatch}),i.errorText=null):o())}}constructor(e){super(e),e.config.define("table.tableCellProperties",{borderColors:JL,backgroundColors:JL})}}class gN extends Da{refresh(){const e=this.editor,t=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(e.model.document.selection);this.isEnabled=!!t.length,this.value=this._getSingleValue(t)}execute(e={}){const{value:t,batch:i}=e,n=this.editor.model,s=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(n.document.selection),o=this._getValueToSet(t);n.enqueueChange(i,(e=>{o?s.forEach((t=>e.setAttribute(this.attributeName,o,t))):s.forEach((t=>e.removeAttribute(this.attributeName,t)))}))}_getAttribute(e){if(!e)return;const t=e.getAttribute(this.attributeName);return t!==this._defaultValue?t:void 0}_getValueToSet(e){if(e!==this._defaultValue)return e}_getSingleValue(e){const t=this._getAttribute(e[0]);return e.every((e=>this._getAttribute(e)===t))?t:void 0}constructor(e,t,i){super(e),this.attributeName=t,this._defaultValue=i}}class fN extends gN{_getValueToSet(e){if((e=dN(e,"px"))!==this._defaultValue)return e}constructor(e,t){super(e,"tableCellWidth",t)}}class pN extends Na{static get pluginName(){return"TableCellWidthEditing"}static get requires(){return[bL]}init(){const e=this.editor,t=hN(e.config.get("table.tableCellProperties.defaultProperties"));oM(e.model.schema,e.conversion,{modelAttribute:"tableCellWidth",styleName:"width",defaultValue:t.width}),e.commands.add("tableCellWidth",new fN(e,t.width))}}class bN extends gN{_getAttribute(e){if(!e)return;const t=cN(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}_getValueToSet(e){const t=dN(e,"px");if(t!==this._defaultValue)return t}constructor(e,t){super(e,"tableCellPadding",t)}}class wN extends gN{_getValueToSet(e){const t=dN(e,"px");if(t!==this._defaultValue)return t}constructor(e,t){super(e,"tableCellHeight",t)}}class vN extends gN{constructor(e,t){super(e,"tableCellBackgroundColor",t)}}class _N extends gN{constructor(e,t){super(e,"tableCellVerticalAlignment",t)}}class yN extends gN{constructor(e,t){super(e,"tableCellHorizontalAlignment",t)}}class kN extends gN{_getAttribute(e){if(!e)return;const t=cN(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}constructor(e,t){super(e,"tableCellBorderStyle",t)}}class CN extends gN{_getAttribute(e){if(!e)return;const t=cN(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}constructor(e,t){super(e,"tableCellBorderColor",t)}}class xN extends gN{_getAttribute(e){if(!e)return;const t=cN(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}_getValueToSet(e){const t=dN(e,"px");if(t!==this._defaultValue)return t}constructor(e,t){super(e,"tableCellBorderWidth",t)}}const AN=/^(top|middle|bottom)$/,EN=/^(left|center|right|justify)$/;class TN extends Na{static get pluginName(){return"TableCellPropertiesEditing"}static get requires(){return[bL,pN]}init(){const e=this.editor,t=e.model.schema,i=e.conversion;e.config.define("table.tableCellProperties.defaultProperties",{});const n=hN(e.config.get("table.tableCellProperties.defaultProperties"),{includeVerticalAlignmentProperty:!0,includeHorizontalAlignmentProperty:!0,includePaddingProperty:!0,isRightToLeftContent:"rtl"===e.locale.contentLanguageDirection});e.data.addStyleProcessorRules(pm),function(e,t,i){const n={width:"tableCellBorderWidth",color:"tableCellBorderColor",style:"tableCellBorderStyle"};e.extend("tableCell",{allowAttributes:Object.values(n)}),YO(t,"td",n,i),YO(t,"th",n,i),XO(t,{modelElement:"tableCell",modelAttribute:n.style,styleName:"border-style"}),XO(t,{modelElement:"tableCell",modelAttribute:n.color,styleName:"border-color"}),XO(t,{modelElement:"tableCell",modelAttribute:n.width,styleName:"border-width"})}(t,i,{color:n.borderColor,style:n.borderStyle,width:n.borderWidth}),e.commands.add("tableCellBorderStyle",new kN(e,n.borderStyle)),e.commands.add("tableCellBorderColor",new CN(e,n.borderColor)),e.commands.add("tableCellBorderWidth",new xN(e,n.borderWidth)),oM(t,i,{modelAttribute:"tableCellHeight",styleName:"height",defaultValue:n.height}),e.commands.add("tableCellHeight",new wN(e,n.height)),e.data.addStyleProcessorRules(Tm),oM(t,i,{modelAttribute:"tableCellPadding",styleName:"padding",reduceBoxSides:!0,defaultValue:n.padding}),e.commands.add("tableCellPadding",new bN(e,n.padding)),e.data.addStyleProcessorRules(fm),oM(t,i,{modelAttribute:"tableCellBackgroundColor",styleName:"background-color",defaultValue:n.backgroundColor}),e.commands.add("tableCellBackgroundColor",new vN(e,n.backgroundColor)),function(e,t,i){e.extend("tableCell",{allowAttributes:["tableCellHorizontalAlignment"]}),t.for("downcast").attributeToAttribute({model:{name:"tableCell",key:"tableCellHorizontalAlignment"},view:e=>({key:"style",value:{"text-align":e}})}),t.for("upcast").attributeToAttribute({view:{name:/^(td|th)$/,styles:{"text-align":EN}},model:{key:"tableCellHorizontalAlignment",value:e=>{const t=e.getStyle("text-align");return t===i?null:t}}}).attributeToAttribute({view:{name:/^(td|th)$/,attributes:{align:EN}},model:{key:"tableCellHorizontalAlignment",value:e=>{const t=e.getAttribute("align");return t===i?null:t}}})}(t,i,n.horizontalAlignment),e.commands.add("tableCellHorizontalAlignment",new yN(e,n.horizontalAlignment)),function(e,t,i){e.extend("tableCell",{allowAttributes:["tableCellVerticalAlignment"]}),t.for("downcast").attributeToAttribute({model:{name:"tableCell",key:"tableCellVerticalAlignment"},view:e=>({key:"style",value:{"vertical-align":e}})}),t.for("upcast").attributeToAttribute({view:{name:/^(td|th)$/,styles:{"vertical-align":AN}},model:{key:"tableCellVerticalAlignment",value:e=>{const t=e.getStyle("vertical-align");return t===i?null:t}}}).attributeToAttribute({view:{name:/^(td|th)$/,attributes:{valign:AN}},model:{key:"tableCellVerticalAlignment",value:e=>{const t=e.getAttribute("valign");return t===i?null:t}}})}(t,i,n.verticalAlignment),e.commands.add("tableCellVerticalAlignment",new _N(e,n.verticalAlignment))}}class SN extends Na{static get pluginName(){return"TableCellProperties"}static get requires(){return[TN,mN]}}class IN extends Da{refresh(){const e=rM(this.editor.model.document.selection);this.isEnabled=!!e,this.value=this._getValue(e)}execute(e={}){const t=this.editor.model,i=t.document.selection,{value:n,batch:s}=e,o=rM(i),r=this._getValueToSet(n);t.enqueueChange(s,(e=>{r?e.setAttribute(this.attributeName,r,o):e.removeAttribute(this.attributeName,o)}))}_getValue(e){if(!e)return;const t=e.getAttribute(this.attributeName);return t!==this._defaultValue?t:void 0}_getValueToSet(e){if(e!==this._defaultValue)return e}constructor(e,t,i){super(e),this.attributeName=t,this._defaultValue=i}}class PN extends IN{constructor(e,t){super(e,"tableBackgroundColor",t)}}class VN extends IN{_getValue(e){if(!e)return;const t=cN(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}constructor(e,t){super(e,"tableBorderColor",t)}}class RN extends IN{_getValue(e){if(!e)return;const t=cN(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}constructor(e,t){super(e,"tableBorderStyle",t)}}class BN extends IN{_getValue(e){if(!e)return;const t=cN(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}_getValueToSet(e){const t=dN(e,"px");if(t!==this._defaultValue)return t}constructor(e,t){super(e,"tableBorderWidth",t)}}class ON extends IN{_getValueToSet(e){if((e=dN(e,"px"))!==this._defaultValue)return e}constructor(e,t){super(e,"tableWidth",t)}}class MN extends IN{_getValueToSet(e){if((e=dN(e,"px"))!==this._defaultValue)return e}constructor(e,t){super(e,"tableHeight",t)}}class LN extends IN{constructor(e,t){super(e,"tableAlignment",t)}}const NN=/^(left|center|right)$/,FN=/^(left|none|right)$/;class DN extends Na{static get pluginName(){return"TablePropertiesEditing"}static get requires(){return[bL]}init(){const e=this.editor,t=e.model.schema,i=e.conversion;e.config.define("table.tableProperties.defaultProperties",{});const n=hN(e.config.get("table.tableProperties.defaultProperties"),{includeAlignmentProperty:!0});e.data.addStyleProcessorRules(pm),function(e,t,i){const n={width:"tableBorderWidth",color:"tableBorderColor",style:"tableBorderStyle"};e.extend("table",{allowAttributes:Object.values(n)}),YO(t,"table",n,i),eM(t,{modelAttribute:n.color,styleName:"border-color"}),eM(t,{modelAttribute:n.style,styleName:"border-style"}),eM(t,{modelAttribute:n.width,styleName:"border-width"})}(t,i,{color:n.borderColor,style:n.borderStyle,width:n.borderWidth}),e.commands.add("tableBorderColor",new VN(e,n.borderColor)),e.commands.add("tableBorderStyle",new RN(e,n.borderStyle)),e.commands.add("tableBorderWidth",new BN(e,n.borderWidth)),function(e,t,i){e.extend("table",{allowAttributes:["tableAlignment"]}),t.for("downcast").attributeToAttribute({model:{name:"table",key:"tableAlignment"},view:e=>({key:"style",value:{float:"center"===e?"none":e}}),converterPriority:"high"}),t.for("upcast").attributeToAttribute({view:{name:/^(table|figure)$/,styles:{float:FN}},model:{key:"tableAlignment",value:e=>{let t=e.getStyle("float");return"none"===t&&(t="center"),t===i?null:t}}}).attributeToAttribute({view:{attributes:{align:NN}},model:{name:"table",key:"tableAlignment",value:e=>{const t=e.getAttribute("align");return t===i?null:t}}})}(t,i,n.alignment),e.commands.add("tableAlignment",new LN(e,n.alignment)),zN(t,i,{modelAttribute:"tableWidth",styleName:"width",defaultValue:n.width}),e.commands.add("tableWidth",new ON(e,n.width)),zN(t,i,{modelAttribute:"tableHeight",styleName:"height",defaultValue:n.height}),e.commands.add("tableHeight",new MN(e,n.height)),e.data.addStyleProcessorRules(fm),function(e,t,i){const{modelAttribute:n}=i;e.extend("table",{allowAttributes:[n]}),QO(t,{viewElement:"table",...i}),eM(t,i)}(t,i,{modelAttribute:"tableBackgroundColor",styleName:"background-color",defaultValue:n.backgroundColor}),e.commands.add("tableBackgroundColor",new PN(e,n.backgroundColor))}}function zN(e,t,i){const{modelAttribute:n}=i;e.extend("table",{allowAttributes:[n]}),QO(t,{viewElement:/^(table|figure)$/,shouldUpcast:e=>!("table"==e.name&&"figure"==e.parent.name),...i}),XO(t,{modelElement:"table",...i})}const HN={left:Dm.objectLeft,center:Dm.objectCenter,right:Dm.objectRight};class $N extends Tg{render(){super.render(),Vg({view:this}),[this.borderColorInput,this.backgroundInput].forEach((e=>{e.fieldView.focusCycler.on("forwardCycle",(e=>{this._focusCycler.focusNext(),e.stop()})),e.fieldView.focusCycler.on("backwardCycle",(e=>{this._focusCycler.focusPrevious(),e.stop()}))})),[this.borderStyleDropdown,this.borderColorInput,this.borderWidthInput,this.backgroundInput,this.widthInput,this.heightInput,this.alignmentToolbar,this.saveButtonView,this.cancelButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createBorderFields(){const e=this.options.defaultTableProperties,t={style:e.borderStyle,width:e.borderWidth,color:e.borderColor},i=QL({colorConfig:this.options.borderColors,columns:5,defaultColorValue:t.color,colorPickerConfig:this.options.colorPickerConfig}),n=this.locale,s=this.t,o=s("Style"),r=new Bg(n);r.text=s("Border");const a=$L(s),l=new bf(n,ep);l.set({label:o,class:"ck-table-form__border-style"}),l.fieldView.buttonView.set({ariaLabel:o,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:o}),l.fieldView.buttonView.bind("label").to(this,"borderStyle",(e=>a[e||"none"])),l.fieldView.on("execute",(e=>{this.borderStyle=e.source._borderStyleValue})),l.bind("isEmpty").to(this,"borderStyle",(e=>!e)),Gf(l.fieldView,KL(this,t.style),{role:"menu",ariaLabel:o});const c=new bf(n,Qf);c.set({label:s("Width"),class:"ck-table-form__border-width"}),c.fieldView.bind("value").to(this,"borderWidth"),c.bind("isEnabled").to(this,"borderStyle",UN),c.fieldView.on("input",(()=>{this.borderWidth=c.fieldView.element.value}));const d=new bf(n,i);return d.set({label:s("Color"),class:"ck-table-form__border-color"}),d.fieldView.bind("value").to(this,"borderColor"),d.bind("isEnabled").to(this,"borderStyle",UN),d.fieldView.on("input",(()=>{this.borderColor=d.fieldView.value})),this.on("change:borderStyle",((e,i,n,s)=>{UN(n)||(this.borderColor="",this.borderWidth=""),UN(s)||(this.borderColor=t.color,this.borderWidth=t.width)})),{borderRowLabel:r,borderStyleDropdown:l,borderColorInput:d,borderWidthInput:c}}_createBackgroundFields(){const e=this.locale,t=this.t,i=new Bg(e);i.text=t("Background");const n=QL({colorConfig:this.options.backgroundColors,columns:5,defaultColorValue:this.options.defaultTableProperties.backgroundColor,colorPickerConfig:this.options.colorPickerConfig}),s=new bf(e,n);return s.set({label:t("Color"),class:"ck-table-properties-form__background"}),s.fieldView.bind("value").to(this,"backgroundColor"),s.fieldView.on("input",(()=>{this.backgroundColor=s.fieldView.value})),{backgroundRowLabel:i,backgroundInput:s}}_createDimensionFields(){const e=this.locale,t=this.t,i=new Bg(e);i.text=t("Dimensions");const n=new bf(e,Qf);n.set({label:t("Width"),class:"ck-table-form__dimensions-row__width"}),n.fieldView.bind("value").to(this,"width"),n.fieldView.on("input",(()=>{this.width=n.fieldView.element.value}));const s=new Tg(e);s.setTemplate({tag:"span",attributes:{class:["ck-table-form__dimension-operator"]},children:[{text:"×"}]});const o=new bf(e,Qf);return o.set({label:t("Height"),class:"ck-table-form__dimensions-row__height"}),o.fieldView.bind("value").to(this,"height"),o.fieldView.on("input",(()=>{this.height=o.fieldView.element.value})),{dimensionsLabel:i,widthInput:n,operatorLabel:s,heightInput:o}}_createAlignmentFields(){const e=this.locale,t=this.t,i=new Bg(e);i.text=t("Alignment");const n=new Mf(e);return n.set({isCompact:!0,ariaLabel:t("Table alignment toolbar")}),ZL({view:this,icons:HN,toolbar:n,labels:this._alignmentLabels,propertyName:"alignment",defaultValue:this.options.defaultTableProperties.alignment}),{alignmentLabel:i,alignmentToolbar:n}}_createActionButtons(){const e=this.locale,t=this.t,i=new Hg(e),n=new Hg(e),s=[this.borderWidthInput,this.borderColorInput,this.backgroundInput,this.widthInput,this.heightInput];return i.set({label:t("Save"),icon:Dm.check,class:"ck-button-save",type:"submit",withText:!0}),i.bind("isEnabled").toMany(s,"errorText",((...e)=>e.every((e=>!e)))),n.set({label:t("Cancel"),icon:Dm.cancel,class:"ck-button-cancel",withText:!0}),n.delegate("execute").to(this,"cancel"),{saveButtonView:i,cancelButtonView:n}}get _alignmentLabels(){const e=this.locale,t=this.t,i=t("Align table to the left"),n=t("Center table"),s=t("Align table to the right");return"rtl"===e.uiLanguageDirection?{right:s,center:n,left:i}:{left:i,center:n,right:s}}constructor(e,t){super(e),this.set({borderStyle:"",borderWidth:"",borderColor:"",backgroundColor:"",width:"",height:"",alignment:""}),this.options=t;const{borderStyleDropdown:i,borderWidthInput:n,borderColorInput:s,borderRowLabel:o}=this._createBorderFields(),{backgroundRowLabel:r,backgroundInput:a}=this._createBackgroundFields(),{widthInput:l,operatorLabel:c,heightInput:d,dimensionsLabel:h}=this._createDimensionFields(),{alignmentToolbar:u,alignmentLabel:m}=this._createAlignmentFields();this.focusTracker=new ya,this.keystrokes=new ka,this.children=this.createCollection(),this.borderStyleDropdown=i,this.borderWidthInput=n,this.borderColorInput=s,this.backgroundInput=a,this.widthInput=l,this.heightInput=d,this.alignmentToolbar=u;const{saveButtonView:g,cancelButtonView:f}=this._createActionButtons();this.saveButtonView=g,this.cancelButtonView=f,this._focusables=new og,this._focusCycler=new Tf({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.children.add(new Up(e,{label:this.t("Table properties")})),this.children.add(new XL(e,{labelView:o,children:[o,i,s,n],class:"ck-table-form__border-row"})),this.children.add(new XL(e,{labelView:r,children:[r,a],class:"ck-table-form__background-row"})),this.children.add(new XL(e,{children:[new XL(e,{labelView:h,children:[h,l,c,d],class:"ck-table-form__dimensions-row"}),new XL(e,{labelView:m,children:[m,u],class:"ck-table-properties-form__alignment-row"})]})),this.children.add(new XL(e,{children:[this.saveButtonView,this.cancelButtonView],class:"ck-table-form__action-row"})),this.setTemplate({tag:"form",attributes:{class:["ck","ck-form","ck-table-form","ck-table-properties-form"],tabindex:"-1"},children:this.children})}}function UN(e){return"none"!==e}const WN={borderStyle:"tableBorderStyle",borderColor:"tableBorderColor",borderWidth:"tableBorderWidth",backgroundColor:"tableBackgroundColor",width:"tableWidth",height:"tableHeight",alignment:"tableAlignment"};class jN extends Na{static get requires(){return[Tb]}static get pluginName(){return"TablePropertiesUI"}init(){const e=this.editor,t=e.t;this._defaultTableProperties=hN(e.config.get("table.tableProperties.defaultProperties"),{includeAlignmentProperty:!0}),this._balloon=e.plugins.get(Tb),e.ui.componentFactory.add("tableProperties",(i=>{const n=new Hg(i);n.set({label:t("Table properties"),icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M8 2v5h4V2h1v5h5v1h-5v4h.021l-.172.351-1.916.28-.151.027c-.287.063-.54.182-.755.341L8 13v5H7v-5H2v-1h5V8H2V7h5V2h1zm4 6H8v4h4V8z" opacity=".6"/><path d="m15.5 11.5 1.323 2.68 2.957.43-2.14 2.085.505 2.946L15.5 18.25l-2.645 1.39.505-2.945-2.14-2.086 2.957-.43L15.5 11.5zM17 1a2 2 0 0 1 2 2v9.475l-.85-.124-.857-1.736a2.048 2.048 0 0 0-.292-.44L17 3H3v14h7.808l.402.392L10.935 19H3a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2h14z"/></svg>',tooltip:!0}),this.listenTo(n,"execute",(()=>this._showView()));const s=Object.values(WN).map((t=>e.commands.get(t)));return n.bind("isEnabled").toMany(s,"isEnabled",((...e)=>e.some((e=>e)))),n}))}destroy(){super.destroy(),this.view&&this.view.destroy()}_createPropertiesView(){const e=this.editor,t=e.config.get("table.tableProperties"),i=Kg(t.borderColors),n=Gg(e.locale,i),s=Kg(t.backgroundColors),o=Gg(e.locale,s),r=!1!==t.colorPicker,a=new $N(e.locale,{borderColors:n,backgroundColors:o,defaultTableProperties:this._defaultTableProperties,colorPickerConfig:!!r&&(t.colorPicker||{})}),l=e.t;a.render(),this.listenTo(a,"submit",(()=>{this._hideView()})),this.listenTo(a,"cancel",(()=>{this._undoStepBatch.operations.length&&e.execute("undo",this._undoStepBatch),this._hideView()})),a.keystrokes.set("Esc",((e,t)=>{this._hideView(),t()})),Sg({emitter:a,activator:()=>this._isViewInBalloon,contextElements:[this._balloon.view.element],callback:()=>this._hideView()});const c=UL(l),d=WL(l);return a.on("change:borderStyle",this._getPropertyChangeCallback("tableBorderStyle")),a.on("change:borderColor",this._getValidatedPropertyChangeCallback({viewField:a.borderColorInput,commandName:"tableBorderColor",errorText:c,validator:jL})),a.on("change:borderWidth",this._getValidatedPropertyChangeCallback({viewField:a.borderWidthInput,commandName:"tableBorderWidth",errorText:d,validator:GL})),a.on("change:backgroundColor",this._getValidatedPropertyChangeCallback({viewField:a.backgroundInput,commandName:"tableBackgroundColor",errorText:c,validator:jL})),a.on("change:width",this._getValidatedPropertyChangeCallback({viewField:a.widthInput,commandName:"tableWidth",errorText:d,validator:qL})),a.on("change:height",this._getValidatedPropertyChangeCallback({viewField:a.heightInput,commandName:"tableHeight",errorText:d,validator:qL})),a.on("change:alignment",this._getPropertyChangeCallback("tableAlignment")),a}_fillViewFormFromCommandValues(){const e=this.editor.commands,t=e.get("tableBorderStyle");Object.entries(WN).map((([t,i])=>{const n=t,s=this._defaultTableProperties[n]||"";return[n,e.get(i).value||s]})).forEach((([e,i])=>{("borderColor"!==e&&"borderWidth"!==e||"none"!==t.value)&&this.view.set(e,i)})),this._isReady=!0}_showView(){const e=this.editor;this.view||(this.view=this._createPropertiesView()),this.listenTo(e.ui,"update",(()=>{this._updateView()})),this._fillViewFormFromCommandValues(),this._balloon.add({view:this.view,position:rN(e)}),this._undoStepBatch=e.model.createBatch(),this.view.focus()}_hideView(){const e=this.editor;this.stopListening(e.ui,"update"),this._isReady=!1,this.view.saveButtonView.focus(),this._balloon.remove(this.view),this.editor.editing.view.focus()}_updateView(){const e=this.editor;OL(e.editing.view.document.selection)?this._isViewVisible&&oN(e,"table"):this._hideView()}get _isViewVisible(){return!!this.view&&this._balloon.visibleView===this.view}get _isViewInBalloon(){return!!this.view&&this._balloon.hasView(this.view)}_getPropertyChangeCallback(e){return(t,i,n)=>{this._isReady&&this.editor.execute(e,{value:n,batch:this._undoStepBatch})}}_getValidatedPropertyChangeCallback(e){const{commandName:t,viewField:i,validator:n,errorText:s}=e,o=ko((()=>{i.errorText=s}),500);return(e,s,r)=>{o.cancel(),this._isReady&&(n(r)?(this.editor.execute(t,{value:r,batch:this._undoStepBatch}),i.errorText=null):o())}}constructor(e){super(e),this.view=null,e.config.define("table.tableProperties",{borderColors:JL,backgroundColors:JL})}}class qN extends Na{static get pluginName(){return"TableProperties"}static get requires(){return[DN,jN]}}function GN(e){e.document.registerPostFixer((t=>function(e,t){const i=t.document.differ.getChanges();let n=!1;for(const t of i){if("insert"!=t.type)continue;const i=t.position.parent;if(i.is("element","table")||"table"==t.name){const s="table"==t.name?t.position.nodeAfter:i,o=Array.from(s.getChildren()).filter((e=>e.is("element","caption"))),r=o.shift();if(!r)continue;for(const t of o)e.move(e.createRangeIn(t),r,"end"),e.remove(t);r.nextSibling&&(e.move(e.createRangeOn(r),s,"end"),n=!0),n=!!o.length||n}}return n}(t,e)))}function KN(e){return!!e&&e.is("element","table")}function ZN(e){for(const t of e.getChildren())if(t.is("element","caption"))return t;return null}function JN(e){const t=e.parent;return"figcaption"==e.name&&t&&t.is("element","figure")&&t.hasClass("table")||"caption"==e.name&&t&&t.is("element","table")?{name:!0}:null}class QN extends Da{refresh(){const e=rM(this.editor.model.document.selection);this.isEnabled=!!e,this.isEnabled?this.value=!!ZN(e):this.value=!1}execute({focusCaptionOnShow:e=!1}={}){this.editor.model.change((t=>{this.value?this._hideTableCaption(t):this._showTableCaption(t,e)}))}_showTableCaption(e,t){const i=this.editor.model,n=rM(i.document.selection),s=this.editor.plugins.get("TableCaptionEditing")._getSavedCaption(n)||e.createElement("caption");i.insertContent(s,n,"end"),t&&e.setSelection(s,"in")}_hideTableCaption(e){const t=this.editor.model,i=rM(t.document.selection),n=this.editor.plugins.get("TableCaptionEditing"),s=ZN(i);n._saveCaption(i,s),t.deleteContent(e.createSelection(s,"on"))}}class YN extends Na{static get pluginName(){return"TableCaptionEditing"}init(){const e=this.editor,t=e.model.schema,i=e.editing.view,n=e.t;t.isRegistered("caption")?t.extend("caption",{allowIn:"table"}):t.register("caption",{allowIn:"table",allowContentOf:"$block",isLimit:!0}),e.commands.add("toggleTableCaption",new QN(this.editor)),e.conversion.for("upcast").elementToElement({view:JN,model:"caption"}),e.conversion.for("dataDowncast").elementToElement({model:"caption",view:(e,{writer:t})=>KN(e.parent)?t.createContainerElement("figcaption"):null}),e.conversion.for("editingDowncast").elementToElement({model:"caption",view:(e,{writer:t})=>{if(!KN(e.parent))return null;const s=t.createEditableElement("figcaption");return t.setCustomProperty("tableCaption",!0,s),s.placeholder=n("Enter table caption"),Ga({view:i,element:s,keepOnFocus:!0}),dy(s,t)}}),GN(e.model)}_getSavedCaption(e){const t=this._savedCaptionsMap.get(e);return t?Gc.fromJSON(t):null}_saveCaption(e,t){this._savedCaptionsMap.set(e,t.toJSON())}constructor(e){super(e),this._savedCaptionsMap=new WeakMap}}class XN extends Na{static get pluginName(){return"TableCaptionUI"}init(){const e=this.editor,t=e.editing.view,i=e.t;e.ui.componentFactory.add("toggleTableCaption",(n=>{const s=e.commands.get("toggleTableCaption"),o=new Hg(n);return o.set({icon:Dm.caption,tooltip:!0,isToggleable:!0}),o.bind("isOn","isEnabled").to(s,"value","isEnabled"),o.bind("label").to(s,"value",(e=>i(e?"Toggle caption off":"Toggle caption on"))),this.listenTo(o,"execute",(()=>{if(e.execute("toggleTableCaption",{focusCaptionOnShow:!0}),s.value){const i=function(e){const t=rM(e);return t?ZN(t):null}(e.model.document.selection),n=e.editing.mapper.toViewElement(i);if(!n)return;t.scrollToTheSelection(),t.change((e=>{e.addClass("table__caption_highlighted",n)}))}e.editing.view.focus()})),o}))}}class eF extends Na{static get pluginName(){return"TableCaption"}static get requires(){return[YN,XN]}}class tF extends Da{refresh(){this.isEnabled=!0}execute(e={}){const{model:t,plugins:i}=this.editor;let{table:n=t.document.selection.getSelectedElement(),columnWidths:s,tableWidth:o}=e;s&&(s=Array.isArray(s)?s:s.split(",")),t.change((e=>{o?e.setAttribute("tableWidth",o,n):e.removeAttribute("tableWidth",n);const t=i.get("TableColumnResizeEditing").getColumnGroupElement(n);if(!s&&!t)return;if(!s)return e.remove(t);const r=jM(s);if(t)Array.from(t.getChildren()).forEach(((t,i)=>e.setAttribute("columnWidth",r[i],t)));else{const t=e.createElement("tableColumnGroup");r.forEach((i=>e.appendElement("tableColumn",{columnWidth:i},t))),e.append(t,n)}}))}}function iF(e){return t=>t.on("element:colgroup",((t,i,n)=>{const s=i.modelCursor.findAncestor("table"),o=KM(s);if(!o)return;const r=ZM(o),a=e.getColumns(s);let l=(c=o,d=n.writer,ZM(c).reduce(((e,t)=>{const i=t.getAttribute("columnWidth"),n=t.getAttribute("colSpan");if(!n)return e.push(i),e;for(let t=0;t<n;t++)e.push(i);return d.removeAttribute("colSpan",t),e}),[]));var c,d;l=Array.from({length:a},((e,t)=>l[t]||"auto")),(l.length!=r.length||l.includes("auto"))&&GM(r,o,jM(l),n.writer)}),{priority:"low"})}class nF extends Na{static get requires(){return[bL,JM]}static get pluginName(){return"TableColumnResizeEditing"}init(){this._extendSchema(),this._registerPostFixer(),this._registerConverters(),this._registerResizingListeners(),this._registerResizerInserter();const e=this.editor,t=e.plugins.get("TableColumnResize");e.plugins.get("TableEditing").registerAdditionalSlot({filter:e=>e.is("element","tableColumnGroup"),positionOffset:0});const i=new tF(e);e.commands.add("resizeTableWidth",i),e.commands.add("resizeColumnWidths",i),this.bind("_isResizingAllowed").to(e,"isReadOnly",t,"isEnabled",i,"isEnabled",((e,t,i)=>!e&&t&&i))}destroy(){this._domEmitter.stopListening(),super.destroy()}getColumnGroupElement(e){return KM(e)}getTableColumnElements(e){return ZM(e)}getTableColumnsWidths(e){return function(e){return ZM(e).map((e=>e.getAttribute("columnWidth")))}(e)}_extendSchema(){this.editor.model.schema.extend("table",{allowAttributes:["tableWidth"]}),this.editor.model.schema.register("tableColumnGroup",{allowIn:"table",isLimit:!0}),this.editor.model.schema.register("tableColumn",{allowIn:"tableColumnGroup",allowAttributes:["columnWidth","colSpan"],isLimit:!0})}_registerPostFixer(){const e=this.editor.model;function t(e,t,i){const n=i._tableUtilsPlugin.getColumns(t);if(0===n-e.length)return e;const s=e.map((e=>Number(e.replace("%","")))),o=function(e,t){const i=new Set;for(const n of e.getChanges())if("insert"==n.type&&n.position.nodeAfter&&"tableCell"==n.position.nodeAfter.name&&n.position.nodeAfter.getAncestors().includes(t))i.add(n.position.nodeAfter);else if("remove"==n.type){const e=n.position.nodeBefore||n.position.nodeAfter;"tableCell"==e.name&&e.getAncestors().includes(t)&&i.add(e)}return i}(i.editor.model.document.differ,t);for(const e of o){const o=n-s.length;if(0===o)continue;const a=o>0,l=i._tableUtilsPlugin.getCellLocation(e).column;if(a){const e=DM(t,i.editor),n=(r=e,Array(o).fill(r));s.splice(l,0,...n)}else{const e=s.splice(l,Math.abs(o));s[l]+=WM(e)}}var r;return s.map((e=>e+"%"))}e.document.registerPostFixer((i=>{let n=!1;for(const s of function(e){const t=new Set;for(const i of e.document.differ.getChanges()){let n=null;switch(i.type){case"insert":n=["table","tableRow","tableCell"].includes(i.name)?i.position:null;break;case"remove":n=["tableRow","tableCell"].includes(i.name)?i.position:null;break;case"attribute":i.range.start.nodeAfter&&(n=["table","tableRow","tableCell"].includes(i.range.start.nodeAfter.name)?i.range.start:null)}if(!n)continue;const s=n.nodeAfter&&n.nodeAfter.is("element","table")?n.nodeAfter:n.findAncestor("table");for(const i of e.createRangeOn(s).getItems())i.is("element","table")&&KM(i)&&t.add(i)}return t}(e)){const e=this.getColumnGroupElement(s),o=this.getTableColumnElements(e),r=this.getTableColumnsWidths(e);let a=jM(r);a=t(a,s,this),Do(r,a)||(GM(o,e,a,i),n=!0)}return n}))}_registerConverters(){const e=this.editor.conversion;e.for("upcast").attributeToAttribute({view:{name:"figure",key:"style",value:{width:/[\s\S]+/}},model:{name:"table",key:"tableWidth",value:e=>e.getStyle("width")}}),e.for("downcast").attributeToAttribute({model:{name:"table",key:"tableWidth"},view:e=>({name:"figure",key:"style",value:{width:e}})}),e.elementToElement({model:"tableColumnGroup",view:"colgroup"}),e.elementToElement({model:"tableColumn",view:"col"}),e.for("downcast").add((e=>e.on("insert:table",((e,t,i)=>{const n=i.writer,s=t.item,o=i.mapper.toViewElement(s),r=o.is("element","table")?o:Array.from(o.getChildren()).find((e=>e.is("element","table")));KM(s)?n.addClass("ck-table-resized",r):n.removeClass("ck-table-resized",r)}),{priority:"low"}))),e.for("upcast").add(iF(this._tableUtilsPlugin)),e.for("upcast").attributeToAttribute({view:{name:"col",styles:{width:/.*/}},model:{key:"columnWidth",value:e=>{const t=e.getStyle("width");return t&&(t.endsWith("%")||t.endsWith("pt"))?t:"auto"}}}),e.for("upcast").attributeToAttribute({view:{name:"col",key:"span"},model:"colSpan"}),e.for("downcast").attributeToAttribute({model:{name:"tableColumn",key:"columnWidth"},view:e=>({key:"style",value:{width:e}})})}_registerResizingListeners(){const e=this.editor.editing.view;e.addObserver(SL),e.document.on("mousedown",this._onMouseDownHandler.bind(this),{priority:"high"}),this._domEmitter.listenTo(_r.window.document,"mousemove",jo(this._onMouseMoveHandler.bind(this),50)),this._domEmitter.listenTo(_r.window.document,"mouseup",this._onMouseUpHandler.bind(this))}_onMouseDownHandler(e,t){const i=t.target;if(!i.hasClass("ck-table-column-resizer"))return;if(!this._isResizingAllowed)return;const n=this.editor,s=n.editing.mapper.toModelElement(i.findAncestor("figure"));if(!n.model.canEditAt(s))return;t.preventDefault(),e.stop();const o=function(e,t,i){const n=Array(t.getColumns(e)),s=new dM(e);for(const e of s){const t=i.editing.mapper.toViewElement(e.cell),s=qM(i.editing.view.domConverter.mapViewToDom(t));(!n[e.column]||s<n[e.column])&&(n[e.column]=UM(s))}return n}(s,this._tableUtilsPlugin,n),r=i.findAncestor("table"),a=n.editing.view;Array.from(r.getChildren()).find((e=>e.is("element","colgroup")))||a.change((e=>{!function(e,t,i){const n=e.createContainerElement("colgroup");for(let i=0;i<t.length;i++){const s=e.createEmptyElement("col"),o=`${UM(t[i]/WM(t)*100)}%`;e.setStyle("width",o,s),e.insert(e.createPositionAt(n,"end"),s)}e.insert(e.createPositionAt(i,0),n)}(e,o,r)})),this._isResizingActive=!0,this._resizingData=this._getResizingData(t,o),a.change((e=>function(e,t,i){const n=i.widths.viewFigureWidth/i.widths.viewFigureParentWidth;e.addClass("ck-table-resized",t),e.addClass("ck-table-column-resizer__active",i.elements.viewResizer),e.setStyle("width",`${UM(100*n)}%`,t.findAncestor("figure"))}(e,r,this._resizingData)))}_onMouseMoveHandler(e,t){if(!this._isResizingActive)return;if(!this._isResizingAllowed)return void this._onMouseUpHandler();const{columnPosition:i,flags:{isRightEdge:n,isTableCentered:s,isLtrContent:o},elements:{viewFigure:r,viewLeftColumn:a,viewRightColumn:l},widths:{viewFigureParentWidth:c,tableWidth:d,leftColumnWidth:h,rightColumnWidth:u}}=this._resizingData,m=40-h,g=n?c-d:u-40,f=(o?1:-1)*(n&&s?2:1),p=(b=(t.clientX-i)*f,w=Math.min(m,0),v=Math.max(g,0),UM(b<=w?w:b>=v?v:b));var b,w,v;0!==p&&this.editor.editing.view.change((e=>{const t=UM(100*(h+p)/d);if(e.setStyle("width",`${t}%`,a),n){const t=UM(100*(d+p)/c);e.setStyle("width",`${t}%`,r)}else{const t=UM(100*(u-p)/d);e.setStyle("width",`${t}%`,l)}}))}_onMouseUpHandler(){if(!this._isResizingActive)return;const{viewResizer:e,modelTable:t,viewFigure:i,viewColgroup:n}=this._resizingData.elements,s=this.editor,o=s.editing.view,r=this.getColumnGroupElement(t),a=Array.from(n.getChildren()).filter((e=>e.is("view:element"))),l=r?this.getTableColumnsWidths(r):null,c=a.map((e=>e.getStyle("width"))),d=!Do(l,c),h=t.getAttribute("tableWidth"),u=i.getStyle("width"),m=h!==u;(d||m)&&(this._isResizingAllowed?s.execute("resizeTableWidth",{table:t,tableWidth:`${UM(u)}%`,columnWidths:c}):o.change((e=>{if(l)for(const t of a)e.setStyle("width",l.shift(),t);else e.remove(n);m&&(h?e.setStyle("width",h,i):e.removeStyle("width",i)),l||h||e.removeClass("ck-table-resized",[...i.getChildren()].find((e=>"table"===e.name)))}))),o.change((t=>{t.removeClass("ck-table-column-resizer__active",e)})),this._isResizingActive=!1,this._resizingData=null}_getResizingData(e,t){const i=this.editor,n=e.domEvent.clientX,s=e.target,o=s.findAncestor("td")||s.findAncestor("th"),r=i.editing.mapper.toModelElement(o),a=r.findAncestor("table"),l=function(e,t){const i=t.getCellLocation(e).column;return{leftEdge:i,rightEdge:i+(e.getAttribute("colspan")||1)-1}}(r,this._tableUtilsPlugin).rightEdge,c=l===this._tableUtilsPlugin.getColumns(a)-1,d=!a.hasAttribute("tableAlignment"),h="rtl"!==i.locale.contentLanguageDirection,u=o.findAncestor("table"),m=u.findAncestor("figure"),g=[...u.getChildren()].find((e=>e.is("element","colgroup"))),f=g.getChild(l),p=c?void 0:g.getChild(l+1);return{columnPosition:n,flags:{isRightEdge:c,isTableCentered:d,isLtrContent:h},elements:{viewResizer:s,modelTable:a,viewFigure:m,viewColgroup:g,viewLeftColumn:f,viewRightColumn:p},widths:{viewFigureParentWidth:$M(i.editing.view.domConverter.mapViewToDom(m.parent)),viewFigureWidth:$M(i.editing.view.domConverter.mapViewToDom(m)),tableWidth:zM(a,i),leftColumnWidth:t[l],rightColumnWidth:c?void 0:t[l+1]}}}_registerResizerInserter(){this.editor.conversion.for("editingDowncast").add((e=>{e.on("insert:tableCell",((e,t,i)=>{const n=t.item,s=i.mapper.toViewElement(n),o=i.writer;o.insert(o.createPositionAt(s,"end"),o.createUIElement("div",{class:"ck-table-column-resizer"}))}),{priority:"lowest"})}))}constructor(e){super(e),this._isResizingActive=!1,this.set("_isResizingAllowed",!0),this._resizingData=null,this._domEmitter=new(pr()),this._tableUtilsPlugin=e.plugins.get("TableUtils"),this.on("change:_isResizingAllowed",((t,i,n)=>{const s=n?"removeClass":"addClass";e.editing.view.change((t=>{for(const i of e.editing.view.document.roots)t[s]("ck-column-resize_disabled",e.editing.view.document.getRoot(i.rootName))}))}))}}class sF extends Na{static get requires(){return[nF,pN]}static get pluginName(){return"TableColumnResize"}}function oF(e){if(e.is("$text")||e.is("$textProxy"))return e.data;const t=e;let i="",n=null;for(const e of t.getChildren()){const t=oF(e);n&&n.is("element")&&(i+="\n"),i+=t,n=e}return i}class rF extends Na{static get pluginName(){return"WordCount"}init(){this.editor.model.document.on("change:data",jo(this._refreshStats.bind(this),250)),"function"==typeof this._config.onUpdate&&this.on("update",((e,t)=>{this._config.onUpdate(t)})),Fo(this._config.container)&&this._config.container.appendChild(this.wordCountContainer)}destroy(){this._outputView&&(this._outputView.element.remove(),this._outputView.destroy()),super.destroy()}get wordCountContainer(){const e=this.editor,t=e.t,i=e.config.get("wordCount.displayWords"),n=e.config.get("wordCount.displayCharacters"),s=rg.bind(this,this),o=[];return this._outputView||(this._outputView=new Tg,(i||void 0===i)&&(this.bind("_wordsLabel").to(this,"words",(e=>t("Words: %0",e))),o.push({tag:"div",children:[{text:[s.to("_wordsLabel")]}],attributes:{class:"ck-word-count__words"}})),(n||void 0===n)&&(this.bind("_charactersLabel").to(this,"characters",(e=>t("Characters: %0",e))),o.push({tag:"div",children:[{text:[s.to("_charactersLabel")]}],attributes:{class:"ck-word-count__characters"}})),this._outputView.setTemplate({tag:"div",attributes:{class:["ck","ck-word-count"]},children:o}),this._outputView.render()),this._outputView.element}_getText(){let e="";for(const t of this.editor.model.document.getRoots())""!==e&&(e+="\n"),e+=oF(t);return e}_getCharacters(e){return e.replace(/\n/g,"").length}_getWords(e){return(e.match(this._wordsMatchRegExp)||[]).length}_refreshStats(){const e=this._getText(),t=this.words=this._getWords(e),i=this.characters=this._getCharacters(e);this.fire("update",{words:t,characters:i})}constructor(e){super(e),this.set("characters",0),this.set("words",0),Object.defineProperties(this,{characters:{get(){return this.characters=this._getCharacters(this._getText())}},words:{get(){return this.words=this._getWords(this._getText())}}}),this.set("_wordsLabel",void 0),this.set("_charactersLabel",void 0),this._config=e.config.get("wordCount")||{},this._outputView=void 0,this._wordsMatchRegExp=i.features.isRegExpUnicodePropertySupported?new RegExp("([\\p{L}\\p{N}]+\\S?)+","gu"):/([a-zA-Z0-9À-ž]+\S?)+/gu}}export{Ng as AccessibilityHelp,HP as AdjacentListsSupport,ww as Alignment,sg as AlignmentEditing,bw as AlignmentUI,Bl as AttributeElement,Lh as AttributeOperation,qA as AutoImage,aS as AutoLink,RR as AutoMediaEmbed,Lb as AutocompleteView,nv as Autoformat,ov as Autosave,Fk as BalloonEditor,Xp as BalloonPanelView,zb as BalloonToolbar,Um as Base64UploadAdapter,o_ as BlockQuote,n_ as BlockQuoteEditing,s_ as BlockQuoteUI,Wb as BlockToolbar,Fg as BodyCollection,uv as Bold,lv as BoldEditing,hv as BoldUI,_b as BoxedEditorUIView,Al as BubblingEventInfo,zg as ButtonLabelView,Hg as ButtonView,R_ as CKBox,T_ as CKBoxEditing,N_ as CKBoxImageEdit,M_ as CKBoxImageEditEditing,L_ as CKBoxImageEditUI,r_ as CKBoxUI,p as CKEditorError,$_ as CKFinder,H_ as CKFinderEditing,F_ as CKFinderUI,Jm as CKFinderUploadAdapter,$k as ClassicEditor,Du as ClickObserver,Jy as Clipboard,K_ as ClipboardMarkersUtils,Z_ as ClipboardPipeline,sk as CloudServices,nk as CloudServicesCore,Ck as CloudServicesUploadAdapter,bv as Code,kk as CodeBlock,wk as CodeBlockEditing,yk as CodeBlockUI,gv as CodeEditing,pv as CodeUI,qg as CollapsibleView,va as Collection,Qg as ColorGridView,Ip as ColorPickerView,zp as ColorSelectorView,Jg as ColorTileView,Da as Command,Hp as ComponentFactory,dr as Config,Ua as Context,Wa as ContextPlugin,Bk as ContextWatchdog,Tb as ContextualBalloon,_h as Conversion,Pg as CssTransitionDisablerMixin,Mm as DataApiMixin,vh as DataController,mA as DataFilter,uA as DataSchema,Lc as DataTransfer,qk as DecoupledEditor,Jb as DefaultMenuBarItems,Rw as Delete,Zp as Dialog,Kp as DialogView,qp as DialogViewPosition,pu as DocumentFragment,UP as DocumentList,WP as DocumentListProperties,_d as DocumentSelection,yc as DomConverter,pr as DomEmitterMixin,Tc as DomEventData,Sc as DomEventObserver,GR as DomWrapperView,Wl as DowncastWriter,jy as DragDrop,Wy as DragDropBlockToolbar,Fy as DragDropTarget,Ef as DropdownButtonView,xf as DropdownPanelView,Af as DropdownView,Ak as EasyImage,Qd as EditingController,Hc as EditingView,Bm as Editor,bb as EditorUI,vb as EditorUIView,Pk as EditorWatchdog,Gc as Element,Lm as ElementApiMixin,sr as ElementReplacer,T as EmitterMixin,Kv as Enter,bC as Essentials,d as EventInfo,Ug as FileDialogButtonView,Hm as FileRepository,VC as FindAndReplace,PC as FindAndReplaceEditing,_C as FindAndReplaceUI,SC as FindAndReplaceUtils,yC as FindCommand,AC as FindNextCommand,EC as FindPreviousCommand,Tf as FocusCycler,Bc as FocusObserver,ya as FocusTracker,ux as Font,hx as FontBackgroundColor,cx as FontBackgroundColorEditing,dx as FontBackgroundColorUI,ax as FontColor,sx as FontColorEditing,rx as FontColorUI,GC as FontFamily,WC as FontFamilyEditing,qC as FontFamilyUI,ix as FontSize,XC as FontSizeEditing,tx as FontSizeUI,Up as FormHeaderView,LA as FullPage,RA as GeneralHtmlSupport,Ax as Heading,Tx as HeadingButtonsUI,kx as HeadingEditing,xx as HeadingUI,Hx as Highlight,Fx as HighlightEditing,Dx as HighlightUI,Nb as HighlightedTextView,lu as History,jx as HorizontalLine,Ux as HorizontalLineEditing,Wx as HorizontalLineUI,OA as HtmlComment,wh as HtmlDataProcessor,Qx as HtmlEmbed,Kx as HtmlEmbedEditing,Jx as HtmlEmbedUI,MA as HtmlPageDataProcessor,Dg as IconView,Cb as IframeView,fE as Image,uE as ImageBlock,lE as ImageBlockEditing,_E as ImageCaption,wE as ImageCaptionEditing,vE as ImageCaptionUI,pE as ImageCaptionUtils,YE as ImageCustomResizeUI,sE as ImageEditing,gE as ImageInline,FE as ImageInsert,hE as ImageInsertUI,NE as ImageInsertViaUrl,XE as ImageResize,$E as ImageResizeButtons,zE as ImageResizeEditing,GE as ImageResizeHandles,oE as ImageSizeAttributes,vT as ImageStyle,gT as ImageStyleEditing,fT as ImageStyleUI,YA as ImageTextAlternative,KA as ImageTextAlternativeEditing,QA as ImageTextAlternativeUI,_T as ImageToolbar,OE as ImageUpload,RE as ImageUploadEditing,AE as ImageUploadProgress,xE as ImageUploadUI,UA as ImageUtils,xT as Indent,IT as IndentBlock,kT as IndentEditing,CT as IndentUI,kb as InlineEditableUIView,Qk as InlineEditor,Cw as Input,yf as InputNumberView,_f as InputTextView,vf as InputView,Rh as InsertOperation,_w as InsertTextCommand,kv as Italic,vv as ItalicEditing,yv as ItalicUI,ka as KeystrokeHandler,Bg as LabelView,bf as LabeledFieldView,WI as LegacyIndentCommand,vP as LegacyList,bP as LegacyListEditing,PP as LegacyListProperties,xP as LegacyListPropertiesEditing,nP as LegacyListUtils,zP as LegacyTodoList,FP as LegacyTodoListEditing,cS as Link,GT as LinkCommand,XT as LinkEditing,gS as LinkImage,dS as LinkImageEditing,mS as LinkImageUI,sS as LinkUI,lI as List,DS as ListCommand,nI as ListEditing,NS as ListIndentCommand,Hf as ListItemGroupView,Df as ListItemView,PI as ListProperties,CI as ListPropertiesEditing,AI as ListPropertiesUI,yI as ListPropertiesUtils,zf as ListSeparatorView,aI as ListUI,$S as ListUtils,$f as ListView,eu as LivePosition,pd as LiveRange,wa as Locale,BB as MSWordNormalizer,vR as Markdown,Mh as MarkerOperation,ol as Matcher,MR as MediaEmbed,PR as MediaEmbedEditing,LR as MediaEmbedToolbar,OR as MediaEmbedUI,sB as Mention,DR as MentionEditing,KR as MentionListItemView,QR as MentionUI,qR as MentionsView,uw as MenuBarMenuListItemButtonView,mw as MenuBarMenuListItemFileDialogButtonView,qb as MenuBarMenuListItemView,hw as MenuBarMenuListView,dw as MenuBarMenuView,fw as MenuBarView,Oh as MergeOperation,mB as Minimap,Nu as Model,zu as MouseObserver,Vh as MoveOperation,Ha as MultiCommand,tC as MultiRootEditor,Nh as NoOperation,xb as Notification,Yo as ObservableMixin,Ec as Observer,$h as OperationFactory,bB as PageBreak,fB as PageBreakEditing,pB as PageBreakUI,px as Paragraph,wx as ParagraphButtonUI,yR as PasteFromMarkdownExperimental,$B as PasteFromOffice,Zy as PastePlainText,Fm as PendingActions,yT as PictureEditing,RL as PlainTableOutput,Na as Plugin,Jc as Position,id as Range,Ir as Rect,GB as RemoveFormat,qB as RemoveFormatEditing,WB as RemoveFormatUI,Fh as RenameOperation,dc as Renderer,xC as ReplaceAllCommand,CC as ReplaceCommand,Or as ResizeObserver,lO as RestrictedEditingMode,iO as RestrictedEditingModeEditing,aO as RestrictedEditingModeUI,Dh as RootAttributeOperation,zh as RootOperation,Bb as SearchInfoView,Mb as SearchTextView,lC as SelectAll,rC as SelectAllEditing,aC as SelectAllUI,Yv as ShiftEnter,pO as ShowBlocks,mO as ShowBlocksCommand,gO as ShowBlocksEditing,fO as ShowBlocksUI,jm as SimpleUploadAdapter,_O as SourceEditing,SO as SpecialCharacters,IO as SpecialCharactersArrows,BO as SpecialCharactersCurrency,OO as SpecialCharactersEssentials,RO as SpecialCharactersLatin,VO as SpecialCharactersMathematical,PO as SpecialCharactersText,Fb as SpinnerView,Uf as SplitButtonView,Bh as SplitOperation,uO as StandardEditingMode,dO as StandardEditingModeEditing,hO as StandardEditingModeUI,Vb as StickyPanelView,Tv as Strikethrough,xv as StrikethroughEditing,Ev as StrikethroughUI,JO as Style,ZO as StyleEditing,$O as StyleUI,zO as StyleUtils,ll as StylesMap,cl as StylesProcessor,Rv as Subscript,Iv as SubscriptEditing,Vv as SubscriptUI,Nv as Superscript,Ov as SuperscriptEditing,Lv as SuperscriptUI,$g as SwitchButtonView,zc as TabObserver,VL as Table,eF as TableCaption,YN as TableCaptionEditing,XN as TableCaptionUI,SN as TableCellProperties,TN as TableCellPropertiesEditing,mN as TableCellPropertiesUI,pN as TableCellWidthEditing,CL as TableClipboard,sF as TableColumnResize,nF as TableColumnResizeEditing,bL as TableEditing,TL as TableKeyboard,IL as TableMouse,qN as TableProperties,DN as TablePropertiesEditing,jN as TablePropertiesUI,kL as TableSelection,FL as TableToolbar,_L as TableUI,JM as TableUtils,rg as Template,jc as Text,OT as TextPartLanguage,RT as TextPartLanguageEditing,BT as TextPartLanguageUI,qc as TextProxy,qw as TextTransformation,Mw as TextWatcher,kf as TextareaView,Ix as Title,jP as TodoDocumentList,zI as TodoList,OI as TodoListEditing,DI as TodoListUI,Rf as ToolbarLineBreakView,Vf as ToolbarSeparatorView,Mf as ToolbarView,nb as TooltipManager,Kc as TreeWalker,Lw as TwoStepCaretMovement,Bw as Typing,$v as Underline,Dv as UnderlineEditing,Hv as UnderlineUI,pC as Undo,gC as UndoEditing,fC as UndoUI,ZT as UnlinkCommand,Hu as UpcastWriter,Tg as View,Bl as ViewAttributeElement,og as ViewCollection,gl as ViewContainerElement,Rl as ViewDocument,Ul as ViewDocumentFragment,pl as ViewEditableElement,ul as ViewElement,Ll as ViewEmptyElement,Ab as ViewModel,Hl as ViewRawElement,wl as ViewRootEditableElement,nl as ViewText,vl as ViewTreeWalker,Fl as ViewUIElement,ty as WIDGET_CLASS_NAME,iy as WIDGET_SELECTED_CLASS_NAME,Ek as Watchdog,Ey as Widget,My as WidgetResize,Sy as WidgetToolbarRepository,ky as WidgetTypeAround,rF as WordCount,or as abortableDebounce,fm as addBackgroundRules,pm as addBorderRules,Rg as addKeyboardHandlingForGrid,Gf as addListToDropdown,Em as addMarginRules,Tm as addPaddingRules,jf as addToolbarToDropdown,Om as attachToForm,gy as calculateResizeHostAncestorWidth,fy as calculateResizeHostPercentageWidth,Sg as clickOutsideHandler,ar as compareArrays,rr as count,Wf as createDropdown,cr as createElement,ep as createLabeledDropdown,Yf as createLabeledInputNumber,Qf as createLabeledInputText,Xf as createLabeledTextarea,Sa as delay,a as diff,l as diffToChanges,Ka as disablePlaceholder,Ga as enablePlaceholder,i as env,Ea as exponentialDelay,s as fastDiff,Qw as findAttributeRange,Yw as findAttributeRangeBound,yr as findClosestScrollableAncestor,hy as findOptimalInsertionRange,_a as first,Zf as focusChildOnDropdownOpen,kr as getAncestors,xr as getBorderWidths,um as getBoxSidesShorthandValue,hm as getBoxSidesValueReducer,dm as getBoxSidesValues,la as getCode,Cr as getDataFromElement,da as getEnvKeystrokeText,fl as getFillerOffset,cy as getLabel,fa as getLanguageDirection,Ow as getLastTextLine,ua as getLocalizedArrowKeyCodeDirection,Gg as getLocalizedColorOptions,$r as getOptimalPosition,mm as getPositionShorthandNormalizer,gm as getShorthandValues,_r as global,Ja as hidePlaceholder,Dm as icons,Nr as indexOf,Ig as injectCssTransitionDisabler,Xw as inlineHighlight,Fr as insertAt,g as insertToPriorityArray,ha as isArrowKeyCode,am as isAttachment,Zu as isColor,Pa as isCombiningMark,Dr as isComment,If as isFocusable,ma as isForwardArrowKeyCode,Va as isHighSurrogateHalf,Oa as isInsideCombinedSymbol,La as isInsideEmojiSequence,Ba as isInsideSurrogatePair,lr as isIterable,Xu as isLength,Qu as isLineStyle,Ra as isLowSurrogateHalf,mr as isNode,tm as isPercentage,om as isPosition,Er as isRange,nm as isRepeat,Ar as isText,cm as isURL,zr as isValidAttributeName,Pf as isViewWithFocusCycler,Hr as isVisible,ny as isWidget,ra as keyCodes,w as logError,b as logWarning,c as mix,Qa as needsPlaceholder,Kg as normalizeColorOptions,Qb as normalizeMenuBarConfig,Zg as normalizeSingleColorDefinition,Bf as normalizeToolbarConfig,HB as parseHtml,ca as parseKeystroke,m as priorities,k as releaseDate,jr as remove,Aa as retry,Gr as scrollAncestorsToShowTarget,qr as scrollViewportToShowTarget,Nm as secureSourceElement,Mr as setDataInElement,ay as setHighlightHandling,ly as setLabel,Za as showPlaceholder,Ta as spliceArray,Vg as submitHandler,pa as toArray,Ca as toMap,Lr as toUnit,sy as toWidget,dy as toWidgetEditable,Gh as transformSets,u as uid,Ia as verifyLicense,y as version,uy as viewToModelPositionOutsideModelElement,xa as wait};
6
+ //# sourceMappingURL=index.js.map