diff --git a/config/nova-ckeditor.php b/config/nova-ckeditor.php index 93429e3..147a646 100644 --- a/config/nova-ckeditor.php +++ b/config/nova-ckeditor.php @@ -102,7 +102,7 @@ 'html-support' => [ 'allow' => [ [ - 'name' => 'div', + 'name' => 'div', 'classes' => true, ], [ @@ -140,6 +140,7 @@ 'videoBrowser', 'mediaEmbed', 'link', + 'resizeImage', '|', 'bold', 'italic', @@ -374,6 +375,70 @@ ] ], + 'image' => [ + 'upload' => [ + 'types' => ['gif', 'png', 'jpg', 'jpeg', 'webp'] + ], + + 'resizeUnit' => '%', + + 'resizeOptions' => [ + [ + 'name' => 'resizeImage:original', + 'value' => null, + 'label' => 'Original', + 'icon' => 'original' + ], + [ + 'name' => 'resizeImage:25', + 'value' => '25', + 'label' => 'Small (25%)', + 'icon' => 'small' + ], + [ + 'name' => 'resizeImage:50', + 'value' => '50', + 'label' => 'Medium', + 'icon' => 'medium' + ], + [ + 'name' => 'resizeImage:75', + 'value' => '75', + 'label' => 'Large (75%)', + 'icon' => 'large' + ] + ], + + 'toolbar' => [ + 'imageBrowser', + '|', + 'imageStyle:full', + 'imageStyle:alignLeft', + 'imageStyle:alignCenter', + 'imageStyle:alignRight', + '|', + 'imageTextAlternative', + 'toggleImageCaption', + '|', + 'imageStyle:block', + 'imageStyle:side', + '|', + 'linkImage', + '|', + 'resizeImage:25', + 'resizeImage:50', + 'resizeImage:75', + 'resizeImage:original', + ], + + 'styles' => [ + 'full', + 'alignLeft', + 'alignCenter', + 'alignRight', + ] + ], + 'mediaEmbed' => [] ], ] diff --git a/dist/js/field.js b/dist/js/field.js index 5209b38..2db2e70 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 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",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","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__(9995),_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 n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function _objectSpread(e){for(var t=1;t1&&t.editing.view.change((function(n){n.setStyle("height","".concat(e.currentField.height,"px"),t.editing.view.document.getRoot())})),e.currentField.readonly&&t.enableReadOnlyMode(e.$options[e.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";n.d(t,{Z:()=>i});const i="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="},9995:(e,t,n)=>{"use strict";function i({emitter:e,activator:t,callback:n,contextElements:i}){e.listenTo(document,"mousedown",((e,o)=>{if(!t())return;const r="function"==typeof o.composedPath?o.composedPath():[],s="function"==typeof i?i():i;for(const e of s)if(e.contains(o.target)||r.includes(e))return;n()}))}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,n)=>{n.preventDefault(),e.fire("submit")}),{useCapture:!0})}function s({keystrokeHandler:e,focusTracker:t,gridItems:n,numberOfColumns:i,uiLanguageDirection:o}){const r="number"==typeof i?()=>i:i;function s(e){return i=>{const o=n.find((e=>e.element===t.focusedElement)),r=n.getIndex(o),s=e(r,n);n.get(s).focus(),i.stopPropagation(),i.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 n=e-r();return n<0&&(n=e+r()*Math.floor(t.length/r()),n>t.length-1&&(n-=r())),n}))),e.set("arrowdown",s(((e,t)=>{let n=e+r();return n>t.length-1&&(n=e%r()),n})))}n.d(t,{Z:()=>OI});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,n,i){n=n||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,n){const i=h(e,t,n);if(-1===i)return{firstIndex:-1,lastIndexOld:-1,lastIndexNew:-1};const o=m(e,i),r=m(t,i),s=h(o,r,n),a=e.length-s,l=t.length-s;return{firstIndex:i,lastIndexOld:a,lastIndexNew:l}}(o,r,n),a=i?function(e,t){const{firstIndex:n,lastIndexOld:i,lastIndexNew:o}=e;if(-1===n)return Array(t).fill("equal");let r=[];n>0&&(r=r.concat(Array(n).fill("equal")));o-n>0&&(r=r.concat(Array(o-n).fill("insert")));i-n>0&&(r=r.concat(Array(i-n).fill("delete")));o0&&n.push({index:i,type:"insert",values:e.slice(i,r)});o-i>0&&n.push({index:i+(r-i),type:"delete",howMany:o-i});return n}(r,s);return a}function h(e,t,n){for(let i=0;i200||o>200||i+o>300)return f.fastDiff(e,t,n,!0);let r,s;if(oc?-1:1;d[i+h]&&(d[i]=d[i+h].slice(0)),d[i]||(d[i]=[]),d[i].push(o>c?r:s);let m=Math.max(o,c),f=m-i;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,n=4294967296*Math.random()>>>0,i=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[n>>0&255]+b[n>>8&255]+b[n>>16&255]+b[n>>24&255]+b[i>>0&255]+b[i>>8&255]+b[i>>16&255]+b[i>>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 n=k.get(t.priority);for(let i=0;i{if("object"==typeof t&&null!==t){if(n.has(t))return`[object ${t.constructor.name}]`;n.add(t)}return t},o=t?` ${JSON.stringify(t,i)}`:"",r=x(e);return e+o+r}(e,n)),this.name="CKEditorError",this.context=t,this.data=n}is(e){return"CKEditorError"===e}static rethrowUnexpectedError(e,t){if(e.is&&e.is("CKEditorError"))throw e;const n=new y(e.message,t);throw n.stack=e.stack,n}}function A(e,t){console.warn(...E(e,t))}function x(e){return`\nRead more: ${v}#error-${e}`}function E(e,t){const n=x(e);return t?[e,t,n]:[e,n]}const C="38.1.0",S=new Date(2023,5,28),T="object"==typeof window?window:n.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,n){this.listenTo(this,e,t,n)}once(e,t,n){let i=!1;this.listenTo(this,e,((e,...n)=>{i||(i=!0,e.off(),t.call(this,e,...n))}),n)}off(e,t){this.stopListening(this,e,t)}listenTo(e,t,n,i={}){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(n),function(e,t,n,i,o){t._addEventListener?t._addEventListener(n,i,o):e._addEventListener.call(t,n,i,o)}(this,e,t,n,i)}stopListening(e,t,n){const i=this[P];let o=e&&V(e);const r=i&&o?i[o]:void 0,s=r&&t?r.callbacks[t]:void 0;if(!(!i||e&&!r||t&&!s))if(n){z(this,e,t,n);-1!==s.indexOf(n)&&(1===s.length?delete r.callbacks[t]:z(this,e,t,n))}else if(s){for(;n=s.pop();)z(this,e,t,n);delete r.callbacks[t]}else if(r){for(t in r.callbacks)this.stopListening(e,t);delete i[o]}else{for(o in i)this.stopListening(i[o].emitter);delete this[P]}}fire(e,...t){try{const n=e instanceof p?e:new p(this,e),i=n.name;let o=B(this,i);if(n.path.push(this),o){const e=[n,...t];o=Array.from(o);for(let t=0;t{this[O]||(this[O]=new Map),e.forEach((e=>{const i=this[O].get(e);i?i.set(t,n):this[O].set(e,new Map([[t,n]]))}))}}}stopDelegating(e,t){if(this[O])if(e)if(t){const n=this[O].get(e);n&&n.delete(t)}else this[O].delete(e);else this[O].clear()}_addEventListener(e,t,n){!function(e,t){const n=D(e);if(n[t])return;let i=t,o=null;const r=[];for(;""!==i&&!n[i];)n[i]={callbacks:[],childEvents:[]},r.push(n[i]),o&&n[i].childEvents.push(o),o=i,i=i.substr(0,i.lastIndexOf(":"));if(""!==i){for(const e of r)e.callbacks=n[i].callbacks.slice();n[i].childEvents.push(o)}}(this,e);const i=L(this,e),o={callback:t,priority:k.get(n.priority)};for(const e of i)_(e,o)}_removeEventListener(e,t){const n=L(this,e);for(const e of n)for(let n=0;n-1?B(e,t.substr(0,t.lastIndexOf(":"))):null}function j(e,t,n){for(let[i,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],i.fire(e,...n)}}function z(e,t,n,i){t._removeEventListener?t._removeEventListener(n,i):e._removeEventListener.call(t,n,i)}["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"),Z=Symbol("boundProperties"),W=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 n=this[H];if(e in this&&!n.has(e))throw new y("observable-set-cannot-override",this);Object.defineProperty(this,e,{enumerable:!0,configurable:!0,get:()=>n.get(e),set(t){const i=n.get(e);let o=this.fire(`set:${e}`,e,t,i);void 0===o&&(o=t),i===o&&n.has(e)||(n.set(e,o),this.fire(`change:${e}`,e,o,i))}}),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[Z];e.forEach((e=>{if(t.has(e))throw new y("observable-bind-rebind",this)}));const n=new Map;return e.forEach((e=>{const i={property:e,to:[]};t.set(e,i),n.set(e,i)})),{to:Y,toMany:Q,_observable:this,_bindProperties:e,_to:[],_bindings:n}}unbind(...e){if(!this[H])return;const t=this[Z],n=this[U];if(e.length){if(!J(e))throw new y("observable-unbind-wrong-properties",this);e.forEach((e=>{const i=t.get(e);i&&(i.to.forEach((([e,t])=>{const o=n.get(e),r=o[t];r.delete(i),r.size||delete o[t],Object.keys(o).length||(n.delete(e),this.stopListening(e,"change"))})),t.delete(e))}))}else n.forEach(((e,t)=>{this.stopListening(t,"change")})),n.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,n)=>{e.return=t.apply(this,n)})),this[e]=function(...t){return this.fire(e,t)},this[e][$]=t,this[W]||(this[W]=[]),this[W].push(e)}stopListening(e,t,n){if(!e&&this[W]){for(const e of this[W])this[e]=this[e][$];delete this[W]}super.stopListening(e,t,n)}}}function K(e){e[H]||(Object.defineProperty(e,H,{value:new Map}),Object.defineProperty(e,U,{value:new Map}),Object.defineProperty(e,Z,{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 n;"function"==typeof e[e.length-1]&&(t.callback=e.pop());return e.forEach((e=>{if("string"==typeof e)n.properties.push(e);else{if("object"!=typeof e)throw new y("observable-bind-to-parse-error",null);n={observable:e,properties:[]},t.to.push(n)}})),t}(...e),n=Array.from(this._bindings.keys()),i=n.length;if(!t.callback&&t.to.length>1)throw new y("observable-bind-to-no-callback",this);if(i>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!==i)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(n[0]).callback=t.callback),o=this._observable,this._to.forEach((e=>{const t=o[U];let n;t.get(e.observable)||o.listenTo(e.observable,"change",((i,r)=>{n=t.get(e.observable)[r],n&&n.forEach((e=>{X(o,e.property)}))}))})),function(e){let t;e._bindings.forEach(((n,i)=>{e._to.forEach((o=>{t=o.properties[n.callback?0:e._bindProperties.indexOf(i)],n.to.push([o.observable,t]),function(e,t,n,i){const o=e[U],r=o.get(n),s=r||{};s[i]||(s[i]=new Set);s[i].add(t),r||o.set(n,s)}(e._observable,n,o.observable,t)}))}))}(this),this._bindProperties.forEach((e=>{X(this._observable,e)}))}function Q(e,t,n){if(this._bindings.size>1)throw new y("observable-bind-to-many-not-one-binding",this);this.to(...function(e,t){const n=e.map((e=>[e,t]));return Array.prototype.concat.apply([],n)}(e,t),n)}function J(e){return e.every((e=>"string"==typeof e))}function X(e,t){const n=e[Z].get(t);let i;n.callback?i=n.callback.apply(e,n.to.map((e=>e[0][e[1]]))):(i=n.to[0],i=i[0][i[1]]),Object.prototype.hasOwnProperty.call(e,t)?e[t]=i:e.set(t,i)}["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 n of e)t++;return t}function ne(e,t){const n=Math.min(e.length,t.length);for(let i=0;i-1};const De=function(e,t){var n=this.__data__,i=Oe(n,e);return i<0?(++this.size,n.push([e,t])):n[i][1]=t,this};function Le(e){var t=-1,n=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 en=Xt&&Xt.isTypedArray;const tn=en?Kt(en):Gt;var nn=Object.prototype.hasOwnProperty;const on=function(e,t){var n=be(e),i=!n&&Bt(e),o=!n&&!i&&Ut(e),r=!n&&!i&&!o&&tn(e),s=n||i||o||r,a=s?Rt(e.length,String):[],l=a.length;for(var c in e)!t&&!nn.call(e,c)||s&&("length"==c||o&&("offset"==c||"parent"==c)||r&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||Wt(c,l))||a.push(c);return a};var rn=Object.prototype;const sn=function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||rn)};const an=ve(Object.keys,Object);var ln=Object.prototype.hasOwnProperty;const cn=function(e){if(!sn(e))return an(e);var t=[];for(var n in Object(e))ln.call(e,n)&&"constructor"!=n&&t.push(n);return t};const dn=function(e){return null!=e&&$t(e.length)&&!Ue(e)};const un=function(e){return dn(e)?on(e):cn(e)};const hn=function(e,t){return e&&Mt(t,un(t),e)};const mn=function(e){var t=[];if(null!=e)for(var n in Object(e))t.push(n);return t};var fn=Object.prototype.hasOwnProperty;const gn=function(e){if(!F(e))return mn(e);var t=sn(e),n=[];for(var i in e)("constructor"!=i||!t&&fn.call(e,i))&&n.push(i);return n};const pn=function(e){return dn(e)?on(e,!0):gn(e)};const bn=function(e,t){return e&&Mt(t,pn(t),e)};var wn="object"==typeof exports&&exports&&!exports.nodeType&&exports,kn=wn&&"object"==typeof module&&module&&!module.nodeType&&module,_n=kn&&kn.exports===wn?se.Buffer:void 0,vn=_n?_n.allocUnsafe:void 0;const yn=function(e,t){if(t)return e.slice();var n=e.length,i=vn?vn(n):new e.constructor(n);return e.copy(i),i};const An=function(e,t){var n=-1,i=e.length;for(t||(t=Array(i));++n{this._setToTarget(e,i,t[i],n)}))}}function Si(e){return xi(e,Ti)}function Ti(e){return Ei(e)?e:void 0}function Pi(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 Ii(e){const t=Object.prototype.toString.apply(e);return"[object Window]"==t||"[object global]"==t}const Oi=Mi(R());function Mi(e){if(!e)return Oi;return class extends e{listenTo(e,t,n,i={}){if(Pi(e)||Ii(e)){const o={capture:!!i.useCapture,passive:!!i.usePassive},r=this._getProxyEmitter(e,o)||new Ri(e,o);this.listenTo(r,t,n,i)}else super.listenTo(e,t,n,i)}stopListening(e,t,n){if(Pi(e)||Ii(e)){const i=this._getAllProxyEmitters(e);for(const e of i)this.stopListening(e,t,n)}else super.stopListening(e,t,n)}_getProxyEmitter(e,t){return function(e,t){const n=e[P];return n&&n[t]?n[t].emitter:null}(this,Ni(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=>{Mi[e]=Oi.prototype[e]}));class Ri extends(R()){constructor(e,t){super(),N(this,Ni(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,n){this.attach(e),R().prototype._addEventListener.call(this,e,t,n)}_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 Ni(e,t){let n=function(e){return e["data-ck-expando"]||(e["data-ck-expando"]=w())}(e);for(const e of Object.keys(t).sort())t[e]&&(n+="-"+e);return n}let Vi;try{Vi={window,document}}catch(e){Vi={window:{},document:{}}}const Di=Vi;function Li(e){const t=[];let n=e;for(;n&&n.nodeType!=Node.DOCUMENT_NODE;)t.unshift(n),n=n.parentNode;return t}function Bi(e){return"[object Text]"==Object.prototype.toString.call(e)}function ji(e){return"[object Range]"==Object.prototype.toString.apply(e)}function zi(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 Fi=["top","right","bottom","left","width","height"];class Hi{constructor(e){const t=ji(e);if(Object.defineProperty(this,"_source",{value:e._source||e,writable:!0,enumerable:!1}),Wi(e)||t)if(t){const t=Hi.getDomRangeRects(e);Ui(this,Hi.getBoundingRect(t))}else Ui(this,e.getBoundingClientRect());else if(Ii(e)){const{innerWidth:t,innerHeight:n}=e;Ui(this,{top:0,right:t,bottom:n,left:0,width:t,height:n})}else Ui(this,e)}clone(){return new Hi(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 Hi(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(Zi(e))return t;let n,i=e,o=e.parentNode||e.commonAncestorContainer;for(;o&&!Zi(o);){if(i instanceof HTMLElement&&"absolute"===$i(i)&&(n=i),n&&("relative"!==$i(o)||"visible"===(r=o).ownerDocument.defaultView.getComputedStyle(r).overflow)){i=o,o=o.parentNode;continue}const e=new Hi(o),s=t.getIntersection(e);if(!s)return null;s.getArea(){for(const t of e){const e=qi._getElementCallbacks(t.target);if(e)for(const n of e)n(t)}}))}}function Gi(e,t){e instanceof HTMLTextAreaElement&&(e.value=t),e.innerHTML=t}function Ki(e){return t=>t+e}function Yi(e){let t=0;for(;e.previousSibling;)e=e.previousSibling,t++;return t}function Qi(e,t,n){e.insertBefore(n,e.childNodes[t]||null)}function Ji(e){return e&&e.nodeType===Node.COMMENT_NODE}function Xi(e){try{Di.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:n,limiter:i,fitInViewport:o,viewportOffsetConfig:r}){Ue(t)&&(t=t()),Ue(i)&&(i=i());const s=function(e){return e&&e.parentNode?e.offsetParent===Di.document.body?null:e.offsetParent:null}(e),a=new Hi(e),l=new Hi(t);let c;const d=o&&function(e){e=Object.assign({top:0,bottom:0,left:0,right:0},e);const t=new Hi(Di.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(i||o){const e=i&&new Hi(i).getVisible();Object.assign(u,{limiterRect:e,viewportRect:d}),c=function(e,t){const{elementRect:n}=t,i=n.getArea(),o=e.map((e=>new io(e,t))).filter((e=>!!e.name));let r=0,s=null;for(const e of o){const{limiterIntersectionArea:t,viewportIntersectionArea:n}=e;if(t===i)return e;const o=n**2+t**2;o>r&&(r=o,s=e)}return s}(n,u)||new io(n[0],u)}else c=new io(n[0],u);return c}function no(e){const{scrollX:t,scrollY:n}=Di.window;return e.clone().moveBy(t,n)}qi._observerInstance=null,qi._elementCallbacks=null;class io{constructor(e,t){const n=e(t.targetRect,t.elementRect,t.viewportRect);if(!n)return;const{left:i,top:o,name:r,config:s}=n;this.name=r,this.config=s,this._positioningFunctionCorrdinates={left:i,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 n=e.getIntersection(t);if(n)return n.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=no(this._rect),this._options.positionedElementAncestor&&function(e,t){const n=no(new Hi(t)),i=zi(t);let o=0,r=0;o-=n.left,r-=n.top,o+=t.scrollLeft,r+=t.scrollTop,o-=i.left,r-=i.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:n,forceScroll:i,viewportOffset:o}){const r=t.clone().moveBy(0,o.bottom),s=t.clone().moveBy(0,-o.top),a=new Hi(e).excludeScrollbarsAndBorders(),l=n&&i,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+=n?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:n,forceScroll:i,ancestorOffset:o=0}){const r=ho(e),s=n&&i;let a,l,c;for(;e!=r.document.body;)l=t(),a=new Hi(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+=n?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 ji(e)?e.startContainer.ownerDocument.defaultView:e.ownerDocument.defaultView}function mo(e){if(ji(e)){let t=e.commonAncestorContainer;return Bi(t)&&(t=t.parentNode),t}return e.parentNode}function fo(e,t){const n=ho(e),i=new Hi(e);if(n===t)return i;{let e=n;for(;e!=t;){const t=e.frameElement,n=new Hi(t).excludeScrollbarsAndBorders();i.moveBy(n.left,n.top),e=e.parent}}return i}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,[n,i])=>(0!=(t&bo[n])&&(t&=~bo[n],e+=i),e)),"")+(t?wo[t]:"")}function yo(e,t){const n="ltr"===t;switch(e){case bo.arrowleft:return n?"left":"right";case bo.arrowright:return n?"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,n=1){if("number"!=typeof n)throw new y("translation-service-quantity-not-a-number",null,{quantity:n});const i=Object.keys(Di.window.CKEDITOR_TRANSLATIONS).length;1===i&&(e=Object.keys(Di.window.CKEDITOR_TRANSLATIONS)[0]);const o=t.id||t.string;if(0===i||!function(e,t){return!!Di.window.CKEDITOR_TRANSLATIONS[e]&&!!Di.window.CKEDITOR_TRANSLATIONS[e].dictionary[t]}(e,o))return 1!==n?t.plural:t.string;const r=Di.window.CKEDITOR_TRANSLATIONS[e].dictionary,s=Di.window.CKEDITOR_TRANSLATIONS[e].getPluralForm||(e=>1===e?0:1),a=r[o];if("string"==typeof a)return a;return a[Number(s(n))]}Di.window.CKEDITOR_TRANSLATIONS||(Di.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 n=!!e.plural?t[0]:1;return function(e,t){return e.replace(/%(\d+)/g,((e,n)=>nthis._items.length||t<0)throw new y("collection-add-item-invalid-index",this);let n=0;for(const i of e){const e=this._getItemIdBeforeAdding(i),o=t+n;this._items.splice(o,0,i),this._itemMap.set(e,i),this.fire("add",i,o),n++}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,n]=this._remove(e);return this.fire("change",{added:[],removed:[t],index:n}),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,n=(n,i,o)=>{const r=t._bindToCollection==this,s=t._bindToInternalToExternalMap.get(i);if(r&&s)this._bindToExternalToInternalMap.set(i,s),this._bindToInternalToExternalMap.set(s,i);else{const n=e(i);if(!n)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(i,n),this._bindToInternalToExternalMap.set(n,i),this.add(n,r);for(let e=0;e{const i=this._bindToExternalToInternalMap.get(t);i&&this.remove(i),this._skippedIndexesFromExternal=this._skippedIndexesFromExternal.reduce(((e,t)=>(nt&&e.push(t),e)),[])}))}_getItemIdBeforeAdding(e){const t=this._idProperty;let n;if(t in e){if(n=e[t],"string"!=typeof n)throw new y("collection-add-invalid-id",this);if(this.get(n))throw new y("collection-add-item-already-exists",this)}else e[t]=n=w();return n}_remove(e){let t,n,i,o=!1;const r=this._idProperty;if("string"==typeof e?(n=e,i=this._itemMap.get(n),o=!i,i&&(t=this._items.indexOf(i))):"number"==typeof e?(t=e,i=this._items[t],o=!i,i&&(n=i[r])):(i=e,n=i[r],t=this._items.indexOf(i),o=-1==t||!this._itemMap.get(n)),o)throw new y("collection-remove-404",this);this._items.splice(t,1),this._itemMap.delete(n);const s=this._bindToInternalToExternalMap.get(i);return this._bindToInternalToExternalMap.delete(i),this._bindToExternalToInternalMap.delete(s),this.fire("remove",i,t),[i,t]}[Symbol.iterator](){return this._items[Symbol.iterator]()}}function Po(e){const t=e.next();return t.done?null:t.value}class Io extends(Mi(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(Mi())}listenTo(e){this._listener.listenTo(e,"keydown",((e,t)=>{this._listener.fire("_keydown:"+ko(t),t)}))}set(e,t,n={}){const i=_o(e),o=n.priority;this._listener.listenTo(this._listener,"_keydown:"+i,((e,n)=>{t(n,(()=>{n.preventDefault(),n.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 ie(e)?new Map(e):function(e){const t=new Map;for(const n in e)t.set(n,e[n]);return t}(e)}function Ro(e,t){let n;function i(...o){i.cancel(),n=setTimeout((()=>e(...o)),t)}return i.cancel=()=>{clearTimeout(n)},i}function No(e,t){return!!(n=e.charAt(t-1))&&1==n.length&&/[\ud800-\udbff]/.test(n)&&function(e){return!!e&&1==e.length&&/[\udc00-\udfff]/.test(e)}(e.charAt(t));var n}function Vo(e,t){return!!(n=e.charAt(t))&&1==n.length&&/[\u0300-\u036f\u1ab0-\u1aff\u1dc0-\u1dff\u20d0-\u20ff\ufe20-\ufe2f]/.test(n);var n}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 n=String(e).matchAll(Do);return Array.from(n).some((e=>e.index{this._renderViewIntoCollectionParent(t,n)})),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 n of this)for(const i of e)n.delegate(i).to(t);this.on("add",((n,i)=>{for(const n of e)i.delegate(n).to(t)})),this.on("remove",((n,i)=>{for(const n of e)i.stopDelegating(n,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 jo=n(3379),zo=n.n(jo),Fo=n(9037),Ho=n.n(Fo),Uo=n(569),Zo=n.n(Uo),Wo=n(8575),$o=n.n(Wo),qo=n(9216),Go=n.n(qo),Ko=n(972),Yo={attributes:{"data-cke":!0}};Yo.setAttributes=$o(),Yo.insert=Zo().bind(null,"head"),Yo.domAPI=Ho(),Yo.insertStyleElement=Go();zo()(Ko.Z,Yo);Ko.Z&&Ko.Z.locals&&Ko.Z.locals;class Qo extends(Mi(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,n)=>{n.locale=e,n.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){ie(e)||(e=[e]);for(const t of e)this._unboundChildren.add(t)}deregisterChild(e){ie(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 n of t.children)fr(n)?yield n:gr(n)&&(yield*e(n))}(this)}static bind(e,t){return{to:(n,i)=>new er({eventNameOrFunction:n,attribute:n,observable:e,emitter:t,callback:i}),if:(n,i,o)=>new tr({observable:e,emitter:t,attribute:n,valueIfTrue:i,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(""),nr(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,n=e.revertData;for(const i in this.attributes){const o=t.getAttribute(i),r=this.attributes[i];n&&(n.attributes[i]=o);const s=br(r)?r[0].ns:null;if(nr(r)){const a=br(r)?r[0].value:r;n&&wr(i)&&a.unshift(o),this._bindToObservable({schema:a,updater:rr(t,i,s),data:e})}else if("style"==i&&"string"!=typeof r[0])this._renderStyleAttribute(r[0],e);else{n&&o&&wr(i)&&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,i,e)}}}_renderStyleAttribute(e,t){const n=t.node;for(const i in e){const o=e[i];nr(o)?this._bindToObservable({schema:[o],updater:sr(n,i),data:t}):n.style[i]=o}}_renderElementChildren(e){const t=e.node,n=e.intoFragment?document.createDocumentFragment():t,i=e.isApplying;let o=0;for(const r of this.children)if(pr(r)){if(!i){r.setParent(t);for(const e of r)n.appendChild(e.element)}}else if(fr(r))i||(r.isRendered||r.render(),n.appendChild(r.element));else if(Pi(r))n.appendChild(r);else if(i){const t={children:[],bindings:[],attributes:{}};e.revertData.children.push(t),r._renderNode({intoFragment:!1,node:n.childNodes[o++],isApplying:!0,revertData:t})}else n.appendChild(r.render());e.intoFragment&&t.appendChild(n)}_setUpListeners(e){if(this.eventListeners)for(const t in this.eventListeners){const n=this.eventListeners[t].map((n=>{const[i,o]=t.split("@");return n.activateDomEventListener(i,o,e)}));e.revertData&&e.revertData.bindings.push(n)}}_bindToObservable({schema:e,updater:t,data:n}){const i=n.revertData;ir(e,t,n);const o=e.filter((e=>!mr(e))).filter((e=>e.observable)).map((i=>i.activateAttributeListener(e,t,n)));i&&i.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 n=e;for(const e in t.attributes){const i=t.attributes[e];null===i?n.removeAttribute(e):n.setAttribute(e,i)}for(let e=0;eir(e,t,n);return this.emitter.listenTo(this.observable,`change:${this.attribute}`,i),()=>{this.emitter.stopListening(this.observable,`change:${this.attribute}`,i)}}}class er extends Xo{constructor(e){super(e),this.eventNameOrFunction=e.eventNameOrFunction}activateDomEventListener(e,t,n){const i=(e,n)=>{t&&!n.target.matches(t)||("function"==typeof this.eventNameOrFunction?this.eventNameOrFunction(n):this.observable.fire(this.eventNameOrFunction,n))};return this.emitter.listenTo(n.node,e,i),()=>{this.emitter.stopListening(n.node,e,i)}}}class tr extends Xo{constructor(e){super(e),this.valueIfTrue=e.valueIfTrue}getValue(e){return!mr(super.getValue(e))&&(this.valueIfTrue||!0)}}function nr(e){return!!e&&(e.value&&(e=e.value),Array.isArray(e)?e.some(nr):e instanceof Xo)}function ir(e,t,{node:n}){const i=function(e,t){return e.map((e=>e instanceof Xo?e.getValue(t):e))}(e,n);let o;o=1==e.length&&e[0]instanceof tr?i[0]:i.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,n){return{set(i){e.setAttributeNS(n,t,i)},remove(){e.removeAttributeNS(n,t)}}}function sr(e,t){return{set(n){e.style[t]=n},remove(){e.style[t]=null}}}function ar(e){return xi(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 n of e.children)gr(n)||fr(n)||Pi(n)?t.push(n):t.push(new Jo(n));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 n in t)e[n]?e[n].push(...t[n]):e[n]=t[n]}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 n=0;for(const i of t.children)hr(e.children[n++],i)}}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=n(3872),vr={attributes:{"data-cke":!0}};vr.setAttributes=$o(),vr.insert=Zo().bind(null,"head"),vr.domAPI=Ho(),vr.insertStyleElement=Go();zo()(_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:n}of Array.from(e.attributes))yr.presentationalAttributeNames.includes(t)&&this.element.setAttribute(t,n);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=n(9377),xr={attributes:{"data-cke":!0}};xr.setAttributes=$o(),xr.insert=Zo().bind(null,"head"),xr.domAPI=Ho(),xr.insertStyleElement=Go();zo()(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,n=w();this.set("ariaChecked",void 0),this.set("ariaLabel",void 0),this.set("ariaLabelledBy",`ck-editor__aria-label_${n}`),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 i={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)),i.on.mousedown=t.to((()=>{this._focusDelayed()})),i.on.mouseup=t.to((()=>{this._focusDelayed.cancel()}))),this.setTemplate(i)}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,n){return e?"string"==typeof e?e:(n&&(n=vo(n)),e instanceof Function?e(t,n):`${t}${n?` (${n})`:""}`):""}}var Cr=n(9547),Sr={attributes:{"data-cke":!0}};Sr.setAttributes=$o(),Sr.insert=Zo().bind(null,"head"),Sr.domAPI=Ho(),Sr.insertStyleElement=Go();zo()(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=n(6601),Mr={attributes:{"data-cke":!0}};Mr.setAttributes=$o(),Mr.insert=Zo().bind(null,"head"),Mr.domAPI=Ho(),Mr.insertStyleElement=Go();zo()(Or.Z,Mr);Or.Z&&Or.Z.locals&&Or.Z.locals;class Rr extends Qo{constructor(e,t){super(e);const n=t&&t.colorDefinitions?t.colorDefinitions:[];this.columns=t&&t.columns?t.columns:5;const i={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})),n.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:i}}),this.on("change:selectedColor",((e,t,n)=>{for(const e of this.items)e.isOn=e.color===n}))}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=n(8874);const Vr=function(e){var t,n,i=[],o=1;if("string"==typeof e)if(Nr[e])i=Nr[e].slice(),n="rgb";else if("transparent"===e)o=0,n="rgb",i=[0,0,0];else if(/^#[A-Fa-f0-9]+$/.test(e)){var r=e.slice(1);o=1,(l=r.length)<=4?(i=[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)):(i=[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)),i[0]||(i[0]=0),i[1]||(i[1]=0),i[2]||(i[2]=0),n="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;n=r=s.replace(/a$/,"");var l="cmyk"===r?4:"gray"===r?1:3;i=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&&i.push(1),o=a||void 0===i[l]?1:i[l],i=i.slice(0,l)}else e.length>10&&/[0-9](?:\s|\/)/.test(e)&&(i=e.match(/([0-9]+)/g).map((function(e){return parseFloat(e)})),n=e.match(/([a-z])/gi).join("").toLowerCase());else isNaN(e)?Array.isArray(e)||e.length?(i=[e[0],e[1],e[2]],n="rgb",o=4===e.length?e[3]:1):e instanceof Object&&(null!=e.r||null!=e.red||null!=e.R?(n="rgb",i=[e.r||e.red||e.R||0,e.g||e.green||e.G||0,e.b||e.blue||e.B||0]):(n="hsl",i=[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)):(n="rgb",i=[e>>>16,(65280&e)>>>8,255&e]);return{space:n,values:i,alpha:o}};var Dr={red:0,orange:60,yellow:120,green:180,blue:240,purple:300};var Lr=n(2085);function Br(e,t){if(!e)return"";const n=jr(e);if(!n)return"";if(n.space===t)return e;if(i=n,!Object.keys(Lr).includes(i.space))return"";var i;const o=Lr[n.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"===n.space?n.hexValue:n.values),t)}function jr(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 zr=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 Zr=function(e){return e?e.slice(0,Hr(e)+1).replace(Ur,""):e};const Wr=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(Wr(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=Zr(e);var n=qr.test(e);return n||Gr.test(e)?Kr(e.slice(2),n?2:8):$r.test(e)?NaN:+e};var Qr=Math.max,Jr=Math.min;const Xr=function(e,t,n){var i,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 n=i,r=o;return i=o=void 0,c=t,s=e.apply(r,n)}function f(e){var n=e-l;return void 0===l||n>=t||n<0||u&&e-c>=r}function g(){var e=zr();if(f(e))return p(e);a=setTimeout(g,function(e){var n=t-(e-l);return u?Jr(n,r-(e-c)):n}(e))}function p(e){return a=void 0,h&&i?m(e):(i=o=void 0,s)}function b(){var e=zr(),n=f(e);if(i=arguments,o=this,l=e,n){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(n)&&(d=!!n.leading,r=(u="maxWait"in n)?Qr(Yr(n.maxWait)||0,t):r,h="trailing"in n?!!n.trailing:h),b.cancel=function(){void 0!==a&&clearTimeout(a),c=0,i=l=o=a=void 0},b.flush=function(){return void 0===a?s:p(zr())},b};var es=n(3320),ts={attributes:{"data-cke":!0}};ts.setAttributes=$o(),ts.insert=Zo().bind(null,"head"),ts.domAPI=Ho(),ts.insertStyleElement=Go();zo()(es.Z,ts);es.Z&&es.Z.locals&&es.Z.locals;class ns 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 is=n(7546),os={attributes:{"data-cke":!0}};os.setAttributes=$o(),os.insert=Zo().bind(null,"head"),os.domAPI=Ho(),os.insertStyleElement=Go();zo()(is.Z,os);is.Z&&is.Z.locals&&is.Z.locals;class rs extends Qo{constructor(e,t){super(e);const n=`ck-labeled-field-view-${w()}`,i=`ck-labeled-field-view-status-${w()}`;this.fieldView=t(this,n,i),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(n),this.statusView=this._createStatusView(i),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 ns(this.locale);return t.for=e,t.bind("text").to(this,"label"),t}_createStatusView(e){const t=new Qo(this.locale),n=this.bindTemplate;return t.setTemplate({tag:"div",attributes:{class:["ck","ck-labeled-field-view__status",n.if("errorText","ck-labeled-field-view__status_error"),n.if("_statusText","ck-hidden",(e=>!e))],id:e,role:n.if("errorText","alert")},children:[{text:n.to("_statusText")}]}),t}focus(){this.fieldView.focus()}}var ss=n(7138),as={attributes:{"data-cke":!0}};as.setAttributes=$o(),as.insert=Zo().bind(null,"head"),as.domAPI=Ho(),as.insertStyleElement=Go();zo()(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,n)=>{this._setDomElementValue(n),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=n(5457),hs={attributes:{"data-cke":!0}};hs.setAttributes=$o(),hs.insert=Zo().bind(null,"head"),hs.domAPI=Ho(),hs.insertStyleElement=Go();zo()(us.Z,hs);us.Z&&us.Z.locals&&us.Z.locals;class ms extends Qo{constructor(e,t,n){super(e);const i=this.bindTemplate;this.buttonView=t,this.panelView=n,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",i.to("class"),i.if("isEnabled","ck-disabled",(e=>!e))],id:i.to("id"),"aria-describedby":i.to("ariaDescribedById")},children:[t,n]}),t.extendTemplate({attributes:{class:["ck-dropdown__button"],"data-cke-tooltip-disabled":i.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,n)=>{n&&("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:n,southWest:i,northEast:o,northWest:r,southMiddleEast:s,southMiddleWest:a,northMiddleEast:l,northMiddleWest:c}=ms.defaultPanelPositions;return"rtl"!==this.locale.uiLanguageDirection?[n,i,s,a,e,o,r,l,c,t]:[i,n,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 n=e.actions[t];"string"==typeof n&&(n=[n]);for(const i of n)e.keystrokeHandler.set(i,((e,n)=>{this[t](),n()}))}}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,n)=>{const i=t.element===this.focusTracker.focusedElement;return i&&(e=n),i})),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,n=this.focusables.length;if(!n)return null;if(null===t)return this[1===e?"first":"last"];let i=(t+n+e)%n;do{const t=this.focusables.get(i);if(bs(t))return t;i=(i+n+e)%n}while(i!==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=[],n=[]){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 n)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=[],n=[]){const i=this,o=this._context;!function e(t,n=new Set){t.forEach((t=>{a(t)&&(n.has(t)||(n.add(t),t.pluginName&&!i._availablePlugins.has(t.pluginName)&&i._availablePlugins.set(t.pluginName,t),t.requires&&e(t.requires,n)))}))}(e),u(e);const r=[...function e(t,n=new Set){return t.map((e=>a(e)?e:i._availablePlugins.get(e))).reduce(((t,i)=>n.has(i)?t:(n.add(i),i.requires&&(u(i.requires,i),e(i.requires,n).forEach((e=>t.add(e)))),t.add(i))),new Set)}(e.filter((e=>!c(e,t))))];!function(e,t){for(const n of t){if("function"!=typeof n)throw new y("plugincollection-replace-plugin-invalid-type",null,{pluginItem:n});const t=n.pluginName;if(!t)throw new y("plugincollection-replace-plugin-missing-name",null,{pluginItem:n});if(n.requires&&n.requires.length)throw new y("plugincollection-plugin-for-replacing-cannot-have-dependencies",null,{pluginName:t});const o=i._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(i._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,n),i._availablePlugins.set(t,n)}}(r,n);const s=function(e){return e.map((e=>{let t=i._contextPlugins.get(e);return t=t||new e(o),i._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,n=null){e.map((e=>a(e)?e:i._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,n),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,n),function(e,n){if(!n)return;if(!c(e,t))return;throw new y("plugincollection-required",o,{plugin:d(e),requiredBy:d(n)})}(e,n)}))}function h(e,t){return e.reduce(((e,n)=>n[t]?i._contextPlugins.has(n)?e:e.then(n[t].bind(n)):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 n=e.pluginName;if(n){if(this._plugins.has(n))throw new y("plugincollection-plugin-name-conflict",null,{pluginName:n,plugin1:this._plugins.get(n).constructor,plugin2:e});this._plugins.set(n,t)}}}class Ss{constructor(e){this._contextOwner=null,this.config=new Ci(e,this.constructor.defaultConfig);const t=this.constructor.builtinPlugins;this.config.define("plugins",t),this.plugins=new Cs(this,t);const n=this.config.get("language")||{};this.locale=new So({uiLanguage:"string"==typeof n?n:n.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 n of e.concat(t)){if("function"!=typeof n)throw new y("context-initplugins-constructor-only",null,{Plugin:n});if(!0!==n.isContextPlugin)throw new y("context-initplugins-invalid-plugin",null,{Plugin:n})}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 n=new this(e);t(n.initPlugins().then((()=>n)))}))}}class Ts extends(G()){constructor(e){super(),this.context=e}destroy(){this.stopListening()}static get isContextPlugin(){return!0}}var Ps=n(5169),Is={attributes:{"data-cke":!0}};Is.setAttributes=$o(),Is.insert=Zo().bind(null,"head"),Is.domAPI=Ho(),Is.insertStyleElement=Go();zo()(Ps.Z,Is);Ps.Z&&Ps.Z.locals&&Ps.Z.locals;const Os=new WeakMap;function Ms({view:e,element:t,text:n,isDirectHost:i=!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:n,isDirectHost:i,keepOnFocus:o,hostElement:i?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 n=Os.get(e),i=[];let o=!1;for(const[e,r]of n)r.isDirectHost&&(i.push(e),Vs(t,e,r)&&(o=!0));for(const[e,r]of n){if(r.isDirectHost)continue;const n=Ds(e);n&&(i.includes(n)||(r.hostElement=n,Vs(t,e,r)&&(o=!0)))}return o}function Vs(e,t,n){const{text:i,isDirectHost:o,hostElement:r}=n;let s=!1;r.getAttribute("data-placeholder")!==i&&(e.setAttribute("data-placeholder",i,r),s=!0);return(o||1==t.childCount)&&function(e,t){if(!e.isAttached())return!1;const n=Array.from(e.getChildren()).some((e=>!e.is("uiElement")));if(n)return!1;const i=e.document,o=i.selection.anchor;return!(i.isComposing&&o&&o.parent===e||!t&&i.isFocused&&(!o||o.parent===e))}(r,n.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 Ai(e,4)};class js 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 n=e.includeSelf?this:this.parent;for(;n;)t[e.parentFirst?"push":"unshift"](n),n=n.parent;return t}getCommonAncestor(e,t={}){const n=this.getAncestors(t),i=e.getAncestors(t);let o=0;for(;n[o]==i[o]&&n[o];)o++;return 0===o?null:n[o-1]}isBefore(e){if(this==e)return!1;if(this.root!==e.root)return!1;const t=this.getPath(),n=e.getPath(),i=ne(t,n);switch(i){case"prefix":return!0;case"extension":return!1;default:return t[i]e.data.length)throw new y("view-textproxy-wrong-offsetintext",this);if(n<0||t+n>e.data.length)throw new y("view-textproxy-wrong-length",this);this.data=e.data.substring(t,t+n),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 n=e.includeSelf?this.textNode:this.parent;for(;null!==n;)t[e.parentFirst?"push":"unshift"](n),n=n.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 n=Us(t,e);if(n)return{element:t,pattern:e,match:n}}return null}matchAll(...e){const t=[];for(const n of e)for(const e of this._patterns){const i=Us(n,e);i&&t.push({element:n,pattern:e,match:i})}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 n={};return t.name&&(n.name=function(e,t){if(e instanceof RegExp)return!!t.match(e);return e===t}(t.name,e.name),!n.name)||t.attributes&&(n.attributes=function(e,t){const n=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)):(n.delete("style"),n.delete("class"));return Zs(e,n,(e=>t.getAttribute(e)))}(t.attributes,e),!n.attributes)||t.classes&&(n.classes=function(e,t){return Zs(e,t.getClassNames(),(()=>{}))}(t.classes,e),!n.classes)||t.styles&&(n.styles=function(e,t){return Zs(e,t.getStyleNames(!0),(e=>t.getStyle(e)))}(t.styles,e),!n.styles)?null:n}function Zs(e,t,n){const i=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(i.forEach((([e,t])=>{o.forEach((i=>{(function(e,t){return!0===e||e===t||e instanceof RegExp&&t.match(e)})(e,i)&&function(e,t,n){if(!0===e)return!0;const i=n(t);return e===i||e instanceof RegExp&&!!String(i).match(e)}(t,i,n)&&r.push(i)}))})),i.length&&!(r.lengtho?0:o+t),(n=n>o?o:n)<0&&(n+=o),o=t>n?0:n-t>>>0,t>>>=0;for(var r=Array(o);++i0){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,n){if(!F(n))return!1;var i=typeof t;return!!("number"==i?dn(n)&&Wt(t,n.length):"string"==i&&t in n)&&Ie(n[t],e)};const Ra=function(e){return Oa((function(t,n){var i=-1,o=n.length,r=o>1?n[o-1]:void 0,s=o>2?n[2]:void 0;for(r=e.length>3&&"function"==typeof r?(o--,r):void 0,s&&Ma(n[0],n[1],s)&&(r=o<3?void 0:r,o=1),t=Object(t);++it===e));return Array.isArray(t)}set(e,t){if(F(e))for(const[t,n]of Object.entries(e))this._styleProcessor.toNormalizedForm(t,n,this._styles);else this._styleProcessor.toNormalizedForm(e,t,this._styles)}remove(e){const t=ja(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 n of t)e.push(...this._styleProcessor.getReducedForm(n,this._styles));return e}_cleanEmptyObjectsOnPath(e){const t=e.split(".");if(!(t.length>1))return;const n=t.splice(0,t.length-1).join("."),i=fa(this._styles,n);if(!i)return;!Array.from(Object.keys(i)).length&&this.remove(n)}}class Ba{constructor(){this._normalizers=new Map,this._extractors=new Map,this._reducers=new Map,this._consumables=new Map}toNormalizedForm(e,t,n){if(F(t))za(n,ja(e),t);else if(this._normalizers.has(e)){const i=this._normalizers.get(e),{path:o,value:r}=i(t);za(n,o,r)}else za(n,e,t)}getNormalized(e,t){if(!e)return Na({},t);if(void 0!==t[e])return t[e];if(this._extractors.has(e)){const n=this._extractors.get(e);if("string"==typeof n)return fa(t,n);const i=n(e,t);if(i)return i}return fa(t,ja(e))}getReducedForm(e,t){const n=this.getNormalized(e,t);if(void 0===n)return[];if(this._reducers.has(e)){return this._reducers.get(e)(n)}return[[e,n]]}getStyleNames(e){const t=Array.from(this._consumables.keys()).filter((t=>{const n=this.getNormalized(t,e);return n&&"object"==typeof n?Object.keys(n).length:n})),n=new Set([...t,...Object.keys(e)]);return Array.from(n.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 n of t)this._mapStyleNames(n,[e])}_mapStyleNames(e,t){this._consumables.has(e)||this._consumables.set(e,[]),this._consumables.get(e).push(...t)}}function ja(e){return e.replace("-",".")}function za(e,t,n){let i=n;F(n)&&(i=Na({},fa(e,t),n)),Da(e,t,i)}class Fa extends js{constructor(e,t,n,i){if(super(e),this._unsafeAttributesToRender=[],this._customProperties=new Map,this.name=t,this._attrs=function(e){const t=Mo(e);for(const[e,n]of t)null===n?t.delete(e):"string"!=typeof n&&t.set(e,String(n));return t}(n),this._children=[],i&&this._insertChild(0,i),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,n]of this._attrs)if(!e._attrs.has(t)||e._attrs.get(t)!==n)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 n=this.parent;for(;n&&!n.is("documentFragment");){if(t.match(n))return n;n=n.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(),n=Array.from(this._attrs).map((e=>`${e[0]}="${e[1]}"`)).sort().join(" ");return this.name+(""==e?"":` class="${e}"`)+(t?` style="${t}"`:"")+(""==n?"":` ${n}`)}shouldRenderUnsafeAttribute(e){return this._unsafeAttributesToRender.includes(e)}_clone(e=!1){const t=[];if(e)for(const n of this.getChildren())t.push(n._clone(e));const n=new this.constructor(this.document,this.name,this._attrs,t);return n._classes=new Set(this._classes),n._styles.set(this._styles.getNormalized()),n._customProperties=new Map(this._customProperties),n.getFillerOffset=this.getFillerOffset,n._unsafeAttributesToRender=this._unsafeAttributesToRender,n}_appendChild(e){return this._insertChild(this.childCount,e)}_insertChild(e,t){this._fireChange("children",this);let n=0;const i=function(e,t){if("string"==typeof t)return[new zs(e,t)];ie(t)||(t=[t]);return Array.from(t).map((t=>"string"==typeof t?new zs(e,t):t instanceof Fs?new zs(e,t.data):t))}(this.document,t);for(const t of i)null!==t.parent&&t._remove(),t.parent=this,t.document=this.document,this._children.splice(e,0,t),e++,n++;return n}_removeChildren(e,t=1){this._fireChange("children",this);for(let n=e;n0&&(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 n=t.split(/\s+/);e.clear(),n.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,n,i){super(e,t,n,i),this.getFillerOffset=Za}}function Za(){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 Wa extends(G(Ua)){constructor(e,t,n,i){super(e,t,n,i),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()}}Wa.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 Wa{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,n;do{n=this.position,t=this.next()}while(!t.done&&e(t.value));t.done||(this._position=n)}next(){return"forward"==this.direction?this._next():this._previous()}_next(){let e=this.position.clone();const t=this.position,n=e.parent;if(null===n.parent&&e.offset===n.childCount)return{done:!0,value:void 0};if(n===this._boundaryEndParent&&e.offset==this.boundaries.end.offset)return{done:!0,value:void 0};let i;if(n instanceof zs){if(e.isAtEnd)return this._position=Ka._createAfter(n),this._next();i=n.data[e.offset]}else i=n.getChild(e.offset);if(i 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(i,0);return this._position=e,this._formatReturnValue("elementStart",i,t,e,1)}if(i instanceof zs){if(this.singleCharacters)return e=new Ka(i,0),this._position=e,this._next();let n,o=i.data.length;return i==this._boundaryEndParent?(o=this.boundaries.end.offset,n=new Fs(i,0,o),e=Ka._createAfter(n)):(n=new Fs(i,0,i.data.length),e.offset++),this._position=e,this._formatReturnValue("text",n,t,e,o)}if("string"==typeof i){let i;if(this.singleCharacters)i=1;else{i=(n===this._boundaryEndParent?this.boundaries.end.offset:n.data.length)-e.offset}const o=new Fs(n,e.offset,i);return e.offset+=i,this._position=e,this._formatReturnValue("text",o,t,e,i)}return e=Ka._createAfter(n),this._position=e,this.ignoreElementEnd?this._next():this._formatReturnValue("elementEnd",n,t,e)}_previous(){let e=this.position.clone();const t=this.position,n=e.parent;if(null===n.parent&&0===e.offset)return{done:!0,value:void 0};if(n==this._boundaryStartParent&&e.offset==this.boundaries.start.offset)return{done:!0,value:void 0};let i;if(n instanceof zs){if(e.isAtStart)return this._position=Ka._createBefore(n),this._previous();i=n.data[e.offset-1]}else i=n.getChild(e.offset-1);if(i instanceof Fa)return this.shallow?(e.offset--,this._position=e,this._formatReturnValue("elementStart",i,t,e,1)):(e=new Ka(i,i.childCount),this._position=e,this.ignoreElementEnd?this._previous():this._formatReturnValue("elementEnd",i,t,e));if(i instanceof zs){if(this.singleCharacters)return e=new Ka(i,i.data.length),this._position=e,this._previous();let n,o=i.data.length;if(i==this._boundaryStartParent){const t=this.boundaries.start.offset;n=new Fs(i,t,i.data.length-t),o=n.data.length,e=Ka._createBefore(n)}else n=new Fs(i,0,i.data.length),e.offset--;return this._position=e,this._formatReturnValue("text",n,t,e,o)}if("string"==typeof i){let i;if(this.singleCharacters)i=1;else{const t=n===this._boundaryStartParent?this.boundaries.start.offset:0;i=e.offset-t}e.offset-=i;const o=new Fs(n,e.offset,i);return this._position=e,this._formatReturnValue("text",o,t,e,i)}return e=Ka._createBefore(n),this._position=e,this._formatReturnValue("elementStart",n,t,e,1)}_formatReturnValue(e,t,n,i,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)?n=Ka._createAfter(t.textNode):(i=Ka._createAfter(t.textNode),this._position=i)),0===t.offsetInText&&("backward"!=this.direction||this.boundaries&&this.boundaries.start.isEqual(this.position)?n=Ka._createBefore(t.textNode):(i=Ka._createBefore(t.textNode),this._position=i))),{done:!1,value:{type:e,item:t,previousPosition:n,nextPosition:i,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 Wa);){if(!e.parent)return null;e=e.parent}return e}getShiftedBy(e){const t=Ka._createAt(this),n=t.offset+e;return t.offset=n<0?0:n,t}getLastMatchingPosition(e,t={}){t.startPosition=this;const n=new Ga(t);return n.skip(e),n.position}getAncestors(){return this.parent.is("documentFragment")?[this.parent]:this.parent.getAncestors({includeSelf:!0})}getCommonAncestor(e){const t=this.getAncestors(),n=e.getAncestors();let i=0;for(;t[i]==n[i]&&t[i];)i++;return 0===i?null:t[i-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():[],n=e.parent.is("node")?e.parent.getPath():[];t.push(this.offset),n.push(e.offset);const i=ne(t,n);switch(i){case"prefix":return"before";case"extension":return"after";default:return t[i]0?new this(n,i):new this(i,n)}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 n=!1;for(const i of e._ranges)if(t.isEqual(i)){n=!0;break}if(!n)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 n=!1;for(let i of e.getRanges())if(i=i.getTrimmed(),t.start.isEqual(i.start)&&t.end.isEqual(i.end)){n=!0;break}if(!n)return!1}return!0}getSelectedElement(){return 1!==this.rangeCount?null:this.getFirstRange().getContainedElement()}setTo(...e){let[t,n,i]=e;if("object"==typeof n&&(i=n,n=void 0),null===t)this._setRanges([]),this._setFakeOptions(i);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],i&&i.backward),this._setFakeOptions(i);else if(t instanceof Ka)this._setRanges([new Ya(t)]),this._setFakeOptions(i);else if(t instanceof js){const e=!!i&&!!i.backward;let o;if(void 0===n)throw new y("view-selection-setto-required-second-parameter",this);o="in"==n?Ya._createIn(t):"on"==n?Ya._createOn(t):new Ya(Ka._createAt(t,n)),this._setRanges([o],e),this._setFakeOptions(i)}else{if(!ie(t))throw new y("view-selection-setto-not-selectable",this);this._setRanges(t,i&&i.backward),this._setFakeOptions(i)}this.fire("change")}setFocus(e,t){if(null===this.anchor)throw new y("view-selection-setfocus-no-ranges",this);const n=Ka._createAt(e,t);if("same"==n.compareWith(this.focus))return;const i=this.anchor;this._ranges.pop(),"before"==n.compareWith(i)?this._addRange(new Ya(n,i),!0):this._addRange(new Ya(i,n)),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,n){super(e,t),this.startRange=n,this._eventPhase="none",this._currentTarget=null}get eventPhase(){return this._eventPhase}get currentTarget(){return this._currentTarget}}const tl=Symbol("bubbling contexts");function nl(e){return class extends e{fire(e,...t){try{const n=e instanceof p?e:new p(this,e),i=sl(this);if(!i.size)return;if(il(n,"capturing",this),ol(i,"$capture",n,...t))return n.return;const o=n.startRange||this.selection.getFirstRange(),r=o?o.getContainedElement():null,s=!!r&&Boolean(rl(i,r));let a=r||function(e){if(!e)return null;const t=e.start.parent,n=e.end.parent,i=t.getPath(),o=n.getPath();return i.length>o.length?t:n}(o);if(il(n,"atTarget",a),!s){if(ol(i,"$text",n,...t))return n.return;il(n,"bubbling",a)}for(;a;){if(a.is("rootElement")){if(ol(i,"$root",n,...t))return n.return}else if(a.is("element")&&ol(i,a.name,n,...t))return n.return;if(ol(i,a,n,...t))return n.return;a=a.parent,il(n,"bubbling",a)}return il(n,"bubbling",this),ol(i,"$document",n,...t),n.return}catch(e){y.rethrowUnexpectedError(e,this)}}_addEventListener(e,t,n){const i=Eo(n.context||"$document"),o=sl(this);for(const r of i){let i=o.get(r);i||(i=new(R()),o.set(r,i)),this.listenTo(i,e,t,n)}}_removeEventListener(e,t){const n=sl(this);for(const i of n.values())this.stopListening(i,e,t)}}}{const e=nl(Object);["fire","_addEventListener","_removeEventListener"].forEach((t=>{nl[t]=e.prototype[t]}))}function il(e,t,n){e instanceof el&&(e._eventPhase=t,e._currentTarget=n)}function ol(e,t,n,...i){const o="string"==typeof t?e.get(t):rl(e,t);return!!o&&(o.fire(n,...i),n.stop.called)}function rl(e,t){for(const[n,i]of e)if("function"==typeof n&&n(t))return i;return null}function sl(e){return e[tl]||(e[tl]=new Map),e[tl]}class al extends(nl(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 n of this._postFixers)if(t=n(e),t)break}while(t)}}class ll extends Fa{constructor(e,t,n,i){super(e,t,n,i),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,n,i){super(e,t,n,i),this.getFillerOffset=hl}_insertChild(e,t){if(t&&(t instanceof js||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,n,i){super(e,t,n,i),this.getFillerOffset=gl}_insertChild(e,t){if(t&&(t instanceof js||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,n)=>function(e,t,n){if(t.keyCode==bo.arrowright){const e=t.domTarget.ownerDocument.defaultView.getSelection(),i=1==e.rangeCount&&e.getRangeAt(0).collapsed;if(i||t.shiftKey){const t=e.focusNode,o=e.focusOffset,r=n.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=n.viewPositionToDom(a);i?e.collapse(t.parent,t.offset):e.extend(t.parent,t.offset)}}}}(0,n,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,n,i){super(e,t,n,i),this.getFillerOffset=bl}_insertChild(e,t){if(t&&(t instanceof js||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 n=0;const i=function(e,t){if("string"==typeof t)return[new zs(e,t)];ie(t)||(t=[t]);return Array.from(t).map((t=>"string"==typeof t?new zs(e,t):t instanceof Fs?new zs(e,t.data):t))}(this.document,t);for(const t of i)null!==t.parent&&t._remove(),t.parent=this,this._children.splice(e,0,t),e++,n++;return n}_removeChildren(e,t=1){this._fireChange("children",this);for(let n=e;n{const n=e[e.length-1],i=!t.is("uiElement");return n&&n.breakAttributes==i?n.nodes.push(t):e.push({breakAttributes:i,nodes:[t]}),e}),[]);let i=null,o=e;for(const{nodes:e,breakAttributes:t}of n){const n=this._insertNodes(o,e,t);i||(i=n.start),o=n.end}return i?new Ya(i,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:n,end:i}=this._breakAttributesRange(t,!0),o=n.parent,r=i.offset-n.offset,s=o._removeChildren(n.offset,r);for(const e of s)this._removeFromClonedElementsGroup(e);const a=this.mergeAttributes(n);return t.start=a,t.end=a.clone(),new wl(this.document,s)}clear(e,t){Tl(e,this.document);const n=e.getWalker({direction:"backward",ignoreElementEnd:!0});for(const i of n){const n=i.item;let o;if(n.is("element")&&t.isSimilar(n))o=Ya._createOn(n);else if(!i.nextPosition.isAfter(e.start)&&n.is("$textProxy")){const e=n.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 n;if(t.isAfter(e.end)){const i=(t=this._breakAttributes(t,!0)).parent,o=i.childCount;e=this._breakAttributesRange(e,!0),n=this.remove(e),t.offset+=i.childCount-o}else n=this.remove(e);return this.insert(t,n)}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 i=e.start;i.parent.is("element")&&(n=i.parent,!Array.from(n.getChildren()).some((e=>!e.is("uiElement"))))&&(i=i.getLastMatchingPosition((e=>e.item.is("uiElement")))),i=this._wrapPosition(i,t);const o=this.document.selection;return o.isCollapsed&&o.getFirstPosition().isEqual(e.start)&&this.setSelection(i),new Ya(i)}return this._wrapRange(e,t);var n}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:n,end:i}=this._breakAttributesRange(e,!0),o=n.parent,r=this._unwrapChildren(o,n.offset,i.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 n=new Ua(this.document,e,t.getAttributes());return this.insert(Ka._createAfter(t),n),this.move(Ya._createIn(t),Ka._createAt(n,0)),this.remove(Ya._createOn(t)),n}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,n){let i,o;if(i=n?_l(e):e.parent.is("$text")?e.parent.parent:e.parent,!i)throw new y("view-writer-invalid-position-container",this.document);o=n?this._breakAttributes(e,!0):e.parent.is("$text")?Al(e):e;const r=i._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,n,i){let o=t;const r=[];for(;o!1,e.parent._insertChild(e.offset,n);const i=new Ya(e,e.getShiftedBy(1));this.wrap(i,t);const o=new Ka(n.parent,n.index);n._remove();const r=o.nodeBefore,s=o.nodeAfter;return r instanceof zs&&s instanceof zs?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 n of e.getAttributeKeys())if("class"!==n&&"style"!==n&&t.hasAttribute(n)&&t.getAttribute(n)!==e.getAttribute(n))return!1;for(const n of e.getStyleNames())if(t.hasStyle(n)&&t.getStyle(n)!==e.getStyle(n))return!1;for(const n of e.getAttributeKeys())"class"!==n&&"style"!==n&&(t.hasAttribute(n)||this.setAttribute(n,e.getAttribute(n),t));for(const n of e.getStyleNames())t.hasStyle(n)||this.setStyle(n,e.getStyle(n),t);for(const n of e.getClassNames())t.hasClass(n)||this.addClass(n,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 n of e.getAttributeKeys())if("class"!==n&&"style"!==n&&(!t.hasAttribute(n)||t.getAttribute(n)!==e.getAttribute(n)))return!1;if(!t.hasClass(...e.getClassNames()))return!1;for(const n of e.getStyleNames())if(!t.hasStyle(n)||t.getStyle(n)!==e.getStyle(n))return!1;for(const n of e.getAttributeKeys())"class"!==n&&"style"!==n&&this.removeAttribute(n,t);return this.removeClass(Array.from(e.getClassNames()),t),this.removeStyle(Array.from(e.getStyleNames()),t),!0}_breakAttributesRange(e,t=!1){const n=e.start,i=e.end;if(Tl(e,this.document),e.isCollapsed){const n=this._breakAttributes(e.start,t);return new Ya(n,n)}const o=this._breakAttributes(i,t),r=o.parent.childCount,s=this._breakAttributes(n,t);return o.offset+=o.parent.childCount-r,new Ya(s,o)}_breakAttributes(e,t=!1){const n=e.offset,i=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&&i.is("$text")&&Sl(i.parent))return e.clone();if(Sl(i))return e.clone();if(i.is("$text"))return this._breakAttributes(Al(e),t);if(n==i.childCount){const e=new Ka(i.parent,i.index+1);return this._breakAttributes(e,t)}if(0===n){const e=new Ka(i.parent,i.index);return this._breakAttributes(e,t)}{const e=i.index+1,o=i._clone();i.parent._insertChild(e,o),this._addToClonedElementsGroup(o);const r=i.childCount-n,s=i._removeChildren(n,r);o._appendChild(s);const a=new Ka(i.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 n=this._cloneGroups.get(t);n||(n=new Set,this._cloneGroups.set(t,n)),n.add(e),e._clonesGroup=n}_removeFromClonedElementsGroup(e){if(e.is("element"))for(const t of e.getChildren())this._removeFromClonedElementsGroup(t);const t=e.id;if(!t)return;const n=this._cloneGroups.get(t);n&&n.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()n instanceof e)))throw new y("view-writer-insert-invalid-node-type",t);n.is("$text")||Cl(n.getChildren(),t)}}function Sl(e){return e&&(e.is("containerElement")||e.is("documentFragment"))}function Tl(e,t){const n=_l(e.start),i=_l(e.end);if(!n||!i||n!==i)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 Bi(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,n=e.getRangeAt(0).startOffset;Vl(t)&&n<=Rl&&e.collapse(t,0)}}}var jl=n(1237),zl={attributes:{"data-cke":!0}};zl.setAttributes=$o(),zl.insert=Zo().bind(null,"head"),zl.domAPI=Ho(),zl.insertStyleElement=Go();zo()(jl.Z,zl);jl.Z&&jl.Z.locals&&jl.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),n=t.parent.ownerDocument;Vl(t.parent)?this._inlineFiller=t.parent:this._inlineFiller=Hl(n,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),n=Array.from(this.domConverter.viewChildrenToDom(e,{withChildren:!1})),i=this._diffNodeLists(t,n),o=this._findUpdateActions(i,t,n,Ul);if(-1!==o.indexOf("update")){const i={equal:0,insert:0,delete:0};for(const r of o)if("update"===r){const o=i.equal+i.insert,r=i.equal+i.delete,s=e.getChild(o);!s||s.is("uiElement")||s.is("rawElement")||this._updateElementMappings(s,t[r]),oo(n[o]),i.equal++}else i[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&&Bi(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,n=e.offset;if(!this.domConverter.mapViewToDom(t.root))return!1;if(!t.is("element"))return!1;if(!function(e){if("false"==e.getAttribute("contenteditable"))return!1;const t=e.findAncestor((e=>e.hasAttribute("contenteditable")));return!t||"true"==t.getAttribute("contenteditable")}(t))return!1;if(n===t.getFillerOffset())return!1;const i=e.nodeBefore,o=e.nodeAfter;return!(i instanceof zs||o instanceof zs)&&(!c.isAndroid||!i&&!o)}_updateText(e,t){const n=this.domConverter.findCorrespondingDomText(e);let i=this.domConverter.viewToDom(e).data;const o=t.inlineFillerPosition;o&&o.parent==e.parent&&o.offset==e.index&&(i=Nl+i),$l(n,i)}_updateAttrs(e){const t=this.domConverter.mapViewToDom(e);if(!t)return;const n=Array.from(t.attributes).map((e=>e.name)),i=e.getAttributeKeys();for(const n of i)this.domConverter.setDomElementAttribute(t,n,e.getAttribute(n),e);for(const i of n)e.hasAttribute(i)||this.domConverter.removeDomElementAttribute(t,i)}_updateChildren(e,t){const n=this.domConverter.mapViewToDom(e);if(!n)return;if(c.isAndroid){let e=null;for(const t of Array.from(n.childNodes)){if(e&&Bi(e)&&Bi(t)){n.normalize();break}e=t}}const i=t.inlineFillerPosition,o=n.childNodes,r=Array.from(this.domConverter.viewChildrenToDom(e,{bind:!0}));i&&i.parent===e&&Hl(n.ownerDocument,r,i.offset);const s=this._diffNodeLists(o,r),a=this._findUpdateActions(s,o,r,Zl);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?(Qi(n,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 n=Array.from(e);if(0==n.length||!t)return n;const i=n[n.length-1];i==t&&n.pop();return n}(e,this._fakeSelectionContainer),f(e,t,Wl.bind(null,this.domConverter))}_findUpdateActions(e,t,n,i){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(n[a.equal+a.insert]):"delete"===l?r.push(t[a.equal+a.delete]):(o=o.concat(f(r,s,i).map((e=>"equal"===e?"update":e))),o.push("equal"),r=[],s=[]),a[l]++;return o.concat(f(r,s,i).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 n=this._fakeSelectionContainer;if(this.domConverter.bindFakeSelection(n,this.selection),!this._fakeSelectionNeedsUpdate(e))return;n.parentElement&&n.parentElement==e||e.appendChild(n),n.textContent=this.selection.fakeSelectionLabel||" ";const i=t.getSelection(),o=t.createRange();i.removeAllRanges(),o.selectNodeContents(n),i.addRange(o)}_updateDomSelection(e){const t=e.ownerDocument.defaultView.getSelection();if(!this._domSelectionNeedsUpdate(t))return;const n=this.domConverter.viewPositionToDom(this.selection.anchor),i=this.domConverter.viewPositionToDom(this.selection.focus);t.collapse(n.parent,n.offset),t.extend(i.parent,i.offset),c.isGecko&&function(e,t){const n=e.parent;if(n.nodeType!=Node.ELEMENT_NODE||e.offset!=n.childNodes.length-1)return;const i=n.childNodes[e.offset];i&&"BR"==i.tagName&&t.addRange(t.getRangeAt(0))}(i,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,n=e.ownerDocument.getSelection();return!t||t.parentElement!==e||(n.anchorNode!==t&&!t.contains(n.anchorNode)||t.textContent!==this.selection.fakeSelectionLabel)}_removeDomSelection(){for(const e of this.domDocuments){const t=e.getSelection();if(t.rangeCount){const n=e.activeElement,i=this.domConverter.mapDomToView(n);n&&i&&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,n){const i=t instanceof Array?t:t.childNodes,o=i[n];if(Bi(o))return o.data=Nl+o.data,o;{const o=e.createTextNode(Nl);return Array.isArray(t)?i.splice(n,0,o):Qi(t,n,o),o}}function Ul(e,t){return Pi(e)&&Pi(t)&&!Bi(e)&&!Bi(t)&&!Ji(e)&&!Ji(t)&&e.tagName.toLowerCase()===t.tagName.toLowerCase()}function Zl(e,t){return Pi(e)&&Pi(t)&&Bi(e)&&Bi(t)}function Wl(e,t,n){return t===n||(Bi(t)&&Bi(n)?t.data===n.data:!(!e.isBlockFiller(t)||!e.isBlockFiller(n)))}function $l(e,t){const n=e.data;if(n==t)return;const i=u(n,t);for(const t of i)"insert"===t.type?e.insertData(t.index,t.values.join("")):e.deleteData(t.index,t.howMany)}const ql=Ml(Di.document),Gl=Il(Di.document),Kl=Ol(Di.document),Yl="data-ck-unsafe-attribute-",Ql="data-ck-unsafe-element";class Jl{constructor(e,{blockFillerMode:t,renderingMode:n="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=n,this.blockFillerMode=t||("editing"===n?"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?Di.document:Di.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,n){return"data"===this.renderingMode||!(e=e.toLowerCase()).startsWith("on")&&(("srcdoc"!==e||!t.match(/\bon\S+\s*=|javascript:|<\s*\/*script/i))&&("img"===n&&("src"===e||"srcset"===e)||("source"===n&&"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 n=(new DOMParser).parseFromString(t,"text/html"),i=n.createDocumentFragment(),o=n.body.childNodes;for(;o.length>0;)i.appendChild(o[0]);const r=n.createTreeWalker(i,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(i)}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 n;if(e.is("documentFragment"))n=this._domDocument.createDocumentFragment(),t.bind&&this.bindDocumentFragments(n,e);else{if(e.is("uiElement"))return n="$comment"===e.name?this._domDocument.createComment(e.getCustomProperty("$rawContent")):e.render(this._domDocument,this),t.bind&&this.bindElements(n,e),n;this._shouldRenameElement(e.name)?(tc(e.name),n=this._createReplacementDomElement(e.name)):n=e.hasAttribute("xmlns")?this._domDocument.createElementNS(e.getAttribute("xmlns"),e.name):this._domDocument.createElement(e.name),e.is("rawElement")&&e.render(n,this),t.bind&&this.bindElements(n,e);for(const t of e.getAttributeKeys())this.setDomElementAttribute(n,t,e.getAttribute(t),e)}if(!1!==t.withChildren)for(const i of this.viewChildrenToDom(e,t))n.appendChild(i);return n}}setDomElementAttribute(e,t,n,i){const o=this.shouldRenderAttribute(t,n,e.tagName.toLowerCase())||i&&i.shouldRenderUnsafeAttribute(t);o||A("domconverter-unsafe-attribute-detected",{domElement:e,key:t,value:n}),Xi(t)?(e.hasAttribute(t)&&!o?e.removeAttribute(t):e.hasAttribute(Yl+t)&&o&&e.removeAttribute(Yl+t),e.setAttribute(o?t:Yl+t,n)):A("domconverter-invalid-attribute-detected",{domElement:e,key:t,value:n})}removeDomElementAttribute(e,t){t!=Ql&&(e.removeAttribute(t),e.removeAttribute(Yl+t))}*viewChildrenToDom(e,t={}){const n=e.getFillerOffset&&e.getFillerOffset();let i=0;for(const o of e.getChildren()){n===i&&(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)),i++}n===i&&(yield this._getBlockFiller())}viewRangeToDom(e){const t=this.viewPositionToDom(e.start),n=this.viewPositionToDom(e.end),i=this._domDocument.createRange();return i.setStart(t.parent,t.offset),i.setEnd(n.parent,n.offset),i}viewPositionToDom(e){const t=e.parent;if(t.is("$text")){const n=this.findCorrespondingDomText(t);if(!n)return null;let i=e.offset;return Vl(n)&&(i+=Rl),{parent:n,offset:i}}{let n,i,o;if(0===e.offset){if(n=this.mapViewToDom(t),!n)return null;o=n.childNodes[0]}else{const t=e.nodeBefore;if(i=t.is("$text")?this.findCorrespondingDomText(t):this.mapViewToDom(t),!i)return null;n=i.parentNode,o=i.nextSibling}if(Bi(o)&&Vl(o))return{parent:o,offset:Rl};return{parent:n,offset:i?Yi(i)+1:0}}}domToView(e,t={}){if(this.isBlockFiller(e))return null;const n=this.getHostViewElement(e);if(n)return n;if(Ji(e)&&t.skipComments)return null;if(Bi(e)){if(Dl(e))return null;{const t=this._processDataFromDomText(e);return""===t?null:new zs(this.document,t)}}{if(this.mapDomToView(e))return this.mapDomToView(e);let n;if(this.isDocumentFragment(e))n=new wl(this.document),t.bind&&this.bindDocumentFragments(e,n);else{n=this._createViewElement(e,t),t.bind&&this.bindElements(e,n);const i=e.attributes;if(i)for(let e=i.length,t=0;t{const{scrollLeft:t,scrollTop:n}=e;i.push([t,n])})),t.focus(),Xl(t,(e=>{const[t,n]=i.shift();e.scrollLeft=t,e.scrollTop=n})),Di.window.scrollTo(e,n)}}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 n=e.isEqualNode(Gl);return n&&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 n=t.collapsed;return t.detach(),n}getHostViewElement(e){const t=Li(e);for(t.pop();t.length;){const e=t.pop(),n=this._domToViewMapping.get(e);if(n&&(n.is("uiElement")||n.is("rawElement")))return n}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(Bi(e)&&Vl(e)&&tthis.preElements.includes(e.name))))return t;if(" "==t.charAt(0)){const n=this._getTouchingInlineViewNode(e,!1);!(n&&n.is("$textProxy")&&this._nodeEndsWithSpace(n))&&n||(t=" "+t.substr(1))}if(" "==t.charAt(t.length-1)){const n=this._getTouchingInlineViewNode(e,!0),i=n&&n.is("$textProxy")&&" "==n.data.charAt(0);" "!=t.charAt(t.length-2)&&n&&!i||(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 n=Li(e);return n.some((e=>e.tagName&&t.includes(e.tagName.toLowerCase())))}(e,this.preElements))return Ll(e);t=t.replace(/[ \n\t\r]{1,}/g," ");const n=this._getTouchingInlineDomNode(e,!1),i=this._getTouchingInlineDomNode(e,!0),o=this._checkShouldLeftTrimDomText(e,n),r=this._checkShouldRightTrimDomText(e,i);o&&(t=t.replace(/^ /,"")),r&&(t=t.replace(/ $/,"")),t=Ll(new Text(t)),t=t.replace(/ \u00A0/g," ");const s=i&&this.isElement(i)&&"BR"!=i.tagName,a=i&&Bi(i)&&" "==i.data.charAt(0);return(/( |\u00A0)\u00A0$/.test(t)||!i||s||a)&&(t=t.replace(/\u00A0$/," ")),(o||n&&this.isElement(n)&&"BR"!=n.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 n=new Ga({startPosition:t?Ka._createAfter(e):Ka._createBefore(e),direction:t?"forward":"backward"});for(const e of n){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 n=t?"firstChild":"lastChild",i=t?"nextSibling":"previousSibling";let o=!0,r=e;do{if(!o&&r[n]?r=r[n]:r[i]?(r=r[i],o=!1):(r=r.parentNode,o=!0),!r||this._isBlockElement(r))return null}while(!Bi(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(Ji(e))return new ml(this.document,"$comment");const n=t.keepOriginalCase?e.tagName:e.tagName.toLowerCase();return new Fa(this.document,n)}_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 n=this._domDocument.createElement("span");if(n.setAttribute(Ql,e),t){for(;t.firstChild;)n.appendChild(t.firstChild);for(const e of t.getAttributeNames())n.setAttribute(e,t.getAttribute(e))}return n}}function Xl(e,t){let n=e;for(;n;)t(n),n=n.parentElement}function ec(e,t){const n=e.parentNode;return!!n&&!!n.tagName&&t.includes(n.tagName.toLowerCase())}function tc(e){"script"===e&&A("domconverter-unsafe-script-element-detected"),"style"===e&&A("domconverter-unsafe-style-element-detected")}class nc extends(Mi()){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 ic=Ra((function(e,t){Mt(t,pn(t),e)}));class oc{constructor(e,t,n){this.view=e,this.document=e.document,this.domEvent=t,this.domTarget=t.target,ic(this,n)}get target(){return this.view.domConverter.mapDomToView(this.domTarget)}preventDefault(){this.domEvent.preventDefault()}stopPropagation(){this.domEvent.stopPropagation()}}class rc extends nc{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,n){this.isEnabled&&this.document.fire(e,new oc(this.view,t,n))}}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 nc{constructor(e){super(e),this._fireSelectionChangeDoneDebounced=Xr((e=>{this.document.fire("selectionChangeDone",e)}),200)}observe(){const e=this.document;e.on("arrowKey",((t,n)=>{e.selection.isFake&&this.isEnabled&&n.preventDefault()}),{context:"$capture"}),e.on("arrowKey",((t,n)=>{e.selection.isFake&&this.isEnabled&&this._handleSelectionMove(n.keyCode)}),{priority:"lowest"})}stopObserving(){}destroy(){super.destroy(),this._fireSelectionChangeDoneDebounced.cancel()}_handleSelectionMove(e){const t=this.document.selection,n=new Ja(t.getRanges(),{backward:t.isBackward,fake:!1});e!=bo.arrowleft&&e!=bo.arrowup||n.setTo(n.getFirstPosition()),e!=bo.arrowright&&e!=bo.arrowdown||n.setTo(n.getLastPosition());const i={oldSelection:t,newSelection:n,domSelection:null};this.document.fire("selectionChange",i),this._fireSelectionChangeDoneDebounced(i)}}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,n=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&n?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",((n,i)=>{const o=t.selection.editableElement;null!==o&&o!==i.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 nc{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,n=()=>{this.document.isSelecting&&(this._handleSelectionChange(null,t),this.document.isSelecting=!1,this._documentIsSelectingInactivityTimeoutDebounced.cancel())};this.listenTo(e,"selectstart",(()=>{this.document.isSelecting=!0,this._documentIsSelectingInactivityTimeoutDebounced()}),{priority:"highest"}),this.listenTo(e,"keydown",n,{priority:"highest",useCapture:!0}),this.listenTo(e,"keyup",n,{priority:"highest",useCapture:!0}),this._documents.has(t)||(this.listenTo(t,"mouseup",n,{priority:"highest",useCapture:!0}),this.listenTo(t,"selectionchange",((e,n)=>{this.document.isComposing&&!c.isAndroid||(this._handleSelectionChange(n,t),this._documentIsSelectingInactivityTimeoutDebounced())})),this._documents.add(t))}stopObserving(e){this.stopListening(e)}destroy(){super.destroy(),clearInterval(this._clearInfiniteLoopInterval),this._fireSelectionChangeDoneDebounced.cancel(),this._documentIsSelectingInactivityTimeoutDebounced.cancel()}_reportInfiniteLoop(){}_handleSelectionChange(e,t){if(!this.isEnabled)return;const n=t.defaultView.getSelection();if(this.checkShouldIgnoreEventFromTarget(n.anchorNode))return;this.mutationObserver.flush();const i=this.domConverter.domSelectionToView(n);if(0!=i.rangeCount){if(this.view.hasDomSelection=!0,!this.selection.isEqual(i)||!this.domConverter.isDomSelectionCorrect(n))if(++this._loopbackCounter>60)this._reportInfiniteLoop();else if(this.focusObserver.flush(),this.selection.isSimilar(i))this.view.forceRender();else{const e={oldSelection:this.selection,newSelection:i,domSelection:n};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,n){this._native.setDragImage(e,t,n)}get isCanceled(){return"none"==this._native.dropEffect||!!this._native.mozUserCancelled}}function Vc(e){const t=Array.from(e.files||[]),n=Array.from(e.items||[]);return t.length?t:n.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(),n=this.view,i=n.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")),i.selection.isFake)s=Array.from(i.selection.getRanges());else if(t.length)s=t.map((e=>{const t=n.domConverter.domPositionToView(e.startContainer,e.startOffset),i=n.domConverter.domPositionToView(e.endContainer,e.endOffset);return t?n.createRange(t,i):i?n.createRange(i):void 0})).filter((e=>!!e));else if(c.isAndroid){const t=e.target.ownerDocument.defaultView.getSelection();s=Array.from(n.domConverter.domSelectionToView(t).getRanges())}if(c.isAndroid&&"insertCompositionText"==e.inputType&&r&&r.endsWith("\n"))this.fire(e.type,e,{inputType:"insertParagraph",targetRanges:[n.createRange(s[0].end)]});else if("insertText"==e.inputType&&r&&r.includes("\n")){const t=r.split(/\n{1,2}/g);let n=s;for(let r=0;r{if(this.isEnabled&&((n=t.keyCode)==bo.arrowright||n==bo.arrowleft||n==bo.arrowup||n==bo.arrowdown)){const n=new el(this.document,"arrowKey",this.document.selection.getFirstRange());this.document.fire(n,t),n.stop.called&&e.stop()}var n}))}observe(){}stopObserving(){}}class Bc extends nc{constructor(e){super(e);const t=this.document;t.on("keydown",((e,n)=>{if(!this.isEnabled||n.keyCode!=bo.tab||n.ctrlKey)return;const i=new el(t,"tab",t.selection.getFirstRange());t.fire(i,n),i.stop.called&&e.stop()}))}observe(){}stopObserving(){}}const jc=function(e){return Ai(e,5)};class zc 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 n=this.document.getRoot(t);n._name=e.tagName.toLowerCase();const i={};for(const{name:t,value:o}of Array.from(e.attributes))i[t]=o,"class"===t?this._writer.addClass(o.split(" "),n):this._writer.setAttribute(t,o,n);this._initialDomRootAttributes.set(e,i);const o=()=>{this._writer.setAttribute("contenteditable",(!n.isReadOnly).toString(),n),n.isReadOnly?this._writer.addClass("ck-read-only",n):this._writer.removeClass("ck-read-only",n)};o(),this.domRoots.set(t,e),this.domConverter.bindElements(e,n),this._renderer.markToSync("children",n),this._renderer.markToSync("attributes",n),this._renderer.domDocuments.add(e.ownerDocument),n.on("change:children",((e,t)=>this._renderer.markToSync("children",t))),n.on("change:attributes",((e,t)=>this._renderer.markToSync("attributes",t))),n.on("change:text",((e,t)=>this._renderer.markToSync("text",t))),n.on("change:isReadOnly",(()=>this.change(o))),n.on("change",(()=>{this._hasChangedSinceTheLastRendering=!0}));for(const n of this._observers.values())n.observe(e,t)}detachDomRoot(e){const t=this.domRoots.get(e);Array.from(t.attributes).forEach((({name:e})=>t.removeAttribute(e)));const n=this._initialDomRootAttributes.get(t);for(const e in n)t.setAttribute(e,n[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,n]of this.domRoots)t.observe(n,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:n=20,ancestorOffset:i=20}={}){const o=this.document.selection.getFirstRange();if(!o)return;const r=jc({alignToTop:e,forceScroll:t,viewportOffset:n,ancestorOffset:i});"number"==typeof n&&(n={top:n,bottom:n,left:n,right:n});const s={target:this.domConverter.viewRangeToDom(o),viewportOffset:n,ancestorOffset:i,alignToTop:e,forceScroll:t};this.fire("scrollToTheSelection",s,r),function({target:e,viewportOffset:t=0,ancestorOffset:n=0,alignToTop:i,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:i,ancestorOffset:n,forceScroll:o});const c=fo(e,s);if(ro({window:s,rect:c,viewportOffset:t,alignToTop:i,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 n=e.includeSelf?this:this.parent;for(;n;)t[e.parentFirst?"push":"unshift"](n),n=n.parent;return t}getCommonAncestor(e,t={}){const n=this.getAncestors(t),i=e.getAncestors(t);let o=0;for(;n[o]==i[o]&&n[o];)o++;return 0===o?null:n[o-1]}isBefore(e){if(this==e)return!1;if(this.root!==e.root)return!1;const t=this.getPath(),n=e.getPath(),i=ne(t,n);switch(i){case"prefix":return!0;case"extension":return!1;default:return t[i](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 n of this._nodes){if(e>=t&&e1e4)return e.slice(0,n).concat(t).concat(e.slice(n+i,e.length));{const o=Array.from(e);return o.splice(n,i,...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 Zc 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 Zc(this.data,this.getAttributes())}static fromJSON(e){return new Zc(e.data,e.attributes)}}Zc.prototype.is=function(e){return"$text"===e||"model:$text"===e||"text"===e||"model:text"===e||"node"===e||"model:node"===e};class Wc extends Fc{constructor(e,t,n){if(super(),this.textNode=e,t<0||t>e.offsetSize)throw new y("model-textproxy-wrong-offsetintext",this);if(n<0||t+n>e.offsetSize)throw new y("model-textproxy-wrong-length",this);this.data=e.data.substring(t,t+n),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 n=e.includeSelf?this:this.parent;for(;n;)t[e.parentFirst?"push":"unshift"](n),n=n.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()}}Wc.prototype.is=function(e){return"$textProxy"===e||"model:$textProxy"===e||"textProxy"===e||"model:textProxy"===e};class $c extends Hc{constructor(e,t,n){super(t),this._children=new Uc,this.name=e,n&&this._insertChild(0,n)}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 n of e)t=t.getChild(t.offsetToIndex(n));return t}findAncestor(e,t={}){let n=t.includeSelf?this:this.parent;for(;n;){if(n.name===e)return n;n=n.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 n=function(e){if("string"==typeof e)return[new Zc(e)];ie(e)||(e=[e]);return Array.from(e).map((e=>"string"==typeof e?new Zc(e):e instanceof Wc?new Zc(e.data,e.getAttributes()):e))}(t);for(const e of n)null!==e.parent&&e._remove(),e.parent=this;this._children._insertNodes(e,n)}_removeChildren(e,t=1){const n=this._children._removeNodes(e,t);for(const e of n)e.parent=null;return n}static fromJSON(e){let t;if(e.children){t=[];for(const n of e.children)n.name?t.push($c.fromJSON(n)):t.push(Zc.fromJSON(n))}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,n,i,o;do{i=this.position,o=this._visitedParent,({done:t,value:n}=this.next())}while(!t&&e(n));t||(this._position=i,this._visitedParent=o)}next(){return"forward"==this.direction?this._next():this._previous()}_next(){const e=this.position,t=this.position.clone(),n=this._visitedParent;if(null===n.parent&&t.offset===n.maxOffset)return{done:!0,value:void 0};if(n===this._boundaryEndParent&&t.offset==this.boundaries.end.offset)return{done:!0,value:void 0};const i=Yc(t,n),o=i||Qc(t,n,i);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 Zc){let i;if(this.singleCharacters)i=1;else{let e=o.endOffset;this._boundaryEndParent==n&&this.boundaries.end.offsete&&(e=this.boundaries.start.offset),i=t.offset-e}const o=t.offset-r.startOffset,s=new Wc(r,o-i,i);return t.offset-=i,this._position=t,Gc("text",s,e,t,i)}return t.path.pop(),this._position=t,this._visitedParent=n.parent,Gc("elementStart",n,e,t,1)}}function Gc(e,t,n,i,o){return{done:!1,value:{type:e,item:t,previousPosition:n,nextPosition:i,length:o}}}class Kc extends Fc{constructor(e,t,n="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=n}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,n);if(-1===t)return Xc(this,e,n)}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"==ne(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 n;return t.containsPosition(this)||t.start.isEqual(this)?(n=this._getCombined(e.sourcePosition,e.targetPosition),e.sourcePosition.isBefore(e.targetPosition)&&(n=n._getTransformedByDeletion(e.deletionPosition,1))):n=this.isEqual(e.deletionPosition)?Kc._createAt(e.deletionPosition):this._getTransformedByMove(e.deletionPosition,e.graveyardPosition,1),n}_getTransformedByDeletion(e,t){const n=Kc._createAt(this);if(this.root!=e.root)return n;if("same"==ne(e.getParentPath(),this.getParentPath())){if(e.offsetthis.offset)return null;n.offset-=t}}else if("prefix"==ne(e.getParentPath(),this.getParentPath())){const i=e.path.length-1;if(e.offset<=this.path[i]){if(e.offset+t>this.path[i])return null;n.path[i]-=t}}return n}_getTransformedByInsertion(e,t){const n=Kc._createAt(this);if(this.root!=e.root)return n;if("same"==ne(e.getParentPath(),this.getParentPath()))(e.offset=t;){if(e.path[i]+o!==n.maxOffset)return!1;o=1,i--,n=n.parent}return!0}(e,n+1))}function ed(e,t){for(;tt+1;){const t=i.maxOffset-n.offset;0!==t&&e.push(new td(n,n.getShiftedBy(t))),n.path=n.path.slice(0,-1),n.offset++,i=i.parent}for(;n.path.length<=this.end.path.length;){const t=this.end.path[n.path.length-1],i=t-n.offset;0!==i&&e.push(new td(n,n.getShiftedBy(i))),n.offset=t,n.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 n of e)for(let e=0;e0?new this(n,i):new this(i,n)}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 n=e.indexOf(t),i=new this(t.start,t.end);if(n>0)for(let t=n-1;e[t].end.isEqual(i.start);t++)i.start=Kc._createAt(e[t].start);for(let t=n+1;t{if(t.viewPosition)return;const n=this._modelToViewMapping.get(t.modelPosition.parent);if(!n)throw new y("mapping-model-position-view-parent-not-found",this,{modelPosition:t.modelPosition});t.viewPosition=this.findPositionIn(n,t.modelPosition.offset)}),{priority:"low"}),this.on("viewToModelPosition",((e,t)=>{if(t.modelPosition)return;const n=this.findMappedViewAncestor(t.viewPosition),i=this._viewToModelMapping.get(n),o=this._toModelOffset(t.viewPosition.parent,t.viewPosition.offset,n);t.modelPosition=Kc._createAt(i,o)}),{priority:"low"})}bindElements(e,t){this._modelToViewMapping.set(e,t),this._viewToModelMapping.set(t,e)}unbindViewElement(e,t={}){const n=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(n)==e&&this._modelToViewMapping.delete(n))}unbindModelElement(e){const t=this.toViewElement(e);this._modelToViewMapping.delete(e),this._viewToModelMapping.get(t)==e&&this._viewToModelMapping.delete(t)}bindElementToMarker(e,t){const n=this._markerNameToElements.get(t)||new Set;n.add(e);const i=this._elementToMarkerNames.get(e)||new Set;i.add(t),this._markerNameToElements.set(t,n),this._elementToMarkerNames.set(e,i)}unbindElementFromMarkerName(e,t){const n=this._markerNameToElements.get(t);n&&(n.delete(e),0==n.size&&this._markerNameToElements.delete(t));const i=this._elementToMarkerNames.get(e);i&&(i.delete(t),0==i.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 n={modelPosition:e,mapper:this,isPhantom:t.isPhantom};return this.fire("modelToViewPosition",n),n.viewPosition}markerNameToElements(e){const t=this._markerNameToElements.get(e);if(!t)return null;const n=new Set;for(const e of t)if(e.is("attributeElement"))for(const t of e.getElementsWithSameId())n.add(t);else n.add(e);return n}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,n){if(n!=e){return this._toModelOffset(e.parent,e.index,n)+this._toModelOffset(e,t,e)}if(e.is("$text"))return t;let i=0;for(let n=0;n1?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,n){const i=this._createConversionApi(n,e.getRefreshedItems());for(const t of e.getMarkersToRemove())this._convertMarkerRemove(t.name,t.range,i);const o=this._reduceChanges(e.getChanges());for(const e of o)"insert"===e.type?this._convertInsert(td._createFromPositionAndShift(e.position,e.length),i):"reinsert"===e.type?this._convertReinsert(td._createFromPositionAndShift(e.position,e.length),i):"remove"===e.type?this._convertRemove(e.position,e.length,e.name,i):this._convertAttribute(e.range,e.attributeKey,e.attributeOldValue,e.attributeNewValue,i);for(const e of i.mapper.flushUnboundMarkerNames()){const n=t.get(e).getRange();this._convertMarkerRemove(e,n,i),this._convertMarkerAdd(e,n,i)}for(const t of e.getMarkersToAdd())this._convertMarkerAdd(t.name,t.range,i);i.mapper.flushDeferredBindings(),i.consumable.verifyAllConsumed("insert")}convert(e,t,n,i={}){const o=this._createConversionApi(n,void 0,i);this._convertInsert(e,o);for(const[e,n]of t)this._convertMarkerAdd(e,n,o);o.consumable.verifyAllConsumed("insert")}convertSelection(e,t,n){const i=Array.from(t.getMarkersAtPosition(e.getFirstPosition())),o=this._createConversionApi(n);if(this._addConsumablesForSelection(o.consumable,e,i),this.fire("selection",{selection:e},o),e.isCollapsed){for(const t of i){const n=t.getRange();if(!sd(e.getFirstPosition(),t,o.mapper))continue;const i={item:e,markerName:t.name,markerRange:n};o.consumable.test(e,"addMarker:"+t.name)&&this.fire(`addMarker:${t.name}`,i,o)}for(const t of e.getAttributeKeys()){const n={item:e,range:e.getFirstRange(),attributeKey:t,attributeOldValue:null,attributeNewValue:e.getAttribute(t)};o.consumable.test(e,"attribute:"+n.attributeKey)&&this.fire(`attribute:${n.attributeKey}:$text`,n,o)}}}_convertInsert(e,t,n={}){n.doNotAddConsumables||this._addConsumablesForInsert(t.consumable,Array.from(e));for(const n of Array.from(e.getWalker({shallow:!0})).map(ad))this._testAndFire("insert",n,t)}_convertRemove(e,t,n,i){this.fire(`remove:${n}`,{position:e,length:t},i)}_convertAttribute(e,t,n,i,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:n,attributeNewValue:i};this._testAndFire(`attribute:${t}`,e,o)}}_convertReinsert(e,t){const n=Array.from(e.getWalker({shallow:!0}));this._addConsumablesForInsert(t.consumable,n);for(const e of n.map(ad))this._testAndFire("insert",{...e,reconversion:!0},t)}_convertMarkerAdd(e,t,n){if("$graveyard"==t.root.rootName)return;const i=`addMarker:${e}`;if(n.consumable.add(t,i),this.fire(i,{markerName:e,markerRange:t},n),n.consumable.consume(t,i)){this._addConsumablesForRange(n.consumable,t,i);for(const o of t.getItems()){if(!n.consumable.test(o,i))continue;const r={item:o,range:td._createOn(o),markerName:e,markerRange:t};this.fire(i,r,n)}}}_convertMarkerRemove(e,t,n){"$graveyard"!=t.root.rootName&&this.fire(`removeMarker:${e}`,{markerName:e,markerRange:t},n)}_reduceChanges(e){const t={changes:e};return this.fire("reduceChanges",t),t.changes}_addConsumablesForInsert(e,t){for(const n of t){const t=n.item;if(null===e.test(t,"insert")){e.add(t,"insert");for(const n of t.getAttributeKeys())e.add(t,"attribute:"+n)}}return e}_addConsumablesForRange(e,t,n){for(const i of t.getItems())e.add(i,n);return e}_addConsumablesForSelection(e,t,n){e.add(t,"selection");for(const i of n)e.add(t,"addMarker:"+i.name);for(const n of t.getAttributeKeys())e.add(t,"attribute:"+n);return e}_testAndFire(e,t,n){const i=function(e,t){const n=t.item.is("element")?t.item.name:"$text";return`${e}:${n}`}(e,t),o=t.item.is("$textProxy")?n.consumable._getSymbolForTextProxy(t.item):t.item,r=this._firedEventsMap.get(n),s=r.get(o);if(s){if(s.has(i))return;s.add(i)}else r.set(o,new Set([i]));this.fire(i,t,n)}_testAndFireAddAttributes(e,t){const n={item:e,range:td._createOn(e)};for(const e of n.item.getAttributeKeys())n.attributeKey=e,n.attributeOldValue=null,n.attributeNewValue=n.item.getAttribute(e),this._testAndFire(`attribute:${e}`,n,t)}_createConversionApi(e,t=new Set,n={}){const i={...this._conversionApi,consumable:new id,writer:e,options:n,convertItem:e=>this._convertInsert(td._createOn(e),i),convertChildren:e=>this._convertInsert(td._createIn(e),i,{doNotAddConsumables:!0}),convertAttributes:e=>this._testAndFireAddAttributes(e,i),canReuseView:e=>!t.has(i.mapper.toModelElement(e))};return this._firedEventsMap.set(i,new Map),i}}function sd(e,t,n){const i=t.getRange(),o=Array.from(e.getAncestors());o.shift(),o.reverse();return!o.some((e=>{if(i.containsItem(e)){return!!n.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 n=!1;for(const i of e._ranges)if(t.isEqual(i)){n=!0;break}if(!n)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,n,i]=e;if("object"==typeof n&&(i=n,n=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],!!i&&!!i.backward);else if(t instanceof Kc)this._setRanges([new td(t)]);else if(t instanceof Hc){const e=!!i&&!!i.backward;let o;if("in"==n)o=td._createIn(t);else if("on"==n)o=td._createOn(t);else{if(void 0===n)throw new y("model-selection-setto-required-second-parameter",[this,t]);o=new td(Kc._createAt(t,n))}this._setRanges([o],e)}else{if(!ie(t))throw new y("model-selection-setto-not-selectable",[this,t]);this._setRanges(t,i&&!!i.backward)}}_setRanges(e,t=!1){const n=Array.from(e),i=n.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)))}));(n.length!==this._ranges.length||i)&&(this._replaceAllRanges(n),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 n=Kc._createAt(e,t);if("same"==n.compareWith(this.focus))return;const i=this.anchor;this._ranges.length&&this._popRange(),"before"==n.compareWith(i)?(this._pushRange(new td(n,i)),this._lastRangeBackward=!0):(this._pushRange(new td(i,n)),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 n=ud(t.start,e);md(n,t)&&(yield n);for(const n of t.getWalker()){const i=n.item;"elementEnd"==n.type&&dd(i,e,t)&&(yield i)}const i=ud(t.end,e);fd(i,t)&&(yield i)}}containsEntireContent(e=this.anchor.root){const t=Kc._createAt(e,0),n=Kc._createAt(e,"end");return t.isTouching(this.getFirstPosition())&&n.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,n){return cd(e,t)&&hd(e,n)}function ud(e,t){const n=e.parent.root.document.model.schema,i=e.parent.getAncestors({parentFirst:!0,includeSelf:!0});let o=!1;const r=i.find((e=>!o&&(o=n.isLimit(e),!o&&cd(e,t))));return i.forEach((e=>t.add(e))),r}function hd(e,t){const n=function(e){const t=e.root.document.model.schema;let n=e.parent;for(;n;){if(t.isBlock(n))return n;n=n.parent}}(e);if(!n)return!0;return!t.containsRange(td._createOn(n),!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 n=t[0];n.isDocumentOperation&&bd.call(this,n)}),{priority:"low"})}function bd(e){const t=this.getTransformedByOperation(e),n=td._createFromRanges(t),i=!n.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(i){"$graveyard"==n.root.rootName&&(r="remove"==e.type?e.sourcePosition:e.deletionPosition);const t=this.toRange();this.start=n.start,this.end=n.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 n=t[0];n.isDocumentOperation&&"marker"!=n.type&&"rename"!=n.type&&"noop"!=n.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,n,i)=>{this._updateMarker(t,i)})),this.listenTo(this._document,"change",((e,t)=>{!function(e,t){const n=e.document.differ;for(const i of n.getChanges()){if("insert"!=i.type)continue;const n=i.position.parent;i.length===n.maxOffset&&e.enqueueChange(t,(e=>{const t=Array.from(n.getAttributeKeys()).filter((e=>e.startsWith(wd)));for(const i of t)e.removeAttribute(i,n)}))}}(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=i.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 n=t.name.split(":",1)[0];if(!this._observedMarkers.has(n))continue;const i=t.getRange();for(const n of this.getRanges())i.containsRange(n,!n.isCollapsed)&&e.push(t)}const n=Array.from(this.markers);for(const n of e)this.markers.has(n)||(this.markers.add(n),t=!0);for(const n of Array.from(this.markers))e.includes(n)||(this.markers.remove(n),t=!0);t&&this.fire("change:marker",{oldMarkers:n,directChange:!1})}_updateMarker(e,t){const n=e.name.split(":",1)[0];if(!this._observedMarkers.has(n))return;let i=!1;const o=Array.from(this.markers),r=this.markers.has(e);if(t){let n=!1;for(const e of this.getRanges())if(t.containsRange(e,!e.isCollapsed)){n=!0;break}n&&!r?(this.markers.add(e),i=!0):!n&&r&&(this.markers.remove(e),i=!0)}else r&&(this.markers.remove(e),i=!0);i&&this.fire("change:marker",{oldMarkers:o,directChange:!1})}_updateAttributes(e){const t=Mo(this._getSurroundingAttributes()),n=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 i=[];for(const[e,t]of this.getAttributes())n.has(e)&&n.get(e)===t||i.push(e);for(const[e]of n)this.hasAttribute(e)||i.push(e);i.length>0&&this.fire("change:attribute",{attributeKeys:i,directChange:!1})}_setAttribute(e,t,n=!0){const i=n?"normal":"low";if("low"==i&&"normal"==this._attributePriority.get(e))return!1;return super.getAttribute(e)!==t&&(this._attrs.set(e,t),this._attributePriority.set(e,i),!0)}_removeAttribute(e,t=!0){const n=t?"normal":"low";return("low"!=n||"normal"!=this._attributePriority.get(e))&&(this._attributePriority.set(e,n),!!super.hasAttribute(e)&&(this._attrs.delete(e),!0))}_setAttributesTo(e){const t=new Set;for(const[t,n]of this.getAttributes())e.get(t)!==n&&this._removeAttribute(t,!1);for(const[n,i]of e){this._setAttribute(n,i,!1)&&t.add(n)}return t}*getStoredAttributes(){const e=this.getFirstPosition().parent;if(this.isCollapsed&&e.isEmpty)for(const t of e.getAttributeKeys())if(t.startsWith(wd)){const n=t.substr(10);yield[n,e.getAttribute(t)]}}_getSurroundingAttributes(){const e=this.getFirstPosition(),t=this._model.schema;let n=null;if(this.isCollapsed){const i=e.textNode?e.textNode:e.nodeBefore,o=e.textNode?e.textNode:e.nodeAfter;if(this.isGravityOverridden||(n=vd(i,t)),n||(n=vd(o,t)),!this.isGravityOverridden&&!n){let e=i;for(;e&&!n;)e=e.previousSibling,n=vd(e,t)}if(!n){let e=o;for(;e&&!n;)e=e.nextSibling,n=vd(e,t)}n||(n=this.getStoredAttributes())}else{const e=this.getFirstRange();for(const i of e){if(i.item.is("element")&&t.isObject(i.item))break;if("text"==i.type){n=i.item.getAttributes();break}}}return n}_fixGraveyardSelection(e){const t=this._model.schema.getNearestSelectionRange(e);t&&this._pushRange(t)}}function vd(e,t){if(!e)return null;if(e instanceof Wc||e instanceof Zc)return e.getAttributes();if(!t.isInline(e))return null;if(!t.isObject(e))return[];const n=[];for(const[i,o]of e.getAttributes())t.checkAttribute("$text",i)&&n.push([i,o]);return n}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),n=Sd(e.view,"container");t.attributes.length&&(t.children=!0);return i=>{i.on(`insert:${t.name}`,function(e,t=Vd){return(n,i,o)=>{if(!t(i.item,o.consumable,{preflight:!0}))return;const r=e(i.item,o,i);if(!r)return;t(i.item,o.consumable);const s=o.mapper.toViewPosition(i.range.start);o.mapper.bindElements(i.item,r),o.writer.insert(s,r),o.convertAttributes(i.item),Rd(r,i.item.getChildren(),o,{reconversion:i.reconversion})}}(n,Md(t)),{priority:e.converterPriority||"normal"}),(t.children||t.attributes.length)&&i.on("reduceChanges",Od(t),{priority:"low"})}}(e))}elementToStructure(e){return this.add(function(e){const t=Cd(e.model),n=Sd(e.view,"container");return t.children=!0,i=>{if(i._conversionApi.schema.checkChild(t.name,"$text"))throw new y("conversion-element-to-structure-disallowed-text",i,{elementName:t.name});var o,r;i.on(`insert:${t.name}`,(o=n,r=Md(t),(e,t,n)=>{if(!r(t.item,n.consumable,{preflight:!0}))return;const i=new Map;n.writer._registerSlotFactory(function(e,t,n){return(i,o)=>{const r=i.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",n.dispatcher,{modeOrFilter:o});s=Array.from(e.getChildren()).filter((e=>o(e)))}return t.set(r,s),r}}(t.item,i,n));const s=o(t.item,n,t);if(n.writer._clearSlotFactory(),!s)return;!function(e,t,n){const i=Array.from(t.values()).flat(),o=new Set(i);if(o.size!=i.length)throw new y("conversion-slot-filter-overlap",n.dispatcher,{element:e});if(o.size!=e.childCount)throw new y("conversion-slot-filter-incomplete",n.dispatcher,{element:e})}(t.item,i,n),r(t.item,n.consumable);const a=n.mapper.toViewPosition(t.range.start);n.mapper.bindElements(t.item,s),n.writer.insert(a,s),n.convertAttributes(t.item),function(e,t,n,i){n.mapper.on("modelToViewPosition",s,{priority:"highest"});let o=null,r=null;for([o,r]of t)Rd(e,r,n,i),n.writer.move(n.writer.createRangeIn(o),n.writer.createPositionBefore(o)),n.writer.remove(o);function s(e,t){const n=t.modelPosition.nodeAfter,i=r.indexOf(n);i<0||(t.viewPosition=t.mapper.findPositionIn(o,i))}n.mapper.off("modelToViewPosition",s)}(s,i,n,{reconversion:t.reconversion})}),{priority:e.converterPriority||"normal"}),i.on("reduceChanges",Od(t),{priority:"low"})}}(e))}attributeToElement(e){return this.add(function(e){e=jc(e);let t=e.model;"string"==typeof t&&(t={key:t});let n=`attribute:${t.key}`;t.name&&(n+=":"+t.name);if(t.values)for(const n of t.values)e.view[n]=Sd(e.view[n],"attribute");else e.view=Sd(e.view,"attribute");const i=Td(e);return t=>{t.on(n,function(e){return(t,n,i)=>{if(!i.consumable.test(n.item,t.name))return;const o=e(n.attributeOldValue,i,n),r=e(n.attributeNewValue,i,n);if(!o&&!r)return;i.consumable.consume(n.item,t.name);const s=i.writer,a=s.document.selection;if(n.item instanceof ld||n.item instanceof kd)s.wrap(a.getFirstRange(),r);else{let e=i.mapper.toViewRange(n.range);null!==n.attributeOldValue&&o&&(e=s.unwrap(e,o)),null!==n.attributeNewValue&&r&&s.wrap(e,r)}}}(i),{priority:e.converterPriority||"normal"})}}(e))}attributeToAttribute(e){return this.add(function(e){e=jc(e);let t=e.model;"string"==typeof t&&(t={key:t});let n=`attribute:${t.key}`;t.name&&(n+=":"+t.name);if(t.values)for(const n of t.values)e.view[n]=Pd(e.view[n]);else e.view=Pd(e.view);const i=Td(e);return t=>{var o;t.on(n,(o=i,(e,t,n)=>{if(!n.consumable.test(t.item,e.name))return;const i=o(t.attributeOldValue,n,t),r=o(t.attributeNewValue,n,t);if(!i&&!r)return;n.consumable.consume(t.item,e.name);const s=n.mapper.toViewElement(t.item),a=n.writer;if(!s)throw new y("conversion-attribute-to-attribute-on-text",n.dispatcher,t);if(null!==t.attributeOldValue&&i)if("class"==i.key){const e=Eo(i.value);for(const t of e)a.removeClass(t,s)}else if("style"==i.key){const e=Object.keys(i.value);for(const t of e)a.removeStyle(t,s)}else a.removeAttribute(i.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 n=>{var i;n.on(`addMarker:${e.model}`,(i=t,(e,t,n)=>{t.isOpening=!0;const o=i(t,n);t.isOpening=!1;const r=i(t,n);if(!o||!r)return;const s=t.markerRange;if(s.isCollapsed&&!n.consumable.consume(s,e.name))return;for(const t of s)if(!n.consumable.consume(t.item,e.name))return;const a=n.mapper,l=n.writer;l.insert(a.toViewPosition(s.start),o),n.mapper.bindElementToMarker(o,t.markerName),s.isCollapsed||(l.insert(a.toViewPosition(s.end),r),n.mapper.bindElementToMarker(r,t.markerName)),e.stop()}),{priority:e.converterPriority||"normal"}),n.on(`removeMarker:${e.model}`,((e,t,n)=>{const i=n.mapper.markerNameToElements(t.markerName);if(i){for(const e of i)n.mapper.unbindElementFromMarkerName(e,t.markerName),n.writer.clear(n.writer.createRangeOn(e),e);n.writer.clearClonedElementsGroup(t.markerName),e.stop()}}),{priority:e.converterPriority||"normal"})}}(e))}markerToHighlight(e){return this.add(function(e){return t=>{var n;t.on(`addMarker:${e.model}`,(n=e.view,(e,t,i)=>{if(!t.item)return;if(!(t.item instanceof ld||t.item instanceof kd||t.item.is("$textProxy")))return;const o=Id(n,t,i);if(!o)return;if(!i.consumable.consume(t.item,e.name))return;const r=i.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=i.mapper.toViewRange(t.range),n=r.wrap(e,s);for(const e of n.getItems())if(e.is("attributeElement")&&e.isSimilar(s)){i.mapper.bindElementToMarker(e,t.markerName);break}}}),{priority:e.converterPriority||"normal"}),t.on(`addMarker:${e.model}`,function(e){return(t,n,i)=>{if(!n.item)return;if(!(n.item instanceof $c))return;const o=Id(e,n,i);if(!o)return;if(!i.consumable.test(n.item,t.name))return;const r=i.mapper.toViewElement(n.item);if(r&&r.getCustomProperty("addHighlight")){i.consumable.consume(n.item,t.name);for(const e of td._createIn(n.item))i.consumable.consume(e.item,t.name);r.getCustomProperty("addHighlight")(r,o,i.writer),i.mapper.bindElementToMarker(r,n.markerName)}}}(e.view),{priority:e.converterPriority||"normal"}),t.on(`removeMarker:${e.model}`,function(e){return(t,n,i)=>{if(n.markerRange.isCollapsed)return;const o=Id(e,n,i);if(!o)return;const r=xd(i.writer,o),s=i.mapper.markerNameToElements(n.markerName);if(s){for(const e of s)if(i.mapper.unbindElementFromMarkerName(e,n.markerName),e.is("attributeElement"))i.writer.unwrap(i.writer.createRangeOn(e),r);else{e.getCustomProperty("removeHighlight")(e,o.id,i.writer)}i.writer.clearClonedElementsGroup(n.markerName),t.stop()}}}(e.view),{priority:e.converterPriority||"normal"})}}(e))}markerToData(e){return this.add(function(e){e=jc(e);const t=e.model;let n=e.view;n||(n=n=>({group:t,name:n.substr(e.model.length+1)}));return i=>{var o;i.on(`addMarker:${t}`,(o=n,(e,t,n)=>{const i=o(t.markerName,n);if(!i)return;const r=t.markerRange;n.consumable.consume(r,e.name)&&(Ed(r,!1,n,t,i),Ed(r,!0,n,t,i),e.stop())}),{priority:e.converterPriority||"normal"}),i.on(`removeMarker:${t}`,function(e){return(t,n,i)=>{const o=e(n.markerName,i);if(!o)return;const r=i.mapper.markerNameToElements(n.markerName);if(r){for(const e of r)i.mapper.unbindElementFromMarkerName(e,n.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)):i.writer.clear(i.writer.createRangeOn(e),e);i.writer.clearClonedElementsGroup(n.markerName),t.stop()}function s(e,t){if(t.hasAttribute(e)){const n=new Set(t.getAttribute(e).split(","));n.delete(o.name),0==n.size?i.writer.removeAttribute(e,t):i.writer.setAttribute(e,Array.from(n).join(","),t)}}}}(n),{priority:e.converterPriority||"normal"})}}(e))}}function xd(e,t){const n=e.createAttributeElement("span",t.attributes);return t.classes&&n._addClass(t.classes),"number"==typeof t.priority&&(n._priority=t.priority),n._id=t.id,n}function Ed(e,t,n,i,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=n.mapper.toViewElement(e);if(l)return void function(e,t,n,i,o,r){const s=`data-${r.group}-${t?"start":"end"}-${n?"before":"after"}`,a=e.hasAttribute(s)?e.getAttribute(s).split(","):[];a.unshift(r.name),i.writer.setAttribute(s,a.join(","),e),i.mapper.bindElementToMarker(e,o.markerName)}(l,t,r,n,i,o)}!function(e,t,n,i,o){const r=`${o.group}-${t?"start":"end"}`,s=o.name?{name:o.name}:null,a=n.writer.createUIElement(r,s);n.writer.insert(e,a),n.mapper.bindElementToMarker(a,i.markerName)}(n.mapper.toViewPosition(r),t,n,i,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:(n,i)=>function(e,t,n){"string"==typeof e&&(e={name:e});let i;const o=t.writer,r=Object.assign({},e.attributes);if("container"==n)i=o.createContainerElement(e.name,r);else if("attribute"==n){const t={priority:e.priority||ll.DEFAULT_PRIORITY};i=o.createAttributeElement(e.name,r,t)}else i=o.createUIElement(e.name,r);if(e.styles){const t=Object.keys(e.styles);for(const n of t)o.setStyle(n,e.styles[n],i)}if(e.classes){const t=e.classes;if("string"==typeof t)o.addClass(t,i);else for(const e of t)o.addClass(e,i)}return i}(e,i,t)}function Td(e){return e.model.values?(t,n,i)=>{const o=e.view[t];return o?o(t,n,i):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,n){const i="function"==typeof e?e(t,n):e;return i?(i.priority||(i.priority=10),i.id||(i.id=t.markerName),i):null}function Od(e){const t=function(e){return(t,n)=>{if(!t.is("element",e.name))return!1;if("attribute"==n.type){if(e.attributes.includes(n.attributeKey))return!0}else if(e.children)return!0;return!1}}(e);return(e,n)=>{const i=[];n.reconvertedElements||(n.reconvertedElements=new Set);for(const e of n.changes){const o="attribute"==e.type?e.range.start.nodeAfter:e.position.parent;if(o&&t(o,e)){if(!n.reconvertedElements.has(o)){n.reconvertedElements.add(o);const e=Kc._createBefore(o);let t=i.length;for(let n=i.length-1;n>=0;n--){const o=i[n],r=("attribute"==o.type?o.range.start:o.position).compareWith(e);if("before"==r||"remove"==o.type&&"same"==r)break;t=n}i.splice(t,0,{type:"remove",name:o.name,position:e,length:1},{type:"reinsert",name:o.name,position:e,length:1})}}else i.push(e)}n.changes=i}}function Md(e){return(t,n,i={})=>{const o=["insert"];for(const n of e.attributes)t.hasAttribute(n)&&o.push(`attribute:${n}`);return!!o.every((e=>n.test(t,e)))&&(i.preflight||o.forEach((e=>n.consume(t,e))),!0)}}function Rd(e,t,n,i){for(const o of t)Nd(e.root,o,n,i)||n.convertItem(o)}function Nd(e,t,n,i){const{writer:o,mapper:r}=n;if(!i.reconversion)return!1;const s=r.toViewElement(t);return!(!s||s.root==e)&&(!!n.canReuseView(s)&&(o.move(o.createRangeOn(s),r.toViewPosition(Kc._createBefore(t))),!0))}function Vd(e,t,{preflight:n}={}){return n?t.test(e,"insert"):t.consume(e,"insert")}function Dd(e){const{schema:t,document:n}=e.model;for(const i of n.getRootNames()){const o=n.getRoot(i);if(o.isEmpty&&!t.checkChild(o,"$text")&&t.checkChild(o,"paragraph"))return e.insertElement("paragraph",o),!0}return!1}function Ld(e,t,n){const i=n.createContext(e);return!!n.checkChild(i,"paragraph")&&!!n.checkChild(i.push("paragraph"),t)}function Bd(e,t){const n=t.createElement("paragraph");return t.insert(n,e),t.createPositionAt(n,0)}class jd extends yd{elementToElement(e){return this.add(zd(e))}elementToAttribute(e){return this.add(function(e){e=jc(e),Ud(e);const t=Zd(e,!1),n=Fd(e.view),i=n?`element:${n}`:"element";return n=>{n.on(i,t,{priority:e.converterPriority||"low"})}}(e))}attributeToAttribute(e){return this.add(function(e){e=jc(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 n;if("class"==t||"style"==t){n={["class"==t?"classes":"styles"]:e.view.value}}else{n={attributes:{[t]:void 0===e.view.value?/[\s\S]*/:e.view.value}}}e.view.name&&(n.name=e.view.name);return e.view=n,t}(e));Ud(e,t);const n=Zd(e,!0);return t=>{t.on("element",n,{priority:e.converterPriority||"low"})}}(e))}elementToMarker(e){return this.add(function(e){const t=function(e){return(t,n)=>{const i="string"==typeof e?e:e(t,n);return n.writer.createElement("$marker",{"data-name":i})}}(e.model);return zd({...e,model:t})}(e))}dataToMarker(e){return this.add(function(e){e=jc(e),e.model||(e.model=t=>t?e.view+":"+t:e.view);const t={view:e.view,model:e.model},n=Hd(Wd(t,"start")),i=Hd(Wd(t,"end"));return o=>{o.on(`element:${e.view}-start`,n,{priority:e.converterPriority||"normal"}),o.on(`element:${e.view}-end`,i,{priority:e.converterPriority||"normal"});const r=k.low,s=k.highest,a=k.get(e.converterPriority)/s;o.on("element",function(e){return(t,n,i)=>{const o=`data-${e.view}`;function r(t,o){for(const r of o){const o=e.model(r,i),s=i.writer.createElement("$marker",{"data-name":o});i.writer.insert(s,t),n.modelCursor.isEqual(t)?n.modelCursor=n.modelCursor.getShiftedBy(1):n.modelCursor=n.modelCursor._getTransformedByInsertion(t,1),n.modelRange=n.modelRange._getTransformedByInsertion(t,1)[0]}}(i.consumable.test(n.viewItem,{attributes:o+"-end-after"})||i.consumable.test(n.viewItem,{attributes:o+"-start-after"})||i.consumable.test(n.viewItem,{attributes:o+"-end-before"})||i.consumable.test(n.viewItem,{attributes:o+"-start-before"}))&&(n.modelRange||Object.assign(n,i.convertChildren(n.viewItem,n.modelCursor)),i.consumable.consume(n.viewItem,{attributes:o+"-end-after"})&&r(n.modelRange.end,n.viewItem.getAttribute(o+"-end-after").split(",")),i.consumable.consume(n.viewItem,{attributes:o+"-start-after"})&&r(n.modelRange.end,n.viewItem.getAttribute(o+"-start-after").split(",")),i.consumable.consume(n.viewItem,{attributes:o+"-end-before"})&&r(n.modelRange.start,n.viewItem.getAttribute(o+"-end-before").split(",")),i.consumable.consume(n.viewItem,{attributes:o+"-start-before"})&&r(n.modelRange.start,n.viewItem.getAttribute(o+"-start-before").split(",")))}}(t),{priority:r+a})}}(e))}}function zd(e){const t=Hd(e=jc(e)),n=Fd(e.view),i=n?`element:${n}`:"element";return n=>{n.on(i,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(n,i,o)=>{const r=t.match(i.viewItem);if(!r)return;const s=r.match;if(s.name=!0,!o.consumable.test(i.viewItem,s))return;const a=function(e,t,n){return e instanceof Function?e(t,n):n.writer.createElement(e)}(e.model,i.viewItem,o);a&&o.safeInsert(a,i.modelCursor)&&(o.consumable.consume(i.viewItem,s),o.convertChildren(i.viewItem,a),o.updateConversionResult(a,i))}}function Ud(e,t=null){const n=null===t||(e=>e.getAttribute(t)),i="object"!=typeof e.model?e.model:e.model.key,o="object"!=typeof e.model||void 0===e.model.value?n:e.model.value;e.model={key:i,value:o}}function Zd(e,t){const n=new Hs(e.view);return(i,o,r)=>{if(!o.modelRange&&t)return;const s=n.match(o.viewItem);if(!s)return;if(!function(e,t){const n="function"==typeof e?e(t):e;if("object"==typeof n&&!Fd(n))return!1;return!n.classes&&!n.attributes&&!n.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,n,i){let o=!1;for(const r of Array.from(e.getItems({shallow:n})))i.schema.checkAttribute(r,t.key)&&(o=!0,r.hasAttribute(t.key)||i.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 Wd(e,t){return{view:`${e.view}-${t}`,model:(t,n)=>{const i=t.getAttribute("name"),o=e.model(i,n);return n.writer.createElement("$marker",{"data-name":o})}}}function $d(e){e.document.registerPostFixer((t=>function(e,t){const n=t.document.selection,i=t.schema,o=[];let r=!1;for(const e of n.getRanges()){const t=qd(e,i);t&&!t.isEqual(e)?(o.push(t),r=!0):o.push(e)}r&&e.setSelection(function(e){const t=[...e],n=new Set;let i=1;for(;i!n.has(t)))}(o),{backward:n.isBackward});return!1}(t,e)))}function qd(e,t){return e.isCollapsed?function(e,t){const n=e.start,i=t.getNearestSelectionRange(n);if(!i){const e=n.getAncestors().reverse().find((e=>t.isObject(e)));return e?td._createOn(e):null}if(!i.isCollapsed)return i;const o=i.start;if(n.isEqual(o))return null;return new td(o)}(e,t):function(e,t){const{start:n,end:i}=e,o=t.checkChild(n,"$text"),r=t.checkChild(i,"$text"),s=t.getLimitElement(n),a=t.getLimitElement(i);if(s===a){if(o&&r)return null;if(function(e,t,n){const i=e.nodeAfter&&!n.isLimit(e.nodeAfter)||n.checkChild(e,"$text"),o=t.nodeBefore&&!n.isLimit(t.nodeBefore)||n.checkChild(t,"$text");return i||o}(n,i,t)){const e=n.nodeAfter&&t.isSelectable(n.nodeAfter)?null:t.getNearestSelectionRange(n,"forward"),o=i.nodeBefore&&t.isSelectable(i.nodeBefore)?null:t.getNearestSelectionRange(i,"backward"),r=e?e.start:n,s=o?o.end:i;return new td(r,s)}}const l=s&&!s.is("rootElement"),c=a&&!a.is("rootElement");if(l||c){const e=n.nodeAfter&&i.nodeBefore&&n.nodeAfter.parent===i.nodeBefore.parent,o=l&&(!e||!Kd(n.nodeAfter,t)),r=c&&(!e||!Kd(i.nodeBefore,t));let d=n,u=i;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 n=e,i=n;for(;t.isLimit(i)&&i.parent;)n=i,i=i.parent;return n}function Kd(e,t){return e&&t.isSelectable(e)}class Yd extends(G()){constructor(e,t){super(),this.model=e,this.view=new zc(t),this.mapper=new nd,this.downcastDispatcher=new rd({mapper:this.mapper,schema:e.schema});const n=this.model.document,i=n.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(n,"change",(()=>{this.view.change((e=>{this.downcastDispatcher.convertChanges(n.differ,o,e),this.downcastDispatcher.convertSelection(i,o,e)}))}),{priority:"low"}),this.listenTo(this.view.document,"selectionChange",function(e,t){return(n,i)=>{const o=i.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(!n.consumable.consume(t.item,e.name))return;const i=n.writer,o=n.mapper.toViewPosition(t.range.start),r=i.createText(t.item.data);i.insert(o,r)}),{priority:"lowest"}),this.downcastDispatcher.on("insert",((e,t,n)=>{n.convertAttributes(t.item),t.reconversion||!t.item.is("element")||t.item.isEmpty||n.convertChildren(t.item)}),{priority:"lowest"}),this.downcastDispatcher.on("remove",((e,t,n)=>{const i=n.mapper.toViewPosition(t.position),o=t.position.getShiftedBy(t.length),r=n.mapper.toViewPosition(o,{isPhantom:!0}),s=n.writer.createRange(i,r),a=n.writer.remove(s.getTrimmed());for(const e of n.writer.createRangeIn(a).getItems())n.mapper.unbindViewElement(e,{defer:!0})}),{priority:"low"}),this.downcastDispatcher.on("selection",((e,t,n)=>{const i=n.writer,o=i.document.selection;for(const e of o.getRanges())e.isCollapsed&&e.end.parent.isAttached()&&n.writer.mergeAttributes(e.start);i.setSelection(null)}),{priority:"high"}),this.downcastDispatcher.on("selection",((e,t,n)=>{const i=t.selection;if(i.isCollapsed)return;if(!n.consumable.consume(i,"selection"))return;const o=[];for(const e of i.getRanges())o.push(n.mapper.toViewRange(e));n.writer.setSelection(o,{backward:i.isBackward})}),{priority:"low"}),this.downcastDispatcher.on("selection",((e,t,n)=>{const i=t.selection;if(!i.isCollapsed)return;if(!n.consumable.consume(i,"selection"))return;const o=n.writer,r=i.getFirstPosition(),s=n.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,n=this.model.markers.get(t);if(!n)throw new y("editingcontroller-reconvertmarker-marker-not-exist",this,{markerName:t});this.model.change((()=>{this.model.markers._refresh(n)}))}reconvertItem(e){this.model.change((()=>{this.model.document.differ._refreshItem(e)}))}}class Qd{constructor(){this._consumables=new Map}add(e,t){let n;e.is("$text")||e.is("documentFragment")?this._consumables.set(e,!0):(this._consumables.has(e)?n=this._consumables.get(e):(n=new Xd(e),this._consumables.set(e,n)),n.add(t))}test(e,t){const n=this._consumables.get(e);return void 0===n?null:e.is("$text")||e.is("documentFragment")?n:n.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 n=this._consumables.get(e);void 0!==n&&(e.is("$text")||e.is("documentFragment")?this._consumables.set(e,!0):n.revert(t))}static consumablesFromElement(e){const t={element:e,name:!0,attributes:[],classes:[],styles:[]},n=e.getAttributeKeys();for(const e of n)"style"!=e&&"class"!=e&&t.attributes.push(e);const i=e.getClassNames();for(const e of i)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 n of e.getChildren())t=Qd.createFrom(n,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 n=this._test(t,e[t]);if(!0!==n)return n}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 n=be(t)?t:[t],i=this._consumables[e];for(const t of n){if("attributes"===e&&("class"===t||"style"===t))throw new y("viewconsumable-invalid-attribute",this);if(i.set(t,!0),"styles"===e)for(const e of this.element.document.stylesProcessor.getRelatedStyles(t))i.set(e,!0)}}_test(e,t){const n=be(t)?t:[t],i=this._consumables[e];for(const t of n)if("attributes"!==e||"class"!==t&&"style"!==t){const e=i.get(t);if(void 0===e)return null;if(!e)return!1}else{const e="class"==t?"classes":"styles",n=this._test(e,[...this._consumables[e].keys()]);if(!0!==n)return n}return!0}_consume(e,t){const n=be(t)?t:[t],i=this._consumables[e];for(const t of n)if("attributes"!==e||"class"!==t&&"style"!==t){if(i.set(t,!1),"styles"==e)for(const e of this.element.document.stylesProcessor.getRelatedStyles(t))i.set(e,!1)}else{const e="class"==t?"classes":"styles";this._consume(e,[...this._consumables[e].keys()])}}_revert(e,t){const n=be(t)?t:[t],i=this._consumables[e];for(const t of n)if("attributes"!==e||"class"!==t&&"style"!==t){!1===i.get(t)&&i.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 n=this.getDefinition(e.last);return!!n&&n.allowAttributes.includes(t)}checkMerge(e,t){if(e instanceof Kc){const t=e.nodeBefore,n=e.nodeAfter;if(!(t instanceof $c))throw new y("schema-check-merge-no-element-before",this);if(!(n instanceof $c))throw new y("schema-check-merge-no-element-after",this);return this.checkMerge(t,n)}for(const n of t.getChildren())if(!this.checkChild(e,n))return!1;return!0}addChildCheck(e){this.on("checkChild",((t,[n,i])=>{if(!i)return;const o=e(n,i);"boolean"==typeof o&&(t.stop(),t.return=o)}),{priority:"high"})}addAttributeCheck(e){this.on("checkAttribute",((t,[n,i])=>{const o=e(n,i);"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 n=t.getCommonAncestor();return e?e.getCommonAncestor(n,{includeSelf:!0}):n}),null)}for(;!this.isLimit(t)&&t.parent;)t=t.parent;return t}checkAttributeInSelection(e,t){if(e.isCollapsed){const n=[...e.getFirstPosition().getAncestors(),new Zc("",e.getAttributes())];return this.checkAttribute(n,t)}{const n=e.getRanges();for(const e of n)for(const n of e)if(this.checkAttribute(n.item,t))return!0}return!1}*getValidRanges(e,t){e=function*(e){for(const t of e)yield*t.getMinimalFlatRanges()}(e);for(const n of e)yield*this._getValidRangesForRange(n,t)}getNearestSelectionRange(e,t="both"){if(this.checkChild(e,"$text"))return new td(e);let n,i;const o=e.getAncestors().reverse().find((e=>this.isLimit(e)))||e.root;"both"!=t&&"backward"!=t||(n=new qc({boundaries:td._createIn(o),startPosition:e,direction:"backward"})),"both"!=t&&"forward"!=t||(i=new qc({boundaries:td._createIn(o),startPosition:e}));for(const e of function*(e,t){let n=!1;for(;!n;){if(n=!0,e){const t=e.next();t.done||(n=!1,yield{walker:e,value:t.value})}if(t){const e=t.next();e.done||(n=!1,yield{walker:t,value:e.value})}}}(n,i)){const t=e.walker==n?"elementEnd":"elementStart",i=e.value;if(i.type==t&&this.isObject(i.item))return td._createOn(i.item);if(this.checkChild(i.nextPosition,"$text"))return new td(i.nextPosition)}return null}findAllowedParent(e,t){let n=e.parent;for(;n;){if(this.checkChild(n,t))return n;if(this.isLimit(n))return null;n=n.parent}return null}setAllowedAttributes(e,t,n){const i=n.model;for(const[o,r]of Object.entries(t))i.schema.checkAttribute(e,o)&&n.setAttribute(o,r,e)}removeDisallowedAttributes(e,t){for(const n of e)if(n.is("$text"))fu(this,n,t);else{const e=td._createIn(n).getPositions();for(const n of e){fu(this,n.nodeBefore||n.parent,t)}}}getAttributesWithProperty(e,t,n){const i={};for(const[o,r]of e.getAttributes()){const e=this.getAttributeProperties(o);void 0!==e[t]&&(void 0!==n&&n!==e[t]||(i[o]=r))}return i}createContext(e){return new tu(e)}_clearCache(){this._compiledDefinitions=null}_compile(){const e={},t=this._sourceDefinitions,n=Object.keys(t);for(const i of n)e[i]=nu(t[i],i);for(const t of n)iu(e,t);for(const t of n)ou(e,t);for(const t of n)ru(e,t);for(const t of n)su(e,t),au(e,t);for(const t of n)lu(e,t),cu(e,t),du(e,t);this._compiledDefinitions=e}_checkContextMatch(e,t,n=t.length-1){const i=t.getItem(n);if(e.allowIn.includes(i.name)){if(0==n)return!0;{const e=this.getDefinition(i);return this._checkContextMatch(e,t,n-1)}}return!1}*_getValidRangesForRange(e,t){let n=e.start,i=e.start;for(const o of e.getItems({shallow:!0}))o.is("element")&&(yield*this._getValidRangesForRange(td._createIn(o),t)),this.checkAttribute(o,t)||(n.isEqual(i)||(yield new td(n,i)),n=Kc._createAfter(o)),i=Kc._createAfter(o);n.isEqual(i)||(yield new td(n,i))}}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 nu(e,t){const n={name:t,allowIn:[],allowContentOf:[],allowWhere:[],allowAttributes:[],allowAttributesOf:[],allowChildren:[],inheritTypesFrom:[]};return function(e,t){for(const n of e){const e=Object.keys(n).filter((e=>e.startsWith("is")));for(const i of e)t[i]=!!n[i]}}(e,n),uu(e,n,"allowIn"),uu(e,n,"allowContentOf"),uu(e,n,"allowWhere"),uu(e,n,"allowAttributes"),uu(e,n,"allowAttributesOf"),uu(e,n,"allowChildren"),uu(e,n,"inheritTypesFrom"),function(e,t){for(const n of e){const e=n.inheritAllFrom;e&&(t.allowContentOf.push(e),t.allowWhere.push(e),t.allowAttributesOf.push(e),t.inheritTypesFrom.push(e))}}(e,n),n}function iu(e,t){const n=e[t];for(const i of n.allowChildren){const n=e[i];n&&n.allowIn.push(t)}n.allowChildren.length=0}function ou(e,t){for(const n of e[t].allowContentOf)if(e[n]){hu(e,n).forEach((e=>{e.allowIn.push(t)}))}delete e[t].allowContentOf}function ru(e,t){for(const n of e[t].allowWhere){const i=e[n];if(i){const n=i.allowIn;e[t].allowIn.push(...n)}}delete e[t].allowWhere}function su(e,t){for(const n of e[t].allowAttributesOf){const i=e[n];if(i){const n=i.allowAttributes;e[t].allowAttributes.push(...n)}}delete e[t].allowAttributesOf}function au(e,t){const n=e[t];for(const t of n.inheritTypesFrom){const i=e[t];if(i){const e=Object.keys(i).filter((e=>e.startsWith("is")));for(const t of e)t in n||(n[t]=i[t])}}delete n.inheritTypesFrom}function lu(e,t){const n=e[t],i=n.allowIn.filter((t=>e[t]));n.allowIn=Array.from(new Set(i))}function cu(e,t){const n=e[t];for(const i of n.allowIn){e[i].allowChildren.push(t)}}function du(e,t){const n=e[t];n.allowAttributes=Array.from(new Set(n.allowAttributes))}function uu(e,t,n){for(const i of e){const e=i[n];"string"==typeof e?t[n].push(e):Array.isArray(e)&&t[n].push(...e)}}function hu(e,t){const n=e[t];return(i=e,Object.keys(i).map((e=>i[e]))).filter((e=>e.allowIn.includes(n.name)));var i}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,n){for(const i of t.getAttributeKeys())e.checkAttribute(t,i)||n.removeAttribute(i,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,n=["$root"]){this.fire("viewCleanup",e),this._modelCursor=function(e,t){let n;for(const i of new tu(e)){const e={};for(const t of i.getAttributeKeys())e[t]=i.getAttribute(t);const o=t.createElement(i.name,e);n&&t.insert(o,n),n=Kc._createAt(o,0)}return n}(n,t),this.conversionApi.writer=t,this.conversionApi.consumable=Qd.createFrom(e),this.conversionApi.store={};const{modelRange:i}=this._convertItem(e,this._modelCursor),o=t.createDocumentFragment();if(i){this._removeEmptyElements();for(const e of Array.from(this._modelCursor.parent.getChildren()))t.append(e,o);o.markers=function(e,t){const n=new Set,i=new Map,o=td._createIn(e).getItems();for(const e of o)e.is("element","$marker")&&n.add(e);for(const e of n){const n=e.getAttribute("data-name"),o=t.createPositionBefore(e);i.has(n)?i.get(n).end=o.clone():i.set(n,new td(o.clone())),t.remove(e)}return i}(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 n={viewItem:e,modelCursor:t,modelRange:null};if(e.is("element")?this.fire(`element:${e.name}`,n,this.conversionApi):e.is("$text")?this.fire("text",n,this.conversionApi):this.fire("documentFragment",n,this.conversionApi),n.modelRange&&!(n.modelRange instanceof td))throw new y("view-conversion-dispatcher-incorrect-result",this);return{modelRange:n.modelRange,modelCursor:n.modelCursor}}_convertChildren(e,t){let n=t.is("position")?t:Kc._createAt(t,0);const i=new td(n);for(const t of Array.from(e.getChildren())){const e=this._convertItem(t,n);e.modelRange instanceof td&&(i.end=e.modelRange.end,n=e.modelCursor)}return{modelRange:i,modelCursor:n}}_safeInsert(e,t){const n=this._splitToAllowedParent(e,t);return!!n&&(this.conversionApi.writer.insert(e,n.position),!0)}_updateConversionResult(e,t){const n=this._getSplitParts(e),i=this.conversionApi.writer;t.modelRange||(t.modelRange=i.createRange(i.createPositionBefore(e),i.createPositionAfter(n[n.length-1])));const o=this._cursorParents.get(e);t.modelCursor=o?i.createPositionAt(o,0):t.modelRange.end}_splitToAllowedParent(e,t){const{schema:n,writer:i}=this.conversionApi;let o=n.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,n)?{position:Bd(t,i)}: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(),n=e.item;this._registerSplitPair(t,n)}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 n=this._splitParts.get(e);this._splitParts.set(t,n),n.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"),n=t.createDocumentFragment(),i=t.body.childNodes;for(;i.length>0;)n.appendChild(i[0]);return n}}class wu extends(R()){constructor(e,t){super(),this.model=e,this.mapper=new nd,this.downcastDispatcher=new rd({mapper:this.mapper,schema:e.schema}),this.downcastDispatcher.on("insert:$text",((e,t,n)=>{if(!n.consumable.consume(t.item,e.name))return;const i=n.writer,o=n.mapper.toViewPosition(t.range.start),r=i.createText(t.item.data);i.insert(o,r)}),{priority:"lowest"}),this.downcastDispatcher.on("insert",((e,t,n)=>{n.convertAttributes(t.item),t.reconversion||!t.item.is("element")||t.item.isEmpty||n.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:n,consumable:i,writer:o})=>{let r=t.modelCursor;if(!i.test(t.viewItem))return;if(!n.checkChild(r,"$text")){if(!Ld(r,"$text",n))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))}i.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,n)=>{if(!t.modelRange&&n.consumable.consume(t.viewItem,{name:!0})){const{modelRange:e,modelCursor:i}=n.convertChildren(t.viewItem,t.modelCursor);t.modelRange=e,t.modelCursor=i}}),{priority:"lowest"}),this.upcastDispatcher.on("documentFragment",((e,t,n)=>{if(!t.modelRange&&n.consumable.consume(t.viewItem,{name:!0})){const{modelRange:e,modelCursor:i}=n.convertChildren(t.viewItem,t.modelCursor);t.modelRange=e,t.modelCursor=i}}),{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:n="empty"}=e;if(!this._checkIfRootsExists([t]))throw new y("datacontroller-get-non-existent-root",this);const i=this.model.document.getRoot(t);return i.isAttached()||A("datacontroller-get-detached-root",this),"empty"!==n||this.model.hasContent(i,{ignoreWhitespaces:!0})?this.stringify(i,e):""}stringify(e,t={}){const n=this.toView(e,t);return this.processor.toData(n)}toView(e,t={}){const n=this.viewDocument,i=this._viewWriter;this.mapper.clearBindings();const o=td._createIn(e),r=new wl(n);this.mapper.bindElements(e,r);const s=e.is("documentFragment")?e.markers:function(e){const t=[],n=e.root.document;if(!n)return new Map;const i=td._createIn(e);for(const e of n.model.markers){const n=e.getRange(),o=n.isCollapsed,r=n.start.isEqual(i.start)||n.end.isEqual(i.end);if(o&&r)t.push([e.name,n]);else{const o=i.getIntersection(n);o&&t.push([e.name,o])}}return t.sort((([e,t],[n,i])=>{if("after"!==t.end.compareWith(i.start))return 1;if("before"!==t.start.compareWith(i.end))return-1;switch(t.start.compareWith(i.start)){case"before":return 1;case"after":return-1;default:switch(t.end.compareWith(i.end)){case"before":return 1;case"after":return-1;default:return n.localeCompare(e)}}})),new Map(t)}(e);return this.downcastDispatcher.convert(o,s,i,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 n of Object.keys(t)){const i=this.model.document.getRoot(n);e.insert(this.parse(t[n],i),i,0)}})),Promise.resolve()}set(e,t={}){let n={};if("string"==typeof e?n.main=e:n=e,!this._checkIfRootsExists(Object.keys(n)))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(n)){const i=this.model.document.getRoot(t);e.remove(e.createRangeIn(i)),e.insert(this.parse(n[t],i),i,0)}}))}parse(e,t="$root"){const n=this.processor.toView(e);return this.toModel(n,t)}toModel(e,t="$root"){return this.model.change((n=>this.upcastDispatcher.convert(e,n,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 n=this._downcast.includes(t);if(!this._upcast.includes(t)&&!n)throw new y("conversion-add-alias-dispatcher-not-registered",this);this._createConversionHelpers({name:e,dispatchers:[t],isDowncast:n})}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:n}of _u(e))this.for("upcast").elementToElement({model:t,view:n,converterPriority:e.converterPriority})}attributeToElement(e){this.for("downcast").attributeToElement(e);for(const{model:t,view:n}of _u(e))this.for("upcast").elementToAttribute({view:n,model:t,converterPriority:e.converterPriority})}attributeToAttribute(e){this.for("downcast").attributeToAttribute(e);for(const{model:t,view:n}of _u(e))this.for("upcast").attributeToAttribute({view:n,model:t})}_createConversionHelpers({name:e,dispatchers:t,isDowncast:n}){if(this._helpers.has(e))throw new y("conversion-group-exists",this);const i=n?new Ad(t):new jd(t);this._helpers.set(e,i)}}function*_u(e){if(e.model.values)for(const t of e.model.values){const n={key:e.model.key,value:t},i=e.view[t],o=e.upcastAlso?e.upcastAlso[t]:void 0;yield*vu(n,i,o)}else yield*vu(e.model,e.view,e.upcastAlso)}function*vu(e,t,n){if(yield{model:e,view:t},n)for(const t of Eo(n))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 n=Cu(t),i=n.reduce(((e,t)=>e+t.offsetSize),0),o=e.parent;Tu(e);const r=e.index;return o._insertChild(r,n),Su(o,r+n.length),Su(o,r),new td(e,e.getShiftedBy(i))}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 n=t._removeChildren(e.start.index,e.end.index-e.start.index);return Su(t,e.start.index),n}function Eu(e,t){if(!e.isFlat)throw new y("operation-utils-move-range-not-flat",this);const n=xu(e);return Au(t=t._getTransformedByDeletion(e.start,e.end.offset-e.start.offset),n)}function Cu(e){const t=[];!function e(n){if("string"==typeof n)t.push(new Zc(n));else if(n instanceof Wc)t.push(new Zc(n.data,n.getAttributes()));else if(n instanceof Hc)t.push(n);else if(ie(n))for(const t of n)e(t)}(e);for(let e=1;ee.maxOffset)throw new y("move-operation-nodes-do-not-exist",this);if(e===t&&n=n&&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 n=[];for(const t of e.nodes)t.name?n.push($c.fromJSON(t)):n.push(Zc.fromJSON(t));const i=new Ou(Kc.fromJSON(e.position,t),n,e.baseVersion);return i.shouldReceiveAttributes=e.shouldReceiveAttributes,i}}class Mu extends yu{constructor(e,t,n,i,o){super(o),this.splitPosition=e.clone(),this.splitPosition.stickiness="toNext",this.howMany=t,this.insertionPosition=n,this.graveyardPosition=i?i.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 i=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&&n.aIsStrong&&i.push(new Du(o,t.key,t.newValue,e.newValue,0)),0==i.length?[new Lu(0)]:i}return[e]})),Zu(Du,Ou,((e,t)=>{if(e.range.start.hasSameParentAs(t.position)&&e.range.containsPosition(t.position)){const n=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 i=Qu(t,e.key,e.oldValue);i&&n.unshift(i)}return n}return e.range=e.range._getTransformedByInsertion(t.position,t.howMany,!1)[0],[e]})),Zu(Du,Ru,((e,t)=>{const n=[];e.range.start.hasSameParentAs(t.deletionPosition)&&(e.range.containsPosition(t.deletionPosition)||e.range.start.isEqual(t.deletionPosition))&&n.push(td._createFromPositionAndShift(t.graveyardPosition,1));const i=e.range._getTransformedByMergeOperation(t);return i.isCollapsed||n.push(i),n.map((t=>new Du(t,e.key,e.oldValue,e.newValue,e.baseVersion)))})),Zu(Du,Iu,((e,t)=>{const n=function(e,t){const n=td._createFromPositionAndShift(t.sourcePosition,t.howMany);let i=null,o=[];n.containsRange(e,!0)?i=e:e.start.hasSameParentAs(n.start)?(o=e.getDifference(n),i=e.getIntersection(n)):o=[e];const r=[];for(let e of o){e=e._getTransformedByDeletion(t.sourcePosition,t.howMany);const n=t.getMovedRangeStart(),i=e.start.hasSameParentAs(n),o=e._getTransformedByInsertion(n,t.howMany,i);r.push(...o)}i&&r.push(i._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany,!1)[0]);return r}(e.range,t);return n.map((t=>new Du(t,e.key,e.oldValue,e.newValue,e.baseVersion)))})),Zu(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 n=e.clone();return n.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,n]}return e.range=e.range._getTransformedBySplitOperation(t),[e]})),Zu(Ou,Du,((e,t)=>{const n=[e];if(e.shouldReceiveAttributes&&e.position.hasSameParentAs(t.range.start)&&t.range.containsPosition(e.position)){const i=Qu(e,t.key,t.newValue);i&&n.push(i)}return n})),Zu(Ou,Ou,((e,t,n)=>(e.position.isEqual(t.position)&&n.aIsStrong||(e.position=e.position._getTransformedByInsertOperation(t)),[e]))),Zu(Ou,Iu,((e,t)=>(e.position=e.position._getTransformedByMoveOperation(t),[e]))),Zu(Ou,Mu,((e,t)=>(e.position=e.position._getTransformedBySplitOperation(t),[e]))),Zu(Ou,Ru,((e,t)=>(e.position=e.position._getTransformedByMergeOperation(t),[e]))),Zu(Nu,Ou,((e,t)=>(e.oldRange&&(e.oldRange=e.oldRange._getTransformedByInsertOperation(t)[0]),e.newRange&&(e.newRange=e.newRange._getTransformedByInsertOperation(t)[0]),[e]))),Zu(Nu,Nu,((e,t,n)=>{if(e.name==t.name){if(!n.aIsStrong)return[new Lu(0)];e.oldRange=t.newRange?t.newRange.clone():null}return[e]})),Zu(Nu,Ru,((e,t)=>(e.oldRange&&(e.oldRange=e.oldRange._getTransformedByMergeOperation(t)),e.newRange&&(e.newRange=e.newRange._getTransformedByMergeOperation(t)),[e]))),Zu(Nu,Iu,((e,t,n)=>{if(e.oldRange&&(e.oldRange=td._createFromRanges(e.oldRange._getTransformedByMoveOperation(t))),e.newRange){if(n.abRelation){const i=td._createFromRanges(e.newRange._getTransformedByMoveOperation(t));if("left"==n.abRelation.side&&t.targetPosition.isEqual(e.newRange.start))return e.newRange.end=i.end,e.newRange.start.path=n.abRelation.path,[e];if("right"==n.abRelation.side&&t.targetPosition.isEqual(e.newRange.end))return e.newRange.start=i.start,e.newRange.end.path=n.abRelation.path,[e]}e.newRange=td._createFromRanges(e.newRange._getTransformedByMoveOperation(t))}return[e]})),Zu(Nu,Mu,((e,t,n)=>{if(e.oldRange&&(e.oldRange=e.oldRange._getTransformedBySplitOperation(t)),e.newRange){if(n.abRelation){const i=e.newRange._getTransformedBySplitOperation(t);return e.newRange.start.isEqual(t.splitPosition)&&n.abRelation.wasStartBeforeMergedElement?e.newRange.start=Kc._createAt(t.insertionPosition):e.newRange.start.isEqual(t.splitPosition)&&!n.abRelation.wasInLeftElement&&(e.newRange.start=Kc._createAt(t.moveTargetPosition)),e.newRange.end.isEqual(t.splitPosition)&&n.abRelation.wasInRightElement?e.newRange.end=Kc._createAt(t.moveTargetPosition):e.newRange.end.isEqual(t.splitPosition)&&n.abRelation.wasEndBeforeMergedElement?e.newRange.end=Kc._createAt(t.insertionPosition):e.newRange.end=i.end,[e]}e.newRange=e.newRange._getTransformedBySplitOperation(t)}return[e]})),Zu(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]))),Zu(Ru,Ru,((e,t,n)=>{if(e.sourcePosition.isEqual(t.sourcePosition)&&e.targetPosition.isEqual(t.targetPosition)){if(n.bWasUndone){const n=t.graveyardPosition.path.slice();return n.push(0),e.sourcePosition=new Kc(t.graveyardPosition.root,n),e.howMany=0,[e]}return[new Lu(0)]}if(e.sourcePosition.isEqual(t.sourcePosition)&&!e.targetPosition.isEqual(t.targetPosition)&&!n.bWasUndone&&"splitAtSource"!=n.abRelation){const i="$graveyard"==e.targetPosition.root.rootName,o="$graveyard"==t.targetPosition.root.rootName;if(o&&!i||!(i&&!o)&&n.aIsStrong){const n=t.targetPosition._getTransformedByMergeOperation(t),i=e.targetPosition._getTransformedByMergeOperation(t);return[new Iu(n,e.howMany,i,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)&&n.aIsStrong||(e.graveyardPosition=e.graveyardPosition._getTransformedByMergeOperation(t)),[e]})),Zu(Ru,Iu,((e,t,n)=>{const i=td._createFromPositionAndShift(t.sourcePosition,t.howMany);return"remove"==t.type&&!n.bWasUndone&&!n.forceWeakRemove&&e.deletionPosition.hasSameParentAs(t.sourcePosition)&&i.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])})),Zu(Ru,Mu,((e,t,n)=>{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 i=0!=t.howMany,o=t.graveyardPosition&&e.deletionPosition.isEqual(t.graveyardPosition);if(i||o||"mergeTargetNotMoved"==n.abRelation)return e.sourcePosition=e.sourcePosition._getTransformedBySplitOperation(t),[e]}if(e.sourcePosition.isEqual(t.splitPosition)){if("mergeSourceNotMoved"==n.abRelation)return e.howMany=0,e.targetPosition=e.targetPosition._getTransformedBySplitOperation(t),[e];if("mergeSameElement"==n.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]})),Zu(Iu,Ou,((e,t)=>{const n=td._createFromPositionAndShift(e.sourcePosition,e.howMany)._getTransformedByInsertOperation(t,!1)[0];return e.sourcePosition=n.start,e.howMany=n.end.offset-n.start.offset,e.targetPosition.isEqual(t.position)||(e.targetPosition=e.targetPosition._getTransformedByInsertOperation(t)),[e]})),Zu(Iu,Iu,((e,t,n)=>{const i=td._createFromPositionAndShift(e.sourcePosition,e.howMany),o=td._createFromPositionAndShift(t.sourcePosition,t.howMany);let r,s=n.aIsStrong,a=!n.aIsStrong;if("insertBefore"==n.abRelation||"insertAfter"==n.baRelation?a=!0:"insertAfter"!=n.abRelation&&"insertBefore"!=n.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(i.containsPosition(t.targetPosition)&&i.containsRange(o,!0))return i.start=i.start._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),i.end=i.end._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),Xu([i],r);if(o.containsPosition(e.targetPosition)&&o.containsRange(i,!0))return i.start=i.start._getCombined(t.sourcePosition,t.getMovedRangeStart()),i.end=i.end._getCombined(t.sourcePosition,t.getMovedRangeStart()),Xu([i],r);const l=ne(e.sourcePosition.getParentPath(),t.sourcePosition.getParentPath());if("prefix"==l||"extension"==l)return i.start=i.start._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),i.end=i.end._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),Xu([i],r);"remove"!=e.type||"remove"==t.type||n.aWasUndone||n.forceWeakRemove?"remove"==e.type||"remove"!=t.type||n.bWasUndone||n.forceWeakRemove||(s=!1):s=!0;const c=[],d=i.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 n="same"==ne(e.start.getParentPath(),t.getMovedRangeStart().getParentPath()),i=e._getTransformedByInsertion(t.getMovedRangeStart(),t.howMany,n);c.push(...i)}const u=i.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(i.start)||o.start.isEqual(i.start)?c.unshift(u):c.push(u):c.splice(1,0,u)),0===c.length?[new Lu(e.baseVersion)]:Xu(c,r)})),Zu(Iu,Mu,((e,t,n)=>{let i=e.targetPosition.clone();e.targetPosition.isEqual(t.insertionPosition)&&t.graveyardPosition&&"moveTargetAfter"!=n.abRelation||(i=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=i,[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],i)}e.targetPosition.isEqual(t.splitPosition)&&"insertAtSource"==n.abRelation&&(i=t.moveTargetPosition),e.targetPosition.isEqual(t.insertionPosition)&&"insertBetween"==n.abRelation&&(i=e.targetPosition);const r=[o._getTransformedBySplitOperation(t)];if(t.graveyardPosition){const i=o.start.isEqual(t.graveyardPosition)||o.containsPosition(t.graveyardPosition);e.howMany>1&&i&&!n.aWasUndone&&r.push(td._createFromPositionAndShift(t.insertionPosition,1))}return Xu(r,i)})),Zu(Iu,Ru,((e,t,n)=>{const i=td._createFromPositionAndShift(e.sourcePosition,e.howMany);if(t.deletionPosition.hasSameParentAs(e.sourcePosition)&&i.containsPosition(t.sourcePosition))if("remove"!=e.type||n.forceWeakRemove){if(1==e.howMany)return n.bWasUndone?(e.sourcePosition=t.graveyardPosition.clone(),e.targetPosition=e.targetPosition._getTransformedByMergeOperation(t),[e]):[new Lu(0)]}else if(!n.aWasUndone){const n=[];let i=t.graveyardPosition.clone(),o=t.targetPosition._getTransformedByMergeOperation(t);e.howMany>1&&(n.push(new Iu(e.sourcePosition,e.howMany-1,e.targetPosition,0)),i=i._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(i,1,r,0),a=s.getMovedRangeStart().path.slice();a.push(0);const l=new Kc(s.targetPosition.root,a);o=o._getTransformedByMove(i,r,1);const c=new Iu(o,t.howMany,l,0);return n.push(s),n.push(c),n}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]})),Zu(Bu,Ou,((e,t)=>(e.position=e.position._getTransformedByInsertOperation(t),[e]))),Zu(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]))),Zu(Bu,Iu,((e,t)=>(e.position=e.position._getTransformedByMoveOperation(t),[e]))),Zu(Bu,Bu,((e,t,n)=>{if(e.position.isEqual(t.position)){if(!n.aIsStrong)return[new Lu(0)];e.oldName=t.newName}return[e]})),Zu(Bu,Mu,((e,t)=>{if("same"==ne(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]})),Zu(ju,ju,((e,t,n)=>{if(e.root===t.root&&e.key===t.key){if(!n.aIsStrong||e.newValue===t.newValue)return[new Lu(0)];e.oldValue=t.newValue}return[e]})),Zu(zu,zu,((e,t,n)=>e.rootName!==t.rootName||e.isAdd!==t.isAdd||n.bWasUndone?[e]:[new Lu(0)])),Zu(Mu,Ou,((e,t)=>(e.splitPosition.hasSameParentAs(t.position)&&e.splitPosition.offset{if(!e.graveyardPosition&&!n.bWasUndone&&e.splitPosition.hasSameParentAs(t.sourcePosition)){const n=t.graveyardPosition.path.slice();n.push(0);const i=new Kc(t.graveyardPosition.root,n),o=Mu.getInsertionPosition(new Kc(t.graveyardPosition.root,n)),r=new Mu(i,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]})),Zu(Mu,Iu,((e,t,n)=>{const i=td._createFromPositionAndShift(t.sourcePosition,t.howMany);if(e.graveyardPosition){const o=i.start.isEqual(e.graveyardPosition)||i.containsPosition(e.graveyardPosition);if(!n.bWasUndone&&o){const n=e.splitPosition._getTransformedByMoveOperation(t),i=e.graveyardPosition._getTransformedByMoveOperation(t),o=i.path.slice();o.push(0);const r=new Kc(i.root,o);return[new Iu(n,e.howMany,r,0)]}e.graveyardPosition=e.graveyardPosition._getTransformedByMoveOperation(t)}const o=e.splitPosition.isEqual(t.targetPosition);if(o&&("insertAtSource"==n.baRelation||"splitBefore"==n.abRelation))return e.howMany+=t.howMany,e.splitPosition=e.splitPosition._getTransformedByDeletion(t.sourcePosition,t.howMany),e.insertionPosition=Mu.getInsertionPosition(e.splitPosition),[e];if(o&&n.abRelation&&n.abRelation.howMany){const{howMany:t,offset:i}=n.abRelation;return e.howMany+=t,e.splitPosition=e.splitPosition.getShiftedBy(i),[e]}if(e.splitPosition.hasSameParentAs(t.sourcePosition)&&i.containsPosition(e.splitPosition)){const n=t.howMany-(e.splitPosition.offset-t.sourcePosition.offset);return e.howMany-=n,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"==n.abRelation)return e.howMany=0,e.graveyardPosition=e.graveyardPosition._getTransformedBySplitOperation(t),[e]}if(e.graveyardPosition&&t.graveyardPosition&&e.graveyardPosition.isEqual(t.graveyardPosition)){const i="$graveyard"==e.splitPosition.root.rootName,o="$graveyard"==t.splitPosition.root.rootName;if(o&&!i||!(i&&!o)&&n.aIsStrong){const n=[];return t.howMany&&n.push(new Iu(t.moveTargetPosition,t.howMany,t.splitPosition,0)),e.howMany&&n.push(new Iu(e.splitPosition,e.howMany,e.moveTargetPosition,0)),n}return[new Lu(0)]}if(e.graveyardPosition&&(e.graveyardPosition=e.graveyardPosition._getTransformedBySplitOperation(t)),e.splitPosition.isEqual(t.insertionPosition)&&"splitBefore"==n.abRelation)return e.howMany++,[e];if(t.splitPosition.isEqual(e.insertionPosition)&&"splitBefore"==n.baRelation){const n=t.insertionPosition.path.slice();n.push(0);const i=new Kc(t.insertionPosition.root,n);return[e,new Iu(e.insertionPosition,1,i,0)]}return e.splitPosition.hasSameParentAs(t.splitPosition)&&e.splitPosition.offset{const n=t[0];n.isDocumentOperation&&nh.call(this,n)}),{priority:"low"})}function nh(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 ih{constructor(e={}){"string"==typeof e&&(e="transparent"===e?{isUndoable:!1}:{},A("batch-constructor-deprecated-string-type"));const{isUndoable:t=!0,isLocal:n=!0,isUndo:i=!1,isTyping:o=!1}=e;this.operations=[],this.isUndoable=t,this.isLocal=n,this.isUndo=i,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),n=this._isInInsertedElement(t.targetPosition.parent);e||this._markRemove(t.sourcePosition.parent,t.sourcePosition.offset,t.howMany),n||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 n=t.graveyardPosition.parent;this._markInsert(n,t.graveyardPosition.offset,1);const i=t.targetPosition.parent;this._isInInsertedElement(i)||this._markInsert(i,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,n){const i=this._changedMarkers.get(e);i?(i.newMarkerData=n,null==i.oldMarkerData.range&&null==n.range&&this._changedMarkers.delete(e)):this._changedMarkers.set(e,{newMarkerData:n,oldMarkerData:t})}getMarkersToRemove(){const e=[];for(const[t,n]of this._changedMarkers)null!=n.oldMarkerData.range&&e.push({name:t,range:n.oldMarkerData.range});return e}getMarkersToAdd(){const e=[];for(const[t,n]of this._changedMarkers)null!=n.newMarkerData.range&&e.push({name:t,range:n.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 n=e.range&&!t.range,i=!e.range&&t.range,o=e.range&&t.range&&!e.range.isEqual(t.range);if(n||i||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 n=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 n=this._changedRoots.get(e);void 0!==n.state?(delete n.state,void 0===n.attributes&&this._changedRoots.delete(e)):n.state=t?"attached":"detached"}_bufferRootAttributeChange(e,t,n,i){const o=this._changedRoots.get(e)||{name:e},r=o.attributes||{};if(r[t]){const e=r[t];i===e.oldValue?delete r[t]:e.newValue=i}else r[t]={oldValue:n,newValue:i};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,n){const i={type:"insert",offset:t,howMany:n,count:this._changeCount++};this._markChange(e,i)}_markRemove(e,t,n){const i={type:"remove",offset:t,howMany:n,count:this._changeCount++};this._markChange(e,i),this._removeAllNestedChanges(e,t,n)}_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 n=this._getChangesForElement(e);this._handleChange(t,n),n.push(t);for(let e=0;en.offset){if(i>o){const e={type:"attribute",offset:o,howMany:i-o,count:this._changeCount++};this._handleChange(e,t),t.push(e)}e.nodesToHandle=n.offset-e.offset,e.howMany=e.nodesToHandle}else e.offset>=n.offset&&e.offseto?(e.nodesToHandle=i-o,e.offset=o):e.nodesToHandle=0);if("remove"==n.type&&e.offsetn.offset){const o={type:"attribute",offset:n.offset,howMany:i-n.offset,count:this._changeCount++};this._handleChange(o,t),t.push(o),e.nodesToHandle=n.offset-e.offset,e.howMany=e.nodesToHandle}"attribute"==n.type&&(e.offset>=n.offset&&i<=o?(e.nodesToHandle=0,e.howMany=0,e.offset=0):e.offset<=n.offset&&i>=o&&(n.howMany=0))}}e.howMany=e.nodesToHandle,delete e.nodesToHandle}_getInsertDiff(e,t,n){return{type:"insert",position:Kc._createAt(e,t),name:n.name,attributes:new Map(n.attributes),length:1,changeCount:this._changeCount++}}_getRemoveDiff(e,t,n){return{type:"remove",position:Kc._createAt(e,t),name:n.name,attributes:new Map(n.attributes),length:1,changeCount:this._changeCount++}}_getAttributesDiff(e,t,n){const i=[];n=new Map(n);for(const[o,r]of t){const t=n.has(o)?n.get(o):null;t!==r&&i.push({type:"attribute",position:e.start,range:e.clone(),length:1,attributeKey:o,attributeOldValue:r,attributeNewValue:t,changeCount:this._changeCount++}),n.delete(o)}for(const[t,o]of n)i.push({type:"attribute",position:e.start,range:e.clone(),length:1,attributeKey:t,attributeOldValue:null,attributeNewValue:o,changeCount:this._changeCount++});return i}_isInInsertedElement(e){const t=e.parent;if(!t)return!1;const n=this._changesInElement.get(t),i=e.startOffset;if(n)for(const e of n)if("insert"==e.type&&i>=e.offset&&ii){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 n=this._operations[0];void 0===e&&(e=n.baseVersion);let i=t-1;for(const[t,n]of this._gaps)e>t&&et&&ithis.lastOperation.baseVersion)return[];let o=this._baseVersionToOperationIndex.get(e);void 0===o&&(o=0);let r=this._baseVersionToOperationIndex.get(i);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,n="main"){super(t),this._isAttached=!0,this._document=e,this.rootName=n}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 n=t[0];n.isDocumentOperation&&this.differ.bufferOperation(n)}),{priority:"high"}),this.listenTo(e,"applyOperation",((e,t)=>{const n=t[0];n.isDocumentOperation&&this.history.addOperation(n)}),{priority:"low"}),this.listenTo(this.selection,"change",(()=>{this._hasSelectionChangedFromTheLastChangeBlock=!0})),this.listenTo(e.markers,"update",((e,t,n,i,o)=>{const r={...t.getData(),range:i};this.differ.bufferMarkerChange(t.name,o,r),null===n&&t.on("change",((e,n)=>{const i=t.getData();this.differ.bufferMarkerChange(t.name,{...i,range:n},i)}))})),this.registerPostFixer((e=>{let t=!1;for(const n of this.roots)n.isAttached()||n.isEmpty||(e.remove(e.createRangeIn(n)),t=!0);for(const n of this.model.markers)n.getRange().root.isAttached()||(e.removeMarker(n),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 n=new ch(this,e,t);return this.roots.add(n),n}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,n=t.schema,i=t.createPositionFromPath(e,[0]);return n.getNearestSelectionRange(i)||t.createRange(i)}_validateSelectionRange(e){return hh(e.start)&&hh(e.end)}_callPostFixers(e){let t=!1;do{for(const n of this._postFixers)if(this.selection.refresh(),t=n(e),t)break}while(t)}}function hh(e){const t=e.textNode;if(t){const n=t.data,i=e.offset-t.startOffset;return!No(n,i)&&!Vo(n,i)}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,n=!1,i=!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),n!=r.managedUsingOperations&&(r._managedUsingOperations=n,a=!0),"boolean"==typeof i&&i!=r.affectsData&&(r._affectsData=i,a=!0),a&&this.fire(`update:${o}`,r,s,t,e),r}const s=gd.fromRange(t),a=new fh(o,s,n,i);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,n=this._markers.get(t);return!!n&&(this._markers.delete(t),this.fire(`update:${t}`,n,n.getRange(),null,n.getData()),this._destroyMarker(n),!0)}_refresh(e){const t=e instanceof fh?e.name:e,n=this._markers.get(t);if(!n)throw new y("markercollection-refresh-marker-not-exists",this);const i=n.getRange();this.fire(`update:${t}`,n,i,i,n.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,n,i){super(),this.name=e,this._liveRange=this._attachLiveRange(t),this._managedUsingOperations=n,this._affectsData=i}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 n of e)t=t.getChild(t.offsetToIndex(n));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 n of e)n.name?t.push($c.fromJSON(n)):t.push(Zc.fromJSON(n));return new ph(t)}_appendChild(e){this._insertChild(this.childCount,e)}_insertChild(e,t){const n=function(e){if("string"==typeof e)return[new Zc(e)];ie(e)||(e=[e]);return Array.from(e).map((e=>"string"==typeof e?new Zc(e):e instanceof Wc?new Zc(e.data,e.getAttributes()):e))}(t);for(const e of n)null!==e.parent&&e._remove(),e.parent=this;this._children._insertNodes(e,n)}_removeChildren(e,t=1){const n=this._children._removeNodes(e,t);for(const e of n)e.parent=null;return n}}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 Zc(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,n=0){if(this._assertWriterUsedCorrectly(),e instanceof Zc&&""==e.data)return;const i=Kc._createAt(t,n);if(e.parent){if(yh(e.root,i.root))return void this.move(td._createOn(e),i);if(e.root.document)throw new y("model-writer-insert-forbidden-move",this);this.remove(e)}const o=i.root.document?i.root.document.version:null,r=new Ou(i,e,o);if(e instanceof Zc&&(r.shouldReceiveAttributes=!0),this.batch.addOperation(r),this.model.applyOperation(r),e instanceof ph)for(const[t,n]of e.markers){const e=Kc._createAt(n.root,0),o={range:new td(n.start._getCombined(e,i),n.end._getCombined(e,i)),usingOperation:!0,affectsData:!0};this.model.markers.has(t)?this.updateMarker(t,o):this.addMarker(t,o)}}insertText(e,t,n,i){t instanceof ph||t instanceof $c||t instanceof Kc?this.insert(this.createText(e),t,n):this.insert(this.createText(e,t),n,i)}insertElement(e,t,n,i){t instanceof ph||t instanceof $c||t instanceof Kc?this.insert(this.createElement(e),t,n):this.insert(this.createElement(e,t),n,i)}append(e,t){this.insert(e,t,"end")}appendText(e,t,n){t instanceof ph||t instanceof $c?this.insert(this.createText(e),t,"end"):this.insert(this.createText(e,t),n,"end")}appendElement(e,t,n){t instanceof ph||t instanceof $c?this.insert(this.createElement(e),t,"end"):this.insert(this.createElement(e,t),n,"end")}setAttribute(e,t,n){if(this._assertWriterUsedCorrectly(),n instanceof td){const i=n.getMinimalFlatRanges();for(const n of i)wh(this,e,t,n)}else kh(this,e,t,n)}setAttributes(e,t){for(const[n,i]of Mo(e))this.setAttribute(n,i,t)}removeAttribute(e,t){if(this._assertWriterUsedCorrectly(),t instanceof td){const n=t.getMinimalFlatRanges();for(const t of n)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 n of e.getItems())t(n);else t(e)}move(e,t,n){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 i=Kc._createAt(t,n);if(i.isEqual(e.start))return;if(this._addOperationForAffectedMarkers("move",e),!yh(e.root,i.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,i,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,n=e.nodeAfter;if(this._addOperationForAffectedMarkers("merge",e),!(t instanceof $c))throw new y("writer-merge-no-element-before",this);if(!(n instanceof $c))throw new y("writer-merge-no-element-after",this);e.root.document?this._merge(e):this._mergeDetached(e)}createPositionFromPath(e,t,n){return this.model.createPositionFromPath(e,t,n)}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,n=e.nodeAfter;this.move(td._createIn(n),Kc._createAt(t,"end")),this.remove(n)}_merge(e){const t=Kc._createAt(e.nodeBefore,"end"),n=Kc._createAt(e.nodeAfter,0),i=e.root.document.graveyard,o=new Kc(i,[0]),r=e.root.document.version,s=new Ru(n,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 n=e.root.document?e.root.document.version:null,i=new Bu(Kc._createBefore(e),e.name,t,n);this.batch.addOperation(i),this.model.applyOperation(i)}split(e,t){this._assertWriterUsedCorrectly();let n,i,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),n||i||(n=o,i=e.parent.nextSibling),o=(e=this.createPositionAfter(e.parent)).parent}while(o!==t);return{position:e,range:new td(Kc._createAt(n,"end"),Kc._createAt(i,0))}}wrap(e,t){if(this._assertWriterUsedCorrectly(),!e.isFlat)throw new y("writer-wrap-range-not-flat",this);const n=t instanceof $c?t:new $c(t);if(n.childCount>0)throw new y("writer-wrap-element-not-empty",this);if(null!==n.parent)throw new y("writer-wrap-element-attached",this);this.insert(n,e.start);const i=new td(e.start.getShiftedBy(1),e.end.getShiftedBy(1));this.move(i,Kc._createAt(n,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 n=t.usingOperation,i=t.range,o=void 0!==t.affectsData&&t.affectsData;if(this.model.markers.has(e))throw new y("writer-addmarker-marker-exists",this);if(!i)throw new y("writer-addmarker-no-range",this);return n?(_h(this,e,null,i,o),this.model.markers.get(e)):this.model.markers._set(e,i,n,o)}updateMarker(e,t){this._assertWriterUsedCorrectly();const n="string"==typeof e?e:e.name,i=this.model.markers.get(n);if(!i)throw new y("writer-updatemarker-marker-not-exists",this);if(!t)return A("writer-updatemarker-reconvert-using-editingcontroller",{markerName:n}),void this.model.markers._refresh(i);const o="boolean"==typeof t.usingOperation,r="boolean"==typeof t.affectsData,s=r?t.affectsData:i.affectsData;if(!o&&!t.range&&!r)throw new y("writer-updatemarker-wrong-options",this);const a=i.getRange(),l=t.range?t.range:a;o&&t.usingOperation!==i.managedUsingOperations?t.usingOperation?_h(this,n,null,l,s):(_h(this,n,a,null,s),this.model.markers._set(n,l,void 0,s)):i.managedUsingOperations?_h(this,n,a,l,s):this.model.markers._set(n,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 n=this.model.markers.get(t);if(!n.managedUsingOperations)return void this.model.markers._remove(t);_h(this,t,n.getRange(),null,n.affectsData)}addRoot(e,t="$root"){this._assertWriterUsedCorrectly();const n=this.model.document.getRoot(e);if(n&&n.isAttached())throw new y("writer-addroot-root-exists",this);const i=this.model.document,o=new zu(e,t,!0,i,i.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 n=this.model.document,i=new zu(t.rootName,t.name,!1,n,n.version);this.batch.addOperation(i),this.model.applyOperation(i)}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,n]of Mo(e))this._setSelectionAttribute(t,n)}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 n=this.model.document.selection;if(n.isCollapsed&&n.anchor.parent.isEmpty){const i=kd._getStoreAttributeKey(e);this.setAttribute(i,t,n.anchor.parent)}n._setAttribute(e,t)}_removeSelectionAttribute(e){const t=this.model.document.selection;if(t.isCollapsed&&t.anchor.parent.isEmpty){const n=kd._getStoreAttributeKey(e);this.removeAttribute(n,t.anchor.parent)}t._removeAttribute(e)}_assertWriterUsedCorrectly(){if(this.model._currentWriter!==this)throw new y("writer-incorrect-use",this)}_addOperationForAffectedMarkers(e,t){for(const n of this.model.markers){if(!n.managedUsingOperations)continue;const i=n.getRange();let o=!1;if("move"===e){const e=t;o=e.containsPosition(i.start)||e.start.isEqual(i.start)||e.containsPosition(i.end)||e.end.isEqual(i.end)}else{const e=t,n=e.nodeBefore,r=e.nodeAfter,s=i.start.parent==n&&i.start.isAtEnd,a=i.end.parent==r&&0==i.end.offset,l=i.end.nodeAfter==r,c=i.start.nodeAfter==r;o=s||a||l||c}o&&this.updateMarker(n.name,{range:i})}}}function wh(e,t,n,i){const o=e.model,r=o.document;let s,a,l,c=i.start;for(const e of i.getWalker({shallow:!0}))l=e.item.getAttribute(t),s&&a!=l&&(a!=n&&d(),c=s),s=e.nextPosition,a=l;function d(){const i=new td(c,s),l=i.root.document?r.version:null,d=new Du(i,t,a,n,l);e.batch.addOperation(d),o.applyOperation(d)}s instanceof Kc&&s!=c&&a!=n&&d()}function kh(e,t,n,i){const o=e.model,r=o.document,s=i.getAttribute(t);let a,l;if(s!=n){if(i.root===i){const e=i.document?r.version:null;l=new ju(i,t,s,n,e)}else{a=new td(Kc._createBefore(i),e.createPositionAfter(i));const o=a.root.document?r.version:null;l=new Du(a,t,s,n,o)}e.batch.addOperation(l),o.applyOperation(l)}}function _h(e,t,n,i,o){const r=e.model,s=r.document,a=new Nu(t,n,i,r.markers,!!o,s.version);e.batch.addOperation(a),r.applyOperation(a)}function vh(e,t,n,i){let o;if(e.root.document){const n=i.document,r=new Kc(n.graveyard,[0]);o=new Iu(e,t,r,n.version)}else o=new gh(e,t);n.addOperation(o),i.applyOperation(o)}function yh(e,t){return e===t||e instanceof ch&&t instanceof ch}function Ah(e,t,n={}){if(t.isCollapsed)return;const i=t.getFirstRange();if("$graveyard"==i.root.rootName)return;const o=e.schema;e.change((e=>{if(!n.doNotResetEntireContent&&function(e,t){const n=e.getLimitElement(t);if(!t.containsEntireContent(n))return!1;const i=t.getFirstRange();if(i.start.parent==i.end.parent)return!1;return e.checkChild(n,"paragraph")}(o,t))return void function(e,t){const n=e.model.schema.getLimitElement(t);e.remove(e.createRangeIn(n)),Sh(e,e.createPositionAt(n,0),t)}(e,t);const r={};if(!n.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,n=e.start;let i=e.end;if(t.hasContent(e,{ignoreMarkers:!0})){const n=function(e){const t=e.parent,n=t.root.document.model.schema,i=t.getAncestors({parentFirst:!0,includeSelf:!0});for(const e of i){if(n.isLimit(e))return null;if(n.isBlock(e))return e}}(i);if(n&&i.isTouching(t.createPositionAt(n,0))){const n=t.createSelection(e);t.modifySelection(n,{direction:"backward"});const o=n.getLastPosition(),r=t.createRange(o,i);t.hasContent(r,{ignoreMarkers:!0})||(i=o)}}return[eh.fromPosition(n,"toPrevious"),eh.fromPosition(i,"toNext")]}(i);s.isTouching(a)||e.remove(e.createRange(s,a)),n.leaveUnmerged||(!function(e,t,n){const i=e.model;if(!Ch(e.model.schema,t,n))return;const[o,r]=function(e,t){const n=e.getAncestors(),i=t.getAncestors();let o=0;for(;n[o]&&n[o]==i[o];)o++;return[n[o],i[o]]}(t,n);if(!o||!r)return;!i.hasContent(o,{ignoreMarkers:!0})&&i.hasContent(r,{ignoreMarkers:!0})?Eh(e,t,n,o.parent):xh(e,t,n,o.parent)}(e,s,a),o.removeDisallowedAttributes(s.parent.getChildren(),e)),Th(e,t,s),!n.doNotAutoparagraph&&function(e,t){const n=e.checkChild(t,"$text"),i=e.checkChild(t,"paragraph");return!n&&i}(o,s)&&Sh(e,s,t,r),s.detach(),a.detach()}))}function xh(e,t,n,i){const o=t.parent,r=n.parent;if(o!=i&&r!=i){for(t=e.createPositionAfter(o),(n=e.createPositionBefore(r)).isEqual(t)||e.insert(r,t),e.merge(t);n.parent.isEmpty;){const t=n.parent;n=e.createPositionBefore(t),e.remove(t)}Ch(e.model.schema,t,n)&&xh(e,t,n,i)}}function Eh(e,t,n,i){const o=t.parent,r=n.parent;if(o!=i&&r!=i){for(t=e.createPositionAfter(o),(n=e.createPositionBefore(r)).isEqual(t)||e.insert(o,n);t.parent.isEmpty;){const n=t.parent;t=e.createPositionBefore(n),e.remove(n)}n=e.createPositionBefore(r),function(e,t){const n=t.nodeBefore,i=t.nodeAfter;n.name!=i.name&&e.rename(n,i.name);e.clearAttributes(n),e.setAttributes(Object.fromEntries(i.getAttributes()),n),e.merge(t)}(e,n),Ch(e.model.schema,t,n)&&Eh(e,t,n,i)}}function Ch(e,t,n){const i=t.parent,o=n.parent;return i!=o&&(!e.isLimit(i)&&!e.isLimit(o)&&function(e,t,n){const i=new td(e,t);for(const e of i.getWalker())if(n.isLimit(e.item))return!1;return!0}(t,n,e))}function Sh(e,t,n,i={}){const o=e.createElement("paragraph");e.model.schema.setAllowedAttributes(o,i,e),e.insert(o,t),Th(e,n,e.createPositionAt(o,0))}function Th(e,t,n){t instanceof kd?e.setSelection(n):t.setTo(n)}function Ph(e,t){const n=[];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=>{n.push(e.start.parent),t.remove(e)})),n.forEach((e=>{let n=e;for(;n.parent&&n.isEmpty;){const e=t.createRangeOn(n);n=n.parent,t.remove(e)}}))}class Ih{constructor(e,t,n){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=n,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),n=this.writer.createPositionAfter(e);if(n.isAfter(t)){if(this._lastNode=e,this.position.parent!=e||!this.position.isAtEnd)throw new y("insertcontent-invalid-insertion-position",this);this.position=n,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 n=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=n.toPosition(),n.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 n=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=n.toPosition(),n.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,n="auto"){const i=e.getSelectedElement();if(i&&t.schema.isObject(i)&&!t.schema.isInline(i))return"before"==n||"after"==n?t.createRange(t.createPositionAt(i,n)):t.createRangeOn(i);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,n,i={}){if(!e.schema.isObject(t))throw new y("insertobject-element-not-an-object",e,{object:t});const o=n||e.document.selection;let r=o;i.findOptimalPosition&&e.schema.isBlock(t)&&(r=e.createSelection(Oh(o,e,i.findOptimalPosition)));const s=Po(o.getSelectedBlocks()),a={};return s&&Object.assign(a,e.schema.getAttributesWithProperty(s,"copyOnReplace",!0)),e.change((n=>{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=n.createElement("paragraph"),n.insert(t,o)),e.schema.setAllowedAttributes(o,a,n);const l=e.insertContent(o,r);return l.isCollapsed||i.setSelection&&function(e,t,n,i){const o=e.model;if("on"==n)return void e.setSelection(t,"on");if("after"!=n)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,i,e),o.insertContent(r,e.createPositionAfter(t)));r&&e.setSelection(r,0)}(n,t,i.setSelection,a),l}))}const Rh=' ,.?!:;"-()';function Nh(e,t){const{isForward:n,walker:i,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 n=e.position.textNode;n||(n=t?e.position.nodeAfter:e.position.nodeBefore);for(;n&&n.is("$text");){const i=e.position.offset-n.startOffset;if(Lh(n,i,t))n=t?e.position.nodeAfter:e.position.nodeBefore;else{if(Dh(n.data,i,t))break;e.next()}}return e.position}(i,n):function(e,t,n){const i=e.position.textNode;if(i){const o=i.data;let r=e.position.offset-i.startOffset;for(;No(o,r)||"character"==t&&Vo(o,r)||n&&Lo(o,r);)e.next(),r=e.position.offset-i.startOffset}return e.position}(i,o,s);if(a==(n?"elementStart":"elementEnd")){if(r.isSelectable(l))return Kc._createAt(l,n?"after":"before");if(r.checkChild(c,"$text"))return c}else{if(r.isLimit(l))return void i.skip((()=>!0));if(r.checkChild(c,"$text"))return c}}function Vh(e,t){const n=e.root,i=Kc._createAt(n,t?"end":0);return t?new td(e,i):new td(i,e)}function Dh(e,t,n){const i=t+(n?0:-1);return Rh.includes(e.charAt(i))}function Lh(e,t,n){return t===(n?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,n])=>{e.return=function(e,t,n){return e.change((i=>{const o=n||e.document.selection;o.isCollapsed||e.deleteContent(o,{doNotAutoparagraph:!0});const r=new Ih(e,i,o.anchor),s=[];let a;if(t.is("documentFragment")){if(t.markers.size){const e=[];for(const[n,i]of t.markers){const{start:t,end:o}=i,r=t.isEqual(o);e.push({position:t,name:n,isCollapsed:r},{position:o,name:n,isCollapsed:r})}e.sort((({position:e},{position:t})=>e.isBefore(t)?1:-1));for(const{position:n,name:o,isCollapsed:r}of e){let e=null,a=null;const l=n.parent===t&&n.isAtStart,c=n.parent===t&&n.isAtEnd;l||c?r&&(a=l?"start":"end"):(e=i.createElement("$marker"),i.insert(e,n)),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:n,element:o,collapsed:a}=s[e],l=!t[n];if(l&&(t[n]=[]),o){const e=i.createPositionAt(o,"before");t[n].push(e),i.remove(o)}else{const e=r.getAffectedRange();if(!e){a&&t[n].push(r.position);continue}a?t[n].push(e[a]):t[n].push(l?e.start:e.end)}}for(const[e,[n,o]]of Object.entries(t))n&&o&&n.root===o.root&&i.addMarker(e,{usingOperation:!0,affectsData:!0,range:new td(n,o)});e&&(l=e.toRange(),e.detach())}l&&(o instanceof kd?i.setSelection(l):o.setTo(l));const c=r.getAffectedRange()||e.createRange(o.anchor);return r.destroy(),c}))}(this,t,n)})),this.on("insertObject",((e,[t,n,i])=>{e.return=Mh(this,t,n,i)})),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 ih,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 ih):e instanceof ih||(e=new ih(e)):e=new ih,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,n,...i){const o=jh(t,n);return this.fire("insertContent",[e,o,n,...i])}insertObject(e,t,n,i,...o){const r=jh(t,n);return this.fire("insertObject",[e,r,i,i,...o])}deleteContent(e,t){Ah(this,e,t)}modifySelection(e,t){!function(e,t,n={}){const i=e.schema,o="backward"!=n.direction,r=n.unit?n.unit:"character",s=!!n.treatEmojiAsSingleUnit,a=t.focus,l=new qc({boundaries:Vh(a,o),singleCharacters:!0,direction:o?"forward":"backward"}),c={walker:l,schema:i,isForward:o,unit:r,treatEmojiAsSingleUnit:s};let d;for(;d=l.next();){if(d.done)return;const n=Nh(c,d.value);if(n)return void(t instanceof kd?e.change((e=>{e.setSelectionFocus(n)})):t.setFocus(n))}}(this,e,t)}getSelectedContent(e){return function(e,t){return e.change((e=>{const n=e.createDocumentFragment(),i=t.getFirstRange();if(!i||i.isCollapsed)return n;const o=i.start.root,r=i.start.getCommonPath(i.end),s=o.getNodeByPath(r);let a;a=i.start.parent==i.end.parent?i:e.createRange(e.createPositionAt(s,i.start.path[r.length]),e.createPositionAt(s,i.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(),n):e.append(e.cloneElement(t,!0),n);if(a!=i){const t=i._getTransformedByMove(a.start,e.createPositionAt(n,0),l)[0],o=e.createRange(e.createPositionAt(n,0),t.start);Ph(e.createRange(t.end,e.createPositionAt(n,"end")),e),Ph(o,e)}return n}))}(this,e)}hasContent(e,t={}){const n=e instanceof td?e:td._createIn(e);if(n.isCollapsed)return!1;const{ignoreWhitespaces:i=!1,ignoreMarkers:o=!1}=t;if(!o)for(const e of this.markers.getMarkersIntersectingRange(n))if(e.affectsData)return!0;for(const e of n.getItems())if(this.schema.isContent(e)){if(!e.is("$textProxy"))return!0;if(!i)return!0;if(-1!==e.data.search(/\S/))return!0}return!1}canEditAt(e){const t=jh(e);return this.fire("canEditAt",[t])}createPositionFromPath(e,t,n){return new Kc(e,t,n)}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 ih(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 n=this._pendingChanges[0].callback(this._currentWriter);e.push(n),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 jh(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 zh 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,n){return new Fa(this.document,e,t,n)}createText(e){return new zs(this.document,e)}clone(e,t=!1){return e._clone(t)}appendChild(e,t){return t._appendChild(e)}insertChild(e,t,n){return n._insertChild(e,t)}removeChildren(e,t,n){return n._removeChildren(e,t)}remove(e){const t=e.parent;return t?this.removeChildren(t.getChildIndex(e),1,t):[]}replace(e,t){const n=e.parent;if(n){const i=n.getChildIndex(e);return this.removeChildren(i,1,n),this.insertChild(i,t,n),!0}return!1}unwrapElement(e){const t=e.parent;if(t){const n=t.getChildIndex(e);this.remove(e),this.insertChild(n,e.getChildren(),t)}}rename(e,t){const n=new Fa(this.document,e,t.getAttributes(),t.getChildren());return this.replace(t,n)?n:null}setAttribute(e,t,n){n._setAttribute(e,t)}removeAttribute(e,t){t._removeAttribute(e)}addClass(e,t){t._addClass(e)}removeClass(e,t){t._removeClass(e)}setStyle(e,t,n){Te(e)&&void 0===n?t._setStyle(e):n._setStyle(e,t)}removeStyle(e,t){t._removeStyle(e)}setCustomProperty(e,t,n){n._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,Zh=/^rgb\([ ]?([0-9]{1,3}[ %]?,[ ]?){2,3}[0-9]{1,3}[ %]?\)$/i,Wh=/^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")?Zh.test(e)||Wh.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 nm(e){return tm.includes(e)}const im=["fixed","scroll","local"];function om(e){return im.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),n=t[0],i=t[2]||n,o=t[1]||n;return{top:n,bottom:i,right:o,left:t[3]||o}}function lm({top:e,right:t,bottom:n,left:i}){const o=[];return i!==t?o.push(e,t,n,i):n!==e?o.push(e,t,n):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={},n=cm(e);for(const e of n)em(e)?(t.repeat=t.repeat||[],t.repeat.push(e)):nm(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,n;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",(n="margin",e=>{const{top:t,right:i,bottom:o,left:r}=e,s=[];return[t,i,r,o].every((e=>!!e))?s.push([n,lm(e)]):(t&&s.push([n+"-top",t]),i&&s.push([n+"-right",i]),o&&s.push([n+"-bottom",o]),r&&s.push([n+"-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 n=this.get(e);if(!n)throw new y("commandcollection-command-not-found",this,{commandName:e});return n.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,n={}){if("string"==typeof t){const e=t;t=(t,n)=>{this.editor.execute(e),n()}}super.set(e,t,n)}}class fm extends(G()){constructor(e={}){super();const t=this.constructor,n=e.language||t.defaultConfig&&t.defaultConfig.language;this._context=e.context||new Ss({language:n}),this._context._addEditor(this,!e.context);const i=Array.from(t.builtinPlugins||[]);this.config=new Ci(e,t.defaultConfig),this.config.define("plugins",i),this.config.define(this._context._getEditorConfig()),this.plugins=new Cs(this,i,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"),n=e.get("removePlugins")||[],i=e.get("extraPlugins")||[],o=e.get("substitutePlugins")||[];return this.plugins.init(t.concat(i),n,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"),n=this.sourceElement instanceof HTMLTextAreaElement;Gi(this.sourceElement,t||n?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=n(7343),ym={attributes:{"data-cke":!0}};ym.setAttributes=$o(),ym.insert=Zo().bind(null,"head"),ym.domAPI=Ho(),ym.insertStyleElement=Go();zo()(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 n=this.bindTemplate,i=this.t;this.options=t||{},this.set("ariaLabel",i("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",n.to("class"),n.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":n.to("ariaLabel"),style:{maxWidth:n.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,n){this.items.addMany(this._buildItemsFromConfig(e,t,n))}_buildItemsFromConfig(e,t,n){const i=_s(e),o=n||i.removeItems;return this._cleanItemsConfiguration(i.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,n){const i=e.filter(((e,i,o)=>"|"===e||-1===n.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(i)}_cleanSeparatorsAndLineBreaks(e){const t=e=>"-"!==e&&"|"!==e,n=e.length,i=e.findIndex(t);if(-1===i)return[];const o=n-e.slice().reverse().findIndex(t);return e.slice(i,o).filter(((e,n,i)=>{if(t(e))return!0;return!(n>0&&i[n-1]===e)}))}_createNestedToolbarDropdown(e,t,n){let{label:i,icon:o,items:r,tooltip:s=!0,withText:a=!1}=e;if(r=this._cleanItemsConfiguration(r,t,n),!r.length)return null;const l=Fm(this.locale);return i||A("toolbarview-nested-toolbar-dropdown-missing-label",e),l.class="ck-toolbar__nested-toolbar-dropdown",l.buttonView.set({label:i,tooltip:s,withText:!!a}),!1!==o?l.buttonView.icon=xm[o]||o||Am:l.buttonView.withText=!0,Hm(l,(()=>l.toolbarView._buildItemsFromConfig(r,t,n))),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 n=t.index,i=Array.from(t.added);for(const e of t.removed)n>=this.ungroupedItems.length?this.groupedItems.remove(e):this.ungroupedItems.remove(e);for(let e=n;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,n=new Hi(e.lastChild),i=new Hi(e);if(!this.cachedPadding){const n=Di.window.getComputedStyle(e),i="ltr"===t?"paddingRight":"paddingLeft";this.cachedPadding=Number.parseInt(n[i])}return"ltr"===t?n.right>i.right-this.cachedPadding:n.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,n=Fm(e);return n.class="ck-toolbar__grouped-dropdown",n.panelPosition="ltr"===e.uiLanguageDirection?"sw":"se",Hm(n,this.groupedItems),n.buttonView.set({label:t("Show more items"),tooltip:!0,tooltipPosition:"rtl"===e.uiLanguageDirection?"se":"sw",icon:Am}),n}_updateFocusCycleableItems(){this.viewFocusables.clear(),this.ungroupedItems.map((e=>{this.viewFocusables.add(e)})),this.groupedItems.length&&this.viewFocusables.add(this.groupedItemsDropdown)}}var Pm=n(9647),Im={attributes:{"data-cke":!0}};Im.setAttributes=$o(),Im.insert=Zo().bind(null,"head"),Im.domAPI=Ho(),Im.insertStyleElement=Go();zo()(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=n(8418),Vm={attributes:{"data-cke":!0}};Vm.setAttributes=$o(),Vm.insert=Zo().bind(null,"head"),Vm.domAPI=Ho(),Vm.insertStyleElement=Go();zo()(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=n(3505),Bm={attributes:{"data-cke":!0}};Bm.setAttributes=$o(),Bm.insert=Zo().bind(null,"head"),Bm.domAPI=Ho(),Bm.insertStyleElement=Go();zo()(Lm.Z,Bm);Lm.Z&&Lm.Z.locals&&Lm.Z.locals;var jm=n(6371),zm={attributes:{"data-cke":!0}};zm.setAttributes=$o(),zm.insert=Zo().bind(null,"head"),zm.domAPI=Ho(),zm.insertStyleElement=Go();zo()(jm.Z,zm);jm.Z&&jm.Z.locals&&jm.Z.locals;function Fm(e,t=gs){const n=new t(e),o=new ds(e),r=new ms(e,n,o);return n.bind("isEnabled").to(r),n instanceof Dm?n.arrowView.bind("isOn").to(r,"isOpen"):n.bind("isOn").to(r,"isOpen"),function(e){(function(e){e.on("render",(()=>{i({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,n,i)=>{e.isOpen&&!i&&(e.isOpen=!1)}))}(e),function(e){e.keystrokes.set("arrowdown",((t,n)=>{e.isOpen&&(e.panelView.focus(),n())})),e.keystrokes.set("arrowup",((t,n)=>{e.isOpen&&(e.panelView.focusLast(),n())}))}(e),function(e){e.on("change:isOpen",((t,n,i)=>{if(i)return;const o=e.panelView.element;o&&o.contains(Di.document.activeElement)&&e.buttonView.focus()}))}(e),function(e){e.on("change:isOpen",((t,n,i)=>{i&&e.panelView.focus()}),{priority:"low"})}(e)}(r),r}function Hm(e,t,n={}){e.extendTemplate({attributes:{class:["ck-toolbar-dropdown"]}}),e.isOpen?Um(e,t,n):e.once("change:isOpen",(()=>Um(e,t,n)),{priority:"highest"}),n.enableActiveItemFocusOnDropdownOpen&&$m(e,(()=>e.toolbarView.items.find((e=>e.isOn))))}function Um(e,t,n){const i=e.locale,o=i.t,r=e.toolbarView=new Em(i),s="function"==typeof t?t():t;r.ariaLabel=n.ariaLabel||o("Dropdown toolbar"),n.maxWidth&&(r.maxWidth=n.maxWidth),n.class&&(r.class=n.class),n.isCompact&&(r.isCompact=n.isCompact),n.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 Zm(e,t,n={}){e.isOpen?Wm(e,t,n):e.once("change:isOpen",(()=>Wm(e,t,n)),{priority:"highest"}),$m(e,(()=>e.listView.items.find((e=>e instanceof Mm&&e.children.first.isOn))))}function Wm(e,t,n){const i=e.locale,o=e.listView=new Om(i),r="function"==typeof t?t():t;o.ariaLabel=n.ariaLabel,o.role=n.role,o.items.bindTo(r).using((e=>{if("separator"===e.type)return new Rm(i);if("button"===e.type||"switchbutton"===e.type){const t=new Mm(i);let n;return n="button"===e.type?new Er(i):new Tr(i),n.bind(...Object.keys(e.model)).to(e.model),n.delegate("execute").to(t),t.children.add(n),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 n=t();n&&("function"==typeof n.focus?n.focus():A("ui-dropdown-focus-child-on-open-child-missing-focus",{view:n}))}),{priority:k.low-10})}function qm(e,t,n){const i=new cs(e.locale);return i.set({id:t,ariaDescribedById:n}),i.bind("isReadOnly").to(e,"isEnabled",(e=>!e)),i.bind("hasError").to(e,"errorText",(e=>!!e)),i.on("input",(()=>{e.errorText=null})),e.bind("isEmpty","isFocused","placeholder").to(i),i}const Gm=(e,t=0,n=1)=>e>n?n:eMath.round(n*e)/n,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:n,a:i})=>{const o=(200-t)*n/100;return{h:Km(e),s:Km(o>0&&o<200?t*n/100/(o<=100?o:200-o)*100:0),l:Km(o/2),a:Km(i,2)}},Jm=e=>{const{h:t,s:n,l:i}=Qm(e);return`hsl(${t}, ${n}%, ${i}%)`},Xm=({h:e,s:t,v:n,a:i})=>{e=e/360*6,t/=100,n/=100;const o=Math.floor(e),r=n*(1-t),s=n*(1-(e-o)*t),a=n*(1-(1-e+o)*t),l=o%6;return{r:Km(255*[n,s,r,r,a,n][l]),g:Km(255*[a,n,n,s,r,r][l]),b:Km(255*[r,r,a,n,n,s][l]),a:Km(i,2)}},ef=e=>{const t=e.toString(16);return t.length<2?"0"+t:t},tf=({r:e,g:t,b:n,a:i})=>{const o=i<1?ef(Km(255*i)):"";return"#"+ef(e)+ef(t)+ef(n)+o},nf=({r:e,g:t,b:n,a:i})=>{const o=Math.max(e,t,n),r=o-Math.min(e,t,n),s=r?o===e?(t-n)/r:o===t?2+(n-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:i}},of=(e,t)=>{if(e===t)return!0;for(const n in e)if(e[n]!==t[n])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,n)=>{e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:n}))};let lf=!1;const cf=e=>"touches"in e,df=(e,t)=>{const n=cf(t)?t.touches[0]:t,i=e.el.getBoundingClientRect();af(e.el,"move",e.getMove({x:Gm((n.pageX-(i.left+window.pageXOffset))/i.width),y:Gm((n.pageY-(i.top+window.pageYOffset))/i.height)}))};class uf{constructor(e,t,n,i){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=i,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 n=t.keyCode;n>40||e.xy&&n<37||n<33||(t.preventDefault(),af(e.el,"move",e.getMove({x:39===n?.01:37===n?-.01:34===n?.05:33===n?-.05:35===n?1:36===n?-1:0,y:40===n?.01:38===n?-.01:0},!0)))})(this,e)}}style(e){e.forEach(((e,t)=>{for(const n in e)this.nodes[t].style.setProperty(n,e[n])}))}}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,n){const i=this.colorModel.fromAttr(n);this[ff](i)||(this.color=i)}handleEvent(e){const t=this[pf],n={...t,...e.detail};let i;this[bf](n),of(n,t)||this[ff](i=this.colorModel.fromHsva(n))||(this[gf]=i,af(this,"color-changed",{value:i}))}[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:n})=>tf(Xm({h:e,s:t,v:n,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=n(2118),Ef={attributes:{"data-cke":!0}};Ef.setAttributes=$o(),Ef.insert=Zo().bind(null,"head"),Ef.domAPI=Ho(),Ef.insertStyleElement=Go();zo()(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 n=this.createCollection();n.add(this.hexInputRow),this.setTemplate({tag:"div",attributes:{class:["ck","ck-color-picker"],tabindex:-1},children:n}),this._debounceColorPickerEvent=Xr((e=>{this.set("color",e)}),150,{leading:!0}),this.on("set:color",((e,t,n)=>{e.return=Br(n,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=Di.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(),n=e.startsWith("#")?e.substring(1):e;[3,4,6,8].includes(n.length)&&/(([0-9a-fA-F]{2}){3,4}|([0-9a-fA-F]){3,4})/.test(n)&&this._debounceColorPickerEvent("#"+n)}})),e}}function Sf(e){let t=function(e){if(!e)return"";const t=jr(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=n(9029),Nf={attributes:{"data-cke":!0}};Nf.setAttributes=$o(),Nf.insert=Zo().bind(null,"head"),Nf.domAPI=Ho(),Nf.insertStyleElement=Go();zo()(Rf.Z,Nf);Rf.Z&&Rf.Z.locals&&Rf.Z.locals;const Vf=Ki("px"),Df=Di.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,n=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),i=Lf._getOptimalPosition(n),o=parseInt(i.left),r=parseInt(i.top),s=i.name,a=i.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),n=e.limiter?Bf(e.limiter):Df;this.listenTo(Di.document,"scroll",((i,o)=>{const r=o.target,s=t&&r.contains(t),a=n&&r.contains(n);!s&&!a&&t&&n||this.attachTo(e)}),{useCapture:!0}),this.listenTo(Di.window,"resize",(()=>{this.attachTo(e)}))}_stopPinning(){this.stopListening(Di.document,"scroll"),this.stopListening(Di.window,"resize")}}function Bf(e){return Ei(e)?e:ji(e)?e.commonAncestorContainer:"function"==typeof e?Bf(e()):null}function jf(e={}){const{sideOffset:t=Lf.arrowSideOffset,heightOffset:n=Lf.arrowHeightOffset,stickyVerticalOffset:i=Lf.stickyVerticalOffset,config:o}=e;return{northWestArrowSouthWest:(e,n)=>({top:r(e,n),left:e.left-t,name:"arrow_sw",...o&&{config:o}}),northWestArrowSouthMiddleWest:(e,n)=>({top:r(e,n),left:e.left-.25*n.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,n)=>({top:r(e,n),left:e.left-.75*n.width+t,name:"arrow_sme",...o&&{config:o}}),northWestArrowSouthEast:(e,n)=>({top:r(e,n),left:e.left-n.width+t,name:"arrow_se",...o&&{config:o}}),northArrowSouthWest:(e,n)=>({top:r(e,n),left:e.left+e.width/2-t,name:"arrow_sw",...o&&{config:o}}),northArrowSouthMiddleWest:(e,n)=>({top:r(e,n),left:e.left+e.width/2-.25*n.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,n)=>({top:r(e,n),left:e.left+e.width/2-.75*n.width+t,name:"arrow_sme",...o&&{config:o}}),northArrowSouthEast:(e,n)=>({top:r(e,n),left:e.left+e.width/2-n.width+t,name:"arrow_se",...o&&{config:o}}),northEastArrowSouthWest:(e,n)=>({top:r(e,n),left:e.right-t,name:"arrow_sw",...o&&{config:o}}),northEastArrowSouthMiddleWest:(e,n)=>({top:r(e,n),left:e.right-.25*n.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,n)=>({top:r(e,n),left:e.right-.75*n.width+t,name:"arrow_sme",...o&&{config:o}}),northEastArrowSouthEast:(e,n)=>({top:r(e,n),left:e.right-n.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,n)=>({top:s(e),left:e.left-.25*n.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,n)=>({top:s(e),left:e.left-.75*n.width+t,name:"arrow_nme",...o&&{config:o}}),southWestArrowNorthEast:(e,n)=>({top:s(e),left:e.left-n.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,n)=>({top:s(e),left:e.left+e.width/2-.25*n.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,n)=>({top:s(e),left:e.left+e.width/2-.75*n.width+t,name:"arrow_nme",...o&&{config:o}}),southArrowNorthEast:(e,n)=>({top:s(e),left:e.left+e.width/2-n.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,n)=>({top:s(e),left:e.right-.25*n.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,n)=>({top:s(e),left:e.right-.75*n.width+t,name:"arrow_nme",...o&&{config:o}}),southEastArrowNorthEast:(e,n)=>({top:s(e),left:e.right-n.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-n,name:"arrow_e",...o&&{config:o}}),eastArrowWest:(e,t)=>({top:e.top+e.height/2-t.height/2,left:e.right+n,name:"arrow_w",...o&&{config:o}}),viewportStickyNorth:(e,t,n)=>e.getIntersection(n)?{top:n.top+i,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-n}function s(e){return e.bottom+n}}Lf.arrowSideOffset=25,Lf.arrowHeightOffset=10,Lf.stickyVerticalOffset=20,Lf._getOptimalPosition=to,Lf.defaultPositions=jf();var zf=n(9721),Ff={attributes:{"data-cke":!0}};Ff.setAttributes=$o(),Ff.insert=Zo().bind(null,"head"),Ff.domAPI=Ho(),Ff.insertStyleElement=Go();zo()(zf.Z,Ff);zf.Z&&zf.Z.locals&&zf.Z.locals;const Hf="ck-tooltip";class Uf extends(Mi()){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(Di.document,"mouseenter",this._onEnterOrFocus.bind(this),{useCapture:!0}),this.listenTo(Di.document,"mouseleave",this._onLeaveOrBlur.bind(this),{useCapture:!0}),this.listenTo(Di.document,"focus",this._onEnterOrFocus.bind(this),{useCapture:!0}),this.listenTo(Di.document,"blur",this._onLeaveOrBlur.bind(this),{useCapture:!0}),this.listenTo(Di.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 n=Zf(t);var i;n&&(n!==this._currentElementWithTooltip&&(this._unpinTooltip(),this._pinTooltipDebounced(n,{text:(i=n).dataset.ckeTooltipText,position:i.dataset.ckeTooltipPosition||"s",cssClass:i.dataset.ckeTooltipClass||""})))}_onLeaveOrBlur(e,{target:t,relatedTarget:n}){if("mouseleave"===e.name){if(!Ei(t))return;if(this._currentElementWithTooltip&&t!==this._currentElementWithTooltip)return;const e=Zf(t),i=Zf(n);e&&e!==i&&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:n,cssClass:i}){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(n)}),this._resizeObserver=new qi(e,(()=>{eo(e)||this._unpinTooltip()})),this.balloonPanelView.class=[Hf,i].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=n}_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 Zf(e){return Ei(e)?e.closest("[data-cke-tooltip-text]:not([data-cke-tooltip-disabled])"):null}Uf.defaultBalloonPositions=jf({heightOffset:5,sideOffset:13}),Uf._editors=new Set,Uf._instance=null;const Wf=function(e,t,n){var i=!0,o=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return F(n)&&(i="leading"in n?!!n.leading:i,o="trailing"in n?!!n.trailing:o),Xr(e,t,{leading:i,maxWait:t,trailing:o})},$f=50,qf=350,Gf="Powered by",Kf={top:-99999,left:-99999,name:"invalid",config:{withArrow:!1}};class Yf extends(Mi()){constructor(e){super(),this.editor=e,this._balloonView=null,this._lastFocusedEditableElement=null,this._showBalloonThrottled=Wf(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 n="";try{n=atob(e)}catch(e){return"INVALID"}const i=n.split("-"),o=i[0],r=i[1];if(!r)return t(e);try{atob(r)}catch(n){try{if(atob(o),!atob(o).length)return t(e)}catch(n){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(),n?this._showBalloon():this._hideBalloon()})),e.ui.focusTracker.on("change:focusedElement",((e,t,n)=>{this._updateLastFocusedEditableElement(),n&&this._showBalloon()})),e.ui.on("update",(()=>{this._showBalloonThrottled()})))}_createBalloonView(){const e=this.editor,t=this._balloonView=new Lf,n=Xf(e),i=new Qf(e.locale,n.label);t.content.add(i),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 n=Xf(e),i="right"===n.side?function(e,t){return Jf(e,t,((e,n)=>e.left+e.width-n.width-t.horizontalOffset))}(t,n):function(e,t){return Jf(e,t,(e=>e.left+t.horizontalOffset))}(t,n);return{target:t,positions:[i]}}(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,n=e.ui.focusTracker.focusedElement;if(!t||!n)return void(this._lastFocusedEditableElement=null);const i=Array.from(e.ui.getEditableElementsNames()).map((t=>e.ui.getEditableElement(t)));i.includes(n)?this._lastFocusedEditableElement=n:this._lastFocusedEditableElement=i[0]}}class Qf extends Qo{constructor(e,t){super(e);const n=new yr,i=this.bindTemplate;n.set({content:'\n',isColorInherited:!1}),n.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]}]:[],n],on:{dragstart:i.to((e=>e.preventDefault()))}}]})}}function Jf(e,t,n){return(i,o)=>{const r=i.getVisible();if(!r)return Kf;if(i.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"),n=t&&t.position||"border";return{position:n,label:Gf,verticalOffset:"inside"===n?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 n=()=>{this.editor.editing.view.getDomRoot(e)||this.editor.keystrokes.listenTo(t)};this.isReady?n():this.once("ready",n)}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 n=e.config.get("toolbar.viewportTopOffset");return n?(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:n}):{top:0}}_initFocusTracking(){const e=this.editor,t=e.editing.view;let n,i;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)&&(n=r);const s=this._getCurrentFocusedToolbarDefinition();s&&i||(i=this._getFocusableCandidateToolbarDefinitions());for(let e=0;e{const o=this._getCurrentFocusedToolbarDefinition();o&&(n?(n.focus(),n=null):e.editing.view.focus(),o.options.afterBlur&&o.options.afterBlur(),i())}))}_getFocusableCandidateToolbarDefinitions(){const e=[];for(const t of this._focusableToolbarDefinitions){const{toolbarView:n,options:i}=t;(eo(n.element)||i.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:n}}=e;return n&&n(),!!eo(t.element)&&(t.focus(),!0)}_handleScrollToTheSelection(e,t){const n={top:0,bottom:0,left:0,right:0,...this.viewportOffset};t.viewportOffset.top+=n.top,t.viewportOffset.bottom+=n.bottom,t.viewportOffset.left+=n.left,t.viewportOffset.right+=n.right}}function tg(e){const{toolbarView:t,options:n}=e;let i=10;return eo(t.element)&&i--,n.isContextual&&i--,i}var ng=n(7456),ig={attributes:{"data-cke":!0}};ig.setAttributes=$o(),ig.insert=Zo().bind(null,"head"),ig.domAPI=Ho(),ig.insertStyleElement=Go();zo()(ng.Z,ig);ng.Z&&ng.Z.locals&&ng.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 ns;return t.text=e("Rich Text Editor"),t.extendTemplate({attributes:{class:"ck-voice-label"}}),t}}class sg extends Qo{constructor(e,t,n){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=n,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((n=>{const i=e.document.getRoot(t.name);n.addClass(t.isFocused?"ck-focused":"ck-blurred",i),n.removeClass(t.isFocused?"ck-blurred":"ck-focused",i)}))}e.isRenderingInProgress?function n(i){e.once("change:isRenderingInProgress",((e,o,r)=>{r?n(i):t(i)}))}(this):t(this)}}class ag extends sg{constructor(e,t,n,i={}){super(e,t,n);const o=e.t;this.extendTemplate({attributes:{role:"textbox",class:"ck-editor__editable_inline"}}),this._generateLabel=i.label||(()=>o("Editor editing area: %0",this.name))}render(){super.render();const e=this._editingView;e.change((t=>{const n=e.document.getRoot(this.name);t.setAttribute("aria-label",this._generateLabel(this),n)}))}}var lg=n(7641),cg={attributes:{"data-cke":!0}};cg.setAttributes=$o(),cg.insert=Zo().bind(null,"head"),cg.domAPI=Ho(),cg.insertStyleElement=Go();zo()(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&&ic(this,t),e&&this.set(e)}}var hg=n(395),mg={attributes:{"data-cke":!0}};mg.setAttributes=$o(),mg.insert=Zo().bind(null,"head"),mg.domAPI=Ho(),mg.insertStyleElement=Go();zo()(hg.Z,mg);hg.Z&&hg.Z.locals&&hg.Z.locals;var fg=n(5078),gg={attributes:{"data-cke":!0}};gg.setAttributes=$o(),gg.insert=Zo().bind(null,"head"),gg.domAPI=Ho(),gg.insertStyleElement=Go();zo()(fg.Z,gg);fg.Z&&fg.Z.locals&&fg.Z.locals;const pg=Ki("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 n=this._idToStack.get(t);e.singleViewMode&&this.showStack(t),n.set(e.view,e),this._viewToStack.set(e.view,n),n===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,n)=>{if(n<2)return"";const i=Array.from(this._idToStack.values()).indexOf(this._visibleStack)+1;return t("%0 of %1",[i,n])})),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:n=!0,singleViewMode:i=!1}){this.view.class=t,this.view.withArrow=n,this._rotatorView.showView(e),this.visibleView=e,this.view.pin(this._getBalloonPosition()),this._fakePanelsView.updatePosition(),i&&(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,n=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",n.to("isNavigationVisible",(e=>e?"":"ck-hidden"))]},children:[this.buttonPrevView,{tag:"span",attributes:{class:["ck-balloon-rotator__counter"]},children:[{text:n.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 n=new Er(this.locale);return n.set({label:e,icon:t,tooltip:!0}),n}}class kg extends Qo{constructor(e,t){super(e);const n=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",n.to("numberOfPanels",(e=>e?"":"ck-hidden"))],style:{top:n.to("top",pg),left:n.to("left",pg),width:n.to("width",pg),height:n.to("height",pg)}},children:this.content}),this.on("change:numberOfPanels",((e,t,n,i)=>{n>i?this._addPanels(n-i):this._removePanels(i-n),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:n,height:i}=new Hi(this._balloonPanelView.element);Object.assign(this,{top:e,left:t,width:n,height:i})}}}var _g=n(3846),vg={attributes:{"data-cke":!0}};vg.setAttributes=$o(),vg.insert=Zo().bind(null,"head"),vg.domAPI=Ho(),vg.insertStyleElement=Go();zo()(_g.Z,vg);_g.Z&&_g.Z.locals&&_g.Z.locals;const yg=Ki("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(Di.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,n=t.document.getRoot(),i=e.sourceElement;let o;const r=e.config.get("placeholder");r&&(o="string"==typeof r?r:r[this.view.editable.name]),!o&&i&&"textarea"===i.tagName.toLowerCase()&&(o=i.getAttribute("placeholder")),o&&Ms({view:t,element:n,text:o,isDirectHost:!1,keepOnFocus:!0})}_handleScrollToTheSelectionWithStickyPanel(e,t,n){const i=this.view.stickyPanel;if(i.isSticky){const e=new Hi(i.element).height;t.viewportOffset.top+=e}else{const e=()=>{this.editor.editing.view.scrollToTheSelection(n)};this.listenTo(i,"change:isSticky",e),setTimeout((()=>{this.stopListening(i,"change:isSticky",e)}),20)}}}var Pg=n(4090),Ig={attributes:{"data-cke":!0}};Ig.setAttributes=$o(),Ig.insert=Zo().bind(null,"head"),Ig.domAPI=Ho(),Ig.insertStyleElement=Go();zo()(Pg.Z,Ig);Pg.Z&&Pg.Z.locals&&Pg.Z.locals;class Og extends rg{constructor(e,t,n={}){super(e),this.stickyPanel=new Ag(e),this.toolbar=new Em(e,{shouldGroupWhenFull:n.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 n=this._listeners[e]||[];for(const e of n)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 n=this._shouldRestart();this.state="crashed",this._fire("stateChange"),this._fire("error",{error:e,causesRestart:n}),n?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 n=[e],i=new Set;let o=0;for(;n.length>o;){const e=n[o++];if(!i.has(e)&&Ng(e)&&!t.has(e))if(i.add(e),Symbol.iterator in e)try{for(const t of e)n.push(t)}catch(e){}else for(const t in e)"defaultValue"!==t&&n.push(e[t])}return i}function Ng(e){const t=Object.prototype.toString.call(e),n=typeof e;return!("number"===n||"boolean"===n||"string"===n||"symbol"===n||"function"===n||"[object Date]"===t||"[object RegExp]"===t||"[object Module]"===t||null==e||e._watchdogExcluded||e instanceof EventTarget||e instanceof Event)}function Vg(e,t,n=new Set){if(e===t&&("object"==typeof(i=e)&&null!==i))return!0;var i;const o=Rg(e,n),r=Rg(t,n);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=Wf(this._save.bind(this),"number"==typeof t.saveInterval?t.saveInterval:5e3),e&&(this._creator=(t,n)=>e.create(t,n)),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,n){return Promise.resolve().then((()=>(super._startErrorHandling(),this._elementOrData=e,this._config=this._cloneEditorConfiguration(t)||{},this._config.context=n,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 xi(e,((e,t)=>Ei(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 n=e===Lg;this._activeActions++,this._queues.get(e)||this._queues.set(e,Promise.resolve());const i=(n?Promise.all(this._queues.values()):Promise.all([this._queues.get(Lg),this._queues.get(e)])).then(t),o=i.catch((()=>{}));return this._queues.set(e,o),i.finally((()=>{this._activeActions--,this._queues.get(e)===o&&0===this._activeActions&&this._onEmptyCallbacks.forEach((e=>e()))}))}}function jg(e){return Array.isArray(e)?e:[e]}class zg 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 n=!this.config.get("toolbar.shouldNotGroupWhenFull"),i=new Og(this.locale,this.editing.view,{shouldToolbarGroupWhenFull:n});this.ui=new Tg(this,i),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 n;const i=t.form,o=()=>e.updateSourceElement();Ue(i.submit)&&(n=i.submit,i.submit=()=>{o(),n.apply(i)}),i.addEventListener("submit",o),e.on("destroy",(()=>{i.removeEventListener("submit",o),n&&(i.submit=n)}))}}(this)}destroy(){return this.sourceElement&&this.updateSourceElement(),this.ui.destroy(),super.destroy()}static create(e,t={}){return new Promise((n=>{const i=new this(e,t);n(i.initPlugins().then((()=>i.ui.init(Fg(e)?e:null))).then((()=>i.data.init(i.config.get("initialData")))).then((()=>i.fire("ready"))).then((()=>i)))}))}}function Fg(e){return Ei(e)}zg.Context=Ss,zg.EditorWatchdog=Dg,zg.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=jg(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",((n,{error:i,causesRestart:o})=>{this._fire("itemError",{itemId:e.id,error:i}),o&&this._actionQueues.enqueue(e.id,(()=>new Promise((n=>{const i=()=>{t.off("restart",i),this._fire("itemRestart",{itemId:e.id}),n()};t.on("restart",i)}))))})),t.create(e.sourceElementOrData,e.config,this._context);throw new Error(`Not supported item type: '${e.type}'.`)})))))}remove(e){const t=jg(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,n=t.document,i=e.text||"",o=i.length;let r=n.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),i&&t.insertContent(e.createText(i,n.selection.getAttributes()),r),s?e.setSelection(s):r.is("documentSelection")||e.setSelection(r),this._buffer.unlock(),this._buffer.input(o)}))}}const Zg=["insertText","insertReplacementText"];class Wg extends nc{constructor(e){super(e),c.isAndroid&&Zg.push("insertCompositionText");const t=e.document;t.on("beforeinput",((n,i)=>{if(!this.isEnabled)return;const{data:o,targetRanges:r,inputType:s,domEvent:a}=i;if(!Zg.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&&n.stop()})),t.on("compositionend",((n,{data:i,domEvent:o})=>{this.isEnabled&&!c.isAndroid&&i&&t.fire("insertText",new oc(e,o,{text:i,selection:t.selection}))}),{priority:"lowest"})}observe(){}stopObserving(){}}class $g extends vs{static get pluginName(){return"Input"}init(){const e=this.editor,t=e.model,n=e.editing.view,i=t.document.selection;n.addObserver(Wg);const o=new Ug(e,e.config.get("typing.undoStep")||20);e.commands.add("insertText",o),e.commands.add("input",o),this.listenTo(n.document,"insertText",((i,o)=>{n.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(n.document,"keydown",((e,r)=>{!i.isCollapsed&&229==r.keyCode&&n.document.isComposing&&qg(t,o)})):this.listenTo(n.document,"compositionstart",(()=>{i.isCollapsed||qg(t,o)}))}}function qg(e,t){if(!t.isEnabled)return;const n=t.buffer;n.lock(),e.enqueueChange(n.batch,(()=>{e.deleteContent(e.document.selection)})),n.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,n=t.document;t.enqueueChange(this._buffer.batch,(i=>{this._buffer.lock();const o=i.createSelection(e.selection||n.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(i);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),i.setSelection(o),this._buffer.unlock()}))}_shouldEntireContentBeReplacedWithParagraph(e){if(e>1)return!1;const t=this.editor.model,n=t.document.selection,i=t.schema.getLimitElement(n);if(!(n.isCollapsed&&n.containsEntireContent(i)))return!1;if(!t.schema.checkChild(i,"paragraph"))return!1;const o=i.getChild(0);return!o||!o.is("element","paragraph")}_replaceEntireContentWithParagraph(e){const t=this.editor.model,n=t.document.selection,i=t.schema.getLimitElement(n),o=e.createElement("paragraph");e.remove(e.createRangeIn(i)),e.insert(o,i),e.setSelection(o,0)}_shouldReplaceFirstBlockWithParagraph(e,t){const n=this.editor.model;if(t>1||"backward"!=this.direction)return!1;if(!e.isCollapsed)return!1;const i=e.getFirstPosition(),o=n.schema.getLimitElement(i),r=o.getChild(0);return i.parent==r&&(!!e.containsEntireContent(r)&&(!!n.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 nc{constructor(e){super(e);const t=e.document;let n=0;t.on("keydown",(()=>{n++})),t.on("keyup",(()=>{n=0})),t.on("beforeinput",((i,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:n};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 n=0;for(const{nextPosition:e}of t){if(e.parent.is("$text")){const t=e.parent.data,i=e.offset;if(No(t,i)||Vo(t,i)||Lo(t,i))continue;n++}else n++;if(n>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&&i.stop()})),c.isBlink&&function(e){const t=e.view,n=t.document;let i=null,o=!1;function r(e){return e==bo.backspace||e==bo.delete}function s(e){return e==bo.backspace?Qg:Jg}n.on("keydown",((e,{keyCode:t})=>{i=t,o=!1})),n.on("keyup",((a,{keyCode:l,domEvent:c})=>{const d=n.selection,u=e.isEnabled&&l==i&&r(l)&&!d.isCollapsed&&!o;if(i=null,u){const e=d.getFirstRange(),i=new el(n,"delete",e),o={unit:Yg,direction:s(l),selectionToRemove:d};n.fire(i,new oc(t,c,o))}})),n.on("beforeinput",((e,{inputType:t})=>{const n=Xg[t];r(i)&&n&&n.direction==s(i)&&(o=!0)}),{priority:"high"}),n.on("beforeinput",((e,{inputType:t,data:n})=>{i==bo.delete&&"insertText"==t&&""==n&&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,n=t.document,i=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(n,"delete",((i,o)=>{n.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(n,"delete",((t,n)=>{this._undoOnBackspace&&"backward"==n.direction&&1==n.sequence&&"codePoint"==n.unit&&(this._undoOnBackspace=!1,e.execute("undo"),n.preventDefault(),t.stop())}),{context:"$capture"}),this.listenTo(i,"change",(()=>{this._undoOnBackspace=!1})))}requestUndoOnBackspace(){this.editor.plugins.has("UndoEditing")&&(this._undoOnBackspace=!0)}}class np extends vs{static get requires(){return[$g,tp]}static get pluginName(){return"Typing"}}function ip(e,t){let n=e.start;return{text:Array.from(e.getWalker({ignoreElementEnd:!1})).reduce(((e,{item:i})=>i.is("$text")||i.is("$textProxy")?e+i.data:(n=t.createPositionAfter(i),"")),""),range:t.createRange(n,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:n})=>{n&&(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 n=this.model,i=n.document.selection,o=n.createRange(n.createPositionAt(i.focus.parent,0),i.focus),{text:r,range:s}=ip(o,n),a=this.testCallback(r);if(!a&&this.hasMatch&&this.fire("unmatched"),this._hasMatch=!!a,a){const n=Object.assign(t,{text:r,range:s});"object"==typeof a&&Object.assign(n,a),this.fire(`matched:${e}`,n)}}}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,n=e.editing.view,i=e.locale,o=t.document.selection;this.listenTo(n.document,"arrowKey",((e,t)=>{if(!o.isCollapsed)return;if(t.shiftKey||t.altKey||t.ctrlKey)return;const n=t.keyCode==bo.arrowright,r=t.keyCode==bo.arrowleft;if(!n&&!r)return;const s=i.contentLanguageDirection;let a=!1;a="ltr"===s&&n||"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,n=this.editor.model.document.selection,i=n.getFirstPosition();return!this._isGravityOverridden&&((!i.isAtStart||!sp(n,t))&&(!!cp(i,t)&&(lp(e),this._overrideGravity(),!0)))}_handleBackwardMovement(e){const t=this.attributes,n=this.editor.model,i=n.document.selection,o=i.getFirstPosition();return this._isGravityOverridden?(lp(e),this._restoreGravity(),ap(n,t,o),!0):o.isAtStart?!!sp(i,t)&&(lp(e),ap(n,t,o),!0):!!function(e,t){const n=e.getShiftedBy(-1);return cp(n,t)}(o,t)&&(o.isAtEnd&&!sp(i,t)&&cp(o,t)?(lp(e),ap(n,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 n of t)if(e.hasAttribute(n))return!0;return!1}function ap(e,t,n){const i=n.nodeBefore;e.change((e=>{i?e.setSelectionAttribute(i.getAttributes()):e.removeSelectionAttribute(t)}))}function lp(e){e.preventDefault()}function cp(e,t){const{nodeBefore:n,nodeAfter:i}=e;for(const e of t){const t=n?n.getAttribute(e):void 0;if((i?i.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,n,i){return i.createRange(hp(e,t,n,!0,i),hp(e,t,n,!1,i))}function hp(e,t,n,i,o){let r=e.textNode||(i?e.nodeBefore:e.nodeAfter),s=null;for(;r&&r.getAttribute(t)==n;)s=r,r=i?r.previousSibling:r.nextSibling;return s?o.createPositionAt(s,i?"before":"after"):e}function mp(e,t,n,i){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",n)&&!e.hasClass(i)&&(o.addClass(i,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(i,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 n of t)n&&e.getAttributeProperties(n[0]).copyOnEnter&&(yield n)}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,n=t.document.selection,i=t.schema,o=n.isCollapsed,r=n.getFirstRange(),s=r.start.parent,a=r.end.parent;if(i.isLimit(s)||i.isLimit(a))return o||s!=a||t.deleteContent(n),!1;if(o){const t=fp(e.model.schema,n.getAttributes());return pp(e,r.start),e.setSelectionAttribute(t),!0}{const i=!(r.start.isAtStart&&r.end.isAtEnd),o=s==a;if(t.deleteContent(n,{leaveUnmerged:i}),i){if(o)return pp(e,n.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 nc{constructor(e){super(e);const t=this.document;let n=!1;t.on("keydown",((e,t)=>{n=t.shiftKey})),t.on("beforeinput",((i,o)=>{if(!this.isEnabled)return;let r=o.inputType;c.isSafari&&n&&"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&&i.stop()}))}observe(){}stopObserving(){}}class kp extends vs{static get pluginName(){return"Enter"}init(){const e=this.editor,t=e.editing.view,n=t.document;t.addObserver(wp),e.commands.add("enter",new gp(e)),this.listenTo(n,"enter",((i,o)=>{n.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((n=>{!function(e,t,n){const i=n.isCollapsed,o=n.getFirstRange(),r=o.start.parent,s=o.end.parent,a=r==s;if(i){const i=fp(e.schema,n.getAttributes());vp(e,t,o.end),t.removeSelectionAttribute(n.getAttributeKeys()),t.setSelectionAttribute(i)}else{const i=!(o.start.isAtStart&&o.end.isAtEnd);e.deleteContent(n,{leaveUnmerged:i}),a?vp(e,t,n.focus):i&&t.setSelection(s,0)}}(e,n,t.selection),this.fire("afterExecute",{writer:n})}))}refresh(){const e=this.editor.model,t=e.document;this.isEnabled=function(e,t){if(t.rangeCount>1)return!1;const n=t.anchor;if(!n||!e.checkChild(n,"softBreak"))return!1;const i=t.getFirstRange(),o=i.start.parent,r=i.end.parent;if((yp(o,e)||yp(r,e))&&o!==r)return!1;return!0}(e.schema,t.selection)}}function vp(e,t,n){const i=t.createElement("softBreak");e.insertContent(i,n),t.setSelection(i,"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,n=e.conversion,i=e.editing.view,o=i.document;t.register("softBreak",{allowWhere:"$text",isInline:!0}),n.for("upcast").elementToElement({model:"softBreak",view:"br"}),n.for("downcast").elementToElement({model:"softBreak",view:(e,{writer:t})=>t.createEmptyElement("br")}),i.addObserver(wp),e.commands.add("shiftEnter",new _p(e)),this.listenTo(o,"enter",((t,n)=>{o.isComposing||n.preventDefault(),n.isSoft&&(e.execute("shiftEnter"),i.scrollToTheSelection())}),{priority:"low"})}}class xp extends(R()){constructor(){super(...arguments),this._stack=[]}add(e,t){const n=this._stack,i=n[0];this._insertDescriptor(e);const o=n[0];i===o||Ep(i,o)||this.fire("change:top",{oldDescriptor:i,newDescriptor:o,writer:t})}remove(e,t){const n=this._stack,i=n[0];this._removeDescriptor(e);const o=n[0];i===o||Ep(i,o)||this.fire("change:top",{oldDescriptor:i,newDescriptor:o,writer:t})}_insertDescriptor(e){const t=this._stack,n=t.findIndex((t=>t.id===e.id));if(Ep(e,t[n]))return;n>-1&&t.splice(n,1);let i=0;for(;t[i]&&Cp(t[i],e);)i++;t.splice(i,0,e)}_removeDescriptor(e){const t=this._stack,n=t.findIndex((t=>t.id===e));n>-1&&t.splice(n,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,n={}){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),n.label&&function(e,t){const n=e.getCustomProperty("widgetLabel");n.push(t)}(e,n.label),n.hasSelectionHandle&&function(e,t){const n=t.createUIElement("div",{class:"ck ck-widget__selection-handle"},(function(e){const t=this.toDomElement(e),n=new yr;return n.set("content",Tp),n.render(),t.appendChild(n.element),t}));t.insert(t.createPositionAt(e,0),n),t.addClass(["ck-widget_with-selection-handle"],e)}(e,t),Vp(e,t),e}function Rp(e,t,n){if(t.classes&&n.addClass(Eo(t.classes),e),t.attributes)for(const i in t.attributes)n.setAttribute(i,t.attributes[i],e)}function Np(e,t,n){if(t.classes&&n.removeClass(Eo(t.classes),e),t.attributes)for(const i in t.attributes)n.removeAttribute(i,e)}function Vp(e,t,n=Rp,i=Np){const o=new xp;o.on("change:top",((t,o)=>{o.oldDescriptor&&i(e,o.oldDescriptor,o.writer),o.newDescriptor&&n(e,o.newDescriptor,o.writer)}));t.setCustomProperty("addHighlight",((e,t,n)=>o.add(t,n)),e),t.setCustomProperty("removeHighlight",((e,t,n)=>o.remove(t,n)),e)}function Dp(e,t,n={}){return t.addClass(["ck-editor__editable","ck-editor__nested-editable"],e),t.setAttribute("role","textbox",e),n.label&&t.setAttribute("aria-label",n.label,e),t.setAttribute("contenteditable",e.isReadOnly?"false":"true",e),e.on("change:isReadOnly",((n,i,o)=>{t.setAttribute("contenteditable",o?"false":"true",e)})),e.on("change:isFocused",((n,i,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 n=e.getSelectedElement();if(n){const i=Fp(e);if(i)return t.createRange(t.createPositionAt(n,i))}return Oh(e,t)}function Bp(){return null}const jp="widget-type-around";function zp(e,t,n){return!!e&&Op(e)&&!n.isInline(t)}function Fp(e){return e.getAttribute(jp)}var Hp=n(5485),Up={attributes:{"data-cke":!0}};Up.setAttributes=$o(),Up.insert=Zo().bind(null,"head"),Up.domAPI=Ho(),Up.insertStyleElement=Go();zo()(Hp.Z,Up);Hp.Z&&Hp.Z.locals&&Hp.Z.locals;const Zp=["before","after"],Wp=(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",((n,i,o)=>{t.change((e=>{for(const n of t.document.roots)o?e.removeClass($p,n):e.addClass($p,n)})),o||e.model.change((e=>{e.removeSelectionAttribute(jp)}))})),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 n=this.editor,i=n.editing.view,o=n.model.schema.getAttributesWithProperty(e,"copyOnReplace",!0);n.execute("insertParagraph",{position:n.model.createPositionAt(e,t),attributes:o}),i.focus(),i.scrollToTheSelection()}_listenToIfEnabled(e,t,n,i){this.listenTo(e,t,((...e)=>{this.isEnabled&&n(...e)}),i)}_insertParagraphAccordingToFakeCaretPosition(){const e=this.editor.model.document.selection,t=Fp(e);if(!t)return!1;const n=e.getSelectedElement();return this._insertParagraph(n,t),!0}_enableTypeAroundUIInjection(){const e=this.editor,t=e.model.schema,n=e.locale.t,i={before:n("Insert paragraph before block"),after:n("Insert paragraph after block")};e.editing.downcastDispatcher.on("insert",((e,o,r)=>{const s=r.mapper.toViewElement(o.item);if(s&&zp(s,o.item,t)){!function(e,t,n){const i=e.createUIElement("div",{class:"ck ck-reset_all ck-widget__type-around"},(function(e){const n=this.toDomElement(e);return function(e,t){for(const n of Zp){const i=new Jo({tag:"div",attributes:{class:["ck","ck-widget__type-around__button",`ck-widget__type-around__button_${n}`],title:t[n],"aria-hidden":"true"},children:[e.ownerDocument.importNode(Wp,!0)]});e.appendChild(i.render())}}(n,t),function(e){const t=new Jo({tag:"div",attributes:{class:["ck","ck-widget__type-around__fake-caret"]}});e.appendChild(t.render())}(n),n}));e.insert(e.createPositionAt(n,"end"),i)}(r.writer,i,s);s.getCustomProperty("widgetLabel").push((()=>this.isEnabled?n("Press Enter to type after or press Shift + Enter to type before the widget"):""))}}),{priority:"low"})}_enableTypeAroundFakeCaretActivationUsingKeyboardArrows(){const e=this.editor,t=e.model,n=t.document.selection,i=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(n,"change:range",((t,n)=>{n.directChange&&e.model.change((e=>{e.removeSelectionAttribute(jp)}))})),this._listenToIfEnabled(t.document,"change:data",(()=>{const t=n.getSelectedElement();if(t){if(zp(e.editing.mapper.toViewElement(t),t,i))return}e.model.change((e=>{e.removeSelectionAttribute(jp)}))})),this._listenToIfEnabled(e.editing.downcastDispatcher,"selection",((e,t,n)=>{const o=n.writer;if(this._currentFakeCaretModelElement){const e=n.mapper.toViewElement(this._currentFakeCaretModelElement);e&&(o.removeClass(Zp.map(r),e),this._currentFakeCaretModelElement=null)}const s=t.selection.getSelectedElement();if(!s)return;const a=n.mapper.toViewElement(s);if(!zp(a,s,i))return;const l=Fp(t.selection);l&&(o.addClass(r(l),a),this._currentFakeCaretModelElement=s)})),this._listenToIfEnabled(e.ui.focusTracker,"change:isFocused",((t,n,i)=>{i||e.model.change((e=>{e.removeSelectionAttribute(jp)}))}))}_handleArrowKeyPress(e,t){const n=this.editor,i=n.model,o=i.document.selection,r=i.schema,s=n.editing.view,a=function(e,t){const n=yo(e,t);return"down"===n||"right"===n}(t.keyCode,n.locale.contentLanguageDirection),l=s.document.selection.getSelectedElement();let c;zp(l,n.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,n=Fp(t.document.selection);return t.change((t=>{if(!n)return t.setSelectionAttribute(jp,e?"after":"before"),!0;if(!(n===(e?"after":"before")))return t.removeSelectionAttribute(jp),!0;return!1}))}_handleArrowKeyPressWhenSelectionNextToAWidget(e){const t=this.editor,n=t.model,i=n.schema,o=t.plugins.get("Widget"),r=o._getObjectElementNextToSelection(e);return!!zp(t.editing.mapper.toViewElement(r),r,i)&&(n.change((t=>{o._setSelectionOverElement(r),t.setSelectionAttribute(jp,e?"before":"after")})),!0)}_handleArrowKeyPressWhenNonCollapsedSelection(e){const t=this.editor,n=t.model,i=n.schema,o=t.editing.mapper,r=n.document.selection,s=e?r.getLastPosition().nodeBefore:r.getFirstPosition().nodeAfter;return!!zp(o.toViewElement(s),s,i)&&(n.change((t=>{t.setSelection(s,"on"),t.setSelectionAttribute(jp,e?"after":"before")})),!0)}_enableInsertingParagraphsOnButtonClick(){const e=this.editor,t=e.editing.view;this._listenToIfEnabled(t.document,"mousedown",((n,i)=>{const o=i.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 n=e.closest(".ck-widget");return t.mapDomToView(n)}(o,t.domConverter),a=e.editing.mapper.toModelElement(s);this._insertParagraph(a,r),i.preventDefault(),n.stop()}))}_enableInsertingParagraphsOnEnterKeypress(){const e=this.editor,t=e.model.document.selection,n=e.editing.view;this._listenToIfEnabled(n.document,"enter",((n,i)=>{if("atTarget"!=n.eventPhase)return;const o=t.getSelectedElement(),r=e.editing.mapper.toViewElement(o),s=e.model.schema;let a;this._insertParagraphAccordingToFakeCaretPosition()?a=!0:zp(r,o,s)&&(this._insertParagraph(o,i.isSoft?"before":"after"),a=!0),a&&(i.preventDefault(),n.stop())}),{context:Op})}_enableInsertingParagraphsOnTypingKeystroke(){const e=this.editor.editing.view.document;this._listenToIfEnabled(e,"insertText",((t,n)=>{this._insertParagraphAccordingToFakeCaretPosition()&&(n.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,n=e.model,i=n.schema;this._listenToIfEnabled(t.document,"delete",((t,o)=>{if("atTarget"!=t.eventPhase)return;const r=Fp(n.document.selection);if(!r)return;const s=o.direction,a=n.document.selection.getSelectedElement(),l="forward"==s;if("before"===r===l)e.execute("delete",{selection:n.createSelection(a,"on")});else{const t=i.getNearestSelectionRange(n.createPositionAt(a,r),s);if(t)if(t.isCollapsed){const o=n.createSelection(t.start);if(n.modifySelection(o,{direction:s}),o.focus.isEqual(t.start)){const e=function(e,t){let n=t;for(const i of t.getAncestors({parentFirst:!0})){if(i.childCount>1||e.isLimit(i))break;n=i}return n}(i,t.start.parent);n.deleteContent(n.createSelection(e,"on"),{doNotAutoparagraph:!0})}else n.change((n=>{n.setSelection(t),e.execute(l?"deleteForward":"delete")}))}else n.change((n=>{n.setSelection(t),e.execute(l?"deleteForward":"delete")}))}o.preventDefault(),t.stop()}),{context:Op})}_enableInsertContentIntegration(){const e=this.editor,t=this.editor.model,n=t.document.selection;this._listenToIfEnabled(e.model,"insertContent",((e,[i,o])=>{if(o&&!o.is("documentSelection"))return;const r=Fp(n);return r?(e.stop(),t.change((e=>{const o=n.getSelectedElement(),s=t.createPositionAt(o,r),a=e.createSelection(s),l=t.insertContent(i,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,n)=>{const[,i,o={}]=n;if(i&&!i.is("documentSelection"))return;const r=Fp(t);r&&(o.findOptimalPosition=r,n[3]=o)}),{priority:"high"})}_enableDeleteContentIntegration(){const e=this.editor,t=this.editor.model.document.selection;this._listenToIfEnabled(e.model,"deleteContent",((e,[n])=>{if(n&&!n.is("documentSelection"))return;Fp(t)&&e.stop()}),{priority:"high"})}}function Gp(e){const t=e.model;return(n,i)=>{const o=i.keyCode==bo.arrowup,r=i.keyCode==bo.arrowdown,s=i.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,n){const i=e.model;if(n){const e=t.isCollapsed?t.focus:t.getLastPosition(),n=Kp(i,e,"forward");if(!n)return null;const o=i.createRange(e,n),r=Yp(i.schema,o,"backward");return r?i.createRange(e,r):null}{const e=t.isCollapsed?t.focus:t.getFirstPosition(),n=Kp(i,e,"backward");if(!n)return null;const o=i.createRange(n,e),r=Yp(i.schema,o,"forward");return r?i.createRange(r,e):null}}(e,a,l);if(c){if(c.isCollapsed){if(a.isCollapsed)return;if(s)return}(c.isCollapsed||function(e,t,n){const i=e.model,o=e.view.domConverter;if(n){const e=i.createSelection(t.start);i.modifySelection(e),e.focus.isAtEnd||t.start.isEqual(e.focus)||(t=i.createRange(e.focus,t.end))}const r=e.mapper.toViewRange(t),s=o.viewRangeToDom(r),a=Hi.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 n=l?c.end:c.start;if(s){const i=t.createSelection(a.anchor);i.setFocus(n),e.setSelection(i)}else e.setSelection(n)})),n.stop(),i.preventDefault(),i.stopPropagation())}}}function Kp(e,t,n){const i=e.schema,o=e.createRangeIn(t.root),r="forward"==n?"elementStart":"elementEnd";for(const{previousPosition:e,item:s,type:a}of o.getWalker({startPosition:t,direction:n})){if(i.isLimit(s)&&!i.isInline(s))return e;if(a==r&&i.isBlock(s))return null}return null}function Yp(e,t,n){const i="backward"==n?t.end:t.start;if(e.checkChild(i,"$text"))return i;for(const{nextPosition:i}of t.getWalker({direction:n}))if(e.checkChild(i,"$text"))return i;return null}var Qp=n(1014),Jp={attributes:{"data-cke":!0}};Jp.setAttributes=$o(),Jp.insert=Zo().bind(null,"head"),Jp.domAPI=Ho(),Jp.insertStyleElement=Go();zo()(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,n=t.document;this.editor.editing.downcastDispatcher.on("selection",((t,n,i)=>{const o=i.writer,r=n.selection;if(r.isCollapsed)return;const s=r.getSelectedElement();if(!s)return;const a=e.editing.mapper.toViewElement(s);var l;Op(a)&&(i.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,n)=>{this._clearPreviouslySelectedWidgets(n.writer);const i=n.writer,o=i.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)&&(i.addClass(Ip,e),this._previouslySelected.add(e),r=e)}}),{priority:"low"}),t.addObserver(Fh),this.listenTo(n,"mousedown",((...e)=>this._onMousedown(...e))),this.listenTo(n,"arrowKey",((...e)=>{this._handleSelectionChangeOnArrowKeyPress(...e)}),{context:[Op,"$text"]}),this.listenTo(n,"arrowKey",((...e)=>{this._preventDefaultOnArrowKeyPress(...e)}),{context:"$root"}),this.listenTo(n,"arrowKey",Gp(this.editor.editing),{context:"$text"}),this.listenTo(n,"delete",((e,t)=>{this._handleDelete("forward"==t.direction)&&(t.preventDefault(),e.stop())}),{context:"$root"})}_onMousedown(e,t){const n=this.editor,i=n.editing.view,o=i.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=n.editing.mapper,i=r.is("attributeElement")?r.findAncestor((e=>!e.is("attributeElement"))):r,o=e.toModelElement(i);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||i.focus();const s=n.editing.mapper.toModelElement(r);this._setSelectionOverElement(s)}_handleSelectionChangeOnArrowKeyPress(e,t){const n=t.keyCode,i=this.editor.model,o=i.schema,r=i.document.selection,s=r.getSelectedElement(),a=yo(n,this.editor.locale.contentLanguageDirection),l="down"==a||"right"==a,c="up"==a||"down"==a;if(s&&o.isObject(s)){const n=l?r.getLastPosition():r.getFirstPosition(),s=o.getNearestSelectionRange(n,l?"forward":"backward");return void(s&&(i.change((e=>{e.setSelection(s)})),t.preventDefault(),e.stop()))}if(!r.isCollapsed&&!t.shiftKey){const n=r.getFirstPosition(),s=r.getLastPosition(),a=n.nodeAfter,c=s.nodeBefore;return void((a&&o.isObject(a)||c&&o.isObject(c))&&(i.change((e=>{e.setSelection(l?s:n)})),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 n=this.editor.model,i=n.schema,o=n.document.selection.getSelectedElement();o&&i.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 n=this._getObjectElementNextToSelection(e);return n?(this.editor.model.change((e=>{let i=t.anchor.parent;for(;i.isEmpty;){const t=i;i=t.parent,e.remove(t)}this._setSelectionOverElement(n)})),!0):void 0}_setSelectionOverElement(e){this.editor.model.change((t=>{t.setSelection(t.createRangeOn(e))}))}_getObjectElementNextToSelection(e){const t=this.editor.model,n=t.schema,i=t.document.selection,o=t.createSelection(i);if(t.modifySelection(o,{direction:e?"forward":"backward"}),o.isEqual(i))return null;const r=e?o.focus.nodeBefore:o.focus.nodeAfter;return r&&n.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:n,getRelatedElement:i,balloonClassName:o="ck-toolbar-container"}){if(!n.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:i,balloonClassName:o,itemsConfig:n,initialized:!1};r.ui.addToolbar(a,{isContextual:!0,beforeFocus:()=>{const e=i(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,n=null;for(const i of this._toolbarDefinitions.values()){const o=i.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,n=i)}else this._isToolbarVisible(i)&&this._hideToolbar(i);else this._isToolbarInBalloon(i)&&this._hideToolbar(i)}n&&this._showToolbar(n,t)}_hideToolbar(e){this._balloon.remove(e.view),this.stopListening(this._balloon,"change:visibleView")}_showToolbar(e,t){this._isToolbarVisible(e)?nb(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:ib(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);nb(this.editor,t)}})))}_isToolbarVisible(e){return this._balloon.visibleView===e.view}_isToolbarInBalloon(e){return this._balloon.hasView(e.view)}}function nb(e,t){const n=e.plugins.get("ContextualBalloon"),i=ib(e,t);n.updatePosition(i)}function ib(e,t){const n=e.editing.view,i=Lf.defaultPositions;return{target:n.domConverter.mapViewToDom(t),positions:[i.northArrowSouth,i.northArrowSouthWest,i.northArrowSouthEast,i.southArrowNorth,i.southArrowNorthWest,i.southArrowNorthEast,i.viewportStickyNorth]}}G();G();var ob=n(6036),rb={attributes:{"data-cke":!0}};rb.setAttributes=$o(),rb.insert=Zo().bind(null,"head"),rb.domAPI=Ho(),rb.insertStyleElement=Go();zo()(ob.Z,rb);ob.Z&&ob.Z.locals&&ob.Z.locals;class sb extends As{refresh(){const e=this.editor.model,t=e.schema,n=e.document.selection;this.isEnabled=function(e,t,n){const i=function(e,t){const n=Lp(e,t),i=n.start.parent;if(i.isEmpty&&!i.is("element","$root"))return i.parent;return i}(e,n);return t.checkChild(i,"horizontalLine")}(n,t,e)}execute(){const e=this.editor.model;e.change((t=>{const n=t.createElement("horizontalLine");e.insertObject(n,null,null,{setSelection:"after"})}))}}var ab=n(4383),lb={attributes:{"data-cke":!0}};lb.setAttributes=$o(),lb.insert=Zo().bind(null,"head"),lb.domAPI=Ho(),lb.insertStyleElement=Go();zo()(ab.Z,lb);ab.Z&&ab.Z.locals&&ab.Z.locals;class cb extends vs{static get pluginName(){return"HorizontalLineEditing"}init(){const e=this.editor,t=e.model.schema,n=e.t,i=e.conversion;t.register("horizontalLine",{inheritAllFrom:"$blockObject"}),i.for("dataDowncast").elementToElement({model:"horizontalLine",view:(e,{writer:t})=>t.createEmptyElement("hr")}),i.for("editingDowncast").elementToStructure({model:"horizontalLine",view:(e,{writer:t})=>{const i=n("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,n){return t.setCustomProperty("horizontalLine",!0,e),Mp(e,t,{label:n})}(o,t,i)}}),i.for("upcast").elementToElement({view:"hr",model:"horizontalLine"}),e.commands.add("horizontalLine",new sb(e))}}class db extends vs{static get pluginName(){return"HorizontalLineUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add("horizontalLine",(n=>{const i=e.commands.get("horizontalLine"),o=new Er(n);return o.set({label:t("Horizontal line"),icon:'',tooltip:!0}),o.bind("isEnabled").to(i,"isEnabled"),this.listenTo(o,"execute",(()=>{e.execute("horizontalLine"),e.editing.view.focus()})),o}))}}class ub extends vs{static get requires(){return[cb,db,Xp]}static get pluginName(){return"HorizontalLine"}}function hb(e){const t=e.getSelectedElement();return t&&fb(t)?t:null}function mb(e){const t=e.getFirstPosition();if(!t)return null;let n=t.parent;for(;n;){if(n.is("element")&&fb(n))return n;n=n.parent}return null}function fb(e){return!!e.getCustomProperty("table")&&Op(e)}class gb extends vs{static get requires(){return[tb]}static get pluginName(){return"TableToolbar"}afterInit(){const e=this.editor,t=e.t,n=e.plugins.get(tb),i=e.config.get("table.contentToolbar"),o=e.config.get("table.tableToolbar");i&&n.register("tableContent",{ariaLabel:t("Table toolbar"),items:i,getRelatedElement:mb}),o&&n.register("table",{ariaLabel:t("Table toolbar"),items:o,getRelatedElement:hb})}}function pb(e,t,n,i,o=1){null!=t&&null!=o&&t>o?i.setAttribute(e,t,n):i.removeAttribute(e,n)}function bb(e,t,n={}){const i=e.createElement("tableCell",n);return e.insertElement("paragraph",i),e.insert(i,t),i}function wb(e,t){const n=t.parent.parent,i=parseInt(n.getAttribute("headingColumns")||"0"),{column:o}=e.getCellLocation(t);return!!i&&o{e.on("element:table",((e,t,n)=>{const i=t.viewItem;if(!n.consumable.test(i,{name:!0}))return;const{rows:o,headingRows:r,headingColumns:s}=function(e){let t,n=0;const i=[],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"))))n++,i.push(a);else{o.push(a);const e=vb(a);(!t||en.convertItem(e,n.writer.createPositionAt(l,"end")))),n.convertChildren(i,n.writer.createPositionAt(l,"end")),l.isEmpty){const e=n.writer.createElement("tableRow");n.writer.insert(e,n.writer.createPositionAt(l,"end")),bb(n.writer,n.writer.createPositionAt(e,"end"))}n.updateConversionResult(l,t)}}))}}function _b(e){return t=>{t.on(`element:${e}`,((e,t,{writer:n})=>{if(!t.modelRange)return;const i=t.modelRange.start.nodeAfter,o=n.createPositionAt(i,0);if(t.viewItem.isEmpty)return void n.insertElement("paragraph",o);const r=Array.from(i.getChildren());if(r.every((e=>e.is("element","$marker")))){const e=n.createElement("paragraph");n.insert(e,n.createPositionAt(i,0));for(const t of r)n.move(n.createRangeOn(t),n.createPositionAt(e,"end"))}}),{priority:"low"})}}function vb(e){let t=0,n=0;const i=Array.from(e.getChildren()).filter((e=>"th"===e.name||"td"===e.name));for(;n1||o>1)&&this._recordSpans(n,o,i),this._shouldSkipSlot()||(t=this._formatOutValue(n)),this._nextCellAtColumn=this._column+i}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,n=this._column){return{done:!1,value:new Ab(this,e,t,n)}}_shouldSkipSlot(){const e=this._skipRows.has(this._row),t=this._rowthis._endColumn;return e||t||n||i}_getSpanned(){const e=this._spannedCells.get(this._row);return e&&e.get(this._column)||null}_recordSpans(e,t,n){const i={cell:e,row:this._row,column:this._column};for(let e=this._row;e{const o=n.getAttribute("headingRows")||0,r=i.createContainerElement("table",null,[]),s=i.createContainerElement("figure",{class:"table"},r);o>0&&i.insert(i.createPositionAt(r,"end"),i.createContainerElement("thead",null,i.createSlot((e=>e.is("element","tableRow")&&e.indexe.is("element","tableRow")&&e.index>=o))));for(const{positionOffset:e,filter:n}of t.additionalSlots)i.insert(i.createPositionAt(r,e),i.createSlot(n));return i.insert(i.createPositionAt(r,"after"),i.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,i):s}}function Eb(e={}){return(t,{writer:n})=>{const i=t.parent,o=i.parent,r=o.getChildIndex(i),s=new yb(o,{row:r}),a=o.getAttribute("headingRows")||0,l=o.getAttribute("headingColumns")||0;let c=null;for(const i of s)if(i.cell==t){const t=i.row{if(!t.parent.is("element","tableCell"))return null;if(!Sb(t))return null;if(e.asWidget)return n.createContainerElement("span",{class:"ck-table-bogus-paragraph"});{const e=n.createContainerElement("p");return n.setCustomProperty("dataPipeline:transparentRendering",!0,e),e}}}function Sb(e){return 1==e.parent.childCount&&!!e.getAttributeKeys().next().done}class Tb extends As{refresh(){const e=this.editor.model,t=e.document.selection,n=e.schema;this.isEnabled=function(e,t){const n=e.getFirstPosition().parent,i=n===n.root?n:n.parent;return t.checkChild(i,"table")}(t,n)}execute(e={}){const t=this.editor,n=t.model,i=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),n.change((t=>{const o=i.createTable(t,e);n.insertObject(o,null,null,{findOptimalPosition:"auto"}),t.setSelection(t.createPositionAt(o.getNodeByPath([0,0,0]),0))}))}}class Pb 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,n=e.plugins.get("TableUtils"),i="above"===this.order,o=n.getSelectionAffectedTableCells(t),r=n.getRowIndexes(o),s=i?r.first:r.last,a=o[0].findAncestor("table");n.insertRows(a,{at:i?s:s+1,copyStructureFromAbove:!i})}}class Ib 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,n=e.plugins.get("TableUtils"),i="left"===this.order,o=n.getSelectionAffectedTableCells(t),r=n.getColumnIndexes(o),s=i?r.first:r.last,a=o[0].findAncestor("table");n.insertColumns(a,{columns:1,at:i?s:s+1})}}class Ob 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 Mb(e,t,n){const{startRow:i,startColumn:o,endRow:r,endColumn:s}=t,a=n.createElement("table"),l=r-i+1;for(let e=0;e0){pb("headingRows",r-n,e,o,0)}const s=parseInt(t.getAttribute("headingColumns")||"0");if(s>0){pb("headingColumns",s-i,e,o,0)}}(a,e,i,o,n),a}function Rb(e,t,n=0){const i=[],o=new yb(e,{startRow:n,endRow:t-1});for(const e of o){const{row:n,cellHeight:o}=e;n1&&(a.rowspan=l);const c=parseInt(e.getAttribute("colspan")||"1");c>1&&(a.colspan=c);const d=r+s,u=[...new yb(o,{startRow:r,endRow:d,includeAllSlots:!0})];let h,m=null;for(const t of u){const{row:i,column:o,cell:r}=t;r===e&&void 0===h&&(h=o),void 0!==h&&h===o&&i===d&&(m=bb(n,t.getPositionBefore(),a))}return pb("rowspan",s,e,n),m}function Vb(e,t){const n=[],i=new yb(e);for(const e of i){const{column:i,cellWidth:o}=e;i1&&(r.colspan=s);const a=parseInt(e.getAttribute("rowspan")||"1");a>1&&(r.rowspan=a);const l=bb(i,i.createPositionAfter(e),r);return pb("colspan",o,e,i),l}function Lb(e,t,n,i,o,r){const s=parseInt(e.getAttribute("colspan")||"1"),a=parseInt(e.getAttribute("rowspan")||"1");if(n+s-1>o){pb("colspan",o-n+1,e,r,1)}if(t+a-1>i){pb("rowspan",i-t+1,e,r,1)}}function Bb(e,t){const n=t.getColumns(e),i=new Array(n).fill(0);for(const{column:t}of new yb(e))i[t]++;const o=i.reduce(((e,t,n)=>t?e:[...e,n]),[]);if(o.length>0){const n=o[o.length-1];return t.removeColumns(e,{at:n}),!0}return!1}function jb(e,t){const n=[],i=t.getRows(e);for(let t=0;t0){const i=n[n.length-1];return t.removeRows(e,{at:i}),!0}return!1}function zb(e,t){Bb(e,t)||jb(e,t)}function Fb(e,t){const n=Array.from(new yb(e,{startColumn:t.firstColumn,endColumn:t.lastColumn,row:t.lastRow}));if(n.every((({cellHeight:e})=>1===e)))return t.lastRow;const i=n[0].cellHeight-1;return t.lastRow+i}function Hb(e,t){const n=Array.from(new yb(e,{startRow:t.firstRow,endRow:t.lastRow,column:t.lastColumn}));if(n.every((({cellWidth:e})=>1===e)))return t.lastColumn;const i=n[0].cellWidth-1;return t.lastColumn+i}class Ub 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,n=this.editor.plugins.get("TableUtils").getTableCellsContainingSelection(t.selection)[0],i=this.value,o=this.direction;e.change((e=>{const t="right"==o||"down"==o,r=t?n:i,s=t?i:n,a=s.parent;!function(e,t,n){Zb(e)||(Zb(t)&&n.remove(n.createRangeIn(t)),n.move(n.createRangeIn(e),n.createPositionAt(t,"end")));n.remove(e)}(s,r,e);const l=this.isHorizontal?"colspan":"rowspan",c=parseInt(n.getAttribute(l)||"1"),d=parseInt(i.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"),n=t.getTableCellsContainingSelection(e.selection)[0];if(!n)return;const i=this.isHorizontal?function(e,t,n){const i=e.parent,o=i.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}=n.getCellLocation(a),{column:d}=n.getCellLocation(l),u=parseInt(a.getAttribute("colspan")||"1"),h=wb(n,a),m=wb(n,l);if(s&&h!=m)return;return c+u===d?r:void 0}(n,this.direction,t):function(e,t,n){const i=e.parent,o=i.parent,r=o.getChildIndex(i);if("down"==t&&r===n.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 yb(o,{endRow:u})],m=h.find((t=>t.cell===e)),f=m.column,g=h.find((({row:e,cellHeight:n,column:i})=>i===f&&("down"==t?e===u:u===e+n)));return g&&g.cell?g.cell:null}(n,this.direction,t);if(!i)return;const o=this.isHorizontal?"rowspan":"colspan",r=parseInt(n.getAttribute(o)||"1");return parseInt(i.getAttribute(o)||"1")===r?i:void 0}}function Zb(e){const t=e.getChild(0);return 1==e.childCount&&t.is("element","paragraph")&&t.isEmpty}class Wb extends As{refresh(){const e=this.editor.plugins.get("TableUtils"),t=e.getSelectionAffectedTableCells(this.editor.model.document.selection),n=t[0];if(n){const i=n.findAncestor("table"),o=e.getRows(i)-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"),n=t.getSelectionAffectedTableCells(e.document.selection),i=t.getRowIndexes(n),o=n[0],r=o.findAncestor("table"),s=t.getCellLocation(o).column;e.change((e=>{const n=i.last-i.first+1;t.removeRows(r,{at:i.first,rows:n});const o=function(e,t,n,i){const o=e.getChild(Math.min(t,i-1));let r=o.getChild(0),s=0;for(const e of o.getChildren()){if(s>n)return r;r=e,s+=parseInt(e.getAttribute("colspan")||"1")}return r}(r,i.first,s,t.getRows(r));e.setSelection(e.createPositionAt(o,0))}))}}class $b extends As{refresh(){const e=this.editor.plugins.get("TableUtils"),t=e.getSelectionAffectedTableCells(this.editor.model.document.selection),n=t[0];if(n){const i=n.findAncestor("table"),o=e.getColumns(i),{first:r,last:s}=e.getColumnIndexes(t);this.isEnabled=s-re.cell===t)).column,last:o.find((e=>e.cell===n)).column},s=function(e,t,n,i){const o=parseInt(n.getAttribute("colspan")||"1");return o>1?n:t.previousSibling||n.nextSibling?n.nextSibling||t.previousSibling:i.first?e.reverse().find((({column:e})=>ee>i.last)).cell}(o,t,n,r);this.editor.model.change((t=>{const n=r.last-r.first+1;e.removeColumns(i,{at:r.first,columns:n}),t.setSelection(t.createPositionAt(s,0))}))}}class qb extends As{refresh(){const e=this.editor.plugins.get("TableUtils"),t=this.editor.model,n=e.getSelectionAffectedTableCells(t.document.selection),i=n.length>0;this.isEnabled=i,this.value=i&&n.every((e=>this._isInHeading(e,e.parent.parent)))}execute(e={}){if(e.forceValue===this.value)return;const t=this.editor.plugins.get("TableUtils"),n=this.editor.model,i=t.getSelectionAffectedTableCells(n.document.selection),o=i[0].findAncestor("table"),{first:r,last:s}=t.getRowIndexes(i),a=this.value?r:s+1,l=o.getAttribute("headingRows")||0;n.change((e=>{if(a){const t=Rb(o,a,a>l?l:0);for(const{cell:n}of t)Nb(n,a,e)}pb("headingRows",a,o,e,0)}))}_isInHeading(e,t){const n=parseInt(t.getAttribute("headingRows")||"0");return!!n&&e.parent.index0;this.isEnabled=i,this.value=i&&n.every((e=>wb(t,e)))}execute(e={}){if(e.forceValue===this.value)return;const t=this.editor.plugins.get("TableUtils"),n=this.editor.model,i=t.getSelectionAffectedTableCells(n.document.selection),o=i[0].findAncestor("table"),{first:r,last:s}=t.getColumnIndexes(i),a=this.value?r:s+1;n.change((e=>{if(a){const t=Vb(o,a);for(const{cell:n,column:i}of t)Db(n,i,a,e)}pb("headingColumns",a,o,e,0)}))}}class Kb extends vs{static get pluginName(){return"TableUtils"}init(){this.decorate("insertColumns"),this.decorate("insertRows")}getCellLocation(e){const t=e.parent,n=t.parent,i=n.getChildIndex(t),o=new yb(n,{row:i});for(const{cell:t,row:n,column:i}of o)if(t===e)return{row:n,column:i}}createTable(e,t){const n=e.createElement("table"),i=t.rows||2,o=t.columns||2;return Yb(e,n,0,i,o),t.headingRows&&pb("headingRows",Math.min(t.headingRows,i),n,e,0),t.headingColumns&&pb("headingColumns",Math.min(t.headingColumns,o),n,e,0),n}insertRows(e,t={}){const n=this.editor.model,i=t.at||0,o=t.rows||1,r=void 0!==t.copyStructureFromAbove,s=t.copyStructureFromAbove?i-1:i,a=this.getRows(e),l=this.getColumns(e);if(i>a)throw new y("tableutils-insertrows-insert-out-of-range",this,{options:t});n.change((t=>{const n=e.getAttribute("headingRows")||0;if(n>i&&pb("headingRows",n+o,e,t,0),!r&&(0===i||i===a))return void Yb(t,e,i,o,l);const c=r?Math.max(i,s):i,d=new yb(e,{endRow:c}),u=new Array(l).fill(1);for(const{row:e,column:n,cellHeight:a,cellWidth:l,cell:c}of d){const d=e+a-1,h=e<=s&&s<=d;e0&&bb(t,o,i>1?{colspan:i}:void 0),e+=Math.abs(i)-1}}}))}insertColumns(e,t={}){const n=this.editor.model,i=t.at||0,o=t.columns||1;n.change((t=>{const n=e.getAttribute("headingColumns");io-1)throw new y("tableutils-removerows-row-index-out-of-range",this,{table:e,options:t});n.change((t=>{const n={first:r,last:s},{cellsToMove:i,cellsToTrim:o}=function(e,{first:t,last:n}){const i=new Map,o=[];for(const{row:r,column:s,cellHeight:a,cell:l}of new yb(e,{endRow:n})){const e=r+a-1;if(r>=t&&r<=n&&e>n){const e=a-(n-r+1);i.set(s,{cell:l,rowspan:e})}if(r=t){let i;i=e>=n?n-t+1:e-t+1,o.push({cell:l,rowspan:a-i})}}return{cellsToMove:i,cellsToTrim:o}}(e,n);if(i.size){!function(e,t,n,i){const o=new yb(e,{includeAllSlots:!0,row:t}),r=[...o],s=e.getChild(t);let a;for(const{column:e,cell:t,isAnchor:o}of r)if(n.has(e)){const{cell:t,rowspan:o}=n.get(e),r=a?i.createPositionAfter(a):i.createPositionAt(s,0);i.move(i.createRangeOn(t),r),pb("rowspan",o,t,i),a=t}else o&&(a=t)}(e,s+1,i,t)}for(let n=s;n>=r;n--)t.remove(e.getChild(n));for(const{rowspan:e,cell:n}of o)pb("rowspan",e,n,t);!function(e,{first:t,last:n},i){const o=e.getAttribute("headingRows")||0;if(t{!function(e,t,n){const i=e.getAttribute("headingColumns")||0;if(i&&t.first=i;n--)for(const{cell:i,column:o,cellWidth:r}of[...new yb(e)])o<=n&&r>1&&o+r>n?pb("colspan",r-1,i,t):o===n&&t.remove(i);jb(e,this)||Bb(e,this)}))}splitCellVertically(e,t=2){const n=this.editor.model,i=e.parent.parent,o=parseInt(e.getAttribute("rowspan")||"1"),r=parseInt(e.getAttribute("colspan")||"1");n.change((n=>{if(r>1){const{newCellsSpan:i,updatedSpan:s}=Jb(r,t);pb("colspan",s,e,n);const a={};i>1&&(a.colspan=i),o>1&&(a.rowspan=o);Qb(r>t?t-1:r-1,n,n.createPositionAfter(e),a)}if(rt===e)),c=a.filter((({cell:t,cellWidth:n,column:i})=>t!==e&&i===l||il));for(const{cell:e,cellWidth:t}of c)n.setAttribute("colspan",t+s,e);const d={};o>1&&(d.rowspan=o),Qb(s,n,n.createPositionAfter(e),d);const u=i.getAttribute("headingColumns")||0;u>l&&pb("headingColumns",u+s,i,n)}}))}splitCellHorizontally(e,t=2){const n=this.editor.model,i=e.parent,o=i.parent,r=o.getChildIndex(i),s=parseInt(e.getAttribute("rowspan")||"1"),a=parseInt(e.getAttribute("colspan")||"1");n.change((n=>{if(s>1){const i=[...new yb(o,{startRow:r,endRow:r+s-1,includeAllSlots:!0})],{newCellsSpan:l,updatedSpan:c}=Jb(s,t);pb("rowspan",c,e,n);const{column:d}=i.find((({cell:t})=>t===e)),u={};l>1&&(u.rowspan=l),a>1&&(u.colspan=a);for(const e of i){const{column:t,row:i}=e;i>=r+c&&t===d&&(i+r+c)%l==0&&Qb(1,n,e.getPositionBefore(),u)}}if(sr){const e=o+i;n.setAttribute("rowspan",e,t)}const c={};a>1&&(c.colspan=a),Yb(n,o,r+1,i,1,c);const d=o.getAttribute("headingRows")||0;d>r&&pb("headingRows",d+i,o,n)}}))}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 yb(e,t)}getSelectedTableCells(e){const t=[];for(const n of this.sortRanges(e.getRanges())){const e=n.getContainedElement();e&&e.is("element","tableCell")&&t.push(e)}return t}getTableCellsContainingSelection(e){const t=[];for(const n of e.getRanges()){const e=n.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"),n=[...new yb(t)].filter((t=>e.includes(t.cell))).map((e=>e.column));return this._getFirstLastIndexesObject(n)}isSelectionRectangular(e){if(e.length<2||!this._areCellInTheSameTableSection(e))return!1;const t=new Set,n=new Set;let i=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),n.add(r),s>1&&t.add(e+s-1),a>1&&n.add(r+a-1),i+=s*a}const o=function(e,t){const n=Array.from(e.values()),i=Array.from(t.values()),o=Math.max(...n),r=Math.min(...n),s=Math.max(...i),a=Math.min(...i);return(o-r+1)*(s-a+1)}(t,n);return o==i}sortRanges(e){return Array.from(e).sort(Xb)}_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"),n=this.getRowIndexes(e),i=parseInt(t.getAttribute("headingRows"))||0;if(!this._areIndexesInSameSection(n,i))return!1;const o=this.getColumnIndexes(e),r=parseInt(t.getAttribute("headingColumns"))||0;return this._areIndexesInSameSection(o,r)}_areIndexesInSameSection({first:e,last:t},n){return e{const i=t.getSelectedTableCells(e.document.selection),o=i.shift(),{mergeWidth:r,mergeHeight:s}=function(e,t,n){let i=0,o=0;for(const e of t){const{row:t,column:r}=n.getCellLocation(e);i=iw(e,r,i,"colspan"),o=iw(e,t,o,"rowspan")}const{row:r,column:s}=n.getCellLocation(e),a=i-s,l=o-r;return{mergeWidth:a,mergeHeight:l}}(o,i,t);pb("colspan",r,o,n),pb("rowspan",s,o,n);for(const e of i)tw(e,o,n);zb(o.findAncestor("table"),t),n.setSelection(o,"in")}))}}function tw(e,t,n){nw(e)||(nw(t)&&n.remove(n.createRangeIn(t)),n.move(n.createRangeIn(e),n.createPositionAt(t,"end"))),n.remove(e)}function nw(e){const t=e.getChild(0);return 1==e.childCount&&t.is("element","paragraph")&&t.isEmpty}function iw(e,t,n,i){const o=parseInt(e.getAttribute(i)||"1");return Math.max(n,t+o)}class ow 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"),n=t.getSelectionAffectedTableCells(e.document.selection),i=t.getRowIndexes(n),o=n[0].findAncestor("table"),r=[];for(let t=i.first;t<=i.last;t++)for(const n of o.getChild(t).getChildren())r.push(e.createRangeOn(n));e.change((e=>{e.setSelection(r)}))}}class rw 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,n=e.getSelectionAffectedTableCells(t.document.selection),i=n[0],o=n.pop(),r=i.findAncestor("table"),s=e.getCellLocation(i),a=e.getCellLocation(o),l=Math.min(s.column,a.column),c=Math.max(s.column,a.column),d=[];for(const e of new yb(r,{startColumn:l,endColumn:c}))d.push(t.createRangeOn(e.cell));t.change((e=>{e.setSelection(d)}))}}function sw(e){e.document.registerPostFixer((t=>function(e,t){const n=t.document.differ.getChanges();let i=!1;const o=new Set;for(const t of n){let n=null;"insert"==t.type&&"table"==t.name&&(n=t.position.nodeAfter),"insert"!=t.type&&"remove"!=t.type||"tableRow"!=t.name&&"tableCell"!=t.name||(n=t.position.findAncestor("table")),cw(t)&&(n=t.range.start.findAncestor("table")),n&&!o.has(n)&&(i=aw(n,e)||i,i=lw(n,e)||i,o.add(n))}return i}(t,e)))}function aw(e,t){let n=!1;const i=function(e){const t=parseInt(e.getAttribute("headingRows")||"0"),n=Array.from(e.getChildren()).reduce(((e,t)=>t.is("element","tableRow")?e+1:e),0),i=[];for(const{row:o,cell:r,cellHeight:s}of new yb(e)){if(s<2)continue;const e=oe){const t=e-o;i.push({cell:r,rowspan:t})}}return i}(e);if(i.length){n=!0;for(const e of i)pb("rowspan",e.rowspan,e.cell,t,1)}return n}function lw(e,t){let n=!1;const i=function(e){const t=new Array(e.childCount).fill(0);for(const{rowIndex:n}of new yb(e,{includeAllSlots:!0}))t[n]++;return t}(e),o=[];for(const[t,n]of i.entries())!n&&e.getChild(t).is("element","tableRow")&&o.push(t);if(o.length){n=!0;for(const n of o.reverse())t.remove(e.getChild(n)),i.splice(n,1)}const r=i.filter(((t,n)=>e.getChild(n).is("element","tableRow"))),s=r[0];if(!r.every((e=>e===s))){const i=r.reduce(((e,t)=>t>e?t:e),0);for(const[o,s]of r.entries()){const r=i-s;if(r){for(let n=0;nfunction(e,t){const n=t.document.differ.getChanges();let i=!1;for(const t of n)"insert"==t.type&&"table"==t.name&&(i=uw(t.position.nodeAfter,e)||i),"insert"==t.type&&"tableRow"==t.name&&(i=hw(t.position.nodeAfter,e)||i),"insert"==t.type&&"tableCell"==t.name&&(i=mw(t.position.nodeAfter,e)||i),"remove"!=t.type&&"insert"!=t.type||!fw(t)||(i=mw(t.position.parent,e)||i);return i}(t,e)))}function uw(e,t){let n=!1;for(const i of e.getChildren())i.is("element","tableRow")&&(n=hw(i,t)||n);return n}function hw(e,t){let n=!1;for(const i of e.getChildren())n=mw(i,t)||n;return n}function mw(e,t){if(0==e.childCount)return t.insertElement("paragraph",e),!0;const n=Array.from(e.getChildren()).filter((e=>e.is("$text")));for(const e of n)t.wrap(t.createRangeOn(e),"paragraph");return!!n.length}function fw(e){return!!e.position.parent.is("element","tableCell")&&("insert"==e.type&&"$text"==e.name||"remove"==e.type)}function gw(e,t){if(!e.is("element","paragraph"))return!1;const n=t.toViewElement(e);return!!n&&Sb(e)!==n.is("element","span")}var pw=n(3137),bw={attributes:{"data-cke":!0}};bw.setAttributes=$o(),bw.insert=Zo().bind(null,"head"),bw.domAPI=Ho(),bw.insertStyleElement=Go();zo()(pw.Z,bw);pw.Z&&pw.Z.locals&&pw.Z.locals;class ww extends vs{static get pluginName(){return"TableEditing"}static get requires(){return[Kb]}constructor(e){super(e),this._additionalSlots=[]}init(){const e=this.editor,t=e.model,n=t.schema,i=e.conversion,o=e.plugins.get(Kb);n.register("table",{inheritAllFrom:"$blockObject",allowAttributes:["headingRows","headingColumns"]}),n.register("tableRow",{allowIn:"table",isLimit:!0}),n.register("tableCell",{allowContentOf:"$container",allowIn:"tableRow",allowAttributes:["colspan","rowspan"],isLimit:!0,isSelectable:!0}),i.for("upcast").add((e=>{e.on("element:figure",((e,t,n)=>{if(!n.consumable.test(t.viewItem,{name:!0,classes:"table"}))return;const i=function(e){for(const t of e.getChildren())if(t.is("element","table"))return t}(t.viewItem);if(!i||!n.consumable.test(i,{name:!0}))return;n.consumable.consume(t.viewItem,{name:!0,classes:"table"});const o=Po(n.convertItem(i,t.modelCursor).modelRange.getItems());o?(n.convertChildren(t.viewItem,n.writer.createPositionAt(o,"end")),n.updateConversionResult(o,t)):n.consumable.revert(t.viewItem,{name:!0,classes:"table"})}))})),i.for("upcast").add(kb()),i.for("editingDowncast").elementToStructure({model:{name:"table",attributes:["headingRows"]},view:xb(o,{asWidget:!0,additionalSlots:this._additionalSlots})}),i.for("dataDowncast").elementToStructure({model:{name:"table",attributes:["headingRows"]},view:xb(o,{additionalSlots:this._additionalSlots})}),i.for("upcast").elementToElement({model:"tableRow",view:"tr"}),i.for("upcast").add((e=>{e.on("element:tr",((e,t)=>{t.viewItem.isEmpty&&0==t.modelCursor.index&&e.stop()}),{priority:"high"})})),i.for("downcast").elementToElement({model:"tableRow",view:(e,{writer:t})=>e.isEmpty?t.createEmptyElement("tr"):t.createContainerElement("tr")}),i.for("upcast").elementToElement({model:"tableCell",view:"td"}),i.for("upcast").elementToElement({model:"tableCell",view:"th"}),i.for("upcast").add(_b("td")),i.for("upcast").add(_b("th")),i.for("editingDowncast").elementToElement({model:"tableCell",view:Eb({asWidget:!0})}),i.for("dataDowncast").elementToElement({model:"tableCell",view:Eb()}),i.for("editingDowncast").elementToElement({model:"paragraph",view:Cb({asWidget:!0}),converterPriority:"high"}),i.for("dataDowncast").elementToElement({model:"paragraph",view:Cb(),converterPriority:"high"}),i.for("downcast").attributeToAttribute({model:"colspan",view:"colspan"}),i.for("upcast").attributeToAttribute({model:{key:"colspan",value:kw("colspan")},view:"colspan"}),i.for("downcast").attributeToAttribute({model:"rowspan",view:"rowspan"}),i.for("upcast").attributeToAttribute({model:{key:"rowspan",value:kw("rowspan")},view:"rowspan"}),e.config.define("table.defaultHeadings.rows",0),e.config.define("table.defaultHeadings.columns",0),e.commands.add("insertTable",new Tb(e)),e.commands.add("insertTableRowAbove",new Pb(e,{order:"above"})),e.commands.add("insertTableRowBelow",new Pb(e,{order:"below"})),e.commands.add("insertTableColumnLeft",new Ib(e,{order:"left"})),e.commands.add("insertTableColumnRight",new Ib(e,{order:"right"})),e.commands.add("removeTableRow",new Wb(e)),e.commands.add("removeTableColumn",new $b(e)),e.commands.add("splitTableCellVertically",new Ob(e,{direction:"vertically"})),e.commands.add("splitTableCellHorizontally",new Ob(e,{direction:"horizontally"})),e.commands.add("mergeTableCells",new ew(e)),e.commands.add("mergeTableCellRight",new Ub(e,{direction:"right"})),e.commands.add("mergeTableCellLeft",new Ub(e,{direction:"left"})),e.commands.add("mergeTableCellDown",new Ub(e,{direction:"down"})),e.commands.add("mergeTableCellUp",new Ub(e,{direction:"up"})),e.commands.add("setTableColumnHeader",new Gb(e)),e.commands.add("setTableRowHeader",new qb(e)),e.commands.add("selectTableRow",new ow(e)),e.commands.add("selectTableColumn",new rw(e)),sw(t),dw(t),this.listenTo(t.document,"change:data",(()=>{!function(e,t){const n=e.document.differ;for(const e of n.getChanges()){let n,i=!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;n=t,i="headingRows"==e.attributeKey}else"tableRow"!=e.name&&"tableCell"!=e.name||(n=e.position.findAncestor("table"),i="tableRow"==e.name);if(!n)continue;const o=n.getAttribute("headingRows")||0,r=n.getAttribute("headingColumns")||0,s=new yb(n);for(const e of s){const n=e.rowgw(e,t.mapper)));for(const e of n)t.reconvertItem(e)}}(t,e.editing)}))}registerAdditionalSlot(e){this._additionalSlots.push(e)}}function kw(e){return t=>{const n=parseInt(t.getAttribute(e));return Number.isNaN(n)||n<=0?null:n}}var _w=n(6516),vw={attributes:{"data-cke":!0}};vw.setAttributes=$o(),vw.insert=Zo().bind(null,"head"),vw.domAPI=Ho(),vw.insertStyleElement=Go();zo()(_w.Z,vw);_w.Z&&_w.Z.locals&&_w.Z.locals;class yw 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:n,column:i}=t.target.dataset;this.items.get(10*(parseInt(n,10)-1)+(parseInt(i,10)-1)).focus()})),this.focusTracker.on("change:focusedElement",((e,t,n)=>{if(!n)return;const{row:i,column:o}=n.dataset;this.set({rows:parseInt(i),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(((n,i)=>{const o=Math.floor(i/10){const i=e.commands.get("insertTable"),o=Fm(n);let r;return o.bind("isEnabled").to(i),o.buttonView.set({icon:'',label:t("Insert table"),tooltip:!0}),o.on("change:isOpen",(()=>{r||(r=new yw(n),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 i=[{type:"switchbutton",model:{commandName:"setTableColumnHeader",label:t("Header column"),bindIsOn:!0}},{type:"separator"},{type:"button",model:{commandName:n?"insertTableColumnLeft":"insertTableColumnRight",label:t("Insert column left")}},{type:"button",model:{commandName:n?"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"),'',i,e)})),e.ui.componentFactory.add("tableRow",(e=>{const n=[{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"),'',n,e)})),e.ui.componentFactory.add("mergeTableCells",(e=>{const i=[{type:"button",model:{commandName:"mergeTableCellUp",label:t("Merge cell up")}},{type:"button",model:{commandName:n?"mergeTableCellRight":"mergeTableCellLeft",label:t("Merge cell right")}},{type:"button",model:{commandName:"mergeTableCellDown",label:t("Merge cell down")}},{type:"button",model:{commandName:n?"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"),'',i,e)}))}_prepareDropdown(e,t,n,i){const o=this.editor,r=Fm(i),s=this._fillDropdownWithListOptions(r,n);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,n,i){const o=this.editor,r=Fm(i,Dm),s="mergeTableCells",a=o.commands.get(s),l=this._fillDropdownWithListOptions(r,n);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 n=this.editor,i=[],o=new To;for(const e of t)xw(e,n,i,o);return Zm(e,o),i}}function xw(e,t,n,i){if("button"===e.type||"switchbutton"===e.type){const i=e.model=new ug(e.model),{commandName:o,bindIsOn:r}=e.model,s=t.commands.get(o);n.push(s),i.set({commandName:o}),i.bind("isEnabled").to(s),r&&i.bind("isOn").to(s,"value"),i.set({withText:!0})}i.add(e)}var Ew=n(2794),Cw={attributes:{"data-cke":!0}};Cw.setAttributes=$o(),Cw.insert=Zo().bind(null,"head"),Cw.domAPI=Ho(),Cw.insertStyleElement=Go();zo()(Ew.Z,Cw);Ew.Z&&Ew.Z.locals&&Ew.Z.locals;class Sw extends vs{static get pluginName(){return"TableSelection"}static get requires(){return[Kb,Kb]}init(){const e=this.editor,t=e.model,n=e.editing.view;this.listenTo(t,"deleteContent",((e,t)=>this._handleDeleteContent(e,t)),{priority:"high"}),this.listenTo(n.document,"insertText",((e,t)=>this._handleInsertTextEvent(e,t)),{priority:"high"}),this._defineSelectionConverter(),this._enablePluginDisabling()}getSelectedTableCells(){const e=this.editor.plugins.get(Kb),t=this.editor.model.document.selection,n=e.getSelectedTableCells(t);return 0==n.length?null:n}getSelectionAsFragment(){const e=this.editor.plugins.get(Kb),t=this.getSelectedTableCells();return t?this.editor.model.change((n=>{const i=n.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=Fb(l,e),d=Hb(l,e)}const u=Mb(l,{startRow:s,startColumn:o,endRow:c,endColumn:d},n);return n.insert(u,i,0),i})):null}setCellSelection(e,t){const n=this._getCellsToSelect(e,t);this.editor.model.change((e=>{e.setSelection(n.cells.map((t=>e.createRangeOn(t))),{backward:n.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,n,i)=>{const o=i.writer;!function(e){for(const n of t)e.removeClass("ck-editor__editable_selected",n);t.clear()}(o);const r=this.getSelectedTableCells();if(!r)return;for(const e of r){const n=i.mapper.toViewElement(e);o.addClass("ck-editor__editable_selected",n),t.add(n)}const s=i.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((n=>{const i=n.createPositionAt(t[0],0),o=e.model.schema.getNearestSelectionRange(i);n.setSelection(o)}))}}))}_handleDeleteContent(e,t){const n=this.editor.plugins.get(Kb),i=t[0],o=t[1],r=this.editor.model,s=!o||"backward"==o.direction,a=n.getSelectedTableCells(i);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 n=r.schema.getNearestSelectionRange(e.createPositionAt(t,0));i.is("documentSelection")?e.setSelection(n):i.setTo(n)})))}_handleInsertTextEvent(e,t){const n=this.editor,i=this.getSelectedTableCells();if(!i)return;const o=n.editing.view,r=n.editing.mapper,s=i.map((e=>o.createRangeOn(r.toViewElement(e))));t.selection=o.createSelection(s)}_getCellsToSelect(e,t){const n=this.editor.plugins.get("TableUtils"),i=n.getCellLocation(e),o=n.getCellLocation(t),r=Math.min(i.row,o.row),s=Math.max(i.row,o.row),a=Math.min(i.column,o.column),l=Math.max(i.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:n}of new yb(e.findAncestor("table"),d))c[t-r].push(n);const u=o.rowe.reverse())),{cells:c.flat(),backward:u||h}}}class Tw extends vs{static get pluginName(){return"TableClipboard"}static get requires(){return[Sw,Kb]}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,n])=>this._onInsertContent(e,t,n)),{priority:"high"}),this.decorate("_replaceTableSlotCell")}_onCopyCut(e,t){const n=this.editor.plugins.get(Sw);if(!n.getSelectedTableCells())return;if("cut"==e.name&&!this.editor.model.canEditAt(this.editor.model.document.selection))return;t.preventDefault(),e.stop();const i=this.editor.data,o=this.editor.editing.view.document,r=i.toView(n.getSelectionAsFragment());o.fire("clipboardOutput",{dataTransfer:t.dataTransfer,content:r,method:e.name})}_onInsertContent(e,t,n){if(n&&!n.is("documentSelection"))return;const i=this.editor.model,o=this.editor.plugins.get(Kb);let r=this.getTableIfOnlyTableInContent(t,i);if(!r)return;const s=o.getSelectionAffectedTableCells(i.document.selection);s.length?(e.stop(),i.change((e=>{const t={width:o.getColumns(r),height:o.getRows(r)},n=function(e,t,n,i){const o=e[0].findAncestor("table"),r=i.getColumnIndexes(e),s=i.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,n,i){const o=i.getColumns(e),r=i.getRows(e);n>o&&i.insertColumns(e,{at:o,columns:n-o});t>r&&i.insertRows(e,{at:r,rows:t-r})}(o,a.lastRow+1,a.lastColumn+1,i));l||!i.isSelectionRectangular(e)?function(e,t,n){const{firstRow:i,lastRow:o,firstColumn:r,lastColumn:s}=t,a={first:i,last:o},l={first:r,last:s};Iw(e,r,a,n),Iw(e,s+1,a,n),Pw(e,i,l,n),Pw(e,o+1,l,n,i)}(o,a,n):(a.lastRow=Fb(o,a),a.lastColumn=Hb(o,a));return a}(s,t,e,o),i=n.lastRow-n.firstRow+1,a=n.lastColumn-n.firstColumn+1,l={startRow:0,startColumn:0,endRow:Math.min(i,t.height)-1,endColumn:Math.min(a,t.width)-1};r=Mb(r,l,e);const c=s[0].findAncestor("table"),d=this._replaceSelectedCellsWithPasted(r,t,c,n,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,n,i,o){const{width:r,height:s}=t,a=function(e,t,n){const i=new Array(n).fill(null).map((()=>new Array(t).fill(null)));for(const{column:t,row:n,cell:o}of new yb(e))i[n][t]=o;return i}(e,r,s),l=[...new yb(n,{startRow:i.firstRow,endRow:i.lastRow,startColumn:i.firstColumn,endColumn:i.lastColumn,includeAllSlots:!0})],c=[];let d;for(const e of l){const{row:t,column:n}=e;n===i.firstColumn&&(d=e.getPositionBefore());const l=t-i.firstRow,u=n-i.firstColumn,h=a[l%s][u%r],m=h?o.cloneElement(h):null,f=this._replaceTableSlotCell(e,m,d,o);f&&(Lb(f,t,n,i.lastRow,i.lastColumn,o),c.push(f),d=o.createPositionAfter(f))}const u=parseInt(n.getAttribute("headingRows")||"0"),h=parseInt(n.getAttribute("headingColumns")||"0"),m=i.firstRowOw(e,t,n))).map((({cell:e})=>Nb(e,t,i)))}function Iw(e,t,n,i){if(t<1)return;return Vb(e,t).filter((({row:e,cellHeight:t})=>Ow(e,t,n))).map((({cell:e,column:n})=>Db(e,n,t,i)))}function Ow(e,t,n){const i=e+t-1,{first:o,last:r}=n;return e>=o&&e<=r||e=o}class Mw extends vs{static get pluginName(){return"TableKeyboard"}static get requires(){return[Sw,Kb]}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 n=this.editor,i=n.model.document.selection.getSelectedElement();i&&i.is("element","table")&&(t.preventDefault(),t.stopPropagation(),e.stop(),n.model.change((e=>{e.setSelection(e.createRangeIn(i.getChild(0).getChild(0)))})))}_handleTab(e,t){const n=this.editor,i=this.editor.plugins.get(Kb),o=this.editor.plugins.get("TableSelection"),r=n.model.document.selection,s=!t.shiftKey;let a=i.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 n.model.change((e=>{e.setSelection(e.createRangeOn(c))}));const m=u===l.childCount-1,f=d===i.getRows(c)-1;if(s&&f&&m&&(n.execute("insertTableRowBelow"),d===i.getRows(c)-1))return void n.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));n.model.change((e=>{e.setSelection(e.createRangeIn(g))}))}_onArrowKey(e,t){const n=this.editor,i=yo(t.keyCode,n.locale.contentLanguageDirection);this._handleArrowKeys(i,t.shiftKey)&&(t.preventDefault(),t.stopPropagation(),e.stop())}_handleArrowKeys(e,t){const n=this.editor.plugins.get(Kb),i=this.editor.plugins.get("TableSelection"),o=this.editor.model,r=o.document.selection,s=["right","down"].includes(e),a=n.getSelectedTableCells(r);if(a.length){let n;return n=t?i.getFocusCell():s?a[a.length-1]:a[0],this._navigateFromCellInDirection(n,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,n){const i=this.editor.model,o=this.editor.model.schema,r=n?e.getLastPosition():e.getFirstPosition();if(!o.getLimitElement(r).is("element","tableCell")){return i.createPositionAt(t,n?"end":0).isTouching(r)}const s=i.createSelection(r);return i.modifySelection(s,{direction:n?"forward":"backward"}),r.isEqual(s.focus)}_navigateFromCellInDirection(e,t,n=!1){const i=this.editor.model,o=e.findAncestor("table"),r=[...new yb(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 i.change((e=>{e.setSelection(e.createRangeOn(o))}));d<0?(d=n?0:a,c--):d>a&&(d=n?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(n&&m.isEnabled){const t=m.getAnchorCell()||e;m.setCellSelection(t,u)}else{const e=i.createPositionAt(u,h?0:"end");i.change((t=>{t.setSelection(e)}))}}}class Rw extends rc{constructor(){super(...arguments),this.domEventType=["mousemove","mouseleave"]}onDomEvent(e){this.fire(e.type,e)}}class Nw extends vs{static get pluginName(){return"TableMouse"}static get requires(){return[Sw,Kb]}init(){this.editor.editing.view.addObserver(Rw),this._enableShiftClickSelection(),this._enableMouseDragSelection()}_enableShiftClickSelection(){const e=this.editor,t=e.plugins.get(Kb);let n=!1;const i=e.plugins.get(Sw);this.listenTo(e.editing.view.document,"mousedown",((o,r)=>{const s=e.model.document.selection;if(!this.isEnabled||!i.isEnabled)return;if(!r.domEvent.shiftKey)return;const a=i.getAnchorCell()||t.getTableCellsContainingSelection(s)[0];if(!a)return;const l=this._getModelTableCellFromDomEvent(r);l&&Vw(a,l)&&(n=!0,i.setCellSelection(a,l),r.preventDefault())})),this.listenTo(e.editing.view.document,"mouseup",(()=>{n=!1})),this.listenTo(e.editing.view.document,"selectionChange",(e=>{n&&e.stop()}),{priority:"highest"})}_enableMouseDragSelection(){const e=this.editor;let t,n,i=!1,o=!1;const r=e.plugins.get(Sw);this.listenTo(e.editing.view.document,"mousedown",((e,n)=>{this.isEnabled&&r.isEnabled&&(n.domEvent.shiftKey||n.domEvent.ctrlKey||n.domEvent.altKey||(t=this._getModelTableCellFromDomEvent(n)))})),this.listenTo(e.editing.view.document,"mousemove",((e,s)=>{if(!s.domEvent.buttons)return;if(!t)return;const a=this._getModelTableCellFromDomEvent(s);a&&Vw(t,a)&&(n=a,i||n==t||(i=!0)),i&&(o=!0,r.setCellSelection(t,n),s.preventDefault())})),this.listenTo(e.editing.view.document,"mouseup",(()=>{i=!1,o=!1,t=null,n=null})),this.listenTo(e.editing.view.document,"selectionChange",(e=>{o&&e.stop()}),{priority:"highest"})}_getModelTableCellFromDomEvent(e){const t=e.target,n=this.editor.editing.view.createPositionAt(t,0);return this.editor.editing.mapper.toModelPosition(n).parent.findAncestor("tableCell",{includeSelf:!0})}}function Vw(e,t){return e.parent.parent==t.parent.parent}var Dw=n(4418),Lw={attributes:{"data-cke":!0}};Lw.setAttributes=$o(),Lw.insert=Zo().bind(null,"head"),Lw.domAPI=Ho(),Lw.insertStyleElement=Go();zo()(Dw.Z,Lw);Dw.Z&&Dw.Z.locals&&Dw.Z.locals;class Bw extends vs{static get requires(){return[ww,Aw,Sw,Nw,Mw,Tw,Xp]}static get pluginName(){return"Table"}}function jw(e,t,n,i){let o,r=null;"function"==typeof i?o=i:(r=e.commands.get(i),o=()=>{e.execute(i)}),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 i&&!["numberedList","bulletedList","todoList"].includes(i))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=n.exec(h.data.substr(0,l.end.offset));f&&e.model.enqueueChange((t=>{const n=t.createPositionAt(u,0),i=t.createPositionAt(u,f[0].length),r=new gd(n,i);if(!1!==o({match:f})){t.remove(r);const n=e.model.document.selection.getFirstRange(),i=t.createRangeIn(u);!u.isEmpty||i.isEqual(n)||i.containsRange(n,!0)||t.remove(u)}r.detach(),e.model.enqueueChange((()=>{e.plugins.get("Delete").requestUndoOnBackspace()}))}))}))}function zw(e,t,n,i){let o,r;n instanceof RegExp?o=n:r=n,r=r||(e=>{let t;const n=[],i=[];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];n.push(l),n.push(c),i.push([e+o.length,e+o.length+r.length])}return{remove:n,format:i}}),e.model.document.on("change:data",((n,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 n=e.start;const i=Array.from(e.getItems()).reduce(((e,i)=>!i.is("$text")&&!i.is("$textProxy")||i.getAttribute("code")?(n=t.createPositionAfter(i),""):e+i.data),"");return{text:i,range:t.createRange(n,e.end)}}(s.createRange(s.createPositionAt(u,0),d),s),f=r(h),g=Fw(m.start,f.format,s),p=Fw(m.start,f.remove,s);g.length&&p.length&&s.enqueueChange((t=>{if(!1!==i(t,g)){for(const e of p.reverse())t.remove(e);s.enqueueChange((()=>{e.plugins.get("Delete").requestUndoOnBackspace()}))}}))}))}function Fw(e,t,n){return t.filter((e=>void 0!==e[0]&&void 0!==e[1])).map((t=>n.createRange(e.getShiftedBy(t[0]),e.getShiftedBy(t[1]))))}class Hw 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")&&jw(this.editor,this,/^[*-]\s$/,"bulletedList"),e.get("numberedList")&&jw(this.editor,this,/^1[.|)]\s$/,"numberedList"),e.get("todoList")&&jw(this.editor,this,/^\[\s?\]\s$/,"todoList"),e.get("checkTodoList")&&jw(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=Uw(this.editor,"bold");zw(this.editor,this,/(?:^|\s)(\*\*)([^*]+)(\*\*)$/g,e),zw(this.editor,this,/(?:^|\s)(__)([^_]+)(__)$/g,e)}if(e.get("italic")){const e=Uw(this.editor,"italic");zw(this.editor,this,/(?:^|\s)(\*)([^*_]+)(\*)$/g,e),zw(this.editor,this,/(?:^|\s)(_)([^_]+)(_)$/g,e)}if(e.get("code")){const e=Uw(this.editor,"code");zw(this.editor,this,/(`)([^`]+)(`)$/g,e)}if(e.get("strikethrough")){const e=Uw(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 n=t[7],i=new RegExp(`^(#{${n}})\\s$`);jw(this.editor,this,i,(()=>{if(!e.isEnabled||e.value===t)return!1;this.editor.execute("heading",{value:t})}))}))}_addBlockQuoteAutoformats(){this.editor.commands.get("blockQuote")&&jw(this.editor,this,/^>\s$/,"blockQuote")}_addCodeBlockAutoformats(){const e=this.editor,t=e.model.document.selection;e.commands.get("codeBlock")&&jw(e,this,/^```$/,(()=>{if(t.getFirstPosition().parent.is("element","listItem"))return!1;this.editor.execute("codeBlock",{usePreviousLanguageChoice:!0})}))}_addHorizontalLineAutoformats(){this.editor.commands.get("horizontalLine")&&jw(this.editor,this,/^---$/,"horizontalLine")}}function Uw(e,t){return(n,i)=>{if(!e.commands.get(t).isEnabled)return!1;const o=e.model.schema.getValidRanges(i,t);for(const e of o)n.setAttribute(t,!0,e);n.removeSelectionAttribute(t)}}class Zw extends rc{constructor(e){super(e),this.domEventType=["paste","copy","cut","drop","dragover","dragstart","dragend","dragenter","dragleave"];const t=this.document;function n(e){return(n,i)=>{i.preventDefault();const o=i.dropRange?[i.dropRange]:null,r=new p(t,e);t.fire(r,{dataTransfer:i.dataTransfer,method:n.name,targetRanges:o,target:i.target,domEvent:i.domEvent}),r.stop.called&&i.stopPropagation()}}this.listenTo(t,"paste",n("clipboardInput"),{priority:"low"}),this.listenTo(t,"drop",n("clipboardInput"),{priority:"low"}),this.listenTo(t,"dragover",n("dragging"),{priority:"low"})}onDomEvent(e){const t="clipboardData"in e?e.clipboardData:e.dataTransfer,n="drop"==e.type||"paste"==e.type,i={dataTransfer:new Nc(t,{cacheFiles:n})};"drop"!=e.type&&"dragover"!=e.type||(i.dropRange=function(e,t){const n=t.target.ownerDocument,i=t.clientX,o=t.clientY;let r;n.caretRangeFromPoint&&n.caretRangeFromPoint(i,o)?r=n.caretRangeFromPoint(i,o):t.rangeParent&&(r=n.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,i)}}const Ww=["figcaption","li"];function $w(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 n=null;for(const i of e.getChildren()){const e=$w(i);n&&(n.is("containerElement")||i.is("containerElement"))&&(Ww.includes(n.name)||Ww.includes(i.name)?t+="\n":t+="\n\n"),t+=e,n=i}}return t}class qw extends vs{static get pluginName(){return"ClipboardPipeline"}init(){this.editor.editing.view.addObserver(Zw),this._setupPasteDrop(),this._setupCopyCut()}_setupPasteDrop(){const e=this.editor,t=e.model,n=e.editing.view,i=n.document;this.listenTo(i,"clipboardInput",((t,n)=>{"paste"!=n.method||e.model.canEditAt(e.model.document.selection)||t.stop()}),{priority:"highest"}),this.listenTo(i,"clipboardInput",((e,t)=>{const i=t.dataTransfer;let o;if(t.content)o=t.content;else{let e="";i.getData("text/html")?e=function(e){return e.replace(/(\s+)<\/span>/g,((e,t)=>1==t.length?" ":t)).replace(//g,"")}(i.getData("text/html")):i.getData("text/plain")&&(((r=(r=i.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:i,targetRanges:t.targetRanges,method:t.method}),s.stop.called&&e.stop(),n.scrollToTheSelection()}),{priority:"low"}),this.listenTo(this,"inputTransformation",((e,n)=>{if(n.content.isEmpty)return;const i=this.editor.data.toModel(n.content,"$clipboardHolder");0!=i.childCount&&(e.stop(),t.change((()=>{this.fire("contentInsertion",{content:i,method:n.method,dataTransfer:n.dataTransfer,targetRanges:n.targetRanges})})))}),{priority:"low"}),this.listenTo(this,"contentInsertion",((e,n)=>{n.resultRange=t.insertContent(n.content)}),{priority:"low"})}_setupCopyCut(){const e=this.editor,t=e.model.document,n=e.editing.view.document,i=(i,o)=>{const r=o.dataTransfer;o.preventDefault();const s=e.data.toView(e.model.getSelectedContent(t.selection));n.fire("clipboardOutput",{dataTransfer:r,content:s,method:i.name})};this.listenTo(n,"copy",i,{priority:"low"}),this.listenTo(n,"cut",((t,n)=>{e.model.canEditAt(e.model.document.selection)?i(t,n):n.preventDefault()}),{priority:"low"}),this.listenTo(n,"clipboardOutput",((n,i)=>{i.content.isEmpty||(i.dataTransfer.setData("text/html",this.editor.data.htmlProcessor.toData(i.content)),i.dataTransfer.setData("text/plain",$w(i.content))),"cut"==i.method&&e.model.deleteContent(t.selection)}),{priority:"low"})}}var Gw=n(3352),Kw={attributes:{"data-cke":!0}};Kw.setAttributes=$o(),Kw.insert=Zo().bind(null,"head"),Kw.domAPI=Ho(),Kw.insertStyleElement=Go();zo()(Gw.Z,Kw);Gw.Z&&Gw.Z.locals&&Gw.Z.locals;class Yw extends vs{static get pluginName(){return"DragDrop"}static get requires(){return[qw,Xp]}init(){const e=this.editor,t=e.editing.view;this._draggedRange=null,this._draggingUid="",this._draggableElement=null,this._updateDropMarkerThrottled=Wf((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(Zw),t.addObserver(Fh),this._setupDragging(),this._setupContentInsertionIntegration(),this._setupClipboardInputIntegration(),this._setupDropMarker(),this._setupDraggableAttributeHandling(),this.listenTo(e,"change:isReadOnly",((e,t,n)=>{n?this.forceDisabled("readOnlyMode"):this.clearForceDisabled("readOnlyMode")})),this.on("change:isEnabled",((e,t,n)=>{n||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,n=t.document,i=e.editing.view,o=i.document;this.listenTo(o,"dragstart",((i,r)=>{const s=n.selection;if(r.target&&r.target.is("editableElement"))return void r.preventDefault();const a=r.target?Xw(r.target):null;if(a){const n=e.editing.mapper.toModelElement(a);if(this._draggedRange=gd.fromRange(t.createRangeOn(n)),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&&i.focus()})),this.listenTo(o,"dragleave",(()=>{this._removeDropMarkerDelayed()})),this.listenTo(o,"dragging",((t,n)=>{if(!this.isEnabled)return void(n.dataTransfer.dropEffect="none");this._removeDropMarkerDelayed.cancel();const i=Qw(e,n.targetRanges,n.target);e.model.canEditAt(i)?(this._draggedRange||(n.dataTransfer.dropEffect="copy"),c.isGecko||("copy"==n.dataTransfer.effectAllowed?n.dataTransfer.dropEffect="copy":["all","copyMove"].includes(n.dataTransfer.effectAllowed)&&(n.dataTransfer.dropEffect="move")),i&&this._updateDropMarkerThrottled(i)):n.dataTransfer.dropEffect="none"}),{priority:"low"})}_setupClipboardInputIntegration(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"clipboardInput",((t,n)=>{if("drop"!=n.method)return;const i=Qw(e,n.targetRanges,n.target);if(this._removeDropMarker(),!i||!e.model.canEditAt(i))return this._finalizeDragging(!1),void t.stop();this._draggedRange&&this._draggingUid!=n.dataTransfer.getData("application/ckeditor5-dragging-uid")&&(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="");if("move"==Jw(n.dataTransfer)&&this._draggedRange&&this._draggedRange.containsRange(i,!0))return this._finalizeDragging(!1),void t.stop();n.targetRanges=[e.editing.mapper.toViewRange(i)]}),{priority:"high"})}_setupContentInsertionIntegration(){const e=this.editor.plugins.get(qw);e.on("contentInsertion",((e,t)=>{if(!this.isEnabled||"drop"!==t.method)return;const n=t.targetRanges.map((e=>this.editor.editing.mapper.toModelRange(e)));this.editor.model.change((e=>e.setSelection(n)))}),{priority:"high"}),e.on("contentInsertion",((e,t)=>{if(!this.isEnabled||"drop"!==t.method)return;const n="move"==Jw(t.dataTransfer),i=!t.resultRange||!t.resultRange.isCollapsed;this._finalizeDragging(i&&n)}),{priority:"lowest"})}_setupDraggableAttributeHandling(){const e=this.editor,t=e.editing.view,n=t.document;this.listenTo(n,"mousedown",((i,o)=>{if(c.isAndroid||!o)return;this._clearDraggableAttributesDelayed.cancel();let r=Xw(o.target);if(c.isBlink&&!r&&!n.selection.isCollapsed){const e=n.selection.getSelectedElement();if(!e||!Op(e)){const e=n.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(n,"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:n})=>{if(e.model.schema.checkChild(t.markerRange.start,"$text"))return n.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,n=t.model.markers;t.model.change((t=>{n.has("drop-target")?n.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,n=t.model;if(this._removeDropMarker(),this._clearDraggableAttributes(),t.plugins.has("WidgetToolbarRepository")){t.plugins.get("WidgetToolbarRepository").clearForceDisabled("dragDrop")}this._draggingUid="",this._draggedRange&&(e&&this.isEnabled&&n.deleteContent(n.createSelection(this._draggedRange),{doNotAutoparagraph:!0}),this._draggedRange.detach(),this._draggedRange=null)}}function Qw(e,t,n){const i=e.model,o=e.editing.mapper;let r=null;const s=t?t[0].start:null;if(n.is("uiElement")&&(n=n.parent),r=function(e,t){const n=e.model,i=e.editing.mapper;if(Op(t))return n.createRangeOn(i.toModelElement(t));if(!t.is("editableElement")){const e=t.findAncestor((e=>Op(e)||e.is("editableElement")));if(Op(e))return n.createRangeOn(i.toModelElement(e))}return null}(e,n),r)return r;const a=function(e,t){const n=e.editing.mapper,i=e.editing.view,o=n.toModelElement(t);if(o)return o;const r=i.createPositionBefore(t),s=n.findMappedViewAncestor(r);return n.toModelElement(s)}(e,n),l=s?o.toModelPosition(s):null;return l?(r=function(e,t,n){const i=e.model;if(!i.schema.checkChild(n,"$block"))return null;const o=i.createPositionAt(n,0),r=t.path.slice(0,o.path.length),s=i.createPositionFromPath(t.root,r),a=s.nodeAfter;if(a&&i.schema.isObject(a))return i.createRangeOn(a);return null}(e,l,a),r||(r=i.schema.getNearestSelectionRange(l,c.isGecko?"forward":"backward"),r||function(e,t){const n=e.model;let i=t;for(;i;){if(n.schema.isObject(i))return n.createRangeOn(i);i=i.parent}return null}(e,l.parent))):function(e,t){const n=e.model,i=n.schema,o=n.createPositionAt(t,0);return i.getNearestSelectionRange(o,"forward")}(e,a)}function Jw(e){return c.isGecko?e.dropEffect:["all","copyMove"].includes(e.effectAllowed)?"move":"copy"}function Xw(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 ek extends vs{static get pluginName(){return"PastePlainText"}static get requires(){return[qw]}init(){const e=this.editor,t=e.model,n=e.editing.view,i=n.document,o=t.document.selection;let r=!1;n.addObserver(Zw),this.listenTo(i,"keydown",((e,t)=>{r=t.shiftKey})),e.plugins.get(qw).on("contentInsertion",((e,n)=>{(r||function(e,t){if(e.childCount>1)return!1;const n=e.getChild(0);if(t.isObject(n))return!1;return 0==Array.from(n.getAttributeKeys()).length}(n.content,t.schema))&&t.change((e=>{const i=Array.from(o.getAttributes()).filter((([e])=>t.schema.getAttributeProperties(e).isFormatting));o.isCollapsed||t.deleteContent(o,{doNotAutoparagraph:!0}),i.push(...o.getAttributes());const r=e.createRangeIn(n.content);for(const t of r.getItems())t.is("$textProxy")&&e.setAttributes(i,t)}))}))}}class tk extends vs{static get pluginName(){return"Clipboard"}static get requires(){return[qw,Yw,ek]}}Ki("px");class nk extends As{constructor(e){super(e),this.affectsData=!1}execute(){const e=this.editor.model,t=e.document.selection;let n=e.schema.getLimitElement(t);if(t.containsEntireContent(n)||!ik(e.schema,n))do{if(n=n.parent,!n)return}while(!ik(e.schema,n));e.change((e=>{e.setSelection(n,"in")}))}}function ik(e,t){return e.isLimit(t)&&(e.checkChild(t,"$text")||e.checkChild(t,"paragraph"))}const ok=_o("Ctrl+A");class rk extends vs{static get pluginName(){return"SelectAllEditing"}init(){const e=this.editor,t=e.editing.view.document;e.commands.add("selectAll",new nk(e)),this.listenTo(t,"keydown",((t,n)=>{ko(n)===ok&&(e.execute("selectAll"),n.preventDefault())}))}}class sk extends vs{static get pluginName(){return"SelectAllUI"}init(){const e=this.editor;e.ui.componentFactory.add("selectAll",(t=>{const n=e.commands.get("selectAll"),i=new Er(t),o=t.t;return i.set({label:o("Select all"),icon:'',keystroke:"Ctrl+A",tooltip:!0}),i.bind("isEnabled").to(n,"isEnabled"),this.listenTo(i,"execute",(()=>{e.execute("selectAll"),e.editing.view.focus()})),i}))}}class ak extends vs{static get requires(){return[rk,sk]}static get pluginName(){return"SelectAll"}}class lk 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 n=t[1];n.batchType||(n.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,n={ranges:t.hasOwnRange?Array.from(t.getRanges()):[],isBackward:t.isBackward};this._stack.push({batch:e,selection:n}),this.refresh()}clearStack(){this._stack=[],this.refresh()}_restoreSelection(e,t,n){const i=this.editor.model,o=i.document,r=[],s=e.map((e=>e.getTransformedByOperations(n))),a=s.flat();for(const e of s){const t=e.filter((e=>e.root!=o.graveyard)).filter((e=>!dk(e,a)));t.length&&(ck(t),r.push(t[0]))}r.length&&i.change((e=>{e.setSelection(r,{backward:t})}))}_undo(e,t){const n=this.editor.model,i=n.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(i.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&&!n.canEditAt(r)&&(o=new Lu(o.baseVersion)),t.addOperation(o),n.applyOperation(o),i.history.setOperationAsUndone(e,o)}}}}function ck(e){e.sort(((e,t)=>e.start.isBefore(t.start)?-1:1));for(let t=1;tt!==e&&t.containsRange(e,!0)))}class uk extends lk{execute(e=null){const t=e?this._stack.findIndex((t=>t.batch==e)):this._stack.length-1,n=this._stack.splice(t,1)[0],i=this.editor.model.createBatch({isUndo:!0});this.editor.model.enqueueChange(i,(()=>{this._undo(n.batch,i);const e=this.editor.model.document.history.getOperations(n.batch.baseVersion);this._restoreSelection(n.selection.ranges,n.selection.isBackward,e),this.fire("revert",n.batch,i)})),this.refresh()}}class hk extends lk{execute(){const e=this._stack.pop(),t=this.editor.model.createBatch({isUndo:!0});this.editor.model.enqueueChange(t,(()=>{const n=e.batch.operations[e.batch.operations.length-1].baseVersion+1,i=this.editor.model.document.history.getOperations(n);this._restoreSelection(e.selection.ranges,e.selection.isBackward,i),this._undo(e.batch,t)})),this.refresh()}}class mk extends vs{constructor(){super(...arguments),this._batchRegistry=new WeakSet}static get pluginName(){return"UndoEditing"}init(){const e=this.editor;this._undoCommand=new uk(e),this._redoCommand=new hk(e),e.commands.add("undo",this._undoCommand),e.commands.add("redo",this._redoCommand),this.listenTo(e.model,"applyOperation",((e,t)=>{const n=t[0];if(!n.isDocumentOperation)return;const i=n.batch,o=this._redoCommand.createdBatches.has(i),r=this._undoCommand.createdBatches.has(i);this._batchRegistry.has(i)||(this._batchRegistry.add(i),i.isUndoable&&(o?this._undoCommand.addBatch(i):r||(this._undoCommand.addBatch(i),this._redoCommand.clearStack())))}),{priority:"highest"}),this.listenTo(this._undoCommand,"revert",((e,t,n)=>{this._redoCommand.addBatch(n)})),e.keystrokes.set("CTRL+Z","undo"),e.keystrokes.set("CTRL+Y","redo"),e.keystrokes.set("CTRL+SHIFT+Z","redo")}}const fk='',gk='';class pk extends vs{static get pluginName(){return"UndoUI"}init(){const e=this.editor,t=e.locale,n=e.t,i="ltr"==t.uiLanguageDirection?fk:gk,o="ltr"==t.uiLanguageDirection?gk:fk;this._addButton("undo",n("Undo"),"CTRL+Z",i),this._addButton("redo",n("Redo"),"CTRL+Y",o)}_addButton(e,t,n,i){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:i,keystroke:n,tooltip:!0}),a.bind("isEnabled").to(s,"isEnabled"),this.listenTo(a,"execute",(()=>{o.execute(e),o.editing.view.focus()})),a}))}}class bk extends vs{static get requires(){return[mk,pk]}static get pluginName(){return"Undo"}}class wk extends vs{static get requires(){return[tk,kp,ak,Ap,np,bk]}static get pluginName(){return"Essentials"}}class kk extends As{refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,n=t.schema,i=t.document.selection,o=Array.from(i.getSelectedBlocks()),r=void 0===e.forceValue?!this.value:e.forceValue;t.change((e=>{if(r){const t=o.filter((e=>_k(e)||yk(n,e)));this._applyQuote(e,t)}else this._removeQuote(e,o.filter(_k))}))}_getValue(){const e=Po(this.editor.model.document.selection.getSelectedBlocks());return!(!e||!_k(e))}_checkEnabled(){if(this.value)return!0;const e=this.editor.model.document.selection,t=this.editor.model.schema,n=Po(e.getSelectedBlocks());return!!n&&yk(t,n)}_removeQuote(e,t){vk(e,t).reverse().forEach((t=>{if(t.start.isAtStart&&t.end.isAtEnd)return void e.unwrap(t.start.parent);if(t.start.isAtStart){const n=e.createPositionBefore(t.start.parent);return void e.move(t,n)}t.end.isAtEnd||e.split(t.end);const n=e.createPositionAfter(t.end.parent);e.move(t,n)}))}_applyQuote(e,t){const n=[];vk(e,t).reverse().forEach((t=>{let i=_k(t.start);i||(i=e.createElement("blockQuote"),e.wrap(t,i)),n.push(i)})),n.reverse().reduce(((t,n)=>t.nextSibling==n?(e.merge(e.createPositionAfter(t)),t):n))}}function _k(e){return"blockQuote"==e.parent.name?e.parent:null}function vk(e,t){let n,i=0;const o=[];for(;i{const i=e.model.document.differ.getChanges();for(const e of i)if("insert"==e.type){const i=e.position.nodeAfter;if(!i)continue;if(i.is("element","blockQuote")&&i.isEmpty)return n.remove(i),!0;if(i.is("element","blockQuote")&&!t.checkChild(e.position,i))return n.unwrap(i),!0;if(i.is("element")){const e=n.createRangeIn(i);for(const i of e.getItems())if(i.is("element","blockQuote")&&!t.checkChild(n.createPositionBefore(i),i))return n.unwrap(i),!0}}else if("remove"==e.type){const t=e.position.parent;if(t.is("element","blockQuote")&&t.isEmpty)return n.remove(t),!0}return!1}));const n=this.editor.editing.view.document,i=e.model.document.selection,o=e.commands.get("blockQuote");this.listenTo(n,"enter",((t,n)=>{if(!i.isCollapsed||!o.value)return;i.getLastPosition().parent.isEmpty&&(e.execute("blockQuote"),e.editing.view.scrollToTheSelection(),n.preventDefault(),t.stop())}),{context:"blockquote"}),this.listenTo(n,"delete",((t,n)=>{if("backward"!=n.direction||!i.isCollapsed||!o.value)return;const r=i.getLastPosition().parent;r.isEmpty&&!r.previousSibling&&(e.execute("blockQuote"),e.editing.view.scrollToTheSelection(),n.preventDefault(),t.stop())}),{context:"blockquote"})}}var xk=n(5558),Ek={attributes:{"data-cke":!0}};Ek.setAttributes=$o(),Ek.insert=Zo().bind(null,"head"),Ek.domAPI=Ho(),Ek.insertStyleElement=Go();zo()(xk.Z,Ek);xk.Z&&xk.Z.locals&&xk.Z.locals;class Ck extends vs{static get pluginName(){return"BlockQuoteUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add("blockQuote",(n=>{const i=e.commands.get("blockQuote"),o=new Er(n);return o.set({label:t("Block quote"),icon:_m.quote,tooltip:!0,isToggleable:!0}),o.bind("isOn","isEnabled").to(i,"value","isEnabled"),this.listenTo(o,"execute",(()=>{e.execute("blockQuote"),e.editing.view.focus()})),o}))}}class Sk extends vs{static get requires(){return[Ak,Ck]}static get pluginName(){return"BlockQuote"}}function Tk(e){const t=e.t,n=e.config.get("codeBlock.languages");for(const e of n)"Plain text"===e.label&&(e.label=t("Plain text")),void 0===e.class&&(e.class=`language-${e.language}`);return n}function Pk(e,t,n){const i={};for(const o of e)if("class"===t){i[o[t].split(" ").shift()]=o[n]}else i[o[t]]=o[n];return i}function Ik(e){return e.data.match(/^(\s*)/)[0]}function Ok(e){const t=e.document.selection,n=[];if(t.isCollapsed)return[t.anchor];const i=t.getFirstRange().getWalker({ignoreElementEnd:!0,direction:"backward"});for(const{item:t}of i){if(!t.is("$textProxy"))continue;const{parent:i,startOffset:o}=t.textNode;if(!i.is("element","codeBlock"))continue;const r=Ik(t.textNode),s=e.createPositionAt(i,o+r.length);n.push(s)}return n}function Mk(e){const t=Po(e.getSelectedBlocks());return!!t&&t.is("element","codeBlock")}function Rk(e,t){return!t.is("rootElement")&&!e.isLimit(t)&&e.checkChild(t.parent,"codeBlock")}class Nk extends As{constructor(e){super(e),this._lastLanguage=null}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor,n=t.model,i=n.document.selection,o=Tk(t)[0],r=Array.from(i.getSelectedBlocks()),s=null==e.forceValue?!this.value:e.forceValue,a=function(e,t,n){if(e.language)return e.language;if(e.usePreviousLanguageChoice&&t)return t;return n}(e,this._lastLanguage,o.language);n.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,n=Po(e.getSelectedBlocks());return!!n&&Rk(t,n)}_applyCodeBlock(e,t,n){this._lastLanguage=n;const i=this.editor.model.schema,o=t.filter((e=>Rk(i,e)));for(const t of o)e.rename(t,"codeBlock"),e.setAttribute("language",n,t),i.removeDisallowedAttributes([t],e),Array.from(t.getChildren()).filter((e=>!i.checkChild(t,e))).forEach((t=>e.remove(t)));o.reverse().forEach(((t,n)=>{const i=o[n+1];t.previousSibling===i&&(e.appendElement("softBreak",i),e.merge(e.createPositionBefore(t)))}))}_removeCodeBlock(e,t){const n=t.filter((e=>e.is("element","codeBlock")));for(const t of n){const n=e.createRangeOn(t);for(const t of Array.from(n.getItems()).reverse())if(t.is("element","softBreak")&&t.parent.is("element","codeBlock")){const{position:n}=e.split(e.createPositionBefore(t)),i=n.nodeAfter;e.rename(i,"paragraph"),e.removeAttribute("language",i),e.remove(t)}e.rename(t,"paragraph"),e.removeAttribute("language",t)}}}class Vk 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 n=Ok(e);for(const i of n){const n=t.createText(this._indentSequence);e.insertContent(n,i)}}))}_checkEnabled(){return!!this._indentSequence&&Mk(this.editor.model.document.selection)}}class Dk 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=Ok(e);for(const n of t){const t=Lk(e,n,this._indentSequence);t&&e.deleteContent(e.createSelection(t))}}))}_checkEnabled(){if(!this._indentSequence)return!1;const e=this.editor.model;return!!Mk(e.document.selection)&&Ok(e).some((t=>Lk(e,t,this._indentSequence)))}}function Lk(e,t,n){const i=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(!i)return null;const o=Ik(i),r=o.lastIndexOf(n);if(r+n.length!==o.length)return null;if(-1===r)return null;const{parent:s,startOffset:a}=i;return e.createRange(e.createPositionAt(s,a+r),e.createPositionAt(s,a+r+n.length))}function Bk(e,t,n=!1){const i=Pk(t,"language","class"),o=Pk(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={};n&&(h["data-language"]=o[d],h.spellcheck="false");const m=i[d]?{class:i[d]}:void 0,f=a.createContainerElement("code",m),g=a.createContainerElement("pre",h,f);a.insert(u,g),l.bindElements(r.item,f)}}const jk="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,n=e.model,i=e.editing.view,o=e.plugins.has("DocumentListEditing"),r=Tk(e);e.commands.add("codeBlock",new Nk(e)),e.commands.add("indentCodeBlock",new Vk(e)),e.commands.add("outdentCodeBlock",new Dk(e)),this.listenTo(i.document,"tab",((t,n)=>{const i=n.shiftKey?"outdentCodeBlock":"indentCodeBlock";e.commands.get(i).isEnabled&&(e.execute(i),n.stopPropagation(),n.preventDefault(),t.stop())}),{context:"pre"}),t.register("codeBlock",{allowWhere:"$block",allowChildren:"$text",isBlock:!0,allowAttributes:["language"]}),t.addAttributeCheck(((e,t)=>{const n=e.endsWith("codeBlock")&&t.startsWith("list")&&"list"!==t;return!(!o||!n)||!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",Bk(n,r,!0)),e.data.downcastDispatcher.on("insert:codeBlock",Bk(n,r)),e.data.downcastDispatcher.on("insert:softBreak",function(e){return(t,n,i)=>{if("codeBlock"!==n.item.parent.name)return;const{writer:o,mapper:r,consumable:s}=i;if(!s.consume(n.item,"insert"))return;const a=r.toViewPosition(e.createPositionBefore(n.item));o.insert(a,o.createText("\n"))}}(n),{priority:"high"}),e.data.upcastDispatcher.on("element:code",function(e,t){const n=Pk(t,"class","language"),i=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=n[e];if(t){l.setAttribute("language",t,c);break}}c.hasAttribute("language")||l.setAttribute("language",i,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:n,writer:i})=>{let o=t.modelCursor;if(!n.test(t.viewItem))return;if(!o.findAncestor("codeBlock"))return;n.consume(t.viewItem);const r=t.viewItem.data.split("\n").map((e=>i.createText(e))),s=r[r.length-1];for(const e of r)if(i.insert(e,o),o=o.getShiftedBy(e.offsetSize),e!==s){const e=i.createElement("softBreak");i.insert(e,o),o=i.createPositionAfter(e)}t.modelRange=i.createRange(t.modelCursor,o),t.modelCursor=o})),e.data.upcastDispatcher.on("element:pre",((e,t,{consumable:n})=>{const i=t.viewItem;if(i.findAncestor("pre"))return;const o=Array.from(i.getChildren()),r=o.find((e=>e.is("element","code")));if(r)for(const e of o)e!==r&&e.is("$text")&&n.consume(e,{name:!0})}),{priority:"high"}),this.listenTo(e.editing.view.document,"clipboardInput",((t,i)=>{let o=n.createRange(n.document.selection.anchor);if(i.targetRanges&&(o=e.editing.mapper.toModelRange(i.targetRanges[0])),!o.start.parent.is("element","codeBlock"))return;const r=i.dataTransfer.getData("text/plain"),s=new Hh(e.editing.view.document);i.content=function(e,t){const n=e.createDocumentFragment(),i=t.split("\n"),o=i.reduce(((t,n,o)=>(t.push(n),o{const o=i.anchor;!i.isCollapsed&&o.parent.is("element","codeBlock")&&o.hasSameParentAs(i.focus)&&n.change((n=>{const r=e.return;if(o.parent.is("element")&&(r.childCount>1||i.containsEntireContent(o.parent))){const t=n.createElement("codeBlock",o.parent.getAttributes());n.append(r,t);const i=n.createDocumentFragment();return n.append(t,i),void(e.return=i)}const s=r.getChild(0);t.checkAttribute(s,"code")&&n.setAttribute("code",!0,s)}))}))}afterInit(){const e=this.editor,t=e.commands,n=t.get("indent"),i=t.get("outdent");n&&n.registerChildCommand(t.get("indentCodeBlock"),{priority:"highest"}),i&&i.registerChildCommand(t.get("outdentCodeBlock")),this.listenTo(e.editing.view.document,"enter",((t,n)=>{e.model.document.selection.getLastPosition().parent.is("element","codeBlock")&&(function(e,t){const n=e.model,i=n.document,o=e.editing.view,r=i.selection.getLastPosition(),s=r.nodeAfter;if(t||!i.selection.isCollapsed||!r.isAtStart)return!1;if(!Hk(s))return!1;return e.model.change((t=>{e.execute("enter");const n=i.selection.anchor.parent.previousSibling;t.rename(n,jk),t.setSelection(n,"in"),e.model.schema.removeDisallowedAttributes([n],t),t.remove(s)})),o.scrollToTheSelection(),!0}(e,n.isSoft)||function(e,t){const n=e.model,i=n.document,o=e.editing.view,r=i.selection.getLastPosition(),s=r.nodeBefore;let a;if(t||!i.selection.isCollapsed||!r.isAtEnd||!s||!s.previousSibling)return!1;if(Hk(s)&&Hk(s.previousSibling))a=n.createRange(n.createPositionBefore(s.previousSibling),n.createPositionAfter(s));else if(Fk(s)&&Hk(s.previousSibling)&&Hk(s.previousSibling.previousSibling))a=n.createRange(n.createPositionBefore(s.previousSibling.previousSibling),n.createPositionAfter(s));else{if(!(Fk(s)&&Hk(s.previousSibling)&&Fk(s.previousSibling.previousSibling)&&s.previousSibling.previousSibling&&Hk(s.previousSibling.previousSibling.previousSibling)))return!1;a=n.createRange(n.createPositionBefore(s.previousSibling.previousSibling.previousSibling),n.createPositionAfter(s))}return e.model.change((t=>{t.remove(a),e.execute("enter");const n=i.selection.anchor.parent;t.rename(n,jk),e.model.schema.removeDisallowedAttributes([n],t)})),o.scrollToTheSelection(),!0}(e,n.isSoft)||function(e){const t=e.model,n=t.document,i=n.selection.getLastPosition(),o=i.nodeBefore||i.textNode;let r;o&&o.is("$text")&&(r=Ik(o));e.model.change((t=>{e.execute("shiftEnter"),r&&t.insertText(r,n.selection.anchor)}))}(e),n.preventDefault(),t.stop())}),{context:"pre"})}}function Fk(e){return e&&e.is("$text")&&!e.data.match(/\S/)}function Hk(e){return e&&e.is("element","softBreak")}var Uk=n(348),Zk={attributes:{"data-cke":!0}};Zk.setAttributes=$o(),Zk.insert=Zo().bind(null,"head"),Zk.domAPI=Ho(),Zk.insertStyleElement=Go();zo()(Uk.Z,Zk);Uk.Z&&Uk.Z.locals&&Uk.Z.locals;class Wk extends vs{static get pluginName(){return"CodeBlockUI"}init(){const e=this.editor,t=e.t,n=e.ui.componentFactory,i=Tk(e);n.add("codeBlock",(n=>{const o=e.commands.get("codeBlock"),r=Fm(n,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),Zm(r,(()=>this._getLanguageListItemDefinitions(i)),{role:"menu",ariaLabel:a}),r}))}_getLanguageListItemDefinitions(e){const t=this.editor.commands.get("codeBlock"),n=new To;for(const i of e){const e={type:"button",model:new ug({_codeBlockLanguage:i.language,label:i.label,role:"menuitemradio",withText:!0})};e.model.bind("isOn").to(t,"value",(t=>t===e.model._codeBlockLanguage)),n.add(e)}return n}}class $k extends vs{static get requires(){return[zk,Wk]}static get pluginName(){return"CodeBlock"}}class qk 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&&Gk(t,e.schema)}execute(e={}){const t=this.editor.model,n=t.document,i=e.selection||n.selection;t.canEditAt(i)&&t.change((e=>{const n=i.getSelectedBlocks();for(const i of n)!i.is("element","paragraph")&&Gk(i,t.schema)&&e.rename(i,"paragraph")}))}}function Gk(e,t){return t.checkChild(e.parent,"paragraph")&&!t.isObject(e)}class Kk extends As{constructor(e){super(e),this._isEnabledBasedOnSelection=!1}execute(e){const t=this.editor.model,n=e.attributes;let i=e.position;t.canEditAt(i)&&t.change((e=>{const o=e.createElement("paragraph");if(n&&t.schema.setAllowedAttributes(o,n,e),!t.schema.checkChild(i.parent,o)){const n=t.schema.findAllowedParent(i,o);if(!n)return;i=e.split(i,n).position}t.insertContent(o,i),e.setSelection(o,"in")}))}}class Yk extends vs{static get pluginName(){return"Paragraph"}init(){const e=this.editor,t=e.model;e.commands.add("paragraph",new qk(e)),e.commands.add("insertParagraph",new Kk(e)),t.schema.register("paragraph",{inheritAllFrom:"$block"}),e.conversion.elementToElement({model:"paragraph",view:"p"}),e.conversion.for("upcast").elementToElement({model:(e,{writer:t})=>Yk.paragraphLikeElements.has(e.name)?e.isEmpty?null:t.createElement("paragraph"):null,view:/.+/,converterPriority:"low"})}}Yk.paragraphLikeElements=new Set(["blockquote","dd","div","dt","h1","h2","h3","h4","h5","h6","li","p","td","th"]);class Qk 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=>Jk(e,t,this.editor.model.schema)))}execute(e){const t=this.editor.model,n=t.document,i=e.value;t.change((e=>{const o=Array.from(n.selection.getSelectedBlocks()).filter((e=>Jk(e,i,t.schema)));for(const t of o)t.is("element",i)||e.rename(t,i)}))}}function Jk(e,t,n){return n.checkChild(e.parent,t)&&!n.isObject(e)}const Xk="paragraph";class e_ 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[Yk]}init(){const e=this.editor,t=e.config.get("heading.options"),n=[];for(const i of t)"paragraph"!==i.model&&(e.model.schema.register(i.model,{inheritAllFrom:"$block"}),e.conversion.elementToElement(i),n.push(i.model));this._addDefaultH1Conversion(e),e.commands.add("heading",new Qk(e,n))}afterInit(){const e=this.editor,t=e.commands.get("enter"),n=e.config.get("heading.options");t&&this.listenTo(t,"afterExecute",((t,i)=>{const o=e.model.document.selection.getFirstPosition().parent;n.some((e=>o.is("element",e.model)))&&!o.is("element",Xk)&&0===o.childCount&&i.writer.rename(o,Xk)}))}_addDefaultH1Conversion(e){e.conversion.for("upcast").elementToElement({model:"heading1",view:"h1",converterPriority:k.low+1})}}var t_=n(4684),n_={attributes:{"data-cke":!0}};n_.setAttributes=$o(),n_.insert=Zo().bind(null,"head"),n_.domAPI=Ho(),n_.insertStyleElement=Go();zo()(t_.Z,n_);t_.Z&&t_.Z.locals&&t_.Z.locals;class i_ extends vs{static get pluginName(){return"HeadingUI"}init(){const e=this.editor,t=e.t,n=function(e){const t=e.t,n={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=n[e.title];return t&&t!=e.title&&(e.title=t),e}))}(e),i=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 n){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 Zm(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 n=e||t&&"paragraph";return"boolean"==typeof n?i:r[n]?r[n]:i})),this.listenTo(d,"execute",(t=>{const{commandName:n,commandValue:i}=t.source;e.execute(n,i?{value:i}:void 0),e.editing.view.focus()})),d}))}}class o_ extends vs{static get requires(){return[e_,i_]}static get pluginName(){return"Heading"}}class r_ 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,n=t.document,i=Array.from(n.selection.getSelectedBlocks()).filter((e=>a_(e,t.schema))),o=void 0!==e.forceValue?!e.forceValue:this.value;t.change((e=>{if(o){let t=i[i.length-1].nextSibling,n=Number.POSITIVE_INFINITY,o=[];for(;t&&"listItem"==t.name&&0!==t.getAttribute("listIndent");){const e=t.getAttribute("listIndent");e=n;)r>o.getAttribute("listIndent")&&(r=o.getAttribute("listIndent")),o.getAttribute("listIndent")==r&&e[t?"unshift":"push"](o),o=o[t?"previousSibling":"nextSibling"]}}function a_(e,t){return t.checkChild(e.parent,"listItem")&&!t.isObject(e)}class l_ 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 n=Array.from(t.selection.getSelectedBlocks());e.change((e=>{const t=n[n.length-1];let i=t.nextSibling;for(;i&&"listItem"==i.name&&i.getAttribute("listIndent")>t.getAttribute("listIndent");)n.push(i),i=i.nextSibling;this._indentBy<0&&(n=n.reverse());for(const t of n){const n=t.getAttribute("listIndent")+this._indentBy;n<0?e.rename(t,"paragraph"):e.setAttribute("listIndent",n,t)}this.fire("_executeCleanup",n)}))}_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"),n=e.getAttribute("listType");let i=e.previousSibling;for(;i&&i.is("element","listItem")&&i.getAttribute("listIndent")>=t;){if(i.getAttribute("listIndent")==t)return i.getAttribute("listType")==n;i=i.previousSibling}return!1}return!0}}function c_(e,t){const n=t.mapper,i=t.writer,o="numbered"==e.getAttribute("listType")?"ol":"ul",r=function(e){const t=e.createContainerElement("li");return t.getFillerOffset=w_,t}(i),s=i.createContainerElement(o,null);return i.insert(i.createPositionAt(s,0),r),n.bindElements(e,r),r}function d_(e,t,n,i){const o=t.parent,r=n.mapper,s=n.writer;let a=r.toViewPosition(i.createPositionBefore(e));const l=m_(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(i.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(i.createPositionBefore(e));if(a=h_(a),s.insert(a,o),c&&"listItem"==c.name){const e=r.toViewElement(c),n=s.createRange(s.createPositionAt(e,0),a).getWalker({ignoreElementEnd:!0});for(const e of n)if(e.item.is("element","li")){const i=s.breakContainer(s.createPositionBefore(e.item)),o=e.item.parent,r=s.createPositionAt(t,"end");u_(s,r.nodeBefore,r.nodeAfter),s.move(s.createRangeOn(o),r),n._position=i}}else{const n=o.nextSibling;if(n&&(n.is("element","ul")||n.is("element","ol"))){let i=null;for(const t of n.getChildren()){const n=r.toModelElement(t);if(!(n&&n.getAttribute("listIndent")>e.getAttribute("listIndent")))break;i=t}i&&(s.breakContainer(s.createPositionAfter(i)),s.move(s.createRangeOn(i.parent),s.createPositionAt(t,"end")))}}u_(s,o,o.nextSibling),u_(s,o.previousSibling,o)}function u_(e,t,n){return!t||!n||"ul"!=t.name&&"ol"!=t.name||t.name!=n.name||t.getAttribute("class")!==n.getAttribute("class")?null:e.mergeContainers(e.createPositionAfter(t))}function h_(e){return e.getLastMatchingPosition((e=>e.item.is("uiElement")))}function m_(e,t){const n=!!t.sameIndent,i=!!t.smallerIndent,o=t.listIndent;let r=e;for(;r&&"listItem"==r.name;){const e=r.getAttribute("listIndent");if(n&&o==e||i&&o>e)return r;r="forward"===t.direction?r.nextSibling:r.previousSibling}return null}function f_(e,t,n,i){e.ui.componentFactory.add(t,(o=>{const r=e.commands.get(t),s=new Er(o);return s.set({label:n,icon:i,tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(r,"value","isEnabled"),s.on("execute",(()=>{e.execute(t),e.editing.view.focus()})),s}))}function g_(e,t){const n=[],i=e.parent,o={ignoreElementEnd:!1,startPosition:e,shallow:!0,direction:t},r=i.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")!==i.getAttribute("listType"))break;if(e.getAttribute("listStyle")!==i.getAttribute("listStyle"))break;if(e.getAttribute("listReversed")!==i.getAttribute("listReversed"))break;if(e.getAttribute("listStart")!==i.getAttribute("listStart"))break;"backward"===t?n.unshift(e):n.push(e)}}return n}const p_=["disc","circle","square"],b_=["decimal","decimal-leading-zero","lower-roman","upper-roman","lower-latin","upper-latin"];function w_(){const e=!this.isEmpty&&("ul"==this.getChild(0).name||"ol"==this.getChild(0).name);return this.isEmpty||e?0:Za.call(this)}class k_ extends vs{static get pluginName(){return"ListUtils"}getListTypeFromListStyleType(e){return function(e){return p_.includes(e)?"bulleted":b_.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 n=e.change((e=>e.createPositionAt(t,0)));return[...g_(n,"backward"),...g_(n,"forward")]})).flat();return t=[...new Set(t)],t}(e)}getSiblingNodes(e,t){return g_(e,t)}}function __(e){return(t,n,i)=>{const o=i.consumable;if(!o.test(n.item,"insert")||!o.test(n.item,"attribute:listType")||!o.test(n.item,"attribute:listIndent"))return;o.consume(n.item,"insert"),o.consume(n.item,"attribute:listType"),o.consume(n.item,"attribute:listIndent");const r=n.item;d_(r,c_(r,i),i,e)}}const v_=(e,t,n)=>{if(!n.consumable.test(t.item,e.name))return;const i=n.mapper.toViewElement(t.item),o=n.writer;o.breakContainer(o.createPositionBefore(i)),o.breakContainer(o.createPositionAfter(i));const r=i.parent,s="numbered"==t.attributeNewValue?"ol":"ul";o.rename(s,r)},y_=(e,t,n)=>{n.consumable.consume(t.item,e.name);const i=n.mapper.toViewElement(t.item).parent,o=n.writer;u_(o,i,i.nextSibling),u_(o,i.previousSibling,i)};const A_=(e,t,n)=>{if(n.consumable.test(t.item,e.name)&&"listItem"!=t.item.name){let e=n.mapper.toViewPosition(t.range.start);const i=n.writer,o=[];for(;("ul"==e.parent.name||"ol"==e.parent.name)&&(e=i.breakContainer(e),"li"==e.parent.name);){const t=e,n=i.createPositionAt(e.parent,"end");if(!t.isEqual(n)){const e=i.remove(i.createRange(t,n));o.push(e)}e=i.createPositionAfter(e.parent)}if(o.length>0){for(let t=0;t0){const t=u_(i,n,n.nextSibling);t&&t.parent==n&&e.offset--}}u_(i,e.nodeBefore,e.nodeAfter)}}},x_=(e,t,n)=>{const i=n.mapper.toViewPosition(t.position),o=i.nodeBefore,r=i.nodeAfter;u_(n.writer,o,r)},E_=(e,t,n)=>{if(n.consumable.consume(t.viewItem,{name:!0})){const e=n.writer,i=e.createElement("listItem"),o=function(e){let t=0,n=e.parent;for(;n;){if(n.is("element","li"))t++;else{const e=n.previousSibling;e&&e.is("element","li")&&t++}n=n.parent}return t}(t.viewItem);e.setAttribute("listIndent",o,i);const r=t.viewItem.parent&&"ol"==t.viewItem.parent.name?"numbered":"bulleted";if(e.setAttribute("listType",r,i),!n.safeInsert(i,t.modelCursor))return;const s=function(e,t,n){const{writer:i,schema:o}=n;let r=i.createPositionAfter(e);for(const s of t)if("ul"==s.name||"ol"==s.name)r=n.convertItem(s,r).modelCursor;else{const t=n.convertItem(s,i.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:I_(t.modelCursor),r=i.createPositionAfter(e))}return r}(i,t.viewItem.getChildren(),n);t.modelRange=e.createRange(t.modelCursor,s),n.updateConversionResult(i,t)}},C_=(e,t,n)=>{if(n.consumable.test(t.viewItem,{name:!0})){const e=Array.from(t.viewItem.getChildren());for(const t of e){!(t.is("element","li")||M_(t))&&t._remove()}}},S_=(e,t,n)=>{if(n.consumable.test(t.viewItem,{name:!0})){if(0===t.viewItem.childCount)return;const e=[...t.viewItem.getChildren()];let n=!1;for(const t of e)n&&!M_(t)&&t._remove(),M_(t)&&(n=!0)}};function T_(e){return(t,n)=>{if(n.isPhantom)return;const i=n.modelPosition.nodeBefore;if(i&&i.is("element","listItem")){const t=n.mapper.toViewElement(i),o=t.getAncestors().find(M_),r=e.createPositionAt(t,0).getWalker();for(const e of r){if("elementStart"==e.type&&e.item.is("element","li")){n.viewPosition=e.previousPosition;break}if("elementEnd"==e.type&&e.item==o){n.viewPosition=e.nextPosition;break}}}}}const P_=function(e,[t,n]){const i=this;let o,r=t.is("documentFragment")?t.getChild(0):t;if(o=n?i.createSelection(n):i.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 I_(e){const t=new qc({startPosition:e});let n;do{n=t.next()}while(!n.value.item.is("element","listItem"));return n.value.item}function O_(e,t,n,i,o,r){const s=m_(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=n;d=h_(d);for(const e of[...i.getChildren()])M_(e)&&(d=l.move(l.createRangeOn(e),d).end,u_(l,e,e.nextSibling),u_(l,e.previousSibling,e))}function M_(e){return e.is("element","ol")||e.is("element","ul")}var R_=n(7872),N_={attributes:{"data-cke":!0}};N_.setAttributes=$o(),N_.insert=Zo().bind(null,"head"),N_.domAPI=Ho(),N_.insertStyleElement=Go();zo()(R_.Z,N_);R_.Z&&R_.Z.locals&&R_.Z.locals;class V_ extends vs{static get pluginName(){return"ListEditing"}static get requires(){return[kp,tp,k_]}init(){const e=this.editor;e.model.schema.register("listItem",{inheritAllFrom:"$block",allowAttributes:["listType","listIndent"]});const t=e.data,n=e.editing;var i;e.model.document.registerPostFixer((t=>function(e,t){const n=e.document.differ.getChanges(),i=new Map;let o=!1;for(const i of n)if("insert"==i.type&&"listItem"==i.name)r(i.position);else if("insert"==i.type&&"listItem"!=i.name){if("$text"!=i.name){const n=i.position.nodeAfter;n.hasAttribute("listIndent")&&(t.removeAttribute("listIndent",n),o=!0),n.hasAttribute("listType")&&(t.removeAttribute("listType",n),o=!0),n.hasAttribute("listStyle")&&(t.removeAttribute("listStyle",n),o=!0),n.hasAttribute("listReversed")&&(t.removeAttribute("listReversed",n),o=!0),n.hasAttribute("listStart")&&(t.removeAttribute("listStart",n),o=!0);for(const t of Array.from(e.createRangeIn(n)).filter((e=>e.item.is("element","listItem"))))r(t.previousPosition)}r(i.position.getShiftedBy(i.length))}else"remove"==i.type&&"listItem"==i.name?r(i.position):("attribute"==i.type&&"listIndent"==i.attributeKey||"attribute"==i.type&&"listType"==i.attributeKey)&&r(i.range.start);for(const e of i.values())s(e),a(e);return o;function r(e){const t=e.nodeBefore;if(t&&t.is("element","listItem")){let e=t;if(i.has(e))return;for(let t=e.previousSibling;t&&t.is("element","listItem");t=e.previousSibling)if(e=t,i.has(e))return;i.set(t,e)}else{const t=e.nodeAfter;t&&t.is("element","listItem")&&i.set(t,t)}}function s(e){let n=0,i=null;for(;e&&e.is("element","listItem");){const r=e.getAttribute("listIndent");if(r>n){let s;null===i?(i=r-n,s=n):(i>r&&(i=r),s=r-i),t.setAttribute("listIndent",s,e),o=!0}else i=null,n=e.getAttribute("listIndent")+1;e=e.nextSibling}}function a(e){let n=[],i=null;for(;e&&e.is("element","listItem");){const r=e.getAttribute("listIndent");if(i&&i.getAttribute("listIndent")>r&&(n=n.slice(0,r+1)),0!=r)if(n[r]){const i=n[r];e.getAttribute("listType")!=i&&(t.setAttribute("listType",i,e),o=!0)}else n[r]=e.getAttribute("listType");i=e,e=e.nextSibling}}}(e.model,t))),n.mapper.registerViewToModelLength("li",D_),t.mapper.registerViewToModelLength("li",D_),n.mapper.on("modelToViewPosition",T_(n.view)),n.mapper.on("viewToModelPosition",(i=e.model,(e,t)=>{const n=t.viewPosition,o=n.parent,r=t.mapper;if("ul"==o.name||"ol"==o.name){if(n.isAtEnd){const e=r.toModelElement(n.nodeBefore),o=r.getModelLength(n.nodeBefore);t.modelPosition=i.createPositionBefore(e).getShiftedBy(o)}else{const e=r.toModelElement(n.nodeAfter);t.modelPosition=i.createPositionBefore(e)}e.stop()}else if("li"==o.name&&n.nodeBefore&&("ul"==n.nodeBefore.name||"ol"==n.nodeBefore.name)){const s=r.toModelElement(o);let a=1,l=n.nodeBefore;for(;l&&M_(l);)a+=r.getModelLength(l),l=l.previousSibling;t.modelPosition=i.createPositionBefore(s).getShiftedBy(a),e.stop()}})),t.mapper.on("modelToViewPosition",T_(n.view)),e.conversion.for("editingDowncast").add((t=>{t.on("insert",A_,{priority:"high"}),t.on("insert:listItem",__(e.model)),t.on("attribute:listType:listItem",v_,{priority:"high"}),t.on("attribute:listType:listItem",y_,{priority:"low"}),t.on("attribute:listIndent:listItem",function(e){return(t,n,i)=>{if(!i.consumable.consume(n.item,"attribute:listIndent"))return;const o=i.mapper.toViewElement(n.item),r=i.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&&u_(r,a,a.nextSibling),O_(n.attributeOldValue+1,n.range.start,l.start,o,i,e),d_(n.item,o,i,e);for(const e of n.item.getChildren())i.consumable.consume(e,"insert")}}(e.model)),t.on("remove:listItem",function(e){return(t,n,i)=>{const o=i.mapper.toViewPosition(n.position).getLastMatchingPosition((e=>!e.item.is("element","li"))).nodeAfter,r=i.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&&u_(r,a,a.nextSibling),O_(i.mapper.toModelElement(o).getAttribute("listIndent")+1,n.position,l.start,o,i,e);for(const e of r.createRangeIn(c).getItems())i.mapper.unbindViewElement(e);t.stop()}}(e.model)),t.on("remove",x_,{priority:"low"})})),e.conversion.for("dataDowncast").add((t=>{t.on("insert",A_,{priority:"high"}),t.on("insert:listItem",__(e.model))})),e.conversion.for("upcast").add((e=>{e.on("element:ul",C_,{priority:"high"}),e.on("element:ol",C_,{priority:"high"}),e.on("element:li",S_,{priority:"high"}),e.on("element:li",E_)})),e.model.on("insertContent",P_,{priority:"high"}),e.commands.add("numberedList",new r_(e,"numbered")),e.commands.add("bulletedList",new r_(e,"bulleted")),e.commands.add("indentList",new l_(e,"forward")),e.commands.add("outdentList",new l_(e,"backward"));const o=n.view.document;this.listenTo(o,"enter",((e,t)=>{const n=this.editor.model.document,i=n.selection.getLastPosition().parent;n.selection.isCollapsed&&"listItem"==i.name&&i.isEmpty&&(this.editor.execute("outdentList"),t.preventDefault(),e.stop())}),{context:"li"}),this.listenTo(o,"delete",((e,t)=>{if("backward"!==t.direction)return;const n=this.editor.model.document.selection;if(!n.isCollapsed)return;const i=n.getFirstPosition();if(!i.isAtStart)return;const o=i.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,n)=>{const i=n.shiftKey?"outdentList":"indentList";this.editor.commands.get(i).isEnabled&&(e.execute(i),n.stopPropagation(),n.preventDefault(),t.stop())}),{context:"li"})}afterInit(){const e=this.editor.commands,t=e.get("indent"),n=e.get("outdent");t&&t.registerChildCommand(e.get("indentList")),n&&n.registerChildCommand(e.get("outdentList"))}}function D_(e){let t=1;for(const n of e.getChildren())if("ul"==n.name||"ol"==n.name)for(const e of n.getChildren())t+=D_(e);return t}class L_ extends vs{static get pluginName(){return"ListUI"}init(){const e=this.editor.t;f_(this.editor,"numberedList",e("Numbered List"),''),f_(this.editor,"bulletedList",e("Bulleted List"),'')}}class B_ extends vs{static get requires(){return[V_,L_]}static get pluginName(){return"List"}}function j_(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 n=this.editor.model,i=n.document.selection,o=!!e&&j_(e,t);n.change((e=>{if(i.isCollapsed)o?e.setSelectionAttribute("language",o):e.removeSelectionAttribute("language");else{const t=n.schema.getValidRanges(i.getRanges(),"language");for(const n of t)o?e.setAttribute("language",o,n):e.removeAttribute("language",n)}}))}_getValueFromFirstAllowedNode(){const e=this.editor.model,t=e.schema,n=e.document.selection;if(n.isCollapsed)return n.getAttribute("language")||!1;for(const e of n.getRanges())for(const n of e.getItems())if(t.checkAttribute(n,"language"))return n.getAttribute("language")||!1;return!1}}class F_ 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=>j_(e.getAttribute("lang"),e.getAttribute("dir"))},view:{name:"span",attributes:{lang:/[\s\S]+/}}}),e.for("downcast").attributeToElement({model:"language",view:(e,{writer:t},n)=>{if(!e)return;if(!n.item.is("$textProxy")&&!n.item.is("documentSelection"))return;const{languageCode:i,textDirection:o}=function(e){const[t,n]=e.split(":");return{languageCode:t,textDirection:n}}(e);return t.createAttributeElement("span",{lang:i,dir:o})}})}}class H_ extends vs{static get pluginName(){return"TextPartLanguageUI"}init(){const e=this.editor,t=e.t,n=e.config.get("language.textPartLanguage"),i=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 n){const t={type:"button",model:new ug({label:e.title,languageCode:e.languageCode,role:"menuitemradio",textDirection:e.textDirection,withText:!0})},n=j_(e.languageCode,e.textDirection);t.model.bind("isOn").to(l,"value",(e=>e===n)),s.add(t),a[n]=e.title}const c=Fm(t);return Zm(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]||i)),this.listenTo(c,"execute",(t=>{l.execute({languageCode:t.source.languageCode,textDirection:t.source.textDirection}),e.editing.view.focus()})),c}))}}class U_ extends vs{static get requires(){return[F_,H_]}static get pluginName(){return"TextPartLanguage"}}class Z_ 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,n=t.document.selection,i=e.value,o=e.batch,r=e=>{if(n.isCollapsed)i?e.setSelectionAttribute(this.attributeKey,i):e.removeSelectionAttribute(this.attributeKey);else{const o=t.schema.getValidRanges(n.getRanges(),this.attributeKey);for(const t of o)i?e.setAttribute(this.attributeKey,i,t):e.removeAttribute(this.attributeKey,t)}};o?t.enqueueChange(o,(e=>{r(e)})):t.change((e=>{r(e)}))}}class W_ 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 $_=n(4590),q_={attributes:{"data-cke":!0}};q_.setAttributes=$o(),q_.insert=Zo().bind(null,"head"),q_.domAPI=Ho(),q_.insertStyleElement=Go();zo()($_.Z,q_);$_.Z&&$_.Z.locals&&$_.Z.locals;class G_ extends Qo{constructor(e,{colors:t,columns:n,removeButtonLabel:i,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 K_(e,{colors:t,columns:n,removeButtonLabel:i,documentColorsLabel:o,documentColorsCount:r,colorPickerLabel:s,focusTracker:this.focusTracker,focusables:this._focusables}),this.colorPickerPageView=new Y_(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,n)=>{this.colorGridsPageView.set("selectedColor",n),this.colorPickerPageView.set("selectedColor",n)})),this.colorGridsPageView.on("change:selectedColor",((e,t,n)=>{this.set("selectedColor",n)})),this.colorPickerPageView.on("change:selectedColor",((e,t,n)=>{this.set("selectedColor",n)})),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 K_ extends Qo{constructor(e,{colors:t,columns:n,removeButtonLabel:i,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=n,this.documentColors=new W_,this.documentColorsCount=r,this._focusables=l,this._removeButtonLabel=i,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 n=e.document,i=this.documentColorsCount;this.documentColors.clear();for(const o of n.getRootNames()){const r=n.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>=i))return}}updateSelectedColors(){const e=this.documentColorsGrid,t=this.staticColorsGrid,n=this.selectedColor;t.selectedColor=n,e&&(e.selectedColor=n)}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 ns(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,n,i)=>{i&&(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 Y_ extends Qo{constructor(e,{focusTracker:t,focusables:n,keystrokes:i,colorPickerConfig:o}){super(e),this.items=this.createCollection(),this.focusTracker=t,this.keystrokes=i,this.set("isVisible",!1),this.set("selectedColor",void 0),this._focusables=n,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,n,i)=>{e.color=i})),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 n=new Qo,i=this.createCollection();return i.add(e),i.add(t),n.setTemplate({tag:"div",attributes:{class:["ck","ck-color-table_action-bar"]},children:i}),n}_createActionButtons(){const e=this.locale,t=e.t,n=new Er(e),i=new Er(e);return n.set({icon:_m.check,class:"ck-button-save",withText:!1,label:t("Accept"),type:"button"}),i.set({icon:_m.cancel,class:"ck-button-cancel",withText:!1,label:t("Cancel")}),n.on("execute",(()=>{this.fire("execute",{source:"saveButton",value:this.selectedColor})})),i.on("execute",(()=>{this.fire("cancel")})),{saveButtonView:n,cancelButtonView:i}}_executeUponColorChange(){this.colorPickerView.on("change:color",((e,t,n)=>{this.fire("execute",{value:n,source:"colorPicker"})}))}}const Q_="fontSize",J_="fontFamily",X_="fontColor",ev="fontBackgroundColor";function tv(e,t){const n={model:{key:e,values:[]},view:{},upcastAlso:{}};for(const e of t)n.model.values.push(e.model),n.view[e.model]=e.view,e.upcastAlso&&(n.upcastAlso[e.model]=e.upcastAlso);return n}function nv(e){return t=>t.getStyle(e).replace(/\s/g,"")}function iv(e){return(t,{writer:n})=>n.createAttributeElement("span",{style:`${e}:${t}`},{priority:7})}class ov extends Z_{constructor(e){super(e,J_)}}function rv(e){return e.map(sv).filter((e=>void 0!==e))}function sv(e){return"object"==typeof e?e:"default"===e?{title:"Default",model:void 0}:"string"==typeof e?function(e){const t=e.replace(/"|'/g,"").split(","),n=t[0],i=t.map(av).join(", ");return{title:n,model:i,view:{name:"span",styles:{"font-family":i},priority:7}}}(e):void 0}function av(e){return(e=e.trim()).indexOf(" ")>0&&(e=`'${e}'`),e}class lv extends vs{static get pluginName(){return"FontFamilyEditing"}constructor(e){super(e),e.config.define(J_,{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:J_}),e.model.schema.setAttributeProperties(J_,{isFormatting:!0,copyOnEnter:!0});const t=rv(e.config.get("fontFamily.options")).filter((e=>e.model)),n=tv(J_,t);e.config.get("fontFamily.supportAllValues")?(this._prepareAnyValueConverters(),this._prepareCompatibilityConverter()):e.conversion.attributeToElement(n),e.commands.add(J_,new ov(e))}_prepareAnyValueConverters(){const e=this.editor;e.conversion.for("downcast").attributeToElement({model:J_,view:(e,{writer:t})=>t.createAttributeElement("span",{style:"font-family:"+e},{priority:7})}),e.conversion.for("upcast").elementToAttribute({model:{key:J_,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:J_,value:e=>e.getAttribute("face")}})}}class cv extends vs{static get pluginName(){return"FontFamilyUI"}init(){const e=this.editor,t=e.t,n=this._getLocalizedOptions(),i=e.commands.get(J_),o=t("Font Family");e.ui.componentFactory.add(J_,(t=>{const r=Fm(t);return Zm(r,(()=>function(e,t){const n=new To;for(const i of e){const e={type:"button",model:new ug({commandName:J_,commandParam:i.model,label:i.title,role:"menuitemradio",withText:!0})};e.model.bind("isOn").to(t,"value",(e=>e===i.model||!(!e||!i.model)&&e.split(",")[0].replace(/'/g,"").toLowerCase()===i.model.toLowerCase())),i.view&&"string"!=typeof i.view&&i.view.styles&&e.model.set("labelStyle",`font-family: ${i.view.styles["font-family"]}`),n.add(e)}return n}(n,i)),{role:"menu",ariaLabel:o}),r.buttonView.set({label:o,icon:'',tooltip:!0}),r.extendTemplate({attributes:{class:"ck-font-family-dropdown"}}),r.bind("isEnabled").to(i),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 rv(e.config.get(J_).options).map((e=>("Default"===e.title&&(e.title=t("Default")),e)))}}class dv extends vs{static get requires(){return[lv,cv]}static get pluginName(){return"FontFamily"}}class uv extends Z_{constructor(e){super(e,Q_)}}function hv(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 fv(e);var t;const n=function(e){return"string"==typeof e?mv[e]:mv[e.model]}(e);if(n)return fv(n);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}},fv(e)}(e)}(e))).filter((e=>void 0!==e))}const mv={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 fv(e){return e.view&&"string"!=typeof e.view&&!e.view.priority&&(e.view.priority=7),e}const gv=["x-small","x-small","small","medium","large","x-large","xx-large","xxx-large"];class pv extends vs{static get pluginName(){return"FontSizeEditing"}constructor(e){super(e),e.config.define(Q_,{options:["tiny","small","default","big","huge"],supportAllValues:!1})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:Q_}),e.model.schema.setAttributeProperties(Q_,{isFormatting:!0,copyOnEnter:!0});const t=e.config.get("fontSize.supportAllValues"),n=hv(this.editor.config.get("fontSize.options")).filter((e=>e.model)),i=tv(Q_,n);t?(this._prepareAnyValueConverters(i),this._prepareCompatibilityConverter()):e.conversion.attributeToElement(i),e.commands.add(Q_,new uv(e))}_prepareAnyValueConverters(e){const t=this.editor,n=e.model.values.filter((e=>{return!(t=String(e),Qh.test(t)||function(e){return Jh.test(e)}(String(e)));var t}));if(n.length)throw new y("font-size-invalid-use-of-named-presets",null,{presets:n});t.conversion.for("downcast").attributeToElement({model:Q_,view:(e,{writer:t})=>{if(e)return t.createAttributeElement("span",{style:"font-size:"+e},{priority:7})}}),t.conversion.for("upcast").elementToAttribute({model:{key:Q_,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:Q_,value:e=>{const t=e.getAttribute("size"),n="-"===t[0]||"+"===t[0];let i=parseInt(t,10);n&&(i=3+i);const o=gv.length-1,r=Math.min(Math.max(i,0),o);return gv[r]}}})}}var bv=n(9875),wv={attributes:{"data-cke":!0}};wv.setAttributes=$o(),wv.insert=Zo().bind(null,"head"),wv.domAPI=Ho(),wv.insertStyleElement=Go();zo()(bv.Z,wv);bv.Z&&bv.Z.locals&&bv.Z.locals;class kv extends vs{static get pluginName(){return"FontSizeUI"}init(){const e=this.editor,t=e.t,n=this._getLocalizedOptions(),i=e.commands.get(Q_),o=t("Font Size");e.ui.componentFactory.add(Q_,(t=>{const r=Fm(t);return Zm(r,(()=>function(e,t){const n=new To;for(const i of e){const e={type:"button",model:new ug({commandName:Q_,commandParam:i.model,label:i.title,class:"ck-fontsize-option",role:"menuitemradio",withText:!0})};i.view&&"string"!=typeof i.view&&(i.view.styles&&e.model.set("labelStyle",`font-size:${i.view.styles["font-size"]}`),i.view.classes&&e.model.set("class",`${e.model.class} ${i.view.classes}`)),e.model.bind("isOn").to(t,"value",(e=>e===i.model)),n.add(e)}return n}(n,i)),{role:"menu",ariaLabel:o}),r.buttonView.set({label:o,icon:'',tooltip:!0}),r.extendTemplate({attributes:{class:["ck-font-size-dropdown"]}}),r.bind("isEnabled").to(i),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,n={Default:t("Default"),Tiny:t("Tiny"),Small:t("Small"),Big:t("Big"),Huge:t("Huge")};return hv(e.config.get(Q_).options).map((e=>{const t=n[e.title];return t&&t!=e.title&&(e=Object.assign({},e,{title:t})),e}))}}class _v extends vs{static get requires(){return[pv,kv]}static get pluginName(){return"FontSize"}normalizeSizeOptions(e){return hv(e)}}class vv extends Z_{constructor(e){super(e,X_)}}class yv extends vs{static get pluginName(){return"FontColorEditing"}constructor(e){super(e),e.config.define(X_,{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:X_,value:nv("color")}}),e.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{color:/^#?\w+$/}},model:{key:X_,value:e=>e.getAttribute("color")}}),e.conversion.for("downcast").attributeToElement({model:X_,view:iv("color")}),e.commands.add(X_,new vv(e)),e.model.schema.extend("$text",{allowAttributes:X_}),e.model.schema.setAttributeProperties(X_,{isFormatting:!0,copyOnEnter:!0})}}class Av extends vs{constructor(e,{commandName:t,componentName:n,icon:i,dropdownLabel:o}){super(e),this.commandName=t,this.componentName=n,this.icon=i,this.dropdownLabel=o,this.columns=e.config.get(`${this.componentName}.columns`),this.colorTableView=void 0}init(){const e=this.editor,t=e.locale,n=t.t,i=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 n=e.t,i={Black:n("Black"),"Dim grey":n("Dim grey"),Grey:n("Grey"),"Light grey":n("Light grey"),White:n("White"),Red:n("Red"),Orange:n("Orange"),Yellow:n("Yellow"),"Light green":n("Light green"),Green:n("Green"),Aquamarine:n("Aquamarine"),Turquoise:n("Turquoise"),"Light blue":n("Light blue"),Blue:n("Blue"),Purple:n("Purple")};return t.map((e=>{const t=i[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:n,removeButtonLabel:i,colorPickerLabel:o,documentColorsLabel:r,documentColorsCount:s,colorPickerConfig:a}){const l=e.locale,c=new G_(l,{colors:t,columns:n,removeButtonLabel:i,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:n("Remove color"),colorPickerLabel:n("Color picker"),documentColorsLabel:0!==a?n("Document colors"):"",documentColorsCount:void 0===a?this.columns:a,colorPickerConfig:!!l&&(o.colorPicker||{})}),this.colorTableView.bind("selectedColor").to(i,"value"),r.buttonView.set({label:this.dropdownLabel,icon:this.icon,tooltip:!0}),r.extendTemplate({attributes:{class:"ck-color-ui-dropdown"}}),r.bind("isEnabled").to(i),this.colorTableView.on("execute",((t,n)=>{r.isOpen&&e.execute(this.commandName,{value:n.value,batch:this._undoStepBatch}),"colorPicker"!==n.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,n,i)=>{c||(c=!0,r.colorTableView.appendUI()),i?(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 xv extends Av{constructor(e){const t=e.locale.t;super(e,{commandName:X_,componentName:X_,icon:'',dropdownLabel:t("Font Color")})}static get pluginName(){return"FontColorUI"}}class Ev extends vs{static get requires(){return[yv,xv]}static get pluginName(){return"FontColor"}}class Cv extends Z_{constructor(e){super(e,ev)}}class Sv extends vs{static get pluginName(){return"FontBackgroundColorEditing"}constructor(e){super(e),e.config.define(ev,{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:ev,value:nv("background-color")}}),e.conversion.for("downcast").attributeToElement({model:ev,view:iv("background-color")}),e.commands.add(ev,new Cv(e)),e.model.schema.extend("$text",{allowAttributes:ev}),e.model.schema.setAttributeProperties(ev,{isFormatting:!0,copyOnEnter:!0})}}class Tv extends Av{constructor(e){const t=e.locale.t;super(e,{commandName:ev,componentName:ev,icon:'',dropdownLabel:t("Font Background Color")})}static get pluginName(){return"FontBackgroundColorUI"}}class Pv extends vs{static get requires(){return[Sv,Tv]}static get pluginName(){return"FontBackgroundColor"}}class Iv extends vs{static get requires(){return[dv,_v,Ev,Pv]}static get pluginName(){return"Font"}}function Ov(e,t){if(!e.childCount)return;const n=new Hh(e.document),i=function(e,t){const n=t.createRangeIn(e),i=new Hs({name:/^p|h\d+$/,styles:{"mso-list":/.*/}}),o=[];for(const e of n)if("elementStart"===e.type&&i.match(e.item)){const t=Nv(e.item);o.push({element:e.item,id:t.id,order:t.order,indent:t.indent})}return o}(e,n);if(!i.length)return;let o=null,r=1;i.forEach(((e,s)=>{const a=function(e,t){if(!e)return!0;if(e.id!==t.id)return t.indent-e.indent!=1;const n=t.element.previousSibling;if(!n)return!0;return i=n,!(i.is("element","ol")||i.is("element","ul"));var i}(i[s-1],e),l=a?null:i[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 i=function(e,t){const n=new RegExp(`@list l${e.id}:level${e.indent}\\s*({[^}]*)`,"gi"),i=/mso-level-number-format:([^;]{0,100});/gi,o=/mso-level-start-at:\s{0,100}([0-9]{0,10})\s{0,100};/gi,r=n.exec(t);let s="decimal",a="ol",l=null;if(r&&r[1]){const t=i.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 n=t._data;if("o"===n)return"circle";if("·"===n)return"disc";if("§"===n)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:Mv(s)}}(e,t);if(o){if(e.indent>r){const e=o.getChild(o.childCount-1),t=e.getChild(e.childCount-1);o=Rv(i,t,n),r+=1}else if(e.indent1&&n.setAttribute("start",e.startIndex,o),o}function Nv(e){const t={},n=e.getStyle("mso-list");if(n){const e=n.match(/(^|\s{1,100})l(\d+)/i),i=n.match(/\s{0,100}lfo(\d+)/i),o=n.match(/\s{0,100}level(\d+)/i);e&&i&&o&&(t.id=e[2],t.order=i[1],t.indent=parseInt(o[1]))}return t}function Vv(e,t){if(!e.childCount)return;const n=new Hh(e.document),i=function(e,t){const n=t.createRangeIn(e),i=new Hs({name:/v:(.+)/}),o=[];for(const e of n){if("elementStart"!=e.type)continue;const t=e.item,n=t.previousSibling,r=n&&n.is("element")?n.name:null;i.match(t)&&t.getAttribute("o:gfxdata")&&"v:shapetype"!==r&&o.push(e.item.getAttribute("id"))}return o}(e,n);!function(e,t,n){const i=n.createRangeIn(t),o=new Hs({name:"img"}),r=[];for(const t of i)if(t.item.is("element")&&o.match(t.item)){const n=t.item,i=n.getAttribute("v:shapes")?n.getAttribute("v:shapes").split(" "):[];i.length&&i.every((t=>e.indexOf(t)>-1))?r.push(n):n.getAttribute("src")||r.push(n)}for(const e of r)n.remove(e)}(i,e,n),function(e,t,n){const i=n.createRangeIn(t),o=[];for(const t of i)if("elementStart"==t.type&&t.item.is("element","v:shape")){const n=t.item.getAttribute("id");if(e.includes(n))continue;r(t.item.parent.getChildren(),n)||o.push(t.item)}for(const e of o){const t={src:s(e)};e.hasAttribute("alt")&&(t.alt=e.getAttribute("alt"));const i=n.createElement("img",t);n.insertChild(e.index+1,i,e.parent)}function r(e,t){for(const n of e)if(n.is("element")){if("img"==n.name&&n.getAttribute("v:shapes")==t)return!0;if(r(n.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")}}(i,e,n),function(e,t){const n=t.createRangeIn(e),i=new Hs({name:/v:(.+)/}),o=[];for(const e of n)"elementStart"==e.type&&i.match(e.item)&&o.push(e.item);for(const e of o)t.remove(e)}(e,n);const o=function(e,t){const n=t.createRangeIn(e),i=new Hs({name:"img"}),o=[];for(const e of n)e.item.is("element")&&i.match(e.item)&&e.item.getAttribute("src").startsWith("file://")&&o.push(e.item);return o}(e,n);o.length&&function(e,t,n){if(e.length===t.length)for(let i=0;iString.fromCharCode(parseInt(e,16)))).join(""))}const Lv=//i,Bv=/xmlns:o="urn:schemas-microsoft-com/i;class jv{constructor(e){this.document=e}isActive(e){return Lv.test(e)||Bv.test(e)}execute(e){const{body:t,stylesString:n}=e._parsedData;Ov(t,n),Vv(t,e.dataTransfer.getData("text/rtf")),e.content=t}}function zv(e,t,n,{blockElements:i,inlineObjectElements:o}){let r=n.createPositionAt(e,"forward"==t?"after":"before");return r=r.getLastMatchingPosition((({item:e})=>e.is("element")&&!i.includes(e.name)&&!o.includes(e.name)),{direction:t}),"forward"==t?r.nodeAfter:r.nodeBefore}function Fv(e,t){return!!e&&e.is("element")&&t.includes(e.name)}const Hv=/id=("|')docs-internal-guid-[-0-9a-f]+("|')/i;class Uv{constructor(e){this.document=e}isActive(e){return Hv.test(e)}execute(e){const t=new Hh(this.document),{body:n}=e._parsedData;!function(e,t){for(const n of e.getChildren())if(n.is("element","b")&&"normal"===n.getStyle("font-weight")){const i=e.getChildIndex(n);t.remove(n),t.insertChild(i,n.getChildren(),e)}}(n,t),function(e,t){for(const n of t.createRangeIn(e)){const e=n.item;if(e.is("element","li")){const n=e.getChild(0);n&&n.is("element","p")&&t.unwrapElement(n)}}}(n,t),function(e,t){const n=new al(t.document.stylesProcessor),i=new Jl(n,{renderingMode:"data"}),o=i.blockElements,r=i.inlineObjectElements,s=[];for(const n of t.createRangeIn(e)){const e=n.item;if(e.is("element","br")){const n=zv(e,"forward",t,{blockElements:o,inlineObjectElements:r}),i=zv(e,"backward",t,{blockElements:o,inlineObjectElements:r}),a=Fv(n,o);(Fv(i,o)||a)&&s.push(e)}}for(const e of s)e.hasClass("Apple-interchange-newline")?t.remove(e):t.replace(e,t.createElement("p"))}(n,t),e.content=n}}const Zv=/(\s+)<\/span>/g,((e,t)=>1===t.length?" ":Array(t.length+1).join("  ").substr(0,t.length)))}function qv(e,t){const n=new DOMParser,i=function(e){return $v($v(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="",n="",i=e.indexOf(t);if(i<0)return e;const o=e.indexOf(n,i+t.length);return e.substring(0,i+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",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(/