diff --git a/config/nova-ckeditor.php b/config/nova-ckeditor.php index 147a646..c9131a3 100644 --- a/config/nova-ckeditor.php +++ b/config/nova-ckeditor.php @@ -168,6 +168,7 @@ 'undo', 'redo', '|', + 'showBlocks', 'sourceEditing' ], diff --git a/dist/js/field.js b/dist/js/field.js index 851d140..3400e1d 100644 --- a/dist/js/field.js +++ b/dist/js/field.js @@ -1,2 +1,2 @@ /*! For license information please see field.js.LICENSE.txt */ -!function(e){const t=e.en=e.en||{};t.dictionary=Object.assign(t.dictionary||{},{"%0 of %1":"%0 of %1",Accept:"Accept","Align center":"Align center","Align left":"Align left","Align right":"Align right",Aquamarine:"Aquamarine",Big:"Big",Black:"Black","Block quote":"Block quote",Blue:"Blue",Bold:"Bold","Break text":"Break text","Bulleted List":"Bulleted List",Cancel:"Cancel","Caption for image: %0":"Caption for image: %0","Caption for the image":"Caption for the image","Centered image":"Centered image","Change image text alternative":"Change image text alternative","Choose heading":"Choose heading","Choose language":"Choose language",Code:"Code","Color picker":"Color picker",Column:"Column","Decrease indent":"Decrease indent",Default:"Default","Delete column":"Delete column","Delete row":"Delete row","Dim grey":"Dim grey","Document colors":"Document colors",Downloadable:"Downloadable","Dropdown toolbar":"Dropdown toolbar","Edit block":"Edit block","Edit link":"Edit link","Edit source":"Edit source","Editor block content toolbar":"Editor block content toolbar","Editor contextual toolbar":"Editor contextual toolbar","Editor editing area: %0":"Editor editing area: %0","Editor toolbar":"Editor toolbar","Empty snippet content":"Empty snippet content","Enter image caption":"Enter image caption","Font Background Color":"Font Background Color","Font Color":"Font Color","Font Family":"Font Family","Font Size":"Font Size","Full size image":"Full size image",Green:"Green",Grey:"Grey","Header column":"Header column","Header row":"Header row",Heading:"Heading","Heading 1":"Heading 1","Heading 2":"Heading 2","Heading 3":"Heading 3","Heading 4":"Heading 4","Heading 5":"Heading 5","Heading 6":"Heading 6",HEX:"HEX","Horizontal line":"Horizontal line","HTML object":"HTML object","HTML snippet":"HTML snippet",Huge:"Huge","Image resize list":"Image resize list","Image toolbar":"Image toolbar","image widget":"image widget","In line":"In line","Increase indent":"Increase indent","Insert code block":"Insert code block","Insert column left":"Insert column left","Insert column right":"Insert column right","Insert HTML":"Insert HTML","Insert image":"Insert image","Insert media":"Insert media","Insert paragraph after block":"Insert paragraph after block","Insert paragraph before block":"Insert paragraph before block","Insert row above":"Insert row above","Insert row below":"Insert row below","Insert table":"Insert table",Italic:"Italic",Justify:"Justify",Language:"Language","Left aligned image":"Left aligned image","Light blue":"Light blue","Light green":"Light green","Light grey":"Light grey",Link:"Link","Link URL":"Link URL","Media URL":"Media URL","media widget":"media widget","Merge cell down":"Merge cell down","Merge cell left":"Merge cell left","Merge cell right":"Merge cell right","Merge cell up":"Merge cell up","Merge cells":"Merge cells",Next:"Next","No preview available":"No preview available","Numbered List":"Numbered List","Open in a new tab":"Open in a new tab","Open link in new tab":"Open link in new tab","Open media in new tab":"Open media in new tab",Orange:"Orange",Original:"Original",Paragraph:"Paragraph","Paste raw HTML here...":"Paste raw HTML here...","Paste the media URL in the input.":"Paste the media URL in the input.","Plain text":"Plain text","Press Enter to type after or press Shift + Enter to type before the widget":"Press Enter to type after or press Shift + Enter to type before the widget",Previous:"Previous",Purple:"Purple",Red:"Red",Redo:"Redo","Remove color":"Remove color","Remove Format":"Remove Format","Remove language":"Remove language","Resize image":"Resize image","Resize image to %0":"Resize image to %0","Resize image to the original size":"Resize image to the original size","Rich Text Editor":"Rich Text Editor","Right aligned image":"Right aligned image",Row:"Row",Save:"Save","Save changes":"Save changes","Select all":"Select all","Select column":"Select column","Select row":"Select row","Show more items":"Show more items","Side image":"Side image",Small:"Small",Source:"Source","Split cell horizontally":"Split cell horizontally","Split cell vertically":"Split cell vertically",Strikethrough:"Strikethrough",Subscript:"Subscript",Superscript:"Superscript","Table toolbar":"Table toolbar","Text alignment":"Text alignment","Text alignment toolbar":"Text alignment toolbar","Text alternative":"Text alternative","The URL must not be empty.":"The URL must not be empty.","This link has no URL":"This link has no URL","This media URL is not supported.":"This media URL is not supported.",Tiny:"Tiny","Tip: Paste the URL into the content to embed faster.":"Tip: Paste the URL into the content to embed faster.","Toggle caption off":"Toggle caption off","Toggle caption on":"Toggle caption on",Turquoise:"Turquoise",Underline:"Underline",Undo:"Undo",Unlink:"Unlink","Upload failed":"Upload failed","Upload in progress":"Upload in progress",White:"White","Widget toolbar":"Widget toolbar","Wrap text":"Wrap text",Yellow:"Yellow"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})),(()=>{var __webpack_modules__={1185:(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{"use strict";__webpack_require__.d(__webpack_exports__,{Z:()=>__WEBPACK_DEFAULT_EXPORT__});var _ckeditor_ckeditor__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(6221),_snippet_browser__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(6401),_media_browser__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(6665),_mixins_hasUUID__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(9034),laravel_nova__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__(9226),laravel_nova__WEBPACK_IMPORTED_MODULE_4___default=__webpack_require__.n(laravel_nova__WEBPACK_IMPORTED_MODULE_4__),lodash_debounce__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__(3279),lodash_debounce__WEBPACK_IMPORTED_MODULE_5___default=__webpack_require__.n(lodash_debounce__WEBPACK_IMPORTED_MODULE_5__),regex_parser__WEBPACK_IMPORTED_MODULE_6__=__webpack_require__(9350),regex_parser__WEBPACK_IMPORTED_MODULE_6___default=__webpack_require__.n(regex_parser__WEBPACK_IMPORTED_MODULE_6__);function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function ownKeys(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function _objectSpread(e){for(var t=1;t1&&e.editing.view.change((function(i){i.setStyle("height","".concat(t.currentField.height,"px"),e.editing.view.document.getRoot())})),t.currentField.readonly&&e.enableReadOnlyMode(t.$options[t.editorUUID])})).catch((function(e){console.log(e),Nova.error(e.toString())}))},destroyCkEditor:function(){var e=this;this.$options[this.editorName]&&this.$options[this.editorName].destroy().then((function(){return e.$options[e.editorName]=null})).catch((function(e){return Nova.error(e.toString())}))},setInitialValue:function(){this.value=this.currentField.value||""},initToolbarOptions:function(e){return e.mediaEmbed&&(e.mediaEmbed.providers&&(e.mediaEmbed.providers=this.normalizeMediaEmbedToolbarOptions(e.mediaEmbed.providers)),e.mediaEmbed.extraProviders&&(e.mediaEmbed.extraProviders=this.normalizeMediaEmbedToolbarOptions(e.mediaEmbed.extraProviders))),e},normalizeMediaEmbedToolbarOptions:function normalizeMediaEmbedToolbarOptions(providers){if(providers&&Array.isArray(providers))for(var _loop=function _loop(){var _providers$i$url,_providers$i,_providers$i$html,_providers$i2,url=null!==(_providers$i$url=null===(_providers$i=providers[i])||void 0===_providers$i?void 0:_providers$i.url)&&void 0!==_providers$i$url?_providers$i$url:null,html=null!==(_providers$i$html=null===(_providers$i2=providers[i])||void 0===_providers$i2?void 0:_providers$i2.html)&&void 0!==_providers$i$html?_providers$i$html:null;if(Array.isArray(url)){for(var urls=url,j=0;j{"use strict";i.d(t,{Z:()=>n});const n="data:image/webp;base64,UklGRhAjAABXRUJQVlA4WAoAAAASAAAA/wAA/wAAQU5JTQYAAAAAAAD/AABBTk1G+AMAAAAAAAAAAP8AAP8AAEYAAAJWUDgg4AMAALAdAJ0BKgABAAE+USiTRqEEMqsEBAFBLS3cLsAWP5O/9AXwD//l8t5c6IMDtnbJd/oaOzcoYW2mW9x1gAqyLbTLe46wAVZFtplvcdYAKsi20y3uOsAFWRbaZb3HWACrIttJoy9avTLxwbGGfoJWsf8IF0x1gActLVsXlbNDwmIeUKhCaxCnSDrUJJB9UF/LL8y46wAVYzC/yg0/tyR+x78/CNJvoxFEveF3M1x0lESZxjrABVXb+RnjGWjRbKIEiDJU6Gdf2jNjjHWACrJia4wC6Y6wAVZFtplvcdYAKsi20y3uOsAFWRbaZb3HWACrIttMt7jUAAD+/v9Bx6G2bGZUcL4XL/d3UpnDj6w4+sOPwRobZriOoyiaRRPi8ZFslOwwi5cMW6eGAwMpGeBZHx6odmEvMztlp0GkPSqB+XTMlEx1GUTSDFkoBcNCSTnQaQ9KoH5dMyU7lqchxB36cgls1FBQcxtC3wwMiCWzUUFA8zb6Gp3s9TjoRZOX1Cn4wd18HQj61jLKIVNZ1iuV7WAAAI2B/PrXdqXtKZ4N4Bh8/P4F4ATZBgpEF711D8cfTPZjtPcXa5oBX2TeyLcuL6sLHIefdnYnlyAAAABqFZNQi072jYy02EBwx3buCFWH00k+yoGgSVa2lyDupn6VahW33YV0AAAIJhEguXPMrUk98EcHUvUUjN97fTsZmtrJUQKv6WEUvWTDk689hIYKVJ0xlgf/RJCy0OE8AWyzufTo8GOiZalEkwoI/eyYyfVXZ452ltZJN1g7DSQ9RvgrpzD/DTz+L6dQW8vvwtv7I3OlU+bpUrEdgjqSoJaP5CRlXbK6oVWb6iTmW1qR3jT2/NoFSNK0EIMjCV0tXyRlSuQnSH4JK63RoQsfFNKRQ1bp4YDAyuLhJQp2/XsD/atuLSeGokwuHZtjvJyu/L0roS8+KgX5NEM/BL0lwgOxSYm5/m7fs+ScFfHn1h7+7k9vHnbIllz0/yj6t/59z5Ns9FmP5fIW07UnZF5rpB6aagx1egrGX6SdY1FPzaA6V6PuGsXdukyvABgQDeHiqWKcpVh22ZhupSZiszXg/TJ5PgD12i0bCd3MM3zx/8TXsC8BlZMTh1Gug7hyj9iuzV1puO43UL5LKPg9JvCL0vxsl1FAg0170ACktdskvy3ubCgeozhLZqKCgQ+sOIO/TkAOEZ5xtDPSrnFkLDe7TWdhhFy6l2pyklXOLIWG8fEtuiqRjlU6MRcayE9iiSjlV3tktmooKDmNoW+T0AuGhJJxFaw4g79OQS2aigoOY2hb5PeryLRsJyk5DiDv05BLZqKCf+AAQU5NRq4CAAAxAAAxAAA7AAA7AABGAAAAQUxQSCoAAAABDzD/ERFCUQCQkQYiqa7Zze69I/ovICiywA3J4WbEp8n2zwECflzqowBWUDggZAIAAPAOAJ0BKjwAPAA+RRyLRAN/lcAAAIiWkADqE2ay7+E+lfmm+W8Sy1mr/J0wPGP0VqsRuDTvmcKlYc7EzmRO+eIFffVAGiAnyCXa98MzZkPbKdnKCRq0vRflGxyzZ8zOdH2K27tZF63aqrtih7mTEdo5/TLBG4YXKuo0sVtu4+0AAP7/1RyPVM7gMkGwG3loUKiXluV6b1ee6Taz7sPvUHuQvvmZumuSmEIPrX7R96shZAaOHqTe1oz499FxXraM2PJzFHD5D/SVi9GbQe6xhEU5BvUEr9xv22RU6W0vjHK0anoXi9fCB5OLyNLvfU/RnOUH5sj4mJVaZFgkTSbOf8ZORV7D3TSlya8IctQ7wiZFWXKV1EmCAkTJUQK1Tb6JapOnBZLXjJ6Obee3K4/fbnDQ+DIyuK/SwCGtqJDC5fzkYHZAR3OldmUKgOCPWnsV66Mtryrf/XF/lriCtJV1ZMObgncmygbMygF97Evih58ssjUsJWCx9aTu08bMuuNpqA8f2M2r9BgQ//Kcd3z7hen79c98ZOXfXwf2vilCiy5wo74w1o+e7pZZzoHyc9h/9Vm9ZYD9TC7t1oqKPw2H09faFf5U2KthssNZwO75lzX7n8DOOk2TMJL/qL/6HXIlvsvzcVWz+aRZvpoHLqwi7jbw1rK/v1+oXP9sx0IbQz12l8SjRcwnlHejMGQwnd+r6LMdDOt5wdg5Dy4p2kK9/5NXR1hN+4VpilVgVobl1Yu11QJ3phdBbSy2QaUc3Y+WTx1FH3dfqjUE/HIy218OmV3la5jF0l3mOWMf5uANHbKG+LIAAEFOTUbAAgAAMQAAMQAAOwAAOwAARgAAAEFMUEgsAAAAAQ8w/xERQk3bSMwzeEhH/Zn1qc4R/SebtDFr+4jWuA8kfr4bpLVRIDmu9ChWUDggdAIAABAPAJ0BKjwAPAA+TR6LRAN/FcAAAJiWkADqbsuYodx3TTtGKJ9tD/tIt1//8ClOGLzVbtSpUKOTcY/3kyme0CCaYYZ2b9NHE/w7S6i1pd0fAKi3ap4b/9/8egeK/yplj7SiCgLoksxhOAnP7OikmI8b0ZBuQLrPDdWmznukqeTQAAD+/9UcllgyMqF+xN2UQhvVvHYz+JXP6b1ee6krOr5yivQRKSJGL0+3k/yAtBdBbmIn/UuQdWPv/bw79D5aeQAYJbmVVEtm72G5zOOm2w+mG2yj71aAh/THL3uyJKkjioHNMDh6f+hHPeFVGj0gbKFIBECbuZcK5o9qm7szvlmIh4xsQperYdY3yIOxRNxr3gMXrrmNYM/H9YmLy1tcL3PHc0EFl1Vo0/zbTWpmbWMxV1TBeCXzrv0qSxxlf/BTNAdcmyTxUHAImCyoZ0rDh7PuiRVFthnHV2Z+ov8ntXL/ylkzy/t91xOGhFZ4BkmkRSj7Eh80tb12KUqxcO+vqtckZOSPV+/fRy9rTmr6VdbFS9hY9cv8WWgwuaUeIlkszySFI5BDXMXzPknAdeA24z14/5LOJYd+0fBX78cbsExiNe0/Ti0j2H8WZ5AcKXodqb39NYdeO7G/2bIBTSkPt/rE0JcG8To8U3HuPNcrhhG9Dk+cnAW1JhnJzIp7VAWSqmr5ZxvZ8eew36zcOjSYM+1rCX3vHdjlHnB5otRuaApApWpU9FGuDyX/NxQ6XdRZLTMKqN5TqFtD/1zfirfEAV5kDjnP2UG7P86Tm7mZcpfoomPntW9yKTzNnhTytEw/npkmBpgJTu7HFi1aJiTnwnVwAABBTk1GqAIAADEAADEAADsAADsAAEYAAABBTFBIMQAAAAEPMP8REUJRAJCRBiKprtnN7r0j+q+2bRtGLknGvCFZuA9ia7HrIOM/TkDAj5P0UQAAVlA4IFYCAABwDwCdASo8ADwAPkkejEQDf0CgAACQlpANULb5xnfSk6eW/pjGjsGprIP2sVUHICr8/voP6ux9G3WgopiulgNL4NZOT2GAQuDED9ue35WyX1L1N/rsbDzGjaUn/x6/Klav2sDGFr4rmCavQkBEJ3IwQGtiL75iRyPezPEyNwDF4T1YtAAA/v+1EFNCOdFIkmgBZuHCMWTe2tMwA1cqNgqTL0DFN9Eu1CL47/PId/ECuywJFWpcfp5gUVcCuL/WrVDHa9ar3eIHDZwV4JaD64fqyTfov2CGt+loB0rMauycdaBKVl9yz3lq2MHOMHQXtCXzqX4b1IFq/xezekU8xVgeMEet//VqxbKmQlDPMxp78cCboT4KIeAhH7vcGa/Vx7GmaZPI78WMxBZywc0hVYqOqSYlqazXUZBofVPZ7zf2x3WVrnAPlr4EoHBwOwT/Gao0O2RIpXS2lnKFG1Gx4KVQhZh/AUSmryihI4fKJ1NKlJE2loceu/rThRizxVSEFJl5HJ+/wJjIP/lvYKfz///22/Ubh6iLXrAqrUlknlVKsnoM+mh390v+HFGBgiyNC0fMHjaeakX9Sr3ECks++dJ95x8xhh39P5Asbbj0egO3G17/pKVJP040/HuEzT6TZAbo5YKNYKpwXPrmJcXHRBy0NftdDGfvHplySC9q2iszAKNYYUJBpHfmRu0Je2K3va4HuoqyiwSNj/It40TVpAc529xvdy9HfSpPPUvw0pC4TPmPZYMyeywKeOqE7zL3ltYxzeQLfHk4ZM5dBfxOg6OP4Jz+AAAAQU5NRqgCAAAxAAAxAAA7AAA7AABGAAAAQUxQSCkAAAABDzD/ERFCTdtIzDN4SEf9mfWpzhH9FxAUWeCG1vhTIDmuNA0yTTs/AQBWUDggXgIAAJAPAJ0BKjwAPAA+SRyMRAN/VcAAAJCWkA1QuCf+OxyLSy5+Wtpp2glE+yRfKT6JLhk+LowdfzocrR4gePwUlUv4IyN2sdzgrbIZsiLZs/CWR4eHWjl0bVn/7ky6h5zCPWer5XkS5KNwXEISc8Qpql54hHAbvGnEzgTyLhcWktvQovraAAAA/v+1EFfcl7JULrEOwbNw4Rc/CAshmp88RfKOTXKapVPOFNwy/y+pmLr214AVNEdrma7c57/sWjqWfZGOXFDlOFgp4jT6UdW3HqCDpH5Dk9gkgu6YRWeW+lcAYb/xRa5oX8zWxdxjNxOKD2+TnUeki78Hyy4jvY2AFiEZZojCWz8SHbN30HEvTLQJpc681QBg9q5trPu5a1zaO4NZw4ABnBlk90ngkokhebKFE147s+qpl35IqMuQLdYKesmfEkyARHGy1WwKLME4zcdQsKaLJVdIacM96AT8N12MbWjvRYApM8s7jI82jqQ8Py6Fj9XA+46FH82qH3JFZY5/0vcEnQ/mIO04x9EiHSavC6lUaiuGf3tv1IlS/zcf/0peSE1t0j9cFOk5G3SzXqh3o14kdqMvpSA4H9VvEEMZ1aW/chbSGI/j8OZiEdVxG1DHyeB/vC8WsIMNBvMqtFdgHXqlZwCGyUZLIzJnX47+E40ir+91Z5vRCAsaIJLwi6nShOf3L8B9vsMP1ze1r+ZvPPDCZTW5DugYBAIX5DzwH6NusMhKaYw0buToelRbrQsXcnNbzNK5y9K+tq+nsfuESVLBkkv7p2tannyw+EBWW/W1Z0MjwJiplWAAAEFOTUbEAgAAMQAAMQAAOwAAOwAARgAAAEFMUEgvAAAAAQ8w/xERQlEjSco6WEljfZwtHcM/ov8CgiIL3LA2PQy8zY5/TkD4uabbwNvs5CcAVlA4IHQCAAAQDwCdASo8ADwAPkkcjEQDf1XAAACQlpANUIDW3bxriz1vpEstZq/ydcPaP2VBujgejarHVnJRbeuiql5laj5mFES/aEHIFKOQYaxm4V7QLo75Z16f8ntt6xPSjyf5KZBNUb3lrCvThUWn2OVtZnnbqTkX4ryDgM29WalQOFEiUgAA/v+1EFfcmqJvhBPkSeoyj9qa8SBNjc/MZBlwzF1W+oKH1y98NNuona8Dtn8nQxQ8mZ7h1MdBHGh3vzTHm8Fjdjnvi9aYs6yF8vvzGucKM5lCM7QkAHMYYScEK73VVCMJpXFvmuG/6iK7YiAF+FohXXfHnjeu3aYvitvS0VXPjnlDJnhWJGoR1jhmE55PFPhiZ+MdniUKby2QtzZtIiPQ291d7lIf6d2ZL6SFLyxP8mGFI4vptiClKRE0XBfp6Uf1rgy0ngOE9FPo0ede/Wd2tkdb4OW6WlZC7XjhzBqdv9+1nOvb3GczFYxp+NjZc4j+S+O2/GcVqMEXB5DFMet1L3ZPE8gUNqYQS7k4vzR1HtarxKUsn/Mn+WY1+I6utMg9dn7iTCGb3Sg7902j9UKz//UfISDlZJZ7N2aGd3b9bSof66qDYtNHVgCcj4L06ReHIOp5nYN/jF/Rncpa0KQUZBjZdH5PlHmR5aFP17DwqMY6Eu4PC1+PYzH50yX9xR8iYTl5eneFLp9lqBaYTQTr1re3MrdYu9lSuBFqLfUq97J/+Ba+1O1mq8Xpg3fcJyaj7Tif+8GP8WUc66Mmu7OEivWey7G2sUGAYiSFcNZC3O9nEmfXd3bxb5L+Qn6PI5FwqEqdqb0bLbk+XOAAmX8AAAAAQU5NRq4CAAAxAAAxAAA6AAA7AABGAAAAQUxQSDQAAAABDzD/ERFCUdtIzv4W1lAfZtdrCET0n0DSxhX4a5S5/Eymle8/DxSe9qPW/ZApmkwrP38CVlA4IFoCAADwDgCdASo7ADwAPkkejEQDXy7MgACQlpANUJuTGn3gy1tJS0wnPKLMwUzLJvyLNoI91ciIKe6MUFC3MYj+WLaJY/UOzlfJ4/atyClGSAn0H4KEkubaVz+jMTh1Bs1IsRzbll3lwGI6YLreXhhW71NZPTVK9t+yWrihEnwLb4KmgAD+/7UQSk8vL3Vx0fA4XPXmkOd47yGanu46UZr/JNJDUN8DtYEkqbhPSfT1PXhGL87hi3bw2HlY7wYvr3RvAR2WRSTsD9m38a7k96QNriiSpIEE7iGWop8cblsOUjbydcRvmo7iv+CRoVkIhby/3eaM1vjcJvemAVxxcMUax3veuN5t7Gb/ZTb3LeKc2kRkruGRIebtf1DBcFhqXeCIv4Z6PRPrT7myHlxlE37uO6kcSN2/YYV698E/rBJmUYysZp2oEtUpFeBGKY5kLLID/6KoLwNlhmVMVGJJk6KxsYe+J/yVXfSWhYZxjmX648veblY6OxNDc9Sa/i4dY4G3ZUJtkVOxRjROccyNrZHXwN4EfhvMfkAY75HXBM/Kfbrwf8Du2l2raTl+Jxz/LKGqh7vrupw+eUNk+RW8cPv9UNSB/eb9lev3vG0V/GXdoWVipybFP/zoJ092jNM/8RkW+59vRI3wUv3uW3wwYOP7yqLKA69HniZnnzcmKgFigozRlrslEG0Z8Z4nF5DnrbhvDjVTXUmfUd56klx7uRfldgLCNoS/i9qoS71pySSHeEGxQVDFVVk7edF72iN2E3AFtJofzaorrPsQ0sPwZZh2ZnnxFKaiQd/+pFugAEFOTUakAgAAMQAAMQAAOwAAOwAARgAAAEFMUEgtAAAAAQ8w/xERQk3bSMwzeEhH/Zn1qc4R/SeQtHEF/hpa40+B5LjSIMR4vyCDtNYIAFZQOCBWAgAA8A4AnQEqPAA8AD5FHIlEA59i1QAAiJaQDVRbNxs8A6sVcAXGZEAncHS6pWpN7Lnf9C3EEcxyq3cnS8VOKpmt+d4oY9KdnUSIO/tWm5lclxEXkkxuf1OPY3QMQk+Vd5MnTaa17Sb7pVHhvgG435yLyjKTyy29NRXUv/eX24nfmAAA/v92NVacR3l/tn/Av/Zyn/w13KcnXkmxdo4Py6HHqLAJUN5zvucx5AMWanpDISLNC5TtLj0M5Sib2XKV9a2sShnX05+4y8cToEo9xW+TEF7Zb1O8W12NoRjVkk8IdLLuL8iYvQ4KurYIyhU3AuMmtkdbO1AheMktcA8asUr22dlzj/K1noW0TdsITmfh22T5t7nmH9NA7SMgXHf/uSoNXw3BWAu7IadvagODPFC5unKp58aOZMQZZhpa3hiYS8Clf7CSO0rG3Pepl+31EdOvxFipH9k3V6ZoE1s7YK4bjrBRmH4tLZhofPvE4hgUOLp1chu5tqfaSxwFiEG5L2Bxu8P3UbektCs1FVinhxjSfmMPpmwAqHcWPqaA7CpANpOplGny9IUBnKgHOuWOD+8bFEvJnjoWHtRLmNw/Z+21nkFO4FvK3/eF/kqx35+Zeh2WLRImpsp2JsbiPiJieFondpg99iQsDOYO89H/OSlRwVh6T0UGFVchqhZTMFrOaK5IFJIZxCI05/ERPMxQieb/Gb2Lmf2Bf3h7vInvm/5thtt5a5BLxAykA6ajELtyY+NtZT2VOV+BLefIrQfzoM+TY/jfsqUaVJcoteVdX+mOMShDNhcAAEFOTUaoAgAAMQAAMQAAOwAAOwAARgAAAEFMUEgoAAAAAQ8w/xERQk3bSMwzeEhH/Zn1qc4R/RcSJJg9ojX+FEiOKw2CTCtfK1ZQOCBgAgAAcA8AnQEqPAA8AD5FHIhEA592AACIlpANVIMA7WMevOa6AOUzUZtFAZ7LYyvaxvNFmfnUqbfyz0QRpstx+gv4d0Hgq6OUuu0UV7q1Xk2xXeEEvOUz4MzmOH97lwC0HZ/16Um1IAAOrCrtvEA6GfzGmJWEknfhXqxmxKq7GuAXVj2ST6oAAP75bxK+N5e/he4pXtl4U8mM7P+CCA/zd3/tczTbuLcCqZftyxIPjZnBh6Vhl/2jOyXOc4gUsK4p1RWeMfVO11qbnBDCnaeRVDijhBszZ6E85eazOEPKgVjW4U05lmqb9/uonx4x5MwdSi1jvJ1TtyVJ2GnvrPrQ2TNerWGx1N8sPhjyIOPUvuRth54bRIhUg8Qqaswueu4nAOFbBibOC92eXdDo3IZCKHPRf3gmftp3Pivu1jt7SMnKOtVNpkE+fsX0LDj400eU98v66UT6b5uLXoNCwcLX1y5E+f+lYtXQMP0jSlBp0FpZf5Dzq3ZlBzma+eCyVI4TeTbJzqosRDW4unrwSEg/xI1l2fyisnK7g5LVCmmyCuE5KHhDaBUdGLzHcz382qidQMgVuEEoGnRLLYUmkLlNG0w5Vmuj4+NfJzyyimKmh/JsCRwvVsGlrIkVvVvx9p4eZsAhkyu0KaXw+WLOHOPUGFT0YmSiRsu35QVishy7DYSASgQJjX5S4NAGWV4+ON9g0zz6vHFIr+P70VeluLXsARV4UXRJtQNS1Q4FtPwK9ZkpQKYWNHZbKmPIgd1D3QHNRGKaYbLxNAb5SUpjC3YoqQTItIzske2GEq4aPHzN5//gAABBTk1GmgIAADEAADEAADsAADoAAEYAAABBTFBIKAAAAAEPMP8REUJN20jMM3hIR/2Z9anOEf0XEiSYPaI1/hRIjisNgkwrXwtWUDggUgIAALAOAJ0BKjwAOwA+UR6LRCEHPikABAFBLSAaqLa2NvOtlr6adpot5SPiQSXcPNlXVjhTaqb6wFDn/8dddJff1R8zJUTb+R1zqIgkfAYPZeZFSXyqzzHGegDFWrBJOt577+AjZcpWoA1AscaLLcbdJyUnlcfwLFV73YyFa8an8AD+/3Y1g/DsEKjkyYZfu99LFNfWef+uW+8IdovdAYOomw4nNwYxLvC6/4sI4x8GUbK4zkS2wgRwBha80ZU5aCPkxVwEH7kEXtXlHbhrJ2KgSkN5m7KAzlizmSIv+NW6bxGmn/yINxb67/cT2SfhyzmybcCwtMPPKHqMKJYZDKVS5/amMcfRdu0XPeCPe5xFIdFDH0fsxQzajXiXsYeyZsTh7czGMlLX+cANZZm0Lahe6kzQYtlayDqtreP8QoX/I5nNz/5pKIPlLrM2yyq6feTbdnZTnTEFm2/Twq7kkuD8HDSAe+6WGSvq+smhfgKO9EXLiRuan1+3gqplAYAGiAFOzUAjALbG6Rp0RXbBhEcx5X6/m83zYY1s6k67+seyAc0CChzTCId1fI/Ci2LxpYu/DTlC18S6kf8+pkReoMxeLINIlVpSuBom2qGyU4CZxCLpwtDTYKQKdr6eHOt2XqxrKI+wj07XkT0ff2yFwMqUoN9ZfTYpYHurIINRzrxJmnZT9eJNy8tDCUZE69s+Sm93gSzMmyA05rElBKZJPdCS+2zfrv9YTJDNjURyOVrcGimUIRmSuFMmMNq1fafJwcJg4iA8Ys5GnXrejSeEZEcYAeLgAEFOTUaoAgAAMQAAMQAAOwAAOwAARgAAAEFMUEgtAAAAAQ8w/xERQlEkqREOkLTW1xmQ7IvjH9F/IUGC2SOheR9wmnzDYDxOGgROk68VAFZQOCBaAgAA8A4AnQEqPAA8AD5FHIpEA592gAAAiJaQDVRbb5z449ghphmnDv2psVpgNPX7hrBFk408J2wM0iJCAeLEjsNOO7Cwg0x0izQzkpkMGZ9czL08RtDfeAVL+fiiqC5iSEZ10v4/ZJ4YgDv5gZjaHJx09gRSoTIrGGGxEQR4lBMmywAA/v92NQnYQdt+lKNg2R6dsvvJTxFHYpkUdFMWe2kazz/FhHCuj5zAS9AI/E51IpyV2V8PAVw4W8Znp3XAg0pR+wKCupm+W2aGs9H5YoH/Rt+B+96Qa/s8pm6f/Sj+uf+DwAOLvI2K6v6X4Hfum8u42D4IJ1Ju2rA5vt0hq22A7qX5/Y53VjTiGD8jvMNVug5Md1oClnc0V3Gkb6y+TZgr76/CRKatYqW1GAHoqJsc5eWHFEuTBhqEoHxx3ux195XlLoG8xpuK+eqGtxyJTuoMOL1h8dO87M2/iEClFvpLa44RSRZfg/DJzShSH8VvpbbDo582X3/af2nv0oXmt/Y/XxRLHAnHeCjnsamwFA3pqJR3dKVXOvp0n7da9x+nv08nwkY6CDFPD/ZWNM9fJJbEr8L4IHT9HfPFWt055iIg0ht0rIYgWvlmC7BMqI0ynlctiCaRXNOytXGm9LzS2PmRS9sjUwpdHgC4pCrDD/tR7meR67vSiWnAZkxWvrenoO9TDMxcriD63xJH+Sbmm73Cr4+zBW52MbrTvl/h57fCBbwmOR8cW5sa+kcwA87gCmfTFooG21nFxja65a7i3vCgo0NZluaw5cERzFoa8BS4B96VAuJkM2FwAABBTk1G1gMAAAAAAAAAAP8AAP8AAEYAAAJWUDggvgMAANAdAJ0BKgABAAE+USiSRqEEOpMCBAFBLS3cLsAWP5O/9AXwD//l8t14zO4mWppoWjQYHZuUMLbMYBcTUAVZFtmMAuJqAKsi2zGAXE1AFWRbZjALiagCrItsxgFxNQBVkW2XMuOqmh/LIXHKngz0v5ubGGzGAXE0WY7Mx2fzaDtRF5QqEKBiVIN0kBvaw+w9i62zGAXEtdh19f9hvx5jNvzpnz4XTSi8qCFyXIQ+1u2sJ1WRbZi9VUbiQPPqYRWmKttDMKEIokC+lDgAqyLbMaFuJqAKsi2zGAXE1AFWRbZjALiagCrItsxgFxNQBVkW2YwC4moApgAA/v7/QcehtmxmVHC+Fy/3d1KZw4+sOPrDj8EaG2a4jqMomkUT4vGRbJTsMIuXDFunhgMDKRngWR8eqHZhLzM7ZadBpD0qgfl0zJRMdRlE0gxZKAXDQkk50GkPSqB+XTMlO5anIcQd+nIJbNRQUHMbQt8MDIgls1FBQPM7fQvxid6z3OhVgaIeGvNWELlByw+VKnmE74KghF2g+oraMjeQ0IHAAATf+IUjP0b3+vfHcyHxR4nLitt0YxVMHmpar3By30m8f0drBIz/E3GUFyAsm/eJ8BM+ZBKbgFCyPcwfRAAANwnqh2YXeyi2SnYYPs9fjgMohLWNwvTkVQJDomtJL3FW7pAAAANl7kvSlw0fZLfWf+XiZhy1R8L7A91imtE+5MHB2gl43/onTacgGR/ArpIa6mTpv5kYnt0yRfDLB5O0z0KkzPZr+rWd6Pp2cQjTwt75pVP1FnMWbzTW/N/jgKYr/g1lNgR/ROwrlwhxxN32Y356Y6Pf5lqbP5AGoUnydN11Tw9v8tds0pwSS20V7d8REm7Vbf5jvK0aK6i9kFDRJvndZzbl2ccR0/8459E9ALhoADXJTsMIvjFIpnRGk0yhb7h4SBEySm9kp9FN4Z1UibyPJu1p3AOBmmQ2arBatrnnqiTBinmL3g4wBADGOKqKwZBasFPYeWD7zfinTEkxtlWbH/Cu8jK/7RjIamsWIKn2LbGRDm9/1nAHrtFo2E7uYZvnj/4fwSC/y7dAKXCIZyoXe8ldxQMVkeUcWJn3PiDXy8UB7c2n7h1jqLd2CvlsS7NdGshPYoLMnj1Q7MJaL46FBQsdadBpD0qg9HkWjYTlJyklXy48iqRjlU6DyilpsID4ppSKVjmxlpsID5bS2kY5VOjEXGshPYoko5VOg8opabCA+KaUilY5sZabCA+W0tpGOVToxFxrIT2KJKOVTn/AAAA="},6221:(e,t,i)=>{"use strict";function n({emitter:e,activator:t,callback:i,contextElements:n}){e.listenTo(document,"mousedown",((e,o)=>{if(!t())return;const r="function"==typeof o.composedPath?o.composedPath():[],s="function"==typeof n?n():n;for(const e of s)if(e.contains(o.target)||r.includes(e))return;i()}))}function o(e){return class extends e{disableCssTransitions(){this._isCssTransitionsDisabled=!0}enableCssTransitions(){this._isCssTransitionsDisabled=!1}constructor(...e){super(...e),this.set("_isCssTransitionsDisabled",!1),this.initializeCssTransitionDisablerMixin()}initializeCssTransitionDisablerMixin(){this.extendTemplate({attributes:{class:[this.bindTemplate.if("_isCssTransitionsDisabled","ck-transitions-disabled")]}})}}}function r({view:e}){e.listenTo(e.element,"submit",((t,i)=>{i.preventDefault(),e.fire("submit")}),{useCapture:!0})}function s({keystrokeHandler:e,focusTracker:t,gridItems:i,numberOfColumns:n,uiLanguageDirection:o}){const r="number"==typeof n?()=>n:n;function s(e){return n=>{const o=i.find((e=>e.element===t.focusedElement)),r=i.getIndex(o),s=e(r,i);i.get(s).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",s(((e,t)=>"rtl"===o?l(e,t.length):a(e,t.length)))),e.set("arrowleft",s(((e,t)=>"rtl"===o?a(e,t.length):l(e,t.length)))),e.set("arrowup",s(((e,t)=>{let i=e-r();return i<0&&(i=e+r()*Math.floor(t.length/r()),i>t.length-1&&(i-=r())),i}))),e.set("arrowdown",s(((e,t)=>{let i=e+r();return i>t.length-1&&(i=e%r()),i})))}i.d(t,{Z:()=>qI});const a=function(){try{return navigator.userAgent.toLowerCase()}catch(e){return""}}(),l={isMac:d(a),isWindows:function(e){return e.indexOf("windows")>-1}(a),isGecko:function(e){return!!e.match(/gecko\/\d+/)}(a),isSafari:function(e){return e.indexOf(" applewebkit/")>-1&&-1===e.indexOf("chrome")}(a),isiOS:function(e){return!!e.match(/iphone|ipad/i)||d(e)&&navigator.maxTouchPoints>0}(a),isAndroid:function(e){return e.indexOf("android")>-1}(a),isBlink:function(e){return e.indexOf("chrome/")>-1&&e.indexOf("edge/")<0}(a),features:{isRegExpUnicodePropertySupported:function(){let e=!1;try{e=0==="ć".search(new RegExp("[\\p{L}]","u"))}catch(e){}return e}()}},c=l;function d(e){return e.indexOf("macintosh")>-1}function u(e,t,i,n){i=i||function(e,t){return e===t};const o=Array.isArray(e)?e:Array.prototype.slice.call(e),r=Array.isArray(t)?t:Array.prototype.slice.call(t),s=function(e,t,i){const n=h(e,t,i);if(-1===n)return{firstIndex:-1,lastIndexOld:-1,lastIndexNew:-1};const o=m(e,n),r=m(t,n),s=h(o,r,i),a=e.length-s,l=t.length-s;return{firstIndex:n,lastIndexOld:a,lastIndexNew:l}}(o,r,i),a=n?function(e,t){const{firstIndex:i,lastIndexOld:n,lastIndexNew:o}=e;if(-1===i)return Array(t).fill("equal");let r=[];i>0&&(r=r.concat(Array(i).fill("equal")));o-i>0&&(r=r.concat(Array(o-i).fill("insert")));n-i>0&&(r=r.concat(Array(n-i).fill("delete")));o0&&i.push({index:n,type:"insert",values:e.slice(n,r)});o-n>0&&i.push({index:n+(r-n),type:"delete",howMany:o-n});return i}(r,s);return a}function h(e,t,i){for(let n=0;n200||o>200||n+o>300)return f.fastDiff(e,t,i,!0);let r,s;if(oc?-1:1;d[n+h]&&(d[n]=d[n+h].slice(0)),d[n]||(d[n]=[]),d[n].push(o>c?r:s);let m=Math.max(o,c),f=m-n;for(;fc;m--)u[m]=h(m);u[c]=h(c),g++}while(u[c]!==l);return d[c].slice(1)}f.fastDiff=u;const g=function(){return function e(){e.called=!0}};class p{constructor(e,t){this.source=e,this.name=t,this.path=[],this.stop=g(),this.off=g()}}const b=new Array(256).fill("").map(((e,t)=>("0"+t.toString(16)).slice(-2)));function w(){const e=4294967296*Math.random()>>>0,t=4294967296*Math.random()>>>0,i=4294967296*Math.random()>>>0,n=4294967296*Math.random()>>>0;return"e"+b[e>>0&255]+b[e>>8&255]+b[e>>16&255]+b[e>>24&255]+b[t>>0&255]+b[t>>8&255]+b[t>>16&255]+b[t>>24&255]+b[i>>0&255]+b[i>>8&255]+b[i>>16&255]+b[i>>24&255]+b[n>>0&255]+b[n>>8&255]+b[n>>16&255]+b[n>>24&255]}const k={get(e="normal"){return"number"!=typeof e?this[e]||this.normal:e},highest:1e5,high:1e3,normal:0,low:-1e3,lowest:-1e5};function _(e,t){const i=k.get(t.priority);for(let n=0;n{if("object"==typeof t&&null!==t){if(i.has(t))return`[object ${t.constructor.name}]`;i.add(t)}return t},o=t?` ${JSON.stringify(t,n)}`:"",r=x(e);return e+o+r}(e,i)),this.name="CKEditorError",this.context=t,this.data=i}is(e){return"CKEditorError"===e}static rethrowUnexpectedError(e,t){if(e.is&&e.is("CKEditorError"))throw e;const i=new y(e.message,t);throw i.stack=e.stack,i}}function A(e,t){console.warn(...E(e,t))}function x(e){return`\nRead more: ${v}#error-${e}`}function E(e,t){const i=x(e);return t?[e,t,i]:[e,i]}const C="38.1.1",S=new Date(2023,6,11),T="object"==typeof window?window:i.g;if(T.CKEDITOR_VERSION)throw new y("ckeditor-duplicated-modules",null);T.CKEDITOR_VERSION=C;const P=Symbol("listeningTo"),I=Symbol("emitterId"),O=Symbol("delegations"),M=R(Object);function R(e){if(!e)return M;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 o,r;this[P]||(this[P]={});const s=this[P];V(e)||N(e);const a=V(e);(o=s[a])||(o=s[a]={emitter:e,callbacks:{}}),(r=o.callbacks[t])||(r=o.callbacks[t]=[]),r.push(i),function(e,t,i,n,o){t._addEventListener?t._addEventListener(i,n,o):e._addEventListener.call(t,i,n,o)}(this,e,t,i,n)}stopListening(e,t,i){const n=this[P];let o=e&&V(e);const r=n&&o?n[o]:void 0,s=r&&t?r.callbacks[t]:void 0;if(!(!n||e&&!r||t&&!s))if(i){j(this,e,t,i);-1!==s.indexOf(i)&&(1===s.length?delete r.callbacks[t]:j(this,e,t,i))}else if(s){for(;i=s.pop();)j(this,e,t,i);delete r.callbacks[t]}else if(r){for(t in r.callbacks)this.stopListening(e,t);delete n[o]}else{for(o in n)this.stopListening(n[o].emitter);delete this[P]}}fire(e,...t){try{const i=e instanceof p?e:new p(this,e),n=i.name;let o=B(this,n);if(i.path.push(this),o){const e=[i,...t];o=Array.from(o);for(let t=0;t{this[O]||(this[O]=new Map),e.forEach((e=>{const n=this[O].get(e);n?n.set(t,i):this[O].set(e,new Map([[t,i]]))}))}}}stopDelegating(e,t){if(this[O])if(e)if(t){const i=this[O].get(e);i&&i.delete(t)}else this[O].delete(e);else this[O].clear()}_addEventListener(e,t,i){!function(e,t){const i=D(e);if(i[t])return;let n=t,o=null;const r=[];for(;""!==n&&!i[n];)i[n]={callbacks:[],childEvents:[]},r.push(i[n]),o&&i[n].childEvents.push(o),o=n,n=n.substr(0,n.lastIndexOf(":"));if(""!==n){for(const e of r)e.callbacks=i[n].callbacks.slice();i[n].childEvents.push(o)}}(this,e);const n=L(this,e),o={callback:t,priority:k.get(i.priority)};for(const e of n)_(e,o)}_removeEventListener(e,t){const i=L(this,e);for(const e of i)for(let i=0;i-1?B(e,t.substr(0,t.lastIndexOf(":"))):null}function z(e,t,i){for(let[n,o]of e){o?"function"==typeof o&&(o=o(t.name)):o=t.name;const e=new p(t.source,o);e.path=[...t.path],n.fire(e,...i)}}function j(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=>{R[e]=M.prototype[e]}));const F=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},H=Symbol("observableProperties"),U=Symbol("boundObservables"),W=Symbol("boundProperties"),Z=Symbol("decoratedMethods"),$=Symbol("decoratedOriginal"),q=G(R());function G(e){if(!e)return q;return class extends e{set(e,t){if(F(e))return void Object.keys(e).forEach((t=>{this.set(t,e[t])}),this);K(this);const i=this[H];if(e in this&&!i.has(e))throw new y("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 o=this.fire(`set:${e}`,e,t,n);void 0===o&&(o=t),n===o&&i.has(e)||(i.set(e,o),this.fire(`change:${e}`,e,o,n))}}),this[e]=t}bind(...e){if(!e.length||!J(e))throw new y("observable-bind-wrong-properties",this);if(new Set(e).size!==e.length)throw new y("observable-bind-duplicate-properties",this);K(this);const t=this[W];e.forEach((e=>{if(t.has(e))throw new y("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:Y,toMany:Q,_observable:this,_bindProperties:e,_to:[],_bindings:i}}unbind(...e){if(!this[H])return;const t=this[W],i=this[U];if(e.length){if(!J(e))throw new y("observable-unbind-wrong-properties",this);e.forEach((e=>{const n=t.get(e);n&&(n.to.forEach((([e,t])=>{const o=i.get(e),r=o[t];r.delete(n),r.size||delete o[t],Object.keys(o).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){K(this);const t=this[e];if(!t)throw new y("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][$]=t,this[Z]||(this[Z]=[]),this[Z].push(e)}stopListening(e,t,i){if(!e&&this[Z]){for(const e of this[Z])this[e]=this[e][$];delete this[Z]}super.stopListening(e,t,i)}}}function K(e){e[H]||(Object.defineProperty(e,H,{value:new Map}),Object.defineProperty(e,U,{value:new Map}),Object.defineProperty(e,W,{value:new Map}))}function Y(...e){const t=function(...e){if(!e.length)throw new y("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 y("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 y("observable-bind-to-no-callback",this);if(n>1&&t.callback)throw new y("observable-bind-to-extra-callback",this);var o;t.to.forEach((e=>{if(e.properties.length&&e.properties.length!==n)throw new y("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),o=this._observable,this._to.forEach((e=>{const t=o[U];let i;t.get(e.observable)||o.listenTo(e.observable,"change",((n,r)=>{i=t.get(e.observable)[r],i&&i.forEach((e=>{X(o,e.property)}))}))})),function(e){let t;e._bindings.forEach(((i,n)=>{e._to.forEach((o=>{t=o.properties[i.callback?0:e._bindProperties.indexOf(n)],i.to.push([o.observable,t]),function(e,t,i,n){const o=e[U],r=o.get(i),s=r||{};s[n]||(s[n]=new Set);s[n].add(t),r||o.set(i,s)}(e._observable,i,o.observable,t)}))}))}(this),this._bindProperties.forEach((e=>{X(this._observable,e)}))}function Q(e,t,i){if(this._bindings.size>1)throw new y("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 J(e){return e.every((e=>"string"==typeof e))}function X(e,t){const i=e[W].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=>{G[e]=q.prototype[e]}));class ee{constructor(){this._replacedElements=[]}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=[]}}function te(e){let t=0;for(const i of e)t++;return t}function ie(e,t){const i=Math.min(e.length,t.length);for(let n=0;n-1};const De=function(e,t){var i=this.__data__,n=Oe(i,e);return n<0?(++this.size,i.push([e,t])):i[n][1]=t,this};function Le(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t-1&&e%1==0&&e-1&&e%1==0&&e<=9007199254740991};var qt={};qt["[object Float32Array]"]=qt["[object Float64Array]"]=qt["[object Int8Array]"]=qt["[object Int16Array]"]=qt["[object Int32Array]"]=qt["[object Uint8Array]"]=qt["[object Uint8ClampedArray]"]=qt["[object Uint16Array]"]=qt["[object Uint32Array]"]=!0,qt["[object Arguments]"]=qt["[object Array]"]=qt["[object ArrayBuffer]"]=qt["[object Boolean]"]=qt["[object DataView]"]=qt["[object Date]"]=qt["[object Error]"]=qt["[object Function]"]=qt["[object Map]"]=qt["[object Number]"]=qt["[object Object]"]=qt["[object RegExp]"]=qt["[object Set]"]=qt["[object String]"]=qt["[object WeakMap]"]=!1;const Gt=function(e){return we(e)&&$t(e.length)&&!!qt[pe(e)]};const Kt=function(e){return function(t){return e(t)}};var Yt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Qt=Yt&&"object"==typeof module&&module&&!module.nodeType&&module,Jt=Qt&&Qt.exports===Yt&&oe.process;const Xt=function(){try{var e=Qt&&Qt.require&&Qt.require("util").types;return e||Jt&&Jt.binding&&Jt.binding("util")}catch(e){}}();var ei=Xt&&Xt.isTypedArray;const ti=ei?Kt(ei):Gt;var ii=Object.prototype.hasOwnProperty;const ni=function(e,t){var i=be(e),n=!i&&Bt(e),o=!i&&!n&&Ut(e),r=!i&&!n&&!o&&ti(e),s=i||n||o||r,a=s?Rt(e.length,String):[],l=a.length;for(var c in e)!t&&!ii.call(e,c)||s&&("length"==c||o&&("offset"==c||"parent"==c)||r&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||Zt(c,l))||a.push(c);return a};var oi=Object.prototype;const ri=function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||oi)};const si=ve(Object.keys,Object);var ai=Object.prototype.hasOwnProperty;const li=function(e){if(!ri(e))return si(e);var t=[];for(var i in Object(e))ai.call(e,i)&&"constructor"!=i&&t.push(i);return t};const ci=function(e){return null!=e&&$t(e.length)&&!Ue(e)};const di=function(e){return ci(e)?ni(e):li(e)};const ui=function(e,t){return e&&Mt(t,di(t),e)};const hi=function(e){var t=[];if(null!=e)for(var i in Object(e))t.push(i);return t};var mi=Object.prototype.hasOwnProperty;const fi=function(e){if(!F(e))return hi(e);var t=ri(e),i=[];for(var n in e)("constructor"!=n||!t&&mi.call(e,n))&&i.push(n);return i};const gi=function(e){return ci(e)?ni(e,!0):fi(e)};const pi=function(e,t){return e&&Mt(t,gi(t),e)};var bi="object"==typeof exports&&exports&&!exports.nodeType&&exports,wi=bi&&"object"==typeof module&&module&&!module.nodeType&&module,ki=wi&&wi.exports===bi?se.Buffer:void 0,_i=ki?ki.allocUnsafe:void 0;const vi=function(e,t){if(t)return e.slice();var i=e.length,n=_i?_i(i):new e.constructor(i);return e.copy(n),n};const yi=function(e,t){var i=-1,n=e.length;for(t||(t=Array(n));++i{this._setToTarget(e,n,t[n],i)}))}}function Sn(e){return xn(e,Tn)}function Tn(e){return En(e)?e:void 0}function Pn(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 In(e){const t=Object.prototype.toString.apply(e);return"[object Window]"==t||"[object global]"==t}const On=Mn(R());function Mn(e){if(!e)return On;return class extends e{listenTo(e,t,i,n={}){if(Pn(e)||In(e)){const o={capture:!!n.useCapture,passive:!!n.usePassive},r=this._getProxyEmitter(e,o)||new Rn(e,o);this.listenTo(r,t,i,n)}else super.listenTo(e,t,i,n)}stopListening(e,t,i){if(Pn(e)||In(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[P];return i&&i[t]?i[t].emitter:null}(this,Nn(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=>{Mn[e]=On.prototype[e]}));class Rn extends(R()){constructor(e,t){super(),N(this,Nn(e,t)),this._domNode=e,this._options=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),R().prototype._addEventListener.call(this,e,t,i)}_removeEventListener(e,t){R().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}}function Nn(e,t){let i=function(e){return e["data-ck-expando"]||(e["data-ck-expando"]=w())}(e);for(const e of Object.keys(t).sort())t[e]&&(i+="-"+e);return i}let Vn;try{Vn={window,document}}catch(e){Vn={window:{},document:{}}}const Dn=Vn;function Ln(e){const t=[];let i=e;for(;i&&i.nodeType!=Node.DOCUMENT_NODE;)t.unshift(i),i=i.parentNode;return t}function Bn(e){return"[object Text]"==Object.prototype.toString.call(e)}function zn(e){return"[object Range]"==Object.prototype.toString.apply(e)}function jn(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)}}const Fn=["top","right","bottom","left","width","height"];class Hn{constructor(e){const t=zn(e);if(Object.defineProperty(this,"_source",{value:e._source||e,writable:!0,enumerable:!1}),Zn(e)||t)if(t){const t=Hn.getDomRangeRects(e);Un(this,Hn.getBoundingRect(t))}else Un(this,e.getBoundingClientRect());else if(In(e)){const{innerWidth:t,innerHeight:i}=e;Un(this,{top:0,right:t,bottom:i,left:0,width:t,height:i})}else Un(this,e)}clone(){return new Hn(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};return t.width=t.right-t.left,t.height=t.bottom-t.top,t.width<0||t.height<0?null:new Hn(t)}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(Wn(e))return t;let i,n=e,o=e.parentNode||e.commonAncestorContainer;for(;o&&!Wn(o);){if(n instanceof HTMLElement&&"absolute"===$n(n)&&(i=n),i&&("relative"!==$n(o)||"visible"===(r=o).ownerDocument.defaultView.getComputedStyle(r).overflow)){n=o,o=o.parentNode;continue}const e=new Hn(o),s=t.getIntersection(e);if(!s)return null;s.getArea(){for(const t of e){const e=qn._getElementCallbacks(t.target);if(e)for(const i of e)i(t)}}))}}function Gn(e,t){e instanceof HTMLTextAreaElement&&(e.value=t),e.innerHTML=t}function Kn(e){return t=>t+e}function Yn(e){let t=0;for(;e.previousSibling;)e=e.previousSibling,t++;return t}function Qn(e,t,i){e.insertBefore(i,e.childNodes[t]||null)}function Jn(e){return e&&e.nodeType===Node.COMMENT_NODE}function Xn(e){try{Dn.document.createAttribute(e)}catch(e){return!1}return!0}function eo(e){return!!(e&&e.getClientRects&&e.getClientRects().length)}function to({element:e,target:t,positions:i,limiter:n,fitInViewport:o,viewportOffsetConfig:r}){Ue(t)&&(t=t()),Ue(n)&&(n=n());const s=function(e){return e&&e.parentNode?e.offsetParent===Dn.document.body?null:e.offsetParent:null}(e),a=new Hn(e),l=new Hn(t);let c;const d=o&&function(e){e=Object.assign({top:0,bottom:0,left:0,right:0},e);const t=new Hn(Dn.window);return t.top+=e.top,t.height-=e.top,t.bottom-=e.bottom,t.height-=e.bottom,t}(r)||null,u={targetRect:l,elementRect:a,positionedElementAncestor:s,viewportRect:d};if(n||o){const e=n&&new Hn(n).getVisible();Object.assign(u,{limiterRect:e,viewportRect:d}),c=function(e,t){const{elementRect:i}=t,n=i.getArea(),o=e.map((e=>new no(e,t))).filter((e=>!!e.name));let r=0,s=null;for(const e of o){const{limiterIntersectionArea:t,viewportIntersectionArea:i}=e;if(t===n)return e;const o=i**2+t**2;o>r&&(r=o,s=e)}return s}(i,u)||new no(i[0],u)}else c=new no(i[0],u);return c}function io(e){const{scrollX:t,scrollY:i}=Dn.window;return e.clone().moveBy(t,i)}qn._observerInstance=null,qn._elementCallbacks=null;class no{constructor(e,t){const i=e(t.targetRect,t.elementRect,t.viewportRect);if(!i)return;const{left:n,top:o,name:r,config:s}=i;this.name=r,this.config=s,this._positioningFunctionCorrdinates={left:n,top:o},this._options=t}get left(){return this._absoluteRect.left}get top(){return this._absoluteRect.top}get limiterIntersectionArea(){const e=this._options.limiterRect;if(e){const t=this._options.viewportRect;if(!t)return e.getIntersectionArea(this._rect);{const i=e.getIntersection(t);if(i)return i.getIntersectionArea(this._rect)}}return 0}get viewportIntersectionArea(){const e=this._options.viewportRect;return e?e.getIntersectionArea(this._rect):0}get _rect(){return this._cachedRect||(this._cachedRect=this._options.elementRect.clone().moveTo(this._positioningFunctionCorrdinates.left,this._positioningFunctionCorrdinates.top)),this._cachedRect}get _absoluteRect(){return this._cachedAbsoluteRect||(this._cachedAbsoluteRect=io(this._rect),this._options.positionedElementAncestor&&function(e,t){const i=io(new Hn(t)),n=jn(t);let o=0,r=0;o-=i.left,r-=i.top,o+=t.scrollLeft,r+=t.scrollTop,o-=n.left,r-=n.top,e.moveBy(o,r)}(this._cachedAbsoluteRect,this._options.positionedElementAncestor)),this._cachedAbsoluteRect}}function oo(e){const t=e.parentNode;t&&t.removeChild(e)}function ro({window:e,rect:t,alignToTop:i,forceScroll:n,viewportOffset:o}){const r=t.clone().moveBy(0,o.bottom),s=t.clone().moveBy(0,-o.top),a=new Hn(e).excludeScrollbarsAndBorders(),l=i&&n,c=[s,r].every((e=>a.contains(e)));let{scrollX:d,scrollY:u}=e;const h=d,m=u;l?u-=a.top-t.top+o.top:c||(lo(s,a)?u-=a.top-t.top+o.top:ao(r,a)&&(u+=i?t.top-a.top-o.top:t.bottom-a.bottom+o.bottom)),c||(co(t,a)?d-=a.left-t.left+o.left:uo(t,a)&&(d+=t.right-a.right+o.right)),d==h&&u===m||e.scrollTo(d,u)}function so({parent:e,getRect:t,alignToTop:i,forceScroll:n,ancestorOffset:o=0}){const r=ho(e),s=i&&n;let a,l,c;for(;e!=r.document.body;)l=t(),a=new Hn(e).excludeScrollbarsAndBorders(),c=a.contains(l),s?e.scrollTop-=a.top-l.top+o:c||(lo(l,a)?e.scrollTop-=a.top-l.top+o:ao(l,a)&&(e.scrollTop+=i?l.top-a.top-o:l.bottom-a.bottom+o)),c||(co(l,a)?e.scrollLeft-=a.left-l.left+o:uo(l,a)&&(e.scrollLeft+=l.right-a.right+o)),e=e.parentNode}function ao(e,t){return e.bottom>t.bottom}function lo(e,t){return e.topt.right}function ho(e){return zn(e)?e.startContainer.ownerDocument.defaultView:e.ownerDocument.defaultView}function mo(e){if(zn(e)){let t=e.commonAncestorContainer;return Bn(t)&&(t=t.parentNode),t}return e.parentNode}function fo(e,t){const i=ho(e),n=new Hn(e);if(i===t)return n;{let e=i;for(;e!=t;){const t=e.frameElement,i=new Hn(t).excludeScrollbarsAndBorders();n.moveBy(i.left,i.top),e=e.parent}}return n}const go={ctrl:"⌃",cmd:"⌘",alt:"⌥",shift:"⇧"},po={ctrl:"Ctrl+",alt:"Alt+",shift:"Shift+"},bo=function(){const e={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;for(const t of"`-=[];',./\\")e[t]=t.charCodeAt(0);return e}(),wo=Object.fromEntries(Object.entries(bo).map((([e,t])=>[t,e.charAt(0).toUpperCase()+e.slice(1)])));function ko(e){let t;if("string"==typeof e){if(t=bo[e.toLowerCase()],!t)throw new y("keyboard-unknown-key",null,{key:e})}else t=e.keyCode+(e.altKey?bo.alt:0)+(e.ctrlKey?bo.ctrl:0)+(e.shiftKey?bo.shift:0)+(e.metaKey?bo.cmd:0);return t}function _o(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 ko(e.slice(0,-1));const t=ko(e);return c.isMac&&t==bo.ctrl?bo.cmd:t}(e):e)).reduce(((e,t)=>t+e),0)}function vo(e){let t=_o(e);return Object.entries(c.isMac?go:po).reduce(((e,[i,n])=>(0!=(t&bo[i])&&(t&=~bo[i],e+=n),e)),"")+(t?wo[t]:"")}function yo(e,t){const i="ltr"===t;switch(e){case bo.arrowleft:return i?"left":"right";case bo.arrowright:return i?"right":"left";case bo.arrowup:return"up";case bo.arrowdown:return"down"}}const Ao=["ar","ara","fa","per","fas","he","heb","ku","kur","ug","uig"];function xo(e){return Ao.includes(e)?"rtl":"ltr"}function Eo(e){return Array.isArray(e)?e:[e]}function Co(e,t,i=1){if("number"!=typeof i)throw new y("translation-service-quantity-not-a-number",null,{quantity:i});const n=Object.keys(Dn.window.CKEDITOR_TRANSLATIONS).length;1===n&&(e=Object.keys(Dn.window.CKEDITOR_TRANSLATIONS)[0]);const o=t.id||t.string;if(0===n||!function(e,t){return!!Dn.window.CKEDITOR_TRANSLATIONS[e]&&!!Dn.window.CKEDITOR_TRANSLATIONS[e].dictionary[t]}(e,o))return 1!==i?t.plural:t.string;const r=Dn.window.CKEDITOR_TRANSLATIONS[e].dictionary,s=Dn.window.CKEDITOR_TRANSLATIONS[e].getPluralForm||(e=>1===e?0:1),a=r[o];if("string"==typeof a)return a;return a[Number(s(i))]}Dn.window.CKEDITOR_TRANSLATIONS||(Dn.window.CKEDITOR_TRANSLATIONS={});class So{constructor({uiLanguage:e="en",contentLanguage:t}={}){this.uiLanguage=e,this.contentLanguage=t||this.uiLanguage,this.uiLanguageDirection=xo(this.uiLanguage),this.contentLanguageDirection=xo(this.contentLanguage),this.t=(e,t)=>this._t(e,t)}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=Eo(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)=>ithis._items.length||t<0)throw new y("collection-add-item-invalid-index",this);let i=0;for(const n of e){const e=this._getItemIdBeforeAdding(n),o=t+i;this._items.splice(o,0,n),this._itemMap.set(e,n),this.fire("add",n,o),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 y("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)}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 y("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,o)=>{const r=t._bindToCollection==this,s=t._bindToInternalToExternalMap.get(n);if(r&&s)this._bindToExternalToInternalMap.set(n,s),this._bindToInternalToExternalMap.set(s,n);else{const i=e(n);if(!i)return void this._skippedIndexesFromExternal.push(o);let r=o;for(const e of this._skippedIndexesFromExternal)o>e&&r--;for(const e of t._skippedIndexesFromExternal)r>=e&&r++;this._bindToExternalToInternalMap.set(n,i),this._bindToInternalToExternalMap.set(i,n),this.add(i,r);for(let e=0;e{const n=this._bindToExternalToInternalMap.get(t);n&&this.remove(n),this._skippedIndexesFromExternal=this._skippedIndexesFromExternal.reduce(((e,t)=>(it&&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 y("collection-add-invalid-id",this);if(this.get(i))throw new y("collection-add-item-already-exists",this)}else e[t]=i=w();return i}_remove(e){let t,i,n,o=!1;const r=this._idProperty;if("string"==typeof e?(i=e,n=this._itemMap.get(i),o=!n,n&&(t=this._items.indexOf(n))):"number"==typeof e?(t=e,n=this._items[t],o=!n,n&&(i=n[r])):(n=e,i=n[r],t=this._items.indexOf(n),o=-1==t||!this._itemMap.get(i)),o)throw new y("collection-remove-404",this);this._items.splice(t,1),this._itemMap.delete(i);const s=this._bindToInternalToExternalMap.get(n);return this._bindToInternalToExternalMap.delete(n),this._bindToExternalToInternalMap.delete(s),this.fire("remove",n,t),[n,t]}[Symbol.iterator](){return this._items[Symbol.iterator]()}}function Po(e){const t=e.next();return t.done?null:t.value}class Io extends(Mn(G())){constructor(){super(),this._elements=new Set,this._nextEventLoopTimeout=null,this.set("isFocused",!1),this.set("focusedElement",null)}add(e){if(this._elements.has(e))throw new y("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)}}class Oo{constructor(){this._listener=new(Mn())}listenTo(e){this._listener.listenTo(e,"keydown",((e,t)=>{this._listener.fire("_keydown:"+ko(t),t)}))}set(e,t,i={}){const n=_o(e),o=i.priority;this._listener.listenTo(this._listener,"_keydown:"+n,((e,i)=>{t(i,(()=>{i.preventDefault(),i.stopPropagation(),e.stop()})),e.return=!0}),{priority:o})}press(e){return!!this._listener.fire("_keydown:"+ko(e),e)}stopListening(e){this._listener.stopListening(e)}destroy(){this.stopListening()}}function Mo(e){return ne(e)?new Map(e):function(e){const t=new Map;for(const i in e)t.set(i,e[i]);return t}(e)}function Ro(e,t){let i;function n(...o){n.cancel(),i=setTimeout((()=>e(...o)),t)}return n.cancel=()=>{clearTimeout(i)},n}function No(e,t){return!!(i=e.charAt(t-1))&&1==i.length&&/[\ud800-\udbff]/.test(i)&&function(e){return!!e&&1==e.length&&/[\udc00-\udfff]/.test(e)}(e.charAt(t));var i}function Vo(e,t){return!!(i=e.charAt(t))&&1==i.length&&/[\u0300-\u036f\u1ab0-\u1aff\u1dc0-\u1dff\u20d0-\u20ff\ufe20-\ufe2f]/.test(i);var i}const Do=function(){const e=/\p{Regional_Indicator}{2}/u.source,t="(?:"+[/\p{Emoji}[\u{E0020}-\u{E007E}]+\u{E007F}/u,/\p{Emoji}\u{FE0F}?\u{20E3}/u,/\p{Emoji}\u{FE0F}/u,/(?=\p{General_Category=Other_Symbol})\p{Emoji}\p{Emoji_Modifier}*/u].map((e=>e.source)).join("|")+")";return new RegExp(`${e}|${t}(?:‍${t})*`,"ug")}();function Lo(e,t){const i=String(e).matchAll(Do);return Array.from(i).some((e=>e.index{this._renderViewIntoCollectionParent(t,i)})),this.on("remove",((e,t)=>{t.element&&this._parentElement&&t.element.remove()})),this._parentElement=null}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 y("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)}}var zo=i(3379),jo=i.n(zo),Fo=i(9037),Ho=i.n(Fo),Uo=i(569),Wo=i.n(Uo),Zo=i(8575),$o=i.n(Zo),qo=i(9216),Go=i.n(qo),Ko=i(972),Yo={attributes:{"data-cke":!0}};Yo.setAttributes=$o(),Yo.insert=Wo().bind(null,"head"),Yo.domAPI=Ho(),Yo.insertStyleElement=Go();jo()(Ko.Z,Yo);Ko.Z&&Ko.Z.locals&&Ko.Z.locals;class Qo extends(Mn(G())){constructor(e){super(),this.element=null,this.isRendered=!1,this.locale=e,this.t=e&&e.t,this._viewCollections=new To,this._unboundChildren=this.createCollection(),this._viewCollections.on("add",((t,i)=>{i.locale=e,i.t=e&&e.t})),this.decorate("render")}get bindTemplate(){return this._bindTemplate?this._bindTemplate:this._bindTemplate=Jo.bind(this,this)}createCollection(e){const t=new Bo(e);return this._viewCollections.add(t),t}registerChild(e){ne(e)||(e=[e]);for(const t of e)this._unboundChildren.add(t)}deregisterChild(e){ne(e)||(e=[e]);for(const t of e)this._unboundChildren.remove(t)}setTemplate(e){this.template=new Jo(e)}extendTemplate(e){Jo.extend(this.template,e)}render(){if(this.isRendered)throw new y("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)}}class Jo extends(R()){constructor(e){super(),Object.assign(this,lr(ar(e))),this._isRendered=!1,this._revertData=null}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 y("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)fr(i)?yield i:gr(i)&&(yield*e(i))}(this)}static bind(e,t){return{to:(i,n)=>new er({eventNameOrFunction:i,attribute:i,observable:e,emitter:t,callback:n}),if:(i,n,o)=>new tr({observable:e,emitter:t,attribute:i,valueIfTrue:n,callback:o})}}static extend(e,t){if(e._isRendered)throw new y("template-extend-render",[this,e]);hr(e,lr(ar(t)))}_renderNode(e){let t;if(t=e.node?this.tag&&this.text:this.tag?this.text:!this.text,t)throw new y("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(""),ir(this.text)?this._bindToObservable({schema:this.text,updater:or(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 o=t.getAttribute(n),r=this.attributes[n];i&&(i.attributes[n]=o);const s=br(r)?r[0].ns:null;if(ir(r)){const a=br(r)?r[0].value:r;i&&wr(n)&&a.unshift(o),this._bindToObservable({schema:a,updater:rr(t,n,s),data:e})}else if("style"==n&&"string"!=typeof r[0])this._renderStyleAttribute(r[0],e);else{i&&o&&wr(n)&&r.unshift(o);const e=r.map((e=>e&&e.value||e)).reduce(((e,t)=>e.concat(t)),[]).reduce(dr,"");mr(e)||t.setAttributeNS(s,n,e)}}}_renderStyleAttribute(e,t){const i=t.node;for(const n in e){const o=e[n];ir(o)?this._bindToObservable({schema:[o],updater:sr(i,n),data:t}):i.style[n]=o}}_renderElementChildren(e){const t=e.node,i=e.intoFragment?document.createDocumentFragment():t,n=e.isApplying;let o=0;for(const r of this.children)if(pr(r)){if(!n){r.setParent(t);for(const e of r)i.appendChild(e.element)}}else if(fr(r))n||(r.isRendered||r.render(),i.appendChild(r.element));else if(Pn(r))i.appendChild(r);else if(n){const t={children:[],bindings:[],attributes:{}};e.revertData.children.push(t),r._renderNode({intoFragment:!1,node:i.childNodes[o++],isApplying:!0,revertData:t})}else i.appendChild(r.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,o]=t.split("@");return i.activateDomEventListener(n,o,e)}));e.revertData&&e.revertData.bindings.push(i)}}_bindToObservable({schema:e,updater:t,data:i}){const n=i.revertData;nr(e,t,i);const o=e.filter((e=>!mr(e))).filter((e=>e.observable)).map((n=>n.activateAttributeListener(e,t,i)));n&&n.bindings.push(o)}_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;enr(e,t,i);return this.emitter.listenTo(this.observable,`change:${this.attribute}`,n),()=>{this.emitter.stopListening(this.observable,`change:${this.attribute}`,n)}}}class er extends Xo{constructor(e){super(e),this.eventNameOrFunction=e.eventNameOrFunction}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)}}}class tr extends Xo{constructor(e){super(e),this.valueIfTrue=e.valueIfTrue}getValue(e){return!mr(super.getValue(e))&&(this.valueIfTrue||!0)}}function ir(e){return!!e&&(e.value&&(e=e.value),Array.isArray(e)?e.some(ir):e instanceof Xo)}function nr(e,t,{node:i}){const n=function(e,t){return e.map((e=>e instanceof Xo?e.getValue(t):e))}(e,i);let o;o=1==e.length&&e[0]instanceof tr?n[0]:n.reduce(dr,""),mr(o)?t.remove():t.set(o)}function or(e){return{set(t){e.textContent=t},remove(){e.textContent=""}}}function rr(e,t,i){return{set(n){e.setAttributeNS(i,t,n)},remove(){e.removeAttributeNS(i,t)}}}function sr(e,t){return{set(i){e.style[t]=i},remove(){e.style[t]=null}}}function ar(e){return xn(e,(e=>{if(e&&(e instanceof Xo||gr(e)||fr(e)||pr(e)))return e}))}function lr(e){if("string"==typeof e?e=function(e){return{text:[e]}}(e):e.text&&function(e){e.text=Eo(e.text)}(e),e.on&&(e.eventListeners=function(e){for(const t in e)cr(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=Eo(e[t].value)),cr(e,t)}(e.attributes);const t=[];if(e.children)if(pr(e.children))t.push(e.children);else for(const i of e.children)gr(i)||fr(i)||Pn(i)?t.push(i):t.push(new Jo(i));e.children=t}return e}function cr(e,t){e[t]=Eo(e[t])}function dr(e,t){return mr(t)?e:mr(e)?t:`${e} ${t}`}function ur(e,t){for(const i in t)e[i]?e[i].push(...t[i]):e[i]=t[i]}function hr(e,t){if(t.attributes&&(e.attributes||(e.attributes={}),ur(e.attributes,t.attributes)),t.eventListeners&&(e.eventListeners||(e.eventListeners={}),ur(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 y("ui-template-extend-children-mismatch",e);let i=0;for(const n of t.children)hr(e.children[i++],n)}}function mr(e){return!e&&0!==e}function fr(e){return e instanceof Qo}function gr(e){return e instanceof Jo}function pr(e){return e instanceof Bo}function br(e){return F(e[0])&&e[0].ns}function wr(e){return"class"==e||"style"==e}class kr extends Bo{constructor(e,t=[]){super(t),this.locale=e}get bodyCollectionContainer(){return this._bodyCollectionContainer}attachToDom(){this._bodyCollectionContainer=new Jo({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=_e(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()}}var _r=i(3872),vr={attributes:{"data-cke":!0}};vr.setAttributes=$o(),vr.insert=Wo().bind(null,"head"),vr.domAPI=Ho(),vr.insertStyleElement=Go();jo()(_r.Z,vr);_r.Z&&_r.Z.locals&&_r.Z.locals;class yr extends Qo{constructor(){super();const e=this.bindTemplate;this.set("content",""),this.set("viewBox","0 0 20 20"),this.set("fillColor",""),this.set("isColorInherited",!0),this.setTemplate({tag:"svg",ns:"http://www.w3.org/2000/svg",attributes:{class:["ck","ck-icon","ck-reset_all-excluded",e.if("isColorInherited","ck-icon_inherit-color")],viewBox:e.to("viewBox")}})}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))yr.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}))}}yr.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"];var Ar=i(9377),xr={attributes:{"data-cke":!0}};xr.setAttributes=$o(),xr.insert=Wo().bind(null,"head"),xr.domAPI=Ho(),xr.insertStyleElement=Go();jo()(Ar.Z,xr);Ar.Z&&Ar.Z.locals&&Ar.Z.locals;class Er extends Qo{constructor(e){super(e),this._focusDelayed=null;const t=this.bindTemplate,i=w();this.set("ariaChecked",void 0),this.set("ariaLabel",void 0),this.set("ariaLabelledBy",`ck-editor__aria-label_${i}`),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._createLabelView(),this.iconView=new yr,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 n={tag:"button",attributes:{class:["ck","ck-button",t.to("class"),t.if("isEnabled","ck-disabled",(e=>!e)),t.if("isVisible","ck-hidden",(e=>!e)),t.to("isOn",(e=>e?"ck-on":"ck-off")),t.if("withText","ck-button_with-text"),t.if("withKeystroke","ck-button_with-keystroke")],role:t.to("role"),type:t.to("type",(e=>e||"button")),tabindex:t.to("tabindex"),"aria-label":t.to("ariaLabel"),"aria-labelledby":t.to("ariaLabelledBy"),"aria-disabled":t.if("isEnabled",!0,(e=>!e)),"aria-checked":t.to("isOn"),"aria-pressed":t.to("isOn",(e=>!!this.isToggleable&&String(!!e))),"data-cke-tooltip-text":t.to("_tooltipString"),"data-cke-tooltip-position":t.to("tooltipPosition")},children:this.children,on:{click:t.to((e=>{this.isEnabled?this.fire("execute"):e.preventDefault()}))}};c.isSafari&&(this._focusDelayed||(this._focusDelayed=Ro((()=>this.focus()),0)),n.on.mousedown=t.to((()=>{this._focusDelayed()})),n.on.mouseup=t.to((()=>{this._focusDelayed.cancel()}))),this.setTemplate(n)}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()}_createLabelView(){const e=new Qo,t=this.bindTemplate;return e.setTemplate({tag:"span",attributes:{class:["ck","ck-button__label"],style:t.to("labelStyle"),id:this.ariaLabelledBy},children:[{text:t.to("label")}]}),e}_createKeystrokeView(){const e=new Qo;return e.setTemplate({tag:"span",attributes:{class:["ck","ck-button__keystroke"]},children:[{text:this.bindTemplate.to("keystroke",(e=>vo(e)))}]}),e}_getTooltipString(e,t,i){return e?"string"==typeof e?e:(i&&(i=vo(i)),e instanceof Function?e(t,i):`${t}${i?` (${i})`:""}`):""}}var Cr=i(9547),Sr={attributes:{"data-cke":!0}};Sr.setAttributes=$o(),Sr.insert=Wo().bind(null,"head"),Sr.domAPI=Ho(),Sr.insertStyleElement=Go();jo()(Cr.Z,Sr);Cr.Z&&Cr.Z.locals&&Cr.Z.locals;class Tr extends Er{constructor(e){super(e),this.isToggleable=!0,this.toggleSwitchView=this._createToggleView(),this.extendTemplate({attributes:{class:"ck-switchbutton"}})}render(){super.render(),this.children.add(this.toggleSwitchView)}_createToggleView(){const e=new Qo;return e.setTemplate({tag:"span",attributes:{class:["ck","ck-button__toggle"]},children:[{tag:"span",attributes:{class:["ck","ck-button__toggle__inner"]}}]}),e}}function Pr(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 Ir extends Er{constructor(e){super(e);const t=this.bindTemplate;this.set("color",void 0),this.set("hasBorder",!1),this.icon='',this.extendTemplate({attributes:{style:{backgroundColor:t.to("color")},class:["ck","ck-color-grid__tile",t.if("hasBorder","ck-color-table__color-tile_bordered")]}})}render(){super.render(),this.iconView.fillColor="hsl(0, 0%, 100%)"}}var Or=i(6601),Mr={attributes:{"data-cke":!0}};Mr.setAttributes=$o(),Mr.insert=Wo().bind(null,"head"),Mr.domAPI=Ho(),Mr.insertStyleElement=Go();jo()(Or.Z,Mr);Or.Z&&Or.Z.locals&&Or.Z.locals;class Rr extends Qo{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 Io,this.keystrokes=new Oo,this.items.on("add",((e,t)=>{t.isOn=t.color===this.selectedColor})),i.forEach((e=>{const t=new Ir;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}))}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),s({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()}}var Nr=i(8874);const Vr=function(e){var t,i,n=[],o=1;if("string"==typeof e)if(Nr[e])n=Nr[e].slice(),i="rgb";else if("transparent"===e)o=0,i="rgb",n=[0,0,0];else if(/^#[A-Fa-f0-9]+$/.test(e)){var r=e.slice(1);o=1,(l=r.length)<=4?(n=[parseInt(r[0]+r[0],16),parseInt(r[1]+r[1],16),parseInt(r[2]+r[2],16)],4===l&&(o=parseInt(r[3]+r[3],16)/255)):(n=[parseInt(r[0]+r[1],16),parseInt(r[2]+r[3],16),parseInt(r[4]+r[5],16)],8===l&&(o=parseInt(r[6]+r[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 s=t[1],a="rgb"===s;i=r=s.replace(/a$/,"");var l="cmyk"===r?4:"gray"===r?1:3;n=t[2].trim().split(/\s*[,\/]\s*|\s+/).map((function(e,t){if(/%$/.test(e))return t===l?parseFloat(e)/100:"rgb"===r?255*parseFloat(e)/100:parseFloat(e);if("h"===r[t]){if(/deg$/.test(e))return parseFloat(e);if(void 0!==Dr[e])return Dr[e]}return parseFloat(e)})),s===r&&n.push(1),o=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",o=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]),o=e.a||e.alpha||e.opacity||1,null!=e.opacity&&(o/=100)):(i="rgb",n=[e>>>16,(65280&e)>>>8,255&e]);return{space:i,values:n,alpha:o}};var Dr={red:0,orange:60,yellow:120,green:180,blue:240,purple:300};var Lr=i(2085);function Br(e,t){if(!e)return"";const i=zr(e);if(!i)return"";if(i.space===t)return e;if(n=i,!Object.keys(Lr).includes(n.space))return"";var n;const o=Lr[i.space][t];if(!o)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""}}(o("hex"===i.space?i.hexValue:i.values),t)}function zr(e){if(e.startsWith("#")){const t=Vr(e);return{space:"hex",values:t.values,hexValue:e,alpha:t.alpha}}const t=Vr(e);return t.space?t:null}const jr=function(){return se.Date.now()};var Fr=/\s/;const Hr=function(e){for(var t=e.length;t--&&Fr.test(e.charAt(t)););return t};var Ur=/^\s+/;const Wr=function(e){return e?e.slice(0,Hr(e)+1).replace(Ur,""):e};const Zr=function(e){return"symbol"==typeof e||we(e)&&"[object Symbol]"==pe(e)};var $r=/^[-+]0x[0-9a-f]+$/i,qr=/^0b[01]+$/i,Gr=/^0o[0-7]+$/i,Kr=parseInt;const Yr=function(e){if("number"==typeof e)return e;if(Zr(e))return NaN;if(F(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=F(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=Wr(e);var i=qr.test(e);return i||Gr.test(e)?Kr(e.slice(2),i?2:8):$r.test(e)?NaN:+e};var Qr=Math.max,Jr=Math.min;const Xr=function(e,t,i){var n,o,r,s,a,l,c=0,d=!1,u=!1,h=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function m(t){var i=n,r=o;return n=o=void 0,c=t,s=e.apply(r,i)}function f(e){var i=e-l;return void 0===l||i>=t||i<0||u&&e-c>=r}function g(){var e=jr();if(f(e))return p(e);a=setTimeout(g,function(e){var i=t-(e-l);return u?Jr(i,r-(e-c)):i}(e))}function p(e){return a=void 0,h&&n?m(e):(n=o=void 0,s)}function b(){var e=jr(),i=f(e);if(n=arguments,o=this,l=e,i){if(void 0===a)return function(e){return c=e,a=setTimeout(g,t),d?m(e):s}(l);if(u)return clearTimeout(a),a=setTimeout(g,t),m(l)}return void 0===a&&(a=setTimeout(g,t)),s}return t=Yr(t)||0,F(i)&&(d=!!i.leading,r=(u="maxWait"in i)?Qr(Yr(i.maxWait)||0,t):r,h="trailing"in i?!!i.trailing:h),b.cancel=function(){void 0!==a&&clearTimeout(a),c=0,n=l=o=a=void 0},b.flush=function(){return void 0===a?s:p(jr())},b};var es=i(3320),ts={attributes:{"data-cke":!0}};ts.setAttributes=$o(),ts.insert=Wo().bind(null,"head"),ts.domAPI=Ho(),ts.insertStyleElement=Go();jo()(es.Z,ts);es.Z&&es.Z.locals&&es.Z.locals;class is extends Qo{constructor(e){super(e),this.set("text",void 0),this.set("for",void 0),this.id=`ck-editor__label_${w()}`;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")}]})}}var ns=i(7546),os={attributes:{"data-cke":!0}};os.setAttributes=$o(),os.insert=Wo().bind(null,"head"),os.domAPI=Ho(),os.insertStyleElement=Go();jo()(ns.Z,os);ns.Z&&ns.Z.locals&&ns.Z.locals;class rs extends Qo{constructor(e,t){super(e);const i=`ck-labeled-field-view-${w()}`,n=`ck-labeled-field-view-status-${w()}`;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 o=this.bindTemplate;this.setTemplate({tag:"div",attributes:{class:["ck","ck-labeled-field-view",o.to("class"),o.if("isEnabled","ck-disabled",(e=>!e)),o.if("isEmpty","ck-labeled-field-view_empty"),o.if("isFocused","ck-labeled-field-view_focused"),o.if("placeholder","ck-labeled-field-view_placeholder"),o.if("errorText","ck-error")]},children:[{tag:"div",attributes:{class:["ck","ck-labeled-field-view__input-wrapper"]},children:this.fieldWrapperChildren},this.statusView]})}_createLabelView(e){const t=new is(this.locale);return t.for=e,t.bind("text").to(this,"label"),t}_createStatusView(e){const t=new Qo(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(){this.fieldView.focus()}}var ss=i(7138),as={attributes:{"data-cke":!0}};as.setAttributes=$o(),as.insert=Wo().bind(null,"head"),as.domAPI=Ho(),as.insertStyleElement=Go();jo()(ss.Z,as);ss.Z&&ss.Z.locals&&ss.Z.locals;class ls extends Qo{constructor(e){super(e),this.set("value",void 0),this.set("id",void 0),this.set("placeholder",void 0),this.set("isReadOnly",!1),this.set("hasError",!1),this.set("ariaDescribedById",void 0),this.focusTracker=new Io,this.bind("isFocused").to(this.focusTracker),this.set("isEmpty",!0),this.set("inputMode","text");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"),readonly:t.to("isReadOnly"),inputmode:t.to("inputMode"),"aria-invalid":t.if("hasError",!0),"aria-describedby":t.to("ariaDescribedById")},on:{input:t.to(((...e)=>{this.fire("input",...e),this._updateIsEmpty()})),change:t.to(this._updateIsEmpty.bind(this))}})}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()}_updateIsEmpty(){this.isEmpty=!this.element.value}_setDomElementValue(e){this.element.value=e||0===e?e:""}}class cs extends ls{constructor(e){super(e),this.extendTemplate({attributes:{type:"text",class:["ck-input-text"]}})}}class ds extends Qo{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")]},children:this.children,on:{selectstart:t.to((e=>{"input"!==e.target.tagName.toLocaleLowerCase()&&e.preventDefault()}))}})}focus(){if(this.children.length){const e=this.children.first;"function"==typeof e.focus?e.focus():A("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()}}}var us=i(5457),hs={attributes:{"data-cke":!0}};hs.setAttributes=$o(),hs.insert=Wo().bind(null,"head"),hs.domAPI=Ho(),hs.insertStyleElement=Go();jo()(us.Z,hs);us.Z&&us.Z.locals&&us.Z.locals;class ms extends Qo{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.keystrokes=new Oo,this.focusTracker=new Io,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")}})}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.panelView.bind("isVisible").to(this,"isOpen"),this.on("change:isOpen",((e,t,i)=>{i&&("auto"===this.panelPosition?this.panelView.position=ms._getOptimalPosition({element:this.panelView.element,target:this.buttonView.element,fitInViewport:!0,positions:this._panelPositions}).name: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:o,northWest:r,southMiddleEast:s,southMiddleWest:a,northMiddleEast:l,northMiddleWest:c}=ms.defaultPanelPositions;return"rtl"!==this.locale.uiLanguageDirection?[i,n,s,a,e,o,r,l,c,t]:[n,i,a,s,e,r,o,c,l,t]}}ms.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"})},ms._getOptimalPosition=to;const fs='';class gs extends Er{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")}render(){super.render(),this.children.add(this.arrowView)}_createArrowView(){const e=new yr;return e.content=fs,e.extendTemplate({attributes:{class:"ck-dropdown__arrow"}}),e}}class ps{constructor(e){if(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()}))}}get first(){return this.focusables.find(bs)||null}get last(){return this.focusables.filter(bs).slice(-1)[0]||null}get next(){return this._getFocusableItem(1)}get previous(){return this._getFocusableItem(-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)}focusLast(){this._focus(this.last)}focusNext(){this._focus(this.next)}focusPrevious(){this._focus(this.previous)}_focus(e){e&&e.focus()}_getFocusableItem(e){const t=this.current,i=this.focusables.length;if(!i)return null;if(null===t)return this[1===e?"first":"last"];let n=(t+i+e)%i;do{const t=this.focusables.get(n);if(bs(t))return t;n=(n+i+e)%i}while(n!==t);return null}}function bs(e){return!(!e.focus||!eo(e.element))}class ws extends Qo{constructor(e){super(e),this.setTemplate({tag:"span",attributes:{class:["ck","ck-toolbar__separator"]}})}}class ks extends Qo{constructor(e){super(e),this.setTemplate({tag:"span",attributes:{class:["ck","ck-toolbar__line-break"]}})}}function _s(e){return Array.isArray(e)?{items:e,removeItems:[]}:e?Object.assign({items:[],removeItems:[]},e):{items:[],removeItems:[]}}class vs extends(G()){constructor(e){super(),this._disableStack=new Set,this.editor=e,this.set("isEnabled",!0)}forceDisabled(e){this._disableStack.add(e),1==this._disableStack.size&&(this.on("set:isEnabled",ys,{priority:"highest"}),this.isEnabled=!1)}clearForceDisabled(e){this._disableStack.delete(e),0==this._disableStack.size&&(this.off("set:isEnabled",ys),this.isEnabled=!0)}destroy(){this.stopListening()}static get isContextPlugin(){return!1}}function ys(e){e.return=!1,e.stop()}class As extends(G()){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=>{this.affectsData&&(e.isReadOnly||this._isEnabledBasedOnSelection&&!e.model.canEditAt(e.model.document.selection))&&(t.return=!1,t.stop())}),{priority:"highest"}),this.on("execute",(e=>{this.isEnabled||e.stop()}),{priority:"high"})}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",xs,{priority:"highest"}),this.isEnabled=!1)}clearForceDisabled(e){this._disableStack.delete(e),0==this._disableStack.size&&(this.off("set:isEnabled",xs),this.refresh())}execute(...e){}destroy(){this.stopListening()}}function xs(e){e.return=!1,e.stop()}class Es extends As{constructor(){super(...arguments),this._childCommandsDefinitions=[]}refresh(){}execute(...e){const t=this._getFirstEnabledCommand();return!!t&&t.execute(e)}registerChildCommand(e,t={}){_(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}}class Cs extends(R()){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)}*[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 y("plugincollection-plugin-not-loaded",this._context,{plugin:t})}return t}has(e){return this._plugins.has(e)}init(e,t=[],i=[]){const n=this,o=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),u(e);const r=[...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&&(u(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 y("plugincollection-replace-plugin-invalid-type",null,{pluginItem:i});const t=i.pluginName;if(!t)throw new y("plugincollection-replace-plugin-missing-name",null,{pluginItem:i});if(i.requires&&i.requires.length)throw new y("plugincollection-plugin-for-replacing-cannot-have-dependencies",null,{pluginName:t});const o=n._availablePlugins.get(t);if(!o)throw new y("plugincollection-plugin-for-replacing-not-exist",null,{pluginName:t});const r=e.indexOf(o);if(-1===r){if(n._contextPlugins.has(o))return;throw new y("plugincollection-plugin-for-replacing-not-loaded",null,{pluginName:t})}if(o.requires&&o.requires.length)throw new y("plugincollection-replaced-plugin-cannot-have-dependencies",null,{pluginName:t});e.splice(r,1,i),n._availablePlugins.set(t,i)}}(r,i);const s=function(e){return e.map((e=>{let t=n._contextPlugins.get(e);return t=t||new e(o),n._add(e,t),t}))}(r);return h(s,"init").then((()=>h(s,"afterInit"))).then((()=>s));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 u(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 y("plugincollection-soft-required",o,{missingPlugin:e,requiredBy:d(t)});throw new y("plugincollection-plugin-not-found",o,{plugin:e})}(e,i),function(e,t){if(!l(t))return;if(l(e))return;throw new y("plugincollection-context-required",o,{plugin:d(e),requiredBy:d(t)})}(e,i),function(e,i){if(!i)return;if(!c(e,t))return;throw new y("plugincollection-required",o,{plugin:d(e),requiredBy:d(i)})}(e,i)}))}function h(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 y("plugincollection-plugin-name-conflict",null,{pluginName:i,plugin1:this._plugins.get(i).constructor,plugin2:e});this._plugins.set(i,t)}}}class Ss{constructor(e){this._contextOwner=null,this.config=new Cn(e,this.constructor.defaultConfig);const t=this.constructor.builtinPlugins;this.config.define("plugins",t),this.plugins=new Cs(this,t);const i=this.config.get("language")||{};this.locale=new So({uiLanguage:"string"==typeof i?i:i.ui,contentLanguage:this.config.get("language.content")}),this.t=this.locale.t,this.editors=new To}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 y("context-initplugins-constructor-only",null,{Plugin:i});if(!0!==i.isContextPlugin)throw new y("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 y("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)))}))}}class Ts extends(G()){constructor(e){super(),this.context=e}destroy(){this.stopListening()}static get isContextPlugin(){return!0}}var Ps=i(5169),Is={attributes:{"data-cke":!0}};Is.setAttributes=$o(),Is.insert=Wo().bind(null,"head"),Is.domAPI=Ho(),Is.insertStyleElement=Go();jo()(Ps.Z,Is);Ps.Z&&Ps.Z.locals&&Ps.Z.locals;const Os=new WeakMap;function Ms({view:e,element:t,text:i,isDirectHost:n=!0,keepOnFocus:o=!1}){const r=e.document;Os.has(r)||(Os.set(r,new Map),r.registerPostFixer((e=>Ns(r,e))),r.on("change:isComposing",(()=>{e.change((e=>Ns(r,e)))}),{priority:"high"})),Os.get(r).set(t,{text:i,isDirectHost:n,keepOnFocus:o,hostElement:n?t:null}),e.change((e=>Ns(r,e)))}function Rs(e,t){return!!t.hasClass("ck-placeholder")&&(e.removeClass("ck-placeholder",t),!0)}function Ns(e,t){const i=Os.get(e),n=[];let o=!1;for(const[e,r]of i)r.isDirectHost&&(n.push(e),Vs(t,e,r)&&(o=!0));for(const[e,r]of i){if(r.isDirectHost)continue;const i=Ds(e);i&&(n.includes(i)||(r.hostElement=i,Vs(t,e,r)&&(o=!0)))}return o}function Vs(e,t,i){const{text:n,isDirectHost:o,hostElement:r}=i;let s=!1;r.getAttribute("data-placeholder")!==n&&(e.setAttribute("data-placeholder",n,r),s=!0);return(o||1==t.childCount)&&function(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,o=n.selection.anchor;return!(n.isComposing&&o&&o.parent===e||!t&&n.isFocused&&(!o||o.parent===e))}(r,i.keepOnFocus)?function(e,t){return!t.hasClass("ck-placeholder")&&(e.addClass("ck-placeholder",t),!0)}(e,r)&&(s=!0):Rs(e,r)&&(s=!0),s}function Ds(e){if(e.childCount){const t=e.getChild(0);if(t.is("element")&&!t.is("uiElement")&&!t.is("attributeElement"))return t}return null}class Ls{is(){throw new Error("is() method is abstract")}}const Bs=function(e){return An(e,4)};class zs extends(R(Ls)){constructor(e){super(),this.document=e,this.parent=null}get index(){let e;if(!this.parent)return null;if(-1==(e=this.parent.getChildIndex(this)))throw new y("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 o=0;for(;i[o]==n[o]&&i[o];)o++;return 0===o?null:i[o-1]}isBefore(e){if(this==e)return!1;if(this.root!==e.root)return!1;const t=this.getPath(),i=e.getPath(),n=ie(t,i);switch(n){case"prefix":return!0;case"extension":return!1;default:return t[n]e.data.length)throw new y("view-textproxy-wrong-offsetintext",this);if(i<0||t+i>e.data.length)throw new y("view-textproxy-wrong-length",this);this.data=e.data.substring(t,t+i),this.offsetInText=t}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}}Fs.prototype.is=function(e){return"$textProxy"===e||"view:$textProxy"===e||"textProxy"===e||"view:textProxy"===e};class Hs{constructor(...e){this._patterns=[],this.add(...e)}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=Us(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=Us(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}}function Us(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());Te(e)?(void 0!==e.style&&A("matcher-pattern-deprecated-attributes-style-key",e),void 0!==e.class&&A("matcher-pattern-deprecated-attributes-class-key",e)):(i.delete("style"),i.delete("class"));return Ws(e,i,(e=>t.getAttribute(e)))}(t.attributes,e),!i.attributes)||t.classes&&(i.classes=function(e,t){return Ws(e,t.getClassNames(),(()=>{}))}(t.classes,e),!i.classes)||t.styles&&(i.styles=function(e,t){return Ws(e,t.getStyleNames(!0),(e=>t.getStyle(e)))}(t.styles,e),!i.styles)?null:i}function Ws(e,t,i){const n=function(e){if(Array.isArray(e))return e.map((e=>Te(e)?(void 0!==e.key&&void 0!==e.value||A("matcher-pattern-missing-key-or-value",e),[e.key,e.value]):[e,!0]));if(Te(e))return Object.entries(e);return[[e,!0]]}(e),o=Array.from(t),r=[];if(n.forEach((([e,t])=>{o.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)&&r.push(n)}))})),n.length&&!(r.lengtho?0:o+t),(i=i>o?o:i)<0&&(i+=o),o=t>i?0:i-t>>>0,t>>>=0;for(var r=Array(o);++n0){if(++t>=800)return arguments[0]}else t=0;return e.apply(void 0,arguments)}};const Ia=Pa(Sa);const Oa=function(e,t){return Ia(Ea(e,t,ya),e+"")};const Ma=function(e,t,i){if(!F(i))return!1;var n=typeof t;return!!("number"==n?ci(i)&&Zt(t,i.length):"string"==n&&t in i)&&Ie(i[t],e)};const Ra=function(e){return Oa((function(t,i){var n=-1,o=i.length,r=o>1?i[o-1]:void 0,s=o>2?i[2]:void 0;for(r=e.length>3&&"function"==typeof r?(o--,r):void 0,s&&Ma(i[0],i[1],s)&&(r=o<3?void 0:r,o=1),t=Object(t);++nt===e));return Array.isArray(t)}set(e,t){if(F(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=za(e);ma(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]&&!F(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=fa(this._styles,i);if(!n)return;!Array.from(Object.keys(n)).length&&this.remove(i)}}class Ba{constructor(){this._normalizers=new Map,this._extractors=new Map,this._reducers=new Map,this._consumables=new Map}toNormalizedForm(e,t,i){if(F(t))ja(i,za(e),t);else if(this._normalizers.has(e)){const n=this._normalizers.get(e),{path:o,value:r}=n(t);ja(i,o,r)}else ja(i,e,t)}getNormalized(e,t){if(!e)return Na({},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 fa(t,i);const n=i(e,t);if(n)return n}return fa(t,za(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.values())}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)}}function za(e){return e.replace("-",".")}function ja(e,t,i){let n=i;F(i)&&(n=Na({},fa(e,t),i)),Da(e,t,n)}class Fa extends zs{constructor(e,t,i,n){if(super(e),this._unsafeAttributesToRender=[],this._customProperties=new Map,this.name=t,this._attrs=function(e){const t=Mo(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");Ha(this._classes,e),this._attrs.delete("class")}this._styles=new La(this.document.stylesProcessor),this._attrs.has("style")&&(this._styles.setTo(this._attrs.get("style")),this._attrs.delete("style"))}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(e){if(!(e instanceof Fa))return!1;if(this===e)return!0;if(this.name!=e.name)return!1;if(this._attrs.size!==e._attrs.size||this._classes.size!==e._classes.size||this._styles.size!==e._styles.size)return!1;for(const[t,i]of this._attrs)if(!e._attrs.has(t)||e._attrs.get(t)!==i)return!1;for(const t of this._classes)if(!e._classes.has(t))return!1;for(const t of this._styles.getStyleNames())if(!e._styles.has(t)||e._styles.getAsString(t)!==this._styles.getAsString(t))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 Hs(...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 js(e,t)];ne(t)||(t=[t]);return Array.from(t).map((t=>"string"==typeof t?new js(e,t):t instanceof Fs?new js(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;i0&&(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 Eo(e))this._classes.add(t)}_removeClass(e){this._fireChange("attributes",this);for(const t of Eo(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 Eo(e))this._styles.remove(t)}_setCustomProperty(e,t){this._customProperties.set(e,t)}_removeCustomProperty(e){return this._customProperties.delete(e)}}function Ha(e,t){const i=t.split(/\s+/);e.clear(),i.forEach((t=>e.add(t)))}Fa.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 Ua extends Fa{constructor(e,t,i,n){super(e,t,i,n),this.getFillerOffset=Wa}}function Wa(){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}Ua.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 Za extends(G(Ua)){constructor(e,t,i,n){super(e,t,i,n),this.set("isReadOnly",!1),this.set("isFocused",!1),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}))}destroy(){this.stopListening()}}Za.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 $a=Symbol("rootName");class qa extends Za{constructor(e,t){super(e,t),this.rootName="main"}get rootName(){return this.getCustomProperty($a)}set rootName(e){this._setCustomProperty($a,e)}set _name(e){this.name=e}}qa.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};class Ga{constructor(e={}){if(!e.boundaries&&!e.startPosition)throw new y("view-tree-walker-no-start-position",null);if(e.direction&&"forward"!=e.direction&&"backward"!=e.direction)throw new y("view-tree-walker-unknown-direction",e.startPosition,{direction:e.direction});this.boundaries=e.boundaries||null,e.startPosition?this._position=Ka._createAt(e.startPosition):this._position=Ka._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}[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 js){if(e.isAtEnd)return this._position=Ka._createAfter(i),this._next();n=i.data[e.offset]}else n=i.getChild(e.offset);if(n instanceof Fa){if(this.shallow){if(this.boundaries&&this.boundaries.end.isBefore(e))return{done:!0,value:void 0};e.offset++}else e=new Ka(n,0);return this._position=e,this._formatReturnValue("elementStart",n,t,e,1)}if(n instanceof js){if(this.singleCharacters)return e=new Ka(n,0),this._position=e,this._next();let i,o=n.data.length;return n==this._boundaryEndParent?(o=this.boundaries.end.offset,i=new Fs(n,0,o),e=Ka._createAfter(i)):(i=new Fs(n,0,n.data.length),e.offset++),this._position=e,this._formatReturnValue("text",i,t,e,o)}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 o=new Fs(i,e.offset,n);return e.offset+=n,this._position=e,this._formatReturnValue("text",o,t,e,n)}return e=Ka._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 js){if(e.isAtStart)return this._position=Ka._createBefore(i),this._previous();n=i.data[e.offset-1]}else n=i.getChild(e.offset-1);if(n instanceof Fa)return this.shallow?(e.offset--,this._position=e,this._formatReturnValue("elementStart",n,t,e,1)):(e=new Ka(n,n.childCount),this._position=e,this.ignoreElementEnd?this._previous():this._formatReturnValue("elementEnd",n,t,e));if(n instanceof js){if(this.singleCharacters)return e=new Ka(n,n.data.length),this._position=e,this._previous();let i,o=n.data.length;if(n==this._boundaryStartParent){const t=this.boundaries.start.offset;i=new Fs(n,t,n.data.length-t),o=i.data.length,e=Ka._createBefore(i)}else i=new Fs(n,0,n.data.length),e.offset--;return this._position=e,this._formatReturnValue("text",i,t,e,o)}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 o=new Fs(i,e.offset,n);return this._position=e,this._formatReturnValue("text",o,t,e,n)}return e=Ka._createBefore(i),this._position=e,this._formatReturnValue("elementStart",i,t,e,1)}_formatReturnValue(e,t,i,n,o){return t instanceof Fs&&(t.offsetInText+t.data.length==t.textNode.data.length&&("forward"!=this.direction||this.boundaries&&this.boundaries.end.isEqual(this.position)?i=Ka._createAfter(t.textNode):(n=Ka._createAfter(t.textNode),this._position=n)),0===t.offsetInText&&("backward"!=this.direction||this.boundaries&&this.boundaries.start.isEqual(this.position)?i=Ka._createBefore(t.textNode):(n=Ka._createBefore(t.textNode),this._position=n))),{done:!1,value:{type:e,item:t,previousPosition:i,nextPosition:n,length:o}}}}class Ka extends Ls{constructor(e,t){super(),this.parent=e,this.offset=t}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 Za);){if(!e.parent)return null;e=e.parent}return e}getShiftedBy(e){const t=Ka._createAt(this),i=t.offset+e;return t.offset=i<0?0:i,t}getLastMatchingPosition(e,t={}){t.startPosition=this;const i=new Ga(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=ie(t,i);switch(n){case"prefix":return"before";case"extension":return"after";default:return t[n]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(Ka._createBefore(e),t)}}function Qa(e){return!(!e.item.is("attributeElement")&&!e.item.is("uiElement"))}Ya.prototype.is=function(e){return"range"===e||"view:range"===e};class Ja extends(R(Ls)){constructor(...e){super(),this._ranges=[],this._lastRangeBackward=!1,this._isFake=!1,this._fakeSelectionLabel="",e.length&&this.setTo(...e)}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=te(this.getRanges());if(t!=te(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(...e){let[t,i,n]=e;if("object"==typeof i&&(n=i,i=void 0),null===t)this._setRanges([]),this._setFakeOptions(n);else if(t instanceof Ja||t instanceof Xa)this._setRanges(t.getRanges(),t.isBackward),this._setFakeOptions({fake:t.isFake,label:t.fakeSelectionLabel});else if(t instanceof Ya)this._setRanges([t],n&&n.backward),this._setFakeOptions(n);else if(t instanceof Ka)this._setRanges([new Ya(t)]),this._setFakeOptions(n);else if(t instanceof zs){const e=!!n&&!!n.backward;let o;if(void 0===i)throw new y("view-selection-setto-required-second-parameter",this);o="in"==i?Ya._createIn(t):"on"==i?Ya._createOn(t):new Ya(Ka._createAt(t,i)),this._setRanges([o],e),this._setFakeOptions(n)}else{if(!ne(t))throw new y("view-selection-setto-not-selectable",this);this._setRanges(t,n&&n.backward),this._setFakeOptions(n)}this.fire("change")}setFocus(e,t){if(null===this.anchor)throw new y("view-selection-setfocus-no-ranges",this);const i=Ka._createAt(e,t);if("same"==i.compareWith(this.focus))return;const n=this.anchor;this._ranges.pop(),"before"==i.compareWith(n)?this._addRange(new Ya(i,n),!0):this._addRange(new Ya(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 Ya))throw new y("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 y("view-selection-range-intersects",this,{addedRange:e,intersectingRange:t});this._ranges.push(new Ya(e.start,e.end))}}Ja.prototype.is=function(e){return"selection"===e||"view:selection"===e};class Xa extends(R(Ls)){constructor(...e){super(),this._selection=new Ja,this._selection.delegate("change").to(this),e.length&&this._selection.setTo(...e)}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)}}Xa.prototype.is=function(e){return"selection"===e||"documentSelection"==e||"view:selection"==e||"view:documentSelection"==e};class el extends p{constructor(e,t,i){super(e,t),this.startRange=i,this._eventPhase="none",this._currentTarget=null}get eventPhase(){return this._eventPhase}get currentTarget(){return this._currentTarget}}const tl=Symbol("bubbling contexts");function il(e){return class extends e{fire(e,...t){try{const i=e instanceof p?e:new p(this,e),n=sl(this);if(!n.size)return;if(nl(i,"capturing",this),ol(n,"$capture",i,...t))return i.return;const o=i.startRange||this.selection.getFirstRange(),r=o?o.getContainedElement():null,s=!!r&&Boolean(rl(n,r));let a=r||function(e){if(!e)return null;const t=e.start.parent,i=e.end.parent,n=t.getPath(),o=i.getPath();return n.length>o.length?t:i}(o);if(nl(i,"atTarget",a),!s){if(ol(n,"$text",i,...t))return i.return;nl(i,"bubbling",a)}for(;a;){if(a.is("rootElement")){if(ol(n,"$root",i,...t))return i.return}else if(a.is("element")&&ol(n,a.name,i,...t))return i.return;if(ol(n,a,i,...t))return i.return;a=a.parent,nl(i,"bubbling",a)}return nl(i,"bubbling",this),ol(n,"$document",i,...t),i.return}catch(e){y.rethrowUnexpectedError(e,this)}}_addEventListener(e,t,i){const n=Eo(i.context||"$document"),o=sl(this);for(const r of n){let n=o.get(r);n||(n=new(R()),o.set(r,n)),this.listenTo(n,e,t,i)}}_removeEventListener(e,t){const i=sl(this);for(const n of i.values())this.stopListening(n,e,t)}}}{const e=il(Object);["fire","_addEventListener","_removeEventListener"].forEach((t=>{il[t]=e.prototype[t]}))}function nl(e,t,i){e instanceof el&&(e._eventPhase=t,e._currentTarget=i)}function ol(e,t,i,...n){const o="string"==typeof t?e.get(t):rl(e,t);return!!o&&(o.fire(i,...n),i.stop.called)}function rl(e,t){for(const[i,n]of e)if("function"==typeof i&&i(t))return n;return null}function sl(e){return e[tl]||(e[tl]=new Map),e[tl]}class al extends(il(G())){constructor(e){super(),this._postFixers=new Set,this.selection=new Xa,this.roots=new To({idProperty:"rootName"}),this.stylesProcessor=e,this.set("isReadOnly",!1),this.set("isFocused",!1),this.set("isSelecting",!1),this.set("isComposing",!1)}getRoot(e="main"){return this.roots.get(e)}registerPostFixer(e){this._postFixers.add(e)}destroy(){this.roots.map((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)}}class ll extends Fa{constructor(e,t,i,n){super(e,t,i,n),this._priority=10,this._id=null,this._clonesGroup=null,this.getFillerOffset=cl}get priority(){return this._priority}get id(){return this._id}getElementsWithSameId(){if(null===this.id)throw new y("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}}function cl(){if(dl(this))return null;let e=this.parent;for(;e&&e.is("attributeElement");){if(dl(e)>1)return null;e=e.parent}return!e||dl(e)>1?null:this.childCount}function dl(e){return Array.from(e.getChildren()).filter((e=>!e.is("uiElement"))).length}ll.DEFAULT_PRIORITY=10,ll.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 ul extends Fa{constructor(e,t,i,n){super(e,t,i,n),this.getFillerOffset=hl}_insertChild(e,t){if(t&&(t instanceof zs||Array.from(t).length>0))throw new y("view-emptyelement-cannot-add",[this,t]);return 0}}function hl(){return null}ul.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 ml extends Fa{constructor(e,t,i,n){super(e,t,i,n),this.getFillerOffset=gl}_insertChild(e,t){if(t&&(t instanceof zs||Array.from(t).length>0))throw new y("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}}function fl(e){e.document.on("arrowKey",((t,i)=>function(e,t,i){if(t.keyCode==bo.arrowright){const e=t.domTarget.ownerDocument.defaultView.getSelection(),n=1==e.rangeCount&&e.getRangeAt(0).collapsed;if(n||t.shiftKey){const t=e.focusNode,o=e.focusOffset,r=i.domPositionToView(t,o);if(null===r)return;let s=!1;const a=r.getLastMatchingPosition((e=>(e.item.is("uiElement")&&(s=!0),!(!e.item.is("uiElement")&&!e.item.is("attributeElement")))));if(s){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 gl(){return null}ml.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 pl extends Fa{constructor(e,t,i,n){super(e,t,i,n),this.getFillerOffset=bl}_insertChild(e,t){if(t&&(t instanceof zs||Array.from(t).length>0))throw new y("view-rawelement-cannot-add",[this,t]);return 0}render(e,t){}}function bl(){return null}pl.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};class wl extends(R(Ls)){constructor(e,t){super(),this._children=[],this._customProperties=new Map,this.document=e,t&&this._insertChild(0,t)}[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(){}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 js(e,t)];ne(t)||(t=[t]);return Array.from(t).map((t=>"string"==typeof t?new js(e,t):t instanceof Fs?new js(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{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,o=e;for(const{nodes:e,breakAttributes:t}of i){const i=this._insertNodes(o,e,t);n||(n=i.start),o=i.end}return n?new Ya(n,o):new Ya(e)}remove(e){const t=e instanceof Ya?e:Ya._createOn(e);if(Tl(t,this.document),t.isCollapsed)return new wl(this.document);const{start:i,end:n}=this._breakAttributesRange(t,!0),o=i.parent,r=n.offset-i.offset,s=o._removeChildren(i.offset,r);for(const e of s)this._removeFromClonedElementsGroup(e);const a=this.mergeAttributes(i);return t.start=a,t.end=a.clone(),new wl(this.document,s)}clear(e,t){Tl(e,this.document);const i=e.getWalker({direction:"backward",ignoreElementEnd:!0});for(const n of i){const i=n.item;let o;if(i.is("element")&&t.isSimilar(i))o=Ya._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&&(o=Ya._createIn(e))}o&&(o.end.isAfter(e.end)&&(o.end=e.end),o.start.isBefore(e.start)&&(o.start=e.start),this.remove(o))}}move(e,t){let i;if(t.isAfter(e.end)){const n=(t=this._breakAttributes(t,!0)).parent,o=n.childCount;e=this._breakAttributesRange(e,!0),i=this.remove(e),t.offset+=n.childCount-o}else i=this.remove(e);return this.insert(t,i)}wrap(e,t){if(!(t instanceof ll))throw new y("view-writer-wrap-invalid-attribute",this.document);if(Tl(e,this.document),e.isCollapsed){let n=e.start;n.parent.is("element")&&(i=n.parent,!Array.from(i.getChildren()).some((e=>!e.is("uiElement"))))&&(n=n.getLastMatchingPosition((e=>e.item.is("uiElement")))),n=this._wrapPosition(n,t);const o=this.document.selection;return o.isCollapsed&&o.getFirstPosition().isEqual(e.start)&&this.setSelection(n),new Ya(n)}return this._wrapRange(e,t);var i}unwrap(e,t){if(!(t instanceof ll))throw new y("view-writer-unwrap-invalid-attribute",this.document);if(Tl(e,this.document),e.isCollapsed)return e;const{start:i,end:n}=this._breakAttributesRange(e,!0),o=i.parent,r=this._unwrapChildren(o,i.offset,n.offset,t),s=this.mergeAttributes(r.start);s.isEqual(r.start)||r.end.offset--;const a=this.mergeAttributes(r.end);return new Ya(s,a)}rename(e,t){const i=new Ua(this.document,e,t.getAttributes());return this.insert(Ka._createAfter(t),i),this.move(Ya._createIn(t),Ka._createAt(i,0)),this.remove(Ya._createOn(t)),i}clearClonedElementsGroup(e){this._cloneGroups.delete(e)}createPositionAt(e,t){return Ka._createAt(e,t)}createPositionAfter(e){return Ka._createAfter(e)}createPositionBefore(e){return Ka._createBefore(e)}createRange(e,t){return new Ya(e,t)}createRangeOn(e){return Ya._createOn(e)}createRangeIn(e){return Ya._createIn(e)}createSelection(...e){return new Ja(...e)}createSlot(e="children"){if(!this._slotFactory)throw new y("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,o;if(n=i?_l(e):e.parent.is("$text")?e.parent.parent:e.parent,!n)throw new y("view-writer-invalid-position-container",this.document);o=i?this._breakAttributes(e,!0):e.parent.is("$text")?Al(e):e;const r=n._insertChild(o.offset,t);for(const e of t)this._addToClonedElementsGroup(e);const s=o.getShiftedBy(r),a=this.mergeAttributes(o);a.isEqual(o)||s.offset--;const l=this.mergeAttributes(s);return new Ya(a,l)}_wrapChildren(e,t,i,n){let o=t;const r=[];for(;o!1,e.parent._insertChild(e.offset,i);const n=new Ya(e,e.getShiftedBy(1));this.wrap(n,t);const o=new Ka(i.parent,i.index);i._remove();const r=o.nodeBefore,s=o.nodeAfter;return r instanceof js&&s instanceof js?xl(r,s):yl(o)}_wrapAttributeElement(e,t){if(!Pl(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(!Pl(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(Tl(e,this.document),e.isCollapsed){const i=this._breakAttributes(e.start,t);return new Ya(i,i)}const o=this._breakAttributes(n,t),r=o.parent.childCount,s=this._breakAttributes(i,t);return o.offset+=o.parent.childCount-r,new Ya(s,o)}_breakAttributes(e,t=!1){const i=e.offset,n=e.parent;if(e.parent.is("emptyElement"))throw new y("view-writer-cannot-break-empty-element",this.document);if(e.parent.is("uiElement"))throw new y("view-writer-cannot-break-ui-element",this.document);if(e.parent.is("rawElement"))throw new y("view-writer-cannot-break-raw-element",this.document);if(!t&&n.is("$text")&&Sl(n.parent))return e.clone();if(Sl(n))return e.clone();if(n.is("$text"))return this._breakAttributes(Al(e),t);if(i==n.childCount){const e=new Ka(n.parent,n.index+1);return this._breakAttributes(e,t)}if(0===i){const e=new Ka(n.parent,n.index);return this._breakAttributes(e,t)}{const e=n.index+1,o=n._clone();n.parent._insertChild(e,o),this._addToClonedElementsGroup(o);const r=n.childCount-i,s=n._removeChildren(i,r);o._appendChild(s);const a=new Ka(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)}}function _l(e){let t=e.parent;for(;!Sl(t);){if(!t)return;t=t.parent}return t}function vl(e,t){return e.priorityt.priority)&&e.getIdentity()i instanceof e)))throw new y("view-writer-insert-invalid-node-type",t);i.is("$text")||Cl(i.getChildren(),t)}}function Sl(e){return e&&(e.is("containerElement")||e.is("documentFragment"))}function Tl(e,t){const i=_l(e.start),n=_l(e.end);if(!i||!n||i!==n)throw new y("view-writer-invalid-range-container",t)}function Pl(e,t){return null===e.id&&null===t.id}const Il=e=>e.createTextNode(" "),Ol=e=>{const t=e.createElement("span");return t.dataset.ckeFiller="true",t.innerText=" ",t},Ml=e=>{const t=e.createElement("br");return t.dataset.ckeFiller="true",t},Rl=7,Nl="⁠".repeat(Rl);function Vl(e){return Bn(e)&&e.data.substr(0,Rl)===Nl}function Dl(e){return e.data.length==Rl&&Vl(e)}function Ll(e){return Vl(e)?e.data.slice(Rl):e.data}function Bl(e,t){if(t.keyCode==bo.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;Vl(t)&&i<=Rl&&e.collapse(t,0)}}}var zl=i(1237),jl={attributes:{"data-cke":!0}};jl.setAttributes=$o(),jl.insert=Wo().bind(null,"head"),jl.domAPI=Ho(),jl.insertStyleElement=Go();jo()(zl.Z,jl);zl.Z&&zl.Z.locals&&zl.Z.locals;class Fl extends(G()){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),c.isBlink&&!c.isAndroid&&this.on("change:isSelecting",(()=>{this.isSelecting||this.render()})),this.set("isComposing",!1),this.on("change:isComposing",(()=>{this.isComposing||this.render()}))}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 y("view-renderer-unknown-type",this)}this.markedChildren.add(t)}}}render(){if(this.isComposing&&!c.isAndroid)return;let e=null;const t=!(c.isBlink&&!c.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=Ka._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;Vl(t.parent)?this._inlineFiller=t.parent:this._inlineFiller=Hl(i,t.parent,t.offset)}else this._inlineFiller=null;this._updateFocus(),this._updateSelection(),this.markedTexts.clear(),this.markedAttributes.clear(),this.markedChildren.clear()}_updateChildrenMappings(e){if(!this.domConverter.mapViewToDom(e))return;const t=Array.from(this.domConverter.mapViewToDom(e).childNodes),i=Array.from(this.domConverter.viewChildrenToDom(e,{withChildren:!1})),n=this._diffNodeLists(t,i),o=this._findUpdateActions(n,t,i,Ul);if(-1!==o.indexOf("update")){const n={equal:0,insert:0,delete:0};for(const r of o)if("update"===r){const o=n.equal+n.insert,r=n.equal+n.delete,s=e.getChild(o);!s||s.is("uiElement")||s.is("rawElement")||this._updateElementMappings(s,t[r]),oo(i[o]),n.equal++}else n[r]++}}_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")?Ka._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&&Bn(t.parent)&&Vl(t.parent))}_removeInlineFiller(){const e=this._inlineFiller;if(!Vl(e))throw new y("view-renderer-filler-was-lost",this);Dl(e)?e.remove():e.data=e.data.substr(Rl),this._inlineFiller=null}_needsInlineFillerAtSelection(){if(1!=this.selection.rangeCount||!this.selection.isCollapsed)return!1;const e=this.selection.getFirstPosition(),t=e.parent,i=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;if(i===t.getFillerOffset())return!1;const n=e.nodeBefore,o=e.nodeAfter;return!(n instanceof js||o instanceof js)&&(!c.isAndroid||!n&&!o)}_updateText(e,t){const i=this.domConverter.findCorrespondingDomText(e);let n=this.domConverter.viewToDom(e).data;const o=t.inlineFillerPosition;o&&o.parent==e.parent&&o.offset==e.index&&(n=Nl+n),$l(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 i=this.domConverter.mapViewToDom(e);if(!i)return;if(c.isAndroid){let e=null;for(const t of Array.from(i.childNodes)){if(e&&Bn(e)&&Bn(t)){i.normalize();break}e=t}}const n=t.inlineFillerPosition,o=i.childNodes,r=Array.from(this.domConverter.viewChildrenToDom(e,{bind:!0}));n&&n.parent===e&&Hl(i.ownerDocument,r,n.offset);const s=this._diffNodeLists(o,r),a=this._findUpdateActions(s,o,r,Wl);let l=0;const d=new Set;for(const e of a)"delete"===e?(d.add(o[l]),oo(o[l])):"equal"!==e&&"update"!==e||l++;l=0;for(const e of a)"insert"===e?(Qn(i,l,r[l]),l++):"update"===e?($l(o[l],r[l].data),l++):"equal"===e&&(this._markDescendantTextToSync(this.domConverter.domToView(r[l])),l++);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),f(e,t,Zl.bind(null,this.domConverter))}_findUpdateActions(e,t,i,n){if(-1===e.indexOf("insert")||-1===e.indexOf("delete"))return e;let o=[],r=[],s=[];const a={equal:0,insert:0,delete:0};for(const l of e)"insert"===l?s.push(i[a.equal+a.insert]):"delete"===l?r.push(t[a.equal+a.delete]):(o=o.concat(f(r,s,n).map((e=>"equal"===e?"update":e))),o.push("equal"),r=[],s=[]),a[l]++;return o.concat(f(r,s,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(c.isBlink&&!c.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&&c.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(),o=t.createRange();n.removeAllRanges(),o.selectNodeContents(i),n.addRange(o)}_updateDomSelection(e){const t=e.ownerDocument.defaultView.getSelection();if(!this._domSelectionNeedsUpdate(t))return;const i=this.domConverter.viewPositionToDom(this.selection.anchor),n=this.domConverter.viewPositionToDom(this.selection.focus);t.collapse(i.parent,i.offset),t.extend(n.parent,n.offset),c.isGecko&&function(e,t){const i=e.parent;if(i.nodeType!=Node.ELEMENT_NODE||e.offset!=i.childNodes.length-1)return;const n=i.childNodes[e.offset];n&&"BR"==n.tagName&&t.addRange(t.getRangeAt(0))}(n,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)}}}function Hl(e,t,i){const n=t instanceof Array?t:t.childNodes,o=n[i];if(Bn(o))return o.data=Nl+o.data,o;{const o=e.createTextNode(Nl);return Array.isArray(t)?n.splice(i,0,o):Qn(t,i,o),o}}function Ul(e,t){return Pn(e)&&Pn(t)&&!Bn(e)&&!Bn(t)&&!Jn(e)&&!Jn(t)&&e.tagName.toLowerCase()===t.tagName.toLowerCase()}function Wl(e,t){return Pn(e)&&Pn(t)&&Bn(e)&&Bn(t)}function Zl(e,t,i){return t===i||(Bn(t)&&Bn(i)?t.data===i.data:!(!e.isBlockFiller(t)||!e.isBlockFiller(i)))}function $l(e,t){const i=e.data;if(i==t)return;const n=u(i,t);for(const t of n)"insert"===t.type?e.insertData(t.index,t.values.join("")):e.deleteData(t.index,t.howMany)}const ql=Ml(Dn.document),Gl=Il(Dn.document),Kl=Ol(Dn.document),Yl="data-ck-unsafe-attribute-",Ql="data-ck-unsafe-element";class Jl{constructor(e,{blockFillerMode:t,renderingMode:i="editing"}={}){this._domToViewMapping=new WeakMap,this._viewToDomMapping=new WeakMap,this._fakeSelectionMapping=new WeakMap,this._rawContentElementMatcher=new Hs,this._encounteredRawContentDomNodes=new WeakSet,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?Dn.document:Dn.document.implementation.createHTMLDocument("")}bindFakeSelection(e,t){this._fakeSelectionMapping.set(e,new Ja(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(),o=i.body.childNodes;for(;o.length>0;)n.appendChild(o[0]);const r=i.createTreeWalker(n,NodeFilter.SHOW_ELEMENT),s=[];let a;for(;a=r.nextNode();)s.push(a);for(const e of s){for(const t of e.getAttributeNames())this.setDomElementAttribute(e,t,e.getAttribute(t));const t=e.tagName.toLowerCase();this._shouldRenameElement(t)&&(tc(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)}{if(this.mapViewToDom(e))return this.mapViewToDom(e);let i;if(e.is("documentFragment"))i=this._domDocument.createDocumentFragment(),t.bind&&this.bindDocumentFragments(i,e);else{if(e.is("uiElement"))return i="$comment"===e.name?this._domDocument.createComment(e.getCustomProperty("$rawContent")):e.render(this._domDocument,this),t.bind&&this.bindElements(i,e),i;this._shouldRenameElement(e.name)?(tc(e.name),i=this._createReplacementDomElement(e.name)):i=e.hasAttribute("xmlns")?this._domDocument.createElementNS(e.getAttribute("xmlns"),e.name):this._domDocument.createElement(e.name),e.is("rawElement")&&e.render(i,this),t.bind&&this.bindElements(i,e);for(const t of e.getAttributeKeys())this.setDomElementAttribute(i,t,e.getAttribute(t),e)}if(!1!==t.withChildren)for(const n of this.viewChildrenToDom(e,t))i.appendChild(n);return i}}setDomElementAttribute(e,t,i,n){const o=this.shouldRenderAttribute(t,i,e.tagName.toLowerCase())||n&&n.shouldRenderUnsafeAttribute(t);o||A("domconverter-unsafe-attribute-detected",{domElement:e,key:t,value:i}),Xn(t)?(e.hasAttribute(t)&&!o?e.removeAttribute(t):e.hasAttribute(Yl+t)&&o&&e.removeAttribute(Yl+t),e.setAttribute(o?t:Yl+t,i)):A("domconverter-invalid-attribute-detected",{domElement:e,key:t,value:i})}removeDomElementAttribute(e,t){t!=Ql&&(e.removeAttribute(t),e.removeAttribute(Yl+t))}*viewChildrenToDom(e,t={}){const i=e.getFillerOffset&&e.getFillerOffset();let n=0;for(const o of e.getChildren()){i===n&&(yield this._getBlockFiller());const e=o.is("element")&&!!o.getCustomProperty("dataPipeline:transparentRendering")&&!Po(o.getAttributes());e&&"data"==this.renderingMode?yield*this.viewChildrenToDom(o,t):(e&&A("domconverter-transparent-rendering-unsupported-in-editing-pipeline",{viewElement:o}),yield this.viewToDom(o,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 Vl(i)&&(n+=Rl),{parent:i,offset:n}}{let i,n,o;if(0===e.offset){if(i=this.mapViewToDom(t),!i)return null;o=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,o=n.nextSibling}if(Bn(o)&&Vl(o))return{parent:o,offset:Rl};return{parent:i,offset:n?Yn(n)+1:0}}}domToView(e,t={}){if(this.isBlockFiller(e))return null;const i=this.getHostViewElement(e);if(i)return i;if(Jn(e)&&t.skipComments)return null;if(Bn(e)){if(Dl(e))return null;{const t=this._processDataFromDomText(e);return""===t?null:new js(this.document,t)}}{if(this.mapDomToView(e))return this.mapDomToView(e);let i;if(this.isDocumentFragment(e))i=new wl(this.document),t.bind&&this.bindDocumentFragments(e,i);else{i=this._createViewElement(e,t),t.bind&&this.bindElements(e,i);const n=e.attributes;if(n)for(let e=n.length,t=0;t{const{scrollLeft:t,scrollTop:i}=e;n.push([t,i])})),t.focus(),Xl(t,(e=>{const[t,i]=n.shift();e.scrollLeft=t,e.scrollTop=i})),Dn.window.scrollTo(e,i)}}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(ql):!("BR"!==e.tagName||!ec(e,this.blockElements)||1!==e.parentNode.childNodes.length)||(e.isEqualNode(Kl)||function(e,t){const i=e.isEqualNode(Gl);return i&&ec(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=Ln(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)}_getBlockFiller(){switch(this.blockFillerMode){case"nbsp":return Il(this._domDocument);case"markedNbsp":return Ol(this._domDocument);case"br":return Ml(this._domDocument)}}_isDomSelectionPositionCorrect(e,t){if(Bn(e)&&Vl(e)&&tthis.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)}_processDataFromDomText(e){let t=e.data;if(function(e,t){const i=Ln(e);return i.some((e=>e.tagName&&t.includes(e.tagName.toLowerCase())))}(e,this.preElements))return Ll(e);t=t.replace(/[ \n\t\r]{1,}/g," ");const i=this._getTouchingInlineDomNode(e,!1),n=this._getTouchingInlineDomNode(e,!0),o=this._checkShouldLeftTrimDomText(e,i),r=this._checkShouldRightTrimDomText(e,n);o&&(t=t.replace(/^ /,"")),r&&(t=t.replace(/ $/,"")),t=Ll(new Text(t)),t=t.replace(/ \u00A0/g," ");const s=n&&this.isElement(n)&&"BR"!=n.tagName,a=n&&Bn(n)&&" "==n.data.charAt(0);return(/( |\u00A0)\u00A0$/.test(t)||!n||s||a)&&(t=t.replace(/\u00A0$/," ")),(o||i&&this.isElement(i)&&"BR"!=i.tagName)&&(t=t.replace(/^\u00A0/," ")),t}_checkShouldLeftTrimDomText(e,t){return!t||(this.isElement(t)?"BR"===t.tagName:!this._encounteredRawContentDomNodes.has(e.previousSibling)&&/[^\S\u00A0]/.test(t.data.charAt(t.data.length-1)))}_checkShouldRightTrimDomText(e,t){return!t&&!Vl(e)}_getTouchingInlineViewNode(e,t){const i=new Ga({startPosition:t?Ka._createAfter(e):Ka._createBefore(e),direction:t?"forward":"backward"});for(const e of i){if(e.item.is("element")&&this.inlineObjectElements.includes(e.item.name))return e.item;if(e.item.is("containerElement"))return null;if(e.item.is("element","br"))return null;if(e.item.is("$textProxy"))return e.item}return null}_getTouchingInlineDomNode(e,t){if(!e.parentNode)return null;const i=t?"firstChild":"lastChild",n=t?"nextSibling":"previousSibling";let o=!0,r=e;do{if(!o&&r[i]?r=r[i]:r[n]?(r=r[n],o=!1):(r=r.parentNode,o=!0),!r||this._isBlockElement(r))return null}while(!Bn(r)&&"BR"!=r.tagName&&!this._isInlineObjectElement(r));return r}_isBlockElement(e){return this.isElement(e)&&this.blockElements.includes(e.tagName.toLowerCase())}_isInlineObjectElement(e){return this.isElement(e)&&this.inlineObjectElements.includes(e.tagName.toLowerCase())}_createViewElement(e,t){if(Jn(e))return new ml(this.document,"$comment");const i=t.keepOriginalCase?e.tagName:e.tagName.toLowerCase();return new Fa(this.document,i)}_isViewElementWithRawContent(e,t){return!1!==t.withChildren&&!!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(Ql,e),t){for(;t.firstChild;)i.appendChild(t.firstChild);for(const e of t.getAttributeNames())i.setAttribute(e,t.getAttribute(e))}return i}}function Xl(e,t){let i=e;for(;i;)t(i),i=i.parentElement}function ec(e,t){const i=e.parentNode;return!!i&&!!i.tagName&&t.includes(i.tagName.toLowerCase())}function tc(e){"script"===e&&A("domconverter-unsafe-script-element-detected"),"style"===e&&A("domconverter-unsafe-style-element-detected")}class ic extends(Mn()){constructor(e){super(),this._isEnabled=!1,this.view=e,this.document=e.document}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] *")}}const nc=Ra((function(e,t){Mt(t,gi(t),e)}));class oc{constructor(e,t,i){this.view=e,this.document=e.document,this.domEvent=t,this.domTarget=t.target,nc(this,i)}get target(){return this.view.domConverter.mapDomToView(this.domTarget)}preventDefault(){this.domEvent.preventDefault()}stopPropagation(){this.domEvent.stopPropagation()}}class rc extends ic{constructor(){super(...arguments),this.useCapture=!1}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 oc(this.view,t,i))}}class sc extends rc{constructor(){super(...arguments),this.domEventType=["keydown","keyup"]}onDomEvent(e){const t={keyCode:e.keyCode,altKey:e.altKey,ctrlKey:e.ctrlKey,shiftKey:e.shiftKey,metaKey:e.metaKey,get keystroke(){return ko(this)}};this.fire(e.type,e,t)}}class ac extends ic{constructor(e){super(e),this._fireSelectionChangeDoneDebounced=Xr((e=>{this.document.fire("selectionChangeDone",e)}),200)}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 Ja(t.getRanges(),{backward:t.isBackward,fake:!1});e!=bo.arrowleft&&e!=bo.arrowup||i.setTo(i.getFirstPosition()),e!=bo.arrowright&&e!=bo.arrowdown||i.setTo(i.getLastPosition());const n={oldSelection:t,newSelection:i,domSelection:null};this.document.fire("selectionChange",n),this._fireSelectionChangeDoneDebounced(n)}}const lc=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this};const cc=function(e){return this.__data__.has(e)};function dc(e){var t=-1,i=null==e?0:e.length;for(this.__data__=new At;++ta))return!1;var c=r.get(e),d=r.get(t);if(c&&d)return c==t&&d==e;var u=-1,h=!0,m=2&i?new uc:void 0;for(r.set(e,t),r.set(t,e);++u{this._isFocusChanging=!0,this._renderTimeoutId=setTimeout((()=>{this.flush(),e.change((()=>{}))}),50)})),t.on("blur",((i,n)=>{const o=t.selection.editableElement;null!==o&&o!==n.target||(t.isFocused=!1,this._isFocusChanging=!1,e.change((()=>{})))}))}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()}}class Mc extends ic{constructor(e){super(e),this.mutationObserver=e.getObserver(Pc),this.focusObserver=e.getObserver(Oc),this.selection=this.document.selection,this.domConverter=e.domConverter,this._documents=new WeakSet,this._fireSelectionChangeDoneDebounced=Xr((e=>{this.document.fire("selectionChangeDone",e)}),200),this._clearInfiniteLoopInterval=setInterval((()=>this._clearInfiniteLoop()),1e3),this._documentIsSelectingInactivityTimeoutDebounced=Xr((()=>this.document.isSelecting=!1),5e3),this._loopbackCounter=0}observe(e){const t=e.ownerDocument,i=()=>{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",i,{priority:"highest",useCapture:!0}),this.listenTo(e,"keyup",i,{priority:"highest",useCapture:!0}),this._documents.has(t)||(this.listenTo(t,"mouseup",i,{priority:"highest",useCapture:!0}),this.listenTo(t,"selectionchange",((e,i)=>{this.document.isComposing&&!c.isAndroid||(this._handleSelectionChange(i,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.selection.isEqual(n)||!this.domConverter.isDomSelectionCorrect(i))if(++this._loopbackCounter>60)this._reportInfiniteLoop();else if(this.focusObserver.flush(),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}}class Rc extends rc{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"})}onDomEvent(e){this.fire(e.type,e,{data:e.data})}}class Nc{constructor(e,t={}){this._files=t.cacheFiles?Vc(e):null,this._native=e}get files(){return this._files||(this._files=Vc(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}}function Vc(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 Dc extends rc{constructor(){super(...arguments),this.domEventType="beforeinput"}onDomEvent(e){const t=e.getTargetRanges(),i=this.view,n=i.document;let o=null,r=null,s=[];if(e.dataTransfer&&(o=new Nc(e.dataTransfer)),null!==e.data?r=e.data:o&&(r=o.getData("text/plain")),n.selection.isFake)s=Array.from(n.selection.getRanges());else if(t.length)s=t.map((e=>{const t=i.domConverter.domPositionToView(e.startContainer,e.startOffset),n=i.domConverter.domPositionToView(e.endContainer,e.endOffset);return t?i.createRange(t,n):n?i.createRange(n):void 0})).filter((e=>!!e));else if(c.isAndroid){const t=e.target.ownerDocument.defaultView.getSelection();s=Array.from(i.domConverter.domSelectionToView(t).getRanges())}if(c.isAndroid&&"insertCompositionText"==e.inputType&&r&&r.endsWith("\n"))this.fire(e.type,e,{inputType:"insertParagraph",targetRanges:[i.createRange(s[0].end)]});else if("insertText"==e.inputType&&r&&r.includes("\n")){const t=r.split(/\n{1,2}/g);let i=s;for(let r=0;r{if(this.isEnabled&&((i=t.keyCode)==bo.arrowright||i==bo.arrowleft||i==bo.arrowup||i==bo.arrowdown)){const i=new el(this.document,"arrowKey",this.document.selection.getFirstRange());this.document.fire(i,t),i.stop.called&&e.stop()}var i}))}observe(){}stopObserving(){}}class Bc extends ic{constructor(e){super(e);const t=this.document;t.on("keydown",((e,i)=>{if(!this.isEnabled||i.keyCode!=bo.tab||i.ctrlKey)return;const n=new el(t,"tab",t.selection.getFirstRange());t.fire(n,i),n.stop.called&&e.stop()}))}observe(){}stopObserving(){}}const zc=function(e){return An(e,5)};class jc extends(G()){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 al(e),this.domConverter=new Jl(this.document),this.set("isRenderingInProgress",!1),this.set("hasDomSelection",!1),this._renderer=new Fl(this.domConverter,this.document.selection),this._renderer.bind("isFocused","isSelecting","isComposing").to(this.document,"isFocused","isSelecting","isComposing"),this._writer=new kl(this.document),this.addObserver(Pc),this.addObserver(Oc),this.addObserver(Mc),this.addObserver(sc),this.addObserver(ac),this.addObserver(Rc),this.addObserver(Lc),this.addObserver(Dc),this.addObserver(Bc),this.document.on("arrowKey",Bl,{priority:"low"}),fl(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}))}attachDomRoot(e,t="main"){const i=this.document.getRoot(t);i._name=e.tagName.toLowerCase();const n={};for(const{name:t,value:o}of Array.from(e.attributes))n[t]=o,"class"===t?this._writer.addClass(o.split(" "),i):this._writer.setAttribute(t,o,i);this._initialDomRootAttributes.set(e,n);const o=()=>{this._writer.setAttribute("contenteditable",(!i.isReadOnly).toString(),i),i.isReadOnly?this._writer.addClass("ck-read-only",i):this._writer.removeClass("ck-read-only",i)};o(),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(o))),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 o=this.document.selection.getFirstRange();if(!o)return;const r=zc({alignToTop:e,forceScroll:t,viewportOffset:i,ancestorOffset:n});"number"==typeof i&&(i={top:i,bottom:i,left:i,right:i});const s={target:this.domConverter.viewRangeToDom(o),viewportOffset:i,ancestorOffset:n,alignToTop:e,forceScroll:t};this.fire("scrollToTheSelection",s,r),function({target:e,viewportOffset:t=0,ancestorOffset:i=0,alignToTop:n,forceScroll:o}){const r=ho(e);let s=r,a=null;for(t=function(e){return"number"==typeof e?{top:e,bottom:e,left:e,right:e}:e}(t);s;){let l;l=mo(s==r?e:a),so({parent:l,getRect:()=>fo(e,s),alignToTop:n,ancestorOffset:i,forceScroll:o});const c=fo(e,s);if(ro({window:s,rect:c,viewportOffset:t,alignToTop:n,forceScroll:o}),s.parent!=s){if(a=s.frameElement,s=s.parent,!a)return}else s=null}}(s)}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 y("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){y.rethrowUnexpectedError(e,this)}}forceRender(){this._hasChangedSinceTheLastRendering=!0,this.getObserver(Oc).flush(),this.change((()=>{}))}destroy(){for(const e of this._observers.values())e.destroy();this.document.destroy(),this.stopListening()}createPositionAt(e,t){return Ka._createAt(e,t)}createPositionAfter(e){return Ka._createAfter(e)}createPositionBefore(e){return Ka._createBefore(e)}createRange(e,t){return new Ya(e,t)}createRangeOn(e){return Ya._createOn(e)}createRangeIn(e){return Ya._createIn(e)}createSelection(...e){return new Ja(...e)}_disableRendering(e){this._renderingDisabled=e,0==e&&this.change((()=>{}))}_render(){this.isRenderingInProgress=!0,this.disableObservers(),this._renderer.render(),this.enableObservers(),this.isRenderingInProgress=!1}}class Fc{is(){throw new Error("is() method is abstract")}}class Hc extends Fc{constructor(e){super(),this.parent=null,this._attrs=Mo(e)}get document(){return null}get index(){let e;if(!this.parent)return null;if(null===(e=this.parent.getChildIndex(this)))throw new y("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 y("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 o=0;for(;i[o]==n[o]&&i[o];)o++;return 0===o?null:i[o-1]}isBefore(e){if(this==e)return!1;if(this.root!==e.root)return!1;const t=this.getPath(),i=e.getPath(),n=ie(t,i);switch(n){case"prefix":return!0;case"extension":return!1;default:return t[n](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=Mo(e)}_removeAttribute(e){return this._attrs.delete(e)}_clearAttributes(){this._attrs.clear()}}Hc.prototype.is=function(e){return"node"===e||"model:node"===e};class Uc{constructor(e){this._nodes=[],e&&this._insertNodes(0,e)}[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 y("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&&e1e4)return e.slice(0,i).concat(t).concat(e.slice(i+n,e.length));{const o=Array.from(e);return o.splice(i,n,...t),o}}(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()))}}class Wc extends Hc{constructor(e,t){super(t),this._data=e||""}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 Wc(this.data,this.getAttributes())}static fromJSON(e){return new Wc(e.data,e.attributes)}}Wc.prototype.is=function(e){return"$text"===e||"model:$text"===e||"text"===e||"model:text"===e||"node"===e||"model:node"===e};class Zc extends Fc{constructor(e,t,i){if(super(),this.textNode=e,t<0||t>e.offsetSize)throw new y("model-textproxy-wrong-offsetintext",this);if(i<0||t+i>e.offsetSize)throw new y("model-textproxy-wrong-length",this);this.data=e.data.substring(t,t+i),this.offsetInText=t}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()}}Zc.prototype.is=function(e){return"$textProxy"===e||"model:$textProxy"===e||"textProxy"===e||"model:textProxy"===e};class $c extends Hc{constructor(e,t,i){super(t),this._children=new Uc,this.name=e,i&&this._insertChild(0,i)}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 $c(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 Wc(e)];ne(e)||(e=[e]);return Array.from(e).map((e=>"string"==typeof e?new Wc(e):e instanceof Zc?new Wc(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($c.fromJSON(i)):t.push(Wc.fromJSON(i))}return new $c(e.name,e.attributes,t)}}$c.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 qc{constructor(e){if(!e||!e.boundaries&&!e.startPosition)throw new y("model-tree-walker-no-start-position",null);const t=e.direction||"forward";if("forward"!=t&&"backward"!=t)throw new y("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=Kc._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}[Symbol.iterator](){return this}get position(){return this._position}skip(e){let t,i,n,o;do{n=this.position,o=this._visitedParent,({done:t,value:i}=this.next())}while(!t&&e(i));t||(this._position=n,this._visitedParent=o)}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=Yc(t,i),o=n||Qc(t,i,n);if(o instanceof $c){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=o;return this._position=t,Gc("elementStart",o,e,t,1)}if(o instanceof Wc){let n;if(this.singleCharacters)n=1;else{let e=o.endOffset;this._boundaryEndParent==i&&this.boundaries.end.offsete&&(e=this.boundaries.start.offset),n=t.offset-e}const o=t.offset-r.startOffset,s=new Zc(r,o-n,n);return t.offset-=n,this._position=t,Gc("text",s,e,t,n)}return t.path.pop(),this._position=t,this._visitedParent=i.parent,Gc("elementStart",i,e,t,1)}}function Gc(e,t,i,n,o){return{done:!1,value:{type:e,item:t,previousPosition:i,nextPosition:n,length:o}}}class Kc extends Fc{constructor(e,t,i="toNone"){if(super(),!e.is("element")&&!e.is("documentFragment"))throw new y("model-position-root-invalid",e);if(!(t instanceof Array)||0===t.length)throw new y("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}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;t1)return!1;if(1===t)return Xc(e,this,i);if(-1===t)return Xc(this,e,i)}return this.path.length===e.path.length||(this.path.length>e.path.length?ed(this.path,t):ed(e.path,t))}hasSameParentAs(e){if(this.root!==e.root)return!1;return"same"==ie(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=Kc._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)?Kc._createAt(e.deletionPosition):this._getTransformedByMove(e.deletionPosition,e.graveyardPosition,1),i}_getTransformedByDeletion(e,t){const i=Kc._createAt(this);if(this.root!=e.root)return i;if("same"==ie(e.getParentPath(),this.getParentPath())){if(e.offsetthis.offset)return null;i.offset-=t}}else if("prefix"==ie(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=Kc._createAt(this);if(this.root!=e.root)return i;if("same"==ie(e.getParentPath(),this.getParentPath()))(e.offset=t;){if(e.path[n]+o!==i.maxOffset)return!1;o=1,n--,i=i.parent}return!0}(e,i+1))}function ed(e,t){for(;tt+1;){const t=n.maxOffset-i.offset;0!==t&&e.push(new td(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 td(i,i.getShiftedBy(n))),i.offset=t,i.path.push(0)}return e}getWalker(e={}){return e.boundaries=this,new qc(e)}*getItems(e={}){e.boundaries=this,e.ignoreElementEnd=!0;const t=new qc(e);for(const e of t)yield e.item}*getPositions(e={}){e.boundaries=this;const t=new qc(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 td(this.start,this.end)]}getTransformedByOperations(e){const t=[new td(this.start,this.end)];for(const i of e)for(let e=0;e0?new this(i,n):new this(n,i)}static _createIn(e){return new this(Kc._createAt(e,0),Kc._createAt(e,e.maxOffset))}static _createOn(e){return this._createFromPositionAndShift(Kc._createBefore(e),e.offsetSize)}static _createFromRanges(e){if(0===e.length)throw new y("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=Kc._createAt(e[t].start);for(let t=i+1;t{if(t.viewPosition)return;const i=this._modelToViewMapping.get(t.modelPosition.parent);if(!i)throw new y("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),o=this._toModelOffset(t.viewPosition.parent,t.viewPosition.offset,i);t.modelPosition=Kc._createAt(n,o)}),{priority:"low"})}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 td(this.toModelPosition(e.start),this.toModelPosition(e.end))}toViewRange(e){return new Ya(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;i1?t[0]+":"+t[1]:t[0]}class rd extends(R()){constructor(e){super(),this._conversionApi={dispatcher:this,...e},this._firedEventsMap=new WeakMap}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 o=this._reduceChanges(e.getChanges());for(const e of o)"insert"===e.type?this._convertInsert(td._createFromPositionAndShift(e.position,e.length),n):"reinsert"===e.type?this._convertReinsert(td._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);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.mapper.flushDeferredBindings(),n.consumable.verifyAllConsumed("insert")}convert(e,t,i,n={}){const o=this._createConversionApi(i,void 0,n);this._convertInsert(e,o);for(const[e,i]of t)this._convertMarkerAdd(e,i,o);o.consumable.verifyAllConsumed("insert")}convertSelection(e,t,i){const n=Array.from(t.getMarkersAtPosition(e.getFirstPosition())),o=this._createConversionApi(i);if(this._addConsumablesForSelection(o.consumable,e,n),this.fire("selection",{selection:e},o),e.isCollapsed){for(const t of n){const i=t.getRange();if(!sd(e.getFirstPosition(),t,o.mapper))continue;const n={item:e,markerName:t.name,markerRange:i};o.consumable.test(e,"addMarker:"+t.name)&&this.fire(`addMarker:${t.name}`,n,o)}for(const t of e.getAttributeKeys()){const i={item:e,range:e.getFirstRange(),attributeKey:t,attributeOldValue:null,attributeNewValue:e.getAttribute(t)};o.consumable.test(e,"attribute:"+i.attributeKey)&&this.fire(`attribute:${i.attributeKey}:$text`,i,o)}}}_convertInsert(e,t,i={}){i.doNotAddConsumables||this._addConsumablesForInsert(t.consumable,Array.from(e));for(const i of Array.from(e.getWalker({shallow:!0})).map(ad))this._testAndFire("insert",i,t)}_convertRemove(e,t,i,n){this.fire(`remove:${i}`,{position:e,length:t},n)}_convertAttribute(e,t,i,n,o){this._addConsumablesForRange(o.consumable,e,`attribute:${t}`);for(const r of e){const e={item:r.item,range:td._createFromPositionAndShift(r.previousPosition,r.length),attributeKey:t,attributeOldValue:i,attributeNewValue:n};this._testAndFire(`attribute:${t}`,e,o)}}_convertReinsert(e,t){const i=Array.from(e.getWalker({shallow:!0}));this._addConsumablesForInsert(t.consumable,i);for(const e of i.map(ad))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 o of t.getItems()){if(!i.consumable.test(o,n))continue;const r={item:o,range:td._createOn(o),markerName:e,markerRange:t};this.fire(n,r,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),o=t.item.is("$textProxy")?i.consumable._getSymbolForTextProxy(t.item):t.item,r=this._firedEventsMap.get(i),s=r.get(o);if(s){if(s.has(n))return;s.add(n)}else r.set(o,new Set([n]));this.fire(n,t,i)}_testAndFireAddAttributes(e,t){const i={item:e,range:td._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 nd,writer:e,options:i,convertItem:e=>this._convertInsert(td._createOn(e),n),convertChildren:e=>this._convertInsert(td._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}}function sd(e,t,i){const n=t.getRange(),o=Array.from(e.getAncestors());o.shift(),o.reverse();return!o.some((e=>{if(n.containsItem(e)){return!!i.toViewElement(e).getCustomProperty("addHighlight")}}))}function ad(e){return{item:e.item,range:td._createFromPositionAndShift(e.previousPosition,e.length)}}class ld extends(R(Fc)){constructor(...e){super(),this._lastRangeBackward=!1,this._attrs=new Map,this._ranges=[],e.length&&this.setTo(...e)}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 td(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 td(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 td(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 ld)this._setRanges(t.getRanges(),t.isBackward);else if(t&&"function"==typeof t.getRanges)this._setRanges(t.getRanges(),t.isBackward);else if(t instanceof td)this._setRanges([t],!!n&&!!n.backward);else if(t instanceof Kc)this._setRanges([new td(t)]);else if(t instanceof Hc){const e=!!n&&!!n.backward;let o;if("in"==i)o=td._createIn(t);else if("on"==i)o=td._createOn(t);else{if(void 0===i)throw new y("model-selection-setto-required-second-parameter",[this,t]);o=new td(Kc._createAt(t,i))}this._setRanges([o],e)}else{if(!ne(t))throw new y("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 td))throw new y("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 y("model-selection-setfocus-no-ranges",[this,e]);const i=Kc._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 td(i,n)),this._lastRangeBackward=!0):(this._pushRange(new td(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);md(i,t)&&(yield i);for(const i of t.getWalker()){const n=i.item;"elementEnd"==i.type&&dd(n,e,t)&&(yield n)}const n=ud(t.end,e);fd(n,t)&&(yield n)}}containsEntireContent(e=this.anchor.root){const t=Kc._createAt(e,0),i=Kc._createAt(e,"end");return t.isTouching(this.getFirstPosition())&&i.isTouching(this.getLastPosition())}_pushRange(e){this._checkRange(e),this._ranges.push(new td(e.start,e.end))}_checkRange(e){for(let t=0;t0;)this._popRange()}_popRange(){this._ranges.pop()}}function cd(e,t){return!t.has(e)&&(t.add(e),e.root.document.model.schema.isBlock(e)&&!!e.parent)}function dd(e,t,i){return cd(e,t)&&hd(e,i)}function ud(e,t){const i=e.parent.root.document.model.schema,n=e.parent.getAncestors({parentFirst:!0,includeSelf:!0});let o=!1;const r=n.find((e=>!o&&(o=i.isLimit(e),!o&&cd(e,t))));return n.forEach((e=>t.add(e))),r}function hd(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(td._createOn(i),!0)}function md(e,t){return!!e&&(!(!t.isCollapsed&&!e.isEmpty)||!t.start.isTouching(Kc._createAt(e,e.maxOffset))&&hd(e,t))}function fd(e,t){return!!e&&(!(!t.isCollapsed&&!e.isEmpty)||!t.end.isTouching(Kc._createAt(e,0))&&hd(e,t))}ld.prototype.is=function(e){return"selection"===e||"model:selection"===e};class gd extends(R(td)){constructor(e,t){super(e,t),pd.call(this)}detach(){this.stopListening()}toRange(){return new td(this.start,this.end)}static fromRange(e){return new gd(e.start,e.end)}}function pd(){this.listenTo(this.root.document.model,"applyOperation",((e,t)=>{const i=t[0];i.isDocumentOperation&&bd.call(this,i)}),{priority:"low"})}function bd(e){const t=this.getTransformedByOperation(e),i=td._createFromRanges(t),n=!i.isEqual(this),o=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 r=null;if(n){"$graveyard"==i.root.rootName&&(r="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:r})}else o&&this.fire("change:content",this.toRange(),{deletionPosition:r})}gd.prototype.is=function(e){return"liveRange"===e||"model:liveRange"===e||"range"==e||"model:range"===e};const wd="selection:";class kd extends(R(Fc)){constructor(e){super(),this._selection=new _d(e),this._selection.delegate("change:range").to(this),this._selection.delegate("change:attribute").to(this),this._selection.delegate("change:marker").to(this)}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 wd+e}static _isStoreAttributeKey(e){return e.startsWith(wd)}}kd.prototype.is=function(e){return"selection"===e||"model:selection"==e||"documentSelection"==e||"model:documentSelection"==e};class _d extends ld{constructor(e){super(),this.markers=new To({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(wd)));for(const n of t)e.removeAttribute(n,i)}))}}(this._model,t)}))}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{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 o=Array.from(this.markers),r=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&&!r?(this.markers.add(e),n=!0):!i&&r&&(this.markers.remove(e),n=!0)}else r&&(this.markers.remove(e),n=!0);n&&this.fire("change:marker",{oldMarkers:o,directChange:!1})}_updateAttributes(e){const t=Mo(this._getSurroundingAttributes()),i=Mo(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(wd)){const i=t.substr(10);yield[i,e.getAttribute(t)]}}_getSurroundingAttributes(){const e=this.getFirstPosition(),t=this._model.schema;let i=null;if(this.isCollapsed){const n=e.textNode?e.textNode:e.nodeBefore,o=e.textNode?e.textNode:e.nodeAfter;if(this.isGravityOverridden||(i=vd(n,t)),i||(i=vd(o,t)),!this.isGravityOverridden&&!i){let e=n;for(;e&&!i;)e=e.previousSibling,i=vd(e,t)}if(!i){let e=o;for(;e&&!i;)e=e.nextSibling,i=vd(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))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)}}function vd(e,t){if(!e)return null;if(e instanceof Zc||e instanceof Wc)return e.getAttributes();if(!t.isInline(e))return null;if(!t.isObject(e))return[];const i=[];for(const[n,o]of e.getAttributes())t.checkAttribute("$text",n)&&i.push([n,o]);return i}class yd{constructor(e){this._dispatchers=e}add(e){for(const t of this._dispatchers)e(t);return this}}class Ad extends yd{elementToElement(e){return this.add(function(e){const t=Cd(e.model),i=Sd(e.view,"container");t.attributes.length&&(t.children=!0);return n=>{n.on(`insert:${t.name}`,function(e,t=Vd){return(i,n,o)=>{if(!t(n.item,o.consumable,{preflight:!0}))return;const r=e(n.item,o,n);if(!r)return;t(n.item,o.consumable);const s=o.mapper.toViewPosition(n.range.start);o.mapper.bindElements(n.item,r),o.writer.insert(s,r),o.convertAttributes(n.item),Rd(r,n.item.getChildren(),o,{reconversion:n.reconversion})}}(i,Md(t)),{priority:e.converterPriority||"normal"}),(t.children||t.attributes.length)&&n.on("reduceChanges",Od(t),{priority:"low"})}}(e))}elementToStructure(e){return this.add(function(e){const t=Cd(e.model),i=Sd(e.view,"container");return t.children=!0,n=>{if(n._conversionApi.schema.checkChild(t.name,"$text"))throw new y("conversion-element-to-structure-disallowed-text",n,{elementName:t.name});var o,r;n.on(`insert:${t.name}`,(o=i,r=Md(t),(e,t,i)=>{if(!r(t.item,i.consumable,{preflight:!0}))return;const n=new Map;i.writer._registerSlotFactory(function(e,t,i){return(n,o)=>{const r=n.createContainerElement("$slot");let s=null;if("children"===o)s=Array.from(e.getChildren());else{if("function"!=typeof o)throw new y("conversion-slot-mode-unknown",i.dispatcher,{modeOrFilter:o});s=Array.from(e.getChildren()).filter((e=>o(e)))}return t.set(r,s),r}}(t.item,n,i));const s=o(t.item,i,t);if(i.writer._clearSlotFactory(),!s)return;!function(e,t,i){const n=Array.from(t.values()).flat(),o=new Set(n);if(o.size!=n.length)throw new y("conversion-slot-filter-overlap",i.dispatcher,{element:e});if(o.size!=e.childCount)throw new y("conversion-slot-filter-incomplete",i.dispatcher,{element:e})}(t.item,n,i),r(t.item,i.consumable);const a=i.mapper.toViewPosition(t.range.start);i.mapper.bindElements(t.item,s),i.writer.insert(a,s),i.convertAttributes(t.item),function(e,t,i,n){i.mapper.on("modelToViewPosition",s,{priority:"highest"});let o=null,r=null;for([o,r]of t)Rd(e,r,i,n),i.writer.move(i.writer.createRangeIn(o),i.writer.createPositionBefore(o)),i.writer.remove(o);function s(e,t){const i=t.modelPosition.nodeAfter,n=r.indexOf(i);n<0||(t.viewPosition=t.mapper.findPositionIn(o,n))}i.mapper.off("modelToViewPosition",s)}(s,n,i,{reconversion:t.reconversion})}),{priority:e.converterPriority||"normal"}),n.on("reduceChanges",Od(t),{priority:"low"})}}(e))}attributeToElement(e){return this.add(function(e){e=zc(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=Td(e);return t=>{t.on(i,function(e){return(t,i,n)=>{if(!n.consumable.test(i.item,t.name))return;const o=e(i.attributeOldValue,n,i),r=e(i.attributeNewValue,n,i);if(!o&&!r)return;n.consumable.consume(i.item,t.name);const s=n.writer,a=s.document.selection;if(i.item instanceof ld||i.item instanceof kd)s.wrap(a.getFirstRange(),r);else{let e=n.mapper.toViewRange(i.range);null!==i.attributeOldValue&&o&&(e=s.unwrap(e,o)),null!==i.attributeNewValue&&r&&s.wrap(e,r)}}}(n),{priority:e.converterPriority||"normal"})}}(e))}attributeToAttribute(e){return this.add(function(e){e=zc(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=Td(e);return t=>{var o;t.on(i,(o=n,(e,t,i)=>{if(!i.consumable.test(t.item,e.name))return;const n=o(t.attributeOldValue,i,t),r=o(t.attributeNewValue,i,t);if(!n&&!r)return;i.consumable.consume(t.item,e.name);const s=i.mapper.toViewElement(t.item),a=i.writer;if(!s)throw new y("conversion-attribute-to-attribute-on-text",i.dispatcher,t);if(null!==t.attributeOldValue&&n)if("class"==n.key){const e=Eo(n.value);for(const t of e)a.removeClass(t,s)}else if("style"==n.key){const e=Object.keys(n.value);for(const t of e)a.removeStyle(t,s)}else a.removeAttribute(n.key,s);if(null!==t.attributeNewValue&&r)if("class"==r.key){const e=Eo(r.value);for(const t of e)a.addClass(t,s)}else if("style"==r.key){const e=Object.keys(r.value);for(const t of e)a.setStyle(t,r.value[t],s)}else a.setAttribute(r.key,r.value,s)}),{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 o=n(t,i);t.isOpening=!1;const r=n(t,i);if(!o||!r)return;const s=t.markerRange;if(s.isCollapsed&&!i.consumable.consume(s,e.name))return;for(const t of s)if(!i.consumable.consume(t.item,e.name))return;const a=i.mapper,l=i.writer;l.insert(a.toViewPosition(s.start),o),i.mapper.bindElementToMarker(o,t.markerName),s.isCollapsed||(l.insert(a.toViewPosition(s.end),r),i.mapper.bindElementToMarker(r,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 ld||t.item instanceof kd||t.item.is("$textProxy")))return;const o=Id(i,t,n);if(!o)return;if(!n.consumable.consume(t.item,e.name))return;const r=n.writer,s=xd(r,o),a=r.document.selection;if(t.item instanceof ld||t.item instanceof kd)r.wrap(a.getFirstRange(),s);else{const e=n.mapper.toViewRange(t.range),i=r.wrap(e,s);for(const e of i.getItems())if(e.is("attributeElement")&&e.isSimilar(s)){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 $c))return;const o=Id(e,i,n);if(!o)return;if(!n.consumable.test(i.item,t.name))return;const r=n.mapper.toViewElement(i.item);if(r&&r.getCustomProperty("addHighlight")){n.consumable.consume(i.item,t.name);for(const e of td._createIn(i.item))n.consumable.consume(e.item,t.name);r.getCustomProperty("addHighlight")(r,o,n.writer),n.mapper.bindElementToMarker(r,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 o=Id(e,i,n);if(!o)return;const r=xd(n.writer,o),s=n.mapper.markerNameToElements(i.markerName);if(s){for(const e of s)if(n.mapper.unbindElementFromMarkerName(e,i.markerName),e.is("attributeElement"))n.writer.unwrap(n.writer.createRangeOn(e),r);else{e.getCustomProperty("removeHighlight")(e,o.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=zc(e);const t=e.model;let i=e.view;i||(i=i=>({group:t,name:i.substr(e.model.length+1)}));return n=>{var o;n.on(`addMarker:${t}`,(o=i,(e,t,i)=>{const n=o(t.markerName,i);if(!n)return;const r=t.markerRange;i.consumable.consume(r,e.name)&&(Ed(r,!1,i,t,n),Ed(r,!0,i,t,n),e.stop())}),{priority:e.converterPriority||"normal"}),n.on(`removeMarker:${t}`,function(e){return(t,i,n)=>{const o=e(i.markerName,n);if(!o)return;const r=n.mapper.markerNameToElements(i.markerName);if(r){for(const e of r)n.mapper.unbindElementFromMarkerName(e,i.markerName),e.is("containerElement")?(s(`data-${o.group}-start-before`,e),s(`data-${o.group}-start-after`,e),s(`data-${o.group}-end-before`,e),s(`data-${o.group}-end-after`,e)):n.writer.clear(n.writer.createRangeOn(e),e);n.writer.clearClonedElementsGroup(i.markerName),t.stop()}function s(e,t){if(t.hasAttribute(e)){const i=new Set(t.getAttribute(e).split(","));i.delete(o.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 xd(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,o){const r=t?e.start:e.end,s=r.nodeAfter&&r.nodeAfter.is("element")?r.nodeAfter:null,a=r.nodeBefore&&r.nodeBefore.is("element")?r.nodeBefore:null;if(s||a){let e,r;t&&s||!t&&!a?(e=s,r=!0):(e=a,r=!1);const l=i.mapper.toViewElement(e);if(l)return void function(e,t,i,n,o,r){const s=`data-${r.group}-${t?"start":"end"}-${i?"before":"after"}`,a=e.hasAttribute(s)?e.getAttribute(s).split(","):[];a.unshift(r.name),n.writer.setAttribute(s,a.join(","),e),n.mapper.bindElementToMarker(e,o.markerName)}(l,t,r,i,n,o)}!function(e,t,i,n,o){const r=`${o.group}-${t?"start":"end"}`,s=o.name?{name:o.name}:null,a=i.writer.createUIElement(r,s);i.writer.insert(e,a),i.mapper.bindElementToMarker(a,n.markerName)}(i.mapper.toViewPosition(r),t,i,n,o)}function Cd(e){return"string"==typeof e&&(e={name:e}),e.attributes?Array.isArray(e.attributes)||(e.attributes=[e.attributes]):e.attributes=[],e.children=!!e.children,e}function Sd(e,t){return"function"==typeof e?e:(i,n)=>function(e,t,i){"string"==typeof e&&(e={name:e});let n;const o=t.writer,r=Object.assign({},e.attributes);if("container"==i)n=o.createContainerElement(e.name,r);else if("attribute"==i){const t={priority:e.priority||ll.DEFAULT_PRIORITY};n=o.createAttributeElement(e.name,r,t)}else n=o.createUIElement(e.name,r);if(e.styles){const t=Object.keys(e.styles);for(const i of t)o.setStyle(i,e.styles[i],n)}if(e.classes){const t=e.classes;if("string"==typeof t)o.addClass(t,n);else for(const e of t)o.addClass(e,n)}return n}(e,n,t)}function Td(e){return e.model.values?(t,i,n)=>{const o=e.view[t];return o?o(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 Id(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 Od(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 o="attribute"==e.type?e.range.start.nodeAfter:e.position.parent;if(o&&t(o,e)){if(!i.reconvertedElements.has(o)){i.reconvertedElements.add(o);const e=Kc._createBefore(o);let t=n.length;for(let i=n.length-1;i>=0;i--){const o=n[i],r=("attribute"==o.type?o.range.start:o.position).compareWith(e);if("before"==r||"remove"==o.type&&"same"==r)break;t=i}n.splice(t,0,{type:"remove",name:o.name,position:e,length:1},{type:"reinsert",name:o.name,position:e,length:1})}}else n.push(e)}i.changes=n}}function Md(e){return(t,i,n={})=>{const o=["insert"];for(const i of e.attributes)t.hasAttribute(i)&&o.push(`attribute:${i}`);return!!o.every((e=>i.test(t,e)))&&(n.preflight||o.forEach((e=>i.consume(t,e))),!0)}}function Rd(e,t,i,n){for(const o of t)Nd(e.root,o,i,n)||i.convertItem(o)}function Nd(e,t,i,n){const{writer:o,mapper:r}=i;if(!n.reconversion)return!1;const s=r.toViewElement(t);return!(!s||s.root==e)&&(!!i.canReuseView(s)&&(o.move(o.createRangeOn(s),r.toViewPosition(Kc._createBefore(t))),!0))}function Vd(e,t,{preflight:i}={}){return i?t.test(e,"insert"):t.consume(e,"insert")}function Dd(e){const{schema:t,document:i}=e.model;for(const n of i.getRootNames()){const o=i.getRoot(n);if(o.isEmpty&&!t.checkChild(o,"$text")&&t.checkChild(o,"paragraph"))return e.insertElement("paragraph",o),!0}return!1}function Ld(e,t,i){const n=i.createContext(e);return!!i.checkChild(n,"paragraph")&&!!i.checkChild(n.push("paragraph"),t)}function Bd(e,t){const i=t.createElement("paragraph");return t.insert(i,e),t.createPositionAt(i,0)}class zd extends yd{elementToElement(e){return this.add(jd(e))}elementToAttribute(e){return this.add(function(e){e=zc(e),Ud(e);const t=Wd(e,!1),i=Fd(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=zc(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;let i;if("class"==t||"style"==t){i={["class"==t?"classes":"styles"]:e.view.value}}else{i={attributes:{[t]:void 0===e.view.value?/[\s\S]*/:e.view.value}}}e.view.name&&(i.name=e.view.name);return e.view=i,t}(e));Ud(e,t);const i=Wd(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 jd({...e,model:t})}(e))}dataToMarker(e){return this.add(function(e){e=zc(e),e.model||(e.model=t=>t?e.view+":"+t:e.view);const t={view:e.view,model:e.model},i=Hd(Zd(t,"start")),n=Hd(Zd(t,"end"));return o=>{o.on(`element:${e.view}-start`,i,{priority:e.converterPriority||"normal"}),o.on(`element:${e.view}-end`,n,{priority:e.converterPriority||"normal"});const r=k.low,s=k.highest,a=k.get(e.converterPriority)/s;o.on("element",function(e){return(t,i,n)=>{const o=`data-${e.view}`;function r(t,o){for(const r of o){const o=e.model(r,n),s=n.writer.createElement("$marker",{"data-name":o});n.writer.insert(s,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:o+"-end-after"})||n.consumable.test(i.viewItem,{attributes:o+"-start-after"})||n.consumable.test(i.viewItem,{attributes:o+"-end-before"})||n.consumable.test(i.viewItem,{attributes:o+"-start-before"}))&&(i.modelRange||Object.assign(i,n.convertChildren(i.viewItem,i.modelCursor)),n.consumable.consume(i.viewItem,{attributes:o+"-end-after"})&&r(i.modelRange.end,i.viewItem.getAttribute(o+"-end-after").split(",")),n.consumable.consume(i.viewItem,{attributes:o+"-start-after"})&&r(i.modelRange.end,i.viewItem.getAttribute(o+"-start-after").split(",")),n.consumable.consume(i.viewItem,{attributes:o+"-end-before"})&&r(i.modelRange.start,i.viewItem.getAttribute(o+"-end-before").split(",")),n.consumable.consume(i.viewItem,{attributes:o+"-start-before"})&&r(i.modelRange.start,i.viewItem.getAttribute(o+"-start-before").split(",")))}}(t),{priority:r+a})}}(e))}}function jd(e){const t=Hd(e=zc(e)),i=Fd(e.view),n=i?`element:${i}`:"element";return i=>{i.on(n,t,{priority:e.converterPriority||"normal"})}}function Fd(e){return"string"==typeof e?e:"object"==typeof e&&"string"==typeof e.name?e.name:null}function Hd(e){const t=new Hs(e.view);return(i,n,o)=>{const r=t.match(n.viewItem);if(!r)return;const s=r.match;if(s.name=!0,!o.consumable.test(n.viewItem,s))return;const a=function(e,t,i){return e instanceof Function?e(t,i):i.writer.createElement(e)}(e.model,n.viewItem,o);a&&o.safeInsert(a,n.modelCursor)&&(o.consumable.consume(n.viewItem,s),o.convertChildren(n.viewItem,a),o.updateConversionResult(a,n))}}function Ud(e,t=null){const i=null===t||(e=>e.getAttribute(t)),n="object"!=typeof e.model?e.model:e.model.key,o="object"!=typeof e.model||void 0===e.model.value?i:e.model.value;e.model={key:n,value:o}}function Wd(e,t){const i=new Hs(e.view);return(n,o,r)=>{if(!o.modelRange&&t)return;const s=i.match(o.viewItem);if(!s)return;if(!function(e,t){const i="function"==typeof e?e(t):e;if("object"==typeof i&&!Fd(i))return!1;return!i.classes&&!i.attributes&&!i.styles}(e.view,o.viewItem)?delete s.match.name:s.match.name=!0,!r.consumable.test(o.viewItem,s.match))return;const a=e.model.key,l="function"==typeof e.model.value?e.model.value(o.viewItem,r):e.model.value;if(null===l)return;o.modelRange||Object.assign(o,r.convertChildren(o.viewItem,o.modelCursor));const c=function(e,t,i,n){let o=!1;for(const r of Array.from(e.getItems({shallow:i})))n.schema.checkAttribute(r,t.key)&&(o=!0,r.hasAttribute(t.key)||n.writer.setAttribute(t.key,t.value,r));return o}(o.modelRange,{key:a,value:l},t,r);c&&(r.consumable.test(o.viewItem,{name:!0})&&(s.match.name=!0),r.consumable.consume(o.viewItem,s.match))}}function Zd(e,t){return{view:`${e.view}-${t}`,model:(t,i)=>{const n=t.getAttribute("name"),o=e.model(n,i);return i.writer.createElement("$marker",{"data-name":o})}}}function $d(e){e.document.registerPostFixer((t=>function(e,t){const i=t.document.selection,n=t.schema,o=[];let r=!1;for(const e of i.getRanges()){const t=qd(e,n);t&&!t.isEqual(e)?(o.push(t),r=!0):o.push(e)}r&&e.setSelection(function(e){const t=[...e],i=new Set;let n=1;for(;n!i.has(t)))}(o),{backward:i.isBackward});return!1}(t,e)))}function qd(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?td._createOn(e):null}if(!n.isCollapsed)return n;const o=n.start;if(i.isEqual(o))return null;return new td(o)}(e,t):function(e,t){const{start:i,end:n}=e,o=t.checkChild(i,"$text"),r=t.checkChild(n,"$text"),s=t.getLimitElement(i),a=t.getLimitElement(n);if(s===a){if(o&&r)return null;if(function(e,t,i){const n=e.nodeAfter&&!i.isLimit(e.nodeAfter)||i.checkChild(e,"$text"),o=t.nodeBefore&&!i.isLimit(t.nodeBefore)||i.checkChild(t,"$text");return n||o}(i,n,t)){const e=i.nodeAfter&&t.isSelectable(i.nodeAfter)?null:t.getNearestSelectionRange(i,"forward"),o=n.nodeBefore&&t.isSelectable(n.nodeBefore)?null:t.getNearestSelectionRange(n,"backward"),r=e?e.start:i,s=o?o.end:n;return new td(r,s)}}const l=s&&!s.is("rootElement"),c=a&&!a.is("rootElement");if(l||c){const e=i.nodeAfter&&n.nodeBefore&&i.nodeAfter.parent===n.nodeBefore.parent,o=l&&(!e||!Kd(i.nodeAfter,t)),r=c&&(!e||!Kd(n.nodeBefore,t));let d=i,u=n;return o&&(d=Kc._createBefore(Gd(s,t))),r&&(u=Kc._createAfter(Gd(a,t))),new td(d,u)}return null}(e,t)}function Gd(e,t){let i=e,n=i;for(;t.isLimit(n)&&n.parent;)i=n,n=n.parent;return i}function Kd(e,t){return e&&t.isSelectable(e)}class Yd extends(G()){constructor(e,t){super(),this.model=e,this.view=new jc(t),this.mapper=new id,this.downcastDispatcher=new rd({mapper:this.mapper,schema:e.schema});const i=this.model.document,n=i.selection,o=this.model.markers;var r,s,a;this.listenTo(this.model,"_beforeChanges",(()=>{this.view._disableRendering(!0)}),{priority:"highest"}),this.listenTo(this.model,"_afterChanges",(()=>{this.view._disableRendering(!1)}),{priority:"lowest"}),this.listenTo(i,"change",(()=>{this.view.change((e=>{this.downcastDispatcher.convertChanges(i.differ,o,e),this.downcastDispatcher.convertSelection(n,o,e)}))}),{priority:"low"}),this.listenTo(this.view.document,"selectionChange",function(e,t){return(i,n)=>{const o=n.newSelection,r=[];for(const e of o.getRanges())r.push(t.toModelRange(e));const s=e.createSelection(r,{backward:o.isBackward});s.isEqual(e.document.selection)||e.change((e=>{e.setSelection(s)}))}}(this.model,this.mapper)),this.listenTo(this.view.document,"beforeinput",(r=this.mapper,s=this.model.schema,a=this.view,(e,t)=>{if(!a.document.isComposing||c.isAndroid)for(let e=0;e{if(!i.consumable.consume(t.item,e.name))return;const n=i.writer,o=i.mapper.toViewPosition(t.range.start),r=n.createText(t.item.data);n.insert(o,r)}),{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),o=t.position.getShiftedBy(t.length),r=i.mapper.toViewPosition(o,{isPhantom:!0}),s=i.writer.createRange(n,r),a=i.writer.remove(s.getTrimmed());for(const e of i.writer.createRangeIn(a).getItems())i.mapper.unbindViewElement(e,{defer:!0})}),{priority:"low"}),this.downcastDispatcher.on("selection",((e,t,i)=>{const n=i.writer,o=n.document.selection;for(const e of o.getRanges())e.isCollapsed&&e.end.parent.isAttached()&&i.writer.mergeAttributes(e.start);n.setSelection(null)}),{priority:"high"}),this.downcastDispatcher.on("selection",((e,t,i)=>{const n=t.selection;if(n.isCollapsed)return;if(!i.consumable.consume(n,"selection"))return;const o=[];for(const e of n.getRanges())o.push(i.mapper.toViewRange(e));i.writer.setSelection(o,{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 o=i.writer,r=n.getFirstPosition(),s=i.mapper.toViewPosition(r),a=o.breakAttributes(s);o.setSelection(a)}),{priority:"low"}),this.view.document.roots.bindTo(this.model.document.roots).using((e=>{if("$graveyard"==e.rootName)return null;const t=new qa(this.view.document,e.name);return t.rootName=e.rootName,this.mapper.bindElements(e,t),t}))}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 y("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)}))}}class Qd{constructor(){this._consumables=new Map}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 Xd(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 o=e.getStyleNames();for(const e of o)t.styles.push(e);return t}static createFrom(e,t){if(t||(t=new Qd),e.is("$text"))return t.add(e),t;e.is("element")&&t.add(e,Qd.consumablesFromElement(e)),e.is("documentFragment")&&t.add(e);for(const i of e.getChildren())t=Qd.createFrom(i,t);return t}}const Jd=["attributes","classes","styles"];class Xd{constructor(e){this.element=e,this._canConsumeName=null,this._consumables={attributes:new Map,styles:new Map,classes:new Map}}add(e){e.name&&(this._canConsumeName=!0);for(const t of Jd)t in e&&this._add(t,e[t])}test(e){if(e.name&&!this._canConsumeName)return this._canConsumeName;for(const t of Jd)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 Jd)t in e&&this._consume(t,e[t])}revert(e){e.name&&(this._canConsumeName=!0);for(const t of Jd)t in e&&this._revert(t,e[t])}_add(e,t){const i=be(t)?t:[t],n=this._consumables[e];for(const t of i){if("attributes"===e&&("class"===t||"style"===t))throw new y("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=be(t)?t:[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=be(t)?t:[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=be(t)?t:[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()])}}}class eu extends(G()){constructor(){super(),this._sourceDefinitions={},this._attributeProperties={},this.decorate("checkChild"),this.decorate("checkAttribute"),this.on("checkAttribute",((e,t)=>{t[0]=new tu(t[0])}),{priority:"highest"}),this.on("checkChild",((e,t)=>{t[0]=new tu(t[0]),t[1]=this.getDefinition(t[1])}),{priority:"highest"})}register(e,t){if(this._sourceDefinitions[e])throw new y("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 y("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 Kc){const t=e.nodeBefore,i=e.nodeAfter;if(!(t instanceof $c))throw new y("schema-check-merge-no-element-before",this);if(!(i instanceof $c))throw new y("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 o=e(i,n);"boolean"==typeof o&&(t.stop(),t.return=o)}),{priority:"high"})}addAttributeCheck(e){this.on("checkAttribute",((t,[i,n])=>{const o=e(i,n);"boolean"==typeof o&&(t.stop(),t.return=o)}),{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 Kc)t=e.parent;else{t=(e instanceof td?[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 Wc("",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(this.checkChild(e,"$text"))return new td(e);let i,n;const o=e.getAncestors().reverse().find((e=>this.isLimit(e)))||e.root;"both"!=t&&"backward"!=t||(i=new qc({boundaries:td._createIn(o),startPosition:e,direction:"backward"})),"both"!=t&&"forward"!=t||(n=new qc({boundaries:td._createIn(o),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 td._createOn(n.item);if(this.checkChild(n.nextPosition,"$text"))return new td(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[o,r]of Object.entries(t))n.schema.checkAttribute(e,o)&&i.setAttribute(o,r,e)}removeDisallowedAttributes(e,t){for(const i of e)if(i.is("$text"))fu(this,i,t);else{const e=td._createIn(i).getPositions();for(const i of e){fu(this,i.nodeBefore||i.parent,t)}}}getAttributesWithProperty(e,t,i){const n={};for(const[o,r]of e.getAttributes()){const e=this.getAttributeProperties(o);void 0!==e[t]&&(void 0!==i&&i!==e[t]||(n[o]=r))}return n}createContext(e){return new tu(e)}_clearCache(){this._compiledDefinitions=null}_compile(){const e={},t=this._sourceDefinitions,i=Object.keys(t);for(const n of i)e[n]=iu(t[n],n);for(const t of i)nu(e,t);for(const t of i)ou(e,t);for(const t of i)ru(e,t);for(const t of i)su(e,t),au(e,t);for(const t of i)lu(e,t),cu(e,t),du(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 o of e.getItems({shallow:!0}))o.is("element")&&(yield*this._getValidRangesForRange(td._createIn(o),t)),this.checkAttribute(o,t)||(i.isEqual(n)||(yield new td(i,n)),i=Kc._createAfter(o)),n=Kc._createAfter(o);i.isEqual(n)||(yield new td(i,n))}}class tu{constructor(e){if(e instanceof tu)return e;let t;t="string"==typeof e?[e]:Array.isArray(e)?e:e.getAncestors({includeSelf:!0}),this._items=t.map(mu)}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 tu([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)}}function iu(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),uu(e,i,"allowIn"),uu(e,i,"allowContentOf"),uu(e,i,"allowWhere"),uu(e,i,"allowAttributes"),uu(e,i,"allowAttributesOf"),uu(e,i,"allowChildren"),uu(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 nu(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 ou(e,t){for(const i of e[t].allowContentOf)if(e[i]){hu(e,i).forEach((e=>{e.allowIn.push(t)}))}delete e[t].allowContentOf}function ru(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 su(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 au(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 lu(e,t){const i=e[t],n=i.allowIn.filter((t=>e[t]));i.allowIn=Array.from(new Set(n))}function cu(e,t){const i=e[t];for(const n of i.allowIn){e[n].allowChildren.push(t)}}function du(e,t){const i=e[t];i.allowAttributes=Array.from(new Set(i.allowAttributes))}function uu(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 hu(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 mu(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 fu(e,t,i){for(const n of t.getAttributeKeys())e.checkAttribute(t,n)||i.removeAttribute(n,t)}class gu extends(R()){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)}}convert(e,t,i=["$root"]){this.fire("viewCleanup",e),this._modelCursor=function(e,t){let i;for(const n of new tu(e)){const e={};for(const t of n.getAttributeKeys())e[t]=n.getAttribute(t);const o=t.createElement(n.name,e);i&&t.insert(o,i),i=Kc._createAt(o,0)}return i}(i,t),this.conversionApi.writer=t,this.conversionApi.consumable=Qd.createFrom(e),this.conversionApi.store={};const{modelRange:n}=this._convertItem(e,this._modelCursor),o=t.createDocumentFragment();if(n){this._removeEmptyElements();for(const e of Array.from(this._modelCursor.parent.getChildren()))t.append(e,o);o.markers=function(e,t){const i=new Set,n=new Map,o=td._createIn(e).getItems();for(const e of o)e.is("element","$marker")&&i.add(e);for(const e of i){const i=e.getAttribute("data-name"),o=t.createPositionBefore(e);n.has(i)?n.get(i).end=o.clone():n.set(i,new td(o.clone())),t.remove(e)}return n}(o,t)}return this._modelCursor=null,this._splitParts.clear(),this._cursorParents.clear(),this._emptyElementsToKeep.clear(),this.conversionApi.writer=null,this.conversionApi.store=null,o}_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 td))throw new y("view-conversion-dispatcher-incorrect-result",this);return{modelRange:i.modelRange,modelCursor:i.modelCursor}}_convertChildren(e,t){let i=t.is("position")?t:Kc._createAt(t,0);const n=new td(i);for(const t of Array.from(e.getChildren())){const e=this._convertItem(t,i);e.modelRange instanceof td&&(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 o=this._cursorParents.get(e);t.modelCursor=o?n.createPositionAt(o,0):t.modelRange.end}_splitToAllowedParent(e,t){const{schema:i,writer:n}=this.conversionApi;let o=i.findAllowedParent(t,e);if(o){if(o===t.parent)return{position:t};this._modelCursor.parent.getAncestors().includes(o)&&(o=null)}if(!o)return Ld(t,e,i)?{position:Bd(t,n)}:null;const r=this.conversionApi.writer.split(t,o),s=[];for(const e of r.range.getWalker())if("elementEnd"==e.type)s.push(e.item);else{const t=s.pop(),i=e.item;this._registerSplitPair(t,i)}const a=r.range.end.parent;return this._cursorParents.set(e,a),{position:r.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()}}class pu{getHtml(e){const t=document.implementation.createHTMLDocument("").createElement("div");return t.appendChild(e),t.innerHTML}}class bu{constructor(e){this.skipComments=!0,this.domParser=new DOMParser,this.domConverter=new Jl(e,{renderingMode:"data"}),this.htmlWriter=new pu}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=`${e}`);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}}class wu extends(R()){constructor(e,t){super(),this.model=e,this.mapper=new id,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,o=i.mapper.toViewPosition(t.range.start),r=n.createText(t.item.data);n.insert(o,r)}),{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 gu({schema:e.schema}),this.viewDocument=new al(t),this.stylesProcessor=t,this.htmlProcessor=new bu(this.viewDocument),this.processor=this.htmlProcessor,this._viewWriter=new kl(this.viewDocument),this.upcastDispatcher.on("text",((e,t,{schema:i,consumable:n,writer:o})=>{let r=t.modelCursor;if(!n.test(t.viewItem))return;if(!i.checkChild(r,"$text")){if(!Ld(r,"$text",i))return;if(0==t.viewItem.data.trim().length)return;const e=r.nodeBefore;r=Bd(r,o),e&&e.is("element","$marker")&&(o.move(o.createRangeOn(e),r),r=o.createPositionAfter(e))}n.consume(t.viewItem);const s=o.createText(t.viewItem.data);o.insert(s,r),t.modelRange=o.createRange(r,r.getShiftedBy(s.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"}),G().prototype.decorate.call(this,"init"),G().prototype.decorate.call(this,"set"),G().prototype.decorate.call(this,"get"),G().prototype.decorate.call(this,"toView"),G().prototype.decorate.call(this,"toModel"),this.on("init",(()=>{this.fire("ready")}),{priority:"lowest"}),this.on("ready",(()=>{this.model.enqueueChange({isUndoable:!1},Dd)}),{priority:"lowest"})}get(e={}){const{rootName:t="main",trim:i="empty"}=e;if(!this._checkIfRootsExists([t]))throw new y("datacontroller-get-non-existent-root",this);const n=this.model.document.getRoot(t);return n.isAttached()||A("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 o=td._createIn(e),r=new wl(i);this.mapper.bindElements(e,r);const s=e.is("documentFragment")?e.markers:function(e){const t=[],i=e.root.document;if(!i)return new Map;const n=td._createIn(e);for(const e of i.model.markers){const i=e.getRange(),o=i.isCollapsed,r=i.start.isEqual(n.start)||i.end.isEqual(n.end);if(o&&r)t.push([e.name,i]);else{const o=n.getIntersection(i);o&&t.push([e.name,o])}}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(o,s,n,t),r}init(e){if(this.model.document.version)throw new y("datacontroller-init-document-not-empty",this);let t={};if("string"==typeof e?t.main=e:t=e,!this._checkIfRootsExists(Object.keys(t)))throw new y("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 y("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}}class ku{constructor(e,t){this._helpers=new Map,this._downcast=Eo(e),this._createConversionHelpers({name:"downcast",dispatchers:this._downcast,isDowncast:!0}),this._upcast=Eo(t),this._createConversionHelpers({name:"upcast",dispatchers:this._upcast,isDowncast:!1})}addAlias(e,t){const i=this._downcast.includes(t);if(!this._upcast.includes(t)&&!i)throw new y("conversion-add-alias-dispatcher-not-registered",this);this._createConversionHelpers({name:e,dispatchers:[t],isDowncast:i})}for(e){if(!this._helpers.has(e))throw new y("conversion-for-unknown-group",this);return this._helpers.get(e)}elementToElement(e){this.for("downcast").elementToElement(e);for(const{model:t,view:i}of _u(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 _u(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 _u(e))this.for("upcast").attributeToAttribute({view:i,model:t})}_createConversionHelpers({name:e,dispatchers:t,isDowncast:i}){if(this._helpers.has(e))throw new y("conversion-group-exists",this);const n=i?new Ad(t):new zd(t);this._helpers.set(e,n)}}function*_u(e){if(e.model.values)for(const t of e.model.values){const i={key:e.model.key,value:t},n=e.view[t],o=e.upcastAlso?e.upcastAlso[t]:void 0;yield*vu(i,n,o)}else yield*vu(e.model,e.view,e.upcastAlso)}function*vu(e,t,i){if(yield{model:e,view:t},i)for(const t of Eo(i))yield{model:e,view:t}}class yu{constructor(e){this.baseVersion=e,this.isDocumentOperation=null!==this.baseVersion,this.batch=null}_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)}}function Au(e,t){const i=Cu(t),n=i.reduce(((e,t)=>e+t.offsetSize),0),o=e.parent;Tu(e);const r=e.index;return o._insertChild(r,i),Su(o,r+i.length),Su(o,r),new td(e,e.getShiftedBy(n))}function xu(e){if(!e.isFlat)throw new y("operation-utils-remove-range-not-flat",this);const t=e.start.parent;Tu(e.start),Tu(e.end);const i=t._removeChildren(e.start.index,e.end.index-e.start.index);return Su(t,e.start.index),i}function Eu(e,t){if(!e.isFlat)throw new y("operation-utils-move-range-not-flat",this);const i=xu(e);return Au(t=t._getTransformedByDeletion(e.start,e.end.offset-e.start.offset),i)}function Cu(e){const t=[];!function e(i){if("string"==typeof i)t.push(new Wc(i));else if(i instanceof Zc)t.push(new Wc(i.data,i.getAttributes()));else if(i instanceof Hc)t.push(i);else if(ne(i))for(const t of i)e(t)}(e);for(let e=1;ee.maxOffset)throw new y("move-operation-nodes-do-not-exist",this);if(e===t&&i=i&&this.targetPosition.path[e]e._clone(!0)))),t=new Ou(this.position,e,this.baseVersion);return t.shouldReceiveAttributes=this.shouldReceiveAttributes,t}getReversed(){const e=this.position.root.document.graveyard,t=new Kc(e,[0]);return new Iu(this.position,this.nodes.maxOffset,t,this.baseVersion+1)}_validate(){const e=this.position.parent;if(!e||e.maxOffsete._clone(!0)))),Au(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($c.fromJSON(t)):i.push(Wc.fromJSON(t));const n=new Ou(Kc.fromJSON(e.position,t),i,e.baseVersion);return n.shouldReceiveAttributes=e.shouldReceiveAttributes,n}}class Mu extends yu{constructor(e,t,i,n,o){super(o),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")}get type(){return"split"}get moveTargetPosition(){const e=this.insertionPosition.path.slice();return e.push(0),new Kc(this.insertionPosition.root,e)}get movedRange(){const e=this.splitPosition.getShiftedBy(Number.POSITIVE_INFINITY);return new td(this.splitPosition,e)}get affectedSelectable(){const e=[td._createFromPositionAndShift(this.splitPosition,0),td._createFromPositionAndShift(this.insertionPosition,0)];return this.graveyardPosition&&e.push(td._createFromPositionAndShift(this.graveyardPosition,0)),e}clone(){return new Mu(this.splitPosition,this.howMany,this.insertionPosition,this.graveyardPosition,this.baseVersion)}getReversed(){const e=this.splitPosition.root.document.graveyard,t=new Kc(e,[0]);return new Ru(this.moveTargetPosition,this.howMany,this.splitPosition,t,this.baseVersion+1)}_validate(){const e=this.splitPosition.parent,t=this.splitPosition.offset;if(!e||e.maxOffset{if(e.key===t.key&&e.range.start.hasSameParentAs(t.range.start)){const n=e.range.getDifference(t.range).map((t=>new Du(t,e.key,e.oldValue,e.newValue,0))),o=e.range.getIntersection(t.range);return o&&i.aIsStrong&&n.push(new Du(o,t.key,t.newValue,e.newValue,0)),0==n.length?[new Lu(0)]:n}return[e]})),Wu(Du,Ou,((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 Du(t,e.key,e.oldValue,e.newValue,e.baseVersion)));if(t.shouldReceiveAttributes){const n=Qu(t,e.key,e.oldValue);n&&i.unshift(n)}return i}return e.range=e.range._getTransformedByInsertion(t.position,t.howMany,!1)[0],[e]})),Wu(Du,Ru,((e,t)=>{const i=[];e.range.start.hasSameParentAs(t.deletionPosition)&&(e.range.containsPosition(t.deletionPosition)||e.range.start.isEqual(t.deletionPosition))&&i.push(td._createFromPositionAndShift(t.graveyardPosition,1));const n=e.range._getTransformedByMergeOperation(t);return n.isCollapsed||i.push(n),i.map((t=>new Du(t,e.key,e.oldValue,e.newValue,e.baseVersion)))})),Wu(Du,Iu,((e,t)=>{const i=function(e,t){const i=td._createFromPositionAndShift(t.sourcePosition,t.howMany);let n=null,o=[];i.containsRange(e,!0)?n=e:e.start.hasSameParentAs(i.start)?(o=e.getDifference(i),n=e.getIntersection(i)):o=[e];const r=[];for(let e of o){e=e._getTransformedByDeletion(t.sourcePosition,t.howMany);const i=t.getMovedRangeStart(),n=e.start.hasSameParentAs(i),o=e._getTransformedByInsertion(i,t.howMany,n);r.push(...o)}n&&r.push(n._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany,!1)[0]);return r}(e.range,t);return i.map((t=>new Du(t,e.key,e.oldValue,e.newValue,e.baseVersion)))})),Wu(Du,Mu,((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 td(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]})),Wu(Ou,Du,((e,t)=>{const i=[e];if(e.shouldReceiveAttributes&&e.position.hasSameParentAs(t.range.start)&&t.range.containsPosition(e.position)){const n=Qu(e,t.key,t.newValue);n&&i.push(n)}return i})),Wu(Ou,Ou,((e,t,i)=>(e.position.isEqual(t.position)&&i.aIsStrong||(e.position=e.position._getTransformedByInsertOperation(t)),[e]))),Wu(Ou,Iu,((e,t)=>(e.position=e.position._getTransformedByMoveOperation(t),[e]))),Wu(Ou,Mu,((e,t)=>(e.position=e.position._getTransformedBySplitOperation(t),[e]))),Wu(Ou,Ru,((e,t)=>(e.position=e.position._getTransformedByMergeOperation(t),[e]))),Wu(Nu,Ou,((e,t)=>(e.oldRange&&(e.oldRange=e.oldRange._getTransformedByInsertOperation(t)[0]),e.newRange&&(e.newRange=e.newRange._getTransformedByInsertOperation(t)[0]),[e]))),Wu(Nu,Nu,((e,t,i)=>{if(e.name==t.name){if(!i.aIsStrong)return[new Lu(0)];e.oldRange=t.newRange?t.newRange.clone():null}return[e]})),Wu(Nu,Ru,((e,t)=>(e.oldRange&&(e.oldRange=e.oldRange._getTransformedByMergeOperation(t)),e.newRange&&(e.newRange=e.newRange._getTransformedByMergeOperation(t)),[e]))),Wu(Nu,Iu,((e,t,i)=>{if(e.oldRange&&(e.oldRange=td._createFromRanges(e.oldRange._getTransformedByMoveOperation(t))),e.newRange){if(i.abRelation){const n=td._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=td._createFromRanges(e.newRange._getTransformedByMoveOperation(t))}return[e]})),Wu(Nu,Mu,((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=Kc._createAt(t.insertionPosition):e.newRange.start.isEqual(t.splitPosition)&&!i.abRelation.wasInLeftElement&&(e.newRange.start=Kc._createAt(t.moveTargetPosition)),e.newRange.end.isEqual(t.splitPosition)&&i.abRelation.wasInRightElement?e.newRange.end=Kc._createAt(t.moveTargetPosition):e.newRange.end.isEqual(t.splitPosition)&&i.abRelation.wasEndBeforeMergedElement?e.newRange.end=Kc._createAt(t.insertionPosition):e.newRange.end=n.end,[e]}e.newRange=e.newRange._getTransformedBySplitOperation(t)}return[e]})),Wu(Ru,Ou,((e,t)=>(e.sourcePosition.hasSameParentAs(t.position)&&(e.howMany+=t.howMany),e.sourcePosition=e.sourcePosition._getTransformedByInsertOperation(t),e.targetPosition=e.targetPosition._getTransformedByInsertOperation(t),[e]))),Wu(Ru,Ru,((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 Kc(t.graveyardPosition.root,i),e.howMany=0,[e]}return[new Lu(0)]}if(e.sourcePosition.isEqual(t.sourcePosition)&&!e.targetPosition.isEqual(t.targetPosition)&&!i.bWasUndone&&"splitAtSource"!=i.abRelation){const n="$graveyard"==e.targetPosition.root.rootName,o="$graveyard"==t.targetPosition.root.rootName;if(o&&!n||!(n&&!o)&&i.aIsStrong){const i=t.targetPosition._getTransformedByMergeOperation(t),n=e.targetPosition._getTransformedByMergeOperation(t);return[new Iu(i,e.howMany,n,0)]}return[new Lu(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]})),Wu(Ru,Iu,((e,t,i)=>{const n=td._createFromPositionAndShift(t.sourcePosition,t.howMany);return"remove"==t.type&&!i.bWasUndone&&!i.forceWeakRemove&&e.deletionPosition.hasSameParentAs(t.sourcePosition)&&n.containsPosition(e.sourcePosition)?[new Lu(0)]:(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.graveyardPosition.isEqual(t.targetPosition)||(e.graveyardPosition=e.graveyardPosition._getTransformedByMoveOperation(t)),[e])})),Wu(Ru,Mu,((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,o=t.graveyardPosition&&e.deletionPosition.isEqual(t.graveyardPosition);if(n||o||"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]})),Wu(Iu,Ou,((e,t)=>{const i=td._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]})),Wu(Iu,Iu,((e,t,i)=>{const n=td._createFromPositionAndShift(e.sourcePosition,e.howMany),o=td._createFromPositionAndShift(t.sourcePosition,t.howMany);let r,s=i.aIsStrong,a=!i.aIsStrong;if("insertBefore"==i.abRelation||"insertAfter"==i.baRelation?a=!0:"insertAfter"!=i.abRelation&&"insertBefore"!=i.baRelation||(a=!1),r=e.targetPosition.isEqual(t.targetPosition)&&a?e.targetPosition._getTransformedByDeletion(t.sourcePosition,t.howMany):e.targetPosition._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),Ju(e,t)&&Ju(t,e))return[t.getReversed()];if(n.containsPosition(t.targetPosition)&&n.containsRange(o,!0))return n.start=n.start._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),n.end=n.end._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),Xu([n],r);if(o.containsPosition(e.targetPosition)&&o.containsRange(n,!0))return n.start=n.start._getCombined(t.sourcePosition,t.getMovedRangeStart()),n.end=n.end._getCombined(t.sourcePosition,t.getMovedRangeStart()),Xu([n],r);const l=ie(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),Xu([n],r);"remove"!=e.type||"remove"==t.type||i.aWasUndone||i.forceWeakRemove?"remove"==e.type||"remove"!=t.type||i.bWasUndone||i.forceWeakRemove||(s=!1):s=!0;const c=[],d=n.getDifference(o);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"==ie(e.start.getParentPath(),t.getMovedRangeStart().getParentPath()),n=e._getTransformedByInsertion(t.getMovedRangeStart(),t.howMany,i);c.push(...n)}const u=n.getIntersection(o);return null!==u&&s&&(u.start=u.start._getCombined(t.sourcePosition,t.getMovedRangeStart()),u.end=u.end._getCombined(t.sourcePosition,t.getMovedRangeStart()),0===c.length?c.push(u):1==c.length?o.start.isBefore(n.start)||o.start.isEqual(n.start)?c.unshift(u):c.push(u):c.splice(1,0,u)),0===c.length?[new Lu(e.baseVersion)]:Xu(c,r)})),Wu(Iu,Mu,((e,t,i)=>{let n=e.targetPosition.clone();e.targetPosition.isEqual(t.insertionPosition)&&t.graveyardPosition&&"moveTargetAfter"!=i.abRelation||(n=e.targetPosition._getTransformedBySplitOperation(t));const o=td._createFromPositionAndShift(e.sourcePosition,e.howMany);if(o.end.isEqual(t.insertionPosition))return t.graveyardPosition||e.howMany++,e.targetPosition=n,[e];if(o.start.hasSameParentAs(t.splitPosition)&&o.containsPosition(t.splitPosition)){let e=new td(t.splitPosition,o.end);e=e._getTransformedBySplitOperation(t);return Xu([new td(o.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 r=[o._getTransformedBySplitOperation(t)];if(t.graveyardPosition){const n=o.start.isEqual(t.graveyardPosition)||o.containsPosition(t.graveyardPosition);e.howMany>1&&n&&!i.aWasUndone&&r.push(td._createFromPositionAndShift(t.insertionPosition,1))}return Xu(r,n)})),Wu(Iu,Ru,((e,t,i)=>{const n=td._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 Lu(0)]}else if(!i.aWasUndone){const i=[];let n=t.graveyardPosition.clone(),o=t.targetPosition._getTransformedByMergeOperation(t);e.howMany>1&&(i.push(new Iu(e.sourcePosition,e.howMany-1,e.targetPosition,0)),n=n._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany-1),o=o._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany-1));const r=t.deletionPosition._getCombined(e.sourcePosition,e.targetPosition),s=new Iu(n,1,r,0),a=s.getMovedRangeStart().path.slice();a.push(0);const l=new Kc(s.targetPosition.root,a);o=o._getTransformedByMove(n,r,1);const c=new Iu(o,t.howMany,l,0);return i.push(s),i.push(c),i}const o=td._createFromPositionAndShift(e.sourcePosition,e.howMany)._getTransformedByMergeOperation(t);return e.sourcePosition=o.start,e.howMany=o.end.offset-o.start.offset,e.targetPosition=e.targetPosition._getTransformedByMergeOperation(t),[e]})),Wu(Bu,Ou,((e,t)=>(e.position=e.position._getTransformedByInsertOperation(t),[e]))),Wu(Bu,Ru,((e,t)=>e.position.isEqual(t.deletionPosition)?(e.position=t.graveyardPosition.clone(),e.position.stickiness="toNext",[e]):(e.position=e.position._getTransformedByMergeOperation(t),[e]))),Wu(Bu,Iu,((e,t)=>(e.position=e.position._getTransformedByMoveOperation(t),[e]))),Wu(Bu,Bu,((e,t,i)=>{if(e.position.isEqual(t.position)){if(!i.aIsStrong)return[new Lu(0)];e.oldName=t.newName}return[e]})),Wu(Bu,Mu,((e,t)=>{if("same"==ie(e.position.path,t.splitPosition.getParentPath())&&!t.graveyardPosition){const t=new Bu(e.position.getShiftedBy(1),e.oldName,e.newName,0);return[e,t]}return e.position=e.position._getTransformedBySplitOperation(t),[e]})),Wu(zu,zu,((e,t,i)=>{if(e.root===t.root&&e.key===t.key){if(!i.aIsStrong||e.newValue===t.newValue)return[new Lu(0)];e.oldValue=t.newValue}return[e]})),Wu(ju,ju,((e,t,i)=>e.rootName!==t.rootName||e.isAdd!==t.isAdd||i.bWasUndone?[e]:[new Lu(0)])),Wu(Mu,Ou,((e,t)=>(e.splitPosition.hasSameParentAs(t.position)&&e.splitPosition.offset{if(!e.graveyardPosition&&!i.bWasUndone&&e.splitPosition.hasSameParentAs(t.sourcePosition)){const i=t.graveyardPosition.path.slice();i.push(0);const n=new Kc(t.graveyardPosition.root,i),o=Mu.getInsertionPosition(new Kc(t.graveyardPosition.root,i)),r=new Mu(n,0,o,null,0);return e.splitPosition=e.splitPosition._getTransformedByMergeOperation(t),e.insertionPosition=Mu.getInsertionPosition(e.splitPosition),e.graveyardPosition=r.insertionPosition.clone(),e.graveyardPosition.stickiness="toNext",[r,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=Mu.getInsertionPosition(e.splitPosition),e.graveyardPosition&&(e.graveyardPosition=e.graveyardPosition._getTransformedByMergeOperation(t)),[e]})),Wu(Mu,Iu,((e,t,i)=>{const n=td._createFromPositionAndShift(t.sourcePosition,t.howMany);if(e.graveyardPosition){const o=n.start.isEqual(e.graveyardPosition)||n.containsPosition(e.graveyardPosition);if(!i.bWasUndone&&o){const i=e.splitPosition._getTransformedByMoveOperation(t),n=e.graveyardPosition._getTransformedByMoveOperation(t),o=n.path.slice();o.push(0);const r=new Kc(n.root,o);return[new Iu(i,e.howMany,r,0)]}e.graveyardPosition=e.graveyardPosition._getTransformedByMoveOperation(t)}const o=e.splitPosition.isEqual(t.targetPosition);if(o&&("insertAtSource"==i.baRelation||"splitBefore"==i.abRelation))return e.howMany+=t.howMany,e.splitPosition=e.splitPosition._getTransformedByDeletion(t.sourcePosition,t.howMany),e.insertionPosition=Mu.getInsertionPosition(e.splitPosition),[e];if(o&&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{if(e.splitPosition.isEqual(t.splitPosition)){if(!e.graveyardPosition&&!t.graveyardPosition)return[new Lu(0)];if(e.graveyardPosition&&t.graveyardPosition&&e.graveyardPosition.isEqual(t.graveyardPosition))return[new Lu(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,o="$graveyard"==t.splitPosition.root.rootName;if(o&&!n||!(n&&!o)&&i.aIsStrong){const i=[];return t.howMany&&i.push(new Iu(t.moveTargetPosition,t.howMany,t.splitPosition,0)),e.howMany&&i.push(new Iu(e.splitPosition,e.howMany,e.moveTargetPosition,0)),i}return[new Lu(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 Kc(t.insertionPosition.root,i);return[e,new Iu(e.insertionPosition,1,n,0)]}return e.splitPosition.hasSameParentAs(t.splitPosition)&&e.splitPosition.offset{const i=t[0];i.isDocumentOperation&&ih.call(this,i)}),{priority:"low"})}function ih(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)}}eh.prototype.is=function(e){return"livePosition"===e||"model:livePosition"===e||"position"==e||"model:position"===e};class nh{constructor(e={}){"string"==typeof e&&(e="transparent"===e?{isUndoable:!1}:{},A("batch-constructor-deprecated-string-type"));const{isUndoable:t=!0,isLocal:i=!0,isUndo:n=!1,isTyping:o=!1}=e;this.operations=[],this.isUndoable=t,this.isLocal=i,this.isUndo=n,this.isTyping=o}get type(){return A("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}}class oh{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}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=td._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":this._bufferRootStateChange(t.rootName,t.isAdd);break;case"addRootAttribute":case"removeRootAttribute":case"changeRootAttribute":{const e=t.root.rootName;this._bufferRootAttributeChange(e,t.key,t.oldValue,t.newValue);break}}this._cachedChanges=null}bufferMarkerChange(e,t,i){const n=this._changedMarkers.get(e);n?(n.newMarkerData=i,null==n.oldMarkerData.range&&null==i.range&&this._changedMarkers.delete(e)):this._changedMarkers.set(e,{newMarkerData:i,oldMarkerData:t})}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._changesInElement.size>0)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,o=e.range&&t.range&&!e.range.isEqual(t.range);if(i||n||o)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.offsete.position.root!=t.position.root?e.position.root.rootNamee));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(ah),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 o=this._changedRoots.get(e)||{name:e},r=o.attributes||{};if(r[t]){const e=r[t];n===e.oldValue?delete r[t]:e.newValue=n}else r[t]={oldValue:i,newValue:n};0===Object.entries(r).length?(delete o.attributes,void 0===o.state&&this._changedRoots.delete(e)):(o.attributes=r,this._changedRoots.set(e,o))}_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=td._createOn(e);for(const e of this._markerCollection.getMarkersIntersectingRange(t)){const t=e.getData();this.bufferMarkerChange(e.name,t,t)}this._cachedChanges=null}_markInsert(e,t,i){const n={type:"insert",offset:t,howMany:i,count:this._changeCount++};this._markChange(e,n)}_markRemove(e,t,i){const n={type:"remove",offset:t,howMany:i,count:this._changeCount++};this._markChange(e,n),this._removeAllNestedChanges(e,t,i)}_markAttribute(e){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;ei.offset){if(n>o){const e={type:"attribute",offset:o,howMany:n-o,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.offseto?(e.nodesToHandle=n-o,e.offset=o):e.nodesToHandle=0);if("remove"==i.type&&e.offseti.offset){const o={type:"attribute",offset:i.offset,howMany:n-i.offset,count:this._changeCount++};this._handleChange(o,t),t.push(o),e.nodesToHandle=i.offset-e.offset,e.howMany=e.nodesToHandle}"attribute"==i.type&&(e.offset>=i.offset&&n<=o?(e.nodesToHandle=0,e.howMany=0,e.offset=0):e.offset<=i.offset&&n>=o&&(i.howMany=0))}}e.howMany=e.nodesToHandle,delete e.nodesToHandle}_getInsertDiff(e,t,i){return{type:"insert",position:Kc._createAt(e,t),name:i.name,attributes:new Map(i.attributes),length:1,changeCount:this._changeCount++}}_getRemoveDiff(e,t,i){return{type:"remove",position:Kc._createAt(e,t),name:i.name,attributes:new Map(i.attributes),length:1,changeCount:this._changeCount++}}_getAttributesDiff(e,t,i){const n=[];i=new Map(i);for(const[o,r]of t){const t=i.has(o)?i.get(o):null;t!==r&&n.push({type:"attribute",position:e.start,range:e.clone(),length:1,attributeKey:o,attributeOldValue:r,attributeNewValue:t,changeCount:this._changeCount++}),i.delete(o)}for(const[t,o]of i)n.push({type:"attribute",position:e.start,range:e.clone(),length:1,attributeKey:t,attributeOldValue:null,attributeNewValue:o,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&&nn){for(let t=0;tthis._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 y("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&&et&&nthis.lastOperation.baseVersion)return[];let o=this._baseVersionToOperationIndex.get(e);void 0===o&&(o=0);let r=this._baseVersionToOperationIndex.get(n);return void 0===r&&(r=this._operations.length-1),this._operations.slice(o,r+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}}class ch extends $c{constructor(e,t,i="main"){super(t),this._isAttached=!0,this._document=e,this.rootName=i}get document(){return this._document}isAttached(){return this._isAttached}toJSON(){return this.rootName}}ch.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 dh="$graveyard";class uh extends(R()){constructor(e){super(),this.model=e,this.history=new lh,this.selection=new kd(this),this.roots=new To({idProperty:"rootName"}),this.differ=new oh(e.markers),this.isReadOnly=!1,this._postFixers=new Set,this._hasSelectionChangedFromTheLastChangeBlock=!1,this.createRoot("$root",dh),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,o)=>{const r={...t.getData(),range:n};this.differ.bufferMarkerChange(t.name,o,r),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}))}get version(){return this.history.version}set version(e){this.history.version=e}get graveyard(){return this.getRoot(dh)}createRoot(e="$root",t="main"){if(this.roots.get(t))throw new y("model-document-createroot-name-exists",this,{name:t});const i=new ch(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 Array.from(this.roots).filter((t=>t.rootName!=dh&&(e||t.isAttached()))).map((e=>e.rootName))}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(){for(const e of this.roots)if(e!==this.graveyard)return e;return 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 hh(e.start)&&hh(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)}}function hh(e){const t=e.textNode;if(t){const i=t.data,n=e.offset-t.startOffset;return!No(i,n)&&!Vo(i,n)}return!0}class mh extends(R()){constructor(){super(...arguments),this._markers=new Map}[Symbol.iterator](){return this._markers.values()}has(e){const t=e instanceof fh?e.name:e;return this._markers.has(t)}get(e){return this._markers.get(e)||null}_set(e,t,i=!1,n=!1){const o=e instanceof fh?e.name:e;if(o.includes(","))throw new y("markercollection-incorrect-marker-name",this);const r=this._markers.get(o);if(r){const e=r.getData(),s=r.getRange();let a=!1;return s.isEqual(t)||(r._attachLiveRange(gd.fromRange(t)),a=!0),i!=r.managedUsingOperations&&(r._managedUsingOperations=i,a=!0),"boolean"==typeof n&&n!=r.affectsData&&(r._affectsData=n,a=!0),a&&this.fire(`update:${o}`,r,s,t,e),r}const s=gd.fromRange(t),a=new fh(o,s,i,n);return this._markers.set(o,a),this.fire(`update:${o}`,a,null,t,{...a.getData(),range:null}),a}_remove(e){const t=e instanceof fh?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 fh?e.name:e,i=this._markers.get(t);if(!i)throw new y("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()}}class fh extends(R(Fc)){constructor(e,t,i,n){super(),this.name=e,this._liveRange=this._attachLiveRange(t),this._managedUsingOperations=i,this._affectsData=n}get managedUsingOperations(){if(!this._liveRange)throw new y("marker-destroyed",this);return this._managedUsingOperations}get affectsData(){if(!this._liveRange)throw new y("marker-destroyed",this);return this._affectsData}getData(){return{range:this.getRange(),affectsData:this.affectsData,managedUsingOperations:this.managedUsingOperations}}getStart(){if(!this._liveRange)throw new y("marker-destroyed",this);return this._liveRange.start.clone()}getEnd(){if(!this._liveRange)throw new y("marker-destroyed",this);return this._liveRange.end.clone()}getRange(){if(!this._liveRange)throw new y("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}}fh.prototype.is=function(e){return"marker"===e||"model:marker"===e};class gh extends yu{constructor(e,t){super(null),this.sourcePosition=e.clone(),this.howMany=t}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 y("detach-operation-on-document-node",this)}_execute(){xu(td._createFromPositionAndShift(this.sourcePosition,this.howMany))}static get className(){return"DetachOperation"}}class ph extends Fc{constructor(e){super(),this.markers=new Map,this._children=new Uc,e&&this._insertChild(0,e)}[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($c.fromJSON(i)):t.push(Wc.fromJSON(i));return new ph(t)}_appendChild(e){this._insertChild(this.childCount,e)}_insertChild(e,t){const i=function(e){if("string"==typeof e)return[new Wc(e)];ne(e)||(e=[e]);return Array.from(e).map((e=>"string"==typeof e?new Wc(e):e instanceof Zc?new Wc(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}}ph.prototype.is=function(e){return"documentFragment"===e||"model:documentFragment"===e};class bh{constructor(e,t){this.model=e,this.batch=t}createText(e,t){return new Wc(e,t)}createElement(e,t){return new $c(e,t)}createDocumentFragment(){return new ph}cloneElement(e,t=!0){return e._clone(t)}insert(e,t,i=0){if(this._assertWriterUsedCorrectly(),e instanceof Wc&&""==e.data)return;const n=Kc._createAt(t,i);if(e.parent){if(yh(e.root,n.root))return void this.move(td._createOn(e),n);if(e.root.document)throw new y("model-writer-insert-forbidden-move",this);this.remove(e)}const o=n.root.document?n.root.document.version:null,r=new Ou(n,e,o);if(e instanceof Wc&&(r.shouldReceiveAttributes=!0),this.batch.addOperation(r),this.model.applyOperation(r),e instanceof ph)for(const[t,i]of e.markers){const e=Kc._createAt(i.root,0),o={range:new td(i.start._getCombined(e,n),i.end._getCombined(e,n)),usingOperation:!0,affectsData:!0};this.model.markers.has(t)?this.updateMarker(t,o):this.addMarker(t,o)}}insertText(e,t,i,n){t instanceof ph||t instanceof $c||t instanceof Kc?this.insert(this.createText(e),t,i):this.insert(this.createText(e,t),i,n)}insertElement(e,t,i,n){t instanceof ph||t instanceof $c||t instanceof Kc?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 ph||t instanceof $c?this.insert(this.createText(e),t,"end"):this.insert(this.createText(e,t),i,"end")}appendElement(e,t,i){t instanceof ph||t instanceof $c?this.insert(this.createElement(e),t,"end"):this.insert(this.createElement(e,t),i,"end")}setAttribute(e,t,i){if(this._assertWriterUsedCorrectly(),i instanceof td){const n=i.getMinimalFlatRanges();for(const i of n)wh(this,e,t,i)}else kh(this,e,t,i)}setAttributes(e,t){for(const[i,n]of Mo(e))this.setAttribute(i,n,t)}removeAttribute(e,t){if(this._assertWriterUsedCorrectly(),t instanceof td){const i=t.getMinimalFlatRanges();for(const t of i)wh(this,e,null,t)}else kh(this,e,null,t)}clearAttributes(e){this._assertWriterUsedCorrectly();const t=e=>{for(const t of e.getAttributeKeys())this.removeAttribute(t,e)};if(e instanceof td)for(const i of e.getItems())t(i);else t(e)}move(e,t,i){if(this._assertWriterUsedCorrectly(),!(e instanceof td))throw new y("writer-move-invalid-range",this);if(!e.isFlat)throw new y("writer-move-range-not-flat",this);const n=Kc._createAt(t,i);if(n.isEqual(e.start))return;if(this._addOperationForAffectedMarkers("move",e),!yh(e.root,n.root))throw new y("writer-move-different-document",this);const o=e.root.document?e.root.document.version:null,r=new Iu(e.start,e.end.offset-e.start.offset,n,o);this.batch.addOperation(r),this.model.applyOperation(r)}remove(e){this._assertWriterUsedCorrectly();const t=(e instanceof td?e:td._createOn(e)).getMinimalFlatRanges().reverse();for(const e of t)this._addOperationForAffectedMarkers("move",e),vh(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 $c))throw new y("writer-merge-no-element-before",this);if(!(i instanceof $c))throw new y("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(td._createIn(i),Kc._createAt(t,"end")),this.remove(i)}_merge(e){const t=Kc._createAt(e.nodeBefore,"end"),i=Kc._createAt(e.nodeAfter,0),n=e.root.document.graveyard,o=new Kc(n,[0]),r=e.root.document.version,s=new Ru(i,e.nodeAfter.maxOffset,t,o,r);this.batch.addOperation(s),this.model.applyOperation(s)}rename(e,t){if(this._assertWriterUsedCorrectly(),!(e instanceof $c))throw new y("writer-rename-not-element-instance",this);const i=e.root.document?e.root.document.version:null,n=new Bu(Kc._createBefore(e),e.name,t,i);this.batch.addOperation(n),this.model.applyOperation(n)}split(e,t){this._assertWriterUsedCorrectly();let i,n,o=e.parent;if(!o.parent)throw new y("writer-split-element-no-parent",this);if(t||(t=o.parent),!e.parent.getAncestors({includeSelf:!0}).includes(t))throw new y("writer-split-invalid-limit-element",this);do{const t=o.root.document?o.root.document.version:null,r=o.maxOffset-e.offset,s=Mu.getInsertionPosition(e),a=new Mu(e,r,s,null,t);this.batch.addOperation(a),this.model.applyOperation(a),i||n||(i=o,n=e.parent.nextSibling),o=(e=this.createPositionAfter(e.parent)).parent}while(o!==t);return{position:e,range:new td(Kc._createAt(i,"end"),Kc._createAt(n,0))}}wrap(e,t){if(this._assertWriterUsedCorrectly(),!e.isFlat)throw new y("writer-wrap-range-not-flat",this);const i=t instanceof $c?t:new $c(t);if(i.childCount>0)throw new y("writer-wrap-element-not-empty",this);if(null!==i.parent)throw new y("writer-wrap-element-attached",this);this.insert(i,e.start);const n=new td(e.start.getShiftedBy(1),e.end.getShiftedBy(1));this.move(n,Kc._createAt(i,0))}unwrap(e){if(this._assertWriterUsedCorrectly(),null===e.parent)throw new y("writer-unwrap-element-no-parent",this);this.move(td._createIn(e),this.createPositionAfter(e)),this.remove(e)}addMarker(e,t){if(this._assertWriterUsedCorrectly(),!t||"boolean"!=typeof t.usingOperation)throw new y("writer-addmarker-no-usingoperation",this);const i=t.usingOperation,n=t.range,o=void 0!==t.affectsData&&t.affectsData;if(this.model.markers.has(e))throw new y("writer-addmarker-marker-exists",this);if(!n)throw new y("writer-addmarker-no-range",this);return i?(_h(this,e,null,n,o),this.model.markers.get(e)):this.model.markers._set(e,n,i,o)}updateMarker(e,t){this._assertWriterUsedCorrectly();const i="string"==typeof e?e:e.name,n=this.model.markers.get(i);if(!n)throw new y("writer-updatemarker-marker-not-exists",this);if(!t)return A("writer-updatemarker-reconvert-using-editingcontroller",{markerName:i}),void this.model.markers._refresh(n);const o="boolean"==typeof t.usingOperation,r="boolean"==typeof t.affectsData,s=r?t.affectsData:n.affectsData;if(!o&&!t.range&&!r)throw new y("writer-updatemarker-wrong-options",this);const a=n.getRange(),l=t.range?t.range:a;o&&t.usingOperation!==n.managedUsingOperations?t.usingOperation?_h(this,i,null,l,s):(_h(this,i,a,null,s),this.model.markers._set(i,l,void 0,s)):n.managedUsingOperations?_h(this,i,a,l,s):this.model.markers._set(i,l,void 0,s)}removeMarker(e){this._assertWriterUsedCorrectly();const t="string"==typeof e?e:e.name;if(!this.model.markers.has(t))throw new y("writer-removemarker-no-marker",this);const i=this.model.markers.get(t);if(!i.managedUsingOperations)return void this.model.markers._remove(t);_h(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 y("writer-addroot-root-exists",this);const n=this.model.document,o=new ju(e,t,!0,n,n.version);return this.batch.addOperation(o),this.model.applyOperation(o),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 y("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 ju(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 Mo(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=kd._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=kd._getStoreAttributeKey(e);this.removeAttribute(i,t.anchor.parent)}t._removeAttribute(e)}_assertWriterUsedCorrectly(){if(this.model._currentWriter!==this)throw new y("writer-incorrect-use",this)}_addOperationForAffectedMarkers(e,t){for(const i of this.model.markers){if(!i.managedUsingOperations)continue;const n=i.getRange();let o=!1;if("move"===e){const e=t;o=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,r=e.nodeAfter,s=n.start.parent==i&&n.start.isAtEnd,a=n.end.parent==r&&0==n.end.offset,l=n.end.nodeAfter==r,c=n.start.nodeAfter==r;o=s||a||l||c}o&&this.updateMarker(i.name,{range:n})}}}function wh(e,t,i,n){const o=e.model,r=o.document;let s,a,l,c=n.start;for(const e of n.getWalker({shallow:!0}))l=e.item.getAttribute(t),s&&a!=l&&(a!=i&&d(),c=s),s=e.nextPosition,a=l;function d(){const n=new td(c,s),l=n.root.document?r.version:null,d=new Du(n,t,a,i,l);e.batch.addOperation(d),o.applyOperation(d)}s instanceof Kc&&s!=c&&a!=i&&d()}function kh(e,t,i,n){const o=e.model,r=o.document,s=n.getAttribute(t);let a,l;if(s!=i){if(n.root===n){const e=n.document?r.version:null;l=new zu(n,t,s,i,e)}else{a=new td(Kc._createBefore(n),e.createPositionAfter(n));const o=a.root.document?r.version:null;l=new Du(a,t,s,i,o)}e.batch.addOperation(l),o.applyOperation(l)}}function _h(e,t,i,n,o){const r=e.model,s=r.document,a=new Nu(t,i,n,r.markers,!!o,s.version);e.batch.addOperation(a),r.applyOperation(a)}function vh(e,t,i,n){let o;if(e.root.document){const i=n.document,r=new Kc(i.graveyard,[0]);o=new Iu(e,t,r,i.version)}else o=new gh(e,t);i.addOperation(o),n.applyOperation(o)}function yh(e,t){return e===t||e instanceof ch&&t instanceof ch}function Ah(e,t,i={}){if(t.isCollapsed)return;const n=t.getFirstRange();if("$graveyard"==n.root.rootName)return;const o=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")}(o,t))return void function(e,t){const i=e.model.schema.getLimitElement(t);e.remove(e.createRangeIn(i)),Sh(e,e.createPositionAt(i,0),t)}(e,t);const r={};if(!i.doNotAutoparagraph){const e=t.getSelectedElement();e&&Object.assign(r,o.getAttributesWithProperty(e,"copyOnReplace",!0))}const[s,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 o=i.getLastPosition(),r=t.createRange(o,n);t.hasContent(r,{ignoreMarkers:!0})||(n=o)}}return[eh.fromPosition(i,"toPrevious"),eh.fromPosition(n,"toNext")]}(n);s.isTouching(a)||e.remove(e.createRange(s,a)),i.leaveUnmerged||(!function(e,t,i){const n=e.model;if(!Ch(e.model.schema,t,i))return;const[o,r]=function(e,t){const i=e.getAncestors(),n=t.getAncestors();let o=0;for(;i[o]&&i[o]==n[o];)o++;return[i[o],n[o]]}(t,i);if(!o||!r)return;!n.hasContent(o,{ignoreMarkers:!0})&&n.hasContent(r,{ignoreMarkers:!0})?Eh(e,t,i,o.parent):xh(e,t,i,o.parent)}(e,s,a),o.removeDisallowedAttributes(s.parent.getChildren(),e)),Th(e,t,s),!i.doNotAutoparagraph&&function(e,t){const i=e.checkChild(t,"$text"),n=e.checkChild(t,"paragraph");return!i&&n}(o,s)&&Sh(e,s,t,r),s.detach(),a.detach()}))}function xh(e,t,i,n){const o=t.parent,r=i.parent;if(o!=n&&r!=n){for(t=e.createPositionAfter(o),(i=e.createPositionBefore(r)).isEqual(t)||e.insert(r,t),e.merge(t);i.parent.isEmpty;){const t=i.parent;i=e.createPositionBefore(t),e.remove(t)}Ch(e.model.schema,t,i)&&xh(e,t,i,n)}}function Eh(e,t,i,n){const o=t.parent,r=i.parent;if(o!=n&&r!=n){for(t=e.createPositionAfter(o),(i=e.createPositionBefore(r)).isEqual(t)||e.insert(o,i);t.parent.isEmpty;){const i=t.parent;t=e.createPositionBefore(i),e.remove(i)}i=e.createPositionBefore(r),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),Ch(e.model.schema,t,i)&&Eh(e,t,i,n)}}function Ch(e,t,i){const n=t.parent,o=i.parent;return n!=o&&(!e.isLimit(n)&&!e.isLimit(o)&&function(e,t,i){const n=new td(e,t);for(const e of n.getWalker())if(i.isLimit(e.item))return!1;return!0}(t,i,e))}function Sh(e,t,i,n={}){const o=e.createElement("paragraph");e.model.schema.setAllowedAttributes(o,n,e),e.insert(o,t),Th(e,i,e.createPositionAt(o,0))}function Th(e,t,i){t instanceof kd?e.setSelection(i):t.setTo(i)}function Ph(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 Ih{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)}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 y("insertcontent-invalid-insertion-position",this);this.position=i,this._setAffectedBoundaries(this.position)}}getSelectionRange(){return this._nodeToSelect?td._createOn(this._nodeToSelect):this.model.schema.getNearestSelectionRange(this.position)}getAffectedRange(){return this._affectedStart?new td(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=eh.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 y("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=eh.fromPosition(e,"toPrevious")),this._affectedEnd&&!this._affectedEnd.isBefore(e)||(this._affectedEnd&&this._affectedEnd.detach(),this._affectedEnd=eh.fromPosition(e,"toNext"))}_mergeOnLeft(){const e=this._firstNode;if(!(e instanceof $c))return;if(!this._canMergeLeft(e))return;const t=eh._createBefore(e);t.stickiness="toNext";const i=eh.fromPosition(this.position,"toNext");this._affectedStart.isEqual(t)&&(this._affectedStart.detach(),this._affectedStart=eh._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=eh._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 $c))return;if(!this._canMergeRight(e))return;const t=eh._createAfter(e);if(t.stickiness="toNext",!this.position.isEqual(t))throw new y("insertcontent-invalid-insertion-position",this);this.position=Kc._createAt(t.nodeBefore,"end");const i=eh.fromPosition(this.position,"toPrevious");this._affectedEnd.isEqual(t)&&(this._affectedEnd.detach(),this._affectedEnd=eh._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=eh._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 $c&&this.canMergeWith.has(t)&&this.model.schema.checkMerge(t,e)}_canMergeRight(e){const t=e.nextSibling;return t instanceof $c&&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)}}function Oh(e,t,i="auto"){const n=e.getSelectedElement();if(n&&t.schema.isObject(n)&&!t.schema.isInline(n))return"before"==i||"after"==i?t.createRange(t.createPositionAt(n,i)):t.createRangeOn(n);const o=Po(e.getSelectedBlocks());if(!o)return t.createRange(e.focus);if(o.isEmpty)return t.createRange(t.createPositionAt(o,0));const r=t.createPositionAfter(o);return e.focus.isTouching(r)?t.createRange(r):t.createRange(t.createPositionBefore(o))}function Mh(e,t,i,n={}){if(!e.schema.isObject(t))throw new y("insertobject-element-not-an-object",e,{object:t});const o=i||e.document.selection;let r=o;n.findOptimalPosition&&e.schema.isBlock(t)&&(r=e.createSelection(Oh(o,e,n.findOptimalPosition)));const s=Po(o.getSelectedBlocks()),a={};return s&&Object.assign(a,e.schema.getAttributesWithProperty(s,"copyOnReplace",!0)),e.change((i=>{r.isCollapsed||e.deleteContent(r,{doNotAutoparagraph:!0});let o=t;const s=r.anchor.parent;!e.schema.checkChild(s,t)&&e.schema.checkChild(s,"paragraph")&&e.schema.checkChild("paragraph",t)&&(o=i.createElement("paragraph"),i.insert(t,o)),e.schema.setAllowedAttributes(o,a,i);const l=e.insertContent(o,r);return l.isCollapsed||n.setSelection&&function(e,t,i,n){const o=e.model;if("on"==i)return void e.setSelection(t,"on");if("after"!=i)throw new y("insertobject-invalid-place-parameter-value",o);let r=t.nextSibling;if(o.schema.isInline(t))return void e.setSelection(t,"after");const s=r&&o.schema.checkChild(r,"$text");!s&&o.schema.checkChild(t.parent,"paragraph")&&(r=e.createElement("paragraph"),o.schema.setAllowedAttributes(r,n,e),o.insertContent(r,e.createPositionAfter(t)));r&&e.setSelection(r,0)}(i,t,n.setSelection,a),l}))}const Rh=' ,.?!:;"-()';function Nh(e,t){const{isForward:i,walker:n,unit:o,schema:r,treatEmojiAsSingleUnit:s}=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(Lh(i,n,t))i=t?e.position.nodeAfter:e.position.nodeBefore;else{if(Dh(i.data,n,t))break;e.next()}}return e.position}(n,i):function(e,t,i){const n=e.position.textNode;if(n){const o=n.data;let r=e.position.offset-n.startOffset;for(;No(o,r)||"character"==t&&Vo(o,r)||i&&Lo(o,r);)e.next(),r=e.position.offset-n.startOffset}return e.position}(n,o,s);if(a==(i?"elementStart":"elementEnd")){if(r.isSelectable(l))return Kc._createAt(l,i?"after":"before");if(r.checkChild(c,"$text"))return c}else{if(r.isLimit(l))return void n.skip((()=>!0));if(r.checkChild(c,"$text"))return c}}function Vh(e,t){const i=e.root,n=Kc._createAt(i,t?"end":0);return t?new td(e,n):new td(n,e)}function Dh(e,t,i){const n=t+(i?0:-1);return Rh.includes(e.charAt(n))}function Lh(e,t,i){return t===(i?e.offsetSize:0)}class Bh extends(G()){constructor(){super(),this.markers=new mh,this.document=new uh(this),this.schema=new eu,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})),$d(this),this.document.registerPostFixer(Dd),this.on("insertContent",((e,[t,i])=>{e.return=function(e,t,i){return e.change((n=>{const o=i||e.document.selection;o.isCollapsed||e.deleteContent(o,{doNotAutoparagraph:!0});const r=new Ih(e,n,o.anchor),s=[];let a;if(t.is("documentFragment")){if(t.markers.size){const e=[];for(const[i,n]of t.markers){const{start:t,end:o}=n,r=t.isEqual(o);e.push({position:t,name:i,isCollapsed:r},{position:o,name:i,isCollapsed:r})}e.sort((({position:e},{position:t})=>e.isBefore(t)?1:-1));for(const{position:i,name:o,isCollapsed:r}of e){let e=null,a=null;const l=i.parent===t&&i.isAtStart,c=i.parent===t&&i.isAtEnd;l||c?r&&(a=l?"start":"end"):(e=n.createElement("$marker"),n.insert(e,i)),s.push({name:o,element:e,collapsed:a})}}a=t.getChildren()}else a=[t];r.handleNodes(a);let l=r.getSelectionRange();if(t.is("documentFragment")&&s.length){const e=l?gd.fromRange(l):null,t={};for(let e=s.length-1;e>=0;e--){const{name:i,element:o,collapsed:a}=s[e],l=!t[i];if(l&&(t[i]=[]),o){const e=n.createPositionAt(o,"before");t[i].push(e),n.remove(o)}else{const e=r.getAffectedRange();if(!e){a&&t[i].push(r.position);continue}a?t[i].push(e[a]):t[i].push(l?e.start:e.end)}}for(const[e,[i,o]]of Object.entries(t))i&&o&&i.root===o.root&&n.addMarker(e,{usingOperation:!0,affectsData:!0,range:new td(i,o)});e&&(l=e.toRange(),e.detach())}l&&(o instanceof kd?n.setSelection(l):o.setTo(l));const c=r.getAffectedRange()||e.createRange(o.anchor);return r.destroy(),c}))}(this,t,i)})),this.on("insertObject",((e,[t,i,n])=>{e.return=Mh(this,t,i,n)})),this.on("canEditAt",(e=>{const t=!this.document.isReadOnly;e.return=t,t||e.stop()}))}change(e){try{return 0===this._pendingChanges.length?(this._pendingChanges.push({batch:new nh,callback:e}),this._runPendingChanges()[0]):e(this._currentWriter)}catch(e){y.rethrowUnexpectedError(e,this)}}enqueueChange(e,t){try{e?"function"==typeof e?(t=e,e=new nh):e instanceof nh||(e=new nh(e)):e=new nh,this._pendingChanges.push({batch:e,callback:t}),1==this._pendingChanges.length&&this._runPendingChanges()}catch(e){y.rethrowUnexpectedError(e,this)}}applyOperation(e){e._execute()}insertContent(e,t,i,...n){const o=zh(t,i);return this.fire("insertContent",[e,o,i,...n])}insertObject(e,t,i,n,...o){const r=zh(t,i);return this.fire("insertObject",[e,r,n,n,...o])}deleteContent(e,t){Ah(this,e,t)}modifySelection(e,t){!function(e,t,i={}){const n=e.schema,o="backward"!=i.direction,r=i.unit?i.unit:"character",s=!!i.treatEmojiAsSingleUnit,a=t.focus,l=new qc({boundaries:Vh(a,o),singleCharacters:!0,direction:o?"forward":"backward"}),c={walker:l,schema:n,isForward:o,unit:r,treatEmojiAsSingleUnit:s};let d;for(;d=l.next();){if(d.done)return;const i=Nh(c,d.value);if(i)return void(t instanceof kd?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 o=n.start.root,r=n.start.getCommonPath(n.end),s=o.getNodeByPath(r);let a;a=n.start.parent==n.end.parent?n:e.createRange(e.createPositionAt(s,n.start.path[r.length]),e.createPositionAt(s,n.end.path[r.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],o=e.createRange(e.createPositionAt(i,0),t.start);Ph(e.createRange(t.end,e.createPositionAt(i,"end")),e),Ph(o,e)}return i}))}(this,e)}hasContent(e,t={}){const i=e instanceof td?e:td._createIn(e);if(i.isCollapsed)return!1;const{ignoreWhitespaces:n=!1,ignoreMarkers:o=!1}=t;if(!o)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=zh(e);return this.fire("canEditAt",[t])}createPositionFromPath(e,t,i){return new Kc(e,t,i)}createPositionAt(e,t){return Kc._createAt(e,t)}createPositionAfter(e){return Kc._createAfter(e)}createPositionBefore(e){return Kc._createBefore(e)}createRange(e,t){return new td(e,t)}createRangeIn(e){return td._createIn(e)}createRangeOn(e){return td._createOn(e)}createSelection(...e){return new ld(...e)}createBatch(e){return new nh(e)}createOperationFromJSON(e){return Hu.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 bh(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}}function zh(e,t){if(e)return e instanceof ld||e instanceof kd?e:e instanceof Hc?t||0===t?new ld(e,t):e.is("rootElement")?new ld(e,"in"):new ld(e,"on"):new ld(e)}class jh extends rc{constructor(){super(...arguments),this.domEventType="click"}onDomEvent(e){this.fire(e.type,e)}}class Fh extends rc{constructor(){super(...arguments),this.domEventType=["mousedown","mouseup","mouseover","mouseout"]}onDomEvent(e){this.fire(e.type,e)}}class Hh{constructor(e){this.document=e}createDocumentFragment(e){return new wl(this.document,e)}createElement(e,t,i){return new Fa(this.document,e,t,i)}createText(e){return new js(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 Fa(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){Te(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 Ka._createAt(e,t)}createPositionAfter(e){return Ka._createAfter(e)}createPositionBefore(e){return Ka._createBefore(e)}createRange(e,t){return new Ya(e,t)}createRangeOn(e){return Ya._createOn(e)}createRangeIn(e){return Ya._createIn(e)}createSelection(...e){return new Ja(...e)}}const Uh=/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,Wh=/^rgb\([ ]?([0-9]{1,3}[ %]?,[ ]?){2,3}[0-9]{1,3}[ %]?\)$/i,Zh=/^rgba\([ ]?([0-9]{1,3}[ %]?,[ ]?){3}(1|[0-9]+%|[0]?\.?[0-9]+)\)$/i,$h=/^hsl\([ ]?([0-9]{1,3}[ %]?[,]?[ ]*){3}(1|[0-9]+%|[0]?\.?[0-9]+)?\)$/i,qh=/^hsla\([ ]?([0-9]{1,3}[ %]?,[ ]?){2,3}(1|[0-9]+%|[0]?\.?[0-9]+)\)$/i,Gh=/\w+\((?:[^()]|\([^()]*\))*\)|\S+/gi,Kh=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 Yh(e){return e.startsWith("#")?Uh.test(e):e.startsWith("rgb")?Wh.test(e)||Zh.test(e):e.startsWith("hsl")?$h.test(e)||qh.test(e):Kh.has(e.toLowerCase())}const Qh=/^([+-]?[0-9]*([.][0-9]+)?(px|cm|mm|in|pc|pt|ch|em|ex|rem|vh|vw|vmin|vmax)|0)$/;const Jh=/^[+-]?[0-9]*([.][0-9]+)?%$/;const Xh=["repeat-x","repeat-y","repeat","space","round","no-repeat"];function em(e){return Xh.includes(e)}const tm=["center","top","bottom","left","right"];function im(e){return tm.includes(e)}const nm=["fixed","scroll","local"];function om(e){return nm.includes(e)}const rm=/^url\(/;function sm(e){return rm.test(e)}function am(e=""){if(""===e)return{top:void 0,right:void 0,bottom:void 0,left:void 0};const t=cm(e),i=t[0],n=t[2]||i,o=t[1]||i;return{top:i,bottom:n,right:o,left:t[3]||o}}function lm({top:e,right:t,bottom:i,left:n}){const o=[];return n!==t?o.push(e,t,i,n):i!==e?o.push(e,t,i):t!==e?o.push(e,t):o.push(e),o.join(" ")}function cm(e){const t=e.matchAll(Gh);return Array.from(t).map((e=>e[0]))}function dm(e){e.setNormalizer("background",(e=>{const t={},i=cm(e);for(const e of i)em(e)?(t.repeat=t.repeat||[],t.repeat.push(e)):im(e)?(t.position=t.position||[],t.position.push(e)):om(e)?t.attachment=e:Yh(e)?t.color=e:sm(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 um(e){var t,i;e.setNormalizer("margin",(t="margin",e=>({path:t,value:am(e)}))),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",(i="margin",e=>{const{top:t,right:n,bottom:o,left:r}=e,s=[];return[t,n,r,o].every((e=>!!e))?s.push([i,lm(e)]):(t&&s.push([i+"-top",t]),n&&s.push([i+"-right",n]),o&&s.push([i+"-bottom",o]),r&&s.push([i+"-left",r])),s})),e.setStyleRelation("margin",["margin-top","margin-right","margin-bottom","margin-left"])}class hm{constructor(){this._commands=new Map}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 y("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()}}class mm extends Oo{constructor(e){super(),this.editor=e}set(e,t,i={}){if("string"==typeof t){const e=t;t=(t,i)=>{this.editor.execute(e),i()}}super.set(e,t,i)}}class fm extends(G()){constructor(e={}){super();const t=this.constructor,i=e.language||t.defaultConfig&&t.defaultConfig.language;this._context=e.context||new Ss({language:i}),this._context._addEditor(this,!e.context);const n=Array.from(t.builtinPlugins||[]);this.config=new Cn(e,t.defaultConfig),this.config.define("plugins",n),this.config.define(this._context._getEditorConfig()),this.plugins=new Cs(this,n,this._context.plugins),this.locale=this._context.locale,this.t=this.locale.t,this._readOnlyLocks=new Set,this.commands=new hm,this.set("state","initializing"),this.once("ready",(()=>this.state="ready"),{priority:"high"}),this.once("destroy",(()=>this.state="destroyed"),{priority:"high"}),this.model=new Bh,this.on("change:isReadOnly",(()=>{this.model.document.isReadOnly=this.isReadOnly}));const o=new Ba;this.data=new wu(this.model,o),this.editing=new Yd(this.model,o),this.editing.view.document.bind("isReadOnly").to(this),this.conversion=new ku([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 mm(this),this.keystrokes.listenTo(this.editing.view.document)}get isReadOnly(){return this._readOnlyLocks.size>0}set isReadOnly(e){throw new y("editor-isreadonly-has-no-setter")}enableReadOnlyMode(e){if("string"!=typeof e&&"symbol"!=typeof e)throw new y("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 y("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))}initPlugins(){const e=this.config,t=e.get("plugins"),i=e.get("removePlugins")||[],n=e.get("extraPlugins")||[],o=e.get("substitutePlugins")||[];return this.plugins.init(t.concat(n),i,o)}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){y.rethrowUnexpectedError(e,this)}}focus(){this.editing.view.focus()}static create(...e){throw new Error("This is an abstract method.")}}function gm(e){return class extends e{setData(e){this.data.set(e)}getData(e){return this.data.get(e)}}}{const e=gm(Object);gm.setData=e.prototype.setData,gm.getData=e.prototype.getData}function pm(e){return class extends e{updateSourceElement(e=this.data.get()){if(!this.sourceElement)throw new y("editor-missing-sourceelement",this);const t=this.config.get("updateSourceElementOnDestroy"),i=this.sourceElement instanceof HTMLTextAreaElement;Gn(this.sourceElement,t||i?e:"")}}}pm.updateSourceElement=pm(Object).prototype.updateSourceElement;class bm extends Ts{static get pluginName(){return"PendingActions"}init(){this.set("hasAny",!1),this._actions=new To({idProperty:"_id"}),this._actions.delegate("add","remove").to(this)}add(e){if("string"!=typeof e)throw new y("pendingactions-add-invalid-message",this);const t=new(G());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 wm='',km='',_m={bold:'',cancel:wm,caption:'',check:km,cog:'',eraser:'',image:'',lowVision:'',importExport:'',paragraph:'',plus:'',text:'',alignBottom:'',alignMiddle:'',alignTop:'',alignLeft:'',alignCenter:'',alignRight:'',alignJustify:'',objectLeft:'',objectCenter:'',objectRight:'',objectFullWidth:'',objectInline:'',objectBlockLeft:'',objectBlockRight:'',objectSizeFull:'',objectSizeLarge:'',objectSizeSmall:'',objectSizeMedium:'',pencil:'',pilcrow:'',quote:'',threeVerticalDots:''};var vm=i(7343),ym={attributes:{"data-cke":!0}};ym.setAttributes=$o(),ym.insert=Wo().bind(null,"head"),ym.domAPI=Ho(),ym.insertStyleElement=Go();jo()(vm.Z,ym);vm.Z&&vm.Z.locals&&vm.Z.locals;const{threeVerticalDots:Am}=_m,xm={alignLeft:_m.alignLeft,bold:_m.bold,importExport:_m.importExport,paragraph:_m.paragraph,plus:_m.plus,text:_m.text,threeVerticalDots:_m.threeVerticalDots};class Em extends Qo{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 Io,this.keystrokes=new Oo,this.set("class",void 0),this.set("isCompact",!1),this.itemsView=new Cm(e),this.children=this.createCollection(),this.children.add(this.itemsView),this.focusables=this.createCollection();const o="rtl"===e.uiLanguageDirection;this._focusCycler=new ps({focusables:this.focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:[o?"arrowright":"arrowleft","arrowup"],focusNext:[o?"arrowleft":"arrowright","arrowdown"]}});const r=["ck","ck-toolbar",i.to("class"),i.if("isCompact","ck-toolbar_compact")];var s;this.options.shouldGroupWhenFull&&this.options.isFloating&&r.push("ck-toolbar_floating"),this.setTemplate({tag:"div",attributes:{class:r,role:"toolbar","aria-label":i.to("ariaLabel"),style:{maxWidth:i.to("maxWidth")},tabindex:-1},children:this.children,on:{mousedown:(s=this,s.bindTemplate.to((e=>{e.target===s.element&&e.preventDefault()})))}}),this._behavior=this.options.shouldGroupWhenFull?new Tm(this):new Sm(this)}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=_s(e),o=i||n.removeItems;return this._cleanItemsConfiguration(n.items,t,o).map((e=>F(e)?this._createNestedToolbarDropdown(e,t,o):"|"===e?new ws:"-"===e?new ks:t.create(e))).filter((e=>!!e))}_cleanItemsConfiguration(e,t,i){const n=e.filter(((e,n,o)=>"|"===e||-1===i.indexOf(e)&&("-"===e?!this.options.shouldGroupWhenFull||(A("toolbarview-line-break-ignored-when-grouping-items",o),!1):!(!F(e)&&!t.has(e))||(A("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 o=i-e.slice().reverse().findIndex(t);return e.slice(n,o).filter(((e,i,n)=>{if(t(e))return!0;return!(i>0&&n[i-1]===e)}))}_createNestedToolbarDropdown(e,t,i){let{label:n,icon:o,items:r,tooltip:s=!0,withText:a=!1}=e;if(r=this._cleanItemsConfiguration(r,t,i),!r.length)return null;const l=Fm(this.locale);return n||A("toolbarview-nested-toolbar-dropdown-missing-label",e),l.class="ck-toolbar__nested-toolbar-dropdown",l.buttonView.set({label:n,tooltip:s,withText:!!a}),!1!==o?l.buttonView.icon=xm[o]||o||Am:l.buttonView.withText=!0,Hm(l,(()=>l.toolbarView._buildItemsFromConfig(r,t,i))),l}}class Cm extends Qo{constructor(e){super(e),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-toolbar__items"]},children:this.children})}}class Sm{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=>e)),e.extendTemplate({attributes:{class:[t.if("isVertical","ck-toolbar_vertical")]}})}render(){}destroy(){}}class Tm{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._updateFocusCycleableItems.bind(this)),e.children.on("change",this._updateFocusCycleableItems.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;ethis.ungroupedItems.length?this.groupedItems.add(t,e-this.ungroupedItems.length):this.ungroupedItems.add(t,e)}this._updateGrouping()})),e.extendTemplate({attributes:{class:["ck-toolbar_grouping"]}})}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(!eo(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 Hn(e.lastChild),n=new Hn(e);if(!this.cachedPadding){const i=Dn.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{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 ws),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=Fm(e);return i.class="ck-toolbar__grouped-dropdown",i.panelPosition="ltr"===e.uiLanguageDirection?"sw":"se",Hm(i,this.groupedItems),i.buttonView.set({label:t("Show more items"),tooltip:!0,tooltipPosition:"rtl"===e.uiLanguageDirection?"se":"sw",icon:Am}),i}_updateFocusCycleableItems(){this.viewFocusables.clear(),this.ungroupedItems.map((e=>{this.viewFocusables.add(e)})),this.groupedItems.length&&this.viewFocusables.add(this.groupedItemsDropdown)}}var Pm=i(9647),Im={attributes:{"data-cke":!0}};Im.setAttributes=$o(),Im.insert=Wo().bind(null,"head"),Im.domAPI=Ho(),Im.insertStyleElement=Go();jo()(Pm.Z,Im);Pm.Z&&Pm.Z.locals&&Pm.Z.locals;class Om extends Qo{constructor(e){super(e);const t=this.bindTemplate;this.items=this.createCollection(),this.focusTracker=new Io,this.keystrokes=new Oo,this._focusCycler=new ps({focusables:this.items,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"arrowup",focusNext:"arrowdown"}}),this.set("ariaLabel",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")},children:this.items})}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)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}}class Mm extends Qo{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})}focus(){this.children.first.focus()}}class Rm extends Qo{constructor(e){super(e),this.setTemplate({tag:"li",attributes:{class:["ck","ck-list__separator"]}})}}var Nm=i(8418),Vm={attributes:{"data-cke":!0}};Vm.setAttributes=$o(),Vm.insert=Wo().bind(null,"head"),Vm.domAPI=Ho(),Vm.insertStyleElement=Go();jo()(Nm.Z,Vm);Nm.Z&&Nm.Z.locals&&Nm.Z.locals;class Dm extends Qo{constructor(e){super(e);const t=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(),this.arrowView=this._createArrowView(),this.keystrokes=new Oo,this.focusTracker=new Io,this.setTemplate({tag:"div",attributes:{class:["ck","ck-splitbutton",t.to("class"),t.if("isVisible","ck-hidden",(e=>!e)),this.arrowView.bindTemplate.if("isOn","ck-splitbutton_open")]},children:this.children})}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(){const e=new Er;return e.bind("icon","isEnabled","isOn","isToggleable","keystroke","label","tabindex","tooltip","tooltipPosition","type","withText").to(this),e.extendTemplate({attributes:{class:"ck-splitbutton__action"}}),e.delegate("execute").to(this),e}_createArrowView(){const e=new Er,t=e.bindTemplate;return e.icon=fs,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}}var Lm=i(3505),Bm={attributes:{"data-cke":!0}};Bm.setAttributes=$o(),Bm.insert=Wo().bind(null,"head"),Bm.domAPI=Ho(),Bm.insertStyleElement=Go();jo()(Lm.Z,Bm);Lm.Z&&Lm.Z.locals&&Lm.Z.locals;var zm=i(6371),jm={attributes:{"data-cke":!0}};jm.setAttributes=$o(),jm.insert=Wo().bind(null,"head"),jm.domAPI=Ho(),jm.insertStyleElement=Go();jo()(zm.Z,jm);zm.Z&&zm.Z.locals&&zm.Z.locals;function Fm(e,t=gs){const i=new t(e),o=new ds(e),r=new ms(e,i,o);return i.bind("isEnabled").to(r),i instanceof Dm?i.arrowView.bind("isOn").to(r,"isOpen"):i.bind("isOn").to(r,"isOpen"),function(e){(function(e){e.on("render",(()=>{n({emitter:e,activator:()=>e.isOpen,callback:()=>{e.isOpen=!1},contextElements:[e.element]})}))})(e),function(e){e.on("execute",(t=>{t.source instanceof Tr||(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 o=e.panelView.element;o&&o.contains(Dn.document.activeElement)&&e.buttonView.focus()}))}(e),function(e){e.on("change:isOpen",((t,i,n)=>{n&&e.panelView.focus()}),{priority:"low"})}(e)}(r),r}function Hm(e,t,i={}){e.extendTemplate({attributes:{class:["ck-toolbar-dropdown"]}}),e.isOpen?Um(e,t,i):e.once("change:isOpen",(()=>Um(e,t,i)),{priority:"highest"}),i.enableActiveItemFocusOnDropdownOpen&&$m(e,(()=>e.toolbarView.items.find((e=>e.isOn))))}function Um(e,t,i){const n=e.locale,o=n.t,r=e.toolbarView=new Em(n),s="function"==typeof t?t():t;r.ariaLabel=i.ariaLabel||o("Dropdown toolbar"),i.maxWidth&&(r.maxWidth=i.maxWidth),i.class&&(r.class=i.class),i.isCompact&&(r.isCompact=i.isCompact),i.isVertical&&(r.isVertical=!0),s instanceof Bo?r.items.bindTo(s).using((e=>e)):r.items.addMany(s),e.panelView.children.add(r),r.items.delegate("execute").to(e)}function Wm(e,t,i={}){e.isOpen?Zm(e,t,i):e.once("change:isOpen",(()=>Zm(e,t,i)),{priority:"highest"}),$m(e,(()=>e.listView.items.find((e=>e instanceof Mm&&e.children.first.isOn))))}function Zm(e,t,i){const n=e.locale,o=e.listView=new Om(n),r="function"==typeof t?t():t;o.ariaLabel=i.ariaLabel,o.role=i.role,o.items.bindTo(r).using((e=>{if("separator"===e.type)return new Rm(n);if("button"===e.type||"switchbutton"===e.type){const t=new Mm(n);let i;return i="button"===e.type?new Er(n):new Tr(n),i.bind(...Object.keys(e.model)).to(e.model),i.delegate("execute").to(t),t.children.add(i),t}return null})),e.panelView.children.add(o),o.items.delegate("execute").to(e)}function $m(e,t){e.on("change:isOpen",(()=>{if(!e.isOpen)return;const i=t();i&&("function"==typeof i.focus?i.focus():A("ui-dropdown-focus-child-on-open-child-missing-focus",{view:i}))}),{priority:k.low-10})}function qm(e,t,i){const n=new cs(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}const Gm=(e,t=0,i=1)=>e>i?i:eMath.round(i*e)/i,Ym=(Math.PI,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?Km(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?Km(parseInt(e.substring(6,8),16)/255,2):1})),Qm=({h:e,s:t,v:i,a:n})=>{const o=(200-t)*i/100;return{h:Km(e),s:Km(o>0&&o<200?t*i/100/(o<=100?o:200-o)*100:0),l:Km(o/2),a:Km(n,2)}},Jm=e=>{const{h:t,s:i,l:n}=Qm(e);return`hsl(${t}, ${i}%, ${n}%)`},Xm=({h:e,s:t,v:i,a:n})=>{e=e/360*6,t/=100,i/=100;const o=Math.floor(e),r=i*(1-t),s=i*(1-(e-o)*t),a=i*(1-(1-e+o)*t),l=o%6;return{r:Km(255*[i,s,r,r,a,i][l]),g:Km(255*[a,i,i,s,r,r][l]),b:Km(255*[r,r,a,i,i,s][l]),a:Km(n,2)}},ef=e=>{const t=e.toString(16);return t.length<2?"0"+t:t},tf=({r:e,g:t,b:i,a:n})=>{const o=n<1?ef(Km(255*n)):"";return"#"+ef(e)+ef(t)+ef(i)+o},nf=({r:e,g:t,b:i,a:n})=>{const o=Math.max(e,t,i),r=o-Math.min(e,t,i),s=r?o===e?(t-i)/r:o===t?2+(i-e)/r:4+(e-t)/r:0;return{h:Km(60*(s<0?s+6:s)),s:Km(o?r/o*100:0),v:Km(o/255*100),a:n}},of=(e,t)=>{if(e===t)return!0;for(const i in e)if(e[i]!==t[i])return!1;return!0},rf={},sf=e=>{let t=rf[e];return t||(t=document.createElement("template"),t.innerHTML=e,rf[e]=t),t},af=(e,t,i)=>{e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:i}))};let lf=!1;const cf=e=>"touches"in e,df=(e,t)=>{const i=cf(t)?t.touches[0]:t,n=e.el.getBoundingClientRect();af(e.el,"move",e.getMove({x:Gm((i.pageX-(n.left+window.pageXOffset))/n.width),y:Gm((i.pageY-(n.top+window.pageYOffset))/n.height)}))};class uf{constructor(e,t,i,n){const o=sf(`
`);e.appendChild(o.content.cloneNode(!0));const r=e.querySelector(`[part=${t}]`);r.addEventListener("mousedown",this),r.addEventListener("touchstart",this),r.addEventListener("keydown",this),this.el=r,this.xy=n,this.nodes=[r.firstChild,r]}set dragging(e){const t=e?document.addEventListener:document.removeEventListener;t(lf?"touchmove":"mousemove",this),t(lf?"touchend":"mouseup",this)}handleEvent(e){switch(e.type){case"mousedown":case"touchstart":if(e.preventDefault(),!(e=>!(lf&&!cf(e)||(lf||(lf=cf(e)),0)))(e)||!lf&&0!=e.button)return;this.el.focus(),df(this,e),this.dragging=!0;break;case"mousemove":case"touchmove":e.preventDefault(),df(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(),af(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])}))}}class hf extends uf{constructor(e){super(e,"hue",'aria-label="Hue" aria-valuemin="0" aria-valuemax="360"',!1)}update({h:e}){this.h=e,this.style([{left:e/360*100+"%",color:Jm({h:e,s:100,v:100,a:1})}]),this.el.setAttribute("aria-valuenow",`${Km(e)}`)}getMove(e,t){return{h:t?Gm(this.h+360*e.x,0,360):360*e.x}}}class mf extends uf{constructor(e){super(e,"saturation",'aria-label="Color"',!0)}update(e){this.hsva=e,this.style([{top:100-e.v+"%",left:`${e.s}%`,color:Jm(e)},{"background-color":Jm({h:e.h,s:100,v:100,a:1})}]),this.el.setAttribute("aria-valuetext",`Saturation ${Km(e.s)}%, Brightness ${Km(e.v)}%`)}getMove(e,t){return{s:t?Gm(this.hsva.s+100*e.x,0,100):100*e.x,v:t?Gm(this.hsva.v-100*e.y,0,100):Math.round(100-100*e.y)}}}const ff=Symbol("same"),gf=Symbol("color"),pf=Symbol("hsva"),bf=Symbol("update"),wf=Symbol("parts"),kf=Symbol("css"),_f=Symbol("sliders");class vf extends HTMLElement{static get observedAttributes(){return["color"]}get[kf](){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[_f](){return[mf,hf]}get color(){return this[gf]}set color(e){if(!this[ff](e)){const t=this.colorModel.toHsva(e);this[bf](t),this[gf]=e}}constructor(){super();const e=sf(``),t=this.attachShadow({mode:"open"});t.appendChild(e.content.cloneNode(!0)),t.addEventListener("move",this),this[wf]=this[_f].map((e=>new e(t)))}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[ff](n)||(this.color=n)}handleEvent(e){const t=this[pf],i={...t,...e.detail};let n;this[bf](i),of(i,t)||this[ff](n=this.colorModel.fromHsva(i))||(this[gf]=n,af(this,"color-changed",{value:n}))}[ff](e){return this.color&&this.colorModel.equal(e,this.color)}[bf](e){this[pf]=e,this[wf].forEach((t=>t.update(e)))}}const yf={defaultColor:"#000",toHsva:e=>nf(Ym(e)),fromHsva:({h:e,s:t,v:i})=>tf(Xm({h:e,s:t,v:i,a:1})),equal:(e,t)=>e.toLowerCase()===t.toLowerCase()||of(Ym(e),Ym(t)),fromAttr:e=>e};class Af extends vf{get colorModel(){return yf}}customElements.define("hex-color-picker",class extends Af{});var xf=i(2118),Ef={attributes:{"data-cke":!0}};Ef.setAttributes=$o(),Ef.insert=Wo().bind(null,"head"),Ef.domAPI=Ho(),Ef.insertStyleElement=Go();jo()(xf.Z,Ef);xf.Z&&xf.Z.locals&&xf.Z.locals;class Cf extends Qo{constructor(e,t){super(e),this.set("color",""),this.set("_hexColor",""),this._format=t.format||"hsl",this.hexInputRow=this._createInputRow();const i=this.createCollection();i.add(this.hexInputRow),this.setTemplate({tag:"div",attributes:{class:["ck","ck-color-picker"],tabindex:-1},children:i}),this._debounceColorPickerEvent=Xr((e=>{this.set("color",e)}),150,{leading:!0}),this.on("set:color",((e,t,i)=>{e.return=Br(i,this._format)})),this.on("change:color",(()=>{this._hexColor=Sf(this.color)})),this.on("change:_hexColor",(()=>{document.activeElement!==this.picker&&this.picker.setAttribute("color",this._hexColor),Sf(this.color)!=Sf(this._hexColor)&&(this.color=this._hexColor)}))}render(){if(super.render(),this.picker=Dn.document.createElement("hex-color-picker"),this.picker.setAttribute("class","hex-color-picker"),this.picker.setAttribute("tabindex","-1"),this._createSlidersView(),this.element){this.element.insertBefore(this.picker,this.hexInputRow.element);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(c.isGecko||c.isiOS||c.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 Tf(e)));this.slidersView=this.createCollection(),e.forEach((e=>{this.slidersView.add(e)}))}_createInputRow(){const e=new Pf,t=this._createColorInput();return new If(this.locale,[e,t])}_createColorInput(){const e=new rs(this.locale,qm),{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=t.trim(),i=e.startsWith("#")?e.substring(1):e;[3,4,6,8].includes(i.length)&&/(([0-9a-fA-F]{2}){3,4}|([0-9a-fA-F]){3,4})/.test(i)&&this._debounceColorPickerEvent("#"+i)}})),e}}function Sf(e){let t=function(e){if(!e)return"";const t=zr(e);return t?"hex"===t.space?t.hexValue:Br(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 Tf extends Qo{constructor(e){super(),this.element=e}focus(){this.element.focus()}}class Pf extends Qo{constructor(e){super(e),this.setTemplate({tag:"div",attributes:{class:["ck","ck-color-picker__hash-view"]},children:"#"})}}class If extends Qo{constructor(e,t){super(e),this.children=this.createCollection(t),this.setTemplate({tag:"div",attributes:{class:["ck","ck-color-picker__row"]},children:this.children})}}class Of{constructor(e){this._components=new Map,this.editor=e}*names(){for(const e of this._components.values())yield e.originalName}add(e,t){this._components.set(Mf(e),{callback:t,originalName:e})}create(e){if(!this.has(e))throw new y("componentfactory-item-missing",this,{name:e});return this._components.get(Mf(e)).callback(this.editor.locale)}has(e){return this._components.has(Mf(e))}}function Mf(e){return String(e).toLowerCase()}var Rf=i(9029),Nf={attributes:{"data-cke":!0}};Nf.setAttributes=$o(),Nf.insert=Wo().bind(null,"head"),Nf.domAPI=Ho(),Nf.insertStyleElement=Go();jo()(Rf.Z,Nf);Rf.Z&&Rf.Z.locals&&Rf.Z.locals;const Vf=Kn("px"),Df=Dn.document.body;class Lf extends Qo{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",Vf),left:t.to("left",Vf)}},children:this.content})}show(){this.isVisible=!0}hide(){this.isVisible=!1}attachTo(e){this.show();const t=Lf.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:Df,fitInViewport:!0},e),n=Lf._getOptimalPosition(i),o=parseInt(n.left),r=parseInt(n.top),s=n.name,a=n.config||{},{withArrow:l=!0}=a;this.top=r,this.left=o,this.position=s,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=Bf(e.target),i=e.limiter?Bf(e.limiter):Df;this.listenTo(Dn.document,"scroll",((n,o)=>{const r=o.target,s=t&&r.contains(t),a=i&&r.contains(i);!s&&!a&&t&&i||this.attachTo(e)}),{useCapture:!0}),this.listenTo(Dn.window,"resize",(()=>{this.attachTo(e)}))}_stopPinning(){this.stopListening(Dn.document,"scroll"),this.stopListening(Dn.window,"resize")}}function Bf(e){return En(e)?e:zn(e)?e.commonAncestorContainer:"function"==typeof e?Bf(e()):null}function zf(e={}){const{sideOffset:t=Lf.arrowSideOffset,heightOffset:i=Lf.arrowHeightOffset,stickyVerticalOffset:n=Lf.stickyVerticalOffset,config:o}=e;return{northWestArrowSouthWest:(e,i)=>({top:r(e,i),left:e.left-t,name:"arrow_sw",...o&&{config:o}}),northWestArrowSouthMiddleWest:(e,i)=>({top:r(e,i),left:e.left-.25*i.width-t,name:"arrow_smw",...o&&{config:o}}),northWestArrowSouth:(e,t)=>({top:r(e,t),left:e.left-t.width/2,name:"arrow_s",...o&&{config:o}}),northWestArrowSouthMiddleEast:(e,i)=>({top:r(e,i),left:e.left-.75*i.width+t,name:"arrow_sme",...o&&{config:o}}),northWestArrowSouthEast:(e,i)=>({top:r(e,i),left:e.left-i.width+t,name:"arrow_se",...o&&{config:o}}),northArrowSouthWest:(e,i)=>({top:r(e,i),left:e.left+e.width/2-t,name:"arrow_sw",...o&&{config:o}}),northArrowSouthMiddleWest:(e,i)=>({top:r(e,i),left:e.left+e.width/2-.25*i.width-t,name:"arrow_smw",...o&&{config:o}}),northArrowSouth:(e,t)=>({top:r(e,t),left:e.left+e.width/2-t.width/2,name:"arrow_s",...o&&{config:o}}),northArrowSouthMiddleEast:(e,i)=>({top:r(e,i),left:e.left+e.width/2-.75*i.width+t,name:"arrow_sme",...o&&{config:o}}),northArrowSouthEast:(e,i)=>({top:r(e,i),left:e.left+e.width/2-i.width+t,name:"arrow_se",...o&&{config:o}}),northEastArrowSouthWest:(e,i)=>({top:r(e,i),left:e.right-t,name:"arrow_sw",...o&&{config:o}}),northEastArrowSouthMiddleWest:(e,i)=>({top:r(e,i),left:e.right-.25*i.width-t,name:"arrow_smw",...o&&{config:o}}),northEastArrowSouth:(e,t)=>({top:r(e,t),left:e.right-t.width/2,name:"arrow_s",...o&&{config:o}}),northEastArrowSouthMiddleEast:(e,i)=>({top:r(e,i),left:e.right-.75*i.width+t,name:"arrow_sme",...o&&{config:o}}),northEastArrowSouthEast:(e,i)=>({top:r(e,i),left:e.right-i.width+t,name:"arrow_se",...o&&{config:o}}),southWestArrowNorthWest:e=>({top:s(e),left:e.left-t,name:"arrow_nw",...o&&{config:o}}),southWestArrowNorthMiddleWest:(e,i)=>({top:s(e),left:e.left-.25*i.width-t,name:"arrow_nmw",...o&&{config:o}}),southWestArrowNorth:(e,t)=>({top:s(e),left:e.left-t.width/2,name:"arrow_n",...o&&{config:o}}),southWestArrowNorthMiddleEast:(e,i)=>({top:s(e),left:e.left-.75*i.width+t,name:"arrow_nme",...o&&{config:o}}),southWestArrowNorthEast:(e,i)=>({top:s(e),left:e.left-i.width+t,name:"arrow_ne",...o&&{config:o}}),southArrowNorthWest:e=>({top:s(e),left:e.left+e.width/2-t,name:"arrow_nw",...o&&{config:o}}),southArrowNorthMiddleWest:(e,i)=>({top:s(e),left:e.left+e.width/2-.25*i.width-t,name:"arrow_nmw",...o&&{config:o}}),southArrowNorth:(e,t)=>({top:s(e),left:e.left+e.width/2-t.width/2,name:"arrow_n",...o&&{config:o}}),southArrowNorthMiddleEast:(e,i)=>({top:s(e),left:e.left+e.width/2-.75*i.width+t,name:"arrow_nme",...o&&{config:o}}),southArrowNorthEast:(e,i)=>({top:s(e),left:e.left+e.width/2-i.width+t,name:"arrow_ne",...o&&{config:o}}),southEastArrowNorthWest:e=>({top:s(e),left:e.right-t,name:"arrow_nw",...o&&{config:o}}),southEastArrowNorthMiddleWest:(e,i)=>({top:s(e),left:e.right-.25*i.width-t,name:"arrow_nmw",...o&&{config:o}}),southEastArrowNorth:(e,t)=>({top:s(e),left:e.right-t.width/2,name:"arrow_n",...o&&{config:o}}),southEastArrowNorthMiddleEast:(e,i)=>({top:s(e),left:e.right-.75*i.width+t,name:"arrow_nme",...o&&{config:o}}),southEastArrowNorthEast:(e,i)=>({top:s(e),left:e.right-i.width+t,name:"arrow_ne",...o&&{config:o}}),westArrowEast:(e,t)=>({top:e.top+e.height/2-t.height/2,left:e.left-t.width-i,name:"arrow_e",...o&&{config:o}}),eastArrowWest:(e,t)=>({top:e.top+e.height/2-t.height/2,left:e.right+i,name:"arrow_w",...o&&{config:o}}),viewportStickyNorth:(e,t,i)=>e.getIntersection(i)?{top:i.top+n,left:e.left+e.width/2-t.width/2,name:"arrowless",config:{withArrow:!1,...o}}:null};function r(e,t){return e.top-t.height-i}function s(e){return e.bottom+i}}Lf.arrowSideOffset=25,Lf.arrowHeightOffset=10,Lf.stickyVerticalOffset=20,Lf._getOptimalPosition=to,Lf.defaultPositions=zf();var jf=i(9721),Ff={attributes:{"data-cke":!0}};Ff.setAttributes=$o(),Ff.insert=Wo().bind(null,"head"),Ff.domAPI=Ho(),Ff.insertStyleElement=Go();jo()(jf.Z,Ff);jf.Z&&jf.Z.locals&&jf.Z.locals;const Hf="ck-tooltip";class Uf extends(Mn()){constructor(e){if(super(),this._currentElementWithTooltip=null,this._currentTooltipPosition=null,this._resizeObserver=null,Uf._editors.add(e),Uf._instance)return Uf._instance;Uf._instance=this,this.tooltipTextView=new Qo(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 Lf(e.locale),this.balloonPanelView.class=Hf,this.balloonPanelView.content.add(this.tooltipTextView),this._pinTooltipDebounced=Xr(this._pinTooltip,600),this.listenTo(Dn.document,"mouseenter",this._onEnterOrFocus.bind(this),{useCapture:!0}),this.listenTo(Dn.document,"mouseleave",this._onLeaveOrBlur.bind(this),{useCapture:!0}),this.listenTo(Dn.document,"focus",this._onEnterOrFocus.bind(this),{useCapture:!0}),this.listenTo(Dn.document,"blur",this._onLeaveOrBlur.bind(this),{useCapture:!0}),this.listenTo(Dn.document,"scroll",this._onScroll.bind(this),{useCapture:!0}),this._watchdogExcluded=!0}destroy(e){const t=e.ui.view&&e.ui.view.body;Uf._editors.delete(e),this.stopListening(e.ui),t&&t.has(this.balloonPanelView)&&t.remove(this.balloonPanelView),Uf._editors.size||(this._unpinTooltip(),this.balloonPanelView.destroy(),this.stopListening(),Uf._instance=null)}static getPositioningFunctions(e){const t=Uf.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]}_onEnterOrFocus(e,{target:t}){const i=Wf(t);var n;i&&(i!==this._currentElementWithTooltip&&(this._unpinTooltip(),this._pinTooltipDebounced(i,{text:(n=i).dataset.ckeTooltipText,position:n.dataset.ckeTooltipPosition||"s",cssClass:n.dataset.ckeTooltipClass||""})))}_onLeaveOrBlur(e,{target:t,relatedTarget:i}){if("mouseleave"===e.name){if(!En(t))return;if(this._currentElementWithTooltip&&t!==this._currentElementWithTooltip)return;const e=Wf(t),n=Wf(i);e&&e!==n&&this._unpinTooltip()}else{if(this._currentElementWithTooltip&&t!==this._currentElementWithTooltip)return;this._unpinTooltip()}}_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}){const o=Po(Uf._editors.values()).ui.view.body;o.has(this.balloonPanelView)||o.add(this.balloonPanelView),this.tooltipTextView.text=t,this.balloonPanelView.pin({target:e,positions:Uf.getPositioningFunctions(i)}),this._resizeObserver=new qn(e,(()=>{eo(e)||this._unpinTooltip()})),this.balloonPanelView.class=[Hf,n].filter((e=>e)).join(" ");for(const e of Uf._editors)this.listenTo(e.ui,"update",this._updateTooltipPosition.bind(this),{priority:"low"});this._currentElementWithTooltip=e,this._currentTooltipPosition=i}_unpinTooltip(){this._pinTooltipDebounced.cancel(),this.balloonPanelView.unpin();for(const e of Uf._editors)this.stopListening(e.ui,"update");this._currentElementWithTooltip=null,this._currentTooltipPosition=null,this._resizeObserver&&this._resizeObserver.destroy()}_updateTooltipPosition(){eo(this._currentElementWithTooltip)?this.balloonPanelView.pin({target:this._currentElementWithTooltip,positions:Uf.getPositioningFunctions(this._currentTooltipPosition)}):this._unpinTooltip()}}function Wf(e){return En(e)?e.closest("[data-cke-tooltip-text]:not([data-cke-tooltip-disabled])"):null}Uf.defaultBalloonPositions=zf({heightOffset:5,sideOffset:13}),Uf._editors=new Set,Uf._instance=null;const Zf=function(e,t,i){var n=!0,o=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return F(i)&&(n="leading"in i?!!i.leading:n,o="trailing"in i?!!i.trailing:o),Xr(e,t,{leading:n,maxWait:t,trailing:o})},$f=50,qf=350,Gf="Powered by",Kf={top:-99999,left:-99999,name:"invalid",config:{withArrow:!1}};class Yf extends(Mn()){constructor(e){super(),this.editor=e,this._balloonView=null,this._lastFocusedEditableElement=null,this._showBalloonThrottled=Zf(this._showBalloon.bind(this),50,{leading:!0}),e.on("ready",this._handleEditorReady.bind(this))}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"!==function(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("-"),o=n[0],r=n[1];if(!r)return t(e);try{atob(r)}catch(i){try{if(atob(o),!atob(o).length)return t(e)}catch(i){return t(e)}}if(o.length<40||o.length>255)return"INVALID";let s="";try{atob(o),s=atob(r)}catch(e){return"INVALID"}if(8!==s.length)return"INVALID";const a=Number(s.substring(0,4)),l=Number(s.substring(4,6))-1,c=Number(s.substring(6,8)),d=new Date(a,l,c);return d{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 Lf,i=Xf(e),n=new Qf(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=Xf(e),n="right"===i.side?function(e,t){return Jf(e,t,((e,i)=>e.left+e.width-i.width-t.horizontalOffset))}(t,i):function(e,t){return Jf(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]}}class Qf extends Qo{constructor(e,t){super(e);const i=new yr,n=this.bindTemplate;i.set({content:'\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 Jf(e,t,i){return(n,o)=>{const r=n.getVisible();if(!r)return Kf;if(n.widthe.bottom)return Kf}}return{top:s,left:a,name:`position_${t.position}-side_${t.side}`,config:{withArrow:!1}}}}function Xf(e){const t=e.config.get("ui.poweredBy"),i=t&&t.position||"border";return{position:i,label:Gf,verticalOffset:"inside"===i?5:0,horizontalOffset:5,side:"ltr"===e.locale.contentLanguageDirection?"right":"left",...t}}class eg extends(G()){constructor(e){super(),this.isReady=!1,this._editableElementsMap=new Map,this._focusableToolbarDefinitions=[];const t=e.editing.view;this.editor=e,this.componentFactory=new Of(e),this.focusTracker=new Io,this.tooltipManager=new Uf(e),this.poweredBy=new Yf(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()}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,o)=>{const r=this.focusTracker.focusedElement;Array.from(this._editableElementsMap.values()).includes(r)&&!Array.from(t.domRoots.values()).includes(r)&&(i=r);const s=this._getCurrentFocusedToolbarDefinition();s&&n||(n=this._getFocusableCandidateToolbarDefinitions());for(let e=0;e{const o=this._getCurrentFocusedToolbarDefinition();o&&(i?(i.focus(),i=null):e.editing.view.focus(),o.options.afterBlur&&o.options.afterBlur(),n())}))}_getFocusableCandidateToolbarDefinitions(){const e=[];for(const t of this._focusableToolbarDefinitions){const{toolbarView:i,options:n}=t;(eo(i.element)||n.beforeFocus)&&e.push(t)}return e.sort(((e,t)=>tg(e)-tg(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(),!!eo(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}}function tg(e){const{toolbarView:t,options:i}=e;let n=10;return eo(t.element)&&n--,i.isContextual&&n--,n}var ig=i(7456),ng={attributes:{"data-cke":!0}};ng.setAttributes=$o(),ng.insert=Wo().bind(null,"head"),ng.domAPI=Ho(),ng.insertStyleElement=Go();jo()(ig.Z,ng);ig.Z&&ig.Z.locals&&ig.Z.locals;class og extends Qo{constructor(e){super(e),this.body=new kr(e)}render(){super.render(),this.body.attachToDom()}destroy(){return this.body.detachFromDom(),super.destroy()}}class rg extends og{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}]})}_createVoiceLabel(){const e=this.t,t=new is;return t.text=e("Rich Text Editor"),t.extendTemplate({attributes:{class:"ck-voice-label"}}),t}}class sg extends Qo{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}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,o,r)=>{r?i(n):t(n)}))}(this):t(this)}}class ag extends sg{constructor(e,t,i,n={}){super(e,t,i);const o=e.t;this.extendTemplate({attributes:{role:"textbox",class:"ck-editor__editable_inline"}}),this._generateLabel=n.label||(()=>o("Editor editing area: %0",this.name))}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)}))}}var lg=i(7641),cg={attributes:{"data-cke":!0}};cg.setAttributes=$o(),cg.insert=Wo().bind(null,"head"),cg.domAPI=Ho(),cg.insertStyleElement=Go();jo()(lg.Z,cg);lg.Z&&lg.Z.locals&&lg.Z.locals;class dg extends Ts{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 ug extends(G()){constructor(e,t){super(),t&&nc(this,t),e&&this.set(e)}}var hg=i(395),mg={attributes:{"data-cke":!0}};mg.setAttributes=$o(),mg.insert=Wo().bind(null,"head"),mg.domAPI=Ho(),mg.insertStyleElement=Go();jo()(hg.Z,mg);hg.Z&&hg.Z.locals&&hg.Z.locals;var fg=i(5078),gg={attributes:{"data-cke":!0}};gg.setAttributes=$o(),gg.insert=Wo().bind(null,"head"),gg.domAPI=Ho(),gg.insertStyleElement=Go();jo()(fg.Z,gg);fg.Z&&fg.Z.locals&&fg.Z.locals;const pg=Kn("px");class bg extends vs{static get pluginName(){return"ContextualBalloon"}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)}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 y("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 y("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 y("contextualballoon-showstack-stack-not-exist",this);this._visibleStack!==t&&this._showView(Array.from(t.values()).pop())}_createPanelView(){this._view=new Lf(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 wg(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 kg(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}}class wg extends Qo{constructor(e){super(e);const t=e.t,i=this.bindTemplate;this.set("isNavigationVisible",!0),this.focusTracker=new Io,this.buttonPrevView=this._createButtonView(t("Previous"),''),this.buttonNextView=this._createButtonView(t("Next"),''),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}]})}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 Er(this.locale);return i.set({label:e,icon:t,tooltip:!0}),i}}class kg extends Qo{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",pg),left:i.to("left",pg),width:i.to("width",pg),height:i.to("height",pg)}},children:this.content}),this.on("change:numberOfPanels",((e,t,i,n)=>{i>n?this._addPanels(i-n):this._removePanels(n-i),this.updatePosition()}))}_addPanels(e){for(;e--;){const e=new Qo;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 Hn(this._balloonPanelView.element);Object.assign(this,{top:e,left:t,width:i,height:n})}}}var _g=i(3846),vg={attributes:{"data-cke":!0}};vg.setAttributes=$o(),vg.insert=Wo().bind(null,"head"),vg.domAPI=Ho(),vg.insertStyleElement=Go();jo()(_g.Z,vg);_g.Z&&_g.Z.locals&&_g.Z.locals;const yg=Kn("px");class Ag extends Qo{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("_isStickyToTheLimiter",!1),this.set("_hasViewportTopOffset",!1),this.content=this.createCollection(),this._contentPanelPlaceholder=new Jo({tag:"div",attributes:{class:["ck","ck-sticky-panel__placeholder"],style:{display:t.to("isSticky",(e=>e?"block":"none")),height:t.to("isSticky",(e=>e?yg(this._panelRect.height):null))}}}).render(),this._contentPanel=new Jo({tag:"div",attributes:{class:["ck","ck-sticky-panel__content",t.if("isSticky","ck-sticky-panel__content_sticky"),t.if("_isStickyToTheLimiter","ck-sticky-panel__content_sticky_bottom-limit")],style:{width:t.to("isSticky",(e=>e?yg(this._contentPanelPlaceholder.getBoundingClientRect().width):null)),top:t.to("_hasViewportTopOffset",(e=>e?yg(this.viewportTopOffset):null)),bottom:t.to("_isStickyToTheLimiter",(e=>e?yg(this.limiterBottomOffset):null)),marginLeft:t.to("_marginLeft")}},children:this.content}).render(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-sticky-panel"]},children:[this._contentPanelPlaceholder,this._contentPanel]})}render(){super.render(),this._checkIfShouldBeSticky(),this.listenTo(Dn.window,"scroll",(()=>{this._checkIfShouldBeSticky()})),this.listenTo(this,"change:isActive",(()=>{this._checkIfShouldBeSticky()}))}_checkIfShouldBeSticky(){const e=this._panelRect=this._contentPanel.getBoundingClientRect();let t;this.limiterElement?(t=this._limiterRect=this.limiterElement.getBoundingClientRect(),this.isSticky=this.isActive&&t.tope||0)),e.toolbar.fillFromConfig(this._toolbarConfig,this.componentFactory),this.addToolbar(e.toolbar)}_initPlaceholder(){const e=this.editor,t=e.editing.view,i=t.document.getRoot(),n=e.sourceElement;let o;const r=e.config.get("placeholder");r&&(o="string"==typeof r?r:r[this.view.editable.name]),!o&&n&&"textarea"===n.tagName.toLowerCase()&&(o=n.getAttribute("placeholder")),o&&Ms({view:t,element:i,text:o,isDirectHost:!1,keepOnFocus:!0})}_handleScrollToTheSelectionWithStickyPanel(e,t,i){const n=this.view.stickyPanel;if(n.isSticky){const e=new Hn(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)}}}var Pg=i(4090),Ig={attributes:{"data-cke":!0}};Ig.setAttributes=$o(),Ig.insert=Wo().bind(null,"head"),Ig.domAPI=Ho(),Ig.insertStyleElement=Go();jo()(Pg.Z,Ig);Pg.Z&&Pg.Z.locals&&Pg.Z.locals;class Og extends rg{constructor(e,t,i={}){super(e),this.stickyPanel=new Ag(e),this.toolbar=new Em(e,{shouldGroupWhenFull:i.shouldToolbarGroupWhenFull}),this.editable=new ag(e,t)}render(){super.render(),this.stickyPanel.content.add(this.toolbar),this.top.add(this.stickyPanel),this.main.add(this.editable)}}class Mg{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.")}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}}function Rg(e,t=new Set){const i=[e],n=new Set;let o=0;for(;i.length>o;){const e=i[o++];if(!n.has(e)&&Ng(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 Ng(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 Vg(e,t,i=new Set){if(e===t&&("object"==typeof(n=e)&&null!==n))return!0;var n;const o=Rg(e,i),r=Rg(t,i);for(const e of o)if(r.has(e))return!0;return!1}class Dg extends Mg{constructor(e,t={}){super(t),this._editor=null,this._throttledSave=Zf(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()}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((()=>{if("string"==typeof this._elementOrData)return this.create(this._data,this._config,this._config.context);{const e=Object.assign({},this._config,{initialData:this._data});return this.create(this._elementOrData,e,e.context)}})).then((()=>{this._fire("restart")}))}create(e=this._elementOrData,t=this._config,i){return Promise.resolve().then((()=>(super._startErrorHandling(),this._elementOrData=e,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.state="ready",this._fire("stateChange")}))}destroy(){return Promise.resolve().then((()=>(this.state="destroyed",this._fire("stateChange"),super.destroy(),this._destroy())))}_destroy(){return Promise.resolve().then((()=>{this._stopErrorHandling(),this._throttledSave.flush();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._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={};for(const t of this._editor.model.document.getRootNames())e[t]=this._editor.data.get({rootName:t});return e}_isErrorComingFromThisItem(e){return Vg(this._editor,e.context,this._excludedProps)}_cloneEditorConfiguration(e){return xn(e,((e,t)=>En(e)||"context"===t?e:void 0))}}const Lg=Symbol("MainQueueId");class Bg{constructor(){this._onEmptyCallbacks=[],this._queues=new Map,this._activeActions=0}onEmpty(e){this._onEmptyCallbacks.push(e)}enqueue(e,t){const i=e===Lg;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(Lg),this._queues.get(e)])).then(t),o=n.catch((()=>{}));return this._queues.set(e,o),n.finally((()=>{this._activeActions--,this._queues.get(e)===o&&0===this._activeActions&&this._onEmptyCallbacks.forEach((e=>e()))}))}}function zg(e){return Array.isArray(e)?e:[e]}class jg extends(gm(pm(fm))){constructor(e,t={}){if(!Fg(e)&&void 0!==t.initialData)throw new y("editor-create-initial-data",null);super(t),void 0===this.config.get("initialData")&&this.config.set("initialData",function(e){return Fg(e)?(t=e,t instanceof HTMLTextAreaElement?t.value:t.innerHTML):e;var t}(e)),Fg(e)&&(this.sourceElement=e),this.model.document.createRoot();const i=!this.config.get("toolbar.shouldNotGroupWhenFull"),n=new Og(this.locale,this.editing.view,{shouldToolbarGroupWhenFull:i});this.ui=new Tg(this,n),function(e){if(!Ue(e.updateSourceElement))throw new y("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,o=()=>e.updateSourceElement();Ue(n.submit)&&(i=n.submit,n.submit=()=>{o(),i.apply(n)}),n.addEventListener("submit",o),e.on("destroy",(()=>{n.removeEventListener("submit",o),i&&(n.submit=i)}))}}(this)}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(Fg(e)?e:null))).then((()=>n.data.init(n.config.get("initialData")))).then((()=>n.fire("ready"))).then((()=>n)))}))}}function Fg(e){return En(e)}jg.Context=Ss,jg.EditorWatchdog=Dg,jg.ContextWatchdog=class extends Mg{constructor(e,t={}){super(t),this._watchdogs=new Map,this._context=null,this._contextProps=new Set,this._actionQueues=new Bg,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"))}))}setCreator(e){this._creator=e}setDestructor(e){this._destructor=e}get context(){return this._context}create(e={}){return this._actionQueues.enqueue(Lg,(()=>(this._contextConfig=e,this._create())))}getItem(e){return this._getWatchdog(e)._item}getItemState(e){return this._getWatchdog(e).state}add(e){const t=zg(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 Dg(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:o})=>{this._fire("itemError",{itemId:e.id,error:n}),o&&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=zg(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(Lg,(()=>(this.state="destroyed",this._fire("stateChange"),super.destroy(),this._destroy())))}_restart(){return this._actionQueues.enqueue(Lg,(()=>(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=Rg(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 Vg(this._context,e.context)}};class Hg{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)}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)}}class Ug extends As{constructor(e,t){super(e),this._buffer=new Hg(e.model,t),this._isEnabledBasedOnSelection=!1}get buffer(){return this._buffer}destroy(){super.destroy(),this._buffer.destroy()}execute(e={}){const t=this.editor.model,i=t.document,n=e.text||"",o=n.length;let r=i.selection;if(e.selection?r=e.selection:e.range&&(r=t.createSelection(e.range)),!t.canEditAt(r))return;const s=e.resultRange;t.enqueueChange(this._buffer.batch,(e=>{this._buffer.lock(),t.deleteContent(r),n&&t.insertContent(e.createText(n,i.selection.getAttributes()),r),s?e.setSelection(s):r.is("documentSelection")||e.setSelection(r),this._buffer.unlock(),this._buffer.input(o)}))}}const Wg=["insertText","insertReplacementText"];class Zg extends ic{constructor(e){super(e),c.isAndroid&&Wg.push("insertCompositionText");const t=e.document;t.on("beforeinput",((i,n)=>{if(!this.isEnabled)return;const{data:o,targetRanges:r,inputType:s,domEvent:a}=n;if(!Wg.includes(s))return;const l=new p(t,"insertText");t.fire(l,new oc(e,a,{text:o,selection:e.createSelection(r)})),l.stop.called&&i.stop()})),t.on("compositionend",((i,{data:n,domEvent:o})=>{this.isEnabled&&!c.isAndroid&&n&&t.fire("insertText",new oc(e,o,{text:n,selection:t.selection}))}),{priority:"lowest"})}observe(){}stopObserving(){}}class $g extends vs{static get pluginName(){return"Input"}init(){const e=this.editor,t=e.model,i=e.editing.view,n=t.document.selection;i.addObserver(Zg);const o=new Ug(e,e.config.get("typing.undoStep")||20);e.commands.add("insertText",o),e.commands.add("input",o),this.listenTo(i.document,"insertText",((n,o)=>{i.document.isComposing||o.preventDefault();const{text:r,selection:s,resultRange:a}=o,l=Array.from(s.getRanges()).map((t=>e.editing.mapper.toModelRange(t)));let d=r;if(c.isAndroid){const e=Array.from(l[0].getItems()).reduce(((e,t)=>e+(t.is("$textProxy")?t.data:"")),"");e&&(e.length<=d.length?d.startsWith(e)&&(d=d.substring(e.length),l[0].start=l[0].start.getShiftedBy(e.length)):e.startsWith(d)&&(l[0].start=l[0].start.getShiftedBy(d.length),d=""))}const u={text:d,selection:t.createSelection(l)};a&&(u.resultRange=e.editing.mapper.toModelRange(a)),e.execute("insertText",u)})),c.isAndroid?this.listenTo(i.document,"keydown",((e,r)=>{!n.isCollapsed&&229==r.keyCode&&i.document.isComposing&&qg(t,o)})):this.listenTo(i.document,"compositionstart",(()=>{n.isCollapsed||qg(t,o)}))}}function qg(e,t){if(!t.isEnabled)return;const i=t.buffer;i.lock(),e.enqueueChange(i.batch,(()=>{e.deleteContent(e.document.selection)})),i.unlock()}class Gg extends As{constructor(e,t){super(e),this.direction=t,this._buffer=new Hg(e.model,e.config.get("typing.undoStep")),this._isEnabledBasedOnSelection=!1}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 o=n.createSelection(e.selection||i.selection);if(!t.canEditAt(o))return;const r=e.sequence||1,s=o.isCollapsed;if(o.isCollapsed&&t.modifySelection(o,{direction:this.direction,unit:e.unit,treatEmojiAsSingleUnit:!0}),this._shouldEntireContentBeReplacedWithParagraph(r))return void this._replaceEntireContentWithParagraph(n);if(this._shouldReplaceFirstBlockWithParagraph(o,r))return void this.editor.execute("paragraph",{selection:o});if(o.isCollapsed)return;let a=0;o.getFirstRange().getMinimalFlatRanges().forEach((e=>{a+=te(e.getWalker({singleCharacters:!0,ignoreElementEnd:!0,shallow:!0}))})),t.deleteContent(o,{doNotResetEntireContent:s,direction:this.direction}),this._buffer.input(a),n.setSelection(o),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 o=n.getChild(0);return!o||!o.is("element","paragraph")}_replaceEntireContentWithParagraph(e){const t=this.editor.model,i=t.document.selection,n=t.schema.getLimitElement(i),o=e.createElement("paragraph");e.remove(e.createRangeIn(n)),e.insert(o,n),e.setSelection(o,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(),o=i.schema.getLimitElement(n),r=o.getChild(0);return n.parent==r&&(!!e.containsEntireContent(r)&&(!!i.schema.checkChild(o,"paragraph")&&"paragraph"!=r.name))}}const Kg="word",Yg="selection",Qg="backward",Jg="forward",Xg={deleteContent:{unit:Yg,direction:Qg},deleteContentBackward:{unit:"codePoint",direction:Qg},deleteWordBackward:{unit:Kg,direction:Qg},deleteHardLineBackward:{unit:Yg,direction:Qg},deleteSoftLineBackward:{unit:Yg,direction:Qg},deleteContentForward:{unit:"character",direction:Jg},deleteWordForward:{unit:Kg,direction:Jg},deleteHardLineForward:{unit:Yg,direction:Jg},deleteSoftLineForward:{unit:Yg,direction:Jg}};class ep extends ic{constructor(e){super(e);const t=e.document;let i=0;t.on("keydown",(()=>{i++})),t.on("keyup",(()=>{i=0})),t.on("beforeinput",((n,o)=>{if(!this.isEnabled)return;const{targetRanges:r,domEvent:s,inputType:a}=o,l=Xg[a];if(!l)return;const d={direction:l.direction,unit:l.unit,sequence:i};d.unit==Yg&&(d.selectionToRemove=e.createSelection(r[0])),"deleteContentBackward"===a&&(c.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(No(t,n)||Vo(t,n)||Lo(t,n))continue;i++}else i++;if(i>1)return!0}return!1}(r)&&(d.unit=Yg,d.selectionToRemove=e.createSelection(r)));const u=new el(t,"delete",r[0]);t.fire(u,new oc(e,s,d)),u.stop.called&&n.stop()})),c.isBlink&&function(e){const t=e.view,i=t.document;let n=null,o=!1;function r(e){return e==bo.backspace||e==bo.delete}function s(e){return e==bo.backspace?Qg:Jg}i.on("keydown",((e,{keyCode:t})=>{n=t,o=!1})),i.on("keyup",((a,{keyCode:l,domEvent:c})=>{const d=i.selection,u=e.isEnabled&&l==n&&r(l)&&!d.isCollapsed&&!o;if(n=null,u){const e=d.getFirstRange(),n=new el(i,"delete",e),o={unit:Yg,direction:s(l),selectionToRemove:d};i.fire(n,new oc(t,c,o))}})),i.on("beforeinput",((e,{inputType:t})=>{const i=Xg[t];r(n)&&i&&i.direction==s(n)&&(o=!0)}),{priority:"high"}),i.on("beforeinput",((e,{inputType:t,data:i})=>{n==bo.delete&&"insertText"==t&&""==i&&e.stop()}),{priority:"high"})}(this)}observe(){}stopObserving(){}}class tp extends vs{static get pluginName(){return"Delete"}init(){const e=this.editor,t=e.editing.view,i=t.document,n=e.model.document;t.addObserver(ep),this._undoOnBackspace=!1;const o=new Gg(e,"forward");e.commands.add("deleteForward",o),e.commands.add("forwardDelete",o),e.commands.add("delete",new Gg(e,"backward")),this.listenTo(i,"delete",((n,o)=>{i.isComposing||o.preventDefault();const{direction:r,sequence:s,selectionToRemove:a,unit:l}=o,c="forward"===r?"deleteForward":"delete",d={sequence:s};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 ip extends vs{static get requires(){return[$g,tp]}static get pluginName(){return"Typing"}}function np(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 op extends(G()){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()}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,o=i.createRange(i.createPositionAt(n.focus.parent,0),n.focus),{text:r,range:s}=np(o,i),a=this.testCallback(r);if(!a&&this.hasMatch&&this.fire("unmatched"),this._hasMatch=!!a,a){const i=Object.assign(t,{text:r,range:s});"object"==typeof a&&Object.assign(i,a),this.fire(`matched:${e}`,i)}}}class rp extends vs{static get pluginName(){return"TwoStepCaretMovement"}constructor(e){super(e),this.attributes=new Set,this._overrideUid=null}init(){const e=this.editor,t=e.model,i=e.editing.view,n=e.locale,o=t.document.selection;this.listenTo(i.document,"arrowKey",((e,t)=>{if(!o.isCollapsed)return;if(t.shiftKey||t.altKey||t.ctrlKey)return;const i=t.keyCode==bo.arrowright,r=t.keyCode==bo.arrowleft;if(!i&&!r)return;const s=n.contentLanguageDirection;let a=!1;a="ltr"===s&&i||"rtl"===s&&r?this._handleForwardMovement(t):this._handleBackwardMovement(t),!0===a&&e.stop()}),{context:"$text",priority:"highest"}),this._isNextGravityRestorationSkipped=!1,this.listenTo(o,"change:range",((e,t)=>{this._isNextGravityRestorationSkipped?this._isNextGravityRestorationSkipped=!1:this._isGravityOverridden&&(!t.directChange&&cp(o.getFirstPosition(),this.attributes)||this._restoreGravity())}))}registerAttribute(e){this.attributes.add(e)}_handleForwardMovement(e){const t=this.attributes,i=this.editor.model.document.selection,n=i.getFirstPosition();return!this._isGravityOverridden&&((!n.isAtStart||!sp(i,t))&&(!!cp(n,t)&&(lp(e),this._overrideGravity(),!0)))}_handleBackwardMovement(e){const t=this.attributes,i=this.editor.model,n=i.document.selection,o=n.getFirstPosition();return this._isGravityOverridden?(lp(e),this._restoreGravity(),ap(i,t,o),!0):o.isAtStart?!!sp(n,t)&&(lp(e),ap(i,t,o),!0):!!function(e,t){const i=e.getShiftedBy(-1);return cp(i,t)}(o,t)&&(o.isAtEnd&&!sp(n,t)&&cp(o,t)?(lp(e),ap(i,t,o),!0):(this._isNextGravityRestorationSkipped=!0,this._overrideGravity(),!1))}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}))}}function sp(e,t){for(const i of t)if(e.hasAttribute(i))return!0;return!1}function ap(e,t,i){const n=i.nodeBefore;e.change((e=>{n?e.setSelectionAttribute(n.getAttributes()):e.removeSelectionAttribute(t)}))}function lp(e){e.preventDefault()}function cp(e,t){const{nodeBefore:i,nodeAfter:n}=e;for(const e of t){const t=i?i.getAttribute(e):void 0;if((n?n.getAttribute(e):void 0)!==t)return!0}return!1}dp('"'),dp("'"),dp("'"),dp('"'),dp('"'),dp("'");function dp(e){return new RegExp(`(^|\\s)(${e})([^${e}]*)(${e})$`)}function up(e,t,i,n){return n.createRange(hp(e,t,i,!0,n),hp(e,t,i,!1,n))}function hp(e,t,i,n,o){let r=e.textNode||(n?e.nodeBefore:e.nodeAfter),s=null;for(;r&&r.getAttribute(t)==i;)s=r,r=n?r.previousSibling:r.nextSibling;return s?o.createPositionAt(s,n?"before":"after"):e}function mp(e,t,i,n){const o=e.editing.view,r=new Set;o.document.registerPostFixer((o=>{const s=e.model.document.selection;let a=!1;if(s.hasAttribute(t)){const l=up(s.getFirstPosition(),t,s.getAttribute(t),e.model),c=e.editing.mapper.toViewRange(l);for(const e of c.getItems())e.is("element",i)&&!e.hasClass(n)&&(o.addClass(n,e),r.add(e),a=!0)}return a})),e.conversion.for("editingDowncast").add((e=>{function t(){o.change((e=>{for(const t of r.values())e.removeClass(n,t),r.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*fp(e,t){for(const i of t)i&&e.getAttributeProperties(i[0]).copyOnEnter&&(yield i)}class gp extends As{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,o=i.isCollapsed,r=i.getFirstRange(),s=r.start.parent,a=r.end.parent;if(n.isLimit(s)||n.isLimit(a))return o||s!=a||t.deleteContent(i),!1;if(o){const t=fp(e.model.schema,i.getAttributes());return pp(e,r.start),e.setSelectionAttribute(t),!0}{const n=!(r.start.isAtStart&&r.end.isAtEnd),o=s==a;if(t.deleteContent(i,{leaveUnmerged:n}),n){if(o)return pp(e,i.focus),!0;e.setSelection(a,0)}}return!1}}function pp(e,t){e.split(t),e.setSelection(t.parent.nextSibling,0)}const bp={insertParagraph:{isSoft:!1},insertLineBreak:{isSoft:!0}};class wp extends ic{constructor(e){super(e);const t=this.document;let i=!1;t.on("keydown",((e,t)=>{i=t.shiftKey})),t.on("beforeinput",((n,o)=>{if(!this.isEnabled)return;let r=o.inputType;c.isSafari&&i&&"insertParagraph"==r&&(r="insertLineBreak");const s=o.domEvent,a=bp[r];if(!a)return;const l=new el(t,"enter",o.targetRanges[0]);t.fire(l,new oc(e,s,{isSoft:a.isSoft})),l.stop.called&&n.stop()}))}observe(){}stopObserving(){}}class kp extends vs{static get pluginName(){return"Enter"}init(){const e=this.editor,t=e.editing.view,i=t.document;t.addObserver(wp),e.commands.add("enter",new gp(e)),this.listenTo(i,"enter",((n,o)=>{i.isComposing||o.preventDefault(),o.isSoft||(e.execute("enter"),t.scrollToTheSelection())}),{priority:"low"})}}class _p extends As{execute(){const e=this.editor.model,t=e.document;e.change((i=>{!function(e,t,i){const n=i.isCollapsed,o=i.getFirstRange(),r=o.start.parent,s=o.end.parent,a=r==s;if(n){const n=fp(e.schema,i.getAttributes());vp(e,t,o.end),t.removeSelectionAttribute(i.getAttributeKeys()),t.setSelectionAttribute(n)}else{const n=!(o.start.isAtStart&&o.end.isAtEnd);e.deleteContent(i,{leaveUnmerged:n}),a?vp(e,t,i.focus):n&&t.setSelection(s,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(),o=n.start.parent,r=n.end.parent;if((yp(o,e)||yp(r,e))&&o!==r)return!1;return!0}(e.schema,t.selection)}}function vp(e,t,i){const n=t.createElement("softBreak");e.insertContent(n,i),t.setSelection(n,"after")}function yp(e,t){return!e.is("rootElement")&&(t.isLimit(e)||yp(e.parent,t))}class Ap extends vs{static get pluginName(){return"ShiftEnter"}init(){const e=this.editor,t=e.model.schema,i=e.conversion,n=e.editing.view,o=n.document;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(wp),e.commands.add("shiftEnter",new _p(e)),this.listenTo(o,"enter",((t,i)=>{o.isComposing||i.preventDefault(),i.isSoft&&(e.execute("shiftEnter"),n.scrollToTheSelection())}),{priority:"low"})}}class xp extends(R()){constructor(){super(...arguments),this._stack=[]}add(e,t){const i=this._stack,n=i[0];this._insertDescriptor(e);const o=i[0];n===o||Ep(n,o)||this.fire("change:top",{oldDescriptor:n,newDescriptor:o,writer:t})}remove(e,t){const i=this._stack,n=i[0];this._removeDescriptor(e);const o=i[0];n===o||Ep(n,o)||this.fire("change:top",{oldDescriptor:n,newDescriptor:o,writer:t})}_insertDescriptor(e){const t=this._stack,i=t.findIndex((t=>t.id===e.id));if(Ep(e,t[i]))return;i>-1&&t.splice(i,1);let n=0;for(;t[n]&&Cp(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)}}function Ep(e,t){return e&&t&&e.priority==t.priority&&Sp(e.classes)==Sp(t.classes)}function Cp(e,t){return e.priority>t.priority||!(e.prioritySp(t.classes)}function Sp(e){return Array.isArray(e)?e.sort().join(","):e}const Tp='',Pp="ck-widget",Ip="ck-widget_selected";function Op(e){return!!e.is("element")&&!!e.getCustomProperty("widget")}function Mp(e,t,i={}){if(!e.is("containerElement"))throw new y("widget-to-widget-wrong-element-type",null,{element:e});return t.setAttribute("contenteditable","false",e),t.addClass(Pp,e),t.setCustomProperty("widget",!0,e),e.getFillerOffset=Bp,t.setCustomProperty("widgetLabel",[],e),i.label&&function(e,t){const i=e.getCustomProperty("widgetLabel");i.push(t)}(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 yr;return i.set("content",Tp),i.render(),t.appendChild(i.element),t}));t.insert(t.createPositionAt(e,0),i),t.addClass(["ck-widget_with-selection-handle"],e)}(e,t),Vp(e,t),e}function Rp(e,t,i){if(t.classes&&i.addClass(Eo(t.classes),e),t.attributes)for(const n in t.attributes)i.setAttribute(n,t.attributes[n],e)}function Np(e,t,i){if(t.classes&&i.removeClass(Eo(t.classes),e),t.attributes)for(const n in t.attributes)i.removeAttribute(n,e)}function Vp(e,t,i=Rp,n=Np){const o=new xp;o.on("change:top",((t,o)=>{o.oldDescriptor&&n(e,o.oldDescriptor,o.writer),o.newDescriptor&&i(e,o.newDescriptor,o.writer)}));t.setCustomProperty("addHighlight",((e,t,i)=>o.add(t,i)),e),t.setCustomProperty("removeHighlight",((e,t,i)=>o.remove(t,i)),e)}function Dp(e,t,i={}){return t.addClass(["ck-editor__editable","ck-editor__nested-editable"],e),t.setAttribute("role","textbox",e),i.label&&t.setAttribute("aria-label",i.label,e),t.setAttribute("contenteditable",e.isReadOnly?"false":"true",e),e.on("change:isReadOnly",((i,n,o)=>{t.setAttribute("contenteditable",o?"false":"true",e)})),e.on("change:isFocused",((i,n,o)=>{o?t.addClass("ck-editor__nested-editable_focused",e):t.removeClass("ck-editor__nested-editable_focused",e)})),Vp(e,t),e}function Lp(e,t){const i=e.getSelectedElement();if(i){const n=Fp(e);if(n)return t.createRange(t.createPositionAt(i,n))}return Oh(e,t)}function Bp(){return null}const zp="widget-type-around";function jp(e,t,i){return!!e&&Op(e)&&!i.isInline(t)}function Fp(e){return e.getAttribute(zp)}var Hp=i(5485),Up={attributes:{"data-cke":!0}};Up.setAttributes=$o(),Up.insert=Wo().bind(null,"head"),Up.domAPI=Ho(),Up.insertStyleElement=Go();jo()(Hp.Z,Up);Hp.Z&&Hp.Z.locals&&Hp.Z.locals;const Wp=["before","after"],Zp=(new DOMParser).parseFromString('',"image/svg+xml").firstChild,$p="ck-widget__type-around_disabled";class qp extends vs{constructor(){super(...arguments),this._currentFakeCaretModelElement=null}static get pluginName(){return"WidgetTypeAround"}static get requires(){return[kp,tp]}init(){const e=this.editor,t=e.editing.view;this.on("change:isEnabled",((i,n,o)=>{t.change((e=>{for(const i of t.document.roots)o?e.removeClass($p,i):e.addClass($p,i)})),o||e.model.change((e=>{e.removeSelectionAttribute(zp)}))})),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,o=i.model.schema.getAttributesWithProperty(e,"copyOnReplace",!0);i.execute("insertParagraph",{position:i.model.createPositionAt(e,t),attributes:o}),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=Fp(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,o,r)=>{const s=r.mapper.toViewElement(o.item);if(s&&jp(s,o.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 Wp){const n=new Jo({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(Zp,!0)]});e.appendChild(n.render())}}(i,t),function(e){const t=new Jo({tag:"div",attributes:{class:["ck","ck-widget__type-around__fake-caret"]}});e.appendChild(t.render())}(i),i}));e.insert(e.createPositionAt(i,"end"),n)}(r.writer,n,s);s.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,o=e.editing.view;function r(e){return`ck-widget_type-around_show-fake-caret_${e}`}this._listenToIfEnabled(o.document,"arrowKey",((e,t)=>{this._handleArrowKeyPress(e,t)}),{context:[Op,"$text"],priority:"high"}),this._listenToIfEnabled(i,"change:range",((t,i)=>{i.directChange&&e.model.change((e=>{e.removeSelectionAttribute(zp)}))})),this._listenToIfEnabled(t.document,"change:data",(()=>{const t=i.getSelectedElement();if(t){if(jp(e.editing.mapper.toViewElement(t),t,n))return}e.model.change((e=>{e.removeSelectionAttribute(zp)}))})),this._listenToIfEnabled(e.editing.downcastDispatcher,"selection",((e,t,i)=>{const o=i.writer;if(this._currentFakeCaretModelElement){const e=i.mapper.toViewElement(this._currentFakeCaretModelElement);e&&(o.removeClass(Wp.map(r),e),this._currentFakeCaretModelElement=null)}const s=t.selection.getSelectedElement();if(!s)return;const a=i.mapper.toViewElement(s);if(!jp(a,s,n))return;const l=Fp(t.selection);l&&(o.addClass(r(l),a),this._currentFakeCaretModelElement=s)})),this._listenToIfEnabled(e.ui.focusTracker,"change:isFocused",((t,i,n)=>{n||e.model.change((e=>{e.removeSelectionAttribute(zp)}))}))}_handleArrowKeyPress(e,t){const i=this.editor,n=i.model,o=n.document.selection,r=n.schema,s=i.editing.view,a=function(e,t){const i=yo(e,t);return"down"===i||"right"===i}(t.keyCode,i.locale.contentLanguageDirection),l=s.document.selection.getSelectedElement();let c;jp(l,i.editing.mapper.toModelElement(l),r)?c=this._handleArrowKeyPressOnSelectedWidget(a):o.isCollapsed?c=this._handleArrowKeyPressWhenSelectionNextToAWidget(a):t.shiftKey||(c=this._handleArrowKeyPressWhenNonCollapsedSelection(a)),c&&(t.preventDefault(),e.stop())}_handleArrowKeyPressOnSelectedWidget(e){const t=this.editor.model,i=Fp(t.document.selection);return t.change((t=>{if(!i)return t.setSelectionAttribute(zp,e?"after":"before"),!0;if(!(i===(e?"after":"before")))return t.removeSelectionAttribute(zp),!0;return!1}))}_handleArrowKeyPressWhenSelectionNextToAWidget(e){const t=this.editor,i=t.model,n=i.schema,o=t.plugins.get("Widget"),r=o._getObjectElementNextToSelection(e);return!!jp(t.editing.mapper.toViewElement(r),r,n)&&(i.change((t=>{o._setSelectionOverElement(r),t.setSelectionAttribute(zp,e?"before":"after")})),!0)}_handleArrowKeyPressWhenNonCollapsedSelection(e){const t=this.editor,i=t.model,n=i.schema,o=t.editing.mapper,r=i.document.selection,s=e?r.getLastPosition().nodeBefore:r.getFirstPosition().nodeAfter;return!!jp(o.toViewElement(s),s,n)&&(i.change((t=>{t.setSelection(s,"on"),t.setSelectionAttribute(zp,e?"after":"before")})),!0)}_enableInsertingParagraphsOnButtonClick(){const e=this.editor,t=e.editing.view;this._listenToIfEnabled(t.document,"mousedown",((i,n)=>{const o=n.domTarget.closest(".ck-widget__type-around__button");if(!o)return;const r=function(e){return e.classList.contains("ck-widget__type-around__button_before")?"before":"after"}(o),s=function(e,t){const i=e.closest(".ck-widget");return t.mapDomToView(i)}(o,t.domConverter),a=e.editing.mapper.toModelElement(s);this._insertParagraph(a,r),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 o=t.getSelectedElement(),r=e.editing.mapper.toViewElement(o),s=e.model.schema;let a;this._insertParagraphAccordingToFakeCaretPosition()?a=!0:jp(r,o,s)&&(this._insertParagraph(o,n.isSoft?"before":"after"),a=!0),a&&(n.preventDefault(),i.stop())}),{context:Op})}_enableInsertingParagraphsOnTypingKeystroke(){const e=this.editor.editing.view.document;this._listenToIfEnabled(e,"insertText",((t,i)=>{this._insertParagraphAccordingToFakeCaretPosition()&&(i.selection=e.selection)}),{priority:"high"}),c.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,o)=>{if("atTarget"!=t.eventPhase)return;const r=Fp(i.document.selection);if(!r)return;const s=o.direction,a=i.document.selection.getSelectedElement(),l="forward"==s;if("before"===r===l)e.execute("delete",{selection:i.createSelection(a,"on")});else{const t=n.getNearestSelectionRange(i.createPositionAt(a,r),s);if(t)if(t.isCollapsed){const o=i.createSelection(t.start);if(i.modifySelection(o,{direction:s}),o.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")}))}o.preventDefault(),t.stop()}),{context:Op})}_enableInsertContentIntegration(){const e=this.editor,t=this.editor.model,i=t.document.selection;this._listenToIfEnabled(e.model,"insertContent",((e,[n,o])=>{if(o&&!o.is("documentSelection"))return;const r=Fp(i);return r?(e.stop(),t.change((e=>{const o=i.getSelectedElement(),s=t.createPositionAt(o,r),a=e.createSelection(s),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,o={}]=i;if(n&&!n.is("documentSelection"))return;const r=Fp(t);r&&(o.findOptimalPosition=r,i[3]=o)}),{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;Fp(t)&&e.stop()}),{priority:"high"})}}function Gp(e){const t=e.model;return(i,n)=>{const o=n.keyCode==bo.arrowup,r=n.keyCode==bo.arrowdown,s=n.shiftKey,a=t.document.selection;if(!o&&!r)return;const l=r;if(s&&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=Kp(n,e,"forward");if(!i)return null;const o=n.createRange(e,i),r=Yp(n.schema,o,"backward");return r?n.createRange(e,r):null}{const e=t.isCollapsed?t.focus:t.getFirstPosition(),i=Kp(n,e,"backward");if(!i)return null;const o=n.createRange(i,e),r=Yp(n.schema,o,"forward");return r?n.createRange(r,e):null}}(e,a,l);if(c){if(c.isCollapsed){if(a.isCollapsed)return;if(s)return}(c.isCollapsed||function(e,t,i){const n=e.model,o=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 r=e.mapper.toViewRange(t),s=o.viewRangeToDom(r),a=Hn.getDomRangeRects(s);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(s){const n=t.createSelection(a.anchor);n.setFocus(i),e.setSelection(n)}else e.setSelection(i)})),i.stop(),n.preventDefault(),n.stopPropagation())}}}function Kp(e,t,i){const n=e.schema,o=e.createRangeIn(t.root),r="forward"==i?"elementStart":"elementEnd";for(const{previousPosition:e,item:s,type:a}of o.getWalker({startPosition:t,direction:i})){if(n.isLimit(s)&&!n.isInline(s))return e;if(a==r&&n.isBlock(s))return null}return null}function Yp(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}var Qp=i(1014),Jp={attributes:{"data-cke":!0}};Jp.setAttributes=$o(),Jp.insert=Wo().bind(null,"head"),Jp.domAPI=Ho(),Jp.insertStyleElement=Go();jo()(Qp.Z,Jp);Qp.Z&&Qp.Z.locals&&Qp.Z.locals;class Xp extends vs{constructor(){super(...arguments),this._previouslySelected=new Set}static get pluginName(){return"Widget"}static get requires(){return[qp,tp]}init(){const e=this.editor,t=e.editing.view,i=t.document;this.editor.editing.downcastDispatcher.on("selection",((t,i,n)=>{const o=n.writer,r=i.selection;if(r.isCollapsed)return;const s=r.getSelectedElement();if(!s)return;const a=e.editing.mapper.toViewElement(s);var l;Op(a)&&(n.consumable.consume(r,"selection")&&o.setSelection(o.createRangeOn(a),{fake:!0,label:(l=a,l.getCustomProperty("widgetLabel").reduce(((e,t)=>"function"==typeof t?e?e+". "+t():t():e?e+". "+t:t),""))}))})),this.editor.editing.downcastDispatcher.on("selection",((e,t,i)=>{this._clearPreviouslySelectedWidgets(i.writer);const n=i.writer,o=n.document.selection;let r=null;for(const e of o.getRanges())for(const t of e){const e=t.item;Op(e)&&!eb(e,r)&&(n.addClass(Ip,e),this._previouslySelected.add(e),r=e)}}),{priority:"low"}),t.addObserver(Fh),this.listenTo(i,"mousedown",((...e)=>this._onMousedown(...e))),this.listenTo(i,"arrowKey",((...e)=>{this._handleSelectionChangeOnArrowKeyPress(...e)}),{context:[Op,"$text"]}),this.listenTo(i,"arrowKey",((...e)=>{this._preventDefaultOnArrowKeyPress(...e)}),{context:"$root"}),this.listenTo(i,"arrowKey",Gp(this.editor.editing),{context:"$text"}),this.listenTo(i,"delete",((e,t)=>{this._handleDelete("forward"==t.direction)&&(t.preventDefault(),e.stop())}),{context:"$root"})}_onMousedown(e,t){const i=this.editor,n=i.editing.view,o=n.document;let r=t.target;if(function(e){let t=e;for(;t;){if(t.is("editableElement")&&!t.is("rootElement"))return!0;if(Op(t))return!1;t=t.parent}return!1}(r)){if((c.isSafari||c.isGecko)&&t.domEvent.detail>=3){const e=i.editing.mapper,n=r.is("attributeElement")?r.findAncestor((e=>!e.is("attributeElement"))):r,o=e.toModelElement(n);t.preventDefault(),this.editor.model.change((e=>{e.setSelection(o,"in")}))}return}if(!Op(r)&&(r=r.findAncestor(Op),!r))return;c.isAndroid&&t.preventDefault(),o.isFocused||n.focus();const s=i.editing.mapper.toModelElement(r);this._setSelectionOverElement(s)}_handleSelectionChangeOnArrowKeyPress(e,t){const i=t.keyCode,n=this.editor.model,o=n.schema,r=n.document.selection,s=r.getSelectedElement(),a=yo(i,this.editor.locale.contentLanguageDirection),l="down"==a||"right"==a,c="up"==a||"down"==a;if(s&&o.isObject(s)){const i=l?r.getLastPosition():r.getFirstPosition(),s=o.getNearestSelectionRange(i,l?"forward":"backward");return void(s&&(n.change((e=>{e.setSelection(s)})),t.preventDefault(),e.stop()))}if(!r.isCollapsed&&!t.shiftKey){const i=r.getFirstPosition(),s=r.getLastPosition(),a=i.nodeAfter,c=s.nodeBefore;return void((a&&o.isObject(a)||c&&o.isObject(c))&&(n.change((e=>{e.setSelection(l?s:i)})),t.preventDefault(),e.stop()))}if(!r.isCollapsed)return;const d=this._getObjectElementNextToSelection(l);if(d&&o.isObject(d)){if(o.isInline(d)&&c)return;this._setSelectionOverElement(d),t.preventDefault(),e.stop()}}_preventDefaultOnArrowKeyPress(e,t){const i=this.editor.model,n=i.schema,o=i.document.selection.getSelectedElement();o&&n.isObject(o)&&(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,o=t.createSelection(n);if(t.modifySelection(o,{direction:e?"forward":"backward"}),o.isEqual(n))return null;const r=e?o.focus.nodeBefore:o.focus.nodeAfter;return r&&i.isObject(r)?r:null}_clearPreviouslySelectedWidgets(e){for(const t of this._previouslySelected)e.removeClass(Ip,t);this._previouslySelected.clear()}}function eb(e,t){return!!t&&Array.from(e.getAncestors()).includes(t)}class tb extends vs{constructor(){super(...arguments),this._toolbarDefinitions=new Map}static get requires(){return[bg]}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||!Op(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:o="ck-toolbar-container"}){if(!i.length)return void A("widget-toolbar-no-items",{toolbarId:e});const r=this.editor,s=r.t,a=new Em(r.locale);if(a.ariaLabel=t||s("Widget toolbar"),this._toolbarDefinitions.has(e))throw new y("widget-toolbar-duplicated",this,{toolbarId:e});const l={view:a,getRelatedElement:n,balloonClassName:o,itemsConfig:i,initialized:!1};r.ui.addToolbar(a,{isContextual:!0,beforeFocus:()=>{const e=n(r.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 o=n.getRelatedElement(this.editor.editing.view.document.selection);if(this.isEnabled&&o)if(this.editor.ui.focusTracker.isFocused){const r=o.getAncestors().length;r>e&&(e=r,t=o,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)?ib(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:nb(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);ib(this.editor,t)}})))}_isToolbarVisible(e){return this._balloon.visibleView===e.view}_isToolbarInBalloon(e){return this._balloon.hasView(e.view)}}function ib(e,t){const i=e.plugins.get("ContextualBalloon"),n=nb(e,t);i.updatePosition(n)}function nb(e,t){const i=e.editing.view,n=Lf.defaultPositions;return{target:i.domConverter.mapViewToDom(t),positions:[n.northArrowSouth,n.northArrowSouthWest,n.northArrowSouthEast,n.southArrowNorth,n.southArrowNorthWest,n.southArrowNorthEast,n.viewportStickyNorth]}}class ob extends(G()){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}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 Hn(t);this.activeHandlePosition=function(e){const t=["top-left","top-right","bottom-right","bottom-left"];for(const i of t)if(e.classList.contains(rb(i)))return i}(e),this._referenceCoordinates=function(e,t){const i=new Hn(e),n=t.split("-"),o={x:"right"==n[1]?i.right:i.left,y:"bottom"==n[0]?i.bottom:i.top};return o.x+=e.ownerDocument.defaultView.scrollX,o.y+=e.ownerDocument.defaultView.scrollY,o}(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 o=i.style.width;o&&o.match(/^\d+(\.\d*)?%$/)?this._originalWidthPercents=parseFloat(o):this._originalWidthPercents=function(e,t){const i=e.parentElement;let n=parseFloat(i.ownerDocument.defaultView.getComputedStyle(i).width);const o=5;let r=0,s=i;for(;isNaN(n);){if(s=s.parentElement,++r>o)return 0;n=parseFloat(i.ownerDocument.defaultView.getComputedStyle(s).width)}return t.width/n*100}(i,n)}update(e){this.proposedWidth=e.width,this.proposedHeight=e.height,this.proposedWidthPercents=e.widthPercents,this.proposedHandleHostWidth=e.handleHostWidth,this.proposedHandleHostHeight=e.handleHostHeight}}function rb(e){return`ck-widget__resizer__handle-${e}`}class sb extends Qo{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")}]})}_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}}class ab extends(G()){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"})}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 ob(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 Hn(i),o=Math.round(n.width),r=Math.round(n.height),s=new Hn(i);t.width=Math.round(s.width),t.height=Math.round(s.height),this.redraw(n),this.state.update({...t,handleHostWidth:o,handleHostHeight:r})}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,o=this._getHandleHost(),r=this._viewResizerWrapper,s=[r.getStyle("width"),r.getStyle("height"),r.getStyle("left"),r.getStyle("top")];let a;if(n.isSameNode(o)){const t=e||new Hn(o);a=[t.width+"px",t.height+"px",void 0,void 0]}else a=[o.offsetWidth+"px",o.offsetHeight+"px",o.offsetLeft+"px",o.offsetTop+"px"];"same"!==ie(s,a)&&this._options.editor.editing.view.change((e=>{e.setStyle({width:a[0],height:a[1],left:a[2],top:a[3]},r)}))}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 o=!this._options.isCentered||this._options.isCentered(this),r={x:t._referenceCoordinates.x-(i.x+t.originalWidth),y:i.y-t.originalHeight-t._referenceCoordinates.y};o&&t.activeHandlePosition.endsWith("-right")&&(r.x=i.x-(t._referenceCoordinates.x+t.originalWidth)),o&&(r.x*=2);let s=Math.abs(t.originalWidth+r.x),a=Math.abs(t.originalHeight+r.y);return"width"==(s/t.aspectRatio>a?"width":"height")?a=s/t.aspectRatio:s=a*t.aspectRatio,{width:Math.round(s),height:Math.round(a),widthPercents:Math.min(Math.round(t.originalWidthPercents/t.originalWidth*s*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 Jo({tag:"div",attributes:{class:"ck-widget__resizer__handle "+(i=n,`ck-widget__resizer__handle-${i}`)}}).render());var i}_appendSizeUI(e){this._sizeView=new sb,this._sizeView.render(),e.appendChild(this._sizeView.element)}}var lb=i(6036),cb={attributes:{"data-cke":!0}};cb.setAttributes=$o(),cb.insert=Wo().bind(null,"head"),cb.domAPI=Ho(),cb.insertStyleElement=Go();jo()(lb.Z,cb);lb.Z&&lb.Z.locals&&lb.Z.locals;class db extends vs{constructor(){super(...arguments),this._resizers=new Map}static get pluginName(){return"WidgetResize"}init(){const e=this.editor.editing,t=Dn.window.document;this.set("selectedResizer",null),this.set("_activeResizer",null),e.view.addObserver(Fh),this._observer=new(Mn()),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=Zf((()=>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(Dn.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 ab(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;ab.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)}}class ub extends As{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=Lp(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"})}))}}var hb=i(4383),mb={attributes:{"data-cke":!0}};mb.setAttributes=$o(),mb.insert=Wo().bind(null,"head"),mb.domAPI=Ho(),mb.insertStyleElement=Go();jo()(hb.Z,mb);hb.Z&&hb.Z.locals&&hb.Z.locals;class fb extends vs{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"),o=t.createContainerElement("div",null,t.createEmptyElement("hr"));return t.addClass("ck-horizontal-line",o),t.setCustomProperty("hr",!0,o),function(e,t,i){return t.setCustomProperty("horizontalLine",!0,e),Mp(e,t,{label:i})}(o,t,n)}}),n.for("upcast").elementToElement({view:"hr",model:"horizontalLine"}),e.commands.add("horizontalLine",new ub(e))}}class gb extends vs{static get pluginName(){return"HorizontalLineUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add("horizontalLine",(i=>{const n=e.commands.get("horizontalLine"),o=new Er(i);return o.set({label:t("Horizontal line"),icon:'',tooltip:!0}),o.bind("isEnabled").to(n,"isEnabled"),this.listenTo(o,"execute",(()=>{e.execute("horizontalLine"),e.editing.view.focus()})),o}))}}class pb extends vs{static get requires(){return[fb,gb,Xp]}static get pluginName(){return"HorizontalLine"}}function bb(e){const t=e.getSelectedElement();return t&&kb(t)?t:null}function wb(e){const t=e.getFirstPosition();if(!t)return null;let i=t.parent;for(;i;){if(i.is("element")&&kb(i))return i;i=i.parent}return null}function kb(e){return!!e.getCustomProperty("table")&&Op(e)}class _b extends vs{static get requires(){return[tb]}static get pluginName(){return"TableToolbar"}afterInit(){const e=this.editor,t=e.t,i=e.plugins.get(tb),n=e.config.get("table.contentToolbar"),o=e.config.get("table.tableToolbar");n&&i.register("tableContent",{ariaLabel:t("Table toolbar"),items:n,getRelatedElement:wb}),o&&i.register("table",{ariaLabel:t("Table toolbar"),items:o,getRelatedElement:bb})}}function vb(e,t,i,n,o=1){null!=t&&null!=o&&t>o?n.setAttribute(e,t,i):n.removeAttribute(e,i)}function yb(e,t,i={}){const n=e.createElement("tableCell",i);return e.insertElement("paragraph",n),e.insert(n,t),n}function Ab(e,t){const i=t.parent.parent,n=parseInt(i.getAttribute("headingColumns")||"0"),{column:o}=e.getCellLocation(t);return!!n&&o{e.on("element:table",((e,t,i)=>{const n=t.viewItem;if(!i.consumable.test(n,{name:!0}))return;const{rows:o,headingRows:r,headingColumns:s}=function(e){let t,i=0;const n=[],o=[];let r;for(const s of Array.from(e.getChildren())){if("tbody"!==s.name&&"thead"!==s.name&&"tfoot"!==s.name)continue;"thead"!==s.name||r||(r=s);const e=Array.from(s.getChildren()).filter((e=>e.is("element","tr")));for(const a of e)if(r&&s===r||"tbody"===s.name&&Array.from(a.getChildren()).length&&Array.from(a.getChildren()).every((e=>e.is("element","th"))))i++,n.push(a);else{o.push(a);const e=Cb(a);(!t||ei.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")),yb(i.writer,i.writer.createPositionAt(e,"end"))}i.updateConversionResult(l,t)}}))}}function Eb(e){return t=>{t.on(`element:${e}`,((e,t,{writer:i})=>{if(!t.modelRange)return;const n=t.modelRange.start.nodeAfter,o=i.createPositionAt(n,0);if(t.viewItem.isEmpty)return void i.insertElement("paragraph",o);const r=Array.from(n.getChildren());if(r.every((e=>e.is("element","$marker")))){const e=i.createElement("paragraph");i.insert(e,i.createPositionAt(n,0));for(const t of r)i.move(i.createRangeOn(t),i.createPositionAt(e,"end"))}}),{priority:"low"})}}function Cb(e){let t=0,i=0;const n=Array.from(e.getChildren()).filter((e=>"th"===e.name||"td"===e.name));for(;i1||o>1)&&this._recordSpans(i,o,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 Tb(this,e,t,i)}}_shouldSkipSlot(){const e=this._skipRows.has(this._row),t=this._rowthis._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{const o=i.getAttribute("headingRows")||0,r=n.createContainerElement("table",null,[]),s=n.createContainerElement("figure",{class:"table"},r);o>0&&n.insert(n.createPositionAt(r,"end"),n.createContainerElement("thead",null,n.createSlot((e=>e.is("element","tableRow")&&e.indexe.is("element","tableRow")&&e.index>=o))));for(const{positionOffset:e,filter:i}of t.additionalSlots)n.insert(n.createPositionAt(r,e),n.createSlot(i));return n.insert(n.createPositionAt(r,"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),Mp(e,t,{hasSelectionHandle:!0})}(s,n):s}}function Ib(e={}){return(t,{writer:i})=>{const n=t.parent,o=n.parent,r=o.getChildIndex(n),s=new Sb(o,{row:r}),a=o.getAttribute("headingRows")||0,l=o.getAttribute("headingColumns")||0;let c=null;for(const n of s)if(n.cell==t){const t=n.row{if(!t.parent.is("element","tableCell"))return null;if(!Mb(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 Mb(e){return 1==e.parent.childCount&&!!e.getAttributeKeys().next().done}class Rb extends As{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"),o=t.config.get("table.defaultHeadings.rows"),r=t.config.get("table.defaultHeadings.columns");void 0===e.headingRows&&o&&(e.headingRows=o),void 0===e.headingColumns&&r&&(e.headingColumns=r),i.change((t=>{const o=n.createTable(t,e);i.insertObject(o,null,null,{findOptimalPosition:"auto"}),t.setSelection(t.createPositionAt(o.getNodeByPath([0,0,0]),0))}))}}class Nb extends As{constructor(e,t={}){super(e),this.order=t.order||"below"}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,o=i.getSelectionAffectedTableCells(t),r=i.getRowIndexes(o),s=n?r.first:r.last,a=o[0].findAncestor("table");i.insertRows(a,{at:n?s:s+1,copyStructureFromAbove:!n})}}class Vb extends As{constructor(e,t={}){super(e),this.order=t.order||"right"}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,o=i.getSelectionAffectedTableCells(t),r=i.getColumnIndexes(o),s=n?r.first:r.last,a=o[0].findAncestor("table");i.insertColumns(a,{columns:1,at:n?s:s+1})}}class Db extends As{constructor(e,t={}){super(e),this.direction=t.direction||"horizontally"}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)}}function Lb(e,t,i){const{startRow:n,startColumn:o,endRow:r,endColumn:s}=t,a=i.createElement("table"),l=r-n+1;for(let e=0;e0){vb("headingRows",r-i,e,o,0)}const s=parseInt(t.getAttribute("headingColumns")||"0");if(s>0){vb("headingColumns",s-n,e,o,0)}}(a,e,n,o,i),a}function Bb(e,t,i=0){const n=[],o=new Sb(e,{startRow:i,endRow:t-1});for(const e of o){const{row:i,cellHeight:o}=e;i1&&(a.rowspan=l);const c=parseInt(e.getAttribute("colspan")||"1");c>1&&(a.colspan=c);const d=r+s,u=[...new Sb(o,{startRow:r,endRow:d,includeAllSlots:!0})];let h,m=null;for(const t of u){const{row:n,column:o,cell:r}=t;r===e&&void 0===h&&(h=o),void 0!==h&&h===o&&n===d&&(m=yb(i,t.getPositionBefore(),a))}return vb("rowspan",s,e,i),m}function jb(e,t){const i=[],n=new Sb(e);for(const e of n){const{column:n,cellWidth:o}=e;n1&&(r.colspan=s);const a=parseInt(e.getAttribute("rowspan")||"1");a>1&&(r.rowspan=a);const l=yb(n,n.createPositionAfter(e),r);return vb("colspan",o,e,n),l}function Hb(e,t,i,n,o,r){const s=parseInt(e.getAttribute("colspan")||"1"),a=parseInt(e.getAttribute("rowspan")||"1");if(i+s-1>o){vb("colspan",o-i+1,e,r,1)}if(t+a-1>n){vb("rowspan",n-t+1,e,r,1)}}function Ub(e,t){const i=t.getColumns(e),n=new Array(i).fill(0);for(const{column:t}of new Sb(e))n[t]++;const o=n.reduce(((e,t,i)=>t?e:[...e,i]),[]);if(o.length>0){const i=o[o.length-1];return t.removeColumns(e,{at:i}),!0}return!1}function Wb(e,t){const i=[],n=t.getRows(e);for(let t=0;t0){const n=i[i.length-1];return t.removeRows(e,{at:n}),!0}return!1}function Zb(e,t){Ub(e,t)||Wb(e,t)}function $b(e,t){const i=Array.from(new Sb(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 qb(e,t){const i=Array.from(new Sb(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 Gb extends As{constructor(e,t){super(e),this.direction=t.direction,this.isHorizontal="right"==this.direction||"left"==this.direction}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,o=this.direction;e.change((e=>{const t="right"==o||"down"==o,r=t?i:n,s=t?n:i,a=s.parent;!function(e,t,i){Kb(e)||(Kb(t)&&i.remove(i.createRangeIn(t)),i.move(i.createRangeIn(e),i.createPositionAt(t,"end")));i.remove(e)}(s,r,e);const l=this.isHorizontal?"colspan":"rowspan",c=parseInt(i.getAttribute(l)||"1"),d=parseInt(n.getAttribute(l)||"1");e.setAttribute(l,c+d,r),e.setSelection(e.createRangeIn(r));const u=this.editor.plugins.get("TableUtils");Zb(a.findAncestor("table"),u)}))}_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,o=n.parent,r="right"==t?e.nextSibling:e.previousSibling,s=(o.getAttribute("headingColumns")||0)>0;if(!r)return;const a="right"==t?e:r,l="right"==t?r:e,{column:c}=i.getCellLocation(a),{column:d}=i.getCellLocation(l),u=parseInt(a.getAttribute("colspan")||"1"),h=Ab(i,a),m=Ab(i,l);if(s&&h!=m)return;return c+u===d?r:void 0}(i,this.direction,t):function(e,t,i){const n=e.parent,o=n.parent,r=o.getChildIndex(n);if("down"==t&&r===i.getRows(o)-1||"up"==t&&0===r)return null;const s=parseInt(e.getAttribute("rowspan")||"1"),a=o.getAttribute("headingRows")||0,l="down"==t&&r+s===a,c="up"==t&&r===a;if(a&&(l||c))return null;const d=parseInt(e.getAttribute("rowspan")||"1"),u="down"==t?r+d:r,h=[...new Sb(o,{endRow:u})],m=h.find((t=>t.cell===e)),f=m.column,g=h.find((({row:e,cellHeight:i,column:n})=>n===f&&("down"==t?e===u:u===e+i)));return g&&g.cell?g.cell:null}(i,this.direction,t);if(!n)return;const o=this.isHorizontal?"rowspan":"colspan",r=parseInt(i.getAttribute(o)||"1");return parseInt(n.getAttribute(o)||"1")===r?n:void 0}}function Kb(e){const t=e.getChild(0);return 1==e.childCount&&t.is("element","paragraph")&&t.isEmpty}class Yb extends As{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"),o=e.getRows(n)-1,r=e.getRowIndexes(t),s=0===r.first&&r.last===o;this.isEnabled=!s}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),o=i[0],r=o.findAncestor("table"),s=t.getCellLocation(o).column;e.change((e=>{const i=n.last-n.first+1;t.removeRows(r,{at:n.first,rows:i});const o=function(e,t,i,n){const o=e.getChild(Math.min(t,n-1));let r=o.getChild(0),s=0;for(const e of o.getChildren()){if(s>i)return r;r=e,s+=parseInt(e.getAttribute("colspan")||"1")}return r}(r,n.first,s,t.getRows(r));e.setSelection(e.createPositionAt(o,0))}))}}class Qb extends As{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"),o=e.getColumns(n),{first:r,last:s}=e.getColumnIndexes(t);this.isEnabled=s-re.cell===t)).column,last:o.find((e=>e.cell===i)).column},s=function(e,t,i,n){const o=parseInt(i.getAttribute("colspan")||"1");return o>1?i:t.previousSibling||i.nextSibling?i.nextSibling||t.previousSibling:n.first?e.reverse().find((({column:e})=>ee>n.last)).cell}(o,t,i,r);this.editor.model.change((t=>{const i=r.last-r.first+1;e.removeColumns(n,{at:r.first,columns:i}),t.setSelection(t.createPositionAt(s,0))}))}}class Jb extends As{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),o=n[0].findAncestor("table"),{first:r,last:s}=t.getRowIndexes(n),a=this.value?r:s+1,l=o.getAttribute("headingRows")||0;i.change((e=>{if(a){const t=Bb(o,a,a>l?l:0);for(const{cell:i}of t)zb(i,a,e)}vb("headingRows",a,o,e,0)}))}_isInHeading(e,t){const i=parseInt(t.getAttribute("headingRows")||"0");return!!i&&e.parent.index0;this.isEnabled=n,this.value=n&&i.every((e=>Ab(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),o=n[0].findAncestor("table"),{first:r,last:s}=t.getColumnIndexes(n),a=this.value?r:s+1;i.change((e=>{if(a){const t=jb(o,a);for(const{cell:i,column:n}of t)Fb(i,n,a,e)}vb("headingColumns",a,o,e,0)}))}}class ew extends vs{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),o=new Sb(i,{row:n});for(const{cell:t,row:i,column:n}of o)if(t===e)return{row:i,column:n}}createTable(e,t){const i=e.createElement("table"),n=t.rows||2,o=t.columns||2;return tw(e,i,0,n,o),t.headingRows&&vb("headingRows",Math.min(t.headingRows,n),i,e,0),t.headingColumns&&vb("headingColumns",Math.min(t.headingColumns,o),i,e,0),i}insertRows(e,t={}){const i=this.editor.model,n=t.at||0,o=t.rows||1,r=void 0!==t.copyStructureFromAbove,s=t.copyStructureFromAbove?n-1:n,a=this.getRows(e),l=this.getColumns(e);if(n>a)throw new y("tableutils-insertrows-insert-out-of-range",this,{options:t});i.change((t=>{const i=e.getAttribute("headingRows")||0;if(i>n&&vb("headingRows",i+o,e,t,0),!r&&(0===n||n===a))return void tw(t,e,n,o,l);const c=r?Math.max(n,s):n,d=new Sb(e,{endRow:c}),u=new Array(l).fill(1);for(const{row:e,column:i,cellHeight:a,cellWidth:l,cell:c}of d){const d=e+a-1,h=e<=s&&s<=d;e0&&yb(t,o,n>1?{colspan:n}:void 0),e+=Math.abs(n)-1}}}))}insertColumns(e,t={}){const i=this.editor.model,n=t.at||0,o=t.columns||1;i.change((t=>{const i=e.getAttribute("headingColumns");no-1)throw new y("tableutils-removerows-row-index-out-of-range",this,{table:e,options:t});i.change((t=>{const i={first:r,last:s},{cellsToMove:n,cellsToTrim:o}=function(e,{first:t,last:i}){const n=new Map,o=[];for(const{row:r,column:s,cellHeight:a,cell:l}of new Sb(e,{endRow:i})){const e=r+a-1;if(r>=t&&r<=i&&e>i){const e=a-(i-r+1);n.set(s,{cell:l,rowspan:e})}if(r=t){let n;n=e>=i?i-t+1:e-t+1,o.push({cell:l,rowspan:a-n})}}return{cellsToMove:n,cellsToTrim:o}}(e,i);if(n.size){!function(e,t,i,n){const o=new Sb(e,{includeAllSlots:!0,row:t}),r=[...o],s=e.getChild(t);let a;for(const{column:e,cell:t,isAnchor:o}of r)if(i.has(e)){const{cell:t,rowspan:o}=i.get(e),r=a?n.createPositionAfter(a):n.createPositionAt(s,0);n.move(n.createRangeOn(t),r),vb("rowspan",o,t,n),a=t}else o&&(a=t)}(e,s+1,n,t)}for(let i=s;i>=r;i--)t.remove(e.getChild(i));for(const{rowspan:e,cell:i}of o)vb("rowspan",e,i,t);!function(e,{first:t,last:i},n){const o=e.getAttribute("headingRows")||0;if(t{!function(e,t,i){const n=e.getAttribute("headingColumns")||0;if(n&&t.first=n;i--)for(const{cell:n,column:o,cellWidth:r}of[...new Sb(e)])o<=i&&r>1&&o+r>i?vb("colspan",r-1,n,t):o===i&&t.remove(n);Wb(e,this)||Ub(e,this)}))}splitCellVertically(e,t=2){const i=this.editor.model,n=e.parent.parent,o=parseInt(e.getAttribute("rowspan")||"1"),r=parseInt(e.getAttribute("colspan")||"1");i.change((i=>{if(r>1){const{newCellsSpan:n,updatedSpan:s}=nw(r,t);vb("colspan",s,e,i);const a={};n>1&&(a.colspan=n),o>1&&(a.rowspan=o);iw(r>t?t-1:r-1,i,i.createPositionAfter(e),a)}if(rt===e)),c=a.filter((({cell:t,cellWidth:i,column:n})=>t!==e&&n===l||nl));for(const{cell:e,cellWidth:t}of c)i.setAttribute("colspan",t+s,e);const d={};o>1&&(d.rowspan=o),iw(s,i,i.createPositionAfter(e),d);const u=n.getAttribute("headingColumns")||0;u>l&&vb("headingColumns",u+s,n,i)}}))}splitCellHorizontally(e,t=2){const i=this.editor.model,n=e.parent,o=n.parent,r=o.getChildIndex(n),s=parseInt(e.getAttribute("rowspan")||"1"),a=parseInt(e.getAttribute("colspan")||"1");i.change((i=>{if(s>1){const n=[...new Sb(o,{startRow:r,endRow:r+s-1,includeAllSlots:!0})],{newCellsSpan:l,updatedSpan:c}=nw(s,t);vb("rowspan",c,e,i);const{column:d}=n.find((({cell:t})=>t===e)),u={};l>1&&(u.rowspan=l),a>1&&(u.colspan=a);for(const e of n){const{column:t,row:n}=e;n>=r+c&&t===d&&(n+r+c)%l==0&&iw(1,i,e.getPositionBefore(),u)}}if(sr){const e=o+n;i.setAttribute("rowspan",e,t)}const c={};a>1&&(c.colspan=a),tw(i,o,r+1,n,1,c);const d=o.getAttribute("headingRows")||0;d>r&&vb("headingRows",d+n,o,i)}}))}getColumns(e){return[...e.getChild(0).getChildren()].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 Sb(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 Sb(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 o of e){const{row:e,column:r}=this.getCellLocation(o),s=parseInt(o.getAttribute("rowspan"))||1,a=parseInt(o.getAttribute("colspan"))||1;t.add(e),i.add(r),s>1&&t.add(e+s-1),a>1&&i.add(r+a-1),n+=s*a}const o=function(e,t){const i=Array.from(e.values()),n=Array.from(t.values()),o=Math.max(...i),r=Math.min(...i),s=Math.max(...n),a=Math.min(...n);return(o-r+1)*(s-a+1)}(t,i);return o==n}sortRanges(e){return Array.from(e).sort(ow)}_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 o=this.getColumnIndexes(e),r=parseInt(t.getAttribute("headingColumns"))||0;return this._areIndexesInSameSection(o,r)}_areIndexesInSameSection({first:e,last:t},i){return e{const n=t.getSelectedTableCells(e.document.selection),o=n.shift(),{mergeWidth:r,mergeHeight:s}=function(e,t,i){let n=0,o=0;for(const e of t){const{row:t,column:r}=i.getCellLocation(e);n=lw(e,r,n,"colspan"),o=lw(e,t,o,"rowspan")}const{row:r,column:s}=i.getCellLocation(e),a=n-s,l=o-r;return{mergeWidth:a,mergeHeight:l}}(o,n,t);vb("colspan",r,o,i),vb("rowspan",s,o,i);for(const e of n)sw(e,o,i);Zb(o.findAncestor("table"),t),i.setSelection(o,"in")}))}}function sw(e,t,i){aw(e)||(aw(t)&&i.remove(i.createRangeIn(t)),i.move(i.createRangeIn(e),i.createPositionAt(t,"end"))),i.remove(e)}function aw(e){const t=e.getChild(0);return 1==e.childCount&&t.is("element","paragraph")&&t.isEmpty}function lw(e,t,i,n){const o=parseInt(e.getAttribute(n)||"1");return Math.max(i,t+o)}class cw extends As{constructor(e){super(e),this.affectsData=!1}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),o=i[0].findAncestor("table"),r=[];for(let t=n.first;t<=n.last;t++)for(const i of o.getChild(t).getChildren())r.push(e.createRangeOn(i));e.change((e=>{e.setSelection(r)}))}}class dw extends As{constructor(e){super(e),this.affectsData=!1}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],o=i.pop(),r=n.findAncestor("table"),s=e.getCellLocation(n),a=e.getCellLocation(o),l=Math.min(s.column,a.column),c=Math.max(s.column,a.column),d=[];for(const e of new Sb(r,{startColumn:l,endColumn:c}))d.push(t.createRangeOn(e.cell));t.change((e=>{e.setSelection(d)}))}}function uw(e){e.document.registerPostFixer((t=>function(e,t){const i=t.document.differ.getChanges();let n=!1;const o=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")),fw(t)&&(i=t.range.start.findAncestor("table")),i&&!o.has(i)&&(n=hw(i,e)||n,n=mw(i,e)||n,o.add(i))}return n}(t,e)))}function hw(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:o,cell:r,cellHeight:s}of new Sb(e)){if(s<2)continue;const e=oe){const t=e-o;n.push({cell:r,rowspan:t})}}return n}(e);if(n.length){i=!0;for(const e of n)vb("rowspan",e.rowspan,e.cell,t,1)}return i}function mw(e,t){let i=!1;const n=function(e){const t=new Array(e.childCount).fill(0);for(const{rowIndex:i}of new Sb(e,{includeAllSlots:!0}))t[i]++;return t}(e),o=[];for(const[t,i]of n.entries())!i&&e.getChild(t).is("element","tableRow")&&o.push(t);if(o.length){i=!0;for(const i of o.reverse())t.remove(e.getChild(i)),n.splice(i,1)}const r=n.filter(((t,i)=>e.getChild(i).is("element","tableRow"))),s=r[0];if(!r.every((e=>e===s))){const n=r.reduce(((e,t)=>t>e?t:e),0);for(const[o,s]of r.entries()){const r=n-s;if(r){for(let i=0;ifunction(e,t){const i=t.document.differ.getChanges();let n=!1;for(const t of i)"insert"==t.type&&"table"==t.name&&(n=pw(t.position.nodeAfter,e)||n),"insert"==t.type&&"tableRow"==t.name&&(n=bw(t.position.nodeAfter,e)||n),"insert"==t.type&&"tableCell"==t.name&&(n=ww(t.position.nodeAfter,e)||n),"remove"!=t.type&&"insert"!=t.type||!kw(t)||(n=ww(t.position.parent,e)||n);return n}(t,e)))}function pw(e,t){let i=!1;for(const n of e.getChildren())n.is("element","tableRow")&&(i=bw(n,t)||i);return i}function bw(e,t){let i=!1;for(const n of e.getChildren())i=ww(n,t)||i;return i}function ww(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 kw(e){return!!e.position.parent.is("element","tableCell")&&("insert"==e.type&&"$text"==e.name||"remove"==e.type)}function _w(e,t){if(!e.is("element","paragraph"))return!1;const i=t.toViewElement(e);return!!i&&Mb(e)!==i.is("element","span")}var vw=i(3137),yw={attributes:{"data-cke":!0}};yw.setAttributes=$o(),yw.insert=Wo().bind(null,"head"),yw.domAPI=Ho(),yw.insertStyleElement=Go();jo()(vw.Z,yw);vw.Z&&vw.Z.locals&&vw.Z.locals;class Aw extends vs{static get pluginName(){return"TableEditing"}static get requires(){return[ew]}constructor(e){super(e),this._additionalSlots=[]}init(){const e=this.editor,t=e.model,i=t.schema,n=e.conversion,o=e.plugins.get(ew);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 o=Po(i.convertItem(n,t.modelCursor).modelRange.getItems());o?(i.convertChildren(t.viewItem,i.writer.createPositionAt(o,"end")),i.updateConversionResult(o,t)):i.consumable.revert(t.viewItem,{name:!0,classes:"table"})}))})),n.for("upcast").add(xb()),n.for("editingDowncast").elementToStructure({model:{name:"table",attributes:["headingRows"]},view:Pb(o,{asWidget:!0,additionalSlots:this._additionalSlots})}),n.for("dataDowncast").elementToStructure({model:{name:"table",attributes:["headingRows"]},view:Pb(o,{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(Eb("td")),n.for("upcast").add(Eb("th")),n.for("editingDowncast").elementToElement({model:"tableCell",view:Ib({asWidget:!0})}),n.for("dataDowncast").elementToElement({model:"tableCell",view:Ib()}),n.for("editingDowncast").elementToElement({model:"paragraph",view:Ob({asWidget:!0}),converterPriority:"high"}),n.for("dataDowncast").elementToElement({model:"paragraph",view:Ob(),converterPriority:"high"}),n.for("downcast").attributeToAttribute({model:"colspan",view:"colspan"}),n.for("upcast").attributeToAttribute({model:{key:"colspan",value:xw("colspan")},view:"colspan"}),n.for("downcast").attributeToAttribute({model:"rowspan",view:"rowspan"}),n.for("upcast").attributeToAttribute({model:{key:"rowspan",value:xw("rowspan")},view:"rowspan"}),e.config.define("table.defaultHeadings.rows",0),e.config.define("table.defaultHeadings.columns",0),e.commands.add("insertTable",new Rb(e)),e.commands.add("insertTableRowAbove",new Nb(e,{order:"above"})),e.commands.add("insertTableRowBelow",new Nb(e,{order:"below"})),e.commands.add("insertTableColumnLeft",new Vb(e,{order:"left"})),e.commands.add("insertTableColumnRight",new Vb(e,{order:"right"})),e.commands.add("removeTableRow",new Yb(e)),e.commands.add("removeTableColumn",new Qb(e)),e.commands.add("splitTableCellVertically",new Db(e,{direction:"vertically"})),e.commands.add("splitTableCellHorizontally",new Db(e,{direction:"horizontally"})),e.commands.add("mergeTableCells",new rw(e)),e.commands.add("mergeTableCellRight",new Gb(e,{direction:"right"})),e.commands.add("mergeTableCellLeft",new Gb(e,{direction:"left"})),e.commands.add("mergeTableCellDown",new Gb(e,{direction:"down"})),e.commands.add("mergeTableCellUp",new Gb(e,{direction:"up"})),e.commands.add("setTableColumnHeader",new Xb(e)),e.commands.add("setTableRowHeader",new Jb(e)),e.commands.add("selectTableRow",new cw(e)),e.commands.add("selectTableColumn",new dw(e)),uw(t),gw(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 o=i.getAttribute("headingRows")||0,r=i.getAttribute("headingColumns")||0,s=new Sb(i);for(const e of s){const i=e.row_w(e,t.mapper)));for(const e of i)t.reconvertItem(e)}}(t,e.editing)}))}registerAdditionalSlot(e){this._additionalSlots.push(e)}}function xw(e){return t=>{const i=parseInt(t.getAttribute(e));return Number.isNaN(i)||i<=0?null:i}}var Ew=i(6516),Cw={attributes:{"data-cke":!0}};Cw.setAttributes=$o(),Cw.insert=Wo().bind(null,"head"),Cw.domAPI=Ho(),Cw.insertStyleElement=Go();jo()(Ew.Z,Cw);Ew.Z&&Ew.Z.locals&&Ew.Z.locals;class Sw extends Qo{constructor(e){super(e);const t=this.bindTemplate;this.items=this._createGridCollection(),this.keystrokes=new Oo,this.focusTracker=new Io,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:o}=i.dataset;this.set({rows:parseInt(n),columns:parseInt(o)})})),this.on("change:columns",(()=>this._highlightGridBoxes())),this.on("change:rows",(()=>this._highlightGridBoxes()))}render(){super.render(),s({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)}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 o=Math.floor(n/10){const n=e.commands.get("insertTable"),o=Fm(i);let r;return o.bind("isEnabled").to(n),o.buttonView.set({icon:'',label:t("Insert table"),tooltip:!0}),o.on("change:isOpen",(()=>{r||(r=new Sw(i),o.panelView.children.add(r),r.delegate("execute").to(o),o.on("execute",(()=>{e.execute("insertTable",{rows:r.rows,columns:r.columns}),e.editing.view.focus()})))})),o})),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"),'',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"),'',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"),'',n,e)}))}_prepareDropdown(e,t,i,n){const o=this.editor,r=Fm(n),s=this._fillDropdownWithListOptions(r,i);return r.buttonView.set({label:e,icon:t,tooltip:!0}),r.bind("isEnabled").toMany(s,"isEnabled",((...e)=>e.some((e=>e)))),this.listenTo(r,"execute",(e=>{o.execute(e.source.commandName),e.source instanceof Tr||o.editing.view.focus()})),r}_prepareMergeSplitButtonDropdown(e,t,i,n){const o=this.editor,r=Fm(n,Dm),s="mergeTableCells",a=o.commands.get(s),l=this._fillDropdownWithListOptions(r,i);return r.buttonView.set({label:e,icon:t,tooltip:!0,isEnabled:!0}),r.bind("isEnabled").toMany([a,...l],"isEnabled",((...e)=>e.some((e=>e)))),this.listenTo(r.buttonView,"execute",(()=>{o.execute(s),o.editing.view.focus()})),this.listenTo(r,"execute",(e=>{o.execute(e.source.commandName),o.editing.view.focus()})),r}_fillDropdownWithListOptions(e,t){const i=this.editor,n=[],o=new To;for(const e of t)Pw(e,i,n,o);return Wm(e,o),n}}function Pw(e,t,i,n){if("button"===e.type||"switchbutton"===e.type){const n=e.model=new ug(e.model),{commandName:o,bindIsOn:r}=e.model,s=t.commands.get(o);i.push(s),n.set({commandName:o}),n.bind("isEnabled").to(s),r&&n.bind("isOn").to(s,"value"),n.set({withText:!0})}n.add(e)}var Iw=i(2794),Ow={attributes:{"data-cke":!0}};Ow.setAttributes=$o(),Ow.insert=Wo().bind(null,"head"),Ow.domAPI=Ho(),Ow.insertStyleElement=Go();jo()(Iw.Z,Ow);Iw.Z&&Iw.Z.locals&&Iw.Z.locals;class Mw extends vs{static get pluginName(){return"TableSelection"}static get requires(){return[ew,ew]}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(ew),t=this.editor.model.document.selection,i=e.getSelectedTableCells(t);return 0==i.length?null:i}getSelectionAsFragment(){const e=this.editor.plugins.get(ew),t=this.getSelectedTableCells();return t?this.editor.model.change((i=>{const n=i.createDocumentFragment(),{first:o,last:r}=e.getColumnIndexes(t),{first:s,last:a}=e.getRowIndexes(t),l=t[0].findAncestor("table");let c=a,d=r;if(e.isSelectionRectangular(t)){const e={firstColumn:o,lastColumn:r,firstRow:s,lastRow:a};c=$b(l,e),d=qb(l,e)}const u=Lb(l,{startRow:s,startColumn:o,endRow:c,endColumn:d},i);return i.insert(u,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=Po(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 o=n.writer;!function(e){for(const i of t)e.removeClass("ck-editor__editable_selected",i);t.clear()}(o);const r=this.getSelectedTableCells();if(!r)return;for(const e of r){const i=n.mapper.toViewElement(e);o.addClass("ck-editor__editable_selected",i),t.add(i)}const s=n.mapper.toViewElement(r[r.length-1]);o.setSelection(s,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),o=e.model.schema.getNearestSelectionRange(n);i.setSelection(o)}))}}))}_handleDeleteContent(e,t){const i=this.editor.plugins.get(ew),n=t[0],o=t[1],r=this.editor.model,s=!o||"backward"==o.direction,a=i.getSelectedTableCells(n);a.length&&(e.stop(),r.change((e=>{const t=a[s?a.length-1:0];r.change((e=>{for(const t of a)r.deleteContent(e.createSelection(t,"in"))}));const i=r.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 o=i.editing.view,r=i.editing.mapper,s=n.map((e=>o.createRangeOn(r.toViewElement(e))));t.selection=o.createSelection(s)}_getCellsToSelect(e,t){const i=this.editor.plugins.get("TableUtils"),n=i.getCellLocation(e),o=i.getCellLocation(t),r=Math.min(n.row,o.row),s=Math.max(n.row,o.row),a=Math.min(n.column,o.column),l=Math.max(n.column,o.column),c=new Array(s-r+1).fill(null).map((()=>[])),d={startRow:r,endRow:s,startColumn:a,endColumn:l};for(const{row:t,cell:i}of new Sb(e.findAncestor("table"),d))c[t-r].push(i);const u=o.rowe.reverse())),{cells:c.flat(),backward:u||h}}}class Rw extends vs{static get pluginName(){return"TableClipboard"}static get requires(){return[Mw,ew]}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.plugins.get(Mw);if(!i.getSelectedTableCells())return;if("cut"==e.name&&!this.editor.model.canEditAt(this.editor.model.document.selection))return;t.preventDefault(),e.stop();const n=this.editor.data,o=this.editor.editing.view.document,r=n.toView(i.getSelectionAsFragment());o.fire("clipboardOutput",{dataTransfer:t.dataTransfer,content:r,method:e.name})}_onInsertContent(e,t,i){if(i&&!i.is("documentSelection"))return;const n=this.editor.model,o=this.editor.plugins.get(ew);let r=this.getTableIfOnlyTableInContent(t,n);if(!r)return;const s=o.getSelectionAffectedTableCells(n.document.selection);s.length?(e.stop(),n.change((e=>{const t={width:o.getColumns(r),height:o.getRows(r)},i=function(e,t,i,n){const o=e[0].findAncestor("table"),r=n.getColumnIndexes(e),s=n.getRowIndexes(e),a={firstColumn:r.first,lastColumn:r.last,firstRow:s.first,lastRow:s.last},l=1===e.length;l&&(a.lastRow+=t.height-1,a.lastColumn+=t.width-1,function(e,t,i,n){const o=n.getColumns(e),r=n.getRows(e);i>o&&n.insertColumns(e,{at:o,columns:i-o});t>r&&n.insertRows(e,{at:r,rows:t-r})}(o,a.lastRow+1,a.lastColumn+1,n));l||!n.isSelectionRectangular(e)?function(e,t,i){const{firstRow:n,lastRow:o,firstColumn:r,lastColumn:s}=t,a={first:n,last:o},l={first:r,last:s};Vw(e,r,a,i),Vw(e,s+1,a,i),Nw(e,n,l,i),Nw(e,o+1,l,i,n)}(o,a,i):(a.lastRow=$b(o,a),a.lastColumn=qb(o,a));return a}(s,t,e,o),n=i.lastRow-i.firstRow+1,a=i.lastColumn-i.firstColumn+1,l={startRow:0,startColumn:0,endRow:Math.min(n,t.height)-1,endColumn:Math.min(a,t.width)-1};r=Lb(r,l,e);const c=s[0].findAncestor("table"),d=this._replaceSelectedCellsWithPasted(r,t,c,i,e);if(this.editor.plugins.get("TableSelection").isEnabled){const t=o.sortRanges(d.map((t=>e.createRangeOn(t))));e.setSelection(t)}else e.setSelection(d[0],0)}))):Zb(r,o)}_replaceSelectedCellsWithPasted(e,t,i,n,o){const{width:r,height:s}=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:o}of new Sb(e))n[i][t]=o;return n}(e,r,s),l=[...new Sb(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,u=i-n.firstColumn,h=a[l%s][u%r],m=h?o.cloneElement(h):null,f=this._replaceTableSlotCell(e,m,d,o);f&&(Hb(f,t,i,n.lastRow,n.lastColumn,o),c.push(f),d=o.createPositionAfter(f))}const u=parseInt(i.getAttribute("headingRows")||"0"),h=parseInt(i.getAttribute("headingColumns")||"0"),m=n.firstRowDw(e,t,i))).map((({cell:e})=>zb(e,t,n)))}function Vw(e,t,i,n){if(t<1)return;return jb(e,t).filter((({row:e,cellHeight:t})=>Dw(e,t,i))).map((({cell:e,column:i})=>Fb(e,i,t,n)))}function Dw(e,t,i){const n=e+t-1,{first:o,last:r}=i;return e>=o&&e<=r||e=o}class Lw extends vs{static get pluginName(){return"TableKeyboard"}static get requires(){return[Mw,ew]}init(){const e=this.editor.editing.view.document;this.listenTo(e,"arrowKey",((...e)=>this._onArrowKey(...e)),{context:"table"}),this.listenTo(e,"tab",((...e)=>this._handleTabOnSelectedTable(...e)),{context:"figure"}),this.listenTo(e,"tab",((...e)=>this._handleTab(...e)),{context:["th","td"]})}_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(ew),o=this.editor.plugins.get("TableSelection"),r=i.model.document.selection,s=!t.shiftKey;let a=n.getTableCellsContainingSelection(r)[0];if(a||(a=o.getFocusCell()),!a)return;t.preventDefault(),t.stopPropagation(),e.stop();const l=a.parent,c=l.parent,d=c.getChildIndex(l),u=l.getChildIndex(a),h=0===u;if(!s&&h&&0===d)return void i.model.change((e=>{e.setSelection(e.createRangeOn(c))}));const m=u===l.childCount-1,f=d===n.getRows(c)-1;if(s&&f&&m&&(i.execute("insertTableRowBelow"),d===n.getRows(c)-1))return void i.model.change((e=>{e.setSelection(e.createRangeOn(c))}));let g;if(s&&m){const e=c.getChild(d+1);g=e.getChild(0)}else if(!s&&h){const e=c.getChild(d-1);g=e.getChild(e.childCount-1)}else g=l.getChild(u+(s?1:-1));i.model.change((e=>{e.setSelection(e.createRangeIn(g))}))}_onArrowKey(e,t){const i=this.editor,n=yo(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(ew),n=this.editor.plugins.get("TableSelection"),o=this.editor.model,r=o.document.selection,s=["right","down"].includes(e),a=i.getSelectedTableCells(r);if(a.length){let i;return i=t?n.getFocusCell():s?a[a.length-1]:a[0],this._navigateFromCellInDirection(i,e,t),!0}const l=r.focus.findAncestor("tableCell");if(!l)return!1;if(!r.isCollapsed)if(t){if(r.isBackward==s&&!r.containsEntireContent(l))return!1}else{const e=r.getSelectedElement();if(!e||!o.schema.isObject(e))return!1}return!!this._isSelectionAtCellEdge(r,l,s)&&(this._navigateFromCellInDirection(l,e,t),!0)}_isSelectionAtCellEdge(e,t,i){const n=this.editor.model,o=this.editor.model.schema,r=i?e.getLastPosition():e.getFirstPosition();if(!o.getLimitElement(r).is("element","tableCell")){return n.createPositionAt(t,i?"end":0).isTouching(r)}const s=n.createSelection(r);return n.modifySelection(s,{direction:i?"forward":"backward"}),r.isEqual(s.focus)}_navigateFromCellInDirection(e,t,i=!1){const n=this.editor.model,o=e.findAncestor("table"),r=[...new Sb(o,{includeAllSlots:!0})],{row:s,column:a}=r[r.length-1],l=r.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>s||d<0&&c<=0||d>a&&c>=s)return void n.change((e=>{e.setSelection(e.createRangeOn(o))}));d<0?(d=i?0:a,c--):d>a&&(d=i?a:0,c++);const u=r.find((e=>e.row==c&&e.column==d)).cell,h=["right","down"].includes(t),m=this.editor.plugins.get("TableSelection");if(i&&m.isEnabled){const t=m.getAnchorCell()||e;m.setCellSelection(t,u)}else{const e=n.createPositionAt(u,h?0:"end");n.change((t=>{t.setSelection(e)}))}}}class Bw extends rc{constructor(){super(...arguments),this.domEventType=["mousemove","mouseleave"]}onDomEvent(e){this.fire(e.type,e)}}class zw extends vs{static get pluginName(){return"TableMouse"}static get requires(){return[Mw,ew]}init(){this.editor.editing.view.addObserver(Bw),this._enableShiftClickSelection(),this._enableMouseDragSelection()}_enableShiftClickSelection(){const e=this.editor,t=e.plugins.get(ew);let i=!1;const n=e.plugins.get(Mw);this.listenTo(e.editing.view.document,"mousedown",((o,r)=>{const s=e.model.document.selection;if(!this.isEnabled||!n.isEnabled)return;if(!r.domEvent.shiftKey)return;const a=n.getAnchorCell()||t.getTableCellsContainingSelection(s)[0];if(!a)return;const l=this._getModelTableCellFromDomEvent(r);l&&jw(a,l)&&(i=!0,n.setCellSelection(a,l),r.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,o=!1;const r=e.plugins.get(Mw);this.listenTo(e.editing.view.document,"mousedown",((e,i)=>{this.isEnabled&&r.isEnabled&&(i.domEvent.shiftKey||i.domEvent.ctrlKey||i.domEvent.altKey||(t=this._getModelTableCellFromDomEvent(i)))})),this.listenTo(e.editing.view.document,"mousemove",((e,s)=>{if(!s.domEvent.buttons)return;if(!t)return;const a=this._getModelTableCellFromDomEvent(s);a&&jw(t,a)&&(i=a,n||i==t||(n=!0)),n&&(o=!0,r.setCellSelection(t,i),s.preventDefault())})),this.listenTo(e.editing.view.document,"mouseup",(()=>{n=!1,o=!1,t=null,i=null})),this.listenTo(e.editing.view.document,"selectionChange",(e=>{o&&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 jw(e,t){return e.parent.parent==t.parent.parent}var Fw=i(4418),Hw={attributes:{"data-cke":!0}};Hw.setAttributes=$o(),Hw.insert=Wo().bind(null,"head"),Hw.domAPI=Ho(),Hw.insertStyleElement=Go();jo()(Fw.Z,Hw);Fw.Z&&Fw.Z.locals&&Fw.Z.locals;class Uw extends vs{static get requires(){return[Aw,Tw,Mw,zw,Lw,Rw,Xp]}static get pluginName(){return"Table"}}function Ww(e,t,i,n){let o,r=null;"function"==typeof n?o=n:(r=e.commands.get(n),o=()=>{e.execute(n)}),e.model.document.on("change:data",((s,a)=>{if(r&&!r.isEnabled||!t.isEnabled)return;const l=Po(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 u=d.position.parent;if(u.is("element","codeBlock"))return;if(u.is("element","listItem")&&"function"!=typeof n&&!["numberedList","bulletedList","todoList"].includes(n))return;if(r&&!0===r.value)return;const h=u.getChild(0),m=e.model.createRangeOn(h);if(!m.containsRange(l)&&!l.end.isEqual(m.end))return;const f=i.exec(h.data.substr(0,l.end.offset));f&&e.model.enqueueChange((t=>{const i=t.createPositionAt(u,0),n=t.createPositionAt(u,f[0].length),r=new gd(i,n);if(!1!==o({match:f})){t.remove(r);const i=e.model.document.selection.getFirstRange(),n=t.createRangeIn(u);!u.isEmpty||n.isEqual(i)||n.containsRange(i,!0)||t.remove(u)}r.detach(),e.model.enqueueChange((()=>{e.plugins.get("Delete").requestUndoOnBackspace()}))}))}))}function Zw(e,t,i,n){let o,r;i instanceof RegExp?o=i:r=i,r=r||(e=>{let t;const i=[],n=[];for(;null!==(t=o.exec(e))&&!(t&&t.length<4);){let{index:e,1:o,2:r,3:s}=t;const a=o+r+s;e+=t[0].length-a.length;const l=[e,e+o.length],c=[e+o.length+r.length,e+o.length+r.length+s.length];i.push(l),i.push(c),n.push([e+o.length,e+o.length+r.length])}return{remove:i,format:n}}),e.model.document.on("change:data",((i,o)=>{if(o.isUndo||!o.isLocal||!t.isEnabled)return;const s=e.model,a=s.document.selection;if(!a.isCollapsed)return;const l=Array.from(s.document.differ.getChanges()),c=l[0];if(1!=l.length||"insert"!==c.type||"$text"!=c.name||1!=c.length)return;const d=a.focus,u=d.parent,{text:h,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)}}(s.createRange(s.createPositionAt(u,0),d),s),f=r(h),g=$w(m.start,f.format,s),p=$w(m.start,f.remove,s);g.length&&p.length&&s.enqueueChange((t=>{if(!1!==n(t,g)){for(const e of p.reverse())t.remove(e);s.enqueueChange((()=>{e.plugins.get("Delete").requestUndoOnBackspace()}))}}))}))}function $w(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 qw extends vs{static get requires(){return[tp]}static get pluginName(){return"Autoformat"}afterInit(){this._addListAutoformats(),this._addBasicStylesAutoformats(),this._addHeadingAutoformats(),this._addBlockQuoteAutoformats(),this._addCodeBlockAutoformats(),this._addHorizontalLineAutoformats()}_addListAutoformats(){const e=this.editor.commands;e.get("bulletedList")&&Ww(this.editor,this,/^[*-]\s$/,"bulletedList"),e.get("numberedList")&&Ww(this.editor,this,/^1[.|)]\s$/,"numberedList"),e.get("todoList")&&Ww(this.editor,this,/^\[\s?\]\s$/,"todoList"),e.get("checkTodoList")&&Ww(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=Gw(this.editor,"bold");Zw(this.editor,this,/(?:^|\s)(\*\*)([^*]+)(\*\*)$/g,e),Zw(this.editor,this,/(?:^|\s)(__)([^_]+)(__)$/g,e)}if(e.get("italic")){const e=Gw(this.editor,"italic");Zw(this.editor,this,/(?:^|\s)(\*)([^*_]+)(\*)$/g,e),Zw(this.editor,this,/(?:^|\s)(_)([^_]+)(_)$/g,e)}if(e.get("code")){const e=Gw(this.editor,"code");Zw(this.editor,this,/(`)([^`]+)(`)$/g,e)}if(e.get("strikethrough")){const e=Gw(this.editor,"strikethrough");Zw(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$`);Ww(this.editor,this,n,(()=>{if(!e.isEnabled||e.value===t)return!1;this.editor.execute("heading",{value:t})}))}))}_addBlockQuoteAutoformats(){this.editor.commands.get("blockQuote")&&Ww(this.editor,this,/^>\s$/,"blockQuote")}_addCodeBlockAutoformats(){const e=this.editor,t=e.model.document.selection;e.commands.get("codeBlock")&&Ww(e,this,/^```$/,(()=>{if(t.getFirstPosition().parent.is("element","listItem"))return!1;this.editor.execute("codeBlock",{usePreviousLanguageChoice:!0})}))}_addHorizontalLineAutoformats(){this.editor.commands.get("horizontalLine")&&Ww(this.editor,this,/^---$/,"horizontalLine")}}function Gw(e,t){return(i,n)=>{if(!e.commands.get(t).isEnabled)return!1;const o=e.model.schema.getValidRanges(n,t);for(const e of o)i.setAttribute(t,!0,e);i.removeSelectionAttribute(t)}}class Kw extends rc{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 o=n.dropRange?[n.dropRange]:null,r=new p(t,e);t.fire(r,{dataTransfer:n.dataTransfer,method:i.name,targetRanges:o,target:n.target,domEvent:n.domEvent}),r.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"})}onDomEvent(e){const t="clipboardData"in e?e.clipboardData:e.dataTransfer,i="drop"==e.type||"paste"==e.type,n={dataTransfer:new Nc(t,{cacheFiles:i})};"drop"!=e.type&&"dragover"!=e.type||(n.dropRange=function(e,t){const i=t.target.ownerDocument,n=t.clientX,o=t.clientY;let r;i.caretRangeFromPoint&&i.caretRangeFromPoint(n,o)?r=i.caretRangeFromPoint(n,o):t.rangeParent&&(r=i.createRange(),r.setStart(t.rangeParent,t.rangeOffset),r.collapse(!0));if(r)return e.domConverter.domRangeToView(r);return null}(this.view,e)),this.fire(e.type,e,n)}}const Yw=["figcaption","li"];function Qw(e){let t="";if(e.is("$text")||e.is("$textProxy"))t=e.data;else if(e.is("element","img")&&e.hasAttribute("alt"))t=e.getAttribute("alt");else if(e.is("element","br"))t="\n";else{let i=null;for(const n of e.getChildren()){const e=Qw(n);i&&(i.is("containerElement")||n.is("containerElement"))&&(Yw.includes(i.name)||Yw.includes(n.name)?t+="\n":t+="\n\n"),t+=e,i=n}}return t}class Jw extends vs{static get pluginName(){return"ClipboardPipeline"}init(){this.editor.editing.view.addObserver(Kw),this._setupPasteDrop(),this._setupCopyCut()}_setupPasteDrop(){const e=this.editor,t=e.model,i=e.editing.view,n=i.document;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 o;if(t.content)o=t.content;else{let e="";n.getData("text/html")?e=function(e){return e.replace(/(\s+)<\/span>/g,((e,t)=>1==t.length?" ":t)).replace(//g,"")}(n.getData("text/html")):n.getData("text/plain")&&(((r=(r=n.getData("text/plain")).replace(//g,">").replace(/\r?\n\r?\n/g,"

").replace(/\r?\n/g,"
").replace(/\t/g,"    ").replace(/^\s/," ").replace(/\s$/," ").replace(/\s\s/g,"  ")).includes("

")||r.includes("
"))&&(r=`

${r}

`),e=r),o=this.editor.data.htmlProcessor.toView(e)}var r;const s=new p(this,"inputTransformation");this.fire(s,{content:o,dataTransfer:n,targetRanges:t.targetRanges,method:t.method}),s.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,i)=>{i.resultRange=t.insertContent(i.content)}),{priority:"low"})}_setupCopyCut(){const e=this.editor,t=e.model.document,i=e.editing.view.document,n=(n,o)=>{const r=o.dataTransfer;o.preventDefault();const s=e.data.toView(e.model.getSelectedContent(t.selection));i.fire("clipboardOutput",{dataTransfer:r,content:s,method:n.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(i,"clipboardOutput",((i,n)=>{n.content.isEmpty||(n.dataTransfer.setData("text/html",this.editor.data.htmlProcessor.toData(n.content)),n.dataTransfer.setData("text/plain",Qw(n.content))),"cut"==n.method&&e.model.deleteContent(t.selection)}),{priority:"low"})}}var Xw=i(3352),ek={attributes:{"data-cke":!0}};ek.setAttributes=$o(),ek.insert=Wo().bind(null,"head"),ek.domAPI=Ho(),ek.insertStyleElement=Go();jo()(Xw.Z,ek);Xw.Z&&Xw.Z.locals&&Xw.Z.locals;class tk extends vs{static get pluginName(){return"DragDrop"}static get requires(){return[Jw,Xp]}init(){const e=this.editor,t=e.editing.view;this._draggedRange=null,this._draggingUid="",this._draggableElement=null,this._updateDropMarkerThrottled=Zf((e=>this._updateDropMarker(e)),40),this._removeDropMarkerDelayed=Ro((()=>this._removeDropMarker()),40),this._clearDraggableAttributesDelayed=Ro((()=>this._clearDraggableAttributes()),40),e.plugins.has("DragDropExperimental")?this.forceDisabled("DragDropExperimental"):(t.addObserver(Kw),t.addObserver(Fh),this._setupDragging(),this._setupContentInsertionIntegration(),this._setupClipboardInputIntegration(),this._setupDropMarker(),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)})),c.isAndroid&&this.forceDisabled("noAndroidSupport"))}destroy(){return this._draggedRange&&(this._draggedRange.detach(),this._draggedRange=null),this._updateDropMarkerThrottled.cancel(),this._removeDropMarkerDelayed.cancel(),this._clearDraggableAttributesDelayed.cancel(),super.destroy()}_setupDragging(){const e=this.editor,t=e.model,i=t.document,n=e.editing.view,o=n.document;this.listenTo(o,"dragstart",((n,r)=>{const s=i.selection;if(r.target&&r.target.is("editableElement"))return void r.preventDefault();const a=r.target?ok(r.target):null;if(a){const i=e.editing.mapper.toModelElement(a);if(this._draggedRange=gd.fromRange(t.createRangeOn(i)),e.plugins.has("WidgetToolbarRepository")){e.plugins.get("WidgetToolbarRepository").forceDisabled("dragDrop")}}else if(!o.selection.isCollapsed){const e=o.selection.getSelectedElement();e&&Op(e)||(this._draggedRange=gd.fromRange(s.getFirstRange()))}if(!this._draggedRange)return void r.preventDefault();this._draggingUid=w();const l=this.isEnabled&&e.model.canEditAt(this._draggedRange);r.dataTransfer.effectAllowed=l?"copyMove":"copy",r.dataTransfer.setData("application/ckeditor5-dragging-uid",this._draggingUid);const c=t.createSelection(this._draggedRange.toRange()),d=e.data.toView(t.getSelectedContent(c));o.fire("clipboardOutput",{dataTransfer:r.dataTransfer,content:d,method:"dragstart"}),l||(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="")}),{priority:"low"}),this.listenTo(o,"dragend",((e,t)=>{this._finalizeDragging(!t.dataTransfer.isCanceled&&"move"==t.dataTransfer.dropEffect)}),{priority:"low"}),this.listenTo(o,"dragenter",(()=>{this.isEnabled&&n.focus()})),this.listenTo(o,"dragleave",(()=>{this._removeDropMarkerDelayed()})),this.listenTo(o,"dragging",((t,i)=>{if(!this.isEnabled)return void(i.dataTransfer.dropEffect="none");this._removeDropMarkerDelayed.cancel();const n=ik(e,i.targetRanges,i.target);e.model.canEditAt(n)?(this._draggedRange||(i.dataTransfer.dropEffect="copy"),c.isGecko||("copy"==i.dataTransfer.effectAllowed?i.dataTransfer.dropEffect="copy":["all","copyMove"].includes(i.dataTransfer.effectAllowed)&&(i.dataTransfer.dropEffect="move")),n&&this._updateDropMarkerThrottled(n)):i.dataTransfer.dropEffect="none"}),{priority:"low"})}_setupClipboardInputIntegration(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"clipboardInput",((t,i)=>{if("drop"!=i.method)return;const n=ik(e,i.targetRanges,i.target);if(this._removeDropMarker(),!n||!e.model.canEditAt(n))return this._finalizeDragging(!1),void t.stop();this._draggedRange&&this._draggingUid!=i.dataTransfer.getData("application/ckeditor5-dragging-uid")&&(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="");if("move"==nk(i.dataTransfer)&&this._draggedRange&&this._draggedRange.containsRange(n,!0))return this._finalizeDragging(!1),void t.stop();i.targetRanges=[e.editing.mapper.toViewRange(n)]}),{priority:"high"})}_setupContentInsertionIntegration(){const e=this.editor.plugins.get(Jw);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"==nk(t.dataTransfer),n=!t.resultRange||!t.resultRange.isCollapsed;this._finalizeDragging(n&&i)}),{priority:"lowest"})}_setupDraggableAttributeHandling(){const e=this.editor,t=e.editing.view,i=t.document;this.listenTo(i,"mousedown",((n,o)=>{if(c.isAndroid||!o)return;this._clearDraggableAttributesDelayed.cancel();let r=ok(o.target);if(c.isBlink&&!r&&!i.selection.isCollapsed){const e=i.selection.getSelectedElement();if(!e||!Op(e)){const e=i.selection.editableElement;e&&!e.isReadOnly&&(r=e)}}r&&(t.change((e=>{e.setAttribute("draggable","true",r)})),this._draggableElement=e.editing.mapper.toModelElement(r))})),this.listenTo(i,"mouseup",(()=>{c.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}))}_setupDropMarker(){const e=this.editor;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 i.createUIElement("span",{class:"ck ck-clipboard-drop-target-position"},(function(e){const t=this.toDomElement(e);return t.append("⁠",e.createElement("span"),"⁠"),t}))}})}_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})}))}_removeDropMarker(){const e=this.editor.model;this._removeDropMarkerDelayed.cancel(),this._updateDropMarkerThrottled.cancel(),e.markers.has("drop-target")&&e.change((e=>{e.removeMarker("drop-target")}))}_finalizeDragging(e){const t=this.editor,i=t.model;if(this._removeDropMarker(),this._clearDraggableAttributes(),t.plugins.has("WidgetToolbarRepository")){t.plugins.get("WidgetToolbarRepository").clearForceDisabled("dragDrop")}this._draggingUid="",this._draggedRange&&(e&&this.isEnabled&&i.deleteContent(i.createSelection(this._draggedRange),{doNotAutoparagraph:!0}),this._draggedRange.detach(),this._draggedRange=null)}}function ik(e,t,i){const n=e.model,o=e.editing.mapper;let r=null;const s=t?t[0].start:null;if(i.is("uiElement")&&(i=i.parent),r=function(e,t){const i=e.model,n=e.editing.mapper;if(Op(t))return i.createRangeOn(n.toModelElement(t));if(!t.is("editableElement")){const e=t.findAncestor((e=>Op(e)||e.is("editableElement")));if(Op(e))return i.createRangeOn(n.toModelElement(e))}return null}(e,i),r)return r;const a=function(e,t){const i=e.editing.mapper,n=e.editing.view,o=i.toModelElement(t);if(o)return o;const r=n.createPositionBefore(t),s=i.findMappedViewAncestor(r);return i.toModelElement(s)}(e,i),l=s?o.toModelPosition(s):null;return l?(r=function(e,t,i){const n=e.model;if(!n.schema.checkChild(i,"$block"))return null;const o=n.createPositionAt(i,0),r=t.path.slice(0,o.path.length),s=n.createPositionFromPath(t.root,r),a=s.nodeAfter;if(a&&n.schema.isObject(a))return n.createRangeOn(a);return null}(e,l,a),r||(r=n.schema.getNearestSelectionRange(l,c.isGecko?"forward":"backward"),r||function(e,t){const i=e.model;let n=t;for(;n;){if(i.schema.isObject(n))return i.createRangeOn(n);n=n.parent}return null}(e,l.parent))):function(e,t){const i=e.model,n=i.schema,o=i.createPositionAt(t,0);return n.getNearestSelectionRange(o,"forward")}(e,a)}function nk(e){return c.isGecko?e.dropEffect:["all","copyMove"].includes(e.effectAllowed)?"move":"copy"}function ok(e){if(e.is("editableElement"))return null;if(e.hasClass("ck-widget__selection-handle"))return e.findAncestor(Op);if(Op(e))return e;const t=e.findAncestor((e=>Op(e)||e.is("editableElement")));return Op(t)?t:null}class rk extends vs{static get pluginName(){return"PastePlainText"}static get requires(){return[Jw]}init(){const e=this.editor,t=e.model,i=e.editing.view,n=i.document,o=t.document.selection;let r=!1;i.addObserver(Kw),this.listenTo(n,"keydown",((e,t)=>{r=t.shiftKey})),e.plugins.get(Jw).on("contentInsertion",((e,i)=>{(r||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(o.getAttributes()).filter((([e])=>t.schema.getAttributeProperties(e).isFormatting));o.isCollapsed||t.deleteContent(o,{doNotAutoparagraph:!0}),n.push(...o.getAttributes());const r=e.createRangeIn(i.content);for(const t of r.getItems())t.is("$textProxy")&&e.setAttributes(n,t)}))}))}}class sk extends vs{static get pluginName(){return"Clipboard"}static get requires(){return[Jw,tk,rk]}}Kn("px");class ak extends As{constructor(e){super(e),this.affectsData=!1}execute(){const e=this.editor.model,t=e.document.selection;let i=e.schema.getLimitElement(t);if(t.containsEntireContent(i)||!lk(e.schema,i))do{if(i=i.parent,!i)return}while(!lk(e.schema,i));e.change((e=>{e.setSelection(i,"in")}))}}function lk(e,t){return e.isLimit(t)&&(e.checkChild(t,"$text")||e.checkChild(t,"paragraph"))}const ck=_o("Ctrl+A");class dk extends vs{static get pluginName(){return"SelectAllEditing"}init(){const e=this.editor,t=e.editing.view.document;e.commands.add("selectAll",new ak(e)),this.listenTo(t,"keydown",((t,i)=>{ko(i)===ck&&(e.execute("selectAll"),i.preventDefault())}))}}class uk extends vs{static get pluginName(){return"SelectAllUI"}init(){const e=this.editor;e.ui.componentFactory.add("selectAll",(t=>{const i=e.commands.get("selectAll"),n=new Er(t),o=t.t;return n.set({label:o("Select all"),icon:'',keystroke:"Ctrl+A",tooltip:!0}),n.bind("isEnabled").to(i,"isEnabled"),this.listenTo(n,"execute",(()=>{e.execute("selectAll"),e.editing.view.focus()})),n}))}}class hk extends vs{static get requires(){return[dk,uk]}static get pluginName(){return"SelectAll"}}class mk extends As{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()}))}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,o=n.document,r=[],s=e.map((e=>e.getTransformedByOperations(i))),a=s.flat();for(const e of s){const t=e.filter((e=>e.root!=o.graveyard)).filter((e=>!gk(e,a)));t.length&&(fk(t),r.push(t[0]))}r.length&&n.change((e=>{e.setSelection(r,{backward:t})}))}_undo(e,t){const i=this.editor.model,n=i.document;this._createdBatches.add(t);const o=e.operations.slice().filter((e=>e.isDocumentOperation));o.reverse();for(const e of o){const o=e.baseVersion+1,r=Array.from(n.history.getOperations(o)),s=qu([e.getReversed()],r,{useRelations:!0,document:this.editor.model.document,padWithNoOps:!1,forceWeakRemove:!0}).operationsA;for(let o of s){const r=o.affectedSelectable;r&&!i.canEditAt(r)&&(o=new Lu(o.baseVersion)),t.addOperation(o),i.applyOperation(o),n.history.setOperationAsUndone(e,o)}}}}function fk(e){e.sort(((e,t)=>e.start.isBefore(t.start)?-1:1));for(let t=1;tt!==e&&t.containsRange(e,!0)))}class pk extends mk{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 bk extends mk{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 wk extends vs{constructor(){super(...arguments),this._batchRegistry=new WeakSet}static get pluginName(){return"UndoEditing"}init(){const e=this.editor;this._undoCommand=new pk(e),this._redoCommand=new bk(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,o=this._redoCommand.createdBatches.has(n),r=this._undoCommand.createdBatches.has(n);this._batchRegistry.has(n)||(this._batchRegistry.add(n),n.isUndoable&&(o?this._undoCommand.addBatch(n):r||(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")}}const kk='',_k='';class vk extends vs{static get pluginName(){return"UndoUI"}init(){const e=this.editor,t=e.locale,i=e.t,n="ltr"==t.uiLanguageDirection?kk:_k,o="ltr"==t.uiLanguageDirection?_k:kk;this._addButton("undo",i("Undo"),"CTRL+Z",n),this._addButton("redo",i("Redo"),"CTRL+Y",o)}_addButton(e,t,i,n){const o=this.editor;o.ui.componentFactory.add(e,(r=>{const s=o.commands.get(e),a=new Er(r);return a.set({label:t,icon:n,keystroke:i,tooltip:!0}),a.bind("isEnabled").to(s,"isEnabled"),this.listenTo(a,"execute",(()=>{o.execute(e),o.editing.view.focus()})),a}))}}class yk extends vs{static get requires(){return[wk,vk]}static get pluginName(){return"Undo"}}class Ak extends vs{static get requires(){return[sk,kp,hk,Ap,ip,yk]}static get pluginName(){return"Essentials"}}class xk extends As{refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,i=t.schema,n=t.document.selection,o=Array.from(n.getSelectedBlocks()),r=void 0===e.forceValue?!this.value:e.forceValue;t.change((e=>{if(r){const t=o.filter((e=>Ek(e)||Sk(i,e)));this._applyQuote(e,t)}else this._removeQuote(e,o.filter(Ek))}))}_getValue(){const e=Po(this.editor.model.document.selection.getSelectedBlocks());return!(!e||!Ek(e))}_checkEnabled(){if(this.value)return!0;const e=this.editor.model.document.selection,t=this.editor.model.schema,i=Po(e.getSelectedBlocks());return!!i&&Sk(t,i)}_removeQuote(e,t){Ck(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=[];Ck(e,t).reverse().forEach((t=>{let n=Ek(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 Ek(e){return"blockQuote"==e.parent.name?e.parent:null}function Ck(e,t){let i,n=0;const o=[];for(;n{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,o=e.commands.get("blockQuote");this.listenTo(i,"enter",((t,i)=>{if(!n.isCollapsed||!o.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||!o.value)return;const r=n.getLastPosition().parent;r.isEmpty&&!r.previousSibling&&(e.execute("blockQuote"),e.editing.view.scrollToTheSelection(),i.preventDefault(),t.stop())}),{context:"blockquote"})}}var Pk=i(5558),Ik={attributes:{"data-cke":!0}};Ik.setAttributes=$o(),Ik.insert=Wo().bind(null,"head"),Ik.domAPI=Ho(),Ik.insertStyleElement=Go();jo()(Pk.Z,Ik);Pk.Z&&Pk.Z.locals&&Pk.Z.locals;class Ok extends vs{static get pluginName(){return"BlockQuoteUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add("blockQuote",(i=>{const n=e.commands.get("blockQuote"),o=new Er(i);return o.set({label:t("Block quote"),icon:_m.quote,tooltip:!0,isToggleable:!0}),o.bind("isOn","isEnabled").to(n,"value","isEnabled"),this.listenTo(o,"execute",(()=>{e.execute("blockQuote"),e.editing.view.focus()})),o}))}}class Mk extends vs{static get requires(){return[Tk,Ok]}static get pluginName(){return"BlockQuote"}}function Rk(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 Nk(e,t,i){const n={};for(const o of e)if("class"===t){n[o[t].split(" ").shift()]=o[i]}else n[o[t]]=o[i];return n}function Vk(e){return e.data.match(/^(\s*)/)[0]}function Dk(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:o}=t.textNode;if(!n.is("element","codeBlock"))continue;const r=Vk(t.textNode),s=e.createPositionAt(n,o+r.length);i.push(s)}return i}function Lk(e){const t=Po(e.getSelectedBlocks());return!!t&&t.is("element","codeBlock")}function Bk(e,t){return!t.is("rootElement")&&!e.isLimit(t)&&e.checkChild(t.parent,"codeBlock")}class zk extends As{constructor(e){super(e),this._lastLanguage=null}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor,i=t.model,n=i.document.selection,o=Rk(t)[0],r=Array.from(n.getSelectedBlocks()),s=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,o.language);i.change((e=>{s?this._applyCodeBlock(e,r,a):this._removeCodeBlock(e,r)}))}_getValue(){const e=Po(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=Po(e.getSelectedBlocks());return!!i&&Bk(t,i)}_applyCodeBlock(e,t,i){this._lastLanguage=i;const n=this.editor.model.schema,o=t.filter((e=>Bk(n,e)));for(const t of o)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)));o.reverse().forEach(((t,i)=>{const n=o[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)}}}class jk extends As{constructor(e){super(e),this._indentSequence=e.config.get("codeBlock.indentSequence")}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model;e.change((t=>{const i=Dk(e);for(const n of i){const i=t.createText(this._indentSequence);e.insertContent(i,n)}}))}_checkEnabled(){return!!this._indentSequence&&Lk(this.editor.model.document.selection)}}class Fk extends As{constructor(e){super(e),this._indentSequence=e.config.get("codeBlock.indentSequence")}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model;e.change((()=>{const t=Dk(e);for(const i of t){const t=Hk(e,i,this._indentSequence);t&&e.deleteContent(e.createSelection(t))}}))}_checkEnabled(){if(!this._indentSequence)return!1;const e=this.editor.model;return!!Lk(e.document.selection)&&Dk(e).some((t=>Hk(e,t,this._indentSequence)))}}function Hk(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 o=Vk(n),r=o.lastIndexOf(i);if(r+i.length!==o.length)return null;if(-1===r)return null;const{parent:s,startOffset:a}=n;return e.createRange(e.createPositionAt(s,a+r),e.createPositionAt(s,a+r+i.length))}function Uk(e,t,i=!1){const n=Nk(t,"language","class"),o=Nk(t,"language","label");return(t,r,s)=>{const{writer:a,mapper:l,consumable:c}=s;if(!c.consume(r.item,"insert"))return;const d=r.item.getAttribute("language"),u=l.toViewPosition(e.createPositionBefore(r.item)),h={};i&&(h["data-language"]=o[d],h.spellcheck="false");const m=n[d]?{class:n[d]}:void 0,f=a.createContainerElement("code",m),g=a.createContainerElement("pre",h,f);a.insert(u,g),l.bindElements(r.item,f)}}const Wk="paragraph";class Zk extends vs{static get pluginName(){return"CodeBlockEditing"}static get requires(){return[Ap]}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"})}init(){const e=this.editor,t=e.model.schema,i=e.model,n=e.editing.view,o=e.plugins.has("DocumentListEditing"),r=Rk(e);e.commands.add("codeBlock",new zk(e)),e.commands.add("indentCodeBlock",new jk(e)),e.commands.add("outdentCodeBlock",new Fk(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)=>{const i=e.endsWith("codeBlock")&&t.startsWith("list")&&"list"!==t;return!(!o||!i)||!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",Uk(i,r,!0)),e.data.downcastDispatcher.on("insert:codeBlock",Uk(i,r)),e.data.downcastDispatcher.on("insert:softBreak",function(e){return(t,i,n)=>{if("codeBlock"!==i.item.parent.name)return;const{writer:o,mapper:r,consumable:s}=n;if(!s.consume(i.item,"insert"))return;const a=r.toViewPosition(e.createPositionBefore(i.item));o.insert(a,o.createText("\n"))}}(i),{priority:"high"}),e.data.upcastDispatcher.on("element:code",function(e,t){const i=Nk(t,"class","language"),n=t[0].language;return(e,t,o)=>{const r=t.viewItem,s=r.parent;if(!s||!s.is("element","pre"))return;if(t.modelCursor.findAncestor("codeBlock"))return;const{consumable:a,writer:l}=o;if(!a.test(r,{name:!0}))return;const c=l.createElement("codeBlock"),d=[...r.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),o.convertChildren(r,c),o.safeInsert(c,t.modelCursor)&&(a.consume(r,{name:!0}),o.updateConversionResult(c,t))}}(0,r)),e.data.upcastDispatcher.on("text",((e,t,{consumable:i,writer:n})=>{let o=t.modelCursor;if(!i.test(t.viewItem))return;if(!o.findAncestor("codeBlock"))return;i.consume(t.viewItem);const r=t.viewItem.data.split("\n").map((e=>n.createText(e))),s=r[r.length-1];for(const e of r)if(n.insert(e,o),o=o.getShiftedBy(e.offsetSize),e!==s){const e=n.createElement("softBreak");n.insert(e,o),o=n.createPositionAfter(e)}t.modelRange=n.createRange(t.modelCursor,o),t.modelCursor=o})),e.data.upcastDispatcher.on("element:pre",((e,t,{consumable:i})=>{const n=t.viewItem;if(n.findAncestor("pre"))return;const o=Array.from(n.getChildren()),r=o.find((e=>e.is("element","code")));if(r)for(const e of o)e!==r&&e.is("$text")&&i.consume(e,{name:!0})}),{priority:"high"}),this.listenTo(e.editing.view.document,"clipboardInput",((t,n)=>{let o=i.createRange(i.document.selection.anchor);if(n.targetRanges&&(o=e.editing.mapper.toModelRange(n.targetRanges[0])),!o.start.parent.is("element","codeBlock"))return;const r=n.dataTransfer.getData("text/plain"),s=new Hh(e.editing.view.document);n.content=function(e,t){const i=e.createDocumentFragment(),n=t.split("\n"),o=n.reduce(((t,i,o)=>(t.push(i),o{const o=n.anchor;!n.isCollapsed&&o.parent.is("element","codeBlock")&&o.hasSameParentAs(n.focus)&&i.change((i=>{const r=e.return;if(o.parent.is("element")&&(r.childCount>1||n.containsEntireContent(o.parent))){const t=i.createElement("codeBlock",o.parent.getAttributes());i.append(r,t);const n=i.createDocumentFragment();return i.append(t,n),void(e.return=n)}const s=r.getChild(0);t.checkAttribute(s,"code")&&i.setAttribute("code",!0,s)}))}))}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,o=e.editing.view,r=n.selection.getLastPosition(),s=r.nodeAfter;if(t||!n.selection.isCollapsed||!r.isAtStart)return!1;if(!qk(s))return!1;return e.model.change((t=>{e.execute("enter");const i=n.selection.anchor.parent.previousSibling;t.rename(i,Wk),t.setSelection(i,"in"),e.model.schema.removeDisallowedAttributes([i],t),t.remove(s)})),o.scrollToTheSelection(),!0}(e,i.isSoft)||function(e,t){const i=e.model,n=i.document,o=e.editing.view,r=n.selection.getLastPosition(),s=r.nodeBefore;let a;if(t||!n.selection.isCollapsed||!r.isAtEnd||!s||!s.previousSibling)return!1;if(qk(s)&&qk(s.previousSibling))a=i.createRange(i.createPositionBefore(s.previousSibling),i.createPositionAfter(s));else if($k(s)&&qk(s.previousSibling)&&qk(s.previousSibling.previousSibling))a=i.createRange(i.createPositionBefore(s.previousSibling.previousSibling),i.createPositionAfter(s));else{if(!($k(s)&&qk(s.previousSibling)&&$k(s.previousSibling.previousSibling)&&s.previousSibling.previousSibling&&qk(s.previousSibling.previousSibling.previousSibling)))return!1;a=i.createRange(i.createPositionBefore(s.previousSibling.previousSibling.previousSibling),i.createPositionAfter(s))}return e.model.change((t=>{t.remove(a),e.execute("enter");const i=n.selection.anchor.parent;t.rename(i,Wk),e.model.schema.removeDisallowedAttributes([i],t)})),o.scrollToTheSelection(),!0}(e,i.isSoft)||function(e){const t=e.model,i=t.document,n=i.selection.getLastPosition(),o=n.nodeBefore||n.textNode;let r;o&&o.is("$text")&&(r=Vk(o));e.model.change((t=>{e.execute("shiftEnter"),r&&t.insertText(r,i.selection.anchor)}))}(e),i.preventDefault(),t.stop())}),{context:"pre"})}}function $k(e){return e&&e.is("$text")&&!e.data.match(/\S/)}function qk(e){return e&&e.is("element","softBreak")}var Gk=i(348),Kk={attributes:{"data-cke":!0}};Kk.setAttributes=$o(),Kk.insert=Wo().bind(null,"head"),Kk.domAPI=Ho(),Kk.insertStyleElement=Go();jo()(Gk.Z,Kk);Gk.Z&&Gk.Z.locals&&Gk.Z.locals;class Yk extends vs{static get pluginName(){return"CodeBlockUI"}init(){const e=this.editor,t=e.t,i=e.ui.componentFactory,n=Rk(e);i.add("codeBlock",(i=>{const o=e.commands.get("codeBlock"),r=Fm(i,Dm),s=r.buttonView,a=t("Insert code block");return s.set({label:a,tooltip:!0,icon:'',isToggleable:!0}),s.bind("isOn").to(o,"value",(e=>!!e)),s.on("execute",(()=>{e.execute("codeBlock",{usePreviousLanguageChoice:!0}),e.editing.view.focus()})),r.on("execute",(t=>{e.execute("codeBlock",{language:t.source._codeBlockLanguage,forceValue:!0}),e.editing.view.focus()})),r.class="ck-code-block-dropdown",r.bind("isEnabled").to(o),Wm(r,(()=>this._getLanguageListItemDefinitions(n)),{role:"menu",ariaLabel:a}),r}))}_getLanguageListItemDefinitions(e){const t=this.editor.commands.get("codeBlock"),i=new To;for(const n of e){const e={type:"button",model:new ug({_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 Qk extends vs{static get requires(){return[Zk,Yk]}static get pluginName(){return"CodeBlock"}}class Jk extends As{constructor(e){super(e),this._isEnabledBasedOnSelection=!1}refresh(){const e=this.editor.model,t=Po(e.document.selection.getSelectedBlocks());this.value=!!t&&t.is("element","paragraph"),this.isEnabled=!!t&&Xk(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")&&Xk(n,t.schema)&&e.rename(n,"paragraph")}))}}function Xk(e,t){return t.checkChild(e.parent,"paragraph")&&!t.isObject(e)}class e_ extends As{constructor(e){super(e),this._isEnabledBasedOnSelection=!1}execute(e){const t=this.editor.model,i=e.attributes;let n=e.position;t.canEditAt(n)&&t.change((e=>{const o=e.createElement("paragraph");if(i&&t.schema.setAllowedAttributes(o,i,e),!t.schema.checkChild(n.parent,o)){const i=t.schema.findAllowedParent(n,o);if(!i)return;n=e.split(n,i).position}t.insertContent(o,n),e.setSelection(o,"in")}))}}class t_ extends vs{static get pluginName(){return"Paragraph"}init(){const e=this.editor,t=e.model;e.commands.add("paragraph",new Jk(e)),e.commands.add("insertParagraph",new e_(e)),t.schema.register("paragraph",{inheritAllFrom:"$block"}),e.conversion.elementToElement({model:"paragraph",view:"p"}),e.conversion.for("upcast").elementToElement({model:(e,{writer:t})=>t_.paragraphLikeElements.has(e.name)?e.isEmpty?null:t.createElement("paragraph"):null,view:/.+/,converterPriority:"low"})}}t_.paragraphLikeElements=new Set(["blockquote","dd","div","dt","h1","h2","h3","h4","h5","h6","li","p","td","th"]);class i_ extends As{constructor(e,t){super(e),this.modelElements=t}refresh(){const e=Po(this.editor.model.document.selection.getSelectedBlocks());this.value=!!e&&this.modelElements.includes(e.name)&&e.name,this.isEnabled=!!e&&this.modelElements.some((t=>n_(e,t,this.editor.model.schema)))}execute(e){const t=this.editor.model,i=t.document,n=e.value;t.change((e=>{const o=Array.from(i.selection.getSelectedBlocks()).filter((e=>n_(e,n,t.schema)));for(const t of o)t.is("element",n)||e.rename(t,n)}))}}function n_(e,t,i){return i.checkChild(e.parent,t)&&!i.isObject(e)}const o_="paragraph";class r_ extends vs{static get pluginName(){return"HeadingEditing"}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"}]})}static get requires(){return[t_]}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 i_(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 o=e.model.document.selection.getFirstPosition().parent;i.some((e=>o.is("element",e.model)))&&!o.is("element",o_)&&0===o.childCount&&n.writer.rename(o,o_)}))}_addDefaultH1Conversion(e){e.conversion.for("upcast").elementToElement({model:"heading1",view:"h1",converterPriority:k.low+1})}}var s_=i(4684),a_={attributes:{"data-cke":!0}};a_.setAttributes=$o(),a_.insert=Wo().bind(null,"head"),a_.domAPI=Ho(),a_.insertStyleElement=Go();jo()(s_.Z,a_);s_.Z&&s_.Z.locals&&s_.Z.locals;class l_ extends vs{static get pluginName(){return"HeadingUI"}init(){const e=this.editor,t=e.t,i=function(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}))}(e),n=t("Choose heading"),o=t("Heading");e.ui.componentFactory.add("heading",(t=>{const r={},s=new To,a=e.commands.get("heading"),l=e.commands.get("paragraph"),c=[a];for(const e of i){const t={type:"button",model:new ug({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})),s.add(t),r[e.model]=e.title}const d=Fm(t);return Wm(d,s,{ariaLabel:o,role:"menu"}),d.buttonView.set({ariaLabel:o,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:o}),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=e||t&&"paragraph";return"boolean"==typeof i?n:r[i]?r[i]:n})),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}))}}class c_ extends vs{static get requires(){return[r_,l_]}static get pluginName(){return"Heading"}}class d_ extends As{constructor(e,t){super(e),this.type=t}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=>h_(e,t.schema))),o=void 0!==e.forceValue?!e.forceValue:this.value;t.change((e=>{if(o){let t=n[n.length-1].nextSibling,i=Number.POSITIVE_INFINITY,o=[];for(;t&&"listItem"==t.name&&0!==t.getAttribute("listIndent");){const e=t.getAttribute("listIndent");e=i;)r>o.getAttribute("listIndent")&&(r=o.getAttribute("listIndent")),o.getAttribute("listIndent")==r&&e[t?"unshift":"push"](o),o=o[t?"previousSibling":"nextSibling"]}}function h_(e,t){return t.checkChild(e.parent,"listItem")&&!t.isObject(e)}class m_ extends As{constructor(e,t){super(e),this._indentBy="forward"==t?1:-1}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=Po(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}}function f_(e,t){const i=t.mapper,n=t.writer,o="numbered"==e.getAttribute("listType")?"ol":"ul",r=function(e){const t=e.createContainerElement("li");return t.getFillerOffset=A_,t}(n),s=n.createContainerElement(o,null);return n.insert(n.createPositionAt(s,0),r),i.bindElements(e,r),r}function g_(e,t,i,n){const o=t.parent,r=i.mapper,s=i.writer;let a=r.toViewPosition(n.createPositionBefore(e));const l=w_(e.previousSibling,{sameIndent:!0,smallerIndent:!0,listIndent:e.getAttribute("listIndent")}),c=e.previousSibling;if(l&&l.getAttribute("listIndent")==e.getAttribute("listIndent")){const e=r.toViewElement(l);a=s.breakContainer(s.createPositionAfter(e))}else if(c&&"listItem"==c.name){a=r.toViewPosition(n.createPositionAt(c,"end"));const e=r.findMappedViewAncestor(a),t=function(e){for(const t of e.getChildren())if("ul"==t.name||"ol"==t.name)return t;return null}(e);a=t?s.createPositionBefore(t):s.createPositionAt(e,"end")}else a=r.toViewPosition(n.createPositionBefore(e));if(a=b_(a),s.insert(a,o),c&&"listItem"==c.name){const e=r.toViewElement(c),i=s.createRange(s.createPositionAt(e,0),a).getWalker({ignoreElementEnd:!0});for(const e of i)if(e.item.is("element","li")){const n=s.breakContainer(s.createPositionBefore(e.item)),o=e.item.parent,r=s.createPositionAt(t,"end");p_(s,r.nodeBefore,r.nodeAfter),s.move(s.createRangeOn(o),r),i._position=n}}else{const i=o.nextSibling;if(i&&(i.is("element","ul")||i.is("element","ol"))){let n=null;for(const t of i.getChildren()){const i=r.toModelElement(t);if(!(i&&i.getAttribute("listIndent")>e.getAttribute("listIndent")))break;n=t}n&&(s.breakContainer(s.createPositionAfter(n)),s.move(s.createRangeOn(n.parent),s.createPositionAt(t,"end")))}}p_(s,o,o.nextSibling),p_(s,o.previousSibling,o)}function p_(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 b_(e){return e.getLastMatchingPosition((e=>e.item.is("uiElement")))}function w_(e,t){const i=!!t.sameIndent,n=!!t.smallerIndent,o=t.listIndent;let r=e;for(;r&&"listItem"==r.name;){const e=r.getAttribute("listIndent");if(i&&o==e||n&&o>e)return r;r="forward"===t.direction?r.nextSibling:r.previousSibling}return null}function k_(e,t,i,n){e.ui.componentFactory.add(t,(o=>{const r=e.commands.get(t),s=new Er(o);return s.set({label:i,icon:n,tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(r,"value","isEnabled"),s.on("execute",(()=>{e.execute(t),e.editing.view.focus()})),s}))}function __(e,t){const i=[],n=e.parent,o={ignoreElementEnd:!1,startPosition:e,shallow:!0,direction:t},r=n.getAttribute("listIndent"),s=[...new qc(o)].filter((e=>e.item.is("element"))).map((e=>e.item));for(const e of s){if(!e.is("element","listItem"))break;if(e.getAttribute("listIndent")r)){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}const v_=["disc","circle","square"],y_=["decimal","decimal-leading-zero","lower-roman","upper-roman","lower-latin","upper-latin"];function A_(){const e=!this.isEmpty&&("ul"==this.getChild(0).name||"ol"==this.getChild(0).name);return this.isEmpty||e?0:Wa.call(this)}class x_ extends vs{static get pluginName(){return"ListUtils"}getListTypeFromListStyleType(e){return function(e){return v_.includes(e)?"bulleted":y_.includes(e)?"numbered":null}(e)}getSelectedListItems(e){return function(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[...__(i,"backward"),...__(i,"forward")]})).flat();return t=[...new Set(t)],t}(e)}getSiblingNodes(e,t){return __(e,t)}}function E_(e){return(t,i,n)=>{const o=n.consumable;if(!o.test(i.item,"insert")||!o.test(i.item,"attribute:listType")||!o.test(i.item,"attribute:listIndent"))return;o.consume(i.item,"insert"),o.consume(i.item,"attribute:listType"),o.consume(i.item,"attribute:listIndent");const r=i.item;g_(r,f_(r,n),n,e)}}const C_=(e,t,i)=>{if(!i.consumable.test(t.item,e.name))return;const n=i.mapper.toViewElement(t.item),o=i.writer;o.breakContainer(o.createPositionBefore(n)),o.breakContainer(o.createPositionAfter(n));const r=n.parent,s="numbered"==t.attributeNewValue?"ol":"ul";o.rename(s,r)},S_=(e,t,i)=>{i.consumable.consume(t.item,e.name);const n=i.mapper.toViewElement(t.item).parent,o=i.writer;p_(o,n,n.nextSibling),p_(o,n.previousSibling,n)};const T_=(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,o=[];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));o.push(e)}e=n.createPositionAfter(e.parent)}if(o.length>0){for(let t=0;t0){const t=p_(n,i,i.nextSibling);t&&t.parent==i&&e.offset--}}p_(n,e.nodeBefore,e.nodeAfter)}}},P_=(e,t,i)=>{const n=i.mapper.toViewPosition(t.position),o=n.nodeBefore,r=n.nodeAfter;p_(i.writer,o,r)},I_=(e,t,i)=>{if(i.consumable.consume(t.viewItem,{name:!0})){const e=i.writer,n=e.createElement("listItem"),o=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",o,n);const r=t.viewItem.parent&&"ol"==t.viewItem.parent.name?"numbered":"bulleted";if(e.setAttribute("listType",r,n),!i.safeInsert(n,t.modelCursor))return;const s=function(e,t,i){const{writer:n,schema:o}=i;let r=n.createPositionAfter(e);for(const s of t)if("ul"==s.name||"ol"==s.name)r=i.convertItem(s,r).modelCursor;else{const t=i.convertItem(s,n.createPositionAt(e,"end")),a=t.modelRange.start.nodeAfter;a&&a.is("element")&&!o.checkChild(e,a.name)&&(e=t.modelCursor.parent.is("element","listItem")?t.modelCursor.parent:V_(t.modelCursor),r=n.createPositionAfter(e))}return r}(n,t.viewItem.getChildren(),i);t.modelRange=e.createRange(t.modelCursor,s),i.updateConversionResult(n,t)}},O_=(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")||L_(t))&&t._remove()}}},M_=(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&&!L_(t)&&t._remove(),L_(t)&&(i=!0)}};function R_(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),o=t.getAncestors().find(L_),r=e.createPositionAt(t,0).getWalker();for(const e of r){if("elementStart"==e.type&&e.item.is("element","li")){i.viewPosition=e.previousPosition;break}if("elementEnd"==e.type&&e.item==o){i.viewPosition=e.nextPosition;break}}}}}const N_=function(e,[t,i]){const n=this;let o,r=t.is("documentFragment")?t.getChild(0):t;if(o=i?n.createSelection(i):n.document.selection,r&&r.is("element","listItem")){const e=o.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(;r&&r.is("element","listItem");)r._setAttribute("listIndent",r.getAttribute("listIndent")+e),r=r.nextSibling}}};function V_(e){const t=new qc({startPosition:e});let i;do{i=t.next()}while(!i.value.item.is("element","listItem"));return i.value.item}function D_(e,t,i,n,o,r){const s=w_(t.nodeBefore,{sameIndent:!0,smallerIndent:!0,listIndent:e}),a=o.mapper,l=o.writer,c=s?s.getAttribute("listIndent"):null;let d;if(s)if(c==e){const e=a.toViewElement(s).parent;d=l.createPositionAfter(e)}else{const e=r.createPositionAt(s,"end");d=a.toViewPosition(e)}else d=i;d=b_(d);for(const e of[...n.getChildren()])L_(e)&&(d=l.move(l.createRangeOn(e),d).end,p_(l,e,e.nextSibling),p_(l,e.previousSibling,e))}function L_(e){return e.is("element","ol")||e.is("element","ul")}var B_=i(7872),z_={attributes:{"data-cke":!0}};z_.setAttributes=$o(),z_.insert=Wo().bind(null,"head"),z_.domAPI=Ho(),z_.insertStyleElement=Go();jo()(B_.Z,z_);B_.Z&&B_.Z.locals&&B_.Z.locals;class j_ extends vs{static get pluginName(){return"ListEditing"}static get requires(){return[kp,tp,x_]}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 o=!1;for(const n of i)if("insert"==n.type&&"listItem"==n.name)r(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),o=!0),i.hasAttribute("listType")&&(t.removeAttribute("listType",i),o=!0),i.hasAttribute("listStyle")&&(t.removeAttribute("listStyle",i),o=!0),i.hasAttribute("listReversed")&&(t.removeAttribute("listReversed",i),o=!0),i.hasAttribute("listStart")&&(t.removeAttribute("listStart",i),o=!0);for(const t of Array.from(e.createRangeIn(i)).filter((e=>e.item.is("element","listItem"))))r(t.previousPosition)}r(n.position.getShiftedBy(n.length))}else"remove"==n.type&&"listItem"==n.name?r(n.position):("attribute"==n.type&&"listIndent"==n.attributeKey||"attribute"==n.type&&"listType"==n.attributeKey)&&r(n.range.start);for(const e of n.values())s(e),a(e);return o;function r(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 s(e){let i=0,n=null;for(;e&&e.is("element","listItem");){const r=e.getAttribute("listIndent");if(r>i){let s;null===n?(n=r-i,s=i):(n>r&&(n=r),s=r-n),t.setAttribute("listIndent",s,e),o=!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 r=e.getAttribute("listIndent");if(n&&n.getAttribute("listIndent")>r&&(i=i.slice(0,r+1)),0!=r)if(i[r]){const n=i[r];e.getAttribute("listType")!=n&&(t.setAttribute("listType",n,e),o=!0)}else i[r]=e.getAttribute("listType");n=e,e=e.nextSibling}}}(e.model,t))),i.mapper.registerViewToModelLength("li",F_),t.mapper.registerViewToModelLength("li",F_),i.mapper.on("modelToViewPosition",R_(i.view)),i.mapper.on("viewToModelPosition",(n=e.model,(e,t)=>{const i=t.viewPosition,o=i.parent,r=t.mapper;if("ul"==o.name||"ol"==o.name){if(i.isAtEnd){const e=r.toModelElement(i.nodeBefore),o=r.getModelLength(i.nodeBefore);t.modelPosition=n.createPositionBefore(e).getShiftedBy(o)}else{const e=r.toModelElement(i.nodeAfter);t.modelPosition=n.createPositionBefore(e)}e.stop()}else if("li"==o.name&&i.nodeBefore&&("ul"==i.nodeBefore.name||"ol"==i.nodeBefore.name)){const s=r.toModelElement(o);let a=1,l=i.nodeBefore;for(;l&&L_(l);)a+=r.getModelLength(l),l=l.previousSibling;t.modelPosition=n.createPositionBefore(s).getShiftedBy(a),e.stop()}})),t.mapper.on("modelToViewPosition",R_(i.view)),e.conversion.for("editingDowncast").add((t=>{t.on("insert",T_,{priority:"high"}),t.on("insert:listItem",E_(e.model)),t.on("attribute:listType:listItem",C_,{priority:"high"}),t.on("attribute:listType:listItem",S_,{priority:"low"}),t.on("attribute:listIndent:listItem",function(e){return(t,i,n)=>{if(!n.consumable.consume(i.item,"attribute:listIndent"))return;const o=n.mapper.toViewElement(i.item),r=n.writer;r.breakContainer(r.createPositionBefore(o)),r.breakContainer(r.createPositionAfter(o));const s=o.parent,a=s.previousSibling,l=r.createRangeOn(s);r.remove(l),a&&a.nextSibling&&p_(r,a,a.nextSibling),D_(i.attributeOldValue+1,i.range.start,l.start,o,n,e),g_(i.item,o,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 o=n.mapper.toViewPosition(i.position).getLastMatchingPosition((e=>!e.item.is("element","li"))).nodeAfter,r=n.writer;r.breakContainer(r.createPositionBefore(o)),r.breakContainer(r.createPositionAfter(o));const s=o.parent,a=s.previousSibling,l=r.createRangeOn(s),c=r.remove(l);a&&a.nextSibling&&p_(r,a,a.nextSibling),D_(n.mapper.toModelElement(o).getAttribute("listIndent")+1,i.position,l.start,o,n,e);for(const e of r.createRangeIn(c).getItems())n.mapper.unbindViewElement(e);t.stop()}}(e.model)),t.on("remove",P_,{priority:"low"})})),e.conversion.for("dataDowncast").add((t=>{t.on("insert",T_,{priority:"high"}),t.on("insert:listItem",E_(e.model))})),e.conversion.for("upcast").add((e=>{e.on("element:ul",O_,{priority:"high"}),e.on("element:ol",O_,{priority:"high"}),e.on("element:li",M_,{priority:"high"}),e.on("element:li",I_)})),e.model.on("insertContent",N_,{priority:"high"}),e.commands.add("numberedList",new d_(e,"numbered")),e.commands.add("bulletedList",new d_(e,"bulleted")),e.commands.add("indentList",new m_(e,"forward")),e.commands.add("outdentList",new m_(e,"backward"));const o=i.view.document;this.listenTo(o,"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(o,"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 o=n.parent;if("listItem"!==o.name)return;o.previousSibling&&"listItem"===o.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 F_(e){let t=1;for(const i of e.getChildren())if("ul"==i.name||"ol"==i.name)for(const e of i.getChildren())t+=F_(e);return t}class H_ extends vs{static get pluginName(){return"ListUI"}init(){const e=this.editor.t;k_(this.editor,"numberedList",e("Numbered List"),''),k_(this.editor,"bulletedList",e("Bulleted List"),'')}}class U_ extends vs{static get requires(){return[j_,H_]}static get pluginName(){return"List"}}function W_(e,t){return`${e}:${t=t||xo(e)}`}class Z_ extends As{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,o=!!e&&W_(e,t);i.change((e=>{if(n.isCollapsed)o?e.setSelectionAttribute("language",o):e.removeSelectionAttribute("language");else{const t=i.schema.getValidRanges(n.getRanges(),"language");for(const i of t)o?e.setAttribute("language",o,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 $_ extends vs{static get pluginName(){return"TextPartLanguageEditing"}constructor(e){super(e),e.config.define("language",{textPartLanguage:[{title:"Arabic",languageCode:"ar"},{title:"French",languageCode:"fr"},{title:"Spanish",languageCode:"es"}]})}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 Z_(e))}_defineConverters(){const e=this.editor.conversion;e.for("upcast").elementToAttribute({model:{key:"language",value:e=>W_(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:o}=function(e){const[t,i]=e.split(":");return{languageCode:t,textDirection:i}}(e);return t.createAttributeElement("span",{lang:n,dir:o})}})}}class q_ extends vs{static get pluginName(){return"TextPartLanguageUI"}init(){const e=this.editor,t=e.t,i=e.config.get("language.textPartLanguage"),n=t("Choose language"),o=t("Remove language"),r=t("Language");e.ui.componentFactory.add("textPartLanguage",(t=>{const s=new To,a={},l=e.commands.get("textPartLanguage");s.add({type:"button",model:new ug({label:o,languageCode:!1,withText:!0})}),s.add({type:"separator"});for(const e of i){const t={type:"button",model:new ug({label:e.title,languageCode:e.languageCode,role:"menuitemradio",textDirection:e.textDirection,withText:!0})},i=W_(e.languageCode,e.textDirection);t.model.bind("isOn").to(l,"value",(e=>e===i)),s.add(t),a[i]=e.title}const c=Fm(t);return Wm(c,s,{ariaLabel:r,role:"menu"}),c.buttonView.set({ariaLabel:r,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:r}),c.extendTemplate({attributes:{class:["ck-text-fragment-language-dropdown"]}}),c.bind("isEnabled").to(l,"isEnabled"),c.buttonView.bind("label").to(l,"value",(e=>e&&a[e]||n)),this.listenTo(c,"execute",(t=>{l.execute({languageCode:t.source.languageCode,textDirection:t.source.textDirection}),e.editing.view.focus()})),c}))}}class G_ extends vs{static get requires(){return[$_,q_]}static get pluginName(){return"TextPartLanguage"}}class K_ extends As{constructor(e,t){super(e),this.attributeKey=t}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,o=e.batch,r=e=>{if(i.isCollapsed)n?e.setSelectionAttribute(this.attributeKey,n):e.removeSelectionAttribute(this.attributeKey);else{const o=t.schema.getValidRanges(i.getRanges(),this.attributeKey);for(const t of o)n?e.setAttribute(this.attributeKey,n,t):e.removeAttribute(this.attributeKey,t)}};o?t.enqueueChange(o,(e=>{r(e)})):t.change((e=>{r(e)}))}}class Y_ extends(G(To)){constructor(e){super(e),this.set("isEmpty",!0),this.on("change",(()=>{this.set("isEmpty",0===this.length)}))}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))}}var Q_=i(4590),J_={attributes:{"data-cke":!0}};J_.setAttributes=$o(),J_.insert=Wo().bind(null,"head"),J_.domAPI=Ho(),J_.insertStyleElement=Go();jo()(Q_.Z,J_);Q_.Z&&Q_.Z.locals&&Q_.Z.locals;class X_ extends Qo{constructor(e,{colors:t,columns:i,removeButtonLabel:n,documentColorsLabel:o,documentColorsCount:r,colorPickerLabel:s,colorPickerConfig:a}){super(e),this.items=this.createCollection(),this.focusTracker=new Io,this.keystrokes=new Oo,this._focusables=new Bo,this._colorPickerConfig=a,this._focusCycler=new ps({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.colorGridsPageView=new ev(e,{colors:t,columns:i,removeButtonLabel:n,documentColorsLabel:o,documentColorsCount:r,colorPickerLabel:s,focusTracker:this.focusTracker,focusables:this._focusables}),this.colorPickerPageView=new tv(e,{focusables:this._focusables,focusTracker:this.focusTracker,keystrokes:this.keystrokes,colorPickerConfig:a}),this.set("_isColorGridsPageVisible",!0),this.set("_isColorPickerPageVisible",!1),this.set("selectedColor",void 0),this.colorGridsPageView.bind("isVisible").to(this,"_isColorGridsPageVisible"),this.colorPickerPageView.bind("isVisible").to(this,"_isColorPickerPageVisible"),this.on("change:selectedColor",((e,t,i)=>{this.colorGridsPageView.set("selectedColor",i),this.colorPickerPageView.set("selectedColor",i)})),this.colorGridsPageView.on("change:selectedColor",((e,t,i)=>{this.set("selectedColor",i)})),this.colorPickerPageView.on("change:selectedColor",((e,t,i)=>{this.set("selectedColor",i)})),this.setTemplate({tag:"div",attributes:{class:["ck","ck-color-table"]},children:this.items})}render(){super.render(),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}appendGrids(){this.items.length||(this.items.add(this.colorGridsPageView),this.colorGridsPageView.delegate("execute").to(this),this.colorGridsPageView.delegate("showColorPicker").to(this))}appendUI(){this.appendGrids(),this._colorPickerConfig&&this._appendColorPicker()}showColorPicker(){this.colorPickerPageView.colorPickerView&&(this.set("_isColorPickerPageVisible",!0),this.colorPickerPageView.focus(),this.set("_isColorGridsPageVisible",!1))}showColorGrids(){this.set("_isColorGridsPageVisible",!0),this.set("_isColorPickerPageVisible",!1)}focus(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}updateDocumentColors(e,t){this.colorGridsPageView.updateDocumentColors(e,t)}updateSelectedColors(){this.colorGridsPageView.updateSelectedColors()}_appendColorPicker(){2!==this.items.length&&(this.items.add(this.colorPickerPageView),this.colorGridsPageView.colorPickerButtonView&&this.colorGridsPageView.colorPickerButtonView.on("execute",(()=>{this.showColorPicker()})),this.colorGridsPageView.addColorPickerButton(),this.colorPickerPageView.delegate("execute").to(this),this.colorPickerPageView.delegate("cancel").to(this))}}class ev extends Qo{constructor(e,{colors:t,columns:i,removeButtonLabel:n,documentColorsLabel:o,documentColorsCount:r,colorPickerLabel:s,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 Y_,this.documentColorsCount=r,this._focusables=l,this._removeButtonLabel=n,this._colorPickerLabel=s,this._documentColorsLabel=o,this.setTemplate({tag:"div",attributes:{class:["ck-color-grids-page-view",c.if("isVisible","ck-hidden",(e=>!e))]},children:this.items}),this.removeColorButtonView=this._createRemoveColorButton(),this.items.add(this.removeColorButtonView)}updateDocumentColors(e,t){const i=e.document,n=this.documentColorsCount;this.documentColors.clear();for(const o of i.getRootNames()){const r=i.getRoot(o),s=e.createRangeIn(r);for(const e of s.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=Jo.bind(this.documentColors,this.documentColors),t=new is(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._addColorTablesElementsToFocusTracker(),this.focus()}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))}_addColorTablesElementsToFocusTracker(){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 Er,this.colorPickerButtonView.set({label:this._colorPickerLabel,withText:!0,icon:Sg,class:"ck-color-table__color-picker"}),this.colorPickerButtonView.on("execute",(()=>{this.fire("showColorPicker")}))}_createRemoveColorButton(){const e=new Er;return e.set({withText:!0,icon:_m.eraser,label:this._removeButtonLabel}),e.class="ck-color-table__remove-color",e.on("execute",(()=>{this.fire("execute",{value:null,source:"removeColorButton"})})),e.render(),e}_createStaticColorsGrid(){const e=new Rr(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=Jo.bind(this.documentColors,this.documentColors),t=new Rr(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 Ir;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}})}}class tv extends Qo{constructor(e,{focusTracker:t,focusables:i,keystrokes:n,colorPickerConfig:o}){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._pickerConfig=o;const r=this.bindTemplate,{saveButtonView:s,cancelButtonView:a}=this._createActionButtons();this.saveButtonView=s,this.cancelButtonView=a,this.actionBarView=this._createActionBarView({saveButtonView:s,cancelButtonView:a}),this.setTemplate({tag:"div",attributes:{class:["ck-color-picker-page-view",r.if("isVisible","ck-hidden",(e=>!e))]},children:this.items})}render(){super.render();const e=new Cf(this.locale,this._pickerConfig);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()}_executeOnEnterPress(){this.keystrokes.set("enter",(e=>{this.isVisible&&this.focusTracker.focusedElement!==this.cancelButtonView.element&&(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);this.focusTracker.add(this.colorPickerView.hexInputRow.children.get(1).element),this._focusables.add(this.colorPickerView.hexInputRow.children.get(1)),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 Qo,n=this.createCollection();return n.add(e),n.add(t),i.setTemplate({tag:"div",attributes:{class:["ck","ck-color-table_action-bar"]},children:n}),i}_createActionButtons(){const e=this.locale,t=e.t,i=new Er(e),n=new Er(e);return i.set({icon:_m.check,class:"ck-button-save",withText:!1,label:t("Accept"),type:"button"}),n.set({icon:_m.cancel,class:"ck-button-cancel",withText:!1,label:t("Cancel")}),i.on("execute",(()=>{this.fire("execute",{source:"saveButton",value:this.selectedColor})})),n.on("execute",(()=>{this.fire("cancel")})),{saveButtonView:i,cancelButtonView:n}}_executeUponColorChange(){this.colorPickerView.on("change:color",((e,t,i)=>{this.fire("execute",{value:i,source:"colorPicker"})}))}}const iv="fontSize",nv="fontFamily",ov="fontColor",rv="fontBackgroundColor";function sv(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 av(e){return t=>t.getStyle(e).replace(/\s/g,"")}function lv(e){return(t,{writer:i})=>i.createAttributeElement("span",{style:`${e}:${t}`},{priority:7})}class cv extends K_{constructor(e){super(e,nv)}}function dv(e){return e.map(uv).filter((e=>void 0!==e))}function uv(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(hv).join(", ");return{title:i,model:n,view:{name:"span",styles:{"font-family":n},priority:7}}}(e):void 0}function hv(e){return(e=e.trim()).indexOf(" ")>0&&(e=`'${e}'`),e}class mv extends vs{static get pluginName(){return"FontFamilyEditing"}constructor(e){super(e),e.config.define(nv,{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})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:nv}),e.model.schema.setAttributeProperties(nv,{isFormatting:!0,copyOnEnter:!0});const t=dv(e.config.get("fontFamily.options")).filter((e=>e.model)),i=sv(nv,t);e.config.get("fontFamily.supportAllValues")?(this._prepareAnyValueConverters(),this._prepareCompatibilityConverter()):e.conversion.attributeToElement(i),e.commands.add(nv,new cv(e))}_prepareAnyValueConverters(){const e=this.editor;e.conversion.for("downcast").attributeToElement({model:nv,view:(e,{writer:t})=>t.createAttributeElement("span",{style:"font-family:"+e},{priority:7})}),e.conversion.for("upcast").elementToAttribute({model:{key:nv,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:nv,value:e=>e.getAttribute("face")}})}}class fv extends vs{static get pluginName(){return"FontFamilyUI"}init(){const e=this.editor,t=e.t,i=this._getLocalizedOptions(),n=e.commands.get(nv),o=t("Font Family");e.ui.componentFactory.add(nv,(t=>{const r=Fm(t);return Wm(r,(()=>function(e,t){const i=new To;for(const n of e){const e={type:"button",model:new ug({commandName:nv,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)),{role:"menu",ariaLabel:o}),r.buttonView.set({label:o,icon:'',tooltip:!0}),r.extendTemplate({attributes:{class:"ck-font-family-dropdown"}}),r.bind("isEnabled").to(n),this.listenTo(r,"execute",(t=>{e.execute(t.source.commandName,{value:t.source.commandParam}),e.editing.view.focus()})),r}))}_getLocalizedOptions(){const e=this.editor,t=e.t;return dv(e.config.get(nv).options).map((e=>("Default"===e.title&&(e.title=t("Default")),e)))}}class gv extends vs{static get requires(){return[mv,fv]}static get pluginName(){return"FontFamily"}}class pv extends K_{constructor(e){super(e,iv)}}function bv(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 kv(e);var t;const i=function(e){return"string"==typeof e?wv[e]:wv[e.model]}(e);if(i)return kv(i);if("default"===e)return{model:void 0,title:"Default"};if(function(e){let t;if("object"==typeof e){if(!e.model)throw new y("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}},kv(e)}(e)}(e))).filter((e=>void 0!==e))}const wv={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 kv(e){return e.view&&"string"!=typeof e.view&&!e.view.priority&&(e.view.priority=7),e}const _v=["x-small","x-small","small","medium","large","x-large","xx-large","xxx-large"];class vv extends vs{static get pluginName(){return"FontSizeEditing"}constructor(e){super(e),e.config.define(iv,{options:["tiny","small","default","big","huge"],supportAllValues:!1})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:iv}),e.model.schema.setAttributeProperties(iv,{isFormatting:!0,copyOnEnter:!0});const t=e.config.get("fontSize.supportAllValues"),i=bv(this.editor.config.get("fontSize.options")).filter((e=>e.model)),n=sv(iv,i);t?(this._prepareAnyValueConverters(n),this._prepareCompatibilityConverter()):e.conversion.attributeToElement(n),e.commands.add(iv,new pv(e))}_prepareAnyValueConverters(e){const t=this.editor,i=e.model.values.filter((e=>{return!(t=String(e),Qh.test(t)||function(e){return Jh.test(e)}(String(e)));var t}));if(i.length)throw new y("font-size-invalid-use-of-named-presets",null,{presets:i});t.conversion.for("downcast").attributeToElement({model:iv,view:(e,{writer:t})=>{if(e)return t.createAttributeElement("span",{style:"font-size:"+e},{priority:7})}}),t.conversion.for("upcast").elementToAttribute({model:{key:iv,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:iv,value:e=>{const t=e.getAttribute("size"),i="-"===t[0]||"+"===t[0];let n=parseInt(t,10);i&&(n=3+n);const o=_v.length-1,r=Math.min(Math.max(n,0),o);return _v[r]}}})}}var yv=i(9875),Av={attributes:{"data-cke":!0}};Av.setAttributes=$o(),Av.insert=Wo().bind(null,"head"),Av.domAPI=Ho(),Av.insertStyleElement=Go();jo()(yv.Z,Av);yv.Z&&yv.Z.locals&&yv.Z.locals;class xv extends vs{static get pluginName(){return"FontSizeUI"}init(){const e=this.editor,t=e.t,i=this._getLocalizedOptions(),n=e.commands.get(iv),o=t("Font Size");e.ui.componentFactory.add(iv,(t=>{const r=Fm(t);return Wm(r,(()=>function(e,t){const i=new To;for(const n of e){const e={type:"button",model:new ug({commandName:iv,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)),{role:"menu",ariaLabel:o}),r.buttonView.set({label:o,icon:'',tooltip:!0}),r.extendTemplate({attributes:{class:["ck-font-size-dropdown"]}}),r.bind("isEnabled").to(n),this.listenTo(r,"execute",(t=>{e.execute(t.source.commandName,{value:t.source.commandParam}),e.editing.view.focus()})),r}))}_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 bv(e.config.get(iv).options).map((e=>{const t=i[e.title];return t&&t!=e.title&&(e=Object.assign({},e,{title:t})),e}))}}class Ev extends vs{static get requires(){return[vv,xv]}static get pluginName(){return"FontSize"}normalizeSizeOptions(e){return bv(e)}}class Cv extends K_{constructor(e){super(e,ov)}}class Sv extends vs{static get pluginName(){return"FontColorEditing"}constructor(e){super(e),e.config.define(ov,{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:ov,value:av("color")}}),e.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{color:/^#?\w+$/}},model:{key:ov,value:e=>e.getAttribute("color")}}),e.conversion.for("downcast").attributeToElement({model:ov,view:lv("color")}),e.commands.add(ov,new Cv(e)),e.model.schema.extend("$text",{allowAttributes:ov}),e.model.schema.setAttributeProperties(ov,{isFormatting:!0,copyOnEnter:!0})}}class Tv extends vs{constructor(e,{commandName:t,componentName:i,icon:n,dropdownLabel:o}){super(e),this.commandName=t,this.componentName=i,this.icon=n,this.dropdownLabel=o,this.columns=e.config.get(`${this.componentName}.columns`),this.colorTableView=void 0}init(){const e=this.editor,t=e.locale,i=t.t,n=e.commands.get(this.commandName),o=e.config.get(this.componentName),r=function(e){return e.map(Pr).filter((e=>!!e))}(o.colors),s=function(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}))}(t,r),a=o.documentColors,l=!1!==o.colorPicker;e.ui.componentFactory.add(this.componentName,(t=>{const r=Fm(t);let c=!1;return this.colorTableView=function({dropdownView:e,colors:t,columns:i,removeButtonLabel:n,colorPickerLabel:o,documentColorsLabel:r,documentColorsCount:s,colorPickerConfig:a}){const l=e.locale,c=new X_(l,{colors:t,columns:i,removeButtonLabel:n,colorPickerLabel:o,documentColorsLabel:r,documentColorsCount:s,colorPickerConfig:a});return e.colorTableView=c,e.panelView.children.add(c),c}({dropdownView:r,colors:s.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!==a?i("Document colors"):"",documentColorsCount:void 0===a?this.columns:a,colorPickerConfig:!!l&&(o.colorPicker||{})}),this.colorTableView.bind("selectedColor").to(n,"value"),r.buttonView.set({label:this.dropdownLabel,icon:this.icon,tooltip:!0}),r.extendTemplate({attributes:{class:"ck-color-ui-dropdown"}}),r.bind("isEnabled").to(n),this.colorTableView.on("execute",((t,i)=>{r.isOpen&&e.execute(this.commandName,{value:i.value,batch:this._undoStepBatch}),"colorPicker"!==i.source&&e.editing.view.focus()})),this.colorTableView.on("showColorPicker",(()=>{this._undoStepBatch=e.model.createBatch()})),this.colorTableView.on("cancel",(()=>{this._undoStepBatch.operations.length&&(r.isOpen=!1,e.execute("undo",this._undoStepBatch)),e.editing.view.focus()})),r.on("change:isOpen",((t,i,n)=>{c||(c=!0,r.colorTableView.appendUI()),n?(0!==a&&this.colorTableView.updateDocumentColors(e.model,this.componentName),this.colorTableView.updateSelectedColors()):this.colorTableView.showColorGrids()})),$m(r,(()=>r.colorTableView.colorGridsPageView.staticColorsGrid.items.find((e=>e.isOn)))),r}))}}class Pv extends Tv{constructor(e){const t=e.locale.t;super(e,{commandName:ov,componentName:ov,icon:'',dropdownLabel:t("Font Color")})}static get pluginName(){return"FontColorUI"}}class Iv extends vs{static get requires(){return[Sv,Pv]}static get pluginName(){return"FontColor"}}class Ov extends K_{constructor(e){super(e,rv)}}class Mv extends vs{static get pluginName(){return"FontBackgroundColorEditing"}constructor(e){super(e),e.config.define(rv,{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(dm),e.conversion.for("upcast").elementToAttribute({view:{name:"span",styles:{"background-color":/[\s\S]+/}},model:{key:rv,value:av("background-color")}}),e.conversion.for("downcast").attributeToElement({model:rv,view:lv("background-color")}),e.commands.add(rv,new Ov(e)),e.model.schema.extend("$text",{allowAttributes:rv}),e.model.schema.setAttributeProperties(rv,{isFormatting:!0,copyOnEnter:!0})}}class Rv extends Tv{constructor(e){const t=e.locale.t;super(e,{commandName:rv,componentName:rv,icon:'',dropdownLabel:t("Font Background Color")})}static get pluginName(){return"FontBackgroundColorUI"}}class Nv extends vs{static get requires(){return[Mv,Rv]}static get pluginName(){return"FontBackgroundColor"}}class Vv extends vs{static get requires(){return[gv,Ev,Iv,Nv]}static get pluginName(){return"Font"}}function Dv(e,t){if(!e.childCount)return;const i=new Hh(e.document),n=function(e,t){const i=t.createRangeIn(e),n=new Hs({name:/^p|h\d+$/,styles:{"mso-list":/.*/}}),o=[];for(const e of i)if("elementStart"===e.type&&n.match(e.item)){const t=zv(e.item);o.push({element:e.item,id:t.id,order:t.order,indent:t.indent})}return o}(e,i);if(!n.length)return;let o=null,r=1;n.forEach(((e,s)=>{const a=function(e,t){if(!e)return!0;if(e.id!==t.id)return t.indent-e.indent!=1;const i=t.element.previousSibling;if(!i)return!0;return n=i,!(n.is("element","ol")||n.is("element","ul"));var n}(n[s-1],e),l=a?null:n[s-1],c=(u=e,(d=l)?u.indent-d.indent:u.indent-1);var d,u;if(a&&(o=null,r=1),!o||0!==c){const n=function(e,t){const i=new RegExp(`@list l${e.id}:level${e.indent}\\s*({[^}]*)`,"gi"),n=/mso-level-number-format:([^;]{0,100});/gi,o=/mso-level-start-at:\s{0,100}([0-9]{0,10})\s{0,100};/gi,r=i.exec(t);let s="decimal",a="ol",l=null;if(r&&r[1]){const t=n.exec(r[1]);if(t&&t[1]&&(s=t[1].trim(),a="bullet"!==s&&"image"!==s?"ol":"ul"),"bullet"===s){const t=function(e){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&&(s=t)}else{const e=o.exec(r[1]);e&&e[1]&&(l=parseInt(e[1]))}}return{type:a,startIndex:l,style:Lv(s)}}(e,t);if(o){if(e.indent>r){const e=o.getChild(o.childCount-1),t=e.getChild(e.childCount-1);o=Bv(n,t,i),r+=1}else if(e.indent1&&i.setAttribute("start",e.startIndex,o),o}function zv(e){const t={},i=e.getStyle("mso-list");if(i){const e=i.match(/(^|\s{1,100})l(\d+)/i),n=i.match(/\s{0,100}lfo(\d+)/i),o=i.match(/\s{0,100}level(\d+)/i);e&&n&&o&&(t.id=e[2],t.order=n[1],t.indent=parseInt(o[1]))}return t}function jv(e,t){if(!e.childCount)return;const i=new Hh(e.document),n=function(e,t){const i=t.createRangeIn(e),n=new Hs({name:/v:(.+)/}),o=[];for(const e of i){if("elementStart"!=e.type)continue;const t=e.item,i=t.previousSibling,r=i&&i.is("element")?i.name:null;n.match(t)&&t.getAttribute("o:gfxdata")&&"v:shapetype"!==r&&o.push(e.item.getAttribute("id"))}return o}(e,i);!function(e,t,i){const n=i.createRangeIn(t),o=new Hs({name:"img"}),r=[];for(const t of n)if(t.item.is("element")&&o.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))?r.push(i):i.getAttribute("src")||r.push(i)}for(const e of r)i.remove(e)}(n,e,i),function(e,t,i){const n=i.createRangeIn(t),o=[];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;r(t.item.parent.getChildren(),i)||o.push(t.item)}for(const e of o){const t={src:s(e)};e.hasAttribute("alt")&&(t.alt=e.getAttribute("alt"));const n=i.createElement("img",t);i.insertChild(e.index+1,n,e.parent)}function r(e,t){for(const i of e)if(i.is("element")){if("img"==i.name&&i.getAttribute("v:shapes")==t)return!0;if(r(i.getChildren(),t))return!0}return!1}function s(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 Hs({name:/v:(.+)/}),o=[];for(const e of i)"elementStart"==e.type&&n.match(e.item)&&o.push(e.item);for(const e of o)t.remove(e)}(e,i);const o=function(e,t){const i=t.createRangeIn(e),n=new Hs({name:"img"}),o=[];for(const e of i)e.item.is("element")&&n.match(e.item)&&e.item.getAttribute("src").startsWith("file://")&&o.push(e.item);return o}(e,i);o.length&&function(e,t,i){if(e.length===t.length)for(let n=0;nString.fromCharCode(parseInt(e,16)))).join(""))}const Hv=//i,Uv=/xmlns:o="urn:schemas-microsoft-com/i;class Wv{constructor(e){this.document=e}isActive(e){return Hv.test(e)||Uv.test(e)}execute(e){const{body:t,stylesString:i}=e._parsedData;Dv(t,i),jv(t,e.dataTransfer.getData("text/rtf")),e.content=t}}function Zv(e,t,i,{blockElements:n,inlineObjectElements:o}){let r=i.createPositionAt(e,"forward"==t?"after":"before");return r=r.getLastMatchingPosition((({item:e})=>e.is("element")&&!n.includes(e.name)&&!o.includes(e.name)),{direction:t}),"forward"==t?r.nodeAfter:r.nodeBefore}function $v(e,t){return!!e&&e.is("element")&&t.includes(e.name)}const qv=/id=("|')docs-internal-guid-[-0-9a-f]+("|')/i;class Gv{constructor(e){this.document=e}isActive(e){return qv.test(e)}execute(e){const t=new Hh(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 al(t.document.stylesProcessor),n=new Jl(i,{renderingMode:"data"}),o=n.blockElements,r=n.inlineObjectElements,s=[];for(const i of t.createRangeIn(e)){const e=i.item;if(e.is("element","br")){const i=Zv(e,"forward",t,{blockElements:o,inlineObjectElements:r}),n=Zv(e,"backward",t,{blockElements:o,inlineObjectElements:r}),a=$v(i,o);($v(n,o)||a)&&s.push(e)}}for(const e of s)e.hasClass("Apple-interchange-newline")?t.remove(e):t.replace(e,t.createElement("p"))}(i,t),e.content=i}}const Kv=/(\s+)<\/span>/g,((e,t)=>1===t.length?" ":Array(t.length+1).join("  ").substr(0,t.length)))}function Jv(e,t){const i=new DOMParser,n=function(e){return Qv(Qv(e)).replace(/([^\S\r\n]*?)[\r\n]+([^\S\r\n]*<\/span>)/g,"$1$2").replace(/<\/span>/g,"").replace(/ <\//g," <\/o:p>/g," ").replace(/( |\u00A0)<\/o:p>/g,"").replace(/>([^\S\r\n]*[\r\n]\s*)<")}(function(e){const t="",i="",n=e.indexOf(t);if(n<0)return e;const o=e.indexOf(i,n+t.length);return e.substring(0,n+t.length)+(o>=0?e.substring(o):"")}(e=e.replace(//g,"")}(n.getData("text/html")):n.getData("text/plain")&&(((r=(r=n.getData("text/plain")).replace(//g,">").replace(/\r?\n\r?\n/g,"

").replace(/\r?\n/g,"
").replace(/\t/g,"    ").replace(/^\s/," ").replace(/\s$/," ").replace(/\s\s/g,"  ")).includes("

")||r.includes("
"))&&(r=`

${r}

`),e=r),o=this.editor.data.htmlProcessor.toView(e)}var r;const s=new p(this,"inputTransformation");this.fire(s,{content:o,dataTransfer:n,targetRanges:t.targetRanges,method:t.method}),s.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,i)=>{i.resultRange=t.insertContent(i.content)}),{priority:"low"})}_setupCopyCut(){const e=this.editor,t=e.model.document,i=e.editing.view.document,n=(n,o)=>{const r=o.dataTransfer;o.preventDefault();const s=e.data.toView(e.model.getSelectedContent(t.selection));i.fire("clipboardOutput",{dataTransfer:r,content:s,method:n.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(i,"clipboardOutput",((i,n)=>{n.content.isEmpty||(n.dataTransfer.setData("text/html",this.editor.data.htmlProcessor.toData(n.content)),n.dataTransfer.setData("text/plain",ak(n.content))),"cut"==n.method&&e.model.deleteContent(t.selection)}),{priority:"low"})}}var ck=i(3352),dk={attributes:{"data-cke":!0}};dk.setAttributes=$o(),dk.insert=Zo().bind(null,"head"),dk.domAPI=Ho(),dk.insertStyleElement=Go();jo()(ck.Z,dk);ck.Z&&ck.Z.locals&&ck.Z.locals;class uk extends vs{static get pluginName(){return"DragDrop"}static get requires(){return[lk,cb]}init(){const e=this.editor,t=e.editing.view;this._draggedRange=null,this._draggingUid="",this._draggableElement=null,this._updateDropMarkerThrottled=ef((e=>this._updateDropMarker(e)),40),this._removeDropMarkerDelayed=Ro((()=>this._removeDropMarker()),40),this._clearDraggableAttributesDelayed=Ro((()=>this._clearDraggableAttributes()),40),e.plugins.has("DragDropExperimental")?this.forceDisabled("DragDropExperimental"):(t.addObserver(rk),t.addObserver(Uh),this._setupDragging(),this._setupContentInsertionIntegration(),this._setupClipboardInputIntegration(),this._setupDropMarker(),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)})),c.isAndroid&&this.forceDisabled("noAndroidSupport"))}destroy(){return this._draggedRange&&(this._draggedRange.detach(),this._draggedRange=null),this._updateDropMarkerThrottled.cancel(),this._removeDropMarkerDelayed.cancel(),this._clearDraggableAttributesDelayed.cancel(),super.destroy()}_setupDragging(){const e=this.editor,t=e.model,i=t.document,n=e.editing.view,o=n.document;this.listenTo(o,"dragstart",((n,r)=>{const s=i.selection;if(r.target&&r.target.is("editableElement"))return void r.preventDefault();const a=r.target?gk(r.target):null;if(a){const i=e.editing.mapper.toModelElement(a);if(this._draggedRange=bd.fromRange(t.createRangeOn(i)),e.plugins.has("WidgetToolbarRepository")){e.plugins.get("WidgetToolbarRepository").forceDisabled("dragDrop")}}else if(!o.selection.isCollapsed){const e=o.selection.getSelectedElement();e&&Fp(e)||(this._draggedRange=bd.fromRange(s.getFirstRange()))}if(!this._draggedRange)return void r.preventDefault();this._draggingUid=w();const l=this.isEnabled&&e.model.canEditAt(this._draggedRange);r.dataTransfer.effectAllowed=l?"copyMove":"copy",r.dataTransfer.setData("application/ckeditor5-dragging-uid",this._draggingUid);const c=t.createSelection(this._draggedRange.toRange()),d=e.data.toView(t.getSelectedContent(c));o.fire("clipboardOutput",{dataTransfer:r.dataTransfer,content:d,method:"dragstart"}),l||(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="")}),{priority:"low"}),this.listenTo(o,"dragend",((e,t)=>{this._finalizeDragging(!t.dataTransfer.isCanceled&&"move"==t.dataTransfer.dropEffect)}),{priority:"low"}),this.listenTo(o,"dragenter",(()=>{this.isEnabled&&n.focus()})),this.listenTo(o,"dragleave",(()=>{this._removeDropMarkerDelayed()})),this.listenTo(o,"dragging",((t,i)=>{if(!this.isEnabled)return void(i.dataTransfer.dropEffect="none");this._removeDropMarkerDelayed.cancel();const n=hk(e,i.targetRanges,i.target);e.model.canEditAt(n)?(this._draggedRange||(i.dataTransfer.dropEffect="copy"),c.isGecko||("copy"==i.dataTransfer.effectAllowed?i.dataTransfer.dropEffect="copy":["all","copyMove"].includes(i.dataTransfer.effectAllowed)&&(i.dataTransfer.dropEffect="move")),n&&this._updateDropMarkerThrottled(n)):i.dataTransfer.dropEffect="none"}),{priority:"low"})}_setupClipboardInputIntegration(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"clipboardInput",((t,i)=>{if("drop"!=i.method)return;const n=hk(e,i.targetRanges,i.target);if(this._removeDropMarker(),!n||!e.model.canEditAt(n))return this._finalizeDragging(!1),void t.stop();this._draggedRange&&this._draggingUid!=i.dataTransfer.getData("application/ckeditor5-dragging-uid")&&(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="");if("move"==mk(i.dataTransfer)&&this._draggedRange&&this._draggedRange.containsRange(n,!0))return this._finalizeDragging(!1),void t.stop();i.targetRanges=[e.editing.mapper.toViewRange(n)]}),{priority:"high"})}_setupContentInsertionIntegration(){const e=this.editor.plugins.get(lk);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"==mk(t.dataTransfer),n=!t.resultRange||!t.resultRange.isCollapsed;this._finalizeDragging(n&&i)}),{priority:"lowest"})}_setupDraggableAttributeHandling(){const e=this.editor,t=e.editing.view,i=t.document;this.listenTo(i,"mousedown",((n,o)=>{if(c.isAndroid||!o)return;this._clearDraggableAttributesDelayed.cancel();let r=gk(o.target);if(c.isBlink&&!r&&!i.selection.isCollapsed){const e=i.selection.getSelectedElement();if(!e||!Fp(e)){const e=i.selection.editableElement;e&&!e.isReadOnly&&(r=e)}}r&&(t.change((e=>{e.setAttribute("draggable","true",r)})),this._draggableElement=e.editing.mapper.toModelElement(r))})),this.listenTo(i,"mouseup",(()=>{c.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}))}_setupDropMarker(){const e=this.editor;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 i.createUIElement("span",{class:"ck ck-clipboard-drop-target-position"},(function(e){const t=this.toDomElement(e);return t.append("⁠",e.createElement("span"),"⁠"),t}))}})}_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})}))}_removeDropMarker(){const e=this.editor.model;this._removeDropMarkerDelayed.cancel(),this._updateDropMarkerThrottled.cancel(),e.markers.has("drop-target")&&e.change((e=>{e.removeMarker("drop-target")}))}_finalizeDragging(e){const t=this.editor,i=t.model;if(this._removeDropMarker(),this._clearDraggableAttributes(),t.plugins.has("WidgetToolbarRepository")){t.plugins.get("WidgetToolbarRepository").clearForceDisabled("dragDrop")}this._draggingUid="",this._draggedRange&&(e&&this.isEnabled&&i.deleteContent(i.createSelection(this._draggedRange),{doNotAutoparagraph:!0}),this._draggedRange.detach(),this._draggedRange=null)}}function hk(e,t,i){const n=e.model,o=e.editing.mapper;let r=null;const s=t?t[0].start:null;if(i.is("uiElement")&&(i=i.parent),r=function(e,t){const i=e.model,n=e.editing.mapper;if(Fp(t))return i.createRangeOn(n.toModelElement(t));if(!t.is("editableElement")){const e=t.findAncestor((e=>Fp(e)||e.is("editableElement")));if(Fp(e))return i.createRangeOn(n.toModelElement(e))}return null}(e,i),r)return r;const a=function(e,t){const i=e.editing.mapper,n=e.editing.view,o=i.toModelElement(t);if(o)return o;const r=n.createPositionBefore(t),s=i.findMappedViewAncestor(r);return i.toModelElement(s)}(e,i),l=s?o.toModelPosition(s):null;return l?(r=function(e,t,i){const n=e.model;if(!n.schema.checkChild(i,"$block"))return null;const o=n.createPositionAt(i,0),r=t.path.slice(0,o.path.length),s=n.createPositionFromPath(t.root,r),a=s.nodeAfter;if(a&&n.schema.isObject(a))return n.createRangeOn(a);return null}(e,l,a),r||(r=n.schema.getNearestSelectionRange(l,c.isGecko?"forward":"backward"),r||function(e,t){const i=e.model;let n=t;for(;n;){if(i.schema.isObject(n))return i.createRangeOn(n);n=n.parent}return null}(e,l.parent))):function(e,t){const i=e.model,n=i.schema,o=i.createPositionAt(t,0);return n.getNearestSelectionRange(o,"forward")}(e,a)}function mk(e){return c.isGecko?e.dropEffect:["all","copyMove"].includes(e.effectAllowed)?"move":"copy"}function gk(e){if(e.is("editableElement"))return null;if(e.hasClass("ck-widget__selection-handle"))return e.findAncestor(Fp);if(Fp(e))return e;const t=e.findAncestor((e=>Fp(e)||e.is("editableElement")));return Fp(t)?t:null}class fk extends vs{static get pluginName(){return"PastePlainText"}static get requires(){return[lk]}init(){const e=this.editor,t=e.model,i=e.editing.view,n=i.document,o=t.document.selection;let r=!1;i.addObserver(rk),this.listenTo(n,"keydown",((e,t)=>{r=t.shiftKey})),e.plugins.get(lk).on("contentInsertion",((e,i)=>{(r||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(o.getAttributes()).filter((([e])=>t.schema.getAttributeProperties(e).isFormatting));o.isCollapsed||t.deleteContent(o,{doNotAutoparagraph:!0}),n.push(...o.getAttributes());const r=e.createRangeIn(i.content);for(const t of r.getItems())t.is("$textProxy")&&e.setAttributes(n,t)}))}))}}class pk extends vs{static get pluginName(){return"Clipboard"}static get requires(){return[lk,uk,fk]}}Kn("px");class bk extends xs{constructor(e){super(e),this.affectsData=!1}execute(){const e=this.editor.model,t=e.document.selection;let i=e.schema.getLimitElement(t);if(t.containsEntireContent(i)||!wk(e.schema,i))do{if(i=i.parent,!i)return}while(!wk(e.schema,i));e.change((e=>{e.setSelection(i,"in")}))}}function wk(e,t){return e.isLimit(t)&&(e.checkChild(t,"$text")||e.checkChild(t,"paragraph"))}const kk=_o("Ctrl+A");class _k extends vs{static get pluginName(){return"SelectAllEditing"}init(){const e=this.editor,t=e.editing.view.document;e.commands.add("selectAll",new bk(e)),this.listenTo(t,"keydown",((t,i)=>{ko(i)===kk&&(e.execute("selectAll"),i.preventDefault())}))}}class vk extends vs{static get pluginName(){return"SelectAllUI"}init(){const e=this.editor;e.ui.componentFactory.add("selectAll",(t=>{const i=e.commands.get("selectAll"),n=new Er(t),o=t.t;return n.set({label:o("Select all"),icon:'',keystroke:"Ctrl+A",tooltip:!0}),n.bind("isEnabled").to(i,"isEnabled"),this.listenTo(n,"execute",(()=>{e.execute("selectAll"),e.editing.view.focus()})),n}))}}class yk extends vs{static get requires(){return[_k,vk]}static get pluginName(){return"SelectAll"}}class xk extends xs{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()}))}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,o=n.document,r=[],s=e.map((e=>e.getTransformedByOperations(i))),a=s.flat();for(const e of s){const t=e.filter((e=>e.root!=o.graveyard)).filter((e=>!Ek(e,a)));t.length&&(Ak(t),r.push(t[0]))}r.length&&n.change((e=>{e.setSelection(r,{backward:t})}))}_undo(e,t){const i=this.editor.model,n=i.document;this._createdBatches.add(t);const o=e.operations.slice().filter((e=>e.isDocumentOperation));o.reverse();for(const e of o){const o=e.baseVersion+1,r=Array.from(n.history.getOperations(o)),s=Ku([e.getReversed()],r,{useRelations:!0,document:this.editor.model.document,padWithNoOps:!1,forceWeakRemove:!0}).operationsA;for(let o of s){const r=o.affectedSelectable;r&&!i.canEditAt(r)&&(o=new zu(o.baseVersion)),t.addOperation(o),i.applyOperation(o),n.history.setOperationAsUndone(e,o)}}}}function Ak(e){e.sort(((e,t)=>e.start.isBefore(t.start)?-1:1));for(let t=1;tt!==e&&t.containsRange(e,!0)))}class Ck extends xk{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 Sk extends xk{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 Tk extends vs{constructor(){super(...arguments),this._batchRegistry=new WeakSet}static get pluginName(){return"UndoEditing"}init(){const e=this.editor;this._undoCommand=new Ck(e),this._redoCommand=new Sk(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,o=this._redoCommand.createdBatches.has(n),r=this._undoCommand.createdBatches.has(n);this._batchRegistry.has(n)||(this._batchRegistry.add(n),n.isUndoable&&(o?this._undoCommand.addBatch(n):r||(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")}}const Pk='',Ik='';class Ok extends vs{static get pluginName(){return"UndoUI"}init(){const e=this.editor,t=e.locale,i=e.t,n="ltr"==t.uiLanguageDirection?Pk:Ik,o="ltr"==t.uiLanguageDirection?Ik:Pk;this._addButton("undo",i("Undo"),"CTRL+Z",n),this._addButton("redo",i("Redo"),"CTRL+Y",o)}_addButton(e,t,i,n){const o=this.editor;o.ui.componentFactory.add(e,(r=>{const s=o.commands.get(e),a=new Er(r);return a.set({label:t,icon:n,keystroke:i,tooltip:!0}),a.bind("isEnabled").to(s,"isEnabled"),this.listenTo(a,"execute",(()=>{o.execute(e),o.editing.view.focus()})),a}))}}class Mk extends vs{static get requires(){return[Tk,Ok]}static get pluginName(){return"Undo"}}class Rk extends vs{static get requires(){return[pk,Pp,yk,Rp,hp,Mk]}static get pluginName(){return"Essentials"}}class Nk extends xs{refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,i=t.schema,n=t.document.selection,o=Array.from(n.getSelectedBlocks()),r=void 0===e.forceValue?!this.value:e.forceValue;t.change((e=>{if(r){const t=o.filter((e=>Vk(e)||Dk(i,e)));this._applyQuote(e,t)}else this._removeQuote(e,o.filter(Vk))}))}_getValue(){const e=Po(this.editor.model.document.selection.getSelectedBlocks());return!(!e||!Vk(e))}_checkEnabled(){if(this.value)return!0;const e=this.editor.model.document.selection,t=this.editor.model.schema,i=Po(e.getSelectedBlocks());return!!i&&Dk(t,i)}_removeQuote(e,t){Lk(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=[];Lk(e,t).reverse().forEach((t=>{let n=Vk(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 Vk(e){return"blockQuote"==e.parent.name?e.parent:null}function Lk(e,t){let i,n=0;const o=[];for(;n{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,o=e.commands.get("blockQuote");this.listenTo(i,"enter",((t,i)=>{if(!n.isCollapsed||!o.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||!o.value)return;const r=n.getLastPosition().parent;r.isEmpty&&!r.previousSibling&&(e.execute("blockQuote"),e.editing.view.scrollToTheSelection(),i.preventDefault(),t.stop())}),{context:"blockquote"})}}var zk=i(5558),jk={attributes:{"data-cke":!0}};jk.setAttributes=$o(),jk.insert=Zo().bind(null,"head"),jk.domAPI=Ho(),jk.insertStyleElement=Go();jo()(zk.Z,jk);zk.Z&&zk.Z.locals&&zk.Z.locals;class Fk extends vs{static get pluginName(){return"BlockQuoteUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add("blockQuote",(i=>{const n=e.commands.get("blockQuote"),o=new Er(i);return o.set({label:t("Block quote"),icon:xm.quote,tooltip:!0,isToggleable:!0}),o.bind("isOn","isEnabled").to(n,"value","isEnabled"),this.listenTo(o,"execute",(()=>{e.execute("blockQuote"),e.editing.view.focus()})),o}))}}class Hk extends vs{static get requires(){return[Bk,Fk]}static get pluginName(){return"BlockQuote"}}function Uk(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 Zk(e,t,i){const n={};for(const o of e)if("class"===t){n[o[t].split(" ").shift()]=o[i]}else n[o[t]]=o[i];return n}function Wk(e){return e.data.match(/^(\s*)/)[0]}function $k(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:o}=t.textNode;if(!n.is("element","codeBlock"))continue;const r=Wk(t.textNode),s=e.createPositionAt(n,o+r.length);i.push(s)}return i}function qk(e){const t=Po(e.getSelectedBlocks());return!!t&&t.is("element","codeBlock")}function Gk(e,t){return!t.is("rootElement")&&!e.isLimit(t)&&e.checkChild(t.parent,"codeBlock")}class Kk extends xs{constructor(e){super(e),this._lastLanguage=null}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor,i=t.model,n=i.document.selection,o=Uk(t)[0],r=Array.from(n.getSelectedBlocks()),s=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,o.language);i.change((e=>{s?this._applyCodeBlock(e,r,a):this._removeCodeBlock(e,r)}))}_getValue(){const e=Po(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=Po(e.getSelectedBlocks());return!!i&&Gk(t,i)}_applyCodeBlock(e,t,i){this._lastLanguage=i;const n=this.editor.model.schema,o=t.filter((e=>Gk(n,e)));for(const t of o)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)));o.reverse().forEach(((t,i)=>{const n=o[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)}}}class Yk extends xs{constructor(e){super(e),this._indentSequence=e.config.get("codeBlock.indentSequence")}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model;e.change((t=>{const i=$k(e);for(const n of i){const i=t.createText(this._indentSequence);e.insertContent(i,n)}}))}_checkEnabled(){return!!this._indentSequence&&qk(this.editor.model.document.selection)}}class Qk extends xs{constructor(e){super(e),this._indentSequence=e.config.get("codeBlock.indentSequence")}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model;e.change((()=>{const t=$k(e);for(const i of t){const t=Jk(e,i,this._indentSequence);t&&e.deleteContent(e.createSelection(t))}}))}_checkEnabled(){if(!this._indentSequence)return!1;const e=this.editor.model;return!!qk(e.document.selection)&&$k(e).some((t=>Jk(e,t,this._indentSequence)))}}function Jk(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 o=Wk(n),r=o.lastIndexOf(i);if(r+i.length!==o.length)return null;if(-1===r)return null;const{parent:s,startOffset:a}=n;return e.createRange(e.createPositionAt(s,a+r),e.createPositionAt(s,a+r+i.length))}function Xk(e,t,i=!1){const n=Zk(t,"language","class"),o=Zk(t,"language","label");return(t,r,s)=>{const{writer:a,mapper:l,consumable:c}=s;if(!c.consume(r.item,"insert"))return;const d=r.item.getAttribute("language"),u=l.toViewPosition(e.createPositionBefore(r.item)),h={};i&&(h["data-language"]=o[d],h.spellcheck="false");const m=n[d]?{class:n[d]}:void 0,g=a.createContainerElement("code",m),f=a.createContainerElement("pre",h,g);a.insert(u,f),l.bindElements(r.item,g)}}const e_="paragraph";class t_ extends vs{static get pluginName(){return"CodeBlockEditing"}static get requires(){return[Rp]}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"})}init(){const e=this.editor,t=e.model.schema,i=e.model,n=e.editing.view,o=e.plugins.has("DocumentListEditing"),r=Uk(e);e.commands.add("codeBlock",new Kk(e)),e.commands.add("indentCodeBlock",new Yk(e)),e.commands.add("outdentCodeBlock",new Qk(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)=>{const i=e.endsWith("codeBlock")&&t.startsWith("list")&&"list"!==t;return!(!o||!i)||!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",Xk(i,r,!0)),e.data.downcastDispatcher.on("insert:codeBlock",Xk(i,r)),e.data.downcastDispatcher.on("insert:softBreak",function(e){return(t,i,n)=>{if("codeBlock"!==i.item.parent.name)return;const{writer:o,mapper:r,consumable:s}=n;if(!s.consume(i.item,"insert"))return;const a=r.toViewPosition(e.createPositionBefore(i.item));o.insert(a,o.createText("\n"))}}(i),{priority:"high"}),e.data.upcastDispatcher.on("element:code",function(e,t){const i=Zk(t,"class","language"),n=t[0].language;return(e,t,o)=>{const r=t.viewItem,s=r.parent;if(!s||!s.is("element","pre"))return;if(t.modelCursor.findAncestor("codeBlock"))return;const{consumable:a,writer:l}=o;if(!a.test(r,{name:!0}))return;const c=l.createElement("codeBlock"),d=[...r.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),o.convertChildren(r,c),o.safeInsert(c,t.modelCursor)&&(a.consume(r,{name:!0}),o.updateConversionResult(c,t))}}(0,r)),e.data.upcastDispatcher.on("text",((e,t,{consumable:i,writer:n})=>{let o=t.modelCursor;if(!i.test(t.viewItem))return;if(!o.findAncestor("codeBlock"))return;i.consume(t.viewItem);const r=t.viewItem.data.split("\n").map((e=>n.createText(e))),s=r[r.length-1];for(const e of r)if(n.insert(e,o),o=o.getShiftedBy(e.offsetSize),e!==s){const e=n.createElement("softBreak");n.insert(e,o),o=n.createPositionAfter(e)}t.modelRange=n.createRange(t.modelCursor,o),t.modelCursor=o})),e.data.upcastDispatcher.on("element:pre",((e,t,{consumable:i})=>{const n=t.viewItem;if(n.findAncestor("pre"))return;const o=Array.from(n.getChildren()),r=o.find((e=>e.is("element","code")));if(r)for(const e of o)e!==r&&e.is("$text")&&i.consume(e,{name:!0})}),{priority:"high"}),this.listenTo(e.editing.view.document,"clipboardInput",((t,n)=>{let o=i.createRange(i.document.selection.anchor);if(n.targetRanges&&(o=e.editing.mapper.toModelRange(n.targetRanges[0])),!o.start.parent.is("element","codeBlock"))return;const r=n.dataTransfer.getData("text/plain"),s=new Zh(e.editing.view.document);n.content=function(e,t){const i=e.createDocumentFragment(),n=t.split("\n"),o=n.reduce(((t,i,o)=>(t.push(i),o{const o=n.anchor;!n.isCollapsed&&o.parent.is("element","codeBlock")&&o.hasSameParentAs(n.focus)&&i.change((i=>{const r=e.return;if(o.parent.is("element")&&(r.childCount>1||n.containsEntireContent(o.parent))){const t=i.createElement("codeBlock",o.parent.getAttributes());i.append(r,t);const n=i.createDocumentFragment();return i.append(t,n),void(e.return=n)}const s=r.getChild(0);t.checkAttribute(s,"code")&&i.setAttribute("code",!0,s)}))}))}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,o=e.editing.view,r=n.selection.getLastPosition(),s=r.nodeAfter;if(t||!n.selection.isCollapsed||!r.isAtStart)return!1;if(!n_(s))return!1;return e.model.change((t=>{e.execute("enter");const i=n.selection.anchor.parent.previousSibling;t.rename(i,e_),t.setSelection(i,"in"),e.model.schema.removeDisallowedAttributes([i],t),t.remove(s)})),o.scrollToTheSelection(),!0}(e,i.isSoft)||function(e,t){const i=e.model,n=i.document,o=e.editing.view,r=n.selection.getLastPosition(),s=r.nodeBefore;let a;if(t||!n.selection.isCollapsed||!r.isAtEnd||!s||!s.previousSibling)return!1;if(n_(s)&&n_(s.previousSibling))a=i.createRange(i.createPositionBefore(s.previousSibling),i.createPositionAfter(s));else if(i_(s)&&n_(s.previousSibling)&&n_(s.previousSibling.previousSibling))a=i.createRange(i.createPositionBefore(s.previousSibling.previousSibling),i.createPositionAfter(s));else{if(!(i_(s)&&n_(s.previousSibling)&&i_(s.previousSibling.previousSibling)&&s.previousSibling.previousSibling&&n_(s.previousSibling.previousSibling.previousSibling)))return!1;a=i.createRange(i.createPositionBefore(s.previousSibling.previousSibling.previousSibling),i.createPositionAfter(s))}return e.model.change((t=>{t.remove(a),e.execute("enter");const i=n.selection.anchor.parent;t.rename(i,e_),e.model.schema.removeDisallowedAttributes([i],t)})),o.scrollToTheSelection(),!0}(e,i.isSoft)||function(e){const t=e.model,i=t.document,n=i.selection.getLastPosition(),o=n.nodeBefore||n.textNode;let r;o&&o.is("$text")&&(r=Wk(o));e.model.change((t=>{e.execute("shiftEnter"),r&&t.insertText(r,i.selection.anchor)}))}(e),i.preventDefault(),t.stop())}),{context:"pre"})}}function i_(e){return e&&e.is("$text")&&!e.data.match(/\S/)}function n_(e){return e&&e.is("element","softBreak")}var o_=i(348),r_={attributes:{"data-cke":!0}};r_.setAttributes=$o(),r_.insert=Zo().bind(null,"head"),r_.domAPI=Ho(),r_.insertStyleElement=Go();jo()(o_.Z,r_);o_.Z&&o_.Z.locals&&o_.Z.locals;class s_ extends vs{static get pluginName(){return"CodeBlockUI"}init(){const e=this.editor,t=e.t,i=e.ui.componentFactory,n=Uk(e);i.add("codeBlock",(i=>{const o=e.commands.get("codeBlock"),r=Zm(i,zm),s=r.buttonView,a=t("Insert code block");return s.set({label:a,tooltip:!0,icon:'',isToggleable:!0}),s.bind("isOn").to(o,"value",(e=>!!e)),s.on("execute",(()=>{e.execute("codeBlock",{usePreviousLanguageChoice:!0}),e.editing.view.focus()})),r.on("execute",(t=>{e.execute("codeBlock",{language:t.source._codeBlockLanguage,forceValue:!0}),e.editing.view.focus()})),r.class="ck-code-block-dropdown",r.bind("isEnabled").to(o),qm(r,(()=>this._getLanguageListItemDefinitions(n)),{role:"menu",ariaLabel:a}),r}))}_getLanguageListItemDefinitions(e){const t=this.editor.commands.get("codeBlock"),i=new To;for(const n of e){const e={type:"button",model:new vf({_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 a_ extends vs{static get requires(){return[t_,s_]}static get pluginName(){return"CodeBlock"}}class l_ extends xs{constructor(e){super(e),this._isEnabledBasedOnSelection=!1}refresh(){const e=this.editor.model,t=Po(e.document.selection.getSelectedBlocks());this.value=!!t&&t.is("element","paragraph"),this.isEnabled=!!t&&c_(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")&&c_(n,t.schema)&&e.rename(n,"paragraph")}))}}function c_(e,t){return t.checkChild(e.parent,"paragraph")&&!t.isObject(e)}class d_ extends xs{constructor(e){super(e),this._isEnabledBasedOnSelection=!1}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 o=e.createElement("paragraph");i&&t.schema.setAllowedAttributes(o,i,e),t.insertContent(o,n),e.setSelection(o,"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 o=e.parent,r=i.schema.checkChild(o,"$text");return o.isEmpty||r&&e.isAtEnd?i.createPositionAfter(o):!o.isEmpty&&r&&e.isAtStart?i.createPositionBefore(o):t.split(e,n).position}}class u_ extends vs{static get pluginName(){return"Paragraph"}init(){const e=this.editor,t=e.model;e.commands.add("paragraph",new l_(e)),e.commands.add("insertParagraph",new d_(e)),t.schema.register("paragraph",{inheritAllFrom:"$block"}),e.conversion.elementToElement({model:"paragraph",view:"p"}),e.conversion.for("upcast").elementToElement({model:(e,{writer:t})=>u_.paragraphLikeElements.has(e.name)?e.isEmpty?null:t.createElement("paragraph"):null,view:/.+/,converterPriority:"low"})}}u_.paragraphLikeElements=new Set(["blockquote","dd","div","dt","h1","h2","h3","h4","h5","h6","li","p","td","th"]);class h_ extends xs{constructor(e,t){super(e),this.modelElements=t}refresh(){const e=Po(this.editor.model.document.selection.getSelectedBlocks());this.value=!!e&&this.modelElements.includes(e.name)&&e.name,this.isEnabled=!!e&&this.modelElements.some((t=>m_(e,t,this.editor.model.schema)))}execute(e){const t=this.editor.model,i=t.document,n=e.value;t.change((e=>{const o=Array.from(i.selection.getSelectedBlocks()).filter((e=>m_(e,n,t.schema)));for(const t of o)t.is("element",n)||e.rename(t,n)}))}}function m_(e,t,i){return i.checkChild(e.parent,t)&&!i.isObject(e)}const g_="paragraph";class f_ extends vs{static get pluginName(){return"HeadingEditing"}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"}]})}static get requires(){return[u_]}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 h_(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 o=e.model.document.selection.getFirstPosition().parent;i.some((e=>o.is("element",e.model)))&&!o.is("element",g_)&&0===o.childCount&&n.writer.rename(o,g_)}))}_addDefaultH1Conversion(e){e.conversion.for("upcast").elementToElement({model:"heading1",view:"h1",converterPriority:k.low+1})}}var p_=i(4684),b_={attributes:{"data-cke":!0}};b_.setAttributes=$o(),b_.insert=Zo().bind(null,"head"),b_.domAPI=Ho(),b_.insertStyleElement=Go();jo()(p_.Z,b_);p_.Z&&p_.Z.locals&&p_.Z.locals;class w_ extends vs{static get pluginName(){return"HeadingUI"}init(){const e=this.editor,t=e.t,i=function(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}))}(e),n=t("Choose heading"),o=t("Heading");e.ui.componentFactory.add("heading",(t=>{const r={},s=new To,a=e.commands.get("heading"),l=e.commands.get("paragraph"),c=[a];for(const e of i){const t={type:"button",model:new vf({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})),s.add(t),r[e.model]=e.title}const d=Zm(t);return qm(d,s,{ariaLabel:o,role:"menu"}),d.buttonView.set({ariaLabel:o,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:o}),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=e||t&&"paragraph";return"boolean"==typeof i?n:r[i]?r[i]:n})),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}))}}class k_ extends vs{static get requires(){return[f_,w_]}static get pluginName(){return"Heading"}}class __ extends xs{constructor(e,t){super(e),this.type=t}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=>y_(e,t.schema))),o=void 0!==e.forceValue?!e.forceValue:this.value;t.change((e=>{if(o){let t=n[n.length-1].nextSibling,i=Number.POSITIVE_INFINITY,o=[];for(;t&&"listItem"==t.name&&0!==t.getAttribute("listIndent");){const e=t.getAttribute("listIndent");e=i;)r>o.getAttribute("listIndent")&&(r=o.getAttribute("listIndent")),o.getAttribute("listIndent")==r&&e[t?"unshift":"push"](o),o=o[t?"previousSibling":"nextSibling"]}}function y_(e,t){return t.checkChild(e.parent,"listItem")&&!t.isObject(e)}class x_ extends xs{constructor(e,t){super(e),this._indentBy="forward"==t?1:-1}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=Po(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}}function A_(e,t){const i=t.mapper,n=t.writer,o="numbered"==e.getAttribute("listType")?"ol":"ul",r=function(e){const t=e.createContainerElement("li");return t.getFillerOffset=R_,t}(n),s=n.createContainerElement(o,null);return n.insert(n.createPositionAt(s,0),r),i.bindElements(e,r),r}function E_(e,t,i,n){const o=t.parent,r=i.mapper,s=i.writer;let a=r.toViewPosition(n.createPositionBefore(e));const l=T_(e.previousSibling,{sameIndent:!0,smallerIndent:!0,listIndent:e.getAttribute("listIndent")}),c=e.previousSibling;if(l&&l.getAttribute("listIndent")==e.getAttribute("listIndent")){const e=r.toViewElement(l);a=s.breakContainer(s.createPositionAfter(e))}else if(c&&"listItem"==c.name){a=r.toViewPosition(n.createPositionAt(c,"end"));const e=r.findMappedViewAncestor(a),t=function(e){for(const t of e.getChildren())if("ul"==t.name||"ol"==t.name)return t;return null}(e);a=t?s.createPositionBefore(t):s.createPositionAt(e,"end")}else a=r.toViewPosition(n.createPositionBefore(e));if(a=S_(a),s.insert(a,o),c&&"listItem"==c.name){const e=r.toViewElement(c),i=s.createRange(s.createPositionAt(e,0),a).getWalker({ignoreElementEnd:!0});for(const e of i)if(e.item.is("element","li")){const n=s.breakContainer(s.createPositionBefore(e.item)),o=e.item.parent,r=s.createPositionAt(t,"end");C_(s,r.nodeBefore,r.nodeAfter),s.move(s.createRangeOn(o),r),i._position=n}}else{const i=o.nextSibling;if(i&&(i.is("element","ul")||i.is("element","ol"))){let n=null;for(const t of i.getChildren()){const i=r.toModelElement(t);if(!(i&&i.getAttribute("listIndent")>e.getAttribute("listIndent")))break;n=t}n&&(s.breakContainer(s.createPositionAfter(n)),s.move(s.createRangeOn(n.parent),s.createPositionAt(t,"end")))}}C_(s,o,o.nextSibling),C_(s,o.previousSibling,o)}function C_(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 S_(e){return e.getLastMatchingPosition((e=>e.item.is("uiElement")))}function T_(e,t){const i=!!t.sameIndent,n=!!t.smallerIndent,o=t.listIndent;let r=e;for(;r&&"listItem"==r.name;){const e=r.getAttribute("listIndent");if(i&&o==e||n&&o>e)return r;r="forward"===t.direction?r.nextSibling:r.previousSibling}return null}function P_(e,t,i,n){e.ui.componentFactory.add(t,(o=>{const r=e.commands.get(t),s=new Er(o);return s.set({label:i,icon:n,tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(r,"value","isEnabled"),s.on("execute",(()=>{e.execute(t),e.editing.view.focus()})),s}))}function I_(e,t){const i=[],n=e.parent,o={ignoreElementEnd:!1,startPosition:e,shallow:!0,direction:t},r=n.getAttribute("listIndent"),s=[...new Kc(o)].filter((e=>e.item.is("element"))).map((e=>e.item));for(const e of s){if(!e.is("element","listItem"))break;if(e.getAttribute("listIndent")r)){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}const O_=["disc","circle","square"],M_=["decimal","decimal-leading-zero","lower-roman","upper-roman","lower-latin","upper-latin"];function R_(){const e=!this.isEmpty&&("ul"==this.getChild(0).name||"ol"==this.getChild(0).name);return this.isEmpty||e?0:Wa.call(this)}class N_ extends vs{static get pluginName(){return"ListUtils"}getListTypeFromListStyleType(e){return function(e){return O_.includes(e)?"bulleted":M_.includes(e)?"numbered":null}(e)}getSelectedListItems(e){return function(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[...I_(i,"backward"),...I_(i,"forward")]})).flat();return t=[...new Set(t)],t}(e)}getSiblingNodes(e,t){return I_(e,t)}}function V_(e){return(t,i,n)=>{const o=n.consumable;if(!o.test(i.item,"insert")||!o.test(i.item,"attribute:listType")||!o.test(i.item,"attribute:listIndent"))return;o.consume(i.item,"insert"),o.consume(i.item,"attribute:listType"),o.consume(i.item,"attribute:listIndent");const r=i.item;E_(r,A_(r,n),n,e)}}const L_=(e,t,i)=>{if(!i.consumable.test(t.item,e.name))return;const n=i.mapper.toViewElement(t.item),o=i.writer;o.breakContainer(o.createPositionBefore(n)),o.breakContainer(o.createPositionAfter(n));const r=n.parent,s="numbered"==t.attributeNewValue?"ol":"ul";o.rename(s,r)},D_=(e,t,i)=>{i.consumable.consume(t.item,e.name);const n=i.mapper.toViewElement(t.item).parent,o=i.writer;C_(o,n,n.nextSibling),C_(o,n.previousSibling,n)};const B_=(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,o=[];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));o.push(e)}e=n.createPositionAfter(e.parent)}if(o.length>0){for(let t=0;t0){const t=C_(n,i,i.nextSibling);t&&t.parent==i&&e.offset--}}C_(n,e.nodeBefore,e.nodeAfter)}}},z_=(e,t,i)=>{const n=i.mapper.toViewPosition(t.position),o=n.nodeBefore,r=n.nodeAfter;C_(i.writer,o,r)},j_=(e,t,i)=>{if(i.consumable.consume(t.viewItem,{name:!0})){const e=i.writer,n=e.createElement("listItem"),o=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",o,n);const r=t.viewItem.parent&&"ol"==t.viewItem.parent.name?"numbered":"bulleted";if(e.setAttribute("listType",r,n),!i.safeInsert(n,t.modelCursor))return;const s=function(e,t,i){const{writer:n,schema:o}=i;let r=n.createPositionAfter(e);for(const s of t)if("ul"==s.name||"ol"==s.name)r=i.convertItem(s,r).modelCursor;else{const t=i.convertItem(s,n.createPositionAt(e,"end")),a=t.modelRange.start.nodeAfter;a&&a.is("element")&&!o.checkChild(e,a.name)&&(e=t.modelCursor.parent.is("element","listItem")?t.modelCursor.parent:W_(t.modelCursor),r=n.createPositionAfter(e))}return r}(n,t.viewItem.getChildren(),i);t.modelRange=e.createRange(t.modelCursor,s),i.updateConversionResult(n,t)}},F_=(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")||q_(t))&&t._remove()}}},H_=(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&&!q_(t)&&t._remove(),q_(t)&&(i=!0)}};function U_(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),o=t.getAncestors().find(q_),r=e.createPositionAt(t,0).getWalker();for(const e of r){if("elementStart"==e.type&&e.item.is("element","li")){i.viewPosition=e.previousPosition;break}if("elementEnd"==e.type&&e.item==o){i.viewPosition=e.nextPosition;break}}}}}const Z_=function(e,[t,i]){const n=this;let o,r=t.is("documentFragment")?t.getChild(0):t;if(o=i?n.createSelection(i):n.document.selection,r&&r.is("element","listItem")){const e=o.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(;r&&r.is("element","listItem");)r._setAttribute("listIndent",r.getAttribute("listIndent")+e),r=r.nextSibling}}};function W_(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 $_(e,t,i,n,o,r){const s=T_(t.nodeBefore,{sameIndent:!0,smallerIndent:!0,listIndent:e}),a=o.mapper,l=o.writer,c=s?s.getAttribute("listIndent"):null;let d;if(s)if(c==e){const e=a.toViewElement(s).parent;d=l.createPositionAfter(e)}else{const e=r.createPositionAt(s,"end");d=a.toViewPosition(e)}else d=i;d=S_(d);for(const e of[...n.getChildren()])q_(e)&&(d=l.move(l.createRangeOn(e),d).end,C_(l,e,e.nextSibling),C_(l,e.previousSibling,e))}function q_(e){return e.is("element","ol")||e.is("element","ul")}var G_=i(7872),K_={attributes:{"data-cke":!0}};K_.setAttributes=$o(),K_.insert=Zo().bind(null,"head"),K_.domAPI=Ho(),K_.insertStyleElement=Go();jo()(G_.Z,K_);G_.Z&&G_.Z.locals&&G_.Z.locals;class Y_ extends vs{static get pluginName(){return"ListEditing"}static get requires(){return[Pp,up,N_]}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 o=!1;for(const n of i)if("insert"==n.type&&"listItem"==n.name)r(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),o=!0),i.hasAttribute("listType")&&(t.removeAttribute("listType",i),o=!0),i.hasAttribute("listStyle")&&(t.removeAttribute("listStyle",i),o=!0),i.hasAttribute("listReversed")&&(t.removeAttribute("listReversed",i),o=!0),i.hasAttribute("listStart")&&(t.removeAttribute("listStart",i),o=!0);for(const t of Array.from(e.createRangeIn(i)).filter((e=>e.item.is("element","listItem"))))r(t.previousPosition)}r(n.position.getShiftedBy(n.length))}else"remove"==n.type&&"listItem"==n.name?r(n.position):("attribute"==n.type&&"listIndent"==n.attributeKey||"attribute"==n.type&&"listType"==n.attributeKey)&&r(n.range.start);for(const e of n.values())s(e),a(e);return o;function r(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 s(e){let i=0,n=null;for(;e&&e.is("element","listItem");){const r=e.getAttribute("listIndent");if(r>i){let s;null===n?(n=r-i,s=i):(n>r&&(n=r),s=r-n),t.setAttribute("listIndent",s,e),o=!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 r=e.getAttribute("listIndent");if(n&&n.getAttribute("listIndent")>r&&(i=i.slice(0,r+1)),0!=r)if(i[r]){const n=i[r];e.getAttribute("listType")!=n&&(t.setAttribute("listType",n,e),o=!0)}else i[r]=e.getAttribute("listType");n=e,e=e.nextSibling}}}(e.model,t))),i.mapper.registerViewToModelLength("li",Q_),t.mapper.registerViewToModelLength("li",Q_),i.mapper.on("modelToViewPosition",U_(i.view)),i.mapper.on("viewToModelPosition",(n=e.model,(e,t)=>{const i=t.viewPosition,o=i.parent,r=t.mapper;if("ul"==o.name||"ol"==o.name){if(i.isAtEnd){const e=r.toModelElement(i.nodeBefore),o=r.getModelLength(i.nodeBefore);t.modelPosition=n.createPositionBefore(e).getShiftedBy(o)}else{const e=r.toModelElement(i.nodeAfter);t.modelPosition=n.createPositionBefore(e)}e.stop()}else if("li"==o.name&&i.nodeBefore&&("ul"==i.nodeBefore.name||"ol"==i.nodeBefore.name)){const s=r.toModelElement(o);let a=1,l=i.nodeBefore;for(;l&&q_(l);)a+=r.getModelLength(l),l=l.previousSibling;t.modelPosition=n.createPositionBefore(s).getShiftedBy(a),e.stop()}})),t.mapper.on("modelToViewPosition",U_(i.view)),e.conversion.for("editingDowncast").add((t=>{t.on("insert",B_,{priority:"high"}),t.on("insert:listItem",V_(e.model)),t.on("attribute:listType:listItem",L_,{priority:"high"}),t.on("attribute:listType:listItem",D_,{priority:"low"}),t.on("attribute:listIndent:listItem",function(e){return(t,i,n)=>{if(!n.consumable.consume(i.item,"attribute:listIndent"))return;const o=n.mapper.toViewElement(i.item),r=n.writer;r.breakContainer(r.createPositionBefore(o)),r.breakContainer(r.createPositionAfter(o));const s=o.parent,a=s.previousSibling,l=r.createRangeOn(s);r.remove(l),a&&a.nextSibling&&C_(r,a,a.nextSibling),$_(i.attributeOldValue+1,i.range.start,l.start,o,n,e),E_(i.item,o,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 o=n.mapper.toViewPosition(i.position).getLastMatchingPosition((e=>!e.item.is("element","li"))).nodeAfter,r=n.writer;r.breakContainer(r.createPositionBefore(o)),r.breakContainer(r.createPositionAfter(o));const s=o.parent,a=s.previousSibling,l=r.createRangeOn(s),c=r.remove(l);a&&a.nextSibling&&C_(r,a,a.nextSibling),$_(n.mapper.toModelElement(o).getAttribute("listIndent")+1,i.position,l.start,o,n,e);for(const e of r.createRangeIn(c).getItems())n.mapper.unbindViewElement(e);t.stop()}}(e.model)),t.on("remove",z_,{priority:"low"})})),e.conversion.for("dataDowncast").add((t=>{t.on("insert",B_,{priority:"high"}),t.on("insert:listItem",V_(e.model))})),e.conversion.for("upcast").add((e=>{e.on("element:ul",F_,{priority:"high"}),e.on("element:ol",F_,{priority:"high"}),e.on("element:li",H_,{priority:"high"}),e.on("element:li",j_)})),e.model.on("insertContent",Z_,{priority:"high"}),e.commands.add("numberedList",new __(e,"numbered")),e.commands.add("bulletedList",new __(e,"bulleted")),e.commands.add("indentList",new x_(e,"forward")),e.commands.add("outdentList",new x_(e,"backward"));const o=i.view.document;this.listenTo(o,"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(o,"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 o=n.parent;if("listItem"!==o.name)return;o.previousSibling&&"listItem"===o.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 Q_(e){let t=1;for(const i of e.getChildren())if("ul"==i.name||"ol"==i.name)for(const e of i.getChildren())t+=Q_(e);return t}class J_ extends vs{static get pluginName(){return"ListUI"}init(){const e=this.editor.t;P_(this.editor,"numberedList",e("Numbered List"),''),P_(this.editor,"bulletedList",e("Bulleted List"),'')}}class X_ extends vs{static get requires(){return[Y_,J_]}static get pluginName(){return"List"}}function ev(e,t){return`${e}:${t=t||Ao(e)}`}class tv extends xs{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,o=!!e&&ev(e,t);i.change((e=>{if(n.isCollapsed)o?e.setSelectionAttribute("language",o):e.removeSelectionAttribute("language");else{const t=i.schema.getValidRanges(n.getRanges(),"language");for(const i of t)o?e.setAttribute("language",o,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 iv extends vs{static get pluginName(){return"TextPartLanguageEditing"}constructor(e){super(e),e.config.define("language",{textPartLanguage:[{title:"Arabic",languageCode:"ar"},{title:"French",languageCode:"fr"},{title:"Spanish",languageCode:"es"}]})}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 tv(e))}_defineConverters(){const e=this.editor.conversion;e.for("upcast").elementToAttribute({model:{key:"language",value:e=>ev(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:o}=function(e){const[t,i]=e.split(":");return{languageCode:t,textDirection:i}}(e);return t.createAttributeElement("span",{lang:n,dir:o})}})}}class nv extends vs{static get pluginName(){return"TextPartLanguageUI"}init(){const e=this.editor,t=e.t,i=e.config.get("language.textPartLanguage"),n=t("Choose language"),o=t("Remove language"),r=t("Language");e.ui.componentFactory.add("textPartLanguage",(t=>{const s=new To,a={},l=e.commands.get("textPartLanguage");s.add({type:"button",model:new vf({label:o,languageCode:!1,withText:!0})}),s.add({type:"separator"});for(const e of i){const t={type:"button",model:new vf({label:e.title,languageCode:e.languageCode,role:"menuitemradio",textDirection:e.textDirection,withText:!0})},i=ev(e.languageCode,e.textDirection);t.model.bind("isOn").to(l,"value",(e=>e===i)),s.add(t),a[i]=e.title}const c=Zm(t);return qm(c,s,{ariaLabel:r,role:"menu"}),c.buttonView.set({ariaLabel:r,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:r}),c.extendTemplate({attributes:{class:["ck-text-fragment-language-dropdown"]}}),c.bind("isEnabled").to(l,"isEnabled"),c.buttonView.bind("label").to(l,"value",(e=>e&&a[e]||n)),this.listenTo(c,"execute",(t=>{l.execute({languageCode:t.source.languageCode,textDirection:t.source.textDirection}),e.editing.view.focus()})),c}))}}class ov extends vs{static get requires(){return[iv,nv]}static get pluginName(){return"TextPartLanguage"}}class rv extends xs{constructor(e){super(e),this.affectsData=!1,this.value=!1}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)}))}}class sv extends vs{static get pluginName(){return"ShowBlocksEditing"}init(){const{editor:e}=this;e.commands.add("showBlocks",new rv(e))}}var av=i(1496),lv={attributes:{"data-cke":!0}};lv.setAttributes=$o(),lv.insert=Zo().bind(null,"head"),lv.domAPI=Ho(),lv.insertStyleElement=Go();jo()(av.Z,lv);av.Z&&av.Z.locals&&av.Z.locals;class cv extends vs{static get pluginName(){return"ShowBlocksUI"}init(){const e=this.editor;e.ui.componentFactory.add("showBlocks",(t=>{const i=e.commands.get("showBlocks"),n=new Er(t),o=t.t;return n.set({label:o("Show blocks"),icon:'',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("showBlocks"),e.editing.view.focus()})),n}))}}class dv extends vs{static get pluginName(){return"ShowBlocks"}static get requires(){return[sv,cv]}}class uv extends xs{constructor(e,t){super(e),this.attributeKey=t}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,o=e.batch,r=e=>{if(i.isCollapsed)n?e.setSelectionAttribute(this.attributeKey,n):e.removeSelectionAttribute(this.attributeKey);else{const o=t.schema.getValidRanges(i.getRanges(),this.attributeKey);for(const t of o)n?e.setAttribute(this.attributeKey,n,t):e.removeAttribute(this.attributeKey,t)}};o?t.enqueueChange(o,(e=>{r(e)})):t.change((e=>{r(e)}))}}const hv="fontSize",mv="fontFamily",gv="fontColor",fv="fontBackgroundColor";function pv(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 bv(e){return t=>t.getStyle(e).replace(/\s/g,"")}function wv(e){return(t,{writer:i})=>i.createAttributeElement("span",{style:`${e}:${t}`},{priority:7})}class kv extends uv{constructor(e){super(e,mv)}}function _v(e){return e.map(vv).filter((e=>void 0!==e))}function vv(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(yv).join(", ");return{title:i,model:n,view:{name:"span",styles:{"font-family":n},priority:7}}}(e):void 0}function yv(e){return(e=e.trim()).indexOf(" ")>0&&(e=`'${e}'`),e}class xv extends vs{static get pluginName(){return"FontFamilyEditing"}constructor(e){super(e),e.config.define(mv,{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})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:mv}),e.model.schema.setAttributeProperties(mv,{isFormatting:!0,copyOnEnter:!0});const t=_v(e.config.get("fontFamily.options")).filter((e=>e.model)),i=pv(mv,t);e.config.get("fontFamily.supportAllValues")?(this._prepareAnyValueConverters(),this._prepareCompatibilityConverter()):e.conversion.attributeToElement(i),e.commands.add(mv,new kv(e))}_prepareAnyValueConverters(){const e=this.editor;e.conversion.for("downcast").attributeToElement({model:mv,view:(e,{writer:t})=>t.createAttributeElement("span",{style:"font-family:"+e},{priority:7})}),e.conversion.for("upcast").elementToAttribute({model:{key:mv,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:mv,value:e=>e.getAttribute("face")}})}}class Av extends vs{static get pluginName(){return"FontFamilyUI"}init(){const e=this.editor,t=e.t,i=this._getLocalizedOptions(),n=e.commands.get(mv),o=t("Font Family");e.ui.componentFactory.add(mv,(t=>{const r=Zm(t);return qm(r,(()=>function(e,t){const i=new To;for(const n of e){const e={type:"button",model:new vf({commandName:mv,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)),{role:"menu",ariaLabel:o}),r.buttonView.set({label:o,icon:'',tooltip:!0}),r.extendTemplate({attributes:{class:"ck-font-family-dropdown"}}),r.bind("isEnabled").to(n),this.listenTo(r,"execute",(t=>{e.execute(t.source.commandName,{value:t.source.commandParam}),e.editing.view.focus()})),r}))}_getLocalizedOptions(){const e=this.editor,t=e.t;return _v(e.config.get(mv).options).map((e=>("Default"===e.title&&(e.title=t("Default")),e)))}}class Ev extends vs{static get requires(){return[xv,Av]}static get pluginName(){return"FontFamily"}}class Cv extends uv{constructor(e){super(e,hv)}}function Sv(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 Pv(e);var t;const i=function(e){return"string"==typeof e?Tv[e]:Tv[e.model]}(e);if(i)return Pv(i);if("default"===e)return{model:void 0,title:"Default"};if(function(e){let t;if("object"==typeof e){if(!e.model)throw new y("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}},Pv(e)}(e)}(e))).filter((e=>void 0!==e))}const Tv={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 Pv(e){return e.view&&"string"!=typeof e.view&&!e.view.priority&&(e.view.priority=7),e}const Iv=["x-small","x-small","small","medium","large","x-large","xx-large","xxx-large"];class Ov extends vs{static get pluginName(){return"FontSizeEditing"}constructor(e){super(e),e.config.define(hv,{options:["tiny","small","default","big","huge"],supportAllValues:!1})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:hv}),e.model.schema.setAttributeProperties(hv,{isFormatting:!0,copyOnEnter:!0});const t=e.config.get("fontSize.supportAllValues"),i=Sv(this.editor.config.get("fontSize.options")).filter((e=>e.model)),n=pv(hv,i);t?(this._prepareAnyValueConverters(n),this._prepareCompatibilityConverter()):e.conversion.attributeToElement(n),e.commands.add(hv,new Cv(e))}_prepareAnyValueConverters(e){const t=this.editor,i=e.model.values.filter((e=>{return!(t=String(e),Xh.test(t)||function(e){return em.test(e)}(String(e)));var t}));if(i.length)throw new y("font-size-invalid-use-of-named-presets",null,{presets:i});t.conversion.for("downcast").attributeToElement({model:hv,view:(e,{writer:t})=>{if(e)return t.createAttributeElement("span",{style:"font-size:"+e},{priority:7})}}),t.conversion.for("upcast").elementToAttribute({model:{key:hv,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:hv,value:e=>{const t=e.getAttribute("size"),i="-"===t[0]||"+"===t[0];let n=parseInt(t,10);i&&(n=3+n);const o=Iv.length-1,r=Math.min(Math.max(n,0),o);return Iv[r]}}})}}var Mv=i(9875),Rv={attributes:{"data-cke":!0}};Rv.setAttributes=$o(),Rv.insert=Zo().bind(null,"head"),Rv.domAPI=Ho(),Rv.insertStyleElement=Go();jo()(Mv.Z,Rv);Mv.Z&&Mv.Z.locals&&Mv.Z.locals;class Nv extends vs{static get pluginName(){return"FontSizeUI"}init(){const e=this.editor,t=e.t,i=this._getLocalizedOptions(),n=e.commands.get(hv),o=t("Font Size");e.ui.componentFactory.add(hv,(t=>{const r=Zm(t);return qm(r,(()=>function(e,t){const i=new To;for(const n of e){const e={type:"button",model:new vf({commandName:hv,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)),{role:"menu",ariaLabel:o}),r.buttonView.set({label:o,icon:'',tooltip:!0}),r.extendTemplate({attributes:{class:["ck-font-size-dropdown"]}}),r.bind("isEnabled").to(n),this.listenTo(r,"execute",(t=>{e.execute(t.source.commandName,{value:t.source.commandParam}),e.editing.view.focus()})),r}))}_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 Sv(e.config.get(hv).options).map((e=>{const t=i[e.title];return t&&t!=e.title&&(e=Object.assign({},e,{title:t})),e}))}}class Vv extends vs{static get requires(){return[Ov,Nv]}static get pluginName(){return"FontSize"}normalizeSizeOptions(e){return Sv(e)}}class Lv extends uv{constructor(e){super(e,gv)}}class Dv extends vs{static get pluginName(){return"FontColorEditing"}constructor(e){super(e),e.config.define(gv,{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:gv,value:bv("color")}}),e.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{color:/^#?\w+$/}},model:{key:gv,value:e=>e.getAttribute("color")}}),e.conversion.for("downcast").attributeToElement({model:gv,view:wv("color")}),e.commands.add(gv,new Lv(e)),e.model.schema.extend("$text",{allowAttributes:gv}),e.model.schema.setAttributeProperties(gv,{isFormatting:!0,copyOnEnter:!0})}}class Bv extends vs{constructor(e,{commandName:t,componentName:i,icon:n,dropdownLabel:o}){super(e),this.commandName=t,this.componentName=i,this.icon=n,this.dropdownLabel=o,this.columns=e.config.get(`${this.componentName}.columns`),this.colorSelectorView=void 0}init(){const e=this.editor,t=e.locale,i=t.t,n=e.commands.get(this.commandName),o=e.config.get(this.componentName),r=function(e){return e.map(Pr).filter((e=>!!e))}(o.colors),s=function(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}))}(t,r),a=o.documentColors,l=!1!==o.colorPicker;e.ui.componentFactory.add(this.componentName,(t=>{const r=Zm(t);let c=!1;return this.colorSelectorView=function({dropdownView:e,colors:t,columns:i,removeButtonLabel:n,colorPickerLabel:o,documentColorsLabel:r,documentColorsCount:s,colorPickerViewConfig:a}){const l=e.locale,c=new zg(l,{colors:t,columns:i,removeButtonLabel:n,colorPickerLabel:o,documentColorsLabel:r,documentColorsCount:s,colorPickerViewConfig:a});return e.colorSelectorView=c,e.panelView.children.add(c),c}({dropdownView:r,colors:s.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!==a?i("Document colors"):"",documentColorsCount:void 0===a?this.columns:a,colorPickerViewConfig:!!l&&(o.colorPicker||{})}),this.colorSelectorView.bind("selectedColor").to(n,"value"),r.buttonView.set({label:this.dropdownLabel,icon:this.icon,tooltip:!0}),r.extendTemplate({attributes:{class:"ck-color-ui-dropdown"}}),r.bind("isEnabled").to(n),this.colorSelectorView.on("execute",((t,i)=>{r.isOpen&&e.execute(this.commandName,{value:i.value,batch:this._undoStepBatch}),"colorPicker"!==i.source&&e.editing.view.focus(),"colorPickerSaveButton"===i.source&&(r.isOpen=!1)})),this.colorSelectorView.on("colorPicker:show",(()=>{this._undoStepBatch=e.model.createBatch()})),this.colorSelectorView.on("colorPicker:cancel",(()=>{this._undoStepBatch.operations.length&&(r.isOpen=!1,e.execute("undo",this._undoStepBatch)),e.editing.view.focus()})),r.on("change:isOpen",((t,i,n)=>{c||(c=!0,r.colorSelectorView.appendUI()),n&&(0!==a&&this.colorSelectorView.updateDocumentColors(e.model,this.componentName),this.colorSelectorView.updateSelectedColors(),this.colorSelectorView.showColorGridsFragment())})),Km(r,(()=>r.colorSelectorView.colorGridsFragmentView.staticColorsGrid.items.find((e=>e.isOn)))),r}))}}class zv extends Bv{constructor(e){const t=e.locale.t;super(e,{commandName:gv,componentName:gv,icon:'',dropdownLabel:t("Font Color")})}static get pluginName(){return"FontColorUI"}}class jv extends vs{static get requires(){return[Dv,zv]}static get pluginName(){return"FontColor"}}class Fv extends uv{constructor(e){super(e,fv)}}class Hv extends vs{static get pluginName(){return"FontBackgroundColorEditing"}constructor(e){super(e),e.config.define(fv,{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(hm),e.conversion.for("upcast").elementToAttribute({view:{name:"span",styles:{"background-color":/[\s\S]+/}},model:{key:fv,value:bv("background-color")}}),e.conversion.for("downcast").attributeToElement({model:fv,view:wv("background-color")}),e.commands.add(fv,new Fv(e)),e.model.schema.extend("$text",{allowAttributes:fv}),e.model.schema.setAttributeProperties(fv,{isFormatting:!0,copyOnEnter:!0})}}class Uv extends Bv{constructor(e){const t=e.locale.t;super(e,{commandName:fv,componentName:fv,icon:'',dropdownLabel:t("Font Background Color")})}static get pluginName(){return"FontBackgroundColorUI"}}class Zv extends vs{static get requires(){return[Hv,Uv]}static get pluginName(){return"FontBackgroundColor"}}class Wv extends vs{static get requires(){return[Ev,Vv,jv,Zv]}static get pluginName(){return"Font"}}function $v(e,t){if(!e.childCount)return;const i=new Zh(e.document),n=function(e,t){const i=t.createRangeIn(e),n=new Us({name:/^p|h\d+$/,styles:{"mso-list":/.*/}}),o=[];for(const e of i)if("elementStart"===e.type&&n.match(e.item)){const t=Kv(e.item);o.push({element:e.item,id:t.id,order:t.order,indent:t.indent})}return o}(e,i);if(!n.length)return;let o=null,r=1;n.forEach(((e,s)=>{const a=function(e,t){if(!e)return!0;if(e.id!==t.id)return t.indent-e.indent!=1;const i=t.element.previousSibling;if(!i)return!0;return n=i,!(n.is("element","ol")||n.is("element","ul"));var n}(n[s-1],e),l=a?null:n[s-1],c=(u=e,(d=l)?u.indent-d.indent:u.indent-1);var d,u;if(a&&(o=null,r=1),!o||0!==c){const n=function(e,t){const i=new RegExp(`@list l${e.id}:level${e.indent}\\s*({[^}]*)`,"gi"),n=/mso-level-number-format:([^;]{0,100});/gi,o=/mso-level-start-at:\s{0,100}([0-9]{0,10})\s{0,100};/gi,r=i.exec(t);let s="decimal",a="ol",l=null;if(r&&r[1]){const t=n.exec(r[1]);if(t&&t[1]&&(s=t[1].trim(),a="bullet"!==s&&"image"!==s?"ol":"ul"),"bullet"===s){const t=function(e){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&&(s=t)}else{const e=o.exec(r[1]);e&&e[1]&&(l=parseInt(e[1]))}}return{type:a,startIndex:l,style:qv(s)}}(e,t);if(o){if(e.indent>r){const e=o.getChild(o.childCount-1),t=e.getChild(e.childCount-1);o=Gv(n,t,i),r+=1}else if(e.indent1&&i.setAttribute("start",e.startIndex,o),o}function Kv(e){const t={},i=e.getStyle("mso-list");if(i){const e=i.match(/(^|\s{1,100})l(\d+)/i),n=i.match(/\s{0,100}lfo(\d+)/i),o=i.match(/\s{0,100}level(\d+)/i);e&&n&&o&&(t.id=e[2],t.order=n[1],t.indent=parseInt(o[1]))}return t}function Yv(e,t){if(!e.childCount)return;const i=new Zh(e.document),n=function(e,t){const i=t.createRangeIn(e),n=new Us({name:/v:(.+)/}),o=[];for(const e of i){if("elementStart"!=e.type)continue;const t=e.item,i=t.previousSibling,r=i&&i.is("element")?i.name:null;n.match(t)&&t.getAttribute("o:gfxdata")&&"v:shapetype"!==r&&o.push(e.item.getAttribute("id"))}return o}(e,i);!function(e,t,i){const n=i.createRangeIn(t),o=new Us({name:"img"}),r=[];for(const t of n)if(t.item.is("element")&&o.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))?r.push(i):i.getAttribute("src")||r.push(i)}for(const e of r)i.remove(e)}(n,e,i),function(e,t,i){const n=i.createRangeIn(t),o=[];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;r(t.item.parent.getChildren(),i)||o.push(t.item)}for(const e of o){const t={src:s(e)};e.hasAttribute("alt")&&(t.alt=e.getAttribute("alt"));const n=i.createElement("img",t);i.insertChild(e.index+1,n,e.parent)}function r(e,t){for(const i of e)if(i.is("element")){if("img"==i.name&&i.getAttribute("v:shapes")==t)return!0;if(r(i.getChildren(),t))return!0}return!1}function s(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 Us({name:/v:(.+)/}),o=[];for(const e of i)"elementStart"==e.type&&n.match(e.item)&&o.push(e.item);for(const e of o)t.remove(e)}(e,i);const o=function(e,t){const i=t.createRangeIn(e),n=new Us({name:"img"}),o=[];for(const e of i)e.item.is("element")&&n.match(e.item)&&e.item.getAttribute("src").startsWith("file://")&&o.push(e.item);return o}(e,i);o.length&&function(e,t,i){if(e.length===t.length)for(let n=0;nString.fromCharCode(parseInt(e,16)))).join(""))}const Jv=//i,Xv=/xmlns:o="urn:schemas-microsoft-com/i;class ey{constructor(e){this.document=e}isActive(e){return Jv.test(e)||Xv.test(e)}execute(e){const{body:t,stylesString:i}=e._parsedData;$v(t,i),Yv(t,e.dataTransfer.getData("text/rtf")),function(e){const t=new Zh(e.document);for(const i of e.getChildren()){if(!i.is("element"))continue;if(i.is("element","table")){t.setAttribute("align","left",i);continue}const e=i.getAttribute("align"),n=i.getChild(0);"div"===i.name&&e&&n&&n.is("element","table")&&t.setAttribute("align","center"===e?"none":e,n)}}(t),e.content=t}}function ty(e,t,i,{blockElements:n,inlineObjectElements:o}){let r=i.createPositionAt(e,"forward"==t?"after":"before");return r=r.getLastMatchingPosition((({item:e})=>e.is("element")&&!n.includes(e.name)&&!o.includes(e.name)),{direction:t}),"forward"==t?r.nodeAfter:r.nodeBefore}function iy(e,t){return!!e&&e.is("element")&&t.includes(e.name)}const ny=/id=("|')docs-internal-guid-[-0-9a-f]+("|')/i;class oy{constructor(e){this.document=e}isActive(e){return ny.test(e)}execute(e){const t=new Zh(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 ll(t.document.stylesProcessor),n=new Xl(i,{renderingMode:"data"}),o=n.blockElements,r=n.inlineObjectElements,s=[];for(const i of t.createRangeIn(e)){const e=i.item;if(e.is("element","br")){const i=ty(e,"forward",t,{blockElements:o,inlineObjectElements:r}),n=ty(e,"backward",t,{blockElements:o,inlineObjectElements:r}),a=iy(i,o);(iy(n,o)||a)&&s.push(e)}}for(const e of s)e.hasClass("Apple-interchange-newline")?t.remove(e):t.replace(e,t.createElement("p"))}(i,t),e.content=i}}const ry=/(\s+)<\/span>/g,((e,t)=>1===t.length?" ":Array(t.length+1).join("  ").substr(0,t.length)))}function ly(e,t){const i=new DOMParser,n=function(e){return ay(ay(e)).replace(/([^\S\r\n]*?)[\r\n]+([^\S\r\n]*<\/span>)/g,"$1$2").replace(/<\/span>/g,"").replace(/()[\r\n]+(<\/span>)/g,"$1 $2").replace(/ <\//g," <\/o:p>/g," ").replace(/( |\u00A0)<\/o:p>/g,"").replace(/>([^\S\r\n]*[\r\n]\s*)<")}(function(e){const t="",i="",n=e.indexOf(t);if(n<0)return e;const o=e.indexOf(i,n+t.length);return e.substring(0,n+t.length)+(o>=0?e.substring(o):"")}(e=e.replace(/