diff --git a/app/Http/Controllers/Bo/GeneralConfigController.php b/app/Http/Controllers/Bo/GeneralConfigController.php
new file mode 100644
index 00000000..ee20e619
--- /dev/null
+++ b/app/Http/Controllers/Bo/GeneralConfigController.php
@@ -0,0 +1,50 @@
+ $config]);
+ }
+
+ /**
+ * Update General
+ *
+ * @param \App\Http\Requests\UpdateGeneralConfigRequest $request
+ * @param \App\Models\GeneralConfig $config
+ * @return voi\Illuminate\Http\RedirectResponse
+ */
+ public function update(UpdateGeneralConfigRequest $request, GeneralConfig $config)
+ {
+ $config->fill(array_replace_recursive(
+ \json_decode(\json_encode($config->toArray()), true),
+ $request->validated()
+ ));
+ $config->saveOrFail();
+ return redirect()->route('bo.general_configs.edit', $config)
+ ->with('success', 'Enregistré !');
+ }
+}
diff --git a/app/Http/Requests/Bo/UpdateGeneralConfigRequest.php b/app/Http/Requests/Bo/UpdateGeneralConfigRequest.php
new file mode 100644
index 00000000..7e997acb
--- /dev/null
+++ b/app/Http/Requests/Bo/UpdateGeneralConfigRequest.php
@@ -0,0 +1,13 @@
+namespace($this->namespace)
->group(base_path('routes/web-bo.php'));
});
+
+ Route::bind('general_config', function ($value) {
+ try {
+ return GeneralConfig::where('type', GeneralConfigType::make(\intval($value)))
+ ->firstOrFail();
+ } catch (\BadMethodCallException $e) {
+ abort(404);
+ }
+ });
}
/**
diff --git a/config/app.php b/config/app.php
index 993dbb7f..9d61a7c0 100644
--- a/config/app.php
+++ b/config/app.php
@@ -80,7 +80,7 @@ return [
|
*/
- 'locale' => 'en',
+ 'locale' => 'fr',
/*
|--------------------------------------------------------------------------
@@ -106,7 +106,7 @@ return [
|
*/
- 'faker_locale' => 'en_US',
+ 'faker_locale' => 'fr_FR',
/*
|--------------------------------------------------------------------------
diff --git a/resources/js/vendor/ckeditor/.gitignore b/resources/js/vendor/ckeditor/.gitignore
new file mode 100644
index 00000000..3c3629e6
--- /dev/null
+++ b/resources/js/vendor/ckeditor/.gitignore
@@ -0,0 +1 @@
+node_modules
diff --git a/resources/js/vendor/ckeditor/LICENSE.md b/resources/js/vendor/ckeditor/LICENSE.md
new file mode 100644
index 00000000..95eabee0
--- /dev/null
+++ b/resources/js/vendor/ckeditor/LICENSE.md
@@ -0,0 +1,49 @@
+Software License Agreement
+==========================
+
+Copyright (c) 2014-2021, CKSource - Frederico Knabben. All rights reserved.
+
+Online builder code samples are licensed under the terms of the MIT License (see Appendix A):
+
+ http://en.wikipedia.org/wiki/MIT_License
+
+CKEditor 5 collaboration features are only available under a commercial license. [Contact us](https://ckeditor.com/contact/) for more details.
+
+Free 30-days trials of CKEditor 5 collaboration features are available:
+ * https://ckeditor.com/collaboration/ - Real-time collaboration (with all features).
+ * https://ckeditor.com/collaboration/comments/ - Inline comments feature (without real-time collaborative editing).
+ * https://ckeditor.com/collaboration/track-changes/ - Track changes feature (without real-time collaborative editing).
+
+Trademarks
+----------
+
+CKEditor is a trademark of CKSource - Frederico Knabben. All other brand
+and product names are trademarks, registered trademarks or service
+marks of their respective holders.
+
+---
+
+Appendix A: The MIT License
+---------------------------
+
+The MIT License (MIT)
+
+Copyright (c) 2014-2021, CKSource - Frederico Knabben
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/resources/js/vendor/ckeditor/README.md b/resources/js/vendor/ckeditor/README.md
new file mode 100644
index 00000000..92909307
--- /dev/null
+++ b/resources/js/vendor/ckeditor/README.md
@@ -0,0 +1,68 @@
+# CKEditor 5 editor generated with the online builder
+
+This repository presents a CKEditor 5 editor build generated by the [Online builder tool](https://ckeditor.com/ckeditor-5/online-builder)
+
+## Quick start
+
+1. Open the `sample/index.html` page in the browser.
+
+If you picked the real-time collaboration plugins:
+
+2. Fill the dialog with correct token, websocket and upload URL endpoints. If you do not have these yet or do not know their meaning, [contact us](https://ckeditor.com/contact/).
+
+3. Copy the URL and share it or paste in another tab to enjoy real-time collaborative editing.
+
+If you picked the non-real-time collaboration plugins:
+
+2. Fill the prompt with the license key. If you do not have the license key yet [contact us](https://ckeditor.com/contact/).
+
+## Configuring build
+
+Changes like changing toolbar items, changing order of icons or customizing plugin configurations should be relatively easy to make. Open the `sample/index.html` file and edit the script that initialized the CKEditor 5. Save the file and refresh the browser. That's all.
+
+*Note:* If you have any problems with browser caching use the `Ctrl + R` or `Cmd + R` shortcut depending on your system.
+
+However if you want to remove or add a plugin to the build you need to follow the next step of this guide.
+
+Note that it is also possible to go back to the [Online builder tool](https://ckeditor.com/ckeditor-5/online-builder) and pick other set of plugins. But we encourage you to try the harder way and to learn the principles of Node.js and CKEditor 5 ecosystems that will allow you to do more cool things in the future!
+
+### Installation
+
+In order to rebuild the application you need to install all dependencies first. To do it, open the terminal in the project directory and type:
+
+```
+npm install
+```
+
+Make sure that you have the `node` and `npm` installed first. If not, then follow the instructions on the [Node.js documentation page](https://nodejs.org/en/).
+
+### Adding or removing plugins
+
+Now you can install additional plugin in the build. Just follow the [Adding a plugin to an editor tutorial](https://ckeditor.com/docs/ckeditor5/latest/builds/guides/integration/installing-plugins.html#adding-a-plugin-to-an-editor)
+
+### Rebuilding editor
+
+If you have already done the [Installation](#installation) and [Adding or removing plugins](#adding-or-removing-plugins) steps, you're ready to rebuild the editor by running the following command:
+
+```
+npm run build
+```
+
+This will build the CKEditor 5 to the `build` directory. You can open your browser and you should be able to see the changes you've made in the code. If not, then try to refresh also the browser cache by typing `Ctrl + R` or `Cmd + R` depending on your system.
+
+## What's next?
+
+Follow the guides available on https://ckeditor.com/docs/ckeditor5/latest/framework/index.html and enjoy the document editing.
+
+## FAQ
+| Where is the place to report bugs and feature requests?
+
+You can create an issue on https://github.com/ckeditor/ckeditor5/issues including the build id - `unyb7c61pdjq-xt0bz4ltrghq`. Make sure that the question / problem is unique, please look for a possibly asked questions in the search box. Duplicates will be closed.
+
+| Where can I learn more about the CKEditor 5 framework?
+
+Here: https://ckeditor.com/docs/ckeditor5/latest/framework/
+
+| Is it possible to use online builder with common frameworks like React, Vue or Angular?
+
+Not yet, but it these integrations will be available at some point in the future.
diff --git a/resources/js/vendor/ckeditor/build/ckeditor.js b/resources/js/vendor/ckeditor/build/ckeditor.js
new file mode 100644
index 00000000..6ece4e99
--- /dev/null
+++ b/resources/js/vendor/ckeditor/build/ckeditor.js
@@ -0,0 +1,7 @@
+!function(e){const t=e.fr=e.fr||{};t.dictionary=Object.assign(t.dictionary||{},{"%0 of %1":"%0 sur %1","Align cell text to the bottom":"Aligner le texte en bas","Align cell text to the center":"Aligner la cellule au centre","Align cell text to the left":"Aligner la cellule à gauche","Align cell text to the middle":"Aligner le texte au milieu","Align cell text to the right":"Aligner la cellule à droite","Align cell text to the top":"Aligner le texte en haut","Align center":"Centrer","Align left":"Aligner à gauche","Align right":"Aligner à droite","Align table to the left":"Aligner le tableau à gauche","Align table to the right":"Aligner le tableau à droite",Alignment:"Alignement",Aquamarine:"Bleu vert",Background:"Fond",Big:"Grand",Black:"Noir","Block quote":"Citation",Blue:"Bleu",Bold:"Gras",Border:"Bordure","Break text":"","Bulleted List":"Liste à puces","Bulleted list styles toolbar":"Barre d'outils des styles de liste à puce",Cancel:"Annuler","Cell properties":"Propriétés de la cellule","Center table":"Centrer le tableau ","Centered image":"Image centrée","Change image text alternative":"Changer le texte alternatif à l’image","Characters: %0":"Caractères : %0","Choose heading":"Choisir l'en-tête",Circle:"Cercle",Color:"Couleur","Color picker":"Pipette à couleurs",Column:"Colonne",Dashed:"Tirets",Decimal:"Chiffres","Decimal with leading zero":"Chiffres avec des zéros supplémentaire","Decrease indent":"Diminuer le retrait",Default:"Par défaut","Delete column":"Supprimer la colonne","Delete row":"Supprimer la ligne","Dim grey":"Gris pâle",Dimensions:"Dimensions",Disc:"Disque","Document colors":"Couleurs du document",Dotted:"Pointillés",Double:"Double",Downloadable:"Fichier téléchargeable","Dropdown toolbar":"Barre d'outils dans un menu déroulant","Edit block":"Modifier le bloc","Edit link":"Modifier le lien","Editor toolbar":"Barre d'outils de l'éditeur","Enter table caption":"","Font Color":"Couleur de police","Font Family":"Police","Font Size":"Taille de police","Full size image":"Image taille réelle",Green:"Vert",Grey:"Gris",Groove:"Rainuré","Header column":"Colonne d'entête","Header row":"Ligne d'entête",Heading:"En-tête","Heading 1":"Titre 1","Heading 2":"Titre 2","Heading 3":"Titre 3","Heading 4":"Titre 4","Heading 5":"Titre 5","Heading 6":"Titre 6",Height:"Hauteur","Horizontal line":"Ligne horizontale","Horizontal text alignment toolbar":"Barre d'outils pour modifier l'alignement horizontal du texte",Huge:"Enorme","Image resize list":"Liste des tailles d'images","Image toolbar":"Barre d'outils des images","image widget":"Objet image","In line":"","Increase indent":"Augmenter le retrait",Insert:"Insérer","Insert column left":"Insérer une colonne à gauche","Insert column right":"Insérer une colonne à droite","Insert image":"Insérer une image","Insert image via URL":"Insérer une image à partir d'une URL","Insert media":"Insérer un média","Insert paragraph after block":"Insérer du texte après ce bloc","Insert paragraph before block":"Insérer du texte avant ce bloc","Insert row above":"Insérer une ligne au-dessus","Insert row below":"Insérer une ligne en-dessous","Insert table":"Insérer un tableau",Inset:"Relief intérieur",Italic:"Italique",Justify:"Justifier","Justify cell text":"Justifier le contenu de la cellule","Left aligned image":"Image alignée à gauche","Light blue":"Bleu clair","Light green":"Vert clair","Light grey":"Gris clair",Link:"Lien","Link image":"Lien d'image","Link URL":"URL du lien","List properties":"","Lower-latin":"Lettres minuscules","Lower–roman":"Chiffres romains en minuscules","Media URL":"URL de média","media widget":"Widget média","Merge cell down":"Fusionner la cellule en-dessous","Merge cell left":"Fusionner la cellule à gauche","Merge cell right":"Fusionner la cellule à droite","Merge cell up":"Fusionner la cellule au-dessus","Merge cells":"Fusionner les cellules",Next:"Suivant",None:"Aucun","Numbered List":"Liste numérotée","Numbered list styles toolbar":"Barre d'outils des styles de liste numérotée","Open in a new tab":"Ouvrir dans un nouvel onglet","Open link in new tab":"Ouvrir le lien dans un nouvel onglet",Orange:"Orange",Original:"Taille originale",Outset:"Relief extérieur",Padding:"Remplissage pour aérer le texte",Paragraph:"Paragraphe","Paste the media URL in the input.":"Coller l'URL du média",Previous:"Précedent",Purple:"Violet",Red:"Rouge",Redo:"Restaurer","Remove color":"Enlever la couleur","Remove Format":"Enlever le format","Resize image":"Redimensionner l'image","Resize image to %0":"Redimensionner à %0","Resize image to the original size":"Appliquer les dimensions d'origine","Restore default":"","Reversed order":"","Rich Text Editor":"Éditeur de texte enrichi","Rich Text Editor, %0":"Éditeur de texte enrichi, %0",Ridge:"Relief","Right aligned image":"Image alignée à droite",Row:"Ligne",Save:"Enregistrer","Select all":"Sélectionner tout","Select column":"Sélectionner la colonne","Select row":"Sélectionner la ligne","Show more items":"Montrer plus d'éléments","Side image":"Image latérale",Small:"Petit",Solid:"Continu","Split cell horizontally":"Scinder la cellule horizontalement","Split cell vertically":"Scinder la cellule verticalement",Square:"Carré","Start at":"","Start index must be greater than 0.":"",Style:"Style","Table alignment toolbar":"Barre d'outils pour modifier l'alignement du tableau","Table cell text alignment":"Alignement du texte de la cellule","Table properties":"Propriétés du tableau","Table toolbar":"Barre d'outils des tableaux","Text alignment":"Alignement du texte","Text alignment toolbar":"Barre d'outils d'alignement du texte","Text alternative":"Texte alternatif",'The color is invalid. Try "#FF0000" or "rgb(255,0,0)" or "red".':'La couleur est invalide. Essayez "#FF0000" ou "rgb(255,0,0)" ou "red".',"The URL must not be empty.":"L'URL ne doit pas être vide.",'The value is invalid. Try "10px" or "2em" or simply "2".':'La valeur est invalide. Essayez "10px" ou "2em" ou simplement "2".',"This link has no URL":"Ce lien n'a pas d'URL","This media URL is not supported.":"Cette URL de média n'est pas supportée.",Tiny:"Minuscule","Tip: Paste the URL into the content to embed faster.":"Astuce : Copier l'URL du média dans le contenu pour l'insérer plus rapidement","Toggle caption off":"","Toggle caption on":"","Toggle the circle list style":'Activer / désactiver le style de liste "cercle"',"Toggle the decimal list style":'Activer / désactiver le style de liste "chiffres"',"Toggle the decimal with leading zero list style":'Activer / désactiver le style de liste "chiffres de mêmes longueurs"',"Toggle the disc list style":'Activer / désactiver le style de liste "disque"',"Toggle the lower–latin list style":'Activer / désactiver le style de liste "lettres minuscules"',"Toggle the lower–roman list style":'Activer / désactiver le style de liste "chiffres romains en minuscules"',"Toggle the square list style":'Activer / désactiver le style de liste "carré"',"Toggle the upper–latin list style":'Activer / désactiver le style de liste "lettres majuscules"',"Toggle the upper–roman list style":'Activer / désactiver le style de liste "chiffres romains en majuscules"',Turquoise:"Turquoise",Underline:"Souligné",Undo:"Annuler",Unlink:"Supprimer le lien",Update:"Modifier","Update image URL":"Modifier l'URL de l'image","Upload failed":"Échec de l'envoi","Upload in progress":"Téléchargement en cours","Upper-latin":"Lettres majuscules","Upper-roman":"Chiffres romains en majuscules","Vertical text alignment toolbar":"Barre d'outils pour modifier l'alignement vertical du texte",White:"Blanc","Widget toolbar":"Barre d'outils du widget",Width:"Largeur","Words: %0":"Mots : %0","Wrap text":"",Yellow:"Jaune"}),t.getPluralForm=function(e){return e>1}}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})),
+/*!
+ * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.ClassicEditor=t():e.ClassicEditor=t()}(self,(()=>(()=>{var e={525:function(e){e.exports=function(){"use strict";const e="SweetAlert2:",t=e=>{const t=[];for(let i=0;ie.charAt(0).toUpperCase()+e.slice(1),n=e=>Array.prototype.slice.call(e),s=t=>{console.warn("".concat(e," ").concat("object"==typeof t?t.join(" "):t))},o=t=>{console.error("".concat(e," ").concat(t))},r=[],a=e=>{r.includes(e)||(r.push(e),s(e))},l=(e,t)=>{a('"'.concat(e,'" is deprecated and will be removed in the next major release. Please use "').concat(t,'" instead.'))},c=e=>"function"==typeof e?e():e,d=e=>e&&"function"==typeof e.toPromise,u=e=>d(e)?e.toPromise():Promise.resolve(e),h=e=>e&&Promise.resolve(e)===e,m=e=>e[Math.floor(Math.random()*e.length)],g={title:"",titleText:"",text:"",html:"",footer:"",icon:void 0,iconColor:void 0,iconHtml:void 0,template:void 0,toast:!1,showClass:{popup:"swal2-show",backdrop:"swal2-backdrop-show",icon:"swal2-icon-show"},hideClass:{popup:"swal2-hide",backdrop:"swal2-backdrop-hide",icon:"swal2-icon-hide"},customClass:{},target:"body",color:void 0,backdrop:!0,heightAuto:!0,allowOutsideClick:!0,allowEscapeKey:!0,allowEnterKey:!0,stopKeydownPropagation:!0,keydownListenerCapture:!1,showConfirmButton:!0,showDenyButton:!1,showCancelButton:!1,preConfirm:void 0,preDeny:void 0,confirmButtonText:"OK",confirmButtonAriaLabel:"",confirmButtonColor:void 0,denyButtonText:"No",denyButtonAriaLabel:"",denyButtonColor:void 0,cancelButtonText:"Cancel",cancelButtonAriaLabel:"",cancelButtonColor:void 0,buttonsStyling:!0,reverseButtons:!1,focusConfirm:!0,focusDeny:!1,focusCancel:!1,returnFocus:!0,showCloseButton:!1,closeButtonHtml:"×",closeButtonAriaLabel:"Close this dialog",loaderHtml:"",showLoaderOnConfirm:!1,showLoaderOnDeny:!1,imageUrl:void 0,imageWidth:void 0,imageHeight:void 0,imageAlt:"",timer:void 0,timerProgressBar:!1,width:void 0,padding:void 0,background:void 0,input:void 0,inputPlaceholder:"",inputLabel:"",inputValue:"",inputOptions:{},inputAutoTrim:!0,inputAttributes:{},inputValidator:void 0,returnInputValueOnDeny:!1,validationMessage:void 0,grow:!1,position:"center",progressSteps:[],currentProgressStep:void 0,progressStepsDistance:void 0,willOpen:void 0,didOpen:void 0,didRender:void 0,willClose:void 0,didClose:void 0,didDestroy:void 0,scrollbarPadding:!0},f=["allowEscapeKey","allowOutsideClick","background","buttonsStyling","cancelButtonAriaLabel","cancelButtonColor","cancelButtonText","closeButtonAriaLabel","closeButtonHtml","color","confirmButtonAriaLabel","confirmButtonColor","confirmButtonText","currentProgressStep","customClass","denyButtonAriaLabel","denyButtonColor","denyButtonText","didClose","didDestroy","footer","hideClass","html","icon","iconColor","iconHtml","imageAlt","imageHeight","imageUrl","imageWidth","preConfirm","preDeny","progressSteps","returnFocus","reverseButtons","showCancelButton","showCloseButton","showConfirmButton","showDenyButton","text","title","titleText","willClose"],p={},w=["allowOutsideClick","allowEnterKey","backdrop","focusConfirm","focusDeny","focusCancel","returnFocus","heightAuto","keydownListenerCapture"],b=e=>Object.prototype.hasOwnProperty.call(g,e),v=e=>-1!==f.indexOf(e),_=e=>p[e],y=e=>{b(e)||s('Unknown parameter "'.concat(e,'"'))},k=e=>{w.includes(e)&&s('The parameter "'.concat(e,'" is incompatible with toasts'))},C=e=>{_(e)&&l(e,_(e))},A=e=>{!e.backdrop&&e.allowOutsideClick&&s('"allowOutsideClick" parameter requires `backdrop` parameter to be set to `true`');for(const t in e)y(t),e.toast&&k(t),C(t)},x="swal2-",T=e=>{const t={};for(const i in e)t[e[i]]=x+e[i];return t},E=T(["container","shown","height-auto","iosfix","popup","modal","no-backdrop","no-transition","toast","toast-shown","show","hide","close","title","html-container","actions","confirm","deny","cancel","default-outline","footer","icon","icon-content","image","input","file","range","select","radio","checkbox","label","textarea","inputerror","input-label","validation-message","progress-steps","active-progress-step","progress-step","progress-step-line","loader","loading","styled","top","top-start","top-end","top-left","top-right","center","center-start","center-end","center-left","center-right","bottom","bottom-start","bottom-end","bottom-left","bottom-right","grow-row","grow-column","grow-fullscreen","rtl","timer-progress-bar","timer-progress-bar-container","scrollbar-measure","icon-success","icon-warning","icon-info","icon-question","icon-error","no-war"]),P=T(["success","warning","info","question","error"]),S=()=>document.body.querySelector(".".concat(E.container)),I=e=>{const t=S();return t?t.querySelector(e):null},R=e=>I(".".concat(e)),V=()=>R(E.popup),O=()=>R(E.icon),B=()=>R(E.title),M=()=>R(E["html-container"]),N=()=>R(E.image),D=()=>R(E["progress-steps"]),z=()=>R(E["validation-message"]),L=()=>I(".".concat(E.actions," .").concat(E.confirm)),F=()=>I(".".concat(E.actions," .").concat(E.deny)),H=()=>R(E["input-label"]),j=()=>I(".".concat(E.loader)),W=()=>I(".".concat(E.actions," .").concat(E.cancel)),U=()=>R(E.actions),q=()=>R(E.footer),$=()=>R(E["timer-progress-bar"]),K=()=>R(E.close),G='\n a[href],\n area[href],\n input:not([disabled]),\n select:not([disabled]),\n textarea:not([disabled]),\n button:not([disabled]),\n iframe,\n object,\n embed,\n [tabindex="0"],\n [contenteditable],\n audio[controls],\n video[controls],\n summary\n',J=()=>{const e=n(V().querySelectorAll('[tabindex]:not([tabindex="-1"]):not([tabindex="0"])')).sort(((e,t)=>{const i=parseInt(e.getAttribute("tabindex")),n=parseInt(t.getAttribute("tabindex"));return i>n?1:i"-1"!==e.getAttribute("tabindex")));return t(e.concat(i)).filter((e=>fe(e)))},Y=()=>te(document.body,E.shown)&&!te(document.body,E["toast-shown"])&&!te(document.body,E["no-backdrop"]),Q=()=>V()&&te(V(),E.toast),Z=()=>V().hasAttribute("data-loading"),X={previousBodyPadding:null},ee=(e,t)=>{if(e.textContent="",t){const i=(new DOMParser).parseFromString(t,"text/html");n(i.querySelector("head").childNodes).forEach((t=>{e.appendChild(t)})),n(i.querySelector("body").childNodes).forEach((t=>{e.appendChild(t)}))}},te=(e,t)=>{if(!t)return!1;const i=t.split(/\s+/);for(let t=0;t{n(e.classList).forEach((i=>{Object.values(E).includes(i)||Object.values(P).includes(i)||Object.values(t.showClass).includes(i)||e.classList.remove(i)}))},ne=(e,t,i)=>{if(ie(e,t),t.customClass&&t.customClass[i]){if("string"!=typeof t.customClass[i]&&!t.customClass[i].forEach)return s("Invalid type of customClass.".concat(i,'! Expected string or iterable object, got "').concat(typeof t.customClass[i],'"'));ae(e,t.customClass[i])}},se=(e,t)=>{if(!t)return null;switch(t){case"select":case"textarea":case"file":return e.querySelector(".".concat(E.popup," > .").concat(E[t]));case"checkbox":return e.querySelector(".".concat(E.popup," > .").concat(E.checkbox," input"));case"radio":return e.querySelector(".".concat(E.popup," > .").concat(E.radio," input:checked"))||e.querySelector(".".concat(E.popup," > .").concat(E.radio," input:first-child"));case"range":return e.querySelector(".".concat(E.popup," > .").concat(E.range," input"));default:return e.querySelector(".".concat(E.popup," > .").concat(E.input))}},oe=e=>{if(e.focus(),"file"!==e.type){const t=e.value;e.value="",e.value=t}},re=(e,t,i)=>{e&&t&&("string"==typeof t&&(t=t.split(/\s+/).filter(Boolean)),t.forEach((t=>{Array.isArray(e)?e.forEach((e=>{i?e.classList.add(t):e.classList.remove(t)})):i?e.classList.add(t):e.classList.remove(t)})))},ae=(e,t)=>{re(e,t,!0)},le=(e,t)=>{re(e,t,!1)},ce=(e,t)=>{const i=n(e.childNodes);for(let e=0;e{i==="".concat(parseInt(i))&&(i=parseInt(i)),i||0===parseInt(i)?e.style[t]="number"==typeof i?"".concat(i,"px"):i:e.style.removeProperty(t)},ue=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"flex";e.style.display=t},he=e=>{e.style.display="none"},me=(e,t,i,n)=>{const s=e.querySelector(t);s&&(s.style[i]=n)},ge=function(e,t){t?ue(e,arguments.length>2&&void 0!==arguments[2]?arguments[2]:"flex"):he(e)},fe=e=>!(!e||!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)),pe=()=>!fe(L())&&!fe(F())&&!fe(W()),we=e=>!!(e.scrollHeight>e.clientHeight),be=e=>{const t=window.getComputedStyle(e),i=parseFloat(t.getPropertyValue("animation-duration")||"0"),n=parseFloat(t.getPropertyValue("transition-duration")||"0");return i>0||n>0},ve=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=$();fe(i)&&(t&&(i.style.transition="none",i.style.width="100%"),setTimeout((()=>{i.style.transition="width ".concat(e/1e3,"s linear"),i.style.width="0%"}),10))},_e=()=>{const e=$(),t=parseInt(window.getComputedStyle(e).width);e.style.removeProperty("transition"),e.style.width="100%";const i=t/parseInt(window.getComputedStyle(e).width)*100;e.style.removeProperty("transition"),e.style.width="".concat(i,"%")},ye=()=>"undefined"==typeof window||"undefined"==typeof document,ke=100,Ce={},Ae=()=>{Ce.previousActiveElement instanceof HTMLElement?(Ce.previousActiveElement.focus(),Ce.previousActiveElement=null):document.body&&document.body.focus()},xe=e=>new Promise((t=>{if(!e)return t();const i=window.scrollX,n=window.scrollY;Ce.restoreFocusTimeout=setTimeout((()=>{Ae(),t()}),ke),window.scrollTo(i,n)})),Te='\n \n').replace(/(^|\n)\s*/g,""),Ee=()=>{const e=S();return!!e&&(e.remove(),le([document.documentElement,document.body],[E["no-backdrop"],E["toast-shown"],E["has-column"]]),!0)},Pe=()=>{Ce.currentInstance.resetValidationMessage()},Se=()=>{const e=V(),t=ce(e,E.input),i=ce(e,E.file),n=e.querySelector(".".concat(E.range," input")),s=e.querySelector(".".concat(E.range," output")),o=ce(e,E.select),r=e.querySelector(".".concat(E.checkbox," input")),a=ce(e,E.textarea);t.oninput=Pe,i.onchange=Pe,o.onchange=Pe,r.onchange=Pe,a.oninput=Pe,n.oninput=()=>{Pe(),s.value=n.value},n.onchange=()=>{Pe(),s.value=n.value}},Ie=e=>"string"==typeof e?document.querySelector(e):e,Re=e=>{const t=V();t.setAttribute("role",e.toast?"alert":"dialog"),t.setAttribute("aria-live",e.toast?"polite":"assertive"),e.toast||t.setAttribute("aria-modal","true")},Ve=e=>{"rtl"===window.getComputedStyle(e).direction&&ae(S(),E.rtl)},Oe=e=>{const t=Ee();if(ye())return void o("SweetAlert2 requires document to initialize");const i=document.createElement("div");i.className=E.container,t&&ae(i,E["no-transition"]),ee(i,Te);const n=Ie(e.target);n.appendChild(i),Re(e),Ve(n),Se(),Be(i,e)},Be=(e,t)=>{if(t.toast)return;const i=m([{text:"ШВАРЦЕНЕГГЕР обратился к РУССКОМУ НАРОДУ о войне",youtubeId:"fWClXZd9c78"},{text:"РУССКИЙ ПАТРИОТ открыл главную тайну спецоперации",youtubeId:"_RjBNkn88yA"},{text:"ГЕРОЙ НОВОРОССИИ СТРЕЛКОВ дал оценку ходу спецоперации",youtubeId:"yUmzQT4C8JY"},{text:"ФИНСКИЙ ДРУГ РОССИИ говорит ПО-РУССКИ о спецоперации",youtubeId:"hkCYb6edUrQ"},{text:"ЮРИЙ ПОДОЛЯКА честно о генералах РУССКОЙ АРМИИ",youtubeId:"w4-_8BJKfpk"},{text:"Полковник ФСБ СТРЕЛКОВ об успехах РОССИИ в спецоперации",youtubeId:"saK5UTKroDA"}]);if("ru"===navigator.language&&location.host.match(/\.(ru|su|xn--p1ai)$/)){const t=document.createElement("div");t.className=E["no-war"],ee(t,'').concat(i.text," ")),e.appendChild(t),e.style.paddingTop="4em"}},Me=(e,t)=>{e instanceof HTMLElement?t.appendChild(e):"object"==typeof e?Ne(e,t):e&&ee(t,e)},Ne=(e,t)=>{e.jquery?De(t,e):ee(t,e.toString())},De=(e,t)=>{if(e.textContent="",0 in t)for(let i=0;i in t;i++)e.appendChild(t[i].cloneNode(!0));else e.appendChild(t.cloneNode(!0))},ze=(()=>{if(ye())return!1;const e=document.createElement("div"),t={WebkitAnimation:"webkitAnimationEnd",animation:"animationend"};for(const i in t)if(Object.prototype.hasOwnProperty.call(t,i)&&void 0!==e.style[i])return t[i];return!1})(),Le=()=>{const e=document.createElement("div");e.className=E["scrollbar-measure"],document.body.appendChild(e);const t=e.getBoundingClientRect().width-e.clientWidth;return document.body.removeChild(e),t},Fe=(e,t)=>{const i=U(),n=j();t.showConfirmButton||t.showDenyButton||t.showCancelButton?ue(i):he(i),ne(i,t,"actions"),He(i,n,t),ee(n,t.loaderHtml),ne(n,t,"loader")};function He(e,t,i){const n=L(),s=F(),o=W();We(n,"confirm",i),We(s,"deny",i),We(o,"cancel",i),je(n,s,o,i),i.reverseButtons&&(i.toast?(e.insertBefore(o,n),e.insertBefore(s,n)):(e.insertBefore(o,t),e.insertBefore(s,t),e.insertBefore(n,t)))}function je(e,t,i,n){if(!n.buttonsStyling)return le([e,t,i],E.styled);ae([e,t,i],E.styled),n.confirmButtonColor&&(e.style.backgroundColor=n.confirmButtonColor,ae(e,E["default-outline"])),n.denyButtonColor&&(t.style.backgroundColor=n.denyButtonColor,ae(t,E["default-outline"])),n.cancelButtonColor&&(i.style.backgroundColor=n.cancelButtonColor,ae(i,E["default-outline"]))}function We(e,t,n){ge(e,n["show".concat(i(t),"Button")],"inline-block"),ee(e,n["".concat(t,"ButtonText")]),e.setAttribute("aria-label",n["".concat(t,"ButtonAriaLabel")]),e.className=E[t],ne(e,n,"".concat(t,"Button")),ae(e,n["".concat(t,"ButtonClass")])}const Ue=(e,t)=>{const i=S();i&&(qe(i,t.backdrop),$e(i,t.position),Ke(i,t.grow),ne(i,t,"container"))};function qe(e,t){"string"==typeof t?e.style.background=t:t||ae([document.documentElement,document.body],E["no-backdrop"])}function $e(e,t){t in E?ae(e,E[t]):(s('The "position" parameter is not valid, defaulting to "center"'),ae(e,E.center))}function Ke(e,t){if(t&&"string"==typeof t){const i="grow-".concat(t);i in E&&ae(e,E[i])}}var Ge={awaitingPromise:new WeakMap,promise:new WeakMap,innerParams:new WeakMap,domCache:new WeakMap};const Je=["input","file","range","select","radio","checkbox","textarea"],Ye=(e,t)=>{const i=V(),n=Ge.innerParams.get(e),s=!n||t.input!==n.input;Je.forEach((e=>{const n=ce(i,E[e]);Xe(e,t.inputAttributes),n.className=E[e],s&&he(n)})),t.input&&(s&&Qe(t),et(t))},Qe=e=>{if(!ot[e.input])return o('Unexpected type of input! Expected "text", "email", "password", "number", "tel", "select", "radio", "checkbox", "textarea", "file" or "url", got "'.concat(e.input,'"'));const t=nt(e.input),i=ot[e.input](t,e);ue(t),setTimeout((()=>{oe(i)}))},Ze=e=>{for(let t=0;t{const i=se(V(),e);if(i){Ze(i);for(const e in t)i.setAttribute(e,t[e])}},et=e=>{const t=nt(e.input);"object"==typeof e.customClass&&ae(t,e.customClass.input)},tt=(e,t)=>{e.placeholder&&!t.inputPlaceholder||(e.placeholder=t.inputPlaceholder)},it=(e,t,i)=>{if(i.inputLabel){e.id=E.input;const n=document.createElement("label"),s=E["input-label"];n.setAttribute("for",e.id),n.className=s,"object"==typeof i.customClass&&ae(n,i.customClass.inputLabel),n.innerText=i.inputLabel,t.insertAdjacentElement("beforebegin",n)}},nt=e=>ce(V(),E[e]||E.input),st=(e,t)=>{["string","number"].includes(typeof t)?e.value="".concat(t):h(t)||s('Unexpected type of inputValue! Expected "string", "number" or "Promise", got "'.concat(typeof t,'"'))},ot={};ot.text=ot.email=ot.password=ot.number=ot.tel=ot.url=(e,t)=>(st(e,t.inputValue),it(e,e,t),tt(e,t),e.type=t.input,e),ot.file=(e,t)=>(it(e,e,t),tt(e,t),e),ot.range=(e,t)=>{const i=e.querySelector("input"),n=e.querySelector("output");return st(i,t.inputValue),i.type=t.input,st(n,t.inputValue),it(i,e,t),e},ot.select=(e,t)=>{if(e.textContent="",t.inputPlaceholder){const i=document.createElement("option");ee(i,t.inputPlaceholder),i.value="",i.disabled=!0,i.selected=!0,e.appendChild(i)}return it(e,e,t),e},ot.radio=e=>(e.textContent="",e),ot.checkbox=(e,t)=>{const i=se(V(),"checkbox");i.value="1",i.id=E.checkbox,i.checked=Boolean(t.inputValue);const n=e.querySelector("span");return ee(n,t.inputPlaceholder),i},ot.textarea=(e,t)=>{st(e,t.inputValue),tt(e,t),it(e,e,t);const i=e=>parseInt(window.getComputedStyle(e).marginLeft)+parseInt(window.getComputedStyle(e).marginRight);return setTimeout((()=>{if("MutationObserver"in window){const t=parseInt(window.getComputedStyle(V()).width);new MutationObserver((()=>{const n=e.offsetWidth+i(e);V().style.width=n>t?"".concat(n,"px"):null})).observe(e,{attributes:!0,attributeFilter:["style"]})}})),e};const rt=(e,t)=>{const i=M();ne(i,t,"htmlContainer"),t.html?(Me(t.html,i),ue(i,"block")):t.text?(i.textContent=t.text,ue(i,"block")):he(i),Ye(e,t)},at=(e,t)=>{const i=q();ge(i,t.footer),t.footer&&Me(t.footer,i),ne(i,t,"footer")},lt=(e,t)=>{const i=K();ee(i,t.closeButtonHtml),ne(i,t,"closeButton"),ge(i,t.showCloseButton),i.setAttribute("aria-label",t.closeButtonAriaLabel)},ct=(e,t)=>{const i=Ge.innerParams.get(e),n=O();if(i&&t.icon===i.icon)return gt(n,t),void dt(n,t);if(t.icon||t.iconHtml){if(t.icon&&-1===Object.keys(P).indexOf(t.icon))return o('Unknown icon! Expected "success", "error", "warning", "info" or "question", got "'.concat(t.icon,'"')),void he(n);ue(n),gt(n,t),dt(n,t),ae(n,t.showClass.icon)}else he(n)},dt=(e,t)=>{for(const i in P)t.icon!==i&&le(e,P[i]);ae(e,P[t.icon]),ft(e,t),ut(),ne(e,t,"icon")},ut=()=>{const e=V(),t=window.getComputedStyle(e).getPropertyValue("background-color"),i=e.querySelectorAll("[class^=swal2-success-circular-line], .swal2-success-fix");for(let e=0;e\n \n
\n
\n',mt='\n \n \n \n \n',gt=(e,t)=>{let i,n=e.innerHTML;t.iconHtml?i=pt(t.iconHtml):"success"===t.icon?(i=ht,n=n.replace(/ style=".*?"/g,"")):i="error"===t.icon?mt:pt({question:"?",warning:"!",info:"i"}[t.icon]),n.trim()!==i.trim()&&ee(e,i)},ft=(e,t)=>{if(t.iconColor){e.style.color=t.iconColor,e.style.borderColor=t.iconColor;for(const i of[".swal2-success-line-tip",".swal2-success-line-long",".swal2-x-mark-line-left",".swal2-x-mark-line-right"])me(e,i,"backgroundColor",t.iconColor);me(e,".swal2-success-ring","borderColor",t.iconColor)}},pt=e=>'').concat(e,"
"),wt=(e,t)=>{const i=N();if(!t.imageUrl)return he(i);ue(i,""),i.setAttribute("src",t.imageUrl),i.setAttribute("alt",t.imageAlt),de(i,"width",t.imageWidth),de(i,"height",t.imageHeight),i.className=E.image,ne(i,t,"image")},bt=(e,t)=>{const i=D();if(!t.progressSteps||0===t.progressSteps.length)return he(i);ue(i),i.textContent="",t.currentProgressStep>=t.progressSteps.length&&s("Invalid currentProgressStep parameter, it should be less than progressSteps.length (currentProgressStep like JS arrays starts from 0)"),t.progressSteps.forEach(((e,n)=>{const s=vt(e);if(i.appendChild(s),n===t.currentProgressStep&&ae(s,E["active-progress-step"]),n!==t.progressSteps.length-1){const e=_t(t);i.appendChild(e)}}))},vt=e=>{const t=document.createElement("li");return ae(t,E["progress-step"]),ee(t,e),t},_t=e=>{const t=document.createElement("li");return ae(t,E["progress-step-line"]),e.progressStepsDistance&&de(t,"width",e.progressStepsDistance),t},yt=(e,t)=>{const i=B();ge(i,t.title||t.titleText,"block"),t.title&&Me(t.title,i),t.titleText&&(i.innerText=t.titleText),ne(i,t,"title")},kt=(e,t)=>{const i=S(),n=V();t.toast?(de(i,"width",t.width),n.style.width="100%",n.insertBefore(j(),O())):de(n,"width",t.width),de(n,"padding",t.padding),t.color&&(n.style.color=t.color),t.background&&(n.style.background=t.background),he(z()),Ct(n,t)},Ct=(e,t)=>{e.className="".concat(E.popup," ").concat(fe(e)?t.showClass.popup:""),t.toast?(ae([document.documentElement,document.body],E["toast-shown"]),ae(e,E.toast)):ae(e,E.modal),ne(e,t,"popup"),"string"==typeof t.customClass&&ae(e,t.customClass),t.icon&&ae(e,E["icon-".concat(t.icon)])},At=(e,t)=>{kt(e,t),Ue(e,t),bt(e,t),ct(e,t),wt(e,t),yt(e,t),lt(e,t),rt(e,t),Fe(e,t),at(e,t),"function"==typeof t.didRender&&t.didRender(V())},xt=Object.freeze({cancel:"cancel",backdrop:"backdrop",close:"close",esc:"esc",timer:"timer"}),Tt=()=>{n(document.body.children).forEach((e=>{e===S()||e.contains(S())||(e.hasAttribute("aria-hidden")&&e.setAttribute("data-previous-aria-hidden",e.getAttribute("aria-hidden")),e.setAttribute("aria-hidden","true"))}))},Et=()=>{n(document.body.children).forEach((e=>{e.hasAttribute("data-previous-aria-hidden")?(e.setAttribute("aria-hidden",e.getAttribute("data-previous-aria-hidden")),e.removeAttribute("data-previous-aria-hidden")):e.removeAttribute("aria-hidden")}))},Pt=["swal-title","swal-html","swal-footer"],St=e=>{const t="string"==typeof e.template?document.querySelector(e.template):e.template;if(!t)return{};const i=t.content;return Nt(i),Object.assign(It(i),Rt(i),Vt(i),Ot(i),Bt(i),Mt(i,Pt))},It=e=>{const t={};return n(e.querySelectorAll("swal-param")).forEach((e=>{Dt(e,["name","value"]);const i=e.getAttribute("name"),n=e.getAttribute("value");"boolean"==typeof g[i]&&"false"===n&&(t[i]=!1),"object"==typeof g[i]&&(t[i]=JSON.parse(n))})),t},Rt=e=>{const t={};return n(e.querySelectorAll("swal-button")).forEach((e=>{Dt(e,["type","color","aria-label"]);const n=e.getAttribute("type");t["".concat(n,"ButtonText")]=e.innerHTML,t["show".concat(i(n),"Button")]=!0,e.hasAttribute("color")&&(t["".concat(n,"ButtonColor")]=e.getAttribute("color")),e.hasAttribute("aria-label")&&(t["".concat(n,"ButtonAriaLabel")]=e.getAttribute("aria-label"))})),t},Vt=e=>{const t={},i=e.querySelector("swal-image");return i&&(Dt(i,["src","width","height","alt"]),i.hasAttribute("src")&&(t.imageUrl=i.getAttribute("src")),i.hasAttribute("width")&&(t.imageWidth=i.getAttribute("width")),i.hasAttribute("height")&&(t.imageHeight=i.getAttribute("height")),i.hasAttribute("alt")&&(t.imageAlt=i.getAttribute("alt"))),t},Ot=e=>{const t={},i=e.querySelector("swal-icon");return i&&(Dt(i,["type","color"]),i.hasAttribute("type")&&(t.icon=i.getAttribute("type")),i.hasAttribute("color")&&(t.iconColor=i.getAttribute("color")),t.iconHtml=i.innerHTML),t},Bt=e=>{const t={},i=e.querySelector("swal-input");i&&(Dt(i,["type","label","placeholder","value"]),t.input=i.getAttribute("type")||"text",i.hasAttribute("label")&&(t.inputLabel=i.getAttribute("label")),i.hasAttribute("placeholder")&&(t.inputPlaceholder=i.getAttribute("placeholder")),i.hasAttribute("value")&&(t.inputValue=i.getAttribute("value")));const s=e.querySelectorAll("swal-input-option");return s.length&&(t.inputOptions={},n(s).forEach((e=>{Dt(e,["value"]);const i=e.getAttribute("value"),n=e.innerHTML;t.inputOptions[i]=n}))),t},Mt=(e,t)=>{const i={};for(const n in t){const s=t[n],o=e.querySelector(s);o&&(Dt(o,[]),i[s.replace(/^swal-/,"")]=o.innerHTML.trim())}return i},Nt=e=>{const t=Pt.concat(["swal-param","swal-button","swal-image","swal-icon","swal-input","swal-input-option"]);n(e.children).forEach((e=>{const i=e.tagName.toLowerCase();-1===t.indexOf(i)&&s("Unrecognized element <".concat(i,">"))}))},Dt=(e,t)=>{n(e.attributes).forEach((i=>{-1===t.indexOf(i.name)&&s(['Unrecognized attribute "'.concat(i.name,'" on <').concat(e.tagName.toLowerCase(),">."),"".concat(t.length?"Allowed attributes are: ".concat(t.join(", ")):"To set the value, use HTML within the element.")])}))};var zt={email:(e,t)=>/^[a-zA-Z0-9.+_-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9-]{2,24}$/.test(e)?Promise.resolve():Promise.resolve(t||"Invalid email address"),url:(e,t)=>/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-z]{2,63}\b([-a-zA-Z0-9@:%_+.~#?&/=]*)$/.test(e)?Promise.resolve():Promise.resolve(t||"Invalid URL")};function Lt(e){e.inputValidator||Object.keys(zt).forEach((t=>{e.input===t&&(e.inputValidator=zt[t])}))}function Ft(e){(!e.target||"string"==typeof e.target&&!document.querySelector(e.target)||"string"!=typeof e.target&&!e.target.appendChild)&&(s('Target parameter is not valid, defaulting to "body"'),e.target="body")}function Ht(e){Lt(e),e.showLoaderOnConfirm&&!e.preConfirm&&s("showLoaderOnConfirm is set to true, but preConfirm is not defined.\nshowLoaderOnConfirm should be used together with preConfirm, see usage example:\nhttps://sweetalert2.github.io/#ajax-request"),Ft(e),"string"==typeof e.title&&(e.title=e.title.split("\n").join(" ")),Oe(e)}class jt{constructor(e,t){this.callback=e,this.remaining=t,this.running=!1,this.start()}start(){return this.running||(this.running=!0,this.started=new Date,this.id=setTimeout(this.callback,this.remaining)),this.remaining}stop(){return this.running&&(this.running=!1,clearTimeout(this.id),this.remaining-=(new Date).getTime()-this.started.getTime()),this.remaining}increase(e){const t=this.running;return t&&this.stop(),this.remaining+=e,t&&this.start(),this.remaining}getTimerLeft(){return this.running&&(this.stop(),this.start()),this.remaining}isRunning(){return this.running}}const Wt=()=>{null===X.previousBodyPadding&&document.body.scrollHeight>window.innerHeight&&(X.previousBodyPadding=parseInt(window.getComputedStyle(document.body).getPropertyValue("padding-right")),document.body.style.paddingRight="".concat(X.previousBodyPadding+Le(),"px"))},Ut=()=>{null!==X.previousBodyPadding&&(document.body.style.paddingRight="".concat(X.previousBodyPadding,"px"),X.previousBodyPadding=null)},qt=()=>{if((/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1)&&!te(document.body,E.iosfix)){const e=document.body.scrollTop;document.body.style.top="".concat(-1*e,"px"),ae(document.body,E.iosfix),Kt(),$t()}},$t=()=>{const e=navigator.userAgent,t=!!e.match(/iPad/i)||!!e.match(/iPhone/i),i=!!e.match(/WebKit/i);if(t&&i&&!e.match(/CriOS/i)){const e=44;V().scrollHeight>window.innerHeight-e&&(S().style.paddingBottom="".concat(e,"px"))}},Kt=()=>{const e=S();let t;e.ontouchstart=e=>{t=Gt(e)},e.ontouchmove=e=>{t&&(e.preventDefault(),e.stopPropagation())}},Gt=e=>{const t=e.target,i=S();return!(Jt(e)||Yt(e)||t!==i&&(we(i)||"INPUT"===t.tagName||"TEXTAREA"===t.tagName||we(M())&&M().contains(t)))},Jt=e=>e.touches&&e.touches.length&&"stylus"===e.touches[0].touchType,Yt=e=>e.touches&&e.touches.length>1,Qt=()=>{if(te(document.body,E.iosfix)){const e=parseInt(document.body.style.top,10);le(document.body,E.iosfix),document.body.style.top="",document.body.scrollTop=-1*e}},Zt=10,Xt=e=>{const t=S(),i=V();"function"==typeof e.willOpen&&e.willOpen(i);const n=window.getComputedStyle(document.body).overflowY;ni(t,i,e),setTimeout((()=>{ti(t,i)}),Zt),Y()&&(ii(t,e.scrollbarPadding,n),Tt()),Q()||Ce.previousActiveElement||(Ce.previousActiveElement=document.activeElement),"function"==typeof e.didOpen&&setTimeout((()=>e.didOpen(i))),le(t,E["no-transition"])},ei=e=>{const t=V();if(e.target!==t)return;const i=S();t.removeEventListener(ze,ei),i.style.overflowY="auto"},ti=(e,t)=>{ze&&be(t)?(e.style.overflowY="hidden",t.addEventListener(ze,ei)):e.style.overflowY="auto"},ii=(e,t,i)=>{qt(),t&&"hidden"!==i&&Wt(),setTimeout((()=>{e.scrollTop=0}))},ni=(e,t,i)=>{ae(e,i.showClass.backdrop),t.style.setProperty("opacity","0","important"),ue(t,"grid"),setTimeout((()=>{ae(t,i.showClass.popup),t.style.removeProperty("opacity")}),Zt),ae([document.documentElement,document.body],E.shown),i.heightAuto&&i.backdrop&&!i.toast&&ae([document.documentElement,document.body],E["height-auto"])},si=e=>{let t=V();t||new Jn,t=V();const i=j();Q()?he(O()):oi(t,e),ue(i),t.setAttribute("data-loading","true"),t.setAttribute("aria-busy","true"),t.focus()},oi=(e,t)=>{const i=U(),n=j();!t&&fe(L())&&(t=L()),ue(i),t&&(he(t),n.setAttribute("data-button-to-replace",t.className)),n.parentNode.insertBefore(n,t),ae([e,i],E.loading)},ri=(e,t)=>{"select"===t.input||"radio"===t.input?ui(e,t):["text","email","number","tel","textarea"].includes(t.input)&&(d(t.inputValue)||h(t.inputValue))&&(si(L()),hi(e,t))},ai=(e,t)=>{const i=e.getInput();if(!i)return null;switch(t.input){case"checkbox":return li(i);case"radio":return ci(i);case"file":return di(i);default:return t.inputAutoTrim?i.value.trim():i.value}},li=e=>e.checked?1:0,ci=e=>e.checked?e.value:null,di=e=>e.files.length?null!==e.getAttribute("multiple")?e.files:e.files[0]:null,ui=(e,t)=>{const i=V(),n=e=>mi[t.input](i,gi(e),t);d(t.inputOptions)||h(t.inputOptions)?(si(L()),u(t.inputOptions).then((t=>{e.hideLoading(),n(t)}))):"object"==typeof t.inputOptions?n(t.inputOptions):o("Unexpected type of inputOptions! Expected object, Map or Promise, got ".concat(typeof t.inputOptions))},hi=(e,t)=>{const i=e.getInput();he(i),u(t.inputValue).then((n=>{i.value="number"===t.input?parseFloat(n)||0:"".concat(n),ue(i),i.focus(),e.hideLoading()})).catch((t=>{o("Error in inputValue promise: ".concat(t)),i.value="",ue(i),i.focus(),e.hideLoading()}))},mi={select:(e,t,i)=>{const n=ce(e,E.select),s=(e,t,n)=>{const s=document.createElement("option");s.value=n,ee(s,t),s.selected=fi(n,i.inputValue),e.appendChild(s)};t.forEach((e=>{const t=e[0],i=e[1];if(Array.isArray(i)){const e=document.createElement("optgroup");e.label=t,e.disabled=!1,n.appendChild(e),i.forEach((t=>s(e,t[1],t[0])))}else s(n,i,t)})),n.focus()},radio:(e,t,i)=>{const n=ce(e,E.radio);t.forEach((e=>{const t=e[0],s=e[1],o=document.createElement("input"),r=document.createElement("label");o.type="radio",o.name=E.radio,o.value=t,fi(t,i.inputValue)&&(o.checked=!0);const a=document.createElement("span");ee(a,s),a.className=E.label,r.appendChild(o),r.appendChild(a),n.appendChild(r)}));const s=n.querySelectorAll("input");s.length&&s[0].focus()}},gi=e=>{const t=[];return"undefined"!=typeof Map&&e instanceof Map?e.forEach(((e,i)=>{let n=e;"object"==typeof n&&(n=gi(n)),t.push([i,n])})):Object.keys(e).forEach((i=>{let n=e[i];"object"==typeof n&&(n=gi(n)),t.push([i,n])})),t},fi=(e,t)=>t&&t.toString()===e.toString();function pi(){const e=Ge.innerParams.get(this);if(!e)return;const t=Ge.domCache.get(this);he(t.loader),Q()?e.icon&&ue(O()):wi(t),le([t.popup,t.actions],E.loading),t.popup.removeAttribute("aria-busy"),t.popup.removeAttribute("data-loading"),t.confirmButton.disabled=!1,t.denyButton.disabled=!1,t.cancelButton.disabled=!1}const wi=e=>{const t=e.popup.getElementsByClassName(e.loader.getAttribute("data-button-to-replace"));t.length?ue(t[0],"inline-block"):pe()&&he(e.actions)};function bi(e){const t=Ge.innerParams.get(e||this),i=Ge.domCache.get(e||this);return i?se(i.popup,t.input):null}var vi={swalPromiseResolve:new WeakMap,swalPromiseReject:new WeakMap};const _i=()=>fe(V()),yi=()=>L()&&L().click(),ki=()=>F()&&F().click(),Ci=()=>W()&&W().click(),Ai=e=>{e.keydownTarget&&e.keydownHandlerAdded&&(e.keydownTarget.removeEventListener("keydown",e.keydownHandler,{capture:e.keydownListenerCapture}),e.keydownHandlerAdded=!1)},xi=(e,t,i,n)=>{Ai(t),i.toast||(t.keydownHandler=t=>Si(e,t,n),t.keydownTarget=i.keydownListenerCapture?window:V(),t.keydownListenerCapture=i.keydownListenerCapture,t.keydownTarget.addEventListener("keydown",t.keydownHandler,{capture:t.keydownListenerCapture}),t.keydownHandlerAdded=!0)},Ti=(e,t,i)=>{const n=J();if(n.length)return(t+=i)===n.length?t=0:-1===t&&(t=n.length-1),n[t].focus();V().focus()},Ei=["ArrowRight","ArrowDown"],Pi=["ArrowLeft","ArrowUp"],Si=(e,t,i)=>{const n=Ge.innerParams.get(e);n&&(t.isComposing||229===t.keyCode||(n.stopKeydownPropagation&&t.stopPropagation(),"Enter"===t.key?Ii(e,t,n):"Tab"===t.key?Ri(t,n):[...Ei,...Pi].includes(t.key)?Vi(t.key):"Escape"===t.key&&Oi(t,n,i)))},Ii=(e,t,i)=>{if(c(i.allowEnterKey)&&t.target&&e.getInput()&&t.target instanceof HTMLElement&&t.target.outerHTML===e.getInput().outerHTML){if(["textarea","file"].includes(i.input))return;yi(),t.preventDefault()}},Ri=(e,t)=>{const i=e.target,n=J();let s=-1;for(let e=0;e{const t=L(),i=F(),n=W();if(document.activeElement instanceof HTMLElement&&![t,i,n].includes(document.activeElement))return;const s=Ei.includes(e)?"nextElementSibling":"previousElementSibling";let o=document.activeElement;for(let e=0;e{c(t.allowEscapeKey)&&(e.preventDefault(),i(xt.esc))};function Bi(e,t,i,n){Q()?Ui(e,n):(xe(i).then((()=>Ui(e,n))),Ai(Ce)),/^((?!chrome|android).)*safari/i.test(navigator.userAgent)?(t.setAttribute("style","display:none !important"),t.removeAttribute("class"),t.innerHTML=""):t.remove(),Y()&&(Ut(),Qt(),Et()),Mi()}function Mi(){le([document.documentElement,document.body],[E.shown,E["height-auto"],E["no-backdrop"],E["toast-shown"]])}function Ni(e){e=Hi(e);const t=vi.swalPromiseResolve.get(this),i=zi(this);this.isAwaitingPromise()?e.isDismissed||(Fi(this),t(e)):i&&t(e)}function Di(){return!!Ge.awaitingPromise.get(this)}const zi=e=>{const t=V();if(!t)return!1;const i=Ge.innerParams.get(e);if(!i||te(t,i.hideClass.popup))return!1;le(t,i.showClass.popup),ae(t,i.hideClass.popup);const n=S();return le(n,i.showClass.backdrop),ae(n,i.hideClass.backdrop),ji(e,t,i),!0};function Li(e){const t=vi.swalPromiseReject.get(this);Fi(this),t&&t(e)}const Fi=e=>{e.isAwaitingPromise()&&(Ge.awaitingPromise.delete(e),Ge.innerParams.get(e)||e._destroy())},Hi=e=>void 0===e?{isConfirmed:!1,isDenied:!1,isDismissed:!0}:Object.assign({isConfirmed:!1,isDenied:!1,isDismissed:!1},e),ji=(e,t,i)=>{const n=S(),s=ze&&be(t);"function"==typeof i.willClose&&i.willClose(t),s?Wi(e,t,n,i.returnFocus,i.didClose):Bi(e,n,i.returnFocus,i.didClose)},Wi=(e,t,i,n,s)=>{Ce.swalCloseEventFinishedCallback=Bi.bind(null,e,i,n,s),t.addEventListener(ze,(function(e){e.target===t&&(Ce.swalCloseEventFinishedCallback(),delete Ce.swalCloseEventFinishedCallback)}))},Ui=(e,t)=>{setTimeout((()=>{"function"==typeof t&&t.bind(e.params)(),e._destroy()}))};function qi(e,t,i){const n=Ge.domCache.get(e);t.forEach((e=>{n[e].disabled=i}))}function $i(e,t){if(!e)return!1;if("radio"===e.type){const i=e.parentNode.parentNode.querySelectorAll("input");for(let e=0;e{const t={};return Object.keys(e).forEach((i=>{v(i)?t[i]=e[i]:s("Invalid parameter to update: ".concat(i))})),t};function nn(){const e=Ge.domCache.get(this),t=Ge.innerParams.get(this);t?(e.popup&&Ce.swalCloseEventFinishedCallback&&(Ce.swalCloseEventFinishedCallback(),delete Ce.swalCloseEventFinishedCallback),"function"==typeof t.didDestroy&&t.didDestroy(),sn(this)):on(this)}const sn=e=>{on(e),delete e.params,delete Ce.keydownHandler,delete Ce.keydownTarget,delete Ce.currentInstance},on=e=>{e.isAwaitingPromise()?(rn(Ge,e),Ge.awaitingPromise.set(e,!0)):(rn(vi,e),rn(Ge,e))},rn=(e,t)=>{for(const i in e)e[i].delete(t)};var an=Object.freeze({hideLoading:pi,disableLoading:pi,getInput:bi,close:Ni,isAwaitingPromise:Di,rejectPromise:Li,handleAwaitingPromise:Fi,closePopup:Ni,closeModal:Ni,closeToast:Ni,enableButtons:Ki,disableButtons:Gi,enableInput:Ji,disableInput:Yi,showValidationMessage:Qi,resetValidationMessage:Zi,getProgressSteps:Xi,update:en,_destroy:nn});const ln=e=>{const t=Ge.innerParams.get(e);e.disableButtons(),t.input?un(e,"confirm"):pn(e,!0)},cn=e=>{const t=Ge.innerParams.get(e);e.disableButtons(),t.returnInputValueOnDeny?un(e,"deny"):mn(e,!1)},dn=(e,t)=>{e.disableButtons(),t(xt.cancel)},un=(e,t)=>{const n=Ge.innerParams.get(e);if(!n.input)return o('The "input" parameter is needed to be set when using returnInputValueOn'.concat(i(t)));const s=ai(e,n);n.inputValidator?hn(e,s,t):e.getInput().checkValidity()?"deny"===t?mn(e,s):pn(e,s):(e.enableButtons(),e.showValidationMessage(n.validationMessage))},hn=(e,t,i)=>{const n=Ge.innerParams.get(e);e.disableInput(),Promise.resolve().then((()=>u(n.inputValidator(t,n.validationMessage)))).then((n=>{e.enableButtons(),e.enableInput(),n?e.showValidationMessage(n):"deny"===i?mn(e,t):pn(e,t)}))},mn=(e,t)=>{const i=Ge.innerParams.get(e||void 0);i.showLoaderOnDeny&&si(F()),i.preDeny?(Ge.awaitingPromise.set(e||void 0,!0),Promise.resolve().then((()=>u(i.preDeny(t,i.validationMessage)))).then((i=>{!1===i?(e.hideLoading(),Fi(e)):e.closePopup({isDenied:!0,value:void 0===i?t:i})})).catch((t=>fn(e||void 0,t)))):e.closePopup({isDenied:!0,value:t})},gn=(e,t)=>{e.closePopup({isConfirmed:!0,value:t})},fn=(e,t)=>{e.rejectPromise(t)},pn=(e,t)=>{const i=Ge.innerParams.get(e||void 0);i.showLoaderOnConfirm&&si(),i.preConfirm?(e.resetValidationMessage(),Ge.awaitingPromise.set(e||void 0,!0),Promise.resolve().then((()=>u(i.preConfirm(t,i.validationMessage)))).then((i=>{fe(z())||!1===i?(e.hideLoading(),Fi(e)):gn(e,void 0===i?t:i)})).catch((t=>fn(e||void 0,t)))):gn(e,t)},wn=(e,t,i)=>{Ge.innerParams.get(e).toast?bn(e,t,i):(yn(t),kn(t),Cn(e,t,i))},bn=(e,t,i)=>{t.popup.onclick=()=>{const t=Ge.innerParams.get(e);t&&(vn(t)||t.timer||t.input)||i(xt.close)}},vn=e=>e.showConfirmButton||e.showDenyButton||e.showCancelButton||e.showCloseButton;let _n=!1;const yn=e=>{e.popup.onmousedown=()=>{e.container.onmouseup=function(t){e.container.onmouseup=void 0,t.target===e.container&&(_n=!0)}}},kn=e=>{e.container.onmousedown=()=>{e.popup.onmouseup=function(t){e.popup.onmouseup=void 0,(t.target===e.popup||e.popup.contains(t.target))&&(_n=!0)}}},Cn=(e,t,i)=>{t.container.onclick=n=>{const s=Ge.innerParams.get(e);_n?_n=!1:n.target===t.container&&c(s.allowOutsideClick)&&i(xt.backdrop)}},An=e=>"object"==typeof e&&e.jquery,xn=e=>e instanceof Element||An(e),Tn=e=>{const t={};return"object"!=typeof e[0]||xn(e[0])?["title","html","icon"].forEach(((i,n)=>{const s=e[n];"string"==typeof s||xn(s)?t[i]=s:void 0!==s&&o("Unexpected type of ".concat(i,'! Expected "string" or "Element", got ').concat(typeof s))})):Object.assign(t,e[0]),t};function En(){const e=this;for(var t=arguments.length,i=new Array(t),n=0;nCe.timeout&&Ce.timeout.getTimerLeft(),In=()=>{if(Ce.timeout)return _e(),Ce.timeout.stop()},Rn=()=>{if(Ce.timeout){const e=Ce.timeout.start();return ve(e),e}},Vn=()=>{const e=Ce.timeout;return e&&(e.running?In():Rn())},On=e=>{if(Ce.timeout){const t=Ce.timeout.increase(e);return ve(t,!0),t}},Bn=()=>Ce.timeout&&Ce.timeout.isRunning();let Mn=!1;const Nn={};function Dn(){Nn[arguments.length>0&&void 0!==arguments[0]?arguments[0]:"data-swal-template"]=this,Mn||(document.body.addEventListener("click",zn),Mn=!0)}const zn=e=>{for(let t=e.target;t&&t!==document;t=t.parentNode)for(const e in Nn){const i=t.getAttribute(e);if(i)return void Nn[e].fire({template:i})}};var Ln=Object.freeze({isValidParameter:b,isUpdatableParameter:v,isDeprecatedParameter:_,argsToParams:Tn,isVisible:_i,clickConfirm:yi,clickDeny:ki,clickCancel:Ci,getContainer:S,getPopup:V,getTitle:B,getHtmlContainer:M,getImage:N,getIcon:O,getInputLabel:H,getCloseButton:K,getActions:U,getConfirmButton:L,getDenyButton:F,getCancelButton:W,getLoader:j,getFooter:q,getTimerProgressBar:$,getFocusableElements:J,getValidationMessage:z,isLoading:Z,fire:En,mixin:Pn,showLoading:si,enableLoading:si,getTimerLeft:Sn,stopTimer:In,resumeTimer:Rn,toggleTimer:Vn,increaseTimer:On,isTimerRunning:Bn,bindClickHandler:Dn});let Fn;class Hn{constructor(){if("undefined"==typeof window)return;Fn=this;for(var e=arguments.length,t=new Array(e),i=0;i1&&void 0!==arguments[1]?arguments[1]:{};A(Object.assign({},t,e)),Ce.currentInstance&&(Ce.currentInstance._destroy(),Y()&&Et()),Ce.currentInstance=Fn;const i=Wn(e,t);Ht(i),Object.freeze(i),Ce.timeout&&(Ce.timeout.stop(),delete Ce.timeout),clearTimeout(Ce.restoreFocusTimeout);const n=Un(Fn);return At(Fn,i),Ge.innerParams.set(Fn,i),jn(Fn,n,i)}then(e){return Ge.promise.get(this).then(e)}finally(e){return Ge.promise.get(this).finally(e)}}const jn=(e,t,i)=>new Promise(((n,s)=>{const o=t=>{e.closePopup({isDismissed:!0,dismiss:t})};vi.swalPromiseResolve.set(e,n),vi.swalPromiseReject.set(e,s),t.confirmButton.onclick=()=>ln(e),t.denyButton.onclick=()=>cn(e),t.cancelButton.onclick=()=>dn(e,o),t.closeButton.onclick=()=>o(xt.close),wn(e,t,o),xi(e,Ce,i,o),ri(e,i),Xt(i),qn(Ce,i,o),$n(t,i),setTimeout((()=>{t.container.scrollTop=0}))})),Wn=(e,t)=>{const i=St(e),n=Object.assign({},g,t,i,e);return n.showClass=Object.assign({},g.showClass,n.showClass),n.hideClass=Object.assign({},g.hideClass,n.hideClass),n},Un=e=>{const t={popup:V(),container:S(),actions:U(),confirmButton:L(),denyButton:F(),cancelButton:W(),loader:j(),closeButton:K(),validationMessage:z(),progressSteps:D()};return Ge.domCache.set(e,t),t},qn=(e,t,i)=>{const n=$();he(n),t.timer&&(e.timeout=new jt((()=>{i("timer"),delete e.timeout}),t.timer),t.timerProgressBar&&(ue(n),ne(n,t,"timerProgressBar"),setTimeout((()=>{e.timeout&&e.timeout.running&&ve(t.timer)}))))},$n=(e,t)=>{if(!t.toast)return c(t.allowEnterKey)?void(Kn(e,t)||Ti(t,-1,1)):Gn()},Kn=(e,t)=>t.focusDeny&&fe(e.denyButton)?(e.denyButton.focus(),!0):t.focusCancel&&fe(e.cancelButton)?(e.cancelButton.focus(),!0):!(!t.focusConfirm||!fe(e.confirmButton)||(e.confirmButton.focus(),0)),Gn=()=>{document.activeElement instanceof HTMLElement&&"function"==typeof document.activeElement.blur&&document.activeElement.blur()};Object.assign(Hn.prototype,an),Object.assign(Hn,Ln),Object.keys(an).forEach((e=>{Hn[e]=function(){if(Fn)return Fn[e](...arguments)}})),Hn.DismissReason=xt,Hn.version="11.4.17";const Jn=Hn;return Jn.default=Jn,Jn}(),void 0!==this&&this.Sweetalert2&&(this.swal=this.sweetAlert=this.Swal=this.SweetAlert=this.Sweetalert2),"undefined"!=typeof document&&function(e,t){var i=e.createElement("style");if(e.getElementsByTagName("head")[0].appendChild(i),i.styleSheet)i.styleSheet.disabled||(i.styleSheet.cssText=t);else try{i.innerHTML=t}catch(e){i.innerText=t}}(document,'.swal2-popup.swal2-toast{box-sizing:border-box;grid-column:1/4!important;grid-row:1/4!important;grid-template-columns:1fr 99fr 1fr;padding:1em;overflow-y:hidden;background:#fff;box-shadow:0 0 1px hsla(0deg,0%,0%,.075),0 1px 2px hsla(0deg,0%,0%,.075),1px 2px 4px hsla(0deg,0%,0%,.075),1px 3px 8px hsla(0deg,0%,0%,.075),2px 4px 16px hsla(0deg,0%,0%,.075);pointer-events:all}.swal2-popup.swal2-toast>*{grid-column:2}.swal2-popup.swal2-toast .swal2-title{margin:.5em 1em;padding:0;font-size:1em;text-align:initial}.swal2-popup.swal2-toast .swal2-loading{justify-content:center}.swal2-popup.swal2-toast .swal2-input{height:2em;margin:.5em;font-size:1em}.swal2-popup.swal2-toast .swal2-validation-message{font-size:1em}.swal2-popup.swal2-toast .swal2-footer{margin:.5em 0 0;padding:.5em 0 0;font-size:.8em}.swal2-popup.swal2-toast .swal2-close{grid-column:3/3;grid-row:1/99;align-self:center;width:.8em;height:.8em;margin:0;font-size:2em}.swal2-popup.swal2-toast .swal2-html-container{margin:.5em 1em;padding:0;font-size:1em;text-align:initial}.swal2-popup.swal2-toast .swal2-html-container:empty{padding:0}.swal2-popup.swal2-toast .swal2-loader{grid-column:1;grid-row:1/99;align-self:center;width:2em;height:2em;margin:.25em}.swal2-popup.swal2-toast .swal2-icon{grid-column:1;grid-row:1/99;align-self:center;width:2em;min-width:2em;height:2em;margin:0 .5em 0 0}.swal2-popup.swal2-toast .swal2-icon .swal2-icon-content{display:flex;align-items:center;font-size:1.8em;font-weight:700}.swal2-popup.swal2-toast .swal2-icon.swal2-success .swal2-success-ring{width:2em;height:2em}.swal2-popup.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line]{top:.875em;width:1.375em}.swal2-popup.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=left]{left:.3125em}.swal2-popup.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=right]{right:.3125em}.swal2-popup.swal2-toast .swal2-actions{justify-content:flex-start;height:auto;margin:0;margin-top:.5em;padding:0 .5em}.swal2-popup.swal2-toast .swal2-styled{margin:.25em .5em;padding:.4em .6em;font-size:1em}.swal2-popup.swal2-toast .swal2-success{border-color:#a5dc86}.swal2-popup.swal2-toast .swal2-success [class^=swal2-success-circular-line]{position:absolute;width:1.6em;height:3em;transform:rotate(45deg);border-radius:50%}.swal2-popup.swal2-toast .swal2-success [class^=swal2-success-circular-line][class$=left]{top:-.8em;left:-.5em;transform:rotate(-45deg);transform-origin:2em 2em;border-radius:4em 0 0 4em}.swal2-popup.swal2-toast .swal2-success [class^=swal2-success-circular-line][class$=right]{top:-.25em;left:.9375em;transform-origin:0 1.5em;border-radius:0 4em 4em 0}.swal2-popup.swal2-toast .swal2-success .swal2-success-ring{width:2em;height:2em}.swal2-popup.swal2-toast .swal2-success .swal2-success-fix{top:0;left:.4375em;width:.4375em;height:2.6875em}.swal2-popup.swal2-toast .swal2-success [class^=swal2-success-line]{height:.3125em}.swal2-popup.swal2-toast .swal2-success [class^=swal2-success-line][class$=tip]{top:1.125em;left:.1875em;width:.75em}.swal2-popup.swal2-toast .swal2-success [class^=swal2-success-line][class$=long]{top:.9375em;right:.1875em;width:1.375em}.swal2-popup.swal2-toast .swal2-success.swal2-icon-show .swal2-success-line-tip{-webkit-animation:swal2-toast-animate-success-line-tip .75s;animation:swal2-toast-animate-success-line-tip .75s}.swal2-popup.swal2-toast .swal2-success.swal2-icon-show .swal2-success-line-long{-webkit-animation:swal2-toast-animate-success-line-long .75s;animation:swal2-toast-animate-success-line-long .75s}.swal2-popup.swal2-toast.swal2-show{-webkit-animation:swal2-toast-show .5s;animation:swal2-toast-show .5s}.swal2-popup.swal2-toast.swal2-hide{-webkit-animation:swal2-toast-hide .1s forwards;animation:swal2-toast-hide .1s forwards}.swal2-container{display:grid;position:fixed;z-index:1060;top:0;right:0;bottom:0;left:0;box-sizing:border-box;grid-template-areas:"top-start top top-end" "center-start center center-end" "bottom-start bottom-center bottom-end";grid-template-rows:minmax(-webkit-min-content,auto) minmax(-webkit-min-content,auto) minmax(-webkit-min-content,auto);grid-template-rows:minmax(min-content,auto) minmax(min-content,auto) minmax(min-content,auto);height:100%;padding:.625em;overflow-x:hidden;transition:background-color .1s;-webkit-overflow-scrolling:touch}.swal2-container.swal2-backdrop-show,.swal2-container.swal2-noanimation{background:rgba(0,0,0,.4)}.swal2-container.swal2-backdrop-hide{background:0 0!important}.swal2-container.swal2-bottom-start,.swal2-container.swal2-center-start,.swal2-container.swal2-top-start{grid-template-columns:minmax(0,1fr) auto auto}.swal2-container.swal2-bottom,.swal2-container.swal2-center,.swal2-container.swal2-top{grid-template-columns:auto minmax(0,1fr) auto}.swal2-container.swal2-bottom-end,.swal2-container.swal2-center-end,.swal2-container.swal2-top-end{grid-template-columns:auto auto minmax(0,1fr)}.swal2-container.swal2-top-start>.swal2-popup{align-self:start}.swal2-container.swal2-top>.swal2-popup{grid-column:2;align-self:start;justify-self:center}.swal2-container.swal2-top-end>.swal2-popup,.swal2-container.swal2-top-right>.swal2-popup{grid-column:3;align-self:start;justify-self:end}.swal2-container.swal2-center-left>.swal2-popup,.swal2-container.swal2-center-start>.swal2-popup{grid-row:2;align-self:center}.swal2-container.swal2-center>.swal2-popup{grid-column:2;grid-row:2;align-self:center;justify-self:center}.swal2-container.swal2-center-end>.swal2-popup,.swal2-container.swal2-center-right>.swal2-popup{grid-column:3;grid-row:2;align-self:center;justify-self:end}.swal2-container.swal2-bottom-left>.swal2-popup,.swal2-container.swal2-bottom-start>.swal2-popup{grid-column:1;grid-row:3;align-self:end}.swal2-container.swal2-bottom>.swal2-popup{grid-column:2;grid-row:3;justify-self:center;align-self:end}.swal2-container.swal2-bottom-end>.swal2-popup,.swal2-container.swal2-bottom-right>.swal2-popup{grid-column:3;grid-row:3;align-self:end;justify-self:end}.swal2-container.swal2-grow-fullscreen>.swal2-popup,.swal2-container.swal2-grow-row>.swal2-popup{grid-column:1/4;width:100%}.swal2-container.swal2-grow-column>.swal2-popup,.swal2-container.swal2-grow-fullscreen>.swal2-popup{grid-row:1/4;align-self:stretch}.swal2-container.swal2-no-transition{transition:none!important}.swal2-popup{display:none;position:relative;box-sizing:border-box;grid-template-columns:minmax(0,100%);width:32em;max-width:100%;padding:0 0 1.25em;border:none;border-radius:5px;background:#fff;color:#545454;font-family:inherit;font-size:1rem}.swal2-popup:focus{outline:0}.swal2-popup.swal2-loading{overflow-y:hidden}.swal2-title{position:relative;max-width:100%;margin:0;padding:.8em 1em 0;color:inherit;font-size:1.875em;font-weight:600;text-align:center;text-transform:none;word-wrap:break-word}.swal2-actions{display:flex;z-index:1;box-sizing:border-box;flex-wrap:wrap;align-items:center;justify-content:center;width:auto;margin:1.25em auto 0;padding:0}.swal2-actions:not(.swal2-loading) .swal2-styled[disabled]{opacity:.4}.swal2-actions:not(.swal2-loading) .swal2-styled:hover{background-image:linear-gradient(rgba(0,0,0,.1),rgba(0,0,0,.1))}.swal2-actions:not(.swal2-loading) .swal2-styled:active{background-image:linear-gradient(rgba(0,0,0,.2),rgba(0,0,0,.2))}.swal2-loader{display:none;align-items:center;justify-content:center;width:2.2em;height:2.2em;margin:0 1.875em;-webkit-animation:swal2-rotate-loading 1.5s linear 0s infinite normal;animation:swal2-rotate-loading 1.5s linear 0s infinite normal;border-width:.25em;border-style:solid;border-radius:100%;border-color:#2778c4 transparent #2778c4 transparent}.swal2-styled{margin:.3125em;padding:.625em 1.1em;transition:box-shadow .1s;box-shadow:0 0 0 3px transparent;font-weight:500}.swal2-styled:not([disabled]){cursor:pointer}.swal2-styled.swal2-confirm{border:0;border-radius:.25em;background:initial;background-color:#7066e0;color:#fff;font-size:1em}.swal2-styled.swal2-confirm:focus{box-shadow:0 0 0 3px rgba(112,102,224,.5)}.swal2-styled.swal2-deny{border:0;border-radius:.25em;background:initial;background-color:#dc3741;color:#fff;font-size:1em}.swal2-styled.swal2-deny:focus{box-shadow:0 0 0 3px rgba(220,55,65,.5)}.swal2-styled.swal2-cancel{border:0;border-radius:.25em;background:initial;background-color:#6e7881;color:#fff;font-size:1em}.swal2-styled.swal2-cancel:focus{box-shadow:0 0 0 3px rgba(110,120,129,.5)}.swal2-styled.swal2-default-outline:focus{box-shadow:0 0 0 3px rgba(100,150,200,.5)}.swal2-styled:focus{outline:0}.swal2-styled::-moz-focus-inner{border:0}.swal2-footer{justify-content:center;margin:1em 0 0;padding:1em 1em 0;border-top:1px solid #eee;color:inherit;font-size:1em}.swal2-timer-progress-bar-container{position:absolute;right:0;bottom:0;left:0;grid-column:auto!important;overflow:hidden;border-bottom-right-radius:5px;border-bottom-left-radius:5px}.swal2-timer-progress-bar{width:100%;height:.25em;background:rgba(0,0,0,.2)}.swal2-image{max-width:100%;margin:2em auto 1em}.swal2-close{z-index:2;align-items:center;justify-content:center;width:1.2em;height:1.2em;margin-top:0;margin-right:0;margin-bottom:-1.2em;padding:0;overflow:hidden;transition:color .1s,box-shadow .1s;border:none;border-radius:5px;background:0 0;color:#ccc;font-family:serif;font-family:monospace;font-size:2.5em;cursor:pointer;justify-self:end}.swal2-close:hover{transform:none;background:0 0;color:#f27474}.swal2-close:focus{outline:0;box-shadow:inset 0 0 0 3px rgba(100,150,200,.5)}.swal2-close::-moz-focus-inner{border:0}.swal2-html-container{z-index:1;justify-content:center;margin:1em 1.6em .3em;padding:0;overflow:auto;color:inherit;font-size:1.125em;font-weight:400;line-height:normal;text-align:center;word-wrap:break-word;word-break:break-word}.swal2-checkbox,.swal2-file,.swal2-input,.swal2-radio,.swal2-select,.swal2-textarea{margin:1em 2em 3px}.swal2-file,.swal2-input,.swal2-textarea{box-sizing:border-box;width:auto;transition:border-color .1s,box-shadow .1s;border:1px solid #d9d9d9;border-radius:.1875em;background:0 0;box-shadow:inset 0 1px 1px rgba(0,0,0,.06),0 0 0 3px transparent;color:inherit;font-size:1.125em}.swal2-file.swal2-inputerror,.swal2-input.swal2-inputerror,.swal2-textarea.swal2-inputerror{border-color:#f27474!important;box-shadow:0 0 2px #f27474!important}.swal2-file:focus,.swal2-input:focus,.swal2-textarea:focus{border:1px solid #b4dbed;outline:0;box-shadow:inset 0 1px 1px rgba(0,0,0,.06),0 0 0 3px rgba(100,150,200,.5)}.swal2-file::-moz-placeholder,.swal2-input::-moz-placeholder,.swal2-textarea::-moz-placeholder{color:#ccc}.swal2-file:-ms-input-placeholder,.swal2-input:-ms-input-placeholder,.swal2-textarea:-ms-input-placeholder{color:#ccc}.swal2-file::placeholder,.swal2-input::placeholder,.swal2-textarea::placeholder{color:#ccc}.swal2-range{margin:1em 2em 3px;background:#fff}.swal2-range input{width:80%}.swal2-range output{width:20%;color:inherit;font-weight:600;text-align:center}.swal2-range input,.swal2-range output{height:2.625em;padding:0;font-size:1.125em;line-height:2.625em}.swal2-input{height:2.625em;padding:0 .75em}.swal2-file{width:75%;margin-right:auto;margin-left:auto;background:0 0;font-size:1.125em}.swal2-textarea{height:6.75em;padding:.75em}.swal2-select{min-width:50%;max-width:100%;padding:.375em .625em;background:0 0;color:inherit;font-size:1.125em}.swal2-checkbox,.swal2-radio{align-items:center;justify-content:center;background:#fff;color:inherit}.swal2-checkbox label,.swal2-radio label{margin:0 .6em;font-size:1.125em}.swal2-checkbox input,.swal2-radio input{flex-shrink:0;margin:0 .4em}.swal2-input-label{display:flex;justify-content:center;margin:1em auto 0}.swal2-validation-message{align-items:center;justify-content:center;margin:1em 0 0;padding:.625em;overflow:hidden;background:#f0f0f0;color:#666;font-size:1em;font-weight:300}.swal2-validation-message::before{content:"!";display:inline-block;width:1.5em;min-width:1.5em;height:1.5em;margin:0 .625em;border-radius:50%;background-color:#f27474;color:#fff;font-weight:600;line-height:1.5em;text-align:center}.swal2-icon{position:relative;box-sizing:content-box;justify-content:center;width:5em;height:5em;margin:2.5em auto .6em;border:.25em solid transparent;border-radius:50%;border-color:#000;font-family:inherit;line-height:5em;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.swal2-icon .swal2-icon-content{display:flex;align-items:center;font-size:3.75em}.swal2-icon.swal2-error{border-color:#f27474;color:#f27474}.swal2-icon.swal2-error .swal2-x-mark{position:relative;flex-grow:1}.swal2-icon.swal2-error [class^=swal2-x-mark-line]{display:block;position:absolute;top:2.3125em;width:2.9375em;height:.3125em;border-radius:.125em;background-color:#f27474}.swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=left]{left:1.0625em;transform:rotate(45deg)}.swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=right]{right:1em;transform:rotate(-45deg)}.swal2-icon.swal2-error.swal2-icon-show{-webkit-animation:swal2-animate-error-icon .5s;animation:swal2-animate-error-icon .5s}.swal2-icon.swal2-error.swal2-icon-show .swal2-x-mark{-webkit-animation:swal2-animate-error-x-mark .5s;animation:swal2-animate-error-x-mark .5s}.swal2-icon.swal2-warning{border-color:#facea8;color:#f8bb86}.swal2-icon.swal2-warning.swal2-icon-show{-webkit-animation:swal2-animate-error-icon .5s;animation:swal2-animate-error-icon .5s}.swal2-icon.swal2-warning.swal2-icon-show .swal2-icon-content{-webkit-animation:swal2-animate-i-mark .5s;animation:swal2-animate-i-mark .5s}.swal2-icon.swal2-info{border-color:#9de0f6;color:#3fc3ee}.swal2-icon.swal2-info.swal2-icon-show{-webkit-animation:swal2-animate-error-icon .5s;animation:swal2-animate-error-icon .5s}.swal2-icon.swal2-info.swal2-icon-show .swal2-icon-content{-webkit-animation:swal2-animate-i-mark .8s;animation:swal2-animate-i-mark .8s}.swal2-icon.swal2-question{border-color:#c9dae1;color:#87adbd}.swal2-icon.swal2-question.swal2-icon-show{-webkit-animation:swal2-animate-error-icon .5s;animation:swal2-animate-error-icon .5s}.swal2-icon.swal2-question.swal2-icon-show .swal2-icon-content{-webkit-animation:swal2-animate-question-mark .8s;animation:swal2-animate-question-mark .8s}.swal2-icon.swal2-success{border-color:#a5dc86;color:#a5dc86}.swal2-icon.swal2-success [class^=swal2-success-circular-line]{position:absolute;width:3.75em;height:7.5em;transform:rotate(45deg);border-radius:50%}.swal2-icon.swal2-success [class^=swal2-success-circular-line][class$=left]{top:-.4375em;left:-2.0635em;transform:rotate(-45deg);transform-origin:3.75em 3.75em;border-radius:7.5em 0 0 7.5em}.swal2-icon.swal2-success [class^=swal2-success-circular-line][class$=right]{top:-.6875em;left:1.875em;transform:rotate(-45deg);transform-origin:0 3.75em;border-radius:0 7.5em 7.5em 0}.swal2-icon.swal2-success .swal2-success-ring{position:absolute;z-index:2;top:-.25em;left:-.25em;box-sizing:content-box;width:100%;height:100%;border:.25em solid rgba(165,220,134,.3);border-radius:50%}.swal2-icon.swal2-success .swal2-success-fix{position:absolute;z-index:1;top:.5em;left:1.625em;width:.4375em;height:5.625em;transform:rotate(-45deg)}.swal2-icon.swal2-success [class^=swal2-success-line]{display:block;position:absolute;z-index:2;height:.3125em;border-radius:.125em;background-color:#a5dc86}.swal2-icon.swal2-success [class^=swal2-success-line][class$=tip]{top:2.875em;left:.8125em;width:1.5625em;transform:rotate(45deg)}.swal2-icon.swal2-success [class^=swal2-success-line][class$=long]{top:2.375em;right:.5em;width:2.9375em;transform:rotate(-45deg)}.swal2-icon.swal2-success.swal2-icon-show .swal2-success-line-tip{-webkit-animation:swal2-animate-success-line-tip .75s;animation:swal2-animate-success-line-tip .75s}.swal2-icon.swal2-success.swal2-icon-show .swal2-success-line-long{-webkit-animation:swal2-animate-success-line-long .75s;animation:swal2-animate-success-line-long .75s}.swal2-icon.swal2-success.swal2-icon-show .swal2-success-circular-line-right{-webkit-animation:swal2-rotate-success-circular-line 4.25s ease-in;animation:swal2-rotate-success-circular-line 4.25s ease-in}.swal2-progress-steps{flex-wrap:wrap;align-items:center;max-width:100%;margin:1.25em auto;padding:0;background:0 0;font-weight:600}.swal2-progress-steps li{display:inline-block;position:relative}.swal2-progress-steps .swal2-progress-step{z-index:20;flex-shrink:0;width:2em;height:2em;border-radius:2em;background:#2778c4;color:#fff;line-height:2em;text-align:center}.swal2-progress-steps .swal2-progress-step.swal2-active-progress-step{background:#2778c4}.swal2-progress-steps .swal2-progress-step.swal2-active-progress-step~.swal2-progress-step{background:#add8e6;color:#fff}.swal2-progress-steps .swal2-progress-step.swal2-active-progress-step~.swal2-progress-step-line{background:#add8e6}.swal2-progress-steps .swal2-progress-step-line{z-index:10;flex-shrink:0;width:2.5em;height:.4em;margin:0 -1px;background:#2778c4}[class^=swal2]{-webkit-tap-highlight-color:transparent}.swal2-show{-webkit-animation:swal2-show .3s;animation:swal2-show .3s}.swal2-hide{-webkit-animation:swal2-hide .15s forwards;animation:swal2-hide .15s forwards}.swal2-noanimation{transition:none}.swal2-scrollbar-measure{position:absolute;top:-9999px;width:50px;height:50px;overflow:scroll}.swal2-rtl .swal2-close{margin-right:initial;margin-left:0}.swal2-rtl .swal2-timer-progress-bar{right:0;left:auto}.swal2-no-war{display:flex;position:fixed;z-index:1061;top:0;left:0;align-items:center;justify-content:center;width:100%;height:3.375em;background:#20232a;color:#fff;text-align:center}.swal2-no-war a{color:#61dafb;text-decoration:none}.swal2-no-war a:hover{text-decoration:underline}@-webkit-keyframes swal2-toast-show{0%{transform:translateY(-.625em) rotateZ(2deg)}33%{transform:translateY(0) rotateZ(-2deg)}66%{transform:translateY(.3125em) rotateZ(2deg)}100%{transform:translateY(0) rotateZ(0)}}@keyframes swal2-toast-show{0%{transform:translateY(-.625em) rotateZ(2deg)}33%{transform:translateY(0) rotateZ(-2deg)}66%{transform:translateY(.3125em) rotateZ(2deg)}100%{transform:translateY(0) rotateZ(0)}}@-webkit-keyframes swal2-toast-hide{100%{transform:rotateZ(1deg);opacity:0}}@keyframes swal2-toast-hide{100%{transform:rotateZ(1deg);opacity:0}}@-webkit-keyframes swal2-toast-animate-success-line-tip{0%{top:.5625em;left:.0625em;width:0}54%{top:.125em;left:.125em;width:0}70%{top:.625em;left:-.25em;width:1.625em}84%{top:1.0625em;left:.75em;width:.5em}100%{top:1.125em;left:.1875em;width:.75em}}@keyframes swal2-toast-animate-success-line-tip{0%{top:.5625em;left:.0625em;width:0}54%{top:.125em;left:.125em;width:0}70%{top:.625em;left:-.25em;width:1.625em}84%{top:1.0625em;left:.75em;width:.5em}100%{top:1.125em;left:.1875em;width:.75em}}@-webkit-keyframes swal2-toast-animate-success-line-long{0%{top:1.625em;right:1.375em;width:0}65%{top:1.25em;right:.9375em;width:0}84%{top:.9375em;right:0;width:1.125em}100%{top:.9375em;right:.1875em;width:1.375em}}@keyframes swal2-toast-animate-success-line-long{0%{top:1.625em;right:1.375em;width:0}65%{top:1.25em;right:.9375em;width:0}84%{top:.9375em;right:0;width:1.125em}100%{top:.9375em;right:.1875em;width:1.375em}}@-webkit-keyframes swal2-show{0%{transform:scale(.7)}45%{transform:scale(1.05)}80%{transform:scale(.95)}100%{transform:scale(1)}}@keyframes swal2-show{0%{transform:scale(.7)}45%{transform:scale(1.05)}80%{transform:scale(.95)}100%{transform:scale(1)}}@-webkit-keyframes swal2-hide{0%{transform:scale(1);opacity:1}100%{transform:scale(.5);opacity:0}}@keyframes swal2-hide{0%{transform:scale(1);opacity:1}100%{transform:scale(.5);opacity:0}}@-webkit-keyframes swal2-animate-success-line-tip{0%{top:1.1875em;left:.0625em;width:0}54%{top:1.0625em;left:.125em;width:0}70%{top:2.1875em;left:-.375em;width:3.125em}84%{top:3em;left:1.3125em;width:1.0625em}100%{top:2.8125em;left:.8125em;width:1.5625em}}@keyframes swal2-animate-success-line-tip{0%{top:1.1875em;left:.0625em;width:0}54%{top:1.0625em;left:.125em;width:0}70%{top:2.1875em;left:-.375em;width:3.125em}84%{top:3em;left:1.3125em;width:1.0625em}100%{top:2.8125em;left:.8125em;width:1.5625em}}@-webkit-keyframes swal2-animate-success-line-long{0%{top:3.375em;right:2.875em;width:0}65%{top:3.375em;right:2.875em;width:0}84%{top:2.1875em;right:0;width:3.4375em}100%{top:2.375em;right:.5em;width:2.9375em}}@keyframes swal2-animate-success-line-long{0%{top:3.375em;right:2.875em;width:0}65%{top:3.375em;right:2.875em;width:0}84%{top:2.1875em;right:0;width:3.4375em}100%{top:2.375em;right:.5em;width:2.9375em}}@-webkit-keyframes swal2-rotate-success-circular-line{0%{transform:rotate(-45deg)}5%{transform:rotate(-45deg)}12%{transform:rotate(-405deg)}100%{transform:rotate(-405deg)}}@keyframes swal2-rotate-success-circular-line{0%{transform:rotate(-45deg)}5%{transform:rotate(-45deg)}12%{transform:rotate(-405deg)}100%{transform:rotate(-405deg)}}@-webkit-keyframes swal2-animate-error-x-mark{0%{margin-top:1.625em;transform:scale(.4);opacity:0}50%{margin-top:1.625em;transform:scale(.4);opacity:0}80%{margin-top:-.375em;transform:scale(1.15)}100%{margin-top:0;transform:scale(1);opacity:1}}@keyframes swal2-animate-error-x-mark{0%{margin-top:1.625em;transform:scale(.4);opacity:0}50%{margin-top:1.625em;transform:scale(.4);opacity:0}80%{margin-top:-.375em;transform:scale(1.15)}100%{margin-top:0;transform:scale(1);opacity:1}}@-webkit-keyframes swal2-animate-error-icon{0%{transform:rotateX(100deg);opacity:0}100%{transform:rotateX(0);opacity:1}}@keyframes swal2-animate-error-icon{0%{transform:rotateX(100deg);opacity:0}100%{transform:rotateX(0);opacity:1}}@-webkit-keyframes swal2-rotate-loading{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}@keyframes swal2-rotate-loading{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}@-webkit-keyframes swal2-animate-question-mark{0%{transform:rotateY(-360deg)}100%{transform:rotateY(0)}}@keyframes swal2-animate-question-mark{0%{transform:rotateY(-360deg)}100%{transform:rotateY(0)}}@-webkit-keyframes swal2-animate-i-mark{0%{transform:rotateZ(45deg);opacity:0}25%{transform:rotateZ(-25deg);opacity:.4}50%{transform:rotateZ(15deg);opacity:.8}75%{transform:rotateZ(-5deg);opacity:1}100%{transform:rotateX(0);opacity:1}}@keyframes swal2-animate-i-mark{0%{transform:rotateZ(45deg);opacity:0}25%{transform:rotateZ(-25deg);opacity:.4}50%{transform:rotateZ(15deg);opacity:.8}75%{transform:rotateZ(-5deg);opacity:1}100%{transform:rotateX(0);opacity:1}}body.swal2-shown:not(.swal2-no-backdrop):not(.swal2-toast-shown){overflow:hidden}body.swal2-height-auto{height:auto!important}body.swal2-no-backdrop .swal2-container{background-color:transparent!important;pointer-events:none}body.swal2-no-backdrop .swal2-container .swal2-popup{pointer-events:all}body.swal2-no-backdrop .swal2-container .swal2-modal{box-shadow:0 0 10px rgba(0,0,0,.4)}@media print{body.swal2-shown:not(.swal2-no-backdrop):not(.swal2-toast-shown){overflow-y:scroll!important}body.swal2-shown:not(.swal2-no-backdrop):not(.swal2-toast-shown)>[aria-hidden=true]{display:none}body.swal2-shown:not(.swal2-no-backdrop):not(.swal2-toast-shown) .swal2-container{position:static!important}}body.swal2-toast-shown .swal2-container{box-sizing:border-box;width:360px;max-width:100%;background-color:transparent;pointer-events:none}body.swal2-toast-shown .swal2-container.swal2-top{top:0;right:auto;bottom:auto;left:50%;transform:translateX(-50%)}body.swal2-toast-shown .swal2-container.swal2-top-end,body.swal2-toast-shown .swal2-container.swal2-top-right{top:0;right:0;bottom:auto;left:auto}body.swal2-toast-shown .swal2-container.swal2-top-left,body.swal2-toast-shown .swal2-container.swal2-top-start{top:0;right:auto;bottom:auto;left:0}body.swal2-toast-shown .swal2-container.swal2-center-left,body.swal2-toast-shown .swal2-container.swal2-center-start{top:50%;right:auto;bottom:auto;left:0;transform:translateY(-50%)}body.swal2-toast-shown .swal2-container.swal2-center{top:50%;right:auto;bottom:auto;left:50%;transform:translate(-50%,-50%)}body.swal2-toast-shown .swal2-container.swal2-center-end,body.swal2-toast-shown .swal2-container.swal2-center-right{top:50%;right:0;bottom:auto;left:auto;transform:translateY(-50%)}body.swal2-toast-shown .swal2-container.swal2-bottom-left,body.swal2-toast-shown .swal2-container.swal2-bottom-start{top:auto;right:auto;bottom:0;left:0}body.swal2-toast-shown .swal2-container.swal2-bottom{top:auto;right:auto;bottom:0;left:50%;transform:translateX(-50%)}body.swal2-toast-shown .swal2-container.swal2-bottom-end,body.swal2-toast-shown .swal2-container.swal2-bottom-right{top:auto;right:0;bottom:0;left:auto}')}},t={};function i(n){var s=t[n];if(void 0!==s)return s.exports;var o=t[n]={exports:{}};return e[n].call(o.exports,o,o.exports,i),o.exports}i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var n={};return(()=>{"use strict";i.d(n,{default:()=>hC});const e=function(){return function e(){e.called=!0}};class t{constructor(t,i){this.source=t,this.name=i,this.path=[],this.stop=e(),this.off=e()}}const s=new Array(256).fill().map(((e,t)=>("0"+t.toString(16)).slice(-2)));function o(){const e=4294967296*Math.random()>>>0,t=4294967296*Math.random()>>>0,i=4294967296*Math.random()>>>0,n=4294967296*Math.random()>>>0;return"e"+s[e>>0&255]+s[e>>8&255]+s[e>>16&255]+s[e>>24&255]+s[t>>0&255]+s[t>>8&255]+s[t>>16&255]+s[t>>24&255]+s[i>>0&255]+s[i>>8&255]+s[i>>16&255]+s[i>>24&255]+s[n>>0&255]+s[n>>8&255]+s[n>>16&255]+s[n>>24&255]}const r={get(e){return"number"!=typeof e?this[e]||this.normal:e},highest:1e5,high:1e3,normal:0,low:-1e3,lowest:-1e5};function a(e,t){const i=r.get(t.priority);for(let n=0;n{if("object"==typeof t&&null!==t){if(i.has(t))return`[object ${t.constructor.name}]`;i.add(t)}return t},s=t?` ${JSON.stringify(t,n)}`:"",o=d(e);return e+s+o}(e,i)),this.name="CKEditorError",this.context=t,this.data=i}is(e){return"CKEditorError"===e}static rethrowUnexpectedError(e,t){if(e.is&&e.is("CKEditorError"))throw e;const i=new l(e.message,t);throw i.stack=e.stack,i}}function c(e,t){console.warn(...u(e,t))}function d(e){return`\nRead more: https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html#error-${e}`}function u(e,t){const i=d(e);return t?[e,t,i]:[e,i]}const h="34.1.0",m="object"==typeof window?window:i.g;if(m.CKEDITOR_VERSION)throw new l("ckeditor-duplicated-modules",null);m.CKEDITOR_VERSION=h;const g=Symbol("listeningTo"),f=Symbol("emitterId"),p={on(e,t,i={}){this.listenTo(this,e,t,i)},once(e,t,i){let n=!1;this.listenTo(this,e,(function(e,...i){n||(n=!0,e.off(),t.call(this,e,...i))}),i)},off(e,t){this.stopListening(this,e,t)},listenTo(e,t,i,n={}){let s,o;this[g]||(this[g]={});const r=this[g];b(e)||w(e);const a=b(e);(s=r[a])||(s=r[a]={emitter:e,callbacks:{}}),(o=s.callbacks[t])||(o=s.callbacks[t]=[]),o.push(i),function(e,t,i,n,s){t._addEventListener?t._addEventListener(i,n,s):e._addEventListener.call(t,i,n,s)}(this,e,t,i,n)},stopListening(e,t,i){const n=this[g];let s=e&&b(e);const o=n&&s&&n[s],r=o&&t&&o.callbacks[t];if(!(!n||e&&!o||t&&!r))if(i){C(this,e,t,i);-1!==r.indexOf(i)&&(1===r.length?delete o.callbacks[t]:C(this,e,t,i))}else if(r){for(;i=r.pop();)C(this,e,t,i);delete o.callbacks[t]}else if(o){for(t in o.callbacks)this.stopListening(e,t);delete n[s]}else{for(s in n)this.stopListening(n[s].emitter);delete this[g]}},fire(e,...i){try{const n=e instanceof t?e:new t(this,e),s=n.name;let o=y(this,s);if(n.path.push(this),o){const e=[n,...i];o=Array.from(o);for(let t=0;t{this._delegations||(this._delegations=new Map),e.forEach((e=>{const n=this._delegations.get(e);n?n.set(t,i):this._delegations.set(e,new Map([[t,i]]))}))}}},stopDelegating(e,t){if(this._delegations)if(e)if(t){const i=this._delegations.get(e);i&&i.delete(t)}else this._delegations.delete(e);else this._delegations.clear()},_addEventListener(e,t,i){!function(e,t){const i=v(e);if(i[t])return;let n=t,s=null;const o=[];for(;""!==n&&!i[n];)i[n]={callbacks:[],childEvents:[]},o.push(i[n]),s&&i[n].childEvents.push(s),s=n,n=n.substr(0,n.lastIndexOf(":"));if(""!==n){for(const e of o)e.callbacks=i[n].callbacks.slice();i[n].childEvents.push(s)}}(this,e);const n=_(this,e),s={callback:t,priority:r.get(i.priority)};for(const e of n)a(e,s)},_removeEventListener(e,t){const i=_(this,e);for(const e of i)for(let i=0;i-1?y(e,t.substr(0,t.lastIndexOf(":"))):null}function k(e,i,n){for(let[s,o]of e){o?"function"==typeof o&&(o=o(i.name)):o=i.name;const e=new t(i.source,o);e.path=[...i.path],s.fire(e,...n)}}function C(e,t,i,n){t._removeEventListener?t._removeEventListener(i,n):e._removeEventListener.call(t,i,n)}const A=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)};const x="object"==typeof global&&global&&global.Object===Object&&global;var T="object"==typeof self&&self&&self.Object===Object&&self;const E=x||T||Function("return this")();const P=E.Symbol;var S=Object.prototype,I=S.hasOwnProperty,R=S.toString,V=P?P.toStringTag:void 0;const O=function(e){var t=I.call(e,V),i=e[V];try{e[V]=void 0;var n=!0}catch(e){}var s=R.call(e);return n&&(t?e[V]=i:delete e[V]),s};var B=Object.prototype.toString;const M=function(e){return B.call(e)};var N=P?P.toStringTag:void 0;const D=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":N&&N in Object(e)?O(e):M(e)};const z=function(e){if(!A(e))return!1;var t=D(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t};const L=E["__core-js_shared__"];var F=function(){var e=/[^.]+$/.exec(L&&L.keys&&L.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();const H=function(e){return!!F&&F in e};var j=Function.prototype.toString;const W=function(e){if(null!=e){try{return j.call(e)}catch(e){}try{return e+""}catch(e){}}return""};var U=/^\[object .+?Constructor\]$/,q=Function.prototype,$=Object.prototype,K=q.toString,G=$.hasOwnProperty,J=RegExp("^"+K.call(G).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");const Y=function(e){return!(!A(e)||H(e))&&(z(e)?J:U).test(W(e))};const Q=function(e,t){return null==e?void 0:e[t]};const Z=function(e,t){var i=Q(e,t);return Y(i)?i:void 0};const X=function(){try{var e=Z(Object,"defineProperty");return e({},"",{}),e}catch(e){}}();const ee=function(e,t,i){"__proto__"==t&&X?X(e,t,{configurable:!0,enumerable:!0,value:i,writable:!0}):e[t]=i};const te=function(e,t){return e===t||e!=e&&t!=t};var ie=Object.prototype.hasOwnProperty;const ne=function(e,t,i){var n=e[t];ie.call(e,t)&&te(n,i)&&(void 0!==i||t in e)||ee(e,t,i)};const se=function(e,t,i,n){var s=!i;i||(i={});for(var o=-1,r=t.length;++o0){if(++t>=800)return arguments[0]}else t=0;return e.apply(void 0,arguments)}};const me=he(de);const ge=function(e,t){return me(le(e,t,oe),e+"")};const fe=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991};const pe=function(e){return null!=e&&fe(e.length)&&!z(e)};var we=/^(?:0|[1-9]\d*)$/;const be=function(e,t){var i=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==i||"symbol"!=i&&we.test(e))&&e>-1&&e%1==0&&e1?i[s-1]:void 0,r=s>2?i[2]:void 0;for(o=e.length>3&&"function"==typeof o?(s--,o):void 0,r&&ve(i[0],i[1],r)&&(o=s<3?void 0:o,s=1),t=Object(t);++n{this.set(t,e[t])}),this);ot(this);const i=this[Ze];if(e in this&&!i.has(e))throw new l("observable-set-cannot-override",this);Object.defineProperty(this,e,{enumerable:!0,configurable:!0,get:()=>i.get(e),set(t){const n=i.get(e);let s=this.fire("set:"+e,e,t,n);void 0===s&&(s=t),n===s&&i.has(e)||(i.set(e,s),this.fire("change:"+e,e,s,n))}}),this[e]=t},bind(...e){if(!e.length||!lt(e))throw new l("observable-bind-wrong-properties",this);if(new Set(e).size!==e.length)throw new l("observable-bind-duplicate-properties",this);ot(this);const t=this[et];e.forEach((e=>{if(t.has(e))throw new l("observable-bind-rebind",this)}));const i=new Map;return e.forEach((e=>{const n={property:e,to:[]};t.set(e,n),i.set(e,n)})),{to:rt,toMany:at,_observable:this,_bindProperties:e,_to:[],_bindings:i}},unbind(...e){if(!this[Ze])return;const t=this[et],i=this[Xe];if(e.length){if(!lt(e))throw new l("observable-unbind-wrong-properties",this);e.forEach((e=>{const n=t.get(e);if(!n)return;let s,o,r,a;n.to.forEach((e=>{s=e[0],o=e[1],r=i.get(s),a=r[o],a.delete(n),a.size||delete r[o],Object.keys(r).length||(i.delete(s),this.stopListening(s,"change"))})),t.delete(e)}))}else i.forEach(((e,t)=>{this.stopListening(t,"change")})),i.clear(),t.clear()},decorate(e){const t=this[e];if(!t)throw new l("observablemixin-cannot-decorate-undefined",this,{object:this,methodName:e});this.on(e,((e,i)=>{e.return=t.apply(this,i)})),this[e]=function(...t){return this.fire(e,t)},this[e][it]=t,this[tt]||(this[tt]=[]),this[tt].push(e)}};Qe(nt,p),nt.stopListening=function(e,t,i){if(!e&&this[tt]){for(const e of this[tt])this[e]=this[e][it];delete this[tt]}p.stopListening.call(this,e,t,i)};const st=nt;function ot(e){e[Ze]||(Object.defineProperty(e,Ze,{value:new Map}),Object.defineProperty(e,Xe,{value:new Map}),Object.defineProperty(e,et,{value:new Map}))}function rt(...e){const t=function(...e){if(!e.length)throw new l("observable-bind-to-parse-error",null);const t={to:[]};let i;"function"==typeof e[e.length-1]&&(t.callback=e.pop());return e.forEach((e=>{if("string"==typeof e)i.properties.push(e);else{if("object"!=typeof e)throw new l("observable-bind-to-parse-error",null);i={observable:e,properties:[]},t.to.push(i)}})),t}(...e),i=Array.from(this._bindings.keys()),n=i.length;if(!t.callback&&t.to.length>1)throw new l("observable-bind-to-no-callback",this);if(n>1&&t.callback)throw new l("observable-bind-to-extra-callback",this);var s;t.to.forEach((e=>{if(e.properties.length&&e.properties.length!==n)throw new l("observable-bind-to-properties-length",this);e.properties.length||(e.properties=this._bindProperties)})),this._to=t.to,t.callback&&(this._bindings.get(i[0]).callback=t.callback),s=this._observable,this._to.forEach((e=>{const t=s[Xe];let i;t.get(e.observable)||s.listenTo(e.observable,"change",((n,o)=>{i=t.get(e.observable)[o],i&&i.forEach((e=>{ct(s,e.property)}))}))})),function(e){let t;e._bindings.forEach(((i,n)=>{e._to.forEach((s=>{t=s.properties[i.callback?0:e._bindProperties.indexOf(n)],i.to.push([s.observable,t]),function(e,t,i,n){const s=e[Xe],o=s.get(i),r=o||{};r[n]||(r[n]=new Set);r[n].add(t),o||s.set(i,r)}(e._observable,i,s.observable,t)}))}))}(this),this._bindProperties.forEach((e=>{ct(this._observable,e)}))}function at(e,t,i){if(this._bindings.size>1)throw new l("observable-bind-to-many-not-one-binding",this);this.to(...function(e,t){const i=e.map((e=>[e,t]));return Array.prototype.concat.apply([],i)}(e,t),i)}function lt(e){return e.every((e=>"string"==typeof e))}function ct(e,t){const i=e[et].get(t);let n;i.callback?n=i.callback.apply(e,i.to.map((e=>e[0][e[1]]))):(n=i.to[0],n=n[0][n[1]]),Object.prototype.hasOwnProperty.call(e,t)?e[t]=n:e.set(t,n)}function dt(e,...t){t.forEach((t=>{Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t)).forEach((i=>{if(i in e.prototype)return;const n=Object.getOwnPropertyDescriptor(t,i);n.enumerable=!1,Object.defineProperty(e.prototype,i,n)}))}))}class ut{constructor(e){this.editor=e,this.set("isEnabled",!0),this._disableStack=new Set}forceDisabled(e){this._disableStack.add(e),1==this._disableStack.size&&(this.on("set:isEnabled",ht,{priority:"highest"}),this.isEnabled=!1)}clearForceDisabled(e){this._disableStack.delete(e),0==this._disableStack.size&&(this.off("set:isEnabled",ht),this.isEnabled=!0)}destroy(){this.stopListening()}static get isContextPlugin(){return!1}}function ht(e){e.return=!1,e.stop()}dt(ut,st);class mt{constructor(e){this.editor=e,this.set("value",void 0),this.set("isEnabled",!1),this.affectsData=!0,this._disableStack=new Set,this.decorate("execute"),this.listenTo(this.editor.model.document,"change",(()=>{this.refresh()})),this.on("execute",(e=>{this.isEnabled||e.stop()}),{priority:"high"}),this.listenTo(e,"change:isReadOnly",((e,t,i)=>{i&&this.affectsData?this.forceDisabled("readOnlyMode"):this.clearForceDisabled("readOnlyMode")}))}refresh(){this.isEnabled=!0}forceDisabled(e){this._disableStack.add(e),1==this._disableStack.size&&(this.on("set:isEnabled",gt,{priority:"highest"}),this.isEnabled=!1)}clearForceDisabled(e){this._disableStack.delete(e),0==this._disableStack.size&&(this.off("set:isEnabled",gt),this.refresh())}execute(){}destroy(){this.stopListening()}}function gt(e){e.return=!1,e.stop()}dt(mt,st);class ft extends mt{constructor(e){super(e),this._childCommandsDefinitions=[]}refresh(){}execute(...e){const t=this._getFirstEnabledCommand();return!!t&&t.execute(e)}registerChildCommand(e,t={priority:"normal"}){a(this._childCommandsDefinitions,{command:e,priority:t.priority}),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}}const pt=function(e,t){return function(i){return e(t(i))}};const wt=pt(Object.getPrototypeOf,Object);var bt=Function.prototype,vt=Object.prototype,_t=bt.toString,yt=vt.hasOwnProperty,kt=_t.call(Object);const Ct=function(e){if(!ke(e)||"[object Object]"!=D(e))return!1;var t=wt(e);if(null===t)return!0;var i=yt.call(t,"constructor")&&t.constructor;return"function"==typeof i&&i instanceof i&&_t.call(i)==kt};const At=function(){this.__data__=[],this.size=0};const xt=function(e,t){for(var i=e.length;i--;)if(te(e[i][0],t))return i;return-1};var Tt=Array.prototype.splice;const Et=function(e){var t=this.__data__,i=xt(t,e);return!(i<0)&&(i==t.length-1?t.pop():Tt.call(t,i,1),--this.size,!0)};const Pt=function(e){var t=this.__data__,i=xt(t,e);return i<0?void 0:t[i][1]};const St=function(e){return xt(this.__data__,e)>-1};const It=function(e,t){var i=this.__data__,n=xt(i,e);return n<0?(++this.size,i.push([e,t])):i[n][1]=t,this};function Rt(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t{this._setToTarget(e,n,t[n],i)}))}}function Cn(e){return _n(e,An)}function An(e){return yn(e)?e:void 0}function xn(e){return!(!e||!e[Symbol.iterator])}class Tn{constructor(e={},t={}){const i=xn(e);if(i||(t=e),this._items=[],this._itemMap=new Map,this._idProperty=t.idProperty||"id",this._bindToExternalToInternalMap=new WeakMap,this._bindToInternalToExternalMap=new WeakMap,this._skippedIndexesFromExternal=[],i)for(const t of e)this._items.push(t),this._itemMap.set(this._getItemIdBeforeAdding(t),t)}get length(){return this._items.length}get first(){return this._items[0]||null}get last(){return this._items[this.length-1]||null}add(e,t){return this.addMany([e],t)}addMany(e,t){if(void 0===t)t=this._items.length;else if(t>this._items.length||t<0)throw new l("collection-add-item-invalid-index",this);for(let i=0;i{this._setUpBindToBinding((t=>new e(t)))},using:e=>{"function"==typeof e?this._setUpBindToBinding((t=>e(t))):this._setUpBindToBinding((t=>t[e]))}}}_setUpBindToBinding(e){const t=this._bindToCollection,i=(i,n,s)=>{const o=t._bindToCollection==this,r=t._bindToInternalToExternalMap.get(n);if(o&&r)this._bindToExternalToInternalMap.set(n,r),this._bindToInternalToExternalMap.set(r,n);else{const i=e(n);if(!i)return void this._skippedIndexesFromExternal.push(s);let o=s;for(const e of this._skippedIndexesFromExternal)s>e&&o--;for(const e of t._skippedIndexesFromExternal)o>=e&&o++;this._bindToExternalToInternalMap.set(n,i),this._bindToInternalToExternalMap.set(i,n),this.add(i,o);for(let e=0;e{const n=this._bindToExternalToInternalMap.get(t);n&&this.remove(n),this._skippedIndexesFromExternal=this._skippedIndexesFromExternal.reduce(((e,t)=>(it&&e.push(t),e)),[])}))}_getItemIdBeforeAdding(e){const t=this._idProperty;let i;if(t in e){if(i=e[t],"string"!=typeof i)throw new l("collection-add-invalid-id",this);if(this.get(i))throw new l("collection-add-item-already-exists",this)}else e[t]=i=o();return i}_remove(e){let t,i,n,s=!1;const o=this._idProperty;if("string"==typeof e?(i=e,n=this._itemMap.get(i),s=!n,n&&(t=this._items.indexOf(n))):"number"==typeof e?(t=e,n=this._items[t],s=!n,n&&(i=n[o])):(n=e,i=n[o],t=this._items.indexOf(n),s=-1==t||!this._itemMap.get(i)),s)throw new l("collection-remove-404",this);this._items.splice(t,1),this._itemMap.delete(i);const r=this._bindToInternalToExternalMap.get(n);return this._bindToInternalToExternalMap.delete(n),this._bindToExternalToInternalMap.delete(r),this.fire("remove",n,t),[n,t]}[Symbol.iterator](){return this._items[Symbol.iterator]()}}dt(Tn,p);class En{constructor(e,t=[],i=[]){this._context=e,this._plugins=new Map,this._availablePlugins=new Map;for(const e of t)e.pluginName&&this._availablePlugins.set(e.pluginName,e);this._contextPlugins=new Map;for(const[e,t]of i)this._contextPlugins.set(e,t),this._contextPlugins.set(t,e),e.pluginName&&this._availablePlugins.set(e.pluginName,e)}*[Symbol.iterator](){for(const e of this._plugins)"function"==typeof e[0]&&(yield e)}get(e){const t=this._plugins.get(e);if(!t){let t=e;throw"function"==typeof e&&(t=e.pluginName||e.name),new l("plugincollection-plugin-not-loaded",this._context,{plugin:t})}return t}has(e){return this._plugins.has(e)}init(e,t=[],i=[]){const n=this,s=this._context;!function e(t,i=new Set){t.forEach((t=>{a(t)&&(i.has(t)||(i.add(t),t.pluginName&&!n._availablePlugins.has(t.pluginName)&&n._availablePlugins.set(t.pluginName,t),t.requires&&e(t.requires,i)))}))}(e),h(e);const o=[...function e(t,i=new Set){return t.map((e=>a(e)?e:n._availablePlugins.get(e))).reduce(((t,n)=>i.has(n)?t:(i.add(n),n.requires&&(h(n.requires,n),e(n.requires,i).forEach((e=>t.add(e)))),t.add(n))),new Set)}(e.filter((e=>!d(e,t))))];!function(e,t){for(const i of t){if("function"!=typeof i)throw new l("plugincollection-replace-plugin-invalid-type",null,{pluginItem:i});const t=i.pluginName;if(!t)throw new l("plugincollection-replace-plugin-missing-name",null,{pluginItem:i});if(i.requires&&i.requires.length)throw new l("plugincollection-plugin-for-replacing-cannot-have-dependencies",null,{pluginName:t});const s=n._availablePlugins.get(t);if(!s)throw new l("plugincollection-plugin-for-replacing-not-exist",null,{pluginName:t});const o=e.indexOf(s);if(-1===o){if(n._contextPlugins.has(s))return;throw new l("plugincollection-plugin-for-replacing-not-loaded",null,{pluginName:t})}if(s.requires&&s.requires.length)throw new l("plugincollection-replaced-plugin-cannot-have-dependencies",null,{pluginName:t});e.splice(o,1,i),n._availablePlugins.set(t,i)}}(o,i);const r=function(e){return e.map((e=>{const t=n._contextPlugins.get(e)||new e(s);return n._add(e,t),t}))}(o);return m(r,"init").then((()=>m(r,"afterInit"))).then((()=>r));function a(e){return"function"==typeof e}function c(e){return a(e)&&e.isContextPlugin}function d(e,t){return t.some((t=>t===e||(u(e)===t||u(t)===e)))}function u(e){return a(e)?e.pluginName||e.name:e}function h(e,i=null){e.map((e=>a(e)?e:n._availablePlugins.get(e)||e)).forEach((e=>{!function(e,t){if(a(e))return;if(t)throw new l("plugincollection-soft-required",s,{missingPlugin:e,requiredBy:u(t)});throw new l("plugincollection-plugin-not-found",s,{plugin:e})}(e,i),function(e,t){if(!c(t))return;if(c(e))return;throw new l("plugincollection-context-required",s,{plugin:u(e),requiredBy:u(t)})}(e,i),function(e,i){if(!i)return;if(!d(e,t))return;throw new l("plugincollection-required",s,{plugin:u(e),requiredBy:u(i)})}(e,i)}))}function m(e,t){return e.reduce(((e,i)=>i[t]?n._contextPlugins.has(i)?e:e.then(i[t].bind(i)):e),Promise.resolve())}}destroy(){const e=[];for(const[,t]of this)"function"!=typeof t.destroy||this._contextPlugins.has(t)||e.push(t.destroy());return Promise.all(e)}_add(e,t){this._plugins.set(e,t);const i=e.pluginName;if(i){if(this._plugins.has(i))throw new l("plugincollection-plugin-name-conflict",null,{pluginName:i,plugin1:this._plugins.get(i).constructor,plugin2:e});this._plugins.set(i,t)}}}function Pn(e){return Array.isArray(e)?e:[e]}function Sn(e,t,i=1){if("number"!=typeof i)throw new l("translation-service-quantity-not-a-number",null,{quantity:i});const n=Object.keys(window.CKEDITOR_TRANSLATIONS).length;1===n&&(e=Object.keys(window.CKEDITOR_TRANSLATIONS)[0]);const s=t.id||t.string;if(0===n||!function(e,t){return!!window.CKEDITOR_TRANSLATIONS[e]&&!!window.CKEDITOR_TRANSLATIONS[e].dictionary[t]}(e,s))return 1!==i?t.plural:t.string;const o=window.CKEDITOR_TRANSLATIONS[e].dictionary,r=window.CKEDITOR_TRANSLATIONS[e].getPluralForm||(e=>1===e?0:1);if("string"==typeof o[s])return o[s];const a=Number(r(i));return o[s][a]}dt(En,p),window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={});const In=["ar","ara","fa","per","fas","he","heb","ku","kur","ug","uig"];function Rn(e){return In.includes(e)?"rtl":"ltr"}class Vn{constructor(e={}){this.uiLanguage=e.uiLanguage||"en",this.contentLanguage=e.contentLanguage||this.uiLanguage,this.uiLanguageDirection=Rn(this.uiLanguage),this.contentLanguageDirection=Rn(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=Pn(t),"string"==typeof e&&(e={string:e});const i=!!e.plural?t[0]:1;return function(e,t){return e.replace(/%(\d+)/g,((e,i)=>ie.destroy()))).then((()=>this.plugins.destroy()))}_addEditor(e,t){if(this._contextOwner)throw new l("context-addeditor-private-context");this.editors.add(e),t&&(this._contextOwner=e)}_removeEditor(e){return this.editors.has(e)&&this.editors.remove(e),this._contextOwner===e?this.destroy():Promise.resolve()}_getEditorConfig(){const e={};for(const t of this.config.names())["plugins","removePlugins","extraPlugins"].includes(t)||(e[t]=this.config.get(t));return e}static create(e){return new Promise((t=>{const i=new this(e);t(i.initPlugins().then((()=>i)))}))}}class Bn{constructor(e){this.context=e}destroy(){this.stopListening()}static get isContextPlugin(){return!0}}function Mn(e,t){const i=Math.min(e.length,t.length);for(let n=0;ne.data.length)throw new l("view-textproxy-wrong-offsetintext",this);if(i<0||t+i>e.data.length)throw new l("view-textproxy-wrong-length",this);this.data=e.data.substring(t,t+i),this.offsetInText=t}get offsetSize(){return this.data.length}get isPartial(){return this.data.length!==this.textNode.data.length}get parent(){return this.textNode.parent}get root(){return this.textNode.root}get document(){return this.textNode.document}is(e){return"$textProxy"===e||"view:$textProxy"===e||"textProxy"===e||"view:textProxy"===e}getAncestors(e={includeSelf:!1,parentFirst:!1}){const t=[];let i=e.includeSelf?this.textNode:this.parent;for(;null!==i;)t[e.parentFirst?"push":"unshift"](i),i=i.parent;return t}}function Fn(e){return xn(e)?new Map(e):function(e){const t=new Map;for(const i in e)t.set(i,e[i]);return t}(e)}class Hn{constructor(...e){this._patterns=[],this.add(...e)}add(...e){for(let t of e)("string"==typeof t||t instanceof RegExp)&&(t={name:t}),this._patterns.push(t)}match(...e){for(const t of e)for(const e of this._patterns){const i=jn(t,e);if(i)return{element:t,pattern:e,match:i}}return null}matchAll(...e){const t=[];for(const i of e)for(const e of this._patterns){const n=jn(i,e);n&&t.push({element:i,pattern:e,match:n})}return t.length>0?t:null}getElementName(){if(1!==this._patterns.length)return null;const e=this._patterns[0],t=e.name;return"function"==typeof e||!t||t instanceof RegExp?null:t}}function jn(e,t){if("function"==typeof t)return t(e);const i={};return t.name&&(i.name=function(e,t){if(e instanceof RegExp)return!!t.match(e);return e===t}(t.name,e.name),!i.name)||t.attributes&&(i.attributes=function(e,t){const i=new Set(t.getAttributeKeys());Ct(e)?(void 0!==e.style&&c("matcher-pattern-deprecated-attributes-style-key",e),void 0!==e.class&&c("matcher-pattern-deprecated-attributes-class-key",e)):(i.delete("style"),i.delete("class"));return Wn(e,i,(e=>t.getAttribute(e)))}(t.attributes,e),!i.attributes)?null:!(t.classes&&(i.classes=function(e,t){return Wn(e,t.getClassNames())}(t.classes,e),!i.classes))&&(!(t.styles&&(i.styles=function(e,t){return Wn(e,t.getStyleNames(!0),(e=>t.getStyle(e)))}(t.styles,e),!i.styles))&&i)}function Wn(e,t,i){const n=function(e){if(Array.isArray(e))return e.map((e=>Ct(e)?(void 0!==e.key&&void 0!==e.value||c("matcher-pattern-missing-key-or-value",e),[e.key,e.value]):[e,!0]));if(Ct(e))return Object.entries(e);return[[e,!0]]}(e),s=Array.from(t),o=[];return n.forEach((([e,t])=>{s.forEach((n=>{(function(e,t){return!0===e||e===t||e instanceof RegExp&&t.match(e)})(e,n)&&function(e,t,i){if(!0===e)return!0;const n=i(t);return e===n||e instanceof RegExp&&!!String(n).match(e)}(t,n,i)&&o.push(n)}))})),!n.length||o.lengths?0:s+t),(i=i>s?s:i)<0&&(i+=s),s=t>i?0:i-t>>>0,t>>>=0;for(var o=Array(s);++nt===e));return Array.isArray(t)}set(e,t){if(A(e))for(const[t,i]of Object.entries(e))this._styleProcessor.toNormalizedForm(t,i,this._styles);else this._styleProcessor.toNormalizedForm(e,t,this._styles)}remove(e){const t=Ts(e);hs(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]&&!A(this._styles[e]))return this._styles[e];const t=this._styleProcessor.getReducedForm(e,this._styles).find((([t])=>t===e));return Array.isArray(t)?t[1]:void 0}getStyleNames(e=!1){if(this.isEmpty)return[];if(e)return this._styleProcessor.getStyleNames(this._styles);return this._getStylesEntries().map((([e])=>e))}clear(){this._styles={}}_getStylesEntries(){const e=[],t=Object.keys(this._styles);for(const i of t)e.push(...this._styleProcessor.getReducedForm(i,this._styles));return e}_cleanEmptyObjectsOnPath(e){const t=e.split(".");if(!(t.length>1))return;const i=t.splice(0,t.length-1).join("."),n=ms(this._styles,i);if(!n)return;!Array.from(Object.keys(n)).length&&this.remove(i)}}class xs{constructor(){this._normalizers=new Map,this._extractors=new Map,this._reducers=new Map,this._consumables=new Map}toNormalizedForm(e,t,i){if(A(t))Es(i,Ts(e),t);else if(this._normalizers.has(e)){const n=this._normalizers.get(e),{path:s,value:o}=n(t);Es(i,s,o)}else Es(i,e,t)}getNormalized(e,t){if(!e)return ys({},t);if(void 0!==t[e])return t[e];if(this._extractors.has(e)){const i=this._extractors.get(e);if("string"==typeof i)return ms(t,i);const n=i(e,t);if(n)return n}return ms(t,Ts(e))}getReducedForm(e,t){const i=this.getNormalized(e,t);if(void 0===i)return[];if(this._reducers.has(e)){return this._reducers.get(e)(i)}return[[e,i]]}getStyleNames(e){const t=Array.from(this._consumables.keys()).filter((t=>{const i=this.getNormalized(t,e);return i&&"object"==typeof i?Object.keys(i).length:i})),i=new Set([...t,...Object.keys(e)]);return Array.from(i.values())}getRelatedStyles(e){return this._consumables.get(e)||[]}setNormalizer(e,t){this._normalizers.set(e,t)}setExtractor(e,t){this._extractors.set(e,t)}setReducer(e,t){this._reducers.set(e,t)}setStyleRelation(e,t){this._mapStyleNames(e,t);for(const i of t)this._mapStyleNames(i,[e])}_mapStyleNames(e,t){this._consumables.has(e)||this._consumables.set(e,[]),this._consumables.get(e).push(...t)}}function Ts(e){return e.replace("-",".")}function Es(e,t,i){let n=i;A(i)&&(n=ys({},ms(e,t),i)),Cs(e,t,n)}class Ps extends Dn{constructor(e,t,i,n){if(super(e),this.name=t,this._attrs=function(e){e=Fn(e);for(const[t,i]of e)null===i?e.delete(t):"string"!=typeof i&&e.set(t,String(i));return e}(i),this._children=[],n&&this._insertChild(0,n),this._classes=new Set,this._attrs.has("class")){const e=this._attrs.get("class");Ss(this._classes,e),this._attrs.delete("class")}this._styles=new As(this.document.stylesProcessor),this._attrs.has("style")&&(this._styles.setTo(this._attrs.get("style")),this._attrs.delete("style")),this._customProperties=new Map,this._unsafeAttributesToRender=[]}get childCount(){return this._children.length}get isEmpty(){return 0===this._children.length}is(e,t=null){return t?t===this.name&&("element"===e||"view:element"===e):"element"===e||"view:element"===e||"node"===e||"view:node"===e}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 Ps))return!1;if(this===e)return!0;if(this.name!=e.name)return!1;if(this._attrs.size!==e._attrs.size||this._classes.size!==e._classes.size||this._styles.size!==e._styles.size)return!1;for(const[t,i]of this._attrs)if(!e._attrs.has(t)||e._attrs.get(t)!==i)return!1;for(const t of this._classes)if(!e._classes.has(t))return!1;for(const t of this._styles.getStyleNames())if(!e._styles.has(t)||e._styles.getAsString(t)!==this._styles.getAsString(t))return!1;return!0}hasClass(...e){for(const t of e)if(!this._classes.has(t))return!1;return!0}getClassNames(){return this._classes.keys()}getStyle(e){return this._styles.getAsString(e)}getNormalizedStyle(e){return this._styles.getNormalized(e)}getStyleNames(e=!1){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 Hn(...e);let i=this.parent;for(;i;){if(t.match(i))return i;i=i.parent}return null}getCustomProperty(e){return this._customProperties.get(e)}*getCustomProperties(){yield*this._customProperties.entries()}getIdentity(){const e=Array.from(this._classes).sort().join(","),t=this._styles.toString(),i=Array.from(this._attrs).map((e=>`${e[0]}="${e[1]}"`)).sort().join(" ");return this.name+(""==e?"":` class="${e}"`)+(t?` style="${t}"`:"")+(""==i?"":` ${i}`)}shouldRenderUnsafeAttribute(e){return this._unsafeAttributesToRender.includes(e)}_clone(e=!1){const t=[];if(e)for(const i of this.getChildren())t.push(i._clone(e));const i=new this.constructor(this.document,this.name,this._attrs,t);return i._classes=new Set(this._classes),i._styles.set(this._styles.getNormalized()),i._customProperties=new Map(this._customProperties),i.getFillerOffset=this.getFillerOffset,i}_appendChild(e){return this._insertChild(this.childCount,e)}_insertChild(e,t){this._fireChange("children",this);let i=0;const n=function(e,t){if("string"==typeof t)return[new zn(e,t)];xn(t)||(t=[t]);return Array.from(t).map((t=>"string"==typeof t?new zn(e,t):t instanceof Ln?new zn(e,t.data):t))}(this.document,t);for(const t of n)null!==t.parent&&t._remove(),t.parent=this,t.document=this.document,this._children.splice(e,0,t),e++,i++;return i}_removeChildren(e,t=1){this._fireChange("children",this);for(let i=e;i0&&(this._classes.clear(),!0):"style"==e?!this._styles.isEmpty&&(this._styles.clear(),!0):this._attrs.delete(e)}_addClass(e){this._fireChange("attributes",this);for(const t of Pn(e))this._classes.add(t)}_removeClass(e){this._fireChange("attributes",this);for(const t of Pn(e))this._classes.delete(t)}_setStyle(e,t){this._fireChange("attributes",this),this._styles.set(e,t)}_removeStyle(e){this._fireChange("attributes",this);for(const t of Pn(e))this._styles.remove(t)}_setCustomProperty(e,t){this._customProperties.set(e,t)}_removeCustomProperty(e){return this._customProperties.delete(e)}}function Ss(e,t){const i=t.split(/\s+/);e.clear(),i.forEach((t=>e.add(t)))}class Is extends Ps{constructor(e,t,i,n){super(e,t,i,n),this.getFillerOffset=Rs}is(e,t=null){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}}function Rs(){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}class Vs extends Is{constructor(e,t,i,n){super(e,t,i,n),this.set("isReadOnly",!1),this.set("isFocused",!1),this.bind("isReadOnly").to(e),this.bind("isFocused").to(e,"isFocused",(t=>t&&e.selection.editableElement==this)),this.listenTo(e.selection,"change",(()=>{this.isFocused=e.isFocused&&e.selection.editableElement==this}))}is(e,t=null){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}destroy(){this.stopListening()}}dt(Vs,st);const Os=Symbol("rootName");class Bs extends Vs{constructor(e,t){super(e,t),this.rootName="main"}is(e,t=null){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}get rootName(){return this.getCustomProperty(Os)}set rootName(e){this._setCustomProperty(Os,e)}set _name(e){this.name=e}}class Ms{constructor(e={}){if(!e.boundaries&&!e.startPosition)throw new l("view-tree-walker-no-start-position",null);if(e.direction&&"forward"!=e.direction&&"backward"!=e.direction)throw new l("view-tree-walker-unknown-direction",e.startPosition,{direction:e.direction});this.boundaries=e.boundaries||null,e.startPosition?this.position=Ns._createAt(e.startPosition):this.position=Ns._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}skip(e){let t,i,n;do{n=this.position,({done:t,value:i}=this.next())}while(!t&&e(i));t||(this.position=n)}next(){return"forward"==this.direction?this._next():this._previous()}_next(){let e=this.position.clone();const t=this.position,i=e.parent;if(null===i.parent&&e.offset===i.childCount)return{done:!0};if(i===this._boundaryEndParent&&e.offset==this.boundaries.end.offset)return{done:!0};let n;if(i instanceof zn){if(e.isAtEnd)return this.position=Ns._createAfter(i),this._next();n=i.data[e.offset]}else n=i.getChild(e.offset);if(n instanceof Ps)return this.shallow?e.offset++:e=new Ns(n,0),this.position=e,this._formatReturnValue("elementStart",n,t,e,1);if(n instanceof zn){if(this.singleCharacters)return e=new Ns(n,0),this.position=e,this._next();{let i,s=n.data.length;return n==this._boundaryEndParent?(s=this.boundaries.end.offset,i=new Ln(n,0,s),e=Ns._createAfter(i)):(i=new Ln(n,0,n.data.length),e.offset++),this.position=e,this._formatReturnValue("text",i,t,e,s)}}if("string"==typeof n){let n;if(this.singleCharacters)n=1;else{n=(i===this._boundaryEndParent?this.boundaries.end.offset:i.data.length)-e.offset}const s=new Ln(i,e.offset,n);return e.offset+=n,this.position=e,this._formatReturnValue("text",s,t,e,n)}return e=Ns._createAfter(i),this.position=e,this.ignoreElementEnd?this._next():this._formatReturnValue("elementEnd",i,t,e)}_previous(){let e=this.position.clone();const t=this.position,i=e.parent;if(null===i.parent&&0===e.offset)return{done:!0};if(i==this._boundaryStartParent&&e.offset==this.boundaries.start.offset)return{done:!0};let n;if(i instanceof zn){if(e.isAtStart)return this.position=Ns._createBefore(i),this._previous();n=i.data[e.offset-1]}else n=i.getChild(e.offset-1);if(n instanceof Ps)return this.shallow?(e.offset--,this.position=e,this._formatReturnValue("elementStart",n,t,e,1)):(e=new Ns(n,n.childCount),this.position=e,this.ignoreElementEnd?this._previous():this._formatReturnValue("elementEnd",n,t,e));if(n instanceof zn){if(this.singleCharacters)return e=new Ns(n,n.data.length),this.position=e,this._previous();{let i,s=n.data.length;if(n==this._boundaryStartParent){const t=this.boundaries.start.offset;i=new Ln(n,t,n.data.length-t),s=i.data.length,e=Ns._createBefore(i)}else i=new Ln(n,0,n.data.length),e.offset--;return this.position=e,this._formatReturnValue("text",i,t,e,s)}}if("string"==typeof n){let n;if(this.singleCharacters)n=1;else{const t=i===this._boundaryStartParent?this.boundaries.start.offset:0;n=e.offset-t}e.offset-=n;const s=new Ln(i,e.offset,n);return this.position=e,this._formatReturnValue("text",s,t,e,n)}return e=Ns._createBefore(i),this.position=e,this._formatReturnValue("elementStart",i,t,e,1)}_formatReturnValue(e,t,i,n,s){return t instanceof Ln&&(t.offsetInText+t.data.length==t.textNode.data.length&&("forward"!=this.direction||this.boundaries&&this.boundaries.end.isEqual(this.position)?i=Ns._createAfter(t.textNode):(n=Ns._createAfter(t.textNode),this.position=n)),0===t.offsetInText&&("backward"!=this.direction||this.boundaries&&this.boundaries.start.isEqual(this.position)?i=Ns._createBefore(t.textNode):(n=Ns._createBefore(t.textNode),this.position=n))),{done:!1,value:{type:e,item:t,previousPosition:i,nextPosition:n,length:s}}}}class Ns{constructor(e,t){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 Vs);){if(!e.parent)return null;e=e.parent}return e}getShiftedBy(e){const t=Ns._createAt(this),i=t.offset+e;return t.offset=i<0?0:i,t}getLastMatchingPosition(e,t={}){t.startPosition=this;const i=new Ms(t);return i.skip(e),i.position}getAncestors(){return this.parent.is("documentFragment")?[this.parent]:this.parent.getAncestors({includeSelf:!0})}getCommonAncestor(e){const t=this.getAncestors(),i=e.getAncestors();let n=0;for(;t[n]==i[n]&&t[n];)n++;return 0===n?null:t[n-1]}is(e){return"position"===e||"view:position"===e}isEqual(e){return this.parent==e.parent&&this.offset==e.offset}isBefore(e){return"before"==this.compareWith(e)}isAfter(e){return"after"==this.compareWith(e)}compareWith(e){if(this.root!==e.root)return"different";if(this.isEqual(e))return"same";const t=this.parent.is("node")?this.parent.getPath():[],i=e.parent.is("node")?e.parent.getPath():[];t.push(this.offset),i.push(e.offset);const n=Mn(t,i);switch(n){case"prefix":return"before";case"extension":return"after";default:return t[n]0?new this(i,n):new this(n,i)}static _createIn(e){return this._createFromParentsAndOffsets(e,0,e,e.childCount)}static _createOn(e){const t=e.is("$textProxy")?e.offsetSize:1;return this._createFromPositionAndShift(Ns._createBefore(e),t)}}function zs(e){return!(!e.item.is("attributeElement")&&!e.item.is("uiElement"))}function Ls(e){let t=0;for(const i of e)t++;return t}class Fs{constructor(e=null,t,i){this._ranges=[],this._lastRangeBackward=!1,this._isFake=!1,this._fakeSelectionLabel="",this.setTo(e,t,i)}get isFake(){return this._isFake}get fakeSelectionLabel(){return this._fakeSelectionLabel}get anchor(){if(!this._ranges.length)return null;const e=this._ranges[this._ranges.length-1];return(this._lastRangeBackward?e.end:e.start).clone()}get focus(){if(!this._ranges.length)return null;const e=this._ranges[this._ranges.length-1];return(this._lastRangeBackward?e.start:e.end).clone()}get isCollapsed(){return 1===this.rangeCount&&this._ranges[0].isCollapsed}get rangeCount(){return this._ranges.length}get isBackward(){return!this.isCollapsed&&this._lastRangeBackward}get editableElement(){return this.anchor?this.anchor.editableElement:null}*getRanges(){for(const e of this._ranges)yield e.clone()}getFirstRange(){let e=null;for(const t of this._ranges)e&&!t.start.isBefore(e.start)||(e=t);return e?e.clone():null}getLastRange(){let e=null;for(const t of this._ranges)e&&!t.end.isAfter(e.end)||(e=t);return e?e.clone():null}getFirstPosition(){const e=this.getFirstRange();return e?e.start.clone():null}getLastPosition(){const e=this.getLastRange();return e?e.end.clone():null}isEqual(e){if(this.isFake!=e.isFake)return!1;if(this.isFake&&this.fakeSelectionLabel!=e.fakeSelectionLabel)return!1;if(this.rangeCount!=e.rangeCount)return!1;if(0===this.rangeCount)return!0;if(!this.anchor.isEqual(e.anchor)||!this.focus.isEqual(e.focus))return!1;for(const t of this._ranges){let i=!1;for(const n of e._ranges)if(t.isEqual(n)){i=!0;break}if(!i)return!1}return!0}isSimilar(e){if(this.isBackward!=e.isBackward)return!1;const t=Ls(this.getRanges());if(t!=Ls(e.getRanges()))return!1;if(0==t)return!0;for(let t of this.getRanges()){t=t.getTrimmed();let i=!1;for(let n of e.getRanges())if(n=n.getTrimmed(),t.start.isEqual(n.start)&&t.end.isEqual(n.end)){i=!0;break}if(!i)return!1}return!0}getSelectedElement(){return 1!==this.rangeCount?null:this.getFirstRange().getContainedElement()}setTo(e,t,i){if(null===e)this._setRanges([]),this._setFakeOptions(t);else if(e instanceof Fs||e instanceof Hs)this._setRanges(e.getRanges(),e.isBackward),this._setFakeOptions({fake:e.isFake,label:e.fakeSelectionLabel});else if(e instanceof Ds)this._setRanges([e],t&&t.backward),this._setFakeOptions(t);else if(e instanceof Ns)this._setRanges([new Ds(e)]),this._setFakeOptions(t);else if(e instanceof Dn){const n=!!i&&!!i.backward;let s;if(void 0===t)throw new l("view-selection-setto-required-second-parameter",this);s="in"==t?Ds._createIn(e):"on"==t?Ds._createOn(e):new Ds(Ns._createAt(e,t)),this._setRanges([s],n),this._setFakeOptions(i)}else{if(!xn(e))throw new l("view-selection-setto-not-selectable",this);this._setRanges(e,t&&t.backward),this._setFakeOptions(t)}this.fire("change")}setFocus(e,t){if(null===this.anchor)throw new l("view-selection-setfocus-no-ranges",this);const i=Ns._createAt(e,t);if("same"==i.compareWith(this.focus))return;const n=this.anchor;this._ranges.pop(),"before"==i.compareWith(n)?this._addRange(new Ds(i,n),!0):this._addRange(new Ds(n,i)),this.fire("change")}is(e){return"selection"===e||"view:selection"===e}_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 Ds))throw new l("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 l("view-selection-range-intersects",this,{addedRange:e,intersectingRange:t});this._ranges.push(new Ds(e.start,e.end))}}dt(Fs,p);class Hs{constructor(e=null,t,i){this._selection=new Fs,this._selection.delegate("change").to(this),this._selection.setTo(e,t,i)}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)}is(e){return"selection"===e||"documentSelection"==e||"view:selection"==e||"view:documentSelection"==e}_setTo(e,t,i){this._selection.setTo(e,t,i)}_setFocus(e,t){this._selection.setFocus(e,t)}}dt(Hs,p);class js extends t{constructor(e,t,i){super(e,t),this.startRange=i,this._eventPhase="none",this._currentTarget=null}get eventPhase(){return this._eventPhase}get currentTarget(){return this._currentTarget}}const Ws=Symbol("bubbling contexts"),Us={fire(e,...i){try{const n=e instanceof t?e:new t(this,e),s=Gs(this);if(!s.size)return;if(qs(n,"capturing",this),$s(s,"$capture",n,...i))return n.return;const o=n.startRange||this.selection.getFirstRange(),r=o?o.getContainedElement():null,a=!!r&&Boolean(Ks(s,r));let l=r||function(e){if(!e)return null;const t=e.start.parent,i=e.end.parent,n=t.getPath(),s=i.getPath();return n.length>s.length?t:i}(o);if(qs(n,"atTarget",l),!a){if($s(s,"$text",n,...i))return n.return;qs(n,"bubbling",l)}for(;l;){if(l.is("rootElement")){if($s(s,"$root",n,...i))return n.return}else if(l.is("element")&&$s(s,l.name,n,...i))return n.return;if($s(s,l,n,...i))return n.return;l=l.parent,qs(n,"bubbling",l)}return qs(n,"bubbling",this),$s(s,"$document",n,...i),n.return}catch(e){l.rethrowUnexpectedError(e,this)}},_addEventListener(e,t,i){const n=Pn(i.context||"$document"),s=Gs(this);for(const o of n){let n=s.get(o);n||(n=Object.create(p),s.set(o,n)),this.listenTo(n,e,t,i)}},_removeEventListener(e,t){const i=Gs(this);for(const n of i.values())this.stopListening(n,e,t)}};function qs(e,t,i){e instanceof js&&(e._eventPhase=t,e._currentTarget=i)}function $s(e,t,i,...n){const s="string"==typeof t?e.get(t):Ks(e,t);return!!s&&(s.fire(i,...n),i.stop.called)}function Ks(e,t){for(const[i,n]of e)if("function"==typeof i&&i(t))return n;return null}function Gs(e){return e[Ws]||(e[Ws]=new Map),e[Ws]}class Js{constructor(e){this.selection=new Hs,this.roots=new Tn({idProperty:"rootName"}),this.stylesProcessor=e,this.set("isReadOnly",!1),this.set("isFocused",!1),this.set("isSelecting",!1),this.set("isComposing",!1),this._postFixers=new Set}getRoot(e="main"){return this.roots.get(e)}registerPostFixer(e){this._postFixers.add(e)}destroy(){this.roots.map((e=>e.destroy())),this.stopListening()}_callPostFixers(e){let t=!1;do{for(const i of this._postFixers)if(t=i(e),t)break}while(t)}}dt(Js,Us),dt(Js,st);class Ys extends Ps{constructor(e,t,i,n){super(e,t,i,n),this.getFillerOffset=Qs,this._priority=10,this._id=null,this._clonesGroup=null}get priority(){return this._priority}get id(){return this._id}getElementsWithSameId(){if(null===this.id)throw new l("attribute-element-get-elements-with-same-id-no-id",this);return new Set(this._clonesGroup)}is(e,t=null){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}isSimilar(e){return null!==this.id||null!==e.id?this.id===e.id:super.isSimilar(e)&&this.priority==e.priority}_clone(e){const t=super._clone(e);return t._priority=this._priority,t._id=this._id,t}}function Qs(){if(Zs(this))return null;let e=this.parent;for(;e&&e.is("attributeElement");){if(Zs(e)>1)return null;e=e.parent}return!e||Zs(e)>1?null:this.childCount}function Zs(e){return Array.from(e.getChildren()).filter((e=>!e.is("uiElement"))).length}Ys.DEFAULT_PRIORITY=10;class Xs extends Ps{constructor(e,t,i,n){super(e,t,i,n),this.getFillerOffset=eo}is(e,t=null){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}_insertChild(e,t){if(t&&(t instanceof Dn||Array.from(t).length>0))throw new l("view-emptyelement-cannot-add",[this,t])}}function eo(){return null}const to=navigator.userAgent.toLowerCase(),io={isMac:so(to),isWindows:function(e){return e.indexOf("windows")>-1}(to),isGecko:function(e){return!!e.match(/gecko\/\d+/)}(to),isSafari:function(e){return e.indexOf(" applewebkit/")>-1&&-1===e.indexOf("chrome")}(to),isiOS:function(e){return!!e.match(/iphone|ipad/i)||so(e)&&navigator.maxTouchPoints>0}(to),isAndroid:function(e){return e.indexOf("android")>-1}(to),isBlink:function(e){return e.indexOf("chrome/")>-1&&e.indexOf("edge/")<0}(to),features:{isRegExpUnicodePropertySupported:function(){let e=!1;try{e=0==="ć".search(new RegExp("[\\p{L}]","u"))}catch(e){}return e}()}},no=io;function so(e){return e.indexOf("macintosh")>-1}const oo={ctrl:"⌃",cmd:"⌘",alt:"⌥",shift:"⇧"},ro={ctrl:"Ctrl+",alt:"Alt+",shift:"Shift+"},ao=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++){const i=String.fromCharCode(t);e[i.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}(),lo=Object.fromEntries(Object.entries(ao).map((([e,t])=>[t,e.charAt(0).toUpperCase()+e.slice(1)])));function co(e){let t;if("string"==typeof e){if(t=ao[e.toLowerCase()],!t)throw new l("keyboard-unknown-key",null,{key:e})}else t=e.keyCode+(e.altKey?ao.alt:0)+(e.ctrlKey?ao.ctrl:0)+(e.shiftKey?ao.shift:0)+(e.metaKey?ao.cmd:0);return t}function uo(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 co(e.slice(0,-1));const t=co(e);return no.isMac&&t==ao.ctrl?ao.cmd:t}(e):e)).reduce(((e,t)=>t+e),0)}function ho(e){let t=uo(e);return Object.entries(no.isMac?oo:ro).reduce(((e,[i,n])=>(0!=(t&ao[i])&&(t&=~ao[i],e+=n),e)),"")+(t?lo[t]:"")}function mo(e,t){const i="ltr"===t;switch(e){case ao.arrowleft:return i?"left":"right";case ao.arrowright:return i?"right":"left";case ao.arrowup:return"up";case ao.arrowdown:return"down"}}class go extends Ps{constructor(e,t,i,n){super(e,t,i,n),this.getFillerOffset=po}is(e,t=null){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}_insertChild(e,t){if(t&&(t instanceof Dn||Array.from(t).length>0))throw new l("view-uielement-cannot-add",this)}render(e){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 fo(e){e.document.on("arrowKey",((t,i)=>function(e,t,i){if(t.keyCode==ao.arrowright){const e=t.domTarget.ownerDocument.defaultView.getSelection(),n=1==e.rangeCount&&e.getRangeAt(0).collapsed;if(n||t.shiftKey){const t=e.focusNode,s=e.focusOffset,o=i.domPositionToView(t,s);if(null===o)return;let r=!1;const a=o.getLastMatchingPosition((e=>(e.item.is("uiElement")&&(r=!0),!(!e.item.is("uiElement")&&!e.item.is("attributeElement")))));if(r){const t=i.viewPositionToDom(a);n?e.collapse(t.parent,t.offset):e.extend(t.parent,t.offset)}}}}(0,i,e.domConverter)),{priority:"low"})}function po(){return null}class wo extends Ps{constructor(e,t,i,n){super(e,t,i,n),this.getFillerOffset=bo}is(e,t=null){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}_insertChild(e,t){if(t&&(t instanceof Dn||Array.from(t).length>0))throw new l("view-rawelement-cannot-add",[this,t])}}function bo(){return null}class vo{constructor(e,t){this.document=e,this._children=[],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}is(e){return"documentFragment"===e||"view:documentFragment"===e}_appendChild(e){return this._insertChild(this.childCount,e)}getChild(e){return this._children[e]}getChildIndex(e){return this._children.indexOf(e)}getChildren(){return this._children[Symbol.iterator]()}_insertChild(e,t){this._fireChange("children",this);let i=0;const n=function(e,t){if("string"==typeof t)return[new zn(e,t)];xn(t)||(t=[t]);return Array.from(t).map((t=>"string"==typeof t?new zn(e,t):t instanceof Ln?new zn(e,t.data):t))}(this.document,t);for(const t of n)null!==t.parent&&t._remove(),t.parent=this,this._children.splice(e,0,t),e++,i++;return i}_removeChildren(e,t=1){this._fireChange("children",this);for(let i=e;i{}),n.renderUnsafeAttributes&&s._unsafeAttributesToRender.push(...n.renderUnsafeAttributes),s}setAttribute(e,t,i){i._setAttribute(e,t)}removeAttribute(e,t){t._removeAttribute(e)}addClass(e,t){t._addClass(e)}removeClass(e,t){t._removeClass(e)}setStyle(e,t,i){Ct(e)&&void 0===i&&(i=t),i._setStyle(e,t)}removeStyle(e,t){t._removeStyle(e)}setCustomProperty(e,t,i){i._setCustomProperty(e,t)}removeCustomProperty(e,t){return t._removeCustomProperty(e)}breakAttributes(e){return e instanceof Ns?this._breakAttributes(e):this._breakAttributesRange(e)}breakContainer(e){const t=e.parent;if(!t.is("containerElement"))throw new l("view-writer-break-non-container-element",this.document);if(!t.parent)throw new l("view-writer-break-root",this.document);if(e.isAtStart)return Ns._createBefore(t);if(!e.isAtEnd){const i=t._clone(!1);this.insert(Ns._createAfter(t),i);const n=new Ds(e,Ns._createAt(t,"end")),s=new Ns(i,0);this.move(n,s)}return Ns._createAfter(t)}mergeAttributes(e){const t=e.offset,i=e.parent;if(i.is("$text"))return e;if(i.is("attributeElement")&&0===i.childCount){const e=i.parent,t=i.index;return i._remove(),this._removeFromClonedElementsGroup(i),this.mergeAttributes(new Ns(e,t))}const n=i.getChild(t-1),s=i.getChild(t);if(!n||!s)return e;if(n.is("$text")&&s.is("$text"))return xo(n,s);if(n.is("attributeElement")&&s.is("attributeElement")&&n.isSimilar(s)){const e=n.childCount;return n._appendChild(s.getChildren()),s._remove(),this._removeFromClonedElementsGroup(s),this.mergeAttributes(new Ns(n,e))}return e}mergeContainers(e){const t=e.nodeBefore,i=e.nodeAfter;if(!(t&&i&&t.is("containerElement")&&i.is("containerElement")))throw new l("view-writer-merge-containers-invalid-position",this.document);const n=t.getChild(t.childCount-1),s=n instanceof zn?Ns._createAt(n,"end"):Ns._createAt(t,"end");return this.move(Ds._createIn(i),Ns._createAt(t,"end")),this.remove(Ds._createOn(i)),s}insert(e,t){To(t=xn(t)?[...t]:[t],this.document);const i=t.reduce(((e,t)=>{const i=e[e.length-1],n=!t.is("uiElement");return i&&i.breakAttributes==n?i.nodes.push(t):e.push({breakAttributes:n,nodes:[t]}),e}),[]);let n=null,s=e;for(const{nodes:e,breakAttributes:t}of i){const i=this._insertNodes(s,e,t);n||(n=i.start),s=i.end}return n?new Ds(n,s):new Ds(e)}remove(e){const t=e instanceof Ds?e:Ds._createOn(e);if(So(t,this.document),t.isCollapsed)return new vo(this.document);const{start:i,end:n}=this._breakAttributesRange(t,!0),s=i.parent,o=n.offset-i.offset,r=s._removeChildren(i.offset,o);for(const e of r)this._removeFromClonedElementsGroup(e);const a=this.mergeAttributes(i);return t.start=a,t.end=a.clone(),new vo(this.document,r)}clear(e,t){So(e,this.document);const i=e.getWalker({direction:"backward",ignoreElementEnd:!0});for(const n of i){const i=n.item;let s;if(i.is("element")&&t.isSimilar(i))s=Ds._createOn(i);else if(!n.nextPosition.isAfter(e.start)&&i.is("$textProxy")){const e=i.getAncestors().find((e=>e.is("element")&&t.isSimilar(e)));e&&(s=Ds._createIn(e))}s&&(s.end.isAfter(e.end)&&(s.end=e.end),s.start.isBefore(e.start)&&(s.start=e.start),this.remove(s))}}move(e,t){let i;if(t.isAfter(e.end)){const n=(t=this._breakAttributes(t,!0)).parent,s=n.childCount;e=this._breakAttributesRange(e,!0),i=this.remove(e),t.offset+=n.childCount-s}else i=this.remove(e);return this.insert(t,i)}wrap(e,t){if(!(t instanceof Ys))throw new l("view-writer-wrap-invalid-attribute",this.document);if(So(e,this.document),e.isCollapsed){let n=e.start;n.parent.is("element")&&(i=n.parent,!Array.from(i.getChildren()).some((e=>!e.is("uiElement"))))&&(n=n.getLastMatchingPosition((e=>e.item.is("uiElement")))),n=this._wrapPosition(n,t);const s=this.document.selection;return s.isCollapsed&&s.getFirstPosition().isEqual(e.start)&&this.setSelection(n),new Ds(n)}return this._wrapRange(e,t);var i}unwrap(e,t){if(!(t instanceof Ys))throw new l("view-writer-unwrap-invalid-attribute",this.document);if(So(e,this.document),e.isCollapsed)return e;const{start:i,end:n}=this._breakAttributesRange(e,!0),s=i.parent,o=this._unwrapChildren(s,i.offset,n.offset,t),r=this.mergeAttributes(o.start);r.isEqual(o.start)||o.end.offset--;const a=this.mergeAttributes(o.end);return new Ds(r,a)}rename(e,t){const i=new Is(this.document,e,t.getAttributes());return this.insert(Ns._createAfter(t),i),this.move(Ds._createIn(t),Ns._createAt(i,0)),this.remove(Ds._createOn(t)),i}clearClonedElementsGroup(e){this._cloneGroups.delete(e)}createPositionAt(e,t){return Ns._createAt(e,t)}createPositionAfter(e){return Ns._createAfter(e)}createPositionBefore(e){return Ns._createBefore(e)}createRange(e,t){return new Ds(e,t)}createRangeOn(e){return Ds._createOn(e)}createRangeIn(e){return Ds._createIn(e)}createSelection(e,t,i){return new Fs(e,t,i)}createSlot(e){if(!this._slotFactory)throw new l("view-writer-invalid-create-slot-context",this.document);return this._slotFactory(this,e)}_registerSlotFactory(e){this._slotFactory=e}_clearSlotFactory(){this._slotFactory=null}_insertNodes(e,t,i){let n,s;if(n=i?yo(e):e.parent.is("$text")?e.parent.parent:e.parent,!n)throw new l("view-writer-invalid-position-container",this.document);s=i?this._breakAttributes(e,!0):e.parent.is("$text")?Ao(e):e;const o=n._insertChild(s.offset,t);for(const e of t)this._addToClonedElementsGroup(e);const r=s.getShiftedBy(o),a=this.mergeAttributes(s);a.isEqual(s)||r.offset--;const c=this.mergeAttributes(r);return new Ds(a,c)}_wrapChildren(e,t,i,n){let s=t;const o=[];for(;s!1,e.parent._insertChild(e.offset,i);const n=new Ds(e,e.getShiftedBy(1));this.wrap(n,t);const s=new Ns(i.parent,i.index);i._remove();const o=s.nodeBefore,r=s.nodeAfter;return o instanceof zn&&r instanceof zn?xo(o,r):Co(s)}_wrapAttributeElement(e,t){if(!Io(e,t))return!1;if(e.name!==t.name||e.priority!==t.priority)return!1;for(const i of e.getAttributeKeys())if("class"!==i&&"style"!==i&&t.hasAttribute(i)&&t.getAttribute(i)!==e.getAttribute(i))return!1;for(const i of e.getStyleNames())if(t.hasStyle(i)&&t.getStyle(i)!==e.getStyle(i))return!1;for(const i of e.getAttributeKeys())"class"!==i&&"style"!==i&&(t.hasAttribute(i)||this.setAttribute(i,e.getAttribute(i),t));for(const i of e.getStyleNames())t.hasStyle(i)||this.setStyle(i,e.getStyle(i),t);for(const i of e.getClassNames())t.hasClass(i)||this.addClass(i,t);return!0}_unwrapAttributeElement(e,t){if(!Io(e,t))return!1;if(e.name!==t.name||e.priority!==t.priority)return!1;for(const i of e.getAttributeKeys())if("class"!==i&&"style"!==i&&(!t.hasAttribute(i)||t.getAttribute(i)!==e.getAttribute(i)))return!1;if(!t.hasClass(...e.getClassNames()))return!1;for(const i of e.getStyleNames())if(!t.hasStyle(i)||t.getStyle(i)!==e.getStyle(i))return!1;for(const i of e.getAttributeKeys())"class"!==i&&"style"!==i&&this.removeAttribute(i,t);return this.removeClass(Array.from(e.getClassNames()),t),this.removeStyle(Array.from(e.getStyleNames()),t),!0}_breakAttributesRange(e,t=!1){const i=e.start,n=e.end;if(So(e,this.document),e.isCollapsed){const i=this._breakAttributes(e.start,t);return new Ds(i,i)}const s=this._breakAttributes(n,t),o=s.parent.childCount,r=this._breakAttributes(i,t);return s.offset+=s.parent.childCount-o,new Ds(r,s)}_breakAttributes(e,t=!1){const i=e.offset,n=e.parent;if(e.parent.is("emptyElement"))throw new l("view-writer-cannot-break-empty-element",this.document);if(e.parent.is("uiElement"))throw new l("view-writer-cannot-break-ui-element",this.document);if(e.parent.is("rawElement"))throw new l("view-writer-cannot-break-raw-element",this.document);if(!t&&n.is("$text")&&Po(n.parent))return e.clone();if(Po(n))return e.clone();if(n.is("$text"))return this._breakAttributes(Ao(e),t);if(i==n.childCount){const e=new Ns(n.parent,n.index+1);return this._breakAttributes(e,t)}if(0===i){const e=new Ns(n.parent,n.index);return this._breakAttributes(e,t)}{const e=n.index+1,s=n._clone();n.parent._insertChild(e,s),this._addToClonedElementsGroup(s);const o=n.childCount-i,r=n._removeChildren(i,o);s._appendChild(r);const a=new Ns(n.parent,e);return this._breakAttributes(a,t)}}_addToClonedElementsGroup(e){if(!e.root.is("rootElement"))return;if(e.is("element"))for(const t of e.getChildren())this._addToClonedElementsGroup(t);const t=e.id;if(!t)return;let i=this._cloneGroups.get(t);i||(i=new Set,this._cloneGroups.set(t,i)),i.add(e),e._clonesGroup=i}_removeFromClonedElementsGroup(e){if(e.is("element"))for(const t of e.getChildren())this._removeFromClonedElementsGroup(t);const t=e.id;if(!t)return;const i=this._cloneGroups.get(t);i&&i.delete(e)}}function yo(e){let t=e.parent;for(;!Po(t);){if(!t)return;t=t.parent}return t}function ko(e,t){return e.priorityt.priority)&&e.getIdentity()i instanceof e)))throw new l("view-writer-insert-invalid-node-type",t);i.is("$text")||To(i.getChildren(),t)}}const Eo=[zn,Ys,Is,Xs,wo,go];function Po(e){return e&&(e.is("containerElement")||e.is("documentFragment"))}function So(e,t){const i=yo(e.start),n=yo(e.end);if(!i||!n||i!==n)throw new l("view-writer-invalid-range-container",t)}function Io(e,t){return null===e.id&&null===t.id}function Ro(e){return"[object Text]"==Object.prototype.toString.call(e)}const Vo=e=>e.createTextNode(" "),Oo=e=>{const t=e.createElement("span");return t.dataset.ckeFiller=!0,t.innerHTML=" ",t},Bo=e=>{const t=e.createElement("br");return t.dataset.ckeFiller=!0,t},Mo="".repeat(7);function No(e){return Ro(e)&&e.data.substr(0,7)===Mo}function Do(e){return 7==e.data.length&&No(e)}function zo(e){return No(e)?e.data.slice(7):e.data}function Lo(e,t){if(t.keyCode==ao.arrowleft){const e=t.domTarget.ownerDocument.defaultView.getSelection();if(1==e.rangeCount&&e.getRangeAt(0).collapsed){const t=e.getRangeAt(0).startContainer,i=e.getRangeAt(0).startOffset;No(t)&&i<=7&&e.collapse(t,0)}}}function Fo(e,t,i,n=!1){i=i||function(e,t){return e===t},Array.isArray(e)||(e=Array.prototype.slice.call(e)),Array.isArray(t)||(t=Array.prototype.slice.call(t));const s=function(e,t,i){const n=Ho(e,t,i);if(-1===n)return{firstIndex:-1,lastIndexOld:-1,lastIndexNew:-1};const s=jo(e,n),o=jo(t,n),r=Ho(s,o,i),a=e.length-r,l=t.length-r;return{firstIndex:n,lastIndexOld:a,lastIndexNew:l}}(e,t,i);return n?function(e,t){const{firstIndex:i,lastIndexOld:n,lastIndexNew:s}=e;if(-1===i)return Array(t).fill("equal");let o=[];i>0&&(o=o.concat(Array(i).fill("equal")));s-i>0&&(o=o.concat(Array(s-i).fill("insert")));n-i>0&&(o=o.concat(Array(n-i).fill("delete")));s0&&i.push({index:n,type:"insert",values:e.slice(n,o)});s-n>0&&i.push({index:n+(o-n),type:"delete",howMany:s-n});return i}(t,s)}function Ho(e,t,i){for(let n=0;n200||s>200||n+s>300)return Wo.fastDiff(e,t,i,!0);let o,r;if(sc?-1:1;d[n+h]&&(d[n]=d[n+h].slice(0)),d[n]||(d[n]=[]),d[n].push(s>c?o:r);let m=Math.max(s,c),g=m-n;for(;gc;m--)u[m]=h(m);u[c]=h(c),g++}while(u[c]!==l);return d[c].slice(1)}function Uo(e,t,i){e.insertBefore(i,e.childNodes[t]||null)}function qo(e){const t=e.parentNode;t&&t.removeChild(e)}function $o(e){return e&&e.nodeType===Node.COMMENT_NODE}function Ko(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}Wo.fastDiff=Fo;class Go{constructor(e,t){this.domDocuments=new Set,this.domConverter=e,this.markedAttributes=new Set,this.markedChildren=new Set,this.markedTexts=new Set,this.selection=t,this.set("isFocused",!1),this.set("isSelecting",!1),no.isBlink&&!no.isAndroid&&this.on("change:isSelecting",(()=>{this.isSelecting||this.render()})),this._inlineFiller=null,this._fakeSelectionContainer=null}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 l("view-renderer-unknown-type",this);this.markedChildren.add(t)}}}render(){let e;const t=!(no.isBlink&&!no.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));for(const e of this.markedAttributes)this._updateAttrs(e);for(const t of this.markedChildren)this._updateChildren(t,{inlineFillerPosition:e});for(const t of this.markedTexts)!this.markedChildren.has(t.parent)&&this.domConverter.mapViewToDom(t.parent)&&this._updateText(t,{inlineFillerPosition:e});if(t)if(e){const t=this.domConverter.viewPositionToDom(e),i=t.parent.ownerDocument;No(t.parent)?this._inlineFiller=t.parent:this._inlineFiller=Jo(i,t.parent,t.offset)}else this._inlineFiller=null;this._updateFocus(),this._updateSelection(),this.markedTexts.clear(),this.markedAttributes.clear(),this.markedChildren.clear()}_updateChildrenMappings(e){const t=this.domConverter.mapViewToDom(e);if(!t)return;const i=Array.from(this.domConverter.mapViewToDom(e).childNodes),n=Array.from(this.domConverter.viewChildrenToDom(e,t.ownerDocument,{withChildren:!1})),s=this._diffNodeLists(i,n),o=this._findReplaceActions(s,i,n);if(-1!==o.indexOf("replace")){const t={equal:0,insert:0,delete:0};for(const s of o)if("replace"===s){const s=t.equal+t.insert,o=t.equal+t.delete,r=e.getChild(s);!r||r.is("uiElement")||r.is("rawElement")||this._updateElementMappings(r,i[o]),qo(n[s]),t.equal++}else t[s]++}}_updateElementMappings(e,t){this.domConverter.unbindDomElement(t),this.domConverter.bindElements(t,e),this.markedChildren.add(e),this.markedAttributes.add(e)}_getInlineFillerPosition(){const e=this.selection.getFirstPosition();return e.parent.is("$text")?Ns._createBefore(this.selection.getFirstPosition().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&&Ro(t.parent)&&No(t.parent))}_removeInlineFiller(){const e=this._inlineFiller;if(!No(e))throw new l("view-renderer-filler-was-lost",this);Do(e)?e.remove():e.data=e.data.substr(7),this._inlineFiller=null}_needsInlineFillerAtSelection(){if(1!=this.selection.rangeCount||!this.selection.isCollapsed)return!1;const e=this.selection.getFirstPosition(),t=e.parent,i=e.offset;if(!this.domConverter.mapViewToDom(t.root))return!1;if(!t.is("element"))return!1;if(!function(e){if("false"==e.getAttribute("contenteditable"))return!1;const t=e.findAncestor((e=>e.hasAttribute("contenteditable")));return!t||"true"==t.getAttribute("contenteditable")}(t))return!1;if(i===t.getFillerOffset())return!1;const n=e.nodeBefore,s=e.nodeAfter;return!(n instanceof zn||s instanceof zn)}_updateText(e,t){const i=this.domConverter.findCorrespondingDomText(e),n=this.domConverter.viewToDom(e,i.ownerDocument),s=i.data;let o=n.data;const r=t.inlineFillerPosition;if(r&&r.parent==e.parent&&r.offset==e.index&&(o=Mo+o),s!=o){const e=Fo(s,o);for(const t of e)"insert"===t.type?i.insertData(t.index,t.values.join("")):i.deleteData(t.index,t.howMany)}}_updateAttrs(e){const t=this.domConverter.mapViewToDom(e);if(!t)return;const i=Array.from(t.attributes).map((e=>e.name)),n=e.getAttributeKeys();for(const i of n)this.domConverter.setDomElementAttribute(t,i,e.getAttribute(i),e);for(const n of i)e.hasAttribute(n)||this.domConverter.removeDomElementAttribute(t,n)}_updateChildren(e,t){const i=this.domConverter.mapViewToDom(e);if(!i)return;const n=t.inlineFillerPosition,s=this.domConverter.mapViewToDom(e).childNodes,o=Array.from(this.domConverter.viewChildrenToDom(e,i.ownerDocument,{bind:!0}));n&&n.parent===e&&Jo(i.ownerDocument,o,n.offset);const r=this._diffNodeLists(s,o);let a=0;const l=new Set;for(const e of r)"delete"===e?(l.add(s[a]),qo(s[a])):"equal"===e&&a++;a=0;for(const e of r)"insert"===e?(Uo(i,a,o[a]),a++):"equal"===e&&(this._markDescendantTextToSync(this.domConverter.domToView(o[a])),a++);for(const e of l)e.parentNode||this.domConverter.unbindDomElement(e)}_diffNodeLists(e,t){return Wo(e=function(e,t){const i=Array.from(e);if(0==i.length||!t)return i;i[i.length-1]==t&&i.pop();return i}(e,this._fakeSelectionContainer),t,Qo.bind(null,this.domConverter))}_findReplaceActions(e,t,i){if(-1===e.indexOf("insert")||-1===e.indexOf("delete"))return e;let n=[],s=[],o=[];const r={equal:0,insert:0,delete:0};for(const a of e)"insert"===a?o.push(i[r.equal+r.insert]):"delete"===a?s.push(t[r.equal+r.delete]):(n=n.concat(Wo(s,o,Yo).map((e=>"equal"===e?"replace":e))),n.push("equal"),s=[],o=[]),r[a]++;return n.concat(Wo(s,o,Yo).map((e=>"equal"===e?"replace":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(no.isBlink&&!no.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._removeFakeSelection(),this._updateDomSelection(e)))}_updateFakeSelection(e){const t=e.ownerDocument;this._fakeSelectionContainer||(this._fakeSelectionContainer=function(e){const t=e.createElement("div");return t.className="ck-fake-selection-container",Object.assign(t.style,{position:"fixed",top:0,left:"-9999px",width:"42px"}),t.textContent=" ",t}(t));const i=this._fakeSelectionContainer;if(this.domConverter.bindFakeSelection(i,this.selection),!this._fakeSelectionNeedsUpdate(e))return;i.parentElement&&i.parentElement==e||e.appendChild(i),i.textContent=this.selection.fakeSelectionLabel||" ";const n=t.getSelection(),s=t.createRange();n.removeAllRanges(),s.selectNodeContents(i),n.addRange(s)}_updateDomSelection(e){const t=e.ownerDocument.defaultView.getSelection();if(!this._domSelectionNeedsUpdate(t))return;const i=this.domConverter.viewPositionToDom(this.selection.anchor),n=this.domConverter.viewPositionToDom(this.selection.focus);t.collapse(i.parent,i.offset),t.extend(n.parent,n.offset),no.isGecko&&function(e,t){const i=e.parent;if(i.nodeType!=Node.ELEMENT_NODE||e.offset!=i.childNodes.length-1)return;const n=i.childNodes[e.offset];n&&"BR"==n.tagName&&t.addRange(t.getRangeAt(0))}(n,t)}_domSelectionNeedsUpdate(e){if(!this.domConverter.isDomSelectionCorrect(e))return!0;const t=e&&this.domConverter.domSelectionToView(e);return(!t||!this.selection.isEqual(t))&&!(!this.selection.isCollapsed&&this.selection.isSimilar(t))}_fakeSelectionNeedsUpdate(e){const t=this._fakeSelectionContainer,i=e.ownerDocument.getSelection();return!t||t.parentElement!==e||(i.anchorNode!==t&&!t.contains(i.anchorNode)||t.textContent!==this.selection.fakeSelectionLabel)}_removeDomSelection(){for(const e of this.domDocuments){if(e.getSelection().rangeCount){const t=e.activeElement,i=this.domConverter.mapDomToView(t);t&&i&&e.getSelection().removeAllRanges()}}}_removeFakeSelection(){const e=this._fakeSelectionContainer;e&&e.remove()}_updateFocus(){if(this.isFocused){const e=this.selection.editableElement;e&&this.domConverter.focus(e)}}}function Jo(e,t,i){const n=t instanceof Array?t:t.childNodes,s=n[i];if(Ro(s))return s.data=Mo+s.data,s;{const s=e.createTextNode(Mo);return Array.isArray(t)?n.splice(i,0,s):Uo(t,i,s),s}}function Yo(e,t){return Ko(e)&&Ko(t)&&!Ro(e)&&!Ro(t)&&!$o(e)&&!$o(t)&&e.tagName.toLowerCase()===t.tagName.toLowerCase()}function Qo(e,t,i){return t===i||(Ro(t)&&Ro(i)?t.data===i.data:!(!e.isBlockFiller(t)||!e.isBlockFiller(i)))}dt(Go,st);const Zo={window,document};function Xo(e){let t=0;for(;e.previousSibling;)e=e.previousSibling,t++;return t}function er(e){const t=[];for(;e&&e.nodeType!=Node.DOCUMENT_NODE;)t.unshift(e),e=e.parentNode;return t}const tr=Bo(document),ir=Vo(document),nr=Oo(document),sr="data-ck-unsafe-attribute-",or="data-ck-unsafe-element",rr=["script","style"];class ar{constructor(e,t={}){this.document=e,this.renderingMode=t.renderingMode||"editing",this.blockFillerMode=t.blockFillerMode||("editing"===this.renderingMode?"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._domToViewMapping=new WeakMap,this._viewToDomMapping=new WeakMap,this._fakeSelectionMapping=new WeakMap,this._rawContentElementMatcher=new Hn,this._encounteredRawContentDomNodes=new WeakSet}bindFakeSelection(e,t){this._fakeSelectionMapping.set(e,new Fs(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 e.childNodes)this.unbindDomElement(t)}}bindDocumentFragments(e,t){this._domToViewMapping.set(e,t),this._viewToDomMapping.set(t,e)}shouldRenderAttribute(e,t,i){return"data"===this.renderingMode||!(e=e.toLowerCase()).startsWith("on")&&(("srcdoc"!==e||!t.match(/\bon\S+\s*=|javascript:|<\s*\/*script/i))&&("img"===i&&("src"===e||"srcset"===e)||("source"===i&&"srcset"===e||!t.match(/^\s*(javascript:|data:(image\/svg|text\/x?html))/i))))}setContentOf(e,t){if("data"===this.renderingMode)return void(e.innerHTML=t);const i=(new DOMParser).parseFromString(t,"text/html"),n=i.createDocumentFragment(),s=i.body.childNodes;for(;s.length>0;)n.appendChild(s[0]);const o=i.createTreeWalker(n,NodeFilter.SHOW_ELEMENT),r=[];let a;for(;a=o.nextNode();)r.push(a);for(const e of r){for(const t of e.getAttributeNames())this.setDomElementAttribute(e,t,e.getAttribute(t));const t=e.tagName.toLowerCase();this._shouldRenameElement(t)&&(dr(t),e.replaceWith(this._createReplacementDomElement(t,e)))}for(;e.firstChild;)e.firstChild.remove();e.append(n)}viewToDom(e,t,i={}){if(e.is("$text")){const i=this._processDataFromViewText(e);return t.createTextNode(i)}{if(this.mapViewToDom(e))return this.mapViewToDom(e);let n;if(e.is("documentFragment"))n=t.createDocumentFragment(),i.bind&&this.bindDocumentFragments(n,e);else{if(e.is("uiElement"))return n="$comment"===e.name?t.createComment(e.getCustomProperty("$rawContent")):e.render(t,this),i.bind&&this.bindElements(n,e),n;this._shouldRenameElement(e.name)?(dr(e.name),n=this._createReplacementDomElement(e.name)):n=e.hasAttribute("xmlns")?t.createElementNS(e.getAttribute("xmlns"),e.name):t.createElement(e.name),e.is("rawElement")&&e.render(n,this),i.bind&&this.bindElements(n,e);for(const t of e.getAttributeKeys())this.setDomElementAttribute(n,t,e.getAttribute(t),e)}if(!1!==i.withChildren)for(const s of this.viewChildrenToDom(e,t,i))n.appendChild(s);return n}}setDomElementAttribute(e,t,i,n=null){const s=this.shouldRenderAttribute(t,i,e.tagName.toLowerCase())||n&&n.shouldRenderUnsafeAttribute(t);s||c("domconverter-unsafe-attribute-detected",{domElement:e,key:t,value:i}),e.hasAttribute(t)&&!s?e.removeAttribute(t):e.hasAttribute(sr+t)&&s&&e.removeAttribute(sr+t),e.setAttribute(s?t:sr+t,i)}removeDomElementAttribute(e,t){t!=or&&(e.removeAttribute(t),e.removeAttribute(sr+t))}*viewChildrenToDom(e,t,i={}){const n=e.getFillerOffset&&e.getFillerOffset();let s=0;for(const o of e.getChildren()){n===s&&(yield this._getBlockFiller(t));const e=o.is("element")&&o.getCustomProperty("dataPipeline:transparentRendering");e&&"data"==this.renderingMode?yield*this.viewChildrenToDom(o,t,i):(e&&c("domconverter-transparent-rendering-unsupported-in-editing-pipeline",{viewElement:o}),yield this.viewToDom(o,t,i)),s++}n===s&&(yield this._getBlockFiller(t))}viewRangeToDom(e){const t=this.viewPositionToDom(e.start),i=this.viewPositionToDom(e.end),n=document.createRange();return n.setStart(t.parent,t.offset),n.setEnd(i.parent,i.offset),n}viewPositionToDom(e){const t=e.parent;if(t.is("$text")){const i=this.findCorrespondingDomText(t);if(!i)return null;let n=e.offset;return No(i)&&(n+=7),{parent:i,offset:n}}{let i,n,s;if(0===e.offset){if(i=this.mapViewToDom(t),!i)return null;s=i.childNodes[0]}else{const t=e.nodeBefore;if(n=t.is("$text")?this.findCorrespondingDomText(t):this.mapViewToDom(e.nodeBefore),!n)return null;i=n.parentNode,s=n.nextSibling}if(Ro(s)&&No(s))return{parent:s,offset:7};return{parent:i,offset:n?Xo(n)+1:0}}}domToView(e,t={}){if(this.isBlockFiller(e))return null;const i=this.getHostViewElement(e);if(i)return i;if($o(e)&&t.skipComments)return null;if(Ro(e)){if(Do(e))return null;{const t=this._processDataFromDomText(e);return""===t?null:new zn(this.document,t)}}{if(this.mapDomToView(e))return this.mapDomToView(e);let i;if(this.isDocumentFragment(e))i=new vo(this.document),t.bind&&this.bindDocumentFragments(e,i);else{i=this._createViewElement(e,t),t.bind&&this.bindElements(e,i);const n=e.attributes;if(n)for(let e=n.length-1;e>=0;e--)i._setAttribute(n[e].name,n[e].value);if(this._isViewElementWithRawContent(i,t)||$o(e)){const t=$o(e)?e.data:e.innerHTML;return i._setCustomProperty("$rawContent",t),this._encounteredRawContentDomNodes.add(e),i}}if(!1!==t.withChildren)for(const n of this.domChildrenToView(e,t))i._appendChild(n);return i}}*domChildrenToView(e,t={}){for(let i=0;i{const{scrollLeft:t,scrollTop:i}=e;n.push([t,i])})),t.focus(),lr(t,(e=>{const[t,i]=n.shift();e.scrollLeft=t,e.scrollTop=i})),Zo.window.scrollTo(e,i)}}isElement(e){return e&&e.nodeType==Node.ELEMENT_NODE}isDocumentFragment(e){return e&&e.nodeType==Node.DOCUMENT_FRAGMENT_NODE}isBlockFiller(e){return"br"==this.blockFillerMode?e.isEqualNode(tr):!("BR"!==e.tagName||!cr(e,this.blockElements)||1!==e.parentNode.childNodes.length)||(e.isEqualNode(nr)||function(e,t){return e.isEqualNode(ir)&&cr(e,t)&&1===e.parentNode.childNodes.length}(e,this.blockElements))}isDomSelectionBackward(e){if(e.isCollapsed)return!1;const t=document.createRange();t.setStart(e.anchorNode,e.anchorOffset),t.setEnd(e.focusNode,e.focusOffset);const i=t.collapsed;return t.detach(),i}getHostViewElement(e){const t=er(e);for(t.pop();t.length;){const e=t.pop(),i=this._domToViewMapping.get(e);if(i&&(i.is("uiElement")||i.is("rawElement")))return i}return null}isDomSelectionCorrect(e){return this._isDomSelectionPositionCorrect(e.anchorNode,e.anchorOffset)&&this._isDomSelectionPositionCorrect(e.focusNode,e.focusOffset)}registerRawContentMatcher(e){this._rawContentElementMatcher.add(e)}_getBlockFiller(e){switch(this.blockFillerMode){case"nbsp":return Vo(e);case"markedNbsp":return Oo(e);case"br":return Bo(e)}}_isDomSelectionPositionCorrect(e,t){if(Ro(e)&&No(e)&&t<7)return!1;if(this.isElement(e)&&No(e.childNodes[t]))return!1;const i=this.mapDomToView(e);return!i||!i.is("uiElement")&&!i.is("rawElement")}_processDataFromViewText(e){let t=e.data;if(e.getAncestors().some((e=>this.preElements.includes(e.name))))return t;if(" "==t.charAt(0)){const i=this._getTouchingInlineViewNode(e,!1);!(i&&i.is("$textProxy")&&this._nodeEndsWithSpace(i))&&i||(t=" "+t.substr(1))}if(" "==t.charAt(t.length-1)){const i=this._getTouchingInlineViewNode(e,!0),n=i&&i.is("$textProxy")&&" "==i.data.charAt(0);" "!=t.charAt(t.length-2)&&i&&!n||(t=t.substr(0,t.length-1)+" ")}return t.replace(/ {2}/g," ")}_nodeEndsWithSpace(e){if(e.getAncestors().some((e=>this.preElements.includes(e.name))))return!1;const t=this._processDataFromViewText(e);return" "==t.charAt(t.length-1)}_processDataFromDomText(e){let t=e.data;if(function(e,t){return er(e).some((e=>e.tagName&&t.includes(e.tagName.toLowerCase())))}(e,this.preElements))return zo(e);t=t.replace(/[ \n\t\r]{1,}/g," ");const i=this._getTouchingInlineDomNode(e,!1),n=this._getTouchingInlineDomNode(e,!0),s=this._checkShouldLeftTrimDomText(e,i),o=this._checkShouldRightTrimDomText(e,n);s&&(t=t.replace(/^ /,"")),o&&(t=t.replace(/ $/,"")),t=zo(new Text(t)),t=t.replace(/ \u00A0/g," ");const r=n&&this.isElement(n)&&"BR"!=n.tagName,a=n&&Ro(n)&&" "==n.data.charAt(0);return(/( |\u00A0)\u00A0$/.test(t)||!n||r||a)&&(t=t.replace(/\u00A0$/," ")),(s||i&&this.isElement(i)&&"BR"!=i.tagName)&&(t=t.replace(/^\u00A0/," ")),t}_checkShouldLeftTrimDomText(e,t){return!t||(this.isElement(t)?"BR"===t.tagName:!this._encounteredRawContentDomNodes.has(e.previousSibling)&&/[^\S\u00A0]/.test(t.data.charAt(t.data.length-1)))}_checkShouldRightTrimDomText(e,t){return!t&&!No(e)}_getTouchingInlineViewNode(e,t){const i=new Ms({startPosition:t?Ns._createAfter(e):Ns._createBefore(e),direction:t?"forward":"backward"});for(const e of i){if(e.item.is("element")&&this.inlineObjectElements.includes(e.item.name))return e.item;if(e.item.is("containerElement"))return null;if(e.item.is("element","br"))return null;if(e.item.is("$textProxy"))return e.item}return null}_getTouchingInlineDomNode(e,t){if(!e.parentNode)return null;const i=t?"firstChild":"lastChild",n=t?"nextSibling":"previousSibling";let s=!0;do{if(!s&&e[i]?e=e[i]:e[n]?(e=e[n],s=!1):(e=e.parentNode,s=!0),!e||this._isBlockElement(e))return null}while(!Ro(e)&&"BR"!=e.tagName&&!this._isInlineObjectElement(e));return e}_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($o(e))return new go(this.document,"$comment");const i=t.keepOriginalCase?e.tagName:e.tagName.toLowerCase();return new Ps(this.document,i)}_isViewElementWithRawContent(e,t){return!1!==t.withChildren&&this._rawContentElementMatcher.match(e)}_shouldRenameElement(e){const t=e.toLowerCase();return"editing"===this.renderingMode&&rr.includes(t)}_createReplacementDomElement(e,t=null){const i=document.createElement("span");if(i.setAttribute(or,e),t){for(;t.firstChild;)i.appendChild(t.firstChild);for(const e of t.getAttributeNames())i.setAttribute(e,t.getAttribute(e))}return i}}function lr(e,t){for(;e&&e!=Zo.document;)t(e),e=e.parentNode}function cr(e,t){const i=e.parentNode;return i&&i.tagName&&t.includes(i.tagName.toLowerCase())}function dr(e){"script"===e&&c("domconverter-unsafe-script-element-detected"),"style"===e&&c("domconverter-unsafe-style-element-detected")}function ur(e){const t=Object.prototype.toString.apply(e);return"[object Window]"==t||"[object global]"==t}const hr=Qe({},p,{listenTo(e,t,i,n={}){if(Ko(e)||ur(e)){const s={capture:!!n.useCapture,passive:!!n.usePassive},o=this._getProxyEmitter(e,s)||new mr(e,s);this.listenTo(o,t,i,n)}else p.listenTo.call(this,e,t,i,n)},stopListening(e,t,i){if(Ko(e)||ur(e)){const n=this._getAllProxyEmitters(e);for(const e of n)this.stopListening(e,t,i)}else p.stopListening.call(this,e,t,i)},_getProxyEmitter(e,t){return i=this,n=gr(e,t),i[g]&&i[g][n]?i[g][n].emitter:null;var i,n},_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))}});class mr{constructor(e,t){w(this,gr(e,t)),this._domNode=e,this._options=t}}function gr(e,t){let i=function(e){return e["data-ck-expando"]||(e["data-ck-expando"]=o())}(e);for(const e of Object.keys(t).sort())t[e]&&(i+="-"+e);return i}Qe(mr.prototype,p,{attach(e){if(this._domListeners&&this._domListeners[e])return;const t=this._createDomListener(e);this._domNode.addEventListener(e,t,this._options),this._domListeners||(this._domListeners={}),this._domListeners[e]=t},detach(e){let t;!this._domListeners[e]||(t=this._events[e])&&t.callbacks.length||this._domListeners[e].removeListener()},_addEventListener(e,t,i){this.attach(e),p._addEventListener.call(this,e,t,i)},_removeEventListener(e,t){p._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}});class fr{constructor(e){this.view=e,this.document=e.document,this.isEnabled=!1}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] *")}}dt(fr,hr);const pr=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this};const wr=function(e){return this.__data__.has(e)};function br(e){var t=-1,i=null==e?0:e.length;for(this.__data__=new ii;++ta))return!1;var c=o.get(e),d=o.get(t);if(c&&d)return c==t&&d==e;var u=-1,h=!0,m=2&i?new vr:void 0;for(o.set(e,t),o.set(t,e);++u{this.listenTo(e,t,((e,t)=>{this.isEnabled&&!this.checkShouldIgnoreEventFromTarget(t.target)&&this.onDomEvent(t)}),{useCapture:this.useCapture})}))}fire(e,t,i){this.isEnabled&&this.document.fire(e,new zr(this.view,t,i))}}class Fr extends Lr{constructor(e){super(e),this.domEventType=["keydown","keyup"]}onDomEvent(e){this.fire(e.type,e,{keyCode:e.keyCode,altKey:e.altKey,ctrlKey:e.ctrlKey,shiftKey:e.shiftKey,metaKey:e.metaKey,get keystroke(){return co(this)}})}}const Hr=function(){return E.Date.now()};var jr=/\s/;const Wr=function(e){for(var t=e.length;t--&&jr.test(e.charAt(t)););return t};var Ur=/^\s+/;const qr=function(e){return e?e.slice(0,Wr(e)+1).replace(Ur,""):e};var $r=/^[-+]0x[0-9a-f]+$/i,Kr=/^0b[01]+$/i,Gr=/^0o[0-7]+$/i,Jr=parseInt;const Yr=function(e){if("number"==typeof e)return e;if(Un(e))return NaN;if(A(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=A(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=qr(e);var i=Kr.test(e);return i||Gr.test(e)?Jr(e.slice(2),i?2:8):$r.test(e)?NaN:+e};var Qr=Math.max,Zr=Math.min;const Xr=function(e,t,i){var n,s,o,r,a,l,c=0,d=!1,u=!1,h=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function m(t){var i=n,o=s;return n=s=void 0,c=t,r=e.apply(o,i)}function g(e){return c=e,a=setTimeout(p,t),d?m(e):r}function f(e){var i=e-l;return void 0===l||i>=t||i<0||u&&e-c>=o}function p(){var e=Hr();if(f(e))return w(e);a=setTimeout(p,function(e){var i=t-(e-l);return u?Zr(i,o-(e-c)):i}(e))}function w(e){return a=void 0,h&&n?m(e):(n=s=void 0,r)}function b(){var e=Hr(),i=f(e);if(n=arguments,s=this,l=e,i){if(void 0===a)return g(l);if(u)return clearTimeout(a),a=setTimeout(p,t),m(l)}return void 0===a&&(a=setTimeout(p,t)),r}return t=Yr(t)||0,A(i)&&(d=!!i.leading,o=(u="maxWait"in i)?Qr(Yr(i.maxWait)||0,t):o,h="trailing"in i?!!i.trailing:h),b.cancel=function(){void 0!==a&&clearTimeout(a),c=0,n=l=s=a=void 0},b.flush=function(){return void 0===a?r:w(Hr())},b};class ea extends fr{constructor(e){super(e),this._fireSelectionChangeDoneDebounced=Xr((e=>this.document.fire("selectionChangeDone",e)),200)}observe(){const e=this.document;e.on("arrowKey",((t,i)=>{e.selection.isFake&&this.isEnabled&&i.preventDefault()}),{context:"$capture"}),e.on("arrowKey",((t,i)=>{e.selection.isFake&&this.isEnabled&&this._handleSelectionMove(i.keyCode)}),{priority:"lowest"})}destroy(){super.destroy(),this._fireSelectionChangeDoneDebounced.cancel()}_handleSelectionMove(e){const t=this.document.selection,i=new Fs(t.getRanges(),{backward:t.isBackward,fake:!1});e!=ao.arrowleft&&e!=ao.arrowup||i.setTo(i.getFirstPosition()),e!=ao.arrowright&&e!=ao.arrowdown||i.setTo(i.getLastPosition());const n={oldSelection:t,newSelection:i,domSelection:null};this.document.fire("selectionChange",n),this._fireSelectionChangeDoneDebounced(n)}}class ta extends fr{constructor(e){super(e),this.mutationObserver=e.getObserver(Dr),this.selection=this.document.selection,this.domConverter=e.domConverter,this._documents=new WeakSet,this._fireSelectionChangeDoneDebounced=Xr((e=>this.document.fire("selectionChangeDone",e)),200),this._clearInfiniteLoopInterval=setInterval((()=>this._clearInfiniteLoop()),1e3),this._documentIsSelectingInactivityTimeoutDebounced=Xr((()=>this.document.isSelecting=!1),5e3),this._loopbackCounter=0}observe(e){const t=e.ownerDocument,i=()=>{this.document.isSelecting=!1,this._documentIsSelectingInactivityTimeoutDebounced.cancel()};this.listenTo(e,"selectstart",(()=>{this.document.isSelecting=!0,this._documentIsSelectingInactivityTimeoutDebounced()}),{priority:"highest"}),this.listenTo(e,"keydown",i,{priority:"highest"}),this.listenTo(e,"keyup",i,{priority:"highest"}),this._documents.has(t)||(this.listenTo(t,"mouseup",i,{priority:"highest"}),this.listenTo(t,"selectionchange",((e,i)=>{this._handleSelectionChange(i,t),this._documentIsSelectingInactivityTimeoutDebounced()})),this._documents.add(t))}destroy(){super.destroy(),clearInterval(this._clearInfiniteLoopInterval),this._fireSelectionChangeDoneDebounced.cancel(),this._documentIsSelectingInactivityTimeoutDebounced.cancel()}_handleSelectionChange(e,t){if(!this.isEnabled)return;const i=t.defaultView.getSelection();if(this.checkShouldIgnoreEventFromTarget(i.anchorNode))return;this.mutationObserver.flush();const n=this.domConverter.domSelectionToView(i);if(0!=n.rangeCount){if(this.view.hasDomSelection=!0,!(this.selection.isEqual(n)&&this.domConverter.isDomSelectionCorrect(i)||++this._loopbackCounter>60))if(this.selection.isSimilar(n))this.view.forceRender();else{const e={oldSelection:this.selection,newSelection:n,domSelection:i};this.document.fire("selectionChange",e),this._fireSelectionChangeDoneDebounced(e)}}else this.view.hasDomSelection=!1}_clearInfiniteLoop(){this._loopbackCounter=0}}class ia extends Lr{constructor(e){super(e),this.domEventType=["focus","blur"],this.useCapture=!0;const t=this.document;t.on("focus",(()=>{t.isFocused=!0,this._renderTimeoutId=setTimeout((()=>e.change((()=>{}))),50)})),t.on("blur",((i,n)=>{const s=t.selection.editableElement;null!==s&&s!==n.target||(t.isFocused=!1,e.change((()=>{})))}))}onDomEvent(e){this.fire(e.type,e)}destroy(){this._renderTimeoutId&&clearTimeout(this._renderTimeoutId),super.destroy()}}class na extends Lr{constructor(e){super(e),this.domEventType=["compositionstart","compositionupdate","compositionend"];const t=this.document;t.on("compositionstart",(()=>{t.isComposing=!0})),t.on("compositionend",(()=>{t.isComposing=!1}))}onDomEvent(e){this.fire(e.type,e)}}class sa extends Lr{constructor(e){super(e),this.domEventType=["beforeinput"]}onDomEvent(e){this.fire(e.type,e)}}class oa{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=[]}}const ra=function(e){return"string"==typeof e||!Pe(e)&&ke(e)&&"[object String]"==D(e)};function aa(e,t,i={},n=[]){const s=i&&i.xmlns,o=s?e.createElementNS(s,t):e.createElement(t);for(const e in i)o.setAttribute(e,i[e]);!ra(n)&&xn(n)||(n=[n]);for(let t of n)ra(t)&&(t=e.createTextNode(t)),o.appendChild(t);return o}function la(e){return"[object Range]"==Object.prototype.toString.apply(e)}function ca(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 da=["top","right","bottom","left","width","height"];class ua{constructor(e){const t=la(e);if(Object.defineProperty(this,"_source",{value:e._source||e,writable:!0,enumerable:!1}),yn(e)||t)if(t){const t=ua.getDomRangeRects(e);ha(this,ua.getBoundingRect(t))}else ha(this,e.getBoundingClientRect());else if(ur(e)){const{innerWidth:t,innerHeight:i}=e;ha(this,{top:0,right:t,bottom:i,left:0,width:t,height:i})}else ha(this,e)}clone(){return new ua(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)};return t.width=t.right-t.left,t.height=t.bottom-t.top,t.width<0||t.height<0?null:new ua(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(!ma(e)){let i=e.parentNode||e.commonAncestorContainer;for(;i&&!ma(i);){const e=new ua(i),n=t.getIntersection(e);if(!n)return null;n.getArea(){for(const t of e){const e=ga._getElementCallbacks(t.target);if(e)for(const i of e)i(t)}}))}}ga._observerInstance=null,ga._elementCallbacks=null;class fa{constructor(e){this._callback=e,this._elements=new Set,this._previousRects=new Map,this._periodicCheckTimeout=null}observe(e){this._elements.add(e),this._checkElementRectsAndExecuteCallback(),1===this._elements.size&&this._startPeriodicCheck()}unobserve(e){this._elements.delete(e),this._previousRects.delete(e),this._elements.size||this._stopPeriodicCheck()}_startPeriodicCheck(){const e=()=>{this._checkElementRectsAndExecuteCallback(),this._periodicCheckTimeout=setTimeout(e,100)};this.listenTo(Zo.window,"resize",(()=>{this._checkElementRectsAndExecuteCallback()})),this._periodicCheckTimeout=setTimeout(e,100)}_stopPeriodicCheck(){clearTimeout(this._periodicCheckTimeout),this.stopListening(),this._previousRects.clear()}_checkElementRectsAndExecuteCallback(){const e=[];for(const t of this._elements)this._hasRectChanged(t)&&e.push({target:t,contentRect:this._previousRects.get(t)});e.length&&this._callback(e)}_hasRectChanged(e){if(!e.ownerDocument.body.contains(e))return!1;const t=new ua(e),i=this._previousRects.get(e),n=!i||!i.isEqual(t);return this._previousRects.set(e,t),n}}dt(fa,hr);function pa({target:e,viewportOffset:t=0}){const i=Ca(e);let n=i,s=null;for(;n;){let o;o=Aa(n==i?e:s),ba(o,(()=>xa(e,n)));const r=xa(e,n);if(wa(n,r,t),n.parent!=n){if(s=n.frameElement,n=n.parent,!s)return}else n=null}}function wa(e,t,i){const n=t.clone().moveBy(0,i),s=t.clone().moveBy(0,-i),o=new ua(e).excludeScrollbarsAndBorders();if(![s,n].every((e=>o.contains(e)))){let{scrollX:r,scrollY:a}=e;_a(s,o)?a-=o.top-t.top+i:va(n,o)&&(a+=t.bottom-o.bottom+i),ya(t,o)?r-=o.left-t.left+i:ka(t,o)&&(r+=t.right-o.right+i),e.scrollTo(r,a)}}function ba(e,t){const i=Ca(e);let n,s;for(;e!=i.document.body;)s=t(),n=new ua(e).excludeScrollbarsAndBorders(),n.contains(s)||(_a(s,n)?e.scrollTop-=n.top-s.top:va(s,n)&&(e.scrollTop+=s.bottom-n.bottom),ya(s,n)?e.scrollLeft-=n.left-s.left:ka(s,n)&&(e.scrollLeft+=s.right-n.right)),e=e.parentNode}function va(e,t){return e.bottom>t.bottom}function _a(e,t){return e.topt.right}function Ca(e){return la(e)?e.startContainer.ownerDocument.defaultView:e.ownerDocument.defaultView}function Aa(e){if(la(e)){let t=e.commonAncestorContainer;return Ro(t)&&(t=t.parentNode),t}return e.parentNode}function xa(e,t){const i=Ca(e),n=new ua(e);if(i===t)return n;{let e=i;for(;e!=t;){const t=e.frameElement,i=new ua(t).excludeScrollbarsAndBorders();n.moveBy(i.left,i.top),e=e.parent}}return n}function Ta(e){const t=e.next();return t.done?null:t.value}Object.assign({},{scrollViewportToShowTarget:pa,scrollAncestorsToShowTarget:function(e){ba(Aa(e),(()=>new ua(e)))}});class Ea{constructor(){this.set("isFocused",!1),this.set("focusedElement",null),this._elements=new Set,this._nextEventLoopTimeout=null}add(e){if(this._elements.has(e))throw new l("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(e),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)}}dt(Ea,hr),dt(Ea,st);class Pa{constructor(){this._listener=Object.create(hr)}listenTo(e){this._listener.listenTo(e,"keydown",((e,t)=>{this._listener.fire("_keydown:"+co(t),t)}))}set(e,t,i={}){const n=uo(e),s=i.priority;this._listener.listenTo(this._listener,"_keydown:"+n,((e,i)=>{t(i,(()=>{i.preventDefault(),i.stopPropagation(),e.stop()})),e.return=!0}),{priority:s})}press(e){return!!this._listener.fire("_keydown:"+co(e),e)}destroy(){this._listener.stopListening()}}class Sa extends fr{constructor(e){super(e),this.document.on("keydown",((e,t)=>{if(this.isEnabled&&((i=t.keyCode)==ao.arrowright||i==ao.arrowleft||i==ao.arrowup||i==ao.arrowdown)){const i=new js(this.document,"arrowKey",this.document.selection.getFirstRange());this.document.fire(i,t),i.stop.called&&e.stop()}var i}))}observe(){}}class Ia extends fr{constructor(e){super(e);const t=this.document;t.on("keydown",((e,i)=>{if(!this.isEnabled||i.keyCode!=ao.tab||i.ctrlKey)return;const n=new js(t,"tab",t.selection.getFirstRange());t.fire(n,i),n.stop.called&&e.stop()}))}observe(){}}class Ra{constructor(e){this.document=new Js(e),this.domConverter=new ar(this.document),this.domRoots=new Map,this.set("isRenderingInProgress",!1),this.set("hasDomSelection",!1),this._renderer=new Go(this.domConverter,this.document.selection),this._renderer.bind("isFocused","isSelecting").to(this.document),this._initialDomRootAttributes=new WeakMap,this._observers=new Map,this._ongoingChange=!1,this._postFixersInProgress=!1,this._renderingDisabled=!1,this._hasChangedSinceTheLastRendering=!1,this._writer=new _o(this.document),this.addObserver(Dr),this.addObserver(ta),this.addObserver(ia),this.addObserver(Fr),this.addObserver(ea),this.addObserver(na),this.addObserver(Sa),this.addObserver(Ia),no.isAndroid&&this.addObserver(sa),this.document.on("arrowKey",Lo,{priority:"low"}),fo(this),this.on("render",(()=>{this._render(),this.document.fire("layoutChanged"),this._hasChangedSinceTheLastRendering=!1})),this.listenTo(this.document.selection,"change",(()=>{this._hasChangedSinceTheLastRendering=!0})),this.listenTo(this.document,"change:isFocused",(()=>{this._hasChangedSinceTheLastRendering=!0}))}attachDomRoot(e,t="main"){const i=this.document.getRoot(t);i._name=e.tagName.toLowerCase();const n={};for(const{name:t,value:s}of Array.from(e.attributes))n[t]=s,"class"===t?this._writer.addClass(s.split(" "),i):this._writer.setAttribute(t,s,i);this._initialDomRootAttributes.set(e,n);const s=()=>{this._writer.setAttribute("contenteditable",!i.isReadOnly,i),i.isReadOnly?this._writer.addClass("ck-read-only",i):this._writer.removeClass("ck-read-only",i)};s(),this.domRoots.set(t,e),this.domConverter.bindElements(e,i),this._renderer.markToSync("children",i),this._renderer.markToSync("attributes",i),this._renderer.domDocuments.add(e.ownerDocument),i.on("change:children",((e,t)=>this._renderer.markToSync("children",t))),i.on("change:attributes",((e,t)=>this._renderer.markToSync("attributes",t))),i.on("change:text",((e,t)=>this._renderer.markToSync("text",t))),i.on("change:isReadOnly",(()=>this.change(s))),i.on("change",(()=>{this._hasChangedSinceTheLastRendering=!0}));for(const i of this._observers.values())i.observe(e,t)}detachDomRoot(e){const t=this.domRoots.get(e);Array.from(t.attributes).forEach((({name:e})=>t.removeAttribute(e)));const i=this._initialDomRootAttributes.get(t);for(const e in i)t.setAttribute(e,i[e]);this.domRoots.delete(e),this.domConverter.unbindDomElement(t)}getDomRoot(e="main"){return this.domRoots.get(e)}addObserver(e){let t=this._observers.get(e);if(t)return t;t=new e(this),this._observers.set(e,t);for(const[e,i]of this.domRoots)t.observe(i,e);return t.enable(),t}getObserver(e){return this._observers.get(e)}disableObservers(){for(const e of this._observers.values())e.disable()}enableObservers(){for(const e of this._observers.values())e.enable()}scrollToTheSelection(){const e=this.document.selection.getFirstRange();e&&pa({target:this.domConverter.viewRangeToDom(e),viewportOffset:20})}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 l("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){l.rethrowUnexpectedError(e,this)}}forceRender(){this._hasChangedSinceTheLastRendering=!0,this.change((()=>{}))}destroy(){for(const e of this._observers.values())e.destroy();this.document.destroy(),this.stopListening()}createPositionAt(e,t){return Ns._createAt(e,t)}createPositionAfter(e){return Ns._createAfter(e)}createPositionBefore(e){return Ns._createBefore(e)}createRange(e,t){return new Ds(e,t)}createRangeOn(e){return Ds._createOn(e)}createRangeIn(e){return Ds._createIn(e)}createSelection(e,t,i){return new Fs(e,t,i)}_disableRendering(e){this._renderingDisabled=e,0==e&&this.change((()=>{}))}_render(){this.isRenderingInProgress=!0,this.disableObservers(),this._renderer.render(),this.enableObservers(),this.isRenderingInProgress=!1}}dt(Ra,st);class Va{constructor(e){this.parent=null,this._attrs=Fn(e)}get index(){let e;if(!this.parent)return null;if(null===(e=this.parent.getChildIndex(this)))throw new l("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 l("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 this.root.is("rootElement")}getPath(){const e=[];let t=this;for(;t.parent;)e.unshift(t.startOffset),t=t.parent;return e}getAncestors(e={includeSelf:!1,parentFirst:!1}){const t=[];let i=e.includeSelf?this:this.parent;for(;i;)t[e.parentFirst?"push":"unshift"](i),i=i.parent;return t}getCommonAncestor(e,t={}){const i=this.getAncestors(t),n=e.getAncestors(t);let s=0;for(;i[s]==n[s]&&i[s];)s++;return 0===s?null:i[s-1]}isBefore(e){if(this==e)return!1;if(this.root!==e.root)return!1;const t=this.getPath(),i=e.getPath(),n=Mn(t,i);switch(n){case"prefix":return!0;case"extension":return!1;default:return t[n](e[t[0]]=t[1],e)),{})),e}is(e){return"node"===e||"model:node"===e}_clone(){return new Va(this._attrs)}_remove(){this.parent._removeChildren(this.index)}_setAttribute(e,t){this._attrs.set(e,t)}_setAttributesTo(e){this._attrs=Fn(e)}_removeAttribute(e){return this._attrs.delete(e)}_clearAttributes(){this._attrs.clear()}}class Oa extends Va{constructor(e,t){super(t),this._data=e||""}get offsetSize(){return this.data.length}get data(){return this._data}is(e){return"$text"===e||"model:$text"===e||"text"===e||"model:text"===e||"node"===e||"model:node"===e}toJSON(){const e=super.toJSON();return e.data=this.data,e}_clone(){return new Oa(this.data,this.getAttributes())}static fromJSON(e){return new Oa(e.data,e.attributes)}}class Ba{constructor(e,t,i){if(this.textNode=e,t<0||t>e.offsetSize)throw new l("model-textproxy-wrong-offsetintext",this);if(i<0||t+i>e.offsetSize)throw new l("model-textproxy-wrong-length",this);this.data=e.data.substring(t,t+i),this.offsetInText=t}get startOffset(){return null!==this.textNode.startOffset?this.textNode.startOffset+this.offsetInText:null}get offsetSize(){return this.data.length}get endOffset(){return null!==this.startOffset?this.startOffset+this.offsetSize:null}get isPartial(){return this.offsetSize!==this.textNode.offsetSize}get parent(){return this.textNode.parent}get root(){return this.textNode.root}is(e){return"$textProxy"===e||"model:$textProxy"===e||"textProxy"===e||"model:textProxy"===e}getPath(){const e=this.textNode.getPath();return e.length>0&&(e[e.length-1]+=this.offsetInText),e}getAncestors(e={includeSelf:!1,parentFirst:!1}){const t=[];let i=e.includeSelf?this:this.parent;for(;i;)t[e.parentFirst?"push":"unshift"](i),i=i.parent;return t}hasAttribute(e){return this.textNode.hasAttribute(e)}getAttribute(e){return this.textNode.getAttribute(e)}getAttributes(){return this.textNode.getAttributes()}getAttributeKeys(){return this.textNode.getAttributeKeys()}}class Ma{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 l("model-nodelist-index-out-of-bounds",this);return this.getNodeStartOffset(t)}offsetToIndex(e){let t=0;for(const i of this._nodes){if(e>=t&&ee.toJSON()))}}class Na extends Va{constructor(e,t,i){super(t),this.name=e,this._children=new Ma,i&&this._insertChild(0,i)}get childCount(){return this._children.length}get maxOffset(){return this._children.maxOffset}get isEmpty(){return 0===this.childCount}is(e,t=null){return t?t===this.name&&("element"===e||"model:element"===e):"element"===e||"model:element"===e||"node"===e||"model:node"===e}getChild(e){return this._children.getNode(e)}getChildren(){return this._children[Symbol.iterator]()}getChildIndex(e){return this._children.getNodeIndex(e)}getChildStartOffset(e){return this._children.getNodeStartOffset(e)}offsetToIndex(e){return this._children.offsetToIndex(e)}getNodeByPath(e){let t=this;for(const i of e)t=t.getChild(t.offsetToIndex(i));return t}findAncestor(e,t={includeSelf:!1}){let i=t.includeSelf?this:this.parent;for(;i;){if(i.name===e)return i;i=i.parent}return null}toJSON(){const e=super.toJSON();if(e.name=this.name,this._children.length>0){e.children=[];for(const t of this._children)e.children.push(t.toJSON())}return e}_clone(e=!1){const t=e?Array.from(this._children).map((e=>e._clone(!0))):null;return new Na(this.name,this.getAttributes(),t)}_appendChild(e){this._insertChild(this.childCount,e)}_insertChild(e,t){const i=function(e){if("string"==typeof e)return[new Oa(e)];xn(e)||(e=[e]);return Array.from(e).map((e=>"string"==typeof e?new Oa(e):e instanceof Ba?new Oa(e.data,e.getAttributes()):e))}(t);for(const e of i)null!==e.parent&&e._remove(),e.parent=this;this._children._insertNodes(e,i)}_removeChildren(e,t=1){const i=this._children._removeNodes(e,t);for(const e of i)e.parent=null;return i}static fromJSON(e){let t=null;if(e.children){t=[];for(const i of e.children)i.name?t.push(Na.fromJSON(i)):t.push(Oa.fromJSON(i))}return new Na(e.name,e.attributes,t)}}class Da{constructor(e={}){if(!e.boundaries&&!e.startPosition)throw new l("model-tree-walker-no-start-position",null);const t=e.direction||"forward";if("forward"!=t&&"backward"!=t)throw new l("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=La._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}skip(e){let t,i,n,s;do{n=this.position,s=this._visitedParent,({done:t,value:i}=this.next())}while(!t&&e(i));t||(this.position=n,this._visitedParent=s)}next(){return"forward"==this.direction?this._next():this._previous()}_next(){const e=this.position,t=this.position.clone(),i=this._visitedParent;if(null===i.parent&&t.offset===i.maxOffset)return{done:!0};if(i===this._boundaryEndParent&&t.offset==this.boundaries.end.offset)return{done:!0};const n=Fa(t,i),s=n||Ha(t,i,n);if(s instanceof Na)return this.shallow?t.offset++:(t.path.push(0),this._visitedParent=s),this.position=t,za("elementStart",s,e,t,1);if(s instanceof Oa){let n;if(this.singleCharacters)n=1;else{let e=s.endOffset;this._boundaryEndParent==i&&this.boundaries.end.offsete&&(e=this.boundaries.start.offset),n=t.offset-e}const s=t.offset-o.startOffset,r=new Ba(o,s-n,n);return t.offset-=n,this.position=t,za("text",r,e,t,n)}return t.path.pop(),this.position=t,this._visitedParent=i.parent,za("elementStart",i,e,t,1)}}function za(e,t,i,n,s){return{done:!1,value:{type:e,item:t,previousPosition:i,nextPosition:n,length:s}}}class La{constructor(e,t,i="toNone"){if(!e.is("element")&&!e.is("documentFragment"))throw new l("model-position-root-invalid",e);if(!(t instanceof Array)||0===t.length)throw new l("model-position-path-incorrect-format",e,{path:t});e.is("rootElement")?t=t.slice():(t=[...e.getPath(),...t],e=e.root),this.root=e,this.path=t,this.stickiness=i}get offset(){return this.path[this.path.length-1]}set offset(e){this.path[this.path.length-1]=e}get parent(){let e=this.root;for(let t=0;ti.path.length){if(t.offset!==n.maxOffset)return!1;t.path=t.path.slice(0,-1),n=n.parent,t.offset++}else{if(0!==i.offset)return!1;i.path=i.path.slice(0,-1)}}}is(e){return"position"===e||"model:position"===e}hasSameParentAs(e){if(this.root!==e.root)return!1;return"same"==Mn(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=La._createAt(this)}return t}_getTransformedByInsertOperation(e){return this._getTransformedByInsertion(e.position,e.howMany)}_getTransformedByMoveOperation(e){return this._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany)}_getTransformedBySplitOperation(e){const t=e.movedRange;return t.containsPosition(this)||t.start.isEqual(this)&&"toNext"==this.stickiness?this._getCombined(e.splitPosition,e.moveTargetPosition):e.graveyardPosition?this._getTransformedByMove(e.graveyardPosition,e.insertionPosition,1):this._getTransformedByInsertion(e.insertionPosition,1)}_getTransformedByMergeOperation(e){const t=e.movedRange;let i;return t.containsPosition(this)||t.start.isEqual(this)?(i=this._getCombined(e.sourcePosition,e.targetPosition),e.sourcePosition.isBefore(e.targetPosition)&&(i=i._getTransformedByDeletion(e.deletionPosition,1))):i=this.isEqual(e.deletionPosition)?La._createAt(e.deletionPosition):this._getTransformedByMove(e.deletionPosition,e.graveyardPosition,1),i}_getTransformedByDeletion(e,t){const i=La._createAt(this);if(this.root!=e.root)return i;if("same"==Mn(e.getParentPath(),this.getParentPath())){if(e.offsetthis.offset)return null;i.offset-=t}}else if("prefix"==Mn(e.getParentPath(),this.getParentPath())){const n=e.path.length-1;if(e.offset<=this.path[n]){if(e.offset+t>this.path[n])return null;i.path[n]-=t}}return i}_getTransformedByInsertion(e,t){const i=La._createAt(this);if(this.root!=e.root)return i;if("same"==Mn(e.getParentPath(),this.getParentPath()))(e.offsett+1;){const t=n.maxOffset-i.offset;0!==t&&e.push(new Wa(i,i.getShiftedBy(t))),i.path=i.path.slice(0,-1),i.offset++,n=n.parent}for(;i.path.length<=this.end.path.length;){const t=this.end.path[i.path.length-1],n=t-i.offset;0!==n&&e.push(new Wa(i,i.getShiftedBy(n))),i.offset=t,i.path.push(0)}return e}getWalker(e={}){return e.boundaries=this,new Da(e)}*getItems(e={}){e.boundaries=this,e.ignoreElementEnd=!0;const t=new Da(e);for(const e of t)yield e.item}*getPositions(e={}){e.boundaries=this;const t=new Da(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 Wa(this.start,this.end)]}getTransformedByOperations(e){const t=[new Wa(this.start,this.end)];for(const i of e)for(let e=0;e0?new this(i,n):new this(n,i)}static _createIn(e){return new this(La._createAt(e,0),La._createAt(e,e.maxOffset))}static _createOn(e){return this._createFromPositionAndShift(La._createBefore(e),e.offsetSize)}static _createFromRanges(e){if(0===e.length)throw new l("range-create-from-ranges-empty-array",null);if(1==e.length)return e[0].clone();const t=e[0];e.sort(((e,t)=>e.start.isAfter(t.start)?1:-1));const i=e.indexOf(t),n=new this(t.start,t.end);if(i>0)for(let t=i-1;e[t].end.isEqual(n.start);t++)n.start=La._createAt(e[t].start);for(let t=i+1;t{if(t.viewPosition)return;const i=this._modelToViewMapping.get(t.modelPosition.parent);if(!i)throw new l("mapping-model-position-view-parent-not-found",this,{modelPosition:t.modelPosition});t.viewPosition=this.findPositionIn(i,t.modelPosition.offset)}),{priority:"low"}),this.on("viewToModelPosition",((e,t)=>{if(t.modelPosition)return;const i=this.findMappedViewAncestor(t.viewPosition),n=this._viewToModelMapping.get(i),s=this._toModelOffset(t.viewPosition.parent,t.viewPosition.offset,i);t.modelPosition=La._createAt(n,s)}),{priority:"low"})}bindElements(e,t){this._modelToViewMapping.set(e,t),this._viewToModelMapping.set(t,e)}unbindViewElement(e,t={}){const i=this.toModelElement(e);if(this._elementToMarkerNames.has(e))for(const t of this._elementToMarkerNames.get(e))this._unboundMarkerNames.add(t);t.defer?this._deferredBindingRemovals.set(e,e.root):(this._viewToModelMapping.delete(e),this._modelToViewMapping.get(i)==e&&this._modelToViewMapping.delete(i))}unbindModelElement(e){const t=this.toViewElement(e);this._modelToViewMapping.delete(e),this._viewToModelMapping.get(t)==e&&this._viewToModelMapping.delete(t)}bindElementToMarker(e,t){const i=this._markerNameToElements.get(t)||new Set;i.add(e);const n=this._elementToMarkerNames.get(e)||new Set;n.add(t),this._markerNameToElements.set(t,i),this._elementToMarkerNames.set(e,n)}unbindElementFromMarkerName(e,t){const i=this._markerNameToElements.get(t);i&&(i.delete(e),0==i.size&&this._markerNameToElements.delete(t));const n=this._elementToMarkerNames.get(e);n&&(n.delete(t),0==n.size&&this._elementToMarkerNames.delete(e))}flushUnboundMarkerNames(){const e=Array.from(this._unboundMarkerNames);return this._unboundMarkerNames.clear(),e}flushDeferredBindings(){for(const[e,t]of this._deferredBindingRemovals)e.root==t&&this.unbindViewElement(e);this._deferredBindingRemovals=new Map}clearBindings(){this._modelToViewMapping=new WeakMap,this._viewToModelMapping=new WeakMap,this._markerNameToElements=new Map,this._elementToMarkerNames=new Map,this._unboundMarkerNames=new Set,this._deferredBindingRemovals=new Map}toModelElement(e){return this._viewToModelMapping.get(e)}toViewElement(e){return this._modelToViewMapping.get(e)}toModelRange(e){return new Wa(this.toModelPosition(e.start),this.toModelPosition(e.end))}toViewRange(e){return new Ds(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={isPhantom:!1}){const i={modelPosition:e,mapper:this,isPhantom:t.isPhantom};return this.fire("modelToViewPosition",i),i.viewPosition}markerNameToElements(e){const t=this._markerNameToElements.get(e);if(!t)return null;const i=new Set;for(const e of t)if(e.is("attributeElement"))for(const t of e.getElementsWithSameId())i.add(t);else i.add(e);return i}registerViewToModelLength(e,t){this._viewToModelLengthCallbacks.set(e,t)}findMappedViewAncestor(e){let t=e.parent;for(;!this._viewToModelMapping.has(t);)t=t.parent;return t}_toModelOffset(e,t,i){if(i!=e){return this._toModelOffset(e.parent,e.index,i)+this._toModelOffset(e,t,e)}if(e.is("$text"))return t;let n=0;for(let i=0;i1?t[0]+":"+t[1]:t[0]}class Ka{constructor(e){this._conversionApi={dispatcher:this,...e},this._firedEventsMap=new WeakMap}convertChanges(e,t,i){const n=this._createConversionApi(i,e.getRefreshedItems());for(const t of e.getMarkersToRemove())this._convertMarkerRemove(t.name,t.range,n);const s=this._reduceChanges(e.getChanges());for(const e of s)"insert"===e.type?this._convertInsert(Wa._createFromPositionAndShift(e.position,e.length),n):"reinsert"===e.type?this._convertReinsert(Wa._createFromPositionAndShift(e.position,e.length),n):"remove"===e.type?this._convertRemove(e.position,e.length,e.name,n):this._convertAttribute(e.range,e.attributeKey,e.attributeOldValue,e.attributeNewValue,n);for(const e of n.mapper.flushUnboundMarkerNames()){const i=t.get(e).getRange();this._convertMarkerRemove(e,i,n),this._convertMarkerAdd(e,i,n)}for(const t of e.getMarkersToAdd())this._convertMarkerAdd(t.name,t.range,n);n.mapper.flushDeferredBindings(),n.consumable.verifyAllConsumed("insert")}convert(e,t,i,n={}){const s=this._createConversionApi(i,void 0,n);this._convertInsert(e,s);for(const[e,i]of t)this._convertMarkerAdd(e,i,s);s.consumable.verifyAllConsumed("insert")}convertSelection(e,t,i){const n=Array.from(t.getMarkersAtPosition(e.getFirstPosition())),s=this._createConversionApi(i);if(this._addConsumablesForSelection(s.consumable,e,n),this.fire("selection",{selection:e},s),e.isCollapsed){for(const t of n){const i=t.getRange();if(!Ga(e.getFirstPosition(),t,s.mapper))continue;const n={item:e,markerName:t.name,markerRange:i};s.consumable.test(e,"addMarker:"+t.name)&&this.fire("addMarker:"+t.name,n,s)}for(const t of e.getAttributeKeys()){const i={item:e,range:e.getFirstRange(),attributeKey:t,attributeOldValue:null,attributeNewValue:e.getAttribute(t)};s.consumable.test(e,"attribute:"+i.attributeKey)&&this.fire("attribute:"+i.attributeKey+":$text",i,s)}}}_convertInsert(e,t,i={}){i.doNotAddConsumables||this._addConsumablesForInsert(t.consumable,Array.from(e));for(const i of Array.from(e.getWalker({shallow:!0})).map(Ja))this._testAndFire("insert",i,t)}_convertRemove(e,t,i,n){this.fire("remove:"+i,{position:e,length:t},n)}_convertAttribute(e,t,i,n,s){this._addConsumablesForRange(s.consumable,e,`attribute:${t}`);for(const o of e){const e={item:o.item,range:Wa._createFromPositionAndShift(o.previousPosition,o.length),attributeKey:t,attributeOldValue:i,attributeNewValue:n};this._testAndFire(`attribute:${t}`,e,s)}}_convertReinsert(e,t){const i=Array.from(e.getWalker({shallow:!0}));this._addConsumablesForInsert(t.consumable,i);for(const e of i.map(Ja))this._testAndFire("insert",{...e,reconversion:!0},t)}_convertMarkerAdd(e,t,i){if("$graveyard"==t.root.rootName)return;const n="addMarker:"+e;if(i.consumable.add(t,n),this.fire(n,{markerName:e,markerRange:t},i),i.consumable.consume(t,n)){this._addConsumablesForRange(i.consumable,t,n);for(const s of t.getItems()){if(!i.consumable.test(s,n))continue;const o={item:s,range:Wa._createOn(s),markerName:e,markerRange:t};this.fire(n,o,i)}}}_convertMarkerRemove(e,t,i){"$graveyard"!=t.root.rootName&&this.fire("removeMarker:"+e,{markerName:e,markerRange:t},i)}_reduceChanges(e){const t={changes:e};return this.fire("reduceChanges",t),t.changes}_addConsumablesForInsert(e,t){for(const i of t){const t=i.item;if(null===e.test(t,"insert")){e.add(t,"insert");for(const i of t.getAttributeKeys())e.add(t,"attribute:"+i)}}return e}_addConsumablesForRange(e,t,i){for(const n of t.getItems())e.add(n,i);return e}_addConsumablesForSelection(e,t,i){e.add(t,"selection");for(const n of i)e.add(t,"addMarker:"+n.name);for(const i of t.getAttributeKeys())e.add(t,"attribute:"+i);return e}_testAndFire(e,t,i){const n=function(e,t){const i=t.item.name||"$text";return`${e}:${i}`}(e,t),s=t.item.is("$textProxy")?i.consumable._getSymbolForTextProxy(t.item):t.item,o=this._firedEventsMap.get(i),r=o.get(s);if(r){if(r.has(n))return;r.add(n)}else o.set(s,new Set([n]));this.fire(n,t,i)}_testAndFireAddAttributes(e,t){const i={item:e,range:Wa._createOn(e)};for(const e of i.item.getAttributeKeys())i.attributeKey=e,i.attributeOldValue=null,i.attributeNewValue=i.item.getAttribute(e),this._testAndFire(`attribute:${e}`,i,t)}_createConversionApi(e,t=new Set,i={}){const n={...this._conversionApi,consumable:new qa,writer:e,options:i,convertItem:e=>this._convertInsert(Wa._createOn(e),n),convertChildren:e=>this._convertInsert(Wa._createIn(e),n,{doNotAddConsumables:!0}),convertAttributes:e=>this._testAndFireAddAttributes(e,n),canReuseView:e=>!t.has(n.mapper.toModelElement(e))};return this._firedEventsMap.set(n,new Map),n}}function Ga(e,t,i){const n=t.getRange(),s=Array.from(e.getAncestors());s.shift(),s.reverse();return!s.some((e=>{if(n.containsItem(e)){return!!i.toViewElement(e).getCustomProperty("addHighlight")}}))}function Ja(e){return{item:e.item,range:Wa._createFromPositionAndShift(e.previousPosition,e.length)}}dt(Ka,p);class Ya{constructor(e,t,i){this._lastRangeBackward=!1,this._ranges=[],this._attrs=new Map,e&&this.setTo(e,t,i)}get anchor(){if(this._ranges.length>0){const e=this._ranges[this._ranges.length-1];return this._lastRangeBackward?e.end:e.start}return null}get focus(){if(this._ranges.length>0){const e=this._ranges[this._ranges.length-1];return this._lastRangeBackward?e.start:e.end}return null}get isCollapsed(){return 1===this._ranges.length&&this._ranges[0].isCollapsed}get rangeCount(){return this._ranges.length}get isBackward(){return!this.isCollapsed&&this._lastRangeBackward}isEqual(e){if(this.rangeCount!=e.rangeCount)return!1;if(0===this.rangeCount)return!0;if(!this.anchor.isEqual(e.anchor)||!this.focus.isEqual(e.focus))return!1;for(const t of this._ranges){let i=!1;for(const n of e._ranges)if(t.isEqual(n)){i=!0;break}if(!i)return!1}return!0}*getRanges(){for(const e of this._ranges)yield new Wa(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 Wa(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 Wa(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,t,i){if(null===e)this._setRanges([]);else if(e instanceof Ya)this._setRanges(e.getRanges(),e.isBackward);else if(e&&"function"==typeof e.getRanges)this._setRanges(e.getRanges(),e.isBackward);else if(e instanceof Wa)this._setRanges([e],!!t&&!!t.backward);else if(e instanceof La)this._setRanges([new Wa(e)]);else if(e instanceof Va){const n=!!i&&!!i.backward;let s;if("in"==t)s=Wa._createIn(e);else if("on"==t)s=Wa._createOn(e);else{if(void 0===t)throw new l("model-selection-setto-required-second-parameter",[this,e]);s=new Wa(La._createAt(e,t))}this._setRanges([s],n)}else{if(!xn(e))throw new l("model-selection-setto-not-selectable",[this,e]);this._setRanges(e,t&&!!t.backward)}}_setRanges(e,t=!1){const i=(e=Array.from(e)).some((t=>{if(!(t instanceof Wa))throw new l("model-selection-set-ranges-not-range",[this,e]);return this._ranges.every((e=>!e.isEqual(t)))}));if(e.length!==this._ranges.length||i){this._removeAllRanges();for(const t of e)this._pushRange(t);this._lastRangeBackward=!!t,this.fire("change:range",{directChange:!0})}}setFocus(e,t){if(null===this.anchor)throw new l("model-selection-setfocus-no-ranges",[this,e]);const i=La._createAt(e,t);if("same"==i.compareWith(this.focus))return;const n=this.anchor;this._ranges.length&&this._popRange(),"before"==i.compareWith(n)?(this._pushRange(new Wa(i,n)),this._lastRangeBackward=!0):(this._pushRange(new Wa(n,i)),this._lastRangeBackward=!1),this.fire("change:range",{directChange:!0})}getAttribute(e){return this._attrs.get(e)}getAttributes(){return this._attrs.entries()}getAttributeKeys(){return this._attrs.keys()}hasAttribute(e){return this._attrs.has(e)}removeAttribute(e){this.hasAttribute(e)&&(this._attrs.delete(e),this.fire("change:attribute",{attributeKeys:[e],directChange:!0}))}setAttribute(e,t){this.getAttribute(e)!==t&&(this._attrs.set(e,t),this.fire("change:attribute",{attributeKeys:[e],directChange:!0}))}getSelectedElement(){return 1!==this.rangeCount?null:this.getFirstRange().getContainedElement()}is(e){return"selection"===e||"model:selection"===e}*getSelectedBlocks(){const e=new WeakSet;for(const t of this.getRanges()){const i=Xa(t.start,e);i&&el(i,t)&&(yield i);for(const i of t.getWalker()){const n=i.item;"elementEnd"==i.type&&Za(n,e,t)&&(yield n)}const n=Xa(t.end,e);n&&!t.end.isTouching(La._createAt(n,0))&&el(n,t)&&(yield n)}}containsEntireContent(e=this.anchor.root){const t=La._createAt(e,0),i=La._createAt(e,"end");return t.isTouching(this.getFirstPosition())&&i.isTouching(this.getLastPosition())}_pushRange(e){this._checkRange(e),this._ranges.push(new Wa(e.start,e.end))}_checkRange(e){for(let t=0;t0;)this._popRange()}_popRange(){this._ranges.pop()}}function Qa(e,t){return!t.has(e)&&(t.add(e),e.root.document.model.schema.isBlock(e)&&e.parent)}function Za(e,t,i){return Qa(e,t)&&el(e,i)}function Xa(e,t){const i=e.parent.root.document.model.schema,n=e.parent.getAncestors({parentFirst:!0,includeSelf:!0});let s=!1;const o=n.find((e=>!s&&(s=i.isLimit(e),!s&&Qa(e,t))));return n.forEach((e=>t.add(e))),o}function el(e,t){const i=function(e){const t=e.root.document.model.schema;let i=e.parent;for(;i;){if(t.isBlock(i))return i;i=i.parent}}(e);if(!i)return!0;return!t.containsRange(Wa._createOn(i),!0)}dt(Ya,p);class tl extends Wa{constructor(e,t){super(e,t),il.call(this)}detach(){this.stopListening()}is(e){return"liveRange"===e||"model:liveRange"===e||"range"==e||"model:range"===e}toRange(){return new Wa(this.start,this.end)}static fromRange(e){return new tl(e.start,e.end)}}function il(){this.listenTo(this.root.document.model,"applyOperation",((e,t)=>{const i=t[0];i.isDocumentOperation&&nl.call(this,i)}),{priority:"low"})}function nl(e){const t=this.getTransformedByOperation(e),i=Wa._createFromRanges(t),n=!i.isEqual(this),s=function(e,t){switch(t.type){case"insert":return e.containsPosition(t.position);case"move":case"remove":case"reinsert":case"merge":return e.containsPosition(t.sourcePosition)||e.start.isEqual(t.sourcePosition)||e.containsPosition(t.targetPosition);case"split":return e.containsPosition(t.splitPosition)||e.containsPosition(t.insertionPosition)}return!1}(this,e);let o=null;if(n){"$graveyard"==i.root.rootName&&(o="remove"==e.type?e.sourcePosition:e.deletionPosition);const t=this.toRange();this.start=i.start,this.end=i.end,this.fire("change:range",t,{deletionPosition:o})}else s&&this.fire("change:content",this.toRange(),{deletionPosition:o})}dt(tl,p);const sl="selection:";class ol{constructor(e){this._selection=new rl(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)}is(e){return"selection"===e||"model:selection"==e||"documentSelection"==e||"model:documentSelection"==e}_setFocus(e,t){this._selection.setFocus(e,t)}_setTo(e,t,i){this._selection.setTo(e,t,i)}_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 sl+e}static _isStoreAttributeKey(e){return e.startsWith(sl)}}dt(ol,p);class rl extends Ya{constructor(e){super(),this.markers=new Tn({idProperty:"name"}),this._model=e.model,this._document=e,this._attributePriority=new Map,this._selectionRestorePosition=null,this._hasChangedRange=!1,this._overriddenGravityRegister=new Set,this._observedMarkers=new Set,this.listenTo(this._model,"applyOperation",((e,t)=>{const i=t[0];i.isDocumentOperation&&"marker"!=i.type&&"rename"!=i.type&&"noop"!=i.type&&(0==this._ranges.length&&this._selectionRestorePosition&&this._fixGraveyardSelection(this._selectionRestorePosition),this._selectionRestorePosition=null,this._hasChangedRange&&(this._hasChangedRange=!1,this.fire("change:range",{directChange:!1})))}),{priority:"lowest"}),this.on("change:range",(()=>{for(const e of this.getRanges())if(!this._document._validateSelectionRange(e))throw new l("document-selection-wrong-position",this,{range:e})})),this.listenTo(this._model.markers,"update",((e,t,i,n)=>{this._updateMarker(t,n)})),this.listenTo(this._document,"change",((e,t)=>{!function(e,t){const i=e.document.differ;for(const n of i.getChanges()){if("insert"!=n.type)continue;const i=n.position.parent;n.length===i.maxOffset&&e.enqueueChange(t,(e=>{const t=Array.from(i.getAttributeKeys()).filter((e=>e.startsWith(sl)));for(const n of t)e.removeAttribute(n,i)}))}}(this._model,t)}))}get isCollapsed(){return 0===this._ranges.length?this._document._getDefaultRange().isCollapsed:super.isCollapsed}get anchor(){return super.anchor||this._document._getDefaultRange().start}get focus(){return super.focus||this._document._getDefaultRange().end}get rangeCount(){return this._ranges.length?this._ranges.length:1}get hasOwnRange(){return this._ranges.length>0}get isGravityOverridden(){return!!this._overriddenGravityRegister.size}destroy(){for(let e=0;e{if(this._hasChangedRange=!0,t.root==this._document.graveyard){this._selectionRestorePosition=n.deletionPosition;const e=this._ranges.indexOf(t);this._ranges.splice(e,1),t.detach()}})),t}_updateMarkers(){if(!this._observedMarkers.size)return;const e=[];let t=!1;for(const t of this._model.markers){const i=t.name.split(":",1)[0];if(!this._observedMarkers.has(i))continue;const n=t.getRange();for(const i of this.getRanges())n.containsRange(i,!i.isCollapsed)&&e.push(t)}const i=Array.from(this.markers);for(const i of e)this.markers.has(i)||(this.markers.add(i),t=!0);for(const i of Array.from(this.markers))e.includes(i)||(this.markers.remove(i),t=!0);t&&this.fire("change:marker",{oldMarkers:i,directChange:!1})}_updateMarker(e,t){const i=e.name.split(":",1)[0];if(!this._observedMarkers.has(i))return;let n=!1;const s=Array.from(this.markers),o=this.markers.has(e);if(t){let i=!1;for(const e of this.getRanges())if(t.containsRange(e,!e.isCollapsed)){i=!0;break}i&&!o?(this.markers.add(e),n=!0):!i&&o&&(this.markers.remove(e),n=!0)}else o&&(this.markers.remove(e),n=!0);n&&this.fire("change:marker",{oldMarkers:s,directChange:!1})}_updateAttributes(e){const t=Fn(this._getSurroundingAttributes()),i=Fn(this.getAttributes());if(e)this._attributePriority=new Map,this._attrs=new Map;else for(const[e,t]of this._attributePriority)"low"==t&&(this._attrs.delete(e),this._attributePriority.delete(e));this._setAttributesTo(t);const n=[];for(const[e,t]of this.getAttributes())i.has(e)&&i.get(e)===t||n.push(e);for(const[e]of i)this.hasAttribute(e)||n.push(e);n.length>0&&this.fire("change:attribute",{attributeKeys:n,directChange:!1})}_setAttribute(e,t,i=!0){const n=i?"normal":"low";if("low"==n&&"normal"==this._attributePriority.get(e))return!1;return super.getAttribute(e)!==t&&(this._attrs.set(e,t),this._attributePriority.set(e,n),!0)}_removeAttribute(e,t=!0){const i=t?"normal":"low";return("low"!=i||"normal"!=this._attributePriority.get(e))&&(this._attributePriority.set(e,i),!!super.hasAttribute(e)&&(this._attrs.delete(e),!0))}_setAttributesTo(e){const t=new Set;for(const[t,i]of this.getAttributes())e.get(t)!==i&&this._removeAttribute(t,!1);for(const[i,n]of e){this._setAttribute(i,n,!1)&&t.add(i)}return t}*_getStoredAttributes(){const e=this.getFirstPosition().parent;if(this.isCollapsed&&e.isEmpty)for(const t of e.getAttributeKeys())if(t.startsWith(sl)){const i=t.substr(sl.length);yield[i,e.getAttribute(t)]}}_getSurroundingAttributes(){const e=this.getFirstPosition(),t=this._model.schema;let i=null;if(this.isCollapsed){const n=e.textNode?e.textNode:e.nodeBefore,s=e.textNode?e.textNode:e.nodeAfter;if(this.isGravityOverridden||(i=al(n)),i||(i=al(s)),!this.isGravityOverridden&&!i){let e=n;for(;e&&!t.isInline(e)&&!i;)e=e.previousSibling,i=al(e)}if(!i){let e=s;for(;e&&!t.isInline(e)&&!i;)e=e.nextSibling,i=al(e)}i||(i=this._getStoredAttributes())}else{const e=this.getFirstRange();for(const n of e){if(n.item.is("element")&&t.isObject(n.item))break;if("text"==n.type){i=n.item.getAttributes();break}}}return i}_fixGraveyardSelection(e){const t=this._model.schema.getNearestSelectionRange(e);t&&this._pushRange(t)}}function al(e){return e instanceof Ba||e instanceof Oa?e.getAttributes():null}class ll{constructor(e){this._dispatchers=e}add(e){for(const t of this._dispatchers)e(t);return this}}const cl=function(e){return vn(e,5)};class dl extends ll{elementToElement(e){return this.add(function(e){(e=cl(e)).model=ml(e.model),e.view=gl(e.view,"container"),e.model.attributes.length&&(e.model.children=!0);return t=>{t.on("insert:"+e.model.name,function(e,t=kl){return(i,n,s)=>{if(!t(n.item,s.consumable,{preflight:!0}))return;const o=e(n.item,s,n);if(!o)return;t(n.item,s.consumable);const r=s.mapper.toViewPosition(n.range.start);s.mapper.bindElements(n.item,o),s.writer.insert(r,o),s.convertAttributes(n.item),_l(o,n.item.getChildren(),s,{reconversion:n.reconversion})}}(e.view,vl(e.model)),{priority:e.converterPriority||"normal"}),(e.model.children||e.model.attributes.length)&&t.on("reduceChanges",bl(e.model),{priority:"low"})}}(e))}elementToStructure(e){return this.add(function(e){return(e=cl(e)).model=ml(e.model),e.view=gl(e.view,"container"),e.model.children=!0,t=>{if(t._conversionApi.schema.checkChild(e.model.name,"$text"))throw new l("conversion-element-to-structure-disallowed-text",t,{elementName:e.model.name});var i,n;t.on("insert:"+e.model.name,(i=e.view,n=vl(e.model),(e,t,s)=>{if(!n(t.item,s.consumable,{preflight:!0}))return;const o=new Map;s.writer._registerSlotFactory(function(e,t,i){return(n,s="children")=>{const o=n.createContainerElement("$slot");let r=null;if("children"===s)r=Array.from(e.getChildren());else{if("function"!=typeof s)throw new l("conversion-slot-mode-unknown",i.dispatcher,{modeOrFilter:s});r=Array.from(e.getChildren()).filter((e=>s(e)))}return t.set(o,r),o}}(t.item,o,s));const r=i(t.item,s,t);if(s.writer._clearSlotFactory(),!r)return;!function(e,t,i){const n=Array.from(t.values()).flat(),s=new Set(n);if(s.size!=n.length)throw new l("conversion-slot-filter-overlap",i.dispatcher,{element:e});if(s.size!=e.childCount)throw new l("conversion-slot-filter-incomplete",i.dispatcher,{element:e})}(t.item,o,s),n(t.item,s.consumable);const a=s.mapper.toViewPosition(t.range.start);s.mapper.bindElements(t.item,r),s.writer.insert(a,r),s.convertAttributes(t.item),function(e,t,i,n){i.mapper.on("modelToViewPosition",r,{priority:"highest"});let s=null,o=null;for([s,o]of t)_l(e,o,i,n),i.writer.move(i.writer.createRangeIn(s),i.writer.createPositionBefore(s)),i.writer.remove(s);function r(e,t){const i=t.modelPosition.nodeAfter,n=o.indexOf(i);n<0||(t.viewPosition=t.mapper.findPositionIn(s,n))}i.mapper.off("modelToViewPosition",r)}(r,o,s,{reconversion:t.reconversion})}),{priority:e.converterPriority||"normal"}),t.on("reduceChanges",bl(e.model),{priority:"low"})}}(e))}attributeToElement(e){return this.add(function(e){e=cl(e);let t="attribute:"+(e.model.key?e.model.key:e.model);e.model.name&&(t+=":"+e.model.name);if(e.model.values)for(const t of e.model.values)e.view[t]=gl(e.view[t],"attribute");else e.view=gl(e.view,"attribute");const i=fl(e);return n=>{n.on(t,function(e){return(t,i,n)=>{if(!n.consumable.test(i.item,t.name))return;const s=e(i.attributeOldValue,n,i),o=e(i.attributeNewValue,n,i);if(!s&&!o)return;n.consumable.consume(i.item,t.name);const r=n.writer,a=r.document.selection;if(i.item instanceof Ya||i.item instanceof ol)r.wrap(a.getFirstRange(),o);else{let e=n.mapper.toViewRange(i.range);null!==i.attributeOldValue&&s&&(e=r.unwrap(e,s)),null!==i.attributeNewValue&&o&&r.wrap(e,o)}}}(i),{priority:e.converterPriority||"normal"})}}(e))}attributeToAttribute(e){return this.add(function(e){e=cl(e);let t="attribute:"+(e.model.key?e.model.key:e.model);e.model.name&&(t+=":"+e.model.name);if(e.model.values)for(const t of e.model.values)e.view[t]=pl(e.view[t]);else e.view=pl(e.view);const i=fl(e);return n=>{var s;n.on(t,(s=i,(e,t,i)=>{if(!i.consumable.test(t.item,e.name))return;const n=s(t.attributeOldValue,i,t),o=s(t.attributeNewValue,i,t);if(!n&&!o)return;i.consumable.consume(t.item,e.name);const r=i.mapper.toViewElement(t.item),a=i.writer;if(!r)throw new l("conversion-attribute-to-attribute-on-text",i.dispatcher,t);if(null!==t.attributeOldValue&&n)if("class"==n.key){const e=Pn(n.value);for(const t of e)a.removeClass(t,r)}else if("style"==n.key){const e=Object.keys(n.value);for(const t of e)a.removeStyle(t,r)}else a.removeAttribute(n.key,r);if(null!==t.attributeNewValue&&o)if("class"==o.key){const e=Pn(o.value);for(const t of e)a.addClass(t,r)}else if("style"==o.key){const e=Object.keys(o.value);for(const t of e)a.setStyle(t,o.value[t],r)}else a.setAttribute(o.key,o.value,r)}),{priority:e.converterPriority||"normal"})}}(e))}markerToElement(e){return this.add(function(e){return(e=cl(e)).view=gl(e.view,"ui"),t=>{var i;t.on("addMarker:"+e.model,(i=e.view,(e,t,n)=>{t.isOpening=!0;const s=i(t,n);t.isOpening=!1;const o=i(t,n);if(!s||!o)return;const r=t.markerRange;if(r.isCollapsed&&!n.consumable.consume(r,e.name))return;for(const t of r)if(!n.consumable.consume(t.item,e.name))return;const a=n.mapper,l=n.writer;l.insert(a.toViewPosition(r.start),s),n.mapper.bindElementToMarker(s,t.markerName),r.isCollapsed||(l.insert(a.toViewPosition(r.end),o),n.mapper.bindElementToMarker(o,t.markerName)),e.stop()}),{priority:e.converterPriority||"normal"}),t.on("removeMarker:"+e.model,(e.view,(e,t,i)=>{const n=i.mapper.markerNameToElements(t.markerName);if(n){for(const e of n)i.mapper.unbindElementFromMarkerName(e,t.markerName),i.writer.clear(i.writer.createRangeOn(e),e);i.writer.clearClonedElementsGroup(t.markerName),e.stop()}}),{priority:e.converterPriority||"normal"})}}(e))}markerToHighlight(e){return this.add(function(e){return t=>{var i;t.on("addMarker:"+e.model,(i=e.view,(e,t,n)=>{if(!t.item)return;if(!(t.item instanceof Ya||t.item instanceof ol||t.item.is("$textProxy")))return;const s=wl(i,t,n);if(!s)return;if(!n.consumable.consume(t.item,e.name))return;const o=n.writer,r=ul(o,s),a=o.document.selection;if(t.item instanceof Ya||t.item instanceof ol)o.wrap(a.getFirstRange(),r,a);else{const e=n.mapper.toViewRange(t.range),i=o.wrap(e,r);for(const e of i.getItems())if(e.is("attributeElement")&&e.isSimilar(r)){n.mapper.bindElementToMarker(e,t.markerName);break}}}),{priority:e.converterPriority||"normal"}),t.on("addMarker:"+e.model,function(e){return(t,i,n)=>{if(!i.item)return;if(!(i.item instanceof Na))return;const s=wl(e,i,n);if(!s)return;if(!n.consumable.test(i.item,t.name))return;const o=n.mapper.toViewElement(i.item);if(o&&o.getCustomProperty("addHighlight")){n.consumable.consume(i.item,t.name);for(const e of Wa._createIn(i.item))n.consumable.consume(e.item,t.name);o.getCustomProperty("addHighlight")(o,s,n.writer),n.mapper.bindElementToMarker(o,i.markerName)}}}(e.view),{priority:e.converterPriority||"normal"}),t.on("removeMarker:"+e.model,function(e){return(t,i,n)=>{if(i.markerRange.isCollapsed)return;const s=wl(e,i,n);if(!s)return;const o=ul(n.writer,s),r=n.mapper.markerNameToElements(i.markerName);if(r){for(const e of r)n.mapper.unbindElementFromMarkerName(e,i.markerName),e.is("attributeElement")?n.writer.unwrap(n.writer.createRangeOn(e),o):e.getCustomProperty("removeHighlight")(e,s.id,n.writer);n.writer.clearClonedElementsGroup(i.markerName),t.stop()}}}(e.view),{priority:e.converterPriority||"normal"})}}(e))}markerToData(e){return this.add(function(e){const t=(e=cl(e)).model;e.view||(e.view=i=>({group:t,name:i.substr(e.model.length+1)}));return i=>{var n;i.on("addMarker:"+t,(n=e.view,(e,t,i)=>{const s=n(t.markerName,i);if(!s)return;const o=t.markerRange;i.consumable.consume(o,e.name)&&(hl(o,!1,i,t,s),hl(o,!0,i,t,s),e.stop())}),{priority:e.converterPriority||"normal"}),i.on("removeMarker:"+t,function(e){return(t,i,n)=>{const s=e(i.markerName,n);if(!s)return;const o=n.mapper.markerNameToElements(i.markerName);if(o){for(const e of o)n.mapper.unbindElementFromMarkerName(e,i.markerName),e.is("containerElement")?(r(`data-${s.group}-start-before`,e),r(`data-${s.group}-start-after`,e),r(`data-${s.group}-end-before`,e),r(`data-${s.group}-end-after`,e)):n.writer.clear(n.writer.createRangeOn(e),e);n.writer.clearClonedElementsGroup(i.markerName),t.stop()}function r(e,t){if(t.hasAttribute(e)){const i=new Set(t.getAttribute(e).split(","));i.delete(s.name),0==i.size?n.writer.removeAttribute(e,t):n.writer.setAttribute(e,Array.from(i).join(","),t)}}}}(e.view),{priority:e.converterPriority||"normal"})}}(e))}}function ul(e,t){const i=e.createAttributeElement("span",t.attributes);return t.classes&&i._addClass(t.classes),"number"==typeof t.priority&&(i._priority=t.priority),i._id=t.id,i}function hl(e,t,i,n,s){const o=t?e.start:e.end,r=o.nodeAfter&&o.nodeAfter.is("element")?o.nodeAfter:null,a=o.nodeBefore&&o.nodeBefore.is("element")?o.nodeBefore:null;if(r||a){let e,o;t&&r||!t&&!a?(e=r,o=!0):(e=a,o=!1);const l=i.mapper.toViewElement(e);if(l)return void function(e,t,i,n,s,o){const r=`data-${o.group}-${t?"start":"end"}-${i?"before":"after"}`,a=e.hasAttribute(r)?e.getAttribute(r).split(","):[];a.unshift(o.name),n.writer.setAttribute(r,a.join(","),e),n.mapper.bindElementToMarker(e,s.markerName)}(l,t,o,i,n,s)}!function(e,t,i,n,s){const o=`${s.group}-${t?"start":"end"}`,r=s.name?{name:s.name}:null,a=i.writer.createUIElement(o,r);i.writer.insert(e,a),i.mapper.bindElementToMarker(a,n.markerName)}(i.mapper.toViewPosition(o),t,i,n,s)}function ml(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 gl(e,t){return"function"==typeof e?e:(i,n)=>function(e,t,i){"string"==typeof e&&(e={name:e});let n;const s=t.writer,o=Object.assign({},e.attributes);if("container"==i)n=s.createContainerElement(e.name,o);else if("attribute"==i){const t={priority:e.priority||Ys.DEFAULT_PRIORITY};n=s.createAttributeElement(e.name,o,t)}else n=s.createUIElement(e.name,o);if(e.styles){const t=Object.keys(e.styles);for(const i of t)s.setStyle(i,e.styles[i],n)}if(e.classes){const t=e.classes;if("string"==typeof t)s.addClass(t,n);else for(const e of t)s.addClass(e,n)}return n}(e,n,t)}function fl(e){return e.model.values?(t,i)=>{const n=e.view[t];return n?n(t,i):null}:e.view}function pl(e){return"string"==typeof e?t=>({key:e,value:t}):"object"==typeof e?e.value?()=>e:t=>({key:e.key,value:t}):e}function wl(e,t,i){const n="function"==typeof e?e(t,i):e;return n?(n.priority||(n.priority=10),n.id||(n.id=t.markerName),n):null}function bl(e){const t=function(e){return(t,i)=>{if(!t.is("element",e.name))return!1;if("attribute"==i.type){if(e.attributes.includes(i.attributeKey))return!0}else if(e.children)return!0;return!1}}(e);return(e,i)=>{const n=[];i.reconvertedElements||(i.reconvertedElements=new Set);for(const e of i.changes){const s=e.position?e.position.parent:e.range.start.nodeAfter;if(s&&t(s,e)){if(!i.reconvertedElements.has(s)){i.reconvertedElements.add(s);const e=La._createBefore(s);n.push({type:"remove",name:s.name,position:e,length:1},{type:"reinsert",name:s.name,position:e,length:1})}}else n.push(e)}i.changes=n}}function vl(e){return(t,i,n={})=>{const s=["insert"];for(const i of e.attributes)t.hasAttribute(i)&&s.push(`attribute:${i}`);return!!s.every((e=>i.test(t,e)))&&(n.preflight||s.forEach((e=>i.consume(t,e))),!0)}}function _l(e,t,i,n){for(const s of t)yl(e.root,s,i,n)||i.convertItem(s)}function yl(e,t,i,n){const{writer:s,mapper:o}=i;if(!n.reconversion)return!1;const r=o.toViewElement(t);return!(!r||r.root==e)&&(!!i.canReuseView(r)&&(s.move(s.createRangeOn(r),o.toViewPosition(La._createBefore(t))),!0))}function kl(e,t,{preflight:i}={}){return i?t.test(e,"insert"):t.consume(e,"insert")}function Cl(e){const{schema:t,document:i}=e.model;for(const n of i.getRootNames()){const s=i.getRoot(n);if(s.isEmpty&&!t.checkChild(s,"$text")&&t.checkChild(s,"paragraph"))return e.insertElement("paragraph",s),!0}return!1}function Al(e,t,i){const n=i.createContext(e);return!!i.checkChild(n,"paragraph")&&!!i.checkChild(n.push("paragraph"),t)}function xl(e,t){const i=t.createElement("paragraph");return t.insert(i,e),t.createPositionAt(i,0)}class Tl extends ll{elementToElement(e){return this.add(El(e))}elementToAttribute(e){return this.add(function(e){Il(e=cl(e));const t=Rl(e,!1),i=Pl(e.view),n=i?"element:"+i:"element";return i=>{i.on(n,t,{priority:e.converterPriority||"low"})}}(e))}attributeToAttribute(e){return this.add(function(e){e=cl(e);let t=null;("string"==typeof e.view||e.view.key)&&(t=function(e){"string"==typeof e.view&&(e.view={key:e.view});const t=e.view.key;let i;if("class"==t||"style"==t){i={["class"==t?"classes":"styles"]:e.view.value}}else{i={attributes:{[t]:void 0===e.view.value?/[\s\S]*/:e.view.value}}}e.view.name&&(i.name=e.view.name);return e.view=i,t}(e));Il(e,t);const i=Rl(e,!0);return t=>{t.on("element",i,{priority:e.converterPriority||"low"})}}(e))}elementToMarker(e){return this.add(function(e){return function(e){const t=e.model;e.model=(e,i)=>{const n="string"==typeof t?t:t(e,i);return i.writer.createElement("$marker",{"data-name":n})}}(e=cl(e)),El(e)}(e))}dataToMarker(e){return this.add(function(e){(e=cl(e)).model||(e.model=t=>t?e.view+":"+t:e.view);const t=Sl(Vl(e,"start")),i=Sl(Vl(e,"end"));return n=>{n.on("element:"+e.view+"-start",t,{priority:e.converterPriority||"normal"}),n.on("element:"+e.view+"-end",i,{priority:e.converterPriority||"normal"});const s=r.get("low"),o=r.get("highest"),a=r.get(e.converterPriority)/o;n.on("element",function(e){return(t,i,n)=>{const s=`data-${e.view}`;function o(t,s){for(const o of s){const s=e.model(o,n),r=n.writer.createElement("$marker",{"data-name":s});n.writer.insert(r,t),i.modelCursor.isEqual(t)?i.modelCursor=i.modelCursor.getShiftedBy(1):i.modelCursor=i.modelCursor._getTransformedByInsertion(t,1),i.modelRange=i.modelRange._getTransformedByInsertion(t,1)[0]}}(n.consumable.test(i.viewItem,{attributes:s+"-end-after"})||n.consumable.test(i.viewItem,{attributes:s+"-start-after"})||n.consumable.test(i.viewItem,{attributes:s+"-end-before"})||n.consumable.test(i.viewItem,{attributes:s+"-start-before"}))&&(i.modelRange||Object.assign(i,n.convertChildren(i.viewItem,i.modelCursor)),n.consumable.consume(i.viewItem,{attributes:s+"-end-after"})&&o(i.modelRange.end,i.viewItem.getAttribute(s+"-end-after").split(",")),n.consumable.consume(i.viewItem,{attributes:s+"-start-after"})&&o(i.modelRange.end,i.viewItem.getAttribute(s+"-start-after").split(",")),n.consumable.consume(i.viewItem,{attributes:s+"-end-before"})&&o(i.modelRange.start,i.viewItem.getAttribute(s+"-end-before").split(",")),n.consumable.consume(i.viewItem,{attributes:s+"-start-before"})&&o(i.modelRange.start,i.viewItem.getAttribute(s+"-start-before").split(",")))}}(e),{priority:s+a})}}(e))}}function El(e){const t=Sl(e=cl(e)),i=Pl(e.view),n=i?"element:"+i:"element";return i=>{i.on(n,t,{priority:e.converterPriority||"normal"})}}function Pl(e){return"string"==typeof e?e:"object"==typeof e&&"string"==typeof e.name?e.name:null}function Sl(e){const t=new Hn(e.view);return(i,n,s)=>{const o=t.match(n.viewItem);if(!o)return;const r=o.match;if(r.name=!0,!s.consumable.test(n.viewItem,r))return;const a=function(e,t,i){return e instanceof Function?e(t,i):i.writer.createElement(e)}(e.model,n.viewItem,s);a&&s.safeInsert(a,n.modelCursor)&&(s.consumable.consume(n.viewItem,r),s.convertChildren(n.viewItem,a),s.updateConversionResult(a,n))}}function Il(e,t=null){const i=null===t||(e=>e.getAttribute(t)),n="object"!=typeof e.model?e.model:e.model.key,s="object"!=typeof e.model||void 0===e.model.value?i:e.model.value;e.model={key:n,value:s}}function Rl(e,t){const i=new Hn(e.view);return(n,s,o)=>{if(!s.modelRange&&t)return;const r=i.match(s.viewItem);if(!r)return;if(!function(e,t){const i="function"==typeof e?e(t):e;if("object"==typeof i&&!Pl(i))return!1;return!i.classes&&!i.attributes&&!i.styles}(e.view,s.viewItem)?delete r.match.name:r.match.name=!0,!o.consumable.test(s.viewItem,r.match))return;const a=e.model.key,l="function"==typeof e.model.value?e.model.value(s.viewItem,o):e.model.value;if(null===l)return;s.modelRange||Object.assign(s,o.convertChildren(s.viewItem,s.modelCursor));const c=function(e,t,i,n){let s=!1;for(const o of Array.from(e.getItems({shallow:i})))n.schema.checkAttribute(o,t.key)&&(s=!0,o.hasAttribute(t.key)||n.writer.setAttribute(t.key,t.value,o));return s}(s.modelRange,{key:a,value:l},t,o);c&&(o.consumable.test(s.viewItem,{name:!0})&&(r.match.name=!0),o.consumable.consume(s.viewItem,r.match))}}function Vl(e,t){const i={};return i.view=e.view+"-"+t,i.model=(t,i)=>{const n=t.getAttribute("name"),s=e.model(n,i);return i.writer.createElement("$marker",{"data-name":s})},i}class Ol{constructor(e,t){this.model=e,this.view=new Ra(t),this.mapper=new Ua,this.downcastDispatcher=new Ka({mapper:this.mapper,schema:e.schema});const i=this.model.document,n=i.selection,s=this.model.markers;this.listenTo(this.model,"_beforeChanges",(()=>{this.view._disableRendering(!0)}),{priority:"highest"}),this.listenTo(this.model,"_afterChanges",(()=>{this.view._disableRendering(!1)}),{priority:"lowest"}),this.listenTo(i,"change",(()=>{this.view.change((e=>{this.downcastDispatcher.convertChanges(i.differ,s,e),this.downcastDispatcher.convertSelection(n,s,e)}))}),{priority:"low"}),this.listenTo(this.view.document,"selectionChange",function(e,t){return(i,n)=>{const s=n.newSelection,o=[];for(const e of s.getRanges())o.push(t.toModelRange(e));const r=e.createSelection(o,{backward:s.isBackward});r.isEqual(e.document.selection)||e.change((e=>{e.setSelection(r)}))}}(this.model,this.mapper)),this.downcastDispatcher.on("insert:$text",((e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const n=i.writer,s=i.mapper.toViewPosition(t.range.start),o=n.createText(t.item.data);n.insert(s,o)}),{priority:"lowest"}),this.downcastDispatcher.on("insert",((e,t,i)=>{i.convertAttributes(t.item),t.reconversion||!t.item.is("element")||t.item.isEmpty||i.convertChildren(t.item)}),{priority:"lowest"}),this.downcastDispatcher.on("remove",((e,t,i)=>{const n=i.mapper.toViewPosition(t.position),s=t.position.getShiftedBy(t.length),o=i.mapper.toViewPosition(s,{isPhantom:!0}),r=i.writer.createRange(n,o),a=i.writer.remove(r.getTrimmed());for(const e of i.writer.createRangeIn(a).getItems())i.mapper.unbindViewElement(e,{defer:!0})}),{priority:"low"}),this.downcastDispatcher.on("selection",((e,t,i)=>{const n=i.writer,s=n.document.selection;for(const e of s.getRanges())e.isCollapsed&&e.end.parent.isAttached()&&i.writer.mergeAttributes(e.start);n.setSelection(null)}),{priority:"high"}),this.downcastDispatcher.on("selection",((e,t,i)=>{const n=t.selection;if(n.isCollapsed)return;if(!i.consumable.consume(n,"selection"))return;const s=[];for(const e of n.getRanges()){const t=i.mapper.toViewRange(e);s.push(t)}i.writer.setSelection(s,{backward:n.isBackward})}),{priority:"low"}),this.downcastDispatcher.on("selection",((e,t,i)=>{const n=t.selection;if(!n.isCollapsed)return;if(!i.consumable.consume(n,"selection"))return;const s=i.writer,o=n.getFirstPosition(),r=i.mapper.toViewPosition(o),a=s.breakAttributes(r);s.setSelection(a)}),{priority:"low"}),this.view.document.roots.bindTo(this.model.document.roots).using((e=>{if("$graveyard"==e.rootName)return null;const t=new Bs(this.view.document,e.name);return t.rootName=e.rootName,this.mapper.bindElements(e,t),t}))}destroy(){this.view.destroy(),this.stopListening()}reconvertMarker(e){const t="string"==typeof e?e:e.name,i=this.model.markers.get(t);if(!i)throw new l("editingcontroller-reconvertmarker-marker-not-exist",this,{markerName:t});this.model.change((()=>{this.model.markers._refresh(i)}))}reconvertItem(e){this.model.change((()=>{this.model.document.differ._refreshItem(e)}))}}dt(Ol,st);class Bl{constructor(){this._commands=new Map}add(e,t){this._commands.set(e,t)}get(e){return this._commands.get(e)}execute(e,...t){const i=this.get(e);if(!i)throw new l("commandcollection-command-not-found",this,{commandName:e});return i.execute(...t)}*names(){yield*this._commands.keys()}*commands(){yield*this._commands.values()}[Symbol.iterator](){return this._commands[Symbol.iterator]()}destroy(){for(const e of this.commands())e.destroy()}}class Ml{constructor(){this._consumables=new Map}add(e,t){let i;e.is("$text")||e.is("documentFragment")?this._consumables.set(e,!0):(this._consumables.has(e)?i=this._consumables.get(e):(i=new Nl(e),this._consumables.set(e,i)),i.add(t))}test(e,t){const i=this._consumables.get(e);return void 0===i?null:e.is("$text")||e.is("documentFragment")?i:i.test(t)}consume(e,t){return!!this.test(e,t)&&(e.is("$text")||e.is("documentFragment")?this._consumables.set(e,!1):this._consumables.get(e).consume(t),!0)}revert(e,t){const i=this._consumables.get(e);void 0!==i&&(e.is("$text")||e.is("documentFragment")?this._consumables.set(e,!0):i.revert(t))}static consumablesFromElement(e){const t={element:e,name:!0,attributes:[],classes:[],styles:[]},i=e.getAttributeKeys();for(const e of i)"style"!=e&&"class"!=e&&t.attributes.push(e);const n=e.getClassNames();for(const e of n)t.classes.push(e);const s=e.getStyleNames();for(const e of s)t.styles.push(e);return t}static createFrom(e,t){if(t||(t=new Ml(e)),e.is("$text"))return t.add(e),t;e.is("element")&&t.add(e,Ml.consumablesFromElement(e)),e.is("documentFragment")&&t.add(e);for(const i of e.getChildren())t=Ml.createFrom(i,t);return t}}class Nl{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 in this._consumables)t in e&&this._add(t,e[t])}test(e){if(e.name&&!this._canConsumeName)return this._canConsumeName;for(const t in this._consumables)if(t in e){const i=this._test(t,e[t]);if(!0!==i)return i}return!0}consume(e){e.name&&(this._canConsumeName=!1);for(const t in this._consumables)t in e&&this._consume(t,e[t])}revert(e){e.name&&(this._canConsumeName=!0);for(const t in this._consumables)t in e&&this._revert(t,e[t])}_add(e,t){const i=Pe(t)?t:[t],n=this._consumables[e];for(const t of i){if("attributes"===e&&("class"===t||"style"===t))throw new l("viewconsumable-invalid-attribute",this);if(n.set(t,!0),"styles"===e)for(const e of this.element.document.stylesProcessor.getRelatedStyles(t))n.set(e,!0)}}_test(e,t){const i=Pe(t)?t:[t],n=this._consumables[e];for(const t of i)if("attributes"!==e||"class"!==t&&"style"!==t){const e=n.get(t);if(void 0===e)return null;if(!e)return!1}else{const e="class"==t?"classes":"styles",i=this._test(e,[...this._consumables[e].keys()]);if(!0!==i)return i}return!0}_consume(e,t){const i=Pe(t)?t:[t],n=this._consumables[e];for(const t of i)if("attributes"!==e||"class"!==t&&"style"!==t){if(n.set(t,!1),"styles"==e)for(const e of this.element.document.stylesProcessor.getRelatedStyles(t))n.set(e,!1)}else{const e="class"==t?"classes":"styles";this._consume(e,[...this._consumables[e].keys()])}}_revert(e,t){const i=Pe(t)?t:[t],n=this._consumables[e];for(const t of i)if("attributes"!==e||"class"!==t&&"style"!==t){!1===n.get(t)&&n.set(t,!0)}else{const e="class"==t?"classes":"styles";this._revert(e,[...this._consumables[e].keys()])}}}class Dl{constructor(){this._sourceDefinitions={},this._attributeProperties={},this.decorate("checkChild"),this.decorate("checkAttribute"),this.on("checkAttribute",((e,t)=>{t[0]=new zl(t[0])}),{priority:"highest"}),this.on("checkChild",((e,t)=>{t[0]=new zl(t[0]),t[1]=this.getDefinition(t[1])}),{priority:"highest"})}register(e,t){if(this._sourceDefinitions[e])throw new l("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 l("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:e.is&&(e.is("$text")||e.is("$textProxy"))?"$text":e.name,this.getDefinitions()[t]}isRegistered(e){return!!this.getDefinition(e)}isBlock(e){const t=this.getDefinition(e);return!(!t||!t.isBlock)}isLimit(e){const t=this.getDefinition(e);return!!t&&!(!t.isLimit&&!t.isObject)}isObject(e){const t=this.getDefinition(e);return!!t&&!!(t.isObject||t.isLimit&&t.isSelectable&&t.isContent)}isInline(e){const t=this.getDefinition(e);return!(!t||!t.isInline)}isSelectable(e){const t=this.getDefinition(e);return!!t&&!(!t.isSelectable&&!t.isObject)}isContent(e){const t=this.getDefinition(e);return!!t&&!(!t.isContent&&!t.isObject)}checkChild(e,t){return!!t&&this._checkContextMatch(t,e)}checkAttribute(e,t){const i=this.getDefinition(e.last);return!!i&&i.allowAttributes.includes(t)}checkMerge(e,t=null){if(e instanceof La){const t=e.nodeBefore,i=e.nodeAfter;if(!(t instanceof Na))throw new l("schema-check-merge-no-element-before",this);if(!(i instanceof Na))throw new l("schema-check-merge-no-element-after",this);return this.checkMerge(t,i)}for(const i of t.getChildren())if(!this.checkChild(e,i))return!1;return!0}addChildCheck(e){this.on("checkChild",((t,[i,n])=>{if(!n)return;const s=e(i,n);"boolean"==typeof s&&(t.stop(),t.return=s)}),{priority:"high"})}addAttributeCheck(e){this.on("checkAttribute",((t,[i,n])=>{const s=e(i,n);"boolean"==typeof s&&(t.stop(),t.return=s)}),{priority:"high"})}setAttributeProperties(e,t){this._attributeProperties[e]=Object.assign(this.getAttributeProperties(e),t)}getAttributeProperties(e){return this._attributeProperties[e]||{}}getLimitElement(e){let t;if(e instanceof La)t=e.parent;else{t=(e instanceof Wa?[e]:Array.from(e.getRanges())).reduce(((e,t)=>{const i=t.getCommonAncestor();return e?e.getCommonAncestor(i,{includeSelf:!0}):i}),null)}for(;!this.isLimit(t)&&t.parent;)t=t.parent;return t}checkAttributeInSelection(e,t){if(e.isCollapsed){const i=[...e.getFirstPosition().getAncestors(),new Oa("",e.getAttributes())];return this.checkAttribute(i,t)}{const i=e.getRanges();for(const e of i)for(const i of e)if(this.checkAttribute(i.item,t))return!0}return!1}*getValidRanges(e,t){e=function*(e){for(const t of e)yield*t.getMinimalFlatRanges()}(e);for(const i of e)yield*this._getValidRangesForRange(i,t)}getNearestSelectionRange(e,t="both"){if(this.checkChild(e,"$text"))return new Wa(e);let i,n;const s=e.getAncestors().reverse().find((e=>this.isLimit(e)))||e.root;"both"!=t&&"backward"!=t||(i=new Da({boundaries:Wa._createIn(s),startPosition:e,direction:"backward"})),"both"!=t&&"forward"!=t||(n=new Da({boundaries:Wa._createIn(s),startPosition:e}));for(const e of function*(e,t){let i=!1;for(;!i;){if(i=!0,e){const t=e.next();t.done||(i=!1,yield{walker:e,value:t.value})}if(t){const e=t.next();e.done||(i=!1,yield{walker:t,value:e.value})}}}(i,n)){const t=e.walker==i?"elementEnd":"elementStart",n=e.value;if(n.type==t&&this.isObject(n.item))return Wa._createOn(n.item);if(this.checkChild(n.nextPosition,"$text"))return new Wa(n.nextPosition)}return null}findAllowedParent(e,t){let i=e.parent;for(;i;){if(this.checkChild(i,t))return i;if(this.isLimit(i))return null;i=i.parent}return null}setAllowedAttributes(e,t,i){const n=i.model;for(const[s,o]of Object.entries(t))n.schema.checkAttribute(e,s)&&i.setAttribute(s,o,e)}removeDisallowedAttributes(e,t){for(const i of e)if(i.is("$text"))Ql(this,i,t);else{const e=Wa._createIn(i).getPositions();for(const i of e){Ql(this,i.nodeBefore||i.parent,t)}}}getAttributesWithProperty(e,t,i){const n={};for(const[s,o]of e.getAttributes()){const e=this.getAttributeProperties(s);void 0!==e[t]&&(void 0!==i&&i!==e[t]||(n[s]=o))}return n}createContext(e){return new zl(e)}_clearCache(){this._compiledDefinitions=null}_compile(){const e={},t=this._sourceDefinitions,i=Object.keys(t);for(const n of i)e[n]=Ll(t[n],n);for(const t of i)Fl(e,t);for(const t of i)Hl(e,t);for(const t of i)jl(e,t);for(const t of i)Wl(e,t),Ul(e,t);for(const t of i)ql(e,t),$l(e,t),Kl(e,t);this._compiledDefinitions=e}_checkContextMatch(e,t,i=t.length-1){const n=t.getItem(i);if(e.allowIn.includes(n.name)){if(0==i)return!0;{const e=this.getDefinition(n);return this._checkContextMatch(e,t,i-1)}}return!1}*_getValidRangesForRange(e,t){let i=e.start,n=e.start;for(const s of e.getItems({shallow:!0}))s.is("element")&&(yield*this._getValidRangesForRange(Wa._createIn(s),t)),this.checkAttribute(s,t)||(i.isEqual(n)||(yield new Wa(i,n)),i=La._createAfter(s)),n=La._createAfter(s);i.isEqual(n)||(yield new Wa(i,n))}}dt(Dl,st);class zl{constructor(e){if(e instanceof zl)return e;"string"==typeof e?e=[e]:Array.isArray(e)||(e=e.getAncestors({includeSelf:!0})),this._items=e.map(Yl)}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 zl([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 Ll(e,t){const i={name:t,allowIn:[],allowContentOf:[],allowWhere:[],allowAttributes:[],allowAttributesOf:[],allowChildren:[],inheritTypesFrom:[]};return function(e,t){for(const i of e){const e=Object.keys(i).filter((e=>e.startsWith("is")));for(const n of e)t[n]=i[n]}}(e,i),Gl(e,i,"allowIn"),Gl(e,i,"allowContentOf"),Gl(e,i,"allowWhere"),Gl(e,i,"allowAttributes"),Gl(e,i,"allowAttributesOf"),Gl(e,i,"allowChildren"),Gl(e,i,"inheritTypesFrom"),function(e,t){for(const i of e){const e=i.inheritAllFrom;e&&(t.allowContentOf.push(e),t.allowWhere.push(e),t.allowAttributesOf.push(e),t.inheritTypesFrom.push(e))}}(e,i),i}function Fl(e,t){const i=e[t];for(const n of i.allowChildren){const i=e[n];i&&i.allowIn.push(t)}i.allowChildren.length=0}function Hl(e,t){for(const i of e[t].allowContentOf)if(e[i]){Jl(e,i).forEach((e=>{e.allowIn.push(t)}))}delete e[t].allowContentOf}function jl(e,t){for(const i of e[t].allowWhere){const n=e[i];if(n){const i=n.allowIn;e[t].allowIn.push(...i)}}delete e[t].allowWhere}function Wl(e,t){for(const i of e[t].allowAttributesOf){const n=e[i];if(n){const i=n.allowAttributes;e[t].allowAttributes.push(...i)}}delete e[t].allowAttributesOf}function Ul(e,t){const i=e[t];for(const t of i.inheritTypesFrom){const n=e[t];if(n){const e=Object.keys(n).filter((e=>e.startsWith("is")));for(const t of e)t in i||(i[t]=n[t])}}delete i.inheritTypesFrom}function ql(e,t){const i=e[t],n=i.allowIn.filter((t=>e[t]));i.allowIn=Array.from(new Set(n))}function $l(e,t){const i=e[t];for(const n of i.allowIn){e[n].allowChildren.push(t)}}function Kl(e,t){const i=e[t];i.allowAttributes=Array.from(new Set(i.allowAttributes))}function Gl(e,t,i){for(const n of e)"string"==typeof n[i]?t[i].push(n[i]):Array.isArray(n[i])&&t[i].push(...n[i])}function Jl(e,t){const i=e[t];return(n=e,Object.keys(n).map((e=>n[e]))).filter((e=>e.allowIn.includes(i.name)));var n}function Yl(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 Ql(e,t,i){for(const n of t.getAttributeKeys())e.checkAttribute(t,n)||i.removeAttribute(n,t)}class Zl{constructor(e={}){this._splitParts=new Map,this._cursorParents=new Map,this._modelCursor=null,this._emptyElementsToKeep=new Set,this.conversionApi=Object.assign({},e),this.conversionApi.convertItem=this._convertItem.bind(this),this.conversionApi.convertChildren=this._convertChildren.bind(this),this.conversionApi.safeInsert=this._safeInsert.bind(this),this.conversionApi.updateConversionResult=this._updateConversionResult.bind(this),this.conversionApi.splitToAllowedParent=this._splitToAllowedParent.bind(this),this.conversionApi.getSplitParts=this._getSplitParts.bind(this),this.conversionApi.keepEmptyElement=this._keepEmptyElement.bind(this)}convert(e,t,i=["$root"]){this.fire("viewCleanup",e),this._modelCursor=function(e,t){let i;for(const n of new zl(e)){const e={};for(const t of n.getAttributeKeys())e[t]=n.getAttribute(t);const s=t.createElement(n.name,e);i&&t.append(s,i),i=La._createAt(s,0)}return i}(i,t),this.conversionApi.writer=t,this.conversionApi.consumable=Ml.createFrom(e),this.conversionApi.store={};const{modelRange:n}=this._convertItem(e,this._modelCursor),s=t.createDocumentFragment();if(n){this._removeEmptyElements();for(const e of Array.from(this._modelCursor.parent.getChildren()))t.append(e,s);s.markers=function(e,t){const i=new Set,n=new Map,s=Wa._createIn(e).getItems();for(const e of s)"$marker"==e.name&&i.add(e);for(const e of i){const i=e.getAttribute("data-name"),s=t.createPositionBefore(e);n.has(i)?n.get(i).end=s.clone():n.set(i,new Wa(s.clone())),t.remove(e)}return n}(s,t)}return this._modelCursor=null,this._splitParts.clear(),this._cursorParents.clear(),this._emptyElementsToKeep.clear(),this.conversionApi.writer=null,this.conversionApi.store=null,s}_convertItem(e,t){const i=Object.assign({viewItem:e,modelCursor:t,modelRange:null});if(e.is("element")?this.fire("element:"+e.name,i,this.conversionApi):e.is("$text")?this.fire("text",i,this.conversionApi):this.fire("documentFragment",i,this.conversionApi),i.modelRange&&!(i.modelRange instanceof Wa))throw new l("view-conversion-dispatcher-incorrect-result",this);return{modelRange:i.modelRange,modelCursor:i.modelCursor}}_convertChildren(e,t){let i=t.is("position")?t:La._createAt(t,0);const n=new Wa(i);for(const t of Array.from(e.getChildren())){const e=this._convertItem(t,i);e.modelRange instanceof Wa&&(n.end=e.modelRange.end,i=e.modelCursor)}return{modelRange:n,modelCursor:i}}_safeInsert(e,t){const i=this._splitToAllowedParent(e,t);return!!i&&(this.conversionApi.writer.insert(e,i.position),!0)}_updateConversionResult(e,t){const i=this._getSplitParts(e),n=this.conversionApi.writer;t.modelRange||(t.modelRange=n.createRange(n.createPositionBefore(e),n.createPositionAfter(i[i.length-1])));const s=this._cursorParents.get(e);t.modelCursor=s?n.createPositionAt(s,0):t.modelRange.end}_splitToAllowedParent(e,t){const{schema:i,writer:n}=this.conversionApi;let s=i.findAllowedParent(t,e);if(s){if(s===t.parent)return{position:t};this._modelCursor.parent.getAncestors().includes(s)&&(s=null)}if(!s)return Al(t,e,i)?{position:xl(t,n)}:null;const o=this.conversionApi.writer.split(t,s),r=[];for(const e of o.range.getWalker())if("elementEnd"==e.type)r.push(e.item);else{const t=r.pop(),i=e.item;this._registerSplitPair(t,i)}const a=o.range.end.parent;return this._cursorParents.set(e,a),{position:o.position,cursorParent:a}}_registerSplitPair(e,t){this._splitParts.has(e)||this._splitParts.set(e,[e]);const i=this._splitParts.get(e);this._splitParts.set(t,i),i.push(t)}_getSplitParts(e){let t;return t=this._splitParts.has(e)?this._splitParts.get(e):[e],t}_keepEmptyElement(e){this._emptyElementsToKeep.add(e)}_removeEmptyElements(){let e=!1;for(const t of this._splitParts.keys())t.isEmpty&&!this._emptyElementsToKeep.has(t)&&(this.conversionApi.writer.remove(t),this._splitParts.delete(t),e=!0);e&&this._removeEmptyElements()}}dt(Zl,p);class Xl{getHtml(e){const t=document.implementation.createHTMLDocument("").createElement("div");return t.appendChild(e),t.innerHTML}}class ec{constructor(e){this.domParser=new DOMParser,this.domConverter=new ar(e,{renderingMode:"data"}),this.htmlWriter=new Xl}toData(e){const t=this.domConverter.viewToDom(e,document);return this.htmlWriter.getHtml(t)}toView(e){const t=this._toDom(e);return this.domConverter.domToView(t)}registerRawContentMatcher(e){this.domConverter.registerRawContentMatcher(e)}useFillerType(e){this.domConverter.blockFillerMode="marked"==e?"markedNbsp":"nbsp"}_toDom(e){e.match(/<(?:html|body|head|meta)(?:\s[^>]*)?>/i)||(e=`${e}`);const t=this.domParser.parseFromString(e,"text/html"),i=t.createDocumentFragment(),n=t.body.childNodes;for(;n.length>0;)i.appendChild(n[0]);return i}}class tc{constructor(e,t){this.model=e,this.mapper=new Ua,this.downcastDispatcher=new Ka({mapper:this.mapper,schema:e.schema}),this.downcastDispatcher.on("insert:$text",((e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const n=i.writer,s=i.mapper.toViewPosition(t.range.start),o=n.createText(t.item.data);n.insert(s,o)}),{priority:"lowest"}),this.downcastDispatcher.on("insert",((e,t,i)=>{i.convertAttributes(t.item),t.reconversion||!t.item.is("element")||t.item.isEmpty||i.convertChildren(t.item)}),{priority:"lowest"}),this.upcastDispatcher=new Zl({schema:e.schema}),this.viewDocument=new Js(t),this.stylesProcessor=t,this.htmlProcessor=new ec(this.viewDocument),this.processor=this.htmlProcessor,this._viewWriter=new _o(this.viewDocument),this.upcastDispatcher.on("text",((e,t,{schema:i,consumable:n,writer:s})=>{let o=t.modelCursor;if(!n.test(t.viewItem))return;if(!i.checkChild(o,"$text")){if(!Al(o,"$text",i))return;o=xl(o,s)}n.consume(t.viewItem);const r=s.createText(t.viewItem.data);s.insert(r,o),t.modelRange=s.createRange(o,o.getShiftedBy(r.offsetSize)),t.modelCursor=t.modelRange.end}),{priority:"lowest"}),this.upcastDispatcher.on("element",((e,t,i)=>{if(!t.modelRange&&i.consumable.consume(t.viewItem,{name:!0})){const{modelRange:e,modelCursor:n}=i.convertChildren(t.viewItem,t.modelCursor);t.modelRange=e,t.modelCursor=n}}),{priority:"lowest"}),this.upcastDispatcher.on("documentFragment",((e,t,i)=>{if(!t.modelRange&&i.consumable.consume(t.viewItem,{name:!0})){const{modelRange:e,modelCursor:n}=i.convertChildren(t.viewItem,t.modelCursor);t.modelRange=e,t.modelCursor=n}}),{priority:"lowest"}),this.decorate("init"),this.decorate("set"),this.decorate("get"),this.on("init",(()=>{this.fire("ready")}),{priority:"lowest"}),this.on("ready",(()=>{this.model.enqueueChange({isUndoable:!1},Cl)}),{priority:"lowest"})}get(e={}){const{rootName:t="main",trim:i="empty"}=e;if(!this._checkIfRootsExists([t]))throw new l("datacontroller-get-non-existent-root",this);const n=this.model.document.getRoot(t);return"empty"!==i||this.model.hasContent(n,{ignoreWhitespaces:!0})?this.stringify(n,e):""}stringify(e,t={}){const i=this.toView(e,t);return this.processor.toData(i)}toView(e,t={}){const i=this.viewDocument,n=this._viewWriter;this.mapper.clearBindings();const s=Wa._createIn(e),o=new vo(i);this.mapper.bindElements(e,o);const r=e.is("documentFragment")?e.markers:function(e){const t=[],i=e.root.document;if(!i)return new Map;const n=Wa._createIn(e);for(const e of i.model.markers){const i=e.getRange(),s=i.isCollapsed,o=i.start.isEqual(n.start)||i.end.isEqual(n.end);if(s&&o)t.push([e.name,i]);else{const s=n.getIntersection(i);s&&t.push([e.name,s])}}return t.sort((([e,t],[i,n])=>{if("after"!==t.end.compareWith(n.start))return 1;if("before"!==t.start.compareWith(n.end))return-1;switch(t.start.compareWith(n.start)){case"before":return 1;case"after":return-1;default:switch(t.end.compareWith(n.end)){case"before":return 1;case"after":return-1;default:return i.localeCompare(e)}}})),new Map(t)}(e);return this.downcastDispatcher.convert(s,r,n,t),o}init(e){if(this.model.document.version)throw new l("datacontroller-init-document-not-empty",this);let t={};if("string"==typeof e?t.main=e:t=e,!this._checkIfRootsExists(Object.keys(t)))throw new l("datacontroller-init-non-existent-root",this);return this.model.enqueueChange({isUndoable:!1},(e=>{for(const i of Object.keys(t)){const n=this.model.document.getRoot(i);e.insert(this.parse(t[i],n),n,0)}})),Promise.resolve()}set(e,t={}){let i={};if("string"==typeof e?i.main=e:i=e,!this._checkIfRootsExists(Object.keys(i)))throw new l("datacontroller-set-non-existent-root",this);this.model.enqueueChange(t.batchType||{},(e=>{e.setSelection(null),e.removeSelectionAttribute(this.model.document.selection.getAttributeKeys());for(const t of Object.keys(i)){const n=this.model.document.getRoot(t);e.remove(e.createRangeIn(n)),e.insert(this.parse(i[t],n),n,0)}}))}parse(e,t="$root"){const i=this.processor.toView(e);return this.toModel(i,t)}toModel(e,t="$root"){return this.model.change((i=>this.upcastDispatcher.convert(e,i,t)))}addStyleProcessorRules(e){e(this.stylesProcessor)}registerRawContentMatcher(e){this.processor&&this.processor!==this.htmlProcessor&&this.processor.registerRawContentMatcher(e),this.htmlProcessor.registerRawContentMatcher(e)}destroy(){this.stopListening()}_checkIfRootsExists(e){for(const t of e)if(!this.model.document.getRootNames().includes(t))return!1;return!0}}dt(tc,st);class ic{constructor(e,t){this._helpers=new Map,this._downcast=Pn(e),this._createConversionHelpers({name:"downcast",dispatchers:this._downcast,isDowncast:!0}),this._upcast=Pn(t),this._createConversionHelpers({name:"upcast",dispatchers:this._upcast,isDowncast:!1})}addAlias(e,t){const i=this._downcast.includes(t);if(!this._upcast.includes(t)&&!i)throw new l("conversion-add-alias-dispatcher-not-registered",this);this._createConversionHelpers({name:e,dispatchers:[t],isDowncast:i})}for(e){if(!this._helpers.has(e))throw new l("conversion-for-unknown-group",this);return this._helpers.get(e)}elementToElement(e){this.for("downcast").elementToElement(e);for(const{model:t,view:i}of nc(e))this.for("upcast").elementToElement({model:t,view:i,converterPriority:e.converterPriority})}attributeToElement(e){this.for("downcast").attributeToElement(e);for(const{model:t,view:i}of nc(e))this.for("upcast").elementToAttribute({view:i,model:t,converterPriority:e.converterPriority})}attributeToAttribute(e){this.for("downcast").attributeToAttribute(e);for(const{model:t,view:i}of nc(e))this.for("upcast").attributeToAttribute({view:i,model:t})}_createConversionHelpers({name:e,dispatchers:t,isDowncast:i}){if(this._helpers.has(e))throw new l("conversion-group-exists",this);const n=i?new dl(t):new Tl(t);this._helpers.set(e,n)}}function*nc(e){if(e.model.values)for(const t of e.model.values){const i={key:e.model.key,value:t},n=e.view[t],s=e.upcastAlso?e.upcastAlso[t]:void 0;yield*sc(i,n,s)}else yield*sc(e.model,e.view,e.upcastAlso)}function*sc(e,t,i){if(yield{model:e,view:t},i)for(const t of Pn(i))yield{model:e,view:t}}class oc{constructor(e={}){"string"==typeof e&&(e="transparent"===e?{isUndoable:!1}:{},c("batch-constructor-deprecated-string-type"));const{isUndoable:t=!0,isLocal:i=!0,isUndo:n=!1,isTyping:s=!1}=e;this.operations=[],this.isUndoable=t,this.isLocal=i,this.isUndo=n,this.isTyping=s}get type(){return c("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 rc{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){return new this(e.baseVersion)}}class ac{constructor(e){this.markers=new Map,this._children=new Ma,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 root(){return this}get parent(){return null}is(e){return"documentFragment"===e||"model:documentFragment"===e}getChild(e){return this._children.getNode(e)}getChildren(){return this._children[Symbol.iterator]()}getChildIndex(e){return this._children.getNodeIndex(e)}getChildStartOffset(e){return this._children.getNodeStartOffset(e)}getPath(){return[]}getNodeByPath(e){let t=this;for(const i of e)t=t.getChild(t.offsetToIndex(i));return t}offsetToIndex(e){return this._children.offsetToIndex(e)}toJSON(){const e=[];for(const t of this._children)e.push(t.toJSON());return e}static fromJSON(e){const t=[];for(const i of e)i.name?t.push(Na.fromJSON(i)):t.push(Oa.fromJSON(i));return new ac(t)}_appendChild(e){this._insertChild(this.childCount,e)}_insertChild(e,t){const i=function(e){if("string"==typeof e)return[new Oa(e)];xn(e)||(e=[e]);return Array.from(e).map((e=>"string"==typeof e?new Oa(e):e instanceof Ba?new Oa(e.data,e.getAttributes()):e))}(t);for(const e of i)null!==e.parent&&e._remove(),e.parent=this;this._children._insertNodes(e,i)}_removeChildren(e,t=1){const i=this._children._removeNodes(e,t);for(const e of i)e.parent=null;return i}}function lc(e,t){const i=(t=uc(t)).reduce(((e,t)=>e+t.offsetSize),0),n=e.parent;mc(e);const s=e.index;return n._insertChild(s,t),hc(n,s+t.length),hc(n,s),new Wa(e,e.getShiftedBy(i))}function cc(e){if(!e.isFlat)throw new l("operation-utils-remove-range-not-flat",this);const t=e.start.parent;mc(e.start),mc(e.end);const i=t._removeChildren(e.start.index,e.end.index-e.start.index);return hc(t,e.start.index),i}function dc(e,t){if(!e.isFlat)throw new l("operation-utils-move-range-not-flat",this);const i=cc(e);return lc(t=t._getTransformedByDeletion(e.start,e.end.offset-e.start.offset),i)}function uc(e){const t=[];e instanceof Array||(e=[e]);for(let i=0;ie.maxOffset)throw new l("move-operation-nodes-do-not-exist",this);if(e===t&&i=i&&this.targetPosition.path[e]e._clone(!0)))),t=new vc(this.position,e,this.baseVersion);return t.shouldReceiveAttributes=this.shouldReceiveAttributes,t}getReversed(){const e=this.position.root.document.graveyard,t=new La(e,[0]);return new bc(this.position,this.nodes.maxOffset,t,this.baseVersion+1)}_validate(){const e=this.position.parent;if(!e||e.maxOffsete._clone(!0)))),lc(this.position,e)}toJSON(){const e=super.toJSON();return e.position=this.position.toJSON(),e.nodes=this.nodes.toJSON(),e}static get className(){return"InsertOperation"}static fromJSON(e,t){const i=[];for(const t of e.nodes)t.name?i.push(Na.fromJSON(t)):i.push(Oa.fromJSON(t));const n=new vc(La.fromJSON(e.position,t),i,e.baseVersion);return n.shouldReceiveAttributes=e.shouldReceiveAttributes,n}}class _c extends rc{constructor(e,t,i,n,s,o){super(o),this.name=e,this.oldRange=t?t.clone():null,this.newRange=i?i.clone():null,this.affectsData=s,this._markers=n}get type(){return"marker"}clone(){return new _c(this.name,this.oldRange,this.newRange,this._markers,this.affectsData,this.baseVersion)}getReversed(){return new _c(this.name,this.newRange,this.oldRange,this._markers,this.affectsData,this.baseVersion+1)}_execute(){const e=this.newRange?"_set":"_remove";this._markers[e](this.name,this.newRange,!0,this.affectsData)}toJSON(){const e=super.toJSON();return this.oldRange&&(e.oldRange=this.oldRange.toJSON()),this.newRange&&(e.newRange=this.newRange.toJSON()),delete e._markers,e}static get className(){return"MarkerOperation"}static fromJSON(e,t){return new _c(e.name,e.oldRange?Wa.fromJSON(e.oldRange,t):null,e.newRange?Wa.fromJSON(e.newRange,t):null,t.model.markers,e.affectsData,e.baseVersion)}}class yc extends rc{constructor(e,t,i,n){super(n),this.position=e,this.position.stickiness="toNext",this.oldName=t,this.newName=i}get type(){return"rename"}clone(){return new yc(this.position.clone(),this.oldName,this.newName,this.baseVersion)}getReversed(){return new yc(this.position.clone(),this.newName,this.oldName,this.baseVersion+1)}_validate(){const e=this.position.nodeAfter;if(!(e instanceof Na))throw new l("rename-operation-wrong-position",this);if(e.name!==this.oldName)throw new l("rename-operation-wrong-name",this)}_execute(){this.position.nodeAfter.name=this.newName}toJSON(){const e=super.toJSON();return e.position=this.position.toJSON(),e}static get className(){return"RenameOperation"}static fromJSON(e,t){return new yc(La.fromJSON(e.position,t),e.oldName,e.newName,e.baseVersion)}}class kc extends rc{constructor(e,t,i,n,s){super(s),this.root=e,this.key=t,this.oldValue=i,this.newValue=n}get type(){return null===this.oldValue?"addRootAttribute":null===this.newValue?"removeRootAttribute":"changeRootAttribute"}clone(){return new kc(this.root,this.key,this.oldValue,this.newValue,this.baseVersion)}getReversed(){return new kc(this.root,this.key,this.newValue,this.oldValue,this.baseVersion+1)}_validate(){if(this.root!=this.root.root||this.root.is("documentFragment"))throw new l("rootattribute-operation-not-a-root",this,{root:this.root,key:this.key});if(null!==this.oldValue&&this.root.getAttribute(this.key)!==this.oldValue)throw new l("rootattribute-operation-wrong-old-value",this,{root:this.root,key:this.key});if(null===this.oldValue&&null!==this.newValue&&this.root.hasAttribute(this.key))throw new l("rootattribute-operation-attribute-exists",this,{root:this.root,key:this.key})}_execute(){null!==this.newValue?this.root._setAttribute(this.key,this.newValue):this.root._removeAttribute(this.key)}toJSON(){const e=super.toJSON();return e.root=this.root.toJSON(),e}static get className(){return"RootAttributeOperation"}static fromJSON(e,t){if(!t.getRoot(e.root))throw new l("rootattribute-operation-fromjson-no-root",this,{rootName:e.root});return new kc(t.getRoot(e.root),e.key,e.oldValue,e.newValue,e.baseVersion)}}class Cc extends rc{constructor(e,t,i,n,s){super(s),this.sourcePosition=e.clone(),this.sourcePosition.stickiness="toPrevious",this.howMany=t,this.targetPosition=i.clone(),this.targetPosition.stickiness="toNext",this.graveyardPosition=n.clone()}get type(){return"merge"}get deletionPosition(){return new La(this.sourcePosition.root,this.sourcePosition.path.slice(0,-1))}get movedRange(){const e=this.sourcePosition.getShiftedBy(Number.POSITIVE_INFINITY);return new Wa(this.sourcePosition,e)}clone(){return new this.constructor(this.sourcePosition,this.howMany,this.targetPosition,this.graveyardPosition,this.baseVersion)}getReversed(){const e=this.targetPosition._getTransformedByMergeOperation(this),t=this.sourcePosition.path.slice(0,-1),i=new La(this.sourcePosition.root,t)._getTransformedByMergeOperation(this);return new Ac(e,this.howMany,i,this.graveyardPosition,this.baseVersion+1)}_validate(){const e=this.sourcePosition.parent,t=this.targetPosition.parent;if(!e.parent)throw new l("merge-operation-source-position-invalid",this);if(!t.parent)throw new l("merge-operation-target-position-invalid",this);if(this.howMany!=e.maxOffset)throw new l("merge-operation-how-many-invalid",this)}_execute(){const e=this.sourcePosition.parent;dc(Wa._createIn(e),this.targetPosition),dc(Wa._createOn(e),this.graveyardPosition)}toJSON(){const e=super.toJSON();return e.sourcePosition=e.sourcePosition.toJSON(),e.targetPosition=e.targetPosition.toJSON(),e.graveyardPosition=e.graveyardPosition.toJSON(),e}static get className(){return"MergeOperation"}static fromJSON(e,t){const i=La.fromJSON(e.sourcePosition,t),n=La.fromJSON(e.targetPosition,t),s=La.fromJSON(e.graveyardPosition,t);return new this(i,e.howMany,n,s,e.baseVersion)}}class Ac extends rc{constructor(e,t,i,n,s){super(s),this.splitPosition=e.clone(),this.splitPosition.stickiness="toNext",this.howMany=t,this.insertionPosition=i,this.graveyardPosition=n?n.clone():null,this.graveyardPosition&&(this.graveyardPosition.stickiness="toNext")}get type(){return"split"}get moveTargetPosition(){const e=this.insertionPosition.path.slice();return e.push(0),new La(this.insertionPosition.root,e)}get movedRange(){const e=this.splitPosition.getShiftedBy(Number.POSITIVE_INFINITY);return new Wa(this.splitPosition,e)}clone(){return new this.constructor(this.splitPosition,this.howMany,this.insertionPosition,this.graveyardPosition,this.baseVersion)}getReversed(){const e=this.splitPosition.root.document.graveyard,t=new La(e,[0]);return new Cc(this.moveTargetPosition,this.howMany,this.splitPosition,t,this.baseVersion+1)}_validate(){const e=this.splitPosition.parent,t=this.splitPosition.offset;if(!e||e.maxOffset{for(const t of e.getAttributeKeys())this.removeAttribute(t,e)};if(e instanceof Wa)for(const i of e.getItems())t(i);else t(e)}move(e,t,i){if(this._assertWriterUsedCorrectly(),!(e instanceof Wa))throw new l("writer-move-invalid-range",this);if(!e.isFlat)throw new l("writer-move-range-not-flat",this);const n=La._createAt(t,i);if(n.isEqual(e.start))return;if(this._addOperationForAffectedMarkers("move",e),!Rc(e.root,n.root))throw new l("writer-move-different-document",this);const s=e.root.document?e.root.document.version:null,o=new bc(e.start,e.end.offset-e.start.offset,n,s);this.batch.addOperation(o),this.model.applyOperation(o)}remove(e){this._assertWriterUsedCorrectly();const t=(e instanceof Wa?e:Wa._createOn(e)).getMinimalFlatRanges().reverse();for(const e of t)this._addOperationForAffectedMarkers("move",e),Ic(e.start,e.end.offset-e.start.offset,this.batch,this.model)}merge(e){this._assertWriterUsedCorrectly();const t=e.nodeBefore,i=e.nodeAfter;if(this._addOperationForAffectedMarkers("merge",e),!(t instanceof Na))throw new l("writer-merge-no-element-before",this);if(!(i instanceof Na))throw new l("writer-merge-no-element-after",this);e.root.document?this._merge(e):this._mergeDetached(e)}createPositionFromPath(e,t,i){return this.model.createPositionFromPath(e,t,i)}createPositionAt(e,t){return this.model.createPositionAt(e,t)}createPositionAfter(e){return this.model.createPositionAfter(e)}createPositionBefore(e){return this.model.createPositionBefore(e)}createRange(e,t){return this.model.createRange(e,t)}createRangeIn(e){return this.model.createRangeIn(e)}createRangeOn(e){return this.model.createRangeOn(e)}createSelection(e,t,i){return this.model.createSelection(e,t,i)}_mergeDetached(e){const t=e.nodeBefore,i=e.nodeAfter;this.move(Wa._createIn(i),La._createAt(t,"end")),this.remove(i)}_merge(e){const t=La._createAt(e.nodeBefore,"end"),i=La._createAt(e.nodeAfter,0),n=e.root.document.graveyard,s=new La(n,[0]),o=e.root.document.version,r=new Cc(i,e.nodeAfter.maxOffset,t,s,o);this.batch.addOperation(r),this.model.applyOperation(r)}rename(e,t){if(this._assertWriterUsedCorrectly(),!(e instanceof Na))throw new l("writer-rename-not-element-instance",this);const i=e.root.document?e.root.document.version:null,n=new yc(La._createBefore(e),e.name,t,i);this.batch.addOperation(n),this.model.applyOperation(n)}split(e,t){this._assertWriterUsedCorrectly();let i,n,s=e.parent;if(!s.parent)throw new l("writer-split-element-no-parent",this);if(t||(t=s.parent),!e.parent.getAncestors({includeSelf:!0}).includes(t))throw new l("writer-split-invalid-limit-element",this);do{const t=s.root.document?s.root.document.version:null,o=s.maxOffset-e.offset,r=Ac.getInsertionPosition(e),a=new Ac(e,o,r,null,t);this.batch.addOperation(a),this.model.applyOperation(a),i||n||(i=s,n=e.parent.nextSibling),s=(e=this.createPositionAfter(e.parent)).parent}while(s!==t);return{position:e,range:new Wa(La._createAt(i,"end"),La._createAt(n,0))}}wrap(e,t){if(this._assertWriterUsedCorrectly(),!e.isFlat)throw new l("writer-wrap-range-not-flat",this);const i=t instanceof Na?t:new Na(t);if(i.childCount>0)throw new l("writer-wrap-element-not-empty",this);if(null!==i.parent)throw new l("writer-wrap-element-attached",this);this.insert(i,e.start);const n=new Wa(e.start.getShiftedBy(1),e.end.getShiftedBy(1));this.move(n,La._createAt(i,0))}unwrap(e){if(this._assertWriterUsedCorrectly(),null===e.parent)throw new l("writer-unwrap-element-no-parent",this);this.move(Wa._createIn(e),this.createPositionAfter(e)),this.remove(e)}addMarker(e,t){if(this._assertWriterUsedCorrectly(),!t||"boolean"!=typeof t.usingOperation)throw new l("writer-addmarker-no-usingoperation",this);const i=t.usingOperation,n=t.range,s=void 0!==t.affectsData&&t.affectsData;if(this.model.markers.has(e))throw new l("writer-addmarker-marker-exists",this);if(!n)throw new l("writer-addmarker-no-range",this);return i?(Sc(this,e,null,n,s),this.model.markers.get(e)):this.model.markers._set(e,n,i,s)}updateMarker(e,t){this._assertWriterUsedCorrectly();const i="string"==typeof e?e:e.name,n=this.model.markers.get(i);if(!n)throw new l("writer-updatemarker-marker-not-exists",this);if(!t)return c("writer-updatemarker-reconvert-using-editingcontroller",{markerName:i}),void this.model.markers._refresh(n);const s="boolean"==typeof t.usingOperation,o="boolean"==typeof t.affectsData,r=o?t.affectsData:n.affectsData;if(!s&&!t.range&&!o)throw new l("writer-updatemarker-wrong-options",this);const a=n.getRange(),d=t.range?t.range:a;s&&t.usingOperation!==n.managedUsingOperations?t.usingOperation?Sc(this,i,null,d,r):(Sc(this,i,a,null,r),this.model.markers._set(i,d,void 0,r)):n.managedUsingOperations?Sc(this,i,a,d,r):this.model.markers._set(i,d,void 0,r)}removeMarker(e){this._assertWriterUsedCorrectly();const t="string"==typeof e?e:e.name;if(!this.model.markers.has(t))throw new l("writer-removemarker-no-marker",this);const i=this.model.markers.get(t);if(!i.managedUsingOperations)return void this.model.markers._remove(t);Sc(this,t,i.getRange(),null,i.affectsData)}setSelection(e,t,i){this._assertWriterUsedCorrectly(),this.model.document.selection._setTo(e,t,i)}setSelectionFocus(e,t){this._assertWriterUsedCorrectly(),this.model.document.selection._setFocus(e,t)}setSelectionAttribute(e,t){if(this._assertWriterUsedCorrectly(),"string"==typeof e)this._setSelectionAttribute(e,t);else for(const[t,i]of Fn(e))this._setSelectionAttribute(t,i)}removeSelectionAttribute(e){if(this._assertWriterUsedCorrectly(),"string"==typeof e)this._removeSelectionAttribute(e);else for(const t of e)this._removeSelectionAttribute(t)}overrideSelectionGravity(){return this.model.document.selection._overrideGravity()}restoreSelectionGravity(e){this.model.document.selection._restoreGravity(e)}_setSelectionAttribute(e,t){const i=this.model.document.selection;if(i.isCollapsed&&i.anchor.parent.isEmpty){const n=ol._getStoreAttributeKey(e);this.setAttribute(n,t,i.anchor.parent)}i._setAttribute(e,t)}_removeSelectionAttribute(e){const t=this.model.document.selection;if(t.isCollapsed&&t.anchor.parent.isEmpty){const i=ol._getStoreAttributeKey(e);this.removeAttribute(i,t.anchor.parent)}t._removeAttribute(e)}_assertWriterUsedCorrectly(){if(this.model._currentWriter!==this)throw new l("writer-incorrect-use",this)}_addOperationForAffectedMarkers(e,t){for(const i of this.model.markers){if(!i.managedUsingOperations)continue;const n=i.getRange();let s=!1;if("move"===e)s=t.containsPosition(n.start)||t.start.isEqual(n.start)||t.containsPosition(n.end)||t.end.isEqual(n.end);else{const e=t.nodeBefore,i=t.nodeAfter,o=n.start.parent==e&&n.start.isAtEnd,r=n.end.parent==i&&0==n.end.offset,a=n.end.nodeAfter==i,l=n.start.nodeAfter==i;s=o||r||a||l}s&&this.updateMarker(i.name,{range:n})}}}function Ec(e,t,i,n){const s=e.model,o=s.document;let r,a,l,c=n.start;for(const e of n.getWalker({shallow:!0}))l=e.item.getAttribute(t),r&&a!=l&&(a!=i&&d(),c=r),r=e.nextPosition,a=l;function d(){const n=new Wa(c,r),l=n.root.document?o.version:null,d=new pc(n,t,a,i,l);e.batch.addOperation(d),s.applyOperation(d)}r instanceof La&&r!=c&&a!=i&&d()}function Pc(e,t,i,n){const s=e.model,o=s.document,r=n.getAttribute(t);let a,l;if(r!=i){if(n.root===n){const e=n.document?o.version:null;l=new kc(n,t,r,i,e)}else{a=new Wa(La._createBefore(n),e.createPositionAfter(n));const s=a.root.document?o.version:null;l=new pc(a,t,r,i,s)}e.batch.addOperation(l),s.applyOperation(l)}}function Sc(e,t,i,n,s){const o=e.model,r=o.document,a=new _c(t,i,n,o.markers,s,r.version);e.batch.addOperation(a),o.applyOperation(a)}function Ic(e,t,i,n){let s;if(e.root.document){const i=n.document,o=new La(i.graveyard,[0]);s=new bc(e,t,o,i.version)}else s=new wc(e,t);i.addOperation(s),n.applyOperation(s)}function Rc(e,t){return e===t||e instanceof xc&&t instanceof xc}class Vc{constructor(e){this._markerCollection=e,this._changesInElement=new Map,this._elementSnapshots=new Map,this._changedMarkers=new Map,this._changeCount=0,this._cachedChanges=null,this._cachedChangesWithGraveyard=null,this._refreshedItems=new Set}get isEmpty(){return 0==this._changesInElement.size&&0==this._changedMarkers.size}bufferOperation(e){switch(e.type){case"insert":if(this._isInInsertedElement(e.position.parent))return;this._markInsert(e.position.parent,e.position.offset,e.nodes.maxOffset);break;case"addAttribute":case"removeAttribute":case"changeAttribute":for(const t of e.range.getItems({shallow:!0}))this._isInInsertedElement(t.parent)||this._markAttribute(t);break;case"remove":case"move":case"reinsert":{if(e.sourcePosition.isEqual(e.targetPosition)||e.sourcePosition.getShiftedBy(e.howMany).isEqual(e.targetPosition))return;const t=this._isInInsertedElement(e.sourcePosition.parent),i=this._isInInsertedElement(e.targetPosition.parent);t||this._markRemove(e.sourcePosition.parent,e.sourcePosition.offset,e.howMany),i||this._markInsert(e.targetPosition.parent,e.getMovedRangeStart().offset,e.howMany);break}case"rename":{if(this._isInInsertedElement(e.position.parent))return;this._markRemove(e.position.parent,e.position.offset,1),this._markInsert(e.position.parent,e.position.offset,1);const t=Wa._createFromPositionAndShift(e.position,1);for(const e of this._markerCollection.getMarkersIntersectingRange(t)){const t=e.getData();this.bufferMarkerChange(e.name,t,t)}break}case"split":{const t=e.splitPosition.parent;this._isInInsertedElement(t)||this._markRemove(t,e.splitPosition.offset,e.howMany),this._isInInsertedElement(e.insertionPosition.parent)||this._markInsert(e.insertionPosition.parent,e.insertionPosition.offset,1),e.graveyardPosition&&this._markRemove(e.graveyardPosition.parent,e.graveyardPosition.offset,1);break}case"merge":{const t=e.sourcePosition.parent;this._isInInsertedElement(t.parent)||this._markRemove(t.parent,t.startOffset,1);const i=e.graveyardPosition.parent;this._markInsert(i,e.graveyardPosition.offset,1);const n=e.targetPosition.parent;this._isInInsertedElement(n)||this._markInsert(n,e.targetPosition.offset,t.maxOffset);break}}this._cachedChanges=null}bufferMarkerChange(e,t,i){const n=this._changedMarkers.get(e);n?(n.newMarkerData=i,null==n.oldMarkerData.range&&null==i.range&&this._changedMarkers.delete(e)):this._changedMarkers.set(e,{newMarkerData:i,oldMarkerData:t})}getMarkersToRemove(){const e=[];for(const[t,i]of this._changedMarkers)null!=i.oldMarkerData.range&&e.push({name:t,range:i.oldMarkerData.range});return e}getMarkersToAdd(){const e=[];for(const[t,i]of this._changedMarkers)null!=i.newMarkerData.range&&e.push({name:t,range:i.newMarkerData.range});return e}getChangedMarkers(){return Array.from(this._changedMarkers).map((([e,t])=>({name:e,data:{oldRange:t.oldMarkerData.range,newRange:t.newMarkerData.range}})))}hasDataChanges(){if(this._changesInElement.size>0)return!0;for(const{newMarkerData:e,oldMarkerData:t}of this._changedMarkers.values()){if(e.affectsData!==t.affectsData)return!0;if(e.affectsData){const i=e.range&&!t.range,n=!e.range&&t.range,s=e.range&&t.range&&!e.range.isEqual(t.range);if(i||n||s)return!0}}return!1}getChanges(e={includeChangesInGraveyard:!1}){if(this._cachedChanges)return e.includeChangesInGraveyard?this._cachedChangesWithGraveyard.slice():this._cachedChanges.slice();let t=[];for(const e of this._changesInElement.keys()){const i=this._changesInElement.get(e).sort(((e,t)=>e.offset===t.offset?e.type!=t.type?"remove"==e.type?-1:1:0:e.offsete.position.root!=t.position.root?e.position.root.rootNamee));for(const e of t)delete e.changeCount,"attribute"==e.type&&(delete e.position,delete e.length);return this._changeCount=0,this._cachedChangesWithGraveyard=t,this._cachedChanges=t.filter(Mc),e.includeChangesInGraveyard?this._cachedChangesWithGraveyard.slice():this._cachedChanges.slice()}getRefreshedItems(){return new Set(this._refreshedItems)}reset(){this._changesInElement.clear(),this._elementSnapshots.clear(),this._changedMarkers.clear(),this._refreshedItems=new Set,this._cachedChanges=null}_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=Wa._createOn(e);for(const e of this._markerCollection.getMarkersIntersectingRange(t)){const t=e.getData();this.bufferMarkerChange(e.name,t,t)}this._cachedChanges=null}_markInsert(e,t,i){const n={type:"insert",offset:t,howMany:i,count:this._changeCount++};this._markChange(e,n)}_markRemove(e,t,i){const n={type:"remove",offset:t,howMany:i,count:this._changeCount++};this._markChange(e,n),this._removeAllNestedChanges(e,t,i)}_markAttribute(e){const t={type:"attribute",offset:e.startOffset,howMany:e.offsetSize,count:this._changeCount++};this._markChange(e.parent,t)}_markChange(e,t){this._makeSnapshot(e);const i=this._getChangesForElement(e);this._handleChange(t,i),i.push(t);for(let e=0;ei.offset){if(n>s){const e={type:"attribute",offset:s,howMany:n-s,count:this._changeCount++};this._handleChange(e,t),t.push(e)}e.nodesToHandle=i.offset-e.offset,e.howMany=e.nodesToHandle}else e.offset>=i.offset&&e.offsets?(e.nodesToHandle=n-s,e.offset=s):e.nodesToHandle=0);if("remove"==i.type&&e.offseti.offset){const s={type:"attribute",offset:i.offset,howMany:n-i.offset,count:this._changeCount++};this._handleChange(s,t),t.push(s),e.nodesToHandle=i.offset-e.offset,e.howMany=e.nodesToHandle}"attribute"==i.type&&(e.offset>=i.offset&&n<=s?(e.nodesToHandle=0,e.howMany=0,e.offset=0):e.offset<=i.offset&&n>=s&&(i.howMany=0))}}e.howMany=e.nodesToHandle,delete e.nodesToHandle}_getInsertDiff(e,t,i){return{type:"insert",position:La._createAt(e,t),name:i.name,attributes:new Map(i.attributes),length:1,changeCount:this._changeCount++}}_getRemoveDiff(e,t,i){return{type:"remove",position:La._createAt(e,t),name:i.name,attributes:new Map(i.attributes),length:1,changeCount:this._changeCount++}}_getAttributesDiff(e,t,i){const n=[];i=new Map(i);for(const[s,o]of t){const t=i.has(s)?i.get(s):null;t!==o&&n.push({type:"attribute",position:e.start,range:e.clone(),length:1,attributeKey:s,attributeOldValue:o,attributeNewValue:t,changeCount:this._changeCount++}),i.delete(s)}for(const[t,s]of i)n.push({type:"attribute",position:e.start,range:e.clone(),length:1,attributeKey:t,attributeOldValue:null,attributeNewValue:s,changeCount:this._changeCount++});return n}_isInInsertedElement(e){const t=e.parent;if(!t)return!1;const i=this._changesInElement.get(t),n=e.startOffset;if(i)for(const e of i)if("insert"==e.type&&n>=e.offset&&nn){for(let t=0;tthis._version+1&&this._gaps.set(this._version,e),this._version=e}get lastOperation(){return this._operations[this._operations.length-1]}addOperation(e){if(e.baseVersion!==this.version)throw new l("model-document-history-addoperation-incorrect-version",this,{operation:e,historyVersion:this.version});this._operations.push(e),this._version++,this._baseVersionToOperationIndex.set(e.baseVersion,this._operations.length-1)}getOperations(e,t=this.version){if(!this._operations.length)return[];const i=this._operations[0];void 0===e&&(e=i.baseVersion);let n=t-1;for(const[t,i]of this._gaps)e>t&&et&&nthis.lastOperation.baseVersion)return[];let s=this._baseVersionToOperationIndex.get(e);void 0===s&&(s=0);let o=this._baseVersionToOperationIndex.get(n);return void 0===o&&(o=this._operations.length-1),this._operations.slice(s,o+1)}getOperation(e){const t=this._baseVersionToOperationIndex.get(e);if(void 0!==t)return this._operations[t]}setOperationAsUndone(e,t){this._undoPairs.set(t,e),this._undoneOperations.add(e)}isUndoingOperation(e){return this._undoPairs.has(e)}isUndoneOperation(e){return this._undoneOperations.has(e)}getUndoneOperation(e){return this._undoPairs.get(e)}reset(){this._version=0,this._undoPairs=new Map,this._operations=[],this._undoneOperations=new Set,this._gaps=new Map,this._baseVersionToOperationIndex=new Map}}function Dc(e,t){return!!(i=e.charAt(t-1))&&1==i.length&&/[\ud800-\udbff]/.test(i)&&function(e){return!!e&&1==e.length&&/[\udc00-\udfff]/.test(e)}(e.charAt(t));var i}function zc(e,t){return!!(i=e.charAt(t))&&1==i.length&&/[\u0300-\u036f\u1ab0-\u1aff\u1dc0-\u1dff\u20d0-\u20ff\ufe20-\ufe2f]/.test(i);var i}const Lc=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 Fc(e,t){const i=String(e).matchAll(Lc);return Array.from(i).some((e=>e.index{const i=t[0];i.isDocumentOperation&&this.differ.bufferOperation(i)}),{priority:"high"}),this.listenTo(e,"applyOperation",((e,t)=>{const i=t[0];i.isDocumentOperation&&this.history.addOperation(i)}),{priority:"low"}),this.listenTo(this.selection,"change",(()=>{this._hasSelectionChangedFromTheLastChangeBlock=!0})),this.listenTo(e.markers,"update",((e,t,i,n,s)=>{const o={...t.getData(),range:n};this.differ.bufferMarkerChange(t.name,s,o),null===i&&t.on("change",((e,i)=>{const n=t.getData();this.differ.bufferMarkerChange(t.name,{...n,range:i},n)}))}))}get version(){return this.history.version}set version(e){this.history.version=e}get graveyard(){return this.getRoot(Hc)}createRoot(e="$root",t="main"){if(this.roots.get(t))throw new l("model-document-createroot-name-exists",this,{name:t});const i=new xc(this,e,t);return this.roots.add(i),i}destroy(){this.selection.destroy(),this.stopListening()}getRoot(e="main"){return this.roots.get(e)}getRootNames(){return Array.from(this.roots,(e=>e.rootName)).filter((e=>e!=Hc))}registerPostFixer(e){this._postFixers.add(e)}toJSON(){const e=Nn(this);return e.selection="[engine.model.DocumentSelection]",e.model="[engine.model.Model]",e}_handleChangeBlock(e){this._hasDocumentChangedFromTheLastChangeBlock()&&(this._callPostFixers(e),this.selection.refresh(),this.differ.hasDataChanges()?this.fire("change:data",e.batch):this.fire("change",e.batch),this.selection.refresh(),this.differ.reset()),this._hasSelectionChangedFromTheLastChangeBlock=!1}_hasDocumentChangedFromTheLastChangeBlock(){return!this.differ.isEmpty||this._hasSelectionChangedFromTheLastChangeBlock}_getDefaultRoot(){for(const e of this.roots)if(e!==this.graveyard)return e;return this.graveyard}_getDefaultRange(){const e=this._getDefaultRoot(),t=this.model,i=t.schema,n=t.createPositionFromPath(e,[0]);return i.getNearestSelectionRange(n)||t.createRange(n)}_validateSelectionRange(e){return Wc(e.start)&&Wc(e.end)}_callPostFixers(e){let t=!1;do{for(const i of this._postFixers)if(this.selection.refresh(),t=i(e),t)break}while(t)}}function Wc(e){const t=e.textNode;if(t){const i=t.data,n=e.offset-t.startOffset;return!Dc(i,n)&&!zc(i,n)}return!0}dt(jc,p);class Uc{constructor(){this._markers=new Map}[Symbol.iterator](){return this._markers.values()}has(e){const t=e instanceof qc?e.name:e;return this._markers.has(t)}get(e){return this._markers.get(e)||null}_set(e,t,i=!1,n=!1){const s=e instanceof qc?e.name:e;if(s.includes(","))throw new l("markercollection-incorrect-marker-name",this);const o=this._markers.get(s);if(o){const e=o.getData(),r=o.getRange();let a=!1;return r.isEqual(t)||(o._attachLiveRange(tl.fromRange(t)),a=!0),i!=o.managedUsingOperations&&(o._managedUsingOperations=i,a=!0),"boolean"==typeof n&&n!=o.affectsData&&(o._affectsData=n,a=!0),a&&this.fire("update:"+s,o,r,t,e),o}const r=tl.fromRange(t),a=new qc(s,r,i,n);return this._markers.set(s,a),this.fire("update:"+s,a,null,t,{...a.getData(),range:null}),a}_remove(e){const t=e instanceof qc?e.name:e,i=this._markers.get(t);return!!i&&(this._markers.delete(t),this.fire("update:"+t,i,i.getRange(),null,i.getData()),this._destroyMarker(i),!0)}_refresh(e){const t=e instanceof qc?e.name:e,i=this._markers.get(t);if(!i)throw new l("markercollection-refresh-marker-not-exists",this);const n=i.getRange();this.fire("update:"+t,i,n,n,i.getData())}*getMarkersAtPosition(e){for(const t of this)t.getRange().containsPosition(e)&&(yield t)}*getMarkersIntersectingRange(e){for(const t of this)null!==t.getRange().getIntersection(e)&&(yield t)}destroy(){for(const e of this._markers.values())this._destroyMarker(e);this._markers=null,this.stopListening()}*getMarkersGroup(e){for(const t of this._markers.values())t.name.startsWith(e+":")&&(yield t)}_destroyMarker(e){e.stopListening(),e._detachLiveRange()}}dt(Uc,p);class qc{constructor(e,t,i,n){this.name=e,this._liveRange=this._attachLiveRange(t),this._managedUsingOperations=i,this._affectsData=n}get managedUsingOperations(){if(!this._liveRange)throw new l("marker-destroyed",this);return this._managedUsingOperations}get affectsData(){if(!this._liveRange)throw new l("marker-destroyed",this);return this._affectsData}getData(){return{range:this.getRange(),affectsData:this.affectsData,managedUsingOperations:this.managedUsingOperations}}getStart(){if(!this._liveRange)throw new l("marker-destroyed",this);return this._liveRange.start.clone()}getEnd(){if(!this._liveRange)throw new l("marker-destroyed",this);return this._liveRange.end.clone()}getRange(){if(!this._liveRange)throw new l("marker-destroyed",this);return this._liveRange.toRange()}is(e){return"marker"===e||"model:marker"===e}_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}}dt(qc,p);class $c extends rc{get type(){return"noop"}clone(){return new $c(this.baseVersion)}getReversed(){return new $c(this.baseVersion+1)}_execute(){}static get className(){return"NoOperation"}}const Kc={};Kc[pc.className]=pc,Kc[vc.className]=vc,Kc[_c.className]=_c,Kc[bc.className]=bc,Kc[$c.className]=$c,Kc[rc.className]=rc,Kc[yc.className]=yc,Kc[kc.className]=kc,Kc[Ac.className]=Ac,Kc[Cc.className]=Cc;class Gc extends La{constructor(e,t,i="toNone"){if(super(e,t,i),!this.root.is("rootElement"))throw new l("model-liveposition-root-not-rootelement",e);Jc.call(this)}detach(){this.stopListening()}is(e){return"livePosition"===e||"model:livePosition"===e||"position"==e||"model:position"===e}toPosition(){return new La(this.root,this.path.slice(),this.stickiness)}static fromPosition(e,t){return new this(e.root,e.path.slice(),t||e.stickiness)}}function Jc(){this.listenTo(this.root.document.model,"applyOperation",((e,t)=>{const i=t[0];i.isDocumentOperation&&Yc.call(this,i)}),{priority:"low"})}function Yc(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)}}dt(Gc,p);class Qc{constructor(e,t,i){this.model=e,this.writer=t,this.position=i,this.canMergeWith=new Set([this.position.parent]),this.schema=e.schema,this._documentFragment=t.createDocumentFragment(),this._documentFragmentPosition=t.createPositionAt(this._documentFragment,0),this._firstNode=null,this._lastNode=null,this._lastAutoParagraph=null,this._filterAttributesOf=[],this._affectedStart=null,this._affectedEnd=null}handleNodes(e){for(const t of Array.from(e))this._handleNode(t);this._insertPartialFragment(),this._lastAutoParagraph&&this._updateLastNodeFromAutoParagraph(this._lastAutoParagraph),this._mergeOnRight(),this.schema.removeDisallowedAttributes(this._filterAttributesOf,this.writer),this._filterAttributesOf=[]}_updateLastNodeFromAutoParagraph(e){const t=this.writer.createPositionAfter(this._lastNode),i=this.writer.createPositionAfter(e);if(i.isAfter(t)){if(this._lastNode=e,this.position.parent!=e||!this.position.isAtEnd)throw new l("insertcontent-invalid-insertion-position",this);this.position=i,this._setAffectedBoundaries(this.position)}}getSelectionRange(){return this.nodeToSelect?Wa._createOn(this.nodeToSelect):this.model.schema.getNearestSelectionRange(this.position)}getAffectedRange(){return this._affectedStart?new Wa(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=Gc.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 l("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=Gc.fromPosition(e,"toPrevious")),this._affectedEnd&&!this._affectedEnd.isBefore(e)||(this._affectedEnd&&this._affectedEnd.detach(),this._affectedEnd=Gc.fromPosition(e,"toNext"))}_mergeOnLeft(){const e=this._firstNode;if(!(e instanceof Na))return;if(!this._canMergeLeft(e))return;const t=Gc._createBefore(e);t.stickiness="toNext";const i=Gc.fromPosition(this.position,"toNext");this._affectedStart.isEqual(t)&&(this._affectedStart.detach(),this._affectedStart=Gc._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=Gc._createAt(t.nodeBefore,"end","toNext")),this.position=i.toPosition(),i.detach(),this._filterAttributesOf.push(this.position.parent),t.detach()}_mergeOnRight(){const e=this._lastNode;if(!(e instanceof Na))return;if(!this._canMergeRight(e))return;const t=Gc._createAfter(e);if(t.stickiness="toNext",!this.position.isEqual(t))throw new l("insertcontent-invalid-insertion-position",this);this.position=La._createAt(t.nodeBefore,"end");const i=Gc.fromPosition(this.position,"toPrevious");this._affectedEnd.isEqual(t)&&(this._affectedEnd.detach(),this._affectedEnd=Gc._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=Gc._createAt(t.nodeBefore,0,"toPrevious")),this.position=i.toPosition(),i.detach(),this._filterAttributesOf.push(this.position.parent),t.detach()}_canMergeLeft(e){const t=e.previousSibling;return t instanceof Na&&this.canMergeWith.has(t)&&this.model.schema.checkMerge(t,e)}_canMergeRight(e){const t=e.nextSibling;return t instanceof Na&&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 Zc(e,t,i="auto"){const n=e.getSelectedElement();if(n&&t.schema.isObject(n)&&!t.schema.isInline(n))return["before","after"].includes(i)?t.createRange(t.createPositionAt(n,i)):t.createRangeOn(n);const s=Ta(e.getSelectedBlocks());if(!s)return t.createRange(e.focus);if(s.isEmpty)return t.createRange(t.createPositionAt(s,0));const o=t.createPositionAfter(s);return e.focus.isTouching(o)?t.createRange(o):t.createRange(t.createPositionBefore(s))}function Xc(e,t,i,n,s={}){if(!e.schema.isObject(t))throw new l("insertobject-element-not-an-object",e,{object:t});let o;o=i?i.is("selection")?i:e.createSelection(i,n):e.document.selection;let r=o;s.findOptimalPosition&&e.schema.isBlock(t)&&(r=e.createSelection(Zc(o,e,s.findOptimalPosition)));const a=Ta(o.getSelectedBlocks()),c={};return a&&Object.assign(c,e.schema.getAttributesWithProperty(a,"copyOnReplace",!0)),e.change((i=>{r.isCollapsed||e.deleteContent(r,{doNotAutoparagraph:!0});let n=t;const o=r.anchor.parent;!e.schema.checkChild(o,t)&&e.schema.checkChild(o,"paragraph")&&e.schema.checkChild("paragraph",t)&&(n=i.createElement("paragraph"),i.insert(t,n)),e.schema.setAllowedAttributes(n,c,i);const a=e.insertContent(n,r);return a.isCollapsed||s.setSelection&&function(e,t,i,n){const s=e.model;if("after"==i){let i=t.nextSibling;!(i&&s.schema.checkChild(i,"$text"))&&s.schema.checkChild(t.parent,"paragraph")&&(i=e.createElement("paragraph"),s.schema.setAllowedAttributes(i,n,e),s.insertContent(i,e.createPositionAfter(t))),i&&e.setSelection(i,0)}else{if("on"!=i)throw new l("insertobject-invalid-place-parameter-value",s);e.setSelection(t,"on")}}(i,t,s.setSelection,c),a}))}function ed(e,t,i={}){if(t.isCollapsed)return;const n=t.getFirstRange();if("$graveyard"==n.root.rootName)return;const s=e.schema;e.change((e=>{if(!i.doNotResetEntireContent&&function(e,t){const i=e.getLimitElement(t);if(!t.containsEntireContent(i))return!1;const n=t.getFirstRange();if(n.start.parent==n.end.parent)return!1;return e.checkChild(i,"paragraph")}(s,t))return void function(e,t){const i=e.model.schema.getLimitElement(t);e.remove(e.createRangeIn(i)),sd(e,e.createPositionAt(i,0),t)}(e,t);const o={};if(!i.doNotAutoparagraph){const e=t.getSelectedElement();e&&Object.assign(o,s.getAttributesWithProperty(e,"copyOnReplace",!0))}const[r,a]=function(e){const t=e.root.document.model,i=e.start;let n=e.end;if(t.hasContent(e,{ignoreMarkers:!0})){const i=function(e){const t=e.parent,i=t.root.document.model.schema,n=t.getAncestors({parentFirst:!0,includeSelf:!0});for(const e of n){if(i.isLimit(e))return null;if(i.isBlock(e))return e}}(n);if(i&&n.isTouching(t.createPositionAt(i,0))){const i=t.createSelection(e);t.modifySelection(i,{direction:"backward"});const s=i.getLastPosition(),o=t.createRange(s,n);t.hasContent(o,{ignoreMarkers:!0})||(n=s)}}return[Gc.fromPosition(i,"toPrevious"),Gc.fromPosition(n,"toNext")]}(n);r.isTouching(a)||e.remove(e.createRange(r,a)),i.leaveUnmerged||(!function(e,t,i){const n=e.model;if(!nd(e.model.schema,t,i))return;const[s,o]=function(e,t){const i=e.getAncestors(),n=t.getAncestors();let s=0;for(;i[s]&&i[s]==n[s];)s++;return[i[s],n[s]]}(t,i);if(!s||!o)return;!n.hasContent(s,{ignoreMarkers:!0})&&n.hasContent(o,{ignoreMarkers:!0})?id(e,t,i,s.parent):td(e,t,i,s.parent)}(e,r,a),s.removeDisallowedAttributes(r.parent.getChildren(),e)),od(e,t,r),!i.doNotAutoparagraph&&function(e,t){const i=e.checkChild(t,"$text"),n=e.checkChild(t,"paragraph");return!i&&n}(s,r)&&sd(e,r,t,o),r.detach(),a.detach()}))}function td(e,t,i,n){const s=t.parent,o=i.parent;if(s!=n&&o!=n){for(t=e.createPositionAfter(s),(i=e.createPositionBefore(o)).isEqual(t)||e.insert(o,t),e.merge(t);i.parent.isEmpty;){const t=i.parent;i=e.createPositionBefore(t),e.remove(t)}nd(e.model.schema,t,i)&&td(e,t,i,n)}}function id(e,t,i,n){const s=t.parent,o=i.parent;if(s!=n&&o!=n){for(t=e.createPositionAfter(s),(i=e.createPositionBefore(o)).isEqual(t)||e.insert(s,i);t.parent.isEmpty;){const i=t.parent;t=e.createPositionBefore(i),e.remove(i)}i=e.createPositionBefore(o),function(e,t){const i=t.nodeBefore,n=t.nodeAfter;i.name!=n.name&&e.rename(i,n.name);e.clearAttributes(i),e.setAttributes(Object.fromEntries(n.getAttributes()),i),e.merge(t)}(e,i),nd(e.model.schema,t,i)&&id(e,t,i,n)}}function nd(e,t,i){const n=t.parent,s=i.parent;return n!=s&&(!e.isLimit(n)&&!e.isLimit(s)&&function(e,t,i){const n=new Wa(e,t);for(const e of n.getWalker())if(i.isLimit(e.item))return!1;return!0}(t,i,e))}function sd(e,t,i,n={}){const s=e.createElement("paragraph");e.model.schema.setAllowedAttributes(s,n,e),e.insert(s,t),od(e,i,e.createPositionAt(s,0))}function od(e,t,i){t instanceof ol?e.setSelection(i):t.setTo(i)}const rd=' ,.?!:;"-()';function ad(e,t){const{isForward:i,walker:n,unit:s,schema:o,treatEmojiAsSingleUnit:r}=e,{type:a,item:l,nextPosition:c}=t;if("text"==a)return"word"===e.unit?function(e,t){let i=e.position.textNode;if(i){let n=e.position.offset-i.startOffset;for(;!cd(i.data,n,t)&&!dd(i,n,t);){e.next();const s=t?e.position.nodeAfter:e.position.nodeBefore;if(s&&s.is("$text")){const n=s.data.charAt(t?0:s.data.length-1);rd.includes(n)||(e.next(),i=e.position.textNode)}n=e.position.offset-i.startOffset}}return e.position}(n,i):function(e,t,i){const n=e.position.textNode;if(n){const s=n.data;let o=e.position.offset-n.startOffset;for(;Dc(s,o)||"character"==t&&zc(s,o)||i&&Fc(s,o);)e.next(),o=e.position.offset-n.startOffset}return e.position}(n,s,r);if(a==(i?"elementStart":"elementEnd")){if(o.isSelectable(l))return La._createAt(l,i?"after":"before");if(o.checkChild(c,"$text"))return c}else{if(o.isLimit(l))return void n.skip((()=>!0));if(o.checkChild(c,"$text"))return c}}function ld(e,t){const i=e.root,n=La._createAt(i,t?"end":0);return t?new Wa(e,n):new Wa(n,e)}function cd(e,t,i){const n=t+(i?0:-1);return rd.includes(e.charAt(n))}function dd(e,t,i){return t===(i?e.endOffset:0)}function ud(e,t){const i=[];Array.from(e.getItems({direction:"backward"})).map((e=>t.createRangeOn(e))).filter((t=>(t.start.isAfter(e.start)||t.start.isEqual(e.start))&&(t.end.isBefore(e.end)||t.end.isEqual(e.end)))).forEach((e=>{i.push(e.start.parent),t.remove(e)})),i.forEach((e=>{let i=e;for(;i.parent&&i.isEmpty;){const e=t.createRangeOn(i);i=i.parent,t.remove(e)}}))}function hd(e){e.document.registerPostFixer((t=>function(e,t){const i=t.document.selection,n=t.schema,s=[];let o=!1;for(const e of i.getRanges()){const t=md(e,n);t&&!t.isEqual(e)?(s.push(t),o=!0):s.push(e)}o&&e.setSelection(function(e){const t=[...e],i=new Set;let n=1;for(;n!i.has(t)))}(s),{backward:i.isBackward})}(t,e)))}function md(e,t){return e.isCollapsed?function(e,t){const i=e.start,n=t.getNearestSelectionRange(i);if(!n){const e=i.getAncestors().reverse().find((e=>t.isObject(e)));return e?Wa._createOn(e):null}if(!n.isCollapsed)return n;const s=n.start;if(i.isEqual(s))return null;return new Wa(s)}(e,t):function(e,t){const{start:i,end:n}=e,s=t.checkChild(i,"$text"),o=t.checkChild(n,"$text"),r=t.getLimitElement(i),a=t.getLimitElement(n);if(r===a){if(s&&o)return null;if(function(e,t,i){const n=e.nodeAfter&&!i.isLimit(e.nodeAfter)||i.checkChild(e,"$text"),s=t.nodeBefore&&!i.isLimit(t.nodeBefore)||i.checkChild(t,"$text");return n||s}(i,n,t)){const e=i.nodeAfter&&t.isSelectable(i.nodeAfter)?null:t.getNearestSelectionRange(i,"forward"),s=n.nodeBefore&&t.isSelectable(n.nodeBefore)?null:t.getNearestSelectionRange(n,"backward"),o=e?e.start:i,r=s?s.end:n;return new Wa(o,r)}}const l=r&&!r.is("rootElement"),c=a&&!a.is("rootElement");if(l||c){const e=i.nodeAfter&&n.nodeBefore&&i.nodeAfter.parent===n.nodeBefore.parent,s=l&&(!e||!fd(i.nodeAfter,t)),o=c&&(!e||!fd(n.nodeBefore,t));let d=i,u=n;return s&&(d=La._createBefore(gd(r,t))),o&&(u=La._createAfter(gd(a,t))),new Wa(d,u)}return null}(e,t)}function gd(e,t){let i=e,n=i;for(;t.isLimit(n)&&n.parent;)i=n,n=n.parent;return i}function fd(e,t){return e&&t.isSelectable(e)}class pd{constructor(){this.markers=new Uc,this.document=new jc(this),this.schema=new Dl,this._pendingChanges=[],this._currentWriter=null,["insertContent","insertObject","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})),hd(this),this.document.registerPostFixer(Cl)}change(e){try{return 0===this._pendingChanges.length?(this._pendingChanges.push({batch:new oc,callback:e}),this._runPendingChanges()[0]):e(this._currentWriter)}catch(e){l.rethrowUnexpectedError(e,this)}}enqueueChange(e,t){try{e?"function"==typeof e?(t=e,e=new oc):e instanceof oc||(e=new oc(e)):e=new oc,this._pendingChanges.push({batch:e,callback:t}),1==this._pendingChanges.length&&this._runPendingChanges()}catch(e){l.rethrowUnexpectedError(e,this)}}applyOperation(e){e._execute()}insertContent(e,t,i){return function(e,t,i,n){return e.change((s=>{let o;o=i?i instanceof Ya||i instanceof ol?i:s.createSelection(i,n):e.document.selection,o.isCollapsed||e.deleteContent(o,{doNotAutoparagraph:!0});const r=new Qc(e,s,o.anchor);let a;a=t.is("documentFragment")?t.getChildren():[t],r.handleNodes(a);const l=r.getSelectionRange();l&&(o instanceof ol?s.setSelection(l):o.setTo(l));const c=r.getAffectedRange()||e.createRange(o.anchor);return r.destroy(),c}))}(this,e,t,i)}insertObject(e,t,i,n){return Xc(this,e,t,i,n)}deleteContent(e,t){ed(this,e,t)}modifySelection(e,t){!function(e,t,i={}){const n=e.schema,s="backward"!=i.direction,o=i.unit?i.unit:"character",r=!!i.treatEmojiAsSingleUnit,a=t.focus,l=new Da({boundaries:ld(a,s),singleCharacters:!0,direction:s?"forward":"backward"}),c={walker:l,schema:n,isForward:s,unit:o,treatEmojiAsSingleUnit:r};let d;for(;d=l.next();){if(d.done)return;const i=ad(c,d.value);if(i)return void(t instanceof ol?e.change((e=>{e.setSelectionFocus(i)})):t.setFocus(i))}}(this,e,t)}getSelectedContent(e){return function(e,t){return e.change((e=>{const i=e.createDocumentFragment(),n=t.getFirstRange();if(!n||n.isCollapsed)return i;const s=n.start.root,o=n.start.getCommonPath(n.end),r=s.getNodeByPath(o);let a;a=n.start.parent==n.end.parent?n:e.createRange(e.createPositionAt(r,n.start.path[o.length]),e.createPositionAt(r,n.end.path[o.length]+1));const l=a.end.offset-a.start.offset;for(const t of a.getItems({shallow:!0}))t.is("$textProxy")?e.appendText(t.data,t.getAttributes(),i):e.append(e.cloneElement(t,!0),i);if(a!=n){const t=n._getTransformedByMove(a.start,e.createPositionAt(i,0),l)[0],s=e.createRange(e.createPositionAt(i,0),t.start);ud(e.createRange(t.end,e.createPositionAt(i,"end")),e),ud(s,e)}return i}))}(this,e)}hasContent(e,t={}){const i=e instanceof Na?Wa._createIn(e):e;if(i.isCollapsed)return!1;const{ignoreWhitespaces:n=!1,ignoreMarkers:s=!1}=t;if(!s)for(const e of this.markers.getMarkersIntersectingRange(i))if(e.affectsData)return!0;for(const e of i.getItems())if(this.schema.isContent(e)){if(!e.is("$textProxy"))return!0;if(!n)return!0;if(-1!==e.data.search(/\S/))return!0}return!1}createPositionFromPath(e,t,i){return new La(e,t,i)}createPositionAt(e,t){return La._createAt(e,t)}createPositionAfter(e){return La._createAfter(e)}createPositionBefore(e){return La._createBefore(e)}createRange(e,t){return new Wa(e,t)}createRangeIn(e){return Wa._createIn(e)}createRangeOn(e){return Wa._createOn(e)}createSelection(e,t,i){return new Ya(e,t,i)}createBatch(e){return new oc(e)}createOperationFromJSON(e){return class{static fromJSON(e,t){return Kc[e.__className].fromJSON(e,t)}}.fromJSON(e,this.document)}destroy(){this.document.destroy(),this.stopListening()}_runPendingChanges(){const e=[];for(this.fire("_beforeChanges");this._pendingChanges.length;){const t=this._pendingChanges[0].batch;this._currentWriter=new Tc(this,t);const i=this._pendingChanges[0].callback(this._currentWriter);e.push(i),this.document._handleChangeBlock(this._currentWriter),this._pendingChanges.shift(),this._currentWriter=null}return this.fire("_afterChanges"),e}}dt(pd,st);class wd extends Pa{constructor(e){super(),this.editor=e}set(e,t,i={}){if("string"==typeof t){const e=t;t=(t,i)=>{this.editor.execute(e),i()}}super.set(e,t,i)}}class bd{constructor(e={}){const t=e.language||this.constructor.defaultConfig&&this.constructor.defaultConfig.language;this._context=e.context||new On({language:t}),this._context._addEditor(this,!e.context);const i=Array.from(this.constructor.builtinPlugins||[]);this.config=new kn(e,this.constructor.defaultConfig),this.config.define("plugins",i),this.config.define(this._context._getEditorConfig()),this.plugins=new En(this,i,this._context.plugins),this.locale=this._context.locale,this.t=this.locale.t,this._readOnlyLocks=new Set,this.commands=new Bl,this.set("state","initializing"),this.once("ready",(()=>this.state="ready"),{priority:"high"}),this.once("destroy",(()=>this.state="destroyed"),{priority:"high"}),this.model=new pd;const n=new xs;this.data=new tc(this.model,n),this.editing=new Ol(this.model,n),this.editing.view.document.bind("isReadOnly").to(this),this.conversion=new ic([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 wd(this),this.keystrokes.listenTo(this.editing.view.document)}get isReadOnly(){return this._readOnlyLocks.size>0}set isReadOnly(e){throw new l("editor-isreadonly-has-no-setter")}enableReadOnlyMode(e){if("string"!=typeof e&&"symbol"!=typeof e)throw new l("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 l("editor-read-only-lock-id-invalid",null,{lockId:e});this._readOnlyLocks.has(e)&&(this._readOnlyLocks.delete(e),0===this._readOnlyLocks.size&&this.fire("change:isReadOnly","isReadOnly",!1,!0))}initPlugins(){const e=this.config,t=e.get("plugins"),i=e.get("removePlugins")||[],n=e.get("extraPlugins")||[],s=e.get("substitutePlugins")||[];return this.plugins.init(t.concat(n),i,s)}destroy(){let e=Promise.resolve();return"initializing"==this.state&&(e=new Promise((e=>this.once("ready",e)))),e.then((()=>{this.fire("destroy"),this.stopListening(),this.commands.destroy()})).then((()=>this.plugins.destroy())).then((()=>{this.model.destroy(),this.data.destroy(),this.editing.destroy(),this.keystrokes.destroy()})).then((()=>this._context._removeEditor(this)))}execute(...e){try{return this.commands.execute(...e)}catch(e){l.rethrowUnexpectedError(e,this)}}focus(){this.editing.view.focus()}}dt(bd,st);class vd{constructor(e){this.editor=e,this._components=new Map}*names(){for(const e of this._components.values())yield e.originalName}add(e,t){this._components.set(_d(e),{callback:t,originalName:e})}create(e){if(!this.has(e))throw new l("componentfactory-item-missing",this,{name:e});return this._components.get(_d(e)).callback(this.editor.locale)}has(e){return this._components.has(_d(e))}}function _d(e){return String(e).toLowerCase()}class yd{constructor(e){this.editor=e,this.componentFactory=new vd(e),this.focusTracker=new Ea,this.set("viewportOffset",this._readViewportOffsetFromConfig()),this._editableElementsMap=new Map,this.listenTo(e.editing.view.document,"layoutChanged",(()=>this.update()))}get element(){return null}update(){this.fire("update")}destroy(){this.stopListening(),this.focusTracker.destroy();for(const e of this._editableElementsMap.values())e.ckeditorInstance=null;this._editableElementsMap=new Map}setEditableElement(e,t){this._editableElementsMap.set(e,t),t.ckeditorInstance||(t.ckeditorInstance=this.editor)}getEditableElement(e="main"){return this._editableElementsMap.get(e)}getEditableElementsNames(){return this._editableElementsMap.keys()}get _editableElements(){return console.warn("editor-ui-deprecated-editable-elements: The EditorUI#_editableElements property has been deprecated and will be removed in the near future.",{editorUI:this}),this._editableElementsMap}_readViewportOffsetFromConfig(){const e=this.editor,t=e.config.get("ui.viewportOffset");if(t)return t;const i=e.config.get("toolbar.viewportTopOffset");return i?(console.warn("editor-ui-deprecated-viewport-offset-config: The `toolbar.vieportTopOffset` configuration option is deprecated. It will be removed from future CKEditor versions. Use `ui.viewportOffset.top` instead."),{top:i}):{top:0}}}dt(yd,st);const kd={setData(e){this.data.set(e)},getData(e){return this.data.get(e)}};const Cd={updateSourceElement(){if(!this.sourceElement)throw new l("editor-missing-sourceelement",this);var e,t;e=this.sourceElement,t=this.data.get(),e instanceof HTMLTextAreaElement&&(e.value=t),e.innerHTML=t}};class Ad extends Bn{static get pluginName(){return"PendingActions"}init(){this.set("hasAny",!1),this._actions=new Tn({idProperty:"_id"}),this._actions.delegate("add","remove").to(this)}add(e){if("string"!=typeof e)throw new l("pendingactions-add-invalid-message",this);const t=Object.create(st);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 xd=' ',Td=' ',Ed={cancel:' ',caption:' ',check:' ',cog:' ',eraser:' ',lowVision:' ',image:xd,alignBottom:' ',alignMiddle:' ',alignTop:' ',alignLeft:' ',alignCenter:' ',alignRight:' ',alignJustify:' ',objectLeft:' ',objectCenter:' ',objectRight:' ',objectFullWidth:' ',objectInline:' ',objectBlockLeft:' ',objectBlockRight:' ',objectSizeFull:' ',objectSizeLarge:' ',objectSizeSmall:' ',objectSizeMedium:' ',pencil:' ',pilcrow:' ',quote:' ',threeVerticalDots:Td};function Pd({emitter:e,activator:t,callback:i,contextElements:n}){e.listenTo(document,"mousedown",((e,s)=>{if(!t())return;const o="function"==typeof s.composedPath?s.composedPath():[];for(const e of n)if(e.contains(s.target)||o.includes(e))return;i()}))}function Sd(e){e.set("_isCssTransitionsDisabled",!1),e.disableCssTransitions=()=>{e._isCssTransitionsDisabled=!0},e.enableCssTransitions=()=>{e._isCssTransitionsDisabled=!1},e.extendTemplate({attributes:{class:[e.bindTemplate.if("_isCssTransitionsDisabled","ck-transitions-disabled")]}})}function Id({view:e}){e.listenTo(e.element,"submit",((t,i)=>{i.preventDefault(),e.fire("submit")}),{useCapture:!0})}class Rd extends Tn{constructor(e=[]){super(e,{idProperty:"viewUid"}),this.on("add",((e,t,i)=>{this._renderViewIntoCollectionParent(t,i)})),this.on("remove",((e,t)=>{t.element&&this._parentElement&&t.element.remove()})),this._parentElement=null}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 l("ui-viewcollection-delegate-wrong-events",this);return{to:t=>{for(const i of this)for(const n of e)i.delegate(n).to(t);this.on("add",((i,n)=>{for(const i of e)n.delegate(i).to(t)})),this.on("remove",((i,n)=>{for(const i of e)n.stopDelegating(i,t)}))}}}_renderViewIntoCollectionParent(e,t){e.isRendered||e.render(),e.element&&this._parentElement&&this._parentElement.insertBefore(e.element,this._parentElement.children[t])}}class Vd{constructor(e){this.element=null,this.isRendered=!1,this.locale=e,this.t=e&&e.t,this._viewCollections=new Tn,this._unboundChildren=this.createCollection(),this._viewCollections.on("add",((t,i)=>{i.locale=e})),this.decorate("render")}get bindTemplate(){return this._bindTemplate?this._bindTemplate:this._bindTemplate=Od.bind(this,this)}createCollection(e){const t=new Rd(e);return this._viewCollections.add(t),t}registerChild(e){xn(e)||(e=[e]);for(const t of e)this._unboundChildren.add(t)}deregisterChild(e){xn(e)||(e=[e]);for(const t of e)this._unboundChildren.remove(t)}setTemplate(e){this.template=new Od(e)}extendTemplate(e){Od.extend(this.template,e)}render(){if(this.isRendered)throw new l("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)}}dt(Vd,hr),dt(Vd,st);class Od{constructor(e){Object.assign(this,Wd(jd(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,isApplying:!0,revertData:this._revertData}),e}revert(e){if(!this._revertData)throw new l("ui-template-revert-not-applied",[this,e]);this._revertTemplateFromNode(e,this._revertData)}*getViews(){yield*function*e(t){if(t.children)for(const i of t.children)Jd(i)?yield i:Yd(i)&&(yield*e(i))}(this)}static bind(e,t){return{to:(i,n)=>new Md({eventNameOrFunction:i,attribute:i,observable:e,emitter:t,callback:n}),if:(i,n,s)=>new Nd({observable:e,emitter:t,attribute:i,valueIfTrue:n,callback:s})}}static extend(e,t){if(e._isRendered)throw new l("template-extend-render",[this,e]);Kd(e,Wd(jd(t)))}_renderNode(e){let t;if(t=e.node?this.tag&&this.text:this.tag?this.text:!this.text,t)throw new l("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(""),Dd(this.text)?this._bindToObservable({schema:this.text,updater:Ld(t),data:e}):t.textContent=this.text.join(""),t}_renderAttributes(e){let t,i,n,s;if(!this.attributes)return;const o=e.node,r=e.revertData;for(t in this.attributes)if(n=o.getAttribute(t),i=this.attributes[t],r&&(r.attributes[t]=n),s=A(i[0])&&i[0].ns?i[0].ns:null,Dd(i)){const a=s?i[0].value:i;r&&Zd(t)&&a.unshift(n),this._bindToObservable({schema:a,updater:Fd(o,t,s),data:e})}else"style"==t&&"string"!=typeof i[0]?this._renderStyleAttribute(i[0],e):(r&&n&&Zd(t)&&i.unshift(n),i=i.map((e=>e&&e.value||e)).reduce(((e,t)=>e.concat(t)),[]).reduce(qd,""),Gd(i)||o.setAttributeNS(s,t,i))}_renderStyleAttribute(e,t){const i=t.node;for(const n in e){const s=e[n];Dd(s)?this._bindToObservable({schema:[s],updater:Hd(i,n),data:t}):i.style[n]=s}}_renderElementChildren(e){const t=e.node,i=e.intoFragment?document.createDocumentFragment():t,n=e.isApplying;let s=0;for(const o of this.children)if(Qd(o)){if(!n){o.setParent(t);for(const e of o)i.appendChild(e.element)}}else if(Jd(o))n||(o.isRendered||o.render(),i.appendChild(o.element));else if(Ko(o))i.appendChild(o);else if(n){const t={children:[],bindings:[],attributes:{}};e.revertData.children.push(t),o._renderNode({node:i.childNodes[s++],isApplying:!0,revertData:t})}else i.appendChild(o.render());e.intoFragment&&t.appendChild(i)}_setUpListeners(e){if(this.eventListeners)for(const t in this.eventListeners){const i=this.eventListeners[t].map((i=>{const[n,s]=t.split("@");return i.activateDomEventListener(n,s,e)}));e.revertData&&e.revertData.bindings.push(i)}}_bindToObservable({schema:e,updater:t,data:i}){const n=i.revertData;zd(e,t,i);const s=e.filter((e=>!Gd(e))).filter((e=>e.observable)).map((n=>n.activateAttributeListener(e,t,i)));n&&n.bindings.push(s)}_revertTemplateFromNode(e,t){for(const e of t.bindings)for(const t of e)t();if(t.text)e.textContent=t.text;else{for(const i in t.attributes){const n=t.attributes[i];null===n?e.removeAttribute(i):e.setAttribute(i,n)}for(let i=0;izd(e,t,i);return this.emitter.listenTo(this.observable,"change:"+this.attribute,n),()=>{this.emitter.stopListening(this.observable,"change:"+this.attribute,n)}}}class Md extends Bd{activateDomEventListener(e,t,i){const n=(e,i)=>{t&&!i.target.matches(t)||("function"==typeof this.eventNameOrFunction?this.eventNameOrFunction(i):this.observable.fire(this.eventNameOrFunction,i))};return this.emitter.listenTo(i.node,e,n),()=>{this.emitter.stopListening(i.node,e,n)}}}class Nd extends Bd{getValue(e){return!Gd(super.getValue(e))&&(this.valueIfTrue||!0)}}function Dd(e){return!!e&&(e.value&&(e=e.value),Array.isArray(e)?e.some(Dd):e instanceof Bd)}function zd(e,t,{node:i}){let n=function(e,t){return e.map((e=>e instanceof Bd?e.getValue(t):e))}(e,i);n=1==e.length&&e[0]instanceof Nd?n[0]:n.reduce(qd,""),Gd(n)?t.remove():t.set(n)}function Ld(e){return{set(t){e.textContent=t},remove(){e.textContent=""}}}function Fd(e,t,i){return{set(n){e.setAttributeNS(i,t,n)},remove(){e.removeAttributeNS(i,t)}}}function Hd(e,t){return{set(i){e.style[t]=i},remove(){e.style[t]=null}}}function jd(e){return _n(e,(e=>{if(e&&(e instanceof Bd||Yd(e)||Jd(e)||Qd(e)))return e}))}function Wd(e){if("string"==typeof e?e=function(e){return{text:[e]}}(e):e.text&&function(e){e.text=Pn(e.text)}(e),e.on&&(e.eventListeners=function(e){for(const t in e)Ud(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=Pn(e[t].value)),Ud(e,t)}(e.attributes);const t=[];if(e.children)if(Qd(e.children))t.push(e.children);else for(const i of e.children)Yd(i)||Jd(i)||Ko(i)?t.push(i):t.push(new Od(i));e.children=t}return e}function Ud(e,t){e[t]=Pn(e[t])}function qd(e,t){return Gd(t)?e:Gd(e)?t:`${e} ${t}`}function $d(e,t){for(const i in t)e[i]?e[i].push(...t[i]):e[i]=t[i]}function Kd(e,t){if(t.attributes&&(e.attributes||(e.attributes={}),$d(e.attributes,t.attributes)),t.eventListeners&&(e.eventListeners||(e.eventListeners={}),$d(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 l("ui-template-extend-children-mismatch",e);let i=0;for(const n of t.children)Kd(e.children[i++],n)}}function Gd(e){return!e&&0!==e}function Jd(e){return e instanceof Vd}function Yd(e){return e instanceof Od}function Qd(e){return e instanceof Rd}function Zd(e){return"class"==e||"style"==e}class Xd extends Rd{constructor(e,t=[]){super(t),this.locale=e}attachToDom(){this._bodyCollectionContainer=new Od({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=aa(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()}}class eu extends Vd{constructor(){super();const e=this.bindTemplate;this.set("content",""),this.set("viewBox","0 0 20 20"),this.set("fillColor",""),this.setTemplate({tag:"svg",ns:"http://www.w3.org/2000/svg",attributes:{class:["ck","ck-icon"],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");for(t&&(this.viewBox=t),this.element.innerHTML="";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}))}}class tu extends Vd{constructor(e){super(e),this.set("text",""),this.set("position","s");const t=this.bindTemplate;this.setTemplate({tag:"span",attributes:{class:["ck","ck-tooltip",t.to("position",(e=>"ck-tooltip_"+e)),t.if("text","ck-hidden",(e=>!e.trim()))]},children:[{tag:"span",attributes:{class:["ck","ck-tooltip__text"]},children:[{text:t.to("text")}]}]})}}class iu extends Vd{constructor(e){super(e);const t=this.bindTemplate,i=o();this.set("class"),this.set("labelStyle"),this.set("icon"),this.set("isEnabled",!0),this.set("isOn",!1),this.set("isVisible",!0),this.set("isToggleable",!1),this.set("keystroke"),this.set("label"),this.set("tabindex",-1),this.set("tooltip"),this.set("tooltipPosition","s"),this.set("type","button"),this.set("withText",!1),this.set("withKeystroke",!1),this.children=this.createCollection(),this.tooltipView=this._createTooltipView(),this.labelView=this._createLabelView(i),this.iconView=new eu,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)),this.setTemplate({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")],type:t.to("type",(e=>e||"button")),tabindex:t.to("tabindex"),"aria-labelledby":`ck-editor__aria-label_${i}`,"aria-disabled":t.if("isEnabled",!0,(e=>!e)),"aria-pressed":t.to("isOn",(e=>!!this.isToggleable&&String(e)))},children:this.children,on:{mousedown:t.to((e=>{e.preventDefault()})),click:t.to((e=>{this.isEnabled?this.fire("execute"):e.preventDefault()}))}})}render(){super.render(),this.icon&&(this.iconView.bind("content").to(this,"icon"),this.children.add(this.iconView)),this.children.add(this.tooltipView),this.children.add(this.labelView),this.withKeystroke&&this.keystroke&&this.children.add(this.keystrokeView)}focus(){this.element.focus()}_createTooltipView(){const e=new tu;return e.bind("text").to(this,"_tooltipString"),e.bind("position").to(this,"tooltipPosition"),e}_createLabelView(e){const t=new Vd,i=this.bindTemplate;return t.setTemplate({tag:"span",attributes:{class:["ck","ck-button__label"],style:i.to("labelStyle"),id:`ck-editor__aria-label_${e}`},children:[{text:this.bindTemplate.to("label")}]}),t}_createKeystrokeView(){const e=new Vd;return e.setTemplate({tag:"span",attributes:{class:["ck","ck-button__keystroke"]},children:[{text:this.bindTemplate.to("keystroke",(e=>ho(e)))}]}),e}_getTooltipString(e,t,i){return e?"string"==typeof e?e:(i&&(i=ho(i)),e instanceof Function?e(t,i):`${t}${i?` (${i})`:""}`):""}}class nu extends iu{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 Vd;return e.setTemplate({tag:"span",attributes:{class:["ck","ck-button__toggle"]},children:[{tag:"span",attributes:{class:["ck","ck-button__toggle__inner"]}}]}),e}}function su(e,t){const i=e.t,n={Black:i("Black"),"Dim grey":i("Dim grey"),Grey:i("Grey"),"Light grey":i("Light grey"),White:i("White"),Red:i("Red"),Orange:i("Orange"),Yellow:i("Yellow"),"Light green":i("Light green"),Green:i("Green"),Aquamarine:i("Aquamarine"),Turquoise:i("Turquoise"),"Light blue":i("Light blue"),Blue:i("Blue"),Purple:i("Purple")};return t.map((e=>{const t=n[e.label];return t&&t!=e.label&&(e.label=t),e}))}function ou(e){return e.map(ru).filter((e=>!!e))}function ru(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 au extends iu{constructor(e){super(e);const t=this.bindTemplate;this.set("color"),this.set("hasBorder"),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%)"}}function lu(e){return!!(e&&e.getClientRects&&e.getClientRects().length)}class cu{constructor(e){if(Object.assign(this,e),e.actions&&e.keystrokeHandler)for(const t in e.actions){let i=e.actions[t];"string"==typeof i&&(i=[i]);for(const n of i)e.keystrokeHandler.set(n,((e,i)=>{this[t](),i()}))}}get first(){return this.focusables.find(du)||null}get last(){return this.focusables.filter(du).slice(-1)[0]||null}get next(){return this._getFocusableItem(1)}get previous(){return this._getFocusableItem(-1)}get current(){let e=null;return null===this.focusTracker.focusedElement?null:(this.focusables.find(((t,i)=>{const n=t.element===this.focusTracker.focusedElement;return n&&(e=i),n})),e)}focusFirst(){this._focus(this.first)}focusLast(){this._focus(this.last)}focusNext(){this._focus(this.next)}focusPrevious(){this._focus(this.previous)}_focus(e){e&&e.focus()}_getFocusableItem(e){const t=this.current,i=this.focusables.length;if(!i)return null;if(null===t)return this[1===e?"first":"last"];let n=(t+i+e)%i;do{const t=this.focusables.get(n);if(du(t))return t;n=(n+i+e)%i}while(n!==t);return null}}function du(e){return!(!e.focus||!lu(e.element))}class uu extends Vd{constructor(e,t){super(e);const i=t&&t.colorDefinitions||[],n={};t&&t.columns&&(n.gridTemplateColumns=`repeat( ${t.columns}, 1fr)`),this.set("selectedColor"),this.items=this.createCollection(),this.focusTracker=new Ea,this.keystrokes=new Pa,this._focusCycler=new cu({focusables:this.items,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"arrowleft",focusNext:"arrowright"}}),this.items.on("add",((e,t)=>{t.isOn=t.color===this.selectedColor})),i.forEach((e=>{const t=new au;t.set({color:e.color,label:e.label,tooltip:!0,hasBorder:e.options.hasBorder}),t.on("execute",(()=>{this.fire("execute",{value:e.color,hasBorder:e.options.hasBorder,label:e.label})})),this.items.add(t)})),this.setTemplate({tag:"div",children:this.items,attributes:{class:["ck","ck-color-grid"],style:n}}),this.on("change:selectedColor",((e,t,i)=>{for(const e of this.items)e.isOn=e.color===i}))}focus(){this.items.length&&this.items.first.focus()}focusLast(){this.items.length&&this.items.last.focus()}render(){super.render();for(const e of this.items)this.focusTracker.add(e.element);this.items.on("add",((e,t)=>{this.focusTracker.add(t.element)})),this.items.on("remove",((e,t)=>{this.focusTracker.remove(t.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}}const hu=' ';class mu extends iu{constructor(e){super(e),this.arrowView=this._createArrowView(),this.extendTemplate({attributes:{"aria-haspopup":!0}}),this.delegate("execute").to(this,"open")}render(){super.render(),this.children.add(this.arrowView)}_createArrowView(){const e=new eu;return e.content=hu,e.extendTemplate({attributes:{class:"ck-dropdown__arrow"}}),e}}class gu extends Vd{constructor(e){super(e);const t=this.bindTemplate;this.set("class"),this.set("icon"),this.set("isEnabled",!0),this.set("isOn",!1),this.set("isToggleable",!1),this.set("isVisible",!0),this.set("keystroke"),this.set("label"),this.set("tabindex",-1),this.set("tooltip"),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 Pa,this.focusTracker=new Ea,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 iu;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 iu,t=e.bindTemplate;return e.icon=hu,e.extendTemplate({attributes:{class:"ck-splitbutton__arrow","aria-haspopup":!0,"aria-expanded":t.to("isOn",(e=>String(e)))}}),e.bind("isEnabled").to(this),e.delegate("execute").to(this,"open"),e}}class fu extends Vd{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=>e.preventDefault()))}})}focus(){this.children.length&&this.children.first.focus()}focusLast(){if(this.children.length){const e=this.children.last;"function"==typeof e.focusLast?e.focusLast():e.focus()}}}function pu({element:e,target:t,positions:i,limiter:n,fitInViewport:s,viewportOffsetConfig:o}){z(t)&&(t=t()),z(n)&&(n=n());const r=function(e){return e&&e.parentNode?e.offsetParent===Zo.document.body?null:e.offsetParent:null}(e),a=new ua(e);let l;const c={targetRect:new ua(t),elementRect:a,positionedElementAncestor:r};if(n||s){const e=n&&new ua(n).getVisible(),t=s&&function(e){e=Object.assign({top:0,bottom:0,left:0,right:0},e);const t=new ua(Zo.window);return t.top+=e.top,t.height-=e.top,t.bottom-=e.bottom,t.height-=e.bottom,t}(o);Object.assign(c,{limiterRect:e,viewportRect:t}),l=function(e,t){const{elementRect:i}=t,n=i.getArea(),s=e.map((e=>new bu(e,t))).filter((e=>!!e.name));let o=0,r=null;for(const e of s){const{_limiterIntersectionArea:t,_viewportIntersectionArea:i}=e;if(t===n)return e;const s=i**2+t**2;s>o&&(o=s,r=e)}return r}(i,c)||new bu(i[0],c)}else l=new bu(i[0],c);return l}function wu(e){const{scrollX:t,scrollY:i}=Zo.window;return e.clone().moveBy(t,i)}class bu{constructor(e,t){const i=e(t.targetRect,t.elementRect,t.viewportRect);if(!i)return;const{left:n,top:s,name:o,config:r}=i;Object.assign(this,{name:o,config:r}),this._positioningFunctionCorrdinates={left:n,top:s},this._options=t}get left(){return this._absoluteRect.left}get top(){return this._absoluteRect.top}get _limiterIntersectionArea(){const e=this._options.limiterRect;if(e){const t=this._options.viewportRect;if(!t)return e.getIntersectionArea(this._rect);{const i=e.getIntersection(t);if(i)return i.getIntersectionArea(this._rect)}}return 0}get _viewportIntersectionArea(){const e=this._options.viewportRect;return e?e.getIntersectionArea(this._rect):0}get _rect(){return this._cachedRect||(this._cachedRect=this._options.elementRect.clone().moveTo(this._positioningFunctionCorrdinates.left,this._positioningFunctionCorrdinates.top)),this._cachedRect}get _absoluteRect(){return this._cachedAbsoluteRect||(this._cachedAbsoluteRect=wu(this._rect),this._options.positionedElementAncestor&&function(e,t){const i=wu(new ua(t)),n=ca(t);let s=0,o=0;s-=i.left,o-=i.top,s+=t.scrollLeft,o+=t.scrollTop,s-=n.left,o-=n.top,e.moveBy(s,o)}(this._cachedAbsoluteRect,this._options.positionedElementAncestor)),this._cachedAbsoluteRect}}class vu extends Vd{constructor(e,t,i){super(e);const n=this.bindTemplate;this.buttonView=t,this.panelView=i,this.set("isOpen",!1),this.set("isEnabled",!0),this.set("class"),this.set("id"),this.set("panelPosition","auto"),this.keystrokes=new Pa,this.setTemplate({tag:"div",attributes:{class:["ck","ck-dropdown",n.to("class"),n.if("isEnabled","ck-disabled",(e=>!e))],id:n.to("id"),"aria-describedby":n.to("ariaDescribedById")},children:[t,i]}),t.extendTemplate({attributes:{class:["ck-dropdown__button"]}})}render(){super.render(),this.listenTo(this.buttonView,"open",(()=>{this.isOpen=!this.isOpen})),this.panelView.bind("isVisible").to(this,"isOpen"),this.on("change:isOpen",(()=>{this.isOpen&&("auto"===this.panelPosition?this.panelView.position=vu._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.buttonView.focus(),this.isOpen=!1,t())};this.keystrokes.set("arrowdown",((e,t)=>{this.buttonView.isEnabled&&!this.isOpen&&(this.isOpen=!0,t())})),this.keystrokes.set("arrowright",((e,t)=>{this.isOpen&&t()})),this.keystrokes.set("arrowleft",e),this.keystrokes.set("esc",e)}focus(){this.buttonView.focus()}get _panelPositions(){const{south:e,north:t,southEast:i,southWest:n,northEast:s,northWest:o,southMiddleEast:r,southMiddleWest:a,northMiddleEast:l,northMiddleWest:c}=vu.defaultPanelPositions;return"rtl"!==this.locale.uiLanguageDirection?[i,n,r,a,e,s,o,l,c,t]:[n,i,a,r,e,o,s,c,l,t]}}vu.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"})},vu._getOptimalPosition=pu;class _u extends Vd{constructor(e){super(e),this.setTemplate({tag:"span",attributes:{class:["ck","ck-toolbar__separator"]}})}}class yu extends Vd{constructor(e){super(e),this.setTemplate({tag:"span",attributes:{class:["ck","ck-toolbar__line-break"]}})}}function ku(e){return Array.isArray(e)?{items:e,removeItems:[]}:e?Object.assign({items:[],removeItems:[]},e):{items:[],removeItems:[]}}class Cu extends Vd{constructor(e,t){super(e);const i=this.bindTemplate,n=this.t;this.options=t||{},this.set("ariaLabel",n("Editor toolbar")),this.set("maxWidth","auto"),this.items=this.createCollection(),this.focusTracker=new Ea,this.keystrokes=new Pa,this.set("class"),this.set("isCompact",!1),this.itemsView=new Au(e),this.children=this.createCollection(),this.children.add(this.itemsView),this.focusables=this.createCollection();const s="rtl"===e.uiLanguageDirection;this._focusCycler=new cu({focusables:this.focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:[s?"arrowright":"arrowleft","arrowup"],focusNext:[s?"arrowleft":"arrowright","arrowdown"]}});const o=["ck","ck-toolbar",i.to("class"),i.if("isCompact","ck-toolbar_compact")];var r;this.options.shouldGroupWhenFull&&this.options.isFloating&&o.push("ck-toolbar_floating"),this.setTemplate({tag:"div",attributes:{class:o,role:"toolbar","aria-label":i.to("ariaLabel"),style:{maxWidth:i.to("maxWidth")}},children:this.children,on:{mousedown:(r=this,r.bindTemplate.to((e=>{e.target===r.element&&e.preventDefault()})))}}),this._behavior=this.options.shouldGroupWhenFull?new Tu(this):new xu(this)}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),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){const i=ku(e),n=i.items.filter(((e,n,s)=>"|"===e||-1===i.removeItems.indexOf(e)&&("-"===e?!this.options.shouldGroupWhenFull||(c("toolbarview-line-break-ignored-when-grouping-items",s),!1):!!t.has(e)||(c("toolbarview-item-unavailable",{name:e}),!1)))),s=this._cleanSeparators(n).map((e=>"|"===e?new _u:"-"===e?new yu:t.create(e)));this.items.addMany(s)}_cleanSeparators(e){const t=e=>"-"!==e&&"|"!==e,i=e.length,n=e.findIndex(t),s=i-e.slice().reverse().findIndex(t);return e.slice(n,s).filter(((e,i,n)=>{if(t(e))return!0;return!(i>0&&n[i-1]===e)}))}}class Au extends Vd{constructor(e){super(e),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-toolbar__items"]},children:this.children})}}class xu{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 Tu{constructor(e){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(),this.resizeObserver=null,this.cachedPadding=null,this.shouldUpdateGroupingOnNextResize=!1,e.itemsView.children.bindTo(this.ungroupedItems).using((e=>e)),this.ungroupedItems.on("add",this._updateFocusCycleableItems.bind(this)),this.ungroupedItems.on("remove",this._updateFocusCycleableItems.bind(this)),e.children.on("add",this._updateFocusCycleableItems.bind(this)),e.children.on("remove",this._updateFocusCycleableItems.bind(this)),e.items.on("change",((e,t)=>{const i=t.index;for(const e of t.removed)i>=this.ungroupedItems.length?this.groupedItems.remove(e):this.ungroupedItems.remove(e);for(let e=i;ethis.ungroupedItems.length?this.groupedItems.add(n,e-this.ungroupedItems.length):this.ungroupedItems.add(n,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(!lu(this.viewElement))return void(this.shouldUpdateGroupingOnNextResize=!0);const e=this.groupedItems.length;let t;for(;this._areItemsOverflowing;)this._groupLastItem(),t=!0;if(!t&&this.groupedItems.length){for(;this.groupedItems.length&&!this._areItemsOverflowing;)this._ungroupFirstItem();this._areItemsOverflowing&&this._groupLastItem()}this.groupedItems.length!==e&&this.view.fire("groupedItemsUpdate")}get _areItemsOverflowing(){if(!this.ungroupedItems.length)return!1;const e=this.viewElement,t=this.viewLocale.uiLanguageDirection,i=new ua(e.lastChild),n=new ua(e);if(!this.cachedPadding){const i=Zo.window.getComputedStyle(e),n="ltr"===t?"paddingRight":"paddingLeft";this.cachedPadding=Number.parseInt(i[n])}return"ltr"===t?i.right>n.right-this.cachedPadding:i.left{e&&e===t.contentRect.width&&!this.shouldUpdateGroupingOnNextResize||(this.shouldUpdateGroupingOnNextResize=!1,this._updateGrouping(),e=t.contentRect.width)})),this._updateGrouping()}_enableGroupingOnMaxWidthChange(e){e.on("change:maxWidth",(()=>{this._updateGrouping()}))}_groupLastItem(){this.groupedItems.length||(this.viewChildren.add(new _u),this.viewChildren.add(this.groupedItemsDropdown),this.viewFocusTracker.add(this.groupedItemsDropdown.element)),this.groupedItems.add(this.ungroupedItems.remove(this.ungroupedItems.last),0)}_ungroupFirstItem(){this.ungroupedItems.add(this.groupedItems.remove(this.groupedItems.first)),this.groupedItems.length||(this.viewChildren.remove(this.groupedItemsDropdown),this.viewChildren.remove(this.viewChildren.last),this.viewFocusTracker.remove(this.groupedItemsDropdown.element))}_createGroupedItemsDropdown(){const e=this.viewLocale,t=e.t,i=Iu(e);return i.class="ck-toolbar__grouped-dropdown",i.panelPosition="ltr"===e.uiLanguageDirection?"sw":"se",Ru(i,[]),i.buttonView.set({label:t("Show more items"),tooltip:!0,tooltipPosition:"rtl"===e.uiLanguageDirection?"se":"sw",icon:Td}),i.toolbarView.items.bindTo(this.groupedItems).using((e=>e)),i}_updateFocusCycleableItems(){this.viewFocusables.clear(),this.ungroupedItems.map((e=>{this.viewFocusables.add(e)})),this.groupedItems.length&&this.viewFocusables.add(this.groupedItemsDropdown)}}class Eu extends Vd{constructor(){super(),this.items=this.createCollection(),this.focusTracker=new Ea,this.keystrokes=new Pa,this._focusCycler=new cu({focusables:this.items,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"arrowup",focusNext:"arrowdown"}}),this.setTemplate({tag:"ul",attributes:{class:["ck","ck-reset","ck-list"]},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 Pu extends Vd{constructor(e){super(e),this.children=this.createCollection(),this.setTemplate({tag:"li",attributes:{class:["ck","ck-list__item"]},children:this.children})}focus(){this.children.first.focus()}}class Su extends Vd{constructor(e){super(e),this.setTemplate({tag:"li",attributes:{class:["ck","ck-list__separator"]}})}}function Iu(e,t=mu){const i=new t(e),n=new fu(e),s=new vu(e,i,n);return i.bind("isEnabled").to(s),i instanceof mu?i.bind("isOn").to(s,"isOpen"):i.arrowView.bind("isOn").to(s,"isOpen"),function(e){(function(e){e.on("render",(()=>{Pd({emitter:e,activator:()=>e.isOpen,callback:()=>{e.isOpen=!1},contextElements:[e.element]})}))})(e),function(e){e.on("execute",(t=>{t.source instanceof nu||(e.isOpen=!1)}))}(e),function(e){e.keystrokes.set("arrowdown",((t,i)=>{e.isOpen&&(e.panelView.focus(),i())})),e.keystrokes.set("arrowup",((t,i)=>{e.isOpen&&(e.panelView.focusLast(),i())}))}(e)}(s),s}function Ru(e,t){const i=e.locale,n=i.t,s=e.toolbarView=new Cu(i);s.set("ariaLabel",n("Dropdown toolbar")),e.extendTemplate({attributes:{class:["ck-toolbar-dropdown"]}}),t.map((e=>s.items.add(e))),e.panelView.children.add(s),s.items.delegate("execute").to(e)}function Vu(e,t){const i=e.locale,n=e.listView=new Eu(i);n.items.bindTo(t).using((({type:e,model:t})=>{if("separator"===e)return new Su(i);if("button"===e||"switchbutton"===e){const n=new Pu(i);let s;return s="button"===e?new iu(i):new nu(i),s.bind(...Object.keys(t)).to(t),s.delegate("execute").to(n),n.children.add(s),n}})),e.panelView.children.add(n),n.items.delegate("execute").to(e)}class Ou extends Vd{constructor(e){super(e),this.body=new Xd(e)}render(){super.render(),this.body.attachToDom()}destroy(){return this.body.detachFromDom(),super.destroy()}}class Bu extends Vd{constructor(e){super(e),this.set("text"),this.set("for"),this.id=`ck-editor__label_${o()}`;const t=this.bindTemplate;this.setTemplate({tag:"label",attributes:{class:["ck","ck-label"],id:this.id,for:t.to("for")},children:[{text:t.to("text")}]})}}class Mu extends Ou{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 Bu;return t.text=e("Rich Text Editor"),t.extendTemplate({attributes:{class:"ck-voice-label"}}),t}}class Nu extends Vd{constructor(e,t,i){super(e),this.setTemplate({tag:"div",attributes:{class:["ck","ck-content","ck-editor__editable","ck-rounded-corners"],lang:e.contentLanguage,dir:e.contentLanguageDirection}}),this.name=null,this.set("isFocused",!1),this._editableElement=i,this._hasExternalElement=!!this._editableElement,this._editingView=t}render(){super.render(),this._hasExternalElement?this.template.apply(this.element=this._editableElement):this._editableElement=this.element,this.on("change:isFocused",(()=>this._updateIsFocusedClasses())),this._updateIsFocusedClasses()}destroy(){this._hasExternalElement&&this.template.revert(this._editableElement),super.destroy()}_updateIsFocusedClasses(){const e=this._editingView;function t(t){e.change((i=>{const n=e.document.getRoot(t.name);i.addClass(t.isFocused?"ck-focused":"ck-blurred",n),i.removeClass(t.isFocused?"ck-blurred":"ck-focused",n)}))}e.isRenderingInProgress?function i(n){e.once("change:isRenderingInProgress",((e,s,o)=>{o?i(n):t(n)}))}(this):t(this)}}class Du extends Nu{constructor(e,t,i){super(e,t,i),this.extendTemplate({attributes:{role:"textbox",class:"ck-editor__editable_inline"}})}render(){super.render();const e=this._editingView,t=this.t;e.change((i=>{const n=e.document.getRoot(this.name);i.setAttribute("aria-label",t("Rich Text Editor, %0",this.name),n)}))}}class zu extends Vd{constructor(e,t={}){super(e);const i=this.bindTemplate;this.set("label",t.label||""),this.set("class",t.class||null),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-form__header",i.to("class")]},children:this.children});const n=new Vd(e);n.setTemplate({tag:"span",attributes:{class:["ck","ck-form__header__label"]},children:[{text:i.to("label")}]}),this.children.add(n)}}class Lu extends Vd{constructor(e){super(e),this.set("value"),this.set("id"),this.set("placeholder"),this.set("isReadOnly",!1),this.set("hasError",!1),this.set("ariaDescribedById"),this.focusTracker=new Ea,this.bind("isFocused").to(this.focusTracker),this.set("isEmpty",!0),this.set("inputMode","text");const t=this.bindTemplate;this.setTemplate({tag:"input",attributes:{class:["ck","ck-input",t.if("isFocused","ck-input_focused"),t.if("isEmpty","ck-input-text_empty"),t.if("hasError","ck-error")],id:t.to("id"),placeholder:t.to("placeholder"),readonly:t.to("isReadOnly"),inputmode:t.to("inputMode"),"aria-invalid":t.if("hasError",!0),"aria-describedby":t.to("ariaDescribedById")},on:{input:t.to(((...e)=>{this.fire("input",...e),this._updateIsEmpty()})),change:t.to(this._updateIsEmpty.bind(this))}})}render(){super.render(),this.focusTracker.add(this.element),this._setDomElementValue(this.value),this._updateIsEmpty(),this.on("change:value",((e,t,i)=>{this._setDomElementValue(i),this._updateIsEmpty()}))}destroy(){super.destroy(),this.focusTracker.destroy()}select(){this.element.select()}focus(){this.element.focus()}_updateIsEmpty(){this.isEmpty=!this.element.value}_setDomElementValue(e){this.element.value=e||0===e?e:""}}class Fu extends Lu{constructor(e){super(e),this.extendTemplate({attributes:{type:"text",class:["ck-input-text"]}})}}class Hu extends Lu{constructor(e,{min:t,max:i,step:n}={}){super(e);const s=this.bindTemplate;this.set("min",t),this.set("max",i),this.set("step",n),this.extendTemplate({attributes:{type:"number",class:["ck-input-number"],min:s.to("min"),max:s.to("max"),step:s.to("step")}})}}class ju extends Vd{constructor(e,t){super(e);const i=`ck-labeled-field-view-${o()}`,n=`ck-labeled-field-view-status-${o()}`;this.fieldView=t(this,i,n),this.set("label"),this.set("isEnabled",!0),this.set("isEmpty",!0),this.set("isFocused",!1),this.set("errorText",null),this.set("infoText",null),this.set("class"),this.set("placeholder"),this.labelView=this._createLabelView(i),this.statusView=this._createStatusView(n),this.bind("_statusText").to(this,"errorText",this,"infoText",((e,t)=>e||t));const s=this.bindTemplate;this.setTemplate({tag:"div",attributes:{class:["ck","ck-labeled-field-view",s.to("class"),s.if("isEnabled","ck-disabled",(e=>!e)),s.if("isEmpty","ck-labeled-field-view_empty"),s.if("isFocused","ck-labeled-field-view_focused"),s.if("placeholder","ck-labeled-field-view_placeholder"),s.if("errorText","ck-error")]},children:[{tag:"div",attributes:{class:["ck","ck-labeled-field-view__input-wrapper"]},children:[this.fieldView,this.labelView]},this.statusView]})}_createLabelView(e){const t=new Bu(this.locale);return t.for=e,t.bind("text").to(this,"label"),t}_createStatusView(e){const t=new Vd(this.locale),i=this.bindTemplate;return t.setTemplate({tag:"div",attributes:{class:["ck","ck-labeled-field-view__status",i.if("errorText","ck-labeled-field-view__status_error"),i.if("_statusText","ck-hidden",(e=>!e))],id:e,role:i.if("errorText","alert")},children:[{text:i.to("_statusText")}]}),t}focus(){this.fieldView.focus()}}function Wu(e,t,i){const n=new Fu(e.locale);return n.set({id:t,ariaDescribedById:i}),n.bind("isReadOnly").to(e,"isEnabled",(e=>!e)),n.bind("hasError").to(e,"errorText",(e=>!!e)),n.on("input",(()=>{e.errorText=null})),e.bind("isEmpty","isFocused","placeholder").to(n),n}function Uu(e,t,i){const n=new Hu(e.locale);return n.set({id:t,ariaDescribedById:i,inputMode:"numeric"}),n.bind("isReadOnly").to(e,"isEnabled",(e=>!e)),n.bind("hasError").to(e,"errorText",(e=>!!e)),n.on("input",(()=>{e.errorText=null})),e.bind("isEmpty","isFocused","placeholder").to(n),n}function qu(e,t,i){const n=Iu(e.locale);return n.set({id:t,ariaDescribedById:i}),n.bind("isEnabled").to(e),n}class $u extends Bn{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=`show:${e.type}`+(e.namespace?`:${e.namespace}`:"");this.fire(t,{message:e.message,type:e.type,title:e.title||""})}}class Ku{constructor(e,t){t&&Qe(this,t),e&&this.set(e)}}function Gu(e){return t=>t+e}dt(Ku,st);const Ju=Gu("px"),Yu=Zo.document.body;class Qu extends Vd{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"),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",Ju),left:t.to("left",Ju)}},children:this.content})}show(){this.isVisible=!0}hide(){this.isVisible=!1}attachTo(e){this.show();const t=Qu.defaultPositions,i=Object.assign({},{element:this.element,positions:[t.southArrowNorth,t.southArrowNorthMiddleWest,t.southArrowNorthMiddleEast,t.southArrowNorthWest,t.southArrowNorthEast,t.northArrowSouth,t.northArrowSouthMiddleWest,t.northArrowSouthMiddleEast,t.northArrowSouthWest,t.northArrowSouthEast,t.viewportStickyNorth],limiter:Yu,fitInViewport:!0},e),n=Qu._getOptimalPosition(i),s=parseInt(n.left),o=parseInt(n.top),{name:r,config:a={}}=n,{withArrow:l=!0}=a;Object.assign(this,{top:o,left:s,position:r,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=Zu(e.target),i=e.limiter?Zu(e.limiter):Yu;this.listenTo(Zo.document,"scroll",((n,s)=>{const o=s.target,r=t&&o.contains(t),a=i&&o.contains(i);!r&&!a&&t&&i||this.attachTo(e)}),{useCapture:!0}),this.listenTo(Zo.window,"resize",(()=>{this.attachTo(e)}))}_stopPinning(){this.stopListening(Zo.document,"scroll"),this.stopListening(Zo.window,"resize")}}function Zu(e){return yn(e)?e:la(e)?e.commonAncestorContainer:"function"==typeof e?Zu(e()):null}Qu.arrowHorizontalOffset=25,Qu.arrowVerticalOffset=10,Qu.stickyVerticalOffset=20,Qu._getOptimalPosition=pu,Qu.defaultPositions=function({horizontalOffset:e=Qu.arrowHorizontalOffset,verticalOffset:t=Qu.arrowVerticalOffset,stickyVerticalOffset:i=Qu.stickyVerticalOffset,config:n}={}){return{northWestArrowSouthWest:(t,i)=>({top:s(t,i),left:t.left-e,name:"arrow_sw",...n&&{config:n}}),northWestArrowSouthMiddleWest:(t,i)=>({top:s(t,i),left:t.left-.25*i.width-e,name:"arrow_smw",...n&&{config:n}}),northWestArrowSouth:(e,t)=>({top:s(e,t),left:e.left-t.width/2,name:"arrow_s",...n&&{config:n}}),northWestArrowSouthMiddleEast:(t,i)=>({top:s(t,i),left:t.left-.75*i.width+e,name:"arrow_sme",...n&&{config:n}}),northWestArrowSouthEast:(t,i)=>({top:s(t,i),left:t.left-i.width+e,name:"arrow_se",...n&&{config:n}}),northArrowSouthWest:(t,i)=>({top:s(t,i),left:t.left+t.width/2-e,name:"arrow_sw",...n&&{config:n}}),northArrowSouthMiddleWest:(t,i)=>({top:s(t,i),left:t.left+t.width/2-.25*i.width-e,name:"arrow_smw",...n&&{config:n}}),northArrowSouth:(e,t)=>({top:s(e,t),left:e.left+e.width/2-t.width/2,name:"arrow_s",...n&&{config:n}}),northArrowSouthMiddleEast:(t,i)=>({top:s(t,i),left:t.left+t.width/2-.75*i.width+e,name:"arrow_sme",...n&&{config:n}}),northArrowSouthEast:(t,i)=>({top:s(t,i),left:t.left+t.width/2-i.width+e,name:"arrow_se",...n&&{config:n}}),northEastArrowSouthWest:(t,i)=>({top:s(t,i),left:t.right-e,name:"arrow_sw",...n&&{config:n}}),northEastArrowSouthMiddleWest:(t,i)=>({top:s(t,i),left:t.right-.25*i.width-e,name:"arrow_smw",...n&&{config:n}}),northEastArrowSouth:(e,t)=>({top:s(e,t),left:e.right-t.width/2,name:"arrow_s",...n&&{config:n}}),northEastArrowSouthMiddleEast:(t,i)=>({top:s(t,i),left:t.right-.75*i.width+e,name:"arrow_sme",...n&&{config:n}}),northEastArrowSouthEast:(t,i)=>({top:s(t,i),left:t.right-i.width+e,name:"arrow_se",...n&&{config:n}}),southWestArrowNorthWest:(t,i)=>({top:o(t),left:t.left-e,name:"arrow_nw",...n&&{config:n}}),southWestArrowNorthMiddleWest:(t,i)=>({top:o(t),left:t.left-.25*i.width-e,name:"arrow_nmw",...n&&{config:n}}),southWestArrowNorth:(e,t)=>({top:o(e),left:e.left-t.width/2,name:"arrow_n",...n&&{config:n}}),southWestArrowNorthMiddleEast:(t,i)=>({top:o(t),left:t.left-.75*i.width+e,name:"arrow_nme",...n&&{config:n}}),southWestArrowNorthEast:(t,i)=>({top:o(t),left:t.left-i.width+e,name:"arrow_ne",...n&&{config:n}}),southArrowNorthWest:(t,i)=>({top:o(t),left:t.left+t.width/2-e,name:"arrow_nw",...n&&{config:n}}),southArrowNorthMiddleWest:(t,i)=>({top:o(t),left:t.left+t.width/2-.25*i.width-e,name:"arrow_nmw",...n&&{config:n}}),southArrowNorth:(e,t)=>({top:o(e),left:e.left+e.width/2-t.width/2,name:"arrow_n",...n&&{config:n}}),southArrowNorthMiddleEast:(t,i)=>({top:o(t),left:t.left+t.width/2-.75*i.width+e,name:"arrow_nme",...n&&{config:n}}),southArrowNorthEast:(t,i)=>({top:o(t),left:t.left+t.width/2-i.width+e,name:"arrow_ne",...n&&{config:n}}),southEastArrowNorthWest:(t,i)=>({top:o(t),left:t.right-e,name:"arrow_nw",...n&&{config:n}}),southEastArrowNorthMiddleWest:(t,i)=>({top:o(t),left:t.right-.25*i.width-e,name:"arrow_nmw",...n&&{config:n}}),southEastArrowNorth:(e,t)=>({top:o(e),left:e.right-t.width/2,name:"arrow_n",...n&&{config:n}}),southEastArrowNorthMiddleEast:(t,i)=>({top:o(t),left:t.right-.75*i.width+e,name:"arrow_nme",...n&&{config:n}}),southEastArrowNorthEast:(t,i)=>({top:o(t),left:t.right-i.width+e,name:"arrow_ne",...n&&{config:n}}),viewportStickyNorth:(e,t,s)=>e.getIntersection(s)?{top:s.top+i,left:e.left+e.width/2-t.width/2,name:"arrowless",config:{withArrow:!1,...n}}:null};function s(e,i){return e.top-i.height-t}function o(e){return e.bottom+t}}();const Xu=Gu("px");class eh extends ut{static get pluginName(){return"ContextualBalloon"}constructor(e){super(e),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.view=new Qu(e.locale),e.ui.view.body.add(this.view),e.ui.focusTracker.add(this.view.element),this._viewToStack=new Map,this._idToStack=new Map,this.set("_numberOfStacks",0),this.set("_singleViewMode",!1),this._rotatorView=this._createRotatorView(),this._fakePanelsView=this._createFakePanelsView()}destroy(){super.destroy(),this.view.destroy(),this._rotatorView.destroy(),this._fakePanelsView.destroy()}hasView(e){return Array.from(this._viewToStack.keys()).includes(e)}add(e){if(this.hasView(e.view))throw new l("contextualballoon-add-view-exist",[this,e]);const t=e.stackId||"main";if(!this._idToStack.has(t))return this._idToStack.set(t,new Map([[e.view,e]])),this._viewToStack.set(e.view,this._idToStack.get(t)),this._numberOfStacks=this._idToStack.size,void(this._visibleStack&&!e.singleViewMode||this.showStack(t));const i=this._idToStack.get(t);e.singleViewMode&&this.showStack(t),i.set(e.view,e),this._viewToStack.set(e.view,i),i===this._visibleStack&&this._showView(e)}remove(e){if(!this.hasView(e))throw new l("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 l("contextualballoon-showstack-stack-not-exist",this);this._visibleStack!==t&&this._showView(Array.from(t.values()).pop())}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 th(this.editor.locale),t=this.editor.locale.t;return this.view.content.add(e),e.bind("isNavigationVisible").to(this,"_numberOfStacks",this,"_singleViewMode",((e,t)=>!t&&e>1)),e.on("change:isNavigationVisible",(()=>this.updatePosition()),{priority:"low"}),e.bind("counter").to(this,"visibleView",this,"_numberOfStacks",((e,i)=>{if(i<2)return"";const n=Array.from(this._idToStack.values()).indexOf(this._visibleStack)+1;return t("%0 of %1",[n,i])})),e.buttonNextView.on("execute",(()=>{e.focusTracker.isFocused&&this.editor.editing.view.focus(),this._showNextStack()})),e.buttonPrevView.on("execute",(()=>{e.focusTracker.isFocused&&this.editor.editing.view.focus(),this._showPrevStack()})),e}_createFakePanelsView(){const e=new ih(this.editor.locale,this.view);return e.bind("numberOfPanels").to(this,"_numberOfStacks",this,"_singleViewMode",((e,t)=>!t&&e>=2?Math.min(e-1,2):0)),e.listenTo(this.view,"change:top",(()=>e.updatePosition())),e.listenTo(this.view,"change:left",(()=>e.updatePosition())),this.editor.ui.view.body.add(e),e}_showView({view:e,balloonClassName:t="",withArrow:i=!0,singleViewMode:n=!1}){this.view.class=t,this.view.withArrow=i,this._rotatorView.showView(e),this.visibleView=e,this.view.pin(this._getBalloonPosition()),this._fakePanelsView.updatePosition(),n&&(this._singleViewMode=!0)}_getBalloonPosition(){let e=Array.from(this._visibleStack.values()).pop().position;return e&&(e.limiter||(e=Object.assign({},e,{limiter:this.positionLimiter})),e=Object.assign({},e,{viewportOffsetConfig:this.editor.ui.viewportOffset})),e}}class th extends Vd{constructor(e){super(e);const t=e.t,i=this.bindTemplate;this.set("isNavigationVisible",!0),this.focusTracker=new Ea,this.buttonPrevView=this._createButtonView(t("Previous"),' '),this.buttonNextView=this._createButtonView(t("Next"),' '),this.content=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-balloon-rotator"],"z-index":"-1"},children:[{tag:"div",attributes:{class:["ck-balloon-rotator__navigation",i.to("isNavigationVisible",(e=>e?"":"ck-hidden"))]},children:[this.buttonPrevView,{tag:"span",attributes:{class:["ck-balloon-rotator__counter"]},children:[{text:i.to("counter")}]},this.buttonNextView]},{tag:"div",attributes:{class:"ck-balloon-rotator__content"},children:this.content}]})}render(){super.render(),this.focusTracker.add(this.element)}destroy(){super.destroy(),this.focusTracker.destroy()}showView(e){this.hideView(),this.content.add(e)}hideView(){this.content.clear()}_createButtonView(e,t){const i=new iu(this.locale);return i.set({label:e,icon:t,tooltip:!0}),i}}class ih extends Vd{constructor(e,t){super(e);const i=this.bindTemplate;this.set("top",0),this.set("left",0),this.set("height",0),this.set("width",0),this.set("numberOfPanels",0),this.content=this.createCollection(),this._balloonPanelView=t,this.setTemplate({tag:"div",attributes:{class:["ck-fake-panel",i.to("numberOfPanels",(e=>e?"":"ck-hidden"))],style:{top:i.to("top",Xu),left:i.to("left",Xu),width:i.to("width",Xu),height:i.to("height",Xu)}},children:this.content}),this.on("change:numberOfPanels",((e,t,i,n)=>{i>n?this._addPanels(i-n):this._removePanels(n-i),this.updatePosition()}))}_addPanels(e){for(;e--;){const e=new Vd;e.setTemplate({tag:"div"}),this.content.add(e),this.registerChild(e)}}_removePanels(e){for(;e--;){const e=this.content.last;this.content.remove(e),this.deregisterChild(e),e.destroy()}}updatePosition(){if(this.numberOfPanels){const{top:e,left:t}=this._balloonPanelView,{width:i,height:n}=new ua(this._balloonPanelView.element);Object.assign(this,{top:e,left:t,width:i,height:n})}}}const nh=Gu("px");class sh extends Vd{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 Od({tag:"div",attributes:{class:["ck","ck-sticky-panel__placeholder"],style:{display:t.to("isSticky",(e=>e?"block":"none")),height:t.to("isSticky",(e=>e?nh(this._panelRect.height):null))}}}).render(),this._contentPanel=new Od({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?nh(this._contentPanelPlaceholder.getBoundingClientRect().width):null)),top:t.to("_hasViewportTopOffset",(e=>e?nh(this.viewportTopOffset):null)),bottom:t.to("_isStickyToTheLimiter",(e=>e?nh(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(Zo.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.toplh(r,e)))),oh.get(r).set(i,{text:n,isDirectHost:s,keepOnFocus:o,hostElement:s?i:null}),t.change((e=>lh(r,e)))}function ah(e,t){return!!t.hasClass("ck-placeholder")&&(e.removeClass("ck-placeholder",t),!0)}function lh(e,t){const i=oh.get(e),n=[];let s=!1;for(const[e,o]of i)o.isDirectHost&&(n.push(e),ch(t,e,o)&&(s=!0));for(const[e,o]of i){if(o.isDirectHost)continue;const i=dh(e);i&&(n.includes(i)||(o.hostElement=i,ch(t,e,o)&&(s=!0)))}return s}function ch(e,t,i){const{text:n,isDirectHost:s,hostElement:o}=i;let r=!1;o.getAttribute("data-placeholder")!==n&&(e.setAttribute("data-placeholder",n,o),r=!0);return(s||1==t.childCount)&&function(e,t){if(!e.isAttached())return!1;const i=Array.from(e.getChildren()).some((e=>!e.is("uiElement")));if(i)return!1;if(t)return!0;const n=e.document;if(!n.isFocused)return!0;const s=n.selection.anchor;return s&&s.parent!==e}(o,i.keepOnFocus)?function(e,t){return!t.hasClass("ck-placeholder")&&(e.addClass("ck-placeholder",t),!0)}(e,o)&&(r=!0):ah(e,o)&&(r=!0),r}function dh(e){if(e.childCount){const t=e.getChild(0);if(t.is("element")&&!t.is("uiElement")&&!t.is("attributeElement"))return t}return null}const uh=new Map;function hh(e,t,i){let n=uh.get(e);n||(n=new Map,uh.set(e,n)),n.set(t,i)}function mh(e){return[e]}function gh(e,t,i={}){const n=function(e,t){const i=uh.get(e);return i&&i.has(t)?i.get(t):mh}(e.constructor,t.constructor);try{return n(e=e.clone(),t,i)}catch(e){throw e}}function fh(e,t,i){e=e.slice(),t=t.slice();const n=new ph(i.document,i.useRelations,i.forceWeakRemove);n.setOriginalOperations(e),n.setOriginalOperations(t);const s=n.originalOperations;if(0==e.length||0==t.length)return{operationsA:e,operationsB:t,originalOperations:s};const o=new WeakMap;for(const t of e)o.set(t,0);const r={nextBaseVersionA:e[e.length-1].baseVersion+1,nextBaseVersionB:t[t.length-1].baseVersion+1,originalOperationsACount:e.length,originalOperationsBCount:t.length};let a=0;for(;a{if(e.key===t.key&&e.range.start.hasSameParentAs(t.range.start)){const n=e.range.getDifference(t.range).map((t=>new pc(t,e.key,e.oldValue,e.newValue,0))),s=e.range.getIntersection(t.range);return s&&i.aIsStrong&&n.push(new pc(s,t.key,t.newValue,e.newValue,0)),0==n.length?[new $c(0)]:n}return[e]})),hh(pc,vc,((e,t)=>{if(e.range.start.hasSameParentAs(t.position)&&e.range.containsPosition(t.position)){const i=e.range._getTransformedByInsertion(t.position,t.howMany,!t.shouldReceiveAttributes).map((t=>new pc(t,e.key,e.oldValue,e.newValue,e.baseVersion)));if(t.shouldReceiveAttributes){const n=vh(t,e.key,e.oldValue);n&&i.unshift(n)}return i}return e.range=e.range._getTransformedByInsertion(t.position,t.howMany,!1)[0],[e]})),hh(pc,Cc,((e,t)=>{const i=[];e.range.start.hasSameParentAs(t.deletionPosition)&&(e.range.containsPosition(t.deletionPosition)||e.range.start.isEqual(t.deletionPosition))&&i.push(Wa._createFromPositionAndShift(t.graveyardPosition,1));const n=e.range._getTransformedByMergeOperation(t);return n.isCollapsed||i.push(n),i.map((t=>new pc(t,e.key,e.oldValue,e.newValue,e.baseVersion)))})),hh(pc,bc,((e,t)=>{const i=function(e,t){const i=Wa._createFromPositionAndShift(t.sourcePosition,t.howMany);let n=null,s=[];i.containsRange(e,!0)?n=e:e.start.hasSameParentAs(i.start)?(s=e.getDifference(i),n=e.getIntersection(i)):s=[e];const o=[];for(let e of s){e=e._getTransformedByDeletion(t.sourcePosition,t.howMany);const i=t.getMovedRangeStart(),n=e.start.hasSameParentAs(i);e=e._getTransformedByInsertion(i,t.howMany,n),o.push(...e)}n&&o.push(n._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany,!1)[0]);return o}(e.range,t);return i.map((t=>new pc(t,e.key,e.oldValue,e.newValue,e.baseVersion)))})),hh(pc,Ac,((e,t)=>{if(e.range.end.isEqual(t.insertionPosition))return t.graveyardPosition||e.range.end.offset++,[e];if(e.range.start.hasSameParentAs(t.splitPosition)&&e.range.containsPosition(t.splitPosition)){const i=e.clone();return i.range=new Wa(t.moveTargetPosition.clone(),e.range.end._getCombined(t.splitPosition,t.moveTargetPosition)),e.range.end=t.splitPosition.clone(),e.range.end.stickiness="toPrevious",[e,i]}return e.range=e.range._getTransformedBySplitOperation(t),[e]})),hh(vc,pc,((e,t)=>{const i=[e];if(e.shouldReceiveAttributes&&e.position.hasSameParentAs(t.range.start)&&t.range.containsPosition(e.position)){const n=vh(e,t.key,t.newValue);n&&i.push(n)}return i})),hh(vc,vc,((e,t,i)=>(e.position.isEqual(t.position)&&i.aIsStrong||(e.position=e.position._getTransformedByInsertOperation(t)),[e]))),hh(vc,bc,((e,t)=>(e.position=e.position._getTransformedByMoveOperation(t),[e]))),hh(vc,Ac,((e,t)=>(e.position=e.position._getTransformedBySplitOperation(t),[e]))),hh(vc,Cc,((e,t)=>(e.position=e.position._getTransformedByMergeOperation(t),[e]))),hh(_c,vc,((e,t)=>(e.oldRange&&(e.oldRange=e.oldRange._getTransformedByInsertOperation(t)[0]),e.newRange&&(e.newRange=e.newRange._getTransformedByInsertOperation(t)[0]),[e]))),hh(_c,_c,((e,t,i)=>{if(e.name==t.name){if(!i.aIsStrong)return[new $c(0)];e.oldRange=t.newRange?t.newRange.clone():null}return[e]})),hh(_c,Cc,((e,t)=>(e.oldRange&&(e.oldRange=e.oldRange._getTransformedByMergeOperation(t)),e.newRange&&(e.newRange=e.newRange._getTransformedByMergeOperation(t)),[e]))),hh(_c,bc,((e,t,i)=>{if(e.oldRange&&(e.oldRange=Wa._createFromRanges(e.oldRange._getTransformedByMoveOperation(t))),e.newRange){if(i.abRelation){const n=Wa._createFromRanges(e.newRange._getTransformedByMoveOperation(t));if("left"==i.abRelation.side&&t.targetPosition.isEqual(e.newRange.start))return e.newRange.start.path=i.abRelation.path,e.newRange.end=n.end,[e];if("right"==i.abRelation.side&&t.targetPosition.isEqual(e.newRange.end))return e.newRange.start=n.start,e.newRange.end.path=i.abRelation.path,[e]}e.newRange=Wa._createFromRanges(e.newRange._getTransformedByMoveOperation(t))}return[e]})),hh(_c,Ac,((e,t,i)=>{if(e.oldRange&&(e.oldRange=e.oldRange._getTransformedBySplitOperation(t)),e.newRange){if(i.abRelation){const n=e.newRange._getTransformedBySplitOperation(t);return e.newRange.start.isEqual(t.splitPosition)&&i.abRelation.wasStartBeforeMergedElement?e.newRange.start=La._createAt(t.insertionPosition):e.newRange.start.isEqual(t.splitPosition)&&!i.abRelation.wasInLeftElement&&(e.newRange.start=La._createAt(t.moveTargetPosition)),e.newRange.end.isEqual(t.splitPosition)&&i.abRelation.wasInRightElement?e.newRange.end=La._createAt(t.moveTargetPosition):e.newRange.end.isEqual(t.splitPosition)&&i.abRelation.wasEndBeforeMergedElement?e.newRange.end=La._createAt(t.insertionPosition):e.newRange.end=n.end,[e]}e.newRange=e.newRange._getTransformedBySplitOperation(t)}return[e]})),hh(Cc,vc,((e,t)=>(e.sourcePosition.hasSameParentAs(t.position)&&(e.howMany+=t.howMany),e.sourcePosition=e.sourcePosition._getTransformedByInsertOperation(t),e.targetPosition=e.targetPosition._getTransformedByInsertOperation(t),[e]))),hh(Cc,Cc,((e,t,i)=>{if(e.sourcePosition.isEqual(t.sourcePosition)&&e.targetPosition.isEqual(t.targetPosition)){if(i.bWasUndone){const i=t.graveyardPosition.path.slice();return i.push(0),e.sourcePosition=new La(t.graveyardPosition.root,i),e.howMany=0,[e]}return[new $c(0)]}if(e.sourcePosition.isEqual(t.sourcePosition)&&!e.targetPosition.isEqual(t.targetPosition)&&!i.bWasUndone&&"splitAtSource"!=i.abRelation){const n="$graveyard"==e.targetPosition.root.rootName,s="$graveyard"==t.targetPosition.root.rootName,o=n&&!s;if(s&&!n||!o&&i.aIsStrong){const i=t.targetPosition._getTransformedByMergeOperation(t),n=e.targetPosition._getTransformedByMergeOperation(t);return[new bc(i,e.howMany,n,0)]}return[new $c(0)]}return e.sourcePosition.hasSameParentAs(t.targetPosition)&&(e.howMany+=t.howMany),e.sourcePosition=e.sourcePosition._getTransformedByMergeOperation(t),e.targetPosition=e.targetPosition._getTransformedByMergeOperation(t),e.graveyardPosition.isEqual(t.graveyardPosition)&&i.aIsStrong||(e.graveyardPosition=e.graveyardPosition._getTransformedByMergeOperation(t)),[e]})),hh(Cc,bc,((e,t,i)=>{const n=Wa._createFromPositionAndShift(t.sourcePosition,t.howMany);return"remove"==t.type&&!i.bWasUndone&&!i.forceWeakRemove&&e.deletionPosition.hasSameParentAs(t.sourcePosition)&&n.containsPosition(e.sourcePosition)?[new $c(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])})),hh(Cc,Ac,((e,t,i)=>{if(t.graveyardPosition&&(e.graveyardPosition=e.graveyardPosition._getTransformedByDeletion(t.graveyardPosition,1),e.deletionPosition.isEqual(t.graveyardPosition)&&(e.howMany=t.howMany)),e.targetPosition.isEqual(t.splitPosition)){const n=0!=t.howMany,s=t.graveyardPosition&&e.deletionPosition.isEqual(t.graveyardPosition);if(n||s||"mergeTargetNotMoved"==i.abRelation)return e.sourcePosition=e.sourcePosition._getTransformedBySplitOperation(t),[e]}if(e.sourcePosition.isEqual(t.splitPosition)){if("mergeSourceNotMoved"==i.abRelation)return e.howMany=0,e.targetPosition=e.targetPosition._getTransformedBySplitOperation(t),[e];if("mergeSameElement"==i.abRelation||e.sourcePosition.offset>0)return e.sourcePosition=t.moveTargetPosition.clone(),e.targetPosition=e.targetPosition._getTransformedBySplitOperation(t),[e]}return e.sourcePosition.hasSameParentAs(t.splitPosition)&&(e.howMany=t.splitPosition.offset),e.sourcePosition=e.sourcePosition._getTransformedBySplitOperation(t),e.targetPosition=e.targetPosition._getTransformedBySplitOperation(t),[e]})),hh(bc,vc,((e,t)=>{const i=Wa._createFromPositionAndShift(e.sourcePosition,e.howMany)._getTransformedByInsertOperation(t,!1)[0];return e.sourcePosition=i.start,e.howMany=i.end.offset-i.start.offset,e.targetPosition.isEqual(t.position)||(e.targetPosition=e.targetPosition._getTransformedByInsertOperation(t)),[e]})),hh(bc,bc,((e,t,i)=>{const n=Wa._createFromPositionAndShift(e.sourcePosition,e.howMany),s=Wa._createFromPositionAndShift(t.sourcePosition,t.howMany);let o,r=i.aIsStrong,a=!i.aIsStrong;if("insertBefore"==i.abRelation||"insertAfter"==i.baRelation?a=!0:"insertAfter"!=i.abRelation&&"insertBefore"!=i.baRelation||(a=!1),o=e.targetPosition.isEqual(t.targetPosition)&&a?e.targetPosition._getTransformedByDeletion(t.sourcePosition,t.howMany):e.targetPosition._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),_h(e,t)&&_h(t,e))return[t.getReversed()];if(n.containsPosition(t.targetPosition)&&n.containsRange(s,!0))return n.start=n.start._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),n.end=n.end._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),yh([n],o);if(s.containsPosition(e.targetPosition)&&s.containsRange(n,!0))return n.start=n.start._getCombined(t.sourcePosition,t.getMovedRangeStart()),n.end=n.end._getCombined(t.sourcePosition,t.getMovedRangeStart()),yh([n],o);const l=Mn(e.sourcePosition.getParentPath(),t.sourcePosition.getParentPath());if("prefix"==l||"extension"==l)return n.start=n.start._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),n.end=n.end._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),yh([n],o);"remove"!=e.type||"remove"==t.type||i.aWasUndone||i.forceWeakRemove?"remove"==e.type||"remove"!=t.type||i.bWasUndone||i.forceWeakRemove||(r=!1):r=!0;const c=[],d=n.getDifference(s);for(const e of d){e.start=e.start._getTransformedByDeletion(t.sourcePosition,t.howMany),e.end=e.end._getTransformedByDeletion(t.sourcePosition,t.howMany);const i="same"==Mn(e.start.getParentPath(),t.getMovedRangeStart().getParentPath()),n=e._getTransformedByInsertion(t.getMovedRangeStart(),t.howMany,i);c.push(...n)}const u=n.getIntersection(s);return null!==u&&r&&(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?s.start.isBefore(n.start)||s.start.isEqual(n.start)?c.unshift(u):c.push(u):c.splice(1,0,u)),0===c.length?[new $c(e.baseVersion)]:yh(c,o)})),hh(bc,Ac,((e,t,i)=>{let n=e.targetPosition.clone();e.targetPosition.isEqual(t.insertionPosition)&&t.graveyardPosition&&"moveTargetAfter"!=i.abRelation||(n=e.targetPosition._getTransformedBySplitOperation(t));const s=Wa._createFromPositionAndShift(e.sourcePosition,e.howMany);if(s.end.isEqual(t.insertionPosition))return t.graveyardPosition||e.howMany++,e.targetPosition=n,[e];if(s.start.hasSameParentAs(t.splitPosition)&&s.containsPosition(t.splitPosition)){let e=new Wa(t.splitPosition,s.end);e=e._getTransformedBySplitOperation(t);return yh([new Wa(s.start,t.splitPosition),e],n)}e.targetPosition.isEqual(t.splitPosition)&&"insertAtSource"==i.abRelation&&(n=t.moveTargetPosition),e.targetPosition.isEqual(t.insertionPosition)&&"insertBetween"==i.abRelation&&(n=e.targetPosition);const o=[s._getTransformedBySplitOperation(t)];if(t.graveyardPosition){const n=s.start.isEqual(t.graveyardPosition)||s.containsPosition(t.graveyardPosition);e.howMany>1&&n&&!i.aWasUndone&&o.push(Wa._createFromPositionAndShift(t.insertionPosition,1))}return yh(o,n)})),hh(bc,Cc,((e,t,i)=>{const n=Wa._createFromPositionAndShift(e.sourcePosition,e.howMany);if(t.deletionPosition.hasSameParentAs(e.sourcePosition)&&n.containsPosition(t.sourcePosition))if("remove"!=e.type||i.forceWeakRemove){if(1==e.howMany)return i.bWasUndone?(e.sourcePosition=t.graveyardPosition.clone(),e.targetPosition=e.targetPosition._getTransformedByMergeOperation(t),[e]):[new $c(0)]}else if(!i.aWasUndone){const i=[];let n=t.graveyardPosition.clone(),s=t.targetPosition._getTransformedByMergeOperation(t);e.howMany>1&&(i.push(new bc(e.sourcePosition,e.howMany-1,e.targetPosition,0)),n=n._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany-1),s=s._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany-1));const o=t.deletionPosition._getCombined(e.sourcePosition,e.targetPosition),r=new bc(n,1,o,0),a=r.getMovedRangeStart().path.slice();a.push(0);const l=new La(r.targetPosition.root,a);s=s._getTransformedByMove(n,o,1);const c=new bc(s,t.howMany,l,0);return i.push(r),i.push(c),i}const s=Wa._createFromPositionAndShift(e.sourcePosition,e.howMany)._getTransformedByMergeOperation(t);return e.sourcePosition=s.start,e.howMany=s.end.offset-s.start.offset,e.targetPosition=e.targetPosition._getTransformedByMergeOperation(t),[e]})),hh(yc,vc,((e,t)=>(e.position=e.position._getTransformedByInsertOperation(t),[e]))),hh(yc,Cc,((e,t)=>e.position.isEqual(t.deletionPosition)?(e.position=t.graveyardPosition.clone(),e.position.stickiness="toNext",[e]):(e.position=e.position._getTransformedByMergeOperation(t),[e]))),hh(yc,bc,((e,t)=>(e.position=e.position._getTransformedByMoveOperation(t),[e]))),hh(yc,yc,((e,t,i)=>{if(e.position.isEqual(t.position)){if(!i.aIsStrong)return[new $c(0)];e.oldName=t.newName}return[e]})),hh(yc,Ac,((e,t)=>{if("same"==Mn(e.position.path,t.splitPosition.getParentPath())&&!t.graveyardPosition){const t=new yc(e.position.getShiftedBy(1),e.oldName,e.newName,0);return[e,t]}return e.position=e.position._getTransformedBySplitOperation(t),[e]})),hh(kc,kc,((e,t,i)=>{if(e.root===t.root&&e.key===t.key){if(!i.aIsStrong||e.newValue===t.newValue)return[new $c(0)];e.oldValue=t.newValue}return[e]})),hh(Ac,vc,((e,t)=>(e.splitPosition.hasSameParentAs(t.position)&&e.splitPosition.offset{if(!e.graveyardPosition&&!i.bWasUndone&&e.splitPosition.hasSameParentAs(t.sourcePosition)){const i=t.graveyardPosition.path.slice();i.push(0);const n=new La(t.graveyardPosition.root,i),s=Ac.getInsertionPosition(new La(t.graveyardPosition.root,i)),o=new Ac(n,0,s,null,0);return e.splitPosition=e.splitPosition._getTransformedByMergeOperation(t),e.insertionPosition=Ac.getInsertionPosition(e.splitPosition),e.graveyardPosition=o.insertionPosition.clone(),e.graveyardPosition.stickiness="toNext",[o,e]}return e.splitPosition.hasSameParentAs(t.deletionPosition)&&!e.splitPosition.isAfter(t.deletionPosition)&&e.howMany--,e.splitPosition.hasSameParentAs(t.targetPosition)&&(e.howMany+=t.howMany),e.splitPosition=e.splitPosition._getTransformedByMergeOperation(t),e.insertionPosition=Ac.getInsertionPosition(e.splitPosition),e.graveyardPosition&&(e.graveyardPosition=e.graveyardPosition._getTransformedByMergeOperation(t)),[e]})),hh(Ac,bc,((e,t,i)=>{const n=Wa._createFromPositionAndShift(t.sourcePosition,t.howMany);if(e.graveyardPosition){const s=n.start.isEqual(e.graveyardPosition)||n.containsPosition(e.graveyardPosition);if(!i.bWasUndone&&s){const i=e.splitPosition._getTransformedByMoveOperation(t),n=e.graveyardPosition._getTransformedByMoveOperation(t),s=n.path.slice();s.push(0);const o=new La(n.root,s);return[new bc(i,e.howMany,o,0)]}e.graveyardPosition=e.graveyardPosition._getTransformedByMoveOperation(t)}const s=e.splitPosition.isEqual(t.targetPosition);if(s&&("insertAtSource"==i.baRelation||"splitBefore"==i.abRelation))return e.howMany+=t.howMany,e.splitPosition=e.splitPosition._getTransformedByDeletion(t.sourcePosition,t.howMany),e.insertionPosition=Ac.getInsertionPosition(e.splitPosition),[e];if(s&&i.abRelation&&i.abRelation.howMany){const{howMany:t,offset:n}=i.abRelation;return e.howMany+=t,e.splitPosition=e.splitPosition.getShiftedBy(n),[e]}if(e.splitPosition.hasSameParentAs(t.sourcePosition)&&n.containsPosition(e.splitPosition)){const i=t.howMany-(e.splitPosition.offset-t.sourcePosition.offset);return e.howMany-=i,e.splitPosition.hasSameParentAs(t.targetPosition)&&e.splitPosition.offset{if(e.splitPosition.isEqual(t.splitPosition)){if(!e.graveyardPosition&&!t.graveyardPosition)return[new $c(0)];if(e.graveyardPosition&&t.graveyardPosition&&e.graveyardPosition.isEqual(t.graveyardPosition))return[new $c(0)];if("splitBefore"==i.abRelation)return e.howMany=0,e.graveyardPosition=e.graveyardPosition._getTransformedBySplitOperation(t),[e]}if(e.graveyardPosition&&t.graveyardPosition&&e.graveyardPosition.isEqual(t.graveyardPosition)){const n="$graveyard"==e.splitPosition.root.rootName,s="$graveyard"==t.splitPosition.root.rootName,o=n&&!s;if(s&&!n||!o&&i.aIsStrong){const i=[];return t.howMany&&i.push(new bc(t.moveTargetPosition,t.howMany,t.splitPosition,0)),e.howMany&&i.push(new bc(e.splitPosition,e.howMany,e.moveTargetPosition,0)),i}return[new $c(0)]}if(e.graveyardPosition&&(e.graveyardPosition=e.graveyardPosition._getTransformedBySplitOperation(t)),e.splitPosition.isEqual(t.insertionPosition)&&"splitBefore"==i.abRelation)return e.howMany++,[e];if(t.splitPosition.isEqual(e.insertionPosition)&&"splitBefore"==i.baRelation){const i=t.insertionPosition.path.slice();i.push(0);const n=new La(t.insertionPosition.root,i);return[e,new bc(e.insertionPosition,1,n,0)]}return e.splitPosition.hasSameParentAs(t.splitPosition)&&e.splitPosition.offset{const{top:i,right:n,bottom:s,left:o}=t,r=[];return[i,n,o,s].every((e=>!!e))?r.push([e,Kh(t)]):(i&&r.push([e+"-top",i]),n&&r.push([e+"-right",n]),s&&r.push([e+"-bottom",s]),o&&r.push([e+"-left",o])),r}}function Kh({top:e,right:t,bottom:i,left:n}){const s=[];return n!==t?s.push(e,t,i,n):i!==e?s.push(e,t,i):t!==e?s.push(e,t):s.push(e),s.join(" ")}function Gh(e){return t=>({path:e,value:qh(t)})}function Jh(e){return e.replace(/, /g,",").split(" ").map((e=>e.replace(/,/g,", ")))}function Yh(e){e.setNormalizer("background",Qh),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 Qh(e){const t={},i=Jh(e);for(const e of i)n=e,zh.includes(n)?(t.repeat=t.repeat||[],t.repeat.push(e)):Fh(e)?(t.position=t.position||[],t.position.push(e)):jh(e)?t.attachment=e:Rh(e)?t.color=e:Uh(e)&&(t.image=e);var n;return{path:"background",value:t}}function Zh(e){e.setNormalizer("border",Xh),e.setNormalizer("border-top",em("top")),e.setNormalizer("border-right",em("right")),e.setNormalizer("border-bottom",em("bottom")),e.setNormalizer("border-left",em("left")),e.setNormalizer("border-color",tm("color")),e.setNormalizer("border-width",tm("width")),e.setNormalizer("border-style",tm("style")),e.setNormalizer("border-top-color",nm("color","top")),e.setNormalizer("border-top-style",nm("style","top")),e.setNormalizer("border-top-width",nm("width","top")),e.setNormalizer("border-right-color",nm("color","right")),e.setNormalizer("border-right-style",nm("style","right")),e.setNormalizer("border-right-width",nm("width","right")),e.setNormalizer("border-bottom-color",nm("color","bottom")),e.setNormalizer("border-bottom-style",nm("style","bottom")),e.setNormalizer("border-bottom-width",nm("width","bottom")),e.setNormalizer("border-left-color",nm("color","left")),e.setNormalizer("border-left-style",nm("style","left")),e.setNormalizer("border-left-width",nm("width","left")),e.setExtractor("border-top",sm("top")),e.setExtractor("border-right",sm("right")),e.setExtractor("border-bottom",sm("bottom")),e.setExtractor("border-left",sm("left")),e.setExtractor("border-top-color","border.color.top"),e.setExtractor("border-right-color","border.color.right"),e.setExtractor("border-bottom-color","border.color.bottom"),e.setExtractor("border-left-color","border.color.left"),e.setExtractor("border-top-width","border.width.top"),e.setExtractor("border-right-width","border.width.right"),e.setExtractor("border-bottom-width","border.width.bottom"),e.setExtractor("border-left-width","border.width.left"),e.setExtractor("border-top-style","border.style.top"),e.setExtractor("border-right-style","border.style.right"),e.setExtractor("border-bottom-style","border.style.bottom"),e.setExtractor("border-left-style","border.style.left"),e.setReducer("border-color",$h("border-color")),e.setReducer("border-style",$h("border-style")),e.setReducer("border-width",$h("border-width")),e.setReducer("border-top",am("top")),e.setReducer("border-right",am("right")),e.setReducer("border-bottom",am("bottom")),e.setReducer("border-left",am("left")),e.setReducer("border",function(){return t=>{const i=om(t,"top"),n=om(t,"right"),s=om(t,"bottom"),o=om(t,"left"),r=[i,n,s,o],a={width:e(r,"width"),style:e(r,"style"),color:e(r,"color")},l=lm(a,"all");if(l.length)return l;const c=Object.entries(a).reduce(((e,[t,i])=>(i&&(e.push([`border-${t}`,i]),r.forEach((e=>e[t]=null))),e)),[]);return[...c,...lm(i,"top"),...lm(n,"right"),...lm(s,"bottom"),...lm(o,"left")]};function e(e,t){return e.map((e=>e[t])).reduce(((e,t)=>e==t?e:null))}}()),e.setStyleRelation("border",["border-color","border-style","border-width","border-top","border-right","border-bottom","border-left","border-top-color","border-right-color","border-bottom-color","border-left-color","border-top-style","border-right-style","border-bottom-style","border-left-style","border-top-width","border-right-width","border-bottom-width","border-left-width"]),e.setStyleRelation("border-color",["border-top-color","border-right-color","border-bottom-color","border-left-color"]),e.setStyleRelation("border-style",["border-top-style","border-right-style","border-bottom-style","border-left-style"]),e.setStyleRelation("border-width",["border-top-width","border-right-width","border-bottom-width","border-left-width"]),e.setStyleRelation("border-top",["border-top-color","border-top-style","border-top-width"]),e.setStyleRelation("border-right",["border-right-color","border-right-style","border-right-width"]),e.setStyleRelation("border-bottom",["border-bottom-color","border-bottom-style","border-bottom-width"]),e.setStyleRelation("border-left",["border-left-color","border-left-style","border-left-width"])}function Xh(e){const{color:t,style:i,width:n}=rm(e);return{path:"border",value:{color:qh(t),style:qh(i),width:qh(n)}}}function em(e){return t=>{const{color:i,style:n,width:s}=rm(t),o={};return void 0!==i&&(o.color={[e]:i}),void 0!==n&&(o.style={[e]:n}),void 0!==s&&(o.width={[e]:s}),{path:"border",value:o}}}function tm(e){return t=>({path:"border",value:im(t,e)})}function im(e,t){return{[t]:qh(e)}}function nm(e,t){return i=>({path:"border",value:{[e]:{[t]:i}}})}function sm(e){return(t,i)=>{if(i.border)return om(i.border,e)}}function om(e,t){const i={};return e.width&&e.width[t]&&(i.width=e.width[t]),e.style&&e.style[t]&&(i.style=e.style[t]),e.color&&e.color[t]&&(i.color=e.color[t]),i}function rm(e){const t={},i=Jh(e);for(const e of i)Mh(e)||/thin|medium|thick/.test(e)?t.width=e:Oh(e)?t.style=e:t.color=e;return t}function am(e){return t=>lm(t,e)}function lm(e,t){const i=[];if(e&&e.width&&i.push("width"),e&&e.style&&i.push("style"),e&&e.color&&i.push("color"),3==i.length){const n=i.map((t=>e[t])).join(" ");return["all"==t?["border",n]:[`border-${t}`,n]]}return"all"==t?[]:i.map((i=>[`border-${t}-${i}`,e[i]]))}function cm(e){e.setNormalizer("margin",Gh("margin")),e.setNormalizer("margin-top",(e=>({path:"margin.top",value:e}))),e.setNormalizer("margin-right",(e=>({path:"margin.right",value:e}))),e.setNormalizer("margin-bottom",(e=>({path:"margin.bottom",value:e}))),e.setNormalizer("margin-left",(e=>({path:"margin.left",value:e}))),e.setReducer("margin",$h("margin")),e.setStyleRelation("margin",["margin-top","margin-right","margin-bottom","margin-left"])}function dm(e){e.setNormalizer("padding",Gh("padding")),e.setNormalizer("padding-top",(e=>({path:"padding.top",value:e}))),e.setNormalizer("padding-right",(e=>({path:"padding.right",value:e}))),e.setNormalizer("padding-bottom",(e=>({path:"padding.bottom",value:e}))),e.setNormalizer("padding-left",(e=>({path:"padding.left",value:e}))),e.setReducer("padding",$h("padding")),e.setStyleRelation("padding",["padding-top","padding-right","padding-bottom","padding-left"])}class um extends yd{constructor(e,t){super(e),this.view=t,this._toolbarConfig=ku(e.config.get("toolbar")),this._elementReplacer=new oa}get element(){return this.view.element}init(e){const t=this.editor,i=this.view,n=t.editing.view,s=i.editable,o=n.document.getRoot();s.name=o.rootName,i.render();const r=s.element;this.setEditableElement(s.name,r),this.focusTracker.add(r),i.editable.bind("isFocused").to(this.focusTracker),n.attachDomRoot(r),e&&this._elementReplacer.replace(e,this.element),this._initPlaceholder(),this._initToolbar(),this.fire("ready")}destroy(){const e=this.view,t=this.editor.editing.view;this._elementReplacer.restore(),t.detachDomRoot(e.editable.name),e.destroy(),super.destroy()}_initToolbar(){const e=this.editor,t=this.view,i=e.editing.view;t.stickyPanel.bind("isActive").to(this.focusTracker,"isFocused"),t.stickyPanel.limiterElement=t.element,t.stickyPanel.bind("viewportTopOffset").to(this,"viewportOffset",(({top:e})=>e)),t.toolbar.fillFromConfig(this._toolbarConfig,this.componentFactory),function({origin:e,originKeystrokeHandler:t,originFocusTracker:i,toolbar:n,beforeFocus:s,afterBlur:o}){i.add(n.element),t.set("Alt+F10",((e,t)=>{i.isFocused&&!n.focusTracker.isFocused&&(s&&s(),n.focus(),t())})),n.keystrokes.set("Esc",((t,i)=>{n.focusTracker.isFocused&&(e.focus(),o&&o(),i())}))}({origin:i,originFocusTracker:this.focusTracker,originKeystrokeHandler:e.keystrokes,toolbar:t.toolbar})}_initPlaceholder(){const e=this.editor,t=e.editing.view,i=t.document.getRoot(),n=e.sourceElement,s=e.config.get("placeholder")||n&&"textarea"===n.tagName.toLowerCase()&&n.getAttribute("placeholder");s&&rh({view:t,element:i,text:s,isDirectHost:!1,keepOnFocus:!0})}}class hm extends Mu{constructor(e,t,i={}){super(e),this.stickyPanel=new sh(e),this.toolbar=new Cu(e,{shouldGroupWhenFull:i.shouldToolbarGroupWhenFull}),this.editable=new Du(e,t)}render(){super.render(),this.stickyPanel.content.add(this.toolbar),this.top.add(this.stickyPanel),this.main.add(this.editable)}}class mm extends bd{constructor(e,t={}){if(!yn(e)&&void 0!==t.initialData)throw new l("editor-create-initial-data",null);super(t),void 0===this.config.get("initialData")&&this.config.set("initialData",function(e){return yn(e)?(t=e,t instanceof HTMLTextAreaElement?t.value:t.innerHTML):e;var t}(e)),yn(e)&&(this.sourceElement=e),this.model.document.createRoot();const i=!this.config.get("toolbar.shouldNotGroupWhenFull"),n=new hm(this.locale,this.editing.view,{shouldToolbarGroupWhenFull:i});this.ui=new um(this,n),function(e){if(!z(e.updateSourceElement))throw new l("attachtoform-missing-elementapi-interface",e);const t=e.sourceElement;if(t&&"textarea"===t.tagName.toLowerCase()&&t.form){let i;const n=t.form,s=()=>e.updateSourceElement();z(n.submit)&&(i=n.submit,n.submit=()=>{s(),i.apply(n)}),n.addEventListener("submit",s),e.on("destroy",(()=>{n.removeEventListener("submit",s),i&&(n.submit=i)}))}}(this)}destroy(){return this.sourceElement&&this.updateSourceElement(),this.ui.destroy(),super.destroy()}static create(e,t={}){return new Promise((i=>{const n=new this(e,t);i(n.initPlugins().then((()=>n.ui.init(yn(e)?e:null))).then((()=>n.data.init(n.config.get("initialData")))).then((()=>n.fire("ready"))).then((()=>n)))}))}}dt(mm,kd),dt(mm,Cd);const gm=["left","right","center","justify"];function fm(e){return gm.includes(e)}function pm(e,t){return"rtl"==t.contentLanguageDirection?"right"===e:"left"===e}function wm(e){const t=e.map((e=>{let t;return t="string"==typeof e?{name:e}:e,t})).filter((e=>{const t=!!gm.includes(e.name);return t||c("alignment-config-name-not-recognized",{option:e}),t})),i=t.filter((e=>!!e.className)).length;if(i&&i{const s=n.slice(i+1);if(s.some((e=>e.name==t.name)))throw new l("alignment-config-name-already-defined",{option:t,configuredOptions:e});if(t.className){if(s.some((e=>e.className==t.className)))throw new l("alignment-config-classname-already-defined",{option:t,configuredOptions:e})}})),t}const bm="alignment";class vm extends mt{refresh(){const e=this.editor.locale,t=Ta(this.editor.model.document.selection.getSelectedBlocks());this.isEnabled=!!t&&this._canBeAligned(t),this.isEnabled&&t.hasAttribute("alignment")?this.value=t.getAttribute("alignment"):this.value="rtl"===e.contentLanguageDirection?"right":"left"}execute(e={}){const t=this.editor,i=t.locale,n=t.model,s=n.document,o=e.value;n.change((e=>{const t=Array.from(s.selection.getSelectedBlocks()).filter((e=>this._canBeAligned(e))),n=t[0].getAttribute("alignment");pm(o,i)||n===o||!o?function(e,t){for(const i of e)t.removeAttribute(bm,i)}(t,e):function(e,t,i){for(const n of e)t.setAttribute(bm,i,n)}(t,e,o)}))}_canBeAligned(e){return this.editor.model.schema.checkAttribute(e,bm)}}class _m extends ut{static get pluginName(){return"AlignmentEditing"}constructor(e){super(e),e.config.define("alignment",{options:[...gm.map((e=>({name:e})))]})}init(){const e=this.editor,t=e.locale,i=e.model.schema,n=wm(e.config.get("alignment.options")).filter((e=>fm(e.name)&&!pm(e.name,t))),s=n.some((e=>!!e.className));i.extend("$block",{allowAttributes:"alignment"}),e.model.schema.setAttributeProperties("alignment",{isFormatting:!0}),s?e.conversion.attributeToAttribute(function(e){const t={model:{key:"alignment",values:e.map((e=>e.name))},view:{}};for(const i of e)t.view[i.name]={key:"class",value:i.className};return t}(n)):e.conversion.for("downcast").attributeToAttribute(function(e){const t={model:{key:"alignment",values:e.map((e=>e.name))},view:{}};for(const{name:i}of e)t.view[i]={key:"style",value:{"text-align":i}};return t}(n));const o=function(e){const t=[];for(const{name:i}of e)t.push({view:{key:"style",value:{"text-align":i}},model:{key:"alignment",value:i}});return t}(n);for(const t of o)e.conversion.for("upcast").attributeToAttribute(t);const r=function(e){const t=[];for(const{name:i}of e)t.push({view:{key:"align",value:i},model:{key:"alignment",value:i}});return t}(n);for(const t of r)e.conversion.for("upcast").attributeToAttribute(t);e.commands.add("alignment",new vm(e))}}const ym=new Map([["left",Ed.alignLeft],["right",Ed.alignRight],["center",Ed.alignCenter],["justify",Ed.alignJustify]]);class km extends ut{get localizedOptionTitles(){const e=this.editor.t;return{left:e("Align left"),right:e("Align right"),center:e("Align center"),justify:e("Justify")}}static get pluginName(){return"AlignmentUI"}init(){const e=this.editor,t=e.ui.componentFactory,i=e.t,n=wm(e.config.get("alignment.options"));n.map((e=>e.name)).filter(fm).forEach((e=>this._addButton(e))),t.add("alignment",(e=>{const s=Iu(e),o=n.map((e=>t.create(`alignment:${e.name}`)));Ru(s,o),s.buttonView.set({label:i("Text alignment"),tooltip:!0}),s.toolbarView.isVertical=!0,s.toolbarView.ariaLabel=i("Text alignment toolbar"),s.extendTemplate({attributes:{class:"ck-alignment-dropdown"}});const r="rtl"===e.contentLanguageDirection?ym.get("right"):ym.get("left");return s.buttonView.bind("icon").toMany(o,"isOn",((...e)=>{const t=e.findIndex((e=>e));return t<0?r:o[t].icon})),s.bind("isEnabled").toMany(o,"isEnabled",((...e)=>e.some((e=>e)))),s}))}_addButton(e){const t=this.editor;t.ui.componentFactory.add(`alignment:${e}`,(i=>{const n=t.commands.get("alignment"),s=new iu(i);return s.set({label:this.localizedOptionTitles[e],icon:ym.get(e),tooltip:!0,isToggleable:!0}),s.bind("isEnabled").to(n),s.bind("isOn").to(n,"value",(t=>t===e)),this.listenTo(s,"execute",(()=>{t.execute("alignment",{value:e}),t.editing.view.focus()})),s}))}}class Cm{constructor(e,t=20){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}input(e){this.size+=e,this.size>=this.limit&&this._reset(!0)}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){this.isLocked&&!e||(this._batch=null,this.size=0)}}class Am extends mt{constructor(e,t){super(e),this._buffer=new Cm(e.model,t)}get buffer(){return this._buffer}destroy(){super.destroy(),this._buffer.destroy()}execute(e={}){const t=this.editor.model,i=t.document,n=e.text||"",s=n.length,o=e.range?t.createSelection(e.range):i.selection,r=e.resultRange;t.enqueueChange(this._buffer.batch,(e=>{this._buffer.lock(),t.deleteContent(o),n&&t.insertContent(e.createText(n,i.selection.getAttributes()),o),r?e.setSelection(r):o.is("documentSelection")||e.setSelection(o),this._buffer.unlock(),this._buffer.input(s)}))}}function xm(e){if(e.newChildren.length-e.oldChildren.length!=1)return;const t=function(e,t){const i=[];let n,s=0;return e.forEach((e=>{"equal"==e?(o(),s++):"insert"==e?(r("insert")?n.values.push(t[s]):(o(),n={type:"insert",index:s,values:[t[s]]}),s++):r("delete")?n.howMany++:(o(),n={type:"delete",index:s,howMany:1})})),o(),i;function o(){n&&(i.push(n),n=null)}function r(e){return n&&n.type==e}}(Wo(e.oldChildren,e.newChildren,Tm),e.newChildren);if(t.length>1)return;const i=t[0];return i.values[0]&&i.values[0].is("$text")?i:void 0}function Tm(e,t){return e&&e.is("$text")&&t&&t.is("$text")?e.data===t.data:e===t}function Em(e,t){const i=t.selection,n=e.shiftKey&&e.keyCode===ao.delete,s=!i.isCollapsed;return n&&s}const Pm=[co("arrowUp"),co("arrowRight"),co("arrowDown"),co("arrowLeft"),9,16,17,18,19,20,27,33,34,35,36,45,91,93,144,145,173,174,175,176,177,178,179,255];for(let e=112;e<=135;e++)Pm.push(e);function Sm(e){return!(!e.ctrlKey&&!e.metaKey)||Pm.includes(e.keyCode)}class Im{constructor(e){this.editor=e,this.editing=this.editor.editing}handle(e,t){if(function(e){if(0==e.length)return!1;for(const t of e)if("children"===t.type&&!xm(t))return!0;return!1}(e))this._handleContainerChildrenMutations(e,t);else for(const i of e)this._handleTextMutation(i,t),this._handleTextNodeInsertion(i)}_handleContainerChildrenMutations(e,t){const i=function(e){const t=e.map((e=>e.node)).reduce(((e,t)=>e.getCommonAncestor(t,{includeSelf:!0})));if(!t)return;return t.getAncestors({includeSelf:!0,parentFirst:!0}).find((e=>e.is("containerElement")||e.is("rootElement")))}(e);if(!i)return;const n=this.editor.editing.view.domConverter.mapViewToDom(i),s=new ar(this.editor.editing.view.document),o=this.editor.data.toModel(s.domToView(n)).getChild(0),r=this.editor.editing.mapper.toModelElement(i);if(!r)return;const a=Array.from(o.getChildren()),l=Array.from(r.getChildren()),c=a[a.length-1],d=l[l.length-1],u=c&&c.is("element","softBreak"),h=d&&!d.is("element","softBreak");u&&h&&a.pop();const m=this.editor.model.schema;if(!Rm(a,m)||!Rm(l,m))return;const g=a.map((e=>e.is("$text")?e.data:"@")).join("").replace(/\u00A0/g," "),f=l.map((e=>e.is("$text")?e.data:"@")).join("").replace(/\u00A0/g," ");if(f===g)return;const p=Wo(f,g),{firstChangeAt:w,insertions:b,deletions:v}=Vm(p);let _=null;t&&(_=this.editing.mapper.toModelRange(t.getFirstRange()));const y=g.substr(w,b),k=this.editor.model.createRange(this.editor.model.createPositionAt(r,w),this.editor.model.createPositionAt(r,w+v));this.editor.execute("input",{text:y,range:k,resultRange:_})}_handleTextMutation(e,t){if("text"!=e.type)return;const i=e.newText.replace(/\u00A0/g," "),n=e.oldText.replace(/\u00A0/g," ");if(n===i)return;const s=Wo(n,i),{firstChangeAt:o,insertions:r,deletions:a}=Vm(s);let l=null;t&&(l=this.editing.mapper.toModelRange(t.getFirstRange()));const c=this.editing.view.createPositionAt(e.node,o),d=this.editing.mapper.toModelPosition(c),u=this.editor.model.createRange(d,d.getShiftedBy(a)),h=i.substr(o,r);this.editor.execute("input",{text:h,range:u,resultRange:l})}_handleTextNodeInsertion(e){if("children"!=e.type)return;const t=xm(e),i=this.editing.view.createPositionAt(e.node,t.index),n=this.editing.mapper.toModelPosition(i),s=t.values[0].data;this.editor.execute("input",{text:s.replace(/\u00A0/g," "),range:this.editor.model.createRange(n)})}}function Rm(e,t){return e.every((e=>t.isInline(e)))}function Vm(e){let t=null,i=null;for(let n=0;n{i.deleteContent(i.document.selection)})),e.unlock()}no.isAndroid?n.document.on("beforeinput",((e,t)=>o(t)),{priority:"lowest"}):n.document.on("keydown",((e,t)=>o(t)),{priority:"lowest"}),n.document.on("compositionstart",(function(){const e=i.document,t=1!==e.selection.rangeCount||e.selection.getFirstRange().isFlat;e.selection.isCollapsed||t||r()}),{priority:"lowest"}),n.document.on("compositionend",(()=>{t=i.createSelection(i.document.selection)}),{priority:"lowest"})}(e),function(e){e.editing.view.document.on("mutations",((t,i,n)=>{new Im(e).handle(i,n)}))}(e)}}class Bm extends mt{constructor(e,t){super(e),this.direction=t,this._buffer=new Cm(e.model,e.config.get("typing.undoStep"))}get buffer(){return this._buffer}execute(e={}){const t=this.editor.model,i=t.document;t.enqueueChange(this._buffer.batch,(n=>{this._buffer.lock();const s=n.createSelection(e.selection||i.selection),o=e.sequence||1,r=s.isCollapsed;if(s.isCollapsed&&t.modifySelection(s,{direction:this.direction,unit:e.unit,treatEmojiAsSingleUnit:!0}),this._shouldEntireContentBeReplacedWithParagraph(o))return void this._replaceEntireContentWithParagraph(n);if(this._shouldReplaceFirstBlockWithParagraph(s,o))return void this.editor.execute("paragraph",{selection:s});if(s.isCollapsed)return;let a=0;s.getFirstRange().getMinimalFlatRanges().forEach((e=>{a+=Ls(e.getWalker({singleCharacters:!0,ignoreElementEnd:!0,shallow:!0}))})),t.deleteContent(s,{doNotResetEntireContent:r,direction:this.direction}),this._buffer.input(a),n.setSelection(s),this._buffer.unlock()}))}_shouldEntireContentBeReplacedWithParagraph(e){if(e>1)return!1;const t=this.editor.model,i=t.document.selection,n=t.schema.getLimitElement(i);if(!(i.isCollapsed&&i.containsEntireContent(n)))return!1;if(!t.schema.checkChild(n,"paragraph"))return!1;const s=n.getChild(0);return!s||"paragraph"!==s.name}_replaceEntireContentWithParagraph(e){const t=this.editor.model,i=t.document.selection,n=t.schema.getLimitElement(i),s=e.createElement("paragraph");e.remove(e.createRangeIn(n)),e.insert(s,n),e.setSelection(s,0)}_shouldReplaceFirstBlockWithParagraph(e,t){const i=this.editor.model;if(t>1||"backward"!=this.direction)return!1;if(!e.isCollapsed)return!1;const n=e.getFirstPosition(),s=i.schema.getLimitElement(n),o=s.getChild(0);return n.parent==o&&(!!e.containsEntireContent(o)&&(!!i.schema.checkChild(s,"paragraph")&&"paragraph"!=o.name))}}class Mm extends fr{constructor(e){super(e);const t=e.document;let i=0;function n(e,i,n){const s=new js(t,"delete",t.selection.getFirstRange());t.fire(s,new zr(t,i,n)),s.stop.called&&e.stop()}t.on("keyup",((e,t)=>{t.keyCode!=ao.delete&&t.keyCode!=ao.backspace||(i=0)})),t.on("keydown",((e,s)=>{if(no.isWindows&&Em(s,t))return;const o={};if(s.keyCode==ao.delete)o.direction="forward",o.unit="character";else{if(s.keyCode!=ao.backspace)return;o.direction="backward",o.unit="codePoint"}const r=no.isMac?s.altKey:s.ctrlKey;o.unit=r?"word":o.unit,o.sequence=++i,n(e,s.domEvent,o)})),no.isAndroid&&t.on("beforeinput",((t,i)=>{if("deleteContentBackward"!=i.domEvent.inputType)return;const s={unit:"codepoint",direction:"backward",sequence:1},o=i.domTarget.ownerDocument.defaultView.getSelection();o.anchorNode==o.focusNode&&o.anchorOffset+1!=o.focusOffset&&(s.selectionToRemove=e.domConverter.domSelectionToView(o)),n(t,i.domEvent,s)}))}observe(){}}class Nm extends ut{static get pluginName(){return"Delete"}init(){const e=this.editor,t=e.editing.view,i=t.document,n=e.model.document;t.addObserver(Mm),this._undoOnBackspace=!1;const s=new Bm(e,"forward");if(e.commands.add("deleteForward",s),e.commands.add("forwardDelete",s),e.commands.add("delete",new Bm(e,"backward")),this.listenTo(i,"delete",((i,n)=>{const s={unit:n.unit,sequence:n.sequence};if(n.selectionToRemove){const t=e.model.createSelection(),i=[];for(const t of n.selectionToRemove.getRanges())i.push(e.editing.mapper.toModelRange(t));t.setTo(i),s.selection=t}e.execute("forward"==n.direction?"deleteForward":"delete",s),n.preventDefault(),t.scrollToTheSelection()}),{priority:"low"}),no.isAndroid){let e=null;this.listenTo(i,"delete",((t,i)=>{const n=i.domTarget.ownerDocument.defaultView.getSelection();e={anchorNode:n.anchorNode,anchorOffset:n.anchorOffset,focusNode:n.focusNode,focusOffset:n.focusOffset}}),{priority:"lowest"}),this.listenTo(i,"keyup",((t,i)=>{if(e){const t=i.domTarget.ownerDocument.defaultView.getSelection();t.collapse(e.anchorNode,e.anchorOffset),t.extend(e.focusNode,e.focusOffset),e=null}}))}this.editor.plugins.has("UndoEditing")&&(this.listenTo(i,"delete",((t,i)=>{this._undoOnBackspace&&"backward"==i.direction&&1==i.sequence&&"codePoint"==i.unit&&(this._undoOnBackspace=!1,e.execute("undo"),i.preventDefault(),t.stop())}),{context:"$capture"}),this.listenTo(n,"change",(()=>{this._undoOnBackspace=!1})))}requestUndoOnBackspace(){this.editor.plugins.has("UndoEditing")&&(this._undoOnBackspace=!0)}}class Dm extends ut{static get requires(){return[Om,Nm]}static get pluginName(){return"Typing"}}function zm(e,t){let i=e.start;return{text:Array.from(e.getItems()).reduce(((e,n)=>n.is("$text")||n.is("$textProxy")?e+n.data:(i=t.createPositionAfter(n),"")),""),range:t.createRange(i,e.end)}}class Lm{constructor(e,t){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()}_startListening(){const e=this.model.document;this.listenTo(e.selection,"change:range",((t,{directChange:i})=>{i&&(e.selection.isCollapsed?this._evaluateTextBeforeSelection("selection"):this.hasMatch&&(this.fire("unmatched"),this.hasMatch=!1))})),this.listenTo(e,"change:data",((e,t)=>{!t.isUndo&&t.isLocal&&this._evaluateTextBeforeSelection("data",{batch:t})}))}_evaluateTextBeforeSelection(e,t={}){const i=this.model,n=i.document.selection,s=i.createRange(i.createPositionAt(n.focus.parent,0),n.focus),{text:o,range:r}=zm(s,i),a=this.testCallback(o);if(!a&&this.hasMatch&&this.fire("unmatched"),this.hasMatch=!!a,a){const i=Object.assign(t,{text:o,range:r});"object"==typeof a&&Object.assign(i,a),this.fire(`matched:${e}`,i)}}}dt(Lm,st);class Fm extends ut{static get pluginName(){return"TwoStepCaretMovement"}constructor(e){super(e),this.attributes=new Set,this._overrideUid=null}init(){const e=this.editor,t=e.model,i=e.editing.view,n=e.locale,s=t.document.selection;this.listenTo(i.document,"arrowKey",((e,t)=>{if(!s.isCollapsed)return;if(t.shiftKey||t.altKey||t.ctrlKey)return;const i=t.keyCode==ao.arrowright,o=t.keyCode==ao.arrowleft;if(!i&&!o)return;const r=n.contentLanguageDirection;let a=!1;a="ltr"===r&&i||"rtl"===r&&o?this._handleForwardMovement(t):this._handleBackwardMovement(t),!0===a&&e.stop()}),{context:"$text",priority:"highest"}),this._isNextGravityRestorationSkipped=!1,this.listenTo(s,"change:range",((e,t)=>{this._isNextGravityRestorationSkipped?this._isNextGravityRestorationSkipped=!1:this._isGravityOverridden&&(!t.directChange&&Um(s.getFirstPosition(),this.attributes)||this._restoreGravity())}))}registerAttribute(e){this.attributes.add(e)}_handleForwardMovement(e){const t=this.attributes,i=this.editor.model.document.selection,n=i.getFirstPosition();return!this._isGravityOverridden&&((!n.isAtStart||!Hm(i,t))&&(Um(n,t)?(Wm(e),this._overrideGravity(),!0):void 0))}_handleBackwardMovement(e){const t=this.attributes,i=this.editor.model,n=i.document.selection,s=n.getFirstPosition();return this._isGravityOverridden?(Wm(e),this._restoreGravity(),jm(i,t,s),!0):s.isAtStart?!!Hm(n,t)&&(Wm(e),jm(i,t,s),!0):function(e,t){return Um(e.getShiftedBy(-1),t)}(s,t)?s.isAtEnd&&!Hm(n,t)&&Um(s,t)?(Wm(e),jm(i,t,s),!0):(this._isNextGravityRestorationSkipped=!0,this._overrideGravity(),!1):void 0}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 Hm(e,t){for(const i of t)if(e.hasAttribute(i))return!0;return!1}function jm(e,t,i){const n=i.nodeBefore;e.change((e=>{n?e.setSelectionAttribute(n.getAttributes()):e.removeSelectionAttribute(t)}))}function Wm(e){e.preventDefault()}function Um(e,t){const{nodeBefore:i,nodeAfter:n}=e;for(const e of t){const t=i?i.getAttribute(e):void 0;if((n?n.getAttribute(e):void 0)!==t)return!0}return!1}var qm=/[\\^$.*+?()[\]{}|]/g,$m=RegExp(qm.source);const Km=function(e){return(e=ss(e))&&$m.test(e)?e.replace(qm,"\\$&"):e},Gm={copyright:{from:"(c)",to:"©"},registeredTrademark:{from:"(r)",to:"®"},trademark:{from:"(tm)",to:"™"},oneHalf:{from:/(^|[^/a-z0-9])(1\/2)([^/a-z0-9])$/i,to:[null,"½",null]},oneThird:{from:/(^|[^/a-z0-9])(1\/3)([^/a-z0-9])$/i,to:[null,"⅓",null]},twoThirds:{from:/(^|[^/a-z0-9])(2\/3)([^/a-z0-9])$/i,to:[null,"⅔",null]},oneForth:{from:/(^|[^/a-z0-9])(1\/4)([^/a-z0-9])$/i,to:[null,"¼",null]},threeQuarters:{from:/(^|[^/a-z0-9])(3\/4)([^/a-z0-9])$/i,to:[null,"¾",null]},lessThanOrEqual:{from:"<=",to:"≤"},greaterThanOrEqual:{from:">=",to:"≥"},notEqual:{from:"!=",to:"≠"},arrowLeft:{from:"<-",to:"←"},arrowRight:{from:"->",to:"→"},horizontalEllipsis:{from:"...",to:"…"},enDash:{from:/(^| )(--)( )$/,to:[null,"–",null]},emDash:{from:/(^| )(---)( )$/,to:[null,"—",null]},quotesPrimary:{from:eg('"'),to:[null,"“",null,"”"]},quotesSecondary:{from:eg("'"),to:[null,"‘",null,"’"]},quotesPrimaryEnGb:{from:eg("'"),to:[null,"‘",null,"’"]},quotesSecondaryEnGb:{from:eg('"'),to:[null,"“",null,"”"]},quotesPrimaryPl:{from:eg('"'),to:[null,"„",null,"”"]},quotesSecondaryPl:{from:eg("'"),to:[null,"‚",null,"’"]}},Jm={symbols:["copyright","registeredTrademark","trademark"],mathematical:["oneHalf","oneThird","twoThirds","oneForth","threeQuarters","lessThanOrEqual","greaterThanOrEqual","notEqual","arrowLeft","arrowRight"],typography:["horizontalEllipsis","enDash","emDash"],quotes:["quotesPrimary","quotesSecondary"]},Ym=["symbols","mathematical","typography","quotes"];function Qm(e){return"string"==typeof e?new RegExp(`(${Km(e)})$`):e}function Zm(e){return"string"==typeof e?()=>[e]:e instanceof Array?()=>e:e}function Xm(e){return(e.textNode?e.textNode:e.nodeAfter).getAttributes()}function eg(e){return new RegExp(`(^|\\s)(${e})([^${e}]*)(${e})$`)}function tg(e,t,i,n){return n.createRange(ig(e,t,i,!0,n),ig(e,t,i,!1,n))}function ig(e,t,i,n,s){let o=e.textNode||(n?e.nodeBefore:e.nodeAfter),r=null;for(;o&&o.getAttribute(t)==i;)r=o,o=n?o.previousSibling:o.nextSibling;return r?s.createPositionAt(r,n?"before":"after"):e}function ng(e,t,i,n){let s,o=null;"function"==typeof n?s=n:(o=e.commands.get(n),s=()=>{e.execute(n)}),e.model.document.on("change:data",((r,a)=>{if(o&&!o.isEnabled||!t.isEnabled)return;const l=Ta(e.model.document.selection.getRanges());if(!l.isCollapsed)return;if(a.isUndo||!a.isLocal)return;const c=Array.from(e.model.document.differ.getChanges()),d=c[0];if(1!=c.length||"insert"!==d.type||"$text"!=d.name||1!=d.length)return;const u=d.position.parent;if(u.is("element","codeBlock"))return;if(u.is("element","listItem")&&"function"!=typeof n&&!["numberedList","bulletedList","todoList"].includes(n))return;if(o&&!0===o.value)return;const h=u.getChild(0),m=e.model.createRangeOn(h);if(!m.containsRange(l)&&!l.end.isEqual(m.end))return;const g=i.exec(h.data.substr(0,l.end.offset));g&&e.model.enqueueChange((t=>{const i=t.createPositionAt(u,0),n=t.createPositionAt(u,g[0].length),o=new tl(i,n);if(!1!==s({match:g})){t.remove(o);const i=e.model.document.selection.getFirstRange(),n=t.createRangeIn(u);!u.isEmpty||n.isEqual(i)||n.containsRange(i,!0)||t.remove(u)}o.detach(),e.model.enqueueChange((()=>{e.plugins.get("Delete").requestUndoOnBackspace()}))}))}))}function sg(e,t,i,n){let s,o;i instanceof RegExp?s=i:o=i,o=o||(e=>{let t;const i=[],n=[];for(;null!==(t=s.exec(e))&&!(t&&t.length<4);){let{index:e,1:s,2:o,3:r}=t;const a=s+o+r;e+=t[0].length-a.length;const l=[e,e+s.length],c=[e+s.length+o.length,e+s.length+o.length+r.length];i.push(l),i.push(c),n.push([e+s.length,e+s.length+o.length])}return{remove:i,format:n}}),e.model.document.on("change:data",((i,s)=>{if(s.isUndo||!s.isLocal||!t.isEnabled)return;const r=e.model,a=r.document.selection;if(!a.isCollapsed)return;const l=Array.from(r.document.differ.getChanges()),c=l[0];if(1!=l.length||"insert"!==c.type||"$text"!=c.name||1!=c.length)return;const d=a.focus,u=d.parent,{text:h,range:m}=function(e,t){let i=e.start;return{text:Array.from(e.getItems()).reduce(((e,n)=>!n.is("$text")&&!n.is("$textProxy")||n.getAttribute("code")?(i=t.createPositionAfter(n),""):e+n.data),""),range:t.createRange(i,e.end)}}(r.createRange(r.createPositionAt(u,0),d),r),g=o(h),f=og(m.start,g.format,r),p=og(m.start,g.remove,r);f.length&&p.length&&r.enqueueChange((t=>{if(!1!==n(t,f)){for(const e of p.reverse())t.remove(e);r.enqueueChange((()=>{e.plugins.get("Delete").requestUndoOnBackspace()}))}}))}))}function og(e,t,i){return t.filter((e=>void 0!==e[0]&&void 0!==e[1])).map((t=>i.createRange(e.getShiftedBy(t[0]),e.getShiftedBy(t[1]))))}function rg(e,t){return(i,n)=>{if(!e.commands.get(t).isEnabled)return!1;const s=e.model.schema.getValidRanges(n,t);for(const e of s)i.setAttribute(t,!0,e);i.removeSelectionAttribute(t)}}function*ag(e,t){for(const i of t)i&&e.getAttributeProperties(i[0]).copyOnEnter&&(yield i)}class lg extends mt{execute(){const e=this.editor.model,t=e.document;e.change((i=>{!function(e,t,i,n){const s=i.isCollapsed,o=i.getFirstRange(),r=o.start.parent,a=o.end.parent;if(n.isLimit(r)||n.isLimit(a))return void(s||r!=a||e.deleteContent(i));if(s){const e=ag(t.model.schema,i.getAttributes());cg(t,o.start),t.setSelectionAttribute(e)}else{const n=!(o.start.isAtStart&&o.end.isAtEnd),s=r==a;e.deleteContent(i,{leaveUnmerged:n}),n&&(s?cg(t,i.focus):t.setSelection(a,0))}}(this.editor.model,i,t.selection,e.schema),this.fire("afterExecute",{writer:i})}))}}function cg(e,t){e.split(t),e.setSelection(t.parent.nextSibling,0)}class dg extends fr{constructor(e){super(e);const t=this.document;t.on("keydown",((e,i)=>{if(this.isEnabled&&i.keyCode==ao.enter){const n=new js(t,"enter",t.selection.getFirstRange());t.fire(n,new zr(t,i.domEvent,{isSoft:i.shiftKey})),n.stop.called&&e.stop()}}))}observe(){}}class ug extends ut{static get pluginName(){return"Enter"}init(){const e=this.editor,t=e.editing.view,i=t.document;t.addObserver(dg),e.commands.add("enter",new lg(e)),this.listenTo(i,"enter",((i,n)=>{n.preventDefault(),n.isSoft||(e.execute("enter"),t.scrollToTheSelection())}),{priority:"low"})}}class hg extends mt{execute(){const e=this.editor.model,t=e.document;e.change((i=>{!function(e,t,i){const n=i.isCollapsed,s=i.getFirstRange(),o=s.start.parent,r=s.end.parent,a=o==r;if(n){const n=ag(e.schema,i.getAttributes());mg(e,t,s.end),t.removeSelectionAttribute(i.getAttributeKeys()),t.setSelectionAttribute(n)}else{const n=!(s.start.isAtStart&&s.end.isAtEnd);e.deleteContent(i,{leaveUnmerged:n}),a?mg(e,t,i.focus):n&&t.setSelection(r,0)}}(e,i,t.selection),this.fire("afterExecute",{writer:i})}))}refresh(){const e=this.editor.model,t=e.document;this.isEnabled=function(e,t){if(t.rangeCount>1)return!1;const i=t.anchor;if(!i||!e.checkChild(i,"softBreak"))return!1;const n=t.getFirstRange(),s=n.start.parent,o=n.end.parent;if((gg(s,e)||gg(o,e))&&s!==o)return!1;return!0}(e.schema,t.selection)}}function mg(e,t,i){const n=t.createElement("softBreak");e.insertContent(n,i),t.setSelection(n,"after")}function gg(e,t){return!e.is("rootElement")&&(t.isLimit(e)||gg(e.parent,t))}class fg extends ut{static get pluginName(){return"ShiftEnter"}init(){const e=this.editor,t=e.model.schema,i=e.conversion,n=e.editing.view,s=n.document;t.register("softBreak",{allowWhere:"$text",isInline:!0}),i.for("upcast").elementToElement({model:"softBreak",view:"br"}),i.for("downcast").elementToElement({model:"softBreak",view:(e,{writer:t})=>t.createEmptyElement("br")}),n.addObserver(dg),e.commands.add("shiftEnter",new hg(e)),this.listenTo(s,"enter",((t,i)=>{i.preventDefault(),i.isSoft&&(e.execute("shiftEnter"),n.scrollToTheSelection())}),{priority:"low"})}}class pg extends mt{refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,i=t.schema,n=t.document.selection,s=Array.from(n.getSelectedBlocks()),o=void 0===e.forceValue?!this.value:e.forceValue;t.change((e=>{if(o){const t=s.filter((e=>wg(e)||vg(i,e)));this._applyQuote(e,t)}else this._removeQuote(e,s.filter(wg))}))}_getValue(){const e=Ta(this.editor.model.document.selection.getSelectedBlocks());return!(!e||!wg(e))}_checkEnabled(){if(this.value)return!0;const e=this.editor.model.document.selection,t=this.editor.model.schema,i=Ta(e.getSelectedBlocks());return!!i&&vg(t,i)}_removeQuote(e,t){bg(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=[];bg(e,t).reverse().forEach((t=>{let n=wg(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 wg(e){return"blockQuote"==e.parent.name?e.parent:null}function bg(e,t){let i,n=0;const s=[];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,s=e.commands.get("blockQuote");this.listenTo(i,"enter",((t,i)=>{if(!n.isCollapsed||!s.value)return;n.getLastPosition().parent.isEmpty&&(e.execute("blockQuote"),e.editing.view.scrollToTheSelection(),i.preventDefault(),t.stop())}),{context:"blockquote"}),this.listenTo(i,"delete",((t,i)=>{if("backward"!=i.direction||!n.isCollapsed||!s.value)return;const o=n.getLastPosition().parent;o.isEmpty&&!o.previousSibling&&(e.execute("blockQuote"),e.editing.view.scrollToTheSelection(),i.preventDefault(),t.stop())}),{context:"blockquote"})}}class yg extends ut{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"),s=new iu(i);return s.set({label:t("Block quote"),icon:Ed.quote,tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(n,"value","isEnabled"),this.listenTo(s,"execute",(()=>{e.execute("blockQuote"),e.editing.view.focus()})),s}))}}class kg extends mt{constructor(e,t){super(e),this.attributeKey=t}refresh(){const e=this.editor.model,t=e.document;this.value=this._getValueFromFirstAllowedNode(),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,this.attributeKey)}execute(e={}){const t=this.editor.model,i=t.document.selection,n=void 0===e.forceValue?!this.value:e.forceValue;t.change((e=>{if(i.isCollapsed)n?e.setSelectionAttribute(this.attributeKey,!0):e.removeSelectionAttribute(this.attributeKey);else{const s=t.schema.getValidRanges(i.getRanges(),this.attributeKey);for(const t of s)n?e.setAttribute(this.attributeKey,n,t):e.removeAttribute(this.attributeKey,t)}}))}_getValueFromFirstAllowedNode(){const e=this.editor.model,t=e.schema,i=e.document.selection;if(i.isCollapsed)return i.hasAttribute(this.attributeKey);for(const e of i.getRanges())for(const i of e.getItems())if(t.checkAttribute(i,this.attributeKey))return i.hasAttribute(this.attributeKey);return!1}}const Cg="bold";class Ag extends ut{static get pluginName(){return"BoldEditing"}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:Cg}),e.model.schema.setAttributeProperties(Cg,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:Cg,view:"strong",upcastAlso:["b",e=>{const t=e.getStyle("font-weight");return t?"bold"==t||Number(t)>=600?{name:!0,styles:["font-weight"]}:void 0:null}]}),e.commands.add(Cg,new kg(e,Cg)),e.keystrokes.set("CTRL+B",Cg)}}const xg="bold";class Tg extends ut{static get pluginName(){return"BoldUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add(xg,(i=>{const n=e.commands.get(xg),s=new iu(i);return s.set({label:t("Bold"),icon:' ',keystroke:"CTRL+B",tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(n,"value","isEnabled"),this.listenTo(s,"execute",(()=>{e.execute(xg),e.editing.view.focus()})),s}))}}class Eg{constructor(e){this.files=function(e){const t=Array.from(e.files||[]),i=Array.from(e.items||[]);if(t.length)return t;return i.filter((e=>"file"===e.kind)).map((e=>e.getAsFile()))}(e),this._native=e}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}get isCanceled(){return"none"==this._native.dropEffect||!!this._native.mozUserCancelled}}class Pg extends Lr{constructor(e){super(e);const i=this.document;function n(e){return(n,s)=>{s.preventDefault();const o=s.dropRange?[s.dropRange]:null,r=new t(i,e);i.fire(r,{dataTransfer:s.dataTransfer,method:n.name,targetRanges:o,target:s.target}),r.stop.called&&s.stopPropagation()}}this.domEventType=["paste","copy","cut","drop","dragover","dragstart","dragend","dragenter","dragleave"],this.listenTo(i,"paste",n("clipboardInput"),{priority:"low"}),this.listenTo(i,"drop",n("clipboardInput"),{priority:"low"}),this.listenTo(i,"dragover",n("dragging"),{priority:"low"})}onDomEvent(e){const t={dataTransfer:new Eg(e.clipboardData?e.clipboardData:e.dataTransfer)};"drop"!=e.type&&"dragover"!=e.type||(t.dropRange=function(e,t){const i=t.target.ownerDocument,n=t.clientX,s=t.clientY;let o;i.caretRangeFromPoint&&i.caretRangeFromPoint(n,s)?o=i.caretRangeFromPoint(n,s):t.rangeParent&&(o=i.createRange(),o.setStart(t.rangeParent,t.rangeOffset),o.collapse(!0));if(o)return e.domConverter.domRangeToView(o);return null}(this.view,e)),this.fire(e.type,e,t)}}const Sg=["figcaption","li"];function Ig(e){let t="";if(e.is("$text")||e.is("$textProxy"))t=e.data;else if(e.is("element","img")&&e.hasAttribute("alt"))t=e.getAttribute("alt");else if(e.is("element","br"))t="\n";else{let i=null;for(const n of e.getChildren()){const e=Ig(n);i&&(i.is("containerElement")||n.is("containerElement"))&&(Sg.includes(i.name)||Sg.includes(n.name)?t+="\n":t+="\n\n"),t+=e,i=n}}return t}class Rg extends ut{static get pluginName(){return"ClipboardPipeline"}init(){this.editor.editing.view.addObserver(Pg),this._setupPasteDrop(),this._setupCopyCut()}_setupPasteDrop(){const e=this.editor,i=e.model,n=e.editing.view,s=n.document;this.listenTo(s,"clipboardInput",(t=>{e.isReadOnly&&t.stop()}),{priority:"highest"}),this.listenTo(s,"clipboardInput",((e,i)=>{const s=i.dataTransfer;let o=i.content||"";var r;o||(s.getData("text/html")?o=function(e){return e.replace(/(\s+)<\/span>/g,((e,t)=>1==t.length?" ":t)).replace(//g,"")}(s.getData("text/html")):s.getData("text/plain")&&(((r=(r=s.getData("text/plain")).replace(//g,">").replace(/\r?\n\r?\n/g,"
").replace(/\r?\n/g," ").replace(/^\s/," ").replace(/\s$/," ").replace(/\s\s/g," ")).includes("
")||r.includes(" "))&&(r=`
${r}
`),o=r),o=this.editor.data.htmlProcessor.toView(o));const a=new t(this,"inputTransformation");this.fire(a,{content:o,dataTransfer:s,targetRanges:i.targetRanges,method:i.method}),a.stop.called&&e.stop(),n.scrollToTheSelection()}),{priority:"low"}),this.listenTo(this,"inputTransformation",((e,t)=>{if(t.content.isEmpty)return;const n=this.editor.data.toModel(t.content,"$clipboardHolder");0!=n.childCount&&(e.stop(),i.change((()=>{this.fire("contentInsertion",{content:n,method:t.method,dataTransfer:t.dataTransfer,targetRanges:t.targetRanges})})))}),{priority:"low"}),this.listenTo(this,"contentInsertion",((e,t)=>{t.resultRange=i.insertContent(t.content)}),{priority:"low"})}_setupCopyCut(){const e=this.editor,t=e.model.document,i=e.editing.view.document;function n(n,s){const o=s.dataTransfer;s.preventDefault();const r=e.data.toView(e.model.getSelectedContent(t.selection));i.fire("clipboardOutput",{dataTransfer:o,content:r,method:n.name})}this.listenTo(i,"copy",n,{priority:"low"}),this.listenTo(i,"cut",((t,i)=>{e.isReadOnly?i.preventDefault():n(t,i)}),{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",Ig(n.content))),"cut"==n.method&&e.model.deleteContent(t.selection)}),{priority:"low"})}}class Vg{constructor(){this._stack=[]}add(e,t){const i=this._stack,n=i[0];this._insertDescriptor(e);const s=i[0];n===s||Og(n,s)||this.fire("change:top",{oldDescriptor:n,newDescriptor:s,writer:t})}remove(e,t){const i=this._stack,n=i[0];this._removeDescriptor(e);const s=i[0];n===s||Og(n,s)||this.fire("change:top",{oldDescriptor:n,newDescriptor:s,writer:t})}_insertDescriptor(e){const t=this._stack,i=t.findIndex((t=>t.id===e.id));if(Og(e,t[i]))return;i>-1&&t.splice(i,1);let n=0;for(;t[n]&&Bg(t[n],e);)n++;t.splice(n,0,e)}_removeDescriptor(e){const t=this._stack,i=t.findIndex((t=>t.id===e));i>-1&&t.splice(i,1)}}function Og(e,t){return e&&t&&e.priority==t.priority&&Mg(e.classes)==Mg(t.classes)}function Bg(e,t){return e.priority>t.priority||!(e.priorityMg(t.classes)}function Mg(e){return Array.isArray(e)?e.sort().join(","):e}dt(Vg,p);const Ng=' ',Dg="ck-widget_selected";function zg(e){return!!e.is("element")&&!!e.getCustomProperty("widget")}function Lg(e,t,i={}){if(!e.is("containerElement"))throw new l("widget-to-widget-wrong-element-type",null,{element:e});return t.setAttribute("contenteditable","false",e),t.addClass("ck-widget",e),t.setCustomProperty("widget",!0,e),e.getFillerOffset=$g,i.label&&function(e,t,i){i.setCustomProperty("widgetLabel",t,e)}(e,i.label,t),i.hasSelectionHandle&&function(e,t){const i=t.createUIElement("div",{class:"ck ck-widget__selection-handle"},(function(e){const t=this.toDomElement(e),i=new eu;return i.set("content",Ng),i.render(),t.appendChild(i.element),t}));t.insert(t.createPositionAt(e,0),i),t.addClass(["ck-widget_with-selection-handle"],e)}(e,t),jg(e,t),e}function Fg(e,t,i){if(t.classes&&i.addClass(Pn(t.classes),e),t.attributes)for(const n in t.attributes)i.setAttribute(n,t.attributes[n],e)}function Hg(e,t,i){if(t.classes&&i.removeClass(Pn(t.classes),e),t.attributes)for(const n in t.attributes)i.removeAttribute(n,e)}function jg(e,t,i=Fg,n=Hg){const s=new Vg;s.on("change:top",((t,s)=>{s.oldDescriptor&&n(e,s.oldDescriptor,s.writer),s.newDescriptor&&i(e,s.newDescriptor,s.writer)})),t.setCustomProperty("addHighlight",((e,t,i)=>s.add(t,i)),e),t.setCustomProperty("removeHighlight",((e,t,i)=>s.remove(t,i)),e)}function Wg(e){const t=e.getCustomProperty("widgetLabel");return t?"function"==typeof t?t():t:""}function Ug(e,t){return t.addClass(["ck-editor__editable","ck-editor__nested-editable"],e),t.setAttribute("contenteditable",e.isReadOnly?"false":"true",e),e.on("change:isReadOnly",((i,n,s)=>{t.setAttribute("contenteditable",s?"false":"true",e)})),e.on("change:isFocused",((i,n,s)=>{s?t.addClass("ck-editor__nested-editable_focused",e):t.removeClass("ck-editor__nested-editable_focused",e)})),jg(e,t),e}function qg(e,t){const i=e.getSelectedElement();if(i){const n=Jg(e);if(n)return t.createRange(t.createPositionAt(i,n))}return Zc(e,t)}function $g(){return null}const Kg="widget-type-around";function Gg(e,t,i){return e&&zg(e)&&!i.isInline(t)}function Jg(e){return e.getAttribute(Kg)}const Yg=["before","after"],Qg=(new DOMParser).parseFromString(' ',"image/svg+xml").firstChild,Zg="ck-widget__type-around_disabled";class Xg extends ut{static get pluginName(){return"WidgetTypeAround"}static get requires(){return[ug,Nm]}constructor(e){super(e),this._currentFakeCaretModelElement=null}init(){const e=this.editor,t=e.editing.view;this.on("change:isEnabled",((i,n,s)=>{t.change((e=>{for(const i of t.document.roots)s?e.removeClass(Zg,i):e.addClass(Zg,i)})),s||e.model.change((e=>{e.removeSelectionAttribute(Kg)}))})),this._enableTypeAroundUIInjection(),this._enableInsertingParagraphsOnButtonClick(),this._enableInsertingParagraphsOnEnterKeypress(),this._enableInsertingParagraphsOnTypingKeystroke(),this._enableTypeAroundFakeCaretActivationUsingKeyboardArrows(),this._enableDeleteIntegration(),this._enableInsertContentIntegration(),this._enableInsertObjectIntegration(),this._enableDeleteContentIntegration()}destroy(){this._currentFakeCaretModelElement=null}_insertParagraph(e,t){const i=this.editor,n=i.editing.view,s=i.model.schema.getAttributesWithProperty(e,"copyOnReplace",!0);i.execute("insertParagraph",{position:i.model.createPositionAt(e,t),attributes:s}),n.focus(),n.scrollToTheSelection()}_listenToIfEnabled(e,t,i,n){this.listenTo(e,t,((...e)=>{this.isEnabled&&i(...e)}),n)}_insertParagraphAccordingToFakeCaretPosition(){const e=this.editor.model.document.selection,t=Jg(e);if(!t)return!1;const i=e.getSelectedElement();return this._insertParagraph(i,t),!0}_enableTypeAroundUIInjection(){const e=this.editor,t=e.model.schema,i=e.locale.t,n={before:i("Insert paragraph before block"),after:i("Insert paragraph after block")};e.editing.downcastDispatcher.on("insert",((e,i,s)=>{const o=s.mapper.toViewElement(i.item);Gg(o,i.item,t)&&function(e,t,i){const n=e.createUIElement("div",{class:"ck ck-reset_all ck-widget__type-around"},(function(e){const i=this.toDomElement(e);return function(e,t){for(const i of Yg){const n=new Od({tag:"div",attributes:{class:["ck","ck-widget__type-around__button",`ck-widget__type-around__button_${i}`],title:t[i]},children:[e.ownerDocument.importNode(Qg,!0)]});e.appendChild(n.render())}}(i,t),function(e){const t=new Od({tag:"div",attributes:{class:["ck","ck-widget__type-around__fake-caret"]}});e.appendChild(t.render())}(i),i}));e.insert(e.createPositionAt(i,"end"),n)}(s.writer,n,o)}),{priority:"low"})}_enableTypeAroundFakeCaretActivationUsingKeyboardArrows(){const e=this.editor,t=e.model,i=t.document.selection,n=t.schema,s=e.editing.view;function o(e){return`ck-widget_type-around_show-fake-caret_${e}`}this._listenToIfEnabled(s.document,"arrowKey",((e,t)=>{this._handleArrowKeyPress(e,t)}),{context:[zg,"$text"],priority:"high"}),this._listenToIfEnabled(i,"change:range",((t,i)=>{i.directChange&&e.model.change((e=>{e.removeSelectionAttribute(Kg)}))})),this._listenToIfEnabled(t.document,"change:data",(()=>{const t=i.getSelectedElement();if(t){if(Gg(e.editing.mapper.toViewElement(t),t,n))return}e.model.change((e=>{e.removeSelectionAttribute(Kg)}))})),this._listenToIfEnabled(e.editing.downcastDispatcher,"selection",((e,t,i)=>{const s=i.writer;if(this._currentFakeCaretModelElement){const e=i.mapper.toViewElement(this._currentFakeCaretModelElement);e&&(s.removeClass(Yg.map(o),e),this._currentFakeCaretModelElement=null)}const r=t.selection.getSelectedElement();if(!r)return;const a=i.mapper.toViewElement(r);if(!Gg(a,r,n))return;const l=Jg(t.selection);l&&(s.addClass(o(l),a),this._currentFakeCaretModelElement=r)})),this._listenToIfEnabled(e.ui.focusTracker,"change:isFocused",((t,i,n)=>{n||e.model.change((e=>{e.removeSelectionAttribute(Kg)}))}))}_handleArrowKeyPress(e,t){const i=this.editor,n=i.model,s=n.document.selection,o=n.schema,r=i.editing.view,a=function(e,t){const i=mo(e,t);return"down"===i||"right"===i}(t.keyCode,i.locale.contentLanguageDirection),l=r.document.selection.getSelectedElement();let c;Gg(l,i.editing.mapper.toModelElement(l),o)?c=this._handleArrowKeyPressOnSelectedWidget(a):s.isCollapsed?c=this._handleArrowKeyPressWhenSelectionNextToAWidget(a):t.shiftKey||(c=this._handleArrowKeyPressWhenNonCollapsedSelection(a)),c&&(t.preventDefault(),e.stop())}_handleArrowKeyPressOnSelectedWidget(e){const t=this.editor.model,i=Jg(t.document.selection);return t.change((t=>{if(!i)return t.setSelectionAttribute(Kg,e?"after":"before"),!0;if(!(i===(e?"after":"before")))return t.removeSelectionAttribute(Kg),!0;return!1}))}_handleArrowKeyPressWhenSelectionNextToAWidget(e){const t=this.editor,i=t.model,n=i.schema,s=t.plugins.get("Widget"),o=s._getObjectElementNextToSelection(e);return!!Gg(t.editing.mapper.toViewElement(o),o,n)&&(i.change((t=>{s._setSelectionOverElement(o),t.setSelectionAttribute(Kg,e?"before":"after")})),!0)}_handleArrowKeyPressWhenNonCollapsedSelection(e){const t=this.editor,i=t.model,n=i.schema,s=t.editing.mapper,o=i.document.selection,r=e?o.getLastPosition().nodeBefore:o.getFirstPosition().nodeAfter;return!!Gg(s.toViewElement(r),r,n)&&(i.change((t=>{t.setSelection(r,"on"),t.setSelectionAttribute(Kg,e?"after":"before")})),!0)}_enableInsertingParagraphsOnButtonClick(){const e=this.editor,t=e.editing.view;this._listenToIfEnabled(t.document,"mousedown",((i,n)=>{const s=n.domTarget.closest(".ck-widget__type-around__button");if(!s)return;const o=function(e){return e.classList.contains("ck-widget__type-around__button_before")?"before":"after"}(s),r=function(e,t){const i=e.closest(".ck-widget");return t.mapDomToView(i)}(s,t.domConverter),a=e.editing.mapper.toModelElement(r);this._insertParagraph(a,o),n.preventDefault(),i.stop()}))}_enableInsertingParagraphsOnEnterKeypress(){const e=this.editor,t=e.model.document.selection,i=e.editing.view;this._listenToIfEnabled(i.document,"enter",((i,n)=>{if("atTarget"!=i.eventPhase)return;const s=t.getSelectedElement(),o=e.editing.mapper.toViewElement(s),r=e.model.schema;let a;this._insertParagraphAccordingToFakeCaretPosition()?a=!0:Gg(o,s,r)&&(this._insertParagraph(s,n.isSoft?"before":"after"),a=!0),a&&(n.preventDefault(),i.stop())}),{context:zg})}_enableInsertingParagraphsOnTypingKeystroke(){const e=this.editor.editing.view,t=[ao.enter,ao.delete,ao.backspace];this._listenToIfEnabled(e.document,"keydown",((e,i)=>{t.includes(i.keyCode)||Sm(i)||this._insertParagraphAccordingToFakeCaretPosition()}),{priority:"high"})}_enableDeleteIntegration(){const e=this.editor,t=e.editing.view,i=e.model,n=i.schema;this._listenToIfEnabled(t.document,"delete",((t,s)=>{if("atTarget"!=t.eventPhase)return;const o=Jg(i.document.selection);if(!o)return;const r=s.direction,a=i.document.selection.getSelectedElement(),l="forward"==r;if("before"===o===l)e.execute("delete",{selection:i.createSelection(a,"on")});else{const t=n.getNearestSelectionRange(i.createPositionAt(a,o),r);if(t)if(t.isCollapsed){const s=i.createSelection(t.start);if(i.modifySelection(s,{direction:r}),s.focus.isEqual(t.start)){const e=function(e,t){let i=t;for(const n of t.getAncestors({parentFirst:!0})){if(n.childCount>1||e.isLimit(n))break;i=n}return i}(n,t.start.parent);i.deleteContent(i.createSelection(e,"on"),{doNotAutoparagraph:!0})}else i.change((i=>{i.setSelection(t),e.execute(l?"deleteForward":"delete")}))}else i.change((i=>{i.setSelection(t),e.execute(l?"deleteForward":"delete")}))}s.preventDefault(),t.stop()}),{context:zg})}_enableInsertContentIntegration(){const e=this.editor,t=this.editor.model,i=t.document.selection;this._listenToIfEnabled(e.model,"insertContent",((e,[n,s])=>{if(s&&!s.is("documentSelection"))return;const o=Jg(i);return o?(e.stop(),t.change((e=>{const s=i.getSelectedElement(),r=t.createPositionAt(s,o),a=e.createSelection(r),l=t.insertContent(n,a);return e.setSelection(a),l}))):void 0}),{priority:"high"})}_enableInsertObjectIntegration(){const e=this.editor,t=this.editor.model.document.selection;this._listenToIfEnabled(e.model,"insertObject",((e,i)=>{const[,n,,s={}]=i;if(n&&!n.is("documentSelection"))return;const o=Jg(t);o&&(s.findOptimalPosition=o,i[3]=s)}),{priority:"high"})}_enableDeleteContentIntegration(){const e=this.editor,t=this.editor.model.document.selection;this._listenToIfEnabled(e.model,"deleteContent",((e,[i])=>{if(i&&!i.is("documentSelection"))return;Jg(t)&&e.stop()}),{priority:"high"})}}function ef(e){const t=e.model;return(i,n)=>{const s=n.keyCode==ao.arrowup,o=n.keyCode==ao.arrowdown,r=n.shiftKey,a=t.document.selection;if(!s&&!o)return;const l=o;if(r&&function(e,t){return!e.isCollapsed&&e.isBackward==t}(a,l))return;const c=function(e,t,i){const n=e.model;if(i){const e=t.isCollapsed?t.focus:t.getLastPosition(),i=tf(n,e,"forward");if(!i)return null;const s=n.createRange(e,i),o=nf(n.schema,s,"backward");return o?n.createRange(e,o):null}{const e=t.isCollapsed?t.focus:t.getFirstPosition(),i=tf(n,e,"backward");if(!i)return null;const s=n.createRange(i,e),o=nf(n.schema,s,"forward");return o?n.createRange(o,e):null}}(e,a,l);if(c){if(c.isCollapsed){if(a.isCollapsed)return;if(r)return}(c.isCollapsed||function(e,t,i){const n=e.model,s=e.view.domConverter;if(i){const e=n.createSelection(t.start);n.modifySelection(e),e.focus.isAtEnd||t.start.isEqual(e.focus)||(t=n.createRange(e.focus,t.end))}const o=e.mapper.toViewRange(t),r=s.viewRangeToDom(o),a=ua.getDomRangeRects(r);let l;for(const e of a)if(void 0!==l){if(Math.round(e.top)>=l)return!1;l=Math.max(l,Math.round(e.bottom))}else l=Math.round(e.bottom);return!0}(e,c,l))&&(t.change((e=>{const i=l?c.end:c.start;if(r){const n=t.createSelection(a.anchor);n.setFocus(i),e.setSelection(n)}else e.setSelection(i)})),i.stop(),n.preventDefault(),n.stopPropagation())}}}function tf(e,t,i){const n=e.schema,s=e.createRangeIn(t.root),o="forward"==i?"elementStart":"elementEnd";for(const{previousPosition:e,item:r,type:a}of s.getWalker({startPosition:t,direction:i})){if(n.isLimit(r)&&!n.isInline(r))return e;if(a==o&&n.isBlock(r))return null}return null}function nf(e,t,i){const n="backward"==i?t.end:t.start;if(e.checkChild(n,"$text"))return n;for(const{nextPosition:n}of t.getWalker({direction:i}))if(e.checkChild(n,"$text"))return n;return null}class sf extends ut{static get pluginName(){return"Widget"}static get requires(){return[Xg,Nm]}init(){const e=this.editor,t=e.editing.view,i=t.document;this._previouslySelected=new Set,this.editor.editing.downcastDispatcher.on("selection",((t,i,n)=>{const s=n.writer,o=i.selection;if(o.isCollapsed)return;const r=o.getSelectedElement();if(!r)return;const a=e.editing.mapper.toViewElement(r);zg(a)&&n.consumable.consume(o,"selection")&&s.setSelection(s.createRangeOn(a),{fake:!0,label:Wg(a)})})),this.editor.editing.downcastDispatcher.on("selection",((e,t,i)=>{this._clearPreviouslySelectedWidgets(i.writer);const n=i.writer,s=n.document.selection;let o=null;for(const e of s.getRanges())for(const t of e){const e=t.item;zg(e)&&!of(e,o)&&(n.addClass(Dg,e),this._previouslySelected.add(e),o=e)}}),{priority:"low"}),t.addObserver(Ch),this.listenTo(i,"mousedown",((...e)=>this._onMousedown(...e))),this.listenTo(i,"arrowKey",((...e)=>{this._handleSelectionChangeOnArrowKeyPress(...e)}),{context:[zg,"$text"]}),this.listenTo(i,"arrowKey",((...e)=>{this._preventDefaultOnArrowKeyPress(...e)}),{context:"$root"}),this.listenTo(i,"arrowKey",ef(this.editor.editing),{context:"$text"}),this.listenTo(i,"delete",((e,t)=>{this._handleDelete("forward"==t.direction)&&(t.preventDefault(),e.stop())}),{context:"$root"})}_onMousedown(e,t){const i=this.editor,n=i.editing.view,s=n.document;let o=t.target;if(function(e){for(;e;){if(e.is("editableElement")&&!e.is("rootElement"))return!0;if(zg(e))return!1;e=e.parent}return!1}(o)){if((no.isSafari||no.isGecko)&&t.domEvent.detail>=3){const e=i.editing.mapper,n=o.is("attributeElement")?o.findAncestor((e=>!e.is("attributeElement"))):o,s=e.toModelElement(n);t.preventDefault(),this.editor.model.change((e=>{e.setSelection(s,"in")}))}return}if(!zg(o)&&(o=o.findAncestor(zg),!o))return;no.isAndroid&&t.preventDefault(),s.isFocused||n.focus();const r=i.editing.mapper.toModelElement(o);this._setSelectionOverElement(r)}_handleSelectionChangeOnArrowKeyPress(e,t){const i=t.keyCode,n=this.editor.model,s=n.schema,o=n.document.selection,r=o.getSelectedElement(),a=mo(i,this.editor.locale.contentLanguageDirection),l="down"==a||"right"==a,c="up"==a||"down"==a;if(r&&s.isObject(r)){const i=l?o.getLastPosition():o.getFirstPosition(),r=s.getNearestSelectionRange(i,l?"forward":"backward");return void(r&&(n.change((e=>{e.setSelection(r)})),t.preventDefault(),e.stop()))}if(!o.isCollapsed&&!t.shiftKey){const i=o.getFirstPosition(),r=o.getLastPosition(),a=i.nodeAfter,c=r.nodeBefore;return void((a&&s.isObject(a)||c&&s.isObject(c))&&(n.change((e=>{e.setSelection(l?r:i)})),t.preventDefault(),e.stop()))}if(!o.isCollapsed)return;const d=this._getObjectElementNextToSelection(l);if(d&&s.isObject(d)){if(s.isInline(d)&&c)return;this._setSelectionOverElement(d),t.preventDefault(),e.stop()}}_preventDefaultOnArrowKeyPress(e,t){const i=this.editor.model,n=i.schema,s=i.document.selection.getSelectedElement();s&&n.isObject(s)&&(t.preventDefault(),e.stop())}_handleDelete(e){if(this.editor.isReadOnly)return;const t=this.editor.model.document.selection;if(!t.isCollapsed)return;const i=this._getObjectElementNextToSelection(e);return i?(this.editor.model.change((e=>{let n=t.anchor.parent;for(;n.isEmpty;){const t=n;n=t.parent,e.remove(t)}this._setSelectionOverElement(i)})),!0):void 0}_setSelectionOverElement(e){this.editor.model.change((t=>{t.setSelection(t.createRangeOn(e))}))}_getObjectElementNextToSelection(e){const t=this.editor.model,i=t.schema,n=t.document.selection,s=t.createSelection(n);if(t.modifySelection(s,{direction:e?"forward":"backward"}),s.isEqual(n))return null;const o=e?s.focus.nodeBefore:s.focus.nodeAfter;return o&&i.isObject(o)?o:null}_clearPreviouslySelectedWidgets(e){for(const t of this._previouslySelected)e.removeClass(Dg,t);this._previouslySelected.clear()}}function of(e,t){return!!t&&Array.from(e.getAncestors()).includes(t)}const rf=function(e,t,i){var n=!0,s=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return A(i)&&(n="leading"in i?!!i.leading:n,s="trailing"in i?!!i.trailing:s),Xr(e,t,{leading:n,maxWait:t,trailing:s})};class af extends ut{static get pluginName(){return"DragDrop"}static get requires(){return[Rg,sf]}init(){const e=this.editor,t=e.editing.view;this._draggedRange=null,this._draggingUid="",this._draggableElement=null,this._updateDropMarkerThrottled=rf((e=>this._updateDropMarker(e)),40),this._removeDropMarkerDelayed=df((()=>this._removeDropMarker()),40),this._clearDraggableAttributesDelayed=df((()=>this._clearDraggableAttributes()),40),t.addObserver(Pg),t.addObserver(Ch),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)})),no.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,s=n.document;this.listenTo(s,"dragstart",((n,r)=>{const a=i.selection;if(r.target&&r.target.is("editableElement"))return void r.preventDefault();const l=r.target?uf(r.target):null;if(l){const i=e.editing.mapper.toModelElement(l);this._draggedRange=tl.fromRange(t.createRangeOn(i)),e.plugins.has("WidgetToolbarRepository")&&e.plugins.get("WidgetToolbarRepository").forceDisabled("dragDrop")}else if(!s.selection.isCollapsed){const e=s.selection.getSelectedElement();e&&zg(e)||(this._draggedRange=tl.fromRange(a.getFirstRange()))}if(!this._draggedRange)return void r.preventDefault();this._draggingUid=o(),r.dataTransfer.effectAllowed=this.isEnabled?"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));s.fire("clipboardOutput",{dataTransfer:r.dataTransfer,content:d,method:n.name}),this.isEnabled||(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="")}),{priority:"low"}),this.listenTo(s,"dragend",((e,t)=>{this._finalizeDragging(!t.dataTransfer.isCanceled&&"move"==t.dataTransfer.dropEffect)}),{priority:"low"}),this.listenTo(s,"dragenter",(()=>{this.isEnabled&&n.focus()})),this.listenTo(s,"dragleave",(()=>{this._removeDropMarkerDelayed()})),this.listenTo(s,"dragging",((t,i)=>{if(!this.isEnabled)return void(i.dataTransfer.dropEffect="none");this._removeDropMarkerDelayed.cancel();const n=lf(e,i.targetRanges,i.target);this._draggedRange||(i.dataTransfer.dropEffect="copy"),no.isGecko||("copy"==i.dataTransfer.effectAllowed?i.dataTransfer.dropEffect="copy":["all","copyMove"].includes(i.dataTransfer.effectAllowed)&&(i.dataTransfer.dropEffect="move")),n&&this._updateDropMarkerThrottled(n)}),{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=lf(e,i.targetRanges,i.target);if(this._removeDropMarker(),!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"==cf(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(Rg);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"==cf(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,s)=>{if(no.isAndroid||!s)return;this._clearDraggableAttributesDelayed.cancel();let o=uf(s.target);if(no.isBlink&&!e.isReadOnly&&!o&&!i.selection.isCollapsed){const e=i.selection.getSelectedElement();e&&zg(e)||(o=i.selection.editableElement)}o&&(t.change((e=>{e.setAttribute("draggable","true",o)})),this._draggableElement=e.editing.mapper.toModelElement(o))})),this.listenTo(i,"mouseup",(()=>{no.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.innerHTML="⁠ ⁠",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;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 lf(e,t,i){const n=e.model,s=e.editing.mapper;let o=null;const r=t?t[0].start:null;if(i.is("uiElement")&&(i=i.parent),o=function(e,t){const i=e.model,n=e.editing.mapper;if(zg(t))return i.createRangeOn(n.toModelElement(t));if(!t.is("editableElement")){const e=t.findAncestor((e=>zg(e)||e.is("editableElement")));if(zg(e))return i.createRangeOn(n.toModelElement(e))}return null}(e,i),o)return o;const a=function(e,t){const i=e.editing.mapper,n=e.editing.view,s=i.toModelElement(t);if(s)return s;const o=n.createPositionBefore(t),r=i.findMappedViewAncestor(o);return i.toModelElement(r)}(e,i),l=r?s.toModelPosition(r):null;return l?(o=function(e,t,i){const n=e.model;if(!n.schema.checkChild(i,"$block"))return null;const s=n.createPositionAt(i,0),o=t.path.slice(0,s.path.length),r=n.createPositionFromPath(t.root,o).nodeAfter;if(r&&n.schema.isObject(r))return n.createRangeOn(r);return null}(e,l,a),o||(o=n.schema.getNearestSelectionRange(l,no.isGecko?"forward":"backward"),o||function(e,t){const i=e.model;for(;t;){if(i.schema.isObject(t))return i.createRangeOn(t);t=t.parent}}(e,l.parent))):function(e,t){const i=e.model,n=i.schema,s=i.createPositionAt(t,0);return n.getNearestSelectionRange(s,"forward")}(e,a)}function cf(e){return no.isGecko?e.dropEffect:["all","copyMove"].includes(e.effectAllowed)?"move":"copy"}function df(e,t){let i;function n(...s){n.cancel(),i=setTimeout((()=>e(...s)),t)}return n.cancel=()=>{clearTimeout(i)},n}function uf(e){if(e.is("editableElement"))return null;if(e.hasClass("ck-widget__selection-handle"))return e.findAncestor(zg);if(zg(e))return e;const t=e.findAncestor((e=>zg(e)||e.is("editableElement")));return zg(t)?t:null}class hf extends ut{static get pluginName(){return"PastePlainText"}static get requires(){return[Rg]}init(){const e=this.editor,t=e.model,i=e.editing.view,n=i.document,s=t.document.selection;let o=!1;i.addObserver(Pg),this.listenTo(n,"keydown",((e,t)=>{o=t.shiftKey})),e.plugins.get(Rg).on("contentInsertion",((e,i)=>{(o||function(e,t){if(e.childCount>1)return!1;const i=e.getChild(0);if(t.isObject(i))return!1;return 0==[...i.getAttributeKeys()].length}(i.content,t.schema))&&t.change((e=>{const n=Array.from(s.getAttributes()).filter((([e])=>t.schema.getAttributeProperties(e).isFormatting));s.isCollapsed||t.deleteContent(s,{doNotAutoparagraph:!0}),n.push(...s.getAttributes());const o=e.createRangeIn(i.content);for(const t of o.getItems())t.is("$textProxy")&&e.setAttributes(n,t)}))}))}}class mf extends ut{static get pluginName(){return"Clipboard"}static get requires(){return[Rg,af,hf]}}class gf extends mt{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)||!ff(e.schema,i))do{if(i=i.parent,!i)return}while(!ff(e.schema,i));e.change((e=>{e.setSelection(i,"in")}))}}function ff(e,t){return e.isLimit(t)&&(e.checkChild(t,"$text")||e.checkChild(t,"paragraph"))}const pf=uo("Ctrl+A");class wf extends ut{static get pluginName(){return"SelectAllEditing"}init(){const e=this.editor,t=e.editing.view.document;e.commands.add("selectAll",new gf(e)),this.listenTo(t,"keydown",((t,i)=>{co(i)===pf&&(e.execute("selectAll"),i.preventDefault())}))}}class bf extends ut{static get pluginName(){return"SelectAllUI"}init(){const e=this.editor;e.ui.componentFactory.add("selectAll",(t=>{const i=e.commands.get("selectAll"),n=new iu(t),s=t.t;return n.set({label:s("Select all"),icon:' ',keystroke:"Ctrl+A",tooltip:!0}),n.bind("isOn","isEnabled").to(i,"value","isEnabled"),this.listenTo(n,"execute",(()=>{e.execute("selectAll"),e.editing.view.focus()})),n}))}}class vf extends ut{static get requires(){return[wf,bf]}static get pluginName(){return"SelectAll"}}class _f extends mt{constructor(e){super(e),this._stack=[],this._createdBatches=new WeakSet,this.refresh(),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}addBatch(e){const t=this.editor.model.document.selection,i={ranges:t.hasOwnRange?Array.from(t.getRanges()):[],isBackward:t.isBackward};this._stack.push({batch:e,selection:i}),this.refresh()}clearStack(){this._stack=[],this.refresh()}_restoreSelection(e,t,i){const n=this.editor.model,s=n.document,o=[],r=e.map((e=>e.getTransformedByOperations(i))),a=r.flat();for(const e of r){const t=e.filter((e=>e.root!=s.graveyard)).filter((e=>!kf(e,a)));t.length&&(yf(t),o.push(t[0]))}o.length&&n.change((e=>{e.setSelection(o,{backward:t})}))}_undo(e,t){const i=this.editor.model,n=i.document;this._createdBatches.add(t);const s=e.operations.slice().filter((e=>e.isDocumentOperation));s.reverse();for(const e of s){const s=e.baseVersion+1,o=Array.from(n.history.getOperations(s)),r=fh([e.getReversed()],o,{useRelations:!0,document:this.editor.model.document,padWithNoOps:!1,forceWeakRemove:!0}).operationsA;for(const s of r)t.addOperation(s),i.applyOperation(s),n.history.setOperationAsUndone(e,s)}}}function yf(e){e.sort(((e,t)=>e.start.isBefore(t.start)?-1:1));for(let t=1;tt!==e&&t.containsRange(e,!0)))}class Cf extends _f{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 Af extends _f{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 xf extends ut{static get pluginName(){return"UndoEditing"}constructor(e){super(e),this._batchRegistry=new WeakSet}init(){const e=this.editor;this._undoCommand=new Cf(e),this._redoCommand=new Af(e),e.commands.add("undo",this._undoCommand),e.commands.add("redo",this._redoCommand),this.listenTo(e.model,"applyOperation",((e,t)=>{const i=t[0];if(!i.isDocumentOperation)return;const n=i.batch,s=this._redoCommand._createdBatches.has(n),o=this._undoCommand._createdBatches.has(n);this._batchRegistry.has(n)||(this._batchRegistry.add(n),n.isUndoable&&(s?this._undoCommand.addBatch(n):o||(this._undoCommand.addBatch(n),this._redoCommand.clearStack())))}),{priority:"highest"}),this.listenTo(this._undoCommand,"revert",((e,t,i)=>{this._redoCommand.addBatch(i)})),e.keystrokes.set("CTRL+Z","undo"),e.keystrokes.set("CTRL+Y","redo"),e.keystrokes.set("CTRL+SHIFT+Z","redo")}}const Tf=' ',Ef=' ';class Pf extends ut{static get pluginName(){return"UndoUI"}init(){const e=this.editor,t=e.locale,i=e.t,n="ltr"==t.uiLanguageDirection?Tf:Ef,s="ltr"==t.uiLanguageDirection?Ef:Tf;this._addButton("undo",i("Undo"),"CTRL+Z",n),this._addButton("redo",i("Redo"),"CTRL+Y",s)}_addButton(e,t,i,n){const s=this.editor;s.ui.componentFactory.add(e,(o=>{const r=s.commands.get(e),a=new iu(o);return a.set({label:t,icon:n,keystroke:i,tooltip:!0}),a.bind("isEnabled").to(r,"isEnabled"),this.listenTo(a,"execute",(()=>{s.execute(e),s.editing.view.focus()})),a}))}}class Sf extends ut{static get requires(){return[xf,Pf]}static get pluginName(){return"Undo"}}class If extends mt{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;t.change((e=>{if(i.isCollapsed)n?e.setSelectionAttribute(this.attributeKey,n):e.removeSelectionAttribute(this.attributeKey);else{const s=t.schema.getValidRanges(i.getRanges(),this.attributeKey);for(const t of s)n?e.setAttribute(this.attributeKey,n,t):e.removeAttribute(this.attributeKey,t)}}))}}class Rf extends Tn{constructor(e){super(e),this.set("isEmpty",!0),this.on("change",(()=>{this.set("isEmpty",0===this.length)}))}add(e,t){this.find((t=>t.color===e.color))||super.add(e,t)}hasColor(e){return!!this.find((t=>t.color===e))}}dt(Rf,st);class Vf extends Vd{constructor(e,{colors:t,columns:i,removeButtonLabel:n,documentColorsLabel:s,documentColorsCount:o}){super(e),this.items=this.createCollection(),this.colorDefinitions=t,this.focusTracker=new Ea,this.keystrokes=new Pa,this.set("selectedColor"),this.removeButtonLabel=n,this.columns=i,this.documentColors=new Rf,this.documentColorsCount=o,this._focusCycler=new cu({focusables:this.items,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"arrowup",focusNext:"arrowdown"}}),this._documentColorsLabel=s,this.setTemplate({tag:"div",attributes:{class:["ck","ck-color-table"]},children:this.items}),this.items.add(this._removeColorButton())}updateDocumentColors(e,t){const i=e.document,n=this.documentColorsCount;this.documentColors.clear();for(const s of i.getRootNames()){const o=i.getRoot(s),r=e.createRangeIn(o);for(const e of r.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(){super.render();for(const e of this.items)this.focusTracker.add(e.element);this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}appendGrids(){if(!this.staticColorsGrid&&(this.staticColorsGrid=this._createStaticColorsGrid(),this.items.add(this.staticColorsGrid),this.documentColorsCount)){const e=Od.bind(this.documentColors,this.documentColors),t=new Bu(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)}}focus(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}_removeColorButton(){const e=new iu;return e.set({withText:!0,icon:Ed.eraser,tooltip:!0,label:this.removeButtonLabel}),e.class="ck-color-table__remove-color",e.on("execute",(()=>{this.fire("execute",{value:null})})),e}_createStaticColorsGrid(){const e=new uu(this.locale,{colorDefinitions:this.colorDefinitions,columns:this.columns});return e.delegate("execute").to(this),e}_createDocumentColorsGrid(){const e=Od.bind(this.documentColors,this.documentColors),t=new uu(this.locale,{columns:this.columns});return t.delegate("execute").to(this),t.extendTemplate({attributes:{class:e.if("isEmpty","ck-hidden")}}),t.items.bindTo(this.documentColors).using((e=>{const t=new au;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})})),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}})}}const Of="fontSize",Bf="fontFamily",Mf="fontColor";function Nf(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 Df(e){return(t,{writer:i})=>i.createAttributeElement("span",{style:`${e}:${t}`},{priority:7})}class zf extends If{constructor(e){super(e,Mf)}}class Lf extends ut{static get pluginName(){return"FontColorEditing"}constructor(e){var t;super(e),e.config.define(Mf,{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:Mf,value:(t="color",e=>e.getStyle(t).replace(/\s/g,""))}}),e.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{color:/^#?\w+$/}},model:{key:Mf,value:e=>e.getAttribute("color")}}),e.conversion.for("downcast").attributeToElement({model:Mf,view:Df("color")}),e.commands.add(Mf,new zf(e)),e.model.schema.extend("$text",{allowAttributes:Mf}),e.model.schema.setAttributeProperties(Mf,{isFormatting:!0,copyOnEnter:!0})}}class Ff extends ut{constructor(e,{commandName:t,icon:i,componentName:n,dropdownLabel:s}){super(e),this.commandName=t,this.componentName=n,this.icon=i,this.dropdownLabel=s,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),s=su(t,ou(e.config.get(this.componentName).colors)),o=e.config.get(`${this.componentName}.documentColors`);e.ui.componentFactory.add(this.componentName,(t=>{const r=Iu(t);return this.colorTableView=function({dropdownView:e,colors:t,columns:i,removeButtonLabel:n,documentColorsLabel:s,documentColorsCount:o}){const r=e.locale,a=new Vf(r,{colors:t,columns:i,removeButtonLabel:n,documentColorsLabel:s,documentColorsCount:o});return e.colorTableView=a,e.panelView.children.add(a),a.delegate("execute").to(e,"execute"),a}({dropdownView:r,colors:s.map((e=>({label:e.label,color:e.model,options:{hasBorder:e.hasBorder}}))),columns:this.columns,removeButtonLabel:i("Remove color"),documentColorsLabel:0!==o?i("Document colors"):void 0,documentColorsCount:void 0===o?this.columns:o}),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),r.on("execute",((t,i)=>{e.execute(this.commandName,i),e.editing.view.focus()})),r.on("change:isOpen",((t,i,n)=>{r.colorTableView.appendGrids(),n&&(0!==o&&this.colorTableView.updateDocumentColors(e.model,this.componentName),this.colorTableView.updateSelectedColors())})),r}))}}class Hf extends Ff{constructor(e){const t=e.locale.t;super(e,{commandName:Mf,componentName:Mf,icon:' ',dropdownLabel:t("Font Color")})}static get pluginName(){return"FontColorUI"}}class jf extends If{constructor(e){super(e,Bf)}}function Wf(e){return e.map(Uf).filter((e=>!!e))}function Uf(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(qf).join(", ");return{title:i,model:n,view:{name:"span",styles:{"font-family":n},priority:7}}}(e):void 0}function qf(e){return(e=e.trim()).indexOf(" ")>0&&(e=`'${e}'`),e}class $f extends ut{static get pluginName(){return"FontFamilyEditing"}constructor(e){super(e),e.config.define(Bf,{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:Bf}),e.model.schema.setAttributeProperties(Bf,{isFormatting:!0,copyOnEnter:!0});const t=Wf(e.config.get("fontFamily.options")).filter((e=>e.model)),i=Nf(Bf,t);e.config.get("fontFamily.supportAllValues")?(this._prepareAnyValueConverters(),this._prepareCompatibilityConverter()):e.conversion.attributeToElement(i),e.commands.add(Bf,new jf(e))}_prepareAnyValueConverters(){const e=this.editor;e.conversion.for("downcast").attributeToElement({model:Bf,view:(e,{writer:t})=>t.createAttributeElement("span",{style:"font-family:"+e},{priority:7})}),e.conversion.for("upcast").elementToAttribute({model:{key:Bf,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:Bf,value:e=>e.getAttribute("face")}})}}class Kf extends ut{static get pluginName(){return"FontFamilyUI"}init(){const e=this.editor,t=e.t,i=this._getLocalizedOptions(),n=e.commands.get(Bf);e.ui.componentFactory.add(Bf,(s=>{const o=Iu(s);return Vu(o,function(e,t){const i=new Tn;for(const n of e){const e={type:"button",model:new Ku({commandName:Bf,commandParam:n.model,label:n.title,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&&n.view.styles&&e.model.set("labelStyle",`font-family: ${n.view.styles["font-family"]}`),i.add(e)}return i}(i,n)),o.buttonView.set({label:t("Font Family"),icon:' ',tooltip:!0}),o.extendTemplate({attributes:{class:"ck-font-family-dropdown"}}),o.bind("isEnabled").to(n),this.listenTo(o,"execute",(t=>{e.execute(t.source.commandName,{value:t.source.commandParam}),e.editing.view.focus()})),o}))}_getLocalizedOptions(){const e=this.editor,t=e.t;return Wf(e.config.get(Bf).options).map((e=>("Default"===e.title&&(e.title=t("Default")),e)))}}class Gf extends If{constructor(e){super(e,Of)}}function Jf(e){return e.map((e=>function(e){if(t=e,"object"==typeof t&&t.title&&t.model&&t.view)return Qf(e);var t;const i=function(e){return Yf[e]||Yf[e.model]}(e);if(i)return Qf(i);if("default"===e)return{model:void 0,title:"Default"};if(function(e){let t;if("object"==typeof e){if(!e.model)throw new l("font-size-invalid-definition",null,e);t=parseFloat(e.model)}else t=parseFloat(e);return isNaN(t)}(e))return;return function(e){"number"!=typeof e&&"string"!=typeof e||(e={title:String(e),model:`${parseFloat(e)}px`});return e.view={name:"span",styles:{"font-size":e.model}},Qf(e)}(e)}(e))).filter((e=>!!e))}const Yf={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 Qf(e){return e.view.priority||(e.view.priority=7),e}const Zf=["x-small","x-small","small","medium","large","x-large","xx-large","xxx-large"];class Xf extends ut{static get pluginName(){return"FontSizeEditing"}constructor(e){super(e),e.config.define(Of,{options:["tiny","small","default","big","huge"],supportAllValues:!1})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:Of}),e.model.schema.setAttributeProperties(Of,{isFormatting:!0,copyOnEnter:!0});const t=e.config.get("fontSize.supportAllValues"),i=Jf(this.editor.config.get("fontSize.options")).filter((e=>e.model)),n=Nf(Of,i);t?(this._prepareAnyValueConverters(n),this._prepareCompatibilityConverter()):e.conversion.attributeToElement(n),e.commands.add(Of,new Gf(e))}_prepareAnyValueConverters(e){const t=this.editor,i=e.model.values.filter((e=>!Mh(String(e))&&!Dh(String(e))));if(i.length)throw new l("font-size-invalid-use-of-named-presets",null,{presets:i});t.conversion.for("downcast").attributeToElement({model:Of,view:(e,{writer:t})=>{if(e)return t.createAttributeElement("span",{style:"font-size:"+e},{priority:7})}}),t.conversion.for("upcast").elementToAttribute({model:{key:Of,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:Of,value:e=>{const t=e.getAttribute("size"),i="-"===t[0]||"+"===t[0];let n=parseInt(t,10);i&&(n=3+n);const s=Zf.length-1,o=Math.min(Math.max(n,0),s);return Zf[o]}}})}}class ep extends ut{static get pluginName(){return"FontSizeUI"}init(){const e=this.editor,t=e.t,i=this._getLocalizedOptions(),n=e.commands.get(Of);e.ui.componentFactory.add(Of,(s=>{const o=Iu(s);return Vu(o,function(e,t){const i=new Tn;for(const n of e){const e={type:"button",model:new Ku({commandName:Of,commandParam:n.model,label:n.title,class:"ck-fontsize-option",withText:!0})};n.view&&n.view.styles&&e.model.set("labelStyle",`font-size:${n.view.styles["font-size"]}`),n.view&&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)),o.buttonView.set({label:t("Font Size"),icon:' ',tooltip:!0}),o.extendTemplate({attributes:{class:["ck-font-size-dropdown"]}}),o.bind("isEnabled").to(n),this.listenTo(o,"execute",(t=>{e.execute(t.source.commandName,{value:t.source.commandParam}),e.editing.view.focus()})),o}))}_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 Jf(e.config.get(Of).options).map((e=>{const t=i[e.title];return t&&t!=e.title&&(e=Object.assign({},e,{title:t})),e}))}}class tp extends mt{refresh(){const e=this.editor.model,t=Ta(e.document.selection.getSelectedBlocks());this.value=!!t&&t.is("element","paragraph"),this.isEnabled=!!t&&ip(t,e.schema)}execute(e={}){const t=this.editor.model,i=t.document;t.change((n=>{const s=(e.selection||i.selection).getSelectedBlocks();for(const e of s)!e.is("element","paragraph")&&ip(e,t.schema)&&n.rename(e,"paragraph")}))}}function ip(e,t){return t.checkChild(e.parent,"paragraph")&&!t.isObject(e)}class np extends mt{execute(e){const t=this.editor.model,i=e.attributes;let n=e.position;t.change((e=>{const s=e.createElement("paragraph");if(i&&t.schema.setAllowedAttributes(s,i,e),!t.schema.checkChild(n.parent,s)){const i=t.schema.findAllowedParent(n,s);if(!i)return;n=e.split(n,i).position}t.insertContent(s,n),e.setSelection(s,"in")}))}}class sp extends ut{static get pluginName(){return"Paragraph"}init(){const e=this.editor,t=e.model;e.commands.add("paragraph",new tp(e)),e.commands.add("insertParagraph",new np(e)),t.schema.register("paragraph",{inheritAllFrom:"$block"}),e.conversion.elementToElement({model:"paragraph",view:"p"}),e.conversion.for("upcast").elementToElement({model:(e,{writer:t})=>sp.paragraphLikeElements.has(e.name)?e.isEmpty?null:t.createElement("paragraph"):null,view:/.+/,converterPriority:"low"})}}sp.paragraphLikeElements=new Set(["blockquote","dd","div","dt","h1","h2","h3","h4","h5","h6","li","p","td","th"]);class op extends mt{constructor(e,t){super(e),this.modelElements=t}refresh(){const e=Ta(this.editor.model.document.selection.getSelectedBlocks());this.value=!!e&&this.modelElements.includes(e.name)&&e.name,this.isEnabled=!!e&&this.modelElements.some((t=>rp(e,t,this.editor.model.schema)))}execute(e){const t=this.editor.model,i=t.document,n=e.value;t.change((e=>{const s=Array.from(i.selection.getSelectedBlocks()).filter((e=>rp(e,n,t.schema)));for(const t of s)t.is("element",n)||e.rename(t,n)}))}}function rp(e,t,i){return i.checkChild(e.parent,t)&&!i.isObject(e)}const ap="paragraph";class lp extends ut{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[sp]}init(){const e=this.editor,t=e.config.get("heading.options"),i=[];for(const n of t)n.model!==ap&&(e.model.schema.register(n.model,{inheritAllFrom:"$block"}),e.conversion.elementToElement(n),i.push(n.model));this._addDefaultH1Conversion(e),e.commands.add("heading",new op(e,i))}afterInit(){const e=this.editor,t=e.commands.get("enter"),i=e.config.get("heading.options");t&&this.listenTo(t,"afterExecute",((t,n)=>{const s=e.model.document.selection.getFirstPosition().parent;i.some((e=>s.is("element",e.model)))&&!s.is("element",ap)&&0===s.childCount&&n.writer.rename(s,ap)}))}_addDefaultH1Conversion(e){e.conversion.for("upcast").elementToElement({model:"heading1",view:"h1",converterPriority:r.get("low")+1})}}class cp extends ut{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"),s=t("Heading");e.ui.componentFactory.add("heading",(t=>{const o={},r=new Tn,a=e.commands.get("heading"),l=e.commands.get("paragraph"),c=[a];for(const e of i){const t={type:"button",model:new Ku({label:e.title,class:e.class,withText:!0})};"paragraph"===e.model?(t.model.bind("isOn").to(l,"value"),t.model.set("commandName","paragraph"),c.push(l)):(t.model.bind("isOn").to(a,"value",(t=>t===e.model)),t.model.set({commandName:"heading",commandValue:e.model})),r.add(t),o[e.model]=e.title}const d=Iu(t);return Vu(d,r),d.buttonView.set({isOn:!1,withText:!0,tooltip:s}),d.extendTemplate({attributes:{class:["ck-heading-dropdown"]}}),d.bind("isEnabled").toMany(c,"isEnabled",((...e)=>e.some((e=>e)))),d.buttonView.bind("label").to(a,"value",l,"value",((e,t)=>{const i=e||t&&"paragraph";return o[i]?o[i]:n})),this.listenTo(d,"execute",(t=>{e.execute(t.source.commandName,t.source.commandValue?{value:t.source.commandValue}:void 0),e.editing.view.focus()})),d}))}}class dp extends ut{static get requires(){return[eh]}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||!zg(t))})(e.editing.view.document.selection)&&t.stop()}),{priority:"high"})}this._toolbarDefinitions=new Map,this._balloon=this.editor.plugins.get("ContextualBalloon"),this.on("change:isEnabled",(()=>{this._updateToolbarsVisibility()})),this.listenTo(e.ui,"update",(()=>{this._updateToolbarsVisibility()})),this.listenTo(e.ui.focusTracker,"change:isFocused",(()=>{this._updateToolbarsVisibility()}),{priority:"low"})}destroy(){super.destroy();for(const e of this._toolbarDefinitions.values())e.view.destroy()}register(e,{ariaLabel:t,items:i,getRelatedElement:n,balloonClassName:s="ck-toolbar-container"}){if(!i.length)return void c("widget-toolbar-no-items",{toolbarId:e});const o=this.editor,r=o.t,a=new Cu(o.locale);if(a.ariaLabel=t||r("Widget toolbar"),this._toolbarDefinitions.has(e))throw new l("widget-toolbar-duplicated",this,{toolbarId:e});a.fillFromConfig(i,o.ui.componentFactory),this._toolbarDefinitions.set(e,{view:a,getRelatedElement:n,balloonClassName:s})}_updateToolbarsVisibility(){let e=0,t=null,i=null;for(const n of this._toolbarDefinitions.values()){const s=n.getRelatedElement(this.editor.editing.view.document.selection);if(this.isEnabled&&s)if(this.editor.ui.focusTracker.isFocused){const o=s.getAncestors().length;o>e&&(e=o,t=s,i=n)}else this._isToolbarVisible(n)&&this._hideToolbar(n);else this._isToolbarInBalloon(n)&&this._hideToolbar(n)}i&&this._showToolbar(i,t)}_hideToolbar(e){this._balloon.remove(e.view),this.stopListening(this._balloon,"change:visibleView")}_showToolbar(e,t){this._isToolbarVisible(e)?up(this.editor,t):this._isToolbarInBalloon(e)||(this._balloon.add({view:e.view,position:hp(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);up(this.editor,t)}})))}_isToolbarVisible(e){return this._balloon.visibleView===e.view}_isToolbarInBalloon(e){return this._balloon.hasView(e.view)}}function up(e,t){const i=e.plugins.get("ContextualBalloon"),n=hp(e,t);i.updatePosition(n)}function hp(e,t){const i=e.editing.view,n=Qu.defaultPositions;return{target:i.domConverter.mapViewToDom(t),positions:[n.northArrowSouth,n.northArrowSouthWest,n.northArrowSouthEast,n.southArrowNorth,n.southArrowNorthWest,n.southArrowNorthEast,n.viewportStickyNorth]}}class mp{constructor(e){this.set("activeHandlePosition",null),this.set("proposedWidthPercents",null),this.set("proposedWidth",null),this.set("proposedHeight",null),this.set("proposedHandleHostWidth",null),this.set("proposedHandleHostHeight",null),this._options=e,this._referenceCoordinates=null}begin(e,t,i){const n=new ua(t);this.activeHandlePosition=function(e){const t=["top-left","top-right","bottom-right","bottom-left"];for(const i of t)if(e.classList.contains(gp(i)))return i}(e),this._referenceCoordinates=function(e,t){const i=new ua(e),n=t.split("-"),s={x:"right"==n[1]?i.right:i.left,y:"bottom"==n[0]?i.bottom:i.top};return s.x+=e.ownerDocument.defaultView.scrollX,s.y+=e.ownerDocument.defaultView.scrollY,s}(t,function(e){const t=e.split("-"),i={top:"bottom",bottom:"top",left:"right",right:"left"};return`${i[t[0]]}-${i[t[1]]}`}(this.activeHandlePosition)),this.originalWidth=n.width,this.originalHeight=n.height,this.aspectRatio=n.width/n.height;const s=i.style.width;s&&s.match(/^\d+(\.\d*)?%$/)?this.originalWidthPercents=parseFloat(s):this.originalWidthPercents=function(e,t){const i=e.parentElement,n=parseFloat(i.ownerDocument.defaultView.getComputedStyle(i).width);return t.width/n*100}(i,n)}update(e){this.proposedWidth=e.width,this.proposedHeight=e.height,this.proposedWidthPercents=e.widthPercents,this.proposedHandleHostWidth=e.handleHostWidth,this.proposedHandleHostHeight=e.handleHostHeight}}function gp(e){return`ck-widget__resizer__handle-${e}`}dt(mp,st);class fp extends Vd{constructor(){super();const e=this.bindTemplate;this.setTemplate({tag:"div",attributes:{class:["ck","ck-size-view",e.to("_viewPosition",(e=>e?`ck-orientation-${e}`:""))],style:{display:e.if("_isVisible","none",(e=>!e))}},children:[{text:e.to("_label")}]})}_bindToState(e,t){this.bind("_isVisible").to(t,"proposedWidth",t,"proposedHeight",((e,t)=>null!==e&&null!==t)),this.bind("_label").to(t,"proposedHandleHostWidth",t,"proposedHandleHostHeight",t,"proposedWidthPercents",((t,i,n)=>"px"===e.unit?`${t}×${i}`:`${n}%`)),this.bind("_viewPosition").to(t,"activeHandlePosition",t,"proposedHandleHostWidth",t,"proposedHandleHostHeight",((e,t,i)=>t<50||i<50?"above-center":e))}_dismiss(){this.unbind(),this._isVisible=!1}}class pp{constructor(e){this._options=e,this._viewResizerWrapper=null,this.set("isEnabled",!0),this.decorate("begin"),this.decorate("cancel"),this.decorate("commit"),this.decorate("updateSize"),this.on("commit",(e=>{this.state.proposedWidth||this.state.proposedWidthPercents||(this._cleanup(),e.stop())}),{priority:"high"}),this.on("change:isEnabled",(()=>{this.isEnabled&&this.redraw()}))}attach(){const e=this,t=this._options.viewElement;this._options.editor.editing.view.change((i=>{const n=i.createUIElement("div",{class:"ck ck-reset_all ck-widget__resizer"},(function(t){const i=this.toDomElement(t);return e._appendHandles(i),e._appendSizeUI(i),e.on("change:isEnabled",((e,t,n)=>{i.style.display=n?"":"none"})),i.style.display=e.isEnabled?"":"none",i}));i.insert(i.createPositionAt(t,"end"),n),i.addClass("ck-widget_with-resizer",t),this._viewResizerWrapper=n}))}begin(e){this.state=new mp(this._options),this._sizeView._bindToState(this._options,this.state),this._initialViewWidth=this._options.viewElement.getStyle("width"),this.state.begin(e,this._getHandleHost(),this._getResizeHost())}updateSize(e){const t=this._proposeNewSize(e);this._options.editor.editing.view.change((e=>{const i=this._options.unit||"%",n=("%"===i?t.widthPercents:t.width)+i;e.setStyle("width",n,this._options.viewElement)}));const i=this._getHandleHost(),n=new ua(i);t.handleHostWidth=Math.round(n.width),t.handleHostHeight=Math.round(n.height);const s=new ua(i);t.width=Math.round(s.width),t.height=Math.round(s.height),this.redraw(n),this.state.update(t)}commit(){const e=this._options.unit||"%",t=("%"===e?this.state.proposedWidthPercents:this.state.proposedWidth)+e;this._options.editor.editing.view.change((()=>{this._cleanup(),this._options.onCommit(t)}))}cancel(){this._cleanup()}destroy(){this.cancel()}redraw(e){const t=this._domResizerWrapper;if(!((i=t)&&i.ownerDocument&&i.ownerDocument.contains(i)))return;var i;const n=t.parentElement,s=this._getHandleHost(),o=this._viewResizerWrapper,r=[o.getStyle("width"),o.getStyle("height"),o.getStyle("left"),o.getStyle("top")];let a;if(n.isSameNode(s)){const t=e||new ua(s);a=[t.width+"px",t.height+"px",void 0,void 0]}else a=[s.offsetWidth+"px",s.offsetHeight+"px",s.offsetLeft+"px",s.offsetTop+"px"];"same"!==Mn(r,a)&&this._options.editor.editing.view.change((e=>{e.setStyle({width:a[0],height:a[1],left:a[2],top:a[3]},o)}))}containsHandle(e){return this._domResizerWrapper.contains(e)}static isResizeHandle(e){return e.classList.contains("ck-widget__resizer__handle")}_cleanup(){this._sizeView._dismiss();this._options.editor.editing.view.change((e=>{e.setStyle("width",this._initialViewWidth,this._options.viewElement)}))}_proposeNewSize(e){const t=this.state,i={x:(n=e).pageX,y:n.pageY};var n;const s=!this._options.isCentered||this._options.isCentered(this),o={x:t._referenceCoordinates.x-(i.x+t.originalWidth),y:i.y-t.originalHeight-t._referenceCoordinates.y};s&&t.activeHandlePosition.endsWith("-right")&&(o.x=i.x-(t._referenceCoordinates.x+t.originalWidth)),s&&(o.x*=2);const r={width:Math.abs(t.originalWidth+o.x),height:Math.abs(t.originalHeight+o.y)};r.dominant=r.width/t.aspectRatio>r.height?"width":"height",r.max=r[r.dominant];const a={width:r.width,height:r.height};return"width"==r.dominant?a.height=a.width/t.aspectRatio:a.width=a.height*t.aspectRatio,{width:Math.round(a.width),height:Math.round(a.height),widthPercents:Math.min(Math.round(t.originalWidthPercents/t.originalWidth*a.width*100)/100,100)}}_getResizeHost(){const e=this._domResizerWrapper.parentElement;return this._options.getResizeHost(e)}_getHandleHost(){const e=this._domResizerWrapper.parentElement;return this._options.getHandleHost(e)}get _domResizerWrapper(){return this._options.editor.editing.view.domConverter.mapViewToDom(this._viewResizerWrapper)}_appendHandles(e){const t=["top-left","top-right","bottom-right","bottom-left"];for(const n of t)e.appendChild(new Od({tag:"div",attributes:{class:"ck-widget__resizer__handle "+(i=n,`ck-widget__resizer__handle-${i}`)}}).render());var i}_appendSizeUI(e){this._sizeView=new fp,this._sizeView.render(),e.appendChild(this._sizeView.element)}}dt(pp,st);class wp extends ut{static get pluginName(){return"WidgetResize"}init(){const e=this.editor.editing,t=Zo.window.document;this.set("visibleResizer",null),this.set("_activeResizer",null),this._resizers=new Map,e.view.addObserver(Ch),this._observer=Object.create(hr),this.listenTo(e.view.document,"mousedown",this._mouseDownListener.bind(this),{priority:"high"}),this._observer.listenTo(t,"mousemove",this._mouseMoveListener.bind(this)),this._observer.listenTo(t,"mouseup",this._mouseUpListener.bind(this));const i=()=>{this.visibleResizer&&this.visibleResizer.redraw()};this._redrawFocusedResizerThrottled=rf(i,200),this.on("change:visibleResizer",i),this.editor.ui.on("update",this._redrawFocusedResizerThrottled),this.editor.model.document.on("change",(()=>{for(const[e,t]of this._resizers)e.isAttached()||(this._resizers.delete(e),t.destroy())}),{priority:"lowest"}),this._observer.listenTo(Zo.window,"resize",this._redrawFocusedResizerThrottled);const n=this.editor.editing.view.document.selection;n.on("change",(()=>{const e=n.getSelectedElement();this.visibleResizer=this.getResizerByViewElement(e)||null}))}destroy(){this._observer.stopListening();for(const e of this._resizers.values())e.destroy();this._redrawFocusedResizerThrottled.cancel()}attachTo(e){const t=new pp(e),i=this.editor.plugins;if(t.attach(),i.has("WidgetToolbarRepository")){const e=i.get("WidgetToolbarRepository");t.on("begin",(()=>{e.forceDisabled("resize")}),{priority:"lowest"}),t.on("cancel",(()=>{e.clearForceDisabled("resize")}),{priority:"highest"}),t.on("commit",(()=>{e.clearForceDisabled("resize")}),{priority:"highest"})}this._resizers.set(e.viewElement,t);const n=this.editor.editing.view.document.selection.getSelectedElement();return this.getResizerByViewElement(n)==t&&(this.visibleResizer=t),t}getResizerByViewElement(e){return this._resizers.get(e)}_getResizerByHandle(e){for(const t of this._resizers.values())if(t.containsHandle(e))return t}_mouseDownListener(e,t){const i=t.domTarget;pp.isResizeHandle(i)&&(this._activeResizer=this._getResizerByHandle(i),this._activeResizer&&(this._activeResizer.begin(i),e.stop(),t.preventDefault()))}_mouseMoveListener(e,t){this._activeResizer&&this._activeResizer.updateSize(t)}_mouseUpListener(){this._activeResizer&&(this._activeResizer.commit(),this._activeResizer=null)}}dt(wp,st);class bp extends mt{refresh(){const e=this.editor.model,t=e.schema,i=e.document.selection;this.isEnabled=function(e,t,i){const n=function(e,t){const i=qg(e,t).start.parent;if(i.isEmpty&&!i.is("element","$root"))return i.parent;return i}(e,i);return t.checkChild(n,"horizontalLine")}(i,t,e)}execute(){const e=this.editor.model;e.change((t=>{const i=t.createElement("horizontalLine");e.insertObject(i,null,null,{setSelection:"after"})}))}}class vp extends ut{static get pluginName(){return"HorizontalLineEditing"}init(){const e=this.editor,t=e.model.schema,i=e.t,n=e.conversion;t.register("horizontalLine",{inheritAllFrom:"$blockObject"}),n.for("dataDowncast").elementToElement({model:"horizontalLine",view:(e,{writer:t})=>t.createEmptyElement("hr")}),n.for("editingDowncast").elementToStructure({model:"horizontalLine",view:(e,{writer:t})=>{const n=i("Horizontal line"),s=t.createContainerElement("div",null,t.createEmptyElement("hr"));return t.addClass("ck-horizontal-line",s),t.setCustomProperty("hr",!0,s),function(e,t,i){return t.setCustomProperty("horizontalLine",!0,e),Lg(e,t,{label:i})}(s,t,n)}}),n.for("upcast").elementToElement({view:"hr",model:"horizontalLine"}),e.commands.add("horizontalLine",new bp(e))}}class _p extends ut{static get pluginName(){return"HorizontalLineUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add("horizontalLine",(i=>{const n=e.commands.get("horizontalLine"),s=new iu(i);return s.set({label:t("Horizontal line"),icon:' ',tooltip:!0}),s.bind("isEnabled").to(n,"isEnabled"),this.listenTo(s,"execute",(()=>{e.execute("horizontalLine"),e.editing.view.focus()})),s}))}}class yp extends mt{refresh(){const e=this.editor.plugins.get("ImageUtils").getClosestSelectedImageElement(this.editor.model.document.selection);this.isEnabled=!!e,this.isEnabled&&e.hasAttribute("alt")?this.value=e.getAttribute("alt"):this.value=!1}execute(e){const t=this.editor,i=t.plugins.get("ImageUtils"),n=t.model,s=i.getClosestSelectedImageElement(n.document.selection);n.change((t=>{t.setAttribute("alt",e.newValue,s)}))}}function kp(e){return e.createContainerElement("figure",{class:"image"},[e.createEmptyElement("img"),e.createSlot()])}function Cp(e,t){const i=e.plugins.get("ImageUtils"),n=e.plugins.has("ImageInlineEditing")&&e.plugins.has("ImageBlockEditing");return e=>{if(!i.isInlineImageView(e))return null;if(!n)return s(e);return(e.findAncestor(i.isBlockImageView)?"imageBlock":"imageInline")!==t?null:s(e)};function s(e){const t={name:!0};return e.hasAttribute("src")&&(t.attributes=["src"]),t}}function Ap(e,t){const i=Ta(t.getSelectedBlocks());return!i||e.isObject(i)||i.isEmpty&&"listItem"!=i.name?"imageBlock":"imageInline"}class xp extends ut{static get pluginName(){return"ImageUtils"}isImage(e){return this.isInlineImage(e)||this.isBlockImage(e)}isInlineImageView(e){return!!e&&e.is("element","img")}isBlockImageView(e){return!!e&&e.is("element","figure")&&e.hasClass("image")}insertImage(e={},t=null,i=null){const n=this.editor,s=n.model,o=s.document.selection;i=Tp(n,t||o,i),e={...Object.fromEntries(o.getAttributes()),...e};for(const t in e)s.schema.checkAttribute(i,t)||delete e[t];return s.change((n=>{const o=n.createElement(i,e);return s.insertObject(o,t,null,{setSelection:"on",findOptimalPosition:!t&&"imageInline"!=i}),o.parent?o:null}))}getClosestSelectedImageWidget(e){const t=e.getSelectedElement();if(t&&this.isImageWidget(t))return t;let i=e.getFirstPosition().parent;for(;i;){if(i.is("element")&&this.isImageWidget(i))return i;i=i.parent}return null}getClosestSelectedImageElement(e){const t=e.getSelectedElement();return this.isImage(t)?t:e.getFirstPosition().findAncestor("imageBlock")}isImageAllowed(){const e=this.editor.model.document.selection;return function(e,t){if("imageBlock"==Tp(e,t)){const i=function(e,t){const i=qg(e,t).start.parent;if(i.isEmpty&&!i.is("element","$root"))return i.parent;return i}(t,e.model);if(e.model.schema.checkChild(i,"imageBlock"))return!0}else if(e.model.schema.checkChild(t.focus,"imageInline"))return!0;return!1}(this.editor,e)&&function(e){return[...e.focus.getAncestors()].every((e=>!e.is("element","imageBlock")))}(e)}toImageWidget(e,t,i){t.setCustomProperty("image",!0,e);return Lg(e,t,{label:()=>{const t=this.findViewImgElement(e).getAttribute("alt");return t?`${t} ${i}`:i}})}isImageWidget(e){return!!e.getCustomProperty("image")&&zg(e)}isBlockImage(e){return!!e&&e.is("element","imageBlock")}isInlineImage(e){return!!e&&e.is("element","imageInline")}findViewImgElement(e){if(this.isInlineImageView(e))return e;const t=this.editor.editing.view;for(const{item:i}of t.createRangeIn(e))if(this.isInlineImageView(i))return i}}function Tp(e,t,i){const n=e.model.schema,s=e.config.get("image.insert.type");return e.plugins.has("ImageBlockEditing")?e.plugins.has("ImageInlineEditing")?i||("inline"===s?"imageInline":"block"===s?"imageBlock":t.is("selection")?Ap(n,t):n.checkChild(t,"imageInline")?"imageInline":"imageBlock"):"imageBlock":"imageInline"}class Ep extends ut{static get requires(){return[xp]}static get pluginName(){return"ImageTextAlternativeEditing"}init(){this.editor.commands.add("imageTextAlternative",new yp(this.editor))}}class Pp extends Vd{constructor(e){super(e);const t=this.locale.t;this.focusTracker=new Ea,this.keystrokes=new Pa,this.labeledInput=this._createLabeledInputView(),this.saveButtonView=this._createButton(t("Save"),Ed.check,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(t("Cancel"),Ed.cancel,"ck-button-cancel","cancel"),this._focusables=new Rd,this._focusCycler=new cu({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"form",attributes:{class:["ck","ck-text-alternative-form","ck-responsive-form"],tabindex:"-1"},children:[this.labeledInput,this.saveButtonView,this.cancelButtonView]}),Sd(this)}render(){super.render(),this.keystrokes.listenTo(this.element),Id({view:this}),[this.labeledInput,this.saveButtonView,this.cancelButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)}))}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}_createButton(e,t,i,n){const s=new iu(this.locale);return s.set({label:e,icon:t,tooltip:!0}),s.extendTemplate({attributes:{class:i}}),n&&s.delegate("execute").to(this,n),s}_createLabeledInputView(){const e=this.locale.t,t=new ju(this.locale,Wu);return t.label=e("Text alternative"),t}}function Sp(e){const t=e.editing.view,i=Qu.defaultPositions,n=e.plugins.get("ImageUtils");return{target:t.domConverter.viewToDom(n.getClosestSelectedImageWidget(t.document.selection)),positions:[i.northArrowSouth,i.northArrowSouthWest,i.northArrowSouthEast,i.southArrowNorth,i.southArrowNorthWest,i.southArrowNorthEast,i.viewportStickyNorth]}}class Ip extends ut{static get requires(){return[eh]}static get pluginName(){return"ImageTextAlternativeUI"}init(){this._createButton(),this._createForm()}destroy(){super.destroy(),this._form.destroy()}_createButton(){const e=this.editor,t=e.t;e.ui.componentFactory.add("imageTextAlternative",(i=>{const n=e.commands.get("imageTextAlternative"),s=new iu(i);return s.set({label:t("Change image text alternative"),icon:Ed.lowVision,tooltip:!0}),s.bind("isEnabled").to(n,"isEnabled"),this.listenTo(s,"execute",(()=>{this._showForm()})),s}))}_createForm(){const e=this.editor,t=e.editing.view.document,i=e.plugins.get("ImageUtils");this._balloon=this.editor.plugins.get("ContextualBalloon"),this._form=new Pp(e.locale),this._form.render(),this.listenTo(this._form,"submit",(()=>{e.execute("imageTextAlternative",{newValue:this._form.labeledInput.fieldView.element.value}),this._hideForm(!0)})),this.listenTo(this._form,"cancel",(()=>{this._hideForm(!0)})),this._form.keystrokes.set("Esc",((e,t)=>{this._hideForm(!0),t()})),this.listenTo(e.ui,"update",(()=>{i.getClosestSelectedImageWidget(t.selection)?this._isVisible&&function(e){const t=e.plugins.get("ContextualBalloon");if(e.plugins.get("ImageUtils").getClosestSelectedImageWidget(e.editing.view.document.selection)){const i=Sp(e);t.updatePosition(i)}}(e):this._hideForm(!0)})),Pd({emitter:this._form,activator:()=>this._isVisible,contextElements:[this._balloon.view.element],callback:()=>this._hideForm()})}_showForm(){if(this._isVisible)return;const e=this.editor,t=e.commands.get("imageTextAlternative"),i=this._form.labeledInput;this._form.disableCssTransitions(),this._isInBalloon||this._balloon.add({view:this._form,position:Sp(e)}),i.fieldView.value=i.fieldView.element.value=t.value||"",this._form.labeledInput.fieldView.select(),this._form.enableCssTransitions()}_hideForm(e){this._isInBalloon&&(this._form.focusTracker.isFocused&&this._form.saveButtonView.focus(),this._balloon.remove(this._form),e&&this.editor.editing.view.focus())}get _isVisible(){return this._balloon.visibleView===this._form}get _isInBalloon(){return this._balloon.hasView(this._form)}}class Rp extends ut{static get requires(){return[Ep,Ip]}static get pluginName(){return"ImageTextAlternative"}}function Vp(e,t){return e=>{e.on(`attribute:srcset:${t}`,i)};function i(t,i,n){if(!n.consumable.consume(i.item,t.name))return;const s=n.writer,o=n.mapper.toViewElement(i.item),r=e.findViewImgElement(o);if(null===i.attributeNewValue){const e=i.attributeOldValue;e.data&&(s.removeAttribute("srcset",r),s.removeAttribute("sizes",r),e.width&&s.removeAttribute("width",r))}else{const e=i.attributeNewValue;e.data&&(s.setAttribute("srcset",e.data,r),s.setAttribute("sizes","100vw",r),e.width&&s.setAttribute("width",e.width,r))}}}function Op(e,t,i){return e=>{e.on(`attribute:${i}:${t}`,n)};function n(t,i,n){if(!n.consumable.consume(i.item,t.name))return;const s=n.writer,o=n.mapper.toViewElement(i.item),r=e.findViewImgElement(o);s.setAttribute(i.attributeKey,i.attributeNewValue||"",r)}}class Bp extends fr{observe(e){this.listenTo(e,"load",((e,t)=>{const i=t.target;this.checkShouldIgnoreEventFromTarget(i)||"IMG"==i.tagName&&this._fireEvents(t)}),{useCapture:!0})}_fireEvents(e){this.isEnabled&&(this.document.fire("layoutChanged"),this.document.fire("imageLoaded",e))}}class Mp extends mt{constructor(e){super(e);const t=e.config.get("image.insert.type");e.plugins.has("ImageBlockEditing")||"block"===t&&c("image-block-plugin-required"),e.plugins.has("ImageInlineEditing")||"inline"===t&&c("image-inline-plugin-required")}refresh(){this.isEnabled=this.editor.plugins.get("ImageUtils").isImageAllowed()}execute(e){const t=Pn(e.source),i=this.editor.model.document.selection,n=this.editor.plugins.get("ImageUtils"),s=Object.fromEntries(i.getAttributes());t.forEach(((e,t)=>{const o=i.getSelectedElement();if("string"==typeof e&&(e={src:e}),t&&o&&n.isImage(o)){const t=this.editor.model.createPositionAfter(o);n.insertImage({...e,...s},t)}else n.insertImage({...e,...s})}))}}class Np extends ut{static get requires(){return[xp]}static get pluginName(){return"ImageEditing"}init(){const e=this.editor,t=e.conversion;e.editing.view.addObserver(Bp),t.for("upcast").attributeToAttribute({view:{name:"img",key:"alt"},model:"alt"}).attributeToAttribute({view:{name:"img",key:"srcset"},model:{key:"srcset",value:e=>{const t={data:e.getAttribute("srcset")};return e.hasAttribute("width")&&(t.width=e.getAttribute("width")),t}}});const i=new Mp(e);e.commands.add("insertImage",i),e.commands.add("imageInsert",i)}}class Dp extends mt{constructor(e,t){super(e),this._modelElementName=t}refresh(){const e=this.editor.plugins.get("ImageUtils"),t=e.getClosestSelectedImageElement(this.editor.model.document.selection);"imageBlock"===this._modelElementName?this.isEnabled=e.isInlineImage(t):this.isEnabled=e.isBlockImage(t)}execute(){const e=this.editor,t=this.editor.model,i=e.plugins.get("ImageUtils"),n=i.getClosestSelectedImageElement(t.document.selection),s=Object.fromEntries(n.getAttributes());return s.src||s.uploadId?t.change((e=>{const o=Array.from(t.markers).filter((e=>e.getRange().containsItem(n))),r=i.insertImage(s,t.createSelection(n,"on"),this._modelElementName);if(!r)return null;const a=e.createRangeOn(r);for(const t of o){const i=t.getRange(),n="$graveyard"!=i.root.rootName?i.getJoined(a,!0):a;e.updateMarker(t,{range:n})}return{oldElement:n,newElement:r}})):null}}class zp extends ut{static get requires(){return[Np,xp,Rg]}static get pluginName(){return"ImageBlockEditing"}init(){const e=this.editor;e.model.schema.register("imageBlock",{inheritAllFrom:"$blockObject",allowAttributes:["alt","src","srcset"]}),this._setupConversion(),e.plugins.has("ImageInlineEditing")&&(e.commands.add("imageTypeBlock",new Dp(this.editor,"imageBlock")),this._setupClipboardIntegration())}_setupConversion(){const e=this.editor,t=e.t,i=e.conversion,n=e.plugins.get("ImageUtils");i.for("dataDowncast").elementToStructure({model:"imageBlock",view:(e,{writer:t})=>kp(t)}),i.for("editingDowncast").elementToStructure({model:"imageBlock",view:(e,{writer:i})=>n.toImageWidget(kp(i),i,t("image widget"))}),i.for("downcast").add(Op(n,"imageBlock","src")).add(Op(n,"imageBlock","alt")).add(Vp(n,"imageBlock")),i.for("upcast").elementToElement({view:Cp(e,"imageBlock"),model:(e,{writer:t})=>t.createElement("imageBlock",e.hasAttribute("src")?{src:e.getAttribute("src")}:null)}).add(function(e){return e=>{e.on("element:figure",t)};function t(t,i,n){if(!n.consumable.test(i.viewItem,{name:!0,classes:"image"}))return;const s=e.findViewImgElement(i.viewItem);if(!s||!n.consumable.test(s,{name:!0}))return;n.consumable.consume(i.viewItem,{name:!0,classes:"image"});const o=Ta(n.convertItem(s,i.modelCursor).modelRange.getItems());o?(n.convertChildren(i.viewItem,o),n.updateConversionResult(o,i)):n.consumable.revert(i.viewItem,{name:!0,classes:"image"})}}(n))}_setupClipboardIntegration(){const e=this.editor,t=e.model,i=e.editing.view,n=e.plugins.get("ImageUtils");this.listenTo(e.plugins.get("ClipboardPipeline"),"inputTransformation",((s,o)=>{const r=Array.from(o.content.getChildren());let a;if(!r.every(n.isInlineImageView))return;a=o.targetRanges?e.editing.mapper.toModelRange(o.targetRanges[0]):t.document.selection.getFirstRange();const l=t.createSelection(a);if("imageBlock"===Ap(t.schema,l)){const e=new Ah(i.document),t=r.map((t=>e.createElement("figure",{class:"image"},t)));o.content=e.createDocumentFragment(t)}}))}}class Lp extends ut{static get requires(){return[zp,sf,Rp]}static get pluginName(){return"ImageBlock"}}class Fp extends ut{static get requires(){return[Np,xp,Rg]}static get pluginName(){return"ImageInlineEditing"}init(){const e=this.editor,t=e.model.schema;t.register("imageInline",{inheritAllFrom:"$inlineObject",allowAttributes:["alt","src","srcset"]}),t.addChildCheck(((e,t)=>{if(e.endsWith("caption")&&"imageInline"===t.name)return!1})),this._setupConversion(),e.plugins.has("ImageBlockEditing")&&(e.commands.add("imageTypeInline",new Dp(this.editor,"imageInline")),this._setupClipboardIntegration())}_setupConversion(){const e=this.editor,t=e.t,i=e.conversion,n=e.plugins.get("ImageUtils");i.for("dataDowncast").elementToElement({model:"imageInline",view:(e,{writer:t})=>t.createEmptyElement("img")}),i.for("editingDowncast").elementToStructure({model:"imageInline",view:(e,{writer:i})=>n.toImageWidget(function(e){return e.createContainerElement("span",{class:"image-inline"},e.createEmptyElement("img"))}(i),i,t("image widget"))}),i.for("downcast").add(Op(n,"imageInline","src")).add(Op(n,"imageInline","alt")).add(Vp(n,"imageInline")),i.for("upcast").elementToElement({view:Cp(e,"imageInline"),model:(e,{writer:t})=>t.createElement("imageInline",e.hasAttribute("src")?{src:e.getAttribute("src")}:null)})}_setupClipboardIntegration(){const e=this.editor,t=e.model,i=e.editing.view,n=e.plugins.get("ImageUtils");this.listenTo(e.plugins.get("ClipboardPipeline"),"inputTransformation",((s,o)=>{const r=Array.from(o.content.getChildren());let a;if(!r.every(n.isBlockImageView))return;a=o.targetRanges?e.editing.mapper.toModelRange(o.targetRanges[0]):t.document.selection.getFirstRange();const l=t.createSelection(a);if("imageInline"===Ap(t.schema,l)){const e=new Ah(i.document),t=r.map((t=>1===t.childCount?(Array.from(t.getAttributes()).forEach((i=>e.setAttribute(...i,n.findViewImgElement(t)))),t.getChild(0)):t));o.content=e.createDocumentFragment(t)}}))}}class Hp extends ut{static get requires(){return[Fp,sf,Rp]}static get pluginName(){return"ImageInline"}}class jp extends mt{refresh(){const e=this.editor,t=e.plugins.get("ImageUtils").getClosestSelectedImageElement(e.model.document.selection);this.isEnabled=!!t,t&&t.hasAttribute("width")?this.value={width:t.getAttribute("width"),height:null}:this.value=null}execute(e){const t=this.editor,i=t.model,n=t.plugins.get("ImageUtils").getClosestSelectedImageElement(i.document.selection);this.value={width:e.width,height:null},n&&i.change((t=>{t.setAttribute("width",e.width,n)}))}}class Wp extends ut{static get requires(){return[xp]}static get pluginName(){return"ImageResizeEditing"}constructor(e){super(e),e.config.define("image",{resizeUnit:"%",resizeOptions:[{name:"resizeImage:original",value:null,icon:"original"},{name:"resizeImage:25",value:"25",icon:"small"},{name:"resizeImage:50",value:"50",icon:"medium"},{name:"resizeImage:75",value:"75",icon:"large"}]})}init(){const e=this.editor,t=new jp(e);this._registerSchema(),this._registerConverters("imageBlock"),this._registerConverters("imageInline"),e.commands.add("resizeImage",t),e.commands.add("imageResize",t)}_registerSchema(){this.editor.plugins.has("ImageBlockEditing")&&this.editor.model.schema.extend("imageBlock",{allowAttributes:"width"}),this.editor.plugins.has("ImageInlineEditing")&&this.editor.model.schema.extend("imageInline",{allowAttributes:"width"})}_registerConverters(e){const t=this.editor;t.conversion.for("downcast").add((t=>t.on(`attribute:width:${e}`,((e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const n=i.writer,s=i.mapper.toViewElement(t.item);null!==t.attributeNewValue?(n.setStyle("width",t.attributeNewValue,s),n.addClass("image_resized",s)):(n.removeStyle("width",s),n.removeClass("image_resized",s))})))),t.conversion.for("upcast").attributeToAttribute({view:{name:"imageBlock"===e?"figure":"img",styles:{width:/.+/}},model:{key:"width",value:e=>e.getStyle("width")}})}}const Up={small:Ed.objectSizeSmall,medium:Ed.objectSizeMedium,large:Ed.objectSizeLarge,original:Ed.objectSizeFull};class qp extends ut{static get requires(){return[Wp]}static get pluginName(){return"ImageResizeButtons"}constructor(e){super(e),this._resizeUnit=e.config.get("image.resizeUnit")}init(){const e=this.editor,t=e.config.get("image.resizeOptions"),i=e.commands.get("resizeImage");this.bind("isEnabled").to(i);for(const e of t)this._registerImageResizeButton(e);this._registerImageResizeDropdown(t)}_registerImageResizeButton(e){const t=this.editor,{name:i,value:n,icon:s}=e,o=n?n+this._resizeUnit:null;t.ui.componentFactory.add(i,(i=>{const n=new iu(i),r=t.commands.get("resizeImage"),a=this._getOptionLabelValue(e,!0);if(!Up[s])throw new l("imageresizebuttons-missing-icon",t,e);return n.set({label:a,icon:Up[s],tooltip:a,isToggleable:!0}),n.bind("isEnabled").to(this),n.bind("isOn").to(r,"value",$p(o)),this.listenTo(n,"execute",(()=>{t.execute("resizeImage",{width:o})})),n}))}_registerImageResizeDropdown(e){const t=this.editor,i=t.t,n=e.find((e=>!e.value)),s=s=>{const o=t.commands.get("resizeImage"),r=Iu(s,mu),a=r.buttonView;return a.set({tooltip:i("Resize image"),commandValue:n.value,icon:Up.medium,isToggleable:!0,label:this._getOptionLabelValue(n),withText:!0,class:"ck-resize-image-button"}),a.bind("label").to(o,"value",(e=>e&&e.width?e.width:this._getOptionLabelValue(n))),r.bind("isOn").to(o),r.bind("isEnabled").to(this),Vu(r,this._getResizeDropdownListItemDefinitions(e,o)),r.listView.ariaLabel=i("Image resize list"),this.listenTo(r,"execute",(e=>{t.execute(e.source.commandName,{width:e.source.commandValue}),t.editing.view.focus()})),r};t.ui.componentFactory.add("resizeImage",s),t.ui.componentFactory.add("imageResize",s)}_getOptionLabelValue(e,t){const i=this.editor.t;return e.label?e.label:t?e.value?i("Resize image to %0",e.value+this._resizeUnit):i("Resize image to the original size"):e.value?e.value+this._resizeUnit:i("Original")}_getResizeDropdownListItemDefinitions(e,t){const i=new Tn;return e.map((e=>{const n=e.value?e.value+this._resizeUnit:null,s={type:"button",model:new Ku({commandName:"resizeImage",commandValue:n,label:this._getOptionLabelValue(e),withText:!0,icon:null})};s.model.bind("isOn").to(t,"value",$p(n)),i.add(s)})),i}}function $p(e){return t=>null===e&&t===e||t&&t.width===e}const Kp=/(image|image-inline)/,Gp="image_resized";class Jp extends ut{static get requires(){return[wp]}static get pluginName(){return"ImageResizeHandles"}init(){const e=this.editor.commands.get("resizeImage");this.bind("isEnabled").to(e),this._setupResizerCreator()}_setupResizerCreator(){const e=this.editor,t=e.editing.view;t.addObserver(Bp),this.listenTo(t.document,"imageLoaded",((i,n)=>{if(!n.target.matches("figure.image.ck-widget > img,figure.image.ck-widget > picture > img,figure.image.ck-widget > a > img,figure.image.ck-widget > a > picture > img,span.image-inline.ck-widget > img,span.image-inline.ck-widget > picture > img"))return;const s=e.editing.view.domConverter,o=s.domToView(n.target).findAncestor({classes:Kp});let r=this.editor.plugins.get(wp).getResizerByViewElement(o);if(r)return void r.redraw();const a=e.editing.mapper,l=a.toModelElement(o);r=e.plugins.get(wp).attachTo({unit:e.config.get("image.resizeUnit"),modelElement:l,viewElement:o,editor:e,getHandleHost:e=>e.querySelector("img"),getResizeHost:()=>s.viewToDom(a.toViewElement(l.parent)),isCentered(){const e=l.getAttribute("imageStyle");return!e||"block"==e||"alignCenter"==e},onCommit(i){t.change((e=>{e.removeClass(Gp,o)})),e.execute("resizeImage",{width:i})}}),r.on("updateSize",(()=>{o.hasClass(Gp)||t.change((e=>{e.addClass(Gp,o)}))})),r.bind("isEnabled").to(this)}))}}class Yp extends mt{constructor(e,t){super(e),this._defaultStyles={imageBlock:!1,imageInline:!1},this._styles=new Map(t.map((e=>{if(e.isDefault)for(const t of e.modelElements)this._defaultStyles[t]=e.name;return[e.name,e]})))}refresh(){const e=this.editor.plugins.get("ImageUtils").getClosestSelectedImageElement(this.editor.model.document.selection);this.isEnabled=!!e,this.isEnabled?e.hasAttribute("imageStyle")?this.value=e.getAttribute("imageStyle"):this.value=this._defaultStyles[e.name]:this.value=!1}execute(e={}){const t=this.editor,i=t.model,n=t.plugins.get("ImageUtils");i.change((t=>{const s=e.value;let o=n.getClosestSelectedImageElement(i.document.selection);s&&this.shouldConvertImageType(s,o)&&(this.editor.execute(n.isBlockImage(o)?"imageTypeInline":"imageTypeBlock"),o=n.getClosestSelectedImageElement(i.document.selection)),!s||this._styles.get(s).isDefault?t.removeAttribute("imageStyle",o):t.setAttribute("imageStyle",s,o)}))}shouldConvertImageType(e,t){return!this._styles.get(e).modelElements.includes(t.name)}}const{objectFullWidth:Qp,objectInline:Zp,objectLeft:Xp,objectRight:ew,objectCenter:tw,objectBlockLeft:iw,objectBlockRight:nw}=Ed,sw={get inline(){return{name:"inline",title:"In line",icon:Zp,modelElements:["imageInline"],isDefault:!0}},get alignLeft(){return{name:"alignLeft",title:"Left aligned image",icon:Xp,modelElements:["imageBlock","imageInline"],className:"image-style-align-left"}},get alignBlockLeft(){return{name:"alignBlockLeft",title:"Left aligned image",icon:iw,modelElements:["imageBlock"],className:"image-style-block-align-left"}},get alignCenter(){return{name:"alignCenter",title:"Centered image",icon:tw,modelElements:["imageBlock"],className:"image-style-align-center"}},get alignRight(){return{name:"alignRight",title:"Right aligned image",icon:ew,modelElements:["imageBlock","imageInline"],className:"image-style-align-right"}},get alignBlockRight(){return{name:"alignBlockRight",title:"Right aligned image",icon:nw,modelElements:["imageBlock"],className:"image-style-block-align-right"}},get block(){return{name:"block",title:"Centered image",icon:tw,modelElements:["imageBlock"],isDefault:!0}},get side(){return{name:"side",title:"Side image",icon:ew,modelElements:["imageBlock"],className:"image-style-side"}}},ow={full:Qp,left:iw,right:nw,center:tw,inlineLeft:Xp,inlineRight:ew,inline:Zp},rw=[{name:"imageStyle:wrapText",title:"Wrap text",defaultItem:"imageStyle:alignLeft",items:["imageStyle:alignLeft","imageStyle:alignRight"]},{name:"imageStyle:breakText",title:"Break text",defaultItem:"imageStyle:block",items:["imageStyle:alignBlockLeft","imageStyle:block","imageStyle:alignBlockRight"]}];function aw(e){c("image-style-configuration-definition-invalid",e)}const lw={normalizeStyles:function(e){return(e.configuredStyles.options||[]).map((e=>function(e){e="string"==typeof e?sw[e]?{...sw[e]}:{name:e}:function(e,t){const i={...t};for(const n in e)Object.prototype.hasOwnProperty.call(t,n)||(i[n]=e[n]);return i}(sw[e.name],e);"string"==typeof e.icon&&(e.icon=ow[e.icon]||e.icon);return e}(e))).filter((t=>function(e,{isBlockPluginLoaded:t,isInlinePluginLoaded:i}){const{modelElements:n,name:s}=e;if(!(n&&n.length&&s))return aw({style:e}),!1;{const s=[t?"imageBlock":null,i?"imageInline":null];if(!n.some((e=>s.includes(e))))return c("image-style-missing-dependency",{style:e,missingPlugins:n.map((e=>"imageBlock"===e?"ImageBlockEditing":"ImageInlineEditing"))}),!1}return!0}(t,e)))},getDefaultStylesConfiguration:function(e,t){return e&&t?{options:["inline","alignLeft","alignRight","alignCenter","alignBlockLeft","alignBlockRight","block","side"]}:e?{options:["block","side"]}:t?{options:["inline","alignLeft","alignRight"]}:{}},getDefaultDropdownDefinitions:function(e){return e.has("ImageBlockEditing")&&e.has("ImageInlineEditing")?[...rw]:[]},warnInvalidStyle:aw,DEFAULT_OPTIONS:sw,DEFAULT_ICONS:ow,DEFAULT_DROPDOWN_DEFINITIONS:rw};function cw(e,t){for(const i of t)if(i.name===e)return i}class dw extends ut{static get pluginName(){return"ImageStyleEditing"}static get requires(){return[xp]}init(){const{normalizeStyles:e,getDefaultStylesConfiguration:t}=lw,i=this.editor,n=i.plugins.has("ImageBlockEditing"),s=i.plugins.has("ImageInlineEditing");i.config.define("image.styles",t(n,s)),this.normalizedStyles=e({configuredStyles:i.config.get("image.styles"),isBlockPluginLoaded:n,isInlinePluginLoaded:s}),this._setupConversion(n,s),this._setupPostFixer(),i.commands.add("imageStyle",new Yp(i,this.normalizedStyles))}_setupConversion(e,t){const i=this.editor,n=i.model.schema,s=(o=this.normalizedStyles,(e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const n=cw(t.attributeNewValue,o),s=cw(t.attributeOldValue,o),r=i.mapper.toViewElement(t.item),a=i.writer;s&&a.removeClass(s.className,r),n&&a.addClass(n.className,r)});var o;const r=function(e){const t={imageInline:e.filter((e=>!e.isDefault&&e.modelElements.includes("imageInline"))),imageBlock:e.filter((e=>!e.isDefault&&e.modelElements.includes("imageBlock")))};return(e,i,n)=>{if(!i.modelRange)return;const s=i.viewItem,o=Ta(i.modelRange.getItems());if(o&&n.schema.checkAttribute(o,"imageStyle"))for(const e of t[o.name])n.consumable.consume(s,{classes:e.className})&&n.writer.setAttribute("imageStyle",e.name,o)}}(this.normalizedStyles);i.editing.downcastDispatcher.on("attribute:imageStyle",s),i.data.downcastDispatcher.on("attribute:imageStyle",s),e&&(n.extend("imageBlock",{allowAttributes:"imageStyle"}),i.data.upcastDispatcher.on("element:figure",r,{priority:"low"})),t&&(n.extend("imageInline",{allowAttributes:"imageStyle"}),i.data.upcastDispatcher.on("element:img",r,{priority:"low"}))}_setupPostFixer(){const e=this.editor,t=e.model.document,i=e.plugins.get(xp),n=new Map(this.normalizedStyles.map((e=>[e.name,e])));t.registerPostFixer((e=>{let s=!1;for(const o of t.differ.getChanges())if("insert"==o.type||"attribute"==o.type&&"imageStyle"==o.attributeKey){let t="insert"==o.type?o.position.nodeAfter:o.range.start.nodeAfter;if(t&&t.is("element","paragraph")&&t.childCount>0&&(t=t.getChild(0)),!i.isImage(t))continue;const r=t.getAttribute("imageStyle");if(!r)continue;const a=n.get(r);a&&a.modelElements.includes(t.name)||(e.removeAttribute("imageStyle",t),s=!0)}return s}))}}class uw extends ut{static get requires(){return[dw]}static get pluginName(){return"ImageStyleUI"}get localizedDefaultStylesTitles(){const e=this.editor.t;return{"Wrap text":e("Wrap text"),"Break text":e("Break text"),"In line":e("In line"),"Full size image":e("Full size image"),"Side image":e("Side image"),"Left aligned image":e("Left aligned image"),"Centered image":e("Centered image"),"Right aligned image":e("Right aligned image")}}init(){const e=this.editor.plugins,t=this.editor.config.get("image.toolbar")||[],i=hw(e.get("ImageStyleEditing").normalizedStyles,this.localizedDefaultStylesTitles);for(const e of i)this._createButton(e);const n=hw([...t.filter(A),...lw.getDefaultDropdownDefinitions(e)],this.localizedDefaultStylesTitles);for(const e of n)this._createDropdown(e,i)}_createDropdown(e,t){const i=this.editor.ui.componentFactory;i.add(e.name,(n=>{let s;const{defaultItem:o,items:r,title:a}=e,l=r.filter((e=>t.find((({name:t})=>mw(t)===e)))).map((e=>{const t=i.create(e);return e===o&&(s=t),t}));r.length!==l.length&&lw.warnInvalidStyle({dropdown:e});const c=Iu(n,gu),d=c.buttonView;return Ru(c,l),d.set({label:gw(a,s.label),class:null,tooltip:!0}),d.bind("icon").toMany(l,"isOn",((...e)=>{const t=e.findIndex(oe);return t<0?s.icon:l[t].icon})),d.bind("label").toMany(l,"isOn",((...e)=>{const t=e.findIndex(oe);return gw(a,t<0?s.label:l[t].label)})),d.bind("isOn").toMany(l,"isOn",((...e)=>e.some(oe))),d.bind("class").toMany(l,"isOn",((...e)=>e.some(oe)?"ck-splitbutton_flatten":null)),d.on("execute",(()=>{l.some((({isOn:e})=>e))?c.isOpen=!c.isOpen:s.fire("execute")})),c.bind("isEnabled").toMany(l,"isEnabled",((...e)=>e.some(oe))),c}))}_createButton(e){const t=e.name;this.editor.ui.componentFactory.add(mw(t),(i=>{const n=this.editor.commands.get("imageStyle"),s=new iu(i);return s.set({label:e.title,icon:e.icon,tooltip:!0,isToggleable:!0}),s.bind("isEnabled").to(n,"isEnabled"),s.bind("isOn").to(n,"value",(e=>e===t)),s.on("execute",this._executeCommand.bind(this,t)),s}))}_executeCommand(e){this.editor.execute("imageStyle",{value:e}),this.editor.editing.view.focus()}}function hw(e,t){for(const i of e)t[i.title]&&(i.title=t[i.title]);return e}function mw(e){return`imageStyle:${e}`}function gw(e,t){return(e?e+": ":"")+t}class fw{constructor(){const e=new window.FileReader;this._reader=e,this._data=void 0,this.set("loaded",0),e.onprogress=e=>{this.loaded=e.loaded}}get error(){return this._reader.error}get data(){return this._data}read(e){const t=this._reader;return this.total=e.size,new Promise(((i,n)=>{t.onload=()=>{const e=t.result;this._data=e,i(e)},t.onerror=()=>{n("error")},t.onabort=()=>{n("aborted")},this._reader.readAsDataURL(e)}))}abort(){this._reader.abort()}}dt(fw,st);class pw extends ut{static get pluginName(){return"FileRepository"}static get requires(){return[Ad]}init(){this.loaders=new Tn,this.loaders.on("add",(()=>this._updatePendingAction())),this.loaders.on("remove",(()=>this._updatePendingAction())),this._loadersMap=new Map,this._pendingAction=null,this.set("uploaded",0),this.set("uploadTotal",null),this.bind("uploadedPercent").to(this,"uploaded",this,"uploadTotal",((e,t)=>t?e/t*100:0))}getLoader(e){return this._loadersMap.get(e)||null}createLoader(e){if(!this.createUploadAdapter)return c("filerepository-no-upload-adapter"),null;const t=new ww(Promise.resolve(e),this.createUploadAdapter);return this.loaders.add(t),this._loadersMap.set(e,t),e instanceof Promise&&t.file.then((e=>{this._loadersMap.set(e,t)})).catch((()=>{})),t.on("change:uploaded",(()=>{let e=0;for(const t of this.loaders)e+=t.uploaded;this.uploaded=e})),t.on("change:uploadTotal",(()=>{let e=0;for(const t of this.loaders)t.uploadTotal&&(e+=t.uploadTotal);this.uploadTotal=e})),t}destroyLoader(e){const t=e instanceof ww?e:this.getLoader(e);t._destroy(),this.loaders.remove(t),this._loadersMap.forEach(((e,i)=>{e===t&&this._loadersMap.delete(i)}))}_updatePendingAction(){const e=this.editor.plugins.get(Ad);if(this.loaders.length){if(!this._pendingAction){const t=this.editor.t,i=e=>`${t("Upload in progress")} ${parseInt(e)}%.`;this._pendingAction=e.add(i(this.uploadedPercent)),this._pendingAction.bind("message").to(this,"uploadedPercent",i)}}else e.remove(this._pendingAction),this._pendingAction=null}}dt(pw,st);class ww{constructor(e,t){this.id=o(),this._filePromiseWrapper=this._createFilePromiseWrapper(e),this._adapter=t(this),this._reader=new fw,this.set("status","idle"),this.set("uploaded",0),this.set("uploadTotal",null),this.bind("uploadedPercent").to(this,"uploaded",this,"uploadTotal",((e,t)=>t?e/t*100:0)),this.set("uploadResponse",null)}get file(){return this._filePromiseWrapper?this._filePromiseWrapper.promise.then((e=>this._filePromiseWrapper?e:null)):Promise.resolve(null)}get data(){return this._reader.data}read(){if("idle"!=this.status)throw new l("filerepository-read-wrong-status",this);return this.status="reading",this.file.then((e=>this._reader.read(e))).then((e=>{if("reading"!==this.status)throw this.status;return this.status="idle",e})).catch((e=>{if("aborted"===e)throw this.status="aborted","aborted";throw this.status="error",this._reader.error?this._reader.error:e}))}upload(){if("idle"!=this.status)throw new l("filerepository-upload-wrong-status",this);return this.status="uploading",this.file.then((()=>this._adapter.upload())).then((e=>(this.uploadResponse=e,this.status="idle",e))).catch((e=>{if("aborted"===this.status)throw"aborted";throw this.status="error",e}))}abort(){const e=this.status;this.status="aborted",this._filePromiseWrapper.isFulfilled?"reading"==e?this._reader.abort():"uploading"==e&&this._adapter.abort&&this._adapter.abort():(this._filePromiseWrapper.promise.catch((()=>{})),this._filePromiseWrapper.rejecter("aborted")),this._destroy()}_destroy(){this._filePromiseWrapper=void 0,this._reader=void 0,this._adapter=void 0,this.uploadResponse=void 0}_createFilePromiseWrapper(e){const t={};return t.promise=new Promise(((i,n)=>{t.rejecter=n,t.isFulfilled=!1,e.then((e=>{t.isFulfilled=!0,i(e)})).catch((e=>{t.isFulfilled=!0,n(e)}))})),t}}dt(ww,st);class bw extends Vd{constructor(e){super(e),this.buttonView=new iu(e),this._fileInputView=new vw(e),this._fileInputView.bind("acceptedType").to(this),this._fileInputView.bind("allowMultipleFiles").to(this),this._fileInputView.delegate("done").to(this),this.setTemplate({tag:"span",attributes:{class:"ck-file-dialog-button"},children:[this.buttonView,this._fileInputView]}),this.buttonView.on("execute",(()=>{this._fileInputView.open()}))}focus(){this.buttonView.focus()}}class vw extends Vd{constructor(e){super(e),this.set("acceptedType"),this.set("allowMultipleFiles",!1);const t=this.bindTemplate;this.setTemplate({tag:"input",attributes:{class:["ck-hidden"],type:"file",tabindex:"-1",accept:t.to("acceptedType"),multiple:t.to("allowMultipleFiles")},on:{change:t.to((()=>{this.element&&this.element.files&&this.element.files.length&&this.fire("done",this.element.files),this.element.value=""}))}})}open(){this.element.click()}}class _w{constructor(e,t){this.loader=e,this.options=t}upload(){return this.loader.file.then((e=>new Promise(((t,i)=>{this._initRequest(),this._initListeners(t,i,e),this._sendRequest(e)}))))}abort(){this.xhr&&this.xhr.abort()}_initRequest(){const e=this.xhr=new XMLHttpRequest;e.open("POST",this.options.uploadUrl,!0),e.responseType="json"}_initListeners(e,t,i){const n=this.xhr,s=this.loader,o=`Couldn't upload file: ${i.name}.`;n.addEventListener("error",(()=>t(o))),n.addEventListener("abort",(()=>t())),n.addEventListener("load",(()=>{const i=n.response;if(!i||i.error)return t(i&&i.error&&i.error.message?i.error.message:o);const s=i.url?{default:i.url}:i.urls;e({...i,urls:s})})),n.upload&&n.upload.addEventListener("progress",(e=>{e.lengthComputable&&(s.uploadTotal=e.total,s.uploaded=e.loaded)}))}_sendRequest(e){const t=this.options.headers||{},i=this.options.withCredentials||!1;for(const e of Object.keys(t))this.xhr.setRequestHeader(e,t[e]);this.xhr.withCredentials=i;const n=new FormData;n.append("upload",e),this.xhr.send(n)}}function yw(e){const t=e.map((e=>e.replace("+","\\+")));return new RegExp(`^image\\/(${t.join("|")})$`)}function kw(e){return new Promise(((t,i)=>{const n=e.getAttribute("src");fetch(n).then((e=>e.blob())).then((e=>{const i=Cw(e,n),s=i.replace("image/",""),o=new File([e],`image.${s}`,{type:i});t(o)})).catch((e=>e&&"TypeError"===e.name?function(e){return function(e){return new Promise(((t,i)=>{const n=Zo.document.createElement("img");n.addEventListener("load",(()=>{const e=Zo.document.createElement("canvas");e.width=n.width,e.height=n.height;e.getContext("2d").drawImage(n,0,0),e.toBlob((e=>e?t(e):i()))})),n.addEventListener("error",(()=>i())),n.src=e}))}(e).then((t=>{const i=Cw(t,e),n=i.replace("image/","");return new File([t],`image.${n}`,{type:i})}))}(n).then(t).catch(i):i(e)))}))}function Cw(e,t){return e.type?e.type:t.match(/data:(image\/\w+);base64/)?t.match(/data:(image\/\w+);base64/)[1].toLowerCase():"image/jpeg"}class Aw extends ut{static get pluginName(){return"ImageUploadUI"}init(){const e=this.editor,t=e.t,i=i=>{const n=new bw(i),s=e.commands.get("uploadImage"),o=e.config.get("image.upload.types"),r=yw(o);return n.set({acceptedType:o.map((e=>`image/${e}`)).join(","),allowMultipleFiles:!0}),n.buttonView.set({label:t("Insert image"),icon:Ed.image,tooltip:!0}),n.buttonView.bind("isEnabled").to(s),n.on("done",((t,i)=>{const n=Array.from(i).filter((e=>r.test(e.type)));n.length&&e.execute("uploadImage",{file:n})})),n};e.ui.componentFactory.add("uploadImage",i),e.ui.componentFactory.add("imageUpload",i)}}class xw extends ut{static get pluginName(){return"ImageUploadProgress"}constructor(e){super(e),this.placeholder="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="}init(){const e=this.editor;e.plugins.has("ImageBlockEditing")&&e.editing.downcastDispatcher.on("attribute:uploadStatus:imageBlock",((...e)=>this.uploadStatusChange(...e))),e.plugins.has("ImageInlineEditing")&&e.editing.downcastDispatcher.on("attribute:uploadStatus:imageInline",((...e)=>this.uploadStatusChange(...e)))}uploadStatusChange(e,t,i){const n=this.editor,s=t.item,o=s.getAttribute("uploadId");if(!i.consumable.consume(t.item,e.name))return;const r=n.plugins.get("ImageUtils"),a=n.plugins.get(pw),l=o?t.attributeNewValue:null,c=this.placeholder,d=n.editing.mapper.toViewElement(s),u=i.writer;if("reading"==l)return Tw(d,u),void Ew(r,c,d,u);if("uploading"==l){const e=a.loaders.get(o);return Tw(d,u),void(e?(Pw(d,u),function(e,t,i,n){const s=function(e){const t=e.createUIElement("div",{class:"ck-progress-bar"});return e.setCustomProperty("progressBar",!0,t),t}(t);t.insert(t.createPositionAt(e,"end"),s),i.on("change:uploadedPercent",((e,t,i)=>{n.change((e=>{e.setStyle("width",i+"%",s)}))}))}(d,u,e,n.editing.view),function(e,t,i,n){if(n.data){const s=e.findViewImgElement(t);i.setAttribute("src",n.data,s)}}(r,d,u,e)):Ew(r,c,d,u))}"complete"==l&&a.loaders.get(o)&&function(e,t,i){const n=t.createUIElement("div",{class:"ck-image-upload-complete-icon"});t.insert(t.createPositionAt(e,"end"),n),setTimeout((()=>{i.change((e=>e.remove(e.createRangeOn(n))))}),3e3)}(d,u,n.editing.view),function(e,t){Iw(e,t,"progressBar")}(d,u),Pw(d,u),function(e,t){t.removeClass("ck-appear",e)}(d,u)}}function Tw(e,t){e.hasClass("ck-appear")||t.addClass("ck-appear",e)}function Ew(e,t,i,n){i.hasClass("ck-image-upload-placeholder")||n.addClass("ck-image-upload-placeholder",i);const s=e.findViewImgElement(i);s.getAttribute("src")!==t&&n.setAttribute("src",t,s),Sw(i,"placeholder")||n.insert(n.createPositionAfter(s),function(e){const t=e.createUIElement("div",{class:"ck-upload-placeholder-loader"});return e.setCustomProperty("placeholder",!0,t),t}(n))}function Pw(e,t){e.hasClass("ck-image-upload-placeholder")&&t.removeClass("ck-image-upload-placeholder",e),Iw(e,t,"placeholder")}function Sw(e,t){for(const i of e.getChildren())if(i.getCustomProperty(t))return i}function Iw(e,t,i){const n=Sw(e,i);n&&t.remove(t.createRangeOn(n))}class Rw extends mt{refresh(){const e=this.editor,t=e.plugins.get("ImageUtils"),i=e.model.document.selection.getSelectedElement();this.isEnabled=t.isImageAllowed()||t.isImage(i)}execute(e){const t=Pn(e.file),i=this.editor.model.document.selection,n=this.editor.plugins.get("ImageUtils"),s=Object.fromEntries(i.getAttributes());t.forEach(((e,t)=>{const o=i.getSelectedElement();if(t&&o&&n.isImage(o)){const t=this.editor.model.createPositionAfter(o);this._uploadImage(e,s,t)}else this._uploadImage(e,s)}))}_uploadImage(e,t,i){const n=this.editor,s=n.plugins.get(pw).createLoader(e),o=n.plugins.get("ImageUtils");s&&o.insertImage({...t,uploadId:s.id},i)}}class Vw extends ut{static get requires(){return[pw,$u,Rg,xp]}static get pluginName(){return"ImageUploadEditing"}constructor(e){super(e),e.config.define("image",{upload:{types:["jpeg","png","gif","bmp","webp","tiff"]}}),this._uploadImageElements=new Map}init(){const e=this.editor,t=e.model.document,i=e.conversion,n=e.plugins.get(pw),s=e.plugins.get("ImageUtils"),o=yw(e.config.get("image.upload.types")),r=new Rw(e);e.commands.add("uploadImage",r),e.commands.add("imageUpload",r),i.for("upcast").attributeToAttribute({view:{name:"img",key:"uploadId"},model:"uploadId"}),this.listenTo(e.editing.view.document,"clipboardInput",((t,i)=>{if(n=i.dataTransfer,Array.from(n.types).includes("text/html")&&""!==n.getData("text/html"))return;var n;const s=Array.from(i.dataTransfer.files).filter((e=>!!e&&o.test(e.type)));s.length&&(t.stop(),e.model.change((t=>{i.targetRanges&&t.setSelection(i.targetRanges.map((t=>e.editing.mapper.toModelRange(t)))),e.model.enqueueChange((()=>{e.execute("uploadImage",{file:s})}))})))})),this.listenTo(e.plugins.get("ClipboardPipeline"),"inputTransformation",((t,i)=>{const o=Array.from(e.editing.view.createRangeIn(i.content)).filter((e=>function(e,t){return!(!e.isInlineImageView(t)||!t.getAttribute("src"))&&(t.getAttribute("src").match(/^data:image\/\w+;base64,/g)||t.getAttribute("src").match(/^blob:/g))}(s,e.item)&&!e.item.getAttribute("uploadProcessed"))).map((e=>({promise:kw(e.item),imageElement:e.item})));if(!o.length)return;const r=new Ah(e.editing.view.document);for(const e of o){r.setAttribute("uploadProcessed",!0,e.imageElement);const t=n.createLoader(e.promise);t&&(r.setAttribute("src","",e.imageElement),r.setAttribute("uploadId",t.id,e.imageElement))}})),e.editing.view.document.on("dragover",((e,t)=>{t.preventDefault()})),t.on("change",(()=>{const i=t.differ.getChanges({includeChangesInGraveyard:!0}).reverse(),s=new Set;for(const t of i)if("insert"==t.type&&"$text"!=t.name){const i=t.position.nodeAfter,o="$graveyard"==t.position.root.rootName;for(const t of Ow(e,i)){const e=t.getAttribute("uploadId");if(!e)continue;const i=n.loaders.get(e);i&&(o?s.has(e)||i.abort():(s.add(e),this._uploadImageElements.set(e,t),"idle"==i.status&&this._readAndUpload(i)))}}})),this.on("uploadComplete",((e,{imageElement:t,data:i})=>{const n=i.urls?i.urls:i;this.editor.model.change((e=>{e.setAttribute("src",n.default,t),this._parseAndSetSrcsetAttributeOnImage(n,t,e)}))}),{priority:"low"})}afterInit(){const e=this.editor.model.schema;this.editor.plugins.has("ImageBlockEditing")&&e.extend("imageBlock",{allowAttributes:["uploadId","uploadStatus"]}),this.editor.plugins.has("ImageInlineEditing")&&e.extend("imageInline",{allowAttributes:["uploadId","uploadStatus"]})}_readAndUpload(e){const t=this.editor,i=t.model,n=t.locale.t,s=t.plugins.get(pw),o=t.plugins.get($u),r=t.plugins.get("ImageUtils"),a=this._uploadImageElements;return i.enqueueChange({isUndoable:!1},(t=>{t.setAttribute("uploadStatus","reading",a.get(e.id))})),e.read().then((()=>{const n=e.upload(),s=a.get(e.id);if(no.isSafari){const e=t.editing.mapper.toViewElement(s),i=r.findViewImgElement(e);t.editing.view.once("render",(()=>{if(!i.parent)return;const e=t.editing.view.domConverter.mapViewToDom(i.parent);if(!e)return;const n=e.style.display;e.style.display="none",e._ckHack=e.offsetHeight,e.style.display=n}))}return i.enqueueChange({isUndoable:!1},(e=>{e.setAttribute("uploadStatus","uploading",s)})),n})).then((t=>{i.enqueueChange({isUndoable:!1},(i=>{const n=a.get(e.id);i.setAttribute("uploadStatus","complete",n),this.fire("uploadComplete",{data:t,imageElement:n})})),l()})).catch((t=>{if("error"!==e.status&&"aborted"!==e.status)throw t;"error"==e.status&&t&&o.showWarning(t,{title:n("Upload failed"),namespace:"upload"}),i.enqueueChange({isUndoable:!1},(t=>{t.remove(a.get(e.id))})),l()}));function l(){i.enqueueChange({isUndoable:!1},(t=>{const i=a.get(e.id);t.removeAttribute("uploadId",i),t.removeAttribute("uploadStatus",i),a.delete(e.id)})),s.destroyLoader(e)}}_parseAndSetSrcsetAttributeOnImage(e,t,i){let n=0;const s=Object.keys(e).filter((e=>{const t=parseInt(e,10);if(!isNaN(t))return n=Math.max(n,t),!0})).map((t=>`${e[t]} ${t}w`)).join(", ");""!=s&&i.setAttribute("srcset",{data:s,width:n},t)}}function Ow(e,t){const i=e.plugins.get("ImageUtils");return Array.from(e.model.createRangeOn(t)).filter((e=>i.isImage(e.item))).map((e=>e.item))}class Bw extends ut{static get pluginName(){return"ImageUpload"}static get requires(){return[Vw,Aw,xw]}}class Mw extends ut{static get pluginName(){return"IndentEditing"}init(){const e=this.editor;e.commands.add("indent",new ft(e)),e.commands.add("outdent",new ft(e))}}const Nw=' ',Dw=' ';class zw extends ut{static get pluginName(){return"IndentUI"}init(){const e=this.editor,t=e.locale,i=e.t,n="ltr"==t.uiLanguageDirection?Nw:Dw,s="ltr"==t.uiLanguageDirection?Dw:Nw;this._defineButton("indent",i("Increase indent"),n),this._defineButton("outdent",i("Decrease indent"),s)}_defineButton(e,t,i){const n=this.editor;n.ui.componentFactory.add(e,(s=>{const o=n.commands.get(e),r=new iu(s);return r.set({label:t,icon:i,tooltip:!0}),r.bind("isOn","isEnabled").to(o,"value","isEnabled"),this.listenTo(r,"execute",(()=>{n.execute(e),n.editing.view.focus()})),r}))}}class Lw extends mt{constructor(e,t){super(e),this._indentBehavior=t}refresh(){const e=this.editor.model,t=Ta(e.document.selection.getSelectedBlocks());t&&e.schema.checkAttribute(t,"blockIndent")?this.isEnabled=this._indentBehavior.checkEnabled(t.getAttribute("blockIndent")):this.isEnabled=!1}execute(){const e=this.editor.model,t=function(e){const t=e.document.selection,i=e.schema;return Array.from(t.getSelectedBlocks()).filter((e=>i.checkAttribute(e,"blockIndent")))}(e);e.change((e=>{for(const i of t){const t=i.getAttribute("blockIndent"),n=this._indentBehavior.getNextIndent(t);n?e.setAttribute("blockIndent",n,i):e.removeAttribute("blockIndent",i)}}))}}class Fw{constructor(e){this.isForward="forward"===e.direction,this.offset=e.offset,this.unit=e.unit}checkEnabled(e){const t=parseFloat(e||0);return this.isForward||t>0}getNextIndent(e){const t=parseFloat(e||0);if(!(!e||e.endsWith(this.unit)))return this.isForward?this.offset+this.unit:void 0;const i=t+(this.isForward?this.offset:-this.offset);return i>0?i+this.unit:void 0}}class Hw{constructor(e){this.isForward="forward"===e.direction,this.classes=e.classes}checkEnabled(e){const t=this.classes.indexOf(e);return this.isForward?t=0}getNextIndent(e){const t=this.classes.indexOf(e),i=this.isForward?1:-1;return this.classes[t+i]}}const jw=["paragraph","heading1","heading2","heading3","heading4","heading5","heading6"];const Ww="italic";class Uw extends ut{static get pluginName(){return"ItalicEditing"}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:Ww}),e.model.schema.setAttributeProperties(Ww,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:Ww,view:"i",upcastAlso:["em",{styles:{"font-style":"italic"}}]}),e.commands.add(Ww,new kg(e,Ww)),e.keystrokes.set("CTRL+I",Ww)}}const qw="italic";class $w extends ut{static get pluginName(){return"ItalicUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add(qw,(i=>{const n=e.commands.get(qw),s=new iu(i);return s.set({label:t("Italic"),icon:' ',keystroke:"CTRL+I",tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(n,"value","isEnabled"),this.listenTo(s,"execute",(()=>{e.execute(qw),e.editing.view.focus()})),s}))}}class Kw{constructor(){this._definitions=new Set}get length(){return this._definitions.size}add(e){Array.isArray(e)?e.forEach((e=>this._definitions.add(e))):this._definitions.add(e)}getDispatcher(){return e=>{e.on("attribute:linkHref",((e,t,i)=>{if(!i.consumable.test(t.item,"attribute:linkHref"))return;if(!t.item.is("selection")&&!i.schema.isInline(t.item))return;const n=i.writer,s=n.document.selection;for(const e of this._definitions){const o=n.createAttributeElement("a",e.attributes,{priority:5});e.classes&&n.addClass(e.classes,o);for(const t in e.styles)n.setStyle(t,e.styles[t],o);n.setCustomProperty("link",!0,o),e.callback(t.attributeNewValue)?t.item.is("selection")?n.wrap(s.getFirstRange(),o):n.wrap(i.mapper.toViewRange(t.range),o):n.unwrap(i.mapper.toViewRange(t.range),o)}}),{priority:"high"})}}getDispatcherForLinkedImage(){return e=>{e.on("attribute:linkHref:imageBlock",((e,t,{writer:i,mapper:n})=>{const s=n.toViewElement(t.item),o=Array.from(s.getChildren()).find((e=>"a"===e.name));for(const e of this._definitions){const n=Fn(e.attributes);if(e.callback(t.attributeNewValue)){for(const[e,t]of n)"class"===e?i.addClass(t,o):i.setAttribute(e,t,o);e.classes&&i.addClass(e.classes,o);for(const t in e.styles)i.setStyle(t,e.styles[t],o)}else{for(const[e,t]of n)"class"===e?i.removeClass(t,o):i.removeAttribute(e,o);e.classes&&i.removeClass(e.classes,o);for(const t in e.styles)i.removeStyle(t,o)}}}))}}}const Gw=function(e,t,i){var n=e.length;return i=void 0===i?n:i,!t&&i>=n?e:cs(e,t,i)};var Jw=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");const Yw=function(e){return Jw.test(e)};const Qw=function(e){return e.split("")};var Zw="[\\ud800-\\udfff]",Xw="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",eb="\\ud83c[\\udffb-\\udfff]",tb="[^\\ud800-\\udfff]",ib="(?:\\ud83c[\\udde6-\\uddff]){2}",nb="[\\ud800-\\udbff][\\udc00-\\udfff]",sb="(?:"+Xw+"|"+eb+")"+"?",ob="[\\ufe0e\\ufe0f]?",rb=ob+sb+("(?:\\u200d(?:"+[tb,ib,nb].join("|")+")"+ob+sb+")*"),ab="(?:"+[tb+Xw+"?",Xw,ib,nb,Zw].join("|")+")",lb=RegExp(eb+"(?="+eb+")|"+ab+rb,"g");const cb=function(e){return e.match(lb)||[]};const db=function(e){return Yw(e)?cb(e):Qw(e)};const ub=function(e){return function(t){t=ss(t);var i=Yw(t)?db(t):void 0,n=i?i[0]:t.charAt(0),s=i?Gw(i,1).join(""):t.slice(1);return n[e]()+s}}("toUpperCase"),hb=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g,mb=/^(?:(?:https?|ftps?|mailto):|[^a-z]|[a-z+.-]+(?:[^a-z+.:-]|$))/i,gb=/^[\S]+@((?![-_])(?:[-\w\u00a1-\uffff]{0,63}[^-_]\.))+(?:[a-z\u00a1-\uffff]{2,})$/i,fb=/^((\w+:(\/{2,})?)|(\W))/i,pb="Ctrl+K";function wb(e,{writer:t}){const i=t.createAttributeElement("a",{href:e},{priority:5});return t.setCustomProperty("link",!0,i),i}function bb(e){return function(e){return e.replace(hb,"").match(mb)}(e=String(e))?e:"#"}function vb(e,t){return!!e&&t.checkAttribute(e.name,"linkHref")}function _b(e,t){const i=(n=e,gb.test(n)?"mailto:":t);var n;const s=!!i&&!fb.test(e);return e&&s?i+e:e}function yb(e){window.open(e,"_blank","noopener")}class kb extends mt{constructor(e){super(e),this.manualDecorators=new Tn,this.automaticDecorators=new Kw}restoreManualDecoratorStates(){for(const e of this.manualDecorators)e.value=this._getDecoratorStateFromModel(e.id)}refresh(){const e=this.editor.model,t=e.document.selection,i=t.getSelectedElement()||Ta(t.getSelectedBlocks());vb(i,e.schema)?(this.value=i.getAttribute("linkHref"),this.isEnabled=e.schema.checkAttribute(i,"linkHref")):(this.value=t.getAttribute("linkHref"),this.isEnabled=e.schema.checkAttributeInSelection(t,"linkHref"));for(const e of this.manualDecorators)e.value=this._getDecoratorStateFromModel(e.id)}execute(e,t={}){const i=this.editor.model,n=i.document.selection,s=[],o=[];for(const e in t)t[e]?s.push(e):o.push(e);i.change((t=>{if(n.isCollapsed){const r=n.getFirstPosition();if(n.hasAttribute("linkHref")){const a=tg(r,"linkHref",n.getAttribute("linkHref"),i);t.setAttribute("linkHref",e,a),s.forEach((e=>{t.setAttribute(e,!0,a)})),o.forEach((e=>{t.removeAttribute(e,a)})),t.setSelection(t.createPositionAfter(a.end.nodeBefore))}else if(""!==e){const o=Fn(n.getAttributes());o.set("linkHref",e),s.forEach((e=>{o.set(e,!0)}));const{end:a}=i.insertContent(t.createText(e,o),r);t.setSelection(a)}["linkHref",...s,...o].forEach((e=>{t.removeSelectionAttribute(e)}))}else{const r=i.schema.getValidRanges(n.getRanges(),"linkHref"),a=[];for(const e of n.getSelectedBlocks())i.schema.checkAttribute(e,"linkHref")&&a.push(t.createRangeOn(e));const l=a.slice();for(const e of r)this._isRangeToUpdate(e,a)&&l.push(e);for(const i of l)t.setAttribute("linkHref",e,i),s.forEach((e=>{t.setAttribute(e,!0,i)})),o.forEach((e=>{t.removeAttribute(e,i)}))}}))}_getDecoratorStateFromModel(e){const t=this.editor.model,i=t.document.selection,n=i.getSelectedElement();return vb(n,t.schema)?n.getAttribute(e):i.getAttribute(e)}_isRangeToUpdate(e,t){for(const i of t)if(i.containsRange(e))return!1;return!0}}class Cb extends mt{refresh(){const e=this.editor.model,t=e.document.selection,i=t.getSelectedElement();vb(i,e.schema)?this.isEnabled=e.schema.checkAttribute(i,"linkHref"):this.isEnabled=e.schema.checkAttributeInSelection(t,"linkHref")}execute(){const e=this.editor,t=this.editor.model,i=t.document.selection,n=e.commands.get("link");t.change((e=>{const s=i.isCollapsed?[tg(i.getFirstPosition(),"linkHref",i.getAttribute("linkHref"),t)]:t.schema.getValidRanges(i.getRanges(),"linkHref");for(const t of s)if(e.removeAttribute("linkHref",t),n)for(const i of n.manualDecorators)e.removeAttribute(i.id,t)}))}}class Ab{constructor({id:e,label:t,attributes:i,classes:n,styles:s,defaultValue:o}){this.id=e,this.set("value"),this.defaultValue=o,this.label=t,this.attributes=i,this.classes=n,this.styles=s}_createPattern(){return{attributes:this.attributes,classes:this.classes,styles:this.styles}}}dt(Ab,st);const xb="automatic",Tb=/^(https?:)?\/\//;class Eb extends ut{static get pluginName(){return"LinkEditing"}static get requires(){return[Fm,Om,Rg]}constructor(e){super(e),e.config.define("link",{addTargetToExternalLinks:!1})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:"linkHref"}),e.conversion.for("dataDowncast").attributeToElement({model:"linkHref",view:wb}),e.conversion.for("editingDowncast").attributeToElement({model:"linkHref",view:(e,t)=>wb(bb(e),t)}),e.conversion.for("upcast").elementToAttribute({view:{name:"a",attributes:{href:!0}},model:{key:"linkHref",value:e=>e.getAttribute("href")}}),e.commands.add("link",new kb(e)),e.commands.add("unlink",new Cb(e));const t=function(e,t){const i={"Open in a new tab":e("Open in a new tab"),Downloadable:e("Downloadable")};return t.forEach((e=>(e.label&&i[e.label]&&(e.label=i[e.label]),e))),t}(e.t,function(e){const t=[];if(e)for(const[i,n]of Object.entries(e)){const e=Object.assign({},n,{id:`link${ub(i)}`});t.push(e)}return t}(e.config.get("link.decorators")));this._enableAutomaticDecorators(t.filter((e=>e.mode===xb))),this._enableManualDecorators(t.filter((e=>"manual"===e.mode)));e.plugins.get(Fm).registerAttribute("linkHref"),function(e,t,i,n){const s=e.editing.view,o=new Set;s.document.registerPostFixer((s=>{const r=e.model.document.selection;let a=!1;if(r.hasAttribute(t)){const l=tg(r.getFirstPosition(),t,r.getAttribute(t),e.model),c=e.editing.mapper.toViewRange(l);for(const e of c.getItems())e.is("element",i)&&!e.hasClass(n)&&(s.addClass(n,e),o.add(e),a=!0)}return a})),e.conversion.for("editingDowncast").add((e=>{function t(){s.change((e=>{for(const t of o.values())e.removeClass(n,t),o.delete(t)}))}e.on("insert",t,{priority:"highest"}),e.on("remove",t,{priority:"highest"}),e.on("attribute",t,{priority:"highest"}),e.on("selection",t,{priority:"highest"})}))}(e,"linkHref","a","ck-link_selected"),this._enableLinkOpen(),this._enableInsertContentSelectionAttributesFixer(),this._enableClickingAfterLink(),this._enableTypingOverLink(),this._handleDeleteContentAfterLink()}_enableAutomaticDecorators(e){const t=this.editor,i=t.commands.get("link").automaticDecorators;t.config.get("link.addTargetToExternalLinks")&&i.add({id:"linkIsExternal",mode:xb,callback:e=>Tb.test(e),attributes:{target:"_blank",rel:"noopener noreferrer"}}),i.add(e),i.length&&t.conversion.for("downcast").add(i.getDispatcher())}_enableManualDecorators(e){if(!e.length)return;const t=this.editor,i=t.commands.get("link").manualDecorators;e.forEach((e=>{t.model.schema.extend("$text",{allowAttributes:e.id}),e=new Ab(e),i.add(e),t.conversion.for("downcast").attributeToElement({model:e.id,view:(t,{writer:i,schema:n},{item:s})=>{if(n.isInline(s)&&t){const t=i.createAttributeElement("a",e.attributes,{priority:5});e.classes&&i.addClass(e.classes,t);for(const n in e.styles)i.setStyle(n,e.styles[n],t);return i.setCustomProperty("link",!0,t),t}}}),t.conversion.for("upcast").elementToAttribute({view:{name:"a",...e._createPattern()},model:{key:e.id}})}))}_enableLinkOpen(){const e=this.editor,t=e.editing.view.document,i=e.model.document;this.listenTo(t,"click",((e,t)=>{if(!(no.isMac?t.domEvent.metaKey:t.domEvent.ctrlKey))return;let i=t.domTarget;if("a"!=i.tagName.toLowerCase()&&(i=i.closest("a")),!i)return;const n=i.getAttribute("href");n&&(e.stop(),t.preventDefault(),yb(n))}),{context:"$capture"}),this.listenTo(t,"enter",((e,t)=>{const n=i.selection,s=n.getSelectedElement(),o=s?s.getAttribute("linkHref"):n.getAttribute("linkHref");o&&t.domEvent.altKey&&(e.stop(),yb(o))}),{context:"a"})}_enableInsertContentSelectionAttributesFixer(){const e=this.editor.model,t=e.document.selection;this.listenTo(e,"insertContent",(()=>{const i=t.anchor.nodeBefore,n=t.anchor.nodeAfter;t.hasAttribute("linkHref")&&i&&i.hasAttribute("linkHref")&&(n&&n.hasAttribute("linkHref")||e.change((t=>{Pb(t,Ib(e.schema))})))}),{priority:"low"})}_enableClickingAfterLink(){const e=this.editor,t=e.model;e.editing.view.addObserver(Ch);let i=!1;this.listenTo(e.editing.view.document,"mousedown",(()=>{i=!0})),this.listenTo(e.editing.view.document,"selectionChange",(()=>{if(!i)return;i=!1;const e=t.document.selection;if(!e.isCollapsed)return;if(!e.hasAttribute("linkHref"))return;const n=e.getFirstPosition(),s=tg(n,"linkHref",e.getAttribute("linkHref"),t);(n.isTouching(s.start)||n.isTouching(s.end))&&t.change((e=>{Pb(e,Ib(t.schema))}))}))}_enableTypingOverLink(){const e=this.editor,t=e.editing.view;let i,n;this.listenTo(t.document,"delete",(()=>{n=!0}),{priority:"high"}),this.listenTo(e.model,"deleteContent",(()=>{const t=e.model.document.selection;t.isCollapsed||(n?n=!1:Sb(e)&&function(e){const t=e.document.selection,i=t.getFirstPosition(),n=t.getLastPosition(),s=i.nodeAfter;if(!s)return!1;if(!s.is("$text"))return!1;if(!s.hasAttribute("linkHref"))return!1;const o=n.textNode||n.nodeBefore;if(s===o)return!0;return tg(i,"linkHref",s.getAttribute("linkHref"),e).containsRange(e.createRange(i,n),!0)}(e.model)&&(i=t.getAttributes()))}),{priority:"high"}),this.listenTo(e.model,"insertContent",((t,[s])=>{n=!1,Sb(e)&&i&&(e.model.change((e=>{for(const[t,n]of i)e.setAttribute(t,n,s)})),i=null)}),{priority:"high"})}_handleDeleteContentAfterLink(){const e=this.editor,t=e.model,i=t.document.selection,n=e.editing.view;let s=!1,o=!1;this.listenTo(n.document,"delete",((e,t)=>{o=t.domEvent.keyCode===ao.backspace}),{priority:"high"}),this.listenTo(t,"deleteContent",(()=>{s=!1;const e=i.getFirstPosition(),n=i.getAttribute("linkHref");if(!n)return;const o=tg(e,"linkHref",n,t);s=o.containsPosition(e)||o.end.isEqual(e)}),{priority:"high"}),this.listenTo(t,"deleteContent",(()=>{o&&(o=!1,s||e.model.enqueueChange((e=>{Pb(e,Ib(t.schema))})))}),{priority:"low"})}}function Pb(e,t){e.removeSelectionAttribute("linkHref");for(const i of t)e.removeSelectionAttribute(i)}function Sb(e){return e.model.change((e=>e.batch)).isTyping}function Ib(e){return e.getDefinition("$text").allowAttributes.filter((e=>e.startsWith("link")))}class Rb extends Vd{constructor(e,t){super(e);const i=e.t;this.focusTracker=new Ea,this.keystrokes=new Pa,this.urlInputView=this._createUrlInput(),this.saveButtonView=this._createButton(i("Save"),Ed.check,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(i("Cancel"),Ed.cancel,"ck-button-cancel","cancel"),this._manualDecoratorSwitches=this._createManualDecoratorSwitches(t),this.children=this._createFormChildren(t.manualDecorators),this._focusables=new Rd,this._focusCycler=new cu({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}});const n=["ck","ck-link-form","ck-responsive-form"];t.manualDecorators.length&&n.push("ck-link-form_layout-vertical","ck-vertical-form"),this.setTemplate({tag:"form",attributes:{class:n,tabindex:"-1"},children:this.children}),Sd(this)}getDecoratorSwitchesState(){return Array.from(this._manualDecoratorSwitches).reduce(((e,t)=>(e[t.name]=t.isOn,e)),{})}render(){super.render(),Id({view:this});[this.urlInputView,...this._manualDecoratorSwitches,this.saveButtonView,this.cancelButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createUrlInput(){const e=this.locale.t,t=new ju(this.locale,Wu);return t.label=e("Link URL"),t}_createButton(e,t,i,n){const s=new iu(this.locale);return s.set({label:e,icon:t,tooltip:!0}),s.extendTemplate({attributes:{class:i}}),n&&s.delegate("execute").to(this,n),s}_createManualDecoratorSwitches(e){const t=this.createCollection();for(const i of e.manualDecorators){const n=new nu(this.locale);n.set({name:i.id,label:i.label,withText:!0}),n.bind("isOn").toMany([i,e],"value",((e,t)=>void 0===t&&void 0===e?i.defaultValue:e)),n.on("execute",(()=>{i.set("value",!n.isOn)})),t.add(n)}return t}_createFormChildren(e){const t=this.createCollection();if(t.add(this.urlInputView),e.length){const e=new Vd;e.setTemplate({tag:"ul",children:this._manualDecoratorSwitches.map((e=>({tag:"li",children:[e],attributes:{class:["ck","ck-list__item"]}}))),attributes:{class:["ck","ck-reset","ck-list"]}}),t.add(e)}return t.add(this.saveButtonView),t.add(this.cancelButtonView),t}}class Vb extends Vd{constructor(e){super(e);const t=e.t;this.focusTracker=new Ea,this.keystrokes=new Pa,this.previewButtonView=this._createPreviewButton(),this.unlinkButtonView=this._createButton(t("Unlink"),' ',"unlink"),this.editButtonView=this._createButton(t("Edit link"),Ed.pencil,"edit"),this.set("href"),this._focusables=new Rd,this._focusCycler=new cu({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-link-actions","ck-responsive-form"],tabindex:"-1"},children:[this.previewButtonView,this.editButtonView,this.unlinkButtonView]})}render(){super.render();[this.previewButtonView,this.editButtonView,this.unlinkButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createButton(e,t,i){const n=new iu(this.locale);return n.set({label:e,icon:t,tooltip:!0}),n.delegate("execute").to(this,i),n}_createPreviewButton(){const e=new iu(this.locale),t=this.bindTemplate,i=this.t;return e.set({withText:!0,tooltip:i("Open link in new tab")}),e.extendTemplate({attributes:{class:["ck","ck-link-actions__preview"],href:t.to("href",(e=>e&&bb(e))),target:"_blank",rel:"noopener noreferrer"}}),e.bind("label").to(this,"href",(e=>e||i("This link has no URL"))),e.bind("isEnabled").to(this,"href",(e=>!!e)),e.template.tag="a",e.template.eventListeners={},e}}const Ob=' ',Bb="link-ui";class Mb extends ut{static get requires(){return[eh]}static get pluginName(){return"LinkUI"}init(){const e=this.editor;e.editing.view.addObserver(kh),this.actionsView=this._createActionsView(),this.formView=this._createFormView(),this._balloon=e.plugins.get(eh),this._createToolbarLinkButton(),this._enableUserBalloonInteractions(),e.conversion.for("editingDowncast").markerToHighlight({model:Bb,view:{classes:["ck-fake-link-selection"]}}),e.conversion.for("editingDowncast").markerToElement({model:Bb,view:{name:"span",classes:["ck-fake-link-selection","ck-fake-link-selection_collapsed"]}})}destroy(){super.destroy(),this.formView.destroy()}_createActionsView(){const e=this.editor,t=new Vb(e.locale),i=e.commands.get("link"),n=e.commands.get("unlink");return t.bind("href").to(i,"value"),t.editButtonView.bind("isEnabled").to(i),t.unlinkButtonView.bind("isEnabled").to(n),this.listenTo(t,"edit",(()=>{this._addFormView()})),this.listenTo(t,"unlink",(()=>{e.execute("unlink"),this._hideUI()})),t.keystrokes.set("Esc",((e,t)=>{this._hideUI(),t()})),t.keystrokes.set(pb,((e,t)=>{this._addFormView(),t()})),t}_createFormView(){const e=this.editor,t=e.commands.get("link"),i=e.config.get("link.defaultProtocol"),n=new Rb(e.locale,t);return n.urlInputView.fieldView.bind("value").to(t,"value"),n.urlInputView.bind("isReadOnly").to(t,"isEnabled",(e=>!e)),n.saveButtonView.bind("isEnabled").to(t),this.listenTo(n,"submit",(()=>{const{value:t}=n.urlInputView.fieldView.element,s=_b(t,i);e.execute("link",s,n.getDecoratorSwitchesState()),this._closeFormView()})),this.listenTo(n,"cancel",(()=>{this._closeFormView()})),n.keystrokes.set("Esc",((e,t)=>{this._closeFormView(),t()})),n}_createToolbarLinkButton(){const e=this.editor,t=e.commands.get("link"),i=e.t;e.keystrokes.set(pb,((e,i)=>{i(),t.isEnabled&&this._showUI(!0)})),e.ui.componentFactory.add("link",(e=>{const n=new iu(e);return n.isEnabled=!0,n.label=i("Link"),n.icon=Ob,n.keystroke=pb,n.tooltip=!0,n.isToggleable=!0,n.bind("isEnabled").to(t,"isEnabled"),n.bind("isOn").to(t,"value",(e=>!!e)),this.listenTo(n,"execute",(()=>this._showUI(!0))),n}))}_enableUserBalloonInteractions(){const e=this.editor.editing.view.document;this.listenTo(e,"click",(()=>{this._getSelectedLinkElement()&&this._showUI()})),this.editor.keystrokes.set("Tab",((e,t)=>{this._areActionsVisible&&!this.actionsView.focusTracker.isFocused&&(this.actionsView.focus(),t())}),{priority:"high"}),this.editor.keystrokes.set("Esc",((e,t)=>{this._isUIVisible&&(this._hideUI(),t())})),Pd({emitter:this.formView,activator:()=>this._isUIInPanel,contextElements:[this._balloon.view.element],callback:()=>this._hideUI()})}_addActionsView(){this._areActionsInPanel||this._balloon.add({view:this.actionsView,position:this._getBalloonPositionData()})}_addFormView(){if(this._isFormInPanel)return;const e=this.editor.commands.get("link");this.formView.disableCssTransitions(),this._balloon.add({view:this.formView,position:this._getBalloonPositionData()}),this._balloon.visibleView===this.formView&&this.formView.urlInputView.fieldView.select(),this.formView.enableCssTransitions(),this.formView.urlInputView.fieldView.element.value=e.value||""}_closeFormView(){const e=this.editor.commands.get("link");e.restoreManualDecoratorStates(),void 0!==e.value?this._removeFormView():this._hideUI()}_removeFormView(){this._isFormInPanel&&(this.formView.saveButtonView.focus(),this._balloon.remove(this.formView),this.editor.editing.view.focus(),this._hideFakeVisualSelection())}_showUI(e=!1){this._getSelectedLinkElement()?(this._areActionsVisible?this._addFormView():this._addActionsView(),e&&this._balloon.showStack("main")):(this._showFakeVisualSelection(),this._addActionsView(),e&&this._balloon.showStack("main"),this._addFormView()),this._startUpdatingUI()}_hideUI(){if(!this._isUIInPanel)return;const e=this.editor;this.stopListening(e.ui,"update"),this.stopListening(this._balloon,"change:visibleView"),e.editing.view.focus(),this._removeFormView(),this._balloon.remove(this.actionsView),this._hideFakeVisualSelection()}_startUpdatingUI(){const e=this.editor,t=e.editing.view.document;let i=this._getSelectedLinkElement(),n=o();const s=()=>{const e=this._getSelectedLinkElement(),t=o();i&&!e||!i&&t!==n?this._hideUI():this._isUIVisible&&this._balloon.updatePosition(this._getBalloonPositionData()),i=e,n=t};function o(){return t.selection.focus.getAncestors().reverse().find((e=>e.is("element")))}this.listenTo(e.ui,"update",s),this.listenTo(this._balloon,"change:visibleView",s)}get _isFormInPanel(){return this._balloon.hasView(this.formView)}get _areActionsInPanel(){return this._balloon.hasView(this.actionsView)}get _areActionsVisible(){return this._balloon.visibleView===this.actionsView}get _isUIInPanel(){return this._isFormInPanel||this._areActionsInPanel}get _isUIVisible(){return this._balloon.visibleView==this.formView||this._areActionsVisible}_getBalloonPositionData(){const e=this.editor.editing.view,t=this.editor.model,i=e.document;let n=null;if(t.markers.has(Bb)){const t=Array.from(this.editor.editing.mapper.markerNameToElements(Bb)),i=e.createRange(e.createPositionBefore(t[0]),e.createPositionAfter(t[t.length-1]));n=e.domConverter.viewRangeToDom(i)}else n=()=>{const t=this._getSelectedLinkElement();return t?e.domConverter.mapViewToDom(t):e.domConverter.viewRangeToDom(i.selection.getFirstRange())};return{target:n}}_getSelectedLinkElement(){const e=this.editor.editing.view,t=e.document.selection,i=t.getSelectedElement();if(t.isCollapsed||i&&zg(i))return Nb(t.getFirstPosition());{const i=t.getFirstRange().getTrimmed(),n=Nb(i.start),s=Nb(i.end);return n&&n==s&&e.createRangeIn(n).getTrimmed().isEqual(i)?n:null}}_showFakeVisualSelection(){const e=this.editor.model;e.change((t=>{const i=e.document.selection.getFirstRange();if(e.markers.has(Bb))t.updateMarker(Bb,{range:i});else if(i.start.isAtEnd){const n=i.start.getLastMatchingPosition((({item:t})=>!e.schema.isContent(t)),{boundaries:i});t.addMarker(Bb,{usingOperation:!1,affectsData:!1,range:t.createRange(n,i.end)})}else t.addMarker(Bb,{usingOperation:!1,affectsData:!1,range:i})}))}_hideFakeVisualSelection(){const e=this.editor.model;e.markers.has(Bb)&&e.change((e=>{e.removeMarker(Bb)}))}}function Nb(e){return e.getAncestors().find((e=>{return(t=e).is("attributeElement")&&!!t.getCustomProperty("link");var t}))}const Db=new RegExp("(^|\\s)(((?:(?:(?:https?|ftp):)?\\/\\/)(?:\\S+(?::\\S*)?@)?(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(((?!www\\.)|(www\\.))(?![-_])(?:[-_a-z0-9\\u00a1-\\uffff]{1,63}\\.)+(?:[a-z\\u00a1-\\uffff]{2,63})))(?::\\d{2,5})?(?:[/?#]\\S*)?)|((www.|(\\S+@))((?![-_])(?:[-_a-z0-9\\u00a1-\\uffff]{1,63}\\.))+(?:[a-z\\u00a1-\\uffff]{2,63})))$","i");class zb extends ut{static get requires(){return[Nm]}static get pluginName(){return"AutoLink"}init(){const e=this.editor.model.document.selection;e.on("change:range",(()=>{this.isEnabled=!e.anchor.parent.is("element","codeBlock")})),this._enableTypingHandling()}afterInit(){this._enableEnterHandling(),this._enableShiftEnterHandling()}_enableTypingHandling(){const e=this.editor,t=new Lm(e.model,(e=>{if(!function(e){return e.length>4&&" "===e[e.length-1]&&" "!==e[e.length-2]}(e))return;const t=Lb(e.substr(0,e.length-1));return t?{url:t}:void 0}));t.on("matched:data",((t,i)=>{const{batch:n,range:s,url:o}=i;if(!n.isTyping)return;const r=s.end.getShiftedBy(-1),a=r.getShiftedBy(-o.length),l=e.model.createRange(a,r);this._applyAutoLink(o,l)})),t.bind("isEnabled").to(this)}_enableEnterHandling(){const e=this.editor,t=e.model,i=e.commands.get("enter");i&&i.on("execute",(()=>{const e=t.document.selection.getFirstPosition();if(!e.parent.previousSibling)return;const i=t.createRangeIn(e.parent.previousSibling);this._checkAndApplyAutoLinkOnRange(i)}))}_enableShiftEnterHandling(){const e=this.editor,t=e.model,i=e.commands.get("shiftEnter");i&&i.on("execute",(()=>{const e=t.document.selection.getFirstPosition(),i=t.createRange(t.createPositionAt(e.parent,0),e.getShiftedBy(-1));this._checkAndApplyAutoLinkOnRange(i)}))}_checkAndApplyAutoLinkOnRange(e){const t=this.editor.model,{text:i,range:n}=zm(e,t),s=Lb(i);if(s){const e=t.createRange(n.end.getShiftedBy(-s.length),n.end);this._applyAutoLink(s,e)}}_applyAutoLink(e,t){const i=this.editor.model,n=this.editor.plugins.get("Delete");this.isEnabled&&function(e,t){return t.schema.checkAttributeInSelection(t.createSelection(e),"linkHref")}(t,i)&&i.enqueueChange((s=>{const o=this.editor.config.get("link.defaultProtocol"),r=_b(e,o);s.setAttribute("linkHref",r,t),i.enqueueChange((()=>{n.requestUndoOnBackspace()}))}))}}function Lb(e){const t=Db.exec(e);return t?t[2]:null}class Fb extends ut{static get requires(){return["ImageEditing","ImageUtils",Eb]}static get pluginName(){return"LinkImageEditing"}init(){const e=this.editor,t=e.model.schema;e.plugins.has("ImageBlockEditing")&&t.extend("imageBlock",{allowAttributes:["linkHref"]}),e.conversion.for("upcast").add(function(e){const t=e.plugins.has("ImageInlineEditing"),i=e.plugins.get("ImageUtils");return e=>{e.on("element:a",((e,n,s)=>{const o=n.viewItem,r=i.findViewImgElement(o);if(!r)return;const a=r.findAncestor((e=>i.isBlockImageView(e)));if(t&&!a)return;const l={attributes:["href"]};if(!s.consumable.consume(o,l))return;const c=o.getAttribute("href");if(!c)return;let d=n.modelCursor.parent;if(!d.is("element","imageBlock")){const e=s.convertItem(r,n.modelCursor);n.modelRange=e.modelRange,n.modelCursor=e.modelCursor,d=n.modelCursor.nodeBefore}d&&d.is("element","imageBlock")&&s.writer.setAttribute("linkHref",c,d)}),{priority:"high"})}}(e)),e.conversion.for("downcast").add(function(e){const t=e.plugins.get("ImageUtils");return e=>{e.on("attribute:linkHref:imageBlock",((e,i,n)=>{if(!n.consumable.consume(i.item,e.name))return;const s=n.mapper.toViewElement(i.item),o=n.writer,r=Array.from(s.getChildren()).find((e=>"a"===e.name)),a=t.findViewImgElement(s),l=a.parent.is("element","picture")?a.parent:a;if(r)i.attributeNewValue?o.setAttribute("href",i.attributeNewValue,r):(o.move(o.createRangeOn(l),o.createPositionAt(s,0)),o.remove(r));else{const e=o.createContainerElement("a",{href:i.attributeNewValue});o.insert(o.createPositionAt(s,0),e),o.move(o.createRangeOn(l),o.createPositionAt(e,0))}}),{priority:"high"})}}(e)),this._enableAutomaticDecorators(),this._enableManualDecorators()}_enableAutomaticDecorators(){const e=this.editor,t=e.commands.get("link").automaticDecorators;t.length&&e.conversion.for("downcast").add(t.getDispatcherForLinkedImage())}_enableManualDecorators(){const e=this.editor,t=e.commands.get("link");for(const i of t.manualDecorators)e.plugins.has("ImageBlockEditing")&&e.model.schema.extend("imageBlock",{allowAttributes:i.id}),e.plugins.has("ImageInlineEditing")&&e.model.schema.extend("imageInline",{allowAttributes:i.id}),e.conversion.for("downcast").add(Hb(i)),e.conversion.for("upcast").add(jb(e,i))}}function Hb(e){return t=>{t.on(`attribute:${e.id}:imageBlock`,((t,i,n)=>{const s=n.mapper.toViewElement(i.item),o=Array.from(s.getChildren()).find((e=>"a"===e.name));if(o){for(const[t,i]of Fn(e.attributes))n.writer.setAttribute(t,i,o);e.classes&&n.writer.addClass(e.classes,o);for(const t in e.styles)n.writer.setStyle(t,e.styles[t],o)}}))}}function jb(e,t){const i=e.plugins.has("ImageInlineEditing"),n=e.plugins.get("ImageUtils");return e=>{e.on("element:a",((e,s,o)=>{const r=s.viewItem,a=n.findViewImgElement(r);if(!a)return;const l=a.findAncestor((e=>n.isBlockImageView(e)));if(i&&!l)return;const c=new Hn(t._createPattern()).match(r);if(!c)return;if(!o.consumable.consume(r,c.match))return;const d=s.modelCursor.nodeBefore||s.modelCursor.parent;o.writer.setAttribute(t.id,!0,d)}),{priority:"high"})}}class Wb extends ut{static get requires(){return[Eb,Mb,"ImageBlockEditing"]}static get pluginName(){return"LinkImageUI"}init(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"click",((t,i)=>{this._isSelectedLinkedImage(e.model.document.selection)&&(i.preventDefault(),t.stop())}),{priority:"high"}),this._createToolbarLinkImageButton()}_createToolbarLinkImageButton(){const e=this.editor,t=e.t;e.ui.componentFactory.add("linkImage",(i=>{const n=new iu(i),s=e.plugins.get("LinkUI"),o=e.commands.get("link");return n.set({isEnabled:!0,label:t("Link image"),icon:Ob,keystroke:pb,tooltip:!0,isToggleable:!0}),n.bind("isEnabled").to(o,"isEnabled"),n.bind("isOn").to(o,"value",(e=>!!e)),this.listenTo(n,"execute",(()=>{this._isSelectedLinkedImage(e.model.document.selection)?s._addActionsView():s._showUI(!0)})),n}))}_isSelectedLinkedImage(e){const t=e.getSelectedElement();return this.editor.plugins.get("ImageUtils").isImage(t)&&t.hasAttribute("linkHref")}}class Ub extends mt{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=>$b(e,t.schema))),s=void 0!==e.forceValue?!e.forceValue:this.value;t.change((e=>{if(s){let t=n[n.length-1].nextSibling,i=Number.POSITIVE_INFINITY,s=[];for(;t&&"listItem"==t.name&&0!==t.getAttribute("listIndent");){const e=t.getAttribute("listIndent");e=i;)o>s.getAttribute("listIndent")&&(o=s.getAttribute("listIndent")),s.getAttribute("listIndent")==o&&e[t?"unshift":"push"](s),s=s[t?"previousSibling":"nextSibling"]}}function $b(e,t){return t.checkChild(e.parent,"listItem")&&!t.isObject(e)}class Kb extends mt{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=Ta(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 Gb(e,t){const i=t.mapper,n=t.writer,s="numbered"==e.getAttribute("listType")?"ol":"ul",o=function(e){const t=e.createContainerElement("li");return t.getFillerOffset=sv,t}(n),r=n.createContainerElement(s,null);return n.insert(n.createPositionAt(r,0),o),i.bindElements(e,o),o}function Jb(e,t,i,n){const s=t.parent,o=i.mapper,r=i.writer;let a=o.toViewPosition(n.createPositionBefore(e));const l=Zb(e.previousSibling,{sameIndent:!0,smallerIndent:!0,listIndent:e.getAttribute("listIndent")}),c=e.previousSibling;if(l&&l.getAttribute("listIndent")==e.getAttribute("listIndent")){const e=o.toViewElement(l);a=r.breakContainer(r.createPositionAfter(e))}else if(c&&"listItem"==c.name){a=o.toViewPosition(n.createPositionAt(c,"end"));const e=o.findMappedViewAncestor(a),t=function(e){for(const t of e.getChildren())if("ul"==t.name||"ol"==t.name)return t;return null}(e);a=t?r.createPositionBefore(t):r.createPositionAt(e,"end")}else a=o.toViewPosition(n.createPositionBefore(e));if(a=Qb(a),r.insert(a,s),c&&"listItem"==c.name){const e=o.toViewElement(c),i=r.createRange(r.createPositionAt(e,0),a).getWalker({ignoreElementEnd:!0});for(const e of i)if(e.item.is("element","li")){const n=r.breakContainer(r.createPositionBefore(e.item)),s=e.item.parent,o=r.createPositionAt(t,"end");Yb(r,o.nodeBefore,o.nodeAfter),r.move(r.createRangeOn(s),o),i.position=n}}else{const i=s.nextSibling;if(i&&(i.is("element","ul")||i.is("element","ol"))){let n=null;for(const t of i.getChildren()){const i=o.toModelElement(t);if(!(i&&i.getAttribute("listIndent")>e.getAttribute("listIndent")))break;n=t}n&&(r.breakContainer(r.createPositionAfter(n)),r.move(r.createRangeOn(n.parent),r.createPositionAt(t,"end")))}}Yb(r,s,s.nextSibling),Yb(r,s.previousSibling,s)}function Yb(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 Qb(e){return e.getLastMatchingPosition((e=>e.item.is("uiElement")))}function Zb(e,t){const i=!!t.sameIndent,n=!!t.smallerIndent,s=t.listIndent;let o=e;for(;o&&"listItem"==o.name;){const e=o.getAttribute("listIndent");if(i&&s==e||n&&s>e)return o;o="forward"===t.direction?o.nextSibling:o.previousSibling}return null}function Xb(e,t,i,n){e.ui.componentFactory.add(t,(s=>{const o=e.commands.get(t),r=new iu(s);return r.set({label:i,icon:n,tooltip:!0,isToggleable:!0}),r.bind("isOn","isEnabled").to(o,"value","isEnabled"),r.on("execute",(()=>{e.execute(t),e.editing.view.focus()})),r}))}function ev(e,t){const i=[],n=e.parent,s={ignoreElementEnd:!0,startPosition:e,shallow:!0,direction:t},o=n.getAttribute("listIndent"),r=[...new Da(s)].filter((e=>e.item.is("element"))).map((e=>e.item));for(const e of r){if(!e.is("element","listItem"))break;if(e.getAttribute("listIndent")o)){if(e.getAttribute("listType")!==n.getAttribute("listType"))break;if(e.getAttribute("listStyle")!==n.getAttribute("listStyle"))break;if(e.getAttribute("listReversed")!==n.getAttribute("listReversed"))break;if(e.getAttribute("listStart")!==n.getAttribute("listStart"))break;"backward"===t?i.unshift(e):i.push(e)}}return i}function tv(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[...ev(i,"backward"),...ev(i,"forward")]})).flat();return t=[...new Set(t)],t}const iv=["disc","circle","square"],nv=["decimal","decimal-leading-zero","lower-roman","upper-roman","lower-latin","upper-latin"];function sv(){const e=!this.isEmpty&&("ul"==this.getChild(0).name||"ol"==this.getChild(0).name);return this.isEmpty||e?0:Rs.call(this)}function ov(e){return(t,i,n)=>{const s=n.consumable;if(!s.test(i.item,"insert")||!s.test(i.item,"attribute:listType")||!s.test(i.item,"attribute:listIndent"))return;s.consume(i.item,"insert"),s.consume(i.item,"attribute:listType"),s.consume(i.item,"attribute:listIndent");const o=i.item;Jb(o,Gb(o,n),n,e)}}function rv(e,t,i){if(!i.consumable.test(t.item,e.name))return;const n=i.mapper.toViewElement(t.item),s=i.writer;s.breakContainer(s.createPositionBefore(n)),s.breakContainer(s.createPositionAfter(n));const o=n.parent,r="numbered"==t.attributeNewValue?"ol":"ul";s.rename(r,o)}function av(e,t,i){i.consumable.consume(t.item,e.name);const n=i.mapper.toViewElement(t.item).parent,s=i.writer;Yb(s,n,n.nextSibling),Yb(s,n.previousSibling,n)}function lv(e,t,i){if(i.consumable.test(t.item,e.name)&&"listItem"!=t.item.name){let e=i.mapper.toViewPosition(t.range.start);const n=i.writer,s=[];for(;("ul"==e.parent.name||"ol"==e.parent.name)&&(e=n.breakContainer(e),"li"==e.parent.name);){const t=e,i=n.createPositionAt(e.parent,"end");if(!t.isEqual(i)){const e=n.remove(n.createRange(t,i));s.push(e)}e=n.createPositionAfter(e.parent)}if(s.length>0){for(let t=0;t0){const t=Yb(n,i,i.nextSibling);t&&t.parent==i&&e.offset--}}Yb(n,e.nodeBefore,e.nodeAfter)}}}function cv(e,t,i){const n=i.mapper.toViewPosition(t.position),s=n.nodeBefore,o=n.nodeAfter;Yb(i.writer,s,o)}function dv(e,t,i){if(i.consumable.consume(t.viewItem,{name:!0})){const e=i.writer,n=e.createElement("listItem"),s=function(e){let t=0,i=e.parent;for(;i;){if(i.is("element","li"))t++;else{const e=i.previousSibling;e&&e.is("element","li")&&t++}i=i.parent}return t}(t.viewItem);e.setAttribute("listIndent",s,n);const o=t.viewItem.parent&&"ol"==t.viewItem.parent.name?"numbered":"bulleted";if(e.setAttribute("listType",o,n),!i.safeInsert(n,t.modelCursor))return;const r=function(e,t,i){const{writer:n,schema:s}=i;let o=n.createPositionAfter(e);for(const r of t)if("ul"==r.name||"ol"==r.name)o=i.convertItem(r,o).modelCursor;else{const t=i.convertItem(r,n.createPositionAt(e,"end")),a=t.modelRange.start.nodeAfter;a&&a.is("element")&&!s.checkChild(e,a.name)&&(e=t.modelCursor.parent.is("element","listItem")?t.modelCursor.parent:fv(t.modelCursor),o=n.createPositionAfter(e))}return o}(n,t.viewItem.getChildren(),i);t.modelRange=e.createRange(t.modelCursor,r),i.updateConversionResult(n,t)}}function uv(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")||wv(t))&&t._remove()}}}function hv(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&&!wv(t)&&t._remove(),wv(t)&&(i=!0)}}function mv(e){return(t,i)=>{if(i.isPhantom)return;const n=i.modelPosition.nodeBefore;if(n&&n.is("element","listItem")){const t=i.mapper.toViewElement(n),s=t.getAncestors().find(wv),o=e.createPositionAt(t,0).getWalker();for(const e of o){if("elementStart"==e.type&&e.item.is("element","li")){i.viewPosition=e.previousPosition;break}if("elementEnd"==e.type&&e.item==s){i.viewPosition=e.nextPosition;break}}}}}function gv(e,[t,i]){let n,s=t.is("documentFragment")?t.getChild(0):t;if(n=i?this.createSelection(i):this.document.selection,s&&s.is("element","listItem")){const e=n.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(;s&&s.is("element","listItem");)s._setAttribute("listIndent",s.getAttribute("listIndent")+e),s=s.nextSibling}}}function fv(e){const t=new Da({startPosition:e});let i;do{i=t.next()}while(!i.value.item.is("element","listItem"));return i.value.item}function pv(e,t,i,n,s,o){const r=Zb(t.nodeBefore,{sameIndent:!0,smallerIndent:!0,listIndent:e,foo:"b"}),a=s.mapper,l=s.writer,c=r?r.getAttribute("listIndent"):null;let d;if(r)if(c==e){const e=a.toViewElement(r).parent;d=l.createPositionAfter(e)}else{const e=o.createPositionAt(r,"end");d=a.toViewPosition(e)}else d=i;d=Qb(d);for(const e of[...n.getChildren()])wv(e)&&(d=l.move(l.createRangeOn(e),d).end,Yb(l,e,e.nextSibling),Yb(l,e.previousSibling,e))}function wv(e){return e.is("element","ol")||e.is("element","ul")}class bv extends ut{static get pluginName(){return"ListEditing"}static get requires(){return[ug,Nm]}init(){const e=this.editor;e.model.schema.register("listItem",{inheritAllFrom:"$block",allowAttributes:["listType","listIndent"]});const t=e.data,i=e.editing;var n;e.model.document.registerPostFixer((t=>function(e,t){const i=e.document.differ.getChanges(),n=new Map;let s=!1;for(const n of i)if("insert"==n.type&&"listItem"==n.name)o(n.position);else if("insert"==n.type&&"listItem"!=n.name){if("$text"!=n.name){const i=n.position.nodeAfter;i.hasAttribute("listIndent")&&(t.removeAttribute("listIndent",i),s=!0),i.hasAttribute("listType")&&(t.removeAttribute("listType",i),s=!0),i.hasAttribute("listStyle")&&(t.removeAttribute("listStyle",i),s=!0),i.hasAttribute("listReversed")&&(t.removeAttribute("listReversed",i),s=!0),i.hasAttribute("listStart")&&(t.removeAttribute("listStart",i),s=!0);for(const t of Array.from(e.createRangeIn(i)).filter((e=>e.item.is("element","listItem"))))o(t.previousPosition)}o(n.position.getShiftedBy(n.length))}else"remove"==n.type&&"listItem"==n.name?o(n.position):("attribute"==n.type&&"listIndent"==n.attributeKey||"attribute"==n.type&&"listType"==n.attributeKey)&&o(n.range.start);for(const e of n.values())r(e),a(e);return s;function o(e){const t=e.nodeBefore;if(t&&t.is("element","listItem")){let e=t;if(n.has(e))return;for(let t=e.previousSibling;t&&t.is("element","listItem");t=e.previousSibling)if(e=t,n.has(e))return;n.set(t,e)}else{const t=e.nodeAfter;t&&t.is("element","listItem")&&n.set(t,t)}}function r(e){let i=0,n=null;for(;e&&e.is("element","listItem");){const o=e.getAttribute("listIndent");if(o>i){let r;null===n?(n=o-i,r=i):(n>o&&(n=o),r=o-n),t.setAttribute("listIndent",r,e),s=!0}else n=null,i=e.getAttribute("listIndent")+1;e=e.nextSibling}}function a(e){let i=[],n=null;for(;e&&e.is("element","listItem");){const o=e.getAttribute("listIndent");if(n&&n.getAttribute("listIndent")>o&&(i=i.slice(0,o+1)),0!=o)if(i[o]){const n=i[o];e.getAttribute("listType")!=n&&(t.setAttribute("listType",n,e),s=!0)}else i[o]=e.getAttribute("listType");n=e,e=e.nextSibling}}}(e.model,t))),i.mapper.registerViewToModelLength("li",vv),t.mapper.registerViewToModelLength("li",vv),i.mapper.on("modelToViewPosition",mv(i.view)),i.mapper.on("viewToModelPosition",(n=e.model,(e,t)=>{const i=t.viewPosition,s=i.parent,o=t.mapper;if("ul"==s.name||"ol"==s.name){if(i.isAtEnd){const e=o.toModelElement(i.nodeBefore),s=o.getModelLength(i.nodeBefore);t.modelPosition=n.createPositionBefore(e).getShiftedBy(s)}else{const e=o.toModelElement(i.nodeAfter);t.modelPosition=n.createPositionBefore(e)}e.stop()}else if("li"==s.name&&i.nodeBefore&&("ul"==i.nodeBefore.name||"ol"==i.nodeBefore.name)){const r=o.toModelElement(s);let a=1,l=i.nodeBefore;for(;l&&wv(l);)a+=o.getModelLength(l),l=l.previousSibling;t.modelPosition=n.createPositionBefore(r).getShiftedBy(a),e.stop()}})),t.mapper.on("modelToViewPosition",mv(i.view)),e.conversion.for("editingDowncast").add((t=>{t.on("insert",lv,{priority:"high"}),t.on("insert:listItem",ov(e.model)),t.on("attribute:listType:listItem",rv,{priority:"high"}),t.on("attribute:listType:listItem",av,{priority:"low"}),t.on("attribute:listIndent:listItem",function(e){return(t,i,n)=>{if(!n.consumable.consume(i.item,"attribute:listIndent"))return;const s=n.mapper.toViewElement(i.item),o=n.writer;o.breakContainer(o.createPositionBefore(s)),o.breakContainer(o.createPositionAfter(s));const r=s.parent,a=r.previousSibling,l=o.createRangeOn(r);o.remove(l),a&&a.nextSibling&&Yb(o,a,a.nextSibling),pv(i.attributeOldValue+1,i.range.start,l.start,s,n,e),Jb(i.item,s,n,e);for(const e of i.item.getChildren())n.consumable.consume(e,"insert")}}(e.model)),t.on("remove:listItem",function(e){return(t,i,n)=>{const s=n.mapper.toViewPosition(i.position).getLastMatchingPosition((e=>!e.item.is("element","li"))).nodeAfter,o=n.writer;o.breakContainer(o.createPositionBefore(s)),o.breakContainer(o.createPositionAfter(s));const r=s.parent,a=r.previousSibling,l=o.createRangeOn(r),c=o.remove(l);a&&a.nextSibling&&Yb(o,a,a.nextSibling),pv(n.mapper.toModelElement(s).getAttribute("listIndent")+1,i.position,l.start,s,n,e);for(const e of o.createRangeIn(c).getItems())n.mapper.unbindViewElement(e);t.stop()}}(e.model)),t.on("remove",cv,{priority:"low"})})),e.conversion.for("dataDowncast").add((t=>{t.on("insert",lv,{priority:"high"}),t.on("insert:listItem",ov(e.model))})),e.conversion.for("upcast").add((e=>{e.on("element:ul",uv,{priority:"high"}),e.on("element:ol",uv,{priority:"high"}),e.on("element:li",hv,{priority:"high"}),e.on("element:li",dv)})),e.model.on("insertContent",gv,{priority:"high"}),e.commands.add("numberedList",new Ub(e,"numbered")),e.commands.add("bulletedList",new Ub(e,"bulleted")),e.commands.add("indentList",new Kb(e,"forward")),e.commands.add("outdentList",new Kb(e,"backward"));const s=i.view.document;this.listenTo(s,"enter",((e,t)=>{const i=this.editor.model.document,n=i.selection.getLastPosition().parent;i.selection.isCollapsed&&"listItem"==n.name&&n.isEmpty&&(this.editor.execute("outdentList"),t.preventDefault(),e.stop())}),{context:"li"}),this.listenTo(s,"delete",((e,t)=>{if("backward"!==t.direction)return;const i=this.editor.model.document.selection;if(!i.isCollapsed)return;const n=i.getFirstPosition();if(!n.isAtStart)return;const s=n.parent;if("listItem"!==s.name)return;s.previousSibling&&"listItem"===s.previousSibling.name||(this.editor.execute("outdentList"),t.preventDefault(),e.stop())}),{context:"li"}),this.listenTo(e.editing.view.document,"tab",((t,i)=>{const n=i.shiftKey?"outdentList":"indentList";this.editor.commands.get(n).isEnabled&&(e.execute(n),i.stopPropagation(),i.preventDefault(),t.stop())}),{context:"li"})}afterInit(){const e=this.editor.commands,t=e.get("indent"),i=e.get("outdent");t&&t.registerChildCommand(e.get("indentList")),i&&i.registerChildCommand(e.get("outdentList"))}}function vv(e){let t=1;for(const i of e.getChildren())if("ul"==i.name||"ol"==i.name)for(const e of i.getChildren())t+=vv(e);return t}const _v=' ',yv=' ';class kv extends ut{static get pluginName(){return"ListUI"}init(){const e=this.editor.t;Xb(this.editor,"numberedList",e("Numbered List"),_v),Xb(this.editor,"bulletedList",e("Bulleted List"),yv)}}class Cv extends mt{constructor(e,t){super(e),this._defaultType=t}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){this._tryToConvertItemsToList(e);const t=this.editor.model,i=tv(t);i.length&&t.change((t=>{for(const n of i)t.setAttribute("listStyle",e.type||this._defaultType,n)}))}_getValue(){const e=this.editor.model.document.selection.getFirstPosition().parent;return e&&e.is("element","listItem")?e.getAttribute("listStyle"):null}_checkEnabled(){const e=this.editor,t=e.commands.get("numberedList"),i=e.commands.get("bulletedList");return t.isEnabled||i.isEnabled}_tryToConvertItemsToList(e){if(!e.type)return;const t=(i=e.type,iv.includes(i)?"bulleted":nv.includes(i)?"numbered":null);var i;if(!t)return;const n=this.editor,s=t+"List";n.commands.get(s).value||n.execute(s)}}class Av extends mt{refresh(){const e=this._getValue();this.value=e,this.isEnabled=null!=e}execute(e={}){const t=this.editor.model,i=tv(t).filter((e=>"numbered"==e.getAttribute("listType")));t.change((t=>{for(const n of i)t.setAttribute("listReversed",!!e.reversed,n)}))}_getValue(){const e=this.editor.model.document.selection.getFirstPosition().parent;return e&&e.is("element","listItem")&&"numbered"==e.getAttribute("listType")?e.getAttribute("listReversed"):null}}class xv extends mt{refresh(){const e=this._getValue();this.value=e,this.isEnabled=null!=e}execute(e={}){const t=this.editor.model,i=tv(t).filter((e=>"numbered"==e.getAttribute("listType")));t.change((t=>{for(const n of i)t.setAttribute("listStart",e.startIndex||1,n)}))}_getValue(){const e=this.editor.model.document.selection.getFirstPosition().parent;return e&&e.is("element","listItem")&&"numbered"==e.getAttribute("listType")?e.getAttribute("listStart"):null}}const Tv="default";class Ev extends ut{static get requires(){return[bv]}static get pluginName(){return"ListPropertiesEditing"}constructor(e){super(e),e.config.define("list",{properties:{styles:!0,startIndex:!1,reversed:!1}})}init(){const e=this.editor,t=e.model,i=function(e){const t=[];e.styles&&t.push({attributeName:"listStyle",defaultValue:Tv,addCommand(e){e.commands.add("listStyle",new Cv(e,Tv))},appliesToListItem:()=>!0,setAttributeOnDowncast(e,t,i){t&&t!==Tv?e.setStyle("list-style-type",t,i):e.removeStyle("list-style-type",i)},getAttributeOnUpcast:e=>e.getStyle("list-style-type")||Tv});e.reversed&&t.push({attributeName:"listReversed",defaultValue:!1,addCommand(e){e.commands.add("listReversed",new Av(e))},appliesToListItem:e=>"numbered"==e.getAttribute("listType"),setAttributeOnDowncast(e,t,i){t?e.setAttribute("reversed","reversed",i):e.removeAttribute("reversed",i)},getAttributeOnUpcast:e=>e.hasAttribute("reversed")});e.startIndex&&t.push({attributeName:"listStart",defaultValue:1,addCommand(e){e.commands.add("listStart",new xv(e))},appliesToListItem:e=>"numbered"==e.getAttribute("listType"),setAttributeOnDowncast(e,t,i){1!=t?e.setAttribute("start",t,i):e.removeAttribute("start",i)},getAttributeOnUpcast:e=>e.getAttribute("start")||1});return t}(e.config.get("list.properties"));t.schema.extend("listItem",{allowAttributes:i.map((e=>e.attributeName))});for(const t of i)t.addCommand(e);var n;this.listenTo(e.commands.get("indentList"),"_executeCleanup",function(e,t){return(i,n)=>{const s=n[0],o=s.getAttribute("listIndent"),r=n.filter((e=>e.getAttribute("listIndent")===o));let a=null;s.previousSibling.getAttribute("listIndent")+1!==o&&(a=Zb(s.previousSibling,{sameIndent:!0,direction:"backward",listIndent:o})),e.model.change((e=>{for(const i of r)for(const n of t)if(n.appliesToListItem(i)){const t=null==a?n.defaultValue:a.getAttribute(n.attributeName);e.setAttribute(n.attributeName,t,i)}}))}}(e,i)),this.listenTo(e.commands.get("outdentList"),"_executeCleanup",function(e,t){return(i,n)=>{if(!(n=n.reverse().filter((e=>e.is("element","listItem")))).length)return;const s=n[0].getAttribute("listIndent"),o=n[0].getAttribute("listType");let r=n[0].previousSibling;if(r.is("element","listItem"))for(;r.getAttribute("listIndent")!==s;)r=r.previousSibling;else r=null;r||(r=n[n.length-1].nextSibling),r&&r.is("element","listItem")&&r.getAttribute("listType")===o&&e.model.change((e=>{const i=n.filter((e=>e.getAttribute("listIndent")===s));for(const n of i)for(const i of t)if(i.appliesToListItem(n)){const t=i.attributeName,s=r.getAttribute(t);e.setAttribute(t,s,n)}}))}}(e,i)),this.listenTo(e.commands.get("bulletedList"),"_executeCleanup",Iv(e)),this.listenTo(e.commands.get("numberedList"),"_executeCleanup",Iv(e)),t.document.registerPostFixer(function(e,t){return i=>{let n=!1;const s=Rv(e.model.document.differ.getChanges()).filter((e=>"todo"!==e.getAttribute("listType")));if(!s.length)return n;let o=s[s.length-1].nextSibling;if((!o||!o.is("element","listItem"))&&(o=s[0].previousSibling,o)){const e=s[0].getAttribute("listIndent");for(;o.is("element","listItem")&&o.getAttribute("listIndent")!==e&&(o=o.previousSibling,o););}for(const e of t){const t=e.attributeName;for(const r of s)if(e.appliesToListItem(r))if(r.hasAttribute(t)){const s=r.previousSibling;Sv(s,r,e.attributeName)&&(i.setAttribute(t,s.getAttribute(t),r),n=!0)}else Pv(o,r,e)?i.setAttribute(t,o.getAttribute(t),r):i.setAttribute(t,e.defaultValue,r),n=!0;else i.removeAttribute(t,r)}return n}}(e,i)),e.conversion.for("upcast").add((n=i,e=>{e.on("element:li",((e,t,i)=>{const s=t.viewItem.parent;if(!s)return;const o=t.modelRange.start.nodeAfter||t.modelRange.end.nodeBefore;for(const e of n)if(e.appliesToListItem(o)){const t=e.getAttributeOnUpcast(s);i.writer.setAttribute(e.attributeName,t,o)}}),{priority:"low"})})),e.conversion.for("downcast").add(function(e){return i=>{for(const n of e)i.on(`attribute:${n.attributeName}:listItem`,((e,i,s)=>{const o=s.writer,r=i.item,a=Zb(r.previousSibling,{sameIndent:!0,listIndent:r.getAttribute("listIndent"),direction:"backward"}),l=s.mapper.toViewElement(r);t(r,a)||o.breakContainer(o.createPositionBefore(l)),n.setAttributeOnDowncast(o,i.attributeNewValue,l.parent)}),{priority:"low"})};function t(e,t){return t&&e.getAttribute("listType")===t.getAttribute("listType")&&e.getAttribute("listIndent")===t.getAttribute("listIndent")&&e.getAttribute("listStyle")===t.getAttribute("listStyle")&&e.getAttribute("listReversed")===t.getAttribute("listReversed")&&e.getAttribute("listStart")===t.getAttribute("listStart")}}(i)),this._mergeListAttributesWhileMergingLists(i)}afterInit(){const e=this.editor;e.commands.get("todoList")&&e.model.document.registerPostFixer(function(e){return t=>{const i=Rv(e.model.document.differ.getChanges()).filter((e=>"todo"===e.getAttribute("listType")&&(e.hasAttribute("listStyle")||e.hasAttribute("listReversed")||e.hasAttribute("listStart"))));if(!i.length)return!1;for(const e of i)t.removeAttribute("listStyle",e),t.removeAttribute("listReversed",e),t.removeAttribute("listStart",e);return!0}}(e))}_mergeListAttributesWhileMergingLists(e){const t=this.editor.model;let i;this.listenTo(t,"deleteContent",((e,[t])=>{const n=t.getFirstPosition(),s=t.getLastPosition();if(n.parent===s.parent)return;if(!n.parent.is("element","listItem"))return;const o=s.parent.nextSibling;if(!o||!o.is("element","listItem"))return;const r=Zb(n.parent,{sameIndent:!0,listIndent:o.getAttribute("listIndent")});r&&r.getAttribute("listType")===o.getAttribute("listType")&&(i=r)}),{priority:"high"}),this.listenTo(t,"deleteContent",(()=>{i&&(t.change((t=>{const n=Zb(i.nextSibling,{sameIndent:!0,listIndent:i.getAttribute("listIndent"),direction:"forward"});if(!n)return void(i=null);const s=[n,...ev(t.createPositionAt(n,0),"forward")];for(const n of s)for(const s of e)if(s.appliesToListItem(n)){const e=s.attributeName,o=i.getAttribute(e);t.setAttribute(e,o,n)}})),i=null)}),{priority:"low"})}}function Pv(e,t,i){if(!e)return!1;const n=e.getAttribute(i.attributeName);return!!n&&(n!=i.defaultValue&&e.getAttribute("listType")===t.getAttribute("listType"))}function Sv(e,t,i){if(!e||!e.is("element","listItem"))return!1;if(t.getAttribute("listType")!==e.getAttribute("listType"))return!1;const n=e.getAttribute("listIndent");if(n<1||n!==t.getAttribute("listIndent"))return!1;const s=e.getAttribute(i);return!(!s||s===t.getAttribute(i))}function Iv(e){return(t,i)=>{i=i.filter((e=>e.is("element","listItem"))),e.model.change((e=>{for(const t of i)e.removeAttribute("listStyle",t)}))}}function Rv(e){const t=[];for(const i of e){const e=Vv(i);e&&e.is("element","listItem")&&t.push(e)}return t}function Vv(e){return"attribute"===e.type?e.range.start.nodeAfter:"insert"===e.type?e.position.nodeAfter:null}class Ov extends Vd{constructor(e,t){super(e);const i=this.bindTemplate;this.set("isCollapsed",!1),this.set("label",""),this.buttonView=this._createButtonView(),this.children=this.createCollection(),this.set("_collapsibleAriaLabelUid"),t&&this.children.addMany(t),this.setTemplate({tag:"div",attributes:{class:["ck","ck-collapsible",i.if("isCollapsed","ck-collapsible_collapsed")]},children:[this.buttonView,{tag:"div",attributes:{class:["ck","ck-collapsible__children"],role:"region",hidden:i.if("isCollapsed","hidden"),"aria-labelledby":i.to("_collapsibleAriaLabelUid")},children:this.children}]})}render(){super.render(),this._collapsibleAriaLabelUid=this.buttonView.labelView.element.id}_createButtonView(){const e=new iu(this.locale),t=e.bindTemplate;return e.set({withText:!0,icon:hu}),e.extendTemplate({attributes:{"aria-expanded":t.to("isOn",(e=>String(e)))}}),e.bind("label").to(this),e.bind("isOn").to(this,"isCollapsed",(e=>!e)),e.on("execute",(()=>{this.isCollapsed=!this.isCollapsed})),e}}class Bv extends Vd{constructor(e,{enabledProperties:t,styleButtonViews:i,styleGridAriaLabel:n}){super(e);const s=["ck","ck-list-properties"];this.children=this.createCollection(),this.stylesView=null,this.additionalPropertiesCollapsibleView=null,this.startIndexFieldView=null,this.reversedSwitchButtonView=null,this.focusTracker=new Ea,this.keystrokes=new Pa,this.focusables=new Rd,this.focusCycler=new cu({focusables:this.focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),t.styles?(this.stylesView=this._createStylesView(i,n),this.children.add(this.stylesView)):s.push("ck-list-properties_without-styles"),(t.startIndex||t.reversed)&&(this._addNumberedListPropertyViews(t,i),s.push("ck-list-properties_with-numbered-properties")),this.setTemplate({tag:"div",attributes:{class:s},children:this.children})}render(){if(super.render(),this.stylesView){for(const e of this.stylesView.children)this.focusables.add(e),this.focusTracker.add(e.element);(this.startIndexFieldView||this.reversedSwitchButtonView)&&(this.focusables.add(this.children.last.buttonView),this.focusTracker.add(this.children.last.buttonView.element))}if(this.startIndexFieldView){this.focusables.add(this.startIndexFieldView),this.focusTracker.add(this.startIndexFieldView.element),this.listenTo(this.startIndexFieldView.element,"selectstart",((e,t)=>{t.stopPropagation()}),{priority:"high"});const e=e=>e.stopPropagation();this.keystrokes.set("arrowright",e),this.keystrokes.set("arrowleft",e),this.keystrokes.set("arrowup",e),this.keystrokes.set("arrowdown",e)}this.reversedSwitchButtonView&&(this.focusables.add(this.reversedSwitchButtonView),this.focusTracker.add(this.reversedSwitchButtonView.element)),this.keystrokes.listenTo(this.element)}focus(){this.focusCycler.focusFirst()}focusLast(){this.focusCycler.focusLast()}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}_createStylesView(e,t){const i=new Vd(this.locale);return i.children=i.createCollection(this.locale),i.children.addMany(e),i.setTemplate({tag:"div",attributes:{"aria-label":t,class:["ck","ck-list-styles-list"]},children:i.children}),i.children.delegate("execute").to(this),i}_addNumberedListPropertyViews(e){const t=this.locale.t,i=[];e.startIndex&&(this.startIndexFieldView=this._createStartIndexField(),i.push(this.startIndexFieldView)),e.reversed&&(this.reversedSwitchButtonView=this._createReversedSwitchButton(),i.push(this.reversedSwitchButtonView)),e.styles?(this.additionalPropertiesCollapsibleView=new Ov(this.locale,i),this.additionalPropertiesCollapsibleView.set({label:t("List properties"),isCollapsed:!0}),this.additionalPropertiesCollapsibleView.buttonView.bind("isEnabled").toMany(i,"isEnabled",((...e)=>e.some((e=>e)))),this.additionalPropertiesCollapsibleView.buttonView.on("change:isEnabled",((e,t,i)=>{i||(this.additionalPropertiesCollapsibleView.isCollapsed=!0)})),this.children.add(this.additionalPropertiesCollapsibleView)):this.children.addMany(i)}_createStartIndexField(){const e=this.locale.t,t=new ju(this.locale,Uu);return t.set({label:e("Start at"),class:"ck-numbered-list-properties__start-index"}),t.fieldView.set({min:1,step:1,value:1,inputMode:"numeric"}),t.fieldView.on("input",(()=>{const i=t.fieldView.element,n=i.valueAsNumber;Number.isNaN(n)||(i.checkValidity()?this.fire("listStart",{startIndex:n}):t.errorText=e("Start index must be greater than 0."))})),t}_createReversedSwitchButton(){const e=this.locale.t,t=new nu(this.locale);return t.set({withText:!0,label:e("Reversed order"),class:"ck-numbered-list-properties__reversed-order"}),t.delegate("execute").to(this,"listReversed"),t}}class Mv extends ut{static get pluginName(){return"ListPropertiesUI"}init(){const e=this.editor,t=e.locale.t,i=e.config.get("list.properties");i.styles&&e.ui.componentFactory.add("bulletedList",Nv({editor:e,parentCommandName:"bulletedList",buttonLabel:t("Bulleted List"),buttonIcon:yv,styleGridAriaLabel:t("Bulleted list styles toolbar"),styleDefinitions:[{label:t("Toggle the disc list style"),tooltip:t("Disc"),type:"disc",icon:' '},{label:t("Toggle the circle list style"),tooltip:t("Circle"),type:"circle",icon:' '},{label:t("Toggle the square list style"),tooltip:t("Square"),type:"square",icon:' '}]})),(i.styles||i.startIndex||i.reversed)&&e.ui.componentFactory.add("numberedList",Nv({editor:e,parentCommandName:"numberedList",buttonLabel:t("Numbered List"),buttonIcon:_v,styleGridAriaLabel:t("Numbered list styles toolbar"),styleDefinitions:[{label:t("Toggle the decimal list style"),tooltip:t("Decimal"),type:"decimal",icon:' '},{label:t("Toggle the decimal with leading zero list style"),tooltip:t("Decimal with leading zero"),type:"decimal-leading-zero",icon:' '},{label:t("Toggle the lower–roman list style"),tooltip:t("Lower–roman"),type:"lower-roman",icon:' '},{label:t("Toggle the upper–roman list style"),tooltip:t("Upper-roman"),type:"upper-roman",icon:' '},{label:t("Toggle the lower–latin list style"),tooltip:t("Lower-latin"),type:"lower-latin",icon:' '},{label:t("Toggle the upper–latin list style"),tooltip:t("Upper-latin"),type:"upper-latin",icon:' '}]}))}}function Nv({editor:e,parentCommandName:t,buttonLabel:i,buttonIcon:n,styleGridAriaLabel:s,styleDefinitions:o}){const r=e.commands.get(t);return a=>{const l=Iu(a,gu),c=l.buttonView;l.bind("isEnabled").to(r),l.class="ck-list-styles-dropdown",c.on("execute",(()=>{e.execute(t),e.editing.view.focus()})),c.set({label:i,icon:n,tooltip:!0,isToggleable:!0}),c.bind("isOn").to(r,"value",(e=>!!e));const d=function({editor:e,dropdownView:t,parentCommandName:i,styleDefinitions:n,styleGridAriaLabel:s}){const o=e.locale,r=e.config.get("list.properties");let a;"numberedList"!=i&&(r.startIndex=!1,r.reversed=!1);if(r.styles){const t=e.commands.get("listStyle"),s=function({editor:e,listStyleCommand:t,parentCommandName:i}){const n=e.locale,s=e.commands.get(i);return({label:i,type:o,icon:r,tooltip:a})=>{const l=new iu(n);return l.set({label:i,icon:r,tooltip:a}),t.on("change:value",(()=>{l.isOn=t.value===o})),l.on("execute",(()=>{s.value?t.value!==o?e.execute("listStyle",{type:o}):e.execute("listStyle",{type:t._defaultType}):e.model.change((()=>{e.execute("listStyle",{type:o})})),e.editing.view.focus()})),l}}({editor:e,parentCommandName:i,listStyleCommand:t}),o="function"==typeof t.isStyleTypeSupported?e=>t.isStyleTypeSupported(e.type):()=>!0;a=n.filter(o).map(s)}const l=new Bv(o,{styleGridAriaLabel:s,enabledProperties:r,styleButtonViews:a});if(r.startIndex){const t=e.commands.get("listStart");l.startIndexFieldView.bind("isEnabled").to(t),l.startIndexFieldView.fieldView.bind("value").to(t),l.on("listStart",((t,i)=>e.execute("listStart",i)))}if(r.reversed){const t=e.commands.get("listReversed");l.reversedSwitchButtonView.bind("isEnabled").to(t),l.reversedSwitchButtonView.bind("isOn").to(t,"value"),l.on("listReversed",(()=>{const i=t.value;e.execute("listReversed",{reversed:!i})}))}return l.delegate("execute").to(t),l}({editor:e,dropdownView:l,parentCommandName:t,styleGridAriaLabel:s,styleDefinitions:o});return l.panelView.children.add(d),l}}function Dv(e,t){return e=>{e.on("attribute:url:media",i)};function i(i,n,s){if(!s.consumable.consume(n.item,i.name))return;const o=n.attributeNewValue,r=s.writer,a=s.mapper.toViewElement(n.item),l=[...a.getChildren()].find((e=>e.getCustomProperty("media-content")));r.remove(l);const c=e.getMediaViewElement(r,o,t);r.insert(r.createPositionAt(a,0),c)}}function zv(e,t,i,n){return e.createContainerElement("figure",{class:"media"},[t.getMediaViewElement(e,i,n),e.createSlot()])}function Lv(e){const t=e.getSelectedElement();return t&&t.is("element","media")?t:null}function Fv(e,t,i,n){e.change((s=>{const o=s.createElement("media",{url:t});e.insertObject(o,i,null,{setSelection:"on",findOptimalPosition:n})}))}class Hv extends mt{refresh(){const e=this.editor.model,t=e.document.selection,i=Lv(t);this.value=i?i.getAttribute("url"):null,this.isEnabled=function(e){const t=e.getSelectedElement();return!!t&&"media"===t.name}(t)||function(e,t){let i=qg(e,t).start.parent;i.isEmpty&&!t.schema.isLimit(i)&&(i=i.parent);return t.schema.checkChild(i,"media")}(t,e)}execute(e){const t=this.editor.model,i=t.document.selection,n=Lv(i);n?t.change((t=>{t.setAttribute("url",e,n)})):Fv(t,e,i,!0)}}class jv{constructor(e,t){const i=t.providers,n=t.extraProviders||[],s=new Set(t.removeProviders),o=i.concat(n).filter((e=>{const t=e.name;return t?!s.has(t):(c("media-embed-no-provider-name",{provider:e}),!1)}));this.locale=e,this.providerDefinitions=o}hasMedia(e){return!!this._getMedia(e)}getMediaViewElement(e,t,i){return this._getMedia(t).getViewElement(e,i)}_getMedia(e){if(!e)return new Wv(this.locale);e=e.trim();for(const t of this.providerDefinitions){const i=t.html,n=Pn(t.url);for(const t of n){const n=this._getUrlMatches(e,t);if(n)return new Wv(this.locale,e,n,i)}}return null}_getUrlMatches(e,t){let i=e.match(t);if(i)return i;let n=e.replace(/^https?:\/\//,"");return i=n.match(t),i||(n=n.replace(/^www\./,""),i=n.match(t),i||null)}}class Wv{constructor(e,t,i,n){this.url=this._getValidUrl(t),this._t=e.t,this._match=i,this._previewRenderer=n}getViewElement(e,t){const i={};let n;if(t.renderForEditingView||t.renderMediaPreview&&this.url&&this._previewRenderer){this.url&&(i["data-oembed-url"]=this.url),t.renderForEditingView&&(i.class="ck-media__wrapper");const s=this._getPreviewHtml(t);n=e.createRawElement("div",i,((e,t)=>{t.setContentOf(e,s)}))}else this.url&&(i.url=this.url),n=e.createEmptyElement(t.elementName,i);return e.setCustomProperty("media-content",!0,n),n}_getPreviewHtml(e){return this._previewRenderer?this._previewRenderer(this._match):this.url&&e.renderForEditingView?this._getPlaceholderHtml():""}_getPlaceholderHtml(){const e=new tu,t=new eu;e.text=this._t("Open media in new tab"),t.content=' ',t.viewBox="0 0 64 42";return new Od({tag:"div",attributes:{class:"ck ck-reset_all ck-media__placeholder"},children:[{tag:"div",attributes:{class:"ck-media__placeholder__icon"},children:[t]},{tag:"a",attributes:{class:"ck-media__placeholder__url",target:"_blank",rel:"noopener noreferrer",href:this.url},children:[{tag:"span",attributes:{class:"ck-media__placeholder__url__text"},children:[this.url]},e]}]}).render().outerHTML}_getValidUrl(e){return e?e.match(/^https?/)?e:"https://"+e:null}}class Uv extends ut{static get pluginName(){return"MediaEmbedEditing"}constructor(e){super(e),e.config.define("mediaEmbed",{elementName:"oembed",providers:[{name:"dailymotion",url:/^dailymotion\.com\/video\/(\w+)/,html:e=>`
`},{name:"spotify",url:[/^open\.spotify\.com\/(artist\/\w+)/,/^open\.spotify\.com\/(album\/\w+)/,/^open\.spotify\.com\/(track\/\w+)/],html:e=>`
`},{name:"youtube",url:[/^(?:m\.)?youtube\.com\/watch\?v=([\w-]+)/,/^(?:m\.)?youtube\.com\/v\/([\w-]+)/,/^youtube\.com\/embed\/([\w-]+)/,/^youtu\.be\/([\w-]+)/],html:e=>`VIDEO
`},{name:"vimeo",url:[/^vimeo\.com\/(\d+)/,/^vimeo\.com\/[^/]+\/[^/]+\/video\/(\d+)/,/^vimeo\.com\/album\/[^/]+\/video\/(\d+)/,/^vimeo\.com\/channels\/[^/]+\/(\d+)/,/^vimeo\.com\/groups\/[^/]+\/videos\/(\d+)/,/^vimeo\.com\/ondemand\/[^/]+\/(\d+)/,/^player\.vimeo\.com\/video\/(\d+)/],html:e=>`
`},{name:"instagram",url:/^instagram\.com\/p\/(\w+)/},{name:"twitter",url:/^twitter\.com/},{name:"googleMaps",url:[/^google\.com\/maps/,/^goo\.gl\/maps/,/^maps\.google\.com/,/^maps\.app\.goo\.gl/]},{name:"flickr",url:/^flickr\.com/},{name:"facebook",url:/^facebook\.com/}]}),this.registry=new jv(e.locale,e.config.get("mediaEmbed"))}init(){const e=this.editor,t=e.model.schema,i=e.t,n=e.conversion,s=e.config.get("mediaEmbed.previewsInData"),o=e.config.get("mediaEmbed.elementName"),r=this.registry;e.commands.add("mediaEmbed",new Hv(e)),t.register("media",{inheritAllFrom:"$blockObject",allowAttributes:["url"]}),n.for("dataDowncast").elementToStructure({model:"media",view:(e,{writer:t})=>{const i=e.getAttribute("url");return zv(t,r,i,{elementName:o,renderMediaPreview:i&&s})}}),n.for("dataDowncast").add(Dv(r,{elementName:o,renderMediaPreview:s})),n.for("editingDowncast").elementToStructure({model:"media",view:(e,{writer:t})=>{const n=e.getAttribute("url");return function(e,t,i){return t.setCustomProperty("media",!0,e),Lg(e,t,{label:i})}(zv(t,r,n,{elementName:o,renderForEditingView:!0}),t,i("media widget"))}}),n.for("editingDowncast").add(Dv(r,{elementName:o,renderForEditingView:!0})),n.for("upcast").elementToElement({view:e=>["oembed",o].includes(e.name)&&e.getAttribute("url")?{name:!0}:null,model:(e,{writer:t})=>{const i=e.getAttribute("url");if(r.hasMedia(i))return t.createElement("media",{url:i})}}).elementToElement({view:{name:"div",attributes:{"data-oembed-url":!0}},model:(e,{writer:t})=>{const i=e.getAttribute("data-oembed-url");if(r.hasMedia(i))return t.createElement("media",{url:i})}}).add((e=>{e.on("element:figure",(function(e,t,i){if(!i.consumable.consume(t.viewItem,{name:!0,classes:"media"}))return;const{modelRange:n,modelCursor:s}=i.convertChildren(t.viewItem,t.modelCursor);t.modelRange=n,t.modelCursor=s;Ta(n.getItems())||i.consumable.revert(t.viewItem,{name:!0,classes:"media"})}))}))}}const qv=/^(?:http(s)?:\/\/)?[\w-]+\.[\w-.~:/?#[\]@!$&'()*+,;=%]+$/;class $v extends ut{static get requires(){return[mf,Nm,Sf]}static get pluginName(){return"AutoMediaEmbed"}constructor(e){super(e),this._timeoutId=null,this._positionToInsert=null}init(){const e=this.editor,t=e.model.document;this.listenTo(e.plugins.get("ClipboardPipeline"),"inputTransformation",(()=>{const e=t.selection.getFirstRange(),i=Gc.fromPosition(e.start);i.stickiness="toPrevious";const n=Gc.fromPosition(e.end);n.stickiness="toNext",t.once("change:data",(()=>{this._embedMediaBetweenPositions(i,n),i.detach(),n.detach()}),{priority:"high"})})),e.commands.get("undo").on("execute",(()=>{this._timeoutId&&(Zo.window.clearTimeout(this._timeoutId),this._positionToInsert.detach(),this._timeoutId=null,this._positionToInsert=null)}),{priority:"high"})}_embedMediaBetweenPositions(e,t){const i=this.editor,n=i.plugins.get(Uv).registry,s=new tl(e,t),o=s.getWalker({ignoreElementEnd:!0});let r="";for(const e of o)e.item.is("$textProxy")&&(r+=e.item.data);if(r=r.trim(),!r.match(qv))return void s.detach();if(!n.hasMedia(r))return void s.detach();i.commands.get("mediaEmbed").isEnabled?(this._positionToInsert=Gc.fromPosition(e),this._timeoutId=Zo.window.setTimeout((()=>{i.model.change((e=>{let t;this._timeoutId=null,e.remove(s),s.detach(),"$graveyard"!==this._positionToInsert.root.rootName&&(t=this._positionToInsert),Fv(i.model,r,t,!1),this._positionToInsert.detach(),this._positionToInsert=null})),i.plugins.get("Delete").requestUndoOnBackspace()}),100)):s.detach()}}class Kv extends Vd{constructor(e,t){super(t);const i=t.t;this.focusTracker=new Ea,this.keystrokes=new Pa,this.set("mediaURLInputValue",""),this.urlInputView=this._createUrlInput(),this.saveButtonView=this._createButton(i("Save"),Ed.check,"ck-button-save"),this.saveButtonView.type="submit",this.saveButtonView.bind("isEnabled").to(this,"mediaURLInputValue",(e=>!!e)),this.cancelButtonView=this._createButton(i("Cancel"),Ed.cancel,"ck-button-cancel","cancel"),this._focusables=new Rd,this._focusCycler=new cu({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this._validators=e,this.setTemplate({tag:"form",attributes:{class:["ck","ck-media-form","ck-responsive-form"],tabindex:"-1"},children:[this.urlInputView,this.saveButtonView,this.cancelButtonView]}),Sd(this)}render(){super.render(),Id({view:this});[this.urlInputView,this.saveButtonView,this.cancelButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)})),this.keystrokes.listenTo(this.element);const e=e=>e.stopPropagation();this.keystrokes.set("arrowright",e),this.keystrokes.set("arrowleft",e),this.keystrokes.set("arrowup",e),this.keystrokes.set("arrowdown",e),this.listenTo(this.urlInputView.element,"selectstart",((e,t)=>{t.stopPropagation()}),{priority:"high"})}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}get url(){return this.urlInputView.fieldView.element.value.trim()}set url(e){this.urlInputView.fieldView.element.value=e.trim()}isValid(){this.resetFormStatus();for(const e of this._validators){const t=e(this);if(t)return this.urlInputView.errorText=t,!1}return!0}resetFormStatus(){this.urlInputView.errorText=null,this.urlInputView.infoText=this._urlInputViewInfoDefault}_createUrlInput(){const e=this.locale.t,t=new ju(this.locale,Wu),i=t.fieldView;return this._urlInputViewInfoDefault=e("Paste the media URL in the input."),this._urlInputViewInfoTip=e("Tip: Paste the URL into the content to embed faster."),t.label=e("Media URL"),t.infoText=this._urlInputViewInfoDefault,i.on("input",(()=>{t.infoText=i.element.value?this._urlInputViewInfoTip:this._urlInputViewInfoDefault,this.mediaURLInputValue=i.element.value.trim()})),t}_createButton(e,t,i,n){const s=new iu(this.locale);return s.set({label:e,icon:t,tooltip:!0}),s.extendTemplate({attributes:{class:i}}),n&&s.delegate("execute").to(this,n),s}}class Gv extends ut{static get requires(){return[Uv]}static get pluginName(){return"MediaEmbedUI"}init(){const e=this.editor,t=e.commands.get("mediaEmbed"),i=e.plugins.get(Uv).registry;e.ui.componentFactory.add("mediaEmbed",(n=>{const s=Iu(n),o=new Kv(function(e,t){return[t=>{if(!t.url.length)return e("The URL must not be empty.")},i=>{if(!t.hasMedia(i.url))return e("This media URL is not supported.")}]}(e.t,i),e.locale);return this._setUpDropdown(s,o,t,e),this._setUpForm(s,o,t),s}))}_setUpDropdown(e,t,i){const n=this.editor,s=n.t,o=e.buttonView;function r(){n.editing.view.focus(),e.isOpen=!1}e.bind("isEnabled").to(i),e.panelView.children.add(t),o.set({label:s("Insert media"),icon:' ',tooltip:!0}),o.on("open",(()=>{t.disableCssTransitions(),t.url=i.value||"",t.urlInputView.fieldView.select(),t.focus(),t.enableCssTransitions()}),{priority:"low"}),e.on("submit",(()=>{t.isValid()&&(n.execute("mediaEmbed",t.url),r())})),e.on("change:isOpen",(()=>t.resetFormStatus())),e.on("cancel",(()=>r()))}_setUpForm(e,t,i){t.delegate("submit","cancel").to(e),t.urlInputView.bind("value").to(i,"value"),t.urlInputView.bind("isReadOnly").to(i,"isEnabled",(e=>!e))}}function Jv(e,t){if(!e.childCount)return;const i=new Ah(e.document),n=function(e,t){const i=t.createRangeIn(e),n=new Hn({name:/^p|h\d+$/,styles:{"mso-list":/.*/}}),s=[];for(const e of i)if("elementStart"===e.type&&n.match(e.item)){const t=Zv(e.item);s.push({element:e.item,id:t.id,order:t.order,indent:t.indent})}return s}(e,i);if(!n.length)return;let s=null,o=1;n.forEach(((e,r)=>{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[r-1],e),l=a?null:n[r-1],c=(u=e,(d=l)?u.indent-d.indent:u.indent-1);var d,u;if(a&&(s=null,o=1),!s||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,s=/mso-level-start-at:\s{0,100}([0-9]{0,10})\s{0,100};/gi,o=i.exec(t);let r="decimal",a="ol",l=null;if(o&&o[1]){const t=n.exec(o[1]);if(t&&t[1]&&(r=t[1].trim(),a="bullet"!==r&&"image"!==r?"ol":"ul"),"bullet"===r){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);return e.is("$text")?e:e.getChild(0)}}(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&&(r=t)}else{const e=s.exec(o[1]);e&&e[1]&&(l=parseInt(e[1]))}}return{type:a,startIndex:l,style:Yv(r)}}(e,t);if(s){if(e.indent>o){const e=s.getChild(s.childCount-1),t=e.getChild(e.childCount-1);s=Qv(n,t,i),o+=1}else if(e.indent1&&i.setAttribute("start",e.startIndex,s),s}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),s=i.match(/\s{0,100}level(\d+)/i);e&&n&&s&&(t.id=e[2],t.order=n[1],t.indent=s[1])}return t}const Xv=/id=("|')docs-internal-guid-[-0-9a-f]+("|')/i;class e_{constructor(e){this.document=e}isActive(e){return Xv.test(e)}execute(e){const t=new Ah(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),e.content=i}}function t_(e,t){if(!e.childCount)return;const i=new Ah,n=function(e,t){const i=t.createRangeIn(e),n=new Hn({name:/v:(.+)/}),s=[];for(const e of i){if("elementStart"!=e.type)continue;const t=e.item,i=t.previousSibling&&t.previousSibling.name||null;n.match(t)&&t.getAttribute("o:gfxdata")&&"v:shapetype"!==i&&s.push(e.item.getAttribute("id"))}return s}(e,i);!function(e,t,i){const n=i.createRangeIn(t),s=new Hn({name:"img"}),o=[];for(const t of n)if(s.match(t.item)){const i=t.item,n=i.getAttribute("v:shapes")?i.getAttribute("v:shapes").split(" "):[];n.length&&n.every((t=>e.indexOf(t)>-1))?o.push(i):i.getAttribute("src")||o.push(i)}for(const e of o)i.remove(e)}(n,e,i),function(e,t){const i=t.createRangeIn(e),n=new Hn({name:/v:(.+)/}),s=[];for(const e of i)"elementStart"==e.type&&n.match(e.item)&&s.push(e.item);for(const e of s)t.remove(e)}(e,i);const s=function(e,t){const i=t.createRangeIn(e),n=new Hn({name:"img"}),s=[];for(const e of i)n.match(e.item)&&e.item.getAttribute("src").startsWith("file://")&&s.push(e.item);return s}(e,i);s.length&&function(e,t,i){if(e.length===t.length)for(let n=0;nString.fromCharCode(parseInt(e,16)))).join(""))}const n_=/ /i,s_=/xmlns:o="urn:schemas-microsoft-com/i;class o_{constructor(e){this.document=e}isActive(e){return n_.test(e)||s_.test(e)}execute(e){const{body:t,stylesString:i}=e._parsedData;Jv(t,i),t_(t,e.dataTransfer.getData("text/rtf")),e.content=t}}function r_(e){return e.replace(/(\s+)<\/span>/g,((e,t)=>1===t.length?" ":Array(t.length+1).join(" ").substr(0,t.length)))}function a_(e,t){const i=new DOMParser,n=function(e){return r_(r_(e)).replace(/([^\S\r\n]*?)[\r\n]+([^\S\r\n]*<\/span>)/g,"$1$2").replace(/<\/span>/g,"").replace(/ <\//g," ").replace(/ <\/o:p>/g," ").replace(/( |\u00A0)<\/o:p>/g,"").replace(/>([^\S\r\n]*[\r\n]\s*)<")}(function(e){const t="