diff --git a/config/locales/js-en.yml b/config/locales/js-en.yml index e0ee4a3050..cac0a762ba 100644 --- a/config/locales/js-en.yml +++ b/config/locales/js-en.yml @@ -499,7 +499,7 @@ en: label_global_queries: "Public views" label_custom_queries: "Private views" label_columns: "Columns" - label_attachments: Files + label_attachments: Attachments label_drop_files: Drop files here label_drop_files_hint: or click to add files label_drop_folders_hint: You cannot upload folders as an attachment. Please select single files. @@ -1072,7 +1072,7 @@ en: activity: Activity relations: Relations watchers: Watchers - attachments: Attachments + files: Files time_relative: days: "days" weeks: "weeks" diff --git a/frontend/src/app/core/state/attachments/attachment.model.ts b/frontend/src/app/core/state/attachments/attachment.model.ts new file mode 100644 index 0000000000..bc04e5bffe --- /dev/null +++ b/frontend/src/app/core/state/attachments/attachment.model.ts @@ -0,0 +1,56 @@ +// -- copyright +// OpenProject is an open source project management software. +// Copyright (C) 2012-2022 the OpenProject GmbH +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License version 3. +// +// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +// Copyright (C) 2006-2013 Jean-Philippe Lang +// Copyright (C) 2010-2013 the ChiliProject Team +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See COPYRIGHT and LICENSE files for more details. +//++ + +import { ID } from '@datorama/akita'; +import { + IFormattable, + IHalResourceLink, + IHalResourceLinks, +} from 'core-app/core/state/hal-resource'; + +export interface IAttachmentHalResourceLinks extends IHalResourceLinks { + self:IHalResourceLink; + delete:IHalResourceLink; + container:IHalResourceLink; + author:IHalResourceLink; + downloadLocation:IHalResourceLink; +} + +export interface IAttachment { + id:ID; + title:string; + fileName:string; + fileSize:number; + description:IFormattable; + contentType:string; + digest:string; + + createdAt:string; + + _links:IAttachmentHalResourceLinks; +} diff --git a/frontend/src/app/core/state/attachments/attachments.service.ts b/frontend/src/app/core/state/attachments/attachments.service.ts new file mode 100644 index 0000000000..4db449ecb6 --- /dev/null +++ b/frontend/src/app/core/state/attachments/attachments.service.ts @@ -0,0 +1,259 @@ +// -- copyright +// OpenProject is an open source project management software. +// Copyright (C) 2012-2022 the OpenProject GmbH +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License version 3. +// +// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +// Copyright (C) 2006-2013 Jean-Philippe Lang +// Copyright (C) 2010-2013 the ChiliProject Team +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See COPYRIGHT and LICENSE files for more details. +//++ + +import { Injectable } from '@angular/core'; +import { + HttpClient, + HttpHeaders, +} from '@angular/common/http'; +import { + applyTransaction, + QueryEntity, +} from '@datorama/akita'; +import { + from, + Observable, +} from 'rxjs'; +import { + catchError, + map, + tap, +} from 'rxjs/operators'; +import { AttachmentsStore } from 'core-app/core/state/attachments/attacments.store'; +import { IAttachment } from 'core-app/core/state/attachments/attachment.model'; +import { IHALCollection } from 'core-app/core/apiv3/types/hal-collection.type'; +import { ToastService } from 'core-app/shared/components/toaster/toast.service'; +import { + OpenProjectFileUploadService, + UploadFile, +} from 'core-app/core/file-upload/op-file-upload.service'; +import { OpenProjectDirectFileUploadService } from 'core-app/core/file-upload/op-direct-file-upload.service'; +import { I18nService } from 'core-app/core/i18n/i18n.service'; +import { HalResource } from 'core-app/features/hal/resources/hal-resource'; +import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service'; +import { HalLink } from 'core-app/features/hal/hal-link/hal-link'; +import isNewResource, { HAL_NEW_RESOURCE_ID } from 'core-app/features/hal/helpers/is-new-resource'; +import { ConfigurationService } from 'core-app/core/config/configuration.service'; +import { insertCollectionIntoState } from 'core-app/core/state/collection-store'; + +@Injectable() +export class AttachmentsResourceService { + protected store = new AttachmentsStore(); + + public query = new QueryEntity(this.store); + + constructor(private readonly I18n:I18nService, + private readonly http:HttpClient, + private readonly apiV3Service:ApiV3Service, + private readonly fileUploadService:OpenProjectFileUploadService, + private readonly directFileUploadService:OpenProjectDirectFileUploadService, + private readonly configurationService:ConfigurationService, + private readonly toastService:ToastService) { } + + /** + * This method ensures that a specific collection is fetched, if not available. + * + * @param key The collection key, of the required collection. + */ + requireCollection(key:string):void { + if (this.store.getValue().collections[key]) { + return; + } + + this.fetchAttachments(key).subscribe(); + } + + /** + * Fetches attachments by the attachment collection self link. + * This link is used as key to store the result collection in the resource store. + * + * @param attachmentsSelfLink The self link of the attachment collection from the parent resource. + */ + fetchAttachments(attachmentsSelfLink:string):Observable> { + return this.http + .get>(attachmentsSelfLink) + .pipe( + tap((collection) => insertCollectionIntoState(this.store, collection, attachmentsSelfLink)), + catchError((error) => { + this.toastService.addError(error); + throw error; + }), + ); + } + + /** + * Sends deletion request and updates the store collection of attachments. + * + * @param collectionKey The identifier of the current attachment collection. + * @param attachment The attachment to be deleted. + */ + removeAttachment(collectionKey:string, attachment:IAttachment):Observable { + const headers = new HttpHeaders({ 'Content-Type': 'application/json' }); + + return this.http + .delete(attachment._links.delete.href, { withCredentials: true, headers }) + .pipe( + tap(() => { + applyTransaction(() => { + this.store.remove(attachment.id); + this.store.update(({ collections }) => ( + { + collections: { + ...collections, + [collectionKey]: { + ...collections[collectionKey], + ids: (collections[collectionKey]?.ids || []).filter((id) => id !== attachment.id), + }, + }, + } + )); + }); + }), + catchError((error) => { + this.toastService.addError(error); + throw error; + }), + ); + } + + /** + * Sends an upload request and updates the store collection of attachments. + * + * @param resource The HAL resource to attach the files to + * @param files The upload files to be attached. + */ + attachFiles(resource:HalResource, files:UploadFile[]):Observable { + const identifier = this.getAttachmentsSelfLink(resource) || HAL_NEW_RESOURCE_ID; + const href = this.getUploadTarget(resource); + const isDirectUpload = !!this.getDirectUploadLink(resource); + + return this + .addAttachments( + identifier, + href, + files, + isDirectUpload, + ); + } + + /** + * Sends an upload request and updates the store collection of attachments. + * + * @param collectionKey The identifier of the current attachment collection. + * @param uploadHref The API target to perform the call against. + * @param files The upload files to be attached. + * @param isDirectUpload whether the provided upload target is a direct upload URL. + */ + addAttachments( + collectionKey:string, + uploadHref:string, + files:UploadFile[], + isDirectUpload = false, + ):Observable { + return this + .uploadAttachments(uploadHref, files, isDirectUpload) + .pipe( + tap((attachments) => { + applyTransaction(() => { + this.store.add(attachments); + this.store.update(({ collections }) => ( + { + collections: { + ...collections, + [collectionKey]: { + ...collections[collectionKey], + ids: (collections[collectionKey]?.ids || []).concat(attachments.map((a) => a.id)), + }, + }, + } + )); + }); + }), + ); + } + + private uploadAttachments(href:string, files:UploadFile[], isDirectUpload:boolean):Observable { + const { uploads, finished } = isDirectUpload + ? this.directFileUploadService.uploadAndMapResponse(href, files) + : this.fileUploadService.uploadAndMapResponse(href, files); + + const message = this.I18n.t('js.label_upload_notification'); + const notification = this.toastService.addAttachmentUpload(message, uploads); + + return from(finished) + .pipe( + tap(() => { + setTimeout(() => this.toastService.remove(notification), 700); + }), + map((result) => result.map(({ response }) => (response as HalResource).$source as IAttachment)), + catchError((error) => { + this.toastService.addError(error); + throw error; + }), + ); + } + + /** + * Get the upload target for a HAL resource, depending on its + * persisted state and available links. + * + * This will be one of the following: + * - The direct upload PREPARE URL endpoint for the resource (if direct upload active + resource persisted) + * - The generic prepare URL endpoint (if direct upload active) + * - The resource's own upload HAL link (if persisted) + * - The generic APIv3 attachments endpoint (new resource, no direct upload) + * + * @param resource The resource we're uploading attachments for. + * @returns {string} The API target URL to perform the upload against. + * @private + */ + private getUploadTarget(resource:HalResource):string { + return this.getDirectUploadLink(resource) + || this.getAttachmentsSelfLink(resource) + || this.apiV3Service.attachments.path; + } + + private getDirectUploadLink(resource:HalResource):string|null { + const links = resource.$links as unknown&{ prepareAttachment:HalLink }; + + if (links.prepareAttachment) { + return links.prepareAttachment.href as string; + } + + if (isNewResource(resource)) { + return this.configurationService.prepareAttachmentURL as string|null; + } + + return null; + } + + private getAttachmentsSelfLink(resource:HalResource):string|null { + const attachments = resource.attachments as unknown&{ href?:string }; + return attachments?.href || null; + } +} diff --git a/frontend/src/app/core/state/attachments/attacments.store.ts b/frontend/src/app/core/state/attachments/attacments.store.ts new file mode 100644 index 0000000000..63ad270526 --- /dev/null +++ b/frontend/src/app/core/state/attachments/attacments.store.ts @@ -0,0 +1,40 @@ +// -- copyright +// OpenProject is an open source project management software. +// Copyright (C) 2012-2022 the OpenProject GmbH +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License version 3. +// +// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +// Copyright (C) 2006-2013 Jean-Philippe Lang +// Copyright (C) 2010-2013 the ChiliProject Team +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See COPYRIGHT and LICENSE files for more details. +//++ + +import { EntityStore, StoreConfig } from '@datorama/akita'; +import { IAttachment } from 'core-app/core/state/attachments/attachment.model'; +import { CollectionState, createInitialCollectionState } from 'core-app/core/state/collection-store'; + +export interface AttachmentsState extends CollectionState {} + +@StoreConfig({ name: 'attachments' }) +export class AttachmentsStore extends EntityStore { + constructor() { + super(createInitialCollectionState()); + } +} diff --git a/frontend/src/app/core/state/collection-store.ts b/frontend/src/app/core/state/collection-store.ts index e609b2c058..b686e40b50 100644 --- a/frontend/src/app/core/state/collection-store.ts +++ b/frontend/src/app/core/state/collection-store.ts @@ -117,7 +117,7 @@ export function insertCollectionIntoState( const ids = collection._embedded.elements?.map((el) => el.id) || []; applyTransaction(() => { - store.add(collection._embedded.elements); + store.upsertMany(collection._embedded.elements); store.update(({ collections }) => ( { collections: { diff --git a/frontend/src/app/core/state/openproject-state.module.ts b/frontend/src/app/core/state/openproject-state.module.ts index b0f45469c3..488f325901 100644 --- a/frontend/src/app/core/state/openproject-state.module.ts +++ b/frontend/src/app/core/state/openproject-state.module.ts @@ -26,9 +26,8 @@ // See docs/COPYRIGHT.rdoc for more details. //++ -import { - NgModule, -} from '@angular/core'; +import { NgModule } from '@angular/core'; +import { AttachmentsResourceService } from 'core-app/core/state/attachments/attachments.service'; import { InAppNotificationsResourceService } from './in-app-notifications/in-app-notifications.service'; import { ProjectsResourceService } from './projects/projects.service'; import { PrincipalsResourceService } from './principals/principals.service'; @@ -36,11 +35,11 @@ import { CapabilitiesResourceService } from 'core-app/core/state/capabilities/ca @NgModule({ providers: [ + AttachmentsResourceService, InAppNotificationsResourceService, ProjectsResourceService, PrincipalsResourceService, CapabilitiesResourceService, ], }) -export class OpenProjectStateModule { -} +export class OpenProjectStateModule {} diff --git a/frontend/src/app/core/state/principals/principals.service.ts b/frontend/src/app/core/state/principals/principals.service.ts index de9c3b04c7..059b702fa7 100644 --- a/frontend/src/app/core/state/principals/principals.service.ts +++ b/frontend/src/app/core/state/principals/principals.service.ts @@ -24,6 +24,7 @@ import { import { ActionsService } from 'core-app/core/state/actions/actions.service'; import { PrincipalsStore } from './principals.store'; import { IPrincipal } from './principal.model'; +import { IUser } from 'core-app/core/state/principals/user.model'; @EffectHandler @Injectable() @@ -44,7 +45,22 @@ export class PrincipalsResourceService { private http:HttpClient, private apiV3Service:ApiV3Service, private toastService:ToastService, - ) { + ) { } + + fetchUser(id:string|number):Observable { + return this.http + .get(this.apiV3Service.users.id(id).path) + .pipe( + tap((data) => { + applyTransaction(() => { + this.store.upsertMany([data]); + }); + }), + catchError((error) => { + this.toastService.addError(error); + throw error; + }), + ); } fetchPrincipals(params:ApiV3ListParameters):Observable> { diff --git a/frontend/src/app/core/state/views/views.service.ts b/frontend/src/app/core/state/views/views.service.ts index 0837c32238..2bcbebb369 100644 --- a/frontend/src/app/core/state/views/views.service.ts +++ b/frontend/src/app/core/state/views/views.service.ts @@ -53,7 +53,7 @@ export class ViewsResourceService { .pipe( tap((events) => { applyTransaction(() => { - this.store.add(events._embedded.elements); + this.store.upsertMany(events._embedded.elements); this.store.update(({ collections }) => ( { collections: { diff --git a/frontend/src/app/features/hal/helpers/is-new-resource.ts b/frontend/src/app/features/hal/helpers/is-new-resource.ts index d7f29ef0e2..be9919898e 100644 --- a/frontend/src/app/features/hal/helpers/is-new-resource.ts +++ b/frontend/src/app/features/hal/helpers/is-new-resource.ts @@ -1,3 +1,5 @@ +export const HAL_NEW_RESOURCE_ID = 'new'; + export default function isNewResource(resource:{ id:string|null }):boolean { - return !resource.id || resource.id === 'new'; + return !resource.id || resource.id === HAL_NEW_RESOURCE_ID; } diff --git a/frontend/src/app/features/plugins/plugin-context.ts b/frontend/src/app/features/plugins/plugin-context.ts index ddf6764447..d83dac5ef1 100644 --- a/frontend/src/app/features/plugins/plugin-context.ts +++ b/frontend/src/app/features/plugins/plugin-context.ts @@ -25,6 +25,7 @@ import { HTMLSanitizeService } from '../../core/html-sanitize/html-sanitize.serv import { DynamicContentModalComponent } from '../../shared/components/modals/modal-wrapper/dynamic-content.modal'; import { PasswordConfirmationModalComponent } from '../../shared/components/modals/request-for-confirmation/password-confirmation.modal'; import { DomAutoscrollService } from 'core-app/shared/helpers/drag-and-drop/dom-autoscroll.service'; +import { AttachmentsResourceService } from 'core-app/core/state/attachments/attachments.service'; /** * Plugin context bridge for plugins outside the CLI compiler context @@ -58,6 +59,7 @@ export class OpenProjectPluginContext { states: this.injector.get(States), apiV3Service: this.injector.get(ApiV3Service), configurationService: this.injector.get(ConfigurationService), + attachmentsResourceService: this.injector.get(AttachmentsResourceService), }; public readonly helpers = { diff --git a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/files-tab/op-files-tab.component.ts b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/files-tab/op-files-tab.component.ts new file mode 100644 index 0000000000..7c46f98da4 --- /dev/null +++ b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/files-tab/op-files-tab.component.ts @@ -0,0 +1,52 @@ +// -- copyright +// OpenProject is an open source project management software. +// Copyright (C) 2012-2022 the OpenProject GmbH +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License version 3. +// +// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +// Copyright (C) 2006-2013 Jean-Philippe Lang +// Copyright (C) 2010-2013 the ChiliProject Team +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See COPYRIGHT and LICENSE files for more details. +//++ + +import { ChangeDetectionStrategy, Component } from '@angular/core'; +import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource'; +import { I18nService } from 'core-app/core/i18n/i18n.service'; +import { HookService } from 'core-app/features/plugins/hook-service'; + +@Component({ + templateUrl: './op-files-tab.html', + changeDetection: ChangeDetectionStrategy.OnPush, + selector: 'op-files-tab', +}) +export class WorkPackageFilesTabComponent { + public workPackage:WorkPackageResource; + + public text = { + attachments: { + label: this.I18n.t('js.label_attachments'), + }, + }; + + constructor( + readonly I18n:I18nService, + protected hook:HookService, + ) { } +} diff --git a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/files-tab/op-files-tab.html b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/files-tab/op-files-tab.html new file mode 100644 index 0000000000..8cab71efd1 --- /dev/null +++ b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/files-tab/op-files-tab.html @@ -0,0 +1,11 @@ +
+
+
+

+
+
+ + + + +
diff --git a/frontend/src/app/features/work-packages/components/wp-single-view/wp-single-view.component.ts b/frontend/src/app/features/work-packages/components/wp-single-view/wp-single-view.component.ts index ab2b8ddb74..a51dd73114 100644 --- a/frontend/src/app/features/work-packages/components/wp-single-view/wp-single-view.component.ts +++ b/frontend/src/app/features/work-packages/components/wp-single-view/wp-single-view.component.ts @@ -129,12 +129,12 @@ export class WorkPackageSingleViewComponent extends UntilDestroyedMixin implemen }, }; + public isNewResource:boolean; + protected firstTimeFocused = false; $element:JQuery; - isNewResource = isNewResource; - constructor(readonly I18n:I18nService, protected currentProject:CurrentProjectService, protected PathHelper:PathHelperService, @@ -152,7 +152,9 @@ export class WorkPackageSingleViewComponent extends UntilDestroyedMixin implemen } public ngOnInit() { - this.$element = jQuery(this.elementRef.nativeElement); + this.$element = jQuery(this.elementRef.nativeElement as HTMLElement); + + this.isNewResource = isNewResource(this.workPackage); const change = this.halEditing.changeFor(this.workPackage); this.resourceContextChange.next(this.contextFrom(change.projectedResource)); @@ -166,7 +168,7 @@ export class WorkPackageSingleViewComponent extends UntilDestroyedMixin implemen distinctUntilChanged((a, b) => _.isEqual(a, b)), map(() => this.halEditing.changeFor(this.workPackage)), ) - .subscribe((change:WorkPackageChangeset) => this.refresh(change)); + .subscribe((changeset:WorkPackageChangeset) => this.refresh(changeset)); // Update the resource context on every update to the temporary resource. // This allows detecting a changed type value in a new work package. @@ -208,7 +210,7 @@ export class WorkPackageSingleViewComponent extends UntilDestroyedMixin implemen * Returns whether a group should be hidden due to being empty * (e.g., consists only of CFs and none of them are active in this project. */ - public shouldHideGroup(group:GroupDescriptor) { + public shouldHideGroup(group:GroupDescriptor):boolean { // Hide if the group is empty const isEmpty = group.members.length === 0; @@ -221,10 +223,10 @@ export class WorkPackageSingleViewComponent extends UntilDestroyedMixin implemen /** * angular 2 doesn't support track by property any more but requires a custom function * https://github.com/angular/angular/issues/12969 - * @param index + * @param _index * @param elem */ - public trackByName(_index:number, elem:{ name:string }) { + public trackByName(_index:number, elem:{ name:string }):string { return elem.name; } @@ -256,8 +258,8 @@ export class WorkPackageSingleViewComponent extends UntilDestroyedMixin implemen /* * Returns the work package label */ - public get idLabel() { - return `#${this.workPackage.id}`; + public get idLabel():string { + return `#${this.workPackage.id || ''}`; } public get projectContextText():string { @@ -337,8 +339,10 @@ export class WorkPackageSingleViewComponent extends UntilDestroyedMixin implemen * combined 'start' and 'due' date field. */ private getDateField(change:WorkPackageChangeset):FieldDescriptor { - const object:any = { + const object:FieldDescriptor = { + name: '', label: this.I18n.t('js.work_packages.properties.date'), + spanAll: false, multiple: false, }; @@ -359,7 +363,7 @@ export class WorkPackageSingleViewComponent extends UntilDestroyedMixin implemen * to the single view. * * @param {WorkPackage} workPackage - * @returns {SchemaContext} + * @returns {ResourceContextChange} */ private contextFrom(workPackage:WorkPackageResource):ResourceContextChange { const schema = this.schema(workPackage); diff --git a/frontend/src/app/features/work-packages/components/wp-single-view/wp-single-view.html b/frontend/src/app/features/work-packages/components/wp-single-view/wp-single-view.html index 375a23f055..923a38ae32 100644 --- a/frontend/src/app/features/work-packages/components/wp-single-view/wp-single-view.html +++ b/frontend/src/app/features/work-packages/components/wp-single-view/wp-single-view.html @@ -3,22 +3,22 @@ [ngClass]="{'work-package--single-view_with-columns': showTwoColumnLayout()}" data-selector="wp-single-view">
+ *ngIf="isNewResource">
- + *ngIf="!isNewResource">
+ *ngIf="!isNewResource"> : /,!0],[/^<\?/,/\?>/,!0],[/^/,!0],[/^/,!0],[new RegExp("^|$))","i"),/^$/,!0],[new RegExp(i.source+"\\s*$"),/^$/,!1]];t.exports=function(t,e,n,o){var i,s,a,c,l=t.bMarks[e]+t.tShift[e],d=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4)return!1;if(!t.md.options.html)return!1;if(60!==t.src.charCodeAt(l))return!1;for(c=t.src.slice(l,d),i=0;i{"use strict";t.exports=function(t,e,n){var o,i,r,s,a,c,l,d,u,h,p=e+1,m=t.md.block.ruler.getRules("paragraph");if(t.sCount[e]-t.blkIndent>=4)return!1;for(h=t.parentType,t.parentType="paragraph";p3)){if(t.sCount[p]>=t.blkIndent&&(c=t.bMarks[p]+t.tShift[p])<(l=t.eMarks[p])&&(45===(u=t.src.charCodeAt(c))||61===u)&&(c=t.skipChars(c,u),(c=t.skipSpaces(c))>=l)){d=61===u?1:2;break}if(!(t.sCount[p]<0)){for(i=!1,r=0,s=m.length;r{"use strict";var o=n(7022).isSpace;function i(t,e){var n,i,r,s;return i=t.bMarks[e]+t.tShift[e],r=t.eMarks[e],42!==(n=t.src.charCodeAt(i++))&&45!==n&&43!==n||i=s)return-1;if((n=t.src.charCodeAt(r++))<48||n>57)return-1;for(;;){if(r>=s)return-1;if(!((n=t.src.charCodeAt(r++))>=48&&n<=57)){if(41===n||46===n)break;return-1}if(r-i>=10)return-1}return r=4)return!1;if(t.listIndent>=0&&t.sCount[e]-t.listIndent>=4&&t.sCount[e]=t.blkIndent&&(z=!0),(S=r(t,e))>=0){if(h=!0,T=t.bMarks[e]+t.tShift[e],k=Number(t.src.slice(T,S-1)),z&&1!==k)return!1}else{if(!((S=i(t,e))>=0))return!1;h=!1}if(z&&t.skipSpaces(S)>=t.eMarks[e])return!1;if(b=t.src.charCodeAt(S-1),o)return!0;for(f=t.tokens.length,h?(R=t.push("ordered_list_open","ol",1),1!==k&&(R.attrs=[["start",k]])):R=t.push("bullet_list_open","ul",1),R.map=g=[e,0],R.markup=String.fromCharCode(b),_=e,B=!1,I=t.md.block.ruler.getRules("list"),v=t.parentType,t.parentType="list";_=w?1:C-u)>4&&(d=1),l=u+d,(R=t.push("list_item_open","li",1)).markup=String.fromCharCode(b),R.map=p=[e,0],h&&(R.info=t.src.slice(T,S-1)),E=t.tight,x=t.tShift[e],y=t.sCount[e],A=t.listIndent,t.listIndent=t.blkIndent,t.blkIndent=l,t.tight=!0,t.tShift[e]=a-t.bMarks[e],t.sCount[e]=C,a>=w&&t.isEmpty(e+1)?t.line=Math.min(t.line+2,n):t.md.block.tokenize(t,e,n,!0),t.tight&&!B||(F=!1),B=t.line-e>1&&t.isEmpty(t.line-1),t.blkIndent=t.listIndent,t.listIndent=A,t.tShift[e]=x,t.sCount[e]=y,t.tight=E,(R=t.push("list_item_close","li",-1)).markup=String.fromCharCode(b),_=e=t.line,p[1]=_,a=t.bMarks[e],_>=n)break;if(t.sCount[_]=4)break;for(P=!1,c=0,m=I.length;c{"use strict";t.exports=function(t,e){var n,o,i,r,s,a,c=e+1,l=t.md.block.ruler.getRules("paragraph"),d=t.lineMax;for(a=t.parentType,t.parentType="paragraph";c3||t.sCount[c]<0)){for(o=!1,i=0,r=l.length;i{"use strict";var o=n(7022).normalizeReference,i=n(7022).isSpace;t.exports=function(t,e,n,r){var s,a,c,l,d,u,h,p,m,g,f,b,k,w,_,C,A=0,v=t.bMarks[e]+t.tShift[e],y=t.eMarks[e],x=e+1;if(t.sCount[e]-t.blkIndent>=4)return!1;if(91!==t.src.charCodeAt(v))return!1;for(;++v3||t.sCount[x]<0)){for(w=!1,u=0,h=_.length;u{"use strict";var o=n(5872),i=n(7022).isSpace;function r(t,e,n,o){var r,s,a,c,l,d,u,h;for(this.src=t,this.md=e,this.env=n,this.tokens=o,this.bMarks=[],this.eMarks=[],this.tShift=[],this.sCount=[],this.bsCount=[],this.blkIndent=0,this.line=0,this.lineMax=0,this.tight=!1,this.ddIndent=-1,this.listIndent=-1,this.parentType="root",this.level=0,this.result="",h=!1,a=c=d=u=0,l=(s=this.src).length;c0&&this.level++,this.tokens.push(i),i},r.prototype.isEmpty=function(t){return this.bMarks[t]+this.tShift[t]>=this.eMarks[t]},r.prototype.skipEmptyLines=function(t){for(var e=this.lineMax;te;)if(!i(this.src.charCodeAt(--t)))return t+1;return t},r.prototype.skipChars=function(t,e){for(var n=this.src.length;tn;)if(e!==this.src.charCodeAt(--t))return t+1;return t},r.prototype.getLines=function(t,e,n,o){var r,s,a,c,l,d,u,h=t;if(t>=e)return"";for(d=new Array(e-t),r=0;hn?new Array(s-n+1).join(" ")+this.src.slice(c,l):this.src.slice(c,l)}return d.join("")},r.prototype.Token=o,t.exports=r},1785:(t,e,n)=>{"use strict";var o=n(7022).isSpace;function i(t,e){var n=t.bMarks[e]+t.tShift[e],o=t.eMarks[e];return t.src.substr(n,o-n)}function r(t){var e,n=[],o=0,i=t.length,r=!1,s=0,a="";for(e=t.charCodeAt(o);on)return!1;if(h=e+1,t.sCount[h]=4)return!1;if((l=t.bMarks[h]+t.tShift[h])>=t.eMarks[h])return!1;if(124!==(v=t.src.charCodeAt(l++))&&45!==v&&58!==v)return!1;if(l>=t.eMarks[h])return!1;if(124!==(y=t.src.charCodeAt(l++))&&45!==y&&58!==y&&!o(y))return!1;if(45===v&&o(y))return!1;for(;l=4)return!1;if((p=r(c)).length&&""===p[0]&&p.shift(),p.length&&""===p[p.length-1]&&p.pop(),0===(m=p.length)||m!==f.length)return!1;if(s)return!0;for(_=t.parentType,t.parentType="table",A=t.md.block.ruler.getRules("blockquote"),(g=t.push("table_open","table",1)).map=k=[e,0],(g=t.push("thead_open","thead",1)).map=[e,e+1],(g=t.push("tr_open","tr",1)).map=[e,e+1],d=0;d=4)break;for((p=r(c)).length&&""===p[0]&&p.shift(),p.length&&""===p[p.length-1]&&p.pop(),h===e+2&&((g=t.push("tbody_open","tbody",1)).map=w=[e+2,0]),(g=t.push("tr_open","tr",1)).map=[h,h+1],d=0;d{"use strict";t.exports=function(t){var e;t.inlineMode?((e=new t.Token("inline","",0)).content=t.src,e.map=[0,1],e.children=[],t.tokens.push(e)):t.md.block.parse(t.src,t.md,t.env,t.tokens)}},9827:t=>{"use strict";t.exports=function(t){var e,n,o,i=t.tokens;for(n=0,o=i.length;n{"use strict";var o=n(7022).arrayReplaceAt;function i(t){return/^<\/a\s*>/i.test(t)}t.exports=function(t){var e,n,r,s,a,c,l,d,u,h,p,m,g,f,b,k,w,_,C=t.tokens;if(t.md.options.linkify)for(n=0,r=C.length;n=0;e--)if("link_close"!==(c=s[e]).type){if("html_inline"===c.type&&(_=c.content,/^\s]/i.test(_)&&g>0&&g--,i(c.content)&&g++),!(g>0)&&"text"===c.type&&t.md.linkify.test(c.content)){for(u=c.content,w=t.md.linkify.match(u),l=[],m=c.level,p=0,d=0;dp&&((a=new t.Token("text","",0)).content=u.slice(p,h),a.level=m,l.push(a)),(a=new t.Token("link_open","a",1)).attrs=[["href",b]],a.level=m++,a.markup="linkify",a.info="auto",l.push(a),(a=new t.Token("text","",0)).content=k,a.level=m,l.push(a),(a=new t.Token("link_close","a",-1)).level=--m,a.markup="linkify",a.info="auto",l.push(a),p=w[d].lastIndex);p{"use strict";var e=/\r\n?|\n/g,n=/\0/g;t.exports=function(t){var o;o=(o=t.src.replace(e,"\n")).replace(n,"�"),t.src=o}},2834:t=>{"use strict";var e=/\+-|\.\.|\?\?\?\?|!!!!|,,|--/,n=/\((c|tm|r|p)\)/i,o=/\((c|tm|r|p)\)/gi,i={c:"©",r:"®",p:"§",tm:"™"};function r(t,e){return i[e.toLowerCase()]}function s(t){var e,n,i=0;for(e=t.length-1;e>=0;e--)"text"!==(n=t[e]).type||i||(n.content=n.content.replace(o,r)),"link_open"===n.type&&"auto"===n.info&&i--,"link_close"===n.type&&"auto"===n.info&&i++}function a(t){var n,o,i=0;for(n=t.length-1;n>=0;n--)"text"!==(o=t[n]).type||i||e.test(o.content)&&(o.content=o.content.replace(/\+-/g,"±").replace(/\.{2,}/g,"…").replace(/([?!])…/g,"$1..").replace(/([?!]){4,}/g,"$1$1$1").replace(/,{2,}/g,",").replace(/(^|[^-])---(?=[^-]|$)/gm,"$1—").replace(/(^|\s)--(?=\s|$)/gm,"$1–").replace(/(^|[^-\s])--(?=[^-\s]|$)/gm,"$1–")),"link_open"===o.type&&"auto"===o.info&&i--,"link_close"===o.type&&"auto"===o.info&&i++}t.exports=function(t){var o;if(t.md.options.typographer)for(o=t.tokens.length-1;o>=0;o--)"inline"===t.tokens[o].type&&(n.test(t.tokens[o].content)&&s(t.tokens[o].children),e.test(t.tokens[o].content)&&a(t.tokens[o].children))}},8450:(t,e,n)=>{"use strict";var o=n(7022).isWhiteSpace,i=n(7022).isPunctChar,r=n(7022).isMdAsciiPunct,s=/['"]/,a=/['"]/g;function c(t,e,n){return t.substr(0,e)+n+t.substr(e+1)}function l(t,e){var n,s,l,d,u,h,p,m,g,f,b,k,w,_,C,A,v,y,x,E,D;for(x=[],n=0;n=0&&!(x[v].level<=p);v--);if(x.length=v+1,"text"===s.type){u=0,h=(l=s.content).length;t:for(;u=0)g=l.charCodeAt(d.index-1);else for(v=n-1;v>=0&&("softbreak"!==t[v].type&&"hardbreak"!==t[v].type);v--)if(t[v].content){g=t[v].content.charCodeAt(t[v].content.length-1);break}if(f=32,u=48&&g<=57&&(A=C=!1),C&&A&&(C=b,A=k),C||A){if(A)for(v=x.length-1;v>=0&&(m=x[v],!(x[v].level=0;e--)"inline"===t.tokens[e].type&&s.test(t.tokens[e].content)&&l(t.tokens[e].children,t)}},6480:(t,e,n)=>{"use strict";var o=n(5872);function i(t,e,n){this.src=t,this.env=n,this.tokens=[],this.inlineMode=!1,this.md=e}i.prototype.Token=o,t.exports=i},3420:t=>{"use strict";var e=/^([a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)$/,n=/^([a-zA-Z][a-zA-Z0-9+.\-]{1,31}):([^<>\x00-\x20]*)$/;t.exports=function(t,o){var i,r,s,a,c,l,d=t.pos;if(60!==t.src.charCodeAt(d))return!1;for(c=t.pos,l=t.posMax;;){if(++d>=l)return!1;if(60===(a=t.src.charCodeAt(d)))return!1;if(62===a)break}return i=t.src.slice(c+1,d),n.test(i)?(r=t.md.normalizeLink(i),!!t.md.validateLink(r)&&(o||((s=t.push("link_open","a",1)).attrs=[["href",r]],s.markup="autolink",s.info="auto",(s=t.push("text","",0)).content=t.md.normalizeLinkText(i),(s=t.push("link_close","a",-1)).markup="autolink",s.info="auto"),t.pos+=i.length+2,!0)):!!e.test(i)&&(r=t.md.normalizeLink("mailto:"+i),!!t.md.validateLink(r)&&(o||((s=t.push("link_open","a",1)).attrs=[["href",r]],s.markup="autolink",s.info="auto",(s=t.push("text","",0)).content=t.md.normalizeLinkText(i),(s=t.push("link_close","a",-1)).markup="autolink",s.info="auto"),t.pos+=i.length+2,!0))}},9755:t=>{"use strict";t.exports=function(t,e){var n,o,i,r,s,a,c,l,d=t.pos;if(96!==t.src.charCodeAt(d))return!1;for(n=d,d++,o=t.posMax;d{"use strict";function e(t,e){var n,o,i,r,s,a,c,l,d={},u=e.length;if(u){var h=0,p=-2,m=[];for(n=0;ns;o-=m[o]+1)if((r=e[o]).marker===i.marker&&r.open&&r.end<0&&(c=!1,(r.close||i.open)&&(r.length+i.length)%3==0&&(r.length%3==0&&i.length%3==0||(c=!0)),!c)){l=o>0&&!e[o-1].open?m[o-1]+1:0,m[n]=n-o+l,m[o]=l,i.open=!1,r.end=n,r.close=!1,a=-1,p=-2;break}-1!==a&&(d[i.marker][(i.open?3:0)+(i.length||0)%3]=a)}}}t.exports=function(t){var n,o=t.tokens_meta,i=t.tokens_meta.length;for(e(0,t.delimiters),n=0;n{"use strict";function e(t,e){var n,o,i,r,s,a;for(n=e.length-1;n>=0;n--)95!==(o=e[n]).marker&&42!==o.marker||-1!==o.end&&(i=e[o.end],a=n>0&&e[n-1].end===o.end+1&&e[n-1].marker===o.marker&&e[n-1].token===o.token-1&&e[o.end+1].token===i.token+1,s=String.fromCharCode(o.marker),(r=t.tokens[o.token]).type=a?"strong_open":"em_open",r.tag=a?"strong":"em",r.nesting=1,r.markup=a?s+s:s,r.content="",(r=t.tokens[i.token]).type=a?"strong_close":"em_close",r.tag=a?"strong":"em",r.nesting=-1,r.markup=a?s+s:s,r.content="",a&&(t.tokens[e[n-1].token].content="",t.tokens[e[o.end+1].token].content="",n--))}t.exports.w=function(t,e){var n,o,i=t.pos,r=t.src.charCodeAt(i);if(e)return!1;if(95!==r&&42!==r)return!1;for(o=t.scanDelims(t.pos,42===r),n=0;n{"use strict";var o=n(6233),i=n(7022).has,r=n(7022).isValidEntityCode,s=n(7022).fromCodePoint,a=/^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i,c=/^&([a-z][a-z0-9]{1,31});/i;t.exports=function(t,e){var n,l,d=t.pos,u=t.posMax;if(38!==t.src.charCodeAt(d))return!1;if(d+1{"use strict";for(var o=n(7022).isSpace,i=[],r=0;r<256;r++)i.push(0);"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach((function(t){i[t.charCodeAt(0)]=1})),t.exports=function(t,e){var n,r=t.pos,s=t.posMax;if(92!==t.src.charCodeAt(r))return!1;if(++r{"use strict";var o=n(1947).n;t.exports=function(t,e){var n,i,r,s=t.pos;return!!t.md.options.html&&(r=t.posMax,!(60!==t.src.charCodeAt(s)||s+2>=r)&&(!(33!==(n=t.src.charCodeAt(s+1))&&63!==n&&47!==n&&!function(t){var e=32|t;return e>=97&&e<=122}(n))&&(!!(i=t.src.slice(s).match(o))&&(e||(t.push("html_inline","",0).content=t.src.slice(s,s+i[0].length)),t.pos+=i[0].length,!0))))}},3006:(t,e,n)=>{"use strict";var o=n(7022).normalizeReference,i=n(7022).isSpace;t.exports=function(t,e){var n,r,s,a,c,l,d,u,h,p,m,g,f,b="",k=t.pos,w=t.posMax;if(33!==t.src.charCodeAt(t.pos))return!1;if(91!==t.src.charCodeAt(t.pos+1))return!1;if(l=t.pos+2,(c=t.md.helpers.parseLinkLabel(t,t.pos+1,!1))<0)return!1;if((d=c+1)=w)return!1;for(f=d,(h=t.md.helpers.parseLinkDestination(t.src,d,t.posMax)).ok&&(b=t.md.normalizeLink(h.str),t.md.validateLink(b)?d=h.pos:b=""),f=d;d=w||41!==t.src.charCodeAt(d))return t.pos=k,!1;d++}else{if(void 0===t.env.references)return!1;if(d=0?a=t.src.slice(f,d++):d=c+1):d=c+1,a||(a=t.src.slice(l,c)),!(u=t.env.references[o(a)]))return t.pos=k,!1;b=u.href,p=u.title}return e||(s=t.src.slice(l,c),t.md.inline.parse(s,t.md,t.env,g=[]),(m=t.push("image","img",0)).attrs=n=[["src",b],["alt",""]],m.children=g,m.content=s,p&&n.push(["title",p])),t.pos=d,t.posMax=w,!0}},1727:(t,e,n)=>{"use strict";var o=n(7022).normalizeReference,i=n(7022).isSpace;t.exports=function(t,e){var n,r,s,a,c,l,d,u,h="",p="",m=t.pos,g=t.posMax,f=t.pos,b=!0;if(91!==t.src.charCodeAt(t.pos))return!1;if(c=t.pos+1,(a=t.md.helpers.parseLinkLabel(t,t.pos,!0))<0)return!1;if((l=a+1)=g)return!1;if(f=l,(d=t.md.helpers.parseLinkDestination(t.src,l,t.posMax)).ok){for(h=t.md.normalizeLink(d.str),t.md.validateLink(h)?l=d.pos:h="",f=l;l=g||41!==t.src.charCodeAt(l))&&(b=!0),l++}if(b){if(void 0===t.env.references)return!1;if(l=0?s=t.src.slice(f,l++):l=a+1):l=a+1,s||(s=t.src.slice(c,a)),!(u=t.env.references[o(s)]))return t.pos=m,!1;h=u.href,p=u.title}return e||(t.pos=c,t.posMax=a,t.push("link_open","a",1).attrs=n=[["href",h]],p&&n.push(["title",p]),t.md.inline.tokenize(t),t.push("link_close","a",-1)),t.pos=l,t.posMax=g,!0}},3905:(t,e,n)=>{"use strict";var o=n(7022).isSpace;t.exports=function(t,e){var n,i,r,s=t.pos;if(10!==t.src.charCodeAt(s))return!1;if(n=t.pending.length-1,i=t.posMax,!e)if(n>=0&&32===t.pending.charCodeAt(n))if(n>=1&&32===t.pending.charCodeAt(n-1)){for(r=n-1;r>=1&&32===t.pending.charCodeAt(r-1);)r--;t.pending=t.pending.slice(0,r),t.push("hardbreak","br",0)}else t.pending=t.pending.slice(0,-1),t.push("softbreak","br",0);else t.push("softbreak","br",0);for(s++;s{"use strict";var o=n(5872),i=n(7022).isWhiteSpace,r=n(7022).isPunctChar,s=n(7022).isMdAsciiPunct;function a(t,e,n,o){this.src=t,this.env=n,this.md=e,this.tokens=o,this.tokens_meta=Array(o.length),this.pos=0,this.posMax=this.src.length,this.level=0,this.pending="",this.pendingLevel=0,this.cache={},this.delimiters=[],this._prev_delimiters=[],this.backticks={},this.backticksScanned=!1}a.prototype.pushPending=function(){var t=new o("text","",0);return t.content=this.pending,t.level=this.pendingLevel,this.tokens.push(t),this.pending="",t},a.prototype.push=function(t,e,n){this.pending&&this.pushPending();var i=new o(t,e,n),r=null;return n<0&&(this.level--,this.delimiters=this._prev_delimiters.pop()),i.level=this.level,n>0&&(this.level++,this._prev_delimiters.push(this.delimiters),this.delimiters=[],r={delimiters:this.delimiters}),this.pendingLevel=this.level,this.tokens.push(i),this.tokens_meta.push(r),i},a.prototype.scanDelims=function(t,e){var n,o,a,c,l,d,u,h,p,m=t,g=!0,f=!0,b=this.posMax,k=this.src.charCodeAt(t);for(n=t>0?this.src.charCodeAt(t-1):32;m{"use strict";function e(t,e){var n,o,i,r,s,a=[],c=e.length;for(n=0;n{"use strict";function e(t){switch(t){case 10:case 33:case 35:case 36:case 37:case 38:case 42:case 43:case 45:case 58:case 60:case 61:case 62:case 64:case 91:case 92:case 93:case 94:case 95:case 96:case 123:case 125:case 126:return!0;default:return!1}}t.exports=function(t,n){for(var o=t.pos;o{"use strict";t.exports=function(t){var e,n,o=0,i=t.tokens,r=t.tokens.length;for(e=n=0;e0&&o++,"text"===i[e].type&&e+1{"use strict";function e(t,e,n){this.type=t,this.tag=e,this.attrs=null,this.map=null,this.nesting=n,this.level=0,this.children=null,this.content="",this.markup="",this.info="",this.meta=null,this.block=!1,this.hidden=!1}e.prototype.attrIndex=function(t){var e,n,o;if(!this.attrs)return-1;for(n=0,o=(e=this.attrs).length;n=0&&(n=this.attrs[e][1]),n},e.prototype.attrJoin=function(t,e){var n=this.attrIndex(t);n<0?this.attrPush([t,e]):this.attrs[n][1]=this.attrs[n][1]+" "+e},t.exports=e},3122:t=>{"use strict";var e={};function n(t,o){var i;return"string"!=typeof o&&(o=n.defaultChars),i=function(t){var n,o,i=e[t];if(i)return i;for(i=e[t]=[],n=0;n<128;n++)o=String.fromCharCode(n),i.push(o);for(n=0;n=55296&&c<=57343?"���":String.fromCharCode(c),e+=6):240==(248&o)&&e+91114111?l+="����":(c-=65536,l+=String.fromCharCode(55296+(c>>10),56320+(1023&c))),e+=9):l+="�";return l}))}n.defaultChars=";/?:@&=+$,#",n.componentChars="",t.exports=n},729:t=>{"use strict";var e={};function n(t,o,i){var r,s,a,c,l,d="";for("string"!=typeof o&&(i=o,o=n.defaultChars),void 0===i&&(i=!0),l=function(t){var n,o,i=e[t];if(i)return i;for(i=e[t]=[],n=0;n<128;n++)o=String.fromCharCode(n),/^[0-9a-z]$/i.test(o)?i.push(o):i.push("%"+("0"+n.toString(16).toUpperCase()).slice(-2));for(n=0;n=55296&&a<=57343){if(a>=55296&&a<=56319&&r+1=56320&&c<=57343){d+=encodeURIComponent(t[r]+t[r+1]),r++;continue}d+="%EF%BF%BD"}else d+=encodeURIComponent(t[r]);return d}n.defaultChars=";/?:@&=+$,-_.!~*'()#",n.componentChars="-_.!~*'()",t.exports=n},2201:t=>{"use strict";t.exports=function(t){var e="";return e+=t.protocol||"",e+=t.slashes?"//":"",e+=t.auth?t.auth+"@":"",t.hostname&&-1!==t.hostname.indexOf(":")?e+="["+t.hostname+"]":e+=t.hostname||"",e+=t.port?":"+t.port:"",e+=t.pathname||"",e+=t.search||"",e+=t.hash||""}},8765:(t,e,n)=>{"use strict";t.exports.encode=n(729),t.exports.decode=n(3122),t.exports.format=n(2201),t.exports.parse=n(9553)},9553:t=>{"use strict";function e(){this.protocol=null,this.slashes=null,this.auth=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.pathname=null}var n=/^([a-z0-9.+-]+:)/i,o=/:[0-9]*$/,i=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,r=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),s=["'"].concat(r),a=["%","/","?",";","#"].concat(s),c=["/","?","#"],l=/^[+a-z0-9A-Z_-]{0,63}$/,d=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,u={javascript:!0,"javascript:":!0},h={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};e.prototype.parse=function(t,e){var o,r,s,p,m,g=t;if(g=g.trim(),!e&&1===t.split("#").length){var f=i.exec(g);if(f)return this.pathname=f[1],f[2]&&(this.search=f[2]),this}var b=n.exec(g);if(b&&(s=(b=b[0]).toLowerCase(),this.protocol=b,g=g.substr(b.length)),(e||b||g.match(/^\/\/[^@\/]+@[^@\/]+/))&&(!(m="//"===g.substr(0,2))||b&&u[b]||(g=g.substr(2),this.slashes=!0)),!u[b]&&(m||b&&!h[b])){var k,w,_=-1;for(o=0;o127?x+="x":x+=y[E];if(!x.match(l)){var S=v.slice(0,o),B=v.slice(o+1),T=y.match(d);T&&(S.push(T[1]),B.unshift(T[2])),B.length&&(g=B.join(".")+g),this.hostname=S.join(".");break}}}}this.hostname.length>255&&(this.hostname=""),A&&(this.hostname=this.hostname.substr(1,this.hostname.length-2))}var P=g.indexOf("#");-1!==P&&(this.hash=g.substr(P),g=g.slice(0,P));var I=g.indexOf("?");return-1!==I&&(this.search=g.substr(I),g=g.slice(0,I)),g&&(this.pathname=g),h[s]&&this.hostname&&!this.pathname&&(this.pathname=""),this},e.prototype.parseHost=function(t){var e=o.exec(t);e&&(":"!==(e=e[0])&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)},t.exports=function(t,n){if(t&&t instanceof e)return t;var o=new e;return o.parse(t,n),o}},3689:(t,e,n)=>{"use strict";n.r(e),n.d(e,{ucs2decode:()=>p,ucs2encode:()=>m,decode:()=>b,encode:()=>k,toASCII:()=>_,toUnicode:()=>w,default:()=>C});const o=2147483647,i=36,r=/^xn--/,s=/[^\0-\x7E]/,a=/[\x2E\u3002\uFF0E\uFF61]/g,c={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},l=Math.floor,d=String.fromCharCode;function u(t){throw new RangeError(c[t])}function h(t,e){const n=t.split("@");let o="";n.length>1&&(o=n[0]+"@",t=n[1]);const i=function(t,e){const n=[];let o=t.length;for(;o--;)n[o]=e(t[o]);return n}((t=t.replace(a,".")).split("."),e).join(".");return o+i}function p(t){const e=[];let n=0;const o=t.length;for(;n=55296&&i<=56319&&nString.fromCodePoint(...t),g=function(t,e){return t+22+75*(t<26)-((0!=e)<<5)},f=function(t,e,n){let o=0;for(t=n?l(t/700):t>>1,t+=l(t/e);t>455;o+=i)t=l(t/35);return l(o+36*t/(t+38))},b=function(t){const e=[],n=t.length;let r=0,s=128,a=72,c=t.lastIndexOf("-");c<0&&(c=0);for(let n=0;n=128&&u("not-basic"),e.push(t.charCodeAt(n));for(let h=c>0?c+1:0;h=n&&u("invalid-input");const c=(d=t.charCodeAt(h++))-48<10?d-22:d-65<26?d-65:d-97<26?d-97:i;(c>=i||c>l((o-r)/e))&&u("overflow"),r+=c*e;const p=s<=a?1:s>=a+26?26:s-a;if(cl(o/m)&&u("overflow"),e*=m}const p=e.length+1;a=f(r-c,p,0==c),l(r/p)>o-s&&u("overflow"),s+=l(r/p),r%=p,e.splice(r++,0,s)}var d;return String.fromCodePoint(...e)},k=function(t){const e=[];let n=(t=p(t)).length,r=128,s=0,a=72;for(const n of t)n<128&&e.push(d(n));let c=e.length,h=c;for(c&&e.push("-");h=r&&el((o-s)/p)&&u("overflow"),s+=(n-r)*p,r=n;for(const n of t)if(no&&u("overflow"),n==r){let t=s;for(let n=i;;n+=i){const o=n<=a?1:n>=a+26?26:n-a;if(t{"use strict";var e=[];function n(t){for(var n=-1,o=0;o{"use strict";var e={};t.exports=function(t,n){var o=function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(t){n=null}e[t]=n}return e[t]}(t);if(!o)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");o.appendChild(n)}},9216:t=>{"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},8575:t=>{"use strict";t.exports=function(t,e){Object.keys(e).forEach((function(n){t.setAttribute(n,e[n])}))}},9037:t=>{"use strict";var e,n=(e=[],function(t,n){return e[t]=n,e.filter(Boolean).join("\n")});function o(t,e,o,i){var r;if(o)r="";else{r="",i.supports&&(r+="@supports (".concat(i.supports,") {")),i.media&&(r+="@media ".concat(i.media," {"));var s=void 0!==i.layer;s&&(r+="@layer".concat(i.layer.length>0?" ".concat(i.layer):""," {")),r+=i.css,s&&(r+="}"),i.media&&(r+="}"),i.supports&&(r+="}")}if(t.styleSheet)t.styleSheet.cssText=n(e,r);else{var a=document.createTextNode(r),c=t.childNodes;c[e]&&t.removeChild(c[e]),c.length?t.insertBefore(a,c[e]):t.appendChild(a)}}var i={singleton:null,singletonCounter:0};t.exports=function(t){var e=i.singletonCounter++,n=i.singleton||(i.singleton=t.insertStyleElement(t));return{update:function(t){o(n,e,!1,t)},remove:function(t){o(n,e,!0,t)}}}},9413:t=>{t.exports=/[\0-\x1F\x7F-\x9F]/},2326:t=>{t.exports=/[\xAD\u0600-\u0605\u061C\u06DD\u070F\u08E2\u180E\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u206F\uFEFF\uFFF9-\uFFFB]|\uD804[\uDCBD\uDCCD]|\uD82F[\uDCA0-\uDCA3]|\uD834[\uDD73-\uDD7A]|\uDB40[\uDC01\uDC20-\uDC7F]/},3189:t=>{t.exports=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4E\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDF55-\uDF59]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDF3C-\uDF3E]|\uD806[\uDC3B\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/},5045:t=>{t.exports=/[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/},4205:(t,e,n)=>{"use strict";e.Any=n(9369),e.Cc=n(9413),e.Cf=n(2326),e.P=n(3189),e.Z=n(5045)},9369:t=>{t.exports=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/},5485:t=>{"use strict";t.exports=JSON.parse('{"Aacute":"Á","aacute":"á","Abreve":"Ă","abreve":"ă","ac":"∾","acd":"∿","acE":"∾̳","Acirc":"Â","acirc":"â","acute":"´","Acy":"А","acy":"а","AElig":"Æ","aelig":"æ","af":"⁡","Afr":"𝔄","afr":"𝔞","Agrave":"À","agrave":"à","alefsym":"ℵ","aleph":"ℵ","Alpha":"Α","alpha":"α","Amacr":"Ā","amacr":"ā","amalg":"⨿","amp":"&","AMP":"&","andand":"⩕","And":"⩓","and":"∧","andd":"⩜","andslope":"⩘","andv":"⩚","ang":"∠","ange":"⦤","angle":"∠","angmsdaa":"⦨","angmsdab":"⦩","angmsdac":"⦪","angmsdad":"⦫","angmsdae":"⦬","angmsdaf":"⦭","angmsdag":"⦮","angmsdah":"⦯","angmsd":"∡","angrt":"∟","angrtvb":"⊾","angrtvbd":"⦝","angsph":"∢","angst":"Å","angzarr":"⍼","Aogon":"Ą","aogon":"ą","Aopf":"𝔸","aopf":"𝕒","apacir":"⩯","ap":"≈","apE":"⩰","ape":"≊","apid":"≋","apos":"\'","ApplyFunction":"⁡","approx":"≈","approxeq":"≊","Aring":"Å","aring":"å","Ascr":"𝒜","ascr":"𝒶","Assign":"≔","ast":"*","asymp":"≈","asympeq":"≍","Atilde":"Ã","atilde":"ã","Auml":"Ä","auml":"ä","awconint":"∳","awint":"⨑","backcong":"≌","backepsilon":"϶","backprime":"‵","backsim":"∽","backsimeq":"⋍","Backslash":"∖","Barv":"⫧","barvee":"⊽","barwed":"⌅","Barwed":"⌆","barwedge":"⌅","bbrk":"⎵","bbrktbrk":"⎶","bcong":"≌","Bcy":"Б","bcy":"б","bdquo":"„","becaus":"∵","because":"∵","Because":"∵","bemptyv":"⦰","bepsi":"϶","bernou":"ℬ","Bernoullis":"ℬ","Beta":"Β","beta":"β","beth":"ℶ","between":"≬","Bfr":"𝔅","bfr":"𝔟","bigcap":"⋂","bigcirc":"◯","bigcup":"⋃","bigodot":"⨀","bigoplus":"⨁","bigotimes":"⨂","bigsqcup":"⨆","bigstar":"★","bigtriangledown":"▽","bigtriangleup":"△","biguplus":"⨄","bigvee":"⋁","bigwedge":"⋀","bkarow":"⤍","blacklozenge":"⧫","blacksquare":"▪","blacktriangle":"▴","blacktriangledown":"▾","blacktriangleleft":"◂","blacktriangleright":"▸","blank":"␣","blk12":"▒","blk14":"░","blk34":"▓","block":"█","bne":"=⃥","bnequiv":"≡⃥","bNot":"⫭","bnot":"⌐","Bopf":"𝔹","bopf":"𝕓","bot":"⊥","bottom":"⊥","bowtie":"⋈","boxbox":"⧉","boxdl":"┐","boxdL":"╕","boxDl":"╖","boxDL":"╗","boxdr":"┌","boxdR":"╒","boxDr":"╓","boxDR":"╔","boxh":"─","boxH":"═","boxhd":"┬","boxHd":"╤","boxhD":"╥","boxHD":"╦","boxhu":"┴","boxHu":"╧","boxhU":"╨","boxHU":"╩","boxminus":"⊟","boxplus":"⊞","boxtimes":"⊠","boxul":"┘","boxuL":"╛","boxUl":"╜","boxUL":"╝","boxur":"└","boxuR":"╘","boxUr":"╙","boxUR":"╚","boxv":"│","boxV":"║","boxvh":"┼","boxvH":"╪","boxVh":"╫","boxVH":"╬","boxvl":"┤","boxvL":"╡","boxVl":"╢","boxVL":"╣","boxvr":"├","boxvR":"╞","boxVr":"╟","boxVR":"╠","bprime":"‵","breve":"˘","Breve":"˘","brvbar":"¦","bscr":"𝒷","Bscr":"ℬ","bsemi":"⁏","bsim":"∽","bsime":"⋍","bsolb":"⧅","bsol":"\\\\","bsolhsub":"⟈","bull":"•","bullet":"•","bump":"≎","bumpE":"⪮","bumpe":"≏","Bumpeq":"≎","bumpeq":"≏","Cacute":"Ć","cacute":"ć","capand":"⩄","capbrcup":"⩉","capcap":"⩋","cap":"∩","Cap":"⋒","capcup":"⩇","capdot":"⩀","CapitalDifferentialD":"ⅅ","caps":"∩︀","caret":"⁁","caron":"ˇ","Cayleys":"ℭ","ccaps":"⩍","Ccaron":"Č","ccaron":"č","Ccedil":"Ç","ccedil":"ç","Ccirc":"Ĉ","ccirc":"ĉ","Cconint":"∰","ccups":"⩌","ccupssm":"⩐","Cdot":"Ċ","cdot":"ċ","cedil":"¸","Cedilla":"¸","cemptyv":"⦲","cent":"¢","centerdot":"·","CenterDot":"·","cfr":"𝔠","Cfr":"ℭ","CHcy":"Ч","chcy":"ч","check":"✓","checkmark":"✓","Chi":"Χ","chi":"χ","circ":"ˆ","circeq":"≗","circlearrowleft":"↺","circlearrowright":"↻","circledast":"⊛","circledcirc":"⊚","circleddash":"⊝","CircleDot":"⊙","circledR":"®","circledS":"Ⓢ","CircleMinus":"⊖","CirclePlus":"⊕","CircleTimes":"⊗","cir":"○","cirE":"⧃","cire":"≗","cirfnint":"⨐","cirmid":"⫯","cirscir":"⧂","ClockwiseContourIntegral":"∲","CloseCurlyDoubleQuote":"”","CloseCurlyQuote":"’","clubs":"♣","clubsuit":"♣","colon":":","Colon":"∷","Colone":"⩴","colone":"≔","coloneq":"≔","comma":",","commat":"@","comp":"∁","compfn":"∘","complement":"∁","complexes":"ℂ","cong":"≅","congdot":"⩭","Congruent":"≡","conint":"∮","Conint":"∯","ContourIntegral":"∮","copf":"𝕔","Copf":"ℂ","coprod":"∐","Coproduct":"∐","copy":"©","COPY":"©","copysr":"℗","CounterClockwiseContourIntegral":"∳","crarr":"↵","cross":"✗","Cross":"⨯","Cscr":"𝒞","cscr":"𝒸","csub":"⫏","csube":"⫑","csup":"⫐","csupe":"⫒","ctdot":"⋯","cudarrl":"⤸","cudarrr":"⤵","cuepr":"⋞","cuesc":"⋟","cularr":"↶","cularrp":"⤽","cupbrcap":"⩈","cupcap":"⩆","CupCap":"≍","cup":"∪","Cup":"⋓","cupcup":"⩊","cupdot":"⊍","cupor":"⩅","cups":"∪︀","curarr":"↷","curarrm":"⤼","curlyeqprec":"⋞","curlyeqsucc":"⋟","curlyvee":"⋎","curlywedge":"⋏","curren":"¤","curvearrowleft":"↶","curvearrowright":"↷","cuvee":"⋎","cuwed":"⋏","cwconint":"∲","cwint":"∱","cylcty":"⌭","dagger":"†","Dagger":"‡","daleth":"ℸ","darr":"↓","Darr":"↡","dArr":"⇓","dash":"‐","Dashv":"⫤","dashv":"⊣","dbkarow":"⤏","dblac":"˝","Dcaron":"Ď","dcaron":"ď","Dcy":"Д","dcy":"д","ddagger":"‡","ddarr":"⇊","DD":"ⅅ","dd":"ⅆ","DDotrahd":"⤑","ddotseq":"⩷","deg":"°","Del":"∇","Delta":"Δ","delta":"δ","demptyv":"⦱","dfisht":"⥿","Dfr":"𝔇","dfr":"𝔡","dHar":"⥥","dharl":"⇃","dharr":"⇂","DiacriticalAcute":"´","DiacriticalDot":"˙","DiacriticalDoubleAcute":"˝","DiacriticalGrave":"`","DiacriticalTilde":"˜","diam":"⋄","diamond":"⋄","Diamond":"⋄","diamondsuit":"♦","diams":"♦","die":"¨","DifferentialD":"ⅆ","digamma":"ϝ","disin":"⋲","div":"÷","divide":"÷","divideontimes":"⋇","divonx":"⋇","DJcy":"Ђ","djcy":"ђ","dlcorn":"⌞","dlcrop":"⌍","dollar":"$","Dopf":"𝔻","dopf":"𝕕","Dot":"¨","dot":"˙","DotDot":"⃜","doteq":"≐","doteqdot":"≑","DotEqual":"≐","dotminus":"∸","dotplus":"∔","dotsquare":"⊡","doublebarwedge":"⌆","DoubleContourIntegral":"∯","DoubleDot":"¨","DoubleDownArrow":"⇓","DoubleLeftArrow":"⇐","DoubleLeftRightArrow":"⇔","DoubleLeftTee":"⫤","DoubleLongLeftArrow":"⟸","DoubleLongLeftRightArrow":"⟺","DoubleLongRightArrow":"⟹","DoubleRightArrow":"⇒","DoubleRightTee":"⊨","DoubleUpArrow":"⇑","DoubleUpDownArrow":"⇕","DoubleVerticalBar":"∥","DownArrowBar":"⤓","downarrow":"↓","DownArrow":"↓","Downarrow":"⇓","DownArrowUpArrow":"⇵","DownBreve":"̑","downdownarrows":"⇊","downharpoonleft":"⇃","downharpoonright":"⇂","DownLeftRightVector":"⥐","DownLeftTeeVector":"⥞","DownLeftVectorBar":"⥖","DownLeftVector":"↽","DownRightTeeVector":"⥟","DownRightVectorBar":"⥗","DownRightVector":"⇁","DownTeeArrow":"↧","DownTee":"⊤","drbkarow":"⤐","drcorn":"⌟","drcrop":"⌌","Dscr":"𝒟","dscr":"𝒹","DScy":"Ѕ","dscy":"ѕ","dsol":"⧶","Dstrok":"Đ","dstrok":"đ","dtdot":"⋱","dtri":"▿","dtrif":"▾","duarr":"⇵","duhar":"⥯","dwangle":"⦦","DZcy":"Џ","dzcy":"џ","dzigrarr":"⟿","Eacute":"É","eacute":"é","easter":"⩮","Ecaron":"Ě","ecaron":"ě","Ecirc":"Ê","ecirc":"ê","ecir":"≖","ecolon":"≕","Ecy":"Э","ecy":"э","eDDot":"⩷","Edot":"Ė","edot":"ė","eDot":"≑","ee":"ⅇ","efDot":"≒","Efr":"𝔈","efr":"𝔢","eg":"⪚","Egrave":"È","egrave":"è","egs":"⪖","egsdot":"⪘","el":"⪙","Element":"∈","elinters":"⏧","ell":"ℓ","els":"⪕","elsdot":"⪗","Emacr":"Ē","emacr":"ē","empty":"∅","emptyset":"∅","EmptySmallSquare":"◻","emptyv":"∅","EmptyVerySmallSquare":"▫","emsp13":" ","emsp14":" ","emsp":" ","ENG":"Ŋ","eng":"ŋ","ensp":" ","Eogon":"Ę","eogon":"ę","Eopf":"𝔼","eopf":"𝕖","epar":"⋕","eparsl":"⧣","eplus":"⩱","epsi":"ε","Epsilon":"Ε","epsilon":"ε","epsiv":"ϵ","eqcirc":"≖","eqcolon":"≕","eqsim":"≂","eqslantgtr":"⪖","eqslantless":"⪕","Equal":"⩵","equals":"=","EqualTilde":"≂","equest":"≟","Equilibrium":"⇌","equiv":"≡","equivDD":"⩸","eqvparsl":"⧥","erarr":"⥱","erDot":"≓","escr":"ℯ","Escr":"ℰ","esdot":"≐","Esim":"⩳","esim":"≂","Eta":"Η","eta":"η","ETH":"Ð","eth":"ð","Euml":"Ë","euml":"ë","euro":"€","excl":"!","exist":"∃","Exists":"∃","expectation":"ℰ","exponentiale":"ⅇ","ExponentialE":"ⅇ","fallingdotseq":"≒","Fcy":"Ф","fcy":"ф","female":"♀","ffilig":"ffi","fflig":"ff","ffllig":"ffl","Ffr":"𝔉","ffr":"𝔣","filig":"fi","FilledSmallSquare":"◼","FilledVerySmallSquare":"▪","fjlig":"fj","flat":"♭","fllig":"fl","fltns":"▱","fnof":"ƒ","Fopf":"𝔽","fopf":"𝕗","forall":"∀","ForAll":"∀","fork":"⋔","forkv":"⫙","Fouriertrf":"ℱ","fpartint":"⨍","frac12":"½","frac13":"⅓","frac14":"¼","frac15":"⅕","frac16":"⅙","frac18":"⅛","frac23":"⅔","frac25":"⅖","frac34":"¾","frac35":"⅗","frac38":"⅜","frac45":"⅘","frac56":"⅚","frac58":"⅝","frac78":"⅞","frasl":"⁄","frown":"⌢","fscr":"𝒻","Fscr":"ℱ","gacute":"ǵ","Gamma":"Γ","gamma":"γ","Gammad":"Ϝ","gammad":"ϝ","gap":"⪆","Gbreve":"Ğ","gbreve":"ğ","Gcedil":"Ģ","Gcirc":"Ĝ","gcirc":"ĝ","Gcy":"Г","gcy":"г","Gdot":"Ġ","gdot":"ġ","ge":"≥","gE":"≧","gEl":"⪌","gel":"⋛","geq":"≥","geqq":"≧","geqslant":"⩾","gescc":"⪩","ges":"⩾","gesdot":"⪀","gesdoto":"⪂","gesdotol":"⪄","gesl":"⋛︀","gesles":"⪔","Gfr":"𝔊","gfr":"𝔤","gg":"≫","Gg":"⋙","ggg":"⋙","gimel":"ℷ","GJcy":"Ѓ","gjcy":"ѓ","gla":"⪥","gl":"≷","glE":"⪒","glj":"⪤","gnap":"⪊","gnapprox":"⪊","gne":"⪈","gnE":"≩","gneq":"⪈","gneqq":"≩","gnsim":"⋧","Gopf":"𝔾","gopf":"𝕘","grave":"`","GreaterEqual":"≥","GreaterEqualLess":"⋛","GreaterFullEqual":"≧","GreaterGreater":"⪢","GreaterLess":"≷","GreaterSlantEqual":"⩾","GreaterTilde":"≳","Gscr":"𝒢","gscr":"ℊ","gsim":"≳","gsime":"⪎","gsiml":"⪐","gtcc":"⪧","gtcir":"⩺","gt":">","GT":">","Gt":"≫","gtdot":"⋗","gtlPar":"⦕","gtquest":"⩼","gtrapprox":"⪆","gtrarr":"⥸","gtrdot":"⋗","gtreqless":"⋛","gtreqqless":"⪌","gtrless":"≷","gtrsim":"≳","gvertneqq":"≩︀","gvnE":"≩︀","Hacek":"ˇ","hairsp":" ","half":"½","hamilt":"ℋ","HARDcy":"Ъ","hardcy":"ъ","harrcir":"⥈","harr":"↔","hArr":"⇔","harrw":"↭","Hat":"^","hbar":"ℏ","Hcirc":"Ĥ","hcirc":"ĥ","hearts":"♥","heartsuit":"♥","hellip":"…","hercon":"⊹","hfr":"𝔥","Hfr":"ℌ","HilbertSpace":"ℋ","hksearow":"⤥","hkswarow":"⤦","hoarr":"⇿","homtht":"∻","hookleftarrow":"↩","hookrightarrow":"↪","hopf":"𝕙","Hopf":"ℍ","horbar":"―","HorizontalLine":"─","hscr":"𝒽","Hscr":"ℋ","hslash":"ℏ","Hstrok":"Ħ","hstrok":"ħ","HumpDownHump":"≎","HumpEqual":"≏","hybull":"⁃","hyphen":"‐","Iacute":"Í","iacute":"í","ic":"⁣","Icirc":"Î","icirc":"î","Icy":"И","icy":"и","Idot":"İ","IEcy":"Е","iecy":"е","iexcl":"¡","iff":"⇔","ifr":"𝔦","Ifr":"ℑ","Igrave":"Ì","igrave":"ì","ii":"ⅈ","iiiint":"⨌","iiint":"∭","iinfin":"⧜","iiota":"℩","IJlig":"IJ","ijlig":"ij","Imacr":"Ī","imacr":"ī","image":"ℑ","ImaginaryI":"ⅈ","imagline":"ℐ","imagpart":"ℑ","imath":"ı","Im":"ℑ","imof":"⊷","imped":"Ƶ","Implies":"⇒","incare":"℅","in":"∈","infin":"∞","infintie":"⧝","inodot":"ı","intcal":"⊺","int":"∫","Int":"∬","integers":"ℤ","Integral":"∫","intercal":"⊺","Intersection":"⋂","intlarhk":"⨗","intprod":"⨼","InvisibleComma":"⁣","InvisibleTimes":"⁢","IOcy":"Ё","iocy":"ё","Iogon":"Į","iogon":"į","Iopf":"𝕀","iopf":"𝕚","Iota":"Ι","iota":"ι","iprod":"⨼","iquest":"¿","iscr":"𝒾","Iscr":"ℐ","isin":"∈","isindot":"⋵","isinE":"⋹","isins":"⋴","isinsv":"⋳","isinv":"∈","it":"⁢","Itilde":"Ĩ","itilde":"ĩ","Iukcy":"І","iukcy":"і","Iuml":"Ï","iuml":"ï","Jcirc":"Ĵ","jcirc":"ĵ","Jcy":"Й","jcy":"й","Jfr":"𝔍","jfr":"𝔧","jmath":"ȷ","Jopf":"𝕁","jopf":"𝕛","Jscr":"𝒥","jscr":"𝒿","Jsercy":"Ј","jsercy":"ј","Jukcy":"Є","jukcy":"є","Kappa":"Κ","kappa":"κ","kappav":"ϰ","Kcedil":"Ķ","kcedil":"ķ","Kcy":"К","kcy":"к","Kfr":"𝔎","kfr":"𝔨","kgreen":"ĸ","KHcy":"Х","khcy":"х","KJcy":"Ќ","kjcy":"ќ","Kopf":"𝕂","kopf":"𝕜","Kscr":"𝒦","kscr":"𝓀","lAarr":"⇚","Lacute":"Ĺ","lacute":"ĺ","laemptyv":"⦴","lagran":"ℒ","Lambda":"Λ","lambda":"λ","lang":"⟨","Lang":"⟪","langd":"⦑","langle":"⟨","lap":"⪅","Laplacetrf":"ℒ","laquo":"«","larrb":"⇤","larrbfs":"⤟","larr":"←","Larr":"↞","lArr":"⇐","larrfs":"⤝","larrhk":"↩","larrlp":"↫","larrpl":"⤹","larrsim":"⥳","larrtl":"↢","latail":"⤙","lAtail":"⤛","lat":"⪫","late":"⪭","lates":"⪭︀","lbarr":"⤌","lBarr":"⤎","lbbrk":"❲","lbrace":"{","lbrack":"[","lbrke":"⦋","lbrksld":"⦏","lbrkslu":"⦍","Lcaron":"Ľ","lcaron":"ľ","Lcedil":"Ļ","lcedil":"ļ","lceil":"⌈","lcub":"{","Lcy":"Л","lcy":"л","ldca":"⤶","ldquo":"“","ldquor":"„","ldrdhar":"⥧","ldrushar":"⥋","ldsh":"↲","le":"≤","lE":"≦","LeftAngleBracket":"⟨","LeftArrowBar":"⇤","leftarrow":"←","LeftArrow":"←","Leftarrow":"⇐","LeftArrowRightArrow":"⇆","leftarrowtail":"↢","LeftCeiling":"⌈","LeftDoubleBracket":"⟦","LeftDownTeeVector":"⥡","LeftDownVectorBar":"⥙","LeftDownVector":"⇃","LeftFloor":"⌊","leftharpoondown":"↽","leftharpoonup":"↼","leftleftarrows":"⇇","leftrightarrow":"↔","LeftRightArrow":"↔","Leftrightarrow":"⇔","leftrightarrows":"⇆","leftrightharpoons":"⇋","leftrightsquigarrow":"↭","LeftRightVector":"⥎","LeftTeeArrow":"↤","LeftTee":"⊣","LeftTeeVector":"⥚","leftthreetimes":"⋋","LeftTriangleBar":"⧏","LeftTriangle":"⊲","LeftTriangleEqual":"⊴","LeftUpDownVector":"⥑","LeftUpTeeVector":"⥠","LeftUpVectorBar":"⥘","LeftUpVector":"↿","LeftVectorBar":"⥒","LeftVector":"↼","lEg":"⪋","leg":"⋚","leq":"≤","leqq":"≦","leqslant":"⩽","lescc":"⪨","les":"⩽","lesdot":"⩿","lesdoto":"⪁","lesdotor":"⪃","lesg":"⋚︀","lesges":"⪓","lessapprox":"⪅","lessdot":"⋖","lesseqgtr":"⋚","lesseqqgtr":"⪋","LessEqualGreater":"⋚","LessFullEqual":"≦","LessGreater":"≶","lessgtr":"≶","LessLess":"⪡","lesssim":"≲","LessSlantEqual":"⩽","LessTilde":"≲","lfisht":"⥼","lfloor":"⌊","Lfr":"𝔏","lfr":"𝔩","lg":"≶","lgE":"⪑","lHar":"⥢","lhard":"↽","lharu":"↼","lharul":"⥪","lhblk":"▄","LJcy":"Љ","ljcy":"љ","llarr":"⇇","ll":"≪","Ll":"⋘","llcorner":"⌞","Lleftarrow":"⇚","llhard":"⥫","lltri":"◺","Lmidot":"Ŀ","lmidot":"ŀ","lmoustache":"⎰","lmoust":"⎰","lnap":"⪉","lnapprox":"⪉","lne":"⪇","lnE":"≨","lneq":"⪇","lneqq":"≨","lnsim":"⋦","loang":"⟬","loarr":"⇽","lobrk":"⟦","longleftarrow":"⟵","LongLeftArrow":"⟵","Longleftarrow":"⟸","longleftrightarrow":"⟷","LongLeftRightArrow":"⟷","Longleftrightarrow":"⟺","longmapsto":"⟼","longrightarrow":"⟶","LongRightArrow":"⟶","Longrightarrow":"⟹","looparrowleft":"↫","looparrowright":"↬","lopar":"⦅","Lopf":"𝕃","lopf":"𝕝","loplus":"⨭","lotimes":"⨴","lowast":"∗","lowbar":"_","LowerLeftArrow":"↙","LowerRightArrow":"↘","loz":"◊","lozenge":"◊","lozf":"⧫","lpar":"(","lparlt":"⦓","lrarr":"⇆","lrcorner":"⌟","lrhar":"⇋","lrhard":"⥭","lrm":"‎","lrtri":"⊿","lsaquo":"‹","lscr":"𝓁","Lscr":"ℒ","lsh":"↰","Lsh":"↰","lsim":"≲","lsime":"⪍","lsimg":"⪏","lsqb":"[","lsquo":"‘","lsquor":"‚","Lstrok":"Ł","lstrok":"ł","ltcc":"⪦","ltcir":"⩹","lt":"<","LT":"<","Lt":"≪","ltdot":"⋖","lthree":"⋋","ltimes":"⋉","ltlarr":"⥶","ltquest":"⩻","ltri":"◃","ltrie":"⊴","ltrif":"◂","ltrPar":"⦖","lurdshar":"⥊","luruhar":"⥦","lvertneqq":"≨︀","lvnE":"≨︀","macr":"¯","male":"♂","malt":"✠","maltese":"✠","Map":"⤅","map":"↦","mapsto":"↦","mapstodown":"↧","mapstoleft":"↤","mapstoup":"↥","marker":"▮","mcomma":"⨩","Mcy":"М","mcy":"м","mdash":"—","mDDot":"∺","measuredangle":"∡","MediumSpace":" ","Mellintrf":"ℳ","Mfr":"𝔐","mfr":"𝔪","mho":"℧","micro":"µ","midast":"*","midcir":"⫰","mid":"∣","middot":"·","minusb":"⊟","minus":"−","minusd":"∸","minusdu":"⨪","MinusPlus":"∓","mlcp":"⫛","mldr":"…","mnplus":"∓","models":"⊧","Mopf":"𝕄","mopf":"𝕞","mp":"∓","mscr":"𝓂","Mscr":"ℳ","mstpos":"∾","Mu":"Μ","mu":"μ","multimap":"⊸","mumap":"⊸","nabla":"∇","Nacute":"Ń","nacute":"ń","nang":"∠⃒","nap":"≉","napE":"⩰̸","napid":"≋̸","napos":"ʼn","napprox":"≉","natural":"♮","naturals":"ℕ","natur":"♮","nbsp":" ","nbump":"≎̸","nbumpe":"≏̸","ncap":"⩃","Ncaron":"Ň","ncaron":"ň","Ncedil":"Ņ","ncedil":"ņ","ncong":"≇","ncongdot":"⩭̸","ncup":"⩂","Ncy":"Н","ncy":"н","ndash":"–","nearhk":"⤤","nearr":"↗","neArr":"⇗","nearrow":"↗","ne":"≠","nedot":"≐̸","NegativeMediumSpace":"​","NegativeThickSpace":"​","NegativeThinSpace":"​","NegativeVeryThinSpace":"​","nequiv":"≢","nesear":"⤨","nesim":"≂̸","NestedGreaterGreater":"≫","NestedLessLess":"≪","NewLine":"\\n","nexist":"∄","nexists":"∄","Nfr":"𝔑","nfr":"𝔫","ngE":"≧̸","nge":"≱","ngeq":"≱","ngeqq":"≧̸","ngeqslant":"⩾̸","nges":"⩾̸","nGg":"⋙̸","ngsim":"≵","nGt":"≫⃒","ngt":"≯","ngtr":"≯","nGtv":"≫̸","nharr":"↮","nhArr":"⇎","nhpar":"⫲","ni":"∋","nis":"⋼","nisd":"⋺","niv":"∋","NJcy":"Њ","njcy":"њ","nlarr":"↚","nlArr":"⇍","nldr":"‥","nlE":"≦̸","nle":"≰","nleftarrow":"↚","nLeftarrow":"⇍","nleftrightarrow":"↮","nLeftrightarrow":"⇎","nleq":"≰","nleqq":"≦̸","nleqslant":"⩽̸","nles":"⩽̸","nless":"≮","nLl":"⋘̸","nlsim":"≴","nLt":"≪⃒","nlt":"≮","nltri":"⋪","nltrie":"⋬","nLtv":"≪̸","nmid":"∤","NoBreak":"⁠","NonBreakingSpace":" ","nopf":"𝕟","Nopf":"ℕ","Not":"⫬","not":"¬","NotCongruent":"≢","NotCupCap":"≭","NotDoubleVerticalBar":"∦","NotElement":"∉","NotEqual":"≠","NotEqualTilde":"≂̸","NotExists":"∄","NotGreater":"≯","NotGreaterEqual":"≱","NotGreaterFullEqual":"≧̸","NotGreaterGreater":"≫̸","NotGreaterLess":"≹","NotGreaterSlantEqual":"⩾̸","NotGreaterTilde":"≵","NotHumpDownHump":"≎̸","NotHumpEqual":"≏̸","notin":"∉","notindot":"⋵̸","notinE":"⋹̸","notinva":"∉","notinvb":"⋷","notinvc":"⋶","NotLeftTriangleBar":"⧏̸","NotLeftTriangle":"⋪","NotLeftTriangleEqual":"⋬","NotLess":"≮","NotLessEqual":"≰","NotLessGreater":"≸","NotLessLess":"≪̸","NotLessSlantEqual":"⩽̸","NotLessTilde":"≴","NotNestedGreaterGreater":"⪢̸","NotNestedLessLess":"⪡̸","notni":"∌","notniva":"∌","notnivb":"⋾","notnivc":"⋽","NotPrecedes":"⊀","NotPrecedesEqual":"⪯̸","NotPrecedesSlantEqual":"⋠","NotReverseElement":"∌","NotRightTriangleBar":"⧐̸","NotRightTriangle":"⋫","NotRightTriangleEqual":"⋭","NotSquareSubset":"⊏̸","NotSquareSubsetEqual":"⋢","NotSquareSuperset":"⊐̸","NotSquareSupersetEqual":"⋣","NotSubset":"⊂⃒","NotSubsetEqual":"⊈","NotSucceeds":"⊁","NotSucceedsEqual":"⪰̸","NotSucceedsSlantEqual":"⋡","NotSucceedsTilde":"≿̸","NotSuperset":"⊃⃒","NotSupersetEqual":"⊉","NotTilde":"≁","NotTildeEqual":"≄","NotTildeFullEqual":"≇","NotTildeTilde":"≉","NotVerticalBar":"∤","nparallel":"∦","npar":"∦","nparsl":"⫽⃥","npart":"∂̸","npolint":"⨔","npr":"⊀","nprcue":"⋠","nprec":"⊀","npreceq":"⪯̸","npre":"⪯̸","nrarrc":"⤳̸","nrarr":"↛","nrArr":"⇏","nrarrw":"↝̸","nrightarrow":"↛","nRightarrow":"⇏","nrtri":"⋫","nrtrie":"⋭","nsc":"⊁","nsccue":"⋡","nsce":"⪰̸","Nscr":"𝒩","nscr":"𝓃","nshortmid":"∤","nshortparallel":"∦","nsim":"≁","nsime":"≄","nsimeq":"≄","nsmid":"∤","nspar":"∦","nsqsube":"⋢","nsqsupe":"⋣","nsub":"⊄","nsubE":"⫅̸","nsube":"⊈","nsubset":"⊂⃒","nsubseteq":"⊈","nsubseteqq":"⫅̸","nsucc":"⊁","nsucceq":"⪰̸","nsup":"⊅","nsupE":"⫆̸","nsupe":"⊉","nsupset":"⊃⃒","nsupseteq":"⊉","nsupseteqq":"⫆̸","ntgl":"≹","Ntilde":"Ñ","ntilde":"ñ","ntlg":"≸","ntriangleleft":"⋪","ntrianglelefteq":"⋬","ntriangleright":"⋫","ntrianglerighteq":"⋭","Nu":"Ν","nu":"ν","num":"#","numero":"№","numsp":" ","nvap":"≍⃒","nvdash":"⊬","nvDash":"⊭","nVdash":"⊮","nVDash":"⊯","nvge":"≥⃒","nvgt":">⃒","nvHarr":"⤄","nvinfin":"⧞","nvlArr":"⤂","nvle":"≤⃒","nvlt":"<⃒","nvltrie":"⊴⃒","nvrArr":"⤃","nvrtrie":"⊵⃒","nvsim":"∼⃒","nwarhk":"⤣","nwarr":"↖","nwArr":"⇖","nwarrow":"↖","nwnear":"⤧","Oacute":"Ó","oacute":"ó","oast":"⊛","Ocirc":"Ô","ocirc":"ô","ocir":"⊚","Ocy":"О","ocy":"о","odash":"⊝","Odblac":"Ő","odblac":"ő","odiv":"⨸","odot":"⊙","odsold":"⦼","OElig":"Œ","oelig":"œ","ofcir":"⦿","Ofr":"𝔒","ofr":"𝔬","ogon":"˛","Ograve":"Ò","ograve":"ò","ogt":"⧁","ohbar":"⦵","ohm":"Ω","oint":"∮","olarr":"↺","olcir":"⦾","olcross":"⦻","oline":"‾","olt":"⧀","Omacr":"Ō","omacr":"ō","Omega":"Ω","omega":"ω","Omicron":"Ο","omicron":"ο","omid":"⦶","ominus":"⊖","Oopf":"𝕆","oopf":"𝕠","opar":"⦷","OpenCurlyDoubleQuote":"“","OpenCurlyQuote":"‘","operp":"⦹","oplus":"⊕","orarr":"↻","Or":"⩔","or":"∨","ord":"⩝","order":"ℴ","orderof":"ℴ","ordf":"ª","ordm":"º","origof":"⊶","oror":"⩖","orslope":"⩗","orv":"⩛","oS":"Ⓢ","Oscr":"𝒪","oscr":"ℴ","Oslash":"Ø","oslash":"ø","osol":"⊘","Otilde":"Õ","otilde":"õ","otimesas":"⨶","Otimes":"⨷","otimes":"⊗","Ouml":"Ö","ouml":"ö","ovbar":"⌽","OverBar":"‾","OverBrace":"⏞","OverBracket":"⎴","OverParenthesis":"⏜","para":"¶","parallel":"∥","par":"∥","parsim":"⫳","parsl":"⫽","part":"∂","PartialD":"∂","Pcy":"П","pcy":"п","percnt":"%","period":".","permil":"‰","perp":"⊥","pertenk":"‱","Pfr":"𝔓","pfr":"𝔭","Phi":"Φ","phi":"φ","phiv":"ϕ","phmmat":"ℳ","phone":"☎","Pi":"Π","pi":"π","pitchfork":"⋔","piv":"ϖ","planck":"ℏ","planckh":"ℎ","plankv":"ℏ","plusacir":"⨣","plusb":"⊞","pluscir":"⨢","plus":"+","plusdo":"∔","plusdu":"⨥","pluse":"⩲","PlusMinus":"±","plusmn":"±","plussim":"⨦","plustwo":"⨧","pm":"±","Poincareplane":"ℌ","pointint":"⨕","popf":"𝕡","Popf":"ℙ","pound":"£","prap":"⪷","Pr":"⪻","pr":"≺","prcue":"≼","precapprox":"⪷","prec":"≺","preccurlyeq":"≼","Precedes":"≺","PrecedesEqual":"⪯","PrecedesSlantEqual":"≼","PrecedesTilde":"≾","preceq":"⪯","precnapprox":"⪹","precneqq":"⪵","precnsim":"⋨","pre":"⪯","prE":"⪳","precsim":"≾","prime":"′","Prime":"″","primes":"ℙ","prnap":"⪹","prnE":"⪵","prnsim":"⋨","prod":"∏","Product":"∏","profalar":"⌮","profline":"⌒","profsurf":"⌓","prop":"∝","Proportional":"∝","Proportion":"∷","propto":"∝","prsim":"≾","prurel":"⊰","Pscr":"𝒫","pscr":"𝓅","Psi":"Ψ","psi":"ψ","puncsp":" ","Qfr":"𝔔","qfr":"𝔮","qint":"⨌","qopf":"𝕢","Qopf":"ℚ","qprime":"⁗","Qscr":"𝒬","qscr":"𝓆","quaternions":"ℍ","quatint":"⨖","quest":"?","questeq":"≟","quot":"\\"","QUOT":"\\"","rAarr":"⇛","race":"∽̱","Racute":"Ŕ","racute":"ŕ","radic":"√","raemptyv":"⦳","rang":"⟩","Rang":"⟫","rangd":"⦒","range":"⦥","rangle":"⟩","raquo":"»","rarrap":"⥵","rarrb":"⇥","rarrbfs":"⤠","rarrc":"⤳","rarr":"→","Rarr":"↠","rArr":"⇒","rarrfs":"⤞","rarrhk":"↪","rarrlp":"↬","rarrpl":"⥅","rarrsim":"⥴","Rarrtl":"⤖","rarrtl":"↣","rarrw":"↝","ratail":"⤚","rAtail":"⤜","ratio":"∶","rationals":"ℚ","rbarr":"⤍","rBarr":"⤏","RBarr":"⤐","rbbrk":"❳","rbrace":"}","rbrack":"]","rbrke":"⦌","rbrksld":"⦎","rbrkslu":"⦐","Rcaron":"Ř","rcaron":"ř","Rcedil":"Ŗ","rcedil":"ŗ","rceil":"⌉","rcub":"}","Rcy":"Р","rcy":"р","rdca":"⤷","rdldhar":"⥩","rdquo":"”","rdquor":"”","rdsh":"↳","real":"ℜ","realine":"ℛ","realpart":"ℜ","reals":"ℝ","Re":"ℜ","rect":"▭","reg":"®","REG":"®","ReverseElement":"∋","ReverseEquilibrium":"⇋","ReverseUpEquilibrium":"⥯","rfisht":"⥽","rfloor":"⌋","rfr":"𝔯","Rfr":"ℜ","rHar":"⥤","rhard":"⇁","rharu":"⇀","rharul":"⥬","Rho":"Ρ","rho":"ρ","rhov":"ϱ","RightAngleBracket":"⟩","RightArrowBar":"⇥","rightarrow":"→","RightArrow":"→","Rightarrow":"⇒","RightArrowLeftArrow":"⇄","rightarrowtail":"↣","RightCeiling":"⌉","RightDoubleBracket":"⟧","RightDownTeeVector":"⥝","RightDownVectorBar":"⥕","RightDownVector":"⇂","RightFloor":"⌋","rightharpoondown":"⇁","rightharpoonup":"⇀","rightleftarrows":"⇄","rightleftharpoons":"⇌","rightrightarrows":"⇉","rightsquigarrow":"↝","RightTeeArrow":"↦","RightTee":"⊢","RightTeeVector":"⥛","rightthreetimes":"⋌","RightTriangleBar":"⧐","RightTriangle":"⊳","RightTriangleEqual":"⊵","RightUpDownVector":"⥏","RightUpTeeVector":"⥜","RightUpVectorBar":"⥔","RightUpVector":"↾","RightVectorBar":"⥓","RightVector":"⇀","ring":"˚","risingdotseq":"≓","rlarr":"⇄","rlhar":"⇌","rlm":"‏","rmoustache":"⎱","rmoust":"⎱","rnmid":"⫮","roang":"⟭","roarr":"⇾","robrk":"⟧","ropar":"⦆","ropf":"𝕣","Ropf":"ℝ","roplus":"⨮","rotimes":"⨵","RoundImplies":"⥰","rpar":")","rpargt":"⦔","rppolint":"⨒","rrarr":"⇉","Rrightarrow":"⇛","rsaquo":"›","rscr":"𝓇","Rscr":"ℛ","rsh":"↱","Rsh":"↱","rsqb":"]","rsquo":"’","rsquor":"’","rthree":"⋌","rtimes":"⋊","rtri":"▹","rtrie":"⊵","rtrif":"▸","rtriltri":"⧎","RuleDelayed":"⧴","ruluhar":"⥨","rx":"℞","Sacute":"Ś","sacute":"ś","sbquo":"‚","scap":"⪸","Scaron":"Š","scaron":"š","Sc":"⪼","sc":"≻","sccue":"≽","sce":"⪰","scE":"⪴","Scedil":"Ş","scedil":"ş","Scirc":"Ŝ","scirc":"ŝ","scnap":"⪺","scnE":"⪶","scnsim":"⋩","scpolint":"⨓","scsim":"≿","Scy":"С","scy":"с","sdotb":"⊡","sdot":"⋅","sdote":"⩦","searhk":"⤥","searr":"↘","seArr":"⇘","searrow":"↘","sect":"§","semi":";","seswar":"⤩","setminus":"∖","setmn":"∖","sext":"✶","Sfr":"𝔖","sfr":"𝔰","sfrown":"⌢","sharp":"♯","SHCHcy":"Щ","shchcy":"щ","SHcy":"Ш","shcy":"ш","ShortDownArrow":"↓","ShortLeftArrow":"←","shortmid":"∣","shortparallel":"∥","ShortRightArrow":"→","ShortUpArrow":"↑","shy":"­","Sigma":"Σ","sigma":"σ","sigmaf":"ς","sigmav":"ς","sim":"∼","simdot":"⩪","sime":"≃","simeq":"≃","simg":"⪞","simgE":"⪠","siml":"⪝","simlE":"⪟","simne":"≆","simplus":"⨤","simrarr":"⥲","slarr":"←","SmallCircle":"∘","smallsetminus":"∖","smashp":"⨳","smeparsl":"⧤","smid":"∣","smile":"⌣","smt":"⪪","smte":"⪬","smtes":"⪬︀","SOFTcy":"Ь","softcy":"ь","solbar":"⌿","solb":"⧄","sol":"/","Sopf":"𝕊","sopf":"𝕤","spades":"♠","spadesuit":"♠","spar":"∥","sqcap":"⊓","sqcaps":"⊓︀","sqcup":"⊔","sqcups":"⊔︀","Sqrt":"√","sqsub":"⊏","sqsube":"⊑","sqsubset":"⊏","sqsubseteq":"⊑","sqsup":"⊐","sqsupe":"⊒","sqsupset":"⊐","sqsupseteq":"⊒","square":"□","Square":"□","SquareIntersection":"⊓","SquareSubset":"⊏","SquareSubsetEqual":"⊑","SquareSuperset":"⊐","SquareSupersetEqual":"⊒","SquareUnion":"⊔","squarf":"▪","squ":"□","squf":"▪","srarr":"→","Sscr":"𝒮","sscr":"𝓈","ssetmn":"∖","ssmile":"⌣","sstarf":"⋆","Star":"⋆","star":"☆","starf":"★","straightepsilon":"ϵ","straightphi":"ϕ","strns":"¯","sub":"⊂","Sub":"⋐","subdot":"⪽","subE":"⫅","sube":"⊆","subedot":"⫃","submult":"⫁","subnE":"⫋","subne":"⊊","subplus":"⪿","subrarr":"⥹","subset":"⊂","Subset":"⋐","subseteq":"⊆","subseteqq":"⫅","SubsetEqual":"⊆","subsetneq":"⊊","subsetneqq":"⫋","subsim":"⫇","subsub":"⫕","subsup":"⫓","succapprox":"⪸","succ":"≻","succcurlyeq":"≽","Succeeds":"≻","SucceedsEqual":"⪰","SucceedsSlantEqual":"≽","SucceedsTilde":"≿","succeq":"⪰","succnapprox":"⪺","succneqq":"⪶","succnsim":"⋩","succsim":"≿","SuchThat":"∋","sum":"∑","Sum":"∑","sung":"♪","sup1":"¹","sup2":"²","sup3":"³","sup":"⊃","Sup":"⋑","supdot":"⪾","supdsub":"⫘","supE":"⫆","supe":"⊇","supedot":"⫄","Superset":"⊃","SupersetEqual":"⊇","suphsol":"⟉","suphsub":"⫗","suplarr":"⥻","supmult":"⫂","supnE":"⫌","supne":"⊋","supplus":"⫀","supset":"⊃","Supset":"⋑","supseteq":"⊇","supseteqq":"⫆","supsetneq":"⊋","supsetneqq":"⫌","supsim":"⫈","supsub":"⫔","supsup":"⫖","swarhk":"⤦","swarr":"↙","swArr":"⇙","swarrow":"↙","swnwar":"⤪","szlig":"ß","Tab":"\\t","target":"⌖","Tau":"Τ","tau":"τ","tbrk":"⎴","Tcaron":"Ť","tcaron":"ť","Tcedil":"Ţ","tcedil":"ţ","Tcy":"Т","tcy":"т","tdot":"⃛","telrec":"⌕","Tfr":"𝔗","tfr":"𝔱","there4":"∴","therefore":"∴","Therefore":"∴","Theta":"Θ","theta":"θ","thetasym":"ϑ","thetav":"ϑ","thickapprox":"≈","thicksim":"∼","ThickSpace":"  ","ThinSpace":" ","thinsp":" ","thkap":"≈","thksim":"∼","THORN":"Þ","thorn":"þ","tilde":"˜","Tilde":"∼","TildeEqual":"≃","TildeFullEqual":"≅","TildeTilde":"≈","timesbar":"⨱","timesb":"⊠","times":"×","timesd":"⨰","tint":"∭","toea":"⤨","topbot":"⌶","topcir":"⫱","top":"⊤","Topf":"𝕋","topf":"𝕥","topfork":"⫚","tosa":"⤩","tprime":"‴","trade":"™","TRADE":"™","triangle":"▵","triangledown":"▿","triangleleft":"◃","trianglelefteq":"⊴","triangleq":"≜","triangleright":"▹","trianglerighteq":"⊵","tridot":"◬","trie":"≜","triminus":"⨺","TripleDot":"⃛","triplus":"⨹","trisb":"⧍","tritime":"⨻","trpezium":"⏢","Tscr":"𝒯","tscr":"𝓉","TScy":"Ц","tscy":"ц","TSHcy":"Ћ","tshcy":"ћ","Tstrok":"Ŧ","tstrok":"ŧ","twixt":"≬","twoheadleftarrow":"↞","twoheadrightarrow":"↠","Uacute":"Ú","uacute":"ú","uarr":"↑","Uarr":"↟","uArr":"⇑","Uarrocir":"⥉","Ubrcy":"Ў","ubrcy":"ў","Ubreve":"Ŭ","ubreve":"ŭ","Ucirc":"Û","ucirc":"û","Ucy":"У","ucy":"у","udarr":"⇅","Udblac":"Ű","udblac":"ű","udhar":"⥮","ufisht":"⥾","Ufr":"𝔘","ufr":"𝔲","Ugrave":"Ù","ugrave":"ù","uHar":"⥣","uharl":"↿","uharr":"↾","uhblk":"▀","ulcorn":"⌜","ulcorner":"⌜","ulcrop":"⌏","ultri":"◸","Umacr":"Ū","umacr":"ū","uml":"¨","UnderBar":"_","UnderBrace":"⏟","UnderBracket":"⎵","UnderParenthesis":"⏝","Union":"⋃","UnionPlus":"⊎","Uogon":"Ų","uogon":"ų","Uopf":"𝕌","uopf":"𝕦","UpArrowBar":"⤒","uparrow":"↑","UpArrow":"↑","Uparrow":"⇑","UpArrowDownArrow":"⇅","updownarrow":"↕","UpDownArrow":"↕","Updownarrow":"⇕","UpEquilibrium":"⥮","upharpoonleft":"↿","upharpoonright":"↾","uplus":"⊎","UpperLeftArrow":"↖","UpperRightArrow":"↗","upsi":"υ","Upsi":"ϒ","upsih":"ϒ","Upsilon":"Υ","upsilon":"υ","UpTeeArrow":"↥","UpTee":"⊥","upuparrows":"⇈","urcorn":"⌝","urcorner":"⌝","urcrop":"⌎","Uring":"Ů","uring":"ů","urtri":"◹","Uscr":"𝒰","uscr":"𝓊","utdot":"⋰","Utilde":"Ũ","utilde":"ũ","utri":"▵","utrif":"▴","uuarr":"⇈","Uuml":"Ü","uuml":"ü","uwangle":"⦧","vangrt":"⦜","varepsilon":"ϵ","varkappa":"ϰ","varnothing":"∅","varphi":"ϕ","varpi":"ϖ","varpropto":"∝","varr":"↕","vArr":"⇕","varrho":"ϱ","varsigma":"ς","varsubsetneq":"⊊︀","varsubsetneqq":"⫋︀","varsupsetneq":"⊋︀","varsupsetneqq":"⫌︀","vartheta":"ϑ","vartriangleleft":"⊲","vartriangleright":"⊳","vBar":"⫨","Vbar":"⫫","vBarv":"⫩","Vcy":"В","vcy":"в","vdash":"⊢","vDash":"⊨","Vdash":"⊩","VDash":"⊫","Vdashl":"⫦","veebar":"⊻","vee":"∨","Vee":"⋁","veeeq":"≚","vellip":"⋮","verbar":"|","Verbar":"‖","vert":"|","Vert":"‖","VerticalBar":"∣","VerticalLine":"|","VerticalSeparator":"❘","VerticalTilde":"≀","VeryThinSpace":" ","Vfr":"𝔙","vfr":"𝔳","vltri":"⊲","vnsub":"⊂⃒","vnsup":"⊃⃒","Vopf":"𝕍","vopf":"𝕧","vprop":"∝","vrtri":"⊳","Vscr":"𝒱","vscr":"𝓋","vsubnE":"⫋︀","vsubne":"⊊︀","vsupnE":"⫌︀","vsupne":"⊋︀","Vvdash":"⊪","vzigzag":"⦚","Wcirc":"Ŵ","wcirc":"ŵ","wedbar":"⩟","wedge":"∧","Wedge":"⋀","wedgeq":"≙","weierp":"℘","Wfr":"𝔚","wfr":"𝔴","Wopf":"𝕎","wopf":"𝕨","wp":"℘","wr":"≀","wreath":"≀","Wscr":"𝒲","wscr":"𝓌","xcap":"⋂","xcirc":"◯","xcup":"⋃","xdtri":"▽","Xfr":"𝔛","xfr":"𝔵","xharr":"⟷","xhArr":"⟺","Xi":"Ξ","xi":"ξ","xlarr":"⟵","xlArr":"⟸","xmap":"⟼","xnis":"⋻","xodot":"⨀","Xopf":"𝕏","xopf":"𝕩","xoplus":"⨁","xotime":"⨂","xrarr":"⟶","xrArr":"⟹","Xscr":"𝒳","xscr":"𝓍","xsqcup":"⨆","xuplus":"⨄","xutri":"△","xvee":"⋁","xwedge":"⋀","Yacute":"Ý","yacute":"ý","YAcy":"Я","yacy":"я","Ycirc":"Ŷ","ycirc":"ŷ","Ycy":"Ы","ycy":"ы","yen":"¥","Yfr":"𝔜","yfr":"𝔶","YIcy":"Ї","yicy":"ї","Yopf":"𝕐","yopf":"𝕪","Yscr":"𝒴","yscr":"𝓎","YUcy":"Ю","yucy":"ю","yuml":"ÿ","Yuml":"Ÿ","Zacute":"Ź","zacute":"ź","Zcaron":"Ž","zcaron":"ž","Zcy":"З","zcy":"з","Zdot":"Ż","zdot":"ż","zeetrf":"ℨ","ZeroWidthSpace":"​","Zeta":"Ζ","zeta":"ζ","zfr":"𝔷","Zfr":"ℨ","ZHcy":"Ж","zhcy":"ж","zigrarr":"⇝","zopf":"𝕫","Zopf":"ℤ","Zscr":"𝒵","zscr":"𝓏","zwj":"‍","zwnj":"‌"}')}},e={};function n(o){var i=e[o];if(void 0!==i)return i.exports;var r=e[o]={id:o,exports:{}};return t[o](r,r.exports,n),r.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var o in e)n.o(e,o)&&!n.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};return(()=>{"use strict";const t=function(){return function t(){t.called=!0}};class e{constructor(e,n){this.source=e,this.name=n,this.path=[],this.stop=t(),this.off=t()}}const o=new Array(256).fill().map(((t,e)=>("0"+e.toString(16)).slice(-2)));function i(){const t=4294967296*Math.random()>>>0,e=4294967296*Math.random()>>>0,n=4294967296*Math.random()>>>0,i=4294967296*Math.random()>>>0;return"e"+o[t>>0&255]+o[t>>8&255]+o[t>>16&255]+o[t>>24&255]+o[e>>0&255]+o[e>>8&255]+o[e>>16&255]+o[e>>24&255]+o[n>>0&255]+o[n>>8&255]+o[n>>16&255]+o[n>>24&255]+o[i>>0&255]+o[i>>8&255]+o[i>>16&255]+o[i>>24&255]}const r={get(t){return"number"!=typeof t?this[t]||this.normal:t},highest:1e5,high:1e3,normal:0,low:-1e3,lowest:-1e5};class s extends Error{constructor(t,e,n){super(function(t,e){const n=new WeakSet,o=(t,e)=>{if("object"==typeof e&&null!==e){if(n.has(e))return`[object ${e.constructor.name}]`;n.add(e)}return e},i=e?` ${JSON.stringify(e,o)}`:"",r=c(t);return t+i+r}(t,n)),this.name="CKEditorError",this.context=e,this.data=n}is(t){return"CKEditorError"===t}static rethrowUnexpectedError(t,e){if(t.is&&t.is("CKEditorError"))throw t;const n=new s(t.message,e);throw n.stack=t.stack,n}}function a(t,e){console.warn(...l(t,e))}function c(t){return`\nRead more: https://ckeditor.com/docs/ckeditor5/latest/framework/guides/support/error-codes.html#error-${t}`}function l(t,e){const n=c(t);return e?[t,e,n]:[t,n]}const d="32.0.0",u="object"==typeof window?window:n.g;if(u.CKEDITOR_VERSION)throw new s("ckeditor-duplicated-modules",null);u.CKEDITOR_VERSION=d;const h=Symbol("listeningTo"),p=Symbol("emitterId"),m={on(t,e,n={}){this.listenTo(this,t,e,n)},once(t,e,n){let o=!1;this.listenTo(this,t,(function(t,...n){o||(o=!0,t.off(),e.call(this,t,...n))}),n)},off(t,e){this.stopListening(this,t,e)},listenTo(t,e,n,o={}){let i,r;this[h]||(this[h]={});const s=this[h];b(t)||f(t);const a=b(t);(i=s[a])||(i=s[a]={emitter:t,callbacks:{}}),(r=i.callbacks[e])||(r=i.callbacks[e]=[]),r.push(n),function(t,e,n,o,i){e._addEventListener?e._addEventListener(n,o,i):t._addEventListener.call(e,n,o,i)}(this,t,e,n,o)},stopListening(t,e,n){const o=this[h];let i=t&&b(t);const r=o&&i&&o[i],s=r&&e&&r.callbacks[e];if(!(!o||t&&!r||e&&!s))if(n){v(this,t,e,n);-1!==s.indexOf(n)&&(1===s.length?delete r.callbacks[e]:v(this,t,e,n))}else if(s){for(;n=s.pop();)v(this,t,e,n);delete r.callbacks[e]}else if(r){for(e in r.callbacks)this.stopListening(t,e);delete o[i]}else{for(i in o)this.stopListening(o[i].emitter);delete this[h]}},fire(t,...n){try{const o=t instanceof e?t:new e(this,t),i=o.name;let r=C(this,i);if(o.path.push(this),r){const t=[o,...n];r=Array.from(r);for(let e=0;e{this._delegations||(this._delegations=new Map),t.forEach((t=>{const o=this._delegations.get(t);o?o.set(e,n):this._delegations.set(t,new Map([[e,n]]))}))}}},stopDelegating(t,e){if(this._delegations)if(t)if(e){const n=this._delegations.get(t);n&&n.delete(e)}else this._delegations.delete(t);else this._delegations.clear()},_addEventListener(t,e,n){!function(t,e){const n=k(t);if(n[e])return;let o=e,i=null;const r=[];for(;""!==o&&!n[o];)n[o]={callbacks:[],childEvents:[]},r.push(n[o]),i&&n[o].childEvents.push(i),i=o,o=o.substr(0,o.lastIndexOf(":"));if(""!==o){for(const t of r)t.callbacks=n[o].callbacks.slice();n[o].childEvents.push(i)}}(this,t);const o=w(this,t),i=r.get(n.priority),s={callback:e,priority:i};for(const t of o){let e=!1;for(let n=0;n-1?C(t,e.substr(0,e.lastIndexOf(":"))):null}function A(t,n,o){for(let[i,r]of t){r?"function"==typeof r&&(r=r(n.name)):r=n.name;const t=new e(n.source,r);t.path=[...n.path],i.fire(t,...o)}}function v(t,e,n,o){e._removeEventListener?e._removeEventListener(n,o):t._removeEventListener.call(e,n,o)}const y=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)};const x="object"==typeof global&&global&&global.Object===Object&&global;var E="object"==typeof self&&self&&self.Object===Object&&self;const D=x||E||Function("return this")();const S=D.Symbol;var B=Object.prototype,T=B.hasOwnProperty,P=B.toString,I=S?S.toStringTag:void 0;const R=function(t){var e=T.call(t,I),n=t[I];try{t[I]=void 0;var o=!0}catch(t){}var i=P.call(t);return o&&(e?t[I]=n:delete t[I]),i};var z=Object.prototype.toString;const F=function(t){return z.call(t)};var N=S?S.toStringTag:void 0;const O=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":N&&N in Object(t)?R(t):F(t)};const M=function(t){if(!y(t))return!1;var e=O(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e};const V=D["__core-js_shared__"];var L=function(){var t=/[^.]+$/.exec(V&&V.keys&&V.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();const H=function(t){return!!L&&L in t};var q=Function.prototype.toString;const W=function(t){if(null!=t){try{return q.call(t)}catch(t){}try{return t+""}catch(t){}}return""};var j=/^\[object .+?Constructor\]$/,U=Function.prototype,$=Object.prototype,G=U.toString,K=$.hasOwnProperty,Z=RegExp("^"+G.call(K).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");const J=function(t){return!(!y(t)||H(t))&&(M(t)?Z:j).test(W(t))};const Y=function(t,e){return null==t?void 0:t[e]};const Q=function(t,e){var n=Y(t,e);return J(n)?n:void 0};const X=function(){try{var t=Q(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();const tt=function(t,e,n){"__proto__"==e&&X?X(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n};const et=function(t,e){return t===e||t!=t&&e!=e};var nt=Object.prototype.hasOwnProperty;const ot=function(t,e,n){var o=t[e];nt.call(t,e)&&et(o,n)&&(void 0!==n||e in t)||tt(t,e,n)};const it=function(t,e,n,o){var i=!n;n||(n={});for(var r=-1,s=e.length;++r0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}};const pt=ht(dt);const mt=function(t,e){return pt(ct(t,e,rt),t+"")};const gt=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991};const ft=function(t){return null!=t&>(t.length)&&!M(t)};var bt=/^(?:0|[1-9]\d*)$/;const kt=function(t,e){var n=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==n||"symbol"!=n&&bt.test(t))&&t>-1&&t%1==0&&t1?n[i-1]:void 0,s=i>2?n[2]:void 0;for(r=t.length>3&&"function"==typeof r?(i--,r):void 0,s&&wt(n[0],n[1],s)&&(r=i<3?void 0:r,i=1),e=Object(e);++o{this.set(e,t[e])}),this);ae(this);const n=this[te];if(t in this&&!n.has(t))throw new s("observable-set-cannot-override",this);Object.defineProperty(this,t,{enumerable:!0,configurable:!0,get:()=>n.get(t),set(e){const o=n.get(t);let i=this.fire("set:"+t,t,e,o);void 0===i&&(i=e),o===i&&n.has(t)||(n.set(t,i),this.fire("change:"+t,t,i,o))}}),this[t]=e},bind(...t){if(!t.length||!de(t))throw new s("observable-bind-wrong-properties",this);if(new Set(t).size!==t.length)throw new s("observable-bind-duplicate-properties",this);ae(this);const e=this[ne];t.forEach((t=>{if(e.has(t))throw new s("observable-bind-rebind",this)}));const n=new Map;return t.forEach((t=>{const o={property:t,to:[]};e.set(t,o),n.set(t,o)})),{to:ce,toMany:le,_observable:this,_bindProperties:t,_to:[],_bindings:n}},unbind(...t){if(!this[te])return;const e=this[ne],n=this[ee];if(t.length){if(!de(t))throw new s("observable-unbind-wrong-properties",this);t.forEach((t=>{const o=e.get(t);if(!o)return;let i,r,s,a;o.to.forEach((t=>{i=t[0],r=t[1],s=n.get(i),a=s[r],a.delete(o),a.size||delete s[r],Object.keys(s).length||(n.delete(i),this.stopListening(i,"change"))})),e.delete(t)}))}else n.forEach(((t,e)=>{this.stopListening(e,"change")})),n.clear(),e.clear()},decorate(t){const e=this[t];if(!e)throw new s("observablemixin-cannot-decorate-undefined",this,{object:this,methodName:t});this.on(t,((t,n)=>{t.return=e.apply(this,n)})),this[t]=function(...e){return this.fire(t,e)},this[t][ie]=e,this[oe]||(this[oe]=[]),this[oe].push(t)}};Xt(re,g),re.stopListening=function(t,e,n){if(!t&&this[oe]){for(const t of this[oe])this[t]=this[t][ie];delete this[oe]}g.stopListening.call(this,t,e,n)};const se=re;function ae(t){t[te]||(Object.defineProperty(t,te,{value:new Map}),Object.defineProperty(t,ee,{value:new Map}),Object.defineProperty(t,ne,{value:new Map}))}function ce(...t){const e=function(...t){if(!t.length)throw new s("observable-bind-to-parse-error",null);const e={to:[]};let n;"function"==typeof t[t.length-1]&&(e.callback=t.pop());return t.forEach((t=>{if("string"==typeof t)n.properties.push(t);else{if("object"!=typeof t)throw new s("observable-bind-to-parse-error",null);n={observable:t,properties:[]},e.to.push(n)}})),e}(...t),n=Array.from(this._bindings.keys()),o=n.length;if(!e.callback&&e.to.length>1)throw new s("observable-bind-to-no-callback",this);if(o>1&&e.callback)throw new s("observable-bind-to-extra-callback",this);var i;e.to.forEach((t=>{if(t.properties.length&&t.properties.length!==o)throw new s("observable-bind-to-properties-length",this);t.properties.length||(t.properties=this._bindProperties)})),this._to=e.to,e.callback&&(this._bindings.get(n[0]).callback=e.callback),i=this._observable,this._to.forEach((t=>{const e=i[ee];let n;e.get(t.observable)||i.listenTo(t.observable,"change",((o,r)=>{n=e.get(t.observable)[r],n&&n.forEach((t=>{ue(i,t.property)}))}))})),function(t){let e;t._bindings.forEach(((n,o)=>{t._to.forEach((i=>{e=i.properties[n.callback?0:t._bindProperties.indexOf(o)],n.to.push([i.observable,e]),function(t,e,n,o){const i=t[ee],r=i.get(n),s=r||{};s[o]||(s[o]=new Set);s[o].add(e),r||i.set(n,s)}(t._observable,n,i.observable,e)}))}))}(this),this._bindProperties.forEach((t=>{ue(this._observable,t)}))}function le(t,e,n){if(this._bindings.size>1)throw new s("observable-bind-to-many-not-one-binding",this);this.to(...function(t,e){const n=t.map((t=>[t,e]));return Array.prototype.concat.apply([],n)}(t,e),n)}function de(t){return t.every((t=>"string"==typeof t))}function ue(t,e){const n=t[ne].get(e);let o;n.callback?o=n.callback.apply(t,n.to.map((t=>t[0][t[1]]))):(o=n.to[0],o=o[0][o[1]]),Object.prototype.hasOwnProperty.call(t,e)?t[e]=o:t.set(e,o)}function he(t,...e){e.forEach((e=>{Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e)).forEach((n=>{if(n in t.prototype)return;const o=Object.getOwnPropertyDescriptor(e,n);o.enumerable=!1,Object.defineProperty(t.prototype,n,o)}))}))}class pe{constructor(t){this.editor=t,this.set("isEnabled",!0),this._disableStack=new Set}forceDisabled(t){this._disableStack.add(t),1==this._disableStack.size&&(this.on("set:isEnabled",me,{priority:"highest"}),this.isEnabled=!1)}clearForceDisabled(t){this._disableStack.delete(t),0==this._disableStack.size&&(this.off("set:isEnabled",me),this.isEnabled=!0)}destroy(){this.stopListening()}static get isContextPlugin(){return!1}}function me(t){t.return=!1,t.stop()}he(pe,se);class ge{constructor(t){this.editor=t,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",(t=>{this.isEnabled||t.stop()}),{priority:"high"}),this.listenTo(t,"change:isReadOnly",((t,e,n)=>{n&&this.affectsData?this.forceDisabled("readOnlyMode"):this.clearForceDisabled("readOnlyMode")}))}refresh(){this.isEnabled=!0}forceDisabled(t){this._disableStack.add(t),1==this._disableStack.size&&(this.on("set:isEnabled",fe,{priority:"highest"}),this.isEnabled=!1)}clearForceDisabled(t){this._disableStack.delete(t),0==this._disableStack.size&&(this.off("set:isEnabled",fe),this.refresh())}execute(){}destroy(){this.stopListening()}}function fe(t){t.return=!1,t.stop()}he(ge,se);const be=function(t,e){return function(n){return t(e(n))}};const ke=be(Object.getPrototypeOf,Object);var we=Function.prototype,_e=Object.prototype,Ce=we.toString,Ae=_e.hasOwnProperty,ve=Ce.call(Object);const ye=function(t){if(!At(t)||"[object Object]"!=O(t))return!1;var e=ke(t);if(null===e)return!0;var n=Ae.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&Ce.call(n)==ve};const xe=function(){this.__data__=[],this.size=0};const Ee=function(t,e){for(var n=t.length;n--;)if(et(t[n][0],e))return n;return-1};var De=Array.prototype.splice;const Se=function(t){var e=this.__data__,n=Ee(e,t);return!(n<0)&&(n==e.length-1?e.pop():De.call(e,n,1),--this.size,!0)};const Be=function(t){var e=this.__data__,n=Ee(e,t);return n<0?void 0:e[n][1]};const Te=function(t){return Ee(this.__data__,t)>-1};const Pe=function(t,e){var n=this.__data__,o=Ee(n,t);return o<0?(++this.size,n.push([t,e])):n[o][1]=e,this};function Ie(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e{this._setToTarget(t,o,e[o],n)}))}}function xo(t){return Ao(t,Eo)}function Eo(t){return vo(t)?t:void 0}function Do(t){return!(!t||!t[Symbol.iterator])}class So{constructor(t={},e={}){const n=Do(t);if(n||(e=t),this._items=[],this._itemMap=new Map,this._idProperty=e.idProperty||"id",this._bindToExternalToInternalMap=new WeakMap,this._bindToInternalToExternalMap=new WeakMap,this._skippedIndexesFromExternal=[],n)for(const e of t)this._items.push(e),this._itemMap.set(this._getItemIdBeforeAdding(e),e)}get length(){return this._items.length}get first(){return this._items[0]||null}get last(){return this._items[this.length-1]||null}add(t,e){return this.addMany([t],e)}addMany(t,e){if(void 0===e)e=this._items.length;else if(e>this._items.length||e<0)throw new s("collection-add-item-invalid-index",this);for(let n=0;n{this._setUpBindToBinding((e=>new t(e)))},using:t=>{"function"==typeof t?this._setUpBindToBinding((e=>t(e))):this._setUpBindToBinding((e=>e[t]))}}}_setUpBindToBinding(t){const e=this._bindToCollection,n=(n,o,i)=>{const r=e._bindToCollection==this,s=e._bindToInternalToExternalMap.get(o);if(r&&s)this._bindToExternalToInternalMap.set(o,s),this._bindToInternalToExternalMap.set(s,o);else{const n=t(o);if(!n)return void this._skippedIndexesFromExternal.push(i);let r=i;for(const t of this._skippedIndexesFromExternal)i>t&&r--;for(const t of e._skippedIndexesFromExternal)r>=t&&r++;this._bindToExternalToInternalMap.set(o,n),this._bindToInternalToExternalMap.set(n,o),this.add(n,r);for(let t=0;t{const o=this._bindToExternalToInternalMap.get(e);o&&this.remove(o),this._skippedIndexesFromExternal=this._skippedIndexesFromExternal.reduce(((t,e)=>(ne&&t.push(e),t)),[])}))}_getItemIdBeforeAdding(t){const e=this._idProperty;let n;if(e in t){if(n=t[e],"string"!=typeof n)throw new s("collection-add-invalid-id",this);if(this.get(n))throw new s("collection-add-item-already-exists",this)}else t[e]=n=i();return n}_remove(t){let e,n,o,i=!1;const r=this._idProperty;if("string"==typeof t?(n=t,o=this._itemMap.get(n),i=!o,o&&(e=this._items.indexOf(o))):"number"==typeof t?(e=t,o=this._items[e],i=!o,o&&(n=o[r])):(o=t,n=o[r],e=this._items.indexOf(o),i=-1==e||!this._itemMap.get(n)),i)throw new s("collection-remove-404",this);this._items.splice(e,1),this._itemMap.delete(n);const a=this._bindToInternalToExternalMap.get(o);return this._bindToInternalToExternalMap.delete(o),this._bindToExternalToInternalMap.delete(a),this.fire("remove",o,e),[o,e]}[Symbol.iterator](){return this._items[Symbol.iterator]()}}he(So,g);class Bo{constructor(t,e=[],n=[]){this._context=t,this._plugins=new Map,this._availablePlugins=new Map;for(const t of e)t.pluginName&&this._availablePlugins.set(t.pluginName,t);this._contextPlugins=new Map;for(const[t,e]of n)this._contextPlugins.set(t,e),this._contextPlugins.set(e,t),t.pluginName&&this._availablePlugins.set(t.pluginName,t)}*[Symbol.iterator](){for(const t of this._plugins)"function"==typeof t[0]&&(yield t)}get(t){const e=this._plugins.get(t);if(!e){let e=t;throw"function"==typeof t&&(e=t.pluginName||t.name),new s("plugincollection-plugin-not-loaded",this._context,{plugin:e})}return e}has(t){return this._plugins.has(t)}init(t,e=[],n=[]){const o=this,i=this._context;!function t(e,n=new Set){e.forEach((e=>{c(e)&&(n.has(e)||(n.add(e),e.pluginName&&!o._availablePlugins.has(e.pluginName)&&o._availablePlugins.set(e.pluginName,e),e.requires&&t(e.requires,n)))}))}(t),h(t);const r=[...function t(e,n=new Set){return e.map((t=>c(t)?t:o._availablePlugins.get(t))).reduce(((e,o)=>n.has(o)?e:(n.add(o),o.requires&&(h(o.requires,o),t(o.requires,n).forEach((t=>e.add(t)))),e.add(o))),new Set)}(t.filter((t=>!d(t,e))))];!function(t,e){for(const n of e){if("function"!=typeof n)throw new s("plugincollection-replace-plugin-invalid-type",null,{pluginItem:n});const e=n.pluginName;if(!e)throw new s("plugincollection-replace-plugin-missing-name",null,{pluginItem:n});if(n.requires&&n.requires.length)throw new s("plugincollection-plugin-for-replacing-cannot-have-dependencies",null,{pluginName:e});const i=o._availablePlugins.get(e);if(!i)throw new s("plugincollection-plugin-for-replacing-not-exist",null,{pluginName:e});const r=t.indexOf(i);if(-1===r){if(o._contextPlugins.has(i))return;throw new s("plugincollection-plugin-for-replacing-not-loaded",null,{pluginName:e})}if(i.requires&&i.requires.length)throw new s("plugincollection-replaced-plugin-cannot-have-dependencies",null,{pluginName:e});t.splice(r,1,n),o._availablePlugins.set(e,n)}}(r,n);const a=function(t){return t.map((t=>{const e=o._contextPlugins.get(t)||new t(i);return o._add(t,e),e}))}(r);return p(a,"init").then((()=>p(a,"afterInit"))).then((()=>a));function c(t){return"function"==typeof t}function l(t){return c(t)&&t.isContextPlugin}function d(t,e){return e.some((e=>e===t||(u(t)===e||u(e)===t)))}function u(t){return c(t)?t.pluginName||t.name:t}function h(t,n=null){t.map((t=>c(t)?t:o._availablePlugins.get(t)||t)).forEach((t=>{!function(t,e){if(c(t))return;if(e)throw new s("plugincollection-soft-required",i,{missingPlugin:t,requiredBy:u(e)});throw new s("plugincollection-plugin-not-found",i,{plugin:t})}(t,n),function(t,e){if(!l(e))return;if(l(t))return;throw new s("plugincollection-context-required",i,{plugin:u(t),requiredBy:u(e)})}(t,n),function(t,n){if(!n)return;if(!d(t,e))return;throw new s("plugincollection-required",i,{plugin:u(t),requiredBy:u(n)})}(t,n)}))}function p(t,e){return t.reduce(((t,n)=>n[e]?o._contextPlugins.has(n)?t:t.then(n[e].bind(n)):t),Promise.resolve())}}destroy(){const t=[];for(const[,e]of this)"function"!=typeof e.destroy||this._contextPlugins.has(e)||t.push(e.destroy());return Promise.all(t)}_add(t,e){this._plugins.set(t,e);const n=t.pluginName;if(n){if(this._plugins.has(n))throw new s("plugincollection-plugin-name-conflict",null,{pluginName:n,plugin1:this._plugins.get(n).constructor,plugin2:t});this._plugins.set(n,e)}}}function To(t){return Array.isArray(t)?t:[t]}function Po(t,e,n=1){if("number"!=typeof n)throw new s("translation-service-quantity-not-a-number",null,{quantity:n});const o=Object.keys(window.CKEDITOR_TRANSLATIONS).length;1===o&&(t=Object.keys(window.CKEDITOR_TRANSLATIONS)[0]);const i=e.id||e.string;if(0===o||!function(t,e){return!!window.CKEDITOR_TRANSLATIONS[t]&&!!window.CKEDITOR_TRANSLATIONS[t].dictionary[e]}(t,i))return 1!==n?e.plural:e.string;const r=window.CKEDITOR_TRANSLATIONS[t].dictionary,a=window.CKEDITOR_TRANSLATIONS[t].getPluralForm||(t=>1===t?0:1);if("string"==typeof r[i])return r[i];const c=Number(a(n));return r[i][c]}he(Bo,g),window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={});const Io=["ar","ara","fa","per","fas","he","heb","ku","kur","ug","uig"];function Ro(t){return Io.includes(t)?"rtl":"ltr"}class zo{constructor(t={}){this.uiLanguage=t.uiLanguage||"en",this.contentLanguage=t.contentLanguage||this.uiLanguage,this.uiLanguageDirection=Ro(this.uiLanguage),this.contentLanguageDirection=Ro(this.contentLanguage),this.t=(t,e)=>this._t(t,e)}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(t,e=[]){e=To(e),"string"==typeof t&&(t={string:t});const n=!!t.plural?e[0]:1;return function(t,e){return t.replace(/%(\d+)/g,((t,n)=>nt.destroy()))).then((()=>this.plugins.destroy()))}_addEditor(t,e){if(this._contextOwner)throw new s("context-addeditor-private-context");this.editors.add(t),e&&(this._contextOwner=t)}_removeEditor(t){return this.editors.has(t)&&this.editors.remove(t),this._contextOwner===t?this.destroy():Promise.resolve()}_getEditorConfig(){const t={};for(const e of this.config.names())["plugins","removePlugins","extraPlugins"].includes(e)||(t[e]=this.config.get(e));return t}static create(t){return new Promise((e=>{const n=new this(t);e(n.initPlugins().then((()=>n)))}))}}class No{constructor(t){this.context=t}destroy(){this.stopListening()}static get isContextPlugin(){return!0}}function Oo(t,e){const n=Math.min(t.length,e.length);for(let o=0;ot.data.length)throw new s("view-textproxy-wrong-offsetintext",this);if(n<0||e+n>t.data.length)throw new s("view-textproxy-wrong-length",this);this.data=t.data.substring(e,e+n),this.offsetInText=e}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(t){return"$textProxy"===t||"view:$textProxy"===t||"textProxy"===t||"view:textProxy"===t}getAncestors(t={includeSelf:!1,parentFirst:!1}){const e=[];let n=t.includeSelf?this.textNode:this.parent;for(;null!==n;)e[t.parentFirst?"push":"unshift"](n),n=n.parent;return e}}function qo(t){return Do(t)?new Map(t):function(t){const e=new Map;for(const n in t)e.set(n,t[n]);return e}(t)}class Wo{constructor(...t){this._patterns=[],this.add(...t)}add(...t){for(let e of t)("string"==typeof e||e instanceof RegExp)&&(e={name:e}),this._patterns.push(e)}match(...t){for(const e of t)for(const t of this._patterns){const n=jo(e,t);if(n)return{element:e,pattern:t,match:n}}return null}matchAll(...t){const e=[];for(const n of t)for(const t of this._patterns){const o=jo(n,t);o&&e.push({element:n,pattern:t,match:o})}return e.length>0?e:null}getElementName(){if(1!==this._patterns.length)return null;const t=this._patterns[0],e=t.name;return"function"==typeof t||!e||e instanceof RegExp?null:e}}function jo(t,e){if("function"==typeof e)return e(t);const n={};return e.name&&(n.name=function(t,e){if(t instanceof RegExp)return!!e.match(t);return t===e}(e.name,t.name),!n.name)||e.attributes&&(n.attributes=function(t,e){const n=new Set(e.getAttributeKeys());ye(t)?(void 0!==t.style&&a("matcher-pattern-deprecated-attributes-style-key",t),void 0!==t.class&&a("matcher-pattern-deprecated-attributes-class-key",t)):(n.delete("style"),n.delete("class"));return Uo(t,n,(t=>e.getAttribute(t)))}(e.attributes,t),!n.attributes)?null:!(e.classes&&(n.classes=function(t,e){return Uo(t,e.getClassNames())}(e.classes,t),!n.classes))&&(!(e.styles&&(n.styles=function(t,e){return Uo(t,e.getStyleNames(!0),(t=>e.getStyle(t)))}(e.styles,t),!n.styles))&&n)}function Uo(t,e,n){const o=function(t){if(Array.isArray(t))return t.map((t=>ye(t)?(void 0!==t.key&&void 0!==t.value||a("matcher-pattern-missing-key-or-value",t),[t.key,t.value]):[t,!0]));if(ye(t))return Object.entries(t);return[[t,!0]]}(t),i=Array.from(e),r=[];return o.forEach((([t,e])=>{i.forEach((o=>{(function(t,e){return!0===t||t===e||t instanceof RegExp&&e.match(t)})(t,o)&&function(t,e,n){if(!0===t)return!0;const o=n(e);return t===o||t instanceof RegExp&&!!String(o).match(t)}(e,o,n)&&r.push(o)}))})),!o.length||r.lengthi?0:i+e),(n=n>i?i:n)<0&&(n+=i),i=e>n?0:n-e>>>0,e>>>=0;for(var r=Array(i);++oe===t));return Array.isArray(e)}set(t,e){if(y(t))for(const[e,n]of Object.entries(t))this._styleProcessor.toNormalizedForm(e,n,this._styles);else this._styleProcessor.toNormalizedForm(t,e,this._styles)}remove(t){const e=Bi(t);mi(this._styles,e),delete this._styles[t],this._cleanEmptyObjectsOnPath(e)}getNormalized(t){return this._styleProcessor.getNormalized(t,this._styles)}toString(){return this.isEmpty?"":this._getStylesEntries().map((t=>t.join(":"))).sort().join(";")+";"}getAsString(t){if(this.isEmpty)return;if(this._styles[t]&&!y(this._styles[t]))return this._styles[t];const e=this._styleProcessor.getReducedForm(t,this._styles).find((([e])=>e===t));return Array.isArray(e)?e[1]:void 0}getStyleNames(t=!1){if(this.isEmpty)return[];if(t)return this._styleProcessor.getStyleNames(this._styles);return this._getStylesEntries().map((([t])=>t))}clear(){this._styles={}}_getStylesEntries(){const t=[],e=Object.keys(this._styles);for(const n of e)t.push(...this._styleProcessor.getReducedForm(n,this._styles));return t}_cleanEmptyObjectsOnPath(t){const e=t.split(".");if(!(e.length>1))return;const n=e.splice(0,e.length-1).join("."),o=gi(this._styles,n);if(!o)return;!Array.from(Object.keys(o)).length&&this.remove(n)}}class Si{constructor(){this._normalizers=new Map,this._extractors=new Map,this._reducers=new Map,this._consumables=new Map}toNormalizedForm(t,e,n){if(y(e))Ti(n,Bi(t),e);else if(this._normalizers.has(t)){const o=this._normalizers.get(t),{path:i,value:r}=o(e);Ti(n,i,r)}else Ti(n,t,e)}getNormalized(t,e){if(!t)return yi({},e);if(void 0!==e[t])return e[t];if(this._extractors.has(t)){const n=this._extractors.get(t);if("string"==typeof n)return gi(e,n);const o=n(t,e);if(o)return o}return gi(e,Bi(t))}getReducedForm(t,e){const n=this.getNormalized(t,e);if(void 0===n)return[];if(this._reducers.has(t)){return this._reducers.get(t)(n)}return[[t,n]]}getStyleNames(t){const e=Array.from(this._consumables.keys()).filter((e=>{const n=this.getNormalized(e,t);return n&&"object"==typeof n?Object.keys(n).length:n})),n=new Set([...e,...Object.keys(t)]);return Array.from(n.values())}getRelatedStyles(t){return this._consumables.get(t)||[]}setNormalizer(t,e){this._normalizers.set(t,e)}setExtractor(t,e){this._extractors.set(t,e)}setReducer(t,e){this._reducers.set(t,e)}setStyleRelation(t,e){this._mapStyleNames(t,e);for(const n of e)this._mapStyleNames(n,[t])}_mapStyleNames(t,e){this._consumables.has(t)||this._consumables.set(t,[]),this._consumables.get(t).push(...e)}}function Bi(t){return t.replace("-",".")}function Ti(t,e,n){let o=n;y(n)&&(o=yi({},gi(t,e),n)),Ei(t,e,o)}class Pi extends Vo{constructor(t,e,n,o){if(super(t),this.name=e,this._attrs=function(t){t=qo(t);for(const[e,n]of t)null===n?t.delete(e):"string"!=typeof n&&t.set(e,String(n));return t}(n),this._children=[],o&&this._insertChild(0,o),this._classes=new Set,this._attrs.has("class")){const t=this._attrs.get("class");Ii(this._classes,t),this._attrs.delete("class")}this._styles=new Di(this.document.stylesProcessor),this._attrs.has("style")&&(this._styles.setTo(this._attrs.get("style")),this._attrs.delete("style")),this._customProperties=new Map,this._isAllowedInsideAttributeElement=!1,this._unsafeAttributesToRender=[]}get childCount(){return this._children.length}get isEmpty(){return 0===this._children.length}get isAllowedInsideAttributeElement(){return this._isAllowedInsideAttributeElement}is(t,e=null){return e?e===this.name&&("element"===t||"view:element"===t):"element"===t||"view:element"===t||"node"===t||"view:node"===t}getChild(t){return this._children[t]}getChildIndex(t){return this._children.indexOf(t)}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(t){if("class"==t)return this._classes.size>0?[...this._classes].join(" "):void 0;if("style"==t){const t=this._styles.toString();return""==t?void 0:t}return this._attrs.get(t)}hasAttribute(t){return"class"==t?this._classes.size>0:"style"==t?!this._styles.isEmpty:this._attrs.has(t)}isSimilar(t){if(!(t instanceof Pi))return!1;if(this===t)return!0;if(this.name!=t.name)return!1;if(this.isAllowedInsideAttributeElement!=t.isAllowedInsideAttributeElement)return!1;if(this._attrs.size!==t._attrs.size||this._classes.size!==t._classes.size||this._styles.size!==t._styles.size)return!1;for(const[e,n]of this._attrs)if(!t._attrs.has(e)||t._attrs.get(e)!==n)return!1;for(const e of this._classes)if(!t._classes.has(e))return!1;for(const e of this._styles.getStyleNames())if(!t._styles.has(e)||t._styles.getAsString(e)!==this._styles.getAsString(e))return!1;return!0}hasClass(...t){for(const e of t)if(!this._classes.has(e))return!1;return!0}getClassNames(){return this._classes.keys()}getStyle(t){return this._styles.getAsString(t)}getNormalizedStyle(t){return this._styles.getNormalized(t)}getStyleNames(t=!1){return this._styles.getStyleNames(t)}hasStyle(...t){for(const e of t)if(!this._styles.has(e))return!1;return!0}findAncestor(...t){const e=new Wo(...t);let n=this.parent;for(;n;){if(e.match(n))return n;n=n.parent}return null}getCustomProperty(t){return this._customProperties.get(t)}*getCustomProperties(){yield*this._customProperties.entries()}getIdentity(){const t=Array.from(this._classes).sort().join(","),e=this._styles.toString(),n=Array.from(this._attrs).map((t=>`${t[0]}="${t[1]}"`)).sort().join(" ");return this.name+(""==t?"":` class="${t}"`)+(e?` style="${e}"`:"")+(""==n?"":` ${n}`)}shouldRenderUnsafeAttribute(t){return this._unsafeAttributesToRender.includes(t)}_clone(t=!1){const e=[];if(t)for(const n of this.getChildren())e.push(n._clone(t));const n=new this.constructor(this.document,this.name,this._attrs,e);return n._classes=new Set(this._classes),n._styles.set(this._styles.getNormalized()),n._customProperties=new Map(this._customProperties),n.getFillerOffset=this.getFillerOffset,n._isAllowedInsideAttributeElement=this.isAllowedInsideAttributeElement,n}_appendChild(t){return this._insertChild(this.childCount,t)}_insertChild(t,e){this._fireChange("children",this);let n=0;const o=function(t,e){if("string"==typeof e)return[new Lo(t,e)];Do(e)||(e=[e]);return Array.from(e).map((e=>"string"==typeof e?new Lo(t,e):e instanceof Ho?new Lo(t,e.data):e))}(this.document,e);for(const e of o)null!==e.parent&&e._remove(),e.parent=this,e.document=this.document,this._children.splice(t,0,e),t++,n++;return n}_removeChildren(t,e=1){this._fireChange("children",this);for(let n=t;n0&&(this._classes.clear(),!0):"style"==t?!this._styles.isEmpty&&(this._styles.clear(),!0):this._attrs.delete(t)}_addClass(t){this._fireChange("attributes",this);for(const e of To(t))this._classes.add(e)}_removeClass(t){this._fireChange("attributes",this);for(const e of To(t))this._classes.delete(e)}_setStyle(t,e){this._fireChange("attributes",this),this._styles.set(t,e)}_removeStyle(t){this._fireChange("attributes",this);for(const e of To(t))this._styles.remove(e)}_setCustomProperty(t,e){this._customProperties.set(t,e)}_removeCustomProperty(t){return this._customProperties.delete(t)}}function Ii(t,e){const n=e.split(/\s+/);t.clear(),n.forEach((e=>t.add(e)))}class Ri extends Pi{constructor(t,e,n,o){super(t,e,n,o),this.getFillerOffset=zi}is(t,e=null){return e?e===this.name&&("containerElement"===t||"view:containerElement"===t||"element"===t||"view:element"===t):"containerElement"===t||"view:containerElement"===t||"element"===t||"view:element"===t||"node"===t||"view:node"===t}}function zi(){const t=[...this.getChildren()],e=t[this.childCount-1];if(e&&e.is("element","br"))return this.childCount;for(const e of t)if(!e.is("uiElement"))return null;return this.childCount}class Fi extends Ri{constructor(t,e,n,o){super(t,e,n,o),this.set("isReadOnly",!1),this.set("isFocused",!1),this.bind("isReadOnly").to(t),this.bind("isFocused").to(t,"isFocused",(e=>e&&t.selection.editableElement==this)),this.listenTo(t.selection,"change",(()=>{this.isFocused=t.isFocused&&t.selection.editableElement==this}))}is(t,e=null){return e?e===this.name&&("editableElement"===t||"view:editableElement"===t||"containerElement"===t||"view:containerElement"===t||"element"===t||"view:element"===t):"editableElement"===t||"view:editableElement"===t||"containerElement"===t||"view:containerElement"===t||"element"===t||"view:element"===t||"node"===t||"view:node"===t}destroy(){this.stopListening()}}he(Fi,se);const Ni=Symbol("rootName");class Oi extends Fi{constructor(t,e){super(t,e),this.rootName="main"}is(t,e=null){return e?e===this.name&&("rootElement"===t||"view:rootElement"===t||"editableElement"===t||"view:editableElement"===t||"containerElement"===t||"view:containerElement"===t||"element"===t||"view:element"===t):"rootElement"===t||"view:rootElement"===t||"editableElement"===t||"view:editableElement"===t||"containerElement"===t||"view:containerElement"===t||"element"===t||"view:element"===t||"node"===t||"view:node"===t}get rootName(){return this.getCustomProperty(Ni)}set rootName(t){this._setCustomProperty(Ni,t)}set _name(t){this.name=t}}class Mi{constructor(t={}){if(!t.boundaries&&!t.startPosition)throw new s("view-tree-walker-no-start-position",null);if(t.direction&&"forward"!=t.direction&&"backward"!=t.direction)throw new s("view-tree-walker-unknown-direction",t.startPosition,{direction:t.direction});this.boundaries=t.boundaries||null,t.startPosition?this.position=Vi._createAt(t.startPosition):this.position=Vi._createAt(t.boundaries["backward"==t.direction?"end":"start"]),this.direction=t.direction||"forward",this.singleCharacters=!!t.singleCharacters,this.shallow=!!t.shallow,this.ignoreElementEnd=!!t.ignoreElementEnd,this._boundaryStartParent=this.boundaries?this.boundaries.start.parent:null,this._boundaryEndParent=this.boundaries?this.boundaries.end.parent:null}[Symbol.iterator](){return this}skip(t){let e,n,o;do{o=this.position,({done:e,value:n}=this.next())}while(!e&&t(n));e||(this.position=o)}next(){return"forward"==this.direction?this._next():this._previous()}_next(){let t=this.position.clone();const e=this.position,n=t.parent;if(null===n.parent&&t.offset===n.childCount)return{done:!0};if(n===this._boundaryEndParent&&t.offset==this.boundaries.end.offset)return{done:!0};let o;if(n instanceof Lo){if(t.isAtEnd)return this.position=Vi._createAfter(n),this._next();o=n.data[t.offset]}else o=n.getChild(t.offset);if(o instanceof Pi)return this.shallow?t.offset++:t=new Vi(o,0),this.position=t,this._formatReturnValue("elementStart",o,e,t,1);if(o instanceof Lo){if(this.singleCharacters)return t=new Vi(o,0),this.position=t,this._next();{let n,i=o.data.length;return o==this._boundaryEndParent?(i=this.boundaries.end.offset,n=new Ho(o,0,i),t=Vi._createAfter(n)):(n=new Ho(o,0,o.data.length),t.offset++),this.position=t,this._formatReturnValue("text",n,e,t,i)}}if("string"==typeof o){let o;if(this.singleCharacters)o=1;else{o=(n===this._boundaryEndParent?this.boundaries.end.offset:n.data.length)-t.offset}const i=new Ho(n,t.offset,o);return t.offset+=o,this.position=t,this._formatReturnValue("text",i,e,t,o)}return t=Vi._createAfter(n),this.position=t,this.ignoreElementEnd?this._next():this._formatReturnValue("elementEnd",n,e,t)}_previous(){let t=this.position.clone();const e=this.position,n=t.parent;if(null===n.parent&&0===t.offset)return{done:!0};if(n==this._boundaryStartParent&&t.offset==this.boundaries.start.offset)return{done:!0};let o;if(n instanceof Lo){if(t.isAtStart)return this.position=Vi._createBefore(n),this._previous();o=n.data[t.offset-1]}else o=n.getChild(t.offset-1);if(o instanceof Pi)return this.shallow?(t.offset--,this.position=t,this._formatReturnValue("elementStart",o,e,t,1)):(t=new Vi(o,o.childCount),this.position=t,this.ignoreElementEnd?this._previous():this._formatReturnValue("elementEnd",o,e,t));if(o instanceof Lo){if(this.singleCharacters)return t=new Vi(o,o.data.length),this.position=t,this._previous();{let n,i=o.data.length;if(o==this._boundaryStartParent){const e=this.boundaries.start.offset;n=new Ho(o,e,o.data.length-e),i=n.data.length,t=Vi._createBefore(n)}else n=new Ho(o,0,o.data.length),t.offset--;return this.position=t,this._formatReturnValue("text",n,e,t,i)}}if("string"==typeof o){let o;if(this.singleCharacters)o=1;else{const e=n===this._boundaryStartParent?this.boundaries.start.offset:0;o=t.offset-e}t.offset-=o;const i=new Ho(n,t.offset,o);return this.position=t,this._formatReturnValue("text",i,e,t,o)}return t=Vi._createBefore(n),this.position=t,this._formatReturnValue("elementStart",n,e,t,1)}_formatReturnValue(t,e,n,o,i){return e instanceof Ho&&(e.offsetInText+e.data.length==e.textNode.data.length&&("forward"!=this.direction||this.boundaries&&this.boundaries.end.isEqual(this.position)?n=Vi._createAfter(e.textNode):(o=Vi._createAfter(e.textNode),this.position=o)),0===e.offsetInText&&("backward"!=this.direction||this.boundaries&&this.boundaries.start.isEqual(this.position)?n=Vi._createBefore(e.textNode):(o=Vi._createBefore(e.textNode),this.position=o))),{done:!1,value:{type:t,item:e,previousPosition:n,nextPosition:o,length:i}}}}class Vi{constructor(t,e){this.parent=t,this.offset=e}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 t=this.parent.is("$text")?this.parent.data.length:this.parent.childCount;return this.offset===t}get root(){return this.parent.root}get editableElement(){let t=this.parent;for(;!(t instanceof Fi);){if(!t.parent)return null;t=t.parent}return t}getShiftedBy(t){const e=Vi._createAt(this),n=e.offset+t;return e.offset=n<0?0:n,e}getLastMatchingPosition(t,e={}){e.startPosition=this;const n=new Mi(e);return n.skip(t),n.position}getAncestors(){return this.parent.is("documentFragment")?[this.parent]:this.parent.getAncestors({includeSelf:!0})}getCommonAncestor(t){const e=this.getAncestors(),n=t.getAncestors();let o=0;for(;e[o]==n[o]&&e[o];)o++;return 0===o?null:e[o-1]}is(t){return"position"===t||"view:position"===t}isEqual(t){return this.parent==t.parent&&this.offset==t.offset}isBefore(t){return"before"==this.compareWith(t)}isAfter(t){return"after"==this.compareWith(t)}compareWith(t){if(this.root!==t.root)return"different";if(this.isEqual(t))return"same";const e=this.parent.is("node")?this.parent.getPath():[],n=t.parent.is("node")?t.parent.getPath():[];e.push(this.offset),n.push(t.offset);const o=Oo(e,n);switch(o){case"prefix":return"before";case"extension":return"after";default:return e[o]0?new this(n,o):new this(o,n)}static _createIn(t){return this._createFromParentsAndOffsets(t,0,t,t.childCount)}static _createOn(t){const e=t.is("$textProxy")?t.offsetSize:1;return this._createFromPositionAndShift(Vi._createBefore(t),e)}}function Hi(t){return!(!t.item.is("attributeElement")&&!t.item.is("uiElement"))}function qi(t){let e=0;for(const n of t)e++;return e}class Wi{constructor(t=null,e,n){this._ranges=[],this._lastRangeBackward=!1,this._isFake=!1,this._fakeSelectionLabel="",this.setTo(t,e,n)}get isFake(){return this._isFake}get fakeSelectionLabel(){return this._fakeSelectionLabel}get anchor(){if(!this._ranges.length)return null;const t=this._ranges[this._ranges.length-1];return(this._lastRangeBackward?t.end:t.start).clone()}get focus(){if(!this._ranges.length)return null;const t=this._ranges[this._ranges.length-1];return(this._lastRangeBackward?t.start:t.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 t of this._ranges)yield t.clone()}getFirstRange(){let t=null;for(const e of this._ranges)t&&!e.start.isBefore(t.start)||(t=e);return t?t.clone():null}getLastRange(){let t=null;for(const e of this._ranges)t&&!e.end.isAfter(t.end)||(t=e);return t?t.clone():null}getFirstPosition(){const t=this.getFirstRange();return t?t.start.clone():null}getLastPosition(){const t=this.getLastRange();return t?t.end.clone():null}isEqual(t){if(this.isFake!=t.isFake)return!1;if(this.isFake&&this.fakeSelectionLabel!=t.fakeSelectionLabel)return!1;if(this.rangeCount!=t.rangeCount)return!1;if(0===this.rangeCount)return!0;if(!this.anchor.isEqual(t.anchor)||!this.focus.isEqual(t.focus))return!1;for(const e of this._ranges){let n=!1;for(const o of t._ranges)if(e.isEqual(o)){n=!0;break}if(!n)return!1}return!0}isSimilar(t){if(this.isBackward!=t.isBackward)return!1;const e=qi(this.getRanges());if(e!=qi(t.getRanges()))return!1;if(0==e)return!0;for(let e of this.getRanges()){e=e.getTrimmed();let n=!1;for(let o of t.getRanges())if(o=o.getTrimmed(),e.start.isEqual(o.start)&&e.end.isEqual(o.end)){n=!0;break}if(!n)return!1}return!0}getSelectedElement(){return 1!==this.rangeCount?null:this.getFirstRange().getContainedElement()}setTo(t,e,n){if(null===t)this._setRanges([]),this._setFakeOptions(e);else if(t instanceof Wi||t instanceof ji)this._setRanges(t.getRanges(),t.isBackward),this._setFakeOptions({fake:t.isFake,label:t.fakeSelectionLabel});else if(t instanceof Li)this._setRanges([t],e&&e.backward),this._setFakeOptions(e);else if(t instanceof Vi)this._setRanges([new Li(t)]),this._setFakeOptions(e);else if(t instanceof Vo){const o=!!n&&!!n.backward;let i;if(void 0===e)throw new s("view-selection-setto-required-second-parameter",this);i="in"==e?Li._createIn(t):"on"==e?Li._createOn(t):new Li(Vi._createAt(t,e)),this._setRanges([i],o),this._setFakeOptions(n)}else{if(!Do(t))throw new s("view-selection-setto-not-selectable",this);this._setRanges(t,e&&e.backward),this._setFakeOptions(e)}this.fire("change")}setFocus(t,e){if(null===this.anchor)throw new s("view-selection-setfocus-no-ranges",this);const n=Vi._createAt(t,e);if("same"==n.compareWith(this.focus))return;const o=this.anchor;this._ranges.pop(),"before"==n.compareWith(o)?this._addRange(new Li(n,o),!0):this._addRange(new Li(o,n)),this.fire("change")}is(t){return"selection"===t||"view:selection"===t}_setRanges(t,e=!1){t=Array.from(t),this._ranges=[];for(const e of t)this._addRange(e);this._lastRangeBackward=!!e}_setFakeOptions(t={}){this._isFake=!!t.fake,this._fakeSelectionLabel=t.fake&&t.label||""}_addRange(t,e=!1){if(!(t instanceof Li))throw new s("view-selection-add-range-not-range",this);this._pushRange(t),this._lastRangeBackward=!!e}_pushRange(t){for(const e of this._ranges)if(t.isIntersecting(e))throw new s("view-selection-range-intersects",this,{addedRange:t,intersectingRange:e});this._ranges.push(new Li(t.start,t.end))}}he(Wi,g);class ji{constructor(t=null,e,n){this._selection=new Wi,this._selection.delegate("change").to(this),this._selection.setTo(t,e,n)}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(t){return this._selection.isEqual(t)}isSimilar(t){return this._selection.isSimilar(t)}is(t){return"selection"===t||"documentSelection"==t||"view:selection"==t||"view:documentSelection"==t}_setTo(t,e,n){this._selection.setTo(t,e,n)}_setFocus(t,e){this._selection.setFocus(t,e)}}he(ji,g);class Ui extends e{constructor(t,e,n){super(t,e),this.startRange=n,this._eventPhase="none",this._currentTarget=null}get eventPhase(){return this._eventPhase}get currentTarget(){return this._currentTarget}}const $i=Symbol("bubbling contexts"),Gi={fire(t,...n){try{const o=t instanceof e?t:new e(this,t),i=Qi(this);if(!i.size)return;if(Zi(o,"capturing",this),Ji(i,"$capture",o,...n))return o.return;const r=o.startRange||this.selection.getFirstRange(),s=r?r.getContainedElement():null,a=!!s&&Boolean(Yi(i,s));let c=s||function(t){if(!t)return null;const e=t.start.parent,n=t.end.parent,o=e.getPath(),i=n.getPath();return o.length>i.length?e:n}(r);if(Zi(o,"atTarget",c),!a){if(Ji(i,"$text",o,...n))return o.return;Zi(o,"bubbling",c)}for(;c;){if(c.is("rootElement")){if(Ji(i,"$root",o,...n))return o.return}else if(c.is("element")&&Ji(i,c.name,o,...n))return o.return;if(Ji(i,c,o,...n))return o.return;c=c.parent,Zi(o,"bubbling",c)}return Zi(o,"bubbling",this),Ji(i,"$document",o,...n),o.return}catch(t){s.rethrowUnexpectedError(t,this)}},_addEventListener(t,e,n){const o=To(n.context||"$document"),i=Qi(this);for(const r of o){let o=i.get(r);o||(o=Object.create(g),i.set(r,o)),this.listenTo(o,t,e,n)}},_removeEventListener(t,e){const n=Qi(this);for(const o of n.values())this.stopListening(o,t,e)}},Ki=Gi;function Zi(t,e,n){t instanceof Ui&&(t._eventPhase=e,t._currentTarget=n)}function Ji(t,e,n,...o){const i="string"==typeof e?t.get(e):Yi(t,e);return!!i&&(i.fire(n,...o),n.stop.called)}function Yi(t,e){for(const[n,o]of t)if("function"==typeof n&&n(e))return o;return null}function Qi(t){return t[$i]||(t[$i]=new Map),t[$i]}class Xi{constructor(t){this.selection=new ji,this.roots=new So({idProperty:"rootName"}),this.stylesProcessor=t,this.set("isReadOnly",!1),this.set("isFocused",!1),this.set("isSelecting",!1),this.set("isComposing",!1),this._postFixers=new Set}getRoot(t="main"){return this.roots.get(t)}registerPostFixer(t){this._postFixers.add(t)}destroy(){this.roots.map((t=>t.destroy())),this.stopListening()}_callPostFixers(t){let e=!1;do{for(const n of this._postFixers)if(e=n(t),e)break}while(e)}}he(Xi,Ki),he(Xi,se);class tr extends Pi{constructor(t,e,n,o){super(t,e,n,o),this.getFillerOffset=er,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 s("attribute-element-get-elements-with-same-id-no-id",this);return new Set(this._clonesGroup)}is(t,e=null){return e?e===this.name&&("attributeElement"===t||"view:attributeElement"===t||"element"===t||"view:element"===t):"attributeElement"===t||"view:attributeElement"===t||"element"===t||"view:element"===t||"node"===t||"view:node"===t}isSimilar(t){return null!==this.id||null!==t.id?this.id===t.id:super.isSimilar(t)&&this.priority==t.priority}_clone(t){const e=super._clone(t);return e._priority=this._priority,e._id=this._id,e}}function er(){if(nr(this))return null;let t=this.parent;for(;t&&t.is("attributeElement");){if(nr(t)>1)return null;t=t.parent}return!t||nr(t)>1?null:this.childCount}function nr(t){return Array.from(t.getChildren()).filter((t=>!t.is("uiElement"))).length}tr.DEFAULT_PRIORITY=10;class or extends Pi{constructor(t,e,n,o){super(t,e,n,o),this._isAllowedInsideAttributeElement=!0,this.getFillerOffset=ir}is(t,e=null){return e?e===this.name&&("emptyElement"===t||"view:emptyElement"===t||"element"===t||"view:element"===t):"emptyElement"===t||"view:emptyElement"===t||"element"===t||"view:element"===t||"node"===t||"view:node"===t}_insertChild(t,e){if(e&&(e instanceof Vo||Array.from(e).length>0))throw new s("view-emptyelement-cannot-add",[this,e])}}function ir(){return null}const rr=navigator.userAgent.toLowerCase(),sr={isMac:cr(rr),isWindows:function(t){return t.indexOf("windows")>-1}(rr),isGecko:function(t){return!!t.match(/gecko\/\d+/)}(rr),isSafari:function(t){return t.indexOf(" applewebkit/")>-1&&-1===t.indexOf("chrome")}(rr),isiOS:function(t){return!!t.match(/iphone|ipad/i)||cr(t)&&navigator.maxTouchPoints>0}(rr),isAndroid:function(t){return t.indexOf("android")>-1}(rr),isBlink:function(t){return t.indexOf("chrome/")>-1&&t.indexOf("edge/")<0}(rr),features:{isRegExpUnicodePropertySupported:function(){let t=!1;try{t=0==="ć".search(new RegExp("[\\p{L}]","u"))}catch(t){}return t}()}},ar=sr;function cr(t){return t.indexOf("macintosh")>-1}const lr={ctrl:"⌃",cmd:"⌘",alt:"⌥",shift:"⇧"},dr={ctrl:"Ctrl+",alt:"Alt+",shift:"Shift+"},ur=function(){const t={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 e=65;e<=90;e++){const n=String.fromCharCode(e);t[n.toLowerCase()]=e}for(let e=48;e<=57;e++)t[e-48]=e;for(let e=112;e<=123;e++)t["f"+(e-111)]=e;for(const e of"`-=[];',./\\")t[e]=e.charCodeAt(0);return t}(),hr=Object.fromEntries(Object.entries(ur).map((([t,e])=>[e,t.charAt(0).toUpperCase()+t.slice(1)])));function pr(t){let e;if("string"==typeof t){if(e=ur[t.toLowerCase()],!e)throw new s("keyboard-unknown-key",null,{key:t})}else e=t.keyCode+(t.altKey?ur.alt:0)+(t.ctrlKey?ur.ctrl:0)+(t.shiftKey?ur.shift:0)+(t.metaKey?ur.cmd:0);return e}function mr(t){return"string"==typeof t&&(t=function(t){return t.split("+").map((t=>t.trim()))}(t)),t.map((t=>"string"==typeof t?function(t){if(t.endsWith("!"))return pr(t.slice(0,-1));const e=pr(t);return ar.isMac&&e==ur.ctrl?ur.cmd:e}(t):t)).reduce(((t,e)=>e+t),0)}function gr(t){let e=mr(t);return Object.entries(ar.isMac?lr:dr).reduce(((t,[n,o])=>(0!=(e&ur[n])&&(e&=~ur[n],t+=o),t)),"")+(e?hr[e]:"")}function fr(t,e){const n="ltr"===e;switch(t){case ur.arrowleft:return n?"left":"right";case ur.arrowright:return n?"right":"left";case ur.arrowup:return"up";case ur.arrowdown:return"down"}}class br extends Pi{constructor(t,e,n,o){super(t,e,n,o),this._isAllowedInsideAttributeElement=!0,this.getFillerOffset=wr}is(t,e=null){return e?e===this.name&&("uiElement"===t||"view:uiElement"===t||"element"===t||"view:element"===t):"uiElement"===t||"view:uiElement"===t||"element"===t||"view:element"===t||"node"===t||"view:node"===t}_insertChild(t,e){if(e&&(e instanceof Vo||Array.from(e).length>0))throw new s("view-uielement-cannot-add",this)}render(t){return this.toDomElement(t)}toDomElement(t){const e=t.createElement(this.name);for(const t of this.getAttributeKeys())e.setAttribute(t,this.getAttribute(t));return e}}function kr(t){t.document.on("arrowKey",((e,n)=>function(t,e,n){if(e.keyCode==ur.arrowright){const t=e.domTarget.ownerDocument.defaultView.getSelection(),o=1==t.rangeCount&&t.getRangeAt(0).collapsed;if(o||e.shiftKey){const e=t.focusNode,i=t.focusOffset,r=n.domPositionToView(e,i);if(null===r)return;let s=!1;const a=r.getLastMatchingPosition((t=>(t.item.is("uiElement")&&(s=!0),!(!t.item.is("uiElement")&&!t.item.is("attributeElement")))));if(s){const e=n.viewPositionToDom(a);o?t.collapse(e.parent,e.offset):t.extend(e.parent,e.offset)}}}}(0,n,t.domConverter)),{priority:"low"})}function wr(){return null}class _r extends Pi{constructor(t,e,n,o){super(t,e,n,o),this._isAllowedInsideAttributeElement=!0,this.getFillerOffset=Cr}is(t,e=null){return e?e===this.name&&("rawElement"===t||"view:rawElement"===t||"element"===t||"view:element"===t):"rawElement"===t||"view:rawElement"===t||t===this.name||t==="view:"+this.name||"element"===t||"view:element"===t||"node"===t||"view:node"===t}_insertChild(t,e){if(e&&(e instanceof Vo||Array.from(e).length>0))throw new s("view-rawelement-cannot-add",[this,e])}}function Cr(){return null}class Ar{constructor(t,e){this.document=t,this._children=[],e&&this._insertChild(0,e)}[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(t){return"documentFragment"===t||"view:documentFragment"===t}_appendChild(t){return this._insertChild(this.childCount,t)}getChild(t){return this._children[t]}getChildIndex(t){return this._children.indexOf(t)}getChildren(){return this._children[Symbol.iterator]()}_insertChild(t,e){this._fireChange("children",this);let n=0;const o=function(t,e){if("string"==typeof e)return[new Lo(t,e)];Do(e)||(e=[e]);return Array.from(e).map((e=>"string"==typeof e?new Lo(t,e):e instanceof Ho?new Lo(t,e.data):e))}(this.document,e);for(const e of o)null!==e.parent&&e._remove(),e.parent=this,this._children.splice(t,0,e),t++,n++;return n}_removeChildren(t,e=1){this._fireChange("children",this);for(let n=t;n{}),void 0!==o.isAllowedInsideAttributeElement&&(i._isAllowedInsideAttributeElement=o.isAllowedInsideAttributeElement),o.renderUnsafeAttributes&&i._unsafeAttributesToRender.push(...o.renderUnsafeAttributes),i}setAttribute(t,e,n){n._setAttribute(t,e)}removeAttribute(t,e){e._removeAttribute(t)}addClass(t,e){e._addClass(t)}removeClass(t,e){e._removeClass(t)}setStyle(t,e,n){ye(t)&&void 0===n&&(n=e),n._setStyle(t,e)}removeStyle(t,e){e._removeStyle(t)}setCustomProperty(t,e,n){n._setCustomProperty(t,e)}removeCustomProperty(t,e){return e._removeCustomProperty(t)}breakAttributes(t){return t instanceof Vi?this._breakAttributes(t):this._breakAttributesRange(t)}breakContainer(t){const e=t.parent;if(!e.is("containerElement"))throw new s("view-writer-break-non-container-element",this.document);if(!e.parent)throw new s("view-writer-break-root",this.document);if(t.isAtStart)return Vi._createBefore(e);if(!t.isAtEnd){const n=e._clone(!1);this.insert(Vi._createAfter(e),n);const o=new Li(t,Vi._createAt(e,"end")),i=new Vi(n,0);this.move(o,i)}return Vi._createAfter(e)}mergeAttributes(t){const e=t.offset,n=t.parent;if(n.is("$text"))return t;if(n.is("attributeElement")&&0===n.childCount){const t=n.parent,e=n.index;return n._remove(),this._removeFromClonedElementsGroup(n),this.mergeAttributes(new Vi(t,e))}const o=n.getChild(e-1),i=n.getChild(e);if(!o||!i)return t;if(o.is("$text")&&i.is("$text"))return Sr(o,i);if(o.is("attributeElement")&&i.is("attributeElement")&&o.isSimilar(i)){const t=o.childCount;return o._appendChild(i.getChildren()),i._remove(),this._removeFromClonedElementsGroup(i),this.mergeAttributes(new Vi(o,t))}return t}mergeContainers(t){const e=t.nodeBefore,n=t.nodeAfter;if(!(e&&n&&e.is("containerElement")&&n.is("containerElement")))throw new s("view-writer-merge-containers-invalid-position",this.document);const o=e.getChild(e.childCount-1),i=o instanceof Lo?Vi._createAt(o,"end"):Vi._createAt(e,"end");return this.move(Li._createIn(n),Vi._createAt(e,"end")),this.remove(Li._createOn(n)),i}insert(t,e){Br(e=Do(e)?[...e]:[e],this.document);const n=e.reduce(((t,e)=>{const n=t[t.length-1],o=!(e.is("uiElement")&&e.isAllowedInsideAttributeElement);return n&&n.breakAttributes==o?n.nodes.push(e):t.push({breakAttributes:o,nodes:[e]}),t}),[]);let o=null,i=t;for(const{nodes:t,breakAttributes:e}of n){const n=this._insertNodes(i,t,e);o||(o=n.start),i=n.end}return o?new Li(o,i):new Li(t)}remove(t){const e=t instanceof Li?t:Li._createOn(t);if(Ir(e,this.document),e.isCollapsed)return new Ar(this.document);const{start:n,end:o}=this._breakAttributesRange(e,!0),i=n.parent,r=o.offset-n.offset,s=i._removeChildren(n.offset,r);for(const t of s)this._removeFromClonedElementsGroup(t);const a=this.mergeAttributes(n);return e.start=a,e.end=a.clone(),new Ar(this.document,s)}clear(t,e){Ir(t,this.document);const n=t.getWalker({direction:"backward",ignoreElementEnd:!0});for(const o of n){const n=o.item;let i;if(n.is("element")&&e.isSimilar(n))i=Li._createOn(n);else if(!o.nextPosition.isAfter(t.start)&&n.is("$textProxy")){const t=n.getAncestors().find((t=>t.is("element")&&e.isSimilar(t)));t&&(i=Li._createIn(t))}i&&(i.end.isAfter(t.end)&&(i.end=t.end),i.start.isBefore(t.start)&&(i.start=t.start),this.remove(i))}}move(t,e){let n;if(e.isAfter(t.end)){const o=(e=this._breakAttributes(e,!0)).parent,i=o.childCount;t=this._breakAttributesRange(t,!0),n=this.remove(t),e.offset+=o.childCount-i}else n=this.remove(t);return this.insert(e,n)}wrap(t,e){if(!(e instanceof tr))throw new s("view-writer-wrap-invalid-attribute",this.document);if(Ir(t,this.document),t.isCollapsed){let o=t.start;o.parent.is("element")&&(n=o.parent,!Array.from(n.getChildren()).some((t=>!t.is("uiElement"))))&&(o=o.getLastMatchingPosition((t=>t.item.is("uiElement")))),o=this._wrapPosition(o,e);const i=this.document.selection;return i.isCollapsed&&i.getFirstPosition().isEqual(t.start)&&this.setSelection(o),new Li(o)}return this._wrapRange(t,e);var n}unwrap(t,e){if(!(e instanceof tr))throw new s("view-writer-unwrap-invalid-attribute",this.document);if(Ir(t,this.document),t.isCollapsed)return t;const{start:n,end:o}=this._breakAttributesRange(t,!0),i=n.parent,r=this._unwrapChildren(i,n.offset,o.offset,e),a=this.mergeAttributes(r.start);a.isEqual(r.start)||r.end.offset--;const c=this.mergeAttributes(r.end);return new Li(a,c)}rename(t,e){const n=new Ri(this.document,t,e.getAttributes());return this.insert(Vi._createAfter(e),n),this.move(Li._createIn(e),Vi._createAt(n,0)),this.remove(Li._createOn(e)),n}clearClonedElementsGroup(t){this._cloneGroups.delete(t)}createPositionAt(t,e){return Vi._createAt(t,e)}createPositionAfter(t){return Vi._createAfter(t)}createPositionBefore(t){return Vi._createBefore(t)}createRange(t,e){return new Li(t,e)}createRangeOn(t){return Li._createOn(t)}createRangeIn(t){return Li._createIn(t)}createSelection(t,e,n){return new Wi(t,e,n)}_insertNodes(t,e,n){let o,i;if(o=n?yr(t):t.parent.is("$text")?t.parent.parent:t.parent,!o)throw new s("view-writer-invalid-position-container",this.document);i=n?this._breakAttributes(t,!0):t.parent.is("$text")?Dr(t):t;const r=o._insertChild(i.offset,e);for(const t of e)this._addToClonedElementsGroup(t);const a=i.getShiftedBy(r),c=this.mergeAttributes(i);c.isEqual(i)||a.offset--;const l=this.mergeAttributes(a);return new Li(c,l)}_wrapChildren(t,e,n,o){let i=e;const r=[];for(;i!1,t.parent._insertChild(t.offset,n);const o=new Li(t,t.getShiftedBy(1));this.wrap(o,e);const i=new Vi(n.parent,n.index);n._remove();const r=i.nodeBefore,s=i.nodeAfter;return r instanceof Lo&&s instanceof Lo?Sr(r,s):Er(i)}_wrapAttributeElement(t,e){if(!Rr(t,e))return!1;if(t.name!==e.name||t.priority!==e.priority)return!1;for(const n of t.getAttributeKeys())if("class"!==n&&"style"!==n&&e.hasAttribute(n)&&e.getAttribute(n)!==t.getAttribute(n))return!1;for(const n of t.getStyleNames())if(e.hasStyle(n)&&e.getStyle(n)!==t.getStyle(n))return!1;for(const n of t.getAttributeKeys())"class"!==n&&"style"!==n&&(e.hasAttribute(n)||this.setAttribute(n,t.getAttribute(n),e));for(const n of t.getStyleNames())e.hasStyle(n)||this.setStyle(n,t.getStyle(n),e);for(const n of t.getClassNames())e.hasClass(n)||this.addClass(n,e);return!0}_unwrapAttributeElement(t,e){if(!Rr(t,e))return!1;if(t.name!==e.name||t.priority!==e.priority)return!1;for(const n of t.getAttributeKeys())if("class"!==n&&"style"!==n&&(!e.hasAttribute(n)||e.getAttribute(n)!==t.getAttribute(n)))return!1;if(!e.hasClass(...t.getClassNames()))return!1;for(const n of t.getStyleNames())if(!e.hasStyle(n)||e.getStyle(n)!==t.getStyle(n))return!1;for(const n of t.getAttributeKeys())"class"!==n&&"style"!==n&&this.removeAttribute(n,e);return this.removeClass(Array.from(t.getClassNames()),e),this.removeStyle(Array.from(t.getStyleNames()),e),!0}_breakAttributesRange(t,e=!1){const n=t.start,o=t.end;if(Ir(t,this.document),t.isCollapsed){const n=this._breakAttributes(t.start,e);return new Li(n,n)}const i=this._breakAttributes(o,e),r=i.parent.childCount,s=this._breakAttributes(n,e);return i.offset+=i.parent.childCount-r,new Li(s,i)}_breakAttributes(t,e=!1){const n=t.offset,o=t.parent;if(t.parent.is("emptyElement"))throw new s("view-writer-cannot-break-empty-element",this.document);if(t.parent.is("uiElement"))throw new s("view-writer-cannot-break-ui-element",this.document);if(t.parent.is("rawElement"))throw new s("view-writer-cannot-break-raw-element",this.document);if(!e&&o.is("$text")&&Pr(o.parent))return t.clone();if(Pr(o))return t.clone();if(o.is("$text"))return this._breakAttributes(Dr(t),e);if(n==o.childCount){const t=new Vi(o.parent,o.index+1);return this._breakAttributes(t,e)}if(0===n){const t=new Vi(o.parent,o.index);return this._breakAttributes(t,e)}{const t=o.index+1,i=o._clone();o.parent._insertChild(t,i),this._addToClonedElementsGroup(i);const r=o.childCount-n,s=o._removeChildren(n,r);i._appendChild(s);const a=new Vi(o.parent,t);return this._breakAttributes(a,e)}}_addToClonedElementsGroup(t){if(!t.root.is("rootElement"))return;if(t.is("element"))for(const e of t.getChildren())this._addToClonedElementsGroup(e);const e=t.id;if(!e)return;let n=this._cloneGroups.get(e);n||(n=new Set,this._cloneGroups.set(e,n)),n.add(t),t._clonesGroup=n}_removeFromClonedElementsGroup(t){if(t.is("element"))for(const e of t.getChildren())this._removeFromClonedElementsGroup(e);const e=t.id;if(!e)return;const n=this._cloneGroups.get(e);n&&n.delete(t)}}function yr(t){let e=t.parent;for(;!Pr(e);){if(!e)return;e=e.parent}return e}function xr(t,e){return t.prioritye.priority)&&t.getIdentity()n instanceof t)))throw new s("view-writer-insert-invalid-node-type",e);n.is("$text")||Br(n.getChildren(),e)}}const Tr=[Lo,tr,Ri,or,_r,br];function Pr(t){return t&&(t.is("containerElement")||t.is("documentFragment"))}function Ir(t,e){const n=yr(t.start),o=yr(t.end);if(!n||!o||n!==o)throw new s("view-writer-invalid-range-container",e)}function Rr(t,e){return null===t.id&&null===e.id}function zr(t){return"[object Text]"==Object.prototype.toString.call(t)}const Fr=t=>t.createTextNode(" "),Nr=t=>{const e=t.createElement("span");return e.dataset.ckeFiller=!0,e.innerHTML=" ",e},Or=t=>{const e=t.createElement("br");return e.dataset.ckeFiller=!0,e},Mr="⁠".repeat(7);function Vr(t){return zr(t)&&t.data.substr(0,7)===Mr}function Lr(t){return 7==t.data.length&&Vr(t)}function Hr(t){return Vr(t)?t.data.slice(7):t.data}function qr(t,e){if(e.keyCode==ur.arrowleft){const t=e.domTarget.ownerDocument.defaultView.getSelection();if(1==t.rangeCount&&t.getRangeAt(0).collapsed){const e=t.getRangeAt(0).startContainer,n=t.getRangeAt(0).startOffset;Vr(e)&&n<=7&&t.collapse(e,0)}}}function Wr(t,e,n,o=!1){n=n||function(t,e){return t===e},Array.isArray(t)||(t=Array.prototype.slice.call(t)),Array.isArray(e)||(e=Array.prototype.slice.call(e));const i=function(t,e,n){const o=jr(t,e,n);if(-1===o)return{firstIndex:-1,lastIndexOld:-1,lastIndexNew:-1};const i=Ur(t,o),r=Ur(e,o),s=jr(i,r,n),a=t.length-s,c=e.length-s;return{firstIndex:o,lastIndexOld:a,lastIndexNew:c}}(t,e,n);return o?function(t,e){const{firstIndex:n,lastIndexOld:o,lastIndexNew:i}=t;if(-1===n)return Array(e).fill("equal");let r=[];n>0&&(r=r.concat(Array(n).fill("equal")));i-n>0&&(r=r.concat(Array(i-n).fill("insert")));o-n>0&&(r=r.concat(Array(o-n).fill("delete")));i0&&n.push({index:o,type:"insert",values:t.slice(o,r)});i-o>0&&n.push({index:o+(r-o),type:"delete",howMany:i-o});return n}(e,i)}function jr(t,e,n){for(let o=0;o200||i>200||o+i>300)return $r.fastDiff(t,e,n,!0);let r,s;if(il?-1:1;d[o+h]&&(d[o]=d[o+h].slice(0)),d[o]||(d[o]=[]),d[o].push(i>l?r:s);let p=Math.max(i,l),m=p-o;for(;ml;p--)u[p]=h(p);u[l]=h(l),m++}while(u[l]!==c);return d[l].slice(1)}function Gr(t,e,n){t.insertBefore(n,t.childNodes[e]||null)}function Kr(t){const e=t.parentNode;e&&e.removeChild(t)}function Zr(t){return t&&t.nodeType===Node.COMMENT_NODE}function Jr(t){if(t){if(t.defaultView)return t instanceof t.defaultView.Document;if(t.ownerDocument&&t.ownerDocument.defaultView)return t instanceof t.ownerDocument.defaultView.Node}return!1}$r.fastDiff=Wr;var Yr=n(3379),Qr=n.n(Yr),Xr=n(9037),ts=n.n(Xr),es=n(569),ns=n.n(es),os=n(8575),is=n.n(os),rs=n(9216),ss=n.n(rs),as=n(4401),cs={attributes:{"data-cke":!0}};cs.setAttributes=is(),cs.insert=ns().bind(null,"head"),cs.domAPI=ts(),cs.insertStyleElement=ss();Qr()(as.Z,cs);as.Z&&as.Z.locals&&as.Z.locals;class ls{constructor(t,e){this.domDocuments=new Set,this.domConverter=t,this.markedAttributes=new Set,this.markedChildren=new Set,this.markedTexts=new Set,this.selection=e,this.set("isFocused",!1),this.set("isSelecting",!1),ar.isBlink&&!ar.isAndroid&&this.on("change:isSelecting",(()=>{this.isSelecting||this.render()})),this._inlineFiller=null,this._fakeSelectionContainer=null}markToSync(t,e){if("text"===t)this.domConverter.mapViewToDom(e.parent)&&this.markedTexts.add(e);else{if(!this.domConverter.mapViewToDom(e))return;if("attributes"===t)this.markedAttributes.add(e);else{if("children"!==t)throw new s("view-renderer-unknown-type",this);this.markedChildren.add(e)}}}render(){let t;const e=!(ar.isBlink&&!ar.isAndroid)||!this.isSelecting;for(const t of this.markedChildren)this._updateChildrenMappings(t);e?(this._inlineFiller&&!this._isSelectionInInlineFiller()&&this._removeInlineFiller(),this._inlineFiller?t=this._getInlineFillerPosition():this._needsInlineFillerAtSelection()&&(t=this.selection.getFirstPosition(),this.markedChildren.add(t.parent))):this._inlineFiller&&this._inlineFiller.parentNode&&(t=this.domConverter.domPositionToView(this._inlineFiller));for(const t of this.markedAttributes)this._updateAttrs(t);for(const e of this.markedChildren)this._updateChildren(e,{inlineFillerPosition:t});for(const e of this.markedTexts)!this.markedChildren.has(e.parent)&&this.domConverter.mapViewToDom(e.parent)&&this._updateText(e,{inlineFillerPosition:t});if(e)if(t){const e=this.domConverter.viewPositionToDom(t),n=e.parent.ownerDocument;Vr(e.parent)?this._inlineFiller=e.parent:this._inlineFiller=ds(n,e.parent,e.offset)}else this._inlineFiller=null;this._updateFocus(),this._updateSelection(),this.markedTexts.clear(),this.markedAttributes.clear(),this.markedChildren.clear()}_updateChildrenMappings(t){const e=this.domConverter.mapViewToDom(t);if(!e)return;const n=Array.from(this.domConverter.mapViewToDom(t).childNodes),o=Array.from(this.domConverter.viewChildrenToDom(t,e.ownerDocument,{withChildren:!1})),i=this._diffNodeLists(n,o),r=this._findReplaceActions(i,n,o);if(-1!==r.indexOf("replace")){const e={equal:0,insert:0,delete:0};for(const i of r)if("replace"===i){const i=e.equal+e.insert,r=e.equal+e.delete,s=t.getChild(i);!s||s.is("uiElement")||s.is("rawElement")||this._updateElementMappings(s,n[r]),Kr(o[i]),e.equal++}else e[i]++}}_updateElementMappings(t,e){this.domConverter.unbindDomElement(e),this.domConverter.bindElements(e,t),this.markedChildren.add(t),this.markedAttributes.add(t)}_getInlineFillerPosition(){const t=this.selection.getFirstPosition();return t.parent.is("$text")?Vi._createBefore(this.selection.getFirstPosition().parent):t}_isSelectionInInlineFiller(){if(1!=this.selection.rangeCount||!this.selection.isCollapsed)return!1;const t=this.selection.getFirstPosition(),e=this.domConverter.viewPositionToDom(t);return!!(e&&zr(e.parent)&&Vr(e.parent))}_removeInlineFiller(){const t=this._inlineFiller;if(!Vr(t))throw new s("view-renderer-filler-was-lost",this);Lr(t)?t.remove():t.data=t.data.substr(7),this._inlineFiller=null}_needsInlineFillerAtSelection(){if(1!=this.selection.rangeCount||!this.selection.isCollapsed)return!1;const t=this.selection.getFirstPosition(),e=t.parent,n=t.offset;if(!this.domConverter.mapViewToDom(e.root))return!1;if(!e.is("element"))return!1;if(!function(t){if("false"==t.getAttribute("contenteditable"))return!1;const e=t.findAncestor((t=>t.hasAttribute("contenteditable")));return!e||"true"==e.getAttribute("contenteditable")}(e))return!1;if(n===e.getFillerOffset())return!1;const o=t.nodeBefore,i=t.nodeAfter;return!(o instanceof Lo||i instanceof Lo)}_updateText(t,e){const n=this.domConverter.findCorrespondingDomText(t),o=this.domConverter.viewToDom(t,n.ownerDocument),i=n.data;let r=o.data;const s=e.inlineFillerPosition;if(s&&s.parent==t.parent&&s.offset==t.index&&(r=Mr+r),i!=r){const t=Wr(i,r);for(const e of t)"insert"===e.type?n.insertData(e.index,e.values.join("")):n.deleteData(e.index,e.howMany)}}_updateAttrs(t){const e=this.domConverter.mapViewToDom(t);if(!e)return;const n=Array.from(e.attributes).map((t=>t.name)),o=t.getAttributeKeys();for(const n of o)this.domConverter.setDomElementAttribute(e,n,t.getAttribute(n),t);for(const o of n)t.hasAttribute(o)||this.domConverter.removeDomElementAttribute(e,o)}_updateChildren(t,e){const n=this.domConverter.mapViewToDom(t);if(!n)return;const o=e.inlineFillerPosition,i=this.domConverter.mapViewToDom(t).childNodes,r=Array.from(this.domConverter.viewChildrenToDom(t,n.ownerDocument,{bind:!0}));o&&o.parent===t&&ds(n.ownerDocument,r,o.offset);const s=this._diffNodeLists(i,r);let a=0;const c=new Set;for(const t of s)"delete"===t?(c.add(i[a]),Kr(i[a])):"equal"===t&&a++;a=0;for(const t of s)"insert"===t?(Gr(n,a,r[a]),a++):"equal"===t&&(this._markDescendantTextToSync(this.domConverter.domToView(r[a])),a++);for(const t of c)t.parentNode||this.domConverter.unbindDomElement(t)}_diffNodeLists(t,e){return $r(t=function(t,e){const n=Array.from(t);if(0==n.length||!e)return n;n[n.length-1]==e&&n.pop();return n}(t,this._fakeSelectionContainer),e,hs.bind(null,this.domConverter))}_findReplaceActions(t,e,n){if(-1===t.indexOf("insert")||-1===t.indexOf("delete"))return t;let o=[],i=[],r=[];const s={equal:0,insert:0,delete:0};for(const a of t)"insert"===a?r.push(n[s.equal+s.insert]):"delete"===a?i.push(e[s.equal+s.delete]):(o=o.concat($r(i,r,us).map((t=>"equal"===t?"replace":t))),o.push("equal"),i=[],r=[]),s[a]++;return o.concat($r(i,r,us).map((t=>"equal"===t?"replace":t)))}_markDescendantTextToSync(t){if(t)if(t.is("$text"))this.markedTexts.add(t);else if(t.is("element"))for(const e of t.getChildren())this._markDescendantTextToSync(e)}_updateSelection(){if(ar.isBlink&&!ar.isAndroid&&this.isSelecting&&!this.markedChildren.size)return;if(0===this.selection.rangeCount)return this._removeDomSelection(),void this._removeFakeSelection();const t=this.domConverter.mapViewToDom(this.selection.editableElement);this.isFocused&&t&&(this.selection.isFake?this._updateFakeSelection(t):(this._removeFakeSelection(),this._updateDomSelection(t)))}_updateFakeSelection(t){const e=t.ownerDocument;this._fakeSelectionContainer||(this._fakeSelectionContainer=function(t){const e=t.createElement("div");return e.className="ck-fake-selection-container",Object.assign(e.style,{position:"fixed",top:0,left:"-9999px",width:"42px"}),e.textContent=" ",e}(e));const n=this._fakeSelectionContainer;if(this.domConverter.bindFakeSelection(n,this.selection),!this._fakeSelectionNeedsUpdate(t))return;n.parentElement&&n.parentElement==t||t.appendChild(n),n.textContent=this.selection.fakeSelectionLabel||" ";const o=e.getSelection(),i=e.createRange();o.removeAllRanges(),i.selectNodeContents(n),o.addRange(i)}_updateDomSelection(t){const e=t.ownerDocument.defaultView.getSelection();if(!this._domSelectionNeedsUpdate(e))return;const n=this.domConverter.viewPositionToDom(this.selection.anchor),o=this.domConverter.viewPositionToDom(this.selection.focus);e.collapse(n.parent,n.offset),e.extend(o.parent,o.offset),ar.isGecko&&function(t,e){const n=t.parent;if(n.nodeType!=Node.ELEMENT_NODE||t.offset!=n.childNodes.length-1)return;const o=n.childNodes[t.offset];o&&"BR"==o.tagName&&e.addRange(e.getRangeAt(0))}(o,e)}_domSelectionNeedsUpdate(t){if(!this.domConverter.isDomSelectionCorrect(t))return!0;const e=t&&this.domConverter.domSelectionToView(t);return(!e||!this.selection.isEqual(e))&&!(!this.selection.isCollapsed&&this.selection.isSimilar(e))}_fakeSelectionNeedsUpdate(t){const e=this._fakeSelectionContainer,n=t.ownerDocument.getSelection();return!e||e.parentElement!==t||(n.anchorNode!==e&&!e.contains(n.anchorNode)||e.textContent!==this.selection.fakeSelectionLabel)}_removeDomSelection(){for(const t of this.domDocuments){if(t.getSelection().rangeCount){const e=t.activeElement,n=this.domConverter.mapDomToView(e);e&&n&&t.getSelection().removeAllRanges()}}}_removeFakeSelection(){const t=this._fakeSelectionContainer;t&&t.remove()}_updateFocus(){if(this.isFocused){const t=this.selection.editableElement;t&&this.domConverter.focus(t)}}}function ds(t,e,n){const o=e instanceof Array?e:e.childNodes,i=o[n];if(zr(i))return i.data=Mr+i.data,i;{const i=t.createTextNode(Mr);return Array.isArray(e)?o.splice(n,0,i):Gr(e,n,i),i}}function us(t,e){return Jr(t)&&Jr(e)&&!zr(t)&&!zr(e)&&!Zr(t)&&!Zr(e)&&t.tagName.toLowerCase()===e.tagName.toLowerCase()}function hs(t,e,n){return e===n||(zr(e)&&zr(n)?e.data===n.data:!(!t.isBlockFiller(e)||!t.isBlockFiller(n)))}he(ls,se);const ps={window,document};function ms(t){let e=0;for(;t.previousSibling;)t=t.previousSibling,e++;return e}function gs(t){const e=[];for(;t&&t.nodeType!=Node.DOCUMENT_NODE;)e.unshift(t),t=t.parentNode;return e}const fs=Or(document),bs=Fr(document),ks=Nr(document),ws="data-ck-unsafe-attribute-",_s="data-ck-unsafe-element";class Cs{constructor(t,e={}){this.document=t,this.renderingMode=e.renderingMode||"editing",this.blockFillerMode=e.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 Wo,this._encounteredRawContentDomNodes=new WeakSet}bindFakeSelection(t,e){this._fakeSelectionMapping.set(t,new Wi(e))}fakeSelectionToView(t){return this._fakeSelectionMapping.get(t)}bindElements(t,e){this._domToViewMapping.set(t,e),this._viewToDomMapping.set(e,t)}unbindDomElement(t){const e=this._domToViewMapping.get(t);if(e){this._domToViewMapping.delete(t),this._viewToDomMapping.delete(e);for(const e of t.childNodes)this.unbindDomElement(e)}}bindDocumentFragments(t,e){this._domToViewMapping.set(t,e),this._viewToDomMapping.set(e,t)}shouldRenderAttribute(t,e,n){return"data"===this.renderingMode||!(t=t.toLowerCase()).startsWith("on")&&(("srcdoc"!==t||!e.match(/\bon\S+\s*=|javascript:|<\s*\/*script/i))&&("img"===n&&("src"===t||"srcset"===t)||("source"===n&&"srcset"===t||!e.match(/^\s*(javascript:|data:(image\/svg|text\/x?html))/i))))}setContentOf(t,e){if("data"===this.renderingMode)return void(t.innerHTML=e);const n=(new DOMParser).parseFromString(e,"text/html"),o=n.createDocumentFragment(),i=n.body.childNodes;for(;i.length>0;)o.appendChild(i[0]);const r=n.createTreeWalker(o,NodeFilter.SHOW_ELEMENT),s=[];let c;for(;c=r.nextNode();)s.push(c);for(const t of s){for(const e of t.getAttributeNames())this.setDomElementAttribute(t,e,t.getAttribute(e));const e=t.tagName.toLowerCase();this._shouldRenameElement(e)&&(a("domconverter-unsafe-element-detected",{unsafeElement:t}),t.replaceWith(this._createReplacementDomElement(e,t)))}for(;t.firstChild;)t.firstChild.remove();t.append(o)}viewToDom(t,e,n={}){if(t.is("$text")){const n=this._processDataFromViewText(t);return e.createTextNode(n)}{if(this.mapViewToDom(t))return this.mapViewToDom(t);let o;if(t.is("documentFragment"))o=e.createDocumentFragment(),n.bind&&this.bindDocumentFragments(o,t);else{if(t.is("uiElement"))return o="$comment"===t.name?e.createComment(t.getCustomProperty("$rawContent")):t.render(e,this),n.bind&&this.bindElements(o,t),o;this._shouldRenameElement(t.name)?(a("domconverter-unsafe-element-detected",{unsafeElement:t}),o=this._createReplacementDomElement(t.name)):o=t.hasAttribute("xmlns")?e.createElementNS(t.getAttribute("xmlns"),t.name):e.createElement(t.name),t.is("rawElement")&&t.render(o,this),n.bind&&this.bindElements(o,t);for(const e of t.getAttributeKeys())this.setDomElementAttribute(o,e,t.getAttribute(e),t)}if(!1!==n.withChildren)for(const i of this.viewChildrenToDom(t,e,n))o.appendChild(i);return o}}setDomElementAttribute(t,e,n,o=null){const i=this.shouldRenderAttribute(e,n,t.tagName.toLowerCase())||o&&o.shouldRenderUnsafeAttribute(e);i||a("domconverter-unsafe-attribute-detected",{domElement:t,key:e,value:n}),t.hasAttribute(e)&&!i?t.removeAttribute(e):t.hasAttribute(ws+e)&&i&&t.removeAttribute(ws+e),t.setAttribute(i?e:ws+e,n)}removeDomElementAttribute(t,e){e!=_s&&(t.removeAttribute(e),t.removeAttribute(ws+e))}*viewChildrenToDom(t,e,n={}){const o=t.getFillerOffset&&t.getFillerOffset();let i=0;for(const r of t.getChildren())o===i&&(yield this._getBlockFiller(e)),yield this.viewToDom(r,e,n),i++;o===i&&(yield this._getBlockFiller(e))}viewRangeToDom(t){const e=this.viewPositionToDom(t.start),n=this.viewPositionToDom(t.end),o=document.createRange();return o.setStart(e.parent,e.offset),o.setEnd(n.parent,n.offset),o}viewPositionToDom(t){const e=t.parent;if(e.is("$text")){const n=this.findCorrespondingDomText(e);if(!n)return null;let o=t.offset;return Vr(n)&&(o+=7),{parent:n,offset:o}}{let n,o,i;if(0===t.offset){if(n=this.mapViewToDom(e),!n)return null;i=n.childNodes[0]}else{const e=t.nodeBefore;if(o=e.is("$text")?this.findCorrespondingDomText(e):this.mapViewToDom(t.nodeBefore),!o)return null;n=o.parentNode,i=o.nextSibling}if(zr(i)&&Vr(i))return{parent:i,offset:7};return{parent:n,offset:o?ms(o)+1:0}}}domToView(t,e={}){if(this.isBlockFiller(t))return null;const n=this.getHostViewElement(t);if(n)return n;if(Zr(t)&&e.skipComments)return null;if(zr(t)){if(Lr(t))return null;{const e=this._processDataFromDomText(t);return""===e?null:new Lo(this.document,e)}}{if(this.mapDomToView(t))return this.mapDomToView(t);let n;if(this.isDocumentFragment(t))n=new Ar(this.document),e.bind&&this.bindDocumentFragments(t,n);else{n=this._createViewElement(t,e),e.bind&&this.bindElements(t,n);const o=t.attributes;if(o)for(let t=o.length-1;t>=0;t--)n._setAttribute(o[t].name,o[t].value);if(this._isViewElementWithRawContent(n,e)||Zr(t)){const e=Zr(t)?t.data:t.innerHTML;return n._setCustomProperty("$rawContent",e),this._encounteredRawContentDomNodes.add(t),n}}if(!1!==e.withChildren)for(const o of this.domChildrenToView(t,e))n._appendChild(o);return n}}*domChildrenToView(t,e={}){for(let n=0;n{const{scrollLeft:e,scrollTop:n}=t;o.push([e,n])})),e.focus(),As(e,(t=>{const[e,n]=o.shift();t.scrollLeft=e,t.scrollTop=n})),ps.window.scrollTo(t,n)}}isElement(t){return t&&t.nodeType==Node.ELEMENT_NODE}isDocumentFragment(t){return t&&t.nodeType==Node.DOCUMENT_FRAGMENT_NODE}isBlockFiller(t){return"br"==this.blockFillerMode?t.isEqualNode(fs):!("BR"!==t.tagName||!vs(t,this.blockElements)||1!==t.parentNode.childNodes.length)||(t.isEqualNode(ks)||function(t,e){return t.isEqualNode(bs)&&vs(t,e)&&1===t.parentNode.childNodes.length}(t,this.blockElements))}isDomSelectionBackward(t){if(t.isCollapsed)return!1;const e=document.createRange();e.setStart(t.anchorNode,t.anchorOffset),e.setEnd(t.focusNode,t.focusOffset);const n=e.collapsed;return e.detach(),n}getHostViewElement(t){const e=gs(t);for(e.pop();e.length;){const t=e.pop(),n=this._domToViewMapping.get(t);if(n&&(n.is("uiElement")||n.is("rawElement")))return n}return null}isDomSelectionCorrect(t){return this._isDomSelectionPositionCorrect(t.anchorNode,t.anchorOffset)&&this._isDomSelectionPositionCorrect(t.focusNode,t.focusOffset)}registerRawContentMatcher(t){this._rawContentElementMatcher.add(t)}_getBlockFiller(t){switch(this.blockFillerMode){case"nbsp":return Fr(t);case"markedNbsp":return Nr(t);case"br":return Or(t)}}_isDomSelectionPositionCorrect(t,e){if(zr(t)&&Vr(t)&&e<7)return!1;if(this.isElement(t)&&Vr(t.childNodes[e]))return!1;const n=this.mapDomToView(t);return!n||!n.is("uiElement")&&!n.is("rawElement")}_processDataFromViewText(t){let e=t.data;if(t.getAncestors().some((t=>this.preElements.includes(t.name))))return e;if(" "==e.charAt(0)){const n=this._getTouchingInlineViewNode(t,!1);!(n&&n.is("$textProxy")&&this._nodeEndsWithSpace(n))&&n||(e=" "+e.substr(1))}if(" "==e.charAt(e.length-1)){const n=this._getTouchingInlineViewNode(t,!0),o=n&&n.is("$textProxy")&&" "==n.data.charAt(0);" "!=e.charAt(e.length-2)&&n&&!o||(e=e.substr(0,e.length-1)+" ")}return e.replace(/ {2}/g,"  ")}_nodeEndsWithSpace(t){if(t.getAncestors().some((t=>this.preElements.includes(t.name))))return!1;const e=this._processDataFromViewText(t);return" "==e.charAt(e.length-1)}_processDataFromDomText(t){let e=t.data;if(function(t,e){return gs(t).some((t=>t.tagName&&e.includes(t.tagName.toLowerCase())))}(t,this.preElements))return Hr(t);e=e.replace(/[ \n\t\r]{1,}/g," ");const n=this._getTouchingInlineDomNode(t,!1),o=this._getTouchingInlineDomNode(t,!0),i=this._checkShouldLeftTrimDomText(t,n),r=this._checkShouldRightTrimDomText(t,o);i&&(e=e.replace(/^ /,"")),r&&(e=e.replace(/ $/,"")),e=Hr(new Text(e)),e=e.replace(/ \u00A0/g," ");const s=o&&this.isElement(o)&&"BR"!=o.tagName,a=o&&zr(o)&&" "==o.data.charAt(0);return(/( |\u00A0)\u00A0$/.test(e)||!o||s||a)&&(e=e.replace(/\u00A0$/," ")),(i||n&&this.isElement(n)&&"BR"!=n.tagName)&&(e=e.replace(/^\u00A0/," ")),e}_checkShouldLeftTrimDomText(t,e){return!e||(this.isElement(e)?"BR"===e.tagName:!this._encounteredRawContentDomNodes.has(t.previousSibling)&&/[^\S\u00A0]/.test(e.data.charAt(e.data.length-1)))}_checkShouldRightTrimDomText(t,e){return!e&&!Vr(t)}_getTouchingInlineViewNode(t,e){const n=new Mi({startPosition:e?Vi._createAfter(t):Vi._createBefore(t),direction:e?"forward":"backward"});for(const t of n){if(t.item.is("element")&&this.inlineObjectElements.includes(t.item.name))return t.item;if(t.item.is("containerElement"))return null;if(t.item.is("element","br"))return null;if(t.item.is("$textProxy"))return t.item}return null}_getTouchingInlineDomNode(t,e){if(!t.parentNode)return null;const n=e?"firstChild":"lastChild",o=e?"nextSibling":"previousSibling";let i=!0;do{if(!i&&t[n]?t=t[n]:t[o]?(t=t[o],i=!1):(t=t.parentNode,i=!0),!t||this._isBlockElement(t))return null}while(!zr(t)&&"BR"!=t.tagName&&!this._isInlineObjectElement(t));return t}_isBlockElement(t){return this.isElement(t)&&this.blockElements.includes(t.tagName.toLowerCase())}_isInlineObjectElement(t){return this.isElement(t)&&this.inlineObjectElements.includes(t.tagName.toLowerCase())}_createViewElement(t,e){if(Zr(t))return new br(this.document,"$comment");const n=e.keepOriginalCase?t.tagName:t.tagName.toLowerCase();return new Pi(this.document,n)}_isViewElementWithRawContent(t,e){return!1!==e.withChildren&&this._rawContentElementMatcher.match(t)}_shouldRenameElement(t){return"editing"==this.renderingMode&&"script"==t.toLowerCase()}_createReplacementDomElement(t,e=null){const n=document.createElement("span");if(n.setAttribute(_s,t),e){for(;e.firstChild;)n.appendChild(e.firstChild);for(const t of e.getAttributeNames())n.setAttribute(t,e.getAttribute(t))}return n}}function As(t,e){for(;t&&t!=ps.document;)e(t),t=t.parentNode}function vs(t,e){const n=t.parentNode;return n&&n.tagName&&e.includes(n.tagName.toLowerCase())}function ys(t){const e=Object.prototype.toString.apply(t);return"[object Window]"==e||"[object global]"==e}const xs=Xt({},g,{listenTo(t,e,n,o={}){if(Jr(t)||ys(t)){const i={capture:!!o.useCapture,passive:!!o.usePassive},r=this._getProxyEmitter(t,i)||new Ds(t,i);this.listenTo(r,e,n,o)}else g.listenTo.call(this,t,e,n,o)},stopListening(t,e,n){if(Jr(t)||ys(t)){const o=this._getAllProxyEmitters(t);for(const t of o)this.stopListening(t,e,n)}else g.stopListening.call(this,t,e,n)},_getProxyEmitter(t,e){return n=this,o=Ss(t,e),n[h]&&n[h][o]?n[h][o].emitter:null;var n,o},_getAllProxyEmitters(t){return[{capture:!1,passive:!1},{capture:!1,passive:!0},{capture:!0,passive:!1},{capture:!0,passive:!0}].map((e=>this._getProxyEmitter(t,e))).filter((t=>!!t))}}),Es=xs;class Ds{constructor(t,e){f(this,Ss(t,e)),this._domNode=t,this._options=e}}function Ss(t,e){let n=function(t){return t["data-ck-expando"]||(t["data-ck-expando"]=i())}(t);for(const t of Object.keys(e).sort())e[t]&&(n+="-"+t);return n}Xt(Ds.prototype,g,{attach(t){if(this._domListeners&&this._domListeners[t])return;const e=this._createDomListener(t);this._domNode.addEventListener(t,e,this._options),this._domListeners||(this._domListeners={}),this._domListeners[t]=e},detach(t){let e;!this._domListeners[t]||(e=this._events[t])&&e.callbacks.length||this._domListeners[t].removeListener()},_addEventListener(t,e,n){this.attach(t),g._addEventListener.call(this,t,e,n)},_removeEventListener(t,e){g._removeEventListener.call(this,t,e),this.detach(t)},_createDomListener(t){const e=e=>{this.fire(t,e)};return e.removeListener=()=>{this._domNode.removeEventListener(t,e,this._options),delete this._domListeners[t]},e}});class Bs{constructor(t){this.view=t,this.document=t.document,this.isEnabled=!1}enable(){this.isEnabled=!0}disable(){this.isEnabled=!1}destroy(){this.disable(),this.stopListening()}checkShouldIgnoreEventFromTarget(t){return t&&3===t.nodeType&&(t=t.parentNode),!(!t||1!==t.nodeType)&&t.matches("[data-cke-ignore-events], [data-cke-ignore-events] *")}}he(Bs,Es);const Ts=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this};const Ps=function(t){return this.__data__.has(t)};function Is(t){var e=-1,n=null==t?0:t.length;for(this.__data__=new on;++ea))return!1;var l=r.get(t),d=r.get(e);if(l&&d)return l==e&&d==t;var u=-1,h=!0,p=2&n?new Rs:void 0;for(r.set(t,e),r.set(e,t);++u{this.listenTo(t,e,((t,e)=>{this.isEnabled&&!this.checkShouldIgnoreEventFromTarget(e.target)&&this.onDomEvent(e)}),{useCapture:this.useCapture})}))}fire(t,e,n){this.isEnabled&&this.document.fire(t,new Qs(this.view,e,n))}}class ta extends Xs{constructor(t){super(t),this.domEventType=["keydown","keyup"]}onDomEvent(t){this.fire(t.type,t,{keyCode:t.keyCode,altKey:t.altKey,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,metaKey:t.metaKey,get keystroke(){return pr(this)}})}}const ea=function(){return D.Date.now()};var na=/\s/;const oa=function(t){for(var e=t.length;e--&&na.test(t.charAt(e)););return e};var ia=/^\s+/;const ra=function(t){return t?t.slice(0,oa(t)+1).replace(ia,""):t};var sa=/^[-+]0x[0-9a-f]+$/i,aa=/^0b[01]+$/i,ca=/^0o[0-7]+$/i,la=parseInt;const da=function(t){if("number"==typeof t)return t;if($o(t))return NaN;if(y(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=y(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=ra(t);var n=aa.test(t);return n||ca.test(t)?la(t.slice(2),n?2:8):sa.test(t)?NaN:+t};var ua=Math.max,ha=Math.min;const pa=function(t,e,n){var o,i,r,s,a,c,l=0,d=!1,u=!1,h=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function p(e){var n=o,r=i;return o=i=void 0,l=e,s=t.apply(r,n)}function m(t){return l=t,a=setTimeout(f,e),d?p(t):s}function g(t){var n=t-c;return void 0===c||n>=e||n<0||u&&t-l>=r}function f(){var t=ea();if(g(t))return b(t);a=setTimeout(f,function(t){var n=e-(t-c);return u?ha(n,r-(t-l)):n}(t))}function b(t){return a=void 0,h&&o?p(t):(o=i=void 0,s)}function k(){var t=ea(),n=g(t);if(o=arguments,i=this,c=t,n){if(void 0===a)return m(c);if(u)return clearTimeout(a),a=setTimeout(f,e),p(c)}return void 0===a&&(a=setTimeout(f,e)),s}return e=da(e)||0,y(n)&&(d=!!n.leading,r=(u="maxWait"in n)?ua(da(n.maxWait)||0,e):r,h="trailing"in n?!!n.trailing:h),k.cancel=function(){void 0!==a&&clearTimeout(a),l=0,o=c=i=a=void 0},k.flush=function(){return void 0===a?s:b(ea())},k};class ma extends Bs{constructor(t){super(t),this._fireSelectionChangeDoneDebounced=pa((t=>this.document.fire("selectionChangeDone",t)),200)}observe(){const t=this.document;t.on("arrowKey",((e,n)=>{t.selection.isFake&&this.isEnabled&&n.preventDefault()}),{context:"$capture"}),t.on("arrowKey",((e,n)=>{t.selection.isFake&&this.isEnabled&&this._handleSelectionMove(n.keyCode)}),{priority:"lowest"})}destroy(){super.destroy(),this._fireSelectionChangeDoneDebounced.cancel()}_handleSelectionMove(t){const e=this.document.selection,n=new Wi(e.getRanges(),{backward:e.isBackward,fake:!1});t!=ur.arrowleft&&t!=ur.arrowup||n.setTo(n.getFirstPosition()),t!=ur.arrowright&&t!=ur.arrowdown||n.setTo(n.getLastPosition());const o={oldSelection:e,newSelection:n,domSelection:null};this.document.fire("selectionChange",o),this._fireSelectionChangeDoneDebounced(o)}}class ga extends Bs{constructor(t){super(t),this.mutationObserver=t.getObserver(Ys),this.selection=this.document.selection,this.domConverter=t.domConverter,this._documents=new WeakSet,this._fireSelectionChangeDoneDebounced=pa((t=>this.document.fire("selectionChangeDone",t)),200),this._clearInfiniteLoopInterval=setInterval((()=>this._clearInfiniteLoop()),1e3),this._documentIsSelectingInactivityTimeoutDebounced=pa((()=>this.document.isSelecting=!1),5e3),this._loopbackCounter=0}observe(t){const e=t.ownerDocument,n=()=>{this.document.isSelecting=!1,this._documentIsSelectingInactivityTimeoutDebounced.cancel()};this.listenTo(t,"selectstart",(()=>{this.document.isSelecting=!0,this._documentIsSelectingInactivityTimeoutDebounced()}),{priority:"highest"}),this.listenTo(t,"keydown",n,{priority:"highest"}),this.listenTo(t,"keyup",n,{priority:"highest"}),this._documents.has(e)||(this.listenTo(e,"mouseup",n,{priority:"highest"}),this.listenTo(e,"selectionchange",((t,n)=>{this._handleSelectionChange(n,e),this._documentIsSelectingInactivityTimeoutDebounced()})),this._documents.add(e))}destroy(){super.destroy(),clearInterval(this._clearInfiniteLoopInterval),this._fireSelectionChangeDoneDebounced.cancel(),this._documentIsSelectingInactivityTimeoutDebounced.cancel()}_handleSelectionChange(t,e){if(!this.isEnabled)return;const n=e.defaultView.getSelection();if(this.checkShouldIgnoreEventFromTarget(n.anchorNode))return;this.mutationObserver.flush();const o=this.domConverter.domSelectionToView(n);if(0!=o.rangeCount){if(this.view.hasDomSelection=!0,!(this.selection.isEqual(o)&&this.domConverter.isDomSelectionCorrect(n)||++this._loopbackCounter>60))if(this.selection.isSimilar(o))this.view.forceRender();else{const t={oldSelection:this.selection,newSelection:o,domSelection:n};this.document.fire("selectionChange",t),this._fireSelectionChangeDoneDebounced(t)}}else this.view.hasDomSelection=!1}_clearInfiniteLoop(){this._loopbackCounter=0}}class fa extends Xs{constructor(t){super(t),this.domEventType=["focus","blur"],this.useCapture=!0;const e=this.document;e.on("focus",(()=>{e.isFocused=!0,this._renderTimeoutId=setTimeout((()=>t.change((()=>{}))),50)})),e.on("blur",((n,o)=>{const i=e.selection.editableElement;null!==i&&i!==o.target||(e.isFocused=!1,t.change((()=>{})))}))}onDomEvent(t){this.fire(t.type,t)}destroy(){this._renderTimeoutId&&clearTimeout(this._renderTimeoutId),super.destroy()}}class ba extends Xs{constructor(t){super(t),this.domEventType=["compositionstart","compositionupdate","compositionend"];const e=this.document;e.on("compositionstart",(()=>{e.isComposing=!0})),e.on("compositionend",(()=>{e.isComposing=!1}))}onDomEvent(t){this.fire(t.type,t)}}class ka extends Xs{constructor(t){super(t),this.domEventType=["beforeinput"]}onDomEvent(t){this.fire(t.type,t)}}const wa=function(t){return"string"==typeof t||!Bt(t)&&At(t)&&"[object String]"==O(t)};function _a(t,e,n={},o=[]){const i=n&&n.xmlns,r=i?t.createElementNS(i,e):t.createElement(e);for(const t in n)r.setAttribute(t,n[t]);!wa(o)&&Do(o)||(o=[o]);for(let e of o)wa(e)&&(e=t.createTextNode(e)),r.appendChild(e);return r}function Ca(t){return"[object Range]"==Object.prototype.toString.apply(t)}function Aa(t){const e=t.ownerDocument.defaultView.getComputedStyle(t);return{top:parseInt(e.borderTopWidth,10),right:parseInt(e.borderRightWidth,10),bottom:parseInt(e.borderBottomWidth,10),left:parseInt(e.borderLeftWidth,10)}}const va=["top","right","bottom","left","width","height"];class ya{constructor(t){const e=Ca(t);if(Object.defineProperty(this,"_source",{value:t._source||t,writable:!0,enumerable:!1}),vo(t)||e)if(e){const e=ya.getDomRangeRects(t);xa(this,ya.getBoundingRect(e))}else xa(this,t.getBoundingClientRect());else if(ys(t)){const{innerWidth:e,innerHeight:n}=t;xa(this,{top:0,right:e,bottom:n,left:0,width:e,height:n})}else xa(this,t)}clone(){return new ya(this)}moveTo(t,e){return this.top=e,this.right=t+this.width,this.bottom=e+this.height,this.left=t,this}moveBy(t,e){return this.top+=e,this.right+=t,this.left+=t,this.bottom+=e,this}getIntersection(t){const e={top:Math.max(this.top,t.top),right:Math.min(this.right,t.right),bottom:Math.min(this.bottom,t.bottom),left:Math.max(this.left,t.left)};return e.width=e.right-e.left,e.height=e.bottom-e.top,e.width<0||e.height<0?null:new ya(e)}getIntersectionArea(t){const e=this.getIntersection(t);return e?e.getArea():0}getArea(){return this.width*this.height}getVisible(){const t=this._source;let e=this.clone();if(!Ea(t)){let n=t.parentNode||t.commonAncestorContainer;for(;n&&!Ea(n);){const t=new ya(n),o=e.getIntersection(t);if(!o)return null;o.getArea(){for(const e of t){const t=Da._getElementCallbacks(e.target);if(t)for(const n of t)n(e)}}))}}Da._observerInstance=null,Da._elementCallbacks=null;class Sa{constructor(t){this._callback=t,this._elements=new Set,this._previousRects=new Map,this._periodicCheckTimeout=null}observe(t){this._elements.add(t),this._checkElementRectsAndExecuteCallback(),1===this._elements.size&&this._startPeriodicCheck()}unobserve(t){this._elements.delete(t),this._previousRects.delete(t),this._elements.size||this._stopPeriodicCheck()}_startPeriodicCheck(){const t=()=>{this._checkElementRectsAndExecuteCallback(),this._periodicCheckTimeout=setTimeout(t,100)};this.listenTo(ps.window,"resize",(()=>{this._checkElementRectsAndExecuteCallback()})),this._periodicCheckTimeout=setTimeout(t,100)}_stopPeriodicCheck(){clearTimeout(this._periodicCheckTimeout),this.stopListening(),this._previousRects.clear()}_checkElementRectsAndExecuteCallback(){const t=[];for(const e of this._elements)this._hasRectChanged(e)&&t.push({target:e,contentRect:this._previousRects.get(e)});t.length&&this._callback(t)}_hasRectChanged(t){if(!t.ownerDocument.body.contains(t))return!1;const e=new ya(t),n=this._previousRects.get(t),o=!n||!n.isEqual(e);return this._previousRects.set(t,e),o}}function Ba(t,e){t instanceof HTMLTextAreaElement&&(t.value=e),t.innerHTML=e}function Ta(t){const e=t.next();return e.done?null:e.value}he(Sa,Es);class Pa{constructor(){this.set("isFocused",!1),this.set("focusedElement",null),this._elements=new Set,this._nextEventLoopTimeout=null}add(t){if(this._elements.has(t))throw new s("focustracker-add-element-already-exist",this);this.listenTo(t,"focus",(()=>this._focus(t)),{useCapture:!0}),this.listenTo(t,"blur",(()=>this._blur()),{useCapture:!0}),this._elements.add(t)}remove(t){t===this.focusedElement&&this._blur(t),this._elements.has(t)&&(this.stopListening(t),this._elements.delete(t))}destroy(){this.stopListening()}_focus(t){clearTimeout(this._nextEventLoopTimeout),this.focusedElement=t,this.isFocused=!0}_blur(){clearTimeout(this._nextEventLoopTimeout),this._nextEventLoopTimeout=setTimeout((()=>{this.focusedElement=null,this.isFocused=!1}),0)}}he(Pa,Es),he(Pa,se);class Ia{constructor(){this._listener=Object.create(Es)}listenTo(t){this._listener.listenTo(t,"keydown",((t,e)=>{this._listener.fire("_keydown:"+pr(e),e)}))}set(t,e,n={}){const o=mr(t),i=n.priority;this._listener.listenTo(this._listener,"_keydown:"+o,((t,n)=>{e(n,(()=>{n.preventDefault(),n.stopPropagation(),t.stop()})),t.return=!0}),{priority:i})}press(t){return!!this._listener.fire("_keydown:"+pr(t),t)}destroy(){this._listener.stopListening()}}class Ra extends Bs{constructor(t){super(t),this.document.on("keydown",((t,e)=>{if(this.isEnabled&&((n=e.keyCode)==ur.arrowright||n==ur.arrowleft||n==ur.arrowup||n==ur.arrowdown)){const n=new Ui(this.document,"arrowKey",this.document.selection.getFirstRange());this.document.fire(n,e),n.stop.called&&t.stop()}var n}))}observe(){}}function za({target:t,viewportOffset:e=0}){const n=Ha(t);let o=n,i=null;for(;o;){let r;r=qa(o==n?t:i),Na(r,(()=>Wa(t,o)));const s=Wa(t,o);if(Fa(o,s,e),o.parent!=o){if(i=o.frameElement,o=o.parent,!i)return}else o=null}}function Fa(t,e,n){const o=e.clone().moveBy(0,n),i=e.clone().moveBy(0,-n),r=new ya(t).excludeScrollbarsAndBorders();if(![i,o].every((t=>r.contains(t)))){let{scrollX:s,scrollY:a}=t;Ma(i,r)?a-=r.top-e.top+n:Oa(o,r)&&(a+=e.bottom-r.bottom+n),Va(e,r)?s-=r.left-e.left+n:La(e,r)&&(s+=e.right-r.right+n),t.scrollTo(s,a)}}function Na(t,e){const n=Ha(t);let o,i;for(;t!=n.document.body;)i=e(),o=new ya(t).excludeScrollbarsAndBorders(),o.contains(i)||(Ma(i,o)?t.scrollTop-=o.top-i.top:Oa(i,o)&&(t.scrollTop+=i.bottom-o.bottom),Va(i,o)?t.scrollLeft-=o.left-i.left:La(i,o)&&(t.scrollLeft+=i.right-o.right)),t=t.parentNode}function Oa(t,e){return t.bottom>e.bottom}function Ma(t,e){return t.tope.right}function Ha(t){return Ca(t)?t.startContainer.ownerDocument.defaultView:t.ownerDocument.defaultView}function qa(t){if(Ca(t)){let e=t.commonAncestorContainer;return zr(e)&&(e=e.parentNode),e}return t.parentNode}function Wa(t,e){const n=Ha(t),o=new ya(t);if(n===e)return o;{let t=n;for(;t!=e;){const e=t.frameElement,n=new ya(e).excludeScrollbarsAndBorders();o.moveBy(n.left,n.top),t=t.parent}}return o}Object.assign({},{scrollViewportToShowTarget:za,scrollAncestorsToShowTarget:function(t){Na(qa(t),(()=>new ya(t)))}});class ja{constructor(t){this.document=new Xi(t),this.domConverter=new Cs(this.document),this.domRoots=new Map,this.set("isRenderingInProgress",!1),this.set("hasDomSelection",!1),this._renderer=new ls(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 vr(this.document),this.addObserver(Ys),this.addObserver(ga),this.addObserver(fa),this.addObserver(ta),this.addObserver(ma),this.addObserver(ba),this.addObserver(Ra),ar.isAndroid&&this.addObserver(ka),this.document.on("arrowKey",qr,{priority:"low"}),kr(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(t,e="main"){const n=this.document.getRoot(e);n._name=t.tagName.toLowerCase();const o={};for(const{name:e,value:i}of Array.from(t.attributes))o[e]=i,"class"===e?this._writer.addClass(i.split(" "),n):this._writer.setAttribute(e,i,n);this._initialDomRootAttributes.set(t,o);const i=()=>{this._writer.setAttribute("contenteditable",!n.isReadOnly,n),n.isReadOnly?this._writer.addClass("ck-read-only",n):this._writer.removeClass("ck-read-only",n)};i(),this.domRoots.set(e,t),this.domConverter.bindElements(t,n),this._renderer.markToSync("children",n),this._renderer.markToSync("attributes",n),this._renderer.domDocuments.add(t.ownerDocument),n.on("change:children",((t,e)=>this._renderer.markToSync("children",e))),n.on("change:attributes",((t,e)=>this._renderer.markToSync("attributes",e))),n.on("change:text",((t,e)=>this._renderer.markToSync("text",e))),n.on("change:isReadOnly",(()=>this.change(i))),n.on("change",(()=>{this._hasChangedSinceTheLastRendering=!0}));for(const n of this._observers.values())n.observe(t,e)}detachDomRoot(t){const e=this.domRoots.get(t);Array.from(e.attributes).forEach((({name:t})=>e.removeAttribute(t)));const n=this._initialDomRootAttributes.get(e);for(const t in n)e.setAttribute(t,n[t]);this.domRoots.delete(t),this.domConverter.unbindDomElement(e)}getDomRoot(t="main"){return this.domRoots.get(t)}addObserver(t){let e=this._observers.get(t);if(e)return e;e=new t(this),this._observers.set(t,e);for(const[t,n]of this.domRoots)e.observe(n,t);return e.enable(),e}getObserver(t){return this._observers.get(t)}disableObservers(){for(const t of this._observers.values())t.disable()}enableObservers(){for(const t of this._observers.values())t.enable()}scrollToTheSelection(){const t=this.document.selection.getFirstRange();t&&za({target:this.domConverter.viewRangeToDom(t),viewportOffset:20})}focus(){if(!this.document.isFocused){const t=this.document.selection.editableElement;t&&(this.domConverter.focus(t),this.forceRender())}}change(t){if(this.isRenderingInProgress||this._postFixersInProgress)throw new s("cannot-change-view-tree",this);try{if(this._ongoingChange)return t(this._writer);this._ongoingChange=!0;const e=t(this._writer);return this._ongoingChange=!1,!this._renderingDisabled&&this._hasChangedSinceTheLastRendering&&(this._postFixersInProgress=!0,this.document._callPostFixers(this._writer),this._postFixersInProgress=!1,this.fire("render")),e}catch(t){s.rethrowUnexpectedError(t,this)}}forceRender(){this._hasChangedSinceTheLastRendering=!0,this.change((()=>{}))}destroy(){for(const t of this._observers.values())t.destroy();this.document.destroy(),this.stopListening()}createPositionAt(t,e){return Vi._createAt(t,e)}createPositionAfter(t){return Vi._createAfter(t)}createPositionBefore(t){return Vi._createBefore(t)}createRange(t,e){return new Li(t,e)}createRangeOn(t){return Li._createOn(t)}createRangeIn(t){return Li._createIn(t)}createSelection(t,e,n){return new Wi(t,e,n)}_disableRendering(t){this._renderingDisabled=t,0==t&&this.change((()=>{}))}_render(){this.isRenderingInProgress=!0,this.disableObservers(),this._renderer.render(),this.enableObservers(),this.isRenderingInProgress=!1}}he(ja,se);class Ua{constructor(t){this.parent=null,this._attrs=qo(t)}get index(){let t;if(!this.parent)return null;if(null===(t=this.parent.getChildIndex(this)))throw new s("model-node-not-found-in-parent",this);return t}get startOffset(){let t;if(!this.parent)return null;if(null===(t=this.parent.getChildStartOffset(this)))throw new s("model-node-not-found-in-parent",this);return t}get offsetSize(){return 1}get endOffset(){return this.parent?this.startOffset+this.offsetSize:null}get nextSibling(){const t=this.index;return null!==t&&this.parent.getChild(t+1)||null}get previousSibling(){const t=this.index;return null!==t&&this.parent.getChild(t-1)||null}get root(){let t=this;for(;t.parent;)t=t.parent;return t}isAttached(){return this.root.is("rootElement")}getPath(){const t=[];let e=this;for(;e.parent;)t.unshift(e.startOffset),e=e.parent;return t}getAncestors(t={includeSelf:!1,parentFirst:!1}){const e=[];let n=t.includeSelf?this:this.parent;for(;n;)e[t.parentFirst?"push":"unshift"](n),n=n.parent;return e}getCommonAncestor(t,e={}){const n=this.getAncestors(e),o=t.getAncestors(e);let i=0;for(;n[i]==o[i]&&n[i];)i++;return 0===i?null:n[i-1]}isBefore(t){if(this==t)return!1;if(this.root!==t.root)return!1;const e=this.getPath(),n=t.getPath(),o=Oo(e,n);switch(o){case"prefix":return!0;case"extension":return!1;default:return e[o](t[e[0]]=e[1],t)),{})),t}is(t){return"node"===t||"model:node"===t}_clone(){return new Ua(this._attrs)}_remove(){this.parent._removeChildren(this.index)}_setAttribute(t,e){this._attrs.set(t,e)}_setAttributesTo(t){this._attrs=qo(t)}_removeAttribute(t){return this._attrs.delete(t)}_clearAttributes(){this._attrs.clear()}}class $a extends Ua{constructor(t,e){super(e),this._data=t||""}get offsetSize(){return this.data.length}get data(){return this._data}is(t){return"$text"===t||"model:$text"===t||"text"===t||"model:text"===t||"node"===t||"model:node"===t}toJSON(){const t=super.toJSON();return t.data=this.data,t}_clone(){return new $a(this.data,this.getAttributes())}static fromJSON(t){return new $a(t.data,t.attributes)}}class Ga{constructor(t,e,n){if(this.textNode=t,e<0||e>t.offsetSize)throw new s("model-textproxy-wrong-offsetintext",this);if(n<0||e+n>t.offsetSize)throw new s("model-textproxy-wrong-length",this);this.data=t.data.substring(e,e+n),this.offsetInText=e}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(t){return"$textProxy"===t||"model:$textProxy"===t||"textProxy"===t||"model:textProxy"===t}getPath(){const t=this.textNode.getPath();return t.length>0&&(t[t.length-1]+=this.offsetInText),t}getAncestors(t={includeSelf:!1,parentFirst:!1}){const e=[];let n=t.includeSelf?this:this.parent;for(;n;)e[t.parentFirst?"push":"unshift"](n),n=n.parent;return e}hasAttribute(t){return this.textNode.hasAttribute(t)}getAttribute(t){return this.textNode.getAttribute(t)}getAttributes(){return this.textNode.getAttributes()}getAttributeKeys(){return this.textNode.getAttributeKeys()}}class Ka{constructor(t){this._nodes=[],t&&this._insertNodes(0,t)}[Symbol.iterator](){return this._nodes[Symbol.iterator]()}get length(){return this._nodes.length}get maxOffset(){return this._nodes.reduce(((t,e)=>t+e.offsetSize),0)}getNode(t){return this._nodes[t]||null}getNodeIndex(t){const e=this._nodes.indexOf(t);return-1==e?null:e}getNodeStartOffset(t){const e=this.getNodeIndex(t);return null===e?null:this._nodes.slice(0,e).reduce(((t,e)=>t+e.offsetSize),0)}indexToOffset(t){if(t==this._nodes.length)return this.maxOffset;const e=this._nodes[t];if(!e)throw new s("model-nodelist-index-out-of-bounds",this);return this.getNodeStartOffset(e)}offsetToIndex(t){let e=0;for(const n of this._nodes){if(t>=e&&tt.toJSON()))}}class Za extends Ua{constructor(t,e,n){super(e),this.name=t,this._children=new Ka,n&&this._insertChild(0,n)}get childCount(){return this._children.length}get maxOffset(){return this._children.maxOffset}get isEmpty(){return 0===this.childCount}is(t,e=null){return e?e===this.name&&("element"===t||"model:element"===t):"element"===t||"model:element"===t||"node"===t||"model:node"===t}getChild(t){return this._children.getNode(t)}getChildren(){return this._children[Symbol.iterator]()}getChildIndex(t){return this._children.getNodeIndex(t)}getChildStartOffset(t){return this._children.getNodeStartOffset(t)}offsetToIndex(t){return this._children.offsetToIndex(t)}getNodeByPath(t){let e=this;for(const n of t)e=e.getChild(e.offsetToIndex(n));return e}findAncestor(t,e={includeSelf:!1}){let n=e.includeSelf?this:this.parent;for(;n;){if(n.name===t)return n;n=n.parent}return null}toJSON(){const t=super.toJSON();if(t.name=this.name,this._children.length>0){t.children=[];for(const e of this._children)t.children.push(e.toJSON())}return t}_clone(t=!1){const e=t?Array.from(this._children).map((t=>t._clone(!0))):null;return new Za(this.name,this.getAttributes(),e)}_appendChild(t){this._insertChild(this.childCount,t)}_insertChild(t,e){const n=function(t){if("string"==typeof t)return[new $a(t)];Do(t)||(t=[t]);return Array.from(t).map((t=>"string"==typeof t?new $a(t):t instanceof Ga?new $a(t.data,t.getAttributes()):t))}(e);for(const t of n)null!==t.parent&&t._remove(),t.parent=this;this._children._insertNodes(t,n)}_removeChildren(t,e=1){const n=this._children._removeNodes(t,e);for(const t of n)t.parent=null;return n}static fromJSON(t){let e=null;if(t.children){e=[];for(const n of t.children)n.name?e.push(Za.fromJSON(n)):e.push($a.fromJSON(n))}return new Za(t.name,t.attributes,e)}}class Ja{constructor(t={}){if(!t.boundaries&&!t.startPosition)throw new s("model-tree-walker-no-start-position",null);const e=t.direction||"forward";if("forward"!=e&&"backward"!=e)throw new s("model-tree-walker-unknown-direction",t,{direction:e});this.direction=e,this.boundaries=t.boundaries||null,t.startPosition?this.position=t.startPosition.clone():this.position=Qa._createAt(this.boundaries["backward"==this.direction?"end":"start"]),this.position.stickiness="toNone",this.singleCharacters=!!t.singleCharacters,this.shallow=!!t.shallow,this.ignoreElementEnd=!!t.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(t){let e,n,o,i;do{o=this.position,i=this._visitedParent,({done:e,value:n}=this.next())}while(!e&&t(n));e||(this.position=o,this._visitedParent=i)}next(){return"forward"==this.direction?this._next():this._previous()}_next(){const t=this.position,e=this.position.clone(),n=this._visitedParent;if(null===n.parent&&e.offset===n.maxOffset)return{done:!0};if(n===this._boundaryEndParent&&e.offset==this.boundaries.end.offset)return{done:!0};const o=e.parent,i=Xa(e,o),r=i||tc(e,o,i);if(r instanceof Za)return this.shallow?e.offset++:(e.path.push(0),this._visitedParent=r),this.position=e,Ya("elementStart",r,t,e,1);if(r instanceof $a){let o;if(this.singleCharacters)o=1;else{let t=r.endOffset;this._boundaryEndParent==n&&this.boundaries.end.offsett&&(t=this.boundaries.start.offset),o=e.offset-t}const i=e.offset-r.startOffset,s=new Ga(r,i-o,o);return e.offset-=o,this.position=e,Ya("text",s,t,e,o)}return e.path.pop(),this.position=e,this._visitedParent=n.parent,Ya("elementStart",n,t,e,1)}}function Ya(t,e,n,o,i){return{done:!1,value:{type:t,item:e,previousPosition:n,nextPosition:o,length:i}}}class Qa{constructor(t,e,n="toNone"){if(!t.is("element")&&!t.is("documentFragment"))throw new s("model-position-root-invalid",t);if(!(e instanceof Array)||0===e.length)throw new s("model-position-path-incorrect-format",t,{path:e});t.is("rootElement")?e=e.slice():(e=[...t.getPath(),...e],t=t.root),this.root=t,this.path=e,this.stickiness=n}get offset(){return this.path[this.path.length-1]}set offset(t){this.path[this.path.length-1]=t}get parent(){let t=this.root;for(let e=0;en.path.length){if(e.offset!==o.maxOffset)return!1;e.path=e.path.slice(0,-1),o=o.parent,e.offset++}else{if(0!==n.offset)return!1;n.path=n.path.slice(0,-1)}}}is(t){return"position"===t||"model:position"===t}hasSameParentAs(t){if(this.root!==t.root)return!1;return"same"==Oo(this.getParentPath(),t.getParentPath())}getTransformedByOperation(t){let e;switch(t.type){case"insert":e=this._getTransformedByInsertOperation(t);break;case"move":case"remove":case"reinsert":e=this._getTransformedByMoveOperation(t);break;case"split":e=this._getTransformedBySplitOperation(t);break;case"merge":e=this._getTransformedByMergeOperation(t);break;default:e=Qa._createAt(this)}return e}_getTransformedByInsertOperation(t){return this._getTransformedByInsertion(t.position,t.howMany)}_getTransformedByMoveOperation(t){return this._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany)}_getTransformedBySplitOperation(t){const e=t.movedRange;return e.containsPosition(this)||e.start.isEqual(this)&&"toNext"==this.stickiness?this._getCombined(t.splitPosition,t.moveTargetPosition):t.graveyardPosition?this._getTransformedByMove(t.graveyardPosition,t.insertionPosition,1):this._getTransformedByInsertion(t.insertionPosition,1)}_getTransformedByMergeOperation(t){const e=t.movedRange;let n;return e.containsPosition(this)||e.start.isEqual(this)?(n=this._getCombined(t.sourcePosition,t.targetPosition),t.sourcePosition.isBefore(t.targetPosition)&&(n=n._getTransformedByDeletion(t.deletionPosition,1))):n=this.isEqual(t.deletionPosition)?Qa._createAt(t.deletionPosition):this._getTransformedByMove(t.deletionPosition,t.graveyardPosition,1),n}_getTransformedByDeletion(t,e){const n=Qa._createAt(this);if(this.root!=t.root)return n;if("same"==Oo(t.getParentPath(),this.getParentPath())){if(t.offsetthis.offset)return null;n.offset-=e}}else if("prefix"==Oo(t.getParentPath(),this.getParentPath())){const o=t.path.length-1;if(t.offset<=this.path[o]){if(t.offset+e>this.path[o])return null;n.path[o]-=e}}return n}_getTransformedByInsertion(t,e){const n=Qa._createAt(this);if(this.root!=t.root)return n;if("same"==Oo(t.getParentPath(),this.getParentPath()))(t.offsete+1;){const e=o.maxOffset-n.offset;0!==e&&t.push(new nc(n,n.getShiftedBy(e))),n.path=n.path.slice(0,-1),n.offset++,o=o.parent}for(;n.path.length<=this.end.path.length;){const e=this.end.path[n.path.length-1],o=e-n.offset;0!==o&&t.push(new nc(n,n.getShiftedBy(o))),n.offset=e,n.path.push(0)}return t}getWalker(t={}){return t.boundaries=this,new Ja(t)}*getItems(t={}){t.boundaries=this,t.ignoreElementEnd=!0;const e=new Ja(t);for(const t of e)yield t.item}*getPositions(t={}){t.boundaries=this;const e=new Ja(t);yield e.position;for(const t of e)yield t.nextPosition}getTransformedByOperation(t){switch(t.type){case"insert":return this._getTransformedByInsertOperation(t);case"move":case"remove":case"reinsert":return this._getTransformedByMoveOperation(t);case"split":return[this._getTransformedBySplitOperation(t)];case"merge":return[this._getTransformedByMergeOperation(t)]}return[new nc(this.start,this.end)]}getTransformedByOperations(t){const e=[new nc(this.start,this.end)];for(const n of t)for(let t=0;t0?new this(n,o):new this(o,n)}static _createIn(t){return new this(Qa._createAt(t,0),Qa._createAt(t,t.maxOffset))}static _createOn(t){return this._createFromPositionAndShift(Qa._createBefore(t),t.offsetSize)}static _createFromRanges(t){if(0===t.length)throw new s("range-create-from-ranges-empty-array",null);if(1==t.length)return t[0].clone();const e=t[0];t.sort(((t,e)=>t.start.isAfter(e.start)?1:-1));const n=t.indexOf(e),o=new this(e.start,e.end);if(n>0)for(let e=n-1;t[e].end.isEqual(o.start);e++)o.start=Qa._createAt(t[e].start);for(let e=n+1;e{if(e.viewPosition)return;const n=this._modelToViewMapping.get(e.modelPosition.parent);e.viewPosition=this.findPositionIn(n,e.modelPosition.offset)}),{priority:"low"}),this.on("viewToModelPosition",((t,e)=>{if(e.modelPosition)return;const n=this.findMappedViewAncestor(e.viewPosition),o=this._viewToModelMapping.get(n),i=this._toModelOffset(e.viewPosition.parent,e.viewPosition.offset,n);e.modelPosition=Qa._createAt(o,i)}),{priority:"low"})}bindElements(t,e){this._modelToViewMapping.set(t,e),this._viewToModelMapping.set(e,t)}unbindViewElement(t){const e=this.toModelElement(t);if(this._viewToModelMapping.delete(t),this._elementToMarkerNames.has(t))for(const e of this._elementToMarkerNames.get(t))this._unboundMarkerNames.add(e);this._modelToViewMapping.get(e)==t&&this._modelToViewMapping.delete(e)}unbindModelElement(t){const e=this.toViewElement(t);this._modelToViewMapping.delete(t),this._viewToModelMapping.get(e)==t&&this._viewToModelMapping.delete(e)}bindElementToMarker(t,e){const n=this._markerNameToElements.get(e)||new Set;n.add(t);const o=this._elementToMarkerNames.get(t)||new Set;o.add(e),this._markerNameToElements.set(e,n),this._elementToMarkerNames.set(t,o)}unbindElementFromMarkerName(t,e){const n=this._markerNameToElements.get(e);n&&(n.delete(t),0==n.size&&this._markerNameToElements.delete(e));const o=this._elementToMarkerNames.get(t);o&&(o.delete(e),0==o.size&&this._elementToMarkerNames.delete(t))}flushUnboundMarkerNames(){const t=Array.from(this._unboundMarkerNames);return this._unboundMarkerNames.clear(),t}clearBindings(){this._modelToViewMapping=new WeakMap,this._viewToModelMapping=new WeakMap,this._markerNameToElements=new Map,this._elementToMarkerNames=new Map,this._unboundMarkerNames=new Set}toModelElement(t){return this._viewToModelMapping.get(t)}toViewElement(t){return this._modelToViewMapping.get(t)}toModelRange(t){return new nc(this.toModelPosition(t.start),this.toModelPosition(t.end))}toViewRange(t){return new Li(this.toViewPosition(t.start),this.toViewPosition(t.end))}toModelPosition(t){const e={viewPosition:t,mapper:this};return this.fire("viewToModelPosition",e),e.modelPosition}toViewPosition(t,e={isPhantom:!1}){const n={modelPosition:t,mapper:this,isPhantom:e.isPhantom};return this.fire("modelToViewPosition",n),n.viewPosition}markerNameToElements(t){const e=this._markerNameToElements.get(t);if(!e)return null;const n=new Set;for(const t of e)if(t.is("attributeElement"))for(const e of t.getElementsWithSameId())n.add(e);else n.add(t);return n}registerViewToModelLength(t,e){this._viewToModelLengthCallbacks.set(t,e)}findMappedViewAncestor(t){let e=t.parent;for(;!this._viewToModelMapping.has(e);)e=e.parent;return e}_toModelOffset(t,e,n){if(n!=t){return this._toModelOffset(t.parent,t.index,n)+this._toModelOffset(t,e,t)}if(t.is("$text"))return e;let o=0;for(let n=0;n1?e[0]+":"+e[1]:e[0]}class sc{constructor(t){this.conversionApi=Object.assign({dispatcher:this},t),this._reconversionEventsMapping=new Map}convertChanges(t,e,n){for(const e of t.getMarkersToRemove())this.convertMarkerRemove(e.name,e.range,n);const o=this._mapChangesWithAutomaticReconversion(t);for(const t of o)"insert"===t.type?this.convertInsert(nc._createFromPositionAndShift(t.position,t.length),n):"remove"===t.type?this.convertRemove(t.position,t.length,t.name,n):"reconvert"===t.type?this.reconvertElement(t.element,n):this.convertAttribute(t.range,t.attributeKey,t.attributeOldValue,t.attributeNewValue,n);for(const t of this.conversionApi.mapper.flushUnboundMarkerNames()){const o=e.get(t).getRange();this.convertMarkerRemove(t,o,n),this.convertMarkerAdd(t,o,n)}for(const e of t.getMarkersToAdd())this.convertMarkerAdd(e.name,e.range,n)}convertInsert(t,e){this.conversionApi.writer=e,this.conversionApi.consumable=this._createInsertConsumable(t);for(const e of Array.from(t).map(cc))this._convertInsertWithAttributes(e);this._clearConversionApi()}convertRemove(t,e,n,o){this.conversionApi.writer=o,this.fire("remove:"+n,{position:t,length:e},this.conversionApi),this._clearConversionApi()}convertAttribute(t,e,n,o,i){this.conversionApi.writer=i,this.conversionApi.consumable=this._createConsumableForRange(t,`attribute:${e}`);for(const i of t){const t={item:i.item,range:nc._createFromPositionAndShift(i.previousPosition,i.length),attributeKey:e,attributeOldValue:n,attributeNewValue:o};this._testAndFire(`attribute:${e}`,t)}this._clearConversionApi()}reconvertElement(t,e){const n=nc._createOn(t);this.conversionApi.writer=e,this.conversionApi.consumable=this._createInsertConsumable(n);const o=this.conversionApi.mapper,i=o.toViewElement(t);e.remove(i),this._convertInsertWithAttributes({item:t,range:n});const r=o.toViewElement(t);for(const n of nc._createIn(t)){const{item:t}=n,i=lc(t,o);i?i.root!==r.root&&e.move(e.createRangeOn(i),o.toViewPosition(Qa._createBefore(t))):this._convertInsertWithAttributes(cc(n))}o.unbindViewElement(i),this._clearConversionApi()}convertSelection(t,e,n){const o=Array.from(e.getMarkersAtPosition(t.getFirstPosition()));if(this.conversionApi.writer=n,this.conversionApi.consumable=this._createSelectionConsumable(t,o),this.fire("selection",{selection:t},this.conversionApi),t.isCollapsed){for(const e of o){const n=e.getRange();if(!ac(t.getFirstPosition(),e,this.conversionApi.mapper))continue;const o={item:t,markerName:e.name,markerRange:n};this.conversionApi.consumable.test(t,"addMarker:"+e.name)&&this.fire("addMarker:"+e.name,o,this.conversionApi)}for(const e of t.getAttributeKeys()){const n={item:t,range:t.getFirstRange(),attributeKey:e,attributeOldValue:null,attributeNewValue:t.getAttribute(e)};this.conversionApi.consumable.test(t,"attribute:"+n.attributeKey)&&this.fire("attribute:"+n.attributeKey+":$text",n,this.conversionApi)}this._clearConversionApi()}else this._clearConversionApi()}convertMarkerAdd(t,e,n){if("$graveyard"==e.root.rootName)return;this.conversionApi.writer=n;const o="addMarker:"+t,i=new ic;if(i.add(e,o),this.conversionApi.consumable=i,this.fire(o,{markerName:t,markerRange:e},this.conversionApi),i.test(e,o)){this.conversionApi.consumable=this._createConsumableForRange(e,o);for(const n of e.getItems()){if(!this.conversionApi.consumable.test(n,o))continue;const i={item:n,range:nc._createOn(n),markerName:t,markerRange:e};this.fire(o,i,this.conversionApi)}this._clearConversionApi()}else this._clearConversionApi()}convertMarkerRemove(t,e,n){"$graveyard"!=e.root.rootName&&(this.conversionApi.writer=n,this.fire("removeMarker:"+t,{markerName:t,markerRange:e},this.conversionApi),this._clearConversionApi())}_mapReconversionTriggerEvent(t,e){this._reconversionEventsMapping.set(e,t)}_createInsertConsumable(t){const e=new ic;for(const n of t){const t=n.item;e.add(t,"insert");for(const n of t.getAttributeKeys())e.add(t,"attribute:"+n)}return e}_createConsumableForRange(t,e){const n=new ic;for(const o of t.getItems())n.add(o,e);return n}_createSelectionConsumable(t,e){const n=new ic;n.add(t,"selection");for(const o of e)n.add(t,"addMarker:"+o.name);for(const e of t.getAttributeKeys())n.add(t,"attribute:"+e);return n}_testAndFire(t,e){this.conversionApi.consumable.test(e.item,t)&&this.fire(function(t,e){const n=e.item.name||"$text";return`${t}:${n}`}(t,e),e,this.conversionApi)}_clearConversionApi(){delete this.conversionApi.writer,delete this.conversionApi.consumable}_convertInsertWithAttributes(t){this._testAndFire("insert",t);for(const e of t.item.getAttributeKeys())t.attributeKey=e,t.attributeOldValue=null,t.attributeNewValue=t.item.getAttribute(e),this._testAndFire(`attribute:${e}`,t)}_mapChangesWithAutomaticReconversion(t){const e=new Set,n=[];for(const o of t.getChanges()){const t=o.position||o.range.start,i=t.parent;if(Xa(t,i)){n.push(o);continue}const r="attribute"===o.type?tc(t,i,null):i;if(r.is("$text")){n.push(o);continue}let s;if(s="attribute"===o.type?`attribute:${o.attributeKey}:${r.name}`:`${o.type}:${o.name}`,this._isReconvertTriggerEvent(s,r.name)){if(e.has(r))continue;e.add(r),n.push({type:"reconvert",element:r})}else n.push(o)}return n}_isReconvertTriggerEvent(t,e){return this._reconversionEventsMapping.get(t)===e}}function ac(t,e,n){const o=e.getRange(),i=Array.from(t.getAncestors());i.shift(),i.reverse();return!i.some((t=>{if(o.containsItem(t)){return!!n.toViewElement(t).getCustomProperty("addHighlight")}}))}function cc(t){return{item:t.item,range:nc._createFromPositionAndShift(t.previousPosition,t.length)}}function lc(t,e){if(t.is("textProxy")){const n=e.toViewPosition(Qa._createBefore(t)).parent;return n.is("$text")?n:null}return e.toViewElement(t)}he(sc,g);class dc{constructor(t,e,n){this._lastRangeBackward=!1,this._ranges=[],this._attrs=new Map,t&&this.setTo(t,e,n)}get anchor(){if(this._ranges.length>0){const t=this._ranges[this._ranges.length-1];return this._lastRangeBackward?t.end:t.start}return null}get focus(){if(this._ranges.length>0){const t=this._ranges[this._ranges.length-1];return this._lastRangeBackward?t.start:t.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(t){if(this.rangeCount!=t.rangeCount)return!1;if(0===this.rangeCount)return!0;if(!this.anchor.isEqual(t.anchor)||!this.focus.isEqual(t.focus))return!1;for(const e of this._ranges){let n=!1;for(const o of t._ranges)if(e.isEqual(o)){n=!0;break}if(!n)return!1}return!0}*getRanges(){for(const t of this._ranges)yield new nc(t.start,t.end)}getFirstRange(){let t=null;for(const e of this._ranges)t&&!e.start.isBefore(t.start)||(t=e);return t?new nc(t.start,t.end):null}getLastRange(){let t=null;for(const e of this._ranges)t&&!e.end.isAfter(t.end)||(t=e);return t?new nc(t.start,t.end):null}getFirstPosition(){const t=this.getFirstRange();return t?t.start.clone():null}getLastPosition(){const t=this.getLastRange();return t?t.end.clone():null}setTo(t,e,n){if(null===t)this._setRanges([]);else if(t instanceof dc)this._setRanges(t.getRanges(),t.isBackward);else if(t&&"function"==typeof t.getRanges)this._setRanges(t.getRanges(),t.isBackward);else if(t instanceof nc)this._setRanges([t],!!e&&!!e.backward);else if(t instanceof Qa)this._setRanges([new nc(t)]);else if(t instanceof Ua){const o=!!n&&!!n.backward;let i;if("in"==e)i=nc._createIn(t);else if("on"==e)i=nc._createOn(t);else{if(void 0===e)throw new s("model-selection-setto-required-second-parameter",[this,t]);i=new nc(Qa._createAt(t,e))}this._setRanges([i],o)}else{if(!Do(t))throw new s("model-selection-setto-not-selectable",[this,t]);this._setRanges(t,e&&!!e.backward)}}_setRanges(t,e=!1){const n=(t=Array.from(t)).some((e=>{if(!(e instanceof nc))throw new s("model-selection-set-ranges-not-range",[this,t]);return this._ranges.every((t=>!t.isEqual(e)))}));if(t.length!==this._ranges.length||n){this._removeAllRanges();for(const e of t)this._pushRange(e);this._lastRangeBackward=!!e,this.fire("change:range",{directChange:!0})}}setFocus(t,e){if(null===this.anchor)throw new s("model-selection-setfocus-no-ranges",[this,t]);const n=Qa._createAt(t,e);if("same"==n.compareWith(this.focus))return;const o=this.anchor;this._ranges.length&&this._popRange(),"before"==n.compareWith(o)?(this._pushRange(new nc(n,o)),this._lastRangeBackward=!0):(this._pushRange(new nc(o,n)),this._lastRangeBackward=!1),this.fire("change:range",{directChange:!0})}getAttribute(t){return this._attrs.get(t)}getAttributes(){return this._attrs.entries()}getAttributeKeys(){return this._attrs.keys()}hasAttribute(t){return this._attrs.has(t)}removeAttribute(t){this.hasAttribute(t)&&(this._attrs.delete(t),this.fire("change:attribute",{attributeKeys:[t],directChange:!0}))}setAttribute(t,e){this.getAttribute(t)!==e&&(this._attrs.set(t,e),this.fire("change:attribute",{attributeKeys:[t],directChange:!0}))}getSelectedElement(){return 1!==this.rangeCount?null:this.getFirstRange().getContainedElement()}is(t){return"selection"===t||"model:selection"===t}*getSelectedBlocks(){const t=new WeakSet;for(const e of this.getRanges()){const n=pc(e.start,t);n&&mc(n,e)&&(yield n);for(const n of e.getWalker()){const o=n.item;"elementEnd"==n.type&&hc(o,t,e)&&(yield o)}const o=pc(e.end,t);o&&!e.end.isTouching(Qa._createAt(o,0))&&mc(o,e)&&(yield o)}}containsEntireContent(t=this.anchor.root){const e=Qa._createAt(t,0),n=Qa._createAt(t,"end");return e.isTouching(this.getFirstPosition())&&n.isTouching(this.getLastPosition())}_pushRange(t){this._checkRange(t),this._ranges.push(new nc(t.start,t.end))}_checkRange(t){for(let e=0;e0;)this._popRange()}_popRange(){this._ranges.pop()}}function uc(t,e){return!e.has(t)&&(e.add(t),t.root.document.model.schema.isBlock(t)&&t.parent)}function hc(t,e,n){return uc(t,e)&&mc(t,n)}function pc(t,e){const n=t.parent.root.document.model.schema,o=t.parent.getAncestors({parentFirst:!0,includeSelf:!0});let i=!1;const r=o.find((t=>!i&&(i=n.isLimit(t),!i&&uc(t,e))));return o.forEach((t=>e.add(t))),r}function mc(t,e){const n=function(t){const e=t.root.document.model.schema;let n=t.parent;for(;n;){if(e.isBlock(n))return n;n=n.parent}}(t);if(!n)return!0;return!e.containsRange(nc._createOn(n),!0)}he(dc,g);class gc extends nc{constructor(t,e){super(t,e),fc.call(this)}detach(){this.stopListening()}is(t){return"liveRange"===t||"model:liveRange"===t||"range"==t||"model:range"===t}toRange(){return new nc(this.start,this.end)}static fromRange(t){return new gc(t.start,t.end)}}function fc(){this.listenTo(this.root.document.model,"applyOperation",((t,e)=>{const n=e[0];n.isDocumentOperation&&bc.call(this,n)}),{priority:"low"})}function bc(t){const e=this.getTransformedByOperation(t),n=nc._createFromRanges(e),o=!n.isEqual(this),i=function(t,e){switch(e.type){case"insert":return t.containsPosition(e.position);case"move":case"remove":case"reinsert":case"merge":return t.containsPosition(e.sourcePosition)||t.start.isEqual(e.sourcePosition)||t.containsPosition(e.targetPosition);case"split":return t.containsPosition(e.splitPosition)||t.containsPosition(e.insertionPosition)}return!1}(this,t);let r=null;if(o){"$graveyard"==n.root.rootName&&(r="remove"==t.type?t.sourcePosition:t.deletionPosition);const e=this.toRange();this.start=n.start,this.end=n.end,this.fire("change:range",e,{deletionPosition:r})}else i&&this.fire("change:content",this.toRange(),{deletionPosition:r})}he(gc,g);const kc="selection:";class wc{constructor(t){this._selection=new _c(t),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(t){return this._selection.containsEntireContent(t)}destroy(){this._selection.destroy()}getAttributeKeys(){return this._selection.getAttributeKeys()}getAttributes(){return this._selection.getAttributes()}getAttribute(t){return this._selection.getAttribute(t)}hasAttribute(t){return this._selection.hasAttribute(t)}refresh(){this._selection._updateMarkers(),this._selection._updateAttributes(!1)}observeMarkers(t){this._selection.observeMarkers(t)}is(t){return"selection"===t||"model:selection"==t||"documentSelection"==t||"model:documentSelection"==t}_setFocus(t,e){this._selection.setFocus(t,e)}_setTo(t,e,n){this._selection.setTo(t,e,n)}_setAttribute(t,e){this._selection.setAttribute(t,e)}_removeAttribute(t){this._selection.removeAttribute(t)}_getStoredAttributes(){return this._selection._getStoredAttributes()}_overrideGravity(){return this._selection.overrideGravity()}_restoreGravity(t){this._selection.restoreGravity(t)}static _getStoreAttributeKey(t){return kc+t}static _isStoreAttributeKey(t){return t.startsWith(kc)}}he(wc,g);class _c extends dc{constructor(t){super(),this.markers=new So({idProperty:"name"}),this._model=t.model,this._document=t,this._attributePriority=new Map,this._selectionRestorePosition=null,this._hasChangedRange=!1,this._overriddenGravityRegister=new Set,this._observedMarkers=new Set,this.listenTo(this._model,"applyOperation",((t,e)=>{const n=e[0];n.isDocumentOperation&&"marker"!=n.type&&"rename"!=n.type&&"noop"!=n.type&&(0==this._ranges.length&&this._selectionRestorePosition&&this._fixGraveyardSelection(this._selectionRestorePosition),this._selectionRestorePosition=null,this._hasChangedRange&&(this._hasChangedRange=!1,this.fire("change:range",{directChange:!1})))}),{priority:"lowest"}),this.on("change:range",(()=>{for(const t of this.getRanges())if(!this._document._validateSelectionRange(t))throw new s("document-selection-wrong-position",this,{range:t})})),this.listenTo(this._model.markers,"update",((t,e,n,o)=>{this._updateMarker(e,o)})),this.listenTo(this._document,"change",((t,e)=>{!function(t,e){const n=t.document.differ;for(const o of n.getChanges()){if("insert"!=o.type)continue;const n=o.position.parent;o.length===n.maxOffset&&t.enqueueChange(e,(t=>{const e=Array.from(n.getAttributeKeys()).filter((t=>t.startsWith(kc)));for(const o of e)t.removeAttribute(o,n)}))}}(this._model,e)}))}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 t=0;t{if(this._hasChangedRange=!0,e.root==this._document.graveyard){this._selectionRestorePosition=o.deletionPosition;const t=this._ranges.indexOf(e);this._ranges.splice(t,1),e.detach()}})),e}_updateMarkers(){if(!this._observedMarkers.size)return;const t=[];let e=!1;for(const e of this._model.markers){const n=e.name.split(":",1)[0];if(!this._observedMarkers.has(n))continue;const o=e.getRange();for(const n of this.getRanges())o.containsRange(n,!n.isCollapsed)&&t.push(e)}const n=Array.from(this.markers);for(const n of t)this.markers.has(n)||(this.markers.add(n),e=!0);for(const n of Array.from(this.markers))t.includes(n)||(this.markers.remove(n),e=!0);e&&this.fire("change:marker",{oldMarkers:n,directChange:!1})}_updateMarker(t,e){const n=t.name.split(":",1)[0];if(!this._observedMarkers.has(n))return;let o=!1;const i=Array.from(this.markers),r=this.markers.has(t);if(e){let n=!1;for(const t of this.getRanges())if(e.containsRange(t,!t.isCollapsed)){n=!0;break}n&&!r?(this.markers.add(t),o=!0):!n&&r&&(this.markers.remove(t),o=!0)}else r&&(this.markers.remove(t),o=!0);o&&this.fire("change:marker",{oldMarkers:i,directChange:!1})}_updateAttributes(t){const e=qo(this._getSurroundingAttributes()),n=qo(this.getAttributes());if(t)this._attributePriority=new Map,this._attrs=new Map;else for(const[t,e]of this._attributePriority)"low"==e&&(this._attrs.delete(t),this._attributePriority.delete(t));this._setAttributesTo(e);const o=[];for(const[t,e]of this.getAttributes())n.has(t)&&n.get(t)===e||o.push(t);for(const[t]of n)this.hasAttribute(t)||o.push(t);o.length>0&&this.fire("change:attribute",{attributeKeys:o,directChange:!1})}_setAttribute(t,e,n=!0){const o=n?"normal":"low";if("low"==o&&"normal"==this._attributePriority.get(t))return!1;return super.getAttribute(t)!==e&&(this._attrs.set(t,e),this._attributePriority.set(t,o),!0)}_removeAttribute(t,e=!0){const n=e?"normal":"low";return("low"!=n||"normal"!=this._attributePriority.get(t))&&(this._attributePriority.set(t,n),!!super.hasAttribute(t)&&(this._attrs.delete(t),!0))}_setAttributesTo(t){const e=new Set;for(const[e,n]of this.getAttributes())t.get(e)!==n&&this._removeAttribute(e,!1);for(const[n,o]of t){this._setAttribute(n,o,!1)&&e.add(n)}return e}*_getStoredAttributes(){const t=this.getFirstPosition().parent;if(this.isCollapsed&&t.isEmpty)for(const e of t.getAttributeKeys())if(e.startsWith(kc)){const n=e.substr(kc.length);yield[n,t.getAttribute(e)]}}_getSurroundingAttributes(){const t=this.getFirstPosition(),e=this._model.schema;let n=null;if(this.isCollapsed){const o=t.textNode?t.textNode:t.nodeBefore,i=t.textNode?t.textNode:t.nodeAfter;if(this.isGravityOverridden||(n=Cc(o)),n||(n=Cc(i)),!this.isGravityOverridden&&!n){let t=o;for(;t&&!e.isInline(t)&&!n;)t=t.previousSibling,n=Cc(t)}if(!n){let t=i;for(;t&&!e.isInline(t)&&!n;)t=t.nextSibling,n=Cc(t)}n||(n=this._getStoredAttributes())}else{const t=this.getFirstRange();for(const o of t){if(o.item.is("element")&&e.isObject(o.item))break;if("text"==o.type){n=o.item.getAttributes();break}}}return n}_fixGraveyardSelection(t){const e=this._model.schema.getNearestSelectionRange(t);e&&this._pushRange(e)}}function Cc(t){return t instanceof Ga||t instanceof $a?t.getAttributes():null}class Ac{constructor(t){this._dispatchers=t}add(t){for(const e of this._dispatchers)t(e);return this}}const vc=function(t){return Co(t,5)};class yc extends Ac{elementToElement(t){return this.add(function(t){return(t=vc(t)).view=Dc(t.view,"container"),e=>{var n;if(e.on("insert:"+t.model,(n=t.view,(t,e,o)=>{const i=n(e.item,o);if(!i)return;if(!o.consumable.consume(e.item,"insert"))return;const r=o.mapper.toViewPosition(e.range.start);o.mapper.bindElements(e.item,i),o.writer.insert(r,i)}),{priority:t.converterPriority||"normal"}),t.triggerBy){if(t.triggerBy.attributes)for(const n of t.triggerBy.attributes)e._mapReconversionTriggerEvent(t.model,`attribute:${n}:${t.model}`);if(t.triggerBy.children)for(const n of t.triggerBy.children)e._mapReconversionTriggerEvent(t.model,`insert:${n}`),e._mapReconversionTriggerEvent(t.model,`remove:${n}`)}}}(t))}attributeToElement(t){return this.add(function(t){t=vc(t);let e="attribute:"+(t.model.key?t.model.key:t.model);t.model.name&&(e+=":"+t.model.name);if(t.model.values)for(const e of t.model.values)t.view[e]=Dc(t.view[e],"attribute");else t.view=Dc(t.view,"attribute");const n=Sc(t);return o=>{o.on(e,function(t){return(e,n,o)=>{const i=t(n.attributeOldValue,o),r=t(n.attributeNewValue,o);if(!i&&!r)return;if(!o.consumable.consume(n.item,e.name))return;const s=o.writer,a=s.document.selection;if(n.item instanceof dc||n.item instanceof wc)s.wrap(a.getFirstRange(),r);else{let t=o.mapper.toViewRange(n.range);null!==n.attributeOldValue&&i&&(t=s.unwrap(t,i)),null!==n.attributeNewValue&&r&&s.wrap(t,r)}}}(n),{priority:t.converterPriority||"normal"})}}(t))}attributeToAttribute(t){return this.add(function(t){t=vc(t);let e="attribute:"+(t.model.key?t.model.key:t.model);t.model.name&&(e+=":"+t.model.name);if(t.model.values)for(const e of t.model.values)t.view[e]=Bc(t.view[e]);else t.view=Bc(t.view);const n=Sc(t);return o=>{var i;o.on(e,(i=n,(t,e,n)=>{const o=i(e.attributeOldValue,n),r=i(e.attributeNewValue,n);if(!o&&!r)return;if(!n.consumable.consume(e.item,t.name))return;const a=n.mapper.toViewElement(e.item),c=n.writer;if(!a)throw new s("conversion-attribute-to-attribute-on-text",[e,n]);if(null!==e.attributeOldValue&&o)if("class"==o.key){const t=To(o.value);for(const e of t)c.removeClass(e,a)}else if("style"==o.key){const t=Object.keys(o.value);for(const e of t)c.removeStyle(e,a)}else c.removeAttribute(o.key,a);if(null!==e.attributeNewValue&&r)if("class"==r.key){const t=To(r.value);for(const e of t)c.addClass(e,a)}else if("style"==r.key){const t=Object.keys(r.value);for(const e of t)c.setStyle(e,r.value[e],a)}else c.setAttribute(r.key,r.value,a)}),{priority:t.converterPriority||"normal"})}}(t))}markerToElement(t){return this.add(function(t){return(t=vc(t)).view=Dc(t.view,"ui"),e=>{var n;e.on("addMarker:"+t.model,(n=t.view,(t,e,o)=>{e.isOpening=!0;const i=n(e,o);e.isOpening=!1;const r=n(e,o);if(!i||!r)return;const s=e.markerRange;if(s.isCollapsed&&!o.consumable.consume(s,t.name))return;for(const e of s)if(!o.consumable.consume(e.item,t.name))return;const a=o.mapper,c=o.writer;c.insert(a.toViewPosition(s.start),i),o.mapper.bindElementToMarker(i,e.markerName),s.isCollapsed||(c.insert(a.toViewPosition(s.end),r),o.mapper.bindElementToMarker(r,e.markerName)),t.stop()}),{priority:t.converterPriority||"normal"}),e.on("removeMarker:"+t.model,(t.view,(t,e,n)=>{const o=n.mapper.markerNameToElements(e.markerName);if(o){for(const t of o)n.mapper.unbindElementFromMarkerName(t,e.markerName),n.writer.clear(n.writer.createRangeOn(t),t);n.writer.clearClonedElementsGroup(e.markerName),t.stop()}}),{priority:t.converterPriority||"normal"})}}(t))}markerToHighlight(t){return this.add(function(t){return e=>{var n;e.on("addMarker:"+t.model,(n=t.view,(t,e,o)=>{if(!e.item)return;if(!(e.item instanceof dc||e.item instanceof wc||e.item.is("$textProxy")))return;const i=Tc(n,e,o);if(!i)return;if(!o.consumable.consume(e.item,t.name))return;const r=o.writer,s=xc(r,i),a=r.document.selection;if(e.item instanceof dc||e.item instanceof wc)r.wrap(a.getFirstRange(),s,a);else{const t=o.mapper.toViewRange(e.range),n=r.wrap(t,s);for(const t of n.getItems())if(t.is("attributeElement")&&t.isSimilar(s)){o.mapper.bindElementToMarker(t,e.markerName);break}}}),{priority:t.converterPriority||"normal"}),e.on("addMarker:"+t.model,function(t){return(e,n,o)=>{if(!n.item)return;if(!(n.item instanceof Za))return;const i=Tc(t,n,o);if(!i)return;if(!o.consumable.test(n.item,e.name))return;const r=o.mapper.toViewElement(n.item);if(r&&r.getCustomProperty("addHighlight")){o.consumable.consume(n.item,e.name);for(const t of nc._createIn(n.item))o.consumable.consume(t.item,e.name);r.getCustomProperty("addHighlight")(r,i,o.writer),o.mapper.bindElementToMarker(r,n.markerName)}}}(t.view),{priority:t.converterPriority||"normal"}),e.on("removeMarker:"+t.model,function(t){return(e,n,o)=>{if(n.markerRange.isCollapsed)return;const i=Tc(t,n,o);if(!i)return;const r=xc(o.writer,i),s=o.mapper.markerNameToElements(n.markerName);if(s){for(const t of s)o.mapper.unbindElementFromMarkerName(t,n.markerName),t.is("attributeElement")?o.writer.unwrap(o.writer.createRangeOn(t),r):t.getCustomProperty("removeHighlight")(t,i.id,o.writer);o.writer.clearClonedElementsGroup(n.markerName),e.stop()}}}(t.view),{priority:t.converterPriority||"normal"})}}(t))}markerToData(t){return this.add(function(t){const e=(t=vc(t)).model;t.view||(t.view=n=>({group:e,name:n.substr(t.model.length+1)}));return n=>{var o;n.on("addMarker:"+e,(o=t.view,(t,e,n)=>{const i=o(e.markerName,n);if(!i)return;const r=e.markerRange;n.consumable.consume(r,t.name)&&(Ec(r,!1,n,e,i),Ec(r,!0,n,e,i),t.stop())}),{priority:t.converterPriority||"normal"}),n.on("removeMarker:"+e,function(t){return(e,n,o)=>{const i=t(n.markerName,o);if(!i)return;const r=o.mapper.markerNameToElements(n.markerName);if(r){for(const t of r)o.mapper.unbindElementFromMarkerName(t,n.markerName),t.is("containerElement")?(s(`data-${i.group}-start-before`,t),s(`data-${i.group}-start-after`,t),s(`data-${i.group}-end-before`,t),s(`data-${i.group}-end-after`,t)):o.writer.clear(o.writer.createRangeOn(t),t);o.writer.clearClonedElementsGroup(n.markerName),e.stop()}function s(t,e){if(e.hasAttribute(t)){const n=new Set(e.getAttribute(t).split(","));n.delete(i.name),0==n.size?o.writer.removeAttribute(t,e):o.writer.setAttribute(t,Array.from(n).join(","),e)}}}}(t.view),{priority:t.converterPriority||"normal"})}}(t))}}function xc(t,e){const n=t.createAttributeElement("span",e.attributes);return e.classes&&n._addClass(e.classes),"number"==typeof e.priority&&(n._priority=e.priority),n._id=e.id,n}function Ec(t,e,n,o,i){const r=e?t.start:t.end,s=r.nodeAfter&&r.nodeAfter.is("element")?r.nodeAfter:null,a=r.nodeBefore&&r.nodeBefore.is("element")?r.nodeBefore:null;if(s||a){let t,r;e&&s||!e&&!a?(t=s,r=!0):(t=a,r=!1);const c=n.mapper.toViewElement(t);if(c)return void function(t,e,n,o,i,r){const s=`data-${r.group}-${e?"start":"end"}-${n?"before":"after"}`,a=t.hasAttribute(s)?t.getAttribute(s).split(","):[];a.unshift(r.name),o.writer.setAttribute(s,a.join(","),t),o.mapper.bindElementToMarker(t,i.markerName)}(c,e,r,n,o,i)}!function(t,e,n,o,i){const r=`${i.group}-${e?"start":"end"}`,s=i.name?{name:i.name}:null,a=n.writer.createUIElement(r,s);n.writer.insert(t,a),n.mapper.bindElementToMarker(a,o.markerName)}(n.mapper.toViewPosition(r),e,n,o,i)}function Dc(t,e){return"function"==typeof t?t:(n,o)=>function(t,e,n){"string"==typeof t&&(t={name:t});let o;const i=e.writer,r=Object.assign({},t.attributes);if("container"==n)o=i.createContainerElement(t.name,r);else if("attribute"==n){const e={priority:t.priority||tr.DEFAULT_PRIORITY};o=i.createAttributeElement(t.name,r,e)}else o=i.createUIElement(t.name,r);if(t.styles){const e=Object.keys(t.styles);for(const n of e)i.setStyle(n,t.styles[n],o)}if(t.classes){const e=t.classes;if("string"==typeof e)i.addClass(e,o);else for(const t of e)i.addClass(t,o)}return o}(t,o,e)}function Sc(t){return t.model.values?(e,n)=>{const o=t.view[e];return o?o(e,n):null}:t.view}function Bc(t){return"string"==typeof t?e=>({key:t,value:e}):"object"==typeof t?t.value?()=>t:e=>({key:t.key,value:e}):t}function Tc(t,e,n){const o="function"==typeof t?t(e,n):t;return o?(o.priority||(o.priority=10),o.id||(o.id=e.markerName),o):null}function Pc(t){const{schema:e,document:n}=t.model;for(const o of n.getRootNames()){const i=n.getRoot(o);if(i.isEmpty&&!e.checkChild(i,"$text")&&e.checkChild(i,"paragraph"))return t.insertElement("paragraph",i),!0}return!1}function Ic(t,e,n){const o=n.createContext(t);return!!n.checkChild(o,"paragraph")&&!!n.checkChild(o.push("paragraph"),e)}function Rc(t,e){const n=e.createElement("paragraph");return e.insert(n,t),e.createPositionAt(n,0)}class zc extends Ac{elementToElement(t){return this.add(Fc(t))}elementToAttribute(t){return this.add(function(t){Mc(t=vc(t));const e=Vc(t,!1),n=Nc(t.view),o=n?"element:"+n:"element";return n=>{n.on(o,e,{priority:t.converterPriority||"low"})}}(t))}attributeToAttribute(t){return this.add(function(t){t=vc(t);let e=null;("string"==typeof t.view||t.view.key)&&(e=function(t){"string"==typeof t.view&&(t.view={key:t.view});const e=t.view.key;let n;if("class"==e||"style"==e){n={["class"==e?"classes":"styles"]:t.view.value}}else{n={attributes:{[e]:void 0===t.view.value?/[\s\S]*/:t.view.value}}}t.view.name&&(n.name=t.view.name);return t.view=n,e}(t));Mc(t,e);const n=Vc(t,!0);return e=>{e.on("element",n,{priority:t.converterPriority||"low"})}}(t))}elementToMarker(t){return this.add(function(t){return function(t){const e=t.model;t.model=(t,n)=>{const o="string"==typeof e?e:e(t,n);return n.writer.createElement("$marker",{"data-name":o})}}(t=vc(t)),Fc(t)}(t))}dataToMarker(t){return this.add(function(t){(t=vc(t)).model||(t.model=e=>e?t.view+":"+e:t.view);const e=Oc(Lc(t,"start")),n=Oc(Lc(t,"end"));return o=>{o.on("element:"+t.view+"-start",e,{priority:t.converterPriority||"normal"}),o.on("element:"+t.view+"-end",n,{priority:t.converterPriority||"normal"});const i=r.get("low"),s=r.get("highest"),a=r.get(t.converterPriority)/s;o.on("element",function(t){return(e,n,o)=>{const i=`data-${t.view}`;function r(e,i){for(const r of i){const i=t.model(r,o),s=o.writer.createElement("$marker",{"data-name":i});o.writer.insert(s,e),n.modelCursor.isEqual(e)?n.modelCursor=n.modelCursor.getShiftedBy(1):n.modelCursor=n.modelCursor._getTransformedByInsertion(e,1),n.modelRange=n.modelRange._getTransformedByInsertion(e,1)[0]}}(o.consumable.test(n.viewItem,{attributes:i+"-end-after"})||o.consumable.test(n.viewItem,{attributes:i+"-start-after"})||o.consumable.test(n.viewItem,{attributes:i+"-end-before"})||o.consumable.test(n.viewItem,{attributes:i+"-start-before"}))&&(n.modelRange||Object.assign(n,o.convertChildren(n.viewItem,n.modelCursor)),o.consumable.consume(n.viewItem,{attributes:i+"-end-after"})&&r(n.modelRange.end,n.viewItem.getAttribute(i+"-end-after").split(",")),o.consumable.consume(n.viewItem,{attributes:i+"-start-after"})&&r(n.modelRange.end,n.viewItem.getAttribute(i+"-start-after").split(",")),o.consumable.consume(n.viewItem,{attributes:i+"-end-before"})&&r(n.modelRange.start,n.viewItem.getAttribute(i+"-end-before").split(",")),o.consumable.consume(n.viewItem,{attributes:i+"-start-before"})&&r(n.modelRange.start,n.viewItem.getAttribute(i+"-start-before").split(",")))}}(t),{priority:i+a})}}(t))}}function Fc(t){const e=Oc(t=vc(t)),n=Nc(t.view),o=n?"element:"+n:"element";return n=>{n.on(o,e,{priority:t.converterPriority||"normal"})}}function Nc(t){return"string"==typeof t?t:"object"==typeof t&&"string"==typeof t.name?t.name:null}function Oc(t){const e=new Wo(t.view);return(n,o,i)=>{const r=e.match(o.viewItem);if(!r)return;const s=r.match;if(s.name=!0,!i.consumable.test(o.viewItem,s))return;const a=function(t,e,n){return t instanceof Function?t(e,n):n.writer.createElement(t)}(t.model,o.viewItem,i);a&&i.safeInsert(a,o.modelCursor)&&(i.consumable.consume(o.viewItem,s),i.convertChildren(o.viewItem,a),i.updateConversionResult(a,o))}}function Mc(t,e=null){const n=null===e||(t=>t.getAttribute(e)),o="object"!=typeof t.model?t.model:t.model.key,i="object"!=typeof t.model||void 0===t.model.value?n:t.model.value;t.model={key:o,value:i}}function Vc(t,e){const n=new Wo(t.view);return(o,i,r)=>{const s=n.match(i.viewItem);if(!s)return;if(!function(t,e){const n="function"==typeof t?t(e):t;if("object"==typeof n&&!Nc(n))return!1;return!n.classes&&!n.attributes&&!n.styles}(t.view,i.viewItem)?delete s.match.name:s.match.name=!0,!r.consumable.test(i.viewItem,s.match))return;const a=t.model.key,c="function"==typeof t.model.value?t.model.value(i.viewItem,r):t.model.value;if(null===c)return;i.modelRange||Object.assign(i,r.convertChildren(i.viewItem,i.modelCursor));const l=function(t,e,n,o){let i=!1;for(const r of Array.from(t.getItems({shallow:n})))o.schema.checkAttribute(r,e.key)&&(i=!0,r.hasAttribute(e.key)||o.writer.setAttribute(e.key,e.value,r));return i}(i.modelRange,{key:a,value:c},e,r);l&&r.consumable.consume(i.viewItem,s.match)}}function Lc(t,e){const n={};return n.view=t.view+"-"+e,n.model=(e,n)=>{const o=e.getAttribute("name"),i=t.model(o,n);return n.writer.createElement("$marker",{"data-name":i})},n}class Hc{constructor(t,e){this.model=t,this.view=new ja(e),this.mapper=new oc,this.downcastDispatcher=new sc({mapper:this.mapper,schema:t.schema});const n=this.model.document,o=n.selection,i=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(n,"change",(()=>{this.view.change((t=>{this.downcastDispatcher.convertChanges(n.differ,i,t),this.downcastDispatcher.convertSelection(o,i,t)}))}),{priority:"low"}),this.listenTo(this.view.document,"selectionChange",function(t,e){return(n,o)=>{const i=o.newSelection,r=[];for(const t of i.getRanges())r.push(e.toModelRange(t));const s=t.createSelection(r,{backward:i.isBackward});s.isEqual(t.document.selection)||t.change((t=>{t.setSelection(s)}))}}(this.model,this.mapper)),this.downcastDispatcher.on("insert:$text",((t,e,n)=>{if(!n.consumable.consume(e.item,"insert"))return;const o=n.writer,i=n.mapper.toViewPosition(e.range.start),r=o.createText(e.item.data);o.insert(i,r)}),{priority:"lowest"}),this.downcastDispatcher.on("remove",((t,e,n)=>{const o=n.mapper.toViewPosition(e.position),i=e.position.getShiftedBy(e.length),r=n.mapper.toViewPosition(i,{isPhantom:!0}),s=n.writer.createRange(o,r),a=n.writer.remove(s.getTrimmed());for(const t of n.writer.createRangeIn(a).getItems())n.mapper.unbindViewElement(t)}),{priority:"low"}),this.downcastDispatcher.on("selection",((t,e,n)=>{const o=n.writer,i=o.document.selection;for(const t of i.getRanges())t.isCollapsed&&t.end.parent.isAttached()&&n.writer.mergeAttributes(t.start);o.setSelection(null)}),{priority:"high"}),this.downcastDispatcher.on("selection",((t,e,n)=>{const o=e.selection;if(o.isCollapsed)return;if(!n.consumable.consume(o,"selection"))return;const i=[];for(const t of o.getRanges()){const e=n.mapper.toViewRange(t);i.push(e)}n.writer.setSelection(i,{backward:o.isBackward})}),{priority:"low"}),this.downcastDispatcher.on("selection",((t,e,n)=>{const o=e.selection;if(!o.isCollapsed)return;if(!n.consumable.consume(o,"selection"))return;const i=n.writer,r=o.getFirstPosition(),s=n.mapper.toViewPosition(r),a=i.breakAttributes(s);i.setSelection(a)}),{priority:"low"}),this.view.document.roots.bindTo(this.model.document.roots).using((t=>{if("$graveyard"==t.rootName)return null;const e=new Oi(this.view.document,t.name);return e.rootName=t.rootName,this.mapper.bindElements(t,e),e}))}destroy(){this.view.destroy(),this.stopListening()}}he(Hc,se);class qc{constructor(){this._commands=new Map}add(t,e){this._commands.set(t,e)}get(t){return this._commands.get(t)}execute(t,...e){const n=this.get(t);if(!n)throw new s("commandcollection-command-not-found",this,{commandName:t});return n.execute(...e)}*names(){yield*this._commands.keys()}*commands(){yield*this._commands.values()}[Symbol.iterator](){return this._commands[Symbol.iterator]()}destroy(){for(const t of this.commands())t.destroy()}}class Wc{constructor(){this._consumables=new Map}add(t,e){let n;t.is("$text")||t.is("documentFragment")?this._consumables.set(t,!0):(this._consumables.has(t)?n=this._consumables.get(t):(n=new jc(t),this._consumables.set(t,n)),n.add(e))}test(t,e){const n=this._consumables.get(t);return void 0===n?null:t.is("$text")||t.is("documentFragment")?n:n.test(e)}consume(t,e){return!!this.test(t,e)&&(t.is("$text")||t.is("documentFragment")?this._consumables.set(t,!1):this._consumables.get(t).consume(e),!0)}revert(t,e){const n=this._consumables.get(t);void 0!==n&&(t.is("$text")||t.is("documentFragment")?this._consumables.set(t,!0):n.revert(e))}static consumablesFromElement(t){const e={element:t,name:!0,attributes:[],classes:[],styles:[]},n=t.getAttributeKeys();for(const t of n)"style"!=t&&"class"!=t&&e.attributes.push(t);const o=t.getClassNames();for(const t of o)e.classes.push(t);const i=t.getStyleNames();for(const t of i)e.styles.push(t);return e}static createFrom(t,e){if(e||(e=new Wc(t)),t.is("$text"))return e.add(t),e;t.is("element")&&e.add(t,Wc.consumablesFromElement(t)),t.is("documentFragment")&&e.add(t);for(const n of t.getChildren())e=Wc.createFrom(n,e);return e}}class jc{constructor(t){this.element=t,this._canConsumeName=null,this._consumables={attributes:new Map,styles:new Map,classes:new Map}}add(t){t.name&&(this._canConsumeName=!0);for(const e in this._consumables)e in t&&this._add(e,t[e])}test(t){if(t.name&&!this._canConsumeName)return this._canConsumeName;for(const e in this._consumables)if(e in t){const n=this._test(e,t[e]);if(!0!==n)return n}return!0}consume(t){t.name&&(this._canConsumeName=!1);for(const e in this._consumables)e in t&&this._consume(e,t[e])}revert(t){t.name&&(this._canConsumeName=!0);for(const e in this._consumables)e in t&&this._revert(e,t[e])}_add(t,e){const n=Bt(e)?e:[e],o=this._consumables[t];for(const e of n){if("attributes"===t&&("class"===e||"style"===e))throw new s("viewconsumable-invalid-attribute",this);if(o.set(e,!0),"styles"===t)for(const t of this.element.document.stylesProcessor.getRelatedStyles(e))o.set(t,!0)}}_test(t,e){const n=Bt(e)?e:[e],o=this._consumables[t];for(const e of n)if("attributes"!==t||"class"!==e&&"style"!==e){const t=o.get(e);if(void 0===t)return null;if(!t)return!1}else{const t="class"==e?"classes":"styles",n=this._test(t,[...this._consumables[t].keys()]);if(!0!==n)return n}return!0}_consume(t,e){const n=Bt(e)?e:[e],o=this._consumables[t];for(const e of n)if("attributes"!==t||"class"!==e&&"style"!==e){if(o.set(e,!1),"styles"==t)for(const t of this.element.document.stylesProcessor.getRelatedStyles(e))o.set(t,!1)}else{const t="class"==e?"classes":"styles";this._consume(t,[...this._consumables[t].keys()])}}_revert(t,e){const n=Bt(e)?e:[e],o=this._consumables[t];for(const e of n)if("attributes"!==t||"class"!==e&&"style"!==e){!1===o.get(e)&&o.set(e,!0)}else{const t="class"==e?"classes":"styles";this._revert(t,[...this._consumables[t].keys()])}}}class Uc{constructor(){this._sourceDefinitions={},this._attributeProperties={},this.decorate("checkChild"),this.decorate("checkAttribute"),this.on("checkAttribute",((t,e)=>{e[0]=new $c(e[0])}),{priority:"highest"}),this.on("checkChild",((t,e)=>{e[0]=new $c(e[0]),e[1]=this.getDefinition(e[1])}),{priority:"highest"})}register(t,e){if(this._sourceDefinitions[t])throw new s("schema-cannot-register-item-twice",this,{itemName:t});this._sourceDefinitions[t]=[Object.assign({},e)],this._clearCache()}extend(t,e){if(!this._sourceDefinitions[t])throw new s("schema-cannot-extend-missing-item",this,{itemName:t});this._sourceDefinitions[t].push(Object.assign({},e)),this._clearCache()}getDefinitions(){return this._compiledDefinitions||this._compile(),this._compiledDefinitions}getDefinition(t){let e;return e="string"==typeof t?t:t.is&&(t.is("$text")||t.is("$textProxy"))?"$text":t.name,this.getDefinitions()[e]}isRegistered(t){return!!this.getDefinition(t)}isBlock(t){const e=this.getDefinition(t);return!(!e||!e.isBlock)}isLimit(t){const e=this.getDefinition(t);return!!e&&!(!e.isLimit&&!e.isObject)}isObject(t){const e=this.getDefinition(t);return!!e&&!!(e.isObject||e.isLimit&&e.isSelectable&&e.isContent)}isInline(t){const e=this.getDefinition(t);return!(!e||!e.isInline)}isSelectable(t){const e=this.getDefinition(t);return!!e&&!(!e.isSelectable&&!e.isObject)}isContent(t){const e=this.getDefinition(t);return!!e&&!(!e.isContent&&!e.isObject)}checkChild(t,e){return!!e&&this._checkContextMatch(e,t)}checkAttribute(t,e){const n=this.getDefinition(t.last);return!!n&&n.allowAttributes.includes(e)}checkMerge(t,e=null){if(t instanceof Qa){const e=t.nodeBefore,n=t.nodeAfter;if(!(e instanceof Za))throw new s("schema-check-merge-no-element-before",this);if(!(n instanceof Za))throw new s("schema-check-merge-no-element-after",this);return this.checkMerge(e,n)}for(const n of e.getChildren())if(!this.checkChild(t,n))return!1;return!0}addChildCheck(t){this.on("checkChild",((e,[n,o])=>{if(!o)return;const i=t(n,o);"boolean"==typeof i&&(e.stop(),e.return=i)}),{priority:"high"})}addAttributeCheck(t){this.on("checkAttribute",((e,[n,o])=>{const i=t(n,o);"boolean"==typeof i&&(e.stop(),e.return=i)}),{priority:"high"})}setAttributeProperties(t,e){this._attributeProperties[t]=Object.assign(this.getAttributeProperties(t),e)}getAttributeProperties(t){return this._attributeProperties[t]||{}}getLimitElement(t){let e;if(t instanceof Qa)e=t.parent;else{e=(t instanceof nc?[t]:Array.from(t.getRanges())).reduce(((t,e)=>{const n=e.getCommonAncestor();return t?t.getCommonAncestor(n,{includeSelf:!0}):n}),null)}for(;!this.isLimit(e)&&e.parent;)e=e.parent;return e}checkAttributeInSelection(t,e){if(t.isCollapsed){const n=[...t.getFirstPosition().getAncestors(),new $a("",t.getAttributes())];return this.checkAttribute(n,e)}{const n=t.getRanges();for(const t of n)for(const n of t)if(this.checkAttribute(n.item,e))return!0}return!1}*getValidRanges(t,e){t=function*(t){for(const e of t)yield*e.getMinimalFlatRanges()}(t);for(const n of t)yield*this._getValidRangesForRange(n,e)}getNearestSelectionRange(t,e="both"){if(this.checkChild(t,"$text"))return new nc(t);let n,o;const i=t.getAncestors().reverse().find((t=>this.isLimit(t)))||t.root;"both"!=e&&"backward"!=e||(n=new Ja({boundaries:nc._createIn(i),startPosition:t,direction:"backward"})),"both"!=e&&"forward"!=e||(o=new Ja({boundaries:nc._createIn(i),startPosition:t}));for(const t of function*(t,e){let n=!1;for(;!n;){if(n=!0,t){const e=t.next();e.done||(n=!1,yield{walker:t,value:e.value})}if(e){const t=e.next();t.done||(n=!1,yield{walker:e,value:t.value})}}}(n,o)){const e=t.walker==n?"elementEnd":"elementStart",o=t.value;if(o.type==e&&this.isObject(o.item))return nc._createOn(o.item);if(this.checkChild(o.nextPosition,"$text"))return new nc(o.nextPosition)}return null}findAllowedParent(t,e){let n=t.parent;for(;n;){if(this.checkChild(n,e))return n;if(this.isLimit(n))return null;n=n.parent}return null}removeDisallowedAttributes(t,e){for(const n of t)if(n.is("$text"))rl(this,n,e);else{const t=nc._createIn(n).getPositions();for(const n of t){rl(this,n.nodeBefore||n.parent,e)}}}createContext(t){return new $c(t)}_clearCache(){this._compiledDefinitions=null}_compile(){const t={},e=this._sourceDefinitions,n=Object.keys(e);for(const o of n)t[o]=Gc(e[o],o);for(const e of n)Kc(t,e);for(const e of n)Zc(t,e);for(const e of n)Jc(t,e);for(const e of n)Yc(t,e),Qc(t,e);for(const e of n)Xc(t,e),tl(t,e),el(t,e);this._compiledDefinitions=t}_checkContextMatch(t,e,n=e.length-1){const o=e.getItem(n);if(t.allowIn.includes(o.name)){if(0==n)return!0;{const t=this.getDefinition(o);return this._checkContextMatch(t,e,n-1)}}return!1}*_getValidRangesForRange(t,e){let n=t.start,o=t.start;for(const i of t.getItems({shallow:!0}))i.is("element")&&(yield*this._getValidRangesForRange(nc._createIn(i),e)),this.checkAttribute(i,e)||(n.isEqual(o)||(yield new nc(n,o)),n=Qa._createAfter(i)),o=Qa._createAfter(i);n.isEqual(o)||(yield new nc(n,o))}}he(Uc,se);class $c{constructor(t){if(t instanceof $c)return t;"string"==typeof t?t=[t]:Array.isArray(t)||(t=t.getAncestors({includeSelf:!0})),this._items=t.map(il)}get length(){return this._items.length}get last(){return this._items[this._items.length-1]}[Symbol.iterator](){return this._items[Symbol.iterator]()}push(t){const e=new $c([t]);return e._items=[...this._items,...e._items],e}getItem(t){return this._items[t]}*getNames(){yield*this._items.map((t=>t.name))}endsWith(t){return Array.from(this.getNames()).join(" ").endsWith(t)}startsWith(t){return Array.from(this.getNames()).join(" ").startsWith(t)}}function Gc(t,e){const n={name:e,allowIn:[],allowContentOf:[],allowWhere:[],allowAttributes:[],allowAttributesOf:[],allowChildren:[],inheritTypesFrom:[]};return function(t,e){for(const n of t){const t=Object.keys(n).filter((t=>t.startsWith("is")));for(const o of t)e[o]=n[o]}}(t,n),nl(t,n,"allowIn"),nl(t,n,"allowContentOf"),nl(t,n,"allowWhere"),nl(t,n,"allowAttributes"),nl(t,n,"allowAttributesOf"),nl(t,n,"allowChildren"),nl(t,n,"inheritTypesFrom"),function(t,e){for(const n of t){const t=n.inheritAllFrom;t&&(e.allowContentOf.push(t),e.allowWhere.push(t),e.allowAttributesOf.push(t),e.inheritTypesFrom.push(t))}}(t,n),n}function Kc(t,e){const n=t[e];for(const o of n.allowChildren){const n=t[o];n&&n.allowIn.push(e)}n.allowChildren.length=0}function Zc(t,e){for(const n of t[e].allowContentOf)if(t[n]){ol(t,n).forEach((t=>{t.allowIn.push(e)}))}delete t[e].allowContentOf}function Jc(t,e){for(const n of t[e].allowWhere){const o=t[n];if(o){const n=o.allowIn;t[e].allowIn.push(...n)}}delete t[e].allowWhere}function Yc(t,e){for(const n of t[e].allowAttributesOf){const o=t[n];if(o){const n=o.allowAttributes;t[e].allowAttributes.push(...n)}}delete t[e].allowAttributesOf}function Qc(t,e){const n=t[e];for(const e of n.inheritTypesFrom){const o=t[e];if(o){const t=Object.keys(o).filter((t=>t.startsWith("is")));for(const e of t)e in n||(n[e]=o[e])}}delete n.inheritTypesFrom}function Xc(t,e){const n=t[e],o=n.allowIn.filter((e=>t[e]));n.allowIn=Array.from(new Set(o))}function tl(t,e){const n=t[e];for(const o of n.allowIn){t[o].allowChildren.push(e)}}function el(t,e){const n=t[e];n.allowAttributes=Array.from(new Set(n.allowAttributes))}function nl(t,e,n){for(const o of t)"string"==typeof o[n]?e[n].push(o[n]):Array.isArray(o[n])&&e[n].push(...o[n])}function ol(t,e){const n=t[e];return(o=t,Object.keys(o).map((t=>o[t]))).filter((t=>t.allowIn.includes(n.name)));var o}function il(t){return"string"==typeof t||t.is("documentFragment")?{name:"string"==typeof t?t:"$documentFragment",*getAttributeKeys(){},getAttribute(){}}:{name:t.is("element")?t.name:"$text",*getAttributeKeys(){yield*t.getAttributeKeys()},getAttribute:e=>t.getAttribute(e)}}function rl(t,e,n){for(const o of e.getAttributeKeys())t.checkAttribute(e,o)||n.removeAttribute(o,e)}class sl{constructor(t={}){this._splitParts=new Map,this._cursorParents=new Map,this._modelCursor=null,this.conversionApi=Object.assign({},t),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)}convert(t,e,n=["$root"]){this.fire("viewCleanup",t),this._modelCursor=function(t,e){let n;for(const o of new $c(t)){const t={};for(const e of o.getAttributeKeys())t[e]=o.getAttribute(e);const i=e.createElement(o.name,t);n&&e.append(i,n),n=Qa._createAt(i,0)}return n}(n,e),this.conversionApi.writer=e,this.conversionApi.consumable=Wc.createFrom(t),this.conversionApi.store={};const{modelRange:o}=this._convertItem(t,this._modelCursor),i=e.createDocumentFragment();if(o){this._removeEmptyElements();for(const t of Array.from(this._modelCursor.parent.getChildren()))e.append(t,i);i.markers=function(t,e){const n=new Set,o=new Map,i=nc._createIn(t).getItems();for(const t of i)"$marker"==t.name&&n.add(t);for(const t of n){const n=t.getAttribute("data-name"),i=e.createPositionBefore(t);o.has(n)?o.get(n).end=i.clone():o.set(n,new nc(i.clone())),e.remove(t)}return o}(i,e)}return this._modelCursor=null,this._splitParts.clear(),this._cursorParents.clear(),this.conversionApi.writer=null,this.conversionApi.store=null,i}_convertItem(t,e){const n=Object.assign({viewItem:t,modelCursor:e,modelRange:null});if(t.is("element")?this.fire("element:"+t.name,n,this.conversionApi):t.is("$text")?this.fire("text",n,this.conversionApi):this.fire("documentFragment",n,this.conversionApi),n.modelRange&&!(n.modelRange instanceof nc))throw new s("view-conversion-dispatcher-incorrect-result",this);return{modelRange:n.modelRange,modelCursor:n.modelCursor}}_convertChildren(t,e){let n=e.is("position")?e:Qa._createAt(e,0);const o=new nc(n);for(const e of Array.from(t.getChildren())){const t=this._convertItem(e,n);t.modelRange instanceof nc&&(o.end=t.modelRange.end,n=t.modelCursor)}return{modelRange:o,modelCursor:n}}_safeInsert(t,e){const n=this._splitToAllowedParent(t,e);return!!n&&(this.conversionApi.writer.insert(t,n.position),!0)}_updateConversionResult(t,e){const n=this._getSplitParts(t),o=this.conversionApi.writer;e.modelRange||(e.modelRange=o.createRange(o.createPositionBefore(t),o.createPositionAfter(n[n.length-1])));const i=this._cursorParents.get(t);e.modelCursor=i?o.createPositionAt(i,0):e.modelRange.end}_splitToAllowedParent(t,e){const{schema:n,writer:o}=this.conversionApi;let i=n.findAllowedParent(e,t);if(i){if(i===e.parent)return{position:e};this._modelCursor.parent.getAncestors().includes(i)&&(i=null)}if(!i)return Ic(e,t,n)?{position:Rc(e,o)}:null;const r=this.conversionApi.writer.split(e,i),s=[];for(const t of r.range.getWalker())if("elementEnd"==t.type)s.push(t.item);else{const e=s.pop(),n=t.item;this._registerSplitPair(e,n)}const a=r.range.end.parent;return this._cursorParents.set(t,a),{position:r.position,cursorParent:a}}_registerSplitPair(t,e){this._splitParts.has(t)||this._splitParts.set(t,[t]);const n=this._splitParts.get(t);this._splitParts.set(e,n),n.push(e)}_getSplitParts(t){let e;return e=this._splitParts.has(t)?this._splitParts.get(t):[t],e}_removeEmptyElements(){let t=!1;for(const e of this._splitParts.keys())e.isEmpty&&(this.conversionApi.writer.remove(e),this._splitParts.delete(e),t=!0);t&&this._removeEmptyElements()}}he(sl,g);class al{getHtml(t){const e=document.implementation.createHTMLDocument("").createElement("div");return e.appendChild(t),e.innerHTML}}class cl{constructor(t){this.domParser=new DOMParser,this.domConverter=new Cs(t,{renderingMode:"data"}),this.htmlWriter=new al}toData(t){const e=this.domConverter.viewToDom(t,document);return this.htmlWriter.getHtml(e)}toView(t){const e=this._toDom(t);return this.domConverter.domToView(e)}registerRawContentMatcher(t){this.domConverter.registerRawContentMatcher(t)}useFillerType(t){this.domConverter.blockFillerMode="marked"==t?"markedNbsp":"nbsp"}_toDom(t){t.match(/<(?:html|body|head|meta)(?:\s[^>]*)?>/i)||(t=`${t}`);const e=this.domParser.parseFromString(t,"text/html"),n=e.createDocumentFragment(),o=e.body.childNodes;for(;o.length>0;)n.appendChild(o[0]);return n}}class ll{constructor(t,e){this.model=t,this.mapper=new oc,this.downcastDispatcher=new sc({mapper:this.mapper,schema:t.schema}),this.downcastDispatcher.on("insert:$text",((t,e,n)=>{if(!n.consumable.consume(e.item,"insert"))return;const o=n.writer,i=n.mapper.toViewPosition(e.range.start),r=o.createText(e.item.data);o.insert(i,r)}),{priority:"lowest"}),this.upcastDispatcher=new sl({schema:t.schema}),this.viewDocument=new Xi(e),this.stylesProcessor=e,this.htmlProcessor=new cl(this.viewDocument),this.processor=this.htmlProcessor,this._viewWriter=new vr(this.viewDocument),this.upcastDispatcher.on("text",((t,e,{schema:n,consumable:o,writer:i})=>{let r=e.modelCursor;if(!o.test(e.viewItem))return;if(!n.checkChild(r,"$text")){if(!Ic(r,"$text",n))return;r=Rc(r,i)}o.consume(e.viewItem);const s=i.createText(e.viewItem.data);i.insert(s,r),e.modelRange=i.createRange(r,r.getShiftedBy(s.offsetSize)),e.modelCursor=e.modelRange.end}),{priority:"lowest"}),this.upcastDispatcher.on("element",((t,e,n)=>{if(!e.modelRange&&n.consumable.consume(e.viewItem,{name:!0})){const{modelRange:t,modelCursor:o}=n.convertChildren(e.viewItem,e.modelCursor);e.modelRange=t,e.modelCursor=o}}),{priority:"lowest"}),this.upcastDispatcher.on("documentFragment",((t,e,n)=>{if(!e.modelRange&&n.consumable.consume(e.viewItem,{name:!0})){const{modelRange:t,modelCursor:o}=n.convertChildren(e.viewItem,e.modelCursor);e.modelRange=t,e.modelCursor=o}}),{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},Pc)}),{priority:"lowest"})}get(t={}){const{rootName:e="main",trim:n="empty"}=t;if(!this._checkIfRootsExists([e]))throw new s("datacontroller-get-non-existent-root",this);const o=this.model.document.getRoot(e);return"empty"!==n||this.model.hasContent(o,{ignoreWhitespaces:!0})?this.stringify(o,t):""}stringify(t,e={}){const n=this.toView(t,e);return this.processor.toData(n)}toView(t,e={}){const n=this.viewDocument,o=this._viewWriter;this.mapper.clearBindings();const i=nc._createIn(t),r=new Ar(n);this.mapper.bindElements(t,r),this.downcastDispatcher.conversionApi.options=e,this.downcastDispatcher.convertInsert(i,o);const s=t.is("documentFragment")?Array.from(t.markers):function(t){const e=[],n=t.root.document;if(!n)return[];const o=nc._createIn(t);for(const t of n.model.markers){const n=t.getRange(),i=n.isCollapsed,r=n.start.isEqual(o.start)||n.end.isEqual(o.end);if(i&&r)e.push([t.name,n]);else{const i=o.getIntersection(n);i&&e.push([t.name,i])}}return e.sort((([t,e],[n,o])=>{if("after"!==e.end.compareWith(o.start))return 1;if("before"!==e.start.compareWith(o.end))return-1;switch(e.start.compareWith(o.start)){case"before":return 1;case"after":return-1;default:switch(e.end.compareWith(o.end)){case"before":return 1;case"after":return-1;default:return n.localeCompare(t)}}}))}(t);for(const[t,e]of s)this.downcastDispatcher.convertMarkerAdd(t,e,o);return delete this.downcastDispatcher.conversionApi.options,r}init(t){if(this.model.document.version)throw new s("datacontroller-init-document-not-empty",this);let e={};if("string"==typeof t?e.main=t:e=t,!this._checkIfRootsExists(Object.keys(e)))throw new s("datacontroller-init-non-existent-root",this);return this.model.enqueueChange({isUndoable:!1},(t=>{for(const n of Object.keys(e)){const o=this.model.document.getRoot(n);t.insert(this.parse(e[n],o),o,0)}})),Promise.resolve()}set(t,e={}){let n={};if("string"==typeof t?n.main=t:n=t,!this._checkIfRootsExists(Object.keys(n)))throw new s("datacontroller-set-non-existent-root",this);this.model.enqueueChange(e.batchType||{},(t=>{t.setSelection(null),t.removeSelectionAttribute(this.model.document.selection.getAttributeKeys());for(const e of Object.keys(n)){const o=this.model.document.getRoot(e);t.remove(t.createRangeIn(o)),t.insert(this.parse(n[e],o),o,0)}}))}parse(t,e="$root"){const n=this.processor.toView(t);return this.toModel(n,e)}toModel(t,e="$root"){return this.model.change((n=>this.upcastDispatcher.convert(t,n,e)))}addStyleProcessorRules(t){t(this.stylesProcessor)}registerRawContentMatcher(t){this.processor&&this.processor!==this.htmlProcessor&&this.processor.registerRawContentMatcher(t),this.htmlProcessor.registerRawContentMatcher(t)}destroy(){this.stopListening()}_checkIfRootsExists(t){for(const e of t)if(!this.model.document.getRootNames().includes(e))return!1;return!0}}he(ll,se);class dl{constructor(t,e){this._helpers=new Map,this._downcast=To(t),this._createConversionHelpers({name:"downcast",dispatchers:this._downcast,isDowncast:!0}),this._upcast=To(e),this._createConversionHelpers({name:"upcast",dispatchers:this._upcast,isDowncast:!1})}addAlias(t,e){const n=this._downcast.includes(e);if(!this._upcast.includes(e)&&!n)throw new s("conversion-add-alias-dispatcher-not-registered",this);this._createConversionHelpers({name:t,dispatchers:[e],isDowncast:n})}for(t){if(!this._helpers.has(t))throw new s("conversion-for-unknown-group",this);return this._helpers.get(t)}elementToElement(t){this.for("downcast").elementToElement(t);for(const{model:e,view:n}of ul(t))this.for("upcast").elementToElement({model:e,view:n,converterPriority:t.converterPriority})}attributeToElement(t){this.for("downcast").attributeToElement(t);for(const{model:e,view:n}of ul(t))this.for("upcast").elementToAttribute({view:n,model:e,converterPriority:t.converterPriority})}attributeToAttribute(t){this.for("downcast").attributeToAttribute(t);for(const{model:e,view:n}of ul(t))this.for("upcast").attributeToAttribute({view:n,model:e})}_createConversionHelpers({name:t,dispatchers:e,isDowncast:n}){if(this._helpers.has(t))throw new s("conversion-group-exists",this);const o=n?new yc(e):new zc(e);this._helpers.set(t,o)}}function*ul(t){if(t.model.values)for(const e of t.model.values){const n={key:t.model.key,value:e},o=t.view[e],i=t.upcastAlso?t.upcastAlso[e]:void 0;yield*hl(n,o,i)}else yield*hl(t.model,t.view,t.upcastAlso)}function*hl(t,e,n){if(yield{model:t,view:e},n)for(const e of To(n))yield{model:t,view:e}}class pl{constructor(t={}){"string"==typeof t&&(t="transparent"===t?{isUndoable:!1}:{},a("batch-constructor-deprecated-string-type"));const{isUndoable:e=!0,isLocal:n=!0,isUndo:o=!1,isTyping:i=!1}=t;this.operations=[],this.isUndoable=e,this.isLocal=n,this.isUndo=o,this.isTyping=i}get type(){return a("batch-type-deprecated"),"default"}get baseVersion(){for(const t of this.operations)if(null!==t.baseVersion)return t.baseVersion;return null}addOperation(t){return t.batch=this,this.operations.push(t),t}}class ml{constructor(t){this.baseVersion=t,this.isDocumentOperation=null!==this.baseVersion,this.batch=null}_validate(){}toJSON(){const t=Object.assign({},this);return t.__className=this.constructor.className,delete t.batch,delete t.isDocumentOperation,t}static get className(){return"Operation"}static fromJSON(t){return new this(t.baseVersion)}}class gl{constructor(t){this.markers=new Map,this._children=new Ka,t&&this._insertChild(0,t)}[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(t){return"documentFragment"===t||"model:documentFragment"===t}getChild(t){return this._children.getNode(t)}getChildren(){return this._children[Symbol.iterator]()}getChildIndex(t){return this._children.getNodeIndex(t)}getChildStartOffset(t){return this._children.getNodeStartOffset(t)}getPath(){return[]}getNodeByPath(t){let e=this;for(const n of t)e=e.getChild(e.offsetToIndex(n));return e}offsetToIndex(t){return this._children.offsetToIndex(t)}toJSON(){const t=[];for(const e of this._children)t.push(e.toJSON());return t}static fromJSON(t){const e=[];for(const n of t)n.name?e.push(Za.fromJSON(n)):e.push($a.fromJSON(n));return new gl(e)}_appendChild(t){this._insertChild(this.childCount,t)}_insertChild(t,e){const n=function(t){if("string"==typeof t)return[new $a(t)];Do(t)||(t=[t]);return Array.from(t).map((t=>"string"==typeof t?new $a(t):t instanceof Ga?new $a(t.data,t.getAttributes()):t))}(e);for(const t of n)null!==t.parent&&t._remove(),t.parent=this;this._children._insertNodes(t,n)}_removeChildren(t,e=1){const n=this._children._removeNodes(t,e);for(const t of n)t.parent=null;return n}}function fl(t,e){const n=(e=wl(e)).reduce(((t,e)=>t+e.offsetSize),0),o=t.parent;Cl(t);const i=t.index;return o._insertChild(i,e),_l(o,i+e.length),_l(o,i),new nc(t,t.getShiftedBy(n))}function bl(t){if(!t.isFlat)throw new s("operation-utils-remove-range-not-flat",this);const e=t.start.parent;Cl(t.start),Cl(t.end);const n=e._removeChildren(t.start.index,t.end.index-t.start.index);return _l(e,t.start.index),n}function kl(t,e){if(!t.isFlat)throw new s("operation-utils-move-range-not-flat",this);const n=bl(t);return fl(e=e._getTransformedByDeletion(t.start,t.end.offset-t.start.offset),n)}function wl(t){const e=[];t instanceof Array||(t=[t]);for(let n=0;nt.maxOffset)throw new s("move-operation-nodes-do-not-exist",this);if(t===e&&n=n&&this.targetPosition.path[t]t._clone(!0)))),e=new Dl(this.position,t,this.baseVersion);return e.shouldReceiveAttributes=this.shouldReceiveAttributes,e}getReversed(){const t=this.position.root.document.graveyard,e=new Qa(t,[0]);return new El(this.position,this.nodes.maxOffset,e,this.baseVersion+1)}_validate(){const t=this.position.parent;if(!t||t.maxOffsett._clone(!0)))),fl(this.position,t)}toJSON(){const t=super.toJSON();return t.position=this.position.toJSON(),t.nodes=this.nodes.toJSON(),t}static get className(){return"InsertOperation"}static fromJSON(t,e){const n=[];for(const e of t.nodes)e.name?n.push(Za.fromJSON(e)):n.push($a.fromJSON(e));const o=new Dl(Qa.fromJSON(t.position,e),n,t.baseVersion);return o.shouldReceiveAttributes=t.shouldReceiveAttributes,o}}class Sl extends ml{constructor(t,e,n,o,i,r){super(r),this.name=t,this.oldRange=e?e.clone():null,this.newRange=n?n.clone():null,this.affectsData=i,this._markers=o}get type(){return"marker"}clone(){return new Sl(this.name,this.oldRange,this.newRange,this._markers,this.affectsData,this.baseVersion)}getReversed(){return new Sl(this.name,this.newRange,this.oldRange,this._markers,this.affectsData,this.baseVersion+1)}_execute(){const t=this.newRange?"_set":"_remove";this._markers[t](this.name,this.newRange,!0,this.affectsData)}toJSON(){const t=super.toJSON();return this.oldRange&&(t.oldRange=this.oldRange.toJSON()),this.newRange&&(t.newRange=this.newRange.toJSON()),delete t._markers,t}static get className(){return"MarkerOperation"}static fromJSON(t,e){return new Sl(t.name,t.oldRange?nc.fromJSON(t.oldRange,e):null,t.newRange?nc.fromJSON(t.newRange,e):null,e.model.markers,t.affectsData,t.baseVersion)}}class Bl extends ml{constructor(t,e,n,o){super(o),this.position=t,this.position.stickiness="toNext",this.oldName=e,this.newName=n}get type(){return"rename"}clone(){return new Bl(this.position.clone(),this.oldName,this.newName,this.baseVersion)}getReversed(){return new Bl(this.position.clone(),this.newName,this.oldName,this.baseVersion+1)}_validate(){const t=this.position.nodeAfter;if(!(t instanceof Za))throw new s("rename-operation-wrong-position",this);if(t.name!==this.oldName)throw new s("rename-operation-wrong-name",this)}_execute(){this.position.nodeAfter.name=this.newName}toJSON(){const t=super.toJSON();return t.position=this.position.toJSON(),t}static get className(){return"RenameOperation"}static fromJSON(t,e){return new Bl(Qa.fromJSON(t.position,e),t.oldName,t.newName,t.baseVersion)}}class Tl extends ml{constructor(t,e,n,o,i){super(i),this.root=t,this.key=e,this.oldValue=n,this.newValue=o}get type(){return null===this.oldValue?"addRootAttribute":null===this.newValue?"removeRootAttribute":"changeRootAttribute"}clone(){return new Tl(this.root,this.key,this.oldValue,this.newValue,this.baseVersion)}getReversed(){return new Tl(this.root,this.key,this.newValue,this.oldValue,this.baseVersion+1)}_validate(){if(this.root!=this.root.root||this.root.is("documentFragment"))throw new s("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 s("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 s("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 t=super.toJSON();return t.root=this.root.toJSON(),t}static get className(){return"RootAttributeOperation"}static fromJSON(t,e){if(!e.getRoot(t.root))throw new s("rootattribute-operation-fromjson-no-root",this,{rootName:t.root});return new Tl(e.getRoot(t.root),t.key,t.oldValue,t.newValue,t.baseVersion)}}class Pl extends ml{constructor(t,e,n,o,i){super(i),this.sourcePosition=t.clone(),this.sourcePosition.stickiness="toPrevious",this.howMany=e,this.targetPosition=n.clone(),this.targetPosition.stickiness="toNext",this.graveyardPosition=o.clone()}get type(){return"merge"}get deletionPosition(){return new Qa(this.sourcePosition.root,this.sourcePosition.path.slice(0,-1))}get movedRange(){const t=this.sourcePosition.getShiftedBy(Number.POSITIVE_INFINITY);return new nc(this.sourcePosition,t)}clone(){return new this.constructor(this.sourcePosition,this.howMany,this.targetPosition,this.graveyardPosition,this.baseVersion)}getReversed(){const t=this.targetPosition._getTransformedByMergeOperation(this),e=this.sourcePosition.path.slice(0,-1),n=new Qa(this.sourcePosition.root,e)._getTransformedByMergeOperation(this);return new Il(t,this.howMany,n,this.graveyardPosition,this.baseVersion+1)}_validate(){const t=this.sourcePosition.parent,e=this.targetPosition.parent;if(!t.parent)throw new s("merge-operation-source-position-invalid",this);if(!e.parent)throw new s("merge-operation-target-position-invalid",this);if(this.howMany!=t.maxOffset)throw new s("merge-operation-how-many-invalid",this)}_execute(){const t=this.sourcePosition.parent;kl(nc._createIn(t),this.targetPosition),kl(nc._createOn(t),this.graveyardPosition)}toJSON(){const t=super.toJSON();return t.sourcePosition=t.sourcePosition.toJSON(),t.targetPosition=t.targetPosition.toJSON(),t.graveyardPosition=t.graveyardPosition.toJSON(),t}static get className(){return"MergeOperation"}static fromJSON(t,e){const n=Qa.fromJSON(t.sourcePosition,e),o=Qa.fromJSON(t.targetPosition,e),i=Qa.fromJSON(t.graveyardPosition,e);return new this(n,t.howMany,o,i,t.baseVersion)}}class Il extends ml{constructor(t,e,n,o,i){super(i),this.splitPosition=t.clone(),this.splitPosition.stickiness="toNext",this.howMany=e,this.insertionPosition=n,this.graveyardPosition=o?o.clone():null,this.graveyardPosition&&(this.graveyardPosition.stickiness="toNext")}get type(){return"split"}get moveTargetPosition(){const t=this.insertionPosition.path.slice();return t.push(0),new Qa(this.insertionPosition.root,t)}get movedRange(){const t=this.splitPosition.getShiftedBy(Number.POSITIVE_INFINITY);return new nc(this.splitPosition,t)}clone(){return new this.constructor(this.splitPosition,this.howMany,this.insertionPosition,this.graveyardPosition,this.baseVersion)}getReversed(){const t=this.splitPosition.root.document.graveyard,e=new Qa(t,[0]);return new Pl(this.moveTargetPosition,this.howMany,this.splitPosition,e,this.baseVersion+1)}_validate(){const t=this.splitPosition.parent,e=this.splitPosition.offset;if(!t||t.maxOffset{for(const e of t.getAttributeKeys())this.removeAttribute(e,t)};if(t instanceof nc)for(const n of t.getItems())e(n);else e(t)}move(t,e,n){if(this._assertWriterUsedCorrectly(),!(t instanceof nc))throw new s("writer-move-invalid-range",this);if(!t.isFlat)throw new s("writer-move-range-not-flat",this);const o=Qa._createAt(e,n);if(o.isEqual(t.start))return;if(this._addOperationForAffectedMarkers("move",t),!Vl(t.root,o.root))throw new s("writer-move-different-document",this);const i=t.root.document?t.root.document.version:null,r=new El(t.start,t.end.offset-t.start.offset,o,i);this.batch.addOperation(r),this.model.applyOperation(r)}remove(t){this._assertWriterUsedCorrectly();const e=(t instanceof nc?t:nc._createOn(t)).getMinimalFlatRanges().reverse();for(const t of e)this._addOperationForAffectedMarkers("move",t),Ml(t.start,t.end.offset-t.start.offset,this.batch,this.model)}merge(t){this._assertWriterUsedCorrectly();const e=t.nodeBefore,n=t.nodeAfter;if(this._addOperationForAffectedMarkers("merge",t),!(e instanceof Za))throw new s("writer-merge-no-element-before",this);if(!(n instanceof Za))throw new s("writer-merge-no-element-after",this);t.root.document?this._merge(t):this._mergeDetached(t)}createPositionFromPath(t,e,n){return this.model.createPositionFromPath(t,e,n)}createPositionAt(t,e){return this.model.createPositionAt(t,e)}createPositionAfter(t){return this.model.createPositionAfter(t)}createPositionBefore(t){return this.model.createPositionBefore(t)}createRange(t,e){return this.model.createRange(t,e)}createRangeIn(t){return this.model.createRangeIn(t)}createRangeOn(t){return this.model.createRangeOn(t)}createSelection(t,e,n){return this.model.createSelection(t,e,n)}_mergeDetached(t){const e=t.nodeBefore,n=t.nodeAfter;this.move(nc._createIn(n),Qa._createAt(e,"end")),this.remove(n)}_merge(t){const e=Qa._createAt(t.nodeBefore,"end"),n=Qa._createAt(t.nodeAfter,0),o=t.root.document.graveyard,i=new Qa(o,[0]),r=t.root.document.version,s=new Pl(n,t.nodeAfter.maxOffset,e,i,r);this.batch.addOperation(s),this.model.applyOperation(s)}rename(t,e){if(this._assertWriterUsedCorrectly(),!(t instanceof Za))throw new s("writer-rename-not-element-instance",this);const n=t.root.document?t.root.document.version:null,o=new Bl(Qa._createBefore(t),t.name,e,n);this.batch.addOperation(o),this.model.applyOperation(o)}split(t,e){this._assertWriterUsedCorrectly();let n,o,i=t.parent;if(!i.parent)throw new s("writer-split-element-no-parent",this);if(e||(e=i.parent),!t.parent.getAncestors({includeSelf:!0}).includes(e))throw new s("writer-split-invalid-limit-element",this);do{const e=i.root.document?i.root.document.version:null,r=i.maxOffset-t.offset,s=Il.getInsertionPosition(t),a=new Il(t,r,s,null,e);this.batch.addOperation(a),this.model.applyOperation(a),n||o||(n=i,o=t.parent.nextSibling),i=(t=this.createPositionAfter(t.parent)).parent}while(i!==e);return{position:t,range:new nc(Qa._createAt(n,"end"),Qa._createAt(o,0))}}wrap(t,e){if(this._assertWriterUsedCorrectly(),!t.isFlat)throw new s("writer-wrap-range-not-flat",this);const n=e instanceof Za?e:new Za(e);if(n.childCount>0)throw new s("writer-wrap-element-not-empty",this);if(null!==n.parent)throw new s("writer-wrap-element-attached",this);this.insert(n,t.start);const o=new nc(t.start.getShiftedBy(1),t.end.getShiftedBy(1));this.move(o,Qa._createAt(n,0))}unwrap(t){if(this._assertWriterUsedCorrectly(),null===t.parent)throw new s("writer-unwrap-element-no-parent",this);this.move(nc._createIn(t),this.createPositionAfter(t)),this.remove(t)}addMarker(t,e){if(this._assertWriterUsedCorrectly(),!e||"boolean"!=typeof e.usingOperation)throw new s("writer-addmarker-no-usingoperation",this);const n=e.usingOperation,o=e.range,i=void 0!==e.affectsData&&e.affectsData;if(this.model.markers.has(t))throw new s("writer-addmarker-marker-exists",this);if(!o)throw new s("writer-addmarker-no-range",this);return n?(Ol(this,t,null,o,i),this.model.markers.get(t)):this.model.markers._set(t,o,n,i)}updateMarker(t,e){this._assertWriterUsedCorrectly();const n="string"==typeof t?t:t.name,o=this.model.markers.get(n);if(!o)throw new s("writer-updatemarker-marker-not-exists",this);if(!e)return void this.model.markers._refresh(o);const i="boolean"==typeof e.usingOperation,r="boolean"==typeof e.affectsData,a=r?e.affectsData:o.affectsData;if(!i&&!e.range&&!r)throw new s("writer-updatemarker-wrong-options",this);const c=o.getRange(),l=e.range?e.range:c;i&&e.usingOperation!==o.managedUsingOperations?e.usingOperation?Ol(this,n,null,l,a):(Ol(this,n,c,null,a),this.model.markers._set(n,l,void 0,a)):o.managedUsingOperations?Ol(this,n,c,l,a):this.model.markers._set(n,l,void 0,a)}removeMarker(t){this._assertWriterUsedCorrectly();const e="string"==typeof t?t:t.name;if(!this.model.markers.has(e))throw new s("writer-removemarker-no-marker",this);const n=this.model.markers.get(e);if(!n.managedUsingOperations)return void this.model.markers._remove(e);Ol(this,e,n.getRange(),null,n.affectsData)}setSelection(t,e,n){this._assertWriterUsedCorrectly(),this.model.document.selection._setTo(t,e,n)}setSelectionFocus(t,e){this._assertWriterUsedCorrectly(),this.model.document.selection._setFocus(t,e)}setSelectionAttribute(t,e){if(this._assertWriterUsedCorrectly(),"string"==typeof t)this._setSelectionAttribute(t,e);else for(const[e,n]of qo(t))this._setSelectionAttribute(e,n)}removeSelectionAttribute(t){if(this._assertWriterUsedCorrectly(),"string"==typeof t)this._removeSelectionAttribute(t);else for(const e of t)this._removeSelectionAttribute(e)}overrideSelectionGravity(){return this.model.document.selection._overrideGravity()}restoreSelectionGravity(t){this.model.document.selection._restoreGravity(t)}_setSelectionAttribute(t,e){const n=this.model.document.selection;if(n.isCollapsed&&n.anchor.parent.isEmpty){const o=wc._getStoreAttributeKey(t);this.setAttribute(o,e,n.anchor.parent)}n._setAttribute(t,e)}_removeSelectionAttribute(t){const e=this.model.document.selection;if(e.isCollapsed&&e.anchor.parent.isEmpty){const n=wc._getStoreAttributeKey(t);this.removeAttribute(n,e.anchor.parent)}e._removeAttribute(t)}_assertWriterUsedCorrectly(){if(this.model._currentWriter!==this)throw new s("writer-incorrect-use",this)}_addOperationForAffectedMarkers(t,e){for(const n of this.model.markers){if(!n.managedUsingOperations)continue;const o=n.getRange();let i=!1;if("move"===t)i=e.containsPosition(o.start)||e.start.isEqual(o.start)||e.containsPosition(o.end)||e.end.isEqual(o.end);else{const t=e.nodeBefore,n=e.nodeAfter,r=o.start.parent==t&&o.start.isAtEnd,s=o.end.parent==n&&0==o.end.offset,a=o.end.nodeAfter==n,c=o.start.nodeAfter==n;i=r||s||a||c}i&&this.updateMarker(n.name,{range:o})}}}function Fl(t,e,n,o){const i=t.model,r=i.document;let s,a,c,l=o.start;for(const t of o.getWalker({shallow:!0}))c=t.item.getAttribute(e),s&&a!=c&&(a!=n&&d(),l=s),s=t.nextPosition,a=c;function d(){const o=new nc(l,s),c=o.root.document?r.version:null,d=new yl(o,e,a,n,c);t.batch.addOperation(d),i.applyOperation(d)}s instanceof Qa&&s!=l&&a!=n&&d()}function Nl(t,e,n,o){const i=t.model,r=i.document,s=o.getAttribute(e);let a,c;if(s!=n){if(o.root===o){const t=o.document?r.version:null;c=new Tl(o,e,s,n,t)}else{a=new nc(Qa._createBefore(o),t.createPositionAfter(o));const i=a.root.document?r.version:null;c=new yl(a,e,s,n,i)}t.batch.addOperation(c),i.applyOperation(c)}}function Ol(t,e,n,o,i){const r=t.model,s=r.document,a=new Sl(e,n,o,r.markers,i,s.version);t.batch.addOperation(a),r.applyOperation(a)}function Ml(t,e,n,o){let i;if(t.root.document){const n=o.document,r=new Qa(n.graveyard,[0]);i=new El(t,e,r,n.version)}else i=new xl(t,e);n.addOperation(i),o.applyOperation(i)}function Vl(t,e){return t===e||t instanceof Rl&&e instanceof Rl}class Ll{constructor(t){this._markerCollection=t,this._changesInElement=new Map,this._elementSnapshots=new Map,this._changedMarkers=new Map,this._changeCount=0,this._cachedChanges=null,this._cachedChangesWithGraveyard=null}get isEmpty(){return 0==this._changesInElement.size&&0==this._changedMarkers.size}refreshItem(t){if(this._isInInsertedElement(t.parent))return;this._markRemove(t.parent,t.startOffset,t.offsetSize),this._markInsert(t.parent,t.startOffset,t.offsetSize);const e=nc._createOn(t);for(const t of this._markerCollection.getMarkersIntersectingRange(e)){const e=t.getRange();this.bufferMarkerChange(t.name,e,e,t.affectsData)}this._cachedChanges=null}bufferOperation(t){switch(t.type){case"insert":if(this._isInInsertedElement(t.position.parent))return;this._markInsert(t.position.parent,t.position.offset,t.nodes.maxOffset);break;case"addAttribute":case"removeAttribute":case"changeAttribute":for(const e of t.range.getItems({shallow:!0}))this._isInInsertedElement(e.parent)||this._markAttribute(e);break;case"remove":case"move":case"reinsert":{if(t.sourcePosition.isEqual(t.targetPosition)||t.sourcePosition.getShiftedBy(t.howMany).isEqual(t.targetPosition))return;const e=this._isInInsertedElement(t.sourcePosition.parent),n=this._isInInsertedElement(t.targetPosition.parent);e||this._markRemove(t.sourcePosition.parent,t.sourcePosition.offset,t.howMany),n||this._markInsert(t.targetPosition.parent,t.getMovedRangeStart().offset,t.howMany);break}case"rename":{if(this._isInInsertedElement(t.position.parent))return;this._markRemove(t.position.parent,t.position.offset,1),this._markInsert(t.position.parent,t.position.offset,1);const e=nc._createFromPositionAndShift(t.position,1);for(const t of this._markerCollection.getMarkersIntersectingRange(e)){const e=t.getRange();this.bufferMarkerChange(t.name,e,e,t.affectsData)}break}case"split":{const e=t.splitPosition.parent;this._isInInsertedElement(e)||this._markRemove(e,t.splitPosition.offset,t.howMany),this._isInInsertedElement(t.insertionPosition.parent)||this._markInsert(t.insertionPosition.parent,t.insertionPosition.offset,1),t.graveyardPosition&&this._markRemove(t.graveyardPosition.parent,t.graveyardPosition.offset,1);break}case"merge":{const e=t.sourcePosition.parent;this._isInInsertedElement(e.parent)||this._markRemove(e.parent,e.startOffset,1);const n=t.graveyardPosition.parent;this._markInsert(n,t.graveyardPosition.offset,1);const o=t.targetPosition.parent;this._isInInsertedElement(o)||this._markInsert(o,t.targetPosition.offset,e.maxOffset);break}}this._cachedChanges=null}bufferMarkerChange(t,e,n,o){const i=this._changedMarkers.get(t);i?(i.newRange=n,i.affectsData=o,null==i.oldRange&&null==i.newRange&&this._changedMarkers.delete(t)):this._changedMarkers.set(t,{oldRange:e,newRange:n,affectsData:o})}getMarkersToRemove(){const t=[];for(const[e,n]of this._changedMarkers)null!=n.oldRange&&t.push({name:e,range:n.oldRange});return t}getMarkersToAdd(){const t=[];for(const[e,n]of this._changedMarkers)null!=n.newRange&&t.push({name:e,range:n.newRange});return t}getChangedMarkers(){return Array.from(this._changedMarkers).map((t=>({name:t[0],data:{oldRange:t[1].oldRange,newRange:t[1].newRange}})))}hasDataChanges(){for(const[,t]of this._changedMarkers)if(t.affectsData)return!0;return this._changesInElement.size>0}getChanges(t={includeChangesInGraveyard:!1}){if(this._cachedChanges)return t.includeChangesInGraveyard?this._cachedChangesWithGraveyard.slice():this._cachedChanges.slice();let e=[];for(const t of this._changesInElement.keys()){const n=this._changesInElement.get(t).sort(((t,e)=>t.offset===e.offset?t.type!=e.type?"remove"==t.type?-1:1:0:t.offsett.position.root!=e.position.root?t.position.root.rootNamet));for(const t of e)delete t.changeCount,"attribute"==t.type&&(delete t.position,delete t.length);return this._changeCount=0,this._cachedChangesWithGraveyard=e.slice(),this._cachedChanges=e.filter(Wl),t.includeChangesInGraveyard?this._cachedChangesWithGraveyard:this._cachedChanges}reset(){this._changesInElement.clear(),this._elementSnapshots.clear(),this._changedMarkers.clear(),this._cachedChanges=null}_markInsert(t,e,n){const o={type:"insert",offset:e,howMany:n,count:this._changeCount++};this._markChange(t,o)}_markRemove(t,e,n){const o={type:"remove",offset:e,howMany:n,count:this._changeCount++};this._markChange(t,o),this._removeAllNestedChanges(t,e,n)}_markAttribute(t){const e={type:"attribute",offset:t.startOffset,howMany:t.offsetSize,count:this._changeCount++};this._markChange(t.parent,e)}_markChange(t,e){this._makeSnapshot(t);const n=this._getChangesForElement(t);this._handleChange(e,n),n.push(e);for(let t=0;tn.offset){if(o>i){const t={type:"attribute",offset:i,howMany:o-i,count:this._changeCount++};this._handleChange(t,e),e.push(t)}t.nodesToHandle=n.offset-t.offset,t.howMany=t.nodesToHandle}else t.offset>=n.offset&&t.offseti?(t.nodesToHandle=o-i,t.offset=i):t.nodesToHandle=0);if("remove"==n.type&&t.offsetn.offset){const i={type:"attribute",offset:n.offset,howMany:o-n.offset,count:this._changeCount++};this._handleChange(i,e),e.push(i),t.nodesToHandle=n.offset-t.offset,t.howMany=t.nodesToHandle}"attribute"==n.type&&(t.offset>=n.offset&&o<=i?(t.nodesToHandle=0,t.howMany=0,t.offset=0):t.offset<=n.offset&&o>=i&&(n.howMany=0))}}t.howMany=t.nodesToHandle,delete t.nodesToHandle}_getInsertDiff(t,e,n){return{type:"insert",position:Qa._createAt(t,e),name:n,length:1,changeCount:this._changeCount++}}_getRemoveDiff(t,e,n){return{type:"remove",position:Qa._createAt(t,e),name:n,length:1,changeCount:this._changeCount++}}_getAttributesDiff(t,e,n){const o=[];n=new Map(n);for(const[i,r]of e){const e=n.has(i)?n.get(i):null;e!==r&&o.push({type:"attribute",position:t.start,range:t.clone(),length:1,attributeKey:i,attributeOldValue:r,attributeNewValue:e,changeCount:this._changeCount++}),n.delete(i)}for(const[e,i]of n)o.push({type:"attribute",position:t.start,range:t.clone(),length:1,attributeKey:e,attributeOldValue:null,attributeNewValue:i,changeCount:this._changeCount++});return o}_isInInsertedElement(t){const e=t.parent;if(!e)return!1;const n=this._changesInElement.get(e),o=t.startOffset;if(n)for(const t of n)if("insert"==t.type&&o>=t.offset&&oo){for(let e=0;e=t&&o.baseVersion{const n=e[0];if(n.isDocumentOperation&&n.baseVersion!==this.version)throw new s("model-document-applyoperation-wrong-version",this,{operation:n})}),{priority:"highest"}),this.listenTo(t,"applyOperation",((t,e)=>{const n=e[0];n.isDocumentOperation&&this.differ.bufferOperation(n)}),{priority:"high"}),this.listenTo(t,"applyOperation",((t,e)=>{const n=e[0];n.isDocumentOperation&&(this.version++,this.history.addOperation(n))}),{priority:"low"}),this.listenTo(this.selection,"change",(()=>{this._hasSelectionChangedFromTheLastChangeBlock=!0})),this.listenTo(t.markers,"update",((t,e,n,o)=>{this.differ.bufferMarkerChange(e.name,n,o,e.affectsData),null===n&&e.on("change",((t,n)=>{this.differ.bufferMarkerChange(e.name,n,e.getRange(),e.affectsData)}))}))}get graveyard(){return this.getRoot(Gl)}createRoot(t="$root",e="main"){if(this.roots.get(e))throw new s("model-document-createroot-name-exists",this,{name:e});const n=new Rl(this,t,e);return this.roots.add(n),n}destroy(){this.selection.destroy(),this.stopListening()}getRoot(t="main"){return this.roots.get(t)}getRootNames(){return Array.from(this.roots,(t=>t.rootName)).filter((t=>t!=Gl))}registerPostFixer(t){this._postFixers.add(t)}toJSON(){const t=Mo(this);return t.selection="[engine.model.DocumentSelection]",t.model="[engine.model.Model]",t}_handleChangeBlock(t){this._hasDocumentChangedFromTheLastChangeBlock()&&(this._callPostFixers(t),this.selection.refresh(),this.differ.hasDataChanges()?this.fire("change:data",t.batch):this.fire("change",t.batch),this.selection.refresh(),this.differ.reset()),this._hasSelectionChangedFromTheLastChangeBlock=!1}_hasDocumentChangedFromTheLastChangeBlock(){return!this.differ.isEmpty||this._hasSelectionChangedFromTheLastChangeBlock}_getDefaultRoot(){for(const t of this.roots)if(t!==this.graveyard)return t;return this.graveyard}_getDefaultRange(){const t=this._getDefaultRoot(),e=this.model,n=e.schema,o=e.createPositionFromPath(t,[0]);return n.getNearestSelectionRange(o)||e.createRange(o)}_validateSelectionRange(t){return Zl(t.start)&&Zl(t.end)}_callPostFixers(t){let e=!1;do{for(const n of this._postFixers)if(this.selection.refresh(),e=n(t),e)break}while(e)}}function Zl(t){const e=t.textNode;if(e){const n=e.data,o=t.offset-e.startOffset;return!Ul(n,o)&&!$l(n,o)}return!0}he(Kl,g);class Jl{constructor(){this._markers=new Map}[Symbol.iterator](){return this._markers.values()}has(t){const e=t instanceof Yl?t.name:t;return this._markers.has(e)}get(t){return this._markers.get(t)||null}_set(t,e,n=!1,o=!1){const i=t instanceof Yl?t.name:t;if(i.includes(","))throw new s("markercollection-incorrect-marker-name",this);const r=this._markers.get(i);if(r){const t=r.getRange();let s=!1;return t.isEqual(e)||(r._attachLiveRange(gc.fromRange(e)),s=!0),n!=r.managedUsingOperations&&(r._managedUsingOperations=n,s=!0),"boolean"==typeof o&&o!=r.affectsData&&(r._affectsData=o,s=!0),s&&this.fire("update:"+i,r,t,e),r}const a=gc.fromRange(e),c=new Yl(i,a,n,o);return this._markers.set(i,c),this.fire("update:"+i,c,null,e),c}_remove(t){const e=t instanceof Yl?t.name:t,n=this._markers.get(e);return!!n&&(this._markers.delete(e),this.fire("update:"+e,n,n.getRange(),null),this._destroyMarker(n),!0)}_refresh(t){const e=t instanceof Yl?t.name:t,n=this._markers.get(e);if(!n)throw new s("markercollection-refresh-marker-not-exists",this);const o=n.getRange();this.fire("update:"+e,n,o,o,n.managedUsingOperations,n.affectsData)}*getMarkersAtPosition(t){for(const e of this)e.getRange().containsPosition(t)&&(yield e)}*getMarkersIntersectingRange(t){for(const e of this)null!==e.getRange().getIntersection(t)&&(yield e)}destroy(){for(const t of this._markers.values())this._destroyMarker(t);this._markers=null,this.stopListening()}*getMarkersGroup(t){for(const e of this._markers.values())e.name.startsWith(t+":")&&(yield e)}_destroyMarker(t){t.stopListening(),t._detachLiveRange()}}he(Jl,g);class Yl{constructor(t,e,n,o){this.name=t,this._liveRange=this._attachLiveRange(e),this._managedUsingOperations=n,this._affectsData=o}get managedUsingOperations(){if(!this._liveRange)throw new s("marker-destroyed",this);return this._managedUsingOperations}get affectsData(){if(!this._liveRange)throw new s("marker-destroyed",this);return this._affectsData}getStart(){if(!this._liveRange)throw new s("marker-destroyed",this);return this._liveRange.start.clone()}getEnd(){if(!this._liveRange)throw new s("marker-destroyed",this);return this._liveRange.end.clone()}getRange(){if(!this._liveRange)throw new s("marker-destroyed",this);return this._liveRange.toRange()}is(t){return"marker"===t||"model:marker"===t}_attachLiveRange(t){return this._liveRange&&this._detachLiveRange(),t.delegate("change:range").to(this),t.delegate("change:content").to(this),this._liveRange=t,t}_detachLiveRange(){this._liveRange.stopDelegating("change:range",this),this._liveRange.stopDelegating("change:content",this),this._liveRange.detach(),this._liveRange=null}}he(Yl,g);class Ql extends ml{get type(){return"noop"}clone(){return new Ql(this.baseVersion)}getReversed(){return new Ql(this.baseVersion+1)}_execute(){}static get className(){return"NoOperation"}}const Xl={};Xl[yl.className]=yl,Xl[Dl.className]=Dl,Xl[Sl.className]=Sl,Xl[El.className]=El,Xl[Ql.className]=Ql,Xl[ml.className]=ml,Xl[Bl.className]=Bl,Xl[Tl.className]=Tl,Xl[Il.className]=Il,Xl[Pl.className]=Pl;class td extends Qa{constructor(t,e,n="toNone"){if(super(t,e,n),!this.root.is("rootElement"))throw new s("model-liveposition-root-not-rootelement",t);ed.call(this)}detach(){this.stopListening()}is(t){return"livePosition"===t||"model:livePosition"===t||"position"==t||"model:position"===t}toPosition(){return new Qa(this.root,this.path.slice(),this.stickiness)}static fromPosition(t,e){return new this(t.root,t.path.slice(),e||t.stickiness)}}function ed(){this.listenTo(this.root.document.model,"applyOperation",((t,e)=>{const n=e[0];n.isDocumentOperation&&nd.call(this,n)}),{priority:"low"})}function nd(t){const e=this.getTransformedByOperation(t);if(!this.isEqual(e)){const t=this.toPosition();this.path=e.path,this.root=e.root,this.fire("change",t)}}he(td,g);class od{constructor(t,e,n){this.model=t,this.writer=e,this.position=n,this.canMergeWith=new Set([this.position.parent]),this.schema=t.schema,this._documentFragment=e.createDocumentFragment(),this._documentFragmentPosition=e.createPositionAt(this._documentFragment,0),this._firstNode=null,this._lastNode=null,this._lastAutoParagraph=null,this._filterAttributesOf=[],this._affectedStart=null,this._affectedEnd=null}handleNodes(t){for(const e of Array.from(t))this._handleNode(e);this._insertPartialFragment(),this._lastAutoParagraph&&this._updateLastNodeFromAutoParagraph(this._lastAutoParagraph),this._mergeOnRight(),this.schema.removeDisallowedAttributes(this._filterAttributesOf,this.writer),this._filterAttributesOf=[]}_updateLastNodeFromAutoParagraph(t){const e=this.writer.createPositionAfter(this._lastNode),n=this.writer.createPositionAfter(t);if(n.isAfter(e)){if(this._lastNode=t,this.position.parent!=t||!this.position.isAtEnd)throw new s("insertcontent-invalid-insertion-position",this);this.position=n,this._setAffectedBoundaries(this.position)}}getSelectionRange(){return this.nodeToSelect?nc._createOn(this.nodeToSelect):this.model.schema.getNearestSelectionRange(this.position)}getAffectedRange(){return this._affectedStart?new nc(this._affectedStart,this._affectedEnd):null}destroy(){this._affectedStart&&this._affectedStart.detach(),this._affectedEnd&&this._affectedEnd.detach()}_handleNode(t){if(this.schema.isObject(t))return void this._handleObject(t);let e=this._checkAndAutoParagraphToAllowedPosition(t);e||(e=this._checkAndSplitToAllowedPosition(t),e)?(this._appendToFragment(t),this._firstNode||(this._firstNode=t),this._lastNode=t):this._handleDisallowedNode(t)}_insertPartialFragment(){if(this._documentFragment.isEmpty)return;const t=td.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=t.toPosition()),this._documentFragment.isEmpty||this.writer.insert(this._documentFragment,this.position),this._documentFragmentPosition=this.writer.createPositionAt(this._documentFragment,0),this.position=t.toPosition(),t.detach()}_handleObject(t){this._checkAndSplitToAllowedPosition(t)?this._appendToFragment(t):this._tryAutoparagraphing(t)}_handleDisallowedNode(t){t.is("element")?this.handleNodes(t.getChildren()):this._tryAutoparagraphing(t)}_appendToFragment(t){if(!this.schema.checkChild(this.position,t))throw new s("insertcontent-wrong-position",this,{node:t,position:this.position});this.writer.insert(t,this._documentFragmentPosition),this._documentFragmentPosition=this._documentFragmentPosition.getShiftedBy(t.offsetSize),this.schema.isObject(t)&&!this.schema.checkChild(this.position,"$text")?this.nodeToSelect=t:this.nodeToSelect=null,this._filterAttributesOf.push(t)}_setAffectedBoundaries(t){this._affectedStart||(this._affectedStart=td.fromPosition(t,"toPrevious")),this._affectedEnd&&!this._affectedEnd.isBefore(t)||(this._affectedEnd&&this._affectedEnd.detach(),this._affectedEnd=td.fromPosition(t,"toNext"))}_mergeOnLeft(){const t=this._firstNode;if(!(t instanceof Za))return;if(!this._canMergeLeft(t))return;const e=td._createBefore(t);e.stickiness="toNext";const n=td.fromPosition(this.position,"toNext");this._affectedStart.isEqual(e)&&(this._affectedStart.detach(),this._affectedStart=td._createAt(e.nodeBefore,"end","toPrevious")),this._firstNode===this._lastNode&&(this._firstNode=e.nodeBefore,this._lastNode=e.nodeBefore),this.writer.merge(e),e.isEqual(this._affectedEnd)&&this._firstNode===this._lastNode&&(this._affectedEnd.detach(),this._affectedEnd=td._createAt(e.nodeBefore,"end","toNext")),this.position=n.toPosition(),n.detach(),this._filterAttributesOf.push(this.position.parent),e.detach()}_mergeOnRight(){const t=this._lastNode;if(!(t instanceof Za))return;if(!this._canMergeRight(t))return;const e=td._createAfter(t);if(e.stickiness="toNext",!this.position.isEqual(e))throw new s("insertcontent-invalid-insertion-position",this);this.position=Qa._createAt(e.nodeBefore,"end");const n=td.fromPosition(this.position,"toPrevious");this._affectedEnd.isEqual(e)&&(this._affectedEnd.detach(),this._affectedEnd=td._createAt(e.nodeBefore,"end","toNext")),this._firstNode===this._lastNode&&(this._firstNode=e.nodeBefore,this._lastNode=e.nodeBefore),this.writer.merge(e),e.getShiftedBy(-1).isEqual(this._affectedStart)&&this._firstNode===this._lastNode&&(this._affectedStart.detach(),this._affectedStart=td._createAt(e.nodeBefore,0,"toPrevious")),this.position=n.toPosition(),n.detach(),this._filterAttributesOf.push(this.position.parent),e.detach()}_canMergeLeft(t){const e=t.previousSibling;return e instanceof Za&&this.canMergeWith.has(e)&&this.model.schema.checkMerge(e,t)}_canMergeRight(t){const e=t.nextSibling;return e instanceof Za&&this.canMergeWith.has(e)&&this.model.schema.checkMerge(t,e)}_tryAutoparagraphing(t){const e=this.writer.createElement("paragraph");this._getAllowedIn(this.position.parent,e)&&this.schema.checkChild(e,t)&&(e._appendChild(t),this._handleNode(e))}_checkAndAutoParagraphToAllowedPosition(t){if(this.schema.checkChild(this.position.parent,t))return!0;if(!this.schema.checkChild(this.position.parent,"paragraph")||!this.schema.checkChild("paragraph",t))return!1;this._insertPartialFragment();const e=this.writer.createElement("paragraph");return this.writer.insert(e,this.position),this._setAffectedBoundaries(this.position),this._lastAutoParagraph=e,this.position=this.writer.createPositionAt(e,0),!0}_checkAndSplitToAllowedPosition(t){const e=this._getAllowedIn(this.position.parent,t);if(!e)return!1;for(e!=this.position.parent&&this._insertPartialFragment();e!=this.position.parent;)if(this.position.isAtStart){const t=this.position.parent;this.position=this.writer.createPositionBefore(t),t.isEmpty&&t.parent===e&&this.writer.remove(t)}else if(this.position.isAtEnd)this.position=this.writer.createPositionAfter(this.position.parent);else{const t=this.writer.createPositionAfter(this.position.parent);this._setAffectedBoundaries(this.position),this.writer.split(this.position),this.position=t,this.canMergeWith.add(this.position.nodeAfter)}return!0}_getAllowedIn(t,e){return this.schema.checkChild(t,e)?t:this.schema.isLimit(t)?null:this._getAllowedIn(t.parent,e)}}function id(t,e,n={}){if(e.isCollapsed)return;const o=e.getFirstRange();if("$graveyard"==o.root.rootName)return;const i=t.schema;t.change((t=>{if(!n.doNotResetEntireContent&&function(t,e){const n=t.getLimitElement(e);if(!e.containsEntireContent(n))return!1;const o=e.getFirstRange();if(o.start.parent==o.end.parent)return!1;return t.checkChild(n,"paragraph")}(i,e))return void function(t,e){const n=t.model.schema.getLimitElement(e);t.remove(t.createRangeIn(n)),cd(t,t.createPositionAt(n,0),e)}(t,e);const[r,s]=function(t){const e=t.root.document.model,n=t.start;let o=t.end;if(e.hasContent(t,{ignoreMarkers:!0})){const n=function(t){const e=t.parent,n=e.root.document.model.schema,o=e.getAncestors({parentFirst:!0,includeSelf:!0});for(const t of o){if(n.isLimit(t))return null;if(n.isBlock(t))return t}}(o);if(n&&o.isTouching(e.createPositionAt(n,0))){const n=e.createSelection(t);e.modifySelection(n,{direction:"backward"});const i=n.getLastPosition(),r=e.createRange(i,o);e.hasContent(r,{ignoreMarkers:!0})||(o=i)}}return[td.fromPosition(n,"toPrevious"),td.fromPosition(o,"toNext")]}(o);r.isTouching(s)||t.remove(t.createRange(r,s)),n.leaveUnmerged||(!function(t,e,n){const o=t.model;if(!ad(t.model.schema,e,n))return;const[i,r]=function(t,e){const n=t.getAncestors(),o=e.getAncestors();let i=0;for(;n[i]&&n[i]==o[i];)i++;return[n[i],o[i]]}(e,n);if(!i||!r)return;!o.hasContent(i,{ignoreMarkers:!0})&&o.hasContent(r,{ignoreMarkers:!0})?sd(t,e,n,i.parent):rd(t,e,n,i.parent)}(t,r,s),i.removeDisallowedAttributes(r.parent.getChildren(),t)),ld(t,e,r),!n.doNotAutoparagraph&&function(t,e){const n=t.checkChild(e,"$text"),o=t.checkChild(e,"paragraph");return!n&&o}(i,r)&&cd(t,r,e),r.detach(),s.detach()}))}function rd(t,e,n,o){const i=e.parent,r=n.parent;if(i!=o&&r!=o){for(e=t.createPositionAfter(i),(n=t.createPositionBefore(r)).isEqual(e)||t.insert(r,e),t.merge(e);n.parent.isEmpty;){const e=n.parent;n=t.createPositionBefore(e),t.remove(e)}ad(t.model.schema,e,n)&&rd(t,e,n,o)}}function sd(t,e,n,o){const i=e.parent,r=n.parent;if(i!=o&&r!=o){for(e=t.createPositionAfter(i),(n=t.createPositionBefore(r)).isEqual(e)||t.insert(i,n);e.parent.isEmpty;){const n=e.parent;e=t.createPositionBefore(n),t.remove(n)}n=t.createPositionBefore(r),function(t,e){const n=e.nodeBefore,o=e.nodeAfter;n.name!=o.name&&t.rename(n,o.name);t.clearAttributes(n),t.setAttributes(Object.fromEntries(o.getAttributes()),n),t.merge(e)}(t,n),ad(t.model.schema,e,n)&&sd(t,e,n,o)}}function ad(t,e,n){const o=e.parent,i=n.parent;return o!=i&&(!t.isLimit(o)&&!t.isLimit(i)&&function(t,e,n){const o=new nc(t,e);for(const t of o.getWalker())if(n.isLimit(t.item))return!1;return!0}(e,n,t))}function cd(t,e,n){const o=t.createElement("paragraph");t.insert(o,e),ld(t,n,t.createPositionAt(o,0))}function ld(t,e,n){e instanceof wc?t.setSelection(n):e.setTo(n)}const dd=' ,.?!:;"-()';function ud(t,e){const{isForward:n,walker:o,unit:i,schema:r}=t,{type:s,item:a,nextPosition:c}=e;if("text"==s)return"word"===t.unit?function(t,e){let n=t.position.textNode;if(n){let o=t.position.offset-n.startOffset;for(;!pd(n.data,o,e)&&!md(n,o,e);){t.next();const i=e?t.position.nodeAfter:t.position.nodeBefore;if(i&&i.is("$text")){const o=i.data.charAt(e?0:i.data.length-1);dd.includes(o)||(t.next(),n=t.position.textNode)}o=t.position.offset-n.startOffset}}return t.position}(o,n):function(t,e){const n=t.position.textNode;if(n){const o=n.data;let i=t.position.offset-n.startOffset;for(;Ul(o,i)||"character"==e&&$l(o,i);)t.next(),i=t.position.offset-n.startOffset}return t.position}(o,i);if(s==(n?"elementStart":"elementEnd")){if(r.isSelectable(a))return Qa._createAt(a,n?"after":"before");if(r.checkChild(c,"$text"))return c}else{if(r.isLimit(a))return void o.skip((()=>!0));if(r.checkChild(c,"$text"))return c}}function hd(t,e){const n=t.root,o=Qa._createAt(n,e?"end":0);return e?new nc(t,o):new nc(o,t)}function pd(t,e,n){const o=e+(n?0:-1);return dd.includes(t.charAt(o))}function md(t,e,n){return e===(n?t.endOffset:0)}function gd(t,e){const n=[];Array.from(t.getItems({direction:"backward"})).map((t=>e.createRangeOn(t))).filter((e=>(e.start.isAfter(t.start)||e.start.isEqual(t.start))&&(e.end.isBefore(t.end)||e.end.isEqual(t.end)))).forEach((t=>{n.push(t.start.parent),e.remove(t)})),n.forEach((t=>{let n=t;for(;n.parent&&n.isEmpty;){const t=e.createRangeOn(n);n=n.parent,e.remove(t)}}))}function fd(t){t.document.registerPostFixer((e=>function(t,e){const n=e.document.selection,o=e.schema,i=[];let r=!1;for(const t of n.getRanges()){const e=bd(t,o);e&&!e.isEqual(t)?(i.push(e),r=!0):i.push(t)}r&&t.setSelection(function(t){const e=[...t],n=new Set;let o=1;for(;o!n.has(e)))}(i),{backward:n.isBackward})}(e,t)))}function bd(t,e){return t.isCollapsed?function(t,e){const n=t.start,o=e.getNearestSelectionRange(n);if(!o){const t=n.getAncestors().reverse().find((t=>e.isObject(t)));return t?nc._createOn(t):null}if(!o.isCollapsed)return o;const i=o.start;if(n.isEqual(i))return null;return new nc(i)}(t,e):function(t,e){const{start:n,end:o}=t,i=e.checkChild(n,"$text"),r=e.checkChild(o,"$text"),s=e.getLimitElement(n),a=e.getLimitElement(o);if(s===a){if(i&&r)return null;if(function(t,e,n){const o=t.nodeAfter&&!n.isLimit(t.nodeAfter)||n.checkChild(t,"$text"),i=e.nodeBefore&&!n.isLimit(e.nodeBefore)||n.checkChild(e,"$text");return o||i}(n,o,e)){const t=n.nodeAfter&&e.isSelectable(n.nodeAfter)?null:e.getNearestSelectionRange(n,"forward"),i=o.nodeBefore&&e.isSelectable(o.nodeBefore)?null:e.getNearestSelectionRange(o,"backward"),r=t?t.start:n,s=i?i.end:o;return new nc(r,s)}}const c=s&&!s.is("rootElement"),l=a&&!a.is("rootElement");if(c||l){const t=n.nodeAfter&&o.nodeBefore&&n.nodeAfter.parent===o.nodeBefore.parent,i=c&&(!t||!wd(n.nodeAfter,e)),r=l&&(!t||!wd(o.nodeBefore,e));let d=n,u=o;return i&&(d=Qa._createBefore(kd(s,e))),r&&(u=Qa._createAfter(kd(a,e))),new nc(d,u)}return null}(t,e)}function kd(t,e){let n=t,o=n;for(;e.isLimit(o)&&o.parent;)n=o,o=o.parent;return n}function wd(t,e){return t&&e.isSelectable(t)}class _d{constructor(){this.markers=new Jl,this.document=new Kl(this),this.schema=new Uc,this._pendingChanges=[],this._currentWriter=null,["insertContent","deleteContent","modifySelection","getSelectedContent","applyOperation"].forEach((t=>this.decorate(t))),this.on("applyOperation",((t,e)=>{e[0]._validate()}),{priority:"highest"}),this.schema.register("$root",{isLimit:!0}),this.schema.register("$block",{allowIn:"$root",isBlock:!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(((t,e)=>{if("$marker"===e.name)return!0})),fd(this),this.document.registerPostFixer(Pc)}change(t){try{return 0===this._pendingChanges.length?(this._pendingChanges.push({batch:new pl,callback:t}),this._runPendingChanges()[0]):t(this._currentWriter)}catch(t){s.rethrowUnexpectedError(t,this)}}enqueueChange(t,e){try{t?"function"==typeof t?(e=t,t=new pl):t instanceof pl||(t=new pl(t)):t=new pl,this._pendingChanges.push({batch:t,callback:e}),1==this._pendingChanges.length&&this._runPendingChanges()}catch(t){s.rethrowUnexpectedError(t,this)}}applyOperation(t){t._execute()}insertContent(t,e,n){return function(t,e,n,o){return t.change((i=>{let r;r=n?n instanceof dc||n instanceof wc?n:i.createSelection(n,o):t.document.selection,r.isCollapsed||t.deleteContent(r,{doNotAutoparagraph:!0});const s=new od(t,i,r.anchor);let a;a=e.is("documentFragment")?e.getChildren():[e],s.handleNodes(a);const c=s.getSelectionRange();c&&(r instanceof wc?i.setSelection(c):r.setTo(c));const l=s.getAffectedRange()||t.createRange(r.anchor);return s.destroy(),l}))}(this,t,e,n)}deleteContent(t,e){id(this,t,e)}modifySelection(t,e){!function(t,e,n={}){const o=t.schema,i="backward"!=n.direction,r=n.unit?n.unit:"character",s=e.focus,a=new Ja({boundaries:hd(s,i),singleCharacters:!0,direction:i?"forward":"backward"}),c={walker:a,schema:o,isForward:i,unit:r};let l;for(;l=a.next();){if(l.done)return;const n=ud(c,l.value);if(n)return void(e instanceof wc?t.change((t=>{t.setSelectionFocus(n)})):e.setFocus(n))}}(this,t,e)}getSelectedContent(t){return function(t,e){return t.change((t=>{const n=t.createDocumentFragment(),o=e.getFirstRange();if(!o||o.isCollapsed)return n;const i=o.start.root,r=o.start.getCommonPath(o.end),s=i.getNodeByPath(r);let a;a=o.start.parent==o.end.parent?o:t.createRange(t.createPositionAt(s,o.start.path[r.length]),t.createPositionAt(s,o.end.path[r.length]+1));const c=a.end.offset-a.start.offset;for(const e of a.getItems({shallow:!0}))e.is("$textProxy")?t.appendText(e.data,e.getAttributes(),n):t.append(t.cloneElement(e,!0),n);if(a!=o){const e=o._getTransformedByMove(a.start,t.createPositionAt(n,0),c)[0],i=t.createRange(t.createPositionAt(n,0),e.start);gd(t.createRange(e.end,t.createPositionAt(n,"end")),t),gd(i,t)}return n}))}(this,t)}hasContent(t,e={}){const n=t instanceof Za?nc._createIn(t):t;if(n.isCollapsed)return!1;const{ignoreWhitespaces:o=!1,ignoreMarkers:i=!1}=e;if(!i)for(const t of this.markers.getMarkersIntersectingRange(n))if(t.affectsData)return!0;for(const t of n.getItems())if(this.schema.isContent(t)){if(!t.is("$textProxy"))return!0;if(!o)return!0;if(-1!==t.data.search(/\S/))return!0}return!1}createPositionFromPath(t,e,n){return new Qa(t,e,n)}createPositionAt(t,e){return Qa._createAt(t,e)}createPositionAfter(t){return Qa._createAfter(t)}createPositionBefore(t){return Qa._createBefore(t)}createRange(t,e){return new nc(t,e)}createRangeIn(t){return nc._createIn(t)}createRangeOn(t){return nc._createOn(t)}createSelection(t,e,n){return new dc(t,e,n)}createBatch(t){return new pl(t)}createOperationFromJSON(t){return class{static fromJSON(t,e){return Xl[t.__className].fromJSON(t,e)}}.fromJSON(t,this.document)}destroy(){this.document.destroy(),this.stopListening()}_runPendingChanges(){const t=[];for(this.fire("_beforeChanges");this._pendingChanges.length;){const e=this._pendingChanges[0].batch;this._currentWriter=new zl(this,e);const n=this._pendingChanges[0].callback(this._currentWriter);t.push(n),this.document._handleChangeBlock(this._currentWriter),this._pendingChanges.shift(),this._currentWriter=null}return this.fire("_afterChanges"),t}}he(_d,se);class Cd extends Ia{constructor(t){super(),this.editor=t}set(t,e,n={}){if("string"==typeof e){const t=e;e=(e,n)=>{this.editor.execute(t),n()}}super.set(t,e,n)}}class Ad{constructor(t={}){const e=t.language||this.constructor.defaultConfig&&this.constructor.defaultConfig.language;this._context=t.context||new Fo({language:e}),this._context._addEditor(this,!t.context);const n=Array.from(this.constructor.builtinPlugins||[]);this.config=new yo(t,this.constructor.defaultConfig),this.config.define("plugins",n),this.config.define(this._context._getEditorConfig()),this.plugins=new Bo(this,n,this._context.plugins),this.locale=this._context.locale,this.t=this.locale.t,this.commands=new qc,this.set("state","initializing"),this.once("ready",(()=>this.state="ready"),{priority:"high"}),this.once("destroy",(()=>this.state="destroyed"),{priority:"high"}),this.set("isReadOnly",!1),this.model=new _d;const o=new Si;this.data=new ll(this.model,o),this.editing=new Hc(this.model,o),this.editing.view.document.bind("isReadOnly").to(this),this.conversion=new dl([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 Cd(this),this.keystrokes.listenTo(this.editing.view.document)}initPlugins(){const t=this.config,e=t.get("plugins"),n=t.get("removePlugins")||[],o=t.get("extraPlugins")||[],i=t.get("substitutePlugins")||[];return this.plugins.init(e.concat(o),n,i)}destroy(){let t=Promise.resolve();return"initializing"==this.state&&(t=new Promise((t=>this.once("ready",t)))),t.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(...t){try{return this.commands.execute(...t)}catch(t){s.rethrowUnexpectedError(t,this)}}focus(){this.editing.view.focus()}}he(Ad,se);class vd{constructor(t){this.editor=t,this._components=new Map}*names(){for(const t of this._components.values())yield t.originalName}add(t,e){this._components.set(yd(t),{callback:e,originalName:t})}create(t){if(!this.has(t))throw new s("componentfactory-item-missing",this,{name:t});return this._components.get(yd(t)).callback(this.editor.locale)}has(t){return this._components.has(yd(t))}}function yd(t){return String(t).toLowerCase()}class xd{constructor(t){this.editor=t,this.componentFactory=new vd(t),this.focusTracker=new Pa,this.set("viewportOffset",this._readViewportOffsetFromConfig()),this._editableElementsMap=new Map,this.listenTo(t.editing.view.document,"layoutChanged",(()=>this.update()))}get element(){return null}update(){this.fire("update")}destroy(){this.stopListening(),this.focusTracker.destroy();for(const t of this._editableElementsMap.values())t.ckeditorInstance=null;this._editableElementsMap=new Map}setEditableElement(t,e){this._editableElementsMap.set(t,e),e.ckeditorInstance||(e.ckeditorInstance=this.editor)}getEditableElement(t="main"){return this._editableElementsMap.get(t)}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 t=this.editor,e=t.config.get("ui.viewportOffset");if(e)return e;const n=t.config.get("toolbar.viewportTopOffset");return n?(console.warn("editor-ui-deprecated-viewport-offset-config: The `toolbar.vieportTopOffset` configuration option is deprecated. It will be removed from future CKEditor versions. Use `ui.viewportOffset.top` instead."),{top:n}):{top:0}}}he(xd,se);const Ed={setData(t){this.data.set(t)},getData(t){return this.data.get(t)}},Dd=Ed;class Sd extends No{static get pluginName(){return"PendingActions"}init(){this.set("hasAny",!1),this._actions=new So({idProperty:"_id"}),this._actions.delegate("add","remove").to(this)}add(t){if("string"!=typeof t)throw new s("pendingactions-add-invalid-message",this);const e=Object.create(se);return e.set("message",t),this._actions.add(e),this.hasAny=!0,e}remove(t){this._actions.remove(t),this.hasAny=!!this._actions.length}get first(){return this._actions.get(0)}[Symbol.iterator](){return this._actions[Symbol.iterator]()}}const Bd='',Td={cancel:'',caption:'',check:'',cog:'',eraser:'',lowVision:'',image:'',alignBottom:'',alignMiddle:'',alignTop:'',alignLeft:'',alignCenter:'',alignRight:'',alignJustify:'',objectLeft:'',objectCenter:'',objectRight:'',objectFullWidth:'',objectInline:'',objectBlockLeft:'',objectBlockRight:'',objectSizeFull:'',objectSizeLarge:'',objectSizeSmall:'',objectSizeMedium:'',pencil:'',pilcrow:'',quote:'',threeVerticalDots:Bd};function Pd({emitter:t,activator:e,callback:n,contextElements:o}){t.listenTo(document,"mousedown",((t,i)=>{if(!e())return;const r="function"==typeof i.composedPath?i.composedPath():[];for(const t of o)if(t.contains(i.target)||r.includes(t))return;n()}))}function Id(t){t.set("_isCssTransitionsDisabled",!1),t.disableCssTransitions=()=>{t._isCssTransitionsDisabled=!0},t.enableCssTransitions=()=>{t._isCssTransitionsDisabled=!1},t.extendTemplate({attributes:{class:[t.bindTemplate.if("_isCssTransitionsDisabled","ck-transitions-disabled")]}})}function Rd({view:t}){t.listenTo(t.element,"submit",((e,n)=>{n.preventDefault(),t.fire("submit")}),{useCapture:!0})}class zd extends So{constructor(t=[]){super(t,{idProperty:"viewUid"}),this.on("add",((t,e,n)=>{this._renderViewIntoCollectionParent(e,n)})),this.on("remove",((t,e)=>{e.element&&this._parentElement&&e.element.remove()})),this._parentElement=null}destroy(){this.map((t=>t.destroy()))}setParent(t){this._parentElement=t;for(const t of this)this._renderViewIntoCollectionParent(t)}delegate(...t){if(!t.length||!t.every((t=>"string"==typeof t)))throw new s("ui-viewcollection-delegate-wrong-events",this);return{to:e=>{for(const n of this)for(const o of t)n.delegate(o).to(e);this.on("add",((n,o)=>{for(const n of t)o.delegate(n).to(e)})),this.on("remove",((n,o)=>{for(const n of t)o.stopDelegating(n,e)}))}}}_renderViewIntoCollectionParent(t,e){t.isRendered||t.render(),t.element&&this._parentElement&&this._parentElement.insertBefore(t.element,this._parentElement.children[e])}}var Fd=n(6150),Nd={attributes:{"data-cke":!0}};Nd.setAttributes=is(),Nd.insert=ns().bind(null,"head"),Nd.domAPI=ts(),Nd.insertStyleElement=ss();Qr()(Fd.Z,Nd);Fd.Z&&Fd.Z.locals&&Fd.Z.locals;class Od{constructor(t){this.element=null,this.isRendered=!1,this.locale=t,this.t=t&&t.t,this._viewCollections=new So,this._unboundChildren=this.createCollection(),this._viewCollections.on("add",((e,n)=>{n.locale=t})),this.decorate("render")}get bindTemplate(){return this._bindTemplate?this._bindTemplate:this._bindTemplate=Md.bind(this,this)}createCollection(t){const e=new zd(t);return this._viewCollections.add(e),e}registerChild(t){Do(t)||(t=[t]);for(const e of t)this._unboundChildren.add(e)}deregisterChild(t){Do(t)||(t=[t]);for(const e of t)this._unboundChildren.remove(e)}setTemplate(t){this.template=new Md(t)}extendTemplate(t){Md.extend(this.template,t)}render(){if(this.isRendered)throw new s("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((t=>t.destroy())),this.template&&this.template._revertData&&this.template.revert(this.element)}}he(Od,Es),he(Od,se);class Md{constructor(t){Object.assign(this,Kd(Gd(t))),this._isRendered=!1,this._revertData=null}render(){const t=this._renderNode({intoFragment:!0});return this._isRendered=!0,t}apply(t){return this._revertData={children:[],bindings:[],attributes:{}},this._renderNode({node:t,isApplying:!0,revertData:this._revertData}),t}revert(t){if(!this._revertData)throw new s("ui-template-revert-not-applied",[this,t]);this._revertTemplateFromNode(t,this._revertData)}*getViews(){yield*function*t(e){if(e.children)for(const n of e.children)tu(n)?yield n:eu(n)&&(yield*t(n))}(this)}static bind(t,e){return{to:(n,o)=>new Ld({eventNameOrFunction:n,attribute:n,observable:t,emitter:e,callback:o}),if:(n,o,i)=>new Hd({observable:t,emitter:e,attribute:n,valueIfTrue:o,callback:i})}}static extend(t,e){if(t._isRendered)throw new s("template-extend-render",[this,t]);Qd(t,Kd(Gd(e)))}_renderNode(t){let e;if(e=t.node?this.tag&&this.text:this.tag?this.text:!this.text,e)throw new s("ui-template-wrong-syntax",this);return this.text?this._renderText(t):this._renderElement(t)}_renderElement(t){let e=t.node;return e||(e=t.node=document.createElementNS(this.ns||"http://www.w3.org/1999/xhtml",this.tag)),this._renderAttributes(t),this._renderElementChildren(t),this._setUpListeners(t),e}_renderText(t){let e=t.node;return e?t.revertData.text=e.textContent:e=t.node=document.createTextNode(""),qd(this.text)?this._bindToObservable({schema:this.text,updater:jd(e),data:t}):e.textContent=this.text.join(""),e}_renderAttributes(t){let e,n,o,i;if(!this.attributes)return;const r=t.node,s=t.revertData;for(e in this.attributes)if(o=r.getAttribute(e),n=this.attributes[e],s&&(s.attributes[e]=o),i=y(n[0])&&n[0].ns?n[0].ns:null,qd(n)){const a=i?n[0].value:n;s&&ou(e)&&a.unshift(o),this._bindToObservable({schema:a,updater:Ud(r,e,i),data:t})}else"style"==e&&"string"!=typeof n[0]?this._renderStyleAttribute(n[0],t):(s&&o&&ou(e)&&n.unshift(o),n=n.map((t=>t&&t.value||t)).reduce(((t,e)=>t.concat(e)),[]).reduce(Jd,""),Xd(n)||r.setAttributeNS(i,e,n))}_renderStyleAttribute(t,e){const n=e.node;for(const o in t){const i=t[o];qd(i)?this._bindToObservable({schema:[i],updater:$d(n,o),data:e}):n.style[o]=i}}_renderElementChildren(t){const e=t.node,n=t.intoFragment?document.createDocumentFragment():e,o=t.isApplying;let i=0;for(const r of this.children)if(nu(r)){if(!o){r.setParent(e);for(const t of r)n.appendChild(t.element)}}else if(tu(r))o||(r.isRendered||r.render(),n.appendChild(r.element));else if(Jr(r))n.appendChild(r);else if(o){const e={children:[],bindings:[],attributes:{}};t.revertData.children.push(e),r._renderNode({node:n.childNodes[i++],isApplying:!0,revertData:e})}else n.appendChild(r.render());t.intoFragment&&e.appendChild(n)}_setUpListeners(t){if(this.eventListeners)for(const e in this.eventListeners){const n=this.eventListeners[e].map((n=>{const[o,i]=e.split("@");return n.activateDomEventListener(o,i,t)}));t.revertData&&t.revertData.bindings.push(n)}}_bindToObservable({schema:t,updater:e,data:n}){const o=n.revertData;Wd(t,e,n);const i=t.filter((t=>!Xd(t))).filter((t=>t.observable)).map((o=>o.activateAttributeListener(t,e,n)));o&&o.bindings.push(i)}_revertTemplateFromNode(t,e){for(const t of e.bindings)for(const e of t)e();if(e.text)t.textContent=e.text;else{for(const n in e.attributes){const o=e.attributes[n];null===o?t.removeAttribute(n):t.setAttribute(n,o)}for(let n=0;nWd(t,e,n);return this.emitter.listenTo(this.observable,"change:"+this.attribute,o),()=>{this.emitter.stopListening(this.observable,"change:"+this.attribute,o)}}}class Ld extends Vd{activateDomEventListener(t,e,n){const o=(t,n)=>{e&&!n.target.matches(e)||("function"==typeof this.eventNameOrFunction?this.eventNameOrFunction(n):this.observable.fire(this.eventNameOrFunction,n))};return this.emitter.listenTo(n.node,t,o),()=>{this.emitter.stopListening(n.node,t,o)}}}class Hd extends Vd{getValue(t){return!Xd(super.getValue(t))&&(this.valueIfTrue||!0)}}function qd(t){return!!t&&(t.value&&(t=t.value),Array.isArray(t)?t.some(qd):t instanceof Vd)}function Wd(t,e,{node:n}){let o=function(t,e){return t.map((t=>t instanceof Vd?t.getValue(e):t))}(t,n);o=1==t.length&&t[0]instanceof Hd?o[0]:o.reduce(Jd,""),Xd(o)?e.remove():e.set(o)}function jd(t){return{set(e){t.textContent=e},remove(){t.textContent=""}}}function Ud(t,e,n){return{set(o){t.setAttributeNS(n,e,o)},remove(){t.removeAttributeNS(n,e)}}}function $d(t,e){return{set(n){t.style[e]=n},remove(){t.style[e]=null}}}function Gd(t){return Ao(t,(t=>{if(t&&(t instanceof Vd||eu(t)||tu(t)||nu(t)))return t}))}function Kd(t){if("string"==typeof t?t=function(t){return{text:[t]}}(t):t.text&&function(t){t.text=To(t.text)}(t),t.on&&(t.eventListeners=function(t){for(const e in t)Zd(t,e);return t}(t.on),delete t.on),!t.text){t.attributes&&function(t){for(const e in t)t[e].value&&(t[e].value=To(t[e].value)),Zd(t,e)}(t.attributes);const e=[];if(t.children)if(nu(t.children))e.push(t.children);else for(const n of t.children)eu(n)||tu(n)||Jr(n)?e.push(n):e.push(new Md(n));t.children=e}return t}function Zd(t,e){t[e]=To(t[e])}function Jd(t,e){return Xd(e)?t:Xd(t)?e:`${t} ${e}`}function Yd(t,e){for(const n in e)t[n]?t[n].push(...e[n]):t[n]=e[n]}function Qd(t,e){if(e.attributes&&(t.attributes||(t.attributes={}),Yd(t.attributes,e.attributes)),e.eventListeners&&(t.eventListeners||(t.eventListeners={}),Yd(t.eventListeners,e.eventListeners)),e.text&&t.text.push(...e.text),e.children&&e.children.length){if(t.children.length!=e.children.length)throw new s("ui-template-extend-children-mismatch",t);let n=0;for(const o of e.children)Qd(t.children[n++],o)}}function Xd(t){return!t&&0!==t}function tu(t){return t instanceof Od}function eu(t){return t instanceof Md}function nu(t){return t instanceof zd}function ou(t){return"class"==t||"style"==t}class iu extends zd{constructor(t,e=[]){super(e),this.locale=t}attachToDom(){this._bodyCollectionContainer=new Md({tag:"div",attributes:{class:["ck","ck-reset_all","ck-body","ck-rounded-corners"],dir:this.locale.uiLanguageDirection},children:this}).render();let t=document.querySelector(".ck-body-wrapper");t||(t=_a(document,"div",{class:"ck-body-wrapper"}),document.body.appendChild(t)),t.appendChild(this._bodyCollectionContainer)}detachFromDom(){super.destroy(),this._bodyCollectionContainer&&this._bodyCollectionContainer.remove();const t=document.querySelector(".ck-body-wrapper");t&&0==t.childElementCount&&t.remove()}}var ru=n(1174),su={attributes:{"data-cke":!0}};su.setAttributes=is(),su.insert=ns().bind(null,"head"),su.domAPI=ts(),su.insertStyleElement=ss();Qr()(ru.Z,su);ru.Z&&ru.Z.locals&&ru.Z.locals;class au extends Od{constructor(){super();const t=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:t.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 t=(new DOMParser).parseFromString(this.content.trim(),"image/svg+xml").querySelector("svg"),e=t.getAttribute("viewBox");for(e&&(this.viewBox=e),this.element.innerHTML="";t.childNodes.length>0;)this.element.appendChild(t.childNodes[0])}}_colorFillPaths(){this.fillColor&&this.element.querySelectorAll(".ck-icon__fill").forEach((t=>{t.style.fill=this.fillColor}))}}var cu=n(9948),lu={attributes:{"data-cke":!0}};lu.setAttributes=is(),lu.insert=ns().bind(null,"head"),lu.domAPI=ts(),lu.insertStyleElement=ss();Qr()(cu.Z,lu);cu.Z&&cu.Z.locals&&cu.Z.locals;class du extends Od{constructor(t){super(t),this.set("text",""),this.set("position","s");const e=this.bindTemplate;this.setTemplate({tag:"span",attributes:{class:["ck","ck-tooltip",e.to("position",(t=>"ck-tooltip_"+t)),e.if("text","ck-hidden",(t=>!t.trim()))]},children:[{tag:"span",attributes:{class:["ck","ck-tooltip__text"]},children:[{text:e.to("text")}]}]})}}var uu=n(4499),hu={attributes:{"data-cke":!0}};hu.setAttributes=is(),hu.insert=ns().bind(null,"head"),hu.domAPI=ts(),hu.insertStyleElement=ss();Qr()(uu.Z,hu);uu.Z&&uu.Z.locals&&uu.Z.locals;class pu extends Od{constructor(t){super(t);const e=this.bindTemplate,n=i();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(n),this.iconView=new au,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",e.to("class"),e.if("isEnabled","ck-disabled",(t=>!t)),e.if("isVisible","ck-hidden",(t=>!t)),e.to("isOn",(t=>t?"ck-on":"ck-off")),e.if("withText","ck-button_with-text"),e.if("withKeystroke","ck-button_with-keystroke")],type:e.to("type",(t=>t||"button")),tabindex:e.to("tabindex"),"aria-labelledby":`ck-editor__aria-label_${n}`,"aria-disabled":e.if("isEnabled",!0,(t=>!t)),"aria-pressed":e.to("isOn",(t=>!!this.isToggleable&&String(t)))},children:this.children,on:{mousedown:e.to((t=>{t.preventDefault()})),click:e.to((t=>{this.isEnabled?this.fire("execute"):t.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 t=new du;return t.bind("text").to(this,"_tooltipString"),t.bind("position").to(this,"tooltipPosition"),t}_createLabelView(t){const e=new Od,n=this.bindTemplate;return e.setTemplate({tag:"span",attributes:{class:["ck","ck-button__label"],style:n.to("labelStyle"),id:`ck-editor__aria-label_${t}`},children:[{text:this.bindTemplate.to("label")}]}),e}_createKeystrokeView(){const t=new Od;return t.setTemplate({tag:"span",attributes:{class:["ck","ck-button__keystroke"]},children:[{text:this.bindTemplate.to("keystroke",(t=>gr(t)))}]}),t}_getTooltipString(t,e,n){return t?"string"==typeof t?t:(n&&(n=gr(n)),t instanceof Function?t(e,n):`${e}${n?` (${n})`:""}`):""}}var mu=n(9681),gu={attributes:{"data-cke":!0}};gu.setAttributes=is(),gu.insert=ns().bind(null,"head"),gu.domAPI=ts(),gu.insertStyleElement=ss();Qr()(mu.Z,gu);mu.Z&&mu.Z.locals&&mu.Z.locals;class fu extends pu{constructor(t){super(t),this.isToggleable=!0,this.toggleSwitchView=this._createToggleView(),this.extendTemplate({attributes:{class:"ck-switchbutton"}})}render(){super.render(),this.children.add(this.toggleSwitchView)}_createToggleView(){const t=new Od;return t.setTemplate({tag:"span",attributes:{class:["ck","ck-button__toggle"]},children:[{tag:"span",attributes:{class:["ck","ck-button__toggle__inner"]}}]}),t}}function bu(t,e){const n=t.t,o={Black:n("Black"),"Dim grey":n("Dim grey"),Grey:n("Grey"),"Light grey":n("Light grey"),White:n("White"),Red:n("Red"),Orange:n("Orange"),Yellow:n("Yellow"),"Light green":n("Light green"),Green:n("Green"),Aquamarine:n("Aquamarine"),Turquoise:n("Turquoise"),"Light blue":n("Light blue"),Blue:n("Blue"),Purple:n("Purple")};return e.map((t=>{const e=o[t.label];return e&&e!=t.label&&(t.label=e),t}))}function ku(t){return t.map(wu).filter((t=>!!t))}function wu(t){return"string"==typeof t?{model:t,label:t,hasBorder:!1,view:{name:"span",styles:{color:t}}}:{model:t.color,label:t.label||t.color,hasBorder:void 0!==t.hasBorder&&t.hasBorder,view:{name:"span",styles:{color:`${t.color}`}}}}class _u extends pu{constructor(t){super(t);const e=this.bindTemplate;this.set("color"),this.set("hasBorder"),this.icon='',this.extendTemplate({attributes:{style:{backgroundColor:e.to("color")},class:["ck","ck-color-grid__tile",e.if("hasBorder","ck-color-table__color-tile_bordered")]}})}render(){super.render(),this.iconView.fillColor="hsl(0, 0%, 100%)"}}function Cu(t){return!!(t&&t.getClientRects&&t.getClientRects().length)}class Au{constructor(t){if(Object.assign(this,t),t.actions&&t.keystrokeHandler)for(const e in t.actions){let n=t.actions[e];"string"==typeof n&&(n=[n]);for(const o of n)t.keystrokeHandler.set(o,((t,n)=>{this[e](),n()}))}}get first(){return this.focusables.find(vu)||null}get last(){return this.focusables.filter(vu).slice(-1)[0]||null}get next(){return this._getFocusableItem(1)}get previous(){return this._getFocusableItem(-1)}get current(){let t=null;return null===this.focusTracker.focusedElement?null:(this.focusables.find(((e,n)=>{const o=e.element===this.focusTracker.focusedElement;return o&&(t=n),o})),t)}focusFirst(){this._focus(this.first)}focusLast(){this._focus(this.last)}focusNext(){this._focus(this.next)}focusPrevious(){this._focus(this.previous)}_focus(t){t&&t.focus()}_getFocusableItem(t){const e=this.current,n=this.focusables.length;if(!n)return null;if(null===e)return this[1===t?"first":"last"];let o=(e+n+t)%n;do{const e=this.focusables.get(o);if(vu(e))return e;o=(o+n+t)%n}while(o!==e);return null}}function vu(t){return!(!t.focus||!Cu(t.element))}var yu=n(4923),xu={attributes:{"data-cke":!0}};xu.setAttributes=is(),xu.insert=ns().bind(null,"head"),xu.domAPI=ts(),xu.insertStyleElement=ss();Qr()(yu.Z,xu);yu.Z&&yu.Z.locals&&yu.Z.locals;class Eu extends Od{constructor(t,e){super(t);const n=e&&e.colorDefinitions||[],o={};e&&e.columns&&(o.gridTemplateColumns=`repeat( ${e.columns}, 1fr)`),this.set("selectedColor"),this.items=this.createCollection(),this.focusTracker=new Pa,this.keystrokes=new Ia,this._focusCycler=new Au({focusables:this.items,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"arrowleft",focusNext:"arrowright"}}),this.items.on("add",((t,e)=>{e.isOn=e.color===this.selectedColor})),n.forEach((t=>{const e=new _u;e.set({color:t.color,label:t.label,tooltip:!0,hasBorder:t.options.hasBorder}),e.on("execute",(()=>{this.fire("execute",{value:t.color,hasBorder:t.options.hasBorder,label:t.label})})),this.items.add(e)})),this.setTemplate({tag:"div",children:this.items,attributes:{class:["ck","ck-color-grid"],style:o}}),this.on("change:selectedColor",((t,e,n)=>{for(const t of this.items)t.isOn=t.color===n}))}focus(){this.items.length&&this.items.first.focus()}focusLast(){this.items.length&&this.items.last.focus()}render(){super.render();for(const t of this.items)this.focusTracker.add(t.element);this.items.on("add",((t,e)=>{this.focusTracker.add(e.element)})),this.items.on("remove",((t,e)=>{this.focusTracker.remove(e.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}}const Du='';class Su extends pu{constructor(t){super(t),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 t=new au;return t.content=Du,t.extendTemplate({attributes:{class:"ck-dropdown__arrow"}}),t}}var Bu=n(66),Tu={attributes:{"data-cke":!0}};Tu.setAttributes=is(),Tu.insert=ns().bind(null,"head"),Tu.domAPI=ts(),Tu.insertStyleElement=ss();Qr()(Bu.Z,Tu);Bu.Z&&Bu.Z.locals&&Bu.Z.locals;class Pu extends Od{constructor(t){super(t);const e=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 Ia,this.focusTracker=new Pa,this.setTemplate({tag:"div",attributes:{class:["ck","ck-splitbutton",e.to("class"),e.if("isVisible","ck-hidden",(t=>!t)),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",((t,e)=>{this.focusTracker.focusedElement===this.actionView.element&&(this.arrowView.focus(),e())})),this.keystrokes.set("arrowleft",((t,e)=>{this.focusTracker.focusedElement===this.arrowView.element&&(this.actionView.focus(),e())}))}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this.actionView.focus()}_createActionView(){const t=new pu;return t.bind("icon","isEnabled","isOn","isToggleable","keystroke","label","tabindex","tooltip","tooltipPosition","type","withText").to(this),t.extendTemplate({attributes:{class:"ck-splitbutton__action"}}),t.delegate("execute").to(this),t}_createArrowView(){const t=new pu,e=t.bindTemplate;return t.icon=Du,t.extendTemplate({attributes:{class:"ck-splitbutton__arrow","aria-haspopup":!0,"aria-expanded":e.to("isOn",(t=>String(t)))}}),t.bind("isEnabled").to(this),t.delegate("execute").to(this,"open"),t}}class Iu extends Od{constructor(t){super(t);const e=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",e.to("position",(t=>`ck-dropdown__panel_${t}`)),e.if("isVisible","ck-dropdown__panel-visible")]},children:this.children,on:{selectstart:e.to((t=>t.preventDefault()))}})}focus(){this.children.length&&this.children.first.focus()}focusLast(){if(this.children.length){const t=this.children.last;"function"==typeof t.focusLast?t.focusLast():t.focus()}}}var Ru=n(3488),zu={attributes:{"data-cke":!0}};zu.setAttributes=is(),zu.insert=ns().bind(null,"head"),zu.domAPI=ts(),zu.insertStyleElement=ss();Qr()(Ru.Z,zu);Ru.Z&&Ru.Z.locals&&Ru.Z.locals;function Fu({element:t,target:e,positions:n,limiter:o,fitInViewport:i,viewportOffsetConfig:r}){M(e)&&(e=e()),M(o)&&(o=o());const s=function(t){return t&&t.parentNode?t.offsetParent===ps.document.body?null:t.offsetParent:null}(t),a=new ya(t);let c;const l={targetRect:new ya(e),elementRect:a,positionedElementAncestor:s};if(o||i){const t=o&&new ya(o).getVisible(),e=i&&function(t){t=Object.assign({top:0,bottom:0,left:0,right:0},t);const e=new ya(ps.window);return e.top+=t.top,e.height-=t.top,e.bottom-=t.bottom,e.height-=t.bottom,e}(r);Object.assign(l,{limiterRect:t,viewportRect:e}),c=function(t,e){const{elementRect:n}=e,o=n.getArea(),i=t.map((t=>new Ou(t,e))).filter((t=>!!t.name));let r=0,s=null;for(const t of i){const{_limiterIntersectionArea:e,_viewportIntersectionArea:n}=t;if(e===o)return t;const i=n**2+e**2;i>r&&(r=i,s=t)}return s}(n,l)||new Ou(n[0],l)}else c=new Ou(n[0],l);return c}function Nu(t){const{scrollX:e,scrollY:n}=ps.window;return t.clone().moveBy(e,n)}class Ou{constructor(t,e){const n=t(e.targetRect,e.elementRect,e.viewportRect);if(!n)return;const{left:o,top:i,name:r,config:s}=n;Object.assign(this,{name:r,config:s}),this._positioningFunctionCorrdinates={left:o,top:i},this._options=e}get left(){return this._absoluteRect.left}get top(){return this._absoluteRect.top}get _limiterIntersectionArea(){const t=this._options.limiterRect;if(t){const e=this._options.viewportRect;if(!e)return t.getIntersectionArea(this._rect);{const n=t.getIntersection(e);if(n)return n.getIntersectionArea(this._rect)}}return 0}get _viewportIntersectionArea(){const t=this._options.viewportRect;return t?t.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=Nu(this._rect),this._options.positionedElementAncestor&&function(t,e){const n=Nu(new ya(e)),o=Aa(e);let i=0,r=0;i-=n.left,r-=n.top,i+=e.scrollLeft,r+=e.scrollTop,i-=o.left,r-=o.top,t.moveBy(i,r)}(this._cachedAbsoluteRect,this._options.positionedElementAncestor)),this._cachedAbsoluteRect}}class Mu extends Od{constructor(t,e,n){super(t);const o=this.bindTemplate;this.buttonView=e,this.panelView=n,this.set("isOpen",!1),this.set("isEnabled",!0),this.set("class"),this.set("id"),this.set("panelPosition","auto"),this.keystrokes=new Ia,this.setTemplate({tag:"div",attributes:{class:["ck","ck-dropdown",o.to("class"),o.if("isEnabled","ck-disabled",(t=>!t))],id:o.to("id"),"aria-describedby":o.to("ariaDescribedById")},children:[e,n]}),e.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=Mu._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 t=(t,e)=>{this.isOpen&&(this.buttonView.focus(),this.isOpen=!1,e())};this.keystrokes.set("arrowdown",((t,e)=>{this.buttonView.isEnabled&&!this.isOpen&&(this.isOpen=!0,e())})),this.keystrokes.set("arrowright",((t,e)=>{this.isOpen&&e()})),this.keystrokes.set("arrowleft",t),this.keystrokes.set("esc",t)}focus(){this.buttonView.focus()}get _panelPositions(){const{south:t,north:e,southEast:n,southWest:o,northEast:i,northWest:r,southMiddleEast:s,southMiddleWest:a,northMiddleEast:c,northMiddleWest:l}=Mu.defaultPanelPositions;return"rtl"!==this.locale.uiLanguageDirection?[n,o,s,a,t,i,r,c,l,e]:[o,n,a,s,t,r,i,l,c,e]}}Mu.defaultPanelPositions={south:(t,e)=>({top:t.bottom,left:t.left-(e.width-t.width)/2,name:"s"}),southEast:t=>({top:t.bottom,left:t.left,name:"se"}),southWest:(t,e)=>({top:t.bottom,left:t.left-e.width+t.width,name:"sw"}),southMiddleEast:(t,e)=>({top:t.bottom,left:t.left-(e.width-t.width)/4,name:"sme"}),southMiddleWest:(t,e)=>({top:t.bottom,left:t.left-3*(e.width-t.width)/4,name:"smw"}),north:(t,e)=>({top:t.top-e.height,left:t.left-(e.width-t.width)/2,name:"n"}),northEast:(t,e)=>({top:t.top-e.height,left:t.left,name:"ne"}),northWest:(t,e)=>({top:t.top-e.height,left:t.left-e.width+t.width,name:"nw"}),northMiddleEast:(t,e)=>({top:t.top-e.height,left:t.left-(e.width-t.width)/4,name:"nme"}),northMiddleWest:(t,e)=>({top:t.top-e.height,left:t.left-3*(e.width-t.width)/4,name:"nmw"})},Mu._getOptimalPosition=Fu;class Vu extends Od{constructor(t){super(t),this.setTemplate({tag:"span",attributes:{class:["ck","ck-toolbar__separator"]}})}}class Lu extends Od{constructor(t){super(t),this.setTemplate({tag:"span",attributes:{class:["ck","ck-toolbar__line-break"]}})}}var Hu=n(5571),qu={attributes:{"data-cke":!0}};qu.setAttributes=is(),qu.insert=ns().bind(null,"head"),qu.domAPI=ts(),qu.insertStyleElement=ss();Qr()(Hu.Z,qu);Hu.Z&&Hu.Z.locals&&Hu.Z.locals;class Wu extends Od{constructor(t,e){super(t);const n=this.bindTemplate,o=this.t;this.options=e||{},this.set("ariaLabel",o("Editor toolbar")),this.set("maxWidth","auto"),this.items=this.createCollection(),this.focusTracker=new Pa,this.keystrokes=new Ia,this.set("class"),this.set("isCompact",!1),this.itemsView=new ju(t),this.children=this.createCollection(),this.children.add(this.itemsView),this.focusables=this.createCollection();const i="rtl"===t.uiLanguageDirection;this._focusCycler=new Au({focusables:this.focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:[i?"arrowright":"arrowleft","arrowup"],focusNext:[i?"arrowleft":"arrowright","arrowdown"]}});const r=["ck","ck-toolbar",n.to("class"),n.if("isCompact","ck-toolbar_compact")];var s;this.options.shouldGroupWhenFull&&this.options.isFloating&&r.push("ck-toolbar_floating"),this.setTemplate({tag:"div",attributes:{class:r,role:"toolbar","aria-label":n.to("ariaLabel"),style:{maxWidth:n.to("maxWidth")}},children:this.children,on:{mousedown:(s=this,s.bindTemplate.to((t=>{t.target===s.element&&t.preventDefault()})))}}),this._behavior=this.options.shouldGroupWhenFull?new $u(this):new Uu(this)}render(){super.render();for(const t of this.items)this.focusTracker.add(t.element);this.items.on("add",((t,e)=>{this.focusTracker.add(e.element)})),this.items.on("remove",((t,e)=>{this.focusTracker.remove(e.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(t,e){const n=function(t){return Array.isArray(t)?{items:t,removeItems:[]}:t?Object.assign({items:[],removeItems:[]},t):{items:[],removeItems:[]}}(t),o=n.items.filter(((t,o,i)=>"|"===t||-1===n.removeItems.indexOf(t)&&("-"===t?!this.options.shouldGroupWhenFull||(a("toolbarview-line-break-ignored-when-grouping-items",i),!1):!!e.has(t)||(a("toolbarview-item-unavailable",{name:t}),!1)))),i=this._cleanSeparators(o).map((t=>"|"===t?new Vu:"-"===t?new Lu:e.create(t)));this.items.addMany(i)}_cleanSeparators(t){const e=t=>"-"!==t&&"|"!==t,n=t.length,o=t.findIndex(e),i=n-t.slice().reverse().findIndex(e);return t.slice(o,i).filter(((t,n,o)=>{if(e(t))return!0;return!(n>0&&o[n-1]===t)}))}}class ju extends Od{constructor(t){super(t),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-toolbar__items"]},children:this.children})}}class Uu{constructor(t){const e=t.bindTemplate;t.set("isVertical",!1),t.itemsView.children.bindTo(t.items).using((t=>t)),t.focusables.bindTo(t.items).using((t=>t)),t.extendTemplate({attributes:{class:[e.if("isVertical","ck-toolbar_vertical")]}})}render(){}destroy(){}}class $u{constructor(t){this.view=t,this.viewChildren=t.children,this.viewFocusables=t.focusables,this.viewItemsView=t.itemsView,this.viewFocusTracker=t.focusTracker,this.viewLocale=t.locale,this.ungroupedItems=t.createCollection(),this.groupedItems=t.createCollection(),this.groupedItemsDropdown=this._createGroupedItemsDropdown(),this.resizeObserver=null,this.cachedPadding=null,this.shouldUpdateGroupingOnNextResize=!1,t.itemsView.children.bindTo(this.ungroupedItems).using((t=>t)),this.ungroupedItems.on("add",this._updateFocusCycleableItems.bind(this)),this.ungroupedItems.on("remove",this._updateFocusCycleableItems.bind(this)),t.children.on("add",this._updateFocusCycleableItems.bind(this)),t.children.on("remove",this._updateFocusCycleableItems.bind(this)),t.items.on("change",((t,e)=>{const n=e.index;for(const t of e.removed)n>=this.ungroupedItems.length?this.groupedItems.remove(t):this.ungroupedItems.remove(t);for(let t=n;tthis.ungroupedItems.length?this.groupedItems.add(o,t-this.ungroupedItems.length):this.ungroupedItems.add(o,t)}this._updateGrouping()})),t.extendTemplate({attributes:{class:["ck-toolbar_grouping"]}})}render(t){this.viewElement=t.element,this._enableGroupingOnResize(),this._enableGroupingOnMaxWidthChange(t)}destroy(){this.groupedItemsDropdown.destroy(),this.resizeObserver.destroy()}_updateGrouping(){if(!this.viewElement.ownerDocument.body.contains(this.viewElement))return;if(!Cu(this.viewElement))return void(this.shouldUpdateGroupingOnNextResize=!0);const t=this.groupedItems.length;let e;for(;this._areItemsOverflowing;)this._groupLastItem(),e=!0;if(!e&&this.groupedItems.length){for(;this.groupedItems.length&&!this._areItemsOverflowing;)this._ungroupFirstItem();this._areItemsOverflowing&&this._groupLastItem()}this.groupedItems.length!==t&&this.view.fire("groupedItemsUpdate")}get _areItemsOverflowing(){if(!this.ungroupedItems.length)return!1;const t=this.viewElement,e=this.viewLocale.uiLanguageDirection,n=new ya(t.lastChild),o=new ya(t);if(!this.cachedPadding){const n=ps.window.getComputedStyle(t),o="ltr"===e?"paddingRight":"paddingLeft";this.cachedPadding=Number.parseInt(n[o])}return"ltr"===e?n.right>o.right-this.cachedPadding:n.left{t&&t===e.contentRect.width&&!this.shouldUpdateGroupingOnNextResize||(this.shouldUpdateGroupingOnNextResize=!1,this._updateGrouping(),t=e.contentRect.width)})),this._updateGrouping()}_enableGroupingOnMaxWidthChange(t){t.on("change:maxWidth",(()=>{this._updateGrouping()}))}_groupLastItem(){this.groupedItems.length||(this.viewChildren.add(new Vu),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 t=this.viewLocale,e=t.t,n=nh(t);return n.class="ck-toolbar__grouped-dropdown",n.panelPosition="ltr"===t.uiLanguageDirection?"sw":"se",oh(n,[]),n.buttonView.set({label:e("Show more items"),tooltip:!0,tooltipPosition:"rtl"===t.uiLanguageDirection?"se":"sw",icon:Bd}),n.toolbarView.items.bindTo(this.groupedItems).using((t=>t)),n}_updateFocusCycleableItems(){this.viewFocusables.clear(),this.ungroupedItems.map((t=>{this.viewFocusables.add(t)})),this.groupedItems.length&&this.viewFocusables.add(this.groupedItemsDropdown)}}var Gu=n(1162),Ku={attributes:{"data-cke":!0}};Ku.setAttributes=is(),Ku.insert=ns().bind(null,"head"),Ku.domAPI=ts(),Ku.insertStyleElement=ss();Qr()(Gu.Z,Ku);Gu.Z&&Gu.Z.locals&&Gu.Z.locals;class Zu extends Od{constructor(){super(),this.items=this.createCollection(),this.focusTracker=new Pa,this.keystrokes=new Ia,this._focusCycler=new Au({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 t of this.items)this.focusTracker.add(t.element);this.items.on("add",((t,e)=>{this.focusTracker.add(e.element)})),this.items.on("remove",((t,e)=>{this.focusTracker.remove(e.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}}class Ju extends Od{constructor(t){super(t),this.children=this.createCollection(),this.setTemplate({tag:"li",attributes:{class:["ck","ck-list__item"]},children:this.children})}focus(){this.children.first.focus()}}class Yu extends Od{constructor(t){super(t),this.setTemplate({tag:"li",attributes:{class:["ck","ck-list__separator"]}})}}var Qu=n(5075),Xu={attributes:{"data-cke":!0}};Xu.setAttributes=is(),Xu.insert=ns().bind(null,"head"),Xu.domAPI=ts(),Xu.insertStyleElement=ss();Qr()(Qu.Z,Xu);Qu.Z&&Qu.Z.locals&&Qu.Z.locals;var th=n(6875),eh={attributes:{"data-cke":!0}};eh.setAttributes=is(),eh.insert=ns().bind(null,"head"),eh.domAPI=ts(),eh.insertStyleElement=ss();Qr()(th.Z,eh);th.Z&&th.Z.locals&&th.Z.locals;function nh(t,e=Su){const n=new e(t),o=new Iu(t),i=new Mu(t,n,o);return n.bind("isEnabled").to(i),n instanceof Su?n.bind("isOn").to(i,"isOpen"):n.arrowView.bind("isOn").to(i,"isOpen"),function(t){(function(t){t.on("render",(()=>{Pd({emitter:t,activator:()=>t.isOpen,callback:()=>{t.isOpen=!1},contextElements:[t.element]})}))})(t),function(t){t.on("execute",(e=>{e.source instanceof fu||(t.isOpen=!1)}))}(t),function(t){t.keystrokes.set("arrowdown",((e,n)=>{t.isOpen&&(t.panelView.focus(),n())})),t.keystrokes.set("arrowup",((e,n)=>{t.isOpen&&(t.panelView.focusLast(),n())}))}(t)}(i),i}function oh(t,e){const n=t.locale,o=n.t,i=t.toolbarView=new Wu(n);i.set("ariaLabel",o("Dropdown toolbar")),t.extendTemplate({attributes:{class:["ck-toolbar-dropdown"]}}),e.map((t=>i.items.add(t))),t.panelView.children.add(i),i.items.delegate("execute").to(t)}function ih(t,e){const n=t.locale,o=t.listView=new Zu(n);o.items.bindTo(e).using((({type:t,model:e})=>{if("separator"===t)return new Yu(n);if("button"===t||"switchbutton"===t){const o=new Ju(n);let i;return i="button"===t?new pu(n):new fu(n),i.bind(...Object.keys(e)).to(e),i.delegate("execute").to(o),o.children.add(i),o}})),t.panelView.children.add(o),o.items.delegate("execute").to(t)}var rh=n(4547),sh={attributes:{"data-cke":!0}};sh.setAttributes=is(),sh.insert=ns().bind(null,"head"),sh.domAPI=ts(),sh.insertStyleElement=ss();Qr()(rh.Z,sh);rh.Z&&rh.Z.locals&&rh.Z.locals;class ah extends Od{constructor(t){super(t),this.body=new iu(t)}render(){super.render(),this.body.attachToDom()}destroy(){return this.body.detachFromDom(),super.destroy()}}var ch=n(2751),lh={attributes:{"data-cke":!0}};lh.setAttributes=is(),lh.insert=ns().bind(null,"head"),lh.domAPI=ts(),lh.insertStyleElement=ss();Qr()(ch.Z,lh);ch.Z&&ch.Z.locals&&ch.Z.locals;class dh extends Od{constructor(t){super(t),this.set("text"),this.set("for"),this.id=`ck-editor__label_${i()}`;const e=this.bindTemplate;this.setTemplate({tag:"label",attributes:{class:["ck","ck-label"],id:this.id,for:e.to("for")},children:[{text:e.to("text")}]})}}class uh extends Od{constructor(t,e,n){super(t),this.setTemplate({tag:"div",attributes:{class:["ck","ck-content","ck-editor__editable","ck-rounded-corners"],lang:t.contentLanguage,dir:t.contentLanguageDirection}}),this.name=null,this.set("isFocused",!1),this._editableElement=n,this._hasExternalElement=!!this._editableElement,this._editingView=e}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 t=this._editingView;function e(e){t.change((n=>{const o=t.document.getRoot(e.name);n.addClass(e.isFocused?"ck-focused":"ck-blurred",o),n.removeClass(e.isFocused?"ck-blurred":"ck-focused",o)}))}t.isRenderingInProgress?function n(o){t.once("change:isRenderingInProgress",((t,i,r)=>{r?n(o):e(o)}))}(this):e(this)}}class hh extends uh{constructor(t,e,n){super(t,e,n),this.extendTemplate({attributes:{role:"textbox",class:"ck-editor__editable_inline"}})}render(){super.render();const t=this._editingView,e=this.t;t.change((n=>{const o=t.document.getRoot(this.name);n.setAttribute("aria-label",e("Rich Text Editor, %0",this.name),o)}))}}var ph=n(5523),mh={attributes:{"data-cke":!0}};mh.setAttributes=is(),mh.insert=ns().bind(null,"head"),mh.domAPI=ts(),mh.insertStyleElement=ss();Qr()(ph.Z,mh);ph.Z&&ph.Z.locals&&ph.Z.locals;class gh extends Od{constructor(t,e={}){super(t);const n=this.bindTemplate;this.set("label",e.label||""),this.set("class",e.class||null),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-form__header",n.to("class")]},children:this.children});const o=new Od(t);o.setTemplate({tag:"span",attributes:{class:["ck","ck-form__header__label"]},children:[{text:n.to("label")}]}),this.children.add(o)}}var fh=n(6985),bh={attributes:{"data-cke":!0}};bh.setAttributes=is(),bh.insert=ns().bind(null,"head"),bh.domAPI=ts(),bh.insertStyleElement=ss();Qr()(fh.Z,bh);fh.Z&&fh.Z.locals&&fh.Z.locals;class kh extends Od{constructor(t){super(t),this.set("value"),this.set("id"),this.set("placeholder"),this.set("isReadOnly",!1),this.set("hasError",!1),this.set("ariaDescribedById"),this.focusTracker=new Pa,this.bind("isFocused").to(this.focusTracker),this.set("isEmpty",!0),this.set("inputMode","text");const e=this.bindTemplate;this.setTemplate({tag:"input",attributes:{class:["ck","ck-input",e.if("isFocused","ck-input_focused"),e.if("isEmpty","ck-input-text_empty"),e.if("hasError","ck-error")],id:e.to("id"),placeholder:e.to("placeholder"),readonly:e.to("isReadOnly"),inputmode:e.to("inputMode"),"aria-invalid":e.if("hasError",!0),"aria-describedby":e.to("ariaDescribedById")},on:{input:e.to(((...t)=>{this.fire("input",...t),this._updateIsEmpty()})),change:e.to(this._updateIsEmpty.bind(this))}})}render(){super.render(),this.focusTracker.add(this.element),this._setDomElementValue(this.value),this._updateIsEmpty(),this.on("change:value",((t,e,n)=>{this._setDomElementValue(n),this._updateIsEmpty()}))}destroy(){super.destroy(),this.focusTracker.destroy()}select(){this.element.select()}focus(){this.element.focus()}_updateIsEmpty(){this.isEmpty=!this.element.value}_setDomElementValue(t){this.element.value=t||0===t?t:""}}class wh extends kh{constructor(t){super(t),this.extendTemplate({attributes:{type:"text",class:["ck-input-text"]}})}}var _h=n(8111),Ch={attributes:{"data-cke":!0}};Ch.setAttributes=is(),Ch.insert=ns().bind(null,"head"),Ch.domAPI=ts(),Ch.insertStyleElement=ss();Qr()(_h.Z,Ch);_h.Z&&_h.Z.locals&&_h.Z.locals;class Ah extends Od{constructor(t,e){super(t);const n=`ck-labeled-field-view-${i()}`,o=`ck-labeled-field-view-status-${i()}`;this.fieldView=e(this,n,o),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(n),this.statusView=this._createStatusView(o),this.bind("_statusText").to(this,"errorText",this,"infoText",((t,e)=>t||e));const r=this.bindTemplate;this.setTemplate({tag:"div",attributes:{class:["ck","ck-labeled-field-view",r.to("class"),r.if("isEnabled","ck-disabled",(t=>!t)),r.if("isEmpty","ck-labeled-field-view_empty"),r.if("isFocused","ck-labeled-field-view_focused"),r.if("placeholder","ck-labeled-field-view_placeholder"),r.if("errorText","ck-error")]},children:[{tag:"div",attributes:{class:["ck","ck-labeled-field-view__input-wrapper"]},children:[this.fieldView,this.labelView]},this.statusView]})}_createLabelView(t){const e=new dh(this.locale);return e.for=t,e.bind("text").to(this,"label"),e}_createStatusView(t){const e=new Od(this.locale),n=this.bindTemplate;return e.setTemplate({tag:"div",attributes:{class:["ck","ck-labeled-field-view__status",n.if("errorText","ck-labeled-field-view__status_error"),n.if("_statusText","ck-hidden",(t=>!t))],id:t,role:n.if("errorText","alert")},children:[{text:n.to("_statusText")}]}),e}focus(){this.fieldView.focus()}}function vh(t,e,n){const o=new wh(t.locale);return o.set({id:e,ariaDescribedById:n}),o.bind("isReadOnly").to(t,"isEnabled",(t=>!t)),o.bind("hasError").to(t,"errorText",(t=>!!t)),o.on("input",(()=>{t.errorText=null})),t.bind("isEmpty","isFocused","placeholder").to(o),o}function yh(t,e,n){const o=nh(t.locale);return o.set({id:e,ariaDescribedById:n}),o.bind("isEnabled").to(t),o}class xh extends No{static get pluginName(){return"Notification"}init(){this.on("show:warning",((t,e)=>{window.alert(e.message)}),{priority:"lowest"})}showSuccess(t,e={}){this._showNotification({message:t,type:"success",namespace:e.namespace,title:e.title})}showInfo(t,e={}){this._showNotification({message:t,type:"info",namespace:e.namespace,title:e.title})}showWarning(t,e={}){this._showNotification({message:t,type:"warning",namespace:e.namespace,title:e.title})}_showNotification(t){const e=`show:${t.type}`+(t.namespace?`:${t.namespace}`:"");this.fire(e,{message:t.message,type:t.type,title:t.title||""})}}class Eh{constructor(t,e){e&&Xt(this,e),t&&this.set(t)}}function Dh(t){return e=>e+t}he(Eh,se);var Sh=n(8245),Bh={attributes:{"data-cke":!0}};Bh.setAttributes=is(),Bh.insert=ns().bind(null,"head"),Bh.domAPI=ts(),Bh.insertStyleElement=ss();Qr()(Sh.Z,Bh);Sh.Z&&Sh.Z.locals&&Sh.Z.locals;const Th=Dh("px"),Ph=ps.document.body;class Ih extends Od{constructor(t){super(t);const e=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",e.to("position",(t=>`ck-balloon-panel_${t}`)),e.if("isVisible","ck-balloon-panel_visible"),e.if("withArrow","ck-balloon-panel_with-arrow"),e.to("class")],style:{top:e.to("top",Th),left:e.to("left",Th)}},children:this.content})}show(){this.isVisible=!0}hide(){this.isVisible=!1}attachTo(t){this.show();const e=Ih.defaultPositions,n=Object.assign({},{element:this.element,positions:[e.southArrowNorth,e.southArrowNorthMiddleWest,e.southArrowNorthMiddleEast,e.southArrowNorthWest,e.southArrowNorthEast,e.northArrowSouth,e.northArrowSouthMiddleWest,e.northArrowSouthMiddleEast,e.northArrowSouthWest,e.northArrowSouthEast,e.viewportStickyNorth],limiter:Ph,fitInViewport:!0},t),o=Ih._getOptimalPosition(n),i=parseInt(o.left),r=parseInt(o.top),{name:s,config:a={}}=o,{withArrow:c=!0}=a;Object.assign(this,{top:r,left:i,position:s,withArrow:c})}pin(t){this.unpin(),this._pinWhenIsVisibleCallback=()=>{this.isVisible?this._startPinning(t):this._stopPinning()},this._startPinning(t),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(t){this.attachTo(t);const e=Rh(t.target),n=t.limiter?Rh(t.limiter):Ph;this.listenTo(ps.document,"scroll",((o,i)=>{const r=i.target,s=e&&r.contains(e),a=n&&r.contains(n);!s&&!a&&e&&n||this.attachTo(t)}),{useCapture:!0}),this.listenTo(ps.window,"resize",(()=>{this.attachTo(t)}))}_stopPinning(){this.stopListening(ps.document,"scroll"),this.stopListening(ps.window,"resize")}}function Rh(t){return vo(t)?t:Ca(t)?t.commonAncestorContainer:"function"==typeof t?Rh(t()):null}Ih.arrowHorizontalOffset=25,Ih.arrowVerticalOffset=10,Ih.stickyVerticalOffset=20,Ih._getOptimalPosition=Fu,Ih.defaultPositions=function({horizontalOffset:t=Ih.arrowHorizontalOffset,verticalOffset:e=Ih.arrowVerticalOffset,stickyVerticalOffset:n=Ih.stickyVerticalOffset,config:o}={}){return{northWestArrowSouthWest:(e,n)=>({top:i(e,n),left:e.left-t,name:"arrow_sw",...o&&{config:o}}),northWestArrowSouthMiddleWest:(e,n)=>({top:i(e,n),left:e.left-.25*n.width-t,name:"arrow_smw",...o&&{config:o}}),northWestArrowSouth:(t,e)=>({top:i(t,e),left:t.left-e.width/2,name:"arrow_s",...o&&{config:o}}),northWestArrowSouthMiddleEast:(e,n)=>({top:i(e,n),left:e.left-.75*n.width+t,name:"arrow_sme",...o&&{config:o}}),northWestArrowSouthEast:(e,n)=>({top:i(e,n),left:e.left-n.width+t,name:"arrow_se",...o&&{config:o}}),northArrowSouthWest:(e,n)=>({top:i(e,n),left:e.left+e.width/2-t,name:"arrow_sw",...o&&{config:o}}),northArrowSouthMiddleWest:(e,n)=>({top:i(e,n),left:e.left+e.width/2-.25*n.width-t,name:"arrow_smw",...o&&{config:o}}),northArrowSouth:(t,e)=>({top:i(t,e),left:t.left+t.width/2-e.width/2,name:"arrow_s",...o&&{config:o}}),northArrowSouthMiddleEast:(e,n)=>({top:i(e,n),left:e.left+e.width/2-.75*n.width+t,name:"arrow_sme",...o&&{config:o}}),northArrowSouthEast:(e,n)=>({top:i(e,n),left:e.left+e.width/2-n.width+t,name:"arrow_se",...o&&{config:o}}),northEastArrowSouthWest:(e,n)=>({top:i(e,n),left:e.right-t,name:"arrow_sw",...o&&{config:o}}),northEastArrowSouthMiddleWest:(e,n)=>({top:i(e,n),left:e.right-.25*n.width-t,name:"arrow_smw",...o&&{config:o}}),northEastArrowSouth:(t,e)=>({top:i(t,e),left:t.right-e.width/2,name:"arrow_s",...o&&{config:o}}),northEastArrowSouthMiddleEast:(e,n)=>({top:i(e,n),left:e.right-.75*n.width+t,name:"arrow_sme",...o&&{config:o}}),northEastArrowSouthEast:(e,n)=>({top:i(e,n),left:e.right-n.width+t,name:"arrow_se",...o&&{config:o}}),southWestArrowNorthWest:(e,n)=>({top:r(e),left:e.left-t,name:"arrow_nw",...o&&{config:o}}),southWestArrowNorthMiddleWest:(e,n)=>({top:r(e),left:e.left-.25*n.width-t,name:"arrow_nmw",...o&&{config:o}}),southWestArrowNorth:(t,e)=>({top:r(t),left:t.left-e.width/2,name:"arrow_n",...o&&{config:o}}),southWestArrowNorthMiddleEast:(e,n)=>({top:r(e),left:e.left-.75*n.width+t,name:"arrow_nme",...o&&{config:o}}),southWestArrowNorthEast:(e,n)=>({top:r(e),left:e.left-n.width+t,name:"arrow_ne",...o&&{config:o}}),southArrowNorthWest:(e,n)=>({top:r(e),left:e.left+e.width/2-t,name:"arrow_nw",...o&&{config:o}}),southArrowNorthMiddleWest:(e,n)=>({top:r(e),left:e.left+e.width/2-.25*n.width-t,name:"arrow_nmw",...o&&{config:o}}),southArrowNorth:(t,e)=>({top:r(t),left:t.left+t.width/2-e.width/2,name:"arrow_n",...o&&{config:o}}),southArrowNorthMiddleEast:(e,n)=>({top:r(e),left:e.left+e.width/2-.75*n.width+t,name:"arrow_nme",...o&&{config:o}}),southArrowNorthEast:(e,n)=>({top:r(e),left:e.left+e.width/2-n.width+t,name:"arrow_ne",...o&&{config:o}}),southEastArrowNorthWest:(e,n)=>({top:r(e),left:e.right-t,name:"arrow_nw",...o&&{config:o}}),southEastArrowNorthMiddleWest:(e,n)=>({top:r(e),left:e.right-.25*n.width-t,name:"arrow_nmw",...o&&{config:o}}),southEastArrowNorth:(t,e)=>({top:r(t),left:t.right-e.width/2,name:"arrow_n",...o&&{config:o}}),southEastArrowNorthMiddleEast:(e,n)=>({top:r(e),left:e.right-.75*n.width+t,name:"arrow_nme",...o&&{config:o}}),southEastArrowNorthEast:(e,n)=>({top:r(e),left:e.right-n.width+t,name:"arrow_ne",...o&&{config:o}}),viewportStickyNorth:(t,e,i)=>t.getIntersection(i)?{top:i.top+n,left:t.left+t.width/2-e.width/2,name:"arrowless",config:{withArrow:!1,...o}}:null};function i(t,n){return t.top-n.height-e}function r(t){return t.bottom+e}}();var zh=n(1757),Fh={attributes:{"data-cke":!0}};Fh.setAttributes=is(),Fh.insert=ns().bind(null,"head"),Fh.domAPI=ts(),Fh.insertStyleElement=ss();Qr()(zh.Z,Fh);zh.Z&&zh.Z.locals&&zh.Z.locals;var Nh=n(3553),Oh={attributes:{"data-cke":!0}};Oh.setAttributes=is(),Oh.insert=ns().bind(null,"head"),Oh.domAPI=ts(),Oh.insertStyleElement=ss();Qr()(Nh.Z,Oh);Nh.Z&&Nh.Z.locals&&Nh.Z.locals;const Mh=Dh("px");class Vh extends pe{static get pluginName(){return"ContextualBalloon"}constructor(t){super(t),this.positionLimiter=()=>{const t=this.editor.editing.view,e=t.document.selection.editableElement;return e?t.domConverter.mapViewToDom(e.root):null},this.set("visibleView",null),this.view=new Ih(t.locale),t.ui.view.body.add(this.view),t.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(t){return Array.from(this._viewToStack.keys()).includes(t)}add(t){if(this.hasView(t.view))throw new s("contextualballoon-add-view-exist",[this,t]);const e=t.stackId||"main";if(!this._idToStack.has(e))return this._idToStack.set(e,new Map([[t.view,t]])),this._viewToStack.set(t.view,this._idToStack.get(e)),this._numberOfStacks=this._idToStack.size,void(this._visibleStack&&!t.singleViewMode||this.showStack(e));const n=this._idToStack.get(e);t.singleViewMode&&this.showStack(e),n.set(t.view,t),this._viewToStack.set(t.view,n),n===this._visibleStack&&this._showView(t)}remove(t){if(!this.hasView(t))throw new s("contextualballoon-remove-view-not-exist",[this,t]);const e=this._viewToStack.get(t);this._singleViewMode&&this.visibleView===t&&(this._singleViewMode=!1),this.visibleView===t&&(1===e.size?this._idToStack.size>1?this._showNextStack():(this.view.hide(),this.visibleView=null,this._rotatorView.hideView()):this._showView(Array.from(e.values())[e.size-2])),1===e.size?(this._idToStack.delete(this._getStackId(e)),this._numberOfStacks=this._idToStack.size):e.delete(t),this._viewToStack.delete(t)}updatePosition(t){t&&(this._visibleStack.get(this.visibleView).position=t),this.view.pin(this._getBalloonPosition()),this._fakePanelsView.updatePosition()}showStack(t){this.visibleStack=t;const e=this._idToStack.get(t);if(!e)throw new s("contextualballoon-showstack-stack-not-exist",this);this._visibleStack!==e&&this._showView(Array.from(e.values()).pop())}get _visibleStack(){return this._viewToStack.get(this.visibleView)}_getStackId(t){return Array.from(this._idToStack.entries()).find((e=>e[1]===t))[0]}_showNextStack(){const t=Array.from(this._idToStack.values());let e=t.indexOf(this._visibleStack)+1;t[e]||(e=0),this.showStack(this._getStackId(t[e]))}_showPrevStack(){const t=Array.from(this._idToStack.values());let e=t.indexOf(this._visibleStack)-1;t[e]||(e=t.length-1),this.showStack(this._getStackId(t[e]))}_createRotatorView(){const t=new Lh(this.editor.locale),e=this.editor.locale.t;return this.view.content.add(t),t.bind("isNavigationVisible").to(this,"_numberOfStacks",this,"_singleViewMode",((t,e)=>!e&&t>1)),t.on("change:isNavigationVisible",(()=>this.updatePosition()),{priority:"low"}),t.bind("counter").to(this,"visibleView",this,"_numberOfStacks",((t,n)=>{if(n<2)return"";const o=Array.from(this._idToStack.values()).indexOf(this._visibleStack)+1;return e("%0 of %1",[o,n])})),t.buttonNextView.on("execute",(()=>{t.focusTracker.isFocused&&this.editor.editing.view.focus(),this._showNextStack()})),t.buttonPrevView.on("execute",(()=>{t.focusTracker.isFocused&&this.editor.editing.view.focus(),this._showPrevStack()})),t}_createFakePanelsView(){const t=new Hh(this.editor.locale,this.view);return t.bind("numberOfPanels").to(this,"_numberOfStacks",this,"_singleViewMode",((t,e)=>!e&&t>=2?Math.min(t-1,2):0)),t.listenTo(this.view,"change:top",(()=>t.updatePosition())),t.listenTo(this.view,"change:left",(()=>t.updatePosition())),this.editor.ui.view.body.add(t),t}_showView({view:t,balloonClassName:e="",withArrow:n=!0,singleViewMode:o=!1}){this.view.class=e,this.view.withArrow=n,this._rotatorView.showView(t),this.visibleView=t,this.view.pin(this._getBalloonPosition()),this._fakePanelsView.updatePosition(),o&&(this._singleViewMode=!0)}_getBalloonPosition(){let t=Array.from(this._visibleStack.values()).pop().position;return t&&(t.limiter||(t=Object.assign({},t,{limiter:this.positionLimiter})),t=Object.assign({},t,{viewportOffsetConfig:this.editor.ui.viewportOffset})),t}}class Lh extends Od{constructor(t){super(t);const e=t.t,n=this.bindTemplate;this.set("isNavigationVisible",!0),this.focusTracker=new Pa,this.buttonPrevView=this._createButtonView(e("Previous"),''),this.buttonNextView=this._createButtonView(e("Next"),''),this.content=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-balloon-rotator"],"z-index":"-1"},children:[{tag:"div",attributes:{class:["ck-balloon-rotator__navigation",n.to("isNavigationVisible",(t=>t?"":"ck-hidden"))]},children:[this.buttonPrevView,{tag:"span",attributes:{class:["ck-balloon-rotator__counter"]},children:[{text:n.to("counter")}]},this.buttonNextView]},{tag:"div",attributes:{class:"ck-balloon-rotator__content"},children:this.content}]})}render(){super.render(),this.focusTracker.add(this.element)}destroy(){super.destroy(),this.focusTracker.destroy()}showView(t){this.hideView(),this.content.add(t)}hideView(){this.content.clear()}_createButtonView(t,e){const n=new pu(this.locale);return n.set({label:t,icon:e,tooltip:!0}),n}}class Hh extends Od{constructor(t,e){super(t);const n=this.bindTemplate;this.set("top",0),this.set("left",0),this.set("height",0),this.set("width",0),this.set("numberOfPanels",0),this.content=this.createCollection(),this._balloonPanelView=e,this.setTemplate({tag:"div",attributes:{class:["ck-fake-panel",n.to("numberOfPanels",(t=>t?"":"ck-hidden"))],style:{top:n.to("top",Mh),left:n.to("left",Mh),width:n.to("width",Mh),height:n.to("height",Mh)}},children:this.content}),this.on("change:numberOfPanels",((t,e,n,o)=>{n>o?this._addPanels(n-o):this._removePanels(o-n),this.updatePosition()}))}_addPanels(t){for(;t--;){const t=new Od;t.setTemplate({tag:"div"}),this.content.add(t),this.registerChild(t)}}_removePanels(t){for(;t--;){const t=this.content.last;this.content.remove(t),this.deregisterChild(t),t.destroy()}}updatePosition(){if(this.numberOfPanels){const{top:t,left:e}=this._balloonPanelView,{width:n,height:o}=new ya(this._balloonPanelView.element);Object.assign(this,{top:t,left:e,width:n,height:o})}}}var qh=n(3609),Wh={attributes:{"data-cke":!0}};Wh.setAttributes=is(),Wh.insert=ns().bind(null,"head"),Wh.domAPI=ts(),Wh.insertStyleElement=ss();Qr()(qh.Z,Wh);qh.Z&&qh.Z.locals&&qh.Z.locals,Dh("px");Dh("px");var jh=n(6706),Uh={attributes:{"data-cke":!0}};Uh.setAttributes=is(),Uh.insert=ns().bind(null,"head"),Uh.domAPI=ts(),Uh.insertStyleElement=ss();Qr()(jh.Z,Uh);jh.Z&&jh.Z.locals&&jh.Z.locals,Dh("px");Dh("px");var $h=n(8894),Gh={attributes:{"data-cke":!0}};Gh.setAttributes=is(),Gh.insert=ns().bind(null,"head"),Gh.domAPI=ts(),Gh.insertStyleElement=ss();Qr()($h.Z,Gh);$h.Z&&$h.Z.locals&&$h.Z.locals;const Kh=new WeakMap;function Zh(t){const{view:e,element:n,text:o,isDirectHost:i=!0,keepOnFocus:r=!1}=t,s=e.document;Kh.has(s)||(Kh.set(s,new Map),s.registerPostFixer((t=>Yh(s,t)))),Kh.get(s).set(n,{text:o,isDirectHost:i,keepOnFocus:r,hostElement:i?n:null}),e.change((t=>Yh(s,t)))}function Jh(t,e){return!!e.hasClass("ck-placeholder")&&(t.removeClass("ck-placeholder",e),!0)}function Yh(t,e){const n=Kh.get(t),o=[];let i=!1;for(const[t,r]of n)r.isDirectHost&&(o.push(t),Qh(e,t,r)&&(i=!0));for(const[t,r]of n){if(r.isDirectHost)continue;const n=Xh(t);n&&(o.includes(n)||(r.hostElement=n,Qh(e,t,r)&&(i=!0)))}return i}function Qh(t,e,n){const{text:o,isDirectHost:i,hostElement:r}=n;let s=!1;r.getAttribute("data-placeholder")!==o&&(t.setAttribute("data-placeholder",o,r),s=!0);return(i||1==e.childCount)&&function(t,e){if(!t.isAttached())return!1;const n=Array.from(t.getChildren()).some((t=>!t.is("uiElement")));if(n)return!1;if(e)return!0;const o=t.document;if(!o.isFocused)return!0;const i=o.selection.anchor;return i&&i.parent!==t}(r,n.keepOnFocus)?function(t,e){return!e.hasClass("ck-placeholder")&&(t.addClass("ck-placeholder",e),!0)}(t,r)&&(s=!0):Jh(t,r)&&(s=!0),s}function Xh(t){if(t.childCount){const e=t.getChild(0);if(e.is("element")&&!e.is("uiElement"))return e}return null}const tp=new Map;function ep(t,e,n){let o=tp.get(t);o||(o=new Map,tp.set(t,o)),o.set(e,n)}function np(t){return[t]}function op(t,e,n={}){const o=function(t,e){const n=tp.get(t);return n&&n.has(e)?n.get(e):np}(t.constructor,e.constructor);try{return o(t=t.clone(),e,n)}catch(t){throw t}}function ip(t,e,n){t=t.slice(),e=e.slice();const o=new rp(n.document,n.useRelations,n.forceWeakRemove);o.setOriginalOperations(t),o.setOriginalOperations(e);const i=o.originalOperations;if(0==t.length||0==e.length)return{operationsA:t,operationsB:e,originalOperations:i};const r=new WeakMap;for(const e of t)r.set(e,0);const s={nextBaseVersionA:t[t.length-1].baseVersion+1,nextBaseVersionB:e[e.length-1].baseVersion+1,originalOperationsACount:t.length,originalOperationsBCount:e.length};let a=0;for(;a{if(t.key===e.key&&t.range.start.hasSameParentAs(e.range.start)){const o=t.range.getDifference(e.range).map((e=>new yl(e,t.key,t.oldValue,t.newValue,0))),i=t.range.getIntersection(e.range);return i&&n.aIsStrong&&o.push(new yl(i,e.key,e.newValue,t.newValue,0)),0==o.length?[new Ql(0)]:o}return[t]})),ep(yl,Dl,((t,e)=>{if(t.range.start.hasSameParentAs(e.position)&&t.range.containsPosition(e.position)){const n=t.range._getTransformedByInsertion(e.position,e.howMany,!e.shouldReceiveAttributes).map((e=>new yl(e,t.key,t.oldValue,t.newValue,t.baseVersion)));if(e.shouldReceiveAttributes){const o=cp(e,t.key,t.oldValue);o&&n.unshift(o)}return n}return t.range=t.range._getTransformedByInsertion(e.position,e.howMany,!1)[0],[t]})),ep(yl,Pl,((t,e)=>{const n=[];t.range.start.hasSameParentAs(e.deletionPosition)&&(t.range.containsPosition(e.deletionPosition)||t.range.start.isEqual(e.deletionPosition))&&n.push(nc._createFromPositionAndShift(e.graveyardPosition,1));const o=t.range._getTransformedByMergeOperation(e);return o.isCollapsed||n.push(o),n.map((e=>new yl(e,t.key,t.oldValue,t.newValue,t.baseVersion)))})),ep(yl,El,((t,e)=>{const n=function(t,e){const n=nc._createFromPositionAndShift(e.sourcePosition,e.howMany);let o=null,i=[];n.containsRange(t,!0)?o=t:t.start.hasSameParentAs(n.start)?(i=t.getDifference(n),o=t.getIntersection(n)):i=[t];const r=[];for(let t of i){t=t._getTransformedByDeletion(e.sourcePosition,e.howMany);const n=e.getMovedRangeStart(),o=t.start.hasSameParentAs(n);t=t._getTransformedByInsertion(n,e.howMany,o),r.push(...t)}o&&r.push(o._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany,!1)[0]);return r}(t.range,e);return n.map((e=>new yl(e,t.key,t.oldValue,t.newValue,t.baseVersion)))})),ep(yl,Il,((t,e)=>{if(t.range.end.isEqual(e.insertionPosition))return e.graveyardPosition||t.range.end.offset++,[t];if(t.range.start.hasSameParentAs(e.splitPosition)&&t.range.containsPosition(e.splitPosition)){const n=t.clone();return n.range=new nc(e.moveTargetPosition.clone(),t.range.end._getCombined(e.splitPosition,e.moveTargetPosition)),t.range.end=e.splitPosition.clone(),t.range.end.stickiness="toPrevious",[t,n]}return t.range=t.range._getTransformedBySplitOperation(e),[t]})),ep(Dl,yl,((t,e)=>{const n=[t];if(t.shouldReceiveAttributes&&t.position.hasSameParentAs(e.range.start)&&e.range.containsPosition(t.position)){const o=cp(t,e.key,e.newValue);o&&n.push(o)}return n})),ep(Dl,Dl,((t,e,n)=>(t.position.isEqual(e.position)&&n.aIsStrong||(t.position=t.position._getTransformedByInsertOperation(e)),[t]))),ep(Dl,El,((t,e)=>(t.position=t.position._getTransformedByMoveOperation(e),[t]))),ep(Dl,Il,((t,e)=>(t.position=t.position._getTransformedBySplitOperation(e),[t]))),ep(Dl,Pl,((t,e)=>(t.position=t.position._getTransformedByMergeOperation(e),[t]))),ep(Sl,Dl,((t,e)=>(t.oldRange&&(t.oldRange=t.oldRange._getTransformedByInsertOperation(e)[0]),t.newRange&&(t.newRange=t.newRange._getTransformedByInsertOperation(e)[0]),[t]))),ep(Sl,Sl,((t,e,n)=>{if(t.name==e.name){if(!n.aIsStrong)return[new Ql(0)];t.oldRange=e.newRange?e.newRange.clone():null}return[t]})),ep(Sl,Pl,((t,e)=>(t.oldRange&&(t.oldRange=t.oldRange._getTransformedByMergeOperation(e)),t.newRange&&(t.newRange=t.newRange._getTransformedByMergeOperation(e)),[t]))),ep(Sl,El,((t,e,n)=>{if(t.oldRange&&(t.oldRange=nc._createFromRanges(t.oldRange._getTransformedByMoveOperation(e))),t.newRange){if(n.abRelation){const o=nc._createFromRanges(t.newRange._getTransformedByMoveOperation(e));if("left"==n.abRelation.side&&e.targetPosition.isEqual(t.newRange.start))return t.newRange.start.path=n.abRelation.path,t.newRange.end=o.end,[t];if("right"==n.abRelation.side&&e.targetPosition.isEqual(t.newRange.end))return t.newRange.start=o.start,t.newRange.end.path=n.abRelation.path,[t]}t.newRange=nc._createFromRanges(t.newRange._getTransformedByMoveOperation(e))}return[t]})),ep(Sl,Il,((t,e,n)=>{if(t.oldRange&&(t.oldRange=t.oldRange._getTransformedBySplitOperation(e)),t.newRange){if(n.abRelation){const o=t.newRange._getTransformedBySplitOperation(e);return t.newRange.start.isEqual(e.splitPosition)&&n.abRelation.wasStartBeforeMergedElement?t.newRange.start=Qa._createAt(e.insertionPosition):t.newRange.start.isEqual(e.splitPosition)&&!n.abRelation.wasInLeftElement&&(t.newRange.start=Qa._createAt(e.moveTargetPosition)),t.newRange.end.isEqual(e.splitPosition)&&n.abRelation.wasInRightElement?t.newRange.end=Qa._createAt(e.moveTargetPosition):t.newRange.end.isEqual(e.splitPosition)&&n.abRelation.wasEndBeforeMergedElement?t.newRange.end=Qa._createAt(e.insertionPosition):t.newRange.end=o.end,[t]}t.newRange=t.newRange._getTransformedBySplitOperation(e)}return[t]})),ep(Pl,Dl,((t,e)=>(t.sourcePosition.hasSameParentAs(e.position)&&(t.howMany+=e.howMany),t.sourcePosition=t.sourcePosition._getTransformedByInsertOperation(e),t.targetPosition=t.targetPosition._getTransformedByInsertOperation(e),[t]))),ep(Pl,Pl,((t,e,n)=>{if(t.sourcePosition.isEqual(e.sourcePosition)&&t.targetPosition.isEqual(e.targetPosition)){if(n.bWasUndone){const n=e.graveyardPosition.path.slice();return n.push(0),t.sourcePosition=new Qa(e.graveyardPosition.root,n),t.howMany=0,[t]}return[new Ql(0)]}if(t.sourcePosition.isEqual(e.sourcePosition)&&!t.targetPosition.isEqual(e.targetPosition)&&!n.bWasUndone&&"splitAtSource"!=n.abRelation){const o="$graveyard"==t.targetPosition.root.rootName,i="$graveyard"==e.targetPosition.root.rootName,r=o&&!i;if(i&&!o||!r&&n.aIsStrong){const n=e.targetPosition._getTransformedByMergeOperation(e),o=t.targetPosition._getTransformedByMergeOperation(e);return[new El(n,t.howMany,o,0)]}return[new Ql(0)]}return t.sourcePosition.hasSameParentAs(e.targetPosition)&&(t.howMany+=e.howMany),t.sourcePosition=t.sourcePosition._getTransformedByMergeOperation(e),t.targetPosition=t.targetPosition._getTransformedByMergeOperation(e),t.graveyardPosition.isEqual(e.graveyardPosition)&&n.aIsStrong||(t.graveyardPosition=t.graveyardPosition._getTransformedByMergeOperation(e)),[t]})),ep(Pl,El,((t,e,n)=>{const o=nc._createFromPositionAndShift(e.sourcePosition,e.howMany);return"remove"==e.type&&!n.bWasUndone&&!n.forceWeakRemove&&t.deletionPosition.hasSameParentAs(e.sourcePosition)&&o.containsPosition(t.sourcePosition)?[new Ql(0)]:(t.sourcePosition.hasSameParentAs(e.targetPosition)&&(t.howMany+=e.howMany),t.sourcePosition.hasSameParentAs(e.sourcePosition)&&(t.howMany-=e.howMany),t.sourcePosition=t.sourcePosition._getTransformedByMoveOperation(e),t.targetPosition=t.targetPosition._getTransformedByMoveOperation(e),t.graveyardPosition.isEqual(e.targetPosition)||(t.graveyardPosition=t.graveyardPosition._getTransformedByMoveOperation(e)),[t])})),ep(Pl,Il,((t,e,n)=>{if(e.graveyardPosition&&(t.graveyardPosition=t.graveyardPosition._getTransformedByDeletion(e.graveyardPosition,1),t.deletionPosition.isEqual(e.graveyardPosition)&&(t.howMany=e.howMany)),t.targetPosition.isEqual(e.splitPosition)){const o=0!=e.howMany,i=e.graveyardPosition&&t.deletionPosition.isEqual(e.graveyardPosition);if(o||i||"mergeTargetNotMoved"==n.abRelation)return t.sourcePosition=t.sourcePosition._getTransformedBySplitOperation(e),[t]}if(t.sourcePosition.isEqual(e.splitPosition)){if("mergeSourceNotMoved"==n.abRelation)return t.howMany=0,t.targetPosition=t.targetPosition._getTransformedBySplitOperation(e),[t];if("mergeSameElement"==n.abRelation||t.sourcePosition.offset>0)return t.sourcePosition=e.moveTargetPosition.clone(),t.targetPosition=t.targetPosition._getTransformedBySplitOperation(e),[t]}return t.sourcePosition.hasSameParentAs(e.splitPosition)&&(t.howMany=e.splitPosition.offset),t.sourcePosition=t.sourcePosition._getTransformedBySplitOperation(e),t.targetPosition=t.targetPosition._getTransformedBySplitOperation(e),[t]})),ep(El,Dl,((t,e)=>{const n=nc._createFromPositionAndShift(t.sourcePosition,t.howMany)._getTransformedByInsertOperation(e,!1)[0];return t.sourcePosition=n.start,t.howMany=n.end.offset-n.start.offset,t.targetPosition.isEqual(e.position)||(t.targetPosition=t.targetPosition._getTransformedByInsertOperation(e)),[t]})),ep(El,El,((t,e,n)=>{const o=nc._createFromPositionAndShift(t.sourcePosition,t.howMany),i=nc._createFromPositionAndShift(e.sourcePosition,e.howMany);let r,s=n.aIsStrong,a=!n.aIsStrong;if("insertBefore"==n.abRelation||"insertAfter"==n.baRelation?a=!0:"insertAfter"!=n.abRelation&&"insertBefore"!=n.baRelation||(a=!1),r=t.targetPosition.isEqual(e.targetPosition)&&a?t.targetPosition._getTransformedByDeletion(e.sourcePosition,e.howMany):t.targetPosition._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),lp(t,e)&&lp(e,t))return[e.getReversed()];if(o.containsPosition(e.targetPosition)&&o.containsRange(i,!0))return o.start=o.start._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),o.end=o.end._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),dp([o],r);if(i.containsPosition(t.targetPosition)&&i.containsRange(o,!0))return o.start=o.start._getCombined(e.sourcePosition,e.getMovedRangeStart()),o.end=o.end._getCombined(e.sourcePosition,e.getMovedRangeStart()),dp([o],r);const c=Oo(t.sourcePosition.getParentPath(),e.sourcePosition.getParentPath());if("prefix"==c||"extension"==c)return o.start=o.start._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),o.end=o.end._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),dp([o],r);"remove"!=t.type||"remove"==e.type||n.aWasUndone||n.forceWeakRemove?"remove"==t.type||"remove"!=e.type||n.bWasUndone||n.forceWeakRemove||(s=!1):s=!0;const l=[],d=o.getDifference(i);for(const t of d){t.start=t.start._getTransformedByDeletion(e.sourcePosition,e.howMany),t.end=t.end._getTransformedByDeletion(e.sourcePosition,e.howMany);const n="same"==Oo(t.start.getParentPath(),e.getMovedRangeStart().getParentPath()),o=t._getTransformedByInsertion(e.getMovedRangeStart(),e.howMany,n);l.push(...o)}const u=o.getIntersection(i);return null!==u&&s&&(u.start=u.start._getCombined(e.sourcePosition,e.getMovedRangeStart()),u.end=u.end._getCombined(e.sourcePosition,e.getMovedRangeStart()),0===l.length?l.push(u):1==l.length?i.start.isBefore(o.start)||i.start.isEqual(o.start)?l.unshift(u):l.push(u):l.splice(1,0,u)),0===l.length?[new Ql(t.baseVersion)]:dp(l,r)})),ep(El,Il,((t,e,n)=>{let o=t.targetPosition.clone();t.targetPosition.isEqual(e.insertionPosition)&&e.graveyardPosition&&"moveTargetAfter"!=n.abRelation||(o=t.targetPosition._getTransformedBySplitOperation(e));const i=nc._createFromPositionAndShift(t.sourcePosition,t.howMany);if(i.end.isEqual(e.insertionPosition))return e.graveyardPosition||t.howMany++,t.targetPosition=o,[t];if(i.start.hasSameParentAs(e.splitPosition)&&i.containsPosition(e.splitPosition)){let t=new nc(e.splitPosition,i.end);t=t._getTransformedBySplitOperation(e);return dp([new nc(i.start,e.splitPosition),t],o)}t.targetPosition.isEqual(e.splitPosition)&&"insertAtSource"==n.abRelation&&(o=e.moveTargetPosition),t.targetPosition.isEqual(e.insertionPosition)&&"insertBetween"==n.abRelation&&(o=t.targetPosition);const r=[i._getTransformedBySplitOperation(e)];if(e.graveyardPosition){const o=i.start.isEqual(e.graveyardPosition)||i.containsPosition(e.graveyardPosition);t.howMany>1&&o&&!n.aWasUndone&&r.push(nc._createFromPositionAndShift(e.insertionPosition,1))}return dp(r,o)})),ep(El,Pl,((t,e,n)=>{const o=nc._createFromPositionAndShift(t.sourcePosition,t.howMany);if(e.deletionPosition.hasSameParentAs(t.sourcePosition)&&o.containsPosition(e.sourcePosition))if("remove"!=t.type||n.forceWeakRemove){if(1==t.howMany)return n.bWasUndone?(t.sourcePosition=e.graveyardPosition.clone(),t.targetPosition=t.targetPosition._getTransformedByMergeOperation(e),[t]):[new Ql(0)]}else if(!n.aWasUndone){const n=[];let o=e.graveyardPosition.clone(),i=e.targetPosition._getTransformedByMergeOperation(e);t.howMany>1&&(n.push(new El(t.sourcePosition,t.howMany-1,t.targetPosition,0)),o=o._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany-1),i=i._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany-1));const r=e.deletionPosition._getCombined(t.sourcePosition,t.targetPosition),s=new El(o,1,r,0),a=s.getMovedRangeStart().path.slice();a.push(0);const c=new Qa(s.targetPosition.root,a);i=i._getTransformedByMove(o,r,1);const l=new El(i,e.howMany,c,0);return n.push(s),n.push(l),n}const i=nc._createFromPositionAndShift(t.sourcePosition,t.howMany)._getTransformedByMergeOperation(e);return t.sourcePosition=i.start,t.howMany=i.end.offset-i.start.offset,t.targetPosition=t.targetPosition._getTransformedByMergeOperation(e),[t]})),ep(Bl,Dl,((t,e)=>(t.position=t.position._getTransformedByInsertOperation(e),[t]))),ep(Bl,Pl,((t,e)=>t.position.isEqual(e.deletionPosition)?(t.position=e.graveyardPosition.clone(),t.position.stickiness="toNext",[t]):(t.position=t.position._getTransformedByMergeOperation(e),[t]))),ep(Bl,El,((t,e)=>(t.position=t.position._getTransformedByMoveOperation(e),[t]))),ep(Bl,Bl,((t,e,n)=>{if(t.position.isEqual(e.position)){if(!n.aIsStrong)return[new Ql(0)];t.oldName=e.newName}return[t]})),ep(Bl,Il,((t,e)=>{if("same"==Oo(t.position.path,e.splitPosition.getParentPath())&&!e.graveyardPosition){const e=new Bl(t.position.getShiftedBy(1),t.oldName,t.newName,0);return[t,e]}return t.position=t.position._getTransformedBySplitOperation(e),[t]})),ep(Tl,Tl,((t,e,n)=>{if(t.root===e.root&&t.key===e.key){if(!n.aIsStrong||t.newValue===e.newValue)return[new Ql(0)];t.oldValue=e.newValue}return[t]})),ep(Il,Dl,((t,e)=>(t.splitPosition.hasSameParentAs(e.position)&&t.splitPosition.offset{if(!t.graveyardPosition&&!n.bWasUndone&&t.splitPosition.hasSameParentAs(e.sourcePosition)){const n=e.graveyardPosition.path.slice();n.push(0);const o=new Qa(e.graveyardPosition.root,n),i=Il.getInsertionPosition(new Qa(e.graveyardPosition.root,n)),r=new Il(o,0,i,null,0);return t.splitPosition=t.splitPosition._getTransformedByMergeOperation(e),t.insertionPosition=Il.getInsertionPosition(t.splitPosition),t.graveyardPosition=r.insertionPosition.clone(),t.graveyardPosition.stickiness="toNext",[r,t]}return t.splitPosition.hasSameParentAs(e.deletionPosition)&&!t.splitPosition.isAfter(e.deletionPosition)&&t.howMany--,t.splitPosition.hasSameParentAs(e.targetPosition)&&(t.howMany+=e.howMany),t.splitPosition=t.splitPosition._getTransformedByMergeOperation(e),t.insertionPosition=Il.getInsertionPosition(t.splitPosition),t.graveyardPosition&&(t.graveyardPosition=t.graveyardPosition._getTransformedByMergeOperation(e)),[t]})),ep(Il,El,((t,e,n)=>{const o=nc._createFromPositionAndShift(e.sourcePosition,e.howMany);if(t.graveyardPosition){const i=o.start.isEqual(t.graveyardPosition)||o.containsPosition(t.graveyardPosition);if(!n.bWasUndone&&i){const n=t.splitPosition._getTransformedByMoveOperation(e),o=t.graveyardPosition._getTransformedByMoveOperation(e),i=o.path.slice();i.push(0);const r=new Qa(o.root,i);return[new El(n,t.howMany,r,0)]}t.graveyardPosition=t.graveyardPosition._getTransformedByMoveOperation(e)}const i=t.splitPosition.isEqual(e.targetPosition);if(i&&("insertAtSource"==n.baRelation||"splitBefore"==n.abRelation))return t.howMany+=e.howMany,t.splitPosition=t.splitPosition._getTransformedByDeletion(e.sourcePosition,e.howMany),t.insertionPosition=Il.getInsertionPosition(t.splitPosition),[t];if(i&&n.abRelation&&n.abRelation.howMany){const{howMany:e,offset:o}=n.abRelation;return t.howMany+=e,t.splitPosition=t.splitPosition.getShiftedBy(o),[t]}if(t.splitPosition.hasSameParentAs(e.sourcePosition)&&o.containsPosition(t.splitPosition)){const n=e.howMany-(t.splitPosition.offset-e.sourcePosition.offset);return t.howMany-=n,t.splitPosition.hasSameParentAs(e.targetPosition)&&t.splitPosition.offset{if(t.splitPosition.isEqual(e.splitPosition)){if(!t.graveyardPosition&&!e.graveyardPosition)return[new Ql(0)];if(t.graveyardPosition&&e.graveyardPosition&&t.graveyardPosition.isEqual(e.graveyardPosition))return[new Ql(0)];if("splitBefore"==n.abRelation)return t.howMany=0,t.graveyardPosition=t.graveyardPosition._getTransformedBySplitOperation(e),[t]}if(t.graveyardPosition&&e.graveyardPosition&&t.graveyardPosition.isEqual(e.graveyardPosition)){const o="$graveyard"==t.splitPosition.root.rootName,i="$graveyard"==e.splitPosition.root.rootName,r=o&&!i;if(i&&!o||!r&&n.aIsStrong){const n=[];return e.howMany&&n.push(new El(e.moveTargetPosition,e.howMany,e.splitPosition,0)),t.howMany&&n.push(new El(t.splitPosition,t.howMany,t.moveTargetPosition,0)),n}return[new Ql(0)]}if(t.graveyardPosition&&(t.graveyardPosition=t.graveyardPosition._getTransformedBySplitOperation(e)),t.splitPosition.isEqual(e.insertionPosition)&&"splitBefore"==n.abRelation)return t.howMany++,[t];if(e.splitPosition.isEqual(t.insertionPosition)&&"splitBefore"==n.baRelation){const n=e.insertionPosition.path.slice();n.push(0);const o=new Qa(e.insertionPosition.root,n);return[t,new El(t.insertionPosition,1,o,0)]}return t.splitPosition.hasSameParentAs(e.splitPosition)&&t.splitPosition.offset{const{top:n,right:o,bottom:i,left:r}=e,s=[];return[n,o,r,i].every((t=>!!t))?s.push([t,Fp(e)]):(n&&s.push([t+"-top",n]),o&&s.push([t+"-right",o]),i&&s.push([t+"-bottom",i]),r&&s.push([t+"-left",r])),s}}function Fp({top:t,right:e,bottom:n,left:o}){const i=[];return o!==e?i.push(t,e,n,o):n!==t?i.push(t,e,n):e!==t?i.push(t,e):i.push(t),i.join(" ")}function Np(t){return t.replace(/, /g,",").split(" ").map((t=>t.replace(/,/g,", ")))}function Op(t){t.setNormalizer("background",Mp),t.setNormalizer("background-color",(t=>({path:"background.color",value:t}))),t.setReducer("background",(t=>{const e=[];return e.push(["background-color",t.color]),e})),t.setStyleRelation("background",["background-color"])}function Mp(t){const e={},n=Np(t);for(const t of n)o=t,Ep.includes(o)?(e.repeat=e.repeat||[],e.repeat.push(t)):Sp(t)?(e.position=e.position||[],e.position.push(t)):Tp(t)?e.attachment=t:_p(t)?e.color=t:Ip(t)&&(e.image=t);var o;return{path:"background",value:e}}function Vp(t){t.setNormalizer("border",Lp),t.setNormalizer("border-top",Hp("top")),t.setNormalizer("border-right",Hp("right")),t.setNormalizer("border-bottom",Hp("bottom")),t.setNormalizer("border-left",Hp("left")),t.setNormalizer("border-color",qp("color")),t.setNormalizer("border-width",qp("width")),t.setNormalizer("border-style",qp("style")),t.setNormalizer("border-top-color",jp("color","top")),t.setNormalizer("border-top-style",jp("style","top")),t.setNormalizer("border-top-width",jp("width","top")),t.setNormalizer("border-right-color",jp("color","right")),t.setNormalizer("border-right-style",jp("style","right")),t.setNormalizer("border-right-width",jp("width","right")),t.setNormalizer("border-bottom-color",jp("color","bottom")),t.setNormalizer("border-bottom-style",jp("style","bottom")),t.setNormalizer("border-bottom-width",jp("width","bottom")),t.setNormalizer("border-left-color",jp("color","left")),t.setNormalizer("border-left-style",jp("style","left")),t.setNormalizer("border-left-width",jp("width","left")),t.setExtractor("border-top",Up("top")),t.setExtractor("border-right",Up("right")),t.setExtractor("border-bottom",Up("bottom")),t.setExtractor("border-left",Up("left")),t.setExtractor("border-top-color","border.color.top"),t.setExtractor("border-right-color","border.color.right"),t.setExtractor("border-bottom-color","border.color.bottom"),t.setExtractor("border-left-color","border.color.left"),t.setExtractor("border-top-width","border.width.top"),t.setExtractor("border-right-width","border.width.right"),t.setExtractor("border-bottom-width","border.width.bottom"),t.setExtractor("border-left-width","border.width.left"),t.setExtractor("border-top-style","border.style.top"),t.setExtractor("border-right-style","border.style.right"),t.setExtractor("border-bottom-style","border.style.bottom"),t.setExtractor("border-left-style","border.style.left"),t.setReducer("border-color",zp("border-color")),t.setReducer("border-style",zp("border-style")),t.setReducer("border-width",zp("border-width")),t.setReducer("border-top",Kp("top")),t.setReducer("border-right",Kp("right")),t.setReducer("border-bottom",Kp("bottom")),t.setReducer("border-left",Kp("left")),t.setReducer("border",function(){return e=>{const n=$p(e,"top"),o=$p(e,"right"),i=$p(e,"bottom"),r=$p(e,"left"),s=[n,o,i,r],a={width:t(s,"width"),style:t(s,"style"),color:t(s,"color")},c=Zp(a,"all");if(c.length)return c;const l=Object.entries(a).reduce(((t,[e,n])=>(n&&(t.push([`border-${e}`,n]),s.forEach((t=>t[e]=null))),t)),[]);return[...l,...Zp(n,"top"),...Zp(o,"right"),...Zp(i,"bottom"),...Zp(r,"left")]};function t(t,e){return t.map((t=>t[e])).reduce(((t,e)=>t==e?t:null))}}()),t.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"]),t.setStyleRelation("border-color",["border-top-color","border-right-color","border-bottom-color","border-left-color"]),t.setStyleRelation("border-style",["border-top-style","border-right-style","border-bottom-style","border-left-style"]),t.setStyleRelation("border-width",["border-top-width","border-right-width","border-bottom-width","border-left-width"]),t.setStyleRelation("border-top",["border-top-color","border-top-style","border-top-width"]),t.setStyleRelation("border-right",["border-right-color","border-right-style","border-right-width"]),t.setStyleRelation("border-bottom",["border-bottom-color","border-bottom-style","border-bottom-width"]),t.setStyleRelation("border-left",["border-left-color","border-left-style","border-left-width"])}function Lp(t){const{color:e,style:n,width:o}=Gp(t);return{path:"border",value:{color:Rp(e),style:Rp(n),width:Rp(o)}}}function Hp(t){return e=>{const{color:n,style:o,width:i}=Gp(e),r={};return void 0!==n&&(r.color={[t]:n}),void 0!==o&&(r.style={[t]:o}),void 0!==i&&(r.width={[t]:i}),{path:"border",value:r}}}function qp(t){return e=>({path:"border",value:Wp(e,t)})}function Wp(t,e){return{[e]:Rp(t)}}function jp(t,e){return n=>({path:"border",value:{[t]:{[e]:n}}})}function Up(t){return(e,n)=>{if(n.border)return $p(n.border,t)}}function $p(t,e){const n={};return t.width&&t.width[e]&&(n.width=t.width[e]),t.style&&t.style[e]&&(n.style=t.style[e]),t.color&&t.color[e]&&(n.color=t.color[e]),n}function Gp(t){const e={},n=Np(t);for(const t of n)yp(t)||/thin|medium|thick/.test(t)?e.width=t:Ap(t)?e.style=t:e.color=t;return e}function Kp(t){return e=>Zp(e,t)}function Zp(t,e){const n=[];if(t&&t.width&&n.push("width"),t&&t.style&&n.push("style"),t&&t.color&&n.push("color"),3==n.length){const o=n.map((e=>t[e])).join(" ");return["all"==e?["border",o]:[`border-${e}`,o]]}return"all"==e?[]:n.map((n=>[`border-${e}-${n}`,t[n]]))}function Jp(t){var e;t.setNormalizer("padding",(e="padding",t=>({path:e,value:Rp(t)}))),t.setNormalizer("padding-top",(t=>({path:"padding.top",value:t}))),t.setNormalizer("padding-right",(t=>({path:"padding.right",value:t}))),t.setNormalizer("padding-bottom",(t=>({path:"padding.bottom",value:t}))),t.setNormalizer("padding-left",(t=>({path:"padding.left",value:t}))),t.setReducer("padding",zp("padding")),t.setStyleRelation("padding",["padding-top","padding-right","padding-bottom","padding-left"])}class Yp extends xd{constructor(t,e){super(t),this.view=e}init(){const t=this.editor,e=this.view,n=t.editing.view,o=e.editable,i=n.document.getRoot();e.editable.name=i.rootName,e.render();const r=o.element;this.setEditableElement(o.name,r),this.focusTracker.add(r),e.editable.bind("isFocused").to(this.focusTracker),n.attachDomRoot(r),this._initPlaceholder(),this._initToolbar(),this.fire("ready")}destroy(){const t=this.view;this.editor.editing.view.detachDomRoot(t.editable.name),t.destroy(),super.destroy()}_initToolbar(){const t=this.editor,e=this.view.toolbar;e.fillFromConfig(t.config.get("toolbar"),this.componentFactory),function({origin:t,originKeystrokeHandler:e,originFocusTracker:n,toolbar:o,beforeFocus:i,afterBlur:r}){n.add(o.element),e.set("Alt+F10",((t,e)=>{n.isFocused&&!o.focusTracker.isFocused&&(i&&i(),o.focus(),e())})),o.keystrokes.set("Esc",((e,n)=>{o.focusTracker.isFocused&&(t.focus(),r&&r(),n())}))}({origin:t.editing.view,originFocusTracker:this.focusTracker,originKeystrokeHandler:t.keystrokes,toolbar:e})}_initPlaceholder(){const t=this.editor,e=t.editing.view,n=e.document.getRoot(),o=t.sourceElement,i=t.config.get("placeholder")||o&&"textarea"===o.tagName.toLowerCase()&&o.getAttribute("placeholder");i&&Zh({view:e,element:n,text:i,isDirectHost:!1,keepOnFocus:!0})}}class Qp extends ah{constructor(t,e,n={}){super(t),this.toolbar=new Wu(t,{shouldGroupWhenFull:n.shouldToolbarGroupWhenFull}),this.editable=new hh(t,e,n.editableElement),this.toolbar.extendTemplate({attributes:{class:["ck-reset_all","ck-rounded-corners"],dir:t.uiLanguageDirection}})}render(){super.render(),this.registerChild([this.toolbar,this.editable])}}class Xp extends Ad{constructor(t,e){super(e),vo(t)&&(this.sourceElement=t,function(t){const e=t.sourceElement;if(e){if(e.ckeditorInstance)throw new s("editor-source-element-already-used",t);e.ckeditorInstance=t,t.once("destroy",(()=>{delete e.ckeditorInstance}))}}(this)),this.model.document.createRoot();const n=!this.config.get("toolbar.shouldNotGroupWhenFull"),o=new Qp(this.locale,this.editing.view,{editableElement:this.sourceElement,shouldToolbarGroupWhenFull:n});this.ui=new Yp(this,o)}destroy(){const t=this.getData();return this.ui.destroy(),super.destroy().then((()=>{this.sourceElement&&Ba(this.sourceElement,t)}))}static create(t,e={}){return new Promise((n=>{const o=vo(t);if(o&&"TEXTAREA"===t.tagName)throw new s("editor-wrong-element",null);const i=new this(t,e);n(i.initPlugins().then((()=>{i.ui.init()})).then((()=>{if(!o&&e.initialData)throw new s("editor-create-initial-data",null);const n=void 0!==e.initialData?e.initialData:function(t){return vo(t)?(e=t,e instanceof HTMLTextAreaElement?e.value:e.innerHTML):t;var e}(t);return i.data.init(n)})).then((()=>i.fire("ready"))).then((()=>i)))}))}}he(Xp,Dd);const tm=function(t,e,n){var o=!0,i=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return y(n)&&(o="leading"in n?!!n.leading:o,i="trailing"in n?!!n.trailing:i),pa(t,e,{leading:o,maxWait:e,trailing:i})};function em(t,e=new Set){const n=[t],o=new Set;for(;n.length>0;){const t=n.shift();if(!(o.has(t)||nm(t)||e.has(t)))if(o.add(t),t[Symbol.iterator])try{for(const e of t)n.push(e)}catch(t){}else for(const e in t)"defaultValue"!==e&&n.push(t[e])}return o}function nm(t){const e=Object.prototype.toString.call(t),n=typeof t;return"number"===n||"boolean"===n||"string"===n||"symbol"===n||"function"===n||"[object Date]"===e||"[object RegExp]"===e||"[object Module]"===e||null==t||t instanceof EventTarget||t instanceof Event}class om{constructor(){this._stack=[]}add(t,e){const n=this._stack,o=n[0];this._insertDescriptor(t);const i=n[0];o===i||im(o,i)||this.fire("change:top",{oldDescriptor:o,newDescriptor:i,writer:e})}remove(t,e){const n=this._stack,o=n[0];this._removeDescriptor(t);const i=n[0];o===i||im(o,i)||this.fire("change:top",{oldDescriptor:o,newDescriptor:i,writer:e})}_insertDescriptor(t){const e=this._stack,n=e.findIndex((e=>e.id===t.id));if(im(t,e[n]))return;n>-1&&e.splice(n,1);let o=0;for(;e[o]&&rm(e[o],t);)o++;e.splice(o,0,t)}_removeDescriptor(t){const e=this._stack,n=e.findIndex((e=>e.id===t));n>-1&&e.splice(n,1)}}function im(t,e){return t&&e&&t.priority==e.priority&&sm(t.classes)==sm(e.classes)}function rm(t,e){return t.priority>e.priority||!(t.prioritysm(e.classes)}function sm(t){return Array.isArray(t)?t.sort().join(","):t}he(om,g);const am="widget-type-around";function cm(t,e,n){return t&&hm(t)&&!n.isInline(e)}function lm(t){return t.getAttribute(am)}const dm='',um="ck-widget_selected";function hm(t){return!!t.is("element")&&!!t.getCustomProperty("widget")}function pm(t,e,n={}){if(!t.is("containerElement"))throw new s("widget-to-widget-wrong-element-type",null,{element:t});return e.setAttribute("contenteditable","false",t),e.addClass("ck-widget",t),e.setCustomProperty("widget",!0,t),t.getFillerOffset=_m,n.label&&function(t,e,n){n.setCustomProperty("widgetLabel",e,t)}(t,n.label,e),n.hasSelectionHandle&&function(t,e){const n=e.createUIElement("div",{class:"ck ck-widget__selection-handle"},(function(t){const e=this.toDomElement(t),n=new au;return n.set("content",dm),n.render(),e.appendChild(n.element),e}));e.insert(e.createPositionAt(t,0),n),e.addClass(["ck-widget_with-selection-handle"],t)}(t,e),fm(t,e),t}function mm(t,e,n){if(e.classes&&n.addClass(To(e.classes),t),e.attributes)for(const o in e.attributes)n.setAttribute(o,e.attributes[o],t)}function gm(t,e,n){if(e.classes&&n.removeClass(To(e.classes),t),e.attributes)for(const o in e.attributes)n.removeAttribute(o,t)}function fm(t,e,n=mm,o=gm){const i=new om;i.on("change:top",((e,i)=>{i.oldDescriptor&&o(t,i.oldDescriptor,i.writer),i.newDescriptor&&n(t,i.newDescriptor,i.writer)})),e.setCustomProperty("addHighlight",((t,e,n)=>i.add(e,n)),t),e.setCustomProperty("removeHighlight",((t,e,n)=>i.remove(e,n)),t)}function bm(t){const e=t.getCustomProperty("widgetLabel");return e?"function"==typeof e?e():e:""}function km(t,e){return e.addClass(["ck-editor__editable","ck-editor__nested-editable"],t),e.setAttribute("contenteditable",t.isReadOnly?"false":"true",t),t.on("change:isReadOnly",((n,o,i)=>{e.setAttribute("contenteditable",i?"false":"true",t)})),t.on("change:isFocused",((n,o,i)=>{i?e.addClass("ck-editor__nested-editable_focused",t):e.removeClass("ck-editor__nested-editable_focused",t)})),fm(t,e),t}function wm(t,e){const n=t.getSelectedElement();if(n){const o=lm(t);if(o)return e.createRange(e.createPositionAt(n,o));if(e.schema.isObject(n)&&!e.schema.isInline(n))return e.createRangeOn(n)}const o=t.getSelectedBlocks().next().value;if(o){if(o.isEmpty)return e.createRange(e.createPositionAt(o,0));const n=e.createPositionAfter(o);return t.focus.isTouching(n)?e.createRange(n):e.createRange(e.createPositionBefore(o))}return e.createRange(t.focus)}function _m(){return null}class Cm extends pe{static get pluginName(){return"OPMacroToc"}static get buttonName(){return"insertToc"}init(){const t=this.editor,e=t.model,n=t.conversion;e.schema.register("op-macro-toc",{allowWhere:"$block",isBlock:!0,isLimit:!0}),n.for("upcast").elementToElement({view:{name:"macro",classes:"toc"},model:"op-macro-toc"}),n.for("editingDowncast").elementToElement({model:"op-macro-toc",view:(t,{writer:e})=>pm(this.createTocViewElement(e),e,{label:this.label})}),n.for("dataDowncast").elementToElement({model:"op-macro-toc",view:(t,{writer:e})=>this.createTocDataElement(e)}),t.ui.componentFactory.add(Cm.buttonName,(e=>{const n=new pu(e);return n.set({label:this.label,withText:!0}),n.on("execute",(()=>{t.model.change((e=>{const n=e.createElement("op-macro-toc",{});t.model.insertContent(n,t.model.document.selection)}))})),n}))}get label(){return window.I18n.t("js.editor.macro.toc")}createTocViewElement(t){const e=t.createText(this.label),n=t.createContainerElement("div");return t.insert(t.createPositionAt(n,0),e),n}createTocDataElement(t){return t.createContainerElement("macro",{class:"toc"})}}const Am=Symbol("isOPEmbeddedTable");function vm(t){const e=t.getSelectedElement();return!(!e||!function(t){return!!t.getCustomProperty(Am)&&hm(t)}(e))}function ym(t){return _.get(t.config,"_config.openProject.context.resource")}function xm(t){return _.get(t.config,"_config.openProject.pluginContext")}function Em(t,e){return xm(t).services[e]}function Dm(t){return Em(t,"pathHelperService")}class Sm extends pe{static get pluginName(){return"EmbeddedTableEditing"}static get buttonName(){return"insertEmbeddedTable"}init(){const t=this.editor,e=t.model,n=t.conversion,o=xm(t);this.text={button:window.I18n.t("js.editor.macro.embedded_table.button"),macro_text:window.I18n.t("js.editor.macro.embedded_table.text")},e.schema.register("op-macro-embedded-table",{allowWhere:"$block",allowAttributes:["opEmbeddedTableQuery"],isBlock:!0,isObject:!0}),n.for("upcast").elementToElement({view:{name:"macro",classes:"embedded-table"},model:(t,{writer:e})=>{const n=t.getAttribute("data-query-props");return e.createElement("op-macro-embedded-table",{opEmbeddedTableQuery:n?JSON.parse(n):{}})}}),n.for("editingDowncast").elementToElement({model:"op-macro-embedded-table",view:(t,{writer:e})=>{return n=this.createEmbeddedTableView(e),o=e,this.label,o.setCustomProperty(Am,!0,n),pm(n,o,{label:"your label here"});var n,o}}),n.for("dataDowncast").elementToElement({model:"op-macro-embedded-table",view:(t,{writer:e})=>this.createEmbeddedTableDataElement(t,e)}),t.ui.componentFactory.add(Sm.buttonName,(e=>{const n=new pu(e);return n.set({label:this.text.button,withText:!0}),n.on("execute",(()=>o.runInZone((()=>{o.services.externalQueryConfiguration.show({currentQuery:{},callback:e=>t.model.change((n=>{const o=n.createElement("op-macro-embedded-table",{opEmbeddedTableQuery:e});t.model.insertContent(o,t.model.document.selection)}))})})))),n}))}createEmbeddedTableView(t){const e=t.createText(this.text.macro_text),n=t.createContainerElement("div");return t.insert(t.createPositionAt(n,0),e),n}createEmbeddedTableDataElement(t,e){const n=t.getAttribute("opEmbeddedTableQuery")||{};return e.createContainerElement("macro",{class:"embedded-table","data-query-props":JSON.stringify(n)})}}function*Bm(t,e){for(const n of e)n&&t.getAttributeProperties(n[0]).copyOnEnter&&(yield n)}class Tm extends ge{execute(){const t=this.editor.model,e=t.document;t.change((n=>{!function(t,e,n,o){const i=n.isCollapsed,r=n.getFirstRange(),s=r.start.parent,a=r.end.parent;if(o.isLimit(s)||o.isLimit(a))return void(i||s!=a||t.deleteContent(n));if(i){const t=Bm(e.model.schema,n.getAttributes());Pm(e,r.start),e.setSelectionAttribute(t)}else{const o=!(r.start.isAtStart&&r.end.isAtEnd),i=s==a;t.deleteContent(n,{leaveUnmerged:o}),o&&(i?Pm(e,n.focus):e.setSelection(a,0))}}(this.editor.model,n,e.selection,t.schema),this.fire("afterExecute",{writer:n})}))}}function Pm(t,e){t.split(e),t.setSelection(e.parent.nextSibling,0)}class Im extends Bs{constructor(t){super(t);const e=this.document;e.on("keydown",((t,n)=>{if(this.isEnabled&&n.keyCode==ur.enter){const o=new Ui(e,"enter",e.selection.getFirstRange());e.fire(o,new Qs(e,n.domEvent,{isSoft:n.shiftKey})),o.stop.called&&t.stop()}}))}observe(){}}class Rm extends pe{static get pluginName(){return"Enter"}init(){const t=this.editor,e=t.editing.view,n=e.document;e.addObserver(Im),t.commands.add("enter",new Tm(t)),this.listenTo(n,"enter",((n,o)=>{o.preventDefault(),o.isSoft||(t.execute("enter"),e.scrollToTheSelection())}),{priority:"low"})}}class zm{constructor(t,e=20){this.model=t,this.size=0,this.limit=e,this.isLocked=!1,this._changeCallback=(t,e)=>{e.isLocal&&e.isUndoable&&e!==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(t){this.size+=t,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(t){this.isLocked&&!t||(this._batch=null,this.size=0)}}class Fm extends ge{constructor(t,e){super(t),this.direction=e,this._buffer=new zm(t.model,t.config.get("typing.undoStep"))}get buffer(){return this._buffer}execute(t={}){const e=this.editor.model,n=e.document;e.enqueueChange(this._buffer.batch,(o=>{this._buffer.lock();const i=o.createSelection(t.selection||n.selection),r=t.sequence||1,s=i.isCollapsed;if(i.isCollapsed&&e.modifySelection(i,{direction:this.direction,unit:t.unit}),this._shouldEntireContentBeReplacedWithParagraph(r))return void this._replaceEntireContentWithParagraph(o);if(this._shouldReplaceFirstBlockWithParagraph(i,r))return void this.editor.execute("paragraph",{selection:i});if(i.isCollapsed)return;let a=0;i.getFirstRange().getMinimalFlatRanges().forEach((t=>{a+=qi(t.getWalker({singleCharacters:!0,ignoreElementEnd:!0,shallow:!0}))})),e.deleteContent(i,{doNotResetEntireContent:s,direction:this.direction}),this._buffer.input(a),o.setSelection(i),this._buffer.unlock()}))}_shouldEntireContentBeReplacedWithParagraph(t){if(t>1)return!1;const e=this.editor.model,n=e.document.selection,o=e.schema.getLimitElement(n);if(!(n.isCollapsed&&n.containsEntireContent(o)))return!1;if(!e.schema.checkChild(o,"paragraph"))return!1;const i=o.getChild(0);return!i||"paragraph"!==i.name}_replaceEntireContentWithParagraph(t){const e=this.editor.model,n=e.document.selection,o=e.schema.getLimitElement(n),i=t.createElement("paragraph");t.remove(t.createRangeIn(o)),t.insert(i,o),t.setSelection(i,0)}_shouldReplaceFirstBlockWithParagraph(t,e){const n=this.editor.model;if(e>1||"backward"!=this.direction)return!1;if(!t.isCollapsed)return!1;const o=t.getFirstPosition(),i=n.schema.getLimitElement(o),r=i.getChild(0);return o.parent==r&&(!!t.containsEntireContent(r)&&(!!n.schema.checkChild(i,"paragraph")&&"paragraph"!=r.name))}}function Nm(t){if(t.newChildren.length-t.oldChildren.length!=1)return;const e=function(t,e){const n=[];let o,i=0;return t.forEach((t=>{"equal"==t?(r(),i++):"insert"==t?(s("insert")?o.values.push(e[i]):(r(),o={type:"insert",index:i,values:[e[i]]}),i++):s("delete")?o.howMany++:(r(),o={type:"delete",index:i,howMany:1})})),r(),n;function r(){o&&(n.push(o),o=null)}function s(t){return o&&o.type==t}}($r(t.oldChildren,t.newChildren,Om),t.newChildren);if(e.length>1)return;const n=e[0];return n.values[0]&&n.values[0].is("$text")?n:void 0}function Om(t,e){return t&&t.is("$text")&&e&&e.is("$text")?t.data===e.data:t===e}function Mm(t,e){const n=e.selection,o=t.shiftKey&&t.keyCode===ur.delete,i=!n.isCollapsed;return o&&i}class Vm extends Bs{constructor(t){super(t);const e=t.document;let n=0;function o(t,n,o){const i=new Ui(e,"delete",e.selection.getFirstRange());e.fire(i,new Qs(e,n,o)),i.stop.called&&t.stop()}e.on("keyup",((t,e)=>{e.keyCode!=ur.delete&&e.keyCode!=ur.backspace||(n=0)})),e.on("keydown",((t,i)=>{if(ar.isWindows&&Mm(i,e))return;const r={};if(i.keyCode==ur.delete)r.direction="forward",r.unit="character";else{if(i.keyCode!=ur.backspace)return;r.direction="backward",r.unit="codePoint"}const s=ar.isMac?i.altKey:i.ctrlKey;r.unit=s?"word":r.unit,r.sequence=++n,o(t,i.domEvent,r)})),ar.isAndroid&&e.on("beforeinput",((e,n)=>{if("deleteContentBackward"!=n.domEvent.inputType)return;const i={unit:"codepoint",direction:"backward",sequence:1},r=n.domTarget.ownerDocument.defaultView.getSelection();r.anchorNode==r.focusNode&&r.anchorOffset+1!=r.focusOffset&&(i.selectionToRemove=t.domConverter.domSelectionToView(r)),o(e,n.domEvent,i)}))}observe(){}}class Lm extends pe{static get pluginName(){return"Delete"}init(){const t=this.editor,e=t.editing.view,n=e.document,o=t.model.document;e.addObserver(Vm),this._undoOnBackspace=!1;const i=new Fm(t,"forward");if(t.commands.add("deleteForward",i),t.commands.add("forwardDelete",i),t.commands.add("delete",new Fm(t,"backward")),this.listenTo(n,"delete",((n,o)=>{const i={unit:o.unit,sequence:o.sequence};if(o.selectionToRemove){const e=t.model.createSelection(),n=[];for(const e of o.selectionToRemove.getRanges())n.push(t.editing.mapper.toModelRange(e));e.setTo(n),i.selection=e}t.execute("forward"==o.direction?"deleteForward":"delete",i),o.preventDefault(),e.scrollToTheSelection()}),{priority:"low"}),ar.isAndroid){let t=null;this.listenTo(n,"delete",((e,n)=>{const o=n.domTarget.ownerDocument.defaultView.getSelection();t={anchorNode:o.anchorNode,anchorOffset:o.anchorOffset,focusNode:o.focusNode,focusOffset:o.focusOffset}}),{priority:"lowest"}),this.listenTo(n,"keyup",((e,n)=>{if(t){const e=n.domTarget.ownerDocument.defaultView.getSelection();e.collapse(t.anchorNode,t.anchorOffset),e.extend(t.focusNode,t.focusOffset),t=null}}))}this.editor.plugins.has("UndoEditing")&&(this.listenTo(n,"delete",((e,n)=>{this._undoOnBackspace&&"backward"==n.direction&&1==n.sequence&&"codePoint"==n.unit&&(this._undoOnBackspace=!1,t.execute("undo"),n.preventDefault(),e.stop())}),{context:"$capture"}),this.listenTo(o,"change",(()=>{this._undoOnBackspace=!1})))}requestUndoOnBackspace(){this.editor.plugins.has("UndoEditing")&&(this._undoOnBackspace=!0)}}const Hm=[pr("arrowUp"),pr("arrowRight"),pr("arrowDown"),pr("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 t=112;t<=135;t++)Hm.push(t);function qm(t){return!(!t.ctrlKey&&!t.metaKey)||Hm.includes(t.keyCode)}var Wm=n(5137),jm={attributes:{"data-cke":!0}};jm.setAttributes=is(),jm.insert=ns().bind(null,"head"),jm.domAPI=ts(),jm.insertStyleElement=ss();Qr()(Wm.Z,jm);Wm.Z&&Wm.Z.locals&&Wm.Z.locals;const Um=["before","after"],$m=(new DOMParser).parseFromString('',"image/svg+xml").firstChild,Gm="ck-widget__type-around_disabled";class Km extends pe{static get pluginName(){return"WidgetTypeAround"}static get requires(){return[Rm,Lm]}constructor(t){super(t),this._currentFakeCaretModelElement=null}init(){const t=this.editor,e=t.editing.view;this.on("change:isEnabled",((n,o,i)=>{e.change((t=>{for(const n of e.document.roots)i?t.removeClass(Gm,n):t.addClass(Gm,n)})),i||t.model.change((t=>{t.removeSelectionAttribute(am)}))})),this._enableTypeAroundUIInjection(),this._enableInsertingParagraphsOnButtonClick(),this._enableInsertingParagraphsOnEnterKeypress(),this._enableInsertingParagraphsOnTypingKeystroke(),this._enableTypeAroundFakeCaretActivationUsingKeyboardArrows(),this._enableDeleteIntegration(),this._enableInsertContentIntegration(),this._enableDeleteContentIntegration()}destroy(){this._currentFakeCaretModelElement=null}_insertParagraph(t,e){const n=this.editor,o=n.editing.view;n.execute("insertParagraph",{position:n.model.createPositionAt(t,e)}),o.focus(),o.scrollToTheSelection()}_listenToIfEnabled(t,e,n,o){this.listenTo(t,e,((...t)=>{this.isEnabled&&n(...t)}),o)}_insertParagraphAccordingToFakeCaretPosition(){const t=this.editor.model.document.selection,e=lm(t);if(!e)return!1;const n=t.getSelectedElement();return this._insertParagraph(n,e),!0}_enableTypeAroundUIInjection(){const t=this.editor,e=t.model.schema,n=t.locale.t,o={before:n("Insert paragraph before block"),after:n("Insert paragraph after block")};t.editing.downcastDispatcher.on("insert",((t,n,i)=>{const r=i.mapper.toViewElement(n.item);cm(r,n.item,e)&&function(t,e,n){const o=t.createUIElement("div",{class:"ck ck-reset_all ck-widget__type-around"},(function(t){const n=this.toDomElement(t);return function(t,e){for(const n of Um){const o=new Md({tag:"div",attributes:{class:["ck","ck-widget__type-around__button",`ck-widget__type-around__button_${n}`],title:e[n]},children:[t.ownerDocument.importNode($m,!0)]});t.appendChild(o.render())}}(n,e),function(t){const e=new Md({tag:"div",attributes:{class:["ck","ck-widget__type-around__fake-caret"]}});t.appendChild(e.render())}(n),n}));t.insert(t.createPositionAt(n,"end"),o)}(i.writer,o,r)}),{priority:"low"})}_enableTypeAroundFakeCaretActivationUsingKeyboardArrows(){const t=this.editor,e=t.model,n=e.document.selection,o=e.schema,i=t.editing.view;function r(t){return`ck-widget_type-around_show-fake-caret_${t}`}this._listenToIfEnabled(i.document,"arrowKey",((t,e)=>{this._handleArrowKeyPress(t,e)}),{context:[hm,"$text"],priority:"high"}),this._listenToIfEnabled(n,"change:range",((e,n)=>{n.directChange&&t.model.change((t=>{t.removeSelectionAttribute(am)}))})),this._listenToIfEnabled(e.document,"change:data",(()=>{const e=n.getSelectedElement();if(e){if(cm(t.editing.mapper.toViewElement(e),e,o))return}t.model.change((t=>{t.removeSelectionAttribute(am)}))})),this._listenToIfEnabled(t.editing.downcastDispatcher,"selection",((t,e,n)=>{const i=n.writer;if(this._currentFakeCaretModelElement){const t=n.mapper.toViewElement(this._currentFakeCaretModelElement);t&&(i.removeClass(Um.map(r),t),this._currentFakeCaretModelElement=null)}const s=e.selection.getSelectedElement();if(!s)return;const a=n.mapper.toViewElement(s);if(!cm(a,s,o))return;const c=lm(e.selection);c&&(i.addClass(r(c),a),this._currentFakeCaretModelElement=s)})),this._listenToIfEnabled(t.ui.focusTracker,"change:isFocused",((e,n,o)=>{o||t.model.change((t=>{t.removeSelectionAttribute(am)}))}))}_handleArrowKeyPress(t,e){const n=this.editor,o=n.model,i=o.document.selection,r=o.schema,s=n.editing.view,a=function(t,e){const n=fr(t,e);return"down"===n||"right"===n}(e.keyCode,n.locale.contentLanguageDirection),c=s.document.selection.getSelectedElement();let l;cm(c,n.editing.mapper.toModelElement(c),r)?l=this._handleArrowKeyPressOnSelectedWidget(a):i.isCollapsed?l=this._handleArrowKeyPressWhenSelectionNextToAWidget(a):e.shiftKey||(l=this._handleArrowKeyPressWhenNonCollapsedSelection(a)),l&&(e.preventDefault(),t.stop())}_handleArrowKeyPressOnSelectedWidget(t){const e=this.editor.model,n=lm(e.document.selection);return e.change((e=>{if(!n)return e.setSelectionAttribute(am,t?"after":"before"),!0;if(!(n===(t?"after":"before")))return e.removeSelectionAttribute(am),!0;return!1}))}_handleArrowKeyPressWhenSelectionNextToAWidget(t){const e=this.editor,n=e.model,o=n.schema,i=e.plugins.get("Widget"),r=i._getObjectElementNextToSelection(t);return!!cm(e.editing.mapper.toViewElement(r),r,o)&&(n.change((e=>{i._setSelectionOverElement(r),e.setSelectionAttribute(am,t?"before":"after")})),!0)}_handleArrowKeyPressWhenNonCollapsedSelection(t){const e=this.editor,n=e.model,o=n.schema,i=e.editing.mapper,r=n.document.selection,s=t?r.getLastPosition().nodeBefore:r.getFirstPosition().nodeAfter;return!!cm(i.toViewElement(s),s,o)&&(n.change((e=>{e.setSelection(s,"on"),e.setSelectionAttribute(am,t?"after":"before")})),!0)}_enableInsertingParagraphsOnButtonClick(){const t=this.editor,e=t.editing.view;this._listenToIfEnabled(e.document,"mousedown",((n,o)=>{const i=o.domTarget.closest(".ck-widget__type-around__button");if(!i)return;const r=function(t){return t.classList.contains("ck-widget__type-around__button_before")?"before":"after"}(i),s=function(t,e){const n=t.closest(".ck-widget");return e.mapDomToView(n)}(i,e.domConverter),a=t.editing.mapper.toModelElement(s);this._insertParagraph(a,r),o.preventDefault(),n.stop()}))}_enableInsertingParagraphsOnEnterKeypress(){const t=this.editor,e=t.model.document.selection,n=t.editing.view;this._listenToIfEnabled(n.document,"enter",((n,o)=>{if("atTarget"!=n.eventPhase)return;const i=e.getSelectedElement(),r=t.editing.mapper.toViewElement(i),s=t.model.schema;let a;this._insertParagraphAccordingToFakeCaretPosition()?a=!0:cm(r,i,s)&&(this._insertParagraph(i,o.isSoft?"before":"after"),a=!0),a&&(o.preventDefault(),n.stop())}),{context:hm})}_enableInsertingParagraphsOnTypingKeystroke(){const t=this.editor.editing.view,e=[ur.enter,ur.delete,ur.backspace];this._listenToIfEnabled(t.document,"keydown",((t,n)=>{e.includes(n.keyCode)||qm(n)||this._insertParagraphAccordingToFakeCaretPosition()}),{priority:"high"})}_enableDeleteIntegration(){const t=this.editor,e=t.editing.view,n=t.model,o=n.schema;this._listenToIfEnabled(e.document,"delete",((e,i)=>{if("atTarget"!=e.eventPhase)return;const r=lm(n.document.selection);if(!r)return;const s=i.direction,a=n.document.selection.getSelectedElement(),c="forward"==s;if("before"===r===c)t.execute("delete",{selection:n.createSelection(a,"on")});else{const e=o.getNearestSelectionRange(n.createPositionAt(a,r),s);if(e)if(e.isCollapsed){const i=n.createSelection(e.start);if(n.modifySelection(i,{direction:s}),i.focus.isEqual(e.start)){const t=function(t,e){let n=e;for(const o of e.getAncestors({parentFirst:!0})){if(o.childCount>1||t.isLimit(o))break;n=o}return n}(o,e.start.parent);n.deleteContent(n.createSelection(t,"on"),{doNotAutoparagraph:!0})}else n.change((n=>{n.setSelection(e),t.execute(c?"deleteForward":"delete")}))}else n.change((n=>{n.setSelection(e),t.execute(c?"deleteForward":"delete")}))}i.preventDefault(),e.stop()}),{context:hm})}_enableInsertContentIntegration(){const t=this.editor,e=this.editor.model,n=e.document.selection;this._listenToIfEnabled(t.model,"insertContent",((t,[o,i])=>{if(i&&!i.is("documentSelection"))return;const r=lm(n);return r?(t.stop(),e.change((t=>{const i=n.getSelectedElement(),s=e.createPositionAt(i,r),a=t.createSelection(s),c=e.insertContent(o,a);return t.setSelection(a),c}))):void 0}),{priority:"high"})}_enableDeleteContentIntegration(){const t=this.editor,e=this.editor.model.document.selection;this._listenToIfEnabled(t.model,"deleteContent",((t,[n])=>{if(n&&!n.is("documentSelection"))return;lm(e)&&t.stop()}),{priority:"high"})}}function Zm(t){const e=t.model;return(n,o)=>{const i=o.keyCode==ur.arrowup,r=o.keyCode==ur.arrowdown,s=o.shiftKey,a=e.document.selection;if(!i&&!r)return;const c=r;if(s&&function(t,e){return!t.isCollapsed&&t.isBackward==e}(a,c))return;const l=function(t,e,n){const o=t.model;if(n){const t=e.isCollapsed?e.focus:e.getLastPosition(),n=Jm(o,t,"forward");if(!n)return null;const i=o.createRange(t,n),r=Ym(o.schema,i,"backward");return r?o.createRange(t,r):null}{const t=e.isCollapsed?e.focus:e.getFirstPosition(),n=Jm(o,t,"backward");if(!n)return null;const i=o.createRange(n,t),r=Ym(o.schema,i,"forward");return r?o.createRange(r,t):null}}(t,a,c);if(l){if(l.isCollapsed){if(a.isCollapsed)return;if(s)return}(l.isCollapsed||function(t,e,n){const o=t.model,i=t.view.domConverter;if(n){const t=o.createSelection(e.start);o.modifySelection(t),t.focus.isAtEnd||e.start.isEqual(t.focus)||(e=o.createRange(t.focus,e.end))}const r=t.mapper.toViewRange(e),s=i.viewRangeToDom(r),a=ya.getDomRangeRects(s);let c;for(const t of a)if(void 0!==c){if(Math.round(t.top)>=c)return!1;c=Math.max(c,Math.round(t.bottom))}else c=Math.round(t.bottom);return!0}(t,l,c))&&(e.change((t=>{const n=c?l.end:l.start;if(s){const o=e.createSelection(a.anchor);o.setFocus(n),t.setSelection(o)}else t.setSelection(n)})),n.stop(),o.preventDefault(),o.stopPropagation())}}}function Jm(t,e,n){const o=t.schema,i=t.createRangeIn(e.root),r="forward"==n?"elementStart":"elementEnd";for(const{previousPosition:t,item:s,type:a}of i.getWalker({startPosition:e,direction:n})){if(o.isLimit(s)&&!o.isInline(s))return t;if(a==r&&o.isBlock(s))return null}return null}function Ym(t,e,n){const o="backward"==n?e.end:e.start;if(t.checkChild(o,"$text"))return o;for(const{nextPosition:o}of e.getWalker({direction:n}))if(t.checkChild(o,"$text"))return o;return null}var Qm=n(6507),Xm={attributes:{"data-cke":!0}};Xm.setAttributes=is(),Xm.insert=ns().bind(null,"head"),Xm.domAPI=ts(),Xm.insertStyleElement=ss();Qr()(Qm.Z,Xm);Qm.Z&&Qm.Z.locals&&Qm.Z.locals;class tg extends pe{static get pluginName(){return"Widget"}static get requires(){return[Km,Lm]}init(){const t=this.editor,e=t.editing.view,n=e.document;this._previouslySelected=new Set,this.editor.editing.downcastDispatcher.on("selection",((e,n,o)=>{const i=o.writer,r=n.selection;if(r.isCollapsed)return;const s=r.getSelectedElement();if(!s)return;const a=t.editing.mapper.toViewElement(s);hm(a)&&o.consumable.consume(r,"selection")&&i.setSelection(i.createRangeOn(a),{fake:!0,label:bm(a)})})),this.editor.editing.downcastDispatcher.on("selection",((t,e,n)=>{this._clearPreviouslySelectedWidgets(n.writer);const o=n.writer,i=o.document.selection;let r=null;for(const t of i.getRanges())for(const e of t){const t=e.item;hm(t)&&!eg(t,r)&&(o.addClass(um,t),this._previouslySelected.add(t),r=t)}}),{priority:"low"}),e.addObserver(hp),this.listenTo(n,"mousedown",((...t)=>this._onMousedown(...t))),this.listenTo(n,"arrowKey",((...t)=>{this._handleSelectionChangeOnArrowKeyPress(...t)}),{context:[hm,"$text"]}),this.listenTo(n,"arrowKey",((...t)=>{this._preventDefaultOnArrowKeyPress(...t)}),{context:"$root"}),this.listenTo(n,"arrowKey",Zm(this.editor.editing),{context:"$text"}),this.listenTo(n,"delete",((t,e)=>{this._handleDelete("forward"==e.direction)&&(e.preventDefault(),t.stop())}),{context:"$root"})}_onMousedown(t,e){const n=this.editor,o=n.editing.view,i=o.document;let r=e.target;if(function(t){for(;t;){if(t.is("editableElement")&&!t.is("rootElement"))return!0;if(hm(t))return!1;t=t.parent}return!1}(r)){if((ar.isSafari||ar.isGecko)&&e.domEvent.detail>=3){const t=n.editing.mapper,o=r.is("attributeElement")?r.findAncestor((t=>!t.is("attributeElement"))):r,i=t.toModelElement(o);e.preventDefault(),this.editor.model.change((t=>{t.setSelection(i,"in")}))}return}if(!hm(r)&&(r=r.findAncestor(hm),!r))return;ar.isAndroid&&e.preventDefault(),i.isFocused||o.focus();const s=n.editing.mapper.toModelElement(r);this._setSelectionOverElement(s)}_handleSelectionChangeOnArrowKeyPress(t,e){const n=e.keyCode,o=this.editor.model,i=o.schema,r=o.document.selection,s=r.getSelectedElement(),a=fr(n,this.editor.locale.contentLanguageDirection),c="down"==a||"right"==a,l="up"==a||"down"==a;if(s&&i.isObject(s)){const n=c?r.getLastPosition():r.getFirstPosition(),s=i.getNearestSelectionRange(n,c?"forward":"backward");return void(s&&(o.change((t=>{t.setSelection(s)})),e.preventDefault(),t.stop()))}if(!r.isCollapsed&&!e.shiftKey){const n=r.getFirstPosition(),s=r.getLastPosition(),a=n.nodeAfter,l=s.nodeBefore;return void((a&&i.isObject(a)||l&&i.isObject(l))&&(o.change((t=>{t.setSelection(c?s:n)})),e.preventDefault(),t.stop()))}if(!r.isCollapsed)return;const d=this._getObjectElementNextToSelection(c);if(d&&i.isObject(d)){if(i.isInline(d)&&l)return;this._setSelectionOverElement(d),e.preventDefault(),t.stop()}}_preventDefaultOnArrowKeyPress(t,e){const n=this.editor.model,o=n.schema,i=n.document.selection.getSelectedElement();i&&o.isObject(i)&&(e.preventDefault(),t.stop())}_handleDelete(t){if(this.editor.isReadOnly)return;const e=this.editor.model.document.selection;if(!e.isCollapsed)return;const n=this._getObjectElementNextToSelection(t);return n?(this.editor.model.change((t=>{let o=e.anchor.parent;for(;o.isEmpty;){const e=o;o=e.parent,t.remove(e)}this._setSelectionOverElement(n)})),!0):void 0}_setSelectionOverElement(t){this.editor.model.change((e=>{e.setSelection(e.createRangeOn(t))}))}_getObjectElementNextToSelection(t){const e=this.editor.model,n=e.schema,o=e.document.selection,i=e.createSelection(o);if(e.modifySelection(i,{direction:t?"forward":"backward"}),i.isEqual(o))return null;const r=t?i.focus.nodeBefore:i.focus.nodeAfter;return r&&n.isObject(r)?r:null}_clearPreviouslySelectedWidgets(t){for(const e of this._previouslySelected)t.removeClass(um,e);this._previouslySelected.clear()}}function eg(t,e){return!!e&&Array.from(t.getAncestors()).includes(e)}function ng(t,e,n){t.ui.componentFactory.add(e,(e=>{const o=new pu(e);return o.set({label:I18n.t("js.button_edit"),icon:'\n',tooltip:!0}),o.on("execute",(()=>{const e=t.model.document.selection.getSelectedElement();e&&n(e)})),o}))}const og="ck-toolbar-container";function ig(t,e,n,o){const i=e.config.get(n+".toolbar");if(!i||!i.length)return;const r=e.plugins.get("ContextualBalloon"),s=new Wu(e.locale);function a(){e.ui.focusTracker.isFocused&&o(e.editing.view.document.selection)?l()?function(t,e){const n=t.plugins.get("ContextualBalloon");if(e(t.editing.view.document.selection)){const e=rg(t);n.updatePosition(e)}}(e,o):r.hasView(s)||r.add({view:s,position:rg(e),balloonClassName:og}):c()}function c(){l()&&r.remove(s)}function l(){return r.visibleView==s}s.fillFromConfig(i,e.ui.componentFactory),t.listenTo(e.editing.view,"render",a),t.listenTo(e.ui.focusTracker,"change:isFocused",a,{priority:"low"})}function rg(t){const e=t.editing.view,n=Ih.defaultPositions;return{target:e.domConverter.viewToDom(e.document.selection.getSelectedElement()),positions:[n.northArrowSouth,n.northArrowSouthWest,n.northArrowSouthEast,n.southArrowNorth,n.southArrowNorthWest,n.southArrowNorthEast]}}class sg extends pe{static get requires(){return[Vh]}static get pluginName(){return"EmbeddedTableToolbar"}init(){const t=this.editor,e=this.editor.model,n=xm(t);ng(t,"opEditEmbeddedTableQuery",(t=>{const o=n.services.externalQueryConfiguration,i=t.getAttribute("opEmbeddedTableQuery")||{};n.runInZone((()=>{o.show({currentQuery:i,callback:n=>e.change((e=>{e.setAttribute("opEmbeddedTableQuery",n,t)}))})}))}))}afterInit(){ig(this,this.editor,"OPMacroEmbeddedTable",vm)}}const ag=Symbol("isWpButtonMacroSymbol");function cg(t){const e=t.getSelectedElement();return!(!e||!function(t){return!!t.getCustomProperty(ag)&&hm(t)}(e))}class lg extends pe{static get pluginName(){return"OPMacroWpButtonEditing"}static get buttonName(){return"insertWorkPackageButton"}init(){const t=this.editor,e=t.model,n=t.conversion,o=xm(t);e.schema.register("op-macro-wp-button",{allowWhere:["$block"],allowAttributes:["type","classes"],isBlock:!0,isLimit:!0}),n.for("upcast").elementToElement({view:{name:"macro",classes:"create_work_package_link"},model:(t,{writer:e})=>{const n=t.getAttribute("data-type")||"",o=t.getAttribute("data-classes")||"";return e.createElement("op-macro-wp-button",{type:n,classes:o})}}),n.for("editingDowncast").elementToElement({model:"op-macro-wp-button",view:(t,{writer:e})=>this.createMacroViewElement(t,e)}),n.for("dataDowncast").elementToElement({model:"op-macro-wp-button",view:(t,{writer:e})=>e.createContainerElement("macro",{class:"create_work_package_link","data-type":t.getAttribute("type")||"","data-classes":t.getAttribute("classes")||""})}),t.ui.componentFactory.add(lg.buttonName,(e=>{const n=new pu(e);return n.set({label:window.I18n.t("js.editor.macro.work_package_button.button"),withText:!0}),n.on("execute",(()=>{o.services.macros.configureWorkPackageButton().then((e=>t.model.change((n=>{const o=n.createElement("op-macro-wp-button",{});n.setAttribute("type",e.type,o),n.setAttribute("classes",e.classes,o),t.model.insertContent(o,t.model.document.selection)}))))})),n}))}macroLabel(t){return t?window.I18n.t("js.editor.macro.work_package_button.with_type",{typename:t}):window.I18n.t("js.editor.macro.work_package_button.without_type")}createMacroViewElement(t,e){t.getAttribute("type");const n=t.getAttribute("classes")||"",o=this.macroLabel(),i=e.createText(o),r=e.createContainerElement("span",{class:n});return e.insert(e.createPositionAt(r,0),i),function(t,e,n){return e.setCustomProperty(ag,!0,t),pm(t,e,{label:n})}(r,e,{label:o})}}class dg extends pe{static get requires(){return[Vh]}static get pluginName(){return"OPMacroWpButtonToolbar"}init(){const t=this.editor,e=(this.editor.model,xm(t));ng(t,"opEditWpMacroButton",(n=>{const o=e.services.macros,i=n.getAttribute("type"),r=n.getAttribute("classes");o.configureWorkPackageButton(i,r).then((e=>t.model.change((t=>{t.setAttribute("classes",e.classes,n),t.setAttribute("type",e.type,n)}))))}))}afterInit(){ig(this,this.editor,"OPMacroWpButton",cg)}}class ug{constructor(){const t=new window.FileReader;this._reader=t,this._data=void 0,this.set("loaded",0),t.onprogress=t=>{this.loaded=t.loaded}}get error(){return this._reader.error}get data(){return this._data}read(t){const e=this._reader;return this.total=t.size,new Promise(((n,o)=>{e.onload=()=>{const t=e.result;this._data=t,n(t)},e.onerror=()=>{o("error")},e.onabort=()=>{o("aborted")},this._reader.readAsDataURL(t)}))}abort(){this._reader.abort()}}he(ug,se);class hg extends pe{static get pluginName(){return"FileRepository"}static get requires(){return[Sd]}init(){this.loaders=new So,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",((t,e)=>e?t/e*100:0))}getLoader(t){return this._loadersMap.get(t)||null}createLoader(t){if(!this.createUploadAdapter)return a("filerepository-no-upload-adapter"),null;const e=new pg(Promise.resolve(t),this.createUploadAdapter);return this.loaders.add(e),this._loadersMap.set(t,e),t instanceof Promise&&e.file.then((t=>{this._loadersMap.set(t,e)})).catch((()=>{})),e.on("change:uploaded",(()=>{let t=0;for(const e of this.loaders)t+=e.uploaded;this.uploaded=t})),e.on("change:uploadTotal",(()=>{let t=0;for(const e of this.loaders)e.uploadTotal&&(t+=e.uploadTotal);this.uploadTotal=t})),e}destroyLoader(t){const e=t instanceof pg?t:this.getLoader(t);e._destroy(),this.loaders.remove(e),this._loadersMap.forEach(((t,n)=>{t===e&&this._loadersMap.delete(n)}))}_updatePendingAction(){const t=this.editor.plugins.get(Sd);if(this.loaders.length){if(!this._pendingAction){const e=this.editor.t,n=t=>`${e("Upload in progress")} ${parseInt(t)}%.`;this._pendingAction=t.add(n(this.uploadedPercent)),this._pendingAction.bind("message").to(this,"uploadedPercent",n)}}else t.remove(this._pendingAction),this._pendingAction=null}}he(hg,se);class pg{constructor(t,e){this.id=i(),this._filePromiseWrapper=this._createFilePromiseWrapper(t),this._adapter=e(this),this._reader=new ug,this.set("status","idle"),this.set("uploaded",0),this.set("uploadTotal",null),this.bind("uploadedPercent").to(this,"uploaded",this,"uploadTotal",((t,e)=>e?t/e*100:0)),this.set("uploadResponse",null)}get file(){return this._filePromiseWrapper?this._filePromiseWrapper.promise.then((t=>this._filePromiseWrapper?t:null)):Promise.resolve(null)}get data(){return this._reader.data}read(){if("idle"!=this.status)throw new s("filerepository-read-wrong-status",this);return this.status="reading",this.file.then((t=>this._reader.read(t))).then((t=>{if("reading"!==this.status)throw this.status;return this.status="idle",t})).catch((t=>{if("aborted"===t)throw this.status="aborted","aborted";throw this.status="error",this._reader.error?this._reader.error:t}))}upload(){if("idle"!=this.status)throw new s("filerepository-upload-wrong-status",this);return this.status="uploading",this.file.then((()=>this._adapter.upload())).then((t=>(this.uploadResponse=t,this.status="idle",t))).catch((t=>{if("aborted"===this.status)throw"aborted";throw this.status="error",t}))}abort(){const t=this.status;this.status="aborted",this._filePromiseWrapper.isFulfilled?"reading"==t?this._reader.abort():"uploading"==t&&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(t){const e={};return e.promise=new Promise(((n,o)=>{e.rejecter=o,e.isFulfilled=!1,t.then((t=>{e.isFulfilled=!0,n(t)})).catch((t=>{e.isFulfilled=!0,o(t)}))})),e}}he(pg,se);class mg{constructor(t,e,n){this.loader=t,this.resource=e,this.editor=n}upload(){const t=this.resource;if(!t||!t.uploadAttachments){const e=t?t.name:"Missing context";return console.warn(`uploadAttachments not present on context: ${e}`),Promise.reject("You're not allowed to upload attachments on this resource.")}return this.loader.file.then((e=>t.uploadAttachments([e]).then((t=>(this.editor.model.fire("op:attachment-added",t),this.buildResponse(t[0])))).catch((t=>{console.error("Failed upload %O",t)}))))}buildResponse(t){return{default:t.uploadUrl}}abort(){return!1}}class gg extends Od{constructor(t){super(t),this.buttonView=new pu(t),this._fileInputView=new fg(t),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 fg extends Od{constructor(t){super(t),this.set("acceptedType"),this.set("allowMultipleFiles",!1);const e=this.bindTemplate;this.setTemplate({tag:"input",attributes:{class:["ck-hidden"],type:"file",tabindex:"-1",accept:e.to("acceptedType"),multiple:e.to("allowMultipleFiles")},on:{change:e.to((()=>{this.element&&this.element.files&&this.element.files.length&&this.fire("done",this.element.files),this.element.value=""}))}})}open(){this.element.click()}}function bg(t){const e=t.map((t=>t.replace("+","\\+")));return new RegExp(`^image\\/(${e.join("|")})$`)}function kg(t){return new Promise(((e,n)=>{const o=t.getAttribute("src");fetch(o).then((t=>t.blob())).then((t=>{const n=wg(t,o),i=n.replace("image/",""),r=new File([t],`image.${i}`,{type:n});e(r)})).catch((t=>t&&"TypeError"===t.name?function(t){return function(t){return new Promise(((e,n)=>{const o=ps.document.createElement("img");o.addEventListener("load",(()=>{const t=ps.document.createElement("canvas");t.width=o.width,t.height=o.height;t.getContext("2d").drawImage(o,0,0),t.toBlob((t=>t?e(t):n()))})),o.addEventListener("error",(()=>n())),o.src=t}))}(t).then((e=>{const n=wg(e,t),o=n.replace("image/","");return new File([e],`image.${o}`,{type:n})}))}(o).then(e).catch(n):n(t)))}))}function wg(t,e){return t.type?t.type:e.match(/data:(image\/\w+);base64/)?e.match(/data:(image\/\w+);base64/)[1].toLowerCase():"image/jpeg"}class _g extends pe{static get pluginName(){return"ImageUploadUI"}init(){const t=this.editor,e=t.t,n=n=>{const o=new gg(n),i=t.commands.get("uploadImage"),r=t.config.get("image.upload.types"),s=bg(r);return o.set({acceptedType:r.map((t=>`image/${t}`)).join(","),allowMultipleFiles:!0}),o.buttonView.set({label:e("Insert image"),icon:Td.image,tooltip:!0}),o.buttonView.bind("isEnabled").to(i),o.on("done",((e,n)=>{const o=Array.from(n).filter((t=>s.test(t.type)));o.length&&t.execute("uploadImage",{file:o})})),o};t.ui.componentFactory.add("uploadImage",n),t.ui.componentFactory.add("imageUpload",n)}}var Cg=n(5870),Ag={attributes:{"data-cke":!0}};Ag.setAttributes=is(),Ag.insert=ns().bind(null,"head"),Ag.domAPI=ts(),Ag.insertStyleElement=ss();Qr()(Cg.Z,Ag);Cg.Z&&Cg.Z.locals&&Cg.Z.locals;var vg=n(9899),yg={attributes:{"data-cke":!0}};yg.setAttributes=is(),yg.insert=ns().bind(null,"head"),yg.domAPI=ts(),yg.insertStyleElement=ss();Qr()(vg.Z,yg);vg.Z&&vg.Z.locals&&vg.Z.locals;var xg=n(9825),Eg={attributes:{"data-cke":!0}};Eg.setAttributes=is(),Eg.insert=ns().bind(null,"head"),Eg.domAPI=ts(),Eg.insertStyleElement=ss();Qr()(xg.Z,Eg);xg.Z&&xg.Z.locals&&xg.Z.locals;class Dg extends pe{static get pluginName(){return"ImageUploadProgress"}constructor(t){super(t),this.placeholder="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="}init(){const t=this.editor;t.plugins.has("ImageBlockEditing")&&t.editing.downcastDispatcher.on("attribute:uploadStatus:imageBlock",((...t)=>this.uploadStatusChange(...t))),t.plugins.has("ImageInlineEditing")&&t.editing.downcastDispatcher.on("attribute:uploadStatus:imageInline",((...t)=>this.uploadStatusChange(...t)))}uploadStatusChange(t,e,n){const o=this.editor,i=e.item,r=i.getAttribute("uploadId");if(!n.consumable.consume(e.item,t.name))return;const s=o.plugins.get("ImageUtils"),a=o.plugins.get(hg),c=r?e.attributeNewValue:null,l=this.placeholder,d=o.editing.mapper.toViewElement(i),u=n.writer;if("reading"==c)return Sg(d,u),void Bg(s,l,d,u);if("uploading"==c){const t=a.loaders.get(r);return Sg(d,u),void(t?(Tg(d,u),function(t,e,n,o){const i=function(t){const e=t.createUIElement("div",{class:"ck-progress-bar"});return t.setCustomProperty("progressBar",!0,e),e}(e);e.insert(e.createPositionAt(t,"end"),i),n.on("change:uploadedPercent",((t,e,n)=>{o.change((t=>{t.setStyle("width",n+"%",i)}))}))}(d,u,t,o.editing.view),function(t,e,n,o){if(o.data){const i=t.findViewImgElement(e);n.setAttribute("src",o.data,i)}}(s,d,u,t)):Bg(s,l,d,u))}"complete"==c&&a.loaders.get(r)&&function(t,e,n){const o=e.createUIElement("div",{class:"ck-image-upload-complete-icon"});e.insert(e.createPositionAt(t,"end"),o),setTimeout((()=>{n.change((t=>t.remove(t.createRangeOn(o))))}),3e3)}(d,u,o.editing.view),function(t,e){Ig(t,e,"progressBar")}(d,u),Tg(d,u),function(t,e){e.removeClass("ck-appear",t)}(d,u)}}function Sg(t,e){t.hasClass("ck-appear")||e.addClass("ck-appear",t)}function Bg(t,e,n,o){n.hasClass("ck-image-upload-placeholder")||o.addClass("ck-image-upload-placeholder",n);const i=t.findViewImgElement(n);i.getAttribute("src")!==e&&o.setAttribute("src",e,i),Pg(n,"placeholder")||o.insert(o.createPositionAfter(i),function(t){const e=t.createUIElement("div",{class:"ck-upload-placeholder-loader"});return t.setCustomProperty("placeholder",!0,e),e}(o))}function Tg(t,e){t.hasClass("ck-image-upload-placeholder")&&e.removeClass("ck-image-upload-placeholder",t),Ig(t,e,"placeholder")}function Pg(t,e){for(const n of t.getChildren())if(n.getCustomProperty(e))return n}function Ig(t,e,n){const o=Pg(t,n);o&&e.remove(e.createRangeOn(o))}class Rg{constructor(t){this.files=function(t){const e=Array.from(t.files||[]),n=Array.from(t.items||[]);if(e.length)return e;return n.filter((t=>"file"===t.kind)).map((t=>t.getAsFile()))}(t),this._native=t}get types(){return this._native.types}getData(t){return this._native.getData(t)}setData(t,e){this._native.setData(t,e)}set effectAllowed(t){this._native.effectAllowed=t}get effectAllowed(){return this._native.effectAllowed}set dropEffect(t){this._native.dropEffect=t}get dropEffect(){return this._native.dropEffect}get isCanceled(){return"none"==this._native.dropEffect||!!this._native.mozUserCancelled}}class zg extends Xs{constructor(t){super(t);const n=this.document;function o(t){return(o,i)=>{i.preventDefault();const r=i.dropRange?[i.dropRange]:null,s=new e(n,t);n.fire(s,{dataTransfer:i.dataTransfer,method:o.name,targetRanges:r,target:i.target}),s.stop.called&&i.stopPropagation()}}this.domEventType=["paste","copy","cut","drop","dragover","dragstart","dragend","dragenter","dragleave"],this.listenTo(n,"paste",o("clipboardInput"),{priority:"low"}),this.listenTo(n,"drop",o("clipboardInput"),{priority:"low"}),this.listenTo(n,"dragover",o("dragging"),{priority:"low"})}onDomEvent(t){const e={dataTransfer:new Rg(t.clipboardData?t.clipboardData:t.dataTransfer)};"drop"!=t.type&&"dragover"!=t.type||(e.dropRange=function(t,e){const n=e.target.ownerDocument,o=e.clientX,i=e.clientY;let r;n.caretRangeFromPoint&&n.caretRangeFromPoint(o,i)?r=n.caretRangeFromPoint(o,i):e.rangeParent&&(r=n.createRange(),r.setStart(e.rangeParent,e.rangeOffset),r.collapse(!0));if(r)return t.domConverter.domRangeToView(r);return null}(this.view,t)),this.fire(t.type,t,e)}}const Fg=["figcaption","li"];function Ng(t){let e="";if(t.is("$text")||t.is("$textProxy"))e=t.data;else if(t.is("element","img")&&t.hasAttribute("alt"))e=t.getAttribute("alt");else if(t.is("element","br"))e="\n";else{let n=null;for(const o of t.getChildren()){const t=Ng(o);n&&(n.is("containerElement")||o.is("containerElement"))&&(Fg.includes(n.name)||Fg.includes(o.name)?e+="\n":e+="\n\n"),e+=t,n=o}}return e}class Og extends pe{static get pluginName(){return"ClipboardPipeline"}init(){this.editor.editing.view.addObserver(zg),this._setupPasteDrop(),this._setupCopyCut()}_setupPasteDrop(){const t=this.editor,n=t.model,o=t.editing.view,i=o.document;this.listenTo(i,"clipboardInput",(e=>{t.isReadOnly&&e.stop()}),{priority:"highest"}),this.listenTo(i,"clipboardInput",((t,n)=>{const i=n.dataTransfer;let r=n.content||"";var s;r||(i.getData("text/html")?r=function(t){return t.replace(/(\s+)<\/span>/g,((t,e)=>1==e.length?" ":e)).replace(//g,"")}(i.getData("text/html")):i.getData("text/plain")&&(((s=(s=i.getData("text/plain")).replace(//g,">").replace(/\r?\n\r?\n/g,"

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

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

${s}

`),r=s),r=this.editor.data.htmlProcessor.toView(r));const a=new e(this,"inputTransformation");this.fire(a,{content:r,dataTransfer:i,targetRanges:n.targetRanges,method:n.method}),a.stop.called&&t.stop(),o.scrollToTheSelection()}),{priority:"low"}),this.listenTo(this,"inputTransformation",((t,e)=>{if(e.content.isEmpty)return;const o=this.editor.data.toModel(e.content,"$clipboardHolder");0!=o.childCount&&(t.stop(),n.change((()=>{this.fire("contentInsertion",{content:o,method:e.method,dataTransfer:e.dataTransfer,targetRanges:e.targetRanges})})))}),{priority:"low"}),this.listenTo(this,"contentInsertion",((t,e)=>{e.resultRange=n.insertContent(e.content)}),{priority:"low"})}_setupCopyCut(){const t=this.editor,e=t.model.document,n=t.editing.view.document;function o(o,i){const r=i.dataTransfer;i.preventDefault();const s=t.data.toView(t.model.getSelectedContent(e.selection));n.fire("clipboardOutput",{dataTransfer:r,content:s,method:o.name})}this.listenTo(n,"copy",o,{priority:"low"}),this.listenTo(n,"cut",((e,n)=>{t.isReadOnly?n.preventDefault():o(e,n)}),{priority:"low"}),this.listenTo(n,"clipboardOutput",((n,o)=>{o.content.isEmpty||(o.dataTransfer.setData("text/html",this.editor.data.htmlProcessor.toData(o.content)),o.dataTransfer.setData("text/plain",Ng(o.content))),"cut"==o.method&&t.model.deleteContent(e.selection)}),{priority:"low"})}}var Mg=n(390),Vg={attributes:{"data-cke":!0}};Vg.setAttributes=is(),Vg.insert=ns().bind(null,"head"),Vg.domAPI=ts(),Vg.insertStyleElement=ss();Qr()(Mg.Z,Vg);Mg.Z&&Mg.Z.locals&&Mg.Z.locals;class Lg extends pe{static get pluginName(){return"DragDrop"}static get requires(){return[Og,tg]}init(){const t=this.editor,e=t.editing.view;this._draggedRange=null,this._draggingUid="",this._draggableElement=null,this._updateDropMarkerThrottled=tm((t=>this._updateDropMarker(t)),40),this._removeDropMarkerDelayed=Wg((()=>this._removeDropMarker()),40),this._clearDraggableAttributesDelayed=Wg((()=>this._clearDraggableAttributes()),40),e.addObserver(zg),e.addObserver(hp),this._setupDragging(),this._setupContentInsertionIntegration(),this._setupClipboardInputIntegration(),this._setupDropMarker(),this._setupDraggableAttributeHandling(),this.listenTo(t,"change:isReadOnly",((t,e,n)=>{n?this.forceDisabled("readOnlyMode"):this.clearForceDisabled("readOnlyMode")})),this.on("change:isEnabled",((t,e,n)=>{n||this._finalizeDragging(!1)})),ar.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 t=this.editor,e=t.model,n=e.document,o=t.editing.view,r=o.document;this.listenTo(r,"dragstart",((o,s)=>{const a=n.selection;if(s.target&&s.target.is("editableElement"))return void s.preventDefault();const c=s.target?jg(s.target):null;if(c){const n=t.editing.mapper.toModelElement(c);this._draggedRange=gc.fromRange(e.createRangeOn(n)),t.plugins.has("WidgetToolbarRepository")&&t.plugins.get("WidgetToolbarRepository").forceDisabled("dragDrop")}else if(!r.selection.isCollapsed){const t=r.selection.getSelectedElement();t&&hm(t)||(this._draggedRange=gc.fromRange(a.getFirstRange()))}if(!this._draggedRange)return void s.preventDefault();this._draggingUid=i(),s.dataTransfer.effectAllowed=this.isEnabled?"copyMove":"copy",s.dataTransfer.setData("application/ckeditor5-dragging-uid",this._draggingUid);const l=e.createSelection(this._draggedRange.toRange()),d=t.data.toView(e.getSelectedContent(l));r.fire("clipboardOutput",{dataTransfer:s.dataTransfer,content:d,method:o.name}),this.isEnabled||(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="")}),{priority:"low"}),this.listenTo(r,"dragend",((t,e)=>{this._finalizeDragging(!e.dataTransfer.isCanceled&&"move"==e.dataTransfer.dropEffect)}),{priority:"low"}),this.listenTo(r,"dragenter",(()=>{this.isEnabled&&o.focus()})),this.listenTo(r,"dragleave",(()=>{this._removeDropMarkerDelayed()})),this.listenTo(r,"dragging",((e,n)=>{if(!this.isEnabled)return void(n.dataTransfer.dropEffect="none");this._removeDropMarkerDelayed.cancel();const o=Hg(t,n.targetRanges,n.target);this._draggedRange||(n.dataTransfer.dropEffect="copy"),ar.isGecko||("copy"==n.dataTransfer.effectAllowed?n.dataTransfer.dropEffect="copy":["all","copyMove"].includes(n.dataTransfer.effectAllowed)&&(n.dataTransfer.dropEffect="move")),o&&this._updateDropMarkerThrottled(o)}),{priority:"low"})}_setupClipboardInputIntegration(){const t=this.editor,e=t.editing.view.document;this.listenTo(e,"clipboardInput",((e,n)=>{if("drop"!=n.method)return;const o=Hg(t,n.targetRanges,n.target);if(this._removeDropMarker(),!o)return this._finalizeDragging(!1),void e.stop();this._draggedRange&&this._draggingUid!=n.dataTransfer.getData("application/ckeditor5-dragging-uid")&&(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="");if("move"==qg(n.dataTransfer)&&this._draggedRange&&this._draggedRange.containsRange(o,!0))return this._finalizeDragging(!1),void e.stop();n.targetRanges=[t.editing.mapper.toViewRange(o)]}),{priority:"high"})}_setupContentInsertionIntegration(){const t=this.editor.plugins.get(Og);t.on("contentInsertion",((t,e)=>{if(!this.isEnabled||"drop"!==e.method)return;const n=e.targetRanges.map((t=>this.editor.editing.mapper.toModelRange(t)));this.editor.model.change((t=>t.setSelection(n)))}),{priority:"high"}),t.on("contentInsertion",((t,e)=>{if(!this.isEnabled||"drop"!==e.method)return;const n="move"==qg(e.dataTransfer),o=!e.resultRange||!e.resultRange.isCollapsed;this._finalizeDragging(o&&n)}),{priority:"lowest"})}_setupDraggableAttributeHandling(){const t=this.editor,e=t.editing.view,n=e.document;this.listenTo(n,"mousedown",((o,i)=>{if(ar.isAndroid||!i)return;this._clearDraggableAttributesDelayed.cancel();let r=jg(i.target);if(ar.isBlink&&!t.isReadOnly&&!r&&!n.selection.isCollapsed){const t=n.selection.getSelectedElement();t&&hm(t)||(r=n.selection.editableElement)}r&&(e.change((t=>{t.setAttribute("draggable","true",r)})),this._draggableElement=t.editing.mapper.toModelElement(r))})),this.listenTo(n,"mouseup",(()=>{ar.isAndroid||this._clearDraggableAttributesDelayed()}))}_clearDraggableAttributes(){const t=this.editor.editing;t.view.change((e=>{this._draggableElement&&"$graveyard"!=this._draggableElement.root.rootName&&e.removeAttribute("draggable",t.mapper.toViewElement(this._draggableElement)),this._draggableElement=null}))}_setupDropMarker(){const t=this.editor;t.conversion.for("editingDowncast").markerToHighlight({model:"drop-target",view:{classes:["ck-clipboard-drop-target-range"]}}),t.conversion.for("editingDowncast").markerToElement({model:"drop-target",view:(e,{writer:n})=>{if(t.model.schema.checkChild(e.markerRange.start,"$text"))return n.createUIElement("span",{class:"ck ck-clipboard-drop-target-position"},(function(t){const e=this.toDomElement(t);return e.innerHTML="⁠⁠",e}))}})}_updateDropMarker(t){const e=this.editor,n=e.model.markers;e.model.change((e=>{n.has("drop-target")?n.get("drop-target").getRange().isEqual(t)||e.updateMarker("drop-target",{range:t}):e.addMarker("drop-target",{range:t,usingOperation:!1,affectsData:!1})}))}_removeDropMarker(){const t=this.editor.model;this._removeDropMarkerDelayed.cancel(),this._updateDropMarkerThrottled.cancel(),t.markers.has("drop-target")&&t.change((t=>{t.removeMarker("drop-target")}))}_finalizeDragging(t){const e=this.editor,n=e.model;this._removeDropMarker(),this._clearDraggableAttributes(),e.plugins.has("WidgetToolbarRepository")&&e.plugins.get("WidgetToolbarRepository").clearForceDisabled("dragDrop"),this._draggingUid="",this._draggedRange&&(t&&this.isEnabled&&n.deleteContent(n.createSelection(this._draggedRange),{doNotAutoparagraph:!0}),this._draggedRange.detach(),this._draggedRange=null)}}function Hg(t,e,n){const o=t.model,i=t.editing.mapper;let r=null;const s=e?e[0].start:null;if(n.is("uiElement")&&(n=n.parent),r=function(t,e){const n=t.model,o=t.editing.mapper;if(hm(e))return n.createRangeOn(o.toModelElement(e));if(!e.is("editableElement")){const t=e.findAncestor((t=>hm(t)||t.is("editableElement")));if(hm(t))return n.createRangeOn(o.toModelElement(t))}return null}(t,n),r)return r;const a=function(t,e){const n=t.editing.mapper,o=t.editing.view,i=n.toModelElement(e);if(i)return i;const r=o.createPositionBefore(e),s=n.findMappedViewAncestor(r);return n.toModelElement(s)}(t,n),c=s?i.toModelPosition(s):null;return c?(r=function(t,e,n){const o=t.model;if(!o.schema.checkChild(n,"$block"))return null;const i=o.createPositionAt(n,0),r=e.path.slice(0,i.path.length),s=o.createPositionFromPath(e.root,r).nodeAfter;if(s&&o.schema.isObject(s))return o.createRangeOn(s);return null}(t,c,a),r||(r=o.schema.getNearestSelectionRange(c,ar.isGecko?"forward":"backward"),r||function(t,e){const n=t.model;for(;e;){if(n.schema.isObject(e))return n.createRangeOn(e);e=e.parent}}(t,c.parent))):function(t,e){const n=t.model,o=n.schema,i=n.createPositionAt(e,0);return o.getNearestSelectionRange(i,"forward")}(t,a)}function qg(t){return ar.isGecko?t.dropEffect:["all","copyMove"].includes(t.effectAllowed)?"move":"copy"}function Wg(t,e){let n;function o(...i){o.cancel(),n=setTimeout((()=>t(...i)),e)}return o.cancel=()=>{clearTimeout(n)},o}function jg(t){if(t.is("editableElement"))return null;if(t.hasClass("ck-widget__selection-handle"))return t.findAncestor(hm);if(hm(t))return t;const e=t.findAncestor((t=>hm(t)||t.is("editableElement")));return hm(e)?e:null}class Ug extends pe{static get pluginName(){return"PastePlainText"}static get requires(){return[Og]}init(){const t=this.editor,e=t.model,n=t.editing.view,o=n.document,i=e.document.selection;let r=!1;n.addObserver(zg),this.listenTo(o,"keydown",((t,e)=>{r=e.shiftKey})),t.plugins.get(Og).on("contentInsertion",((t,n)=>{(r||function(t,e){if(t.childCount>1)return!1;const n=t.getChild(0);if(e.isObject(n))return!1;return 0==[...n.getAttributeKeys()].length}(n.content,e.schema))&&e.change((t=>{const o=Array.from(i.getAttributes()).filter((([t])=>e.schema.getAttributeProperties(t).isFormatting));i.isCollapsed||e.deleteContent(i,{doNotAutoparagraph:!0}),o.push(...i.getAttributes());const r=t.createRangeIn(n.content);for(const e of r.getItems())e.is("$textProxy")&&t.setAttributes(o,e)}))}))}}class $g extends pe{static get pluginName(){return"Clipboard"}static get requires(){return[Og,Lg,Ug]}}class Gg extends pe{static get requires(){return[Vh]}static get pluginName(){return"WidgetToolbarRepository"}init(){const t=this.editor;if(t.plugins.has("BalloonToolbar")){const e=t.plugins.get("BalloonToolbar");this.listenTo(e,"show",(e=>{(function(t){const e=t.getSelectedElement();return!(!e||!hm(e))})(t.editing.view.document.selection)&&e.stop()}),{priority:"high"})}this._toolbarDefinitions=new Map,this._balloon=this.editor.plugins.get("ContextualBalloon"),this.on("change:isEnabled",(()=>{this._updateToolbarsVisibility()})),this.listenTo(t.ui,"update",(()=>{this._updateToolbarsVisibility()})),this.listenTo(t.ui.focusTracker,"change:isFocused",(()=>{this._updateToolbarsVisibility()}),{priority:"low"})}destroy(){super.destroy();for(const t of this._toolbarDefinitions.values())t.view.destroy()}register(t,{ariaLabel:e,items:n,getRelatedElement:o,balloonClassName:i="ck-toolbar-container"}){if(!n.length)return void a("widget-toolbar-no-items",{toolbarId:t});const r=this.editor,c=r.t,l=new Wu(r.locale);if(l.ariaLabel=e||c("Widget toolbar"),this._toolbarDefinitions.has(t))throw new s("widget-toolbar-duplicated",this,{toolbarId:t});l.fillFromConfig(n,r.ui.componentFactory),this._toolbarDefinitions.set(t,{view:l,getRelatedElement:o,balloonClassName:i})}_updateToolbarsVisibility(){let t=0,e=null,n=null;for(const o of this._toolbarDefinitions.values()){const i=o.getRelatedElement(this.editor.editing.view.document.selection);if(this.isEnabled&&i)if(this.editor.ui.focusTracker.isFocused){const r=i.getAncestors().length;r>t&&(t=r,e=i,n=o)}else this._isToolbarVisible(o)&&this._hideToolbar(o);else this._isToolbarInBalloon(o)&&this._hideToolbar(o)}n&&this._showToolbar(n,e)}_hideToolbar(t){this._balloon.remove(t.view),this.stopListening(this._balloon,"change:visibleView")}_showToolbar(t,e){this._isToolbarVisible(t)?Kg(this.editor,e):this._isToolbarInBalloon(t)||(this._balloon.add({view:t.view,position:Zg(this.editor,e),balloonClassName:t.balloonClassName}),this.listenTo(this._balloon,"change:visibleView",(()=>{for(const t of this._toolbarDefinitions.values())if(this._isToolbarVisible(t)){const e=t.getRelatedElement(this.editor.editing.view.document.selection);Kg(this.editor,e)}})))}_isToolbarVisible(t){return this._balloon.visibleView===t.view}_isToolbarInBalloon(t){return this._balloon.hasView(t.view)}}function Kg(t,e){const n=t.plugins.get("ContextualBalloon"),o=Zg(t,e);n.updatePosition(o)}function Zg(t,e){const n=t.editing.view,o=Ih.defaultPositions;return{target:n.domConverter.mapViewToDom(e),positions:[o.northArrowSouth,o.northArrowSouthWest,o.northArrowSouthEast,o.southArrowNorth,o.southArrowNorthWest,o.southArrowNorthEast,o.viewportStickyNorth]}}class Jg{constructor(t){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=t,this._referenceCoordinates=null}begin(t,e,n){const o=new ya(e);this.activeHandlePosition=function(t){const e=["top-left","top-right","bottom-right","bottom-left"];for(const n of e)if(t.classList.contains(Yg(n)))return n}(t),this._referenceCoordinates=function(t,e){const n=new ya(t),o=e.split("-"),i={x:"right"==o[1]?n.right:n.left,y:"bottom"==o[0]?n.bottom:n.top};return i.x+=t.ownerDocument.defaultView.scrollX,i.y+=t.ownerDocument.defaultView.scrollY,i}(e,function(t){const e=t.split("-"),n={top:"bottom",bottom:"top",left:"right",right:"left"};return`${n[e[0]]}-${n[e[1]]}`}(this.activeHandlePosition)),this.originalWidth=o.width,this.originalHeight=o.height,this.aspectRatio=o.width/o.height;const i=n.style.width;i&&i.match(/^\d+(\.\d*)?%$/)?this.originalWidthPercents=parseFloat(i):this.originalWidthPercents=function(t,e){const n=t.parentElement,o=parseFloat(n.ownerDocument.defaultView.getComputedStyle(n).width);return e.width/o*100}(n,o)}update(t){this.proposedWidth=t.width,this.proposedHeight=t.height,this.proposedWidthPercents=t.widthPercents,this.proposedHandleHostWidth=t.handleHostWidth,this.proposedHandleHostHeight=t.handleHostHeight}}function Yg(t){return`ck-widget__resizer__handle-${t}`}he(Jg,se);class Qg extends Od{constructor(){super();const t=this.bindTemplate;this.setTemplate({tag:"div",attributes:{class:["ck","ck-size-view",t.to("_viewPosition",(t=>t?`ck-orientation-${t}`:""))],style:{display:t.if("_isVisible","none",(t=>!t))}},children:[{text:t.to("_label")}]})}_bindToState(t,e){this.bind("_isVisible").to(e,"proposedWidth",e,"proposedHeight",((t,e)=>null!==t&&null!==e)),this.bind("_label").to(e,"proposedHandleHostWidth",e,"proposedHandleHostHeight",e,"proposedWidthPercents",((e,n,o)=>"px"===t.unit?`${e}×${n}`:`${o}%`)),this.bind("_viewPosition").to(e,"activeHandlePosition",e,"proposedHandleHostWidth",e,"proposedHandleHostHeight",((t,e,n)=>e<50||n<50?"above-center":t))}_dismiss(){this.unbind(),this._isVisible=!1}}class Xg{constructor(t){this._options=t,this._viewResizerWrapper=null,this.set("isEnabled",!0),this.decorate("begin"),this.decorate("cancel"),this.decorate("commit"),this.decorate("updateSize"),this.on("commit",(t=>{this.state.proposedWidth||this.state.proposedWidthPercents||(this._cleanup(),t.stop())}),{priority:"high"}),this.on("change:isEnabled",(()=>{this.isEnabled&&this.redraw()}))}attach(){const t=this,e=this._options.viewElement;this._options.editor.editing.view.change((n=>{const o=n.createUIElement("div",{class:"ck ck-reset_all ck-widget__resizer"},(function(e){const n=this.toDomElement(e);return t._appendHandles(n),t._appendSizeUI(n),t.on("change:isEnabled",((t,e,o)=>{n.style.display=o?"":"none"})),n.style.display=t.isEnabled?"":"none",n}));n.insert(n.createPositionAt(e,"end"),o),n.addClass("ck-widget_with-resizer",e),this._viewResizerWrapper=o}))}begin(t){this.state=new Jg(this._options),this._sizeView._bindToState(this._options,this.state),this._initialViewWidth=this._options.viewElement.getStyle("width"),this.state.begin(t,this._getHandleHost(),this._getResizeHost())}updateSize(t){const e=this._proposeNewSize(t);this._options.editor.editing.view.change((t=>{const n=this._options.unit||"%",o=("%"===n?e.widthPercents:e.width)+n;t.setStyle("width",o,this._options.viewElement)}));const n=this._getHandleHost(),o=new ya(n);e.handleHostWidth=Math.round(o.width),e.handleHostHeight=Math.round(o.height);const i=new ya(n);e.width=Math.round(i.width),e.height=Math.round(i.height),this.redraw(o),this.state.update(e)}commit(){const t=this._options.unit||"%",e=("%"===t?this.state.proposedWidthPercents:this.state.proposedWidth)+t;this._options.editor.editing.view.change((()=>{this._cleanup(),this._options.onCommit(e)}))}cancel(){this._cleanup()}destroy(){this.cancel()}redraw(t){const e=this._domResizerWrapper;if(!((n=e)&&n.ownerDocument&&n.ownerDocument.contains(n)))return;var n;const o=e.parentElement,i=this._getHandleHost(),r=this._viewResizerWrapper,s=[r.getStyle("width"),r.getStyle("height"),r.getStyle("left"),r.getStyle("top")];let a;if(o.isSameNode(i)){const e=t||new ya(i);a=[e.width+"px",e.height+"px",void 0,void 0]}else a=[i.offsetWidth+"px",i.offsetHeight+"px",i.offsetLeft+"px",i.offsetTop+"px"];"same"!==Oo(s,a)&&this._options.editor.editing.view.change((t=>{t.setStyle({width:a[0],height:a[1],left:a[2],top:a[3]},r)}))}containsHandle(t){return this._domResizerWrapper.contains(t)}static isResizeHandle(t){return t.classList.contains("ck-widget__resizer__handle")}_cleanup(){this._sizeView._dismiss();this._options.editor.editing.view.change((t=>{t.setStyle("width",this._initialViewWidth,this._options.viewElement)}))}_proposeNewSize(t){const e=this.state,n={x:(o=t).pageX,y:o.pageY};var o;const i=!this._options.isCentered||this._options.isCentered(this),r={x:e._referenceCoordinates.x-(n.x+e.originalWidth),y:n.y-e.originalHeight-e._referenceCoordinates.y};i&&e.activeHandlePosition.endsWith("-right")&&(r.x=n.x-(e._referenceCoordinates.x+e.originalWidth)),i&&(r.x*=2);const s={width:Math.abs(e.originalWidth+r.x),height:Math.abs(e.originalHeight+r.y)};s.dominant=s.width/e.aspectRatio>s.height?"width":"height",s.max=s[s.dominant];const a={width:s.width,height:s.height};return"width"==s.dominant?a.height=a.width/e.aspectRatio:a.width=a.height*e.aspectRatio,{width:Math.round(a.width),height:Math.round(a.height),widthPercents:Math.min(Math.round(e.originalWidthPercents/e.originalWidth*a.width*100)/100,100)}}_getResizeHost(){const t=this._domResizerWrapper.parentElement;return this._options.getResizeHost(t)}_getHandleHost(){const t=this._domResizerWrapper.parentElement;return this._options.getHandleHost(t)}get _domResizerWrapper(){return this._options.editor.editing.view.domConverter.mapViewToDom(this._viewResizerWrapper)}_appendHandles(t){const e=["top-left","top-right","bottom-right","bottom-left"];for(const o of e)t.appendChild(new Md({tag:"div",attributes:{class:"ck-widget__resizer__handle "+(n=o,`ck-widget__resizer__handle-${n}`)}}).render());var n}_appendSizeUI(t){this._sizeView=new Qg,this._sizeView.render(),t.appendChild(this._sizeView.element)}}he(Xg,se);var tf=n(2263),ef={attributes:{"data-cke":!0}};ef.setAttributes=is(),ef.insert=ns().bind(null,"head"),ef.domAPI=ts(),ef.insertStyleElement=ss();Qr()(tf.Z,ef);tf.Z&&tf.Z.locals&&tf.Z.locals;class nf extends pe{static get pluginName(){return"WidgetResize"}init(){const t=this.editor.editing,e=ps.window.document;this.set("visibleResizer",null),this.set("_activeResizer",null),this._resizers=new Map,t.view.addObserver(hp),this._observer=Object.create(Es),this.listenTo(t.view.document,"mousedown",this._mouseDownListener.bind(this),{priority:"high"}),this._observer.listenTo(e,"mousemove",this._mouseMoveListener.bind(this)),this._observer.listenTo(e,"mouseup",this._mouseUpListener.bind(this));const n=()=>{this.visibleResizer&&this.visibleResizer.redraw()};this._redrawFocusedResizerThrottled=tm(n,200),this.on("change:visibleResizer",n),this.editor.ui.on("update",this._redrawFocusedResizerThrottled),this.editor.model.document.on("change",(()=>{for(const[t,e]of this._resizers)t.isAttached()||(this._resizers.delete(t),e.destroy())}),{priority:"lowest"}),this._observer.listenTo(ps.window,"resize",this._redrawFocusedResizerThrottled);const o=this.editor.editing.view.document.selection;o.on("change",(()=>{const t=o.getSelectedElement();this.visibleResizer=this.getResizerByViewElement(t)||null}))}destroy(){this._observer.stopListening();for(const t of this._resizers.values())t.destroy();this._redrawFocusedResizerThrottled.cancel()}attachTo(t){const e=new Xg(t),n=this.editor.plugins;if(e.attach(),n.has("WidgetToolbarRepository")){const t=n.get("WidgetToolbarRepository");e.on("begin",(()=>{t.forceDisabled("resize")}),{priority:"lowest"}),e.on("cancel",(()=>{t.clearForceDisabled("resize")}),{priority:"highest"}),e.on("commit",(()=>{t.clearForceDisabled("resize")}),{priority:"highest"})}this._resizers.set(t.viewElement,e);const o=this.editor.editing.view.document.selection.getSelectedElement();return this.getResizerByViewElement(o)==e&&(this.visibleResizer=e),e}getResizerByViewElement(t){return this._resizers.get(t)}_getResizerByHandle(t){for(const e of this._resizers.values())if(e.containsHandle(t))return e}_mouseDownListener(t,e){const n=e.domTarget;Xg.isResizeHandle(n)&&(this._activeResizer=this._getResizerByHandle(n),this._activeResizer&&(this._activeResizer.begin(n),t.stop(),e.preventDefault()))}_mouseMoveListener(t,e){this._activeResizer&&this._activeResizer.updateSize(e)}_mouseUpListener(){this._activeResizer&&(this._activeResizer.commit(),this._activeResizer=null)}}function of(t,e){const n=t.createEmptyElement("img"),o="imageBlock"===e?t.createContainerElement("figure",{class:"image"}):t.createContainerElement("span",{class:"image-inline"},{isAllowedInsideAttributeElement:!0});return t.insert(t.createPositionAt(o,0),n),o}function rf(t,e){if(t.plugins.has("ImageInlineEditing")!==t.plugins.has("ImageBlockEditing"))return{name:"img"};const n=t.plugins.get("ImageUtils");return t=>{if(!n.isInlineImageView(t))return null;return(t.findAncestor(n.isBlockImageView)?"imageBlock":"imageInline")!==e?null:{name:!0}}}function sf(t,e){const n=Ta(e.getSelectedBlocks());return!n||t.isObject(n)||n.isEmpty&&"listItem"!=n.name?"imageBlock":"imageInline"}he(nf,se);class af extends pe{static get pluginName(){return"ImageUtils"}isImage(t){return this.isInlineImage(t)||this.isBlockImage(t)}isInlineImageView(t){return!!t&&t.is("element","img")}isBlockImageView(t){return!!t&&t.is("element","figure")&&t.hasClass("image")}insertImage(t={},e=null,n=null){const o=this.editor,i=o.model,r=i.document.selection;n=cf(o,e||r,n),t={...Object.fromEntries(r.getAttributes()),...t};for(const e in t)i.schema.checkAttribute(n,e)||delete t[e];return i.change((o=>{const s=o.createElement(n,t);return e||"imageInline"==n||(e=wm(r,i)),i.insertContent(s,e),s.parent?(o.setSelection(s,"on"),s):null}))}getClosestSelectedImageWidget(t){const e=t.getSelectedElement();if(e&&this.isImageWidget(e))return e;let n=t.getFirstPosition().parent;for(;n;){if(n.is("element")&&this.isImageWidget(n))return n;n=n.parent}return null}getClosestSelectedImageElement(t){const e=t.getSelectedElement();return this.isImage(e)?e:t.getFirstPosition().findAncestor("imageBlock")}isImageAllowed(){const t=this.editor.model.document.selection;return function(t,e){if("imageBlock"==cf(t,e)){const n=function(t,e){const n=wm(t,e).start.parent;if(n.isEmpty&&!n.is("element","$root"))return n.parent;return n}(e,t.model);if(t.model.schema.checkChild(n,"imageBlock"))return!0}else if(t.model.schema.checkChild(e.focus,"imageInline"))return!0;return!1}(this.editor,t)&&function(t){return[...t.focus.getAncestors()].every((t=>!t.is("element","imageBlock")))}(t)}toImageWidget(t,e,n){e.setCustomProperty("image",!0,t);return pm(t,e,{label:()=>{const e=this.findViewImgElement(t).getAttribute("alt");return e?`${e} ${n}`:n}})}isImageWidget(t){return!!t.getCustomProperty("image")&&hm(t)}isBlockImage(t){return!!t&&t.is("element","imageBlock")}isInlineImage(t){return!!t&&t.is("element","imageInline")}findViewImgElement(t){if(this.isInlineImageView(t))return t;const e=this.editor.editing.view;for(const{item:n}of e.createRangeIn(t))if(this.isInlineImageView(n))return n}}function cf(t,e,n){const o=t.model.schema,i=t.config.get("image.insert.type");return t.plugins.has("ImageBlockEditing")?t.plugins.has("ImageInlineEditing")?n||("inline"===i?"imageInline":"block"===i?"imageBlock":e.is("selection")?sf(o,e):o.checkChild(e,"imageInline")?"imageInline":"imageBlock"):"imageBlock":"imageInline"}class lf extends ge{refresh(){const t=this.editor,e=t.plugins.get("ImageUtils"),n=t.model.document.selection.getSelectedElement();this.isEnabled=e.isImageAllowed()||e.isImage(n)}execute(t){const e=To(t.file),n=this.editor.model.document.selection,o=this.editor.plugins.get("ImageUtils"),i=Object.fromEntries(n.getAttributes());e.forEach(((t,e)=>{const r=n.getSelectedElement();if(e&&r&&o.isImage(r)){const e=this.editor.model.createPositionAfter(r);this._uploadImage(t,i,e)}else this._uploadImage(t,i)}))}_uploadImage(t,e,n){const o=this.editor,i=o.plugins.get(hg).createLoader(t),r=o.plugins.get("ImageUtils");i&&r.insertImage({...e,uploadId:i.id},n)}}class df extends pe{static get requires(){return[hg,xh,Og,af]}static get pluginName(){return"ImageUploadEditing"}constructor(t){super(t),t.config.define("image",{upload:{types:["jpeg","png","gif","bmp","webp","tiff"]}}),this._uploadImageElements=new Map}init(){const t=this.editor,e=t.model.document,n=t.conversion,o=t.plugins.get(hg),i=t.plugins.get("ImageUtils"),r=bg(t.config.get("image.upload.types")),s=new lf(t);t.commands.add("uploadImage",s),t.commands.add("imageUpload",s),n.for("upcast").attributeToAttribute({view:{name:"img",key:"uploadId"},model:"uploadId"}),this.listenTo(t.editing.view.document,"clipboardInput",((e,n)=>{if(o=n.dataTransfer,Array.from(o.types).includes("text/html")&&""!==o.getData("text/html"))return;var o;const i=Array.from(n.dataTransfer.files).filter((t=>!!t&&r.test(t.type)));i.length&&(e.stop(),t.model.change((e=>{n.targetRanges&&e.setSelection(n.targetRanges.map((e=>t.editing.mapper.toModelRange(e)))),t.model.enqueueChange((()=>{t.execute("uploadImage",{file:i})}))})))})),this.listenTo(t.plugins.get("ClipboardPipeline"),"inputTransformation",((e,n)=>{const r=Array.from(t.editing.view.createRangeIn(n.content)).filter((t=>function(t,e){return!(!t.isInlineImageView(e)||!e.getAttribute("src"))&&(e.getAttribute("src").match(/^data:image\/\w+;base64,/g)||e.getAttribute("src").match(/^blob:/g))}(i,t.item)&&!t.item.getAttribute("uploadProcessed"))).map((t=>({promise:kg(t.item),imageElement:t.item})));if(!r.length)return;const s=new pp(t.editing.view.document);for(const t of r){s.setAttribute("uploadProcessed",!0,t.imageElement);const e=o.createLoader(t.promise);e&&(s.setAttribute("src","",t.imageElement),s.setAttribute("uploadId",e.id,t.imageElement))}})),t.editing.view.document.on("dragover",((t,e)=>{e.preventDefault()})),e.on("change",(()=>{const n=e.differ.getChanges({includeChangesInGraveyard:!0}).reverse(),i=new Set;for(const e of n)if("insert"==e.type&&"$text"!=e.name){const n=e.position.nodeAfter,r="$graveyard"==e.position.root.rootName;for(const e of uf(t,n)){const t=e.getAttribute("uploadId");if(!t)continue;const n=o.loaders.get(t);n&&(r?i.has(t)||n.abort():(i.add(t),this._uploadImageElements.set(t,e),"idle"==n.status&&this._readAndUpload(n)))}}})),this.on("uploadComplete",((t,{imageElement:e,data:n})=>{const o=n.urls?n.urls:n;this.editor.model.change((t=>{t.setAttribute("src",o.default,e),this._parseAndSetSrcsetAttributeOnImage(o,e,t)}))}),{priority:"low"})}afterInit(){const t=this.editor.model.schema;this.editor.plugins.has("ImageBlockEditing")&&t.extend("imageBlock",{allowAttributes:["uploadId","uploadStatus"]}),this.editor.plugins.has("ImageInlineEditing")&&t.extend("imageInline",{allowAttributes:["uploadId","uploadStatus"]})}_readAndUpload(t){const e=this.editor,n=e.model,o=e.locale.t,i=e.plugins.get(hg),r=e.plugins.get(xh),s=e.plugins.get("ImageUtils"),a=this._uploadImageElements;return n.enqueueChange({isUndoable:!1},(e=>{e.setAttribute("uploadStatus","reading",a.get(t.id))})),t.read().then((()=>{const o=t.upload(),i=a.get(t.id);if(ar.isSafari){const t=e.editing.mapper.toViewElement(i),n=s.findViewImgElement(t);e.editing.view.once("render",(()=>{if(!n.parent)return;const t=e.editing.view.domConverter.mapViewToDom(n.parent);if(!t)return;const o=t.style.display;t.style.display="none",t._ckHack=t.offsetHeight,t.style.display=o}))}return n.enqueueChange({isUndoable:!1},(t=>{t.setAttribute("uploadStatus","uploading",i)})),o})).then((e=>{n.enqueueChange({isUndoable:!1},(n=>{const o=a.get(t.id);n.setAttribute("uploadStatus","complete",o),this.fire("uploadComplete",{data:e,imageElement:o})})),c()})).catch((e=>{if("error"!==t.status&&"aborted"!==t.status)throw e;"error"==t.status&&e&&r.showWarning(e,{title:o("Upload failed"),namespace:"upload"}),n.enqueueChange({isUndoable:!1},(e=>{e.remove(a.get(t.id))})),c()}));function c(){n.enqueueChange({isUndoable:!1},(e=>{const n=a.get(t.id);e.removeAttribute("uploadId",n),e.removeAttribute("uploadStatus",n),a.delete(t.id)})),i.destroyLoader(t)}}_parseAndSetSrcsetAttributeOnImage(t,e,n){let o=0;const i=Object.keys(t).filter((t=>{const e=parseInt(t,10);if(!isNaN(e))return o=Math.max(o,e),!0})).map((e=>`${t[e]} ${e}w`)).join(", ");""!=i&&n.setAttribute("srcset",{data:i,width:o},e)}}function uf(t,e){const n=t.plugins.get("ImageUtils");return Array.from(t.model.createRangeOn(e)).filter((t=>n.isImage(t.item))).map((t=>t.item))}class hf extends pe{static get pluginName(){return"ImageUpload"}static get requires(){return[df,_g,Dg]}}const pf=Symbol("isWpButtonMacroSymbol");function mf(t){const e=t.getSelectedElement();return!(!e||!function(t){return!!t.getCustomProperty(pf)&&hm(t)}(e))}class gf extends pe{static get pluginName(){return"OPChildPagesEditing"}static get buttonName(){return"insertChildPages"}init(){const t=this.editor,e=t.model,n=t.conversion;e.schema.register("op-macro-child-pages",{allowWhere:["$block"],allowAttributes:["page"],isBlock:!0,isLimit:!0}),n.for("upcast").elementToElement({view:{name:"macro",classes:"child_pages"},model:(t,{writer:e})=>{const n=t.getAttribute("data-page")||"",o="true"==t.getAttribute("data-include-parent");return e.createElement("op-macro-child-pages",{page:n,includeParent:o})}}),n.for("editingDowncast").elementToElement({model:"op-macro-child-pages",view:(t,{writer:e})=>this.createMacroViewElement(t,e)}).add((t=>t.on("attribute:page",this.modelAttributeToView.bind(this)))).add((t=>t.on("attribute:includeParent",this.modelAttributeToView.bind(this)))),n.for("dataDowncast").elementToElement({model:"op-macro-child-pages",view:(t,{writer:e})=>e.createContainerElement("macro",{class:"child_pages","data-page":t.getAttribute("page")||"","data-include-parent":t.getAttribute("includeParent")||""})}),t.ui.componentFactory.add(gf.buttonName,(e=>{const n=new pu(e);return n.set({label:window.I18n.t("js.editor.macro.child_pages.button"),withText:!0}),n.on("execute",(()=>{t.model.change((e=>{const n=e.createElement("op-macro-child-pages",{});t.model.insertContent(n,t.model.document.selection)}))})),n}))}modelAttributeToView(t,e,n){const o=e.item;if(!o.is("element","op-macro-child-pages"))return;n.consumable.consume(e.item,t.name);const i=n.mapper.toViewElement(o);n.writer.remove(n.writer.createRangeIn(i)),this.setPlaceholderContent(n.writer,o,i)}macroLabel(){return window.I18n.t("js.editor.macro.child_pages.text")}pageLabel(t){return t&&t.length>0?t:window.I18n.t("js.editor.macro.child_pages.this_page")}includeParentText(t){return t?` (${window.I18n.t("js.editor.macro.child_pages.include_parent")})`:""}createMacroViewElement(t,e){const n=e.createContainerElement("div");return this.setPlaceholderContent(e,t,n),function(t,e,n){return e.setCustomProperty(pf,!0,t),pm(t,e,{label:n})}(n,e,{label:this.macroLabel()})}setPlaceholderContent(t,e,n){const o=e.getAttribute("page"),i=e.getAttribute("includeParent"),r=this.macroLabel(),s=this.pageLabel(o),a=t.createContainerElement("span",{class:"macro-value"});let c=[t.createText(`${r} `)];t.insert(t.createPositionAt(a,0),t.createText(`${s}`)),c.push(a),c.push(t.createText(this.includeParentText(i))),t.insert(t.createPositionAt(n,0),c)}}class ff extends pe{static get requires(){return[Vh]}static get pluginName(){return"OPChildPagesToolbar"}init(){const t=this.editor,e=this.editor.model,n=xm(t);ng(t,"opEditChildPagesMacroButton",(t=>{const o=n.services.macros,i=t.getAttribute("page"),r=t.getAttribute("includeParent"),s=i&&i.length>0?i:"";o.configureChildPages(s,r).then((n=>e.change((e=>{e.setAttribute("page",n.page,t),e.setAttribute("includeParent",n.includeParent,t)}))))}))}afterInit(){ig(this,this.editor,"OPChildPages",mf)}}class bf extends ge{execute(){const t=this.editor.model,e=t.document;t.change((n=>{!function(t,e,n){const o=n.isCollapsed,i=n.getFirstRange(),r=i.start.parent,s=i.end.parent,a=r==s;if(o){const o=Bm(t.schema,n.getAttributes());kf(t,e,i.end),e.removeSelectionAttribute(n.getAttributeKeys()),e.setSelectionAttribute(o)}else{const o=!(i.start.isAtStart&&i.end.isAtEnd);t.deleteContent(n,{leaveUnmerged:o}),a?kf(t,e,n.focus):o&&e.setSelection(s,0)}}(t,n,e.selection),this.fire("afterExecute",{writer:n})}))}refresh(){const t=this.editor.model,e=t.document;this.isEnabled=function(t,e){if(e.rangeCount>1)return!1;const n=e.anchor;if(!n||!t.checkChild(n,"softBreak"))return!1;const o=e.getFirstRange(),i=o.start.parent,r=o.end.parent;if((wf(i,t)||wf(r,t))&&i!==r)return!1;return!0}(t.schema,e.selection)}}function kf(t,e,n){const o=e.createElement("softBreak");t.insertContent(o,n),e.setSelection(o,"after")}function wf(t,e){return!t.is("rootElement")&&(e.isLimit(t)||wf(t.parent,e))}class _f extends pe{static get pluginName(){return"ShiftEnter"}init(){const t=this.editor,e=t.model.schema,n=t.conversion,o=t.editing.view,i=o.document;e.register("softBreak",{allowWhere:"$text",isInline:!0}),n.for("upcast").elementToElement({model:"softBreak",view:"br"}),n.for("downcast").elementToElement({model:"softBreak",view:(t,{writer:e})=>e.createEmptyElement("br")}),o.addObserver(Im),t.commands.add("shiftEnter",new bf(t)),this.listenTo(i,"enter",((e,n)=>{n.preventDefault(),n.isSoft&&(t.execute("shiftEnter"),o.scrollToTheSelection())}),{priority:"low"})}}class Cf extends ge{constructor(t){super(t),this.affectsData=!1}execute(){const t=this.editor.model,e=t.document.selection;let n=t.schema.getLimitElement(e);if(e.containsEntireContent(n)||!Af(t.schema,n))do{if(n=n.parent,!n)return}while(!Af(t.schema,n));t.change((t=>{t.setSelection(n,"in")}))}}function Af(t,e){return t.isLimit(e)&&(t.checkChild(e,"$text")||t.checkChild(e,"paragraph"))}const vf=mr("Ctrl+A");class yf extends pe{static get pluginName(){return"SelectAllEditing"}init(){const t=this.editor,e=t.editing.view.document;t.commands.add("selectAll",new Cf(t)),this.listenTo(e,"keydown",((e,n)=>{pr(n)===vf&&(t.execute("selectAll"),n.preventDefault())}))}}class xf extends pe{static get pluginName(){return"SelectAllUI"}init(){const t=this.editor;t.ui.componentFactory.add("selectAll",(e=>{const n=t.commands.get("selectAll"),o=new pu(e),i=e.t;return o.set({label:i("Select all"),icon:'',keystroke:"Ctrl+A",tooltip:!0}),o.bind("isOn","isEnabled").to(n,"value","isEnabled"),this.listenTo(o,"execute",(()=>{t.execute("selectAll"),t.editing.view.focus()})),o}))}}class Ef extends pe{static get requires(){return[yf,xf]}static get pluginName(){return"SelectAll"}}class Df extends ge{constructor(t,e){super(t),this._buffer=new zm(t.model,e)}get buffer(){return this._buffer}destroy(){super.destroy(),this._buffer.destroy()}execute(t={}){const e=this.editor.model,n=e.document,o=t.text||"",i=o.length,r=t.range?e.createSelection(t.range):n.selection,s=t.resultRange;e.enqueueChange(this._buffer.batch,(t=>{this._buffer.lock(),e.deleteContent(r),o&&e.insertContent(t.createText(o,n.selection.getAttributes()),r),s?t.setSelection(s):r.is("documentSelection")||t.setSelection(r),this._buffer.unlock(),this._buffer.input(i)}))}}class Sf{constructor(t){this.editor=t,this.editing=this.editor.editing}handle(t,e){if(function(t){if(0==t.length)return!1;for(const e of t)if("children"===e.type&&!Nm(e))return!0;return!1}(t))this._handleContainerChildrenMutations(t,e);else for(const n of t)this._handleTextMutation(n,e),this._handleTextNodeInsertion(n)}_handleContainerChildrenMutations(t,e){const n=function(t){const e=t.map((t=>t.node)).reduce(((t,e)=>t.getCommonAncestor(e,{includeSelf:!0})));if(!e)return;return e.getAncestors({includeSelf:!0,parentFirst:!0}).find((t=>t.is("containerElement")||t.is("rootElement")))}(t);if(!n)return;const o=this.editor.editing.view.domConverter.mapViewToDom(n),i=new Cs(this.editor.editing.view.document),r=this.editor.data.toModel(i.domToView(o)).getChild(0),s=this.editor.editing.mapper.toModelElement(n);if(!s)return;const a=Array.from(r.getChildren()),c=Array.from(s.getChildren()),l=a[a.length-1],d=c[c.length-1],u=l&&l.is("element","softBreak"),h=d&&!d.is("element","softBreak");u&&h&&a.pop();const p=this.editor.model.schema;if(!Bf(a,p)||!Bf(c,p))return;const m=a.map((t=>t.is("$text")?t.data:"@")).join("").replace(/\u00A0/g," "),g=c.map((t=>t.is("$text")?t.data:"@")).join("").replace(/\u00A0/g," ");if(g===m)return;const f=$r(g,m),{firstChangeAt:b,insertions:k,deletions:w}=Tf(f);let _=null;e&&(_=this.editing.mapper.toModelRange(e.getFirstRange()));const C=m.substr(b,k),A=this.editor.model.createRange(this.editor.model.createPositionAt(s,b),this.editor.model.createPositionAt(s,b+w));this.editor.execute("input",{text:C,range:A,resultRange:_})}_handleTextMutation(t,e){if("text"!=t.type)return;const n=t.newText.replace(/\u00A0/g," "),o=t.oldText.replace(/\u00A0/g," ");if(o===n)return;const i=$r(o,n),{firstChangeAt:r,insertions:s,deletions:a}=Tf(i);let c=null;e&&(c=this.editing.mapper.toModelRange(e.getFirstRange()));const l=this.editing.view.createPositionAt(t.node,r),d=this.editing.mapper.toModelPosition(l),u=this.editor.model.createRange(d,d.getShiftedBy(a)),h=n.substr(r,s);this.editor.execute("input",{text:h,range:u,resultRange:c})}_handleTextNodeInsertion(t){if("children"!=t.type)return;const e=Nm(t),n=this.editing.view.createPositionAt(t.node,e.index),o=this.editing.mapper.toModelPosition(n),i=e.values[0].data;this.editor.execute("input",{text:i.replace(/\u00A0/g," "),range:this.editor.model.createRange(o)})}}function Bf(t,e){return t.every((t=>e.isInline(t)))}function Tf(t){let e=null,n=null;for(let o=0;o{n.deleteContent(n.document.selection)})),t.unlock()}ar.isAndroid?o.document.on("beforeinput",((t,e)=>r(e)),{priority:"lowest"}):o.document.on("keydown",((t,e)=>r(e)),{priority:"lowest"}),o.document.on("compositionstart",(function(){const t=n.document,e=1!==t.selection.rangeCount||t.selection.getFirstRange().isFlat;t.selection.isCollapsed||e||s()}),{priority:"lowest"}),o.document.on("compositionend",(()=>{e=n.createSelection(n.document.selection)}),{priority:"lowest"})}(t),function(t){t.editing.view.document.on("mutations",((e,n,o)=>{new Sf(t).handle(n,o)}))}(t)}}class If extends pe{static get requires(){return[Pf,Lm]}static get pluginName(){return"Typing"}}function Rf(t,e){let n=t.start;return{text:Array.from(t.getItems()).reduce(((t,o)=>o.is("$text")||o.is("$textProxy")?t+o.data:(n=e.createPositionAfter(o),"")),""),range:e.createRange(n,t.end)}}class zf{constructor(t,e){this.model=t,this.testCallback=e,this.hasMatch=!1,this.set("isEnabled",!0),this.on("change:isEnabled",(()=>{this.isEnabled?this._startListening():(this.stopListening(t.document.selection),this.stopListening(t.document))})),this._startListening()}_startListening(){const t=this.model.document;this.listenTo(t.selection,"change:range",((e,{directChange:n})=>{n&&(t.selection.isCollapsed?this._evaluateTextBeforeSelection("selection"):this.hasMatch&&(this.fire("unmatched"),this.hasMatch=!1))})),this.listenTo(t,"change:data",((t,e)=>{!e.isUndo&&e.isLocal&&this._evaluateTextBeforeSelection("data",{batch:e})}))}_evaluateTextBeforeSelection(t,e={}){const n=this.model,o=n.document.selection,i=n.createRange(n.createPositionAt(o.focus.parent,0),o.focus),{text:r,range:s}=Rf(i,n),a=this.testCallback(r);if(!a&&this.hasMatch&&this.fire("unmatched"),this.hasMatch=!!a,a){const n=Object.assign(e,{text:r,range:s});"object"==typeof a&&Object.assign(n,a),this.fire(`matched:${t}`,n)}}}he(zf,se);class Ff extends pe{static get pluginName(){return"TwoStepCaretMovement"}constructor(t){super(t),this.attributes=new Set,this._overrideUid=null}init(){const t=this.editor,e=t.model,n=t.editing.view,o=t.locale,i=e.document.selection;this.listenTo(n.document,"arrowKey",((t,e)=>{if(!i.isCollapsed)return;if(e.shiftKey||e.altKey||e.ctrlKey)return;const n=e.keyCode==ur.arrowright,r=e.keyCode==ur.arrowleft;if(!n&&!r)return;const s=o.contentLanguageDirection;let a=!1;a="ltr"===s&&n||"rtl"===s&&r?this._handleForwardMovement(e):this._handleBackwardMovement(e),!0===a&&t.stop()}),{context:"$text",priority:"highest"}),this._isNextGravityRestorationSkipped=!1,this.listenTo(i,"change:range",((t,e)=>{this._isNextGravityRestorationSkipped?this._isNextGravityRestorationSkipped=!1:this._isGravityOverridden&&(!e.directChange&&Vf(i.getFirstPosition(),this.attributes)||this._restoreGravity())}))}registerAttribute(t){this.attributes.add(t)}_handleForwardMovement(t){const e=this.attributes,n=this.editor.model.document.selection,o=n.getFirstPosition();return!this._isGravityOverridden&&((!o.isAtStart||!Nf(n,e))&&(Vf(o,e)?(Mf(t),this._overrideGravity(),!0):void 0))}_handleBackwardMovement(t){const e=this.attributes,n=this.editor.model,o=n.document.selection,i=o.getFirstPosition();return this._isGravityOverridden?(Mf(t),this._restoreGravity(),Of(n,e,i),!0):i.isAtStart?!!Nf(o,e)&&(Mf(t),Of(n,e,i),!0):function(t,e){return Vf(t.getShiftedBy(-1),e)}(i,e)?i.isAtEnd&&!Nf(o,e)&&Vf(i,e)?(Mf(t),Of(n,e,i),!0):(this._isNextGravityRestorationSkipped=!0,this._overrideGravity(),!1):void 0}get _isGravityOverridden(){return!!this._overrideUid}_overrideGravity(){this._overrideUid=this.editor.model.change((t=>t.overrideSelectionGravity()))}_restoreGravity(){this.editor.model.change((t=>{t.restoreSelectionGravity(this._overrideUid),this._overrideUid=null}))}}function Nf(t,e){for(const n of e)if(t.hasAttribute(n))return!0;return!1}function Of(t,e,n){const o=n.nodeBefore;t.change((t=>{o?t.setSelectionAttribute(o.getAttributes()):t.removeSelectionAttribute(e)}))}function Mf(t){t.preventDefault()}function Vf(t,e){const{nodeBefore:n,nodeAfter:o}=t;for(const t of e){const e=n?n.getAttribute(t):void 0;if((o?o.getAttribute(t):void 0)!==e)return!0}return!1}Lf('"'),Lf("'"),Lf("'"),Lf('"'),Lf('"'),Lf("'");function Lf(t){return new RegExp(`(^|\\s)(${t})([^${t}]*)(${t})$`)}function Hf(t,e,n,o){return o.createRange(qf(t,e,n,!0,o),qf(t,e,n,!1,o))}function qf(t,e,n,o,i){let r=t.textNode||(o?t.nodeBefore:t.nodeAfter),s=null;for(;r&&r.getAttribute(e)==n;)s=r,r=o?r.previousSibling:r.nextSibling;return s?i.createPositionAt(s,o?"before":"after"):t}function Wf(t,e,n,o){const i=t.editing.view,r=new Set;i.document.registerPostFixer((i=>{const s=t.model.document.selection;let a=!1;if(s.hasAttribute(e)){const c=Hf(s.getFirstPosition(),e,s.getAttribute(e),t.model),l=t.editing.mapper.toViewRange(c);for(const t of l.getItems())t.is("element",n)&&!t.hasClass(o)&&(i.addClass(o,t),r.add(t),a=!0)}return a})),t.conversion.for("editingDowncast").add((t=>{function e(){i.change((t=>{for(const e of r.values())t.removeClass(o,e),r.delete(e)}))}t.on("insert",e,{priority:"highest"}),t.on("remove",e,{priority:"highest"}),t.on("attribute",e,{priority:"highest"}),t.on("selection",e,{priority:"highest"})}))}class jf extends ge{constructor(t){super(t),this._stack=[],this._createdBatches=new WeakSet,this.refresh(),this.listenTo(t.data,"set",((t,e)=>{e[1]={...e[1]};const n=e[1];n.batchType||(n.batchType={isUndoable:!1})}),{priority:"high"}),this.listenTo(t.data,"set",((t,e)=>{e[1].batchType.isUndoable||this.clearStack()}))}refresh(){this.isEnabled=this._stack.length>0}addBatch(t){const e=this.editor.model.document.selection,n={ranges:e.hasOwnRange?Array.from(e.getRanges()):[],isBackward:e.isBackward};this._stack.push({batch:t,selection:n}),this.refresh()}clearStack(){this._stack=[],this.refresh()}_restoreSelection(t,e,n){const o=this.editor.model,i=o.document,r=[],s=t.map((t=>t.getTransformedByOperations(n))),a=s.flat();for(const t of s){const e=t.filter((t=>t.root!=i.graveyard)).filter((t=>!$f(t,a)));e.length&&(Uf(e),r.push(e[0]))}r.length&&o.change((t=>{t.setSelection(r,{backward:e})}))}_undo(t,e){const n=this.editor.model,o=n.document;this._createdBatches.add(e);const i=t.operations.slice().filter((t=>t.isDocumentOperation));i.reverse();for(const t of i){const i=t.baseVersion+1,r=Array.from(o.history.getOperations(i)),s=ip([t.getReversed()],r,{useRelations:!0,document:this.editor.model.document,padWithNoOps:!1,forceWeakRemove:!0}).operationsA;for(const i of s)e.addOperation(i),n.applyOperation(i),o.history.setOperationAsUndone(t,i)}}}function Uf(t){t.sort(((t,e)=>t.start.isBefore(e.start)?-1:1));for(let e=1;ee!==t&&e.containsRange(t,!0)))}class Gf extends jf{execute(t=null){const e=t?this._stack.findIndex((e=>e.batch==t)):this._stack.length-1,n=this._stack.splice(e,1)[0],o=this.editor.model.createBatch({isUndo:!0});this.editor.model.enqueueChange(o,(()=>{this._undo(n.batch,o);const t=this.editor.model.document.history.getOperations(n.batch.baseVersion);this._restoreSelection(n.selection.ranges,n.selection.isBackward,t),this.fire("revert",n.batch,o)})),this.refresh()}}class Kf extends jf{execute(){const t=this._stack.pop(),e=this.editor.model.createBatch({isUndo:!0});this.editor.model.enqueueChange(e,(()=>{const n=t.batch.operations[t.batch.operations.length-1].baseVersion+1,o=this.editor.model.document.history.getOperations(n);this._restoreSelection(t.selection.ranges,t.selection.isBackward,o),this._undo(t.batch,e)})),this.refresh()}}class Zf extends pe{static get pluginName(){return"UndoEditing"}constructor(t){super(t),this._batchRegistry=new WeakSet}init(){const t=this.editor;this._undoCommand=new Gf(t),this._redoCommand=new Kf(t),t.commands.add("undo",this._undoCommand),t.commands.add("redo",this._redoCommand),this.listenTo(t.model,"applyOperation",((t,e)=>{const n=e[0];if(!n.isDocumentOperation)return;const o=n.batch,i=this._redoCommand._createdBatches.has(o),r=this._undoCommand._createdBatches.has(o);this._batchRegistry.has(o)||(this._batchRegistry.add(o),o.isUndoable&&(i?this._undoCommand.addBatch(o):r||(this._undoCommand.addBatch(o),this._redoCommand.clearStack())))}),{priority:"highest"}),this.listenTo(this._undoCommand,"revert",((t,e,n)=>{this._redoCommand.addBatch(n)})),t.keystrokes.set("CTRL+Z","undo"),t.keystrokes.set("CTRL+Y","redo"),t.keystrokes.set("CTRL+SHIFT+Z","redo")}}const Jf='',Yf='';class Qf extends pe{static get pluginName(){return"UndoUI"}init(){const t=this.editor,e=t.locale,n=t.t,o="ltr"==e.uiLanguageDirection?Jf:Yf,i="ltr"==e.uiLanguageDirection?Yf:Jf;this._addButton("undo",n("Undo"),"CTRL+Z",o),this._addButton("redo",n("Redo"),"CTRL+Y",i)}_addButton(t,e,n,o){const i=this.editor;i.ui.componentFactory.add(t,(r=>{const s=i.commands.get(t),a=new pu(r);return a.set({label:e,icon:o,keystroke:n,tooltip:!0}),a.bind("isEnabled").to(s,"isEnabled"),this.listenTo(a,"execute",(()=>{i.execute(t),i.editing.view.focus()})),a}))}}class Xf extends pe{static get requires(){return[Zf,Qf]}static get pluginName(){return"Undo"}}const tb="ckCsrfToken",eb="abcdefghijklmnopqrstuvwxyz0123456789";function nb(){let t=function(t){t=t.toLowerCase();const e=document.cookie.split(";");for(const n of e){const e=n.split("=");if(decodeURIComponent(e[0].trim().toLowerCase())===t)return decodeURIComponent(e[1])}return null}(tb);var e,n;return t&&40==t.length||(t=function(t){let e="";const n=new Uint8Array(t);window.crypto.getRandomValues(n);for(let t=0;t.5?o.toUpperCase():o}return e}(40),e=tb,n=t,document.cookie=encodeURIComponent(e)+"="+encodeURIComponent(n)+";path=/"),t}class ob{constructor(t,e,n){this.loader=t,this.url=e,this.t=n}upload(){return this.loader.file.then((t=>new Promise(((e,n)=>{this._initRequest(),this._initListeners(e,n,t),this._sendRequest(t)}))))}abort(){this.xhr&&this.xhr.abort()}_initRequest(){const t=this.xhr=new XMLHttpRequest;t.open("POST",this.url,!0),t.responseType="json"}_initListeners(t,e,n){const o=this.xhr,i=this.loader,r=(0,this.t)("Cannot upload file:")+` ${n.name}.`;o.addEventListener("error",(()=>e(r))),o.addEventListener("abort",(()=>e())),o.addEventListener("load",(()=>{const n=o.response;if(!n||!n.uploaded)return e(n&&n.error&&n.error.message?n.error.message:r);t({default:n.url})})),o.upload&&o.upload.addEventListener("progress",(t=>{t.lengthComputable&&(i.uploadTotal=t.total,i.uploaded=t.loaded)}))}_sendRequest(t){const e=new FormData;e.append("upload",t),e.append("ckCsrfToken",nb()),this.xhr.send(e)}}function ib(t,e,n,o){let i,r=null;"function"==typeof o?i=o:(r=t.commands.get(o),i=()=>{t.execute(o)}),t.model.document.on("change:data",((s,a)=>{if(r&&!r.isEnabled||!e.isEnabled)return;const c=Ta(t.model.document.selection.getRanges());if(!c.isCollapsed)return;if(a.isUndo||!a.isLocal)return;const l=Array.from(t.model.document.differ.getChanges()),d=l[0];if(1!=l.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 o&&!["numberedList","bulletedList","todoList"].includes(o))return;if(r&&!0===r.value)return;const h=u.getChild(0),p=t.model.createRangeOn(h);if(!p.containsRange(c)&&!c.end.isEqual(p.end))return;const m=n.exec(h.data.substr(0,c.end.offset));m&&t.model.enqueueChange((e=>{const n=e.createPositionAt(u,0),o=e.createPositionAt(u,m[0].length),r=new gc(n,o);if(!1!==i({match:m})){e.remove(r);const n=t.model.document.selection.getFirstRange(),o=e.createRangeIn(u);!u.isEmpty||o.isEqual(n)||o.containsRange(n,!0)||e.remove(u)}r.detach(),t.model.enqueueChange((()=>{t.plugins.get("Delete").requestUndoOnBackspace()}))}))}))}function rb(t,e,n,o){let i,r;n instanceof RegExp?i=n:r=n,r=r||(t=>{let e;const n=[],o=[];for(;null!==(e=i.exec(t))&&!(e&&e.length<4);){let{index:t,1:i,2:r,3:s}=e;const a=i+r+s;t+=e[0].length-a.length;const c=[t,t+i.length],l=[t+i.length+r.length,t+i.length+r.length+s.length];n.push(c),n.push(l),o.push([t+i.length,t+i.length+r.length])}return{remove:n,format:o}}),t.model.document.on("change:data",((n,i)=>{if(i.isUndo||!i.isLocal||!e.isEnabled)return;const s=t.model,a=s.document.selection;if(!a.isCollapsed)return;const c=Array.from(s.document.differ.getChanges()),l=c[0];if(1!=c.length||"insert"!==l.type||"$text"!=l.name||1!=l.length)return;const d=a.focus,u=d.parent,{text:h,range:p}=function(t,e){let n=t.start;return{text:Array.from(t.getItems()).reduce(((t,o)=>!o.is("$text")&&!o.is("$textProxy")||o.getAttribute("code")?(n=e.createPositionAfter(o),""):t+o.data),""),range:e.createRange(n,t.end)}}(s.createRange(s.createPositionAt(u,0),d),s),m=r(h),g=sb(p.start,m.format,s),f=sb(p.start,m.remove,s);g.length&&f.length&&s.enqueueChange((e=>{if(!1!==o(e,g)){for(const t of f.reverse())e.remove(t);s.enqueueChange((()=>{t.plugins.get("Delete").requestUndoOnBackspace()}))}}))}))}function sb(t,e,n){return e.filter((t=>void 0!==t[0]&&void 0!==t[1])).map((e=>n.createRange(t.getShiftedBy(e[0]),t.getShiftedBy(e[1]))))}function ab(t,e){return(n,o)=>{if(!t.commands.get(e).isEnabled)return!1;const i=t.model.schema.getValidRanges(o,e);for(const t of i)n.setAttribute(e,!0,t);n.removeSelectionAttribute(e)}}class cb extends ge{constructor(t,e){super(t),this.attributeKey=e}refresh(){const t=this.editor.model,e=t.document;this.value=this._getValueFromFirstAllowedNode(),this.isEnabled=t.schema.checkAttributeInSelection(e.selection,this.attributeKey)}execute(t={}){const e=this.editor.model,n=e.document.selection,o=void 0===t.forceValue?!this.value:t.forceValue;e.change((t=>{if(n.isCollapsed)o?t.setSelectionAttribute(this.attributeKey,!0):t.removeSelectionAttribute(this.attributeKey);else{const i=e.schema.getValidRanges(n.getRanges(),this.attributeKey);for(const e of i)o?t.setAttribute(this.attributeKey,o,e):t.removeAttribute(this.attributeKey,e)}}))}_getValueFromFirstAllowedNode(){const t=this.editor.model,e=t.schema,n=t.document.selection;if(n.isCollapsed)return n.hasAttribute(this.attributeKey);for(const t of n.getRanges())for(const n of t.getItems())if(e.checkAttribute(n,this.attributeKey))return n.hasAttribute(this.attributeKey);return!1}}const lb="bold";class db extends pe{static get pluginName(){return"BoldEditing"}init(){const t=this.editor;t.model.schema.extend("$text",{allowAttributes:lb}),t.model.schema.setAttributeProperties(lb,{isFormatting:!0,copyOnEnter:!0}),t.conversion.attributeToElement({model:lb,view:"strong",upcastAlso:["b",t=>{const e=t.getStyle("font-weight");return e?"bold"==e||Number(e)>=600?{name:!0,styles:["font-weight"]}:void 0:null}]}),t.commands.add(lb,new cb(t,lb)),t.keystrokes.set("CTRL+B",lb)}}const ub="bold";class hb extends pe{static get pluginName(){return"BoldUI"}init(){const t=this.editor,e=t.t;t.ui.componentFactory.add(ub,(n=>{const o=t.commands.get(ub),i=new pu(n);return i.set({label:e("Bold"),icon:'',keystroke:"CTRL+B",tooltip:!0,isToggleable:!0}),i.bind("isOn","isEnabled").to(o,"value","isEnabled"),this.listenTo(i,"execute",(()=>{t.execute(ub),t.editing.view.focus()})),i}))}}const pb="code";class mb extends pe{static get pluginName(){return"CodeEditing"}static get requires(){return[Ff]}init(){const t=this.editor;t.model.schema.extend("$text",{allowAttributes:pb}),t.model.schema.setAttributeProperties(pb,{isFormatting:!0,copyOnEnter:!1}),t.conversion.attributeToElement({model:pb,view:"code",upcastAlso:{styles:{"word-wrap":"break-word"}}}),t.commands.add(pb,new cb(t,pb)),t.plugins.get(Ff).registerAttribute(pb),Wf(t,pb,"code","ck-code_selected")}}var gb=n(8180),fb={attributes:{"data-cke":!0}};fb.setAttributes=is(),fb.insert=ns().bind(null,"head"),fb.domAPI=ts(),fb.insertStyleElement=ss();Qr()(gb.Z,fb);gb.Z&&gb.Z.locals&&gb.Z.locals;const bb="code";class kb extends pe{static get pluginName(){return"CodeUI"}init(){const t=this.editor,e=t.t;t.ui.componentFactory.add(bb,(n=>{const o=t.commands.get(bb),i=new pu(n);return i.set({label:e("Code"),icon:'',tooltip:!0,isToggleable:!0}),i.bind("isOn","isEnabled").to(o,"value","isEnabled"),this.listenTo(i,"execute",(()=>{t.execute(bb),t.editing.view.focus()})),i}))}}const wb="strikethrough";class _b extends pe{static get pluginName(){return"StrikethroughEditing"}init(){const t=this.editor;t.model.schema.extend("$text",{allowAttributes:wb}),t.model.schema.setAttributeProperties(wb,{isFormatting:!0,copyOnEnter:!0}),t.conversion.attributeToElement({model:wb,view:"s",upcastAlso:["del","strike",{styles:{"text-decoration":"line-through"}}]}),t.commands.add(wb,new cb(t,wb)),t.keystrokes.set("CTRL+SHIFT+X","strikethrough")}}const Cb="strikethrough";class Ab extends pe{static get pluginName(){return"StrikethroughUI"}init(){const t=this.editor,e=t.t;t.ui.componentFactory.add(Cb,(n=>{const o=t.commands.get(Cb),i=new pu(n);return i.set({label:e("Strikethrough"),icon:'',keystroke:"CTRL+SHIFT+X",tooltip:!0,isToggleable:!0}),i.bind("isOn","isEnabled").to(o,"value","isEnabled"),this.listenTo(i,"execute",(()=>{t.execute(Cb),t.editing.view.focus()})),i}))}}const vb="italic";class yb extends pe{static get pluginName(){return"ItalicEditing"}init(){const t=this.editor;t.model.schema.extend("$text",{allowAttributes:vb}),t.model.schema.setAttributeProperties(vb,{isFormatting:!0,copyOnEnter:!0}),t.conversion.attributeToElement({model:vb,view:"i",upcastAlso:["em",{styles:{"font-style":"italic"}}]}),t.commands.add(vb,new cb(t,vb)),t.keystrokes.set("CTRL+I",vb)}}const xb="italic";class Eb extends pe{static get pluginName(){return"ItalicUI"}init(){const t=this.editor,e=t.t;t.ui.componentFactory.add(xb,(n=>{const o=t.commands.get(xb),i=new pu(n);return i.set({label:e("Italic"),icon:'',keystroke:"CTRL+I",tooltip:!0,isToggleable:!0}),i.bind("isOn","isEnabled").to(o,"value","isEnabled"),this.listenTo(i,"execute",(()=>{t.execute(xb),t.editing.view.focus()})),i}))}}class Db extends ge{refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(t={}){const e=this.editor.model,n=e.schema,o=e.document.selection,i=Array.from(o.getSelectedBlocks()),r=void 0===t.forceValue?!this.value:t.forceValue;e.change((t=>{if(r){const e=i.filter((t=>Sb(t)||Tb(n,t)));this._applyQuote(t,e)}else this._removeQuote(t,i.filter(Sb))}))}_getValue(){const t=Ta(this.editor.model.document.selection.getSelectedBlocks());return!(!t||!Sb(t))}_checkEnabled(){if(this.value)return!0;const t=this.editor.model.document.selection,e=this.editor.model.schema,n=Ta(t.getSelectedBlocks());return!!n&&Tb(e,n)}_removeQuote(t,e){Bb(t,e).reverse().forEach((e=>{if(e.start.isAtStart&&e.end.isAtEnd)return void t.unwrap(e.start.parent);if(e.start.isAtStart){const n=t.createPositionBefore(e.start.parent);return void t.move(e,n)}e.end.isAtEnd||t.split(e.end);const n=t.createPositionAfter(e.end.parent);t.move(e,n)}))}_applyQuote(t,e){const n=[];Bb(t,e).reverse().forEach((e=>{let o=Sb(e.start);o||(o=t.createElement("blockQuote"),t.wrap(e,o)),n.push(o)})),n.reverse().reduce(((e,n)=>e.nextSibling==n?(t.merge(t.createPositionAfter(e)),e):n))}}function Sb(t){return"blockQuote"==t.parent.name?t.parent:null}function Bb(t,e){let n,o=0;const i=[];for(;o{const o=t.model.document.differ.getChanges();for(const t of o)if("insert"==t.type){const o=t.position.nodeAfter;if(!o)continue;if(o.is("element","blockQuote")&&o.isEmpty)return n.remove(o),!0;if(o.is("element","blockQuote")&&!e.checkChild(t.position,o))return n.unwrap(o),!0;if(o.is("element")){const t=n.createRangeIn(o);for(const o of t.getItems())if(o.is("element","blockQuote")&&!e.checkChild(n.createPositionBefore(o),o))return n.unwrap(o),!0}}else if("remove"==t.type){const e=t.position.parent;if(e.is("element","blockQuote")&&e.isEmpty)return n.remove(e),!0}return!1}));const n=this.editor.editing.view.document,o=t.model.document.selection,i=t.commands.get("blockQuote");this.listenTo(n,"enter",((e,n)=>{if(!o.isCollapsed||!i.value)return;o.getLastPosition().parent.isEmpty&&(t.execute("blockQuote"),t.editing.view.scrollToTheSelection(),n.preventDefault(),e.stop())}),{context:"blockquote"}),this.listenTo(n,"delete",((e,n)=>{if("backward"!=n.direction||!o.isCollapsed||!i.value)return;const r=o.getLastPosition().parent;r.isEmpty&&!r.previousSibling&&(t.execute("blockQuote"),t.editing.view.scrollToTheSelection(),n.preventDefault(),e.stop())}),{context:"blockquote"})}}var Ib=n(636),Rb={attributes:{"data-cke":!0}};Rb.setAttributes=is(),Rb.insert=ns().bind(null,"head"),Rb.domAPI=ts(),Rb.insertStyleElement=ss();Qr()(Ib.Z,Rb);Ib.Z&&Ib.Z.locals&&Ib.Z.locals;class zb extends pe{static get pluginName(){return"BlockQuoteUI"}init(){const t=this.editor,e=t.t;t.ui.componentFactory.add("blockQuote",(n=>{const o=t.commands.get("blockQuote"),i=new pu(n);return i.set({label:e("Block quote"),icon:Td.quote,tooltip:!0,isToggleable:!0}),i.bind("isOn","isEnabled").to(o,"value","isEnabled"),this.listenTo(i,"execute",(()=>{t.execute("blockQuote"),t.editing.view.focus()})),i}))}}class Fb extends ge{refresh(){const t=this.editor.model,e=Ta(t.document.selection.getSelectedBlocks());this.value=!!e&&e.is("element","paragraph"),this.isEnabled=!!e&&Nb(e,t.schema)}execute(t={}){const e=this.editor.model,n=e.document;e.change((o=>{const i=(t.selection||n.selection).getSelectedBlocks();for(const t of i)!t.is("element","paragraph")&&Nb(t,e.schema)&&o.rename(t,"paragraph")}))}}function Nb(t,e){return e.checkChild(t.parent,"paragraph")&&!e.isObject(t)}class Ob extends ge{execute(t){const e=this.editor.model;let n=t.position;e.change((t=>{const o=t.createElement("paragraph");if(!e.schema.checkChild(n.parent,o)){const i=e.schema.findAllowedParent(n,o);if(!i)return;n=t.split(n,i).position}e.insertContent(o,n),t.setSelection(o,"in")}))}}class Mb extends pe{static get pluginName(){return"Paragraph"}init(){const t=this.editor,e=t.model;t.commands.add("paragraph",new Fb(t)),t.commands.add("insertParagraph",new Ob(t)),e.schema.register("paragraph",{inheritAllFrom:"$block"}),t.conversion.elementToElement({model:"paragraph",view:"p"}),t.conversion.for("upcast").elementToElement({model:(t,{writer:e})=>Mb.paragraphLikeElements.has(t.name)?t.isEmpty?null:e.createElement("paragraph"):null,view:/.+/,converterPriority:"low"})}}Mb.paragraphLikeElements=new Set(["blockquote","dd","div","dt","h1","h2","h3","h4","h5","h6","li","p","td","th"]);class Vb extends ge{constructor(t,e){super(t),this.modelElements=e}refresh(){const t=Ta(this.editor.model.document.selection.getSelectedBlocks());this.value=!!t&&this.modelElements.includes(t.name)&&t.name,this.isEnabled=!!t&&this.modelElements.some((e=>Lb(t,e,this.editor.model.schema)))}execute(t){const e=this.editor.model,n=e.document,o=t.value;e.change((t=>{const i=Array.from(n.selection.getSelectedBlocks()).filter((t=>Lb(t,o,e.schema)));for(const e of i)e.is("element",o)||t.rename(e,o)}))}}function Lb(t,e,n){return n.checkChild(t.parent,e)&&!n.isObject(t)}const Hb="paragraph";class qb extends pe{static get pluginName(){return"HeadingEditing"}constructor(t){super(t),t.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[Mb]}init(){const t=this.editor,e=t.config.get("heading.options"),n=[];for(const o of e)o.model!==Hb&&(t.model.schema.register(o.model,{inheritAllFrom:"$block"}),t.conversion.elementToElement(o),n.push(o.model));this._addDefaultH1Conversion(t),t.commands.add("heading",new Vb(t,n))}afterInit(){const t=this.editor,e=t.commands.get("enter"),n=t.config.get("heading.options");e&&this.listenTo(e,"afterExecute",((e,o)=>{const i=t.model.document.selection.getFirstPosition().parent;n.some((t=>i.is("element",t.model)))&&!i.is("element",Hb)&&0===i.childCount&&o.writer.rename(i,Hb)}))}_addDefaultH1Conversion(t){t.conversion.for("upcast").elementToElement({model:"heading1",view:"h1",converterPriority:r.get("low")+1})}}var Wb=n(3230),jb={attributes:{"data-cke":!0}};jb.setAttributes=is(),jb.insert=ns().bind(null,"head"),jb.domAPI=ts(),jb.insertStyleElement=ss();Qr()(Wb.Z,jb);Wb.Z&&Wb.Z.locals&&Wb.Z.locals;class Ub extends pe{static get pluginName(){return"HeadingUI"}init(){const t=this.editor,e=t.t,n=function(t){const e=t.t,n={Paragraph:e("Paragraph"),"Heading 1":e("Heading 1"),"Heading 2":e("Heading 2"),"Heading 3":e("Heading 3"),"Heading 4":e("Heading 4"),"Heading 5":e("Heading 5"),"Heading 6":e("Heading 6")};return t.config.get("heading.options").map((t=>{const e=n[t.title];return e&&e!=t.title&&(t.title=e),t}))}(t),o=e("Choose heading"),i=e("Heading");t.ui.componentFactory.add("heading",(e=>{const r={},s=new So,a=t.commands.get("heading"),c=t.commands.get("paragraph"),l=[a];for(const t of n){const e={type:"button",model:new Eh({label:t.title,class:t.class,withText:!0})};"paragraph"===t.model?(e.model.bind("isOn").to(c,"value"),e.model.set("commandName","paragraph"),l.push(c)):(e.model.bind("isOn").to(a,"value",(e=>e===t.model)),e.model.set({commandName:"heading",commandValue:t.model})),s.add(e),r[t.model]=t.title}const d=nh(e);return ih(d,s),d.buttonView.set({isOn:!1,withText:!0,tooltip:i}),d.extendTemplate({attributes:{class:["ck-heading-dropdown"]}}),d.bind("isEnabled").toMany(l,"isEnabled",((...t)=>t.some((t=>t)))),d.buttonView.bind("label").to(a,"value",c,"value",((t,e)=>{const n=t||e&&"paragraph";return r[n]?r[n]:o})),this.listenTo(d,"execute",(e=>{t.execute(e.source.commandName,e.source.commandValue?{value:e.source.commandValue}:void 0),t.editing.view.focus()})),d}))}}function $b(t,e,n){return t=>{t.on(`attribute:${n}:${e}`,o)};function o(e,n,o){if(!o.consumable.consume(n.item,e.name))return;const i=o.writer,r=o.mapper.toViewElement(n.item),s=t.findViewImgElement(r);i.setAttribute(n.attributeKey,n.attributeNewValue||"",s)}}class Gb extends Bs{observe(t){this.listenTo(t,"load",((t,e)=>{const n=e.target;this.checkShouldIgnoreEventFromTarget(n)||"IMG"==n.tagName&&this._fireEvents(e)}),{useCapture:!0})}_fireEvents(t){this.isEnabled&&(this.document.fire("layoutChanged"),this.document.fire("imageLoaded",t))}}class Kb extends ge{constructor(t){super(t);const e=t.config.get("image.insert.type");t.plugins.has("ImageBlockEditing")||"block"===e&&a("image-block-plugin-required"),t.plugins.has("ImageInlineEditing")||"inline"===e&&a("image-inline-plugin-required")}refresh(){this.isEnabled=this.editor.plugins.get("ImageUtils").isImageAllowed()}execute(t){const e=To(t.source),n=this.editor.model.document.selection,o=this.editor.plugins.get("ImageUtils"),i=Object.fromEntries(n.getAttributes());e.forEach(((t,e)=>{const r=n.getSelectedElement();if("string"==typeof t&&(t={src:t}),e&&r&&o.isImage(r)){const e=this.editor.model.createPositionAfter(r);o.insertImage({...t,...i},e)}else o.insertImage({...t,...i})}))}}class Zb extends pe{static get requires(){return[af]}static get pluginName(){return"ImageEditing"}init(){const t=this.editor,e=t.conversion;t.editing.view.addObserver(Gb),e.for("upcast").attributeToAttribute({view:{name:"img",key:"alt"},model:"alt"}).attributeToAttribute({view:{name:"img",key:"srcset"},model:{key:"srcset",value:t=>{const e={data:t.getAttribute("srcset")};return t.hasAttribute("width")&&(e.width=t.getAttribute("width")),e}}});const n=new Kb(t);t.commands.add("insertImage",n),t.commands.add("imageInsert",n)}}class Jb extends ge{constructor(t,e){super(t),this._modelElementName=e}refresh(){const t=this.editor.plugins.get("ImageUtils"),e=t.getClosestSelectedImageElement(this.editor.model.document.selection);"imageBlock"===this._modelElementName?this.isEnabled=t.isInlineImage(e):this.isEnabled=t.isBlockImage(e)}execute(){const t=this.editor,e=this.editor.model,n=t.plugins.get("ImageUtils"),o=n.getClosestSelectedImageElement(e.document.selection),i=Object.fromEntries(o.getAttributes());return i.src||i.uploadId?e.change((t=>{const r=Array.from(e.markers).filter((t=>t.getRange().containsItem(o))),s=n.insertImage(i,e.createSelection(o,"on"),this._modelElementName);if(!s)return null;const a=t.createRangeOn(s);for(const e of r){const n=e.getRange(),o="$graveyard"!=n.root.rootName?n.getJoined(a,!0):a;t.updateMarker(e,{range:o})}return{oldElement:o,newElement:s}})):null}}class Yb extends pe{static get requires(){return[Zb,af,Og]}static get pluginName(){return"ImageBlockEditing"}init(){const t=this.editor;t.model.schema.register("imageBlock",{isObject:!0,isBlock:!0,allowWhere:"$block",allowAttributes:["alt","src","srcset"]}),this._setupConversion(),t.plugins.has("ImageInlineEditing")&&(t.commands.add("imageTypeBlock",new Jb(this.editor,"imageBlock")),this._setupClipboardIntegration())}_setupConversion(){const t=this.editor,e=t.t,n=t.conversion,o=t.plugins.get("ImageUtils");n.for("dataDowncast").elementToElement({model:"imageBlock",view:(t,{writer:e})=>of(e,"imageBlock")}),n.for("editingDowncast").elementToElement({model:"imageBlock",view:(t,{writer:n})=>o.toImageWidget(of(n,"imageBlock"),n,e("image widget"))}),n.for("downcast").add($b(o,"imageBlock","src")).add($b(o,"imageBlock","alt")).add(function(t,e){return t=>{t.on(`attribute:srcset:${e}`,n)};function n(e,n,o){if(!o.consumable.consume(n.item,e.name))return;const i=o.writer,r=o.mapper.toViewElement(n.item),s=t.findViewImgElement(r);if(null===n.attributeNewValue){const t=n.attributeOldValue;t.data&&(i.removeAttribute("srcset",s),i.removeAttribute("sizes",s),t.width&&i.removeAttribute("width",s))}else{const t=n.attributeNewValue;t.data&&(i.setAttribute("srcset",t.data,s),i.setAttribute("sizes","100vw",s),t.width&&i.setAttribute("width",t.width,s))}}}(o,"imageBlock")),n.for("upcast").elementToElement({view:rf(t,"imageBlock"),model:(t,{writer:e})=>e.createElement("imageBlock",t.hasAttribute("src")?{src:t.getAttribute("src")}:null)}).add(function(t){return t=>{t.on("element:figure",e)};function e(e,n,o){if(!o.consumable.test(n.viewItem,{name:!0,classes:"image"}))return;const i=t.findViewImgElement(n.viewItem);if(!i||!o.consumable.test(i,{name:!0}))return;o.consumable.consume(n.viewItem,{name:!0,classes:"image"});const r=Ta(o.convertItem(i,n.modelCursor).modelRange.getItems());r?(o.convertChildren(n.viewItem,r),o.updateConversionResult(r,n)):o.consumable.revert(n.viewItem,{name:!0,classes:"image"})}}(o))}_setupClipboardIntegration(){const t=this.editor,e=t.model,n=t.editing.view,o=t.plugins.get("ImageUtils");this.listenTo(t.plugins.get("ClipboardPipeline"),"inputTransformation",((i,r)=>{const s=Array.from(r.content.getChildren());let a;if(!s.every(o.isInlineImageView))return;a=r.targetRanges?t.editing.mapper.toModelRange(r.targetRanges[0]):e.document.selection.getFirstRange();const c=e.createSelection(a);if("imageBlock"===sf(e.schema,c)){const t=new pp(n.document),e=s.map((e=>t.createElement("figure",{class:"image"},e)));r.content=t.createDocumentFragment(e)}}))}}function Qb(t){for(const e of t.getChildren())if(e&&e.is("element","caption"))return e;return null}function Xb(t,e){const n=e.getFirstPosition().findAncestor("caption");return n&&t.isBlockImage(n.parent)?n:null}class tk extends ge{refresh(){const t=this.editor,e=t.plugins.get("ImageUtils");if(!t.plugins.has(Yb))return this.isEnabled=!1,void(this.value=!1);const n=t.model.document.selection,o=n.getSelectedElement();if(!o){const t=Xb(e,n);return this.isEnabled=!!t,void(this.value=!!t)}this.isEnabled=this.editor.plugins.get("ImageUtils").isImage(o),this.isEnabled?this.value=!!Qb(o):this.value=!1}execute(t={}){const{focusCaptionOnShow:e}=t;this.editor.model.change((t=>{this.value?this._hideImageCaption(t):this._showImageCaption(t,e)}))}_showImageCaption(t,e){const n=this.editor.model.document.selection,o=this.editor.plugins.get("ImageCaptionEditing");let i=n.getSelectedElement();const r=o._getSavedCaption(i);this.editor.plugins.get("ImageUtils").isInlineImage(i)&&(this.editor.execute("imageTypeBlock"),i=n.getSelectedElement());const s=r||t.createElement("caption");t.append(s,i),e&&t.setSelection(s,"in")}_hideImageCaption(t){const e=this.editor,n=e.model.document.selection,o=e.plugins.get("ImageCaptionEditing"),i=e.plugins.get("ImageUtils");let r,s=n.getSelectedElement();s?r=Qb(s):(r=Xb(i,n),s=r.parent),o._saveCaption(s,r),t.setSelection(s,"on"),t.remove(r)}}class ek extends pe{static get requires(){return[af]}static get pluginName(){return"ImageCaptionEditing"}constructor(t){super(t),this._savedCaptionsMap=new WeakMap}init(){const t=this.editor,e=t.model.schema;e.isRegistered("caption")?e.extend("caption",{allowIn:"imageBlock"}):e.register("caption",{allowIn:"imageBlock",allowContentOf:"$block",isLimit:!0}),t.commands.add("toggleImageCaption",new tk(this.editor)),this._setupConversion(),this._setupImageTypeCommandsIntegration()}_setupConversion(){const t=this.editor,e=t.editing.view,n=t.plugins.get("ImageUtils"),o=t.t;t.conversion.for("upcast").elementToElement({view:t=>function(t,e){return"figcaption"==e.name&&t.isBlockImageView(e.parent)?{name:!0}:null}(n,t),model:"caption"}),t.conversion.for("dataDowncast").elementToElement({model:"caption",view:(t,{writer:e})=>n.isBlockImage(t.parent)?e.createContainerElement("figcaption"):null}),t.conversion.for("editingDowncast").elementToElement({model:"caption",view:(t,{writer:i})=>{if(!n.isBlockImage(t.parent))return null;const r=i.createEditableElement("figcaption");return i.setCustomProperty("imageCaption",!0,r),Zh({view:e,element:r,text:o("Enter image caption"),keepOnFocus:!0}),km(r,i)}}),t.editing.mapper.on("modelToViewPosition",nk(e)),t.data.mapper.on("modelToViewPosition",nk(e))}_setupImageTypeCommandsIntegration(){const t=this.editor,e=t.plugins.get("ImageUtils"),n=t.commands.get("imageTypeInline"),o=t.commands.get("imageTypeBlock"),i=t=>{if(!t.return)return;const{oldElement:n,newElement:o}=t.return;if(!n)return;if(e.isBlockImage(n)){const t=Qb(n);if(t)return void this._saveCaption(o,t)}const i=this._getSavedCaption(n);i&&this._saveCaption(o,i)};n&&this.listenTo(n,"execute",i,{priority:"low"}),o&&this.listenTo(o,"execute",i,{priority:"low"})}_getSavedCaption(t){const e=this._savedCaptionsMap.get(t);return e?Za.fromJSON(e):null}_saveCaption(t,e){this._savedCaptionsMap.set(t,e.toJSON())}}function nk(t){return(e,n)=>{const o=n.modelPosition,i=o.parent;if(!i.is("element","imageBlock"))return;const r=n.mapper.toViewElement(i);n.viewPosition=t.createPositionAt(r,o.offset+1)}}class ok extends pe{static get requires(){return[af]}static get pluginName(){return"ImageCaptionUI"}init(){const t=this.editor,e=t.editing.view,n=t.plugins.get("ImageUtils"),o=t.t;t.ui.componentFactory.add("toggleImageCaption",(i=>{const r=t.commands.get("toggleImageCaption"),s=new pu(i);return s.set({icon:Td.caption,tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(r,"value","isEnabled"),s.bind("label").to(r,"value",(t=>o(t?"Toggle caption off":"Toggle caption on"))),this.listenTo(s,"execute",(()=>{t.execute("toggleImageCaption",{focusCaptionOnShow:!0});const o=Xb(n,t.model.document.selection);if(o){const n=t.editing.mapper.toViewElement(o);e.scrollToTheSelection(),e.change((t=>{t.addClass("image__caption_highlighted",n)}))}})),s}))}}var ik=n(8662),rk={attributes:{"data-cke":!0}};rk.setAttributes=is(),rk.insert=ns().bind(null,"head"),rk.domAPI=ts(),rk.insertStyleElement=ss();Qr()(ik.Z,rk);ik.Z&&ik.Z.locals&&ik.Z.locals;class sk extends ge{constructor(t,e){super(t),this._defaultStyles={imageBlock:!1,imageInline:!1},this._styles=new Map(e.map((t=>{if(t.isDefault)for(const e of t.modelElements)this._defaultStyles[e]=t.name;return[t.name,t]})))}refresh(){const t=this.editor.plugins.get("ImageUtils").getClosestSelectedImageElement(this.editor.model.document.selection);this.isEnabled=!!t,this.isEnabled?t.hasAttribute("imageStyle")?this.value=t.getAttribute("imageStyle"):this.value=this._defaultStyles[t.name]:this.value=!1}execute(t={}){const e=this.editor,n=e.model,o=e.plugins.get("ImageUtils");n.change((e=>{const i=t.value;let r=o.getClosestSelectedImageElement(n.document.selection);i&&this.shouldConvertImageType(i,r)&&(this.editor.execute(o.isBlockImage(r)?"imageTypeInline":"imageTypeBlock"),r=o.getClosestSelectedImageElement(n.document.selection)),!i||this._styles.get(i).isDefault?e.removeAttribute("imageStyle",r):e.setAttribute("imageStyle",i,r)}))}shouldConvertImageType(t,e){return!this._styles.get(t).modelElements.includes(e.name)}}const{objectFullWidth:ak,objectInline:ck,objectLeft:lk,objectRight:dk,objectCenter:uk,objectBlockLeft:hk,objectBlockRight:pk}=Td,mk={inline:{name:"inline",title:"In line",icon:ck,modelElements:["imageInline"],isDefault:!0},alignLeft:{name:"alignLeft",title:"Left aligned image",icon:lk,modelElements:["imageBlock","imageInline"],className:"image-style-align-left"},alignBlockLeft:{name:"alignBlockLeft",title:"Left aligned image",icon:hk,modelElements:["imageBlock"],className:"image-style-block-align-left"},alignCenter:{name:"alignCenter",title:"Centered image",icon:uk,modelElements:["imageBlock"],className:"image-style-align-center"},alignRight:{name:"alignRight",title:"Right aligned image",icon:dk,modelElements:["imageBlock","imageInline"],className:"image-style-align-right"},alignBlockRight:{name:"alignBlockRight",title:"Right aligned image",icon:pk,modelElements:["imageBlock"],className:"image-style-block-align-right"},block:{name:"block",title:"Centered image",icon:uk,modelElements:["imageBlock"],isDefault:!0},side:{name:"side",title:"Side image",icon:dk,modelElements:["imageBlock"],className:"image-style-side"}},gk={full:ak,left:hk,right:pk,center:uk,inlineLeft:lk,inlineRight:dk,inline:ck},fk=[{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 bk(t){a("image-style-configuration-definition-invalid",t)}const kk={normalizeStyles:function(t){const e=(t.configuredStyles.options||[]).map((t=>function(t){t="string"==typeof t?mk[t]?{...mk[t]}:{name:t}:function(t,e){const n={...e};for(const o in t)Object.prototype.hasOwnProperty.call(e,o)||(n[o]=t[o]);return n}(mk[t.name],t);"string"==typeof t.icon&&(t.icon=gk[t.icon]||t.icon);return t}(t))).filter((e=>function(t,{isBlockPluginLoaded:e,isInlinePluginLoaded:n}){const{modelElements:o,name:i}=t;if(!(o&&o.length&&i))return bk({style:t}),!1;{const i=[e?"imageBlock":null,n?"imageInline":null];if(!o.some((t=>i.includes(t))))return a("image-style-missing-dependency",{style:t,missingPlugins:o.map((t=>"imageBlock"===t?"ImageBlockEditing":"ImageInlineEditing"))}),!1}return!0}(e,t)));return e},getDefaultStylesConfiguration:function(t,e){return t&&e?{options:["inline","alignLeft","alignRight","alignCenter","alignBlockLeft","alignBlockRight","block","side"]}:t?{options:["block","side"]}:e?{options:["inline","alignLeft","alignRight"]}:{}},getDefaultDropdownDefinitions:function(t){return t.has("ImageBlockEditing")&&t.has("ImageInlineEditing")?[...fk]:[]},warnInvalidStyle:bk,DEFAULT_OPTIONS:mk,DEFAULT_ICONS:gk,DEFAULT_DROPDOWN_DEFINITIONS:fk};function wk(t,e){for(const n of e)if(n.name===t)return n}class _k extends pe{static get pluginName(){return"ImageStyleEditing"}static get requires(){return[af]}init(){const{normalizeStyles:t,getDefaultStylesConfiguration:e}=kk,n=this.editor,o=n.plugins.has("ImageBlockEditing"),i=n.plugins.has("ImageInlineEditing");n.config.define("image.styles",e(o,i)),this.normalizedStyles=t({configuredStyles:n.config.get("image.styles"),isBlockPluginLoaded:o,isInlinePluginLoaded:i}),this._setupConversion(o,i),this._setupPostFixer(),n.commands.add("imageStyle",new sk(n,this.normalizedStyles))}_setupConversion(t,e){const n=this.editor,o=n.model.schema,i=(r=this.normalizedStyles,(t,e,n)=>{if(!n.consumable.consume(e.item,t.name))return;const o=wk(e.attributeNewValue,r),i=wk(e.attributeOldValue,r),s=n.mapper.toViewElement(e.item),a=n.writer;i&&a.removeClass(i.className,s),o&&a.addClass(o.className,s)});var r;const s=function(t){const e={imageInline:t.filter((t=>!t.isDefault&&t.modelElements.includes("imageInline"))),imageBlock:t.filter((t=>!t.isDefault&&t.modelElements.includes("imageBlock")))};return(t,n,o)=>{if(!n.modelRange)return;const i=n.viewItem,r=Ta(n.modelRange.getItems());if(r&&o.schema.checkAttribute(r,"imageStyle"))for(const t of e[r.name])o.consumable.consume(i,{classes:t.className})&&o.writer.setAttribute("imageStyle",t.name,r)}}(this.normalizedStyles);n.editing.downcastDispatcher.on("attribute:imageStyle",i),n.data.downcastDispatcher.on("attribute:imageStyle",i),t&&(o.extend("imageBlock",{allowAttributes:"imageStyle"}),n.data.upcastDispatcher.on("element:figure",s,{priority:"low"})),e&&(o.extend("imageInline",{allowAttributes:"imageStyle"}),n.data.upcastDispatcher.on("element:img",s,{priority:"low"}))}_setupPostFixer(){const t=this.editor,e=t.model.document,n=t.plugins.get(af),o=new Map(this.normalizedStyles.map((t=>[t.name,t])));e.registerPostFixer((t=>{let i=!1;for(const r of e.differ.getChanges())if("insert"==r.type||"attribute"==r.type&&"imageStyle"==r.attributeKey){let e="insert"==r.type?r.position.nodeAfter:r.range.start.nodeAfter;if(e&&e.is("element","paragraph")&&e.childCount>0&&(e=e.getChild(0)),!n.isImage(e))continue;const s=e.getAttribute("imageStyle");if(!s)continue;const a=o.get(s);a&&a.modelElements.includes(e.name)||(t.removeAttribute("imageStyle",e),i=!0)}return i}))}}var Ck=n(4622),Ak={attributes:{"data-cke":!0}};Ak.setAttributes=is(),Ak.insert=ns().bind(null,"head"),Ak.domAPI=ts(),Ak.insertStyleElement=ss();Qr()(Ck.Z,Ak);Ck.Z&&Ck.Z.locals&&Ck.Z.locals;class vk extends pe{static get requires(){return[_k]}static get pluginName(){return"ImageStyleUI"}get localizedDefaultStylesTitles(){const t=this.editor.t;return{"Wrap text":t("Wrap text"),"Break text":t("Break text"),"In line":t("In line"),"Full size image":t("Full size image"),"Side image":t("Side image"),"Left aligned image":t("Left aligned image"),"Centered image":t("Centered image"),"Right aligned image":t("Right aligned image")}}init(){const t=this.editor.plugins,e=this.editor.config.get("image.toolbar")||[],n=yk(t.get("ImageStyleEditing").normalizedStyles,this.localizedDefaultStylesTitles);for(const t of n)this._createButton(t);const o=yk([...e.filter(y),...kk.getDefaultDropdownDefinitions(t)],this.localizedDefaultStylesTitles);for(const t of o)this._createDropdown(t,n)}_createDropdown(t,e){const n=this.editor.ui.componentFactory;n.add(t.name,(o=>{let i;const{defaultItem:r,items:s,title:a}=t,c=s.filter((t=>e.find((({name:e})=>xk(e)===t)))).map((t=>{const e=n.create(t);return t===r&&(i=e),e}));s.length!==c.length&&kk.warnInvalidStyle({dropdown:t});const l=nh(o,Pu),d=l.buttonView;return oh(l,c),d.set({label:Ek(a,i.label),class:null,tooltip:!0}),d.bind("icon").toMany(c,"isOn",((...t)=>{const e=t.findIndex(rt);return e<0?i.icon:c[e].icon})),d.bind("label").toMany(c,"isOn",((...t)=>{const e=t.findIndex(rt);return Ek(a,e<0?i.label:c[e].label)})),d.bind("isOn").toMany(c,"isOn",((...t)=>t.some(rt))),d.bind("class").toMany(c,"isOn",((...t)=>t.some(rt)?"ck-splitbutton_flatten":null)),d.on("execute",(()=>{c.some((({isOn:t})=>t))?l.isOpen=!l.isOpen:i.fire("execute")})),l.bind("isEnabled").toMany(c,"isEnabled",((...t)=>t.some(rt))),l}))}_createButton(t){const e=t.name;this.editor.ui.componentFactory.add(xk(e),(n=>{const o=this.editor.commands.get("imageStyle"),i=new pu(n);return i.set({label:t.title,icon:t.icon,tooltip:!0,isToggleable:!0}),i.bind("isEnabled").to(o,"isEnabled"),i.bind("isOn").to(o,"value",(t=>t===e)),i.on("execute",this._executeCommand.bind(this,e)),i}))}_executeCommand(t){this.editor.execute("imageStyle",{value:t}),this.editor.editing.view.focus()}}function yk(t,e){for(const n of t)e[n.title]&&(n.title=e[n.title]);return t}function xk(t){return`imageStyle:${t}`}function Ek(t,e){return(t?t+": ":"")+e}class Dk{constructor(){this._definitions=new Set}get length(){return this._definitions.size}add(t){Array.isArray(t)?t.forEach((t=>this._definitions.add(t))):this._definitions.add(t)}getDispatcher(){return t=>{t.on("attribute:linkHref",((t,e,n)=>{if(!n.consumable.test(e.item,"attribute:linkHref"))return;const o=n.writer,i=o.document.selection;for(const t of this._definitions){const r=o.createAttributeElement("a",t.attributes,{priority:5});t.classes&&o.addClass(t.classes,r);for(const e in t.styles)o.setStyle(e,t.styles[e],r);o.setCustomProperty("link",!0,r),t.callback(e.attributeNewValue)?e.item.is("selection")?o.wrap(i.getFirstRange(),r):o.wrap(n.mapper.toViewRange(e.range),r):o.unwrap(n.mapper.toViewRange(e.range),r)}}),{priority:"high"})}}getDispatcherForLinkedImage(){return t=>{t.on("attribute:linkHref:imageBlock",((t,e,{writer:n,mapper:o})=>{const i=o.toViewElement(e.item),r=Array.from(i.getChildren()).find((t=>"a"===t.name));for(const t of this._definitions){const o=qo(t.attributes);if(t.callback(e.attributeNewValue)){for(const[t,e]of o)"class"===t?n.addClass(e,r):n.setAttribute(t,e,r);t.classes&&n.addClass(t.classes,r);for(const e in t.styles)n.setStyle(e,t.styles[e],r)}else{for(const[t,e]of o)"class"===t?n.removeClass(e,r):n.removeAttribute(t,r);t.classes&&n.removeClass(t.classes,r);for(const e in t.styles)n.removeStyle(e,r)}}}))}}}const Sk=function(t,e,n){var o=t.length;return n=void 0===n?o:n,!e&&n>=o?t:ui(t,e,n)};var Bk=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");const Tk=function(t){return Bk.test(t)};const Pk=function(t){return t.split("")};var Ik="[\\ud800-\\udfff]",Rk="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",zk="\\ud83c[\\udffb-\\udfff]",Fk="[^\\ud800-\\udfff]",Nk="(?:\\ud83c[\\udde6-\\uddff]){2}",Ok="[\\ud800-\\udbff][\\udc00-\\udfff]",Mk="(?:"+Rk+"|"+zk+")"+"?",Vk="[\\ufe0e\\ufe0f]?",Lk=Vk+Mk+("(?:\\u200d(?:"+[Fk,Nk,Ok].join("|")+")"+Vk+Mk+")*"),Hk="(?:"+[Fk+Rk+"?",Rk,Nk,Ok,Ik].join("|")+")",qk=RegExp(zk+"(?="+zk+")|"+Hk+Lk,"g");const Wk=function(t){return t.match(qk)||[]};const jk=function(t){return Tk(t)?Wk(t):Pk(t)};const Uk=function(t){return function(e){e=si(e);var n=Tk(e)?jk(e):void 0,o=n?n[0]:e.charAt(0),i=n?Sk(n,1).join(""):e.slice(1);return o[t]()+i}}("toUpperCase"),$k=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g,Gk=/^(?:(?:https?|ftps?|mailto):|[^a-z]|[a-z+.-]+(?:[^a-z+.:-]|$))/i,Kk=/^[\S]+@((?![-_])(?:[-\w\u00a1-\uffff]{0,63}[^-_]\.))+(?:[a-z\u00a1-\uffff]{2,})$/i,Zk=/^((\w+:(\/{2,})?)|(\W))/i,Jk="Ctrl+K";function Yk(t,{writer:e}){const n=e.createAttributeElement("a",{href:t},{priority:5});return e.setCustomProperty("link",!0,n),n}function Qk(t){return function(t){return t.replace($k,"").match(Gk)}(t=String(t))?t:"#"}function Xk(t,e){return!!t&&e.checkAttribute(t.name,"linkHref")}function tw(t,e){const n=(o=t,Kk.test(o)?"mailto:":e);var o;const i=!!n&&!Zk.test(t);return t&&i?n+t:t}function ew(t){window.open(t,"_blank","noopener")}class nw extends ge{constructor(t){super(t),this.manualDecorators=new So,this.automaticDecorators=new Dk}restoreManualDecoratorStates(){for(const t of this.manualDecorators)t.value=this._getDecoratorStateFromModel(t.id)}refresh(){const t=this.editor.model,e=t.document.selection,n=e.getSelectedElement()||Ta(e.getSelectedBlocks());Xk(n,t.schema)?(this.value=n.getAttribute("linkHref"),this.isEnabled=t.schema.checkAttribute(n,"linkHref")):(this.value=e.getAttribute("linkHref"),this.isEnabled=t.schema.checkAttributeInSelection(e,"linkHref"));for(const t of this.manualDecorators)t.value=this._getDecoratorStateFromModel(t.id)}execute(t,e={}){const n=this.editor.model,o=n.document.selection,i=[],r=[];for(const t in e)e[t]?i.push(t):r.push(t);n.change((e=>{if(o.isCollapsed){const s=o.getFirstPosition();if(o.hasAttribute("linkHref")){const a=Hf(s,"linkHref",o.getAttribute("linkHref"),n);e.setAttribute("linkHref",t,a),i.forEach((t=>{e.setAttribute(t,!0,a)})),r.forEach((t=>{e.removeAttribute(t,a)})),e.setSelection(e.createPositionAfter(a.end.nodeBefore))}else if(""!==t){const r=qo(o.getAttributes());r.set("linkHref",t),i.forEach((t=>{r.set(t,!0)}));const{end:a}=n.insertContent(e.createText(t,r),s);e.setSelection(a)}["linkHref",...i,...r].forEach((t=>{e.removeSelectionAttribute(t)}))}else{const s=n.schema.getValidRanges(o.getRanges(),"linkHref"),a=[];for(const t of o.getSelectedBlocks())n.schema.checkAttribute(t,"linkHref")&&a.push(e.createRangeOn(t));const c=a.slice();for(const t of s)this._isRangeToUpdate(t,a)&&c.push(t);for(const n of c)e.setAttribute("linkHref",t,n),i.forEach((t=>{e.setAttribute(t,!0,n)})),r.forEach((t=>{e.removeAttribute(t,n)}))}}))}_getDecoratorStateFromModel(t){const e=this.editor.model,n=e.document.selection,o=n.getSelectedElement();return Xk(o,e.schema)?o.getAttribute(t):n.getAttribute(t)}_isRangeToUpdate(t,e){for(const n of e)if(n.containsRange(t))return!1;return!0}}class ow extends ge{refresh(){const t=this.editor.model,e=t.document.selection,n=e.getSelectedElement();Xk(n,t.schema)?this.isEnabled=t.schema.checkAttribute(n,"linkHref"):this.isEnabled=t.schema.checkAttributeInSelection(e,"linkHref")}execute(){const t=this.editor,e=this.editor.model,n=e.document.selection,o=t.commands.get("link");e.change((t=>{const i=n.isCollapsed?[Hf(n.getFirstPosition(),"linkHref",n.getAttribute("linkHref"),e)]:e.schema.getValidRanges(n.getRanges(),"linkHref");for(const e of i)if(t.removeAttribute("linkHref",e),o)for(const n of o.manualDecorators)t.removeAttribute(n.id,e)}))}}class iw{constructor({id:t,label:e,attributes:n,classes:o,styles:i,defaultValue:r}){this.id=t,this.set("value"),this.defaultValue=r,this.label=e,this.attributes=n,this.classes=o,this.styles=i}_createPattern(){return{attributes:this.attributes,classes:this.classes,styles:this.styles}}}he(iw,se);var rw=n(399),sw={attributes:{"data-cke":!0}};sw.setAttributes=is(),sw.insert=ns().bind(null,"head"),sw.domAPI=ts(),sw.insertStyleElement=ss();Qr()(rw.Z,sw);rw.Z&&rw.Z.locals&&rw.Z.locals;const aw="automatic",cw=/^(https?:)?\/\//;class lw extends pe{static get pluginName(){return"LinkEditing"}static get requires(){return[Ff,Pf,Og]}constructor(t){super(t),t.config.define("link",{addTargetToExternalLinks:!1})}init(){const t=this.editor;t.model.schema.extend("$text",{allowAttributes:"linkHref"}),t.conversion.for("dataDowncast").attributeToElement({model:"linkHref",view:Yk}),t.conversion.for("editingDowncast").attributeToElement({model:"linkHref",view:(t,e)=>Yk(Qk(t),e)}),t.conversion.for("upcast").elementToAttribute({view:{name:"a",attributes:{href:!0}},model:{key:"linkHref",value:t=>t.getAttribute("href")}}),t.commands.add("link",new nw(t)),t.commands.add("unlink",new ow(t));const e=function(t,e){const n={"Open in a new tab":t("Open in a new tab"),Downloadable:t("Downloadable")};return e.forEach((t=>(t.label&&n[t.label]&&(t.label=n[t.label]),t))),e}(t.t,function(t){const e=[];if(t)for(const[n,o]of Object.entries(t)){const t=Object.assign({},o,{id:`link${Uk(n)}`});e.push(t)}return e}(t.config.get("link.decorators")));this._enableAutomaticDecorators(e.filter((t=>t.mode===aw))),this._enableManualDecorators(e.filter((t=>"manual"===t.mode)));t.plugins.get(Ff).registerAttribute("linkHref"),Wf(t,"linkHref","a","ck-link_selected"),this._enableLinkOpen(),this._enableInsertContentSelectionAttributesFixer(),this._enableClickingAfterLink(),this._enableTypingOverLink(),this._handleDeleteContentAfterLink()}_enableAutomaticDecorators(t){const e=this.editor,n=e.commands.get("link").automaticDecorators;e.config.get("link.addTargetToExternalLinks")&&n.add({id:"linkIsExternal",mode:aw,callback:t=>cw.test(t),attributes:{target:"_blank",rel:"noopener noreferrer"}}),n.add(t),n.length&&e.conversion.for("downcast").add(n.getDispatcher())}_enableManualDecorators(t){if(!t.length)return;const e=this.editor,n=e.commands.get("link").manualDecorators;t.forEach((t=>{e.model.schema.extend("$text",{allowAttributes:t.id}),t=new iw(t),n.add(t),e.conversion.for("downcast").attributeToElement({model:t.id,view:(e,{writer:n})=>{if(e){const e=n.createAttributeElement("a",t.attributes,{priority:5});t.classes&&n.addClass(t.classes,e);for(const o in t.styles)n.setStyle(o,t.styles[o],e);return n.setCustomProperty("link",!0,e),e}}}),e.conversion.for("upcast").elementToAttribute({view:{name:"a",...t._createPattern()},model:{key:t.id}})}))}_enableLinkOpen(){const t=this.editor,e=t.editing.view.document,n=t.model.document;this.listenTo(e,"click",((t,e)=>{if(!(ar.isMac?e.domEvent.metaKey:e.domEvent.ctrlKey))return;let n=e.domTarget;if("a"!=n.tagName.toLowerCase()&&(n=n.closest("a")),!n)return;const o=n.getAttribute("href");o&&(t.stop(),e.preventDefault(),ew(o))}),{context:"$capture"}),this.listenTo(e,"enter",((t,e)=>{const o=n.selection,i=o.getSelectedElement(),r=i?i.getAttribute("linkHref"):o.getAttribute("linkHref");r&&e.domEvent.altKey&&(t.stop(),ew(r))}),{context:"a"})}_enableInsertContentSelectionAttributesFixer(){const t=this.editor.model,e=t.document.selection;this.listenTo(t,"insertContent",(()=>{const n=e.anchor.nodeBefore,o=e.anchor.nodeAfter;e.hasAttribute("linkHref")&&n&&n.hasAttribute("linkHref")&&(o&&o.hasAttribute("linkHref")||t.change((e=>{dw(e,hw(t.schema))})))}),{priority:"low"})}_enableClickingAfterLink(){const t=this.editor,e=t.model;t.editing.view.addObserver(hp);let n=!1;this.listenTo(t.editing.view.document,"mousedown",(()=>{n=!0})),this.listenTo(t.editing.view.document,"selectionChange",(()=>{if(!n)return;n=!1;const t=e.document.selection;if(!t.isCollapsed)return;if(!t.hasAttribute("linkHref"))return;const o=t.getFirstPosition(),i=Hf(o,"linkHref",t.getAttribute("linkHref"),e);(o.isTouching(i.start)||o.isTouching(i.end))&&e.change((t=>{dw(t,hw(e.schema))}))}))}_enableTypingOverLink(){const t=this.editor,e=t.editing.view;let n,o;this.listenTo(e.document,"delete",(()=>{o=!0}),{priority:"high"}),this.listenTo(t.model,"deleteContent",(()=>{const e=t.model.document.selection;e.isCollapsed||(o?o=!1:uw(t)&&function(t){const e=t.document.selection,n=e.getFirstPosition(),o=e.getLastPosition(),i=n.nodeAfter;if(!i)return!1;if(!i.is("$text"))return!1;if(!i.hasAttribute("linkHref"))return!1;const r=o.textNode||o.nodeBefore;if(i===r)return!0;return Hf(n,"linkHref",i.getAttribute("linkHref"),t).containsRange(t.createRange(n,o),!0)}(t.model)&&(n=e.getAttributes()))}),{priority:"high"}),this.listenTo(t.model,"insertContent",((e,[i])=>{o=!1,uw(t)&&n&&(t.model.change((t=>{for(const[e,o]of n)t.setAttribute(e,o,i)})),n=null)}),{priority:"high"})}_handleDeleteContentAfterLink(){const t=this.editor,e=t.model,n=e.document.selection,o=t.editing.view;let i=!1,r=!1;this.listenTo(o.document,"delete",((t,e)=>{r=e.domEvent.keyCode===ur.backspace}),{priority:"high"}),this.listenTo(e,"deleteContent",(()=>{i=!1;const t=n.getFirstPosition(),o=n.getAttribute("linkHref");if(!o)return;const r=Hf(t,"linkHref",o,e);i=r.containsPosition(t)||r.end.isEqual(t)}),{priority:"high"}),this.listenTo(e,"deleteContent",(()=>{r&&(r=!1,i||t.model.enqueueChange((t=>{dw(t,hw(e.schema))})))}),{priority:"low"})}}function dw(t,e){t.removeSelectionAttribute("linkHref");for(const n of e)t.removeSelectionAttribute(n)}function uw(t){return t.model.change((t=>t.batch)).isTyping}function hw(t){return t.getDefinition("$text").allowAttributes.filter((t=>t.startsWith("link")))}var pw=n(1590),mw={attributes:{"data-cke":!0}};mw.setAttributes=is(),mw.insert=ns().bind(null,"head"),mw.domAPI=ts(),mw.insertStyleElement=ss();Qr()(pw.Z,mw);pw.Z&&pw.Z.locals&&pw.Z.locals;var gw=n(4827),fw={attributes:{"data-cke":!0}};fw.setAttributes=is(),fw.insert=ns().bind(null,"head"),fw.domAPI=ts(),fw.insertStyleElement=ss();Qr()(gw.Z,fw);gw.Z&&gw.Z.locals&&gw.Z.locals;class bw extends Od{constructor(t,e){super(t);const n=t.t;this.focusTracker=new Pa,this.keystrokes=new Ia,this.urlInputView=this._createUrlInput(),this.saveButtonView=this._createButton(n("Save"),Td.check,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(n("Cancel"),Td.cancel,"ck-button-cancel","cancel"),this._manualDecoratorSwitches=this._createManualDecoratorSwitches(e),this.children=this._createFormChildren(e.manualDecorators),this._focusables=new zd,this._focusCycler=new Au({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}});const o=["ck","ck-link-form","ck-responsive-form"];e.manualDecorators.length&&o.push("ck-link-form_layout-vertical","ck-vertical-form"),this.setTemplate({tag:"form",attributes:{class:o,tabindex:"-1"},children:this.children}),Id(this)}getDecoratorSwitchesState(){return Array.from(this._manualDecoratorSwitches).reduce(((t,e)=>(t[e.name]=e.isOn,t)),{})}render(){super.render(),Rd({view:this});[this.urlInputView,...this._manualDecoratorSwitches,this.saveButtonView,this.cancelButtonView].forEach((t=>{this._focusables.add(t),this.focusTracker.add(t.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createUrlInput(){const t=this.locale.t,e=new Ah(this.locale,vh);return e.label=t("Link URL"),e}_createButton(t,e,n,o){const i=new pu(this.locale);return i.set({label:t,icon:e,tooltip:!0}),i.extendTemplate({attributes:{class:n}}),o&&i.delegate("execute").to(this,o),i}_createManualDecoratorSwitches(t){const e=this.createCollection();for(const n of t.manualDecorators){const o=new fu(this.locale);o.set({name:n.id,label:n.label,withText:!0}),o.bind("isOn").toMany([n,t],"value",((t,e)=>void 0===e&&void 0===t?n.defaultValue:t)),o.on("execute",(()=>{n.set("value",!o.isOn)})),e.add(o)}return e}_createFormChildren(t){const e=this.createCollection();if(e.add(this.urlInputView),t.length){const t=new Od;t.setTemplate({tag:"ul",children:this._manualDecoratorSwitches.map((t=>({tag:"li",children:[t],attributes:{class:["ck","ck-list__item"]}}))),attributes:{class:["ck","ck-reset","ck-list"]}}),e.add(t)}return e.add(this.saveButtonView),e.add(this.cancelButtonView),e}}var kw=n(9465),ww={attributes:{"data-cke":!0}};ww.setAttributes=is(),ww.insert=ns().bind(null,"head"),ww.domAPI=ts(),ww.insertStyleElement=ss();Qr()(kw.Z,ww);kw.Z&&kw.Z.locals&&kw.Z.locals;class _w extends Od{constructor(t){super(t);const e=t.t;this.focusTracker=new Pa,this.keystrokes=new Ia,this.previewButtonView=this._createPreviewButton(),this.unlinkButtonView=this._createButton(e("Unlink"),'',"unlink"),this.editButtonView=this._createButton(e("Edit link"),Td.pencil,"edit"),this.set("href"),this._focusables=new zd,this._focusCycler=new Au({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((t=>{this._focusables.add(t),this.focusTracker.add(t.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createButton(t,e,n){const o=new pu(this.locale);return o.set({label:t,icon:e,tooltip:!0}),o.delegate("execute").to(this,n),o}_createPreviewButton(){const t=new pu(this.locale),e=this.bindTemplate,n=this.t;return t.set({withText:!0,tooltip:n("Open link in new tab")}),t.extendTemplate({attributes:{class:["ck","ck-link-actions__preview"],href:e.to("href",(t=>t&&Qk(t))),target:"_blank",rel:"noopener noreferrer"}}),t.bind("label").to(this,"href",(t=>t||n("This link has no URL"))),t.bind("isEnabled").to(this,"href",(t=>!!t)),t.template.tag="a",t.template.eventListeners={},t}}const Cw="link-ui";class Aw extends pe{static get requires(){return[Vh]}static get pluginName(){return"LinkUI"}init(){const t=this.editor;t.editing.view.addObserver(up),this.actionsView=this._createActionsView(),this.formView=this._createFormView(),this._balloon=t.plugins.get(Vh),this._createToolbarLinkButton(),this._enableUserBalloonInteractions(),t.conversion.for("editingDowncast").markerToHighlight({model:Cw,view:{classes:["ck-fake-link-selection"]}}),t.conversion.for("editingDowncast").markerToElement({model:Cw,view:{name:"span",classes:["ck-fake-link-selection","ck-fake-link-selection_collapsed"]}})}destroy(){super.destroy(),this.formView.destroy()}_createActionsView(){const t=this.editor,e=new _w(t.locale),n=t.commands.get("link"),o=t.commands.get("unlink");return e.bind("href").to(n,"value"),e.editButtonView.bind("isEnabled").to(n),e.unlinkButtonView.bind("isEnabled").to(o),this.listenTo(e,"edit",(()=>{this._addFormView()})),this.listenTo(e,"unlink",(()=>{t.execute("unlink"),this._hideUI()})),e.keystrokes.set("Esc",((t,e)=>{this._hideUI(),e()})),e.keystrokes.set(Jk,((t,e)=>{this._addFormView(),e()})),e}_createFormView(){const t=this.editor,e=t.commands.get("link"),n=t.config.get("link.defaultProtocol"),o=new bw(t.locale,e);return o.urlInputView.fieldView.bind("value").to(e,"value"),o.urlInputView.bind("isReadOnly").to(e,"isEnabled",(t=>!t)),o.saveButtonView.bind("isEnabled").to(e),this.listenTo(o,"submit",(()=>{const{value:e}=o.urlInputView.fieldView.element,i=tw(e,n);t.execute("link",i,o.getDecoratorSwitchesState()),this._closeFormView()})),this.listenTo(o,"cancel",(()=>{this._closeFormView()})),o.keystrokes.set("Esc",((t,e)=>{this._closeFormView(),e()})),o}_createToolbarLinkButton(){const t=this.editor,e=t.commands.get("link"),n=t.t;t.keystrokes.set(Jk,((t,n)=>{n(),e.isEnabled&&this._showUI(!0)})),t.ui.componentFactory.add("link",(t=>{const o=new pu(t);return o.isEnabled=!0,o.label=n("Link"),o.icon='',o.keystroke=Jk,o.tooltip=!0,o.isToggleable=!0,o.bind("isEnabled").to(e,"isEnabled"),o.bind("isOn").to(e,"value",(t=>!!t)),this.listenTo(o,"execute",(()=>this._showUI(!0))),o}))}_enableUserBalloonInteractions(){const t=this.editor.editing.view.document;this.listenTo(t,"click",(()=>{this._getSelectedLinkElement()&&this._showUI()})),this.editor.keystrokes.set("Tab",((t,e)=>{this._areActionsVisible&&!this.actionsView.focusTracker.isFocused&&(this.actionsView.focus(),e())}),{priority:"high"}),this.editor.keystrokes.set("Esc",((t,e)=>{this._isUIVisible&&(this._hideUI(),e())})),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 t=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=t.value||""}_closeFormView(){const t=this.editor.commands.get("link");t.restoreManualDecoratorStates(),void 0!==t.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(t=!1){this._getSelectedLinkElement()?(this._areActionsVisible?this._addFormView():this._addActionsView(),t&&this._balloon.showStack("main")):(this._showFakeVisualSelection(),this._addActionsView(),t&&this._balloon.showStack("main"),this._addFormView()),this._startUpdatingUI()}_hideUI(){if(!this._isUIInPanel)return;const t=this.editor;this.stopListening(t.ui,"update"),this.stopListening(this._balloon,"change:visibleView"),t.editing.view.focus(),this._removeFormView(),this._balloon.remove(this.actionsView),this._hideFakeVisualSelection()}_startUpdatingUI(){const t=this.editor,e=t.editing.view.document;let n=this._getSelectedLinkElement(),o=r();const i=()=>{const t=this._getSelectedLinkElement(),e=r();n&&!t||!n&&e!==o?this._hideUI():this._isUIVisible&&this._balloon.updatePosition(this._getBalloonPositionData()),n=t,o=e};function r(){return e.selection.focus.getAncestors().reverse().find((t=>t.is("element")))}this.listenTo(t.ui,"update",i),this.listenTo(this._balloon,"change:visibleView",i)}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 t=this.editor.editing.view,e=this.editor.model,n=t.document;let o=null;if(e.markers.has(Cw)){const e=Array.from(this.editor.editing.mapper.markerNameToElements(Cw)),n=t.createRange(t.createPositionBefore(e[0]),t.createPositionAfter(e[e.length-1]));o=t.domConverter.viewRangeToDom(n)}else o=()=>{const e=this._getSelectedLinkElement();return e?t.domConverter.mapViewToDom(e):t.domConverter.viewRangeToDom(n.selection.getFirstRange())};return{target:o}}_getSelectedLinkElement(){const t=this.editor.editing.view,e=t.document.selection,n=e.getSelectedElement();if(e.isCollapsed||n&&hm(n))return vw(e.getFirstPosition());{const n=e.getFirstRange().getTrimmed(),o=vw(n.start),i=vw(n.end);return o&&o==i&&t.createRangeIn(o).getTrimmed().isEqual(n)?o:null}}_showFakeVisualSelection(){const t=this.editor.model;t.change((e=>{const n=t.document.selection.getFirstRange();if(t.markers.has(Cw))e.updateMarker(Cw,{range:n});else if(n.start.isAtEnd){const o=n.start.getLastMatchingPosition((({item:e})=>!t.schema.isContent(e)),{boundaries:n});e.addMarker(Cw,{usingOperation:!1,affectsData:!1,range:e.createRange(o,n.end)})}else e.addMarker(Cw,{usingOperation:!1,affectsData:!1,range:n})}))}_hideFakeVisualSelection(){const t=this.editor.model;t.markers.has(Cw)&&t.change((t=>{t.removeMarker(Cw)}))}}function vw(t){return t.getAncestors().find((t=>{return(e=t).is("attributeElement")&&!!e.getCustomProperty("link");var e}))}const yw=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 xw extends pe{static get requires(){return[Lm]}static get pluginName(){return"AutoLink"}init(){const t=this.editor.model.document.selection;t.on("change:range",(()=>{this.isEnabled=!t.anchor.parent.is("element","codeBlock")})),this._enableTypingHandling()}afterInit(){this._enableEnterHandling(),this._enableShiftEnterHandling()}_enableTypingHandling(){const t=this.editor,e=new zf(t.model,(t=>{if(!function(t){return t.length>4&&" "===t[t.length-1]&&" "!==t[t.length-2]}(t))return;const e=Ew(t.substr(0,t.length-1));return e?{url:e}:void 0}));e.on("matched:data",((e,n)=>{const{batch:o,range:i,url:r}=n;if(!o.isTyping)return;const s=i.end.getShiftedBy(-1),a=s.getShiftedBy(-r.length),c=t.model.createRange(a,s);this._applyAutoLink(r,c)})),e.bind("isEnabled").to(this)}_enableEnterHandling(){const t=this.editor,e=t.model,n=t.commands.get("enter");n&&n.on("execute",(()=>{const t=e.document.selection.getFirstPosition();if(!t.parent.previousSibling)return;const n=e.createRangeIn(t.parent.previousSibling);this._checkAndApplyAutoLinkOnRange(n)}))}_enableShiftEnterHandling(){const t=this.editor,e=t.model,n=t.commands.get("shiftEnter");n&&n.on("execute",(()=>{const t=e.document.selection.getFirstPosition(),n=e.createRange(e.createPositionAt(t.parent,0),t.getShiftedBy(-1));this._checkAndApplyAutoLinkOnRange(n)}))}_checkAndApplyAutoLinkOnRange(t){const e=this.editor.model,{text:n,range:o}=Rf(t,e),i=Ew(n);if(i){const t=e.createRange(o.end.getShiftedBy(-i.length),o.end);this._applyAutoLink(i,t)}}_applyAutoLink(t,e){const n=this.editor.model,o=this.editor.plugins.get("Delete");this.isEnabled&&function(t,e){return e.schema.checkAttributeInSelection(e.createSelection(t),"linkHref")}(e,n)&&n.enqueueChange((i=>{const r=this.editor.config.get("link.defaultProtocol"),s=tw(t,r);i.setAttribute("linkHref",s,e),n.enqueueChange((()=>{o.requestUndoOnBackspace()}))}))}}function Ew(t){const e=yw.exec(t);return e?e[2]:null}class Dw extends ge{constructor(t,e){super(t),this.type=e}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(t={}){const e=this.editor.model,n=e.document,o=Array.from(n.selection.getSelectedBlocks()).filter((t=>Bw(t,e.schema))),i=void 0!==t.forceValue?!t.forceValue:this.value;e.change((t=>{if(i){let e=o[o.length-1].nextSibling,n=Number.POSITIVE_INFINITY,i=[];for(;e&&"listItem"==e.name&&0!==e.getAttribute("listIndent");){const t=e.getAttribute("listIndent");t=n;)r>i.getAttribute("listIndent")&&(r=i.getAttribute("listIndent")),i.getAttribute("listIndent")==r&&t[e?"unshift":"push"](i),i=i[e?"previousSibling":"nextSibling"]}}function Bw(t,e){return e.checkChild(t.parent,"listItem")&&!e.isObject(t)}class Tw extends ge{constructor(t,e){super(t),this._indentBy="forward"==e?1:-1}refresh(){this.isEnabled=this._checkEnabled()}execute(){const t=this.editor.model,e=t.document;let n=Array.from(e.selection.getSelectedBlocks());t.change((t=>{const e=n[n.length-1];let o=e.nextSibling;for(;o&&"listItem"==o.name&&o.getAttribute("listIndent")>e.getAttribute("listIndent");)n.push(o),o=o.nextSibling;this._indentBy<0&&(n=n.reverse());for(const e of n){const n=e.getAttribute("listIndent")+this._indentBy;n<0?t.rename(e,"paragraph"):t.setAttribute("listIndent",n,e)}this.fire("_executeCleanup",n)}))}_checkEnabled(){const t=Ta(this.editor.model.document.selection.getSelectedBlocks());if(!t||!t.is("element","listItem"))return!1;if(this._indentBy>0){const e=t.getAttribute("listIndent"),n=t.getAttribute("listType");let o=t.previousSibling;for(;o&&o.is("element","listItem")&&o.getAttribute("listIndent")>=e;){if(o.getAttribute("listIndent")==e)return o.getAttribute("listType")==n;o=o.previousSibling}return!1}return!0}}function Pw(t,e){const n=e.mapper,o=e.writer,i="numbered"==t.getAttribute("listType")?"ol":"ul",r=function(t){const e=t.createContainerElement("li");return e.getFillerOffset=Mw,e}(o),s=o.createContainerElement(i,null);return o.insert(o.createPositionAt(s,0),r),n.bindElements(t,r),r}function Iw(t,e,n,o){const i=e.parent,r=n.mapper,s=n.writer;let a=r.toViewPosition(o.createPositionBefore(t));const c=Fw(t.previousSibling,{sameIndent:!0,smallerIndent:!0,listIndent:t.getAttribute("listIndent")}),l=t.previousSibling;if(c&&c.getAttribute("listIndent")==t.getAttribute("listIndent")){const t=r.toViewElement(c);a=s.breakContainer(s.createPositionAfter(t))}else if(l&&"listItem"==l.name){a=r.toViewPosition(o.createPositionAt(l,"end"));const t=r.findMappedViewAncestor(a),e=Ow(t);a=e?s.createPositionBefore(e):s.createPositionAt(t,"end")}else a=r.toViewPosition(o.createPositionBefore(t));if(a=zw(a),s.insert(a,i),l&&"listItem"==l.name){const t=r.toViewElement(l),n=s.createRange(s.createPositionAt(t,0),a).getWalker({ignoreElementEnd:!0});for(const t of n)if(t.item.is("element","li")){const o=s.breakContainer(s.createPositionBefore(t.item)),i=t.item.parent,r=s.createPositionAt(e,"end");Rw(s,r.nodeBefore,r.nodeAfter),s.move(s.createRangeOn(i),r),n.position=o}}else{const n=i.nextSibling;if(n&&(n.is("element","ul")||n.is("element","ol"))){let o=null;for(const e of n.getChildren()){const n=r.toModelElement(e);if(!(n&&n.getAttribute("listIndent")>t.getAttribute("listIndent")))break;o=e}o&&(s.breakContainer(s.createPositionAfter(o)),s.move(s.createRangeOn(o.parent),s.createPositionAt(e,"end")))}}Rw(s,i,i.nextSibling),Rw(s,i.previousSibling,i)}function Rw(t,e,n){return!e||!n||"ul"!=e.name&&"ol"!=e.name||e.name!=n.name||e.getAttribute("class")!==n.getAttribute("class")?null:t.mergeContainers(t.createPositionAfter(e))}function zw(t){return t.getLastMatchingPosition((t=>t.item.is("uiElement")))}function Fw(t,e){const n=!!e.sameIndent,o=!!e.smallerIndent,i=e.listIndent;let r=t;for(;r&&"listItem"==r.name;){const t=r.getAttribute("listIndent");if(n&&i==t||o&&i>t)return r;r="forward"===e.direction?r.nextSibling:r.previousSibling}return null}function Nw(t,e,n,o){t.ui.componentFactory.add(e,(i=>{const r=t.commands.get(e),s=new pu(i);return s.set({label:n,icon:o,tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(r,"value","isEnabled"),s.on("execute",(()=>{t.execute(e),t.editing.view.focus()})),s}))}function Ow(t){for(const e of t.getChildren())if("ul"==e.name||"ol"==e.name)return e;return null}function Mw(){const t=!this.isEmpty&&("ul"==this.getChild(0).name||"ol"==this.getChild(0).name);return this.isEmpty||t?0:zi.call(this)}function Vw(t){return(e,n,o)=>{const i=o.consumable;if(!i.test(n.item,"insert")||!i.test(n.item,"attribute:listType")||!i.test(n.item,"attribute:listIndent"))return;i.consume(n.item,"insert"),i.consume(n.item,"attribute:listType"),i.consume(n.item,"attribute:listIndent");const r=n.item;Iw(r,Pw(r,o),o,t)}}function Lw(t,e,n){if(!n.consumable.consume(e.item,"attribute:listType"))return;const o=n.mapper.toViewElement(e.item),i=n.writer;i.breakContainer(i.createPositionBefore(o)),i.breakContainer(i.createPositionAfter(o));const r=o.parent,s="numbered"==e.attributeNewValue?"ol":"ul";i.rename(s,r)}function Hw(t,e,n){const o=n.mapper.toViewElement(e.item).parent,i=n.writer;Rw(i,o,o.nextSibling),Rw(i,o.previousSibling,o);for(const t of e.item.getChildren())n.consumable.consume(t,"insert")}function qw(t,e,n){if("listItem"!=e.item.name){let t=n.mapper.toViewPosition(e.range.start);const o=n.writer,i=[];for(;("ul"==t.parent.name||"ol"==t.parent.name)&&(t=o.breakContainer(t),"li"==t.parent.name);){const e=t,n=o.createPositionAt(t.parent,"end");if(!e.isEqual(n)){const t=o.remove(o.createRange(e,n));i.push(t)}t=o.createPositionAfter(t.parent)}if(i.length>0){for(let e=0;e0){const e=Rw(o,n,n.nextSibling);e&&e.parent==n&&t.offset--}}Rw(o,t.nodeBefore,t.nodeAfter)}}}function Ww(t,e,n){const o=n.mapper.toViewPosition(e.position),i=o.nodeBefore,r=o.nodeAfter;Rw(n.writer,i,r)}function jw(t,e,n){if(n.consumable.consume(e.viewItem,{name:!0})){const t=n.writer,o=t.createElement("listItem"),i=function(t){let e=0,n=t.parent;for(;n;){if(n.is("element","li"))e++;else{const t=n.previousSibling;t&&t.is("element","li")&&e++}n=n.parent}return e}(e.viewItem);t.setAttribute("listIndent",i,o);const r=e.viewItem.parent&&"ol"==e.viewItem.parent.name?"numbered":"bulleted";if(t.setAttribute("listType",r,o),!n.safeInsert(o,e.modelCursor))return;const s=function(t,e,n){const{writer:o,schema:i}=n;let r=o.createPositionAfter(t);for(const s of e)if("ul"==s.name||"ol"==s.name)r=n.convertItem(s,r).modelCursor;else{const e=n.convertItem(s,o.createPositionAt(t,"end")),a=e.modelRange.start.nodeAfter;a&&a.is("element")&&!i.checkChild(t,a.name)&&(t=e.modelCursor.parent.is("element","listItem")?e.modelCursor.parent:Zw(e.modelCursor),r=o.createPositionAfter(t))}return r}(o,e.viewItem.getChildren(),n);e.modelRange=t.createRange(e.modelCursor,s),n.updateConversionResult(o,e)}}function Uw(t,e,n){if(n.consumable.test(e.viewItem,{name:!0})){const t=Array.from(e.viewItem.getChildren());for(const e of t){!(e.is("element","li")||Yw(e))&&e._remove()}}}function $w(t,e,n){if(n.consumable.test(e.viewItem,{name:!0})){if(0===e.viewItem.childCount)return;const t=[...e.viewItem.getChildren()];let n=!1;for(const e of t)n&&!Yw(e)&&e._remove(),Yw(e)&&(n=!0)}}function Gw(t){return(e,n)=>{if(n.isPhantom)return;const o=n.modelPosition.nodeBefore;if(o&&o.is("element","listItem")){const e=n.mapper.toViewElement(o),i=e.getAncestors().find(Yw),r=t.createPositionAt(e,0).getWalker();for(const t of r){if("elementStart"==t.type&&t.item.is("element","li")){n.viewPosition=t.previousPosition;break}if("elementEnd"==t.type&&t.item==i){n.viewPosition=t.nextPosition;break}}}}}function Kw(t,[e,n]){let o,i=e.is("documentFragment")?e.getChild(0):e;if(o=n?this.createSelection(n):this.document.selection,i&&i.is("element","listItem")){const t=o.getFirstPosition();let e=null;if(t.parent.is("element","listItem")?e=t.parent:t.nodeBefore&&t.nodeBefore.is("element","listItem")&&(e=t.nodeBefore),e){const t=e.getAttribute("listIndent");if(t>0)for(;i&&i.is("element","listItem");)i._setAttribute("listIndent",i.getAttribute("listIndent")+t),i=i.nextSibling}}}function Zw(t){const e=new Ja({startPosition:t});let n;do{n=e.next()}while(!n.value.item.is("element","listItem"));return n.value.item}function Jw(t,e,n,o,i,r){const s=Fw(e.nodeBefore,{sameIndent:!0,smallerIndent:!0,listIndent:t,foo:"b"}),a=i.mapper,c=i.writer,l=s?s.getAttribute("listIndent"):null;let d;if(s)if(l==t){const t=a.toViewElement(s).parent;d=c.createPositionAfter(t)}else{const t=r.createPositionAt(s,"end");d=a.toViewPosition(t)}else d=n;d=zw(d);for(const t of[...o.getChildren()])Yw(t)&&(d=c.move(c.createRangeOn(t),d).end,Rw(c,t,t.nextSibling),Rw(c,t.previousSibling,t))}function Yw(t){return t.is("element","ol")||t.is("element","ul")}class Qw extends pe{static get pluginName(){return"ListEditing"}static get requires(){return[Rm,Lm]}init(){const t=this.editor;t.model.schema.register("listItem",{inheritAllFrom:"$block",allowAttributes:["listType","listIndent"]});const e=t.data,n=t.editing;var o;t.model.document.registerPostFixer((e=>function(t,e){const n=t.document.differ.getChanges(),o=new Map;let i=!1;for(const o of n)if("insert"==o.type&&"listItem"==o.name)r(o.position);else if("insert"==o.type&&"listItem"!=o.name){if("$text"!=o.name){const n=o.position.nodeAfter;n.hasAttribute("listIndent")&&(e.removeAttribute("listIndent",n),i=!0),n.hasAttribute("listType")&&(e.removeAttribute("listType",n),i=!0),n.hasAttribute("listStyle")&&(e.removeAttribute("listStyle",n),i=!0),n.hasAttribute("listReversed")&&(e.removeAttribute("listReversed",n),i=!0),n.hasAttribute("listStart")&&(e.removeAttribute("listStart",n),i=!0);for(const e of Array.from(t.createRangeIn(n)).filter((t=>t.item.is("element","listItem"))))r(e.previousPosition)}r(o.position.getShiftedBy(o.length))}else"remove"==o.type&&"listItem"==o.name?r(o.position):("attribute"==o.type&&"listIndent"==o.attributeKey||"attribute"==o.type&&"listType"==o.attributeKey)&&r(o.range.start);for(const t of o.values())s(t),a(t);return i;function r(t){const e=t.nodeBefore;if(e&&e.is("element","listItem")){let t=e;if(o.has(t))return;for(let e=t.previousSibling;e&&e.is("element","listItem");e=t.previousSibling)if(t=e,o.has(t))return;o.set(e,t)}else{const e=t.nodeAfter;e&&e.is("element","listItem")&&o.set(e,e)}}function s(t){let n=0,o=null;for(;t&&t.is("element","listItem");){const r=t.getAttribute("listIndent");if(r>n){let s;null===o?(o=r-n,s=n):(o>r&&(o=r),s=r-o),e.setAttribute("listIndent",s,t),i=!0}else o=null,n=t.getAttribute("listIndent")+1;t=t.nextSibling}}function a(t){let n=[],o=null;for(;t&&t.is("element","listItem");){const r=t.getAttribute("listIndent");if(o&&o.getAttribute("listIndent")>r&&(n=n.slice(0,r+1)),0!=r)if(n[r]){const o=n[r];t.getAttribute("listType")!=o&&(e.setAttribute("listType",o,t),i=!0)}else n[r]=t.getAttribute("listType");o=t,t=t.nextSibling}}}(t.model,e))),n.mapper.registerViewToModelLength("li",Xw),e.mapper.registerViewToModelLength("li",Xw),n.mapper.on("modelToViewPosition",Gw(n.view)),n.mapper.on("viewToModelPosition",(o=t.model,(t,e)=>{const n=e.viewPosition,i=n.parent,r=e.mapper;if("ul"==i.name||"ol"==i.name){if(n.isAtEnd){const t=r.toModelElement(n.nodeBefore),i=r.getModelLength(n.nodeBefore);e.modelPosition=o.createPositionBefore(t).getShiftedBy(i)}else{const t=r.toModelElement(n.nodeAfter);e.modelPosition=o.createPositionBefore(t)}t.stop()}else if("li"==i.name&&n.nodeBefore&&("ul"==n.nodeBefore.name||"ol"==n.nodeBefore.name)){const s=r.toModelElement(i);let a=1,c=n.nodeBefore;for(;c&&Yw(c);)a+=r.getModelLength(c),c=c.previousSibling;e.modelPosition=o.createPositionBefore(s).getShiftedBy(a),t.stop()}})),e.mapper.on("modelToViewPosition",Gw(n.view)),t.conversion.for("editingDowncast").add((e=>{e.on("insert",qw,{priority:"high"}),e.on("insert:listItem",Vw(t.model)),e.on("attribute:listType:listItem",Lw,{priority:"high"}),e.on("attribute:listType:listItem",Hw,{priority:"low"}),e.on("attribute:listIndent:listItem",function(t){return(e,n,o)=>{if(!o.consumable.consume(n.item,"attribute:listIndent"))return;const i=o.mapper.toViewElement(n.item),r=o.writer;r.breakContainer(r.createPositionBefore(i)),r.breakContainer(r.createPositionAfter(i));const s=i.parent,a=s.previousSibling,c=r.createRangeOn(s);r.remove(c),a&&a.nextSibling&&Rw(r,a,a.nextSibling),Jw(n.attributeOldValue+1,n.range.start,c.start,i,o,t),Iw(n.item,i,o,t);for(const t of n.item.getChildren())o.consumable.consume(t,"insert")}}(t.model)),e.on("remove:listItem",function(t){return(e,n,o)=>{const i=o.mapper.toViewPosition(n.position).getLastMatchingPosition((t=>!t.item.is("element","li"))).nodeAfter,r=o.writer;r.breakContainer(r.createPositionBefore(i)),r.breakContainer(r.createPositionAfter(i));const s=i.parent,a=s.previousSibling,c=r.createRangeOn(s),l=r.remove(c);a&&a.nextSibling&&Rw(r,a,a.nextSibling),Jw(o.mapper.toModelElement(i).getAttribute("listIndent")+1,n.position,c.start,i,o,t);for(const t of r.createRangeIn(l).getItems())o.mapper.unbindViewElement(t);e.stop()}}(t.model)),e.on("remove",Ww,{priority:"low"})})),t.conversion.for("dataDowncast").add((e=>{e.on("insert",qw,{priority:"high"}),e.on("insert:listItem",Vw(t.model))})),t.conversion.for("upcast").add((t=>{t.on("element:ul",Uw,{priority:"high"}),t.on("element:ol",Uw,{priority:"high"}),t.on("element:li",$w,{priority:"high"}),t.on("element:li",jw)})),t.model.on("insertContent",Kw,{priority:"high"}),t.commands.add("numberedList",new Dw(t,"numbered")),t.commands.add("bulletedList",new Dw(t,"bulleted")),t.commands.add("indentList",new Tw(t,"forward")),t.commands.add("outdentList",new Tw(t,"backward"));const i=n.view.document;this.listenTo(i,"enter",((t,e)=>{const n=this.editor.model.document,o=n.selection.getLastPosition().parent;n.selection.isCollapsed&&"listItem"==o.name&&o.isEmpty&&(this.editor.execute("outdentList"),e.preventDefault(),t.stop())}),{context:"li"}),this.listenTo(i,"delete",((t,e)=>{if("backward"!==e.direction)return;const n=this.editor.model.document.selection;if(!n.isCollapsed)return;const o=n.getFirstPosition();if(!o.isAtStart)return;const i=o.parent;if("listItem"!==i.name)return;i.previousSibling&&"listItem"===i.previousSibling.name||(this.editor.execute("outdentList"),e.preventDefault(),t.stop())}),{context:"li"});const r=t=>(e,n)=>{this.editor.commands.get(t).isEnabled&&(this.editor.execute(t),n())};t.keystrokes.set("Tab",r("indentList")),t.keystrokes.set("Shift+Tab",r("outdentList"))}afterInit(){const t=this.editor.commands,e=t.get("indent"),n=t.get("outdent");e&&e.registerChildCommand(t.get("indentList")),n&&n.registerChildCommand(t.get("outdentList"))}}function Xw(t){let e=1;for(const n of t.getChildren())if("ul"==n.name||"ol"==n.name)for(const t of n.getChildren())e+=Xw(t);return e}class t_ extends pe{static get pluginName(){return"ListUI"}init(){const t=this.editor.t;Nw(this.editor,"numberedList",t("Numbered List"),''),Nw(this.editor,"bulletedList",t("Bulleted List"),'')}}const e_=Symbol("isOPCodeBlock");function n_(t){return!!t.getCustomProperty(e_)&&hm(t)}function o_(t){const e=t.getSelectedElement();return!(!e||!n_(e))}function i_(t,e,n){const o=e.createContainerElement("pre",{title:window.I18n.t("js.editor.macro.toolbar_help")});return r_(e,t,o),function(t,e,n){return e.setCustomProperty(e_,!0,t),pm(t,e,{label:n})}(o,e,n)}function r_(t,e,n){const o=(e.getAttribute("opCodeblockLanguage")||"language-text").replace(/^language-/,""),i=t.createContainerElement("div",{class:"op-uc-code-block--language"});s_(t,o,i,"text"),t.insert(t.createPositionAt(n,0),i);s_(t,e.getAttribute("opCodeblockContent"),n,"(empty)")}function s_(t,e,n,o){const i=t.createText(e||o);t.insert(t.createPositionAt(n,0),i)}class a_ extends Xs{constructor(t){super(t),this.domEventType="dblclick"}onDomEvent(t){this.fire(t.type,t)}}class c_ extends pe{static get pluginName(){return"CodeBlockEditing"}init(){const t=this.editor,e=t.model.schema,n=t.conversion,o=t.editing.view,i=o.document,r=xm(t);e.register("codeblock",{isObject:!0,isBlock:!0,allowContentOf:"$block",allowWhere:["$root","$block"],allowIn:["$root"],allowAttributes:["opCodeblockLanguage","opCodeblockContent"]}),n.for("upcast").add(function(){return e=>{e.on("element:pre",t,{priority:"high"})};function t(t,e,n){if(!n.consumable.test(e.viewItem,{name:!0}))return;const o=Array.from(e.viewItem.getChildren()).find((t=>t.is("element","code")));if(!o||!n.consumable.consume(o,{name:!0}))return;const i=n.writer.createElement("codeblock");n.writer.setAttribute("opCodeblockLanguage",o.getAttribute("class"),i);const r=n.splitToAllowedParent(i,e.modelCursor);if(r){n.writer.insert(i,r.position);const t=o.getChild(0);n.consumable.consume(t,{name:!0});const s=t.data.replace(/\n$/,"");n.writer.setAttribute("opCodeblockContent",s,i),e.modelRange=new nc(n.writer.createPositionBefore(i),n.writer.createPositionAfter(i)),e.modelCursor=e.modelRange.end}}}()),n.for("editingDowncast").elementToElement({model:"codeblock",view:(t,{writer:e})=>i_(t,e,"Code block")}).add(function(){return e=>{e.on("attribute:opCodeblockContent",t),e.on("attribute:opCodeblockLanguage",t)};function t(t,e,n){const o=e.item;n.consumable.consume(e.item,t.name);const i=n.mapper.toViewElement(o);n.writer.remove(n.writer.createRangeOn(i.getChild(1))),n.writer.remove(n.writer.createRangeOn(i.getChild(0))),r_(n.writer,o,i)}}()),n.for("dataDowncast").add(function(){return e=>{e.on("insert:codeblock",t,{priority:"high"})};function t(t,e,n){const o=e.item,i=o.getAttribute("opCodeblockLanguage")||"language-text",r=o.getAttribute("opCodeblockContent");n.consumable.consume(o,"insert");const s=n.writer,a=s.createContainerElement("pre"),c=s.createContainerElement("div",{class:"op-uc-code-block--language"}),l=s.createContainerElement("code",{class:i}),d=s.createText(i),u=s.createText(r);s.insert(s.createPositionAt(l,0),u),s.insert(s.createPositionAt(c,0),d),s.insert(s.createPositionAt(a,0),c),s.insert(s.createPositionAt(a,0),l),n.mapper.bindElements(o,l),n.mapper.bindElements(o,a);const h=n.mapper.toViewPosition(e.range.start);s.insert(h,a),t.stop()}}()),o.addObserver(a_),this.listenTo(i,"dblclick",((e,n)=>{let o=n.target,i=n.domEvent;if(i.shiftKey||i.altKey||i.metaKey)return;if(!n_(o)&&(o=o.findAncestor(n_),!o))return;n.preventDefault(),n.stopPropagation();const s=t.editing.mapper.toModelElement(o),a=r.services.macros,c=s.getAttribute("opCodeblockLanguage"),l=s.getAttribute("opCodeblockContent");a.editCodeBlock(l,c).then((e=>t.model.change((t=>{t.setAttribute("opCodeblockLanguage",e.languageClass,s),t.setAttribute("opCodeblockContent",e.content,s)}))))})),t.ui.componentFactory.add("insertCodeBlock",(e=>{const n=new pu(e);return n.set({label:window.I18n.t("js.editor.macro.code_block.button"),icon:'\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n image/svg+xml\n \n \n \n \n\n',tooltip:!0}),n.on("execute",(()=>{r.services.macros.editCodeBlock().then((e=>t.model.change((n=>{const o=n.createElement("codeblock");n.setAttribute("opCodeblockLanguage",e.languageClass,o),n.setAttribute("opCodeblockContent",e.content,o),t.model.insertContent(o,t.model.document.selection)}))))})),n}))}}class l_ extends pe{static get requires(){return[Vh]}static get pluginName(){return"CodeBlockToolbar"}init(){const t=this.editor,e=this.editor.model,n=xm(t);ng(t,"opEditCodeBlock",(t=>{const o=n.services.macros,i=t.getAttribute("opCodeblockLanguage"),r=t.getAttribute("opCodeblockContent");o.editCodeBlock(r,i).then((n=>e.change((e=>{e.setAttribute("opCodeblockLanguage",n.languageClass,t),e.setAttribute("opCodeblockContent",n.content,t)}))))}))}afterInit(){ig(this,this.editor,"OPCodeBlock",o_)}}function d_(t){return t.__currentlyDisabled=t.__currentlyDisabled||[],t.ui.view.toolbar?t.ui.view.toolbar.items._items:[]}function u_(t,e){jQuery.each(d_(t),(function(n,o){let i=o;o instanceof gg?i=o.buttonView:o!==e&&o.hasOwnProperty("isEnabled")||(i=null),i&&(i.isEnabled?i.isEnabled=!1:t.__currentlyDisabled.push(i))}))}function h_(t){jQuery.each(d_(t),(function(e,n){let o=n;n instanceof gg&&(o=n.buttonView),t.__currentlyDisabled.indexOf(o)<0&&(o.isEnabled=!0)})),t.__currentlyDisabled=[]}function p_(t,e,n,o,i=1){e>i?o.setAttribute(t,e,n):o.removeAttribute(t,n)}function m_(t,e,n={}){const o=t.createElement("tableCell",n);return t.insertElement("paragraph",o),t.insert(o,e),o}function g_(t,e){const n=e.parent.parent,o=parseInt(n.getAttribute("headingColumns")||0),{column:i}=t.getCellLocation(e);return!!o&&i{t.on("element:table",((t,e,n)=>{const o=e.viewItem;if(!n.consumable.test(o,{name:!0}))return;const{rows:i,headingRows:r,headingColumns:s}=function(t){const e={headingRows:0,headingColumns:0},n=[],o=[];let i;for(const r of Array.from(t.getChildren()))if("tbody"===r.name||"thead"===r.name||"tfoot"===r.name){"thead"!==r.name||i||(i=r);const t=Array.from(r.getChildren()).filter((t=>t.is("element","tr")));for(const r of t)if("thead"===r.parent.name&&r.parent===i)e.headingRows++,n.push(r);else{o.push(r);const t=k_(r);t>e.headingColumns&&(e.headingColumns=t)}}return e.rows=[...n,...o],e}(o),a={};s&&(a.headingColumns=s),r&&(a.headingRows=r);const c=n.writer.createElement("table",a);if(n.safeInsert(c,e.modelCursor)){if(n.consumable.consume(o,{name:!0}),i.forEach((t=>n.convertItem(t,n.writer.createPositionAt(c,"end")))),n.convertChildren(o,n.writer.createPositionAt(c,"end")),c.isEmpty){const t=n.writer.createElement("tableRow");n.writer.insert(t,n.writer.createPositionAt(c,"end")),m_(n.writer,n.writer.createPositionAt(t,"end"))}n.updateConversionResult(c,e)}}))}}function b_(t){return e=>{e.on(`element:${t}`,((t,e,n)=>{if(e.modelRange&&e.viewItem.isEmpty){const t=e.modelRange.start.nodeAfter,o=n.writer.createPositionAt(t,0);n.writer.insertElement("paragraph",o)}}),{priority:"low"})}}function k_(t){let e=0,n=0;const o=Array.from(t.getChildren()).filter((t=>"th"===t.name||"td"===t.name));for(;n1||i>1)&&this._recordSpans(n,i,o),this._shouldSkipSlot()||(e=this._formatOutValue(n)),this._nextCellAtColumn=this._column+o}return this._column++,this._column==this._nextCellAtColumn&&this._cellIndex++,e||this.next()}skipRow(t){this._skipRows.add(t)}_advanceToNextRow(){return this._row++,this._rowIndex++,this._column=0,this._cellIndex=0,this._nextCellAtColumn=-1,this.next()}_isOverEndRow(){return void 0!==this._endRow&&this._row>this._endRow}_isOverEndColumn(){return void 0!==this._endColumn&&this._column>this._endColumn}_formatOutValue(t,e=this._row,n=this._column){return{done:!1,value:new __(this,t,e,n)}}_shouldSkipSlot(){const t=this._skipRows.has(this._row),e=this._rowthis._endColumn;return t||e||n||o}_getSpanned(){const t=this._spannedCells.get(this._row);return t&&t.get(this._column)||null}_recordSpans(t,e,n){const o={cell:t,row:this._row,column:this._column};for(let t=this._row;te.on("insert:table",((e,n,o)=>{const i=n.item;if(!o.consumable.consume(i,"insert"))return;o.consumable.consume(i,"attribute:headingRows:table"),o.consumable.consume(i,"attribute:headingColumns:table");const r=t&&t.asWidget,s=o.writer.createContainerElement("figure",{class:"table"}),a=o.writer.createContainerElement("table");let c;var l,d;o.writer.insert(o.writer.createPositionAt(s,0),a),r&&(l=s,(d=o.writer).setCustomProperty("table",!0,l),c=pm(l,d,{hasSelectionHandle:!0}));const u=new w_(i),h={headingRows:i.getAttribute("headingRows")||0,headingColumns:i.getAttribute("headingColumns")||0},p=new Map;for(const e of u){const{row:n,cell:r}=e,s=i.getChild(n),c=p.get(n)||E_(a,s,n,h,o);p.set(n,c),o.consumable.consume(r,"insert");x_(e,h,o.writer.createPositionAt(c,"end"),o,t)}for(const t of i.getChildren()){const e=t.index;t.is("element","tableRow")&&!p.has(e)&&p.set(e,E_(a,t,e,h,o))}const m=o.mapper.toViewPosition(n.range.start);o.mapper.bindElements(i,r?c:s),o.writer.insert(m,r?c:s)}))}function A_(t,e){const{writer:n}=e;if(t.parent.is("element","tableCell"))return v_(t)?n.createContainerElement("span",{class:"ck-table-bogus-paragraph"}):n.createContainerElement("p")}function v_(t){return 1===t.parent.childCount&&!T_(t)}function y_(t,e,n){const{cell:o}=t,i=D_(t,e),r=n.mapper.toViewElement(o);r&&r.name!==i&&function(t,e,n){const o=n.writer,i=n.mapper.toViewElement(t),r=km(o.createEditableElement(e,i.getAttributes()),o);o.insert(o.createPositionAfter(i),r),o.move(o.createRangeIn(i),o.createPositionAt(r,0)),o.remove(o.createRangeOn(i)),n.mapper.unbindViewElement(i),n.mapper.bindElements(t,r)}(o,i,n)}function x_(t,e,n,o,i){const r=i&&i.asWidget,s=D_(t,e),a=r?km(o.writer.createEditableElement(s),o.writer):o.writer.createContainerElement(s),c=t.cell,l=c.getChild(0),d=1===c.childCount&&"paragraph"===l.name;if(o.writer.insert(n,a),o.mapper.bindElements(c,a),!r&&d&&!T_(l)){const t=c.getChild(0);o.consumable.consume(t,"insert"),o.mapper.bindElements(t,a)}}function E_(t,e,n,o,i){i.consumable.consume(e,"insert");const r=e.isEmpty?i.writer.createEmptyElement("tr"):i.writer.createContainerElement("tr");i.mapper.bindElements(e,r);const s=o.headingRows,a=function(t,e,n){const o=S_(t,e);return o||function(t,e,n){const o=n.writer.createContainerElement(t),i=n.writer.createPositionAt(e,"tbody"==t?"end":0);return n.writer.insert(i,o),o}(t,e,n)}(function(t,e){return t0&&n>=s?n-s:n,l=i.writer.createPositionAt(a,c);return i.writer.insert(l,r),r}function D_(t,e){const{row:n,column:o}=t,{headingColumns:i,headingRows:r}=e;if(r&&r>n)return"th";return i&&i>o?"th":"td"}function S_(t,e){for(const n of e.getChildren())if(n.name==t)return n}function B_(t,e,n){const o=S_(t,e);o&&0===o.childCount&&n.writer.remove(n.writer.createRangeOn(o))}function T_(t){return!![...t.getAttributeKeys()].length}class P_ extends ge{refresh(){const t=this.editor.model,e=t.document.selection,n=t.schema;this.isEnabled=function(t,e){const n=t.getFirstPosition().parent,o=n===n.root?n:n.parent;return e.checkChild(o,"table")}(e,n)}execute(t={}){const e=this.editor.model,n=e.document.selection,o=this.editor.plugins.get("TableUtils"),i=this.editor.config.get("table"),r=wm(n,e),s=i.defaultHeadings.rows,a=i.defaultHeadings.columns;void 0===t.headingRows&&s&&(t.headingRows=s),void 0===t.headingColumns&&a&&(t.headingColumns=a),e.change((n=>{const i=o.createTable(n,t);e.insertContent(i,r),n.setSelection(n.createPositionAt(i.getNodeByPath([0,0,0]),0))}))}}function I_(t){const e=[];for(const n of M_(t.getRanges())){const t=n.getContainedElement();t&&t.is("element","tableCell")&&e.push(t)}return e}function R_(t){const e=[];for(const n of t.getRanges()){const t=n.start.findAncestor("tableCell");t&&e.push(t)}return e}function z_(t){const e=I_(t);return e.length?e:R_(t)}function F_(t){const e=t.map((t=>t.parent.index));return V_(e)}function N_(t){const e=t[0].findAncestor("table");return V_([...new w_(e)].filter((e=>t.includes(e.cell))).map((t=>t.column)))}function O_(t,e){if(t.length<2||!function(t){const e=t[0].findAncestor("table"),n=F_(t),o=parseInt(e.getAttribute("headingRows")||0);if(!H_(n,o))return!1;const i=parseInt(e.getAttribute("headingColumns")||0);return H_(N_(t),i)}(t))return!1;const n=new Set,o=new Set;let i=0;for(const r of t){const{row:t,column:s}=e.getCellLocation(r),a=parseInt(r.getAttribute("rowspan")||1),c=parseInt(r.getAttribute("colspan")||1);n.add(t),o.add(s),a>1&&n.add(t+a-1),c>1&&o.add(s+c-1),i+=a*c}const r=function(t,e){const n=Array.from(t.values()),o=Array.from(e.values()),i=Math.max(...n),r=Math.min(...n),s=Math.max(...o),a=Math.min(...o);return(i-r+1)*(s-a+1)}(n,o);return r==i}function M_(t){return Array.from(t).sort(L_)}function V_(t){const e=t.sort(((t,e)=>t-e));return{first:e[0],last:e[e.length-1]}}function L_(t,e){const n=t.start,o=e.start;return n.isBefore(o)?-1:1}function H_({first:t,last:e},n){return t0){p_("headingRows",r-n,t,i,0)}const s=parseInt(e.getAttribute("headingColumns")||0);if(s>0){p_("headingColumns",s-o,t,i,0)}}(a,t,o,i,n),a}function $_(t,e,n=0){const o=[],i=new w_(t,{startRow:n,endRow:e-1});for(const t of i){const{row:n,cellHeight:i}=t,r=n+i-1;n1&&(a.rowspan=c);const l=parseInt(t.getAttribute("colspan")||1);l>1&&(a.colspan=l);const d=r+s,u=[...new w_(i,{startRow:r,endRow:d,includeAllSlots:!0})];let h,p=null;for(const e of u){const{row:o,column:i,cell:r}=e;r===t&&void 0===h&&(h=i),void 0!==h&&h===i&&o===d&&(p=m_(n,e.getPositionBefore(),a))}return p_("rowspan",s,t,n),p}function K_(t,e){const n=[],o=new w_(t);for(const t of o){const{column:o,cellWidth:i}=t,r=o+i-1;o1&&(r.colspan=s);const a=parseInt(t.getAttribute("rowspan")||1);a>1&&(r.rowspan=a);const c=m_(o,o.createPositionAfter(t),r);return p_("colspan",i,t,o),c}function J_(t,e,n,o,i,r){const s=parseInt(t.getAttribute("colspan")||1),a=parseInt(t.getAttribute("rowspan")||1);if(n+s-1>i){p_("colspan",i-n+1,t,r,1)}if(e+a-1>o){p_("rowspan",o-e+1,t,r,1)}}function Y_(t,e){const n=e.getColumns(t),o=new Array(n).fill(0);for(const{column:e}of new w_(t))o[e]++;const i=o.reduce(((t,e,n)=>e?t:[...t,n]),[]);if(i.length>0){const n=i[i.length-1];return e.removeColumns(t,{at:n}),!0}return!1}function Q_(t,e){const n=[],o=e.getRows(t);for(let e=0;e0){const o=n[n.length-1];return e.removeRows(t,{at:o}),!0}return!1}function X_(t,e){Y_(t,e)||Q_(t,e)}function tC(t,e){const n=Array.from(new w_(t,{startColumn:e.firstColumn,endColumn:e.lastColumn,row:e.lastRow}));if(n.every((({cellHeight:t})=>1===t)))return e.lastRow;const o=n[0].cellHeight-1;return e.lastRow+o}function eC(t,e){const n=Array.from(new w_(t,{startRow:e.firstRow,endRow:e.lastRow,column:e.lastColumn}));if(n.every((({cellWidth:t})=>1===t)))return e.lastColumn;const o=n[0].cellWidth-1;return e.lastColumn+o}class nC extends ge{constructor(t,e){super(t),this.direction=e.direction,this.isHorizontal="right"==this.direction||"left"==this.direction}refresh(){const t=this._getMergeableCell();this.value=t,this.isEnabled=!!t}execute(){const t=this.editor.model,e=R_(t.document.selection)[0],n=this.value,o=this.direction;t.change((t=>{const i="right"==o||"down"==o,r=i?e:n,s=i?n:e,a=s.parent;!function(t,e,n){oC(t)||(oC(e)&&n.remove(n.createRangeIn(e)),n.move(n.createRangeIn(t),n.createPositionAt(e,"end")));n.remove(t)}(s,r,t);const c=this.isHorizontal?"colspan":"rowspan",l=parseInt(e.getAttribute(c)||1),d=parseInt(n.getAttribute(c)||1);t.setAttribute(c,l+d,r),t.setSelection(t.createRangeIn(r));const u=this.editor.plugins.get("TableUtils");X_(a.findAncestor("table"),u)}))}_getMergeableCell(){const t=R_(this.editor.model.document.selection)[0];if(!t)return;const e=this.editor.plugins.get("TableUtils"),n=this.isHorizontal?function(t,e,n){const o=t.parent.parent,i="right"==e?t.nextSibling:t.previousSibling,r=(o.getAttribute("headingColumns")||0)>0;if(!i)return;const s="right"==e?t:i,a="right"==e?i:t,{column:c}=n.getCellLocation(s),{column:l}=n.getCellLocation(a),d=parseInt(s.getAttribute("colspan")||1),u=g_(n,s),h=g_(n,a);if(r&&u!=h)return;return c+d===l?i:void 0}(t,this.direction,e):function(t,e,n){const o=t.parent,i=o.parent,r=i.getChildIndex(o);if("down"==e&&r===n.getRows(i)-1||"up"==e&&0===r)return;const s=parseInt(t.getAttribute("rowspan")||1),a=i.getAttribute("headingRows")||0,c="down"==e&&r+s===a,l="up"==e&&r===a;if(a&&(c||l))return;const d=parseInt(t.getAttribute("rowspan")||1),u="down"==e?r+d:r,h=[...new w_(i,{endRow:u})],p=h.find((e=>e.cell===t)).column,m=h.find((({row:t,cellHeight:n,column:o})=>o===p&&("down"==e?t===u:u===t+n)));return m&&m.cell}(t,this.direction,e);if(!n)return;const o=this.isHorizontal?"rowspan":"colspan",i=parseInt(t.getAttribute(o)||1);return parseInt(n.getAttribute(o)||1)===i?n:void 0}}function oC(t){return 1==t.childCount&&t.getChild(0).is("element","paragraph")&&t.getChild(0).isEmpty}class iC extends ge{refresh(){const t=z_(this.editor.model.document.selection),e=t[0];if(e){const n=e.findAncestor("table"),o=this.editor.plugins.get("TableUtils").getRows(n)-1,i=F_(t),r=0===i.first&&i.last===o;this.isEnabled=!r}else this.isEnabled=!1}execute(){const t=this.editor.model,e=this.editor.plugins.get("TableUtils"),n=z_(t.document.selection),o=F_(n),i=n[0],r=i.findAncestor("table"),s=e.getCellLocation(i).column;t.change((t=>{const n=o.last-o.first+1;e.removeRows(r,{at:o.first,rows:n});const i=function(t,e,n,o){const i=t.getChild(Math.min(e,o-1));let r=i.getChild(0),s=0;for(const t of i.getChildren()){if(s>n)return r;r=t,s+=parseInt(t.getAttribute("colspan")||1)}return r}(r,o.first,s,e.getRows(r));t.setSelection(t.createPositionAt(i,0))}))}}class rC extends ge{refresh(){const t=z_(this.editor.model.document.selection),e=t[0];if(e){const n=e.findAncestor("table"),o=this.editor.plugins.get("TableUtils").getColumns(n),{first:i,last:r}=N_(t);this.isEnabled=r-ie.cell===t)).column,last:o.find((t=>t.cell===e)).column},r=function(t,e,n,o){return parseInt(n.getAttribute("colspan")||1)>1?n:e.previousSibling||n.nextSibling?n.nextSibling||e.previousSibling:o.first?t.reverse().find((({column:t})=>tt>o.last)).cell}(o,t,e,i);this.editor.model.change((t=>{const e=i.last-i.first+1;this.editor.plugins.get("TableUtils").removeColumns(n,{at:i.first,columns:e}),t.setSelection(t.createPositionAt(r,0))}))}}class sC extends ge{refresh(){const t=z_(this.editor.model.document.selection),e=t.length>0;this.isEnabled=e,this.value=e&&t.every((t=>this._isInHeading(t,t.parent.parent)))}execute(t={}){if(t.forceValue===this.value)return;const e=this.editor.model,n=z_(e.document.selection),o=n[0].findAncestor("table"),{first:i,last:r}=F_(n),s=this.value?i:r+1,a=o.getAttribute("headingRows")||0;e.change((t=>{if(s){const e=$_(o,s,s>a?a:0);for(const{cell:n}of e)G_(n,s,t)}p_("headingRows",s,o,t,0)}))}_isInHeading(t,e){const n=parseInt(e.getAttribute("headingRows")||0);return!!n&&t.parent.index0;this.isEnabled=n,this.value=n&&t.every((t=>g_(e,t)))}execute(t={}){if(t.forceValue===this.value)return;const e=this.editor.model,n=z_(e.document.selection),o=n[0].findAncestor("table"),{first:i,last:r}=N_(n),s=this.value?i:r+1;e.change((t=>{if(s){const e=K_(o,s);for(const{cell:n,column:o}of e)Z_(n,o,s,t)}p_("headingColumns",s,o,t,0)}))}}class cC extends pe{static get pluginName(){return"TableUtils"}init(){this.decorate("insertColumns"),this.decorate("insertRows")}getCellLocation(t){const e=t.parent,n=e.parent,o=n.getChildIndex(e),i=new w_(n,{row:o});for(const{cell:e,row:n,column:o}of i)if(e===t)return{row:n,column:o}}createTable(t,e){const n=t.createElement("table"),o=parseInt(e.rows)||2,i=parseInt(e.columns)||2;return lC(t,n,0,o,i),e.headingRows&&p_("headingRows",Math.min(e.headingRows,o),n,t,0),e.headingColumns&&p_("headingColumns",Math.min(e.headingColumns,i),n,t,0),n}insertRows(t,e={}){const n=this.editor.model,o=e.at||0,i=e.rows||1,r=void 0!==e.copyStructureFromAbove,a=e.copyStructureFromAbove?o-1:o,c=this.getRows(t),l=this.getColumns(t);if(o>c)throw new s("tableutils-insertrows-insert-out-of-range",this,{options:e});n.change((e=>{const n=t.getAttribute("headingRows")||0;if(n>o&&p_("headingRows",n+i,t,e,0),!r&&(0===o||o===c))return void lC(e,t,o,i,l);const s=r?Math.max(o,a):o,d=new w_(t,{endRow:s}),u=new Array(l).fill(1);for(const{row:t,column:n,cellHeight:s,cellWidth:c,cell:l}of d){const d=t+s-1,h=t<=a&&a<=d;t0&&m_(e,i,o>1?{colspan:o}:null),t+=Math.abs(o)-1}}}))}insertColumns(t,e={}){const n=this.editor.model,o=e.at||0,i=e.columns||1;n.change((e=>{const n=t.getAttribute("headingColumns");oi-1)throw new s("tableutils-removerows-row-index-out-of-range",this,{table:t,options:e});n.change((e=>{const{cellsToMove:n,cellsToTrim:o}=function(t,e,n){const o=new Map,i=[];for(const{row:r,column:s,cellHeight:a,cell:c}of new w_(t,{endRow:n})){const t=r+a-1;if(r>=e&&r<=n&&t>n){const t=a-(n-r+1);o.set(s,{cell:c,rowspan:t})}if(r=e){let o;o=t>=n?n-e+1:t-e+1,i.push({cell:c,rowspan:a-o})}}return{cellsToMove:o,cellsToTrim:i}}(t,r,a);if(n.size){!function(t,e,n,o){const i=[...new w_(t,{includeAllSlots:!0,row:e})],r=t.getChild(e);let s;for(const{column:t,cell:e,isAnchor:a}of i)if(n.has(t)){const{cell:e,rowspan:i}=n.get(t),a=s?o.createPositionAfter(s):o.createPositionAt(r,0);o.move(o.createRangeOn(e),a),p_("rowspan",i,e,o),s=e}else a&&(s=e)}(t,a+1,n,e)}for(let n=a;n>=r;n--)e.remove(t.getChild(n));for(const{rowspan:t,cell:n}of o)p_("rowspan",t,n,e);!function(t,e,n,o){const i=t.getAttribute("headingRows")||0;if(e{!function(t,e,n){const o=t.getAttribute("headingColumns")||0;if(o&&e.first=o;n--)for(const{cell:o,column:i,cellWidth:r}of[...new w_(t)])i<=n&&r>1&&i+r>n?p_("colspan",r-1,o,e):i===n&&e.remove(o);Q_(t,this)||Y_(t,this)}))}splitCellVertically(t,e=2){const n=this.editor.model,o=t.parent.parent,i=parseInt(t.getAttribute("rowspan")||1),r=parseInt(t.getAttribute("colspan")||1);n.change((n=>{if(r>1){const{newCellsSpan:o,updatedSpan:s}=uC(r,e);p_("colspan",s,t,n);const a={};o>1&&(a.colspan=o),i>1&&(a.rowspan=i);dC(r>e?e-1:r-1,n,n.createPositionAfter(t),a)}if(re===t)),l=a.filter((({cell:e,cellWidth:n,column:o})=>e!==t&&o===c||oc));for(const{cell:t,cellWidth:e}of l)n.setAttribute("colspan",e+s,t);const d={};i>1&&(d.rowspan=i),dC(s,n,n.createPositionAfter(t),d);const u=o.getAttribute("headingColumns")||0;u>c&&p_("headingColumns",u+s,o,n)}}))}splitCellHorizontally(t,e=2){const n=this.editor.model,o=t.parent,i=o.parent,r=i.getChildIndex(o),s=parseInt(t.getAttribute("rowspan")||1),a=parseInt(t.getAttribute("colspan")||1);n.change((n=>{if(s>1){const o=[...new w_(i,{startRow:r,endRow:r+s-1,includeAllSlots:!0})],{newCellsSpan:c,updatedSpan:l}=uC(s,e);p_("rowspan",l,t,n);const{column:d}=o.find((({cell:e})=>e===t)),u={};c>1&&(u.rowspan=c),a>1&&(u.colspan=a);for(const t of o){const{column:e,row:o}=t,i=e===d,s=(o+r+l)%c==0;o>=r+l&&i&&s&&dC(1,n,t.getPositionBefore(),u)}}if(sr){const t=i+o;n.setAttribute("rowspan",t,e)}const l={};a>1&&(l.colspan=a),lC(n,i,r+1,o,1,l);const d=i.getAttribute("headingRows")||0;d>r&&p_("headingRows",d+o,i,n)}}))}getColumns(t){return[...t.getChild(0).getChildren()].reduce(((t,e)=>t+parseInt(e.getAttribute("colspan")||1)),0)}getRows(t){return Array.from(t.getChildren()).reduce(((t,e)=>e.is("element","tableRow")?t+1:t),0)}}function lC(t,e,n,o,i,r={}){for(let s=0;s{const o=I_(t.document.selection),i=o.shift(),{mergeWidth:r,mergeHeight:s}=function(t,e,n){let o=0,i=0;for(const t of e){const{row:e,column:r}=n.getCellLocation(t);o=gC(t,r,o,"colspan"),i=gC(t,e,i,"rowspan")}const{row:r,column:s}=n.getCellLocation(t);return{mergeWidth:o-s,mergeHeight:i-r}}(i,o,e);p_("colspan",r,i,n),p_("rowspan",s,i,n);for(const t of o)pC(t,i,n);X_(i.findAncestor("table"),e),n.setSelection(i,"in")}))}}function pC(t,e,n){mC(t)||(mC(e)&&n.remove(n.createRangeIn(e)),n.move(n.createRangeIn(t),n.createPositionAt(e,"end"))),n.remove(t)}function mC(t){return 1==t.childCount&&t.getChild(0).is("element","paragraph")&&t.getChild(0).isEmpty}function gC(t,e,n,o){const i=parseInt(t.getAttribute(o)||1);return Math.max(n,e+i)}class fC extends ge{constructor(t){super(t),this.affectsData=!1}refresh(){const t=z_(this.editor.model.document.selection);this.isEnabled=t.length>0}execute(){const t=this.editor.model,e=z_(t.document.selection),n=F_(e),o=e[0].findAncestor("table"),i=[];for(let e=n.first;e<=n.last;e++)for(const n of o.getChild(e).getChildren())i.push(t.createRangeOn(n));t.change((t=>{t.setSelection(i)}))}}class bC extends ge{constructor(t){super(t),this.affectsData=!1}refresh(){const t=z_(this.editor.model.document.selection);this.isEnabled=t.length>0}execute(){const t=this.editor.model,e=z_(t.document.selection),n=e[0],o=e.pop(),i=n.findAncestor("table"),r=this.editor.plugins.get("TableUtils"),s=r.getCellLocation(n),a=r.getCellLocation(o),c=Math.min(s.column,a.column),l=Math.max(s.column,a.column),d=[];for(const e of new w_(i,{startColumn:c,endColumn:l}))d.push(t.createRangeOn(e.cell));t.change((t=>{t.setSelection(d)}))}}function kC(t){t.document.registerPostFixer((e=>function(t,e){const n=e.document.differ.getChanges();let o=!1;const i=new Set;for(const e of n){let n;"table"==e.name&&"insert"==e.type&&(n=e.position.nodeAfter),"tableRow"!=e.name&&"tableCell"!=e.name||(n=e.position.findAncestor("table")),CC(e)&&(n=e.range.start.findAncestor("table")),n&&!i.has(n)&&(o=wC(n,t)||o,o=_C(n,t)||o,i.add(n))}return o}(e,t)))}function wC(t,e){let n=!1;const o=function(t){const e=parseInt(t.getAttribute("headingRows")||0),n=Array.from(t.getChildren()).reduce(((t,e)=>e.is("element","tableRow")?t+1:t),0),o=[];for(const{row:i,cell:r,cellHeight:s}of new w_(t)){if(s<2)continue;const t=it){const e=t-i;o.push({cell:r,rowspan:e})}}return o}(t);if(o.length){n=!0;for(const t of o)p_("rowspan",t.rowspan,t.cell,e,1)}return n}function _C(t,e){let n=!1;const o=function(t){const e=new Array(t.childCount).fill(0);for(const{rowIndex:n}of new w_(t,{includeAllSlots:!0}))e[n]++;return e}(t),i=[];for(const[e,n]of o.entries())!n&&t.getChild(e).is("element","tableRow")&&i.push(e);if(i.length){n=!0;for(const n of i.reverse())e.remove(t.getChild(n)),o.splice(n,1)}const r=o.filter(((e,n)=>t.getChild(n).is("element","tableRow"))),s=r[0];if(!r.every((t=>t===s))){const o=r.reduce(((t,e)=>e>t?e:t),0);for(const[i,s]of r.entries()){const r=o-s;if(r){for(let n=0;nfunction(t,e){const n=e.document.differ.getChanges();let o=!1;for(const e of n)"insert"==e.type&&"table"==e.name&&(o=vC(e.position.nodeAfter,t)||o),"insert"==e.type&&"tableRow"==e.name&&(o=yC(e.position.nodeAfter,t)||o),"insert"==e.type&&"tableCell"==e.name&&(o=xC(e.position.nodeAfter,t)||o),EC(e)&&(o=xC(e.position.parent,t)||o);return o}(e,t)))}function vC(t,e){let n=!1;for(const o of t.getChildren())o.is("element","tableRow")&&(n=yC(o,e)||n);return n}function yC(t,e){let n=!1;for(const o of t.getChildren())n=xC(o,e)||n;return n}function xC(t,e){if(0==t.childCount)return e.insertElement("paragraph",t),!0;const n=Array.from(t.getChildren()).filter((t=>t.is("$text")));for(const t of n)e.wrap(e.createRangeOn(t),"paragraph");return!!n.length}function EC(t){return!(!t.position||!t.position.parent.is("element","tableCell"))&&("insert"==t.type&&"$text"==t.name||"remove"==t.type)}function DC(t,e){t.document.registerPostFixer((()=>function(t,e){const n=new Set;for(const e of t.getChanges()){const t="attribute"==e.type?e.range.start.parent:e.position.parent;t.is("element","tableCell")&&n.add(t)}for(const o of n.values())for(const n of[...o.getChildren()].filter((t=>SC(t,e))))t.refreshItem(n);return!1}(t.document.differ,e)))}function SC(t,e){if(!t.is("element","paragraph"))return!1;const n=e.toViewElement(t);return!!n&&v_(t)!==n.is("element","span")}function BC(t){t.document.registerPostFixer((()=>function(t){const e=t.document.differ,n=new Set;for(const t of e.getChanges())if("attribute"===t.type){const e=t.range.start.nodeAfter;e&&e.is("element","table")&&"headingRows"===t.attributeKey&&n.add(e)}else if("insert"===t.type||"remove"===t.type)if("tableRow"===t.name){const e=t.position.findAncestor("table"),o=e.getAttribute("headingRows")||0;t.position.offset{t.on("element:figure",((t,e,n)=>{if(!n.consumable.test(e.viewItem,{name:!0,classes:"table"}))return;const o=function(t){for(const e of t.getChildren())if(e.is("element","table"))return e}(e.viewItem);if(!o||!n.consumable.test(o,{name:!0}))return;n.consumable.consume(e.viewItem,{name:!0,classes:"table"});const i=Ta(n.convertItem(o,e.modelCursor).modelRange.getItems());i?(n.convertChildren(e.viewItem,n.writer.createPositionAt(i,"end")),n.updateConversionResult(i,e)):n.consumable.revert(e.viewItem,{name:!0,classes:"table"})}))})),o.for("upcast").add(f_()),o.for("editingDowncast").add(C_({asWidget:!0})),o.for("dataDowncast").add(C_()),o.for("upcast").elementToElement({model:"tableRow",view:"tr"}),o.for("upcast").add((t=>{t.on("element:tr",((t,e)=>{e.viewItem.isEmpty&&0==e.modelCursor.index&&t.stop()}),{priority:"high"})})),o.for("editingDowncast").add((t=>t.on("insert:tableRow",((t,e,n)=>{const o=e.item;if(!n.consumable.consume(o,"insert"))return;const i=o.parent,r=function(t){for(const e of t.getChildren())if("table"===e.name)return e}(n.mapper.toViewElement(i)),s=i.getChildIndex(o),a=new w_(i,{row:s}),c={headingRows:i.getAttribute("headingRows")||0,headingColumns:i.getAttribute("headingColumns")||0},l=new Map;for(const t of a){const e=l.get(s)||E_(r,o,s,c,n);l.set(s,e),n.consumable.consume(t.cell,"insert"),x_(t,c,n.writer.createPositionAt(e,"end"),n,{asWidget:!0})}})))),o.for("editingDowncast").add((t=>t.on("remove:tableRow",((t,e,n)=>{t.stop();const o=n.writer,i=n.mapper,r=i.toViewPosition(e.position).getLastMatchingPosition((t=>!t.item.is("element","tr"))).nodeAfter,s=r.parent.parent,a=o.createRangeOn(r),c=o.remove(a);for(const t of o.createRangeIn(c).getItems())i.unbindViewElement(t);B_("thead",s,n),B_("tbody",s,n)}),{priority:"higher"}))),o.for("upcast").elementToElement({model:"tableCell",view:"td"}),o.for("upcast").elementToElement({model:"tableCell",view:"th"}),o.for("upcast").add(b_("td")),o.for("upcast").add(b_("th")),o.for("editingDowncast").add((t=>t.on("insert:tableCell",((t,e,n)=>{const o=e.item;if(!n.consumable.consume(o,"insert"))return;const i=o.parent,r=i.parent,s=r.getChildIndex(i),a=new w_(r,{row:s}),c={headingRows:r.getAttribute("headingRows")||0,headingColumns:r.getAttribute("headingColumns")||0};for(const t of a)if(t.cell===o){const e=n.mapper.toViewElement(i);return void x_(t,c,n.writer.createPositionAt(e,i.getChildIndex(o)),n,{asWidget:!0})}})))),o.for("editingDowncast").elementToElement({model:"paragraph",view:A_,converterPriority:"high"}),o.for("downcast").attributeToAttribute({model:"colspan",view:"colspan"}),o.for("upcast").attributeToAttribute({model:{key:"colspan",value:RC("colspan")},view:"colspan"}),o.for("downcast").attributeToAttribute({model:"rowspan",view:"rowspan"}),o.for("upcast").attributeToAttribute({model:{key:"rowspan",value:RC("rowspan")},view:"rowspan"}),o.for("editingDowncast").add((t=>t.on("attribute:headingColumns:table",((t,e,n)=>{const o=e.item;if(!n.consumable.consume(e.item,t.name))return;const i={headingRows:o.getAttribute("headingRows")||0,headingColumns:o.getAttribute("headingColumns")||0},r=e.attributeOldValue,s=e.attributeNewValue,a=(r>s?r:s)-1;for(const t of new w_(o,{endColumn:a}))y_(t,i,n)})))),t.data.mapper.on("modelToViewPosition",((t,e)=>{const n=e.modelPosition.parent,o=e.modelPosition.nodeBefore;if(!n.is("element","tableCell"))return;if(!o||!o.is("element","paragraph"))return;const i=e.mapper.toViewElement(o),r=e.mapper.toViewElement(n);i===r&&(e.viewPosition=e.mapper.findPositionIn(r,o.maxOffset))})),t.config.define("table.defaultHeadings.rows",0),t.config.define("table.defaultHeadings.columns",0),t.commands.add("insertTable",new P_(t)),t.commands.add("insertTableRowAbove",new q_(t,{order:"above"})),t.commands.add("insertTableRowBelow",new q_(t,{order:"below"})),t.commands.add("insertTableColumnLeft",new W_(t,{order:"left"})),t.commands.add("insertTableColumnRight",new W_(t,{order:"right"})),t.commands.add("removeTableRow",new iC(t)),t.commands.add("removeTableColumn",new rC(t)),t.commands.add("splitTableCellVertically",new j_(t,{direction:"vertically"})),t.commands.add("splitTableCellHorizontally",new j_(t,{direction:"horizontally"})),t.commands.add("mergeTableCells",new hC(t)),t.commands.add("mergeTableCellRight",new nC(t,{direction:"right"})),t.commands.add("mergeTableCellLeft",new nC(t,{direction:"left"})),t.commands.add("mergeTableCellDown",new nC(t,{direction:"down"})),t.commands.add("mergeTableCellUp",new nC(t,{direction:"up"})),t.commands.add("setTableColumnHeader",new aC(t)),t.commands.add("setTableRowHeader",new sC(t)),t.commands.add("selectTableRow",new fC(t)),t.commands.add("selectTableColumn",new bC(t)),BC(e),kC(e),DC(e,t.editing.mapper),AC(e)}static get requires(){return[cC]}}function RC(t){return e=>{const n=parseInt(e.getAttribute(t));return Number.isNaN(n)||n<=0?null:n}}var zC=n(8085),FC={attributes:{"data-cke":!0}};FC.setAttributes=is(),FC.insert=ns().bind(null,"head"),FC.domAPI=ts(),FC.insertStyleElement=ss();Qr()(zC.Z,FC);zC.Z&&zC.Z.locals&&zC.Z.locals;class NC extends Od{constructor(t){super(t);const e=this.bindTemplate;this.items=this._createGridCollection(),this.set("rows",0),this.set("columns",0),this.bind("label").to(this,"columns",this,"rows",((t,e)=>`${e} × ${t}`)),this.setTemplate({tag:"div",attributes:{class:["ck"]},children:[{tag:"div",attributes:{class:["ck-insert-table-dropdown__grid"]},on:{"mouseover@.ck-insert-table-dropdown-grid-box":e.to("boxover")},children:this.items},{tag:"div",attributes:{class:["ck-insert-table-dropdown__label"]},children:[{text:e.to("label")}]}],on:{mousedown:e.to((t=>{t.preventDefault()})),click:e.to((()=>{this.fire("execute")}))}}),this.on("boxover",((t,e)=>{const{row:n,column:o}=e.target.dataset;this.set({rows:parseInt(n),columns:parseInt(o)})})),this.on("change:columns",(()=>{this._highlightGridBoxes()})),this.on("change:rows",(()=>{this._highlightGridBoxes()}))}focus(){}focusLast(){}_highlightGridBoxes(){const t=this.rows,e=this.columns;this.items.map(((n,o)=>{const i=Math.floor(o/10){const o=t.commands.get("insertTable"),i=nh(n);let r;return i.bind("isEnabled").to(o),i.buttonView.set({icon:'',label:e("Insert table"),tooltip:!0}),i.on("change:isOpen",(()=>{r||(r=new NC(n),i.panelView.children.add(r),r.delegate("execute").to(i),i.buttonView.on("open",(()=>{r.rows=0,r.columns=0})),i.on("execute",(()=>{t.execute("insertTable",{rows:r.rows,columns:r.columns}),t.editing.view.focus()})))})),i})),t.ui.componentFactory.add("tableColumn",(t=>{const o=[{type:"switchbutton",model:{commandName:"setTableColumnHeader",label:e("Header column"),bindIsOn:!0}},{type:"separator"},{type:"button",model:{commandName:n?"insertTableColumnLeft":"insertTableColumnRight",label:e("Insert column left")}},{type:"button",model:{commandName:n?"insertTableColumnRight":"insertTableColumnLeft",label:e("Insert column right")}},{type:"button",model:{commandName:"removeTableColumn",label:e("Delete column")}},{type:"button",model:{commandName:"selectTableColumn",label:e("Select column")}}];return this._prepareDropdown(e("Column"),'',o,t)})),t.ui.componentFactory.add("tableRow",(t=>{const n=[{type:"switchbutton",model:{commandName:"setTableRowHeader",label:e("Header row"),bindIsOn:!0}},{type:"separator"},{type:"button",model:{commandName:"insertTableRowAbove",label:e("Insert row above")}},{type:"button",model:{commandName:"insertTableRowBelow",label:e("Insert row below")}},{type:"button",model:{commandName:"removeTableRow",label:e("Delete row")}},{type:"button",model:{commandName:"selectTableRow",label:e("Select row")}}];return this._prepareDropdown(e("Row"),'',n,t)})),t.ui.componentFactory.add("mergeTableCells",(t=>{const o=[{type:"button",model:{commandName:"mergeTableCellUp",label:e("Merge cell up")}},{type:"button",model:{commandName:n?"mergeTableCellRight":"mergeTableCellLeft",label:e("Merge cell right")}},{type:"button",model:{commandName:"mergeTableCellDown",label:e("Merge cell down")}},{type:"button",model:{commandName:n?"mergeTableCellLeft":"mergeTableCellRight",label:e("Merge cell left")}},{type:"separator"},{type:"button",model:{commandName:"splitTableCellVertically",label:e("Split cell vertically")}},{type:"button",model:{commandName:"splitTableCellHorizontally",label:e("Split cell horizontally")}}];return this._prepareMergeSplitButtonDropdown(e("Merge cells"),'',o,t)}))}_prepareDropdown(t,e,n,o){const i=this.editor,r=nh(o),s=this._fillDropdownWithListOptions(r,n);return r.buttonView.set({label:t,icon:e,tooltip:!0}),r.bind("isEnabled").toMany(s,"isEnabled",((...t)=>t.some((t=>t)))),this.listenTo(r,"execute",(t=>{i.execute(t.source.commandName),i.editing.view.focus()})),r}_prepareMergeSplitButtonDropdown(t,e,n,o){const i=this.editor,r=nh(o,Pu),s="mergeTableCells",a=i.commands.get(s),c=this._fillDropdownWithListOptions(r,n);return r.buttonView.set({label:t,icon:e,tooltip:!0,isEnabled:!0}),r.bind("isEnabled").toMany([a,...c],"isEnabled",((...t)=>t.some((t=>t)))),this.listenTo(r.buttonView,"execute",(()=>{i.execute(s),i.editing.view.focus()})),this.listenTo(r,"execute",(t=>{i.execute(t.source.commandName),i.editing.view.focus()})),r}_fillDropdownWithListOptions(t,e){const n=this.editor,o=[],i=new So;for(const t of e)VC(t,n,o,i);return ih(t,i,n.ui.componentFactory),o}}function VC(t,e,n,o){const i=t.model=new Eh(t.model),{commandName:r,bindIsOn:s}=t.model;if("button"===t.type||"switchbutton"===t.type){const t=e.commands.get(r);n.push(t),i.set({commandName:r}),i.bind("isEnabled").to(t),s&&i.bind("isOn").to(t,"value")}i.set({withText:!0}),o.add(t)}var LC=n(5593),HC={attributes:{"data-cke":!0}};HC.setAttributes=is(),HC.insert=ns().bind(null,"head"),HC.domAPI=ts(),HC.insertStyleElement=ss();Qr()(LC.Z,HC);LC.Z&&LC.Z.locals&&LC.Z.locals;class qC extends pe{static get pluginName(){return"TableSelection"}static get requires(){return[cC]}init(){const t=this.editor.model;this.listenTo(t,"deleteContent",((t,e)=>this._handleDeleteContent(t,e)),{priority:"high"}),this._defineSelectionConverter(),this._enablePluginDisabling()}getSelectedTableCells(){const t=I_(this.editor.model.document.selection);return 0==t.length?null:t}getSelectionAsFragment(){const t=this.getSelectedTableCells();return t?this.editor.model.change((e=>{const n=e.createDocumentFragment(),o=this.editor.plugins.get("TableUtils"),{first:i,last:r}=N_(t),{first:s,last:a}=F_(t),c=t[0].findAncestor("table");let l=a,d=r;if(O_(t,o)){const t={firstColumn:i,lastColumn:r,firstRow:s,lastRow:a};l=tC(c,t),d=eC(c,t)}const u=U_(c,{startRow:s,startColumn:i,endRow:l,endColumn:d},e);return e.insert(u,n,0),n})):null}setCellSelection(t,e){const n=this._getCellsToSelect(t,e);this.editor.model.change((t=>{t.setSelection(n.cells.map((e=>t.createRangeOn(e))),{backward:n.backward})}))}getFocusCell(){const t=[...this.editor.model.document.selection.getRanges()].pop().getContainedElement();return t&&t.is("element","tableCell")?t:null}getAnchorCell(){const t=Ta(this.editor.model.document.selection.getRanges()).getContainedElement();return t&&t.is("element","tableCell")?t:null}_defineSelectionConverter(){const t=this.editor,e=new Set;t.conversion.for("editingDowncast").add((t=>t.on("selection",((t,n,o)=>{const i=o.writer;!function(t){for(const n of e)t.removeClass("ck-editor__editable_selected",n);e.clear()}(i);const r=this.getSelectedTableCells();if(!r)return;for(const t of r){const n=o.mapper.toViewElement(t);i.addClass("ck-editor__editable_selected",n),e.add(n)}const s=o.mapper.toViewElement(r[r.length-1]);i.setSelection(s,0)}),{priority:"lowest"})))}_enablePluginDisabling(){const t=this.editor;this.on("change:isEnabled",(()=>{if(!this.isEnabled){const e=this.getSelectedTableCells();if(!e)return;t.model.change((n=>{const o=n.createPositionAt(e[0],0),i=t.model.schema.getNearestSelectionRange(o);n.setSelection(i)}))}}))}_handleDeleteContent(t,e){const[n,o]=e,i=this.editor.model,r=!o||"backward"==o.direction,s=I_(n);s.length&&(t.stop(),i.change((t=>{const e=s[r?s.length-1:0];i.change((t=>{for(const e of s)i.deleteContent(t.createSelection(e,"in"))}));const o=i.schema.getNearestSelectionRange(t.createPositionAt(e,0));n.is("documentSelection")?t.setSelection(o):n.setTo(o)})))}_getCellsToSelect(t,e){const n=this.editor.plugins.get("TableUtils"),o=n.getCellLocation(t),i=n.getCellLocation(e),r=Math.min(o.row,i.row),s=Math.max(o.row,i.row),a=Math.min(o.column,i.column),c=Math.max(o.column,i.column),l=new Array(s-r+1).fill(null).map((()=>[])),d={startRow:r,endRow:s,startColumn:a,endColumn:c};for(const{row:e,cell:n}of new w_(t.findAncestor("table"),d))l[e-r].push(n);const u=i.rowt.reverse())),{cells:l.flat(),backward:u||h}}}class WC extends pe{static get pluginName(){return"TableClipboard"}static get requires(){return[qC,cC]}init(){const t=this.editor,e=t.editing.view.document;this.listenTo(e,"copy",((t,e)=>this._onCopyCut(t,e))),this.listenTo(e,"cut",((t,e)=>this._onCopyCut(t,e))),this.listenTo(t.model,"insertContent",((t,e)=>this._onInsertContent(t,...e)),{priority:"high"}),this.decorate("_replaceTableSlotCell")}_onCopyCut(t,e){const n=this.editor.plugins.get(qC);if(!n.getSelectedTableCells())return;if("cut"==t.name&&this.editor.isReadOnly)return;e.preventDefault(),t.stop();const o=this.editor.data,i=this.editor.editing.view.document,r=o.toView(n.getSelectionAsFragment());i.fire("clipboardOutput",{dataTransfer:e.dataTransfer,content:r,method:t.name})}_onInsertContent(t,e,n){if(n&&!n.is("documentSelection"))return;const o=this.editor.model,i=this.editor.plugins.get(cC);let r=function(t,e){if(!t.is("documentFragment")&&!t.is("element"))return null;if(t.is("element","table"))return t;if(1==t.childCount&&t.getChild(0).is("element","table"))return t.getChild(0);const n=e.createRangeIn(t);for(const t of n.getItems())if(t.is("element","table")){const o=e.createRange(n.start,e.createPositionBefore(t));if(e.hasContent(o,{ignoreWhitespaces:!0}))return null;const i=e.createRange(e.createPositionAfter(t),n.end);return e.hasContent(i,{ignoreWhitespaces:!0})?null:t}return null}(e,o);if(!r)return;const s=z_(o.document.selection);s.length?(t.stop(),o.change((t=>{const e={width:i.getColumns(r),height:i.getRows(r)},n=function(t,e,n,o){const i=t[0].findAncestor("table"),r=N_(t),s=F_(t),a={firstColumn:r.first,lastColumn:r.last,firstRow:s.first,lastRow:s.last},c=1===t.length;c&&(a.lastRow+=e.height-1,a.lastColumn+=e.width-1,function(t,e,n,o){const i=o.getColumns(t),r=o.getRows(t);n>i&&o.insertColumns(t,{at:i,columns:n-i});e>r&&o.insertRows(t,{at:r,rows:e-r})}(i,a.lastRow+1,a.lastColumn+1,o));c||!O_(t,o)?function(t,e,n){const{firstRow:o,lastRow:i,firstColumn:r,lastColumn:s}=e,a={first:o,last:i},c={first:r,last:s};UC(t,r,a,n),UC(t,s+1,a,n),jC(t,o,c,n),jC(t,i+1,c,n,o)}(i,a,n):(a.lastRow=tC(i,a),a.lastColumn=eC(i,a));return a}(s,e,t,i),o=n.lastRow-n.firstRow+1,a=n.lastColumn-n.firstColumn+1,c={startRow:0,startColumn:0,endRow:Math.min(o,e.height)-1,endColumn:Math.min(a,e.width)-1};r=U_(r,c,t);const l=s[0].findAncestor("table"),d=this._replaceSelectedCellsWithPasted(r,e,l,n,t);if(this.editor.plugins.get("TableSelection").isEnabled){const e=M_(d.map((e=>t.createRangeOn(e))));t.setSelection(e)}else t.setSelection(d[0],0)}))):X_(r,i)}_replaceSelectedCellsWithPasted(t,e,n,o,i){const{width:r,height:s}=e,a=function(t,e,n){const o=new Array(n).fill(null).map((()=>new Array(e).fill(null)));for(const{column:e,row:n,cell:i}of new w_(t))o[n][e]=i;return o}(t,r,s),c=[...new w_(n,{startRow:o.firstRow,endRow:o.lastRow,startColumn:o.firstColumn,endColumn:o.lastColumn,includeAllSlots:!0})],l=[];let d;for(const t of c){const{row:e,column:n}=t;n===o.firstColumn&&(d=t.getPositionBefore());const c=e-o.firstRow,u=n-o.firstColumn,h=a[c%s][u%r],p=h?i.cloneElement(h):null,m=this._replaceTableSlotCell(t,p,d,i);m&&(J_(m,e,n,o.lastRow,o.lastColumn,i),l.push(m),d=i.createPositionAfter(m))}const u=parseInt(n.getAttribute("headingRows")||0),h=parseInt(n.getAttribute("headingColumns")||0),p=o.firstRow$C(t,e,n))).map((({cell:t})=>G_(t,e,o)))}function UC(t,e,n,o){if(e<1)return;return K_(t,e).filter((({row:t,cellHeight:e})=>$C(t,e,n))).map((({cell:t,column:n})=>Z_(t,n,e,o)))}function $C(t,e,n){const o=t+e-1,{first:i,last:r}=n;return t>=i&&t<=r||t=i}class GC extends pe{static get pluginName(){return"TableKeyboard"}static get requires(){return[qC]}init(){const t=this.editor.editing.view.document;this.editor.keystrokes.set("Tab",((...t)=>this._handleTabOnSelectedTable(...t)),{priority:"low"}),this.editor.keystrokes.set("Tab",this._getTabHandler(!0),{priority:"low"}),this.editor.keystrokes.set("Shift+Tab",this._getTabHandler(!1),{priority:"low"}),this.listenTo(t,"arrowKey",((...t)=>this._onArrowKey(...t)),{context:"table"})}_handleTabOnSelectedTable(t,e){const n=this.editor,o=n.model.document.selection.getSelectedElement();o&&o.is("element","table")&&(e(),n.model.change((t=>{t.setSelection(t.createRangeIn(o.getChild(0).getChild(0)))})))}_getTabHandler(t){const e=this.editor;return(n,o)=>{let i=R_(e.model.document.selection)[0];if(i||(i=this.editor.plugins.get("TableSelection").getFocusCell()),!i)return;o();const r=i.parent,s=r.parent,a=s.getChildIndex(r),c=r.getChildIndex(i),l=0===c;if(!t&&l&&0===a)return void e.model.change((t=>{t.setSelection(t.createRangeOn(s))}));const d=this.editor.plugins.get("TableUtils"),u=c===r.childCount-1,h=a===d.getRows(s)-1;if(t&&h&&u&&(e.execute("insertTableRowBelow"),a===d.getRows(s)-1))return void e.model.change((t=>{t.setSelection(t.createRangeOn(s))}));let p;if(t&&u){const t=s.getChild(a+1);p=t.getChild(0)}else if(!t&&l){const t=s.getChild(a-1);p=t.getChild(t.childCount-1)}else p=r.getChild(c+(t?1:-1));e.model.change((t=>{t.setSelection(t.createRangeIn(p))}))}}_onArrowKey(t,e){const n=this.editor,o=fr(e.keyCode,n.locale.contentLanguageDirection);this._handleArrowKeys(o,e.shiftKey)&&(e.preventDefault(),e.stopPropagation(),t.stop())}_handleArrowKeys(t,e){const n=this.editor.model,o=n.document.selection,i=["right","down"].includes(t),r=I_(o);if(r.length){let n;return n=e?this.editor.plugins.get("TableSelection").getFocusCell():i?r[r.length-1]:r[0],this._navigateFromCellInDirection(n,t,e),!0}const s=o.focus.findAncestor("tableCell");if(!s)return!1;if(!o.isCollapsed)if(e){if(o.isBackward==i&&!o.containsEntireContent(s))return!1}else{const t=o.getSelectedElement();if(!t||!n.schema.isObject(t))return!1}return!!this._isSelectionAtCellEdge(o,s,i)&&(this._navigateFromCellInDirection(s,t,e),!0)}_isSelectionAtCellEdge(t,e,n){const o=this.editor.model,i=this.editor.model.schema,r=n?t.getLastPosition():t.getFirstPosition();if(!i.getLimitElement(r).is("element","tableCell")){return o.createPositionAt(e,n?"end":0).isTouching(r)}const s=o.createSelection(r);return o.modifySelection(s,{direction:n?"forward":"backward"}),r.isEqual(s.focus)}_navigateFromCellInDirection(t,e,n=!1){const o=this.editor.model,i=t.findAncestor("table"),r=[...new w_(i,{includeAllSlots:!0})],{row:s,column:a}=r[r.length-1],c=r.find((({cell:e})=>e==t));let{row:l,column:d}=c;switch(e){case"left":d--;break;case"up":l--;break;case"right":d+=c.cellWidth;break;case"down":l+=c.cellHeight}if(l<0||l>s||d<0&&l<=0||d>a&&l>=s)return void o.change((t=>{t.setSelection(t.createRangeOn(i))}));d<0?(d=n?0:a,l--):d>a&&(d=n?a:0,l++);const u=r.find((t=>t.row==l&&t.column==d)).cell,h=["right","down"].includes(e),p=this.editor.plugins.get("TableSelection");if(n&&p.isEnabled){const e=p.getAnchorCell()||t;p.setCellSelection(e,u)}else{const t=o.createPositionAt(u,h?0:"end");o.change((e=>{e.setSelection(t)}))}}}class KC extends Xs{constructor(t){super(t),this.domEventType=["mousemove","mouseleave"]}onDomEvent(t){this.fire(t.type,t)}}class ZC extends pe{static get pluginName(){return"TableMouse"}static get requires(){return[qC]}init(){this.editor.editing.view.addObserver(KC),this._enableShiftClickSelection(),this._enableMouseDragSelection()}_enableShiftClickSelection(){const t=this.editor;let e=!1;const n=t.plugins.get(qC);this.listenTo(t.editing.view.document,"mousedown",((o,i)=>{if(!this.isEnabled||!n.isEnabled)return;if(!i.domEvent.shiftKey)return;const r=n.getAnchorCell()||R_(t.model.document.selection)[0];if(!r)return;const s=this._getModelTableCellFromDomEvent(i);s&&JC(r,s)&&(e=!0,n.setCellSelection(r,s),i.preventDefault())})),this.listenTo(t.editing.view.document,"mouseup",(()=>{e=!1})),this.listenTo(t.editing.view.document,"selectionChange",(t=>{e&&t.stop()}),{priority:"highest"})}_enableMouseDragSelection(){const t=this.editor;let e,n,o=!1,i=!1;const r=t.plugins.get(qC);this.listenTo(t.editing.view.document,"mousedown",((t,n)=>{this.isEnabled&&r.isEnabled&&(n.domEvent.shiftKey||n.domEvent.ctrlKey||n.domEvent.altKey||(e=this._getModelTableCellFromDomEvent(n)))})),this.listenTo(t.editing.view.document,"mousemove",((t,s)=>{if(!s.domEvent.buttons)return;if(!e)return;const a=this._getModelTableCellFromDomEvent(s);a&&JC(e,a)&&(n=a,o||n==e||(o=!0)),o&&(i=!0,r.setCellSelection(e,n),s.preventDefault())})),this.listenTo(t.editing.view.document,"mouseup",(()=>{o=!1,i=!1,e=null,n=null})),this.listenTo(t.editing.view.document,"selectionChange",(t=>{i&&t.stop()}),{priority:"highest"})}_getModelTableCellFromDomEvent(t){const e=t.target,n=this.editor.editing.view.createPositionAt(e,0);return this.editor.editing.mapper.toModelPosition(n).parent.findAncestor("tableCell",{includeSelf:!0})}}function JC(t,e){return t.parent.parent==e.parent.parent}var YC=n(4104),QC={attributes:{"data-cke":!0}};QC.setAttributes=is(),QC.insert=ns().bind(null,"head"),QC.domAPI=ts(),QC.insertStyleElement=ss();Qr()(YC.Z,QC);YC.Z&&YC.Z.locals&&YC.Z.locals;function XC(t){const e=t.getSelectedElement();return e&&eA(e)?e:null}function tA(t){let e=t.getFirstPosition().parent;for(;e;){if(e.is("element")&&eA(e))return e;e=e.parent}return null}function eA(t){return!!t.getCustomProperty("table")&&hm(t)}function nA(t,e){const{viewElement:n,defaultValue:o,modelAttribute:i,styleName:r,reduceBoxSides:s=!1}=e;t.for("upcast").attributeToAttribute({view:{name:n,styles:{[r]:/[\s\S]+/}},model:{key:i,value:t=>{const e=t.getNormalizedStyle(r),n=s?sA(e):e;if(o!==n)return n}}})}function oA(t,e,n,o){t.for("upcast").add((t=>t.on("element:"+e,((t,e,i)=>{if(!e.modelRange)return;const r=["border-top-width","border-top-color","border-top-style","border-bottom-width","border-bottom-color","border-bottom-style","border-right-width","border-right-color","border-right-style","border-left-width","border-left-color","border-left-style"].filter((t=>e.viewItem.hasStyle(t)));if(!r.length)return;const s={styles:r};if(!i.consumable.test(e.viewItem,s))return;const a=[...e.modelRange.getItems({shallow:!0})].pop();i.consumable.consume(e.viewItem,s);const c={style:e.viewItem.getNormalizedStyle("border-style"),color:e.viewItem.getNormalizedStyle("border-color"),width:e.viewItem.getNormalizedStyle("border-width")},l={style:sA(c.style),color:sA(c.color),width:sA(c.width)};l.style!==o.style&&i.writer.setAttribute(n.style,l.style,a),l.color!==o.color&&i.writer.setAttribute(n.color,l.color,a),l.width!==o.width&&i.writer.setAttribute(n.width,l.width,a)}))))}function iA(t,{modelElement:e,modelAttribute:n,styleName:o}){t.for("downcast").attributeToAttribute({model:{name:e,key:n},view:t=>({key:"style",value:{[o]:t}})})}function rA(t,{modelAttribute:e,styleName:n}){t.for("downcast").add((t=>t.on(`attribute:${e}:table`,((t,e,o)=>{const{item:i,attributeNewValue:r}=e,{mapper:s,writer:a}=o;if(!o.consumable.consume(e.item,t.name))return;const c=[...s.toViewElement(i).getChildren()].find((t=>t.is("element","table")));r?a.setStyle(n,r,c):a.removeStyle(n,c)}))))}function sA(t){if(!t)return;return["top","right","bottom","left"].map((e=>t[e])).reduce(((t,e)=>t==e?t:null))||t}class aA extends ge{constructor(t,e,n){super(t),this.attributeName=e,this._defaultValue=n}refresh(){const t=this.editor.model.document.selection.getFirstPosition().findAncestor("table");this.isEnabled=!!t,this.value=this._getValue(t)}execute(t={}){const e=this.editor.model,n=e.document.selection,{value:o,batch:i}=t,r=n.getFirstPosition().findAncestor("table"),s=this._getValueToSet(o);e.enqueueChange(i,(t=>{s?t.setAttribute(this.attributeName,s,r):t.removeAttribute(this.attributeName,r)}))}_getValue(t){if(!t)return;const e=t.getAttribute(this.attributeName);return e!==this._defaultValue?e:void 0}_getValueToSet(t){if(t!==this._defaultValue)return t}}class cA extends aA{constructor(t,e){super(t,"tableBackgroundColor",e)}}function lA(t){if(!t||!y(t))return t;const{top:e,right:n,bottom:o,left:i}=t;return e==n&&n==o&&o==i?e:void 0}function dA(t,e){const n=parseFloat(t);return Number.isNaN(n)||String(n)!==String(t)?t:`${n}${e}`}function uA(t,e={}){const n=Object.assign({borderStyle:"none",borderWidth:"",borderColor:"",backgroundColor:"",width:"",height:""},t);return e.includeAlignmentProperty&&!n.alignment&&(n.alignment="center"),e.includePaddingProperty&&!n.padding&&(n.padding=""),e.includeVerticalAlignmentProperty&&!n.verticalAlignment&&(n.verticalAlignment="middle"),e.includeHorizontalAlignmentProperty&&!n.horizontalAlignment&&(n.horizontalAlignment=e.isRightToLeftContent?"right":"left"),n}class hA extends aA{constructor(t,e){super(t,"tableBorderColor",e)}_getValue(t){if(!t)return;const e=lA(t.getAttribute(this.attributeName));return e!==this._defaultValue?e:void 0}}class pA extends aA{constructor(t,e){super(t,"tableBorderStyle",e)}_getValue(t){if(!t)return;const e=lA(t.getAttribute(this.attributeName));return e!==this._defaultValue?e:void 0}}class mA extends aA{constructor(t,e){super(t,"tableBorderWidth",e)}_getValue(t){if(!t)return;const e=lA(t.getAttribute(this.attributeName));return e!==this._defaultValue?e:void 0}_getValueToSet(t){if((t=dA(t,"px"))!==this._defaultValue)return t}}class gA extends aA{constructor(t,e){super(t,"tableWidth",e)}_getValueToSet(t){if((t=dA(t,"px"))!==this._defaultValue)return t}}class fA extends aA{constructor(t,e){super(t,"tableHeight",e)}_getValueToSet(t){return(t=dA(t,"px"))===this._defaultValue?null:t}}class bA extends aA{constructor(t,e){super(t,"tableAlignment",e)}}const kA=/^(left|center|right)$/,wA=/^(left|none|right)$/;class _A extends pe{static get pluginName(){return"TablePropertiesEditing"}static get requires(){return[IC]}init(){const t=this.editor,e=t.model.schema,n=t.conversion;t.config.define("table.tableProperties.defaultProperties",{});const o=uA(t.config.get("table.tableProperties.defaultProperties"),{includeAlignmentProperty:!0});t.data.addStyleProcessorRules(Vp),function(t,e,n){const o={width:"tableBorderWidth",color:"tableBorderColor",style:"tableBorderStyle"};t.extend("table",{allowAttributes:Object.values(o)}),oA(e,"table",o,n),rA(e,{modelAttribute:o.color,styleName:"border-color"}),rA(e,{modelAttribute:o.style,styleName:"border-style"}),rA(e,{modelAttribute:o.width,styleName:"border-width"})}(e,n,{color:o.borderColor,style:o.borderStyle,width:o.borderWidth}),t.commands.add("tableBorderColor",new hA(t,o.borderColor)),t.commands.add("tableBorderStyle",new pA(t,o.borderStyle)),t.commands.add("tableBorderWidth",new mA(t,o.borderWidth)),function(t,e,n){t.extend("table",{allowAttributes:["tableAlignment"]}),e.for("downcast").attributeToAttribute({model:{name:"table",key:"tableAlignment"},view:t=>({key:"style",value:{float:"center"===t?"none":t}}),converterPriority:"high"}),e.for("upcast").attributeToAttribute({view:{name:/^(table|figure)$/,styles:{float:wA}},model:{key:"tableAlignment",value:t=>{let e=t.getStyle("float");return"none"===e&&(e="center"),e===n?null:e}}}).attributeToAttribute({view:{attributes:{align:kA}},model:{name:"table",key:"tableAlignment",value:t=>{const e=t.getAttribute("align");return e===n?null:e}}})}(e,n,o.alignment),t.commands.add("tableAlignment",new bA(t,o.alignment)),CA(e,n,{modelAttribute:"tableWidth",styleName:"width",defaultValue:o.width}),t.commands.add("tableWidth",new gA(t,o.width)),CA(e,n,{modelAttribute:"tableHeight",styleName:"height",defaultValue:o.height}),t.commands.add("tableHeight",new fA(t,o.height)),t.data.addStyleProcessorRules(Op),function(t,e,n){const{modelAttribute:o}=n;t.extend("table",{allowAttributes:[o]}),nA(e,{viewElement:"table",...n}),rA(e,n)}(e,n,{modelAttribute:"tableBackgroundColor",styleName:"background-color",defaultValue:o.backgroundColor}),t.commands.add("tableBackgroundColor",new cA(t,o.backgroundColor))}}function CA(t,e,n){const{modelAttribute:o}=n;t.extend("table",{allowAttributes:[o]}),nA(e,{viewElement:/^(table|figure)$/,...n}),iA(e,{modelElement:"table",...n})}var AA=n(4082),vA={attributes:{"data-cke":!0}};vA.setAttributes=is(),vA.insert=ns().bind(null,"head"),vA.domAPI=ts(),vA.insertStyleElement=ss();Qr()(AA.Z,vA);AA.Z&&AA.Z.locals&&AA.Z.locals;class yA extends Od{constructor(t,e){super(t);const n=this.bindTemplate;this.set("value",""),this.set("id"),this.set("isReadOnly",!1),this.set("hasError",!1),this.set("isFocused",!1),this.set("isEmpty",!0),this.set("ariaDescribedById"),this.options=e,this._dropdownView=this._createDropdownView(),this._inputView=this._createInputTextView(),this._stillTyping=!1,this.setTemplate({tag:"div",attributes:{class:["ck","ck-input-color",n.if("hasError","ck-error")],id:n.to("id"),"aria-invalid":n.if("hasError",!0),"aria-describedby":n.to("ariaDescribedById")},children:[this._dropdownView,this._inputView]}),this.on("change:value",((t,e,n)=>this._setInputValue(n)))}focus(){this._inputView.focus()}_createDropdownView(){const t=this.locale,e=t.t,n=this.bindTemplate,o=this._createColorGrid(t),i=nh(t),r=new Od,s=this._createRemoveColorButton();return r.setTemplate({tag:"span",attributes:{class:["ck","ck-input-color__button__preview"],style:{backgroundColor:n.to("value")}},children:[{tag:"span",attributes:{class:["ck","ck-input-color__button__preview__no-color-indicator",n.if("value","ck-hidden",(t=>""!=t))]}}]}),i.buttonView.extendTemplate({attributes:{class:"ck-input-color__button"}}),i.buttonView.children.add(r),i.buttonView.tooltip=e("Color picker"),i.panelPosition="rtl"===t.uiLanguageDirection?"se":"sw",i.panelView.children.add(s),i.panelView.children.add(o),i.bind("isEnabled").to(this,"isReadOnly",(t=>!t)),i}_createInputTextView(){const t=this.locale,e=new wh(t);return e.extendTemplate({on:{blur:e.bindTemplate.to("blur")}}),e.value=this.value,e.bind("isReadOnly","hasError").to(this),this.bind("isFocused","isEmpty").to(e),e.on("input",(()=>{const t=e.element.value,n=this.options.colorDefinitions.find((e=>t===e.label));this._stillTyping=!0,this.value=n&&n.color||t})),e.on("blur",(()=>{this._stillTyping=!1,this._setInputValue(e.element.value)})),e.delegate("input").to(this),e}_createRemoveColorButton(){const t=this.locale,e=t.t,n=new pu(t),o=this.options.defaultColorValue||"",i=e(o?"Restore default":"Remove color");return n.class="ck-input-color__remove-color",n.withText=!0,n.icon=Td.eraser,n.label=i,n.on("execute",(()=>{this.value=o,this._dropdownView.isOpen=!1,this.fire("input")})),n}_createColorGrid(t){const e=new Eu(t,{colorDefinitions:this.options.colorDefinitions,columns:this.options.columns});return e.on("execute",((t,e)=>{this.value=e.value,this._dropdownView.isOpen=!1,this.fire("input")})),e.bind("selectedColor").to(this,"value"),e}_setInputValue(t){if(!this._stillTyping){const e=xA(t),n=this.options.colorDefinitions.find((t=>e===xA(t.color)));this._inputView.value=n?n.label:t||""}}}function xA(t){return t.replace(/([(,])\s+/g,"$1").replace(/^\s+|\s+(?=[),\s]|$)/g,"").replace(/,|\s/g," ")}const EA=t=>""===t;function DA(t){return{none:t("None"),solid:t("Solid"),dotted:t("Dotted"),dashed:t("Dashed"),double:t("Double"),groove:t("Groove"),ridge:t("Ridge"),inset:t("Inset"),outset:t("Outset")}}function SA(t){return t('The color is invalid. Try "#FF0000" or "rgb(255,0,0)" or "red".')}function BA(t){return t('The value is invalid. Try "10px" or "2em" or simply "2".')}function TA(t){return t=t.trim(),EA(t)||_p(t)}function PA(t){return t=t.trim(),EA(t)||OA(t)||yp(t)||(e=t,xp.test(e));var e}function IA(t){return t=t.trim(),EA(t)||OA(t)||yp(t)}function RA(t,e){const n=new So,o=DA(t.t);for(const i in o){const r={type:"button",model:new Eh({_borderStyleValue:i,label:o[i],withText:!0})};"none"===i?r.model.bind("isOn").to(t,"borderStyle",(t=>"none"===e?!t:t===i)):r.model.bind("isOn").to(t,"borderStyle",(t=>t===i)),n.add(r)}return n}function zA(t){const{view:e,icons:n,toolbar:o,labels:i,propertyName:r,nameToValue:s,defaultValue:a}=t;for(const t in i){const c=new pu(e.locale);c.set({label:i[t],icon:n[t],tooltip:i[t]});const l=s?s(t):t;c.bind("isOn").to(e,r,(t=>{let e=t;return""===t&&a&&(e=a),l===e})),c.on("execute",(()=>{e[r]=l})),o.items.add(c)}}const FA=[{color:"hsl(0, 0%, 0%)",label:"Black"},{color:"hsl(0, 0%, 30%)",label:"Dim grey"},{color:"hsl(0, 0%, 60%)",label:"Grey"},{color:"hsl(0, 0%, 90%)",label:"Light grey"},{color:"hsl(0, 0%, 100%)",label:"White",hasBorder:!0},{color:"hsl(0, 75%, 60%)",label:"Red"},{color:"hsl(30, 75%, 60%)",label:"Orange"},{color:"hsl(60, 75%, 60%)",label:"Yellow"},{color:"hsl(90, 75%, 60%)",label:"Light green"},{color:"hsl(120, 75%, 60%)",label:"Green"},{color:"hsl(150, 75%, 60%)",label:"Aquamarine"},{color:"hsl(180, 75%, 60%)",label:"Turquoise"},{color:"hsl(210, 75%, 60%)",label:"Light blue"},{color:"hsl(240, 75%, 60%)",label:"Blue"},{color:"hsl(270, 75%, 60%)",label:"Purple"}];function NA(t){return(e,n,o)=>{const i=new yA(e.locale,{colorDefinitions:(r=t.colorConfig,r.map((t=>({color:t.model,label:t.label,options:{hasBorder:t.hasBorder}})))),columns:t.columns,defaultColorValue:t.defaultColorValue});var r;return i.set({id:n,ariaDescribedById:o}),i.bind("isReadOnly").to(e,"isEnabled",(t=>!t)),i.bind("hasError").to(e,"errorText",(t=>!!t)),i.on("input",(()=>{e.errorText=null})),e.bind("isEmpty","isFocused").to(i),i}}function OA(t){const e=parseFloat(t);return!Number.isNaN(e)&&t===String(e)}var MA=n(9865),VA={attributes:{"data-cke":!0}};VA.setAttributes=is(),VA.insert=ns().bind(null,"head"),VA.domAPI=ts(),VA.insertStyleElement=ss();Qr()(MA.Z,VA);MA.Z&&MA.Z.locals&&MA.Z.locals;class LA extends Od{constructor(t,e={}){super(t);const n=this.bindTemplate;this.set("class",e.class||null),this.children=this.createCollection(),e.children&&e.children.forEach((t=>this.children.add(t))),this.set("_role",null),this.set("_ariaLabelledBy",null),e.labelView&&this.set({_role:"group",_ariaLabelledBy:e.labelView.id}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-form__row",n.to("class")],role:n.to("_role"),"aria-labelledby":n.to("_ariaLabelledBy")},children:this.children})}}var HA=n(4880),qA={attributes:{"data-cke":!0}};qA.setAttributes=is(),qA.insert=ns().bind(null,"head"),qA.domAPI=ts(),qA.insertStyleElement=ss();Qr()(HA.Z,qA);HA.Z&&HA.Z.locals&&HA.Z.locals;var WA=n(198),jA={attributes:{"data-cke":!0}};jA.setAttributes=is(),jA.insert=ns().bind(null,"head"),jA.domAPI=ts(),jA.insertStyleElement=ss();Qr()(WA.Z,jA);WA.Z&&WA.Z.locals&&WA.Z.locals;var UA=n(9221),$A={attributes:{"data-cke":!0}};$A.setAttributes=is(),$A.insert=ns().bind(null,"head"),$A.domAPI=ts(),$A.insertStyleElement=ss();Qr()(UA.Z,$A);UA.Z&&UA.Z.locals&&UA.Z.locals;const GA={left:Td.objectLeft,center:Td.objectCenter,right:Td.objectRight};class KA extends Od{constructor(t,e){super(t),this.set({borderStyle:"",borderWidth:"",borderColor:"",backgroundColor:"",width:"",height:"",alignment:""}),this.options=e;const{borderStyleDropdown:n,borderWidthInput:o,borderColorInput:i,borderRowLabel:r}=this._createBorderFields(),{backgroundRowLabel:s,backgroundInput:a}=this._createBackgroundFields(),{widthInput:c,operatorLabel:l,heightInput:d,dimensionsLabel:u}=this._createDimensionFields(),{alignmentToolbar:h,alignmentLabel:p}=this._createAlignmentFields();this.focusTracker=new Pa,this.keystrokes=new Ia,this.children=this.createCollection(),this.borderStyleDropdown=n,this.borderWidthInput=o,this.borderColorInput=i,this.backgroundInput=a,this.widthInput=c,this.heightInput=d,this.alignmentToolbar=h;const{saveButtonView:m,cancelButtonView:g}=this._createActionButtons();this.saveButtonView=m,this.cancelButtonView=g,this._focusables=new zd,this._focusCycler=new Au({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.children.add(new gh(t,{label:this.t("Table properties")})),this.children.add(new LA(t,{labelView:r,children:[r,n,i,o],class:"ck-table-form__border-row"})),this.children.add(new LA(t,{labelView:s,children:[s,a],class:"ck-table-form__background-row"})),this.children.add(new LA(t,{children:[new LA(t,{labelView:u,children:[u,c,l,d],class:"ck-table-form__dimensions-row"}),new LA(t,{labelView:p,children:[p,h],class:"ck-table-properties-form__alignment-row"})]})),this.children.add(new LA(t,{children:[this.saveButtonView,this.cancelButtonView],class:"ck-table-form__action-row"})),this.setTemplate({tag:"form",attributes:{class:["ck","ck-form","ck-table-form","ck-table-properties-form"],tabindex:"-1"},children:this.children})}render(){super.render(),Rd({view:this}),[this.borderStyleDropdown,this.borderColorInput,this.borderWidthInput,this.backgroundInput,this.widthInput,this.heightInput,this.alignmentToolbar,this.saveButtonView,this.cancelButtonView].forEach((t=>{this._focusables.add(t),this.focusTracker.add(t.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createBorderFields(){const t=this.options.defaultTableProperties,e={style:t.borderStyle,width:t.borderWidth,color:t.borderColor},n=NA({colorConfig:this.options.borderColors,columns:5,defaultColorValue:e.color}),o=this.locale,i=this.t,r=new dh(o);r.text=i("Border");const s=DA(this.t),a=new Ah(o,yh);a.set({label:i("Style"),class:"ck-table-form__border-style"}),a.fieldView.buttonView.set({isOn:!1,withText:!0,tooltip:i("Style")}),a.fieldView.buttonView.bind("label").to(this,"borderStyle",(t=>s[t||"none"])),a.fieldView.on("execute",(t=>{this.borderStyle=t.source._borderStyleValue})),a.bind("isEmpty").to(this,"borderStyle",(t=>!t)),ih(a.fieldView,RA(this,e.style));const c=new Ah(o,vh);c.set({label:i("Width"),class:"ck-table-form__border-width"}),c.fieldView.bind("value").to(this,"borderWidth"),c.bind("isEnabled").to(this,"borderStyle",ZA),c.fieldView.on("input",(()=>{this.borderWidth=c.fieldView.element.value}));const l=new Ah(o,n);return l.set({label:i("Color"),class:"ck-table-form__border-color"}),l.fieldView.bind("value").to(this,"borderColor"),l.bind("isEnabled").to(this,"borderStyle",ZA),l.fieldView.on("input",(()=>{this.borderColor=l.fieldView.value})),this.on("change:borderStyle",((t,n,o,i)=>{ZA(o)||(this.borderColor="",this.borderWidth=""),ZA(i)||(this.borderColor=e.color,this.borderWidth=e.width)})),{borderRowLabel:r,borderStyleDropdown:a,borderColorInput:l,borderWidthInput:c}}_createBackgroundFields(){const t=this.locale,e=this.t,n=new dh(t);n.text=e("Background");const o=NA({colorConfig:this.options.backgroundColors,columns:5,defaultColorValue:this.options.defaultTableProperties.backgroundColor}),i=new Ah(t,o);return i.set({label:e("Color"),class:"ck-table-properties-form__background"}),i.fieldView.bind("value").to(this,"backgroundColor"),i.fieldView.on("input",(()=>{this.backgroundColor=i.fieldView.value})),{backgroundRowLabel:n,backgroundInput:i}}_createDimensionFields(){const t=this.locale,e=this.t,n=new dh(t);n.text=e("Dimensions");const o=new Ah(t,vh);o.set({label:e("Width"),class:"ck-table-form__dimensions-row__width"}),o.fieldView.bind("value").to(this,"width"),o.fieldView.on("input",(()=>{this.width=o.fieldView.element.value}));const i=new Od(t);i.setTemplate({tag:"span",attributes:{class:["ck-table-form__dimension-operator"]},children:[{text:"×"}]});const r=new Ah(t,vh);return r.set({label:e("Height"),class:"ck-table-form__dimensions-row__height"}),r.fieldView.bind("value").to(this,"height"),r.fieldView.on("input",(()=>{this.height=r.fieldView.element.value})),{dimensionsLabel:n,widthInput:o,operatorLabel:i,heightInput:r}}_createAlignmentFields(){const t=this.locale,e=this.t,n=new dh(t);n.text=e("Alignment");const o=new Wu(t);return o.set({isCompact:!0,ariaLabel:e("Table alignment toolbar")}),zA({view:this,icons:GA,toolbar:o,labels:this._alignmentLabels,propertyName:"alignment",defaultValue:this.options.defaultTableProperties.alignment}),{alignmentLabel:n,alignmentToolbar:o}}_createActionButtons(){const t=this.locale,e=this.t,n=new pu(t),o=new pu(t),i=[this.borderWidthInput,this.borderColorInput,this.backgroundInput,this.widthInput,this.heightInput];return n.set({label:e("Save"),icon:Td.check,class:"ck-button-save",type:"submit",withText:!0}),n.bind("isEnabled").toMany(i,"errorText",((...t)=>t.every((t=>!t)))),o.set({label:e("Cancel"),icon:Td.cancel,class:"ck-button-cancel",withText:!0}),o.delegate("execute").to(this,"cancel"),{saveButtonView:n,cancelButtonView:o}}get _alignmentLabels(){const t=this.locale,e=this.t,n=e("Align table to the left"),o=e("Center table"),i=e("Align table to the right");return"rtl"===t.uiLanguageDirection?{right:i,center:o,left:n}:{left:n,center:o,right:i}}}function ZA(t){return"none"!==t}const JA=Ih.defaultPositions,YA=[JA.northArrowSouth,JA.northArrowSouthWest,JA.northArrowSouthEast,JA.southArrowNorth,JA.southArrowNorthWest,JA.southArrowNorthEast,JA.viewportStickyNorth];function QA(t,e){const n=t.plugins.get("ContextualBalloon");if(tA(t.editing.view.document.selection)){let o;o="cell"===e?tv(t):XA(t),n.updatePosition(o)}}function XA(t){const e=t.model.document.selection.getFirstPosition().findAncestor("table"),n=t.editing.mapper.toViewElement(e);return{target:t.editing.view.domConverter.viewToDom(n),positions:YA}}function tv(t){const e=t.editing.mapper,n=t.editing.view.domConverter,o=t.model.document.selection;if(o.rangeCount>1)return{target:()=>function(t,e){const n=e.editing.mapper,o=e.editing.view.domConverter,i=Array.from(t).map((t=>{const e=ev(t.start),i=n.toViewElement(e);return new ya(o.viewToDom(i))}));return ya.getBoundingRect(i)}(o.getRanges(),t),positions:YA};const i=ev(o.getFirstPosition()),r=e.toViewElement(i);return{target:n.viewToDom(r),positions:YA}}function ev(t){return t.nodeAfter&&t.nodeAfter.is("element","tableCell")?t.nodeAfter:t.findAncestor("tableCell")}const nv={borderStyle:"tableBorderStyle",borderColor:"tableBorderColor",borderWidth:"tableBorderWidth",backgroundColor:"tableBackgroundColor",width:"tableWidth",height:"tableHeight",alignment:"tableAlignment"};class ov extends pe{static get requires(){return[Vh]}static get pluginName(){return"TablePropertiesUI"}constructor(t){super(t),t.config.define("table.tableProperties",{borderColors:FA,backgroundColors:FA})}init(){const t=this.editor,e=t.t;this._defaultTableProperties=uA(t.config.get("table.tableProperties.defaultProperties"),{includeAlignmentProperty:!0}),this._balloon=t.plugins.get(Vh),this.view=this._createPropertiesView(),this._undoStepBatch=null,t.ui.componentFactory.add("tableProperties",(n=>{const o=new pu(n);o.set({label:e("Table properties"),icon:'',tooltip:!0}),this.listenTo(o,"execute",(()=>this._showView()));const i=Object.values(nv).map((e=>t.commands.get(e)));return o.bind("isEnabled").toMany(i,"isEnabled",((...t)=>t.some((t=>t)))),o}))}destroy(){super.destroy(),this.view.destroy()}_createPropertiesView(){const t=this.editor,e=t.config.get("table.tableProperties"),n=ku(e.borderColors),o=bu(t.locale,n),i=ku(e.backgroundColors),r=bu(t.locale,i),s=new KA(t.locale,{borderColors:o,backgroundColors:r,defaultTableProperties:this._defaultTableProperties}),a=t.t;s.render(),this.listenTo(s,"submit",(()=>{this._hideView()})),this.listenTo(s,"cancel",(()=>{this._undoStepBatch.operations.length&&t.execute("undo",this._undoStepBatch),this._hideView()})),s.keystrokes.set("Esc",((t,e)=>{this._hideView(),e()})),Pd({emitter:s,activator:()=>this._isViewInBalloon,contextElements:[this._balloon.view.element],callback:()=>this._hideView()});const c=SA(a),l=BA(a);return s.on("change:borderStyle",this._getPropertyChangeCallback("tableBorderStyle",this._defaultTableProperties.borderStyle)),s.on("change:borderColor",this._getValidatedPropertyChangeCallback({viewField:s.borderColorInput,commandName:"tableBorderColor",errorText:c,validator:TA,defaultValue:this._defaultTableProperties.borderColor})),s.on("change:borderWidth",this._getValidatedPropertyChangeCallback({viewField:s.borderWidthInput,commandName:"tableBorderWidth",errorText:l,validator:IA,defaultValue:this._defaultTableProperties.borderWidth})),s.on("change:backgroundColor",this._getValidatedPropertyChangeCallback({viewField:s.backgroundInput,commandName:"tableBackgroundColor",errorText:c,validator:TA,defaultValue:this._defaultTableProperties.backgroundColor})),s.on("change:width",this._getValidatedPropertyChangeCallback({viewField:s.widthInput,commandName:"tableWidth",errorText:l,validator:PA,defaultValue:this._defaultTableProperties.width})),s.on("change:height",this._getValidatedPropertyChangeCallback({viewField:s.heightInput,commandName:"tableHeight",errorText:l,validator:PA,defaultValue:this._defaultTableProperties.height})),s.on("change:alignment",this._getPropertyChangeCallback("tableAlignment",this._defaultTableProperties.alignment)),s}_fillViewFormFromCommandValues(){const t=this.editor.commands,e=t.get("tableBorderStyle");Object.entries(nv).map((([e,n])=>{const o=this._defaultTableProperties[e]||"";return[e,t.get(n).value||o]})).forEach((([t,n])=>{("borderColor"!==t&&"borderWidth"!==t||"none"!==e.value)&&this.view.set(t,n)}))}_showView(){const t=this.editor;this.listenTo(t.ui,"update",(()=>{this._updateView()})),this._fillViewFormFromCommandValues(),this._balloon.add({view:this.view,position:XA(t)}),this._undoStepBatch=t.model.createBatch(),this.view.focus()}_hideView(){const t=this.editor;this.stopListening(t.ui,"update"),this.view.saveButtonView.focus(),this._balloon.remove(this.view),this.editor.editing.view.focus()}_updateView(){const t=this.editor;tA(t.editing.view.document.selection)?this._isViewVisible&&QA(t,"table"):this._hideView()}get _isViewVisible(){return this._balloon.visibleView===this.view}get _isViewInBalloon(){return this._balloon.hasView(this.view)}_getPropertyChangeCallback(t,e){return(n,o,i,r)=>{(r||e!==i)&&this.editor.execute(t,{value:i,batch:this._undoStepBatch})}}_getValidatedPropertyChangeCallback(t){const{commandName:e,viewField:n,validator:o,errorText:i,defaultValue:r}=t,s=pa((()=>{n.errorText=i}),500);return(t,i,a,c)=>{s.cancel(),(c||r!==a)&&(o(a)?(this.editor.execute(e,{value:a,batch:this._undoStepBatch}),n.errorText=null):s())}}}var iv=n(5737),rv={attributes:{"data-cke":!0}};rv.setAttributes=is(),rv.insert=ns().bind(null,"head"),rv.domAPI=ts(),rv.insertStyleElement=ss();Qr()(iv.Z,rv);iv.Z&&iv.Z.locals&&iv.Z.locals;const sv={left:Td.alignLeft,center:Td.alignCenter,right:Td.alignRight,justify:Td.alignJustify,top:Td.alignTop,middle:Td.alignMiddle,bottom:Td.alignBottom};class av extends Od{constructor(t,e){super(t),this.set({borderStyle:"",borderWidth:"",borderColor:"",padding:"",backgroundColor:"",width:"",height:"",horizontalAlignment:"",verticalAlignment:""}),this.options=e;const{borderStyleDropdown:n,borderWidthInput:o,borderColorInput:i,borderRowLabel:r}=this._createBorderFields(),{backgroundRowLabel:s,backgroundInput:a}=this._createBackgroundFields(),{widthInput:c,operatorLabel:l,heightInput:d,dimensionsLabel:u}=this._createDimensionFields(),{horizontalAlignmentToolbar:h,verticalAlignmentToolbar:p,alignmentLabel:m}=this._createAlignmentFields();this.focusTracker=new Pa,this.keystrokes=new Ia,this.children=this.createCollection(),this.borderStyleDropdown=n,this.borderWidthInput=o,this.borderColorInput=i,this.backgroundInput=a,this.paddingInput=this._createPaddingField(),this.widthInput=c,this.heightInput=d,this.horizontalAlignmentToolbar=h,this.verticalAlignmentToolbar=p;const{saveButtonView:g,cancelButtonView:f}=this._createActionButtons();this.saveButtonView=g,this.cancelButtonView=f,this._focusables=new zd,this._focusCycler=new Au({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.children.add(new gh(t,{label:this.t("Cell properties")})),this.children.add(new LA(t,{labelView:r,children:[r,n,i,o],class:"ck-table-form__border-row"})),this.children.add(new LA(t,{labelView:s,children:[s,a],class:"ck-table-form__background-row"})),this.children.add(new LA(t,{children:[new LA(t,{labelView:u,children:[u,c,l,d],class:"ck-table-form__dimensions-row"}),new LA(t,{children:[this.paddingInput],class:"ck-table-cell-properties-form__padding-row"})]})),this.children.add(new LA(t,{labelView:m,children:[m,h,p],class:"ck-table-cell-properties-form__alignment-row"})),this.children.add(new LA(t,{children:[this.saveButtonView,this.cancelButtonView],class:"ck-table-form__action-row"})),this.setTemplate({tag:"form",attributes:{class:["ck","ck-form","ck-table-form","ck-table-cell-properties-form"],tabindex:"-1"},children:this.children})}render(){super.render(),Rd({view:this}),[this.borderStyleDropdown,this.borderColorInput,this.borderWidthInput,this.backgroundInput,this.widthInput,this.heightInput,this.paddingInput,this.horizontalAlignmentToolbar,this.verticalAlignmentToolbar,this.saveButtonView,this.cancelButtonView].forEach((t=>{this._focusables.add(t),this.focusTracker.add(t.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createBorderFields(){const t=this.options.defaultTableCellProperties,e={style:t.borderStyle,width:t.borderWidth,color:t.borderColor},n=NA({colorConfig:this.options.borderColors,columns:5,defaultColorValue:e.color}),o=this.locale,i=this.t,r=new dh(o);r.text=i("Border");const s=DA(i),a=new Ah(o,yh);a.set({label:i("Style"),class:"ck-table-form__border-style"}),a.fieldView.buttonView.set({isOn:!1,withText:!0,tooltip:i("Style")}),a.fieldView.buttonView.bind("label").to(this,"borderStyle",(t=>s[t||"none"])),a.fieldView.on("execute",(t=>{this.borderStyle=t.source._borderStyleValue})),a.bind("isEmpty").to(this,"borderStyle",(t=>!t)),ih(a.fieldView,RA(this,e.style));const c=new Ah(o,vh);c.set({label:i("Width"),class:"ck-table-form__border-width"}),c.fieldView.bind("value").to(this,"borderWidth"),c.bind("isEnabled").to(this,"borderStyle",cv),c.fieldView.on("input",(()=>{this.borderWidth=c.fieldView.element.value}));const l=new Ah(o,n);return l.set({label:i("Color"),class:"ck-table-form__border-color"}),l.fieldView.bind("value").to(this,"borderColor"),l.bind("isEnabled").to(this,"borderStyle",cv),l.fieldView.on("input",(()=>{this.borderColor=l.fieldView.value})),this.on("change:borderStyle",((t,n,o,i)=>{cv(o)||(this.borderColor="",this.borderWidth=""),cv(i)||(this.borderColor=e.color,this.borderWidth=e.width)})),{borderRowLabel:r,borderStyleDropdown:a,borderColorInput:l,borderWidthInput:c}}_createBackgroundFields(){const t=this.locale,e=this.t,n=new dh(t);n.text=e("Background");const o=NA({colorConfig:this.options.backgroundColors,columns:5,defaultColorValue:this.options.defaultTableCellProperties.backgroundColor}),i=new Ah(t,o);return i.set({label:e("Color"),class:"ck-table-cell-properties-form__background"}),i.fieldView.bind("value").to(this,"backgroundColor"),i.fieldView.on("input",(()=>{this.backgroundColor=i.fieldView.value})),{backgroundRowLabel:n,backgroundInput:i}}_createDimensionFields(){const t=this.locale,e=this.t,n=new dh(t);n.text=e("Dimensions");const o=new Ah(t,vh);o.set({label:e("Width"),class:"ck-table-form__dimensions-row__width"}),o.fieldView.bind("value").to(this,"width"),o.fieldView.on("input",(()=>{this.width=o.fieldView.element.value}));const i=new Od(t);i.setTemplate({tag:"span",attributes:{class:["ck-table-form__dimension-operator"]},children:[{text:"×"}]});const r=new Ah(t,vh);return r.set({label:e("Height"),class:"ck-table-form__dimensions-row__height"}),r.fieldView.bind("value").to(this,"height"),r.fieldView.on("input",(()=>{this.height=r.fieldView.element.value})),{dimensionsLabel:n,widthInput:o,operatorLabel:i,heightInput:r}}_createPaddingField(){const t=this.locale,e=this.t,n=new Ah(t,vh);return n.set({label:e("Padding"),class:"ck-table-cell-properties-form__padding"}),n.fieldView.bind("value").to(this,"padding"),n.fieldView.on("input",(()=>{this.padding=n.fieldView.element.value})),n}_createAlignmentFields(){const t=this.locale,e=this.t,n=new dh(t);n.text=e("Table cell text alignment");const o=new Wu(t),i="rtl"===this.locale.contentLanguageDirection;o.set({isCompact:!0,ariaLabel:e("Horizontal text alignment toolbar")}),zA({view:this,icons:sv,toolbar:o,labels:this._horizontalAlignmentLabels,propertyName:"horizontalAlignment",nameToValue:t=>{if(i){if("left"===t)return"right";if("right"===t)return"left"}return t},defaultValue:this.options.defaultTableCellProperties.horizontalAlignment});const r=new Wu(t);return r.set({isCompact:!0,ariaLabel:e("Vertical text alignment toolbar")}),zA({view:this,icons:sv,toolbar:r,labels:this._verticalAlignmentLabels,propertyName:"verticalAlignment",defaultValue:this.options.defaultTableCellProperties.verticalAlignment}),{horizontalAlignmentToolbar:o,verticalAlignmentToolbar:r,alignmentLabel:n}}_createActionButtons(){const t=this.locale,e=this.t,n=new pu(t),o=new pu(t),i=[this.borderWidthInput,this.borderColorInput,this.backgroundInput,this.paddingInput];return n.set({label:e("Save"),icon:Td.check,class:"ck-button-save",type:"submit",withText:!0}),n.bind("isEnabled").toMany(i,"errorText",((...t)=>t.every((t=>!t)))),o.set({label:e("Cancel"),icon:Td.cancel,class:"ck-button-cancel",withText:!0}),o.delegate("execute").to(this,"cancel"),{saveButtonView:n,cancelButtonView:o}}get _horizontalAlignmentLabels(){const t=this.locale,e=this.t,n=e("Align cell text to the left"),o=e("Align cell text to the center"),i=e("Align cell text to the right"),r=e("Justify cell text");return"rtl"===t.uiLanguageDirection?{right:i,center:o,left:n,justify:r}:{left:n,center:o,right:i,justify:r}}get _verticalAlignmentLabels(){const t=this.t;return{top:t("Align cell text to the top"),middle:t("Align cell text to the middle"),bottom:t("Align cell text to the bottom")}}}function cv(t){return"none"!==t}const lv={borderStyle:"tableCellBorderStyle",borderColor:"tableCellBorderColor",borderWidth:"tableCellBorderWidth",width:"tableCellWidth",height:"tableCellHeight",padding:"tableCellPadding",backgroundColor:"tableCellBackgroundColor",horizontalAlignment:"tableCellHorizontalAlignment",verticalAlignment:"tableCellVerticalAlignment"};class dv extends pe{static get requires(){return[Vh]}static get pluginName(){return"TableCellPropertiesUI"}constructor(t){super(t),t.config.define("table.tableCellProperties",{borderColors:FA,backgroundColors:FA})}init(){const t=this.editor,e=t.t;this._defaultTableCellProperties=uA(t.config.get("table.tableCellProperties.defaultProperties"),{includeVerticalAlignmentProperty:!0,includeHorizontalAlignmentProperty:!0,includePaddingProperty:!0,isRightToLeftContent:"rtl"===t.locale.contentLanguageDirection}),this._balloon=t.plugins.get(Vh),this.view=this._createPropertiesView(),this._undoStepBatch=null,t.ui.componentFactory.add("tableCellProperties",(n=>{const o=new pu(n);o.set({label:e("Cell properties"),icon:'',tooltip:!0}),this.listenTo(o,"execute",(()=>this._showView()));const i=Object.values(lv).map((e=>t.commands.get(e)));return o.bind("isEnabled").toMany(i,"isEnabled",((...t)=>t.some((t=>t)))),o}))}destroy(){super.destroy(),this.view.destroy()}_createPropertiesView(){const t=this.editor,e=t.editing.view.document,n=t.config.get("table.tableCellProperties"),o=ku(n.borderColors),i=bu(t.locale,o),r=ku(n.backgroundColors),s=bu(t.locale,r),a=new av(t.locale,{borderColors:i,backgroundColors:s,defaultTableCellProperties:this._defaultTableCellProperties}),c=t.t;a.render(),this.listenTo(a,"submit",(()=>{this._hideView()})),this.listenTo(a,"cancel",(()=>{this._undoStepBatch.operations.length&&t.execute("undo",this._undoStepBatch),this._hideView()})),a.keystrokes.set("Esc",((t,e)=>{this._hideView(),e()})),this.listenTo(t.ui,"update",(()=>{tA(e.selection)?this._isViewVisible&&QA(t,"cell"):this._hideView()})),Pd({emitter:a,activator:()=>this._isViewInBalloon,contextElements:[this._balloon.view.element],callback:()=>this._hideView()});const l=SA(c),d=BA(c);return a.on("change:borderStyle",this._getPropertyChangeCallback("tableCellBorderStyle",this._defaultTableCellProperties.borderStyle)),a.on("change:borderColor",this._getValidatedPropertyChangeCallback({viewField:a.borderColorInput,commandName:"tableCellBorderColor",errorText:l,validator:TA,defaultValue:this._defaultTableCellProperties.borderColor})),a.on("change:borderWidth",this._getValidatedPropertyChangeCallback({viewField:a.borderWidthInput,commandName:"tableCellBorderWidth",errorText:d,validator:IA,defaultValue:this._defaultTableCellProperties.borderWidth})),a.on("change:padding",this._getValidatedPropertyChangeCallback({viewField:a.paddingInput,commandName:"tableCellPadding",errorText:d,validator:PA,defaultValue:this._defaultTableCellProperties.padding})),a.on("change:width",this._getValidatedPropertyChangeCallback({viewField:a.widthInput,commandName:"tableCellWidth",errorText:d,validator:PA,defaultValue:this._defaultTableCellProperties.width})),a.on("change:height",this._getValidatedPropertyChangeCallback({viewField:a.heightInput,commandName:"tableCellHeight",errorText:d,validator:PA,defaultValue:this._defaultTableCellProperties.height})),a.on("change:backgroundColor",this._getValidatedPropertyChangeCallback({viewField:a.backgroundInput,commandName:"tableCellBackgroundColor",errorText:l,validator:TA,defaultValue:this._defaultTableCellProperties.backgroundColor})),a.on("change:horizontalAlignment",this._getPropertyChangeCallback("tableCellHorizontalAlignment",this._defaultTableCellProperties.horizontalAlignment)),a.on("change:verticalAlignment",this._getPropertyChangeCallback("tableCellVerticalAlignment",this._defaultTableCellProperties.verticalAlignment)),a}_fillViewFormFromCommandValues(){const t=this.editor.commands,e=t.get("tableCellBorderStyle");Object.entries(lv).map((([e,n])=>{const o=this._defaultTableCellProperties[e]||"";return[e,t.get(n).value||o]})).forEach((([t,n])=>{("borderColor"!==t&&"borderWidth"!==t||"none"!==e.value)&&this.view.set(t,n)}))}_showView(){const t=this.editor;this._fillViewFormFromCommandValues(),this._balloon.add({view:this.view,position:tv(t)}),this._undoStepBatch=t.model.createBatch(),this.view.focus()}_hideView(){if(!this._isViewInBalloon)return;const t=this.editor;this.stopListening(t.ui,"update"),this.view.saveButtonView.focus(),this._balloon.remove(this.view),this.editor.editing.view.focus()}get _isViewVisible(){return this._balloon.visibleView===this.view}get _isViewInBalloon(){return this._balloon.hasView(this.view)}_getPropertyChangeCallback(t,e){return(n,o,i,r)=>{(r||e!==i)&&this.editor.execute(t,{value:i,batch:this._undoStepBatch})}}_getValidatedPropertyChangeCallback(t){const{commandName:e,viewField:n,validator:o,errorText:i,defaultValue:r}=t,s=pa((()=>{n.errorText=i}),500);return(t,i,a,c)=>{s.cancel(),(c||r!==a)&&(o(a)?(this.editor.execute(e,{value:a,batch:this._undoStepBatch}),n.errorText=null):s())}}}class uv extends ge{constructor(t,e,n){super(t),this.attributeName=e,this._defaultValue=n}refresh(){const t=z_(this.editor.model.document.selection);this.isEnabled=!!t.length,this.value=this._getSingleValue(t)}execute(t={}){const{value:e,batch:n}=t,o=this.editor.model,i=z_(o.document.selection),r=this._getValueToSet(e);o.enqueueChange(n,(t=>{r?i.forEach((e=>t.setAttribute(this.attributeName,r,e))):i.forEach((e=>t.removeAttribute(this.attributeName,e)))}))}_getAttribute(t){if(!t)return;const e=t.getAttribute(this.attributeName);return e!==this._defaultValue?e:void 0}_getValueToSet(t){if(t!==this._defaultValue)return t}_getSingleValue(t){const e=this._getAttribute(t[0]);return t.every((t=>this._getAttribute(t)===e))?e:void 0}}class hv extends uv{constructor(t,e){super(t,"tableCellPadding",e)}_getAttribute(t){if(!t)return;const e=lA(t.getAttribute(this.attributeName));return e!==this._defaultValue?e:void 0}_getValueToSet(t){if((t=dA(t,"px"))!==this._defaultValue)return t}}class pv extends uv{constructor(t,e){super(t,"tableCellWidth",e)}_getValueToSet(t){if((t=dA(t,"px"))!==this._defaultValue)return t}}class mv extends uv{constructor(t,e){super(t,"tableCellHeight",e)}_getValueToSet(t){return(t=dA(t,"px"))===this._defaultValue?null:t}}class gv extends uv{constructor(t,e){super(t,"tableCellBackgroundColor",e)}}class fv extends uv{constructor(t,e){super(t,"tableCellVerticalAlignment",e)}}class bv extends uv{constructor(t,e){super(t,"tableCellHorizontalAlignment",e)}}class kv extends uv{constructor(t,e){super(t,"tableCellBorderStyle",e)}_getAttribute(t){if(!t)return;const e=lA(t.getAttribute(this.attributeName));return e!==this._defaultValue?e:void 0}}class wv extends uv{constructor(t,e){super(t,"tableCellBorderColor",e)}_getAttribute(t){if(!t)return;const e=lA(t.getAttribute(this.attributeName));return e!==this._defaultValue?e:void 0}}class _v extends uv{constructor(t,e){super(t,"tableCellBorderWidth",e)}_getAttribute(t){if(!t)return;const e=lA(t.getAttribute(this.attributeName));return e!==this._defaultValue?e:void 0}_getValueToSet(t){if((t=dA(t,"px"))!==this._defaultValue)return t}}const Cv=/^(top|middle|bottom)$/,Av=/^(left|center|right|justify)$/;class vv extends pe{static get pluginName(){return"TableCellPropertiesEditing"}static get requires(){return[IC]}init(){const t=this.editor,e=t.model.schema,n=t.conversion;t.config.define("table.tableCellProperties.defaultProperties",{});const o=uA(t.config.get("table.tableCellProperties.defaultProperties"),{includeVerticalAlignmentProperty:!0,includeHorizontalAlignmentProperty:!0,includePaddingProperty:!0,isRightToLeftContent:"rtl"===t.locale.contentLanguageDirection});t.data.addStyleProcessorRules(Vp),function(t,e,n){const o={width:"tableCellBorderWidth",color:"tableCellBorderColor",style:"tableCellBorderStyle"};t.extend("tableCell",{allowAttributes:Object.values(o)}),oA(e,"td",o,n),oA(e,"th",o,n),iA(e,{modelElement:"tableCell",modelAttribute:o.style,styleName:"border-style"}),iA(e,{modelElement:"tableCell",modelAttribute:o.color,styleName:"border-color"}),iA(e,{modelElement:"tableCell",modelAttribute:o.width,styleName:"border-width"})}(e,n,{color:o.borderColor,style:o.borderStyle,width:o.borderWidth}),t.commands.add("tableCellBorderStyle",new kv(t,o.borderStyle)),t.commands.add("tableCellBorderColor",new wv(t,o.borderColor)),t.commands.add("tableCellBorderWidth",new _v(t,o.borderWidth)),yv(e,n,{modelAttribute:"tableCellWidth",styleName:"width",defaultValue:o.width}),t.commands.add("tableCellWidth",new pv(t,o.width)),yv(e,n,{modelAttribute:"tableCellHeight",styleName:"height",defaultValue:o.height}),t.commands.add("tableCellHeight",new mv(t,o.height)),t.data.addStyleProcessorRules(Jp),yv(e,n,{modelAttribute:"tableCellPadding",styleName:"padding",reduceBoxSides:!0,defaultValue:o.padding}),t.commands.add("tableCellPadding",new hv(t,o.padding)),t.data.addStyleProcessorRules(Op),yv(e,n,{modelAttribute:"tableCellBackgroundColor",styleName:"background-color",defaultValue:o.backgroundColor}),t.commands.add("tableCellBackgroundColor",new gv(t,o.backgroundColor)),function(t,e,n){t.extend("tableCell",{allowAttributes:["tableCellHorizontalAlignment"]}),e.for("downcast").attributeToAttribute({model:{name:"tableCell",key:"tableCellHorizontalAlignment"},view:t=>({key:"style",value:{"text-align":t}})}),e.for("upcast").attributeToAttribute({view:{name:/^(td|th)$/,styles:{"text-align":Av}},model:{key:"tableCellHorizontalAlignment",value:t=>{const e=t.getStyle("text-align");return e===n?null:e}}}).attributeToAttribute({view:{name:/^(td|th)$/,attributes:{align:Av}},model:{key:"tableCellHorizontalAlignment",value:t=>{const e=t.getAttribute("align");return e===n?null:e}}})}(e,n,o.horizontalAlignment),t.commands.add("tableCellHorizontalAlignment",new bv(t,o.horizontalAlignment)),function(t,e,n){t.extend("tableCell",{allowAttributes:["tableCellVerticalAlignment"]}),e.for("downcast").attributeToAttribute({model:{name:"tableCell",key:"tableCellVerticalAlignment"},view:t=>({key:"style",value:{"vertical-align":t}})}),e.for("upcast").attributeToAttribute({view:{name:/^(td|th)$/,styles:{"vertical-align":Cv}},model:{key:"tableCellVerticalAlignment",value:t=>{const e=t.getStyle("vertical-align");return e===n?null:e}}}).attributeToAttribute({view:{name:/^(td|th)$/,attributes:{valign:Cv}},model:{key:"tableCellVerticalAlignment",value:t=>{const e=t.getAttribute("valign");return e===n?null:e}}})}(e,n,o.verticalAlignment),t.commands.add("tableCellVerticalAlignment",new fv(t,o.verticalAlignment))}}function yv(t,e,n){const{modelAttribute:o}=n;t.extend("tableCell",{allowAttributes:[o]}),nA(e,{viewElement:/^(td|th)$/,...n}),iA(e,{modelElement:"tableCell",...n})}function xv(t,e){if(!t.childCount)return;const n=new pp(t.document),o=function(t,e){const n=e.createRangeIn(t),o=new Wo({name:/^p|h\d+$/,styles:{"mso-list":/.*/}}),i=[];for(const t of n)if("elementStart"===t.type&&o.match(t.item)){const e=Sv(t.item);i.push({element:t.item,id:e.id,order:e.order,indent:e.indent})}return i}(t,n);if(!o.length)return;let i=null,r=1;o.forEach(((t,s)=>{const a=function(t,e){if(!t)return!0;if(t.id!==e.id)return e.indent-t.indent!=1;const n=e.element.previousSibling;if(!n)return!0;return o=n,!(o.is("element","ol")||o.is("element","ul"));var o}(o[s-1],t),c=a?null:o[s-1],l=(u=t,(d=c)?u.indent-d.indent:u.indent-1);var d,u;if(a&&(i=null,r=1),!i||0!==l){const o=function(t,e){const n=new RegExp(`@list l${t.id}:level${t.indent}\\s*({[^}]*)`,"gi"),o=/mso-level-number-format:([^;]{0,100});/gi,i=/mso-level-start-at:\s{0,100}([0-9]{0,10})\s{0,100};/gi,r=n.exec(e);let s="decimal",a="ol",c=null;if(r&&r[1]){const e=o.exec(r[1]);if(e&&e[1]&&(s=e[1].trim(),a="bullet"!==s&&"image"!==s?"ol":"ul"),"bullet"===s){const e=function(t){const e=function(t){if(t.getChild(0).is("$text"))return null;for(const e of t.getChildren()){if(!e.is("element","span"))continue;const t=e.getChild(0);return t.is("$text")?t:t.getChild(0)}}(t);if(!e)return null;const n=e._data;if("o"===n)return"circle";if("·"===n)return"disc";if("§"===n)return"square";return null}(t.element);e&&(s=e)}else{const t=i.exec(r[1]);t&&t[1]&&(c=parseInt(t[1]))}}return{type:a,startIndex:c,style:Ev(s)}}(t,e);if(i){if(t.indent>r){const t=i.getChild(i.childCount-1),e=t.getChild(t.childCount-1);i=Dv(o,e,n),r+=1}else if(t.indent1&&n.setAttribute("start",t.startIndex,i),i}function Sv(t){const e={},n=t.getStyle("mso-list");if(n){const t=n.match(/(^|\s{1,100})l(\d+)/i),o=n.match(/\s{0,100}lfo(\d+)/i),i=n.match(/\s{0,100}level(\d+)/i);t&&o&&i&&(e.id=t[2],e.order=o[1],e.indent=i[1])}return e}const Bv=/id=("|')docs-internal-guid-[-0-9a-f]+("|')/i;class Tv{constructor(t){this.document=t}isActive(t){return Bv.test(t)}execute(t){const e=new pp(this.document),{body:n}=t._parsedData;!function(t,e){for(const n of t.getChildren())if(n.is("element","b")&&"normal"===n.getStyle("font-weight")){const o=t.getChildIndex(n);e.remove(n),e.insertChild(o,n.getChildren(),t)}}(n,e),function(t,e){for(const n of e.createRangeIn(t)){const t=n.item;if(t.is("element","li")){const n=t.getChild(0);n&&n.is("element","p")&&e.unwrapElement(n)}}}(n,e),t.content=n}}function Pv(t,e){if(!t.childCount)return;const n=new pp,o=function(t,e){const n=e.createRangeIn(t),o=new Wo({name:/v:(.+)/}),i=[];for(const t of n){if("elementStart"!=t.type)continue;const e=t.item,n=e.previousSibling&&e.previousSibling.name||null;o.match(e)&&e.getAttribute("o:gfxdata")&&"v:shapetype"!==n&&i.push(t.item.getAttribute("id"))}return i}(t,n);!function(t,e,n){const o=n.createRangeIn(e),i=new Wo({name:"img"}),r=[];for(const e of o)if(i.match(e.item)){const n=e.item,o=n.getAttribute("v:shapes")?n.getAttribute("v:shapes").split(" "):[];o.length&&o.every((e=>t.indexOf(e)>-1))?r.push(n):n.getAttribute("src")||r.push(n)}for(const t of r)n.remove(t)}(o,t,n),function(t,e){const n=e.createRangeIn(t),o=new Wo({name:/v:(.+)/}),i=[];for(const t of n)"elementStart"==t.type&&o.match(t.item)&&i.push(t.item);for(const t of i)e.remove(t)}(t,n);const i=function(t,e){const n=e.createRangeIn(t),o=new Wo({name:"img"}),i=[];for(const t of n)o.match(t.item)&&t.item.getAttribute("src").startsWith("file://")&&i.push(t.item);return i}(t,n);i.length&&function(t,e,n){if(t.length===e.length)for(let o=0;oString.fromCharCode(parseInt(t,16)))).join(""))}const Rv=//i,zv=/xmlns:o="urn:schemas-microsoft-com/i;class Fv{constructor(t){this.document=t}isActive(t){return Rv.test(t)||zv.test(t)}execute(t){const{body:e,stylesString:n}=t._parsedData;xv(e,n),Pv(e,t.dataTransfer.getData("text/rtf")),t.content=e}}function Nv(t){return t.replace(/(\s+)<\/span>/g,((t,e)=>1===e.length?" ":Array(e.length+1).join("  ").substr(0,e.length)))}function Ov(t,e){const n=new DOMParser,o=function(t){return Nv(Nv(t)).replace(/([^\S\r\n]*?)[\r\n]+([^\S\r\n]*<\/span>)/g,"$1$2").replace(/<\/span>/g,"").replace(/ <\//g," <\/o:p>/g," ").replace(/( |\u00A0)<\/o:p>/g,"").replace(/>([^\S\r\n]*[\r\n]\s*)<")}(function(t){const e="",n="",o=t.indexOf(e);if(o<0)return t;const i=t.indexOf(n,o+e.length);return t.substring(0,o+e.length)+(i>=0?t.substring(i):"")}(t=t.replace(//,!0],[/^<\?/,/\?>/,!0],[/^/,!0],[/^/,!0],[new RegExp("^|$))","i"),/^$/,!0],[new RegExp(i.source+"\\s*$"),/^$/,!1]];t.exports=function(t,e,n,o){var i,s,a,c,l=t.bMarks[e]+t.tShift[e],d=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4)return!1;if(!t.md.options.html)return!1;if(60!==t.src.charCodeAt(l))return!1;for(c=t.src.slice(l,d),i=0;i{"use strict";t.exports=function(t,e,n){var o,i,r,s,a,c,l,d,u,h,p=e+1,m=t.md.block.ruler.getRules("paragraph");if(t.sCount[e]-t.blkIndent>=4)return!1;for(h=t.parentType,t.parentType="paragraph";p3)){if(t.sCount[p]>=t.blkIndent&&(c=t.bMarks[p]+t.tShift[p])<(l=t.eMarks[p])&&(45===(u=t.src.charCodeAt(c))||61===u)&&(c=t.skipChars(c,u),(c=t.skipSpaces(c))>=l)){d=61===u?1:2;break}if(!(t.sCount[p]<0)){for(i=!1,r=0,s=m.length;r{"use strict";var o=n(7022).isSpace;function i(t,e){var n,i,r,s;return i=t.bMarks[e]+t.tShift[e],r=t.eMarks[e],42!==(n=t.src.charCodeAt(i++))&&45!==n&&43!==n||i=s)return-1;if((n=t.src.charCodeAt(r++))<48||n>57)return-1;for(;;){if(r>=s)return-1;if(!((n=t.src.charCodeAt(r++))>=48&&n<=57)){if(41===n||46===n)break;return-1}if(r-i>=10)return-1}return r=4)return!1;if(t.listIndent>=0&&t.sCount[e]-t.listIndent>=4&&t.sCount[e]=t.blkIndent&&(z=!0),(S=r(t,e))>=0){if(h=!0,T=t.bMarks[e]+t.tShift[e],k=Number(t.src.slice(T,S-1)),z&&1!==k)return!1}else{if(!((S=i(t,e))>=0))return!1;h=!1}if(z&&t.skipSpaces(S)>=t.eMarks[e])return!1;if(b=t.src.charCodeAt(S-1),o)return!0;for(f=t.tokens.length,h?(R=t.push("ordered_list_open","ol",1),1!==k&&(R.attrs=[["start",k]])):R=t.push("bullet_list_open","ul",1),R.map=g=[e,0],R.markup=String.fromCharCode(b),_=e,B=!1,I=t.md.block.ruler.getRules("list"),v=t.parentType,t.parentType="list";_=w?1:C-u)>4&&(d=1),l=u+d,(R=t.push("list_item_open","li",1)).markup=String.fromCharCode(b),R.map=p=[e,0],h&&(R.info=t.src.slice(T,S-1)),E=t.tight,x=t.tShift[e],y=t.sCount[e],A=t.listIndent,t.listIndent=t.blkIndent,t.blkIndent=l,t.tight=!0,t.tShift[e]=a-t.bMarks[e],t.sCount[e]=C,a>=w&&t.isEmpty(e+1)?t.line=Math.min(t.line+2,n):t.md.block.tokenize(t,e,n,!0),t.tight&&!B||(F=!1),B=t.line-e>1&&t.isEmpty(t.line-1),t.blkIndent=t.listIndent,t.listIndent=A,t.tShift[e]=x,t.sCount[e]=y,t.tight=E,(R=t.push("list_item_close","li",-1)).markup=String.fromCharCode(b),_=e=t.line,p[1]=_,a=t.bMarks[e],_>=n)break;if(t.sCount[_]=4)break;for(P=!1,c=0,m=I.length;c{"use strict";t.exports=function(t,e){var n,o,i,r,s,a,c=e+1,l=t.md.block.ruler.getRules("paragraph"),d=t.lineMax;for(a=t.parentType,t.parentType="paragraph";c3||t.sCount[c]<0)){for(o=!1,i=0,r=l.length;i{"use strict";var o=n(7022).normalizeReference,i=n(7022).isSpace;t.exports=function(t,e,n,r){var s,a,c,l,d,u,h,p,m,g,f,b,k,w,_,C,A=0,v=t.bMarks[e]+t.tShift[e],y=t.eMarks[e],x=e+1;if(t.sCount[e]-t.blkIndent>=4)return!1;if(91!==t.src.charCodeAt(v))return!1;for(;++v3||t.sCount[x]<0)){for(w=!1,u=0,h=_.length;u{"use strict";var o=n(5872),i=n(7022).isSpace;function r(t,e,n,o){var r,s,a,c,l,d,u,h;for(this.src=t,this.md=e,this.env=n,this.tokens=o,this.bMarks=[],this.eMarks=[],this.tShift=[],this.sCount=[],this.bsCount=[],this.blkIndent=0,this.line=0,this.lineMax=0,this.tight=!1,this.ddIndent=-1,this.listIndent=-1,this.parentType="root",this.level=0,this.result="",h=!1,a=c=d=u=0,l=(s=this.src).length;c0&&this.level++,this.tokens.push(i),i},r.prototype.isEmpty=function(t){return this.bMarks[t]+this.tShift[t]>=this.eMarks[t]},r.prototype.skipEmptyLines=function(t){for(var e=this.lineMax;te;)if(!i(this.src.charCodeAt(--t)))return t+1;return t},r.prototype.skipChars=function(t,e){for(var n=this.src.length;tn;)if(e!==this.src.charCodeAt(--t))return t+1;return t},r.prototype.getLines=function(t,e,n,o){var r,s,a,c,l,d,u,h=t;if(t>=e)return"";for(d=new Array(e-t),r=0;hn?new Array(s-n+1).join(" ")+this.src.slice(c,l):this.src.slice(c,l)}return d.join("")},r.prototype.Token=o,t.exports=r},1785:(t,e,n)=>{"use strict";var o=n(7022).isSpace;function i(t,e){var n=t.bMarks[e]+t.tShift[e],o=t.eMarks[e];return t.src.substr(n,o-n)}function r(t){var e,n=[],o=0,i=t.length,r=!1,s=0,a="";for(e=t.charCodeAt(o);on)return!1;if(h=e+1,t.sCount[h]=4)return!1;if((l=t.bMarks[h]+t.tShift[h])>=t.eMarks[h])return!1;if(124!==(v=t.src.charCodeAt(l++))&&45!==v&&58!==v)return!1;if(l>=t.eMarks[h])return!1;if(124!==(y=t.src.charCodeAt(l++))&&45!==y&&58!==y&&!o(y))return!1;if(45===v&&o(y))return!1;for(;l=4)return!1;if((p=r(c)).length&&""===p[0]&&p.shift(),p.length&&""===p[p.length-1]&&p.pop(),0===(m=p.length)||m!==f.length)return!1;if(s)return!0;for(_=t.parentType,t.parentType="table",A=t.md.block.ruler.getRules("blockquote"),(g=t.push("table_open","table",1)).map=k=[e,0],(g=t.push("thead_open","thead",1)).map=[e,e+1],(g=t.push("tr_open","tr",1)).map=[e,e+1],d=0;d=4)break;for((p=r(c)).length&&""===p[0]&&p.shift(),p.length&&""===p[p.length-1]&&p.pop(),h===e+2&&((g=t.push("tbody_open","tbody",1)).map=w=[e+2,0]),(g=t.push("tr_open","tr",1)).map=[h,h+1],d=0;d{"use strict";t.exports=function(t){var e;t.inlineMode?((e=new t.Token("inline","",0)).content=t.src,e.map=[0,1],e.children=[],t.tokens.push(e)):t.md.block.parse(t.src,t.md,t.env,t.tokens)}},9827:t=>{"use strict";t.exports=function(t){var e,n,o,i=t.tokens;for(n=0,o=i.length;n{"use strict";var o=n(7022).arrayReplaceAt;function i(t){return/^<\/a\s*>/i.test(t)}t.exports=function(t){var e,n,r,s,a,c,l,d,u,h,p,m,g,f,b,k,w,_,C=t.tokens;if(t.md.options.linkify)for(n=0,r=C.length;n=0;e--)if("link_close"!==(c=s[e]).type){if("html_inline"===c.type&&(_=c.content,/^\s]/i.test(_)&&g>0&&g--,i(c.content)&&g++),!(g>0)&&"text"===c.type&&t.md.linkify.test(c.content)){for(u=c.content,w=t.md.linkify.match(u),l=[],m=c.level,p=0,d=0;dp&&((a=new t.Token("text","",0)).content=u.slice(p,h),a.level=m,l.push(a)),(a=new t.Token("link_open","a",1)).attrs=[["href",b]],a.level=m++,a.markup="linkify",a.info="auto",l.push(a),(a=new t.Token("text","",0)).content=k,a.level=m,l.push(a),(a=new t.Token("link_close","a",-1)).level=--m,a.markup="linkify",a.info="auto",l.push(a),p=w[d].lastIndex);p{"use strict";var e=/\r\n?|\n/g,n=/\0/g;t.exports=function(t){var o;o=(o=t.src.replace(e,"\n")).replace(n,"�"),t.src=o}},2834:t=>{"use strict";var e=/\+-|\.\.|\?\?\?\?|!!!!|,,|--/,n=/\((c|tm|r|p)\)/i,o=/\((c|tm|r|p)\)/gi,i={c:"©",r:"®",p:"§",tm:"™"};function r(t,e){return i[e.toLowerCase()]}function s(t){var e,n,i=0;for(e=t.length-1;e>=0;e--)"text"!==(n=t[e]).type||i||(n.content=n.content.replace(o,r)),"link_open"===n.type&&"auto"===n.info&&i--,"link_close"===n.type&&"auto"===n.info&&i++}function a(t){var n,o,i=0;for(n=t.length-1;n>=0;n--)"text"!==(o=t[n]).type||i||e.test(o.content)&&(o.content=o.content.replace(/\+-/g,"±").replace(/\.{2,}/g,"…").replace(/([?!])…/g,"$1..").replace(/([?!]){4,}/g,"$1$1$1").replace(/,{2,}/g,",").replace(/(^|[^-])---(?=[^-]|$)/gm,"$1—").replace(/(^|\s)--(?=\s|$)/gm,"$1–").replace(/(^|[^-\s])--(?=[^-\s]|$)/gm,"$1–")),"link_open"===o.type&&"auto"===o.info&&i--,"link_close"===o.type&&"auto"===o.info&&i++}t.exports=function(t){var o;if(t.md.options.typographer)for(o=t.tokens.length-1;o>=0;o--)"inline"===t.tokens[o].type&&(n.test(t.tokens[o].content)&&s(t.tokens[o].children),e.test(t.tokens[o].content)&&a(t.tokens[o].children))}},8450:(t,e,n)=>{"use strict";var o=n(7022).isWhiteSpace,i=n(7022).isPunctChar,r=n(7022).isMdAsciiPunct,s=/['"]/,a=/['"]/g;function c(t,e,n){return t.substr(0,e)+n+t.substr(e+1)}function l(t,e){var n,s,l,d,u,h,p,m,g,f,b,k,w,_,C,A,v,y,x,E,D;for(x=[],n=0;n=0&&!(x[v].level<=p);v--);if(x.length=v+1,"text"===s.type){u=0,h=(l=s.content).length;t:for(;u=0)g=l.charCodeAt(d.index-1);else for(v=n-1;v>=0&&("softbreak"!==t[v].type&&"hardbreak"!==t[v].type);v--)if(t[v].content){g=t[v].content.charCodeAt(t[v].content.length-1);break}if(f=32,u=48&&g<=57&&(A=C=!1),C&&A&&(C=b,A=k),C||A){if(A)for(v=x.length-1;v>=0&&(m=x[v],!(x[v].level=0;e--)"inline"===t.tokens[e].type&&s.test(t.tokens[e].content)&&l(t.tokens[e].children,t)}},6480:(t,e,n)=>{"use strict";var o=n(5872);function i(t,e,n){this.src=t,this.env=n,this.tokens=[],this.inlineMode=!1,this.md=e}i.prototype.Token=o,t.exports=i},3420:t=>{"use strict";var e=/^([a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)$/,n=/^([a-zA-Z][a-zA-Z0-9+.\-]{1,31}):([^<>\x00-\x20]*)$/;t.exports=function(t,o){var i,r,s,a,c,l,d=t.pos;if(60!==t.src.charCodeAt(d))return!1;for(c=t.pos,l=t.posMax;;){if(++d>=l)return!1;if(60===(a=t.src.charCodeAt(d)))return!1;if(62===a)break}return i=t.src.slice(c+1,d),n.test(i)?(r=t.md.normalizeLink(i),!!t.md.validateLink(r)&&(o||((s=t.push("link_open","a",1)).attrs=[["href",r]],s.markup="autolink",s.info="auto",(s=t.push("text","",0)).content=t.md.normalizeLinkText(i),(s=t.push("link_close","a",-1)).markup="autolink",s.info="auto"),t.pos+=i.length+2,!0)):!!e.test(i)&&(r=t.md.normalizeLink("mailto:"+i),!!t.md.validateLink(r)&&(o||((s=t.push("link_open","a",1)).attrs=[["href",r]],s.markup="autolink",s.info="auto",(s=t.push("text","",0)).content=t.md.normalizeLinkText(i),(s=t.push("link_close","a",-1)).markup="autolink",s.info="auto"),t.pos+=i.length+2,!0))}},9755:t=>{"use strict";t.exports=function(t,e){var n,o,i,r,s,a,c,l,d=t.pos;if(96!==t.src.charCodeAt(d))return!1;for(n=d,d++,o=t.posMax;d{"use strict";function e(t,e){var n,o,i,r,s,a,c,l,d={},u=e.length;if(u){var h=0,p=-2,m=[];for(n=0;ns;o-=m[o]+1)if((r=e[o]).marker===i.marker&&r.open&&r.end<0&&(c=!1,(r.close||i.open)&&(r.length+i.length)%3==0&&(r.length%3==0&&i.length%3==0||(c=!0)),!c)){l=o>0&&!e[o-1].open?m[o-1]+1:0,m[n]=n-o+l,m[o]=l,i.open=!1,r.end=n,r.close=!1,a=-1,p=-2;break}-1!==a&&(d[i.marker][(i.open?3:0)+(i.length||0)%3]=a)}}}t.exports=function(t){var n,o=t.tokens_meta,i=t.tokens_meta.length;for(e(0,t.delimiters),n=0;n{"use strict";function e(t,e){var n,o,i,r,s,a;for(n=e.length-1;n>=0;n--)95!==(o=e[n]).marker&&42!==o.marker||-1!==o.end&&(i=e[o.end],a=n>0&&e[n-1].end===o.end+1&&e[n-1].marker===o.marker&&e[n-1].token===o.token-1&&e[o.end+1].token===i.token+1,s=String.fromCharCode(o.marker),(r=t.tokens[o.token]).type=a?"strong_open":"em_open",r.tag=a?"strong":"em",r.nesting=1,r.markup=a?s+s:s,r.content="",(r=t.tokens[i.token]).type=a?"strong_close":"em_close",r.tag=a?"strong":"em",r.nesting=-1,r.markup=a?s+s:s,r.content="",a&&(t.tokens[e[n-1].token].content="",t.tokens[e[o.end+1].token].content="",n--))}t.exports.w=function(t,e){var n,o,i=t.pos,r=t.src.charCodeAt(i);if(e)return!1;if(95!==r&&42!==r)return!1;for(o=t.scanDelims(t.pos,42===r),n=0;n{"use strict";var o=n(6233),i=n(7022).has,r=n(7022).isValidEntityCode,s=n(7022).fromCodePoint,a=/^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i,c=/^&([a-z][a-z0-9]{1,31});/i;t.exports=function(t,e){var n,l,d=t.pos,u=t.posMax;if(38!==t.src.charCodeAt(d))return!1;if(d+1{"use strict";for(var o=n(7022).isSpace,i=[],r=0;r<256;r++)i.push(0);"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach((function(t){i[t.charCodeAt(0)]=1})),t.exports=function(t,e){var n,r=t.pos,s=t.posMax;if(92!==t.src.charCodeAt(r))return!1;if(++r{"use strict";var o=n(1947).n;t.exports=function(t,e){var n,i,r,s=t.pos;return!!t.md.options.html&&(r=t.posMax,!(60!==t.src.charCodeAt(s)||s+2>=r)&&(!(33!==(n=t.src.charCodeAt(s+1))&&63!==n&&47!==n&&!function(t){var e=32|t;return e>=97&&e<=122}(n))&&(!!(i=t.src.slice(s).match(o))&&(e||(t.push("html_inline","",0).content=t.src.slice(s,s+i[0].length)),t.pos+=i[0].length,!0))))}},3006:(t,e,n)=>{"use strict";var o=n(7022).normalizeReference,i=n(7022).isSpace;t.exports=function(t,e){var n,r,s,a,c,l,d,u,h,p,m,g,f,b="",k=t.pos,w=t.posMax;if(33!==t.src.charCodeAt(t.pos))return!1;if(91!==t.src.charCodeAt(t.pos+1))return!1;if(l=t.pos+2,(c=t.md.helpers.parseLinkLabel(t,t.pos+1,!1))<0)return!1;if((d=c+1)=w)return!1;for(f=d,(h=t.md.helpers.parseLinkDestination(t.src,d,t.posMax)).ok&&(b=t.md.normalizeLink(h.str),t.md.validateLink(b)?d=h.pos:b=""),f=d;d=w||41!==t.src.charCodeAt(d))return t.pos=k,!1;d++}else{if(void 0===t.env.references)return!1;if(d=0?a=t.src.slice(f,d++):d=c+1):d=c+1,a||(a=t.src.slice(l,c)),!(u=t.env.references[o(a)]))return t.pos=k,!1;b=u.href,p=u.title}return e||(s=t.src.slice(l,c),t.md.inline.parse(s,t.md,t.env,g=[]),(m=t.push("image","img",0)).attrs=n=[["src",b],["alt",""]],m.children=g,m.content=s,p&&n.push(["title",p])),t.pos=d,t.posMax=w,!0}},1727:(t,e,n)=>{"use strict";var o=n(7022).normalizeReference,i=n(7022).isSpace;t.exports=function(t,e){var n,r,s,a,c,l,d,u,h="",p="",m=t.pos,g=t.posMax,f=t.pos,b=!0;if(91!==t.src.charCodeAt(t.pos))return!1;if(c=t.pos+1,(a=t.md.helpers.parseLinkLabel(t,t.pos,!0))<0)return!1;if((l=a+1)=g)return!1;if(f=l,(d=t.md.helpers.parseLinkDestination(t.src,l,t.posMax)).ok){for(h=t.md.normalizeLink(d.str),t.md.validateLink(h)?l=d.pos:h="",f=l;l=g||41!==t.src.charCodeAt(l))&&(b=!0),l++}if(b){if(void 0===t.env.references)return!1;if(l=0?s=t.src.slice(f,l++):l=a+1):l=a+1,s||(s=t.src.slice(c,a)),!(u=t.env.references[o(s)]))return t.pos=m,!1;h=u.href,p=u.title}return e||(t.pos=c,t.posMax=a,t.push("link_open","a",1).attrs=n=[["href",h]],p&&n.push(["title",p]),t.md.inline.tokenize(t),t.push("link_close","a",-1)),t.pos=l,t.posMax=g,!0}},3905:(t,e,n)=>{"use strict";var o=n(7022).isSpace;t.exports=function(t,e){var n,i,r,s=t.pos;if(10!==t.src.charCodeAt(s))return!1;if(n=t.pending.length-1,i=t.posMax,!e)if(n>=0&&32===t.pending.charCodeAt(n))if(n>=1&&32===t.pending.charCodeAt(n-1)){for(r=n-1;r>=1&&32===t.pending.charCodeAt(r-1);)r--;t.pending=t.pending.slice(0,r),t.push("hardbreak","br",0)}else t.pending=t.pending.slice(0,-1),t.push("softbreak","br",0);else t.push("softbreak","br",0);for(s++;s{"use strict";var o=n(5872),i=n(7022).isWhiteSpace,r=n(7022).isPunctChar,s=n(7022).isMdAsciiPunct;function a(t,e,n,o){this.src=t,this.env=n,this.md=e,this.tokens=o,this.tokens_meta=Array(o.length),this.pos=0,this.posMax=this.src.length,this.level=0,this.pending="",this.pendingLevel=0,this.cache={},this.delimiters=[],this._prev_delimiters=[],this.backticks={},this.backticksScanned=!1}a.prototype.pushPending=function(){var t=new o("text","",0);return t.content=this.pending,t.level=this.pendingLevel,this.tokens.push(t),this.pending="",t},a.prototype.push=function(t,e,n){this.pending&&this.pushPending();var i=new o(t,e,n),r=null;return n<0&&(this.level--,this.delimiters=this._prev_delimiters.pop()),i.level=this.level,n>0&&(this.level++,this._prev_delimiters.push(this.delimiters),this.delimiters=[],r={delimiters:this.delimiters}),this.pendingLevel=this.level,this.tokens.push(i),this.tokens_meta.push(r),i},a.prototype.scanDelims=function(t,e){var n,o,a,c,l,d,u,h,p,m=t,g=!0,f=!0,b=this.posMax,k=this.src.charCodeAt(t);for(n=t>0?this.src.charCodeAt(t-1):32;m{"use strict";function e(t,e){var n,o,i,r,s,a=[],c=e.length;for(n=0;n{"use strict";function e(t){switch(t){case 10:case 33:case 35:case 36:case 37:case 38:case 42:case 43:case 45:case 58:case 60:case 61:case 62:case 64:case 91:case 92:case 93:case 94:case 95:case 96:case 123:case 125:case 126:return!0;default:return!1}}t.exports=function(t,n){for(var o=t.pos;o{"use strict";t.exports=function(t){var e,n,o=0,i=t.tokens,r=t.tokens.length;for(e=n=0;e0&&o++,"text"===i[e].type&&e+1{"use strict";function e(t,e,n){this.type=t,this.tag=e,this.attrs=null,this.map=null,this.nesting=n,this.level=0,this.children=null,this.content="",this.markup="",this.info="",this.meta=null,this.block=!1,this.hidden=!1}e.prototype.attrIndex=function(t){var e,n,o;if(!this.attrs)return-1;for(n=0,o=(e=this.attrs).length;n=0&&(n=this.attrs[e][1]),n},e.prototype.attrJoin=function(t,e){var n=this.attrIndex(t);n<0?this.attrPush([t,e]):this.attrs[n][1]=this.attrs[n][1]+" "+e},t.exports=e},3122:t=>{"use strict";var e={};function n(t,o){var i;return"string"!=typeof o&&(o=n.defaultChars),i=function(t){var n,o,i=e[t];if(i)return i;for(i=e[t]=[],n=0;n<128;n++)o=String.fromCharCode(n),i.push(o);for(n=0;n=55296&&c<=57343?"���":String.fromCharCode(c),e+=6):240==(248&o)&&e+91114111?l+="����":(c-=65536,l+=String.fromCharCode(55296+(c>>10),56320+(1023&c))),e+=9):l+="�";return l}))}n.defaultChars=";/?:@&=+$,#",n.componentChars="",t.exports=n},729:t=>{"use strict";var e={};function n(t,o,i){var r,s,a,c,l,d="";for("string"!=typeof o&&(i=o,o=n.defaultChars),void 0===i&&(i=!0),l=function(t){var n,o,i=e[t];if(i)return i;for(i=e[t]=[],n=0;n<128;n++)o=String.fromCharCode(n),/^[0-9a-z]$/i.test(o)?i.push(o):i.push("%"+("0"+n.toString(16).toUpperCase()).slice(-2));for(n=0;n=55296&&a<=57343){if(a>=55296&&a<=56319&&r+1=56320&&c<=57343){d+=encodeURIComponent(t[r]+t[r+1]),r++;continue}d+="%EF%BF%BD"}else d+=encodeURIComponent(t[r]);return d}n.defaultChars=";/?:@&=+$,-_.!~*'()#",n.componentChars="-_.!~*'()",t.exports=n},2201:t=>{"use strict";t.exports=function(t){var e="";return e+=t.protocol||"",e+=t.slashes?"//":"",e+=t.auth?t.auth+"@":"",t.hostname&&-1!==t.hostname.indexOf(":")?e+="["+t.hostname+"]":e+=t.hostname||"",e+=t.port?":"+t.port:"",e+=t.pathname||"",e+=t.search||"",e+=t.hash||""}},8765:(t,e,n)=>{"use strict";t.exports.encode=n(729),t.exports.decode=n(3122),t.exports.format=n(2201),t.exports.parse=n(9553)},9553:t=>{"use strict";function e(){this.protocol=null,this.slashes=null,this.auth=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.pathname=null}var n=/^([a-z0-9.+-]+:)/i,o=/:[0-9]*$/,i=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,r=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),s=["'"].concat(r),a=["%","/","?",";","#"].concat(s),c=["/","?","#"],l=/^[+a-z0-9A-Z_-]{0,63}$/,d=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,u={javascript:!0,"javascript:":!0},h={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};e.prototype.parse=function(t,e){var o,r,s,p,m,g=t;if(g=g.trim(),!e&&1===t.split("#").length){var f=i.exec(g);if(f)return this.pathname=f[1],f[2]&&(this.search=f[2]),this}var b=n.exec(g);if(b&&(s=(b=b[0]).toLowerCase(),this.protocol=b,g=g.substr(b.length)),(e||b||g.match(/^\/\/[^@\/]+@[^@\/]+/))&&(!(m="//"===g.substr(0,2))||b&&u[b]||(g=g.substr(2),this.slashes=!0)),!u[b]&&(m||b&&!h[b])){var k,w,_=-1;for(o=0;o127?x+="x":x+=y[E];if(!x.match(l)){var S=v.slice(0,o),B=v.slice(o+1),T=y.match(d);T&&(S.push(T[1]),B.unshift(T[2])),B.length&&(g=B.join(".")+g),this.hostname=S.join(".");break}}}}this.hostname.length>255&&(this.hostname=""),A&&(this.hostname=this.hostname.substr(1,this.hostname.length-2))}var P=g.indexOf("#");-1!==P&&(this.hash=g.substr(P),g=g.slice(0,P));var I=g.indexOf("?");return-1!==I&&(this.search=g.substr(I),g=g.slice(0,I)),g&&(this.pathname=g),h[s]&&this.hostname&&!this.pathname&&(this.pathname=""),this},e.prototype.parseHost=function(t){var e=o.exec(t);e&&(":"!==(e=e[0])&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)},t.exports=function(t,n){if(t&&t instanceof e)return t;var o=new e;return o.parse(t,n),o}},3689:(t,e,n)=>{"use strict";n.r(e),n.d(e,{ucs2decode:()=>p,ucs2encode:()=>m,decode:()=>b,encode:()=>k,toASCII:()=>_,toUnicode:()=>w,default:()=>C});const o=2147483647,i=36,r=/^xn--/,s=/[^\0-\x7E]/,a=/[\x2E\u3002\uFF0E\uFF61]/g,c={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},l=Math.floor,d=String.fromCharCode;function u(t){throw new RangeError(c[t])}function h(t,e){const n=t.split("@");let o="";n.length>1&&(o=n[0]+"@",t=n[1]);const i=function(t,e){const n=[];let o=t.length;for(;o--;)n[o]=e(t[o]);return n}((t=t.replace(a,".")).split("."),e).join(".");return o+i}function p(t){const e=[];let n=0;const o=t.length;for(;n=55296&&i<=56319&&nString.fromCodePoint(...t),g=function(t,e){return t+22+75*(t<26)-((0!=e)<<5)},f=function(t,e,n){let o=0;for(t=n?l(t/700):t>>1,t+=l(t/e);t>455;o+=i)t=l(t/35);return l(o+36*t/(t+38))},b=function(t){const e=[],n=t.length;let r=0,s=128,a=72,c=t.lastIndexOf("-");c<0&&(c=0);for(let n=0;n=128&&u("not-basic"),e.push(t.charCodeAt(n));for(let h=c>0?c+1:0;h=n&&u("invalid-input");const c=(d=t.charCodeAt(h++))-48<10?d-22:d-65<26?d-65:d-97<26?d-97:i;(c>=i||c>l((o-r)/e))&&u("overflow"),r+=c*e;const p=s<=a?1:s>=a+26?26:s-a;if(cl(o/m)&&u("overflow"),e*=m}const p=e.length+1;a=f(r-c,p,0==c),l(r/p)>o-s&&u("overflow"),s+=l(r/p),r%=p,e.splice(r++,0,s)}var d;return String.fromCodePoint(...e)},k=function(t){const e=[];let n=(t=p(t)).length,r=128,s=0,a=72;for(const n of t)n<128&&e.push(d(n));let c=e.length,h=c;for(c&&e.push("-");h=r&&el((o-s)/p)&&u("overflow"),s+=(n-r)*p,r=n;for(const n of t)if(no&&u("overflow"),n==r){let t=s;for(let n=i;;n+=i){const o=n<=a?1:n>=a+26?26:n-a;if(t{"use strict";var e=[];function n(t){for(var n=-1,o=0;o{"use strict";var e={};t.exports=function(t,n){var o=function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(t){n=null}e[t]=n}return e[t]}(t);if(!o)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");o.appendChild(n)}},9216:t=>{"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},8575:t=>{"use strict";t.exports=function(t,e){Object.keys(e).forEach((function(n){t.setAttribute(n,e[n])}))}},9037:t=>{"use strict";var e,n=(e=[],function(t,n){return e[t]=n,e.filter(Boolean).join("\n")});function o(t,e,o,i){var r;if(o)r="";else{r="",i.supports&&(r+="@supports (".concat(i.supports,") {")),i.media&&(r+="@media ".concat(i.media," {"));var s=void 0!==i.layer;s&&(r+="@layer".concat(i.layer.length>0?" ".concat(i.layer):""," {")),r+=i.css,s&&(r+="}"),i.media&&(r+="}"),i.supports&&(r+="}")}if(t.styleSheet)t.styleSheet.cssText=n(e,r);else{var a=document.createTextNode(r),c=t.childNodes;c[e]&&t.removeChild(c[e]),c.length?t.insertBefore(a,c[e]):t.appendChild(a)}}var i={singleton:null,singletonCounter:0};t.exports=function(t){var e=i.singletonCounter++,n=i.singleton||(i.singleton=t.insertStyleElement(t));return{update:function(t){o(n,e,!1,t)},remove:function(t){o(n,e,!0,t)}}}},9413:t=>{t.exports=/[\0-\x1F\x7F-\x9F]/},2326:t=>{t.exports=/[\xAD\u0600-\u0605\u061C\u06DD\u070F\u08E2\u180E\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u206F\uFEFF\uFFF9-\uFFFB]|\uD804[\uDCBD\uDCCD]|\uD82F[\uDCA0-\uDCA3]|\uD834[\uDD73-\uDD7A]|\uDB40[\uDC01\uDC20-\uDC7F]/},3189:t=>{t.exports=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4E\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDF55-\uDF59]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDF3C-\uDF3E]|\uD806[\uDC3B\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/},5045:t=>{t.exports=/[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/},4205:(t,e,n)=>{"use strict";e.Any=n(9369),e.Cc=n(9413),e.Cf=n(2326),e.P=n(3189),e.Z=n(5045)},9369:t=>{t.exports=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/},5485:t=>{"use strict";t.exports=JSON.parse('{"Aacute":"Á","aacute":"á","Abreve":"Ă","abreve":"ă","ac":"∾","acd":"∿","acE":"∾̳","Acirc":"Â","acirc":"â","acute":"´","Acy":"А","acy":"а","AElig":"Æ","aelig":"æ","af":"⁡","Afr":"𝔄","afr":"𝔞","Agrave":"À","agrave":"à","alefsym":"ℵ","aleph":"ℵ","Alpha":"Α","alpha":"α","Amacr":"Ā","amacr":"ā","amalg":"⨿","amp":"&","AMP":"&","andand":"⩕","And":"⩓","and":"∧","andd":"⩜","andslope":"⩘","andv":"⩚","ang":"∠","ange":"⦤","angle":"∠","angmsdaa":"⦨","angmsdab":"⦩","angmsdac":"⦪","angmsdad":"⦫","angmsdae":"⦬","angmsdaf":"⦭","angmsdag":"⦮","angmsdah":"⦯","angmsd":"∡","angrt":"∟","angrtvb":"⊾","angrtvbd":"⦝","angsph":"∢","angst":"Å","angzarr":"⍼","Aogon":"Ą","aogon":"ą","Aopf":"𝔸","aopf":"𝕒","apacir":"⩯","ap":"≈","apE":"⩰","ape":"≊","apid":"≋","apos":"\'","ApplyFunction":"⁡","approx":"≈","approxeq":"≊","Aring":"Å","aring":"å","Ascr":"𝒜","ascr":"𝒶","Assign":"≔","ast":"*","asymp":"≈","asympeq":"≍","Atilde":"Ã","atilde":"ã","Auml":"Ä","auml":"ä","awconint":"∳","awint":"⨑","backcong":"≌","backepsilon":"϶","backprime":"‵","backsim":"∽","backsimeq":"⋍","Backslash":"∖","Barv":"⫧","barvee":"⊽","barwed":"⌅","Barwed":"⌆","barwedge":"⌅","bbrk":"⎵","bbrktbrk":"⎶","bcong":"≌","Bcy":"Б","bcy":"б","bdquo":"„","becaus":"∵","because":"∵","Because":"∵","bemptyv":"⦰","bepsi":"϶","bernou":"ℬ","Bernoullis":"ℬ","Beta":"Β","beta":"β","beth":"ℶ","between":"≬","Bfr":"𝔅","bfr":"𝔟","bigcap":"⋂","bigcirc":"◯","bigcup":"⋃","bigodot":"⨀","bigoplus":"⨁","bigotimes":"⨂","bigsqcup":"⨆","bigstar":"★","bigtriangledown":"▽","bigtriangleup":"△","biguplus":"⨄","bigvee":"⋁","bigwedge":"⋀","bkarow":"⤍","blacklozenge":"⧫","blacksquare":"▪","blacktriangle":"▴","blacktriangledown":"▾","blacktriangleleft":"◂","blacktriangleright":"▸","blank":"␣","blk12":"▒","blk14":"░","blk34":"▓","block":"█","bne":"=⃥","bnequiv":"≡⃥","bNot":"⫭","bnot":"⌐","Bopf":"𝔹","bopf":"𝕓","bot":"⊥","bottom":"⊥","bowtie":"⋈","boxbox":"⧉","boxdl":"┐","boxdL":"╕","boxDl":"╖","boxDL":"╗","boxdr":"┌","boxdR":"╒","boxDr":"╓","boxDR":"╔","boxh":"─","boxH":"═","boxhd":"┬","boxHd":"╤","boxhD":"╥","boxHD":"╦","boxhu":"┴","boxHu":"╧","boxhU":"╨","boxHU":"╩","boxminus":"⊟","boxplus":"⊞","boxtimes":"⊠","boxul":"┘","boxuL":"╛","boxUl":"╜","boxUL":"╝","boxur":"└","boxuR":"╘","boxUr":"╙","boxUR":"╚","boxv":"│","boxV":"║","boxvh":"┼","boxvH":"╪","boxVh":"╫","boxVH":"╬","boxvl":"┤","boxvL":"╡","boxVl":"╢","boxVL":"╣","boxvr":"├","boxvR":"╞","boxVr":"╟","boxVR":"╠","bprime":"‵","breve":"˘","Breve":"˘","brvbar":"¦","bscr":"𝒷","Bscr":"ℬ","bsemi":"⁏","bsim":"∽","bsime":"⋍","bsolb":"⧅","bsol":"\\\\","bsolhsub":"⟈","bull":"•","bullet":"•","bump":"≎","bumpE":"⪮","bumpe":"≏","Bumpeq":"≎","bumpeq":"≏","Cacute":"Ć","cacute":"ć","capand":"⩄","capbrcup":"⩉","capcap":"⩋","cap":"∩","Cap":"⋒","capcup":"⩇","capdot":"⩀","CapitalDifferentialD":"ⅅ","caps":"∩︀","caret":"⁁","caron":"ˇ","Cayleys":"ℭ","ccaps":"⩍","Ccaron":"Č","ccaron":"č","Ccedil":"Ç","ccedil":"ç","Ccirc":"Ĉ","ccirc":"ĉ","Cconint":"∰","ccups":"⩌","ccupssm":"⩐","Cdot":"Ċ","cdot":"ċ","cedil":"¸","Cedilla":"¸","cemptyv":"⦲","cent":"¢","centerdot":"·","CenterDot":"·","cfr":"𝔠","Cfr":"ℭ","CHcy":"Ч","chcy":"ч","check":"✓","checkmark":"✓","Chi":"Χ","chi":"χ","circ":"ˆ","circeq":"≗","circlearrowleft":"↺","circlearrowright":"↻","circledast":"⊛","circledcirc":"⊚","circleddash":"⊝","CircleDot":"⊙","circledR":"®","circledS":"Ⓢ","CircleMinus":"⊖","CirclePlus":"⊕","CircleTimes":"⊗","cir":"○","cirE":"⧃","cire":"≗","cirfnint":"⨐","cirmid":"⫯","cirscir":"⧂","ClockwiseContourIntegral":"∲","CloseCurlyDoubleQuote":"”","CloseCurlyQuote":"’","clubs":"♣","clubsuit":"♣","colon":":","Colon":"∷","Colone":"⩴","colone":"≔","coloneq":"≔","comma":",","commat":"@","comp":"∁","compfn":"∘","complement":"∁","complexes":"ℂ","cong":"≅","congdot":"⩭","Congruent":"≡","conint":"∮","Conint":"∯","ContourIntegral":"∮","copf":"𝕔","Copf":"ℂ","coprod":"∐","Coproduct":"∐","copy":"©","COPY":"©","copysr":"℗","CounterClockwiseContourIntegral":"∳","crarr":"↵","cross":"✗","Cross":"⨯","Cscr":"𝒞","cscr":"𝒸","csub":"⫏","csube":"⫑","csup":"⫐","csupe":"⫒","ctdot":"⋯","cudarrl":"⤸","cudarrr":"⤵","cuepr":"⋞","cuesc":"⋟","cularr":"↶","cularrp":"⤽","cupbrcap":"⩈","cupcap":"⩆","CupCap":"≍","cup":"∪","Cup":"⋓","cupcup":"⩊","cupdot":"⊍","cupor":"⩅","cups":"∪︀","curarr":"↷","curarrm":"⤼","curlyeqprec":"⋞","curlyeqsucc":"⋟","curlyvee":"⋎","curlywedge":"⋏","curren":"¤","curvearrowleft":"↶","curvearrowright":"↷","cuvee":"⋎","cuwed":"⋏","cwconint":"∲","cwint":"∱","cylcty":"⌭","dagger":"†","Dagger":"‡","daleth":"ℸ","darr":"↓","Darr":"↡","dArr":"⇓","dash":"‐","Dashv":"⫤","dashv":"⊣","dbkarow":"⤏","dblac":"˝","Dcaron":"Ď","dcaron":"ď","Dcy":"Д","dcy":"д","ddagger":"‡","ddarr":"⇊","DD":"ⅅ","dd":"ⅆ","DDotrahd":"⤑","ddotseq":"⩷","deg":"°","Del":"∇","Delta":"Δ","delta":"δ","demptyv":"⦱","dfisht":"⥿","Dfr":"𝔇","dfr":"𝔡","dHar":"⥥","dharl":"⇃","dharr":"⇂","DiacriticalAcute":"´","DiacriticalDot":"˙","DiacriticalDoubleAcute":"˝","DiacriticalGrave":"`","DiacriticalTilde":"˜","diam":"⋄","diamond":"⋄","Diamond":"⋄","diamondsuit":"♦","diams":"♦","die":"¨","DifferentialD":"ⅆ","digamma":"ϝ","disin":"⋲","div":"÷","divide":"÷","divideontimes":"⋇","divonx":"⋇","DJcy":"Ђ","djcy":"ђ","dlcorn":"⌞","dlcrop":"⌍","dollar":"$","Dopf":"𝔻","dopf":"𝕕","Dot":"¨","dot":"˙","DotDot":"⃜","doteq":"≐","doteqdot":"≑","DotEqual":"≐","dotminus":"∸","dotplus":"∔","dotsquare":"⊡","doublebarwedge":"⌆","DoubleContourIntegral":"∯","DoubleDot":"¨","DoubleDownArrow":"⇓","DoubleLeftArrow":"⇐","DoubleLeftRightArrow":"⇔","DoubleLeftTee":"⫤","DoubleLongLeftArrow":"⟸","DoubleLongLeftRightArrow":"⟺","DoubleLongRightArrow":"⟹","DoubleRightArrow":"⇒","DoubleRightTee":"⊨","DoubleUpArrow":"⇑","DoubleUpDownArrow":"⇕","DoubleVerticalBar":"∥","DownArrowBar":"⤓","downarrow":"↓","DownArrow":"↓","Downarrow":"⇓","DownArrowUpArrow":"⇵","DownBreve":"̑","downdownarrows":"⇊","downharpoonleft":"⇃","downharpoonright":"⇂","DownLeftRightVector":"⥐","DownLeftTeeVector":"⥞","DownLeftVectorBar":"⥖","DownLeftVector":"↽","DownRightTeeVector":"⥟","DownRightVectorBar":"⥗","DownRightVector":"⇁","DownTeeArrow":"↧","DownTee":"⊤","drbkarow":"⤐","drcorn":"⌟","drcrop":"⌌","Dscr":"𝒟","dscr":"𝒹","DScy":"Ѕ","dscy":"ѕ","dsol":"⧶","Dstrok":"Đ","dstrok":"đ","dtdot":"⋱","dtri":"▿","dtrif":"▾","duarr":"⇵","duhar":"⥯","dwangle":"⦦","DZcy":"Џ","dzcy":"џ","dzigrarr":"⟿","Eacute":"É","eacute":"é","easter":"⩮","Ecaron":"Ě","ecaron":"ě","Ecirc":"Ê","ecirc":"ê","ecir":"≖","ecolon":"≕","Ecy":"Э","ecy":"э","eDDot":"⩷","Edot":"Ė","edot":"ė","eDot":"≑","ee":"ⅇ","efDot":"≒","Efr":"𝔈","efr":"𝔢","eg":"⪚","Egrave":"È","egrave":"è","egs":"⪖","egsdot":"⪘","el":"⪙","Element":"∈","elinters":"⏧","ell":"ℓ","els":"⪕","elsdot":"⪗","Emacr":"Ē","emacr":"ē","empty":"∅","emptyset":"∅","EmptySmallSquare":"◻","emptyv":"∅","EmptyVerySmallSquare":"▫","emsp13":" ","emsp14":" ","emsp":" ","ENG":"Ŋ","eng":"ŋ","ensp":" ","Eogon":"Ę","eogon":"ę","Eopf":"𝔼","eopf":"𝕖","epar":"⋕","eparsl":"⧣","eplus":"⩱","epsi":"ε","Epsilon":"Ε","epsilon":"ε","epsiv":"ϵ","eqcirc":"≖","eqcolon":"≕","eqsim":"≂","eqslantgtr":"⪖","eqslantless":"⪕","Equal":"⩵","equals":"=","EqualTilde":"≂","equest":"≟","Equilibrium":"⇌","equiv":"≡","equivDD":"⩸","eqvparsl":"⧥","erarr":"⥱","erDot":"≓","escr":"ℯ","Escr":"ℰ","esdot":"≐","Esim":"⩳","esim":"≂","Eta":"Η","eta":"η","ETH":"Ð","eth":"ð","Euml":"Ë","euml":"ë","euro":"€","excl":"!","exist":"∃","Exists":"∃","expectation":"ℰ","exponentiale":"ⅇ","ExponentialE":"ⅇ","fallingdotseq":"≒","Fcy":"Ф","fcy":"ф","female":"♀","ffilig":"ffi","fflig":"ff","ffllig":"ffl","Ffr":"𝔉","ffr":"𝔣","filig":"fi","FilledSmallSquare":"◼","FilledVerySmallSquare":"▪","fjlig":"fj","flat":"♭","fllig":"fl","fltns":"▱","fnof":"ƒ","Fopf":"𝔽","fopf":"𝕗","forall":"∀","ForAll":"∀","fork":"⋔","forkv":"⫙","Fouriertrf":"ℱ","fpartint":"⨍","frac12":"½","frac13":"⅓","frac14":"¼","frac15":"⅕","frac16":"⅙","frac18":"⅛","frac23":"⅔","frac25":"⅖","frac34":"¾","frac35":"⅗","frac38":"⅜","frac45":"⅘","frac56":"⅚","frac58":"⅝","frac78":"⅞","frasl":"⁄","frown":"⌢","fscr":"𝒻","Fscr":"ℱ","gacute":"ǵ","Gamma":"Γ","gamma":"γ","Gammad":"Ϝ","gammad":"ϝ","gap":"⪆","Gbreve":"Ğ","gbreve":"ğ","Gcedil":"Ģ","Gcirc":"Ĝ","gcirc":"ĝ","Gcy":"Г","gcy":"г","Gdot":"Ġ","gdot":"ġ","ge":"≥","gE":"≧","gEl":"⪌","gel":"⋛","geq":"≥","geqq":"≧","geqslant":"⩾","gescc":"⪩","ges":"⩾","gesdot":"⪀","gesdoto":"⪂","gesdotol":"⪄","gesl":"⋛︀","gesles":"⪔","Gfr":"𝔊","gfr":"𝔤","gg":"≫","Gg":"⋙","ggg":"⋙","gimel":"ℷ","GJcy":"Ѓ","gjcy":"ѓ","gla":"⪥","gl":"≷","glE":"⪒","glj":"⪤","gnap":"⪊","gnapprox":"⪊","gne":"⪈","gnE":"≩","gneq":"⪈","gneqq":"≩","gnsim":"⋧","Gopf":"𝔾","gopf":"𝕘","grave":"`","GreaterEqual":"≥","GreaterEqualLess":"⋛","GreaterFullEqual":"≧","GreaterGreater":"⪢","GreaterLess":"≷","GreaterSlantEqual":"⩾","GreaterTilde":"≳","Gscr":"𝒢","gscr":"ℊ","gsim":"≳","gsime":"⪎","gsiml":"⪐","gtcc":"⪧","gtcir":"⩺","gt":">","GT":">","Gt":"≫","gtdot":"⋗","gtlPar":"⦕","gtquest":"⩼","gtrapprox":"⪆","gtrarr":"⥸","gtrdot":"⋗","gtreqless":"⋛","gtreqqless":"⪌","gtrless":"≷","gtrsim":"≳","gvertneqq":"≩︀","gvnE":"≩︀","Hacek":"ˇ","hairsp":" ","half":"½","hamilt":"ℋ","HARDcy":"Ъ","hardcy":"ъ","harrcir":"⥈","harr":"↔","hArr":"⇔","harrw":"↭","Hat":"^","hbar":"ℏ","Hcirc":"Ĥ","hcirc":"ĥ","hearts":"♥","heartsuit":"♥","hellip":"…","hercon":"⊹","hfr":"𝔥","Hfr":"ℌ","HilbertSpace":"ℋ","hksearow":"⤥","hkswarow":"⤦","hoarr":"⇿","homtht":"∻","hookleftarrow":"↩","hookrightarrow":"↪","hopf":"𝕙","Hopf":"ℍ","horbar":"―","HorizontalLine":"─","hscr":"𝒽","Hscr":"ℋ","hslash":"ℏ","Hstrok":"Ħ","hstrok":"ħ","HumpDownHump":"≎","HumpEqual":"≏","hybull":"⁃","hyphen":"‐","Iacute":"Í","iacute":"í","ic":"⁣","Icirc":"Î","icirc":"î","Icy":"И","icy":"и","Idot":"İ","IEcy":"Е","iecy":"е","iexcl":"¡","iff":"⇔","ifr":"𝔦","Ifr":"ℑ","Igrave":"Ì","igrave":"ì","ii":"ⅈ","iiiint":"⨌","iiint":"∭","iinfin":"⧜","iiota":"℩","IJlig":"IJ","ijlig":"ij","Imacr":"Ī","imacr":"ī","image":"ℑ","ImaginaryI":"ⅈ","imagline":"ℐ","imagpart":"ℑ","imath":"ı","Im":"ℑ","imof":"⊷","imped":"Ƶ","Implies":"⇒","incare":"℅","in":"∈","infin":"∞","infintie":"⧝","inodot":"ı","intcal":"⊺","int":"∫","Int":"∬","integers":"ℤ","Integral":"∫","intercal":"⊺","Intersection":"⋂","intlarhk":"⨗","intprod":"⨼","InvisibleComma":"⁣","InvisibleTimes":"⁢","IOcy":"Ё","iocy":"ё","Iogon":"Į","iogon":"į","Iopf":"𝕀","iopf":"𝕚","Iota":"Ι","iota":"ι","iprod":"⨼","iquest":"¿","iscr":"𝒾","Iscr":"ℐ","isin":"∈","isindot":"⋵","isinE":"⋹","isins":"⋴","isinsv":"⋳","isinv":"∈","it":"⁢","Itilde":"Ĩ","itilde":"ĩ","Iukcy":"І","iukcy":"і","Iuml":"Ï","iuml":"ï","Jcirc":"Ĵ","jcirc":"ĵ","Jcy":"Й","jcy":"й","Jfr":"𝔍","jfr":"𝔧","jmath":"ȷ","Jopf":"𝕁","jopf":"𝕛","Jscr":"𝒥","jscr":"𝒿","Jsercy":"Ј","jsercy":"ј","Jukcy":"Є","jukcy":"є","Kappa":"Κ","kappa":"κ","kappav":"ϰ","Kcedil":"Ķ","kcedil":"ķ","Kcy":"К","kcy":"к","Kfr":"𝔎","kfr":"𝔨","kgreen":"ĸ","KHcy":"Х","khcy":"х","KJcy":"Ќ","kjcy":"ќ","Kopf":"𝕂","kopf":"𝕜","Kscr":"𝒦","kscr":"𝓀","lAarr":"⇚","Lacute":"Ĺ","lacute":"ĺ","laemptyv":"⦴","lagran":"ℒ","Lambda":"Λ","lambda":"λ","lang":"⟨","Lang":"⟪","langd":"⦑","langle":"⟨","lap":"⪅","Laplacetrf":"ℒ","laquo":"«","larrb":"⇤","larrbfs":"⤟","larr":"←","Larr":"↞","lArr":"⇐","larrfs":"⤝","larrhk":"↩","larrlp":"↫","larrpl":"⤹","larrsim":"⥳","larrtl":"↢","latail":"⤙","lAtail":"⤛","lat":"⪫","late":"⪭","lates":"⪭︀","lbarr":"⤌","lBarr":"⤎","lbbrk":"❲","lbrace":"{","lbrack":"[","lbrke":"⦋","lbrksld":"⦏","lbrkslu":"⦍","Lcaron":"Ľ","lcaron":"ľ","Lcedil":"Ļ","lcedil":"ļ","lceil":"⌈","lcub":"{","Lcy":"Л","lcy":"л","ldca":"⤶","ldquo":"“","ldquor":"„","ldrdhar":"⥧","ldrushar":"⥋","ldsh":"↲","le":"≤","lE":"≦","LeftAngleBracket":"⟨","LeftArrowBar":"⇤","leftarrow":"←","LeftArrow":"←","Leftarrow":"⇐","LeftArrowRightArrow":"⇆","leftarrowtail":"↢","LeftCeiling":"⌈","LeftDoubleBracket":"⟦","LeftDownTeeVector":"⥡","LeftDownVectorBar":"⥙","LeftDownVector":"⇃","LeftFloor":"⌊","leftharpoondown":"↽","leftharpoonup":"↼","leftleftarrows":"⇇","leftrightarrow":"↔","LeftRightArrow":"↔","Leftrightarrow":"⇔","leftrightarrows":"⇆","leftrightharpoons":"⇋","leftrightsquigarrow":"↭","LeftRightVector":"⥎","LeftTeeArrow":"↤","LeftTee":"⊣","LeftTeeVector":"⥚","leftthreetimes":"⋋","LeftTriangleBar":"⧏","LeftTriangle":"⊲","LeftTriangleEqual":"⊴","LeftUpDownVector":"⥑","LeftUpTeeVector":"⥠","LeftUpVectorBar":"⥘","LeftUpVector":"↿","LeftVectorBar":"⥒","LeftVector":"↼","lEg":"⪋","leg":"⋚","leq":"≤","leqq":"≦","leqslant":"⩽","lescc":"⪨","les":"⩽","lesdot":"⩿","lesdoto":"⪁","lesdotor":"⪃","lesg":"⋚︀","lesges":"⪓","lessapprox":"⪅","lessdot":"⋖","lesseqgtr":"⋚","lesseqqgtr":"⪋","LessEqualGreater":"⋚","LessFullEqual":"≦","LessGreater":"≶","lessgtr":"≶","LessLess":"⪡","lesssim":"≲","LessSlantEqual":"⩽","LessTilde":"≲","lfisht":"⥼","lfloor":"⌊","Lfr":"𝔏","lfr":"𝔩","lg":"≶","lgE":"⪑","lHar":"⥢","lhard":"↽","lharu":"↼","lharul":"⥪","lhblk":"▄","LJcy":"Љ","ljcy":"љ","llarr":"⇇","ll":"≪","Ll":"⋘","llcorner":"⌞","Lleftarrow":"⇚","llhard":"⥫","lltri":"◺","Lmidot":"Ŀ","lmidot":"ŀ","lmoustache":"⎰","lmoust":"⎰","lnap":"⪉","lnapprox":"⪉","lne":"⪇","lnE":"≨","lneq":"⪇","lneqq":"≨","lnsim":"⋦","loang":"⟬","loarr":"⇽","lobrk":"⟦","longleftarrow":"⟵","LongLeftArrow":"⟵","Longleftarrow":"⟸","longleftrightarrow":"⟷","LongLeftRightArrow":"⟷","Longleftrightarrow":"⟺","longmapsto":"⟼","longrightarrow":"⟶","LongRightArrow":"⟶","Longrightarrow":"⟹","looparrowleft":"↫","looparrowright":"↬","lopar":"⦅","Lopf":"𝕃","lopf":"𝕝","loplus":"⨭","lotimes":"⨴","lowast":"∗","lowbar":"_","LowerLeftArrow":"↙","LowerRightArrow":"↘","loz":"◊","lozenge":"◊","lozf":"⧫","lpar":"(","lparlt":"⦓","lrarr":"⇆","lrcorner":"⌟","lrhar":"⇋","lrhard":"⥭","lrm":"‎","lrtri":"⊿","lsaquo":"‹","lscr":"𝓁","Lscr":"ℒ","lsh":"↰","Lsh":"↰","lsim":"≲","lsime":"⪍","lsimg":"⪏","lsqb":"[","lsquo":"‘","lsquor":"‚","Lstrok":"Ł","lstrok":"ł","ltcc":"⪦","ltcir":"⩹","lt":"<","LT":"<","Lt":"≪","ltdot":"⋖","lthree":"⋋","ltimes":"⋉","ltlarr":"⥶","ltquest":"⩻","ltri":"◃","ltrie":"⊴","ltrif":"◂","ltrPar":"⦖","lurdshar":"⥊","luruhar":"⥦","lvertneqq":"≨︀","lvnE":"≨︀","macr":"¯","male":"♂","malt":"✠","maltese":"✠","Map":"⤅","map":"↦","mapsto":"↦","mapstodown":"↧","mapstoleft":"↤","mapstoup":"↥","marker":"▮","mcomma":"⨩","Mcy":"М","mcy":"м","mdash":"—","mDDot":"∺","measuredangle":"∡","MediumSpace":" ","Mellintrf":"ℳ","Mfr":"𝔐","mfr":"𝔪","mho":"℧","micro":"µ","midast":"*","midcir":"⫰","mid":"∣","middot":"·","minusb":"⊟","minus":"−","minusd":"∸","minusdu":"⨪","MinusPlus":"∓","mlcp":"⫛","mldr":"…","mnplus":"∓","models":"⊧","Mopf":"𝕄","mopf":"𝕞","mp":"∓","mscr":"𝓂","Mscr":"ℳ","mstpos":"∾","Mu":"Μ","mu":"μ","multimap":"⊸","mumap":"⊸","nabla":"∇","Nacute":"Ń","nacute":"ń","nang":"∠⃒","nap":"≉","napE":"⩰̸","napid":"≋̸","napos":"ʼn","napprox":"≉","natural":"♮","naturals":"ℕ","natur":"♮","nbsp":" ","nbump":"≎̸","nbumpe":"≏̸","ncap":"⩃","Ncaron":"Ň","ncaron":"ň","Ncedil":"Ņ","ncedil":"ņ","ncong":"≇","ncongdot":"⩭̸","ncup":"⩂","Ncy":"Н","ncy":"н","ndash":"–","nearhk":"⤤","nearr":"↗","neArr":"⇗","nearrow":"↗","ne":"≠","nedot":"≐̸","NegativeMediumSpace":"​","NegativeThickSpace":"​","NegativeThinSpace":"​","NegativeVeryThinSpace":"​","nequiv":"≢","nesear":"⤨","nesim":"≂̸","NestedGreaterGreater":"≫","NestedLessLess":"≪","NewLine":"\\n","nexist":"∄","nexists":"∄","Nfr":"𝔑","nfr":"𝔫","ngE":"≧̸","nge":"≱","ngeq":"≱","ngeqq":"≧̸","ngeqslant":"⩾̸","nges":"⩾̸","nGg":"⋙̸","ngsim":"≵","nGt":"≫⃒","ngt":"≯","ngtr":"≯","nGtv":"≫̸","nharr":"↮","nhArr":"⇎","nhpar":"⫲","ni":"∋","nis":"⋼","nisd":"⋺","niv":"∋","NJcy":"Њ","njcy":"њ","nlarr":"↚","nlArr":"⇍","nldr":"‥","nlE":"≦̸","nle":"≰","nleftarrow":"↚","nLeftarrow":"⇍","nleftrightarrow":"↮","nLeftrightarrow":"⇎","nleq":"≰","nleqq":"≦̸","nleqslant":"⩽̸","nles":"⩽̸","nless":"≮","nLl":"⋘̸","nlsim":"≴","nLt":"≪⃒","nlt":"≮","nltri":"⋪","nltrie":"⋬","nLtv":"≪̸","nmid":"∤","NoBreak":"⁠","NonBreakingSpace":" ","nopf":"𝕟","Nopf":"ℕ","Not":"⫬","not":"¬","NotCongruent":"≢","NotCupCap":"≭","NotDoubleVerticalBar":"∦","NotElement":"∉","NotEqual":"≠","NotEqualTilde":"≂̸","NotExists":"∄","NotGreater":"≯","NotGreaterEqual":"≱","NotGreaterFullEqual":"≧̸","NotGreaterGreater":"≫̸","NotGreaterLess":"≹","NotGreaterSlantEqual":"⩾̸","NotGreaterTilde":"≵","NotHumpDownHump":"≎̸","NotHumpEqual":"≏̸","notin":"∉","notindot":"⋵̸","notinE":"⋹̸","notinva":"∉","notinvb":"⋷","notinvc":"⋶","NotLeftTriangleBar":"⧏̸","NotLeftTriangle":"⋪","NotLeftTriangleEqual":"⋬","NotLess":"≮","NotLessEqual":"≰","NotLessGreater":"≸","NotLessLess":"≪̸","NotLessSlantEqual":"⩽̸","NotLessTilde":"≴","NotNestedGreaterGreater":"⪢̸","NotNestedLessLess":"⪡̸","notni":"∌","notniva":"∌","notnivb":"⋾","notnivc":"⋽","NotPrecedes":"⊀","NotPrecedesEqual":"⪯̸","NotPrecedesSlantEqual":"⋠","NotReverseElement":"∌","NotRightTriangleBar":"⧐̸","NotRightTriangle":"⋫","NotRightTriangleEqual":"⋭","NotSquareSubset":"⊏̸","NotSquareSubsetEqual":"⋢","NotSquareSuperset":"⊐̸","NotSquareSupersetEqual":"⋣","NotSubset":"⊂⃒","NotSubsetEqual":"⊈","NotSucceeds":"⊁","NotSucceedsEqual":"⪰̸","NotSucceedsSlantEqual":"⋡","NotSucceedsTilde":"≿̸","NotSuperset":"⊃⃒","NotSupersetEqual":"⊉","NotTilde":"≁","NotTildeEqual":"≄","NotTildeFullEqual":"≇","NotTildeTilde":"≉","NotVerticalBar":"∤","nparallel":"∦","npar":"∦","nparsl":"⫽⃥","npart":"∂̸","npolint":"⨔","npr":"⊀","nprcue":"⋠","nprec":"⊀","npreceq":"⪯̸","npre":"⪯̸","nrarrc":"⤳̸","nrarr":"↛","nrArr":"⇏","nrarrw":"↝̸","nrightarrow":"↛","nRightarrow":"⇏","nrtri":"⋫","nrtrie":"⋭","nsc":"⊁","nsccue":"⋡","nsce":"⪰̸","Nscr":"𝒩","nscr":"𝓃","nshortmid":"∤","nshortparallel":"∦","nsim":"≁","nsime":"≄","nsimeq":"≄","nsmid":"∤","nspar":"∦","nsqsube":"⋢","nsqsupe":"⋣","nsub":"⊄","nsubE":"⫅̸","nsube":"⊈","nsubset":"⊂⃒","nsubseteq":"⊈","nsubseteqq":"⫅̸","nsucc":"⊁","nsucceq":"⪰̸","nsup":"⊅","nsupE":"⫆̸","nsupe":"⊉","nsupset":"⊃⃒","nsupseteq":"⊉","nsupseteqq":"⫆̸","ntgl":"≹","Ntilde":"Ñ","ntilde":"ñ","ntlg":"≸","ntriangleleft":"⋪","ntrianglelefteq":"⋬","ntriangleright":"⋫","ntrianglerighteq":"⋭","Nu":"Ν","nu":"ν","num":"#","numero":"№","numsp":" ","nvap":"≍⃒","nvdash":"⊬","nvDash":"⊭","nVdash":"⊮","nVDash":"⊯","nvge":"≥⃒","nvgt":">⃒","nvHarr":"⤄","nvinfin":"⧞","nvlArr":"⤂","nvle":"≤⃒","nvlt":"<⃒","nvltrie":"⊴⃒","nvrArr":"⤃","nvrtrie":"⊵⃒","nvsim":"∼⃒","nwarhk":"⤣","nwarr":"↖","nwArr":"⇖","nwarrow":"↖","nwnear":"⤧","Oacute":"Ó","oacute":"ó","oast":"⊛","Ocirc":"Ô","ocirc":"ô","ocir":"⊚","Ocy":"О","ocy":"о","odash":"⊝","Odblac":"Ő","odblac":"ő","odiv":"⨸","odot":"⊙","odsold":"⦼","OElig":"Œ","oelig":"œ","ofcir":"⦿","Ofr":"𝔒","ofr":"𝔬","ogon":"˛","Ograve":"Ò","ograve":"ò","ogt":"⧁","ohbar":"⦵","ohm":"Ω","oint":"∮","olarr":"↺","olcir":"⦾","olcross":"⦻","oline":"‾","olt":"⧀","Omacr":"Ō","omacr":"ō","Omega":"Ω","omega":"ω","Omicron":"Ο","omicron":"ο","omid":"⦶","ominus":"⊖","Oopf":"𝕆","oopf":"𝕠","opar":"⦷","OpenCurlyDoubleQuote":"“","OpenCurlyQuote":"‘","operp":"⦹","oplus":"⊕","orarr":"↻","Or":"⩔","or":"∨","ord":"⩝","order":"ℴ","orderof":"ℴ","ordf":"ª","ordm":"º","origof":"⊶","oror":"⩖","orslope":"⩗","orv":"⩛","oS":"Ⓢ","Oscr":"𝒪","oscr":"ℴ","Oslash":"Ø","oslash":"ø","osol":"⊘","Otilde":"Õ","otilde":"õ","otimesas":"⨶","Otimes":"⨷","otimes":"⊗","Ouml":"Ö","ouml":"ö","ovbar":"⌽","OverBar":"‾","OverBrace":"⏞","OverBracket":"⎴","OverParenthesis":"⏜","para":"¶","parallel":"∥","par":"∥","parsim":"⫳","parsl":"⫽","part":"∂","PartialD":"∂","Pcy":"П","pcy":"п","percnt":"%","period":".","permil":"‰","perp":"⊥","pertenk":"‱","Pfr":"𝔓","pfr":"𝔭","Phi":"Φ","phi":"φ","phiv":"ϕ","phmmat":"ℳ","phone":"☎","Pi":"Π","pi":"π","pitchfork":"⋔","piv":"ϖ","planck":"ℏ","planckh":"ℎ","plankv":"ℏ","plusacir":"⨣","plusb":"⊞","pluscir":"⨢","plus":"+","plusdo":"∔","plusdu":"⨥","pluse":"⩲","PlusMinus":"±","plusmn":"±","plussim":"⨦","plustwo":"⨧","pm":"±","Poincareplane":"ℌ","pointint":"⨕","popf":"𝕡","Popf":"ℙ","pound":"£","prap":"⪷","Pr":"⪻","pr":"≺","prcue":"≼","precapprox":"⪷","prec":"≺","preccurlyeq":"≼","Precedes":"≺","PrecedesEqual":"⪯","PrecedesSlantEqual":"≼","PrecedesTilde":"≾","preceq":"⪯","precnapprox":"⪹","precneqq":"⪵","precnsim":"⋨","pre":"⪯","prE":"⪳","precsim":"≾","prime":"′","Prime":"″","primes":"ℙ","prnap":"⪹","prnE":"⪵","prnsim":"⋨","prod":"∏","Product":"∏","profalar":"⌮","profline":"⌒","profsurf":"⌓","prop":"∝","Proportional":"∝","Proportion":"∷","propto":"∝","prsim":"≾","prurel":"⊰","Pscr":"𝒫","pscr":"𝓅","Psi":"Ψ","psi":"ψ","puncsp":" ","Qfr":"𝔔","qfr":"𝔮","qint":"⨌","qopf":"𝕢","Qopf":"ℚ","qprime":"⁗","Qscr":"𝒬","qscr":"𝓆","quaternions":"ℍ","quatint":"⨖","quest":"?","questeq":"≟","quot":"\\"","QUOT":"\\"","rAarr":"⇛","race":"∽̱","Racute":"Ŕ","racute":"ŕ","radic":"√","raemptyv":"⦳","rang":"⟩","Rang":"⟫","rangd":"⦒","range":"⦥","rangle":"⟩","raquo":"»","rarrap":"⥵","rarrb":"⇥","rarrbfs":"⤠","rarrc":"⤳","rarr":"→","Rarr":"↠","rArr":"⇒","rarrfs":"⤞","rarrhk":"↪","rarrlp":"↬","rarrpl":"⥅","rarrsim":"⥴","Rarrtl":"⤖","rarrtl":"↣","rarrw":"↝","ratail":"⤚","rAtail":"⤜","ratio":"∶","rationals":"ℚ","rbarr":"⤍","rBarr":"⤏","RBarr":"⤐","rbbrk":"❳","rbrace":"}","rbrack":"]","rbrke":"⦌","rbrksld":"⦎","rbrkslu":"⦐","Rcaron":"Ř","rcaron":"ř","Rcedil":"Ŗ","rcedil":"ŗ","rceil":"⌉","rcub":"}","Rcy":"Р","rcy":"р","rdca":"⤷","rdldhar":"⥩","rdquo":"”","rdquor":"”","rdsh":"↳","real":"ℜ","realine":"ℛ","realpart":"ℜ","reals":"ℝ","Re":"ℜ","rect":"▭","reg":"®","REG":"®","ReverseElement":"∋","ReverseEquilibrium":"⇋","ReverseUpEquilibrium":"⥯","rfisht":"⥽","rfloor":"⌋","rfr":"𝔯","Rfr":"ℜ","rHar":"⥤","rhard":"⇁","rharu":"⇀","rharul":"⥬","Rho":"Ρ","rho":"ρ","rhov":"ϱ","RightAngleBracket":"⟩","RightArrowBar":"⇥","rightarrow":"→","RightArrow":"→","Rightarrow":"⇒","RightArrowLeftArrow":"⇄","rightarrowtail":"↣","RightCeiling":"⌉","RightDoubleBracket":"⟧","RightDownTeeVector":"⥝","RightDownVectorBar":"⥕","RightDownVector":"⇂","RightFloor":"⌋","rightharpoondown":"⇁","rightharpoonup":"⇀","rightleftarrows":"⇄","rightleftharpoons":"⇌","rightrightarrows":"⇉","rightsquigarrow":"↝","RightTeeArrow":"↦","RightTee":"⊢","RightTeeVector":"⥛","rightthreetimes":"⋌","RightTriangleBar":"⧐","RightTriangle":"⊳","RightTriangleEqual":"⊵","RightUpDownVector":"⥏","RightUpTeeVector":"⥜","RightUpVectorBar":"⥔","RightUpVector":"↾","RightVectorBar":"⥓","RightVector":"⇀","ring":"˚","risingdotseq":"≓","rlarr":"⇄","rlhar":"⇌","rlm":"‏","rmoustache":"⎱","rmoust":"⎱","rnmid":"⫮","roang":"⟭","roarr":"⇾","robrk":"⟧","ropar":"⦆","ropf":"𝕣","Ropf":"ℝ","roplus":"⨮","rotimes":"⨵","RoundImplies":"⥰","rpar":")","rpargt":"⦔","rppolint":"⨒","rrarr":"⇉","Rrightarrow":"⇛","rsaquo":"›","rscr":"𝓇","Rscr":"ℛ","rsh":"↱","Rsh":"↱","rsqb":"]","rsquo":"’","rsquor":"’","rthree":"⋌","rtimes":"⋊","rtri":"▹","rtrie":"⊵","rtrif":"▸","rtriltri":"⧎","RuleDelayed":"⧴","ruluhar":"⥨","rx":"℞","Sacute":"Ś","sacute":"ś","sbquo":"‚","scap":"⪸","Scaron":"Š","scaron":"š","Sc":"⪼","sc":"≻","sccue":"≽","sce":"⪰","scE":"⪴","Scedil":"Ş","scedil":"ş","Scirc":"Ŝ","scirc":"ŝ","scnap":"⪺","scnE":"⪶","scnsim":"⋩","scpolint":"⨓","scsim":"≿","Scy":"С","scy":"с","sdotb":"⊡","sdot":"⋅","sdote":"⩦","searhk":"⤥","searr":"↘","seArr":"⇘","searrow":"↘","sect":"§","semi":";","seswar":"⤩","setminus":"∖","setmn":"∖","sext":"✶","Sfr":"𝔖","sfr":"𝔰","sfrown":"⌢","sharp":"♯","SHCHcy":"Щ","shchcy":"щ","SHcy":"Ш","shcy":"ш","ShortDownArrow":"↓","ShortLeftArrow":"←","shortmid":"∣","shortparallel":"∥","ShortRightArrow":"→","ShortUpArrow":"↑","shy":"­","Sigma":"Σ","sigma":"σ","sigmaf":"ς","sigmav":"ς","sim":"∼","simdot":"⩪","sime":"≃","simeq":"≃","simg":"⪞","simgE":"⪠","siml":"⪝","simlE":"⪟","simne":"≆","simplus":"⨤","simrarr":"⥲","slarr":"←","SmallCircle":"∘","smallsetminus":"∖","smashp":"⨳","smeparsl":"⧤","smid":"∣","smile":"⌣","smt":"⪪","smte":"⪬","smtes":"⪬︀","SOFTcy":"Ь","softcy":"ь","solbar":"⌿","solb":"⧄","sol":"/","Sopf":"𝕊","sopf":"𝕤","spades":"♠","spadesuit":"♠","spar":"∥","sqcap":"⊓","sqcaps":"⊓︀","sqcup":"⊔","sqcups":"⊔︀","Sqrt":"√","sqsub":"⊏","sqsube":"⊑","sqsubset":"⊏","sqsubseteq":"⊑","sqsup":"⊐","sqsupe":"⊒","sqsupset":"⊐","sqsupseteq":"⊒","square":"□","Square":"□","SquareIntersection":"⊓","SquareSubset":"⊏","SquareSubsetEqual":"⊑","SquareSuperset":"⊐","SquareSupersetEqual":"⊒","SquareUnion":"⊔","squarf":"▪","squ":"□","squf":"▪","srarr":"→","Sscr":"𝒮","sscr":"𝓈","ssetmn":"∖","ssmile":"⌣","sstarf":"⋆","Star":"⋆","star":"☆","starf":"★","straightepsilon":"ϵ","straightphi":"ϕ","strns":"¯","sub":"⊂","Sub":"⋐","subdot":"⪽","subE":"⫅","sube":"⊆","subedot":"⫃","submult":"⫁","subnE":"⫋","subne":"⊊","subplus":"⪿","subrarr":"⥹","subset":"⊂","Subset":"⋐","subseteq":"⊆","subseteqq":"⫅","SubsetEqual":"⊆","subsetneq":"⊊","subsetneqq":"⫋","subsim":"⫇","subsub":"⫕","subsup":"⫓","succapprox":"⪸","succ":"≻","succcurlyeq":"≽","Succeeds":"≻","SucceedsEqual":"⪰","SucceedsSlantEqual":"≽","SucceedsTilde":"≿","succeq":"⪰","succnapprox":"⪺","succneqq":"⪶","succnsim":"⋩","succsim":"≿","SuchThat":"∋","sum":"∑","Sum":"∑","sung":"♪","sup1":"¹","sup2":"²","sup3":"³","sup":"⊃","Sup":"⋑","supdot":"⪾","supdsub":"⫘","supE":"⫆","supe":"⊇","supedot":"⫄","Superset":"⊃","SupersetEqual":"⊇","suphsol":"⟉","suphsub":"⫗","suplarr":"⥻","supmult":"⫂","supnE":"⫌","supne":"⊋","supplus":"⫀","supset":"⊃","Supset":"⋑","supseteq":"⊇","supseteqq":"⫆","supsetneq":"⊋","supsetneqq":"⫌","supsim":"⫈","supsub":"⫔","supsup":"⫖","swarhk":"⤦","swarr":"↙","swArr":"⇙","swarrow":"↙","swnwar":"⤪","szlig":"ß","Tab":"\\t","target":"⌖","Tau":"Τ","tau":"τ","tbrk":"⎴","Tcaron":"Ť","tcaron":"ť","Tcedil":"Ţ","tcedil":"ţ","Tcy":"Т","tcy":"т","tdot":"⃛","telrec":"⌕","Tfr":"𝔗","tfr":"𝔱","there4":"∴","therefore":"∴","Therefore":"∴","Theta":"Θ","theta":"θ","thetasym":"ϑ","thetav":"ϑ","thickapprox":"≈","thicksim":"∼","ThickSpace":"  ","ThinSpace":" ","thinsp":" ","thkap":"≈","thksim":"∼","THORN":"Þ","thorn":"þ","tilde":"˜","Tilde":"∼","TildeEqual":"≃","TildeFullEqual":"≅","TildeTilde":"≈","timesbar":"⨱","timesb":"⊠","times":"×","timesd":"⨰","tint":"∭","toea":"⤨","topbot":"⌶","topcir":"⫱","top":"⊤","Topf":"𝕋","topf":"𝕥","topfork":"⫚","tosa":"⤩","tprime":"‴","trade":"™","TRADE":"™","triangle":"▵","triangledown":"▿","triangleleft":"◃","trianglelefteq":"⊴","triangleq":"≜","triangleright":"▹","trianglerighteq":"⊵","tridot":"◬","trie":"≜","triminus":"⨺","TripleDot":"⃛","triplus":"⨹","trisb":"⧍","tritime":"⨻","trpezium":"⏢","Tscr":"𝒯","tscr":"𝓉","TScy":"Ц","tscy":"ц","TSHcy":"Ћ","tshcy":"ћ","Tstrok":"Ŧ","tstrok":"ŧ","twixt":"≬","twoheadleftarrow":"↞","twoheadrightarrow":"↠","Uacute":"Ú","uacute":"ú","uarr":"↑","Uarr":"↟","uArr":"⇑","Uarrocir":"⥉","Ubrcy":"Ў","ubrcy":"ў","Ubreve":"Ŭ","ubreve":"ŭ","Ucirc":"Û","ucirc":"û","Ucy":"У","ucy":"у","udarr":"⇅","Udblac":"Ű","udblac":"ű","udhar":"⥮","ufisht":"⥾","Ufr":"𝔘","ufr":"𝔲","Ugrave":"Ù","ugrave":"ù","uHar":"⥣","uharl":"↿","uharr":"↾","uhblk":"▀","ulcorn":"⌜","ulcorner":"⌜","ulcrop":"⌏","ultri":"◸","Umacr":"Ū","umacr":"ū","uml":"¨","UnderBar":"_","UnderBrace":"⏟","UnderBracket":"⎵","UnderParenthesis":"⏝","Union":"⋃","UnionPlus":"⊎","Uogon":"Ų","uogon":"ų","Uopf":"𝕌","uopf":"𝕦","UpArrowBar":"⤒","uparrow":"↑","UpArrow":"↑","Uparrow":"⇑","UpArrowDownArrow":"⇅","updownarrow":"↕","UpDownArrow":"↕","Updownarrow":"⇕","UpEquilibrium":"⥮","upharpoonleft":"↿","upharpoonright":"↾","uplus":"⊎","UpperLeftArrow":"↖","UpperRightArrow":"↗","upsi":"υ","Upsi":"ϒ","upsih":"ϒ","Upsilon":"Υ","upsilon":"υ","UpTeeArrow":"↥","UpTee":"⊥","upuparrows":"⇈","urcorn":"⌝","urcorner":"⌝","urcrop":"⌎","Uring":"Ů","uring":"ů","urtri":"◹","Uscr":"𝒰","uscr":"𝓊","utdot":"⋰","Utilde":"Ũ","utilde":"ũ","utri":"▵","utrif":"▴","uuarr":"⇈","Uuml":"Ü","uuml":"ü","uwangle":"⦧","vangrt":"⦜","varepsilon":"ϵ","varkappa":"ϰ","varnothing":"∅","varphi":"ϕ","varpi":"ϖ","varpropto":"∝","varr":"↕","vArr":"⇕","varrho":"ϱ","varsigma":"ς","varsubsetneq":"⊊︀","varsubsetneqq":"⫋︀","varsupsetneq":"⊋︀","varsupsetneqq":"⫌︀","vartheta":"ϑ","vartriangleleft":"⊲","vartriangleright":"⊳","vBar":"⫨","Vbar":"⫫","vBarv":"⫩","Vcy":"В","vcy":"в","vdash":"⊢","vDash":"⊨","Vdash":"⊩","VDash":"⊫","Vdashl":"⫦","veebar":"⊻","vee":"∨","Vee":"⋁","veeeq":"≚","vellip":"⋮","verbar":"|","Verbar":"‖","vert":"|","Vert":"‖","VerticalBar":"∣","VerticalLine":"|","VerticalSeparator":"❘","VerticalTilde":"≀","VeryThinSpace":" ","Vfr":"𝔙","vfr":"𝔳","vltri":"⊲","vnsub":"⊂⃒","vnsup":"⊃⃒","Vopf":"𝕍","vopf":"𝕧","vprop":"∝","vrtri":"⊳","Vscr":"𝒱","vscr":"𝓋","vsubnE":"⫋︀","vsubne":"⊊︀","vsupnE":"⫌︀","vsupne":"⊋︀","Vvdash":"⊪","vzigzag":"⦚","Wcirc":"Ŵ","wcirc":"ŵ","wedbar":"⩟","wedge":"∧","Wedge":"⋀","wedgeq":"≙","weierp":"℘","Wfr":"𝔚","wfr":"𝔴","Wopf":"𝕎","wopf":"𝕨","wp":"℘","wr":"≀","wreath":"≀","Wscr":"𝒲","wscr":"𝓌","xcap":"⋂","xcirc":"◯","xcup":"⋃","xdtri":"▽","Xfr":"𝔛","xfr":"𝔵","xharr":"⟷","xhArr":"⟺","Xi":"Ξ","xi":"ξ","xlarr":"⟵","xlArr":"⟸","xmap":"⟼","xnis":"⋻","xodot":"⨀","Xopf":"𝕏","xopf":"𝕩","xoplus":"⨁","xotime":"⨂","xrarr":"⟶","xrArr":"⟹","Xscr":"𝒳","xscr":"𝓍","xsqcup":"⨆","xuplus":"⨄","xutri":"△","xvee":"⋁","xwedge":"⋀","Yacute":"Ý","yacute":"ý","YAcy":"Я","yacy":"я","Ycirc":"Ŷ","ycirc":"ŷ","Ycy":"Ы","ycy":"ы","yen":"¥","Yfr":"𝔜","yfr":"𝔶","YIcy":"Ї","yicy":"ї","Yopf":"𝕐","yopf":"𝕪","Yscr":"𝒴","yscr":"𝓎","YUcy":"Ю","yucy":"ю","yuml":"ÿ","Yuml":"Ÿ","Zacute":"Ź","zacute":"ź","Zcaron":"Ž","zcaron":"ž","Zcy":"З","zcy":"з","Zdot":"Ż","zdot":"ż","zeetrf":"ℨ","ZeroWidthSpace":"​","Zeta":"Ζ","zeta":"ζ","zfr":"𝔷","Zfr":"ℨ","ZHcy":"Ж","zhcy":"ж","zigrarr":"⇝","zopf":"𝕫","Zopf":"ℤ","Zscr":"𝒵","zscr":"𝓏","zwj":"‍","zwnj":"‌"}')}},e={};function n(o){var i=e[o];if(void 0!==i)return i.exports;var r=e[o]={id:o,exports:{}};return t[o](r,r.exports,n),r.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var o in e)n.o(e,o)&&!n.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};return(()=>{"use strict";const t=function(){return function t(){t.called=!0}};class e{constructor(e,n){this.source=e,this.name=n,this.path=[],this.stop=t(),this.off=t()}}const o=new Array(256).fill().map(((t,e)=>("0"+e.toString(16)).slice(-2)));function i(){const t=4294967296*Math.random()>>>0,e=4294967296*Math.random()>>>0,n=4294967296*Math.random()>>>0,i=4294967296*Math.random()>>>0;return"e"+o[t>>0&255]+o[t>>8&255]+o[t>>16&255]+o[t>>24&255]+o[e>>0&255]+o[e>>8&255]+o[e>>16&255]+o[e>>24&255]+o[n>>0&255]+o[n>>8&255]+o[n>>16&255]+o[n>>24&255]+o[i>>0&255]+o[i>>8&255]+o[i>>16&255]+o[i>>24&255]}const r={get(t){return"number"!=typeof t?this[t]||this.normal:t},highest:1e5,high:1e3,normal:0,low:-1e3,lowest:-1e5};class s extends Error{constructor(t,e,n){super(function(t,e){const n=new WeakSet,o=(t,e)=>{if("object"==typeof e&&null!==e){if(n.has(e))return`[object ${e.constructor.name}]`;n.add(e)}return e},i=e?` ${JSON.stringify(e,o)}`:"",r=c(t);return t+i+r}(t,n)),this.name="CKEditorError",this.context=e,this.data=n}is(t){return"CKEditorError"===t}static rethrowUnexpectedError(t,e){if(t.is&&t.is("CKEditorError"))throw t;const n=new s(t.message,e);throw n.stack=t.stack,n}}function a(t,e){console.warn(...l(t,e))}function c(t){return`\nRead more: https://ckeditor.com/docs/ckeditor5/latest/framework/guides/support/error-codes.html#error-${t}`}function l(t,e){const n=c(t);return e?[t,e,n]:[t,n]}const d="32.0.0",u="object"==typeof window?window:n.g;if(u.CKEDITOR_VERSION)throw new s("ckeditor-duplicated-modules",null);u.CKEDITOR_VERSION=d;const h=Symbol("listeningTo"),p=Symbol("emitterId"),m={on(t,e,n={}){this.listenTo(this,t,e,n)},once(t,e,n){let o=!1;this.listenTo(this,t,(function(t,...n){o||(o=!0,t.off(),e.call(this,t,...n))}),n)},off(t,e){this.stopListening(this,t,e)},listenTo(t,e,n,o={}){let i,r;this[h]||(this[h]={});const s=this[h];b(t)||f(t);const a=b(t);(i=s[a])||(i=s[a]={emitter:t,callbacks:{}}),(r=i.callbacks[e])||(r=i.callbacks[e]=[]),r.push(n),function(t,e,n,o,i){e._addEventListener?e._addEventListener(n,o,i):t._addEventListener.call(e,n,o,i)}(this,t,e,n,o)},stopListening(t,e,n){const o=this[h];let i=t&&b(t);const r=o&&i&&o[i],s=r&&e&&r.callbacks[e];if(!(!o||t&&!r||e&&!s))if(n){v(this,t,e,n);-1!==s.indexOf(n)&&(1===s.length?delete r.callbacks[e]:v(this,t,e,n))}else if(s){for(;n=s.pop();)v(this,t,e,n);delete r.callbacks[e]}else if(r){for(e in r.callbacks)this.stopListening(t,e);delete o[i]}else{for(i in o)this.stopListening(o[i].emitter);delete this[h]}},fire(t,...n){try{const o=t instanceof e?t:new e(this,t),i=o.name;let r=C(this,i);if(o.path.push(this),r){const t=[o,...n];r=Array.from(r);for(let e=0;e{this._delegations||(this._delegations=new Map),t.forEach((t=>{const o=this._delegations.get(t);o?o.set(e,n):this._delegations.set(t,new Map([[e,n]]))}))}}},stopDelegating(t,e){if(this._delegations)if(t)if(e){const n=this._delegations.get(t);n&&n.delete(e)}else this._delegations.delete(t);else this._delegations.clear()},_addEventListener(t,e,n){!function(t,e){const n=k(t);if(n[e])return;let o=e,i=null;const r=[];for(;""!==o&&!n[o];)n[o]={callbacks:[],childEvents:[]},r.push(n[o]),i&&n[o].childEvents.push(i),i=o,o=o.substr(0,o.lastIndexOf(":"));if(""!==o){for(const t of r)t.callbacks=n[o].callbacks.slice();n[o].childEvents.push(i)}}(this,t);const o=w(this,t),i=r.get(n.priority),s={callback:e,priority:i};for(const t of o){let e=!1;for(let n=0;n-1?C(t,e.substr(0,e.lastIndexOf(":"))):null}function A(t,n,o){for(let[i,r]of t){r?"function"==typeof r&&(r=r(n.name)):r=n.name;const t=new e(n.source,r);t.path=[...n.path],i.fire(t,...o)}}function v(t,e,n,o){e._removeEventListener?e._removeEventListener(n,o):t._removeEventListener.call(e,n,o)}const y=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)};const x="object"==typeof global&&global&&global.Object===Object&&global;var E="object"==typeof self&&self&&self.Object===Object&&self;const D=x||E||Function("return this")();const S=D.Symbol;var B=Object.prototype,T=B.hasOwnProperty,P=B.toString,I=S?S.toStringTag:void 0;const R=function(t){var e=T.call(t,I),n=t[I];try{t[I]=void 0;var o=!0}catch(t){}var i=P.call(t);return o&&(e?t[I]=n:delete t[I]),i};var z=Object.prototype.toString;const F=function(t){return z.call(t)};var N=S?S.toStringTag:void 0;const O=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":N&&N in Object(t)?R(t):F(t)};const M=function(t){if(!y(t))return!1;var e=O(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e};const V=D["__core-js_shared__"];var L=function(){var t=/[^.]+$/.exec(V&&V.keys&&V.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();const H=function(t){return!!L&&L in t};var q=Function.prototype.toString;const W=function(t){if(null!=t){try{return q.call(t)}catch(t){}try{return t+""}catch(t){}}return""};var j=/^\[object .+?Constructor\]$/,U=Function.prototype,$=Object.prototype,G=U.toString,K=$.hasOwnProperty,Z=RegExp("^"+G.call(K).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");const J=function(t){return!(!y(t)||H(t))&&(M(t)?Z:j).test(W(t))};const Y=function(t,e){return null==t?void 0:t[e]};const Q=function(t,e){var n=Y(t,e);return J(n)?n:void 0};const X=function(){try{var t=Q(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();const tt=function(t,e,n){"__proto__"==e&&X?X(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n};const et=function(t,e){return t===e||t!=t&&e!=e};var nt=Object.prototype.hasOwnProperty;const ot=function(t,e,n){var o=t[e];nt.call(t,e)&&et(o,n)&&(void 0!==n||e in t)||tt(t,e,n)};const it=function(t,e,n,o){var i=!n;n||(n={});for(var r=-1,s=e.length;++r0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}};const pt=ht(dt);const mt=function(t,e){return pt(ct(t,e,rt),t+"")};const gt=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991};const ft=function(t){return null!=t&>(t.length)&&!M(t)};var bt=/^(?:0|[1-9]\d*)$/;const kt=function(t,e){var n=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==n||"symbol"!=n&&bt.test(t))&&t>-1&&t%1==0&&t1?n[i-1]:void 0,s=i>2?n[2]:void 0;for(r=t.length>3&&"function"==typeof r?(i--,r):void 0,s&&wt(n[0],n[1],s)&&(r=i<3?void 0:r,i=1),e=Object(e);++o{this.set(e,t[e])}),this);ae(this);const n=this[te];if(t in this&&!n.has(t))throw new s("observable-set-cannot-override",this);Object.defineProperty(this,t,{enumerable:!0,configurable:!0,get:()=>n.get(t),set(e){const o=n.get(t);let i=this.fire("set:"+t,t,e,o);void 0===i&&(i=e),o===i&&n.has(t)||(n.set(t,i),this.fire("change:"+t,t,i,o))}}),this[t]=e},bind(...t){if(!t.length||!de(t))throw new s("observable-bind-wrong-properties",this);if(new Set(t).size!==t.length)throw new s("observable-bind-duplicate-properties",this);ae(this);const e=this[ne];t.forEach((t=>{if(e.has(t))throw new s("observable-bind-rebind",this)}));const n=new Map;return t.forEach((t=>{const o={property:t,to:[]};e.set(t,o),n.set(t,o)})),{to:ce,toMany:le,_observable:this,_bindProperties:t,_to:[],_bindings:n}},unbind(...t){if(!this[te])return;const e=this[ne],n=this[ee];if(t.length){if(!de(t))throw new s("observable-unbind-wrong-properties",this);t.forEach((t=>{const o=e.get(t);if(!o)return;let i,r,s,a;o.to.forEach((t=>{i=t[0],r=t[1],s=n.get(i),a=s[r],a.delete(o),a.size||delete s[r],Object.keys(s).length||(n.delete(i),this.stopListening(i,"change"))})),e.delete(t)}))}else n.forEach(((t,e)=>{this.stopListening(e,"change")})),n.clear(),e.clear()},decorate(t){const e=this[t];if(!e)throw new s("observablemixin-cannot-decorate-undefined",this,{object:this,methodName:t});this.on(t,((t,n)=>{t.return=e.apply(this,n)})),this[t]=function(...e){return this.fire(t,e)},this[t][ie]=e,this[oe]||(this[oe]=[]),this[oe].push(t)}};Xt(re,g),re.stopListening=function(t,e,n){if(!t&&this[oe]){for(const t of this[oe])this[t]=this[t][ie];delete this[oe]}g.stopListening.call(this,t,e,n)};const se=re;function ae(t){t[te]||(Object.defineProperty(t,te,{value:new Map}),Object.defineProperty(t,ee,{value:new Map}),Object.defineProperty(t,ne,{value:new Map}))}function ce(...t){const e=function(...t){if(!t.length)throw new s("observable-bind-to-parse-error",null);const e={to:[]};let n;"function"==typeof t[t.length-1]&&(e.callback=t.pop());return t.forEach((t=>{if("string"==typeof t)n.properties.push(t);else{if("object"!=typeof t)throw new s("observable-bind-to-parse-error",null);n={observable:t,properties:[]},e.to.push(n)}})),e}(...t),n=Array.from(this._bindings.keys()),o=n.length;if(!e.callback&&e.to.length>1)throw new s("observable-bind-to-no-callback",this);if(o>1&&e.callback)throw new s("observable-bind-to-extra-callback",this);var i;e.to.forEach((t=>{if(t.properties.length&&t.properties.length!==o)throw new s("observable-bind-to-properties-length",this);t.properties.length||(t.properties=this._bindProperties)})),this._to=e.to,e.callback&&(this._bindings.get(n[0]).callback=e.callback),i=this._observable,this._to.forEach((t=>{const e=i[ee];let n;e.get(t.observable)||i.listenTo(t.observable,"change",((o,r)=>{n=e.get(t.observable)[r],n&&n.forEach((t=>{ue(i,t.property)}))}))})),function(t){let e;t._bindings.forEach(((n,o)=>{t._to.forEach((i=>{e=i.properties[n.callback?0:t._bindProperties.indexOf(o)],n.to.push([i.observable,e]),function(t,e,n,o){const i=t[ee],r=i.get(n),s=r||{};s[o]||(s[o]=new Set);s[o].add(e),r||i.set(n,s)}(t._observable,n,i.observable,e)}))}))}(this),this._bindProperties.forEach((t=>{ue(this._observable,t)}))}function le(t,e,n){if(this._bindings.size>1)throw new s("observable-bind-to-many-not-one-binding",this);this.to(...function(t,e){const n=t.map((t=>[t,e]));return Array.prototype.concat.apply([],n)}(t,e),n)}function de(t){return t.every((t=>"string"==typeof t))}function ue(t,e){const n=t[ne].get(e);let o;n.callback?o=n.callback.apply(t,n.to.map((t=>t[0][t[1]]))):(o=n.to[0],o=o[0][o[1]]),Object.prototype.hasOwnProperty.call(t,e)?t[e]=o:t.set(e,o)}function he(t,...e){e.forEach((e=>{Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e)).forEach((n=>{if(n in t.prototype)return;const o=Object.getOwnPropertyDescriptor(e,n);o.enumerable=!1,Object.defineProperty(t.prototype,n,o)}))}))}class pe{constructor(t){this.editor=t,this.set("isEnabled",!0),this._disableStack=new Set}forceDisabled(t){this._disableStack.add(t),1==this._disableStack.size&&(this.on("set:isEnabled",me,{priority:"highest"}),this.isEnabled=!1)}clearForceDisabled(t){this._disableStack.delete(t),0==this._disableStack.size&&(this.off("set:isEnabled",me),this.isEnabled=!0)}destroy(){this.stopListening()}static get isContextPlugin(){return!1}}function me(t){t.return=!1,t.stop()}he(pe,se);class ge{constructor(t){this.editor=t,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",(t=>{this.isEnabled||t.stop()}),{priority:"high"}),this.listenTo(t,"change:isReadOnly",((t,e,n)=>{n&&this.affectsData?this.forceDisabled("readOnlyMode"):this.clearForceDisabled("readOnlyMode")}))}refresh(){this.isEnabled=!0}forceDisabled(t){this._disableStack.add(t),1==this._disableStack.size&&(this.on("set:isEnabled",fe,{priority:"highest"}),this.isEnabled=!1)}clearForceDisabled(t){this._disableStack.delete(t),0==this._disableStack.size&&(this.off("set:isEnabled",fe),this.refresh())}execute(){}destroy(){this.stopListening()}}function fe(t){t.return=!1,t.stop()}he(ge,se);const be=function(t,e){return function(n){return t(e(n))}};const ke=be(Object.getPrototypeOf,Object);var we=Function.prototype,_e=Object.prototype,Ce=we.toString,Ae=_e.hasOwnProperty,ve=Ce.call(Object);const ye=function(t){if(!At(t)||"[object Object]"!=O(t))return!1;var e=ke(t);if(null===e)return!0;var n=Ae.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&Ce.call(n)==ve};const xe=function(){this.__data__=[],this.size=0};const Ee=function(t,e){for(var n=t.length;n--;)if(et(t[n][0],e))return n;return-1};var De=Array.prototype.splice;const Se=function(t){var e=this.__data__,n=Ee(e,t);return!(n<0)&&(n==e.length-1?e.pop():De.call(e,n,1),--this.size,!0)};const Be=function(t){var e=this.__data__,n=Ee(e,t);return n<0?void 0:e[n][1]};const Te=function(t){return Ee(this.__data__,t)>-1};const Pe=function(t,e){var n=this.__data__,o=Ee(n,t);return o<0?(++this.size,n.push([t,e])):n[o][1]=e,this};function Ie(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e{this._setToTarget(t,o,e[o],n)}))}}function xo(t){return Ao(t,Eo)}function Eo(t){return vo(t)?t:void 0}function Do(t){return!(!t||!t[Symbol.iterator])}class So{constructor(t={},e={}){const n=Do(t);if(n||(e=t),this._items=[],this._itemMap=new Map,this._idProperty=e.idProperty||"id",this._bindToExternalToInternalMap=new WeakMap,this._bindToInternalToExternalMap=new WeakMap,this._skippedIndexesFromExternal=[],n)for(const e of t)this._items.push(e),this._itemMap.set(this._getItemIdBeforeAdding(e),e)}get length(){return this._items.length}get first(){return this._items[0]||null}get last(){return this._items[this.length-1]||null}add(t,e){return this.addMany([t],e)}addMany(t,e){if(void 0===e)e=this._items.length;else if(e>this._items.length||e<0)throw new s("collection-add-item-invalid-index",this);for(let n=0;n{this._setUpBindToBinding((e=>new t(e)))},using:t=>{"function"==typeof t?this._setUpBindToBinding((e=>t(e))):this._setUpBindToBinding((e=>e[t]))}}}_setUpBindToBinding(t){const e=this._bindToCollection,n=(n,o,i)=>{const r=e._bindToCollection==this,s=e._bindToInternalToExternalMap.get(o);if(r&&s)this._bindToExternalToInternalMap.set(o,s),this._bindToInternalToExternalMap.set(s,o);else{const n=t(o);if(!n)return void this._skippedIndexesFromExternal.push(i);let r=i;for(const t of this._skippedIndexesFromExternal)i>t&&r--;for(const t of e._skippedIndexesFromExternal)r>=t&&r++;this._bindToExternalToInternalMap.set(o,n),this._bindToInternalToExternalMap.set(n,o),this.add(n,r);for(let t=0;t{const o=this._bindToExternalToInternalMap.get(e);o&&this.remove(o),this._skippedIndexesFromExternal=this._skippedIndexesFromExternal.reduce(((t,e)=>(ne&&t.push(e),t)),[])}))}_getItemIdBeforeAdding(t){const e=this._idProperty;let n;if(e in t){if(n=t[e],"string"!=typeof n)throw new s("collection-add-invalid-id",this);if(this.get(n))throw new s("collection-add-item-already-exists",this)}else t[e]=n=i();return n}_remove(t){let e,n,o,i=!1;const r=this._idProperty;if("string"==typeof t?(n=t,o=this._itemMap.get(n),i=!o,o&&(e=this._items.indexOf(o))):"number"==typeof t?(e=t,o=this._items[e],i=!o,o&&(n=o[r])):(o=t,n=o[r],e=this._items.indexOf(o),i=-1==e||!this._itemMap.get(n)),i)throw new s("collection-remove-404",this);this._items.splice(e,1),this._itemMap.delete(n);const a=this._bindToInternalToExternalMap.get(o);return this._bindToInternalToExternalMap.delete(o),this._bindToExternalToInternalMap.delete(a),this.fire("remove",o,e),[o,e]}[Symbol.iterator](){return this._items[Symbol.iterator]()}}he(So,g);class Bo{constructor(t,e=[],n=[]){this._context=t,this._plugins=new Map,this._availablePlugins=new Map;for(const t of e)t.pluginName&&this._availablePlugins.set(t.pluginName,t);this._contextPlugins=new Map;for(const[t,e]of n)this._contextPlugins.set(t,e),this._contextPlugins.set(e,t),t.pluginName&&this._availablePlugins.set(t.pluginName,t)}*[Symbol.iterator](){for(const t of this._plugins)"function"==typeof t[0]&&(yield t)}get(t){const e=this._plugins.get(t);if(!e){let e=t;throw"function"==typeof t&&(e=t.pluginName||t.name),new s("plugincollection-plugin-not-loaded",this._context,{plugin:e})}return e}has(t){return this._plugins.has(t)}init(t,e=[],n=[]){const o=this,i=this._context;!function t(e,n=new Set){e.forEach((e=>{c(e)&&(n.has(e)||(n.add(e),e.pluginName&&!o._availablePlugins.has(e.pluginName)&&o._availablePlugins.set(e.pluginName,e),e.requires&&t(e.requires,n)))}))}(t),h(t);const r=[...function t(e,n=new Set){return e.map((t=>c(t)?t:o._availablePlugins.get(t))).reduce(((e,o)=>n.has(o)?e:(n.add(o),o.requires&&(h(o.requires,o),t(o.requires,n).forEach((t=>e.add(t)))),e.add(o))),new Set)}(t.filter((t=>!d(t,e))))];!function(t,e){for(const n of e){if("function"!=typeof n)throw new s("plugincollection-replace-plugin-invalid-type",null,{pluginItem:n});const e=n.pluginName;if(!e)throw new s("plugincollection-replace-plugin-missing-name",null,{pluginItem:n});if(n.requires&&n.requires.length)throw new s("plugincollection-plugin-for-replacing-cannot-have-dependencies",null,{pluginName:e});const i=o._availablePlugins.get(e);if(!i)throw new s("plugincollection-plugin-for-replacing-not-exist",null,{pluginName:e});const r=t.indexOf(i);if(-1===r){if(o._contextPlugins.has(i))return;throw new s("plugincollection-plugin-for-replacing-not-loaded",null,{pluginName:e})}if(i.requires&&i.requires.length)throw new s("plugincollection-replaced-plugin-cannot-have-dependencies",null,{pluginName:e});t.splice(r,1,n),o._availablePlugins.set(e,n)}}(r,n);const a=function(t){return t.map((t=>{const e=o._contextPlugins.get(t)||new t(i);return o._add(t,e),e}))}(r);return p(a,"init").then((()=>p(a,"afterInit"))).then((()=>a));function c(t){return"function"==typeof t}function l(t){return c(t)&&t.isContextPlugin}function d(t,e){return e.some((e=>e===t||(u(t)===e||u(e)===t)))}function u(t){return c(t)?t.pluginName||t.name:t}function h(t,n=null){t.map((t=>c(t)?t:o._availablePlugins.get(t)||t)).forEach((t=>{!function(t,e){if(c(t))return;if(e)throw new s("plugincollection-soft-required",i,{missingPlugin:t,requiredBy:u(e)});throw new s("plugincollection-plugin-not-found",i,{plugin:t})}(t,n),function(t,e){if(!l(e))return;if(l(t))return;throw new s("plugincollection-context-required",i,{plugin:u(t),requiredBy:u(e)})}(t,n),function(t,n){if(!n)return;if(!d(t,e))return;throw new s("plugincollection-required",i,{plugin:u(t),requiredBy:u(n)})}(t,n)}))}function p(t,e){return t.reduce(((t,n)=>n[e]?o._contextPlugins.has(n)?t:t.then(n[e].bind(n)):t),Promise.resolve())}}destroy(){const t=[];for(const[,e]of this)"function"!=typeof e.destroy||this._contextPlugins.has(e)||t.push(e.destroy());return Promise.all(t)}_add(t,e){this._plugins.set(t,e);const n=t.pluginName;if(n){if(this._plugins.has(n))throw new s("plugincollection-plugin-name-conflict",null,{pluginName:n,plugin1:this._plugins.get(n).constructor,plugin2:t});this._plugins.set(n,e)}}}function To(t){return Array.isArray(t)?t:[t]}function Po(t,e,n=1){if("number"!=typeof n)throw new s("translation-service-quantity-not-a-number",null,{quantity:n});const o=Object.keys(window.CKEDITOR_TRANSLATIONS).length;1===o&&(t=Object.keys(window.CKEDITOR_TRANSLATIONS)[0]);const i=e.id||e.string;if(0===o||!function(t,e){return!!window.CKEDITOR_TRANSLATIONS[t]&&!!window.CKEDITOR_TRANSLATIONS[t].dictionary[e]}(t,i))return 1!==n?e.plural:e.string;const r=window.CKEDITOR_TRANSLATIONS[t].dictionary,a=window.CKEDITOR_TRANSLATIONS[t].getPluralForm||(t=>1===t?0:1);if("string"==typeof r[i])return r[i];const c=Number(a(n));return r[i][c]}he(Bo,g),window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={});const Io=["ar","ara","fa","per","fas","he","heb","ku","kur","ug","uig"];function Ro(t){return Io.includes(t)?"rtl":"ltr"}class zo{constructor(t={}){this.uiLanguage=t.uiLanguage||"en",this.contentLanguage=t.contentLanguage||this.uiLanguage,this.uiLanguageDirection=Ro(this.uiLanguage),this.contentLanguageDirection=Ro(this.contentLanguage),this.t=(t,e)=>this._t(t,e)}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(t,e=[]){e=To(e),"string"==typeof t&&(t={string:t});const n=!!t.plural?e[0]:1;return function(t,e){return t.replace(/%(\d+)/g,((t,n)=>nt.destroy()))).then((()=>this.plugins.destroy()))}_addEditor(t,e){if(this._contextOwner)throw new s("context-addeditor-private-context");this.editors.add(t),e&&(this._contextOwner=t)}_removeEditor(t){return this.editors.has(t)&&this.editors.remove(t),this._contextOwner===t?this.destroy():Promise.resolve()}_getEditorConfig(){const t={};for(const e of this.config.names())["plugins","removePlugins","extraPlugins"].includes(e)||(t[e]=this.config.get(e));return t}static create(t){return new Promise((e=>{const n=new this(t);e(n.initPlugins().then((()=>n)))}))}}class No{constructor(t){this.context=t}destroy(){this.stopListening()}static get isContextPlugin(){return!0}}function Oo(t,e){const n=Math.min(t.length,e.length);for(let o=0;ot.data.length)throw new s("view-textproxy-wrong-offsetintext",this);if(n<0||e+n>t.data.length)throw new s("view-textproxy-wrong-length",this);this.data=t.data.substring(e,e+n),this.offsetInText=e}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(t){return"$textProxy"===t||"view:$textProxy"===t||"textProxy"===t||"view:textProxy"===t}getAncestors(t={includeSelf:!1,parentFirst:!1}){const e=[];let n=t.includeSelf?this.textNode:this.parent;for(;null!==n;)e[t.parentFirst?"push":"unshift"](n),n=n.parent;return e}}function qo(t){return Do(t)?new Map(t):function(t){const e=new Map;for(const n in t)e.set(n,t[n]);return e}(t)}class Wo{constructor(...t){this._patterns=[],this.add(...t)}add(...t){for(let e of t)("string"==typeof e||e instanceof RegExp)&&(e={name:e}),this._patterns.push(e)}match(...t){for(const e of t)for(const t of this._patterns){const n=jo(e,t);if(n)return{element:e,pattern:t,match:n}}return null}matchAll(...t){const e=[];for(const n of t)for(const t of this._patterns){const o=jo(n,t);o&&e.push({element:n,pattern:t,match:o})}return e.length>0?e:null}getElementName(){if(1!==this._patterns.length)return null;const t=this._patterns[0],e=t.name;return"function"==typeof t||!e||e instanceof RegExp?null:e}}function jo(t,e){if("function"==typeof e)return e(t);const n={};return e.name&&(n.name=function(t,e){if(t instanceof RegExp)return!!e.match(t);return t===e}(e.name,t.name),!n.name)||e.attributes&&(n.attributes=function(t,e){const n=new Set(e.getAttributeKeys());ye(t)?(void 0!==t.style&&a("matcher-pattern-deprecated-attributes-style-key",t),void 0!==t.class&&a("matcher-pattern-deprecated-attributes-class-key",t)):(n.delete("style"),n.delete("class"));return Uo(t,n,(t=>e.getAttribute(t)))}(e.attributes,t),!n.attributes)?null:!(e.classes&&(n.classes=function(t,e){return Uo(t,e.getClassNames())}(e.classes,t),!n.classes))&&(!(e.styles&&(n.styles=function(t,e){return Uo(t,e.getStyleNames(!0),(t=>e.getStyle(t)))}(e.styles,t),!n.styles))&&n)}function Uo(t,e,n){const o=function(t){if(Array.isArray(t))return t.map((t=>ye(t)?(void 0!==t.key&&void 0!==t.value||a("matcher-pattern-missing-key-or-value",t),[t.key,t.value]):[t,!0]));if(ye(t))return Object.entries(t);return[[t,!0]]}(t),i=Array.from(e),r=[];return o.forEach((([t,e])=>{i.forEach((o=>{(function(t,e){return!0===t||t===e||t instanceof RegExp&&e.match(t)})(t,o)&&function(t,e,n){if(!0===t)return!0;const o=n(e);return t===o||t instanceof RegExp&&!!String(o).match(t)}(e,o,n)&&r.push(o)}))})),!o.length||r.lengthi?0:i+e),(n=n>i?i:n)<0&&(n+=i),i=e>n?0:n-e>>>0,e>>>=0;for(var r=Array(i);++oe===t));return Array.isArray(e)}set(t,e){if(y(t))for(const[e,n]of Object.entries(t))this._styleProcessor.toNormalizedForm(e,n,this._styles);else this._styleProcessor.toNormalizedForm(t,e,this._styles)}remove(t){const e=Bi(t);mi(this._styles,e),delete this._styles[t],this._cleanEmptyObjectsOnPath(e)}getNormalized(t){return this._styleProcessor.getNormalized(t,this._styles)}toString(){return this.isEmpty?"":this._getStylesEntries().map((t=>t.join(":"))).sort().join(";")+";"}getAsString(t){if(this.isEmpty)return;if(this._styles[t]&&!y(this._styles[t]))return this._styles[t];const e=this._styleProcessor.getReducedForm(t,this._styles).find((([e])=>e===t));return Array.isArray(e)?e[1]:void 0}getStyleNames(t=!1){if(this.isEmpty)return[];if(t)return this._styleProcessor.getStyleNames(this._styles);return this._getStylesEntries().map((([t])=>t))}clear(){this._styles={}}_getStylesEntries(){const t=[],e=Object.keys(this._styles);for(const n of e)t.push(...this._styleProcessor.getReducedForm(n,this._styles));return t}_cleanEmptyObjectsOnPath(t){const e=t.split(".");if(!(e.length>1))return;const n=e.splice(0,e.length-1).join("."),o=gi(this._styles,n);if(!o)return;!Array.from(Object.keys(o)).length&&this.remove(n)}}class Si{constructor(){this._normalizers=new Map,this._extractors=new Map,this._reducers=new Map,this._consumables=new Map}toNormalizedForm(t,e,n){if(y(e))Ti(n,Bi(t),e);else if(this._normalizers.has(t)){const o=this._normalizers.get(t),{path:i,value:r}=o(e);Ti(n,i,r)}else Ti(n,t,e)}getNormalized(t,e){if(!t)return yi({},e);if(void 0!==e[t])return e[t];if(this._extractors.has(t)){const n=this._extractors.get(t);if("string"==typeof n)return gi(e,n);const o=n(t,e);if(o)return o}return gi(e,Bi(t))}getReducedForm(t,e){const n=this.getNormalized(t,e);if(void 0===n)return[];if(this._reducers.has(t)){return this._reducers.get(t)(n)}return[[t,n]]}getStyleNames(t){const e=Array.from(this._consumables.keys()).filter((e=>{const n=this.getNormalized(e,t);return n&&"object"==typeof n?Object.keys(n).length:n})),n=new Set([...e,...Object.keys(t)]);return Array.from(n.values())}getRelatedStyles(t){return this._consumables.get(t)||[]}setNormalizer(t,e){this._normalizers.set(t,e)}setExtractor(t,e){this._extractors.set(t,e)}setReducer(t,e){this._reducers.set(t,e)}setStyleRelation(t,e){this._mapStyleNames(t,e);for(const n of e)this._mapStyleNames(n,[t])}_mapStyleNames(t,e){this._consumables.has(t)||this._consumables.set(t,[]),this._consumables.get(t).push(...e)}}function Bi(t){return t.replace("-",".")}function Ti(t,e,n){let o=n;y(n)&&(o=yi({},gi(t,e),n)),Ei(t,e,o)}class Pi extends Vo{constructor(t,e,n,o){if(super(t),this.name=e,this._attrs=function(t){t=qo(t);for(const[e,n]of t)null===n?t.delete(e):"string"!=typeof n&&t.set(e,String(n));return t}(n),this._children=[],o&&this._insertChild(0,o),this._classes=new Set,this._attrs.has("class")){const t=this._attrs.get("class");Ii(this._classes,t),this._attrs.delete("class")}this._styles=new Di(this.document.stylesProcessor),this._attrs.has("style")&&(this._styles.setTo(this._attrs.get("style")),this._attrs.delete("style")),this._customProperties=new Map,this._isAllowedInsideAttributeElement=!1,this._unsafeAttributesToRender=[]}get childCount(){return this._children.length}get isEmpty(){return 0===this._children.length}get isAllowedInsideAttributeElement(){return this._isAllowedInsideAttributeElement}is(t,e=null){return e?e===this.name&&("element"===t||"view:element"===t):"element"===t||"view:element"===t||"node"===t||"view:node"===t}getChild(t){return this._children[t]}getChildIndex(t){return this._children.indexOf(t)}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(t){if("class"==t)return this._classes.size>0?[...this._classes].join(" "):void 0;if("style"==t){const t=this._styles.toString();return""==t?void 0:t}return this._attrs.get(t)}hasAttribute(t){return"class"==t?this._classes.size>0:"style"==t?!this._styles.isEmpty:this._attrs.has(t)}isSimilar(t){if(!(t instanceof Pi))return!1;if(this===t)return!0;if(this.name!=t.name)return!1;if(this.isAllowedInsideAttributeElement!=t.isAllowedInsideAttributeElement)return!1;if(this._attrs.size!==t._attrs.size||this._classes.size!==t._classes.size||this._styles.size!==t._styles.size)return!1;for(const[e,n]of this._attrs)if(!t._attrs.has(e)||t._attrs.get(e)!==n)return!1;for(const e of this._classes)if(!t._classes.has(e))return!1;for(const e of this._styles.getStyleNames())if(!t._styles.has(e)||t._styles.getAsString(e)!==this._styles.getAsString(e))return!1;return!0}hasClass(...t){for(const e of t)if(!this._classes.has(e))return!1;return!0}getClassNames(){return this._classes.keys()}getStyle(t){return this._styles.getAsString(t)}getNormalizedStyle(t){return this._styles.getNormalized(t)}getStyleNames(t=!1){return this._styles.getStyleNames(t)}hasStyle(...t){for(const e of t)if(!this._styles.has(e))return!1;return!0}findAncestor(...t){const e=new Wo(...t);let n=this.parent;for(;n;){if(e.match(n))return n;n=n.parent}return null}getCustomProperty(t){return this._customProperties.get(t)}*getCustomProperties(){yield*this._customProperties.entries()}getIdentity(){const t=Array.from(this._classes).sort().join(","),e=this._styles.toString(),n=Array.from(this._attrs).map((t=>`${t[0]}="${t[1]}"`)).sort().join(" ");return this.name+(""==t?"":` class="${t}"`)+(e?` style="${e}"`:"")+(""==n?"":` ${n}`)}shouldRenderUnsafeAttribute(t){return this._unsafeAttributesToRender.includes(t)}_clone(t=!1){const e=[];if(t)for(const n of this.getChildren())e.push(n._clone(t));const n=new this.constructor(this.document,this.name,this._attrs,e);return n._classes=new Set(this._classes),n._styles.set(this._styles.getNormalized()),n._customProperties=new Map(this._customProperties),n.getFillerOffset=this.getFillerOffset,n._isAllowedInsideAttributeElement=this.isAllowedInsideAttributeElement,n}_appendChild(t){return this._insertChild(this.childCount,t)}_insertChild(t,e){this._fireChange("children",this);let n=0;const o=function(t,e){if("string"==typeof e)return[new Lo(t,e)];Do(e)||(e=[e]);return Array.from(e).map((e=>"string"==typeof e?new Lo(t,e):e instanceof Ho?new Lo(t,e.data):e))}(this.document,e);for(const e of o)null!==e.parent&&e._remove(),e.parent=this,e.document=this.document,this._children.splice(t,0,e),t++,n++;return n}_removeChildren(t,e=1){this._fireChange("children",this);for(let n=t;n0&&(this._classes.clear(),!0):"style"==t?!this._styles.isEmpty&&(this._styles.clear(),!0):this._attrs.delete(t)}_addClass(t){this._fireChange("attributes",this);for(const e of To(t))this._classes.add(e)}_removeClass(t){this._fireChange("attributes",this);for(const e of To(t))this._classes.delete(e)}_setStyle(t,e){this._fireChange("attributes",this),this._styles.set(t,e)}_removeStyle(t){this._fireChange("attributes",this);for(const e of To(t))this._styles.remove(e)}_setCustomProperty(t,e){this._customProperties.set(t,e)}_removeCustomProperty(t){return this._customProperties.delete(t)}}function Ii(t,e){const n=e.split(/\s+/);t.clear(),n.forEach((e=>t.add(e)))}class Ri extends Pi{constructor(t,e,n,o){super(t,e,n,o),this.getFillerOffset=zi}is(t,e=null){return e?e===this.name&&("containerElement"===t||"view:containerElement"===t||"element"===t||"view:element"===t):"containerElement"===t||"view:containerElement"===t||"element"===t||"view:element"===t||"node"===t||"view:node"===t}}function zi(){const t=[...this.getChildren()],e=t[this.childCount-1];if(e&&e.is("element","br"))return this.childCount;for(const e of t)if(!e.is("uiElement"))return null;return this.childCount}class Fi extends Ri{constructor(t,e,n,o){super(t,e,n,o),this.set("isReadOnly",!1),this.set("isFocused",!1),this.bind("isReadOnly").to(t),this.bind("isFocused").to(t,"isFocused",(e=>e&&t.selection.editableElement==this)),this.listenTo(t.selection,"change",(()=>{this.isFocused=t.isFocused&&t.selection.editableElement==this}))}is(t,e=null){return e?e===this.name&&("editableElement"===t||"view:editableElement"===t||"containerElement"===t||"view:containerElement"===t||"element"===t||"view:element"===t):"editableElement"===t||"view:editableElement"===t||"containerElement"===t||"view:containerElement"===t||"element"===t||"view:element"===t||"node"===t||"view:node"===t}destroy(){this.stopListening()}}he(Fi,se);const Ni=Symbol("rootName");class Oi extends Fi{constructor(t,e){super(t,e),this.rootName="main"}is(t,e=null){return e?e===this.name&&("rootElement"===t||"view:rootElement"===t||"editableElement"===t||"view:editableElement"===t||"containerElement"===t||"view:containerElement"===t||"element"===t||"view:element"===t):"rootElement"===t||"view:rootElement"===t||"editableElement"===t||"view:editableElement"===t||"containerElement"===t||"view:containerElement"===t||"element"===t||"view:element"===t||"node"===t||"view:node"===t}get rootName(){return this.getCustomProperty(Ni)}set rootName(t){this._setCustomProperty(Ni,t)}set _name(t){this.name=t}}class Mi{constructor(t={}){if(!t.boundaries&&!t.startPosition)throw new s("view-tree-walker-no-start-position",null);if(t.direction&&"forward"!=t.direction&&"backward"!=t.direction)throw new s("view-tree-walker-unknown-direction",t.startPosition,{direction:t.direction});this.boundaries=t.boundaries||null,t.startPosition?this.position=Vi._createAt(t.startPosition):this.position=Vi._createAt(t.boundaries["backward"==t.direction?"end":"start"]),this.direction=t.direction||"forward",this.singleCharacters=!!t.singleCharacters,this.shallow=!!t.shallow,this.ignoreElementEnd=!!t.ignoreElementEnd,this._boundaryStartParent=this.boundaries?this.boundaries.start.parent:null,this._boundaryEndParent=this.boundaries?this.boundaries.end.parent:null}[Symbol.iterator](){return this}skip(t){let e,n,o;do{o=this.position,({done:e,value:n}=this.next())}while(!e&&t(n));e||(this.position=o)}next(){return"forward"==this.direction?this._next():this._previous()}_next(){let t=this.position.clone();const e=this.position,n=t.parent;if(null===n.parent&&t.offset===n.childCount)return{done:!0};if(n===this._boundaryEndParent&&t.offset==this.boundaries.end.offset)return{done:!0};let o;if(n instanceof Lo){if(t.isAtEnd)return this.position=Vi._createAfter(n),this._next();o=n.data[t.offset]}else o=n.getChild(t.offset);if(o instanceof Pi)return this.shallow?t.offset++:t=new Vi(o,0),this.position=t,this._formatReturnValue("elementStart",o,e,t,1);if(o instanceof Lo){if(this.singleCharacters)return t=new Vi(o,0),this.position=t,this._next();{let n,i=o.data.length;return o==this._boundaryEndParent?(i=this.boundaries.end.offset,n=new Ho(o,0,i),t=Vi._createAfter(n)):(n=new Ho(o,0,o.data.length),t.offset++),this.position=t,this._formatReturnValue("text",n,e,t,i)}}if("string"==typeof o){let o;if(this.singleCharacters)o=1;else{o=(n===this._boundaryEndParent?this.boundaries.end.offset:n.data.length)-t.offset}const i=new Ho(n,t.offset,o);return t.offset+=o,this.position=t,this._formatReturnValue("text",i,e,t,o)}return t=Vi._createAfter(n),this.position=t,this.ignoreElementEnd?this._next():this._formatReturnValue("elementEnd",n,e,t)}_previous(){let t=this.position.clone();const e=this.position,n=t.parent;if(null===n.parent&&0===t.offset)return{done:!0};if(n==this._boundaryStartParent&&t.offset==this.boundaries.start.offset)return{done:!0};let o;if(n instanceof Lo){if(t.isAtStart)return this.position=Vi._createBefore(n),this._previous();o=n.data[t.offset-1]}else o=n.getChild(t.offset-1);if(o instanceof Pi)return this.shallow?(t.offset--,this.position=t,this._formatReturnValue("elementStart",o,e,t,1)):(t=new Vi(o,o.childCount),this.position=t,this.ignoreElementEnd?this._previous():this._formatReturnValue("elementEnd",o,e,t));if(o instanceof Lo){if(this.singleCharacters)return t=new Vi(o,o.data.length),this.position=t,this._previous();{let n,i=o.data.length;if(o==this._boundaryStartParent){const e=this.boundaries.start.offset;n=new Ho(o,e,o.data.length-e),i=n.data.length,t=Vi._createBefore(n)}else n=new Ho(o,0,o.data.length),t.offset--;return this.position=t,this._formatReturnValue("text",n,e,t,i)}}if("string"==typeof o){let o;if(this.singleCharacters)o=1;else{const e=n===this._boundaryStartParent?this.boundaries.start.offset:0;o=t.offset-e}t.offset-=o;const i=new Ho(n,t.offset,o);return this.position=t,this._formatReturnValue("text",i,e,t,o)}return t=Vi._createBefore(n),this.position=t,this._formatReturnValue("elementStart",n,e,t,1)}_formatReturnValue(t,e,n,o,i){return e instanceof Ho&&(e.offsetInText+e.data.length==e.textNode.data.length&&("forward"!=this.direction||this.boundaries&&this.boundaries.end.isEqual(this.position)?n=Vi._createAfter(e.textNode):(o=Vi._createAfter(e.textNode),this.position=o)),0===e.offsetInText&&("backward"!=this.direction||this.boundaries&&this.boundaries.start.isEqual(this.position)?n=Vi._createBefore(e.textNode):(o=Vi._createBefore(e.textNode),this.position=o))),{done:!1,value:{type:t,item:e,previousPosition:n,nextPosition:o,length:i}}}}class Vi{constructor(t,e){this.parent=t,this.offset=e}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 t=this.parent.is("$text")?this.parent.data.length:this.parent.childCount;return this.offset===t}get root(){return this.parent.root}get editableElement(){let t=this.parent;for(;!(t instanceof Fi);){if(!t.parent)return null;t=t.parent}return t}getShiftedBy(t){const e=Vi._createAt(this),n=e.offset+t;return e.offset=n<0?0:n,e}getLastMatchingPosition(t,e={}){e.startPosition=this;const n=new Mi(e);return n.skip(t),n.position}getAncestors(){return this.parent.is("documentFragment")?[this.parent]:this.parent.getAncestors({includeSelf:!0})}getCommonAncestor(t){const e=this.getAncestors(),n=t.getAncestors();let o=0;for(;e[o]==n[o]&&e[o];)o++;return 0===o?null:e[o-1]}is(t){return"position"===t||"view:position"===t}isEqual(t){return this.parent==t.parent&&this.offset==t.offset}isBefore(t){return"before"==this.compareWith(t)}isAfter(t){return"after"==this.compareWith(t)}compareWith(t){if(this.root!==t.root)return"different";if(this.isEqual(t))return"same";const e=this.parent.is("node")?this.parent.getPath():[],n=t.parent.is("node")?t.parent.getPath():[];e.push(this.offset),n.push(t.offset);const o=Oo(e,n);switch(o){case"prefix":return"before";case"extension":return"after";default:return e[o]0?new this(n,o):new this(o,n)}static _createIn(t){return this._createFromParentsAndOffsets(t,0,t,t.childCount)}static _createOn(t){const e=t.is("$textProxy")?t.offsetSize:1;return this._createFromPositionAndShift(Vi._createBefore(t),e)}}function Hi(t){return!(!t.item.is("attributeElement")&&!t.item.is("uiElement"))}function qi(t){let e=0;for(const n of t)e++;return e}class Wi{constructor(t=null,e,n){this._ranges=[],this._lastRangeBackward=!1,this._isFake=!1,this._fakeSelectionLabel="",this.setTo(t,e,n)}get isFake(){return this._isFake}get fakeSelectionLabel(){return this._fakeSelectionLabel}get anchor(){if(!this._ranges.length)return null;const t=this._ranges[this._ranges.length-1];return(this._lastRangeBackward?t.end:t.start).clone()}get focus(){if(!this._ranges.length)return null;const t=this._ranges[this._ranges.length-1];return(this._lastRangeBackward?t.start:t.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 t of this._ranges)yield t.clone()}getFirstRange(){let t=null;for(const e of this._ranges)t&&!e.start.isBefore(t.start)||(t=e);return t?t.clone():null}getLastRange(){let t=null;for(const e of this._ranges)t&&!e.end.isAfter(t.end)||(t=e);return t?t.clone():null}getFirstPosition(){const t=this.getFirstRange();return t?t.start.clone():null}getLastPosition(){const t=this.getLastRange();return t?t.end.clone():null}isEqual(t){if(this.isFake!=t.isFake)return!1;if(this.isFake&&this.fakeSelectionLabel!=t.fakeSelectionLabel)return!1;if(this.rangeCount!=t.rangeCount)return!1;if(0===this.rangeCount)return!0;if(!this.anchor.isEqual(t.anchor)||!this.focus.isEqual(t.focus))return!1;for(const e of this._ranges){let n=!1;for(const o of t._ranges)if(e.isEqual(o)){n=!0;break}if(!n)return!1}return!0}isSimilar(t){if(this.isBackward!=t.isBackward)return!1;const e=qi(this.getRanges());if(e!=qi(t.getRanges()))return!1;if(0==e)return!0;for(let e of this.getRanges()){e=e.getTrimmed();let n=!1;for(let o of t.getRanges())if(o=o.getTrimmed(),e.start.isEqual(o.start)&&e.end.isEqual(o.end)){n=!0;break}if(!n)return!1}return!0}getSelectedElement(){return 1!==this.rangeCount?null:this.getFirstRange().getContainedElement()}setTo(t,e,n){if(null===t)this._setRanges([]),this._setFakeOptions(e);else if(t instanceof Wi||t instanceof ji)this._setRanges(t.getRanges(),t.isBackward),this._setFakeOptions({fake:t.isFake,label:t.fakeSelectionLabel});else if(t instanceof Li)this._setRanges([t],e&&e.backward),this._setFakeOptions(e);else if(t instanceof Vi)this._setRanges([new Li(t)]),this._setFakeOptions(e);else if(t instanceof Vo){const o=!!n&&!!n.backward;let i;if(void 0===e)throw new s("view-selection-setto-required-second-parameter",this);i="in"==e?Li._createIn(t):"on"==e?Li._createOn(t):new Li(Vi._createAt(t,e)),this._setRanges([i],o),this._setFakeOptions(n)}else{if(!Do(t))throw new s("view-selection-setto-not-selectable",this);this._setRanges(t,e&&e.backward),this._setFakeOptions(e)}this.fire("change")}setFocus(t,e){if(null===this.anchor)throw new s("view-selection-setfocus-no-ranges",this);const n=Vi._createAt(t,e);if("same"==n.compareWith(this.focus))return;const o=this.anchor;this._ranges.pop(),"before"==n.compareWith(o)?this._addRange(new Li(n,o),!0):this._addRange(new Li(o,n)),this.fire("change")}is(t){return"selection"===t||"view:selection"===t}_setRanges(t,e=!1){t=Array.from(t),this._ranges=[];for(const e of t)this._addRange(e);this._lastRangeBackward=!!e}_setFakeOptions(t={}){this._isFake=!!t.fake,this._fakeSelectionLabel=t.fake&&t.label||""}_addRange(t,e=!1){if(!(t instanceof Li))throw new s("view-selection-add-range-not-range",this);this._pushRange(t),this._lastRangeBackward=!!e}_pushRange(t){for(const e of this._ranges)if(t.isIntersecting(e))throw new s("view-selection-range-intersects",this,{addedRange:t,intersectingRange:e});this._ranges.push(new Li(t.start,t.end))}}he(Wi,g);class ji{constructor(t=null,e,n){this._selection=new Wi,this._selection.delegate("change").to(this),this._selection.setTo(t,e,n)}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(t){return this._selection.isEqual(t)}isSimilar(t){return this._selection.isSimilar(t)}is(t){return"selection"===t||"documentSelection"==t||"view:selection"==t||"view:documentSelection"==t}_setTo(t,e,n){this._selection.setTo(t,e,n)}_setFocus(t,e){this._selection.setFocus(t,e)}}he(ji,g);class Ui extends e{constructor(t,e,n){super(t,e),this.startRange=n,this._eventPhase="none",this._currentTarget=null}get eventPhase(){return this._eventPhase}get currentTarget(){return this._currentTarget}}const $i=Symbol("bubbling contexts"),Gi={fire(t,...n){try{const o=t instanceof e?t:new e(this,t),i=Qi(this);if(!i.size)return;if(Zi(o,"capturing",this),Ji(i,"$capture",o,...n))return o.return;const r=o.startRange||this.selection.getFirstRange(),s=r?r.getContainedElement():null,a=!!s&&Boolean(Yi(i,s));let c=s||function(t){if(!t)return null;const e=t.start.parent,n=t.end.parent,o=e.getPath(),i=n.getPath();return o.length>i.length?e:n}(r);if(Zi(o,"atTarget",c),!a){if(Ji(i,"$text",o,...n))return o.return;Zi(o,"bubbling",c)}for(;c;){if(c.is("rootElement")){if(Ji(i,"$root",o,...n))return o.return}else if(c.is("element")&&Ji(i,c.name,o,...n))return o.return;if(Ji(i,c,o,...n))return o.return;c=c.parent,Zi(o,"bubbling",c)}return Zi(o,"bubbling",this),Ji(i,"$document",o,...n),o.return}catch(t){s.rethrowUnexpectedError(t,this)}},_addEventListener(t,e,n){const o=To(n.context||"$document"),i=Qi(this);for(const r of o){let o=i.get(r);o||(o=Object.create(g),i.set(r,o)),this.listenTo(o,t,e,n)}},_removeEventListener(t,e){const n=Qi(this);for(const o of n.values())this.stopListening(o,t,e)}},Ki=Gi;function Zi(t,e,n){t instanceof Ui&&(t._eventPhase=e,t._currentTarget=n)}function Ji(t,e,n,...o){const i="string"==typeof e?t.get(e):Yi(t,e);return!!i&&(i.fire(n,...o),n.stop.called)}function Yi(t,e){for(const[n,o]of t)if("function"==typeof n&&n(e))return o;return null}function Qi(t){return t[$i]||(t[$i]=new Map),t[$i]}class Xi{constructor(t){this.selection=new ji,this.roots=new So({idProperty:"rootName"}),this.stylesProcessor=t,this.set("isReadOnly",!1),this.set("isFocused",!1),this.set("isSelecting",!1),this.set("isComposing",!1),this._postFixers=new Set}getRoot(t="main"){return this.roots.get(t)}registerPostFixer(t){this._postFixers.add(t)}destroy(){this.roots.map((t=>t.destroy())),this.stopListening()}_callPostFixers(t){let e=!1;do{for(const n of this._postFixers)if(e=n(t),e)break}while(e)}}he(Xi,Ki),he(Xi,se);class tr extends Pi{constructor(t,e,n,o){super(t,e,n,o),this.getFillerOffset=er,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 s("attribute-element-get-elements-with-same-id-no-id",this);return new Set(this._clonesGroup)}is(t,e=null){return e?e===this.name&&("attributeElement"===t||"view:attributeElement"===t||"element"===t||"view:element"===t):"attributeElement"===t||"view:attributeElement"===t||"element"===t||"view:element"===t||"node"===t||"view:node"===t}isSimilar(t){return null!==this.id||null!==t.id?this.id===t.id:super.isSimilar(t)&&this.priority==t.priority}_clone(t){const e=super._clone(t);return e._priority=this._priority,e._id=this._id,e}}function er(){if(nr(this))return null;let t=this.parent;for(;t&&t.is("attributeElement");){if(nr(t)>1)return null;t=t.parent}return!t||nr(t)>1?null:this.childCount}function nr(t){return Array.from(t.getChildren()).filter((t=>!t.is("uiElement"))).length}tr.DEFAULT_PRIORITY=10;class or extends Pi{constructor(t,e,n,o){super(t,e,n,o),this._isAllowedInsideAttributeElement=!0,this.getFillerOffset=ir}is(t,e=null){return e?e===this.name&&("emptyElement"===t||"view:emptyElement"===t||"element"===t||"view:element"===t):"emptyElement"===t||"view:emptyElement"===t||"element"===t||"view:element"===t||"node"===t||"view:node"===t}_insertChild(t,e){if(e&&(e instanceof Vo||Array.from(e).length>0))throw new s("view-emptyelement-cannot-add",[this,e])}}function ir(){return null}const rr=navigator.userAgent.toLowerCase(),sr={isMac:cr(rr),isWindows:function(t){return t.indexOf("windows")>-1}(rr),isGecko:function(t){return!!t.match(/gecko\/\d+/)}(rr),isSafari:function(t){return t.indexOf(" applewebkit/")>-1&&-1===t.indexOf("chrome")}(rr),isiOS:function(t){return!!t.match(/iphone|ipad/i)||cr(t)&&navigator.maxTouchPoints>0}(rr),isAndroid:function(t){return t.indexOf("android")>-1}(rr),isBlink:function(t){return t.indexOf("chrome/")>-1&&t.indexOf("edge/")<0}(rr),features:{isRegExpUnicodePropertySupported:function(){let t=!1;try{t=0==="ć".search(new RegExp("[\\p{L}]","u"))}catch(t){}return t}()}},ar=sr;function cr(t){return t.indexOf("macintosh")>-1}const lr={ctrl:"⌃",cmd:"⌘",alt:"⌥",shift:"⇧"},dr={ctrl:"Ctrl+",alt:"Alt+",shift:"Shift+"},ur=function(){const t={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 e=65;e<=90;e++){const n=String.fromCharCode(e);t[n.toLowerCase()]=e}for(let e=48;e<=57;e++)t[e-48]=e;for(let e=112;e<=123;e++)t["f"+(e-111)]=e;for(const e of"`-=[];',./\\")t[e]=e.charCodeAt(0);return t}(),hr=Object.fromEntries(Object.entries(ur).map((([t,e])=>[e,t.charAt(0).toUpperCase()+t.slice(1)])));function pr(t){let e;if("string"==typeof t){if(e=ur[t.toLowerCase()],!e)throw new s("keyboard-unknown-key",null,{key:t})}else e=t.keyCode+(t.altKey?ur.alt:0)+(t.ctrlKey?ur.ctrl:0)+(t.shiftKey?ur.shift:0)+(t.metaKey?ur.cmd:0);return e}function mr(t){return"string"==typeof t&&(t=function(t){return t.split("+").map((t=>t.trim()))}(t)),t.map((t=>"string"==typeof t?function(t){if(t.endsWith("!"))return pr(t.slice(0,-1));const e=pr(t);return ar.isMac&&e==ur.ctrl?ur.cmd:e}(t):t)).reduce(((t,e)=>e+t),0)}function gr(t){let e=mr(t);return Object.entries(ar.isMac?lr:dr).reduce(((t,[n,o])=>(0!=(e&ur[n])&&(e&=~ur[n],t+=o),t)),"")+(e?hr[e]:"")}function fr(t,e){const n="ltr"===e;switch(t){case ur.arrowleft:return n?"left":"right";case ur.arrowright:return n?"right":"left";case ur.arrowup:return"up";case ur.arrowdown:return"down"}}class br extends Pi{constructor(t,e,n,o){super(t,e,n,o),this._isAllowedInsideAttributeElement=!0,this.getFillerOffset=wr}is(t,e=null){return e?e===this.name&&("uiElement"===t||"view:uiElement"===t||"element"===t||"view:element"===t):"uiElement"===t||"view:uiElement"===t||"element"===t||"view:element"===t||"node"===t||"view:node"===t}_insertChild(t,e){if(e&&(e instanceof Vo||Array.from(e).length>0))throw new s("view-uielement-cannot-add",this)}render(t){return this.toDomElement(t)}toDomElement(t){const e=t.createElement(this.name);for(const t of this.getAttributeKeys())e.setAttribute(t,this.getAttribute(t));return e}}function kr(t){t.document.on("arrowKey",((e,n)=>function(t,e,n){if(e.keyCode==ur.arrowright){const t=e.domTarget.ownerDocument.defaultView.getSelection(),o=1==t.rangeCount&&t.getRangeAt(0).collapsed;if(o||e.shiftKey){const e=t.focusNode,i=t.focusOffset,r=n.domPositionToView(e,i);if(null===r)return;let s=!1;const a=r.getLastMatchingPosition((t=>(t.item.is("uiElement")&&(s=!0),!(!t.item.is("uiElement")&&!t.item.is("attributeElement")))));if(s){const e=n.viewPositionToDom(a);o?t.collapse(e.parent,e.offset):t.extend(e.parent,e.offset)}}}}(0,n,t.domConverter)),{priority:"low"})}function wr(){return null}class _r extends Pi{constructor(t,e,n,o){super(t,e,n,o),this._isAllowedInsideAttributeElement=!0,this.getFillerOffset=Cr}is(t,e=null){return e?e===this.name&&("rawElement"===t||"view:rawElement"===t||"element"===t||"view:element"===t):"rawElement"===t||"view:rawElement"===t||t===this.name||t==="view:"+this.name||"element"===t||"view:element"===t||"node"===t||"view:node"===t}_insertChild(t,e){if(e&&(e instanceof Vo||Array.from(e).length>0))throw new s("view-rawelement-cannot-add",[this,e])}}function Cr(){return null}class Ar{constructor(t,e){this.document=t,this._children=[],e&&this._insertChild(0,e)}[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(t){return"documentFragment"===t||"view:documentFragment"===t}_appendChild(t){return this._insertChild(this.childCount,t)}getChild(t){return this._children[t]}getChildIndex(t){return this._children.indexOf(t)}getChildren(){return this._children[Symbol.iterator]()}_insertChild(t,e){this._fireChange("children",this);let n=0;const o=function(t,e){if("string"==typeof e)return[new Lo(t,e)];Do(e)||(e=[e]);return Array.from(e).map((e=>"string"==typeof e?new Lo(t,e):e instanceof Ho?new Lo(t,e.data):e))}(this.document,e);for(const e of o)null!==e.parent&&e._remove(),e.parent=this,this._children.splice(t,0,e),t++,n++;return n}_removeChildren(t,e=1){this._fireChange("children",this);for(let n=t;n{}),void 0!==o.isAllowedInsideAttributeElement&&(i._isAllowedInsideAttributeElement=o.isAllowedInsideAttributeElement),o.renderUnsafeAttributes&&i._unsafeAttributesToRender.push(...o.renderUnsafeAttributes),i}setAttribute(t,e,n){n._setAttribute(t,e)}removeAttribute(t,e){e._removeAttribute(t)}addClass(t,e){e._addClass(t)}removeClass(t,e){e._removeClass(t)}setStyle(t,e,n){ye(t)&&void 0===n&&(n=e),n._setStyle(t,e)}removeStyle(t,e){e._removeStyle(t)}setCustomProperty(t,e,n){n._setCustomProperty(t,e)}removeCustomProperty(t,e){return e._removeCustomProperty(t)}breakAttributes(t){return t instanceof Vi?this._breakAttributes(t):this._breakAttributesRange(t)}breakContainer(t){const e=t.parent;if(!e.is("containerElement"))throw new s("view-writer-break-non-container-element",this.document);if(!e.parent)throw new s("view-writer-break-root",this.document);if(t.isAtStart)return Vi._createBefore(e);if(!t.isAtEnd){const n=e._clone(!1);this.insert(Vi._createAfter(e),n);const o=new Li(t,Vi._createAt(e,"end")),i=new Vi(n,0);this.move(o,i)}return Vi._createAfter(e)}mergeAttributes(t){const e=t.offset,n=t.parent;if(n.is("$text"))return t;if(n.is("attributeElement")&&0===n.childCount){const t=n.parent,e=n.index;return n._remove(),this._removeFromClonedElementsGroup(n),this.mergeAttributes(new Vi(t,e))}const o=n.getChild(e-1),i=n.getChild(e);if(!o||!i)return t;if(o.is("$text")&&i.is("$text"))return Sr(o,i);if(o.is("attributeElement")&&i.is("attributeElement")&&o.isSimilar(i)){const t=o.childCount;return o._appendChild(i.getChildren()),i._remove(),this._removeFromClonedElementsGroup(i),this.mergeAttributes(new Vi(o,t))}return t}mergeContainers(t){const e=t.nodeBefore,n=t.nodeAfter;if(!(e&&n&&e.is("containerElement")&&n.is("containerElement")))throw new s("view-writer-merge-containers-invalid-position",this.document);const o=e.getChild(e.childCount-1),i=o instanceof Lo?Vi._createAt(o,"end"):Vi._createAt(e,"end");return this.move(Li._createIn(n),Vi._createAt(e,"end")),this.remove(Li._createOn(n)),i}insert(t,e){Br(e=Do(e)?[...e]:[e],this.document);const n=e.reduce(((t,e)=>{const n=t[t.length-1],o=!(e.is("uiElement")&&e.isAllowedInsideAttributeElement);return n&&n.breakAttributes==o?n.nodes.push(e):t.push({breakAttributes:o,nodes:[e]}),t}),[]);let o=null,i=t;for(const{nodes:t,breakAttributes:e}of n){const n=this._insertNodes(i,t,e);o||(o=n.start),i=n.end}return o?new Li(o,i):new Li(t)}remove(t){const e=t instanceof Li?t:Li._createOn(t);if(Ir(e,this.document),e.isCollapsed)return new Ar(this.document);const{start:n,end:o}=this._breakAttributesRange(e,!0),i=n.parent,r=o.offset-n.offset,s=i._removeChildren(n.offset,r);for(const t of s)this._removeFromClonedElementsGroup(t);const a=this.mergeAttributes(n);return e.start=a,e.end=a.clone(),new Ar(this.document,s)}clear(t,e){Ir(t,this.document);const n=t.getWalker({direction:"backward",ignoreElementEnd:!0});for(const o of n){const n=o.item;let i;if(n.is("element")&&e.isSimilar(n))i=Li._createOn(n);else if(!o.nextPosition.isAfter(t.start)&&n.is("$textProxy")){const t=n.getAncestors().find((t=>t.is("element")&&e.isSimilar(t)));t&&(i=Li._createIn(t))}i&&(i.end.isAfter(t.end)&&(i.end=t.end),i.start.isBefore(t.start)&&(i.start=t.start),this.remove(i))}}move(t,e){let n;if(e.isAfter(t.end)){const o=(e=this._breakAttributes(e,!0)).parent,i=o.childCount;t=this._breakAttributesRange(t,!0),n=this.remove(t),e.offset+=o.childCount-i}else n=this.remove(t);return this.insert(e,n)}wrap(t,e){if(!(e instanceof tr))throw new s("view-writer-wrap-invalid-attribute",this.document);if(Ir(t,this.document),t.isCollapsed){let o=t.start;o.parent.is("element")&&(n=o.parent,!Array.from(n.getChildren()).some((t=>!t.is("uiElement"))))&&(o=o.getLastMatchingPosition((t=>t.item.is("uiElement")))),o=this._wrapPosition(o,e);const i=this.document.selection;return i.isCollapsed&&i.getFirstPosition().isEqual(t.start)&&this.setSelection(o),new Li(o)}return this._wrapRange(t,e);var n}unwrap(t,e){if(!(e instanceof tr))throw new s("view-writer-unwrap-invalid-attribute",this.document);if(Ir(t,this.document),t.isCollapsed)return t;const{start:n,end:o}=this._breakAttributesRange(t,!0),i=n.parent,r=this._unwrapChildren(i,n.offset,o.offset,e),a=this.mergeAttributes(r.start);a.isEqual(r.start)||r.end.offset--;const c=this.mergeAttributes(r.end);return new Li(a,c)}rename(t,e){const n=new Ri(this.document,t,e.getAttributes());return this.insert(Vi._createAfter(e),n),this.move(Li._createIn(e),Vi._createAt(n,0)),this.remove(Li._createOn(e)),n}clearClonedElementsGroup(t){this._cloneGroups.delete(t)}createPositionAt(t,e){return Vi._createAt(t,e)}createPositionAfter(t){return Vi._createAfter(t)}createPositionBefore(t){return Vi._createBefore(t)}createRange(t,e){return new Li(t,e)}createRangeOn(t){return Li._createOn(t)}createRangeIn(t){return Li._createIn(t)}createSelection(t,e,n){return new Wi(t,e,n)}_insertNodes(t,e,n){let o,i;if(o=n?yr(t):t.parent.is("$text")?t.parent.parent:t.parent,!o)throw new s("view-writer-invalid-position-container",this.document);i=n?this._breakAttributes(t,!0):t.parent.is("$text")?Dr(t):t;const r=o._insertChild(i.offset,e);for(const t of e)this._addToClonedElementsGroup(t);const a=i.getShiftedBy(r),c=this.mergeAttributes(i);c.isEqual(i)||a.offset--;const l=this.mergeAttributes(a);return new Li(c,l)}_wrapChildren(t,e,n,o){let i=e;const r=[];for(;i!1,t.parent._insertChild(t.offset,n);const o=new Li(t,t.getShiftedBy(1));this.wrap(o,e);const i=new Vi(n.parent,n.index);n._remove();const r=i.nodeBefore,s=i.nodeAfter;return r instanceof Lo&&s instanceof Lo?Sr(r,s):Er(i)}_wrapAttributeElement(t,e){if(!Rr(t,e))return!1;if(t.name!==e.name||t.priority!==e.priority)return!1;for(const n of t.getAttributeKeys())if("class"!==n&&"style"!==n&&e.hasAttribute(n)&&e.getAttribute(n)!==t.getAttribute(n))return!1;for(const n of t.getStyleNames())if(e.hasStyle(n)&&e.getStyle(n)!==t.getStyle(n))return!1;for(const n of t.getAttributeKeys())"class"!==n&&"style"!==n&&(e.hasAttribute(n)||this.setAttribute(n,t.getAttribute(n),e));for(const n of t.getStyleNames())e.hasStyle(n)||this.setStyle(n,t.getStyle(n),e);for(const n of t.getClassNames())e.hasClass(n)||this.addClass(n,e);return!0}_unwrapAttributeElement(t,e){if(!Rr(t,e))return!1;if(t.name!==e.name||t.priority!==e.priority)return!1;for(const n of t.getAttributeKeys())if("class"!==n&&"style"!==n&&(!e.hasAttribute(n)||e.getAttribute(n)!==t.getAttribute(n)))return!1;if(!e.hasClass(...t.getClassNames()))return!1;for(const n of t.getStyleNames())if(!e.hasStyle(n)||e.getStyle(n)!==t.getStyle(n))return!1;for(const n of t.getAttributeKeys())"class"!==n&&"style"!==n&&this.removeAttribute(n,e);return this.removeClass(Array.from(t.getClassNames()),e),this.removeStyle(Array.from(t.getStyleNames()),e),!0}_breakAttributesRange(t,e=!1){const n=t.start,o=t.end;if(Ir(t,this.document),t.isCollapsed){const n=this._breakAttributes(t.start,e);return new Li(n,n)}const i=this._breakAttributes(o,e),r=i.parent.childCount,s=this._breakAttributes(n,e);return i.offset+=i.parent.childCount-r,new Li(s,i)}_breakAttributes(t,e=!1){const n=t.offset,o=t.parent;if(t.parent.is("emptyElement"))throw new s("view-writer-cannot-break-empty-element",this.document);if(t.parent.is("uiElement"))throw new s("view-writer-cannot-break-ui-element",this.document);if(t.parent.is("rawElement"))throw new s("view-writer-cannot-break-raw-element",this.document);if(!e&&o.is("$text")&&Pr(o.parent))return t.clone();if(Pr(o))return t.clone();if(o.is("$text"))return this._breakAttributes(Dr(t),e);if(n==o.childCount){const t=new Vi(o.parent,o.index+1);return this._breakAttributes(t,e)}if(0===n){const t=new Vi(o.parent,o.index);return this._breakAttributes(t,e)}{const t=o.index+1,i=o._clone();o.parent._insertChild(t,i),this._addToClonedElementsGroup(i);const r=o.childCount-n,s=o._removeChildren(n,r);i._appendChild(s);const a=new Vi(o.parent,t);return this._breakAttributes(a,e)}}_addToClonedElementsGroup(t){if(!t.root.is("rootElement"))return;if(t.is("element"))for(const e of t.getChildren())this._addToClonedElementsGroup(e);const e=t.id;if(!e)return;let n=this._cloneGroups.get(e);n||(n=new Set,this._cloneGroups.set(e,n)),n.add(t),t._clonesGroup=n}_removeFromClonedElementsGroup(t){if(t.is("element"))for(const e of t.getChildren())this._removeFromClonedElementsGroup(e);const e=t.id;if(!e)return;const n=this._cloneGroups.get(e);n&&n.delete(t)}}function yr(t){let e=t.parent;for(;!Pr(e);){if(!e)return;e=e.parent}return e}function xr(t,e){return t.prioritye.priority)&&t.getIdentity()n instanceof t)))throw new s("view-writer-insert-invalid-node-type",e);n.is("$text")||Br(n.getChildren(),e)}}const Tr=[Lo,tr,Ri,or,_r,br];function Pr(t){return t&&(t.is("containerElement")||t.is("documentFragment"))}function Ir(t,e){const n=yr(t.start),o=yr(t.end);if(!n||!o||n!==o)throw new s("view-writer-invalid-range-container",e)}function Rr(t,e){return null===t.id&&null===e.id}function zr(t){return"[object Text]"==Object.prototype.toString.call(t)}const Fr=t=>t.createTextNode(" "),Nr=t=>{const e=t.createElement("span");return e.dataset.ckeFiller=!0,e.innerHTML=" ",e},Or=t=>{const e=t.createElement("br");return e.dataset.ckeFiller=!0,e},Mr="⁠".repeat(7);function Vr(t){return zr(t)&&t.data.substr(0,7)===Mr}function Lr(t){return 7==t.data.length&&Vr(t)}function Hr(t){return Vr(t)?t.data.slice(7):t.data}function qr(t,e){if(e.keyCode==ur.arrowleft){const t=e.domTarget.ownerDocument.defaultView.getSelection();if(1==t.rangeCount&&t.getRangeAt(0).collapsed){const e=t.getRangeAt(0).startContainer,n=t.getRangeAt(0).startOffset;Vr(e)&&n<=7&&t.collapse(e,0)}}}function Wr(t,e,n,o=!1){n=n||function(t,e){return t===e},Array.isArray(t)||(t=Array.prototype.slice.call(t)),Array.isArray(e)||(e=Array.prototype.slice.call(e));const i=function(t,e,n){const o=jr(t,e,n);if(-1===o)return{firstIndex:-1,lastIndexOld:-1,lastIndexNew:-1};const i=Ur(t,o),r=Ur(e,o),s=jr(i,r,n),a=t.length-s,c=e.length-s;return{firstIndex:o,lastIndexOld:a,lastIndexNew:c}}(t,e,n);return o?function(t,e){const{firstIndex:n,lastIndexOld:o,lastIndexNew:i}=t;if(-1===n)return Array(e).fill("equal");let r=[];n>0&&(r=r.concat(Array(n).fill("equal")));i-n>0&&(r=r.concat(Array(i-n).fill("insert")));o-n>0&&(r=r.concat(Array(o-n).fill("delete")));i0&&n.push({index:o,type:"insert",values:t.slice(o,r)});i-o>0&&n.push({index:o+(r-o),type:"delete",howMany:i-o});return n}(e,i)}function jr(t,e,n){for(let o=0;o200||i>200||o+i>300)return $r.fastDiff(t,e,n,!0);let r,s;if(il?-1:1;d[o+h]&&(d[o]=d[o+h].slice(0)),d[o]||(d[o]=[]),d[o].push(i>l?r:s);let p=Math.max(i,l),m=p-o;for(;ml;p--)u[p]=h(p);u[l]=h(l),m++}while(u[l]!==c);return d[l].slice(1)}function Gr(t,e,n){t.insertBefore(n,t.childNodes[e]||null)}function Kr(t){const e=t.parentNode;e&&e.removeChild(t)}function Zr(t){return t&&t.nodeType===Node.COMMENT_NODE}function Jr(t){if(t){if(t.defaultView)return t instanceof t.defaultView.Document;if(t.ownerDocument&&t.ownerDocument.defaultView)return t instanceof t.ownerDocument.defaultView.Node}return!1}$r.fastDiff=Wr;var Yr=n(3379),Qr=n.n(Yr),Xr=n(9037),ts=n.n(Xr),es=n(569),ns=n.n(es),os=n(8575),is=n.n(os),rs=n(9216),ss=n.n(rs),as=n(4401),cs={attributes:{"data-cke":!0}};cs.setAttributes=is(),cs.insert=ns().bind(null,"head"),cs.domAPI=ts(),cs.insertStyleElement=ss();Qr()(as.Z,cs);as.Z&&as.Z.locals&&as.Z.locals;class ls{constructor(t,e){this.domDocuments=new Set,this.domConverter=t,this.markedAttributes=new Set,this.markedChildren=new Set,this.markedTexts=new Set,this.selection=e,this.set("isFocused",!1),this.set("isSelecting",!1),ar.isBlink&&!ar.isAndroid&&this.on("change:isSelecting",(()=>{this.isSelecting||this.render()})),this._inlineFiller=null,this._fakeSelectionContainer=null}markToSync(t,e){if("text"===t)this.domConverter.mapViewToDom(e.parent)&&this.markedTexts.add(e);else{if(!this.domConverter.mapViewToDom(e))return;if("attributes"===t)this.markedAttributes.add(e);else{if("children"!==t)throw new s("view-renderer-unknown-type",this);this.markedChildren.add(e)}}}render(){let t;const e=!(ar.isBlink&&!ar.isAndroid)||!this.isSelecting;for(const t of this.markedChildren)this._updateChildrenMappings(t);e?(this._inlineFiller&&!this._isSelectionInInlineFiller()&&this._removeInlineFiller(),this._inlineFiller?t=this._getInlineFillerPosition():this._needsInlineFillerAtSelection()&&(t=this.selection.getFirstPosition(),this.markedChildren.add(t.parent))):this._inlineFiller&&this._inlineFiller.parentNode&&(t=this.domConverter.domPositionToView(this._inlineFiller));for(const t of this.markedAttributes)this._updateAttrs(t);for(const e of this.markedChildren)this._updateChildren(e,{inlineFillerPosition:t});for(const e of this.markedTexts)!this.markedChildren.has(e.parent)&&this.domConverter.mapViewToDom(e.parent)&&this._updateText(e,{inlineFillerPosition:t});if(e)if(t){const e=this.domConverter.viewPositionToDom(t),n=e.parent.ownerDocument;Vr(e.parent)?this._inlineFiller=e.parent:this._inlineFiller=ds(n,e.parent,e.offset)}else this._inlineFiller=null;this._updateFocus(),this._updateSelection(),this.markedTexts.clear(),this.markedAttributes.clear(),this.markedChildren.clear()}_updateChildrenMappings(t){const e=this.domConverter.mapViewToDom(t);if(!e)return;const n=Array.from(this.domConverter.mapViewToDom(t).childNodes),o=Array.from(this.domConverter.viewChildrenToDom(t,e.ownerDocument,{withChildren:!1})),i=this._diffNodeLists(n,o),r=this._findReplaceActions(i,n,o);if(-1!==r.indexOf("replace")){const e={equal:0,insert:0,delete:0};for(const i of r)if("replace"===i){const i=e.equal+e.insert,r=e.equal+e.delete,s=t.getChild(i);!s||s.is("uiElement")||s.is("rawElement")||this._updateElementMappings(s,n[r]),Kr(o[i]),e.equal++}else e[i]++}}_updateElementMappings(t,e){this.domConverter.unbindDomElement(e),this.domConverter.bindElements(e,t),this.markedChildren.add(t),this.markedAttributes.add(t)}_getInlineFillerPosition(){const t=this.selection.getFirstPosition();return t.parent.is("$text")?Vi._createBefore(this.selection.getFirstPosition().parent):t}_isSelectionInInlineFiller(){if(1!=this.selection.rangeCount||!this.selection.isCollapsed)return!1;const t=this.selection.getFirstPosition(),e=this.domConverter.viewPositionToDom(t);return!!(e&&zr(e.parent)&&Vr(e.parent))}_removeInlineFiller(){const t=this._inlineFiller;if(!Vr(t))throw new s("view-renderer-filler-was-lost",this);Lr(t)?t.remove():t.data=t.data.substr(7),this._inlineFiller=null}_needsInlineFillerAtSelection(){if(1!=this.selection.rangeCount||!this.selection.isCollapsed)return!1;const t=this.selection.getFirstPosition(),e=t.parent,n=t.offset;if(!this.domConverter.mapViewToDom(e.root))return!1;if(!e.is("element"))return!1;if(!function(t){if("false"==t.getAttribute("contenteditable"))return!1;const e=t.findAncestor((t=>t.hasAttribute("contenteditable")));return!e||"true"==e.getAttribute("contenteditable")}(e))return!1;if(n===e.getFillerOffset())return!1;const o=t.nodeBefore,i=t.nodeAfter;return!(o instanceof Lo||i instanceof Lo)}_updateText(t,e){const n=this.domConverter.findCorrespondingDomText(t),o=this.domConverter.viewToDom(t,n.ownerDocument),i=n.data;let r=o.data;const s=e.inlineFillerPosition;if(s&&s.parent==t.parent&&s.offset==t.index&&(r=Mr+r),i!=r){const t=Wr(i,r);for(const e of t)"insert"===e.type?n.insertData(e.index,e.values.join("")):n.deleteData(e.index,e.howMany)}}_updateAttrs(t){const e=this.domConverter.mapViewToDom(t);if(!e)return;const n=Array.from(e.attributes).map((t=>t.name)),o=t.getAttributeKeys();for(const n of o)this.domConverter.setDomElementAttribute(e,n,t.getAttribute(n),t);for(const o of n)t.hasAttribute(o)||this.domConverter.removeDomElementAttribute(e,o)}_updateChildren(t,e){const n=this.domConverter.mapViewToDom(t);if(!n)return;const o=e.inlineFillerPosition,i=this.domConverter.mapViewToDom(t).childNodes,r=Array.from(this.domConverter.viewChildrenToDom(t,n.ownerDocument,{bind:!0}));o&&o.parent===t&&ds(n.ownerDocument,r,o.offset);const s=this._diffNodeLists(i,r);let a=0;const c=new Set;for(const t of s)"delete"===t?(c.add(i[a]),Kr(i[a])):"equal"===t&&a++;a=0;for(const t of s)"insert"===t?(Gr(n,a,r[a]),a++):"equal"===t&&(this._markDescendantTextToSync(this.domConverter.domToView(r[a])),a++);for(const t of c)t.parentNode||this.domConverter.unbindDomElement(t)}_diffNodeLists(t,e){return $r(t=function(t,e){const n=Array.from(t);if(0==n.length||!e)return n;n[n.length-1]==e&&n.pop();return n}(t,this._fakeSelectionContainer),e,hs.bind(null,this.domConverter))}_findReplaceActions(t,e,n){if(-1===t.indexOf("insert")||-1===t.indexOf("delete"))return t;let o=[],i=[],r=[];const s={equal:0,insert:0,delete:0};for(const a of t)"insert"===a?r.push(n[s.equal+s.insert]):"delete"===a?i.push(e[s.equal+s.delete]):(o=o.concat($r(i,r,us).map((t=>"equal"===t?"replace":t))),o.push("equal"),i=[],r=[]),s[a]++;return o.concat($r(i,r,us).map((t=>"equal"===t?"replace":t)))}_markDescendantTextToSync(t){if(t)if(t.is("$text"))this.markedTexts.add(t);else if(t.is("element"))for(const e of t.getChildren())this._markDescendantTextToSync(e)}_updateSelection(){if(ar.isBlink&&!ar.isAndroid&&this.isSelecting&&!this.markedChildren.size)return;if(0===this.selection.rangeCount)return this._removeDomSelection(),void this._removeFakeSelection();const t=this.domConverter.mapViewToDom(this.selection.editableElement);this.isFocused&&t&&(this.selection.isFake?this._updateFakeSelection(t):(this._removeFakeSelection(),this._updateDomSelection(t)))}_updateFakeSelection(t){const e=t.ownerDocument;this._fakeSelectionContainer||(this._fakeSelectionContainer=function(t){const e=t.createElement("div");return e.className="ck-fake-selection-container",Object.assign(e.style,{position:"fixed",top:0,left:"-9999px",width:"42px"}),e.textContent=" ",e}(e));const n=this._fakeSelectionContainer;if(this.domConverter.bindFakeSelection(n,this.selection),!this._fakeSelectionNeedsUpdate(t))return;n.parentElement&&n.parentElement==t||t.appendChild(n),n.textContent=this.selection.fakeSelectionLabel||" ";const o=e.getSelection(),i=e.createRange();o.removeAllRanges(),i.selectNodeContents(n),o.addRange(i)}_updateDomSelection(t){const e=t.ownerDocument.defaultView.getSelection();if(!this._domSelectionNeedsUpdate(e))return;const n=this.domConverter.viewPositionToDom(this.selection.anchor),o=this.domConverter.viewPositionToDom(this.selection.focus);e.collapse(n.parent,n.offset),e.extend(o.parent,o.offset),ar.isGecko&&function(t,e){const n=t.parent;if(n.nodeType!=Node.ELEMENT_NODE||t.offset!=n.childNodes.length-1)return;const o=n.childNodes[t.offset];o&&"BR"==o.tagName&&e.addRange(e.getRangeAt(0))}(o,e)}_domSelectionNeedsUpdate(t){if(!this.domConverter.isDomSelectionCorrect(t))return!0;const e=t&&this.domConverter.domSelectionToView(t);return(!e||!this.selection.isEqual(e))&&!(!this.selection.isCollapsed&&this.selection.isSimilar(e))}_fakeSelectionNeedsUpdate(t){const e=this._fakeSelectionContainer,n=t.ownerDocument.getSelection();return!e||e.parentElement!==t||(n.anchorNode!==e&&!e.contains(n.anchorNode)||e.textContent!==this.selection.fakeSelectionLabel)}_removeDomSelection(){for(const t of this.domDocuments){if(t.getSelection().rangeCount){const e=t.activeElement,n=this.domConverter.mapDomToView(e);e&&n&&t.getSelection().removeAllRanges()}}}_removeFakeSelection(){const t=this._fakeSelectionContainer;t&&t.remove()}_updateFocus(){if(this.isFocused){const t=this.selection.editableElement;t&&this.domConverter.focus(t)}}}function ds(t,e,n){const o=e instanceof Array?e:e.childNodes,i=o[n];if(zr(i))return i.data=Mr+i.data,i;{const i=t.createTextNode(Mr);return Array.isArray(e)?o.splice(n,0,i):Gr(e,n,i),i}}function us(t,e){return Jr(t)&&Jr(e)&&!zr(t)&&!zr(e)&&!Zr(t)&&!Zr(e)&&t.tagName.toLowerCase()===e.tagName.toLowerCase()}function hs(t,e,n){return e===n||(zr(e)&&zr(n)?e.data===n.data:!(!t.isBlockFiller(e)||!t.isBlockFiller(n)))}he(ls,se);const ps={window,document};function ms(t){let e=0;for(;t.previousSibling;)t=t.previousSibling,e++;return e}function gs(t){const e=[];for(;t&&t.nodeType!=Node.DOCUMENT_NODE;)e.unshift(t),t=t.parentNode;return e}const fs=Or(document),bs=Fr(document),ks=Nr(document),ws="data-ck-unsafe-attribute-",_s="data-ck-unsafe-element";class Cs{constructor(t,e={}){this.document=t,this.renderingMode=e.renderingMode||"editing",this.blockFillerMode=e.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 Wo,this._encounteredRawContentDomNodes=new WeakSet}bindFakeSelection(t,e){this._fakeSelectionMapping.set(t,new Wi(e))}fakeSelectionToView(t){return this._fakeSelectionMapping.get(t)}bindElements(t,e){this._domToViewMapping.set(t,e),this._viewToDomMapping.set(e,t)}unbindDomElement(t){const e=this._domToViewMapping.get(t);if(e){this._domToViewMapping.delete(t),this._viewToDomMapping.delete(e);for(const e of t.childNodes)this.unbindDomElement(e)}}bindDocumentFragments(t,e){this._domToViewMapping.set(t,e),this._viewToDomMapping.set(e,t)}shouldRenderAttribute(t,e,n){return"data"===this.renderingMode||!(t=t.toLowerCase()).startsWith("on")&&(("srcdoc"!==t||!e.match(/\bon\S+\s*=|javascript:|<\s*\/*script/i))&&("img"===n&&("src"===t||"srcset"===t)||("source"===n&&"srcset"===t||!e.match(/^\s*(javascript:|data:(image\/svg|text\/x?html))/i))))}setContentOf(t,e){if("data"===this.renderingMode)return void(t.innerHTML=e);const n=(new DOMParser).parseFromString(e,"text/html"),o=n.createDocumentFragment(),i=n.body.childNodes;for(;i.length>0;)o.appendChild(i[0]);const r=n.createTreeWalker(o,NodeFilter.SHOW_ELEMENT),s=[];let c;for(;c=r.nextNode();)s.push(c);for(const t of s){for(const e of t.getAttributeNames())this.setDomElementAttribute(t,e,t.getAttribute(e));const e=t.tagName.toLowerCase();this._shouldRenameElement(e)&&(a("domconverter-unsafe-element-detected",{unsafeElement:t}),t.replaceWith(this._createReplacementDomElement(e,t)))}for(;t.firstChild;)t.firstChild.remove();t.append(o)}viewToDom(t,e,n={}){if(t.is("$text")){const n=this._processDataFromViewText(t);return e.createTextNode(n)}{if(this.mapViewToDom(t))return this.mapViewToDom(t);let o;if(t.is("documentFragment"))o=e.createDocumentFragment(),n.bind&&this.bindDocumentFragments(o,t);else{if(t.is("uiElement"))return o="$comment"===t.name?e.createComment(t.getCustomProperty("$rawContent")):t.render(e,this),n.bind&&this.bindElements(o,t),o;this._shouldRenameElement(t.name)?(a("domconverter-unsafe-element-detected",{unsafeElement:t}),o=this._createReplacementDomElement(t.name)):o=t.hasAttribute("xmlns")?e.createElementNS(t.getAttribute("xmlns"),t.name):e.createElement(t.name),t.is("rawElement")&&t.render(o,this),n.bind&&this.bindElements(o,t);for(const e of t.getAttributeKeys())this.setDomElementAttribute(o,e,t.getAttribute(e),t)}if(!1!==n.withChildren)for(const i of this.viewChildrenToDom(t,e,n))o.appendChild(i);return o}}setDomElementAttribute(t,e,n,o=null){const i=this.shouldRenderAttribute(e,n,t.tagName.toLowerCase())||o&&o.shouldRenderUnsafeAttribute(e);i||a("domconverter-unsafe-attribute-detected",{domElement:t,key:e,value:n}),t.hasAttribute(e)&&!i?t.removeAttribute(e):t.hasAttribute(ws+e)&&i&&t.removeAttribute(ws+e),t.setAttribute(i?e:ws+e,n)}removeDomElementAttribute(t,e){e!=_s&&(t.removeAttribute(e),t.removeAttribute(ws+e))}*viewChildrenToDom(t,e,n={}){const o=t.getFillerOffset&&t.getFillerOffset();let i=0;for(const r of t.getChildren())o===i&&(yield this._getBlockFiller(e)),yield this.viewToDom(r,e,n),i++;o===i&&(yield this._getBlockFiller(e))}viewRangeToDom(t){const e=this.viewPositionToDom(t.start),n=this.viewPositionToDom(t.end),o=document.createRange();return o.setStart(e.parent,e.offset),o.setEnd(n.parent,n.offset),o}viewPositionToDom(t){const e=t.parent;if(e.is("$text")){const n=this.findCorrespondingDomText(e);if(!n)return null;let o=t.offset;return Vr(n)&&(o+=7),{parent:n,offset:o}}{let n,o,i;if(0===t.offset){if(n=this.mapViewToDom(e),!n)return null;i=n.childNodes[0]}else{const e=t.nodeBefore;if(o=e.is("$text")?this.findCorrespondingDomText(e):this.mapViewToDom(t.nodeBefore),!o)return null;n=o.parentNode,i=o.nextSibling}if(zr(i)&&Vr(i))return{parent:i,offset:7};return{parent:n,offset:o?ms(o)+1:0}}}domToView(t,e={}){if(this.isBlockFiller(t))return null;const n=this.getHostViewElement(t);if(n)return n;if(Zr(t)&&e.skipComments)return null;if(zr(t)){if(Lr(t))return null;{const e=this._processDataFromDomText(t);return""===e?null:new Lo(this.document,e)}}{if(this.mapDomToView(t))return this.mapDomToView(t);let n;if(this.isDocumentFragment(t))n=new Ar(this.document),e.bind&&this.bindDocumentFragments(t,n);else{n=this._createViewElement(t,e),e.bind&&this.bindElements(t,n);const o=t.attributes;if(o)for(let t=o.length-1;t>=0;t--)n._setAttribute(o[t].name,o[t].value);if(this._isViewElementWithRawContent(n,e)||Zr(t)){const e=Zr(t)?t.data:t.innerHTML;return n._setCustomProperty("$rawContent",e),this._encounteredRawContentDomNodes.add(t),n}}if(!1!==e.withChildren)for(const o of this.domChildrenToView(t,e))n._appendChild(o);return n}}*domChildrenToView(t,e={}){for(let n=0;n{const{scrollLeft:e,scrollTop:n}=t;o.push([e,n])})),e.focus(),As(e,(t=>{const[e,n]=o.shift();t.scrollLeft=e,t.scrollTop=n})),ps.window.scrollTo(t,n)}}isElement(t){return t&&t.nodeType==Node.ELEMENT_NODE}isDocumentFragment(t){return t&&t.nodeType==Node.DOCUMENT_FRAGMENT_NODE}isBlockFiller(t){return"br"==this.blockFillerMode?t.isEqualNode(fs):!("BR"!==t.tagName||!vs(t,this.blockElements)||1!==t.parentNode.childNodes.length)||(t.isEqualNode(ks)||function(t,e){return t.isEqualNode(bs)&&vs(t,e)&&1===t.parentNode.childNodes.length}(t,this.blockElements))}isDomSelectionBackward(t){if(t.isCollapsed)return!1;const e=document.createRange();e.setStart(t.anchorNode,t.anchorOffset),e.setEnd(t.focusNode,t.focusOffset);const n=e.collapsed;return e.detach(),n}getHostViewElement(t){const e=gs(t);for(e.pop();e.length;){const t=e.pop(),n=this._domToViewMapping.get(t);if(n&&(n.is("uiElement")||n.is("rawElement")))return n}return null}isDomSelectionCorrect(t){return this._isDomSelectionPositionCorrect(t.anchorNode,t.anchorOffset)&&this._isDomSelectionPositionCorrect(t.focusNode,t.focusOffset)}registerRawContentMatcher(t){this._rawContentElementMatcher.add(t)}_getBlockFiller(t){switch(this.blockFillerMode){case"nbsp":return Fr(t);case"markedNbsp":return Nr(t);case"br":return Or(t)}}_isDomSelectionPositionCorrect(t,e){if(zr(t)&&Vr(t)&&e<7)return!1;if(this.isElement(t)&&Vr(t.childNodes[e]))return!1;const n=this.mapDomToView(t);return!n||!n.is("uiElement")&&!n.is("rawElement")}_processDataFromViewText(t){let e=t.data;if(t.getAncestors().some((t=>this.preElements.includes(t.name))))return e;if(" "==e.charAt(0)){const n=this._getTouchingInlineViewNode(t,!1);!(n&&n.is("$textProxy")&&this._nodeEndsWithSpace(n))&&n||(e=" "+e.substr(1))}if(" "==e.charAt(e.length-1)){const n=this._getTouchingInlineViewNode(t,!0),o=n&&n.is("$textProxy")&&" "==n.data.charAt(0);" "!=e.charAt(e.length-2)&&n&&!o||(e=e.substr(0,e.length-1)+" ")}return e.replace(/ {2}/g,"  ")}_nodeEndsWithSpace(t){if(t.getAncestors().some((t=>this.preElements.includes(t.name))))return!1;const e=this._processDataFromViewText(t);return" "==e.charAt(e.length-1)}_processDataFromDomText(t){let e=t.data;if(function(t,e){return gs(t).some((t=>t.tagName&&e.includes(t.tagName.toLowerCase())))}(t,this.preElements))return Hr(t);e=e.replace(/[ \n\t\r]{1,}/g," ");const n=this._getTouchingInlineDomNode(t,!1),o=this._getTouchingInlineDomNode(t,!0),i=this._checkShouldLeftTrimDomText(t,n),r=this._checkShouldRightTrimDomText(t,o);i&&(e=e.replace(/^ /,"")),r&&(e=e.replace(/ $/,"")),e=Hr(new Text(e)),e=e.replace(/ \u00A0/g," ");const s=o&&this.isElement(o)&&"BR"!=o.tagName,a=o&&zr(o)&&" "==o.data.charAt(0);return(/( |\u00A0)\u00A0$/.test(e)||!o||s||a)&&(e=e.replace(/\u00A0$/," ")),(i||n&&this.isElement(n)&&"BR"!=n.tagName)&&(e=e.replace(/^\u00A0/," ")),e}_checkShouldLeftTrimDomText(t,e){return!e||(this.isElement(e)?"BR"===e.tagName:!this._encounteredRawContentDomNodes.has(t.previousSibling)&&/[^\S\u00A0]/.test(e.data.charAt(e.data.length-1)))}_checkShouldRightTrimDomText(t,e){return!e&&!Vr(t)}_getTouchingInlineViewNode(t,e){const n=new Mi({startPosition:e?Vi._createAfter(t):Vi._createBefore(t),direction:e?"forward":"backward"});for(const t of n){if(t.item.is("element")&&this.inlineObjectElements.includes(t.item.name))return t.item;if(t.item.is("containerElement"))return null;if(t.item.is("element","br"))return null;if(t.item.is("$textProxy"))return t.item}return null}_getTouchingInlineDomNode(t,e){if(!t.parentNode)return null;const n=e?"firstChild":"lastChild",o=e?"nextSibling":"previousSibling";let i=!0;do{if(!i&&t[n]?t=t[n]:t[o]?(t=t[o],i=!1):(t=t.parentNode,i=!0),!t||this._isBlockElement(t))return null}while(!zr(t)&&"BR"!=t.tagName&&!this._isInlineObjectElement(t));return t}_isBlockElement(t){return this.isElement(t)&&this.blockElements.includes(t.tagName.toLowerCase())}_isInlineObjectElement(t){return this.isElement(t)&&this.inlineObjectElements.includes(t.tagName.toLowerCase())}_createViewElement(t,e){if(Zr(t))return new br(this.document,"$comment");const n=e.keepOriginalCase?t.tagName:t.tagName.toLowerCase();return new Pi(this.document,n)}_isViewElementWithRawContent(t,e){return!1!==e.withChildren&&this._rawContentElementMatcher.match(t)}_shouldRenameElement(t){return"editing"==this.renderingMode&&"script"==t.toLowerCase()}_createReplacementDomElement(t,e=null){const n=document.createElement("span");if(n.setAttribute(_s,t),e){for(;e.firstChild;)n.appendChild(e.firstChild);for(const t of e.getAttributeNames())n.setAttribute(t,e.getAttribute(t))}return n}}function As(t,e){for(;t&&t!=ps.document;)e(t),t=t.parentNode}function vs(t,e){const n=t.parentNode;return n&&n.tagName&&e.includes(n.tagName.toLowerCase())}function ys(t){const e=Object.prototype.toString.apply(t);return"[object Window]"==e||"[object global]"==e}const xs=Xt({},g,{listenTo(t,e,n,o={}){if(Jr(t)||ys(t)){const i={capture:!!o.useCapture,passive:!!o.usePassive},r=this._getProxyEmitter(t,i)||new Ds(t,i);this.listenTo(r,e,n,o)}else g.listenTo.call(this,t,e,n,o)},stopListening(t,e,n){if(Jr(t)||ys(t)){const o=this._getAllProxyEmitters(t);for(const t of o)this.stopListening(t,e,n)}else g.stopListening.call(this,t,e,n)},_getProxyEmitter(t,e){return n=this,o=Ss(t,e),n[h]&&n[h][o]?n[h][o].emitter:null;var n,o},_getAllProxyEmitters(t){return[{capture:!1,passive:!1},{capture:!1,passive:!0},{capture:!0,passive:!1},{capture:!0,passive:!0}].map((e=>this._getProxyEmitter(t,e))).filter((t=>!!t))}}),Es=xs;class Ds{constructor(t,e){f(this,Ss(t,e)),this._domNode=t,this._options=e}}function Ss(t,e){let n=function(t){return t["data-ck-expando"]||(t["data-ck-expando"]=i())}(t);for(const t of Object.keys(e).sort())e[t]&&(n+="-"+t);return n}Xt(Ds.prototype,g,{attach(t){if(this._domListeners&&this._domListeners[t])return;const e=this._createDomListener(t);this._domNode.addEventListener(t,e,this._options),this._domListeners||(this._domListeners={}),this._domListeners[t]=e},detach(t){let e;!this._domListeners[t]||(e=this._events[t])&&e.callbacks.length||this._domListeners[t].removeListener()},_addEventListener(t,e,n){this.attach(t),g._addEventListener.call(this,t,e,n)},_removeEventListener(t,e){g._removeEventListener.call(this,t,e),this.detach(t)},_createDomListener(t){const e=e=>{this.fire(t,e)};return e.removeListener=()=>{this._domNode.removeEventListener(t,e,this._options),delete this._domListeners[t]},e}});class Bs{constructor(t){this.view=t,this.document=t.document,this.isEnabled=!1}enable(){this.isEnabled=!0}disable(){this.isEnabled=!1}destroy(){this.disable(),this.stopListening()}checkShouldIgnoreEventFromTarget(t){return t&&3===t.nodeType&&(t=t.parentNode),!(!t||1!==t.nodeType)&&t.matches("[data-cke-ignore-events], [data-cke-ignore-events] *")}}he(Bs,Es);const Ts=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this};const Ps=function(t){return this.__data__.has(t)};function Is(t){var e=-1,n=null==t?0:t.length;for(this.__data__=new on;++ea))return!1;var l=r.get(t),d=r.get(e);if(l&&d)return l==e&&d==t;var u=-1,h=!0,p=2&n?new Rs:void 0;for(r.set(t,e),r.set(e,t);++u{this.listenTo(t,e,((t,e)=>{this.isEnabled&&!this.checkShouldIgnoreEventFromTarget(e.target)&&this.onDomEvent(e)}),{useCapture:this.useCapture})}))}fire(t,e,n){this.isEnabled&&this.document.fire(t,new Qs(this.view,e,n))}}class ta extends Xs{constructor(t){super(t),this.domEventType=["keydown","keyup"]}onDomEvent(t){this.fire(t.type,t,{keyCode:t.keyCode,altKey:t.altKey,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,metaKey:t.metaKey,get keystroke(){return pr(this)}})}}const ea=function(){return D.Date.now()};var na=/\s/;const oa=function(t){for(var e=t.length;e--&&na.test(t.charAt(e)););return e};var ia=/^\s+/;const ra=function(t){return t?t.slice(0,oa(t)+1).replace(ia,""):t};var sa=/^[-+]0x[0-9a-f]+$/i,aa=/^0b[01]+$/i,ca=/^0o[0-7]+$/i,la=parseInt;const da=function(t){if("number"==typeof t)return t;if($o(t))return NaN;if(y(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=y(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=ra(t);var n=aa.test(t);return n||ca.test(t)?la(t.slice(2),n?2:8):sa.test(t)?NaN:+t};var ua=Math.max,ha=Math.min;const pa=function(t,e,n){var o,i,r,s,a,c,l=0,d=!1,u=!1,h=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function p(e){var n=o,r=i;return o=i=void 0,l=e,s=t.apply(r,n)}function m(t){return l=t,a=setTimeout(f,e),d?p(t):s}function g(t){var n=t-c;return void 0===c||n>=e||n<0||u&&t-l>=r}function f(){var t=ea();if(g(t))return b(t);a=setTimeout(f,function(t){var n=e-(t-c);return u?ha(n,r-(t-l)):n}(t))}function b(t){return a=void 0,h&&o?p(t):(o=i=void 0,s)}function k(){var t=ea(),n=g(t);if(o=arguments,i=this,c=t,n){if(void 0===a)return m(c);if(u)return clearTimeout(a),a=setTimeout(f,e),p(c)}return void 0===a&&(a=setTimeout(f,e)),s}return e=da(e)||0,y(n)&&(d=!!n.leading,r=(u="maxWait"in n)?ua(da(n.maxWait)||0,e):r,h="trailing"in n?!!n.trailing:h),k.cancel=function(){void 0!==a&&clearTimeout(a),l=0,o=c=i=a=void 0},k.flush=function(){return void 0===a?s:b(ea())},k};class ma extends Bs{constructor(t){super(t),this._fireSelectionChangeDoneDebounced=pa((t=>this.document.fire("selectionChangeDone",t)),200)}observe(){const t=this.document;t.on("arrowKey",((e,n)=>{t.selection.isFake&&this.isEnabled&&n.preventDefault()}),{context:"$capture"}),t.on("arrowKey",((e,n)=>{t.selection.isFake&&this.isEnabled&&this._handleSelectionMove(n.keyCode)}),{priority:"lowest"})}destroy(){super.destroy(),this._fireSelectionChangeDoneDebounced.cancel()}_handleSelectionMove(t){const e=this.document.selection,n=new Wi(e.getRanges(),{backward:e.isBackward,fake:!1});t!=ur.arrowleft&&t!=ur.arrowup||n.setTo(n.getFirstPosition()),t!=ur.arrowright&&t!=ur.arrowdown||n.setTo(n.getLastPosition());const o={oldSelection:e,newSelection:n,domSelection:null};this.document.fire("selectionChange",o),this._fireSelectionChangeDoneDebounced(o)}}class ga extends Bs{constructor(t){super(t),this.mutationObserver=t.getObserver(Ys),this.selection=this.document.selection,this.domConverter=t.domConverter,this._documents=new WeakSet,this._fireSelectionChangeDoneDebounced=pa((t=>this.document.fire("selectionChangeDone",t)),200),this._clearInfiniteLoopInterval=setInterval((()=>this._clearInfiniteLoop()),1e3),this._documentIsSelectingInactivityTimeoutDebounced=pa((()=>this.document.isSelecting=!1),5e3),this._loopbackCounter=0}observe(t){const e=t.ownerDocument,n=()=>{this.document.isSelecting=!1,this._documentIsSelectingInactivityTimeoutDebounced.cancel()};this.listenTo(t,"selectstart",(()=>{this.document.isSelecting=!0,this._documentIsSelectingInactivityTimeoutDebounced()}),{priority:"highest"}),this.listenTo(t,"keydown",n,{priority:"highest"}),this.listenTo(t,"keyup",n,{priority:"highest"}),this._documents.has(e)||(this.listenTo(e,"mouseup",n,{priority:"highest"}),this.listenTo(e,"selectionchange",((t,n)=>{this._handleSelectionChange(n,e),this._documentIsSelectingInactivityTimeoutDebounced()})),this._documents.add(e))}destroy(){super.destroy(),clearInterval(this._clearInfiniteLoopInterval),this._fireSelectionChangeDoneDebounced.cancel(),this._documentIsSelectingInactivityTimeoutDebounced.cancel()}_handleSelectionChange(t,e){if(!this.isEnabled)return;const n=e.defaultView.getSelection();if(this.checkShouldIgnoreEventFromTarget(n.anchorNode))return;this.mutationObserver.flush();const o=this.domConverter.domSelectionToView(n);if(0!=o.rangeCount){if(this.view.hasDomSelection=!0,!(this.selection.isEqual(o)&&this.domConverter.isDomSelectionCorrect(n)||++this._loopbackCounter>60))if(this.selection.isSimilar(o))this.view.forceRender();else{const t={oldSelection:this.selection,newSelection:o,domSelection:n};this.document.fire("selectionChange",t),this._fireSelectionChangeDoneDebounced(t)}}else this.view.hasDomSelection=!1}_clearInfiniteLoop(){this._loopbackCounter=0}}class fa extends Xs{constructor(t){super(t),this.domEventType=["focus","blur"],this.useCapture=!0;const e=this.document;e.on("focus",(()=>{e.isFocused=!0,this._renderTimeoutId=setTimeout((()=>t.change((()=>{}))),50)})),e.on("blur",((n,o)=>{const i=e.selection.editableElement;null!==i&&i!==o.target||(e.isFocused=!1,t.change((()=>{})))}))}onDomEvent(t){this.fire(t.type,t)}destroy(){this._renderTimeoutId&&clearTimeout(this._renderTimeoutId),super.destroy()}}class ba extends Xs{constructor(t){super(t),this.domEventType=["compositionstart","compositionupdate","compositionend"];const e=this.document;e.on("compositionstart",(()=>{e.isComposing=!0})),e.on("compositionend",(()=>{e.isComposing=!1}))}onDomEvent(t){this.fire(t.type,t)}}class ka extends Xs{constructor(t){super(t),this.domEventType=["beforeinput"]}onDomEvent(t){this.fire(t.type,t)}}const wa=function(t){return"string"==typeof t||!Bt(t)&&At(t)&&"[object String]"==O(t)};function _a(t,e,n={},o=[]){const i=n&&n.xmlns,r=i?t.createElementNS(i,e):t.createElement(e);for(const t in n)r.setAttribute(t,n[t]);!wa(o)&&Do(o)||(o=[o]);for(let e of o)wa(e)&&(e=t.createTextNode(e)),r.appendChild(e);return r}function Ca(t){return"[object Range]"==Object.prototype.toString.apply(t)}function Aa(t){const e=t.ownerDocument.defaultView.getComputedStyle(t);return{top:parseInt(e.borderTopWidth,10),right:parseInt(e.borderRightWidth,10),bottom:parseInt(e.borderBottomWidth,10),left:parseInt(e.borderLeftWidth,10)}}const va=["top","right","bottom","left","width","height"];class ya{constructor(t){const e=Ca(t);if(Object.defineProperty(this,"_source",{value:t._source||t,writable:!0,enumerable:!1}),vo(t)||e)if(e){const e=ya.getDomRangeRects(t);xa(this,ya.getBoundingRect(e))}else xa(this,t.getBoundingClientRect());else if(ys(t)){const{innerWidth:e,innerHeight:n}=t;xa(this,{top:0,right:e,bottom:n,left:0,width:e,height:n})}else xa(this,t)}clone(){return new ya(this)}moveTo(t,e){return this.top=e,this.right=t+this.width,this.bottom=e+this.height,this.left=t,this}moveBy(t,e){return this.top+=e,this.right+=t,this.left+=t,this.bottom+=e,this}getIntersection(t){const e={top:Math.max(this.top,t.top),right:Math.min(this.right,t.right),bottom:Math.min(this.bottom,t.bottom),left:Math.max(this.left,t.left)};return e.width=e.right-e.left,e.height=e.bottom-e.top,e.width<0||e.height<0?null:new ya(e)}getIntersectionArea(t){const e=this.getIntersection(t);return e?e.getArea():0}getArea(){return this.width*this.height}getVisible(){const t=this._source;let e=this.clone();if(!Ea(t)){let n=t.parentNode||t.commonAncestorContainer;for(;n&&!Ea(n);){const t=new ya(n),o=e.getIntersection(t);if(!o)return null;o.getArea(){for(const e of t){const t=Da._getElementCallbacks(e.target);if(t)for(const n of t)n(e)}}))}}Da._observerInstance=null,Da._elementCallbacks=null;class Sa{constructor(t){this._callback=t,this._elements=new Set,this._previousRects=new Map,this._periodicCheckTimeout=null}observe(t){this._elements.add(t),this._checkElementRectsAndExecuteCallback(),1===this._elements.size&&this._startPeriodicCheck()}unobserve(t){this._elements.delete(t),this._previousRects.delete(t),this._elements.size||this._stopPeriodicCheck()}_startPeriodicCheck(){const t=()=>{this._checkElementRectsAndExecuteCallback(),this._periodicCheckTimeout=setTimeout(t,100)};this.listenTo(ps.window,"resize",(()=>{this._checkElementRectsAndExecuteCallback()})),this._periodicCheckTimeout=setTimeout(t,100)}_stopPeriodicCheck(){clearTimeout(this._periodicCheckTimeout),this.stopListening(),this._previousRects.clear()}_checkElementRectsAndExecuteCallback(){const t=[];for(const e of this._elements)this._hasRectChanged(e)&&t.push({target:e,contentRect:this._previousRects.get(e)});t.length&&this._callback(t)}_hasRectChanged(t){if(!t.ownerDocument.body.contains(t))return!1;const e=new ya(t),n=this._previousRects.get(t),o=!n||!n.isEqual(e);return this._previousRects.set(t,e),o}}function Ba(t,e){t instanceof HTMLTextAreaElement&&(t.value=e),t.innerHTML=e}function Ta(t){const e=t.next();return e.done?null:e.value}he(Sa,Es);class Pa{constructor(){this.set("isFocused",!1),this.set("focusedElement",null),this._elements=new Set,this._nextEventLoopTimeout=null}add(t){if(this._elements.has(t))throw new s("focustracker-add-element-already-exist",this);this.listenTo(t,"focus",(()=>this._focus(t)),{useCapture:!0}),this.listenTo(t,"blur",(()=>this._blur()),{useCapture:!0}),this._elements.add(t)}remove(t){t===this.focusedElement&&this._blur(t),this._elements.has(t)&&(this.stopListening(t),this._elements.delete(t))}destroy(){this.stopListening()}_focus(t){clearTimeout(this._nextEventLoopTimeout),this.focusedElement=t,this.isFocused=!0}_blur(){clearTimeout(this._nextEventLoopTimeout),this._nextEventLoopTimeout=setTimeout((()=>{this.focusedElement=null,this.isFocused=!1}),0)}}he(Pa,Es),he(Pa,se);class Ia{constructor(){this._listener=Object.create(Es)}listenTo(t){this._listener.listenTo(t,"keydown",((t,e)=>{this._listener.fire("_keydown:"+pr(e),e)}))}set(t,e,n={}){const o=mr(t),i=n.priority;this._listener.listenTo(this._listener,"_keydown:"+o,((t,n)=>{e(n,(()=>{n.preventDefault(),n.stopPropagation(),t.stop()})),t.return=!0}),{priority:i})}press(t){return!!this._listener.fire("_keydown:"+pr(t),t)}destroy(){this._listener.stopListening()}}class Ra extends Bs{constructor(t){super(t),this.document.on("keydown",((t,e)=>{if(this.isEnabled&&((n=e.keyCode)==ur.arrowright||n==ur.arrowleft||n==ur.arrowup||n==ur.arrowdown)){const n=new Ui(this.document,"arrowKey",this.document.selection.getFirstRange());this.document.fire(n,e),n.stop.called&&t.stop()}var n}))}observe(){}}function za({target:t,viewportOffset:e=0}){const n=Ha(t);let o=n,i=null;for(;o;){let r;r=qa(o==n?t:i),Na(r,(()=>Wa(t,o)));const s=Wa(t,o);if(Fa(o,s,e),o.parent!=o){if(i=o.frameElement,o=o.parent,!i)return}else o=null}}function Fa(t,e,n){const o=e.clone().moveBy(0,n),i=e.clone().moveBy(0,-n),r=new ya(t).excludeScrollbarsAndBorders();if(![i,o].every((t=>r.contains(t)))){let{scrollX:s,scrollY:a}=t;Ma(i,r)?a-=r.top-e.top+n:Oa(o,r)&&(a+=e.bottom-r.bottom+n),Va(e,r)?s-=r.left-e.left+n:La(e,r)&&(s+=e.right-r.right+n),t.scrollTo(s,a)}}function Na(t,e){const n=Ha(t);let o,i;for(;t!=n.document.body;)i=e(),o=new ya(t).excludeScrollbarsAndBorders(),o.contains(i)||(Ma(i,o)?t.scrollTop-=o.top-i.top:Oa(i,o)&&(t.scrollTop+=i.bottom-o.bottom),Va(i,o)?t.scrollLeft-=o.left-i.left:La(i,o)&&(t.scrollLeft+=i.right-o.right)),t=t.parentNode}function Oa(t,e){return t.bottom>e.bottom}function Ma(t,e){return t.tope.right}function Ha(t){return Ca(t)?t.startContainer.ownerDocument.defaultView:t.ownerDocument.defaultView}function qa(t){if(Ca(t)){let e=t.commonAncestorContainer;return zr(e)&&(e=e.parentNode),e}return t.parentNode}function Wa(t,e){const n=Ha(t),o=new ya(t);if(n===e)return o;{let t=n;for(;t!=e;){const e=t.frameElement,n=new ya(e).excludeScrollbarsAndBorders();o.moveBy(n.left,n.top),t=t.parent}}return o}Object.assign({},{scrollViewportToShowTarget:za,scrollAncestorsToShowTarget:function(t){Na(qa(t),(()=>new ya(t)))}});class ja{constructor(t){this.document=new Xi(t),this.domConverter=new Cs(this.document),this.domRoots=new Map,this.set("isRenderingInProgress",!1),this.set("hasDomSelection",!1),this._renderer=new ls(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 vr(this.document),this.addObserver(Ys),this.addObserver(ga),this.addObserver(fa),this.addObserver(ta),this.addObserver(ma),this.addObserver(ba),this.addObserver(Ra),ar.isAndroid&&this.addObserver(ka),this.document.on("arrowKey",qr,{priority:"low"}),kr(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(t,e="main"){const n=this.document.getRoot(e);n._name=t.tagName.toLowerCase();const o={};for(const{name:e,value:i}of Array.from(t.attributes))o[e]=i,"class"===e?this._writer.addClass(i.split(" "),n):this._writer.setAttribute(e,i,n);this._initialDomRootAttributes.set(t,o);const i=()=>{this._writer.setAttribute("contenteditable",!n.isReadOnly,n),n.isReadOnly?this._writer.addClass("ck-read-only",n):this._writer.removeClass("ck-read-only",n)};i(),this.domRoots.set(e,t),this.domConverter.bindElements(t,n),this._renderer.markToSync("children",n),this._renderer.markToSync("attributes",n),this._renderer.domDocuments.add(t.ownerDocument),n.on("change:children",((t,e)=>this._renderer.markToSync("children",e))),n.on("change:attributes",((t,e)=>this._renderer.markToSync("attributes",e))),n.on("change:text",((t,e)=>this._renderer.markToSync("text",e))),n.on("change:isReadOnly",(()=>this.change(i))),n.on("change",(()=>{this._hasChangedSinceTheLastRendering=!0}));for(const n of this._observers.values())n.observe(t,e)}detachDomRoot(t){const e=this.domRoots.get(t);Array.from(e.attributes).forEach((({name:t})=>e.removeAttribute(t)));const n=this._initialDomRootAttributes.get(e);for(const t in n)e.setAttribute(t,n[t]);this.domRoots.delete(t),this.domConverter.unbindDomElement(e)}getDomRoot(t="main"){return this.domRoots.get(t)}addObserver(t){let e=this._observers.get(t);if(e)return e;e=new t(this),this._observers.set(t,e);for(const[t,n]of this.domRoots)e.observe(n,t);return e.enable(),e}getObserver(t){return this._observers.get(t)}disableObservers(){for(const t of this._observers.values())t.disable()}enableObservers(){for(const t of this._observers.values())t.enable()}scrollToTheSelection(){const t=this.document.selection.getFirstRange();t&&za({target:this.domConverter.viewRangeToDom(t),viewportOffset:20})}focus(){if(!this.document.isFocused){const t=this.document.selection.editableElement;t&&(this.domConverter.focus(t),this.forceRender())}}change(t){if(this.isRenderingInProgress||this._postFixersInProgress)throw new s("cannot-change-view-tree",this);try{if(this._ongoingChange)return t(this._writer);this._ongoingChange=!0;const e=t(this._writer);return this._ongoingChange=!1,!this._renderingDisabled&&this._hasChangedSinceTheLastRendering&&(this._postFixersInProgress=!0,this.document._callPostFixers(this._writer),this._postFixersInProgress=!1,this.fire("render")),e}catch(t){s.rethrowUnexpectedError(t,this)}}forceRender(){this._hasChangedSinceTheLastRendering=!0,this.change((()=>{}))}destroy(){for(const t of this._observers.values())t.destroy();this.document.destroy(),this.stopListening()}createPositionAt(t,e){return Vi._createAt(t,e)}createPositionAfter(t){return Vi._createAfter(t)}createPositionBefore(t){return Vi._createBefore(t)}createRange(t,e){return new Li(t,e)}createRangeOn(t){return Li._createOn(t)}createRangeIn(t){return Li._createIn(t)}createSelection(t,e,n){return new Wi(t,e,n)}_disableRendering(t){this._renderingDisabled=t,0==t&&this.change((()=>{}))}_render(){this.isRenderingInProgress=!0,this.disableObservers(),this._renderer.render(),this.enableObservers(),this.isRenderingInProgress=!1}}he(ja,se);class Ua{constructor(t){this.parent=null,this._attrs=qo(t)}get index(){let t;if(!this.parent)return null;if(null===(t=this.parent.getChildIndex(this)))throw new s("model-node-not-found-in-parent",this);return t}get startOffset(){let t;if(!this.parent)return null;if(null===(t=this.parent.getChildStartOffset(this)))throw new s("model-node-not-found-in-parent",this);return t}get offsetSize(){return 1}get endOffset(){return this.parent?this.startOffset+this.offsetSize:null}get nextSibling(){const t=this.index;return null!==t&&this.parent.getChild(t+1)||null}get previousSibling(){const t=this.index;return null!==t&&this.parent.getChild(t-1)||null}get root(){let t=this;for(;t.parent;)t=t.parent;return t}isAttached(){return this.root.is("rootElement")}getPath(){const t=[];let e=this;for(;e.parent;)t.unshift(e.startOffset),e=e.parent;return t}getAncestors(t={includeSelf:!1,parentFirst:!1}){const e=[];let n=t.includeSelf?this:this.parent;for(;n;)e[t.parentFirst?"push":"unshift"](n),n=n.parent;return e}getCommonAncestor(t,e={}){const n=this.getAncestors(e),o=t.getAncestors(e);let i=0;for(;n[i]==o[i]&&n[i];)i++;return 0===i?null:n[i-1]}isBefore(t){if(this==t)return!1;if(this.root!==t.root)return!1;const e=this.getPath(),n=t.getPath(),o=Oo(e,n);switch(o){case"prefix":return!0;case"extension":return!1;default:return e[o](t[e[0]]=e[1],t)),{})),t}is(t){return"node"===t||"model:node"===t}_clone(){return new Ua(this._attrs)}_remove(){this.parent._removeChildren(this.index)}_setAttribute(t,e){this._attrs.set(t,e)}_setAttributesTo(t){this._attrs=qo(t)}_removeAttribute(t){return this._attrs.delete(t)}_clearAttributes(){this._attrs.clear()}}class $a extends Ua{constructor(t,e){super(e),this._data=t||""}get offsetSize(){return this.data.length}get data(){return this._data}is(t){return"$text"===t||"model:$text"===t||"text"===t||"model:text"===t||"node"===t||"model:node"===t}toJSON(){const t=super.toJSON();return t.data=this.data,t}_clone(){return new $a(this.data,this.getAttributes())}static fromJSON(t){return new $a(t.data,t.attributes)}}class Ga{constructor(t,e,n){if(this.textNode=t,e<0||e>t.offsetSize)throw new s("model-textproxy-wrong-offsetintext",this);if(n<0||e+n>t.offsetSize)throw new s("model-textproxy-wrong-length",this);this.data=t.data.substring(e,e+n),this.offsetInText=e}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(t){return"$textProxy"===t||"model:$textProxy"===t||"textProxy"===t||"model:textProxy"===t}getPath(){const t=this.textNode.getPath();return t.length>0&&(t[t.length-1]+=this.offsetInText),t}getAncestors(t={includeSelf:!1,parentFirst:!1}){const e=[];let n=t.includeSelf?this:this.parent;for(;n;)e[t.parentFirst?"push":"unshift"](n),n=n.parent;return e}hasAttribute(t){return this.textNode.hasAttribute(t)}getAttribute(t){return this.textNode.getAttribute(t)}getAttributes(){return this.textNode.getAttributes()}getAttributeKeys(){return this.textNode.getAttributeKeys()}}class Ka{constructor(t){this._nodes=[],t&&this._insertNodes(0,t)}[Symbol.iterator](){return this._nodes[Symbol.iterator]()}get length(){return this._nodes.length}get maxOffset(){return this._nodes.reduce(((t,e)=>t+e.offsetSize),0)}getNode(t){return this._nodes[t]||null}getNodeIndex(t){const e=this._nodes.indexOf(t);return-1==e?null:e}getNodeStartOffset(t){const e=this.getNodeIndex(t);return null===e?null:this._nodes.slice(0,e).reduce(((t,e)=>t+e.offsetSize),0)}indexToOffset(t){if(t==this._nodes.length)return this.maxOffset;const e=this._nodes[t];if(!e)throw new s("model-nodelist-index-out-of-bounds",this);return this.getNodeStartOffset(e)}offsetToIndex(t){let e=0;for(const n of this._nodes){if(t>=e&&tt.toJSON()))}}class Za extends Ua{constructor(t,e,n){super(e),this.name=t,this._children=new Ka,n&&this._insertChild(0,n)}get childCount(){return this._children.length}get maxOffset(){return this._children.maxOffset}get isEmpty(){return 0===this.childCount}is(t,e=null){return e?e===this.name&&("element"===t||"model:element"===t):"element"===t||"model:element"===t||"node"===t||"model:node"===t}getChild(t){return this._children.getNode(t)}getChildren(){return this._children[Symbol.iterator]()}getChildIndex(t){return this._children.getNodeIndex(t)}getChildStartOffset(t){return this._children.getNodeStartOffset(t)}offsetToIndex(t){return this._children.offsetToIndex(t)}getNodeByPath(t){let e=this;for(const n of t)e=e.getChild(e.offsetToIndex(n));return e}findAncestor(t,e={includeSelf:!1}){let n=e.includeSelf?this:this.parent;for(;n;){if(n.name===t)return n;n=n.parent}return null}toJSON(){const t=super.toJSON();if(t.name=this.name,this._children.length>0){t.children=[];for(const e of this._children)t.children.push(e.toJSON())}return t}_clone(t=!1){const e=t?Array.from(this._children).map((t=>t._clone(!0))):null;return new Za(this.name,this.getAttributes(),e)}_appendChild(t){this._insertChild(this.childCount,t)}_insertChild(t,e){const n=function(t){if("string"==typeof t)return[new $a(t)];Do(t)||(t=[t]);return Array.from(t).map((t=>"string"==typeof t?new $a(t):t instanceof Ga?new $a(t.data,t.getAttributes()):t))}(e);for(const t of n)null!==t.parent&&t._remove(),t.parent=this;this._children._insertNodes(t,n)}_removeChildren(t,e=1){const n=this._children._removeNodes(t,e);for(const t of n)t.parent=null;return n}static fromJSON(t){let e=null;if(t.children){e=[];for(const n of t.children)n.name?e.push(Za.fromJSON(n)):e.push($a.fromJSON(n))}return new Za(t.name,t.attributes,e)}}class Ja{constructor(t={}){if(!t.boundaries&&!t.startPosition)throw new s("model-tree-walker-no-start-position",null);const e=t.direction||"forward";if("forward"!=e&&"backward"!=e)throw new s("model-tree-walker-unknown-direction",t,{direction:e});this.direction=e,this.boundaries=t.boundaries||null,t.startPosition?this.position=t.startPosition.clone():this.position=Qa._createAt(this.boundaries["backward"==this.direction?"end":"start"]),this.position.stickiness="toNone",this.singleCharacters=!!t.singleCharacters,this.shallow=!!t.shallow,this.ignoreElementEnd=!!t.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(t){let e,n,o,i;do{o=this.position,i=this._visitedParent,({done:e,value:n}=this.next())}while(!e&&t(n));e||(this.position=o,this._visitedParent=i)}next(){return"forward"==this.direction?this._next():this._previous()}_next(){const t=this.position,e=this.position.clone(),n=this._visitedParent;if(null===n.parent&&e.offset===n.maxOffset)return{done:!0};if(n===this._boundaryEndParent&&e.offset==this.boundaries.end.offset)return{done:!0};const o=e.parent,i=Xa(e,o),r=i||tc(e,o,i);if(r instanceof Za)return this.shallow?e.offset++:(e.path.push(0),this._visitedParent=r),this.position=e,Ya("elementStart",r,t,e,1);if(r instanceof $a){let o;if(this.singleCharacters)o=1;else{let t=r.endOffset;this._boundaryEndParent==n&&this.boundaries.end.offsett&&(t=this.boundaries.start.offset),o=e.offset-t}const i=e.offset-r.startOffset,s=new Ga(r,i-o,o);return e.offset-=o,this.position=e,Ya("text",s,t,e,o)}return e.path.pop(),this.position=e,this._visitedParent=n.parent,Ya("elementStart",n,t,e,1)}}function Ya(t,e,n,o,i){return{done:!1,value:{type:t,item:e,previousPosition:n,nextPosition:o,length:i}}}class Qa{constructor(t,e,n="toNone"){if(!t.is("element")&&!t.is("documentFragment"))throw new s("model-position-root-invalid",t);if(!(e instanceof Array)||0===e.length)throw new s("model-position-path-incorrect-format",t,{path:e});t.is("rootElement")?e=e.slice():(e=[...t.getPath(),...e],t=t.root),this.root=t,this.path=e,this.stickiness=n}get offset(){return this.path[this.path.length-1]}set offset(t){this.path[this.path.length-1]=t}get parent(){let t=this.root;for(let e=0;en.path.length){if(e.offset!==o.maxOffset)return!1;e.path=e.path.slice(0,-1),o=o.parent,e.offset++}else{if(0!==n.offset)return!1;n.path=n.path.slice(0,-1)}}}is(t){return"position"===t||"model:position"===t}hasSameParentAs(t){if(this.root!==t.root)return!1;return"same"==Oo(this.getParentPath(),t.getParentPath())}getTransformedByOperation(t){let e;switch(t.type){case"insert":e=this._getTransformedByInsertOperation(t);break;case"move":case"remove":case"reinsert":e=this._getTransformedByMoveOperation(t);break;case"split":e=this._getTransformedBySplitOperation(t);break;case"merge":e=this._getTransformedByMergeOperation(t);break;default:e=Qa._createAt(this)}return e}_getTransformedByInsertOperation(t){return this._getTransformedByInsertion(t.position,t.howMany)}_getTransformedByMoveOperation(t){return this._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany)}_getTransformedBySplitOperation(t){const e=t.movedRange;return e.containsPosition(this)||e.start.isEqual(this)&&"toNext"==this.stickiness?this._getCombined(t.splitPosition,t.moveTargetPosition):t.graveyardPosition?this._getTransformedByMove(t.graveyardPosition,t.insertionPosition,1):this._getTransformedByInsertion(t.insertionPosition,1)}_getTransformedByMergeOperation(t){const e=t.movedRange;let n;return e.containsPosition(this)||e.start.isEqual(this)?(n=this._getCombined(t.sourcePosition,t.targetPosition),t.sourcePosition.isBefore(t.targetPosition)&&(n=n._getTransformedByDeletion(t.deletionPosition,1))):n=this.isEqual(t.deletionPosition)?Qa._createAt(t.deletionPosition):this._getTransformedByMove(t.deletionPosition,t.graveyardPosition,1),n}_getTransformedByDeletion(t,e){const n=Qa._createAt(this);if(this.root!=t.root)return n;if("same"==Oo(t.getParentPath(),this.getParentPath())){if(t.offsetthis.offset)return null;n.offset-=e}}else if("prefix"==Oo(t.getParentPath(),this.getParentPath())){const o=t.path.length-1;if(t.offset<=this.path[o]){if(t.offset+e>this.path[o])return null;n.path[o]-=e}}return n}_getTransformedByInsertion(t,e){const n=Qa._createAt(this);if(this.root!=t.root)return n;if("same"==Oo(t.getParentPath(),this.getParentPath()))(t.offsete+1;){const e=o.maxOffset-n.offset;0!==e&&t.push(new nc(n,n.getShiftedBy(e))),n.path=n.path.slice(0,-1),n.offset++,o=o.parent}for(;n.path.length<=this.end.path.length;){const e=this.end.path[n.path.length-1],o=e-n.offset;0!==o&&t.push(new nc(n,n.getShiftedBy(o))),n.offset=e,n.path.push(0)}return t}getWalker(t={}){return t.boundaries=this,new Ja(t)}*getItems(t={}){t.boundaries=this,t.ignoreElementEnd=!0;const e=new Ja(t);for(const t of e)yield t.item}*getPositions(t={}){t.boundaries=this;const e=new Ja(t);yield e.position;for(const t of e)yield t.nextPosition}getTransformedByOperation(t){switch(t.type){case"insert":return this._getTransformedByInsertOperation(t);case"move":case"remove":case"reinsert":return this._getTransformedByMoveOperation(t);case"split":return[this._getTransformedBySplitOperation(t)];case"merge":return[this._getTransformedByMergeOperation(t)]}return[new nc(this.start,this.end)]}getTransformedByOperations(t){const e=[new nc(this.start,this.end)];for(const n of t)for(let t=0;t0?new this(n,o):new this(o,n)}static _createIn(t){return new this(Qa._createAt(t,0),Qa._createAt(t,t.maxOffset))}static _createOn(t){return this._createFromPositionAndShift(Qa._createBefore(t),t.offsetSize)}static _createFromRanges(t){if(0===t.length)throw new s("range-create-from-ranges-empty-array",null);if(1==t.length)return t[0].clone();const e=t[0];t.sort(((t,e)=>t.start.isAfter(e.start)?1:-1));const n=t.indexOf(e),o=new this(e.start,e.end);if(n>0)for(let e=n-1;t[e].end.isEqual(o.start);e++)o.start=Qa._createAt(t[e].start);for(let e=n+1;e{if(e.viewPosition)return;const n=this._modelToViewMapping.get(e.modelPosition.parent);e.viewPosition=this.findPositionIn(n,e.modelPosition.offset)}),{priority:"low"}),this.on("viewToModelPosition",((t,e)=>{if(e.modelPosition)return;const n=this.findMappedViewAncestor(e.viewPosition),o=this._viewToModelMapping.get(n),i=this._toModelOffset(e.viewPosition.parent,e.viewPosition.offset,n);e.modelPosition=Qa._createAt(o,i)}),{priority:"low"})}bindElements(t,e){this._modelToViewMapping.set(t,e),this._viewToModelMapping.set(e,t)}unbindViewElement(t){const e=this.toModelElement(t);if(this._viewToModelMapping.delete(t),this._elementToMarkerNames.has(t))for(const e of this._elementToMarkerNames.get(t))this._unboundMarkerNames.add(e);this._modelToViewMapping.get(e)==t&&this._modelToViewMapping.delete(e)}unbindModelElement(t){const e=this.toViewElement(t);this._modelToViewMapping.delete(t),this._viewToModelMapping.get(e)==t&&this._viewToModelMapping.delete(e)}bindElementToMarker(t,e){const n=this._markerNameToElements.get(e)||new Set;n.add(t);const o=this._elementToMarkerNames.get(t)||new Set;o.add(e),this._markerNameToElements.set(e,n),this._elementToMarkerNames.set(t,o)}unbindElementFromMarkerName(t,e){const n=this._markerNameToElements.get(e);n&&(n.delete(t),0==n.size&&this._markerNameToElements.delete(e));const o=this._elementToMarkerNames.get(t);o&&(o.delete(e),0==o.size&&this._elementToMarkerNames.delete(t))}flushUnboundMarkerNames(){const t=Array.from(this._unboundMarkerNames);return this._unboundMarkerNames.clear(),t}clearBindings(){this._modelToViewMapping=new WeakMap,this._viewToModelMapping=new WeakMap,this._markerNameToElements=new Map,this._elementToMarkerNames=new Map,this._unboundMarkerNames=new Set}toModelElement(t){return this._viewToModelMapping.get(t)}toViewElement(t){return this._modelToViewMapping.get(t)}toModelRange(t){return new nc(this.toModelPosition(t.start),this.toModelPosition(t.end))}toViewRange(t){return new Li(this.toViewPosition(t.start),this.toViewPosition(t.end))}toModelPosition(t){const e={viewPosition:t,mapper:this};return this.fire("viewToModelPosition",e),e.modelPosition}toViewPosition(t,e={isPhantom:!1}){const n={modelPosition:t,mapper:this,isPhantom:e.isPhantom};return this.fire("modelToViewPosition",n),n.viewPosition}markerNameToElements(t){const e=this._markerNameToElements.get(t);if(!e)return null;const n=new Set;for(const t of e)if(t.is("attributeElement"))for(const e of t.getElementsWithSameId())n.add(e);else n.add(t);return n}registerViewToModelLength(t,e){this._viewToModelLengthCallbacks.set(t,e)}findMappedViewAncestor(t){let e=t.parent;for(;!this._viewToModelMapping.has(e);)e=e.parent;return e}_toModelOffset(t,e,n){if(n!=t){return this._toModelOffset(t.parent,t.index,n)+this._toModelOffset(t,e,t)}if(t.is("$text"))return e;let o=0;for(let n=0;n1?e[0]+":"+e[1]:e[0]}class sc{constructor(t){this.conversionApi=Object.assign({dispatcher:this},t),this._reconversionEventsMapping=new Map}convertChanges(t,e,n){for(const e of t.getMarkersToRemove())this.convertMarkerRemove(e.name,e.range,n);const o=this._mapChangesWithAutomaticReconversion(t);for(const t of o)"insert"===t.type?this.convertInsert(nc._createFromPositionAndShift(t.position,t.length),n):"remove"===t.type?this.convertRemove(t.position,t.length,t.name,n):"reconvert"===t.type?this.reconvertElement(t.element,n):this.convertAttribute(t.range,t.attributeKey,t.attributeOldValue,t.attributeNewValue,n);for(const t of this.conversionApi.mapper.flushUnboundMarkerNames()){const o=e.get(t).getRange();this.convertMarkerRemove(t,o,n),this.convertMarkerAdd(t,o,n)}for(const e of t.getMarkersToAdd())this.convertMarkerAdd(e.name,e.range,n)}convertInsert(t,e){this.conversionApi.writer=e,this.conversionApi.consumable=this._createInsertConsumable(t);for(const e of Array.from(t).map(cc))this._convertInsertWithAttributes(e);this._clearConversionApi()}convertRemove(t,e,n,o){this.conversionApi.writer=o,this.fire("remove:"+n,{position:t,length:e},this.conversionApi),this._clearConversionApi()}convertAttribute(t,e,n,o,i){this.conversionApi.writer=i,this.conversionApi.consumable=this._createConsumableForRange(t,`attribute:${e}`);for(const i of t){const t={item:i.item,range:nc._createFromPositionAndShift(i.previousPosition,i.length),attributeKey:e,attributeOldValue:n,attributeNewValue:o};this._testAndFire(`attribute:${e}`,t)}this._clearConversionApi()}reconvertElement(t,e){const n=nc._createOn(t);this.conversionApi.writer=e,this.conversionApi.consumable=this._createInsertConsumable(n);const o=this.conversionApi.mapper,i=o.toViewElement(t);e.remove(i),this._convertInsertWithAttributes({item:t,range:n});const r=o.toViewElement(t);for(const n of nc._createIn(t)){const{item:t}=n,i=lc(t,o);i?i.root!==r.root&&e.move(e.createRangeOn(i),o.toViewPosition(Qa._createBefore(t))):this._convertInsertWithAttributes(cc(n))}o.unbindViewElement(i),this._clearConversionApi()}convertSelection(t,e,n){const o=Array.from(e.getMarkersAtPosition(t.getFirstPosition()));if(this.conversionApi.writer=n,this.conversionApi.consumable=this._createSelectionConsumable(t,o),this.fire("selection",{selection:t},this.conversionApi),t.isCollapsed){for(const e of o){const n=e.getRange();if(!ac(t.getFirstPosition(),e,this.conversionApi.mapper))continue;const o={item:t,markerName:e.name,markerRange:n};this.conversionApi.consumable.test(t,"addMarker:"+e.name)&&this.fire("addMarker:"+e.name,o,this.conversionApi)}for(const e of t.getAttributeKeys()){const n={item:t,range:t.getFirstRange(),attributeKey:e,attributeOldValue:null,attributeNewValue:t.getAttribute(e)};this.conversionApi.consumable.test(t,"attribute:"+n.attributeKey)&&this.fire("attribute:"+n.attributeKey+":$text",n,this.conversionApi)}this._clearConversionApi()}else this._clearConversionApi()}convertMarkerAdd(t,e,n){if("$graveyard"==e.root.rootName)return;this.conversionApi.writer=n;const o="addMarker:"+t,i=new ic;if(i.add(e,o),this.conversionApi.consumable=i,this.fire(o,{markerName:t,markerRange:e},this.conversionApi),i.test(e,o)){this.conversionApi.consumable=this._createConsumableForRange(e,o);for(const n of e.getItems()){if(!this.conversionApi.consumable.test(n,o))continue;const i={item:n,range:nc._createOn(n),markerName:t,markerRange:e};this.fire(o,i,this.conversionApi)}this._clearConversionApi()}else this._clearConversionApi()}convertMarkerRemove(t,e,n){"$graveyard"!=e.root.rootName&&(this.conversionApi.writer=n,this.fire("removeMarker:"+t,{markerName:t,markerRange:e},this.conversionApi),this._clearConversionApi())}_mapReconversionTriggerEvent(t,e){this._reconversionEventsMapping.set(e,t)}_createInsertConsumable(t){const e=new ic;for(const n of t){const t=n.item;e.add(t,"insert");for(const n of t.getAttributeKeys())e.add(t,"attribute:"+n)}return e}_createConsumableForRange(t,e){const n=new ic;for(const o of t.getItems())n.add(o,e);return n}_createSelectionConsumable(t,e){const n=new ic;n.add(t,"selection");for(const o of e)n.add(t,"addMarker:"+o.name);for(const e of t.getAttributeKeys())n.add(t,"attribute:"+e);return n}_testAndFire(t,e){this.conversionApi.consumable.test(e.item,t)&&this.fire(function(t,e){const n=e.item.name||"$text";return`${t}:${n}`}(t,e),e,this.conversionApi)}_clearConversionApi(){delete this.conversionApi.writer,delete this.conversionApi.consumable}_convertInsertWithAttributes(t){this._testAndFire("insert",t);for(const e of t.item.getAttributeKeys())t.attributeKey=e,t.attributeOldValue=null,t.attributeNewValue=t.item.getAttribute(e),this._testAndFire(`attribute:${e}`,t)}_mapChangesWithAutomaticReconversion(t){const e=new Set,n=[];for(const o of t.getChanges()){const t=o.position||o.range.start,i=t.parent;if(Xa(t,i)){n.push(o);continue}const r="attribute"===o.type?tc(t,i,null):i;if(r.is("$text")){n.push(o);continue}let s;if(s="attribute"===o.type?`attribute:${o.attributeKey}:${r.name}`:`${o.type}:${o.name}`,this._isReconvertTriggerEvent(s,r.name)){if(e.has(r))continue;e.add(r),n.push({type:"reconvert",element:r})}else n.push(o)}return n}_isReconvertTriggerEvent(t,e){return this._reconversionEventsMapping.get(t)===e}}function ac(t,e,n){const o=e.getRange(),i=Array.from(t.getAncestors());i.shift(),i.reverse();return!i.some((t=>{if(o.containsItem(t)){return!!n.toViewElement(t).getCustomProperty("addHighlight")}}))}function cc(t){return{item:t.item,range:nc._createFromPositionAndShift(t.previousPosition,t.length)}}function lc(t,e){if(t.is("textProxy")){const n=e.toViewPosition(Qa._createBefore(t)).parent;return n.is("$text")?n:null}return e.toViewElement(t)}he(sc,g);class dc{constructor(t,e,n){this._lastRangeBackward=!1,this._ranges=[],this._attrs=new Map,t&&this.setTo(t,e,n)}get anchor(){if(this._ranges.length>0){const t=this._ranges[this._ranges.length-1];return this._lastRangeBackward?t.end:t.start}return null}get focus(){if(this._ranges.length>0){const t=this._ranges[this._ranges.length-1];return this._lastRangeBackward?t.start:t.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(t){if(this.rangeCount!=t.rangeCount)return!1;if(0===this.rangeCount)return!0;if(!this.anchor.isEqual(t.anchor)||!this.focus.isEqual(t.focus))return!1;for(const e of this._ranges){let n=!1;for(const o of t._ranges)if(e.isEqual(o)){n=!0;break}if(!n)return!1}return!0}*getRanges(){for(const t of this._ranges)yield new nc(t.start,t.end)}getFirstRange(){let t=null;for(const e of this._ranges)t&&!e.start.isBefore(t.start)||(t=e);return t?new nc(t.start,t.end):null}getLastRange(){let t=null;for(const e of this._ranges)t&&!e.end.isAfter(t.end)||(t=e);return t?new nc(t.start,t.end):null}getFirstPosition(){const t=this.getFirstRange();return t?t.start.clone():null}getLastPosition(){const t=this.getLastRange();return t?t.end.clone():null}setTo(t,e,n){if(null===t)this._setRanges([]);else if(t instanceof dc)this._setRanges(t.getRanges(),t.isBackward);else if(t&&"function"==typeof t.getRanges)this._setRanges(t.getRanges(),t.isBackward);else if(t instanceof nc)this._setRanges([t],!!e&&!!e.backward);else if(t instanceof Qa)this._setRanges([new nc(t)]);else if(t instanceof Ua){const o=!!n&&!!n.backward;let i;if("in"==e)i=nc._createIn(t);else if("on"==e)i=nc._createOn(t);else{if(void 0===e)throw new s("model-selection-setto-required-second-parameter",[this,t]);i=new nc(Qa._createAt(t,e))}this._setRanges([i],o)}else{if(!Do(t))throw new s("model-selection-setto-not-selectable",[this,t]);this._setRanges(t,e&&!!e.backward)}}_setRanges(t,e=!1){const n=(t=Array.from(t)).some((e=>{if(!(e instanceof nc))throw new s("model-selection-set-ranges-not-range",[this,t]);return this._ranges.every((t=>!t.isEqual(e)))}));if(t.length!==this._ranges.length||n){this._removeAllRanges();for(const e of t)this._pushRange(e);this._lastRangeBackward=!!e,this.fire("change:range",{directChange:!0})}}setFocus(t,e){if(null===this.anchor)throw new s("model-selection-setfocus-no-ranges",[this,t]);const n=Qa._createAt(t,e);if("same"==n.compareWith(this.focus))return;const o=this.anchor;this._ranges.length&&this._popRange(),"before"==n.compareWith(o)?(this._pushRange(new nc(n,o)),this._lastRangeBackward=!0):(this._pushRange(new nc(o,n)),this._lastRangeBackward=!1),this.fire("change:range",{directChange:!0})}getAttribute(t){return this._attrs.get(t)}getAttributes(){return this._attrs.entries()}getAttributeKeys(){return this._attrs.keys()}hasAttribute(t){return this._attrs.has(t)}removeAttribute(t){this.hasAttribute(t)&&(this._attrs.delete(t),this.fire("change:attribute",{attributeKeys:[t],directChange:!0}))}setAttribute(t,e){this.getAttribute(t)!==e&&(this._attrs.set(t,e),this.fire("change:attribute",{attributeKeys:[t],directChange:!0}))}getSelectedElement(){return 1!==this.rangeCount?null:this.getFirstRange().getContainedElement()}is(t){return"selection"===t||"model:selection"===t}*getSelectedBlocks(){const t=new WeakSet;for(const e of this.getRanges()){const n=pc(e.start,t);n&&mc(n,e)&&(yield n);for(const n of e.getWalker()){const o=n.item;"elementEnd"==n.type&&hc(o,t,e)&&(yield o)}const o=pc(e.end,t);o&&!e.end.isTouching(Qa._createAt(o,0))&&mc(o,e)&&(yield o)}}containsEntireContent(t=this.anchor.root){const e=Qa._createAt(t,0),n=Qa._createAt(t,"end");return e.isTouching(this.getFirstPosition())&&n.isTouching(this.getLastPosition())}_pushRange(t){this._checkRange(t),this._ranges.push(new nc(t.start,t.end))}_checkRange(t){for(let e=0;e0;)this._popRange()}_popRange(){this._ranges.pop()}}function uc(t,e){return!e.has(t)&&(e.add(t),t.root.document.model.schema.isBlock(t)&&t.parent)}function hc(t,e,n){return uc(t,e)&&mc(t,n)}function pc(t,e){const n=t.parent.root.document.model.schema,o=t.parent.getAncestors({parentFirst:!0,includeSelf:!0});let i=!1;const r=o.find((t=>!i&&(i=n.isLimit(t),!i&&uc(t,e))));return o.forEach((t=>e.add(t))),r}function mc(t,e){const n=function(t){const e=t.root.document.model.schema;let n=t.parent;for(;n;){if(e.isBlock(n))return n;n=n.parent}}(t);if(!n)return!0;return!e.containsRange(nc._createOn(n),!0)}he(dc,g);class gc extends nc{constructor(t,e){super(t,e),fc.call(this)}detach(){this.stopListening()}is(t){return"liveRange"===t||"model:liveRange"===t||"range"==t||"model:range"===t}toRange(){return new nc(this.start,this.end)}static fromRange(t){return new gc(t.start,t.end)}}function fc(){this.listenTo(this.root.document.model,"applyOperation",((t,e)=>{const n=e[0];n.isDocumentOperation&&bc.call(this,n)}),{priority:"low"})}function bc(t){const e=this.getTransformedByOperation(t),n=nc._createFromRanges(e),o=!n.isEqual(this),i=function(t,e){switch(e.type){case"insert":return t.containsPosition(e.position);case"move":case"remove":case"reinsert":case"merge":return t.containsPosition(e.sourcePosition)||t.start.isEqual(e.sourcePosition)||t.containsPosition(e.targetPosition);case"split":return t.containsPosition(e.splitPosition)||t.containsPosition(e.insertionPosition)}return!1}(this,t);let r=null;if(o){"$graveyard"==n.root.rootName&&(r="remove"==t.type?t.sourcePosition:t.deletionPosition);const e=this.toRange();this.start=n.start,this.end=n.end,this.fire("change:range",e,{deletionPosition:r})}else i&&this.fire("change:content",this.toRange(),{deletionPosition:r})}he(gc,g);const kc="selection:";class wc{constructor(t){this._selection=new _c(t),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(t){return this._selection.containsEntireContent(t)}destroy(){this._selection.destroy()}getAttributeKeys(){return this._selection.getAttributeKeys()}getAttributes(){return this._selection.getAttributes()}getAttribute(t){return this._selection.getAttribute(t)}hasAttribute(t){return this._selection.hasAttribute(t)}refresh(){this._selection._updateMarkers(),this._selection._updateAttributes(!1)}observeMarkers(t){this._selection.observeMarkers(t)}is(t){return"selection"===t||"model:selection"==t||"documentSelection"==t||"model:documentSelection"==t}_setFocus(t,e){this._selection.setFocus(t,e)}_setTo(t,e,n){this._selection.setTo(t,e,n)}_setAttribute(t,e){this._selection.setAttribute(t,e)}_removeAttribute(t){this._selection.removeAttribute(t)}_getStoredAttributes(){return this._selection._getStoredAttributes()}_overrideGravity(){return this._selection.overrideGravity()}_restoreGravity(t){this._selection.restoreGravity(t)}static _getStoreAttributeKey(t){return kc+t}static _isStoreAttributeKey(t){return t.startsWith(kc)}}he(wc,g);class _c extends dc{constructor(t){super(),this.markers=new So({idProperty:"name"}),this._model=t.model,this._document=t,this._attributePriority=new Map,this._selectionRestorePosition=null,this._hasChangedRange=!1,this._overriddenGravityRegister=new Set,this._observedMarkers=new Set,this.listenTo(this._model,"applyOperation",((t,e)=>{const n=e[0];n.isDocumentOperation&&"marker"!=n.type&&"rename"!=n.type&&"noop"!=n.type&&(0==this._ranges.length&&this._selectionRestorePosition&&this._fixGraveyardSelection(this._selectionRestorePosition),this._selectionRestorePosition=null,this._hasChangedRange&&(this._hasChangedRange=!1,this.fire("change:range",{directChange:!1})))}),{priority:"lowest"}),this.on("change:range",(()=>{for(const t of this.getRanges())if(!this._document._validateSelectionRange(t))throw new s("document-selection-wrong-position",this,{range:t})})),this.listenTo(this._model.markers,"update",((t,e,n,o)=>{this._updateMarker(e,o)})),this.listenTo(this._document,"change",((t,e)=>{!function(t,e){const n=t.document.differ;for(const o of n.getChanges()){if("insert"!=o.type)continue;const n=o.position.parent;o.length===n.maxOffset&&t.enqueueChange(e,(t=>{const e=Array.from(n.getAttributeKeys()).filter((t=>t.startsWith(kc)));for(const o of e)t.removeAttribute(o,n)}))}}(this._model,e)}))}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 t=0;t{if(this._hasChangedRange=!0,e.root==this._document.graveyard){this._selectionRestorePosition=o.deletionPosition;const t=this._ranges.indexOf(e);this._ranges.splice(t,1),e.detach()}})),e}_updateMarkers(){if(!this._observedMarkers.size)return;const t=[];let e=!1;for(const e of this._model.markers){const n=e.name.split(":",1)[0];if(!this._observedMarkers.has(n))continue;const o=e.getRange();for(const n of this.getRanges())o.containsRange(n,!n.isCollapsed)&&t.push(e)}const n=Array.from(this.markers);for(const n of t)this.markers.has(n)||(this.markers.add(n),e=!0);for(const n of Array.from(this.markers))t.includes(n)||(this.markers.remove(n),e=!0);e&&this.fire("change:marker",{oldMarkers:n,directChange:!1})}_updateMarker(t,e){const n=t.name.split(":",1)[0];if(!this._observedMarkers.has(n))return;let o=!1;const i=Array.from(this.markers),r=this.markers.has(t);if(e){let n=!1;for(const t of this.getRanges())if(e.containsRange(t,!t.isCollapsed)){n=!0;break}n&&!r?(this.markers.add(t),o=!0):!n&&r&&(this.markers.remove(t),o=!0)}else r&&(this.markers.remove(t),o=!0);o&&this.fire("change:marker",{oldMarkers:i,directChange:!1})}_updateAttributes(t){const e=qo(this._getSurroundingAttributes()),n=qo(this.getAttributes());if(t)this._attributePriority=new Map,this._attrs=new Map;else for(const[t,e]of this._attributePriority)"low"==e&&(this._attrs.delete(t),this._attributePriority.delete(t));this._setAttributesTo(e);const o=[];for(const[t,e]of this.getAttributes())n.has(t)&&n.get(t)===e||o.push(t);for(const[t]of n)this.hasAttribute(t)||o.push(t);o.length>0&&this.fire("change:attribute",{attributeKeys:o,directChange:!1})}_setAttribute(t,e,n=!0){const o=n?"normal":"low";if("low"==o&&"normal"==this._attributePriority.get(t))return!1;return super.getAttribute(t)!==e&&(this._attrs.set(t,e),this._attributePriority.set(t,o),!0)}_removeAttribute(t,e=!0){const n=e?"normal":"low";return("low"!=n||"normal"!=this._attributePriority.get(t))&&(this._attributePriority.set(t,n),!!super.hasAttribute(t)&&(this._attrs.delete(t),!0))}_setAttributesTo(t){const e=new Set;for(const[e,n]of this.getAttributes())t.get(e)!==n&&this._removeAttribute(e,!1);for(const[n,o]of t){this._setAttribute(n,o,!1)&&e.add(n)}return e}*_getStoredAttributes(){const t=this.getFirstPosition().parent;if(this.isCollapsed&&t.isEmpty)for(const e of t.getAttributeKeys())if(e.startsWith(kc)){const n=e.substr(kc.length);yield[n,t.getAttribute(e)]}}_getSurroundingAttributes(){const t=this.getFirstPosition(),e=this._model.schema;let n=null;if(this.isCollapsed){const o=t.textNode?t.textNode:t.nodeBefore,i=t.textNode?t.textNode:t.nodeAfter;if(this.isGravityOverridden||(n=Cc(o)),n||(n=Cc(i)),!this.isGravityOverridden&&!n){let t=o;for(;t&&!e.isInline(t)&&!n;)t=t.previousSibling,n=Cc(t)}if(!n){let t=i;for(;t&&!e.isInline(t)&&!n;)t=t.nextSibling,n=Cc(t)}n||(n=this._getStoredAttributes())}else{const t=this.getFirstRange();for(const o of t){if(o.item.is("element")&&e.isObject(o.item))break;if("text"==o.type){n=o.item.getAttributes();break}}}return n}_fixGraveyardSelection(t){const e=this._model.schema.getNearestSelectionRange(t);e&&this._pushRange(e)}}function Cc(t){return t instanceof Ga||t instanceof $a?t.getAttributes():null}class Ac{constructor(t){this._dispatchers=t}add(t){for(const e of this._dispatchers)t(e);return this}}const vc=function(t){return Co(t,5)};class yc extends Ac{elementToElement(t){return this.add(function(t){return(t=vc(t)).view=Dc(t.view,"container"),e=>{var n;if(e.on("insert:"+t.model,(n=t.view,(t,e,o)=>{const i=n(e.item,o);if(!i)return;if(!o.consumable.consume(e.item,"insert"))return;const r=o.mapper.toViewPosition(e.range.start);o.mapper.bindElements(e.item,i),o.writer.insert(r,i)}),{priority:t.converterPriority||"normal"}),t.triggerBy){if(t.triggerBy.attributes)for(const n of t.triggerBy.attributes)e._mapReconversionTriggerEvent(t.model,`attribute:${n}:${t.model}`);if(t.triggerBy.children)for(const n of t.triggerBy.children)e._mapReconversionTriggerEvent(t.model,`insert:${n}`),e._mapReconversionTriggerEvent(t.model,`remove:${n}`)}}}(t))}attributeToElement(t){return this.add(function(t){t=vc(t);let e="attribute:"+(t.model.key?t.model.key:t.model);t.model.name&&(e+=":"+t.model.name);if(t.model.values)for(const e of t.model.values)t.view[e]=Dc(t.view[e],"attribute");else t.view=Dc(t.view,"attribute");const n=Sc(t);return o=>{o.on(e,function(t){return(e,n,o)=>{const i=t(n.attributeOldValue,o),r=t(n.attributeNewValue,o);if(!i&&!r)return;if(!o.consumable.consume(n.item,e.name))return;const s=o.writer,a=s.document.selection;if(n.item instanceof dc||n.item instanceof wc)s.wrap(a.getFirstRange(),r);else{let t=o.mapper.toViewRange(n.range);null!==n.attributeOldValue&&i&&(t=s.unwrap(t,i)),null!==n.attributeNewValue&&r&&s.wrap(t,r)}}}(n),{priority:t.converterPriority||"normal"})}}(t))}attributeToAttribute(t){return this.add(function(t){t=vc(t);let e="attribute:"+(t.model.key?t.model.key:t.model);t.model.name&&(e+=":"+t.model.name);if(t.model.values)for(const e of t.model.values)t.view[e]=Bc(t.view[e]);else t.view=Bc(t.view);const n=Sc(t);return o=>{var i;o.on(e,(i=n,(t,e,n)=>{const o=i(e.attributeOldValue,n),r=i(e.attributeNewValue,n);if(!o&&!r)return;if(!n.consumable.consume(e.item,t.name))return;const a=n.mapper.toViewElement(e.item),c=n.writer;if(!a)throw new s("conversion-attribute-to-attribute-on-text",[e,n]);if(null!==e.attributeOldValue&&o)if("class"==o.key){const t=To(o.value);for(const e of t)c.removeClass(e,a)}else if("style"==o.key){const t=Object.keys(o.value);for(const e of t)c.removeStyle(e,a)}else c.removeAttribute(o.key,a);if(null!==e.attributeNewValue&&r)if("class"==r.key){const t=To(r.value);for(const e of t)c.addClass(e,a)}else if("style"==r.key){const t=Object.keys(r.value);for(const e of t)c.setStyle(e,r.value[e],a)}else c.setAttribute(r.key,r.value,a)}),{priority:t.converterPriority||"normal"})}}(t))}markerToElement(t){return this.add(function(t){return(t=vc(t)).view=Dc(t.view,"ui"),e=>{var n;e.on("addMarker:"+t.model,(n=t.view,(t,e,o)=>{e.isOpening=!0;const i=n(e,o);e.isOpening=!1;const r=n(e,o);if(!i||!r)return;const s=e.markerRange;if(s.isCollapsed&&!o.consumable.consume(s,t.name))return;for(const e of s)if(!o.consumable.consume(e.item,t.name))return;const a=o.mapper,c=o.writer;c.insert(a.toViewPosition(s.start),i),o.mapper.bindElementToMarker(i,e.markerName),s.isCollapsed||(c.insert(a.toViewPosition(s.end),r),o.mapper.bindElementToMarker(r,e.markerName)),t.stop()}),{priority:t.converterPriority||"normal"}),e.on("removeMarker:"+t.model,(t.view,(t,e,n)=>{const o=n.mapper.markerNameToElements(e.markerName);if(o){for(const t of o)n.mapper.unbindElementFromMarkerName(t,e.markerName),n.writer.clear(n.writer.createRangeOn(t),t);n.writer.clearClonedElementsGroup(e.markerName),t.stop()}}),{priority:t.converterPriority||"normal"})}}(t))}markerToHighlight(t){return this.add(function(t){return e=>{var n;e.on("addMarker:"+t.model,(n=t.view,(t,e,o)=>{if(!e.item)return;if(!(e.item instanceof dc||e.item instanceof wc||e.item.is("$textProxy")))return;const i=Tc(n,e,o);if(!i)return;if(!o.consumable.consume(e.item,t.name))return;const r=o.writer,s=xc(r,i),a=r.document.selection;if(e.item instanceof dc||e.item instanceof wc)r.wrap(a.getFirstRange(),s,a);else{const t=o.mapper.toViewRange(e.range),n=r.wrap(t,s);for(const t of n.getItems())if(t.is("attributeElement")&&t.isSimilar(s)){o.mapper.bindElementToMarker(t,e.markerName);break}}}),{priority:t.converterPriority||"normal"}),e.on("addMarker:"+t.model,function(t){return(e,n,o)=>{if(!n.item)return;if(!(n.item instanceof Za))return;const i=Tc(t,n,o);if(!i)return;if(!o.consumable.test(n.item,e.name))return;const r=o.mapper.toViewElement(n.item);if(r&&r.getCustomProperty("addHighlight")){o.consumable.consume(n.item,e.name);for(const t of nc._createIn(n.item))o.consumable.consume(t.item,e.name);r.getCustomProperty("addHighlight")(r,i,o.writer),o.mapper.bindElementToMarker(r,n.markerName)}}}(t.view),{priority:t.converterPriority||"normal"}),e.on("removeMarker:"+t.model,function(t){return(e,n,o)=>{if(n.markerRange.isCollapsed)return;const i=Tc(t,n,o);if(!i)return;const r=xc(o.writer,i),s=o.mapper.markerNameToElements(n.markerName);if(s){for(const t of s)o.mapper.unbindElementFromMarkerName(t,n.markerName),t.is("attributeElement")?o.writer.unwrap(o.writer.createRangeOn(t),r):t.getCustomProperty("removeHighlight")(t,i.id,o.writer);o.writer.clearClonedElementsGroup(n.markerName),e.stop()}}}(t.view),{priority:t.converterPriority||"normal"})}}(t))}markerToData(t){return this.add(function(t){const e=(t=vc(t)).model;t.view||(t.view=n=>({group:e,name:n.substr(t.model.length+1)}));return n=>{var o;n.on("addMarker:"+e,(o=t.view,(t,e,n)=>{const i=o(e.markerName,n);if(!i)return;const r=e.markerRange;n.consumable.consume(r,t.name)&&(Ec(r,!1,n,e,i),Ec(r,!0,n,e,i),t.stop())}),{priority:t.converterPriority||"normal"}),n.on("removeMarker:"+e,function(t){return(e,n,o)=>{const i=t(n.markerName,o);if(!i)return;const r=o.mapper.markerNameToElements(n.markerName);if(r){for(const t of r)o.mapper.unbindElementFromMarkerName(t,n.markerName),t.is("containerElement")?(s(`data-${i.group}-start-before`,t),s(`data-${i.group}-start-after`,t),s(`data-${i.group}-end-before`,t),s(`data-${i.group}-end-after`,t)):o.writer.clear(o.writer.createRangeOn(t),t);o.writer.clearClonedElementsGroup(n.markerName),e.stop()}function s(t,e){if(e.hasAttribute(t)){const n=new Set(e.getAttribute(t).split(","));n.delete(i.name),0==n.size?o.writer.removeAttribute(t,e):o.writer.setAttribute(t,Array.from(n).join(","),e)}}}}(t.view),{priority:t.converterPriority||"normal"})}}(t))}}function xc(t,e){const n=t.createAttributeElement("span",e.attributes);return e.classes&&n._addClass(e.classes),"number"==typeof e.priority&&(n._priority=e.priority),n._id=e.id,n}function Ec(t,e,n,o,i){const r=e?t.start:t.end,s=r.nodeAfter&&r.nodeAfter.is("element")?r.nodeAfter:null,a=r.nodeBefore&&r.nodeBefore.is("element")?r.nodeBefore:null;if(s||a){let t,r;e&&s||!e&&!a?(t=s,r=!0):(t=a,r=!1);const c=n.mapper.toViewElement(t);if(c)return void function(t,e,n,o,i,r){const s=`data-${r.group}-${e?"start":"end"}-${n?"before":"after"}`,a=t.hasAttribute(s)?t.getAttribute(s).split(","):[];a.unshift(r.name),o.writer.setAttribute(s,a.join(","),t),o.mapper.bindElementToMarker(t,i.markerName)}(c,e,r,n,o,i)}!function(t,e,n,o,i){const r=`${i.group}-${e?"start":"end"}`,s=i.name?{name:i.name}:null,a=n.writer.createUIElement(r,s);n.writer.insert(t,a),n.mapper.bindElementToMarker(a,o.markerName)}(n.mapper.toViewPosition(r),e,n,o,i)}function Dc(t,e){return"function"==typeof t?t:(n,o)=>function(t,e,n){"string"==typeof t&&(t={name:t});let o;const i=e.writer,r=Object.assign({},t.attributes);if("container"==n)o=i.createContainerElement(t.name,r);else if("attribute"==n){const e={priority:t.priority||tr.DEFAULT_PRIORITY};o=i.createAttributeElement(t.name,r,e)}else o=i.createUIElement(t.name,r);if(t.styles){const e=Object.keys(t.styles);for(const n of e)i.setStyle(n,t.styles[n],o)}if(t.classes){const e=t.classes;if("string"==typeof e)i.addClass(e,o);else for(const t of e)i.addClass(t,o)}return o}(t,o,e)}function Sc(t){return t.model.values?(e,n)=>{const o=t.view[e];return o?o(e,n):null}:t.view}function Bc(t){return"string"==typeof t?e=>({key:t,value:e}):"object"==typeof t?t.value?()=>t:e=>({key:t.key,value:e}):t}function Tc(t,e,n){const o="function"==typeof t?t(e,n):t;return o?(o.priority||(o.priority=10),o.id||(o.id=e.markerName),o):null}function Pc(t){const{schema:e,document:n}=t.model;for(const o of n.getRootNames()){const i=n.getRoot(o);if(i.isEmpty&&!e.checkChild(i,"$text")&&e.checkChild(i,"paragraph"))return t.insertElement("paragraph",i),!0}return!1}function Ic(t,e,n){const o=n.createContext(t);return!!n.checkChild(o,"paragraph")&&!!n.checkChild(o.push("paragraph"),e)}function Rc(t,e){const n=e.createElement("paragraph");return e.insert(n,t),e.createPositionAt(n,0)}class zc extends Ac{elementToElement(t){return this.add(Fc(t))}elementToAttribute(t){return this.add(function(t){Mc(t=vc(t));const e=Vc(t,!1),n=Nc(t.view),o=n?"element:"+n:"element";return n=>{n.on(o,e,{priority:t.converterPriority||"low"})}}(t))}attributeToAttribute(t){return this.add(function(t){t=vc(t);let e=null;("string"==typeof t.view||t.view.key)&&(e=function(t){"string"==typeof t.view&&(t.view={key:t.view});const e=t.view.key;let n;if("class"==e||"style"==e){n={["class"==e?"classes":"styles"]:t.view.value}}else{n={attributes:{[e]:void 0===t.view.value?/[\s\S]*/:t.view.value}}}t.view.name&&(n.name=t.view.name);return t.view=n,e}(t));Mc(t,e);const n=Vc(t,!0);return e=>{e.on("element",n,{priority:t.converterPriority||"low"})}}(t))}elementToMarker(t){return this.add(function(t){return function(t){const e=t.model;t.model=(t,n)=>{const o="string"==typeof e?e:e(t,n);return n.writer.createElement("$marker",{"data-name":o})}}(t=vc(t)),Fc(t)}(t))}dataToMarker(t){return this.add(function(t){(t=vc(t)).model||(t.model=e=>e?t.view+":"+e:t.view);const e=Oc(Lc(t,"start")),n=Oc(Lc(t,"end"));return o=>{o.on("element:"+t.view+"-start",e,{priority:t.converterPriority||"normal"}),o.on("element:"+t.view+"-end",n,{priority:t.converterPriority||"normal"});const i=r.get("low"),s=r.get("highest"),a=r.get(t.converterPriority)/s;o.on("element",function(t){return(e,n,o)=>{const i=`data-${t.view}`;function r(e,i){for(const r of i){const i=t.model(r,o),s=o.writer.createElement("$marker",{"data-name":i});o.writer.insert(s,e),n.modelCursor.isEqual(e)?n.modelCursor=n.modelCursor.getShiftedBy(1):n.modelCursor=n.modelCursor._getTransformedByInsertion(e,1),n.modelRange=n.modelRange._getTransformedByInsertion(e,1)[0]}}(o.consumable.test(n.viewItem,{attributes:i+"-end-after"})||o.consumable.test(n.viewItem,{attributes:i+"-start-after"})||o.consumable.test(n.viewItem,{attributes:i+"-end-before"})||o.consumable.test(n.viewItem,{attributes:i+"-start-before"}))&&(n.modelRange||Object.assign(n,o.convertChildren(n.viewItem,n.modelCursor)),o.consumable.consume(n.viewItem,{attributes:i+"-end-after"})&&r(n.modelRange.end,n.viewItem.getAttribute(i+"-end-after").split(",")),o.consumable.consume(n.viewItem,{attributes:i+"-start-after"})&&r(n.modelRange.end,n.viewItem.getAttribute(i+"-start-after").split(",")),o.consumable.consume(n.viewItem,{attributes:i+"-end-before"})&&r(n.modelRange.start,n.viewItem.getAttribute(i+"-end-before").split(",")),o.consumable.consume(n.viewItem,{attributes:i+"-start-before"})&&r(n.modelRange.start,n.viewItem.getAttribute(i+"-start-before").split(",")))}}(t),{priority:i+a})}}(t))}}function Fc(t){const e=Oc(t=vc(t)),n=Nc(t.view),o=n?"element:"+n:"element";return n=>{n.on(o,e,{priority:t.converterPriority||"normal"})}}function Nc(t){return"string"==typeof t?t:"object"==typeof t&&"string"==typeof t.name?t.name:null}function Oc(t){const e=new Wo(t.view);return(n,o,i)=>{const r=e.match(o.viewItem);if(!r)return;const s=r.match;if(s.name=!0,!i.consumable.test(o.viewItem,s))return;const a=function(t,e,n){return t instanceof Function?t(e,n):n.writer.createElement(t)}(t.model,o.viewItem,i);a&&i.safeInsert(a,o.modelCursor)&&(i.consumable.consume(o.viewItem,s),i.convertChildren(o.viewItem,a),i.updateConversionResult(a,o))}}function Mc(t,e=null){const n=null===e||(t=>t.getAttribute(e)),o="object"!=typeof t.model?t.model:t.model.key,i="object"!=typeof t.model||void 0===t.model.value?n:t.model.value;t.model={key:o,value:i}}function Vc(t,e){const n=new Wo(t.view);return(o,i,r)=>{const s=n.match(i.viewItem);if(!s)return;if(!function(t,e){const n="function"==typeof t?t(e):t;if("object"==typeof n&&!Nc(n))return!1;return!n.classes&&!n.attributes&&!n.styles}(t.view,i.viewItem)?delete s.match.name:s.match.name=!0,!r.consumable.test(i.viewItem,s.match))return;const a=t.model.key,c="function"==typeof t.model.value?t.model.value(i.viewItem,r):t.model.value;if(null===c)return;i.modelRange||Object.assign(i,r.convertChildren(i.viewItem,i.modelCursor));const l=function(t,e,n,o){let i=!1;for(const r of Array.from(t.getItems({shallow:n})))o.schema.checkAttribute(r,e.key)&&(i=!0,r.hasAttribute(e.key)||o.writer.setAttribute(e.key,e.value,r));return i}(i.modelRange,{key:a,value:c},e,r);l&&r.consumable.consume(i.viewItem,s.match)}}function Lc(t,e){const n={};return n.view=t.view+"-"+e,n.model=(e,n)=>{const o=e.getAttribute("name"),i=t.model(o,n);return n.writer.createElement("$marker",{"data-name":i})},n}class Hc{constructor(t,e){this.model=t,this.view=new ja(e),this.mapper=new oc,this.downcastDispatcher=new sc({mapper:this.mapper,schema:t.schema});const n=this.model.document,o=n.selection,i=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(n,"change",(()=>{this.view.change((t=>{this.downcastDispatcher.convertChanges(n.differ,i,t),this.downcastDispatcher.convertSelection(o,i,t)}))}),{priority:"low"}),this.listenTo(this.view.document,"selectionChange",function(t,e){return(n,o)=>{const i=o.newSelection,r=[];for(const t of i.getRanges())r.push(e.toModelRange(t));const s=t.createSelection(r,{backward:i.isBackward});s.isEqual(t.document.selection)||t.change((t=>{t.setSelection(s)}))}}(this.model,this.mapper)),this.downcastDispatcher.on("insert:$text",((t,e,n)=>{if(!n.consumable.consume(e.item,"insert"))return;const o=n.writer,i=n.mapper.toViewPosition(e.range.start),r=o.createText(e.item.data);o.insert(i,r)}),{priority:"lowest"}),this.downcastDispatcher.on("remove",((t,e,n)=>{const o=n.mapper.toViewPosition(e.position),i=e.position.getShiftedBy(e.length),r=n.mapper.toViewPosition(i,{isPhantom:!0}),s=n.writer.createRange(o,r),a=n.writer.remove(s.getTrimmed());for(const t of n.writer.createRangeIn(a).getItems())n.mapper.unbindViewElement(t)}),{priority:"low"}),this.downcastDispatcher.on("selection",((t,e,n)=>{const o=n.writer,i=o.document.selection;for(const t of i.getRanges())t.isCollapsed&&t.end.parent.isAttached()&&n.writer.mergeAttributes(t.start);o.setSelection(null)}),{priority:"high"}),this.downcastDispatcher.on("selection",((t,e,n)=>{const o=e.selection;if(o.isCollapsed)return;if(!n.consumable.consume(o,"selection"))return;const i=[];for(const t of o.getRanges()){const e=n.mapper.toViewRange(t);i.push(e)}n.writer.setSelection(i,{backward:o.isBackward})}),{priority:"low"}),this.downcastDispatcher.on("selection",((t,e,n)=>{const o=e.selection;if(!o.isCollapsed)return;if(!n.consumable.consume(o,"selection"))return;const i=n.writer,r=o.getFirstPosition(),s=n.mapper.toViewPosition(r),a=i.breakAttributes(s);i.setSelection(a)}),{priority:"low"}),this.view.document.roots.bindTo(this.model.document.roots).using((t=>{if("$graveyard"==t.rootName)return null;const e=new Oi(this.view.document,t.name);return e.rootName=t.rootName,this.mapper.bindElements(t,e),e}))}destroy(){this.view.destroy(),this.stopListening()}}he(Hc,se);class qc{constructor(){this._commands=new Map}add(t,e){this._commands.set(t,e)}get(t){return this._commands.get(t)}execute(t,...e){const n=this.get(t);if(!n)throw new s("commandcollection-command-not-found",this,{commandName:t});return n.execute(...e)}*names(){yield*this._commands.keys()}*commands(){yield*this._commands.values()}[Symbol.iterator](){return this._commands[Symbol.iterator]()}destroy(){for(const t of this.commands())t.destroy()}}class Wc{constructor(){this._consumables=new Map}add(t,e){let n;t.is("$text")||t.is("documentFragment")?this._consumables.set(t,!0):(this._consumables.has(t)?n=this._consumables.get(t):(n=new jc(t),this._consumables.set(t,n)),n.add(e))}test(t,e){const n=this._consumables.get(t);return void 0===n?null:t.is("$text")||t.is("documentFragment")?n:n.test(e)}consume(t,e){return!!this.test(t,e)&&(t.is("$text")||t.is("documentFragment")?this._consumables.set(t,!1):this._consumables.get(t).consume(e),!0)}revert(t,e){const n=this._consumables.get(t);void 0!==n&&(t.is("$text")||t.is("documentFragment")?this._consumables.set(t,!0):n.revert(e))}static consumablesFromElement(t){const e={element:t,name:!0,attributes:[],classes:[],styles:[]},n=t.getAttributeKeys();for(const t of n)"style"!=t&&"class"!=t&&e.attributes.push(t);const o=t.getClassNames();for(const t of o)e.classes.push(t);const i=t.getStyleNames();for(const t of i)e.styles.push(t);return e}static createFrom(t,e){if(e||(e=new Wc(t)),t.is("$text"))return e.add(t),e;t.is("element")&&e.add(t,Wc.consumablesFromElement(t)),t.is("documentFragment")&&e.add(t);for(const n of t.getChildren())e=Wc.createFrom(n,e);return e}}class jc{constructor(t){this.element=t,this._canConsumeName=null,this._consumables={attributes:new Map,styles:new Map,classes:new Map}}add(t){t.name&&(this._canConsumeName=!0);for(const e in this._consumables)e in t&&this._add(e,t[e])}test(t){if(t.name&&!this._canConsumeName)return this._canConsumeName;for(const e in this._consumables)if(e in t){const n=this._test(e,t[e]);if(!0!==n)return n}return!0}consume(t){t.name&&(this._canConsumeName=!1);for(const e in this._consumables)e in t&&this._consume(e,t[e])}revert(t){t.name&&(this._canConsumeName=!0);for(const e in this._consumables)e in t&&this._revert(e,t[e])}_add(t,e){const n=Bt(e)?e:[e],o=this._consumables[t];for(const e of n){if("attributes"===t&&("class"===e||"style"===e))throw new s("viewconsumable-invalid-attribute",this);if(o.set(e,!0),"styles"===t)for(const t of this.element.document.stylesProcessor.getRelatedStyles(e))o.set(t,!0)}}_test(t,e){const n=Bt(e)?e:[e],o=this._consumables[t];for(const e of n)if("attributes"!==t||"class"!==e&&"style"!==e){const t=o.get(e);if(void 0===t)return null;if(!t)return!1}else{const t="class"==e?"classes":"styles",n=this._test(t,[...this._consumables[t].keys()]);if(!0!==n)return n}return!0}_consume(t,e){const n=Bt(e)?e:[e],o=this._consumables[t];for(const e of n)if("attributes"!==t||"class"!==e&&"style"!==e){if(o.set(e,!1),"styles"==t)for(const t of this.element.document.stylesProcessor.getRelatedStyles(e))o.set(t,!1)}else{const t="class"==e?"classes":"styles";this._consume(t,[...this._consumables[t].keys()])}}_revert(t,e){const n=Bt(e)?e:[e],o=this._consumables[t];for(const e of n)if("attributes"!==t||"class"!==e&&"style"!==e){!1===o.get(e)&&o.set(e,!0)}else{const t="class"==e?"classes":"styles";this._revert(t,[...this._consumables[t].keys()])}}}class Uc{constructor(){this._sourceDefinitions={},this._attributeProperties={},this.decorate("checkChild"),this.decorate("checkAttribute"),this.on("checkAttribute",((t,e)=>{e[0]=new $c(e[0])}),{priority:"highest"}),this.on("checkChild",((t,e)=>{e[0]=new $c(e[0]),e[1]=this.getDefinition(e[1])}),{priority:"highest"})}register(t,e){if(this._sourceDefinitions[t])throw new s("schema-cannot-register-item-twice",this,{itemName:t});this._sourceDefinitions[t]=[Object.assign({},e)],this._clearCache()}extend(t,e){if(!this._sourceDefinitions[t])throw new s("schema-cannot-extend-missing-item",this,{itemName:t});this._sourceDefinitions[t].push(Object.assign({},e)),this._clearCache()}getDefinitions(){return this._compiledDefinitions||this._compile(),this._compiledDefinitions}getDefinition(t){let e;return e="string"==typeof t?t:t.is&&(t.is("$text")||t.is("$textProxy"))?"$text":t.name,this.getDefinitions()[e]}isRegistered(t){return!!this.getDefinition(t)}isBlock(t){const e=this.getDefinition(t);return!(!e||!e.isBlock)}isLimit(t){const e=this.getDefinition(t);return!!e&&!(!e.isLimit&&!e.isObject)}isObject(t){const e=this.getDefinition(t);return!!e&&!!(e.isObject||e.isLimit&&e.isSelectable&&e.isContent)}isInline(t){const e=this.getDefinition(t);return!(!e||!e.isInline)}isSelectable(t){const e=this.getDefinition(t);return!!e&&!(!e.isSelectable&&!e.isObject)}isContent(t){const e=this.getDefinition(t);return!!e&&!(!e.isContent&&!e.isObject)}checkChild(t,e){return!!e&&this._checkContextMatch(e,t)}checkAttribute(t,e){const n=this.getDefinition(t.last);return!!n&&n.allowAttributes.includes(e)}checkMerge(t,e=null){if(t instanceof Qa){const e=t.nodeBefore,n=t.nodeAfter;if(!(e instanceof Za))throw new s("schema-check-merge-no-element-before",this);if(!(n instanceof Za))throw new s("schema-check-merge-no-element-after",this);return this.checkMerge(e,n)}for(const n of e.getChildren())if(!this.checkChild(t,n))return!1;return!0}addChildCheck(t){this.on("checkChild",((e,[n,o])=>{if(!o)return;const i=t(n,o);"boolean"==typeof i&&(e.stop(),e.return=i)}),{priority:"high"})}addAttributeCheck(t){this.on("checkAttribute",((e,[n,o])=>{const i=t(n,o);"boolean"==typeof i&&(e.stop(),e.return=i)}),{priority:"high"})}setAttributeProperties(t,e){this._attributeProperties[t]=Object.assign(this.getAttributeProperties(t),e)}getAttributeProperties(t){return this._attributeProperties[t]||{}}getLimitElement(t){let e;if(t instanceof Qa)e=t.parent;else{e=(t instanceof nc?[t]:Array.from(t.getRanges())).reduce(((t,e)=>{const n=e.getCommonAncestor();return t?t.getCommonAncestor(n,{includeSelf:!0}):n}),null)}for(;!this.isLimit(e)&&e.parent;)e=e.parent;return e}checkAttributeInSelection(t,e){if(t.isCollapsed){const n=[...t.getFirstPosition().getAncestors(),new $a("",t.getAttributes())];return this.checkAttribute(n,e)}{const n=t.getRanges();for(const t of n)for(const n of t)if(this.checkAttribute(n.item,e))return!0}return!1}*getValidRanges(t,e){t=function*(t){for(const e of t)yield*e.getMinimalFlatRanges()}(t);for(const n of t)yield*this._getValidRangesForRange(n,e)}getNearestSelectionRange(t,e="both"){if(this.checkChild(t,"$text"))return new nc(t);let n,o;const i=t.getAncestors().reverse().find((t=>this.isLimit(t)))||t.root;"both"!=e&&"backward"!=e||(n=new Ja({boundaries:nc._createIn(i),startPosition:t,direction:"backward"})),"both"!=e&&"forward"!=e||(o=new Ja({boundaries:nc._createIn(i),startPosition:t}));for(const t of function*(t,e){let n=!1;for(;!n;){if(n=!0,t){const e=t.next();e.done||(n=!1,yield{walker:t,value:e.value})}if(e){const t=e.next();t.done||(n=!1,yield{walker:e,value:t.value})}}}(n,o)){const e=t.walker==n?"elementEnd":"elementStart",o=t.value;if(o.type==e&&this.isObject(o.item))return nc._createOn(o.item);if(this.checkChild(o.nextPosition,"$text"))return new nc(o.nextPosition)}return null}findAllowedParent(t,e){let n=t.parent;for(;n;){if(this.checkChild(n,e))return n;if(this.isLimit(n))return null;n=n.parent}return null}removeDisallowedAttributes(t,e){for(const n of t)if(n.is("$text"))rl(this,n,e);else{const t=nc._createIn(n).getPositions();for(const n of t){rl(this,n.nodeBefore||n.parent,e)}}}createContext(t){return new $c(t)}_clearCache(){this._compiledDefinitions=null}_compile(){const t={},e=this._sourceDefinitions,n=Object.keys(e);for(const o of n)t[o]=Gc(e[o],o);for(const e of n)Kc(t,e);for(const e of n)Zc(t,e);for(const e of n)Jc(t,e);for(const e of n)Yc(t,e),Qc(t,e);for(const e of n)Xc(t,e),tl(t,e),el(t,e);this._compiledDefinitions=t}_checkContextMatch(t,e,n=e.length-1){const o=e.getItem(n);if(t.allowIn.includes(o.name)){if(0==n)return!0;{const t=this.getDefinition(o);return this._checkContextMatch(t,e,n-1)}}return!1}*_getValidRangesForRange(t,e){let n=t.start,o=t.start;for(const i of t.getItems({shallow:!0}))i.is("element")&&(yield*this._getValidRangesForRange(nc._createIn(i),e)),this.checkAttribute(i,e)||(n.isEqual(o)||(yield new nc(n,o)),n=Qa._createAfter(i)),o=Qa._createAfter(i);n.isEqual(o)||(yield new nc(n,o))}}he(Uc,se);class $c{constructor(t){if(t instanceof $c)return t;"string"==typeof t?t=[t]:Array.isArray(t)||(t=t.getAncestors({includeSelf:!0})),this._items=t.map(il)}get length(){return this._items.length}get last(){return this._items[this._items.length-1]}[Symbol.iterator](){return this._items[Symbol.iterator]()}push(t){const e=new $c([t]);return e._items=[...this._items,...e._items],e}getItem(t){return this._items[t]}*getNames(){yield*this._items.map((t=>t.name))}endsWith(t){return Array.from(this.getNames()).join(" ").endsWith(t)}startsWith(t){return Array.from(this.getNames()).join(" ").startsWith(t)}}function Gc(t,e){const n={name:e,allowIn:[],allowContentOf:[],allowWhere:[],allowAttributes:[],allowAttributesOf:[],allowChildren:[],inheritTypesFrom:[]};return function(t,e){for(const n of t){const t=Object.keys(n).filter((t=>t.startsWith("is")));for(const o of t)e[o]=n[o]}}(t,n),nl(t,n,"allowIn"),nl(t,n,"allowContentOf"),nl(t,n,"allowWhere"),nl(t,n,"allowAttributes"),nl(t,n,"allowAttributesOf"),nl(t,n,"allowChildren"),nl(t,n,"inheritTypesFrom"),function(t,e){for(const n of t){const t=n.inheritAllFrom;t&&(e.allowContentOf.push(t),e.allowWhere.push(t),e.allowAttributesOf.push(t),e.inheritTypesFrom.push(t))}}(t,n),n}function Kc(t,e){const n=t[e];for(const o of n.allowChildren){const n=t[o];n&&n.allowIn.push(e)}n.allowChildren.length=0}function Zc(t,e){for(const n of t[e].allowContentOf)if(t[n]){ol(t,n).forEach((t=>{t.allowIn.push(e)}))}delete t[e].allowContentOf}function Jc(t,e){for(const n of t[e].allowWhere){const o=t[n];if(o){const n=o.allowIn;t[e].allowIn.push(...n)}}delete t[e].allowWhere}function Yc(t,e){for(const n of t[e].allowAttributesOf){const o=t[n];if(o){const n=o.allowAttributes;t[e].allowAttributes.push(...n)}}delete t[e].allowAttributesOf}function Qc(t,e){const n=t[e];for(const e of n.inheritTypesFrom){const o=t[e];if(o){const t=Object.keys(o).filter((t=>t.startsWith("is")));for(const e of t)e in n||(n[e]=o[e])}}delete n.inheritTypesFrom}function Xc(t,e){const n=t[e],o=n.allowIn.filter((e=>t[e]));n.allowIn=Array.from(new Set(o))}function tl(t,e){const n=t[e];for(const o of n.allowIn){t[o].allowChildren.push(e)}}function el(t,e){const n=t[e];n.allowAttributes=Array.from(new Set(n.allowAttributes))}function nl(t,e,n){for(const o of t)"string"==typeof o[n]?e[n].push(o[n]):Array.isArray(o[n])&&e[n].push(...o[n])}function ol(t,e){const n=t[e];return(o=t,Object.keys(o).map((t=>o[t]))).filter((t=>t.allowIn.includes(n.name)));var o}function il(t){return"string"==typeof t||t.is("documentFragment")?{name:"string"==typeof t?t:"$documentFragment",*getAttributeKeys(){},getAttribute(){}}:{name:t.is("element")?t.name:"$text",*getAttributeKeys(){yield*t.getAttributeKeys()},getAttribute:e=>t.getAttribute(e)}}function rl(t,e,n){for(const o of e.getAttributeKeys())t.checkAttribute(e,o)||n.removeAttribute(o,e)}class sl{constructor(t={}){this._splitParts=new Map,this._cursorParents=new Map,this._modelCursor=null,this.conversionApi=Object.assign({},t),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)}convert(t,e,n=["$root"]){this.fire("viewCleanup",t),this._modelCursor=function(t,e){let n;for(const o of new $c(t)){const t={};for(const e of o.getAttributeKeys())t[e]=o.getAttribute(e);const i=e.createElement(o.name,t);n&&e.append(i,n),n=Qa._createAt(i,0)}return n}(n,e),this.conversionApi.writer=e,this.conversionApi.consumable=Wc.createFrom(t),this.conversionApi.store={};const{modelRange:o}=this._convertItem(t,this._modelCursor),i=e.createDocumentFragment();if(o){this._removeEmptyElements();for(const t of Array.from(this._modelCursor.parent.getChildren()))e.append(t,i);i.markers=function(t,e){const n=new Set,o=new Map,i=nc._createIn(t).getItems();for(const t of i)"$marker"==t.name&&n.add(t);for(const t of n){const n=t.getAttribute("data-name"),i=e.createPositionBefore(t);o.has(n)?o.get(n).end=i.clone():o.set(n,new nc(i.clone())),e.remove(t)}return o}(i,e)}return this._modelCursor=null,this._splitParts.clear(),this._cursorParents.clear(),this.conversionApi.writer=null,this.conversionApi.store=null,i}_convertItem(t,e){const n=Object.assign({viewItem:t,modelCursor:e,modelRange:null});if(t.is("element")?this.fire("element:"+t.name,n,this.conversionApi):t.is("$text")?this.fire("text",n,this.conversionApi):this.fire("documentFragment",n,this.conversionApi),n.modelRange&&!(n.modelRange instanceof nc))throw new s("view-conversion-dispatcher-incorrect-result",this);return{modelRange:n.modelRange,modelCursor:n.modelCursor}}_convertChildren(t,e){let n=e.is("position")?e:Qa._createAt(e,0);const o=new nc(n);for(const e of Array.from(t.getChildren())){const t=this._convertItem(e,n);t.modelRange instanceof nc&&(o.end=t.modelRange.end,n=t.modelCursor)}return{modelRange:o,modelCursor:n}}_safeInsert(t,e){const n=this._splitToAllowedParent(t,e);return!!n&&(this.conversionApi.writer.insert(t,n.position),!0)}_updateConversionResult(t,e){const n=this._getSplitParts(t),o=this.conversionApi.writer;e.modelRange||(e.modelRange=o.createRange(o.createPositionBefore(t),o.createPositionAfter(n[n.length-1])));const i=this._cursorParents.get(t);e.modelCursor=i?o.createPositionAt(i,0):e.modelRange.end}_splitToAllowedParent(t,e){const{schema:n,writer:o}=this.conversionApi;let i=n.findAllowedParent(e,t);if(i){if(i===e.parent)return{position:e};this._modelCursor.parent.getAncestors().includes(i)&&(i=null)}if(!i)return Ic(e,t,n)?{position:Rc(e,o)}:null;const r=this.conversionApi.writer.split(e,i),s=[];for(const t of r.range.getWalker())if("elementEnd"==t.type)s.push(t.item);else{const e=s.pop(),n=t.item;this._registerSplitPair(e,n)}const a=r.range.end.parent;return this._cursorParents.set(t,a),{position:r.position,cursorParent:a}}_registerSplitPair(t,e){this._splitParts.has(t)||this._splitParts.set(t,[t]);const n=this._splitParts.get(t);this._splitParts.set(e,n),n.push(e)}_getSplitParts(t){let e;return e=this._splitParts.has(t)?this._splitParts.get(t):[t],e}_removeEmptyElements(){let t=!1;for(const e of this._splitParts.keys())e.isEmpty&&(this.conversionApi.writer.remove(e),this._splitParts.delete(e),t=!0);t&&this._removeEmptyElements()}}he(sl,g);class al{getHtml(t){const e=document.implementation.createHTMLDocument("").createElement("div");return e.appendChild(t),e.innerHTML}}class cl{constructor(t){this.domParser=new DOMParser,this.domConverter=new Cs(t,{renderingMode:"data"}),this.htmlWriter=new al}toData(t){const e=this.domConverter.viewToDom(t,document);return this.htmlWriter.getHtml(e)}toView(t){const e=this._toDom(t);return this.domConverter.domToView(e)}registerRawContentMatcher(t){this.domConverter.registerRawContentMatcher(t)}useFillerType(t){this.domConverter.blockFillerMode="marked"==t?"markedNbsp":"nbsp"}_toDom(t){t.match(/<(?:html|body|head|meta)(?:\s[^>]*)?>/i)||(t=`${t}`);const e=this.domParser.parseFromString(t,"text/html"),n=e.createDocumentFragment(),o=e.body.childNodes;for(;o.length>0;)n.appendChild(o[0]);return n}}class ll{constructor(t,e){this.model=t,this.mapper=new oc,this.downcastDispatcher=new sc({mapper:this.mapper,schema:t.schema}),this.downcastDispatcher.on("insert:$text",((t,e,n)=>{if(!n.consumable.consume(e.item,"insert"))return;const o=n.writer,i=n.mapper.toViewPosition(e.range.start),r=o.createText(e.item.data);o.insert(i,r)}),{priority:"lowest"}),this.upcastDispatcher=new sl({schema:t.schema}),this.viewDocument=new Xi(e),this.stylesProcessor=e,this.htmlProcessor=new cl(this.viewDocument),this.processor=this.htmlProcessor,this._viewWriter=new vr(this.viewDocument),this.upcastDispatcher.on("text",((t,e,{schema:n,consumable:o,writer:i})=>{let r=e.modelCursor;if(!o.test(e.viewItem))return;if(!n.checkChild(r,"$text")){if(!Ic(r,"$text",n))return;r=Rc(r,i)}o.consume(e.viewItem);const s=i.createText(e.viewItem.data);i.insert(s,r),e.modelRange=i.createRange(r,r.getShiftedBy(s.offsetSize)),e.modelCursor=e.modelRange.end}),{priority:"lowest"}),this.upcastDispatcher.on("element",((t,e,n)=>{if(!e.modelRange&&n.consumable.consume(e.viewItem,{name:!0})){const{modelRange:t,modelCursor:o}=n.convertChildren(e.viewItem,e.modelCursor);e.modelRange=t,e.modelCursor=o}}),{priority:"lowest"}),this.upcastDispatcher.on("documentFragment",((t,e,n)=>{if(!e.modelRange&&n.consumable.consume(e.viewItem,{name:!0})){const{modelRange:t,modelCursor:o}=n.convertChildren(e.viewItem,e.modelCursor);e.modelRange=t,e.modelCursor=o}}),{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},Pc)}),{priority:"lowest"})}get(t={}){const{rootName:e="main",trim:n="empty"}=t;if(!this._checkIfRootsExists([e]))throw new s("datacontroller-get-non-existent-root",this);const o=this.model.document.getRoot(e);return"empty"!==n||this.model.hasContent(o,{ignoreWhitespaces:!0})?this.stringify(o,t):""}stringify(t,e={}){const n=this.toView(t,e);return this.processor.toData(n)}toView(t,e={}){const n=this.viewDocument,o=this._viewWriter;this.mapper.clearBindings();const i=nc._createIn(t),r=new Ar(n);this.mapper.bindElements(t,r),this.downcastDispatcher.conversionApi.options=e,this.downcastDispatcher.convertInsert(i,o);const s=t.is("documentFragment")?Array.from(t.markers):function(t){const e=[],n=t.root.document;if(!n)return[];const o=nc._createIn(t);for(const t of n.model.markers){const n=t.getRange(),i=n.isCollapsed,r=n.start.isEqual(o.start)||n.end.isEqual(o.end);if(i&&r)e.push([t.name,n]);else{const i=o.getIntersection(n);i&&e.push([t.name,i])}}return e.sort((([t,e],[n,o])=>{if("after"!==e.end.compareWith(o.start))return 1;if("before"!==e.start.compareWith(o.end))return-1;switch(e.start.compareWith(o.start)){case"before":return 1;case"after":return-1;default:switch(e.end.compareWith(o.end)){case"before":return 1;case"after":return-1;default:return n.localeCompare(t)}}}))}(t);for(const[t,e]of s)this.downcastDispatcher.convertMarkerAdd(t,e,o);return delete this.downcastDispatcher.conversionApi.options,r}init(t){if(this.model.document.version)throw new s("datacontroller-init-document-not-empty",this);let e={};if("string"==typeof t?e.main=t:e=t,!this._checkIfRootsExists(Object.keys(e)))throw new s("datacontroller-init-non-existent-root",this);return this.model.enqueueChange({isUndoable:!1},(t=>{for(const n of Object.keys(e)){const o=this.model.document.getRoot(n);t.insert(this.parse(e[n],o),o,0)}})),Promise.resolve()}set(t,e={}){let n={};if("string"==typeof t?n.main=t:n=t,!this._checkIfRootsExists(Object.keys(n)))throw new s("datacontroller-set-non-existent-root",this);this.model.enqueueChange(e.batchType||{},(t=>{t.setSelection(null),t.removeSelectionAttribute(this.model.document.selection.getAttributeKeys());for(const e of Object.keys(n)){const o=this.model.document.getRoot(e);t.remove(t.createRangeIn(o)),t.insert(this.parse(n[e],o),o,0)}}))}parse(t,e="$root"){const n=this.processor.toView(t);return this.toModel(n,e)}toModel(t,e="$root"){return this.model.change((n=>this.upcastDispatcher.convert(t,n,e)))}addStyleProcessorRules(t){t(this.stylesProcessor)}registerRawContentMatcher(t){this.processor&&this.processor!==this.htmlProcessor&&this.processor.registerRawContentMatcher(t),this.htmlProcessor.registerRawContentMatcher(t)}destroy(){this.stopListening()}_checkIfRootsExists(t){for(const e of t)if(!this.model.document.getRootNames().includes(e))return!1;return!0}}he(ll,se);class dl{constructor(t,e){this._helpers=new Map,this._downcast=To(t),this._createConversionHelpers({name:"downcast",dispatchers:this._downcast,isDowncast:!0}),this._upcast=To(e),this._createConversionHelpers({name:"upcast",dispatchers:this._upcast,isDowncast:!1})}addAlias(t,e){const n=this._downcast.includes(e);if(!this._upcast.includes(e)&&!n)throw new s("conversion-add-alias-dispatcher-not-registered",this);this._createConversionHelpers({name:t,dispatchers:[e],isDowncast:n})}for(t){if(!this._helpers.has(t))throw new s("conversion-for-unknown-group",this);return this._helpers.get(t)}elementToElement(t){this.for("downcast").elementToElement(t);for(const{model:e,view:n}of ul(t))this.for("upcast").elementToElement({model:e,view:n,converterPriority:t.converterPriority})}attributeToElement(t){this.for("downcast").attributeToElement(t);for(const{model:e,view:n}of ul(t))this.for("upcast").elementToAttribute({view:n,model:e,converterPriority:t.converterPriority})}attributeToAttribute(t){this.for("downcast").attributeToAttribute(t);for(const{model:e,view:n}of ul(t))this.for("upcast").attributeToAttribute({view:n,model:e})}_createConversionHelpers({name:t,dispatchers:e,isDowncast:n}){if(this._helpers.has(t))throw new s("conversion-group-exists",this);const o=n?new yc(e):new zc(e);this._helpers.set(t,o)}}function*ul(t){if(t.model.values)for(const e of t.model.values){const n={key:t.model.key,value:e},o=t.view[e],i=t.upcastAlso?t.upcastAlso[e]:void 0;yield*hl(n,o,i)}else yield*hl(t.model,t.view,t.upcastAlso)}function*hl(t,e,n){if(yield{model:t,view:e},n)for(const e of To(n))yield{model:t,view:e}}class pl{constructor(t={}){"string"==typeof t&&(t="transparent"===t?{isUndoable:!1}:{},a("batch-constructor-deprecated-string-type"));const{isUndoable:e=!0,isLocal:n=!0,isUndo:o=!1,isTyping:i=!1}=t;this.operations=[],this.isUndoable=e,this.isLocal=n,this.isUndo=o,this.isTyping=i}get type(){return a("batch-type-deprecated"),"default"}get baseVersion(){for(const t of this.operations)if(null!==t.baseVersion)return t.baseVersion;return null}addOperation(t){return t.batch=this,this.operations.push(t),t}}class ml{constructor(t){this.baseVersion=t,this.isDocumentOperation=null!==this.baseVersion,this.batch=null}_validate(){}toJSON(){const t=Object.assign({},this);return t.__className=this.constructor.className,delete t.batch,delete t.isDocumentOperation,t}static get className(){return"Operation"}static fromJSON(t){return new this(t.baseVersion)}}class gl{constructor(t){this.markers=new Map,this._children=new Ka,t&&this._insertChild(0,t)}[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(t){return"documentFragment"===t||"model:documentFragment"===t}getChild(t){return this._children.getNode(t)}getChildren(){return this._children[Symbol.iterator]()}getChildIndex(t){return this._children.getNodeIndex(t)}getChildStartOffset(t){return this._children.getNodeStartOffset(t)}getPath(){return[]}getNodeByPath(t){let e=this;for(const n of t)e=e.getChild(e.offsetToIndex(n));return e}offsetToIndex(t){return this._children.offsetToIndex(t)}toJSON(){const t=[];for(const e of this._children)t.push(e.toJSON());return t}static fromJSON(t){const e=[];for(const n of t)n.name?e.push(Za.fromJSON(n)):e.push($a.fromJSON(n));return new gl(e)}_appendChild(t){this._insertChild(this.childCount,t)}_insertChild(t,e){const n=function(t){if("string"==typeof t)return[new $a(t)];Do(t)||(t=[t]);return Array.from(t).map((t=>"string"==typeof t?new $a(t):t instanceof Ga?new $a(t.data,t.getAttributes()):t))}(e);for(const t of n)null!==t.parent&&t._remove(),t.parent=this;this._children._insertNodes(t,n)}_removeChildren(t,e=1){const n=this._children._removeNodes(t,e);for(const t of n)t.parent=null;return n}}function fl(t,e){const n=(e=wl(e)).reduce(((t,e)=>t+e.offsetSize),0),o=t.parent;Cl(t);const i=t.index;return o._insertChild(i,e),_l(o,i+e.length),_l(o,i),new nc(t,t.getShiftedBy(n))}function bl(t){if(!t.isFlat)throw new s("operation-utils-remove-range-not-flat",this);const e=t.start.parent;Cl(t.start),Cl(t.end);const n=e._removeChildren(t.start.index,t.end.index-t.start.index);return _l(e,t.start.index),n}function kl(t,e){if(!t.isFlat)throw new s("operation-utils-move-range-not-flat",this);const n=bl(t);return fl(e=e._getTransformedByDeletion(t.start,t.end.offset-t.start.offset),n)}function wl(t){const e=[];t instanceof Array||(t=[t]);for(let n=0;nt.maxOffset)throw new s("move-operation-nodes-do-not-exist",this);if(t===e&&n=n&&this.targetPosition.path[t]t._clone(!0)))),e=new Dl(this.position,t,this.baseVersion);return e.shouldReceiveAttributes=this.shouldReceiveAttributes,e}getReversed(){const t=this.position.root.document.graveyard,e=new Qa(t,[0]);return new El(this.position,this.nodes.maxOffset,e,this.baseVersion+1)}_validate(){const t=this.position.parent;if(!t||t.maxOffsett._clone(!0)))),fl(this.position,t)}toJSON(){const t=super.toJSON();return t.position=this.position.toJSON(),t.nodes=this.nodes.toJSON(),t}static get className(){return"InsertOperation"}static fromJSON(t,e){const n=[];for(const e of t.nodes)e.name?n.push(Za.fromJSON(e)):n.push($a.fromJSON(e));const o=new Dl(Qa.fromJSON(t.position,e),n,t.baseVersion);return o.shouldReceiveAttributes=t.shouldReceiveAttributes,o}}class Sl extends ml{constructor(t,e,n,o,i,r){super(r),this.name=t,this.oldRange=e?e.clone():null,this.newRange=n?n.clone():null,this.affectsData=i,this._markers=o}get type(){return"marker"}clone(){return new Sl(this.name,this.oldRange,this.newRange,this._markers,this.affectsData,this.baseVersion)}getReversed(){return new Sl(this.name,this.newRange,this.oldRange,this._markers,this.affectsData,this.baseVersion+1)}_execute(){const t=this.newRange?"_set":"_remove";this._markers[t](this.name,this.newRange,!0,this.affectsData)}toJSON(){const t=super.toJSON();return this.oldRange&&(t.oldRange=this.oldRange.toJSON()),this.newRange&&(t.newRange=this.newRange.toJSON()),delete t._markers,t}static get className(){return"MarkerOperation"}static fromJSON(t,e){return new Sl(t.name,t.oldRange?nc.fromJSON(t.oldRange,e):null,t.newRange?nc.fromJSON(t.newRange,e):null,e.model.markers,t.affectsData,t.baseVersion)}}class Bl extends ml{constructor(t,e,n,o){super(o),this.position=t,this.position.stickiness="toNext",this.oldName=e,this.newName=n}get type(){return"rename"}clone(){return new Bl(this.position.clone(),this.oldName,this.newName,this.baseVersion)}getReversed(){return new Bl(this.position.clone(),this.newName,this.oldName,this.baseVersion+1)}_validate(){const t=this.position.nodeAfter;if(!(t instanceof Za))throw new s("rename-operation-wrong-position",this);if(t.name!==this.oldName)throw new s("rename-operation-wrong-name",this)}_execute(){this.position.nodeAfter.name=this.newName}toJSON(){const t=super.toJSON();return t.position=this.position.toJSON(),t}static get className(){return"RenameOperation"}static fromJSON(t,e){return new Bl(Qa.fromJSON(t.position,e),t.oldName,t.newName,t.baseVersion)}}class Tl extends ml{constructor(t,e,n,o,i){super(i),this.root=t,this.key=e,this.oldValue=n,this.newValue=o}get type(){return null===this.oldValue?"addRootAttribute":null===this.newValue?"removeRootAttribute":"changeRootAttribute"}clone(){return new Tl(this.root,this.key,this.oldValue,this.newValue,this.baseVersion)}getReversed(){return new Tl(this.root,this.key,this.newValue,this.oldValue,this.baseVersion+1)}_validate(){if(this.root!=this.root.root||this.root.is("documentFragment"))throw new s("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 s("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 s("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 t=super.toJSON();return t.root=this.root.toJSON(),t}static get className(){return"RootAttributeOperation"}static fromJSON(t,e){if(!e.getRoot(t.root))throw new s("rootattribute-operation-fromjson-no-root",this,{rootName:t.root});return new Tl(e.getRoot(t.root),t.key,t.oldValue,t.newValue,t.baseVersion)}}class Pl extends ml{constructor(t,e,n,o,i){super(i),this.sourcePosition=t.clone(),this.sourcePosition.stickiness="toPrevious",this.howMany=e,this.targetPosition=n.clone(),this.targetPosition.stickiness="toNext",this.graveyardPosition=o.clone()}get type(){return"merge"}get deletionPosition(){return new Qa(this.sourcePosition.root,this.sourcePosition.path.slice(0,-1))}get movedRange(){const t=this.sourcePosition.getShiftedBy(Number.POSITIVE_INFINITY);return new nc(this.sourcePosition,t)}clone(){return new this.constructor(this.sourcePosition,this.howMany,this.targetPosition,this.graveyardPosition,this.baseVersion)}getReversed(){const t=this.targetPosition._getTransformedByMergeOperation(this),e=this.sourcePosition.path.slice(0,-1),n=new Qa(this.sourcePosition.root,e)._getTransformedByMergeOperation(this);return new Il(t,this.howMany,n,this.graveyardPosition,this.baseVersion+1)}_validate(){const t=this.sourcePosition.parent,e=this.targetPosition.parent;if(!t.parent)throw new s("merge-operation-source-position-invalid",this);if(!e.parent)throw new s("merge-operation-target-position-invalid",this);if(this.howMany!=t.maxOffset)throw new s("merge-operation-how-many-invalid",this)}_execute(){const t=this.sourcePosition.parent;kl(nc._createIn(t),this.targetPosition),kl(nc._createOn(t),this.graveyardPosition)}toJSON(){const t=super.toJSON();return t.sourcePosition=t.sourcePosition.toJSON(),t.targetPosition=t.targetPosition.toJSON(),t.graveyardPosition=t.graveyardPosition.toJSON(),t}static get className(){return"MergeOperation"}static fromJSON(t,e){const n=Qa.fromJSON(t.sourcePosition,e),o=Qa.fromJSON(t.targetPosition,e),i=Qa.fromJSON(t.graveyardPosition,e);return new this(n,t.howMany,o,i,t.baseVersion)}}class Il extends ml{constructor(t,e,n,o,i){super(i),this.splitPosition=t.clone(),this.splitPosition.stickiness="toNext",this.howMany=e,this.insertionPosition=n,this.graveyardPosition=o?o.clone():null,this.graveyardPosition&&(this.graveyardPosition.stickiness="toNext")}get type(){return"split"}get moveTargetPosition(){const t=this.insertionPosition.path.slice();return t.push(0),new Qa(this.insertionPosition.root,t)}get movedRange(){const t=this.splitPosition.getShiftedBy(Number.POSITIVE_INFINITY);return new nc(this.splitPosition,t)}clone(){return new this.constructor(this.splitPosition,this.howMany,this.insertionPosition,this.graveyardPosition,this.baseVersion)}getReversed(){const t=this.splitPosition.root.document.graveyard,e=new Qa(t,[0]);return new Pl(this.moveTargetPosition,this.howMany,this.splitPosition,e,this.baseVersion+1)}_validate(){const t=this.splitPosition.parent,e=this.splitPosition.offset;if(!t||t.maxOffset{for(const e of t.getAttributeKeys())this.removeAttribute(e,t)};if(t instanceof nc)for(const n of t.getItems())e(n);else e(t)}move(t,e,n){if(this._assertWriterUsedCorrectly(),!(t instanceof nc))throw new s("writer-move-invalid-range",this);if(!t.isFlat)throw new s("writer-move-range-not-flat",this);const o=Qa._createAt(e,n);if(o.isEqual(t.start))return;if(this._addOperationForAffectedMarkers("move",t),!Vl(t.root,o.root))throw new s("writer-move-different-document",this);const i=t.root.document?t.root.document.version:null,r=new El(t.start,t.end.offset-t.start.offset,o,i);this.batch.addOperation(r),this.model.applyOperation(r)}remove(t){this._assertWriterUsedCorrectly();const e=(t instanceof nc?t:nc._createOn(t)).getMinimalFlatRanges().reverse();for(const t of e)this._addOperationForAffectedMarkers("move",t),Ml(t.start,t.end.offset-t.start.offset,this.batch,this.model)}merge(t){this._assertWriterUsedCorrectly();const e=t.nodeBefore,n=t.nodeAfter;if(this._addOperationForAffectedMarkers("merge",t),!(e instanceof Za))throw new s("writer-merge-no-element-before",this);if(!(n instanceof Za))throw new s("writer-merge-no-element-after",this);t.root.document?this._merge(t):this._mergeDetached(t)}createPositionFromPath(t,e,n){return this.model.createPositionFromPath(t,e,n)}createPositionAt(t,e){return this.model.createPositionAt(t,e)}createPositionAfter(t){return this.model.createPositionAfter(t)}createPositionBefore(t){return this.model.createPositionBefore(t)}createRange(t,e){return this.model.createRange(t,e)}createRangeIn(t){return this.model.createRangeIn(t)}createRangeOn(t){return this.model.createRangeOn(t)}createSelection(t,e,n){return this.model.createSelection(t,e,n)}_mergeDetached(t){const e=t.nodeBefore,n=t.nodeAfter;this.move(nc._createIn(n),Qa._createAt(e,"end")),this.remove(n)}_merge(t){const e=Qa._createAt(t.nodeBefore,"end"),n=Qa._createAt(t.nodeAfter,0),o=t.root.document.graveyard,i=new Qa(o,[0]),r=t.root.document.version,s=new Pl(n,t.nodeAfter.maxOffset,e,i,r);this.batch.addOperation(s),this.model.applyOperation(s)}rename(t,e){if(this._assertWriterUsedCorrectly(),!(t instanceof Za))throw new s("writer-rename-not-element-instance",this);const n=t.root.document?t.root.document.version:null,o=new Bl(Qa._createBefore(t),t.name,e,n);this.batch.addOperation(o),this.model.applyOperation(o)}split(t,e){this._assertWriterUsedCorrectly();let n,o,i=t.parent;if(!i.parent)throw new s("writer-split-element-no-parent",this);if(e||(e=i.parent),!t.parent.getAncestors({includeSelf:!0}).includes(e))throw new s("writer-split-invalid-limit-element",this);do{const e=i.root.document?i.root.document.version:null,r=i.maxOffset-t.offset,s=Il.getInsertionPosition(t),a=new Il(t,r,s,null,e);this.batch.addOperation(a),this.model.applyOperation(a),n||o||(n=i,o=t.parent.nextSibling),i=(t=this.createPositionAfter(t.parent)).parent}while(i!==e);return{position:t,range:new nc(Qa._createAt(n,"end"),Qa._createAt(o,0))}}wrap(t,e){if(this._assertWriterUsedCorrectly(),!t.isFlat)throw new s("writer-wrap-range-not-flat",this);const n=e instanceof Za?e:new Za(e);if(n.childCount>0)throw new s("writer-wrap-element-not-empty",this);if(null!==n.parent)throw new s("writer-wrap-element-attached",this);this.insert(n,t.start);const o=new nc(t.start.getShiftedBy(1),t.end.getShiftedBy(1));this.move(o,Qa._createAt(n,0))}unwrap(t){if(this._assertWriterUsedCorrectly(),null===t.parent)throw new s("writer-unwrap-element-no-parent",this);this.move(nc._createIn(t),this.createPositionAfter(t)),this.remove(t)}addMarker(t,e){if(this._assertWriterUsedCorrectly(),!e||"boolean"!=typeof e.usingOperation)throw new s("writer-addmarker-no-usingoperation",this);const n=e.usingOperation,o=e.range,i=void 0!==e.affectsData&&e.affectsData;if(this.model.markers.has(t))throw new s("writer-addmarker-marker-exists",this);if(!o)throw new s("writer-addmarker-no-range",this);return n?(Ol(this,t,null,o,i),this.model.markers.get(t)):this.model.markers._set(t,o,n,i)}updateMarker(t,e){this._assertWriterUsedCorrectly();const n="string"==typeof t?t:t.name,o=this.model.markers.get(n);if(!o)throw new s("writer-updatemarker-marker-not-exists",this);if(!e)return void this.model.markers._refresh(o);const i="boolean"==typeof e.usingOperation,r="boolean"==typeof e.affectsData,a=r?e.affectsData:o.affectsData;if(!i&&!e.range&&!r)throw new s("writer-updatemarker-wrong-options",this);const c=o.getRange(),l=e.range?e.range:c;i&&e.usingOperation!==o.managedUsingOperations?e.usingOperation?Ol(this,n,null,l,a):(Ol(this,n,c,null,a),this.model.markers._set(n,l,void 0,a)):o.managedUsingOperations?Ol(this,n,c,l,a):this.model.markers._set(n,l,void 0,a)}removeMarker(t){this._assertWriterUsedCorrectly();const e="string"==typeof t?t:t.name;if(!this.model.markers.has(e))throw new s("writer-removemarker-no-marker",this);const n=this.model.markers.get(e);if(!n.managedUsingOperations)return void this.model.markers._remove(e);Ol(this,e,n.getRange(),null,n.affectsData)}setSelection(t,e,n){this._assertWriterUsedCorrectly(),this.model.document.selection._setTo(t,e,n)}setSelectionFocus(t,e){this._assertWriterUsedCorrectly(),this.model.document.selection._setFocus(t,e)}setSelectionAttribute(t,e){if(this._assertWriterUsedCorrectly(),"string"==typeof t)this._setSelectionAttribute(t,e);else for(const[e,n]of qo(t))this._setSelectionAttribute(e,n)}removeSelectionAttribute(t){if(this._assertWriterUsedCorrectly(),"string"==typeof t)this._removeSelectionAttribute(t);else for(const e of t)this._removeSelectionAttribute(e)}overrideSelectionGravity(){return this.model.document.selection._overrideGravity()}restoreSelectionGravity(t){this.model.document.selection._restoreGravity(t)}_setSelectionAttribute(t,e){const n=this.model.document.selection;if(n.isCollapsed&&n.anchor.parent.isEmpty){const o=wc._getStoreAttributeKey(t);this.setAttribute(o,e,n.anchor.parent)}n._setAttribute(t,e)}_removeSelectionAttribute(t){const e=this.model.document.selection;if(e.isCollapsed&&e.anchor.parent.isEmpty){const n=wc._getStoreAttributeKey(t);this.removeAttribute(n,e.anchor.parent)}e._removeAttribute(t)}_assertWriterUsedCorrectly(){if(this.model._currentWriter!==this)throw new s("writer-incorrect-use",this)}_addOperationForAffectedMarkers(t,e){for(const n of this.model.markers){if(!n.managedUsingOperations)continue;const o=n.getRange();let i=!1;if("move"===t)i=e.containsPosition(o.start)||e.start.isEqual(o.start)||e.containsPosition(o.end)||e.end.isEqual(o.end);else{const t=e.nodeBefore,n=e.nodeAfter,r=o.start.parent==t&&o.start.isAtEnd,s=o.end.parent==n&&0==o.end.offset,a=o.end.nodeAfter==n,c=o.start.nodeAfter==n;i=r||s||a||c}i&&this.updateMarker(n.name,{range:o})}}}function Fl(t,e,n,o){const i=t.model,r=i.document;let s,a,c,l=o.start;for(const t of o.getWalker({shallow:!0}))c=t.item.getAttribute(e),s&&a!=c&&(a!=n&&d(),l=s),s=t.nextPosition,a=c;function d(){const o=new nc(l,s),c=o.root.document?r.version:null,d=new yl(o,e,a,n,c);t.batch.addOperation(d),i.applyOperation(d)}s instanceof Qa&&s!=l&&a!=n&&d()}function Nl(t,e,n,o){const i=t.model,r=i.document,s=o.getAttribute(e);let a,c;if(s!=n){if(o.root===o){const t=o.document?r.version:null;c=new Tl(o,e,s,n,t)}else{a=new nc(Qa._createBefore(o),t.createPositionAfter(o));const i=a.root.document?r.version:null;c=new yl(a,e,s,n,i)}t.batch.addOperation(c),i.applyOperation(c)}}function Ol(t,e,n,o,i){const r=t.model,s=r.document,a=new Sl(e,n,o,r.markers,i,s.version);t.batch.addOperation(a),r.applyOperation(a)}function Ml(t,e,n,o){let i;if(t.root.document){const n=o.document,r=new Qa(n.graveyard,[0]);i=new El(t,e,r,n.version)}else i=new xl(t,e);n.addOperation(i),o.applyOperation(i)}function Vl(t,e){return t===e||t instanceof Rl&&e instanceof Rl}class Ll{constructor(t){this._markerCollection=t,this._changesInElement=new Map,this._elementSnapshots=new Map,this._changedMarkers=new Map,this._changeCount=0,this._cachedChanges=null,this._cachedChangesWithGraveyard=null}get isEmpty(){return 0==this._changesInElement.size&&0==this._changedMarkers.size}refreshItem(t){if(this._isInInsertedElement(t.parent))return;this._markRemove(t.parent,t.startOffset,t.offsetSize),this._markInsert(t.parent,t.startOffset,t.offsetSize);const e=nc._createOn(t);for(const t of this._markerCollection.getMarkersIntersectingRange(e)){const e=t.getRange();this.bufferMarkerChange(t.name,e,e,t.affectsData)}this._cachedChanges=null}bufferOperation(t){switch(t.type){case"insert":if(this._isInInsertedElement(t.position.parent))return;this._markInsert(t.position.parent,t.position.offset,t.nodes.maxOffset);break;case"addAttribute":case"removeAttribute":case"changeAttribute":for(const e of t.range.getItems({shallow:!0}))this._isInInsertedElement(e.parent)||this._markAttribute(e);break;case"remove":case"move":case"reinsert":{if(t.sourcePosition.isEqual(t.targetPosition)||t.sourcePosition.getShiftedBy(t.howMany).isEqual(t.targetPosition))return;const e=this._isInInsertedElement(t.sourcePosition.parent),n=this._isInInsertedElement(t.targetPosition.parent);e||this._markRemove(t.sourcePosition.parent,t.sourcePosition.offset,t.howMany),n||this._markInsert(t.targetPosition.parent,t.getMovedRangeStart().offset,t.howMany);break}case"rename":{if(this._isInInsertedElement(t.position.parent))return;this._markRemove(t.position.parent,t.position.offset,1),this._markInsert(t.position.parent,t.position.offset,1);const e=nc._createFromPositionAndShift(t.position,1);for(const t of this._markerCollection.getMarkersIntersectingRange(e)){const e=t.getRange();this.bufferMarkerChange(t.name,e,e,t.affectsData)}break}case"split":{const e=t.splitPosition.parent;this._isInInsertedElement(e)||this._markRemove(e,t.splitPosition.offset,t.howMany),this._isInInsertedElement(t.insertionPosition.parent)||this._markInsert(t.insertionPosition.parent,t.insertionPosition.offset,1),t.graveyardPosition&&this._markRemove(t.graveyardPosition.parent,t.graveyardPosition.offset,1);break}case"merge":{const e=t.sourcePosition.parent;this._isInInsertedElement(e.parent)||this._markRemove(e.parent,e.startOffset,1);const n=t.graveyardPosition.parent;this._markInsert(n,t.graveyardPosition.offset,1);const o=t.targetPosition.parent;this._isInInsertedElement(o)||this._markInsert(o,t.targetPosition.offset,e.maxOffset);break}}this._cachedChanges=null}bufferMarkerChange(t,e,n,o){const i=this._changedMarkers.get(t);i?(i.newRange=n,i.affectsData=o,null==i.oldRange&&null==i.newRange&&this._changedMarkers.delete(t)):this._changedMarkers.set(t,{oldRange:e,newRange:n,affectsData:o})}getMarkersToRemove(){const t=[];for(const[e,n]of this._changedMarkers)null!=n.oldRange&&t.push({name:e,range:n.oldRange});return t}getMarkersToAdd(){const t=[];for(const[e,n]of this._changedMarkers)null!=n.newRange&&t.push({name:e,range:n.newRange});return t}getChangedMarkers(){return Array.from(this._changedMarkers).map((t=>({name:t[0],data:{oldRange:t[1].oldRange,newRange:t[1].newRange}})))}hasDataChanges(){for(const[,t]of this._changedMarkers)if(t.affectsData)return!0;return this._changesInElement.size>0}getChanges(t={includeChangesInGraveyard:!1}){if(this._cachedChanges)return t.includeChangesInGraveyard?this._cachedChangesWithGraveyard.slice():this._cachedChanges.slice();let e=[];for(const t of this._changesInElement.keys()){const n=this._changesInElement.get(t).sort(((t,e)=>t.offset===e.offset?t.type!=e.type?"remove"==t.type?-1:1:0:t.offsett.position.root!=e.position.root?t.position.root.rootNamet));for(const t of e)delete t.changeCount,"attribute"==t.type&&(delete t.position,delete t.length);return this._changeCount=0,this._cachedChangesWithGraveyard=e.slice(),this._cachedChanges=e.filter(Wl),t.includeChangesInGraveyard?this._cachedChangesWithGraveyard:this._cachedChanges}reset(){this._changesInElement.clear(),this._elementSnapshots.clear(),this._changedMarkers.clear(),this._cachedChanges=null}_markInsert(t,e,n){const o={type:"insert",offset:e,howMany:n,count:this._changeCount++};this._markChange(t,o)}_markRemove(t,e,n){const o={type:"remove",offset:e,howMany:n,count:this._changeCount++};this._markChange(t,o),this._removeAllNestedChanges(t,e,n)}_markAttribute(t){const e={type:"attribute",offset:t.startOffset,howMany:t.offsetSize,count:this._changeCount++};this._markChange(t.parent,e)}_markChange(t,e){this._makeSnapshot(t);const n=this._getChangesForElement(t);this._handleChange(e,n),n.push(e);for(let t=0;tn.offset){if(o>i){const t={type:"attribute",offset:i,howMany:o-i,count:this._changeCount++};this._handleChange(t,e),e.push(t)}t.nodesToHandle=n.offset-t.offset,t.howMany=t.nodesToHandle}else t.offset>=n.offset&&t.offseti?(t.nodesToHandle=o-i,t.offset=i):t.nodesToHandle=0);if("remove"==n.type&&t.offsetn.offset){const i={type:"attribute",offset:n.offset,howMany:o-n.offset,count:this._changeCount++};this._handleChange(i,e),e.push(i),t.nodesToHandle=n.offset-t.offset,t.howMany=t.nodesToHandle}"attribute"==n.type&&(t.offset>=n.offset&&o<=i?(t.nodesToHandle=0,t.howMany=0,t.offset=0):t.offset<=n.offset&&o>=i&&(n.howMany=0))}}t.howMany=t.nodesToHandle,delete t.nodesToHandle}_getInsertDiff(t,e,n){return{type:"insert",position:Qa._createAt(t,e),name:n,length:1,changeCount:this._changeCount++}}_getRemoveDiff(t,e,n){return{type:"remove",position:Qa._createAt(t,e),name:n,length:1,changeCount:this._changeCount++}}_getAttributesDiff(t,e,n){const o=[];n=new Map(n);for(const[i,r]of e){const e=n.has(i)?n.get(i):null;e!==r&&o.push({type:"attribute",position:t.start,range:t.clone(),length:1,attributeKey:i,attributeOldValue:r,attributeNewValue:e,changeCount:this._changeCount++}),n.delete(i)}for(const[e,i]of n)o.push({type:"attribute",position:t.start,range:t.clone(),length:1,attributeKey:e,attributeOldValue:null,attributeNewValue:i,changeCount:this._changeCount++});return o}_isInInsertedElement(t){const e=t.parent;if(!e)return!1;const n=this._changesInElement.get(e),o=t.startOffset;if(n)for(const t of n)if("insert"==t.type&&o>=t.offset&&oo){for(let e=0;e=t&&o.baseVersion{const n=e[0];if(n.isDocumentOperation&&n.baseVersion!==this.version)throw new s("model-document-applyoperation-wrong-version",this,{operation:n})}),{priority:"highest"}),this.listenTo(t,"applyOperation",((t,e)=>{const n=e[0];n.isDocumentOperation&&this.differ.bufferOperation(n)}),{priority:"high"}),this.listenTo(t,"applyOperation",((t,e)=>{const n=e[0];n.isDocumentOperation&&(this.version++,this.history.addOperation(n))}),{priority:"low"}),this.listenTo(this.selection,"change",(()=>{this._hasSelectionChangedFromTheLastChangeBlock=!0})),this.listenTo(t.markers,"update",((t,e,n,o)=>{this.differ.bufferMarkerChange(e.name,n,o,e.affectsData),null===n&&e.on("change",((t,n)=>{this.differ.bufferMarkerChange(e.name,n,e.getRange(),e.affectsData)}))}))}get graveyard(){return this.getRoot(Gl)}createRoot(t="$root",e="main"){if(this.roots.get(e))throw new s("model-document-createroot-name-exists",this,{name:e});const n=new Rl(this,t,e);return this.roots.add(n),n}destroy(){this.selection.destroy(),this.stopListening()}getRoot(t="main"){return this.roots.get(t)}getRootNames(){return Array.from(this.roots,(t=>t.rootName)).filter((t=>t!=Gl))}registerPostFixer(t){this._postFixers.add(t)}toJSON(){const t=Mo(this);return t.selection="[engine.model.DocumentSelection]",t.model="[engine.model.Model]",t}_handleChangeBlock(t){this._hasDocumentChangedFromTheLastChangeBlock()&&(this._callPostFixers(t),this.selection.refresh(),this.differ.hasDataChanges()?this.fire("change:data",t.batch):this.fire("change",t.batch),this.selection.refresh(),this.differ.reset()),this._hasSelectionChangedFromTheLastChangeBlock=!1}_hasDocumentChangedFromTheLastChangeBlock(){return!this.differ.isEmpty||this._hasSelectionChangedFromTheLastChangeBlock}_getDefaultRoot(){for(const t of this.roots)if(t!==this.graveyard)return t;return this.graveyard}_getDefaultRange(){const t=this._getDefaultRoot(),e=this.model,n=e.schema,o=e.createPositionFromPath(t,[0]);return n.getNearestSelectionRange(o)||e.createRange(o)}_validateSelectionRange(t){return Zl(t.start)&&Zl(t.end)}_callPostFixers(t){let e=!1;do{for(const n of this._postFixers)if(this.selection.refresh(),e=n(t),e)break}while(e)}}function Zl(t){const e=t.textNode;if(e){const n=e.data,o=t.offset-e.startOffset;return!Ul(n,o)&&!$l(n,o)}return!0}he(Kl,g);class Jl{constructor(){this._markers=new Map}[Symbol.iterator](){return this._markers.values()}has(t){const e=t instanceof Yl?t.name:t;return this._markers.has(e)}get(t){return this._markers.get(t)||null}_set(t,e,n=!1,o=!1){const i=t instanceof Yl?t.name:t;if(i.includes(","))throw new s("markercollection-incorrect-marker-name",this);const r=this._markers.get(i);if(r){const t=r.getRange();let s=!1;return t.isEqual(e)||(r._attachLiveRange(gc.fromRange(e)),s=!0),n!=r.managedUsingOperations&&(r._managedUsingOperations=n,s=!0),"boolean"==typeof o&&o!=r.affectsData&&(r._affectsData=o,s=!0),s&&this.fire("update:"+i,r,t,e),r}const a=gc.fromRange(e),c=new Yl(i,a,n,o);return this._markers.set(i,c),this.fire("update:"+i,c,null,e),c}_remove(t){const e=t instanceof Yl?t.name:t,n=this._markers.get(e);return!!n&&(this._markers.delete(e),this.fire("update:"+e,n,n.getRange(),null),this._destroyMarker(n),!0)}_refresh(t){const e=t instanceof Yl?t.name:t,n=this._markers.get(e);if(!n)throw new s("markercollection-refresh-marker-not-exists",this);const o=n.getRange();this.fire("update:"+e,n,o,o,n.managedUsingOperations,n.affectsData)}*getMarkersAtPosition(t){for(const e of this)e.getRange().containsPosition(t)&&(yield e)}*getMarkersIntersectingRange(t){for(const e of this)null!==e.getRange().getIntersection(t)&&(yield e)}destroy(){for(const t of this._markers.values())this._destroyMarker(t);this._markers=null,this.stopListening()}*getMarkersGroup(t){for(const e of this._markers.values())e.name.startsWith(t+":")&&(yield e)}_destroyMarker(t){t.stopListening(),t._detachLiveRange()}}he(Jl,g);class Yl{constructor(t,e,n,o){this.name=t,this._liveRange=this._attachLiveRange(e),this._managedUsingOperations=n,this._affectsData=o}get managedUsingOperations(){if(!this._liveRange)throw new s("marker-destroyed",this);return this._managedUsingOperations}get affectsData(){if(!this._liveRange)throw new s("marker-destroyed",this);return this._affectsData}getStart(){if(!this._liveRange)throw new s("marker-destroyed",this);return this._liveRange.start.clone()}getEnd(){if(!this._liveRange)throw new s("marker-destroyed",this);return this._liveRange.end.clone()}getRange(){if(!this._liveRange)throw new s("marker-destroyed",this);return this._liveRange.toRange()}is(t){return"marker"===t||"model:marker"===t}_attachLiveRange(t){return this._liveRange&&this._detachLiveRange(),t.delegate("change:range").to(this),t.delegate("change:content").to(this),this._liveRange=t,t}_detachLiveRange(){this._liveRange.stopDelegating("change:range",this),this._liveRange.stopDelegating("change:content",this),this._liveRange.detach(),this._liveRange=null}}he(Yl,g);class Ql extends ml{get type(){return"noop"}clone(){return new Ql(this.baseVersion)}getReversed(){return new Ql(this.baseVersion+1)}_execute(){}static get className(){return"NoOperation"}}const Xl={};Xl[yl.className]=yl,Xl[Dl.className]=Dl,Xl[Sl.className]=Sl,Xl[El.className]=El,Xl[Ql.className]=Ql,Xl[ml.className]=ml,Xl[Bl.className]=Bl,Xl[Tl.className]=Tl,Xl[Il.className]=Il,Xl[Pl.className]=Pl;class td extends Qa{constructor(t,e,n="toNone"){if(super(t,e,n),!this.root.is("rootElement"))throw new s("model-liveposition-root-not-rootelement",t);ed.call(this)}detach(){this.stopListening()}is(t){return"livePosition"===t||"model:livePosition"===t||"position"==t||"model:position"===t}toPosition(){return new Qa(this.root,this.path.slice(),this.stickiness)}static fromPosition(t,e){return new this(t.root,t.path.slice(),e||t.stickiness)}}function ed(){this.listenTo(this.root.document.model,"applyOperation",((t,e)=>{const n=e[0];n.isDocumentOperation&&nd.call(this,n)}),{priority:"low"})}function nd(t){const e=this.getTransformedByOperation(t);if(!this.isEqual(e)){const t=this.toPosition();this.path=e.path,this.root=e.root,this.fire("change",t)}}he(td,g);class od{constructor(t,e,n){this.model=t,this.writer=e,this.position=n,this.canMergeWith=new Set([this.position.parent]),this.schema=t.schema,this._documentFragment=e.createDocumentFragment(),this._documentFragmentPosition=e.createPositionAt(this._documentFragment,0),this._firstNode=null,this._lastNode=null,this._lastAutoParagraph=null,this._filterAttributesOf=[],this._affectedStart=null,this._affectedEnd=null}handleNodes(t){for(const e of Array.from(t))this._handleNode(e);this._insertPartialFragment(),this._lastAutoParagraph&&this._updateLastNodeFromAutoParagraph(this._lastAutoParagraph),this._mergeOnRight(),this.schema.removeDisallowedAttributes(this._filterAttributesOf,this.writer),this._filterAttributesOf=[]}_updateLastNodeFromAutoParagraph(t){const e=this.writer.createPositionAfter(this._lastNode),n=this.writer.createPositionAfter(t);if(n.isAfter(e)){if(this._lastNode=t,this.position.parent!=t||!this.position.isAtEnd)throw new s("insertcontent-invalid-insertion-position",this);this.position=n,this._setAffectedBoundaries(this.position)}}getSelectionRange(){return this.nodeToSelect?nc._createOn(this.nodeToSelect):this.model.schema.getNearestSelectionRange(this.position)}getAffectedRange(){return this._affectedStart?new nc(this._affectedStart,this._affectedEnd):null}destroy(){this._affectedStart&&this._affectedStart.detach(),this._affectedEnd&&this._affectedEnd.detach()}_handleNode(t){if(this.schema.isObject(t))return void this._handleObject(t);let e=this._checkAndAutoParagraphToAllowedPosition(t);e||(e=this._checkAndSplitToAllowedPosition(t),e)?(this._appendToFragment(t),this._firstNode||(this._firstNode=t),this._lastNode=t):this._handleDisallowedNode(t)}_insertPartialFragment(){if(this._documentFragment.isEmpty)return;const t=td.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=t.toPosition()),this._documentFragment.isEmpty||this.writer.insert(this._documentFragment,this.position),this._documentFragmentPosition=this.writer.createPositionAt(this._documentFragment,0),this.position=t.toPosition(),t.detach()}_handleObject(t){this._checkAndSplitToAllowedPosition(t)?this._appendToFragment(t):this._tryAutoparagraphing(t)}_handleDisallowedNode(t){t.is("element")?this.handleNodes(t.getChildren()):this._tryAutoparagraphing(t)}_appendToFragment(t){if(!this.schema.checkChild(this.position,t))throw new s("insertcontent-wrong-position",this,{node:t,position:this.position});this.writer.insert(t,this._documentFragmentPosition),this._documentFragmentPosition=this._documentFragmentPosition.getShiftedBy(t.offsetSize),this.schema.isObject(t)&&!this.schema.checkChild(this.position,"$text")?this.nodeToSelect=t:this.nodeToSelect=null,this._filterAttributesOf.push(t)}_setAffectedBoundaries(t){this._affectedStart||(this._affectedStart=td.fromPosition(t,"toPrevious")),this._affectedEnd&&!this._affectedEnd.isBefore(t)||(this._affectedEnd&&this._affectedEnd.detach(),this._affectedEnd=td.fromPosition(t,"toNext"))}_mergeOnLeft(){const t=this._firstNode;if(!(t instanceof Za))return;if(!this._canMergeLeft(t))return;const e=td._createBefore(t);e.stickiness="toNext";const n=td.fromPosition(this.position,"toNext");this._affectedStart.isEqual(e)&&(this._affectedStart.detach(),this._affectedStart=td._createAt(e.nodeBefore,"end","toPrevious")),this._firstNode===this._lastNode&&(this._firstNode=e.nodeBefore,this._lastNode=e.nodeBefore),this.writer.merge(e),e.isEqual(this._affectedEnd)&&this._firstNode===this._lastNode&&(this._affectedEnd.detach(),this._affectedEnd=td._createAt(e.nodeBefore,"end","toNext")),this.position=n.toPosition(),n.detach(),this._filterAttributesOf.push(this.position.parent),e.detach()}_mergeOnRight(){const t=this._lastNode;if(!(t instanceof Za))return;if(!this._canMergeRight(t))return;const e=td._createAfter(t);if(e.stickiness="toNext",!this.position.isEqual(e))throw new s("insertcontent-invalid-insertion-position",this);this.position=Qa._createAt(e.nodeBefore,"end");const n=td.fromPosition(this.position,"toPrevious");this._affectedEnd.isEqual(e)&&(this._affectedEnd.detach(),this._affectedEnd=td._createAt(e.nodeBefore,"end","toNext")),this._firstNode===this._lastNode&&(this._firstNode=e.nodeBefore,this._lastNode=e.nodeBefore),this.writer.merge(e),e.getShiftedBy(-1).isEqual(this._affectedStart)&&this._firstNode===this._lastNode&&(this._affectedStart.detach(),this._affectedStart=td._createAt(e.nodeBefore,0,"toPrevious")),this.position=n.toPosition(),n.detach(),this._filterAttributesOf.push(this.position.parent),e.detach()}_canMergeLeft(t){const e=t.previousSibling;return e instanceof Za&&this.canMergeWith.has(e)&&this.model.schema.checkMerge(e,t)}_canMergeRight(t){const e=t.nextSibling;return e instanceof Za&&this.canMergeWith.has(e)&&this.model.schema.checkMerge(t,e)}_tryAutoparagraphing(t){const e=this.writer.createElement("paragraph");this._getAllowedIn(this.position.parent,e)&&this.schema.checkChild(e,t)&&(e._appendChild(t),this._handleNode(e))}_checkAndAutoParagraphToAllowedPosition(t){if(this.schema.checkChild(this.position.parent,t))return!0;if(!this.schema.checkChild(this.position.parent,"paragraph")||!this.schema.checkChild("paragraph",t))return!1;this._insertPartialFragment();const e=this.writer.createElement("paragraph");return this.writer.insert(e,this.position),this._setAffectedBoundaries(this.position),this._lastAutoParagraph=e,this.position=this.writer.createPositionAt(e,0),!0}_checkAndSplitToAllowedPosition(t){const e=this._getAllowedIn(this.position.parent,t);if(!e)return!1;for(e!=this.position.parent&&this._insertPartialFragment();e!=this.position.parent;)if(this.position.isAtStart){const t=this.position.parent;this.position=this.writer.createPositionBefore(t),t.isEmpty&&t.parent===e&&this.writer.remove(t)}else if(this.position.isAtEnd)this.position=this.writer.createPositionAfter(this.position.parent);else{const t=this.writer.createPositionAfter(this.position.parent);this._setAffectedBoundaries(this.position),this.writer.split(this.position),this.position=t,this.canMergeWith.add(this.position.nodeAfter)}return!0}_getAllowedIn(t,e){return this.schema.checkChild(t,e)?t:this.schema.isLimit(t)?null:this._getAllowedIn(t.parent,e)}}function id(t,e,n={}){if(e.isCollapsed)return;const o=e.getFirstRange();if("$graveyard"==o.root.rootName)return;const i=t.schema;t.change((t=>{if(!n.doNotResetEntireContent&&function(t,e){const n=t.getLimitElement(e);if(!e.containsEntireContent(n))return!1;const o=e.getFirstRange();if(o.start.parent==o.end.parent)return!1;return t.checkChild(n,"paragraph")}(i,e))return void function(t,e){const n=t.model.schema.getLimitElement(e);t.remove(t.createRangeIn(n)),cd(t,t.createPositionAt(n,0),e)}(t,e);const[r,s]=function(t){const e=t.root.document.model,n=t.start;let o=t.end;if(e.hasContent(t,{ignoreMarkers:!0})){const n=function(t){const e=t.parent,n=e.root.document.model.schema,o=e.getAncestors({parentFirst:!0,includeSelf:!0});for(const t of o){if(n.isLimit(t))return null;if(n.isBlock(t))return t}}(o);if(n&&o.isTouching(e.createPositionAt(n,0))){const n=e.createSelection(t);e.modifySelection(n,{direction:"backward"});const i=n.getLastPosition(),r=e.createRange(i,o);e.hasContent(r,{ignoreMarkers:!0})||(o=i)}}return[td.fromPosition(n,"toPrevious"),td.fromPosition(o,"toNext")]}(o);r.isTouching(s)||t.remove(t.createRange(r,s)),n.leaveUnmerged||(!function(t,e,n){const o=t.model;if(!ad(t.model.schema,e,n))return;const[i,r]=function(t,e){const n=t.getAncestors(),o=e.getAncestors();let i=0;for(;n[i]&&n[i]==o[i];)i++;return[n[i],o[i]]}(e,n);if(!i||!r)return;!o.hasContent(i,{ignoreMarkers:!0})&&o.hasContent(r,{ignoreMarkers:!0})?sd(t,e,n,i.parent):rd(t,e,n,i.parent)}(t,r,s),i.removeDisallowedAttributes(r.parent.getChildren(),t)),ld(t,e,r),!n.doNotAutoparagraph&&function(t,e){const n=t.checkChild(e,"$text"),o=t.checkChild(e,"paragraph");return!n&&o}(i,r)&&cd(t,r,e),r.detach(),s.detach()}))}function rd(t,e,n,o){const i=e.parent,r=n.parent;if(i!=o&&r!=o){for(e=t.createPositionAfter(i),(n=t.createPositionBefore(r)).isEqual(e)||t.insert(r,e),t.merge(e);n.parent.isEmpty;){const e=n.parent;n=t.createPositionBefore(e),t.remove(e)}ad(t.model.schema,e,n)&&rd(t,e,n,o)}}function sd(t,e,n,o){const i=e.parent,r=n.parent;if(i!=o&&r!=o){for(e=t.createPositionAfter(i),(n=t.createPositionBefore(r)).isEqual(e)||t.insert(i,n);e.parent.isEmpty;){const n=e.parent;e=t.createPositionBefore(n),t.remove(n)}n=t.createPositionBefore(r),function(t,e){const n=e.nodeBefore,o=e.nodeAfter;n.name!=o.name&&t.rename(n,o.name);t.clearAttributes(n),t.setAttributes(Object.fromEntries(o.getAttributes()),n),t.merge(e)}(t,n),ad(t.model.schema,e,n)&&sd(t,e,n,o)}}function ad(t,e,n){const o=e.parent,i=n.parent;return o!=i&&(!t.isLimit(o)&&!t.isLimit(i)&&function(t,e,n){const o=new nc(t,e);for(const t of o.getWalker())if(n.isLimit(t.item))return!1;return!0}(e,n,t))}function cd(t,e,n){const o=t.createElement("paragraph");t.insert(o,e),ld(t,n,t.createPositionAt(o,0))}function ld(t,e,n){e instanceof wc?t.setSelection(n):e.setTo(n)}const dd=' ,.?!:;"-()';function ud(t,e){const{isForward:n,walker:o,unit:i,schema:r}=t,{type:s,item:a,nextPosition:c}=e;if("text"==s)return"word"===t.unit?function(t,e){let n=t.position.textNode;if(n){let o=t.position.offset-n.startOffset;for(;!pd(n.data,o,e)&&!md(n,o,e);){t.next();const i=e?t.position.nodeAfter:t.position.nodeBefore;if(i&&i.is("$text")){const o=i.data.charAt(e?0:i.data.length-1);dd.includes(o)||(t.next(),n=t.position.textNode)}o=t.position.offset-n.startOffset}}return t.position}(o,n):function(t,e){const n=t.position.textNode;if(n){const o=n.data;let i=t.position.offset-n.startOffset;for(;Ul(o,i)||"character"==e&&$l(o,i);)t.next(),i=t.position.offset-n.startOffset}return t.position}(o,i);if(s==(n?"elementStart":"elementEnd")){if(r.isSelectable(a))return Qa._createAt(a,n?"after":"before");if(r.checkChild(c,"$text"))return c}else{if(r.isLimit(a))return void o.skip((()=>!0));if(r.checkChild(c,"$text"))return c}}function hd(t,e){const n=t.root,o=Qa._createAt(n,e?"end":0);return e?new nc(t,o):new nc(o,t)}function pd(t,e,n){const o=e+(n?0:-1);return dd.includes(t.charAt(o))}function md(t,e,n){return e===(n?t.endOffset:0)}function gd(t,e){const n=[];Array.from(t.getItems({direction:"backward"})).map((t=>e.createRangeOn(t))).filter((e=>(e.start.isAfter(t.start)||e.start.isEqual(t.start))&&(e.end.isBefore(t.end)||e.end.isEqual(t.end)))).forEach((t=>{n.push(t.start.parent),e.remove(t)})),n.forEach((t=>{let n=t;for(;n.parent&&n.isEmpty;){const t=e.createRangeOn(n);n=n.parent,e.remove(t)}}))}function fd(t){t.document.registerPostFixer((e=>function(t,e){const n=e.document.selection,o=e.schema,i=[];let r=!1;for(const t of n.getRanges()){const e=bd(t,o);e&&!e.isEqual(t)?(i.push(e),r=!0):i.push(t)}r&&t.setSelection(function(t){const e=[...t],n=new Set;let o=1;for(;o!n.has(e)))}(i),{backward:n.isBackward})}(e,t)))}function bd(t,e){return t.isCollapsed?function(t,e){const n=t.start,o=e.getNearestSelectionRange(n);if(!o){const t=n.getAncestors().reverse().find((t=>e.isObject(t)));return t?nc._createOn(t):null}if(!o.isCollapsed)return o;const i=o.start;if(n.isEqual(i))return null;return new nc(i)}(t,e):function(t,e){const{start:n,end:o}=t,i=e.checkChild(n,"$text"),r=e.checkChild(o,"$text"),s=e.getLimitElement(n),a=e.getLimitElement(o);if(s===a){if(i&&r)return null;if(function(t,e,n){const o=t.nodeAfter&&!n.isLimit(t.nodeAfter)||n.checkChild(t,"$text"),i=e.nodeBefore&&!n.isLimit(e.nodeBefore)||n.checkChild(e,"$text");return o||i}(n,o,e)){const t=n.nodeAfter&&e.isSelectable(n.nodeAfter)?null:e.getNearestSelectionRange(n,"forward"),i=o.nodeBefore&&e.isSelectable(o.nodeBefore)?null:e.getNearestSelectionRange(o,"backward"),r=t?t.start:n,s=i?i.end:o;return new nc(r,s)}}const c=s&&!s.is("rootElement"),l=a&&!a.is("rootElement");if(c||l){const t=n.nodeAfter&&o.nodeBefore&&n.nodeAfter.parent===o.nodeBefore.parent,i=c&&(!t||!wd(n.nodeAfter,e)),r=l&&(!t||!wd(o.nodeBefore,e));let d=n,u=o;return i&&(d=Qa._createBefore(kd(s,e))),r&&(u=Qa._createAfter(kd(a,e))),new nc(d,u)}return null}(t,e)}function kd(t,e){let n=t,o=n;for(;e.isLimit(o)&&o.parent;)n=o,o=o.parent;return n}function wd(t,e){return t&&e.isSelectable(t)}class _d{constructor(){this.markers=new Jl,this.document=new Kl(this),this.schema=new Uc,this._pendingChanges=[],this._currentWriter=null,["insertContent","deleteContent","modifySelection","getSelectedContent","applyOperation"].forEach((t=>this.decorate(t))),this.on("applyOperation",((t,e)=>{e[0]._validate()}),{priority:"highest"}),this.schema.register("$root",{isLimit:!0}),this.schema.register("$block",{allowIn:"$root",isBlock:!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(((t,e)=>{if("$marker"===e.name)return!0})),fd(this),this.document.registerPostFixer(Pc)}change(t){try{return 0===this._pendingChanges.length?(this._pendingChanges.push({batch:new pl,callback:t}),this._runPendingChanges()[0]):t(this._currentWriter)}catch(t){s.rethrowUnexpectedError(t,this)}}enqueueChange(t,e){try{t?"function"==typeof t?(e=t,t=new pl):t instanceof pl||(t=new pl(t)):t=new pl,this._pendingChanges.push({batch:t,callback:e}),1==this._pendingChanges.length&&this._runPendingChanges()}catch(t){s.rethrowUnexpectedError(t,this)}}applyOperation(t){t._execute()}insertContent(t,e,n){return function(t,e,n,o){return t.change((i=>{let r;r=n?n instanceof dc||n instanceof wc?n:i.createSelection(n,o):t.document.selection,r.isCollapsed||t.deleteContent(r,{doNotAutoparagraph:!0});const s=new od(t,i,r.anchor);let a;a=e.is("documentFragment")?e.getChildren():[e],s.handleNodes(a);const c=s.getSelectionRange();c&&(r instanceof wc?i.setSelection(c):r.setTo(c));const l=s.getAffectedRange()||t.createRange(r.anchor);return s.destroy(),l}))}(this,t,e,n)}deleteContent(t,e){id(this,t,e)}modifySelection(t,e){!function(t,e,n={}){const o=t.schema,i="backward"!=n.direction,r=n.unit?n.unit:"character",s=e.focus,a=new Ja({boundaries:hd(s,i),singleCharacters:!0,direction:i?"forward":"backward"}),c={walker:a,schema:o,isForward:i,unit:r};let l;for(;l=a.next();){if(l.done)return;const n=ud(c,l.value);if(n)return void(e instanceof wc?t.change((t=>{t.setSelectionFocus(n)})):e.setFocus(n))}}(this,t,e)}getSelectedContent(t){return function(t,e){return t.change((t=>{const n=t.createDocumentFragment(),o=e.getFirstRange();if(!o||o.isCollapsed)return n;const i=o.start.root,r=o.start.getCommonPath(o.end),s=i.getNodeByPath(r);let a;a=o.start.parent==o.end.parent?o:t.createRange(t.createPositionAt(s,o.start.path[r.length]),t.createPositionAt(s,o.end.path[r.length]+1));const c=a.end.offset-a.start.offset;for(const e of a.getItems({shallow:!0}))e.is("$textProxy")?t.appendText(e.data,e.getAttributes(),n):t.append(t.cloneElement(e,!0),n);if(a!=o){const e=o._getTransformedByMove(a.start,t.createPositionAt(n,0),c)[0],i=t.createRange(t.createPositionAt(n,0),e.start);gd(t.createRange(e.end,t.createPositionAt(n,"end")),t),gd(i,t)}return n}))}(this,t)}hasContent(t,e={}){const n=t instanceof Za?nc._createIn(t):t;if(n.isCollapsed)return!1;const{ignoreWhitespaces:o=!1,ignoreMarkers:i=!1}=e;if(!i)for(const t of this.markers.getMarkersIntersectingRange(n))if(t.affectsData)return!0;for(const t of n.getItems())if(this.schema.isContent(t)){if(!t.is("$textProxy"))return!0;if(!o)return!0;if(-1!==t.data.search(/\S/))return!0}return!1}createPositionFromPath(t,e,n){return new Qa(t,e,n)}createPositionAt(t,e){return Qa._createAt(t,e)}createPositionAfter(t){return Qa._createAfter(t)}createPositionBefore(t){return Qa._createBefore(t)}createRange(t,e){return new nc(t,e)}createRangeIn(t){return nc._createIn(t)}createRangeOn(t){return nc._createOn(t)}createSelection(t,e,n){return new dc(t,e,n)}createBatch(t){return new pl(t)}createOperationFromJSON(t){return class{static fromJSON(t,e){return Xl[t.__className].fromJSON(t,e)}}.fromJSON(t,this.document)}destroy(){this.document.destroy(),this.stopListening()}_runPendingChanges(){const t=[];for(this.fire("_beforeChanges");this._pendingChanges.length;){const e=this._pendingChanges[0].batch;this._currentWriter=new zl(this,e);const n=this._pendingChanges[0].callback(this._currentWriter);t.push(n),this.document._handleChangeBlock(this._currentWriter),this._pendingChanges.shift(),this._currentWriter=null}return this.fire("_afterChanges"),t}}he(_d,se);class Cd extends Ia{constructor(t){super(),this.editor=t}set(t,e,n={}){if("string"==typeof e){const t=e;e=(e,n)=>{this.editor.execute(t),n()}}super.set(t,e,n)}}class Ad{constructor(t={}){const e=t.language||this.constructor.defaultConfig&&this.constructor.defaultConfig.language;this._context=t.context||new Fo({language:e}),this._context._addEditor(this,!t.context);const n=Array.from(this.constructor.builtinPlugins||[]);this.config=new yo(t,this.constructor.defaultConfig),this.config.define("plugins",n),this.config.define(this._context._getEditorConfig()),this.plugins=new Bo(this,n,this._context.plugins),this.locale=this._context.locale,this.t=this.locale.t,this.commands=new qc,this.set("state","initializing"),this.once("ready",(()=>this.state="ready"),{priority:"high"}),this.once("destroy",(()=>this.state="destroyed"),{priority:"high"}),this.set("isReadOnly",!1),this.model=new _d;const o=new Si;this.data=new ll(this.model,o),this.editing=new Hc(this.model,o),this.editing.view.document.bind("isReadOnly").to(this),this.conversion=new dl([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 Cd(this),this.keystrokes.listenTo(this.editing.view.document)}initPlugins(){const t=this.config,e=t.get("plugins"),n=t.get("removePlugins")||[],o=t.get("extraPlugins")||[],i=t.get("substitutePlugins")||[];return this.plugins.init(e.concat(o),n,i)}destroy(){let t=Promise.resolve();return"initializing"==this.state&&(t=new Promise((t=>this.once("ready",t)))),t.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(...t){try{return this.commands.execute(...t)}catch(t){s.rethrowUnexpectedError(t,this)}}focus(){this.editing.view.focus()}}he(Ad,se);class vd{constructor(t){this.editor=t,this._components=new Map}*names(){for(const t of this._components.values())yield t.originalName}add(t,e){this._components.set(yd(t),{callback:e,originalName:t})}create(t){if(!this.has(t))throw new s("componentfactory-item-missing",this,{name:t});return this._components.get(yd(t)).callback(this.editor.locale)}has(t){return this._components.has(yd(t))}}function yd(t){return String(t).toLowerCase()}class xd{constructor(t){this.editor=t,this.componentFactory=new vd(t),this.focusTracker=new Pa,this.set("viewportOffset",this._readViewportOffsetFromConfig()),this._editableElementsMap=new Map,this.listenTo(t.editing.view.document,"layoutChanged",(()=>this.update()))}get element(){return null}update(){this.fire("update")}destroy(){this.stopListening(),this.focusTracker.destroy();for(const t of this._editableElementsMap.values())t.ckeditorInstance=null;this._editableElementsMap=new Map}setEditableElement(t,e){this._editableElementsMap.set(t,e),e.ckeditorInstance||(e.ckeditorInstance=this.editor)}getEditableElement(t="main"){return this._editableElementsMap.get(t)}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 t=this.editor,e=t.config.get("ui.viewportOffset");if(e)return e;const n=t.config.get("toolbar.viewportTopOffset");return n?(console.warn("editor-ui-deprecated-viewport-offset-config: The `toolbar.vieportTopOffset` configuration option is deprecated. It will be removed from future CKEditor versions. Use `ui.viewportOffset.top` instead."),{top:n}):{top:0}}}he(xd,se);const Ed={setData(t){this.data.set(t)},getData(t){return this.data.get(t)}},Dd=Ed;class Sd extends No{static get pluginName(){return"PendingActions"}init(){this.set("hasAny",!1),this._actions=new So({idProperty:"_id"}),this._actions.delegate("add","remove").to(this)}add(t){if("string"!=typeof t)throw new s("pendingactions-add-invalid-message",this);const e=Object.create(se);return e.set("message",t),this._actions.add(e),this.hasAny=!0,e}remove(t){this._actions.remove(t),this.hasAny=!!this._actions.length}get first(){return this._actions.get(0)}[Symbol.iterator](){return this._actions[Symbol.iterator]()}}const Bd='',Td={cancel:'',caption:'',check:'',cog:'',eraser:'',lowVision:'',image:'',alignBottom:'',alignMiddle:'',alignTop:'',alignLeft:'',alignCenter:'',alignRight:'',alignJustify:'',objectLeft:'',objectCenter:'',objectRight:'',objectFullWidth:'',objectInline:'',objectBlockLeft:'',objectBlockRight:'',objectSizeFull:'',objectSizeLarge:'',objectSizeSmall:'',objectSizeMedium:'',pencil:'',pilcrow:'',quote:'',threeVerticalDots:Bd};function Pd({emitter:t,activator:e,callback:n,contextElements:o}){t.listenTo(document,"mousedown",((t,i)=>{if(!e())return;const r="function"==typeof i.composedPath?i.composedPath():[];for(const t of o)if(t.contains(i.target)||r.includes(t))return;n()}))}function Id(t){t.set("_isCssTransitionsDisabled",!1),t.disableCssTransitions=()=>{t._isCssTransitionsDisabled=!0},t.enableCssTransitions=()=>{t._isCssTransitionsDisabled=!1},t.extendTemplate({attributes:{class:[t.bindTemplate.if("_isCssTransitionsDisabled","ck-transitions-disabled")]}})}function Rd({view:t}){t.listenTo(t.element,"submit",((e,n)=>{n.preventDefault(),t.fire("submit")}),{useCapture:!0})}class zd extends So{constructor(t=[]){super(t,{idProperty:"viewUid"}),this.on("add",((t,e,n)=>{this._renderViewIntoCollectionParent(e,n)})),this.on("remove",((t,e)=>{e.element&&this._parentElement&&e.element.remove()})),this._parentElement=null}destroy(){this.map((t=>t.destroy()))}setParent(t){this._parentElement=t;for(const t of this)this._renderViewIntoCollectionParent(t)}delegate(...t){if(!t.length||!t.every((t=>"string"==typeof t)))throw new s("ui-viewcollection-delegate-wrong-events",this);return{to:e=>{for(const n of this)for(const o of t)n.delegate(o).to(e);this.on("add",((n,o)=>{for(const n of t)o.delegate(n).to(e)})),this.on("remove",((n,o)=>{for(const n of t)o.stopDelegating(n,e)}))}}}_renderViewIntoCollectionParent(t,e){t.isRendered||t.render(),t.element&&this._parentElement&&this._parentElement.insertBefore(t.element,this._parentElement.children[e])}}var Fd=n(6150),Nd={attributes:{"data-cke":!0}};Nd.setAttributes=is(),Nd.insert=ns().bind(null,"head"),Nd.domAPI=ts(),Nd.insertStyleElement=ss();Qr()(Fd.Z,Nd);Fd.Z&&Fd.Z.locals&&Fd.Z.locals;class Od{constructor(t){this.element=null,this.isRendered=!1,this.locale=t,this.t=t&&t.t,this._viewCollections=new So,this._unboundChildren=this.createCollection(),this._viewCollections.on("add",((e,n)=>{n.locale=t})),this.decorate("render")}get bindTemplate(){return this._bindTemplate?this._bindTemplate:this._bindTemplate=Md.bind(this,this)}createCollection(t){const e=new zd(t);return this._viewCollections.add(e),e}registerChild(t){Do(t)||(t=[t]);for(const e of t)this._unboundChildren.add(e)}deregisterChild(t){Do(t)||(t=[t]);for(const e of t)this._unboundChildren.remove(e)}setTemplate(t){this.template=new Md(t)}extendTemplate(t){Md.extend(this.template,t)}render(){if(this.isRendered)throw new s("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((t=>t.destroy())),this.template&&this.template._revertData&&this.template.revert(this.element)}}he(Od,Es),he(Od,se);class Md{constructor(t){Object.assign(this,Kd(Gd(t))),this._isRendered=!1,this._revertData=null}render(){const t=this._renderNode({intoFragment:!0});return this._isRendered=!0,t}apply(t){return this._revertData={children:[],bindings:[],attributes:{}},this._renderNode({node:t,isApplying:!0,revertData:this._revertData}),t}revert(t){if(!this._revertData)throw new s("ui-template-revert-not-applied",[this,t]);this._revertTemplateFromNode(t,this._revertData)}*getViews(){yield*function*t(e){if(e.children)for(const n of e.children)tu(n)?yield n:eu(n)&&(yield*t(n))}(this)}static bind(t,e){return{to:(n,o)=>new Ld({eventNameOrFunction:n,attribute:n,observable:t,emitter:e,callback:o}),if:(n,o,i)=>new Hd({observable:t,emitter:e,attribute:n,valueIfTrue:o,callback:i})}}static extend(t,e){if(t._isRendered)throw new s("template-extend-render",[this,t]);Qd(t,Kd(Gd(e)))}_renderNode(t){let e;if(e=t.node?this.tag&&this.text:this.tag?this.text:!this.text,e)throw new s("ui-template-wrong-syntax",this);return this.text?this._renderText(t):this._renderElement(t)}_renderElement(t){let e=t.node;return e||(e=t.node=document.createElementNS(this.ns||"http://www.w3.org/1999/xhtml",this.tag)),this._renderAttributes(t),this._renderElementChildren(t),this._setUpListeners(t),e}_renderText(t){let e=t.node;return e?t.revertData.text=e.textContent:e=t.node=document.createTextNode(""),qd(this.text)?this._bindToObservable({schema:this.text,updater:jd(e),data:t}):e.textContent=this.text.join(""),e}_renderAttributes(t){let e,n,o,i;if(!this.attributes)return;const r=t.node,s=t.revertData;for(e in this.attributes)if(o=r.getAttribute(e),n=this.attributes[e],s&&(s.attributes[e]=o),i=y(n[0])&&n[0].ns?n[0].ns:null,qd(n)){const a=i?n[0].value:n;s&&ou(e)&&a.unshift(o),this._bindToObservable({schema:a,updater:Ud(r,e,i),data:t})}else"style"==e&&"string"!=typeof n[0]?this._renderStyleAttribute(n[0],t):(s&&o&&ou(e)&&n.unshift(o),n=n.map((t=>t&&t.value||t)).reduce(((t,e)=>t.concat(e)),[]).reduce(Jd,""),Xd(n)||r.setAttributeNS(i,e,n))}_renderStyleAttribute(t,e){const n=e.node;for(const o in t){const i=t[o];qd(i)?this._bindToObservable({schema:[i],updater:$d(n,o),data:e}):n.style[o]=i}}_renderElementChildren(t){const e=t.node,n=t.intoFragment?document.createDocumentFragment():e,o=t.isApplying;let i=0;for(const r of this.children)if(nu(r)){if(!o){r.setParent(e);for(const t of r)n.appendChild(t.element)}}else if(tu(r))o||(r.isRendered||r.render(),n.appendChild(r.element));else if(Jr(r))n.appendChild(r);else if(o){const e={children:[],bindings:[],attributes:{}};t.revertData.children.push(e),r._renderNode({node:n.childNodes[i++],isApplying:!0,revertData:e})}else n.appendChild(r.render());t.intoFragment&&e.appendChild(n)}_setUpListeners(t){if(this.eventListeners)for(const e in this.eventListeners){const n=this.eventListeners[e].map((n=>{const[o,i]=e.split("@");return n.activateDomEventListener(o,i,t)}));t.revertData&&t.revertData.bindings.push(n)}}_bindToObservable({schema:t,updater:e,data:n}){const o=n.revertData;Wd(t,e,n);const i=t.filter((t=>!Xd(t))).filter((t=>t.observable)).map((o=>o.activateAttributeListener(t,e,n)));o&&o.bindings.push(i)}_revertTemplateFromNode(t,e){for(const t of e.bindings)for(const e of t)e();if(e.text)t.textContent=e.text;else{for(const n in e.attributes){const o=e.attributes[n];null===o?t.removeAttribute(n):t.setAttribute(n,o)}for(let n=0;nWd(t,e,n);return this.emitter.listenTo(this.observable,"change:"+this.attribute,o),()=>{this.emitter.stopListening(this.observable,"change:"+this.attribute,o)}}}class Ld extends Vd{activateDomEventListener(t,e,n){const o=(t,n)=>{e&&!n.target.matches(e)||("function"==typeof this.eventNameOrFunction?this.eventNameOrFunction(n):this.observable.fire(this.eventNameOrFunction,n))};return this.emitter.listenTo(n.node,t,o),()=>{this.emitter.stopListening(n.node,t,o)}}}class Hd extends Vd{getValue(t){return!Xd(super.getValue(t))&&(this.valueIfTrue||!0)}}function qd(t){return!!t&&(t.value&&(t=t.value),Array.isArray(t)?t.some(qd):t instanceof Vd)}function Wd(t,e,{node:n}){let o=function(t,e){return t.map((t=>t instanceof Vd?t.getValue(e):t))}(t,n);o=1==t.length&&t[0]instanceof Hd?o[0]:o.reduce(Jd,""),Xd(o)?e.remove():e.set(o)}function jd(t){return{set(e){t.textContent=e},remove(){t.textContent=""}}}function Ud(t,e,n){return{set(o){t.setAttributeNS(n,e,o)},remove(){t.removeAttributeNS(n,e)}}}function $d(t,e){return{set(n){t.style[e]=n},remove(){t.style[e]=null}}}function Gd(t){return Ao(t,(t=>{if(t&&(t instanceof Vd||eu(t)||tu(t)||nu(t)))return t}))}function Kd(t){if("string"==typeof t?t=function(t){return{text:[t]}}(t):t.text&&function(t){t.text=To(t.text)}(t),t.on&&(t.eventListeners=function(t){for(const e in t)Zd(t,e);return t}(t.on),delete t.on),!t.text){t.attributes&&function(t){for(const e in t)t[e].value&&(t[e].value=To(t[e].value)),Zd(t,e)}(t.attributes);const e=[];if(t.children)if(nu(t.children))e.push(t.children);else for(const n of t.children)eu(n)||tu(n)||Jr(n)?e.push(n):e.push(new Md(n));t.children=e}return t}function Zd(t,e){t[e]=To(t[e])}function Jd(t,e){return Xd(e)?t:Xd(t)?e:`${t} ${e}`}function Yd(t,e){for(const n in e)t[n]?t[n].push(...e[n]):t[n]=e[n]}function Qd(t,e){if(e.attributes&&(t.attributes||(t.attributes={}),Yd(t.attributes,e.attributes)),e.eventListeners&&(t.eventListeners||(t.eventListeners={}),Yd(t.eventListeners,e.eventListeners)),e.text&&t.text.push(...e.text),e.children&&e.children.length){if(t.children.length!=e.children.length)throw new s("ui-template-extend-children-mismatch",t);let n=0;for(const o of e.children)Qd(t.children[n++],o)}}function Xd(t){return!t&&0!==t}function tu(t){return t instanceof Od}function eu(t){return t instanceof Md}function nu(t){return t instanceof zd}function ou(t){return"class"==t||"style"==t}class iu extends zd{constructor(t,e=[]){super(e),this.locale=t}attachToDom(){this._bodyCollectionContainer=new Md({tag:"div",attributes:{class:["ck","ck-reset_all","ck-body","ck-rounded-corners"],dir:this.locale.uiLanguageDirection},children:this}).render();let t=document.querySelector(".ck-body-wrapper");t||(t=_a(document,"div",{class:"ck-body-wrapper"}),document.body.appendChild(t)),t.appendChild(this._bodyCollectionContainer)}detachFromDom(){super.destroy(),this._bodyCollectionContainer&&this._bodyCollectionContainer.remove();const t=document.querySelector(".ck-body-wrapper");t&&0==t.childElementCount&&t.remove()}}var ru=n(1174),su={attributes:{"data-cke":!0}};su.setAttributes=is(),su.insert=ns().bind(null,"head"),su.domAPI=ts(),su.insertStyleElement=ss();Qr()(ru.Z,su);ru.Z&&ru.Z.locals&&ru.Z.locals;class au extends Od{constructor(){super();const t=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:t.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 t=(new DOMParser).parseFromString(this.content.trim(),"image/svg+xml").querySelector("svg"),e=t.getAttribute("viewBox");for(e&&(this.viewBox=e),this.element.innerHTML="";t.childNodes.length>0;)this.element.appendChild(t.childNodes[0])}}_colorFillPaths(){this.fillColor&&this.element.querySelectorAll(".ck-icon__fill").forEach((t=>{t.style.fill=this.fillColor}))}}var cu=n(9948),lu={attributes:{"data-cke":!0}};lu.setAttributes=is(),lu.insert=ns().bind(null,"head"),lu.domAPI=ts(),lu.insertStyleElement=ss();Qr()(cu.Z,lu);cu.Z&&cu.Z.locals&&cu.Z.locals;class du extends Od{constructor(t){super(t),this.set("text",""),this.set("position","s");const e=this.bindTemplate;this.setTemplate({tag:"span",attributes:{class:["ck","ck-tooltip",e.to("position",(t=>"ck-tooltip_"+t)),e.if("text","ck-hidden",(t=>!t.trim()))]},children:[{tag:"span",attributes:{class:["ck","ck-tooltip__text"]},children:[{text:e.to("text")}]}]})}}var uu=n(4499),hu={attributes:{"data-cke":!0}};hu.setAttributes=is(),hu.insert=ns().bind(null,"head"),hu.domAPI=ts(),hu.insertStyleElement=ss();Qr()(uu.Z,hu);uu.Z&&uu.Z.locals&&uu.Z.locals;class pu extends Od{constructor(t){super(t);const e=this.bindTemplate,n=i();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(n),this.iconView=new au,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",e.to("class"),e.if("isEnabled","ck-disabled",(t=>!t)),e.if("isVisible","ck-hidden",(t=>!t)),e.to("isOn",(t=>t?"ck-on":"ck-off")),e.if("withText","ck-button_with-text"),e.if("withKeystroke","ck-button_with-keystroke")],type:e.to("type",(t=>t||"button")),tabindex:e.to("tabindex"),"aria-labelledby":`ck-editor__aria-label_${n}`,"aria-disabled":e.if("isEnabled",!0,(t=>!t)),"aria-pressed":e.to("isOn",(t=>!!this.isToggleable&&String(t)))},children:this.children,on:{mousedown:e.to((t=>{t.preventDefault()})),click:e.to((t=>{this.isEnabled?this.fire("execute"):t.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 t=new du;return t.bind("text").to(this,"_tooltipString"),t.bind("position").to(this,"tooltipPosition"),t}_createLabelView(t){const e=new Od,n=this.bindTemplate;return e.setTemplate({tag:"span",attributes:{class:["ck","ck-button__label"],style:n.to("labelStyle"),id:`ck-editor__aria-label_${t}`},children:[{text:this.bindTemplate.to("label")}]}),e}_createKeystrokeView(){const t=new Od;return t.setTemplate({tag:"span",attributes:{class:["ck","ck-button__keystroke"]},children:[{text:this.bindTemplate.to("keystroke",(t=>gr(t)))}]}),t}_getTooltipString(t,e,n){return t?"string"==typeof t?t:(n&&(n=gr(n)),t instanceof Function?t(e,n):`${e}${n?` (${n})`:""}`):""}}var mu=n(9681),gu={attributes:{"data-cke":!0}};gu.setAttributes=is(),gu.insert=ns().bind(null,"head"),gu.domAPI=ts(),gu.insertStyleElement=ss();Qr()(mu.Z,gu);mu.Z&&mu.Z.locals&&mu.Z.locals;class fu extends pu{constructor(t){super(t),this.isToggleable=!0,this.toggleSwitchView=this._createToggleView(),this.extendTemplate({attributes:{class:"ck-switchbutton"}})}render(){super.render(),this.children.add(this.toggleSwitchView)}_createToggleView(){const t=new Od;return t.setTemplate({tag:"span",attributes:{class:["ck","ck-button__toggle"]},children:[{tag:"span",attributes:{class:["ck","ck-button__toggle__inner"]}}]}),t}}function bu(t,e){const n=t.t,o={Black:n("Black"),"Dim grey":n("Dim grey"),Grey:n("Grey"),"Light grey":n("Light grey"),White:n("White"),Red:n("Red"),Orange:n("Orange"),Yellow:n("Yellow"),"Light green":n("Light green"),Green:n("Green"),Aquamarine:n("Aquamarine"),Turquoise:n("Turquoise"),"Light blue":n("Light blue"),Blue:n("Blue"),Purple:n("Purple")};return e.map((t=>{const e=o[t.label];return e&&e!=t.label&&(t.label=e),t}))}function ku(t){return t.map(wu).filter((t=>!!t))}function wu(t){return"string"==typeof t?{model:t,label:t,hasBorder:!1,view:{name:"span",styles:{color:t}}}:{model:t.color,label:t.label||t.color,hasBorder:void 0!==t.hasBorder&&t.hasBorder,view:{name:"span",styles:{color:`${t.color}`}}}}class _u extends pu{constructor(t){super(t);const e=this.bindTemplate;this.set("color"),this.set("hasBorder"),this.icon='',this.extendTemplate({attributes:{style:{backgroundColor:e.to("color")},class:["ck","ck-color-grid__tile",e.if("hasBorder","ck-color-table__color-tile_bordered")]}})}render(){super.render(),this.iconView.fillColor="hsl(0, 0%, 100%)"}}function Cu(t){return!!(t&&t.getClientRects&&t.getClientRects().length)}class Au{constructor(t){if(Object.assign(this,t),t.actions&&t.keystrokeHandler)for(const e in t.actions){let n=t.actions[e];"string"==typeof n&&(n=[n]);for(const o of n)t.keystrokeHandler.set(o,((t,n)=>{this[e](),n()}))}}get first(){return this.focusables.find(vu)||null}get last(){return this.focusables.filter(vu).slice(-1)[0]||null}get next(){return this._getFocusableItem(1)}get previous(){return this._getFocusableItem(-1)}get current(){let t=null;return null===this.focusTracker.focusedElement?null:(this.focusables.find(((e,n)=>{const o=e.element===this.focusTracker.focusedElement;return o&&(t=n),o})),t)}focusFirst(){this._focus(this.first)}focusLast(){this._focus(this.last)}focusNext(){this._focus(this.next)}focusPrevious(){this._focus(this.previous)}_focus(t){t&&t.focus()}_getFocusableItem(t){const e=this.current,n=this.focusables.length;if(!n)return null;if(null===e)return this[1===t?"first":"last"];let o=(e+n+t)%n;do{const e=this.focusables.get(o);if(vu(e))return e;o=(o+n+t)%n}while(o!==e);return null}}function vu(t){return!(!t.focus||!Cu(t.element))}var yu=n(4923),xu={attributes:{"data-cke":!0}};xu.setAttributes=is(),xu.insert=ns().bind(null,"head"),xu.domAPI=ts(),xu.insertStyleElement=ss();Qr()(yu.Z,xu);yu.Z&&yu.Z.locals&&yu.Z.locals;class Eu extends Od{constructor(t,e){super(t);const n=e&&e.colorDefinitions||[],o={};e&&e.columns&&(o.gridTemplateColumns=`repeat( ${e.columns}, 1fr)`),this.set("selectedColor"),this.items=this.createCollection(),this.focusTracker=new Pa,this.keystrokes=new Ia,this._focusCycler=new Au({focusables:this.items,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"arrowleft",focusNext:"arrowright"}}),this.items.on("add",((t,e)=>{e.isOn=e.color===this.selectedColor})),n.forEach((t=>{const e=new _u;e.set({color:t.color,label:t.label,tooltip:!0,hasBorder:t.options.hasBorder}),e.on("execute",(()=>{this.fire("execute",{value:t.color,hasBorder:t.options.hasBorder,label:t.label})})),this.items.add(e)})),this.setTemplate({tag:"div",children:this.items,attributes:{class:["ck","ck-color-grid"],style:o}}),this.on("change:selectedColor",((t,e,n)=>{for(const t of this.items)t.isOn=t.color===n}))}focus(){this.items.length&&this.items.first.focus()}focusLast(){this.items.length&&this.items.last.focus()}render(){super.render();for(const t of this.items)this.focusTracker.add(t.element);this.items.on("add",((t,e)=>{this.focusTracker.add(e.element)})),this.items.on("remove",((t,e)=>{this.focusTracker.remove(e.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}}const Du='';class Su extends pu{constructor(t){super(t),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 t=new au;return t.content=Du,t.extendTemplate({attributes:{class:"ck-dropdown__arrow"}}),t}}var Bu=n(66),Tu={attributes:{"data-cke":!0}};Tu.setAttributes=is(),Tu.insert=ns().bind(null,"head"),Tu.domAPI=ts(),Tu.insertStyleElement=ss();Qr()(Bu.Z,Tu);Bu.Z&&Bu.Z.locals&&Bu.Z.locals;class Pu extends Od{constructor(t){super(t);const e=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 Ia,this.focusTracker=new Pa,this.setTemplate({tag:"div",attributes:{class:["ck","ck-splitbutton",e.to("class"),e.if("isVisible","ck-hidden",(t=>!t)),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",((t,e)=>{this.focusTracker.focusedElement===this.actionView.element&&(this.arrowView.focus(),e())})),this.keystrokes.set("arrowleft",((t,e)=>{this.focusTracker.focusedElement===this.arrowView.element&&(this.actionView.focus(),e())}))}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this.actionView.focus()}_createActionView(){const t=new pu;return t.bind("icon","isEnabled","isOn","isToggleable","keystroke","label","tabindex","tooltip","tooltipPosition","type","withText").to(this),t.extendTemplate({attributes:{class:"ck-splitbutton__action"}}),t.delegate("execute").to(this),t}_createArrowView(){const t=new pu,e=t.bindTemplate;return t.icon=Du,t.extendTemplate({attributes:{class:"ck-splitbutton__arrow","aria-haspopup":!0,"aria-expanded":e.to("isOn",(t=>String(t)))}}),t.bind("isEnabled").to(this),t.delegate("execute").to(this,"open"),t}}class Iu extends Od{constructor(t){super(t);const e=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",e.to("position",(t=>`ck-dropdown__panel_${t}`)),e.if("isVisible","ck-dropdown__panel-visible")]},children:this.children,on:{selectstart:e.to((t=>t.preventDefault()))}})}focus(){this.children.length&&this.children.first.focus()}focusLast(){if(this.children.length){const t=this.children.last;"function"==typeof t.focusLast?t.focusLast():t.focus()}}}var Ru=n(3488),zu={attributes:{"data-cke":!0}};zu.setAttributes=is(),zu.insert=ns().bind(null,"head"),zu.domAPI=ts(),zu.insertStyleElement=ss();Qr()(Ru.Z,zu);Ru.Z&&Ru.Z.locals&&Ru.Z.locals;function Fu({element:t,target:e,positions:n,limiter:o,fitInViewport:i,viewportOffsetConfig:r}){M(e)&&(e=e()),M(o)&&(o=o());const s=function(t){return t&&t.parentNode?t.offsetParent===ps.document.body?null:t.offsetParent:null}(t),a=new ya(t);let c;const l={targetRect:new ya(e),elementRect:a,positionedElementAncestor:s};if(o||i){const t=o&&new ya(o).getVisible(),e=i&&function(t){t=Object.assign({top:0,bottom:0,left:0,right:0},t);const e=new ya(ps.window);return e.top+=t.top,e.height-=t.top,e.bottom-=t.bottom,e.height-=t.bottom,e}(r);Object.assign(l,{limiterRect:t,viewportRect:e}),c=function(t,e){const{elementRect:n}=e,o=n.getArea(),i=t.map((t=>new Ou(t,e))).filter((t=>!!t.name));let r=0,s=null;for(const t of i){const{_limiterIntersectionArea:e,_viewportIntersectionArea:n}=t;if(e===o)return t;const i=n**2+e**2;i>r&&(r=i,s=t)}return s}(n,l)||new Ou(n[0],l)}else c=new Ou(n[0],l);return c}function Nu(t){const{scrollX:e,scrollY:n}=ps.window;return t.clone().moveBy(e,n)}class Ou{constructor(t,e){const n=t(e.targetRect,e.elementRect,e.viewportRect);if(!n)return;const{left:o,top:i,name:r,config:s}=n;Object.assign(this,{name:r,config:s}),this._positioningFunctionCorrdinates={left:o,top:i},this._options=e}get left(){return this._absoluteRect.left}get top(){return this._absoluteRect.top}get _limiterIntersectionArea(){const t=this._options.limiterRect;if(t){const e=this._options.viewportRect;if(!e)return t.getIntersectionArea(this._rect);{const n=t.getIntersection(e);if(n)return n.getIntersectionArea(this._rect)}}return 0}get _viewportIntersectionArea(){const t=this._options.viewportRect;return t?t.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=Nu(this._rect),this._options.positionedElementAncestor&&function(t,e){const n=Nu(new ya(e)),o=Aa(e);let i=0,r=0;i-=n.left,r-=n.top,i+=e.scrollLeft,r+=e.scrollTop,i-=o.left,r-=o.top,t.moveBy(i,r)}(this._cachedAbsoluteRect,this._options.positionedElementAncestor)),this._cachedAbsoluteRect}}class Mu extends Od{constructor(t,e,n){super(t);const o=this.bindTemplate;this.buttonView=e,this.panelView=n,this.set("isOpen",!1),this.set("isEnabled",!0),this.set("class"),this.set("id"),this.set("panelPosition","auto"),this.keystrokes=new Ia,this.setTemplate({tag:"div",attributes:{class:["ck","ck-dropdown",o.to("class"),o.if("isEnabled","ck-disabled",(t=>!t))],id:o.to("id"),"aria-describedby":o.to("ariaDescribedById")},children:[e,n]}),e.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=Mu._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 t=(t,e)=>{this.isOpen&&(this.buttonView.focus(),this.isOpen=!1,e())};this.keystrokes.set("arrowdown",((t,e)=>{this.buttonView.isEnabled&&!this.isOpen&&(this.isOpen=!0,e())})),this.keystrokes.set("arrowright",((t,e)=>{this.isOpen&&e()})),this.keystrokes.set("arrowleft",t),this.keystrokes.set("esc",t)}focus(){this.buttonView.focus()}get _panelPositions(){const{south:t,north:e,southEast:n,southWest:o,northEast:i,northWest:r,southMiddleEast:s,southMiddleWest:a,northMiddleEast:c,northMiddleWest:l}=Mu.defaultPanelPositions;return"rtl"!==this.locale.uiLanguageDirection?[n,o,s,a,t,i,r,c,l,e]:[o,n,a,s,t,r,i,l,c,e]}}Mu.defaultPanelPositions={south:(t,e)=>({top:t.bottom,left:t.left-(e.width-t.width)/2,name:"s"}),southEast:t=>({top:t.bottom,left:t.left,name:"se"}),southWest:(t,e)=>({top:t.bottom,left:t.left-e.width+t.width,name:"sw"}),southMiddleEast:(t,e)=>({top:t.bottom,left:t.left-(e.width-t.width)/4,name:"sme"}),southMiddleWest:(t,e)=>({top:t.bottom,left:t.left-3*(e.width-t.width)/4,name:"smw"}),north:(t,e)=>({top:t.top-e.height,left:t.left-(e.width-t.width)/2,name:"n"}),northEast:(t,e)=>({top:t.top-e.height,left:t.left,name:"ne"}),northWest:(t,e)=>({top:t.top-e.height,left:t.left-e.width+t.width,name:"nw"}),northMiddleEast:(t,e)=>({top:t.top-e.height,left:t.left-(e.width-t.width)/4,name:"nme"}),northMiddleWest:(t,e)=>({top:t.top-e.height,left:t.left-3*(e.width-t.width)/4,name:"nmw"})},Mu._getOptimalPosition=Fu;class Vu extends Od{constructor(t){super(t),this.setTemplate({tag:"span",attributes:{class:["ck","ck-toolbar__separator"]}})}}class Lu extends Od{constructor(t){super(t),this.setTemplate({tag:"span",attributes:{class:["ck","ck-toolbar__line-break"]}})}}var Hu=n(5571),qu={attributes:{"data-cke":!0}};qu.setAttributes=is(),qu.insert=ns().bind(null,"head"),qu.domAPI=ts(),qu.insertStyleElement=ss();Qr()(Hu.Z,qu);Hu.Z&&Hu.Z.locals&&Hu.Z.locals;class Wu extends Od{constructor(t,e){super(t);const n=this.bindTemplate,o=this.t;this.options=e||{},this.set("ariaLabel",o("Editor toolbar")),this.set("maxWidth","auto"),this.items=this.createCollection(),this.focusTracker=new Pa,this.keystrokes=new Ia,this.set("class"),this.set("isCompact",!1),this.itemsView=new ju(t),this.children=this.createCollection(),this.children.add(this.itemsView),this.focusables=this.createCollection();const i="rtl"===t.uiLanguageDirection;this._focusCycler=new Au({focusables:this.focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:[i?"arrowright":"arrowleft","arrowup"],focusNext:[i?"arrowleft":"arrowright","arrowdown"]}});const r=["ck","ck-toolbar",n.to("class"),n.if("isCompact","ck-toolbar_compact")];var s;this.options.shouldGroupWhenFull&&this.options.isFloating&&r.push("ck-toolbar_floating"),this.setTemplate({tag:"div",attributes:{class:r,role:"toolbar","aria-label":n.to("ariaLabel"),style:{maxWidth:n.to("maxWidth")}},children:this.children,on:{mousedown:(s=this,s.bindTemplate.to((t=>{t.target===s.element&&t.preventDefault()})))}}),this._behavior=this.options.shouldGroupWhenFull?new $u(this):new Uu(this)}render(){super.render();for(const t of this.items)this.focusTracker.add(t.element);this.items.on("add",((t,e)=>{this.focusTracker.add(e.element)})),this.items.on("remove",((t,e)=>{this.focusTracker.remove(e.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(t,e){const n=function(t){return Array.isArray(t)?{items:t,removeItems:[]}:t?Object.assign({items:[],removeItems:[]},t):{items:[],removeItems:[]}}(t),o=n.items.filter(((t,o,i)=>"|"===t||-1===n.removeItems.indexOf(t)&&("-"===t?!this.options.shouldGroupWhenFull||(a("toolbarview-line-break-ignored-when-grouping-items",i),!1):!!e.has(t)||(a("toolbarview-item-unavailable",{name:t}),!1)))),i=this._cleanSeparators(o).map((t=>"|"===t?new Vu:"-"===t?new Lu:e.create(t)));this.items.addMany(i)}_cleanSeparators(t){const e=t=>"-"!==t&&"|"!==t,n=t.length,o=t.findIndex(e),i=n-t.slice().reverse().findIndex(e);return t.slice(o,i).filter(((t,n,o)=>{if(e(t))return!0;return!(n>0&&o[n-1]===t)}))}}class ju extends Od{constructor(t){super(t),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-toolbar__items"]},children:this.children})}}class Uu{constructor(t){const e=t.bindTemplate;t.set("isVertical",!1),t.itemsView.children.bindTo(t.items).using((t=>t)),t.focusables.bindTo(t.items).using((t=>t)),t.extendTemplate({attributes:{class:[e.if("isVertical","ck-toolbar_vertical")]}})}render(){}destroy(){}}class $u{constructor(t){this.view=t,this.viewChildren=t.children,this.viewFocusables=t.focusables,this.viewItemsView=t.itemsView,this.viewFocusTracker=t.focusTracker,this.viewLocale=t.locale,this.ungroupedItems=t.createCollection(),this.groupedItems=t.createCollection(),this.groupedItemsDropdown=this._createGroupedItemsDropdown(),this.resizeObserver=null,this.cachedPadding=null,this.shouldUpdateGroupingOnNextResize=!1,t.itemsView.children.bindTo(this.ungroupedItems).using((t=>t)),this.ungroupedItems.on("add",this._updateFocusCycleableItems.bind(this)),this.ungroupedItems.on("remove",this._updateFocusCycleableItems.bind(this)),t.children.on("add",this._updateFocusCycleableItems.bind(this)),t.children.on("remove",this._updateFocusCycleableItems.bind(this)),t.items.on("change",((t,e)=>{const n=e.index;for(const t of e.removed)n>=this.ungroupedItems.length?this.groupedItems.remove(t):this.ungroupedItems.remove(t);for(let t=n;tthis.ungroupedItems.length?this.groupedItems.add(o,t-this.ungroupedItems.length):this.ungroupedItems.add(o,t)}this._updateGrouping()})),t.extendTemplate({attributes:{class:["ck-toolbar_grouping"]}})}render(t){this.viewElement=t.element,this._enableGroupingOnResize(),this._enableGroupingOnMaxWidthChange(t)}destroy(){this.groupedItemsDropdown.destroy(),this.resizeObserver.destroy()}_updateGrouping(){if(!this.viewElement.ownerDocument.body.contains(this.viewElement))return;if(!Cu(this.viewElement))return void(this.shouldUpdateGroupingOnNextResize=!0);const t=this.groupedItems.length;let e;for(;this._areItemsOverflowing;)this._groupLastItem(),e=!0;if(!e&&this.groupedItems.length){for(;this.groupedItems.length&&!this._areItemsOverflowing;)this._ungroupFirstItem();this._areItemsOverflowing&&this._groupLastItem()}this.groupedItems.length!==t&&this.view.fire("groupedItemsUpdate")}get _areItemsOverflowing(){if(!this.ungroupedItems.length)return!1;const t=this.viewElement,e=this.viewLocale.uiLanguageDirection,n=new ya(t.lastChild),o=new ya(t);if(!this.cachedPadding){const n=ps.window.getComputedStyle(t),o="ltr"===e?"paddingRight":"paddingLeft";this.cachedPadding=Number.parseInt(n[o])}return"ltr"===e?n.right>o.right-this.cachedPadding:n.left{t&&t===e.contentRect.width&&!this.shouldUpdateGroupingOnNextResize||(this.shouldUpdateGroupingOnNextResize=!1,this._updateGrouping(),t=e.contentRect.width)})),this._updateGrouping()}_enableGroupingOnMaxWidthChange(t){t.on("change:maxWidth",(()=>{this._updateGrouping()}))}_groupLastItem(){this.groupedItems.length||(this.viewChildren.add(new Vu),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 t=this.viewLocale,e=t.t,n=nh(t);return n.class="ck-toolbar__grouped-dropdown",n.panelPosition="ltr"===t.uiLanguageDirection?"sw":"se",oh(n,[]),n.buttonView.set({label:e("Show more items"),tooltip:!0,tooltipPosition:"rtl"===t.uiLanguageDirection?"se":"sw",icon:Bd}),n.toolbarView.items.bindTo(this.groupedItems).using((t=>t)),n}_updateFocusCycleableItems(){this.viewFocusables.clear(),this.ungroupedItems.map((t=>{this.viewFocusables.add(t)})),this.groupedItems.length&&this.viewFocusables.add(this.groupedItemsDropdown)}}var Gu=n(1162),Ku={attributes:{"data-cke":!0}};Ku.setAttributes=is(),Ku.insert=ns().bind(null,"head"),Ku.domAPI=ts(),Ku.insertStyleElement=ss();Qr()(Gu.Z,Ku);Gu.Z&&Gu.Z.locals&&Gu.Z.locals;class Zu extends Od{constructor(){super(),this.items=this.createCollection(),this.focusTracker=new Pa,this.keystrokes=new Ia,this._focusCycler=new Au({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 t of this.items)this.focusTracker.add(t.element);this.items.on("add",((t,e)=>{this.focusTracker.add(e.element)})),this.items.on("remove",((t,e)=>{this.focusTracker.remove(e.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}}class Ju extends Od{constructor(t){super(t),this.children=this.createCollection(),this.setTemplate({tag:"li",attributes:{class:["ck","ck-list__item"]},children:this.children})}focus(){this.children.first.focus()}}class Yu extends Od{constructor(t){super(t),this.setTemplate({tag:"li",attributes:{class:["ck","ck-list__separator"]}})}}var Qu=n(5075),Xu={attributes:{"data-cke":!0}};Xu.setAttributes=is(),Xu.insert=ns().bind(null,"head"),Xu.domAPI=ts(),Xu.insertStyleElement=ss();Qr()(Qu.Z,Xu);Qu.Z&&Qu.Z.locals&&Qu.Z.locals;var th=n(6875),eh={attributes:{"data-cke":!0}};eh.setAttributes=is(),eh.insert=ns().bind(null,"head"),eh.domAPI=ts(),eh.insertStyleElement=ss();Qr()(th.Z,eh);th.Z&&th.Z.locals&&th.Z.locals;function nh(t,e=Su){const n=new e(t),o=new Iu(t),i=new Mu(t,n,o);return n.bind("isEnabled").to(i),n instanceof Su?n.bind("isOn").to(i,"isOpen"):n.arrowView.bind("isOn").to(i,"isOpen"),function(t){(function(t){t.on("render",(()=>{Pd({emitter:t,activator:()=>t.isOpen,callback:()=>{t.isOpen=!1},contextElements:[t.element]})}))})(t),function(t){t.on("execute",(e=>{e.source instanceof fu||(t.isOpen=!1)}))}(t),function(t){t.keystrokes.set("arrowdown",((e,n)=>{t.isOpen&&(t.panelView.focus(),n())})),t.keystrokes.set("arrowup",((e,n)=>{t.isOpen&&(t.panelView.focusLast(),n())}))}(t)}(i),i}function oh(t,e){const n=t.locale,o=n.t,i=t.toolbarView=new Wu(n);i.set("ariaLabel",o("Dropdown toolbar")),t.extendTemplate({attributes:{class:["ck-toolbar-dropdown"]}}),e.map((t=>i.items.add(t))),t.panelView.children.add(i),i.items.delegate("execute").to(t)}function ih(t,e){const n=t.locale,o=t.listView=new Zu(n);o.items.bindTo(e).using((({type:t,model:e})=>{if("separator"===t)return new Yu(n);if("button"===t||"switchbutton"===t){const o=new Ju(n);let i;return i="button"===t?new pu(n):new fu(n),i.bind(...Object.keys(e)).to(e),i.delegate("execute").to(o),o.children.add(i),o}})),t.panelView.children.add(o),o.items.delegate("execute").to(t)}var rh=n(4547),sh={attributes:{"data-cke":!0}};sh.setAttributes=is(),sh.insert=ns().bind(null,"head"),sh.domAPI=ts(),sh.insertStyleElement=ss();Qr()(rh.Z,sh);rh.Z&&rh.Z.locals&&rh.Z.locals;class ah extends Od{constructor(t){super(t),this.body=new iu(t)}render(){super.render(),this.body.attachToDom()}destroy(){return this.body.detachFromDom(),super.destroy()}}var ch=n(2751),lh={attributes:{"data-cke":!0}};lh.setAttributes=is(),lh.insert=ns().bind(null,"head"),lh.domAPI=ts(),lh.insertStyleElement=ss();Qr()(ch.Z,lh);ch.Z&&ch.Z.locals&&ch.Z.locals;class dh extends Od{constructor(t){super(t),this.set("text"),this.set("for"),this.id=`ck-editor__label_${i()}`;const e=this.bindTemplate;this.setTemplate({tag:"label",attributes:{class:["ck","ck-label"],id:this.id,for:e.to("for")},children:[{text:e.to("text")}]})}}class uh extends Od{constructor(t,e,n){super(t),this.setTemplate({tag:"div",attributes:{class:["ck","ck-content","ck-editor__editable","ck-rounded-corners"],lang:t.contentLanguage,dir:t.contentLanguageDirection}}),this.name=null,this.set("isFocused",!1),this._editableElement=n,this._hasExternalElement=!!this._editableElement,this._editingView=e}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 t=this._editingView;function e(e){t.change((n=>{const o=t.document.getRoot(e.name);n.addClass(e.isFocused?"ck-focused":"ck-blurred",o),n.removeClass(e.isFocused?"ck-blurred":"ck-focused",o)}))}t.isRenderingInProgress?function n(o){t.once("change:isRenderingInProgress",((t,i,r)=>{r?n(o):e(o)}))}(this):e(this)}}class hh extends uh{constructor(t,e,n){super(t,e,n),this.extendTemplate({attributes:{role:"textbox",class:"ck-editor__editable_inline"}})}render(){super.render();const t=this._editingView,e=this.t;t.change((n=>{const o=t.document.getRoot(this.name);n.setAttribute("aria-label",e("Rich Text Editor, %0",this.name),o)}))}}var ph=n(5523),mh={attributes:{"data-cke":!0}};mh.setAttributes=is(),mh.insert=ns().bind(null,"head"),mh.domAPI=ts(),mh.insertStyleElement=ss();Qr()(ph.Z,mh);ph.Z&&ph.Z.locals&&ph.Z.locals;class gh extends Od{constructor(t,e={}){super(t);const n=this.bindTemplate;this.set("label",e.label||""),this.set("class",e.class||null),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-form__header",n.to("class")]},children:this.children});const o=new Od(t);o.setTemplate({tag:"span",attributes:{class:["ck","ck-form__header__label"]},children:[{text:n.to("label")}]}),this.children.add(o)}}var fh=n(6985),bh={attributes:{"data-cke":!0}};bh.setAttributes=is(),bh.insert=ns().bind(null,"head"),bh.domAPI=ts(),bh.insertStyleElement=ss();Qr()(fh.Z,bh);fh.Z&&fh.Z.locals&&fh.Z.locals;class kh extends Od{constructor(t){super(t),this.set("value"),this.set("id"),this.set("placeholder"),this.set("isReadOnly",!1),this.set("hasError",!1),this.set("ariaDescribedById"),this.focusTracker=new Pa,this.bind("isFocused").to(this.focusTracker),this.set("isEmpty",!0),this.set("inputMode","text");const e=this.bindTemplate;this.setTemplate({tag:"input",attributes:{class:["ck","ck-input",e.if("isFocused","ck-input_focused"),e.if("isEmpty","ck-input-text_empty"),e.if("hasError","ck-error")],id:e.to("id"),placeholder:e.to("placeholder"),readonly:e.to("isReadOnly"),inputmode:e.to("inputMode"),"aria-invalid":e.if("hasError",!0),"aria-describedby":e.to("ariaDescribedById")},on:{input:e.to(((...t)=>{this.fire("input",...t),this._updateIsEmpty()})),change:e.to(this._updateIsEmpty.bind(this))}})}render(){super.render(),this.focusTracker.add(this.element),this._setDomElementValue(this.value),this._updateIsEmpty(),this.on("change:value",((t,e,n)=>{this._setDomElementValue(n),this._updateIsEmpty()}))}destroy(){super.destroy(),this.focusTracker.destroy()}select(){this.element.select()}focus(){this.element.focus()}_updateIsEmpty(){this.isEmpty=!this.element.value}_setDomElementValue(t){this.element.value=t||0===t?t:""}}class wh extends kh{constructor(t){super(t),this.extendTemplate({attributes:{type:"text",class:["ck-input-text"]}})}}var _h=n(8111),Ch={attributes:{"data-cke":!0}};Ch.setAttributes=is(),Ch.insert=ns().bind(null,"head"),Ch.domAPI=ts(),Ch.insertStyleElement=ss();Qr()(_h.Z,Ch);_h.Z&&_h.Z.locals&&_h.Z.locals;class Ah extends Od{constructor(t,e){super(t);const n=`ck-labeled-field-view-${i()}`,o=`ck-labeled-field-view-status-${i()}`;this.fieldView=e(this,n,o),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(n),this.statusView=this._createStatusView(o),this.bind("_statusText").to(this,"errorText",this,"infoText",((t,e)=>t||e));const r=this.bindTemplate;this.setTemplate({tag:"div",attributes:{class:["ck","ck-labeled-field-view",r.to("class"),r.if("isEnabled","ck-disabled",(t=>!t)),r.if("isEmpty","ck-labeled-field-view_empty"),r.if("isFocused","ck-labeled-field-view_focused"),r.if("placeholder","ck-labeled-field-view_placeholder"),r.if("errorText","ck-error")]},children:[{tag:"div",attributes:{class:["ck","ck-labeled-field-view__input-wrapper"]},children:[this.fieldView,this.labelView]},this.statusView]})}_createLabelView(t){const e=new dh(this.locale);return e.for=t,e.bind("text").to(this,"label"),e}_createStatusView(t){const e=new Od(this.locale),n=this.bindTemplate;return e.setTemplate({tag:"div",attributes:{class:["ck","ck-labeled-field-view__status",n.if("errorText","ck-labeled-field-view__status_error"),n.if("_statusText","ck-hidden",(t=>!t))],id:t,role:n.if("errorText","alert")},children:[{text:n.to("_statusText")}]}),e}focus(){this.fieldView.focus()}}function vh(t,e,n){const o=new wh(t.locale);return o.set({id:e,ariaDescribedById:n}),o.bind("isReadOnly").to(t,"isEnabled",(t=>!t)),o.bind("hasError").to(t,"errorText",(t=>!!t)),o.on("input",(()=>{t.errorText=null})),t.bind("isEmpty","isFocused","placeholder").to(o),o}function yh(t,e,n){const o=nh(t.locale);return o.set({id:e,ariaDescribedById:n}),o.bind("isEnabled").to(t),o}class xh extends No{static get pluginName(){return"Notification"}init(){this.on("show:warning",((t,e)=>{window.alert(e.message)}),{priority:"lowest"})}showSuccess(t,e={}){this._showNotification({message:t,type:"success",namespace:e.namespace,title:e.title})}showInfo(t,e={}){this._showNotification({message:t,type:"info",namespace:e.namespace,title:e.title})}showWarning(t,e={}){this._showNotification({message:t,type:"warning",namespace:e.namespace,title:e.title})}_showNotification(t){const e=`show:${t.type}`+(t.namespace?`:${t.namespace}`:"");this.fire(e,{message:t.message,type:t.type,title:t.title||""})}}class Eh{constructor(t,e){e&&Xt(this,e),t&&this.set(t)}}function Dh(t){return e=>e+t}he(Eh,se);var Sh=n(8245),Bh={attributes:{"data-cke":!0}};Bh.setAttributes=is(),Bh.insert=ns().bind(null,"head"),Bh.domAPI=ts(),Bh.insertStyleElement=ss();Qr()(Sh.Z,Bh);Sh.Z&&Sh.Z.locals&&Sh.Z.locals;const Th=Dh("px"),Ph=ps.document.body;class Ih extends Od{constructor(t){super(t);const e=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",e.to("position",(t=>`ck-balloon-panel_${t}`)),e.if("isVisible","ck-balloon-panel_visible"),e.if("withArrow","ck-balloon-panel_with-arrow"),e.to("class")],style:{top:e.to("top",Th),left:e.to("left",Th)}},children:this.content})}show(){this.isVisible=!0}hide(){this.isVisible=!1}attachTo(t){this.show();const e=Ih.defaultPositions,n=Object.assign({},{element:this.element,positions:[e.southArrowNorth,e.southArrowNorthMiddleWest,e.southArrowNorthMiddleEast,e.southArrowNorthWest,e.southArrowNorthEast,e.northArrowSouth,e.northArrowSouthMiddleWest,e.northArrowSouthMiddleEast,e.northArrowSouthWest,e.northArrowSouthEast,e.viewportStickyNorth],limiter:Ph,fitInViewport:!0},t),o=Ih._getOptimalPosition(n),i=parseInt(o.left),r=parseInt(o.top),{name:s,config:a={}}=o,{withArrow:c=!0}=a;Object.assign(this,{top:r,left:i,position:s,withArrow:c})}pin(t){this.unpin(),this._pinWhenIsVisibleCallback=()=>{this.isVisible?this._startPinning(t):this._stopPinning()},this._startPinning(t),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(t){this.attachTo(t);const e=Rh(t.target),n=t.limiter?Rh(t.limiter):Ph;this.listenTo(ps.document,"scroll",((o,i)=>{const r=i.target,s=e&&r.contains(e),a=n&&r.contains(n);!s&&!a&&e&&n||this.attachTo(t)}),{useCapture:!0}),this.listenTo(ps.window,"resize",(()=>{this.attachTo(t)}))}_stopPinning(){this.stopListening(ps.document,"scroll"),this.stopListening(ps.window,"resize")}}function Rh(t){return vo(t)?t:Ca(t)?t.commonAncestorContainer:"function"==typeof t?Rh(t()):null}Ih.arrowHorizontalOffset=25,Ih.arrowVerticalOffset=10,Ih.stickyVerticalOffset=20,Ih._getOptimalPosition=Fu,Ih.defaultPositions=function({horizontalOffset:t=Ih.arrowHorizontalOffset,verticalOffset:e=Ih.arrowVerticalOffset,stickyVerticalOffset:n=Ih.stickyVerticalOffset,config:o}={}){return{northWestArrowSouthWest:(e,n)=>({top:i(e,n),left:e.left-t,name:"arrow_sw",...o&&{config:o}}),northWestArrowSouthMiddleWest:(e,n)=>({top:i(e,n),left:e.left-.25*n.width-t,name:"arrow_smw",...o&&{config:o}}),northWestArrowSouth:(t,e)=>({top:i(t,e),left:t.left-e.width/2,name:"arrow_s",...o&&{config:o}}),northWestArrowSouthMiddleEast:(e,n)=>({top:i(e,n),left:e.left-.75*n.width+t,name:"arrow_sme",...o&&{config:o}}),northWestArrowSouthEast:(e,n)=>({top:i(e,n),left:e.left-n.width+t,name:"arrow_se",...o&&{config:o}}),northArrowSouthWest:(e,n)=>({top:i(e,n),left:e.left+e.width/2-t,name:"arrow_sw",...o&&{config:o}}),northArrowSouthMiddleWest:(e,n)=>({top:i(e,n),left:e.left+e.width/2-.25*n.width-t,name:"arrow_smw",...o&&{config:o}}),northArrowSouth:(t,e)=>({top:i(t,e),left:t.left+t.width/2-e.width/2,name:"arrow_s",...o&&{config:o}}),northArrowSouthMiddleEast:(e,n)=>({top:i(e,n),left:e.left+e.width/2-.75*n.width+t,name:"arrow_sme",...o&&{config:o}}),northArrowSouthEast:(e,n)=>({top:i(e,n),left:e.left+e.width/2-n.width+t,name:"arrow_se",...o&&{config:o}}),northEastArrowSouthWest:(e,n)=>({top:i(e,n),left:e.right-t,name:"arrow_sw",...o&&{config:o}}),northEastArrowSouthMiddleWest:(e,n)=>({top:i(e,n),left:e.right-.25*n.width-t,name:"arrow_smw",...o&&{config:o}}),northEastArrowSouth:(t,e)=>({top:i(t,e),left:t.right-e.width/2,name:"arrow_s",...o&&{config:o}}),northEastArrowSouthMiddleEast:(e,n)=>({top:i(e,n),left:e.right-.75*n.width+t,name:"arrow_sme",...o&&{config:o}}),northEastArrowSouthEast:(e,n)=>({top:i(e,n),left:e.right-n.width+t,name:"arrow_se",...o&&{config:o}}),southWestArrowNorthWest:(e,n)=>({top:r(e),left:e.left-t,name:"arrow_nw",...o&&{config:o}}),southWestArrowNorthMiddleWest:(e,n)=>({top:r(e),left:e.left-.25*n.width-t,name:"arrow_nmw",...o&&{config:o}}),southWestArrowNorth:(t,e)=>({top:r(t),left:t.left-e.width/2,name:"arrow_n",...o&&{config:o}}),southWestArrowNorthMiddleEast:(e,n)=>({top:r(e),left:e.left-.75*n.width+t,name:"arrow_nme",...o&&{config:o}}),southWestArrowNorthEast:(e,n)=>({top:r(e),left:e.left-n.width+t,name:"arrow_ne",...o&&{config:o}}),southArrowNorthWest:(e,n)=>({top:r(e),left:e.left+e.width/2-t,name:"arrow_nw",...o&&{config:o}}),southArrowNorthMiddleWest:(e,n)=>({top:r(e),left:e.left+e.width/2-.25*n.width-t,name:"arrow_nmw",...o&&{config:o}}),southArrowNorth:(t,e)=>({top:r(t),left:t.left+t.width/2-e.width/2,name:"arrow_n",...o&&{config:o}}),southArrowNorthMiddleEast:(e,n)=>({top:r(e),left:e.left+e.width/2-.75*n.width+t,name:"arrow_nme",...o&&{config:o}}),southArrowNorthEast:(e,n)=>({top:r(e),left:e.left+e.width/2-n.width+t,name:"arrow_ne",...o&&{config:o}}),southEastArrowNorthWest:(e,n)=>({top:r(e),left:e.right-t,name:"arrow_nw",...o&&{config:o}}),southEastArrowNorthMiddleWest:(e,n)=>({top:r(e),left:e.right-.25*n.width-t,name:"arrow_nmw",...o&&{config:o}}),southEastArrowNorth:(t,e)=>({top:r(t),left:t.right-e.width/2,name:"arrow_n",...o&&{config:o}}),southEastArrowNorthMiddleEast:(e,n)=>({top:r(e),left:e.right-.75*n.width+t,name:"arrow_nme",...o&&{config:o}}),southEastArrowNorthEast:(e,n)=>({top:r(e),left:e.right-n.width+t,name:"arrow_ne",...o&&{config:o}}),viewportStickyNorth:(t,e,i)=>t.getIntersection(i)?{top:i.top+n,left:t.left+t.width/2-e.width/2,name:"arrowless",config:{withArrow:!1,...o}}:null};function i(t,n){return t.top-n.height-e}function r(t){return t.bottom+e}}();var zh=n(1757),Fh={attributes:{"data-cke":!0}};Fh.setAttributes=is(),Fh.insert=ns().bind(null,"head"),Fh.domAPI=ts(),Fh.insertStyleElement=ss();Qr()(zh.Z,Fh);zh.Z&&zh.Z.locals&&zh.Z.locals;var Nh=n(3553),Oh={attributes:{"data-cke":!0}};Oh.setAttributes=is(),Oh.insert=ns().bind(null,"head"),Oh.domAPI=ts(),Oh.insertStyleElement=ss();Qr()(Nh.Z,Oh);Nh.Z&&Nh.Z.locals&&Nh.Z.locals;const Mh=Dh("px");class Vh extends pe{static get pluginName(){return"ContextualBalloon"}constructor(t){super(t),this.positionLimiter=()=>{const t=this.editor.editing.view,e=t.document.selection.editableElement;return e?t.domConverter.mapViewToDom(e.root):null},this.set("visibleView",null),this.view=new Ih(t.locale),t.ui.view.body.add(this.view),t.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(t){return Array.from(this._viewToStack.keys()).includes(t)}add(t){if(this.hasView(t.view))throw new s("contextualballoon-add-view-exist",[this,t]);const e=t.stackId||"main";if(!this._idToStack.has(e))return this._idToStack.set(e,new Map([[t.view,t]])),this._viewToStack.set(t.view,this._idToStack.get(e)),this._numberOfStacks=this._idToStack.size,void(this._visibleStack&&!t.singleViewMode||this.showStack(e));const n=this._idToStack.get(e);t.singleViewMode&&this.showStack(e),n.set(t.view,t),this._viewToStack.set(t.view,n),n===this._visibleStack&&this._showView(t)}remove(t){if(!this.hasView(t))throw new s("contextualballoon-remove-view-not-exist",[this,t]);const e=this._viewToStack.get(t);this._singleViewMode&&this.visibleView===t&&(this._singleViewMode=!1),this.visibleView===t&&(1===e.size?this._idToStack.size>1?this._showNextStack():(this.view.hide(),this.visibleView=null,this._rotatorView.hideView()):this._showView(Array.from(e.values())[e.size-2])),1===e.size?(this._idToStack.delete(this._getStackId(e)),this._numberOfStacks=this._idToStack.size):e.delete(t),this._viewToStack.delete(t)}updatePosition(t){t&&(this._visibleStack.get(this.visibleView).position=t),this.view.pin(this._getBalloonPosition()),this._fakePanelsView.updatePosition()}showStack(t){this.visibleStack=t;const e=this._idToStack.get(t);if(!e)throw new s("contextualballoon-showstack-stack-not-exist",this);this._visibleStack!==e&&this._showView(Array.from(e.values()).pop())}get _visibleStack(){return this._viewToStack.get(this.visibleView)}_getStackId(t){return Array.from(this._idToStack.entries()).find((e=>e[1]===t))[0]}_showNextStack(){const t=Array.from(this._idToStack.values());let e=t.indexOf(this._visibleStack)+1;t[e]||(e=0),this.showStack(this._getStackId(t[e]))}_showPrevStack(){const t=Array.from(this._idToStack.values());let e=t.indexOf(this._visibleStack)-1;t[e]||(e=t.length-1),this.showStack(this._getStackId(t[e]))}_createRotatorView(){const t=new Lh(this.editor.locale),e=this.editor.locale.t;return this.view.content.add(t),t.bind("isNavigationVisible").to(this,"_numberOfStacks",this,"_singleViewMode",((t,e)=>!e&&t>1)),t.on("change:isNavigationVisible",(()=>this.updatePosition()),{priority:"low"}),t.bind("counter").to(this,"visibleView",this,"_numberOfStacks",((t,n)=>{if(n<2)return"";const o=Array.from(this._idToStack.values()).indexOf(this._visibleStack)+1;return e("%0 of %1",[o,n])})),t.buttonNextView.on("execute",(()=>{t.focusTracker.isFocused&&this.editor.editing.view.focus(),this._showNextStack()})),t.buttonPrevView.on("execute",(()=>{t.focusTracker.isFocused&&this.editor.editing.view.focus(),this._showPrevStack()})),t}_createFakePanelsView(){const t=new Hh(this.editor.locale,this.view);return t.bind("numberOfPanels").to(this,"_numberOfStacks",this,"_singleViewMode",((t,e)=>!e&&t>=2?Math.min(t-1,2):0)),t.listenTo(this.view,"change:top",(()=>t.updatePosition())),t.listenTo(this.view,"change:left",(()=>t.updatePosition())),this.editor.ui.view.body.add(t),t}_showView({view:t,balloonClassName:e="",withArrow:n=!0,singleViewMode:o=!1}){this.view.class=e,this.view.withArrow=n,this._rotatorView.showView(t),this.visibleView=t,this.view.pin(this._getBalloonPosition()),this._fakePanelsView.updatePosition(),o&&(this._singleViewMode=!0)}_getBalloonPosition(){let t=Array.from(this._visibleStack.values()).pop().position;return t&&(t.limiter||(t=Object.assign({},t,{limiter:this.positionLimiter})),t=Object.assign({},t,{viewportOffsetConfig:this.editor.ui.viewportOffset})),t}}class Lh extends Od{constructor(t){super(t);const e=t.t,n=this.bindTemplate;this.set("isNavigationVisible",!0),this.focusTracker=new Pa,this.buttonPrevView=this._createButtonView(e("Previous"),''),this.buttonNextView=this._createButtonView(e("Next"),''),this.content=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-balloon-rotator"],"z-index":"-1"},children:[{tag:"div",attributes:{class:["ck-balloon-rotator__navigation",n.to("isNavigationVisible",(t=>t?"":"ck-hidden"))]},children:[this.buttonPrevView,{tag:"span",attributes:{class:["ck-balloon-rotator__counter"]},children:[{text:n.to("counter")}]},this.buttonNextView]},{tag:"div",attributes:{class:"ck-balloon-rotator__content"},children:this.content}]})}render(){super.render(),this.focusTracker.add(this.element)}destroy(){super.destroy(),this.focusTracker.destroy()}showView(t){this.hideView(),this.content.add(t)}hideView(){this.content.clear()}_createButtonView(t,e){const n=new pu(this.locale);return n.set({label:t,icon:e,tooltip:!0}),n}}class Hh extends Od{constructor(t,e){super(t);const n=this.bindTemplate;this.set("top",0),this.set("left",0),this.set("height",0),this.set("width",0),this.set("numberOfPanels",0),this.content=this.createCollection(),this._balloonPanelView=e,this.setTemplate({tag:"div",attributes:{class:["ck-fake-panel",n.to("numberOfPanels",(t=>t?"":"ck-hidden"))],style:{top:n.to("top",Mh),left:n.to("left",Mh),width:n.to("width",Mh),height:n.to("height",Mh)}},children:this.content}),this.on("change:numberOfPanels",((t,e,n,o)=>{n>o?this._addPanels(n-o):this._removePanels(o-n),this.updatePosition()}))}_addPanels(t){for(;t--;){const t=new Od;t.setTemplate({tag:"div"}),this.content.add(t),this.registerChild(t)}}_removePanels(t){for(;t--;){const t=this.content.last;this.content.remove(t),this.deregisterChild(t),t.destroy()}}updatePosition(){if(this.numberOfPanels){const{top:t,left:e}=this._balloonPanelView,{width:n,height:o}=new ya(this._balloonPanelView.element);Object.assign(this,{top:t,left:e,width:n,height:o})}}}var qh=n(3609),Wh={attributes:{"data-cke":!0}};Wh.setAttributes=is(),Wh.insert=ns().bind(null,"head"),Wh.domAPI=ts(),Wh.insertStyleElement=ss();Qr()(qh.Z,Wh);qh.Z&&qh.Z.locals&&qh.Z.locals,Dh("px");Dh("px");var jh=n(6706),Uh={attributes:{"data-cke":!0}};Uh.setAttributes=is(),Uh.insert=ns().bind(null,"head"),Uh.domAPI=ts(),Uh.insertStyleElement=ss();Qr()(jh.Z,Uh);jh.Z&&jh.Z.locals&&jh.Z.locals,Dh("px");Dh("px");var $h=n(8894),Gh={attributes:{"data-cke":!0}};Gh.setAttributes=is(),Gh.insert=ns().bind(null,"head"),Gh.domAPI=ts(),Gh.insertStyleElement=ss();Qr()($h.Z,Gh);$h.Z&&$h.Z.locals&&$h.Z.locals;const Kh=new WeakMap;function Zh(t){const{view:e,element:n,text:o,isDirectHost:i=!0,keepOnFocus:r=!1}=t,s=e.document;Kh.has(s)||(Kh.set(s,new Map),s.registerPostFixer((t=>Yh(s,t)))),Kh.get(s).set(n,{text:o,isDirectHost:i,keepOnFocus:r,hostElement:i?n:null}),e.change((t=>Yh(s,t)))}function Jh(t,e){return!!e.hasClass("ck-placeholder")&&(t.removeClass("ck-placeholder",e),!0)}function Yh(t,e){const n=Kh.get(t),o=[];let i=!1;for(const[t,r]of n)r.isDirectHost&&(o.push(t),Qh(e,t,r)&&(i=!0));for(const[t,r]of n){if(r.isDirectHost)continue;const n=Xh(t);n&&(o.includes(n)||(r.hostElement=n,Qh(e,t,r)&&(i=!0)))}return i}function Qh(t,e,n){const{text:o,isDirectHost:i,hostElement:r}=n;let s=!1;r.getAttribute("data-placeholder")!==o&&(t.setAttribute("data-placeholder",o,r),s=!0);return(i||1==e.childCount)&&function(t,e){if(!t.isAttached())return!1;const n=Array.from(t.getChildren()).some((t=>!t.is("uiElement")));if(n)return!1;if(e)return!0;const o=t.document;if(!o.isFocused)return!0;const i=o.selection.anchor;return i&&i.parent!==t}(r,n.keepOnFocus)?function(t,e){return!e.hasClass("ck-placeholder")&&(t.addClass("ck-placeholder",e),!0)}(t,r)&&(s=!0):Jh(t,r)&&(s=!0),s}function Xh(t){if(t.childCount){const e=t.getChild(0);if(e.is("element")&&!e.is("uiElement"))return e}return null}const tp=new Map;function ep(t,e,n){let o=tp.get(t);o||(o=new Map,tp.set(t,o)),o.set(e,n)}function np(t){return[t]}function op(t,e,n={}){const o=function(t,e){const n=tp.get(t);return n&&n.has(e)?n.get(e):np}(t.constructor,e.constructor);try{return o(t=t.clone(),e,n)}catch(t){throw t}}function ip(t,e,n){t=t.slice(),e=e.slice();const o=new rp(n.document,n.useRelations,n.forceWeakRemove);o.setOriginalOperations(t),o.setOriginalOperations(e);const i=o.originalOperations;if(0==t.length||0==e.length)return{operationsA:t,operationsB:e,originalOperations:i};const r=new WeakMap;for(const e of t)r.set(e,0);const s={nextBaseVersionA:t[t.length-1].baseVersion+1,nextBaseVersionB:e[e.length-1].baseVersion+1,originalOperationsACount:t.length,originalOperationsBCount:e.length};let a=0;for(;a{if(t.key===e.key&&t.range.start.hasSameParentAs(e.range.start)){const o=t.range.getDifference(e.range).map((e=>new yl(e,t.key,t.oldValue,t.newValue,0))),i=t.range.getIntersection(e.range);return i&&n.aIsStrong&&o.push(new yl(i,e.key,e.newValue,t.newValue,0)),0==o.length?[new Ql(0)]:o}return[t]})),ep(yl,Dl,((t,e)=>{if(t.range.start.hasSameParentAs(e.position)&&t.range.containsPosition(e.position)){const n=t.range._getTransformedByInsertion(e.position,e.howMany,!e.shouldReceiveAttributes).map((e=>new yl(e,t.key,t.oldValue,t.newValue,t.baseVersion)));if(e.shouldReceiveAttributes){const o=cp(e,t.key,t.oldValue);o&&n.unshift(o)}return n}return t.range=t.range._getTransformedByInsertion(e.position,e.howMany,!1)[0],[t]})),ep(yl,Pl,((t,e)=>{const n=[];t.range.start.hasSameParentAs(e.deletionPosition)&&(t.range.containsPosition(e.deletionPosition)||t.range.start.isEqual(e.deletionPosition))&&n.push(nc._createFromPositionAndShift(e.graveyardPosition,1));const o=t.range._getTransformedByMergeOperation(e);return o.isCollapsed||n.push(o),n.map((e=>new yl(e,t.key,t.oldValue,t.newValue,t.baseVersion)))})),ep(yl,El,((t,e)=>{const n=function(t,e){const n=nc._createFromPositionAndShift(e.sourcePosition,e.howMany);let o=null,i=[];n.containsRange(t,!0)?o=t:t.start.hasSameParentAs(n.start)?(i=t.getDifference(n),o=t.getIntersection(n)):i=[t];const r=[];for(let t of i){t=t._getTransformedByDeletion(e.sourcePosition,e.howMany);const n=e.getMovedRangeStart(),o=t.start.hasSameParentAs(n);t=t._getTransformedByInsertion(n,e.howMany,o),r.push(...t)}o&&r.push(o._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany,!1)[0]);return r}(t.range,e);return n.map((e=>new yl(e,t.key,t.oldValue,t.newValue,t.baseVersion)))})),ep(yl,Il,((t,e)=>{if(t.range.end.isEqual(e.insertionPosition))return e.graveyardPosition||t.range.end.offset++,[t];if(t.range.start.hasSameParentAs(e.splitPosition)&&t.range.containsPosition(e.splitPosition)){const n=t.clone();return n.range=new nc(e.moveTargetPosition.clone(),t.range.end._getCombined(e.splitPosition,e.moveTargetPosition)),t.range.end=e.splitPosition.clone(),t.range.end.stickiness="toPrevious",[t,n]}return t.range=t.range._getTransformedBySplitOperation(e),[t]})),ep(Dl,yl,((t,e)=>{const n=[t];if(t.shouldReceiveAttributes&&t.position.hasSameParentAs(e.range.start)&&e.range.containsPosition(t.position)){const o=cp(t,e.key,e.newValue);o&&n.push(o)}return n})),ep(Dl,Dl,((t,e,n)=>(t.position.isEqual(e.position)&&n.aIsStrong||(t.position=t.position._getTransformedByInsertOperation(e)),[t]))),ep(Dl,El,((t,e)=>(t.position=t.position._getTransformedByMoveOperation(e),[t]))),ep(Dl,Il,((t,e)=>(t.position=t.position._getTransformedBySplitOperation(e),[t]))),ep(Dl,Pl,((t,e)=>(t.position=t.position._getTransformedByMergeOperation(e),[t]))),ep(Sl,Dl,((t,e)=>(t.oldRange&&(t.oldRange=t.oldRange._getTransformedByInsertOperation(e)[0]),t.newRange&&(t.newRange=t.newRange._getTransformedByInsertOperation(e)[0]),[t]))),ep(Sl,Sl,((t,e,n)=>{if(t.name==e.name){if(!n.aIsStrong)return[new Ql(0)];t.oldRange=e.newRange?e.newRange.clone():null}return[t]})),ep(Sl,Pl,((t,e)=>(t.oldRange&&(t.oldRange=t.oldRange._getTransformedByMergeOperation(e)),t.newRange&&(t.newRange=t.newRange._getTransformedByMergeOperation(e)),[t]))),ep(Sl,El,((t,e,n)=>{if(t.oldRange&&(t.oldRange=nc._createFromRanges(t.oldRange._getTransformedByMoveOperation(e))),t.newRange){if(n.abRelation){const o=nc._createFromRanges(t.newRange._getTransformedByMoveOperation(e));if("left"==n.abRelation.side&&e.targetPosition.isEqual(t.newRange.start))return t.newRange.start.path=n.abRelation.path,t.newRange.end=o.end,[t];if("right"==n.abRelation.side&&e.targetPosition.isEqual(t.newRange.end))return t.newRange.start=o.start,t.newRange.end.path=n.abRelation.path,[t]}t.newRange=nc._createFromRanges(t.newRange._getTransformedByMoveOperation(e))}return[t]})),ep(Sl,Il,((t,e,n)=>{if(t.oldRange&&(t.oldRange=t.oldRange._getTransformedBySplitOperation(e)),t.newRange){if(n.abRelation){const o=t.newRange._getTransformedBySplitOperation(e);return t.newRange.start.isEqual(e.splitPosition)&&n.abRelation.wasStartBeforeMergedElement?t.newRange.start=Qa._createAt(e.insertionPosition):t.newRange.start.isEqual(e.splitPosition)&&!n.abRelation.wasInLeftElement&&(t.newRange.start=Qa._createAt(e.moveTargetPosition)),t.newRange.end.isEqual(e.splitPosition)&&n.abRelation.wasInRightElement?t.newRange.end=Qa._createAt(e.moveTargetPosition):t.newRange.end.isEqual(e.splitPosition)&&n.abRelation.wasEndBeforeMergedElement?t.newRange.end=Qa._createAt(e.insertionPosition):t.newRange.end=o.end,[t]}t.newRange=t.newRange._getTransformedBySplitOperation(e)}return[t]})),ep(Pl,Dl,((t,e)=>(t.sourcePosition.hasSameParentAs(e.position)&&(t.howMany+=e.howMany),t.sourcePosition=t.sourcePosition._getTransformedByInsertOperation(e),t.targetPosition=t.targetPosition._getTransformedByInsertOperation(e),[t]))),ep(Pl,Pl,((t,e,n)=>{if(t.sourcePosition.isEqual(e.sourcePosition)&&t.targetPosition.isEqual(e.targetPosition)){if(n.bWasUndone){const n=e.graveyardPosition.path.slice();return n.push(0),t.sourcePosition=new Qa(e.graveyardPosition.root,n),t.howMany=0,[t]}return[new Ql(0)]}if(t.sourcePosition.isEqual(e.sourcePosition)&&!t.targetPosition.isEqual(e.targetPosition)&&!n.bWasUndone&&"splitAtSource"!=n.abRelation){const o="$graveyard"==t.targetPosition.root.rootName,i="$graveyard"==e.targetPosition.root.rootName,r=o&&!i;if(i&&!o||!r&&n.aIsStrong){const n=e.targetPosition._getTransformedByMergeOperation(e),o=t.targetPosition._getTransformedByMergeOperation(e);return[new El(n,t.howMany,o,0)]}return[new Ql(0)]}return t.sourcePosition.hasSameParentAs(e.targetPosition)&&(t.howMany+=e.howMany),t.sourcePosition=t.sourcePosition._getTransformedByMergeOperation(e),t.targetPosition=t.targetPosition._getTransformedByMergeOperation(e),t.graveyardPosition.isEqual(e.graveyardPosition)&&n.aIsStrong||(t.graveyardPosition=t.graveyardPosition._getTransformedByMergeOperation(e)),[t]})),ep(Pl,El,((t,e,n)=>{const o=nc._createFromPositionAndShift(e.sourcePosition,e.howMany);return"remove"==e.type&&!n.bWasUndone&&!n.forceWeakRemove&&t.deletionPosition.hasSameParentAs(e.sourcePosition)&&o.containsPosition(t.sourcePosition)?[new Ql(0)]:(t.sourcePosition.hasSameParentAs(e.targetPosition)&&(t.howMany+=e.howMany),t.sourcePosition.hasSameParentAs(e.sourcePosition)&&(t.howMany-=e.howMany),t.sourcePosition=t.sourcePosition._getTransformedByMoveOperation(e),t.targetPosition=t.targetPosition._getTransformedByMoveOperation(e),t.graveyardPosition.isEqual(e.targetPosition)||(t.graveyardPosition=t.graveyardPosition._getTransformedByMoveOperation(e)),[t])})),ep(Pl,Il,((t,e,n)=>{if(e.graveyardPosition&&(t.graveyardPosition=t.graveyardPosition._getTransformedByDeletion(e.graveyardPosition,1),t.deletionPosition.isEqual(e.graveyardPosition)&&(t.howMany=e.howMany)),t.targetPosition.isEqual(e.splitPosition)){const o=0!=e.howMany,i=e.graveyardPosition&&t.deletionPosition.isEqual(e.graveyardPosition);if(o||i||"mergeTargetNotMoved"==n.abRelation)return t.sourcePosition=t.sourcePosition._getTransformedBySplitOperation(e),[t]}if(t.sourcePosition.isEqual(e.splitPosition)){if("mergeSourceNotMoved"==n.abRelation)return t.howMany=0,t.targetPosition=t.targetPosition._getTransformedBySplitOperation(e),[t];if("mergeSameElement"==n.abRelation||t.sourcePosition.offset>0)return t.sourcePosition=e.moveTargetPosition.clone(),t.targetPosition=t.targetPosition._getTransformedBySplitOperation(e),[t]}return t.sourcePosition.hasSameParentAs(e.splitPosition)&&(t.howMany=e.splitPosition.offset),t.sourcePosition=t.sourcePosition._getTransformedBySplitOperation(e),t.targetPosition=t.targetPosition._getTransformedBySplitOperation(e),[t]})),ep(El,Dl,((t,e)=>{const n=nc._createFromPositionAndShift(t.sourcePosition,t.howMany)._getTransformedByInsertOperation(e,!1)[0];return t.sourcePosition=n.start,t.howMany=n.end.offset-n.start.offset,t.targetPosition.isEqual(e.position)||(t.targetPosition=t.targetPosition._getTransformedByInsertOperation(e)),[t]})),ep(El,El,((t,e,n)=>{const o=nc._createFromPositionAndShift(t.sourcePosition,t.howMany),i=nc._createFromPositionAndShift(e.sourcePosition,e.howMany);let r,s=n.aIsStrong,a=!n.aIsStrong;if("insertBefore"==n.abRelation||"insertAfter"==n.baRelation?a=!0:"insertAfter"!=n.abRelation&&"insertBefore"!=n.baRelation||(a=!1),r=t.targetPosition.isEqual(e.targetPosition)&&a?t.targetPosition._getTransformedByDeletion(e.sourcePosition,e.howMany):t.targetPosition._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),lp(t,e)&&lp(e,t))return[e.getReversed()];if(o.containsPosition(e.targetPosition)&&o.containsRange(i,!0))return o.start=o.start._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),o.end=o.end._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),dp([o],r);if(i.containsPosition(t.targetPosition)&&i.containsRange(o,!0))return o.start=o.start._getCombined(e.sourcePosition,e.getMovedRangeStart()),o.end=o.end._getCombined(e.sourcePosition,e.getMovedRangeStart()),dp([o],r);const c=Oo(t.sourcePosition.getParentPath(),e.sourcePosition.getParentPath());if("prefix"==c||"extension"==c)return o.start=o.start._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),o.end=o.end._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),dp([o],r);"remove"!=t.type||"remove"==e.type||n.aWasUndone||n.forceWeakRemove?"remove"==t.type||"remove"!=e.type||n.bWasUndone||n.forceWeakRemove||(s=!1):s=!0;const l=[],d=o.getDifference(i);for(const t of d){t.start=t.start._getTransformedByDeletion(e.sourcePosition,e.howMany),t.end=t.end._getTransformedByDeletion(e.sourcePosition,e.howMany);const n="same"==Oo(t.start.getParentPath(),e.getMovedRangeStart().getParentPath()),o=t._getTransformedByInsertion(e.getMovedRangeStart(),e.howMany,n);l.push(...o)}const u=o.getIntersection(i);return null!==u&&s&&(u.start=u.start._getCombined(e.sourcePosition,e.getMovedRangeStart()),u.end=u.end._getCombined(e.sourcePosition,e.getMovedRangeStart()),0===l.length?l.push(u):1==l.length?i.start.isBefore(o.start)||i.start.isEqual(o.start)?l.unshift(u):l.push(u):l.splice(1,0,u)),0===l.length?[new Ql(t.baseVersion)]:dp(l,r)})),ep(El,Il,((t,e,n)=>{let o=t.targetPosition.clone();t.targetPosition.isEqual(e.insertionPosition)&&e.graveyardPosition&&"moveTargetAfter"!=n.abRelation||(o=t.targetPosition._getTransformedBySplitOperation(e));const i=nc._createFromPositionAndShift(t.sourcePosition,t.howMany);if(i.end.isEqual(e.insertionPosition))return e.graveyardPosition||t.howMany++,t.targetPosition=o,[t];if(i.start.hasSameParentAs(e.splitPosition)&&i.containsPosition(e.splitPosition)){let t=new nc(e.splitPosition,i.end);t=t._getTransformedBySplitOperation(e);return dp([new nc(i.start,e.splitPosition),t],o)}t.targetPosition.isEqual(e.splitPosition)&&"insertAtSource"==n.abRelation&&(o=e.moveTargetPosition),t.targetPosition.isEqual(e.insertionPosition)&&"insertBetween"==n.abRelation&&(o=t.targetPosition);const r=[i._getTransformedBySplitOperation(e)];if(e.graveyardPosition){const o=i.start.isEqual(e.graveyardPosition)||i.containsPosition(e.graveyardPosition);t.howMany>1&&o&&!n.aWasUndone&&r.push(nc._createFromPositionAndShift(e.insertionPosition,1))}return dp(r,o)})),ep(El,Pl,((t,e,n)=>{const o=nc._createFromPositionAndShift(t.sourcePosition,t.howMany);if(e.deletionPosition.hasSameParentAs(t.sourcePosition)&&o.containsPosition(e.sourcePosition))if("remove"!=t.type||n.forceWeakRemove){if(1==t.howMany)return n.bWasUndone?(t.sourcePosition=e.graveyardPosition.clone(),t.targetPosition=t.targetPosition._getTransformedByMergeOperation(e),[t]):[new Ql(0)]}else if(!n.aWasUndone){const n=[];let o=e.graveyardPosition.clone(),i=e.targetPosition._getTransformedByMergeOperation(e);t.howMany>1&&(n.push(new El(t.sourcePosition,t.howMany-1,t.targetPosition,0)),o=o._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany-1),i=i._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany-1));const r=e.deletionPosition._getCombined(t.sourcePosition,t.targetPosition),s=new El(o,1,r,0),a=s.getMovedRangeStart().path.slice();a.push(0);const c=new Qa(s.targetPosition.root,a);i=i._getTransformedByMove(o,r,1);const l=new El(i,e.howMany,c,0);return n.push(s),n.push(l),n}const i=nc._createFromPositionAndShift(t.sourcePosition,t.howMany)._getTransformedByMergeOperation(e);return t.sourcePosition=i.start,t.howMany=i.end.offset-i.start.offset,t.targetPosition=t.targetPosition._getTransformedByMergeOperation(e),[t]})),ep(Bl,Dl,((t,e)=>(t.position=t.position._getTransformedByInsertOperation(e),[t]))),ep(Bl,Pl,((t,e)=>t.position.isEqual(e.deletionPosition)?(t.position=e.graveyardPosition.clone(),t.position.stickiness="toNext",[t]):(t.position=t.position._getTransformedByMergeOperation(e),[t]))),ep(Bl,El,((t,e)=>(t.position=t.position._getTransformedByMoveOperation(e),[t]))),ep(Bl,Bl,((t,e,n)=>{if(t.position.isEqual(e.position)){if(!n.aIsStrong)return[new Ql(0)];t.oldName=e.newName}return[t]})),ep(Bl,Il,((t,e)=>{if("same"==Oo(t.position.path,e.splitPosition.getParentPath())&&!e.graveyardPosition){const e=new Bl(t.position.getShiftedBy(1),t.oldName,t.newName,0);return[t,e]}return t.position=t.position._getTransformedBySplitOperation(e),[t]})),ep(Tl,Tl,((t,e,n)=>{if(t.root===e.root&&t.key===e.key){if(!n.aIsStrong||t.newValue===e.newValue)return[new Ql(0)];t.oldValue=e.newValue}return[t]})),ep(Il,Dl,((t,e)=>(t.splitPosition.hasSameParentAs(e.position)&&t.splitPosition.offset{if(!t.graveyardPosition&&!n.bWasUndone&&t.splitPosition.hasSameParentAs(e.sourcePosition)){const n=e.graveyardPosition.path.slice();n.push(0);const o=new Qa(e.graveyardPosition.root,n),i=Il.getInsertionPosition(new Qa(e.graveyardPosition.root,n)),r=new Il(o,0,i,null,0);return t.splitPosition=t.splitPosition._getTransformedByMergeOperation(e),t.insertionPosition=Il.getInsertionPosition(t.splitPosition),t.graveyardPosition=r.insertionPosition.clone(),t.graveyardPosition.stickiness="toNext",[r,t]}return t.splitPosition.hasSameParentAs(e.deletionPosition)&&!t.splitPosition.isAfter(e.deletionPosition)&&t.howMany--,t.splitPosition.hasSameParentAs(e.targetPosition)&&(t.howMany+=e.howMany),t.splitPosition=t.splitPosition._getTransformedByMergeOperation(e),t.insertionPosition=Il.getInsertionPosition(t.splitPosition),t.graveyardPosition&&(t.graveyardPosition=t.graveyardPosition._getTransformedByMergeOperation(e)),[t]})),ep(Il,El,((t,e,n)=>{const o=nc._createFromPositionAndShift(e.sourcePosition,e.howMany);if(t.graveyardPosition){const i=o.start.isEqual(t.graveyardPosition)||o.containsPosition(t.graveyardPosition);if(!n.bWasUndone&&i){const n=t.splitPosition._getTransformedByMoveOperation(e),o=t.graveyardPosition._getTransformedByMoveOperation(e),i=o.path.slice();i.push(0);const r=new Qa(o.root,i);return[new El(n,t.howMany,r,0)]}t.graveyardPosition=t.graveyardPosition._getTransformedByMoveOperation(e)}const i=t.splitPosition.isEqual(e.targetPosition);if(i&&("insertAtSource"==n.baRelation||"splitBefore"==n.abRelation))return t.howMany+=e.howMany,t.splitPosition=t.splitPosition._getTransformedByDeletion(e.sourcePosition,e.howMany),t.insertionPosition=Il.getInsertionPosition(t.splitPosition),[t];if(i&&n.abRelation&&n.abRelation.howMany){const{howMany:e,offset:o}=n.abRelation;return t.howMany+=e,t.splitPosition=t.splitPosition.getShiftedBy(o),[t]}if(t.splitPosition.hasSameParentAs(e.sourcePosition)&&o.containsPosition(t.splitPosition)){const n=e.howMany-(t.splitPosition.offset-e.sourcePosition.offset);return t.howMany-=n,t.splitPosition.hasSameParentAs(e.targetPosition)&&t.splitPosition.offset{if(t.splitPosition.isEqual(e.splitPosition)){if(!t.graveyardPosition&&!e.graveyardPosition)return[new Ql(0)];if(t.graveyardPosition&&e.graveyardPosition&&t.graveyardPosition.isEqual(e.graveyardPosition))return[new Ql(0)];if("splitBefore"==n.abRelation)return t.howMany=0,t.graveyardPosition=t.graveyardPosition._getTransformedBySplitOperation(e),[t]}if(t.graveyardPosition&&e.graveyardPosition&&t.graveyardPosition.isEqual(e.graveyardPosition)){const o="$graveyard"==t.splitPosition.root.rootName,i="$graveyard"==e.splitPosition.root.rootName,r=o&&!i;if(i&&!o||!r&&n.aIsStrong){const n=[];return e.howMany&&n.push(new El(e.moveTargetPosition,e.howMany,e.splitPosition,0)),t.howMany&&n.push(new El(t.splitPosition,t.howMany,t.moveTargetPosition,0)),n}return[new Ql(0)]}if(t.graveyardPosition&&(t.graveyardPosition=t.graveyardPosition._getTransformedBySplitOperation(e)),t.splitPosition.isEqual(e.insertionPosition)&&"splitBefore"==n.abRelation)return t.howMany++,[t];if(e.splitPosition.isEqual(t.insertionPosition)&&"splitBefore"==n.baRelation){const n=e.insertionPosition.path.slice();n.push(0);const o=new Qa(e.insertionPosition.root,n);return[t,new El(t.insertionPosition,1,o,0)]}return t.splitPosition.hasSameParentAs(e.splitPosition)&&t.splitPosition.offset{const{top:n,right:o,bottom:i,left:r}=e,s=[];return[n,o,r,i].every((t=>!!t))?s.push([t,Fp(e)]):(n&&s.push([t+"-top",n]),o&&s.push([t+"-right",o]),i&&s.push([t+"-bottom",i]),r&&s.push([t+"-left",r])),s}}function Fp({top:t,right:e,bottom:n,left:o}){const i=[];return o!==e?i.push(t,e,n,o):n!==t?i.push(t,e,n):e!==t?i.push(t,e):i.push(t),i.join(" ")}function Np(t){return t.replace(/, /g,",").split(" ").map((t=>t.replace(/,/g,", ")))}function Op(t){t.setNormalizer("background",Mp),t.setNormalizer("background-color",(t=>({path:"background.color",value:t}))),t.setReducer("background",(t=>{const e=[];return e.push(["background-color",t.color]),e})),t.setStyleRelation("background",["background-color"])}function Mp(t){const e={},n=Np(t);for(const t of n)o=t,Ep.includes(o)?(e.repeat=e.repeat||[],e.repeat.push(t)):Sp(t)?(e.position=e.position||[],e.position.push(t)):Tp(t)?e.attachment=t:_p(t)?e.color=t:Ip(t)&&(e.image=t);var o;return{path:"background",value:e}}function Vp(t){t.setNormalizer("border",Lp),t.setNormalizer("border-top",Hp("top")),t.setNormalizer("border-right",Hp("right")),t.setNormalizer("border-bottom",Hp("bottom")),t.setNormalizer("border-left",Hp("left")),t.setNormalizer("border-color",qp("color")),t.setNormalizer("border-width",qp("width")),t.setNormalizer("border-style",qp("style")),t.setNormalizer("border-top-color",jp("color","top")),t.setNormalizer("border-top-style",jp("style","top")),t.setNormalizer("border-top-width",jp("width","top")),t.setNormalizer("border-right-color",jp("color","right")),t.setNormalizer("border-right-style",jp("style","right")),t.setNormalizer("border-right-width",jp("width","right")),t.setNormalizer("border-bottom-color",jp("color","bottom")),t.setNormalizer("border-bottom-style",jp("style","bottom")),t.setNormalizer("border-bottom-width",jp("width","bottom")),t.setNormalizer("border-left-color",jp("color","left")),t.setNormalizer("border-left-style",jp("style","left")),t.setNormalizer("border-left-width",jp("width","left")),t.setExtractor("border-top",Up("top")),t.setExtractor("border-right",Up("right")),t.setExtractor("border-bottom",Up("bottom")),t.setExtractor("border-left",Up("left")),t.setExtractor("border-top-color","border.color.top"),t.setExtractor("border-right-color","border.color.right"),t.setExtractor("border-bottom-color","border.color.bottom"),t.setExtractor("border-left-color","border.color.left"),t.setExtractor("border-top-width","border.width.top"),t.setExtractor("border-right-width","border.width.right"),t.setExtractor("border-bottom-width","border.width.bottom"),t.setExtractor("border-left-width","border.width.left"),t.setExtractor("border-top-style","border.style.top"),t.setExtractor("border-right-style","border.style.right"),t.setExtractor("border-bottom-style","border.style.bottom"),t.setExtractor("border-left-style","border.style.left"),t.setReducer("border-color",zp("border-color")),t.setReducer("border-style",zp("border-style")),t.setReducer("border-width",zp("border-width")),t.setReducer("border-top",Kp("top")),t.setReducer("border-right",Kp("right")),t.setReducer("border-bottom",Kp("bottom")),t.setReducer("border-left",Kp("left")),t.setReducer("border",function(){return e=>{const n=$p(e,"top"),o=$p(e,"right"),i=$p(e,"bottom"),r=$p(e,"left"),s=[n,o,i,r],a={width:t(s,"width"),style:t(s,"style"),color:t(s,"color")},c=Zp(a,"all");if(c.length)return c;const l=Object.entries(a).reduce(((t,[e,n])=>(n&&(t.push([`border-${e}`,n]),s.forEach((t=>t[e]=null))),t)),[]);return[...l,...Zp(n,"top"),...Zp(o,"right"),...Zp(i,"bottom"),...Zp(r,"left")]};function t(t,e){return t.map((t=>t[e])).reduce(((t,e)=>t==e?t:null))}}()),t.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"]),t.setStyleRelation("border-color",["border-top-color","border-right-color","border-bottom-color","border-left-color"]),t.setStyleRelation("border-style",["border-top-style","border-right-style","border-bottom-style","border-left-style"]),t.setStyleRelation("border-width",["border-top-width","border-right-width","border-bottom-width","border-left-width"]),t.setStyleRelation("border-top",["border-top-color","border-top-style","border-top-width"]),t.setStyleRelation("border-right",["border-right-color","border-right-style","border-right-width"]),t.setStyleRelation("border-bottom",["border-bottom-color","border-bottom-style","border-bottom-width"]),t.setStyleRelation("border-left",["border-left-color","border-left-style","border-left-width"])}function Lp(t){const{color:e,style:n,width:o}=Gp(t);return{path:"border",value:{color:Rp(e),style:Rp(n),width:Rp(o)}}}function Hp(t){return e=>{const{color:n,style:o,width:i}=Gp(e),r={};return void 0!==n&&(r.color={[t]:n}),void 0!==o&&(r.style={[t]:o}),void 0!==i&&(r.width={[t]:i}),{path:"border",value:r}}}function qp(t){return e=>({path:"border",value:Wp(e,t)})}function Wp(t,e){return{[e]:Rp(t)}}function jp(t,e){return n=>({path:"border",value:{[t]:{[e]:n}}})}function Up(t){return(e,n)=>{if(n.border)return $p(n.border,t)}}function $p(t,e){const n={};return t.width&&t.width[e]&&(n.width=t.width[e]),t.style&&t.style[e]&&(n.style=t.style[e]),t.color&&t.color[e]&&(n.color=t.color[e]),n}function Gp(t){const e={},n=Np(t);for(const t of n)yp(t)||/thin|medium|thick/.test(t)?e.width=t:Ap(t)?e.style=t:e.color=t;return e}function Kp(t){return e=>Zp(e,t)}function Zp(t,e){const n=[];if(t&&t.width&&n.push("width"),t&&t.style&&n.push("style"),t&&t.color&&n.push("color"),3==n.length){const o=n.map((e=>t[e])).join(" ");return["all"==e?["border",o]:[`border-${e}`,o]]}return"all"==e?[]:n.map((n=>[`border-${e}-${n}`,t[n]]))}function Jp(t){var e;t.setNormalizer("padding",(e="padding",t=>({path:e,value:Rp(t)}))),t.setNormalizer("padding-top",(t=>({path:"padding.top",value:t}))),t.setNormalizer("padding-right",(t=>({path:"padding.right",value:t}))),t.setNormalizer("padding-bottom",(t=>({path:"padding.bottom",value:t}))),t.setNormalizer("padding-left",(t=>({path:"padding.left",value:t}))),t.setReducer("padding",zp("padding")),t.setStyleRelation("padding",["padding-top","padding-right","padding-bottom","padding-left"])}class Yp extends xd{constructor(t,e){super(t),this.view=e}init(){const t=this.editor,e=this.view,n=t.editing.view,o=e.editable,i=n.document.getRoot();e.editable.name=i.rootName,e.render();const r=o.element;this.setEditableElement(o.name,r),this.focusTracker.add(r),e.editable.bind("isFocused").to(this.focusTracker),n.attachDomRoot(r),this._initPlaceholder(),this._initToolbar(),this.fire("ready")}destroy(){const t=this.view;this.editor.editing.view.detachDomRoot(t.editable.name),t.destroy(),super.destroy()}_initToolbar(){const t=this.editor,e=this.view.toolbar;e.fillFromConfig(t.config.get("toolbar"),this.componentFactory),function({origin:t,originKeystrokeHandler:e,originFocusTracker:n,toolbar:o,beforeFocus:i,afterBlur:r}){n.add(o.element),e.set("Alt+F10",((t,e)=>{n.isFocused&&!o.focusTracker.isFocused&&(i&&i(),o.focus(),e())})),o.keystrokes.set("Esc",((e,n)=>{o.focusTracker.isFocused&&(t.focus(),r&&r(),n())}))}({origin:t.editing.view,originFocusTracker:this.focusTracker,originKeystrokeHandler:t.keystrokes,toolbar:e})}_initPlaceholder(){const t=this.editor,e=t.editing.view,n=e.document.getRoot(),o=t.sourceElement,i=t.config.get("placeholder")||o&&"textarea"===o.tagName.toLowerCase()&&o.getAttribute("placeholder");i&&Zh({view:e,element:n,text:i,isDirectHost:!1,keepOnFocus:!0})}}class Qp extends ah{constructor(t,e,n={}){super(t),this.toolbar=new Wu(t,{shouldGroupWhenFull:n.shouldToolbarGroupWhenFull}),this.editable=new hh(t,e,n.editableElement),this.toolbar.extendTemplate({attributes:{class:["ck-reset_all","ck-rounded-corners"],dir:t.uiLanguageDirection}})}render(){super.render(),this.registerChild([this.toolbar,this.editable])}}class Xp extends Ad{constructor(t,e){super(e),vo(t)&&(this.sourceElement=t,function(t){const e=t.sourceElement;if(e){if(e.ckeditorInstance)throw new s("editor-source-element-already-used",t);e.ckeditorInstance=t,t.once("destroy",(()=>{delete e.ckeditorInstance}))}}(this)),this.model.document.createRoot();const n=!this.config.get("toolbar.shouldNotGroupWhenFull"),o=new Qp(this.locale,this.editing.view,{editableElement:this.sourceElement,shouldToolbarGroupWhenFull:n});this.ui=new Yp(this,o)}destroy(){const t=this.getData();return this.ui.destroy(),super.destroy().then((()=>{this.sourceElement&&Ba(this.sourceElement,t)}))}static create(t,e={}){return new Promise((n=>{const o=vo(t);if(o&&"TEXTAREA"===t.tagName)throw new s("editor-wrong-element",null);const i=new this(t,e);n(i.initPlugins().then((()=>{i.ui.init()})).then((()=>{if(!o&&e.initialData)throw new s("editor-create-initial-data",null);const n=void 0!==e.initialData?e.initialData:function(t){return vo(t)?(e=t,e instanceof HTMLTextAreaElement?e.value:e.innerHTML):t;var e}(t);return i.data.init(n)})).then((()=>i.fire("ready"))).then((()=>i)))}))}}he(Xp,Dd);const tm=function(t,e,n){var o=!0,i=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return y(n)&&(o="leading"in n?!!n.leading:o,i="trailing"in n?!!n.trailing:i),pa(t,e,{leading:o,maxWait:e,trailing:i})};function em(t,e=new Set){const n=[t],o=new Set;for(;n.length>0;){const t=n.shift();if(!(o.has(t)||nm(t)||e.has(t)))if(o.add(t),t[Symbol.iterator])try{for(const e of t)n.push(e)}catch(t){}else for(const e in t)"defaultValue"!==e&&n.push(t[e])}return o}function nm(t){const e=Object.prototype.toString.call(t),n=typeof t;return"number"===n||"boolean"===n||"string"===n||"symbol"===n||"function"===n||"[object Date]"===e||"[object RegExp]"===e||"[object Module]"===e||null==t||t instanceof EventTarget||t instanceof Event}class om{constructor(){this._stack=[]}add(t,e){const n=this._stack,o=n[0];this._insertDescriptor(t);const i=n[0];o===i||im(o,i)||this.fire("change:top",{oldDescriptor:o,newDescriptor:i,writer:e})}remove(t,e){const n=this._stack,o=n[0];this._removeDescriptor(t);const i=n[0];o===i||im(o,i)||this.fire("change:top",{oldDescriptor:o,newDescriptor:i,writer:e})}_insertDescriptor(t){const e=this._stack,n=e.findIndex((e=>e.id===t.id));if(im(t,e[n]))return;n>-1&&e.splice(n,1);let o=0;for(;e[o]&&rm(e[o],t);)o++;e.splice(o,0,t)}_removeDescriptor(t){const e=this._stack,n=e.findIndex((e=>e.id===t));n>-1&&e.splice(n,1)}}function im(t,e){return t&&e&&t.priority==e.priority&&sm(t.classes)==sm(e.classes)}function rm(t,e){return t.priority>e.priority||!(t.prioritysm(e.classes)}function sm(t){return Array.isArray(t)?t.sort().join(","):t}he(om,g);const am="widget-type-around";function cm(t,e,n){return t&&hm(t)&&!n.isInline(e)}function lm(t){return t.getAttribute(am)}const dm='',um="ck-widget_selected";function hm(t){return!!t.is("element")&&!!t.getCustomProperty("widget")}function pm(t,e,n={}){if(!t.is("containerElement"))throw new s("widget-to-widget-wrong-element-type",null,{element:t});return e.setAttribute("contenteditable","false",t),e.addClass("ck-widget",t),e.setCustomProperty("widget",!0,t),t.getFillerOffset=_m,n.label&&function(t,e,n){n.setCustomProperty("widgetLabel",e,t)}(t,n.label,e),n.hasSelectionHandle&&function(t,e){const n=e.createUIElement("div",{class:"ck ck-widget__selection-handle"},(function(t){const e=this.toDomElement(t),n=new au;return n.set("content",dm),n.render(),e.appendChild(n.element),e}));e.insert(e.createPositionAt(t,0),n),e.addClass(["ck-widget_with-selection-handle"],t)}(t,e),fm(t,e),t}function mm(t,e,n){if(e.classes&&n.addClass(To(e.classes),t),e.attributes)for(const o in e.attributes)n.setAttribute(o,e.attributes[o],t)}function gm(t,e,n){if(e.classes&&n.removeClass(To(e.classes),t),e.attributes)for(const o in e.attributes)n.removeAttribute(o,t)}function fm(t,e,n=mm,o=gm){const i=new om;i.on("change:top",((e,i)=>{i.oldDescriptor&&o(t,i.oldDescriptor,i.writer),i.newDescriptor&&n(t,i.newDescriptor,i.writer)})),e.setCustomProperty("addHighlight",((t,e,n)=>i.add(e,n)),t),e.setCustomProperty("removeHighlight",((t,e,n)=>i.remove(e,n)),t)}function bm(t){const e=t.getCustomProperty("widgetLabel");return e?"function"==typeof e?e():e:""}function km(t,e){return e.addClass(["ck-editor__editable","ck-editor__nested-editable"],t),e.setAttribute("contenteditable",t.isReadOnly?"false":"true",t),t.on("change:isReadOnly",((n,o,i)=>{e.setAttribute("contenteditable",i?"false":"true",t)})),t.on("change:isFocused",((n,o,i)=>{i?e.addClass("ck-editor__nested-editable_focused",t):e.removeClass("ck-editor__nested-editable_focused",t)})),fm(t,e),t}function wm(t,e){const n=t.getSelectedElement();if(n){const o=lm(t);if(o)return e.createRange(e.createPositionAt(n,o));if(e.schema.isObject(n)&&!e.schema.isInline(n))return e.createRangeOn(n)}const o=t.getSelectedBlocks().next().value;if(o){if(o.isEmpty)return e.createRange(e.createPositionAt(o,0));const n=e.createPositionAfter(o);return t.focus.isTouching(n)?e.createRange(n):e.createRange(e.createPositionBefore(o))}return e.createRange(t.focus)}function _m(){return null}class Cm extends pe{static get pluginName(){return"OPMacroToc"}static get buttonName(){return"insertToc"}init(){const t=this.editor,e=t.model,n=t.conversion;e.schema.register("op-macro-toc",{allowWhere:"$block",isBlock:!0,isLimit:!0}),n.for("upcast").elementToElement({view:{name:"macro",classes:"toc"},model:"op-macro-toc"}),n.for("editingDowncast").elementToElement({model:"op-macro-toc",view:(t,{writer:e})=>pm(this.createTocViewElement(e),e,{label:this.label})}),n.for("dataDowncast").elementToElement({model:"op-macro-toc",view:(t,{writer:e})=>this.createTocDataElement(e)}),t.ui.componentFactory.add(Cm.buttonName,(e=>{const n=new pu(e);return n.set({label:this.label,withText:!0}),n.on("execute",(()=>{t.model.change((e=>{const n=e.createElement("op-macro-toc",{});t.model.insertContent(n,t.model.document.selection)}))})),n}))}get label(){return window.I18n.t("js.editor.macro.toc")}createTocViewElement(t){const e=t.createText(this.label),n=t.createContainerElement("div");return t.insert(t.createPositionAt(n,0),e),n}createTocDataElement(t){return t.createContainerElement("macro",{class:"toc"})}}const Am=Symbol("isOPEmbeddedTable");function vm(t){const e=t.getSelectedElement();return!(!e||!function(t){return!!t.getCustomProperty(Am)&&hm(t)}(e))}function ym(t){return _.get(t.config,"_config.openProject.context.resource")}function xm(t){return _.get(t.config,"_config.openProject.pluginContext")}function Em(t,e){return xm(t).services[e]}function Dm(t){return Em(t,"pathHelperService")}class Sm extends pe{static get pluginName(){return"EmbeddedTableEditing"}static get buttonName(){return"insertEmbeddedTable"}init(){const t=this.editor,e=t.model,n=t.conversion,o=xm(t);this.text={button:window.I18n.t("js.editor.macro.embedded_table.button"),macro_text:window.I18n.t("js.editor.macro.embedded_table.text")},e.schema.register("op-macro-embedded-table",{allowWhere:"$block",allowAttributes:["opEmbeddedTableQuery"],isBlock:!0,isObject:!0}),n.for("upcast").elementToElement({view:{name:"macro",classes:"embedded-table"},model:(t,{writer:e})=>{const n=t.getAttribute("data-query-props");return e.createElement("op-macro-embedded-table",{opEmbeddedTableQuery:n?JSON.parse(n):{}})}}),n.for("editingDowncast").elementToElement({model:"op-macro-embedded-table",view:(t,{writer:e})=>{return n=this.createEmbeddedTableView(e),o=e,this.label,o.setCustomProperty(Am,!0,n),pm(n,o,{label:"your label here"});var n,o}}),n.for("dataDowncast").elementToElement({model:"op-macro-embedded-table",view:(t,{writer:e})=>this.createEmbeddedTableDataElement(t,e)}),t.ui.componentFactory.add(Sm.buttonName,(e=>{const n=new pu(e);return n.set({label:this.text.button,withText:!0}),n.on("execute",(()=>o.runInZone((()=>{o.services.externalQueryConfiguration.show({currentQuery:{},callback:e=>t.model.change((n=>{const o=n.createElement("op-macro-embedded-table",{opEmbeddedTableQuery:e});t.model.insertContent(o,t.model.document.selection)}))})})))),n}))}createEmbeddedTableView(t){const e=t.createText(this.text.macro_text),n=t.createContainerElement("div");return t.insert(t.createPositionAt(n,0),e),n}createEmbeddedTableDataElement(t,e){const n=t.getAttribute("opEmbeddedTableQuery")||{};return e.createContainerElement("macro",{class:"embedded-table","data-query-props":JSON.stringify(n)})}}function*Bm(t,e){for(const n of e)n&&t.getAttributeProperties(n[0]).copyOnEnter&&(yield n)}class Tm extends ge{execute(){const t=this.editor.model,e=t.document;t.change((n=>{!function(t,e,n,o){const i=n.isCollapsed,r=n.getFirstRange(),s=r.start.parent,a=r.end.parent;if(o.isLimit(s)||o.isLimit(a))return void(i||s!=a||t.deleteContent(n));if(i){const t=Bm(e.model.schema,n.getAttributes());Pm(e,r.start),e.setSelectionAttribute(t)}else{const o=!(r.start.isAtStart&&r.end.isAtEnd),i=s==a;t.deleteContent(n,{leaveUnmerged:o}),o&&(i?Pm(e,n.focus):e.setSelection(a,0))}}(this.editor.model,n,e.selection,t.schema),this.fire("afterExecute",{writer:n})}))}}function Pm(t,e){t.split(e),t.setSelection(e.parent.nextSibling,0)}class Im extends Bs{constructor(t){super(t);const e=this.document;e.on("keydown",((t,n)=>{if(this.isEnabled&&n.keyCode==ur.enter){const o=new Ui(e,"enter",e.selection.getFirstRange());e.fire(o,new Qs(e,n.domEvent,{isSoft:n.shiftKey})),o.stop.called&&t.stop()}}))}observe(){}}class Rm extends pe{static get pluginName(){return"Enter"}init(){const t=this.editor,e=t.editing.view,n=e.document;e.addObserver(Im),t.commands.add("enter",new Tm(t)),this.listenTo(n,"enter",((n,o)=>{o.preventDefault(),o.isSoft||(t.execute("enter"),e.scrollToTheSelection())}),{priority:"low"})}}class zm{constructor(t,e=20){this.model=t,this.size=0,this.limit=e,this.isLocked=!1,this._changeCallback=(t,e)=>{e.isLocal&&e.isUndoable&&e!==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(t){this.size+=t,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(t){this.isLocked&&!t||(this._batch=null,this.size=0)}}class Fm extends ge{constructor(t,e){super(t),this.direction=e,this._buffer=new zm(t.model,t.config.get("typing.undoStep"))}get buffer(){return this._buffer}execute(t={}){const e=this.editor.model,n=e.document;e.enqueueChange(this._buffer.batch,(o=>{this._buffer.lock();const i=o.createSelection(t.selection||n.selection),r=t.sequence||1,s=i.isCollapsed;if(i.isCollapsed&&e.modifySelection(i,{direction:this.direction,unit:t.unit}),this._shouldEntireContentBeReplacedWithParagraph(r))return void this._replaceEntireContentWithParagraph(o);if(this._shouldReplaceFirstBlockWithParagraph(i,r))return void this.editor.execute("paragraph",{selection:i});if(i.isCollapsed)return;let a=0;i.getFirstRange().getMinimalFlatRanges().forEach((t=>{a+=qi(t.getWalker({singleCharacters:!0,ignoreElementEnd:!0,shallow:!0}))})),e.deleteContent(i,{doNotResetEntireContent:s,direction:this.direction}),this._buffer.input(a),o.setSelection(i),this._buffer.unlock()}))}_shouldEntireContentBeReplacedWithParagraph(t){if(t>1)return!1;const e=this.editor.model,n=e.document.selection,o=e.schema.getLimitElement(n);if(!(n.isCollapsed&&n.containsEntireContent(o)))return!1;if(!e.schema.checkChild(o,"paragraph"))return!1;const i=o.getChild(0);return!i||"paragraph"!==i.name}_replaceEntireContentWithParagraph(t){const e=this.editor.model,n=e.document.selection,o=e.schema.getLimitElement(n),i=t.createElement("paragraph");t.remove(t.createRangeIn(o)),t.insert(i,o),t.setSelection(i,0)}_shouldReplaceFirstBlockWithParagraph(t,e){const n=this.editor.model;if(e>1||"backward"!=this.direction)return!1;if(!t.isCollapsed)return!1;const o=t.getFirstPosition(),i=n.schema.getLimitElement(o),r=i.getChild(0);return o.parent==r&&(!!t.containsEntireContent(r)&&(!!n.schema.checkChild(i,"paragraph")&&"paragraph"!=r.name))}}function Nm(t){if(t.newChildren.length-t.oldChildren.length!=1)return;const e=function(t,e){const n=[];let o,i=0;return t.forEach((t=>{"equal"==t?(r(),i++):"insert"==t?(s("insert")?o.values.push(e[i]):(r(),o={type:"insert",index:i,values:[e[i]]}),i++):s("delete")?o.howMany++:(r(),o={type:"delete",index:i,howMany:1})})),r(),n;function r(){o&&(n.push(o),o=null)}function s(t){return o&&o.type==t}}($r(t.oldChildren,t.newChildren,Om),t.newChildren);if(e.length>1)return;const n=e[0];return n.values[0]&&n.values[0].is("$text")?n:void 0}function Om(t,e){return t&&t.is("$text")&&e&&e.is("$text")?t.data===e.data:t===e}function Mm(t,e){const n=e.selection,o=t.shiftKey&&t.keyCode===ur.delete,i=!n.isCollapsed;return o&&i}class Vm extends Bs{constructor(t){super(t);const e=t.document;let n=0;function o(t,n,o){const i=new Ui(e,"delete",e.selection.getFirstRange());e.fire(i,new Qs(e,n,o)),i.stop.called&&t.stop()}e.on("keyup",((t,e)=>{e.keyCode!=ur.delete&&e.keyCode!=ur.backspace||(n=0)})),e.on("keydown",((t,i)=>{if(ar.isWindows&&Mm(i,e))return;const r={};if(i.keyCode==ur.delete)r.direction="forward",r.unit="character";else{if(i.keyCode!=ur.backspace)return;r.direction="backward",r.unit="codePoint"}const s=ar.isMac?i.altKey:i.ctrlKey;r.unit=s?"word":r.unit,r.sequence=++n,o(t,i.domEvent,r)})),ar.isAndroid&&e.on("beforeinput",((e,n)=>{if("deleteContentBackward"!=n.domEvent.inputType)return;const i={unit:"codepoint",direction:"backward",sequence:1},r=n.domTarget.ownerDocument.defaultView.getSelection();r.anchorNode==r.focusNode&&r.anchorOffset+1!=r.focusOffset&&(i.selectionToRemove=t.domConverter.domSelectionToView(r)),o(e,n.domEvent,i)}))}observe(){}}class Lm extends pe{static get pluginName(){return"Delete"}init(){const t=this.editor,e=t.editing.view,n=e.document,o=t.model.document;e.addObserver(Vm),this._undoOnBackspace=!1;const i=new Fm(t,"forward");if(t.commands.add("deleteForward",i),t.commands.add("forwardDelete",i),t.commands.add("delete",new Fm(t,"backward")),this.listenTo(n,"delete",((n,o)=>{const i={unit:o.unit,sequence:o.sequence};if(o.selectionToRemove){const e=t.model.createSelection(),n=[];for(const e of o.selectionToRemove.getRanges())n.push(t.editing.mapper.toModelRange(e));e.setTo(n),i.selection=e}t.execute("forward"==o.direction?"deleteForward":"delete",i),o.preventDefault(),e.scrollToTheSelection()}),{priority:"low"}),ar.isAndroid){let t=null;this.listenTo(n,"delete",((e,n)=>{const o=n.domTarget.ownerDocument.defaultView.getSelection();t={anchorNode:o.anchorNode,anchorOffset:o.anchorOffset,focusNode:o.focusNode,focusOffset:o.focusOffset}}),{priority:"lowest"}),this.listenTo(n,"keyup",((e,n)=>{if(t){const e=n.domTarget.ownerDocument.defaultView.getSelection();e.collapse(t.anchorNode,t.anchorOffset),e.extend(t.focusNode,t.focusOffset),t=null}}))}this.editor.plugins.has("UndoEditing")&&(this.listenTo(n,"delete",((e,n)=>{this._undoOnBackspace&&"backward"==n.direction&&1==n.sequence&&"codePoint"==n.unit&&(this._undoOnBackspace=!1,t.execute("undo"),n.preventDefault(),e.stop())}),{context:"$capture"}),this.listenTo(o,"change",(()=>{this._undoOnBackspace=!1})))}requestUndoOnBackspace(){this.editor.plugins.has("UndoEditing")&&(this._undoOnBackspace=!0)}}const Hm=[pr("arrowUp"),pr("arrowRight"),pr("arrowDown"),pr("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 t=112;t<=135;t++)Hm.push(t);function qm(t){return!(!t.ctrlKey&&!t.metaKey)||Hm.includes(t.keyCode)}var Wm=n(5137),jm={attributes:{"data-cke":!0}};jm.setAttributes=is(),jm.insert=ns().bind(null,"head"),jm.domAPI=ts(),jm.insertStyleElement=ss();Qr()(Wm.Z,jm);Wm.Z&&Wm.Z.locals&&Wm.Z.locals;const Um=["before","after"],$m=(new DOMParser).parseFromString('',"image/svg+xml").firstChild,Gm="ck-widget__type-around_disabled";class Km extends pe{static get pluginName(){return"WidgetTypeAround"}static get requires(){return[Rm,Lm]}constructor(t){super(t),this._currentFakeCaretModelElement=null}init(){const t=this.editor,e=t.editing.view;this.on("change:isEnabled",((n,o,i)=>{e.change((t=>{for(const n of e.document.roots)i?t.removeClass(Gm,n):t.addClass(Gm,n)})),i||t.model.change((t=>{t.removeSelectionAttribute(am)}))})),this._enableTypeAroundUIInjection(),this._enableInsertingParagraphsOnButtonClick(),this._enableInsertingParagraphsOnEnterKeypress(),this._enableInsertingParagraphsOnTypingKeystroke(),this._enableTypeAroundFakeCaretActivationUsingKeyboardArrows(),this._enableDeleteIntegration(),this._enableInsertContentIntegration(),this._enableDeleteContentIntegration()}destroy(){this._currentFakeCaretModelElement=null}_insertParagraph(t,e){const n=this.editor,o=n.editing.view;n.execute("insertParagraph",{position:n.model.createPositionAt(t,e)}),o.focus(),o.scrollToTheSelection()}_listenToIfEnabled(t,e,n,o){this.listenTo(t,e,((...t)=>{this.isEnabled&&n(...t)}),o)}_insertParagraphAccordingToFakeCaretPosition(){const t=this.editor.model.document.selection,e=lm(t);if(!e)return!1;const n=t.getSelectedElement();return this._insertParagraph(n,e),!0}_enableTypeAroundUIInjection(){const t=this.editor,e=t.model.schema,n=t.locale.t,o={before:n("Insert paragraph before block"),after:n("Insert paragraph after block")};t.editing.downcastDispatcher.on("insert",((t,n,i)=>{const r=i.mapper.toViewElement(n.item);cm(r,n.item,e)&&function(t,e,n){const o=t.createUIElement("div",{class:"ck ck-reset_all ck-widget__type-around"},(function(t){const n=this.toDomElement(t);return function(t,e){for(const n of Um){const o=new Md({tag:"div",attributes:{class:["ck","ck-widget__type-around__button",`ck-widget__type-around__button_${n}`],title:e[n]},children:[t.ownerDocument.importNode($m,!0)]});t.appendChild(o.render())}}(n,e),function(t){const e=new Md({tag:"div",attributes:{class:["ck","ck-widget__type-around__fake-caret"]}});t.appendChild(e.render())}(n),n}));t.insert(t.createPositionAt(n,"end"),o)}(i.writer,o,r)}),{priority:"low"})}_enableTypeAroundFakeCaretActivationUsingKeyboardArrows(){const t=this.editor,e=t.model,n=e.document.selection,o=e.schema,i=t.editing.view;function r(t){return`ck-widget_type-around_show-fake-caret_${t}`}this._listenToIfEnabled(i.document,"arrowKey",((t,e)=>{this._handleArrowKeyPress(t,e)}),{context:[hm,"$text"],priority:"high"}),this._listenToIfEnabled(n,"change:range",((e,n)=>{n.directChange&&t.model.change((t=>{t.removeSelectionAttribute(am)}))})),this._listenToIfEnabled(e.document,"change:data",(()=>{const e=n.getSelectedElement();if(e){if(cm(t.editing.mapper.toViewElement(e),e,o))return}t.model.change((t=>{t.removeSelectionAttribute(am)}))})),this._listenToIfEnabled(t.editing.downcastDispatcher,"selection",((t,e,n)=>{const i=n.writer;if(this._currentFakeCaretModelElement){const t=n.mapper.toViewElement(this._currentFakeCaretModelElement);t&&(i.removeClass(Um.map(r),t),this._currentFakeCaretModelElement=null)}const s=e.selection.getSelectedElement();if(!s)return;const a=n.mapper.toViewElement(s);if(!cm(a,s,o))return;const c=lm(e.selection);c&&(i.addClass(r(c),a),this._currentFakeCaretModelElement=s)})),this._listenToIfEnabled(t.ui.focusTracker,"change:isFocused",((e,n,o)=>{o||t.model.change((t=>{t.removeSelectionAttribute(am)}))}))}_handleArrowKeyPress(t,e){const n=this.editor,o=n.model,i=o.document.selection,r=o.schema,s=n.editing.view,a=function(t,e){const n=fr(t,e);return"down"===n||"right"===n}(e.keyCode,n.locale.contentLanguageDirection),c=s.document.selection.getSelectedElement();let l;cm(c,n.editing.mapper.toModelElement(c),r)?l=this._handleArrowKeyPressOnSelectedWidget(a):i.isCollapsed?l=this._handleArrowKeyPressWhenSelectionNextToAWidget(a):e.shiftKey||(l=this._handleArrowKeyPressWhenNonCollapsedSelection(a)),l&&(e.preventDefault(),t.stop())}_handleArrowKeyPressOnSelectedWidget(t){const e=this.editor.model,n=lm(e.document.selection);return e.change((e=>{if(!n)return e.setSelectionAttribute(am,t?"after":"before"),!0;if(!(n===(t?"after":"before")))return e.removeSelectionAttribute(am),!0;return!1}))}_handleArrowKeyPressWhenSelectionNextToAWidget(t){const e=this.editor,n=e.model,o=n.schema,i=e.plugins.get("Widget"),r=i._getObjectElementNextToSelection(t);return!!cm(e.editing.mapper.toViewElement(r),r,o)&&(n.change((e=>{i._setSelectionOverElement(r),e.setSelectionAttribute(am,t?"before":"after")})),!0)}_handleArrowKeyPressWhenNonCollapsedSelection(t){const e=this.editor,n=e.model,o=n.schema,i=e.editing.mapper,r=n.document.selection,s=t?r.getLastPosition().nodeBefore:r.getFirstPosition().nodeAfter;return!!cm(i.toViewElement(s),s,o)&&(n.change((e=>{e.setSelection(s,"on"),e.setSelectionAttribute(am,t?"after":"before")})),!0)}_enableInsertingParagraphsOnButtonClick(){const t=this.editor,e=t.editing.view;this._listenToIfEnabled(e.document,"mousedown",((n,o)=>{const i=o.domTarget.closest(".ck-widget__type-around__button");if(!i)return;const r=function(t){return t.classList.contains("ck-widget__type-around__button_before")?"before":"after"}(i),s=function(t,e){const n=t.closest(".ck-widget");return e.mapDomToView(n)}(i,e.domConverter),a=t.editing.mapper.toModelElement(s);this._insertParagraph(a,r),o.preventDefault(),n.stop()}))}_enableInsertingParagraphsOnEnterKeypress(){const t=this.editor,e=t.model.document.selection,n=t.editing.view;this._listenToIfEnabled(n.document,"enter",((n,o)=>{if("atTarget"!=n.eventPhase)return;const i=e.getSelectedElement(),r=t.editing.mapper.toViewElement(i),s=t.model.schema;let a;this._insertParagraphAccordingToFakeCaretPosition()?a=!0:cm(r,i,s)&&(this._insertParagraph(i,o.isSoft?"before":"after"),a=!0),a&&(o.preventDefault(),n.stop())}),{context:hm})}_enableInsertingParagraphsOnTypingKeystroke(){const t=this.editor.editing.view,e=[ur.enter,ur.delete,ur.backspace];this._listenToIfEnabled(t.document,"keydown",((t,n)=>{e.includes(n.keyCode)||qm(n)||this._insertParagraphAccordingToFakeCaretPosition()}),{priority:"high"})}_enableDeleteIntegration(){const t=this.editor,e=t.editing.view,n=t.model,o=n.schema;this._listenToIfEnabled(e.document,"delete",((e,i)=>{if("atTarget"!=e.eventPhase)return;const r=lm(n.document.selection);if(!r)return;const s=i.direction,a=n.document.selection.getSelectedElement(),c="forward"==s;if("before"===r===c)t.execute("delete",{selection:n.createSelection(a,"on")});else{const e=o.getNearestSelectionRange(n.createPositionAt(a,r),s);if(e)if(e.isCollapsed){const i=n.createSelection(e.start);if(n.modifySelection(i,{direction:s}),i.focus.isEqual(e.start)){const t=function(t,e){let n=e;for(const o of e.getAncestors({parentFirst:!0})){if(o.childCount>1||t.isLimit(o))break;n=o}return n}(o,e.start.parent);n.deleteContent(n.createSelection(t,"on"),{doNotAutoparagraph:!0})}else n.change((n=>{n.setSelection(e),t.execute(c?"deleteForward":"delete")}))}else n.change((n=>{n.setSelection(e),t.execute(c?"deleteForward":"delete")}))}i.preventDefault(),e.stop()}),{context:hm})}_enableInsertContentIntegration(){const t=this.editor,e=this.editor.model,n=e.document.selection;this._listenToIfEnabled(t.model,"insertContent",((t,[o,i])=>{if(i&&!i.is("documentSelection"))return;const r=lm(n);return r?(t.stop(),e.change((t=>{const i=n.getSelectedElement(),s=e.createPositionAt(i,r),a=t.createSelection(s),c=e.insertContent(o,a);return t.setSelection(a),c}))):void 0}),{priority:"high"})}_enableDeleteContentIntegration(){const t=this.editor,e=this.editor.model.document.selection;this._listenToIfEnabled(t.model,"deleteContent",((t,[n])=>{if(n&&!n.is("documentSelection"))return;lm(e)&&t.stop()}),{priority:"high"})}}function Zm(t){const e=t.model;return(n,o)=>{const i=o.keyCode==ur.arrowup,r=o.keyCode==ur.arrowdown,s=o.shiftKey,a=e.document.selection;if(!i&&!r)return;const c=r;if(s&&function(t,e){return!t.isCollapsed&&t.isBackward==e}(a,c))return;const l=function(t,e,n){const o=t.model;if(n){const t=e.isCollapsed?e.focus:e.getLastPosition(),n=Jm(o,t,"forward");if(!n)return null;const i=o.createRange(t,n),r=Ym(o.schema,i,"backward");return r?o.createRange(t,r):null}{const t=e.isCollapsed?e.focus:e.getFirstPosition(),n=Jm(o,t,"backward");if(!n)return null;const i=o.createRange(n,t),r=Ym(o.schema,i,"forward");return r?o.createRange(r,t):null}}(t,a,c);if(l){if(l.isCollapsed){if(a.isCollapsed)return;if(s)return}(l.isCollapsed||function(t,e,n){const o=t.model,i=t.view.domConverter;if(n){const t=o.createSelection(e.start);o.modifySelection(t),t.focus.isAtEnd||e.start.isEqual(t.focus)||(e=o.createRange(t.focus,e.end))}const r=t.mapper.toViewRange(e),s=i.viewRangeToDom(r),a=ya.getDomRangeRects(s);let c;for(const t of a)if(void 0!==c){if(Math.round(t.top)>=c)return!1;c=Math.max(c,Math.round(t.bottom))}else c=Math.round(t.bottom);return!0}(t,l,c))&&(e.change((t=>{const n=c?l.end:l.start;if(s){const o=e.createSelection(a.anchor);o.setFocus(n),t.setSelection(o)}else t.setSelection(n)})),n.stop(),o.preventDefault(),o.stopPropagation())}}}function Jm(t,e,n){const o=t.schema,i=t.createRangeIn(e.root),r="forward"==n?"elementStart":"elementEnd";for(const{previousPosition:t,item:s,type:a}of i.getWalker({startPosition:e,direction:n})){if(o.isLimit(s)&&!o.isInline(s))return t;if(a==r&&o.isBlock(s))return null}return null}function Ym(t,e,n){const o="backward"==n?e.end:e.start;if(t.checkChild(o,"$text"))return o;for(const{nextPosition:o}of e.getWalker({direction:n}))if(t.checkChild(o,"$text"))return o;return null}var Qm=n(6507),Xm={attributes:{"data-cke":!0}};Xm.setAttributes=is(),Xm.insert=ns().bind(null,"head"),Xm.domAPI=ts(),Xm.insertStyleElement=ss();Qr()(Qm.Z,Xm);Qm.Z&&Qm.Z.locals&&Qm.Z.locals;class tg extends pe{static get pluginName(){return"Widget"}static get requires(){return[Km,Lm]}init(){const t=this.editor,e=t.editing.view,n=e.document;this._previouslySelected=new Set,this.editor.editing.downcastDispatcher.on("selection",((e,n,o)=>{const i=o.writer,r=n.selection;if(r.isCollapsed)return;const s=r.getSelectedElement();if(!s)return;const a=t.editing.mapper.toViewElement(s);hm(a)&&o.consumable.consume(r,"selection")&&i.setSelection(i.createRangeOn(a),{fake:!0,label:bm(a)})})),this.editor.editing.downcastDispatcher.on("selection",((t,e,n)=>{this._clearPreviouslySelectedWidgets(n.writer);const o=n.writer,i=o.document.selection;let r=null;for(const t of i.getRanges())for(const e of t){const t=e.item;hm(t)&&!eg(t,r)&&(o.addClass(um,t),this._previouslySelected.add(t),r=t)}}),{priority:"low"}),e.addObserver(hp),this.listenTo(n,"mousedown",((...t)=>this._onMousedown(...t))),this.listenTo(n,"arrowKey",((...t)=>{this._handleSelectionChangeOnArrowKeyPress(...t)}),{context:[hm,"$text"]}),this.listenTo(n,"arrowKey",((...t)=>{this._preventDefaultOnArrowKeyPress(...t)}),{context:"$root"}),this.listenTo(n,"arrowKey",Zm(this.editor.editing),{context:"$text"}),this.listenTo(n,"delete",((t,e)=>{this._handleDelete("forward"==e.direction)&&(e.preventDefault(),t.stop())}),{context:"$root"})}_onMousedown(t,e){const n=this.editor,o=n.editing.view,i=o.document;let r=e.target;if(function(t){for(;t;){if(t.is("editableElement")&&!t.is("rootElement"))return!0;if(hm(t))return!1;t=t.parent}return!1}(r)){if((ar.isSafari||ar.isGecko)&&e.domEvent.detail>=3){const t=n.editing.mapper,o=r.is("attributeElement")?r.findAncestor((t=>!t.is("attributeElement"))):r,i=t.toModelElement(o);e.preventDefault(),this.editor.model.change((t=>{t.setSelection(i,"in")}))}return}if(!hm(r)&&(r=r.findAncestor(hm),!r))return;ar.isAndroid&&e.preventDefault(),i.isFocused||o.focus();const s=n.editing.mapper.toModelElement(r);this._setSelectionOverElement(s)}_handleSelectionChangeOnArrowKeyPress(t,e){const n=e.keyCode,o=this.editor.model,i=o.schema,r=o.document.selection,s=r.getSelectedElement(),a=fr(n,this.editor.locale.contentLanguageDirection),c="down"==a||"right"==a,l="up"==a||"down"==a;if(s&&i.isObject(s)){const n=c?r.getLastPosition():r.getFirstPosition(),s=i.getNearestSelectionRange(n,c?"forward":"backward");return void(s&&(o.change((t=>{t.setSelection(s)})),e.preventDefault(),t.stop()))}if(!r.isCollapsed&&!e.shiftKey){const n=r.getFirstPosition(),s=r.getLastPosition(),a=n.nodeAfter,l=s.nodeBefore;return void((a&&i.isObject(a)||l&&i.isObject(l))&&(o.change((t=>{t.setSelection(c?s:n)})),e.preventDefault(),t.stop()))}if(!r.isCollapsed)return;const d=this._getObjectElementNextToSelection(c);if(d&&i.isObject(d)){if(i.isInline(d)&&l)return;this._setSelectionOverElement(d),e.preventDefault(),t.stop()}}_preventDefaultOnArrowKeyPress(t,e){const n=this.editor.model,o=n.schema,i=n.document.selection.getSelectedElement();i&&o.isObject(i)&&(e.preventDefault(),t.stop())}_handleDelete(t){if(this.editor.isReadOnly)return;const e=this.editor.model.document.selection;if(!e.isCollapsed)return;const n=this._getObjectElementNextToSelection(t);return n?(this.editor.model.change((t=>{let o=e.anchor.parent;for(;o.isEmpty;){const e=o;o=e.parent,t.remove(e)}this._setSelectionOverElement(n)})),!0):void 0}_setSelectionOverElement(t){this.editor.model.change((e=>{e.setSelection(e.createRangeOn(t))}))}_getObjectElementNextToSelection(t){const e=this.editor.model,n=e.schema,o=e.document.selection,i=e.createSelection(o);if(e.modifySelection(i,{direction:t?"forward":"backward"}),i.isEqual(o))return null;const r=t?i.focus.nodeBefore:i.focus.nodeAfter;return r&&n.isObject(r)?r:null}_clearPreviouslySelectedWidgets(t){for(const e of this._previouslySelected)t.removeClass(um,e);this._previouslySelected.clear()}}function eg(t,e){return!!e&&Array.from(t.getAncestors()).includes(e)}function ng(t,e,n){t.ui.componentFactory.add(e,(e=>{const o=new pu(e);return o.set({label:I18n.t("js.button_edit"),icon:'\n',tooltip:!0}),o.on("execute",(()=>{const e=t.model.document.selection.getSelectedElement();e&&n(e)})),o}))}const og="ck-toolbar-container";function ig(t,e,n,o){const i=e.config.get(n+".toolbar");if(!i||!i.length)return;const r=e.plugins.get("ContextualBalloon"),s=new Wu(e.locale);function a(){e.ui.focusTracker.isFocused&&o(e.editing.view.document.selection)?l()?function(t,e){const n=t.plugins.get("ContextualBalloon");if(e(t.editing.view.document.selection)){const e=rg(t);n.updatePosition(e)}}(e,o):r.hasView(s)||r.add({view:s,position:rg(e),balloonClassName:og}):c()}function c(){l()&&r.remove(s)}function l(){return r.visibleView==s}s.fillFromConfig(i,e.ui.componentFactory),t.listenTo(e.editing.view,"render",a),t.listenTo(e.ui.focusTracker,"change:isFocused",a,{priority:"low"})}function rg(t){const e=t.editing.view,n=Ih.defaultPositions;return{target:e.domConverter.viewToDom(e.document.selection.getSelectedElement()),positions:[n.northArrowSouth,n.northArrowSouthWest,n.northArrowSouthEast,n.southArrowNorth,n.southArrowNorthWest,n.southArrowNorthEast]}}class sg extends pe{static get requires(){return[Vh]}static get pluginName(){return"EmbeddedTableToolbar"}init(){const t=this.editor,e=this.editor.model,n=xm(t);ng(t,"opEditEmbeddedTableQuery",(t=>{const o=n.services.externalQueryConfiguration,i=t.getAttribute("opEmbeddedTableQuery")||{};n.runInZone((()=>{o.show({currentQuery:i,callback:n=>e.change((e=>{e.setAttribute("opEmbeddedTableQuery",n,t)}))})}))}))}afterInit(){ig(this,this.editor,"OPMacroEmbeddedTable",vm)}}const ag=Symbol("isWpButtonMacroSymbol");function cg(t){const e=t.getSelectedElement();return!(!e||!function(t){return!!t.getCustomProperty(ag)&&hm(t)}(e))}class lg extends pe{static get pluginName(){return"OPMacroWpButtonEditing"}static get buttonName(){return"insertWorkPackageButton"}init(){const t=this.editor,e=t.model,n=t.conversion,o=xm(t);e.schema.register("op-macro-wp-button",{allowWhere:["$block"],allowAttributes:["type","classes"],isBlock:!0,isLimit:!0}),n.for("upcast").elementToElement({view:{name:"macro",classes:"create_work_package_link"},model:(t,{writer:e})=>{const n=t.getAttribute("data-type")||"",o=t.getAttribute("data-classes")||"";return e.createElement("op-macro-wp-button",{type:n,classes:o})}}),n.for("editingDowncast").elementToElement({model:"op-macro-wp-button",view:(t,{writer:e})=>this.createMacroViewElement(t,e)}),n.for("dataDowncast").elementToElement({model:"op-macro-wp-button",view:(t,{writer:e})=>e.createContainerElement("macro",{class:"create_work_package_link","data-type":t.getAttribute("type")||"","data-classes":t.getAttribute("classes")||""})}),t.ui.componentFactory.add(lg.buttonName,(e=>{const n=new pu(e);return n.set({label:window.I18n.t("js.editor.macro.work_package_button.button"),withText:!0}),n.on("execute",(()=>{o.services.macros.configureWorkPackageButton().then((e=>t.model.change((n=>{const o=n.createElement("op-macro-wp-button",{});n.setAttribute("type",e.type,o),n.setAttribute("classes",e.classes,o),t.model.insertContent(o,t.model.document.selection)}))))})),n}))}macroLabel(t){return t?window.I18n.t("js.editor.macro.work_package_button.with_type",{typename:t}):window.I18n.t("js.editor.macro.work_package_button.without_type")}createMacroViewElement(t,e){t.getAttribute("type");const n=t.getAttribute("classes")||"",o=this.macroLabel(),i=e.createText(o),r=e.createContainerElement("span",{class:n});return e.insert(e.createPositionAt(r,0),i),function(t,e,n){return e.setCustomProperty(ag,!0,t),pm(t,e,{label:n})}(r,e,{label:o})}}class dg extends pe{static get requires(){return[Vh]}static get pluginName(){return"OPMacroWpButtonToolbar"}init(){const t=this.editor,e=(this.editor.model,xm(t));ng(t,"opEditWpMacroButton",(n=>{const o=e.services.macros,i=n.getAttribute("type"),r=n.getAttribute("classes");o.configureWorkPackageButton(i,r).then((e=>t.model.change((t=>{t.setAttribute("classes",e.classes,n),t.setAttribute("type",e.type,n)}))))}))}afterInit(){ig(this,this.editor,"OPMacroWpButton",cg)}}class ug{constructor(){const t=new window.FileReader;this._reader=t,this._data=void 0,this.set("loaded",0),t.onprogress=t=>{this.loaded=t.loaded}}get error(){return this._reader.error}get data(){return this._data}read(t){const e=this._reader;return this.total=t.size,new Promise(((n,o)=>{e.onload=()=>{const t=e.result;this._data=t,n(t)},e.onerror=()=>{o("error")},e.onabort=()=>{o("aborted")},this._reader.readAsDataURL(t)}))}abort(){this._reader.abort()}}he(ug,se);class hg extends pe{static get pluginName(){return"FileRepository"}static get requires(){return[Sd]}init(){this.loaders=new So,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",((t,e)=>e?t/e*100:0))}getLoader(t){return this._loadersMap.get(t)||null}createLoader(t){if(!this.createUploadAdapter)return a("filerepository-no-upload-adapter"),null;const e=new pg(Promise.resolve(t),this.createUploadAdapter);return this.loaders.add(e),this._loadersMap.set(t,e),t instanceof Promise&&e.file.then((t=>{this._loadersMap.set(t,e)})).catch((()=>{})),e.on("change:uploaded",(()=>{let t=0;for(const e of this.loaders)t+=e.uploaded;this.uploaded=t})),e.on("change:uploadTotal",(()=>{let t=0;for(const e of this.loaders)e.uploadTotal&&(t+=e.uploadTotal);this.uploadTotal=t})),e}destroyLoader(t){const e=t instanceof pg?t:this.getLoader(t);e._destroy(),this.loaders.remove(e),this._loadersMap.forEach(((t,n)=>{t===e&&this._loadersMap.delete(n)}))}_updatePendingAction(){const t=this.editor.plugins.get(Sd);if(this.loaders.length){if(!this._pendingAction){const e=this.editor.t,n=t=>`${e("Upload in progress")} ${parseInt(t)}%.`;this._pendingAction=t.add(n(this.uploadedPercent)),this._pendingAction.bind("message").to(this,"uploadedPercent",n)}}else t.remove(this._pendingAction),this._pendingAction=null}}he(hg,se);class pg{constructor(t,e){this.id=i(),this._filePromiseWrapper=this._createFilePromiseWrapper(t),this._adapter=e(this),this._reader=new ug,this.set("status","idle"),this.set("uploaded",0),this.set("uploadTotal",null),this.bind("uploadedPercent").to(this,"uploaded",this,"uploadTotal",((t,e)=>e?t/e*100:0)),this.set("uploadResponse",null)}get file(){return this._filePromiseWrapper?this._filePromiseWrapper.promise.then((t=>this._filePromiseWrapper?t:null)):Promise.resolve(null)}get data(){return this._reader.data}read(){if("idle"!=this.status)throw new s("filerepository-read-wrong-status",this);return this.status="reading",this.file.then((t=>this._reader.read(t))).then((t=>{if("reading"!==this.status)throw this.status;return this.status="idle",t})).catch((t=>{if("aborted"===t)throw this.status="aborted","aborted";throw this.status="error",this._reader.error?this._reader.error:t}))}upload(){if("idle"!=this.status)throw new s("filerepository-upload-wrong-status",this);return this.status="uploading",this.file.then((()=>this._adapter.upload())).then((t=>(this.uploadResponse=t,this.status="idle",t))).catch((t=>{if("aborted"===this.status)throw"aborted";throw this.status="error",t}))}abort(){const t=this.status;this.status="aborted",this._filePromiseWrapper.isFulfilled?"reading"==t?this._reader.abort():"uploading"==t&&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(t){const e={};return e.promise=new Promise(((n,o)=>{e.rejecter=o,e.isFulfilled=!1,t.then((t=>{e.isFulfilled=!0,n(t)})).catch((t=>{e.isFulfilled=!0,o(t)}))})),e}}he(pg,se);class mg{constructor(t,e,n){this.loader=t,this.resource=e,this.editor=n}upload(){const t=this.resource,e=Em(this.editor,"attachmentsResourceService");return t?this.loader.file.then((n=>e.attachFiles(t,[n]).toPromise().then((t=>(this.editor.model.fire("op:attachment-added",t),this.buildResponse(t[0])))).catch((t=>{console.error("Failed upload %O",t)})))):(console.warn("resource not available in this CKEditor instance"),Promise.reject("Not possible to upload attachments without resource"))}buildResponse(t){return{default:t._links.staticDownloadLocation.href}}abort(){return!1}}class gg extends Od{constructor(t){super(t),this.buttonView=new pu(t),this._fileInputView=new fg(t),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 fg extends Od{constructor(t){super(t),this.set("acceptedType"),this.set("allowMultipleFiles",!1);const e=this.bindTemplate;this.setTemplate({tag:"input",attributes:{class:["ck-hidden"],type:"file",tabindex:"-1",accept:e.to("acceptedType"),multiple:e.to("allowMultipleFiles")},on:{change:e.to((()=>{this.element&&this.element.files&&this.element.files.length&&this.fire("done",this.element.files),this.element.value=""}))}})}open(){this.element.click()}}function bg(t){const e=t.map((t=>t.replace("+","\\+")));return new RegExp(`^image\\/(${e.join("|")})$`)}function kg(t){return new Promise(((e,n)=>{const o=t.getAttribute("src");fetch(o).then((t=>t.blob())).then((t=>{const n=wg(t,o),i=n.replace("image/",""),r=new File([t],`image.${i}`,{type:n});e(r)})).catch((t=>t&&"TypeError"===t.name?function(t){return function(t){return new Promise(((e,n)=>{const o=ps.document.createElement("img");o.addEventListener("load",(()=>{const t=ps.document.createElement("canvas");t.width=o.width,t.height=o.height;t.getContext("2d").drawImage(o,0,0),t.toBlob((t=>t?e(t):n()))})),o.addEventListener("error",(()=>n())),o.src=t}))}(t).then((e=>{const n=wg(e,t),o=n.replace("image/","");return new File([e],`image.${o}`,{type:n})}))}(o).then(e).catch(n):n(t)))}))}function wg(t,e){return t.type?t.type:e.match(/data:(image\/\w+);base64/)?e.match(/data:(image\/\w+);base64/)[1].toLowerCase():"image/jpeg"}class _g extends pe{static get pluginName(){return"ImageUploadUI"}init(){const t=this.editor,e=t.t,n=n=>{const o=new gg(n),i=t.commands.get("uploadImage"),r=t.config.get("image.upload.types"),s=bg(r);return o.set({acceptedType:r.map((t=>`image/${t}`)).join(","),allowMultipleFiles:!0}),o.buttonView.set({label:e("Insert image"),icon:Td.image,tooltip:!0}),o.buttonView.bind("isEnabled").to(i),o.on("done",((e,n)=>{const o=Array.from(n).filter((t=>s.test(t.type)));o.length&&t.execute("uploadImage",{file:o})})),o};t.ui.componentFactory.add("uploadImage",n),t.ui.componentFactory.add("imageUpload",n)}}var Cg=n(5870),Ag={attributes:{"data-cke":!0}};Ag.setAttributes=is(),Ag.insert=ns().bind(null,"head"),Ag.domAPI=ts(),Ag.insertStyleElement=ss();Qr()(Cg.Z,Ag);Cg.Z&&Cg.Z.locals&&Cg.Z.locals;var vg=n(9899),yg={attributes:{"data-cke":!0}};yg.setAttributes=is(),yg.insert=ns().bind(null,"head"),yg.domAPI=ts(),yg.insertStyleElement=ss();Qr()(vg.Z,yg);vg.Z&&vg.Z.locals&&vg.Z.locals;var xg=n(9825),Eg={attributes:{"data-cke":!0}};Eg.setAttributes=is(),Eg.insert=ns().bind(null,"head"),Eg.domAPI=ts(),Eg.insertStyleElement=ss();Qr()(xg.Z,Eg);xg.Z&&xg.Z.locals&&xg.Z.locals;class Dg extends pe{static get pluginName(){return"ImageUploadProgress"}constructor(t){super(t),this.placeholder="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="}init(){const t=this.editor;t.plugins.has("ImageBlockEditing")&&t.editing.downcastDispatcher.on("attribute:uploadStatus:imageBlock",((...t)=>this.uploadStatusChange(...t))),t.plugins.has("ImageInlineEditing")&&t.editing.downcastDispatcher.on("attribute:uploadStatus:imageInline",((...t)=>this.uploadStatusChange(...t)))}uploadStatusChange(t,e,n){const o=this.editor,i=e.item,r=i.getAttribute("uploadId");if(!n.consumable.consume(e.item,t.name))return;const s=o.plugins.get("ImageUtils"),a=o.plugins.get(hg),c=r?e.attributeNewValue:null,l=this.placeholder,d=o.editing.mapper.toViewElement(i),u=n.writer;if("reading"==c)return Sg(d,u),void Bg(s,l,d,u);if("uploading"==c){const t=a.loaders.get(r);return Sg(d,u),void(t?(Tg(d,u),function(t,e,n,o){const i=function(t){const e=t.createUIElement("div",{class:"ck-progress-bar"});return t.setCustomProperty("progressBar",!0,e),e}(e);e.insert(e.createPositionAt(t,"end"),i),n.on("change:uploadedPercent",((t,e,n)=>{o.change((t=>{t.setStyle("width",n+"%",i)}))}))}(d,u,t,o.editing.view),function(t,e,n,o){if(o.data){const i=t.findViewImgElement(e);n.setAttribute("src",o.data,i)}}(s,d,u,t)):Bg(s,l,d,u))}"complete"==c&&a.loaders.get(r)&&function(t,e,n){const o=e.createUIElement("div",{class:"ck-image-upload-complete-icon"});e.insert(e.createPositionAt(t,"end"),o),setTimeout((()=>{n.change((t=>t.remove(t.createRangeOn(o))))}),3e3)}(d,u,o.editing.view),function(t,e){Ig(t,e,"progressBar")}(d,u),Tg(d,u),function(t,e){e.removeClass("ck-appear",t)}(d,u)}}function Sg(t,e){t.hasClass("ck-appear")||e.addClass("ck-appear",t)}function Bg(t,e,n,o){n.hasClass("ck-image-upload-placeholder")||o.addClass("ck-image-upload-placeholder",n);const i=t.findViewImgElement(n);i.getAttribute("src")!==e&&o.setAttribute("src",e,i),Pg(n,"placeholder")||o.insert(o.createPositionAfter(i),function(t){const e=t.createUIElement("div",{class:"ck-upload-placeholder-loader"});return t.setCustomProperty("placeholder",!0,e),e}(o))}function Tg(t,e){t.hasClass("ck-image-upload-placeholder")&&e.removeClass("ck-image-upload-placeholder",t),Ig(t,e,"placeholder")}function Pg(t,e){for(const n of t.getChildren())if(n.getCustomProperty(e))return n}function Ig(t,e,n){const o=Pg(t,n);o&&e.remove(e.createRangeOn(o))}class Rg{constructor(t){this.files=function(t){const e=Array.from(t.files||[]),n=Array.from(t.items||[]);if(e.length)return e;return n.filter((t=>"file"===t.kind)).map((t=>t.getAsFile()))}(t),this._native=t}get types(){return this._native.types}getData(t){return this._native.getData(t)}setData(t,e){this._native.setData(t,e)}set effectAllowed(t){this._native.effectAllowed=t}get effectAllowed(){return this._native.effectAllowed}set dropEffect(t){this._native.dropEffect=t}get dropEffect(){return this._native.dropEffect}get isCanceled(){return"none"==this._native.dropEffect||!!this._native.mozUserCancelled}}class zg extends Xs{constructor(t){super(t);const n=this.document;function o(t){return(o,i)=>{i.preventDefault();const r=i.dropRange?[i.dropRange]:null,s=new e(n,t);n.fire(s,{dataTransfer:i.dataTransfer,method:o.name,targetRanges:r,target:i.target}),s.stop.called&&i.stopPropagation()}}this.domEventType=["paste","copy","cut","drop","dragover","dragstart","dragend","dragenter","dragleave"],this.listenTo(n,"paste",o("clipboardInput"),{priority:"low"}),this.listenTo(n,"drop",o("clipboardInput"),{priority:"low"}),this.listenTo(n,"dragover",o("dragging"),{priority:"low"})}onDomEvent(t){const e={dataTransfer:new Rg(t.clipboardData?t.clipboardData:t.dataTransfer)};"drop"!=t.type&&"dragover"!=t.type||(e.dropRange=function(t,e){const n=e.target.ownerDocument,o=e.clientX,i=e.clientY;let r;n.caretRangeFromPoint&&n.caretRangeFromPoint(o,i)?r=n.caretRangeFromPoint(o,i):e.rangeParent&&(r=n.createRange(),r.setStart(e.rangeParent,e.rangeOffset),r.collapse(!0));if(r)return t.domConverter.domRangeToView(r);return null}(this.view,t)),this.fire(t.type,t,e)}}const Fg=["figcaption","li"];function Ng(t){let e="";if(t.is("$text")||t.is("$textProxy"))e=t.data;else if(t.is("element","img")&&t.hasAttribute("alt"))e=t.getAttribute("alt");else if(t.is("element","br"))e="\n";else{let n=null;for(const o of t.getChildren()){const t=Ng(o);n&&(n.is("containerElement")||o.is("containerElement"))&&(Fg.includes(n.name)||Fg.includes(o.name)?e+="\n":e+="\n\n"),e+=t,n=o}}return e}class Og extends pe{static get pluginName(){return"ClipboardPipeline"}init(){this.editor.editing.view.addObserver(zg),this._setupPasteDrop(),this._setupCopyCut()}_setupPasteDrop(){const t=this.editor,n=t.model,o=t.editing.view,i=o.document;this.listenTo(i,"clipboardInput",(e=>{t.isReadOnly&&e.stop()}),{priority:"highest"}),this.listenTo(i,"clipboardInput",((t,n)=>{const i=n.dataTransfer;let r=n.content||"";var s;r||(i.getData("text/html")?r=function(t){return t.replace(/(\s+)<\/span>/g,((t,e)=>1==e.length?" ":e)).replace(//g,"")}(i.getData("text/html")):i.getData("text/plain")&&(((s=(s=i.getData("text/plain")).replace(//g,">").replace(/\r?\n\r?\n/g,"

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

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

${s}

`),r=s),r=this.editor.data.htmlProcessor.toView(r));const a=new e(this,"inputTransformation");this.fire(a,{content:r,dataTransfer:i,targetRanges:n.targetRanges,method:n.method}),a.stop.called&&t.stop(),o.scrollToTheSelection()}),{priority:"low"}),this.listenTo(this,"inputTransformation",((t,e)=>{if(e.content.isEmpty)return;const o=this.editor.data.toModel(e.content,"$clipboardHolder");0!=o.childCount&&(t.stop(),n.change((()=>{this.fire("contentInsertion",{content:o,method:e.method,dataTransfer:e.dataTransfer,targetRanges:e.targetRanges})})))}),{priority:"low"}),this.listenTo(this,"contentInsertion",((t,e)=>{e.resultRange=n.insertContent(e.content)}),{priority:"low"})}_setupCopyCut(){const t=this.editor,e=t.model.document,n=t.editing.view.document;function o(o,i){const r=i.dataTransfer;i.preventDefault();const s=t.data.toView(t.model.getSelectedContent(e.selection));n.fire("clipboardOutput",{dataTransfer:r,content:s,method:o.name})}this.listenTo(n,"copy",o,{priority:"low"}),this.listenTo(n,"cut",((e,n)=>{t.isReadOnly?n.preventDefault():o(e,n)}),{priority:"low"}),this.listenTo(n,"clipboardOutput",((n,o)=>{o.content.isEmpty||(o.dataTransfer.setData("text/html",this.editor.data.htmlProcessor.toData(o.content)),o.dataTransfer.setData("text/plain",Ng(o.content))),"cut"==o.method&&t.model.deleteContent(e.selection)}),{priority:"low"})}}var Mg=n(390),Vg={attributes:{"data-cke":!0}};Vg.setAttributes=is(),Vg.insert=ns().bind(null,"head"),Vg.domAPI=ts(),Vg.insertStyleElement=ss();Qr()(Mg.Z,Vg);Mg.Z&&Mg.Z.locals&&Mg.Z.locals;class Lg extends pe{static get pluginName(){return"DragDrop"}static get requires(){return[Og,tg]}init(){const t=this.editor,e=t.editing.view;this._draggedRange=null,this._draggingUid="",this._draggableElement=null,this._updateDropMarkerThrottled=tm((t=>this._updateDropMarker(t)),40),this._removeDropMarkerDelayed=Wg((()=>this._removeDropMarker()),40),this._clearDraggableAttributesDelayed=Wg((()=>this._clearDraggableAttributes()),40),e.addObserver(zg),e.addObserver(hp),this._setupDragging(),this._setupContentInsertionIntegration(),this._setupClipboardInputIntegration(),this._setupDropMarker(),this._setupDraggableAttributeHandling(),this.listenTo(t,"change:isReadOnly",((t,e,n)=>{n?this.forceDisabled("readOnlyMode"):this.clearForceDisabled("readOnlyMode")})),this.on("change:isEnabled",((t,e,n)=>{n||this._finalizeDragging(!1)})),ar.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 t=this.editor,e=t.model,n=e.document,o=t.editing.view,r=o.document;this.listenTo(r,"dragstart",((o,s)=>{const a=n.selection;if(s.target&&s.target.is("editableElement"))return void s.preventDefault();const c=s.target?jg(s.target):null;if(c){const n=t.editing.mapper.toModelElement(c);this._draggedRange=gc.fromRange(e.createRangeOn(n)),t.plugins.has("WidgetToolbarRepository")&&t.plugins.get("WidgetToolbarRepository").forceDisabled("dragDrop")}else if(!r.selection.isCollapsed){const t=r.selection.getSelectedElement();t&&hm(t)||(this._draggedRange=gc.fromRange(a.getFirstRange()))}if(!this._draggedRange)return void s.preventDefault();this._draggingUid=i(),s.dataTransfer.effectAllowed=this.isEnabled?"copyMove":"copy",s.dataTransfer.setData("application/ckeditor5-dragging-uid",this._draggingUid);const l=e.createSelection(this._draggedRange.toRange()),d=t.data.toView(e.getSelectedContent(l));r.fire("clipboardOutput",{dataTransfer:s.dataTransfer,content:d,method:o.name}),this.isEnabled||(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="")}),{priority:"low"}),this.listenTo(r,"dragend",((t,e)=>{this._finalizeDragging(!e.dataTransfer.isCanceled&&"move"==e.dataTransfer.dropEffect)}),{priority:"low"}),this.listenTo(r,"dragenter",(()=>{this.isEnabled&&o.focus()})),this.listenTo(r,"dragleave",(()=>{this._removeDropMarkerDelayed()})),this.listenTo(r,"dragging",((e,n)=>{if(!this.isEnabled)return void(n.dataTransfer.dropEffect="none");this._removeDropMarkerDelayed.cancel();const o=Hg(t,n.targetRanges,n.target);this._draggedRange||(n.dataTransfer.dropEffect="copy"),ar.isGecko||("copy"==n.dataTransfer.effectAllowed?n.dataTransfer.dropEffect="copy":["all","copyMove"].includes(n.dataTransfer.effectAllowed)&&(n.dataTransfer.dropEffect="move")),o&&this._updateDropMarkerThrottled(o)}),{priority:"low"})}_setupClipboardInputIntegration(){const t=this.editor,e=t.editing.view.document;this.listenTo(e,"clipboardInput",((e,n)=>{if("drop"!=n.method)return;const o=Hg(t,n.targetRanges,n.target);if(this._removeDropMarker(),!o)return this._finalizeDragging(!1),void e.stop();this._draggedRange&&this._draggingUid!=n.dataTransfer.getData("application/ckeditor5-dragging-uid")&&(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="");if("move"==qg(n.dataTransfer)&&this._draggedRange&&this._draggedRange.containsRange(o,!0))return this._finalizeDragging(!1),void e.stop();n.targetRanges=[t.editing.mapper.toViewRange(o)]}),{priority:"high"})}_setupContentInsertionIntegration(){const t=this.editor.plugins.get(Og);t.on("contentInsertion",((t,e)=>{if(!this.isEnabled||"drop"!==e.method)return;const n=e.targetRanges.map((t=>this.editor.editing.mapper.toModelRange(t)));this.editor.model.change((t=>t.setSelection(n)))}),{priority:"high"}),t.on("contentInsertion",((t,e)=>{if(!this.isEnabled||"drop"!==e.method)return;const n="move"==qg(e.dataTransfer),o=!e.resultRange||!e.resultRange.isCollapsed;this._finalizeDragging(o&&n)}),{priority:"lowest"})}_setupDraggableAttributeHandling(){const t=this.editor,e=t.editing.view,n=e.document;this.listenTo(n,"mousedown",((o,i)=>{if(ar.isAndroid||!i)return;this._clearDraggableAttributesDelayed.cancel();let r=jg(i.target);if(ar.isBlink&&!t.isReadOnly&&!r&&!n.selection.isCollapsed){const t=n.selection.getSelectedElement();t&&hm(t)||(r=n.selection.editableElement)}r&&(e.change((t=>{t.setAttribute("draggable","true",r)})),this._draggableElement=t.editing.mapper.toModelElement(r))})),this.listenTo(n,"mouseup",(()=>{ar.isAndroid||this._clearDraggableAttributesDelayed()}))}_clearDraggableAttributes(){const t=this.editor.editing;t.view.change((e=>{this._draggableElement&&"$graveyard"!=this._draggableElement.root.rootName&&e.removeAttribute("draggable",t.mapper.toViewElement(this._draggableElement)),this._draggableElement=null}))}_setupDropMarker(){const t=this.editor;t.conversion.for("editingDowncast").markerToHighlight({model:"drop-target",view:{classes:["ck-clipboard-drop-target-range"]}}),t.conversion.for("editingDowncast").markerToElement({model:"drop-target",view:(e,{writer:n})=>{if(t.model.schema.checkChild(e.markerRange.start,"$text"))return n.createUIElement("span",{class:"ck ck-clipboard-drop-target-position"},(function(t){const e=this.toDomElement(t);return e.innerHTML="⁠⁠",e}))}})}_updateDropMarker(t){const e=this.editor,n=e.model.markers;e.model.change((e=>{n.has("drop-target")?n.get("drop-target").getRange().isEqual(t)||e.updateMarker("drop-target",{range:t}):e.addMarker("drop-target",{range:t,usingOperation:!1,affectsData:!1})}))}_removeDropMarker(){const t=this.editor.model;this._removeDropMarkerDelayed.cancel(),this._updateDropMarkerThrottled.cancel(),t.markers.has("drop-target")&&t.change((t=>{t.removeMarker("drop-target")}))}_finalizeDragging(t){const e=this.editor,n=e.model;this._removeDropMarker(),this._clearDraggableAttributes(),e.plugins.has("WidgetToolbarRepository")&&e.plugins.get("WidgetToolbarRepository").clearForceDisabled("dragDrop"),this._draggingUid="",this._draggedRange&&(t&&this.isEnabled&&n.deleteContent(n.createSelection(this._draggedRange),{doNotAutoparagraph:!0}),this._draggedRange.detach(),this._draggedRange=null)}}function Hg(t,e,n){const o=t.model,i=t.editing.mapper;let r=null;const s=e?e[0].start:null;if(n.is("uiElement")&&(n=n.parent),r=function(t,e){const n=t.model,o=t.editing.mapper;if(hm(e))return n.createRangeOn(o.toModelElement(e));if(!e.is("editableElement")){const t=e.findAncestor((t=>hm(t)||t.is("editableElement")));if(hm(t))return n.createRangeOn(o.toModelElement(t))}return null}(t,n),r)return r;const a=function(t,e){const n=t.editing.mapper,o=t.editing.view,i=n.toModelElement(e);if(i)return i;const r=o.createPositionBefore(e),s=n.findMappedViewAncestor(r);return n.toModelElement(s)}(t,n),c=s?i.toModelPosition(s):null;return c?(r=function(t,e,n){const o=t.model;if(!o.schema.checkChild(n,"$block"))return null;const i=o.createPositionAt(n,0),r=e.path.slice(0,i.path.length),s=o.createPositionFromPath(e.root,r).nodeAfter;if(s&&o.schema.isObject(s))return o.createRangeOn(s);return null}(t,c,a),r||(r=o.schema.getNearestSelectionRange(c,ar.isGecko?"forward":"backward"),r||function(t,e){const n=t.model;for(;e;){if(n.schema.isObject(e))return n.createRangeOn(e);e=e.parent}}(t,c.parent))):function(t,e){const n=t.model,o=n.schema,i=n.createPositionAt(e,0);return o.getNearestSelectionRange(i,"forward")}(t,a)}function qg(t){return ar.isGecko?t.dropEffect:["all","copyMove"].includes(t.effectAllowed)?"move":"copy"}function Wg(t,e){let n;function o(...i){o.cancel(),n=setTimeout((()=>t(...i)),e)}return o.cancel=()=>{clearTimeout(n)},o}function jg(t){if(t.is("editableElement"))return null;if(t.hasClass("ck-widget__selection-handle"))return t.findAncestor(hm);if(hm(t))return t;const e=t.findAncestor((t=>hm(t)||t.is("editableElement")));return hm(e)?e:null}class Ug extends pe{static get pluginName(){return"PastePlainText"}static get requires(){return[Og]}init(){const t=this.editor,e=t.model,n=t.editing.view,o=n.document,i=e.document.selection;let r=!1;n.addObserver(zg),this.listenTo(o,"keydown",((t,e)=>{r=e.shiftKey})),t.plugins.get(Og).on("contentInsertion",((t,n)=>{(r||function(t,e){if(t.childCount>1)return!1;const n=t.getChild(0);if(e.isObject(n))return!1;return 0==[...n.getAttributeKeys()].length}(n.content,e.schema))&&e.change((t=>{const o=Array.from(i.getAttributes()).filter((([t])=>e.schema.getAttributeProperties(t).isFormatting));i.isCollapsed||e.deleteContent(i,{doNotAutoparagraph:!0}),o.push(...i.getAttributes());const r=t.createRangeIn(n.content);for(const e of r.getItems())e.is("$textProxy")&&t.setAttributes(o,e)}))}))}}class $g extends pe{static get pluginName(){return"Clipboard"}static get requires(){return[Og,Lg,Ug]}}class Gg extends pe{static get requires(){return[Vh]}static get pluginName(){return"WidgetToolbarRepository"}init(){const t=this.editor;if(t.plugins.has("BalloonToolbar")){const e=t.plugins.get("BalloonToolbar");this.listenTo(e,"show",(e=>{(function(t){const e=t.getSelectedElement();return!(!e||!hm(e))})(t.editing.view.document.selection)&&e.stop()}),{priority:"high"})}this._toolbarDefinitions=new Map,this._balloon=this.editor.plugins.get("ContextualBalloon"),this.on("change:isEnabled",(()=>{this._updateToolbarsVisibility()})),this.listenTo(t.ui,"update",(()=>{this._updateToolbarsVisibility()})),this.listenTo(t.ui.focusTracker,"change:isFocused",(()=>{this._updateToolbarsVisibility()}),{priority:"low"})}destroy(){super.destroy();for(const t of this._toolbarDefinitions.values())t.view.destroy()}register(t,{ariaLabel:e,items:n,getRelatedElement:o,balloonClassName:i="ck-toolbar-container"}){if(!n.length)return void a("widget-toolbar-no-items",{toolbarId:t});const r=this.editor,c=r.t,l=new Wu(r.locale);if(l.ariaLabel=e||c("Widget toolbar"),this._toolbarDefinitions.has(t))throw new s("widget-toolbar-duplicated",this,{toolbarId:t});l.fillFromConfig(n,r.ui.componentFactory),this._toolbarDefinitions.set(t,{view:l,getRelatedElement:o,balloonClassName:i})}_updateToolbarsVisibility(){let t=0,e=null,n=null;for(const o of this._toolbarDefinitions.values()){const i=o.getRelatedElement(this.editor.editing.view.document.selection);if(this.isEnabled&&i)if(this.editor.ui.focusTracker.isFocused){const r=i.getAncestors().length;r>t&&(t=r,e=i,n=o)}else this._isToolbarVisible(o)&&this._hideToolbar(o);else this._isToolbarInBalloon(o)&&this._hideToolbar(o)}n&&this._showToolbar(n,e)}_hideToolbar(t){this._balloon.remove(t.view),this.stopListening(this._balloon,"change:visibleView")}_showToolbar(t,e){this._isToolbarVisible(t)?Kg(this.editor,e):this._isToolbarInBalloon(t)||(this._balloon.add({view:t.view,position:Zg(this.editor,e),balloonClassName:t.balloonClassName}),this.listenTo(this._balloon,"change:visibleView",(()=>{for(const t of this._toolbarDefinitions.values())if(this._isToolbarVisible(t)){const e=t.getRelatedElement(this.editor.editing.view.document.selection);Kg(this.editor,e)}})))}_isToolbarVisible(t){return this._balloon.visibleView===t.view}_isToolbarInBalloon(t){return this._balloon.hasView(t.view)}}function Kg(t,e){const n=t.plugins.get("ContextualBalloon"),o=Zg(t,e);n.updatePosition(o)}function Zg(t,e){const n=t.editing.view,o=Ih.defaultPositions;return{target:n.domConverter.mapViewToDom(e),positions:[o.northArrowSouth,o.northArrowSouthWest,o.northArrowSouthEast,o.southArrowNorth,o.southArrowNorthWest,o.southArrowNorthEast,o.viewportStickyNorth]}}class Jg{constructor(t){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=t,this._referenceCoordinates=null}begin(t,e,n){const o=new ya(e);this.activeHandlePosition=function(t){const e=["top-left","top-right","bottom-right","bottom-left"];for(const n of e)if(t.classList.contains(Yg(n)))return n}(t),this._referenceCoordinates=function(t,e){const n=new ya(t),o=e.split("-"),i={x:"right"==o[1]?n.right:n.left,y:"bottom"==o[0]?n.bottom:n.top};return i.x+=t.ownerDocument.defaultView.scrollX,i.y+=t.ownerDocument.defaultView.scrollY,i}(e,function(t){const e=t.split("-"),n={top:"bottom",bottom:"top",left:"right",right:"left"};return`${n[e[0]]}-${n[e[1]]}`}(this.activeHandlePosition)),this.originalWidth=o.width,this.originalHeight=o.height,this.aspectRatio=o.width/o.height;const i=n.style.width;i&&i.match(/^\d+(\.\d*)?%$/)?this.originalWidthPercents=parseFloat(i):this.originalWidthPercents=function(t,e){const n=t.parentElement,o=parseFloat(n.ownerDocument.defaultView.getComputedStyle(n).width);return e.width/o*100}(n,o)}update(t){this.proposedWidth=t.width,this.proposedHeight=t.height,this.proposedWidthPercents=t.widthPercents,this.proposedHandleHostWidth=t.handleHostWidth,this.proposedHandleHostHeight=t.handleHostHeight}}function Yg(t){return`ck-widget__resizer__handle-${t}`}he(Jg,se);class Qg extends Od{constructor(){super();const t=this.bindTemplate;this.setTemplate({tag:"div",attributes:{class:["ck","ck-size-view",t.to("_viewPosition",(t=>t?`ck-orientation-${t}`:""))],style:{display:t.if("_isVisible","none",(t=>!t))}},children:[{text:t.to("_label")}]})}_bindToState(t,e){this.bind("_isVisible").to(e,"proposedWidth",e,"proposedHeight",((t,e)=>null!==t&&null!==e)),this.bind("_label").to(e,"proposedHandleHostWidth",e,"proposedHandleHostHeight",e,"proposedWidthPercents",((e,n,o)=>"px"===t.unit?`${e}×${n}`:`${o}%`)),this.bind("_viewPosition").to(e,"activeHandlePosition",e,"proposedHandleHostWidth",e,"proposedHandleHostHeight",((t,e,n)=>e<50||n<50?"above-center":t))}_dismiss(){this.unbind(),this._isVisible=!1}}class Xg{constructor(t){this._options=t,this._viewResizerWrapper=null,this.set("isEnabled",!0),this.decorate("begin"),this.decorate("cancel"),this.decorate("commit"),this.decorate("updateSize"),this.on("commit",(t=>{this.state.proposedWidth||this.state.proposedWidthPercents||(this._cleanup(),t.stop())}),{priority:"high"}),this.on("change:isEnabled",(()=>{this.isEnabled&&this.redraw()}))}attach(){const t=this,e=this._options.viewElement;this._options.editor.editing.view.change((n=>{const o=n.createUIElement("div",{class:"ck ck-reset_all ck-widget__resizer"},(function(e){const n=this.toDomElement(e);return t._appendHandles(n),t._appendSizeUI(n),t.on("change:isEnabled",((t,e,o)=>{n.style.display=o?"":"none"})),n.style.display=t.isEnabled?"":"none",n}));n.insert(n.createPositionAt(e,"end"),o),n.addClass("ck-widget_with-resizer",e),this._viewResizerWrapper=o}))}begin(t){this.state=new Jg(this._options),this._sizeView._bindToState(this._options,this.state),this._initialViewWidth=this._options.viewElement.getStyle("width"),this.state.begin(t,this._getHandleHost(),this._getResizeHost())}updateSize(t){const e=this._proposeNewSize(t);this._options.editor.editing.view.change((t=>{const n=this._options.unit||"%",o=("%"===n?e.widthPercents:e.width)+n;t.setStyle("width",o,this._options.viewElement)}));const n=this._getHandleHost(),o=new ya(n);e.handleHostWidth=Math.round(o.width),e.handleHostHeight=Math.round(o.height);const i=new ya(n);e.width=Math.round(i.width),e.height=Math.round(i.height),this.redraw(o),this.state.update(e)}commit(){const t=this._options.unit||"%",e=("%"===t?this.state.proposedWidthPercents:this.state.proposedWidth)+t;this._options.editor.editing.view.change((()=>{this._cleanup(),this._options.onCommit(e)}))}cancel(){this._cleanup()}destroy(){this.cancel()}redraw(t){const e=this._domResizerWrapper;if(!((n=e)&&n.ownerDocument&&n.ownerDocument.contains(n)))return;var n;const o=e.parentElement,i=this._getHandleHost(),r=this._viewResizerWrapper,s=[r.getStyle("width"),r.getStyle("height"),r.getStyle("left"),r.getStyle("top")];let a;if(o.isSameNode(i)){const e=t||new ya(i);a=[e.width+"px",e.height+"px",void 0,void 0]}else a=[i.offsetWidth+"px",i.offsetHeight+"px",i.offsetLeft+"px",i.offsetTop+"px"];"same"!==Oo(s,a)&&this._options.editor.editing.view.change((t=>{t.setStyle({width:a[0],height:a[1],left:a[2],top:a[3]},r)}))}containsHandle(t){return this._domResizerWrapper.contains(t)}static isResizeHandle(t){return t.classList.contains("ck-widget__resizer__handle")}_cleanup(){this._sizeView._dismiss();this._options.editor.editing.view.change((t=>{t.setStyle("width",this._initialViewWidth,this._options.viewElement)}))}_proposeNewSize(t){const e=this.state,n={x:(o=t).pageX,y:o.pageY};var o;const i=!this._options.isCentered||this._options.isCentered(this),r={x:e._referenceCoordinates.x-(n.x+e.originalWidth),y:n.y-e.originalHeight-e._referenceCoordinates.y};i&&e.activeHandlePosition.endsWith("-right")&&(r.x=n.x-(e._referenceCoordinates.x+e.originalWidth)),i&&(r.x*=2);const s={width:Math.abs(e.originalWidth+r.x),height:Math.abs(e.originalHeight+r.y)};s.dominant=s.width/e.aspectRatio>s.height?"width":"height",s.max=s[s.dominant];const a={width:s.width,height:s.height};return"width"==s.dominant?a.height=a.width/e.aspectRatio:a.width=a.height*e.aspectRatio,{width:Math.round(a.width),height:Math.round(a.height),widthPercents:Math.min(Math.round(e.originalWidthPercents/e.originalWidth*a.width*100)/100,100)}}_getResizeHost(){const t=this._domResizerWrapper.parentElement;return this._options.getResizeHost(t)}_getHandleHost(){const t=this._domResizerWrapper.parentElement;return this._options.getHandleHost(t)}get _domResizerWrapper(){return this._options.editor.editing.view.domConverter.mapViewToDom(this._viewResizerWrapper)}_appendHandles(t){const e=["top-left","top-right","bottom-right","bottom-left"];for(const o of e)t.appendChild(new Md({tag:"div",attributes:{class:"ck-widget__resizer__handle "+(n=o,`ck-widget__resizer__handle-${n}`)}}).render());var n}_appendSizeUI(t){this._sizeView=new Qg,this._sizeView.render(),t.appendChild(this._sizeView.element)}}he(Xg,se);var tf=n(2263),ef={attributes:{"data-cke":!0}};ef.setAttributes=is(),ef.insert=ns().bind(null,"head"),ef.domAPI=ts(),ef.insertStyleElement=ss();Qr()(tf.Z,ef);tf.Z&&tf.Z.locals&&tf.Z.locals;class nf extends pe{static get pluginName(){return"WidgetResize"}init(){const t=this.editor.editing,e=ps.window.document;this.set("visibleResizer",null),this.set("_activeResizer",null),this._resizers=new Map,t.view.addObserver(hp),this._observer=Object.create(Es),this.listenTo(t.view.document,"mousedown",this._mouseDownListener.bind(this),{priority:"high"}),this._observer.listenTo(e,"mousemove",this._mouseMoveListener.bind(this)),this._observer.listenTo(e,"mouseup",this._mouseUpListener.bind(this));const n=()=>{this.visibleResizer&&this.visibleResizer.redraw()};this._redrawFocusedResizerThrottled=tm(n,200),this.on("change:visibleResizer",n),this.editor.ui.on("update",this._redrawFocusedResizerThrottled),this.editor.model.document.on("change",(()=>{for(const[t,e]of this._resizers)t.isAttached()||(this._resizers.delete(t),e.destroy())}),{priority:"lowest"}),this._observer.listenTo(ps.window,"resize",this._redrawFocusedResizerThrottled);const o=this.editor.editing.view.document.selection;o.on("change",(()=>{const t=o.getSelectedElement();this.visibleResizer=this.getResizerByViewElement(t)||null}))}destroy(){this._observer.stopListening();for(const t of this._resizers.values())t.destroy();this._redrawFocusedResizerThrottled.cancel()}attachTo(t){const e=new Xg(t),n=this.editor.plugins;if(e.attach(),n.has("WidgetToolbarRepository")){const t=n.get("WidgetToolbarRepository");e.on("begin",(()=>{t.forceDisabled("resize")}),{priority:"lowest"}),e.on("cancel",(()=>{t.clearForceDisabled("resize")}),{priority:"highest"}),e.on("commit",(()=>{t.clearForceDisabled("resize")}),{priority:"highest"})}this._resizers.set(t.viewElement,e);const o=this.editor.editing.view.document.selection.getSelectedElement();return this.getResizerByViewElement(o)==e&&(this.visibleResizer=e),e}getResizerByViewElement(t){return this._resizers.get(t)}_getResizerByHandle(t){for(const e of this._resizers.values())if(e.containsHandle(t))return e}_mouseDownListener(t,e){const n=e.domTarget;Xg.isResizeHandle(n)&&(this._activeResizer=this._getResizerByHandle(n),this._activeResizer&&(this._activeResizer.begin(n),t.stop(),e.preventDefault()))}_mouseMoveListener(t,e){this._activeResizer&&this._activeResizer.updateSize(e)}_mouseUpListener(){this._activeResizer&&(this._activeResizer.commit(),this._activeResizer=null)}}function of(t,e){const n=t.createEmptyElement("img"),o="imageBlock"===e?t.createContainerElement("figure",{class:"image"}):t.createContainerElement("span",{class:"image-inline"},{isAllowedInsideAttributeElement:!0});return t.insert(t.createPositionAt(o,0),n),o}function rf(t,e){if(t.plugins.has("ImageInlineEditing")!==t.plugins.has("ImageBlockEditing"))return{name:"img"};const n=t.plugins.get("ImageUtils");return t=>{if(!n.isInlineImageView(t))return null;return(t.findAncestor(n.isBlockImageView)?"imageBlock":"imageInline")!==e?null:{name:!0}}}function sf(t,e){const n=Ta(e.getSelectedBlocks());return!n||t.isObject(n)||n.isEmpty&&"listItem"!=n.name?"imageBlock":"imageInline"}he(nf,se);class af extends pe{static get pluginName(){return"ImageUtils"}isImage(t){return this.isInlineImage(t)||this.isBlockImage(t)}isInlineImageView(t){return!!t&&t.is("element","img")}isBlockImageView(t){return!!t&&t.is("element","figure")&&t.hasClass("image")}insertImage(t={},e=null,n=null){const o=this.editor,i=o.model,r=i.document.selection;n=cf(o,e||r,n),t={...Object.fromEntries(r.getAttributes()),...t};for(const e in t)i.schema.checkAttribute(n,e)||delete t[e];return i.change((o=>{const s=o.createElement(n,t);return e||"imageInline"==n||(e=wm(r,i)),i.insertContent(s,e),s.parent?(o.setSelection(s,"on"),s):null}))}getClosestSelectedImageWidget(t){const e=t.getSelectedElement();if(e&&this.isImageWidget(e))return e;let n=t.getFirstPosition().parent;for(;n;){if(n.is("element")&&this.isImageWidget(n))return n;n=n.parent}return null}getClosestSelectedImageElement(t){const e=t.getSelectedElement();return this.isImage(e)?e:t.getFirstPosition().findAncestor("imageBlock")}isImageAllowed(){const t=this.editor.model.document.selection;return function(t,e){if("imageBlock"==cf(t,e)){const n=function(t,e){const n=wm(t,e).start.parent;if(n.isEmpty&&!n.is("element","$root"))return n.parent;return n}(e,t.model);if(t.model.schema.checkChild(n,"imageBlock"))return!0}else if(t.model.schema.checkChild(e.focus,"imageInline"))return!0;return!1}(this.editor,t)&&function(t){return[...t.focus.getAncestors()].every((t=>!t.is("element","imageBlock")))}(t)}toImageWidget(t,e,n){e.setCustomProperty("image",!0,t);return pm(t,e,{label:()=>{const e=this.findViewImgElement(t).getAttribute("alt");return e?`${e} ${n}`:n}})}isImageWidget(t){return!!t.getCustomProperty("image")&&hm(t)}isBlockImage(t){return!!t&&t.is("element","imageBlock")}isInlineImage(t){return!!t&&t.is("element","imageInline")}findViewImgElement(t){if(this.isInlineImageView(t))return t;const e=this.editor.editing.view;for(const{item:n}of e.createRangeIn(t))if(this.isInlineImageView(n))return n}}function cf(t,e,n){const o=t.model.schema,i=t.config.get("image.insert.type");return t.plugins.has("ImageBlockEditing")?t.plugins.has("ImageInlineEditing")?n||("inline"===i?"imageInline":"block"===i?"imageBlock":e.is("selection")?sf(o,e):o.checkChild(e,"imageInline")?"imageInline":"imageBlock"):"imageBlock":"imageInline"}class lf extends ge{refresh(){const t=this.editor,e=t.plugins.get("ImageUtils"),n=t.model.document.selection.getSelectedElement();this.isEnabled=e.isImageAllowed()||e.isImage(n)}execute(t){const e=To(t.file),n=this.editor.model.document.selection,o=this.editor.plugins.get("ImageUtils"),i=Object.fromEntries(n.getAttributes());e.forEach(((t,e)=>{const r=n.getSelectedElement();if(e&&r&&o.isImage(r)){const e=this.editor.model.createPositionAfter(r);this._uploadImage(t,i,e)}else this._uploadImage(t,i)}))}_uploadImage(t,e,n){const o=this.editor,i=o.plugins.get(hg).createLoader(t),r=o.plugins.get("ImageUtils");i&&r.insertImage({...e,uploadId:i.id},n)}}class df extends pe{static get requires(){return[hg,xh,Og,af]}static get pluginName(){return"ImageUploadEditing"}constructor(t){super(t),t.config.define("image",{upload:{types:["jpeg","png","gif","bmp","webp","tiff"]}}),this._uploadImageElements=new Map}init(){const t=this.editor,e=t.model.document,n=t.conversion,o=t.plugins.get(hg),i=t.plugins.get("ImageUtils"),r=bg(t.config.get("image.upload.types")),s=new lf(t);t.commands.add("uploadImage",s),t.commands.add("imageUpload",s),n.for("upcast").attributeToAttribute({view:{name:"img",key:"uploadId"},model:"uploadId"}),this.listenTo(t.editing.view.document,"clipboardInput",((e,n)=>{if(o=n.dataTransfer,Array.from(o.types).includes("text/html")&&""!==o.getData("text/html"))return;var o;const i=Array.from(n.dataTransfer.files).filter((t=>!!t&&r.test(t.type)));i.length&&(e.stop(),t.model.change((e=>{n.targetRanges&&e.setSelection(n.targetRanges.map((e=>t.editing.mapper.toModelRange(e)))),t.model.enqueueChange((()=>{t.execute("uploadImage",{file:i})}))})))})),this.listenTo(t.plugins.get("ClipboardPipeline"),"inputTransformation",((e,n)=>{const r=Array.from(t.editing.view.createRangeIn(n.content)).filter((t=>function(t,e){return!(!t.isInlineImageView(e)||!e.getAttribute("src"))&&(e.getAttribute("src").match(/^data:image\/\w+;base64,/g)||e.getAttribute("src").match(/^blob:/g))}(i,t.item)&&!t.item.getAttribute("uploadProcessed"))).map((t=>({promise:kg(t.item),imageElement:t.item})));if(!r.length)return;const s=new pp(t.editing.view.document);for(const t of r){s.setAttribute("uploadProcessed",!0,t.imageElement);const e=o.createLoader(t.promise);e&&(s.setAttribute("src","",t.imageElement),s.setAttribute("uploadId",e.id,t.imageElement))}})),t.editing.view.document.on("dragover",((t,e)=>{e.preventDefault()})),e.on("change",(()=>{const n=e.differ.getChanges({includeChangesInGraveyard:!0}).reverse(),i=new Set;for(const e of n)if("insert"==e.type&&"$text"!=e.name){const n=e.position.nodeAfter,r="$graveyard"==e.position.root.rootName;for(const e of uf(t,n)){const t=e.getAttribute("uploadId");if(!t)continue;const n=o.loaders.get(t);n&&(r?i.has(t)||n.abort():(i.add(t),this._uploadImageElements.set(t,e),"idle"==n.status&&this._readAndUpload(n)))}}})),this.on("uploadComplete",((t,{imageElement:e,data:n})=>{const o=n.urls?n.urls:n;this.editor.model.change((t=>{t.setAttribute("src",o.default,e),this._parseAndSetSrcsetAttributeOnImage(o,e,t)}))}),{priority:"low"})}afterInit(){const t=this.editor.model.schema;this.editor.plugins.has("ImageBlockEditing")&&t.extend("imageBlock",{allowAttributes:["uploadId","uploadStatus"]}),this.editor.plugins.has("ImageInlineEditing")&&t.extend("imageInline",{allowAttributes:["uploadId","uploadStatus"]})}_readAndUpload(t){const e=this.editor,n=e.model,o=e.locale.t,i=e.plugins.get(hg),r=e.plugins.get(xh),s=e.plugins.get("ImageUtils"),a=this._uploadImageElements;return n.enqueueChange({isUndoable:!1},(e=>{e.setAttribute("uploadStatus","reading",a.get(t.id))})),t.read().then((()=>{const o=t.upload(),i=a.get(t.id);if(ar.isSafari){const t=e.editing.mapper.toViewElement(i),n=s.findViewImgElement(t);e.editing.view.once("render",(()=>{if(!n.parent)return;const t=e.editing.view.domConverter.mapViewToDom(n.parent);if(!t)return;const o=t.style.display;t.style.display="none",t._ckHack=t.offsetHeight,t.style.display=o}))}return n.enqueueChange({isUndoable:!1},(t=>{t.setAttribute("uploadStatus","uploading",i)})),o})).then((e=>{n.enqueueChange({isUndoable:!1},(n=>{const o=a.get(t.id);n.setAttribute("uploadStatus","complete",o),this.fire("uploadComplete",{data:e,imageElement:o})})),c()})).catch((e=>{if("error"!==t.status&&"aborted"!==t.status)throw e;"error"==t.status&&e&&r.showWarning(e,{title:o("Upload failed"),namespace:"upload"}),n.enqueueChange({isUndoable:!1},(e=>{e.remove(a.get(t.id))})),c()}));function c(){n.enqueueChange({isUndoable:!1},(e=>{const n=a.get(t.id);e.removeAttribute("uploadId",n),e.removeAttribute("uploadStatus",n),a.delete(t.id)})),i.destroyLoader(t)}}_parseAndSetSrcsetAttributeOnImage(t,e,n){let o=0;const i=Object.keys(t).filter((t=>{const e=parseInt(t,10);if(!isNaN(e))return o=Math.max(o,e),!0})).map((e=>`${t[e]} ${e}w`)).join(", ");""!=i&&n.setAttribute("srcset",{data:i,width:o},e)}}function uf(t,e){const n=t.plugins.get("ImageUtils");return Array.from(t.model.createRangeOn(e)).filter((t=>n.isImage(t.item))).map((t=>t.item))}class hf extends pe{static get pluginName(){return"ImageUpload"}static get requires(){return[df,_g,Dg]}}const pf=Symbol("isWpButtonMacroSymbol");function mf(t){const e=t.getSelectedElement();return!(!e||!function(t){return!!t.getCustomProperty(pf)&&hm(t)}(e))}class gf extends pe{static get pluginName(){return"OPChildPagesEditing"}static get buttonName(){return"insertChildPages"}init(){const t=this.editor,e=t.model,n=t.conversion;e.schema.register("op-macro-child-pages",{allowWhere:["$block"],allowAttributes:["page"],isBlock:!0,isLimit:!0}),n.for("upcast").elementToElement({view:{name:"macro",classes:"child_pages"},model:(t,{writer:e})=>{const n=t.getAttribute("data-page")||"",o="true"==t.getAttribute("data-include-parent");return e.createElement("op-macro-child-pages",{page:n,includeParent:o})}}),n.for("editingDowncast").elementToElement({model:"op-macro-child-pages",view:(t,{writer:e})=>this.createMacroViewElement(t,e)}).add((t=>t.on("attribute:page",this.modelAttributeToView.bind(this)))).add((t=>t.on("attribute:includeParent",this.modelAttributeToView.bind(this)))),n.for("dataDowncast").elementToElement({model:"op-macro-child-pages",view:(t,{writer:e})=>e.createContainerElement("macro",{class:"child_pages","data-page":t.getAttribute("page")||"","data-include-parent":t.getAttribute("includeParent")||""})}),t.ui.componentFactory.add(gf.buttonName,(e=>{const n=new pu(e);return n.set({label:window.I18n.t("js.editor.macro.child_pages.button"),withText:!0}),n.on("execute",(()=>{t.model.change((e=>{const n=e.createElement("op-macro-child-pages",{});t.model.insertContent(n,t.model.document.selection)}))})),n}))}modelAttributeToView(t,e,n){const o=e.item;if(!o.is("element","op-macro-child-pages"))return;n.consumable.consume(e.item,t.name);const i=n.mapper.toViewElement(o);n.writer.remove(n.writer.createRangeIn(i)),this.setPlaceholderContent(n.writer,o,i)}macroLabel(){return window.I18n.t("js.editor.macro.child_pages.text")}pageLabel(t){return t&&t.length>0?t:window.I18n.t("js.editor.macro.child_pages.this_page")}includeParentText(t){return t?` (${window.I18n.t("js.editor.macro.child_pages.include_parent")})`:""}createMacroViewElement(t,e){const n=e.createContainerElement("div");return this.setPlaceholderContent(e,t,n),function(t,e,n){return e.setCustomProperty(pf,!0,t),pm(t,e,{label:n})}(n,e,{label:this.macroLabel()})}setPlaceholderContent(t,e,n){const o=e.getAttribute("page"),i=e.getAttribute("includeParent"),r=this.macroLabel(),s=this.pageLabel(o),a=t.createContainerElement("span",{class:"macro-value"});let c=[t.createText(`${r} `)];t.insert(t.createPositionAt(a,0),t.createText(`${s}`)),c.push(a),c.push(t.createText(this.includeParentText(i))),t.insert(t.createPositionAt(n,0),c)}}class ff extends pe{static get requires(){return[Vh]}static get pluginName(){return"OPChildPagesToolbar"}init(){const t=this.editor,e=this.editor.model,n=xm(t);ng(t,"opEditChildPagesMacroButton",(t=>{const o=n.services.macros,i=t.getAttribute("page"),r=t.getAttribute("includeParent"),s=i&&i.length>0?i:"";o.configureChildPages(s,r).then((n=>e.change((e=>{e.setAttribute("page",n.page,t),e.setAttribute("includeParent",n.includeParent,t)}))))}))}afterInit(){ig(this,this.editor,"OPChildPages",mf)}}class bf extends ge{execute(){const t=this.editor.model,e=t.document;t.change((n=>{!function(t,e,n){const o=n.isCollapsed,i=n.getFirstRange(),r=i.start.parent,s=i.end.parent,a=r==s;if(o){const o=Bm(t.schema,n.getAttributes());kf(t,e,i.end),e.removeSelectionAttribute(n.getAttributeKeys()),e.setSelectionAttribute(o)}else{const o=!(i.start.isAtStart&&i.end.isAtEnd);t.deleteContent(n,{leaveUnmerged:o}),a?kf(t,e,n.focus):o&&e.setSelection(s,0)}}(t,n,e.selection),this.fire("afterExecute",{writer:n})}))}refresh(){const t=this.editor.model,e=t.document;this.isEnabled=function(t,e){if(e.rangeCount>1)return!1;const n=e.anchor;if(!n||!t.checkChild(n,"softBreak"))return!1;const o=e.getFirstRange(),i=o.start.parent,r=o.end.parent;if((wf(i,t)||wf(r,t))&&i!==r)return!1;return!0}(t.schema,e.selection)}}function kf(t,e,n){const o=e.createElement("softBreak");t.insertContent(o,n),e.setSelection(o,"after")}function wf(t,e){return!t.is("rootElement")&&(e.isLimit(t)||wf(t.parent,e))}class _f extends pe{static get pluginName(){return"ShiftEnter"}init(){const t=this.editor,e=t.model.schema,n=t.conversion,o=t.editing.view,i=o.document;e.register("softBreak",{allowWhere:"$text",isInline:!0}),n.for("upcast").elementToElement({model:"softBreak",view:"br"}),n.for("downcast").elementToElement({model:"softBreak",view:(t,{writer:e})=>e.createEmptyElement("br")}),o.addObserver(Im),t.commands.add("shiftEnter",new bf(t)),this.listenTo(i,"enter",((e,n)=>{n.preventDefault(),n.isSoft&&(t.execute("shiftEnter"),o.scrollToTheSelection())}),{priority:"low"})}}class Cf extends ge{constructor(t){super(t),this.affectsData=!1}execute(){const t=this.editor.model,e=t.document.selection;let n=t.schema.getLimitElement(e);if(e.containsEntireContent(n)||!Af(t.schema,n))do{if(n=n.parent,!n)return}while(!Af(t.schema,n));t.change((t=>{t.setSelection(n,"in")}))}}function Af(t,e){return t.isLimit(e)&&(t.checkChild(e,"$text")||t.checkChild(e,"paragraph"))}const vf=mr("Ctrl+A");class yf extends pe{static get pluginName(){return"SelectAllEditing"}init(){const t=this.editor,e=t.editing.view.document;t.commands.add("selectAll",new Cf(t)),this.listenTo(e,"keydown",((e,n)=>{pr(n)===vf&&(t.execute("selectAll"),n.preventDefault())}))}}class xf extends pe{static get pluginName(){return"SelectAllUI"}init(){const t=this.editor;t.ui.componentFactory.add("selectAll",(e=>{const n=t.commands.get("selectAll"),o=new pu(e),i=e.t;return o.set({label:i("Select all"),icon:'',keystroke:"Ctrl+A",tooltip:!0}),o.bind("isOn","isEnabled").to(n,"value","isEnabled"),this.listenTo(o,"execute",(()=>{t.execute("selectAll"),t.editing.view.focus()})),o}))}}class Ef extends pe{static get requires(){return[yf,xf]}static get pluginName(){return"SelectAll"}}class Df extends ge{constructor(t,e){super(t),this._buffer=new zm(t.model,e)}get buffer(){return this._buffer}destroy(){super.destroy(),this._buffer.destroy()}execute(t={}){const e=this.editor.model,n=e.document,o=t.text||"",i=o.length,r=t.range?e.createSelection(t.range):n.selection,s=t.resultRange;e.enqueueChange(this._buffer.batch,(t=>{this._buffer.lock(),e.deleteContent(r),o&&e.insertContent(t.createText(o,n.selection.getAttributes()),r),s?t.setSelection(s):r.is("documentSelection")||t.setSelection(r),this._buffer.unlock(),this._buffer.input(i)}))}}class Sf{constructor(t){this.editor=t,this.editing=this.editor.editing}handle(t,e){if(function(t){if(0==t.length)return!1;for(const e of t)if("children"===e.type&&!Nm(e))return!0;return!1}(t))this._handleContainerChildrenMutations(t,e);else for(const n of t)this._handleTextMutation(n,e),this._handleTextNodeInsertion(n)}_handleContainerChildrenMutations(t,e){const n=function(t){const e=t.map((t=>t.node)).reduce(((t,e)=>t.getCommonAncestor(e,{includeSelf:!0})));if(!e)return;return e.getAncestors({includeSelf:!0,parentFirst:!0}).find((t=>t.is("containerElement")||t.is("rootElement")))}(t);if(!n)return;const o=this.editor.editing.view.domConverter.mapViewToDom(n),i=new Cs(this.editor.editing.view.document),r=this.editor.data.toModel(i.domToView(o)).getChild(0),s=this.editor.editing.mapper.toModelElement(n);if(!s)return;const a=Array.from(r.getChildren()),c=Array.from(s.getChildren()),l=a[a.length-1],d=c[c.length-1],u=l&&l.is("element","softBreak"),h=d&&!d.is("element","softBreak");u&&h&&a.pop();const p=this.editor.model.schema;if(!Bf(a,p)||!Bf(c,p))return;const m=a.map((t=>t.is("$text")?t.data:"@")).join("").replace(/\u00A0/g," "),g=c.map((t=>t.is("$text")?t.data:"@")).join("").replace(/\u00A0/g," ");if(g===m)return;const f=$r(g,m),{firstChangeAt:b,insertions:k,deletions:w}=Tf(f);let _=null;e&&(_=this.editing.mapper.toModelRange(e.getFirstRange()));const C=m.substr(b,k),A=this.editor.model.createRange(this.editor.model.createPositionAt(s,b),this.editor.model.createPositionAt(s,b+w));this.editor.execute("input",{text:C,range:A,resultRange:_})}_handleTextMutation(t,e){if("text"!=t.type)return;const n=t.newText.replace(/\u00A0/g," "),o=t.oldText.replace(/\u00A0/g," ");if(o===n)return;const i=$r(o,n),{firstChangeAt:r,insertions:s,deletions:a}=Tf(i);let c=null;e&&(c=this.editing.mapper.toModelRange(e.getFirstRange()));const l=this.editing.view.createPositionAt(t.node,r),d=this.editing.mapper.toModelPosition(l),u=this.editor.model.createRange(d,d.getShiftedBy(a)),h=n.substr(r,s);this.editor.execute("input",{text:h,range:u,resultRange:c})}_handleTextNodeInsertion(t){if("children"!=t.type)return;const e=Nm(t),n=this.editing.view.createPositionAt(t.node,e.index),o=this.editing.mapper.toModelPosition(n),i=e.values[0].data;this.editor.execute("input",{text:i.replace(/\u00A0/g," "),range:this.editor.model.createRange(o)})}}function Bf(t,e){return t.every((t=>e.isInline(t)))}function Tf(t){let e=null,n=null;for(let o=0;o{n.deleteContent(n.document.selection)})),t.unlock()}ar.isAndroid?o.document.on("beforeinput",((t,e)=>r(e)),{priority:"lowest"}):o.document.on("keydown",((t,e)=>r(e)),{priority:"lowest"}),o.document.on("compositionstart",(function(){const t=n.document,e=1!==t.selection.rangeCount||t.selection.getFirstRange().isFlat;t.selection.isCollapsed||e||s()}),{priority:"lowest"}),o.document.on("compositionend",(()=>{e=n.createSelection(n.document.selection)}),{priority:"lowest"})}(t),function(t){t.editing.view.document.on("mutations",((e,n,o)=>{new Sf(t).handle(n,o)}))}(t)}}class If extends pe{static get requires(){return[Pf,Lm]}static get pluginName(){return"Typing"}}function Rf(t,e){let n=t.start;return{text:Array.from(t.getItems()).reduce(((t,o)=>o.is("$text")||o.is("$textProxy")?t+o.data:(n=e.createPositionAfter(o),"")),""),range:e.createRange(n,t.end)}}class zf{constructor(t,e){this.model=t,this.testCallback=e,this.hasMatch=!1,this.set("isEnabled",!0),this.on("change:isEnabled",(()=>{this.isEnabled?this._startListening():(this.stopListening(t.document.selection),this.stopListening(t.document))})),this._startListening()}_startListening(){const t=this.model.document;this.listenTo(t.selection,"change:range",((e,{directChange:n})=>{n&&(t.selection.isCollapsed?this._evaluateTextBeforeSelection("selection"):this.hasMatch&&(this.fire("unmatched"),this.hasMatch=!1))})),this.listenTo(t,"change:data",((t,e)=>{!e.isUndo&&e.isLocal&&this._evaluateTextBeforeSelection("data",{batch:e})}))}_evaluateTextBeforeSelection(t,e={}){const n=this.model,o=n.document.selection,i=n.createRange(n.createPositionAt(o.focus.parent,0),o.focus),{text:r,range:s}=Rf(i,n),a=this.testCallback(r);if(!a&&this.hasMatch&&this.fire("unmatched"),this.hasMatch=!!a,a){const n=Object.assign(e,{text:r,range:s});"object"==typeof a&&Object.assign(n,a),this.fire(`matched:${t}`,n)}}}he(zf,se);class Ff extends pe{static get pluginName(){return"TwoStepCaretMovement"}constructor(t){super(t),this.attributes=new Set,this._overrideUid=null}init(){const t=this.editor,e=t.model,n=t.editing.view,o=t.locale,i=e.document.selection;this.listenTo(n.document,"arrowKey",((t,e)=>{if(!i.isCollapsed)return;if(e.shiftKey||e.altKey||e.ctrlKey)return;const n=e.keyCode==ur.arrowright,r=e.keyCode==ur.arrowleft;if(!n&&!r)return;const s=o.contentLanguageDirection;let a=!1;a="ltr"===s&&n||"rtl"===s&&r?this._handleForwardMovement(e):this._handleBackwardMovement(e),!0===a&&t.stop()}),{context:"$text",priority:"highest"}),this._isNextGravityRestorationSkipped=!1,this.listenTo(i,"change:range",((t,e)=>{this._isNextGravityRestorationSkipped?this._isNextGravityRestorationSkipped=!1:this._isGravityOverridden&&(!e.directChange&&Vf(i.getFirstPosition(),this.attributes)||this._restoreGravity())}))}registerAttribute(t){this.attributes.add(t)}_handleForwardMovement(t){const e=this.attributes,n=this.editor.model.document.selection,o=n.getFirstPosition();return!this._isGravityOverridden&&((!o.isAtStart||!Nf(n,e))&&(Vf(o,e)?(Mf(t),this._overrideGravity(),!0):void 0))}_handleBackwardMovement(t){const e=this.attributes,n=this.editor.model,o=n.document.selection,i=o.getFirstPosition();return this._isGravityOverridden?(Mf(t),this._restoreGravity(),Of(n,e,i),!0):i.isAtStart?!!Nf(o,e)&&(Mf(t),Of(n,e,i),!0):function(t,e){return Vf(t.getShiftedBy(-1),e)}(i,e)?i.isAtEnd&&!Nf(o,e)&&Vf(i,e)?(Mf(t),Of(n,e,i),!0):(this._isNextGravityRestorationSkipped=!0,this._overrideGravity(),!1):void 0}get _isGravityOverridden(){return!!this._overrideUid}_overrideGravity(){this._overrideUid=this.editor.model.change((t=>t.overrideSelectionGravity()))}_restoreGravity(){this.editor.model.change((t=>{t.restoreSelectionGravity(this._overrideUid),this._overrideUid=null}))}}function Nf(t,e){for(const n of e)if(t.hasAttribute(n))return!0;return!1}function Of(t,e,n){const o=n.nodeBefore;t.change((t=>{o?t.setSelectionAttribute(o.getAttributes()):t.removeSelectionAttribute(e)}))}function Mf(t){t.preventDefault()}function Vf(t,e){const{nodeBefore:n,nodeAfter:o}=t;for(const t of e){const e=n?n.getAttribute(t):void 0;if((o?o.getAttribute(t):void 0)!==e)return!0}return!1}Lf('"'),Lf("'"),Lf("'"),Lf('"'),Lf('"'),Lf("'");function Lf(t){return new RegExp(`(^|\\s)(${t})([^${t}]*)(${t})$`)}function Hf(t,e,n,o){return o.createRange(qf(t,e,n,!0,o),qf(t,e,n,!1,o))}function qf(t,e,n,o,i){let r=t.textNode||(o?t.nodeBefore:t.nodeAfter),s=null;for(;r&&r.getAttribute(e)==n;)s=r,r=o?r.previousSibling:r.nextSibling;return s?i.createPositionAt(s,o?"before":"after"):t}function Wf(t,e,n,o){const i=t.editing.view,r=new Set;i.document.registerPostFixer((i=>{const s=t.model.document.selection;let a=!1;if(s.hasAttribute(e)){const c=Hf(s.getFirstPosition(),e,s.getAttribute(e),t.model),l=t.editing.mapper.toViewRange(c);for(const t of l.getItems())t.is("element",n)&&!t.hasClass(o)&&(i.addClass(o,t),r.add(t),a=!0)}return a})),t.conversion.for("editingDowncast").add((t=>{function e(){i.change((t=>{for(const e of r.values())t.removeClass(o,e),r.delete(e)}))}t.on("insert",e,{priority:"highest"}),t.on("remove",e,{priority:"highest"}),t.on("attribute",e,{priority:"highest"}),t.on("selection",e,{priority:"highest"})}))}class jf extends ge{constructor(t){super(t),this._stack=[],this._createdBatches=new WeakSet,this.refresh(),this.listenTo(t.data,"set",((t,e)=>{e[1]={...e[1]};const n=e[1];n.batchType||(n.batchType={isUndoable:!1})}),{priority:"high"}),this.listenTo(t.data,"set",((t,e)=>{e[1].batchType.isUndoable||this.clearStack()}))}refresh(){this.isEnabled=this._stack.length>0}addBatch(t){const e=this.editor.model.document.selection,n={ranges:e.hasOwnRange?Array.from(e.getRanges()):[],isBackward:e.isBackward};this._stack.push({batch:t,selection:n}),this.refresh()}clearStack(){this._stack=[],this.refresh()}_restoreSelection(t,e,n){const o=this.editor.model,i=o.document,r=[],s=t.map((t=>t.getTransformedByOperations(n))),a=s.flat();for(const t of s){const e=t.filter((t=>t.root!=i.graveyard)).filter((t=>!$f(t,a)));e.length&&(Uf(e),r.push(e[0]))}r.length&&o.change((t=>{t.setSelection(r,{backward:e})}))}_undo(t,e){const n=this.editor.model,o=n.document;this._createdBatches.add(e);const i=t.operations.slice().filter((t=>t.isDocumentOperation));i.reverse();for(const t of i){const i=t.baseVersion+1,r=Array.from(o.history.getOperations(i)),s=ip([t.getReversed()],r,{useRelations:!0,document:this.editor.model.document,padWithNoOps:!1,forceWeakRemove:!0}).operationsA;for(const i of s)e.addOperation(i),n.applyOperation(i),o.history.setOperationAsUndone(t,i)}}}function Uf(t){t.sort(((t,e)=>t.start.isBefore(e.start)?-1:1));for(let e=1;ee!==t&&e.containsRange(t,!0)))}class Gf extends jf{execute(t=null){const e=t?this._stack.findIndex((e=>e.batch==t)):this._stack.length-1,n=this._stack.splice(e,1)[0],o=this.editor.model.createBatch({isUndo:!0});this.editor.model.enqueueChange(o,(()=>{this._undo(n.batch,o);const t=this.editor.model.document.history.getOperations(n.batch.baseVersion);this._restoreSelection(n.selection.ranges,n.selection.isBackward,t),this.fire("revert",n.batch,o)})),this.refresh()}}class Kf extends jf{execute(){const t=this._stack.pop(),e=this.editor.model.createBatch({isUndo:!0});this.editor.model.enqueueChange(e,(()=>{const n=t.batch.operations[t.batch.operations.length-1].baseVersion+1,o=this.editor.model.document.history.getOperations(n);this._restoreSelection(t.selection.ranges,t.selection.isBackward,o),this._undo(t.batch,e)})),this.refresh()}}class Zf extends pe{static get pluginName(){return"UndoEditing"}constructor(t){super(t),this._batchRegistry=new WeakSet}init(){const t=this.editor;this._undoCommand=new Gf(t),this._redoCommand=new Kf(t),t.commands.add("undo",this._undoCommand),t.commands.add("redo",this._redoCommand),this.listenTo(t.model,"applyOperation",((t,e)=>{const n=e[0];if(!n.isDocumentOperation)return;const o=n.batch,i=this._redoCommand._createdBatches.has(o),r=this._undoCommand._createdBatches.has(o);this._batchRegistry.has(o)||(this._batchRegistry.add(o),o.isUndoable&&(i?this._undoCommand.addBatch(o):r||(this._undoCommand.addBatch(o),this._redoCommand.clearStack())))}),{priority:"highest"}),this.listenTo(this._undoCommand,"revert",((t,e,n)=>{this._redoCommand.addBatch(n)})),t.keystrokes.set("CTRL+Z","undo"),t.keystrokes.set("CTRL+Y","redo"),t.keystrokes.set("CTRL+SHIFT+Z","redo")}}const Jf='',Yf='';class Qf extends pe{static get pluginName(){return"UndoUI"}init(){const t=this.editor,e=t.locale,n=t.t,o="ltr"==e.uiLanguageDirection?Jf:Yf,i="ltr"==e.uiLanguageDirection?Yf:Jf;this._addButton("undo",n("Undo"),"CTRL+Z",o),this._addButton("redo",n("Redo"),"CTRL+Y",i)}_addButton(t,e,n,o){const i=this.editor;i.ui.componentFactory.add(t,(r=>{const s=i.commands.get(t),a=new pu(r);return a.set({label:e,icon:o,keystroke:n,tooltip:!0}),a.bind("isEnabled").to(s,"isEnabled"),this.listenTo(a,"execute",(()=>{i.execute(t),i.editing.view.focus()})),a}))}}class Xf extends pe{static get requires(){return[Zf,Qf]}static get pluginName(){return"Undo"}}const tb="ckCsrfToken",eb="abcdefghijklmnopqrstuvwxyz0123456789";function nb(){let t=function(t){t=t.toLowerCase();const e=document.cookie.split(";");for(const n of e){const e=n.split("=");if(decodeURIComponent(e[0].trim().toLowerCase())===t)return decodeURIComponent(e[1])}return null}(tb);var e,n;return t&&40==t.length||(t=function(t){let e="";const n=new Uint8Array(t);window.crypto.getRandomValues(n);for(let t=0;t.5?o.toUpperCase():o}return e}(40),e=tb,n=t,document.cookie=encodeURIComponent(e)+"="+encodeURIComponent(n)+";path=/"),t}class ob{constructor(t,e,n){this.loader=t,this.url=e,this.t=n}upload(){return this.loader.file.then((t=>new Promise(((e,n)=>{this._initRequest(),this._initListeners(e,n,t),this._sendRequest(t)}))))}abort(){this.xhr&&this.xhr.abort()}_initRequest(){const t=this.xhr=new XMLHttpRequest;t.open("POST",this.url,!0),t.responseType="json"}_initListeners(t,e,n){const o=this.xhr,i=this.loader,r=(0,this.t)("Cannot upload file:")+` ${n.name}.`;o.addEventListener("error",(()=>e(r))),o.addEventListener("abort",(()=>e())),o.addEventListener("load",(()=>{const n=o.response;if(!n||!n.uploaded)return e(n&&n.error&&n.error.message?n.error.message:r);t({default:n.url})})),o.upload&&o.upload.addEventListener("progress",(t=>{t.lengthComputable&&(i.uploadTotal=t.total,i.uploaded=t.loaded)}))}_sendRequest(t){const e=new FormData;e.append("upload",t),e.append("ckCsrfToken",nb()),this.xhr.send(e)}}function ib(t,e,n,o){let i,r=null;"function"==typeof o?i=o:(r=t.commands.get(o),i=()=>{t.execute(o)}),t.model.document.on("change:data",((s,a)=>{if(r&&!r.isEnabled||!e.isEnabled)return;const c=Ta(t.model.document.selection.getRanges());if(!c.isCollapsed)return;if(a.isUndo||!a.isLocal)return;const l=Array.from(t.model.document.differ.getChanges()),d=l[0];if(1!=l.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 o&&!["numberedList","bulletedList","todoList"].includes(o))return;if(r&&!0===r.value)return;const h=u.getChild(0),p=t.model.createRangeOn(h);if(!p.containsRange(c)&&!c.end.isEqual(p.end))return;const m=n.exec(h.data.substr(0,c.end.offset));m&&t.model.enqueueChange((e=>{const n=e.createPositionAt(u,0),o=e.createPositionAt(u,m[0].length),r=new gc(n,o);if(!1!==i({match:m})){e.remove(r);const n=t.model.document.selection.getFirstRange(),o=e.createRangeIn(u);!u.isEmpty||o.isEqual(n)||o.containsRange(n,!0)||e.remove(u)}r.detach(),t.model.enqueueChange((()=>{t.plugins.get("Delete").requestUndoOnBackspace()}))}))}))}function rb(t,e,n,o){let i,r;n instanceof RegExp?i=n:r=n,r=r||(t=>{let e;const n=[],o=[];for(;null!==(e=i.exec(t))&&!(e&&e.length<4);){let{index:t,1:i,2:r,3:s}=e;const a=i+r+s;t+=e[0].length-a.length;const c=[t,t+i.length],l=[t+i.length+r.length,t+i.length+r.length+s.length];n.push(c),n.push(l),o.push([t+i.length,t+i.length+r.length])}return{remove:n,format:o}}),t.model.document.on("change:data",((n,i)=>{if(i.isUndo||!i.isLocal||!e.isEnabled)return;const s=t.model,a=s.document.selection;if(!a.isCollapsed)return;const c=Array.from(s.document.differ.getChanges()),l=c[0];if(1!=c.length||"insert"!==l.type||"$text"!=l.name||1!=l.length)return;const d=a.focus,u=d.parent,{text:h,range:p}=function(t,e){let n=t.start;return{text:Array.from(t.getItems()).reduce(((t,o)=>!o.is("$text")&&!o.is("$textProxy")||o.getAttribute("code")?(n=e.createPositionAfter(o),""):t+o.data),""),range:e.createRange(n,t.end)}}(s.createRange(s.createPositionAt(u,0),d),s),m=r(h),g=sb(p.start,m.format,s),f=sb(p.start,m.remove,s);g.length&&f.length&&s.enqueueChange((e=>{if(!1!==o(e,g)){for(const t of f.reverse())e.remove(t);s.enqueueChange((()=>{t.plugins.get("Delete").requestUndoOnBackspace()}))}}))}))}function sb(t,e,n){return e.filter((t=>void 0!==t[0]&&void 0!==t[1])).map((e=>n.createRange(t.getShiftedBy(e[0]),t.getShiftedBy(e[1]))))}function ab(t,e){return(n,o)=>{if(!t.commands.get(e).isEnabled)return!1;const i=t.model.schema.getValidRanges(o,e);for(const t of i)n.setAttribute(e,!0,t);n.removeSelectionAttribute(e)}}class cb extends ge{constructor(t,e){super(t),this.attributeKey=e}refresh(){const t=this.editor.model,e=t.document;this.value=this._getValueFromFirstAllowedNode(),this.isEnabled=t.schema.checkAttributeInSelection(e.selection,this.attributeKey)}execute(t={}){const e=this.editor.model,n=e.document.selection,o=void 0===t.forceValue?!this.value:t.forceValue;e.change((t=>{if(n.isCollapsed)o?t.setSelectionAttribute(this.attributeKey,!0):t.removeSelectionAttribute(this.attributeKey);else{const i=e.schema.getValidRanges(n.getRanges(),this.attributeKey);for(const e of i)o?t.setAttribute(this.attributeKey,o,e):t.removeAttribute(this.attributeKey,e)}}))}_getValueFromFirstAllowedNode(){const t=this.editor.model,e=t.schema,n=t.document.selection;if(n.isCollapsed)return n.hasAttribute(this.attributeKey);for(const t of n.getRanges())for(const n of t.getItems())if(e.checkAttribute(n,this.attributeKey))return n.hasAttribute(this.attributeKey);return!1}}const lb="bold";class db extends pe{static get pluginName(){return"BoldEditing"}init(){const t=this.editor;t.model.schema.extend("$text",{allowAttributes:lb}),t.model.schema.setAttributeProperties(lb,{isFormatting:!0,copyOnEnter:!0}),t.conversion.attributeToElement({model:lb,view:"strong",upcastAlso:["b",t=>{const e=t.getStyle("font-weight");return e?"bold"==e||Number(e)>=600?{name:!0,styles:["font-weight"]}:void 0:null}]}),t.commands.add(lb,new cb(t,lb)),t.keystrokes.set("CTRL+B",lb)}}const ub="bold";class hb extends pe{static get pluginName(){return"BoldUI"}init(){const t=this.editor,e=t.t;t.ui.componentFactory.add(ub,(n=>{const o=t.commands.get(ub),i=new pu(n);return i.set({label:e("Bold"),icon:'',keystroke:"CTRL+B",tooltip:!0,isToggleable:!0}),i.bind("isOn","isEnabled").to(o,"value","isEnabled"),this.listenTo(i,"execute",(()=>{t.execute(ub),t.editing.view.focus()})),i}))}}const pb="code";class mb extends pe{static get pluginName(){return"CodeEditing"}static get requires(){return[Ff]}init(){const t=this.editor;t.model.schema.extend("$text",{allowAttributes:pb}),t.model.schema.setAttributeProperties(pb,{isFormatting:!0,copyOnEnter:!1}),t.conversion.attributeToElement({model:pb,view:"code",upcastAlso:{styles:{"word-wrap":"break-word"}}}),t.commands.add(pb,new cb(t,pb)),t.plugins.get(Ff).registerAttribute(pb),Wf(t,pb,"code","ck-code_selected")}}var gb=n(8180),fb={attributes:{"data-cke":!0}};fb.setAttributes=is(),fb.insert=ns().bind(null,"head"),fb.domAPI=ts(),fb.insertStyleElement=ss();Qr()(gb.Z,fb);gb.Z&&gb.Z.locals&&gb.Z.locals;const bb="code";class kb extends pe{static get pluginName(){return"CodeUI"}init(){const t=this.editor,e=t.t;t.ui.componentFactory.add(bb,(n=>{const o=t.commands.get(bb),i=new pu(n);return i.set({label:e("Code"),icon:'',tooltip:!0,isToggleable:!0}),i.bind("isOn","isEnabled").to(o,"value","isEnabled"),this.listenTo(i,"execute",(()=>{t.execute(bb),t.editing.view.focus()})),i}))}}const wb="strikethrough";class _b extends pe{static get pluginName(){return"StrikethroughEditing"}init(){const t=this.editor;t.model.schema.extend("$text",{allowAttributes:wb}),t.model.schema.setAttributeProperties(wb,{isFormatting:!0,copyOnEnter:!0}),t.conversion.attributeToElement({model:wb,view:"s",upcastAlso:["del","strike",{styles:{"text-decoration":"line-through"}}]}),t.commands.add(wb,new cb(t,wb)),t.keystrokes.set("CTRL+SHIFT+X","strikethrough")}}const Cb="strikethrough";class Ab extends pe{static get pluginName(){return"StrikethroughUI"}init(){const t=this.editor,e=t.t;t.ui.componentFactory.add(Cb,(n=>{const o=t.commands.get(Cb),i=new pu(n);return i.set({label:e("Strikethrough"),icon:'',keystroke:"CTRL+SHIFT+X",tooltip:!0,isToggleable:!0}),i.bind("isOn","isEnabled").to(o,"value","isEnabled"),this.listenTo(i,"execute",(()=>{t.execute(Cb),t.editing.view.focus()})),i}))}}const vb="italic";class yb extends pe{static get pluginName(){return"ItalicEditing"}init(){const t=this.editor;t.model.schema.extend("$text",{allowAttributes:vb}),t.model.schema.setAttributeProperties(vb,{isFormatting:!0,copyOnEnter:!0}),t.conversion.attributeToElement({model:vb,view:"i",upcastAlso:["em",{styles:{"font-style":"italic"}}]}),t.commands.add(vb,new cb(t,vb)),t.keystrokes.set("CTRL+I",vb)}}const xb="italic";class Eb extends pe{static get pluginName(){return"ItalicUI"}init(){const t=this.editor,e=t.t;t.ui.componentFactory.add(xb,(n=>{const o=t.commands.get(xb),i=new pu(n);return i.set({label:e("Italic"),icon:'',keystroke:"CTRL+I",tooltip:!0,isToggleable:!0}),i.bind("isOn","isEnabled").to(o,"value","isEnabled"),this.listenTo(i,"execute",(()=>{t.execute(xb),t.editing.view.focus()})),i}))}}class Db extends ge{refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(t={}){const e=this.editor.model,n=e.schema,o=e.document.selection,i=Array.from(o.getSelectedBlocks()),r=void 0===t.forceValue?!this.value:t.forceValue;e.change((t=>{if(r){const e=i.filter((t=>Sb(t)||Tb(n,t)));this._applyQuote(t,e)}else this._removeQuote(t,i.filter(Sb))}))}_getValue(){const t=Ta(this.editor.model.document.selection.getSelectedBlocks());return!(!t||!Sb(t))}_checkEnabled(){if(this.value)return!0;const t=this.editor.model.document.selection,e=this.editor.model.schema,n=Ta(t.getSelectedBlocks());return!!n&&Tb(e,n)}_removeQuote(t,e){Bb(t,e).reverse().forEach((e=>{if(e.start.isAtStart&&e.end.isAtEnd)return void t.unwrap(e.start.parent);if(e.start.isAtStart){const n=t.createPositionBefore(e.start.parent);return void t.move(e,n)}e.end.isAtEnd||t.split(e.end);const n=t.createPositionAfter(e.end.parent);t.move(e,n)}))}_applyQuote(t,e){const n=[];Bb(t,e).reverse().forEach((e=>{let o=Sb(e.start);o||(o=t.createElement("blockQuote"),t.wrap(e,o)),n.push(o)})),n.reverse().reduce(((e,n)=>e.nextSibling==n?(t.merge(t.createPositionAfter(e)),e):n))}}function Sb(t){return"blockQuote"==t.parent.name?t.parent:null}function Bb(t,e){let n,o=0;const i=[];for(;o{const o=t.model.document.differ.getChanges();for(const t of o)if("insert"==t.type){const o=t.position.nodeAfter;if(!o)continue;if(o.is("element","blockQuote")&&o.isEmpty)return n.remove(o),!0;if(o.is("element","blockQuote")&&!e.checkChild(t.position,o))return n.unwrap(o),!0;if(o.is("element")){const t=n.createRangeIn(o);for(const o of t.getItems())if(o.is("element","blockQuote")&&!e.checkChild(n.createPositionBefore(o),o))return n.unwrap(o),!0}}else if("remove"==t.type){const e=t.position.parent;if(e.is("element","blockQuote")&&e.isEmpty)return n.remove(e),!0}return!1}));const n=this.editor.editing.view.document,o=t.model.document.selection,i=t.commands.get("blockQuote");this.listenTo(n,"enter",((e,n)=>{if(!o.isCollapsed||!i.value)return;o.getLastPosition().parent.isEmpty&&(t.execute("blockQuote"),t.editing.view.scrollToTheSelection(),n.preventDefault(),e.stop())}),{context:"blockquote"}),this.listenTo(n,"delete",((e,n)=>{if("backward"!=n.direction||!o.isCollapsed||!i.value)return;const r=o.getLastPosition().parent;r.isEmpty&&!r.previousSibling&&(t.execute("blockQuote"),t.editing.view.scrollToTheSelection(),n.preventDefault(),e.stop())}),{context:"blockquote"})}}var Ib=n(636),Rb={attributes:{"data-cke":!0}};Rb.setAttributes=is(),Rb.insert=ns().bind(null,"head"),Rb.domAPI=ts(),Rb.insertStyleElement=ss();Qr()(Ib.Z,Rb);Ib.Z&&Ib.Z.locals&&Ib.Z.locals;class zb extends pe{static get pluginName(){return"BlockQuoteUI"}init(){const t=this.editor,e=t.t;t.ui.componentFactory.add("blockQuote",(n=>{const o=t.commands.get("blockQuote"),i=new pu(n);return i.set({label:e("Block quote"),icon:Td.quote,tooltip:!0,isToggleable:!0}),i.bind("isOn","isEnabled").to(o,"value","isEnabled"),this.listenTo(i,"execute",(()=>{t.execute("blockQuote"),t.editing.view.focus()})),i}))}}class Fb extends ge{refresh(){const t=this.editor.model,e=Ta(t.document.selection.getSelectedBlocks());this.value=!!e&&e.is("element","paragraph"),this.isEnabled=!!e&&Nb(e,t.schema)}execute(t={}){const e=this.editor.model,n=e.document;e.change((o=>{const i=(t.selection||n.selection).getSelectedBlocks();for(const t of i)!t.is("element","paragraph")&&Nb(t,e.schema)&&o.rename(t,"paragraph")}))}}function Nb(t,e){return e.checkChild(t.parent,"paragraph")&&!e.isObject(t)}class Ob extends ge{execute(t){const e=this.editor.model;let n=t.position;e.change((t=>{const o=t.createElement("paragraph");if(!e.schema.checkChild(n.parent,o)){const i=e.schema.findAllowedParent(n,o);if(!i)return;n=t.split(n,i).position}e.insertContent(o,n),t.setSelection(o,"in")}))}}class Mb extends pe{static get pluginName(){return"Paragraph"}init(){const t=this.editor,e=t.model;t.commands.add("paragraph",new Fb(t)),t.commands.add("insertParagraph",new Ob(t)),e.schema.register("paragraph",{inheritAllFrom:"$block"}),t.conversion.elementToElement({model:"paragraph",view:"p"}),t.conversion.for("upcast").elementToElement({model:(t,{writer:e})=>Mb.paragraphLikeElements.has(t.name)?t.isEmpty?null:e.createElement("paragraph"):null,view:/.+/,converterPriority:"low"})}}Mb.paragraphLikeElements=new Set(["blockquote","dd","div","dt","h1","h2","h3","h4","h5","h6","li","p","td","th"]);class Vb extends ge{constructor(t,e){super(t),this.modelElements=e}refresh(){const t=Ta(this.editor.model.document.selection.getSelectedBlocks());this.value=!!t&&this.modelElements.includes(t.name)&&t.name,this.isEnabled=!!t&&this.modelElements.some((e=>Lb(t,e,this.editor.model.schema)))}execute(t){const e=this.editor.model,n=e.document,o=t.value;e.change((t=>{const i=Array.from(n.selection.getSelectedBlocks()).filter((t=>Lb(t,o,e.schema)));for(const e of i)e.is("element",o)||t.rename(e,o)}))}}function Lb(t,e,n){return n.checkChild(t.parent,e)&&!n.isObject(t)}const Hb="paragraph";class qb extends pe{static get pluginName(){return"HeadingEditing"}constructor(t){super(t),t.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[Mb]}init(){const t=this.editor,e=t.config.get("heading.options"),n=[];for(const o of e)o.model!==Hb&&(t.model.schema.register(o.model,{inheritAllFrom:"$block"}),t.conversion.elementToElement(o),n.push(o.model));this._addDefaultH1Conversion(t),t.commands.add("heading",new Vb(t,n))}afterInit(){const t=this.editor,e=t.commands.get("enter"),n=t.config.get("heading.options");e&&this.listenTo(e,"afterExecute",((e,o)=>{const i=t.model.document.selection.getFirstPosition().parent;n.some((t=>i.is("element",t.model)))&&!i.is("element",Hb)&&0===i.childCount&&o.writer.rename(i,Hb)}))}_addDefaultH1Conversion(t){t.conversion.for("upcast").elementToElement({model:"heading1",view:"h1",converterPriority:r.get("low")+1})}}var Wb=n(3230),jb={attributes:{"data-cke":!0}};jb.setAttributes=is(),jb.insert=ns().bind(null,"head"),jb.domAPI=ts(),jb.insertStyleElement=ss();Qr()(Wb.Z,jb);Wb.Z&&Wb.Z.locals&&Wb.Z.locals;class Ub extends pe{static get pluginName(){return"HeadingUI"}init(){const t=this.editor,e=t.t,n=function(t){const e=t.t,n={Paragraph:e("Paragraph"),"Heading 1":e("Heading 1"),"Heading 2":e("Heading 2"),"Heading 3":e("Heading 3"),"Heading 4":e("Heading 4"),"Heading 5":e("Heading 5"),"Heading 6":e("Heading 6")};return t.config.get("heading.options").map((t=>{const e=n[t.title];return e&&e!=t.title&&(t.title=e),t}))}(t),o=e("Choose heading"),i=e("Heading");t.ui.componentFactory.add("heading",(e=>{const r={},s=new So,a=t.commands.get("heading"),c=t.commands.get("paragraph"),l=[a];for(const t of n){const e={type:"button",model:new Eh({label:t.title,class:t.class,withText:!0})};"paragraph"===t.model?(e.model.bind("isOn").to(c,"value"),e.model.set("commandName","paragraph"),l.push(c)):(e.model.bind("isOn").to(a,"value",(e=>e===t.model)),e.model.set({commandName:"heading",commandValue:t.model})),s.add(e),r[t.model]=t.title}const d=nh(e);return ih(d,s),d.buttonView.set({isOn:!1,withText:!0,tooltip:i}),d.extendTemplate({attributes:{class:["ck-heading-dropdown"]}}),d.bind("isEnabled").toMany(l,"isEnabled",((...t)=>t.some((t=>t)))),d.buttonView.bind("label").to(a,"value",c,"value",((t,e)=>{const n=t||e&&"paragraph";return r[n]?r[n]:o})),this.listenTo(d,"execute",(e=>{t.execute(e.source.commandName,e.source.commandValue?{value:e.source.commandValue}:void 0),t.editing.view.focus()})),d}))}}function $b(t,e,n){return t=>{t.on(`attribute:${n}:${e}`,o)};function o(e,n,o){if(!o.consumable.consume(n.item,e.name))return;const i=o.writer,r=o.mapper.toViewElement(n.item),s=t.findViewImgElement(r);i.setAttribute(n.attributeKey,n.attributeNewValue||"",s)}}class Gb extends Bs{observe(t){this.listenTo(t,"load",((t,e)=>{const n=e.target;this.checkShouldIgnoreEventFromTarget(n)||"IMG"==n.tagName&&this._fireEvents(e)}),{useCapture:!0})}_fireEvents(t){this.isEnabled&&(this.document.fire("layoutChanged"),this.document.fire("imageLoaded",t))}}class Kb extends ge{constructor(t){super(t);const e=t.config.get("image.insert.type");t.plugins.has("ImageBlockEditing")||"block"===e&&a("image-block-plugin-required"),t.plugins.has("ImageInlineEditing")||"inline"===e&&a("image-inline-plugin-required")}refresh(){this.isEnabled=this.editor.plugins.get("ImageUtils").isImageAllowed()}execute(t){const e=To(t.source),n=this.editor.model.document.selection,o=this.editor.plugins.get("ImageUtils"),i=Object.fromEntries(n.getAttributes());e.forEach(((t,e)=>{const r=n.getSelectedElement();if("string"==typeof t&&(t={src:t}),e&&r&&o.isImage(r)){const e=this.editor.model.createPositionAfter(r);o.insertImage({...t,...i},e)}else o.insertImage({...t,...i})}))}}class Zb extends pe{static get requires(){return[af]}static get pluginName(){return"ImageEditing"}init(){const t=this.editor,e=t.conversion;t.editing.view.addObserver(Gb),e.for("upcast").attributeToAttribute({view:{name:"img",key:"alt"},model:"alt"}).attributeToAttribute({view:{name:"img",key:"srcset"},model:{key:"srcset",value:t=>{const e={data:t.getAttribute("srcset")};return t.hasAttribute("width")&&(e.width=t.getAttribute("width")),e}}});const n=new Kb(t);t.commands.add("insertImage",n),t.commands.add("imageInsert",n)}}class Jb extends ge{constructor(t,e){super(t),this._modelElementName=e}refresh(){const t=this.editor.plugins.get("ImageUtils"),e=t.getClosestSelectedImageElement(this.editor.model.document.selection);"imageBlock"===this._modelElementName?this.isEnabled=t.isInlineImage(e):this.isEnabled=t.isBlockImage(e)}execute(){const t=this.editor,e=this.editor.model,n=t.plugins.get("ImageUtils"),o=n.getClosestSelectedImageElement(e.document.selection),i=Object.fromEntries(o.getAttributes());return i.src||i.uploadId?e.change((t=>{const r=Array.from(e.markers).filter((t=>t.getRange().containsItem(o))),s=n.insertImage(i,e.createSelection(o,"on"),this._modelElementName);if(!s)return null;const a=t.createRangeOn(s);for(const e of r){const n=e.getRange(),o="$graveyard"!=n.root.rootName?n.getJoined(a,!0):a;t.updateMarker(e,{range:o})}return{oldElement:o,newElement:s}})):null}}class Yb extends pe{static get requires(){return[Zb,af,Og]}static get pluginName(){return"ImageBlockEditing"}init(){const t=this.editor;t.model.schema.register("imageBlock",{isObject:!0,isBlock:!0,allowWhere:"$block",allowAttributes:["alt","src","srcset"]}),this._setupConversion(),t.plugins.has("ImageInlineEditing")&&(t.commands.add("imageTypeBlock",new Jb(this.editor,"imageBlock")),this._setupClipboardIntegration())}_setupConversion(){const t=this.editor,e=t.t,n=t.conversion,o=t.plugins.get("ImageUtils");n.for("dataDowncast").elementToElement({model:"imageBlock",view:(t,{writer:e})=>of(e,"imageBlock")}),n.for("editingDowncast").elementToElement({model:"imageBlock",view:(t,{writer:n})=>o.toImageWidget(of(n,"imageBlock"),n,e("image widget"))}),n.for("downcast").add($b(o,"imageBlock","src")).add($b(o,"imageBlock","alt")).add(function(t,e){return t=>{t.on(`attribute:srcset:${e}`,n)};function n(e,n,o){if(!o.consumable.consume(n.item,e.name))return;const i=o.writer,r=o.mapper.toViewElement(n.item),s=t.findViewImgElement(r);if(null===n.attributeNewValue){const t=n.attributeOldValue;t.data&&(i.removeAttribute("srcset",s),i.removeAttribute("sizes",s),t.width&&i.removeAttribute("width",s))}else{const t=n.attributeNewValue;t.data&&(i.setAttribute("srcset",t.data,s),i.setAttribute("sizes","100vw",s),t.width&&i.setAttribute("width",t.width,s))}}}(o,"imageBlock")),n.for("upcast").elementToElement({view:rf(t,"imageBlock"),model:(t,{writer:e})=>e.createElement("imageBlock",t.hasAttribute("src")?{src:t.getAttribute("src")}:null)}).add(function(t){return t=>{t.on("element:figure",e)};function e(e,n,o){if(!o.consumable.test(n.viewItem,{name:!0,classes:"image"}))return;const i=t.findViewImgElement(n.viewItem);if(!i||!o.consumable.test(i,{name:!0}))return;o.consumable.consume(n.viewItem,{name:!0,classes:"image"});const r=Ta(o.convertItem(i,n.modelCursor).modelRange.getItems());r?(o.convertChildren(n.viewItem,r),o.updateConversionResult(r,n)):o.consumable.revert(n.viewItem,{name:!0,classes:"image"})}}(o))}_setupClipboardIntegration(){const t=this.editor,e=t.model,n=t.editing.view,o=t.plugins.get("ImageUtils");this.listenTo(t.plugins.get("ClipboardPipeline"),"inputTransformation",((i,r)=>{const s=Array.from(r.content.getChildren());let a;if(!s.every(o.isInlineImageView))return;a=r.targetRanges?t.editing.mapper.toModelRange(r.targetRanges[0]):e.document.selection.getFirstRange();const c=e.createSelection(a);if("imageBlock"===sf(e.schema,c)){const t=new pp(n.document),e=s.map((e=>t.createElement("figure",{class:"image"},e)));r.content=t.createDocumentFragment(e)}}))}}function Qb(t){for(const e of t.getChildren())if(e&&e.is("element","caption"))return e;return null}function Xb(t,e){const n=e.getFirstPosition().findAncestor("caption");return n&&t.isBlockImage(n.parent)?n:null}class tk extends ge{refresh(){const t=this.editor,e=t.plugins.get("ImageUtils");if(!t.plugins.has(Yb))return this.isEnabled=!1,void(this.value=!1);const n=t.model.document.selection,o=n.getSelectedElement();if(!o){const t=Xb(e,n);return this.isEnabled=!!t,void(this.value=!!t)}this.isEnabled=this.editor.plugins.get("ImageUtils").isImage(o),this.isEnabled?this.value=!!Qb(o):this.value=!1}execute(t={}){const{focusCaptionOnShow:e}=t;this.editor.model.change((t=>{this.value?this._hideImageCaption(t):this._showImageCaption(t,e)}))}_showImageCaption(t,e){const n=this.editor.model.document.selection,o=this.editor.plugins.get("ImageCaptionEditing");let i=n.getSelectedElement();const r=o._getSavedCaption(i);this.editor.plugins.get("ImageUtils").isInlineImage(i)&&(this.editor.execute("imageTypeBlock"),i=n.getSelectedElement());const s=r||t.createElement("caption");t.append(s,i),e&&t.setSelection(s,"in")}_hideImageCaption(t){const e=this.editor,n=e.model.document.selection,o=e.plugins.get("ImageCaptionEditing"),i=e.plugins.get("ImageUtils");let r,s=n.getSelectedElement();s?r=Qb(s):(r=Xb(i,n),s=r.parent),o._saveCaption(s,r),t.setSelection(s,"on"),t.remove(r)}}class ek extends pe{static get requires(){return[af]}static get pluginName(){return"ImageCaptionEditing"}constructor(t){super(t),this._savedCaptionsMap=new WeakMap}init(){const t=this.editor,e=t.model.schema;e.isRegistered("caption")?e.extend("caption",{allowIn:"imageBlock"}):e.register("caption",{allowIn:"imageBlock",allowContentOf:"$block",isLimit:!0}),t.commands.add("toggleImageCaption",new tk(this.editor)),this._setupConversion(),this._setupImageTypeCommandsIntegration()}_setupConversion(){const t=this.editor,e=t.editing.view,n=t.plugins.get("ImageUtils"),o=t.t;t.conversion.for("upcast").elementToElement({view:t=>function(t,e){return"figcaption"==e.name&&t.isBlockImageView(e.parent)?{name:!0}:null}(n,t),model:"caption"}),t.conversion.for("dataDowncast").elementToElement({model:"caption",view:(t,{writer:e})=>n.isBlockImage(t.parent)?e.createContainerElement("figcaption"):null}),t.conversion.for("editingDowncast").elementToElement({model:"caption",view:(t,{writer:i})=>{if(!n.isBlockImage(t.parent))return null;const r=i.createEditableElement("figcaption");return i.setCustomProperty("imageCaption",!0,r),Zh({view:e,element:r,text:o("Enter image caption"),keepOnFocus:!0}),km(r,i)}}),t.editing.mapper.on("modelToViewPosition",nk(e)),t.data.mapper.on("modelToViewPosition",nk(e))}_setupImageTypeCommandsIntegration(){const t=this.editor,e=t.plugins.get("ImageUtils"),n=t.commands.get("imageTypeInline"),o=t.commands.get("imageTypeBlock"),i=t=>{if(!t.return)return;const{oldElement:n,newElement:o}=t.return;if(!n)return;if(e.isBlockImage(n)){const t=Qb(n);if(t)return void this._saveCaption(o,t)}const i=this._getSavedCaption(n);i&&this._saveCaption(o,i)};n&&this.listenTo(n,"execute",i,{priority:"low"}),o&&this.listenTo(o,"execute",i,{priority:"low"})}_getSavedCaption(t){const e=this._savedCaptionsMap.get(t);return e?Za.fromJSON(e):null}_saveCaption(t,e){this._savedCaptionsMap.set(t,e.toJSON())}}function nk(t){return(e,n)=>{const o=n.modelPosition,i=o.parent;if(!i.is("element","imageBlock"))return;const r=n.mapper.toViewElement(i);n.viewPosition=t.createPositionAt(r,o.offset+1)}}class ok extends pe{static get requires(){return[af]}static get pluginName(){return"ImageCaptionUI"}init(){const t=this.editor,e=t.editing.view,n=t.plugins.get("ImageUtils"),o=t.t;t.ui.componentFactory.add("toggleImageCaption",(i=>{const r=t.commands.get("toggleImageCaption"),s=new pu(i);return s.set({icon:Td.caption,tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(r,"value","isEnabled"),s.bind("label").to(r,"value",(t=>o(t?"Toggle caption off":"Toggle caption on"))),this.listenTo(s,"execute",(()=>{t.execute("toggleImageCaption",{focusCaptionOnShow:!0});const o=Xb(n,t.model.document.selection);if(o){const n=t.editing.mapper.toViewElement(o);e.scrollToTheSelection(),e.change((t=>{t.addClass("image__caption_highlighted",n)}))}})),s}))}}var ik=n(8662),rk={attributes:{"data-cke":!0}};rk.setAttributes=is(),rk.insert=ns().bind(null,"head"),rk.domAPI=ts(),rk.insertStyleElement=ss();Qr()(ik.Z,rk);ik.Z&&ik.Z.locals&&ik.Z.locals;class sk extends ge{constructor(t,e){super(t),this._defaultStyles={imageBlock:!1,imageInline:!1},this._styles=new Map(e.map((t=>{if(t.isDefault)for(const e of t.modelElements)this._defaultStyles[e]=t.name;return[t.name,t]})))}refresh(){const t=this.editor.plugins.get("ImageUtils").getClosestSelectedImageElement(this.editor.model.document.selection);this.isEnabled=!!t,this.isEnabled?t.hasAttribute("imageStyle")?this.value=t.getAttribute("imageStyle"):this.value=this._defaultStyles[t.name]:this.value=!1}execute(t={}){const e=this.editor,n=e.model,o=e.plugins.get("ImageUtils");n.change((e=>{const i=t.value;let r=o.getClosestSelectedImageElement(n.document.selection);i&&this.shouldConvertImageType(i,r)&&(this.editor.execute(o.isBlockImage(r)?"imageTypeInline":"imageTypeBlock"),r=o.getClosestSelectedImageElement(n.document.selection)),!i||this._styles.get(i).isDefault?e.removeAttribute("imageStyle",r):e.setAttribute("imageStyle",i,r)}))}shouldConvertImageType(t,e){return!this._styles.get(t).modelElements.includes(e.name)}}const{objectFullWidth:ak,objectInline:ck,objectLeft:lk,objectRight:dk,objectCenter:uk,objectBlockLeft:hk,objectBlockRight:pk}=Td,mk={inline:{name:"inline",title:"In line",icon:ck,modelElements:["imageInline"],isDefault:!0},alignLeft:{name:"alignLeft",title:"Left aligned image",icon:lk,modelElements:["imageBlock","imageInline"],className:"image-style-align-left"},alignBlockLeft:{name:"alignBlockLeft",title:"Left aligned image",icon:hk,modelElements:["imageBlock"],className:"image-style-block-align-left"},alignCenter:{name:"alignCenter",title:"Centered image",icon:uk,modelElements:["imageBlock"],className:"image-style-align-center"},alignRight:{name:"alignRight",title:"Right aligned image",icon:dk,modelElements:["imageBlock","imageInline"],className:"image-style-align-right"},alignBlockRight:{name:"alignBlockRight",title:"Right aligned image",icon:pk,modelElements:["imageBlock"],className:"image-style-block-align-right"},block:{name:"block",title:"Centered image",icon:uk,modelElements:["imageBlock"],isDefault:!0},side:{name:"side",title:"Side image",icon:dk,modelElements:["imageBlock"],className:"image-style-side"}},gk={full:ak,left:hk,right:pk,center:uk,inlineLeft:lk,inlineRight:dk,inline:ck},fk=[{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 bk(t){a("image-style-configuration-definition-invalid",t)}const kk={normalizeStyles:function(t){const e=(t.configuredStyles.options||[]).map((t=>function(t){t="string"==typeof t?mk[t]?{...mk[t]}:{name:t}:function(t,e){const n={...e};for(const o in t)Object.prototype.hasOwnProperty.call(e,o)||(n[o]=t[o]);return n}(mk[t.name],t);"string"==typeof t.icon&&(t.icon=gk[t.icon]||t.icon);return t}(t))).filter((e=>function(t,{isBlockPluginLoaded:e,isInlinePluginLoaded:n}){const{modelElements:o,name:i}=t;if(!(o&&o.length&&i))return bk({style:t}),!1;{const i=[e?"imageBlock":null,n?"imageInline":null];if(!o.some((t=>i.includes(t))))return a("image-style-missing-dependency",{style:t,missingPlugins:o.map((t=>"imageBlock"===t?"ImageBlockEditing":"ImageInlineEditing"))}),!1}return!0}(e,t)));return e},getDefaultStylesConfiguration:function(t,e){return t&&e?{options:["inline","alignLeft","alignRight","alignCenter","alignBlockLeft","alignBlockRight","block","side"]}:t?{options:["block","side"]}:e?{options:["inline","alignLeft","alignRight"]}:{}},getDefaultDropdownDefinitions:function(t){return t.has("ImageBlockEditing")&&t.has("ImageInlineEditing")?[...fk]:[]},warnInvalidStyle:bk,DEFAULT_OPTIONS:mk,DEFAULT_ICONS:gk,DEFAULT_DROPDOWN_DEFINITIONS:fk};function wk(t,e){for(const n of e)if(n.name===t)return n}class _k extends pe{static get pluginName(){return"ImageStyleEditing"}static get requires(){return[af]}init(){const{normalizeStyles:t,getDefaultStylesConfiguration:e}=kk,n=this.editor,o=n.plugins.has("ImageBlockEditing"),i=n.plugins.has("ImageInlineEditing");n.config.define("image.styles",e(o,i)),this.normalizedStyles=t({configuredStyles:n.config.get("image.styles"),isBlockPluginLoaded:o,isInlinePluginLoaded:i}),this._setupConversion(o,i),this._setupPostFixer(),n.commands.add("imageStyle",new sk(n,this.normalizedStyles))}_setupConversion(t,e){const n=this.editor,o=n.model.schema,i=(r=this.normalizedStyles,(t,e,n)=>{if(!n.consumable.consume(e.item,t.name))return;const o=wk(e.attributeNewValue,r),i=wk(e.attributeOldValue,r),s=n.mapper.toViewElement(e.item),a=n.writer;i&&a.removeClass(i.className,s),o&&a.addClass(o.className,s)});var r;const s=function(t){const e={imageInline:t.filter((t=>!t.isDefault&&t.modelElements.includes("imageInline"))),imageBlock:t.filter((t=>!t.isDefault&&t.modelElements.includes("imageBlock")))};return(t,n,o)=>{if(!n.modelRange)return;const i=n.viewItem,r=Ta(n.modelRange.getItems());if(r&&o.schema.checkAttribute(r,"imageStyle"))for(const t of e[r.name])o.consumable.consume(i,{classes:t.className})&&o.writer.setAttribute("imageStyle",t.name,r)}}(this.normalizedStyles);n.editing.downcastDispatcher.on("attribute:imageStyle",i),n.data.downcastDispatcher.on("attribute:imageStyle",i),t&&(o.extend("imageBlock",{allowAttributes:"imageStyle"}),n.data.upcastDispatcher.on("element:figure",s,{priority:"low"})),e&&(o.extend("imageInline",{allowAttributes:"imageStyle"}),n.data.upcastDispatcher.on("element:img",s,{priority:"low"}))}_setupPostFixer(){const t=this.editor,e=t.model.document,n=t.plugins.get(af),o=new Map(this.normalizedStyles.map((t=>[t.name,t])));e.registerPostFixer((t=>{let i=!1;for(const r of e.differ.getChanges())if("insert"==r.type||"attribute"==r.type&&"imageStyle"==r.attributeKey){let e="insert"==r.type?r.position.nodeAfter:r.range.start.nodeAfter;if(e&&e.is("element","paragraph")&&e.childCount>0&&(e=e.getChild(0)),!n.isImage(e))continue;const s=e.getAttribute("imageStyle");if(!s)continue;const a=o.get(s);a&&a.modelElements.includes(e.name)||(t.removeAttribute("imageStyle",e),i=!0)}return i}))}}var Ck=n(4622),Ak={attributes:{"data-cke":!0}};Ak.setAttributes=is(),Ak.insert=ns().bind(null,"head"),Ak.domAPI=ts(),Ak.insertStyleElement=ss();Qr()(Ck.Z,Ak);Ck.Z&&Ck.Z.locals&&Ck.Z.locals;class vk extends pe{static get requires(){return[_k]}static get pluginName(){return"ImageStyleUI"}get localizedDefaultStylesTitles(){const t=this.editor.t;return{"Wrap text":t("Wrap text"),"Break text":t("Break text"),"In line":t("In line"),"Full size image":t("Full size image"),"Side image":t("Side image"),"Left aligned image":t("Left aligned image"),"Centered image":t("Centered image"),"Right aligned image":t("Right aligned image")}}init(){const t=this.editor.plugins,e=this.editor.config.get("image.toolbar")||[],n=yk(t.get("ImageStyleEditing").normalizedStyles,this.localizedDefaultStylesTitles);for(const t of n)this._createButton(t);const o=yk([...e.filter(y),...kk.getDefaultDropdownDefinitions(t)],this.localizedDefaultStylesTitles);for(const t of o)this._createDropdown(t,n)}_createDropdown(t,e){const n=this.editor.ui.componentFactory;n.add(t.name,(o=>{let i;const{defaultItem:r,items:s,title:a}=t,c=s.filter((t=>e.find((({name:e})=>xk(e)===t)))).map((t=>{const e=n.create(t);return t===r&&(i=e),e}));s.length!==c.length&&kk.warnInvalidStyle({dropdown:t});const l=nh(o,Pu),d=l.buttonView;return oh(l,c),d.set({label:Ek(a,i.label),class:null,tooltip:!0}),d.bind("icon").toMany(c,"isOn",((...t)=>{const e=t.findIndex(rt);return e<0?i.icon:c[e].icon})),d.bind("label").toMany(c,"isOn",((...t)=>{const e=t.findIndex(rt);return Ek(a,e<0?i.label:c[e].label)})),d.bind("isOn").toMany(c,"isOn",((...t)=>t.some(rt))),d.bind("class").toMany(c,"isOn",((...t)=>t.some(rt)?"ck-splitbutton_flatten":null)),d.on("execute",(()=>{c.some((({isOn:t})=>t))?l.isOpen=!l.isOpen:i.fire("execute")})),l.bind("isEnabled").toMany(c,"isEnabled",((...t)=>t.some(rt))),l}))}_createButton(t){const e=t.name;this.editor.ui.componentFactory.add(xk(e),(n=>{const o=this.editor.commands.get("imageStyle"),i=new pu(n);return i.set({label:t.title,icon:t.icon,tooltip:!0,isToggleable:!0}),i.bind("isEnabled").to(o,"isEnabled"),i.bind("isOn").to(o,"value",(t=>t===e)),i.on("execute",this._executeCommand.bind(this,e)),i}))}_executeCommand(t){this.editor.execute("imageStyle",{value:t}),this.editor.editing.view.focus()}}function yk(t,e){for(const n of t)e[n.title]&&(n.title=e[n.title]);return t}function xk(t){return`imageStyle:${t}`}function Ek(t,e){return(t?t+": ":"")+e}class Dk{constructor(){this._definitions=new Set}get length(){return this._definitions.size}add(t){Array.isArray(t)?t.forEach((t=>this._definitions.add(t))):this._definitions.add(t)}getDispatcher(){return t=>{t.on("attribute:linkHref",((t,e,n)=>{if(!n.consumable.test(e.item,"attribute:linkHref"))return;const o=n.writer,i=o.document.selection;for(const t of this._definitions){const r=o.createAttributeElement("a",t.attributes,{priority:5});t.classes&&o.addClass(t.classes,r);for(const e in t.styles)o.setStyle(e,t.styles[e],r);o.setCustomProperty("link",!0,r),t.callback(e.attributeNewValue)?e.item.is("selection")?o.wrap(i.getFirstRange(),r):o.wrap(n.mapper.toViewRange(e.range),r):o.unwrap(n.mapper.toViewRange(e.range),r)}}),{priority:"high"})}}getDispatcherForLinkedImage(){return t=>{t.on("attribute:linkHref:imageBlock",((t,e,{writer:n,mapper:o})=>{const i=o.toViewElement(e.item),r=Array.from(i.getChildren()).find((t=>"a"===t.name));for(const t of this._definitions){const o=qo(t.attributes);if(t.callback(e.attributeNewValue)){for(const[t,e]of o)"class"===t?n.addClass(e,r):n.setAttribute(t,e,r);t.classes&&n.addClass(t.classes,r);for(const e in t.styles)n.setStyle(e,t.styles[e],r)}else{for(const[t,e]of o)"class"===t?n.removeClass(e,r):n.removeAttribute(t,r);t.classes&&n.removeClass(t.classes,r);for(const e in t.styles)n.removeStyle(e,r)}}}))}}}const Sk=function(t,e,n){var o=t.length;return n=void 0===n?o:n,!e&&n>=o?t:ui(t,e,n)};var Bk=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");const Tk=function(t){return Bk.test(t)};const Pk=function(t){return t.split("")};var Ik="[\\ud800-\\udfff]",Rk="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",zk="\\ud83c[\\udffb-\\udfff]",Fk="[^\\ud800-\\udfff]",Nk="(?:\\ud83c[\\udde6-\\uddff]){2}",Ok="[\\ud800-\\udbff][\\udc00-\\udfff]",Mk="(?:"+Rk+"|"+zk+")"+"?",Vk="[\\ufe0e\\ufe0f]?",Lk=Vk+Mk+("(?:\\u200d(?:"+[Fk,Nk,Ok].join("|")+")"+Vk+Mk+")*"),Hk="(?:"+[Fk+Rk+"?",Rk,Nk,Ok,Ik].join("|")+")",qk=RegExp(zk+"(?="+zk+")|"+Hk+Lk,"g");const Wk=function(t){return t.match(qk)||[]};const jk=function(t){return Tk(t)?Wk(t):Pk(t)};const Uk=function(t){return function(e){e=si(e);var n=Tk(e)?jk(e):void 0,o=n?n[0]:e.charAt(0),i=n?Sk(n,1).join(""):e.slice(1);return o[t]()+i}}("toUpperCase"),$k=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g,Gk=/^(?:(?:https?|ftps?|mailto):|[^a-z]|[a-z+.-]+(?:[^a-z+.:-]|$))/i,Kk=/^[\S]+@((?![-_])(?:[-\w\u00a1-\uffff]{0,63}[^-_]\.))+(?:[a-z\u00a1-\uffff]{2,})$/i,Zk=/^((\w+:(\/{2,})?)|(\W))/i,Jk="Ctrl+K";function Yk(t,{writer:e}){const n=e.createAttributeElement("a",{href:t},{priority:5});return e.setCustomProperty("link",!0,n),n}function Qk(t){return function(t){return t.replace($k,"").match(Gk)}(t=String(t))?t:"#"}function Xk(t,e){return!!t&&e.checkAttribute(t.name,"linkHref")}function tw(t,e){const n=(o=t,Kk.test(o)?"mailto:":e);var o;const i=!!n&&!Zk.test(t);return t&&i?n+t:t}function ew(t){window.open(t,"_blank","noopener")}class nw extends ge{constructor(t){super(t),this.manualDecorators=new So,this.automaticDecorators=new Dk}restoreManualDecoratorStates(){for(const t of this.manualDecorators)t.value=this._getDecoratorStateFromModel(t.id)}refresh(){const t=this.editor.model,e=t.document.selection,n=e.getSelectedElement()||Ta(e.getSelectedBlocks());Xk(n,t.schema)?(this.value=n.getAttribute("linkHref"),this.isEnabled=t.schema.checkAttribute(n,"linkHref")):(this.value=e.getAttribute("linkHref"),this.isEnabled=t.schema.checkAttributeInSelection(e,"linkHref"));for(const t of this.manualDecorators)t.value=this._getDecoratorStateFromModel(t.id)}execute(t,e={}){const n=this.editor.model,o=n.document.selection,i=[],r=[];for(const t in e)e[t]?i.push(t):r.push(t);n.change((e=>{if(o.isCollapsed){const s=o.getFirstPosition();if(o.hasAttribute("linkHref")){const a=Hf(s,"linkHref",o.getAttribute("linkHref"),n);e.setAttribute("linkHref",t,a),i.forEach((t=>{e.setAttribute(t,!0,a)})),r.forEach((t=>{e.removeAttribute(t,a)})),e.setSelection(e.createPositionAfter(a.end.nodeBefore))}else if(""!==t){const r=qo(o.getAttributes());r.set("linkHref",t),i.forEach((t=>{r.set(t,!0)}));const{end:a}=n.insertContent(e.createText(t,r),s);e.setSelection(a)}["linkHref",...i,...r].forEach((t=>{e.removeSelectionAttribute(t)}))}else{const s=n.schema.getValidRanges(o.getRanges(),"linkHref"),a=[];for(const t of o.getSelectedBlocks())n.schema.checkAttribute(t,"linkHref")&&a.push(e.createRangeOn(t));const c=a.slice();for(const t of s)this._isRangeToUpdate(t,a)&&c.push(t);for(const n of c)e.setAttribute("linkHref",t,n),i.forEach((t=>{e.setAttribute(t,!0,n)})),r.forEach((t=>{e.removeAttribute(t,n)}))}}))}_getDecoratorStateFromModel(t){const e=this.editor.model,n=e.document.selection,o=n.getSelectedElement();return Xk(o,e.schema)?o.getAttribute(t):n.getAttribute(t)}_isRangeToUpdate(t,e){for(const n of e)if(n.containsRange(t))return!1;return!0}}class ow extends ge{refresh(){const t=this.editor.model,e=t.document.selection,n=e.getSelectedElement();Xk(n,t.schema)?this.isEnabled=t.schema.checkAttribute(n,"linkHref"):this.isEnabled=t.schema.checkAttributeInSelection(e,"linkHref")}execute(){const t=this.editor,e=this.editor.model,n=e.document.selection,o=t.commands.get("link");e.change((t=>{const i=n.isCollapsed?[Hf(n.getFirstPosition(),"linkHref",n.getAttribute("linkHref"),e)]:e.schema.getValidRanges(n.getRanges(),"linkHref");for(const e of i)if(t.removeAttribute("linkHref",e),o)for(const n of o.manualDecorators)t.removeAttribute(n.id,e)}))}}class iw{constructor({id:t,label:e,attributes:n,classes:o,styles:i,defaultValue:r}){this.id=t,this.set("value"),this.defaultValue=r,this.label=e,this.attributes=n,this.classes=o,this.styles=i}_createPattern(){return{attributes:this.attributes,classes:this.classes,styles:this.styles}}}he(iw,se);var rw=n(399),sw={attributes:{"data-cke":!0}};sw.setAttributes=is(),sw.insert=ns().bind(null,"head"),sw.domAPI=ts(),sw.insertStyleElement=ss();Qr()(rw.Z,sw);rw.Z&&rw.Z.locals&&rw.Z.locals;const aw="automatic",cw=/^(https?:)?\/\//;class lw extends pe{static get pluginName(){return"LinkEditing"}static get requires(){return[Ff,Pf,Og]}constructor(t){super(t),t.config.define("link",{addTargetToExternalLinks:!1})}init(){const t=this.editor;t.model.schema.extend("$text",{allowAttributes:"linkHref"}),t.conversion.for("dataDowncast").attributeToElement({model:"linkHref",view:Yk}),t.conversion.for("editingDowncast").attributeToElement({model:"linkHref",view:(t,e)=>Yk(Qk(t),e)}),t.conversion.for("upcast").elementToAttribute({view:{name:"a",attributes:{href:!0}},model:{key:"linkHref",value:t=>t.getAttribute("href")}}),t.commands.add("link",new nw(t)),t.commands.add("unlink",new ow(t));const e=function(t,e){const n={"Open in a new tab":t("Open in a new tab"),Downloadable:t("Downloadable")};return e.forEach((t=>(t.label&&n[t.label]&&(t.label=n[t.label]),t))),e}(t.t,function(t){const e=[];if(t)for(const[n,o]of Object.entries(t)){const t=Object.assign({},o,{id:`link${Uk(n)}`});e.push(t)}return e}(t.config.get("link.decorators")));this._enableAutomaticDecorators(e.filter((t=>t.mode===aw))),this._enableManualDecorators(e.filter((t=>"manual"===t.mode)));t.plugins.get(Ff).registerAttribute("linkHref"),Wf(t,"linkHref","a","ck-link_selected"),this._enableLinkOpen(),this._enableInsertContentSelectionAttributesFixer(),this._enableClickingAfterLink(),this._enableTypingOverLink(),this._handleDeleteContentAfterLink()}_enableAutomaticDecorators(t){const e=this.editor,n=e.commands.get("link").automaticDecorators;e.config.get("link.addTargetToExternalLinks")&&n.add({id:"linkIsExternal",mode:aw,callback:t=>cw.test(t),attributes:{target:"_blank",rel:"noopener noreferrer"}}),n.add(t),n.length&&e.conversion.for("downcast").add(n.getDispatcher())}_enableManualDecorators(t){if(!t.length)return;const e=this.editor,n=e.commands.get("link").manualDecorators;t.forEach((t=>{e.model.schema.extend("$text",{allowAttributes:t.id}),t=new iw(t),n.add(t),e.conversion.for("downcast").attributeToElement({model:t.id,view:(e,{writer:n})=>{if(e){const e=n.createAttributeElement("a",t.attributes,{priority:5});t.classes&&n.addClass(t.classes,e);for(const o in t.styles)n.setStyle(o,t.styles[o],e);return n.setCustomProperty("link",!0,e),e}}}),e.conversion.for("upcast").elementToAttribute({view:{name:"a",...t._createPattern()},model:{key:t.id}})}))}_enableLinkOpen(){const t=this.editor,e=t.editing.view.document,n=t.model.document;this.listenTo(e,"click",((t,e)=>{if(!(ar.isMac?e.domEvent.metaKey:e.domEvent.ctrlKey))return;let n=e.domTarget;if("a"!=n.tagName.toLowerCase()&&(n=n.closest("a")),!n)return;const o=n.getAttribute("href");o&&(t.stop(),e.preventDefault(),ew(o))}),{context:"$capture"}),this.listenTo(e,"enter",((t,e)=>{const o=n.selection,i=o.getSelectedElement(),r=i?i.getAttribute("linkHref"):o.getAttribute("linkHref");r&&e.domEvent.altKey&&(t.stop(),ew(r))}),{context:"a"})}_enableInsertContentSelectionAttributesFixer(){const t=this.editor.model,e=t.document.selection;this.listenTo(t,"insertContent",(()=>{const n=e.anchor.nodeBefore,o=e.anchor.nodeAfter;e.hasAttribute("linkHref")&&n&&n.hasAttribute("linkHref")&&(o&&o.hasAttribute("linkHref")||t.change((e=>{dw(e,hw(t.schema))})))}),{priority:"low"})}_enableClickingAfterLink(){const t=this.editor,e=t.model;t.editing.view.addObserver(hp);let n=!1;this.listenTo(t.editing.view.document,"mousedown",(()=>{n=!0})),this.listenTo(t.editing.view.document,"selectionChange",(()=>{if(!n)return;n=!1;const t=e.document.selection;if(!t.isCollapsed)return;if(!t.hasAttribute("linkHref"))return;const o=t.getFirstPosition(),i=Hf(o,"linkHref",t.getAttribute("linkHref"),e);(o.isTouching(i.start)||o.isTouching(i.end))&&e.change((t=>{dw(t,hw(e.schema))}))}))}_enableTypingOverLink(){const t=this.editor,e=t.editing.view;let n,o;this.listenTo(e.document,"delete",(()=>{o=!0}),{priority:"high"}),this.listenTo(t.model,"deleteContent",(()=>{const e=t.model.document.selection;e.isCollapsed||(o?o=!1:uw(t)&&function(t){const e=t.document.selection,n=e.getFirstPosition(),o=e.getLastPosition(),i=n.nodeAfter;if(!i)return!1;if(!i.is("$text"))return!1;if(!i.hasAttribute("linkHref"))return!1;const r=o.textNode||o.nodeBefore;if(i===r)return!0;return Hf(n,"linkHref",i.getAttribute("linkHref"),t).containsRange(t.createRange(n,o),!0)}(t.model)&&(n=e.getAttributes()))}),{priority:"high"}),this.listenTo(t.model,"insertContent",((e,[i])=>{o=!1,uw(t)&&n&&(t.model.change((t=>{for(const[e,o]of n)t.setAttribute(e,o,i)})),n=null)}),{priority:"high"})}_handleDeleteContentAfterLink(){const t=this.editor,e=t.model,n=e.document.selection,o=t.editing.view;let i=!1,r=!1;this.listenTo(o.document,"delete",((t,e)=>{r=e.domEvent.keyCode===ur.backspace}),{priority:"high"}),this.listenTo(e,"deleteContent",(()=>{i=!1;const t=n.getFirstPosition(),o=n.getAttribute("linkHref");if(!o)return;const r=Hf(t,"linkHref",o,e);i=r.containsPosition(t)||r.end.isEqual(t)}),{priority:"high"}),this.listenTo(e,"deleteContent",(()=>{r&&(r=!1,i||t.model.enqueueChange((t=>{dw(t,hw(e.schema))})))}),{priority:"low"})}}function dw(t,e){t.removeSelectionAttribute("linkHref");for(const n of e)t.removeSelectionAttribute(n)}function uw(t){return t.model.change((t=>t.batch)).isTyping}function hw(t){return t.getDefinition("$text").allowAttributes.filter((t=>t.startsWith("link")))}var pw=n(1590),mw={attributes:{"data-cke":!0}};mw.setAttributes=is(),mw.insert=ns().bind(null,"head"),mw.domAPI=ts(),mw.insertStyleElement=ss();Qr()(pw.Z,mw);pw.Z&&pw.Z.locals&&pw.Z.locals;var gw=n(4827),fw={attributes:{"data-cke":!0}};fw.setAttributes=is(),fw.insert=ns().bind(null,"head"),fw.domAPI=ts(),fw.insertStyleElement=ss();Qr()(gw.Z,fw);gw.Z&&gw.Z.locals&&gw.Z.locals;class bw extends Od{constructor(t,e){super(t);const n=t.t;this.focusTracker=new Pa,this.keystrokes=new Ia,this.urlInputView=this._createUrlInput(),this.saveButtonView=this._createButton(n("Save"),Td.check,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(n("Cancel"),Td.cancel,"ck-button-cancel","cancel"),this._manualDecoratorSwitches=this._createManualDecoratorSwitches(e),this.children=this._createFormChildren(e.manualDecorators),this._focusables=new zd,this._focusCycler=new Au({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}});const o=["ck","ck-link-form","ck-responsive-form"];e.manualDecorators.length&&o.push("ck-link-form_layout-vertical","ck-vertical-form"),this.setTemplate({tag:"form",attributes:{class:o,tabindex:"-1"},children:this.children}),Id(this)}getDecoratorSwitchesState(){return Array.from(this._manualDecoratorSwitches).reduce(((t,e)=>(t[e.name]=e.isOn,t)),{})}render(){super.render(),Rd({view:this});[this.urlInputView,...this._manualDecoratorSwitches,this.saveButtonView,this.cancelButtonView].forEach((t=>{this._focusables.add(t),this.focusTracker.add(t.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createUrlInput(){const t=this.locale.t,e=new Ah(this.locale,vh);return e.label=t("Link URL"),e}_createButton(t,e,n,o){const i=new pu(this.locale);return i.set({label:t,icon:e,tooltip:!0}),i.extendTemplate({attributes:{class:n}}),o&&i.delegate("execute").to(this,o),i}_createManualDecoratorSwitches(t){const e=this.createCollection();for(const n of t.manualDecorators){const o=new fu(this.locale);o.set({name:n.id,label:n.label,withText:!0}),o.bind("isOn").toMany([n,t],"value",((t,e)=>void 0===e&&void 0===t?n.defaultValue:t)),o.on("execute",(()=>{n.set("value",!o.isOn)})),e.add(o)}return e}_createFormChildren(t){const e=this.createCollection();if(e.add(this.urlInputView),t.length){const t=new Od;t.setTemplate({tag:"ul",children:this._manualDecoratorSwitches.map((t=>({tag:"li",children:[t],attributes:{class:["ck","ck-list__item"]}}))),attributes:{class:["ck","ck-reset","ck-list"]}}),e.add(t)}return e.add(this.saveButtonView),e.add(this.cancelButtonView),e}}var kw=n(9465),ww={attributes:{"data-cke":!0}};ww.setAttributes=is(),ww.insert=ns().bind(null,"head"),ww.domAPI=ts(),ww.insertStyleElement=ss();Qr()(kw.Z,ww);kw.Z&&kw.Z.locals&&kw.Z.locals;class _w extends Od{constructor(t){super(t);const e=t.t;this.focusTracker=new Pa,this.keystrokes=new Ia,this.previewButtonView=this._createPreviewButton(),this.unlinkButtonView=this._createButton(e("Unlink"),'',"unlink"),this.editButtonView=this._createButton(e("Edit link"),Td.pencil,"edit"),this.set("href"),this._focusables=new zd,this._focusCycler=new Au({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((t=>{this._focusables.add(t),this.focusTracker.add(t.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createButton(t,e,n){const o=new pu(this.locale);return o.set({label:t,icon:e,tooltip:!0}),o.delegate("execute").to(this,n),o}_createPreviewButton(){const t=new pu(this.locale),e=this.bindTemplate,n=this.t;return t.set({withText:!0,tooltip:n("Open link in new tab")}),t.extendTemplate({attributes:{class:["ck","ck-link-actions__preview"],href:e.to("href",(t=>t&&Qk(t))),target:"_blank",rel:"noopener noreferrer"}}),t.bind("label").to(this,"href",(t=>t||n("This link has no URL"))),t.bind("isEnabled").to(this,"href",(t=>!!t)),t.template.tag="a",t.template.eventListeners={},t}}const Cw="link-ui";class Aw extends pe{static get requires(){return[Vh]}static get pluginName(){return"LinkUI"}init(){const t=this.editor;t.editing.view.addObserver(up),this.actionsView=this._createActionsView(),this.formView=this._createFormView(),this._balloon=t.plugins.get(Vh),this._createToolbarLinkButton(),this._enableUserBalloonInteractions(),t.conversion.for("editingDowncast").markerToHighlight({model:Cw,view:{classes:["ck-fake-link-selection"]}}),t.conversion.for("editingDowncast").markerToElement({model:Cw,view:{name:"span",classes:["ck-fake-link-selection","ck-fake-link-selection_collapsed"]}})}destroy(){super.destroy(),this.formView.destroy()}_createActionsView(){const t=this.editor,e=new _w(t.locale),n=t.commands.get("link"),o=t.commands.get("unlink");return e.bind("href").to(n,"value"),e.editButtonView.bind("isEnabled").to(n),e.unlinkButtonView.bind("isEnabled").to(o),this.listenTo(e,"edit",(()=>{this._addFormView()})),this.listenTo(e,"unlink",(()=>{t.execute("unlink"),this._hideUI()})),e.keystrokes.set("Esc",((t,e)=>{this._hideUI(),e()})),e.keystrokes.set(Jk,((t,e)=>{this._addFormView(),e()})),e}_createFormView(){const t=this.editor,e=t.commands.get("link"),n=t.config.get("link.defaultProtocol"),o=new bw(t.locale,e);return o.urlInputView.fieldView.bind("value").to(e,"value"),o.urlInputView.bind("isReadOnly").to(e,"isEnabled",(t=>!t)),o.saveButtonView.bind("isEnabled").to(e),this.listenTo(o,"submit",(()=>{const{value:e}=o.urlInputView.fieldView.element,i=tw(e,n);t.execute("link",i,o.getDecoratorSwitchesState()),this._closeFormView()})),this.listenTo(o,"cancel",(()=>{this._closeFormView()})),o.keystrokes.set("Esc",((t,e)=>{this._closeFormView(),e()})),o}_createToolbarLinkButton(){const t=this.editor,e=t.commands.get("link"),n=t.t;t.keystrokes.set(Jk,((t,n)=>{n(),e.isEnabled&&this._showUI(!0)})),t.ui.componentFactory.add("link",(t=>{const o=new pu(t);return o.isEnabled=!0,o.label=n("Link"),o.icon='',o.keystroke=Jk,o.tooltip=!0,o.isToggleable=!0,o.bind("isEnabled").to(e,"isEnabled"),o.bind("isOn").to(e,"value",(t=>!!t)),this.listenTo(o,"execute",(()=>this._showUI(!0))),o}))}_enableUserBalloonInteractions(){const t=this.editor.editing.view.document;this.listenTo(t,"click",(()=>{this._getSelectedLinkElement()&&this._showUI()})),this.editor.keystrokes.set("Tab",((t,e)=>{this._areActionsVisible&&!this.actionsView.focusTracker.isFocused&&(this.actionsView.focus(),e())}),{priority:"high"}),this.editor.keystrokes.set("Esc",((t,e)=>{this._isUIVisible&&(this._hideUI(),e())})),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 t=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=t.value||""}_closeFormView(){const t=this.editor.commands.get("link");t.restoreManualDecoratorStates(),void 0!==t.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(t=!1){this._getSelectedLinkElement()?(this._areActionsVisible?this._addFormView():this._addActionsView(),t&&this._balloon.showStack("main")):(this._showFakeVisualSelection(),this._addActionsView(),t&&this._balloon.showStack("main"),this._addFormView()),this._startUpdatingUI()}_hideUI(){if(!this._isUIInPanel)return;const t=this.editor;this.stopListening(t.ui,"update"),this.stopListening(this._balloon,"change:visibleView"),t.editing.view.focus(),this._removeFormView(),this._balloon.remove(this.actionsView),this._hideFakeVisualSelection()}_startUpdatingUI(){const t=this.editor,e=t.editing.view.document;let n=this._getSelectedLinkElement(),o=r();const i=()=>{const t=this._getSelectedLinkElement(),e=r();n&&!t||!n&&e!==o?this._hideUI():this._isUIVisible&&this._balloon.updatePosition(this._getBalloonPositionData()),n=t,o=e};function r(){return e.selection.focus.getAncestors().reverse().find((t=>t.is("element")))}this.listenTo(t.ui,"update",i),this.listenTo(this._balloon,"change:visibleView",i)}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 t=this.editor.editing.view,e=this.editor.model,n=t.document;let o=null;if(e.markers.has(Cw)){const e=Array.from(this.editor.editing.mapper.markerNameToElements(Cw)),n=t.createRange(t.createPositionBefore(e[0]),t.createPositionAfter(e[e.length-1]));o=t.domConverter.viewRangeToDom(n)}else o=()=>{const e=this._getSelectedLinkElement();return e?t.domConverter.mapViewToDom(e):t.domConverter.viewRangeToDom(n.selection.getFirstRange())};return{target:o}}_getSelectedLinkElement(){const t=this.editor.editing.view,e=t.document.selection,n=e.getSelectedElement();if(e.isCollapsed||n&&hm(n))return vw(e.getFirstPosition());{const n=e.getFirstRange().getTrimmed(),o=vw(n.start),i=vw(n.end);return o&&o==i&&t.createRangeIn(o).getTrimmed().isEqual(n)?o:null}}_showFakeVisualSelection(){const t=this.editor.model;t.change((e=>{const n=t.document.selection.getFirstRange();if(t.markers.has(Cw))e.updateMarker(Cw,{range:n});else if(n.start.isAtEnd){const o=n.start.getLastMatchingPosition((({item:e})=>!t.schema.isContent(e)),{boundaries:n});e.addMarker(Cw,{usingOperation:!1,affectsData:!1,range:e.createRange(o,n.end)})}else e.addMarker(Cw,{usingOperation:!1,affectsData:!1,range:n})}))}_hideFakeVisualSelection(){const t=this.editor.model;t.markers.has(Cw)&&t.change((t=>{t.removeMarker(Cw)}))}}function vw(t){return t.getAncestors().find((t=>{return(e=t).is("attributeElement")&&!!e.getCustomProperty("link");var e}))}const yw=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 xw extends pe{static get requires(){return[Lm]}static get pluginName(){return"AutoLink"}init(){const t=this.editor.model.document.selection;t.on("change:range",(()=>{this.isEnabled=!t.anchor.parent.is("element","codeBlock")})),this._enableTypingHandling()}afterInit(){this._enableEnterHandling(),this._enableShiftEnterHandling()}_enableTypingHandling(){const t=this.editor,e=new zf(t.model,(t=>{if(!function(t){return t.length>4&&" "===t[t.length-1]&&" "!==t[t.length-2]}(t))return;const e=Ew(t.substr(0,t.length-1));return e?{url:e}:void 0}));e.on("matched:data",((e,n)=>{const{batch:o,range:i,url:r}=n;if(!o.isTyping)return;const s=i.end.getShiftedBy(-1),a=s.getShiftedBy(-r.length),c=t.model.createRange(a,s);this._applyAutoLink(r,c)})),e.bind("isEnabled").to(this)}_enableEnterHandling(){const t=this.editor,e=t.model,n=t.commands.get("enter");n&&n.on("execute",(()=>{const t=e.document.selection.getFirstPosition();if(!t.parent.previousSibling)return;const n=e.createRangeIn(t.parent.previousSibling);this._checkAndApplyAutoLinkOnRange(n)}))}_enableShiftEnterHandling(){const t=this.editor,e=t.model,n=t.commands.get("shiftEnter");n&&n.on("execute",(()=>{const t=e.document.selection.getFirstPosition(),n=e.createRange(e.createPositionAt(t.parent,0),t.getShiftedBy(-1));this._checkAndApplyAutoLinkOnRange(n)}))}_checkAndApplyAutoLinkOnRange(t){const e=this.editor.model,{text:n,range:o}=Rf(t,e),i=Ew(n);if(i){const t=e.createRange(o.end.getShiftedBy(-i.length),o.end);this._applyAutoLink(i,t)}}_applyAutoLink(t,e){const n=this.editor.model,o=this.editor.plugins.get("Delete");this.isEnabled&&function(t,e){return e.schema.checkAttributeInSelection(e.createSelection(t),"linkHref")}(e,n)&&n.enqueueChange((i=>{const r=this.editor.config.get("link.defaultProtocol"),s=tw(t,r);i.setAttribute("linkHref",s,e),n.enqueueChange((()=>{o.requestUndoOnBackspace()}))}))}}function Ew(t){const e=yw.exec(t);return e?e[2]:null}class Dw extends ge{constructor(t,e){super(t),this.type=e}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(t={}){const e=this.editor.model,n=e.document,o=Array.from(n.selection.getSelectedBlocks()).filter((t=>Bw(t,e.schema))),i=void 0!==t.forceValue?!t.forceValue:this.value;e.change((t=>{if(i){let e=o[o.length-1].nextSibling,n=Number.POSITIVE_INFINITY,i=[];for(;e&&"listItem"==e.name&&0!==e.getAttribute("listIndent");){const t=e.getAttribute("listIndent");t=n;)r>i.getAttribute("listIndent")&&(r=i.getAttribute("listIndent")),i.getAttribute("listIndent")==r&&t[e?"unshift":"push"](i),i=i[e?"previousSibling":"nextSibling"]}}function Bw(t,e){return e.checkChild(t.parent,"listItem")&&!e.isObject(t)}class Tw extends ge{constructor(t,e){super(t),this._indentBy="forward"==e?1:-1}refresh(){this.isEnabled=this._checkEnabled()}execute(){const t=this.editor.model,e=t.document;let n=Array.from(e.selection.getSelectedBlocks());t.change((t=>{const e=n[n.length-1];let o=e.nextSibling;for(;o&&"listItem"==o.name&&o.getAttribute("listIndent")>e.getAttribute("listIndent");)n.push(o),o=o.nextSibling;this._indentBy<0&&(n=n.reverse());for(const e of n){const n=e.getAttribute("listIndent")+this._indentBy;n<0?t.rename(e,"paragraph"):t.setAttribute("listIndent",n,e)}this.fire("_executeCleanup",n)}))}_checkEnabled(){const t=Ta(this.editor.model.document.selection.getSelectedBlocks());if(!t||!t.is("element","listItem"))return!1;if(this._indentBy>0){const e=t.getAttribute("listIndent"),n=t.getAttribute("listType");let o=t.previousSibling;for(;o&&o.is("element","listItem")&&o.getAttribute("listIndent")>=e;){if(o.getAttribute("listIndent")==e)return o.getAttribute("listType")==n;o=o.previousSibling}return!1}return!0}}function Pw(t,e){const n=e.mapper,o=e.writer,i="numbered"==t.getAttribute("listType")?"ol":"ul",r=function(t){const e=t.createContainerElement("li");return e.getFillerOffset=Mw,e}(o),s=o.createContainerElement(i,null);return o.insert(o.createPositionAt(s,0),r),n.bindElements(t,r),r}function Iw(t,e,n,o){const i=e.parent,r=n.mapper,s=n.writer;let a=r.toViewPosition(o.createPositionBefore(t));const c=Fw(t.previousSibling,{sameIndent:!0,smallerIndent:!0,listIndent:t.getAttribute("listIndent")}),l=t.previousSibling;if(c&&c.getAttribute("listIndent")==t.getAttribute("listIndent")){const t=r.toViewElement(c);a=s.breakContainer(s.createPositionAfter(t))}else if(l&&"listItem"==l.name){a=r.toViewPosition(o.createPositionAt(l,"end"));const t=r.findMappedViewAncestor(a),e=Ow(t);a=e?s.createPositionBefore(e):s.createPositionAt(t,"end")}else a=r.toViewPosition(o.createPositionBefore(t));if(a=zw(a),s.insert(a,i),l&&"listItem"==l.name){const t=r.toViewElement(l),n=s.createRange(s.createPositionAt(t,0),a).getWalker({ignoreElementEnd:!0});for(const t of n)if(t.item.is("element","li")){const o=s.breakContainer(s.createPositionBefore(t.item)),i=t.item.parent,r=s.createPositionAt(e,"end");Rw(s,r.nodeBefore,r.nodeAfter),s.move(s.createRangeOn(i),r),n.position=o}}else{const n=i.nextSibling;if(n&&(n.is("element","ul")||n.is("element","ol"))){let o=null;for(const e of n.getChildren()){const n=r.toModelElement(e);if(!(n&&n.getAttribute("listIndent")>t.getAttribute("listIndent")))break;o=e}o&&(s.breakContainer(s.createPositionAfter(o)),s.move(s.createRangeOn(o.parent),s.createPositionAt(e,"end")))}}Rw(s,i,i.nextSibling),Rw(s,i.previousSibling,i)}function Rw(t,e,n){return!e||!n||"ul"!=e.name&&"ol"!=e.name||e.name!=n.name||e.getAttribute("class")!==n.getAttribute("class")?null:t.mergeContainers(t.createPositionAfter(e))}function zw(t){return t.getLastMatchingPosition((t=>t.item.is("uiElement")))}function Fw(t,e){const n=!!e.sameIndent,o=!!e.smallerIndent,i=e.listIndent;let r=t;for(;r&&"listItem"==r.name;){const t=r.getAttribute("listIndent");if(n&&i==t||o&&i>t)return r;r="forward"===e.direction?r.nextSibling:r.previousSibling}return null}function Nw(t,e,n,o){t.ui.componentFactory.add(e,(i=>{const r=t.commands.get(e),s=new pu(i);return s.set({label:n,icon:o,tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(r,"value","isEnabled"),s.on("execute",(()=>{t.execute(e),t.editing.view.focus()})),s}))}function Ow(t){for(const e of t.getChildren())if("ul"==e.name||"ol"==e.name)return e;return null}function Mw(){const t=!this.isEmpty&&("ul"==this.getChild(0).name||"ol"==this.getChild(0).name);return this.isEmpty||t?0:zi.call(this)}function Vw(t){return(e,n,o)=>{const i=o.consumable;if(!i.test(n.item,"insert")||!i.test(n.item,"attribute:listType")||!i.test(n.item,"attribute:listIndent"))return;i.consume(n.item,"insert"),i.consume(n.item,"attribute:listType"),i.consume(n.item,"attribute:listIndent");const r=n.item;Iw(r,Pw(r,o),o,t)}}function Lw(t,e,n){if(!n.consumable.consume(e.item,"attribute:listType"))return;const o=n.mapper.toViewElement(e.item),i=n.writer;i.breakContainer(i.createPositionBefore(o)),i.breakContainer(i.createPositionAfter(o));const r=o.parent,s="numbered"==e.attributeNewValue?"ol":"ul";i.rename(s,r)}function Hw(t,e,n){const o=n.mapper.toViewElement(e.item).parent,i=n.writer;Rw(i,o,o.nextSibling),Rw(i,o.previousSibling,o);for(const t of e.item.getChildren())n.consumable.consume(t,"insert")}function qw(t,e,n){if("listItem"!=e.item.name){let t=n.mapper.toViewPosition(e.range.start);const o=n.writer,i=[];for(;("ul"==t.parent.name||"ol"==t.parent.name)&&(t=o.breakContainer(t),"li"==t.parent.name);){const e=t,n=o.createPositionAt(t.parent,"end");if(!e.isEqual(n)){const t=o.remove(o.createRange(e,n));i.push(t)}t=o.createPositionAfter(t.parent)}if(i.length>0){for(let e=0;e0){const e=Rw(o,n,n.nextSibling);e&&e.parent==n&&t.offset--}}Rw(o,t.nodeBefore,t.nodeAfter)}}}function Ww(t,e,n){const o=n.mapper.toViewPosition(e.position),i=o.nodeBefore,r=o.nodeAfter;Rw(n.writer,i,r)}function jw(t,e,n){if(n.consumable.consume(e.viewItem,{name:!0})){const t=n.writer,o=t.createElement("listItem"),i=function(t){let e=0,n=t.parent;for(;n;){if(n.is("element","li"))e++;else{const t=n.previousSibling;t&&t.is("element","li")&&e++}n=n.parent}return e}(e.viewItem);t.setAttribute("listIndent",i,o);const r=e.viewItem.parent&&"ol"==e.viewItem.parent.name?"numbered":"bulleted";if(t.setAttribute("listType",r,o),!n.safeInsert(o,e.modelCursor))return;const s=function(t,e,n){const{writer:o,schema:i}=n;let r=o.createPositionAfter(t);for(const s of e)if("ul"==s.name||"ol"==s.name)r=n.convertItem(s,r).modelCursor;else{const e=n.convertItem(s,o.createPositionAt(t,"end")),a=e.modelRange.start.nodeAfter;a&&a.is("element")&&!i.checkChild(t,a.name)&&(t=e.modelCursor.parent.is("element","listItem")?e.modelCursor.parent:Zw(e.modelCursor),r=o.createPositionAfter(t))}return r}(o,e.viewItem.getChildren(),n);e.modelRange=t.createRange(e.modelCursor,s),n.updateConversionResult(o,e)}}function Uw(t,e,n){if(n.consumable.test(e.viewItem,{name:!0})){const t=Array.from(e.viewItem.getChildren());for(const e of t){!(e.is("element","li")||Yw(e))&&e._remove()}}}function $w(t,e,n){if(n.consumable.test(e.viewItem,{name:!0})){if(0===e.viewItem.childCount)return;const t=[...e.viewItem.getChildren()];let n=!1;for(const e of t)n&&!Yw(e)&&e._remove(),Yw(e)&&(n=!0)}}function Gw(t){return(e,n)=>{if(n.isPhantom)return;const o=n.modelPosition.nodeBefore;if(o&&o.is("element","listItem")){const e=n.mapper.toViewElement(o),i=e.getAncestors().find(Yw),r=t.createPositionAt(e,0).getWalker();for(const t of r){if("elementStart"==t.type&&t.item.is("element","li")){n.viewPosition=t.previousPosition;break}if("elementEnd"==t.type&&t.item==i){n.viewPosition=t.nextPosition;break}}}}}function Kw(t,[e,n]){let o,i=e.is("documentFragment")?e.getChild(0):e;if(o=n?this.createSelection(n):this.document.selection,i&&i.is("element","listItem")){const t=o.getFirstPosition();let e=null;if(t.parent.is("element","listItem")?e=t.parent:t.nodeBefore&&t.nodeBefore.is("element","listItem")&&(e=t.nodeBefore),e){const t=e.getAttribute("listIndent");if(t>0)for(;i&&i.is("element","listItem");)i._setAttribute("listIndent",i.getAttribute("listIndent")+t),i=i.nextSibling}}}function Zw(t){const e=new Ja({startPosition:t});let n;do{n=e.next()}while(!n.value.item.is("element","listItem"));return n.value.item}function Jw(t,e,n,o,i,r){const s=Fw(e.nodeBefore,{sameIndent:!0,smallerIndent:!0,listIndent:t,foo:"b"}),a=i.mapper,c=i.writer,l=s?s.getAttribute("listIndent"):null;let d;if(s)if(l==t){const t=a.toViewElement(s).parent;d=c.createPositionAfter(t)}else{const t=r.createPositionAt(s,"end");d=a.toViewPosition(t)}else d=n;d=zw(d);for(const t of[...o.getChildren()])Yw(t)&&(d=c.move(c.createRangeOn(t),d).end,Rw(c,t,t.nextSibling),Rw(c,t.previousSibling,t))}function Yw(t){return t.is("element","ol")||t.is("element","ul")}class Qw extends pe{static get pluginName(){return"ListEditing"}static get requires(){return[Rm,Lm]}init(){const t=this.editor;t.model.schema.register("listItem",{inheritAllFrom:"$block",allowAttributes:["listType","listIndent"]});const e=t.data,n=t.editing;var o;t.model.document.registerPostFixer((e=>function(t,e){const n=t.document.differ.getChanges(),o=new Map;let i=!1;for(const o of n)if("insert"==o.type&&"listItem"==o.name)r(o.position);else if("insert"==o.type&&"listItem"!=o.name){if("$text"!=o.name){const n=o.position.nodeAfter;n.hasAttribute("listIndent")&&(e.removeAttribute("listIndent",n),i=!0),n.hasAttribute("listType")&&(e.removeAttribute("listType",n),i=!0),n.hasAttribute("listStyle")&&(e.removeAttribute("listStyle",n),i=!0),n.hasAttribute("listReversed")&&(e.removeAttribute("listReversed",n),i=!0),n.hasAttribute("listStart")&&(e.removeAttribute("listStart",n),i=!0);for(const e of Array.from(t.createRangeIn(n)).filter((t=>t.item.is("element","listItem"))))r(e.previousPosition)}r(o.position.getShiftedBy(o.length))}else"remove"==o.type&&"listItem"==o.name?r(o.position):("attribute"==o.type&&"listIndent"==o.attributeKey||"attribute"==o.type&&"listType"==o.attributeKey)&&r(o.range.start);for(const t of o.values())s(t),a(t);return i;function r(t){const e=t.nodeBefore;if(e&&e.is("element","listItem")){let t=e;if(o.has(t))return;for(let e=t.previousSibling;e&&e.is("element","listItem");e=t.previousSibling)if(t=e,o.has(t))return;o.set(e,t)}else{const e=t.nodeAfter;e&&e.is("element","listItem")&&o.set(e,e)}}function s(t){let n=0,o=null;for(;t&&t.is("element","listItem");){const r=t.getAttribute("listIndent");if(r>n){let s;null===o?(o=r-n,s=n):(o>r&&(o=r),s=r-o),e.setAttribute("listIndent",s,t),i=!0}else o=null,n=t.getAttribute("listIndent")+1;t=t.nextSibling}}function a(t){let n=[],o=null;for(;t&&t.is("element","listItem");){const r=t.getAttribute("listIndent");if(o&&o.getAttribute("listIndent")>r&&(n=n.slice(0,r+1)),0!=r)if(n[r]){const o=n[r];t.getAttribute("listType")!=o&&(e.setAttribute("listType",o,t),i=!0)}else n[r]=t.getAttribute("listType");o=t,t=t.nextSibling}}}(t.model,e))),n.mapper.registerViewToModelLength("li",Xw),e.mapper.registerViewToModelLength("li",Xw),n.mapper.on("modelToViewPosition",Gw(n.view)),n.mapper.on("viewToModelPosition",(o=t.model,(t,e)=>{const n=e.viewPosition,i=n.parent,r=e.mapper;if("ul"==i.name||"ol"==i.name){if(n.isAtEnd){const t=r.toModelElement(n.nodeBefore),i=r.getModelLength(n.nodeBefore);e.modelPosition=o.createPositionBefore(t).getShiftedBy(i)}else{const t=r.toModelElement(n.nodeAfter);e.modelPosition=o.createPositionBefore(t)}t.stop()}else if("li"==i.name&&n.nodeBefore&&("ul"==n.nodeBefore.name||"ol"==n.nodeBefore.name)){const s=r.toModelElement(i);let a=1,c=n.nodeBefore;for(;c&&Yw(c);)a+=r.getModelLength(c),c=c.previousSibling;e.modelPosition=o.createPositionBefore(s).getShiftedBy(a),t.stop()}})),e.mapper.on("modelToViewPosition",Gw(n.view)),t.conversion.for("editingDowncast").add((e=>{e.on("insert",qw,{priority:"high"}),e.on("insert:listItem",Vw(t.model)),e.on("attribute:listType:listItem",Lw,{priority:"high"}),e.on("attribute:listType:listItem",Hw,{priority:"low"}),e.on("attribute:listIndent:listItem",function(t){return(e,n,o)=>{if(!o.consumable.consume(n.item,"attribute:listIndent"))return;const i=o.mapper.toViewElement(n.item),r=o.writer;r.breakContainer(r.createPositionBefore(i)),r.breakContainer(r.createPositionAfter(i));const s=i.parent,a=s.previousSibling,c=r.createRangeOn(s);r.remove(c),a&&a.nextSibling&&Rw(r,a,a.nextSibling),Jw(n.attributeOldValue+1,n.range.start,c.start,i,o,t),Iw(n.item,i,o,t);for(const t of n.item.getChildren())o.consumable.consume(t,"insert")}}(t.model)),e.on("remove:listItem",function(t){return(e,n,o)=>{const i=o.mapper.toViewPosition(n.position).getLastMatchingPosition((t=>!t.item.is("element","li"))).nodeAfter,r=o.writer;r.breakContainer(r.createPositionBefore(i)),r.breakContainer(r.createPositionAfter(i));const s=i.parent,a=s.previousSibling,c=r.createRangeOn(s),l=r.remove(c);a&&a.nextSibling&&Rw(r,a,a.nextSibling),Jw(o.mapper.toModelElement(i).getAttribute("listIndent")+1,n.position,c.start,i,o,t);for(const t of r.createRangeIn(l).getItems())o.mapper.unbindViewElement(t);e.stop()}}(t.model)),e.on("remove",Ww,{priority:"low"})})),t.conversion.for("dataDowncast").add((e=>{e.on("insert",qw,{priority:"high"}),e.on("insert:listItem",Vw(t.model))})),t.conversion.for("upcast").add((t=>{t.on("element:ul",Uw,{priority:"high"}),t.on("element:ol",Uw,{priority:"high"}),t.on("element:li",$w,{priority:"high"}),t.on("element:li",jw)})),t.model.on("insertContent",Kw,{priority:"high"}),t.commands.add("numberedList",new Dw(t,"numbered")),t.commands.add("bulletedList",new Dw(t,"bulleted")),t.commands.add("indentList",new Tw(t,"forward")),t.commands.add("outdentList",new Tw(t,"backward"));const i=n.view.document;this.listenTo(i,"enter",((t,e)=>{const n=this.editor.model.document,o=n.selection.getLastPosition().parent;n.selection.isCollapsed&&"listItem"==o.name&&o.isEmpty&&(this.editor.execute("outdentList"),e.preventDefault(),t.stop())}),{context:"li"}),this.listenTo(i,"delete",((t,e)=>{if("backward"!==e.direction)return;const n=this.editor.model.document.selection;if(!n.isCollapsed)return;const o=n.getFirstPosition();if(!o.isAtStart)return;const i=o.parent;if("listItem"!==i.name)return;i.previousSibling&&"listItem"===i.previousSibling.name||(this.editor.execute("outdentList"),e.preventDefault(),t.stop())}),{context:"li"});const r=t=>(e,n)=>{this.editor.commands.get(t).isEnabled&&(this.editor.execute(t),n())};t.keystrokes.set("Tab",r("indentList")),t.keystrokes.set("Shift+Tab",r("outdentList"))}afterInit(){const t=this.editor.commands,e=t.get("indent"),n=t.get("outdent");e&&e.registerChildCommand(t.get("indentList")),n&&n.registerChildCommand(t.get("outdentList"))}}function Xw(t){let e=1;for(const n of t.getChildren())if("ul"==n.name||"ol"==n.name)for(const t of n.getChildren())e+=Xw(t);return e}class t_ extends pe{static get pluginName(){return"ListUI"}init(){const t=this.editor.t;Nw(this.editor,"numberedList",t("Numbered List"),''),Nw(this.editor,"bulletedList",t("Bulleted List"),'')}}const e_=Symbol("isOPCodeBlock");function n_(t){return!!t.getCustomProperty(e_)&&hm(t)}function o_(t){const e=t.getSelectedElement();return!(!e||!n_(e))}function i_(t,e,n){const o=e.createContainerElement("pre",{title:window.I18n.t("js.editor.macro.toolbar_help")});return r_(e,t,o),function(t,e,n){return e.setCustomProperty(e_,!0,t),pm(t,e,{label:n})}(o,e,n)}function r_(t,e,n){const o=(e.getAttribute("opCodeblockLanguage")||"language-text").replace(/^language-/,""),i=t.createContainerElement("div",{class:"op-uc-code-block--language"});s_(t,o,i,"text"),t.insert(t.createPositionAt(n,0),i);s_(t,e.getAttribute("opCodeblockContent"),n,"(empty)")}function s_(t,e,n,o){const i=t.createText(e||o);t.insert(t.createPositionAt(n,0),i)}class a_ extends Xs{constructor(t){super(t),this.domEventType="dblclick"}onDomEvent(t){this.fire(t.type,t)}}class c_ extends pe{static get pluginName(){return"CodeBlockEditing"}init(){const t=this.editor,e=t.model.schema,n=t.conversion,o=t.editing.view,i=o.document,r=xm(t);e.register("codeblock",{isObject:!0,isBlock:!0,allowContentOf:"$block",allowWhere:["$root","$block"],allowIn:["$root"],allowAttributes:["opCodeblockLanguage","opCodeblockContent"]}),n.for("upcast").add(function(){return e=>{e.on("element:pre",t,{priority:"high"})};function t(t,e,n){if(!n.consumable.test(e.viewItem,{name:!0}))return;const o=Array.from(e.viewItem.getChildren()).find((t=>t.is("element","code")));if(!o||!n.consumable.consume(o,{name:!0}))return;const i=n.writer.createElement("codeblock");n.writer.setAttribute("opCodeblockLanguage",o.getAttribute("class"),i);const r=n.splitToAllowedParent(i,e.modelCursor);if(r){n.writer.insert(i,r.position);const t=o.getChild(0);n.consumable.consume(t,{name:!0});const s=t.data.replace(/\n$/,"");n.writer.setAttribute("opCodeblockContent",s,i),e.modelRange=new nc(n.writer.createPositionBefore(i),n.writer.createPositionAfter(i)),e.modelCursor=e.modelRange.end}}}()),n.for("editingDowncast").elementToElement({model:"codeblock",view:(t,{writer:e})=>i_(t,e,"Code block")}).add(function(){return e=>{e.on("attribute:opCodeblockContent",t),e.on("attribute:opCodeblockLanguage",t)};function t(t,e,n){const o=e.item;n.consumable.consume(e.item,t.name);const i=n.mapper.toViewElement(o);n.writer.remove(n.writer.createRangeOn(i.getChild(1))),n.writer.remove(n.writer.createRangeOn(i.getChild(0))),r_(n.writer,o,i)}}()),n.for("dataDowncast").add(function(){return e=>{e.on("insert:codeblock",t,{priority:"high"})};function t(t,e,n){const o=e.item,i=o.getAttribute("opCodeblockLanguage")||"language-text",r=o.getAttribute("opCodeblockContent");n.consumable.consume(o,"insert");const s=n.writer,a=s.createContainerElement("pre"),c=s.createContainerElement("div",{class:"op-uc-code-block--language"}),l=s.createContainerElement("code",{class:i}),d=s.createText(i),u=s.createText(r);s.insert(s.createPositionAt(l,0),u),s.insert(s.createPositionAt(c,0),d),s.insert(s.createPositionAt(a,0),c),s.insert(s.createPositionAt(a,0),l),n.mapper.bindElements(o,l),n.mapper.bindElements(o,a);const h=n.mapper.toViewPosition(e.range.start);s.insert(h,a),t.stop()}}()),o.addObserver(a_),this.listenTo(i,"dblclick",((e,n)=>{let o=n.target,i=n.domEvent;if(i.shiftKey||i.altKey||i.metaKey)return;if(!n_(o)&&(o=o.findAncestor(n_),!o))return;n.preventDefault(),n.stopPropagation();const s=t.editing.mapper.toModelElement(o),a=r.services.macros,c=s.getAttribute("opCodeblockLanguage"),l=s.getAttribute("opCodeblockContent");a.editCodeBlock(l,c).then((e=>t.model.change((t=>{t.setAttribute("opCodeblockLanguage",e.languageClass,s),t.setAttribute("opCodeblockContent",e.content,s)}))))})),t.ui.componentFactory.add("insertCodeBlock",(e=>{const n=new pu(e);return n.set({label:window.I18n.t("js.editor.macro.code_block.button"),icon:'\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n image/svg+xml\n \n \n \n \n\n',tooltip:!0}),n.on("execute",(()=>{r.services.macros.editCodeBlock().then((e=>t.model.change((n=>{const o=n.createElement("codeblock");n.setAttribute("opCodeblockLanguage",e.languageClass,o),n.setAttribute("opCodeblockContent",e.content,o),t.model.insertContent(o,t.model.document.selection)}))))})),n}))}}class l_ extends pe{static get requires(){return[Vh]}static get pluginName(){return"CodeBlockToolbar"}init(){const t=this.editor,e=this.editor.model,n=xm(t);ng(t,"opEditCodeBlock",(t=>{const o=n.services.macros,i=t.getAttribute("opCodeblockLanguage"),r=t.getAttribute("opCodeblockContent");o.editCodeBlock(r,i).then((n=>e.change((e=>{e.setAttribute("opCodeblockLanguage",n.languageClass,t),e.setAttribute("opCodeblockContent",n.content,t)}))))}))}afterInit(){ig(this,this.editor,"OPCodeBlock",o_)}}function d_(t){return t.__currentlyDisabled=t.__currentlyDisabled||[],t.ui.view.toolbar?t.ui.view.toolbar.items._items:[]}function u_(t,e){jQuery.each(d_(t),(function(n,o){let i=o;o instanceof gg?i=o.buttonView:o!==e&&o.hasOwnProperty("isEnabled")||(i=null),i&&(i.isEnabled?i.isEnabled=!1:t.__currentlyDisabled.push(i))}))}function h_(t){jQuery.each(d_(t),(function(e,n){let o=n;n instanceof gg&&(o=n.buttonView),t.__currentlyDisabled.indexOf(o)<0&&(o.isEnabled=!0)})),t.__currentlyDisabled=[]}function p_(t,e,n,o,i=1){e>i?o.setAttribute(t,e,n):o.removeAttribute(t,n)}function m_(t,e,n={}){const o=t.createElement("tableCell",n);return t.insertElement("paragraph",o),t.insert(o,e),o}function g_(t,e){const n=e.parent.parent,o=parseInt(n.getAttribute("headingColumns")||0),{column:i}=t.getCellLocation(e);return!!o&&i{t.on("element:table",((t,e,n)=>{const o=e.viewItem;if(!n.consumable.test(o,{name:!0}))return;const{rows:i,headingRows:r,headingColumns:s}=function(t){const e={headingRows:0,headingColumns:0},n=[],o=[];let i;for(const r of Array.from(t.getChildren()))if("tbody"===r.name||"thead"===r.name||"tfoot"===r.name){"thead"!==r.name||i||(i=r);const t=Array.from(r.getChildren()).filter((t=>t.is("element","tr")));for(const r of t)if("thead"===r.parent.name&&r.parent===i)e.headingRows++,n.push(r);else{o.push(r);const t=k_(r);t>e.headingColumns&&(e.headingColumns=t)}}return e.rows=[...n,...o],e}(o),a={};s&&(a.headingColumns=s),r&&(a.headingRows=r);const c=n.writer.createElement("table",a);if(n.safeInsert(c,e.modelCursor)){if(n.consumable.consume(o,{name:!0}),i.forEach((t=>n.convertItem(t,n.writer.createPositionAt(c,"end")))),n.convertChildren(o,n.writer.createPositionAt(c,"end")),c.isEmpty){const t=n.writer.createElement("tableRow");n.writer.insert(t,n.writer.createPositionAt(c,"end")),m_(n.writer,n.writer.createPositionAt(t,"end"))}n.updateConversionResult(c,e)}}))}}function b_(t){return e=>{e.on(`element:${t}`,((t,e,n)=>{if(e.modelRange&&e.viewItem.isEmpty){const t=e.modelRange.start.nodeAfter,o=n.writer.createPositionAt(t,0);n.writer.insertElement("paragraph",o)}}),{priority:"low"})}}function k_(t){let e=0,n=0;const o=Array.from(t.getChildren()).filter((t=>"th"===t.name||"td"===t.name));for(;n1||i>1)&&this._recordSpans(n,i,o),this._shouldSkipSlot()||(e=this._formatOutValue(n)),this._nextCellAtColumn=this._column+o}return this._column++,this._column==this._nextCellAtColumn&&this._cellIndex++,e||this.next()}skipRow(t){this._skipRows.add(t)}_advanceToNextRow(){return this._row++,this._rowIndex++,this._column=0,this._cellIndex=0,this._nextCellAtColumn=-1,this.next()}_isOverEndRow(){return void 0!==this._endRow&&this._row>this._endRow}_isOverEndColumn(){return void 0!==this._endColumn&&this._column>this._endColumn}_formatOutValue(t,e=this._row,n=this._column){return{done:!1,value:new __(this,t,e,n)}}_shouldSkipSlot(){const t=this._skipRows.has(this._row),e=this._rowthis._endColumn;return t||e||n||o}_getSpanned(){const t=this._spannedCells.get(this._row);return t&&t.get(this._column)||null}_recordSpans(t,e,n){const o={cell:t,row:this._row,column:this._column};for(let t=this._row;te.on("insert:table",((e,n,o)=>{const i=n.item;if(!o.consumable.consume(i,"insert"))return;o.consumable.consume(i,"attribute:headingRows:table"),o.consumable.consume(i,"attribute:headingColumns:table");const r=t&&t.asWidget,s=o.writer.createContainerElement("figure",{class:"table"}),a=o.writer.createContainerElement("table");let c;var l,d;o.writer.insert(o.writer.createPositionAt(s,0),a),r&&(l=s,(d=o.writer).setCustomProperty("table",!0,l),c=pm(l,d,{hasSelectionHandle:!0}));const u=new w_(i),h={headingRows:i.getAttribute("headingRows")||0,headingColumns:i.getAttribute("headingColumns")||0},p=new Map;for(const e of u){const{row:n,cell:r}=e,s=i.getChild(n),c=p.get(n)||E_(a,s,n,h,o);p.set(n,c),o.consumable.consume(r,"insert");x_(e,h,o.writer.createPositionAt(c,"end"),o,t)}for(const t of i.getChildren()){const e=t.index;t.is("element","tableRow")&&!p.has(e)&&p.set(e,E_(a,t,e,h,o))}const m=o.mapper.toViewPosition(n.range.start);o.mapper.bindElements(i,r?c:s),o.writer.insert(m,r?c:s)}))}function A_(t,e){const{writer:n}=e;if(t.parent.is("element","tableCell"))return v_(t)?n.createContainerElement("span",{class:"ck-table-bogus-paragraph"}):n.createContainerElement("p")}function v_(t){return 1===t.parent.childCount&&!T_(t)}function y_(t,e,n){const{cell:o}=t,i=D_(t,e),r=n.mapper.toViewElement(o);r&&r.name!==i&&function(t,e,n){const o=n.writer,i=n.mapper.toViewElement(t),r=km(o.createEditableElement(e,i.getAttributes()),o);o.insert(o.createPositionAfter(i),r),o.move(o.createRangeIn(i),o.createPositionAt(r,0)),o.remove(o.createRangeOn(i)),n.mapper.unbindViewElement(i),n.mapper.bindElements(t,r)}(o,i,n)}function x_(t,e,n,o,i){const r=i&&i.asWidget,s=D_(t,e),a=r?km(o.writer.createEditableElement(s),o.writer):o.writer.createContainerElement(s),c=t.cell,l=c.getChild(0),d=1===c.childCount&&"paragraph"===l.name;if(o.writer.insert(n,a),o.mapper.bindElements(c,a),!r&&d&&!T_(l)){const t=c.getChild(0);o.consumable.consume(t,"insert"),o.mapper.bindElements(t,a)}}function E_(t,e,n,o,i){i.consumable.consume(e,"insert");const r=e.isEmpty?i.writer.createEmptyElement("tr"):i.writer.createContainerElement("tr");i.mapper.bindElements(e,r);const s=o.headingRows,a=function(t,e,n){const o=S_(t,e);return o||function(t,e,n){const o=n.writer.createContainerElement(t),i=n.writer.createPositionAt(e,"tbody"==t?"end":0);return n.writer.insert(i,o),o}(t,e,n)}(function(t,e){return t0&&n>=s?n-s:n,l=i.writer.createPositionAt(a,c);return i.writer.insert(l,r),r}function D_(t,e){const{row:n,column:o}=t,{headingColumns:i,headingRows:r}=e;if(r&&r>n)return"th";return i&&i>o?"th":"td"}function S_(t,e){for(const n of e.getChildren())if(n.name==t)return n}function B_(t,e,n){const o=S_(t,e);o&&0===o.childCount&&n.writer.remove(n.writer.createRangeOn(o))}function T_(t){return!![...t.getAttributeKeys()].length}class P_ extends ge{refresh(){const t=this.editor.model,e=t.document.selection,n=t.schema;this.isEnabled=function(t,e){const n=t.getFirstPosition().parent,o=n===n.root?n:n.parent;return e.checkChild(o,"table")}(e,n)}execute(t={}){const e=this.editor.model,n=e.document.selection,o=this.editor.plugins.get("TableUtils"),i=this.editor.config.get("table"),r=wm(n,e),s=i.defaultHeadings.rows,a=i.defaultHeadings.columns;void 0===t.headingRows&&s&&(t.headingRows=s),void 0===t.headingColumns&&a&&(t.headingColumns=a),e.change((n=>{const i=o.createTable(n,t);e.insertContent(i,r),n.setSelection(n.createPositionAt(i.getNodeByPath([0,0,0]),0))}))}}function I_(t){const e=[];for(const n of M_(t.getRanges())){const t=n.getContainedElement();t&&t.is("element","tableCell")&&e.push(t)}return e}function R_(t){const e=[];for(const n of t.getRanges()){const t=n.start.findAncestor("tableCell");t&&e.push(t)}return e}function z_(t){const e=I_(t);return e.length?e:R_(t)}function F_(t){const e=t.map((t=>t.parent.index));return V_(e)}function N_(t){const e=t[0].findAncestor("table");return V_([...new w_(e)].filter((e=>t.includes(e.cell))).map((t=>t.column)))}function O_(t,e){if(t.length<2||!function(t){const e=t[0].findAncestor("table"),n=F_(t),o=parseInt(e.getAttribute("headingRows")||0);if(!H_(n,o))return!1;const i=parseInt(e.getAttribute("headingColumns")||0);return H_(N_(t),i)}(t))return!1;const n=new Set,o=new Set;let i=0;for(const r of t){const{row:t,column:s}=e.getCellLocation(r),a=parseInt(r.getAttribute("rowspan")||1),c=parseInt(r.getAttribute("colspan")||1);n.add(t),o.add(s),a>1&&n.add(t+a-1),c>1&&o.add(s+c-1),i+=a*c}const r=function(t,e){const n=Array.from(t.values()),o=Array.from(e.values()),i=Math.max(...n),r=Math.min(...n),s=Math.max(...o),a=Math.min(...o);return(i-r+1)*(s-a+1)}(n,o);return r==i}function M_(t){return Array.from(t).sort(L_)}function V_(t){const e=t.sort(((t,e)=>t-e));return{first:e[0],last:e[e.length-1]}}function L_(t,e){const n=t.start,o=e.start;return n.isBefore(o)?-1:1}function H_({first:t,last:e},n){return t0){p_("headingRows",r-n,t,i,0)}const s=parseInt(e.getAttribute("headingColumns")||0);if(s>0){p_("headingColumns",s-o,t,i,0)}}(a,t,o,i,n),a}function $_(t,e,n=0){const o=[],i=new w_(t,{startRow:n,endRow:e-1});for(const t of i){const{row:n,cellHeight:i}=t,r=n+i-1;n1&&(a.rowspan=c);const l=parseInt(t.getAttribute("colspan")||1);l>1&&(a.colspan=l);const d=r+s,u=[...new w_(i,{startRow:r,endRow:d,includeAllSlots:!0})];let h,p=null;for(const e of u){const{row:o,column:i,cell:r}=e;r===t&&void 0===h&&(h=i),void 0!==h&&h===i&&o===d&&(p=m_(n,e.getPositionBefore(),a))}return p_("rowspan",s,t,n),p}function K_(t,e){const n=[],o=new w_(t);for(const t of o){const{column:o,cellWidth:i}=t,r=o+i-1;o1&&(r.colspan=s);const a=parseInt(t.getAttribute("rowspan")||1);a>1&&(r.rowspan=a);const c=m_(o,o.createPositionAfter(t),r);return p_("colspan",i,t,o),c}function J_(t,e,n,o,i,r){const s=parseInt(t.getAttribute("colspan")||1),a=parseInt(t.getAttribute("rowspan")||1);if(n+s-1>i){p_("colspan",i-n+1,t,r,1)}if(e+a-1>o){p_("rowspan",o-e+1,t,r,1)}}function Y_(t,e){const n=e.getColumns(t),o=new Array(n).fill(0);for(const{column:e}of new w_(t))o[e]++;const i=o.reduce(((t,e,n)=>e?t:[...t,n]),[]);if(i.length>0){const n=i[i.length-1];return e.removeColumns(t,{at:n}),!0}return!1}function Q_(t,e){const n=[],o=e.getRows(t);for(let e=0;e0){const o=n[n.length-1];return e.removeRows(t,{at:o}),!0}return!1}function X_(t,e){Y_(t,e)||Q_(t,e)}function tC(t,e){const n=Array.from(new w_(t,{startColumn:e.firstColumn,endColumn:e.lastColumn,row:e.lastRow}));if(n.every((({cellHeight:t})=>1===t)))return e.lastRow;const o=n[0].cellHeight-1;return e.lastRow+o}function eC(t,e){const n=Array.from(new w_(t,{startRow:e.firstRow,endRow:e.lastRow,column:e.lastColumn}));if(n.every((({cellWidth:t})=>1===t)))return e.lastColumn;const o=n[0].cellWidth-1;return e.lastColumn+o}class nC extends ge{constructor(t,e){super(t),this.direction=e.direction,this.isHorizontal="right"==this.direction||"left"==this.direction}refresh(){const t=this._getMergeableCell();this.value=t,this.isEnabled=!!t}execute(){const t=this.editor.model,e=R_(t.document.selection)[0],n=this.value,o=this.direction;t.change((t=>{const i="right"==o||"down"==o,r=i?e:n,s=i?n:e,a=s.parent;!function(t,e,n){oC(t)||(oC(e)&&n.remove(n.createRangeIn(e)),n.move(n.createRangeIn(t),n.createPositionAt(e,"end")));n.remove(t)}(s,r,t);const c=this.isHorizontal?"colspan":"rowspan",l=parseInt(e.getAttribute(c)||1),d=parseInt(n.getAttribute(c)||1);t.setAttribute(c,l+d,r),t.setSelection(t.createRangeIn(r));const u=this.editor.plugins.get("TableUtils");X_(a.findAncestor("table"),u)}))}_getMergeableCell(){const t=R_(this.editor.model.document.selection)[0];if(!t)return;const e=this.editor.plugins.get("TableUtils"),n=this.isHorizontal?function(t,e,n){const o=t.parent.parent,i="right"==e?t.nextSibling:t.previousSibling,r=(o.getAttribute("headingColumns")||0)>0;if(!i)return;const s="right"==e?t:i,a="right"==e?i:t,{column:c}=n.getCellLocation(s),{column:l}=n.getCellLocation(a),d=parseInt(s.getAttribute("colspan")||1),u=g_(n,s),h=g_(n,a);if(r&&u!=h)return;return c+d===l?i:void 0}(t,this.direction,e):function(t,e,n){const o=t.parent,i=o.parent,r=i.getChildIndex(o);if("down"==e&&r===n.getRows(i)-1||"up"==e&&0===r)return;const s=parseInt(t.getAttribute("rowspan")||1),a=i.getAttribute("headingRows")||0,c="down"==e&&r+s===a,l="up"==e&&r===a;if(a&&(c||l))return;const d=parseInt(t.getAttribute("rowspan")||1),u="down"==e?r+d:r,h=[...new w_(i,{endRow:u})],p=h.find((e=>e.cell===t)).column,m=h.find((({row:t,cellHeight:n,column:o})=>o===p&&("down"==e?t===u:u===t+n)));return m&&m.cell}(t,this.direction,e);if(!n)return;const o=this.isHorizontal?"rowspan":"colspan",i=parseInt(t.getAttribute(o)||1);return parseInt(n.getAttribute(o)||1)===i?n:void 0}}function oC(t){return 1==t.childCount&&t.getChild(0).is("element","paragraph")&&t.getChild(0).isEmpty}class iC extends ge{refresh(){const t=z_(this.editor.model.document.selection),e=t[0];if(e){const n=e.findAncestor("table"),o=this.editor.plugins.get("TableUtils").getRows(n)-1,i=F_(t),r=0===i.first&&i.last===o;this.isEnabled=!r}else this.isEnabled=!1}execute(){const t=this.editor.model,e=this.editor.plugins.get("TableUtils"),n=z_(t.document.selection),o=F_(n),i=n[0],r=i.findAncestor("table"),s=e.getCellLocation(i).column;t.change((t=>{const n=o.last-o.first+1;e.removeRows(r,{at:o.first,rows:n});const i=function(t,e,n,o){const i=t.getChild(Math.min(e,o-1));let r=i.getChild(0),s=0;for(const t of i.getChildren()){if(s>n)return r;r=t,s+=parseInt(t.getAttribute("colspan")||1)}return r}(r,o.first,s,e.getRows(r));t.setSelection(t.createPositionAt(i,0))}))}}class rC extends ge{refresh(){const t=z_(this.editor.model.document.selection),e=t[0];if(e){const n=e.findAncestor("table"),o=this.editor.plugins.get("TableUtils").getColumns(n),{first:i,last:r}=N_(t);this.isEnabled=r-ie.cell===t)).column,last:o.find((t=>t.cell===e)).column},r=function(t,e,n,o){return parseInt(n.getAttribute("colspan")||1)>1?n:e.previousSibling||n.nextSibling?n.nextSibling||e.previousSibling:o.first?t.reverse().find((({column:t})=>tt>o.last)).cell}(o,t,e,i);this.editor.model.change((t=>{const e=i.last-i.first+1;this.editor.plugins.get("TableUtils").removeColumns(n,{at:i.first,columns:e}),t.setSelection(t.createPositionAt(r,0))}))}}class sC extends ge{refresh(){const t=z_(this.editor.model.document.selection),e=t.length>0;this.isEnabled=e,this.value=e&&t.every((t=>this._isInHeading(t,t.parent.parent)))}execute(t={}){if(t.forceValue===this.value)return;const e=this.editor.model,n=z_(e.document.selection),o=n[0].findAncestor("table"),{first:i,last:r}=F_(n),s=this.value?i:r+1,a=o.getAttribute("headingRows")||0;e.change((t=>{if(s){const e=$_(o,s,s>a?a:0);for(const{cell:n}of e)G_(n,s,t)}p_("headingRows",s,o,t,0)}))}_isInHeading(t,e){const n=parseInt(e.getAttribute("headingRows")||0);return!!n&&t.parent.index0;this.isEnabled=n,this.value=n&&t.every((t=>g_(e,t)))}execute(t={}){if(t.forceValue===this.value)return;const e=this.editor.model,n=z_(e.document.selection),o=n[0].findAncestor("table"),{first:i,last:r}=N_(n),s=this.value?i:r+1;e.change((t=>{if(s){const e=K_(o,s);for(const{cell:n,column:o}of e)Z_(n,o,s,t)}p_("headingColumns",s,o,t,0)}))}}class cC extends pe{static get pluginName(){return"TableUtils"}init(){this.decorate("insertColumns"),this.decorate("insertRows")}getCellLocation(t){const e=t.parent,n=e.parent,o=n.getChildIndex(e),i=new w_(n,{row:o});for(const{cell:e,row:n,column:o}of i)if(e===t)return{row:n,column:o}}createTable(t,e){const n=t.createElement("table"),o=parseInt(e.rows)||2,i=parseInt(e.columns)||2;return lC(t,n,0,o,i),e.headingRows&&p_("headingRows",Math.min(e.headingRows,o),n,t,0),e.headingColumns&&p_("headingColumns",Math.min(e.headingColumns,i),n,t,0),n}insertRows(t,e={}){const n=this.editor.model,o=e.at||0,i=e.rows||1,r=void 0!==e.copyStructureFromAbove,a=e.copyStructureFromAbove?o-1:o,c=this.getRows(t),l=this.getColumns(t);if(o>c)throw new s("tableutils-insertrows-insert-out-of-range",this,{options:e});n.change((e=>{const n=t.getAttribute("headingRows")||0;if(n>o&&p_("headingRows",n+i,t,e,0),!r&&(0===o||o===c))return void lC(e,t,o,i,l);const s=r?Math.max(o,a):o,d=new w_(t,{endRow:s}),u=new Array(l).fill(1);for(const{row:t,column:n,cellHeight:s,cellWidth:c,cell:l}of d){const d=t+s-1,h=t<=a&&a<=d;t0&&m_(e,i,o>1?{colspan:o}:null),t+=Math.abs(o)-1}}}))}insertColumns(t,e={}){const n=this.editor.model,o=e.at||0,i=e.columns||1;n.change((e=>{const n=t.getAttribute("headingColumns");oi-1)throw new s("tableutils-removerows-row-index-out-of-range",this,{table:t,options:e});n.change((e=>{const{cellsToMove:n,cellsToTrim:o}=function(t,e,n){const o=new Map,i=[];for(const{row:r,column:s,cellHeight:a,cell:c}of new w_(t,{endRow:n})){const t=r+a-1;if(r>=e&&r<=n&&t>n){const t=a-(n-r+1);o.set(s,{cell:c,rowspan:t})}if(r=e){let o;o=t>=n?n-e+1:t-e+1,i.push({cell:c,rowspan:a-o})}}return{cellsToMove:o,cellsToTrim:i}}(t,r,a);if(n.size){!function(t,e,n,o){const i=[...new w_(t,{includeAllSlots:!0,row:e})],r=t.getChild(e);let s;for(const{column:t,cell:e,isAnchor:a}of i)if(n.has(t)){const{cell:e,rowspan:i}=n.get(t),a=s?o.createPositionAfter(s):o.createPositionAt(r,0);o.move(o.createRangeOn(e),a),p_("rowspan",i,e,o),s=e}else a&&(s=e)}(t,a+1,n,e)}for(let n=a;n>=r;n--)e.remove(t.getChild(n));for(const{rowspan:t,cell:n}of o)p_("rowspan",t,n,e);!function(t,e,n,o){const i=t.getAttribute("headingRows")||0;if(e{!function(t,e,n){const o=t.getAttribute("headingColumns")||0;if(o&&e.first=o;n--)for(const{cell:o,column:i,cellWidth:r}of[...new w_(t)])i<=n&&r>1&&i+r>n?p_("colspan",r-1,o,e):i===n&&e.remove(o);Q_(t,this)||Y_(t,this)}))}splitCellVertically(t,e=2){const n=this.editor.model,o=t.parent.parent,i=parseInt(t.getAttribute("rowspan")||1),r=parseInt(t.getAttribute("colspan")||1);n.change((n=>{if(r>1){const{newCellsSpan:o,updatedSpan:s}=uC(r,e);p_("colspan",s,t,n);const a={};o>1&&(a.colspan=o),i>1&&(a.rowspan=i);dC(r>e?e-1:r-1,n,n.createPositionAfter(t),a)}if(re===t)),l=a.filter((({cell:e,cellWidth:n,column:o})=>e!==t&&o===c||oc));for(const{cell:t,cellWidth:e}of l)n.setAttribute("colspan",e+s,t);const d={};i>1&&(d.rowspan=i),dC(s,n,n.createPositionAfter(t),d);const u=o.getAttribute("headingColumns")||0;u>c&&p_("headingColumns",u+s,o,n)}}))}splitCellHorizontally(t,e=2){const n=this.editor.model,o=t.parent,i=o.parent,r=i.getChildIndex(o),s=parseInt(t.getAttribute("rowspan")||1),a=parseInt(t.getAttribute("colspan")||1);n.change((n=>{if(s>1){const o=[...new w_(i,{startRow:r,endRow:r+s-1,includeAllSlots:!0})],{newCellsSpan:c,updatedSpan:l}=uC(s,e);p_("rowspan",l,t,n);const{column:d}=o.find((({cell:e})=>e===t)),u={};c>1&&(u.rowspan=c),a>1&&(u.colspan=a);for(const t of o){const{column:e,row:o}=t,i=e===d,s=(o+r+l)%c==0;o>=r+l&&i&&s&&dC(1,n,t.getPositionBefore(),u)}}if(sr){const t=i+o;n.setAttribute("rowspan",t,e)}const l={};a>1&&(l.colspan=a),lC(n,i,r+1,o,1,l);const d=i.getAttribute("headingRows")||0;d>r&&p_("headingRows",d+o,i,n)}}))}getColumns(t){return[...t.getChild(0).getChildren()].reduce(((t,e)=>t+parseInt(e.getAttribute("colspan")||1)),0)}getRows(t){return Array.from(t.getChildren()).reduce(((t,e)=>e.is("element","tableRow")?t+1:t),0)}}function lC(t,e,n,o,i,r={}){for(let s=0;s{const o=I_(t.document.selection),i=o.shift(),{mergeWidth:r,mergeHeight:s}=function(t,e,n){let o=0,i=0;for(const t of e){const{row:e,column:r}=n.getCellLocation(t);o=gC(t,r,o,"colspan"),i=gC(t,e,i,"rowspan")}const{row:r,column:s}=n.getCellLocation(t);return{mergeWidth:o-s,mergeHeight:i-r}}(i,o,e);p_("colspan",r,i,n),p_("rowspan",s,i,n);for(const t of o)pC(t,i,n);X_(i.findAncestor("table"),e),n.setSelection(i,"in")}))}}function pC(t,e,n){mC(t)||(mC(e)&&n.remove(n.createRangeIn(e)),n.move(n.createRangeIn(t),n.createPositionAt(e,"end"))),n.remove(t)}function mC(t){return 1==t.childCount&&t.getChild(0).is("element","paragraph")&&t.getChild(0).isEmpty}function gC(t,e,n,o){const i=parseInt(t.getAttribute(o)||1);return Math.max(n,e+i)}class fC extends ge{constructor(t){super(t),this.affectsData=!1}refresh(){const t=z_(this.editor.model.document.selection);this.isEnabled=t.length>0}execute(){const t=this.editor.model,e=z_(t.document.selection),n=F_(e),o=e[0].findAncestor("table"),i=[];for(let e=n.first;e<=n.last;e++)for(const n of o.getChild(e).getChildren())i.push(t.createRangeOn(n));t.change((t=>{t.setSelection(i)}))}}class bC extends ge{constructor(t){super(t),this.affectsData=!1}refresh(){const t=z_(this.editor.model.document.selection);this.isEnabled=t.length>0}execute(){const t=this.editor.model,e=z_(t.document.selection),n=e[0],o=e.pop(),i=n.findAncestor("table"),r=this.editor.plugins.get("TableUtils"),s=r.getCellLocation(n),a=r.getCellLocation(o),c=Math.min(s.column,a.column),l=Math.max(s.column,a.column),d=[];for(const e of new w_(i,{startColumn:c,endColumn:l}))d.push(t.createRangeOn(e.cell));t.change((t=>{t.setSelection(d)}))}}function kC(t){t.document.registerPostFixer((e=>function(t,e){const n=e.document.differ.getChanges();let o=!1;const i=new Set;for(const e of n){let n;"table"==e.name&&"insert"==e.type&&(n=e.position.nodeAfter),"tableRow"!=e.name&&"tableCell"!=e.name||(n=e.position.findAncestor("table")),CC(e)&&(n=e.range.start.findAncestor("table")),n&&!i.has(n)&&(o=wC(n,t)||o,o=_C(n,t)||o,i.add(n))}return o}(e,t)))}function wC(t,e){let n=!1;const o=function(t){const e=parseInt(t.getAttribute("headingRows")||0),n=Array.from(t.getChildren()).reduce(((t,e)=>e.is("element","tableRow")?t+1:t),0),o=[];for(const{row:i,cell:r,cellHeight:s}of new w_(t)){if(s<2)continue;const t=it){const e=t-i;o.push({cell:r,rowspan:e})}}return o}(t);if(o.length){n=!0;for(const t of o)p_("rowspan",t.rowspan,t.cell,e,1)}return n}function _C(t,e){let n=!1;const o=function(t){const e=new Array(t.childCount).fill(0);for(const{rowIndex:n}of new w_(t,{includeAllSlots:!0}))e[n]++;return e}(t),i=[];for(const[e,n]of o.entries())!n&&t.getChild(e).is("element","tableRow")&&i.push(e);if(i.length){n=!0;for(const n of i.reverse())e.remove(t.getChild(n)),o.splice(n,1)}const r=o.filter(((e,n)=>t.getChild(n).is("element","tableRow"))),s=r[0];if(!r.every((t=>t===s))){const o=r.reduce(((t,e)=>e>t?e:t),0);for(const[i,s]of r.entries()){const r=o-s;if(r){for(let n=0;nfunction(t,e){const n=e.document.differ.getChanges();let o=!1;for(const e of n)"insert"==e.type&&"table"==e.name&&(o=vC(e.position.nodeAfter,t)||o),"insert"==e.type&&"tableRow"==e.name&&(o=yC(e.position.nodeAfter,t)||o),"insert"==e.type&&"tableCell"==e.name&&(o=xC(e.position.nodeAfter,t)||o),EC(e)&&(o=xC(e.position.parent,t)||o);return o}(e,t)))}function vC(t,e){let n=!1;for(const o of t.getChildren())o.is("element","tableRow")&&(n=yC(o,e)||n);return n}function yC(t,e){let n=!1;for(const o of t.getChildren())n=xC(o,e)||n;return n}function xC(t,e){if(0==t.childCount)return e.insertElement("paragraph",t),!0;const n=Array.from(t.getChildren()).filter((t=>t.is("$text")));for(const t of n)e.wrap(e.createRangeOn(t),"paragraph");return!!n.length}function EC(t){return!(!t.position||!t.position.parent.is("element","tableCell"))&&("insert"==t.type&&"$text"==t.name||"remove"==t.type)}function DC(t,e){t.document.registerPostFixer((()=>function(t,e){const n=new Set;for(const e of t.getChanges()){const t="attribute"==e.type?e.range.start.parent:e.position.parent;t.is("element","tableCell")&&n.add(t)}for(const o of n.values())for(const n of[...o.getChildren()].filter((t=>SC(t,e))))t.refreshItem(n);return!1}(t.document.differ,e)))}function SC(t,e){if(!t.is("element","paragraph"))return!1;const n=e.toViewElement(t);return!!n&&v_(t)!==n.is("element","span")}function BC(t){t.document.registerPostFixer((()=>function(t){const e=t.document.differ,n=new Set;for(const t of e.getChanges())if("attribute"===t.type){const e=t.range.start.nodeAfter;e&&e.is("element","table")&&"headingRows"===t.attributeKey&&n.add(e)}else if("insert"===t.type||"remove"===t.type)if("tableRow"===t.name){const e=t.position.findAncestor("table"),o=e.getAttribute("headingRows")||0;t.position.offset{t.on("element:figure",((t,e,n)=>{if(!n.consumable.test(e.viewItem,{name:!0,classes:"table"}))return;const o=function(t){for(const e of t.getChildren())if(e.is("element","table"))return e}(e.viewItem);if(!o||!n.consumable.test(o,{name:!0}))return;n.consumable.consume(e.viewItem,{name:!0,classes:"table"});const i=Ta(n.convertItem(o,e.modelCursor).modelRange.getItems());i?(n.convertChildren(e.viewItem,n.writer.createPositionAt(i,"end")),n.updateConversionResult(i,e)):n.consumable.revert(e.viewItem,{name:!0,classes:"table"})}))})),o.for("upcast").add(f_()),o.for("editingDowncast").add(C_({asWidget:!0})),o.for("dataDowncast").add(C_()),o.for("upcast").elementToElement({model:"tableRow",view:"tr"}),o.for("upcast").add((t=>{t.on("element:tr",((t,e)=>{e.viewItem.isEmpty&&0==e.modelCursor.index&&t.stop()}),{priority:"high"})})),o.for("editingDowncast").add((t=>t.on("insert:tableRow",((t,e,n)=>{const o=e.item;if(!n.consumable.consume(o,"insert"))return;const i=o.parent,r=function(t){for(const e of t.getChildren())if("table"===e.name)return e}(n.mapper.toViewElement(i)),s=i.getChildIndex(o),a=new w_(i,{row:s}),c={headingRows:i.getAttribute("headingRows")||0,headingColumns:i.getAttribute("headingColumns")||0},l=new Map;for(const t of a){const e=l.get(s)||E_(r,o,s,c,n);l.set(s,e),n.consumable.consume(t.cell,"insert"),x_(t,c,n.writer.createPositionAt(e,"end"),n,{asWidget:!0})}})))),o.for("editingDowncast").add((t=>t.on("remove:tableRow",((t,e,n)=>{t.stop();const o=n.writer,i=n.mapper,r=i.toViewPosition(e.position).getLastMatchingPosition((t=>!t.item.is("element","tr"))).nodeAfter,s=r.parent.parent,a=o.createRangeOn(r),c=o.remove(a);for(const t of o.createRangeIn(c).getItems())i.unbindViewElement(t);B_("thead",s,n),B_("tbody",s,n)}),{priority:"higher"}))),o.for("upcast").elementToElement({model:"tableCell",view:"td"}),o.for("upcast").elementToElement({model:"tableCell",view:"th"}),o.for("upcast").add(b_("td")),o.for("upcast").add(b_("th")),o.for("editingDowncast").add((t=>t.on("insert:tableCell",((t,e,n)=>{const o=e.item;if(!n.consumable.consume(o,"insert"))return;const i=o.parent,r=i.parent,s=r.getChildIndex(i),a=new w_(r,{row:s}),c={headingRows:r.getAttribute("headingRows")||0,headingColumns:r.getAttribute("headingColumns")||0};for(const t of a)if(t.cell===o){const e=n.mapper.toViewElement(i);return void x_(t,c,n.writer.createPositionAt(e,i.getChildIndex(o)),n,{asWidget:!0})}})))),o.for("editingDowncast").elementToElement({model:"paragraph",view:A_,converterPriority:"high"}),o.for("downcast").attributeToAttribute({model:"colspan",view:"colspan"}),o.for("upcast").attributeToAttribute({model:{key:"colspan",value:RC("colspan")},view:"colspan"}),o.for("downcast").attributeToAttribute({model:"rowspan",view:"rowspan"}),o.for("upcast").attributeToAttribute({model:{key:"rowspan",value:RC("rowspan")},view:"rowspan"}),o.for("editingDowncast").add((t=>t.on("attribute:headingColumns:table",((t,e,n)=>{const o=e.item;if(!n.consumable.consume(e.item,t.name))return;const i={headingRows:o.getAttribute("headingRows")||0,headingColumns:o.getAttribute("headingColumns")||0},r=e.attributeOldValue,s=e.attributeNewValue,a=(r>s?r:s)-1;for(const t of new w_(o,{endColumn:a}))y_(t,i,n)})))),t.data.mapper.on("modelToViewPosition",((t,e)=>{const n=e.modelPosition.parent,o=e.modelPosition.nodeBefore;if(!n.is("element","tableCell"))return;if(!o||!o.is("element","paragraph"))return;const i=e.mapper.toViewElement(o),r=e.mapper.toViewElement(n);i===r&&(e.viewPosition=e.mapper.findPositionIn(r,o.maxOffset))})),t.config.define("table.defaultHeadings.rows",0),t.config.define("table.defaultHeadings.columns",0),t.commands.add("insertTable",new P_(t)),t.commands.add("insertTableRowAbove",new q_(t,{order:"above"})),t.commands.add("insertTableRowBelow",new q_(t,{order:"below"})),t.commands.add("insertTableColumnLeft",new W_(t,{order:"left"})),t.commands.add("insertTableColumnRight",new W_(t,{order:"right"})),t.commands.add("removeTableRow",new iC(t)),t.commands.add("removeTableColumn",new rC(t)),t.commands.add("splitTableCellVertically",new j_(t,{direction:"vertically"})),t.commands.add("splitTableCellHorizontally",new j_(t,{direction:"horizontally"})),t.commands.add("mergeTableCells",new hC(t)),t.commands.add("mergeTableCellRight",new nC(t,{direction:"right"})),t.commands.add("mergeTableCellLeft",new nC(t,{direction:"left"})),t.commands.add("mergeTableCellDown",new nC(t,{direction:"down"})),t.commands.add("mergeTableCellUp",new nC(t,{direction:"up"})),t.commands.add("setTableColumnHeader",new aC(t)),t.commands.add("setTableRowHeader",new sC(t)),t.commands.add("selectTableRow",new fC(t)),t.commands.add("selectTableColumn",new bC(t)),BC(e),kC(e),DC(e,t.editing.mapper),AC(e)}static get requires(){return[cC]}}function RC(t){return e=>{const n=parseInt(e.getAttribute(t));return Number.isNaN(n)||n<=0?null:n}}var zC=n(8085),FC={attributes:{"data-cke":!0}};FC.setAttributes=is(),FC.insert=ns().bind(null,"head"),FC.domAPI=ts(),FC.insertStyleElement=ss();Qr()(zC.Z,FC);zC.Z&&zC.Z.locals&&zC.Z.locals;class NC extends Od{constructor(t){super(t);const e=this.bindTemplate;this.items=this._createGridCollection(),this.set("rows",0),this.set("columns",0),this.bind("label").to(this,"columns",this,"rows",((t,e)=>`${e} × ${t}`)),this.setTemplate({tag:"div",attributes:{class:["ck"]},children:[{tag:"div",attributes:{class:["ck-insert-table-dropdown__grid"]},on:{"mouseover@.ck-insert-table-dropdown-grid-box":e.to("boxover")},children:this.items},{tag:"div",attributes:{class:["ck-insert-table-dropdown__label"]},children:[{text:e.to("label")}]}],on:{mousedown:e.to((t=>{t.preventDefault()})),click:e.to((()=>{this.fire("execute")}))}}),this.on("boxover",((t,e)=>{const{row:n,column:o}=e.target.dataset;this.set({rows:parseInt(n),columns:parseInt(o)})})),this.on("change:columns",(()=>{this._highlightGridBoxes()})),this.on("change:rows",(()=>{this._highlightGridBoxes()}))}focus(){}focusLast(){}_highlightGridBoxes(){const t=this.rows,e=this.columns;this.items.map(((n,o)=>{const i=Math.floor(o/10){const o=t.commands.get("insertTable"),i=nh(n);let r;return i.bind("isEnabled").to(o),i.buttonView.set({icon:'',label:e("Insert table"),tooltip:!0}),i.on("change:isOpen",(()=>{r||(r=new NC(n),i.panelView.children.add(r),r.delegate("execute").to(i),i.buttonView.on("open",(()=>{r.rows=0,r.columns=0})),i.on("execute",(()=>{t.execute("insertTable",{rows:r.rows,columns:r.columns}),t.editing.view.focus()})))})),i})),t.ui.componentFactory.add("tableColumn",(t=>{const o=[{type:"switchbutton",model:{commandName:"setTableColumnHeader",label:e("Header column"),bindIsOn:!0}},{type:"separator"},{type:"button",model:{commandName:n?"insertTableColumnLeft":"insertTableColumnRight",label:e("Insert column left")}},{type:"button",model:{commandName:n?"insertTableColumnRight":"insertTableColumnLeft",label:e("Insert column right")}},{type:"button",model:{commandName:"removeTableColumn",label:e("Delete column")}},{type:"button",model:{commandName:"selectTableColumn",label:e("Select column")}}];return this._prepareDropdown(e("Column"),'',o,t)})),t.ui.componentFactory.add("tableRow",(t=>{const n=[{type:"switchbutton",model:{commandName:"setTableRowHeader",label:e("Header row"),bindIsOn:!0}},{type:"separator"},{type:"button",model:{commandName:"insertTableRowAbove",label:e("Insert row above")}},{type:"button",model:{commandName:"insertTableRowBelow",label:e("Insert row below")}},{type:"button",model:{commandName:"removeTableRow",label:e("Delete row")}},{type:"button",model:{commandName:"selectTableRow",label:e("Select row")}}];return this._prepareDropdown(e("Row"),'',n,t)})),t.ui.componentFactory.add("mergeTableCells",(t=>{const o=[{type:"button",model:{commandName:"mergeTableCellUp",label:e("Merge cell up")}},{type:"button",model:{commandName:n?"mergeTableCellRight":"mergeTableCellLeft",label:e("Merge cell right")}},{type:"button",model:{commandName:"mergeTableCellDown",label:e("Merge cell down")}},{type:"button",model:{commandName:n?"mergeTableCellLeft":"mergeTableCellRight",label:e("Merge cell left")}},{type:"separator"},{type:"button",model:{commandName:"splitTableCellVertically",label:e("Split cell vertically")}},{type:"button",model:{commandName:"splitTableCellHorizontally",label:e("Split cell horizontally")}}];return this._prepareMergeSplitButtonDropdown(e("Merge cells"),'',o,t)}))}_prepareDropdown(t,e,n,o){const i=this.editor,r=nh(o),s=this._fillDropdownWithListOptions(r,n);return r.buttonView.set({label:t,icon:e,tooltip:!0}),r.bind("isEnabled").toMany(s,"isEnabled",((...t)=>t.some((t=>t)))),this.listenTo(r,"execute",(t=>{i.execute(t.source.commandName),i.editing.view.focus()})),r}_prepareMergeSplitButtonDropdown(t,e,n,o){const i=this.editor,r=nh(o,Pu),s="mergeTableCells",a=i.commands.get(s),c=this._fillDropdownWithListOptions(r,n);return r.buttonView.set({label:t,icon:e,tooltip:!0,isEnabled:!0}),r.bind("isEnabled").toMany([a,...c],"isEnabled",((...t)=>t.some((t=>t)))),this.listenTo(r.buttonView,"execute",(()=>{i.execute(s),i.editing.view.focus()})),this.listenTo(r,"execute",(t=>{i.execute(t.source.commandName),i.editing.view.focus()})),r}_fillDropdownWithListOptions(t,e){const n=this.editor,o=[],i=new So;for(const t of e)VC(t,n,o,i);return ih(t,i,n.ui.componentFactory),o}}function VC(t,e,n,o){const i=t.model=new Eh(t.model),{commandName:r,bindIsOn:s}=t.model;if("button"===t.type||"switchbutton"===t.type){const t=e.commands.get(r);n.push(t),i.set({commandName:r}),i.bind("isEnabled").to(t),s&&i.bind("isOn").to(t,"value")}i.set({withText:!0}),o.add(t)}var LC=n(5593),HC={attributes:{"data-cke":!0}};HC.setAttributes=is(),HC.insert=ns().bind(null,"head"),HC.domAPI=ts(),HC.insertStyleElement=ss();Qr()(LC.Z,HC);LC.Z&&LC.Z.locals&&LC.Z.locals;class qC extends pe{static get pluginName(){return"TableSelection"}static get requires(){return[cC]}init(){const t=this.editor.model;this.listenTo(t,"deleteContent",((t,e)=>this._handleDeleteContent(t,e)),{priority:"high"}),this._defineSelectionConverter(),this._enablePluginDisabling()}getSelectedTableCells(){const t=I_(this.editor.model.document.selection);return 0==t.length?null:t}getSelectionAsFragment(){const t=this.getSelectedTableCells();return t?this.editor.model.change((e=>{const n=e.createDocumentFragment(),o=this.editor.plugins.get("TableUtils"),{first:i,last:r}=N_(t),{first:s,last:a}=F_(t),c=t[0].findAncestor("table");let l=a,d=r;if(O_(t,o)){const t={firstColumn:i,lastColumn:r,firstRow:s,lastRow:a};l=tC(c,t),d=eC(c,t)}const u=U_(c,{startRow:s,startColumn:i,endRow:l,endColumn:d},e);return e.insert(u,n,0),n})):null}setCellSelection(t,e){const n=this._getCellsToSelect(t,e);this.editor.model.change((t=>{t.setSelection(n.cells.map((e=>t.createRangeOn(e))),{backward:n.backward})}))}getFocusCell(){const t=[...this.editor.model.document.selection.getRanges()].pop().getContainedElement();return t&&t.is("element","tableCell")?t:null}getAnchorCell(){const t=Ta(this.editor.model.document.selection.getRanges()).getContainedElement();return t&&t.is("element","tableCell")?t:null}_defineSelectionConverter(){const t=this.editor,e=new Set;t.conversion.for("editingDowncast").add((t=>t.on("selection",((t,n,o)=>{const i=o.writer;!function(t){for(const n of e)t.removeClass("ck-editor__editable_selected",n);e.clear()}(i);const r=this.getSelectedTableCells();if(!r)return;for(const t of r){const n=o.mapper.toViewElement(t);i.addClass("ck-editor__editable_selected",n),e.add(n)}const s=o.mapper.toViewElement(r[r.length-1]);i.setSelection(s,0)}),{priority:"lowest"})))}_enablePluginDisabling(){const t=this.editor;this.on("change:isEnabled",(()=>{if(!this.isEnabled){const e=this.getSelectedTableCells();if(!e)return;t.model.change((n=>{const o=n.createPositionAt(e[0],0),i=t.model.schema.getNearestSelectionRange(o);n.setSelection(i)}))}}))}_handleDeleteContent(t,e){const[n,o]=e,i=this.editor.model,r=!o||"backward"==o.direction,s=I_(n);s.length&&(t.stop(),i.change((t=>{const e=s[r?s.length-1:0];i.change((t=>{for(const e of s)i.deleteContent(t.createSelection(e,"in"))}));const o=i.schema.getNearestSelectionRange(t.createPositionAt(e,0));n.is("documentSelection")?t.setSelection(o):n.setTo(o)})))}_getCellsToSelect(t,e){const n=this.editor.plugins.get("TableUtils"),o=n.getCellLocation(t),i=n.getCellLocation(e),r=Math.min(o.row,i.row),s=Math.max(o.row,i.row),a=Math.min(o.column,i.column),c=Math.max(o.column,i.column),l=new Array(s-r+1).fill(null).map((()=>[])),d={startRow:r,endRow:s,startColumn:a,endColumn:c};for(const{row:e,cell:n}of new w_(t.findAncestor("table"),d))l[e-r].push(n);const u=i.rowt.reverse())),{cells:l.flat(),backward:u||h}}}class WC extends pe{static get pluginName(){return"TableClipboard"}static get requires(){return[qC,cC]}init(){const t=this.editor,e=t.editing.view.document;this.listenTo(e,"copy",((t,e)=>this._onCopyCut(t,e))),this.listenTo(e,"cut",((t,e)=>this._onCopyCut(t,e))),this.listenTo(t.model,"insertContent",((t,e)=>this._onInsertContent(t,...e)),{priority:"high"}),this.decorate("_replaceTableSlotCell")}_onCopyCut(t,e){const n=this.editor.plugins.get(qC);if(!n.getSelectedTableCells())return;if("cut"==t.name&&this.editor.isReadOnly)return;e.preventDefault(),t.stop();const o=this.editor.data,i=this.editor.editing.view.document,r=o.toView(n.getSelectionAsFragment());i.fire("clipboardOutput",{dataTransfer:e.dataTransfer,content:r,method:t.name})}_onInsertContent(t,e,n){if(n&&!n.is("documentSelection"))return;const o=this.editor.model,i=this.editor.plugins.get(cC);let r=function(t,e){if(!t.is("documentFragment")&&!t.is("element"))return null;if(t.is("element","table"))return t;if(1==t.childCount&&t.getChild(0).is("element","table"))return t.getChild(0);const n=e.createRangeIn(t);for(const t of n.getItems())if(t.is("element","table")){const o=e.createRange(n.start,e.createPositionBefore(t));if(e.hasContent(o,{ignoreWhitespaces:!0}))return null;const i=e.createRange(e.createPositionAfter(t),n.end);return e.hasContent(i,{ignoreWhitespaces:!0})?null:t}return null}(e,o);if(!r)return;const s=z_(o.document.selection);s.length?(t.stop(),o.change((t=>{const e={width:i.getColumns(r),height:i.getRows(r)},n=function(t,e,n,o){const i=t[0].findAncestor("table"),r=N_(t),s=F_(t),a={firstColumn:r.first,lastColumn:r.last,firstRow:s.first,lastRow:s.last},c=1===t.length;c&&(a.lastRow+=e.height-1,a.lastColumn+=e.width-1,function(t,e,n,o){const i=o.getColumns(t),r=o.getRows(t);n>i&&o.insertColumns(t,{at:i,columns:n-i});e>r&&o.insertRows(t,{at:r,rows:e-r})}(i,a.lastRow+1,a.lastColumn+1,o));c||!O_(t,o)?function(t,e,n){const{firstRow:o,lastRow:i,firstColumn:r,lastColumn:s}=e,a={first:o,last:i},c={first:r,last:s};UC(t,r,a,n),UC(t,s+1,a,n),jC(t,o,c,n),jC(t,i+1,c,n,o)}(i,a,n):(a.lastRow=tC(i,a),a.lastColumn=eC(i,a));return a}(s,e,t,i),o=n.lastRow-n.firstRow+1,a=n.lastColumn-n.firstColumn+1,c={startRow:0,startColumn:0,endRow:Math.min(o,e.height)-1,endColumn:Math.min(a,e.width)-1};r=U_(r,c,t);const l=s[0].findAncestor("table"),d=this._replaceSelectedCellsWithPasted(r,e,l,n,t);if(this.editor.plugins.get("TableSelection").isEnabled){const e=M_(d.map((e=>t.createRangeOn(e))));t.setSelection(e)}else t.setSelection(d[0],0)}))):X_(r,i)}_replaceSelectedCellsWithPasted(t,e,n,o,i){const{width:r,height:s}=e,a=function(t,e,n){const o=new Array(n).fill(null).map((()=>new Array(e).fill(null)));for(const{column:e,row:n,cell:i}of new w_(t))o[n][e]=i;return o}(t,r,s),c=[...new w_(n,{startRow:o.firstRow,endRow:o.lastRow,startColumn:o.firstColumn,endColumn:o.lastColumn,includeAllSlots:!0})],l=[];let d;for(const t of c){const{row:e,column:n}=t;n===o.firstColumn&&(d=t.getPositionBefore());const c=e-o.firstRow,u=n-o.firstColumn,h=a[c%s][u%r],p=h?i.cloneElement(h):null,m=this._replaceTableSlotCell(t,p,d,i);m&&(J_(m,e,n,o.lastRow,o.lastColumn,i),l.push(m),d=i.createPositionAfter(m))}const u=parseInt(n.getAttribute("headingRows")||0),h=parseInt(n.getAttribute("headingColumns")||0),p=o.firstRow$C(t,e,n))).map((({cell:t})=>G_(t,e,o)))}function UC(t,e,n,o){if(e<1)return;return K_(t,e).filter((({row:t,cellHeight:e})=>$C(t,e,n))).map((({cell:t,column:n})=>Z_(t,n,e,o)))}function $C(t,e,n){const o=t+e-1,{first:i,last:r}=n;return t>=i&&t<=r||t=i}class GC extends pe{static get pluginName(){return"TableKeyboard"}static get requires(){return[qC]}init(){const t=this.editor.editing.view.document;this.editor.keystrokes.set("Tab",((...t)=>this._handleTabOnSelectedTable(...t)),{priority:"low"}),this.editor.keystrokes.set("Tab",this._getTabHandler(!0),{priority:"low"}),this.editor.keystrokes.set("Shift+Tab",this._getTabHandler(!1),{priority:"low"}),this.listenTo(t,"arrowKey",((...t)=>this._onArrowKey(...t)),{context:"table"})}_handleTabOnSelectedTable(t,e){const n=this.editor,o=n.model.document.selection.getSelectedElement();o&&o.is("element","table")&&(e(),n.model.change((t=>{t.setSelection(t.createRangeIn(o.getChild(0).getChild(0)))})))}_getTabHandler(t){const e=this.editor;return(n,o)=>{let i=R_(e.model.document.selection)[0];if(i||(i=this.editor.plugins.get("TableSelection").getFocusCell()),!i)return;o();const r=i.parent,s=r.parent,a=s.getChildIndex(r),c=r.getChildIndex(i),l=0===c;if(!t&&l&&0===a)return void e.model.change((t=>{t.setSelection(t.createRangeOn(s))}));const d=this.editor.plugins.get("TableUtils"),u=c===r.childCount-1,h=a===d.getRows(s)-1;if(t&&h&&u&&(e.execute("insertTableRowBelow"),a===d.getRows(s)-1))return void e.model.change((t=>{t.setSelection(t.createRangeOn(s))}));let p;if(t&&u){const t=s.getChild(a+1);p=t.getChild(0)}else if(!t&&l){const t=s.getChild(a-1);p=t.getChild(t.childCount-1)}else p=r.getChild(c+(t?1:-1));e.model.change((t=>{t.setSelection(t.createRangeIn(p))}))}}_onArrowKey(t,e){const n=this.editor,o=fr(e.keyCode,n.locale.contentLanguageDirection);this._handleArrowKeys(o,e.shiftKey)&&(e.preventDefault(),e.stopPropagation(),t.stop())}_handleArrowKeys(t,e){const n=this.editor.model,o=n.document.selection,i=["right","down"].includes(t),r=I_(o);if(r.length){let n;return n=e?this.editor.plugins.get("TableSelection").getFocusCell():i?r[r.length-1]:r[0],this._navigateFromCellInDirection(n,t,e),!0}const s=o.focus.findAncestor("tableCell");if(!s)return!1;if(!o.isCollapsed)if(e){if(o.isBackward==i&&!o.containsEntireContent(s))return!1}else{const t=o.getSelectedElement();if(!t||!n.schema.isObject(t))return!1}return!!this._isSelectionAtCellEdge(o,s,i)&&(this._navigateFromCellInDirection(s,t,e),!0)}_isSelectionAtCellEdge(t,e,n){const o=this.editor.model,i=this.editor.model.schema,r=n?t.getLastPosition():t.getFirstPosition();if(!i.getLimitElement(r).is("element","tableCell")){return o.createPositionAt(e,n?"end":0).isTouching(r)}const s=o.createSelection(r);return o.modifySelection(s,{direction:n?"forward":"backward"}),r.isEqual(s.focus)}_navigateFromCellInDirection(t,e,n=!1){const o=this.editor.model,i=t.findAncestor("table"),r=[...new w_(i,{includeAllSlots:!0})],{row:s,column:a}=r[r.length-1],c=r.find((({cell:e})=>e==t));let{row:l,column:d}=c;switch(e){case"left":d--;break;case"up":l--;break;case"right":d+=c.cellWidth;break;case"down":l+=c.cellHeight}if(l<0||l>s||d<0&&l<=0||d>a&&l>=s)return void o.change((t=>{t.setSelection(t.createRangeOn(i))}));d<0?(d=n?0:a,l--):d>a&&(d=n?a:0,l++);const u=r.find((t=>t.row==l&&t.column==d)).cell,h=["right","down"].includes(e),p=this.editor.plugins.get("TableSelection");if(n&&p.isEnabled){const e=p.getAnchorCell()||t;p.setCellSelection(e,u)}else{const t=o.createPositionAt(u,h?0:"end");o.change((e=>{e.setSelection(t)}))}}}class KC extends Xs{constructor(t){super(t),this.domEventType=["mousemove","mouseleave"]}onDomEvent(t){this.fire(t.type,t)}}class ZC extends pe{static get pluginName(){return"TableMouse"}static get requires(){return[qC]}init(){this.editor.editing.view.addObserver(KC),this._enableShiftClickSelection(),this._enableMouseDragSelection()}_enableShiftClickSelection(){const t=this.editor;let e=!1;const n=t.plugins.get(qC);this.listenTo(t.editing.view.document,"mousedown",((o,i)=>{if(!this.isEnabled||!n.isEnabled)return;if(!i.domEvent.shiftKey)return;const r=n.getAnchorCell()||R_(t.model.document.selection)[0];if(!r)return;const s=this._getModelTableCellFromDomEvent(i);s&&JC(r,s)&&(e=!0,n.setCellSelection(r,s),i.preventDefault())})),this.listenTo(t.editing.view.document,"mouseup",(()=>{e=!1})),this.listenTo(t.editing.view.document,"selectionChange",(t=>{e&&t.stop()}),{priority:"highest"})}_enableMouseDragSelection(){const t=this.editor;let e,n,o=!1,i=!1;const r=t.plugins.get(qC);this.listenTo(t.editing.view.document,"mousedown",((t,n)=>{this.isEnabled&&r.isEnabled&&(n.domEvent.shiftKey||n.domEvent.ctrlKey||n.domEvent.altKey||(e=this._getModelTableCellFromDomEvent(n)))})),this.listenTo(t.editing.view.document,"mousemove",((t,s)=>{if(!s.domEvent.buttons)return;if(!e)return;const a=this._getModelTableCellFromDomEvent(s);a&&JC(e,a)&&(n=a,o||n==e||(o=!0)),o&&(i=!0,r.setCellSelection(e,n),s.preventDefault())})),this.listenTo(t.editing.view.document,"mouseup",(()=>{o=!1,i=!1,e=null,n=null})),this.listenTo(t.editing.view.document,"selectionChange",(t=>{i&&t.stop()}),{priority:"highest"})}_getModelTableCellFromDomEvent(t){const e=t.target,n=this.editor.editing.view.createPositionAt(e,0);return this.editor.editing.mapper.toModelPosition(n).parent.findAncestor("tableCell",{includeSelf:!0})}}function JC(t,e){return t.parent.parent==e.parent.parent}var YC=n(4104),QC={attributes:{"data-cke":!0}};QC.setAttributes=is(),QC.insert=ns().bind(null,"head"),QC.domAPI=ts(),QC.insertStyleElement=ss();Qr()(YC.Z,QC);YC.Z&&YC.Z.locals&&YC.Z.locals;function XC(t){const e=t.getSelectedElement();return e&&eA(e)?e:null}function tA(t){let e=t.getFirstPosition().parent;for(;e;){if(e.is("element")&&eA(e))return e;e=e.parent}return null}function eA(t){return!!t.getCustomProperty("table")&&hm(t)}function nA(t,e){const{viewElement:n,defaultValue:o,modelAttribute:i,styleName:r,reduceBoxSides:s=!1}=e;t.for("upcast").attributeToAttribute({view:{name:n,styles:{[r]:/[\s\S]+/}},model:{key:i,value:t=>{const e=t.getNormalizedStyle(r),n=s?sA(e):e;if(o!==n)return n}}})}function oA(t,e,n,o){t.for("upcast").add((t=>t.on("element:"+e,((t,e,i)=>{if(!e.modelRange)return;const r=["border-top-width","border-top-color","border-top-style","border-bottom-width","border-bottom-color","border-bottom-style","border-right-width","border-right-color","border-right-style","border-left-width","border-left-color","border-left-style"].filter((t=>e.viewItem.hasStyle(t)));if(!r.length)return;const s={styles:r};if(!i.consumable.test(e.viewItem,s))return;const a=[...e.modelRange.getItems({shallow:!0})].pop();i.consumable.consume(e.viewItem,s);const c={style:e.viewItem.getNormalizedStyle("border-style"),color:e.viewItem.getNormalizedStyle("border-color"),width:e.viewItem.getNormalizedStyle("border-width")},l={style:sA(c.style),color:sA(c.color),width:sA(c.width)};l.style!==o.style&&i.writer.setAttribute(n.style,l.style,a),l.color!==o.color&&i.writer.setAttribute(n.color,l.color,a),l.width!==o.width&&i.writer.setAttribute(n.width,l.width,a)}))))}function iA(t,{modelElement:e,modelAttribute:n,styleName:o}){t.for("downcast").attributeToAttribute({model:{name:e,key:n},view:t=>({key:"style",value:{[o]:t}})})}function rA(t,{modelAttribute:e,styleName:n}){t.for("downcast").add((t=>t.on(`attribute:${e}:table`,((t,e,o)=>{const{item:i,attributeNewValue:r}=e,{mapper:s,writer:a}=o;if(!o.consumable.consume(e.item,t.name))return;const c=[...s.toViewElement(i).getChildren()].find((t=>t.is("element","table")));r?a.setStyle(n,r,c):a.removeStyle(n,c)}))))}function sA(t){if(!t)return;return["top","right","bottom","left"].map((e=>t[e])).reduce(((t,e)=>t==e?t:null))||t}class aA extends ge{constructor(t,e,n){super(t),this.attributeName=e,this._defaultValue=n}refresh(){const t=this.editor.model.document.selection.getFirstPosition().findAncestor("table");this.isEnabled=!!t,this.value=this._getValue(t)}execute(t={}){const e=this.editor.model,n=e.document.selection,{value:o,batch:i}=t,r=n.getFirstPosition().findAncestor("table"),s=this._getValueToSet(o);e.enqueueChange(i,(t=>{s?t.setAttribute(this.attributeName,s,r):t.removeAttribute(this.attributeName,r)}))}_getValue(t){if(!t)return;const e=t.getAttribute(this.attributeName);return e!==this._defaultValue?e:void 0}_getValueToSet(t){if(t!==this._defaultValue)return t}}class cA extends aA{constructor(t,e){super(t,"tableBackgroundColor",e)}}function lA(t){if(!t||!y(t))return t;const{top:e,right:n,bottom:o,left:i}=t;return e==n&&n==o&&o==i?e:void 0}function dA(t,e){const n=parseFloat(t);return Number.isNaN(n)||String(n)!==String(t)?t:`${n}${e}`}function uA(t,e={}){const n=Object.assign({borderStyle:"none",borderWidth:"",borderColor:"",backgroundColor:"",width:"",height:""},t);return e.includeAlignmentProperty&&!n.alignment&&(n.alignment="center"),e.includePaddingProperty&&!n.padding&&(n.padding=""),e.includeVerticalAlignmentProperty&&!n.verticalAlignment&&(n.verticalAlignment="middle"),e.includeHorizontalAlignmentProperty&&!n.horizontalAlignment&&(n.horizontalAlignment=e.isRightToLeftContent?"right":"left"),n}class hA extends aA{constructor(t,e){super(t,"tableBorderColor",e)}_getValue(t){if(!t)return;const e=lA(t.getAttribute(this.attributeName));return e!==this._defaultValue?e:void 0}}class pA extends aA{constructor(t,e){super(t,"tableBorderStyle",e)}_getValue(t){if(!t)return;const e=lA(t.getAttribute(this.attributeName));return e!==this._defaultValue?e:void 0}}class mA extends aA{constructor(t,e){super(t,"tableBorderWidth",e)}_getValue(t){if(!t)return;const e=lA(t.getAttribute(this.attributeName));return e!==this._defaultValue?e:void 0}_getValueToSet(t){if((t=dA(t,"px"))!==this._defaultValue)return t}}class gA extends aA{constructor(t,e){super(t,"tableWidth",e)}_getValueToSet(t){if((t=dA(t,"px"))!==this._defaultValue)return t}}class fA extends aA{constructor(t,e){super(t,"tableHeight",e)}_getValueToSet(t){return(t=dA(t,"px"))===this._defaultValue?null:t}}class bA extends aA{constructor(t,e){super(t,"tableAlignment",e)}}const kA=/^(left|center|right)$/,wA=/^(left|none|right)$/;class _A extends pe{static get pluginName(){return"TablePropertiesEditing"}static get requires(){return[IC]}init(){const t=this.editor,e=t.model.schema,n=t.conversion;t.config.define("table.tableProperties.defaultProperties",{});const o=uA(t.config.get("table.tableProperties.defaultProperties"),{includeAlignmentProperty:!0});t.data.addStyleProcessorRules(Vp),function(t,e,n){const o={width:"tableBorderWidth",color:"tableBorderColor",style:"tableBorderStyle"};t.extend("table",{allowAttributes:Object.values(o)}),oA(e,"table",o,n),rA(e,{modelAttribute:o.color,styleName:"border-color"}),rA(e,{modelAttribute:o.style,styleName:"border-style"}),rA(e,{modelAttribute:o.width,styleName:"border-width"})}(e,n,{color:o.borderColor,style:o.borderStyle,width:o.borderWidth}),t.commands.add("tableBorderColor",new hA(t,o.borderColor)),t.commands.add("tableBorderStyle",new pA(t,o.borderStyle)),t.commands.add("tableBorderWidth",new mA(t,o.borderWidth)),function(t,e,n){t.extend("table",{allowAttributes:["tableAlignment"]}),e.for("downcast").attributeToAttribute({model:{name:"table",key:"tableAlignment"},view:t=>({key:"style",value:{float:"center"===t?"none":t}}),converterPriority:"high"}),e.for("upcast").attributeToAttribute({view:{name:/^(table|figure)$/,styles:{float:wA}},model:{key:"tableAlignment",value:t=>{let e=t.getStyle("float");return"none"===e&&(e="center"),e===n?null:e}}}).attributeToAttribute({view:{attributes:{align:kA}},model:{name:"table",key:"tableAlignment",value:t=>{const e=t.getAttribute("align");return e===n?null:e}}})}(e,n,o.alignment),t.commands.add("tableAlignment",new bA(t,o.alignment)),CA(e,n,{modelAttribute:"tableWidth",styleName:"width",defaultValue:o.width}),t.commands.add("tableWidth",new gA(t,o.width)),CA(e,n,{modelAttribute:"tableHeight",styleName:"height",defaultValue:o.height}),t.commands.add("tableHeight",new fA(t,o.height)),t.data.addStyleProcessorRules(Op),function(t,e,n){const{modelAttribute:o}=n;t.extend("table",{allowAttributes:[o]}),nA(e,{viewElement:"table",...n}),rA(e,n)}(e,n,{modelAttribute:"tableBackgroundColor",styleName:"background-color",defaultValue:o.backgroundColor}),t.commands.add("tableBackgroundColor",new cA(t,o.backgroundColor))}}function CA(t,e,n){const{modelAttribute:o}=n;t.extend("table",{allowAttributes:[o]}),nA(e,{viewElement:/^(table|figure)$/,...n}),iA(e,{modelElement:"table",...n})}var AA=n(4082),vA={attributes:{"data-cke":!0}};vA.setAttributes=is(),vA.insert=ns().bind(null,"head"),vA.domAPI=ts(),vA.insertStyleElement=ss();Qr()(AA.Z,vA);AA.Z&&AA.Z.locals&&AA.Z.locals;class yA extends Od{constructor(t,e){super(t);const n=this.bindTemplate;this.set("value",""),this.set("id"),this.set("isReadOnly",!1),this.set("hasError",!1),this.set("isFocused",!1),this.set("isEmpty",!0),this.set("ariaDescribedById"),this.options=e,this._dropdownView=this._createDropdownView(),this._inputView=this._createInputTextView(),this._stillTyping=!1,this.setTemplate({tag:"div",attributes:{class:["ck","ck-input-color",n.if("hasError","ck-error")],id:n.to("id"),"aria-invalid":n.if("hasError",!0),"aria-describedby":n.to("ariaDescribedById")},children:[this._dropdownView,this._inputView]}),this.on("change:value",((t,e,n)=>this._setInputValue(n)))}focus(){this._inputView.focus()}_createDropdownView(){const t=this.locale,e=t.t,n=this.bindTemplate,o=this._createColorGrid(t),i=nh(t),r=new Od,s=this._createRemoveColorButton();return r.setTemplate({tag:"span",attributes:{class:["ck","ck-input-color__button__preview"],style:{backgroundColor:n.to("value")}},children:[{tag:"span",attributes:{class:["ck","ck-input-color__button__preview__no-color-indicator",n.if("value","ck-hidden",(t=>""!=t))]}}]}),i.buttonView.extendTemplate({attributes:{class:"ck-input-color__button"}}),i.buttonView.children.add(r),i.buttonView.tooltip=e("Color picker"),i.panelPosition="rtl"===t.uiLanguageDirection?"se":"sw",i.panelView.children.add(s),i.panelView.children.add(o),i.bind("isEnabled").to(this,"isReadOnly",(t=>!t)),i}_createInputTextView(){const t=this.locale,e=new wh(t);return e.extendTemplate({on:{blur:e.bindTemplate.to("blur")}}),e.value=this.value,e.bind("isReadOnly","hasError").to(this),this.bind("isFocused","isEmpty").to(e),e.on("input",(()=>{const t=e.element.value,n=this.options.colorDefinitions.find((e=>t===e.label));this._stillTyping=!0,this.value=n&&n.color||t})),e.on("blur",(()=>{this._stillTyping=!1,this._setInputValue(e.element.value)})),e.delegate("input").to(this),e}_createRemoveColorButton(){const t=this.locale,e=t.t,n=new pu(t),o=this.options.defaultColorValue||"",i=e(o?"Restore default":"Remove color");return n.class="ck-input-color__remove-color",n.withText=!0,n.icon=Td.eraser,n.label=i,n.on("execute",(()=>{this.value=o,this._dropdownView.isOpen=!1,this.fire("input")})),n}_createColorGrid(t){const e=new Eu(t,{colorDefinitions:this.options.colorDefinitions,columns:this.options.columns});return e.on("execute",((t,e)=>{this.value=e.value,this._dropdownView.isOpen=!1,this.fire("input")})),e.bind("selectedColor").to(this,"value"),e}_setInputValue(t){if(!this._stillTyping){const e=xA(t),n=this.options.colorDefinitions.find((t=>e===xA(t.color)));this._inputView.value=n?n.label:t||""}}}function xA(t){return t.replace(/([(,])\s+/g,"$1").replace(/^\s+|\s+(?=[),\s]|$)/g,"").replace(/,|\s/g," ")}const EA=t=>""===t;function DA(t){return{none:t("None"),solid:t("Solid"),dotted:t("Dotted"),dashed:t("Dashed"),double:t("Double"),groove:t("Groove"),ridge:t("Ridge"),inset:t("Inset"),outset:t("Outset")}}function SA(t){return t('The color is invalid. Try "#FF0000" or "rgb(255,0,0)" or "red".')}function BA(t){return t('The value is invalid. Try "10px" or "2em" or simply "2".')}function TA(t){return t=t.trim(),EA(t)||_p(t)}function PA(t){return t=t.trim(),EA(t)||OA(t)||yp(t)||(e=t,xp.test(e));var e}function IA(t){return t=t.trim(),EA(t)||OA(t)||yp(t)}function RA(t,e){const n=new So,o=DA(t.t);for(const i in o){const r={type:"button",model:new Eh({_borderStyleValue:i,label:o[i],withText:!0})};"none"===i?r.model.bind("isOn").to(t,"borderStyle",(t=>"none"===e?!t:t===i)):r.model.bind("isOn").to(t,"borderStyle",(t=>t===i)),n.add(r)}return n}function zA(t){const{view:e,icons:n,toolbar:o,labels:i,propertyName:r,nameToValue:s,defaultValue:a}=t;for(const t in i){const c=new pu(e.locale);c.set({label:i[t],icon:n[t],tooltip:i[t]});const l=s?s(t):t;c.bind("isOn").to(e,r,(t=>{let e=t;return""===t&&a&&(e=a),l===e})),c.on("execute",(()=>{e[r]=l})),o.items.add(c)}}const FA=[{color:"hsl(0, 0%, 0%)",label:"Black"},{color:"hsl(0, 0%, 30%)",label:"Dim grey"},{color:"hsl(0, 0%, 60%)",label:"Grey"},{color:"hsl(0, 0%, 90%)",label:"Light grey"},{color:"hsl(0, 0%, 100%)",label:"White",hasBorder:!0},{color:"hsl(0, 75%, 60%)",label:"Red"},{color:"hsl(30, 75%, 60%)",label:"Orange"},{color:"hsl(60, 75%, 60%)",label:"Yellow"},{color:"hsl(90, 75%, 60%)",label:"Light green"},{color:"hsl(120, 75%, 60%)",label:"Green"},{color:"hsl(150, 75%, 60%)",label:"Aquamarine"},{color:"hsl(180, 75%, 60%)",label:"Turquoise"},{color:"hsl(210, 75%, 60%)",label:"Light blue"},{color:"hsl(240, 75%, 60%)",label:"Blue"},{color:"hsl(270, 75%, 60%)",label:"Purple"}];function NA(t){return(e,n,o)=>{const i=new yA(e.locale,{colorDefinitions:(r=t.colorConfig,r.map((t=>({color:t.model,label:t.label,options:{hasBorder:t.hasBorder}})))),columns:t.columns,defaultColorValue:t.defaultColorValue});var r;return i.set({id:n,ariaDescribedById:o}),i.bind("isReadOnly").to(e,"isEnabled",(t=>!t)),i.bind("hasError").to(e,"errorText",(t=>!!t)),i.on("input",(()=>{e.errorText=null})),e.bind("isEmpty","isFocused").to(i),i}}function OA(t){const e=parseFloat(t);return!Number.isNaN(e)&&t===String(e)}var MA=n(9865),VA={attributes:{"data-cke":!0}};VA.setAttributes=is(),VA.insert=ns().bind(null,"head"),VA.domAPI=ts(),VA.insertStyleElement=ss();Qr()(MA.Z,VA);MA.Z&&MA.Z.locals&&MA.Z.locals;class LA extends Od{constructor(t,e={}){super(t);const n=this.bindTemplate;this.set("class",e.class||null),this.children=this.createCollection(),e.children&&e.children.forEach((t=>this.children.add(t))),this.set("_role",null),this.set("_ariaLabelledBy",null),e.labelView&&this.set({_role:"group",_ariaLabelledBy:e.labelView.id}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-form__row",n.to("class")],role:n.to("_role"),"aria-labelledby":n.to("_ariaLabelledBy")},children:this.children})}}var HA=n(4880),qA={attributes:{"data-cke":!0}};qA.setAttributes=is(),qA.insert=ns().bind(null,"head"),qA.domAPI=ts(),qA.insertStyleElement=ss();Qr()(HA.Z,qA);HA.Z&&HA.Z.locals&&HA.Z.locals;var WA=n(198),jA={attributes:{"data-cke":!0}};jA.setAttributes=is(),jA.insert=ns().bind(null,"head"),jA.domAPI=ts(),jA.insertStyleElement=ss();Qr()(WA.Z,jA);WA.Z&&WA.Z.locals&&WA.Z.locals;var UA=n(9221),$A={attributes:{"data-cke":!0}};$A.setAttributes=is(),$A.insert=ns().bind(null,"head"),$A.domAPI=ts(),$A.insertStyleElement=ss();Qr()(UA.Z,$A);UA.Z&&UA.Z.locals&&UA.Z.locals;const GA={left:Td.objectLeft,center:Td.objectCenter,right:Td.objectRight};class KA extends Od{constructor(t,e){super(t),this.set({borderStyle:"",borderWidth:"",borderColor:"",backgroundColor:"",width:"",height:"",alignment:""}),this.options=e;const{borderStyleDropdown:n,borderWidthInput:o,borderColorInput:i,borderRowLabel:r}=this._createBorderFields(),{backgroundRowLabel:s,backgroundInput:a}=this._createBackgroundFields(),{widthInput:c,operatorLabel:l,heightInput:d,dimensionsLabel:u}=this._createDimensionFields(),{alignmentToolbar:h,alignmentLabel:p}=this._createAlignmentFields();this.focusTracker=new Pa,this.keystrokes=new Ia,this.children=this.createCollection(),this.borderStyleDropdown=n,this.borderWidthInput=o,this.borderColorInput=i,this.backgroundInput=a,this.widthInput=c,this.heightInput=d,this.alignmentToolbar=h;const{saveButtonView:m,cancelButtonView:g}=this._createActionButtons();this.saveButtonView=m,this.cancelButtonView=g,this._focusables=new zd,this._focusCycler=new Au({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.children.add(new gh(t,{label:this.t("Table properties")})),this.children.add(new LA(t,{labelView:r,children:[r,n,i,o],class:"ck-table-form__border-row"})),this.children.add(new LA(t,{labelView:s,children:[s,a],class:"ck-table-form__background-row"})),this.children.add(new LA(t,{children:[new LA(t,{labelView:u,children:[u,c,l,d],class:"ck-table-form__dimensions-row"}),new LA(t,{labelView:p,children:[p,h],class:"ck-table-properties-form__alignment-row"})]})),this.children.add(new LA(t,{children:[this.saveButtonView,this.cancelButtonView],class:"ck-table-form__action-row"})),this.setTemplate({tag:"form",attributes:{class:["ck","ck-form","ck-table-form","ck-table-properties-form"],tabindex:"-1"},children:this.children})}render(){super.render(),Rd({view:this}),[this.borderStyleDropdown,this.borderColorInput,this.borderWidthInput,this.backgroundInput,this.widthInput,this.heightInput,this.alignmentToolbar,this.saveButtonView,this.cancelButtonView].forEach((t=>{this._focusables.add(t),this.focusTracker.add(t.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createBorderFields(){const t=this.options.defaultTableProperties,e={style:t.borderStyle,width:t.borderWidth,color:t.borderColor},n=NA({colorConfig:this.options.borderColors,columns:5,defaultColorValue:e.color}),o=this.locale,i=this.t,r=new dh(o);r.text=i("Border");const s=DA(this.t),a=new Ah(o,yh);a.set({label:i("Style"),class:"ck-table-form__border-style"}),a.fieldView.buttonView.set({isOn:!1,withText:!0,tooltip:i("Style")}),a.fieldView.buttonView.bind("label").to(this,"borderStyle",(t=>s[t||"none"])),a.fieldView.on("execute",(t=>{this.borderStyle=t.source._borderStyleValue})),a.bind("isEmpty").to(this,"borderStyle",(t=>!t)),ih(a.fieldView,RA(this,e.style));const c=new Ah(o,vh);c.set({label:i("Width"),class:"ck-table-form__border-width"}),c.fieldView.bind("value").to(this,"borderWidth"),c.bind("isEnabled").to(this,"borderStyle",ZA),c.fieldView.on("input",(()=>{this.borderWidth=c.fieldView.element.value}));const l=new Ah(o,n);return l.set({label:i("Color"),class:"ck-table-form__border-color"}),l.fieldView.bind("value").to(this,"borderColor"),l.bind("isEnabled").to(this,"borderStyle",ZA),l.fieldView.on("input",(()=>{this.borderColor=l.fieldView.value})),this.on("change:borderStyle",((t,n,o,i)=>{ZA(o)||(this.borderColor="",this.borderWidth=""),ZA(i)||(this.borderColor=e.color,this.borderWidth=e.width)})),{borderRowLabel:r,borderStyleDropdown:a,borderColorInput:l,borderWidthInput:c}}_createBackgroundFields(){const t=this.locale,e=this.t,n=new dh(t);n.text=e("Background");const o=NA({colorConfig:this.options.backgroundColors,columns:5,defaultColorValue:this.options.defaultTableProperties.backgroundColor}),i=new Ah(t,o);return i.set({label:e("Color"),class:"ck-table-properties-form__background"}),i.fieldView.bind("value").to(this,"backgroundColor"),i.fieldView.on("input",(()=>{this.backgroundColor=i.fieldView.value})),{backgroundRowLabel:n,backgroundInput:i}}_createDimensionFields(){const t=this.locale,e=this.t,n=new dh(t);n.text=e("Dimensions");const o=new Ah(t,vh);o.set({label:e("Width"),class:"ck-table-form__dimensions-row__width"}),o.fieldView.bind("value").to(this,"width"),o.fieldView.on("input",(()=>{this.width=o.fieldView.element.value}));const i=new Od(t);i.setTemplate({tag:"span",attributes:{class:["ck-table-form__dimension-operator"]},children:[{text:"×"}]});const r=new Ah(t,vh);return r.set({label:e("Height"),class:"ck-table-form__dimensions-row__height"}),r.fieldView.bind("value").to(this,"height"),r.fieldView.on("input",(()=>{this.height=r.fieldView.element.value})),{dimensionsLabel:n,widthInput:o,operatorLabel:i,heightInput:r}}_createAlignmentFields(){const t=this.locale,e=this.t,n=new dh(t);n.text=e("Alignment");const o=new Wu(t);return o.set({isCompact:!0,ariaLabel:e("Table alignment toolbar")}),zA({view:this,icons:GA,toolbar:o,labels:this._alignmentLabels,propertyName:"alignment",defaultValue:this.options.defaultTableProperties.alignment}),{alignmentLabel:n,alignmentToolbar:o}}_createActionButtons(){const t=this.locale,e=this.t,n=new pu(t),o=new pu(t),i=[this.borderWidthInput,this.borderColorInput,this.backgroundInput,this.widthInput,this.heightInput];return n.set({label:e("Save"),icon:Td.check,class:"ck-button-save",type:"submit",withText:!0}),n.bind("isEnabled").toMany(i,"errorText",((...t)=>t.every((t=>!t)))),o.set({label:e("Cancel"),icon:Td.cancel,class:"ck-button-cancel",withText:!0}),o.delegate("execute").to(this,"cancel"),{saveButtonView:n,cancelButtonView:o}}get _alignmentLabels(){const t=this.locale,e=this.t,n=e("Align table to the left"),o=e("Center table"),i=e("Align table to the right");return"rtl"===t.uiLanguageDirection?{right:i,center:o,left:n}:{left:n,center:o,right:i}}}function ZA(t){return"none"!==t}const JA=Ih.defaultPositions,YA=[JA.northArrowSouth,JA.northArrowSouthWest,JA.northArrowSouthEast,JA.southArrowNorth,JA.southArrowNorthWest,JA.southArrowNorthEast,JA.viewportStickyNorth];function QA(t,e){const n=t.plugins.get("ContextualBalloon");if(tA(t.editing.view.document.selection)){let o;o="cell"===e?tv(t):XA(t),n.updatePosition(o)}}function XA(t){const e=t.model.document.selection.getFirstPosition().findAncestor("table"),n=t.editing.mapper.toViewElement(e);return{target:t.editing.view.domConverter.viewToDom(n),positions:YA}}function tv(t){const e=t.editing.mapper,n=t.editing.view.domConverter,o=t.model.document.selection;if(o.rangeCount>1)return{target:()=>function(t,e){const n=e.editing.mapper,o=e.editing.view.domConverter,i=Array.from(t).map((t=>{const e=ev(t.start),i=n.toViewElement(e);return new ya(o.viewToDom(i))}));return ya.getBoundingRect(i)}(o.getRanges(),t),positions:YA};const i=ev(o.getFirstPosition()),r=e.toViewElement(i);return{target:n.viewToDom(r),positions:YA}}function ev(t){return t.nodeAfter&&t.nodeAfter.is("element","tableCell")?t.nodeAfter:t.findAncestor("tableCell")}const nv={borderStyle:"tableBorderStyle",borderColor:"tableBorderColor",borderWidth:"tableBorderWidth",backgroundColor:"tableBackgroundColor",width:"tableWidth",height:"tableHeight",alignment:"tableAlignment"};class ov extends pe{static get requires(){return[Vh]}static get pluginName(){return"TablePropertiesUI"}constructor(t){super(t),t.config.define("table.tableProperties",{borderColors:FA,backgroundColors:FA})}init(){const t=this.editor,e=t.t;this._defaultTableProperties=uA(t.config.get("table.tableProperties.defaultProperties"),{includeAlignmentProperty:!0}),this._balloon=t.plugins.get(Vh),this.view=this._createPropertiesView(),this._undoStepBatch=null,t.ui.componentFactory.add("tableProperties",(n=>{const o=new pu(n);o.set({label:e("Table properties"),icon:'',tooltip:!0}),this.listenTo(o,"execute",(()=>this._showView()));const i=Object.values(nv).map((e=>t.commands.get(e)));return o.bind("isEnabled").toMany(i,"isEnabled",((...t)=>t.some((t=>t)))),o}))}destroy(){super.destroy(),this.view.destroy()}_createPropertiesView(){const t=this.editor,e=t.config.get("table.tableProperties"),n=ku(e.borderColors),o=bu(t.locale,n),i=ku(e.backgroundColors),r=bu(t.locale,i),s=new KA(t.locale,{borderColors:o,backgroundColors:r,defaultTableProperties:this._defaultTableProperties}),a=t.t;s.render(),this.listenTo(s,"submit",(()=>{this._hideView()})),this.listenTo(s,"cancel",(()=>{this._undoStepBatch.operations.length&&t.execute("undo",this._undoStepBatch),this._hideView()})),s.keystrokes.set("Esc",((t,e)=>{this._hideView(),e()})),Pd({emitter:s,activator:()=>this._isViewInBalloon,contextElements:[this._balloon.view.element],callback:()=>this._hideView()});const c=SA(a),l=BA(a);return s.on("change:borderStyle",this._getPropertyChangeCallback("tableBorderStyle",this._defaultTableProperties.borderStyle)),s.on("change:borderColor",this._getValidatedPropertyChangeCallback({viewField:s.borderColorInput,commandName:"tableBorderColor",errorText:c,validator:TA,defaultValue:this._defaultTableProperties.borderColor})),s.on("change:borderWidth",this._getValidatedPropertyChangeCallback({viewField:s.borderWidthInput,commandName:"tableBorderWidth",errorText:l,validator:IA,defaultValue:this._defaultTableProperties.borderWidth})),s.on("change:backgroundColor",this._getValidatedPropertyChangeCallback({viewField:s.backgroundInput,commandName:"tableBackgroundColor",errorText:c,validator:TA,defaultValue:this._defaultTableProperties.backgroundColor})),s.on("change:width",this._getValidatedPropertyChangeCallback({viewField:s.widthInput,commandName:"tableWidth",errorText:l,validator:PA,defaultValue:this._defaultTableProperties.width})),s.on("change:height",this._getValidatedPropertyChangeCallback({viewField:s.heightInput,commandName:"tableHeight",errorText:l,validator:PA,defaultValue:this._defaultTableProperties.height})),s.on("change:alignment",this._getPropertyChangeCallback("tableAlignment",this._defaultTableProperties.alignment)),s}_fillViewFormFromCommandValues(){const t=this.editor.commands,e=t.get("tableBorderStyle");Object.entries(nv).map((([e,n])=>{const o=this._defaultTableProperties[e]||"";return[e,t.get(n).value||o]})).forEach((([t,n])=>{("borderColor"!==t&&"borderWidth"!==t||"none"!==e.value)&&this.view.set(t,n)}))}_showView(){const t=this.editor;this.listenTo(t.ui,"update",(()=>{this._updateView()})),this._fillViewFormFromCommandValues(),this._balloon.add({view:this.view,position:XA(t)}),this._undoStepBatch=t.model.createBatch(),this.view.focus()}_hideView(){const t=this.editor;this.stopListening(t.ui,"update"),this.view.saveButtonView.focus(),this._balloon.remove(this.view),this.editor.editing.view.focus()}_updateView(){const t=this.editor;tA(t.editing.view.document.selection)?this._isViewVisible&&QA(t,"table"):this._hideView()}get _isViewVisible(){return this._balloon.visibleView===this.view}get _isViewInBalloon(){return this._balloon.hasView(this.view)}_getPropertyChangeCallback(t,e){return(n,o,i,r)=>{(r||e!==i)&&this.editor.execute(t,{value:i,batch:this._undoStepBatch})}}_getValidatedPropertyChangeCallback(t){const{commandName:e,viewField:n,validator:o,errorText:i,defaultValue:r}=t,s=pa((()=>{n.errorText=i}),500);return(t,i,a,c)=>{s.cancel(),(c||r!==a)&&(o(a)?(this.editor.execute(e,{value:a,batch:this._undoStepBatch}),n.errorText=null):s())}}}var iv=n(5737),rv={attributes:{"data-cke":!0}};rv.setAttributes=is(),rv.insert=ns().bind(null,"head"),rv.domAPI=ts(),rv.insertStyleElement=ss();Qr()(iv.Z,rv);iv.Z&&iv.Z.locals&&iv.Z.locals;const sv={left:Td.alignLeft,center:Td.alignCenter,right:Td.alignRight,justify:Td.alignJustify,top:Td.alignTop,middle:Td.alignMiddle,bottom:Td.alignBottom};class av extends Od{constructor(t,e){super(t),this.set({borderStyle:"",borderWidth:"",borderColor:"",padding:"",backgroundColor:"",width:"",height:"",horizontalAlignment:"",verticalAlignment:""}),this.options=e;const{borderStyleDropdown:n,borderWidthInput:o,borderColorInput:i,borderRowLabel:r}=this._createBorderFields(),{backgroundRowLabel:s,backgroundInput:a}=this._createBackgroundFields(),{widthInput:c,operatorLabel:l,heightInput:d,dimensionsLabel:u}=this._createDimensionFields(),{horizontalAlignmentToolbar:h,verticalAlignmentToolbar:p,alignmentLabel:m}=this._createAlignmentFields();this.focusTracker=new Pa,this.keystrokes=new Ia,this.children=this.createCollection(),this.borderStyleDropdown=n,this.borderWidthInput=o,this.borderColorInput=i,this.backgroundInput=a,this.paddingInput=this._createPaddingField(),this.widthInput=c,this.heightInput=d,this.horizontalAlignmentToolbar=h,this.verticalAlignmentToolbar=p;const{saveButtonView:g,cancelButtonView:f}=this._createActionButtons();this.saveButtonView=g,this.cancelButtonView=f,this._focusables=new zd,this._focusCycler=new Au({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.children.add(new gh(t,{label:this.t("Cell properties")})),this.children.add(new LA(t,{labelView:r,children:[r,n,i,o],class:"ck-table-form__border-row"})),this.children.add(new LA(t,{labelView:s,children:[s,a],class:"ck-table-form__background-row"})),this.children.add(new LA(t,{children:[new LA(t,{labelView:u,children:[u,c,l,d],class:"ck-table-form__dimensions-row"}),new LA(t,{children:[this.paddingInput],class:"ck-table-cell-properties-form__padding-row"})]})),this.children.add(new LA(t,{labelView:m,children:[m,h,p],class:"ck-table-cell-properties-form__alignment-row"})),this.children.add(new LA(t,{children:[this.saveButtonView,this.cancelButtonView],class:"ck-table-form__action-row"})),this.setTemplate({tag:"form",attributes:{class:["ck","ck-form","ck-table-form","ck-table-cell-properties-form"],tabindex:"-1"},children:this.children})}render(){super.render(),Rd({view:this}),[this.borderStyleDropdown,this.borderColorInput,this.borderWidthInput,this.backgroundInput,this.widthInput,this.heightInput,this.paddingInput,this.horizontalAlignmentToolbar,this.verticalAlignmentToolbar,this.saveButtonView,this.cancelButtonView].forEach((t=>{this._focusables.add(t),this.focusTracker.add(t.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createBorderFields(){const t=this.options.defaultTableCellProperties,e={style:t.borderStyle,width:t.borderWidth,color:t.borderColor},n=NA({colorConfig:this.options.borderColors,columns:5,defaultColorValue:e.color}),o=this.locale,i=this.t,r=new dh(o);r.text=i("Border");const s=DA(i),a=new Ah(o,yh);a.set({label:i("Style"),class:"ck-table-form__border-style"}),a.fieldView.buttonView.set({isOn:!1,withText:!0,tooltip:i("Style")}),a.fieldView.buttonView.bind("label").to(this,"borderStyle",(t=>s[t||"none"])),a.fieldView.on("execute",(t=>{this.borderStyle=t.source._borderStyleValue})),a.bind("isEmpty").to(this,"borderStyle",(t=>!t)),ih(a.fieldView,RA(this,e.style));const c=new Ah(o,vh);c.set({label:i("Width"),class:"ck-table-form__border-width"}),c.fieldView.bind("value").to(this,"borderWidth"),c.bind("isEnabled").to(this,"borderStyle",cv),c.fieldView.on("input",(()=>{this.borderWidth=c.fieldView.element.value}));const l=new Ah(o,n);return l.set({label:i("Color"),class:"ck-table-form__border-color"}),l.fieldView.bind("value").to(this,"borderColor"),l.bind("isEnabled").to(this,"borderStyle",cv),l.fieldView.on("input",(()=>{this.borderColor=l.fieldView.value})),this.on("change:borderStyle",((t,n,o,i)=>{cv(o)||(this.borderColor="",this.borderWidth=""),cv(i)||(this.borderColor=e.color,this.borderWidth=e.width)})),{borderRowLabel:r,borderStyleDropdown:a,borderColorInput:l,borderWidthInput:c}}_createBackgroundFields(){const t=this.locale,e=this.t,n=new dh(t);n.text=e("Background");const o=NA({colorConfig:this.options.backgroundColors,columns:5,defaultColorValue:this.options.defaultTableCellProperties.backgroundColor}),i=new Ah(t,o);return i.set({label:e("Color"),class:"ck-table-cell-properties-form__background"}),i.fieldView.bind("value").to(this,"backgroundColor"),i.fieldView.on("input",(()=>{this.backgroundColor=i.fieldView.value})),{backgroundRowLabel:n,backgroundInput:i}}_createDimensionFields(){const t=this.locale,e=this.t,n=new dh(t);n.text=e("Dimensions");const o=new Ah(t,vh);o.set({label:e("Width"),class:"ck-table-form__dimensions-row__width"}),o.fieldView.bind("value").to(this,"width"),o.fieldView.on("input",(()=>{this.width=o.fieldView.element.value}));const i=new Od(t);i.setTemplate({tag:"span",attributes:{class:["ck-table-form__dimension-operator"]},children:[{text:"×"}]});const r=new Ah(t,vh);return r.set({label:e("Height"),class:"ck-table-form__dimensions-row__height"}),r.fieldView.bind("value").to(this,"height"),r.fieldView.on("input",(()=>{this.height=r.fieldView.element.value})),{dimensionsLabel:n,widthInput:o,operatorLabel:i,heightInput:r}}_createPaddingField(){const t=this.locale,e=this.t,n=new Ah(t,vh);return n.set({label:e("Padding"),class:"ck-table-cell-properties-form__padding"}),n.fieldView.bind("value").to(this,"padding"),n.fieldView.on("input",(()=>{this.padding=n.fieldView.element.value})),n}_createAlignmentFields(){const t=this.locale,e=this.t,n=new dh(t);n.text=e("Table cell text alignment");const o=new Wu(t),i="rtl"===this.locale.contentLanguageDirection;o.set({isCompact:!0,ariaLabel:e("Horizontal text alignment toolbar")}),zA({view:this,icons:sv,toolbar:o,labels:this._horizontalAlignmentLabels,propertyName:"horizontalAlignment",nameToValue:t=>{if(i){if("left"===t)return"right";if("right"===t)return"left"}return t},defaultValue:this.options.defaultTableCellProperties.horizontalAlignment});const r=new Wu(t);return r.set({isCompact:!0,ariaLabel:e("Vertical text alignment toolbar")}),zA({view:this,icons:sv,toolbar:r,labels:this._verticalAlignmentLabels,propertyName:"verticalAlignment",defaultValue:this.options.defaultTableCellProperties.verticalAlignment}),{horizontalAlignmentToolbar:o,verticalAlignmentToolbar:r,alignmentLabel:n}}_createActionButtons(){const t=this.locale,e=this.t,n=new pu(t),o=new pu(t),i=[this.borderWidthInput,this.borderColorInput,this.backgroundInput,this.paddingInput];return n.set({label:e("Save"),icon:Td.check,class:"ck-button-save",type:"submit",withText:!0}),n.bind("isEnabled").toMany(i,"errorText",((...t)=>t.every((t=>!t)))),o.set({label:e("Cancel"),icon:Td.cancel,class:"ck-button-cancel",withText:!0}),o.delegate("execute").to(this,"cancel"),{saveButtonView:n,cancelButtonView:o}}get _horizontalAlignmentLabels(){const t=this.locale,e=this.t,n=e("Align cell text to the left"),o=e("Align cell text to the center"),i=e("Align cell text to the right"),r=e("Justify cell text");return"rtl"===t.uiLanguageDirection?{right:i,center:o,left:n,justify:r}:{left:n,center:o,right:i,justify:r}}get _verticalAlignmentLabels(){const t=this.t;return{top:t("Align cell text to the top"),middle:t("Align cell text to the middle"),bottom:t("Align cell text to the bottom")}}}function cv(t){return"none"!==t}const lv={borderStyle:"tableCellBorderStyle",borderColor:"tableCellBorderColor",borderWidth:"tableCellBorderWidth",width:"tableCellWidth",height:"tableCellHeight",padding:"tableCellPadding",backgroundColor:"tableCellBackgroundColor",horizontalAlignment:"tableCellHorizontalAlignment",verticalAlignment:"tableCellVerticalAlignment"};class dv extends pe{static get requires(){return[Vh]}static get pluginName(){return"TableCellPropertiesUI"}constructor(t){super(t),t.config.define("table.tableCellProperties",{borderColors:FA,backgroundColors:FA})}init(){const t=this.editor,e=t.t;this._defaultTableCellProperties=uA(t.config.get("table.tableCellProperties.defaultProperties"),{includeVerticalAlignmentProperty:!0,includeHorizontalAlignmentProperty:!0,includePaddingProperty:!0,isRightToLeftContent:"rtl"===t.locale.contentLanguageDirection}),this._balloon=t.plugins.get(Vh),this.view=this._createPropertiesView(),this._undoStepBatch=null,t.ui.componentFactory.add("tableCellProperties",(n=>{const o=new pu(n);o.set({label:e("Cell properties"),icon:'',tooltip:!0}),this.listenTo(o,"execute",(()=>this._showView()));const i=Object.values(lv).map((e=>t.commands.get(e)));return o.bind("isEnabled").toMany(i,"isEnabled",((...t)=>t.some((t=>t)))),o}))}destroy(){super.destroy(),this.view.destroy()}_createPropertiesView(){const t=this.editor,e=t.editing.view.document,n=t.config.get("table.tableCellProperties"),o=ku(n.borderColors),i=bu(t.locale,o),r=ku(n.backgroundColors),s=bu(t.locale,r),a=new av(t.locale,{borderColors:i,backgroundColors:s,defaultTableCellProperties:this._defaultTableCellProperties}),c=t.t;a.render(),this.listenTo(a,"submit",(()=>{this._hideView()})),this.listenTo(a,"cancel",(()=>{this._undoStepBatch.operations.length&&t.execute("undo",this._undoStepBatch),this._hideView()})),a.keystrokes.set("Esc",((t,e)=>{this._hideView(),e()})),this.listenTo(t.ui,"update",(()=>{tA(e.selection)?this._isViewVisible&&QA(t,"cell"):this._hideView()})),Pd({emitter:a,activator:()=>this._isViewInBalloon,contextElements:[this._balloon.view.element],callback:()=>this._hideView()});const l=SA(c),d=BA(c);return a.on("change:borderStyle",this._getPropertyChangeCallback("tableCellBorderStyle",this._defaultTableCellProperties.borderStyle)),a.on("change:borderColor",this._getValidatedPropertyChangeCallback({viewField:a.borderColorInput,commandName:"tableCellBorderColor",errorText:l,validator:TA,defaultValue:this._defaultTableCellProperties.borderColor})),a.on("change:borderWidth",this._getValidatedPropertyChangeCallback({viewField:a.borderWidthInput,commandName:"tableCellBorderWidth",errorText:d,validator:IA,defaultValue:this._defaultTableCellProperties.borderWidth})),a.on("change:padding",this._getValidatedPropertyChangeCallback({viewField:a.paddingInput,commandName:"tableCellPadding",errorText:d,validator:PA,defaultValue:this._defaultTableCellProperties.padding})),a.on("change:width",this._getValidatedPropertyChangeCallback({viewField:a.widthInput,commandName:"tableCellWidth",errorText:d,validator:PA,defaultValue:this._defaultTableCellProperties.width})),a.on("change:height",this._getValidatedPropertyChangeCallback({viewField:a.heightInput,commandName:"tableCellHeight",errorText:d,validator:PA,defaultValue:this._defaultTableCellProperties.height})),a.on("change:backgroundColor",this._getValidatedPropertyChangeCallback({viewField:a.backgroundInput,commandName:"tableCellBackgroundColor",errorText:l,validator:TA,defaultValue:this._defaultTableCellProperties.backgroundColor})),a.on("change:horizontalAlignment",this._getPropertyChangeCallback("tableCellHorizontalAlignment",this._defaultTableCellProperties.horizontalAlignment)),a.on("change:verticalAlignment",this._getPropertyChangeCallback("tableCellVerticalAlignment",this._defaultTableCellProperties.verticalAlignment)),a}_fillViewFormFromCommandValues(){const t=this.editor.commands,e=t.get("tableCellBorderStyle");Object.entries(lv).map((([e,n])=>{const o=this._defaultTableCellProperties[e]||"";return[e,t.get(n).value||o]})).forEach((([t,n])=>{("borderColor"!==t&&"borderWidth"!==t||"none"!==e.value)&&this.view.set(t,n)}))}_showView(){const t=this.editor;this._fillViewFormFromCommandValues(),this._balloon.add({view:this.view,position:tv(t)}),this._undoStepBatch=t.model.createBatch(),this.view.focus()}_hideView(){if(!this._isViewInBalloon)return;const t=this.editor;this.stopListening(t.ui,"update"),this.view.saveButtonView.focus(),this._balloon.remove(this.view),this.editor.editing.view.focus()}get _isViewVisible(){return this._balloon.visibleView===this.view}get _isViewInBalloon(){return this._balloon.hasView(this.view)}_getPropertyChangeCallback(t,e){return(n,o,i,r)=>{(r||e!==i)&&this.editor.execute(t,{value:i,batch:this._undoStepBatch})}}_getValidatedPropertyChangeCallback(t){const{commandName:e,viewField:n,validator:o,errorText:i,defaultValue:r}=t,s=pa((()=>{n.errorText=i}),500);return(t,i,a,c)=>{s.cancel(),(c||r!==a)&&(o(a)?(this.editor.execute(e,{value:a,batch:this._undoStepBatch}),n.errorText=null):s())}}}class uv extends ge{constructor(t,e,n){super(t),this.attributeName=e,this._defaultValue=n}refresh(){const t=z_(this.editor.model.document.selection);this.isEnabled=!!t.length,this.value=this._getSingleValue(t)}execute(t={}){const{value:e,batch:n}=t,o=this.editor.model,i=z_(o.document.selection),r=this._getValueToSet(e);o.enqueueChange(n,(t=>{r?i.forEach((e=>t.setAttribute(this.attributeName,r,e))):i.forEach((e=>t.removeAttribute(this.attributeName,e)))}))}_getAttribute(t){if(!t)return;const e=t.getAttribute(this.attributeName);return e!==this._defaultValue?e:void 0}_getValueToSet(t){if(t!==this._defaultValue)return t}_getSingleValue(t){const e=this._getAttribute(t[0]);return t.every((t=>this._getAttribute(t)===e))?e:void 0}}class hv extends uv{constructor(t,e){super(t,"tableCellPadding",e)}_getAttribute(t){if(!t)return;const e=lA(t.getAttribute(this.attributeName));return e!==this._defaultValue?e:void 0}_getValueToSet(t){if((t=dA(t,"px"))!==this._defaultValue)return t}}class pv extends uv{constructor(t,e){super(t,"tableCellWidth",e)}_getValueToSet(t){if((t=dA(t,"px"))!==this._defaultValue)return t}}class mv extends uv{constructor(t,e){super(t,"tableCellHeight",e)}_getValueToSet(t){return(t=dA(t,"px"))===this._defaultValue?null:t}}class gv extends uv{constructor(t,e){super(t,"tableCellBackgroundColor",e)}}class fv extends uv{constructor(t,e){super(t,"tableCellVerticalAlignment",e)}}class bv extends uv{constructor(t,e){super(t,"tableCellHorizontalAlignment",e)}}class kv extends uv{constructor(t,e){super(t,"tableCellBorderStyle",e)}_getAttribute(t){if(!t)return;const e=lA(t.getAttribute(this.attributeName));return e!==this._defaultValue?e:void 0}}class wv extends uv{constructor(t,e){super(t,"tableCellBorderColor",e)}_getAttribute(t){if(!t)return;const e=lA(t.getAttribute(this.attributeName));return e!==this._defaultValue?e:void 0}}class _v extends uv{constructor(t,e){super(t,"tableCellBorderWidth",e)}_getAttribute(t){if(!t)return;const e=lA(t.getAttribute(this.attributeName));return e!==this._defaultValue?e:void 0}_getValueToSet(t){if((t=dA(t,"px"))!==this._defaultValue)return t}}const Cv=/^(top|middle|bottom)$/,Av=/^(left|center|right|justify)$/;class vv extends pe{static get pluginName(){return"TableCellPropertiesEditing"}static get requires(){return[IC]}init(){const t=this.editor,e=t.model.schema,n=t.conversion;t.config.define("table.tableCellProperties.defaultProperties",{});const o=uA(t.config.get("table.tableCellProperties.defaultProperties"),{includeVerticalAlignmentProperty:!0,includeHorizontalAlignmentProperty:!0,includePaddingProperty:!0,isRightToLeftContent:"rtl"===t.locale.contentLanguageDirection});t.data.addStyleProcessorRules(Vp),function(t,e,n){const o={width:"tableCellBorderWidth",color:"tableCellBorderColor",style:"tableCellBorderStyle"};t.extend("tableCell",{allowAttributes:Object.values(o)}),oA(e,"td",o,n),oA(e,"th",o,n),iA(e,{modelElement:"tableCell",modelAttribute:o.style,styleName:"border-style"}),iA(e,{modelElement:"tableCell",modelAttribute:o.color,styleName:"border-color"}),iA(e,{modelElement:"tableCell",modelAttribute:o.width,styleName:"border-width"})}(e,n,{color:o.borderColor,style:o.borderStyle,width:o.borderWidth}),t.commands.add("tableCellBorderStyle",new kv(t,o.borderStyle)),t.commands.add("tableCellBorderColor",new wv(t,o.borderColor)),t.commands.add("tableCellBorderWidth",new _v(t,o.borderWidth)),yv(e,n,{modelAttribute:"tableCellWidth",styleName:"width",defaultValue:o.width}),t.commands.add("tableCellWidth",new pv(t,o.width)),yv(e,n,{modelAttribute:"tableCellHeight",styleName:"height",defaultValue:o.height}),t.commands.add("tableCellHeight",new mv(t,o.height)),t.data.addStyleProcessorRules(Jp),yv(e,n,{modelAttribute:"tableCellPadding",styleName:"padding",reduceBoxSides:!0,defaultValue:o.padding}),t.commands.add("tableCellPadding",new hv(t,o.padding)),t.data.addStyleProcessorRules(Op),yv(e,n,{modelAttribute:"tableCellBackgroundColor",styleName:"background-color",defaultValue:o.backgroundColor}),t.commands.add("tableCellBackgroundColor",new gv(t,o.backgroundColor)),function(t,e,n){t.extend("tableCell",{allowAttributes:["tableCellHorizontalAlignment"]}),e.for("downcast").attributeToAttribute({model:{name:"tableCell",key:"tableCellHorizontalAlignment"},view:t=>({key:"style",value:{"text-align":t}})}),e.for("upcast").attributeToAttribute({view:{name:/^(td|th)$/,styles:{"text-align":Av}},model:{key:"tableCellHorizontalAlignment",value:t=>{const e=t.getStyle("text-align");return e===n?null:e}}}).attributeToAttribute({view:{name:/^(td|th)$/,attributes:{align:Av}},model:{key:"tableCellHorizontalAlignment",value:t=>{const e=t.getAttribute("align");return e===n?null:e}}})}(e,n,o.horizontalAlignment),t.commands.add("tableCellHorizontalAlignment",new bv(t,o.horizontalAlignment)),function(t,e,n){t.extend("tableCell",{allowAttributes:["tableCellVerticalAlignment"]}),e.for("downcast").attributeToAttribute({model:{name:"tableCell",key:"tableCellVerticalAlignment"},view:t=>({key:"style",value:{"vertical-align":t}})}),e.for("upcast").attributeToAttribute({view:{name:/^(td|th)$/,styles:{"vertical-align":Cv}},model:{key:"tableCellVerticalAlignment",value:t=>{const e=t.getStyle("vertical-align");return e===n?null:e}}}).attributeToAttribute({view:{name:/^(td|th)$/,attributes:{valign:Cv}},model:{key:"tableCellVerticalAlignment",value:t=>{const e=t.getAttribute("valign");return e===n?null:e}}})}(e,n,o.verticalAlignment),t.commands.add("tableCellVerticalAlignment",new fv(t,o.verticalAlignment))}}function yv(t,e,n){const{modelAttribute:o}=n;t.extend("tableCell",{allowAttributes:[o]}),nA(e,{viewElement:/^(td|th)$/,...n}),iA(e,{modelElement:"tableCell",...n})}function xv(t,e){if(!t.childCount)return;const n=new pp(t.document),o=function(t,e){const n=e.createRangeIn(t),o=new Wo({name:/^p|h\d+$/,styles:{"mso-list":/.*/}}),i=[];for(const t of n)if("elementStart"===t.type&&o.match(t.item)){const e=Sv(t.item);i.push({element:t.item,id:e.id,order:e.order,indent:e.indent})}return i}(t,n);if(!o.length)return;let i=null,r=1;o.forEach(((t,s)=>{const a=function(t,e){if(!t)return!0;if(t.id!==e.id)return e.indent-t.indent!=1;const n=e.element.previousSibling;if(!n)return!0;return o=n,!(o.is("element","ol")||o.is("element","ul"));var o}(o[s-1],t),c=a?null:o[s-1],l=(u=t,(d=c)?u.indent-d.indent:u.indent-1);var d,u;if(a&&(i=null,r=1),!i||0!==l){const o=function(t,e){const n=new RegExp(`@list l${t.id}:level${t.indent}\\s*({[^}]*)`,"gi"),o=/mso-level-number-format:([^;]{0,100});/gi,i=/mso-level-start-at:\s{0,100}([0-9]{0,10})\s{0,100};/gi,r=n.exec(e);let s="decimal",a="ol",c=null;if(r&&r[1]){const e=o.exec(r[1]);if(e&&e[1]&&(s=e[1].trim(),a="bullet"!==s&&"image"!==s?"ol":"ul"),"bullet"===s){const e=function(t){const e=function(t){if(t.getChild(0).is("$text"))return null;for(const e of t.getChildren()){if(!e.is("element","span"))continue;const t=e.getChild(0);return t.is("$text")?t:t.getChild(0)}}(t);if(!e)return null;const n=e._data;if("o"===n)return"circle";if("·"===n)return"disc";if("§"===n)return"square";return null}(t.element);e&&(s=e)}else{const t=i.exec(r[1]);t&&t[1]&&(c=parseInt(t[1]))}}return{type:a,startIndex:c,style:Ev(s)}}(t,e);if(i){if(t.indent>r){const t=i.getChild(i.childCount-1),e=t.getChild(t.childCount-1);i=Dv(o,e,n),r+=1}else if(t.indent1&&n.setAttribute("start",t.startIndex,i),i}function Sv(t){const e={},n=t.getStyle("mso-list");if(n){const t=n.match(/(^|\s{1,100})l(\d+)/i),o=n.match(/\s{0,100}lfo(\d+)/i),i=n.match(/\s{0,100}level(\d+)/i);t&&o&&i&&(e.id=t[2],e.order=o[1],e.indent=i[1])}return e}const Bv=/id=("|')docs-internal-guid-[-0-9a-f]+("|')/i;class Tv{constructor(t){this.document=t}isActive(t){return Bv.test(t)}execute(t){const e=new pp(this.document),{body:n}=t._parsedData;!function(t,e){for(const n of t.getChildren())if(n.is("element","b")&&"normal"===n.getStyle("font-weight")){const o=t.getChildIndex(n);e.remove(n),e.insertChild(o,n.getChildren(),t)}}(n,e),function(t,e){for(const n of e.createRangeIn(t)){const t=n.item;if(t.is("element","li")){const n=t.getChild(0);n&&n.is("element","p")&&e.unwrapElement(n)}}}(n,e),t.content=n}}function Pv(t,e){if(!t.childCount)return;const n=new pp,o=function(t,e){const n=e.createRangeIn(t),o=new Wo({name:/v:(.+)/}),i=[];for(const t of n){if("elementStart"!=t.type)continue;const e=t.item,n=e.previousSibling&&e.previousSibling.name||null;o.match(e)&&e.getAttribute("o:gfxdata")&&"v:shapetype"!==n&&i.push(t.item.getAttribute("id"))}return i}(t,n);!function(t,e,n){const o=n.createRangeIn(e),i=new Wo({name:"img"}),r=[];for(const e of o)if(i.match(e.item)){const n=e.item,o=n.getAttribute("v:shapes")?n.getAttribute("v:shapes").split(" "):[];o.length&&o.every((e=>t.indexOf(e)>-1))?r.push(n):n.getAttribute("src")||r.push(n)}for(const t of r)n.remove(t)}(o,t,n),function(t,e){const n=e.createRangeIn(t),o=new Wo({name:/v:(.+)/}),i=[];for(const t of n)"elementStart"==t.type&&o.match(t.item)&&i.push(t.item);for(const t of i)e.remove(t)}(t,n);const i=function(t,e){const n=e.createRangeIn(t),o=new Wo({name:"img"}),i=[];for(const t of n)o.match(t.item)&&t.item.getAttribute("src").startsWith("file://")&&i.push(t.item);return i}(t,n);i.length&&function(t,e,n){if(t.length===e.length)for(let o=0;oString.fromCharCode(parseInt(t,16)))).join(""))}const Rv=//i,zv=/xmlns:o="urn:schemas-microsoft-com/i;class Fv{constructor(t){this.document=t}isActive(t){return Rv.test(t)||zv.test(t)}execute(t){const{body:e,stylesString:n}=t._parsedData;xv(e,n),Pv(e,t.dataTransfer.getData("text/rtf")),t.content=e}}function Nv(t){return t.replace(/(\s+)<\/span>/g,((t,e)=>1===e.length?" ":Array(e.length+1).join("  ").substr(0,e.length)))}function Ov(t,e){const n=new DOMParser,o=function(t){return Nv(Nv(t)).replace(/([^\S\r\n]*?)[\r\n]+([^\S\r\n]*<\/span>)/g,"$1$2").replace(/<\/span>/g,"").replace(/ <\//g," <\/o:p>/g," ").replace(/( |\u00A0)<\/o:p>/g,"").replace(/>([^\S\r\n]*[\r\n]\s*)<")}(function(t){const e="",n="",o=t.indexOf(e);if(o<0)return t;const i=t.indexOf(n,o+e.length);return t.substring(0,o+e.length)+(i>=0?t.substring(i):"")}(t=t.replace(/|';\nvar processing = '<[?][\\\\s\\\\S]*?[?]>';\nvar declaration = ']*>';\nvar cdata = '';\n\nvar HTML_TAG_RE = new RegExp('^(?:' + open_tag + '|' + close_tag + '|' + comment +\n '|' + processing + '|' + declaration + '|' + cdata + ')');\nvar HTML_OPEN_CLOSE_TAG_RE = new RegExp('^(?:' + open_tag + '|' + close_tag + ')');\n\nmodule.exports.HTML_TAG_RE = HTML_TAG_RE;\nmodule.exports.HTML_OPEN_CLOSE_TAG_RE = HTML_OPEN_CLOSE_TAG_RE;\n","// Utilities\n//\n'use strict';\n\n\nfunction _class(obj) { return Object.prototype.toString.call(obj); }\n\nfunction isString(obj) { return _class(obj) === '[object String]'; }\n\nvar _hasOwnProperty = Object.prototype.hasOwnProperty;\n\nfunction has(object, key) {\n return _hasOwnProperty.call(object, key);\n}\n\n// Merge objects\n//\nfunction assign(obj /*from1, from2, from3, ...*/) {\n var sources = Array.prototype.slice.call(arguments, 1);\n\n sources.forEach(function (source) {\n if (!source) { return; }\n\n if (typeof source !== 'object') {\n throw new TypeError(source + 'must be object');\n }\n\n Object.keys(source).forEach(function (key) {\n obj[key] = source[key];\n });\n });\n\n return obj;\n}\n\n// Remove element from array and put another array at those position.\n// Useful for some operations with tokens\nfunction arrayReplaceAt(src, pos, newElements) {\n return [].concat(src.slice(0, pos), newElements, src.slice(pos + 1));\n}\n\n////////////////////////////////////////////////////////////////////////////////\n\nfunction isValidEntityCode(c) {\n /*eslint no-bitwise:0*/\n // broken sequence\n if (c >= 0xD800 && c <= 0xDFFF) { return false; }\n // never used\n if (c >= 0xFDD0 && c <= 0xFDEF) { return false; }\n if ((c & 0xFFFF) === 0xFFFF || (c & 0xFFFF) === 0xFFFE) { return false; }\n // control codes\n if (c >= 0x00 && c <= 0x08) { return false; }\n if (c === 0x0B) { return false; }\n if (c >= 0x0E && c <= 0x1F) { return false; }\n if (c >= 0x7F && c <= 0x9F) { return false; }\n // out of range\n if (c > 0x10FFFF) { return false; }\n return true;\n}\n\nfunction fromCodePoint(c) {\n /*eslint no-bitwise:0*/\n if (c > 0xffff) {\n c -= 0x10000;\n var surrogate1 = 0xd800 + (c >> 10),\n surrogate2 = 0xdc00 + (c & 0x3ff);\n\n return String.fromCharCode(surrogate1, surrogate2);\n }\n return String.fromCharCode(c);\n}\n\n\nvar UNESCAPE_MD_RE = /\\\\([!\"#$%&'()*+,\\-.\\/:;<=>?@[\\\\\\]^_`{|}~])/g;\nvar ENTITY_RE = /&([a-z#][a-z0-9]{1,31});/gi;\nvar UNESCAPE_ALL_RE = new RegExp(UNESCAPE_MD_RE.source + '|' + ENTITY_RE.source, 'gi');\n\nvar DIGITAL_ENTITY_TEST_RE = /^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))/i;\n\nvar entities = require('./entities');\n\nfunction replaceEntityPattern(match, name) {\n var code = 0;\n\n if (has(entities, name)) {\n return entities[name];\n }\n\n if (name.charCodeAt(0) === 0x23/* # */ && DIGITAL_ENTITY_TEST_RE.test(name)) {\n code = name[1].toLowerCase() === 'x' ?\n parseInt(name.slice(2), 16) : parseInt(name.slice(1), 10);\n\n if (isValidEntityCode(code)) {\n return fromCodePoint(code);\n }\n }\n\n return match;\n}\n\n/*function replaceEntities(str) {\n if (str.indexOf('&') < 0) { return str; }\n\n return str.replace(ENTITY_RE, replaceEntityPattern);\n}*/\n\nfunction unescapeMd(str) {\n if (str.indexOf('\\\\') < 0) { return str; }\n return str.replace(UNESCAPE_MD_RE, '$1');\n}\n\nfunction unescapeAll(str) {\n if (str.indexOf('\\\\') < 0 && str.indexOf('&') < 0) { return str; }\n\n return str.replace(UNESCAPE_ALL_RE, function (match, escaped, entity) {\n if (escaped) { return escaped; }\n return replaceEntityPattern(match, entity);\n });\n}\n\n////////////////////////////////////////////////////////////////////////////////\n\nvar HTML_ESCAPE_TEST_RE = /[&<>\"]/;\nvar HTML_ESCAPE_REPLACE_RE = /[&<>\"]/g;\nvar HTML_REPLACEMENTS = {\n '&': '&',\n '<': '<',\n '>': '>',\n '\"': '"'\n};\n\nfunction replaceUnsafeChar(ch) {\n return HTML_REPLACEMENTS[ch];\n}\n\nfunction escapeHtml(str) {\n if (HTML_ESCAPE_TEST_RE.test(str)) {\n return str.replace(HTML_ESCAPE_REPLACE_RE, replaceUnsafeChar);\n }\n return str;\n}\n\n////////////////////////////////////////////////////////////////////////////////\n\nvar REGEXP_ESCAPE_RE = /[.?*+^$[\\]\\\\(){}|-]/g;\n\nfunction escapeRE(str) {\n return str.replace(REGEXP_ESCAPE_RE, '\\\\$&');\n}\n\n////////////////////////////////////////////////////////////////////////////////\n\nfunction isSpace(code) {\n switch (code) {\n case 0x09:\n case 0x20:\n return true;\n }\n return false;\n}\n\n// Zs (unicode class) || [\\t\\f\\v\\r\\n]\nfunction isWhiteSpace(code) {\n if (code >= 0x2000 && code <= 0x200A) { return true; }\n switch (code) {\n case 0x09: // \\t\n case 0x0A: // \\n\n case 0x0B: // \\v\n case 0x0C: // \\f\n case 0x0D: // \\r\n case 0x20:\n case 0xA0:\n case 0x1680:\n case 0x202F:\n case 0x205F:\n case 0x3000:\n return true;\n }\n return false;\n}\n\n////////////////////////////////////////////////////////////////////////////////\n\n/*eslint-disable max-len*/\nvar UNICODE_PUNCT_RE = require('uc.micro/categories/P/regex');\n\n// Currently without astral characters support.\nfunction isPunctChar(ch) {\n return UNICODE_PUNCT_RE.test(ch);\n}\n\n\n// Markdown ASCII punctuation characters.\n//\n// !, \", #, $, %, &, ', (, ), *, +, ,, -, ., /, :, ;, <, =, >, ?, @, [, \\, ], ^, _, `, {, |, }, or ~\n// http://spec.commonmark.org/0.15/#ascii-punctuation-character\n//\n// Don't confuse with unicode punctuation !!! It lacks some chars in ascii range.\n//\nfunction isMdAsciiPunct(ch) {\n switch (ch) {\n case 0x21/* ! */:\n case 0x22/* \" */:\n case 0x23/* # */:\n case 0x24/* $ */:\n case 0x25/* % */:\n case 0x26/* & */:\n case 0x27/* ' */:\n case 0x28/* ( */:\n case 0x29/* ) */:\n case 0x2A/* * */:\n case 0x2B/* + */:\n case 0x2C/* , */:\n case 0x2D/* - */:\n case 0x2E/* . */:\n case 0x2F/* / */:\n case 0x3A/* : */:\n case 0x3B/* ; */:\n case 0x3C/* < */:\n case 0x3D/* = */:\n case 0x3E/* > */:\n case 0x3F/* ? */:\n case 0x40/* @ */:\n case 0x5B/* [ */:\n case 0x5C/* \\ */:\n case 0x5D/* ] */:\n case 0x5E/* ^ */:\n case 0x5F/* _ */:\n case 0x60/* ` */:\n case 0x7B/* { */:\n case 0x7C/* | */:\n case 0x7D/* } */:\n case 0x7E/* ~ */:\n return true;\n default:\n return false;\n }\n}\n\n// Hepler to unify [reference labels].\n//\nfunction normalizeReference(str) {\n // Trim and collapse whitespace\n //\n str = str.trim().replace(/\\s+/g, ' ');\n\n // In node v10 'ẞ'.toLowerCase() === 'Ṿ', which is presumed to be a bug\n // fixed in v12 (couldn't find any details).\n //\n // So treat this one as a special case\n // (remove this when node v10 is no longer supported).\n //\n if ('ẞ'.toLowerCase() === 'Ṿ') {\n str = str.replace(/ẞ/g, 'ß');\n }\n\n // .toLowerCase().toUpperCase() should get rid of all differences\n // between letter variants.\n //\n // Simple .toLowerCase() doesn't normalize 125 code points correctly,\n // and .toUpperCase doesn't normalize 6 of them (list of exceptions:\n // İ, ϴ, ẞ, Ω, K, Å - those are already uppercased, but have differently\n // uppercased versions).\n //\n // Here's an example showing how it happens. Lets take greek letter omega:\n // uppercase U+0398 (Θ), U+03f4 (ϴ) and lowercase U+03b8 (θ), U+03d1 (ϑ)\n //\n // Unicode entries:\n // 0398;GREEK CAPITAL LETTER THETA;Lu;0;L;;;;;N;;;;03B8;\n // 03B8;GREEK SMALL LETTER THETA;Ll;0;L;;;;;N;;;0398;;0398\n // 03D1;GREEK THETA SYMBOL;Ll;0;L; 03B8;;;;N;GREEK SMALL LETTER SCRIPT THETA;;0398;;0398\n // 03F4;GREEK CAPITAL THETA SYMBOL;Lu;0;L; 0398;;;;N;;;;03B8;\n //\n // Case-insensitive comparison should treat all of them as equivalent.\n //\n // But .toLowerCase() doesn't change ϑ (it's already lowercase),\n // and .toUpperCase() doesn't change ϴ (already uppercase).\n //\n // Applying first lower then upper case normalizes any character:\n // '\\u0398\\u03f4\\u03b8\\u03d1'.toLowerCase().toUpperCase() === '\\u0398\\u0398\\u0398\\u0398'\n //\n // Note: this is equivalent to unicode case folding; unicode normalization\n // is a different step that is not required here.\n //\n // Final result should be uppercased, because it's later stored in an object\n // (this avoid a conflict with Object.prototype members,\n // most notably, `__proto__`)\n //\n return str.toLowerCase().toUpperCase();\n}\n\n////////////////////////////////////////////////////////////////////////////////\n\n// Re-export libraries commonly used in both markdown-it and its plugins,\n// so plugins won't have to depend on them explicitly, which reduces their\n// bundled size (e.g. a browser build).\n//\nexports.lib = {};\nexports.lib.mdurl = require('mdurl');\nexports.lib.ucmicro = require('uc.micro');\n\nexports.assign = assign;\nexports.isString = isString;\nexports.has = has;\nexports.unescapeMd = unescapeMd;\nexports.unescapeAll = unescapeAll;\nexports.isValidEntityCode = isValidEntityCode;\nexports.fromCodePoint = fromCodePoint;\n// exports.replaceEntities = replaceEntities;\nexports.escapeHtml = escapeHtml;\nexports.arrayReplaceAt = arrayReplaceAt;\nexports.isSpace = isSpace;\nexports.isWhiteSpace = isWhiteSpace;\nexports.isMdAsciiPunct = isMdAsciiPunct;\nexports.isPunctChar = isPunctChar;\nexports.escapeRE = escapeRE;\nexports.normalizeReference = normalizeReference;\n","// Just a shortcut for bulk export\n'use strict';\n\n\nexports.parseLinkLabel = require('./parse_link_label');\nexports.parseLinkDestination = require('./parse_link_destination');\nexports.parseLinkTitle = require('./parse_link_title');\n","// Parse link destination\n//\n'use strict';\n\n\nvar unescapeAll = require('../common/utils').unescapeAll;\n\n\nmodule.exports = function parseLinkDestination(str, pos, max) {\n var code, level,\n lines = 0,\n start = pos,\n result = {\n ok: false,\n pos: 0,\n lines: 0,\n str: ''\n };\n\n if (str.charCodeAt(pos) === 0x3C /* < */) {\n pos++;\n while (pos < max) {\n code = str.charCodeAt(pos);\n if (code === 0x0A /* \\n */) { return result; }\n if (code === 0x3C /* < */) { return result; }\n if (code === 0x3E /* > */) {\n result.pos = pos + 1;\n result.str = unescapeAll(str.slice(start + 1, pos));\n result.ok = true;\n return result;\n }\n if (code === 0x5C /* \\ */ && pos + 1 < max) {\n pos += 2;\n continue;\n }\n\n pos++;\n }\n\n // no closing '>'\n return result;\n }\n\n // this should be ... } else { ... branch\n\n level = 0;\n while (pos < max) {\n code = str.charCodeAt(pos);\n\n if (code === 0x20) { break; }\n\n // ascii control characters\n if (code < 0x20 || code === 0x7F) { break; }\n\n if (code === 0x5C /* \\ */ && pos + 1 < max) {\n if (str.charCodeAt(pos + 1) === 0x20) { break; }\n pos += 2;\n continue;\n }\n\n if (code === 0x28 /* ( */) {\n level++;\n if (level > 32) { return result; }\n }\n\n if (code === 0x29 /* ) */) {\n if (level === 0) { break; }\n level--;\n }\n\n pos++;\n }\n\n if (start === pos) { return result; }\n if (level !== 0) { return result; }\n\n result.str = unescapeAll(str.slice(start, pos));\n result.lines = lines;\n result.pos = pos;\n result.ok = true;\n return result;\n};\n","// Parse link label\n//\n// this function assumes that first character (\"[\") already matches;\n// returns the end of the label\n//\n'use strict';\n\nmodule.exports = function parseLinkLabel(state, start, disableNested) {\n var level, found, marker, prevPos,\n labelEnd = -1,\n max = state.posMax,\n oldPos = state.pos;\n\n state.pos = start + 1;\n level = 1;\n\n while (state.pos < max) {\n marker = state.src.charCodeAt(state.pos);\n if (marker === 0x5D /* ] */) {\n level--;\n if (level === 0) {\n found = true;\n break;\n }\n }\n\n prevPos = state.pos;\n state.md.inline.skipToken(state);\n if (marker === 0x5B /* [ */) {\n if (prevPos === state.pos - 1) {\n // increase level if we find text `[`, which is not a part of any token\n level++;\n } else if (disableNested) {\n state.pos = oldPos;\n return -1;\n }\n }\n }\n\n if (found) {\n labelEnd = state.pos;\n }\n\n // restore old state\n state.pos = oldPos;\n\n return labelEnd;\n};\n","// Parse link title\n//\n'use strict';\n\n\nvar unescapeAll = require('../common/utils').unescapeAll;\n\n\nmodule.exports = function parseLinkTitle(str, pos, max) {\n var code,\n marker,\n lines = 0,\n start = pos,\n result = {\n ok: false,\n pos: 0,\n lines: 0,\n str: ''\n };\n\n if (pos >= max) { return result; }\n\n marker = str.charCodeAt(pos);\n\n if (marker !== 0x22 /* \" */ && marker !== 0x27 /* ' */ && marker !== 0x28 /* ( */) { return result; }\n\n pos++;\n\n // if opening marker is \"(\", switch it to closing marker \")\"\n if (marker === 0x28) { marker = 0x29; }\n\n while (pos < max) {\n code = str.charCodeAt(pos);\n if (code === marker) {\n result.pos = pos + 1;\n result.lines = lines;\n result.str = unescapeAll(str.slice(start + 1, pos));\n result.ok = true;\n return result;\n } else if (code === 0x28 /* ( */ && marker === 0x29 /* ) */) {\n return result;\n } else if (code === 0x0A) {\n lines++;\n } else if (code === 0x5C /* \\ */ && pos + 1 < max) {\n pos++;\n if (str.charCodeAt(pos) === 0x0A) {\n lines++;\n }\n }\n\n pos++;\n }\n\n return result;\n};\n","// Main parser class\n\n'use strict';\n\n\nvar utils = require('./common/utils');\nvar helpers = require('./helpers');\nvar Renderer = require('./renderer');\nvar ParserCore = require('./parser_core');\nvar ParserBlock = require('./parser_block');\nvar ParserInline = require('./parser_inline');\nvar LinkifyIt = require('linkify-it');\nvar mdurl = require('mdurl');\nvar punycode = require('punycode');\n\n\nvar config = {\n default: require('./presets/default'),\n zero: require('./presets/zero'),\n commonmark: require('./presets/commonmark')\n};\n\n////////////////////////////////////////////////////////////////////////////////\n//\n// This validator can prohibit more than really needed to prevent XSS. It's a\n// tradeoff to keep code simple and to be secure by default.\n//\n// If you need different setup - override validator method as you wish. Or\n// replace it with dummy function and use external sanitizer.\n//\n\nvar BAD_PROTO_RE = /^(vbscript|javascript|file|data):/;\nvar GOOD_DATA_RE = /^data:image\\/(gif|png|jpeg|webp);/;\n\nfunction validateLink(url) {\n // url should be normalized at this point, and existing entities are decoded\n var str = url.trim().toLowerCase();\n\n return BAD_PROTO_RE.test(str) ? (GOOD_DATA_RE.test(str) ? true : false) : true;\n}\n\n////////////////////////////////////////////////////////////////////////////////\n\n\nvar RECODE_HOSTNAME_FOR = [ 'http:', 'https:', 'mailto:' ];\n\nfunction normalizeLink(url) {\n var parsed = mdurl.parse(url, true);\n\n if (parsed.hostname) {\n // Encode hostnames in urls like:\n // `http://host/`, `https://host/`, `mailto:user@host`, `//host/`\n //\n // We don't encode unknown schemas, because it's likely that we encode\n // something we shouldn't (e.g. `skype:name` treated as `skype:host`)\n //\n if (!parsed.protocol || RECODE_HOSTNAME_FOR.indexOf(parsed.protocol) >= 0) {\n try {\n parsed.hostname = punycode.toASCII(parsed.hostname);\n } catch (er) { /**/ }\n }\n }\n\n return mdurl.encode(mdurl.format(parsed));\n}\n\nfunction normalizeLinkText(url) {\n var parsed = mdurl.parse(url, true);\n\n if (parsed.hostname) {\n // Encode hostnames in urls like:\n // `http://host/`, `https://host/`, `mailto:user@host`, `//host/`\n //\n // We don't encode unknown schemas, because it's likely that we encode\n // something we shouldn't (e.g. `skype:name` treated as `skype:host`)\n //\n if (!parsed.protocol || RECODE_HOSTNAME_FOR.indexOf(parsed.protocol) >= 0) {\n try {\n parsed.hostname = punycode.toUnicode(parsed.hostname);\n } catch (er) { /**/ }\n }\n }\n\n // add '%' to exclude list because of https://github.com/markdown-it/markdown-it/issues/720\n return mdurl.decode(mdurl.format(parsed), mdurl.decode.defaultChars + '%');\n}\n\n\n/**\n * class MarkdownIt\n *\n * Main parser/renderer class.\n *\n * ##### Usage\n *\n * ```javascript\n * // node.js, \"classic\" way:\n * var MarkdownIt = require('markdown-it'),\n * md = new MarkdownIt();\n * var result = md.render('# markdown-it rulezz!');\n *\n * // node.js, the same, but with sugar:\n * var md = require('markdown-it')();\n * var result = md.render('# markdown-it rulezz!');\n *\n * // browser without AMD, added to \"window\" on script load\n * // Note, there are no dash.\n * var md = window.markdownit();\n * var result = md.render('# markdown-it rulezz!');\n * ```\n *\n * Single line rendering, without paragraph wrap:\n *\n * ```javascript\n * var md = require('markdown-it')();\n * var result = md.renderInline('__markdown-it__ rulezz!');\n * ```\n **/\n\n/**\n * new MarkdownIt([presetName, options])\n * - presetName (String): optional, `commonmark` / `zero`\n * - options (Object)\n *\n * Creates parser instanse with given config. Can be called without `new`.\n *\n * ##### presetName\n *\n * MarkdownIt provides named presets as a convenience to quickly\n * enable/disable active syntax rules and options for common use cases.\n *\n * - [\"commonmark\"](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/commonmark.js) -\n * configures parser to strict [CommonMark](http://commonmark.org/) mode.\n * - [default](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/default.js) -\n * similar to GFM, used when no preset name given. Enables all available rules,\n * but still without html, typographer & autolinker.\n * - [\"zero\"](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/zero.js) -\n * all rules disabled. Useful to quickly setup your config via `.enable()`.\n * For example, when you need only `bold` and `italic` markup and nothing else.\n *\n * ##### options:\n *\n * - __html__ - `false`. Set `true` to enable HTML tags in source. Be careful!\n * That's not safe! You may need external sanitizer to protect output from XSS.\n * It's better to extend features via plugins, instead of enabling HTML.\n * - __xhtmlOut__ - `false`. Set `true` to add '/' when closing single tags\n * (`
`). This is needed only for full CommonMark compatibility. In real\n * world you will need HTML output.\n * - __breaks__ - `false`. Set `true` to convert `\\n` in paragraphs into `
`.\n * - __langPrefix__ - `language-`. CSS language class prefix for fenced blocks.\n * Can be useful for external highlighters.\n * - __linkify__ - `false`. Set `true` to autoconvert URL-like text to links.\n * - __typographer__ - `false`. Set `true` to enable [some language-neutral\n * replacement](https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/replacements.js) +\n * quotes beautification (smartquotes).\n * - __quotes__ - `“”‘’`, String or Array. Double + single quotes replacement\n * pairs, when typographer enabled and smartquotes on. For example, you can\n * use `'«»„“'` for Russian, `'„“‚‘'` for German, and\n * `['«\\xA0', '\\xA0»', '‹\\xA0', '\\xA0›']` for French (including nbsp).\n * - __highlight__ - `null`. Highlighter function for fenced code blocks.\n * Highlighter `function (str, lang)` should return escaped HTML. It can also\n * return empty string if the source was not changed and should be escaped\n * externaly. If result starts with `):\n *\n * ```javascript\n * var hljs = require('highlight.js') // https://highlightjs.org/\n *\n * // Actual default values\n * var md = require('markdown-it')({\n * highlight: function (str, lang) {\n * if (lang && hljs.getLanguage(lang)) {\n * try {\n * return '
' +\n *                hljs.highlight(str, { language: lang, ignoreIllegals: true }).value +\n *                '
';\n * } catch (__) {}\n * }\n *\n * return '
' + md.utils.escapeHtml(str) + '
';\n * }\n * });\n * ```\n *\n **/\nfunction MarkdownIt(presetName, options) {\n if (!(this instanceof MarkdownIt)) {\n return new MarkdownIt(presetName, options);\n }\n\n if (!options) {\n if (!utils.isString(presetName)) {\n options = presetName || {};\n presetName = 'default';\n }\n }\n\n /**\n * MarkdownIt#inline -> ParserInline\n *\n * Instance of [[ParserInline]]. You may need it to add new rules when\n * writing plugins. For simple rules control use [[MarkdownIt.disable]] and\n * [[MarkdownIt.enable]].\n **/\n this.inline = new ParserInline();\n\n /**\n * MarkdownIt#block -> ParserBlock\n *\n * Instance of [[ParserBlock]]. You may need it to add new rules when\n * writing plugins. For simple rules control use [[MarkdownIt.disable]] and\n * [[MarkdownIt.enable]].\n **/\n this.block = new ParserBlock();\n\n /**\n * MarkdownIt#core -> Core\n *\n * Instance of [[Core]] chain executor. You may need it to add new rules when\n * writing plugins. For simple rules control use [[MarkdownIt.disable]] and\n * [[MarkdownIt.enable]].\n **/\n this.core = new ParserCore();\n\n /**\n * MarkdownIt#renderer -> Renderer\n *\n * Instance of [[Renderer]]. Use it to modify output look. Or to add rendering\n * rules for new token types, generated by plugins.\n *\n * ##### Example\n *\n * ```javascript\n * var md = require('markdown-it')();\n *\n * function myToken(tokens, idx, options, env, self) {\n * //...\n * return result;\n * };\n *\n * md.renderer.rules['my_token'] = myToken\n * ```\n *\n * See [[Renderer]] docs and [source code](https://github.com/markdown-it/markdown-it/blob/master/lib/renderer.js).\n **/\n this.renderer = new Renderer();\n\n /**\n * MarkdownIt#linkify -> LinkifyIt\n *\n * [linkify-it](https://github.com/markdown-it/linkify-it) instance.\n * Used by [linkify](https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/linkify.js)\n * rule.\n **/\n this.linkify = new LinkifyIt();\n\n /**\n * MarkdownIt#validateLink(url) -> Boolean\n *\n * Link validation function. CommonMark allows too much in links. By default\n * we disable `javascript:`, `vbscript:`, `file:` schemas, and almost all `data:...` schemas\n * except some embedded image types.\n *\n * You can change this behaviour:\n *\n * ```javascript\n * var md = require('markdown-it')();\n * // enable everything\n * md.validateLink = function () { return true; }\n * ```\n **/\n this.validateLink = validateLink;\n\n /**\n * MarkdownIt#normalizeLink(url) -> String\n *\n * Function used to encode link url to a machine-readable format,\n * which includes url-encoding, punycode, etc.\n **/\n this.normalizeLink = normalizeLink;\n\n /**\n * MarkdownIt#normalizeLinkText(url) -> String\n *\n * Function used to decode link url to a human-readable format`\n **/\n this.normalizeLinkText = normalizeLinkText;\n\n\n // Expose utils & helpers for easy acces from plugins\n\n /**\n * MarkdownIt#utils -> utils\n *\n * Assorted utility functions, useful to write plugins. See details\n * [here](https://github.com/markdown-it/markdown-it/blob/master/lib/common/utils.js).\n **/\n this.utils = utils;\n\n /**\n * MarkdownIt#helpers -> helpers\n *\n * Link components parser functions, useful to write plugins. See details\n * [here](https://github.com/markdown-it/markdown-it/blob/master/lib/helpers).\n **/\n this.helpers = utils.assign({}, helpers);\n\n\n this.options = {};\n this.configure(presetName);\n\n if (options) { this.set(options); }\n}\n\n\n/** chainable\n * MarkdownIt.set(options)\n *\n * Set parser options (in the same format as in constructor). Probably, you\n * will never need it, but you can change options after constructor call.\n *\n * ##### Example\n *\n * ```javascript\n * var md = require('markdown-it')()\n * .set({ html: true, breaks: true })\n * .set({ typographer, true });\n * ```\n *\n * __Note:__ To achieve the best possible performance, don't modify a\n * `markdown-it` instance options on the fly. If you need multiple configurations\n * it's best to create multiple instances and initialize each with separate\n * config.\n **/\nMarkdownIt.prototype.set = function (options) {\n utils.assign(this.options, options);\n return this;\n};\n\n\n/** chainable, internal\n * MarkdownIt.configure(presets)\n *\n * Batch load of all options and compenent settings. This is internal method,\n * and you probably will not need it. But if you will - see available presets\n * and data structure [here](https://github.com/markdown-it/markdown-it/tree/master/lib/presets)\n *\n * We strongly recommend to use presets instead of direct config loads. That\n * will give better compatibility with next versions.\n **/\nMarkdownIt.prototype.configure = function (presets) {\n var self = this, presetName;\n\n if (utils.isString(presets)) {\n presetName = presets;\n presets = config[presetName];\n if (!presets) { throw new Error('Wrong `markdown-it` preset \"' + presetName + '\", check name'); }\n }\n\n if (!presets) { throw new Error('Wrong `markdown-it` preset, can\\'t be empty'); }\n\n if (presets.options) { self.set(presets.options); }\n\n if (presets.components) {\n Object.keys(presets.components).forEach(function (name) {\n if (presets.components[name].rules) {\n self[name].ruler.enableOnly(presets.components[name].rules);\n }\n if (presets.components[name].rules2) {\n self[name].ruler2.enableOnly(presets.components[name].rules2);\n }\n });\n }\n return this;\n};\n\n\n/** chainable\n * MarkdownIt.enable(list, ignoreInvalid)\n * - list (String|Array): rule name or list of rule names to enable\n * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.\n *\n * Enable list or rules. It will automatically find appropriate components,\n * containing rules with given names. If rule not found, and `ignoreInvalid`\n * not set - throws exception.\n *\n * ##### Example\n *\n * ```javascript\n * var md = require('markdown-it')()\n * .enable(['sub', 'sup'])\n * .disable('smartquotes');\n * ```\n **/\nMarkdownIt.prototype.enable = function (list, ignoreInvalid) {\n var result = [];\n\n if (!Array.isArray(list)) { list = [ list ]; }\n\n [ 'core', 'block', 'inline' ].forEach(function (chain) {\n result = result.concat(this[chain].ruler.enable(list, true));\n }, this);\n\n result = result.concat(this.inline.ruler2.enable(list, true));\n\n var missed = list.filter(function (name) { return result.indexOf(name) < 0; });\n\n if (missed.length && !ignoreInvalid) {\n throw new Error('MarkdownIt. Failed to enable unknown rule(s): ' + missed);\n }\n\n return this;\n};\n\n\n/** chainable\n * MarkdownIt.disable(list, ignoreInvalid)\n * - list (String|Array): rule name or list of rule names to disable.\n * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.\n *\n * The same as [[MarkdownIt.enable]], but turn specified rules off.\n **/\nMarkdownIt.prototype.disable = function (list, ignoreInvalid) {\n var result = [];\n\n if (!Array.isArray(list)) { list = [ list ]; }\n\n [ 'core', 'block', 'inline' ].forEach(function (chain) {\n result = result.concat(this[chain].ruler.disable(list, true));\n }, this);\n\n result = result.concat(this.inline.ruler2.disable(list, true));\n\n var missed = list.filter(function (name) { return result.indexOf(name) < 0; });\n\n if (missed.length && !ignoreInvalid) {\n throw new Error('MarkdownIt. Failed to disable unknown rule(s): ' + missed);\n }\n return this;\n};\n\n\n/** chainable\n * MarkdownIt.use(plugin, params)\n *\n * Load specified plugin with given params into current parser instance.\n * It's just a sugar to call `plugin(md, params)` with curring.\n *\n * ##### Example\n *\n * ```javascript\n * var iterator = require('markdown-it-for-inline');\n * var md = require('markdown-it')()\n * .use(iterator, 'foo_replace', 'text', function (tokens, idx) {\n * tokens[idx].content = tokens[idx].content.replace(/foo/g, 'bar');\n * });\n * ```\n **/\nMarkdownIt.prototype.use = function (plugin /*, params, ... */) {\n var args = [ this ].concat(Array.prototype.slice.call(arguments, 1));\n plugin.apply(plugin, args);\n return this;\n};\n\n\n/** internal\n * MarkdownIt.parse(src, env) -> Array\n * - src (String): source string\n * - env (Object): environment sandbox\n *\n * Parse input string and return list of block tokens (special token type\n * \"inline\" will contain list of inline tokens). You should not call this\n * method directly, until you write custom renderer (for example, to produce\n * AST).\n *\n * `env` is used to pass data between \"distributed\" rules and return additional\n * metadata like reference info, needed for the renderer. It also can be used to\n * inject data in specific cases. Usually, you will be ok to pass `{}`,\n * and then pass updated object to renderer.\n **/\nMarkdownIt.prototype.parse = function (src, env) {\n if (typeof src !== 'string') {\n throw new Error('Input data should be a String');\n }\n\n var state = new this.core.State(src, this, env);\n\n this.core.process(state);\n\n return state.tokens;\n};\n\n\n/**\n * MarkdownIt.render(src [, env]) -> String\n * - src (String): source string\n * - env (Object): environment sandbox\n *\n * Render markdown string into html. It does all magic for you :).\n *\n * `env` can be used to inject additional metadata (`{}` by default).\n * But you will not need it with high probability. See also comment\n * in [[MarkdownIt.parse]].\n **/\nMarkdownIt.prototype.render = function (src, env) {\n env = env || {};\n\n return this.renderer.render(this.parse(src, env), this.options, env);\n};\n\n\n/** internal\n * MarkdownIt.parseInline(src, env) -> Array\n * - src (String): source string\n * - env (Object): environment sandbox\n *\n * The same as [[MarkdownIt.parse]] but skip all block rules. It returns the\n * block tokens list with the single `inline` element, containing parsed inline\n * tokens in `children` property. Also updates `env` object.\n **/\nMarkdownIt.prototype.parseInline = function (src, env) {\n var state = new this.core.State(src, this, env);\n\n state.inlineMode = true;\n this.core.process(state);\n\n return state.tokens;\n};\n\n\n/**\n * MarkdownIt.renderInline(src [, env]) -> String\n * - src (String): source string\n * - env (Object): environment sandbox\n *\n * Similar to [[MarkdownIt.render]] but for single paragraph content. Result\n * will NOT be wrapped into `

` tags.\n **/\nMarkdownIt.prototype.renderInline = function (src, env) {\n env = env || {};\n\n return this.renderer.render(this.parseInline(src, env), this.options, env);\n};\n\n\nmodule.exports = MarkdownIt;\n","/** internal\n * class ParserBlock\n *\n * Block-level tokenizer.\n **/\n'use strict';\n\n\nvar Ruler = require('./ruler');\n\n\nvar _rules = [\n // First 2 params - rule name & source. Secondary array - list of rules,\n // which can be terminated by this one.\n [ 'table', require('./rules_block/table'), [ 'paragraph', 'reference' ] ],\n [ 'code', require('./rules_block/code') ],\n [ 'fence', require('./rules_block/fence'), [ 'paragraph', 'reference', 'blockquote', 'list' ] ],\n [ 'blockquote', require('./rules_block/blockquote'), [ 'paragraph', 'reference', 'blockquote', 'list' ] ],\n [ 'hr', require('./rules_block/hr'), [ 'paragraph', 'reference', 'blockquote', 'list' ] ],\n [ 'list', require('./rules_block/list'), [ 'paragraph', 'reference', 'blockquote' ] ],\n [ 'reference', require('./rules_block/reference') ],\n [ 'html_block', require('./rules_block/html_block'), [ 'paragraph', 'reference', 'blockquote' ] ],\n [ 'heading', require('./rules_block/heading'), [ 'paragraph', 'reference', 'blockquote' ] ],\n [ 'lheading', require('./rules_block/lheading') ],\n [ 'paragraph', require('./rules_block/paragraph') ]\n];\n\n\n/**\n * new ParserBlock()\n **/\nfunction ParserBlock() {\n /**\n * ParserBlock#ruler -> Ruler\n *\n * [[Ruler]] instance. Keep configuration of block rules.\n **/\n this.ruler = new Ruler();\n\n for (var i = 0; i < _rules.length; i++) {\n this.ruler.push(_rules[i][0], _rules[i][1], { alt: (_rules[i][2] || []).slice() });\n }\n}\n\n\n// Generate tokens for input range\n//\nParserBlock.prototype.tokenize = function (state, startLine, endLine) {\n var ok, i,\n rules = this.ruler.getRules(''),\n len = rules.length,\n line = startLine,\n hasEmptyLines = false,\n maxNesting = state.md.options.maxNesting;\n\n while (line < endLine) {\n state.line = line = state.skipEmptyLines(line);\n if (line >= endLine) { break; }\n\n // Termination condition for nested calls.\n // Nested calls currently used for blockquotes & lists\n if (state.sCount[line] < state.blkIndent) { break; }\n\n // If nesting level exceeded - skip tail to the end. That's not ordinary\n // situation and we should not care about content.\n if (state.level >= maxNesting) {\n state.line = endLine;\n break;\n }\n\n // Try all possible rules.\n // On success, rule should:\n //\n // - update `state.line`\n // - update `state.tokens`\n // - return true\n\n for (i = 0; i < len; i++) {\n ok = rules[i](state, line, endLine, false);\n if (ok) { break; }\n }\n\n // set state.tight if we had an empty line before current tag\n // i.e. latest empty line should not count\n state.tight = !hasEmptyLines;\n\n // paragraph might \"eat\" one newline after it in nested lists\n if (state.isEmpty(state.line - 1)) {\n hasEmptyLines = true;\n }\n\n line = state.line;\n\n if (line < endLine && state.isEmpty(line)) {\n hasEmptyLines = true;\n line++;\n state.line = line;\n }\n }\n};\n\n\n/**\n * ParserBlock.parse(str, md, env, outTokens)\n *\n * Process input string and push block tokens into `outTokens`\n **/\nParserBlock.prototype.parse = function (src, md, env, outTokens) {\n var state;\n\n if (!src) { return; }\n\n state = new this.State(src, md, env, outTokens);\n\n this.tokenize(state, state.line, state.lineMax);\n};\n\n\nParserBlock.prototype.State = require('./rules_block/state_block');\n\n\nmodule.exports = ParserBlock;\n","/** internal\n * class Core\n *\n * Top-level rules executor. Glues block/inline parsers and does intermediate\n * transformations.\n **/\n'use strict';\n\n\nvar Ruler = require('./ruler');\n\n\nvar _rules = [\n [ 'normalize', require('./rules_core/normalize') ],\n [ 'block', require('./rules_core/block') ],\n [ 'inline', require('./rules_core/inline') ],\n [ 'linkify', require('./rules_core/linkify') ],\n [ 'replacements', require('./rules_core/replacements') ],\n [ 'smartquotes', require('./rules_core/smartquotes') ]\n];\n\n\n/**\n * new Core()\n **/\nfunction Core() {\n /**\n * Core#ruler -> Ruler\n *\n * [[Ruler]] instance. Keep configuration of core rules.\n **/\n this.ruler = new Ruler();\n\n for (var i = 0; i < _rules.length; i++) {\n this.ruler.push(_rules[i][0], _rules[i][1]);\n }\n}\n\n\n/**\n * Core.process(state)\n *\n * Executes core chain rules.\n **/\nCore.prototype.process = function (state) {\n var i, l, rules;\n\n rules = this.ruler.getRules('');\n\n for (i = 0, l = rules.length; i < l; i++) {\n rules[i](state);\n }\n};\n\nCore.prototype.State = require('./rules_core/state_core');\n\n\nmodule.exports = Core;\n","/** internal\n * class ParserInline\n *\n * Tokenizes paragraph content.\n **/\n'use strict';\n\n\nvar Ruler = require('./ruler');\n\n\n////////////////////////////////////////////////////////////////////////////////\n// Parser rules\n\nvar _rules = [\n [ 'text', require('./rules_inline/text') ],\n [ 'newline', require('./rules_inline/newline') ],\n [ 'escape', require('./rules_inline/escape') ],\n [ 'backticks', require('./rules_inline/backticks') ],\n [ 'strikethrough', require('./rules_inline/strikethrough').tokenize ],\n [ 'emphasis', require('./rules_inline/emphasis').tokenize ],\n [ 'link', require('./rules_inline/link') ],\n [ 'image', require('./rules_inline/image') ],\n [ 'autolink', require('./rules_inline/autolink') ],\n [ 'html_inline', require('./rules_inline/html_inline') ],\n [ 'entity', require('./rules_inline/entity') ]\n];\n\nvar _rules2 = [\n [ 'balance_pairs', require('./rules_inline/balance_pairs') ],\n [ 'strikethrough', require('./rules_inline/strikethrough').postProcess ],\n [ 'emphasis', require('./rules_inline/emphasis').postProcess ],\n [ 'text_collapse', require('./rules_inline/text_collapse') ]\n];\n\n\n/**\n * new ParserInline()\n **/\nfunction ParserInline() {\n var i;\n\n /**\n * ParserInline#ruler -> Ruler\n *\n * [[Ruler]] instance. Keep configuration of inline rules.\n **/\n this.ruler = new Ruler();\n\n for (i = 0; i < _rules.length; i++) {\n this.ruler.push(_rules[i][0], _rules[i][1]);\n }\n\n /**\n * ParserInline#ruler2 -> Ruler\n *\n * [[Ruler]] instance. Second ruler used for post-processing\n * (e.g. in emphasis-like rules).\n **/\n this.ruler2 = new Ruler();\n\n for (i = 0; i < _rules2.length; i++) {\n this.ruler2.push(_rules2[i][0], _rules2[i][1]);\n }\n}\n\n\n// Skip single token by running all rules in validation mode;\n// returns `true` if any rule reported success\n//\nParserInline.prototype.skipToken = function (state) {\n var ok, i, pos = state.pos,\n rules = this.ruler.getRules(''),\n len = rules.length,\n maxNesting = state.md.options.maxNesting,\n cache = state.cache;\n\n\n if (typeof cache[pos] !== 'undefined') {\n state.pos = cache[pos];\n return;\n }\n\n if (state.level < maxNesting) {\n for (i = 0; i < len; i++) {\n // Increment state.level and decrement it later to limit recursion.\n // It's harmless to do here, because no tokens are created. But ideally,\n // we'd need a separate private state variable for this purpose.\n //\n state.level++;\n ok = rules[i](state, true);\n state.level--;\n\n if (ok) { break; }\n }\n } else {\n // Too much nesting, just skip until the end of the paragraph.\n //\n // NOTE: this will cause links to behave incorrectly in the following case,\n // when an amount of `[` is exactly equal to `maxNesting + 1`:\n //\n // [[[[[[[[[[[[[[[[[[[[[foo]()\n //\n // TODO: remove this workaround when CM standard will allow nested links\n // (we can replace it by preventing links from being parsed in\n // validation mode)\n //\n state.pos = state.posMax;\n }\n\n if (!ok) { state.pos++; }\n cache[pos] = state.pos;\n};\n\n\n// Generate tokens for input range\n//\nParserInline.prototype.tokenize = function (state) {\n var ok, i,\n rules = this.ruler.getRules(''),\n len = rules.length,\n end = state.posMax,\n maxNesting = state.md.options.maxNesting;\n\n while (state.pos < end) {\n // Try all possible rules.\n // On success, rule should:\n //\n // - update `state.pos`\n // - update `state.tokens`\n // - return true\n\n if (state.level < maxNesting) {\n for (i = 0; i < len; i++) {\n ok = rules[i](state, false);\n if (ok) { break; }\n }\n }\n\n if (ok) {\n if (state.pos >= end) { break; }\n continue;\n }\n\n state.pending += state.src[state.pos++];\n }\n\n if (state.pending) {\n state.pushPending();\n }\n};\n\n\n/**\n * ParserInline.parse(str, md, env, outTokens)\n *\n * Process input string and push inline tokens into `outTokens`\n **/\nParserInline.prototype.parse = function (str, md, env, outTokens) {\n var i, rules, len;\n var state = new this.State(str, md, env, outTokens);\n\n this.tokenize(state);\n\n rules = this.ruler2.getRules('');\n len = rules.length;\n\n for (i = 0; i < len; i++) {\n rules[i](state);\n }\n};\n\n\nParserInline.prototype.State = require('./rules_inline/state_inline');\n\n\nmodule.exports = ParserInline;\n","// Commonmark default options\n\n'use strict';\n\n\nmodule.exports = {\n options: {\n html: true, // Enable HTML tags in source\n xhtmlOut: true, // Use '/' to close single tags (
)\n breaks: false, // Convert '\\n' in paragraphs into
\n langPrefix: 'language-', // CSS language prefix for fenced blocks\n linkify: false, // autoconvert URL-like texts to links\n\n // Enable some language-neutral replacements + quotes beautification\n typographer: false,\n\n // Double + single quotes replacement pairs, when typographer enabled,\n // and smartquotes on. Could be either a String or an Array.\n //\n // For example, you can use '«»„“' for Russian, '„“‚‘' for German,\n // and ['«\\xA0', '\\xA0»', '‹\\xA0', '\\xA0›'] for French (including nbsp).\n quotes: '\\u201c\\u201d\\u2018\\u2019', /* “”‘’ */\n\n // Highlighter function. Should return escaped HTML,\n // or '' if the source string is not changed and should be escaped externaly.\n // If result starts with )\n breaks: false, // Convert '\\n' in paragraphs into
\n langPrefix: 'language-', // CSS language prefix for fenced blocks\n linkify: false, // autoconvert URL-like texts to links\n\n // Enable some language-neutral replacements + quotes beautification\n typographer: false,\n\n // Double + single quotes replacement pairs, when typographer enabled,\n // and smartquotes on. Could be either a String or an Array.\n //\n // For example, you can use '«»„“' for Russian, '„“‚‘' for German,\n // and ['«\\xA0', '\\xA0»', '‹\\xA0', '\\xA0›'] for French (including nbsp).\n quotes: '\\u201c\\u201d\\u2018\\u2019', /* “”‘’ */\n\n // Highlighter function. Should return escaped HTML,\n // or '' if the source string is not changed and should be escaped externaly.\n // If result starts with )\n breaks: false, // Convert '\\n' in paragraphs into
\n langPrefix: 'language-', // CSS language prefix for fenced blocks\n linkify: false, // autoconvert URL-like texts to links\n\n // Enable some language-neutral replacements + quotes beautification\n typographer: false,\n\n // Double + single quotes replacement pairs, when typographer enabled,\n // and smartquotes on. Could be either a String or an Array.\n //\n // For example, you can use '«»„“' for Russian, '„“‚‘' for German,\n // and ['«\\xA0', '\\xA0»', '‹\\xA0', '\\xA0›'] for French (including nbsp).\n quotes: '\\u201c\\u201d\\u2018\\u2019', /* “”‘’ */\n\n // Highlighter function. Should return escaped HTML,\n // or '' if the source string is not changed and should be escaped externaly.\n // If result starts with ' +\n escapeHtml(tokens[idx].content) +\n '';\n};\n\n\ndefault_rules.code_block = function (tokens, idx, options, env, slf) {\n var token = tokens[idx];\n\n return '' +\n escapeHtml(tokens[idx].content) +\n '\\n';\n};\n\n\ndefault_rules.fence = function (tokens, idx, options, env, slf) {\n var token = tokens[idx],\n info = token.info ? unescapeAll(token.info).trim() : '',\n langName = '',\n langAttrs = '',\n highlighted, i, arr, tmpAttrs, tmpToken;\n\n if (info) {\n arr = info.split(/(\\s+)/g);\n langName = arr[0];\n langAttrs = arr.slice(2).join('');\n }\n\n if (options.highlight) {\n highlighted = options.highlight(token.content, langName, langAttrs) || escapeHtml(token.content);\n } else {\n highlighted = escapeHtml(token.content);\n }\n\n if (highlighted.indexOf(''\n + highlighted\n + '\\n';\n }\n\n\n return '

'\n        + highlighted\n        + '
\\n';\n};\n\n\ndefault_rules.image = function (tokens, idx, options, env, slf) {\n var token = tokens[idx];\n\n // \"alt\" attr MUST be set, even if empty. Because it's mandatory and\n // should be placed on proper position for tests.\n //\n // Replace content with actual value\n\n token.attrs[token.attrIndex('alt')][1] =\n slf.renderInlineAsText(token.children, options, env);\n\n return slf.renderToken(tokens, idx, options);\n};\n\n\ndefault_rules.hardbreak = function (tokens, idx, options /*, env */) {\n return options.xhtmlOut ? '
\\n' : '
\\n';\n};\ndefault_rules.softbreak = function (tokens, idx, options /*, env */) {\n return options.breaks ? (options.xhtmlOut ? '
\\n' : '
\\n') : '\\n';\n};\n\n\ndefault_rules.text = function (tokens, idx /*, options, env */) {\n return escapeHtml(tokens[idx].content);\n};\n\n\ndefault_rules.html_block = function (tokens, idx /*, options, env */) {\n return tokens[idx].content;\n};\ndefault_rules.html_inline = function (tokens, idx /*, options, env */) {\n return tokens[idx].content;\n};\n\n\n/**\n * new Renderer()\n *\n * Creates new [[Renderer]] instance and fill [[Renderer#rules]] with defaults.\n **/\nfunction Renderer() {\n\n /**\n * Renderer#rules -> Object\n *\n * Contains render rules for tokens. Can be updated and extended.\n *\n * ##### Example\n *\n * ```javascript\n * var md = require('markdown-it')();\n *\n * md.renderer.rules.strong_open = function () { return ''; };\n * md.renderer.rules.strong_close = function () { return ''; };\n *\n * var result = md.renderInline(...);\n * ```\n *\n * Each rule is called as independent static function with fixed signature:\n *\n * ```javascript\n * function my_token_render(tokens, idx, options, env, renderer) {\n * // ...\n * return renderedHTML;\n * }\n * ```\n *\n * See [source code](https://github.com/markdown-it/markdown-it/blob/master/lib/renderer.js)\n * for more details and examples.\n **/\n this.rules = assign({}, default_rules);\n}\n\n\n/**\n * Renderer.renderAttrs(token) -> String\n *\n * Render token attributes to string.\n **/\nRenderer.prototype.renderAttrs = function renderAttrs(token) {\n var i, l, result;\n\n if (!token.attrs) { return ''; }\n\n result = '';\n\n for (i = 0, l = token.attrs.length; i < l; i++) {\n result += ' ' + escapeHtml(token.attrs[i][0]) + '=\"' + escapeHtml(token.attrs[i][1]) + '\"';\n }\n\n return result;\n};\n\n\n/**\n * Renderer.renderToken(tokens, idx, options) -> String\n * - tokens (Array): list of tokens\n * - idx (Numbed): token index to render\n * - options (Object): params of parser instance\n *\n * Default token renderer. Can be overriden by custom function\n * in [[Renderer#rules]].\n **/\nRenderer.prototype.renderToken = function renderToken(tokens, idx, options) {\n var nextToken,\n result = '',\n needLf = false,\n token = tokens[idx];\n\n // Tight list paragraphs\n if (token.hidden) {\n return '';\n }\n\n // Insert a newline between hidden paragraph and subsequent opening\n // block-level tag.\n //\n // For example, here we should insert a newline before blockquote:\n // - a\n // >\n //\n if (token.block && token.nesting !== -1 && idx && tokens[idx - 1].hidden) {\n result += '\\n';\n }\n\n // Add token name, e.g. ``.\n //\n needLf = false;\n }\n }\n }\n }\n\n result += needLf ? '>\\n' : '>';\n\n return result;\n};\n\n\n/**\n * Renderer.renderInline(tokens, options, env) -> String\n * - tokens (Array): list on block tokens to render\n * - options (Object): params of parser instance\n * - env (Object): additional data from parsed input (references, for example)\n *\n * The same as [[Renderer.render]], but for single token of `inline` type.\n **/\nRenderer.prototype.renderInline = function (tokens, options, env) {\n var type,\n result = '',\n rules = this.rules;\n\n for (var i = 0, len = tokens.length; i < len; i++) {\n type = tokens[i].type;\n\n if (typeof rules[type] !== 'undefined') {\n result += rules[type](tokens, i, options, env, this);\n } else {\n result += this.renderToken(tokens, i, options);\n }\n }\n\n return result;\n};\n\n\n/** internal\n * Renderer.renderInlineAsText(tokens, options, env) -> String\n * - tokens (Array): list on block tokens to render\n * - options (Object): params of parser instance\n * - env (Object): additional data from parsed input (references, for example)\n *\n * Special kludge for image `alt` attributes to conform CommonMark spec.\n * Don't try to use it! Spec requires to show `alt` content with stripped markup,\n * instead of simple escaping.\n **/\nRenderer.prototype.renderInlineAsText = function (tokens, options, env) {\n var result = '';\n\n for (var i = 0, len = tokens.length; i < len; i++) {\n if (tokens[i].type === 'text') {\n result += tokens[i].content;\n } else if (tokens[i].type === 'image') {\n result += this.renderInlineAsText(tokens[i].children, options, env);\n } else if (tokens[i].type === 'softbreak') {\n result += '\\n';\n }\n }\n\n return result;\n};\n\n\n/**\n * Renderer.render(tokens, options, env) -> String\n * - tokens (Array): list on block tokens to render\n * - options (Object): params of parser instance\n * - env (Object): additional data from parsed input (references, for example)\n *\n * Takes token stream and generates HTML. Probably, you will never need to call\n * this method directly.\n **/\nRenderer.prototype.render = function (tokens, options, env) {\n var i, len, type,\n result = '',\n rules = this.rules;\n\n for (i = 0, len = tokens.length; i < len; i++) {\n type = tokens[i].type;\n\n if (type === 'inline') {\n result += this.renderInline(tokens[i].children, options, env);\n } else if (typeof rules[type] !== 'undefined') {\n result += rules[tokens[i].type](tokens, i, options, env, this);\n } else {\n result += this.renderToken(tokens, i, options, env);\n }\n }\n\n return result;\n};\n\nmodule.exports = Renderer;\n","/**\n * class Ruler\n *\n * Helper class, used by [[MarkdownIt#core]], [[MarkdownIt#block]] and\n * [[MarkdownIt#inline]] to manage sequences of functions (rules):\n *\n * - keep rules in defined order\n * - assign the name to each rule\n * - enable/disable rules\n * - add/replace rules\n * - allow assign rules to additional named chains (in the same)\n * - cacheing lists of active rules\n *\n * You will not need use this class directly until write plugins. For simple\n * rules control use [[MarkdownIt.disable]], [[MarkdownIt.enable]] and\n * [[MarkdownIt.use]].\n **/\n'use strict';\n\n\n/**\n * new Ruler()\n **/\nfunction Ruler() {\n // List of added rules. Each element is:\n //\n // {\n // name: XXX,\n // enabled: Boolean,\n // fn: Function(),\n // alt: [ name2, name3 ]\n // }\n //\n this.__rules__ = [];\n\n // Cached rule chains.\n //\n // First level - chain name, '' for default.\n // Second level - diginal anchor for fast filtering by charcodes.\n //\n this.__cache__ = null;\n}\n\n////////////////////////////////////////////////////////////////////////////////\n// Helper methods, should not be used directly\n\n\n// Find rule index by name\n//\nRuler.prototype.__find__ = function (name) {\n for (var i = 0; i < this.__rules__.length; i++) {\n if (this.__rules__[i].name === name) {\n return i;\n }\n }\n return -1;\n};\n\n\n// Build rules lookup cache\n//\nRuler.prototype.__compile__ = function () {\n var self = this;\n var chains = [ '' ];\n\n // collect unique names\n self.__rules__.forEach(function (rule) {\n if (!rule.enabled) { return; }\n\n rule.alt.forEach(function (altName) {\n if (chains.indexOf(altName) < 0) {\n chains.push(altName);\n }\n });\n });\n\n self.__cache__ = {};\n\n chains.forEach(function (chain) {\n self.__cache__[chain] = [];\n self.__rules__.forEach(function (rule) {\n if (!rule.enabled) { return; }\n\n if (chain && rule.alt.indexOf(chain) < 0) { return; }\n\n self.__cache__[chain].push(rule.fn);\n });\n });\n};\n\n\n/**\n * Ruler.at(name, fn [, options])\n * - name (String): rule name to replace.\n * - fn (Function): new rule function.\n * - options (Object): new rule options (not mandatory).\n *\n * Replace rule by name with new function & options. Throws error if name not\n * found.\n *\n * ##### Options:\n *\n * - __alt__ - array with names of \"alternate\" chains.\n *\n * ##### Example\n *\n * Replace existing typographer replacement rule with new one:\n *\n * ```javascript\n * var md = require('markdown-it')();\n *\n * md.core.ruler.at('replacements', function replace(state) {\n * //...\n * });\n * ```\n **/\nRuler.prototype.at = function (name, fn, options) {\n var index = this.__find__(name);\n var opt = options || {};\n\n if (index === -1) { throw new Error('Parser rule not found: ' + name); }\n\n this.__rules__[index].fn = fn;\n this.__rules__[index].alt = opt.alt || [];\n this.__cache__ = null;\n};\n\n\n/**\n * Ruler.before(beforeName, ruleName, fn [, options])\n * - beforeName (String): new rule will be added before this one.\n * - ruleName (String): name of added rule.\n * - fn (Function): rule function.\n * - options (Object): rule options (not mandatory).\n *\n * Add new rule to chain before one with given name. See also\n * [[Ruler.after]], [[Ruler.push]].\n *\n * ##### Options:\n *\n * - __alt__ - array with names of \"alternate\" chains.\n *\n * ##### Example\n *\n * ```javascript\n * var md = require('markdown-it')();\n *\n * md.block.ruler.before('paragraph', 'my_rule', function replace(state) {\n * //...\n * });\n * ```\n **/\nRuler.prototype.before = function (beforeName, ruleName, fn, options) {\n var index = this.__find__(beforeName);\n var opt = options || {};\n\n if (index === -1) { throw new Error('Parser rule not found: ' + beforeName); }\n\n this.__rules__.splice(index, 0, {\n name: ruleName,\n enabled: true,\n fn: fn,\n alt: opt.alt || []\n });\n\n this.__cache__ = null;\n};\n\n\n/**\n * Ruler.after(afterName, ruleName, fn [, options])\n * - afterName (String): new rule will be added after this one.\n * - ruleName (String): name of added rule.\n * - fn (Function): rule function.\n * - options (Object): rule options (not mandatory).\n *\n * Add new rule to chain after one with given name. See also\n * [[Ruler.before]], [[Ruler.push]].\n *\n * ##### Options:\n *\n * - __alt__ - array with names of \"alternate\" chains.\n *\n * ##### Example\n *\n * ```javascript\n * var md = require('markdown-it')();\n *\n * md.inline.ruler.after('text', 'my_rule', function replace(state) {\n * //...\n * });\n * ```\n **/\nRuler.prototype.after = function (afterName, ruleName, fn, options) {\n var index = this.__find__(afterName);\n var opt = options || {};\n\n if (index === -1) { throw new Error('Parser rule not found: ' + afterName); }\n\n this.__rules__.splice(index + 1, 0, {\n name: ruleName,\n enabled: true,\n fn: fn,\n alt: opt.alt || []\n });\n\n this.__cache__ = null;\n};\n\n/**\n * Ruler.push(ruleName, fn [, options])\n * - ruleName (String): name of added rule.\n * - fn (Function): rule function.\n * - options (Object): rule options (not mandatory).\n *\n * Push new rule to the end of chain. See also\n * [[Ruler.before]], [[Ruler.after]].\n *\n * ##### Options:\n *\n * - __alt__ - array with names of \"alternate\" chains.\n *\n * ##### Example\n *\n * ```javascript\n * var md = require('markdown-it')();\n *\n * md.core.ruler.push('my_rule', function replace(state) {\n * //...\n * });\n * ```\n **/\nRuler.prototype.push = function (ruleName, fn, options) {\n var opt = options || {};\n\n this.__rules__.push({\n name: ruleName,\n enabled: true,\n fn: fn,\n alt: opt.alt || []\n });\n\n this.__cache__ = null;\n};\n\n\n/**\n * Ruler.enable(list [, ignoreInvalid]) -> Array\n * - list (String|Array): list of rule names to enable.\n * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.\n *\n * Enable rules with given names. If any rule name not found - throw Error.\n * Errors can be disabled by second param.\n *\n * Returns list of found rule names (if no exception happened).\n *\n * See also [[Ruler.disable]], [[Ruler.enableOnly]].\n **/\nRuler.prototype.enable = function (list, ignoreInvalid) {\n if (!Array.isArray(list)) { list = [ list ]; }\n\n var result = [];\n\n // Search by name and enable\n list.forEach(function (name) {\n var idx = this.__find__(name);\n\n if (idx < 0) {\n if (ignoreInvalid) { return; }\n throw new Error('Rules manager: invalid rule name ' + name);\n }\n this.__rules__[idx].enabled = true;\n result.push(name);\n }, this);\n\n this.__cache__ = null;\n return result;\n};\n\n\n/**\n * Ruler.enableOnly(list [, ignoreInvalid])\n * - list (String|Array): list of rule names to enable (whitelist).\n * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.\n *\n * Enable rules with given names, and disable everything else. If any rule name\n * not found - throw Error. Errors can be disabled by second param.\n *\n * See also [[Ruler.disable]], [[Ruler.enable]].\n **/\nRuler.prototype.enableOnly = function (list, ignoreInvalid) {\n if (!Array.isArray(list)) { list = [ list ]; }\n\n this.__rules__.forEach(function (rule) { rule.enabled = false; });\n\n this.enable(list, ignoreInvalid);\n};\n\n\n/**\n * Ruler.disable(list [, ignoreInvalid]) -> Array\n * - list (String|Array): list of rule names to disable.\n * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.\n *\n * Disable rules with given names. If any rule name not found - throw Error.\n * Errors can be disabled by second param.\n *\n * Returns list of found rule names (if no exception happened).\n *\n * See also [[Ruler.enable]], [[Ruler.enableOnly]].\n **/\nRuler.prototype.disable = function (list, ignoreInvalid) {\n if (!Array.isArray(list)) { list = [ list ]; }\n\n var result = [];\n\n // Search by name and disable\n list.forEach(function (name) {\n var idx = this.__find__(name);\n\n if (idx < 0) {\n if (ignoreInvalid) { return; }\n throw new Error('Rules manager: invalid rule name ' + name);\n }\n this.__rules__[idx].enabled = false;\n result.push(name);\n }, this);\n\n this.__cache__ = null;\n return result;\n};\n\n\n/**\n * Ruler.getRules(chainName) -> Array\n *\n * Return array of active functions (rules) for given chain name. It analyzes\n * rules configuration, compiles caches if not exists and returns result.\n *\n * Default chain name is `''` (empty string). It can't be skipped. That's\n * done intentionally, to keep signature monomorphic for high speed.\n **/\nRuler.prototype.getRules = function (chainName) {\n if (this.__cache__ === null) {\n this.__compile__();\n }\n\n // Chain can be empty, if rules disabled. But we still have to return Array.\n return this.__cache__[chainName] || [];\n};\n\nmodule.exports = Ruler;\n","// Block quotes\n\n'use strict';\n\nvar isSpace = require('../common/utils').isSpace;\n\n\nmodule.exports = function blockquote(state, startLine, endLine, silent) {\n var adjustTab,\n ch,\n i,\n initial,\n l,\n lastLineEmpty,\n lines,\n nextLine,\n offset,\n oldBMarks,\n oldBSCount,\n oldIndent,\n oldParentType,\n oldSCount,\n oldTShift,\n spaceAfterMarker,\n terminate,\n terminatorRules,\n token,\n isOutdented,\n oldLineMax = state.lineMax,\n pos = state.bMarks[startLine] + state.tShift[startLine],\n max = state.eMarks[startLine];\n\n // if it's indented more than 3 spaces, it should be a code block\n if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }\n\n // check the block quote marker\n if (state.src.charCodeAt(pos++) !== 0x3E/* > */) { return false; }\n\n // we know that it's going to be a valid blockquote,\n // so no point trying to find the end of it in silent mode\n if (silent) { return true; }\n\n // set offset past spaces and \">\"\n initial = offset = state.sCount[startLine] + 1;\n\n // skip one optional space after '>'\n if (state.src.charCodeAt(pos) === 0x20 /* space */) {\n // ' > test '\n // ^ -- position start of line here:\n pos++;\n initial++;\n offset++;\n adjustTab = false;\n spaceAfterMarker = true;\n } else if (state.src.charCodeAt(pos) === 0x09 /* tab */) {\n spaceAfterMarker = true;\n\n if ((state.bsCount[startLine] + offset) % 4 === 3) {\n // ' >\\t test '\n // ^ -- position start of line here (tab has width===1)\n pos++;\n initial++;\n offset++;\n adjustTab = false;\n } else {\n // ' >\\t test '\n // ^ -- position start of line here + shift bsCount slightly\n // to make extra space appear\n adjustTab = true;\n }\n } else {\n spaceAfterMarker = false;\n }\n\n oldBMarks = [ state.bMarks[startLine] ];\n state.bMarks[startLine] = pos;\n\n while (pos < max) {\n ch = state.src.charCodeAt(pos);\n\n if (isSpace(ch)) {\n if (ch === 0x09) {\n offset += 4 - (offset + state.bsCount[startLine] + (adjustTab ? 1 : 0)) % 4;\n } else {\n offset++;\n }\n } else {\n break;\n }\n\n pos++;\n }\n\n oldBSCount = [ state.bsCount[startLine] ];\n state.bsCount[startLine] = state.sCount[startLine] + 1 + (spaceAfterMarker ? 1 : 0);\n\n lastLineEmpty = pos >= max;\n\n oldSCount = [ state.sCount[startLine] ];\n state.sCount[startLine] = offset - initial;\n\n oldTShift = [ state.tShift[startLine] ];\n state.tShift[startLine] = pos - state.bMarks[startLine];\n\n terminatorRules = state.md.block.ruler.getRules('blockquote');\n\n oldParentType = state.parentType;\n state.parentType = 'blockquote';\n\n // Search the end of the block\n //\n // Block ends with either:\n // 1. an empty line outside:\n // ```\n // > test\n //\n // ```\n // 2. an empty line inside:\n // ```\n // >\n // test\n // ```\n // 3. another tag:\n // ```\n // > test\n // - - -\n // ```\n for (nextLine = startLine + 1; nextLine < endLine; nextLine++) {\n // check if it's outdented, i.e. it's inside list item and indented\n // less than said list item:\n //\n // ```\n // 1. anything\n // > current blockquote\n // 2. checking this line\n // ```\n isOutdented = state.sCount[nextLine] < state.blkIndent;\n\n pos = state.bMarks[nextLine] + state.tShift[nextLine];\n max = state.eMarks[nextLine];\n\n if (pos >= max) {\n // Case 1: line is not inside the blockquote, and this line is empty.\n break;\n }\n\n if (state.src.charCodeAt(pos++) === 0x3E/* > */ && !isOutdented) {\n // This line is inside the blockquote.\n\n // set offset past spaces and \">\"\n initial = offset = state.sCount[nextLine] + 1;\n\n // skip one optional space after '>'\n if (state.src.charCodeAt(pos) === 0x20 /* space */) {\n // ' > test '\n // ^ -- position start of line here:\n pos++;\n initial++;\n offset++;\n adjustTab = false;\n spaceAfterMarker = true;\n } else if (state.src.charCodeAt(pos) === 0x09 /* tab */) {\n spaceAfterMarker = true;\n\n if ((state.bsCount[nextLine] + offset) % 4 === 3) {\n // ' >\\t test '\n // ^ -- position start of line here (tab has width===1)\n pos++;\n initial++;\n offset++;\n adjustTab = false;\n } else {\n // ' >\\t test '\n // ^ -- position start of line here + shift bsCount slightly\n // to make extra space appear\n adjustTab = true;\n }\n } else {\n spaceAfterMarker = false;\n }\n\n oldBMarks.push(state.bMarks[nextLine]);\n state.bMarks[nextLine] = pos;\n\n while (pos < max) {\n ch = state.src.charCodeAt(pos);\n\n if (isSpace(ch)) {\n if (ch === 0x09) {\n offset += 4 - (offset + state.bsCount[nextLine] + (adjustTab ? 1 : 0)) % 4;\n } else {\n offset++;\n }\n } else {\n break;\n }\n\n pos++;\n }\n\n lastLineEmpty = pos >= max;\n\n oldBSCount.push(state.bsCount[nextLine]);\n state.bsCount[nextLine] = state.sCount[nextLine] + 1 + (spaceAfterMarker ? 1 : 0);\n\n oldSCount.push(state.sCount[nextLine]);\n state.sCount[nextLine] = offset - initial;\n\n oldTShift.push(state.tShift[nextLine]);\n state.tShift[nextLine] = pos - state.bMarks[nextLine];\n continue;\n }\n\n // Case 2: line is not inside the blockquote, and the last line was empty.\n if (lastLineEmpty) { break; }\n\n // Case 3: another tag found.\n terminate = false;\n for (i = 0, l = terminatorRules.length; i < l; i++) {\n if (terminatorRules[i](state, nextLine, endLine, true)) {\n terminate = true;\n break;\n }\n }\n\n if (terminate) {\n // Quirk to enforce \"hard termination mode\" for paragraphs;\n // normally if you call `tokenize(state, startLine, nextLine)`,\n // paragraphs will look below nextLine for paragraph continuation,\n // but if blockquote is terminated by another tag, they shouldn't\n state.lineMax = nextLine;\n\n if (state.blkIndent !== 0) {\n // state.blkIndent was non-zero, we now set it to zero,\n // so we need to re-calculate all offsets to appear as\n // if indent wasn't changed\n oldBMarks.push(state.bMarks[nextLine]);\n oldBSCount.push(state.bsCount[nextLine]);\n oldTShift.push(state.tShift[nextLine]);\n oldSCount.push(state.sCount[nextLine]);\n state.sCount[nextLine] -= state.blkIndent;\n }\n\n break;\n }\n\n oldBMarks.push(state.bMarks[nextLine]);\n oldBSCount.push(state.bsCount[nextLine]);\n oldTShift.push(state.tShift[nextLine]);\n oldSCount.push(state.sCount[nextLine]);\n\n // A negative indentation means that this is a paragraph continuation\n //\n state.sCount[nextLine] = -1;\n }\n\n oldIndent = state.blkIndent;\n state.blkIndent = 0;\n\n token = state.push('blockquote_open', 'blockquote', 1);\n token.markup = '>';\n token.map = lines = [ startLine, 0 ];\n\n state.md.block.tokenize(state, startLine, nextLine);\n\n token = state.push('blockquote_close', 'blockquote', -1);\n token.markup = '>';\n\n state.lineMax = oldLineMax;\n state.parentType = oldParentType;\n lines[1] = state.line;\n\n // Restore original tShift; this might not be necessary since the parser\n // has already been here, but just to make sure we can do that.\n for (i = 0; i < oldTShift.length; i++) {\n state.bMarks[i + startLine] = oldBMarks[i];\n state.tShift[i + startLine] = oldTShift[i];\n state.sCount[i + startLine] = oldSCount[i];\n state.bsCount[i + startLine] = oldBSCount[i];\n }\n state.blkIndent = oldIndent;\n\n return true;\n};\n","// Code block (4 spaces padded)\n\n'use strict';\n\n\nmodule.exports = function code(state, startLine, endLine/*, silent*/) {\n var nextLine, last, token;\n\n if (state.sCount[startLine] - state.blkIndent < 4) { return false; }\n\n last = nextLine = startLine + 1;\n\n while (nextLine < endLine) {\n if (state.isEmpty(nextLine)) {\n nextLine++;\n continue;\n }\n\n if (state.sCount[nextLine] - state.blkIndent >= 4) {\n nextLine++;\n last = nextLine;\n continue;\n }\n break;\n }\n\n state.line = last;\n\n token = state.push('code_block', 'code', 0);\n token.content = state.getLines(startLine, last, 4 + state.blkIndent, false) + '\\n';\n token.map = [ startLine, state.line ];\n\n return true;\n};\n","// fences (``` lang, ~~~ lang)\n\n'use strict';\n\n\nmodule.exports = function fence(state, startLine, endLine, silent) {\n var marker, len, params, nextLine, mem, token, markup,\n haveEndMarker = false,\n pos = state.bMarks[startLine] + state.tShift[startLine],\n max = state.eMarks[startLine];\n\n // if it's indented more than 3 spaces, it should be a code block\n if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }\n\n if (pos + 3 > max) { return false; }\n\n marker = state.src.charCodeAt(pos);\n\n if (marker !== 0x7E/* ~ */ && marker !== 0x60 /* ` */) {\n return false;\n }\n\n // scan marker length\n mem = pos;\n pos = state.skipChars(pos, marker);\n\n len = pos - mem;\n\n if (len < 3) { return false; }\n\n markup = state.src.slice(mem, pos);\n params = state.src.slice(pos, max);\n\n if (marker === 0x60 /* ` */) {\n if (params.indexOf(String.fromCharCode(marker)) >= 0) {\n return false;\n }\n }\n\n // Since start is found, we can report success here in validation mode\n if (silent) { return true; }\n\n // search end of block\n nextLine = startLine;\n\n for (;;) {\n nextLine++;\n if (nextLine >= endLine) {\n // unclosed block should be autoclosed by end of document.\n // also block seems to be autoclosed by end of parent\n break;\n }\n\n pos = mem = state.bMarks[nextLine] + state.tShift[nextLine];\n max = state.eMarks[nextLine];\n\n if (pos < max && state.sCount[nextLine] < state.blkIndent) {\n // non-empty line with negative indent should stop the list:\n // - ```\n // test\n break;\n }\n\n if (state.src.charCodeAt(pos) !== marker) { continue; }\n\n if (state.sCount[nextLine] - state.blkIndent >= 4) {\n // closing fence should be indented less than 4 spaces\n continue;\n }\n\n pos = state.skipChars(pos, marker);\n\n // closing code fence must be at least as long as the opening one\n if (pos - mem < len) { continue; }\n\n // make sure tail has spaces only\n pos = state.skipSpaces(pos);\n\n if (pos < max) { continue; }\n\n haveEndMarker = true;\n // found!\n break;\n }\n\n // If a fence has heading spaces, they should be removed from its inner block\n len = state.sCount[startLine];\n\n state.line = nextLine + (haveEndMarker ? 1 : 0);\n\n token = state.push('fence', 'code', 0);\n token.info = params;\n token.content = state.getLines(startLine + 1, nextLine, len, true);\n token.markup = markup;\n token.map = [ startLine, state.line ];\n\n return true;\n};\n","// heading (#, ##, ...)\n\n'use strict';\n\nvar isSpace = require('../common/utils').isSpace;\n\n\nmodule.exports = function heading(state, startLine, endLine, silent) {\n var ch, level, tmp, token,\n pos = state.bMarks[startLine] + state.tShift[startLine],\n max = state.eMarks[startLine];\n\n // if it's indented more than 3 spaces, it should be a code block\n if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }\n\n ch = state.src.charCodeAt(pos);\n\n if (ch !== 0x23/* # */ || pos >= max) { return false; }\n\n // count heading level\n level = 1;\n ch = state.src.charCodeAt(++pos);\n while (ch === 0x23/* # */ && pos < max && level <= 6) {\n level++;\n ch = state.src.charCodeAt(++pos);\n }\n\n if (level > 6 || (pos < max && !isSpace(ch))) { return false; }\n\n if (silent) { return true; }\n\n // Let's cut tails like ' ### ' from the end of string\n\n max = state.skipSpacesBack(max, pos);\n tmp = state.skipCharsBack(max, 0x23, pos); // #\n if (tmp > pos && isSpace(state.src.charCodeAt(tmp - 1))) {\n max = tmp;\n }\n\n state.line = startLine + 1;\n\n token = state.push('heading_open', 'h' + String(level), 1);\n token.markup = '########'.slice(0, level);\n token.map = [ startLine, state.line ];\n\n token = state.push('inline', '', 0);\n token.content = state.src.slice(pos, max).trim();\n token.map = [ startLine, state.line ];\n token.children = [];\n\n token = state.push('heading_close', 'h' + String(level), -1);\n token.markup = '########'.slice(0, level);\n\n return true;\n};\n","// Horizontal rule\n\n'use strict';\n\nvar isSpace = require('../common/utils').isSpace;\n\n\nmodule.exports = function hr(state, startLine, endLine, silent) {\n var marker, cnt, ch, token,\n pos = state.bMarks[startLine] + state.tShift[startLine],\n max = state.eMarks[startLine];\n\n // if it's indented more than 3 spaces, it should be a code block\n if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }\n\n marker = state.src.charCodeAt(pos++);\n\n // Check hr marker\n if (marker !== 0x2A/* * */ &&\n marker !== 0x2D/* - */ &&\n marker !== 0x5F/* _ */) {\n return false;\n }\n\n // markers can be mixed with spaces, but there should be at least 3 of them\n\n cnt = 1;\n while (pos < max) {\n ch = state.src.charCodeAt(pos++);\n if (ch !== marker && !isSpace(ch)) { return false; }\n if (ch === marker) { cnt++; }\n }\n\n if (cnt < 3) { return false; }\n\n if (silent) { return true; }\n\n state.line = startLine + 1;\n\n token = state.push('hr', 'hr', 0);\n token.map = [ startLine, state.line ];\n token.markup = Array(cnt + 1).join(String.fromCharCode(marker));\n\n return true;\n};\n","// HTML block\n\n'use strict';\n\n\nvar block_names = require('../common/html_blocks');\nvar HTML_OPEN_CLOSE_TAG_RE = require('../common/html_re').HTML_OPEN_CLOSE_TAG_RE;\n\n// An array of opening and corresponding closing sequences for html tags,\n// last argument defines whether it can terminate a paragraph or not\n//\nvar HTML_SEQUENCES = [\n [ /^<(script|pre|style|textarea)(?=(\\s|>|$))/i, /<\\/(script|pre|style|textarea)>/i, true ],\n [ /^/, true ],\n [ /^<\\?/, /\\?>/, true ],\n [ /^/, true ],\n [ /^/, true ],\n [ new RegExp('^|$))', 'i'), /^$/, true ],\n [ new RegExp(HTML_OPEN_CLOSE_TAG_RE.source + '\\\\s*$'), /^$/, false ]\n];\n\n\nmodule.exports = function html_block(state, startLine, endLine, silent) {\n var i, nextLine, token, lineText,\n pos = state.bMarks[startLine] + state.tShift[startLine],\n max = state.eMarks[startLine];\n\n // if it's indented more than 3 spaces, it should be a code block\n if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }\n\n if (!state.md.options.html) { return false; }\n\n if (state.src.charCodeAt(pos) !== 0x3C/* < */) { return false; }\n\n lineText = state.src.slice(pos, max);\n\n for (i = 0; i < HTML_SEQUENCES.length; i++) {\n if (HTML_SEQUENCES[i][0].test(lineText)) { break; }\n }\n\n if (i === HTML_SEQUENCES.length) { return false; }\n\n if (silent) {\n // true if this sequence can be a terminator, false otherwise\n return HTML_SEQUENCES[i][2];\n }\n\n nextLine = startLine + 1;\n\n // If we are here - we detected HTML block.\n // Let's roll down till block end.\n if (!HTML_SEQUENCES[i][1].test(lineText)) {\n for (; nextLine < endLine; nextLine++) {\n if (state.sCount[nextLine] < state.blkIndent) { break; }\n\n pos = state.bMarks[nextLine] + state.tShift[nextLine];\n max = state.eMarks[nextLine];\n lineText = state.src.slice(pos, max);\n\n if (HTML_SEQUENCES[i][1].test(lineText)) {\n if (lineText.length !== 0) { nextLine++; }\n break;\n }\n }\n }\n\n state.line = nextLine;\n\n token = state.push('html_block', '', 0);\n token.map = [ startLine, nextLine ];\n token.content = state.getLines(startLine, nextLine, state.blkIndent, true);\n\n return true;\n};\n","// lheading (---, ===)\n\n'use strict';\n\n\nmodule.exports = function lheading(state, startLine, endLine/*, silent*/) {\n var content, terminate, i, l, token, pos, max, level, marker,\n nextLine = startLine + 1, oldParentType,\n terminatorRules = state.md.block.ruler.getRules('paragraph');\n\n // if it's indented more than 3 spaces, it should be a code block\n if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }\n\n oldParentType = state.parentType;\n state.parentType = 'paragraph'; // use paragraph to match terminatorRules\n\n // jump line-by-line until empty one or EOF\n for (; nextLine < endLine && !state.isEmpty(nextLine); nextLine++) {\n // this would be a code block normally, but after paragraph\n // it's considered a lazy continuation regardless of what's there\n if (state.sCount[nextLine] - state.blkIndent > 3) { continue; }\n\n //\n // Check for underline in setext header\n //\n if (state.sCount[nextLine] >= state.blkIndent) {\n pos = state.bMarks[nextLine] + state.tShift[nextLine];\n max = state.eMarks[nextLine];\n\n if (pos < max) {\n marker = state.src.charCodeAt(pos);\n\n if (marker === 0x2D/* - */ || marker === 0x3D/* = */) {\n pos = state.skipChars(pos, marker);\n pos = state.skipSpaces(pos);\n\n if (pos >= max) {\n level = (marker === 0x3D/* = */ ? 1 : 2);\n break;\n }\n }\n }\n }\n\n // quirk for blockquotes, this line should already be checked by that rule\n if (state.sCount[nextLine] < 0) { continue; }\n\n // Some tags can terminate paragraph without empty line.\n terminate = false;\n for (i = 0, l = terminatorRules.length; i < l; i++) {\n if (terminatorRules[i](state, nextLine, endLine, true)) {\n terminate = true;\n break;\n }\n }\n if (terminate) { break; }\n }\n\n if (!level) {\n // Didn't find valid underline\n return false;\n }\n\n content = state.getLines(startLine, nextLine, state.blkIndent, false).trim();\n\n state.line = nextLine + 1;\n\n token = state.push('heading_open', 'h' + String(level), 1);\n token.markup = String.fromCharCode(marker);\n token.map = [ startLine, state.line ];\n\n token = state.push('inline', '', 0);\n token.content = content;\n token.map = [ startLine, state.line - 1 ];\n token.children = [];\n\n token = state.push('heading_close', 'h' + String(level), -1);\n token.markup = String.fromCharCode(marker);\n\n state.parentType = oldParentType;\n\n return true;\n};\n","// Lists\n\n'use strict';\n\nvar isSpace = require('../common/utils').isSpace;\n\n\n// Search `[-+*][\\n ]`, returns next pos after marker on success\n// or -1 on fail.\nfunction skipBulletListMarker(state, startLine) {\n var marker, pos, max, ch;\n\n pos = state.bMarks[startLine] + state.tShift[startLine];\n max = state.eMarks[startLine];\n\n marker = state.src.charCodeAt(pos++);\n // Check bullet\n if (marker !== 0x2A/* * */ &&\n marker !== 0x2D/* - */ &&\n marker !== 0x2B/* + */) {\n return -1;\n }\n\n if (pos < max) {\n ch = state.src.charCodeAt(pos);\n\n if (!isSpace(ch)) {\n // \" -test \" - is not a list item\n return -1;\n }\n }\n\n return pos;\n}\n\n// Search `\\d+[.)][\\n ]`, returns next pos after marker on success\n// or -1 on fail.\nfunction skipOrderedListMarker(state, startLine) {\n var ch,\n start = state.bMarks[startLine] + state.tShift[startLine],\n pos = start,\n max = state.eMarks[startLine];\n\n // List marker should have at least 2 chars (digit + dot)\n if (pos + 1 >= max) { return -1; }\n\n ch = state.src.charCodeAt(pos++);\n\n if (ch < 0x30/* 0 */ || ch > 0x39/* 9 */) { return -1; }\n\n for (;;) {\n // EOL -> fail\n if (pos >= max) { return -1; }\n\n ch = state.src.charCodeAt(pos++);\n\n if (ch >= 0x30/* 0 */ && ch <= 0x39/* 9 */) {\n\n // List marker should have no more than 9 digits\n // (prevents integer overflow in browsers)\n if (pos - start >= 10) { return -1; }\n\n continue;\n }\n\n // found valid marker\n if (ch === 0x29/* ) */ || ch === 0x2e/* . */) {\n break;\n }\n\n return -1;\n }\n\n\n if (pos < max) {\n ch = state.src.charCodeAt(pos);\n\n if (!isSpace(ch)) {\n // \" 1.test \" - is not a list item\n return -1;\n }\n }\n return pos;\n}\n\nfunction markTightParagraphs(state, idx) {\n var i, l,\n level = state.level + 2;\n\n for (i = idx + 2, l = state.tokens.length - 2; i < l; i++) {\n if (state.tokens[i].level === level && state.tokens[i].type === 'paragraph_open') {\n state.tokens[i + 2].hidden = true;\n state.tokens[i].hidden = true;\n i += 2;\n }\n }\n}\n\n\nmodule.exports = function list(state, startLine, endLine, silent) {\n var ch,\n contentStart,\n i,\n indent,\n indentAfterMarker,\n initial,\n isOrdered,\n itemLines,\n l,\n listLines,\n listTokIdx,\n markerCharCode,\n markerValue,\n max,\n nextLine,\n offset,\n oldListIndent,\n oldParentType,\n oldSCount,\n oldTShift,\n oldTight,\n pos,\n posAfterMarker,\n prevEmptyEnd,\n start,\n terminate,\n terminatorRules,\n token,\n isTerminatingParagraph = false,\n tight = true;\n\n // if it's indented more than 3 spaces, it should be a code block\n if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }\n\n // Special case:\n // - item 1\n // - item 2\n // - item 3\n // - item 4\n // - this one is a paragraph continuation\n if (state.listIndent >= 0 &&\n state.sCount[startLine] - state.listIndent >= 4 &&\n state.sCount[startLine] < state.blkIndent) {\n return false;\n }\n\n // limit conditions when list can interrupt\n // a paragraph (validation mode only)\n if (silent && state.parentType === 'paragraph') {\n // Next list item should still terminate previous list item;\n //\n // This code can fail if plugins use blkIndent as well as lists,\n // but I hope the spec gets fixed long before that happens.\n //\n if (state.sCount[startLine] >= state.blkIndent) {\n isTerminatingParagraph = true;\n }\n }\n\n // Detect list type and position after marker\n if ((posAfterMarker = skipOrderedListMarker(state, startLine)) >= 0) {\n isOrdered = true;\n start = state.bMarks[startLine] + state.tShift[startLine];\n markerValue = Number(state.src.slice(start, posAfterMarker - 1));\n\n // If we're starting a new ordered list right after\n // a paragraph, it should start with 1.\n if (isTerminatingParagraph && markerValue !== 1) return false;\n\n } else if ((posAfterMarker = skipBulletListMarker(state, startLine)) >= 0) {\n isOrdered = false;\n\n } else {\n return false;\n }\n\n // If we're starting a new unordered list right after\n // a paragraph, first line should not be empty.\n if (isTerminatingParagraph) {\n if (state.skipSpaces(posAfterMarker) >= state.eMarks[startLine]) return false;\n }\n\n // We should terminate list on style change. Remember first one to compare.\n markerCharCode = state.src.charCodeAt(posAfterMarker - 1);\n\n // For validation mode we can terminate immediately\n if (silent) { return true; }\n\n // Start list\n listTokIdx = state.tokens.length;\n\n if (isOrdered) {\n token = state.push('ordered_list_open', 'ol', 1);\n if (markerValue !== 1) {\n token.attrs = [ [ 'start', markerValue ] ];\n }\n\n } else {\n token = state.push('bullet_list_open', 'ul', 1);\n }\n\n token.map = listLines = [ startLine, 0 ];\n token.markup = String.fromCharCode(markerCharCode);\n\n //\n // Iterate list items\n //\n\n nextLine = startLine;\n prevEmptyEnd = false;\n terminatorRules = state.md.block.ruler.getRules('list');\n\n oldParentType = state.parentType;\n state.parentType = 'list';\n\n while (nextLine < endLine) {\n pos = posAfterMarker;\n max = state.eMarks[nextLine];\n\n initial = offset = state.sCount[nextLine] + posAfterMarker - (state.bMarks[startLine] + state.tShift[startLine]);\n\n while (pos < max) {\n ch = state.src.charCodeAt(pos);\n\n if (ch === 0x09) {\n offset += 4 - (offset + state.bsCount[nextLine]) % 4;\n } else if (ch === 0x20) {\n offset++;\n } else {\n break;\n }\n\n pos++;\n }\n\n contentStart = pos;\n\n if (contentStart >= max) {\n // trimming space in \"- \\n 3\" case, indent is 1 here\n indentAfterMarker = 1;\n } else {\n indentAfterMarker = offset - initial;\n }\n\n // If we have more than 4 spaces, the indent is 1\n // (the rest is just indented code block)\n if (indentAfterMarker > 4) { indentAfterMarker = 1; }\n\n // \" - test\"\n // ^^^^^ - calculating total length of this thing\n indent = initial + indentAfterMarker;\n\n // Run subparser & write tokens\n token = state.push('list_item_open', 'li', 1);\n token.markup = String.fromCharCode(markerCharCode);\n token.map = itemLines = [ startLine, 0 ];\n if (isOrdered) {\n token.info = state.src.slice(start, posAfterMarker - 1);\n }\n\n // change current state, then restore it after parser subcall\n oldTight = state.tight;\n oldTShift = state.tShift[startLine];\n oldSCount = state.sCount[startLine];\n\n // - example list\n // ^ listIndent position will be here\n // ^ blkIndent position will be here\n //\n oldListIndent = state.listIndent;\n state.listIndent = state.blkIndent;\n state.blkIndent = indent;\n\n state.tight = true;\n state.tShift[startLine] = contentStart - state.bMarks[startLine];\n state.sCount[startLine] = offset;\n\n if (contentStart >= max && state.isEmpty(startLine + 1)) {\n // workaround for this case\n // (list item is empty, list terminates before \"foo\"):\n // ~~~~~~~~\n // -\n //\n // foo\n // ~~~~~~~~\n state.line = Math.min(state.line + 2, endLine);\n } else {\n state.md.block.tokenize(state, startLine, endLine, true);\n }\n\n // If any of list item is tight, mark list as tight\n if (!state.tight || prevEmptyEnd) {\n tight = false;\n }\n // Item become loose if finish with empty line,\n // but we should filter last element, because it means list finish\n prevEmptyEnd = (state.line - startLine) > 1 && state.isEmpty(state.line - 1);\n\n state.blkIndent = state.listIndent;\n state.listIndent = oldListIndent;\n state.tShift[startLine] = oldTShift;\n state.sCount[startLine] = oldSCount;\n state.tight = oldTight;\n\n token = state.push('list_item_close', 'li', -1);\n token.markup = String.fromCharCode(markerCharCode);\n\n nextLine = startLine = state.line;\n itemLines[1] = nextLine;\n contentStart = state.bMarks[startLine];\n\n if (nextLine >= endLine) { break; }\n\n //\n // Try to check if list is terminated or continued.\n //\n if (state.sCount[nextLine] < state.blkIndent) { break; }\n\n // if it's indented more than 3 spaces, it should be a code block\n if (state.sCount[startLine] - state.blkIndent >= 4) { break; }\n\n // fail if terminating block found\n terminate = false;\n for (i = 0, l = terminatorRules.length; i < l; i++) {\n if (terminatorRules[i](state, nextLine, endLine, true)) {\n terminate = true;\n break;\n }\n }\n if (terminate) { break; }\n\n // fail if list has another type\n if (isOrdered) {\n posAfterMarker = skipOrderedListMarker(state, nextLine);\n if (posAfterMarker < 0) { break; }\n start = state.bMarks[nextLine] + state.tShift[nextLine];\n } else {\n posAfterMarker = skipBulletListMarker(state, nextLine);\n if (posAfterMarker < 0) { break; }\n }\n\n if (markerCharCode !== state.src.charCodeAt(posAfterMarker - 1)) { break; }\n }\n\n // Finalize list\n if (isOrdered) {\n token = state.push('ordered_list_close', 'ol', -1);\n } else {\n token = state.push('bullet_list_close', 'ul', -1);\n }\n token.markup = String.fromCharCode(markerCharCode);\n\n listLines[1] = nextLine;\n state.line = nextLine;\n\n state.parentType = oldParentType;\n\n // mark paragraphs tight if needed\n if (tight) {\n markTightParagraphs(state, listTokIdx);\n }\n\n return true;\n};\n","// Paragraph\n\n'use strict';\n\n\nmodule.exports = function paragraph(state, startLine/*, endLine*/) {\n var content, terminate, i, l, token, oldParentType,\n nextLine = startLine + 1,\n terminatorRules = state.md.block.ruler.getRules('paragraph'),\n endLine = state.lineMax;\n\n oldParentType = state.parentType;\n state.parentType = 'paragraph';\n\n // jump line-by-line until empty one or EOF\n for (; nextLine < endLine && !state.isEmpty(nextLine); nextLine++) {\n // this would be a code block normally, but after paragraph\n // it's considered a lazy continuation regardless of what's there\n if (state.sCount[nextLine] - state.blkIndent > 3) { continue; }\n\n // quirk for blockquotes, this line should already be checked by that rule\n if (state.sCount[nextLine] < 0) { continue; }\n\n // Some tags can terminate paragraph without empty line.\n terminate = false;\n for (i = 0, l = terminatorRules.length; i < l; i++) {\n if (terminatorRules[i](state, nextLine, endLine, true)) {\n terminate = true;\n break;\n }\n }\n if (terminate) { break; }\n }\n\n content = state.getLines(startLine, nextLine, state.blkIndent, false).trim();\n\n state.line = nextLine;\n\n token = state.push('paragraph_open', 'p', 1);\n token.map = [ startLine, state.line ];\n\n token = state.push('inline', '', 0);\n token.content = content;\n token.map = [ startLine, state.line ];\n token.children = [];\n\n token = state.push('paragraph_close', 'p', -1);\n\n state.parentType = oldParentType;\n\n return true;\n};\n","'use strict';\n\n\nvar normalizeReference = require('../common/utils').normalizeReference;\nvar isSpace = require('../common/utils').isSpace;\n\n\nmodule.exports = function reference(state, startLine, _endLine, silent) {\n var ch,\n destEndPos,\n destEndLineNo,\n endLine,\n href,\n i,\n l,\n label,\n labelEnd,\n oldParentType,\n res,\n start,\n str,\n terminate,\n terminatorRules,\n title,\n lines = 0,\n pos = state.bMarks[startLine] + state.tShift[startLine],\n max = state.eMarks[startLine],\n nextLine = startLine + 1;\n\n // if it's indented more than 3 spaces, it should be a code block\n if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }\n\n if (state.src.charCodeAt(pos) !== 0x5B/* [ */) { return false; }\n\n // Simple check to quickly interrupt scan on [link](url) at the start of line.\n // Can be useful on practice: https://github.com/markdown-it/markdown-it/issues/54\n while (++pos < max) {\n if (state.src.charCodeAt(pos) === 0x5D /* ] */ &&\n state.src.charCodeAt(pos - 1) !== 0x5C/* \\ */) {\n if (pos + 1 === max) { return false; }\n if (state.src.charCodeAt(pos + 1) !== 0x3A/* : */) { return false; }\n break;\n }\n }\n\n endLine = state.lineMax;\n\n // jump line-by-line until empty one or EOF\n terminatorRules = state.md.block.ruler.getRules('reference');\n\n oldParentType = state.parentType;\n state.parentType = 'reference';\n\n for (; nextLine < endLine && !state.isEmpty(nextLine); nextLine++) {\n // this would be a code block normally, but after paragraph\n // it's considered a lazy continuation regardless of what's there\n if (state.sCount[nextLine] - state.blkIndent > 3) { continue; }\n\n // quirk for blockquotes, this line should already be checked by that rule\n if (state.sCount[nextLine] < 0) { continue; }\n\n // Some tags can terminate paragraph without empty line.\n terminate = false;\n for (i = 0, l = terminatorRules.length; i < l; i++) {\n if (terminatorRules[i](state, nextLine, endLine, true)) {\n terminate = true;\n break;\n }\n }\n if (terminate) { break; }\n }\n\n str = state.getLines(startLine, nextLine, state.blkIndent, false).trim();\n max = str.length;\n\n for (pos = 1; pos < max; pos++) {\n ch = str.charCodeAt(pos);\n if (ch === 0x5B /* [ */) {\n return false;\n } else if (ch === 0x5D /* ] */) {\n labelEnd = pos;\n break;\n } else if (ch === 0x0A /* \\n */) {\n lines++;\n } else if (ch === 0x5C /* \\ */) {\n pos++;\n if (pos < max && str.charCodeAt(pos) === 0x0A) {\n lines++;\n }\n }\n }\n\n if (labelEnd < 0 || str.charCodeAt(labelEnd + 1) !== 0x3A/* : */) { return false; }\n\n // [label]: destination 'title'\n // ^^^ skip optional whitespace here\n for (pos = labelEnd + 2; pos < max; pos++) {\n ch = str.charCodeAt(pos);\n if (ch === 0x0A) {\n lines++;\n } else if (isSpace(ch)) {\n /*eslint no-empty:0*/\n } else {\n break;\n }\n }\n\n // [label]: destination 'title'\n // ^^^^^^^^^^^ parse this\n res = state.md.helpers.parseLinkDestination(str, pos, max);\n if (!res.ok) { return false; }\n\n href = state.md.normalizeLink(res.str);\n if (!state.md.validateLink(href)) { return false; }\n\n pos = res.pos;\n lines += res.lines;\n\n // save cursor state, we could require to rollback later\n destEndPos = pos;\n destEndLineNo = lines;\n\n // [label]: destination 'title'\n // ^^^ skipping those spaces\n start = pos;\n for (; pos < max; pos++) {\n ch = str.charCodeAt(pos);\n if (ch === 0x0A) {\n lines++;\n } else if (isSpace(ch)) {\n /*eslint no-empty:0*/\n } else {\n break;\n }\n }\n\n // [label]: destination 'title'\n // ^^^^^^^ parse this\n res = state.md.helpers.parseLinkTitle(str, pos, max);\n if (pos < max && start !== pos && res.ok) {\n title = res.str;\n pos = res.pos;\n lines += res.lines;\n } else {\n title = '';\n pos = destEndPos;\n lines = destEndLineNo;\n }\n\n // skip trailing spaces until the rest of the line\n while (pos < max) {\n ch = str.charCodeAt(pos);\n if (!isSpace(ch)) { break; }\n pos++;\n }\n\n if (pos < max && str.charCodeAt(pos) !== 0x0A) {\n if (title) {\n // garbage at the end of the line after title,\n // but it could still be a valid reference if we roll back\n title = '';\n pos = destEndPos;\n lines = destEndLineNo;\n while (pos < max) {\n ch = str.charCodeAt(pos);\n if (!isSpace(ch)) { break; }\n pos++;\n }\n }\n }\n\n if (pos < max && str.charCodeAt(pos) !== 0x0A) {\n // garbage at the end of the line\n return false;\n }\n\n label = normalizeReference(str.slice(1, labelEnd));\n if (!label) {\n // CommonMark 0.20 disallows empty labels\n return false;\n }\n\n // Reference can not terminate anything. This check is for safety only.\n /*istanbul ignore if*/\n if (silent) { return true; }\n\n if (typeof state.env.references === 'undefined') {\n state.env.references = {};\n }\n if (typeof state.env.references[label] === 'undefined') {\n state.env.references[label] = { title: title, href: href };\n }\n\n state.parentType = oldParentType;\n\n state.line = startLine + lines + 1;\n return true;\n};\n","// Parser state class\n\n'use strict';\n\nvar Token = require('../token');\nvar isSpace = require('../common/utils').isSpace;\n\n\nfunction StateBlock(src, md, env, tokens) {\n var ch, s, start, pos, len, indent, offset, indent_found;\n\n this.src = src;\n\n // link to parser instance\n this.md = md;\n\n this.env = env;\n\n //\n // Internal state vartiables\n //\n\n this.tokens = tokens;\n\n this.bMarks = []; // line begin offsets for fast jumps\n this.eMarks = []; // line end offsets for fast jumps\n this.tShift = []; // offsets of the first non-space characters (tabs not expanded)\n this.sCount = []; // indents for each line (tabs expanded)\n\n // An amount of virtual spaces (tabs expanded) between beginning\n // of each line (bMarks) and real beginning of that line.\n //\n // It exists only as a hack because blockquotes override bMarks\n // losing information in the process.\n //\n // It's used only when expanding tabs, you can think about it as\n // an initial tab length, e.g. bsCount=21 applied to string `\\t123`\n // means first tab should be expanded to 4-21%4 === 3 spaces.\n //\n this.bsCount = [];\n\n // block parser variables\n this.blkIndent = 0; // required block content indent (for example, if we are\n // inside a list, it would be positioned after list marker)\n this.line = 0; // line index in src\n this.lineMax = 0; // lines count\n this.tight = false; // loose/tight mode for lists\n this.ddIndent = -1; // indent of the current dd block (-1 if there isn't any)\n this.listIndent = -1; // indent of the current list block (-1 if there isn't any)\n\n // can be 'blockquote', 'list', 'root', 'paragraph' or 'reference'\n // used in lists to determine if they interrupt a paragraph\n this.parentType = 'root';\n\n this.level = 0;\n\n // renderer\n this.result = '';\n\n // Create caches\n // Generate markers.\n s = this.src;\n indent_found = false;\n\n for (start = pos = indent = offset = 0, len = s.length; pos < len; pos++) {\n ch = s.charCodeAt(pos);\n\n if (!indent_found) {\n if (isSpace(ch)) {\n indent++;\n\n if (ch === 0x09) {\n offset += 4 - offset % 4;\n } else {\n offset++;\n }\n continue;\n } else {\n indent_found = true;\n }\n }\n\n if (ch === 0x0A || pos === len - 1) {\n if (ch !== 0x0A) { pos++; }\n this.bMarks.push(start);\n this.eMarks.push(pos);\n this.tShift.push(indent);\n this.sCount.push(offset);\n this.bsCount.push(0);\n\n indent_found = false;\n indent = 0;\n offset = 0;\n start = pos + 1;\n }\n }\n\n // Push fake entry to simplify cache bounds checks\n this.bMarks.push(s.length);\n this.eMarks.push(s.length);\n this.tShift.push(0);\n this.sCount.push(0);\n this.bsCount.push(0);\n\n this.lineMax = this.bMarks.length - 1; // don't count last fake line\n}\n\n// Push new token to \"stream\".\n//\nStateBlock.prototype.push = function (type, tag, nesting) {\n var token = new Token(type, tag, nesting);\n token.block = true;\n\n if (nesting < 0) this.level--; // closing tag\n token.level = this.level;\n if (nesting > 0) this.level++; // opening tag\n\n this.tokens.push(token);\n return token;\n};\n\nStateBlock.prototype.isEmpty = function isEmpty(line) {\n return this.bMarks[line] + this.tShift[line] >= this.eMarks[line];\n};\n\nStateBlock.prototype.skipEmptyLines = function skipEmptyLines(from) {\n for (var max = this.lineMax; from < max; from++) {\n if (this.bMarks[from] + this.tShift[from] < this.eMarks[from]) {\n break;\n }\n }\n return from;\n};\n\n// Skip spaces from given position.\nStateBlock.prototype.skipSpaces = function skipSpaces(pos) {\n var ch;\n\n for (var max = this.src.length; pos < max; pos++) {\n ch = this.src.charCodeAt(pos);\n if (!isSpace(ch)) { break; }\n }\n return pos;\n};\n\n// Skip spaces from given position in reverse.\nStateBlock.prototype.skipSpacesBack = function skipSpacesBack(pos, min) {\n if (pos <= min) { return pos; }\n\n while (pos > min) {\n if (!isSpace(this.src.charCodeAt(--pos))) { return pos + 1; }\n }\n return pos;\n};\n\n// Skip char codes from given position\nStateBlock.prototype.skipChars = function skipChars(pos, code) {\n for (var max = this.src.length; pos < max; pos++) {\n if (this.src.charCodeAt(pos) !== code) { break; }\n }\n return pos;\n};\n\n// Skip char codes reverse from given position - 1\nStateBlock.prototype.skipCharsBack = function skipCharsBack(pos, code, min) {\n if (pos <= min) { return pos; }\n\n while (pos > min) {\n if (code !== this.src.charCodeAt(--pos)) { return pos + 1; }\n }\n return pos;\n};\n\n// cut lines range from source.\nStateBlock.prototype.getLines = function getLines(begin, end, indent, keepLastLF) {\n var i, lineIndent, ch, first, last, queue, lineStart,\n line = begin;\n\n if (begin >= end) {\n return '';\n }\n\n queue = new Array(end - begin);\n\n for (i = 0; line < end; line++, i++) {\n lineIndent = 0;\n lineStart = first = this.bMarks[line];\n\n if (line + 1 < end || keepLastLF) {\n // No need for bounds check because we have fake entry on tail.\n last = this.eMarks[line] + 1;\n } else {\n last = this.eMarks[line];\n }\n\n while (first < last && lineIndent < indent) {\n ch = this.src.charCodeAt(first);\n\n if (isSpace(ch)) {\n if (ch === 0x09) {\n lineIndent += 4 - (lineIndent + this.bsCount[line]) % 4;\n } else {\n lineIndent++;\n }\n } else if (first - lineStart < this.tShift[line]) {\n // patched tShift masked characters to look like spaces (blockquotes, list markers)\n lineIndent++;\n } else {\n break;\n }\n\n first++;\n }\n\n if (lineIndent > indent) {\n // partially expanding tabs in code blocks, e.g '\\t\\tfoobar'\n // with indent=2 becomes ' \\tfoobar'\n queue[i] = new Array(lineIndent - indent + 1).join(' ') + this.src.slice(first, last);\n } else {\n queue[i] = this.src.slice(first, last);\n }\n }\n\n return queue.join('');\n};\n\n// re-export Token class to use in block rules\nStateBlock.prototype.Token = Token;\n\n\nmodule.exports = StateBlock;\n","// GFM table, https://github.github.com/gfm/#tables-extension-\n\n'use strict';\n\nvar isSpace = require('../common/utils').isSpace;\n\n\nfunction getLine(state, line) {\n var pos = state.bMarks[line] + state.tShift[line],\n max = state.eMarks[line];\n\n return state.src.substr(pos, max - pos);\n}\n\nfunction escapedSplit(str) {\n var result = [],\n pos = 0,\n max = str.length,\n ch,\n isEscaped = false,\n lastPos = 0,\n current = '';\n\n ch = str.charCodeAt(pos);\n\n while (pos < max) {\n if (ch === 0x7c/* | */) {\n if (!isEscaped) {\n // pipe separating cells, '|'\n result.push(current + str.substring(lastPos, pos));\n current = '';\n lastPos = pos + 1;\n } else {\n // escaped pipe, '\\|'\n current += str.substring(lastPos, pos - 1);\n lastPos = pos;\n }\n }\n\n isEscaped = (ch === 0x5c/* \\ */);\n pos++;\n\n ch = str.charCodeAt(pos);\n }\n\n result.push(current + str.substring(lastPos));\n\n return result;\n}\n\n\nmodule.exports = function table(state, startLine, endLine, silent) {\n var ch, lineText, pos, i, l, nextLine, columns, columnCount, token,\n aligns, t, tableLines, tbodyLines, oldParentType, terminate,\n terminatorRules, firstCh, secondCh;\n\n // should have at least two lines\n if (startLine + 2 > endLine) { return false; }\n\n nextLine = startLine + 1;\n\n if (state.sCount[nextLine] < state.blkIndent) { return false; }\n\n // if it's indented more than 3 spaces, it should be a code block\n if (state.sCount[nextLine] - state.blkIndent >= 4) { return false; }\n\n // first character of the second line should be '|', '-', ':',\n // and no other characters are allowed but spaces;\n // basically, this is the equivalent of /^[-:|][-:|\\s]*$/ regexp\n\n pos = state.bMarks[nextLine] + state.tShift[nextLine];\n if (pos >= state.eMarks[nextLine]) { return false; }\n\n firstCh = state.src.charCodeAt(pos++);\n if (firstCh !== 0x7C/* | */ && firstCh !== 0x2D/* - */ && firstCh !== 0x3A/* : */) { return false; }\n\n if (pos >= state.eMarks[nextLine]) { return false; }\n\n secondCh = state.src.charCodeAt(pos++);\n if (secondCh !== 0x7C/* | */ && secondCh !== 0x2D/* - */ && secondCh !== 0x3A/* : */ && !isSpace(secondCh)) {\n return false;\n }\n\n // if first character is '-', then second character must not be a space\n // (due to parsing ambiguity with list)\n if (firstCh === 0x2D/* - */ && isSpace(secondCh)) { return false; }\n\n while (pos < state.eMarks[nextLine]) {\n ch = state.src.charCodeAt(pos);\n\n if (ch !== 0x7C/* | */ && ch !== 0x2D/* - */ && ch !== 0x3A/* : */ && !isSpace(ch)) { return false; }\n\n pos++;\n }\n\n lineText = getLine(state, startLine + 1);\n\n columns = lineText.split('|');\n aligns = [];\n for (i = 0; i < columns.length; i++) {\n t = columns[i].trim();\n if (!t) {\n // allow empty columns before and after table, but not in between columns;\n // e.g. allow ` |---| `, disallow ` ---||--- `\n if (i === 0 || i === columns.length - 1) {\n continue;\n } else {\n return false;\n }\n }\n\n if (!/^:?-+:?$/.test(t)) { return false; }\n if (t.charCodeAt(t.length - 1) === 0x3A/* : */) {\n aligns.push(t.charCodeAt(0) === 0x3A/* : */ ? 'center' : 'right');\n } else if (t.charCodeAt(0) === 0x3A/* : */) {\n aligns.push('left');\n } else {\n aligns.push('');\n }\n }\n\n lineText = getLine(state, startLine).trim();\n if (lineText.indexOf('|') === -1) { return false; }\n if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }\n columns = escapedSplit(lineText);\n if (columns.length && columns[0] === '') columns.shift();\n if (columns.length && columns[columns.length - 1] === '') columns.pop();\n\n // header row will define an amount of columns in the entire table,\n // and align row should be exactly the same (the rest of the rows can differ)\n columnCount = columns.length;\n if (columnCount === 0 || columnCount !== aligns.length) { return false; }\n\n if (silent) { return true; }\n\n oldParentType = state.parentType;\n state.parentType = 'table';\n\n // use 'blockquote' lists for termination because it's\n // the most similar to tables\n terminatorRules = state.md.block.ruler.getRules('blockquote');\n\n token = state.push('table_open', 'table', 1);\n token.map = tableLines = [ startLine, 0 ];\n\n token = state.push('thead_open', 'thead', 1);\n token.map = [ startLine, startLine + 1 ];\n\n token = state.push('tr_open', 'tr', 1);\n token.map = [ startLine, startLine + 1 ];\n\n for (i = 0; i < columns.length; i++) {\n token = state.push('th_open', 'th', 1);\n if (aligns[i]) {\n token.attrs = [ [ 'style', 'text-align:' + aligns[i] ] ];\n }\n\n token = state.push('inline', '', 0);\n token.content = columns[i].trim();\n token.children = [];\n\n token = state.push('th_close', 'th', -1);\n }\n\n token = state.push('tr_close', 'tr', -1);\n token = state.push('thead_close', 'thead', -1);\n\n for (nextLine = startLine + 2; nextLine < endLine; nextLine++) {\n if (state.sCount[nextLine] < state.blkIndent) { break; }\n\n terminate = false;\n for (i = 0, l = terminatorRules.length; i < l; i++) {\n if (terminatorRules[i](state, nextLine, endLine, true)) {\n terminate = true;\n break;\n }\n }\n\n if (terminate) { break; }\n lineText = getLine(state, nextLine).trim();\n if (!lineText) { break; }\n if (state.sCount[nextLine] - state.blkIndent >= 4) { break; }\n columns = escapedSplit(lineText);\n if (columns.length && columns[0] === '') columns.shift();\n if (columns.length && columns[columns.length - 1] === '') columns.pop();\n\n if (nextLine === startLine + 2) {\n token = state.push('tbody_open', 'tbody', 1);\n token.map = tbodyLines = [ startLine + 2, 0 ];\n }\n\n token = state.push('tr_open', 'tr', 1);\n token.map = [ nextLine, nextLine + 1 ];\n\n for (i = 0; i < columnCount; i++) {\n token = state.push('td_open', 'td', 1);\n if (aligns[i]) {\n token.attrs = [ [ 'style', 'text-align:' + aligns[i] ] ];\n }\n\n token = state.push('inline', '', 0);\n token.content = columns[i] ? columns[i].trim() : '';\n token.children = [];\n\n token = state.push('td_close', 'td', -1);\n }\n token = state.push('tr_close', 'tr', -1);\n }\n\n if (tbodyLines) {\n token = state.push('tbody_close', 'tbody', -1);\n tbodyLines[1] = nextLine;\n }\n\n token = state.push('table_close', 'table', -1);\n tableLines[1] = nextLine;\n\n state.parentType = oldParentType;\n state.line = nextLine;\n return true;\n};\n","'use strict';\n\n\nmodule.exports = function block(state) {\n var token;\n\n if (state.inlineMode) {\n token = new state.Token('inline', '', 0);\n token.content = state.src;\n token.map = [ 0, 1 ];\n token.children = [];\n state.tokens.push(token);\n } else {\n state.md.block.parse(state.src, state.md, state.env, state.tokens);\n }\n};\n","'use strict';\n\nmodule.exports = function inline(state) {\n var tokens = state.tokens, tok, i, l;\n\n // Parse inlines\n for (i = 0, l = tokens.length; i < l; i++) {\n tok = tokens[i];\n if (tok.type === 'inline') {\n state.md.inline.parse(tok.content, state.md, state.env, tok.children);\n }\n }\n};\n","// Replace link-like texts with link nodes.\n//\n// Currently restricted by `md.validateLink()` to http/https/ftp\n//\n'use strict';\n\n\nvar arrayReplaceAt = require('../common/utils').arrayReplaceAt;\n\n\nfunction isLinkOpen(str) {\n return /^\\s]/i.test(str);\n}\nfunction isLinkClose(str) {\n return /^<\\/a\\s*>/i.test(str);\n}\n\n\nmodule.exports = function linkify(state) {\n var i, j, l, tokens, token, currentToken, nodes, ln, text, pos, lastPos,\n level, htmlLinkLevel, url, fullUrl, urlText,\n blockTokens = state.tokens,\n links;\n\n if (!state.md.options.linkify) { return; }\n\n for (j = 0, l = blockTokens.length; j < l; j++) {\n if (blockTokens[j].type !== 'inline' ||\n !state.md.linkify.pretest(blockTokens[j].content)) {\n continue;\n }\n\n tokens = blockTokens[j].children;\n\n htmlLinkLevel = 0;\n\n // We scan from the end, to keep position when new tags added.\n // Use reversed logic in links start/end match\n for (i = tokens.length - 1; i >= 0; i--) {\n currentToken = tokens[i];\n\n // Skip content of markdown links\n if (currentToken.type === 'link_close') {\n i--;\n while (tokens[i].level !== currentToken.level && tokens[i].type !== 'link_open') {\n i--;\n }\n continue;\n }\n\n // Skip content of html tag links\n if (currentToken.type === 'html_inline') {\n if (isLinkOpen(currentToken.content) && htmlLinkLevel > 0) {\n htmlLinkLevel--;\n }\n if (isLinkClose(currentToken.content)) {\n htmlLinkLevel++;\n }\n }\n if (htmlLinkLevel > 0) { continue; }\n\n if (currentToken.type === 'text' && state.md.linkify.test(currentToken.content)) {\n\n text = currentToken.content;\n links = state.md.linkify.match(text);\n\n // Now split string to nodes\n nodes = [];\n level = currentToken.level;\n lastPos = 0;\n\n for (ln = 0; ln < links.length; ln++) {\n\n url = links[ln].url;\n fullUrl = state.md.normalizeLink(url);\n if (!state.md.validateLink(fullUrl)) { continue; }\n\n urlText = links[ln].text;\n\n // Linkifier might send raw hostnames like \"example.com\", where url\n // starts with domain name. So we prepend http:// in those cases,\n // and remove it afterwards.\n //\n if (!links[ln].schema) {\n urlText = state.md.normalizeLinkText('http://' + urlText).replace(/^http:\\/\\//, '');\n } else if (links[ln].schema === 'mailto:' && !/^mailto:/i.test(urlText)) {\n urlText = state.md.normalizeLinkText('mailto:' + urlText).replace(/^mailto:/, '');\n } else {\n urlText = state.md.normalizeLinkText(urlText);\n }\n\n pos = links[ln].index;\n\n if (pos > lastPos) {\n token = new state.Token('text', '', 0);\n token.content = text.slice(lastPos, pos);\n token.level = level;\n nodes.push(token);\n }\n\n token = new state.Token('link_open', 'a', 1);\n token.attrs = [ [ 'href', fullUrl ] ];\n token.level = level++;\n token.markup = 'linkify';\n token.info = 'auto';\n nodes.push(token);\n\n token = new state.Token('text', '', 0);\n token.content = urlText;\n token.level = level;\n nodes.push(token);\n\n token = new state.Token('link_close', 'a', -1);\n token.level = --level;\n token.markup = 'linkify';\n token.info = 'auto';\n nodes.push(token);\n\n lastPos = links[ln].lastIndex;\n }\n if (lastPos < text.length) {\n token = new state.Token('text', '', 0);\n token.content = text.slice(lastPos);\n token.level = level;\n nodes.push(token);\n }\n\n // replace current node\n blockTokens[j].children = tokens = arrayReplaceAt(tokens, i, nodes);\n }\n }\n }\n};\n","// Normalize input string\n\n'use strict';\n\n\n// https://spec.commonmark.org/0.29/#line-ending\nvar NEWLINES_RE = /\\r\\n?|\\n/g;\nvar NULL_RE = /\\0/g;\n\n\nmodule.exports = function normalize(state) {\n var str;\n\n // Normalize newlines\n str = state.src.replace(NEWLINES_RE, '\\n');\n\n // Replace NULL characters\n str = str.replace(NULL_RE, '\\uFFFD');\n\n state.src = str;\n};\n","// Simple typographic replacements\n//\n// (c) (C) → ©\n// (tm) (TM) → ™\n// (r) (R) → ®\n// +- → ±\n// (p) (P) -> §\n// ... → … (also ?.... → ?.., !.... → !..)\n// ???????? → ???, !!!!! → !!!, `,,` → `,`\n// -- → –, --- → —\n//\n'use strict';\n\n// TODO:\n// - fractionals 1/2, 1/4, 3/4 -> ½, ¼, ¾\n// - miltiplication 2 x 4 -> 2 × 4\n\nvar RARE_RE = /\\+-|\\.\\.|\\?\\?\\?\\?|!!!!|,,|--/;\n\n// Workaround for phantomjs - need regex without /g flag,\n// or root check will fail every second time\nvar SCOPED_ABBR_TEST_RE = /\\((c|tm|r|p)\\)/i;\n\nvar SCOPED_ABBR_RE = /\\((c|tm|r|p)\\)/ig;\nvar SCOPED_ABBR = {\n c: '©',\n r: '®',\n p: '§',\n tm: '™'\n};\n\nfunction replaceFn(match, name) {\n return SCOPED_ABBR[name.toLowerCase()];\n}\n\nfunction replace_scoped(inlineTokens) {\n var i, token, inside_autolink = 0;\n\n for (i = inlineTokens.length - 1; i >= 0; i--) {\n token = inlineTokens[i];\n\n if (token.type === 'text' && !inside_autolink) {\n token.content = token.content.replace(SCOPED_ABBR_RE, replaceFn);\n }\n\n if (token.type === 'link_open' && token.info === 'auto') {\n inside_autolink--;\n }\n\n if (token.type === 'link_close' && token.info === 'auto') {\n inside_autolink++;\n }\n }\n}\n\nfunction replace_rare(inlineTokens) {\n var i, token, inside_autolink = 0;\n\n for (i = inlineTokens.length - 1; i >= 0; i--) {\n token = inlineTokens[i];\n\n if (token.type === 'text' && !inside_autolink) {\n if (RARE_RE.test(token.content)) {\n token.content = token.content\n .replace(/\\+-/g, '±')\n // .., ..., ....... -> …\n // but ?..... & !..... -> ?.. & !..\n .replace(/\\.{2,}/g, '…').replace(/([?!])…/g, '$1..')\n .replace(/([?!]){4,}/g, '$1$1$1').replace(/,{2,}/g, ',')\n // em-dash\n .replace(/(^|[^-])---(?=[^-]|$)/mg, '$1\\u2014')\n // en-dash\n .replace(/(^|\\s)--(?=\\s|$)/mg, '$1\\u2013')\n .replace(/(^|[^-\\s])--(?=[^-\\s]|$)/mg, '$1\\u2013');\n }\n }\n\n if (token.type === 'link_open' && token.info === 'auto') {\n inside_autolink--;\n }\n\n if (token.type === 'link_close' && token.info === 'auto') {\n inside_autolink++;\n }\n }\n}\n\n\nmodule.exports = function replace(state) {\n var blkIdx;\n\n if (!state.md.options.typographer) { return; }\n\n for (blkIdx = state.tokens.length - 1; blkIdx >= 0; blkIdx--) {\n\n if (state.tokens[blkIdx].type !== 'inline') { continue; }\n\n if (SCOPED_ABBR_TEST_RE.test(state.tokens[blkIdx].content)) {\n replace_scoped(state.tokens[blkIdx].children);\n }\n\n if (RARE_RE.test(state.tokens[blkIdx].content)) {\n replace_rare(state.tokens[blkIdx].children);\n }\n\n }\n};\n","// Convert straight quotation marks to typographic ones\n//\n'use strict';\n\n\nvar isWhiteSpace = require('../common/utils').isWhiteSpace;\nvar isPunctChar = require('../common/utils').isPunctChar;\nvar isMdAsciiPunct = require('../common/utils').isMdAsciiPunct;\n\nvar QUOTE_TEST_RE = /['\"]/;\nvar QUOTE_RE = /['\"]/g;\nvar APOSTROPHE = '\\u2019'; /* ’ */\n\n\nfunction replaceAt(str, index, ch) {\n return str.substr(0, index) + ch + str.substr(index + 1);\n}\n\nfunction process_inlines(tokens, state) {\n var i, token, text, t, pos, max, thisLevel, item, lastChar, nextChar,\n isLastPunctChar, isNextPunctChar, isLastWhiteSpace, isNextWhiteSpace,\n canOpen, canClose, j, isSingle, stack, openQuote, closeQuote;\n\n stack = [];\n\n for (i = 0; i < tokens.length; i++) {\n token = tokens[i];\n\n thisLevel = tokens[i].level;\n\n for (j = stack.length - 1; j >= 0; j--) {\n if (stack[j].level <= thisLevel) { break; }\n }\n stack.length = j + 1;\n\n if (token.type !== 'text') { continue; }\n\n text = token.content;\n pos = 0;\n max = text.length;\n\n /*eslint no-labels:0,block-scoped-var:0*/\n OUTER:\n while (pos < max) {\n QUOTE_RE.lastIndex = pos;\n t = QUOTE_RE.exec(text);\n if (!t) { break; }\n\n canOpen = canClose = true;\n pos = t.index + 1;\n isSingle = (t[0] === \"'\");\n\n // Find previous character,\n // default to space if it's the beginning of the line\n //\n lastChar = 0x20;\n\n if (t.index - 1 >= 0) {\n lastChar = text.charCodeAt(t.index - 1);\n } else {\n for (j = i - 1; j >= 0; j--) {\n if (tokens[j].type === 'softbreak' || tokens[j].type === 'hardbreak') break; // lastChar defaults to 0x20\n if (!tokens[j].content) continue; // should skip all tokens except 'text', 'html_inline' or 'code_inline'\n\n lastChar = tokens[j].content.charCodeAt(tokens[j].content.length - 1);\n break;\n }\n }\n\n // Find next character,\n // default to space if it's the end of the line\n //\n nextChar = 0x20;\n\n if (pos < max) {\n nextChar = text.charCodeAt(pos);\n } else {\n for (j = i + 1; j < tokens.length; j++) {\n if (tokens[j].type === 'softbreak' || tokens[j].type === 'hardbreak') break; // nextChar defaults to 0x20\n if (!tokens[j].content) continue; // should skip all tokens except 'text', 'html_inline' or 'code_inline'\n\n nextChar = tokens[j].content.charCodeAt(0);\n break;\n }\n }\n\n isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctChar(String.fromCharCode(lastChar));\n isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctChar(String.fromCharCode(nextChar));\n\n isLastWhiteSpace = isWhiteSpace(lastChar);\n isNextWhiteSpace = isWhiteSpace(nextChar);\n\n if (isNextWhiteSpace) {\n canOpen = false;\n } else if (isNextPunctChar) {\n if (!(isLastWhiteSpace || isLastPunctChar)) {\n canOpen = false;\n }\n }\n\n if (isLastWhiteSpace) {\n canClose = false;\n } else if (isLastPunctChar) {\n if (!(isNextWhiteSpace || isNextPunctChar)) {\n canClose = false;\n }\n }\n\n if (nextChar === 0x22 /* \" */ && t[0] === '\"') {\n if (lastChar >= 0x30 /* 0 */ && lastChar <= 0x39 /* 9 */) {\n // special case: 1\"\" - count first quote as an inch\n canClose = canOpen = false;\n }\n }\n\n if (canOpen && canClose) {\n // Replace quotes in the middle of punctuation sequence, but not\n // in the middle of the words, i.e.:\n //\n // 1. foo \" bar \" baz - not replaced\n // 2. foo-\"-bar-\"-baz - replaced\n // 3. foo\"bar\"baz - not replaced\n //\n canOpen = isLastPunctChar;\n canClose = isNextPunctChar;\n }\n\n if (!canOpen && !canClose) {\n // middle of word\n if (isSingle) {\n token.content = replaceAt(token.content, t.index, APOSTROPHE);\n }\n continue;\n }\n\n if (canClose) {\n // this could be a closing quote, rewind the stack to get a match\n for (j = stack.length - 1; j >= 0; j--) {\n item = stack[j];\n if (stack[j].level < thisLevel) { break; }\n if (item.single === isSingle && stack[j].level === thisLevel) {\n item = stack[j];\n\n if (isSingle) {\n openQuote = state.md.options.quotes[2];\n closeQuote = state.md.options.quotes[3];\n } else {\n openQuote = state.md.options.quotes[0];\n closeQuote = state.md.options.quotes[1];\n }\n\n // replace token.content *before* tokens[item.token].content,\n // because, if they are pointing at the same token, replaceAt\n // could mess up indices when quote length != 1\n token.content = replaceAt(token.content, t.index, closeQuote);\n tokens[item.token].content = replaceAt(\n tokens[item.token].content, item.pos, openQuote);\n\n pos += closeQuote.length - 1;\n if (item.token === i) { pos += openQuote.length - 1; }\n\n text = token.content;\n max = text.length;\n\n stack.length = j;\n continue OUTER;\n }\n }\n }\n\n if (canOpen) {\n stack.push({\n token: i,\n pos: t.index,\n single: isSingle,\n level: thisLevel\n });\n } else if (canClose && isSingle) {\n token.content = replaceAt(token.content, t.index, APOSTROPHE);\n }\n }\n }\n}\n\n\nmodule.exports = function smartquotes(state) {\n /*eslint max-depth:0*/\n var blkIdx;\n\n if (!state.md.options.typographer) { return; }\n\n for (blkIdx = state.tokens.length - 1; blkIdx >= 0; blkIdx--) {\n\n if (state.tokens[blkIdx].type !== 'inline' ||\n !QUOTE_TEST_RE.test(state.tokens[blkIdx].content)) {\n continue;\n }\n\n process_inlines(state.tokens[blkIdx].children, state);\n }\n};\n","// Core state object\n//\n'use strict';\n\nvar Token = require('../token');\n\n\nfunction StateCore(src, md, env) {\n this.src = src;\n this.env = env;\n this.tokens = [];\n this.inlineMode = false;\n this.md = md; // link to parser instance\n}\n\n// re-export Token class to use in core rules\nStateCore.prototype.Token = Token;\n\n\nmodule.exports = StateCore;\n","// Process autolinks ''\n\n'use strict';\n\n\n/*eslint max-len:0*/\nvar EMAIL_RE = /^([a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)$/;\nvar AUTOLINK_RE = /^([a-zA-Z][a-zA-Z0-9+.\\-]{1,31}):([^<>\\x00-\\x20]*)$/;\n\n\nmodule.exports = function autolink(state, silent) {\n var url, fullUrl, token, ch, start, max,\n pos = state.pos;\n\n if (state.src.charCodeAt(pos) !== 0x3C/* < */) { return false; }\n\n start = state.pos;\n max = state.posMax;\n\n for (;;) {\n if (++pos >= max) return false;\n\n ch = state.src.charCodeAt(pos);\n\n if (ch === 0x3C /* < */) return false;\n if (ch === 0x3E /* > */) break;\n }\n\n url = state.src.slice(start + 1, pos);\n\n if (AUTOLINK_RE.test(url)) {\n fullUrl = state.md.normalizeLink(url);\n if (!state.md.validateLink(fullUrl)) { return false; }\n\n if (!silent) {\n token = state.push('link_open', 'a', 1);\n token.attrs = [ [ 'href', fullUrl ] ];\n token.markup = 'autolink';\n token.info = 'auto';\n\n token = state.push('text', '', 0);\n token.content = state.md.normalizeLinkText(url);\n\n token = state.push('link_close', 'a', -1);\n token.markup = 'autolink';\n token.info = 'auto';\n }\n\n state.pos += url.length + 2;\n return true;\n }\n\n if (EMAIL_RE.test(url)) {\n fullUrl = state.md.normalizeLink('mailto:' + url);\n if (!state.md.validateLink(fullUrl)) { return false; }\n\n if (!silent) {\n token = state.push('link_open', 'a', 1);\n token.attrs = [ [ 'href', fullUrl ] ];\n token.markup = 'autolink';\n token.info = 'auto';\n\n token = state.push('text', '', 0);\n token.content = state.md.normalizeLinkText(url);\n\n token = state.push('link_close', 'a', -1);\n token.markup = 'autolink';\n token.info = 'auto';\n }\n\n state.pos += url.length + 2;\n return true;\n }\n\n return false;\n};\n","// Parse backticks\n\n'use strict';\n\n\nmodule.exports = function backtick(state, silent) {\n var start, max, marker, token, matchStart, matchEnd, openerLength, closerLength,\n pos = state.pos,\n ch = state.src.charCodeAt(pos);\n\n if (ch !== 0x60/* ` */) { return false; }\n\n start = pos;\n pos++;\n max = state.posMax;\n\n // scan marker length\n while (pos < max && state.src.charCodeAt(pos) === 0x60/* ` */) { pos++; }\n\n marker = state.src.slice(start, pos);\n openerLength = marker.length;\n\n if (state.backticksScanned && (state.backticks[openerLength] || 0) <= start) {\n if (!silent) state.pending += marker;\n state.pos += openerLength;\n return true;\n }\n\n matchStart = matchEnd = pos;\n\n // Nothing found in the cache, scan until the end of the line (or until marker is found)\n while ((matchStart = state.src.indexOf('`', matchEnd)) !== -1) {\n matchEnd = matchStart + 1;\n\n // scan marker length\n while (matchEnd < max && state.src.charCodeAt(matchEnd) === 0x60/* ` */) { matchEnd++; }\n\n closerLength = matchEnd - matchStart;\n\n if (closerLength === openerLength) {\n // Found matching closer length.\n if (!silent) {\n token = state.push('code_inline', 'code', 0);\n token.markup = marker;\n token.content = state.src.slice(pos, matchStart)\n .replace(/\\n/g, ' ')\n .replace(/^ (.+) $/, '$1');\n }\n state.pos = matchEnd;\n return true;\n }\n\n // Some different length found, put it in cache as upper limit of where closer can be found\n state.backticks[closerLength] = matchStart;\n }\n\n // Scanned through the end, didn't find anything\n state.backticksScanned = true;\n\n if (!silent) state.pending += marker;\n state.pos += openerLength;\n return true;\n};\n","// For each opening emphasis-like marker find a matching closing one\n//\n'use strict';\n\n\nfunction processDelimiters(state, delimiters) {\n var closerIdx, openerIdx, closer, opener, minOpenerIdx, newMinOpenerIdx,\n isOddMatch, lastJump,\n openersBottom = {},\n max = delimiters.length;\n\n if (!max) return;\n\n // headerIdx is the first delimiter of the current (where closer is) delimiter run\n var headerIdx = 0;\n var lastTokenIdx = -2; // needs any value lower than -1\n var jumps = [];\n\n for (closerIdx = 0; closerIdx < max; closerIdx++) {\n closer = delimiters[closerIdx];\n\n jumps.push(0);\n\n // markers belong to same delimiter run if:\n // - they have adjacent tokens\n // - AND markers are the same\n //\n if (delimiters[headerIdx].marker !== closer.marker || lastTokenIdx !== closer.token - 1) {\n headerIdx = closerIdx;\n }\n\n lastTokenIdx = closer.token;\n\n // Length is only used for emphasis-specific \"rule of 3\",\n // if it's not defined (in strikethrough or 3rd party plugins),\n // we can default it to 0 to disable those checks.\n //\n closer.length = closer.length || 0;\n\n if (!closer.close) continue;\n\n // Previously calculated lower bounds (previous fails)\n // for each marker, each delimiter length modulo 3,\n // and for whether this closer can be an opener;\n // https://github.com/commonmark/cmark/commit/34250e12ccebdc6372b8b49c44fab57c72443460\n if (!openersBottom.hasOwnProperty(closer.marker)) {\n openersBottom[closer.marker] = [ -1, -1, -1, -1, -1, -1 ];\n }\n\n minOpenerIdx = openersBottom[closer.marker][(closer.open ? 3 : 0) + (closer.length % 3)];\n\n openerIdx = headerIdx - jumps[headerIdx] - 1;\n\n newMinOpenerIdx = openerIdx;\n\n for (; openerIdx > minOpenerIdx; openerIdx -= jumps[openerIdx] + 1) {\n opener = delimiters[openerIdx];\n\n if (opener.marker !== closer.marker) continue;\n\n if (opener.open && opener.end < 0) {\n\n isOddMatch = false;\n\n // from spec:\n //\n // If one of the delimiters can both open and close emphasis, then the\n // sum of the lengths of the delimiter runs containing the opening and\n // closing delimiters must not be a multiple of 3 unless both lengths\n // are multiples of 3.\n //\n if (opener.close || closer.open) {\n if ((opener.length + closer.length) % 3 === 0) {\n if (opener.length % 3 !== 0 || closer.length % 3 !== 0) {\n isOddMatch = true;\n }\n }\n }\n\n if (!isOddMatch) {\n // If previous delimiter cannot be an opener, we can safely skip\n // the entire sequence in future checks. This is required to make\n // sure algorithm has linear complexity (see *_*_*_*_*_... case).\n //\n lastJump = openerIdx > 0 && !delimiters[openerIdx - 1].open ?\n jumps[openerIdx - 1] + 1 :\n 0;\n\n jumps[closerIdx] = closerIdx - openerIdx + lastJump;\n jumps[openerIdx] = lastJump;\n\n closer.open = false;\n opener.end = closerIdx;\n opener.close = false;\n newMinOpenerIdx = -1;\n // treat next token as start of run,\n // it optimizes skips in **<...>**a**<...>** pathological case\n lastTokenIdx = -2;\n break;\n }\n }\n }\n\n if (newMinOpenerIdx !== -1) {\n // If match for this delimiter run failed, we want to set lower bound for\n // future lookups. This is required to make sure algorithm has linear\n // complexity.\n //\n // See details here:\n // https://github.com/commonmark/cmark/issues/178#issuecomment-270417442\n //\n openersBottom[closer.marker][(closer.open ? 3 : 0) + ((closer.length || 0) % 3)] = newMinOpenerIdx;\n }\n }\n}\n\n\nmodule.exports = function link_pairs(state) {\n var curr,\n tokens_meta = state.tokens_meta,\n max = state.tokens_meta.length;\n\n processDelimiters(state, state.delimiters);\n\n for (curr = 0; curr < max; curr++) {\n if (tokens_meta[curr] && tokens_meta[curr].delimiters) {\n processDelimiters(state, tokens_meta[curr].delimiters);\n }\n }\n};\n","// Process *this* and _that_\n//\n'use strict';\n\n\n// Insert each marker as a separate text token, and add it to delimiter list\n//\nmodule.exports.tokenize = function emphasis(state, silent) {\n var i, scanned, token,\n start = state.pos,\n marker = state.src.charCodeAt(start);\n\n if (silent) { return false; }\n\n if (marker !== 0x5F /* _ */ && marker !== 0x2A /* * */) { return false; }\n\n scanned = state.scanDelims(state.pos, marker === 0x2A);\n\n for (i = 0; i < scanned.length; i++) {\n token = state.push('text', '', 0);\n token.content = String.fromCharCode(marker);\n\n state.delimiters.push({\n // Char code of the starting marker (number).\n //\n marker: marker,\n\n // Total length of these series of delimiters.\n //\n length: scanned.length,\n\n // A position of the token this delimiter corresponds to.\n //\n token: state.tokens.length - 1,\n\n // If this delimiter is matched as a valid opener, `end` will be\n // equal to its position, otherwise it's `-1`.\n //\n end: -1,\n\n // Boolean flags that determine if this delimiter could open or close\n // an emphasis.\n //\n open: scanned.can_open,\n close: scanned.can_close\n });\n }\n\n state.pos += scanned.length;\n\n return true;\n};\n\n\nfunction postProcess(state, delimiters) {\n var i,\n startDelim,\n endDelim,\n token,\n ch,\n isStrong,\n max = delimiters.length;\n\n for (i = max - 1; i >= 0; i--) {\n startDelim = delimiters[i];\n\n if (startDelim.marker !== 0x5F/* _ */ && startDelim.marker !== 0x2A/* * */) {\n continue;\n }\n\n // Process only opening markers\n if (startDelim.end === -1) {\n continue;\n }\n\n endDelim = delimiters[startDelim.end];\n\n // If the previous delimiter has the same marker and is adjacent to this one,\n // merge those into one strong delimiter.\n //\n // `whatever` -> `whatever`\n //\n isStrong = i > 0 &&\n delimiters[i - 1].end === startDelim.end + 1 &&\n // check that first two markers match and adjacent\n delimiters[i - 1].marker === startDelim.marker &&\n delimiters[i - 1].token === startDelim.token - 1 &&\n // check that last two markers are adjacent (we can safely assume they match)\n delimiters[startDelim.end + 1].token === endDelim.token + 1;\n\n ch = String.fromCharCode(startDelim.marker);\n\n token = state.tokens[startDelim.token];\n token.type = isStrong ? 'strong_open' : 'em_open';\n token.tag = isStrong ? 'strong' : 'em';\n token.nesting = 1;\n token.markup = isStrong ? ch + ch : ch;\n token.content = '';\n\n token = state.tokens[endDelim.token];\n token.type = isStrong ? 'strong_close' : 'em_close';\n token.tag = isStrong ? 'strong' : 'em';\n token.nesting = -1;\n token.markup = isStrong ? ch + ch : ch;\n token.content = '';\n\n if (isStrong) {\n state.tokens[delimiters[i - 1].token].content = '';\n state.tokens[delimiters[startDelim.end + 1].token].content = '';\n i--;\n }\n }\n}\n\n\n// Walk through delimiter list and replace text tokens with tags\n//\nmodule.exports.postProcess = function emphasis(state) {\n var curr,\n tokens_meta = state.tokens_meta,\n max = state.tokens_meta.length;\n\n postProcess(state, state.delimiters);\n\n for (curr = 0; curr < max; curr++) {\n if (tokens_meta[curr] && tokens_meta[curr].delimiters) {\n postProcess(state, tokens_meta[curr].delimiters);\n }\n }\n};\n","// Process html entity - {, ¯, ", ...\n\n'use strict';\n\nvar entities = require('../common/entities');\nvar has = require('../common/utils').has;\nvar isValidEntityCode = require('../common/utils').isValidEntityCode;\nvar fromCodePoint = require('../common/utils').fromCodePoint;\n\n\nvar DIGITAL_RE = /^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i;\nvar NAMED_RE = /^&([a-z][a-z0-9]{1,31});/i;\n\n\nmodule.exports = function entity(state, silent) {\n var ch, code, match, pos = state.pos, max = state.posMax;\n\n if (state.src.charCodeAt(pos) !== 0x26/* & */) { return false; }\n\n if (pos + 1 < max) {\n ch = state.src.charCodeAt(pos + 1);\n\n if (ch === 0x23 /* # */) {\n match = state.src.slice(pos).match(DIGITAL_RE);\n if (match) {\n if (!silent) {\n code = match[1][0].toLowerCase() === 'x' ? parseInt(match[1].slice(1), 16) : parseInt(match[1], 10);\n state.pending += isValidEntityCode(code) ? fromCodePoint(code) : fromCodePoint(0xFFFD);\n }\n state.pos += match[0].length;\n return true;\n }\n } else {\n match = state.src.slice(pos).match(NAMED_RE);\n if (match) {\n if (has(entities, match[1])) {\n if (!silent) { state.pending += entities[match[1]]; }\n state.pos += match[0].length;\n return true;\n }\n }\n }\n }\n\n if (!silent) { state.pending += '&'; }\n state.pos++;\n return true;\n};\n","// Process escaped chars and hardbreaks\n\n'use strict';\n\nvar isSpace = require('../common/utils').isSpace;\n\nvar ESCAPED = [];\n\nfor (var i = 0; i < 256; i++) { ESCAPED.push(0); }\n\n'\\\\!\"#$%&\\'()*+,./:;<=>?@[]^_`{|}~-'\n .split('').forEach(function (ch) { ESCAPED[ch.charCodeAt(0)] = 1; });\n\n\nmodule.exports = function escape(state, silent) {\n var ch, pos = state.pos, max = state.posMax;\n\n if (state.src.charCodeAt(pos) !== 0x5C/* \\ */) { return false; }\n\n pos++;\n\n if (pos < max) {\n ch = state.src.charCodeAt(pos);\n\n if (ch < 256 && ESCAPED[ch] !== 0) {\n if (!silent) { state.pending += state.src[pos]; }\n state.pos += 2;\n return true;\n }\n\n if (ch === 0x0A) {\n if (!silent) {\n state.push('hardbreak', 'br', 0);\n }\n\n pos++;\n // skip leading whitespaces from next line\n while (pos < max) {\n ch = state.src.charCodeAt(pos);\n if (!isSpace(ch)) { break; }\n pos++;\n }\n\n state.pos = pos;\n return true;\n }\n }\n\n if (!silent) { state.pending += '\\\\'; }\n state.pos++;\n return true;\n};\n","// Process html tags\n\n'use strict';\n\n\nvar HTML_TAG_RE = require('../common/html_re').HTML_TAG_RE;\n\n\nfunction isLetter(ch) {\n /*eslint no-bitwise:0*/\n var lc = ch | 0x20; // to lower case\n return (lc >= 0x61/* a */) && (lc <= 0x7a/* z */);\n}\n\n\nmodule.exports = function html_inline(state, silent) {\n var ch, match, max, token,\n pos = state.pos;\n\n if (!state.md.options.html) { return false; }\n\n // Check start\n max = state.posMax;\n if (state.src.charCodeAt(pos) !== 0x3C/* < */ ||\n pos + 2 >= max) {\n return false;\n }\n\n // Quick fail on second char\n ch = state.src.charCodeAt(pos + 1);\n if (ch !== 0x21/* ! */ &&\n ch !== 0x3F/* ? */ &&\n ch !== 0x2F/* / */ &&\n !isLetter(ch)) {\n return false;\n }\n\n match = state.src.slice(pos).match(HTML_TAG_RE);\n if (!match) { return false; }\n\n if (!silent) {\n token = state.push('html_inline', '', 0);\n token.content = state.src.slice(pos, pos + match[0].length);\n }\n state.pos += match[0].length;\n return true;\n};\n","// Process ![image]( \"title\")\n\n'use strict';\n\nvar normalizeReference = require('../common/utils').normalizeReference;\nvar isSpace = require('../common/utils').isSpace;\n\n\nmodule.exports = function image(state, silent) {\n var attrs,\n code,\n content,\n label,\n labelEnd,\n labelStart,\n pos,\n ref,\n res,\n title,\n token,\n tokens,\n start,\n href = '',\n oldPos = state.pos,\n max = state.posMax;\n\n if (state.src.charCodeAt(state.pos) !== 0x21/* ! */) { return false; }\n if (state.src.charCodeAt(state.pos + 1) !== 0x5B/* [ */) { return false; }\n\n labelStart = state.pos + 2;\n labelEnd = state.md.helpers.parseLinkLabel(state, state.pos + 1, false);\n\n // parser failed to find ']', so it's not a valid link\n if (labelEnd < 0) { return false; }\n\n pos = labelEnd + 1;\n if (pos < max && state.src.charCodeAt(pos) === 0x28/* ( */) {\n //\n // Inline link\n //\n\n // [link]( \"title\" )\n // ^^ skipping these spaces\n pos++;\n for (; pos < max; pos++) {\n code = state.src.charCodeAt(pos);\n if (!isSpace(code) && code !== 0x0A) { break; }\n }\n if (pos >= max) { return false; }\n\n // [link]( \"title\" )\n // ^^^^^^ parsing link destination\n start = pos;\n res = state.md.helpers.parseLinkDestination(state.src, pos, state.posMax);\n if (res.ok) {\n href = state.md.normalizeLink(res.str);\n if (state.md.validateLink(href)) {\n pos = res.pos;\n } else {\n href = '';\n }\n }\n\n // [link]( \"title\" )\n // ^^ skipping these spaces\n start = pos;\n for (; pos < max; pos++) {\n code = state.src.charCodeAt(pos);\n if (!isSpace(code) && code !== 0x0A) { break; }\n }\n\n // [link]( \"title\" )\n // ^^^^^^^ parsing link title\n res = state.md.helpers.parseLinkTitle(state.src, pos, state.posMax);\n if (pos < max && start !== pos && res.ok) {\n title = res.str;\n pos = res.pos;\n\n // [link]( \"title\" )\n // ^^ skipping these spaces\n for (; pos < max; pos++) {\n code = state.src.charCodeAt(pos);\n if (!isSpace(code) && code !== 0x0A) { break; }\n }\n } else {\n title = '';\n }\n\n if (pos >= max || state.src.charCodeAt(pos) !== 0x29/* ) */) {\n state.pos = oldPos;\n return false;\n }\n pos++;\n } else {\n //\n // Link reference\n //\n if (typeof state.env.references === 'undefined') { return false; }\n\n if (pos < max && state.src.charCodeAt(pos) === 0x5B/* [ */) {\n start = pos + 1;\n pos = state.md.helpers.parseLinkLabel(state, pos);\n if (pos >= 0) {\n label = state.src.slice(start, pos++);\n } else {\n pos = labelEnd + 1;\n }\n } else {\n pos = labelEnd + 1;\n }\n\n // covers label === '' and label === undefined\n // (collapsed reference link and shortcut reference link respectively)\n if (!label) { label = state.src.slice(labelStart, labelEnd); }\n\n ref = state.env.references[normalizeReference(label)];\n if (!ref) {\n state.pos = oldPos;\n return false;\n }\n href = ref.href;\n title = ref.title;\n }\n\n //\n // We found the end of the link, and know for a fact it's a valid link;\n // so all that's left to do is to call tokenizer.\n //\n if (!silent) {\n content = state.src.slice(labelStart, labelEnd);\n\n state.md.inline.parse(\n content,\n state.md,\n state.env,\n tokens = []\n );\n\n token = state.push('image', 'img', 0);\n token.attrs = attrs = [ [ 'src', href ], [ 'alt', '' ] ];\n token.children = tokens;\n token.content = content;\n\n if (title) {\n attrs.push([ 'title', title ]);\n }\n }\n\n state.pos = pos;\n state.posMax = max;\n return true;\n};\n","// Process [link]( \"stuff\")\n\n'use strict';\n\nvar normalizeReference = require('../common/utils').normalizeReference;\nvar isSpace = require('../common/utils').isSpace;\n\n\nmodule.exports = function link(state, silent) {\n var attrs,\n code,\n label,\n labelEnd,\n labelStart,\n pos,\n res,\n ref,\n token,\n href = '',\n title = '',\n oldPos = state.pos,\n max = state.posMax,\n start = state.pos,\n parseReference = true;\n\n if (state.src.charCodeAt(state.pos) !== 0x5B/* [ */) { return false; }\n\n labelStart = state.pos + 1;\n labelEnd = state.md.helpers.parseLinkLabel(state, state.pos, true);\n\n // parser failed to find ']', so it's not a valid link\n if (labelEnd < 0) { return false; }\n\n pos = labelEnd + 1;\n if (pos < max && state.src.charCodeAt(pos) === 0x28/* ( */) {\n //\n // Inline link\n //\n\n // might have found a valid shortcut link, disable reference parsing\n parseReference = false;\n\n // [link]( \"title\" )\n // ^^ skipping these spaces\n pos++;\n for (; pos < max; pos++) {\n code = state.src.charCodeAt(pos);\n if (!isSpace(code) && code !== 0x0A) { break; }\n }\n if (pos >= max) { return false; }\n\n // [link]( \"title\" )\n // ^^^^^^ parsing link destination\n start = pos;\n res = state.md.helpers.parseLinkDestination(state.src, pos, state.posMax);\n if (res.ok) {\n href = state.md.normalizeLink(res.str);\n if (state.md.validateLink(href)) {\n pos = res.pos;\n } else {\n href = '';\n }\n\n // [link]( \"title\" )\n // ^^ skipping these spaces\n start = pos;\n for (; pos < max; pos++) {\n code = state.src.charCodeAt(pos);\n if (!isSpace(code) && code !== 0x0A) { break; }\n }\n\n // [link]( \"title\" )\n // ^^^^^^^ parsing link title\n res = state.md.helpers.parseLinkTitle(state.src, pos, state.posMax);\n if (pos < max && start !== pos && res.ok) {\n title = res.str;\n pos = res.pos;\n\n // [link]( \"title\" )\n // ^^ skipping these spaces\n for (; pos < max; pos++) {\n code = state.src.charCodeAt(pos);\n if (!isSpace(code) && code !== 0x0A) { break; }\n }\n }\n }\n\n if (pos >= max || state.src.charCodeAt(pos) !== 0x29/* ) */) {\n // parsing a valid shortcut link failed, fallback to reference\n parseReference = true;\n }\n pos++;\n }\n\n if (parseReference) {\n //\n // Link reference\n //\n if (typeof state.env.references === 'undefined') { return false; }\n\n if (pos < max && state.src.charCodeAt(pos) === 0x5B/* [ */) {\n start = pos + 1;\n pos = state.md.helpers.parseLinkLabel(state, pos);\n if (pos >= 0) {\n label = state.src.slice(start, pos++);\n } else {\n pos = labelEnd + 1;\n }\n } else {\n pos = labelEnd + 1;\n }\n\n // covers label === '' and label === undefined\n // (collapsed reference link and shortcut reference link respectively)\n if (!label) { label = state.src.slice(labelStart, labelEnd); }\n\n ref = state.env.references[normalizeReference(label)];\n if (!ref) {\n state.pos = oldPos;\n return false;\n }\n href = ref.href;\n title = ref.title;\n }\n\n //\n // We found the end of the link, and know for a fact it's a valid link;\n // so all that's left to do is to call tokenizer.\n //\n if (!silent) {\n state.pos = labelStart;\n state.posMax = labelEnd;\n\n token = state.push('link_open', 'a', 1);\n token.attrs = attrs = [ [ 'href', href ] ];\n if (title) {\n attrs.push([ 'title', title ]);\n }\n\n state.md.inline.tokenize(state);\n\n token = state.push('link_close', 'a', -1);\n }\n\n state.pos = pos;\n state.posMax = max;\n return true;\n};\n","// Proceess '\\n'\n\n'use strict';\n\nvar isSpace = require('../common/utils').isSpace;\n\n\nmodule.exports = function newline(state, silent) {\n var pmax, max, ws, pos = state.pos;\n\n if (state.src.charCodeAt(pos) !== 0x0A/* \\n */) { return false; }\n\n pmax = state.pending.length - 1;\n max = state.posMax;\n\n // ' \\n' -> hardbreak\n // Lookup in pending chars is bad practice! Don't copy to other rules!\n // Pending string is stored in concat mode, indexed lookups will cause\n // convertion to flat mode.\n if (!silent) {\n if (pmax >= 0 && state.pending.charCodeAt(pmax) === 0x20) {\n if (pmax >= 1 && state.pending.charCodeAt(pmax - 1) === 0x20) {\n // Find whitespaces tail of pending chars.\n ws = pmax - 1;\n while (ws >= 1 && state.pending.charCodeAt(ws - 1) === 0x20) ws--;\n\n state.pending = state.pending.slice(0, ws);\n state.push('hardbreak', 'br', 0);\n } else {\n state.pending = state.pending.slice(0, -1);\n state.push('softbreak', 'br', 0);\n }\n\n } else {\n state.push('softbreak', 'br', 0);\n }\n }\n\n pos++;\n\n // skip heading spaces for next line\n while (pos < max && isSpace(state.src.charCodeAt(pos))) { pos++; }\n\n state.pos = pos;\n return true;\n};\n","// Inline parser state\n\n'use strict';\n\n\nvar Token = require('../token');\nvar isWhiteSpace = require('../common/utils').isWhiteSpace;\nvar isPunctChar = require('../common/utils').isPunctChar;\nvar isMdAsciiPunct = require('../common/utils').isMdAsciiPunct;\n\n\nfunction StateInline(src, md, env, outTokens) {\n this.src = src;\n this.env = env;\n this.md = md;\n this.tokens = outTokens;\n this.tokens_meta = Array(outTokens.length);\n\n this.pos = 0;\n this.posMax = this.src.length;\n this.level = 0;\n this.pending = '';\n this.pendingLevel = 0;\n\n // Stores { start: end } pairs. Useful for backtrack\n // optimization of pairs parse (emphasis, strikes).\n this.cache = {};\n\n // List of emphasis-like delimiters for current tag\n this.delimiters = [];\n\n // Stack of delimiter lists for upper level tags\n this._prev_delimiters = [];\n\n // backtick length => last seen position\n this.backticks = {};\n this.backticksScanned = false;\n}\n\n\n// Flush pending text\n//\nStateInline.prototype.pushPending = function () {\n var token = new Token('text', '', 0);\n token.content = this.pending;\n token.level = this.pendingLevel;\n this.tokens.push(token);\n this.pending = '';\n return token;\n};\n\n\n// Push new token to \"stream\".\n// If pending text exists - flush it as text token\n//\nStateInline.prototype.push = function (type, tag, nesting) {\n if (this.pending) {\n this.pushPending();\n }\n\n var token = new Token(type, tag, nesting);\n var token_meta = null;\n\n if (nesting < 0) {\n // closing tag\n this.level--;\n this.delimiters = this._prev_delimiters.pop();\n }\n\n token.level = this.level;\n\n if (nesting > 0) {\n // opening tag\n this.level++;\n this._prev_delimiters.push(this.delimiters);\n this.delimiters = [];\n token_meta = { delimiters: this.delimiters };\n }\n\n this.pendingLevel = this.level;\n this.tokens.push(token);\n this.tokens_meta.push(token_meta);\n return token;\n};\n\n\n// Scan a sequence of emphasis-like markers, and determine whether\n// it can start an emphasis sequence or end an emphasis sequence.\n//\n// - start - position to scan from (it should point at a valid marker);\n// - canSplitWord - determine if these markers can be found inside a word\n//\nStateInline.prototype.scanDelims = function (start, canSplitWord) {\n var pos = start, lastChar, nextChar, count, can_open, can_close,\n isLastWhiteSpace, isLastPunctChar,\n isNextWhiteSpace, isNextPunctChar,\n left_flanking = true,\n right_flanking = true,\n max = this.posMax,\n marker = this.src.charCodeAt(start);\n\n // treat beginning of the line as a whitespace\n lastChar = start > 0 ? this.src.charCodeAt(start - 1) : 0x20;\n\n while (pos < max && this.src.charCodeAt(pos) === marker) { pos++; }\n\n count = pos - start;\n\n // treat end of the line as a whitespace\n nextChar = pos < max ? this.src.charCodeAt(pos) : 0x20;\n\n isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctChar(String.fromCharCode(lastChar));\n isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctChar(String.fromCharCode(nextChar));\n\n isLastWhiteSpace = isWhiteSpace(lastChar);\n isNextWhiteSpace = isWhiteSpace(nextChar);\n\n if (isNextWhiteSpace) {\n left_flanking = false;\n } else if (isNextPunctChar) {\n if (!(isLastWhiteSpace || isLastPunctChar)) {\n left_flanking = false;\n }\n }\n\n if (isLastWhiteSpace) {\n right_flanking = false;\n } else if (isLastPunctChar) {\n if (!(isNextWhiteSpace || isNextPunctChar)) {\n right_flanking = false;\n }\n }\n\n if (!canSplitWord) {\n can_open = left_flanking && (!right_flanking || isLastPunctChar);\n can_close = right_flanking && (!left_flanking || isNextPunctChar);\n } else {\n can_open = left_flanking;\n can_close = right_flanking;\n }\n\n return {\n can_open: can_open,\n can_close: can_close,\n length: count\n };\n};\n\n\n// re-export Token class to use in block rules\nStateInline.prototype.Token = Token;\n\n\nmodule.exports = StateInline;\n","// ~~strike through~~\n//\n'use strict';\n\n\n// Insert each marker as a separate text token, and add it to delimiter list\n//\nmodule.exports.tokenize = function strikethrough(state, silent) {\n var i, scanned, token, len, ch,\n start = state.pos,\n marker = state.src.charCodeAt(start);\n\n if (silent) { return false; }\n\n if (marker !== 0x7E/* ~ */) { return false; }\n\n scanned = state.scanDelims(state.pos, true);\n len = scanned.length;\n ch = String.fromCharCode(marker);\n\n if (len < 2) { return false; }\n\n if (len % 2) {\n token = state.push('text', '', 0);\n token.content = ch;\n len--;\n }\n\n for (i = 0; i < len; i += 2) {\n token = state.push('text', '', 0);\n token.content = ch + ch;\n\n state.delimiters.push({\n marker: marker,\n length: 0, // disable \"rule of 3\" length checks meant for emphasis\n token: state.tokens.length - 1,\n end: -1,\n open: scanned.can_open,\n close: scanned.can_close\n });\n }\n\n state.pos += scanned.length;\n\n return true;\n};\n\n\nfunction postProcess(state, delimiters) {\n var i, j,\n startDelim,\n endDelim,\n token,\n loneMarkers = [],\n max = delimiters.length;\n\n for (i = 0; i < max; i++) {\n startDelim = delimiters[i];\n\n if (startDelim.marker !== 0x7E/* ~ */) {\n continue;\n }\n\n if (startDelim.end === -1) {\n continue;\n }\n\n endDelim = delimiters[startDelim.end];\n\n token = state.tokens[startDelim.token];\n token.type = 's_open';\n token.tag = 's';\n token.nesting = 1;\n token.markup = '~~';\n token.content = '';\n\n token = state.tokens[endDelim.token];\n token.type = 's_close';\n token.tag = 's';\n token.nesting = -1;\n token.markup = '~~';\n token.content = '';\n\n if (state.tokens[endDelim.token - 1].type === 'text' &&\n state.tokens[endDelim.token - 1].content === '~') {\n\n loneMarkers.push(endDelim.token - 1);\n }\n }\n\n // If a marker sequence has an odd number of characters, it's splitted\n // like this: `~~~~~` -> `~` + `~~` + `~~`, leaving one marker at the\n // start of the sequence.\n //\n // So, we have to move all those markers after subsequent s_close tags.\n //\n while (loneMarkers.length) {\n i = loneMarkers.pop();\n j = i + 1;\n\n while (j < state.tokens.length && state.tokens[j].type === 's_close') {\n j++;\n }\n\n j--;\n\n if (i !== j) {\n token = state.tokens[j];\n state.tokens[j] = state.tokens[i];\n state.tokens[i] = token;\n }\n }\n}\n\n\n// Walk through delimiter list and replace text tokens with tags\n//\nmodule.exports.postProcess = function strikethrough(state) {\n var curr,\n tokens_meta = state.tokens_meta,\n max = state.tokens_meta.length;\n\n postProcess(state, state.delimiters);\n\n for (curr = 0; curr < max; curr++) {\n if (tokens_meta[curr] && tokens_meta[curr].delimiters) {\n postProcess(state, tokens_meta[curr].delimiters);\n }\n }\n};\n","// Skip text characters for text token, place those to pending buffer\n// and increment current pos\n\n'use strict';\n\n\n// Rule to skip pure text\n// '{}$%@~+=:' reserved for extentions\n\n// !, \", #, $, %, &, ', (, ), *, +, ,, -, ., /, :, ;, <, =, >, ?, @, [, \\, ], ^, _, `, {, |, }, or ~\n\n// !!!! Don't confuse with \"Markdown ASCII Punctuation\" chars\n// http://spec.commonmark.org/0.15/#ascii-punctuation-character\nfunction isTerminatorChar(ch) {\n switch (ch) {\n case 0x0A/* \\n */:\n case 0x21/* ! */:\n case 0x23/* # */:\n case 0x24/* $ */:\n case 0x25/* % */:\n case 0x26/* & */:\n case 0x2A/* * */:\n case 0x2B/* + */:\n case 0x2D/* - */:\n case 0x3A/* : */:\n case 0x3C/* < */:\n case 0x3D/* = */:\n case 0x3E/* > */:\n case 0x40/* @ */:\n case 0x5B/* [ */:\n case 0x5C/* \\ */:\n case 0x5D/* ] */:\n case 0x5E/* ^ */:\n case 0x5F/* _ */:\n case 0x60/* ` */:\n case 0x7B/* { */:\n case 0x7D/* } */:\n case 0x7E/* ~ */:\n return true;\n default:\n return false;\n }\n}\n\nmodule.exports = function text(state, silent) {\n var pos = state.pos;\n\n while (pos < state.posMax && !isTerminatorChar(state.src.charCodeAt(pos))) {\n pos++;\n }\n\n if (pos === state.pos) { return false; }\n\n if (!silent) { state.pending += state.src.slice(state.pos, pos); }\n\n state.pos = pos;\n\n return true;\n};\n\n// Alternative implementation, for memory.\n//\n// It costs 10% of performance, but allows extend terminators list, if place it\n// to `ParcerInline` property. Probably, will switch to it sometime, such\n// flexibility required.\n\n/*\nvar TERMINATOR_RE = /[\\n!#$%&*+\\-:<=>@[\\\\\\]^_`{}~]/;\n\nmodule.exports = function text(state, silent) {\n var pos = state.pos,\n idx = state.src.slice(pos).search(TERMINATOR_RE);\n\n // first char is terminator -> empty text\n if (idx === 0) { return false; }\n\n // no terminator -> text till end of string\n if (idx < 0) {\n if (!silent) { state.pending += state.src.slice(pos); }\n state.pos = state.src.length;\n return true;\n }\n\n if (!silent) { state.pending += state.src.slice(pos, pos + idx); }\n\n state.pos += idx;\n\n return true;\n};*/\n","// Clean up tokens after emphasis and strikethrough postprocessing:\n// merge adjacent text nodes into one and re-calculate all token levels\n//\n// This is necessary because initially emphasis delimiter markers (*, _, ~)\n// are treated as their own separate text tokens. Then emphasis rule either\n// leaves them as text (needed to merge with adjacent text) or turns them\n// into opening/closing tags (which messes up levels inside).\n//\n'use strict';\n\n\nmodule.exports = function text_collapse(state) {\n var curr, last,\n level = 0,\n tokens = state.tokens,\n max = state.tokens.length;\n\n for (curr = last = 0; curr < max; curr++) {\n // re-calculate levels after emphasis/strikethrough turns some text nodes\n // into opening/closing tags\n if (tokens[curr].nesting < 0) level--; // closing tag\n tokens[curr].level = level;\n if (tokens[curr].nesting > 0) level++; // opening tag\n\n if (tokens[curr].type === 'text' &&\n curr + 1 < max &&\n tokens[curr + 1].type === 'text') {\n\n // collapse two adjacent text nodes\n tokens[curr + 1].content = tokens[curr].content + tokens[curr + 1].content;\n } else {\n if (curr !== last) { tokens[last] = tokens[curr]; }\n\n last++;\n }\n }\n\n if (curr !== last) {\n tokens.length = last;\n }\n};\n","// Token class\n\n'use strict';\n\n\n/**\n * class Token\n **/\n\n/**\n * new Token(type, tag, nesting)\n *\n * Create new token and fill passed properties.\n **/\nfunction Token(type, tag, nesting) {\n /**\n * Token#type -> String\n *\n * Type of the token (string, e.g. \"paragraph_open\")\n **/\n this.type = type;\n\n /**\n * Token#tag -> String\n *\n * html tag name, e.g. \"p\"\n **/\n this.tag = tag;\n\n /**\n * Token#attrs -> Array\n *\n * Html attributes. Format: `[ [ name1, value1 ], [ name2, value2 ] ]`\n **/\n this.attrs = null;\n\n /**\n * Token#map -> Array\n *\n * Source map info. Format: `[ line_begin, line_end ]`\n **/\n this.map = null;\n\n /**\n * Token#nesting -> Number\n *\n * Level change (number in {-1, 0, 1} set), where:\n *\n * - `1` means the tag is opening\n * - `0` means the tag is self-closing\n * - `-1` means the tag is closing\n **/\n this.nesting = nesting;\n\n /**\n * Token#level -> Number\n *\n * nesting level, the same as `state.level`\n **/\n this.level = 0;\n\n /**\n * Token#children -> Array\n *\n * An array of child nodes (inline and img tokens)\n **/\n this.children = null;\n\n /**\n * Token#content -> String\n *\n * In a case of self-closing tag (code, html, fence, etc.),\n * it has contents of this tag.\n **/\n this.content = '';\n\n /**\n * Token#markup -> String\n *\n * '*' or '_' for emphasis, fence string for fence, etc.\n **/\n this.markup = '';\n\n /**\n * Token#info -> String\n *\n * Additional information:\n *\n * - Info string for \"fence\" tokens\n * - The value \"auto\" for autolink \"link_open\" and \"link_close\" tokens\n * - The string value of the item marker for ordered-list \"list_item_open\" tokens\n **/\n this.info = '';\n\n /**\n * Token#meta -> Object\n *\n * A place for plugins to store an arbitrary data\n **/\n this.meta = null;\n\n /**\n * Token#block -> Boolean\n *\n * True for block-level tokens, false for inline tokens.\n * Used in renderer to calculate line breaks\n **/\n this.block = false;\n\n /**\n * Token#hidden -> Boolean\n *\n * If it's true, ignore this element when rendering. Used for tight lists\n * to hide paragraphs.\n **/\n this.hidden = false;\n}\n\n\n/**\n * Token.attrIndex(name) -> Number\n *\n * Search attribute index by name.\n **/\nToken.prototype.attrIndex = function attrIndex(name) {\n var attrs, i, len;\n\n if (!this.attrs) { return -1; }\n\n attrs = this.attrs;\n\n for (i = 0, len = attrs.length; i < len; i++) {\n if (attrs[i][0] === name) { return i; }\n }\n return -1;\n};\n\n\n/**\n * Token.attrPush(attrData)\n *\n * Add `[ name, value ]` attribute to list. Init attrs if necessary\n **/\nToken.prototype.attrPush = function attrPush(attrData) {\n if (this.attrs) {\n this.attrs.push(attrData);\n } else {\n this.attrs = [ attrData ];\n }\n};\n\n\n/**\n * Token.attrSet(name, value)\n *\n * Set `name` attribute to `value`. Override old value if exists.\n **/\nToken.prototype.attrSet = function attrSet(name, value) {\n var idx = this.attrIndex(name),\n attrData = [ name, value ];\n\n if (idx < 0) {\n this.attrPush(attrData);\n } else {\n this.attrs[idx] = attrData;\n }\n};\n\n\n/**\n * Token.attrGet(name)\n *\n * Get the value of attribute `name`, or null if it does not exist.\n **/\nToken.prototype.attrGet = function attrGet(name) {\n var idx = this.attrIndex(name), value = null;\n if (idx >= 0) {\n value = this.attrs[idx][1];\n }\n return value;\n};\n\n\n/**\n * Token.attrJoin(name, value)\n *\n * Join value to existing attribute via space. Or create new attribute if not\n * exists. Useful to operate with token classes.\n **/\nToken.prototype.attrJoin = function attrJoin(name, value) {\n var idx = this.attrIndex(name);\n\n if (idx < 0) {\n this.attrPush([ name, value ]);\n } else {\n this.attrs[idx][1] = this.attrs[idx][1] + ' ' + value;\n }\n};\n\n\nmodule.exports = Token;\n","\n'use strict';\n\n\n/* eslint-disable no-bitwise */\n\nvar decodeCache = {};\n\nfunction getDecodeCache(exclude) {\n var i, ch, cache = decodeCache[exclude];\n if (cache) { return cache; }\n\n cache = decodeCache[exclude] = [];\n\n for (i = 0; i < 128; i++) {\n ch = String.fromCharCode(i);\n cache.push(ch);\n }\n\n for (i = 0; i < exclude.length; i++) {\n ch = exclude.charCodeAt(i);\n cache[ch] = '%' + ('0' + ch.toString(16).toUpperCase()).slice(-2);\n }\n\n return cache;\n}\n\n\n// Decode percent-encoded string.\n//\nfunction decode(string, exclude) {\n var cache;\n\n if (typeof exclude !== 'string') {\n exclude = decode.defaultChars;\n }\n\n cache = getDecodeCache(exclude);\n\n return string.replace(/(%[a-f0-9]{2})+/gi, function(seq) {\n var i, l, b1, b2, b3, b4, chr,\n result = '';\n\n for (i = 0, l = seq.length; i < l; i += 3) {\n b1 = parseInt(seq.slice(i + 1, i + 3), 16);\n\n if (b1 < 0x80) {\n result += cache[b1];\n continue;\n }\n\n if ((b1 & 0xE0) === 0xC0 && (i + 3 < l)) {\n // 110xxxxx 10xxxxxx\n b2 = parseInt(seq.slice(i + 4, i + 6), 16);\n\n if ((b2 & 0xC0) === 0x80) {\n chr = ((b1 << 6) & 0x7C0) | (b2 & 0x3F);\n\n if (chr < 0x80) {\n result += '\\ufffd\\ufffd';\n } else {\n result += String.fromCharCode(chr);\n }\n\n i += 3;\n continue;\n }\n }\n\n if ((b1 & 0xF0) === 0xE0 && (i + 6 < l)) {\n // 1110xxxx 10xxxxxx 10xxxxxx\n b2 = parseInt(seq.slice(i + 4, i + 6), 16);\n b3 = parseInt(seq.slice(i + 7, i + 9), 16);\n\n if ((b2 & 0xC0) === 0x80 && (b3 & 0xC0) === 0x80) {\n chr = ((b1 << 12) & 0xF000) | ((b2 << 6) & 0xFC0) | (b3 & 0x3F);\n\n if (chr < 0x800 || (chr >= 0xD800 && chr <= 0xDFFF)) {\n result += '\\ufffd\\ufffd\\ufffd';\n } else {\n result += String.fromCharCode(chr);\n }\n\n i += 6;\n continue;\n }\n }\n\n if ((b1 & 0xF8) === 0xF0 && (i + 9 < l)) {\n // 111110xx 10xxxxxx 10xxxxxx 10xxxxxx\n b2 = parseInt(seq.slice(i + 4, i + 6), 16);\n b3 = parseInt(seq.slice(i + 7, i + 9), 16);\n b4 = parseInt(seq.slice(i + 10, i + 12), 16);\n\n if ((b2 & 0xC0) === 0x80 && (b3 & 0xC0) === 0x80 && (b4 & 0xC0) === 0x80) {\n chr = ((b1 << 18) & 0x1C0000) | ((b2 << 12) & 0x3F000) | ((b3 << 6) & 0xFC0) | (b4 & 0x3F);\n\n if (chr < 0x10000 || chr > 0x10FFFF) {\n result += '\\ufffd\\ufffd\\ufffd\\ufffd';\n } else {\n chr -= 0x10000;\n result += String.fromCharCode(0xD800 + (chr >> 10), 0xDC00 + (chr & 0x3FF));\n }\n\n i += 9;\n continue;\n }\n }\n\n result += '\\ufffd';\n }\n\n return result;\n });\n}\n\n\ndecode.defaultChars = ';/?:@&=+$,#';\ndecode.componentChars = '';\n\n\nmodule.exports = decode;\n","\n'use strict';\n\n\nvar encodeCache = {};\n\n\n// Create a lookup array where anything but characters in `chars` string\n// and alphanumeric chars is percent-encoded.\n//\nfunction getEncodeCache(exclude) {\n var i, ch, cache = encodeCache[exclude];\n if (cache) { return cache; }\n\n cache = encodeCache[exclude] = [];\n\n for (i = 0; i < 128; i++) {\n ch = String.fromCharCode(i);\n\n if (/^[0-9a-z]$/i.test(ch)) {\n // always allow unencoded alphanumeric characters\n cache.push(ch);\n } else {\n cache.push('%' + ('0' + i.toString(16).toUpperCase()).slice(-2));\n }\n }\n\n for (i = 0; i < exclude.length; i++) {\n cache[exclude.charCodeAt(i)] = exclude[i];\n }\n\n return cache;\n}\n\n\n// Encode unsafe characters with percent-encoding, skipping already\n// encoded sequences.\n//\n// - string - string to encode\n// - exclude - list of characters to ignore (in addition to a-zA-Z0-9)\n// - keepEscaped - don't encode '%' in a correct escape sequence (default: true)\n//\nfunction encode(string, exclude, keepEscaped) {\n var i, l, code, nextCode, cache,\n result = '';\n\n if (typeof exclude !== 'string') {\n // encode(string, keepEscaped)\n keepEscaped = exclude;\n exclude = encode.defaultChars;\n }\n\n if (typeof keepEscaped === 'undefined') {\n keepEscaped = true;\n }\n\n cache = getEncodeCache(exclude);\n\n for (i = 0, l = string.length; i < l; i++) {\n code = string.charCodeAt(i);\n\n if (keepEscaped && code === 0x25 /* % */ && i + 2 < l) {\n if (/^[0-9a-f]{2}$/i.test(string.slice(i + 1, i + 3))) {\n result += string.slice(i, i + 3);\n i += 2;\n continue;\n }\n }\n\n if (code < 128) {\n result += cache[code];\n continue;\n }\n\n if (code >= 0xD800 && code <= 0xDFFF) {\n if (code >= 0xD800 && code <= 0xDBFF && i + 1 < l) {\n nextCode = string.charCodeAt(i + 1);\n if (nextCode >= 0xDC00 && nextCode <= 0xDFFF) {\n result += encodeURIComponent(string[i] + string[i + 1]);\n i++;\n continue;\n }\n }\n result += '%EF%BF%BD';\n continue;\n }\n\n result += encodeURIComponent(string[i]);\n }\n\n return result;\n}\n\nencode.defaultChars = \";/?:@&=+$,-_.!~*'()#\";\nencode.componentChars = \"-_.!~*'()\";\n\n\nmodule.exports = encode;\n","\n'use strict';\n\n\nmodule.exports = function format(url) {\n var result = '';\n\n result += url.protocol || '';\n result += url.slashes ? '//' : '';\n result += url.auth ? url.auth + '@' : '';\n\n if (url.hostname && url.hostname.indexOf(':') !== -1) {\n // ipv6 address\n result += '[' + url.hostname + ']';\n } else {\n result += url.hostname || '';\n }\n\n result += url.port ? ':' + url.port : '';\n result += url.pathname || '';\n result += url.search || '';\n result += url.hash || '';\n\n return result;\n};\n","'use strict';\n\n\nmodule.exports.encode = require('./encode');\nmodule.exports.decode = require('./decode');\nmodule.exports.format = require('./format');\nmodule.exports.parse = require('./parse');\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\n//\n// Changes from joyent/node:\n//\n// 1. No leading slash in paths,\n// e.g. in `url.parse('http://foo?bar')` pathname is ``, not `/`\n//\n// 2. Backslashes are not replaced with slashes,\n// so `http:\\\\example.org\\` is treated like a relative path\n//\n// 3. Trailing colon is treated like a part of the path,\n// i.e. in `http://example.org:foo` pathname is `:foo`\n//\n// 4. Nothing is URL-encoded in the resulting object,\n// (in joyent/node some chars in auth and paths are encoded)\n//\n// 5. `url.parse()` does not have `parseQueryString` argument\n//\n// 6. Removed extraneous result properties: `host`, `path`, `query`, etc.,\n// which can be constructed using other parts of the url.\n//\n\n\nfunction Url() {\n this.protocol = null;\n this.slashes = null;\n this.auth = null;\n this.port = null;\n this.hostname = null;\n this.hash = null;\n this.search = null;\n this.pathname = null;\n}\n\n// Reference: RFC 3986, RFC 1808, RFC 2396\n\n// define these here so at least they only have to be\n// compiled once on the first module load.\nvar protocolPattern = /^([a-z0-9.+-]+:)/i,\n portPattern = /:[0-9]*$/,\n\n // Special case for a simple path URL\n simplePathPattern = /^(\\/\\/?(?!\\/)[^\\?\\s]*)(\\?[^\\s]*)?$/,\n\n // RFC 2396: characters reserved for delimiting URLs.\n // We actually just auto-escape these.\n delims = [ '<', '>', '\"', '`', ' ', '\\r', '\\n', '\\t' ],\n\n // RFC 2396: characters not allowed for various reasons.\n unwise = [ '{', '}', '|', '\\\\', '^', '`' ].concat(delims),\n\n // Allowed by RFCs, but cause of XSS attacks. Always escape these.\n autoEscape = [ '\\'' ].concat(unwise),\n // Characters that are never ever allowed in a hostname.\n // Note that any invalid chars are also handled, but these\n // are the ones that are *expected* to be seen, so we fast-path\n // them.\n nonHostChars = [ '%', '/', '?', ';', '#' ].concat(autoEscape),\n hostEndingChars = [ '/', '?', '#' ],\n hostnameMaxLen = 255,\n hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/,\n hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/,\n // protocols that can allow \"unsafe\" and \"unwise\" chars.\n /* eslint-disable no-script-url */\n // protocols that never have a hostname.\n hostlessProtocol = {\n 'javascript': true,\n 'javascript:': true\n },\n // protocols that always contain a // bit.\n slashedProtocol = {\n 'http': true,\n 'https': true,\n 'ftp': true,\n 'gopher': true,\n 'file': true,\n 'http:': true,\n 'https:': true,\n 'ftp:': true,\n 'gopher:': true,\n 'file:': true\n };\n /* eslint-enable no-script-url */\n\nfunction urlParse(url, slashesDenoteHost) {\n if (url && url instanceof Url) { return url; }\n\n var u = new Url();\n u.parse(url, slashesDenoteHost);\n return u;\n}\n\nUrl.prototype.parse = function(url, slashesDenoteHost) {\n var i, l, lowerProto, hec, slashes,\n rest = url;\n\n // trim before proceeding.\n // This is to support parse stuff like \" http://foo.com \\n\"\n rest = rest.trim();\n\n if (!slashesDenoteHost && url.split('#').length === 1) {\n // Try fast path regexp\n var simplePath = simplePathPattern.exec(rest);\n if (simplePath) {\n this.pathname = simplePath[1];\n if (simplePath[2]) {\n this.search = simplePath[2];\n }\n return this;\n }\n }\n\n var proto = protocolPattern.exec(rest);\n if (proto) {\n proto = proto[0];\n lowerProto = proto.toLowerCase();\n this.protocol = proto;\n rest = rest.substr(proto.length);\n }\n\n // figure out if it's got a host\n // user@server is *always* interpreted as a hostname, and url\n // resolution will treat //foo/bar as host=foo,path=bar because that's\n // how the browser resolves relative URLs.\n if (slashesDenoteHost || proto || rest.match(/^\\/\\/[^@\\/]+@[^@\\/]+/)) {\n slashes = rest.substr(0, 2) === '//';\n if (slashes && !(proto && hostlessProtocol[proto])) {\n rest = rest.substr(2);\n this.slashes = true;\n }\n }\n\n if (!hostlessProtocol[proto] &&\n (slashes || (proto && !slashedProtocol[proto]))) {\n\n // there's a hostname.\n // the first instance of /, ?, ;, or # ends the host.\n //\n // If there is an @ in the hostname, then non-host chars *are* allowed\n // to the left of the last @ sign, unless some host-ending character\n // comes *before* the @-sign.\n // URLs are obnoxious.\n //\n // ex:\n // http://a@b@c/ => user:a@b host:c\n // http://a@b?@c => user:a host:c path:/?@c\n\n // v0.12 TODO(isaacs): This is not quite how Chrome does things.\n // Review our test case against browsers more comprehensively.\n\n // find the first instance of any hostEndingChars\n var hostEnd = -1;\n for (i = 0; i < hostEndingChars.length; i++) {\n hec = rest.indexOf(hostEndingChars[i]);\n if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) {\n hostEnd = hec;\n }\n }\n\n // at this point, either we have an explicit point where the\n // auth portion cannot go past, or the last @ char is the decider.\n var auth, atSign;\n if (hostEnd === -1) {\n // atSign can be anywhere.\n atSign = rest.lastIndexOf('@');\n } else {\n // atSign must be in auth portion.\n // http://a@b/c@d => host:b auth:a path:/c@d\n atSign = rest.lastIndexOf('@', hostEnd);\n }\n\n // Now we have a portion which is definitely the auth.\n // Pull that off.\n if (atSign !== -1) {\n auth = rest.slice(0, atSign);\n rest = rest.slice(atSign + 1);\n this.auth = auth;\n }\n\n // the host is the remaining to the left of the first non-host char\n hostEnd = -1;\n for (i = 0; i < nonHostChars.length; i++) {\n hec = rest.indexOf(nonHostChars[i]);\n if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) {\n hostEnd = hec;\n }\n }\n // if we still have not hit it, then the entire thing is a host.\n if (hostEnd === -1) {\n hostEnd = rest.length;\n }\n\n if (rest[hostEnd - 1] === ':') { hostEnd--; }\n var host = rest.slice(0, hostEnd);\n rest = rest.slice(hostEnd);\n\n // pull out port.\n this.parseHost(host);\n\n // we've indicated that there is a hostname,\n // so even if it's empty, it has to be present.\n this.hostname = this.hostname || '';\n\n // if hostname begins with [ and ends with ]\n // assume that it's an IPv6 address.\n var ipv6Hostname = this.hostname[0] === '[' &&\n this.hostname[this.hostname.length - 1] === ']';\n\n // validate a little.\n if (!ipv6Hostname) {\n var hostparts = this.hostname.split(/\\./);\n for (i = 0, l = hostparts.length; i < l; i++) {\n var part = hostparts[i];\n if (!part) { continue; }\n if (!part.match(hostnamePartPattern)) {\n var newpart = '';\n for (var j = 0, k = part.length; j < k; j++) {\n if (part.charCodeAt(j) > 127) {\n // we replace non-ASCII char with a temporary placeholder\n // we need this to make sure size of hostname is not\n // broken by replacing non-ASCII by nothing\n newpart += 'x';\n } else {\n newpart += part[j];\n }\n }\n // we test again with ASCII char only\n if (!newpart.match(hostnamePartPattern)) {\n var validParts = hostparts.slice(0, i);\n var notHost = hostparts.slice(i + 1);\n var bit = part.match(hostnamePartStart);\n if (bit) {\n validParts.push(bit[1]);\n notHost.unshift(bit[2]);\n }\n if (notHost.length) {\n rest = notHost.join('.') + rest;\n }\n this.hostname = validParts.join('.');\n break;\n }\n }\n }\n }\n\n if (this.hostname.length > hostnameMaxLen) {\n this.hostname = '';\n }\n\n // strip [ and ] from the hostname\n // the host field still retains them, though\n if (ipv6Hostname) {\n this.hostname = this.hostname.substr(1, this.hostname.length - 2);\n }\n }\n\n // chop off from the tail first.\n var hash = rest.indexOf('#');\n if (hash !== -1) {\n // got a fragment string.\n this.hash = rest.substr(hash);\n rest = rest.slice(0, hash);\n }\n var qm = rest.indexOf('?');\n if (qm !== -1) {\n this.search = rest.substr(qm);\n rest = rest.slice(0, qm);\n }\n if (rest) { this.pathname = rest; }\n if (slashedProtocol[lowerProto] &&\n this.hostname && !this.pathname) {\n this.pathname = '';\n }\n\n return this;\n};\n\nUrl.prototype.parseHost = function(host) {\n var port = portPattern.exec(host);\n if (port) {\n port = port[0];\n if (port !== ':') {\n this.port = port.substr(1);\n }\n host = host.substr(0, host.length - port.length);\n }\n if (host) { this.hostname = host; }\n};\n\nmodule.exports = urlParse;\n","'use strict';\n\n/** Highest positive signed 32-bit float value */\nconst maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1\n\n/** Bootstring parameters */\nconst base = 36;\nconst tMin = 1;\nconst tMax = 26;\nconst skew = 38;\nconst damp = 700;\nconst initialBias = 72;\nconst initialN = 128; // 0x80\nconst delimiter = '-'; // '\\x2D'\n\n/** Regular expressions */\nconst regexPunycode = /^xn--/;\nconst regexNonASCII = /[^\\0-\\x7E]/; // non-ASCII chars\nconst regexSeparators = /[\\x2E\\u3002\\uFF0E\\uFF61]/g; // RFC 3490 separators\n\n/** Error messages */\nconst errors = {\n\t'overflow': 'Overflow: input needs wider integers to process',\n\t'not-basic': 'Illegal input >= 0x80 (not a basic code point)',\n\t'invalid-input': 'Invalid input'\n};\n\n/** Convenience shortcuts */\nconst baseMinusTMin = base - tMin;\nconst floor = Math.floor;\nconst stringFromCharCode = String.fromCharCode;\n\n/*--------------------------------------------------------------------------*/\n\n/**\n * A generic error utility function.\n * @private\n * @param {String} type The error type.\n * @returns {Error} Throws a `RangeError` with the applicable error message.\n */\nfunction error(type) {\n\tthrow new RangeError(errors[type]);\n}\n\n/**\n * A generic `Array#map` utility function.\n * @private\n * @param {Array} array The array to iterate over.\n * @param {Function} callback The function that gets called for every array\n * item.\n * @returns {Array} A new array of values returned by the callback function.\n */\nfunction map(array, fn) {\n\tconst result = [];\n\tlet length = array.length;\n\twhile (length--) {\n\t\tresult[length] = fn(array[length]);\n\t}\n\treturn result;\n}\n\n/**\n * A simple `Array#map`-like wrapper to work with domain name strings or email\n * addresses.\n * @private\n * @param {String} domain The domain name or email address.\n * @param {Function} callback The function that gets called for every\n * character.\n * @returns {Array} A new string of characters returned by the callback\n * function.\n */\nfunction mapDomain(string, fn) {\n\tconst parts = string.split('@');\n\tlet result = '';\n\tif (parts.length > 1) {\n\t\t// In email addresses, only the domain name should be punycoded. Leave\n\t\t// the local part (i.e. everything up to `@`) intact.\n\t\tresult = parts[0] + '@';\n\t\tstring = parts[1];\n\t}\n\t// Avoid `split(regex)` for IE8 compatibility. See #17.\n\tstring = string.replace(regexSeparators, '\\x2E');\n\tconst labels = string.split('.');\n\tconst encoded = map(labels, fn).join('.');\n\treturn result + encoded;\n}\n\n/**\n * Creates an array containing the numeric code points of each Unicode\n * character in the string. While JavaScript uses UCS-2 internally,\n * this function will convert a pair of surrogate halves (each of which\n * UCS-2 exposes as separate characters) into a single code point,\n * matching UTF-16.\n * @see `punycode.ucs2.encode`\n * @see \n * @memberOf punycode.ucs2\n * @name decode\n * @param {String} string The Unicode input string (UCS-2).\n * @returns {Array} The new array of code points.\n */\nfunction ucs2decode(string) {\n\tconst output = [];\n\tlet counter = 0;\n\tconst length = string.length;\n\twhile (counter < length) {\n\t\tconst value = string.charCodeAt(counter++);\n\t\tif (value >= 0xD800 && value <= 0xDBFF && counter < length) {\n\t\t\t// It's a high surrogate, and there is a next character.\n\t\t\tconst extra = string.charCodeAt(counter++);\n\t\t\tif ((extra & 0xFC00) == 0xDC00) { // Low surrogate.\n\t\t\t\toutput.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);\n\t\t\t} else {\n\t\t\t\t// It's an unmatched surrogate; only append this code unit, in case the\n\t\t\t\t// next code unit is the high surrogate of a surrogate pair.\n\t\t\t\toutput.push(value);\n\t\t\t\tcounter--;\n\t\t\t}\n\t\t} else {\n\t\t\toutput.push(value);\n\t\t}\n\t}\n\treturn output;\n}\n\n/**\n * Creates a string based on an array of numeric code points.\n * @see `punycode.ucs2.decode`\n * @memberOf punycode.ucs2\n * @name encode\n * @param {Array} codePoints The array of numeric code points.\n * @returns {String} The new Unicode string (UCS-2).\n */\nconst ucs2encode = array => String.fromCodePoint(...array);\n\n/**\n * Converts a basic code point into a digit/integer.\n * @see `digitToBasic()`\n * @private\n * @param {Number} codePoint The basic numeric code point value.\n * @returns {Number} The numeric value of a basic code point (for use in\n * representing integers) in the range `0` to `base - 1`, or `base` if\n * the code point does not represent a value.\n */\nconst basicToDigit = function(codePoint) {\n\tif (codePoint - 0x30 < 0x0A) {\n\t\treturn codePoint - 0x16;\n\t}\n\tif (codePoint - 0x41 < 0x1A) {\n\t\treturn codePoint - 0x41;\n\t}\n\tif (codePoint - 0x61 < 0x1A) {\n\t\treturn codePoint - 0x61;\n\t}\n\treturn base;\n};\n\n/**\n * Converts a digit/integer into a basic code point.\n * @see `basicToDigit()`\n * @private\n * @param {Number} digit The numeric value of a basic code point.\n * @returns {Number} The basic code point whose value (when used for\n * representing integers) is `digit`, which needs to be in the range\n * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is\n * used; else, the lowercase form is used. The behavior is undefined\n * if `flag` is non-zero and `digit` has no uppercase form.\n */\nconst digitToBasic = function(digit, flag) {\n\t// 0..25 map to ASCII a..z or A..Z\n\t// 26..35 map to ASCII 0..9\n\treturn digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);\n};\n\n/**\n * Bias adaptation function as per section 3.4 of RFC 3492.\n * https://tools.ietf.org/html/rfc3492#section-3.4\n * @private\n */\nconst adapt = function(delta, numPoints, firstTime) {\n\tlet k = 0;\n\tdelta = firstTime ? floor(delta / damp) : delta >> 1;\n\tdelta += floor(delta / numPoints);\n\tfor (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) {\n\t\tdelta = floor(delta / baseMinusTMin);\n\t}\n\treturn floor(k + (baseMinusTMin + 1) * delta / (delta + skew));\n};\n\n/**\n * Converts a Punycode string of ASCII-only symbols to a string of Unicode\n * symbols.\n * @memberOf punycode\n * @param {String} input The Punycode string of ASCII-only symbols.\n * @returns {String} The resulting string of Unicode symbols.\n */\nconst decode = function(input) {\n\t// Don't use UCS-2.\n\tconst output = [];\n\tconst inputLength = input.length;\n\tlet i = 0;\n\tlet n = initialN;\n\tlet bias = initialBias;\n\n\t// Handle the basic code points: let `basic` be the number of input code\n\t// points before the last delimiter, or `0` if there is none, then copy\n\t// the first basic code points to the output.\n\n\tlet basic = input.lastIndexOf(delimiter);\n\tif (basic < 0) {\n\t\tbasic = 0;\n\t}\n\n\tfor (let j = 0; j < basic; ++j) {\n\t\t// if it's not a basic code point\n\t\tif (input.charCodeAt(j) >= 0x80) {\n\t\t\terror('not-basic');\n\t\t}\n\t\toutput.push(input.charCodeAt(j));\n\t}\n\n\t// Main decoding loop: start just after the last delimiter if any basic code\n\t// points were copied; start at the beginning otherwise.\n\n\tfor (let index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) {\n\n\t\t// `index` is the index of the next character to be consumed.\n\t\t// Decode a generalized variable-length integer into `delta`,\n\t\t// which gets added to `i`. The overflow checking is easier\n\t\t// if we increase `i` as we go, then subtract off its starting\n\t\t// value at the end to obtain `delta`.\n\t\tlet oldi = i;\n\t\tfor (let w = 1, k = base; /* no condition */; k += base) {\n\n\t\t\tif (index >= inputLength) {\n\t\t\t\terror('invalid-input');\n\t\t\t}\n\n\t\t\tconst digit = basicToDigit(input.charCodeAt(index++));\n\n\t\t\tif (digit >= base || digit > floor((maxInt - i) / w)) {\n\t\t\t\terror('overflow');\n\t\t\t}\n\n\t\t\ti += digit * w;\n\t\t\tconst t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);\n\n\t\t\tif (digit < t) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tconst baseMinusT = base - t;\n\t\t\tif (w > floor(maxInt / baseMinusT)) {\n\t\t\t\terror('overflow');\n\t\t\t}\n\n\t\t\tw *= baseMinusT;\n\n\t\t}\n\n\t\tconst out = output.length + 1;\n\t\tbias = adapt(i - oldi, out, oldi == 0);\n\n\t\t// `i` was supposed to wrap around from `out` to `0`,\n\t\t// incrementing `n` each time, so we'll fix that now:\n\t\tif (floor(i / out) > maxInt - n) {\n\t\t\terror('overflow');\n\t\t}\n\n\t\tn += floor(i / out);\n\t\ti %= out;\n\n\t\t// Insert `n` at position `i` of the output.\n\t\toutput.splice(i++, 0, n);\n\n\t}\n\n\treturn String.fromCodePoint(...output);\n};\n\n/**\n * Converts a string of Unicode symbols (e.g. a domain name label) to a\n * Punycode string of ASCII-only symbols.\n * @memberOf punycode\n * @param {String} input The string of Unicode symbols.\n * @returns {String} The resulting Punycode string of ASCII-only symbols.\n */\nconst encode = function(input) {\n\tconst output = [];\n\n\t// Convert the input in UCS-2 to an array of Unicode code points.\n\tinput = ucs2decode(input);\n\n\t// Cache the length.\n\tlet inputLength = input.length;\n\n\t// Initialize the state.\n\tlet n = initialN;\n\tlet delta = 0;\n\tlet bias = initialBias;\n\n\t// Handle the basic code points.\n\tfor (const currentValue of input) {\n\t\tif (currentValue < 0x80) {\n\t\t\toutput.push(stringFromCharCode(currentValue));\n\t\t}\n\t}\n\n\tlet basicLength = output.length;\n\tlet handledCPCount = basicLength;\n\n\t// `handledCPCount` is the number of code points that have been handled;\n\t// `basicLength` is the number of basic code points.\n\n\t// Finish the basic string with a delimiter unless it's empty.\n\tif (basicLength) {\n\t\toutput.push(delimiter);\n\t}\n\n\t// Main encoding loop:\n\twhile (handledCPCount < inputLength) {\n\n\t\t// All non-basic code points < n have been handled already. Find the next\n\t\t// larger one:\n\t\tlet m = maxInt;\n\t\tfor (const currentValue of input) {\n\t\t\tif (currentValue >= n && currentValue < m) {\n\t\t\t\tm = currentValue;\n\t\t\t}\n\t\t}\n\n\t\t// Increase `delta` enough to advance the decoder's state to ,\n\t\t// but guard against overflow.\n\t\tconst handledCPCountPlusOne = handledCPCount + 1;\n\t\tif (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {\n\t\t\terror('overflow');\n\t\t}\n\n\t\tdelta += (m - n) * handledCPCountPlusOne;\n\t\tn = m;\n\n\t\tfor (const currentValue of input) {\n\t\t\tif (currentValue < n && ++delta > maxInt) {\n\t\t\t\terror('overflow');\n\t\t\t}\n\t\t\tif (currentValue == n) {\n\t\t\t\t// Represent delta as a generalized variable-length integer.\n\t\t\t\tlet q = delta;\n\t\t\t\tfor (let k = base; /* no condition */; k += base) {\n\t\t\t\t\tconst t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);\n\t\t\t\t\tif (q < t) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tconst qMinusT = q - t;\n\t\t\t\t\tconst baseMinusT = base - t;\n\t\t\t\t\toutput.push(\n\t\t\t\t\t\tstringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))\n\t\t\t\t\t);\n\t\t\t\t\tq = floor(qMinusT / baseMinusT);\n\t\t\t\t}\n\n\t\t\t\toutput.push(stringFromCharCode(digitToBasic(q, 0)));\n\t\t\t\tbias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);\n\t\t\t\tdelta = 0;\n\t\t\t\t++handledCPCount;\n\t\t\t}\n\t\t}\n\n\t\t++delta;\n\t\t++n;\n\n\t}\n\treturn output.join('');\n};\n\n/**\n * Converts a Punycode string representing a domain name or an email address\n * to Unicode. Only the Punycoded parts of the input will be converted, i.e.\n * it doesn't matter if you call it on a string that has already been\n * converted to Unicode.\n * @memberOf punycode\n * @param {String} input The Punycoded domain name or email address to\n * convert to Unicode.\n * @returns {String} The Unicode representation of the given Punycode\n * string.\n */\nconst toUnicode = function(input) {\n\treturn mapDomain(input, function(string) {\n\t\treturn regexPunycode.test(string)\n\t\t\t? decode(string.slice(4).toLowerCase())\n\t\t\t: string;\n\t});\n};\n\n/**\n * Converts a Unicode string representing a domain name or an email address to\n * Punycode. Only the non-ASCII parts of the domain name will be converted,\n * i.e. it doesn't matter if you call it with a domain that's already in\n * ASCII.\n * @memberOf punycode\n * @param {String} input The domain name or email address to convert, as a\n * Unicode string.\n * @returns {String} The Punycode representation of the given domain name or\n * email address.\n */\nconst toASCII = function(input) {\n\treturn mapDomain(input, function(string) {\n\t\treturn regexNonASCII.test(string)\n\t\t\t? 'xn--' + encode(string)\n\t\t\t: string;\n\t});\n};\n\n/*--------------------------------------------------------------------------*/\n\n/** Define the public API */\nconst punycode = {\n\t/**\n\t * A string representing the current Punycode.js version number.\n\t * @memberOf punycode\n\t * @type String\n\t */\n\t'version': '2.1.0',\n\t/**\n\t * An object of methods to convert from JavaScript's internal character\n\t * representation (UCS-2) to Unicode code points, and back.\n\t * @see \n\t * @memberOf punycode\n\t * @type Object\n\t */\n\t'ucs2': {\n\t\t'decode': ucs2decode,\n\t\t'encode': ucs2encode\n\t},\n\t'decode': decode,\n\t'encode': encode,\n\t'toASCII': toASCII,\n\t'toUnicode': toUnicode\n};\n\nexport { ucs2decode, ucs2encode, decode, encode, toASCII, toUnicode };\nexport default punycode;\n","\"use strict\";\n\nvar stylesInDOM = [];\n\nfunction getIndexByIdentifier(identifier) {\n var result = -1;\n\n for (var i = 0; i < stylesInDOM.length; i++) {\n if (stylesInDOM[i].identifier === identifier) {\n result = i;\n break;\n }\n }\n\n return result;\n}\n\nfunction modulesToDom(list, options) {\n var idCountMap = {};\n var identifiers = [];\n\n for (var i = 0; i < list.length; i++) {\n var item = list[i];\n var id = options.base ? item[0] + options.base : item[0];\n var count = idCountMap[id] || 0;\n var identifier = \"\".concat(id, \" \").concat(count);\n idCountMap[id] = count + 1;\n var indexByIdentifier = getIndexByIdentifier(identifier);\n var obj = {\n css: item[1],\n media: item[2],\n sourceMap: item[3],\n supports: item[4],\n layer: item[5]\n };\n\n if (indexByIdentifier !== -1) {\n stylesInDOM[indexByIdentifier].references++;\n stylesInDOM[indexByIdentifier].updater(obj);\n } else {\n var updater = addElementStyle(obj, options);\n options.byIndex = i;\n stylesInDOM.splice(i, 0, {\n identifier: identifier,\n updater: updater,\n references: 1\n });\n }\n\n identifiers.push(identifier);\n }\n\n return identifiers;\n}\n\nfunction addElementStyle(obj, options) {\n var api = options.domAPI(options);\n api.update(obj);\n\n var updater = function updater(newObj) {\n if (newObj) {\n if (newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap && newObj.supports === obj.supports && newObj.layer === obj.layer) {\n return;\n }\n\n api.update(obj = newObj);\n } else {\n api.remove();\n }\n };\n\n return updater;\n}\n\nmodule.exports = function (list, options) {\n options = options || {};\n list = list || [];\n var lastIdentifiers = modulesToDom(list, options);\n return function update(newList) {\n newList = newList || [];\n\n for (var i = 0; i < lastIdentifiers.length; i++) {\n var identifier = lastIdentifiers[i];\n var index = getIndexByIdentifier(identifier);\n stylesInDOM[index].references--;\n }\n\n var newLastIdentifiers = modulesToDom(newList, options);\n\n for (var _i = 0; _i < lastIdentifiers.length; _i++) {\n var _identifier = lastIdentifiers[_i];\n\n var _index = getIndexByIdentifier(_identifier);\n\n if (stylesInDOM[_index].references === 0) {\n stylesInDOM[_index].updater();\n\n stylesInDOM.splice(_index, 1);\n }\n }\n\n lastIdentifiers = newLastIdentifiers;\n };\n};","\"use strict\";\n\nvar memo = {};\n/* istanbul ignore next */\n\nfunction getTarget(target) {\n if (typeof memo[target] === \"undefined\") {\n var styleTarget = document.querySelector(target); // Special case to return head of iframe instead of iframe itself\n\n if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {\n try {\n // This will throw an exception if access to iframe is blocked\n // due to cross-origin restrictions\n styleTarget = styleTarget.contentDocument.head;\n } catch (e) {\n // istanbul ignore next\n styleTarget = null;\n }\n }\n\n memo[target] = styleTarget;\n }\n\n return memo[target];\n}\n/* istanbul ignore next */\n\n\nfunction insertBySelector(insert, style) {\n var target = getTarget(insert);\n\n if (!target) {\n throw new Error(\"Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.\");\n }\n\n target.appendChild(style);\n}\n\nmodule.exports = insertBySelector;","\"use strict\";\n\n/* istanbul ignore next */\nfunction insertStyleElement(options) {\n var element = document.createElement(\"style\");\n options.setAttributes(element, options.attributes);\n options.insert(element, options.options);\n return element;\n}\n\nmodule.exports = insertStyleElement;","\"use strict\";\n\n/* istanbul ignore next */\nfunction setAttributesWithoutAttributes(styleElement, attributes) {\n Object.keys(attributes).forEach(function (key) {\n styleElement.setAttribute(key, attributes[key]);\n });\n}\n\nmodule.exports = setAttributesWithoutAttributes;","\"use strict\";\n\n/* istanbul ignore next */\nvar replaceText = function replaceText() {\n var textStore = [];\n return function replace(index, replacement) {\n textStore[index] = replacement;\n return textStore.filter(Boolean).join(\"\\n\");\n };\n}();\n/* istanbul ignore next */\n\n\nfunction apply(styleElement, index, remove, obj) {\n var css;\n\n if (remove) {\n css = \"\";\n } else {\n css = \"\";\n\n if (obj.supports) {\n css += \"@supports (\".concat(obj.supports, \") {\");\n }\n\n if (obj.media) {\n css += \"@media \".concat(obj.media, \" {\");\n }\n\n var needLayer = typeof obj.layer !== \"undefined\";\n\n if (needLayer) {\n css += \"@layer\".concat(obj.layer.length > 0 ? \" \".concat(obj.layer) : \"\", \" {\");\n }\n\n css += obj.css;\n\n if (needLayer) {\n css += \"}\";\n }\n\n if (obj.media) {\n css += \"}\";\n }\n\n if (obj.supports) {\n css += \"}\";\n }\n } // For old IE\n\n /* istanbul ignore if */\n\n\n if (styleElement.styleSheet) {\n styleElement.styleSheet.cssText = replaceText(index, css);\n } else {\n var cssNode = document.createTextNode(css);\n var childNodes = styleElement.childNodes;\n\n if (childNodes[index]) {\n styleElement.removeChild(childNodes[index]);\n }\n\n if (childNodes.length) {\n styleElement.insertBefore(cssNode, childNodes[index]);\n } else {\n styleElement.appendChild(cssNode);\n }\n }\n}\n\nvar singletonData = {\n singleton: null,\n singletonCounter: 0\n};\n/* istanbul ignore next */\n\nfunction domAPI(options) {\n // eslint-disable-next-line no-undef,no-use-before-define\n var styleIndex = singletonData.singletonCounter++;\n var styleElement = // eslint-disable-next-line no-undef,no-use-before-define\n singletonData.singleton || ( // eslint-disable-next-line no-undef,no-use-before-define\n singletonData.singleton = options.insertStyleElement(options));\n return {\n update: function update(obj) {\n apply(styleElement, styleIndex, false, obj);\n },\n remove: function remove(obj) {\n apply(styleElement, styleIndex, true, obj);\n }\n };\n}\n\nmodule.exports = domAPI;","module.exports=/[\\0-\\x1F\\x7F-\\x9F]/","module.exports=/[\\xAD\\u0600-\\u0605\\u061C\\u06DD\\u070F\\u08E2\\u180E\\u200B-\\u200F\\u202A-\\u202E\\u2060-\\u2064\\u2066-\\u206F\\uFEFF\\uFFF9-\\uFFFB]|\\uD804[\\uDCBD\\uDCCD]|\\uD82F[\\uDCA0-\\uDCA3]|\\uD834[\\uDD73-\\uDD7A]|\\uDB40[\\uDC01\\uDC20-\\uDC7F]/","module.exports=/[!-#%-\\*,-\\/:;\\?@\\[-\\]_\\{\\}\\xA1\\xA7\\xAB\\xB6\\xB7\\xBB\\xBF\\u037E\\u0387\\u055A-\\u055F\\u0589\\u058A\\u05BE\\u05C0\\u05C3\\u05C6\\u05F3\\u05F4\\u0609\\u060A\\u060C\\u060D\\u061B\\u061E\\u061F\\u066A-\\u066D\\u06D4\\u0700-\\u070D\\u07F7-\\u07F9\\u0830-\\u083E\\u085E\\u0964\\u0965\\u0970\\u09FD\\u0A76\\u0AF0\\u0C84\\u0DF4\\u0E4F\\u0E5A\\u0E5B\\u0F04-\\u0F12\\u0F14\\u0F3A-\\u0F3D\\u0F85\\u0FD0-\\u0FD4\\u0FD9\\u0FDA\\u104A-\\u104F\\u10FB\\u1360-\\u1368\\u1400\\u166D\\u166E\\u169B\\u169C\\u16EB-\\u16ED\\u1735\\u1736\\u17D4-\\u17D6\\u17D8-\\u17DA\\u1800-\\u180A\\u1944\\u1945\\u1A1E\\u1A1F\\u1AA0-\\u1AA6\\u1AA8-\\u1AAD\\u1B5A-\\u1B60\\u1BFC-\\u1BFF\\u1C3B-\\u1C3F\\u1C7E\\u1C7F\\u1CC0-\\u1CC7\\u1CD3\\u2010-\\u2027\\u2030-\\u2043\\u2045-\\u2051\\u2053-\\u205E\\u207D\\u207E\\u208D\\u208E\\u2308-\\u230B\\u2329\\u232A\\u2768-\\u2775\\u27C5\\u27C6\\u27E6-\\u27EF\\u2983-\\u2998\\u29D8-\\u29DB\\u29FC\\u29FD\\u2CF9-\\u2CFC\\u2CFE\\u2CFF\\u2D70\\u2E00-\\u2E2E\\u2E30-\\u2E4E\\u3001-\\u3003\\u3008-\\u3011\\u3014-\\u301F\\u3030\\u303D\\u30A0\\u30FB\\uA4FE\\uA4FF\\uA60D-\\uA60F\\uA673\\uA67E\\uA6F2-\\uA6F7\\uA874-\\uA877\\uA8CE\\uA8CF\\uA8F8-\\uA8FA\\uA8FC\\uA92E\\uA92F\\uA95F\\uA9C1-\\uA9CD\\uA9DE\\uA9DF\\uAA5C-\\uAA5F\\uAADE\\uAADF\\uAAF0\\uAAF1\\uABEB\\uFD3E\\uFD3F\\uFE10-\\uFE19\\uFE30-\\uFE52\\uFE54-\\uFE61\\uFE63\\uFE68\\uFE6A\\uFE6B\\uFF01-\\uFF03\\uFF05-\\uFF0A\\uFF0C-\\uFF0F\\uFF1A\\uFF1B\\uFF1F\\uFF20\\uFF3B-\\uFF3D\\uFF3F\\uFF5B\\uFF5D\\uFF5F-\\uFF65]|\\uD800[\\uDD00-\\uDD02\\uDF9F\\uDFD0]|\\uD801\\uDD6F|\\uD802[\\uDC57\\uDD1F\\uDD3F\\uDE50-\\uDE58\\uDE7F\\uDEF0-\\uDEF6\\uDF39-\\uDF3F\\uDF99-\\uDF9C]|\\uD803[\\uDF55-\\uDF59]|\\uD804[\\uDC47-\\uDC4D\\uDCBB\\uDCBC\\uDCBE-\\uDCC1\\uDD40-\\uDD43\\uDD74\\uDD75\\uDDC5-\\uDDC8\\uDDCD\\uDDDB\\uDDDD-\\uDDDF\\uDE38-\\uDE3D\\uDEA9]|\\uD805[\\uDC4B-\\uDC4F\\uDC5B\\uDC5D\\uDCC6\\uDDC1-\\uDDD7\\uDE41-\\uDE43\\uDE60-\\uDE6C\\uDF3C-\\uDF3E]|\\uD806[\\uDC3B\\uDE3F-\\uDE46\\uDE9A-\\uDE9C\\uDE9E-\\uDEA2]|\\uD807[\\uDC41-\\uDC45\\uDC70\\uDC71\\uDEF7\\uDEF8]|\\uD809[\\uDC70-\\uDC74]|\\uD81A[\\uDE6E\\uDE6F\\uDEF5\\uDF37-\\uDF3B\\uDF44]|\\uD81B[\\uDE97-\\uDE9A]|\\uD82F\\uDC9F|\\uD836[\\uDE87-\\uDE8B]|\\uD83A[\\uDD5E\\uDD5F]/","module.exports=/[ \\xA0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000]/","'use strict';\n\nexports.Any = require('./properties/Any/regex');\nexports.Cc = require('./categories/Cc/regex');\nexports.Cf = require('./categories/Cf/regex');\nexports.P = require('./categories/P/regex');\nexports.Z = require('./categories/Z/regex');\n","module.exports=/[\\0-\\uD7FF\\uE000-\\uFFFF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]|[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?:[^\\uD800-\\uDBFF]|^)[\\uDC00-\\uDFFF]/","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\tid: moduleId,\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.g = (function() {\n\tif (typeof globalThis === 'object') return globalThis;\n\ttry {\n\t\treturn this || new Function('return this')();\n\t} catch (e) {\n\t\tif (typeof window === 'object') return window;\n\t}\n})();","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/**\n * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license\n */\n\n/**\n * @module utils/spy\n */\n\n/**\n * Creates a spy function (ala Sinon.js) that can be used to inspect call to it.\n *\n * The following are the present features:\n *\n * * spy.called: property set to `true` if the function has been called at least once.\n *\n * @returns {Function} The spy function.\n */\nfunction spy() {\n\treturn function spy() {\n\t\tspy.called = true;\n\t};\n}\n\nexport default spy;\n","/**\n * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license\n */\n\n/**\n * @module utils/eventinfo\n */\n\nimport spy from './spy';\n\n/**\n * The event object passed to event callbacks. It is used to provide information about the event as well as a tool to\n * manipulate it.\n */\nexport default class EventInfo {\n\t/**\n\t * @param {Object} source The emitter.\n\t * @param {String} name The event name.\n\t */\n\tconstructor( source, name ) {\n\t\t/**\n\t\t * The object that fired the event.\n\t\t *\n\t\t * @readonly\n\t\t * @member {Object}\n\t\t */\n\t\tthis.source = source;\n\n\t\t/**\n\t\t * The event name.\n\t\t *\n\t\t * @readonly\n\t\t * @member {String}\n\t\t */\n\t\tthis.name = name;\n\n\t\t/**\n\t\t * Path this event has followed. See {@link module:utils/emittermixin~EmitterMixin#delegate}.\n\t\t *\n\t\t * @readonly\n\t\t * @member {Array.}\n\t\t */\n\t\tthis.path = [];\n\n\t\t// The following methods are defined in the constructor because they must be re-created per instance.\n\n\t\t/**\n\t\t * Stops the event emitter to call further callbacks for this event interaction.\n\t\t *\n\t\t * @method #stop\n\t\t */\n\t\tthis.stop = spy();\n\n\t\t/**\n\t\t * Removes the current callback from future interactions of this event.\n\t\t *\n\t\t * @method #off\n\t\t */\n\t\tthis.off = spy();\n\n\t\t/**\n\t\t * The value which will be returned by {@link module:utils/emittermixin~EmitterMixin#fire}.\n\t\t *\n\t\t * It's `undefined` by default and can be changed by an event listener:\n\t\t *\n\t\t *\t\tdataController.fire( 'getSelectedContent', ( evt ) => {\n\t\t *\t\t\t// This listener will make `dataController.fire( 'getSelectedContent' )`\n\t\t *\t\t\t// always return an empty DocumentFragment.\n\t\t *\t\t\tevt.return = new DocumentFragment();\n\t\t *\n\t\t *\t\t\t// Make sure no other listeners are executed.\n\t\t *\t\t\tevt.stop();\n\t\t *\t\t} );\n\t\t *\n\t\t * @member #return\n\t\t */\n\t}\n}\n","/**\n * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license\n */\n\n/**\n * @module utils/uid\n */\n\n// A hash table of hex numbers to avoid using toString() in uid() which is costly.\n// [ '00', '01', '02', ..., 'fe', 'ff' ]\nconst HEX_NUMBERS = new Array( 256 ).fill()\n\t.map( ( val, index ) => ( '0' + ( index ).toString( 16 ) ).slice( -2 ) );\n\n/**\n * Returns a unique id. The id starts with an \"e\" character and a randomly generated string of\n * 32 alphanumeric characters.\n *\n * **Note**: The characters the unique id is built from correspond to the hex number notation\n * (from \"0\" to \"9\", from \"a\" to \"f\"). In other words, each id corresponds to an \"e\" followed\n * by 16 8-bit numbers next to each other.\n *\n * @returns {String} An unique id string.\n */\nexport default function uid() {\n\t// Let's create some positive random 32bit integers first.\n\t//\n\t// 1. Math.random() is a float between 0 and 1.\n\t// 2. 0x100000000 is 2^32 = 4294967296.\n\t// 3. >>> 0 enforces integer (in JS all numbers are floating point).\n\t//\n\t// For instance:\n\t//\t\tMath.random() * 0x100000000 = 3366450031.853859\n\t// but\n\t//\t\tMath.random() * 0x100000000 >>> 0 = 3366450031.\n\tconst r1 = Math.random() * 0x100000000 >>> 0;\n\tconst r2 = Math.random() * 0x100000000 >>> 0;\n\tconst r3 = Math.random() * 0x100000000 >>> 0;\n\tconst r4 = Math.random() * 0x100000000 >>> 0;\n\n\t// Make sure that id does not start with number.\n\treturn 'e' +\n\t\tHEX_NUMBERS[ r1 >> 0 & 0xFF ] +\n\t\tHEX_NUMBERS[ r1 >> 8 & 0xFF ] +\n\t\tHEX_NUMBERS[ r1 >> 16 & 0xFF ] +\n\t\tHEX_NUMBERS[ r1 >> 24 & 0xFF ] +\n\t\tHEX_NUMBERS[ r2 >> 0 & 0xFF ] +\n\t\tHEX_NUMBERS[ r2 >> 8 & 0xFF ] +\n\t\tHEX_NUMBERS[ r2 >> 16 & 0xFF ] +\n\t\tHEX_NUMBERS[ r2 >> 24 & 0xFF ] +\n\t\tHEX_NUMBERS[ r3 >> 0 & 0xFF ] +\n\t\tHEX_NUMBERS[ r3 >> 8 & 0xFF ] +\n\t\tHEX_NUMBERS[ r3 >> 16 & 0xFF ] +\n\t\tHEX_NUMBERS[ r3 >> 24 & 0xFF ] +\n\t\tHEX_NUMBERS[ r4 >> 0 & 0xFF ] +\n\t\tHEX_NUMBERS[ r4 >> 8 & 0xFF ] +\n\t\tHEX_NUMBERS[ r4 >> 16 & 0xFF ] +\n\t\tHEX_NUMBERS[ r4 >> 24 & 0xFF ];\n}\n","/**\n * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license\n */\n\n/**\n * @module utils/priorities\n */\n\n/**\n * String representing a priority value.\n *\n * @typedef {'highest'|'high'|'normal'|'low'|'lowest'} module:utils/priorities~PriorityString\n */\n\n/**\n * Provides group of constants to use instead of hardcoding numeric priority values.\n *\n * @namespace\n */\nconst priorities = {\n\t/**\n\t * Converts a string with priority name to it's numeric value. If `Number` is given, it just returns it.\n\t *\n\t * @static\n\t * @param {module:utils/priorities~PriorityString|Number} priority Priority to convert.\n\t * @returns {Number} Converted priority.\n\t */\n\tget( priority ) {\n\t\tif ( typeof priority != 'number' ) {\n\t\t\treturn this[ priority ] || this.normal;\n\t\t} else {\n\t\t\treturn priority;\n\t\t}\n\t},\n\n\thighest: 100000,\n\thigh: 1000,\n\tnormal: 0,\n\tlow: -1000,\n\tlowest: -100000\n};\n\nexport default priorities;\n","/**\n * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license\n */\n\n/**\n * @module utils/ckeditorerror\n */\n\n/* globals console */\n\n/**\n * URL to the documentation with error codes.\n */\nexport const DOCUMENTATION_URL =\n\t'https://ckeditor.com/docs/ckeditor5/latest/framework/guides/support/error-codes.html';\n\n/**\n * The CKEditor error class.\n *\n * You should throw `CKEditorError` when:\n *\n * * An unexpected situation occurred and the editor (most probably) will not work properly. Such exception will be handled\n * by the {@link module:watchdog/watchdog~Watchdog watchdog} (if it is integrated),\n * * If the editor is incorrectly integrated or the editor API is used in the wrong way. This way you will give\n * feedback to the developer as soon as possible. Keep in mind that for common integration issues which should not\n * stop editor initialization (like missing upload adapter, wrong name of a toolbar component) we use\n * {@link module:utils/ckeditorerror~logWarning `logWarning()`} and\n * {@link module:utils/ckeditorerror~logError `logError()`}\n * to improve developers experience and let them see the a working editor as soon as possible.\n *\n *\t\t/**\n *\t\t * Error thrown when a plugin cannot be loaded due to JavaScript errors, lack of plugins with a given name, etc.\n *\t\t *\n *\t\t * @error plugin-load\n *\t\t * @param pluginName The name of the plugin that could not be loaded.\n *\t\t * @param moduleName The name of the module which tried to load this plugin.\n *\t\t * /\n *\t\tthrow new CKEditorError( 'plugin-load', {\n *\t\t\tpluginName: 'foo',\n *\t\t\tmoduleName: 'bar'\n *\t\t} );\n *\n * @extends Error\n */\nexport default class CKEditorError extends Error {\n\t/**\n\t * Creates an instance of the CKEditorError class.\n\t *\n\t * @param {String} errorName The error id in an `error-name` format. A link to this error documentation page will be added\n\t * to the thrown error's `message`.\n\t * @param {Object|null} context A context of the error by which the {@link module:watchdog/watchdog~Watchdog watchdog}\n\t * is able to determine which editor crashed. It should be an editor instance or a property connected to it. It can be also\n\t * a `null` value if the editor should not be restarted in case of the error (e.g. during the editor initialization).\n\t * The error context should be checked using the `areConnectedThroughProperties( editor, context )` utility\n\t * to check if the object works as the context.\n\t * @param {Object} [data] Additional data describing the error. A stringified version of this object\n\t * will be appended to the error message, so the data are quickly visible in the console. The original\n\t * data object will also be later available under the {@link #data} property.\n\t */\n\tconstructor( errorName, context, data ) {\n\t\tsuper( getErrorMessage( errorName, data ) );\n\n\t\t/**\n\t\t * @type {String}\n\t\t */\n\t\tthis.name = 'CKEditorError';\n\n\t\t/**\n\t\t * A context of the error by which the Watchdog is able to determine which editor crashed.\n\t\t *\n\t\t * @type {Object|null}\n\t\t */\n\t\tthis.context = context;\n\n\t\t/**\n\t\t * The additional error data passed to the constructor. Undefined if none was passed.\n\t\t *\n\t\t * @type {Object|undefined}\n\t\t */\n\t\tthis.data = data;\n\t}\n\n\t/**\n\t * Checks if the error is of the `CKEditorError` type.\n\t * @returns {Boolean}\n\t */\n\tis( type ) {\n\t\treturn type === 'CKEditorError';\n\t}\n\n\t/**\n\t * A utility that ensures that the thrown error is a {@link module:utils/ckeditorerror~CKEditorError} one.\n\t * It is useful when combined with the {@link module:watchdog/watchdog~Watchdog} feature, which can restart the editor in case\n\t * of a {@link module:utils/ckeditorerror~CKEditorError} error.\n\t *\n\t * @static\n\t * @param {Error} err The error to rethrow.\n\t * @param {Object} context An object connected through properties with the editor instance. This context will be used\n\t * by the watchdog to verify which editor should be restarted.\n\t */\n\tstatic rethrowUnexpectedError( err, context ) {\n\t\tif ( err.is && err.is( 'CKEditorError' ) ) {\n\t\t\tthrow err;\n\t\t}\n\n\t\t/**\n\t\t * An unexpected error occurred inside the CKEditor 5 codebase. This error will look like the original one\n\t\t * to make the debugging easier.\n\t\t *\n\t\t * This error is only useful when the editor is initialized using the {@link module:watchdog/watchdog~Watchdog} feature.\n\t\t * In case of such error (or any {@link module:utils/ckeditorerror~CKEditorError} error) the watchdog should restart the editor.\n\t\t *\n\t\t * @error unexpected-error\n\t\t */\n\t\tconst error = new CKEditorError( err.message, context );\n\n\t\t// Restore the original stack trace to make the error look like the original one.\n\t\t// See https://github.com/ckeditor/ckeditor5/issues/5595 for more details.\n\t\terror.stack = err.stack;\n\n\t\tthrow error;\n\t}\n}\n\n/**\n * Logs a warning to the console with a properly formatted message and adds a link to the documentation.\n * Use whenever you want to log a warning to the console.\n *\n *\t\t/**\n *\t\t * There was a problem processing the configuration of the toolbar. The item with the given\n *\t\t * name does not exist, so it was omitted when rendering the toolbar.\n *\t\t *\n *\t\t * @error toolbarview-item-unavailable\n *\t\t * @param {String} name The name of the component.\n *\t\t * /\n *\t\tlogWarning( 'toolbarview-item-unavailable', { name } );\n *\n * See also {@link module:utils/ckeditorerror~CKEditorError} for an explanation when to throw an error and when to log\n * a warning or an error to the console.\n *\n * @param {String} errorName The error name to be logged.\n * @param {Object} [data] Additional data to be logged.\n */\nexport function logWarning( errorName, data ) {\n\tconsole.warn( ...formatConsoleArguments( errorName, data ) );\n}\n\n/**\n * Logs an error to the console with a properly formatted message and adds a link to the documentation.\n * Use whenever you want to log an error to the console.\n *\n *\t\t/**\n *\t\t * There was a problem processing the configuration of the toolbar. The item with the given\n *\t\t * name does not exist, so it was omitted when rendering the toolbar.\n *\t\t *\n *\t\t * @error toolbarview-item-unavailable\n *\t\t * @param {String} name The name of the component.\n *\t\t * /\n *\t\t logError( 'toolbarview-item-unavailable', { name } );\n *\n * **Note**: In most cases logging a warning using {@link module:utils/ckeditorerror~logWarning} is enough.\n *\n * See also {@link module:utils/ckeditorerror~CKEditorError} for an explanation when to use each method.\n *\n * @param {String} errorName The error name to be logged.\n * @param {Object} [data] Additional data to be logged.\n */\nexport function logError( errorName, data ) {\n\tconsole.error( ...formatConsoleArguments( errorName, data ) );\n}\n\n// Returns formatted link to documentation message.\n//\n// @private\n// @param {String} errorName\n// @returns {string}\nfunction getLinkToDocumentationMessage( errorName ) {\n\treturn `\\nRead more: ${ DOCUMENTATION_URL }#error-${ errorName }`;\n}\n\n// Returns formatted error message.\n//\n// @private\n// @param {String} errorName\n// @param {Object} [data]\n// @returns {string}\nfunction getErrorMessage( errorName, data ) {\n\tconst processedObjects = new WeakSet();\n\tconst circularReferencesReplacer = ( key, value ) => {\n\t\tif ( typeof value === 'object' && value !== null ) {\n\t\t\tif ( processedObjects.has( value ) ) {\n\t\t\t\treturn `[object ${ value.constructor.name }]`;\n\t\t\t}\n\n\t\t\tprocessedObjects.add( value );\n\t\t}\n\n\t\treturn value;\n\t};\n\n\tconst stringifiedData = data ? ` ${ JSON.stringify( data, circularReferencesReplacer ) }` : '';\n\tconst documentationLink = getLinkToDocumentationMessage( errorName );\n\n\treturn errorName + stringifiedData + documentationLink;\n}\n\n// Returns formatted console error arguments.\n//\n// @private\n// @param {String} errorName\n// @param {Object} [data]\n// @returns {Array}\nfunction formatConsoleArguments( errorName, data ) {\n\tconst documentationMessage = getLinkToDocumentationMessage( errorName );\n\n\treturn data ? [ errorName, data, documentationMessage ] : [ errorName, documentationMessage ];\n}\n","/**\n * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license\n */\n\n/**\n * @module utils/version\n */\n\n/* globals window, global */\n\nimport CKEditorError from './ckeditorerror';\n\nconst version = '32.0.0';\n\nexport default version;\n\n/* istanbul ignore next */\nconst windowOrGlobal = typeof window === 'object' ? window : global;\n\n/* istanbul ignore next */\nif ( windowOrGlobal.CKEDITOR_VERSION ) {\n\t/**\n\t * This error is thrown when due to a mistake in how CKEditor 5 was installed or initialized, some\n\t * of its modules were duplicated (evaluated and executed twice). Module duplication leads to inevitable runtime\n\t * errors.\n\t *\n\t * There are many situations in which some modules can be loaded twice. In the worst case scenario,\n\t * you may need to check your project for each of these issues and fix them all.\n\t *\n\t * # Trying to add a plugin to an existing build\n\t *\n\t * If you import an existing CKEditor 5 build and a plugin like this:\n\t *\n\t *\t\timport ClassicEditor from '@ckeditor/ckeditor5-build-classic';\n\t *\t\timport Highlight from '@ckeditor/ckeditor5-highlight/src/highlight';\n\t *\n\t * Then your project loads some CKEditor 5 packages twice. How does it happen?\n\t *\n\t * The build package contains a file which is already compiled with webpack. This means\n\t * that it contains all the necessary code from e.g. `@ckeditor/ckeditor5-engine` and `@ckeditor/ckeditor5-utils`.\n\t *\n\t * However, the `Highlight` plugin imports some of the modules from these packages, too. If you ask webpack to\n\t * build such a project, you will end up with the modules being included (and run) twice — first, because they are\n\t * included inside the build package, and second, because they are required by the `Highlight` plugin.\n\t *\n\t * Therefore, **you must never add plugins to an existing build** unless your plugin has no dependencies.\n\t *\n\t * Adding plugins to a build is done by taking the source version of this build (so, before it was built with webpack)\n\t * and adding plugins there. In this situation, webpack will know that it only needs to load each plugin once.\n\t *\n\t * Read more in the {@glink builds/guides/integration/installing-plugins \"Installing plugins\"} guide.\n\t *\n\t * # Confused an editor build with an editor implementation\n\t *\n\t * This scenario is very similar to the previous one, but has a different origin.\n\t *\n\t * Let's assume that you wanted to use CKEditor 5 from source, as explained in the\n\t * {@glink builds/guides/integration/advanced-setup#scenario-2-building-from-source \"Building from source\"} section\n\t * or in the {@glink framework/guides/quick-start \"Quick start\"} guide of CKEditor 5 Framework.\n\t *\n\t * The correct way to do so is to import an editor and plugins and run them together like this:\n\t *\n\t *\t\timport ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';\n\t *\t\timport Essentials from '@ckeditor/ckeditor5-essentials/src/essentials';\n\t *\t\timport Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';\n\t *\t\timport Bold from '@ckeditor/ckeditor5-basic-styles/src/bold';\n\t *\t\timport Italic from '@ckeditor/ckeditor5-basic-styles/src/italic';\n\t *\n\t *\t\tClassicEditor\n\t *\t\t\t.create( document.querySelector( '#editor' ), {\n\t *\t\t\t\tplugins: [ Essentials, Paragraph, Bold, Italic ],\n\t *\t\t\t\ttoolbar: [ 'bold', 'italic' ]\n\t *\t\t\t} )\n\t *\t\t\t.then( editor => {\n\t *\t\t\t\tconsole.log( 'Editor was initialized', editor );\n\t *\t\t\t} )\n\t *\t\t\t.catch( error => {\n\t *\t\t\t\tconsole.error( error.stack );\n\t *\t\t\t} );\n\t *\n\t * However, you might have mistakenly imported a build instead of the source `ClassicEditor`. In this case\n\t * your imports will look like this:\n\t *\n\t *\t\timport ClassicEditor from '@ckeditor/ckeditor5-build-classic';\n\t *\t\timport Essentials from '@ckeditor/ckeditor5-essentials/src/essentials';\n\t *\t\timport Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';\n\t *\t\timport Bold from '@ckeditor/ckeditor5-basic-styles/src/bold';\n\t *\t\timport Italic from '@ckeditor/ckeditor5-basic-styles/src/italic';\n\t *\n\t * This creates the same situation as in the previous section because you use a build together with source plugins.\n\t *\n\t * Remember: `@ckeditor/ckeditor5-build-*` packages contain editor builds and `@ckeditor/ckeditor5-editor-*` contain source editors.\n\t *\n\t * # Loading two or more builds on one page\n\t *\n\t * If you use CKEditor 5 builds, you might have loaded two (or more) `ckeditor.js` files on one web page.\n\t * Check your web page for duplicated `